From 3e08b0968447b54974eb175738fa0e60e52972f3 Mon Sep 17 00:00:00 2001 From: wangfeifan Date: Thu, 24 Aug 2023 20:15:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=93=E5=8D=B0ux=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangfeifan --- entry/src/main/ets/pages/AboutPage.ets | 87 ++++---- .../main/ets/pages/PrivacyStatementPage.ets | 187 ++++++++---------- .../ets/pages/PrivacyStatementWebPage.ets | 43 ++-- .../pages/component/AboutPageComponent.ets | 21 +- 4 files changed, 154 insertions(+), 184 deletions(-) diff --git a/entry/src/main/ets/pages/AboutPage.ets b/entry/src/main/ets/pages/AboutPage.ets index b83a6f2..1e61ab3 100644 --- a/entry/src/main/ets/pages/AboutPage.ets +++ b/entry/src/main/ets/pages/AboutPage.ets @@ -13,9 +13,6 @@ * limitations under the License. */ -import { Log } from '@ohos/common'; -import bundleManager from '@ohos.bundle.bundleManager'; -import window from '@ohos.window'; import router from '@ohos.router'; import {CancelButton} from './component/BaseComponent'; import AppStorageHelper from '../Common/Adapter/AppStorageHelper'; @@ -33,54 +30,54 @@ struct AboutPage { } build() { - Column() { - Column() { - Image($r('app.media.logo')) - .width($r('app.float.privacy_statement_print_log_width_height')) - .height($r('app.float.privacy_statement_print_log_width_height')) - .margin({top: $r('app.float.about_print_log_width_height')}) - Text($r('app.string.MainAbility_label')) - .fontSize($r('sys.float.ohos_id_text_size_headline7')) - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .fontWeight(FontWeight.Bolder) - .margin({top: $r('app.float.about_text_relative_img_margin_top')}) - Text(this.versionName) - .margin({ top: $r('app.float.privacy_statement_text_relative_text_margin_top')}) - .fontColor($r('sys.color.ohos_fa_text_tertiary')) - .fontWeight(FontWeight.Regular) - } - Blank().height('20%') - Column() { - Text($r('app.string.about_privacy_statement_text')) - .fontColor($r('sys.color.ohos_id_color_text_hyperlink')) - .onClick(() => { - router.pushUrl({url: 'pages/PrivacyStatementWebPage'}) + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Column() { + Image($r('app.media.logo')) + .width($r('app.float.privacy_statement_print_log_width_height')) + .height($r('app.float.privacy_statement_print_log_width_height')) + .margin({top: $r('app.float.about_print_log_width_height')}) + Text($r('app.string.MainAbility_label')) + .fontSize($r('sys.float.ohos_id_text_size_headline7')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .fontWeight(FontWeight.Bolder) + .margin({top: $r('app.float.about_text_relative_img_margin_top')}) + Text(this.versionName) + .margin({ top: $r('app.float.privacy_statement_text_relative_text_margin_top')}) + .fontColor($r('sys.color.ohos_fa_text_tertiary')) + .fontWeight(FontWeight.Regular) + } + Column() { + Text($r('app.string.about_privacy_statement_text')) + .fontColor($r('sys.color.ohos_id_color_text_hyperlink')) + .onClick(() => { + router.pushUrl({ + url: 'pages/PrivacyStatementWebPage', + params: { + info: false + } + }); + }) + .margin({ + left: $r('app.float.privacy_statement_text_margin_left_right'), + right: $r('app.float.privacy_statement_text_margin_left_right') + }) + CancelButton({ + cancelLabel: $r('app.string.Cancel'), + cancelWidth: $r('app.float.about_button_width'), + cancelHeight: $r('app.float.privacy_statement_button_height'), + cancelClick: () => { + router.back({ url: 'pages/PrintPage' }); + } }) .margin({ - left: $r('app.float.privacy_statement_text_margin_left_right'), - right: $r('app.float.privacy_statement_text_margin_left_right') + top: $r('app.float.privacy_statement_button_to_text_margin_top') }) - CancelButton({ - cancelLabel: $r('app.string.Cancel'), - cancelWidth: $r('app.float.about_button_width'), - cancelHeight: $r('app.float.privacy_statement_button_height'), - cancelClick: () => { - var windowClass = window.findWindow('AboutPage'); - if (windowClass) { - windowClass.destroyWindow(() => { - Log.info(TAG, 'Succeeded in destroying the window'); - }) - } - } - }) - .margin({ - top: $r('app.float.privacy_statement_button_to_text_margin_top') - }) + } + .margin({bottom: $r('app.float.privacy_statement_button_margin_bottom')}) } - .margin({bottom: $r('app.float.privacy_statement_button_margin_bottom')}) } .width('100%') .height('100%') - .alignItems(HorizontalAlign.Center) } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/PrivacyStatementPage.ets b/entry/src/main/ets/pages/PrivacyStatementPage.ets index ce5d1b0..62d9660 100644 --- a/entry/src/main/ets/pages/PrivacyStatementPage.ets +++ b/entry/src/main/ets/pages/PrivacyStatementPage.ets @@ -22,7 +22,6 @@ import { PreferencesKey} from '@ohos/common'; import PreferencesAdapter from '../Common/Adapter/PreferencesAdapter'; import {PrivacyStatementDialog} from './PrivacyStatementDialog'; import {CancelButton} from './component/BaseComponent'; -import window from '@ohos.window'; const TAG = 'PrivacyStatementPage'; @@ -48,116 +47,100 @@ struct PrivacyStatementPage { } build() { - Column() { - Column() { - Image($r('app.media.logo')) - .width($r('app.float.privacy_statement_print_log_width_height')) - .height($r("app.float.privacy_statement_print_log_width_height")) - .margin({top: $r('app.float.print_log_margin_top')}) - Text($r('app.string.welcome')) - .margin({ top: $r('app.float.privacy_statement_text_relative_img_margin_top')}) - .fontColor($r('sys.color.ohos_id_color_text_tertiary')) - .fontSize($r('sys.float.ohos_id_text_size_over_line')) - .fontWeight(FontWeight.Regular) - .height($r('app.float.privacy_statement_text_tertiary_height')) - Text($r('app.string.MainAbility_label')) - .fontSize($r('sys.float.ohos_id_text_size_headline7')) + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Column() { + Image($r('app.media.logo')) + .width($r('app.float.privacy_statement_print_log_width_height')) + .height($r("app.float.privacy_statement_print_log_width_height")) + .margin({top: $r('app.float.print_log_margin_top')}) + Text($r('app.string.welcome')) + .margin({ top: $r('app.float.privacy_statement_text_relative_img_margin_top')}) + .fontColor($r('sys.color.ohos_id_color_text_tertiary')) + .fontSize($r('sys.float.ohos_id_text_size_over_line')) + .fontWeight(FontWeight.Regular) + .height($r('app.float.privacy_statement_text_tertiary_height')) + Text($r('app.string.MainAbility_label')) + .fontSize($r('sys.float.ohos_id_text_size_headline7')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .fontWeight(FontWeight.Bolder) + .height($r('app.float.privacy_statement_text_headline_height')) + .margin({top: $r('app.float.privacy_statement_text_relative_text_margin_top')}) + Text($r('app.string.print_slogan')) + .fontColor($r('sys.color.ohos_id_color_text_tertiary')) + .fontSize($r('sys.float.ohos_id_text_size_over_line')) + .fontWeight(FontWeight.Regular) + .margin({top: $r('app.float.privacy_statement_text_relative_text_margin_top')}) + .height($r('app.float.privacy_statement_text_tertiary_height')) + } + + Column() { + Image($r('app.media.ic_public_shield')) + .width($r('app.float.shield_width_height')) + .height($r('app.float.shield_width_height')) + Text() { + ForEach(this.getPrivacyStatementText(), (privacyStatementText) => { + if (privacyStatementText === this.abilityContext.resourceManager.getStringByNameSync('location_information') || + privacyStatementText === this.abilityContext.resourceManager.getStringByNameSync('print_permission_network')) { + Span(privacyStatementText).fontWeight(FontWeight.Bolder) + } else { + Span(privacyStatementText) + } + }) + Span($r('app.string.about_privacy_statement_text')) + .onClick(() => { + router.replaceUrl({ + url: 'pages/PrivacyStatementWebPage', + params: { + info: true + } + }); + }) + .fontColor($r('sys.color.ohos_id_color_text_hyperlink')) + .fontSize($r('sys.float.ohos_id_text_size_body3')) + Span('、') + Span($r('app.string.permissions_notice')) + .fontColor($r('sys.color.ohos_id_color_text_hyperlink')) + .fontSize($r('sys.float.ohos_id_text_size_body3')) + .onClick(() => { + this.dialogController.open(); + }) + Span('。') + } .fontColor($r('sys.color.ohos_id_color_text_primary')) - .fontWeight(FontWeight.Bolder) - .height($r('app.float.privacy_statement_text_headline_height')) - .margin({top: $r('app.float.privacy_statement_text_relative_text_margin_top')}) - Text($r('app.string.print_slogan')) - .fontColor($r('sys.color.ohos_id_color_text_tertiary')) - .fontSize($r('sys.float.ohos_id_text_size_over_line')) - .fontWeight(FontWeight.Regular) - .margin({top: $r('app.float.privacy_statement_text_relative_text_margin_top')}) - .height($r('app.float.privacy_statement_text_tertiary_height')) - } - Blank().height('20%') - Column() { - Image($r('app.media.ic_public_shield')) - .width($r('app.float.shield_width_height')) - .height($r('app.float.shield_width_height')) - Text() { - ForEach(this.getPrivacyStatementText(), (privacyStatementText) => { - if (privacyStatementText === this.abilityContext.resourceManager.getStringByNameSync('location_information') || - privacyStatementText === this.abilityContext.resourceManager.getStringByNameSync('print_permission_network')) { - Span(privacyStatementText).fontWeight(FontWeight.Bolder) - } else { - Span(privacyStatementText) - } + .fontSize($r('sys.float.ohos_id_text_size_body3')) + .margin({ + top: $r('app.float.privacy_statement_text_relative_img_margin_top'), + left: $r('app.float.privacy_statement_text_margin_left_right'), + right: $r('app.float.privacy_statement_text_margin_left_right') }) - Span($r('app.string.about_privacy_statement_text')) - .onClick(() => { - var windowStage = GlobalThisHelper.getValue(GlobalThisStorageKey.KEY_MAIN_ABILITY_WINDOW_STAGE); - windowStage.createSubWindow('PrivacyStatementWebPage') - .then((windowMode) => { - let storage = new LocalStorage(); - storage.setOrCreate('privacyStatementFlag', true); - // @ts-ignore - windowMode.setForbidSplitMove(false); - windowMode.loadContent('pages/PrivacyStatementWebPage', storage, (err) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content.'); - }) - windowMode.showWindow((err) => { - if (err.code) { - Log.info(TAG, 'Failed to show the window. Cause: ' + JSON.stringify(err)) - return - } - Log.info(TAG, 'Succeeded in showing the window.') - }) - }) - }) - .fontColor($r('sys.color.ohos_id_color_text_hyperlink')) - .fontSize($r('sys.float.ohos_id_text_size_body3')) - Span('、') - Span($r('app.string.permissions_notice')) - .fontColor($r('sys.color.ohos_id_color_text_hyperlink')) - .fontSize($r('sys.float.ohos_id_text_size_body3')) - .onClick(() => { - this.dialogController.open(); + Row() { + CancelButton({ + cancelLabel: $r('app.string.Cancel'), + cancelWidth: $r('app.float.privacy_statement_button_width'), + cancelHeight: $r('app.float.privacy_statement_button_height'), + cancelClick: () => { + this.abilityContext.terminateSelf(); + } }) - Span('。') - } - .fontColor($r('sys.color.ohos_id_color_text_primary')) - .fontSize($r('sys.float.ohos_id_text_size_body3')) - .margin({ - top: $r('app.float.privacy_statement_text_relative_img_margin_top'), - left: $r('app.float.privacy_statement_text_margin_left_right'), - right: $r('app.float.privacy_statement_text_margin_left_right') - }) - Row() { - CancelButton({ - cancelLabel: $r('app.string.Cancel'), - cancelWidth: $r('app.float.privacy_statement_button_width'), - cancelHeight: $r('app.float.privacy_statement_button_height'), - cancelClick: () => { - this.abilityContext.terminateSelf(); - } + .margin({right: $r('app.float.privacy_statement_button_space')}) + Button($r('app.string.Agree')) + .onClick(() => { + this.agreePrivacyStatement(); + router.replaceUrl({url: 'pages/PrintPage'}); + }) + .width($r('app.float.privacy_statement_button_width')) + .height($r('app.float.privacy_statement_button_height')) + } + .margin({ + top: $r('app.float.privacy_statement_button_to_text_margin_top'), + bottom: $r('app.float.privacy_statement_button_margin_bottom'), }) - .margin({right: $r('app.float.privacy_statement_button_space')}) - Button($r('app.string.Agree')) - .onClick(() => { - this.agreePrivacyStatement(); - router.replaceUrl({url: 'pages/PrintPage'}); - }) - .width($r('app.float.privacy_statement_button_width')) - .height($r('app.float.privacy_statement_button_height')) } - .margin({ - top: $r('app.float.privacy_statement_button_to_text_margin_top'), - bottom: $r('app.float.privacy_statement_button_margin_bottom'), - }) - } } .width('100%') .height('100%') - .alignItems(HorizontalAlign.Center) } async agreePrivacyStatement() { diff --git a/entry/src/main/ets/pages/PrivacyStatementWebPage.ets b/entry/src/main/ets/pages/PrivacyStatementWebPage.ets index 66ee898..26a37d2 100644 --- a/entry/src/main/ets/pages/PrivacyStatementWebPage.ets +++ b/entry/src/main/ets/pages/PrivacyStatementWebPage.ets @@ -38,9 +38,10 @@ struct PrivacyStatementWebPage { private url: string; aboutToAppear() { - let storage = LocalStorage.GetShared(); - if (storage) { - this.privacyStatementFlag = storage.get('privacyStatementFlag'); + const params = router.getParams(); + const hideCancel = params['info']; + if (hideCancel) { + this.privacyStatementFlag = hideCancel; } Log.info(TAG, 'privacyStatementFlag: ' + this.privacyStatementFlag); this.languageToWebUrl(); @@ -48,7 +49,7 @@ struct PrivacyStatementWebPage { } build() { - Column() { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, direction: FlexDirection.Column }) { Column() { ClickableImage({ imageSrc: $r('app.media.ic_back'), @@ -70,33 +71,33 @@ struct PrivacyStatementWebPage { .width('100%') .height('100%') } - .height('75%') + .height(600) .width('100%') - Column() { - CancelButton({ - cancelLabel: $r('app.string.Cancel'), - cancelWidth: $r('app.float.about_button_width'), - cancelHeight: $r('app.float.privacy_statement_button_height'), - cancelClick: () => { - this.closeWindow(); - } - }) + if (!this.privacyStatementFlag) { + Column() { + CancelButton({ + cancelLabel: $r('app.string.Cancel'), + cancelWidth: $r('app.float.about_button_width'), + cancelHeight: $r('app.float.privacy_statement_button_height'), + cancelClick: () => { + router.back({ url: 'pages/PrintPage' }); + } + }) .margin({ top: $r('app.float.privacy_statement_button_to_text_margin_top') }) + } + .width('100%') + .alignItems(HorizontalAlign.Center) } - .width('100%') - .alignItems(HorizontalAlign.Center) - .visibility(this.privacyStatementFlag ? Visibility.None : Visibility.Visible) } .margin({ bottom: this.privacyStatementFlag ? 0 : $r('app.float.privacy_statement_button_margin_bottom') }) + .width('100%') + .height('100%') } - .width('100%') - .height('100%') - .alignItems(HorizontalAlign.Center) } @@ -114,7 +115,7 @@ struct PrivacyStatementWebPage { if (parseInt(router.getLength()) > 1) { router.back({url: 'pages/AboutPage'}) } else { - this.closeWindow(); + router.replaceUrl({ url: 'pages/PrivacyStatementPage' }) } } } catch (error) { diff --git a/entry/src/main/ets/pages/component/AboutPageComponent.ets b/entry/src/main/ets/pages/component/AboutPageComponent.ets index ee50653..9c7cf27 100644 --- a/entry/src/main/ets/pages/component/AboutPageComponent.ets +++ b/entry/src/main/ets/pages/component/AboutPageComponent.ets @@ -13,8 +13,8 @@ * limitations under the License. */ -import { GlobalThisHelper, GlobalThisStorageKey, Log } from '@ohos/common'; -import window from '@ohos.window'; +import { Log } from '@ohos/common'; +import router from '@ohos.router'; const TAG = 'AboutPageComponent' @Component @@ -25,20 +25,9 @@ export struct AboutPageComponent { Image($r('app.media.ic_public_detail')).width($r('app.float.image_comp_width')).height($r('app.float.image_comp_height')) .onClick(() => { Log.info(TAG, 'PrivacyStatementPage onClick'); - var windowStage = GlobalThisHelper.getValue(GlobalThisStorageKey.KEY_MAIN_ABILITY_WINDOW_STAGE); - windowStage.createSubWindow('AboutPage') - .then((windowMode) => { - windowMode.setUIContent('pages/AboutPage') - // @ts-ignore - windowMode.setForbidSplitMove(false); - windowMode.showWindow((err) => { - if (err.code) { - Log.info(TAG, 'Failed to show the window. Cause: ' + JSON.stringify(err)) - return - } - Log.info(TAG, 'Succeeded in showing the window.') - }) - }) + router.pushUrl({ + url: 'pages/AboutPage' + }) }) .backgroundColor(this.bckColor) .clip(new Circle({width: 24, height: 24})).onTouch((event) => { -- Gitee