mirror of
https://gitee.com/openharmony/applications_dlp_manager
synced 2024-11-23 09:59:57 +00:00
Signed-off-by: ml <mengli12@huawei.com>
This commit is contained in:
parent
7105983f9f
commit
b9abdcd1f7
@ -37,7 +37,7 @@ import {
|
||||
} from '../common/utils';
|
||||
import GlobalContext from '../common/GlobalContext';
|
||||
import HomeFeature from '../feature/HomeFeature';
|
||||
import { AccountTipsConfig } from '../common/AccountTipsConfig';
|
||||
import { AccountTipsConfig } from '../component/AccountTipsConfig';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import { GetAlertMessage } from '../common/GetAlertMessage';
|
||||
import { HiLog } from '../common/HiLog';
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 rpc from '@ohos.rpc';
|
||||
import ConnectService from './ConnectService';
|
||||
import { HiLog } from '../HiLog';
|
||||
import Constants from '../constant';
|
||||
|
||||
const TAG = 'CredCallbackStub';
|
||||
|
||||
export default class CredCallbackStub extends rpc.RemoteObject {
|
||||
private connectService: ConnectService = new ConnectService(getContext(this));
|
||||
private static readonly DESCRIPTOR: string = 'OHOS.HapDlpCredAbilityServiceStub';
|
||||
|
||||
constructor(des: string) {
|
||||
super(des);
|
||||
}
|
||||
|
||||
asObject(): rpc.IRemoteObject {
|
||||
return this;
|
||||
}
|
||||
|
||||
async onRemoteMessageRequest(code: number, data: rpc.MessageSequence): Promise<boolean> {
|
||||
HiLog.info(TAG, `onRemoteMessageRequest called, code = ${code}`);
|
||||
try {
|
||||
if (data.readInterfaceToken() !== CredCallbackStub.DESCRIPTOR) {
|
||||
HiLog.info(TAG, `DESCRIPTOR unmatched.`);
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
HiLog.error(TAG, `read data exception, error is ${JSON.stringify(error)}`);
|
||||
return false;
|
||||
}
|
||||
switch (code) {
|
||||
case Constants.COMMAND_SEARCH_USER_INFO: {
|
||||
let storage = LocalStorage.getShared();
|
||||
HiLog.info(TAG, `onRemoteMessageRequest command search user info`);
|
||||
let resultVar = '';
|
||||
try {
|
||||
resultVar = data.readString();
|
||||
} catch (error) {
|
||||
HiLog.error(TAG, `read string exception, error is ${JSON.stringify(error)}`);
|
||||
return false;
|
||||
}
|
||||
storage.setOrCreate('commandSearchUserInfo', resultVar);
|
||||
this.connectService.disconnectServiceShareAbility();
|
||||
return true;
|
||||
}
|
||||
case Constants.COMMAND_GET_ACCOUNT_INFO: {
|
||||
let storage = LocalStorage.getShared();
|
||||
HiLog.info(TAG, `onRemoteMessageRequest command get account info`);
|
||||
let resultVar = '';
|
||||
try {
|
||||
resultVar = data.readString();
|
||||
} catch (error) {
|
||||
HiLog.error(TAG, `read string exception, error is ${JSON.stringify(error)}`);
|
||||
return false;
|
||||
}
|
||||
storage.setOrCreate('commandGetAccountInfo', resultVar);
|
||||
this.connectService.disconnectServiceShareAbility();
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
HiLog.error(TAG, `invalid request code: ${code}`);
|
||||
this.connectService.disconnectServiceShareAbility();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ import resourceManager from '@ohos.resourceManager';
|
||||
import util from '@ohos.util';
|
||||
import osAccount from '@ohos.account.osAccount';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import GlobalContext from './GlobalContext';
|
||||
import GlobalContext from '../common/GlobalContext';
|
||||
import I18n from '@ohos.i18n';
|
||||
import { HiLog } from '../common/HiLog';
|
||||
|
@ -15,13 +15,13 @@
|
||||
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import { staffItem } from './staff';
|
||||
import Constants from '../constant';
|
||||
import Constants from '../../common/constant';
|
||||
import { AccountTipsConfig } from '../AccountTipsConfig';
|
||||
import { HiLog } from '../HiLog';
|
||||
import CommonUtil from '../CommonUtil';
|
||||
import { HiLog } from '../../common/HiLog';
|
||||
import CommonUtil from '../../common/CommonUtil';
|
||||
import AccountManager from '../../manager/AccountManager';
|
||||
import DomainAccountResponse from '../../bean/response/DomainAccountResponse';
|
||||
import AppStorageConstant from '../constant/AppStorageConstant';
|
||||
import AppStorageConstant from '../../common/constant/AppStorageConstant';
|
||||
import { common } from '@kit.AbilityKit';
|
||||
import DomainAccountInfo from '../../bean/data/DomainAccountInfo';
|
||||
|
@ -1,76 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 Constants from '../constant';
|
||||
|
||||
@Component
|
||||
struct EncryptingPanel {
|
||||
@Link processing: boolean;
|
||||
@Prop loadingType: number = 0;
|
||||
|
||||
loadingText() {
|
||||
if (this.loadingType === Constants.LOAD_TYPE_CE) {
|
||||
return $r('app.string.loading_title');
|
||||
} else {
|
||||
return $r('app.string.encryption_loading_title');
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
if (this.processing) {
|
||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center,
|
||||
direction: FlexDirection.Column }) {
|
||||
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||
Column() {
|
||||
Row() {
|
||||
Text($r('app.string.header_title'))
|
||||
.fontWeight(FontWeight.Bold)
|
||||
.fontFamily($r('app.string.typeface'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_dialog_tittle'))
|
||||
.width(Constants.HEADER_TEXT_WIDTH)
|
||||
.align(Alignment.Start)
|
||||
}
|
||||
.width(Constants.HEADER_COLUMN_WIDTH)
|
||||
.height(Constants.HEADER_COLUMN_HEIGHT)
|
||||
.padding({
|
||||
left: Constants.HEADER_COLUMN_PADDING_LEFT,
|
||||
right: Constants.HEADER_COLUMN_PADDING_RIGHT
|
||||
})
|
||||
Column() {
|
||||
LoadingProgress()
|
||||
.color($r('sys.color.ohos_id_color_progress'))
|
||||
.height(Constants.ENCRYPTION_LOADING_ICON_HEIGHT)
|
||||
.width(Constants.ENCRYPTION_LOADING_ICON_HEIGHT)
|
||||
Text(this.loadingText())
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_secondary'))
|
||||
}
|
||||
.height(Constants.ENCRYPTION_LOADING_CONTENT_HEIGHT)
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
.justifyContent(FlexAlign.Center)
|
||||
}
|
||||
.width(Constants.ENCRYPTION_PC_FIXING_WIDTH)
|
||||
.height(Constants.ENCRYPTION_LOADING_HEIGHT)
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_dialog'))
|
||||
.constraintSize({ minWidth: Constants.ENCRYPTION_PC_FIXING_WIDTH })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { EncryptingPanel };
|
||||
/*
|
||||
* Copyright (c) 2023 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 Constants from '../../common/constant';
|
||||
|
||||
@Component
|
||||
struct EncryptingPanel {
|
||||
@Link processing: boolean;
|
||||
@Prop loadingType: number = 0;
|
||||
|
||||
loadingText() {
|
||||
if (this.loadingType === Constants.LOAD_TYPE_CE) {
|
||||
return $r('app.string.loading_title');
|
||||
} else {
|
||||
return $r('app.string.encryption_loading_title');
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
if (this.processing) {
|
||||
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center,
|
||||
direction: FlexDirection.Column }) {
|
||||
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||
Column() {
|
||||
Row() {
|
||||
Text($r('app.string.header_title'))
|
||||
.fontWeight(FontWeight.Bold)
|
||||
.fontFamily($r('app.string.typeface'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_dialog_tittle'))
|
||||
.width(Constants.HEADER_TEXT_WIDTH)
|
||||
.align(Alignment.Start)
|
||||
}
|
||||
.width(Constants.HEADER_COLUMN_WIDTH)
|
||||
.height(Constants.HEADER_COLUMN_HEIGHT)
|
||||
.padding({
|
||||
left: Constants.HEADER_COLUMN_PADDING_LEFT,
|
||||
right: Constants.HEADER_COLUMN_PADDING_RIGHT
|
||||
})
|
||||
Column() {
|
||||
LoadingProgress()
|
||||
.color($r('sys.color.ohos_id_color_progress'))
|
||||
.height(Constants.ENCRYPTION_LOADING_ICON_HEIGHT)
|
||||
.width(Constants.ENCRYPTION_LOADING_ICON_HEIGHT)
|
||||
Text(this.loadingText())
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_secondary'))
|
||||
}
|
||||
.height(Constants.ENCRYPTION_LOADING_CONTENT_HEIGHT)
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
.justifyContent(FlexAlign.Center)
|
||||
}
|
||||
.width(Constants.ENCRYPTION_PC_FIXING_WIDTH)
|
||||
.height(Constants.ENCRYPTION_LOADING_HEIGHT)
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_dialog'))
|
||||
.constraintSize({ minWidth: Constants.ENCRYPTION_PC_FIXING_WIDTH })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { EncryptingPanel };
|
@ -1,174 +1,174 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 Constants from '../constant';
|
||||
import { AuthAccount, PermissionType } from '../utils';
|
||||
|
||||
const TAG = 'Select';
|
||||
|
||||
@Extend(MenuItem)
|
||||
function timeTextStyle() {
|
||||
.labelFont({ size: $r('sys.float.ohos_id_text_size_body1'), weight: FontWeight.Regular })
|
||||
.margin({
|
||||
left: Constants.ENCRYPTION_PROTECTION_TIME_MENU_MARGIN_LEFT,
|
||||
right: Constants.ENCRYPTION_PROTECTION_TIME_MENU_MARGIN_RIGHT
|
||||
})
|
||||
.padding({
|
||||
left: Constants.ENCRYPTION_PROTECTION_TIME_MENU_PADDING_LEFT,
|
||||
right: Constants.ENCRYPTION_PROTECTION_TIME_MENU_PADDING_RIGHT,
|
||||
})
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_default_m'))
|
||||
}
|
||||
|
||||
@Component
|
||||
struct permissionTypeSelect {
|
||||
@State index: number = 0;
|
||||
@Prop isReadType: boolean = false;
|
||||
@State permissionTypes: PermissionType[] = [
|
||||
{ value: $r('app.string.PERMISSION_TYPE_SELECT_TARGET'), data: 'target', index: 0 },
|
||||
{ value: $r('app.string.PERMISSION_TYPE_SELECT_ALL'), data: 'all', index: 1 },
|
||||
{ value: $r('app.string.PERMISSION_TYPE_SELECT_SELF'), data: 'self', index: 2 }
|
||||
];
|
||||
@Link @Watch('selectedItemUpdated') selectedItem: PermissionType;
|
||||
@Link staffArray: AuthAccount[];
|
||||
@Prop @Watch('onCountUpdated') isDisable: boolean = false;
|
||||
|
||||
onCountUpdated(isDisable: boolean): void {
|
||||
if (this.isReadType) {
|
||||
if (this.isDisable) {
|
||||
this.selectedItem = this.permissionTypes[Constants.ENCRYPTION_TYPE_SELECT];
|
||||
this.index = Constants.ENCRYPTION_TYPE_SELECT;
|
||||
} else {
|
||||
this.selectedItem = this.permissionTypes[Constants.ENCRYPTION_TYPE_SELECT_INDEX];
|
||||
this.index = Constants.ENCRYPTION_TYPE_SELECT_INDEX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
selectedItemUpdated(selectedItem: object): void {
|
||||
this.index = this.selectedItem.index;
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
if (this.isReadType) {
|
||||
this.permissionTypes = this.permissionTypes.filter(item => {
|
||||
return item.data !== 'self';
|
||||
})
|
||||
}
|
||||
setTimeout(() => {
|
||||
let selectIndex = this.selectedItem.index === -1 ? 0 : this.selectedItem.index;
|
||||
this.selectedItem = this.permissionTypes[selectIndex];
|
||||
}, Constants.ENCRYPTION_SET_TIMEOUT_TIME)
|
||||
}
|
||||
|
||||
@Builder
|
||||
PermissionTypeMenu() {
|
||||
Menu() {
|
||||
ForEach(this.permissionTypes, (item: PermissionType) => {
|
||||
MenuItem({ content: item.value })
|
||||
.selected(this.index === item.index)
|
||||
.selectIcon(true)
|
||||
.onChange(() => {
|
||||
this.index = item.index;
|
||||
this.selectedItem = this.permissionTypes[item.index];
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Text() {
|
||||
Span(this.permissionTypes[this.index].value)
|
||||
Span(`${this.selectedItem?.data === 'target' && this.staffArray.length > 0 ?
|
||||
` (${this.staffArray.length})` : ''}`)
|
||||
}
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor($r('sys.color.ohos_id_color_text_secondary'));
|
||||
|
||||
SymbolGlyph($r('sys.symbol.arrowtriangle_down_fill'))
|
||||
.fontSize(`${Constants.VALIDITY_IMAGE_WIDTH}vp`)
|
||||
.fontColor([$r('sys.color.ohos_id_color_tertiary')])
|
||||
.margin({
|
||||
left: Constants.VALIDITY_IMAGE_PADDING_LEFT,
|
||||
right: Constants.VALIDITY_IMAGE_PADDING_RIGHT
|
||||
});
|
||||
}
|
||||
.opacity(this.isDisable ? Constants.DU_LINE_WIDTH : Constants.FOOTER_OPACITY_ONE)
|
||||
.enabled(this.isDisable ? false : true)
|
||||
.bindMenu(this.PermissionTypeMenu, { placement: Placement.BottomRight, showInSubWindow: false });
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct validDateTypeMenuItem {
|
||||
@Link selectedIndex: number;
|
||||
@State perMissionTypes: PermissionType[] = [
|
||||
{ value: $r('app.string.permanently'), data: 'permanently', index: 0 },
|
||||
{ value: $r('app.string.Appointed_day'), data: 'Appointed_day', index: 1 }
|
||||
];
|
||||
|
||||
build() {
|
||||
Menu() {
|
||||
ForEach(this.perMissionTypes, (item: PermissionType) => {
|
||||
MenuItem({ content: item.value })
|
||||
.selected(this.selectedIndex === item.index)
|
||||
.selectIcon(true)
|
||||
.timeTextStyle()
|
||||
.onChange(() => {
|
||||
this.selectedIndex = item.index;
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct validDateTypeMenu {
|
||||
@Link selectedIndex: number;
|
||||
@Prop isDisable: boolean = false;
|
||||
@State validDateTypes: PermissionType[] = [
|
||||
{ value: $r('app.string.permanently'), data: 'permanently', index: 0 },
|
||||
{ value: $r('app.string.Appointed_day'), data: 'Appointed_day', index: 1 }
|
||||
];
|
||||
|
||||
@Builder
|
||||
ValidDateMenuItem() {
|
||||
validDateTypeMenuItem({ selectedIndex: $selectedIndex });
|
||||
}
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Text(this.validDateTypes[this.selectedIndex].value)
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor($r('sys.color.ohos_id_color_text_secondary'));
|
||||
|
||||
SymbolGlyph($r('sys.symbol.arrowtriangle_down_fill'))
|
||||
.fontSize(`${Constants.VALIDITY_IMAGE_WIDTH}vp`)
|
||||
.fontColor([$r('sys.color.ohos_id_color_tertiary')])
|
||||
.margin({
|
||||
left: Constants.VALIDITY_IMAGE_PADDING_LEFT,
|
||||
right: Constants.VALIDITY_IMAGE_PADDING_RIGHT
|
||||
});
|
||||
}
|
||||
.opacity(this.isDisable ? Constants.DU_LINE_WIDTH : Constants.FOOTER_OPACITY_ONE)
|
||||
.enabled(this.isDisable ? false : true)
|
||||
.bindMenu(this.ValidDateMenuItem(), { placement: Placement.BottomRight, showInSubWindow: false });
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright (c) 2023 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 Constants from '../../common/constant';
|
||||
import { AuthAccount, PermissionType } from '../../common/utils';
|
||||
|
||||
const TAG = 'Select';
|
||||
|
||||
@Extend(MenuItem)
|
||||
function timeTextStyle() {
|
||||
.labelFont({ size: $r('sys.float.ohos_id_text_size_body1'), weight: FontWeight.Regular })
|
||||
.margin({
|
||||
left: Constants.ENCRYPTION_PROTECTION_TIME_MENU_MARGIN_LEFT,
|
||||
right: Constants.ENCRYPTION_PROTECTION_TIME_MENU_MARGIN_RIGHT
|
||||
})
|
||||
.padding({
|
||||
left: Constants.ENCRYPTION_PROTECTION_TIME_MENU_PADDING_LEFT,
|
||||
right: Constants.ENCRYPTION_PROTECTION_TIME_MENU_PADDING_RIGHT,
|
||||
})
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_default_m'))
|
||||
}
|
||||
|
||||
@Component
|
||||
struct permissionTypeSelect {
|
||||
@State index: number = 0;
|
||||
@Prop isReadType: boolean = false;
|
||||
@State permissionTypes: PermissionType[] = [
|
||||
{ value: $r('app.string.PERMISSION_TYPE_SELECT_TARGET'), data: 'target', index: 0 },
|
||||
{ value: $r('app.string.PERMISSION_TYPE_SELECT_ALL'), data: 'all', index: 1 },
|
||||
{ value: $r('app.string.PERMISSION_TYPE_SELECT_SELF'), data: 'self', index: 2 }
|
||||
];
|
||||
@Link @Watch('selectedItemUpdated') selectedItem: PermissionType;
|
||||
@Link staffArray: AuthAccount[];
|
||||
@Prop @Watch('onCountUpdated') isDisable: boolean = false;
|
||||
|
||||
onCountUpdated(isDisable: boolean): void {
|
||||
if (this.isReadType) {
|
||||
if (this.isDisable) {
|
||||
this.selectedItem = this.permissionTypes[Constants.ENCRYPTION_TYPE_SELECT];
|
||||
this.index = Constants.ENCRYPTION_TYPE_SELECT;
|
||||
} else {
|
||||
this.selectedItem = this.permissionTypes[Constants.ENCRYPTION_TYPE_SELECT_INDEX];
|
||||
this.index = Constants.ENCRYPTION_TYPE_SELECT_INDEX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
selectedItemUpdated(selectedItem: object): void {
|
||||
this.index = this.selectedItem.index;
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
if (this.isReadType) {
|
||||
this.permissionTypes = this.permissionTypes.filter(item => {
|
||||
return item.data !== 'self';
|
||||
})
|
||||
}
|
||||
setTimeout(() => {
|
||||
let selectIndex = this.selectedItem.index === -1 ? 0 : this.selectedItem.index;
|
||||
this.selectedItem = this.permissionTypes[selectIndex];
|
||||
}, Constants.ENCRYPTION_SET_TIMEOUT_TIME)
|
||||
}
|
||||
|
||||
@Builder
|
||||
PermissionTypeMenu() {
|
||||
Menu() {
|
||||
ForEach(this.permissionTypes, (item: PermissionType) => {
|
||||
MenuItem({ content: item.value })
|
||||
.selected(this.index === item.index)
|
||||
.selectIcon(true)
|
||||
.onChange(() => {
|
||||
this.index = item.index;
|
||||
this.selectedItem = this.permissionTypes[item.index];
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Text() {
|
||||
Span(this.permissionTypes[this.index].value)
|
||||
Span(`${this.selectedItem?.data === 'target' && this.staffArray.length > 0 ?
|
||||
` (${this.staffArray.length})` : ''}`)
|
||||
}
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor($r('sys.color.ohos_id_color_text_secondary'));
|
||||
|
||||
SymbolGlyph($r('sys.symbol.arrowtriangle_down_fill'))
|
||||
.fontSize(`${Constants.VALIDITY_IMAGE_WIDTH}vp`)
|
||||
.fontColor([$r('sys.color.ohos_id_color_tertiary')])
|
||||
.margin({
|
||||
left: Constants.VALIDITY_IMAGE_PADDING_LEFT,
|
||||
right: Constants.VALIDITY_IMAGE_PADDING_RIGHT
|
||||
});
|
||||
}
|
||||
.opacity(this.isDisable ? Constants.DU_LINE_WIDTH : Constants.FOOTER_OPACITY_ONE)
|
||||
.enabled(this.isDisable ? false : true)
|
||||
.bindMenu(this.PermissionTypeMenu, { placement: Placement.BottomRight, showInSubWindow: false });
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct validDateTypeMenuItem {
|
||||
@Link selectedIndex: number;
|
||||
@State perMissionTypes: PermissionType[] = [
|
||||
{ value: $r('app.string.permanently'), data: 'permanently', index: 0 },
|
||||
{ value: $r('app.string.Appointed_day'), data: 'Appointed_day', index: 1 }
|
||||
];
|
||||
|
||||
build() {
|
||||
Menu() {
|
||||
ForEach(this.perMissionTypes, (item: PermissionType) => {
|
||||
MenuItem({ content: item.value })
|
||||
.selected(this.selectedIndex === item.index)
|
||||
.selectIcon(true)
|
||||
.timeTextStyle()
|
||||
.onChange(() => {
|
||||
this.selectedIndex = item.index;
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct validDateTypeMenu {
|
||||
@Link selectedIndex: number;
|
||||
@Prop isDisable: boolean = false;
|
||||
@State validDateTypes: PermissionType[] = [
|
||||
{ value: $r('app.string.permanently'), data: 'permanently', index: 0 },
|
||||
{ value: $r('app.string.Appointed_day'), data: 'Appointed_day', index: 1 }
|
||||
];
|
||||
|
||||
@Builder
|
||||
ValidDateMenuItem() {
|
||||
validDateTypeMenuItem({ selectedIndex: $selectedIndex });
|
||||
}
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Text(this.validDateTypes[this.selectedIndex].value)
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor($r('sys.color.ohos_id_color_text_secondary'));
|
||||
|
||||
SymbolGlyph($r('sys.symbol.arrowtriangle_down_fill'))
|
||||
.fontSize(`${Constants.VALIDITY_IMAGE_WIDTH}vp`)
|
||||
.fontColor([$r('sys.color.ohos_id_color_tertiary')])
|
||||
.margin({
|
||||
left: Constants.VALIDITY_IMAGE_PADDING_LEFT,
|
||||
right: Constants.VALIDITY_IMAGE_PADDING_RIGHT
|
||||
});
|
||||
}
|
||||
.opacity(this.isDisable ? Constants.DU_LINE_WIDTH : Constants.FOOTER_OPACITY_ONE)
|
||||
.enabled(this.isDisable ? false : true)
|
||||
.bindMenu(this.ValidDateMenuItem(), { placement: Placement.BottomRight, showInSubWindow: false });
|
||||
}
|
||||
}
|
||||
|
||||
export { permissionTypeSelect, validDateTypeMenuItem, validDateTypeMenu };
|
@ -1,211 +1,211 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 account_osAccount from '@ohos.account.osAccount';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import Constants from '../constant';
|
||||
import { AccountTips, AccountTipsConfig } from '../AccountTipsConfig';
|
||||
import { GetAlertMessage } from '../GetAlertMessage';
|
||||
import { DlpAlertDialog } from '../components/dlp_alert_dialog';
|
||||
import { HiLog } from '../HiLog';
|
||||
import { SystemUtils } from '../systemUtils';
|
||||
import AccountManager from '../../manager/AccountManager';
|
||||
import accountManager from '@ohos.enterprise.accountManager';
|
||||
import DomainAccountInfo from '../../bean/data/DomainAccountInfo';
|
||||
|
||||
const TAG = 'staff';
|
||||
|
||||
@Extend(Text)
|
||||
function tipsTextStyle() {
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.textOverflow({
|
||||
overflow: TextOverflow.Ellipsis
|
||||
})
|
||||
.maxLines(Constants.PP_TEXT_MAX_LINE)
|
||||
}
|
||||
|
||||
@Component
|
||||
struct staffItem {
|
||||
@Prop authAccount: string = '';
|
||||
@Prop isActive: boolean = false;
|
||||
@State color: Resource[] = [
|
||||
$r('sys.color.multi_color_01'),
|
||||
$r('sys.color.multi_color_02'),
|
||||
$r('sys.color.multi_color_03'),
|
||||
$r('sys.color.multi_color_04'),
|
||||
$r('sys.color.multi_color_05'),
|
||||
$r('sys.color.multi_color_06'),
|
||||
$r('sys.color.multi_color_07'),
|
||||
$r('sys.color.multi_color_08'),
|
||||
$r('sys.color.multi_color_09'),
|
||||
$r('sys.color.multi_color_10'),
|
||||
$r('sys.color.multi_color_11'),
|
||||
];
|
||||
@Prop changeIndex: number = 0;
|
||||
@State domainTips: string = '';
|
||||
@State accountNameTips: string = '';
|
||||
@State handlePopupTips: boolean = false;
|
||||
|
||||
@Prop textContent: string = '';
|
||||
@State accountTipsArray: AccountTips[] = [];
|
||||
@State isHover: boolean = false;
|
||||
dlpAlertDialog?: CustomDialogController;
|
||||
|
||||
@Builder popupBuilderTips() {
|
||||
Column() {
|
||||
ForEach(this.accountTipsArray, (item: AccountTips) => {
|
||||
if (item.isShow) {
|
||||
Row() {
|
||||
if (AccountTipsConfig.isSysLanguage()) {
|
||||
Text(item.description?.replace('%s', item.value)).tipsTextStyle()
|
||||
} else {
|
||||
Text(item.descriptionEn?.replace('%s', item.value)).tipsTextStyle()
|
||||
}
|
||||
}.height(Constants.TIPS_HEIGHT_ITEM)
|
||||
}
|
||||
}, (item: AccountTips) => item.key)
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.padding({
|
||||
left: Constants.ROW_FONT_SIZE,
|
||||
right: Constants.ROW_FONT_SIZE,
|
||||
top: Constants.DA_MARGIN_TOP,
|
||||
bottom: Constants.DA_MARGIN_TOP
|
||||
})
|
||||
}
|
||||
|
||||
private rollColor() {
|
||||
while (this.changeIndex > this.color.length - 1) {
|
||||
this.changeIndex = this.changeIndex - this.color.length
|
||||
}
|
||||
return this.color[this.changeIndex]
|
||||
}
|
||||
|
||||
private showErrorDialog(title: Resource, message: Resource) {
|
||||
this.dlpAlertDialog = new CustomDialogController({
|
||||
builder: DlpAlertDialog({
|
||||
title: title,
|
||||
message: message,
|
||||
action: () => {
|
||||
}
|
||||
}),
|
||||
autoCancel: false,
|
||||
customStyle: true,
|
||||
});
|
||||
this.dlpAlertDialog.open();
|
||||
}
|
||||
|
||||
private splitContent() {
|
||||
if (this.textContent) {
|
||||
if (this.textContent.length > Constants.TIPS_NAME_LENGTH) {
|
||||
return this.textContent.split('').join(Constants.TIPS_SPACE_ZERO)
|
||||
} else if (this.textContent.length === Constants.TIPS_NAME_LENGTH) {
|
||||
return this.textContent.split('').join(Constants.TIPS_SPACE_EM)
|
||||
} else {
|
||||
return Constants.TIPS_SPACE_EN + this.textContent;
|
||||
}
|
||||
}
|
||||
return this.textContent;
|
||||
}
|
||||
|
||||
private getFontWeight() {
|
||||
try {
|
||||
return (getContext(this) as common.UIAbilityContext).resourceManager.getNumber(
|
||||
$r('sys.float.font_weight_semibold'));
|
||||
} catch (error) {
|
||||
HiLog.error(TAG, `getFontWeight callback getNumber failed: ${JSON.stringify(error)}.`);
|
||||
return FontWeight.Regular;
|
||||
}
|
||||
}
|
||||
|
||||
async aboutToAppear() {
|
||||
AccountManager.connectAbility(getContext(this) as common.UIAbilityContext);
|
||||
}
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Stack() {
|
||||
Circle({ width: Constants.HEADER_ROW_FONT_SIZE, height: Constants.HEADER_ROW_FONT_SIZE })
|
||||
.fill(this.rollColor())
|
||||
.opacity(Constants.FOOTER_OPACITY_MID);
|
||||
Text(this.authAccount?.[0]?.toLocaleUpperCase())
|
||||
.fontSize(Constants.STAFF_FONT_SIZE)
|
||||
.fontWeight(this.getFontWeight())
|
||||
.width(Constants.HEADER_ROW_FONT_SIZE)
|
||||
.height(Constants.HEADER_ROW_FONT_SIZE)
|
||||
.borderRadius(Constants.ENCRYPTION_STAFF_BORDER_RADIUS)
|
||||
.fontColor($r('sys.color.ohos_fa_text_contrary'))
|
||||
.textAlign(TextAlign.Center)
|
||||
.opacity(Constants.FOOTER_OPACITY_MID)
|
||||
.padding({ bottom: Constants.STAFF_FONT_PADDING });
|
||||
}
|
||||
.margin({
|
||||
left: SystemUtils.isRTL() ? Constants.ADD_STAFF_ITEM_MARGIN_RIGHT : Constants.ADD_STAFF_ITEM_MARGIN_LEFT,
|
||||
right: SystemUtils.isRTL() ? Constants.ADD_STAFF_ITEM_MARGIN_LEFT : Constants.ADD_STAFF_ITEM_MARGIN_RIGHT,
|
||||
});
|
||||
Text(this.splitContent())
|
||||
.textOverflow({
|
||||
overflow: TextOverflow.Ellipsis
|
||||
})
|
||||
.maxLines(Constants.PP_TEXT_MAX_LINE)
|
||||
.fontSize($r('sys.float.ohos_id_text_size_button3'))
|
||||
.height(Constants.HEADER_ROW_FONT_SIZE);
|
||||
}
|
||||
.onClick(async () => {
|
||||
try {
|
||||
let accountInfo: DomainAccountInfo = await AccountManager.getDomainAccountByAccountName(this.authAccount);
|
||||
this.accountTipsArray = await AccountTipsConfig.getConfigTips();
|
||||
this.handlePopupTips = !this.handlePopupTips;
|
||||
this.accountTipsArray?.forEach((item: AccountTips) => {
|
||||
item.value = accountInfo[item.key];
|
||||
})
|
||||
} catch (error) {
|
||||
HiLog.error(TAG, `getFontWeight callback getNumber failed: ${JSON.stringify(error)}.`);
|
||||
}
|
||||
})
|
||||
.hitTestBehavior(HitTestMode.Block)
|
||||
.bindPopup(this.handlePopupTips, {
|
||||
builder: this.popupBuilderTips,
|
||||
placement: SystemUtils.isRTL() ? Placement.BottomRight : Placement.BottomLeft,
|
||||
enableArrow: true,
|
||||
showInSubWindow: false,
|
||||
onStateChange: (e) => {
|
||||
if (!e.isVisible) {
|
||||
this.handlePopupTips = false;
|
||||
}
|
||||
}
|
||||
})
|
||||
.height(Constants.ENCRYPTION_ADD_STAFF_HEIGHT)
|
||||
.alignItems(VerticalAlign.Center)
|
||||
.backgroundColor(this.isActive && this.handlePopupTips ? '#1A0A59F7' : $r('sys.color.ohos_id_color_button_normal'))
|
||||
.borderRadius(Constants.ENCRYPTION_SUCCESS_CHANGE_TOP)
|
||||
.padding(
|
||||
{
|
||||
top: Constants.ENCRYPTION_STAFF_PAD,
|
||||
bottom: Constants.ENCRYPTION_STAFF_PAD,
|
||||
left: Constants.ENCRYPTION_STAFF_ITEM_MARGIN,
|
||||
right: Constants.ENCRYPTION_STAFF_ITEM_MARGIN
|
||||
}
|
||||
)
|
||||
.margin({
|
||||
right: Constants.ENCRYPTION_ADD_STAFF_MARGIN_RIGHT,
|
||||
top: Constants.ENCRYPTION_ADD_STAFF_MARGIN_BOTTOM
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export { staffItem };
|
||||
/*
|
||||
* Copyright (c) 2023 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 account_osAccount from '@ohos.account.osAccount';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import Constants from '../../common/constant';
|
||||
import { AccountTips, AccountTipsConfig } from '../AccountTipsConfig';
|
||||
import { GetAlertMessage } from '../../common/GetAlertMessage';
|
||||
import { DlpAlertDialog } from '../../common/components/dlp_alert_dialog';
|
||||
import { HiLog } from '../../common/HiLog';
|
||||
import { SystemUtils } from '../../common/systemUtils';
|
||||
import AccountManager from '../../manager/AccountManager';
|
||||
import accountManager from '@ohos.enterprise.accountManager';
|
||||
import DomainAccountInfo from '../../bean/data/DomainAccountInfo';
|
||||
|
||||
const TAG = 'staff';
|
||||
|
||||
@Extend(Text)
|
||||
function tipsTextStyle() {
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.textOverflow({
|
||||
overflow: TextOverflow.Ellipsis
|
||||
})
|
||||
.maxLines(Constants.PP_TEXT_MAX_LINE)
|
||||
}
|
||||
|
||||
@Component
|
||||
struct staffItem {
|
||||
@Prop authAccount: string = '';
|
||||
@Prop isActive: boolean = false;
|
||||
@State color: Resource[] = [
|
||||
$r('sys.color.multi_color_01'),
|
||||
$r('sys.color.multi_color_02'),
|
||||
$r('sys.color.multi_color_03'),
|
||||
$r('sys.color.multi_color_04'),
|
||||
$r('sys.color.multi_color_05'),
|
||||
$r('sys.color.multi_color_06'),
|
||||
$r('sys.color.multi_color_07'),
|
||||
$r('sys.color.multi_color_08'),
|
||||
$r('sys.color.multi_color_09'),
|
||||
$r('sys.color.multi_color_10'),
|
||||
$r('sys.color.multi_color_11'),
|
||||
];
|
||||
@Prop changeIndex: number = 0;
|
||||
@State domainTips: string = '';
|
||||
@State accountNameTips: string = '';
|
||||
@State handlePopupTips: boolean = false;
|
||||
|
||||
@Prop textContent: string = '';
|
||||
@State accountTipsArray: AccountTips[] = [];
|
||||
@State isHover: boolean = false;
|
||||
dlpAlertDialog?: CustomDialogController;
|
||||
|
||||
@Builder popupBuilderTips() {
|
||||
Column() {
|
||||
ForEach(this.accountTipsArray, (item: AccountTips) => {
|
||||
if (item.isShow) {
|
||||
Row() {
|
||||
if (AccountTipsConfig.isSysLanguage()) {
|
||||
Text(item.description?.replace('%s', item.value)).tipsTextStyle()
|
||||
} else {
|
||||
Text(item.descriptionEn?.replace('%s', item.value)).tipsTextStyle()
|
||||
}
|
||||
}.height(Constants.TIPS_HEIGHT_ITEM)
|
||||
}
|
||||
}, (item: AccountTips) => item.key)
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.padding({
|
||||
left: Constants.ROW_FONT_SIZE,
|
||||
right: Constants.ROW_FONT_SIZE,
|
||||
top: Constants.DA_MARGIN_TOP,
|
||||
bottom: Constants.DA_MARGIN_TOP
|
||||
})
|
||||
}
|
||||
|
||||
private rollColor() {
|
||||
while (this.changeIndex > this.color.length - 1) {
|
||||
this.changeIndex = this.changeIndex - this.color.length
|
||||
}
|
||||
return this.color[this.changeIndex]
|
||||
}
|
||||
|
||||
private showErrorDialog(title: Resource, message: Resource) {
|
||||
this.dlpAlertDialog = new CustomDialogController({
|
||||
builder: DlpAlertDialog({
|
||||
title: title,
|
||||
message: message,
|
||||
action: () => {
|
||||
}
|
||||
}),
|
||||
autoCancel: false,
|
||||
customStyle: true,
|
||||
});
|
||||
this.dlpAlertDialog.open();
|
||||
}
|
||||
|
||||
private splitContent() {
|
||||
if (this.textContent) {
|
||||
if (this.textContent.length > Constants.TIPS_NAME_LENGTH) {
|
||||
return this.textContent.split('').join(Constants.TIPS_SPACE_ZERO)
|
||||
} else if (this.textContent.length === Constants.TIPS_NAME_LENGTH) {
|
||||
return this.textContent.split('').join(Constants.TIPS_SPACE_EM)
|
||||
} else {
|
||||
return Constants.TIPS_SPACE_EN + this.textContent;
|
||||
}
|
||||
}
|
||||
return this.textContent;
|
||||
}
|
||||
|
||||
private getFontWeight() {
|
||||
try {
|
||||
return (getContext(this) as common.UIAbilityContext).resourceManager.getNumber(
|
||||
$r('sys.float.font_weight_semibold'));
|
||||
} catch (error) {
|
||||
HiLog.error(TAG, `getFontWeight callback getNumber failed: ${JSON.stringify(error)}.`);
|
||||
return FontWeight.Regular;
|
||||
}
|
||||
}
|
||||
|
||||
async aboutToAppear() {
|
||||
AccountManager.connectAbility(getContext(this) as common.UIAbilityContext);
|
||||
}
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Stack() {
|
||||
Circle({ width: Constants.HEADER_ROW_FONT_SIZE, height: Constants.HEADER_ROW_FONT_SIZE })
|
||||
.fill(this.rollColor())
|
||||
.opacity(Constants.FOOTER_OPACITY_MID);
|
||||
Text(this.authAccount?.[0]?.toLocaleUpperCase())
|
||||
.fontSize(Constants.STAFF_FONT_SIZE)
|
||||
.fontWeight(this.getFontWeight())
|
||||
.width(Constants.HEADER_ROW_FONT_SIZE)
|
||||
.height(Constants.HEADER_ROW_FONT_SIZE)
|
||||
.borderRadius(Constants.ENCRYPTION_STAFF_BORDER_RADIUS)
|
||||
.fontColor($r('sys.color.ohos_fa_text_contrary'))
|
||||
.textAlign(TextAlign.Center)
|
||||
.opacity(Constants.FOOTER_OPACITY_MID)
|
||||
.padding({ bottom: Constants.STAFF_FONT_PADDING });
|
||||
}
|
||||
.margin({
|
||||
left: SystemUtils.isRTL() ? Constants.ADD_STAFF_ITEM_MARGIN_RIGHT : Constants.ADD_STAFF_ITEM_MARGIN_LEFT,
|
||||
right: SystemUtils.isRTL() ? Constants.ADD_STAFF_ITEM_MARGIN_LEFT : Constants.ADD_STAFF_ITEM_MARGIN_RIGHT,
|
||||
});
|
||||
Text(this.splitContent())
|
||||
.textOverflow({
|
||||
overflow: TextOverflow.Ellipsis
|
||||
})
|
||||
.maxLines(Constants.PP_TEXT_MAX_LINE)
|
||||
.fontSize($r('sys.float.ohos_id_text_size_button3'))
|
||||
.height(Constants.HEADER_ROW_FONT_SIZE);
|
||||
}
|
||||
.onClick(async () => {
|
||||
try {
|
||||
let accountInfo: DomainAccountInfo = await AccountManager.getDomainAccountByAccountName(this.authAccount);
|
||||
this.accountTipsArray = await AccountTipsConfig.getConfigTips();
|
||||
this.handlePopupTips = !this.handlePopupTips;
|
||||
this.accountTipsArray?.forEach((item: AccountTips) => {
|
||||
item.value = accountInfo[item.key];
|
||||
})
|
||||
} catch (error) {
|
||||
HiLog.error(TAG, `getFontWeight callback getNumber failed: ${JSON.stringify(error)}.`);
|
||||
}
|
||||
})
|
||||
.hitTestBehavior(HitTestMode.Block)
|
||||
.bindPopup(this.handlePopupTips, {
|
||||
builder: this.popupBuilderTips,
|
||||
placement: SystemUtils.isRTL() ? Placement.BottomRight : Placement.BottomLeft,
|
||||
enableArrow: true,
|
||||
showInSubWindow: false,
|
||||
onStateChange: (e) => {
|
||||
if (!e.isVisible) {
|
||||
this.handlePopupTips = false;
|
||||
}
|
||||
}
|
||||
})
|
||||
.height(Constants.ENCRYPTION_ADD_STAFF_HEIGHT)
|
||||
.alignItems(VerticalAlign.Center)
|
||||
.backgroundColor(this.isActive && this.handlePopupTips ? '#1A0A59F7' : $r('sys.color.ohos_id_color_button_normal'))
|
||||
.borderRadius(Constants.ENCRYPTION_SUCCESS_CHANGE_TOP)
|
||||
.padding(
|
||||
{
|
||||
top: Constants.ENCRYPTION_STAFF_PAD,
|
||||
bottom: Constants.ENCRYPTION_STAFF_PAD,
|
||||
left: Constants.ENCRYPTION_STAFF_ITEM_MARGIN,
|
||||
right: Constants.ENCRYPTION_STAFF_ITEM_MARGIN
|
||||
}
|
||||
)
|
||||
.margin({
|
||||
right: Constants.ENCRYPTION_ADD_STAFF_MARGIN_RIGHT,
|
||||
top: Constants.ENCRYPTION_ADD_STAFF_MARGIN_BOTTOM
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export { staffItem };
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
import DomainAccountInfo from '../bean/data/DomainAccountInfo';
|
||||
import DomainAccountResponse from '../bean/response/DomainAccountResponse';
|
||||
import CredConnection from '../common/connection/CredConnection';
|
||||
import CredConnection from '../rpc/CredConnection';
|
||||
import AppStorageConstant from '../common/constant/AppStorageConstant';
|
||||
import { HiLog } from '../common/HiLog';
|
||||
import { getOsAccountInfo } from '../common/utils';
|
||||
|
@ -23,7 +23,7 @@ import fileUri from '@ohos.file.fileuri';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import osAccount from '@ohos.account.osAccount';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import { staffItem } from '../common/encryptionComponents/staff';
|
||||
import { staffItem } from '../component/encryptionComponents/staff';
|
||||
import Constants from '../common/constant';
|
||||
import {
|
||||
AuthAccount,
|
||||
@ -38,8 +38,8 @@ import {
|
||||
import { DlpAlertDialog } from '../common/components/dlp_alert_dialog';
|
||||
import GlobalContext from '../common/GlobalContext';
|
||||
import HomeFeature from '../feature/HomeFeature';
|
||||
import { AccountTipsConfig } from '../common/AccountTipsConfig';
|
||||
import { EncryptingPanel } from '../common/encryptionComponents/encrypting';
|
||||
import { AccountTipsConfig } from '../component/AccountTipsConfig';
|
||||
import { EncryptingPanel } from '../component/encryptionComponents/encrypting';
|
||||
import { GetAlertMessage } from '../common/GetAlertMessage';
|
||||
import { HiLog } from '../common/HiLog';
|
||||
import { SystemUtils } from '../common/systemUtils';
|
||||
|
@ -16,7 +16,7 @@
|
||||
import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession';
|
||||
import { EditableLeftIconType } from '@ohos.arkui.advanced.EditableTitleBar';
|
||||
import { EditableTitleBar } from '@ohos.arkui.advanced.EditableTitleBar';
|
||||
import ConnectService from '../common/share/ConnectService';
|
||||
import ConnectService from '../rpc/ConnectService';
|
||||
import { LengthMetrics } from '@ohos.arkui.node';
|
||||
import dlpPermission from '@ohos.dlpPermission';
|
||||
import promptAction from '@ohos.promptAction';
|
||||
|
@ -24,7 +24,7 @@ import fs from '@ohos.file.fs';
|
||||
import osAccount from '@ohos.account.osAccount';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import { EncryptingPanel } from '../common/encryptionComponents/encrypting';
|
||||
import { EncryptingPanel } from '../component/encryptionComponents/encrypting';
|
||||
import { DlpAlertDialog } from '../common/components/dlp_alert_dialog';
|
||||
import {
|
||||
PermissionType,
|
||||
@ -44,8 +44,8 @@ import {
|
||||
permissionTypeSelect,
|
||||
validDateTypeMenu,
|
||||
validDateTypeMenuItem
|
||||
} from '../common/encryptionComponents/permission_type_select';
|
||||
import { AddStaff } from '../common/encryptionComponents/AddStaff';
|
||||
} from '../component/encryptionComponents/permission_type_select';
|
||||
import { AddStaff } from '../component/encryptionComponents/AddStaff';
|
||||
import GlobalContext from '../common/GlobalContext';
|
||||
import IDLDLPProperty from '../serviceExtensionAbility/sequenceable/dlpClass';
|
||||
import { IAuthUser } from '../serviceExtensionAbility/sequenceable/dlpClass';
|
||||
|
@ -16,7 +16,7 @@
|
||||
import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession';
|
||||
import router from '@ohos.router';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import { staffItem } from '../common/encryptionComponents/staff';
|
||||
import { staffItem } from '../component/encryptionComponents/staff';
|
||||
import Constants from '../common/constant';
|
||||
import ability from '@ohos.ability.ability';
|
||||
import {
|
||||
|
86
entry/src/main/ets/rpc/ConnectService.ets
Normal file
86
entry/src/main/ets/rpc/ConnectService.ets
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 common from '@ohos.app.ability.common';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
import CredCallbackStub from './CredCallback';
|
||||
import Constants from '../common/constant';
|
||||
import { HiLog } from '../common/HiLog';
|
||||
|
||||
const TAG = 'ConnectService';
|
||||
|
||||
export default class ConnectService {
|
||||
private service: CredCallbackStub = new CredCallbackStub('CredCallbackStub');
|
||||
private context: ESObject;
|
||||
private connection = -1;
|
||||
private optionsSearchUser: common.ConnectOptions;
|
||||
private optionsGetAccount: common.ConnectOptions;
|
||||
|
||||
constructor(context: ESObject) {
|
||||
this.context = context;
|
||||
this.optionsSearchUser = {
|
||||
onConnect: (elementName, remote) => {
|
||||
HiLog.info(TAG, `onConnect success search account ${JSON.stringify(elementName)}`);
|
||||
this.service.searchUserInfo(remote);
|
||||
},
|
||||
onDisconnect: () => {
|
||||
HiLog.info(TAG, `onDisconnect`);
|
||||
},
|
||||
onFailed: () => {
|
||||
HiLog.info(TAG, `onFailed`);
|
||||
}
|
||||
}
|
||||
this.optionsGetAccount = {
|
||||
onConnect: (elementName, remote) => {
|
||||
HiLog.info(TAG, `onConnect success get account ${JSON.stringify(elementName)}`);
|
||||
this.service.getAccountInfo(remote);
|
||||
},
|
||||
onDisconnect: () => {
|
||||
HiLog.info(TAG, `onDisconnect`);
|
||||
},
|
||||
onFailed: () => {
|
||||
HiLog.info(TAG, `onFailed`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
connectServiceShareAbility(code: number) {
|
||||
HiLog.info(TAG, `connectServiceShareAbility start`);
|
||||
let want: Want = {
|
||||
bundleName: 'com.huawei.hmos.dlpcredmgr',
|
||||
abilityName: 'DlpCredDataExtAbility',
|
||||
};
|
||||
try {
|
||||
switch (code) {
|
||||
case Constants.COMMAND_SEARCH_USER_INFO: {
|
||||
this.connection = this.context.connectServiceExtensionAbility(want, this.optionsSearchUser);
|
||||
AppStorage.setOrCreate('connection', this.connection);
|
||||
break;
|
||||
}
|
||||
case Constants.COMMAND_GET_ACCOUNT_INFO: {
|
||||
this.connection = this.context.connectServiceExtensionAbility(want, this.optionsGetAccount);
|
||||
AppStorage.setOrCreate('connection', this.connection);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
HiLog.error(TAG, `code is not exist ${code}`);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
HiLog.error(TAG, `connectServiceExtAbility failed: ${JSON.stringify(err)}`);
|
||||
}
|
||||
HiLog.info(TAG, `connectServiceExtAbility result: ${this.connection}`);
|
||||
}
|
||||
}
|
@ -13,77 +13,71 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import common from '@ohos.app.ability.common';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import rpc from '@ohos.rpc';
|
||||
import CredCallbackStub from './CredCallback';
|
||||
import Constants from '../constant';
|
||||
import { HiLog } from '../HiLog';
|
||||
import { HiLog } from '../common/HiLog';
|
||||
import Constants from '../common/constant';
|
||||
import { common } from '@kit.AbilityKit';
|
||||
|
||||
const TAG = 'ConnectService';
|
||||
const TAG = 'CredCallbackStub';
|
||||
|
||||
export default class ConnectService {
|
||||
private context: ESObject;
|
||||
private connection = -1;
|
||||
private optionsSearchUser: common.ConnectOptions;
|
||||
private optionsGetAccount: common.ConnectOptions;
|
||||
export default class CredCallbackStub extends rpc.RemoteObject {
|
||||
private static readonly DESCRIPTOR: string = 'OHOS.HapDlpCredAbilityServiceStub';
|
||||
|
||||
constructor(context: ESObject) {
|
||||
let that = this;
|
||||
this.context = context;
|
||||
this.optionsSearchUser = {
|
||||
onConnect: (elementName, remote) => {
|
||||
HiLog.info(TAG, `onConnect success search account ${JSON.stringify(elementName)}`);
|
||||
that.searchUserInfo(remote);
|
||||
},
|
||||
onDisconnect: () => {
|
||||
HiLog.info(TAG, `onDisconnect`);
|
||||
},
|
||||
onFailed: () => {
|
||||
HiLog.info(TAG, `onFailed`);
|
||||
}
|
||||
}
|
||||
this.optionsGetAccount = {
|
||||
onConnect: (elementName, remote) => {
|
||||
HiLog.info(TAG, `onConnect success get account ${JSON.stringify(elementName)}`);
|
||||
that.getAccountInfo(remote);
|
||||
},
|
||||
onDisconnect: () => {
|
||||
HiLog.info(TAG, `onDisconnect`);
|
||||
},
|
||||
onFailed: () => {
|
||||
HiLog.info(TAG, `onFailed`);
|
||||
}
|
||||
}
|
||||
constructor(des: string) {
|
||||
super(des);
|
||||
}
|
||||
|
||||
connectServiceShareAbility(code: number) {
|
||||
HiLog.info(TAG, `connectServiceShareAbility start`);
|
||||
let want: Want = {
|
||||
bundleName: 'com.huawei.hmos.dlpcredmgr',
|
||||
abilityName: 'DlpCredDataExtAbility',
|
||||
};
|
||||
asObject(): rpc.IRemoteObject {
|
||||
return this;
|
||||
}
|
||||
|
||||
async onRemoteMessageRequest(code: number, data: rpc.MessageSequence): Promise<boolean> {
|
||||
HiLog.info(TAG, `onRemoteMessageRequest called, code = ${code}`);
|
||||
try {
|
||||
switch (code) {
|
||||
case Constants.COMMAND_SEARCH_USER_INFO: {
|
||||
this.connection = this.context.connectServiceExtensionAbility(want, this.optionsSearchUser);
|
||||
AppStorage.setOrCreate('connection', this.connection);
|
||||
break;
|
||||
}
|
||||
case Constants.COMMAND_GET_ACCOUNT_INFO: {
|
||||
this.connection = this.context.connectServiceExtensionAbility(want, this.optionsGetAccount);
|
||||
AppStorage.setOrCreate('connection', this.connection);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
HiLog.error(TAG, `code is not exist ${code}`);
|
||||
}
|
||||
if (data.readInterfaceToken() !== CredCallbackStub.DESCRIPTOR) {
|
||||
HiLog.info(TAG, `DESCRIPTOR unmatched.`);
|
||||
return false;
|
||||
}
|
||||
} catch (err) {
|
||||
HiLog.error(TAG, `connectServiceExtAbility failed: ${JSON.stringify(err)}`);
|
||||
} catch (error) {
|
||||
HiLog.error(TAG, `read data exception, error is ${JSON.stringify(error)}`);
|
||||
return false;
|
||||
}
|
||||
HiLog.info(TAG, `connectServiceExtAbility result: ${this.connection}`);
|
||||
switch (code) {
|
||||
case Constants.COMMAND_SEARCH_USER_INFO: {
|
||||
let storage = LocalStorage.getShared();
|
||||
HiLog.info(TAG, `onRemoteMessageRequest command search user info`);
|
||||
let resultVar = '';
|
||||
try {
|
||||
resultVar = data.readString();
|
||||
} catch (error) {
|
||||
HiLog.error(TAG, `read string exception, error is ${JSON.stringify(error)}`);
|
||||
return false;
|
||||
}
|
||||
storage.setOrCreate('commandSearchUserInfo', resultVar);
|
||||
this.disconnectServiceShareAbility();
|
||||
return true;
|
||||
}
|
||||
case Constants.COMMAND_GET_ACCOUNT_INFO: {
|
||||
let storage = LocalStorage.getShared();
|
||||
HiLog.info(TAG, `onRemoteMessageRequest command get account info`);
|
||||
let resultVar = '';
|
||||
try {
|
||||
resultVar = data.readString();
|
||||
} catch (error) {
|
||||
HiLog.error(TAG, `read string exception, error is ${JSON.stringify(error)}`);
|
||||
return false;
|
||||
}
|
||||
storage.setOrCreate('commandGetAccountInfo', resultVar);
|
||||
this.disconnectServiceShareAbility();
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
HiLog.error(TAG, `invalid request code: ${code}`);
|
||||
this.disconnectServiceShareAbility();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
searchUserInfo(remote: rpc.IRemoteObject) {
|
||||
@ -139,10 +133,12 @@ export default class ConnectService {
|
||||
disconnectServiceShareAbility() {
|
||||
HiLog.info(TAG, `disconnectServiceShareAbility: ${AppStorage.get('connection')}`);
|
||||
let connectionNum: number | undefined = AppStorage.get('connection');
|
||||
this.context.disconnectAbility(connectionNum).then(() => {
|
||||
HiLog.info(TAG, `disconnectAbility success.`);
|
||||
}).catch((error: BusinessError) => {
|
||||
HiLog.error(TAG, `disconnectAbility failed. Error: ${JSON.stringify(error)}`);
|
||||
})
|
||||
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
|
||||
try {
|
||||
context.disconnectServiceExtensionAbility(connectionNum);
|
||||
HiLog.info(TAG, `disconnectServiceExtensionAbility success.`);
|
||||
} catch (error) {
|
||||
HiLog.error(TAG, `disconnectServiceExtensionAbility failed. Error: ${JSON.stringify(error)}`);
|
||||
}
|
||||
};
|
||||
}
|
@ -17,13 +17,13 @@ import common from '@ohos.app.ability.common';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import rpc from '@ohos.rpc';
|
||||
import DomainAccountRequest from '../../bean/request/DomainAccountRequest';
|
||||
import DomainAccountResponse from '../../bean/response/DomainAccountResponse';
|
||||
import DomainAccountConvertor from '../../convertor/DomainAccountConvertor';
|
||||
import Constants from '../constant';
|
||||
import AppStorageConstant from '../constant/AppStorageConstant';
|
||||
import { HiLog } from '../HiLog';
|
||||
import CredCallbackStub from '../share/CredCallback';
|
||||
import DomainAccountRequest from '../bean/request/DomainAccountRequest';
|
||||
import DomainAccountResponse from '../bean/response/DomainAccountResponse';
|
||||
import DomainAccountConvertor from '../convertor/DomainAccountConvertor';
|
||||
import Constants from '../common/constant';
|
||||
import AppStorageConstant from '../common/constant/AppStorageConstant';
|
||||
import { HiLog } from '../common/HiLog';
|
||||
import CredCallbackStub from './CredCallback';
|
||||
|
||||
const TAG = 'CredConnection';
|
||||
|
Loading…
Reference in New Issue
Block a user