mirror of
https://github.com/openharmony/applications_admin_provisioning.git
synced 2026-07-01 20:35:17 -04:00
@@ -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');
|
||||
}
|
||||
};
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"pages/autoManager/termsShowPage",
|
||||
"pages/autoManager/loadingInfo",
|
||||
"pages/autoManager/setFinishSuccess",
|
||||
"pages/autoManager/setFinishFail"
|
||||
"pages/autoManager/setFinishFail",
|
||||
"pages/byod/byodActivationPage"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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": "知道了"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user