From 1bb2af4663e973f02f679f59c1450a6493c71c54 Mon Sep 17 00:00:00 2001 From: 16609420912 Date: Thu, 21 Jul 2022 15:19:02 +0800 Subject: [PATCH 1/4] Update camera persistence --- .gitignore | 5 ++++- .../featurecommon/cameraswitcher/CameraSwitchButton.ets | 8 ++++++-- .../src/main/ets/default/function/CameraBasicFunction.ts | 4 ++++ product/tablet/src/main/ets/pages/indexLand.ets | 4 ++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d6377cd..14d103f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ /local.properties /.idea **/build -/signature \ No newline at end of file +/signature +/build-profile.json5 +/package.json +/package-lock.json diff --git a/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets b/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets index adb21bd..1406e2d 100644 --- a/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets +++ b/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets @@ -42,12 +42,14 @@ let localDispatcher = (dispatch) => { } } +let storageCameraId = AppStorage.Link('storageCameraId') + @Component export struct CameraSwitchButton { private TAG: string = '[CameraSwitchButton]:' @State state: any = {} @State deviceType: string = deviceInfo.deviceType - + @StorageLink('storageCameraId') storageCameraId: string = '' icon: Resource = $r('app.media.small_switch_camera') width: number height: number @@ -107,9 +109,11 @@ export struct CameraSwitchButton { } else { this.state.updateXComponentChangeFlag(!this.state.xComponentChangeFlag) if (this.state.cameraPosition !== 'BACK') { - this.state.changeCameraPosition('BACK') + this.state.changeCameraPosition('BACK') + this.storageCameraId = 'BACK' } else { this.state.changeCameraPosition('FRONT') + this.storageCameraId = 'FRONT' } } } diff --git a/common/src/main/ets/default/function/CameraBasicFunction.ts b/common/src/main/ets/default/function/CameraBasicFunction.ts index de4bd13..c232420 100644 --- a/common/src/main/ets/default/function/CameraBasicFunction.ts +++ b/common/src/main/ets/default/function/CameraBasicFunction.ts @@ -52,6 +52,10 @@ export class CameraBasicFunction extends Function { private async initCamera(data) { Log.info(`${this.TAG} initCamera ${JSON.stringify(data)} E`) + let curStorageCameraId = AppStorage.Get('storageCameraId') + if (curStorageCameraId){ + data.cameraId = curStorageCameraId + } this.mCameraId = data.cameraId this.mCurrentMode = data.mode let mCameraCount = await this.mCameraService.initCamera(this.mCameraId) diff --git a/product/tablet/src/main/ets/pages/indexLand.ets b/product/tablet/src/main/ets/pages/indexLand.ets index 7a5462f..75dda95 100644 --- a/product/tablet/src/main/ets/pages/indexLand.ets +++ b/product/tablet/src/main/ets/pages/indexLand.ets @@ -84,6 +84,8 @@ let indexDispatcher = (dispatch) => { } } +PersistentStorage.PersistProp("storageCameraId", "") + @Entry @Component struct Index { @@ -157,6 +159,8 @@ struct Index { onPageShow(): void { Log.info(`${this.TAG} onPageShow this.permissionFlag: ${this.state.permissionFlag} globalThis.permissionFlag: ${globalThis.permissionFlag}`) this.state.setPermissionFlag(globalThis.permissionFlag) + let curCameraId = AppStorage.Get('storageCameraId') + if(curCameraId) this.state.initCameraPosition(curCameraId) } aboutToDisappear(): void { -- Gitee From a7c19c50cab1a6eee1f302c50136a60a7fc07054 Mon Sep 17 00:00:00 2001 From: 16609420912 Date: Thu, 21 Jul 2022 15:19:02 +0800 Subject: [PATCH 2/4] Update camera persistence Signed-off-by: 16609420912 --- .gitignore | 5 ++++- .../featurecommon/cameraswitcher/CameraSwitchButton.ets | 8 ++++++-- .../src/main/ets/default/function/CameraBasicFunction.ts | 4 ++++ product/tablet/src/main/ets/pages/indexLand.ets | 4 ++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d6377cd..14d103f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ /local.properties /.idea **/build -/signature \ No newline at end of file +/signature +/build-profile.json5 +/package.json +/package-lock.json diff --git a/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets b/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets index adb21bd..1406e2d 100644 --- a/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets +++ b/common/src/main/ets/default/featurecommon/cameraswitcher/CameraSwitchButton.ets @@ -42,12 +42,14 @@ let localDispatcher = (dispatch) => { } } +let storageCameraId = AppStorage.Link('storageCameraId') + @Component export struct CameraSwitchButton { private TAG: string = '[CameraSwitchButton]:' @State state: any = {} @State deviceType: string = deviceInfo.deviceType - + @StorageLink('storageCameraId') storageCameraId: string = '' icon: Resource = $r('app.media.small_switch_camera') width: number height: number @@ -107,9 +109,11 @@ export struct CameraSwitchButton { } else { this.state.updateXComponentChangeFlag(!this.state.xComponentChangeFlag) if (this.state.cameraPosition !== 'BACK') { - this.state.changeCameraPosition('BACK') + this.state.changeCameraPosition('BACK') + this.storageCameraId = 'BACK' } else { this.state.changeCameraPosition('FRONT') + this.storageCameraId = 'FRONT' } } } diff --git a/common/src/main/ets/default/function/CameraBasicFunction.ts b/common/src/main/ets/default/function/CameraBasicFunction.ts index de4bd13..c232420 100644 --- a/common/src/main/ets/default/function/CameraBasicFunction.ts +++ b/common/src/main/ets/default/function/CameraBasicFunction.ts @@ -52,6 +52,10 @@ export class CameraBasicFunction extends Function { private async initCamera(data) { Log.info(`${this.TAG} initCamera ${JSON.stringify(data)} E`) + let curStorageCameraId = AppStorage.Get('storageCameraId') + if (curStorageCameraId){ + data.cameraId = curStorageCameraId + } this.mCameraId = data.cameraId this.mCurrentMode = data.mode let mCameraCount = await this.mCameraService.initCamera(this.mCameraId) diff --git a/product/tablet/src/main/ets/pages/indexLand.ets b/product/tablet/src/main/ets/pages/indexLand.ets index 7a5462f..75dda95 100644 --- a/product/tablet/src/main/ets/pages/indexLand.ets +++ b/product/tablet/src/main/ets/pages/indexLand.ets @@ -84,6 +84,8 @@ let indexDispatcher = (dispatch) => { } } +PersistentStorage.PersistProp("storageCameraId", "") + @Entry @Component struct Index { @@ -157,6 +159,8 @@ struct Index { onPageShow(): void { Log.info(`${this.TAG} onPageShow this.permissionFlag: ${this.state.permissionFlag} globalThis.permissionFlag: ${globalThis.permissionFlag}`) this.state.setPermissionFlag(globalThis.permissionFlag) + let curCameraId = AppStorage.Get('storageCameraId') + if(curCameraId) this.state.initCameraPosition(curCameraId) } aboutToDisappear(): void { -- Gitee From 05b9ef81b89ba1cef1a16eb80a647ca449bf5a31 Mon Sep 17 00:00:00 2001 From: 16609420912 Date: Fri, 22 Jul 2022 10:24:04 +0800 Subject: [PATCH 3/4] Update mobile camera persistence --- product/phone/src/main/ets/pages/index.ets | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/product/phone/src/main/ets/pages/index.ets b/product/phone/src/main/ets/pages/index.ets index 5132519..5fe4edf 100644 --- a/product/phone/src/main/ets/pages/index.ets +++ b/product/phone/src/main/ets/pages/index.ets @@ -84,6 +84,8 @@ let indexDispatcher = (dispatch) => { } } +PersistentStorage.PersistProp("storageCameraId", "") + @Entry @Component struct Index { @@ -159,6 +161,8 @@ struct Index { onPageShow(): void { Log.info(`${this.TAG} onPageShow this.permissionFlag: ${this.state.permissionFlag} globalThis.permissionFlag: ${globalThis.permissionFlag}`) this.state.setPermissionFlag(globalThis.permissionFlag) + let curCameraId = AppStorage.Get('storageCameraId') + if(curCameraId) this.state.initCameraPosition(curCameraId) } aboutToDisappear(): void { -- Gitee From c9c3e105e1814b5dba60ec9c31988dbf6905be27 Mon Sep 17 00:00:00 2001 From: 16609420912 Date: Sat, 23 Jul 2022 12:15:48 +0800 Subject: [PATCH 4/4] test dco Signed-off-by: 16609420912 --- product/phone/src/main/ets/pages/index.ets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product/phone/src/main/ets/pages/index.ets b/product/phone/src/main/ets/pages/index.ets index 5fe4edf..a42b1c3 100644 --- a/product/phone/src/main/ets/pages/index.ets +++ b/product/phone/src/main/ets/pages/index.ets @@ -89,7 +89,7 @@ PersistentStorage.PersistProp("storageCameraId", "") @Entry @Component struct Index { - private TAG: string = '[Index]:' + private TAG: string = '[Index]:222' private modeConfig: ModeConfig = new ModeConfig() appEventBus: EventBus = EventBusManager.getInstance().getEventBus() @State state: any = {} -- Gitee