From ee9e67bfe03db24f35513e1278c4bdb48fd2323c Mon Sep 17 00:00:00 2001 From: huangxiao <1286409928@qq.com> Date: Mon, 6 Jan 2025 16:42:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0byod=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ib732ccf01900a34df48efb0feb7ab94224568798 Signed-off-by: huangxiao <1286409928@qq.com> --- .../MainAbility/ByodAdminProvisionAbility.ts | 55 +++++++++ .../main/ets/pages/byod/baseByodAdminPage.ets | 108 ++++++++++++++++++ .../ets/pages/byod/byodActivationPage.ets | 93 +++++++++++++++ entry/src/main/module.json | 14 ++- .../resources/base/profile/main_pages.json | 3 +- .../main/resources/zh_CN/element/string.json | 28 +++++ 6 files changed, 299 insertions(+), 2 deletions(-) create mode 100644 entry/src/main/ets/MainAbility/ByodAdminProvisionAbility.ts create mode 100644 entry/src/main/ets/pages/byod/baseByodAdminPage.ets create mode 100644 entry/src/main/ets/pages/byod/byodActivationPage.ets diff --git a/entry/src/main/ets/MainAbility/ByodAdminProvisionAbility.ts b/entry/src/main/ets/MainAbility/ByodAdminProvisionAbility.ts new file mode 100644 index 0000000..7a7a890 --- /dev/null +++ b/entry/src/main/ets/MainAbility/ByodAdminProvisionAbility.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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. + */ + +import UIAbility from '@ohos.app.ability.UIAbility'; +import logger from '../common/logger'; +import type Want from '@ohos.app.ability.Want'; +import type AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import type window from '@ohos.window'; + +const TAG = 'ByosAdminProvisioningAbility'; + +export default class ByosAdminProvisioningAbility extends UIAbility { + private localStorage: LocalStorage = new LocalStorage(); + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + logger.info(TAG, 'onCreate'); + } + + onDestroy(): void { + logger.info(TAG, 'onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + logger.info(TAG, 'onWindowStageCreate'); + windowStage.loadContent('pages/byod/byodActivationPage', this.localStorage); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + logger.info(TAG, 'onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + logger.info(TAG, 'onForeground'); + } + + onBackground(): void { + // Ability has back to background + logger.info(TAG, 'onBackground'); + } +}; diff --git a/entry/src/main/ets/pages/byod/baseByodAdminPage.ets b/entry/src/main/ets/pages/byod/baseByodAdminPage.ets new file mode 100644 index 0000000..9a5d2c4 --- /dev/null +++ b/entry/src/main/ets/pages/byod/baseByodAdminPage.ets @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2025 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. + */ + +const TAG = 'BaseByodAdminPage'; + +@Component +export struct BaseByodAdminPage { + @BuilderParam topBuilderParam: () => void = this.doNothingBuilder; + @BuilderParam centerBuilderParam: () => void = this.doNothingBuilder; + @BuilderParam bottomBuilderParam: () => void = this.doNothingBuilder; + @Prop listTitle: Resource | string = ''; + + @Builder + doNothingBuilder() { + }; + + build() { + Column() { + Column() { + Column() { + this.topBuilderParam(); + } + .width('100%') + .height('56vp') + .padding({ + top: '14.5vp', + bottom: '14.5vp' + }) + .alignItems(HorizontalAlign.Start) + + Column() { + List() { + ListItem() { + Text(this.listTitle) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .fontWeight(FontWeight.Bold) + .lineHeight('24vp') + .fontSize('18vp') + } + .padding({ + top: '24vp', + bottom: '8vp' + }) + .margin({ + bottom: '8vp' + }) + + this.centerBuilderParam(); + } + .width('100%') + .height('100%') + } + .height('80%') + } + + Column() { + this.bottomBuilderParam(); + } + .margin({ + bottom: '16vp' + }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.SpaceBetween) + .padding({ + left: '16vp', + right: '16vp' + }) + } +} + +@Preview +@Component +export struct BottomButton { + @Require @Prop description: string | Resource = ''; + @Require buttonWidth: string = ''; + @Prop isEnabled: boolean = true; + + build() { + Column() { + Button() { + Text(this.description) + .fontSize('16vp') + .lineHeight('21vp') + .fontFamily('HarmonyHeiTi') + .fontWeight(FontWeight.Medium) + .fontColor($r('sys.color.font_emphasize')) + } + .backgroundColor($r('sys.color.comp_background_tertiary')) + .width(this.buttonWidth) + .height('40vp') + .enabled(this.isEnabled) + } + } +} diff --git a/entry/src/main/ets/pages/byod/byodActivationPage.ets b/entry/src/main/ets/pages/byod/byodActivationPage.ets new file mode 100644 index 0000000..cdb4c2b --- /dev/null +++ b/entry/src/main/ets/pages/byod/byodActivationPage.ets @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2025 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. + */ +import { BaseByodAdminPage, BottomButton } from './baseByodAdminPage'; +import common from '@ohos.app.ability.common'; + +const TAG = 'ByodActivationPage'; + +@Entry +@Component +struct ByodActivationPage { + + @Builder + topBuilder() { + Text($r('app.string.byodActivationPageTitle')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .fontWeight(FontWeight.Bold) + .lineHeight('27vp') + .fontSize('20vp') + } + + @Builder + centerBuilder() { + } + + @Builder + bottomBuilder() { + Row({ space: '12vp' }) { + BottomButton({ + description: $r('app.string.byodDisagree'), + buttonWidth: '158vp', + isEnabled: true + }) + .onClick(() => { + (getContext(this) as common.UIAbilityContext).terminateSelf(); + }) + + BottomButton({ + description: $r('app.string.byodAgree'), + buttonWidth: '158vp', + isEnabled: true + }) + .onClick(() => { + AlertDialog.show( + { + title: $r('app.string.canNotActivate'), + message: $r('app.string.doNotSupport'), + autoCancel: true, + alignment: DialogAlignment.Center, + gridCount: 4, + confirm: { + value: $r('app.string.gotIt'), + action: () => { + (getContext(this) as common.UIAbilityContext).terminateSelf(); + } + }, + cancel: () => { + console.info('Closed callbacks') + } + } + ) + }) + } + } + + build() { + Column() { + BaseByodAdminPage({ + topBuilderParam: () => { + this.topBuilder() + }, + listTitle: '', + centerBuilderParam: () => { + this.centerBuilder() + }, + bottomBuilderParam: () => { + this.bottomBuilder() + } + }) + } + } +} diff --git a/entry/src/main/module.json b/entry/src/main/module.json index 8ff0f32..5508f71 100644 --- a/entry/src/main/module.json +++ b/entry/src/main/module.json @@ -48,9 +48,21 @@ "permissions": ["ohos.permission.PROVISIONING_MESSAGE"], "startWindowIcon": "$media:transparent", "startWindowBackground": "$color:color_00000000_transparent" + }, + { + "removeMissionAfterTerminate": true, + "name": "ByodAdminProvisionAbility", + "srcEntrance": "./ets/MainAbility/ByodAdminProvisionAbility.ts", + "description": "$string:description_ByodAdminProvisionAbility", + "icon": "$media:icon", + "exported": true, + "launchType": "singleton", + "permissions": ["ohos.permission.START_PROVISIONING_MESSAGE"], + "startWindowIcon": "$media:transparent", + "startWindowBackground": "$color:color_00000000_transparent" } ], - "extensionAbilities": [ + "extensionAbilities": [ { "name": "MDMUIExtensionAbility", "icon": "$media:icon", diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index ef1f87b..3b42dd1 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -7,6 +7,7 @@ "pages/autoManager/termsShowPage", "pages/autoManager/loadingInfo", "pages/autoManager/setFinishSuccess", - "pages/autoManager/setFinishFail" + "pages/autoManager/setFinishFail", + "pages/byod/byodActivationPage" ] } diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index eb2c6c3..4b6b331 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -155,6 +155,34 @@ { "name": "textApplicationInfoInactive", "value": "激活此管理器可允许应用“%s”执行以下操作:" + }, + { + "name": "description_ByodAdminProvisionAbility", + "value": "激活Byod设备管理器" + }, + { + "name": "byodActivationPageTitle", + "value": "是否激活您的设备?" + }, + { + "name": "byodDisagree", + "value": "不同意" + }, + { + "name": "byodAgree", + "value": "同意" + }, + { + "name": "canNotActivate", + "value": "无法激活" + }, + { + "name": "doNotSupport", + "value": "暂不支持此功能" + }, + { + "name": "gotIt", + "value": "知道了" } ] } \ No newline at end of file -- Gitee