diff --git a/common/src/main/ets/model/Constants.ts b/common/src/main/ets/model/Constants.ts index b932fe1be35c6f5ad93b58df60221e5194bafe72..b4a11b2ba2e0afba39a46a810d9661cf1d2a7013 100644 --- a/common/src/main/ets/model/Constants.ts +++ b/common/src/main/ets/model/Constants.ts @@ -115,8 +115,8 @@ export class Constants { static readonly SHOW_TOAST_TIMEOUT: number = 200; static readonly COUNTDOWN_ALARM_TO_FAIL: number = 26; static readonly COUNTDOWN_TO_FAIL: number = 25; - static readonly CANVAS_MAX_WIDTH: number = 441; - static readonly CANVAS_MAX_HEIGHT: number = 506; + static readonly CANVAS_MAX_WIDTH: number = 432; + static readonly CANVAS_MAX_HEIGHT: number = 302; static readonly MAX_PIXELMAP: number = 33554432; static readonly MAX_PAGES: number = 100; static readonly MAX_CUSTOM_PRINT_RANGE_LENGTH: number = 50; diff --git a/entry/src/main/ets/Common/Utils/FileUtil.ts b/entry/src/main/ets/Common/Utils/FileUtil.ts index ce7cd546d89a7d3683600735d51b83b29a88ade2..bb5ddbe27d773ed2c4a19953e52125f26a0f3b17 100644 --- a/entry/src/main/ets/Common/Utils/FileUtil.ts +++ b/entry/src/main/ets/Common/Utils/FileUtil.ts @@ -155,6 +155,8 @@ export default class FileUtil { return imageArray; } for (let uri of fileList) { + let uriArr = uri.split(FILE_SEPARATOR); + let fileName = uriArr[uriArr.length-1]; let file = undefined; try { file = Fileio.openSync(uri, Constants.READ_WRITE); @@ -183,7 +185,7 @@ export default class FileUtil { errorCount++; continue; } - imageArray.push(new FileModel( file.fd, file.fd, uri, + imageArray.push(new FileModel( file.fd, fileName, uri, imageInfo.size.width, imageInfo.size.height, imageSource)); Log.debug(TAG, 'initImageData imageArray: ', JSON.stringify(imageArray)); } diff --git a/entry/src/main/ets/MainAbility/JobManagerAbility.ts b/entry/src/main/ets/MainAbility/JobManagerAbility.ts index 4a5d6c976c00ad2104ab58bd77a033e015f16fd6..c059041ba874c8c3e6b7efb92bb750128ee0d756 100644 --- a/entry/src/main/ets/MainAbility/JobManagerAbility.ts +++ b/entry/src/main/ets/MainAbility/JobManagerAbility.ts @@ -39,11 +39,11 @@ export default class JobManagerAbility extends UIAbility { onWindowStageCreate(windowStage): void { // Main window is created, set main page for this ability Log.info(TAG, 'onWindowStageCreate'); - windowStage.getMainWindow().then((window) => { - window.resetSize(vp2px(Constants.JOB_WINDOW_WIDTH), vp2px(Constants.JOB_WINDOW_HEIGHT)); - }).catch((err) => { - Log.error(TAG, 'Failed to obtain the main window. Cause: ' + JSON.stringify(err)); - }); + // windowStage.getMainWindow().then((window) => { + // window.resetSize(vp2px(Constants.MAIN_WINDOW_WIDTH), vp2px(Constants.MAIN_WINDOW_HEIGHT)); + // }).catch((err) => { + // Log.error(TAG, 'Failed to obtain the main window. Cause: ' + JSON.stringify(err)); + // }); windowStage.setUIContent(this.context, 'pages/JobManagerPage', null); } diff --git a/entry/src/main/ets/pages/JobManagerPage.ets b/entry/src/main/ets/pages/JobManagerPage.ets index b87f55353103e8119aaee69011bf9a2bb5096dfc..94d87505a48286ed0aea352e1363f86d5c936e76 100644 --- a/entry/src/main/ets/pages/JobManagerPage.ets +++ b/entry/src/main/ets/pages/JobManagerPage.ets @@ -117,7 +117,8 @@ struct JobManagerPage { }); }) } - .width($r('app.float.print_job_width')) + .width('100%') + .height('100%') .backgroundColor(Color.White) .alignItems(HorizontalAlign.Center) diff --git a/entry/src/main/ets/pages/PrintPage.ets b/entry/src/main/ets/pages/PrintPage.ets index d5d2627eed3dd3260d98bde6b0ca3d781a6d3c2c..04508910c0c606895efd4151faa3777ccb64f82a 100644 --- a/entry/src/main/ets/pages/PrintPage.ets +++ b/entry/src/main/ets/pages/PrintPage.ets @@ -408,6 +408,9 @@ struct Index { e.stopPropagation() }) Text($r('app.string.index_from')) + .maxLines(Constants.NUMBER_2) + .textOverflow({ overflow: TextOverflow.Ellipsis}) + .textAlign(TextAlign.Start) .fontSize($r('app.float.font_size_body2')) .key('Index_Text_from_pageRange') TextInput({ text: this.startPageStr }) @@ -467,7 +470,12 @@ struct Index { e.stopPropagation() }) - Text($r('app.string.index_to')).fontSize($r('app.float.font_size_body2')).key('Index_Text_to_pageRange') + Text($r('app.string.index_to')) + .maxLines(Constants.NUMBER_2) + .textOverflow({ overflow: TextOverflow.Ellipsis}) + .textAlign(TextAlign.Start) + .fontSize($r('app.float.font_size_body2')) + .key('Index_Text_to_pageRange') TextInput({ text: this.endPageStr }) .width($r('app.float.textInput_pageRange_width')) .height($r('app.float.params_comp_height')) @@ -621,29 +629,31 @@ struct Index { MediaTypeSelection().visibility(!this.isPhotoEnabled ? Visibility.None : Visibility.Visible) Row() { Blank() - Checkbox() - .select(this.isBorderless) - .width($r('app.float.image_comp_width')) - .height($r('app.float.image_comp_height')) - .enabled(this.currentMediaType.obj === MediaType.PHOTO) - .key('Index_Checkbox_borderless') - .onChange((value: boolean) => { - if (value) { - this.showToast($r('app.string.borderless_enable_toast')) - } - this.isBorderless = value - }) + Row(){ + Checkbox() + .select(this.isBorderless) + .width($r('app.float.image_comp_width')) + .height($r('app.float.image_comp_height')) + .enabled(this.currentMediaType.obj === MediaType.PHOTO) + .key('Index_Checkbox_borderless') + .onChange((value: boolean) => { + if (value) { + this.showToast($r('app.string.borderless_enable_toast')) + } + this.isBorderless = value + }) + } + .onClick(() => { + if (this.currentMediaType.obj !== MediaType.PHOTO) { + this.showToast($r('app.string.borderless_type_toast')) + } + }) Text($r('app.string.index_borderless')) .fontSize($r('app.float.font_size_body2')) .width($r('app.float.text_borderless_width')) .opacity(this.currentMediaType.obj === MediaType.PHOTO ? Constants.NUMBER_1 : $r('app.float.disable_opacity')) .key('Index_Text_borderless') } - .onClick(() => { - if (this.currentMediaType.obj !== MediaType.PHOTO) { - this.showToast($r('app.string.borderless_type_toast')) - } - }) .visibility(!this.isPhotoEnabled? Visibility.None : Visibility.Visible) .height($r('app.float.params_row_height')) .width($r('app.float.params_row_width')) @@ -899,13 +909,23 @@ struct Index { print.on('extInfoChange', (extensionId: string, info: string) => { let extInfo = JSON.parse(info) Log.info(TAG, 'extInfoChange: ', info) - if (extInfo.code === ErrorCode.GET_CAPS_ERROR) { - this.adapter.getPrinterDiscCtl().queryPrinterCapability(this.printer.printerId) - } else if (extInfo.code === ErrorCode.CONNECTION_POP) { - if (!CheckEmptyUtils.isEmpty(this.printer)) { - if (this.printer.printerId !== this.usedPrinterId) + if (CheckEmptyUtils.isEmpty(this.printer)){ + Log.info(TAG, 'invalid printer!') + return; + } + switch (extInfo.code){ + case ErrorCode.IPP_CONNECT_ERROR: + this.connectionFailed(); + break; + case ErrorCode.GET_CAPS_ERROR: + this.adapter.getPrinterDiscCtl().queryPrinterCapability(this.printer.printerId); + break; + case ErrorCode.CONNECTION_POP: + if (this.printer.printerId !== this.usedPrinterId){ this.connectFlag = !this.connectFlag - } + } + default: + break; } }) } @@ -1170,12 +1190,16 @@ struct Index { async loadImageSources() { Log.info(TAG, 'loadImageSources start') if (this.jobFileList) { + this.fileNum = this.jobFileList.length; this.imageSources = await FileUtil.initImageData(this.checkMaxPages(this.jobFileList)); } else { // @ts-ignore await print.queryPrintJobById(this.jobId).then(async (printJob) => { - Log.debug(TAG, 'queryPrintJobById printJob: ', JSON.stringify(printJob)); - this.imageSources = await FileUtil.initFdImageData(printJob.fdList); + if (!CheckEmptyUtils.isEmpty(printJob) && !CheckEmptyUtils.isEmptyArr(printJob.fdList)) { + this.fileNum = printJob.fdList.length; + Log.debug(TAG, 'queryPrintJobById printJob: ', JSON.stringify(printJob)); + this.imageSources = await FileUtil.initFdImageData(printJob.fdList); + } }) } Log.debug(TAG, "loadImageSources imageSources: ", JSON.stringify(this.imageSources)) @@ -1373,7 +1397,8 @@ struct Index { Log.error(TAG, 'imageSource is error') continue; }; - pixelMap = await imageSource.createPixelMap(); + const editResult: boolean = orientation === Constants.NUMBER_1 ? true : false; + pixelMap = await imageSource.createPixelMap({isEdit: editResult}); if (CheckEmptyUtils.isEmpty(pixelMap)) { Log.error(TAG, 'pixelMap is error') continue; @@ -1386,7 +1411,7 @@ struct Index { //保存图片 Log.info(TAG, 'begin createDataShareUri'); if (this.firstFileName === undefined) { - this.firstFileName = '图片'//暂时不支持获取文件名 + this.firstFileName = imageModel.name; Log.info(TAG, 'init firstFileName:' + this.firstFileName) } let fileName = uuidGenerator() + Constants.JPEG_SUFFIX; @@ -1405,6 +1430,9 @@ struct Index { if (canvasPixelMap !== undefined) { canvasPixelMap.release(); } + if (imageSource !== undefined) { + imageSource.release(); + } } } Log.info(TAG, 'exit saveImage'); @@ -1442,7 +1470,7 @@ struct Index { } let option = JSON.stringify(ops); - this.printJob = new PrintJob(jobFiles,fileList,this.jobId,this.printer.printerId,state,this.printCount,Constants.NUMBER_0,this.printerRange,true,this.printerPageSize,true, + this.printJob = new PrintJob(jobFiles,fileList,this.jobId,this.printer.printerId,state,Constants.NUMBER_0,this.printCount,this.printerRange,true,this.printerPageSize,true, this.colorMode,this.currentDuplex.obj,new PrintMargin(),null,option); let printMargin = new PrintMargin(); printMargin.top = Constants.NUMBER_0; @@ -1468,11 +1496,8 @@ struct Index { jobId: this.jobId }, } - let options = { - windowMode: Constants.WINDOW_FLOAT_MODE, - } // @ts-ignore - this.abilityContext.startAbility(jobAbilityWant, options).then(() => { + this.abilityContext.startAbility(jobAbilityWant).then(() => { Log.info(TAG,'startJobManagerAbility') this.canPrint = false; this.abilityContext.terminateSelf().then((data) => { diff --git a/entry/src/main/ets/pages/component/PreviewComponent.ets b/entry/src/main/ets/pages/component/PreviewComponent.ets index 6c1d25a1c0ced12a04c7e60d101cec9adfbfd0a1..aebd544027c08bff44e82d163eaa7d09be4ee6d5 100644 --- a/entry/src/main/ets/pages/component/PreviewComponent.ets +++ b/entry/src/main/ets/pages/component/PreviewComponent.ets @@ -42,9 +42,9 @@ export struct PreviewComponent { @State isPreviewFailed: boolean = false; @State @Watch('loadCurrentPix')currentPixelMap: PixelMap = undefined; @State imageOrientation: number = PageDirection.VERTICAL; - @State canvasWidth: number = 472 / canvasScale; - @State canvasHeight: number = 668 / canvasScale; - @State canvasRatio: number = 472 / 668;//width/height + @State canvasWidth: number = 313 / canvasScale; + @State canvasHeight: number = 444 / canvasScale; + @State canvasRatio: number = 313 / 444;//width/height @State offCanvasWidth: number = this.canvasWidth * to300DPI * canvasScale; @State offCanvasHeight: number = this.canvasHeight * to300DPI * canvasScale; @State imageWidth: number = Constants.NUMBER_0; @@ -222,6 +222,8 @@ export struct PreviewComponent { aboutToAppear() { if(this.imageSources !== undefined){ this.handleImage() + }else{ + this.checkCanvasWidth() } } @@ -318,6 +320,10 @@ export struct PreviewComponent { *界面高度调整 */ onHeightLoad(){ + Log.info(TAG,'onHeightLoad:'+this.previewCompHeight) + if (this.imageSources === undefined ){ + return; + } if(this.previewCompHeight){ this.handleImage(); } diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json index 0e8229ade9b0740b41eb3b5518f1abafb7dfc7f3..460424fec5c4bc1817bf5aca28f57fc86639d644 100644 --- a/entry/src/main/resources/base/element/float.json +++ b/entry/src/main/resources/base/element/float.json @@ -202,7 +202,7 @@ }, { "name":"print_job_height", - "value":"374vp" + "value":"627vp" }, { "name":"print_job_title_height",