!166 ux样式修改

Merge pull request !166 from 王力量/share_weekly
This commit is contained in:
openharmony_ci 2024-06-05 10:05:08 +00:00 committed by Gitee
commit 8f440dc191
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
12 changed files with 72 additions and 93 deletions

View File

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

View File

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

View File

@ -17,7 +17,6 @@ import Want from '@ohos.app.ability.Want';
import fileio from '@ohos.fileio';
import dlpPermission from '@ohos.dlpPermission';
import common from '@ohos.app.ability.common';
import { BusinessError } from '@ohos.base';
import GlobalContext from '../common/GlobalContext';
import { HiLog } from '../common/HiLog';

View File

@ -17,7 +17,7 @@ import ActionExtensionAbility from '@ohos.app.ability.ActionExtensionAbility';
import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession';
import Want from '@ohos.app.ability.Want';
import { HiLog } from '../common/HiLog';
import { getDLPInfo, DLPInfo, sendDlpManager2CAccountLogin } from '../common/utils';
import { getDLPInfo, DLPInfo } from '../common/utils';
const TAG = 'share';
const BG_COLOR = '#00000000';
@ -56,7 +56,6 @@ export default class EncryptedSharingAbility extends ActionExtensionAbility {
let dlpInfo: DLPInfo = await getDLPInfo();
AppStorage.setOrCreate('hiPNameId', dlpInfo.name);
AppStorage.setOrCreate('hiPVersionId', dlpInfo.versionCode);
sendDlpManager2CAccountLogin(0);
let storage: LocalStorage = new LocalStorage({
'session': session,
'actionWant': want

View File

@ -15,7 +15,6 @@
import dlpPermission from '@ohos.dlpPermission';
import fs from '@ohos.file.fs';
import { BusinessError } from '@ohos.base';
import { HiLog } from '../common/HiLog';
const TAG = 'FileUtils';

View File

@ -13,10 +13,7 @@
* limitations under the License.
*/
import { BusinessError } from '@ohos.base';
import Want from '@ohos.app.ability.Want';
import Constants from '../constant';
import GlobalContext from '../GlobalContext';
import common from '@ohos.app.ability.common';
const TAG = '[DLPManager_dialog]';

View File

@ -269,12 +269,13 @@ export default class Constants {
public static SHARE_CONTACTS_GROUP_OFFSET_X = -40;
public static SHARE_CONTACTS_GROUP_OFFSET_Y = 0;
public static SHARE_TITLE_HEAD_PADDING_LEFT = 16;
public static SHARE_TEXT_INPUT_MARGIN_RIGHT = 24;
public static SHARE_TEXT_INPUT_MARGIN_LEFT = 24;
public static SHARE_TEXT_INPUT_MARGIN_RIGHT = 16;
public static SHARE_TEXT_INPUT_MARGIN_LEFT = 16;
public static SHARE_TEXT_INPUT_COLUMN_HEIGHT = 120;
public static SHARE_BUTTON_WIDTH = '100%';
public static SHARE_BUTTON_MARGIN_TOP = 64;
public static SHARE_BUTTON_MARGIN_LEFT = 24;
public static SHARE_BUTTON_MARGIN_RIGHT = 24;
public static SHARE_BUTTON_MARGIN_TOP = 16;
public static SHARE_BUTTON_MARGIN_LEFT = 16;
public static SHARE_BUTTON_MARGIN_RIGHT = 16;
public static SHARE_BUTTON_PADDING_BOTTOM = 24;
public static SHARE_PAGES_COLUMN_WIDTH = '100%';
public static SHARE_PAGES_COLUMN_HEIGHT = '100%';

View File

@ -19,7 +19,7 @@ import ability from '@ohos.ability.ability';
import account_osAccount from '@ohos.account.osAccount';
import emitter from '@ohos.events.emitter';
import dlpPermission from '@ohos.dlpPermission';
import bundleManager from '@ohos.bundle.bundleManager'
import bundleManager from '@ohos.bundle.bundleManager';
import fs from '@ohos.file.fs';
import zlib from '@ohos.zlib';
import fileUri from '@ohos.file.fileuri';
@ -102,7 +102,7 @@ async function getOsAccountInfo(): Promise<account_osAccount.OsAccountInfo> {
}
function checkDomainAccountInfo(accountInfo: account_osAccount.OsAccountInfo): number {
AppStorage.setOrCreate('hiAccountType', 'Domain_Account');
AppStorage.setOrCreate('hiAccountType', dlpPermission.AccountType.DOMAIN_ACCOUNT);
if (accountInfo.domainInfo.accountName === '' &&
accountInfo.domainInfo.accountId === '') {
AppStorage.setOrCreate('hiAccountStatus', 0);
@ -385,12 +385,13 @@ function sendDlpManagerFileConfiguration() {
}
}
function sendDlpFileCreateProperties(name: string) {
function sendDlpFileCreateProperties(accountType: number) {
let event: hiSysEvent.SysEventInfo = {
domain: 'DLP_UE',
name: name,
name: 'DLP_FILE_CREATE_EVENT',
eventType: hiSysEvent?.EventType?.BEHAVIOR,
params: {
'ACCOUNT_TYPE': accountType,
'PNAMEID': AppStorage.get('hiPNameId') ?? '',
'PVERSIONID': AppStorage.get('hiPVersionId') ?? '',
'CODE': AppStorage.get('hiCode') ?? -1,
@ -432,26 +433,6 @@ function sendDlpFileOpenProperties() {
}
}
function sendDlpManager2CAccountLogin(errorCode: number) {
let event: hiSysEvent.SysEventInfo = {
domain: 'DLP_UE',
name: 'DLP_2C_MANAGER_ACCOUNT_LOGIN',
eventType: hiSysEvent?.EventType?.BEHAVIOR,
params: {
'PNAMEID': AppStorage.get('hiPNameId') ?? '',
'PVERSIONID': AppStorage.get('hiPVersionId') ?? '',
'ACCOUNT_TYPE': 1,
'PKG_NAME': AppStorage.get('hiPkgName') ?? '',
} as Record<string, number>
};
try {
hiSysEvent.write(event);
} catch (err) {
HiLog.error(TAG, `sendDlpManagerAccountLogin failed`);
}
}
function isValidPath(path: string): Boolean {
if (path.indexOf('/./') !== -1 || path.indexOf('/../') !== -1) {
return false;
@ -548,7 +529,6 @@ export {
sendDlpManagerFileConfiguration,
sendDlpFileCreateProperties,
sendDlpFileOpenProperties,
sendDlpManager2CAccountLogin,
DLPInfo,
isValidPath,
measureTextSizeWidth,

View File

@ -24,7 +24,14 @@ import fs from '@ohos.file.fs';
import { HiLog } from '../common/HiLog';
import Constants from '../common/constant';
import FileUtils, { FileMsg } from '../common/FileUtils';
import { getFileUriByPath, getFileFd, sendDlpFileCreateProperties, getFileSizeByUri } from '../common/utils';
import {
getFileUriByPath,
getFileFd,
sendDlpFileCreateProperties,
getFileSizeByUri,
sendDlpManagerAccountLogin,
getAppId
} from '../common/utils';
const TAG = 'Share';
class Test {
@ -65,11 +72,11 @@ struct encryptedSharing {
@State cloudAccountLogin: boolean = true;
@State actionWant: Want | undefined = storage.get<Want>('actionWant');
@State inputValue: string = '';
@State showTipsMsg: boolean = true;
@State phoneFormatTips: boolean = true;
@State phoneFormatTips: boolean = false;
@State ownerAccount: string = '';
@State ownerAccountID: string = '';
@State credentialCallBackMsg: string = '';
@State contactExists: boolean = true;
@State credentialCallBackMsg: string | Resource = '';
@State session: UIExtensionContentSession | undefined =
storage === undefined ? undefined : storage.get<UIExtensionContentSession>('session');
@ -82,6 +89,7 @@ struct encryptedSharing {
parameters: {
'ability.want.params.uiExtensionType': 'sys/commonUI',
'targetUrl': 'BatchSelectContactsPage',
'isContactMultiSelect': false,
}
})
.onRelease((code) => {
@ -120,7 +128,8 @@ struct encryptedSharing {
}
if (!(/^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(phone))) {
HiLog.info(TAG, `Please enter the phone.`);
this.phoneFormatTips = false;
this.phoneFormatTips = true;
this.credentialCallBackMsg = $r('app.string.Share_Tips_Phone_Format');
HiLog.info(TAG, `phoneFormatTips: ${this.phoneFormatTips}`);
return false;
};
@ -162,7 +171,7 @@ struct encryptedSharing {
let dstFileSize: number = await getFileSizeByUri(filePathUri);
AppStorage.setOrCreate('hiPolicySizeEnc', dstFileSize);
AppStorage.setOrCreate('hiCode', 201);
sendDlpFileCreateProperties('DLP_2C_FILE_CREATE_EVENT'); // 201: DLP_2C_FILE_CREATE_EVENT
sendDlpFileCreateProperties(dlpPermission.AccountType.CLOUD_ACCOUNT); // 201: DLP_2C_FILE_CREATE_EVENT
this.backToPages(filePathUri, filePatch);
try {
await fs.close(file);
@ -170,7 +179,6 @@ struct encryptedSharing {
HiLog.info(TAG, `close failed: ${JSON.stringify(err)}`);
}
} catch (err) {
this.showTipsMsg = false;
this.enabledFocus = true;
HiLog.info(TAG, `generateDLPFile file failed: ${JSON.stringify(err)}`);
AppStorage.setOrCreate('isInputInvalid', '');
@ -217,7 +225,7 @@ struct encryptedSharing {
if (!credentialCallBack.status) {
HiLog.info(TAG, `credentialCallBack: ${credentialCallBack.msg}`);
this.credentialCallBackMsg = credentialCallBack.msg;
this.showTipsMsg = false;
this.phoneFormatTips = true;
AppStorage.setOrCreate('isInputInvalid', '');
return false;
}
@ -239,8 +247,17 @@ struct encryptedSharing {
return true;
}
async checkContacts() {
let callerBundleName = 'com.ohos.contacts';
let callerAppId = await getAppId(callerBundleName);
this.contactExists = callerAppId ? true : false;
}
aboutToAppear() {
HiLog.info(TAG, `aboutToAppear enter: ${this.showUIExtension}`);
AppStorage.setOrCreate('hiAccountType', dlpPermission.AccountType.CLOUD_ACCOUNT);
sendDlpManagerAccountLogin(-1);
this.checkContacts();
}
build() {
@ -274,61 +291,56 @@ struct encryptedSharing {
.height(Constants.SHARE_TITLE_HEAD_HEIGHT)
.margin({
top: Constants.SHARE_TITLE_HEAD_MARGIN_TOP,
right: Constants.SHARE_TITLE_HEAD_MARGIN_RIGHT,
bottom: Constants.SHARE_TITLE_HEAD_MARGIN_BOTTOM,
left: Constants.SHARE_TITLE_HEAD_MARGIN_LEFT
})
Column() {
Row() {
TextInput({ text: this.inputValue, placeholder: $r('app.string.Share_Enter_Mobile_Number') })
TextInput({ text: this.inputValue })
.enabled(this.enabledFocus)
.height(Constants.SHARE_TEXT_INPUT_HEIGHT)
.defaultFocus(true)
.type(InputType.PhoneNumber)
.contentType(ContentType.PHONE_COUNTRY_CODE)
.enterKeyType(EnterKeyType.NEW_LINE)
.border(!this.showTipsMsg ?
{ width: Constants.DIALOG_MD_OFFSET, color: $r('sys.color.ohos_id_color_warning') } : {})
.maxLength(Constants.SHARE_TEXT_INPUT_MAX_LENGTH)
.border(this.phoneFormatTips ?
{ width: Constants.DIALOG_MD_OFFSET, color: $r('sys.color.ohos_id_color_warning') } : { width: 0})
.onChange((value: string) => {
this.inputValue = value;
this.showTipsMsg = true;
this.phoneFormatTips = true;
})
Image($r('app.media.ic_public_contacts_group'))
.fillColor($r('sys.color.ohos_id_color_secondary'))
.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;
}
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;
}
})
}
}
Text(){
if (this.showTipsMsg) {
if (this.phoneFormatTips) {
Span($r('app.string.Share_Only_Supported_Mobile_Number'))
} else {
Span($r('app.string.Share_Tips_Phone_Format'))
}
} else {
if (this.phoneFormatTips) {
Span(this.credentialCallBackMsg)
.fontColor($r('sys.color.ohos_id_color_warning'))
} else {
Span($r('app.string.Share_Enter_Mobile_Number'))
}
}
.inputMessageText()
.width(Constants.CONTACTS_PICKER_WIDTH)
.padding({left: Constants.SHARE_TITLE_HEAD_PADDING_LEFT})
}
.height(Constants.SHARE_TEXT_INPUT_COLUMN_HEIGHT)
.margin({ left: Constants.SHARE_TEXT_INPUT_MARGIN_LEFT, right: Constants.SHARE_TEXT_INPUT_MARGIN_RIGHT })
Column() {
Button($r('app.string.Share_Confirms'), { type: ButtonType.Capsule, stateEffect: true })

View File

@ -420,7 +420,7 @@ struct DlpDialog {
let dstFileSize: number = await getFileSizeByUri(uri);
AppStorage.setOrCreate('hiPolicySizeEnc', dstFileSize);
AppStorage.setOrCreate('hiCode', 201);
sendDlpFileCreateProperties('DLP_FILE_CREATE_EVENT'); // 201: DLP_FILE_CREATE_SUCCESS
sendDlpFileCreateProperties(dlpPermission.AccountType.DOMAIN_ACCOUNT); // 201: DLP_FILE_CREATE_SUCCESS
GlobalContext.store('dlpFileName', uriInfo.name);
GlobalContext.store('dlpProperty', _dlp);
GlobalContext.store('uri', uri);

View File

@ -310,15 +310,11 @@
},
{
"name": "Share_Add_Viewable_Users",
"value": "Add Viewable Users"
"value": "Adding a user"
},
{
"name": "Share_Enter_Mobile_Number",
"value": "Enter the bound mobile number"
},
{
"name": "Share_Only_Supported_Mobile_Number",
"value": "Currently, only mobile numbers are supported."
"value": "Enter a mobile number."
},
{
"name": "Share_Tips_Phone_Format",

View File

@ -310,15 +310,11 @@
},
{
"name": "Share_Add_Viewable_Users",
"value": "添加可查看用户"
"value": "添加用户"
},
{
"name": "Share_Enter_Mobile_Number",
"value": "输入绑定的手机号码"
},
{
"name": "Share_Only_Supported_Mobile_Number",
"value": "当前仅支持输入手机号码"
"value": "请输入手机号码"
},
{
"name": "Share_Tips_Phone_Format",