适老化和无障碍

Signed-off-by: li-li-wang <wangliliang5@huawei.com>
This commit is contained in:
li-li-wang 2024-07-12 20:36:26 +08:00
parent 256a793da9
commit 9ec70a100a
13 changed files with 141 additions and 53 deletions

View File

@ -2,8 +2,8 @@
"app": {
"bundleName": "com.ohos.dlpmanager",
"vendor": "example",
"versionCode": 1000052,
"versionName": "1.0.0.52",
"versionCode": 1000053,
"versionName": "1.0.0.53",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 12,

View File

@ -16,8 +16,8 @@
"app": {
"bundleName": "com.ohos.dlpmanager",
"vendor": "example",
"versionCode": 1000052,
"versionName": "1.0.0.52",
"versionCode": 1000053,
"versionName": "1.0.0.53",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 12,

View File

@ -0,0 +1,28 @@
/*
* 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.
*/
enum FontSizeScale {
SM = 0.85,
MD = 1.0,
DEFAULT = MD,
L = 1.15,
XL = 1.3,
XXL = 1.45,
XXL1 = 1.75,
XXL2 = 2,
XXL3 = 3.2,
}
export default FontSizeScale;

View File

@ -248,6 +248,7 @@ export default class Constants {
public static SHARE_PAGES_COLUMN_WIDTH = '100%';
public static SHARE_PAGES_COLUMN_HEIGHT = '100%';
public static SHARE_SET_TIMEOUT = 1500;
public static SHARE_FILE_NAME_TOO_LONG = 13900030;
public static readonly ERR_CODE_NETWORK_ERROR: number = -4;
public static readonly ERR_CODE_CONNECTION_FAIL: number = -301;
@ -255,4 +256,9 @@ export default class Constants {
public static readonly ERR_CODE_SUCCESS: number = 0;
public static readonly COMMAND_SEARCH_USER_INFO = 1;
public static readonly COMMAND_GET_ACCOUNT_INFO = 2;
public static readonly GET_SETTING_ITEM_XXL1 = 8;
public static readonly GET_SETTING_ITEM_XXL2 = 18;
public static readonly GET_SETTING_ITEM_XXL3 = 48;
public static readonly GET_SETTING_ITEM_DEFAULT = 0;
public static readonly SYMBOL_GLYPH_FONT_SIZE = 24;
}

View File

@ -28,7 +28,7 @@ const TAG = 'AddStaff';
@Extend(Text)
function inputMessageText() {
.fontSize($r('sys.float.ohos_fa_text_size_body'))
.fontSize($r('sys.float.ohos_id_text_size_body3'))
.lineHeight(Constants.PP_TEXT_LINE_HEIGHT2)
.fontColor($r('sys.color.ohos_id_color_handup'))
.fontWeight(FontWeight.Medium)
@ -309,7 +309,7 @@ struct AddStaff {
if (this.staffArray.length >=
Constants.ENCRYPTION_ADD_STAFF_LENGTH_MAX * Constants.ENCRYPTION_ADD_STAFF_LENGTH) {
Text(`${this.staffArray.length}/${Constants.ENCRYPTION_ADD_STAFF_LENGTH_MAX}`)
.fontSize($r('sys.float.ohos_fa_text_size_body'))
.fontSize($r('sys.float.ohos_id_text_size_body3'))
.lineHeight(Constants.PP_TEXT_LINE_HEIGHT2)
.fontColor(this.staffArrayLength
? $r('sys.color.ohos_id_color_handup') : $r('sys.color.ohos_id_color_text_secondary'))

View File

@ -34,7 +34,7 @@ export default class ConnectService {
this.context = context;
this.optionsSearchUser = {
onConnect: (elementName, remote) => {
HiLog.info(TAG, `onConnect success ${JSON.stringify(elementName)}`);
HiLog.info(TAG, `onConnect success search account ${JSON.stringify(elementName)}`);
that.searchUserInfo(remote);
},
onDisconnect: () => {
@ -46,7 +46,7 @@ export default class ConnectService {
}
this.optionsGetAccount = {
onConnect: (elementName, remote) => {
HiLog.info(TAG, `onConnect success ${JSON.stringify(elementName)}`);
HiLog.info(TAG, `onConnect success get account ${JSON.stringify(elementName)}`);
that.getAccountInfo(remote);
},
onDisconnect: () => {
@ -69,10 +69,15 @@ export default class ConnectService {
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) {

View File

@ -40,16 +40,18 @@ export default class CredCallbackStub extends rpc.RemoteObject {
}
switch (code) {
case Constants.COMMAND_SEARCH_USER_INFO: {
let storage = LocalStorage.getShared();
HiLog.info(TAG, `onRemoteMessageRequest command search user info`);
let resultVar = data.readString();
AppStorage.setOrCreate('commandSearchUserInfo', resultVar);
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 = data.readString();
AppStorage.setOrCreate('commandGetAccountInfo', resultVar);
storage.setOrCreate('commandGetAccountInfo', resultVar);
this.connectService.disconnectServiceShareAbility();
return true;
}

View File

@ -217,7 +217,6 @@ struct Index {
top: Constants.ENCRYPTION_BUTTON_TO_BUTTON_WIDTH
})
}
.width(Constants.ENCRYPTION_MESSAGE_DIALOG_TIPS)
.borderRadius($r('sys.float.ohos_id_corner_radius_dialog'))
.alignItems(HorizontalAlign.Center)
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))

View File

@ -25,6 +25,7 @@ import connection from '@ohos.net.connection';
import { BusinessError } from '@ohos.base';
import Want from '@ohos.app.ability.Want';
import fs from '@ohos.file.fs';
import systemParameterEnhance from '@ohos.systemParameterEnhance';
import emitter from '@ohos.events.emitter';
import { HiLog } from '../common/HiLog';
import Constants from '../common/constant';
@ -38,6 +39,7 @@ import {
getAppId,
getOsAccountInfo
} from '../common/utils';
import FontSizeScale from '../common/FontSizeScale';
const TAG = 'Share';
class Test {
@ -65,7 +67,7 @@ let defaultDlpProperty: dlpPermission.DLPProperty = {
@Extend(Text)
function inputMessageText() {
.fontSize($r('sys.float.ohos_fa_text_size_body'))
.fontSize($r('sys.float.ohos_id_text_size_body3'))
.lineHeight(Constants.PP_TEXT_LINE_HEIGHT2)
.fontColor($r('sys.color.ohos_id_color_text_secondary'))
.fontWeight(FontWeight.Regular)
@ -81,7 +83,8 @@ struct encryptedSharing {
start: LengthMetrics.vp(Constants.SHARE_TITLE_HEAD_MARGIN_RIGHT),
end: LengthMetrics.vp(Constants.SHARE_TITLE_HEAD_MARGIN_RIGHT),
};
@StorageLink('commandSearchUserInfo') @Watch('beginToGenerateDLPFile') isInputInvalid: string = '';
@LocalStorageLink('commandSearchUserInfo') @Watch('beginToGenerateDLPFile') isInputInvalid: string = '';
@LocalStorageLink('commandGetAccountInfo') commandGetAccountInfo: string = '';
@State commandGetAccountInfoFlag: boolean = false;
@State dlpProperty: dlpPermission.DLPProperty = defaultDlpProperty;
@State enabledFocus: boolean = true;
@ -98,6 +101,7 @@ struct encryptedSharing {
@State session: UIExtensionContentSession | undefined =
storage === undefined ? undefined : storage.get<UIExtensionContentSession>('session');
@State placeHolderStr: ResourceStr = '';
@State contactPerson: string = '';
@Builder
contactsPicker() {
@ -135,6 +139,7 @@ struct encryptedSharing {
let cloudAccountLoginFlag = this.cloudAccountLoginFlag();
HiLog.info(TAG, `cloudAccountLoginFlag: ${cloudAccountLoginFlag}`);
if (cloudAccountLoginFlag) {
this.enabledFocus = false;
this.connectService.connectServiceShareAbility(Constants.COMMAND_SEARCH_USER_INFO);
} else {
this.showUIExtension = true;
@ -144,7 +149,7 @@ struct encryptedSharing {
cloudAccountLoginFlag(): boolean {
if (this.commandGetAccountInfoFlag) {
let info = AppStorage.get('commandGetAccountInfo') as string;
let info = this.commandGetAccountInfo;
if (info === undefined) {
HiLog.error(TAG, `command get account info undefined`);
this.showToast($r('app.string.Share_File_Encrypted_Failed'));
@ -180,6 +185,7 @@ struct encryptedSharing {
async beginToGenerateDLPFile() {
HiLog.info(TAG, `beginToGenerateDLPFile start`);
if (!this.getInputInvalid()) {
this.enabledFocus = true;
return;
}
let parameters = this.actionWant?.parameters as Record<string, Array<string>>;
@ -194,7 +200,6 @@ struct encryptedSharing {
let filePath = getContext(this).filesDir + '/' + filePatch;
let file: fs.File | undefined;
let filePathUri = getFileUriByPath(filePath);
this.enabledFocus = false;
try {
file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
await dlpPermission.generateDLPFile(inFileFd, file.fd, this.dlpProperty);
@ -206,16 +211,16 @@ struct encryptedSharing {
this.backToPages(filePathUri, filePatch);
HiLog.info(TAG, `beginToGenerateDLPFile success`);
} catch (err) {
this.enabledFocus = true;
HiLog.error(TAG, `open temp failed: ${JSON.stringify(err)}`);
HiLog.info(TAG, `generateDLPFile file failed: ${JSON.stringify(err)}`);
AppStorage.setOrCreate('commandSearchUserInfo', '');
if ([13900030].includes(err.code)) {
storage.setOrCreate('commandSearchUserInfo', '');
if (err.code === Constants.SHARE_FILE_NAME_TOO_LONG) {
this.showToast($r('app.string.Share_File_Name_Too_Long'));
return;
};
this.showToast($r('app.string.Share_File_Encrypted_Failed'));
} finally {
this.enabledFocus = true;
if (file) {
fs.closeSync(file);
}
@ -256,14 +261,14 @@ struct encryptedSharing {
if (!this.isInputInvalid) {
return false;
};
HiLog.info(TAG, `credential Call Back`);
let credentialCallBack = JSON.parse(this.isInputInvalid) as Record<string, string>;
HiLog.info(TAG, `credential Call Back errorCode: ${credentialCallBack.errorCode}`);
if (!credentialCallBack.status && Number(credentialCallBack.errorCode) === Constants.ERR_CODE_SUCCESS) {
HiLog.info(TAG, `credentialCallBack msg`);
let str = this.getExternalResourceString(Constants.DLP_CREDMGR_BUNDLE_NAME, 'entry', 'no_user');
this.credentialCallBackMsg = str.length > 0 ? str : credentialCallBack.msg;
this.phoneFormatTips = true;
AppStorage.setOrCreate('commandSearchUserInfo', '');
storage.setOrCreate('commandSearchUserInfo', '');
return false;
}
if (!credentialCallBack.status && [
@ -272,12 +277,12 @@ struct encryptedSharing {
Constants.ERR_CODE_CONNECTION_TIME_OUT
].includes(Number(credentialCallBack.errorCode))) {
this.showToast($r('app.string.network_invalid'));
AppStorage.setOrCreate('commandSearchUserInfo', '');
storage.setOrCreate('commandSearchUserInfo', '');
return false;
}
if (!credentialCallBack.status && Number(credentialCallBack.errorCode) !== Constants.ERR_CODE_SUCCESS) {
this.showToast($r('app.string.Share_File_Encrypted_Failed'));
AppStorage.setOrCreate('commandSearchUserInfo', '');
storage.setOrCreate('commandSearchUserInfo', '');
return false;
}
let authUserList: AuthUserList[] = [
@ -362,6 +367,7 @@ struct encryptedSharing {
if (str.length > 0) {
this.credentialCallBackMsg = str;
}
this.getContactPersonString();
}
subscribeLanguageChange() {
@ -383,6 +389,36 @@ struct encryptedSharing {
}
}
getContactPersonString() {
try {
getContext().resourceManager.getStringValue($r('app.string.Share_Contact_Person').id,
(error: BusinessError, value: string) => {
if (error === undefined || error === null) {
this.contactPerson = value;
} else {
HiLog.error(TAG, `error is ${JSON.stringify(error)}`);
}
});
} catch (error) {
HiLog.error(TAG, `callback getStringValue failed, error ${JSON.stringify(error)}`);
}
}
private getSettingItemPadding(): number {
const FONT_SIZE_SCALE_PARAM = 'persist.sys.font_scale_for_user0';
let fontSizeScale = Number.parseFloat(systemParameterEnhance.getSync(FONT_SIZE_SCALE_PARAM, '1'));
switch (fontSizeScale) {
case FontSizeScale.XXL1:
return Constants.GET_SETTING_ITEM_XXL1;
case FontSizeScale.XXL2:
return Constants.GET_SETTING_ITEM_XXL2;
case FontSizeScale.XXL3:
return Constants.GET_SETTING_ITEM_XXL3;
default:
return Constants.GET_SETTING_ITEM_DEFAULT;
}
}
aboutToAppear() {
HiLog.info(TAG, `aboutToAppear enter: ${this.showUIExtension}`);
this.getAccountInfo();
@ -395,6 +431,7 @@ struct encryptedSharing {
this.subscribeLanguageChange();
let str = this.getExternalResourceString(Constants.DLP_CREDMGR_BUNDLE_NAME, 'entry', 'add_users_hint');
this.placeHolderStr = str.length > 0 ? str : $r('app.string.Share_Enter_Mobile_Number');
this.getContactPersonString();
}
build() {
@ -434,9 +471,9 @@ struct encryptedSharing {
Column() {
Row() {
TextInput({ placeholder: this.placeHolderStr, text: this.inputValue })
.padding({ right: Constants.SHARE_TEXT_INPUT_CONTENT_PADDING_RIGHT})
.padding({ right: Constants.SHARE_TEXT_INPUT_CONTENT_PADDING_RIGHT + this.getSettingItemPadding()})
.enabled(this.enabledFocus)
.height(Constants.SHARE_TEXT_INPUT_HEIGHT)
.constraintSize({ minHeight: Constants.SHARE_TEXT_INPUT_HEIGHT })
.defaultFocus(true)
.type(InputType.PhoneNumber)
.contentType(ContentType.PHONE_COUNTRY_CODE)
@ -449,24 +486,30 @@ struct encryptedSharing {
this.phoneFormatTips = false;
})
if (this.contactExists) {
Image($r('app.media.ic_public_contacts_group'))
.fillColor(this.enabledFocus ? $r('sys.color.icon_primary') : $r('sys.color.icon_tertiary'))
.width(Constants.SHARE_CONTACTS_GROUP_WIDTH)
.height(Constants.SHARE_CONTACTS_GROUP_HEIGHT)
.offset({x: Constants.SHARE_CONTACTS_GROUP_OFFSET_X, y: Constants.SHARE_CONTACTS_GROUP_OFFSET_Y})
.onClick(() => {
this.isShowSheet = !this.isShowSheet;
})
.bindSheet(this.isShowSheet, this.contactsPicker(), {
height: SheetSize.LARGE,
dragBar: false,
showClose: false,
onDisappear: () => {
this.isShowSheet = false;
},
backgroundColor: Color.Transparent,
blurStyle: BlurStyle.COMPONENT_ULTRA_THICK
})
Column() {
SymbolGlyph($r('sys.symbol.person_2'))
.fontSize(`${Constants.SYMBOL_GLYPH_FONT_SIZE}fp`)
.fontColor(this.enabledFocus ? [$r('sys.color.icon_primary')] : [$r('sys.color.icon_tertiary')])
}
.accessibilityText(this.contactPerson)
.enabled(this.enabledFocus)
.offset({
x: Constants.SHARE_CONTACTS_GROUP_OFFSET_X - this.getSettingItemPadding(),
y: Constants.SHARE_CONTACTS_GROUP_OFFSET_Y
})
.onClick(() => {
this.isShowSheet = !this.isShowSheet;
})
.bindSheet(this.isShowSheet, this.contactsPicker(), {
height: SheetSize.LARGE,
dragBar: false,
showClose: false,
onDisappear: () => {
this.isShowSheet = false;
},
backgroundColor: Color.Transparent,
blurStyle: BlurStyle.COMPONENT_ULTRA_THICK
})
}
}
@ -486,9 +529,8 @@ struct encryptedSharing {
Button($r('app.string.Share_Confirms'), { type: ButtonType.Capsule, stateEffect: true })
.enabled(this.enabledFocus)
.backgroundColor($r('sys.color.ohos_id_color_text_primary_activated'))
.fontWeight(FontWeight.Medium)
.width(Constants.SHARE_BUTTON_WIDTH)
.height(Constants.FOOTER_HEIGHT)
.controlSize(ControlSize.NORMAL)
.onClick(async () => {
try {
await this.checkNetworkStatus();
@ -503,9 +545,11 @@ struct encryptedSharing {
.margin({
top: Constants.SHARE_BUTTON_MARGIN_TOP,
left: Constants.SHARE_BUTTON_MARGIN_LEFT,
right: Constants.SHARE_BUTTON_MARGIN_RIGHT
right: Constants.SHARE_BUTTON_MARGIN_RIGHT,
bottom: Constants.SHARE_BUTTON_PADDING_BOTTOM
})
.padding({
top: Constants.SHARE_BUTTON_MARGIN_TOP,
bottom: Constants.SHARE_BUTTON_PADDING_BOTTOM
})
}

View File

@ -69,8 +69,7 @@ class DlpRpcServiceStub extends IdlDlpRpcServiceStub {
return null;
}
async genDlpFile(
inputUri: string, outputUri: string, dlp: IDLDLPProperty, callback: genDlpFileCallback
async genDlpFile(inputUri: string, outputUri: string, dlp: IDLDLPProperty, callback: genDlpFileCallback
): Promise<void> {
HiLog.info(TAG, `genDlpFile in service`);
let result: Record<string, number>;
@ -96,11 +95,9 @@ class DlpRpcServiceStub extends IdlDlpRpcServiceStub {
this.dlpFileMap.set(outputUri, dlpFile);
AppStorage.setOrCreate('dlpFileMap', this.dlpFileMap);
} else {
HiLog.info(TAG, `map is overwrite: ${outputUri}`);
let rawDlpFile = this.dlpFileMap.get(outputUri) ?? null;
if (rawDlpFile !== null) {
try {
HiLog.info(TAG, `closeDLPFile start`);
await rawDlpFile.closeDLPFile();
} catch (err) {
HiLog.error(TAG, `closeDlpFile file: ${JSON.stringify(err)}`);

View File

@ -340,6 +340,10 @@
"name": "Share_File_Name_Too_Long",
"value": "File name too long, Failed to encrypt the file."
},
{
"name": "Share_Contact_Person",
"value": "Contact Person"
},
{
"name": "Function_Is_Not_Available",
"value": "This function is not currently available."

View File

@ -340,6 +340,10 @@
"name": "Share_File_Name_Too_Long",
"value": "文件名过长,加密失败"
},
{
"name": "Share_Contact_Person",
"value": "联系人"
},
{
"name": "Function_Is_Not_Available",
"value": "此功能暂未开放"

View File

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- 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.
@ -12,6 +13,4 @@
limitations under the License.
-->
<?xml version="1.0" encoding="UTF-8">
<packageInfo package="com.ohos.dlpmanager" label="数据防泄漏管理应用" feature="数据防泄漏管理应用" author="OpenHarmony Team"></packageInfo>