Adapt to API9

Signed-off-by: marenqing@huawei.com <marenqing@huawei.com>
This commit is contained in:
marenqing@huawei.com 2022-04-23 21:13:59 +08:00
parent 57b9f34ddb
commit 7107b419ef
66 changed files with 2789 additions and 2579 deletions

21
.gitignore vendored
View File

@ -1,15 +1,8 @@
*.iml
.idea
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
/entry/.preview
.cxx
build
local.properties
entry/.preview
node_modules
package-lock.json

24
OAT.xml
View File

@ -45,6 +45,30 @@
</filefilter>
<filefilter name="readmeOpenSourcefileNamePolicyFilter" desc="Filters for README.OpenSource file policies">
</filefilter>
<filefilter
desc="Files not to check"
name="defaultFilter">
<filteritem
desc="build config file"
name=".*.json5"
type="filepath"/>
<filteritem
desc="build config file"
name="AppScope/.*.json5"
type="filepath"/>
<filteritem
desc="build config file"
name="entry/.*.json5"
type="filepath"/>
<filteritem
desc="build config file"
name="entry/src/main/.*.json5"
type="filepath"/>
<filteritem
desc="build config file"
name="entry/src/main/ets/MainAbility/workers/.*.js"
type="filepath"/>
</filefilter>
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
<filteritem type="filepath" name="doc/image/.*.png" desc="self developed image"/>
<filteritem type="filepath" name="entry/src/main/resources/base/media/.*.png" desc="self developed image"/>

View File

@ -1,38 +1,46 @@
# mms_app
# 信息应用
#### 简介
mms_app是基于OpenHarmony系统ETS UI框架开发的短信项目主要的功能包含信息查看、发送短信、接收短信、短信送达报告、删除短信等功能
## 简介
#### 架构图
主要针对架构目标、关键架构需求、假设和约束加以说明,对架构的原则性进行必要说明,针对架构的相关视图,进行绘制并加以说明(主要包含用例视图、逻辑视图、开发视图、部署视图、运行视图)
### 内容介绍
Mms应用是OpenHarmony中预置的系统应用主要的功能包含信息查看、发送短信、接收短信、短信送达报告、删除短信等功能
![screenshot-20211129-202627](./doc/image/screenshot-20211129-202627.png)
### 架构图
#### 目录
![MMS_architectural_diagram](./doc/image/MMS_architectural_diagram.png)
/mms/
├── entry # 主entry模块目录
│ ├── src
│ ├── main
│ └── ets # js代码目录
│ └── default
│ └── data # 自定义数据类型
│ └── model # 对接数据库
│ └── pages # 页面
│ └── conversation # 会话详情页面
│ └── conversationlist # 信息列表页面
│ └── index # 首页
│ └── info_msg # 通知信息列表页面
│ └── query_report # 报告详情页面
│ └── settings # 设置页面
│ └── service # 业务逻辑
│ └── utils # 工具类
│ └── views # 自定义组件
│ └── ServiceAbility # 后台常驻服务
│ └── java # Ability
│ └── resources # 资源存放目录
│ └── config.json # 全局配置文件
├── gradle # gradle
│ ├──wrapper
## 目录
~~~
/Mms/
├── doc # 资料
├── entry
│ └── src
│ └── main
│ └── ets # ets代码目录
│ └── default # 业务代码目录
│ ├── data # 自定义数据类型
│ ├── model # 对接数据库
│ ├── pages # 所有页面
│ ├── conversation # 会话详情页面
│ ├── conversationlist # 信息列表页面
│ ├── index # 初始页面
│ ├── info_msg # 通知信息列表页面
│ ├── query_report # 报告详情页面
│ └── settings # 设置页面
│ ├── service # 业务逻辑
│ ├── utils # 工具类
│ ├── views # 自定义组件
│ └── app.ets # 应用生命周期
│ └── ServiceAbility # 后台常驻服务
│ ├── resources # 资源配置文件存放目录
│ └── config.json # 全局配置文件
├── signs # 签名
└── LICENSE
~~~
## 相关仓
[**applications_contacts**](https://gitee.com/openharmony/applications_contacts)
[**telephony_sms_mms**](https://gitee.com/openharmony/telephony_sms_mms)

40
build-profile.json5 Normal file
View File

@ -0,0 +1,40 @@
{
"app": {
"signingConfigs": [
{
"material": {
"certpath": "signs\\IDE.cer",
"storePassword": "00000016AC378B1FECCAFF8E49A871A54D12CA6BD5F4CE1D932414EE9CA119B28BB239AFAB6A",
"keyAlias": "OpenHarmony Application CA",
"keyPassword": "00000016022E1570597F702ED9641DF2C2B914160A07423337B974370A26C48BBBF6479508D3",
"profile": "signs\\com.ohos.mms.p7b",
"signAlg": "SHA256withECDSA",
"storeFile": "signs\\OpenHarmony.p12",
},
"name": "debug",
},
],
"compileSdkVersion": 9,
"compatibleSdkVersion": 9,
"products": [
{
"name": "default",
"signingConfig": "debug"
},
],
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default",
],
},
],
},
],
}

View File

@ -1,63 +0,0 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'com.huawei.ohos.app'
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
ohos {
compileSdkVersion 8
signingConfigs {
debug {
storeFile file('signs\\OpenHarmony.p12')
storePassword '00000016AC378B1FECCAFF8E49A871A54D12CA6BD5F4CE1D932414EE9CA119B28BB239AFAB6A'
keyAlias = 'OpenHarmony Application CA'
keyPassword '00000016022E1570597F702ED9641DF2C2B914160A07423337B974370A26C48BBBF6479508D3'
signAlg = 'SHA256withECDSA'
profile file('signs\\com.ohos.mms.p7b')
certpath file('signs\\IDE.cer')
}
release {
storeFile file('signs\\OpenHarmony.p12')
storePassword '00000016885CAF8FF83DE130396B1828AFAB4AB42CDE3AAE8D0B56597A63F37F42C419A1910A'
keyAlias = 'OpenHarmony Application CA'
keyPassword '000000165D468138AA56D3B714428073CB0821EA43BD405E5C2DA4CCEC66847BB04EF4599248'
signAlg = 'SHA256withECDSA'
profile file('signs\\com.ohos.mms.p7b')
certpath file('signs\\IDE.cer')
}
}
supportSystem "standard"
}
buildscript {
repositories {
maven {
url 'http://repo.ark.tools.huawei.com/artifactory/maven-public/'
allowInsecureProtocol = true
}
maven {
url 'http://mirrors.tools.huawei.com/maven/'
allowInsecureProtocol = true
}
}
dependencies {
classpath 'com.huawei.ohos:hap:3.0.6.4'
// classpath 'com.huawei.ohos:decctest:3.0.4.3'
}
}
allprojects {
repositories {
maven {
url 'http://repo.ark.tools.huawei.com/artifactory/maven-public/'
allowInsecureProtocol = true
}
maven {
url 'http://mirrors.tools.huawei.com/maven/'
allowInsecureProtocol = true
}
}
}
task assembleDebugSignHap(type: Exec, dependsOn: ':entry:assembleDebug') {
workingDir('./signs')
commandLine 'cmd', '/c', 'sign'
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

13
entry/build-profile.json5 Normal file
View File

@ -0,0 +1,13 @@
{
"apiType": 'faMode',
"buildOption": {
},
"targets": [
{
"name": "default",
},
{
"name": "ohosTest",
}
]
}

View File

@ -1,26 +0,0 @@
apply plugin: 'com.huawei.ohos.hap'
//apply plugin: 'com.huawei.ohos.decctest'
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
ohos {
compileSdkVersion 8
defaultConfig {
compatibleSdkVersion 7
}
buildTypes {
release {
proguardOpt {
proguardEnabled false
rulesFiles 'proguard-rules.pro'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
testImplementation 'junit:junit:4.13.1'
ohosTestImplementation 'com.huawei.ohos.testkit:runner:2.0.0.200'
}
//decc {
// supportType = ['html','xml']
//}

2
entry/hvigorfile.js Normal file
View File

@ -0,0 +1,2 @@
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
module.exports = require('@ohos/hvigor-ohos-plugin').legacyHapTasks

View File

@ -1 +0,0 @@
# config module specific ProGuard rules here.

View File

@ -2,16 +2,21 @@
"app": {
"bundleName": "com.ohos.mms",
"vendor": "ohos",
"singleton": true,
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"deviceConfig": {},
"deviceConfig": {
"default": {
"keepAlive": true
}
},
"module": {
"package": "com.ohos.mms",
"name": ".MyApplication",
"mainAbility": "com.ohos.mms.MainAbility",
"mainAbility": "com.ohos.mms.ServiceAbility",
"deviceType": [
"phone",
"tablet",
@ -81,7 +86,7 @@
"pages/settings/ringtoneSettings/ringtoneSettings",
"pages/query_report/query_report"
],
"name": "default",
"name": "com.ohos.mms.MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false

View File

@ -24,7 +24,7 @@ import telSim from '@ohos.telephony.sms';
import ohosDataRdb from '@ohos.data.rdb';
import commonService from '../default/service/CommonService';
import http from '@ohos.net.http';
import notificationService from '../default/service/NotificationService';
import NotificationService from '../default/service/NotificationService';
import LooseObject from '../default/data/LooseObject'
// 数据库实例对象
@ -666,7 +666,7 @@ export default class MmsManagerService {
};
actionData.message = message;
actionData.msgId = msgId;
notificationService.sendNotify(actionData);
NotificationService.getInstance().sendNotify(actionData);
});
}

View File

@ -19,10 +19,10 @@ const TAG = 'app';
export default {
onCreate() {
HiLog.i(TAG, 'onCreate');
HiLog.i(TAG, 'onCreate version: 1.0.0.8');
new AppStorageUtil();
},
onDestroy() {
HiLog.i(TAG, 'onDestroy');
}
};
};

View File

@ -0,0 +1,25 @@
/**
* Copyright (c) 2022 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.
*/
/**
* Observed参数需要自定义类不能是基础类型所以新增一个Boolean自定义类
*/
@Observed
export default class MmsBoolean {
public value : boolean;
constructor(v: boolean) {
this.value = v;
}
}

View File

@ -0,0 +1,74 @@
/**
* Copyright (c) 2022 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 HiLog from '../utils/HiLog';
const TAG = 'BasicDataSource'
export default class BasicDataSource implements IDataSource {
private listeners: DataChangeListener[] = []
public totalCount(): number {
return 0
}
public getData(index: number): any {
return undefined
}
registerDataChangeListener(listener: DataChangeListener): void {
if (this.listeners.indexOf(listener) < 0) {
HiLog.i(TAG, 'add listener')
this.listeners.push(listener)
}
}
unregisterDataChangeListener(listener: DataChangeListener): void {
const pos = this.listeners.indexOf(listener);
if (pos >= 0) {
HiLog.i(TAG, 'remove listener')
this.listeners.splice(pos, 1)
}
}
notifyDataReload(): void {
this.listeners.forEach(listener => {
listener.onDataReloaded()
})
}
notifyDataAdd(index: number): void {
this.listeners.forEach(listener => {
listener.onDataAdded(index)
})
}
notifyDataChange(index: number): void {
this.listeners.forEach(listener => {
listener.onDataChanged(index)
})
}
notifyDataDelete(index: number): void {
this.listeners.forEach(listener => {
listener.onDataDeleted(index)
})
}
notifyDataMove(from: number, to: number): void {
this.listeners.forEach(listener => {
listener.onDataMoved(from, to)
})
}
}

View File

@ -61,6 +61,7 @@ export default class ContactsModel extends BaseModel {
callback(this.dealResultSet(resultSet));
}).catch(error => {
HiLog.e(TAG, 'queryContactDataByTelephone, error: ' + JSON.stringify(error.message));
callback([]);
});
}

View File

@ -0,0 +1,48 @@
// @ts-nocheck
/**
* Copyright (c) 2022 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 BaseDataSource from './BaseDataSource';
import HiLog from '../utils/HiLog';
const TAG = "ConversationListDataSource";
export default class ConversationListDataSource extends BaseDataSource {
private mmsList: Array = [];
public totalCount(): number {
HiLog.i(TAG, "totalCount is %s", this.mmsList.length);
return this.mmsList.length;
}
public getData(index: number): any {
HiLog.i(TAG, "getData index is %s", index);
if (this.mmsList == null || index >= this.mmsList.length) {
HiLog.i(TAG, "getData Conversationlist is empty");
return null;
} else {
let conversation = this.mmsList[index];
return {
index: index,
conversation: conversation
};
}
}
public refresh(conversationList) {
HiLog.i(TAG, ' refresh!');
this.mmsList = conversationList;
this.notifyDataReload();
}
}

View File

@ -21,7 +21,6 @@ import mmsTable from '../data/tableData';
import HiLog from '../utils/HiLog'
import LooseObject from '../data/LooseObject'
import featureAbility from '@ohos.ability.featureAbility';
import particleAbility from '@ohos.ability.particleAbility';
import dataAbility from '@ohos.data.dataAbility';
const TAG = 'ConversationModel';

View File

@ -0,0 +1,28 @@
/**
* Copyright (c) 2022 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 LooseObject from '../../data/LooseObject'
export default class Common {
private static sInstance: Common;
// 给receive传递的参数数据
paramContact: LooseObject = {};
static getInstance() {
if (Common.sInstance == null) {
Common.sInstance = new Common();
}
return Common.sInstance;
}
}

View File

@ -15,86 +15,75 @@
/**
* 信息/彩信查看界面
*/
import ConversationController from './conversationController'
import {Receive} from '../../views/receive/receive'
import LooseObject from '../../data/LooseObject'
import mediaquery from '@ohos.mediaquery'
import observer from '@ohos.telephony.observer';
let portraitFunc = null
import ConversationController from "./conversationController";
import DeviceUtil from "../../utils/DeviceUtil";
import { Receive } from "../../views/receive/receive";
import LooseObject from "../../data/LooseObject";
import { MmsMenu } from "../../views/MmsMenu";
import Common from "./common";
@Entry
@Component
export struct Conversation {
@StorageLink('ConversationController') conversationController: ConversationController = ConversationController.getInstance();
@State mConversationCtrl: ConversationController = ConversationController.getInstance();
@State mCommonCtrl: Common = Common.getInstance();
@State sizeType: SizeType = DeviceUtil.isTablet() ? SizeType.LG : SizeType.SM;
@State columns: number = DeviceUtil.isTablet() ? 12 : 4;
@State gutter: string = "24vp";
@State margin: string = DeviceUtil.isTablet() ? "24vp" : "12vp";
private menuItems: Array<any> = [
{
value: $r("app.string.delete"),
action: () => {
this.mConversationCtrl.longPressMore(0);
},
enabled: true
}
];
/** 短信详情弹框 */
dialogController: CustomDialogController = new CustomDialogController({
builder: DetailsDialog({
item: this.conversationController.mmsList[this.conversationController.mmsIndex],
receiver: this.conversationController.strContactsName == ''
? this.conversationController.strContactsNumber :
this.conversationController.strContactsName
item: this.mConversationCtrl.mmsList[this.mConversationCtrl.mmsIndex],
receiver: this.mConversationCtrl.strContactsName == ''
? this.mConversationCtrl.strContactsNumber :
this.mConversationCtrl.strContactsName
}),
autoCancel: true,
alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: -30 }
})
// 监听横竖屏
listener = mediaquery.matchMediaSync('(orientation: landscape)')
onPortrait(mediaQueryResult) {
if (mediaQueryResult.matches) {
console.log("mediaQuery landScape")
this.sizeType = SizeType.LG
} else {
console.log("mediaQuery vert")
this.sizeType = SizeType.XS
this.columns = 4
this.margin = '12vp'
}
aboutToAppear() {
this.mConversationCtrl.onInit()
}
private aboutToAppear(): void {
this.onPortrait(this.listener)
portraitFunc = this.onPortrait.bind(this)
this.listener.on('change', portraitFunc)
// 实时监听SIM卡状态
observer.on('simStateChange', data => {
let simState = data.state
if (simState == 0 || simState == 1) {
this.conversationController.haveSimCard = false
} else {
this.conversationController.haveSimCard = true
}
this.conversationController.initSendTip()
});
this.conversationController.onInit()
// 初始化函数
onPageShow() {
this.mConversationCtrl.onShow()
}
private onPageShow(): void {
this.conversationController.onShow()
onPageHide() {
this.mConversationCtrl.onHide()
}
private onBackPress(): void {
this.conversationController.onBackPress()
onBackPress() {
return this.mConversationCtrl.onBackPress();
}
@State columns: number = 12;
@State sizeType: SizeType = SizeType.LG;
@State gutter: string = '24vp';
@State margin: string = '24vp';
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
// <!--上方titleBar-->
// 新建界面
if (this.conversationController.isNewMsg) {
if (this.mConversationCtrl.isNewMsg) {
Row() {
Image($rawfile('icon/ic_message_back.svg'))
.width('24vp')
.height('24vp')
.onClick(() => {
// 点击返回恢复到未选中短信状态
this.conversationController.titleBarBack()
this.mConversationCtrl.titleBarBack()
})
Text($r("app.string.new_message"))
.margin({ left: '24vp' })
@ -114,16 +103,16 @@ export struct Conversation {
else {
Row() {
// 选择状态
if (this.conversationController.isSelectStatus) {
if (this.mConversationCtrl.isSelectStatus) {
Row() {
Image($rawfile('icon/ic_cancel_black.svg'))
Image($rawfile('icon/ic_public_cancel.svg'))
.width(24)
.height(24)
.onClick(() => {
// 点击返回恢复到未选中短信状态
this.conversationController.titleBarCancel()
this.mConversationCtrl.titleBarCancel()
})
Text(this.conversationController.selectDeleteMsgCount == 0 ? $r("app.string.msg_unselected_tip") : $r("app.string.msg_selected_tip", this.conversationController.selectDeleteMsgCount))
Text(this.mConversationCtrl.selectDeleteMsgCount == 0 ? $r("app.string.msg_unselected_tip") : $r("app.string.msg_selected_tip", this.mConversationCtrl.selectDeleteMsgCount))
.margin({ left: 16 })
.fontSize(20)
.fontColor($r('app.color.main_font_color'))
@ -143,14 +132,14 @@ export struct Conversation {
.width(24)
.height(24)
.onClick(() => {
this.conversationController.titleBarBack()
this.mConversationCtrl.titleBarBack()
})
Image($rawfile('icon/user_avatar_full_fill.svg'))
.width(40)
.height(40)
.margin({ left: 16 })
.onClick(() => {
this.conversationController.titleBarAvatar();
this.mConversationCtrl.titleBarAvatar();
})
}
.flexBasis(80)
@ -161,14 +150,14 @@ export struct Conversation {
justifyContent: FlexAlign.Center,
alignItems: ItemAlign.Start
}) {
if (this.conversationController.contactsNum > 1) {
Text(this.conversationController.strContactsName).fontSize(16).fontColor($r('app.color.main_font_color'))
Text($r("app.string.members", this.conversationController.contactsNum)).fontSize(14).fontColor($r('app.color.main_font_color_40'))
} else if (this.conversationController.strContactsName == '' || this.conversationController.strContactsName == null) {
Text(this.conversationController.strContactsNumberFormat).fontSize(16).fontColor($r('app.color.main_font_color'))
if (this.mConversationCtrl.contactsNum > 1) {
Text(this.mConversationCtrl.strContactsName).fontSize(16).fontColor($r('app.color.main_font_color'))
Text($r("app.string.members", this.mConversationCtrl.contactsNum)).fontSize(14).fontColor($r('app.color.main_font_color_40'))
} else if (this.mConversationCtrl.strContactsName == '' || this.mConversationCtrl.strContactsName == null) {
Text(this.mConversationCtrl.strContactsNumberFormat).fontSize(16).fontColor($r('app.color.main_font_color'))
} else {
Text(this.conversationController.strContactsName).fontSize(16).fontColor($r('app.color.main_font_color'))
Text(this.conversationController.strContactsNumberFormat).fontSize(14).fontColor($r('app.color.main_font_color_40'))
Text(this.mConversationCtrl.strContactsName).fontSize(16).fontColor($r('app.color.main_font_color'))
Text(this.mConversationCtrl.strContactsNumberFormat).fontSize(14).fontColor($r('app.color.main_font_color_40'))
}
}
}
@ -181,49 +170,15 @@ export struct Conversation {
.width(24)
.height(24)
.onClick(() => {
this.conversationController.clickCall();
this.mConversationCtrl.clickCall();
})
Image($rawfile('icon/ic_message_more1.svg'))
.width(24)
.height(24)
.margin({ left: 16 })
.bindMenu([
{
// @ts-ignore
value: $r("app.string.delete"),
action: () => {
this.conversationController.longPressMore(0);
}
},
// {
// // @ts-ignore
// value: $r("app.string.msg_new_contact"),
// action: () => {
// this.conversationController.longPressMore(1);
// }
// },
// {
// // @ts-ignore
// value: $r("app.string.msg_save_to_an_existing_contact"),
// action: () => {
// this.conversationController.longPressMore(2);
// }
// },
// {
// // @ts-ignore
// value: $r("app.string.msg_pre_call_editor"),
// action: () => {
// this.conversationController.longPressMore(3);
// }
// },
// {
// // @ts-ignore
// value: $r("app.string.msg_blacklist"),
// action: () => {
//
// }
// }
])
Column() {
MmsMenu({
menuItems: this.menuItems,
sizeType: this.sizeType
})
}
.margin({ left: 16 })
}
.flexBasis(64)
@ -240,16 +195,16 @@ export struct Conversation {
// <!--中间内容区域-->
Row() {
// 新建消息内容
if (this.conversationController.isNewMsg) {
if (this.mConversationCtrl.isNewMsg) {
Row() {
Receive()
Receive({ mConversationController: $mConversationCtrl })
}.margin({ top: 8 })
}
// 短信内容
// <!--信息列表-->
if (!this.conversationController.isNewMsg) {
List({ space: 10, initialIndex: this.conversationController.mmsList.length - 1 }) {
ForEach(this.conversationController.mmsList, (item, index) => {
if (!this.mConversationCtrl.isNewMsg) {
List({ space: 10, initialIndex: this.mConversationCtrl.mmsList.length - 1 }) {
ForEach(this.mConversationCtrl.mmsList, (item, index) => {
ListItem() {
Column() {
GridContainer({
@ -270,19 +225,14 @@ export struct Conversation {
Text($r("app.string.msg_note_mms")).fontSize(12).lineHeight(16).fontColor($r('app.color.main_font_color_60')).margin({ bottom: 2 })
}
// 时间
if (!this.conversationController.mmsDateSet.has(item.date.id) &&
this.conversationController.mmsDateSet.add(item.date.id)) {
Text(item.date).fontSize(12).lineHeight(16).fontColor($r('app.color.main_font_color_60')).margin({ bottom: 8 })
if (item.dateShow) {
Text(){
Span(item.date).fontSize(12).fontColor($r('app.color.main_font_color_60'))
Span(item.week).fontSize(12).fontColor($r('app.color.main_font_color_60'))
}.lineHeight(16).margin({ bottom: 8 })
}
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Start }) {
Column() {
// if (this.conversationController.isSelectStatus == false && item.isShowMsgLongMenu) {
// menu({
//// controller: this.conversationController,
// index: index,
// isSender: true
// })
// }
Flex({
justifyContent: FlexAlign.End,
alignItems: ItemAlign.End
@ -293,7 +243,7 @@ export struct Conversation {
alignItems: ItemAlign.End
}) {
// <!--发送失败icon-->
if (!item.isMsm && ((this.conversationController.contactsNum == 1 && item.sendStatus == 2) || (this.conversationController.contactsNum > 1 && item.failuresNumber > 0 && item.completeNumber == this.conversationController.contactsNum))) {
if (!item.isMsm && ((this.mConversationCtrl.contactsNum == 1 && item.sendStatus == 2) || (this.mConversationCtrl.contactsNum > 1 && item.failuresNumber > 0 && item.completeNumber == this.mConversationCtrl.contactsNum))) {
Row() {
Image($rawfile('icon/ic_send_fail.svg'))
.width(24)
@ -304,6 +254,7 @@ export struct Conversation {
}
// 消息气泡
bubbleText({
conversationCtrl: $mConversationCtrl,
borderRadius: [4, 24],
direction: 'right',
content: item.content,
@ -315,11 +266,11 @@ export struct Conversation {
}
// <!--发送时间、发送状态那行-->
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.End }) {
if (this.conversationController.contactsNum == 1 && item.sendStatus != 1) {
if (this.mConversationCtrl.contactsNum == 1 && item.sendStatus != 1) {
Text(item.time).textAlign(TextAlign.Start).fontSize(10).lineHeight(13).fontColor($r('app.color.main_font_color_60')).margin({ top: 8, right: 5 })
}
// 卡1还是卡2
if (this.conversationController.cardImage) {
if (this.mConversationCtrl.cardImage) {
Image(item.subId == 0 ? $rawfile('icon/icon_mms_sim_1.svg') : $rawfile('icon/icon_mms_sim_2.svg'))
.width(10)
.height(10)
@ -367,24 +318,31 @@ export struct Conversation {
}
.width(50)
.height(30)
.visibility(this.conversationController.contactsNum > 1 ? Visibility.Visible : Visibility.None)
.visibility(this.mConversationCtrl.contactsNum > 1 ? Visibility.Visible : Visibility.None)
// <!--信息checkbox-->
Toggle({ type: ToggleType.Checkbox, isOn: item.isCbChecked })
.width(20)
.height(20)
.visibility(this.conversationController.isSelectStatus ? Visibility.Visible : Visibility.None)
.onChange(((isOn: boolean) => {
this.conversationController.listCheckBoxChange(index, isOn)
}))
if (this.mConversationCtrl.isSelectStatus) {
Row() {
Toggle({ type: ToggleType.Checkbox, isOn: item.isCbChecked })
.width(24)
.height(24)
.selectedColor($r("app.color.control_activated_color"))
.onChange(((isOn: boolean) => {
this.mConversationCtrl.listCheckBoxChange(index, isOn)
}))
}
.width(48)
.height(48)
.margin({ left: 4 })
}
}
.useSizeType({
xs: { span: 4, offset: 0 }, sm: { span: 8, offset: 2 },
xs: { span: 4, offset: 0 }, sm: { span: 4, offset: 0 },
md: { span: 8, offset: 2 }, lg: { span: 8, offset: 2 }
})
}
.width('100%')
.useSizeType({
xs: { span: 4, offset: 0 }, sm: { span: 12, offset: 0 },
xs: { span: 4, offset: 0 }, sm: { span: 4, offset: 0 },
md: { span: 12, offset: 0 }, lg: { span: 12, offset: 0 }
})
}
@ -401,23 +359,19 @@ export struct Conversation {
Text($r("app.string.msg_note_mms")).fontSize(12).lineHeight(16).fontColor($r('app.color.main_font_color_60')).margin({ bottom: 2 })
}
// 时间
if (!this.conversationController.mmsDateSet.has(item.date.id) &&
this.conversationController.mmsDateSet.add(item.date.id)) {
Text(item.date).fontSize(12).lineHeight(16).fontColor($r('app.color.main_font_color_60')).margin({ bottom: 8 })
if (item.dateShow) {
Text(){
Span(item.date).fontSize(12).fontColor($r('app.color.main_font_color_60'))
Span(item.week).fontSize(12).fontColor($r('app.color.main_font_color_60'))
}.lineHeight(16).margin({ bottom: 8 })
}
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Start }) {
Column() {
// if (this.conversationController.isSelectStatus == false && item.isShowMsgLongMenu) {
// menu({
//// controller: this.conversationController,
// index: index,
// isSender: false
// })
// }
Flex({ alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
// 消息气泡
bubbleText({
conversationCtrl: $mConversationCtrl,
borderRadius: [4, 24],
direction: 'left',
content: item.content,
@ -427,14 +381,14 @@ export struct Conversation {
})
}
.useSizeType({
xs: { span: 4, offset: 0 }, sm: { span: 8, offset: 0 },
xs: { span: 4, offset: 0 }, sm: { span: 4, offset: 0 },
md: { span: 8, offset: 0 }, lg: { span: 8, offset: 0 }
})
// <!--发送时间、发送状态那行-->
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
Text(item.time).textAlign(TextAlign.Start).fontSize(10).lineHeight(13).fontColor($r('app.color.main_font_color_60')).margin({ top: 8, right: 5 })
// 卡1还是卡2
if (this.conversationController.cardImage) {
if (this.mConversationCtrl.cardImage) {
Image(item.subId == 0 ? $rawfile('icon/icon_mms_sim_1.svg') : $rawfile('icon/icon_mms_sim_2.svg'))
.width(10)
.height(10)
@ -452,29 +406,35 @@ export struct Conversation {
.width('100%')
.alignItems(HorizontalAlign.Start)
Toggle({ type: ToggleType.Checkbox, isOn: item.isCbChecked })
.width(20)
.height(20)
.visibility(this.conversationController.isSelectStatus ? Visibility.Visible : Visibility.None)
.onChange(((isOn: boolean) => {
this.conversationController.listCheckBoxChange(index, isOn)
}))
if (this.mConversationCtrl.isSelectStatus) {
Row() {
Toggle({ type: ToggleType.Checkbox, isOn: item.isCbChecked })
.width(24)
.height(24)
.selectedColor($r("app.color.control_activated_color"))
.onChange(((isOn: boolean) => {
this.mConversationCtrl.listCheckBoxChange(index, isOn)
}))
}
.margin({ left: 4 })
.width(48)
.height(48)
}
}
}.width('100%')
.useSizeType({
xs: { span: 4, offset: 0 }, sm: { span: 12, offset: 0 },
xs: { span: 4, offset: 0 }, sm: { span: 4, offset: 0 },
md: { span: 12, offset: 0 }, lg: { span: 12, offset: 0 }
})
}
}
}
}.onClick(() => {
if (this.conversationController.isSelectStatus) {
this.conversationController.listCheckBoxChange(index,!item.isCbChecked)
if (this.mConversationCtrl.isSelectStatus) {
this.mConversationCtrl.listCheckBoxChange(index,!item.isCbChecked)
}
})
// .padding({ left: 24, right: 24 })
.padding(index == this.mConversationCtrl.mmsList.length - 1 ? { bottom: 20 } : null)
}, item => item.id)
}
.listDirection(Axis.Vertical) // 排列方向
@ -484,13 +444,13 @@ export struct Conversation {
}
.width('100%')
.flexBasis('auto')
.flexShrink(1)
}
.width('100%')
// <!--底部输入框-->
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
// <!--底部更多选项 -->
if (this.conversationController.isSelectStatus && !this.conversationController.hasDetailDelete) {
if (this.mConversationCtrl.isSelectStatus && !this.mConversationCtrl.hasDetailDelete) {
/** 底部选中了信息按钮 */
Flex({
direction: FlexDirection.Row,
@ -503,14 +463,14 @@ export struct Conversation {
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Center
}) {
Image($rawfile('icon/ic_delete_m.svg'))
Image($rawfile('icon/ic_public_delete.svg'))
.width(24)
.height(24)
Text($r("app.string.delete")).fontSize(10).margin({ top: 3 }).fontColor($r('app.color.main_font_color'))
}.width('25%').opacity(this.conversationController.selectDeleteMsgCount == 0 ? 0.4 : 1)
}.width('25%').opacity(this.mConversationCtrl.selectDeleteMsgCount == 0 ? 0.4 : 1)
.onClick(() => {
if (this.conversationController.selectDeleteMsgCount != 0) {
this.conversationController.clickGroupDelete()
if (this.mConversationCtrl.selectDeleteMsgCount != 0) {
this.mConversationCtrl.clickGroupDelete()
}
})
/** 转发 */
@ -523,7 +483,7 @@ export struct Conversation {
Text($r("app.string.msg_transmit")) {
}.fontSize(10).margin({ top: 3 }).fontColor($r('app.color.main_font_color'))
}.width('25%').opacity(this.conversationController.selectDeleteMsgCount == 0 ? 0.4 : 1)
}.width('25%').opacity(this.mConversationCtrl.selectDeleteMsgCount == 0 ? 0.4 : 1)
.onClick(() => {
})
@ -537,7 +497,7 @@ export struct Conversation {
Text($r("app.string.msg_star")) {
}.fontSize(10).margin({ top: 3 }).fontColor($r('app.color.main_font_color'))
}.width('25%').opacity(this.conversationController.selectDeleteMsgCount == 0 ? 0.4 : 1)
}.width('25%').opacity(this.mConversationCtrl.selectDeleteMsgCount == 0 ? 0.4 : 1)
.onClick(() => {
})
@ -545,14 +505,18 @@ export struct Conversation {
Flex({ direction: FlexDirection.Column,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Center }) {
Image(this.conversationController.isMessageCheckAll ? $rawfile('icon/ic_select_all_filled.svg') : $rawfile('icon/ic_select_all.svg'))
Image(this.mConversationCtrl.isMessageCheckAll ? $rawfile('icon/ic_select_all_filled.svg') : $rawfile('icon/ic_select_all.svg'))
.width(24)
.height(24)
Text(this.conversationController.isMessageCheckAll ? $r("app.string.msg_deselect_all") : $r("app.string.msg_select_all")) {
}.fontSize(10).margin({ top: 3 }).fontColor($r('app.color.main_font_color'))
Text(this.mConversationCtrl.isMessageCheckAll ? $r("app.string.msg_deselect_all") : $r("app.string.msg_select_all")) {
}
.fontSize(10)
.margin({ top: 3 })
.fontColor(this.mConversationCtrl.isMessageCheckAll ?
$r("app.color.control_activated_color") : $r("app.color.main_font_color"))
}.width('25%')
.onClick(() => {
this.conversationController.clickGroupCheckAll()
this.mConversationCtrl.clickGroupCheckAll()
})
/** 更多 */
Flex({ direction: FlexDirection.Column,
@ -565,7 +529,7 @@ export struct Conversation {
}.fontSize(10).margin({ top: 3 }).fontColor($r('app.color.main_font_color'))
}.width('25%')
// @ts-ignore
.bindMenu(this.conversationController.selectDeleteMsgCount == 1 ?
.bindMenu(this.mConversationCtrl.selectDeleteMsgCount == 1 ?
[
// {
// value: $r("app.string.msg_copy"),
@ -595,15 +559,15 @@ export struct Conversation {
value: $r("app.string.query_details"),
action: () => {
this.dialogController.open()
this.conversationController.isSelectStatus = !this.conversationController.isSelectStatus
this.conversationController.isMessageCheckAll = false
this.conversationController.cancleCheckedAll()
this.mConversationCtrl.isSelectStatus = !this.mConversationCtrl.isSelectStatus
this.mConversationCtrl.isMessageCheckAll = false
this.mConversationCtrl.cancleCheckedAll()
}
},
this.conversationController.hasReport ? {
this.mConversationCtrl.hasReport ? {
value: $r("app.string.query_report"),
action: () => {
this.conversationController.moreSelected(6)
this.mConversationCtrl.moreSelected(6)
}
} : {}
] : [{}
@ -625,7 +589,7 @@ export struct Conversation {
.height(56)
}
// <!--底部发送栏-->
if (!this.conversationController.isSelectStatus) {
if (!this.mConversationCtrl.isSelectStatus) {
Flex({ alignItems: ItemAlign.End, justifyContent: FlexAlign.Center }) {
// <!--左侧更多和全屏显示-->
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
@ -640,11 +604,11 @@ export struct Conversation {
}
}
.flexBasis('40')
.visibility(Visibility.None)
.visibility(Visibility.Hidden)
// <!--输入框-->
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Flex({ alignItems: ItemAlign.Center }) {
Image(this.conversationController.slotId == 0 ? $rawfile('icon/ic_message_card1.svg') : $rawfile('icon/ic_message_card2.svg'))
Image(this.mConversationCtrl.slotId == 0 ? $rawfile('icon/ic_message_card1.svg') : $rawfile('icon/ic_message_card2.svg'))
.width(22)
.height(22)
Image($rawfile('icon/icon_down.svg'))
@ -652,26 +616,30 @@ export struct Conversation {
.height(22)
}
.flexBasis(36)
.visibility(this.conversationController.cardImage ? Visibility.Visible : Visibility.None)
.visibility(this.mConversationCtrl.cardImage ? Visibility.Visible : Visibility.None)
Flex() {
TextArea({
placeholder: $r("app.string.msg_note_mms"),
text: this.conversationController.textValue
text: this.mConversationCtrl.textValue
})
.placeholderColor($r('app.color.placeholder_color'))
.caretColor($r('app.color.control_activated_color'))
.backgroundColor($r('app.color.default_main_background'))
.backgroundColor($r("app.color.transparent_color"))
.borderRadius(20)
.onChange(value => {
this.conversationController.changeValue(value);
this.mConversationCtrl.changeValue(value);
})
}.flexGrow(1).constraintSize({ minHeight: 40, maxHeight: 584 })
}
.flexGrow(1)
.flexShrink(1)
.constraintSize({ minHeight: 40, maxHeight: 584 })
}
.backgroundColor($r('app.color.default_main_background'))
.padding({ left: 8, right: 8 })
.backgroundColor($r("app.color.search_input_background"))
.padding(this.mConversationCtrl.cardImage ? { left: 8, right: 8 } : 0)
.borderRadius(20)
.flexBasis('auto')
.flexShrink(1)
Column().width(12)
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Flex() {
@ -682,24 +650,23 @@ export struct Conversation {
}
}
.flexBasis('40')
.visibility(Visibility.None)
.visibility(Visibility.Hidden)
// <!--发送-->
Flex({
direction: FlexDirection.Row,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Start
}) {
// Text((this.conversationController.textValue.length !=0 || this.conversationController.isEditMms)
// ? this.conversationController.msgSendTip : '').fontSize(12)
// Text((this.mConversationCtrl.textValue.length !=0 || this.mConversationCtrl.isEditMms)
// ? this.mConversationCtrl.msgSendTip : '').fontSize(12)
Flex() {
Image(this.conversationController.canSendMessage ? $rawfile('icon/ic_message_send_filled.svg') : $rawfile('icon/ic_message_send.svg'))
Image(this.mConversationCtrl.canSendMessage ? $rawfile('icon/ic_message_send_filled.svg') : $rawfile('icon/ic_message_send.svg'))
.onClick(() => {
// 点击发送按钮
this.conversationController.send()
this.mConversationCtrl.send()
})
.width(24)
.height(24)
.opacity(this.conversationController.canSendMessage ? 1 : 0.4)
.margin({ bottom: 16 })
}
}
@ -710,10 +677,10 @@ export struct Conversation {
}
}
.width('100%')
.padding({ left: 24, right: 24 })
.padding({ left: 24, right: 12 })
.backgroundColor($r("app.color.white"))
}
.backgroundColor($r("app.color.default_main_background"))
.backgroundColor($r("app.color.detail_main_background"))
.width('100%')
.height('100%')
}
@ -767,7 +734,7 @@ struct DetailsDialog {
// 自定义聊天气泡
@Component
struct bubbleText {
@StorageLink('ConversationController') controller: ConversationController = ConversationController.getInstance();
@Link conversationCtrl: ConversationController;
private borderRadius: Array<number>; // 圆角大小,共两个参数
private direction: string; // left:左上角 right: 右上角
private content: string; // 气泡显示内容
@ -777,67 +744,45 @@ struct bubbleText {
@State showMenu: boolean = false
@Builder MenuBuilder() {
Row() {
// Button($r("app.string.msg_copy"))
// .fontSize(14)
// .fontColor(Color.Black)
// .backgroundColor($r("app.color.white"))
// Button($r("app.string.msg_transmit"))
// .fontSize(14)
// .fontColor(Color.Black)
// .backgroundColor($r("app.color.white"))
Button($r("app.string.delete"))
.fontSize(14)
.fontColor(Color.Black)
.fontColor($r('app.color.main_font_color'))
.backgroundColor($r("app.color.white"))
.onClick(() => {
this.controller.longPressSelected(2)
this.conversationCtrl.longPressSelected(2)
this.showMenu = false
})
// Button($r("app.string.msg_select_text"))
// .fontSize(12)
// .fontColor(Color.Black)
// .backgroundColor($r("app.color.white"))
Button($r("app.string.more"))
.fontSize(14)
.fontColor(Color.Black)
.fontColor($r('app.color.main_font_color'))
.backgroundColor($r("app.color.white"))
.onClick(() => {
this.controller.longPressSelected(4)
this.conversationCtrl.longPressSelected(4)
this.showMenu = false
})
}
.height(40)
// .padding(10)
.borderRadius(20)
.backgroundColor($r("app.color.white"))
}
build() {
Row() {
Stack({ alignContent: this.direction == 'left' ? Alignment.TopStart : Alignment.TopEnd }) {
Text()
.backgroundColor(this.backgroundColor)
.borderRadius(this.borderRadius[0])
.width(24)
.height(24)
.visibility(this.content ? Visibility.Visible : Visibility.None)
Text(this.content)
.fontSize(16)
.lineHeight(21)
.padding({ left: 12, right: 12, top: 8, bottom: 8 })
.backgroundColor(this.backgroundColor)
.borderRadius(this.borderRadius[1])
.fontColor($r('app.color.main_font_color'))
}
Text(this.content)
.fontSize(16)
.lineHeight(21)
.padding({ left: 12, right: 12, top: 8, bottom: 8 })
.backgroundColor(this.backgroundColor)
.borderRadius(this.borderRadius[1])
.fontColor($r('app.color.main_font_color'))
}
.flexBasis('auto')
.gesture(
LongPressGesture({ repeat: false, duration: 500 })
//长按动作存在会连续触发
.onAction(() => {
if (!this.controller.isSelectStatus) {
this.controller.mmsListLongPress(this.itemIndex)
if (!this.conversationCtrl.isSelectStatus) {
this.conversationCtrl.mmsListLongPress(this.itemIndex)
this.showMenu = true
}
})
@ -845,8 +790,8 @@ struct bubbleText {
.bindPopup(this.showMenu, {
builder: this.MenuBuilder,
placement: this.direction == 'left' ? Placement.TopRight : Placement.TopLeft,
maskColor: 0x33000000,
popupColor: Color.White,
maskColor: $r("app.color.mask_color"),
popupColor: $r("app.color.transparent_color"),
enableArrow: false,
onStateChange: (e) => {
if (!e.isVisible) {

View File

@ -29,23 +29,23 @@ import callService from '../../service/CallService';
import sendMsgService from '../../service/SendMsgService'
import preferences from '../../utils/PreferencesUtil';
import dateUtil from '../../utils/DateUtil';
import appConfig from '../../app';
import rdbStore from '../../utils/RdbStoreUtil';
import featureAbility from '@ohos.ability.featureAbility';
import appStorage from '../../utils/AppStorageUtil';
import notificationService from '../../service/NotificationService';
import NotificationService from '../../service/NotificationService';
import observer from '@ohos.telephony.observer';
import telephonySim from '@ohos.telephony.sim';
import commonCtrl from './common'
const TAG = 'ConversationController';
const ANIMATION_DURATION = 1500;
const TRANSFORM_SCALE_MIN = '1.0';
const TRANSFORM_SCALE_MAX = '3.0';
const COMMON_FILE_SIZE_STRING = '/300KB';
const COMMON_FILE_SIZE = 300;
let conversationCtrl;
let commonEventData = null;
export default class ConversationController {
private static sInstance: ConversationController;
commonCtrl = commonCtrl.getInstance();
// 短信列表刷新flag
refresh: boolean = false;
// 信息删除提示
@ -161,8 +161,6 @@ export default class ConversationController {
selectContacts: Array<any> = [];
// 收件人输入框内容
receiveContactValue: string = '';
// 给receive传递的参数数据
paramContact: LooseObject = {};
// 控制最后div显示与隐藏
isSendStatus: boolean = false;
// 会话列表的id
@ -230,11 +228,10 @@ export default class ConversationController {
mmsDateSet: Set<any> = new Set();
static getInstance() {
if (conversationCtrl == null) {
conversationCtrl = new ConversationController();
appStorage.setAndLink('ConversationController', conversationCtrl);
if (ConversationController.sInstance == null) {
ConversationController.sInstance = new ConversationController();
}
return conversationCtrl;
return ConversationController.sInstance;
}
onInit() {
@ -249,17 +246,15 @@ export default class ConversationController {
// this.setTabTitleText();
// 获取真实数据,新建无需查询数据
if (!this.isNewMsg) {
this.queryMessageDetail(this.strContactsNumber, this.threadId);
this.queryMessageDetail(this.strContactsNumber, this.threadId, () => {});
}
}
onShow() {
HiLog.i(TAG, 'onShow');
if (this.mmsDateSet.size > 0) {
this.mmsDateSet.clear();
}
this.addSimChangeListener();
// 判断是否插入了电话卡
this.haveSimCard = conversationService.judgeHasSimCard();
this.getSimState();
// 判断发送按钮是否可点击
this.judgeSendBtnCanClicked();
// 初始化转发的数据
@ -287,6 +282,43 @@ export default class ConversationController {
this.unSubscribeDetail();
}
getSimState() {
telephonySim.getSimState(common.int.SIM_ONE, (err, value) => {
if (err) {
HiLog.e(TAG, 'getSimState, SIM_ONE error: ' + JSON.stringify(err.message));
} else {
HiLog.i(TAG, 'getSimState, SIM_ONE value: ' + value);
if (value == 0 || value == 1 || value == undefined) {
this.haveSimCard = false;
} else {
this.haveSimCard = true;
}
this.initSendTip();
HiLog.i(TAG, 'haveSimCard1 = ' + this.haveSimCard);
}
});
}
// 监听SIM卡状态
addSimChangeListener() {
observer.on('simStateChange', {
slotId: common.int.SIM_ONE
}, data => {
let simState = data.state;
let isEffective: boolean;
HiLog.i(TAG, 'addSimChangeListener simState = ' + simState);
if (simState == 0 || simState == 1 || simState == undefined) {
isEffective = false;
} else {
isEffective = true;
}
HiLog.i(TAG, 'simState is = ' + isEffective);
preferences.setValueForSwitch(common.string.KEY_OF_SIM_0_EXIST_FLAG, isEffective);
this.haveSimCard = isEffective;
this.initSendTip();
});
}
initData() {
this.strMsgDeleteDialogTip = $r('app.string.msg_delete_dialog_tip2',
this.selectDeleteMsgCount
@ -331,7 +363,6 @@ export default class ConversationController {
this.textValue = '';
this.receiveContactValue = '';
this.isDraft = false;
this.isNewMsg = false;
this.mmsList = [];
}
@ -355,9 +386,9 @@ export default class ConversationController {
transmitContracts.push(item);
}
}
this.paramContact.transmitContracts = transmitContracts;
this.paramContact.isSelectContact = false;
this.paramContact.isNewRecallMessagesFlag = false;
this.commonCtrl.paramContact.transmitContracts = transmitContracts;
this.commonCtrl.paramContact.isSelectContact = false;
this.commonCtrl.paramContact.isNewRecallMessagesFlag = false;
}
initRouterData() {
@ -769,6 +800,7 @@ export default class ConversationController {
// 通过filter删除选中的item
for (let element of this.mmsList) {
if (!element.isCbChecked || (element.isLock && !this.isSelectLockMsg)) {
this.setDateShow(element, mmsListCopy);
mmsListCopy.push(element);
} else {
groupIds.push(element.groupId);
@ -783,6 +815,7 @@ export default class ConversationController {
if (this.mmsIndex == i) {
continue;
} else {
this.setDateShow(this.mmsList[i], mmsListCopy);
mmsListCopy.push(this.mmsList[i]);
}
}
@ -879,13 +912,14 @@ export default class ConversationController {
},
primaryButton: {
value: $r("app.string.cancel"),
fontColor: $r("app.color.control_activated_color"),
action: () => {
this.deleteDialogCancel()
}
},
secondaryButton: {
value: $r("app.string.delete"),
fontColor: Color.Red,
fontColor: $r("app.color.message_send_failed"),
action: () => {
this.deleteDialogConfirm()
}
@ -918,7 +952,7 @@ export default class ConversationController {
* @return
*/
// 查询信息会话列表
queryMessageDetail(telephone, threadId) {
queryMessageDetail(telephone, threadId, callback) {
HiLog.i(TAG, 'queryMessageDetail, start');
let actionData: LooseObject = {};
if (telephone != common.string.EMPTY_STR) {
@ -937,12 +971,12 @@ export default class ConversationController {
if (this.mmsList.length == 0 && this.isDraft) {
HiLog.i(TAG, 'queryMessageDetail, isNewMsg = true');
this.isNewMsg = true;
return;
}
} else {
HiLog.w(TAG, 'queryMessageDetail, failed');
}
this.deleteDraftData();
callback();
});
}
@ -982,6 +1016,7 @@ export default class ConversationController {
for (let item of result.response) {
item.timeMillisecond = parseInt(item.timeMillisecond);
dateUtil.convertTimeStampToDateWeek(item, false);
this.setDateShow(item, resultList);
dateUtil.convertDateFormatForItem(item, false);
if (item.sendStatus == common.int.SEND_DRAFT) {
this.dealDraftData(item);
@ -1069,7 +1104,6 @@ export default class ConversationController {
this.isDraft = true;
this.draftContent = item.content;
this.draftGroupId = item.groupId;
this.receiveContactValue = this.strContactsNumber
this.setDraft();
if (item.isMsm) {
this.isEditMms = true;
@ -1115,8 +1149,8 @@ export default class ConversationController {
}
// 设置发送状态
setCanSendMsgStatus() {
if (this.receiveContactValue == common.string.EMPTY_STR && this.selectContacts && this.selectContacts.length == 0) {
HiLog.d(TAG, 'setCanSendMsgStatus: ' + this.canSendMessage)
if (this.receiveContactValue == common.string.EMPTY_STR && this.selectContacts.length == 0) {
HiLog.d(TAG, 'setCanSendMsgStatus: ' + this.canSendMessage);
this.canSendMessage = false;
}
}
@ -1147,6 +1181,7 @@ export default class ConversationController {
return;
} else {
this.canSendMessage = this.haveSimCard && !this.isFlightMode;
HiLog.i(TAG, 'setSmsTip, canSendMessage=' + this.canSendMessage + ', haveSimCard=' + this.haveSimCard);
}
if (this.isNewMsg) {
this.setCanSendMsgStatus();
@ -1330,10 +1365,21 @@ export default class ConversationController {
item.msgShowType = this.getMsgShowType(item);
item.mmsSource = this.getMmsSource();
item.isMsm = this.isEditMms;
this.setDateShow(item, this.mmsList);
this.mmsList.push(item);
this.refresh = !this.refresh
}
// 判断每条短信上方的时间是否显示
setDateShow(item, list) {
item.dateShow = true;
let tempDateId = item.date.id;
let tempWeekId = item.week.id;
if (list.length > 0) {
item.dateShow =
(tempDateId != (list[list.length-1]).date.id)
&& (tempWeekId != (list[list.length-1]).week.id)
}
}
getMmsSource() {
HiLog.i(TAG, 'getMmsSource, start')
let sources = [];
@ -1594,8 +1640,15 @@ export default class ConversationController {
// 新建状态切换到会话状态
if (this.isNewMsg) {
HiLog.i(TAG, 'send, isNewMsg=true');
this.newSend();
this.newSend(() => {
this.sendDataRefresh();
});
} else {
this.sendDataRefresh();
}
}
sendDataRefresh() {
this.isSendStatus = true;
// 发送文本
if (this.textValue != common.string.EMPTY_STR || this.mmsEditList.length != 0 ||
@ -1619,6 +1672,7 @@ export default class ConversationController {
this.distanceBottomFlag = false;
this.receiveContactValue = common.string.EMPTY_STR;
this.selectContacts = [];
this.isNewMsg = false;
}
isPhoneNumber(str) {
@ -1628,14 +1682,14 @@ export default class ConversationController {
return pattern.test(str);
}
newSend() {
newSend(callback) {
// 先校验输入的内容是否有值
if (this.receiveContactValue != common.string.EMPTY_STR) {
if (!this.isPhoneNumber(this.receiveContactValue)) {
// 无效收件人
this.showToast($r('app.string.invalid_receive', this.receiveContactValue))
HiLog.w(TAG, 'newSend, PhoneNumber is invalidate');
// return;
return;
}
}
if (this.selectContacts.length > 0 && this.receiveContactValue != common.string.EMPTY_STR) {
@ -1661,15 +1715,15 @@ export default class ConversationController {
// 如果设置取消发送直接设置为true
if (this.recallMessagesFlag) {
this.isNewRecallMessagesFlag = true;
this.paramContact.isNewRecallMessagesFlag = true;
this.commonCtrl.paramContact.isNewRecallMessagesFlag = true;
}
// 当新建页面全屏跳转过来,需要获取下列表数据
if (true) {
this.queryOldMessageList(this.strContactsNumber);
this.queryOldMessageList(this.strContactsNumber, callback);
}
}
queryOldMessageList(telephone) {
queryOldMessageList(telephone, callback) {
HiLog.i(TAG, 'queryOldMessageList, start');
if (telephone == common.string.EMPTY_STR) {
return;
@ -1679,9 +1733,10 @@ export default class ConversationController {
HiLog.i(TAG, 'queryOldMessageList, querySessionByTelephone res.response.id: ' + res.response.id)
if (res.code == common.int.SUCCESS && res.response.id > 0) {
this.threadId = res.response.id;
this.queryMessageDetail(telephone, res.response.id);
this.queryMessageDetail(telephone, res.response.id, callback);
} else {
this.threadId = 0;
callback();
}
});
}
@ -1841,7 +1896,7 @@ export default class ConversationController {
HiLog.i(TAG, 'subscriberCallBack, start');
// 接收短信更新
setTimeout(() => {
this.queryMessageDetail(this.strContactsNumber, this.threadId);
this.queryMessageDetail(this.strContactsNumber, this.threadId, () => {});
let valueBucket = {
'unread_count': 0,
};
@ -1850,7 +1905,7 @@ export default class ConversationController {
hasRead: 0,
valueBucket: valueBucket
};
notificationService.cancelMessageNotify(actionData, res => {
NotificationService.getInstance().cancelMessageNotify(actionData, res => {
actionData.hasRead = 1;
conversationListService.markAllAsRead(actionData);
});
@ -2123,7 +2178,7 @@ export default class ConversationController {
}
// 判断字符串是否包含中文
checkChinese(str) {
return escape(str).indexOf('%u') != -1;
return true;
}
getTime(nS) {
@ -2135,18 +2190,59 @@ export default class ConversationController {
}
// 新建页面,返回的联系人数据
setReceiveContactValue(e) {
this.receiveContactValue = e.contactValue;
this.setCanSendMessage(this.receiveContactValue)
setReceiveContactValue(receiverData) {
let selectContacts = receiverData.selectContacts;
let receiveContactValue = selectContacts.length > 0 ? common.string.EMPTY_STR : receiverData.contactValue;
let hasBlur = receiverData.hasBlur;
let telephone = common.string.EMPTY_STR;
this.setCanSendMessage(selectContacts, receiveContactValue)
if (hasBlur && receiveContactValue != common.string.EMPTY_STR) {
let index = -1;
for (let i = 0; i < selectContacts.length; i++) {
let contact = selectContacts[i];
if(contact.telephone == receiveContactValue) {
index = i;
break;
}
}
if(index >= 0) {
selectContacts.splice(index, 1);
}
}
if(receiveContactValue != common.string.EMPTY_STR) {
this.receiveContactValue = receiveContactValue;
} else {
this.receiveContactValue = common.string.EMPTY_STR;
}
if(selectContacts.length > 0) {
this.selectContacts = selectContacts;
} else {
this.selectContacts = [];
}
if (this.selectContacts.length > 0) {
for (let element of this.selectContacts) {
telephone += element.telephone + common.string.COMMA;
}
}
if(this.receiveContactValue != common.string.EMPTY_STR) {
telephone += this.receiveContactValue + common.string.COMMA;
}
if (telephone != common.string.EMPTY_STR) {
telephone = telephone.substring(0, telephone.length - 1);
}
this.initSendTip();
if (!hasBlur && telephone != "") {
this.queryOldMessageList(telephone, null);
}
}
setCanSendMessage(/*selectContacts, */receiveContactValue) {
setCanSendMessage(selectContacts, receiveContactValue) {
if (this.textValue != common.string.EMPTY_STR || this.isEditMms) {
if (this.canSendMessage) {
if (/*selectContacts.length == 0 && */receiveContactValue == common.string.EMPTY_STR) {
if (selectContacts.length == 0 && receiveContactValue == common.string.EMPTY_STR) {
this.canSendMessage = false;
}
} else if ((/*selectContacts.length != 0 || */receiveContactValue != common.string.EMPTY_STR)
} else if ((selectContacts.length != 0 || receiveContactValue != common.string.EMPTY_STR)
&& this.haveSimCard) {
this.canSendMessage = true;
}

View File

@ -12,351 +12,381 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import prompt from '@system.prompt';
import router from '@system.router';
import ConListController from './conversationListController'
import common from '../../data/commonData'
import {DeleteDialog} from '../../views/MmsDialogs';
import {MmsListItem} from '../../views/MmsListItem';
import {SearchResultPage} from './SearchResultPage';
import LooseObject from '../../data/LooseObject';
import router from "@system.router";
import ConListController from "./conversationListController";
import DeviceUtil from "../../utils/DeviceUtil";
import { DeleteDialog } from "../../views/MmsDialogs";
import { MmsListItem } from "../../views/MmsListItem";
import { MmsMenu } from "../../views/MmsMenu";
@Entry
@Component
struct ConversationList {
@StorageLink('ConListController') mConListCtrl: ConListController = ConListController.getInstance();
delDialogController: CustomDialogController = new CustomDialogController({
builder: DeleteDialog({
cancel: () => {
this.mConListCtrl.deleteDialogCancel()
},
confirm: () => {
this.mConListCtrl.deleteDialogConfirm()
},
msg: this.mConListCtrl.strMsgDeleteDialogTip,
hasLockMsg: this.mConListCtrl.hasLockMsg,
setSelectLock: () => {
this.mConListCtrl.setSelectLock()
},
isSelectLockMsg: this.mConListCtrl.isSelectLockMsg,
setSelectLockChange: (isOn: boolean) => {
this.mConListCtrl.setSelectLockChange(isOn)
}
}),
autoCancel: false,
alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: '-20vp' }
})
@State isSMSReceiving: boolean = false
@State smsReceiving: boolean = false
build() {
Column() {
Row() {
Image($rawfile('icon/ic_cancel_black.svg')).height('24vp').width('24vp')
.onClick(() => {
this.mConListCtrl.onBackPress()
})
.visibility(this.mConListCtrl.isMultipleSelectState
? Visibility.Visible : Visibility.None)
Blank()
Image($rawfile('icon/add_2.svg'))
.width($r('app.float.icon_side_length_medium'))
.height($r('app.float.icon_side_length_medium'))
.onClick(() => {
// 跳转新建短信界面
router.push(
{
uri: 'pages/conversation/conversation',
params: {
isNewMsg: true
}
})
}).visibility(this.mConListCtrl.isMultipleSelectState
? Visibility.Hidden : Visibility.Visible)
Image($rawfile('icon/ic_public_more.svg'))
.width($r('app.float.icon_side_length_medium'))
.height($r('app.float.icon_side_length_medium'))
.onClick(() => {
})
.visibility(this.mConListCtrl.isMultipleSelectState
? Visibility.Hidden : Visibility.Visible)
.margin({ right: $r('app.float.action_bar_space'), left: $r('app.float.action_bar_space') })
.bindMenu([
{ //this.mConListCtrl.messageList.length == 0
// @ts-ignore
value: $r("app.string.delete"),
action: () => {
this.mConListCtrl.isMultipleSelectState = true
this.mConListCtrl.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN)
}
@StorageLink('ConListController') mConListCtrl: ConListController = ConListController.getInstance();
@State isSMSReceiving: boolean = false;
@State smsReceiving: boolean = false;
@State gridColumns: number = DeviceUtil.isTablet() ? 12 : 4;
@State gridSizeType: SizeType = DeviceUtil.isTablet() ? SizeType.LG : SizeType.SM;
@State gridGutter: string = '24vp';
@State gridMargin: string = '24vp';
private dialogAlignment: DialogAlignment = DeviceUtil.isTablet() ? DialogAlignment.Center : DialogAlignment.Bottom;
private dialogOffset: Offset = DeviceUtil.isTablet() ? { dx: 0, dy: 0 } : { dx: 0, dy: -12 };
delDialogController: CustomDialogController = new CustomDialogController({
builder: DeleteDialog({
cancel: () => {
this.mConListCtrl.deleteDialogCancel()
},
{
// @ts-ignore
value: $r("app.string.favorites"),
action: () => {
this.mConListCtrl.jumpToFavoritesPage();
}
confirm: () => {
this.mConListCtrl.deleteDialogConfirm()
},
{
// @ts-ignore
value: $r("app.string.blocked"),
action: () => {
}
msg: this.mConListCtrl.strMsgDeleteDialogTip,
hasLockMsg: this.mConListCtrl.hasLockMsg,
setSelectLock: () => {
this.mConListCtrl.setSelectLock()
},
{
// @ts-ignore
value: $r("app.string.markAllAsRead"),
action: () => {
this.mConListCtrl.clickToMarkAllAsRead()
}
},
{
// @ts-ignore
value: $r("app.string.settings"),
action: () => {
this.mConListCtrl.jumpToSettingsPage()
}
},
])
}
.width('100%')
.height($r('app.float.action_bar_height'))
.padding({ left: $r('app.float.settings_item_padding_left') })
Row() {
Text($r("app.string.messages"))
.fontSize($r('app.float.list_title_font_size_large'))
.fontColor('#182431')
.fontWeight(FontWeight.Bold)
.visibility(this.mConListCtrl.isMultipleSelectState
? Visibility.None : Visibility.Visible)
Text(this.mConListCtrl.conversationSelectedNumber === 0 ?
$r("app.string.msg_unselected_tip") : $r("app.string.msg_selected_tip", this.mConListCtrl.conversationSelectedNumber))
.fontSize('30fp')
.fontColor(Color.Black)
.visibility(this.mConListCtrl.isMultipleSelectState
? Visibility.Visible : Visibility.None)
}
.width('100%')
.height('56vp')
.padding({ left: '24vp' })
if (this.mConListCtrl.messageList.length != 0) {
//搜索框
// @ts-ignore
Search({ value: this.mConListCtrl.inputValueOfSearch, placeholder: $r("app.string.search2") })
.visibility(Visibility.None)
.height('40vp')
.border({ radius: '20vp' })
// .focusable(this.mInfoMsgCtrl.isSearchFocusable)
.enabled(!this.mConListCtrl.isMultipleSelectState)
.margin({ left: '24vp', right: '24vp', top: '8vp', bottom: '8vp' })
.backgroundColor($r("app.color.search_input_background"))
// .onChange((value: string) => {
//// this.mConListCtrl.clickToSearch(value);
// })
// .onTouch((event: TouchEvent) => {
// if (event.type === TouchType.Down) {
//// this.mConListCtrl.searchTouchStart(true, event)
// }
// })
}
Column() {
List() {
if (this.mConListCtrl.hasAggregate && this.mConListCtrl.showInfoDivWhenSearchFlag
&& this.mConListCtrl.isSearchStatus) {
ListItem() {
Column() {
Row() {
if (this.mConListCtrl.unreadTotalOfInfo <= 0) {
Image($rawfile('icon/entrance_icon01.svg'))
.clip(Circle)
.width('40vp')
.height('40vp')
} else {
Badge({
count: this.mConListCtrl.unreadTotalOfInfo,
maxCount: 99,
style: { color: 0xFFFFFF, fontSize: '10', badgeSize: '16', badgeColor: Color.Red }
}) {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile('icon/entrance_icon01.svg'))
.clip(Circle)
.width('40vp')
.height('40vp')
}.width('100%')
.height('100%')
}.width('40vp').height('40vp')
}
Column() {
Row() {
Text($r("app.string.infoMessages"))
.fontSize('16fp')
.fontColor(Color.Black)
Blank()
if (this.mConListCtrl.unreadTotalOfInfo > 0) {
Text(this.mConListCtrl.unreadTotalOfInfo + '')
.fontSize('12fp')
.fontColor(Color.Black)
.height('64vp')
.width('64vp')
}
}.width('100%')
.height('100%')
.margin({ left: '4vp' })
if (this.mConListCtrl.messageList.length > 0) {
Divider().vertical(false).color(Color.Black).height('1vp')
}
}.layoutWeight(1)
.height('100%')
.padding({ left: '12vp' })
}.height('64vp')
.width('100%')
.padding({ left: '24vp', right: '24vp' })
.onClick(() => {
this.mConListCtrl.clickToInfoMessages()
})
}
isSelectLockMsg: this.mConListCtrl.isSelectLockMsg,
setSelectLockChange: (isOn: boolean) => {
this.mConListCtrl.setSelectLockChange(isOn)
}
}
ForEach(this.mConListCtrl.messageList, (item: any, index: number) => {
ListItem() {
MmsListItem({
item: item,
index: index,
isShowHead: this.mConListCtrl.isShowContactHeadIcon,
isMultipleSelectState: this.mConListCtrl.isMultipleSelectState,
onClickHead: (event: ClickEvent) => {
this.mConListCtrl.clickToGroupDetail(index);
},
onClickBody: (event: ClickEvent) => {
this.mConListCtrl.clickInfoToConversation(index);
},
onItemLongPress: (event: GestureEvent) => {
this.mConListCtrl.conversationLongPress(index);
},
onTouchStart: (event: GestureEvent) => {
this.mConListCtrl.touchStart(event, index);
},
onTouchUpdate: (event: GestureEvent) => {
this.mConListCtrl.touchMove(event, index);
},
onTouchEnd: (event: GestureEvent) => {
this.mConListCtrl.touchEnd(event, index);
},
onClickFirstSlipBtn: (event: ClickEvent) => { //已读
this.mConListCtrl.markAllAsReadByIndex(index);
},
onClickSecondSlipBtn: (event: ClickEvent) => { //删除
this.mConListCtrl.deleteAction(index);
this.delDialogController.open();
}
})
}.width('100%')
.height('64vp')
}, (item: any) => item.threadId.toString())
}),
autoCancel: false,
alignment: this.dialogAlignment,
offset: this.dialogOffset
})
private menuItems: Array<any> = [
{
value: $r("app.string.delete"),
action: () => {
this.mConListCtrl.showMultipleSelectView();
},
enabled: true
}, {
value: $r("app.string.markAllAsRead"),
action: () => {
this.mConListCtrl.clickToMarkAllAsRead();
},
enabled: true
}, {
value: $r("app.string.settings"),
action: () => {
this.mConListCtrl.jumpToSettingsPage();
},
enabled: true
}
.visibility(Visibility.Visible)
.edgeEffect(EdgeEffect.Spring)
.width('100%')
.align(Alignment.Top)
}.layoutWeight(1)
];
/*底部全选删除按钮*/
Row() {
Column() {
Image($rawfile('icon/ic_delete_m.svg')).height(20).width(20)
Text($r("app.string.delete")).fontSize(10).fontColor(Color.Black)
}.layoutWeight(1).onClick(() => {
this.mConListCtrl.clickConversationDelete()
this.delDialogController.open()
}).enabled(!(this.mConListCtrl.conversationSelectedNumber === 0))
.opacity(this.mConListCtrl.conversationSelectedNumber == 0 ? 0.5 : 1)
/**
* 当用户点击返回按钮时触发,仅@Entry修饰的自定义组件生效。
* 返回true表示页面自己处理返回逻辑, 不进行页面路由。
* 返回false表示使用默认的返回逻辑。
* 不返回值会作为false处理。
*/
onBackPress() {
return this.mConListCtrl.onBackPress();
}
Column() {
Image(this.mConListCtrl.isConversationCheckAll ?
$rawfile('icon/ic_select_all_filled.svg') : $rawfile('icon/ic_select_all.svg'))
.height(20).width(20)
Text(this.mConListCtrl.isConversationCheckAll ? $r("app.string.msg_deselect_all")
: $r("app.string.msg_select_all")).fontSize(10)
.fontColor(this.mConListCtrl.isConversationCheckAll ? Color.Blue : Color.Black)
}.layoutWeight(1).onClick(() => {
this.mConListCtrl.clickConversationCheckAll()
})
}.width('100%')
.height(45)
.backgroundColor($r("app.color.white"))
.visibility(this.mConListCtrl.isMultipleSelectState
? Visibility.Visible : Visibility.None)
build() {
GridContainer({
columns: this.gridColumns,
sizeType: this.gridSizeType,
gutter: this.gridGutter,
margin: this.gridMargin
}) {
Stack() {
if (this.mConListCtrl.hasNoMessage && !(this.mConListCtrl.hasAggregate && this.mConListCtrl.showInfoDivWhenSearchFlag
&& this.mConListCtrl.isSearchStatus)) {
EmptyView()
}
if (this.mConListCtrl.messageList.length == 0 && !(this.mConListCtrl.hasAggregate && this.mConListCtrl.showInfoDivWhenSearchFlag
&& this.mConListCtrl.isSearchStatus)) {
EmptyView()
}
Flex({
justifyContent: FlexAlign.SpaceBetween,
alignItems: ItemAlign.Center,
direction: FlexDirection.Column
}) {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Start} ) {
Column() {
Row() {
if (!this.mConListCtrl.isMultipleSelectState) {
Blank()
Image($rawfile('icon/ic_public_add.svg'))
.width($r('app.float.icon_side_length_medium'))
.height($r('app.float.icon_side_length_medium'))
.onClick(() => {
// 跳转新建短信界面
router.push(
{
uri: 'pages/conversation/conversation',
params: {
isNewMsg: true
}
})
})
Column() {
MmsMenu({
menuItems: this.menuItems,
sizeType: this.gridSizeType
})
}
.margin({ left: $r('app.float.action_bar_space') })
} else {
Image($rawfile('icon/ic_public_cancel.svg')).height('24vp').width('24vp')
.onClick(() => {
this.mConListCtrl.onBackPress()
})
Text(this.mConListCtrl.conversationSelectedNumber === 0 ?
$r("app.string.msg_unselected_tip") : $r("app.string.msg_selected_tip", this.mConListCtrl.conversationSelectedNumber))
.fontSize('20fp')
.fontWeight(FontWeight.Bold)
.fontColor(Color.Black)
.margin({ left: 16 })
}
}
.width('100%')
.height($r('app.float.action_bar_height'))
Column() {
if (!this.mConListCtrl.isMultipleSelectState) {
Row() {
Text($r("app.string.messages"))
.fontSize($r('app.float.list_title_font_size_large'))
.fontColor('#182431')
.fontWeight(FontWeight.Bold)
.lineHeight(41)
}
}
if (this.mConListCtrl.messageList.length != 0) {
//搜索框
// @ts-ignore
Search({
value: this.mConListCtrl.inputValueOfSearch,
placeholder: "搜索信息"
})
.visibility(Visibility.None)
.height('40vp')
.border({ radius: '20vp' })
// .focusable(this.mInfoMsgCtrl.isSearchFocusable)
.enabled(!this.mConListCtrl.isMultipleSelectState)
.margin({ left: '24vp', right: '24vp', top: '8vp', bottom: '8vp' })
.backgroundColor($r("app.color.search_input_background"))
// .onChange((value: string) => {
//// this.mConListCtrl.clickToSearch(value);
// })
// .onTouch((event: TouchEvent) => {
// if (event.type === TouchType.Down) {
//// this.mConListCtrl.searchTouchStart(true, event)
// }
// })
}
}
}.alignItems(HorizontalAlign.Start)
List() {
if (this.mConListCtrl.hasAggregate && this.mConListCtrl.showInfoDivWhenSearchFlag
&& this.mConListCtrl.isSearchStatus) {
ListItem() {
Column() {
Row() {
if (this.mConListCtrl.unreadTotalOfInfo <= 0) {
Image($rawfile('icon/entrance_icon01.svg'))
.width('40vp')
.height('40vp')
} else {
Badge({
count: this.mConListCtrl.unreadTotalOfInfo,
maxCount: 99,
style: {
color: 0xFFFFFF,
fontSize: '10',
badgeSize: '16',
badgeColor: Color.Red
}
}) {
Flex({
justifyContent: FlexAlign.Center,
alignItems: ItemAlign.Center
}) {
Image($rawfile('icon/entrance_icon01.svg'))
.width('40vp')
.height('40vp')
}.width('100%')
.height('100%')
}.width('40vp').height('40vp')
}
Column() {
Row() {
Text($r("app.string.infoMessages"))
.fontSize('16fp')
.fontColor(Color.Black)
Blank()
if (this.mConListCtrl.unreadTotalOfInfo > 0) {
Text(this.mConListCtrl.unreadTotalOfInfo + '')
.fontSize('12fp')
.fontColor(Color.Black)
.height('64vp')
.width('64vp')
}
}.width('100%')
.height('100%')
.margin({ left: '4vp' })
if (this.mConListCtrl.messageList.length > 0) {
Divider()
.vertical(false)
.color($r("app.color.divider_color"))
.height('1vp')
}
}.layoutWeight(1)
.height('100%')
.padding({ left: '12vp' })
}.height('64vp')
.width('100%')
.onClick(() => {
this.mConListCtrl.clickToInfoMessages()
})
}
}
}
LazyForEach(this.mConListCtrl.conversationListDataSource, (item: any, index: number) => {
ListItem() {
MmsListItem({
item: item,
index: index,
isShowHead: this.mConListCtrl.isShowContactHeadIcon,
isMultipleSelectState: this.mConListCtrl.isMultipleSelectState,
onClickHead: (event: ClickEvent) => {
this.mConListCtrl.clickToGroupDetail(item.index);
},
onClickBody: (event: ClickEvent) => {
this.mConListCtrl.clickInfoToConversation(item.index);
},
onItemLongPress: (event: GestureEvent) => {
this.mConListCtrl.conversationLongPress(item.index);
},
onTouchStart: (event: GestureEvent) => {
this.mConListCtrl.touchStart(event, item.index);
},
onTouchUpdate: (event: GestureEvent) => {
this.mConListCtrl.touchMove(event, item.index);
},
onTouchEnd: (event: GestureEvent) => {
this.mConListCtrl.touchEnd(event, item.index);
},
onClickFirstSlipBtn: (event: ClickEvent) => { //已读
this.mConListCtrl.markAllAsReadByIndex(item.index);
},
onClickSecondSlipBtn: (event: ClickEvent) => { //删除
this.mConListCtrl.deleteAction(item.index);
this.delDialogController.open();
}
})
}.width('100%')
.height('64vp')
}, (item: any) => item.threadId.toString())
}
.edgeEffect(EdgeEffect.Spring)
.width('100%')
.align(Alignment.Top)
}
.width("100%")
/*底部全选删除按钮*/
Row() {
Column() {
Image($rawfile('icon/ic_delete_m.svg')).height(20).width(20)
Text($r("app.string.delete")).fontSize(10).fontColor(Color.Black)
}.layoutWeight(1).onClick(() => {
this.mConListCtrl.clickConversationDelete()
this.delDialogController.open()
}).enabled(!(this.mConListCtrl.conversationSelectedNumber === 0))
.opacity(this.mConListCtrl.conversationSelectedNumber == 0 ? 0.5 : 1)
Column() {
Image(this.mConListCtrl.isConversationCheckAll ?
$rawfile('icon/ic_select_all_filled.svg') : $rawfile('icon/ic_select_all.svg'))
.height(20).width(20)
Text(this.mConListCtrl.isConversationCheckAll ? $r("app.string.msg_deselect_all")
: $r("app.string.msg_select_all"))
.fontSize(10)
.fontColor(this.mConListCtrl.isConversationCheckAll ? $r("app.color.control_activated_color") : $r('app.color.main_font_color'))
}.layoutWeight(1).onClick(() => {
this.mConListCtrl.clickConversationCheckAll()
})
}.width('100%')
.height(45)
.backgroundColor($r("app.color.white"))
.visibility(this.mConListCtrl.isMultipleSelectState
? Visibility.Visible : Visibility.None)
}
.width('100%')
.height('100%')
.useSizeType({
xs: { span: 4, offset: 0 }, sm: { span: 4, offset: 0 },
md: { span: 12, offset: 0 }, lg: { span: 12, offset: 0 }
})
.onKeyEvent((event: KeyEvent) => {
if (event.keyCode === 4 && event.keyText === 'Back') { //返回按钮
if (this.mConListCtrl.deleteDialogShow) {
this.delDialogController.close()
this.mConListCtrl.deleteDialogShow = false
event.stopPropagation()
return
}
if (this.mConListCtrl.isMultipleSelectState) {
// @ts-ignore
for (let element of this.mConListCtrl.messageList) {
element.isCbChecked = false;
}
this.mConListCtrl.isMultipleSelectState = false;
event.stopPropagation()
}
if (!this.mConListCtrl.isSearchStatus) {
this.mConListCtrl.backSearch();
event.stopPropagation()
}
}
})
}
}
}
.width('100%')
.height('100%')
.onKeyEvent((event: KeyEvent) => {
if (event.keyCode === 4 && event.keyText === 'Back') { //返回按钮
if (this.mConListCtrl.deleteDialogShow) {
this.delDialogController.close()
this.mConListCtrl.deleteDialogShow = false
event.stopPropagation()
return
}
if (this.mConListCtrl.isMultipleSelectState) {
// @ts-ignore
for (let element of this.mConListCtrl.messageList) {
element.isCbChecked = false;
}
this.mConListCtrl.isMultipleSelectState = false;
event.stopPropagation()
}
if (!this.mConListCtrl.isSearchStatus) {
this.mConListCtrl.backSearch();
event.stopPropagation()
}
}
})
}
aboutToAppear() {
}
aboutToAppear() {
}
aboutToDisappear() {
}
aboutToDisappear() {
}
onPageShow() {
this.mConListCtrl.onShow();
}
onPageShow() {
this.mConListCtrl.onShow();
}
onPageHide() {
this.mConListCtrl.unSubscribe();
onPageHide() {
this.mConListCtrl.unSubscribe();
}
}
}
@Component
struct EmptyView {
build() {
Column() {
Image($rawfile('icon/ic_massage_m.svg'))
.width('160vp')
.height('157vp')
Text($r("app.string.noMessages"))
.margin({ top: '9vp' })
}.height('100%')
.padding({ top: $r('app.float.empty_view_top_padding') })
}
build() {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Column() {
Image($rawfile('icon/ic_massage_m.svg'))
.width('160vp')
.height('157vp')
Text($r("app.string.noMessages"))
.margin({ top: '9vp' })
.fontWeight(FontWeight.Regular)
.fontFamily('HarmonyHeiTi')
.fontSize($r('app.float.conversation_list_no_message_fs'))
.fontColor($r('app.color.main_font_color_40'))
}
}
.height('100%')
.width('100%')
}
}

View File

@ -21,11 +21,11 @@ import featureAbility from '@ohos.ability.featureAbility';
import LooseObject from '../../data/LooseObject';
import messageService from '../../service/ConversationListService';
import HiLog from '../../utils/HiLog';
import rdbStore from '../../utils/RdbStoreUtil';
import SettingService from '../../service/SettingService'
import commonService from '../../service/CommonService';
import notificationService from '../../service/NotificationService';
import NotificationService from '../../service/NotificationService';
import AppStorageUtil from '../../utils/AppStorageUtil';
import ConversationListDataSource from '../../model/ConversationListDataSource'
let ConversationCtrl;
@ -34,6 +34,7 @@ let commonEventData = null;
const TAG = 'ConversationListController';
export default class ConversationListController {
hasNoMessage: boolean = false;
svgDelete: string = '';
strCheckBoxSelectTip: Resource;
strMsgDeleteDialogTip: Resource;
@ -124,6 +125,8 @@ export default class ConversationListController {
page: number = 0;
// 列表分页,数量
limit: number = 1000;
// conversation list adapters
conversationListDataSource: ConversationListDataSource = new ConversationListDataSource();
static getInstance() {
if (ConversationCtrl == null) {
@ -148,11 +151,13 @@ export default class ConversationListController {
this.statisticalData();
this.page = 0;
this.messageList = [];
this.conversationListDataSource.refresh(this.messageList);
this.requestItem();
let hasInfoMsg = false;
hasInfoMsg = AppStorageUtil.getHasInfoMsg();
if (!hasInfoMsg && this.messageList.length == 0) {
this.total = 0;
this.hasNoMessage = true;
}
};
@ -427,10 +432,13 @@ export default class ConversationListController {
element.isCbChecked = false;
}
this.isMultipleSelectState = false;
return true;
}
if (!this.isSearchStatus) {
this.backSearch();
return true;
}
return false;
};
deleteDialogConfirm() {
@ -453,7 +461,9 @@ export default class ConversationListController {
this.isMultipleSelectState = false;
this.isSelectLockMsg = false;
this.messageList = mmsList;
this.conversationListDataSource.refresh(this.messageList);
this.total = this.messageList.length;
this.hasNoMessage = this.total == 0 ? true : false;
if (threadIds.length > 0) {
let actionData = {
threadIds: threadIds
@ -513,9 +523,11 @@ export default class ConversationListController {
};
jumpToSettingsPage() {
// 暂时跳转到高级设置且只显示一个送达报告开关
router.push({
uri: 'pages/settings/advancedSettings/advancedSettings'
uri: "pages/settings/settings",
params: {
pageFlag: "settingsDetail",
}
});
};
@ -667,6 +679,7 @@ export default class ConversationListController {
actionData.page = this.page;
actionData.limit = this.limit;
messageService.querySessionList(actionData, result => {
HiLog.i(TAG, "querySessionList code=" + result.code);
if (result.code == common.int.SUCCESS) {
let res = [];
result.response.forEach(item => {
@ -681,7 +694,9 @@ export default class ConversationListController {
res.push(obj);
});
this.messageList = res;
this.conversationListDataSource.refresh(this.messageList);
this.total = result.total;
this.hasNoMessage = this.total == 0 ? true : false;
this.showInfoDivWhenSearchFlag = result.showInfoDivWhenSearchFlag;
}
});
@ -736,6 +751,7 @@ export default class ConversationListController {
}
}
this.messageList = tempMsgList;
this.conversationListDataSource.refresh(this.messageList);
this.unreadTotalOfInfo = this.unreadTotalOfInfo - threadIds.length;
HiLog.i(TAG, 'markAllAsRead, unreadTotalOfInfo=' + this.unreadTotalOfInfo)
};
@ -745,7 +761,7 @@ export default class ConversationListController {
threadIds: threadIds,
hasRead: 0
};
notificationService.cancelMessageNotify(actionData, res => {
NotificationService.getInstance().cancelMessageNotify(actionData, res => {
callback();
});
};
@ -903,4 +919,16 @@ export default class ConversationListController {
});
}
};
checkHasCommonMessage() {
return this.messageList.length > 0;
}
showMultipleSelectView() {
this.resetTouch();
if (this.checkHasCommonMessage()) {
this.isMultipleSelectState = true;
this.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN)
}
}
}

View File

@ -13,15 +13,12 @@
* limitations under the License.
*/
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import appStorage from '../../utils/AppStorageUtil';
import bundle from '@ohos.bundle'
// JS公共常量
import common from '../../data/commonData';
import contactService from '../../service/ContractService';
import conversationListService from '../../service/ConversationListService';
import featureAbility from '@ohos.ability.featureAbility';
import LooseObject from '../../data/LooseObject'
import HiLog from '../../utils/HiLog';
import mmsTable from '../../data/tableData';
import preferences from '../../utils/PreferencesUtil';
@ -39,33 +36,34 @@ export default {
contractParams: null,
onInit() {
let insertPromise = this.verifyPermissions();
insertPromise.then((requestPermissions) => {
if (requestPermissions.length == 0 || requestPermissions == []) {
this.getWant();
} else {
let context = featureAbility.getContext();
context.requestPermissionsFromUser(requestPermissions, 1, (data) => {
if (data.authResults == undefined) {
return;
}
for (let i = 0; i < data.authResults.length; i++) {
if (data.authResults[i] == -1) {
HiLog.i(TAG, 'Application requestPermissionsFromUser failed');
return;
}
}
this.getWant();
});
HiLog.i(TAG, 'Application requestPermissionsFromUser end');
}
}).catch((err) => {
HiLog.e(TAG, 'verifyPermissions, error: ' + JSON.stringify(err.message));
});
this.initPermissions()
// 初始化数据库
this.initRdb();
},
async initPermissions() {
let requestPermissions: Array<string> = [
"ohos.permission.READ_CONTACTS",
"ohos.permission.READ_MESSAGES",
"ohos.permission.SEND_MESSAGES",
"ohos.permission.RECEIVE_SMS"
];
let context = featureAbility.getContext();
context.requestPermissionsFromUser(requestPermissions, 1, (data) => {
if (data.authResults == undefined) {
return;
}
for (let i = 0; i < data.authResults.length; i++) {
if (data.authResults[i] == -1) {
HiLog.i(TAG, 'Application requestPermissionsFromUser failed');
return;
}
}
this.getWant();
});
HiLog.i(TAG, 'Application requestPermissionsFromUser end');
},
onShow() {
this.initStorage();
},
@ -104,7 +102,6 @@ export default {
getWant() {
featureAbility.getWant().then((want) => {
HiLog.i(TAG, 'getWant, want: ' + JSON.stringify(want));
if (want.hasOwnProperty("uri")) {
this.uri = want.uri;
}
@ -129,6 +126,7 @@ export default {
uri: '',
params: ''
};
HiLog.i(TAG, 'want.pageFlag: ' + this.pageFlag);
switch (this.pageFlag) {
case 'conversationList':
result.uri = 'pages/conversationlist/conversationList';
@ -154,6 +152,7 @@ export default {
conversationListService.querySessionByTelephone(this.contractParams.strContactsNumber, res => {
if (res.code == common.int.SUCCESS && res.response.id > 0) {
result.params.threadId = res.response.id;
this.markAllAsRead(result.params.threadId);
} else {
result.params.isNewMsg = true;
}
@ -161,30 +160,14 @@ export default {
});
},
async verifyPermissions() {
let array: Array<string> = [
"ohos.permission.READ_CONTACTS",
"ohos.permission.READ_MESSAGES",
"ohos.permission.SEND_MESSAGES",
"ohos.permission.SET_TELEPHONY_STATE",
"ohos.permission.GET_TELEPHONY_STATE",
"ohos.permission.RECEIVE_SMS",
"ohos.permission.PLACE_CALL"
];
var bundleFlag = 0;
var tokenID = undefined;
var userID = 100;
var appInfo = await bundle.getApplicationInfo('com.ohos.mms', bundleFlag, userID);
tokenID = appInfo.accessTokenId;
var atManager = abilityAccessCtrl.createAtManager();
let requestPermissions: Array<string> = [];
for (let i = 0;i < array.length; i++) {
var result = await atManager.verifyAccessToken(tokenID, array[i]);
if (result != abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
requestPermissions.push(array[i]);
markAllAsRead(threadId) {
let actionData = {
threadIds: [threadId],
hasRead: 1,
valueBucket: {
'unread_count': 0
}
}
return requestPermissions;
};
conversationListService.markAllAsRead(actionData);
}
}

View File

@ -12,15 +12,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import DeviceUtil from "../../utils/DeviceUtil";
import InfoMsgController from "./InfoMsgController";
import { DeleteDialog } from "../../views/MmsDialogs";
import { MmsListItem } from "../../views/MmsListItem";
import { MmsMenu } from "../../views/MmsMenu";
import InfoMsgController from './InfoMsgController'
import {DeleteDialog} from '../../views/MmsDialogs';
import {MmsListItem} from '../../views/MmsListItem';
import common from '../../data/commonData'
@Entry
@Component
export default struct InfoMsg {
@StorageLink('InfoMsgController') mInfoMsgCtrl: InfoMsgController = InfoMsgController.getInstance();
@State gridColumns: number = DeviceUtil.isTablet() ? 12 : 4;
@State gridSizeType: SizeType = DeviceUtil.isTablet() ? SizeType.LG : SizeType.SM;
@State gridGutter: string = "24vp";
@State gridMargin: string = "24vp";
private dialogAlignment: DialogAlignment = DeviceUtil.isTablet() ? DialogAlignment.Center : DialogAlignment.Bottom;
private dialogOffset: Offset = DeviceUtil.isTablet() ? { dx: 0, dy: 0 } : { dx: 0, dy: -12 };
delDialogController: CustomDialogController = new CustomDialogController({
builder: DeleteDialog({
cancel: () => {
@ -40,10 +47,27 @@ export default struct InfoMsg {
}
}),
autoCancel: false,
alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: '-20vp' }
alignment: this.dialogAlignment,
offset: this.dialogOffset
})
private menuItems: Array<any> = [
{
value: $r("app.string.delete"),
action: () => {
this.mInfoMsgCtrl.selectInMoreMenu(1);
},
enabled: true
},
{
value: $r("app.string.blocked"),
action: () => {
this.mInfoMsgCtrl.selectInMoreMenu(2);
},
enabled: true
}
];
/**
* 函数在创建自定义组件的新实例后在执行其build函数之前执行。
* 允许在aboutToAppear函数中改变状态变量这些更改将在后续执行build函数中生效。
@ -89,248 +113,244 @@ export default struct InfoMsg {
}
build() {
//通知信息
Column() {
if (this.mInfoMsgCtrl.isMultipleSelectState) {
//多选状态标题
Flex({ direction: FlexDirection.Column }) {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
Image($rawfile("icon/conversation_select_exit.svg"))
.width('24vp')
.height('24vp')
.onClick(() => {
this.onBackPress()
})
Text(this.mInfoMsgCtrl.conversationSelectedNumber == 0 ? $r('app.string.msg_unselected_tip') :
$r('app.string.msg_selected_tip', this.mInfoMsgCtrl.conversationSelectedNumber))
.padding({ left: '16vp' })
.fontSize('20fp')
.fontWeight(FontWeight.Bold)
GridContainer({ columns: this.gridColumns, sizeType: this.gridSizeType, gutter: this.gridGutter, margin: this.gridMargin }) {
//通知信息
Column() {
if (this.mInfoMsgCtrl.isMultipleSelectState) {
//多选状态标题
Flex({ direction: FlexDirection.Column }) {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
Image($rawfile("icon/ic_public_cancel.svg"))
.width('24vp')
.height('24vp')
.onClick(() => {
this.onBackPress()
})
Text(this.mInfoMsgCtrl.conversationSelectedNumber == 0 ? $r('app.string.msg_unselected_tip') :
$r('app.string.msg_selected_tip', this.mInfoMsgCtrl.conversationSelectedNumber))
.padding({ left: '16vp' })
.fontSize('20fp')
.fontWeight(FontWeight.Bold)
}
.height('56vp')
}
.width('100%')
.height('56vp')
} else if (!this.mInfoMsgCtrl.searchStatus) {
//标题行
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
Image($rawfile("icon/ic_message_back.svg"))
.width('24vp')
.height('24vp')
.onClick(() => {
this.mInfoMsgCtrl.back()
})
Text($r("app.string.infoMessages"))
.padding({ left: '16vp' })
.fontSize('20fp')
.fontWeight(FontWeight.Bold)
}
.height('56vp')
}
.width('100%')
.height('56vp')
}
.width('100%')
.height('56vp')
.padding({ left: '24vp' })
} else if (!this.mInfoMsgCtrl.searchStatus) {
//标题行
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
Row() {
//返回按钮
if (this.mInfoMsgCtrl.isShowSearchBack) {
Image($rawfile("icon/ic_message_back.svg"))
.width('24vp')
.height('24vp')
.onClick(() => {
this.mInfoMsgCtrl.back()
.width(24)
.height(24)
.onClick((event: ClickEvent) => {
this.mInfoMsgCtrl.clickSearchBack();
})
Text($r("app.string.infoMessages"))
.padding({ left: '16vp' })
.fontSize('20fp')
.fontWeight(FontWeight.Bold)
}
.height('56vp')
//搜索框
// @ts-ignore
Search({ value: this.mInfoMsgCtrl.inputValueOfSearch, placeholder: "搜索通知信息" })
.layoutWeight(1)
.height('40vp')
.border({ radius: '20vp' })
// .focusable(this.mInfoMsgCtrl.isSearchFocusable)
.enabled(!this.mInfoMsgCtrl.isMultipleSelectState)
.backgroundColor($r("app.color.search_input_background"))
.onChange((value: string) => {
this.mInfoMsgCtrl.clickToSearch(value);
})
.onSubmit((value: string) => {
this.mInfoMsgCtrl.clickToSearch(value);
})
// .onTouch((event: TouchEvent) => {
// if (event.type === TouchType.Down) {
// this.mInfoMsgCtrl.searchTouchStart(true, event)
// }
// })
}
.visibility(Visibility.None)
.width('100%')
.height('56vp')
.padding({ left: '24vp' })
}
.padding({ left: 24, right: 24 })
.alignItems(VerticalAlign.Center)
Row() {
//返回按钮
if (this.mInfoMsgCtrl.isShowSearchBack) {
Image($rawfile("icon/ic_message_back.svg"))
.width(24)
.height(24)
.onClick((event: ClickEvent) => {
this.mInfoMsgCtrl.clickSearchBack();
})
}
//搜索框
// @ts-ignore
Search({ value: this.mInfoMsgCtrl.inputValueOfSearch, placeholder: $r("app.string.search2") })
.layoutWeight(1)
.height('40vp')
.border({ radius: '20vp' })
// .focusable(this.mInfoMsgCtrl.isSearchFocusable)
.enabled(!this.mInfoMsgCtrl.isMultipleSelectState)
.backgroundColor($r("app.color.search_input_background"))
.onChange((value: string) => {
this.mInfoMsgCtrl.clickToSearch(value);
})
.onSubmit((value: string) => {
this.mInfoMsgCtrl.clickToSearch(value);
})
// .onTouch((event: TouchEvent) => {
// if (event.type === TouchType.Down) {
// this.mInfoMsgCtrl.searchTouchStart(true, event)
// }
// })
}
.visibility(Visibility.None)
.width('100%')
.height('56vp')
.padding({ left: 24, right: 24 })
.alignItems(VerticalAlign.Center)
//短信展示列表
Stack() {
Column() {
List({ initialIndex: 0 }) {
ForEach(this.mInfoMsgCtrl.messageList, (item, index) => {
//真正的信息列表
if (this.mInfoMsgCtrl.isSearchStatus) {
ListItem() {
MmsListItem({
item: item,
index: index,
isShowHead: this.mInfoMsgCtrl.isShowContactHeadIcon,
isMultipleSelectState: this.mInfoMsgCtrl.isMultipleSelectState,
onClickHead: (event: ClickEvent) => {
this.mInfoMsgCtrl.clickToGroupDetail(index);
},
onClickBody: (event: ClickEvent) => {
this.mInfoMsgCtrl.clickInfoToConversation(index);
},
onItemLongPress: (event: GestureEvent) => {
this.mInfoMsgCtrl.conversationLongPress(index)
},
onTouchStart: (event: GestureEvent) => {
this.mInfoMsgCtrl.touchStart(event, index);
},
onTouchUpdate: (event: GestureEvent) => {
this.mInfoMsgCtrl.touchMove(event, index);
},
onTouchEnd: (event: GestureEvent) => {
this.mInfoMsgCtrl.touchEnd(event, index);
},
onClickFirstSlipBtn: (event: ClickEvent) => {
this.mInfoMsgCtrl.markAllAsReadByIndex(index);
},
onClickSecondSlipBtn: (event: ClickEvent) => {
this.mInfoMsgCtrl.deleteAction(index);
this.delDialogController.open();
}
})
//短信展示列表
Stack({ alignContent: Alignment.Top }) {
Column() {
List({ initialIndex: 0 }) {
LazyForEach(this.mInfoMsgCtrl.conversationListDataSource, (item, index) => {
//真正的信息列表
if (this.mInfoMsgCtrl.isSearchStatus) {
ListItem() {
MmsListItem({
item: item,
index: index,
isShowHead: this.mInfoMsgCtrl.isShowContactHeadIcon,
isMultipleSelectState: this.mInfoMsgCtrl.isMultipleSelectState,
onClickHead: (event: ClickEvent) => {
this.mInfoMsgCtrl.clickToGroupDetail(item.index);
},
onClickBody: (event: ClickEvent) => {
this.mInfoMsgCtrl.clickInfoToConversation(item.index);
},
onItemLongPress: (event: GestureEvent) => {
this.mInfoMsgCtrl.conversationLongPress(item.index)
},
onTouchStart: (event: GestureEvent) => {
this.mInfoMsgCtrl.touchStart(event, item.index);
},
onTouchUpdate: (event: GestureEvent) => {
this.mInfoMsgCtrl.touchMove(event, item.index);
},
onTouchEnd: (event: GestureEvent) => {
this.mInfoMsgCtrl.touchEnd(event, item.index);
},
onClickFirstSlipBtn: (event: ClickEvent) => {
this.mInfoMsgCtrl.markAllAsReadByIndex(item.index);
},
onClickSecondSlipBtn: (event: ClickEvent) => {
this.mInfoMsgCtrl.deleteAction(item.index);
this.delDialogController.open();
}
})
}
.width('100%')
.height('64vp')
.alignSelf(ItemAlign.Start)
}
.width('100%')
.height('64vp')
.alignSelf(ItemAlign.Start)
}
}, item => item.threadId)
}, item => item.threadId)
}
.align(Alignment.Top)
.cachedCount(this.mInfoMsgCtrl.limit)
}.width('100%')
//搜索上方
//短信搜索会话item
//左侧头像
//右侧信息等
//上方的name和日期
//下方的信息详情
//中间间隔线
//搜索信息列表 信息条码数量
//搜索信息列表
//左侧头像
//右侧信息等
//上方的name和日期
//下方的信息详情
//如果没有会话信息,也就是{{total}}为0则显示空白图片
//显示搜索状态
if (this.mInfoMsgCtrl.isSearchCoverage) {
//图层用于搜索的展示
Flex()
.width('100%')
.height('100%')
.opacity(0.2)
.backgroundColor(Color.Gray)
.onTouch((event: TouchEvent) => {
if (event.type === TouchType.Down) {
this.mInfoMsgCtrl.searchCoverageClick()
}
})
}
.align(Alignment.Top)
.cachedCount(this.mInfoMsgCtrl.limit)
}.width('100%').height('100%')
//搜索上方
//短信搜索会话item
//左侧头像
//右侧信息等
//上方的name和日期
//下方的信息详情
//中间间隔线
//搜索信息列表 信息条码数量
//搜索信息列表
//左侧头像
//右侧信息等
//上方的name和日期
//下方的信息详情
//如果没有会话信息,也就是{{total}}为0则显示空白图片
//显示搜索状态
if (this.mInfoMsgCtrl.isSearchCoverage) {
//图层用于搜索的展示
Flex()
.width('100%')
.height('100%')
.opacity(0.2)
.backgroundColor(Color.Gray)
.onTouch((event: TouchEvent) => {
if (event.type === TouchType.Down) {
this.mInfoMsgCtrl.searchCoverageClick()
}
.flexGrow(1)
//单个会话长按选项
if (this.mInfoMsgCtrl.isMultipleSelectState) {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
//删除
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile(this.mInfoMsgCtrl.svgDelete))
.width('24vp')
.height('24vp')
.margin({ top: '3vp' })
Text($r("app.string.delete")).fontSize('10fp')
}
.width('50%')
.opacity(this.mInfoMsgCtrl.checkSelectedNumberIsEmpty() ? 0.4 : 1)
.onClick(() => {
if (!this.mInfoMsgCtrl.checkSelectedNumberIsEmpty()) {
this.mInfoMsgCtrl.clickConversationDelete()
this.delDialogController.open()
}
})
//全选
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile(this.mInfoMsgCtrl.isConversationCheckAll ? 'icon/ic_select_all_filled.svg' : 'icon/ic_select_all.svg'))
.width('24vp')
.height('24vp')
.margin({ top: '3vp' })
Text(this.mInfoMsgCtrl.strCheckBoxSelectTip)
.fontSize('10fp')
.fontColor(this.mInfoMsgCtrl.isConversationCheckAll ? '#007DFF' : '#2C2C2C')
}
.width('50%')
.onClick(() => {
this.mInfoMsgCtrl.clickConversationCheckAll()
})
}
.width('100%')
.height('56vp')
.padding({ left: '86vp', right: '86vp' })
}
}
.flexGrow(1)
//单个会话长按选项
if (this.mInfoMsgCtrl.isMultipleSelectState) {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
//删除
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile(this.mInfoMsgCtrl.svgDelete))
.width('24vp')
.height('24vp')
.margin({ top: '3vp' })
Text($r("app.string.delete")).fontSize('10fp')
//全部已读和更多
if (!this.mInfoMsgCtrl.isMultipleSelectState && this.mInfoMsgCtrl.showToolBar) {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
//全部已读
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile('icon/ic_allread.svg'))
.width('24vp')
.height('24vp')
.margin({ top: '3vp' })
Text($r("app.string.markAllAsRead")).fontSize('10fp')
}
.width('50%')
.opacity(this.mInfoMsgCtrl.unreadTotalOfInfo == 0 ? 0.4 : 1)
.onClick(() => {
this.mInfoMsgCtrl.clickToMarkAllAsReadForInfo()
})
//更多
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
MmsMenu({
menuItems: this.menuItems,
sizeType: this.gridSizeType,
menuText: $r("app.string.more")
})
}
.width('50%')
}
.width('50%')
.opacity(this.mInfoMsgCtrl.conversationSelectedNumber == 0 ? 0.5 : 1)
.onClick(() => {
this.mInfoMsgCtrl.clickConversationDelete()
this.delDialogController.open()
})
//全选
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile(this.mInfoMsgCtrl.isConversationCheckAll ? 'icon/ic_select_all_filled.svg' : 'icon/ic_select_all.svg'))
.width('24vp')
.height('24vp')
.margin({ top: '3vp' })
Text(this.mInfoMsgCtrl.strCheckBoxSelectTip)
.fontSize('10fp')
.fontColor(this.mInfoMsgCtrl.isConversationCheckAll ? '#007DFF' : '#2C2C2C')
}
.width('50%')
.onClick(() => {
this.mInfoMsgCtrl.clickConversationCheckAll()
})
.width('100%')
.height('56vp')
.padding({ left: '86vp', right: '86vp' })
}
.width('100%')
.height('56vp')
.padding({ left: '86vp', right: '86vp' })
//设置导航栏显示背景
//删除弹出对话框
}
//全部已读和更多
if (!this.mInfoMsgCtrl.isMultipleSelectState && this.mInfoMsgCtrl.showToolBar) {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
//全部已读
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile('icon/ic_allread.svg'))
.width('24vp')
.height('24vp')
.margin({ top: '3vp' })
Text($r("app.string.markAllAsRead")).fontSize('10fp')
}
.width('50%')
.opacity(this.mInfoMsgCtrl.unreadTotalOfInfo == 0 ? 0.5 : 1)
.onClick(() => {
this.mInfoMsgCtrl.clickToMarkAllAsReadForInfo()
})
//更多
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile('icon/ic_more_24x24.svg')).width('24vp').height('24vp')
.margin({ top: '3vp' })
Text($r("app.string.more")).fontSize('10fp')
}
.width('50%')
.bindMenu([{
// @ts-ignore
value: $r("app.string.delete"),
action: () => {
this.mInfoMsgCtrl.selectInMoreMenu(1)
}
}, {
// @ts-ignore
value: $r("app.string.blocked"),
action: () => {
this.mInfoMsgCtrl.selectInMoreMenu(2)
}
},])
}
.width('100%')
.height('56vp')
.padding({ left: '86vp', right: '86vp' })
}
//设置导航栏显示背景
//删除弹出对话框
.width('100%')
.height('100%')
.useSizeType({
xs: { span: 4, offset: 0 }, sm: { span: 4, offset: 0 },
md: { span: 12, offset: 0 }, lg: { span: 12, offset: 0 }
})
}
.width('100%')
.height('100%')
}
}

View File

@ -23,11 +23,13 @@ import LooseObject from '../../data/LooseObject'
import messageService from '../../service/ConversationListService';
// log工具类
import HiLog from '../../utils/HiLog';
import notificationService from '../../service/NotificationService';
import NotificationService from '../../service/NotificationService';
// 通知信息
import router from '@system.router';
// 获取设置开关
import settingService from '../../service/SettingService';
import ConversationListDataSource from '../../model/ConversationListDataSource'
const TAG = 'InfoMsgController'
let sInfoMsgCtrl;
@ -109,6 +111,9 @@ export default class InfoMsgController {
page: number = 0;
// 信息总数
totalMessage: number = 0;
// notification conversation list adapters
conversationListDataSource: ConversationListDataSource = new ConversationListDataSource();
static getInstance() {
if (sInfoMsgCtrl == null) {
sInfoMsgCtrl = new InfoMsgController();
@ -142,6 +147,7 @@ export default class InfoMsgController {
HiLog.i(TAG, 'queryAllMessages, Success');
let res = this.buildSessionList(result);
this.messageList = res;
this.conversationListDataSource.refresh(this.messageList);
this.totalMessage = result.total;
this.total = this.messageList.length;
if (this.totalMessage === this.total) {
@ -499,7 +505,7 @@ export default class InfoMsgController {
threadIds: threadIds,
hasRead: 0
};
notificationService.cancelMessageNotify(actionData, res => {
NotificationService.getInstance().cancelMessageNotify(actionData, res => {
callback();
});
}
@ -522,6 +528,7 @@ export default class InfoMsgController {
}
}
this.messageList = tempMsgList;
this.conversationListDataSource.refresh(this.messageList);
this.unreadTotalOfInfo = this.unreadTotalOfInfo - threadIds.length;
}
selectInMoreMenu(menuId: number) {
@ -549,6 +556,9 @@ export default class InfoMsgController {
}
this.hasLockMsg = (this.messageList.some((element, index) => element.isCbChecked && element.isLock));
}
checkSelectedNumberIsEmpty() {
return this.conversationSelectedNumber == common.int.MESSAGE_CODE_ZERO
}
// 取消弹出
deleteDialogCancel() {
if (this.isSelectLockMsg) {
@ -583,6 +593,7 @@ export default class InfoMsgController {
this.showToolBar = true;
this.isSelectLockMsg = false;
this.messageList = mmsList;
this.conversationListDataSource.refresh(this.messageList);
this.total = mmsList.length;
if (this.total == 0) {
router.back();

View File

@ -29,6 +29,8 @@ export default class QueryReportController {
sendStatus: number = 0;
// 时间
mmsTime: Resource;
// 具体上下午时间
specificTime: Resource;
// 时间戳
timeMillisecond: string = '0';
// 手机号
@ -68,6 +70,6 @@ export default class QueryReportController {
};
dealTime() {
this.mmsTime = dateUtil.convertTimeStampDate(this.timeMillisecond);
HiLog.i(TAG, 'dealTime mmsTime=' + this.mmsTime)
this.specificTime = dateUtil.convertTimeStampTime(this.timeMillisecond, false)
}
}

View File

@ -12,13 +12,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
import QueryReportController from './queryReportController'
import DeviceUtil from "../../utils/DeviceUtil";
import router from "@system.router";
import QueryReportController from "./queryReportController";
@Entry
@Component
struct Query_report {
@StorageLink('QueryReportController') queryReportController: QueryReportController = QueryReportController.getInstance();
@State columns: number = DeviceUtil.isTablet() ? 12 : 4;
@State sizeType: SizeType = DeviceUtil.isTablet() ? SizeType.LG : SizeType.SM;
@State gutter: string = "24vp";
@State margin: string = "24vp";
private onPageShow(): void {
this.queryReportController.onShow()
@ -30,57 +35,71 @@ struct Query_report {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
Row() {
Image($rawfile('icon/ic_message_back.svg'))
.width(24)
.height(24)
.onClick(() => {
router.back()
})
Text($r("app.string.send_reports"))
.margin({ left: 16 })
.fontSize(20)
.fontWeight(FontWeight.Bold)
.lineHeight(28)
}
.alignItems(VerticalAlign.Center)
.width('100%')
.height(56)
.backgroundColor('#F0F0F0')
.padding({ left: 24, right: 24 })
Column() {
Text() {
Span($r("app.string.putAddresser")).fontSize(16)
Span(this.queryReportController.telephone).fontSize(16)
GridContainer({
columns: this.columns,
sizeType: this.sizeType,
gutter: this.gutter,
margin: this.margin
}) {
Row() {
Image($rawfile('icon/ic_message_back.svg'))
.width(24)
.height(24)
.onClick(() => {
router.back()
})
Text($r("app.string.send_reports"))
.margin({ left: 16 })
.fontSize(20)
.fontWeight(FontWeight.Bold)
.lineHeight(28)
}
.fontSize(16)
.height(48)
.fontWeight(FontWeight.Medium)
.lineHeight(22)
.alignItems(VerticalAlign.Center)
.height(56)
.useSizeType({
xs: { span: 4, offset: 0 }, sm: { span: 4, offset: 0 },
md: { span: 12, offset: 0 }, lg: { span: 12, offset: 0 }
})
Text() {
Span($r("app.string.Status")).fontSize(16)
Span(this.queryReportController.sendStatusDesc).fontSize(16)
}
.fontSize(16)
.height(48)
.fontWeight(FontWeight.Medium)
.lineHeight(22)
if (!this.queryReportController.isMsm && this.queryReportController.sendStatus != 2) {
Column() {
Text() {
Span($r("app.string.Delivered")).fontSize(16)
Span(this.queryReportController.mmsTime).fontSize(16)
Span($r("app.string.putAddresser")).fontSize(16)
Span(this.queryReportController.telephone).fontSize(16)
}
.fontSize(16)
.height(48)
.fontWeight(FontWeight.Medium)
.lineHeight(22)
Text() {
Span($r("app.string.Status")).fontSize(16)
Span(this.queryReportController.sendStatusDesc).fontSize(16)
}
.fontSize(16)
.height(48)
.fontWeight(FontWeight.Medium)
.lineHeight(22)
if (!this.queryReportController.isMsm && this.queryReportController.sendStatus != 2) {
Text() {
Span($r("app.string.Delivered")).fontSize(16)
Span(this.queryReportController.mmsTime).fontSize(16)
Span(' ')
Span(this.queryReportController.specificTime).fontSize(16)
}
.fontSize(16)
.height(48)
.fontWeight(FontWeight.Medium)
.lineHeight(22)
}
}
.alignItems(HorizontalAlign.Start)
.padding({ left: 12, right: 12 })
.useSizeType({
xs: { span: 4, offset: 0 }, sm: { span: 4, offset: 0 },
md: { span: 12, offset: 0 }, lg: { span: 12, offset: 0 }
})
}
.alignItems(HorizontalAlign.Start)
.padding({ left: 36, right: 36 })
}
.width('100%')
.height('100%')

View File

@ -12,247 +12,234 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaquery from '@ohos.mediaquery'
import router from '@system.router';
import AdvancedSettingsController from './advancedSettingsController'
import common from '../../../data/commonData'
import {RestoreDialogs} from '../../../views/MmsDialogs'
import {SettingItemSwitch, SettingItemJump} from '../../../views/SettingItem'
let portraitFunc = null
import AdvancedSettingsController from "./advancedSettingsController";
import DeviceUtil from "../../../utils/DeviceUtil";
import { MmsSimpleDialog } from '../../../views/MmsDialogs';
import { MmsMenu } from "../../../views/MmsMenu";
import router from "@system.router";
import { SettingItemJump } from "../../../views/SettingItem";
@Entry
@Component
struct AdvancedSettings {
@StorageLink('AdvancedSettingsController') mAdvancedSettingsCtrl: AdvancedSettingsController = AdvancedSettingsController.getInstance();
@State gridColumns: number = 12;
@State gridSizeType: SizeType = SizeType.LG;
@State gridGutter: string = '12vp';
@State gridMargin: string = '12vp';
@State mAdvancedSettingsCtrl: AdvancedSettingsController = AdvancedSettingsController.getInstance();
@State gridColumns: number = DeviceUtil.isTablet() ? 12 : 4;
@State gridSizeType: SizeType = DeviceUtil.isTablet() ? SizeType.LG : SizeType.SM;
@State gridGutter: string = "12vp";
@State gridMargin: string = "12vp";
dialogAlignment: DialogAlignment = DeviceUtil.isTablet() ? DialogAlignment.Center : DialogAlignment.Bottom;
dialogOffset: Offset = DeviceUtil.isTablet() ? { dx: 0, dy: 0 } : { dx: 0, dy: -12 };
private restoreDialog = new MmsSimpleDialog({
message: $r("app.string.restore_all_default_settings"),
primaryButton: {
value: $r("app.string.cancel"),
action: () => {
}
},
secondaryButton: {
value: $r("app.string.restore"),
action: () => {
this.mAdvancedSettingsCtrl.restoreSettingPageSwitchValue();
}
}
});
private menuItems: Array<any> = [
{
value: $r("app.string.restore_default_settings"),
action: () => {
this.restoreDialog.show();
},
enabled: true
}
];
deliveryReportsDialogCtrl: CustomDialogController = new CustomDialogController({
builder: DeliveryReportsDialog({
cancel: () => {
this.mAdvancedSettingsCtrl.cancelRestore();
},
confirm: (isOnOfSms: boolean, isOnOfMms: boolean) => {
this.mAdvancedSettingsCtrl.setRestore(isOnOfSms, isOnOfMms);
},
isOnOfSms: this.mAdvancedSettingsCtrl.checkedValueOfSms,
isOnOfMms: this.mAdvancedSettingsCtrl.checkedValueOfMms
}),
autoCancel: false,
alignment: this.dialogAlignment,
offset: this.dialogOffset
})
listener = mediaquery.matchMediaSync('(orientation: landscape)');
onPortrait(mediaQueryResult) {
if (mediaQueryResult.matches) {
console.log("mediaQuery landScape")
} else {
console.log("mediaQuery vert")
this.gridColumns = 4;
this.gridSizeType = SizeType.SM;
this.gridGutter = '20vp';
this.gridMargin = '20vp';
/**
* 函数在创建自定义组件的新实例后在执行其build函数之前执行。
* 允许在aboutToAppear函数中改变状态变量这些更改将在后续执行build函数中生效。
*/
aboutToAppear() {
this.mAdvancedSettingsCtrl.onInit();
}
/**
* 当此页面显示时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。
*/
onPageShow() {
this.mAdvancedSettingsCtrl.onShow()
}
/**
* 当此页面消失时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。
*/
onPageHide() {
}
/**
* 函数在自定义组件析构消耗之前执行。
* 不允许在aboutToDisappear函数中改变状态变量特别是@Link变量的修改可能会导致应用程序行为不稳定。
*/
aboutToDisappear() {
}
/**
* 当用户点击返回按钮时触发,,仅@Entry修饰的自定义组件生效。
* 返回true表示页面自己处理返回逻辑, 不进行页面路由。
* 返回false表示使用默认的返回逻辑。
* 不返回值会作为false处理。
*/
onBackPress() {
}
}
restoreDialogCtrl : CustomDialogController = new CustomDialogController({
builder : RestoreDialogs({
cancel : () => {
},
confirm : () => {
this.mAdvancedSettingsCtrl.restoreSettingPageSwitchValue();
},
msg : $r("app.string.restore_all_default_settings"),
}),
autoCancel: false,
alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: '-20vp' }
})
deliveryReportsDialogCtrl : CustomDialogController = new CustomDialogController({
builder : DeliveryReportsDialog({
cancel : () => {
this.mAdvancedSettingsCtrl.cancelRestore();
},
confirm : () => {
this.mAdvancedSettingsCtrl.setRestore();
},
ctrl : $mAdvancedSettingsCtrl
}),
autoCancel: false,
alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: '-20vp' }
})
/**
* 函数在创建自定义组件的新实例后在执行其build函数之前执行。
* 允许在aboutToAppear函数中改变状态变量这些更改将在后续执行build函数中生效。
*/
aboutToAppear() {
this.mAdvancedSettingsCtrl.onInit();
this.onPortrait(this.listener)
portraitFunc = this.onPortrait.bind(this)
this.listener.on('change', portraitFunc)
}
/**
* 当此页面显示时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。
*/
onPageShow() {
this.mAdvancedSettingsCtrl.onShow()
}
/**
* 当此页面消失时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。
*/
onPageHide() {
}
/**
* 函数在自定义组件析构消耗之前执行。
* 不允许在aboutToDisappear函数中改变状态变量特别是@Link变量的修改可能会导致应用程序行为不稳定。
*/
aboutToDisappear() {
}
/**
* 当用户点击返回按钮时触发,,仅@Entry修饰的自定义组件生效。
* 返回true表示页面自己处理返回逻辑, 不进行页面路由。
* 返回false表示使用默认的返回逻辑。
* 不返回值会作为false处理。
*/
onBackPress() {}
build() {
Row() {
GridContainer({ columns: this.gridColumns, sizeType: this.gridSizeType, gutter: this.gridGutter, margin: this.gridMargin }) {
// 顶部设备标题
build() {
Row() {
Image($rawfile("icon/ic_message_back.svg"))
.width($r('app.float.icon_side_length_medium'))
.height($r('app.float.icon_side_length_medium'))
.margin({ left: $r('app.float.action_bar_margin_left'), right: $r('app.float.action_bar_space') })
.onClick(() => {
router.back()
})
GridContainer({
columns: this.gridColumns,
sizeType: this.gridSizeType,
gutter: this.gridGutter,
margin: this.gridMargin
}) {
// 顶部设备标题
Row() {
Image($rawfile("icon/ic_message_back.svg"))
.width($r('app.float.icon_side_length_medium'))
.height($r('app.float.icon_side_length_medium'))
.margin({
left: $r('app.float.action_bar_margin_left'),
right: $r('app.float.action_bar_space')
})
.onClick(() => {
router.back()
})
Text($r("app.string.advanced"))
.fontSize($r('app.float.action_bar_text_size'))
.fontColor(Color.Black)
.fontWeight(FontWeight.Bold)
Text($r("app.string.advanced"))
.fontSize($r('app.float.action_bar_text_size'))
.fontColor(Color.Black)
.fontWeight(FontWeight.Bold)
Blank()
Blank()
Image($rawfile("icon/ic_public_more.svg"))
.width($r('app.float.icon_side_length_medium'))
.height($r('app.float.icon_side_length_medium'))
.margin({ left: $r('app.float.action_bar_space'), right: $r('app.float.action_bar_margin_right') })
.bindMenu([
{
// @ts-ignore
value : $r('app.string.restore_default_settings'),
action : () => {
this.restoreDialogCtrl.open()
Column() {
MmsMenu({
menuItems: this.menuItems,
sizeType: this.gridSizeType
})
}
.margin({ left: $r('app.float.action_bar_space'), right: $r('app.float.action_bar_margin_right') })
}
}
])
.width('100%')
.height($r('app.float.action_bar_height'))
.useSizeType({
xs: { span: 12, offset: 0 },
sm: { span: 4, offset: 0 },
md: { span: 12, offset: 0 },
lg: { span: 12, offset: 0 }
})
// 所有设置项
Column({ space: 12 }) {
// 第一组设置项
Column() {
// 送达报告
SettingItemJump({
primaryTitle: $r("app.string.delivery_reports"),
secondaryTitle: $r("app.string.delivery_reports_hint"),
statusTitle: this.mAdvancedSettingsCtrl.deliveryReportSwitchInText,
showBottomDivider: false,
onClick: (event?: ClickEvent) => {
this.deliveryReportsDialogCtrl.open();
}
})
// 自动下载彩信
SettingItemJump({
primaryTitle: $r("app.string.auto_retrieve_mms"),
statusTitle: this.mAdvancedSettingsCtrl.autoRetrieveMmsSwitchInText,
visibility: Visibility.None,
onClick: (event?: ClickEvent) => {
this.mAdvancedSettingsCtrl.showAutoRetrieveMmsDialog();
}
})
}
.width('100%')
.padding({
top: $r('app.float.settings_item_padding_top'),
bottom: $r('app.float.settings_item_padding_bottom'),
left: $r('app.float.settings_item_padding_left'),
right: $r('app.float.settings_item_padding_right')
})
.border({ radius: $r('app.float.settings_items_radius'), color: $r("app.color.white") })
.backgroundColor($r("app.color.white"))
// 第二组设置项
Column() {
}
.width('100%')
.padding({
top: $r('app.float.settings_item_padding_top'),
bottom: $r('app.float.settings_item_padding_bottom'),
left: $r('app.float.settings_item_padding_left'),
right: $r('app.float.settings_item_padding_right')
})
.border({ radius: $r('app.float.settings_items_radius'), color: $r("app.color.white") })
.backgroundColor($r("app.color.white"))
.visibility(Visibility.None)
// 第三组设置项
Column() {
// 短信中心
SettingItemJump({
primaryTitle: $r("app.string.sms_center"),
showBottomDivider: true,
onClick: (event?: ClickEvent) => {
this.mAdvancedSettingsCtrl.jumpToSmsCenterPage(1);
}
})
// 管理SIM卡中的信息
SettingItemJump({
primaryTitle: $r("app.string.manage_sim_card_messages"),
onClick: (event?: ClickEvent) => {
this.mAdvancedSettingsCtrl.jumpToManageSimPage(1);
}
})
}
.width('100%')
.padding({
top: $r('app.float.settings_item_padding_top'),
bottom: $r('app.float.settings_item_padding_bottom'),
left: $r('app.float.settings_item_padding_left'),
right: $r('app.float.settings_item_padding_right')
})
.border({ radius: $r('app.float.settings_items_radius'), color: $r("app.color.white") })
.backgroundColor($r("app.color.white"))
.visibility(Visibility.None)
}
.margin({
top: $r('app.float.settings_items_margin_top'),
bottom: $r('app.float.settings_items_margin_bottom')
})
.useSizeType({
xs: { span: 8, offset: 2 },
sm: { span: 4, offset: 0 },
md: { span: 8, offset: 2 },
lg: { span: 8, offset: 2 }
})
}
.height('100%')
}
.width('100%')
.height($r('app.float.action_bar_height'))
.useSizeType({
xs: { span: 12, offset: 0 },
sm: { span: 4, offset: 0 },
md: { span: 12, offset: 0 },
lg: { span: 12, offset: 0 }
})
// 所有设置项
Column({space: 12}) {
// 第一组设置项
Column() {
// 送达报告
SettingItemJump({
primaryTitle : $r("app.string.delivery_reports"),
secondaryTitle : $r("app.string.delivery_reports_hint"),
statusTitle : this.mAdvancedSettingsCtrl.deliveryReportSwitchInText,
showBottomDivider: true,
onClick : (event?: ClickEvent) => {
this.deliveryReportsDialogCtrl.open();
}
})
// 自动下载彩信
}
.width('100%')
.padding({
top: $r('app.float.settings_item_padding_top'),
bottom: $r('app.float.settings_item_padding_bottom'),
left: $r('app.float.settings_item_padding_left'),
right: $r('app.float.settings_item_padding_right')
})
.border({ radius: $r('app.float.settings_items_radius'), color: $r("app.color.white") })
.backgroundColor($r("app.color.white"))
// 第二组设置项
Column() {
// 取消发送
SettingItemSwitch({
primaryTitle: $r('app.string.recall_messages'),
secondaryTitle: $r('app.string.recall_messages_hint'),
isEnable: this.mAdvancedSettingsCtrl.recallMessageSwitch == common.bool.TRUE ? true : false,
showBottomDivider: true,
onChange: (isOn: boolean) => {
this.mAdvancedSettingsCtrl.recallMsg(this);
}
})
// 自动删除通知信息
SettingItemSwitch({
primaryTitle: $r('app.string.auto_delete_info_messages'),
secondaryTitle: $r('app.string.auto_delete_info_messages_hint'),
isEnable: this.mAdvancedSettingsCtrl.tempAutoDeleteInfoSwitch == common.bool.TRUE ? true : false,
onChange: (isOn: boolean) => {
this.mAdvancedSettingsCtrl.autoDeleteInfo(this);
}
})
}
.width('100%')
.padding({
top: $r('app.float.settings_item_padding_top'),
bottom: $r('app.float.settings_item_padding_bottom'),
left: $r('app.float.settings_item_padding_left'),
right: $r('app.float.settings_item_padding_right')
})
.visibility(Visibility.None)
.border({ radius: $r('app.float.settings_items_radius'), color: $r("app.color.white") })
.backgroundColor($r("app.color.white"))
// 第三组设置项
Column() {
// 短信中心
SettingItemJump({
primaryTitle : $r("app.string.sms_center"),
showBottomDivider: true,
onClick : (event?: ClickEvent) => {
this.mAdvancedSettingsCtrl.jumpToSmsCenterPage(1);
}
})
// 管理SIM卡中的信息
SettingItemJump({
primaryTitle : $r("app.string.manage_sim_card_messages"),
onClick : (event?: ClickEvent) => {
this.mAdvancedSettingsCtrl.jumpToManageSimPage(1);
}
})
}
.width('100%')
.padding({
top: $r('app.float.settings_item_padding_top'),
bottom: $r('app.float.settings_item_padding_bottom'),
left: $r('app.float.settings_item_padding_left'),
right: $r('app.float.settings_item_padding_right')
})
.visibility(Visibility.None)
.border({ radius: $r('app.float.settings_items_radius'), color: $r("app.color.white") })
.backgroundColor($r("app.color.white"))
}
.margin({top: $r('app.float.settings_items_margin_top'), bottom: $r('app.float.settings_items_margin_bottom')})
.useSizeType({
xs: { span: 8, offset: 2 },
sm: { span: 4, offset: 0 },
md: { span: 8, offset: 2 },
lg: { span: 8, offset: 2 }
})
}
.height('100%')
.height('100%')
.backgroundColor($r("app.color.setting_background"))
}
.width('100%')
.height('100%')
.backgroundColor($r("app.color.default_main_background"))
}
}
/**
@ -260,79 +247,120 @@ struct AdvancedSettings {
*/
@CustomDialog
struct DeliveryReportsDialog {
controller: CustomDialogController
/**
* 取消事件
*/
cancel: () => void
/**
* 确认事件
*/
confirm: () => void
controller: CustomDialogController;
cancel: () => void;
confirm: (isOnOfSms: boolean, isOnOfMms: boolean) => void;
@State isOnOfSms: boolean = false;
@State isOnOfMms: boolean = false;
@Link ctrl: any;
build() {
Column() {
Column() {
Text($r("app.string.delivery_reports"))
.width("100%")
.height(56)
.textAlign(TextAlign.Start)
.fontSize(20)
.fontColor($r("sys.color.ohos_id_color_foreground"))
.lineHeight(28)
.fontWeight(FontWeight.Medium)
.fontFamily("HarmonyHeiTi")
Flex({
direction: FlexDirection.Row,
justifyContent: FlexAlign.SpaceBetween,
alignItems: ItemAlign.Center
}) {
Text($r("app.string.sms"))
.fontSize(16)
.fontColor($r("sys.color.ohos_id_color_foreground"))
.lineHeight(22)
.fontWeight(FontWeight.Medium)
.fontFamily("HarmonyHeiTi")
Toggle({ type: ToggleType.Checkbox, isOn: this.isOnOfSms })
.width(20)
.height(20)
.enabled(false)
}
.width("100%")
.height(48)
.onClick((event: ClickEvent) => {
this.isOnOfSms = !this.isOnOfSms;
})
build() {
Column() {
Text($r('app.string.delivery_reports')).width('100%').margin({ bottom: 8 }).fontSize(16)
.fontColor('#182431').lineHeight(22).fontWeight(FontWeight.Regular).fontFamily('HarmonyHeiTi')
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Text($r('app.string.sms'))
Toggle({ type: ToggleType.Checkbox, isOn: this.ctrl.checkedValueOfSms})
.width('20vp')
.height('20vp')
.enabled(false)
}
.width('100%')
.height('32vp')
.onClick((event: ClickEvent) => {
this.ctrl.clickSmsDiv();
})
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Text($r('app.string.mms'))
Toggle({ type: ToggleType.Checkbox, isOn: this.ctrl.checkedValueOfMms })
.width('20vp')
.height('20vp')
.enabled(false)
}
.width('100%')
.height('32vp')
.onClick((event: ClickEvent) => {
this.ctrl.clickMmsDiv();
})
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {
Button() {
Text($r("app.string.cancel"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor('#007DFF')
.fontWeight(FontWeight.Medium)
.fontFamily('HarmonyHeiTi')
.lineHeight(22)
.onClick(() => {
this.controller.close();
this.cancel();
})
}.backgroundColor($r("app.color.back_Transparent")).layoutWeight(1)
Divider().vertical(true).strokeWidth('2px').height('20vp').color(Color.Gray)
Button() {
Text($r("app.string.ok"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor('#007DFF')
.fontWeight(FontWeight.Medium)
.fontFamily('HarmonyHeiTi')
.lineHeight(22)
.onClick(() => {
this.controller.close();
this.confirm();
})
}.backgroundColor($r("app.color.back_Transparent")).layoutWeight(1)
}
.width('100%')
.height(40)
Divider().vertical(false).strokeWidth(1).width("100%").color($r("app.color.divider_color"))
Flex({
direction: FlexDirection.Row,
justifyContent: FlexAlign.SpaceBetween,
alignItems: ItemAlign.Center
}) {
Text($r("app.string.mms"))
.fontSize(16)
.fontColor($r("sys.color.ohos_id_color_foreground"))
.lineHeight(22)
.fontWeight(FontWeight.Medium)
.fontFamily("HarmonyHeiTi")
Toggle({ type: ToggleType.Checkbox, isOn: this.isOnOfMms })
.width(20)
.height(20)
.enabled(false)
}
.width("100%")
.height(48)
.onClick((event: ClickEvent) => {
this.isOnOfMms = !this.isOnOfMms;
})
Divider().vertical(false).strokeWidth(1).width("100%").color($r("app.color.divider_color"))
}
.padding({ left: 24, right: 24, bottom: 9 })
Flex({
direction: FlexDirection.Row,
justifyContent: FlexAlign.SpaceEvenly,
alignItems: ItemAlign.Center
}) {
Button() {
Text($r("app.string.cancel"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor($r("sys.color.ohos_id_color_activated"))
.fontWeight(FontWeight.Medium)
.fontFamily("HarmonyHeiTi")
.lineHeight(22)
}
.backgroundColor($r("app.color.back_Transparent"))
.layoutWeight(1)
.height(40)
.onClick(() => {
this.controller.close();
this.cancel();
})
Divider().vertical(true).strokeWidth(0.5).height(24).color($r("app.color.divider_color"))
Button() {
Text($r("app.string.ok"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor($r("sys.color.ohos_id_color_activated"))
.fontWeight(FontWeight.Medium)
.fontFamily("HarmonyHeiTi")
.lineHeight(22)
}
.backgroundColor($r("app.color.back_Transparent"))
.layoutWeight(1)
.height(40)
.onClick(() => {
this.controller.close();
this.confirm(this.isOnOfSms, this.isOnOfMms);
})
}
.width('100%')
.height(56)
.padding({ left: 16, right: 16, bottom: 16 })
}
.width(DeviceUtil.isTablet() ? 622 : "100%")
.borderRadius($r("app.float.settings_items_radius"))
.backgroundColor($r("app.color.white"))
}
.width('100%')
.padding( {left: 24, right: 24, top: 24, bottom: 16} )
}
}

View File

@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import appStorage from '../../../utils/AppStorageUtil';
import LooseObject from '../../../data/LooseObject'
import HiLog from '../../../utils/HiLog';
import router from '@system.router';
@ -20,11 +19,10 @@ import prompt from '@system.prompt';
import settingService from '../../../service/SettingService'
import common from '../../../data/commonData';
const TAG = 'AdvancedSettingsController';
let sAdvancedSettingsCtrl;
const TAG = "AdvancedSettingsController";
export default class AdvancedSettingsController {
private static sInstance: AdvancedSettingsController;
// 送达报告短信
checkedValueOfSms: boolean = false;
// 送达报告彩信
@ -55,12 +53,10 @@ export default class AdvancedSettingsController {
secondSpnNameOfTwoSimCard: string = '';
static getInstance() {
sAdvancedSettingsCtrl = appStorage.Link('AdvancedSettingsController');
if (sAdvancedSettingsCtrl == null) {
sAdvancedSettingsCtrl = new AdvancedSettingsController();
appStorage.setAndLink('AdvancedSettingsController', sAdvancedSettingsCtrl);
if (AdvancedSettingsController.sInstance == null) {
AdvancedSettingsController.sInstance = new AdvancedSettingsController();
}
return sAdvancedSettingsCtrl;
return AdvancedSettingsController.sInstance;
}
constructor() {
@ -178,7 +174,9 @@ export default class AdvancedSettingsController {
this.returnDeliveryReportResultInText(this.deliveryReportSwitch);
}
// 送达报告dialog确定
setRestore() {
setRestore(isOnOfSms: boolean, isOnOfMms: boolean) {
this.checkedValueOfSms = isOnOfSms;
this.checkedValueOfMms = isOnOfMms;
this.deliveryReportSwitch = common.string.EMPTY_STR;
if (this.checkedValueOfSms && this.checkedValueOfMms) {
this.deliveryReportSwitch = common.DELIVERY_REPORTS.SMS_AND_MMS;

View File

@ -12,257 +12,231 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaquery from '@ohos.mediaquery'
import DeviceUtil from "../../utils/DeviceUtil";
import { MmsSimpleDialog } from '../../views/MmsDialogs';
import { MmsMenu } from '../../views/MmsMenu';
import router from '@system.router';
import SettingsController from './settingsController'
import {RestoreDialogs} from '../../views/MmsDialogs'
import {SettingItemSwitch, SettingItemJump} from '../../views/SettingItem'
let portraitFunc = null
import { SettingItemSwitch, SettingItemJump } from '../../views/SettingItem';
import SettingsController from './settingsController';
@Entry
@Component
struct Settings {
@StorageLink('SettingsController') mSettingsCtrl : SettingsController = SettingsController.getInstance();
@State gridColumns: number = 12;
@State gridSizeType: SizeType = SizeType.LG;
@State gridGutter: string = '12vp';
@State gridMargin: string = '12vp';
@State isMoreShow: Visibility = Visibility.Visible;
isEnhanceShow: Visibility = Visibility.None;
listener = mediaquery.matchMediaSync('(orientation: landscape)');
@State mSettingsCtrl: SettingsController = SettingsController.getInstance();
@State gridColumns: number = DeviceUtil.isTablet() ? 12 : 4;
@State gridSizeType: SizeType = DeviceUtil.isTablet() ? SizeType.LG : SizeType.SM;
@State gridGutter: string = '12vp';
@State gridMargin: string = '12vp';
isEnhanceShow: Visibility = DeviceUtil.isTablet() ? Visibility.None : Visibility.Visible;
private restoreDialog = new MmsSimpleDialog({
message: $r("app.string.restore_all_default_settings"),
primaryButton: {
value: $r("app.string.cancel"),
action: () => {
}
},
secondaryButton: {
value: $r("app.string.restore"),
action: () => {
this.mSettingsCtrl.restoreSettingsPageSwitchValue();
}
}
});
private menuItems: Array<any> = [
{
value: $r("app.string.restore_default_settings"),
action: () => {
this.restoreDialog.show();
},
enabled: true
}
];
onPortrait(mediaQueryResult) {
if (mediaQueryResult.matches) {
console.log("mediaQuery landScape")
} else {
console.log("mediaQuery vert")
this.gridColumns = 4;
this.gridSizeType = SizeType.SM;
this.gridGutter = '20vp';
this.gridMargin = '20vp';
this.isMoreShow = Visibility.None;
this.isEnhanceShow = Visibility.Visible;
/**
* 函数在创建自定义组件的新实例后在执行其build函数之前执行。
* 允许在aboutToAppear函数中改变状态变量这些更改将在后续执行build函数中生效。
*/
aboutToAppear() {
this.mSettingsCtrl.onInit()
}
}
delDialogController : CustomDialogController = new CustomDialogController({
builder : RestoreDialogs({
cancel : () => {
},
confirm : () => {
this.mSettingsCtrl.restoreSettingsPageSwitchValue()
},
msg : $r("app.string.restore_all_default_settings"),
}),
autoCancel: false,
alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: '-20vp' }
})
/**
* 函数在自定义组件析构消耗之前执行。
* 不允许在aboutToDisappear函数中改变状态变量特别是@Link变量的修改可能会导致应用程序行为不稳定。
*/
aboutToDisappear() {
}
/**
* 函数在创建自定义组件的新实例后在执行其build函数之前执行。
* 允许在aboutToAppear函数中改变状态变量这些更改将在后续执行build函数中生效。
*/
aboutToAppear() {
this.mSettingsCtrl.onInit()
this.onPortrait(this.listener)
portraitFunc = this.onPortrait.bind(this)
this.listener.on('change', portraitFunc)
}
/**
* 函数在自定义组件析构消耗之前执行。
* 不允许在aboutToDisappear函数中改变状态变量特别是@Link变量的修改可能会导致应用程序行为不稳定。
*/
aboutToDisappear() {
}
/**
* 当此页面显示时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。
*/
onPageShow() {
this.mSettingsCtrl.onShow()
}
/**
* 当此页面消失时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。
*/
onPageHide() {
}
/**
* 当用户点击返回按钮时触发,,仅@Entry修饰的自定义组件生效。
* 返回true表示页面自己处理返回逻辑, 不进行页面路由。
* 返回false表示使用默认的返回逻辑。
* 不返回值会作为false处理。
*/
onBackPress() {}
/**
* 当此页面显示时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。
*/
onPageShow() {
this.mSettingsCtrl.onShow()
}
build() {
Row() {
GridContainer({ columns: this.gridColumns, sizeType: this.gridSizeType, gutter: this.gridGutter, margin: this.gridMargin }) {
// 顶部设备标题
/**
* 当此页面消失时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。
*/
onPageHide() {
}
/**
* 当用户点击返回按钮时触发,,仅@Entry修饰的自定义组件生效。
* 返回true表示页面自己处理返回逻辑, 不进行页面路由。
* 返回false表示使用默认的返回逻辑。
* 不返回值会作为false处理。
*/
onBackPress() {
}
build() {
Row() {
Image($rawfile("icon/ic_message_back.svg"))
.width($r('app.float.icon_side_length_medium'))
.height($r('app.float.icon_side_length_medium'))
.margin({ left: $r('app.float.action_bar_margin_left'), right: $r('app.float.action_bar_space') })
.onClick(() => {
router.back()
})
GridContainer({
columns: this.gridColumns,
sizeType: this.gridSizeType,
gutter: this.gridGutter,
margin: this.gridMargin
}) {
// 顶部设备标题
Row() {
Image($rawfile("icon/ic_message_back.svg"))
.width($r('app.float.icon_side_length_medium'))
.height($r('app.float.icon_side_length_medium'))
.margin({
left: $r('app.float.action_bar_margin_left'),
right: $r('app.float.action_bar_space')
})
.onClick(() => {
router.back()
})
Text($r("app.string.settings"))
.fontSize($r('app.float.action_bar_text_size'))
.fontColor(Color.Black)
.fontWeight(FontWeight.Bold)
Text($r("app.string.settings"))
.fontSize($r('app.float.action_bar_text_size'))
.fontColor(Color.Black)
.fontWeight(FontWeight.Bold)
Blank()
Blank()
Image($rawfile("icon/ic_public_more.svg"))
.visibility(this.isMoreShow)
.width($r('app.float.icon_side_length_medium'))
.height($r('app.float.icon_side_length_medium'))
.margin({ left: $r('app.float.action_bar_space'), right: $r('app.float.action_bar_margin_right') })
.bindMenu([
{
// @ts-ignore
value : $r('app.string.restore_default_settings'),
action : () => {
this.delDialogController.open()
Column() {
MmsMenu({
menuItems: this.menuItems,
sizeType: this.gridSizeType
})
}
.margin({ left: $r('app.float.action_bar_space'), right: $r('app.float.action_bar_margin_right') })
}
}
])
.width('100%')
.height($r('app.float.action_bar_height'))
.useSizeType({
xs: { span: 12, offset: 0 },
sm: { span: 4, offset: 0 },
md: { span: 12, offset: 0 },
lg: { span: 12, offset: 0 }
})
// 所有设置项
Column({ space: 12 }) {
// 第一组设置项
Column() {
// 增强信息
SettingItemJump({
primaryTitle: $r("app.string.enhanced_information"),
statusTitle: $r("app.string.enabled"),
visibility: this.isEnhanceShow,
onClick: (event?: ClickEvent) => {
// 跳转增强信息设置页面
}
})
// 智能信息
SettingItemJump({
primaryTitle: $r("app.string.intelligent_information"),
statusTitle: $r("app.string.enabled"),
onClick: (event?: ClickEvent) => {
// 跳转铃声设置页面
}
})
}
.width('100%')
.padding({
top: $r('app.float.settings_item_padding_top'),
bottom: $r('app.float.settings_item_padding_bottom'),
left: $r('app.float.settings_item_padding_left'),
right: $r('app.float.settings_item_padding_right')
})
.border({ radius: $r('app.float.settings_items_radius'), color: $r("app.color.white") })
.backgroundColor($r("app.color.white"))
.visibility(Visibility.None)
// 第二组设置项
Column() {
// 通知信息整合
SettingItemSwitch({
primaryTitle: $r('app.string.archive_info_messages'),
secondaryTitle: $r('app.string.archive_info_messages_hint'),
isEnable: this.mSettingsCtrl.integrationSwitch,
showBottomDivider: false,
onChange: (isOn: boolean) => {
this.mSettingsCtrl.integration(isOn)
}
})
}
.width('100%')
.padding({
top: $r('app.float.settings_item_padding_top'),
bottom: $r('app.float.settings_item_padding_bottom'),
left: $r('app.float.settings_item_padding_left'),
right: $r('app.float.settings_item_padding_right')
})
.border({ radius: $r('app.float.settings_items_radius'), color: $r("app.color.white") })
.backgroundColor($r("app.color.white"))
// 第三组设置项
Column() {
// 信息铃声
SettingItemJump({
primaryTitle: $r("app.string.message_tone"),
showBottomDivider: true,
visibility: Visibility.None,
onClick: (event?: ClickEvent) => {
// 跳转铃声设置页面
this.mSettingsCtrl.jumpToMessageTonePage()
}
})
// 高级
SettingItemJump({
primaryTitle: $r("app.string.advanced"),
onClick: (event?: ClickEvent) => {
// 跳转高级设置界面
this.mSettingsCtrl.advancedSetting()
}
})
}
.width('100%')
.padding({
top: $r('app.float.settings_item_padding_top'),
bottom: $r('app.float.settings_item_padding_bottom'),
left: $r('app.float.settings_item_padding_left'),
right: $r('app.float.settings_item_padding_right')
})
.border({ radius: $r('app.float.settings_items_radius'), color: $r("app.color.white") })
.backgroundColor($r("app.color.white"))
}
.margin({
top: $r('app.float.settings_items_margin_top'),
bottom: $r('app.float.settings_items_margin_bottom')
})
.useSizeType({
xs: { span: 8, offset: 2 },
sm: { span: 4, offset: 0 },
md: { span: 8, offset: 2 },
lg: { span: 8, offset: 2 }
})
}
.height('100%')
}
.width('100%')
.height($r('app.float.action_bar_height'))
.useSizeType({
xs: { span: 12, offset: 0 },
sm: { span: 4, offset: 0 },
md: { span: 12, offset: 0 },
lg: { span: 12, offset: 0 }
})
// 所有设置项
Column({space: 12}) {
// 第一组设置项
Column() {
// 增强信息
SettingItemJump({
primaryTitle: $r("app.string.enhanced_information"),
statusTitle: $r("app.string.enabled"),
isVisible: this.isEnhanceShow,
onClick: (event?: ClickEvent) => {
// 跳转增强信息设置页面
}
})
// 智能信息
SettingItemJump({
primaryTitle : $r("app.string.intelligent_information"),
statusTitle : $r("app.string.enabled"),
onClick : (event?: ClickEvent) => {
// 跳转铃声设置页面
}
})
}
.width('100%')
.padding({
top: $r('app.float.settings_item_padding_top'),
bottom: $r('app.float.settings_item_padding_bottom'),
left: $r('app.float.settings_item_padding_left'),
right: $r('app.float.settings_item_padding_right')
})
.border({ radius: $r('app.float.settings_items_radius'), color: $r("app.color.white") })
.backgroundColor($r("app.color.white"))
// 第二组设置项
Column() {
// 通知信息整合
SettingItemSwitch({
primaryTitle: $r('app.string.archive_info_messages'),
secondaryTitle: $r('app.string.archive_info_messages_hint'),
isEnable: this.mSettingsCtrl.integrationSwitch,
showBottomDivider: true,
onChange: (isOn: boolean) => {
this.mSettingsCtrl.integration(this)
}
})
// 恶意网址识别
SettingItemSwitch({
primaryTitle: $r('app.string.malicious_website_identification'),
secondaryTitle: $r('app.string.malicious_website_identification_hint'),
isEnable: this.mSettingsCtrl.maliciousWebSwitch,
showBottomDivider: true,
onChange: (isOn: boolean) => {
this.mSettingsCtrl.maliciousWeb(this)
}
})
// 验证码安全保护
SettingItemSwitch({
primaryTitle: $r('app.string.verification_code_security'),
secondaryTitle: $r('app.string.verification_code_security_hint'),
isEnable: true,
onChange: (isOn: boolean) => {
}
})
}
.width('100%')
.padding({
top: $r('app.float.settings_item_padding_top'),
bottom: $r('app.float.settings_item_padding_bottom'),
left: $r('app.float.settings_item_padding_left'),
right: $r('app.float.settings_item_padding_right')
})
.border({ radius: $r('app.float.settings_items_radius'), color: $r("app.color.white") })
.backgroundColor($r("app.color.white"))
// 第三组设置项
Column() {
// 信息铃声
SettingItemJump({
primaryTitle : $r("app.string.message_tone"),
showBottomDivider: true,
onClick : (event?: ClickEvent) => {
// 跳转铃声设置页面
this.mSettingsCtrl.jumpToMessageTonePage()
}
})
// 显示联系人头像
SettingItemSwitch({
primaryTitle: $r('app.string.show_contact_profile_pics'),
isEnable: true,
showBottomDivider: true,
onChange: (isOn: boolean) => {
}
})
// 高级
SettingItemJump({
primaryTitle : $r("app.string.advanced"),
onClick : (event?: ClickEvent) => {
// 跳转高级设置界面
this.mSettingsCtrl.advancedSetting()
}
})
}
.width('100%')
.padding({
top: $r('app.float.settings_item_padding_top'),
bottom: $r('app.float.settings_item_padding_bottom'),
left: $r('app.float.settings_item_padding_left'),
right: $r('app.float.settings_item_padding_right')
})
.border({ radius: $r('app.float.settings_items_radius'), color: $r("app.color.white") })
.backgroundColor($r("app.color.white"))
}
.margin({top: $r('app.float.settings_items_margin_top'), bottom: $r('app.float.settings_items_margin_bottom')})
.useSizeType({
xs: { span: 8, offset: 2 },
sm: { span: 4, offset: 0 },
md: { span: 8, offset: 2 },
lg: { span: 8, offset: 2 }
})
}
.height('100%')
.height('100%')
.backgroundColor($r("app.color.setting_background"))
}
.width('100%')
.height('100%')
.backgroundColor($r("app.color.default_main_background"))
}
}

View File

@ -12,33 +12,37 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import appStorage from '../../utils/AppStorageUtil';
import LooseObject from '../../data/LooseObject'
import MmsBoolean from '../../data/MmsBoolean'
import HiLog from '../../utils/HiLog';
import router from '@system.router';
import prompt from '@system.prompt';
// JS公共常量
import common from '../../data/commonData';
import settingService from '../../service/SettingService'
let sSettingsCtrl;
const TAG = "SettingsController";
const TAG = 'SettingsController';
export default class SettingsController{
export default class SettingsController {
private static sInstance: SettingsController;
// 通知信息整合
integrationSwitch: boolean = false;
integrationSwitch: MmsBoolean = new MmsBoolean(true);
// 恶意网站选择
maliciousWebSwitch: boolean = false;
// 验证码安全保护
verificationCodeSwitch: boolean = false;
// 显示联系人头像
showContactSwitch: boolean = false
showContactSwitch: boolean = true
static getInstance() {
if(sSettingsCtrl == null) {
sSettingsCtrl = new SettingsController();
appStorage.setAndLink(TAG, sSettingsCtrl);
if(SettingsController.sInstance == null) {
SettingsController.sInstance = new SettingsController();
}
return sSettingsCtrl;
return SettingsController.sInstance;
}
constructor() {
HiLog.i(TAG, 'constructor, start');
this.getSettingPageSwitchValue();
}
onInit() {
@ -46,28 +50,26 @@ export default class SettingsController{
};
onShow() {
this.getSettingPageSwitchValue();
HiLog.i(TAG, 'onShow, start');
};
// 初始化setting页面的开关
getSettingPageSwitchValue() {
HiLog.i(TAG, 'getSettingPageSwitchValue, start');
settingService.setOnSettingValueListener(this.initializeSettingData);
};
// 初始化setting数据
initializeSettingData(data) {
this.integrationSwitch = data.integrationSwitch;
this.maliciousWebSwitch = data.maliciousWebSwitch;
this.showContactSwitch = data.showContactSwitch;
let that = this;
settingService.setOnSettingValueListener(function (result) {
that.integrationSwitch.value = result.integrationSwitch;
that.maliciousWebSwitch = result.maliciousWebSwitch;
that.showContactSwitch = result.showContactSwitch;
});
};
// 通知信息整合
integration(e) {
integration(isOn: boolean) {
let messageCode = common.route.MESSAGE_CODE_UPDATE_ARCHIVE_INFO_MESSAGES_VALUE;
let actionData: LooseObject = {};
this.integrationSwitch = e.checked;
if(this.integrationSwitch) {
this.integrationSwitch.value = isOn;
if(this.integrationSwitch.value) {
actionData.booleanValue = common.bool.TRUE;
} else {
actionData.booleanValue = common.bool.FALSE;
@ -110,11 +112,12 @@ export default class SettingsController{
// 还原设置页面的默认值
restoreSettingsPageSwitchValue() {
let that = this;
settingService.restoreSwitchValue(function (result) {
if (result.code === common.int.SUCCESS) {
this.integrationSwitch = true;
this.maliciousWebSwitch = false;
this.showContactSwitch = true;
that.integrationSwitch.value = true;
that.maliciousWebSwitch = false;
that.showContactSwitch = true;
HiLog.i(TAG, 'restoreSettingsPageSwitchValue, success');
} else {
HiLog.w(TAG, 'restoreSettingsPageSwitchValue, failed');

View File

@ -16,9 +16,7 @@
import call from '@ohos.telephony.call';
import HiLog from '../utils/HiLog';
import common from '../data/commonData';
interface LooseObject {
[key: string]: any
}
import LooseObject from '../data/LooseObject'
const TAG = 'CallService';
export default {

View File

@ -55,9 +55,11 @@ export default {
let messageList = this.convertSessionList(res[0].response, telephones);
result.total = res[1].total;
result.showInfoDivWhenSearchFlag = res[2];
HiLog.i(TAG, "querySessionList, messageList length=" + messageList.length
+ ", total=" + result.total + ", showInfoDivWhenSearchFlag=" + result.showInfoDivWhenSearchFlag);
this.dealContactsName(telephones, actionData, messageList, sessionList => {
HiLog.i(TAG, 'querySessionList, dealContactsName len=' + sessionList.length);
result.response = sessionList;
HiLog.i(TAG, 'querySessionList, dealContactsName callback');
callback(result);
});
}).catch((err) => {
@ -107,11 +109,13 @@ export default {
dealContactsName(telephones, actionData, sessionLists, callback) {
actionData.telephones = telephones;
if(telephones.length == 0) {
HiLog.w(TAG, 'dealContactsName, has no telephones');
callback(sessionLists);
return;
}
contractService.queryContactDataByTelephone(actionData, contacts => {
if(contacts.length == 0) {
HiLog.w(TAG, 'dealContactsName, has no contacts');
callback(sessionLists);
} else {
// 将结果转换为Map,key:手机号value: 名称
@ -414,6 +418,7 @@ export default {
Promise.all([queryPromise]).then((res) => {
result.code = common.int.SUCCESS;
result.response = res[0].response;
HiLog.i(TAG, "querySessionList SUCCESS. len=" + result.response.length);
callback(result);
}).catch((err) => {
HiLog.e(TAG, 'querySessionByNumberType, error: ' + JSON.stringify(err.message));

View File

@ -12,16 +12,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import wantAgent from '@ohos.wantAgent';
import notify from '@ohos.notification';
import WantAgent from '@ohos.wantAgent';
import Notification from '@ohos.notification';
import common from '../data/commonData';
import HiLog from '../utils/HiLog';
import conversationService from './ConversationService';
const label = 'notification_';
const label = 'notification_';
const TAG = 'NotificationService';
export default {
export default class NotificationService {
private static sInstance: NotificationService;
static getInstance() {
if (NotificationService.sInstance == null) {
NotificationService.sInstance = new NotificationService();
}
return NotificationService.sInstance;
}
constructor() {
HiLog.i(TAG, 'new start');
}
/**
* 发送通知
@ -33,15 +45,14 @@ export default {
let wantAgentInfo = this.buildWantAgentInfo(actionData);
// 构建发送请求
let notificationRequest = this.buildNotificationRequest(actionData);
wantAgentInfo.requestCode = actionData.msgId;
this.getWantAgent(wantAgentInfo, (data) => {
notificationRequest.wantAgent = data;
notificationRequest.id = actionData.msgId;
notificationRequest.label = label + actionData.msgId;
// notify.publish(notificationRequest);
Notification.publish(notificationRequest);
HiLog.i(TAG, 'sendNotify finished');
});
},
}
/**
* 创建需要发送的跳转的Want
@ -50,89 +61,93 @@ export default {
* @return
*/
getWantAgent(agentInfo, callback) {
wantAgent.getWantAgent(agentInfo).then(data1 => {
WantAgent.getWantAgent(agentInfo).then(data1 => {
callback(data1);
});
},
}
/**
* 构建分布式拉起参数
* @param actionData 参数
* @return
*/
buildWantAgentInfo(actionData) {
buildWantAgentInfo(actionData): any {
let parameters = {
pageFlag: '',
contactObjects: ''
pageFlag: "conversation",
contactObjects: actionData.contactObjects
};
parameters.pageFlag = 'conversation';
parameters.contactObjects = actionData.contactObjects;
let wantAgentInfo = {
wants: [
{
deviceId: 'receive',
deviceId: "",
bundleName: common.string.BUNDLE_NAME,
abilityName: common.string.ABILITY_NAME,
entities: [common.string.COMMON_ENTITIES],
type: 'MIMETYPE',
uri: parameters.pageFlag,
parameters: parameters,
action: "mms.event.notification",
entities: [],
type: "MIMETYPE",
uri: ""
}
],
operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0
operationType: WantAgent.OperationType.START_ABILITY,
requestCode: actionData.msgId,
wantAgentFlags: [WantAgent.WantAgentFlags.CONSTANT_FLAG],
extraInfo: parameters
};
return wantAgentInfo;
},
}
/**
* 构建通知参数
* @param actionData 参数
* @return
*/
buildNotificationRequest(actionData) {
buildNotificationRequest(actionData): any {
let message = actionData.message;
let notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: message.title,
text: message.text
},
},
wantAgent: '',
slotType: notify.SlotType.OTHER_TYPES,
deliveryTime: new Date().getTime()
slotType: Notification.SlotType.OTHER_TYPES,
deliveryTime: new Date().getTime(),
groupName: "MMS"
};
return notificationRequest;
},
}
cancelMessageNotify(actionData, callback) {
conversationService.queryMessageDetail(actionData, res => {
if (res.code == common.int.FAILURE || res.response.length == 0) {
callback(common.int.FAILURE);
}
let count = 0;
for(let item of res.response) {
for (let item of res.response) {
this.cancelNotify(parseInt(item.id), result => {
count ++;
count++;
if (count == res.response.length) {
callback(common.int.SUCCESS);
}
});
}
});
},
}
cancelNotify(msgId, callback) {
notify.cancel(msgId, label + msgId, (err, data) => {
Notification.cancel(msgId, label + msgId, (err, data) => {
if (err) {
HiLog.w(TAG, 'cancelNotify, error: ' + JSON.stringify(err.message));
callback(common.int.FAILURE);
}
callback(common.int.SUCCESS);
});
},
}
cancelAllNotify() {
let promise = notify.cancelAll();
let promise = Notification.cancelAll();
promise.then((ret) => {
}).catch((err) => {
HiLog.e(TAG, 'cancelAllNotify, error: ' + JSON.stringify(err.message));

View File

@ -59,7 +59,7 @@ export default {
},
dealSendResult(value) {
let sendStatus = common.int.SEND_MESSAGE_SENDING;
if (value.result == sms.SEND_SMS_SUCCESS) {
if (value.result == sms.SendSmsResult.SEND_SMS_SUCCESS) {
sendStatus = common.int.SEND_MESSAGE_SUCCESS;
} else {
sendStatus = common.int.SEND_MESSAGE_FAILED;

View File

@ -89,7 +89,7 @@ export default {
},
timeTwelveHourSystem(hoursOfSms, minutesOfSmsStr, hoursOfSmsStr) {
let time = common.string.EMPTY_STR;
let time: Resource = null;
if (hoursOfSms <= 12) {
time = this.morningTimeTwelveHourSystem(hoursOfSms, minutesOfSmsStr, hoursOfSmsStr);
} else {
@ -155,13 +155,13 @@ export default {
let monthOfNow = now.getMonth() + 1;
let dayOfNow = now.getDate();
let timeMillisecond = messageItem.timeMillisecond;
messageItem.date = this.convertTimeStampToDate(timeMillisecond, yearOfNow, monthOfNow, dayOfNow);
this.convertTimeStampToDate(messageItem, timeMillisecond, yearOfNow, monthOfNow, dayOfNow);
},
/**
* 把时间戳形式转换为日期形式
*/
convertTimeStampToDate(timeStampFromDb, yearOfNow, monthOfNow, dayOfNow) {
convertTimeStampToDate(messageItem, timeStampFromDb, yearOfNow, monthOfNow, dayOfNow) {
let date: Resource = null;
let sms = new Date(timeStampFromDb);
let yearOfSms = sms.getFullYear();
@ -169,15 +169,16 @@ export default {
let dayOfSms = sms.getDate();
let weekOfSms = sms.getDay();
if (yearOfNow == yearOfSms && monthOfNow == monthOfSms && dayOfNow == dayOfSms) {
date = $r('app.string.recentDateToday', this.getWeek(weekOfSms));
date = $r('app.string.recentDateToday', '');
} else if (yearOfNow == yearOfSms && monthOfNow == monthOfSms && dayOfNow - dayOfSms == 1) {
date = $r('app.string.recentDateYesterday', this.getWeek(weekOfSms));
date = $r('app.string.recentDateYesterday', '');
} else if (yearOfNow == yearOfSms) {
date = $r('app.string.monthDayDate', monthOfSms, dayOfSms, this.getWeek(weekOfSms));
date = $r('app.string.monthDayDate', monthOfSms, dayOfSms, '');
} else {
date = $r('app.string.yearMonthDayDate', yearOfSms, monthOfSms, dayOfSms, this.getWeek(weekOfSms));
date = $r('app.string.yearMonthDayDate', yearOfSms, monthOfSms, dayOfSms, '');
}
return date;
messageItem.date = date;
messageItem.week = this.getWeek(weekOfSms);
},
/**

View File

@ -0,0 +1,44 @@
/**
* Copyright (c) 2022 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 deviceInfo from '@ohos.deviceInfo';
import HiLog from './HiLog';
const TAG = 'DeviceUtil';
export default class DeviceUtil {
private static readonly DEVICE_TYPE = deviceInfo.deviceType;
constructor() {
}
/**
* Querying the Device Type
*
* default智能手机
* tablet平板
* tv智慧屏
* wearable智能穿戴
* liteWearable轻量级智能穿戴
* smartVision智慧视觉设备
*/
static getDeviceType(): string {
HiLog.i(TAG, "deviceType is " + this.DEVICE_TYPE)
return this.DEVICE_TYPE;
}
static isTablet(): boolean{
let deviceType = DeviceUtil.getDeviceType()
return deviceType === "tablet";
}
}

View File

@ -24,7 +24,6 @@
* 5. the function execute many times can not print.
* 6. uniqueness.
*
* @author m00445151
* @since 2022-02-18
*/
export default class HiLog {

View File

@ -19,8 +19,6 @@ import dataStorage from '@ohos.data.storage';
import featureAbility from '@ohos.ability.featureAbility';
const TAG = 'PreferencesUtil';
var prefIns = undefined;
/**
* 获取轻量级偏好数据库实例
*/

View File

@ -12,149 +12,155 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import DeviceUtil from "../utils/DeviceUtil";
/**
* 弹框种类无标题1个消息2个按钮
*/
@CustomDialog
export struct DeleteDialog {
controller: CustomDialogController;
/**
* 取消事件
*/
cancel: () => void;
/**
* 确认事件
*/
confirm: () => void;
/**
* 消息内容
*/
msg: string | Resource;
/**
* 删除的信息中,是否包含锁定的信息
*/
hasLockMsg: boolean;
setSelectLock?: () => void;
/**
* 是否同步删除锁定信息勾选项
*/
isSelectLockMsg?: boolean;
setSelectLockChange?: (isOn: boolean) => void;
build() {
Column() {
Text(this.msg).width('100%').margin({ bottom: 8 }).textAlign(TextAlign.Center).fontSize(16)
.fontColor('#182431').lineHeight(22).fontWeight(FontWeight.Regular).fontFamily('HarmonyHeiTi')
if (this.hasLockMsg) {
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Toggle({ type: ToggleType.Checkbox, isOn: this.isSelectLockMsg })
.width('20vp')
.height('20vp')
.onChange((isOn: boolean) => {
this.setSelectLockChange(isOn)
})
Text($r("app.string.msg_delete_dialog_cb_tip")).height('100%')
}
.width('100%')
.height('32vp')
.onClick((event?: ClickEvent) => {
this.setSelectLock();
})
}
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {
Button() {
Text($r("app.string.cancel"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor('#007DFF')
.fontWeight(FontWeight.Medium)
.fontFamily('HarmonyHeiTi')
.lineHeight(22)
.onClick(() => {
this.controller.close();
this.cancel();
})
}.backgroundColor($r("app.color.back_Transparent")).layoutWeight(1)
Divider().vertical(true).strokeWidth('2px').height('20vp').color(Color.Gray)
Button() {
Text($r("app.string.delete"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor('#FA2A2D')
.fontWeight(FontWeight.Medium)
.fontFamily('HarmonyHeiTi')
.lineHeight(22)
.onClick(() => {
this.controller.close();
this.confirm();
})
}.backgroundColor($r("app.color.back_Transparent")).layoutWeight(1)
}
.width('100%')
.height(40)
}
.width('100%')
.padding( {left: 24, right: 24, top: 24, bottom: 16} )
}
}
/**
* 弹框种类:重置弹框
*/
@CustomDialog
export struct RestoreDialogs {
controller: CustomDialogController
/**
controller: CustomDialogController;
/**
* 取消事件
*/
cancel: () => void
/**
cancel: () => void;
/**
* 确认事件
*/
confirm: () => void
/**
confirm: () => void;
/**
* 消息内容
*/
msg: string | Resource
msg: string | Resource;
/**
* 删除的信息中,是否包含锁定的信息
*/
hasLockMsg: boolean;
setSelectLock?: () => void;
/**
* 是否同步删除锁定信息勾选项
*/
isSelectLockMsg?: boolean;
setSelectLockChange?: (isOn: boolean) => void;
build() {
// Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.End }) {
build() {
Column() {
Text(this.msg)
.width('100%')
.margin({ bottom: 8 })
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor('#182431')
.lineHeight(22)
.fontWeight(FontWeight.Regular)
.fontFamily('HarmonyHeiTi')
if (this.hasLockMsg) {
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Toggle({ type: ToggleType.Checkbox, isOn: this.isSelectLockMsg })
.width('20vp')
.height('20vp')
.onChange((isOn: boolean) => {
this.setSelectLockChange(isOn)
})
Text($r("app.string.msg_delete_dialog_cb_tip")).height('100%')
}
.width('100%')
.height('32vp')
.onClick((event?: ClickEvent) => {
this.setSelectLock();
})
}
Flex({
direction: FlexDirection.Row,
justifyContent: FlexAlign.SpaceEvenly,
alignItems: ItemAlign.Center
}) {
Button() {
Text($r("app.string.cancel"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor('#007DFF')
.fontWeight(FontWeight.Medium)
.fontFamily('HarmonyHeiTi')
.lineHeight(22)
}
.backgroundColor($r("app.color.back_Transparent"))
.layoutWeight(1)
.onClick(() => {
this.controller.close();
this.cancel();
})
Column() {
Text(this.msg).width('100%').margin({ top: '16vp', bottom: '8vp' }).textAlign(TextAlign.Center).fontSize(14)
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {
Text($r("app.string.cancel"))
.fontSize(16)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.fontColor(Color.Blue)
.onClick(() => {
this.controller.close()
this.cancel()
})
Divider().vertical(true).strokeWidth('2px').height('20vp').color(Color.Gray)
Text($r("app.string.restore"))
.fontSize(16)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.fontColor(Color.Blue)
.onClick(() => {
this.controller.close()
this.confirm()
})
}
.margin({ top: '4vp', bottom: '16vp' })
Divider().vertical(true).strokeWidth('2px').height('20vp').color(Color.Gray)
Button() {
Text($r("app.string.delete"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor('#FA2A2D')
.fontWeight(FontWeight.Medium)
.fontFamily('HarmonyHeiTi')
.lineHeight(22)
}
.backgroundColor($r("app.color.back_Transparent"))
.layoutWeight(1)
.onClick(() => {
this.controller.close();
this.confirm();
})
}
.width('100%')
.height(40)
}
.width('100%')
.padding({ left: 24, right: 24, top: 24, bottom: 16 })
}
.width('100%')
.padding('8vp')
}
}
export class MmsSimpleDialog {
value: AlertDialogParamWithMms;
private dialogAlignment: DialogAlignment = DeviceUtil.isTablet() ? DialogAlignment.Center : DialogAlignment.Bottom;
private dialogOffset: Offset = DeviceUtil.isTablet() ? { dx: 0, dy: 0 } : { dx: 0, dy: -12 };
constructor(value: AlertDialogParamWithMms) {
this.value = value;
}
show() {
AlertDialog.show(
{
message: this.value.message,
autoCancel: false,
alignment: this.dialogAlignment,
offset: this.dialogOffset,
primaryButton: {
value: this.value.primaryButton.value,
action: this.value.primaryButton.action
},
secondaryButton: {
value: this.value.secondaryButton.value,
action: this.value.secondaryButton.action,
fontColor: $r("sys.color.ohos_id_color_handup")
}
}
)
}
}
declare interface AlertDialogParamWithMms {
message: ResourceStr;
primaryButton: {
value: ResourceStr;
action: () => void;
};
secondaryButton: {
value: ResourceStr;
action: () => void;
};
}
export interface CheckBoxItem {
title: string | Resource;
isOn: boolean;
onClick: (event?: ClickEvent) => void;
title: string | Resource;
isOn: boolean;
onClick: (event?: ClickEvent) => void;
}
/**
@ -162,77 +168,92 @@ export interface CheckBoxItem {
*/
@CustomDialog
export struct CheckBoxDialog {
controller: CustomDialogController;
/**
* 取消事件
*/
cancel: () => void;
/**
* 确认事件
*/
confirm: () => void;
/**
* 标题
*/
title: string | Resource;
controller: CustomDialogController;
/**
* 取消事件
*/
cancel: () => void;
/**
* 确认事件
*/
confirm: () => void;
/**
* 标题
*/
title: string | Resource;
/**
* 选项集合
*/
@State itemList: Array<CheckBoxItem> = [];
/**
* 选项集合
*/
@State itemList: Array<CheckBoxItem> = [];
build() {
Column() {
// dialog标题
Text(this.title).width('100%').margin({ bottom: 8 }).fontSize(16)
.fontColor('#182431').lineHeight(22).fontWeight(FontWeight.Regular).fontFamily('HarmonyHeiTi')
// item勾选列表
ForEach(this.itemList, (item, index) => {
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Text(item.title)
Toggle({ type: ToggleType.Checkbox, isOn: item.isOn})
.width('20vp')
.height('20vp')
.enabled(false)
build() {
Column() {
// dialog标题
Text(this.title)
.width('100%')
.margin({ bottom: 8 })
.fontSize(16)
.fontColor('#182431')
.lineHeight(22)
.fontWeight(FontWeight.Regular)
.fontFamily('HarmonyHeiTi')
// item勾选列表
ForEach(this.itemList, (item, index) => {
Flex({
direction: FlexDirection.Row,
justifyContent: FlexAlign.SpaceBetween,
alignItems: ItemAlign.Center
}) {
Text(item.title)
Toggle({ type: ToggleType.Checkbox, isOn: item.isOn })
.width('20vp')
.height('20vp')
.enabled(false)
}
.width('100%')
.height('32vp')
.onClick(item.onClick)
}, (item, index) => index.toString())
// 确定和取消按钮
Flex({
direction: FlexDirection.Row,
justifyContent: FlexAlign.SpaceEvenly,
alignItems: ItemAlign.Center
}) {
Button() {
Text($r("app.string.cancel"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor('#007DFF')
.fontWeight(FontWeight.Medium)
.fontFamily('HarmonyHeiTi')
.lineHeight(22)
.onClick(() => {
this.controller.close();
this.cancel();
})
}.backgroundColor($r("app.color.back_Transparent")).layoutWeight(1)
Divider().vertical(true).strokeWidth('2px').height('20vp').color(Color.Gray)
Button() {
Text($r("app.string.ok"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor('#007DFF')
.fontWeight(FontWeight.Medium)
.fontFamily('HarmonyHeiTi')
.lineHeight(22)
.onClick(() => {
this.controller.close();
this.confirm();
})
}.backgroundColor($r("app.color.back_Transparent")).layoutWeight(1)
}
.width('100%')
.height(40)
}
.width('100%')
.height('32vp')
.onClick(item.onClick)
}, (item, index) => index.toString())
// 确定和取消按钮
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {
Button() {
Text($r("app.string.cancel"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor('#007DFF')
.fontWeight(FontWeight.Medium)
.fontFamily('HarmonyHeiTi')
.lineHeight(22)
.onClick(() => {
this.controller.close();
this.cancel();
})
}.backgroundColor($r("app.color.back_Transparent")).layoutWeight(1)
Divider().vertical(true).strokeWidth('2px').height('20vp').color(Color.Gray)
Button() {
Text($r("app.string.ok"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor('#007DFF')
.fontWeight(FontWeight.Medium)
.fontFamily('HarmonyHeiTi')
.lineHeight(22)
.onClick(() => {
this.controller.close();
this.confirm();
})
}.backgroundColor($r("app.color.back_Transparent")).layoutWeight(1)
}
.width('100%')
.height(40)
.padding({ left: 24, right: 24, top: 24, bottom: 16 })
}
.width('100%')
.padding( {left: 24, right: 24, top: 24, bottom: 16} )
}
}

View File

@ -36,24 +36,23 @@ export struct MmsListItem {
//头像
if (this.isShowHead) {
//是否需要加未读标志红点
if (this.item.countOfUnread > 0) {
Badge({
count: this.item.countOfUnread,
maxCount: 99,
style: { color: 0xFFFFFF, fontSize: '10fp', badgeSize: '16vp', badgeColor: Color.Red }
}) {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile(this.item.icon))
.width('40vp')
.height('40vp')
}
.onClick(this.onClickHead)
}
.width('40vp')
.height('40vp')
} else {
Stack() {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile(this.item.icon))
if(this.item.conversation.countOfUnread > 0) {
Text(this.item.conversation.countOfUnread < 100 ? this.item.conversation.countOfUnread.toString() : '99+')
.fontSize(10)
.align(Alignment.Center)
.padding({ left: 5, right: 5 })
.height(20)
.backgroundColor(Color.Red)
.fontColor($r("app.color.white"))
.zIndex(2)
.position({ x: '60%', y: '-10%' })
.border({ width: 2, color: $r("app.color.white"), radius: 50 })
}
Image($rawfile(this.item.conversation.icon))
.width('40vp')
.height('40vp')
}
.width('40vp')
.height('40vp')
@ -62,30 +61,31 @@ export struct MmsListItem {
}
//body
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start }) {
if (this.index != 0) {
Divider().vertical(false)
.width('100%').height('1vp')
.color(Color.Gray)
}
Divider().vertical(false)
.width('100%').height('1vp')
.color($r("app.color.divider_color"))
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center }) {
Flex({ direction: FlexDirection.Row,
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
//电话号码或名字
Text(this.item.name != '' ? this.item.name : this.item.telephoneFormat)
Text(this.item.conversation.name != '' ? this.item.conversation.name : this.item.conversation.telephoneFormat)
.fontSize('16fp')
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontColor('#191919')
.fontColor($r("app.color.main_font_color"))
.maxLines(1)
Text().width(16)
//日期时间
Text(this.item.time)
.fontColor(Color.Gray)
Text(this.item.conversation.time)
.fontColor($r('app.color.main_font_color_40'))
.fontSize('12fp')
.maxLines(1)
.flexShrink(0)
}.width('100%')
//最新消息的内容缩略语
Row() {
//最新的消息是否未发送成功,如果是
if (this.item.sendingFailed) {
if (this.item.conversation.sendingFailed) {
Text($r("app.string.messageSendFailed"))
.fontSize('12fp')
.fontColor(Color.Red)
@ -93,21 +93,21 @@ export struct MmsListItem {
//如果不是
Text() {
//最新的消息是否是草稿,如果是
if (this.item.isDraft) {
if (this.item.conversation.isDraft) {
Span($r("app.string.draft"))
.fontSize('14fp')
.fontColor(Color.Red)
}
//如果不是,且未读的消息个数>1条
if (!this.item.isDraft && this.item.countOfUnread > 1) {
Span($r("app.string.multiUnread", this.item.countOfUnread))
if (!this.item.conversation.isDraft && this.item.conversation.countOfUnread > 1) {
Span($r("app.string.multiUnread", this.item.conversation.countOfUnread))
.fontSize('14fp')
.fontColor('#666666')
}
//最新消息的内容缩略语
Span(this.item.content)
Span(this.item.conversation.content)
.fontSize('14fp')
.fontColor('#666666')
.fontColor($r('app.color.main_font_color_40'))
}
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
@ -126,7 +126,7 @@ export struct MmsListItem {
//CheckBox选择框
if (this.isMultipleSelectState) {
Toggle({ type: ToggleType.Checkbox, isOn: this.item.isCbChecked })
Toggle({ type: ToggleType.Checkbox, isOn: this.item.conversation.isCbChecked })
.width('20vp')
.height('20vp')
.enabled(false)
@ -134,9 +134,8 @@ export struct MmsListItem {
}
.width('100%')
.height('100%')
.padding({ left: '24vp', right: '24vp' })
.translate({
x: this.item.itemLeft
x: this.item.conversation.itemLeft
})
//左滑的删除图标
if (!this.isMultipleSelectState) {
@ -145,7 +144,7 @@ export struct MmsListItem {
justifyContent: FlexAlign.Center,
alignItems: ItemAlign.Center
}) {
if (this.item.countOfUnread > 0) {
if (this.item.conversation.countOfUnread > 0) {
Image($rawfile("icon/msg_done.svg"))
.width(40)
.height(40)
@ -160,15 +159,15 @@ export struct MmsListItem {
.width(this.item.countOfUnread > 0 ? 128 : 80)
.height('100%')
.backgroundColor($r("app.color.title_bar_background"))
.padding({ right: '24vp' })
.padding({ right: '16vp' })
.translate({
x: this.item.itemLeft
x: this.item.conversation.itemLeft
})
}
}
.width('100%')
.height('100%')
.gesture(PanGesture({ direction: this.item.isDelShow ? PanDirection.Right : PanDirection.Left })
.gesture(PanGesture({ direction: this.item.conversation.isDelShow ? PanDirection.Right : PanDirection.Left })
.onActionStart(this.onTouchStart)
.onActionUpdate(this.onTouchUpdate)
.onActionEnd(this.onTouchEnd)

View File

@ -0,0 +1,88 @@
/**
* Copyright (c) 2022 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.
*/
/** 自定义弹出窗menu组件 */
@Component
export struct MmsMenu {
@State showPopup: boolean = false;
private menuItems: Array<any>
private menuImage: Resource = $rawfile('icon/ic_public_more.svg');
private sizeType: SizeType = SizeType.LG;
private placement: Placement = Placement.Bottom;
private defaultColor: Resource = $r("app.color.white");
private menuText: Resource = null;
private menuTextColor: Resource = $r("app.color.main_font_color");
@Builder PopupBuilder() {
Column() {
List() {
ForEach(this.menuItems, (item, index) => {
ListItem() {
Text(item.value)
.fontSize(16)
.lineHeight(21)
.width("100%")
.height(48)
.padding({ left: 12, right: 12 })
.fontWeight(FontWeight.Regular)
.fontColor(item.enabled ? $r("app.color.main_font_color") : $r("app.color.main_font_color_40"))
.onClick(() => {
if (item.enabled) {
item.action();
}
})
}
}, item => JSON.stringify(item))
}
.listDirection(Axis.Vertical) // 排列方向
.divider({ strokeWidth: 0.5, color: $r('app.color.divider_color'), startMargin: 12, endMargin: 12 }) // 每行之间的分界线
.edgeEffect(EdgeEffect.Spring) // 滑动到边缘效果
.chainAnimation(false) // 联动特效关闭
}
.backgroundColor(this.defaultColor)
.width(this.sizeType == SizeType.LG ? 186 : 144)
.borderRadius(16)
.padding({ top: 4, bottom: 4, left: 4, right: 4 })
}
build() {
Column() {
Image(this.menuImage)
.width(24)
.height(24)
if (this.menuText != null) {
Text(this.menuText)
.fontSize(10)
.lineHeight(14)
.fontColor(this.menuTextColor)
.margin({ top: 3 })
}
}
.onClick(() => {
this.showPopup = !this.showPopup;
})
.bindPopup(this.showPopup, {
builder: this.PopupBuilder,
placement: this.placement,
maskColor: $r("app.color.mask_color"),
popupColor: $r("app.color.transparent_color"),
enableArrow: false,
onStateChange: (e) => {
if (!e.isVisible) {
this.showPopup = false;
}
}
})
}
}

View File

@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import MmsBoolean from '../data/MmsBoolean'
/**
* 设置项双标题1开关
*/
@ -19,8 +20,9 @@
export struct SettingItemSwitch {
primaryTitle: string | Resource;
secondaryTitle?: string | Resource;
isEnable: boolean;
@ObjectLink isEnable: MmsBoolean;
showBottomDivider ?: boolean = false;
visibility ?: Visibility = Visibility.Visible;
onChange: (isOn: boolean) => void;
build() {
@ -46,18 +48,35 @@ export struct SettingItemSwitch {
}
.layoutWeight(1)
Toggle({ type: ToggleType.Switch, isOn: this.isEnable })
Toggle({ type: ToggleType.Switch, isOn: this.isEnable.value })
.width($r('app.float.settings_item_switch_width'))
.onChange(this.onChange)
.selectedColor($r("app.color.control_activated_color"))
.onChange((isOn: boolean) => {
if (typeof isOn === "number") {
let newIsOn: number = isOn;
switch (newIsOn) {
case 1:
isOn = true;
break;
case 0:
isOn = false;
break;
default:
break;
}
}
this.onChange(isOn);
})
}
.layoutWeight(1)
if (this.showBottomDivider) {
Divider().vertical(false).strokeWidth(1).color($r("app.color.default_main_background")).lineCap(LineCapStyle.Round)
Divider().vertical(false).strokeWidth(1).color($r("app.color.divider_color")).lineCap(LineCapStyle.Round)
}
}
.width('100%')
.height(this.secondaryTitle != undefined ? $r('app.float.settings_item_height_2') : $r('app.float.settings_item_height_1'))
.visibility(this.visibility)
}
}
@ -70,8 +89,8 @@ export struct SettingItemJump {
secondaryTitle ?: string | Resource;
@State statusTitle ?: string | Resource = "";
showBottomDivider ?: boolean = false;
visibility ?: Visibility = Visibility.Visible;
onClick: (event?: ClickEvent) => void;
isVisible: Visibility = Visibility.Visible;
build() {
Column() {
@ -116,11 +135,11 @@ export struct SettingItemJump {
.onClick(this.onClick)
if (this.showBottomDivider) {
Divider().vertical(false).strokeWidth(1).color($r("app.color.default_main_background")).lineCap(LineCapStyle.Round)
Divider().vertical(false).strokeWidth(1).color($r("app.color.divider_color")).lineCap(LineCapStyle.Round)
}
}
.width('100%')
.height(this.secondaryTitle != undefined ? $r('app.float.settings_item_height_2') : $r('app.float.settings_item_height_1'))
.visibility(this.isVisible)
.visibility(this.visibility)
}
}

View File

@ -13,174 +13,194 @@
* limitations under the License.
*/
import ReceiveController from './receiveController'
import LooseObject from '../../data/LooseObject'
import ConversationController from '../../pages/conversation/conversationController'
@Component
export struct Receive {
@StorageLink('ReceiveController') mReceiveController: ReceiveController = ReceiveController.getInstance();
@StorageLink('ConversationController') mConversationController: ConversationController = ConversationController.getInstance();
@State mReceiveController: ReceiveController = ReceiveController.getInstance();
@Link mConversationController: ConversationController;
private aboutToAppear(): void {
this.mReceiveController.changeMyText(this.mConversationController.strContactsNumberFormat);
}
private onPageShow(): void {
aboutToAppear() {
this.mReceiveController.onInit((receiverData) => {
this.mConversationController.setReceiveContactValue(receiverData)
this.mConversationController.setReceiveContactValue(receiverData)
})
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
Text($r('app.string.putAddresser'))
.flexBasis(70)
.height(21)
.maxLines(1)
.fontSize(16)
.fontColor($r('app.color.main_font_color_40'))
.fontWeight(FontWeight.Regular)
.fontFamily('HarmonyHeiTi')
Flex({ wrap: FlexWrap.Wrap, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
// 如果选择了联系人
// if (this.mReceiveController.isInputStatus) {
// ForEach(this.mReceiveController.selectContacts, (item, index) => {
// Row() {
// if (item.contactName == '' || item.contactName == null) {
// Text(item.telephoneFormat)
// .textAlign(TextAlign.Center)
// .textOverflow({ overflow: TextOverflow.Ellipsis })
// .fontSize(12)
// }
// if (item.contactName != '' && item.contactName != null) {
// Text(item.contactName)
// .textAlign(TextAlign.Center)
// .textOverflow({ overflow: TextOverflow.Ellipsis })
// .fontSize(12)
// }
// if (item.select) {
// Image($rawfile('icon/ic_cancel_black.svg'))
// .width(16)
// .height(16)
// }
// }
// .padding({ left: 8, right: 8 })
// .margin(4)
// .backgroundColor('#EEE')
// .borderRadius(24)
// .height(20)
// .alignItems(VerticalAlign.Center)
// .onClick(() => {
// this.mReceiveController.nameClick(index)
// })
// }, item => item.id)
// }
// //
// else {
// Text(this.mReceiveController.strSelectContact)
// .fontColor('#171BFA')
// .textAlign(TextAlign.Center)
// .textOverflow({ overflow: TextOverflow.Ellipsis })
// }
// if (this.mReceiveController.isInputStatus) {
Row() {
TextArea({ text: this.mReceiveController.myText })
.flexBasis('auto')
.caretColor($r('app.color.control_activated_color'))
.placeholderColor($r('app.color.placeholder_color'))
.backgroundColor($r('app.color.white'))
.onChange((value) => {
this.mReceiveController.searchChange(value, (receiverData) => {
this.mConversationController.setReceiveContactValue(receiverData);
});
})
// .onBlur(() => {
// this.mReceiveController.checkReceive()
// })
// .onFocus(() => {
// this.mReceiveController.myContactFocus();
// })
}
.constraintSize({ maxHeight: 120 })
// }
}
.flexGrow(1)
// .onClick(() => {
// this.mReceiveController.myContactClick();
// })
}
.flexBasis('auto')
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
// 右侧联系人图标
Image($rawfile('icon/ic_about.svg'))
.width(24)
.height(24)
.margin({ right: 12 })
.onClick(() => {
// 跳转到联系人模块选择联系人界面
this.mReceiveController.clickToContracts((receiverData) => {
this.mConversationController.setReceiveContactValue(receiverData);
})
})
}
.width(36)
.height(56)
}
.constraintSize({ maxHeight: 200 })
.backgroundColor($r('app.color.white'))
.borderRadius(24)
.padding({ top: 8, bottom: 8, left: 12, right: 12 })
Column() {
// 是否显示最近联系人列表
if (this.mReceiveController.isShowSearch) {
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
Text('最近联系人')
.fontSize(16)
.fontColor($r('app.color.main_font_color_40'))
.fontWeight(FontWeight.Regular)
}
.height(48)
// <!-- list区域 -->
List({ space: 0, initialIndex: 0 }) {
ForEach(this.mReceiveController.contacts, (item, index) => {
ListItem() {
Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
Image($rawfile(item.headImage))
.width(40)
.height(40)
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Center,
alignItems: ItemAlign.Start
}) {
if (item.contactName != '' || item.contactName != null) {
Text(item.contactName)
.fontSize(16)
.fontColor($r('app.color.main_font_color'))
.lineHeight(22)
}
Text(item.telephoneFormat)
.fontColor($r('app.color.main_font_color_40'))
.fontSize(14)
.lineHeight(19)
}
.margin({ left: 12 })
}.height(64)
}
}, item => item.id)
}
.listDirection(Axis.Vertical) // 排列方向
.edgeEffect(EdgeEffect.Spring) // 滑动到边缘无效果
.divider({ strokeWidth: 1, color: $r('app.color.divider_color'), startMargin: 52, endMargin: 0 }) // 每行之间的分界线
}
}.padding({ left: 12, right: 12 })
}
.width('100%')
.padding({ left: 12, right: 12 })
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
Text($r('app.string.putAddresser'))
.flexBasis(70)
.height(21)
.maxLines(1)
.fontSize(16)
.fontColor($r('app.color.main_font_color_40'))
.fontWeight(FontWeight.Regular)
.fontFamily('HarmonyHeiTi')
Flex({ wrap: FlexWrap.Wrap, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
// 如果选择了联系人
if (this.mReceiveController.isInputStatus) {
if (this.mReceiveController.selectContacts.length > 0) {
ForEach(this.mReceiveController.selectContacts, (item, index) => {
Row() {
if (item.contactName == '' || item.contactName == null) {
Text(item.telephoneFormat)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize(12)
}
if (item.contactName != '' && item.contactName != null) {
Text(item.contactName)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize(12)
}
if (item.select) {
Image($rawfile('icon/ic_cancel_black.svg'))
.width(16)
.height(16)
}
}
.padding({ left: 8, right: 8 })
.margin(4)
.backgroundColor('#EEE')
.borderRadius(24)
.height(20)
.alignItems(VerticalAlign.Center)
.onClick(() => {
this.mReceiveController.nameClick(index, (receiverData) => {
this.mConversationController.setReceiveContactValue(receiverData);
})
})
}, item => item.toString())
}
Flex() {
TextArea({ text: this.mReceiveController.myText })
.caretColor($r('app.color.control_activated_color'))
.placeholderColor($r('app.color.placeholder_color'))
.backgroundColor($r("app.color.transparent_color"))
.focusable(true)
.onChange((value) => {
this.mReceiveController.searchChange(value, (receiverData) => {
this.mConversationController.setReceiveContactValue(receiverData);
});
})
.onBlur(() => {
this.mReceiveController.checkReceive((receiverData) => {
this.mConversationController.setReceiveContactValue(receiverData);
});
})
.onFocus(() => {
this.mReceiveController.myContactFocus();
})
}
.constraintSize({ maxHeight: 120 })
}
else {
Text(this.mReceiveController.strSelectContact)
.fontColor(Color.Blue)
.textAlign(TextAlign.Center)
.fontSize(16)
.lineHeight(24)
.textAlign(TextAlign.Start)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.width("100%")
.padding({ top: 12, bottom: 12 })
.onClick(() => {
this.mReceiveController.myContactClick();
})
}
}
.flexShrink(1)
}
.flexBasis('auto')
.flexShrink(1)
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
// 右侧联系人图标
Image($rawfile('icon/ic_about.svg'))
.width(24)
.height(24)
.margin({ right: 12 })
}
.width(56)
.height(56)
.onClick(() => {
// 跳转到联系人模块选择联系人界面
this.mReceiveController.clickToContracts((receiverData) => {
this.mConversationController.setReceiveContactValue(receiverData);
})
})
}
.constraintSize({ maxHeight: 200 })
.backgroundColor($r('app.color.white'))
.borderRadius(24)
.padding({ top: 8, bottom: 8, left: 12, right: 12 })
Column() {
// 是否显示最近联系人列表
if (this.mReceiveController.isShowSearch && this.mReceiveController.contacts.length > 0) {
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
Text('最近联系人')
.fontSize(16)
.fontColor($r('app.color.main_font_color_40'))
.fontWeight(FontWeight.Regular)
}
.height(48)
// list区域
List({ space: 0, initialIndex: 0 }) {
ForEach(this.mReceiveController.contacts, (item, index) => {
ListItem() {
Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
Image($rawfile('icon/user_avatar_full_fill.svg'))
.width(40)
.height(40)
.onClick(() => {
this.mReceiveController.titleBarAvatar(index)
})
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Center,
alignItems: ItemAlign.Start
}) {
if (item.contactName != '' || item.contactName != null) {
Text(item.contactName)
.fontSize(16)
.fontColor($r('app.color.main_font_color'))
.lineHeight(22)
}
Text(item.telephoneFormat)
.fontColor($r('app.color.main_font_color_40'))
.fontSize(14)
.lineHeight(19)
}
.width("100%")
.margin({ left: 12 })
.onClick(() => {
this.mReceiveController.addContact(index, (receiverData) => {
this.mConversationController.setReceiveContactValue(receiverData);
})
})
}
.height(64)
}
}, item => item.toString())
}
.listDirection(Axis.Vertical) // 排列方向
.edgeEffect(EdgeEffect.Spring) // 滑动到边缘无效果
.divider({
strokeWidth: 1,
color: $r('app.color.divider_color'),
startMargin: 52,
endMargin: 0
}) // 每行之间的分界线
}
}.padding({ left: 12, right: 12, bottom: 56 })
}
.width('100%')
.padding({ left: 12, right: 12 })
}
}

View File

@ -20,6 +20,7 @@ import prompt from '@system.prompt';
import common from '../../data/commonData';
import contractService from '../../service/ContractService';
import commonService from '../../service/CommonService'
import commonCtrl from '../../pages/conversation/common'
import featureAbility from '@ohos.ability.featureAbility';
import LooseObject from '../../data/LooseObject'
@ -28,7 +29,9 @@ let ReceiveCtrl;
const TAG = 'ReceiveController';
export default class ReceiveController {
paramContact: LooseObject = {};
private static sInstance: ReceiveController;
commonCtrl = commonCtrl.getInstance();
refresh: boolean = false;
// 收件人信息(已经选择)
selectContacts: Array<any> = [];
contacts: Array<any> = [];
@ -52,16 +55,16 @@ export default class ReceiveController {
totalMessage: number = 0;
static getInstance() {
if (ReceiveCtrl == null) {
ReceiveCtrl = new ReceiveController();
appStorage.setAndLink('ReceiveController', ReceiveCtrl);
if (ReceiveController.sInstance == null) {
ReceiveController.sInstance = new ReceiveController();
}
return ReceiveCtrl;
return ReceiveController.sInstance;
}
onInit(call) {
this.selectContacts = this.paramContact.transmitContracts;
HiLog.i(TAG, "onInit()")
// this.$watch('paramContact', 'onPropertyChange');
this.selectContacts = this.commonCtrl.paramContact.transmitContracts;
if (this.selectContacts.length > 0) {
let that = this;
setTimeout(function () {
@ -71,6 +74,7 @@ export default class ReceiveController {
this.setInputStatus(false);
}
this.requestItem()
this.refresh = !this.refresh;
}
requestItem() {
@ -85,10 +89,6 @@ export default class ReceiveController {
}
}
changeMyText(value) {
this.myText = value;
}
queryContacts() {
let actionData = {
page: this.page,
@ -150,12 +150,8 @@ export default class ReceiveController {
setInputStatus(flag) {
this.isInputStatus = flag;
if (flag) {
this.styleTextarea = 'select-contact-textarea';
} else {
this.styleTextarea = 'content-addressee-text';
if (!flag) {
this.strSelectContact = this.setShowContactName();
this.myText = this.strSelectContact;
}
}
@ -175,7 +171,7 @@ export default class ReceiveController {
for (let index in this.contacts) {
let contract = this.contacts[index];
if (contract.telephone == that.myText) {
selectContact.headImage = '/common/icon/user_avatar_full_fill.svg';
selectContact.headImage = 'icon/user_avatar_full_fill.svg';
selectContact.contactName = contract.contactName;
selectContact.telephone = contract.telephone;
selectContact.telephoneFormat = contract.telephone;
@ -193,6 +189,7 @@ export default class ReceiveController {
}
HiLog.i(TAG, 'checkReceive, isPhoneNumber yes');
this.selectContacts.push(selectContact);
this.refresh = !this.refresh;
this.setInputStatus(false);
this.isShowSearch = false;
this.setContactValue(call);
@ -204,35 +201,43 @@ export default class ReceiveController {
message: $r('app.string.invalid_receive', this.myText),
duration: 1000,
});
this.setInputStatus(false);
this.isShowSearch = false;
this.myText = "";
this.isShowSearch = true;
this.setContactValue(call);
}
}
searchChange(text, call) {
HiLog.d(TAG, 'searchChange, start');
if (this.checkSingle()) {
this.setInputStatus(false);
this.isShowSearch = false;
return;
}
this.myText = text;
if (!this.isInputStatus) {
HiLog.w(TAG, 'searchChange, isInputStatus false');
return;
}
// this.searchContacts(this.myText, code => {
// if (code == common.int.SUCCESS) {
this.setContactValue(call);
this.dealSearchData();
this.setContactValue(call);
// }
// });
this.searchContacts(this.myText, code => {
if (code == common.int.SUCCESS && this.myText.trim() != "") {
this.setContactValue(call);
this.dealSearchData();
this.setContactValue(call);
} else {
this.setContactValue(call);
}
});
}
dealSearchData() {
if (false) {
if (this.myText.trim() == "") {
this.contacts = this.contactsTemp.slice(0);
// this.$element('receiveTxt').focus({
// focus: true
// });
} else {
let textValue = this.myText.toLowerCase();
let textValue = this.myText.trim().toLowerCase();
// 过滤逻辑
this.filterContacts(textValue);
}
@ -241,7 +246,7 @@ export default class ReceiveController {
setContactValue(call) {
// 将收件人信息,传给调用的父组件
call({
// 输入框的内容
// 选择联系人之前的输入框的内容
contactValue: this.myText,
// 已经选择的收件人信息
selectContacts: this.selectContacts,
@ -250,8 +255,20 @@ export default class ReceiveController {
});
}
addContact(index) {
addContact(index, call) {
let curItem = this.contacts[index];
if (this.checkSingle()) {
return;
}
if (curItem.telephone.toString().trim() == "") {
prompt.showToast({
// 无效收件人
// @ts-ignore
message: $r('app.string.invalid_receive', this.myText),
duration: 1000,
});
return;
}
this.selectContacts.push(curItem);
this.contactsTemp = this.contactsTemp.filter((item) => {
return item.telephone != curItem.telephone
@ -262,13 +279,11 @@ export default class ReceiveController {
if (this.selectContacts.length == 1) {
this.setInputStatus(false);
this.isShowSearch = false;
// 未开发list区域暂传null
this.setContactValue(null);
this.setContactValue(call);
} else {
this.setInputStatus(true);
this.isShowSearch = true;
// 未开发list区域暂传null
this.setContactValue(null);
this.setContactValue(call);
}
HiLog.i(TAG, 'addContact, isInputStatus: ' + this.isInputStatus);
}
@ -277,22 +292,16 @@ export default class ReceiveController {
if (this.selectContacts.length == 0) {
return '';
}
/*
* 控件不支持没法像手机一样选择1个联系人就显示一个胶囊图标330需求也不支持多联系人发送。
* 目前先改成选择联系人后只显示第1个联系人的号码在编辑框非胶囊形状
*/
return this.selectContacts[0].telephone;
// let myName = this.selectContacts[0].contactName.trim();
// if (myName == '') {
// myName = this.selectContacts[0].telephone;
// }
// if (this.selectContacts.length >= 2) {
// // name以及其他number个
// return $r('app.string.and_others', myName, this.selectContacts.length - 1)
// } else {
// return myName
// }
let myName = this.selectContacts[0].contactName.trim();
if (myName == '') {
myName = this.selectContacts[0].telephone;
}
if (this.selectContacts.length >= 2) {
// name以及其他number个
return $r('app.string.and_others', myName, this.selectContacts.length - 1)
} else {
return myName
}
}
myContactFocus() {
@ -315,18 +324,24 @@ export default class ReceiveController {
}
}
nameClick(idx) {
nameClick(idx, call) {
HiLog.i(TAG, "click-->" + idx)
if (this.selectContacts[idx].select) {
let item = this.selectContacts.splice(idx, 1);
// 已经删除的添加到 需要搜索的集合
this.contactsTemp.push(item);
this.contacts.push(item[0]);
if (item[0].telephoneFormat.toString().trim() != "") {
this.contacts.push(item[0]);
}
this.refresh = !this.refresh;
this.setContactValue(call);
return;
}
for (let element of this.selectContacts) {
element.select = false;
}
this.selectContacts[idx].select = true;
this.refresh = !this.refresh;
}
clickToContracts(call) {
@ -360,10 +375,13 @@ export default class ReceiveController {
dealContractParams(contactObjects, call) {
let params = JSON.parse(contactObjects);
this.selectContacts = [];
for (let element of params) {
if (params.length > 1 || this.checkSingle()) {
return;
}
if (params.length == 1) {
let element = params[0]
let selectContact: LooseObject = {};
selectContact.headImage = '/common/icon/user_avatar_full_fill.svg';
selectContact.headImage = 'icon/user_avatar_full_fill.svg';
selectContact.contactName = element.contactName;
selectContact.telephone = element.telephone;
selectContact.telephoneFormat = element.telephone;
@ -376,8 +394,8 @@ export default class ReceiveController {
this.isShowSearch = false;
this.setContactValue(call);
}
this.paramContact.isSelectContact = false;
this.paramContact.isNewRecallMessagesFlag = false;
this.commonCtrl.paramContact.isSelectContact = false;
this.commonCtrl.paramContact.isNewRecallMessagesFlag = false;
}
deleteRepetitionContracts(contacts, selectContacts) {
@ -414,4 +432,19 @@ export default class ReceiveController {
}
}
}
// 目前只支持单个收件人,先规避操作只能输入一个收件人
checkSingle() {
if (this.selectContacts.length > 0) {
prompt.showToast({
// 无效收件人
// @ts-ignore
message: "只支持单个收件人",
duration: 1000,
});
return true;
} else {
return false;
}
}
}

View File

@ -8,13 +8,9 @@
"name": "back_Transparent",
"value": "#FFFFFFFF"
},
{
"name": "default_main_background",
"value": "#F1F3F5"
},
{
"name": "sender_bubble",
"value": "#C0EBDF"
"value": "#3300CB87"
},
{
"name": "receiver_bubble",
@ -46,7 +42,7 @@
},
{
"name": "divider_color",
"value": "#33000000"
"value": "#0D000000"
},
{
"name": "control_activated_color",
@ -55,6 +51,22 @@
{
"name": "placeholder_color",
"value": "#99000000"
},
{
"name": "setting_background",
"value": "#F1F3F5"
},
{
"name": "detail_main_background",
"value": "#DAEFF9"
},
{
"name": "transparent_color",
"value": "#00FFFFFF"
},
{
"name": "mask_color",
"value": "#26000000"
}
]
}

View File

@ -50,7 +50,7 @@
},
{
"name": "settings_items_radius",
"value": "24vp"
"value": "16vp"
},
{
"name": "settings_item_padding_left",
@ -111,6 +111,10 @@
{
"name": "settings_item_next_image_height",
"value": "24vp"
},
{
"name": "conversation_list_no_message_fs",
"value": "14fp"
}
]
}

View File

@ -137,8 +137,8 @@
{"name": "addSlide", "value": "添加幻灯片"},
{"name": "sendAddresser", "value": "发件人: "},
{"name": "putAddresser", "value": "收件人: "},
{"name": "invalid_receive", "value": "无效收件人:<{str}>"},
{"name": "and_others", "value": "{name}以及其他{number}个"},
{"name": "invalid_receive", "value": "无效收件人:%s"},
{"name": "and_others", "value": "%s以及其他%d个"},
{"name": "msgDetails", "value": "信息详情"},
{"name": "transmitButton", "value": "转发"},
{"name": "transmitButtonOne", "value": "卡1转发"},

View File

@ -137,8 +137,8 @@
{"name": "addSlide", "value": "Add slide"},
{"name": "sendAddresser", "value": "From: "},
{"name": "putAddresser", "value": "To: "},
{"name": "invalid_receive", "value": "Invalid receive:<{str}>"},
{"name": "and_others", "value": "{name}and{number}others"},
{"name": "invalid_receive", "value": "Invalid receive:%s"},
{"name": "and_others", "value": "%s and %d others"},
{"name": "msgDetails", "value": "Message details"},
{"name": "transmitButton", "value": "FORWARD"},
{"name": "transmitButtonOne", "value": "SEND (SIM1)"},

View File

@ -9,6 +9,6 @@
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="形状结合" fill="#182431" fill-rule="nonzero" xlink:href="#path-1"></use>
<use id="形状结合" fill="#182431" fill-opacity="0.4" fill-rule="nonzero" xlink:href="#path-1"></use>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -10,6 +10,6 @@
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="路径" fill="#000000" fill-rule="nonzero" xlink:href="#path-1"></use>
<use id="路径" fill="#182431" fill-opacity="0.4" fill-rule="nonzero" xlink:href="#path-1"></use>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>ic_public_add</title>
<defs>
<path d="M12.75,21.25 C12.75,21.6642136 12.4142136,22 12,22 C11.5857864,22 11.25,21.6642136 11.25,21.25 L11.25,12.75 L2.75,12.75 C2.33578644,12.75 2,12.4142136 2,12 C2,11.5857864 2.33578644,11.25 2.75,11.25 L11.25,11.25 L11.25,2.75 C11.25,2.33578644 11.5857864,2 12,2 C12.4142136,2 12.75,2.33578644 12.75,2.75 L12.75,21.25 Z M21.25,11.25 C21.6642136,11.25 22,11.5857864 22,12 C22,12.4142136 21.6642136,12.75 21.25,12.75 L13.75,12.75 L13.75,11.25 L21.25,11.25 Z" id="path-1"></path>
</defs>
<g id="ic_public_add" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<rect id="矩形" x="0" y="0" width="24" height="24"></rect>
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="形状结合" fill="#182431" xlink:href="#path-1"></use>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>ic_public_cancel</title>
<defs>
<path d="M19.7781746,4.22182541 C20.0710678,4.51471863 20.0710678,4.98959236 19.7781746,5.28248558 L5.28248558,19.7781746 C4.98959236,20.0710678 4.51471863,20.0710678 4.22182541,19.7781746 C3.92893219,19.4852814 3.92893219,19.0104076 4.22182541,18.7175144 L10.9395166,11.9994697 L4.22182541,5.28248558 C3.92893219,4.98959236 3.92893219,4.51471863 4.22182541,4.22182541 C4.51471863,3.92893219 4.98959236,3.92893219 5.28248558,4.22182541 L12,10.9389863 L18.7175144,4.22182541 C19.0104076,3.92893219 19.4852814,3.92893219 19.7781746,4.22182541 Z M19.7781746,18.7175144 C20.0710678,19.0104076 20.0710678,19.4852814 19.7781746,19.7781746 C19.4852814,20.0710678 19.0104076,20.0710678 18.7175144,19.7781746 L12.7072836,13.7675902 L13.767767,12.7071068 L19.7781746,18.7175144 Z" id="path-1"></path>
</defs>
<g id="ic_public_cancel" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<rect id="矩形" x="0" y="0" width="24" height="24"></rect>
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="形状" fill="#182431" xlink:href="#path-1"></use>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>ic_public_delete</title>
<defs>
<path d="M5.629,7.5 L6.72612901,18.4738834 C6.83893748,19.6019681 7.77211147,20.4662096 8.89848718,20.4990325 L8.96496269,20.5 L15.0342282,20.5 C16.1681898,20.5 17.1211231,19.6570911 17.2655686,18.5392856 L17.2731282,18.4732196 L18.1924161,9.2527383 L18.369,7.5 L19.877,7.5 L19.6849078,9.40262938 L18.7657282,18.6220326 C18.5772847,20.512127 17.0070268,21.9581787 15.1166184,21.9991088 L15.0342282,22 L8.96496269,22 C7.06591715,22 5.47142703,20.5815579 5.24265599,18.7050136 L5.23357322,18.6231389 L4.121,7.5 L5.629,7.5 Z M10.25,11.75 C10.6642136,11.75 11,12.0857864 11,12.5 L11,18.5 C11,18.9142136 10.6642136,19.25 10.25,19.25 C9.83578644,19.25 9.5,18.9142136 9.5,18.5 L9.5,12.5 C9.5,12.0857864 9.83578644,11.75 10.25,11.75 Z M13.75,11.75 C14.1642136,11.75 14.5,12.0857864 14.5,12.5 L14.5,18.5 C14.5,18.9142136 14.1642136,19.25 13.75,19.25 C13.3357864,19.25 13,18.9142136 13,18.5 L13,12.5 C13,12.0857864 13.3357864,11.75 13.75,11.75 Z M12,1.75 C13.7692836,1.75 15.2083571,3.16379796 15.2491124,4.92328595 L15.25,5 L21,5 C21.4142136,5 21.75,5.33578644 21.75,5.75 C21.75,6.14942022 21.43777,6.47591522 21.0440682,6.49872683 L21,6.5 L14.5,6.5 C14.1005798,6.5 13.7740848,6.18777001 13.7512732,5.7940682 L13.75,5.75 L13.75,5 C13.75,4.03350169 12.9664983,3.25 12,3.25 C11.0536371,3.25 10.2827253,4.00119585 10.2510148,4.93983756 L10.25,5 L10.25,5.75 C10.25,6.14942022 9.93777001,6.47591522 9.5440682,6.49872683 L9.5,6.5 L2.75,6.5 C2.33578644,6.5 2,6.16421356 2,5.75 C2,5.35057978 2.31222999,5.02408478 2.7059318,5.00127317 L2.75,5 L8.75,5 C8.75,3.20507456 10.2050746,1.75 12,1.75 Z" id="path-1"></path>
</defs>
<g id="ic_public_delete" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<rect id="矩形" x="0" y="0" width="24" height="24"></rect>
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="形状结合" fill="#182431" fill-rule="nonzero" xlink:href="#path-1"></use>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -1,116 +1,8 @@
{
"float": [
{
"name": "list_title_font_size_large",
"value": "45fp"
},
{
"name": "empty_view_top_padding",
"value": "327vp"
},
{
"name": "icon_side_length_small",
"value": "18vp"
},
{
"name": "icon_side_length_medium",
"value": "36vp"
},
{
"name": "icon_side_length_Large",
"value": "72vp"
},
{
"name": "action_bar_height",
"value": "84vp"
},
{
"name": "action_bar_margin_left",
"value": "18vp"
},
{
"name": "action_bar_margin_right",
"value": "18vp"
},
{
"name": "action_bar_space",
"value": "24vp"
},
{
"name": "action_bar_text_size",
"value": "30vp"
},
{
"name": "settings_items_margin_top",
"value": "12vp"
},
{
"name": "settings_items_margin_bottom",
"value": "12vp"
},
{
"name": "settings_items_radius",
"value": "36vp"
},
{
"name": "settings_item_padding_left",
"value": "36vp"
},
{
"name": "settings_item_padding_right",
"value": "36vp"
},
{
"name": "settings_item_padding_top",
"value": "6vp"
},
{
"name": "settings_item_padding_bottom",
"value": "6vp"
},
{
"name": "settings_item_height_1",
"value": "72vp"
},
{
"name": "settings_item_height_2",
"value": "96vp"
},
{
"name": "settings_item_primary_title_height",
"value": "33vp"
},
{
"name": "settings_item_secondary_title_height",
"value": "30vp"
},
{
"name": "settings_item_primary_title_font_size",
"value": "24vp"
},
{
"name": "settings_item_secondary_title_font_size",
"value": "19vp"
},
{
"name": "settings_item_title_space",
"value": "3vp"
},
{
"name": "settings_item_switch_width",
"value": "54vp"
},
{
"name": "settings_item_status_title_margin_right",
"value": "6vp"
},
{
"name": "settings_item_next_image_width",
"value": "18vp"
},
{
"name": "settings_item_next_image_height",
"value": "36vp"
}
]
}

View File

@ -137,8 +137,8 @@
{"name": "addSlide", "value": "添加幻灯片"},
{"name": "sendAddresser", "value": "发件人: "},
{"name": "putAddresser", "value": "收件人: "},
{"name": "invalid_receive", "value": "无效收件人:<{str}>"},
{"name": "and_others", "value": "{name}以及其他{number}个"},
{"name": "invalid_receive", "value": "无效收件人:%s"},
{"name": "and_others", "value": "%s以及其他%d个"},
{"name": "msgDetails", "value": "信息详情"},
{"name": "transmitButton", "value": "转发"},
{"name": "transmitButtonOne", "value": "卡1转发"},

View File

@ -14,7 +14,6 @@
*/
import {Core, ExpectExtend, InstrumentLog} from "deccjsunit/index"
import testsuite from "../../../test/List.test"
import app from '@system.app'
import featureAbility from "@ohos.ability.featureAbility"
@Entry

View File

@ -1,13 +0,0 @@
# Project-wide Gradle settings.
# IDE (e.g. DevEco Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# If the Chinese output is garbled, please configure the following parameter.
# This function is enabled by default when the DevEco Studio builds the hap/app,if you need disable gradle parallel,you should set org.gradle.parallel false.
# more information see https://docs.gradle.org/current/userguide/performance.html
# org.gradle.parallel=false
# org.gradle.jvmargs=-Dfile.encoding=GBK

183
gradlew vendored
View File

@ -1,183 +0,0 @@
#!/usr/bin/env sh
#
# Copyright (c) 2022 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
#
# https://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.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

103
gradlew.bat vendored
View File

@ -1,103 +0,0 @@
@rem
@rem Copyright (c) 2022 Huawei Device Co., Ltd.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

2
hvigorfile.js Normal file
View File

@ -0,0 +1,2 @@
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
module.exports = require('@ohos/hvigor-ohos-plugin').legacyAppTasks

View File

@ -1 +1,13 @@
{}
{
"name": "myapplication",
"version": "1.0.0",
"ohos": {
"org": "huawei",
"buildTool": "hvigor",
"directoryLevel": "project"
},
"dependencies": {
"@ohos/hvigor": "1.0.6",
"@ohos/hvigor-ohos-plugin": "1.0.6"
}
}

View File

@ -1 +0,0 @@
include ':entry'

Binary file not shown.