diff --git a/build-profile.json5 b/build-profile.json5 index a26322be009dee037180d202476580c798b5908b..64b3e22fc4023b7431ba78db3237f5829a3c5618 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -1,12 +1,25 @@ { "app": { "signingConfigs": [ + { + "name": "default", + "type": "HarmonyOS", + "material": { + "certpath": "C:\\Users\\Admin\\.ohos\\config\\default_graphic-creation_CoZKp-2jHSgv7qL93_O9eWzOx7gwNk3v_BY3lWgnaC4=.cer", + "keyAlias": "debugKey", + "keyPassword": "0000001B1155C8803A7E4840C7F65F3FE14F0A32B604D77F74EEA0FE28029AE3575ECB9759D1C6252A2F7D", + "profile": "C:\\Users\\Admin\\.ohos\\config\\default_graphic-creation_CoZKp-2jHSgv7qL93_O9eWzOx7gwNk3v_BY3lWgnaC4=.p7b", + "signAlg": "SHA256withECDSA", + "storeFile": "C:\\Users\\Admin\\.ohos\\config\\default_graphic-creation_CoZKp-2jHSgv7qL93_O9eWzOx7gwNk3v_BY3lWgnaC4=.p12", + "storePassword": "0000001B45F2615CFB8CD5C90270C5B9FFA7A648181684C870CC778027DD4E5F5951132D2B75A4A420733C" + } + } ], "products": [ { "name": "default", "signingConfig": "default", - "compatibleSdkVersion": "5.0.0(12)", + "compatibleSdkVersion": "5.0.4(16)", "runtimeOS": "HarmonyOS" } ], diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 03add71fa6bc6a350686e7572f6b72a7821286f3..d9a4faff7e97d1d1648ba7dd16df185a5d54b16b 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -123,6 +123,7 @@ export default class EntryAbility extends UIAbility { Logger.info(this.tag, '%{public}s', 'Ability onWindowStageCreate'); windowStage.loadContent('pages/Index', (err) => { + AppStorage.setOrCreate('uiContext', windowStage.getMainWindowSync().getUIContext()); if (err.code) { Logger.info(this.tag, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; diff --git a/entry/src/main/ets/pages/GraphicCreationPage.ets b/entry/src/main/ets/pages/GraphicCreationPage.ets index d3be547f9e9644bd161605e77d5d1346ab55d7a8..c2a9d4b9f9e64bc59107dd0a26cfd2357ba6a435 100644 --- a/entry/src/main/ets/pages/GraphicCreationPage.ets +++ b/entry/src/main/ets/pages/GraphicCreationPage.ets @@ -48,11 +48,11 @@ struct GraphicCreationPage { $r('app.string.category_4')]; @State selectedUri: string[] = []; @State isShow: boolean = false; - private context = getContext(this) as common.UIAbilityContext; + private context = this.getUIContext().getHostContext() as common.UIAbilityContext; aboutToAppear() { - UIUtils.setWindowFullScreen(getContext(this), true); - UIUtils.setWindowBackGroundColor(getContext(this), CommonConstants.WHITE_COLOR); + UIUtils.setWindowFullScreen(this.getUIContext().getHostContext()!, true); + UIUtils.setWindowBackGroundColor(this.getUIContext().getHostContext()!, CommonConstants.WHITE_COLOR); this.imageInfoArr.forEach((imageInfo: ImageInfo) => { this.selectedData.addData(imageInfo.imagePixelMap); }); @@ -160,7 +160,7 @@ struct GraphicCreationPage { }) .onClick(() => { if (this.imageInfoArr.length === CommonConstants.LIMIT_PICKER_NUM) { - promptAction.showToast({ + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.toast_picker_limit'), duration: DataUtils.fromResToNumber($r('app.float.show_DELAY_TIME')), }); @@ -287,7 +287,7 @@ struct GraphicCreationPage { .onClick(() => { let uri: string = '' if (this.imageInfoArr.length > 0) { - uri = fileUri.getUriFromPath(`${getContext().distributedFilesDir}/${this.imageInfoArr[0].imageName}`); + uri = fileUri.getUriFromPath(`${this.getUIContext().getHostContext()!.distributedFilesDir}/${this.imageInfoArr[0].imageName}`); } const waterFlowData: WaterFlowData = { coverPath: uri, @@ -296,10 +296,10 @@ struct GraphicCreationPage { author: $r('app.string.author_2') } AppStorage.setOrCreate(CommonConstants.KEY_POST_CONTENT, waterFlowData); - router.back({ + this.getUIContext().getRouter().back({ url: 'pages/Index' }); - router.clear(); + this.getUIContext().getRouter().clear(); }) .margin({ right: $r('app.float.margin_16') }) } @@ -318,18 +318,18 @@ struct GraphicCreationPage { Logger.info(this.tag, `doInsertPicture bufferType: ${bufferType}}`); if (bufferType === CommonConstants.BUFFER_TYPE) { if (this.imageInfoArr.length === CommonConstants.LIMIT_PICKER_NUM) { - promptAction.showToast({ + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.toast_picker_limit'), duration: DataUtils.fromResToNumber($r('app.float.show_DELAY_TIME')), }); return; } - let saveUri: string = FileUtils.saveFile(getContext(this), buffer); + let saveUri: string = FileUtils.saveFile(this.getUIContext().getHostContext()!, buffer); let imageInfo: ImageInfo | undefined = FileUtils.createPixelMap(saveUri); if (imageInfo) { this.imageInfoArr.unshift(imageInfo); this.selectedData.unshiftData(imageInfo.imagePixelMap); - FileUtils.copyFileToDestination(saveUri, getContext().distributedFilesDir); + FileUtils.copyFileToDestination(saveUri, this.getUIContext().getHostContext()!.distributedFilesDir); } } } diff --git a/entry/src/main/ets/pages/ImageEditPage.ets b/entry/src/main/ets/pages/ImageEditPage.ets index cff6b2b53d9e636d1ffe6df0a2bad412d92602bf..7ed8ed9ff9ee4d79af9ff0cce50ce761ddbb2b97 100644 --- a/entry/src/main/ets/pages/ImageEditPage.ets +++ b/entry/src/main/ets/pages/ImageEditPage.ets @@ -35,7 +35,7 @@ struct ImageEditPage { $r('app.media.icon_text'), $r('app.media.icon_camera')]; aboutToAppear() { - UIUtils.setWindowBackGroundColor(getContext(this), CommonConstants.WHITE_COLOR); + UIUtils.setWindowBackGroundColor(this.getUIContext().getHostContext()!, CommonConstants.WHITE_COLOR); CameraService.register(); } @@ -44,7 +44,7 @@ struct ImageEditPage { } onPageShow(): void { - UIUtils.setWindowBackGroundColor(getContext(this), CommonConstants.WHITE_COLOR); + UIUtils.setWindowBackGroundColor(this.getUIContext().getHostContext()!, CommonConstants.WHITE_COLOR); this.isEnterCamera = this.tabsIndex === 3; } @@ -71,15 +71,15 @@ struct ImageEditPage { this.isEnterCamera = index === 3; if (this.currentBreakpoint === CommonConstants.BREAKPOINT_SM) { if (this.isEnterCamera) { - UIUtils.setWindowBackGroundColor(getContext(this), CommonConstants.BLACK_COLOR); + UIUtils.setWindowBackGroundColor(this.getUIContext().getHostContext()!, CommonConstants.BLACK_COLOR); } else { - UIUtils.setWindowBackGroundColor(getContext(this), CommonConstants.WHITE_COLOR); + UIUtils.setWindowBackGroundColor(this.getUIContext().getHostContext()!, CommonConstants.WHITE_COLOR); } } else { if (this.isEnterCamera) { - UIUtils.setWindowSystemBarVisible(getContext(this), []); + UIUtils.setWindowSystemBarVisible(this.getUIContext().getHostContext()!, []); } else { - UIUtils.setWindowSystemBarVisible(getContext(this), + UIUtils.setWindowSystemBarVisible(this.getUIContext().getHostContext()!, [CommonConstants.WINDOW_STATUS, CommonConstants.WINDOW_NAVIGATION]); } } diff --git a/entry/src/main/ets/pages/PreviewMovingPhotoPage.ets b/entry/src/main/ets/pages/PreviewMovingPhotoPage.ets index ec9ce13c52f834120b147575e674bebfa6118c8f..48b6284513cee84be0b2ad40bbdb8cf3301457cf 100644 --- a/entry/src/main/ets/pages/PreviewMovingPhotoPage.ets +++ b/entry/src/main/ets/pages/PreviewMovingPhotoPage.ets @@ -22,8 +22,9 @@ import { BreakpointType } from '../utils/BreakpointSystem'; import { FileUtils } from '../utils/FileUtils'; import { ImageInfo } from '../model/ContentInfo'; +const uiContext: UIContext | undefined = AppStorage.get('uiContext'); const PHOTO_SELECT_EVENT_ID: number = 80001; -let context = getContext(this); +let context = uiContext?.getHostContext(); @Entry @Component @@ -36,8 +37,8 @@ struct PreviewMovingPhotoPage { private photoUri: string = ''; async aboutToAppear(): Promise { - UIUtils.setWindowBackGroundColor(getContext(this), CommonConstants.BLACK_COLOR); - let params: object = router.getParams(); + UIUtils.setWindowBackGroundColor(this.getUIContext().getHostContext()!, CommonConstants.BLACK_COLOR); + let params: object = this.getUIContext().getRouter().getParams(); if (params !== undefined) { this.photoUri = params[CommonConstants.KEY_PARAMS_URI] as string; } @@ -144,7 +145,7 @@ struct PreviewMovingPhotoPage { .height($r('app.float.icon_size_24')) .objectFit(ImageFit.Cover) .onClick(() => { - router.back({ + this.getUIContext().getRouter().back({ url: 'pages/ImageEditPage' }); }) @@ -158,10 +159,10 @@ struct PreviewMovingPhotoPage { let imageInfo: ImageInfo | undefined = FileUtils.createPixelMap(this.photoUri); if (imageInfo) { this.imageInfoArr.unshift(imageInfo); - FileUtils.copyFileToDestination(this.photoUri, getContext().distributedFilesDir); + FileUtils.copyFileToDestination(this.photoUri, this.getUIContext().getHostContext()!.distributedFilesDir); } } - router.replaceUrl({ + this.getUIContext().getRouter().replaceUrl({ url: 'pages/GraphicCreationPage' }); }) diff --git a/entry/src/main/ets/pages/PreviewPhotoPage.ets b/entry/src/main/ets/pages/PreviewPhotoPage.ets index 8d58cbecaf02dae4d8a0deebda19c35d64e71c1e..4546823be8ce5abf1abac77be204032e10d72b68 100644 --- a/entry/src/main/ets/pages/PreviewPhotoPage.ets +++ b/entry/src/main/ets/pages/PreviewPhotoPage.ets @@ -29,8 +29,8 @@ struct PreviewPhotoPage { private imageInfo: ImageInfo | undefined = undefined; aboutToAppear(): void { - UIUtils.setWindowBackGroundColor(getContext(this), CommonConstants.BLACK_COLOR); - let params: object = router.getParams(); + UIUtils.setWindowBackGroundColor(this.getUIContext().getHostContext()!, CommonConstants.BLACK_COLOR); + let params: object = this.getUIContext().getRouter().getParams(); if (params !== undefined) { this.photoUri = params[CommonConstants.KEY_PARAMS_URI] as string; this.imageInfo = FileUtils.createPixelMap(this.photoUri); @@ -133,7 +133,7 @@ struct PreviewPhotoPage { .height($r('app.float.icon_size_24')) .objectFit(ImageFit.Cover) .onClick(() => { - router.back({ + this.getUIContext().getRouter().back({ url: 'pages/ImageEditPage' }); }) @@ -145,9 +145,9 @@ struct PreviewPhotoPage { .onClick(() => { if (this.photoUri !== '' && this.imageInfo !== undefined) { this.imageInfoArr.unshift(this.imageInfo); - FileUtils.copyFileToDestination(this.photoUri, getContext().distributedFilesDir); + FileUtils.copyFileToDestination(this.photoUri, this.getUIContext().getHostContext()!.distributedFilesDir); } - router.replaceUrl({ + this.getUIContext().getRouter().replaceUrl({ url: 'pages/GraphicCreationPage', }); }) diff --git a/entry/src/main/ets/utils/BreakpointSystem.ets b/entry/src/main/ets/utils/BreakpointSystem.ets index fca2fa94e612fcced5d9a4f5877d12706b048a56..97baa15f3fc566560ea87bd48f94862228f873c8 100644 --- a/entry/src/main/ets/utils/BreakpointSystem.ets +++ b/entry/src/main/ets/utils/BreakpointSystem.ets @@ -16,6 +16,8 @@ import mediaQuery from '@ohos.mediaquery'; import { CommonConstants } from '../common/CommonConstants'; import Logger from './Logger'; +const uiContext: UIContext | undefined = AppStorage.get('uiContext'); + declare interface BreakPointTypeOption { sm?: T, md?: T, @@ -54,9 +56,9 @@ export class BreakpointSystem { private readonly listenerKey = 'change'; private readonly tag: string = 'BreakpointSystem'; private currentBreakpoint: string = CommonConstants.BREAKPOINT_SM; - private smListener: mediaQuery.MediaQueryListener = mediaQuery.matchMediaSync(CommonConstants.RANGE_SM); - private mdListener: mediaQuery.MediaQueryListener = mediaQuery.matchMediaSync(CommonConstants.RANGE_MD); - private lgListener: mediaQuery.MediaQueryListener = mediaQuery.matchMediaSync(CommonConstants.RANGE_LG); + private smListener: mediaQuery.MediaQueryListener = uiContext!.getMediaQuery().matchMediaSync(CommonConstants.RANGE_SM); + private mdListener: mediaQuery.MediaQueryListener = uiContext!.getMediaQuery().matchMediaSync(CommonConstants.RANGE_MD); + private lgListener: mediaQuery.MediaQueryListener = uiContext!.getMediaQuery().matchMediaSync(CommonConstants.RANGE_LG); private updateCurrentBreakpoint(breakpoint: string): void { if (this.currentBreakpoint !== breakpoint) { @@ -83,11 +85,11 @@ export class BreakpointSystem { } public register(): void { - this.smListener = mediaQuery.matchMediaSync(CommonConstants.RANGE_SM); + this.smListener = uiContext!.getMediaQuery().matchMediaSync(CommonConstants.RANGE_SM); this.smListener.on(this.listenerKey, this.isBreakpointSM); - this.mdListener = mediaQuery.matchMediaSync(CommonConstants.RANGE_MD); + this.mdListener = uiContext!.getMediaQuery().matchMediaSync(CommonConstants.RANGE_MD); this.mdListener.on(this.listenerKey, this.isBreakpointMD); - this.lgListener = mediaQuery.matchMediaSync(CommonConstants.RANGE_LG); + this.lgListener = uiContext!.getMediaQuery().matchMediaSync(CommonConstants.RANGE_LG); this.lgListener.on(this.listenerKey, this.isBreakpointLG); } diff --git a/entry/src/main/ets/utils/UIUtils.ets b/entry/src/main/ets/utils/UIUtils.ets index f19c3f6115c450b587728b744b2c5cffcb20c079..9f00a2f8e34a9785d9d1a213a9ad973b09bea448 100644 --- a/entry/src/main/ets/utils/UIUtils.ets +++ b/entry/src/main/ets/utils/UIUtils.ets @@ -46,8 +46,9 @@ export class UIUtils { * @param callback */ static showPickerView(selectedNum: number, callback: Function) { + const uiContext: UIContext | undefined = AppStorage.get('uiContext'); if (selectedNum >= CommonConstants.LIMIT_PICKER_NUM) { - promptAction.showToast({ + uiContext?.getPromptAction().showToast({ message: $r('app.string.toast_picker_limit'), duration: DataUtils.fromResToNumber($r('app.float.show_DELAY_TIME')), }); diff --git a/entry/src/main/ets/view/CameraView.ets b/entry/src/main/ets/view/CameraView.ets index 984ce6d4357f1bd911fb867f82dd4c077bd9b477..51a2ce3f7c7965331a44bfabe59e316b5a5c949f 100644 --- a/entry/src/main/ets/view/CameraView.ets +++ b/entry/src/main/ets/view/CameraView.ets @@ -173,7 +173,7 @@ export struct CameraView { }).getValue(this.currentBreakpoint) } ); - abilityAccessCtrl.createAtManager().requestPermissionsFromUser(getContext(this), this.permissions).then(() => { + abilityAccessCtrl.createAtManager().requestPermissionsFromUser(this.getUIContext().getHostContext(), this.permissions).then(() => { this.surfaceId = this.mXComponentController.getXComponentSurfaceId(); this.initCamera(); this.getThumbnail(); @@ -329,7 +329,7 @@ export struct CameraView { } private initCamera() { - CameraService.initCamera(getContext(this), this.cameraIndex, this.surfaceId, this.isLocalCamera); + CameraService.initCamera(this.getUIContext().getHostContext()!, this.cameraIndex, this.surfaceId, this.isLocalCamera); this.supperCameraArr = CameraService.supperCameraArr; this.distributedCameraArr = CameraService.distributedCameraArr; CameraService.setEnableLivePhoto(this.isMovingPhoto); @@ -347,7 +347,7 @@ export struct CameraView { Logger.info(this.tag, `pushPreviewPage isMovingPhoto: ${isMovingPhoto}`); let pageName = isMovingPhoto ? 'pages/PreviewMovingPhotoPage' : 'pages/PreviewPhotoPage'; this.currentImg = await photoAsset.getThumbnail(); - router.pushUrl({ + this.getUIContext().getRouter().pushUrl({ url: pageName, params: { uri: uri, diff --git a/entry/src/main/ets/view/ListAddPictureView.ets b/entry/src/main/ets/view/ListAddPictureView.ets index a0745b67025f7347ba7b18b9fee628943102431b..7cd751b9f1c02e0c24294abc0779efb224e0c85a 100644 --- a/entry/src/main/ets/view/ListAddPictureView.ets +++ b/entry/src/main/ets/view/ListAddPictureView.ets @@ -69,7 +69,7 @@ export struct ListAddPictureView { if (uri === undefined) { continue; } - FileUtils.copyFileToDestination(uri, getContext().distributedFilesDir); + FileUtils.copyFileToDestination(uri, this.getUIContext().getHostContext()!.distributedFilesDir); let imageInfo: ImageInfo | undefined = FileUtils.createPixelMap(uri); if (imageInfo) { this.imageInfoArr.unshift(imageInfo); diff --git a/entry/src/main/ets/view/NavigationBarView.ets b/entry/src/main/ets/view/NavigationBarView.ets index bd2774ca89921527b5da0817432a5cce03e2f9fb..2508bcafcd8a43fff248f7f6ccb58f77130d38e6 100644 --- a/entry/src/main/ets/view/NavigationBarView.ets +++ b/entry/src/main/ets/view/NavigationBarView.ets @@ -95,14 +95,14 @@ export struct NavigationBarView { UIUtils.showPickerView(0, (uriArr: string[]) => { let imageInfoArr: ImageInfo[] = []; uriArr.forEach((uri: string) => { - FileUtils.copyFileToDestination(uri, getContext().distributedFilesDir); + FileUtils.copyFileToDestination(uri, this.getUIContext().getHostContext()!.distributedFilesDir); let imageInfo: ImageInfo | undefined = FileUtils.createPixelMap(uri); if (imageInfo) { imageInfoArr.push(imageInfo); } }); AppStorage.setOrCreate>(CommonConstants.KEY_IMAGE_INFO, imageInfoArr); - router.pushUrl({ + this.getUIContext().getRouter().pushUrl({ url: 'pages/ImageEditPage' }); }); diff --git a/entry/src/main/ets/view/SelectedEditeView.ets b/entry/src/main/ets/view/SelectedEditeView.ets index a47cd18405cca5506f5b3ac74c22632d6fa32167..248cddc9938af781e941e316d1feb21ca872e52e 100644 --- a/entry/src/main/ets/view/SelectedEditeView.ets +++ b/entry/src/main/ets/view/SelectedEditeView.ets @@ -138,7 +138,7 @@ export struct SelectedEditeView { .height($r('app.float.finish_btn_height')) .width($r('app.float.size_80')) .onClick(() => { - router.pushUrl({ + this.getUIContext().getRouter().pushUrl({ url: 'pages/GraphicCreationPage' }); }) diff --git a/entry/src/main/ets/view/TitleBackView.ets b/entry/src/main/ets/view/TitleBackView.ets index 75974764a13e5a2a7ea3815d08e873916e4a7e70..b59777505b4a0467583a419b404d56d3c8fe787b 100644 --- a/entry/src/main/ets/view/TitleBackView.ets +++ b/entry/src/main/ets/view/TitleBackView.ets @@ -42,7 +42,7 @@ export struct TitleBackView { .align(Alignment.Start) .justifyContent(FlexAlign.Start) .onClick(() => { - router.back() + this.getUIContext().getRouter().back() }) }.align(Alignment.Start)