From 644b9544b3b1ea121f7e8cecfbdf00215ebfd5c4 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Tue, 29 Oct 2024 19:40:23 +0800 Subject: [PATCH 1/2] eliminate diff Signed-off-by: dengxiaoyu --- application/AppScope/app.json | 4 +- application/AppScope/app.json5 | 4 +- .../ets/common/constants/CommonConstants.ets | 8 +++ .../src/main/ets/pages/ContinueSwitch.ets | 70 +++++++++++-------- 4 files changed, 54 insertions(+), 32 deletions(-) diff --git a/application/AppScope/app.json b/application/AppScope/app.json index 5bae6c47..26c7cc0f 100644 --- a/application/AppScope/app.json +++ b/application/AppScope/app.json @@ -2,8 +2,8 @@ "app": { "bundleName": "com.ohos.dhardwareui", "vendor": "example", - "versionCode": 10000023, - "versionName": "1.0.23", + "versionCode": 10000026, + "versionName": "1.0.26", "icon": "$media:app_icon", "label": "$string:app_name", "minAPIVersion": 12, diff --git a/application/AppScope/app.json5 b/application/AppScope/app.json5 index 0b63ad3d..c708a31f 100644 --- a/application/AppScope/app.json5 +++ b/application/AppScope/app.json5 @@ -16,8 +16,8 @@ "app": { "bundleName": "com.ohos.dhardwareui", "vendor": "example", - "versionCode": 10000023, - "versionName": "1.0.23", + "versionCode": 10000026, + "versionName": "1.0.26", "icon": "$media:app_icon", "label": "$string:app_name", "minAPIVersion": 12, diff --git a/application/entry/src/main/ets/common/constants/CommonConstants.ets b/application/entry/src/main/ets/common/constants/CommonConstants.ets index 1f1c2c71..2e4c19bf 100644 --- a/application/entry/src/main/ets/common/constants/CommonConstants.ets +++ b/application/entry/src/main/ets/common/constants/CommonConstants.ets @@ -38,6 +38,12 @@ export default class CommonConstants { public static readonly ITEM_LIST_PADDING_BOTTOM: number = 18; public static readonly CONTINUE_SWITCH_KEY: string = 'Continue_Switch_Status'; public static readonly FONT_SIZE_SCALE_PARAM: string = 'persist.sys.font_scale_for_user0'; + public static readonly ANIMATOR_HEIGHT_PHONE: number = 192; + public static readonly ANIMATOR_HEIGHT_PC: number = 207; + public static readonly ANIMATOR_HEIGHT_PAD: number = 212; + public static readonly ANIMATOR_WIDTH_PHONE: number = 290; + public static readonly ANIMATOR_WIDTH_PC: number = 312; + public static readonly ANIMATOR_WIDTH_PAD: number = 320; // Tips public static readonly TIPS_TYPE: string = '105'; public static readonly FUN_NUM = 'SF-20005815_f101'; @@ -47,6 +53,8 @@ export default class CommonConstants { // Update prompt text public static readonly UPDATE_PROMPT_LINE_HEIGHT: number = 16; public static readonly UPDATE_PROMPT_MARGIN_TOP: number = 9; + // isMirrorLanguages + public static readonly MIRROR_LANGUAGES: Array = ['ug']; } export enum FontSizeScale { diff --git a/application/entry/src/main/ets/pages/ContinueSwitch.ets b/application/entry/src/main/ets/pages/ContinueSwitch.ets index 7f68b73b..d4558222 100644 --- a/application/entry/src/main/ets/pages/ContinueSwitch.ets +++ b/application/entry/src/main/ets/pages/ContinueSwitch.ets @@ -26,6 +26,7 @@ import { logger } from '../utils/Logger'; import { TipsJumpUtils } from '../utils/TipsJumpUtils'; import osAccount from '@ohos.account.osAccount'; import systemParameterEnhance from '@ohos.systemParameterEnhance'; +import i18n from '@ohos.i18n'; const TAG = '[ContinueSwitch_Page] : '; let context = getContext(this) as common.UIAbilityContext; @@ -50,8 +51,8 @@ struct ContinueSwitch { @State screenHeight: number = 0; @State screenWidth: number = 0; @State shortSideSize: number = 0; - @State imageAnimatorHeight: number = 0; - @State imageAnimatorWidth: number = 0; + @State imageAnimatorHeight: number = this.getImageAnimatorHeight(); + @State imageAnimatorWidth: number = this.getImageAnimatorWidth(); @State textWidth: number = 0; @State gapLength: number = 0; @State isShow: boolean = false; @@ -65,6 +66,7 @@ struct ContinueSwitch { @State iterations: number = -1; @State isEnabled: boolean = true; @State isShowBack: boolean = true; + @State isAnimatorDone: boolean = false; @StorageProp('currentFontSizeScale') @Watch('onFontSizeScaleChange') fontSizeScale: number = 1; @State phoneSwitchTextTopMargin: string = '17vp'; @State phoneSwitchTextBottomMargin: string = '18vp'; @@ -117,30 +119,6 @@ struct ContinueSwitch { this.phoneSwitchTextBottomMargin = this.UpdateMarginBasedOnFontSize(18, fontSizeScale); } - /** - * @description Calculate the ImageAnimator size - * Calculation rule: - * 1.general phone & pad : screen height/2 compare with width,shorter is ImageAnimator width - * 2.pc: screen height/2 compare with width,shorter is ImageAnimator height - * 3.ratio: 3:2 - * @param height - * @param width - */ - getImageAnimatorSize(height: Length, width: Length): void { - logger.info(`${TAG} getImageAnimatorSize in, deviceInfo.deviceType : ${deviceInfo.deviceType}`); - let totalHeight = height as number; - this.shortSideSize = width < totalHeight / 2 ? width as number : totalHeight / 2 as number; - if (deviceInfo.deviceType === 'phone' || deviceInfo.deviceType === 'tablet') { - this.imageAnimatorWidth = this.shortSideSize * 0.8; - this.imageAnimatorHeight = this.shortSideSize * 0.8 * 2 / 3; - } else if (deviceInfo.deviceType === '2in1') { - this.imageAnimatorWidth = this.shortSideSize * 0.8 * 3 / 2; - this.imageAnimatorHeight = this.shortSideSize * 0.8; - } - logger.info(`${TAG} this.shortSideSize = ${this.shortSideSize} , this.imageAnimatorWidth = - ${this.imageAnimatorWidth} , this.imageAnimatorHeight = ${this.imageAnimatorHeight}`); - } - getStringSync(): void { logger.info(`${TAG} getStringSync in`); try { @@ -259,6 +237,9 @@ struct ContinueSwitch { } this.checkPcPadBackButton(); this.phoneSwitchTextMarginInit(); + setTimeout(() => { + this.isAnimatorDone = true; + }, 20) } aboutToDisappear() { @@ -405,7 +386,8 @@ struct ContinueSwitch { .fontWeight(FontWeight.Medium) .fontSize(CommonConstants.SYMBOL_INFO_CIRCLE) .fontColor([$r('sys.color.ohos_id_color_activated')]) - .margin({ right: CommonConstants.SYMBOL_MARGIN_RIGHT }) + .margin(this.isMirrorLanguages() ? { left: CommonConstants.SYMBOL_MARGIN_RIGHT } : + { right: CommonConstants.SYMBOL_MARGIN_RIGHT }) .width(CommonConstants.SYMBOL_INFO_CIRCLE) .height(CommonConstants.SYMBOL_INFO_CIRCLE) .accessibilityLevel('no') @@ -445,6 +427,7 @@ struct ContinueSwitch { .padding({ left: this.gapLength, right: this.gapLength }) .margin({ bottom: this.contentHeight * 0.09 }) .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + .visibility(this.getContentVisibility()) } .width('100%') .height(this.screenHeight) @@ -477,12 +460,37 @@ struct ContinueSwitch { .backgroundColor($r('sys.color.ohos_id_color_sub_background')) .onAreaChange((oldArea: Area, newArea: Area) => { logger.info(`${TAG} build column , oldArea.height = ${oldArea.height}, newArea.height = ${newArea.height}`); - this.getImageAnimatorSize(newArea.height, newArea.width); logger.info(`${TAG} this.shortSideSize = ${this.shortSideSize}, this.imageAnimatorWidth = ${this.imageAnimatorWidth}, this.imageAnimatorHeight = ${this.imageAnimatorHeight}`); }) } + private getContentVisibility(): Visibility { + return (this.imageAnimatorWidth !== 0 && this.isAnimatorDone) ? Visibility.Visible : Visibility.Hidden; + } + + private getImageAnimatorHeight(): number { + if (deviceInfo.deviceType === 'phone') { + return CommonConstants.ANIMATOR_HEIGHT_PHONE; + } else if (deviceInfo.deviceType === '2in1') { + return CommonConstants.ANIMATOR_HEIGHT_PC; + } else if (deviceInfo.deviceType === 'tablet') { + return CommonConstants.ANIMATOR_HEIGHT_PAD; + } + return CommonConstants.ANIMATOR_HEIGHT_PHONE; + } + + private getImageAnimatorWidth(): number { + if (deviceInfo.deviceType === 'phone') { + return CommonConstants.ANIMATOR_WIDTH_PHONE; + } else if (deviceInfo.deviceType === '2in1') { + return CommonConstants.ANIMATOR_WIDTH_PC; + } else if (deviceInfo.deviceType === 'tablet') { + return CommonConstants.ANIMATOR_WIDTH_PAD; + } + return CommonConstants.ANIMATOR_WIDTH_PHONE; + } + private checkPcPadBackButton(): void { logger.info(`${TAG} checkPcPadBackButton in`); if (this.startReason === 'from_search') { @@ -529,4 +537,10 @@ struct ContinueSwitch { } } } + + private isMirrorLanguages(): boolean { + logger.info(`${TAG} isMirrorLanguages in`); + let locale = new Intl.Locale(i18n.System.getSystemLanguage()).toString(); + return CommonConstants.MIRROR_LANGUAGES.includes(locale); + } } \ No newline at end of file -- Gitee From c5822171491cd41d76946c761e97d544a1969b33 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Wed, 30 Oct 2024 18:44:31 +0800 Subject: [PATCH 2/2] fix:bo launage gap Signed-off-by: dengxiaoyu --- application/AppScope/app.json | 4 ++-- application/AppScope/app.json5 | 4 ++-- .../src/main/ets/common/constants/CommonConstants.ets | 2 ++ .../entry/src/main/ets/pages/ContinueSwitch.ets | 10 +++++++++- application/entry/src/main/module.json | 3 +++ application/entry/src/main/module.json5 | 3 +++ 6 files changed, 21 insertions(+), 5 deletions(-) diff --git a/application/AppScope/app.json b/application/AppScope/app.json index 26c7cc0f..40494bea 100644 --- a/application/AppScope/app.json +++ b/application/AppScope/app.json @@ -2,8 +2,8 @@ "app": { "bundleName": "com.ohos.dhardwareui", "vendor": "example", - "versionCode": 10000026, - "versionName": "1.0.26", + "versionCode": 10000027, + "versionName": "1.0.27", "icon": "$media:app_icon", "label": "$string:app_name", "minAPIVersion": 12, diff --git a/application/AppScope/app.json5 b/application/AppScope/app.json5 index c708a31f..878d650d 100644 --- a/application/AppScope/app.json5 +++ b/application/AppScope/app.json5 @@ -16,8 +16,8 @@ "app": { "bundleName": "com.ohos.dhardwareui", "vendor": "example", - "versionCode": 10000026, - "versionName": "1.0.26", + "versionCode": 10000027, + "versionName": "1.0.27", "icon": "$media:app_icon", "label": "$string:app_name", "minAPIVersion": 12, diff --git a/application/entry/src/main/ets/common/constants/CommonConstants.ets b/application/entry/src/main/ets/common/constants/CommonConstants.ets index 2e4c19bf..4e48e9a4 100644 --- a/application/entry/src/main/ets/common/constants/CommonConstants.ets +++ b/application/entry/src/main/ets/common/constants/CommonConstants.ets @@ -55,6 +55,8 @@ export default class CommonConstants { public static readonly UPDATE_PROMPT_MARGIN_TOP: number = 9; // isMirrorLanguages public static readonly MIRROR_LANGUAGES: Array = ['ug']; + // isTibetanLanguages + public static readonly TIBETAN_LANGUAGES: Array = ['bo']; } export enum FontSizeScale { diff --git a/application/entry/src/main/ets/pages/ContinueSwitch.ets b/application/entry/src/main/ets/pages/ContinueSwitch.ets index d4558222..c4ca7527 100644 --- a/application/entry/src/main/ets/pages/ContinueSwitch.ets +++ b/application/entry/src/main/ets/pages/ContinueSwitch.ets @@ -397,7 +397,7 @@ struct ContinueSwitch { .fontWeight(FontWeight.Medium) .fontColor($r('sys.color.ohos_id_color_text_primary')) .textAlign(TextAlign.Start) - .lineHeight(CommonConstants.UPDATE_PROMPT_LINE_HEIGHT) + .lineHeight(-1) } .margin({ top: CommonConstants.UPDATE_PROMPT_MARGIN_TOP }) } @@ -415,6 +415,7 @@ struct ContinueSwitch { .fontColor($r('sys.color.ohos_id_color_text_secondary')) .textAlign(TextAlign.Start) .width('100%') + .lineHeight(this.isTibetanLanguages() ? 19 : 0) } .padding({ left: CommonConstants.TEXT_LIST_ALIGN_DISTANCE, @@ -543,4 +544,11 @@ struct ContinueSwitch { let locale = new Intl.Locale(i18n.System.getSystemLanguage()).toString(); return CommonConstants.MIRROR_LANGUAGES.includes(locale); } + + private isTibetanLanguages(): boolean { + logger.info(`${TAG} isTibetanLanguages in`); + let locale = new Intl.Locale(i18n.System.getSystemLanguage()).toString(); + logger.info(`${TAG} isTibetanLanguages: ${locale}`); + return CommonConstants.TIBETAN_LANGUAGES.includes(locale); + } } \ No newline at end of file diff --git a/application/entry/src/main/module.json b/application/entry/src/main/module.json index ee3894ba..8b9d2318 100644 --- a/application/entry/src/main/module.json +++ b/application/entry/src/main/module.json @@ -65,6 +65,9 @@ { "name": "action.settings.search.path", "value": "searchConfig/searchPage.json" + }, + { + "name": "ohos.graphics2d.text.adapter_text_height" } ] } diff --git a/application/entry/src/main/module.json5 b/application/entry/src/main/module.json5 index dd1c501f..82cddf0a 100644 --- a/application/entry/src/main/module.json5 +++ b/application/entry/src/main/module.json5 @@ -79,6 +79,9 @@ { "name": "action.settings.search.path", "value": "searchConfig/searchPage.json" + }, + { + "name": "ohos.graphics2d.text.adapter_text_height" } ] } -- Gitee