From 8c49ff0da6ffbb07bc24de7af93df2523873b269 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Sat, 12 Jul 2025 18:07:13 +0800 Subject: [PATCH] fix diff with AI commit Signed-off-by: dengxiaoyu --- .../ets/mechextability/MechExtAbility.ets | 2 -- .../entry/src/main/ets/pages/MechControl.ets | 27 +++++-------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/application/entry/src/main/ets/mechextability/MechExtAbility.ets b/application/entry/src/main/ets/mechextability/MechExtAbility.ets index e6c237f3..2f91fdad 100644 --- a/application/entry/src/main/ets/mechextability/MechExtAbility.ets +++ b/application/entry/src/main/ets/mechextability/MechExtAbility.ets @@ -22,8 +22,6 @@ const TAG: string = '[MechExtAbility]'; export default class MechExtAbility extends UIExtensionAbility { onCreate() { logger.info(`${TAG} UIExtAbility onCreate`); - AppStorage.setOrCreate('currentColorMode', this.context.config.colorMode); - AppStorage.setOrCreate('currentFontSizeScale', this.context.config.fontSizeScale); } onForeground() { diff --git a/application/entry/src/main/ets/pages/MechControl.ets b/application/entry/src/main/ets/pages/MechControl.ets index c5320487..674a61aa 100644 --- a/application/entry/src/main/ets/pages/MechControl.ets +++ b/application/entry/src/main/ets/pages/MechControl.ets @@ -43,19 +43,22 @@ struct MechControl { .height('40vp') .backgroundColor(this.isTrackingEnabled ? $r('app.color.color_0A59F7_blue') : $r('sys.color.ohos_id_color_component_normal')) .onClick(() => { - this.isTrackingEnabled = !this.isTrackingEnabled; + const originalState = this.isTrackingEnabled; try { - if (this.isTrackingEnabled) { + if (!this.isTrackingEnabled) { logger.info(`${TAG} enable camera tracking`); mechanicManager.setCameraTrackingEnabled(true); + this.isTrackingEnabled = true; } else { logger.info(`${TAG} disable camera tracking`); mechanicManager.setCameraTrackingEnabled(false); + this.isTrackingEnabled = false; } } catch (error) { let code: number = (error as BusinessError).code; let message: string = (error as BusinessError).message; logger.error(`${TAG} setCameraTrackingEnabled failed. error.code: ${code}, message: ${message}`); + this.isTrackingEnabled = originalState; } logger.info(`${TAG} onClick end, isTrackingEnabled = ${this.isTrackingEnabled}`); }) @@ -90,25 +93,7 @@ struct MechControl { .height('40vp') .backgroundColor($r('app.color.color_0A59F7_blue')) .onClick(() => { - this.isTrackingEnabled = !this.isTrackingEnabled; - try { - if (this.isTrackingEnabled) { - logger.info(`${TAG} enable camera tracking`); - mechanicManager.setCameraTrackingEnabled(true); - - this.currentTrackingLayoutImage = $r('app.media.track_layout_center'); - } else { - logger.info(`${TAG} disable camera tracking`); - mechanicManager.setCameraTrackingEnabled(false); - - this.currentTrackingLayoutImage = $r('app.media.track_layout_center_dark'); - } - } catch (error) { - let code: number = (error as BusinessError).code; - let message: string = (error as BusinessError).message; - logger.error(`${TAG} setCameraTrackingEnabled failed. error.code: ${code}, message: ${message}`); - } - logger.info(`${TAG} onClick end, isTrackingEnabled = ${this.isTrackingEnabled}`); + logger.info(`${TAG} onClick TrackingLayout in`); }) Text($r('app.string.mech_tracking_layout')) -- Gitee