From e9e42821858bf464d9c08c63de75e5ae9080a85b Mon Sep 17 00:00:00 2001 From: jiang-xiaofeng Date: Mon, 14 Feb 2022 11:27:35 +0800 Subject: [PATCH] fix devil number Signed-off-by: jiang-xiaofeng Signed-off-by: jiang-xiaofeng --- .../ets/dynamic/common/components/dialog.ets | 54 ++++++++++--------- .../ets/dynamic/common/utils/constant.ets | 43 +++++++++++++++ .../resources/base/media/ic_call_logs.svg | 39 +++++--------- 3 files changed, 83 insertions(+), 53 deletions(-) create mode 100644 frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/dynamic/common/utils/constant.ets diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/dynamic/common/components/dialog.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/dynamic/common/components/dialog.ets index f1dd95144..388e7f1b2 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/dynamic/common/components/dialog.ets +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/dynamic/common/components/dialog.ets @@ -13,12 +13,13 @@ * limitations under the License. */ -import { getPermissionGroup } from "../utils/utils.ets" -import { BundleFlag, userId } from "../model/bundle.ets" -import featureAbility from '@ohos.ability.featureAbility'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import bundle from '@ohos.bundle'; -import Resmgr from '@ohos.resourceManager'; +import { getPermissionGroup } from '../utils/utils.ets' +import { BundleFlag, userId } from '../model/bundle.ets' +import Constants from '../utils/constant.ets' +import featureAbility from '@ohos.ability.featureAbility' +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' +import bundle from '@ohos.bundle' +import Resmgr from '@ohos.resourceManager' @Extend(Button) function customizeButton() { .backgroundColor($r('app.color.default_background_color')) @@ -28,13 +29,13 @@ import Resmgr from '@ohos.resourceManager'; @CustomDialog export struct privacyDialog { @Link count: number - @Link result: Array + @Link result: Array controller: CustomDialogController cancel: (group, accessTokenId, permissionList, userFixedFlag) => void confirm: (group, accessTokenId, permissionList, userFixedFlag) => void @State accessTokenId: number = 0 @State hasPrepared: boolean = false - @State reqPerms: Array = [] + @State reqPerms: Array = [] @State grantGroups: Array = [] @State userFixedFlag: number = 2 // means user fixed @State appName: string = "" @@ -43,34 +44,35 @@ export struct privacyDialog { Column() { if (this.hasPrepared && this.verify(this.reqPerms[this.count])) { Image(this.grantGroups[this.count].icon) - .width(24) - .height(24) + .width(Constants.DIALOG_ICON_WIDTH) + .height(Constants.DIALOG_ICON_HEIGHT) .margin({ - top: 24 + top: Constants.DIALOG_ICON_MARGIN_TOP }) Text(`${this.count + 1} / ${this.reqPerms.length}`) - .fontSize(14) + .fontSize(Constants.DIALOG_LABEL_FONT_SIZE) .fontColor($r('app.color.secondary_font_color')) .margin({ - top: 2 + top: Constants.DIALOG_LABEL_MARGIN_TOP }) Column() { Row() { Flex({ justifyContent: FlexAlign.Start }) { - Text("是否允许" + this.appName + "访问" + this.grantGroups[this.count].groupName).fontSize(16) + Text("是否允许" + this.appName + "访问" + + this.grantGroups[this.count].groupName).fontSize(Constants.DIALOG_REQ_FONT_SIZE) .margin({ - top: 16, - left: 24 + top: Constants.DIALOG_REQ_MARGIN_TOP, + left: Constants.DIALOG_REQ_MARGIN_LEFT }) } } Row() { Flex({ justifyContent: FlexAlign.Start }) { - Text("用于" + this.grantGroups[this.count].description).fontSize(14) + Text("用于" + this.grantGroups[this.count].description).fontSize(Constants.DIALOG_DESP_FONT_SIZE) .fontColor($r('app.color.secondary_font_color')) .margin({ - top: 2, - left: 24 + top: Constants.DIALOG_DESP_MARGIN_TOP, + left: Constants.DIALOG_DESP_MARGIN_LEFT }) } } @@ -79,16 +81,16 @@ export struct privacyDialog { Row() { Flex({ justifyContent: FlexAlign.SpaceAround }) { Button('禁止') - .fontSize(16) + .fontSize(Constants.BUTTON_FONT_SIZE) .onClick(() => { this.cancel(this.grantGroups[this.count], this.accessTokenId, this.reqPerms, this.userFixedFlag) if (this.count === this.reqPerms.length) { this.controller.close() } }).customizeButton() - Text('|').fontSize(30).fontColor($r('app.color.divider_color')) + Text('|').fontSize(Constants.BUTTON_DIVIDER_FONT_SIZE).fontColor($r('app.color.divider_color')) Button('允许') - .fontSize(16) + .fontSize(Constants.BUTTON_FONT_SIZE) .onClick(() => { this.confirm(this.grantGroups[this.count], this.accessTokenId, this.reqPerms, this.userFixedFlag) if (this.count === this.reqPerms.length) { @@ -96,14 +98,14 @@ export struct privacyDialog { } }).customizeButton() }.margin({ - top: 8 + top: Constants.BUTTON_MARGIN_TOP }) } } .backgroundColor($r('app.color.default_background_color')) - .borderRadius(24) - .height(186) - .width(336) + .borderRadius(Constants.DIALOG_BORDER_RADIUS) + .height(Constants.DIALOG_HEIGHT) + .width(Constants.DIALOG_WIDTH) } async verify(permission) { if(this.count >= this.grantGroups.length) { diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/dynamic/common/utils/constant.ets b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/dynamic/common/utils/constant.ets new file mode 100644 index 000000000..700486b60 --- /dev/null +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/ets/dynamic/common/utils/constant.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default class Constants { + // icon of dialog + static DIALOG_ICON_WIDTH = 24; + static DIALOG_ICON_HEIGHT = 24; + static DIALOG_ICON_MARGIN_TOP = 24; + + // label text of dialog + static DIALOG_LABEL_FONT_SIZE = 14; + static DIALOG_LABEL_MARGIN_TOP = 2; + + // request text of dialog + static DIALOG_REQ_FONT_SIZE = 16; + static DIALOG_REQ_MARGIN_TOP = 16; + static DIALOG_REQ_MARGIN_LEFT = 24; + + // description text of dialog + static DIALOG_DESP_FONT_SIZE = 14; + static DIALOG_DESP_MARGIN_TOP = 2; + static DIALOG_DESP_MARGIN_LEFT = 24; + + static BUTTON_FONT_SIZE = 16; + static BUTTON_DIVIDER_FONT_SIZE = 30; + static BUTTON_MARGIN_TOP = 8; + + static DIALOG_BORDER_RADIUS = 24; + static DIALOG_HEIGHT = 186; + static DIALOG_WIDTH = 336; +} \ No newline at end of file diff --git a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_call_logs.svg b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_call_logs.svg index d3ff7d855..42f8ad97c 100644 --- a/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_call_logs.svg +++ b/frameworks/com.ohos.permissionmanager/permissionmanager/src/main/resources/base/media/ic_call_logs.svg @@ -2,30 +2,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + -- Gitee