diff --git a/.gitignore b/.gitignore
index eeee8d0..91d237b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,5 @@
-.idea
-.gradle
-build
-
-local.properties
-entry/.preview
-node_modules
-package-lock.json
\ No newline at end of file
+/node_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
\ No newline at end of file
diff --git a/AppScope/app.json5 b/AppScope/app.json5
new file mode 100644
index 0000000..d5df565
--- /dev/null
+++ b/AppScope/app.json5
@@ -0,0 +1,11 @@
+{
+ "app": {
+ "bundleName": "com.ohos.mms",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:smsmms",
+ "label": "$string:app_name",
+ "distributedNotificationEnabled": true
+ }
+}
diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000..63c7a0e
--- /dev/null
+++ b/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "mms"
+ }
+ ]
+}
diff --git a/entry/src/ohosTest/resources/base/media/icon.png b/AppScope/resources/base/media/app_icon.png
similarity index 100%
rename from entry/src/ohosTest/resources/base/media/icon.png
rename to AppScope/resources/base/media/app_icon.png
diff --git a/AppScope/resources/base/media/smsmms.png b/AppScope/resources/base/media/smsmms.png
new file mode 100644
index 0000000..a75e2d8
Binary files /dev/null and b/AppScope/resources/base/media/smsmms.png differ
diff --git a/OAT.xml b/OAT.xml
index c4d5604..5ca9b26 100644
--- a/OAT.xml
+++ b/OAT.xml
@@ -30,10 +30,16 @@
-
+
-
-
+
+
+
+
+
+
+
@@ -45,42 +51,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
+
diff --git a/README.md b/README.md
index c3c3f8d..3ede60f 100644
--- a/README.md
+++ b/README.md
@@ -25,14 +25,14 @@ Mms应用是OpenHarmony中预置的系统应用,主要的功能包含信息查
│ ├── conversation # 会话详情页面
│ ├── conversationlist # 信息列表页面
│ ├── index # 初始页面
-│ ├── info_msg # 通知信息列表页面
-│ ├── query_report # 报告详情页面
+│ ├── infomsg # 通知信息列表页面
+│ ├── queryreport # 报告详情页面
│ └── settings # 设置页面
│ ├── service # 业务逻辑
│ ├── utils # 工具类
│ ├── views # 自定义组件
│ └── app.ets # 应用生命周期
-│ └── ServiceAbility # 后台常驻服务
+│ └── StaticSubscriber # 静态事件监听
│ ├── resources # 资源配置文件存放目录
│ └── config.json # 全局配置文件
├── signs # 签名
diff --git a/build-profile.json5 b/build-profile.json5
index 53dbfd6..68309bc 100644
--- a/build-profile.json5
+++ b/build-profile.json5
@@ -2,26 +2,26 @@
"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",
- },
+ "material": {
+ "storePassword": "000000195AA880DECC8D7622499B07D65C9593805D7CD84B966C48F695E8BDE678568D38C44C5676F1",
+ "certpath": "signs/IDE.cer",
+ "keyAlias": "OpenHarmony Application CA",
+ "keyPassword": "0000001960B019FAD679AFE8BFD7CB2C7C99C32F325AEF5CB40D344D9449487426694157CC4686EB22",
+ "profile": "signs/com.ohos.mms.p7b",
+ "signAlg": "SHA256withECDSA",
+ "storeFile": "signs/OpenHarmony.p12"
+ }
+ }
],
"compileSdkVersion": 9,
"compatibleSdkVersion": 9,
"products": [
{
"name": "default",
- "signingConfig": "debug"
- },
- ],
+ "signingConfig": "debug",
+ }
+ ]
},
"modules": [
{
@@ -31,10 +31,10 @@
{
"name": "default",
"applyToProducts": [
- "default",
- ],
- },
- ],
- },
- ],
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
}
\ No newline at end of file
diff --git a/entry/.gitignore b/entry/.gitignore
new file mode 100644
index 0000000..5a6ba80
--- /dev/null
+++ b/entry/.gitignore
@@ -0,0 +1,4 @@
+/node_modules
+/.preview
+/build
+/.cxx
\ No newline at end of file
diff --git a/entry/build-profile.json5 b/entry/build-profile.json5
index ae58d1d..befa101 100644
--- a/entry/build-profile.json5
+++ b/entry/build-profile.json5
@@ -1,13 +1,10 @@
{
- "apiType": 'faMode',
+ "apiType": 'stageMode',
"buildOption": {
},
"targets": [
{
- "name": "default",
- },
- {
- "name": "ohosTest",
+ "name": "default"
}
]
}
\ No newline at end of file
diff --git a/entry/hvigorfile.js b/entry/hvigorfile.js
index bcec4c9..d7720ee 100644
--- a/entry/hvigorfile.js
+++ b/entry/hvigorfile.js
@@ -1,2 +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
+module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks
diff --git a/entry/src/main/config.json b/entry/src/main/config.json
deleted file mode 100644
index 8ba6f41..0000000
--- a/entry/src/main/config.json
+++ /dev/null
@@ -1,134 +0,0 @@
-{
- "app": {
- "bundleName": "com.ohos.mms",
- "vendor": "ohos",
- "singleton": true,
- "version": {
- "code": 1000000,
- "name": "1.0.0"
- }
- },
- "deviceConfig": {
- "default": {
- "keepAlive": true
- }
- },
- "module": {
- "package": "com.ohos.mms",
- "name": ".MyApplication",
- "mainAbility": "com.ohos.mms.ServiceAbility",
- "deviceType": [
- "phone",
- "tablet",
- "car"
- ],
- "distro": {
- "deliveryWithInstall": true,
- "moduleName": "entry",
- "moduleType": "entry",
- "installationFree": false
- },
- "abilities": [
- {
- "skills": [
- {
- "entities": [
- "entity.system.home"
- ],
- "actions": [
- "action.system.home"
- ]
- }
- ],
- "visible": true,
- "orientation": "unspecified",
- "name": "com.ohos.mms.MainAbility",
- "icon": "$media:smsmms",
- "description": "$string:mainability_description",
- "label": "$string:messages",
- "type": "page",
- "launchType": "singleton",
- "srcPath": "default",
- "srcLanguage": "ets",
- "metaData": {
- "customizeData": [
- {
- "name": "hwc-theme",
- "value": "androidhwext:style/Theme.Emui.Light.NoTitleBar",
- "extra": ""
- }
- ]
- }
- },
- {
- "name": "com.ohos.mms.ServiceAbility",
- "icon": "$media:icon",
- "description": "service",
- "type": "service",
- "srcPath": "ServiceAbility",
- "srcLanguage": "ets",
- "visible": true
- }
- ],
- "js": [
- {
- "mode": {
- "syntax": "ets",
- "type": "pageAbility"
- },
- "pages": [
- "pages/index/index",
- "pages/conversationlist/conversationList",
- "pages/conversation/conversation",
- "pages/info_msg/InfoMsg",
- "pages/settings/settings",
- "pages/settings/advancedSettings/advancedSettings",
- "pages/settings/ringtoneSettings/ringtoneSettings",
- "pages/query_report/query_report"
- ],
- "name": "com.ohos.mms.MainAbility",
- "window": {
- "designWidth": 720,
- "autoDesignWidth": false
- }
- }
- ],
- "reqPermissions": [
- {
- "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
- },
- {
- "name": "ohos.permission.READ_CONTACTS"
- },
- {
- "name": "ohos.permission.READ_MESSAGES"
- },
- {
- "name": "ohos.permission.READ_USER_STORAGE"
- },
- {
- "name": "ohos.permission.WRITE_USER_STORAGE"
- },
- {
- "name": "ohos.permission.SEND_MESSAGES"
- },
- {
- "name": "ohos.permission.SET_TELEPHONY_STATE"
- },
- {
- "name": "ohos.permission.GET_TELEPHONY_STATE"
- },
- {
- "name": "ohos.permission.RECEIVE_SMS"
- },
- {
- "name": "ohos.permission.PLACE_CALL"
- }
- ],
- "defPermissions": [
- {
- "name": "com.ohos.mms.DataAbilityShellProvider.PROVIDER"
- }
- ]
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/Application/MyAbilityStage.ts b/entry/src/main/ets/Application/MyAbilityStage.ts
new file mode 100644
index 0000000..99db8a1
--- /dev/null
+++ b/entry/src/main/ets/Application/MyAbilityStage.ts
@@ -0,0 +1,19 @@
+import AbilityStage from "@ohos.application.AbilityStage"
+import notification from "@ohos.notification";
+import HiLog from "../utils/HiLog";
+
+const TAG = "MyAbilityStage"
+
+export default class MyAbilityStage extends AbilityStage {
+ onCreate() {
+ HiLog.i(TAG, "AbilityStage onCreate");
+ globalThis.AbilityStageConstant = this.context;
+ notification.enableNotification({
+ bundle: "com.ohos.mms"
+ }, true, (err, data) => {
+ if (err) {
+ HiLog.i(TAG, "enableNotification err: " + JSON.stringify(err));
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/MainAbility/MainAbility.ts b/entry/src/main/ets/MainAbility/MainAbility.ts
new file mode 100644
index 0000000..47056cf
--- /dev/null
+++ b/entry/src/main/ets/MainAbility/MainAbility.ts
@@ -0,0 +1,53 @@
+import Ability from '@ohos.application.Ability'
+import Window from '@ohos.window'
+
+import HiLog from "../utils/HiLog";
+import MmsPreferences from "../utils/MmsPreferences";
+import WantUtil from "../utils/WantUtil"
+import MmsDatabaseHelper from "../utils/MmsDatabaseHelper";
+
+const TAG = "app";
+
+export default class MainAbility extends Ability {
+ onCreate(want, launchParam) {
+ HiLog.i(TAG, "Ability onCreate com.ohos.mms version: 1.0.0.27");
+ globalThis.mmsContext = this.context;
+ globalThis.abilityWant = want;
+ globalThis.MmsDatabaseHelper = new MmsDatabaseHelper();
+ globalThis.MmsDatabaseHelper.createTable();
+ globalThis.needToUpdate = true;
+ MmsPreferences.getInstance().initPreferences();
+
+ WantUtil.getWant();
+ }
+
+ onDestroy() {
+
+ }
+
+ onWindowStageCreate(windowStage: Window.WindowStage) {
+ // Main window is created, set main page for this ability
+ windowStage.loadContent('pages/index', (err, data) => {
+ if (err.code) {
+ HiLog.e(TAG, 'testTag', 'Failed to load the content.');
+ return;
+ }
+ HiLog.i(TAG, 'testTag', 'Succeeded in loading the content. Data: %{public}s');
+ });
+ }
+
+ onWindowStageDestroy() {
+ // Main window is destroyed, release UI related resources
+ HiLog.i(TAG, 'Ability onWindowStageDestroy');
+ }
+
+ onForeground() {
+ // Ability has brought to foreground
+ HiLog.i(TAG, 'Ability onForeground');
+ }
+
+ onBackground() {
+ // Ability has back to background
+ HiLog.i(TAG, 'Ability onBackground');
+ }
+}
diff --git a/entry/src/main/ets/ServiceAbility/service.ts b/entry/src/main/ets/ServiceAbility/service.ts
deleted file mode 100644
index 844015d..0000000
--- a/entry/src/main/ets/ServiceAbility/service.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @file: service entry 服务入口
- */
-
-import MmsManagerService from './MmsManagerService';
-import HiLog from '../default/utils/HiLog';
-
-const TAG = 'service';
-export default {
- /**
- * onStart
- */
- onStart() {
- HiLog.i(TAG, 'onStart');
- this.mmsManagerService = new MmsManagerService();
- },
-
- /**
- * onStop
- */
- onStop() {
- HiLog.i(TAG, 'onStop');
- this.mmsManagerService.unsubscribe();
- }
-};
diff --git a/entry/src/main/ets/ServiceAbility/MmsManagerService.ets b/entry/src/main/ets/StaticSubscriber/MmsStaticSubscriber.ts
similarity index 63%
rename from entry/src/main/ets/ServiceAbility/MmsManagerService.ets
rename to entry/src/main/ets/StaticSubscriber/MmsStaticSubscriber.ts
index 8118656..70a9f31 100644
--- a/entry/src/main/ets/ServiceAbility/MmsManagerService.ets
+++ b/entry/src/main/ets/StaticSubscriber/MmsStaticSubscriber.ts
@@ -12,67 +12,41 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import commonEvent from "@ohos.commonEvent";
+import common from "../data/commonData";
+import mmsTable from "../data/tableData";
+import telephoneUtils from "../utils/TelephoneUtil";
+import HiLog from "../utils/HiLog";
+import particleAbility from "@ohos.ability.particleAbility";
+import MmsDatabaseHelper from "../utils/MmsDatabaseHelper";
+import ohosDataAbility from "@ohos.data.dataAbility";
+import telSim from "@ohos.telephony.sms";
+import ohosDataRdb from "@ohos.data.rdb";
+import commonService from "../service/CommonService";
+import http from "@ohos.net.http";
+import NotificationService from "../service/NotificationService";
+import LooseObject from "../data/LooseObject"
+import dataShare from "@ohos.data.dataShare";
+import dataSharePredicates from "@ohos.data.dataSharePredicates";
+import messageService from "../service/ConversationListService";
-import commonEvent from '@ohos.commonEvent';
-import common from '../default/data/commonData';
-import mmsTable from '../default/data/tableData';
-import telephoneUtils from '../default/utils/TelephoneUtil';
-import HiLog from '../default/utils/HiLog';
-import particleAbility from '@ohos.ability.particleAbility';
-import ohosDataAbility from '@ohos.data.dataAbility';
-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 LooseObject from '../default/data/LooseObject'
-
-// 数据库实例对象
+const TAG = 'MmsStaticSubscriber'
+// database instance object
var rdbStore = undefined;
-const TAG = 'MmsManagerService'
+var StaticSubscriberExtensionAbility = globalThis.requireNapi('application.StaticSubscriberExtensionAbility');
-let commonEventData = null;
+export default class MmsStaticSubscriber extends StaticSubscriberExtensionAbility {
+ onReceiveEvent(data) {
+ HiLog.i(TAG, 'onRecevieEvent, event:' );
+ // Initializing the Database
+ this.initRdb(data)
-export default class MmsManagerService {
- constructor() {
- this.addSubscriberListener();
- // 初始化数据库
- this.initRdb();
- }
-
- /**
- * add mms app subscriber
- */
- async addSubscriberListener() {
- let events = [common.string.SUBSCRIBER_EVENT, common.string.MMS_SUBSCRIBER_EVENT];
- let commonEventSubscribeInfo = {
- events: events
- };
- // 创建订阅信息
- commonEvent.createSubscriber(commonEventSubscribeInfo, this.createSubscriberCallBack.bind(this));
- }
-
- createSubscriberCallBack(err, data) {
- commonEventData = data;
- // 接收到订阅
- commonEvent.subscribe(commonEventData, this.subscriberCallBack.bind(this));
- }
-
- subscriberCallBack(err, data) {
- HiLog.i(TAG, 'subscriberCallBack, err: ' + JSON.stringify(err.message));
- // 短信接收
- if (data.event === common.string.SUBSCRIBER_EVENT) {
- this.dealSmsReceiveData(data);
- } else {
- // 彩信接收
- this.dealMmsReceiveData(data);
- }
}
async dealSmsReceiveData(data) {
- let netType = data.parameters.isCdma ? '3gpp2' : '3gpp';
- // 同步等待操作
+ let netType = data.parameters.isCdma ? "3gpp2" : "3gpp";
+ // Synchronize wait operation
let promisesAll = [];
data.parameters.pdus.forEach(pdu => {
let promise = telSim.createMessage(this.convertStrArray(pdu), netType);
@@ -89,7 +63,7 @@ export default class MmsManagerService {
result.content += shortMessage.visibleMessageBody;
})
}).catch((err) => {
- HiLog.e(TAG, 'dealSmsReceiveData, err: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "dealSmsReceiveData, err: " + JSON.stringify(err.message));
result.code = common.int.FAILURE;
});
await createMessagePromise;
@@ -129,13 +103,13 @@ export default class MmsManagerService {
{
method: http.RequestMethod.GET,
header: {
- 'Content-Type': 'application/json',
+ "Content-Type": "application/json",
},
extraData: baseUrl,
readTimeout: 50000,
connectTimeout: 50000
}, (err, data) => {
- HiLog.i(TAG, 'saveAttachment, err: ' + JSON.stringify(err.message));
+ HiLog.i(TAG, "saveAttachment, err: " + JSON.stringify(err.message));
}
);
}
@@ -146,30 +120,30 @@ export default class MmsManagerService {
if (mmsSource.length === 1) {
let item = mmsSource[0];
switch (item.msgType) {
- // 主题
+ // Subject
case 0:
content = themeContent;
break;
- // 图片
+ // Pictures
case 1:
- content = '(picture)' + themeContent;
+ content = "(picture)" + themeContent;
break;
- // 视频
+ // Video
case 2:
- content = '(video)' + themeContent;
+ content = "(video)" + themeContent;
break;
- // 音频
+ // Audio
case 3:
- content = '(audio)' + themeContent;
+ content = "(audio)" + themeContent;
break;
}
} else {
- content = '(slide)' + mmsSource[0].content;
+ content = "(slide)" + mmsSource[0].content;
}
return content;
}
- // 插入接收到的数据
+ // Insert Received Data
insertMessageDetailBy(param, callback) {
let sendResults = [];
let sendResult = {
@@ -195,11 +169,11 @@ export default class MmsManagerService {
let length = wby.length;
let isDouble = (length % 2) == 0;
let halfSize = parseInt('' + length / 2);
- HiLog.i(TAG, 'convertStrArray, length=' + length + ', isDouble=' + isDouble);
+ HiLog.i(TAG, "convertStrArray, length=" + length + ", isDouble=" + isDouble);
if (isDouble) {
let number0xArray = new Array(halfSize);
for (let i = 0;i < halfSize; i++) {
- number0xArray[i] = '0x' + wby.substr(i * 2, 2);
+ number0xArray[i] = "0x" + wby.substr(i * 2, 2);
}
let numberArray = new Array(halfSize);
for (let i = 0;i < halfSize; i++) {
@@ -209,51 +183,35 @@ export default class MmsManagerService {
} else {
let number0xArray = new Array(halfSize + 1);
for (let i = 0;i < halfSize; i++) {
- number0xArray[i] = '0x' + wby.substr(i * 2, 2);
+ number0xArray[i] = "0x" + wby.substr(i * 2, 2);
}
- number0xArray[halfSize] = '0x' + wby.substr((halfSize * 2) + 1, 1);
+ number0xArray[halfSize] = "0x" + wby.substr((halfSize * 2) + 1, 1);
let numberArray = new Array(halfSize + 1);
for (let i = 0;i < halfSize; i++) {
numberArray[i] = parseInt(number0xArray[i], 16);
}
- let last0x = '0x' + wby.substr(wby.length - 1, 1);
+ let last0x = "0x" + wby.substr(wby.length - 1, 1);
numberArray[halfSize] = parseInt(last0x);
return numberArray;
}
}
- // 取消订阅
- unsubscribe() {
- commonEvent.unsubscribe(commonEventData, () => {
- HiLog.i(TAG, 'unsubscribe success');
- });
- }
+ // Initializing the Database
+ async initRdb(data) {
+ HiLog.i(TAG, "initRdb, createRdbStore start: " );
+ // Creating a Database
+ rdbStore = await ohosDataRdb.getRdbStore(globalThis.AbilityStageConstant,
+ { name: mmsTable.DB.MMSSMS.config.name }, mmsTable.DB.MMSSMS.version);
+ // Creating Database Tables
+ await rdbStore.executeSql(mmsTable.table.session, null);
- // 初始化数据库
- async initRdb() {
- // 创建数据库表
- this.createRdbStore().then(async (ret) => {
- HiLog.i(TAG, 'initRdb, createRdbStore first done: ' + ret);
- await this.createTable(mmsTable.table.session);
- }).catch((err) => {
- HiLog.e(TAG, 'initRdb, createRdbStore error: ' + JSON.stringify(err.message));
- });
- }
+ if (data.event === common.string.SUBSCRIBER_EVENT) {
+ this.dealSmsReceiveData(data);
+ } else {
+ // MMS message receiving
+ this.dealMmsReceiveData(data);
+ }
- /**
- * 创建数据库
- */
- async createRdbStore() {
- HiLog.i(TAG, 'createRdbStore start');
- rdbStore = await ohosDataRdb.getRdbStore(mmsTable.DB.MMSSMS.config, mmsTable.DB.MMSSMS.version);
- HiLog.i(TAG, 'createRdbStore end');
- }
-
- /**
- * 创建数据库表
- */
- async createTable(table) {
- await rdbStore.executeSql(table, null);
}
insertSessionAndDetail(actionData, callback) {
@@ -264,11 +222,11 @@ export default class MmsManagerService {
}
let value = this.dealSendResults(sendResults);
- // 先判断是否创建过会话列表
+ // Check whether a session list has been created.
this.querySessionByTelephone(value.telephone, res => {
- HiLog.i(TAG, 'insertSessionAndDetail, querySessionByTelephone code=' + res.code);
+ HiLog.i(TAG, " insertSessionAndDetail, querySessionByTelephone code=" + res.code);
let response = res.response;
- HiLog.i(TAG, 'insertSessionAndDetail, querySessionByTelephone response.id=' + response.id);
+ HiLog.i(TAG, " insertSessionAndDetail, querySessionByTelephone response.id=" + response.id);
if (res.code == common.int.SUCCESS && response.id <= 0) {
this.insertNoExitingSession(isReceive, value, actionData, callback);
} else {
@@ -283,20 +241,20 @@ export default class MmsManagerService {
unreadCount = 1;
}
let valueBucket = {
- 'telephone': value.telephone,
- 'content': value.content,
- 'contacts_num': value.contractsNum,
- 'sms_type': value.smsType,
- 'unread_count': unreadCount,
- 'sending_status': value.sendStatus,
- 'has_draft': 0,
- 'time': value.timestamp,
- 'message_count': 1,
- 'has_mms': actionData.isMms ? 1 : 0,
- 'has_attachment': actionData.hasAttachment ? 1 : 0
+ "telephone": value.telephone,
+ "content": value.content,
+ "contacts_num": value.contractsNum,
+ "sms_type": value.smsType,
+ "unread_count": unreadCount,
+ "sending_status": value.sendStatus,
+ "has_draft": 0,
+ "time": value.timestamp,
+ "message_count": 1,
+ "has_mms": actionData.isMms ? 1 : 0,
+ "has_attachment": actionData.hasAttachment ? 1 : 0
}
this.insertSession(valueBucket, res => {
- // 这里调用短信数据库,插入短信信息
+ // Invoke the SMS database to insert SMS messages.
this.dealInsertMessageDetail(value, actionData, res.rowId, initDatas => {
let result = {
rowId: res.rowId,
@@ -309,28 +267,28 @@ export default class MmsManagerService {
insertExitingSession(response, param, actionData, callback) {
let sessionId = response.id;
- // 这里调用短信数据库,插入短信信息
+ // Invoke the SMS database to insert SMS messages.
let threadIds = [sessionId];
let time = new Date();
let unreadCount = 0;
- if(actionData.isReceive) {
+ if (actionData.isReceive) {
unreadCount = response.unreadCount;
unreadCount = unreadCount + 1;
}
let messageCount = response.messageCount;
messageCount = messageCount + 1;
let valueBucket = {
- 'content': param.content,
- 'unread_count': unreadCount,
- 'time': time.getTime(),
- 'sending_status': param.sendStatus,
- 'message_count': messageCount,
- 'has_mms': actionData.isMms ? 1 : 0,
- 'has_draft': 0,
- 'has_attachment': actionData.hasAttachment ? 1 : 0
+ "content": param.content,
+ "unread_count": unreadCount,
+ "time": time.getTime(),
+ "sending_status": param.sendStatus,
+ "message_count": messageCount,
+ "has_mms": actionData.isMms ? 1 : 0,
+ "has_draft": 0,
+ "has_attachment": actionData.hasAttachment ? 1 : 0
};
this.updateById(threadIds, valueBucket, res => {
- // 这里调用短信数据库,插入短信信息
+ // Invoke the SMS database to insert SMS messages.
this.dealInsertMessageDetail(param, actionData, sessionId, initDatas => {
let result = {
rowId: sessionId,
@@ -349,78 +307,82 @@ export default class MmsManagerService {
result.response = res[0];
callback(result);
}).catch((err) => {
- HiLog.e(TAG, 'querySessionByTelephone, error: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "querySessionByTelephone, error: " + JSON.stringify(err.message));
result.code = common.int.FAILURE;
callback(result);
});
}
- // 根据手机号,获取会话列表
+ // Obtains the session list based on the mobile number.
async querySessionByTelephoneRdb(telephone) {
- HiLog.i(TAG, 'querySessionByTelephoneRdb');
- // 创建查询条件对象
- let predicates = new ohosDataRdb.RdbPredicates(common.tableName.SESSION);
- // 如果为空,查询所有的列表数据
+ HiLog.i(TAG, "querySessionByTelephoneRdb" + JSON.stringify(telephone));
+ // Creating a query condition object
+ let predicates = new ohosDataRdb.RdbPredicates(MmsDatabaseHelper.TABLE.SESSION);
+ // If this parameter is left blank, all list data is queried.
if (telephone) {
await predicates.equalTo(mmsTable.sessionField.telephone, telephone);
}
- // 获取到结果集
+ // Obtain the result set.
let resultSet = await rdbStore.query(predicates);
- // 获取第一条
+ // Obtain the first entry.
resultSet.goToFirstRow();
let result: LooseObject = {};
- result.id = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.id));
- result.time = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.time));
+ result.id = await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.id)));
+ result.time = await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.time)));
result.telephone = await resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.telephone));
result.content = await resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.content));
- result.contactsNum = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.contactsNum));
- result.smsType = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.smsType));
- result.unreadCount = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.unreadCount));
- result.sendStatus = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.sendStatus));
- result.hasDraft = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.hasDraft));
- result.messageCount = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.messageCount));
+ result.contactsNum =
+ await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.contactsNum)));
+ result.smsType = await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.smsType)));
+ result.unreadCount =
+ await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.unreadCount)));
+ result.sendStatus =
+ await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.sendStatus)));
+ result.hasDraft = await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.hasDraft)));
+ result.messageCount =
+ await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.messageCount)));
return result;
}
- // 插入
+ // insert
insertSession(valueBucket, callback) {
- this.insertSessionRdb(common.tableName.SESSION, valueBucket, callback);
+ this.insertSessionRdb(valueBucket, callback);
}
- insertSessionRdb(tableName, valueBucket, callback) {
- HiLog.i(TAG, 'insertSessionRdb');
- let insertPromise = rdbStore.insert(tableName, valueBucket);
+ insertSessionRdb(valueBucket, callback) {
+ HiLog.i(TAG, "insert session rdb 123");
+ let insertPromise = rdbStore.insert(MmsDatabaseHelper.TABLE.SESSION, valueBucket);
let result: LooseObject = {};
insertPromise.then((ret) => {
- HiLog.i(TAG, 'insertSessionRdb, rowId: ' + ret);
+ HiLog.i(TAG, "insert session rdb rowId: " + ret);
result.code = common.int.SUCCESS;
result.rowId = ret;
callback(result);
}).catch((err) => {
- HiLog.e(TAG, 'insertSessionRdb, error: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "insert session rdb error: " + JSON.stringify(err.message));
result.code = common.int.FAILURE;
callback(result);
});
}
/**
- * 新增数据
+ * New data
*/
async insert(tableName, valueBucket) {
let promise = await rdbStore.insert(tableName, valueBucket);
let rowId = 0;
promise.then((ret) => {
rowId = ret;
- HiLog.i(TAG, 'insert, first success: ' + rowId);
+ HiLog.i(TAG, "insert, first success: " + rowId);
}).catch((err) => {
- HiLog.e(TAG, 'insert, err: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "insert, err: " + JSON.stringify(err.message));
})
await promise;
return rowId;
}
dealInsertMessageDetail(param, actionData, threadId, callback) {
- // 获取到最大的groupId
+ // Get the largest groupId
this.queryMaxGroupId(actionData, res => {
let maxGroupId = res == common.string.EMPTY_STR ? 0 : parseInt(res);
maxGroupId = maxGroupId + 1;
@@ -454,7 +416,7 @@ export default class MmsManagerService {
}
this.insertMessageDetail(insertDetail, result => {
count++;
- HiLog.i(TAG, 'insertMessageDetailByGroupId, result: ' + result);
+ HiLog.i(TAG, "insertMessageDetailByGroupId, result: " + result);
let initData = {
id: result,
telephone: sendResult.telephone
@@ -471,7 +433,7 @@ export default class MmsManagerService {
let contractsNum = sendResults.length;
let telephone = common.string.EMPTY_STR;
let content = common.string.EMPTY_STR;
- // 发送成功
+ // Sending succeeded.
let sendStatus = 0;
for (let sendResult of sendResults) {
telephone = telephone + sendResult.telephone + common.string.COMMA;
@@ -499,30 +461,30 @@ export default class MmsManagerService {
let time = new Date();
let timeStr = time.getTime() + common.string.EMPTY_STR;
var stringValue = {
- 'receiver_number': value.receiverNumber,
- 'sender_number': value.senderNumber,
- 'start_time': timeStr,
- 'end_time': timeStr,
- 'msg_type': value.isMms ? '1' : '0',
- 'sms_type': value.smsType,
- 'msg_title': value.content,
- 'msg_content': value.content,
- 'msg_state': value.sendStatus,
- 'operator_service_number': common.string.EMPTY_STR,
- 'msg_code': common.string.EMPTY_STR,
- 'session_id': value.threadId,
- 'is_lock': '0',
- 'is_read': value.isRead,
- 'is_collect': '0',
- 'session_type': value.sessionType,
- 'is_subsection': '0',
- 'is_sender': value.isSender,
- 'is_send_report': 0,
- 'group_id': value.groupId
+ "receiver_number": value.receiverNumber,
+ "sender_number": value.senderNumber,
+ "start_time": timeStr,
+ "end_time": timeStr,
+ "msg_type": value.isMms ? "1" : "0",
+ "sms_type": value.smsType,
+ "msg_title": value.content,
+ "msg_content": value.content,
+ "msg_state": value.sendStatus,
+ "operator_service_number": common.string.EMPTY_STR,
+ "msg_code": common.string.EMPTY_STR,
+ "session_id": value.threadId,
+ "is_lock": "0",
+ "is_read": value.isRead,
+ "is_collect": "0",
+ "session_type": value.sessionType,
+ "is_subsection": "0",
+ "is_sender": value.isSender,
+ "is_send_report": 0,
+ "group_id": value.groupId
};
actionData.stringValue = stringValue;
this.insertMessageDetailRdb(actionData, msgId => {
- HiLog.i(TAG, 'insertMessageDetail, msgId: ' + msgId);
+ HiLog.i(TAG, "insertMessageDetail, msgId: " + msgId);
if (value.isMms) {
value.msgId = msgId;
this.batchInsertMmsPart(value);
@@ -535,54 +497,54 @@ export default class MmsManagerService {
let bacthmsParts = [];
for (let source of value.mmsSource) {
let stringValue = {
- 'msg_id': value.msgId,
- 'group_id': value.groupId,
- 'type': source.msgType,
- 'location_path': source.msgUriPath,
- 'content': source.content,
- 'recording_time': source.time,
- 'part_size': source.fileSize
+ "msg_id": value.msgId,
+ "group_id": value.groupId,
+ "type": source.msgType,
+ "location_path": source.msgUriPath,
+ "content": source.content,
+ "recording_time": source.time,
+ "part_size": source.fileSize
};
bacthmsParts.push(stringValue);
}
- for(let stringValue of bacthmsParts) {
+ for (let stringValue of bacthmsParts) {
this.insertMmsPart(stringValue);
}
}
async insertMmsPart(stringValue) {
- let dataAbilityHelper = await particleAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = particleAbility.acquireDataAbilityHelper(this.context, common.string.URI_MESSAGE_LOG);
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_MMS_PART;
dataAbilityHelper.insert(managerUri, stringValue).then(data => {
}).catch(error => {
- HiLog.e(TAG, 'insertMmsPart, fail: ' + JSON.stringify(error.meaasge));
+ HiLog.e(TAG, "insertMmsPart, fail: " + JSON.stringify(error.meaasge));
});
}
- // 插入单个短信信息
+ // Inserting a single SMS message
async insertMessageDetailRdb(actionData, callback) {
- // 获取DataAbilityHelper对象
+ // Obtains the DataAbilityHelper object.
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
- let dataAbilityHelper = await particleAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = particleAbility.acquireDataAbilityHelper(this.context, common.string.URI_MESSAGE_LOG);
let promise = dataAbilityHelper.insert(managerUri, actionData.stringValue);
await promise.then(data => {
callback(data);
}).catch(error => {
- HiLog.e(TAG, 'insertMessageDetailRdb, fail: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "insertMessageDetailRdb, fail: " + JSON.stringify(error.message));
});
}
/**
- * 根据主键ID,更新数据
- * @param threadIds 会话ID
+ * Update data based on the primary key ID.
+ * @param threadIds Session ID
* @return
*/
async updateById(threadIds, valueBucket, callback) {
- HiLog.i(TAG, 'updateById, threadIds: ' + JSON.stringify(threadIds));
+ HiLog.i(TAG, "updateById, threadIds: " + JSON.stringify(threadIds));
if (threadIds.length != 0) {
for (let threadId of threadIds) {
- // 创建查询条件对象
- let predicates = new ohosDataRdb.RdbPredicates(common.tableName.SESSION);
+ // Creating a query condition object
+ let predicates = new ohosDataRdb.RdbPredicates(MmsDatabaseHelper.TABLE.SESSION);
await predicates.equalTo(mmsTable.sessionField.id, threadId);
this.update(predicates, valueBucket, res => {
callback(res);
@@ -593,9 +555,9 @@ export default class MmsManagerService {
}
/**
- * 更新接口
- * @param predicates 更新条件
- * @param predicates 更新值
+ * Update Interface
+ * @param predicates Update Condition
+ * @param predicates Update Value
* @return
*/
async update(predicates, valueBucket, callback) {
@@ -604,34 +566,34 @@ export default class MmsManagerService {
}
/**
- * 查询最大的groupId
- * @param actionData 参数
- * @param callBack 回调
+ * Query the maximum group ID.
+ * @param actionData
+ * @param callBack
* @return
*/
queryMaxGroupId(actionData, callBack) {
this.queryMaxGroupIdDb(actionData, res => {
- HiLog.i(TAG, 'queryMaxGroupId, callback');
+ HiLog.i(TAG, "queryMaxGroupId, callback");
callBack(res.maxGroupId);
});
}
- // 获取最大的groupId
+ // Get the largest groupId
async queryMaxGroupIdDb(actionData, callback) {
- let dataAbilityHelper = await particleAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = particleAbility.acquireDataAbilityHelper(this.context, common.string.URI_MESSAGE_LOG);
let resultColumns = [
- 'maxGroupId'
+ "maxGroupId"
];
let condition = new ohosDataAbility.DataAbilityPredicates();
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_MAX_GROUP;
- dataAbilityHelper.query(managerUri, resultColumns, condition, (err, resultSet) => {
+ dataAbilityHelper.query(managerUri, resultColumns, condition).then( resultSet => {
let result: LooseObject = {};
while (resultSet.goToNextRow()) {
result.maxGroupId = resultSet.getString(0);
}
callback(result);
}).catch(error => {
- HiLog.e(TAG, 'queryMaxGroupIdDb, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "queryMaxGroupIdDb, error: " + JSON.stringify(error.message));
});
}
@@ -639,13 +601,14 @@ export default class MmsManagerService {
* commonEvent publish data
*/
publishData(telephone, content) {
- HiLog.i(TAG, 'publishData, start');
+ HiLog.i(TAG, "publishData, start");
let actionData = {
telephone: telephone,
content: content
};
commonEvent.publish(common.string.RECEIVE_TRANSMIT_EVENT, {
bundleName: common.string.BUNDLE_NAME,
+ subscriberPermissions: ['ohos.permission.RECEIVE_SMS'],
isOrdered: false,
data: JSON.stringify(actionData)
}, (res) => {
@@ -655,10 +618,10 @@ export default class MmsManagerService {
async sendNotification(telephone, msgId, content) {
let telephones = [telephone];
this.queryContactDataByTelephone(telephones, async (contracts) => {
- HiLog.i(TAG, 'sendNotification, callback');
+ HiLog.i(TAG, "sendNotification, callback");
let actionData = this.dealContactParams(contracts, telephone);
if (content.length > 15) {
- content = content.substring(0, 15) + '...';
+ content = content.substring(0, 15) + "...";
}
let message = {
title: content,
@@ -666,14 +629,24 @@ export default class MmsManagerService {
};
actionData.message = message;
actionData.msgId = msgId;
- NotificationService.getInstance().sendNotify(actionData);
+ actionData.unreadTotal = 0;
+ let params: LooseObject = {
+ mmsContext: this.context
+ };
+ messageService.statisticalData(params, function (res) {
+ if (res.code == common.int.SUCCESS) {
+ actionData.unreadTotal= res.response.totalListCount;
+ HiLog.i(TAG, "sendNotification, callback actionData");
+ }
+ NotificationService.getInstance().sendNotify(actionData);
+ });
});
}
dealContactParams(contracts, telephone) {
let actionData: LooseObject = {};
let params = [];
- if(contracts.length == 0) {
+ if (contracts.length == 0) {
params.push({
telephone: telephone,
});
@@ -694,12 +667,13 @@ export default class MmsManagerService {
mmsTable.contactDataColumns.detailInfo,
mmsTable.contactDataColumns.displayName,
];
- let contactDataAbilityHelper = await particleAbility.acquireDataAbilityHelper(common.string.URI_ROW_CONTACTS);
+ let contactDataAbilityHelper =
+ particleAbility.acquireDataAbilityHelper(this.context, common.string.URI_ROW_CONTACTS);
let condition = new ohosDataAbility.DataAbilityPredicates();
let contactDataUri = common.string.URI_ROW_CONTACTS + common.string.CONTACT_DATA_URI;
condition.in(mmsTable.contactDataColumns.detailInfo, telephones);
condition.and();
- condition.equalTo(mmsTable.contactDataColumns.typeId, '5');
+ condition.equalTo(mmsTable.contactDataColumns.typeId, "5");
contactDataAbilityHelper.query(contactDataUri, resultColumns, condition).then(resultSet => {
let contracts = [];
while (resultSet.goToNextRow()) {
@@ -711,7 +685,9 @@ export default class MmsManagerService {
}
callback(contracts);
}).catch(error => {
- HiLog.e(TAG, 'queryContactDataByTelephone error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "queryContactDataByTelephone error: " + JSON.stringify(error.message));
});
}
-}
\ No newline at end of file
+
+
+}
diff --git a/entry/src/main/ets/default/data/LooseObject.ets b/entry/src/main/ets/data/LooseObject.ets
similarity index 96%
rename from entry/src/main/ets/default/data/LooseObject.ets
rename to entry/src/main/ets/data/LooseObject.ets
index f548ca5..1b10b27 100644
--- a/entry/src/main/ets/default/data/LooseObject.ets
+++ b/entry/src/main/ets/data/LooseObject.ets
@@ -14,5 +14,5 @@
*/
export default interface LooseObject {
- [key: string]: any
+ [key: string]: any
}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/data/MmsBoolean.ets b/entry/src/main/ets/data/MmsBoolean.ets
similarity index 81%
rename from entry/src/main/ets/default/data/MmsBoolean.ets
rename to entry/src/main/ets/data/MmsBoolean.ets
index 7ee537d..3410c3e 100644
--- a/entry/src/main/ets/default/data/MmsBoolean.ets
+++ b/entry/src/main/ets/data/MmsBoolean.ets
@@ -14,11 +14,13 @@
*/
/**
- * Observed参数需要自定义类,不能是基础类型,所以新增一个Boolean自定义类
+ * The reserved parameter needs to be a user-defined class and cannot be a basic type. Therefore, a user-defined
+ * Boolean class is added.
*/
@Observed
export default class MmsBoolean {
- public value : boolean;
+ public value: boolean;
+
constructor(v: boolean) {
this.value = v;
}
diff --git a/entry/src/main/ets/default/data/Pasteboard.ets b/entry/src/main/ets/data/Pasteboard.ets
similarity index 84%
rename from entry/src/main/ets/default/data/Pasteboard.ets
rename to entry/src/main/ets/data/Pasteboard.ets
index a44a127..69672fb 100644
--- a/entry/src/main/ets/default/data/Pasteboard.ets
+++ b/entry/src/main/ets/data/Pasteboard.ets
@@ -13,10 +13,10 @@
* limitations under the License.
*/
-import pasteboard from '@ohos.pasteboard';
-import HiLog from '../Utils/HiLog';
+import pasteboard from "@ohos.pasteboard";
+import HiLog from "../utils/HiLog";
-const TAG = 'Pasteboard';
+const TAG = "Pasteboard";
let commonPasteboard = {
getPasteboard() {
let sysPasteboard = pasteboard.getSystemPasteboard();
@@ -26,8 +26,9 @@ let commonPasteboard = {
let sysPasteboard = pasteboard.getSystemPasteboard();
let textData = pasteboard.createPlainTextData(text);
sysPasteboard.setPasteData(textData, () => {
- HiLog.i(TAG, 'setPasteboard done');
+ HiLog.i(TAG, "setPasteboard done");
});
}
};
-export {commonPasteboard};
\ No newline at end of file
+
+export { commonPasteboard };
\ No newline at end of file
diff --git a/entry/src/main/ets/data/commonData.ets b/entry/src/main/ets/data/commonData.ets
new file mode 100644
index 0000000..44340d3
--- /dev/null
+++ b/entry/src/main/ets/data/commonData.ets
@@ -0,0 +1,278 @@
+/**
+ * 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.
+ */
+
+export default {
+ bool: {
+ TRUE: "1",
+ FALSE: "0",
+ },
+ route: {
+ // Update the value of the delivery report switch.
+ MESSAGE_CODE_UPDATE_DELIVERY_REPORTS_VALUE: 32001,
+ // Update the value of the function of automatically downloading MMS messages.
+ MESSAGE_CODE_UPDATE_AUTO_RETRIEVE_MMS_VALUE: 32002,
+ // Update the value of the send cancel switch.
+ MESSAGE_CODE_UPDATE_RECALL_MESSAGES_VALUE: 32003,
+ // Update the value of the switch for automatically deleting notification information.
+ MESSAGE_CODE_UPDATE_AUTO_DELETE_INFO_MESSAGES_VALUE: 32004,
+ // Update the value of the notification integration switch.
+ MESSAGE_CODE_UPDATE_ARCHIVE_INFO_MESSAGES_VALUE: 30002,
+ // Update the value of the malicious URL identification switch.
+ MESSAGE_CODE_UPDATE_MALICIOUS_WEBSITE_IDENTIFICATION_VALUE: 30003,
+ // Updates the value of the switch for displaying contact avatars.
+ MESSAGE_CODE_UPDATE_SHOW_CONTACT_PROFILE_PICS_VALUE: 30004,
+ // Restore the value of the advanced page switch.
+ MESSAGE_CODE_RESTORE_ADVANCED_PAGE_SWITCH_VALUE: 30005
+ },
+ int: {
+ // status code
+ SUCCESS: 0,
+ FAILURE: -1,
+ // CheckBox select status code 1. Select all. 2. Do not select all. 3. Unknown.
+ CHECKBOX_SELECT_ALL: 1,
+ // None
+ CHECKBOX_SELECT_NONE: 2,
+ // Unknown
+ CHECKBOX_SELECT_UNKNOWN: 3,
+ MESSAGE_CODE_TWENTY_FIVE: 60,
+ MESSAGE_CODE_THREE_FOUR_ZERO: 660,
+ // Text
+ TYPE_TEXT: 0,
+ // Pictures
+ TYPE_IMAGE: 1,
+ // Audio
+ TYPE_AUDIO: 2,
+ // Video
+ TYPE_VIDEO: 3,
+ // 0
+ MESSAGE_CODE_ZERO: 0,
+ // 1
+ MESSAGE_CODE_ONE: 1,
+ // 2
+ MESSAGE_CODE_TWO: 2,
+ // 300
+ MESSAGE_CODE_THREE_ZERO_ZERO: 300,
+ // 1000
+ MESSAGE_CODE_THOUSAND: 1000,
+ // The SMS message is sent successfully.
+ SEND_MESSAGE_SUCCESS: 0,
+ // Sending
+ SEND_MESSAGE_SENDING: 1,
+ // Failed to send the SMS message.
+ SEND_MESSAGE_FAILED: 2,
+ // Draft Data Type
+ SEND_DRAFT: 3,
+ // Width of the left slide control of the list
+ OPERATE_DELETE_WIDTH: 80,
+ OPERATE_UNREAD_WIDTH: 128,
+ // Number of SIM cards
+ SIM_COUNT: 2,
+ // sim card 1
+ SIM_ONE: 0,
+ // sim card2
+ SIM_TWO: 1,
+ // 550 Default Height
+ TAB_HEIGHT: 550,
+ // 550+720tab Full screen height
+ FULL_HEIGHT: 550 + 720,
+ // Cancel SMS Countdown
+ CANCEL_TIME_COUNT: 6,
+ // Number of words in full screen
+ FULL_SCREEN_SEND_LENGTH: 38,
+ },
+ string: {
+ SMS_TYPE: "0",
+ // Empty String
+ EMPTY_STR: '',
+ // comma
+ COMMA: ",",
+ // bundleName
+ BUNDLE_NAME: "com.ohos.mms",
+ // abilityName
+ ABILITY_NAME: "com.ohos.mms.MainAbility",
+ // BundleName of a contact.
+ CONTRACT_BUNDLE_NAME: "com.ohos.contacts",
+ // contact AbilityName
+ CONTRACT_ABILITY_NAME: "com.ohos.contacts.MainAbility",
+ // Public entity
+ COMMON_ENTITIES: "entity.system.home",
+ // Processing succeeded.
+ SUCCESS: "success",
+ // Storage path of the lightweight preference database
+ PATH_OF_PREFERENCES: "/PREFERENCES_FOR_MMS",
+ // Notification information integration
+ KEY_OF_INTEGRATION_SWITCH: "integrationSwitch",
+ // Malicious Website Identification
+ KEY_OF_MALICIOUS_WEB_SWITCH: "maliciousWebSwitch",
+ // Display contact avatar
+ KEY_OF_SHOW_CONTACT_SWITCH: "showContactSwitch",
+ // Delivery Report
+ KEY_OF_DELIVERY_REPORT_SWITCH: "deliveryReportSwitch",
+ // Automatically downloading MMs
+ KEY_OF_AUTO_RETRIEVE_SWITCH: "autoRetrieveMmsSwitch",
+ // Cancel Sending
+ KEY_OF_RECALL_MESSAGE_SWITCH: "recallMessageSwitch",
+ // Automatically delete notification information
+ KEY_OF_AUTO_DELETE_INFO_SWITCH: "autoDeleteInfoSwitch",
+ // Number of SIM cards
+ KEY_OF_SIM_COUNT: "simCount",
+ // Carrier name of SIM card 1
+ KEY_OF_SIM_0_SPN: "simSpn0",
+ // Carrier name of SIM card 2
+ KEY_OF_SIM_1_SPN: "simSpn1",
+ // Whether SIM card 1 exists
+ KEY_OF_SIM_0_EXIST_FLAG: "simExistFlag0",
+ // Whether SIM card 2 exists
+ KEY_OF_SIM_1_EXIST_FLAG: "simExistFlag1",
+ // If the SMSC number of SIM card 1 is changed, the new SMSC number is changed.
+ KEY_OF_NEW_SIM_0_SMSC: "newSimSmsc0",
+ // If the SMSC number of SIM card 2 is changed, the new SMSC number is changed.
+ KEY_OF_NEW_SIM_1_SMSC: "newSimSmsc1",
+ // Mobile number of the SIM card
+ KEY_OF_SIM_0_NUMBER: "sim_0_number",
+ KEY_OF_SIM_1_NUMBER: "sim_1_number",
+ // Events for Subscribing to Notifications usual.event.SMS_RECEIVE_COMPLETED
+ SUBSCRIBER_EVENT: "usual.event.SMS_RECEIVE_COMPLETED",
+ // Receiving and forwarding
+ RECEIVE_TRANSMIT_EVENT: "usual.event.RECEIVE_COMPLETED_TRANSMIT",
+ // MMS message receiving event
+ MMS_SUBSCRIBER_EVENT: "usual.event.MMS_RECEIVE_COMPLETED",
+ // Contact database
+ URI_ROW_CONTACTS: "dataability:///com.ohos.contactsdataability",
+ // Contact Information
+ CONTACT_DATA_URI: "/contacts/contact_data",
+ // Business Card Contact
+ PROFILE_DATA_URI: "/profile/raw_contact",
+ // Querying Contacts
+ CONTACT_SEARCHE: "/contacts/search_contact",
+ // Contact Information
+ CONTACT_URI: "/contacts/contact",
+ // SMS database
+ URI_MESSAGE_LOG: "dataability:///com.ohos.smsmmsability",
+ // Querying SMs
+ URI_MESSAGE_INFO_TABLE: "/sms_mms/sms_mms_info",
+ // Statistic
+ URI_MESSAGE_UNREAD_COUNT: "/sms_mms/sms_mms_info/unread_total",
+ // Get the largest groupID
+ URI_MESSAGE_MAX_GROUP: "/sms_mms/sms_mms_info/max_group",
+ // Querying MMS Messages
+ URI_MESSAGE_MMS_PART: "/sms_mms/mms_part",
+ AUDIO_NAME: "recording2021111512454545.amr",
+ // MMSC
+ MMS_URL: "http://mmsc.monternet.com"
+ },
+ DELIVERY_REPORTS: {
+ // Closed
+ DISABLED: "0",
+ // SMS
+ SMS: "1",
+ // MMS
+ MMS: "2",
+ // SMS and MMS
+ SMS_AND_MMS: "3"
+ },
+ AUTO_RETRIEVE_MMS: {
+ // OFF
+ OFF: "0",
+ // Non-roaming
+ NOT_WHEN_ROAMING: "1",
+ // All networks
+ ALWAYS: "2"
+ },
+ SPN_CHINA: {
+ // TELECOM
+ TELECOM: "中国电信",
+ // MOBILE
+ MOBILE: "CMCC",
+ // UNICOM
+ UNICOM: "China Unicom",
+ },
+ contractPage: {
+ // Go to New Contact
+ PAGE_FLAG_SAVE_CONTACT: "page_flag_save_contact",
+ // Edit Before Call
+ PAGE_FLAG_EDIT_BEFORE_CALLING: "page_flag_edit_before_calling",
+ // Save to Existing Contacts
+ PAGE_FLAG_SAVE_EXIST_CONTACT: "page_flag_save_exist_contact",
+ // The page for selecting a contact is displayed after an SMS message is sent.
+ PAGE_FLAG_SINGLE_CHOOSE: "page_flag_single_choose",
+ // Select Contact List Page
+ PAGE_FLAG_CHOOSE_CONTACTS: "page_flag_choose_contacts",
+ // Contact details page
+ PAGE_FLAG_CONTACT_DETAILS: "page_flag_contact_details",
+ // The My Business Card page is displayed.
+ PAGE_FLAG_CALLING_CARD: "page_flag_card_details",
+ // Querying MMS Data
+ URI_MESSAGE_MMS_PART: "/sms_mms/mms_part"
+ },
+ MESSAGE_TAB_INDEX: {
+ TAB_CAMERA: 0,
+ TAB_PICTURE: 1,
+ TAB_AUDIO: 2,
+ TAB_MORE: 3
+ },
+ HIGHLIGHT_TYPE: {
+ // Common data
+ NORMAL: 0,
+ // email
+ EMAIL: 1,
+ // Website
+ URL: 2,
+ // Telephone
+ TEL: 3,
+ // Time
+ DATE: 4,
+ // Verification Code
+ NUM: 5
+ },
+ MESSAGE_TYPE: {
+ // General Information
+ NORMAL: 0,
+ // theme
+ THEME: 1,
+ // slideshow
+ PPT: 2,
+ // Themes and Slides
+ THEME_AND_PPT: 3,
+ },
+ MESSAGE_SHOW_TYPE: {
+ // Common SM style
+ NORMAL: 0,
+ // Does not contain the picture theme style
+ THEME_NO_IMAGE: 1,
+ // Does not include picture slide styles
+ PPT_NO_IMAGE: 2,
+ // Slideshow Styles with Pictures
+ PPT_IMAGE: 3,
+ // Include Image Theme Styles
+ THEME_IMAGE: 4
+ },
+ MSG_ITEM_TYPE: {
+ THEME: 0,
+ IMAGE: 1,
+ VIDEO: 2,
+ AUDIO: 3,
+ TEXT: 4,
+ CARD: 5
+ },
+ TRANSMIT_ITEM_HEIGHT: {
+ TEXT_HEIGHT: 150,
+ THEME_HEIGHT: 200,
+ THEME_IMAGE_HEIGHT: 300,
+ PPT_IMAGE_HEIGHT: 220,
+ DISTANCE: 20,
+ TOTAL_HEIGHT: 650
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/data/tableData.ets b/entry/src/main/ets/data/tableData.ets
new file mode 100644
index 0000000..bf7bdc6
--- /dev/null
+++ b/entry/src/main/ets/data/tableData.ets
@@ -0,0 +1,156 @@
+/**
+ * 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.
+ */
+export default {
+ DB: {
+ MMSSMS: {
+ config: {
+ name: "mmssms.db"
+ },
+ version: 1
+ }
+ },
+ table: {
+ // Session table
+ session:
+ "CREATE TABLE IF NOT EXISTS session (" +
+ "id INTEGER PRIMARY KEY AUTOINCREMENT, " +
+ "time INTEGER DEFAULT 0, " +
+ "telephone TEXT, " +
+ "content TEXT, " +
+ "contacts_num INTEGER DEFAULT 0, " +
+ "sms_type INTEGER DEFAULT 0, " +
+ "unread_count INTEGER DEFAULT 0, " +
+ "sending_status INTEGER DEFAULT 0, " +
+ "has_draft INTEGER DEFAULT 0," +
+ "has_lock INTEGER DEFAULT 0," +
+ "message_count INTEGER DEFAULT 0," +
+ "has_mms INTEGER DEFAULT 0," +
+ "has_attachment INTEGER DEFAULT 0" +
+ ");",
+ },
+ // Name of the field corresponding to the session list
+ sessionField: {
+ id: "id", //session Table id integer
+ time: "time", // Last SMS message time integer
+ telephone: "telephone", //Phone number TEXT
+ content: "content", // SMS message content TEXT
+ contactsNum: "contacts_num", // Number of Contacts integer
+ smsType: "sms_type", //Sms Type 0-Common,1-Notice integer
+ unreadCount: "unread_count", // Number of unread SMs integer
+ sendStatus: "sending_status", // Sending success status 0:Success ,1 :Fail , 2 : Sending... integer
+ hasDraft: "has_draft", //Whether there is a draft 0: no, 1:have integer
+ hasLock: "has_lock", // Whether there is a lock 0: no, 1:have integer
+ messageCount: "message_count", //Total number of messages integer
+ hasMms: "has_mms", //Whether there is a new message 0: no, 1:have integer
+ hasAttachment: "has_attachment" //Whether there are attachments 0: no, 1:have integer
+ },
+ // Name of the field corresponding to the SMS message details.
+ messageInfo: {
+ msgId: "msg_id", //sms_mms_info Table id integer
+ receiverNumber: "receiver_number", //Recipient number TEXT
+ senderNumber: "sender_number", //Sender number TEXT
+ startTime: "start_time", //Start Time TEXT
+ endTime: "end_time", //End Time TEXT
+ msgType: "msg_type", //Message Type 0 Subject、1 Pictures、2 Video、3 Audio、4 Text、5 business card integer
+ smsType: "sms_type", //SM Type 0-Common,1-Notice integer
+ msgTitle: "msg_title", //Message Title TEXT
+ msgContent: "msg_content", //Message content TEXT
+ msgState: "msg_state", //Message Status 0:Success ,1 :fail , 2 : Sending... integer
+ operatorServiceNumber: "operator_service_number", //Operator service number TEXT
+ msgCode: "msg_code", //Message Code integer
+ isLock: "is_lock", //Locked 0-No,1-Yes integer
+ isRead: "is_read", // Read or Not 0-Read,1-Unread integer
+ isCollect: "is_collect", //Favorites 0-Not favorited,1-Favorites integer
+ sessionType: "session_type", //Session Type 0 - Common 1 - broadcast 2 - Group Sending integer
+ retryNumber: "retry_number", //Retry Times integer
+ isSubsection: "is_subsection", //Branch 0 - NO 1 - Yes integer
+ sessionId: "session_id", //Session ID integer
+ groupId: "group_id", //Group ID integer
+ isSender: "is_sender", //Sender or Not 0 - Recipient 1 - Sender integer
+ isSendReport: "is_send_report" //Whether to send a report 0 - No 1 - Yes integer
+ },
+ contactColumns: {
+ id: "id", // raw_contact_table id
+ displayName: "display_name", // Display Name
+ contactedCount: "contacted_count", // Number of Contacts
+ lastestContactedTime: "lastest_contacted_time", // Last Contact Time
+ },
+ contactDataColumns: {
+ id: "id", // raw_contact_table id
+ contactId: "contact_id", // raw_contact_table id
+ detailInfo: "detail_info",
+ typeId: "type_id", // raw_contact_table id
+ contentType: "content_type", // raw_contact_table id
+ displayName: "display_name", // Display Name
+ hasDelete: "is_deleted" // hasDelete
+ },
+ searchContactView: {
+ searchName: "search_name",
+ contactId: "contact_id",
+ detailInfo: "detail_info",
+ contentType: "content_type",
+ displayName: "display_name", // Display Name
+ hasDelete: "is_deleted" // hasDelete
+ },
+ // Saving MMS data
+ mmsPart: {
+ msgId: "msg_id", //mms_part table id integer
+ groupId: "group_id", // Group ID integer
+ type: "type", // 0: theme; 1: picture; 2: video; 3: audio; 4: text; 5: business card integer
+ locationPath: "location_path", //Local storage path TEXT
+ content: "content", //MMS text content TEXT
+ partSize: "part_size", //MMS Size TEXT
+ partIndex: "part_index", //MMS data subscript integer
+ recordingTime: "recording_time", //Audio/Video Recording Time TEXT
+ encode: "encode", //Encoding or not 0: no encoding/encryption; 1: encoding/encryption integer
+ state: "state" //Sending success status 0: success; 1: failure; 2: sending... integer
+ },
+ // Saving SMS data in partitions
+ smsSubsection: {
+ smsSubsectionId: "sms_subsection_id", //sms_subsection table id integer
+ receiverNumber: "receiver_number", //Recipient number TEXT
+ senderNumber: "sender_number", //Sender number TEXT
+ isSender: "is_sender", //Sender number 0 - Sender 1 - Recipient integer
+ startTime: "start_time", //Start Time TEXT
+ endTime: "end_time", //End Time TEXT
+ rawPdu: "raw_pdu", //PDU string of the SMS message TEXT
+ format: "format", //Formatted data integer
+ destPort: "dest_port", //Destination Port integer
+ subsectionIndex: "subsection_index", //Section Index integer
+ size: "size" //size integer
+ },
+ // mms Protocol data saving
+ mmsProtocol: {
+ msgId: "msg_id", //mms_Protocol table id integer
+ bcc: "bcc", //bcc TEXT
+ cc: "cc", //cc TEXT
+ content_location: "content_location", //content_location TEXT
+ date: "date", //date TEXT
+ deliveryReport: "delivery_report", //deliveryReport integer
+ deliveryTime: "delivery_time", //deliveryTime TEXT
+ expiry: "expiry", //expiry integer
+ type: "type", //type integer
+ serialNumber: "serial_number", //serialNumber TEXT
+ category: "category", //category TEXT
+ version: "version", //version integer
+ size: "size", //size integer
+ priority: "priority", //priority integer
+ readReply: "read_reply", //readReply integer
+ reportAllowed: "report_allowed", //reportAllowed integer
+ responseStatus: "response_status", //responseStatus integer
+ responseText: "response_text", //responseText TEXT
+ senderVisibility: "sender_visibility" //senderVisibility integer
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/app.ets b/entry/src/main/ets/default/app.ets
deleted file mode 100644
index 2a68b9c..0000000
--- a/entry/src/main/ets/default/app.ets
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * 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';
-import AppStorageUtil from './utils/AppStorageUtil';
-
-const TAG = 'app';
-
-export default {
- onCreate() {
- HiLog.i(TAG, 'onCreate version: 1.0.0.8');
- new AppStorageUtil();
- },
- onDestroy() {
- HiLog.i(TAG, 'onDestroy');
- }
-};
diff --git a/entry/src/main/ets/default/data/commonData.ets b/entry/src/main/ets/default/data/commonData.ets
deleted file mode 100644
index bf957ea..0000000
--- a/entry/src/main/ets/default/data/commonData.ets
+++ /dev/null
@@ -1,281 +0,0 @@
-/**
- * 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.
- */
-
-export default {
- bool: {
- TRUE: '1',
- FALSE: '0',
- },
- route: {
- // 更新送达报告开关的值
- MESSAGE_CODE_UPDATE_DELIVERY_REPORTS_VALUE: 32001,
- // 更新自动下载彩信开关的值
- MESSAGE_CODE_UPDATE_AUTO_RETRIEVE_MMS_VALUE: 32002,
- // 更新取消发送开关的值
- MESSAGE_CODE_UPDATE_RECALL_MESSAGES_VALUE: 32003,
- // 更新自动删除通知信息开关的值
- MESSAGE_CODE_UPDATE_AUTO_DELETE_INFO_MESSAGES_VALUE: 32004,
- // 更新通知信息整合开关的值
- MESSAGE_CODE_UPDATE_ARCHIVE_INFO_MESSAGES_VALUE: 30002,
- // 更新恶意网址识别开关的值
- MESSAGE_CODE_UPDATE_MALICIOUS_WEBSITE_IDENTIFICATION_VALUE: 30003,
- // 更新显示联系人头像开关的值
- MESSAGE_CODE_UPDATE_SHOW_CONTACT_PROFILE_PICS_VALUE: 30004,
- // 还原高级页面开关的值
- MESSAGE_CODE_RESTORE_ADVANCED_PAGE_SWITCH_VALUE: 30005
- },
- int: {
- // status code
- SUCCESS: 0,
- FAILURE: -1,
- // CheckBox select status code 1 全选 2.全不选 3.未知
- CHECKBOX_SELECT_ALL: 1,
- // 全不选
- CHECKBOX_SELECT_NONE: 2,
- // 未知
- CHECKBOX_SELECT_UNKNOWN: 3,
- MESSAGE_CODE_TWENTY_FIVE: 60,
- MESSAGE_CODE_THREE_FOUR_ZERO: 660,
- // 文本
- TYPE_TEXT: 0,
- // 图片
- TYPE_IMAGE: 1,
- // 音频
- TYPE_AUDIO: 2,
- // 视频
- TYPE_VIDEO: 3,
- // 0
- MESSAGE_CODE_ZERO: 0,
- // 1
- MESSAGE_CODE_ONE: 1,
- // 2
- MESSAGE_CODE_TWO: 2,
- // 300
- MESSAGE_CODE_THREE_ZERO_ZERO: 300,
- // 1000
- MESSAGE_CODE_THOUSAND: 1000,
- // 发送短信成功
- SEND_MESSAGE_SUCCESS: 0,
- // 正在发送中
- SEND_MESSAGE_SENDING: 1,
- // 发送短信失败
- SEND_MESSAGE_FAILED: 2,
- // 草稿数据类型
- SEND_DRAFT: 3,
- // 列表左移滑动操作控件的宽度
- OPERATE_DELETE_WIDTH: 80,
- OPERATE_UNREAD_WIDTH: 128,
- // sim卡数量
- SIM_COUNT: 2,
- // sim卡1
- SIM_ONE: 0,
- // sim卡2
- SIM_TWO: 1,
- // 550默认高度
- TAB_HEIGHT: 550,
- // 550+720tab全屏高度
- FULL_HEIGHT: 550 + 720,
- // 取消短信倒计时
- CANCEL_TIME_COUNT: 6,
- // 全屏的字数
- FULL_SCREEN_SEND_LENGTH: 38,
- },
- string: {
- SMS_TYPE: '0',
- // 空字符串
- EMPTY_STR: '',
- // 逗号
- COMMA: ',',
- // bundleName
- BUNDLE_NAME: 'com.ohos.mms',
- // abilityName
- ABILITY_NAME: 'com.ohos.mms.MainAbility',
- // 联系人的bundleName
- CONTRACT_BUNDLE_NAME: 'com.ohos.contacts',
- // 联系人AbilityName
- CONTRACT_ABILITY_NAME: 'com.ohos.contacts.MainAbility',
- // 公用的entity
- COMMON_ENTITIES: 'entity.system.home',
- // 处理成功
- SUCCESS: 'success',
- // 轻量级偏好数据库的存储路径
- PATH_OF_PREFERENCES: '/PREFERENCES_FOR_MMS',
- // 通知信息整合
- KEY_OF_INTEGRATION_SWITCH: 'integrationSwitch',
- // 恶意网址识别
- KEY_OF_MALICIOUS_WEB_SWITCH: 'maliciousWebSwitch',
- // 显示联系人头像
- KEY_OF_SHOW_CONTACT_SWITCH: 'showContactSwitch',
- // 送达报告
- KEY_OF_DELIVERY_REPORT_SWITCH: 'deliveryReportSwitch',
- // 自动下载彩信
- KEY_OF_AUTO_RETRIEVE_SWITCH: 'autoRetrieveMmsSwitch',
- // 取消发送
- KEY_OF_RECALL_MESSAGE_SWITCH: 'recallMessageSwitch',
- // 自动删除通知信息
- KEY_OF_AUTO_DELETE_INFO_SWITCH: 'autoDeleteInfoSwitch',
- // sim卡的个数
- KEY_OF_SIM_COUNT: 'simCount',
- // sim卡1的运营商名称
- KEY_OF_SIM_0_SPN: 'simSpn0',
- // sim卡2的运营商名称
- KEY_OF_SIM_1_SPN: 'simSpn1',
- // sim卡1是否存在
- KEY_OF_SIM_0_EXIST_FLAG: 'simExistFlag0',
- // sim卡2是否存在
- KEY_OF_SIM_1_EXIST_FLAG: 'simExistFlag1',
- // 如果sim卡1的短信中心号码被修改过,新的短信中心号码
- KEY_OF_NEW_SIM_0_SMSC: 'newSimSmsc0',
- // 如果sim卡2的短信中心号码被修改过,新的短信中心号码
- KEY_OF_NEW_SIM_1_SMSC: 'newSimSmsc1',
- // sim卡的手机号
- KEY_OF_SIM_0_NUMBER: 'sim_0_number',
- KEY_OF_SIM_1_NUMBER: 'sim_1_number',
- // 订阅通知的事件
- SUBSCRIBER_EVENT: 'usual.event.SMS_RECEIVE_COMPLETED',
- // 接收转发
- RECEIVE_TRANSMIT_EVENT: 'usual.event.RECEIVE_COMPLETED_TRANSMIT',
- // 彩信接收事件
- MMS_SUBSCRIBER_EVENT: 'usual.event.MMS_RECEIVE_COMPLETED',
- // 联系人数据库
- URI_ROW_CONTACTS: 'dataability:///com.ohos.contactsdataability',
- // 联系人信息
- CONTACT_DATA_URI: '/contacts/contact_data',
- // 名片联系人
- PROFILE_DATA_URI: '/profile/raw_contact',
- // 查询联系人
- CONTACT_SEARCHE: '/contacts/search_contact',
- // 联系人信息
- CONTACT_URI: '/contacts/contact',
- // 短信数据库
- URI_MESSAGE_LOG: 'dataability:///com.ohos.smsmmsability',
- // 查询短信
- URI_MESSAGE_INFO_TABLE: '/sms_mms/sms_mms_info',
- // 统计
- URI_MESSAGE_UNREAD_COUNT: '/sms_mms/sms_mms_info/unread_total',
- // 获取最大的groupID
- URI_MESSAGE_MAX_GROUP: '/sms_mms/sms_mms_info/max_group',
- // 查询彩信
- URI_MESSAGE_MMS_PART: '/sms_mms/mms_part',
- AUDIO_NAME: 'recording2021111512454545.amr',
- // 彩信中心
- MMS_URL: 'http://mmsc.monternet.com'
- },
- DELIVERY_REPORTS: {
- // 已关闭
- DISABLED: '0',
- // 短信
- SMS: '1',
- // 彩信
- MMS: '2',
- // 短信和彩信
- SMS_AND_MMS: '3'
- },
- AUTO_RETRIEVE_MMS: {
- // 关闭
- OFF: '0',
- // 非漫游时
- NOT_WHEN_ROAMING: '1',
- // 所有网络下
- ALWAYS: '2'
- },
- SPN_CHINA: {
- // 电信
- TELECOM: '中国电信',
- // 移动
- MOBILE: 'CMCC',
- // 联通
- UNICOM: 'China Unicom',
- },
- contractPage: {
- // 跳转至新建联系人
- PAGE_FLAG_SAVE_CONTACT: 'page_flag_save_contact',
- // 呼叫前编辑
- PAGE_FLAG_EDIT_BEFORE_CALLING: 'page_flag_edit_before_calling',
- // 保存至已有联系人
- PAGE_FLAG_SAVE_EXIST_CONTACT: 'page_flag_save_exist_contact',
- // 短信发送跳转到选择联系人界面
- PAGE_FLAG_MULT_CHOOSE: 'page_flag_mult_choose',
- // 选择联系人列表页面
- PAGE_FLAG_CHOOSE_CONTACTS: 'page_flag_choose_contacts',
- // 联系人详情页面
- PAGE_FLAG_CONTACT_DETAILS: 'page_flag_contact_details',
- // 跳转至我的名片界面
- PAGE_FLAG_CALLING_CARD: 'page_flag_card_details',
- // 查询彩信数据
- URI_MESSAGE_MMS_PART: '/sms_mms/mms_part'
- },
- MESSAGE_TAB_INDEX: {
- TAB_CAMERA: 0,
- TAB_PICTURE: 1,
- TAB_AUDIO: 2,
- TAB_MORE: 3
- },
- HIGHLIGHT_TYPE: {
- // 普通数据
- NORMAL: 0,
- // 邮箱
- EMAIL: 1,
- // 网址
- URL: 2,
- // 电话
- TEL: 3,
- // 时间
- DATE: 4,
- // 验证码
- NUM: 5
- },
- tableName: {
- SESSION: 'session'
- },
- MESSAGE_TYPE: {
- // 普通信息
- NORMAL: 0,
- // 主题
- THEME: 1,
- // 幻灯片
- PPT: 2,
- // 主题和幻灯片
- THEME_AND_PPT: 3,
- },
- MESSAGE_SHOW_TYPE: {
- // 普通短信样式
- NORMAL: 0,
- // 不包含图片主题样式
- THEME_NO_IMAGE: 1,
- // 不包含图片幻灯片样式
- PPT_NO_IMAGE: 2,
- // 含图片幻灯片样式
- PPT_IMAGE: 3,
- // 含图片主题样式
- THEME_IMAGE: 4
- },
- MSG_ITEM_TYPE: {
- THEME: 0,
- IMAGE: 1,
- VIDEO: 2,
- AUDIO: 3,
- TEXT: 4,
- CARD: 5
- },
- TRANSMIT_ITEM_HEIGHT: {
- TEXT_HEIGHT: 150,
- THEME_HEIGHT: 200,
- THEME_IMAGE_HEIGHT: 300,
- PPT_IMAGE_HEIGHT: 220,
- DISTANCE: 20,
- TOTAL_HEIGHT: 650
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/data/tableData.ets b/entry/src/main/ets/default/data/tableData.ets
deleted file mode 100644
index 5722c1f..0000000
--- a/entry/src/main/ets/default/data/tableData.ets
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * 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.
- */
-export default {
- DB: {
- MMSSMS: {
- config: {
- name: 'mmssms.db'
- },
- version: 1
- }
- },
- table: {
- // 会话表
- session:
- 'CREATE TABLE IF NOT EXISTS session (' +
- 'id INTEGER PRIMARY KEY AUTOINCREMENT, ' +
- 'time INTEGER DEFAULT 0, ' +
- 'telephone TEXT, ' +
- 'content TEXT, ' +
- 'contacts_num INTEGER DEFAULT 0, ' +
- 'sms_type INTEGER DEFAULT 0, ' +
- 'unread_count INTEGER DEFAULT 0, ' +
- 'sending_status INTEGER DEFAULT 0, ' +
- 'has_draft INTEGER DEFAULT 0,' +
- 'has_lock INTEGER DEFAULT 0,' +
- 'message_count INTEGER DEFAULT 0,' +
- 'has_mms INTEGER DEFAULT 0,' +
- 'has_attachment INTEGER DEFAULT 0' +
- ');',
- },
- // 会话列表对应的字段名称
- sessionField: {
- id: 'id', //session 表id integer
- time: 'time', // 上条短信时间 integer
- telephone: 'telephone',//电话号码 TEXT
- content: 'content',// 短信内容 TEXT
- contactsNum: 'contacts_num', // 联系人数 integer
- smsType: 'sms_type',//短信类型 0-普通,1-通知 integer
- unreadCount: 'unread_count',// 未读短息数 integer
- sendStatus: 'sending_status',// 发送成功状态 0:成功 ,1 :失败 , 2 : 发送中... integer
- hasDraft: 'has_draft',//是否有草稿 0: 没有, 1:有 integer
- hasLock: 'has_lock',// 是否有锁 0: 沒有, 1:有 integer
- messageCount: 'message_count', //消息总数 integer
- hasMms: 'has_mms', //是否有新消息 0: 沒有, 1:有 integer
- hasAttachment: 'has_attachment' //是否有附件 0: 没有, 1:有 integer
- },
- // 短信详情对应字段名称
- messageInfo: {
- msgId: 'msg_id', //sms_mms_info 表id integer
- receiverNumber: 'receiver_number', //接收方号码 TEXT
- senderNumber: 'sender_number', //发送方号码 TEXT
- startTime: 'start_time', //启始时间 TEXT
- endTime: 'end_time', //结束时间 TEXT
- msgType: 'msg_type', //消息类型 0主题、1图片、2视频、3音频、4文本、5名片 integer
- smsType: 'sms_type', //短息类型 0-普通,1-通知 integer
- msgTitle: 'msg_title', //消息标题 TEXT
- msgContent: 'msg_content', //消息内容 TEXT
- msgState: 'msg_state', //消息状态 0:成功 ,1 :失败 , 2 : 发送中... integer
- operatorServiceNumber: 'operator_service_number', //操作员服务号码 TEXT
- msgCode: 'msg_code', //消息码 integer
- isLock: 'is_lock', //是否锁定 0-否,1-是 integer
- isRead: 'is_read', // 是否读取 0-已读,1-未读 integer
- isCollect: 'is_collect', //是否收藏 0-未收藏,1-已收藏 integer
- sessionType: 'session_type', //会话类型 0 - 普通 1 - 广播 2 - 群发 integer
- retryNumber: 'retry_number', //重试次数 integer
- isSubsection: 'is_subsection', //是否分支 0 - 否 1 - 是 integer
- sessionId: 'session_id', //会话Id integer
- groupId: 'group_id', //群组ID integer
- isSender: 'is_sender', //是否是发送方 0 - 接收方 1 - 发送方 integer
- isSendReport: 'is_send_report' //是否发送报告 0 - 否 1 - 是 integer
- },
- contactColumns: {
- id: 'id', // raw_contact_表 id
- displayName: 'display_name', // 显示名称
- contactedCount: 'contacted_count', // 联系次数
- lastestContactedTime: 'lastest_contacted_time', // 最近联系时间
- },
- contactDataColumns: {
- id: 'id', // raw_contact_表 id
- contactId: 'contact_id', // raw_contact_表 id
- detailInfo: 'detail_info',
- typeId: 'type_id', // raw_contact_表 id
- contentType: 'content_type', // raw_contact_表 id
- displayName: 'display_name', // 显示名称
- hasDelete: 'is_deleted' // 显示名称
- },
- searchContactView: {
- searchName: 'search_name',
- contactId: 'contact_id',
- detailInfo: 'detail_info',
- contentType: 'content_type',
- displayName: 'display_name', // 显示名称
- hasDelete: 'is_deleted' // 显示名称
- },
- // 彩信数据保存
- mmsPart: {
- msgId: 'msg_id',//mms_part 表id integer
- groupId: 'group_id', // 群组ID integer
- type: 'type', // 0主题、1图片、2视频、3音频、4文本、5名片 integer
- locationPath: 'location_path',//本地存储路径 TEXT
- content: 'content',//彩信文本内容 TEXT
- partSize: 'part_size',//彩信大小 TEXT
- partIndex: 'part_index',//彩信数据下标 integer
- recordingTime: 'recording_time',//录制音视频时间 TEXT
- encode: 'encode',//是否编码 0:不编码/不加密, 1:编码/加密 integer
- state: 'state'//发送成功状态 0:成功 ,1 :失败 , 2 : 发送中... integer
- },
- // 分区短信数据保存
- smsSubsection: {
- smsSubsectionId: 'sms_subsection_id',//sms_subsection 表id integer
- receiverNumber: 'receiver_number', //接收方号码 TEXT
- senderNumber: 'sender_number', //发送方号码 TEXT
- isSender: 'is_sender',//是否是发送方 0 - 发送方 1 - 接收方 integer
- startTime: 'start_time',//启始时间 TEXT
- endTime: 'end_time',//结束时间 TEXT
- rawPdu: 'raw_pdu',//短信的PDU串 TEXT
- format: 'format',//格式化后的数据 integer
- destPort: 'dest_port',//目标端口 integer
- subsectionIndex: 'subsection_index',//小节索引 integer
- size: 'size'//大小 integer
- },
- // mms协议数据保存
- mmsProtocol: {
- msgId: 'msg_id',//mms_Protocol 表id integer
- bcc: 'bcc', //bcc TEXT
- cc: 'cc', //cc TEXT
- content_location: 'content_location',//content_location TEXT
- date: 'date',//date TEXT
- deliveryReport: 'delivery_report',//deliveryReport integer
- deliveryTime: 'delivery_time',//deliveryTime TEXT
- expiry: 'expiry',//expiry integer
- type: 'type',//type integer
- serialNumber: 'serial_number',//serialNumber TEXT
- category: 'category',//category TEXT
- version: 'version',//version integer
- size: 'size',//size integer
- priority: 'priority',//priority integer
- readReply: 'read_reply',//readReply integer
- reportAllowed: 'report_allowed',//reportAllowed integer
- responseStatus: 'response_status',//responseStatus integer
- responseText: 'response_text',//responseText TEXT
- senderVisibility: 'sender_visibility'//senderVisibility integer
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/model/BaseDataSource.ets b/entry/src/main/ets/default/model/BaseDataSource.ets
deleted file mode 100644
index c3f4c63..0000000
--- a/entry/src/main/ets/default/model/BaseDataSource.ets
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * 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)
- })
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/model/SettingsModel.ets b/entry/src/main/ets/default/model/SettingsModel.ets
deleted file mode 100644
index 84bce3a..0000000
--- a/entry/src/main/ets/default/model/SettingsModel.ets
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * 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 BaseModel from './BaseModel';
-import common from '../data/commonData'
-import HiLog from '../utils/HiLog';
-import preferences from '../utils/PreferencesUtil';
-import telephonySMS from '@ohos.telephony.sms';
-import LooseObject from '../data/LooseObject'
-
-const TAG = 'SettingModel';
-
-export default class SettingModel extends BaseModel {
- setOnSettingValueListener(callback) {
- let data : LooseObject = {};
- data.integrationSwitch = preferences.getValueOfIntegrationSwitch();
- data.maliciousWebSwitch = preferences.getValueOfMaliciousWebSwitch();
- data.showContactSwitch = preferences.getValueOfShowContactSwitch();
- callback(data);
- }
-
- getSettingValue(callback) {
- let settingValues: LooseObject = {};
- settingValues.hasAggregate = preferences.getValueOfIntegrationSwitch();
- settingValues.isShowContactHeadIcon = preferences.getValueOfShowContactSwitch();
- settingValues.recallMessagesFlag = preferences.getValueOfRecallMessageSwitch();
- callback(this.encapsulateReturnResult(common.int.SUCCESS, settingValues));
- }
-
- getAdvancedPageSwitchValue(callback) {
- let result: LooseObject = {
- deliveryReportSwitch: false,
- autoRetrieveMmsSwitch: false,
- recallMessageSwitch: false,
- autoDeleteInfoSwitch: false
- };
- result.deliveryReportSwitch = preferences.getValueOfDeliveryReportSwitch();
- result.autoRetrieveMmsSwitch = preferences.getValueOfAutoRetrieveMmsSwitch();
- if (preferences.getValueOfRecallMessageSwitch() == common.bool.TRUE) {
- result.recallMessageSwitch = true;
- }
- if (preferences.getValueOfAutoDeleteInfoSwitch() == common.bool.TRUE) {
- result.autoDeleteInfoSwitch = true;
- }
- result.simCount = preferences.getCountOfSim();
- if (result.simCount == common.int.SIM_COUNT) {
- result.firstSpnNameOfTwoSimCard = preferences.getSpnOfSim1();
- result.secondSpnNameOfTwoSimCard = preferences.getSpnOfSim2();
- } else {
- if (preferences.getSim1ExistFlag() == common.bool.TRUE) {
- result.spnNameOfOneSimCard = preferences.getSpnOfSim1();
- } else if (preferences.getSim2ExistFlag() == common.bool.TRUE) {
- result.spnNameOfOneSimCard = preferences.getSpnOfSim2();
- } else {
- result.spnNameOfOneSimCard = common.string.EMPTY_STR;
- }
- }
- callback(this.encapsulateReturnResult(common.int.SUCCESS, result));
- }
-
- updateSmscNumber(actionData, callback) {
- let index = actionData.index - 1;
- let newTelNum = actionData.number;
- telephonySMS.setSmscAddr(index, newTelNum, (value) => {
- // 如果是卡1
- if(index == common.int.SIM_ONE) {
- preferences.setValueForSwitch(common.string.KEY_OF_NEW_SIM_0_SMSC, newTelNum);
- } else if(index == common.int.SIM_TWO) {
- preferences.setValueForSwitch(common.string.KEY_OF_NEW_SIM_1_SMSC, newTelNum);
- }
- callback(this.encapsulateReturnResult(common.int.SUCCESS, common.string.SUCCESS));
- }).catch((error) => {
- HiLog.e(TAG, 'updateSmscNumber, setSmscAddr, error: ' + JSON.stringify(error.message));
- callback(this.encapsulateReturnCode(common.int.FAILURE));
- });
- }
-
- shareSmsEnterSelectedText(actionData, callback) {
- // 分享API目前未提供
- callback(this.encapsulateReturnResult(common.int.SUCCESS, common.string.SUCCESS));
- }
-
- updateSwitchValue(keyOfSwitch, valueOfSwitch, callback) {
- preferences.setValueForSwitch(keyOfSwitch, valueOfSwitch);
- callback(this.encapsulateReturnResult(common.int.SUCCESS, common.string.SUCCESS));
- }
-
- restoreSwitchValueToDefault(callback) {
- preferences.setValueForSwitch(common.string.KEY_OF_INTEGRATION_SWITCH, common.bool.TRUE);
- preferences.setValueForSwitch(common.string.KEY_OF_MALICIOUS_WEB_SWITCH, common.bool.FALSE);
- preferences.setValueForSwitch(common.string.KEY_OF_SHOW_CONTACT_SWITCH, common.bool.TRUE);
- preferences.setValueForSwitch(common.string.KEY_OF_DELIVERY_REPORT_SWITCH, common.DELIVERY_REPORTS.DISABLED);
- preferences.setValueForSwitch(common.string.KEY_OF_AUTO_RETRIEVE_SWITCH,
- common.AUTO_RETRIEVE_MMS.NOT_WHEN_ROAMING);
- preferences.setValueForSwitch(common.string.KEY_OF_RECALL_MESSAGE_SWITCH, common.bool.FALSE);
- preferences.setValueForSwitch(common.string.KEY_OF_AUTO_DELETE_INFO_SWITCH, common.bool.FALSE);
- callback(this.encapsulateReturnResult(common.int.SUCCESS, common.string.SUCCESS));
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/pages/conversation/conversation.ets b/entry/src/main/ets/default/pages/conversation/conversation.ets
deleted file mode 100644
index 4ae33f0..0000000
--- a/entry/src/main/ets/default/pages/conversation/conversation.ets
+++ /dev/null
@@ -1,803 +0,0 @@
-/**
- * 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 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 {
- @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 = [
- {
- value: $r("app.string.delete"),
- action: () => {
- this.mConversationCtrl.longPressMore(0);
- },
- enabled: true
- }
- ];
-
- /** 短信详情弹框 */
- dialogController: CustomDialogController = new CustomDialogController({
- builder: DetailsDialog({
- 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 }
- })
-
- aboutToAppear() {
- this.mConversationCtrl.onInit()
- }
-
- onPageShow() {
- this.mConversationCtrl.onShow()
- }
-
- onPageHide() {
- this.mConversationCtrl.onHide()
- }
-
- onBackPress() {
- return this.mConversationCtrl.onBackPress();
- }
-
- build() {
- Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
- Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
- //
- // 新建界面
- if (this.mConversationCtrl.isNewMsg) {
- Row() {
- Image($rawfile('icon/ic_message_back.svg'))
- .width('24vp')
- .height('24vp')
- .onClick(() => {
- // 点击返回恢复到未选中短信状态
- this.mConversationCtrl.titleBarBack()
- })
- Text($r("app.string.new_message"))
- .margin({ left: '24vp' })
- .fontSize(20)
- .lineHeight(28)
- .fontColor($r('app.color.main_font_color'))
- .fontWeight(FontWeight.Bold)
- }
- .alignItems(VerticalAlign.Center)
- .width('100%')
- .height(56)
- .padding({left: '24vp', right: '24vp' })
- .zIndex(2)
- .constraintSize({ minHeight: 56 })
- }
- // 短信详情查看界面
- else {
- Row() {
- // 选择状态
- if (this.mConversationCtrl.isSelectStatus) {
- Row() {
- Image($rawfile('icon/ic_public_cancel.svg'))
- .width(24)
- .height(24)
- .onClick(() => {
- // 点击返回恢复到未选中短信状态
- this.mConversationCtrl.titleBarCancel()
- })
- 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'))
- .fontWeight(FontWeight.Bold)
- }
- .alignItems(VerticalAlign.Center)
- .width('100%')
- }
- // 非选择状态
- else {
- Row() {
- Flex({
- alignItems:ItemAlign.Center,
- }) {
- Row() {
- Image($rawfile('icon/ic_message_back.svg'))
- .width(24)
- .height(24)
- .onClick(() => {
- this.mConversationCtrl.titleBarBack()
- })
- Image($rawfile('icon/user_avatar_full_fill.svg'))
- .width(40)
- .height(40)
- .margin({ left: 16 })
- .onClick(() => {
- this.mConversationCtrl.titleBarAvatar();
- })
- }
- .flexBasis(80)
-
- Column() {
- Flex({
- direction: FlexDirection.Column,
- justifyContent: FlexAlign.Center,
- alignItems: ItemAlign.Start
- }) {
- 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.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'))
- }
- }
- }
- .flexGrow(1)
- .alignItems(HorizontalAlign.Start)
- .padding({ left: 16 })
-
- Row() {
- Image($rawfile('icon/ic_message_phone.svg'))
- .width(24)
- .height(24)
- .onClick(() => {
- this.mConversationCtrl.clickCall();
- })
- Column() {
- MmsMenu({
- menuItems: this.menuItems,
- sizeType: this.sizeType
- })
- }
- .margin({ left: 16 })
- }
- .flexBasis(64)
-
- }.height('100%')
- }
- .width('100%')
- }
- }
- .height(56)
- .constraintSize({ minHeight: 56 })
- .padding({left: 24, right: 24 })
- .zIndex(2)
- }
- //
- Row() {
- // 新建消息内容
- if (this.mConversationCtrl.isNewMsg) {
- Row() {
- Receive({ mConversationController: $mConversationCtrl })
- }.margin({ top: 8 })
- }
- // 短信内容
- //
- if (!this.mConversationCtrl.isNewMsg) {
- List({ space: 10, initialIndex: this.mConversationCtrl.mmsList.length - 1 }) {
- ForEach(this.mConversationCtrl.mmsList, (item, index) => {
- ListItem() {
- Column() {
- GridContainer({
- columns: this.columns,
- sizeType: this.sizeType,
- gutter: this.gutter,
- margin: this.margin
- }) {
- //
- if (!item.isReceive && !item.isDraft) {
- Flex({
- direction: FlexDirection.Column,
- justifyContent: FlexAlign.Center,
- alignItems: ItemAlign.Center
- }) {
- // 短信/彩信
- if (index == 0) {
- Text($r("app.string.msg_note_mms")).fontSize(12).lineHeight(16).fontColor($r('app.color.main_font_color_60')).margin({ bottom: 2 })
- }
- // 时间
- 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.Start }) {
- Column() {
- Flex({
- justifyContent: FlexAlign.End,
- alignItems: ItemAlign.End
- }) {
- //
- Flex({
- justifyContent: FlexAlign.End,
- alignItems: ItemAlign.End
- }) {
- //
- 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)
- .height(24)
- }
- .flexBasis(35)
- .padding({ top: 9 })
- }
- // 消息气泡
- bubbleText({
- conversationCtrl: $mConversationCtrl,
- borderRadius: [4, 24],
- direction: 'right',
- content: item.content,
- backgroundColor: $r("app.color.sender_bubble"),
- isShowMsgLongMenu: item.isShowMsgLongMenu,
- itemIndex: index
- })
- }
- }
- //
- Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.End }) {
- 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.mConversationCtrl.cardImage) {
- Image(item.subId == 0 ? $rawfile('icon/icon_mms_sim_1.svg') : $rawfile('icon/icon_mms_sim_2.svg'))
- .width(10)
- .height(10)
- .margin({ top: 8, right: 5 })
- }
- // 是否锁定
- if (item.isLock) {
- Image($rawfile('icon/msg_lock.svg'))
- .width(10)
- .height(10)
- .margin({ top: 8, right: 5 })
- }
- Text($r("app.string.messageSendFailed"))
- .textAlign(TextAlign.Start)
- .fontSize(10)
- .lineHeight(13)
- .margin({ top: 8 })
- .fontColor($r('app.color.message_send_failed'))
- .visibility(item.sendStatus == 2 ? Visibility.Visible : Visibility.None)
- Text($r("app.string.messageSending"))
- .textAlign(TextAlign.Start)
- .fontSize(10)
- .fontColor($r('app.color.main_font_color_60'))
- .lineHeight(13)
- .margin({ top: 8 })
- .visibility(item.sendStatus == 1 ? Visibility.Visible : Visibility.None)
- Text($r("app.string.messageDeliver"))
- .textAlign(TextAlign.Start)
- .fontSize(10)
- .fontColor($r('app.color.main_font_color_60'))
- .lineHeight(13)
- .margin({ top: 8 })
- .visibility(item.sendStatus == 0 ? Visibility.Visible : Visibility.None)
- }.width('100%').margin({ right: 12 })
- }
- .width('100%')
- .alignItems(HorizontalAlign.End)
- //
- Flex({ direction: FlexDirection.Column,
- justifyContent: FlexAlign.Start,
- alignItems: ItemAlign.Center }) {
- Image($rawfile('icon/user_avatar_full_fill.svg'))
- .width(30)
- .height(30)
- }
- .width(50)
- .height(30)
- .visibility(this.mConversationCtrl.contactsNum > 1 ? Visibility.Visible : Visibility.None)
- //
- 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: 4, offset: 0 },
- md: { span: 8, offset: 2 }, lg: { span: 8, offset: 2 }
- })
- }
- .width('100%')
- .useSizeType({
- xs: { span: 4, offset: 0 }, sm: { span: 4, offset: 0 },
- md: { span: 12, offset: 0 }, lg: { span: 12, offset: 0 }
- })
- }
- //
- else if (item.isReceive) {
- //
- Flex({
- direction: FlexDirection.Column,
- justifyContent: FlexAlign.Center,
- alignItems: ItemAlign.Center
- }) {
- // 短信/彩信
- if (index == 0) {
- Text($r("app.string.msg_note_mms")).fontSize(12).lineHeight(16).fontColor($r('app.color.main_font_color_60')).margin({ bottom: 2 })
- }
- // 时间
- 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.Start }) {
- Column() {
- Flex({ alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
- // 消息气泡
- bubbleText({
- conversationCtrl: $mConversationCtrl,
- borderRadius: [4, 24],
- direction: 'left',
- content: item.content,
- backgroundColor: $r("app.color.receiver_bubble"),
- isShowMsgLongMenu: item.isShowMsgLongMenu,
- itemIndex: index
- })
- }
- .useSizeType({
- 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.mConversationCtrl.cardImage) {
- Image(item.subId == 0 ? $rawfile('icon/icon_mms_sim_1.svg') : $rawfile('icon/icon_mms_sim_2.svg'))
- .width(10)
- .height(10)
- .margin({ top: 8, left: 5 })
- }
- // 是否锁定
- if (item.isLock) {
- Image($rawfile('icon/msg_lock.svg'))
- .width(10)
- .height(10)
- .margin({ top: 8, left: 5 })
- }
- }.width('70%').margin({ left: 12 })
- }
- .width('100%')
- .alignItems(HorizontalAlign.Start)
-
- 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: 4, offset: 0 },
- md: { span: 12, offset: 0 }, lg: { span: 12, offset: 0 }
- })
- }
- }
- }
- }.onClick(() => {
- if (this.mConversationCtrl.isSelectStatus) {
- this.mConversationCtrl.listCheckBoxChange(index,!item.isCbChecked)
- }
- })
- .padding(index == this.mConversationCtrl.mmsList.length - 1 ? { bottom: 20 } : null)
- }, item => item.id)
- }
- .listDirection(Axis.Vertical) // 排列方向
- .edgeEffect(EdgeEffect.Spring) // 滑动到边缘无效果
- .width('100%')
- }
- }
- .width('100%')
- .flexBasis('auto')
- .flexShrink(1)
- }
- .width('100%')
- //
- Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
- //
- if (this.mConversationCtrl.isSelectStatus && !this.mConversationCtrl.hasDetailDelete) {
- /** 底部选中了信息按钮 */
- Flex({
- direction: FlexDirection.Row,
- alignItems: ItemAlign.Center,
- justifyContent: FlexAlign.SpaceBetween
- }) {
- /** 删除 */
- Flex({
- direction: FlexDirection.Column,
- alignItems: ItemAlign.Center,
- justifyContent: FlexAlign.Center
- }) {
- 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.mConversationCtrl.selectDeleteMsgCount == 0 ? 0.4 : 1)
- .onClick(() => {
- if (this.mConversationCtrl.selectDeleteMsgCount != 0) {
- this.mConversationCtrl.clickGroupDelete()
- }
- })
- /** 转发 */
- Flex({ direction: FlexDirection.Column,
- alignItems: ItemAlign.Center,
- justifyContent: FlexAlign.Center }) {
- Image($rawfile('icon/ic_transfer.svg'))
- .width(24)
- .height(24)
- Text($r("app.string.msg_transmit")) {
-
- }.fontSize(10).margin({ top: 3 }).fontColor($r('app.color.main_font_color'))
- }.width('25%').opacity(this.mConversationCtrl.selectDeleteMsgCount == 0 ? 0.4 : 1)
- .onClick(() => {
-
- })
- /** 收藏 */
- Flex({ direction: FlexDirection.Column,
- alignItems: ItemAlign.Center,
- justifyContent: FlexAlign.Center }) {
- Image($rawfile('icon/ic_msg_favorite_m.svg'))
- .width(24)
- .height(24)
- Text($r("app.string.msg_star")) {
-
- }.fontSize(10).margin({ top: 3 }).fontColor($r('app.color.main_font_color'))
- }.width('25%').opacity(this.mConversationCtrl.selectDeleteMsgCount == 0 ? 0.4 : 1)
- .onClick(() => {
-
- })
- /** 全选 */
- Flex({ direction: FlexDirection.Column,
- alignItems: ItemAlign.Center,
- justifyContent: FlexAlign.Center }) {
- Image(this.mConversationCtrl.isMessageCheckAll ? $rawfile('icon/ic_select_all_filled.svg') : $rawfile('icon/ic_select_all.svg'))
- .width(24)
- .height(24)
- 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.mConversationCtrl.clickGroupCheckAll()
- })
- /** 更多 */
- Flex({ direction: FlexDirection.Column,
- alignItems: ItemAlign.Center,
- justifyContent: FlexAlign.Center }) {
- Image($rawfile('icon/ic_message_more1.svg'))
- .width(24)
- .height(24)
- Text($r("app.string.more")) {
- }.fontSize(10).margin({ top: 3 }).fontColor($r('app.color.main_font_color'))
- }.width('25%')
- // @ts-ignore
- .bindMenu(this.mConversationCtrl.selectDeleteMsgCount == 1 ?
- [
-// {
-// value: $r("app.string.msg_copy"),
-// action: () => {
-//
-// }
-// },
-// {
-// value: $r("app.string.share"),
-// action: () => {
-//
-// }
-// },
-// {
-// value: $r("app.string.msg_select_text"),
-// action: () => {
-//
-// }
-// },
-// {
-// value: $r("app.string.lock"),
-// action: () => {
-//
-// }
-// },
- {
- value: $r("app.string.query_details"),
- action: () => {
- this.dialogController.open()
- this.mConversationCtrl.isSelectStatus = !this.mConversationCtrl.isSelectStatus
- this.mConversationCtrl.isMessageCheckAll = false
- this.mConversationCtrl.cancleCheckedAll()
- }
- },
- this.mConversationCtrl.hasReport ? {
- value: $r("app.string.query_report"),
- action: () => {
- this.mConversationCtrl.moreSelected(6)
- }
- } : {}
- ] : [{}
-// {
-// value: $r("app.string.msg_copy"),
-// action: () => {
-//
-// }
-// },
-// {
-// value: $r("app.string.lock"),
-// action: () => {
-// }
-// }
- ]
- )
- }
- .width('100%')
- .height(56)
- }
- //
- if (!this.mConversationCtrl.isSelectStatus) {
- Flex({ alignItems: ItemAlign.End, justifyContent: FlexAlign.Center }) {
- //
- Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
- Flex() {
- Image($rawfile('icon/msg_add.svg'))
- .onClick(() => {
-
- })
- .width(24)
- .height(24)
- .margin({ bottom: 16 })
- }
- }
- .flexBasis('40')
- .visibility(Visibility.Hidden)
- //
- Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
- Flex({ alignItems: ItemAlign.Center }) {
- 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'))
- .width(16)
- .height(22)
- }
- .flexBasis(36)
- .visibility(this.mConversationCtrl.cardImage ? Visibility.Visible : Visibility.None)
-
- Flex() {
- TextArea({
- placeholder: $r("app.string.msg_note_mms"),
- text: this.mConversationCtrl.textValue
- })
- .placeholderColor($r('app.color.placeholder_color'))
- .caretColor($r('app.color.control_activated_color'))
- .backgroundColor($r("app.color.transparent_color"))
- .borderRadius(20)
- .onChange(value => {
- this.mConversationCtrl.changeValue(value);
- })
- }
- .flexGrow(1)
- .flexShrink(1)
- .constraintSize({ minHeight: 40, maxHeight: 584 })
- }
- .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() {
- Image($r("app.media.smileyFace"))
- .width(24)
- .height(24)
- .margin({ bottom: 16 })
- }
- }
- .flexBasis('40')
- .visibility(Visibility.Hidden)
- //
- Flex({
- direction: FlexDirection.Row,
- alignItems: ItemAlign.Center,
- justifyContent: FlexAlign.Start
- }) {
- // Text((this.mConversationCtrl.textValue.length !=0 || this.mConversationCtrl.isEditMms)
- // ? this.mConversationCtrl.msgSendTip : '').fontSize(12)
- Flex() {
- Image(this.mConversationCtrl.canSendMessage ? $rawfile('icon/ic_message_send_filled.svg') : $rawfile('icon/ic_message_send.svg'))
- .onClick(() => {
- // 点击发送按钮
- this.mConversationCtrl.send()
- })
- .width(24)
- .height(24)
- .margin({ bottom: 16 })
- }
- }
- .flexBasis('40')
- }
- .constraintSize({ minHeight: 72 })
- .width('100%').padding({ bottom: 16, top: 8 })
- }
- }
- .width('100%')
- .padding({ left: 24, right: 12 })
- .backgroundColor($r("app.color.white"))
- }
- .backgroundColor($r("app.color.detail_main_background"))
- .width('100%')
- .height('100%')
- }
-}
-
-@CustomDialog
-struct DetailsDialog {
- controller: CustomDialogController
- item: LooseObject
- receiver: string
-
- build() {
- Column() {
- Text($r("app.string.msgDetails"))
- .width('70%')
- .fontSize(20)
- .fontColor($r('app.color.main_font_color'))
- .fontWeight(FontWeight.Bold)
- .margin({ top: 10, bottom: 10 })
- Text() {
- Span($r("app.string.type")).fontSize(16)
- Span($r("app.string.sms")).fontSize(16)
- }.fontSize(16).fontColor($r('app.color.main_font_color')).margin({ bottom: 10 })
-
- Text() {
- Span($r("app.string.putAddresser")).fontSize(16)
- Span(this.receiver).fontSize(16)
- }.fontSize(16).fontColor($r('app.color.main_font_color')).margin({ bottom: 10 })
-
- Text() {
- Span($r("app.string.sendTime")).fontSize(16)
- Span(this.item.date).fontSize(16)
- }.fontSize(16).fontColor($r('app.color.main_font_color')).margin({ bottom: 10 })
-
- Flex({ justifyContent: FlexAlign.Center }) {
- Button() {
- Text($r("app.string.msg_know")).fontSize(16).fontColor($r('app.color.control_activated_color'))
- }
- .width(200)
- .backgroundColor($r("app.color.white"))
- .onClick(() => {
- this.controller.close()
- })
- }
- }
- .padding(20)
- .alignItems(HorizontalAlign.Start)
- }
-}
-
-// 自定义聊天气泡
-@Component
-struct bubbleText {
- @Link conversationCtrl: ConversationController;
- private borderRadius: Array; // 圆角大小,共两个参数
- private direction: string; // left:左上角 right: 右上角
- private content: string; // 气泡显示内容
- private backgroundColor: Resource | string; // 气泡背景色
- private isShowMsgLongMenu: boolean;
- private itemIndex: number;
- @State showMenu: boolean = false
- @Builder MenuBuilder() {
- Row() {
- Button($r("app.string.delete"))
- .fontSize(14)
- .fontColor($r('app.color.main_font_color'))
- .backgroundColor($r("app.color.white"))
- .onClick(() => {
- this.conversationCtrl.longPressSelected(2)
- this.showMenu = false
- })
- Button($r("app.string.more"))
- .fontSize(14)
- .fontColor($r('app.color.main_font_color'))
- .backgroundColor($r("app.color.white"))
- .onClick(() => {
- this.conversationCtrl.longPressSelected(4)
- this.showMenu = false
- })
- }
- .height(40)
- .borderRadius(20)
- .backgroundColor($r("app.color.white"))
- }
-
- build() {
- Row() {
- 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.conversationCtrl.isSelectStatus) {
- this.conversationCtrl.mmsListLongPress(this.itemIndex)
- this.showMenu = true
- }
- })
- )
- .bindPopup(this.showMenu, {
- builder: this.MenuBuilder,
- placement: this.direction == 'left' ? Placement.TopRight : Placement.TopLeft,
- maskColor: $r("app.color.mask_color"),
- popupColor: $r("app.color.transparent_color"),
- enableArrow: false,
- onStateChange: (e) => {
- if (!e.isVisible) {
- this.showMenu = false
- }
- }
- })
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/pages/conversationlist/SearchResultPage.ets b/entry/src/main/ets/default/pages/conversationlist/SearchResultPage.ets
deleted file mode 100644
index 4243e7b..0000000
--- a/entry/src/main/ets/default/pages/conversationlist/SearchResultPage.ets
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * 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.
- */
-@Component
-export struct SearchResultPage {
- build() {
- List() {
- ListItem() { //搜索到回话数量
- Text('找到2个会话').fontSize(10).fontColor(Color.Black).margin({ left: 24, top: 24 })
-
- }
-
- ListItem() { //搜索到的会话item
- SearchItem()
- }
- ListItem() { //搜索到的会话item
- SearchItem()
- }
-
- ListItem() { //中间间隔线
- Divider().width('100%').height(5)
- .backgroundColor('#F5F5F5')
- }
-
- ListItem() { //搜索到的信息数量
- Text('找到2条信息').fontSize(10).fontColor(Color.Black).margin({ left: 24, top: 24 })
- }
-
- ListItem() { //信息item
- SearchItem()
- }
- ListItem() { //信息item
- SearchItem()
- }
- }
-
- }
-}
-
-@Component
-struct SearchItem {
- build() {
- Column(){
- Row() {
- Image($rawfile('icon/user_avatar_full_fill.svg'))
- .height(40)
- .width(40)
- Column() {
- Row() {
- Text('电话').fontSize(16).fontColor(Color.Black)
- Blank()
- Text('时间').fontSize(12).fontColor(Color.Gray)
- }.width('100%')
-
- Row() {
- Text('内容').fontSize(14).fontColor(Color.Gray)
-
- }.width('100%')
- }.layoutWeight(1).margin({ left: 12 })
- }.height(64).width('100%').padding({ left: 24, right: 24 })
-// Divider().width('100%').height(1)
-// .backgroundColor('#F5F5F5')
-
- }
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/pages/conversationlist/conversationList.ets b/entry/src/main/ets/default/pages/conversationlist/conversationList.ets
deleted file mode 100644
index 4d7dfcb..0000000
--- a/entry/src/main/ets/default/pages/conversationlist/conversationList.ets
+++ /dev/null
@@ -1,392 +0,0 @@
-/**
- * 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 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();
- @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()
- },
- 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: this.dialogAlignment,
- offset: this.dialogOffset
- })
- private menuItems: Array = [
- {
- 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
- }
- ];
-
- /**
- * 当用户点击返回按钮时触发,仅@Entry修饰的自定义组件生效。
- * 返回true表示页面自己处理返回逻辑, 不进行页面路由。
- * 返回false表示使用默认的返回逻辑。
- * 不返回值会作为false处理。
- */
- onBackPress() {
- return this.mConListCtrl.onBackPress();
- }
-
- 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()
- }
-
- 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()
- }
- }
- })
- }
- }
-
- }
-
- aboutToAppear() {
- }
-
- aboutToDisappear() {
- }
-
- onPageShow() {
- this.mConListCtrl.onShow();
- }
-
- onPageHide() {
- this.mConListCtrl.unSubscribe();
-
- }
-}
-
-@Component
-struct EmptyView {
- 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%')
- }
-}
diff --git a/entry/src/main/ets/default/pages/conversationlist/conversationListController.ets b/entry/src/main/ets/default/pages/conversationlist/conversationListController.ets
deleted file mode 100644
index 74f8601..0000000
--- a/entry/src/main/ets/default/pages/conversationlist/conversationListController.ets
+++ /dev/null
@@ -1,934 +0,0 @@
-/**
- * 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 appStorage from '../../utils/AppStorageUtil';
-import common from '../../data/commonData'
-import router from '@system.router';
-import commonEvent from '@ohos.commonEvent';
-import dateUtil from '../../utils/DateUtil';
-import featureAbility from '@ohos.ability.featureAbility';
-import LooseObject from '../../data/LooseObject';
-import messageService from '../../service/ConversationListService';
-import HiLog from '../../utils/HiLog';
-import SettingService from '../../service/SettingService'
-import commonService from '../../service/CommonService';
-import NotificationService from '../../service/NotificationService';
-import AppStorageUtil from '../../utils/AppStorageUtil';
-import ConversationListDataSource from '../../model/ConversationListDataSource'
-
-let ConversationCtrl;
-
-let commonEventData = null;
-
-const TAG = 'ConversationListController';
-
-export default class ConversationListController {
- hasNoMessage: boolean = false;
- svgDelete: string = '';
- strCheckBoxSelectTip: Resource;
- strMsgDeleteDialogTip: Resource;
- // 所有短信的总条数
- total: number = 0;
- // 通知信息的总条数
- totalOfInfo: number = 0;
- // 未读信息的总条数
- unreadTotal: number = 0;
- // 未读的通知信息总条数
- unreadTotalOfInfo: number = 0;
- // 已经选中的会话条数
- conversationSelectedNumber: number = 0;
- // 是否处于多选状态*/
- isMultipleSelectState: boolean = false;
- // 是否会话列表处于全选状态
- isConversationCheckAll: boolean = false;
- // 信息列表页面搜索框输入的值
- inputValueOfSearch: string = '';
- inputValueOfSearchTemp: string = '';
- // 通知信息所在行隐藏的'标记为已读',当存在未读信息时,向左滑动屏幕才能看见该图标
- markAllAsReadForInfo: boolean = false;
- // 标记为已读
- showMarkAllAsRead: boolean = false;
- // 删除,在每条单独的消息那一行,向左滑动屏幕可见
- showDelete: boolean = false;
- // 是否锁定 默认false不锁定
- hasLockMsg: boolean = false;
- isSelectLockMsg: boolean = false;
- // 动态设置删除弹窗高度
- dialogHeight: string = '';
- // 通知信息内的数据
- messageListForInfo: Array = [];
- //删除弹窗是否显示
- deleteDialogShow: boolean = false;
- // 如果通知信息整合开关打开,则是非通知信息,如果没有打开,则是所有数据
- messageList: Array = [];
- // 搜索结果列表
- searchResultList: LooseObject = {
- sessionList: [],
- contentList: []
- };
- // 搜索结果队列
- searchResultListQueue: Array = [];
- // 搜索文本队列
- searchTextQueue: Array = [];
- // 队列启动标志位
- queueFlag: boolean = false;
- // 队列定时器启动标志位
- setTimeOutQueueFlag: boolean = false;
- // 搜索结果的个数
- countOfSearchResult: number = 0;
- // 是否真正进行跳转,避免重复跳转
- isJumping: boolean = false;
- // 通知信息整合开关'是否打开,该开关在设置里
- hasAggregate: boolean = true;
- // 显示联系人头像
- isShowContactHeadIcon: boolean = true;
- // 是否显示搜索返回按钮 默认不显示
- isShowSearchBack: boolean = false;
- isSearchFocusable: boolean = false;
- // 搜索的时候蒙层透明色展示
- isSearchCoverage: boolean = false;
- // 是否展示查询全部信息
- isSearchStatus: boolean = true;
- // 是否展示会话搜索
- isSearchConversation: boolean = false;
- // 是否展示间隔线
- isSearchInterval: boolean = false;
- // 是否展示单个信息搜索
- isSearchSms: boolean = false;
- // 显示搜索状态
- showSearchStatus: Resource;
- // 是否显示新建短信按钮
- isNewSms: boolean = true;
- conversationName: string = '';
- // 搜索时显示搜索框所在div
- showInfoDivWhenSearchFlag: boolean = true;
- // 变化刷新UI
- flushTranslate: boolean = true;
- // 操作按钮的长度
- operateBtnW: number = 145;
- // 当前触摸的数据索引
- itemTouchedIdx: number = -1;
- // 通知信息的左边距
- infoLeft: number = 0;
- // 列表分页,页数
- page: number = 0;
- // 列表分页,数量
- limit: number = 1000;
- // conversation list adapters
- conversationListDataSource: ConversationListDataSource = new ConversationListDataSource();
-
- static getInstance() {
- if (ConversationCtrl == null) {
- ConversationCtrl = new ConversationListController();
- appStorage.setAndLink('ConListController', ConversationCtrl);
- }
- return ConversationCtrl;
- }
-
- onInit() {
- this.svgDelete = 'icon/ic_delete_m.svg';
- this.strCheckBoxSelectTip = $r("app.string.msg_select_all");
- this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip2", this.conversationSelectedNumber);
- this.showSearchStatus = $r("app.string.noMessages");
- };
-
- onShow() {
- HiLog.i(TAG, 'onShow');
- this.isJumping = false;
- this.subscribe()
- this.getSettingFlagForConvListPage();
- 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;
- }
- };
-
- onDestroy() {
- HiLog.i(TAG, 'onDestroy');
- this.unSubscribe();
- };
-
- // 长按单个列表,展示全选和删除
- conversationLongPress(index) {
- // 是否有左滑删除按钮存在,存在则不可点击
- if (this.messageList[index].isDelShow) {
- return;
- }
- // 长按单个列表,展示全选和删除
- HiLog.i(TAG, 'conversationLongPress, index: ' + index);
- if (this.isMultipleSelectState) {
- this.messageList[index].isCbChecked = !this.messageList[index].isCbChecked;
- } else {
- this.isMultipleSelectState = true;
- this.messageList[index].isCbChecked = true;
- }
- this.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN);
- };
-
- setConversationCheckAll(selectType) {
- // 检查是否全选
- if (!this.isMultipleSelectState) {
- return;
- }
- if (selectType == common.int.CHECKBOX_SELECT_ALL) {
- this.conversationSelectedNumber = this.messageList.length;
- this.isConversationCheckAll = true;
- } else if (selectType == common.int.CHECKBOX_SELECT_NONE) {
- this.conversationSelectedNumber = common.int.MESSAGE_CODE_ZERO;
- this.isConversationCheckAll = false;
- } else {
- // 默认为 CHECKBOX_SELECT_UNKNOWN,判断是否有未选中
- this.isConversationCheckAll = true;
- this.conversationSelectedNumber = 0;
- this.messageList.forEach((element, index, array) => {
- if (element.isCbChecked) {
- this.conversationSelectedNumber++;
- } else if (this.isConversationCheckAll) {
- this.isConversationCheckAll = false;
- }
- })
- }
- if (this.isConversationCheckAll) {
- // 全选状态
- this.strCheckBoxSelectTip = $r("app.string.msg_deselect_all");
- } else {
- // 非全选状态
- this.strCheckBoxSelectTip = $r("app.string.msg_select_all");
- }
- };
-
- //点击联系人
- clickToConversation(index) {
- if (this.resetTouch()) {
- return;
- }
- // 跳转至短信详情页面
- HiLog.i(TAG, 'clickToConversation, isMultipleSelectState: ' + this.isMultipleSelectState);
- // 如果处于多选状态,响应CheckBox
- if (this.isMultipleSelectState) {
- this.messageList[index].isCbChecked = !this.messageList[index].isCbChecked;
- this.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN);
- return;
- }
- if (this.isJumping) {
- return;
- }
- this.isJumping = true;
- this.jumpToConversationPage(this.messageList[index]);
- // 如果该联系人下有未读的信息,还需要向后端PA发送消息,使该联系人的所有信息标记为已读
- if (this.messageList[index].countOfUnread > common.int.MESSAGE_CODE_ZERO) {
- this.markAllAsReadByIndex(index);
- }
- };
-
- backSearch() {
- this.isShowSearchBack = false;
- this.isSearchCoverage = false;
- // this.$element('searchBox').focus({
- // focus: false
- // });
- this.isSearchFocusable = false
- this.inputValueOfSearch = common.string.EMPTY_STR;
- this.isSearchStatus = true;
- this.isNewSms = true;
- this.searchResultList.sessionList = [];
- this.searchResultList.contentList = [];
- };
-
- // 重置触摸事件,用于其他按钮点击时复位已左滑移动的item
- resetTouch() {
- if (this.itemTouchedIdx !== -1) {
- let itemTouched = this.messageList[this.itemTouchedIdx];
- if (itemTouched.isDelShow) {
- itemTouched.isDelShow = false;
- this.setListItemTransX(0);
- return true;
- }
- } else if (this.showMarkAllAsRead) {
- this.showMarkAllAsRead = false;
- this.setInfoItemTransX(0);
- return true;
- }
- return false;
- };
-
- // 信息列表的触摸事件
- touchStart(event: GestureEvent, index: number) {
- if (this.isMultipleSelectState) {
- return;
- }
- if (this.showMarkAllAsRead) {
- // 上一个触控的是通知item,则将通知item复位
- // this.setInfoItemTransX(0);
- // setTimeout(() => {
- // this.showMarkAllAsRead = false;
- // }, 200);
- } else {
- // 查看当前触控的item是否是跟上一个触控的是同一个,若不是,将上一个复位
- if (this.itemTouchedIdx !== -1 && index !== this.itemTouchedIdx) {
- let itemTouched = this.messageList[this.itemTouchedIdx];
- this.setListItemTransX(0);
- itemTouched.isDelShow = false;
- }
- }
- this.itemTouchedIdx = index;
- let item = this.messageList[this.itemTouchedIdx];
- if (item.countOfUnread > 0) {
- this.operateBtnW = common.int.OPERATE_UNREAD_WIDTH;
- } else {
- this.operateBtnW = common.int.OPERATE_DELETE_WIDTH;
- }
- };
-
- touchMove(event: GestureEvent, index: number) {
- if (this.isMultipleSelectState) {
- return;
- }
- // offsetX是偏移量,值区间在[-operateBtnW, 0]
- let offsetX = event.offsetX;
- // 位移小于2,视为没有滑动
- if (Math.abs(offsetX) <= 2) {
- return;
- }
- let item = this.messageList[this.itemTouchedIdx];
- let transX = offsetX;
- if (item.isDelShow) {
- if (event.offsetX - this.operateBtnW <= 0) {
- transX = event.offsetX - this.operateBtnW
- } else {
- // 右滑到关闭
- transX = 0
- }
- } else {
- if (event.offsetX + this.operateBtnW >= 0) {
- transX = event.offsetX
- } else {
- // 左滑到最大宽度
- transX = 0 - this.operateBtnW;
- }
- }
- this.setListItemTransX(transX);
- };
-
- touchEnd(event: GestureEvent, index: number) {
- if (this.isMultipleSelectState) {
- return;
- }
- // offsetX是偏移量,值区间在[-operateBtnW, 0]
- let offsetX = event.offsetX;
- let item = this.messageList[this.itemTouchedIdx];
- if (offsetX + (this.operateBtnW / 2) >= 0) {
- this.setListItemTransX(0);
- item.isDelShow = false;
- } else {
- this.setListItemTransX(0 - this.operateBtnW);
- item.isDelShow = true;
- }
- };
-
- setListItemTransX(transX) {
- let item = this.messageList[this.itemTouchedIdx];
- if (item) {
- if (transX <= 0) {
- item.itemLeft = transX;
- } else {
- item.itemLeft = 0;
- }
- }
- // 用来刷新界面
- this.flushTranslate = !this.flushTranslate;
- };
-
- setInfoItemTransX(disX) {
- if (disX >= 0) {
- this.infoLeft = -disX;
- } else {
- this.infoLeft = -this.operateBtnW - disX;
- }
- };
-
- markInfoAsRead() {
- this.unreadTotalOfInfo = 0;
- this.showMarkAllAsRead = false;
- this.setInfoItemTransX(0);
- };
-
- jumpToCamera() {
- router.push({
- uri: 'pages/test_camera/test_camera'
- })
- };
-
- clickConversationCheckAll() {
- // 全选/取消全选
- if (this.isConversationCheckAll) {
- for (let element of this.messageList) {
- element.isCbChecked = false;
- }
- this.setConversationCheckAll(common.int.CHECKBOX_SELECT_NONE);
- } else {
- // 非全选-->全选
- for (let element of this.messageList) {
- element.isCbChecked = true;
- }
- this.setConversationCheckAll(common.int.CHECKBOX_SELECT_ALL);
- }
- };
-
- clickConversationDelete() {
- // 按钮删除
- if (this.conversationSelectedNumber == common.int.MESSAGE_CODE_ZERO) {
- return;
- }
- // 删除一条
- if (this.conversationSelectedNumber == common.int.MESSAGE_CODE_ONE) {
- this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip1");
- } else if (this.conversationSelectedNumber == this.messageList.length) {
- // 删除全部
- this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip3");
- } else {
- // 删除多条
- this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip2", this.conversationSelectedNumber);
- }
- // 是否被锁定
- this.hasLockMsg = this.judgehasLockMsg()
- this.deleteDialogShow = true
- // this.$element('delete_dialog').show();
- };
-
- judgehasLockMsg() {
- let hasLockMsg = false;
- for (let element of this.messageList) {
- if (element.isCbChecked && element.isLock) {
- hasLockMsg = true;
- break;
- }
- }
- return hasLockMsg;
- };
-
- onBackPress() {
- // 系统返回键,true代表拦截
- if (this.isMultipleSelectState) {
- for (let element of this.messageList) {
- element.isCbChecked = false;
- }
- this.isMultipleSelectState = false;
- return true;
- }
- if (!this.isSearchStatus) {
- this.backSearch();
- return true;
- }
- return false;
- };
-
- deleteDialogConfirm() {
- let mmsList = [];
- let threadIds = [];
- let lockThreadIds = [];
- for (let element of this.messageList) {
- if (element.isCbChecked) {
- if (element.isLock && !this.isSelectLockMsg) {
- lockThreadIds.push(element.threadId);
- mmsList.push(element);
- } else {
- threadIds.push(element.threadId);
- }
- } else {
- mmsList.push(element);
- }
- }
- // 设置为非多选状态
- 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
- };
- messageService.deleteMessageById(actionData);
- }
-
- if (lockThreadIds.length > 0) {
- let actionData: LooseObject = {};
- actionData.threadIds = lockThreadIds;
- messageService.dealMessageLockContent(actionData, res => {
- actionData.hasLock = 0;
- messageService.deleteMessageBySessionIdsAndLock(actionData);
- });
- }
- };
-
- deleteDialogCancel() {
- // 取消弹出
- if (this.isSelectLockMsg) {
- this.isSelectLockMsg = false;
- }
- };
-
- setDelShow() {
- if (this.itemTouchedIdx >= 0) {
- let item = this.messageList[this.itemTouchedIdx];
- this.setListItemTransX(0);
- item.isDelShow = false;
- }
- };
-
- jumpToFavoritesPage() {
- router.push({
- uri: 'pages/my_star/my_star',
- });
- };
-
- clickToMarkAllAsRead() {
- // 把未读的标记为已读,这里处理的是信息列表中的值
- let threadIds = [];
- for (let mms of this.messageList) {
- if (mms.countOfUnread > common.int.MESSAGE_CODE_ZERO) {
- threadIds.push(mms.threadId);
- }
- }
- this.markAllAsRead(threadIds);
-
- // 把通知信息的标记为已读
- let actionData = {
- hasRead: 1,
- smsType: 1,
- }
- messageService.markAllToRead(actionData);
- this.unreadTotalOfInfo = 0;
- this.unreadTotal = 0;
- };
-
- jumpToSettingsPage() {
- router.push({
- uri: "pages/settings/settings",
- params: {
- pageFlag: "settingsDetail",
- }
- });
- };
-
- subscribe() {
- let events = [common.string.RECEIVE_TRANSMIT_EVENT]
- let commonEventSubscribeInfo = {
- events: events
- };
- commonEvent.createSubscriber(commonEventSubscribeInfo, this.createSubscriberCallBack.bind(this));
-
- };
-
- subscriberCallBack(err, data) {
- this.page = 1;
- this.queryAllMessages();
- // 统计未读的信息
- this.statisticalData();
- };
-
- // 取消订阅
- unSubscribe() {
- HiLog.i(TAG, 'unSubscribe');
- commonEvent.unsubscribe(commonEventData, () => {
- HiLog.i(TAG, 'unSubscribe, success');
- });
- };
-
- createSubscriberCallBack(err, data) {
- commonEventData = data;
- // 接收到订阅
- commonEvent.subscribe(commonEventData, this.subscriberCallBack.bind(this));
- };
-
- // 统计数据
- statisticalData() {
- let actionData: LooseObject = {};
- let that = this;
- messageService.statisticalData(actionData, function (result) {
- if (result.code == common.int.SUCCESS) {
- // 列表的总数
- that.unreadTotal = result.response.totalListCount;
- // 通知信息的未读数
- that.unreadTotalOfInfo = result.response.unreadTotalOfInfo;
- } else {
- HiLog.w(TAG, 'statisticalData, failed');
- }
- });
- };
-
- // 获取整合通知信息和显示联系人头像的开关值
- getSettingFlagForConvListPage() {
- let result = SettingService.getSettingFlagForConvListPage();
- if (result) {
- this.hasAggregate = result.hasAggregate;
- this.isShowContactHeadIcon = result.isShowContactHeadIcon;
- }
- };
-
- // 分页获取列表数据
- requestItem() {
- let count = this.page * this.limit;
- if (this.page === 0) {
- this.page++;
- this.queryAllMessages();
- } else if (count < this.total && this.messageList.length > (this.page - 1) * this.limit) {
- // 对messageList的限制,是防止初始化时多次刷新请求
- this.page++;
- this.queryAllMessages();
- }
- };
-
- // 跳转至通知信息页面
- clickToInfoMessages() {
- if (this.resetTouch()) {
- return;
- }
- if (this.isMultipleSelectState) {
- return;
- }
- router.push({
- uri: 'pages/info_msg/InfoMsg'
- })
- };
-
- // 点击头像跳转至联系人详情页面或收件人列表页面
- clickToGroupDetail(index) {
- if (this.isJumping) {
- return;
- }
- this.isJumping = true;
- // 判断跳转到联系人详情还是跳转到多个收件人的列表页面
- var contactsNum = this.messageList[index].contactsNum;
- var telephone = this.messageList[index].telephone;
- if (contactsNum == common.int.MESSAGE_CODE_ONE) {
- var actionData = {
- phoneNumber: telephone,
- pageFlag: common.contractPage.PAGE_FLAG_CONTACT_DETAILS
- };
- this.jumpToContract(actionData);
- } else {
- let threadId = this.messageList[index].threadId;
- let contactsNum = this.messageList[index].contactsNum;
- this.jumpToGroupDetail(threadId, contactsNum);
- }
- };
-
- // 跳转联系人app
- jumpToContract(actionData) {
- let str = commonService.commonContractParam(actionData);
- featureAbility.startAbility(str).then((data) => {
- HiLog.i(TAG, 'jumpToContract, startAbility success');
- }).catch((error) => {
- HiLog.e(TAG, 'jumpToContract, failed Cause: ' + JSON.stringify(error.message));
- })
- };
-
- // 跳转多人头像列表页面
- jumpToGroupDetail(threadId, contactsNum) {
- let actionData = {
- uri: 'pages/group_detail/group_detail',
- params: {
- threadId: threadId,
- contactsNum: contactsNum
- }
- };
- router.push(actionData);
- };
-
- setSelectLock() {
- this.isSelectLockMsg = !this.isSelectLockMsg;
- };
-
- setSelectLockChange(e) {
- // 删除锁定CheckBox勾选事件
- this.isSelectLockMsg = e.checked;
- };
-
-
- // 查询所有的列表信息
- queryAllMessages() {
- HiLog.i(TAG, 'queryAllMessages, start');
- let that = this;
- let actionData: LooseObject = {};
- // 通知信息是否需要整合
- if (this.hasAggregate) {
- // 只查询非通知信息
- actionData.numberType = 0;
- }
- 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 => {
- let obj: LooseObject = {};
- obj = item;
- obj.isDelShow = false;
- obj.itemLeft = 0;
- // 时间转换
- dateUtil.convertDateFormatForItem(item, false);
- // 处理彩信的内容展示
- this.dealMmsListContent(item);
- 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;
- }
- });
- };
-
- dealMmsListContent(item) {
- if (item.hasMms && item.hasAttachment) {
- if (item.content == common.string.EMPTY_STR) {
- item.content = $r('app.string.attachment_no_subject');
- } else {
- item.content = $r('app.string.attachment', item.content);
- }
- }
- if (item.hasMms && !item.hasAttachment && item.content == common.string.EMPTY_STR) {
- item.content = $r('app.string.no_subject');
- }
- };
-
- // 把通知信息中未读的都标记为已读
- clickToMarkAllAsReadForInfo() {
- let actionData = {
- hasRead: 1,
- smsType: 1,
- }
- let threadIds = [];
- for (let msg of this.messageList) {
- msg.countOfUnread = common.int.MESSAGE_CODE_ZERO;
- threadIds.push(msg.threadId);
- }
- this.cancelMessageInfoNotify(threadIds, () => {
- messageService.markAllToRead(actionData);
- this.unreadTotalOfInfo = 0;
- });
- };
-
- markAllAsRead(threadIds) {
- let tempMsgList = this.messageList;
- // 把联系人(参数类型为数组)的所有信息标记为已读
- let valueBucket = {
- 'unread_count': 0,
- };
- let actionData: LooseObject = {};
- actionData.threadIds = threadIds;
- actionData.valueBucket = valueBucket;
- actionData.hasRead = 1;
- // 将标记已读的数据更新为0
- messageService.markAllAsRead(actionData);
- for (let msg of tempMsgList) {
- if (threadIds.indexOf(msg.threadId) > common.int.FAILURE) {
- // 控制列表的未读图标的显示
- msg.countOfUnread = common.int.MESSAGE_CODE_ZERO;
- }
- }
- this.messageList = tempMsgList;
- this.conversationListDataSource.refresh(this.messageList);
- this.unreadTotalOfInfo = this.unreadTotalOfInfo - threadIds.length;
- HiLog.i(TAG, 'markAllAsRead, unreadTotalOfInfo=' + this.unreadTotalOfInfo)
- };
-
- cancelMessageInfoNotify(threadIds, callback) {
- let actionData = {
- threadIds: threadIds,
- hasRead: 0
- };
- NotificationService.getInstance().cancelMessageNotify(actionData, res => {
- callback();
- });
- };
-
- // 跳转至短信详情页面
- clickInfoToConversation(index) {
- if (this.resetTouch()) {
- return;
- }
- // 如果处于多选状态,响应CheckBox
- if (this.isMultipleSelectState) {
- this.messageList[index].isCbChecked = !this.messageList[index].isCbChecked;
- this.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN);
- return;
- }
- if (this.isJumping) {
- return;
- }
- this.isJumping = true;
- // 如果该联系人下有未读的信息,还需要向后端PA发送消息,使该联系人的所有信息标记为已读
- if (this.messageList[index].countOfUnread > common.int.MESSAGE_CODE_ZERO) {
- this.markAllAsReadByIndex(index);
- }
- this.jumpToConversationPage(this.messageList[index]);
- };
-
- // 跳转至会话详情页面
- jumpToConversationPage(item) {
- router.push({
- uri: 'pages/conversation/conversation',
- params: {
- strContactsNumber: item.telephone,
- strContactsNumberFormat: item.telephoneFormat,
- strContactsName: item.name,
- contactsNum: item.contactsNum,
- threadId: item.threadId,
- isDraft: item.isDraft,
- draftContent: item.content,
- searchContent: this.inputValueOfSearch
- }
- });
- };
-
- markAllAsReadByIndex(index) {
- let threadId = this.messageList[index].threadId;
- let threadIds = [threadId];
- this.cancelMessageInfoNotify(threadIds, () => {
- // 把联系人(参数类型为数组)的所有信息标记为已读
- this.markAllAsRead(threadIds);
- this.setListItemTransX(0);
- });
- };
-
- deleteAction(idx) {
- let element = this.messageList[idx];
- this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip1");
- element.isCbChecked = true;
- this.hasLockMsg = this.judgehasLockMsg();
- };
-
- searchTouchStart(e) {
- // 判断是否是多选状态
- if (this.isMultipleSelectState) {
- return false;
- }
- let that = this
- // 搜索区域touchStart监控x > 125 && x < 600) && (y < 70 && y > 20
- var x = e.touches[0].localX;
- if (e.currentTarget.type === 'search' && x > 80 && x < 560) {
- this.isShowSearchBack = true;
- // 蒙层展示
- this.isSearchCoverage = true;
- // 是否显示新建按钮
- this.isNewSms = false;
- // 拉起输入法
- setTimeout(function () {
- // that.$element('searchBox').focus({
- // focus: true
- // })
- }, common.int.MESSAGE_CODE_THREE_ZERO_ZERO)
- }
- this.resetTouch();
- return false;
- };
-
- // 搜索
- clickToSearch(inputContent) {
- this.inputValueOfSearch = inputContent;
- this.search(inputContent);
- };
-
- search(text) {
- // 在信息列表页面搜索
- let actionData: LooseObject = {}
- actionData.inputValue = text
- this.searchTextAsync(actionData);
- };
-
- searchTextAsync(actionData) {
- messageService.searchMessageWithLike(actionData, result => {
- if (result.code == common.int.SUCCESS) {
- // 获取搜索返回的结果先做判空处理
- if (this.inputValueOfSearch !== common.string.EMPTY_STR) {
- this.dealSearchResult(result);
- }
- } else {
- this.searchResultListEmpty();
- }
- });
- };
-
- searchResultListEmpty() {
- this.searchResultList = {
- contentList: [],
- sessionList: []
- }
- this.isSearchStatus = true;
- this.showInfoDivWhenSearchFlag = true;
- if (this.isShowSearchBack) {
- this.isSearchCoverage = true;
- } else {
- this.isSearchCoverage = false;
- }
- };
-
- dealSearchResult(result) {
- this.searchResultList = {
- contentList: [],
- sessionList: []
- }
- this.showInfoDivWhenSearchFlag = false;
- this.isSearchStatus = false;
- this.isSearchCoverage = false;
- this.buildSearchResult(result);
- if (this.inputValueOfSearch === result.search) {
- this.searchResultList = result.resultMap;
- }
- };
-
- buildSearchResult(result) {
-
- if (result.resultMap.contentList) {
- result.resultMap.contentList.forEach(content => {
- content.timeMillisecond = parseInt(content.timeMillisecond);
- dateUtil.convertDateFormatForItem(content, true);
- if (content.isFavorite) {
- content.name = $r('app.string.message_in_favorites');
- }
- });
- }
- if (result.resultMap.sessionList) {
- result.resultMap.sessionList.forEach(session => {
- session.timeMillisecond = parseInt(session.timeMillisecond);
- dateUtil.convertDateFormatForItem(session, true);
- });
- }
- };
-
- checkHasCommonMessage() {
- return this.messageList.length > 0;
- }
-
- showMultipleSelectView() {
- this.resetTouch();
- if (this.checkHasCommonMessage()) {
- this.isMultipleSelectState = true;
- this.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN)
- }
- }
-}
diff --git a/entry/src/main/ets/default/pages/index/index.ets b/entry/src/main/ets/default/pages/index/index.ets
deleted file mode 100644
index de9ea52..0000000
--- a/entry/src/main/ets/default/pages/index/index.ets
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * 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 indexCtrl from './indexController'
-
-@Entry
-@Component
-struct Index {
- @State mIndexCtrl: typeof indexCtrl = indexCtrl
-
- /**
- * 函数在创建自定义组件的新实例后,在执行其build函数之前执行。
- * 允许在aboutToAppear函数中改变状态变量,这些更改将在后续执行build函数中生效。
- */
- aboutToAppear() {
- this.mIndexCtrl.onInit();
- }
-
- /**
- * 函数在自定义组件析构消耗之前执行。
- * 不允许在aboutToDisappear函数中改变状态变量,特别是@Link变量的修改可能会导致应用程序行为不稳定。
- */
- aboutToDisappear() {
- }
-
- /**
- * 当此页面显示时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。
- */
- onPageShow() {
- this.mIndexCtrl.onShow();
- }
-
- /**
- * 当此页面消失时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。
- */
- onPageHide() {
- this.mIndexCtrl.onHide();
- }
-
- /**
- * 当用户点击返回按钮时触发,,仅@Entry修饰的自定义组件生效。
- * 返回true表示页面自己处理返回逻辑, 不进行页面路由。
- * 返回false表示使用默认的返回逻辑。
- * 不返回值会作为false处理。
- */
- onBackPress() {
- }
-
- build() {
- Flex({ direction: FlexDirection.Column }) {
- }
- .width('100%')
- .height('100%')
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/pages/index/indexController.ets b/entry/src/main/ets/default/pages/index/indexController.ets
deleted file mode 100644
index 98f225d..0000000
--- a/entry/src/main/ets/default/pages/index/indexController.ets
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- * 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 appStorage from '../../utils/AppStorageUtil';
-// JS公共常量
-import common from '../../data/commonData';
-import contactService from '../../service/ContractService';
-import conversationListService from '../../service/ConversationListService';
-import featureAbility from '@ohos.ability.featureAbility';
-import HiLog from '../../utils/HiLog';
-import mmsTable from '../../data/tableData';
-import preferences from '../../utils/PreferencesUtil';
-import rdbStore from '../../utils/RdbStoreUtil';
-import router from '@system.router';
-import simCardService from '../../service/SimCardService';
-
-const TAG = 'IndexController';
-
-export default {
- uri: common.string.EMPTY_STR,
-
- pageFlag: 'conversationList',
-
- contractParams: null,
-
- onInit() {
- this.initPermissions()
- // 初始化数据库
- this.initRdb();
- },
-
- async initPermissions() {
- let requestPermissions: Array = [
- "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();
- },
-
- onHide() {
- },
-
- async initRdb() {
- // 创建数据库表
- HiLog.i(TAG, 'initRdb');
- rdbStore.createTable(mmsTable.table.session).then(() => {
- HiLog.i(TAG, 'initRdb, createTable done');
- });
- },
-
- initStorage() {
- preferences.initDataStorage().then((prefIns) => {
- appStorage.setPreferences(prefIns);
- // 获取simCount
- this.initSimCardNum(preferences);
- // 获取卡的运营商
- this.simInfoProcessor(preferences);
- }).catch((err) => {
- HiLog.e(TAG, 'initStorage, failed: ' + err.message);
- });
- },
-
- initSimCardNum(preferences) {
- simCardService.initSimCardNum(preferences);
- },
-
- // 处理Sim卡相关的信息(sim卡的数量以及运营商的名字)
- simInfoProcessor(preferences) {
- simCardService.simInfoHandler(preferences);
- },
-
- getWant() {
- featureAbility.getWant().then((want) => {
- if (want.hasOwnProperty("uri")) {
- this.uri = want.uri;
- }
- if (want.hasOwnProperty("parameters")) {
- let parameters = want.parameters;
- if (parameters.hasOwnProperty("pageFlag")) {
- this.pageFlag = parameters.pageFlag;
- }
- if (parameters.hasOwnProperty("contactObjects")) {
- this.contractParams = contactService.dealContractParams(parameters.contactObjects);
- }
- }
- // 页面跳转
- this.jump();
- }).catch((error) => {
- HiLog.e(TAG, 'getWant, failed Cause: ' + JSON.stringify(error.message));
- })
- },
-
- jump() {
- let result = {
- uri: '',
- params: ''
- };
- HiLog.i(TAG, 'want.pageFlag: ' + this.pageFlag);
- switch (this.pageFlag) {
- case 'conversationList':
- result.uri = 'pages/conversationlist/conversationList';
- router.replace(result);
- break;
- case 'conversation':
- result.uri = 'pages/conversation/conversation';
- if (this.contractParams) {
- result.params = this.contractParams;
- this.jumpIsNewPage(result);
- } else {
- router.replace(result);
- }
- break;
- default:
- result.uri = common.string.EMPTY_STR;
- break;
- }
- },
-
- jumpIsNewPage(result) {
- // 判断是否
- 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;
- }
- router.replace(result);
- });
- },
-
- markAllAsRead(threadId) {
- let actionData = {
- threadIds: [threadId],
- hasRead: 1,
- valueBucket: {
- 'unread_count': 0
- }
- };
- conversationListService.markAllAsRead(actionData);
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/pages/info_msg/InfoMsg.ets b/entry/src/main/ets/default/pages/info_msg/InfoMsg.ets
deleted file mode 100644
index 8187d94..0000000
--- a/entry/src/main/ets/default/pages/info_msg/InfoMsg.ets
+++ /dev/null
@@ -1,356 +0,0 @@
-/**
- * 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 DeviceUtil from "../../utils/DeviceUtil";
-import InfoMsgController from "./InfoMsgController";
-import { DeleteDialog } from "../../views/MmsDialogs";
-import { MmsListItem } from "../../views/MmsListItem";
-import { MmsMenu } from "../../views/MmsMenu";
-
-@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: () => {
- this.mInfoMsgCtrl.deleteDialogCancel()
- },
- confirm: () => {
- this.mInfoMsgCtrl.deleteDialogConfirm()
- },
- msg: this.mInfoMsgCtrl.strMsgDeleteDialogTip,
- hasLockMsg: this.mInfoMsgCtrl.hasLockMsg,
- setSelectLock: () => {
- this.mInfoMsgCtrl.setSelectLock()
- },
- isSelectLockMsg: this.mInfoMsgCtrl.isSelectLockMsg,
- setSelectLockChange: (isOn: boolean) => {
- this.mInfoMsgCtrl.setSelectLockChange(isOn)
- }
- }),
- autoCancel: false,
- alignment: this.dialogAlignment,
- offset: this.dialogOffset
- })
-
- private menuItems: Array = [
- {
- 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函数中生效。
- */
- aboutToAppear() {
- this.mInfoMsgCtrl.onInit()
- }
- /**
- * 函数在自定义组件析构消耗之前执行。
- * 不允许在aboutToDisappear函数中改变状态变量,特别是@Link变量的修改可能会导致应用程序行为不稳定。
- */
- aboutToDisappear() {
- }
- /**
- * 当此页面显示时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。
- */
- onPageShow() {
- this.mInfoMsgCtrl.onShow()
- }
- /**
- * 当此页面消失时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。
- */
- onPageHide() {
- this.mInfoMsgCtrl.onHide()
- }
- /**
- * 当用户点击返回按钮时触发,,仅@Entry修饰的自定义组件生效。
- * 返回true表示页面自己处理返回逻辑, 不进行页面路由。
- * 返回false表示使用默认的返回逻辑。
- * 不返回值会作为false处理。
- */
- onBackPress() {
- // 系统返回键,true代表拦截
- if (this.mInfoMsgCtrl.isMultipleSelectState) {
- for (let element of this.mInfoMsgCtrl.messageList) {
- element.isCbChecked = false;
- }
- this.mInfoMsgCtrl.isMultipleSelectState = false;
- this.mInfoMsgCtrl.showToolBar = true;
- return true;
- }
- return false;
- }
-
- build() {
-
- 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')
- }
-
- 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: "搜索通知信息" })
- .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({ 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)
- }
- }, 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()
- }
- })
- }
- }
- .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' })
- }
- //全部已读和更多
- 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('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 }
- })
- }
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/pages/query_report/queryReportController.ets b/entry/src/main/ets/default/pages/query_report/queryReportController.ets
deleted file mode 100644
index 3fac708..0000000
--- a/entry/src/main/ets/default/pages/query_report/queryReportController.ets
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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 common from '../../data/commonData';
-import dateUtil from '../../utils/DateUtil';
-import router from '@system.router';
-import HiLog from '../../utils/HiLog'
-import appStorage from '../../utils/AppStorageUtil';
-const TAG = 'QueryReportController';
-
-let queryReportCtrl;
-export default class QueryReportController {
- // 是否是彩信
- isMsm: boolean = true;
- // 发送状态描述
- sendStatusDesc: Resource;
- // 发送状态
- sendStatus: number = 0;
- // 时间
- mmsTime: Resource;
- // 具体上下午时间
- specificTime: Resource;
- // 时间戳
- timeMillisecond: string = '0';
- // 手机号
- telephone: string = '';
-
- static getInstance() {
- if (queryReportCtrl == null) {
- queryReportCtrl = new QueryReportController();
- appStorage.setAndLink('QueryReportController', queryReportCtrl);
- }
- return queryReportCtrl;
- };
-
- onInit() {
- HiLog.i(TAG, 'onInit')
- this.isMsm = router.getParams().isMsm == undefined ? true : router.getParams().isMsm;
- this.sendStatus = router.getParams().sendStatus == undefined ? 0 : router.getParams().sendStatus;
- this.timeMillisecond = router.getParams().timeMillisecond == undefined ? '0' : router.getParams().timeMillisecond;
- this.telephone = router.getParams().telephone == undefined ? '' : router.getParams().telephone
- };
- onShow() {
- HiLog.i(TAG, 'onShow')
- // 状态转换成中文描述
- this.dealSendStatus();
- // 时间转换
- this.dealTime();
- };
- dealSendStatus() {
- HiLog.i(TAG, 'dealSendStatus sendStatus=' + this.sendStatus)
- if (this.sendStatus == common.int.SEND_MESSAGE_SUCCESS) {
- this.sendStatusDesc = $r("app.string.received");
- } else if (this.sendStatus == common.int.SEND_MESSAGE_FAILED) {
- this.sendStatusDesc = this.isMsm ? $r("app.string.refused") : $r("app.string.failed");
- } else {
- this.sendStatusDesc = $r("app.string.rending");
- }
- };
- dealTime() {
- this.mmsTime = dateUtil.convertTimeStampDate(this.timeMillisecond);
- this.specificTime = dateUtil.convertTimeStampTime(this.timeMillisecond, false)
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/pages/query_report/query_report.ets b/entry/src/main/ets/default/pages/query_report/query_report.ets
deleted file mode 100644
index 257b910..0000000
--- a/entry/src/main/ets/default/pages/query_report/query_report.ets
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * 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 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()
- }
-
- private aboutToAppear(): void {
- this.queryReportController.onInit()
- }
-
- build() {
- Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
- 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)
- }
- .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 }
- })
-
- Column() {
- Text() {
- 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 }
- })
- }
- }
- .width('100%')
- .height('100%')
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/pages/settings/advancedSettings/advancedSettings.ets b/entry/src/main/ets/default/pages/settings/advancedSettings/advancedSettings.ets
deleted file mode 100644
index 3ad0218..0000000
--- a/entry/src/main/ets/default/pages/settings/advancedSettings/advancedSettings.ets
+++ /dev/null
@@ -1,366 +0,0 @@
-/**
- * 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 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 {
- @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 = [
- {
- 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
- })
-
- /**
- * 函数在创建自定义组件的新实例后,在执行其build函数之前执行。
- * 允许在aboutToAppear函数中改变状态变量,这些更改将在后续执行build函数中生效。
- */
- aboutToAppear() {
- this.mAdvancedSettingsCtrl.onInit();
- }
- /**
- * 当此页面显示时触发一次。包括路由过程、应用进入前后台等场景,仅@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
- }) {
- // 顶部设备标题
- 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)
-
- Blank()
-
- 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('100%')
- .backgroundColor($r("app.color.setting_background"))
- }
-}
-
-/**
- * 送达报告选择框
- */
-@CustomDialog
-struct DeliveryReportsDialog {
- controller: CustomDialogController;
- cancel: () => void;
- confirm: (isOnOfSms: boolean, isOnOfMms: boolean) => void;
- @State isOnOfSms: boolean = false;
- @State isOnOfMms: boolean = false;
-
- 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;
- })
-
- 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"))
- }
-}
diff --git a/entry/src/main/ets/default/pages/settings/advancedSettings/advancedSettingsController.ets b/entry/src/main/ets/default/pages/settings/advancedSettings/advancedSettingsController.ets
deleted file mode 100644
index d45da80..0000000
--- a/entry/src/main/ets/default/pages/settings/advancedSettings/advancedSettingsController.ets
+++ /dev/null
@@ -1,314 +0,0 @@
-/**
- * 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'
-import HiLog from '../../../utils/HiLog';
-import router from '@system.router';
-import prompt from '@system.prompt';
-import settingService from '../../../service/SettingService'
-import common from '../../../data/commonData';
-
-const TAG = "AdvancedSettingsController";
-
-export default class AdvancedSettingsController {
- private static sInstance: AdvancedSettingsController;
- // 送达报告短信
- checkedValueOfSms: boolean = false;
- // 送达报告彩信
- checkedValueOfMms: boolean = false;
- // 送达报告开关的值
- deliveryReportSwitch: string = common.DELIVERY_REPORTS.DISABLED;
- // 送达报告文本
- deliveryReportSwitchInText: Resource | string = $r('app.string.disabled');
- // 自动下载彩信开关
- autoRetrieveMmsSwitch: string = common.AUTO_RETRIEVE_MMS.OFF;
- // 自动下载彩信开关文本
- autoRetrieveMmsSwitchInText: Resource | string = $r('app.string.off');
- // 取消发送开关
- recallMessageSwitch: string = common.bool.FALSE;
- // 自动删除通知信息开关
- autoDeleteInfoSwitch: string = common.bool.FALSE;
- // 自动删除通知信息开关,临时变量
- tempAutoDeleteInfoSwitch: string = common.bool.FALSE;
- // 中国电信
- snpNameOfChinaTelecom : string = '';
- // sim卡的数量
- simCount: number = 0;
- // 如果是1张卡,运营商的名字
- spnNameOfOneSimCard: string = '';
- // 如果是2张卡,卡1运营商的名字
- firstSpnNameOfTwoSimCard: string = '';
- // 如果是2张卡,卡2运营商的名字
- secondSpnNameOfTwoSimCard: string = '';
-
- static getInstance() {
- if (AdvancedSettingsController.sInstance == null) {
- AdvancedSettingsController.sInstance = new AdvancedSettingsController();
- }
- return AdvancedSettingsController.sInstance;
- }
-
- constructor() {
- HiLog.i(TAG, 'constructor, start');
- this.getAdvancedPageSwitchValue();
- }
-
- onInit() {
- HiLog.i(TAG, 'onInit, start');
- }
- onShow() {
- HiLog.i(TAG, 'onShow, start');
- }
- getAdvancedPageSwitchValue() {
- HiLog.i(TAG, 'getAdvancedPageSwitchValue, start');
- let that = this;
- settingService.getAdvancedPageSwitchValue(function (result) {
- if (result.code === common.int.SUCCESS) {
- let switchValue = result.abilityResult;
- that.deliveryReportSwitch = switchValue.deliveryReportSwitch;
- that.returnDeliveryReportResultInText(that.deliveryReportSwitch);
- that.autoRetrieveMmsSwitch = switchValue.autoRetrieveMmsSwitch;
- that.returnAutoRetrieveMmsResultInText(that.autoRetrieveMmsSwitch);
- that.recallMessageSwitch = switchValue.recallMessageSwitch;
- that.autoDeleteInfoSwitch = switchValue.autoDeleteInfoSwitch;
- that.tempAutoDeleteInfoSwitch = that.autoDeleteInfoSwitch;
- // 等sim卡功能好,需要换成 switchValue.simCount;
- that.simCount = switchValue.simCount;
- if (that.simCount === 2) {
- that.firstSpnNameOfTwoSimCard = switchValue.firstSpnNameOfTwoSimCard;
- that.secondSpnNameOfTwoSimCard = switchValue.secondSpnNameOfTwoSimCard;
- } else {
- that.spnNameOfOneSimCard = switchValue.spnNameOfOneSimCard;
- }
- } else {
- HiLog.w(TAG, 'getAdvancedPageSwitchValue, failed');
- }
- });
- }
- // 根据整数值返回文本版的送达报告结果
- returnDeliveryReportResultInText(intValue) {
- let tempValue;
- if (intValue == common.DELIVERY_REPORTS.DISABLED) {
- tempValue = $r('app.string.disabled');
- this.checkedValueOfSms = false;
- this.checkedValueOfMms = false;
- } else if (intValue == common.DELIVERY_REPORTS.SMS) {
- tempValue = $r('app.string.sms');
- this.checkedValueOfSms = true;
- this.checkedValueOfMms = false;
- } else if (intValue == common.DELIVERY_REPORTS.MMS) {
- tempValue = $r('app.string.mms');
- this.checkedValueOfSms = false;
- this.checkedValueOfMms = true;
- } else {
- tempValue = $r('app.string.sms_and_mms');
- this.checkedValueOfSms = true;
- this.checkedValueOfMms = true;
- }
- this.deliveryReportSwitchInText = tempValue;
- }
- // 根据整数值返回文本版的送达报告结果
- returnAutoRetrieveMmsResultInText(intValue) {
- let tempValue;
- if (intValue == common.AUTO_RETRIEVE_MMS.OFF) {
- tempValue = $r('app.string.off');
- } else if (intValue == common.AUTO_RETRIEVE_MMS.NOT_WHEN_ROAMING) {
- tempValue = $r('app.string.not_when_roaming');
- } else {
- tempValue = $r('app.string.always');
- }
- this.autoRetrieveMmsSwitchInText = tempValue;
- }
- // 返回按键
- back() {
- router.back();
- }
- // 还原设置页面的默认值
- restoreSettingPageSwitchValue() {
- HiLog.i(TAG, 'restoreSettingPageSwitchValue');
- let that = this;
- settingService.restoreSwitchValue(function (result) {
- if (result.code === common.int.SUCCESS) {
- that.deliveryReportSwitch = common.DELIVERY_REPORTS.DISABLED;
- that.returnDeliveryReportResultInText(common.DELIVERY_REPORTS.DISABLED);
- that.autoRetrieveMmsSwitch = common.AUTO_RETRIEVE_MMS.NOT_WHEN_ROAMING;
- that.returnAutoRetrieveMmsResultInText(common.AUTO_RETRIEVE_MMS.NOT_WHEN_ROAMING);
- that.recallMessageSwitch = common.bool.FALSE;
- that.autoDeleteInfoSwitch = common.bool.FALSE;
- that.tempAutoDeleteInfoSwitch = common.bool.FALSE;
- HiLog.i(TAG, 'restoreSettingPageSwitchValue, success');
- } else {
- HiLog.w(TAG, 'restoreSettingPageSwitchValue, failed');
- }
- });
- }
- // 点击短信那行
- clickSmsDiv() {
- this.checkedValueOfSms = !this.checkedValueOfSms;
- }
- // 点击短信那行的checkbox
- clickSmsCheckbox(e) {
- this.checkedValueOfSms = e.checked;
- }
- // 点击彩信那行
- clickMmsDiv() {
- this.checkedValueOfMms = !this.checkedValueOfMms;
- }
- // 点击彩信那行的checkbox
- clickMmsCheckbox(e) {
- this.checkedValueOfMms = e.checked;
- }
- // 取消还原配置的弹框
- cancelRestore() {
- this.returnDeliveryReportResultInText(this.deliveryReportSwitch);
- }
- // 送达报告dialog,确定
- 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;
- } else if(this.checkedValueOfSms) {
- this.deliveryReportSwitch = common.DELIVERY_REPORTS.SMS;
- } else if(this.checkedValueOfMms) {
- this.deliveryReportSwitch = common.DELIVERY_REPORTS.MMS;
- } else {
- this.deliveryReportSwitch = common.DELIVERY_REPORTS.DISABLED;
- }
- this.returnDeliveryReportResultInText(this.deliveryReportSwitch);
- this.autoHandleDeliveryReportValueChange(this.deliveryReportSwitch);
- }
- // 当deliveryReportSwitch开关的值变化时,由该方法处理
- autoHandleDeliveryReportValueChange(newValue) {
- HiLog.i(TAG, 'autoHandleDeliveryReportValueChange, newValue = ' + newValue);
- let messageCode = common.route.MESSAGE_CODE_UPDATE_DELIVERY_REPORTS_VALUE;
- let actionData: LooseObject = {};
- actionData.intValue = newValue;
- this.updateAdvancedPageSwitchValue(messageCode, actionData);
- }
- // 显示'自动下载彩信'dialog
- showAutoRetrieveMmsDialog() {
-// this.$element('auto-retrieve-mms-dialog').show();
- }
- // 点击'自动下载彩信'dialog内相应的选项
- clickDiv(idx) {
- this.autoRetrieveMmsSwitch = idx + common.string.EMPTY_STR;
- this.returnAutoRetrieveMmsResultInText(idx);
-// this.$element('auto-retrieve-mms-dialog').close();
- this.autoHandleAutoRetrieveMmsValueChange(this.autoRetrieveMmsSwitch);
- }
- // 关闭'自动下载彩信'dialog
- closeAutoRetrieveMmsDialog() {
-// this.$element('auto-retrieve-mms-dialog').close();
- }
- // 当autoRetrieveMmsSwitch开关的值变化时,由该方法处理
- autoHandleAutoRetrieveMmsValueChange(newValue) {
- HiLog.i(TAG, 'autoHandleAutoRetrieveMmsValueChange, newValue = ' + newValue);
- let messageCode = common.route.MESSAGE_CODE_UPDATE_AUTO_RETRIEVE_MMS_VALUE;
- let actionData: LooseObject = {};
- actionData.intValue = newValue;
- this.updateAdvancedPageSwitchValue(messageCode, actionData);
- }
- // 取消发送
- recallMsg(e) {
- let messageCode = common.route.MESSAGE_CODE_UPDATE_RECALL_MESSAGES_VALUE;
- let actionData: LooseObject = {};
- this.recallMessageSwitch = e.checked;
- if (this.recallMessageSwitch) {
- actionData.booleanValue = common.bool.TRUE;
- } else {
- actionData.booleanValue = common.bool.FALSE;
- }
- this.updateAdvancedPageSwitchValue(messageCode, actionData);
- }
- // 自动删除通知信息
- autoDeleteInfo(e) {
- let that = this;
- that.tempAutoDeleteInfoSwitch = e.checked;
- if (e.checked) {
- prompt.showDialog({
- title: $r('app.string.enable_auto_delete') + '',
- message: $r('app.string.enable_auto_delete_hint') + '',
- buttons: [
- {text: $r('app.string.cancel') + '', color: '#007DFF'},
- {text: $r('app.string.enable') + '', color: '#007DFF'}
- ],
- success: function (data) {
- that.autoDeleteSuccess(data);
- },
- cancel: function () {
- HiLog.i(TAG, 'autoDeleteInfo, cancel');
- that.tempAutoDeleteInfoSwitch = common.bool.FALSE;
- that.autoDeleteInfoSwitch = common.bool.FALSE;
- }
- });
- } else {
- that.autoDeleteInfoSwitch = common.bool.FALSE;
- that.autoHandleAutoDeleteInfoValueChange(common.bool.FALSE);
- }
- }
- autoDeleteSuccess(data) {
- if (data.index == 0) {
- this.tempAutoDeleteInfoSwitch = common.bool.FALSE;
- } else {
- this.autoDeleteInfoSwitch = common.bool.TRUE;
- this.autoHandleAutoDeleteInfoValueChange(common.bool.TRUE);
- }
- }
- // 当autoDeleteInfoSwitch开关的值变化时,由该方法处理
- autoHandleAutoDeleteInfoValueChange(newValue) {
- HiLog.i(TAG, 'autoHandleAutoDeleteInfoValueChange, newValue = ' + newValue);
- let messageCode = common.route.MESSAGE_CODE_UPDATE_AUTO_DELETE_INFO_MESSAGES_VALUE;
- let actionData: LooseObject = {};
- actionData.booleanValue = newValue;
- this.updateAdvancedPageSwitchValue(messageCode, actionData);
- }
- // 跳转至'短信中心'页面
- jumpToSmsCenterPage(index) {
- if (this.simCount == 0) {
- return;
- }
- router.push({
- uri: 'pages/sms_center/sms_center',
- params: {
- idx: index,
- countOfSim: this.simCount
- }
- });
- }
- // 跳转至'管理Sim卡'页面
- jumpToManageSimPage(index) {
- if (this.simCount == 0) {
- return;
- }
- router.push({
- uri: 'pages/manage_sim/manage_sim',
- params: {
- idx: index,
- countOfSim: this.simCount
- }
- });
- }
- // 更新开关值
- updateAdvancedPageSwitchValue(messageCode, actionData) {
- settingService.updateSettingValue(messageCode, actionData, function (result) {
- if (result.code == common.int.SUCCESS) {
- HiLog.i(TAG, 'updateAdvancedPageSwitchValue, success');
- } else {
- HiLog.w(TAG, 'updateAdvancedPageSwitchValue, failed');
- }
- });
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/pages/settings/settings.ets b/entry/src/main/ets/default/pages/settings/settings.ets
deleted file mode 100644
index ee7b47f..0000000
--- a/entry/src/main/ets/default/pages/settings/settings.ets
+++ /dev/null
@@ -1,242 +0,0 @@
-/**
- * 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 DeviceUtil from "../../utils/DeviceUtil";
-import { MmsSimpleDialog } from '../../views/MmsDialogs';
-import { MmsMenu } from '../../views/MmsMenu';
-import router from '@system.router';
-import { SettingItemSwitch, SettingItemJump } from '../../views/SettingItem';
-import SettingsController from './settingsController';
-
-@Entry
-@Component
-struct Settings {
- @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 = [
- {
- value: $r("app.string.restore_default_settings"),
- action: () => {
- this.restoreDialog.show();
- },
- enabled: true
- }
- ];
-
- /**
- * 函数在创建自定义组件的新实例后,在执行其build函数之前执行。
- * 允许在aboutToAppear函数中改变状态变量,这些更改将在后续执行build函数中生效。
- */
- aboutToAppear() {
- this.mSettingsCtrl.onInit()
- }
-
- /**
- * 函数在自定义组件析构消耗之前执行。
- * 不允许在aboutToDisappear函数中改变状态变量,特别是@Link变量的修改可能会导致应用程序行为不稳定。
- */
- aboutToDisappear() {
- }
-
- /**
- * 当此页面显示时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。
- */
- onPageShow() {
- this.mSettingsCtrl.onShow()
- }
-
- /**
- * 当此页面消失时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。
- */
- onPageHide() {
- }
-
- /**
- * 当用户点击返回按钮时触发,,仅@Entry修饰的自定义组件生效。
- * 返回true表示页面自己处理返回逻辑, 不进行页面路由。
- * 返回false表示使用默认的返回逻辑。
- * 不返回值会作为false处理。
- */
- onBackPress() {
- }
-
- build() {
- Row() {
- 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)
-
- Blank()
-
- 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('100%')
- .backgroundColor($r("app.color.setting_background"))
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/pages/settings/settingsController.ets b/entry/src/main/ets/default/pages/settings/settingsController.ets
deleted file mode 100644
index b950b03..0000000
--- a/entry/src/main/ets/default/pages/settings/settingsController.ets
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- * 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'
-import MmsBoolean from '../../data/MmsBoolean'
-import HiLog from '../../utils/HiLog';
-import router from '@system.router';
-// JS公共常量
-import common from '../../data/commonData';
-import settingService from '../../service/SettingService'
-
-const TAG = "SettingsController";
-
-export default class SettingsController {
- private static sInstance: SettingsController;
- // 通知信息整合
- integrationSwitch: MmsBoolean = new MmsBoolean(true);
- // 恶意网站选择
- maliciousWebSwitch: boolean = false;
- // 验证码安全保护
- verificationCodeSwitch: boolean = false;
- // 显示联系人头像
- showContactSwitch: boolean = true
-
- static getInstance() {
- if(SettingsController.sInstance == null) {
- SettingsController.sInstance = new SettingsController();
- }
- return SettingsController.sInstance;
- }
-
- constructor() {
- HiLog.i(TAG, 'constructor, start');
- this.getSettingPageSwitchValue();
- }
-
- onInit() {
- HiLog.i(TAG, 'onInit, start');
- };
-
- onShow() {
- HiLog.i(TAG, 'onShow, start');
- };
-
- // 初始化setting页面的开关
- getSettingPageSwitchValue() {
- HiLog.i(TAG, 'getSettingPageSwitchValue, start');
- let that = this;
- settingService.setOnSettingValueListener(function (result) {
- that.integrationSwitch.value = result.integrationSwitch;
- that.maliciousWebSwitch = result.maliciousWebSwitch;
- that.showContactSwitch = result.showContactSwitch;
- });
- };
-
- // 通知信息整合
- integration(isOn: boolean) {
- let messageCode = common.route.MESSAGE_CODE_UPDATE_ARCHIVE_INFO_MESSAGES_VALUE;
- let actionData: LooseObject = {};
- this.integrationSwitch.value = isOn;
- if(this.integrationSwitch.value) {
- actionData.booleanValue = common.bool.TRUE;
- } else {
- actionData.booleanValue = common.bool.FALSE;
- }
- this.updateSettingPageSwitchValue(messageCode, actionData);
- };
-
- // 恶意网站选择
- maliciousWeb(e) {
- HiLog.i(TAG, 'maliciousWeb, checked = ' + e.checked);
- let messageCode = common.route.MESSAGE_CODE_UPDATE_MALICIOUS_WEBSITE_IDENTIFICATION_VALUE;
- let actionData: LooseObject = {};
- this.maliciousWebSwitch = e.checked;
- if(this.maliciousWebSwitch) {
- actionData.booleanValue = common.bool.TRUE;
- } else {
- actionData.booleanValue = common.bool.FALSE;
- }
- this.updateSettingPageSwitchValue(messageCode, actionData);
- };
-
- // 跳转至'信息铃声页面,在设置->声音和振动->信息铃声'
- jumpToMessageTonePage() {
- HiLog.i(TAG, 'jumpToMessageTonePage')
- };
-
- // 显示联系人的头像
- showContact(e) {
- HiLog.i(TAG, 'showContact, checked = ' + e.checked);
- let messageCode = common.route.MESSAGE_CODE_UPDATE_SHOW_CONTACT_PROFILE_PICS_VALUE;
- let actionData: LooseObject = {};
- this.showContactSwitch = e.checked;
- if (this.showContactSwitch) {
- actionData.booleanValue = common.bool.TRUE;
- } else {
- actionData.booleanValue = common.bool.FALSE;
- }
- this.updateSettingPageSwitchValue(messageCode, actionData);
- };
-
- // 还原设置页面的默认值
- restoreSettingsPageSwitchValue() {
- let that = this;
- settingService.restoreSwitchValue(function (result) {
- if (result.code === common.int.SUCCESS) {
- that.integrationSwitch.value = true;
- that.maliciousWebSwitch = false;
- that.showContactSwitch = true;
- HiLog.i(TAG, 'restoreSettingsPageSwitchValue, success');
- } else {
- HiLog.w(TAG, 'restoreSettingsPageSwitchValue, failed');
- }
- });
- };
-
- // 返回按钮
- back() {
- router.back();
- };
-
- // 高级 页目跳转
- advancedSetting() {
- HiLog.i(TAG, 'advancedSetting')
- router.push({
- uri: 'pages/settings/advancedSettings/advancedSettings'
- });
- };
-
- // 更新开关值
- updateSettingPageSwitchValue(messageCode, actionData) {
- HiLog.i(TAG, 'updateSettingPageSwitchValue, messageCode = ' + messageCode);
- settingService.updateSettingValue(messageCode, actionData, function (result) {
- if (result.code == common.int.SUCCESS) {
- HiLog.i(TAG, 'updateSettingPageSwitchValue, success');
- } else {
- HiLog.w(TAG, 'updateSettingPageSwitchValue, failed');
- }
- });
- };
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/utils/AppStorageUtil.ets b/entry/src/main/ets/default/utils/AppStorageUtil.ets
deleted file mode 100644
index e7eaea7..0000000
--- a/entry/src/main/ets/default/utils/AppStorageUtil.ets
+++ /dev/null
@@ -1,460 +0,0 @@
-/**
- * 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.
- */
-
-const TAG = 'AppStorageUtil';
-export default class AppStorageUtil {
- constructor() {
- this.initData()
- }
- /**
- * 是否展示通知信息
- *
- * @param hasInfoMsg 是否展示通知信息
- */
- static setHasInfoMsg(hasInfoMsg) {
- AppStorage.SetOrCreate('hasInfoMsg', hasInfoMsg);
- }
-
- /**
- * 是否展示通知信息
- *
- * @return dragItemInfo 是否展示通知信息
- */
- static getHasInfoMsg() {
- let globalData: boolean = AppStorage.Get('hasInfoMsg');
- return globalData;
- }
-
-
- /**
- * full_screen_show_picture页面中图片或视频的index
- *
- * @param indexInShowPicPage
- */
- static setIndexInShowPicPage(indexInShowPicPage) {
- AppStorage.SetOrCreate('indexInShowPicPage', indexInShowPicPage);
- }
-
- /**
- * full_screen_show_picture页面中图片或视频的index
- *
- * @return indexInShowPicPage
- */
- static getIndexInShowPicPage() {
- let indexInShowPicPage: any = AppStorage.Get('indexInShowPicPage');
- return indexInShowPicPage;
- }
-
-
- /**
- * full_screen_show_picture页面中图片或视频的checkbox的值
- *
- * @param checkedValueInShowPicPage
- */
- static setCheckedValueInShowPicPage(checkedValueInShowPicPage) {
- AppStorage.SetOrCreate('checkedValueInShowPicPage', checkedValueInShowPicPage);
- }
-
- /**
- * full_screen_show_picture页面中图片或视频的checkbox的值
- *
- * @return checkedValueInShowPicPage
- */
- static getCheckedValueInShowPicPage() {
- let checkedValueInShowPicPage: any = AppStorage.Get('checkedValueInShowPicPage');
- return checkedValueInShowPicPage;
- }
-
- /**
- * contact_item_pick页面中的电话号码列表
- *
- * @param oneContactInContactItemPickPage
- */
- static setOneContactInContactItemPickPage(oneContactInContactItemPickPage) {
- AppStorage.SetOrCreate('oneContactInContactItemPickPage', oneContactInContactItemPickPage);
- }
-
- /**
- * contact_item_pick页面中的电话号码列表
- *
- * @return oneContactInContactItemPickPage
- */
- static getOneContactInContactItemPickPage() {
- let oneContactInContactItemPickPage: any = AppStorage.Get('oneContactInContactItemPickPage');
- return oneContactInContactItemPickPage;
- }
-
- /**
- * 全屏发送值
- *
- * @param textValueOther
- */
- static setTextValueOther(textValueOther) {
- AppStorage.SetOrCreate('textValueOther', textValueOther);
- }
-
- /**
- * 全屏发送值
- *
- * @return textValueOther
- */
- static getTextValueOther() {
- let textValueOther: string = AppStorage.Get('textValueOther');
- return textValueOther;
- }
-
- /**
- * 全屏发送标记
- *
- * @param sendFlag
- */
- static setSendFlag(sendFlag) {
- AppStorage.SetOrCreate('sendFlag', sendFlag);
- }
-
- /**
- * 全屏发送标记
- *
- * @return sendFlag
- */
- static getSendFlag() {
- let sendFlag: boolean = AppStorage.Get('sendFlag');
- return sendFlag;
- }
-
-
- /**
- * 转发发送的标记
- *
- * @param transmitFlag
- */
- static setTransmitFlag(transmitFlag) {
- AppStorage.SetOrCreate('transmitFlag', transmitFlag);
- }
-
- /**
- * 转发发送的标记
- *
- * @return transmitFlag
- */
- static getTransmitFlag() {
- let transmitFlag: boolean = AppStorage.Get('transmitFlag');
- return transmitFlag;
- }
-
- /**
- * 转发内容
- *
- * @param transmitContent
- */
- static setTransmitContent(transmitContent) {
- AppStorage.SetOrCreate('transmitContent', transmitContent);
- }
-
- /**
- * 转发内容
- *
- * @return transmitContent
- */
- static getTransmitContent() {
- let transmitContent: string = AppStorage.Get('transmitContent');
- return transmitContent;
- }
-
-
- /**
- * 转发的内容包含彩信
- *
- * @param transmitContents
- */
- static setTransmitContents(transmitContents) {
- AppStorage.SetOrCreate('transmitContents', transmitContents);
- }
-
- /**
- * 转发的内容包含彩信
- *
- * @return transmitContents
- */
- static getTransmitContents() {
- let transmitContents: any = AppStorage.Get('transmitContents');
- return transmitContents;
- }
-
- /**
- *
- *
- * @param isSlideDetail
- */
- static setIsSlideDetail(isSlideDetail) {
- AppStorage.SetOrCreate('isSlideDetail', isSlideDetail);
- }
-
- /**
- *
- *
- * @return isSlideDetail
- */
- static getIsSlideDetail() {
- let isSlideDetail: boolean = AppStorage.Get('isSlideDetail');
- return isSlideDetail;
- }
-
- /**
- *
- *
- * @param mmsSource
- */
- static setMmsSource(mmsSource) {
- AppStorage.SetOrCreate('mmsSource', mmsSource);
- }
-
- /**
- *
- *
- * @return mmsSource
- */
- static getMmsSource() {
- let mmsSource: any = AppStorage.Get('mmsSource');
- return mmsSource;
- }
-
- /**
- *
- *
- * @param transmitSource
- */
- static setTransmitSource(transmitSource) {
- AppStorage.SetOrCreate('transmitSource', transmitSource);
- }
-
- /**
- *
- *
- * @return transmitSource
- */
- static getTransmitSource() {
- let sendFlag: any = AppStorage.Get('transmitSource');
- return sendFlag;
- }
-
- /**
- *
- *
- * @param isContainerOriginSource
- */
- static setIsContainerOriginSource(isContainerOriginSource) {
- AppStorage.SetOrCreate('isContainerOriginSource', isContainerOriginSource);
- }
-
- /**
- *
- *
- * @return isContainerOriginSource
- */
- static getIsContainerOriginSource() {
- let isContainerOriginSource: boolean = AppStorage.Get('isContainerOriginSource');
- return isContainerOriginSource;
- }
- /**
- * 卡的槽位
- *
- * @param slotId
- */
- static setSlotId(slotId) {
- AppStorage.SetOrCreate('slotId', slotId);
- }
-
- /**
- * 卡的槽位
- *
- * @return slotId
- */
- static getSlotId() {
- let slotId: number = AppStorage.Get('slotId');
- return slotId;
- }
- /**
- * 列表Id
- *
- * @param threadId
- */
- static setThreadId(threadId) {
- AppStorage.SetOrCreate('threadId', threadId);
- }
-
- /**
- * 列表Id
- *
- * @return threadId
- */
- static getThreadId() {
- let threadId: string = AppStorage.Get('threadId');
- return threadId;
- }
- /**
- * 联系人数量
- *
- * @param contactsNum
- */
- static setContactsNum(contactsNum) {
- AppStorage.SetOrCreate('contactsNum', contactsNum);
- }
-
- /**
- * 联系人数量
- *
- * @return contactsNum
- */
- static getContactsNum() {
- let contactsNum: number = AppStorage.Get('contactsNum');
- return contactsNum;
- }
- /**
- * 联系人名称
- *
- * @param strContactsName
- */
- static setStrContactsName(strContactsName) {
- AppStorage.SetOrCreate('strContactsName', strContactsName);
- }
-
- /**
- * 联系人名称
- *
- * @return strContactsName
- */
- static getStrContactsName() {
- let strContactsName: string = AppStorage.Get('strContactsName');
- return strContactsName;
- }
- /**
- * 联系人号码
- *
- * @param strContactsNumber
- */
- static setStrContactsNumber(strContactsNumber) {
- AppStorage.SetOrCreate('strContactsNumber', strContactsNumber);
- }
-
- /**
- * 联系人号码
- *
- * @return strContactsNumber
- */
- static getStrContactsNumber() {
- let strContactsNumber: string = AppStorage.Get('strContactsNumber');
- return strContactsNumber;
- }
- /**
- * 格式化联系人号码
- *
- * @param strContactsNumberFormat
- */
- static setStrContactsNumberFormat(strContactsNumberFormat) {
- AppStorage.SetOrCreate('strContactsNumberFormat', strContactsNumberFormat);
- }
-
- /**
- * 格式化联系人号码
- *
- * @return strContactsNumberFormat
- */
- static getStrContactsNumberFormat() {
- let strContactsNumberFormat: string = AppStorage.Get('strContactsNumberFormat');
- return strContactsNumberFormat;
- }
-
- /**
- * 是否从全屏界面回来
- *
- * @param isFromFullScreen
- */
- static setIsFromFullScreen(isFromFullScreen) {
- AppStorage.SetOrCreate('isFromFullScreen', isFromFullScreen);
- }
-
- /**
- * 是否从全屏界面回来
- *
- * @return isFromFullScreen
- */
- static getIsFromFullScreen() {
- let isFromFullScreen: boolean = AppStorage.Get('isFromFullScreen');
- return isFromFullScreen;
- }
-
- /**
- * 是否从全屏界面回来
- *
- * @param isFromFullScreen
- */
- static setPreferences(preferences) {
- AppStorage.SetOrCreate('preferences', preferences);
- }
-
- /**
- * 保存状态到AppStorage,和组件建立双向数据绑定
- *
- * @param propName 键
- * @param defaultValue 值
- */
- static setAndLink(propName, defaultValue) {
- AppStorage.SetAndLink(propName, defaultValue);
- }
-
- /**
- * 保存状态到AppStorage,和组件建立双向数据绑定
- *
- * @param propName 键
- * @param defaultValue 值
- */
- static Link(propName) {
- return AppStorage.Link(propName);
- }
-
- /**
- * 是否从全屏界面回来
- *
- * @return isFromFullScreen
- */
- static getPreferences() {
- let preferences = AppStorage.Get('preferences');
- return preferences;
- }
-
- initData(){
- AppStorageUtil.setHasInfoMsg(true)
- AppStorageUtil.setIndexInShowPicPage(undefined)
- AppStorageUtil.setCheckedValueInShowPicPage(undefined)
- AppStorageUtil.setOneContactInContactItemPickPage(undefined)
- AppStorageUtil.setTextValueOther('')
- AppStorageUtil.setSendFlag(false)
- AppStorageUtil.setTransmitFlag(false)
- AppStorageUtil.setTransmitContent('')
- AppStorageUtil.setTransmitContents([])
- AppStorageUtil.setIsSlideDetail(false)
- AppStorageUtil.setMmsSource([])
- AppStorageUtil.setTransmitSource([])
- AppStorageUtil.setIsContainerOriginSource(false)
- AppStorageUtil.setSlotId(0)
- AppStorageUtil.setThreadId('')
- AppStorageUtil.setContactsNum(0)
- AppStorageUtil.setStrContactsName('')
- AppStorageUtil.setStrContactsNumber('')
- AppStorageUtil.setStrContactsNumberFormat('')
- AppStorageUtil.setIsFromFullScreen(false)
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/utils/DeviceUtil.ets b/entry/src/main/ets/default/utils/DeviceUtil.ets
deleted file mode 100644
index 0934ab6..0000000
--- a/entry/src/main/ets/default/utils/DeviceUtil.ets
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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";
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/utils/HiLog.ets b/entry/src/main/ets/default/utils/HiLog.ets
deleted file mode 100644
index af2a301..0000000
--- a/entry/src/main/ets/default/utils/HiLog.ets
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * Log Util
- *
- * standard :
- * 1. define TAG, recommend class name。
- * 2. switch IS_DEBUG_ON as true, when debugging.
- * 3. msg should be short and valuable.
- * 4. choose appropriate function.
- * 5. the function execute many times can not print.
- * 6. uniqueness.
- *
- * @since 2022-02-18
- */
-export default class HiLog {
- private static readonly IS_DEBUG_ON: boolean = false;
- private static readonly CONTACTS_DOMAIN: string = "00800";
- private static readonly SLASH: string = "/";
- private static readonly COLON: string = ": ";
- constructor() {
- }
-
- private static prefix(tag: string) {
- return this.CONTACTS_DOMAIN + this.SLASH + tag + this.COLON;
- }
-
- static d(tag: string, msg: string, ...args: any[]) {
- if (this.IS_DEBUG_ON) {
- console.info(this.prefix(tag) + msg, args);
- } else {
- console.debug(this.prefix(tag) + msg, args);
- }
- }
-
- static i(tag: string, msg: string, ...args: any[]) {
- console.info(this.prefix(tag) + msg, args);
- }
-
- static w(tag: string, msg: string, ...args: any[]) {
- console.warn(this.prefix(tag) + msg, args);
- }
-
- static e(tag: string, msg: string, ...args: any[]) {
- console.error(this.prefix(tag) + msg, args);
- }
-}
-
diff --git a/entry/src/main/ets/default/utils/PreferencesUtil.ets b/entry/src/main/ets/default/utils/PreferencesUtil.ets
deleted file mode 100644
index a784813..0000000
--- a/entry/src/main/ets/default/utils/PreferencesUtil.ets
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- * 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 appStorage from './AppStorageUtil';
-import common from '../data/commonData';
-import dataStorage from '@ohos.data.storage';
-import featureAbility from '@ohos.ability.featureAbility';
-const TAG = 'PreferencesUtil';
-
-/**
- * 获取轻量级偏好数据库实例
- */
-export default {
-
- async initDataStorage() {
- let context = featureAbility.getContext();
- let path = await context.getFilesDir();
- return dataStorage.getStorageSync(path + common.string.PATH_OF_PREFERENCES);
- },
-
- getPreferencesInstance() {
- return appStorage.getPreferences();
- },
-
- /**
- * 获取值
- *
- * @param {string} key value值
- */
- getValue(key) {
- let prefIns = this.getPreferencesInstance();
- return prefIns.getSync(key, common.string.EMPTY_STR);
- },
-
- /**
- * 获取通知信息整合开关的值
- */
- getValueOfIntegrationSwitch() {
- let prefIns = this.getPreferencesInstance();
- return prefIns.getSync(common.string.KEY_OF_INTEGRATION_SWITCH, common.bool.TRUE);
- },
-
- /**
- * 获取恶意网址识别开关的值
- */
- getValueOfMaliciousWebSwitch() {
- let prefIns = this.getPreferencesInstance();
- return prefIns.getSync(common.string.KEY_OF_MALICIOUS_WEB_SWITCH, common.bool.FALSE);
- },
-
- /**
- * 获取显示联系人头像开关的值
- */
- getValueOfShowContactSwitch() {
- let prefIns = this.getPreferencesInstance();
- return prefIns.getSync(common.string.KEY_OF_SHOW_CONTACT_SWITCH, common.bool.TRUE);
- },
-
- /**
- * 获取送达报告开关的值
- */
- getValueOfDeliveryReportSwitch() {
- let prefIns = this.getPreferencesInstance();
- return prefIns.getSync(common.string.KEY_OF_DELIVERY_REPORT_SWITCH, common.DELIVERY_REPORTS.DISABLED);
- },
-
- /**
- * 获取自动下载彩信开关的值
- */
- getValueOfAutoRetrieveMmsSwitch() {
- let prefIns = this.getPreferencesInstance();
- return prefIns.getSync(common.string.KEY_OF_AUTO_RETRIEVE_SWITCH, common.AUTO_RETRIEVE_MMS.NOT_WHEN_ROAMING);
- },
-
- /**
- * 获取取消发送开关的值
- */
- getValueOfRecallMessageSwitch() {
- let prefIns = this.getPreferencesInstance();
- return prefIns.getSync(common.string.KEY_OF_RECALL_MESSAGE_SWITCH, common.bool.FALSE);
- },
-
- /**
- * 获取自动删除通知信息开关的值
- */
- getValueOfAutoDeleteInfoSwitch() {
- let prefIns = this.getPreferencesInstance();
- return prefIns.getSync(common.string.KEY_OF_AUTO_DELETE_INFO_SWITCH, common.bool.FALSE);
- },
-
- /**
- * 获取sim卡的个数
- */
- getCountOfSim() {
- let count = 0;
- if (this.getSim1ExistFlag() === common.bool.TRUE) {
- count++;
- }
- if (this.getSim2ExistFlag() == common.bool.TRUE) {
- count++;
- }
- return count;
- },
-
- /**
- * 获取sim卡1是否存在
- */
- getSim1ExistFlag() {
- let prefIns = this.getPreferencesInstance();
- return prefIns.getSync(common.string.KEY_OF_SIM_0_EXIST_FLAG, common.bool.FALSE);
- },
-
- /**
- * 获取sim卡2是否存在
- */
- getSim2ExistFlag() {
- let prefIns = this.getPreferencesInstance();
- return prefIns.getSync(common.string.KEY_OF_SIM_1_EXIST_FLAG, common.bool.FALSE);
- },
-
- /**
- * 获取sim卡1的运营商名字
- */
- getSpnOfSim1() {
- let prefIns = this.getPreferencesInstance();
- return prefIns.getSync(common.string.KEY_OF_SIM_0_SPN, common.string.EMPTY_STR);
- },
-
- /**
- * 获取sim卡2的运营商名字
- */
- getSpnOfSim2() {
- let prefIns = this.getPreferencesInstance();
- return prefIns.getSync(common.string.KEY_OF_SIM_1_SPN, common.string.EMPTY_STR);
- },
-
- /**
- * 获取sim卡1的新的短信中心号码,如果被修改过
- */
- getNewSmscOfSim1() {
- let prefIns = this.getPreferencesInstance();
- return prefIns.getSync(common.string.KEY_OF_NEW_SIM_0_SMSC, common.string.EMPTY_STR);
- },
-
- /**
- * 获取sim卡2的新的短信中心号码,如果被修改过
- */
- getNewSmscOfSim2() {
- let prefIns = this.getPreferencesInstance();
- return prefIns.getSync(common.string.KEY_OF_NEW_SIM_1_SMSC, common.string.EMPTY_STR);
- },
-
- /**
- * 给设置值
- */
- setValueForSwitch(keyOfSwitch, valueOfSwitch) {
- let prefIns = this.getPreferencesInstance();
- prefIns.putSync(keyOfSwitch, valueOfSwitch);
- prefIns.flushSync();
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/utils/RdbStoreUtil.ets b/entry/src/main/ets/default/utils/RdbStoreUtil.ets
deleted file mode 100644
index 32beed2..0000000
--- a/entry/src/main/ets/default/utils/RdbStoreUtil.ets
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * 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 ohosDataRdb from '@ohos.data.rdb';
-import HiLog from './HiLog';
-import mmsTable from '../data/tableData';
-
-const TAG = 'RdbStoreUtil';
-
-export default {
- /**
- * 创建数据库表
- */
- async createTable(table) {
- let rdbStore = await ohosDataRdb.getRdbStore(mmsTable.DB.MMSSMS.config, mmsTable.DB.MMSSMS.version)
- return await rdbStore.executeSql(table, null);
- },
-
- /**
- * 查询接口
- * @param predicates 查询条件
- * @return
- */
- async query(predicates) {
- let rdbStore = await ohosDataRdb.getRdbStore(mmsTable.DB.MMSSMS.config, mmsTable.DB.MMSSMS.version);
- let resultSet = await rdbStore.query(predicates);
- return resultSet;
- },
-
- /**
- * 新增数据
- */
- async insert(tableName, valueBucket) {
- let rdbStore = await ohosDataRdb.getRdbStore(mmsTable.DB.MMSSMS.config, mmsTable.DB.MMSSMS.version);
- let insertPromise = rdbStore.insert(tableName, valueBucket);
- let rowId = 0;
- insertPromise.then((ret) => {
- HiLog.i(TAG, 'insert, first done: ' + rowId);
- rowId = ret;
- }).catch((err) => {
- HiLog.e(TAG, 'insert, first fail: ' + JSON.stringify(err.message));
- })
- await insertPromise;
- return rowId;
- },
-
- /**
- * 更新接口
- * @param predicates 更新条件
- * @param predicates 更新值
- * @return
- */
- async update(predicates, valueBucket) {
- let rdbStore = await ohosDataRdb.getRdbStore(mmsTable.DB.MMSSMS.config, mmsTable.DB.MMSSMS.version);
- let changedRows = await rdbStore.update(valueBucket, predicates);
- HiLog.i(TAG, 'update, changedRows=' + changedRows);
- },
-
- /**
- * 删除接口
- * @param predicates 删除条件
- * @return
- */
- async deleteItem(predicates) {
- let rdbStore = await ohosDataRdb.getRdbStore(mmsTable.DB.MMSSMS.config, mmsTable.DB.MMSSMS.version);
- let deletedRows = await rdbStore.delete(predicates);
- HiLog.i(TAG, 'deleteItem, deletedRows=' + deletedRows);
- },
-
- /**
- * 获取查询条件的对象
- * @param tableName 表名
- * @return
- */
- getRdbPredicates(tableName){
- let predicates = new ohosDataRdb.RdbPredicates(tableName);
- return predicates;
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/utils/ResourceUtil.ets b/entry/src/main/ets/default/utils/ResourceUtil.ets
deleted file mode 100644
index 51204cc..0000000
--- a/entry/src/main/ets/default/utils/ResourceUtil.ets
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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 ResMgr from '@ohos.resourceManager';
-
-/**
- * Resource util
- */
-export class ResourceUtil {
- private resMgr;
-
- /**
- * Initialize ResourceManager
- */
- async initResourceManager(): Promise {
- if (!this.resMgr) {
- this.resMgr = await ResMgr.getResourceManager('com.ohos.mms');
- }
- return this.resMgr;
- }
-
- /**
- * Get string value from NormalResource instance
- *
- * @param resource - NormalResource instance
- */
- async getString(resource): Promise {
- await this.initResourceManager();
- let result:string = await this.resMgr.getString(resource.id);
- return result;
- }
-
- /**
- * Get getPluralString value from NormalResource instance
- *
- * @param resource - NormalResource instance
- */
- async getStringReplace(resource, list): Promise {
- await this.initResourceManager();
- let result:string = await this.resMgr.getString(resource.id);
- for (let i = 0; i < list.length; i++) {
- if (typeof (list[i]) == 'object') {
- let value = await this.resMgr.getString(list[i].id)
- result = result.replace('%s', value) || result.replace('%d', value);
- } else {
- result = result.replace('%s', list[i]) || result.replace('%d', list[i]);
- }
- }
- return result;
- }
-
- /**
- * Get direction value from NormalResource instance
- *
- * @param resource - NormalResource instance
- */
- async getConfiguration(): Promise {
- await this.initResourceManager();
- return await this.resMgr.getConfiguration();
- }
-}
-
-let resourceUtil = new ResourceUtil();
-
-export default resourceUtil as ResourceUtil;
\ No newline at end of file
diff --git a/entry/src/main/ets/default/views/MmsListItem.ets b/entry/src/main/ets/default/views/MmsListItem.ets
deleted file mode 100644
index 7aa30cb..0000000
--- a/entry/src/main/ets/default/views/MmsListItem.ets
+++ /dev/null
@@ -1,179 +0,0 @@
-/**
- * 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';
-
-@Component
-export struct MmsListItem {
- @State item: LooseObject = {};
- @State index: number = 0;
- @State isShowHead: boolean = true;
- @State isMultipleSelectState: boolean = false;
- onClickHead: (event?: ClickEvent) => void;
- onClickBody: (event?: ClickEvent) => void;
- onItemLongPress: (event?: GestureEvent) => void;
- onTouchStart: (event?: GestureEvent) => void;
- onTouchUpdate: (event?: GestureEvent) => void;
- onTouchEnd: (event?: GestureEvent) => void;
- onClickFirstSlipBtn: (event?: ClickEvent) => void;
- onClickSecondSlipBtn: (event?: ClickEvent) => void;
-
- build() {
- Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.End }) {
- Row() {
- Row() {
- //头像
- if (this.isShowHead) {
- //是否需要加未读标志红点
- Stack() {
- Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
- 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')
- .onClick(this.onClickHead)
- }
- }
- //body
- Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start }) {
- 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.conversation.name != '' ? this.item.conversation.name : this.item.conversation.telephoneFormat)
- .fontSize('16fp')
- .textOverflow({ overflow: TextOverflow.Ellipsis })
- .fontColor($r("app.color.main_font_color"))
- .maxLines(1)
- Text().width(16)
- //日期时间
- 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.conversation.sendingFailed) {
- Text($r("app.string.messageSendFailed"))
- .fontSize('12fp')
- .fontColor(Color.Red)
- } else {
- //如果不是
- Text() {
- //最新的消息是否是草稿,如果是
- if (this.item.conversation.isDraft) {
- Span($r("app.string.draft"))
- .fontSize('14fp')
- .fontColor(Color.Red)
- }
- //如果不是,且未读的消息个数>1条
- 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.conversation.content)
- .fontSize('14fp')
- .fontColor($r('app.color.main_font_color_40'))
- }
- .maxLines(1)
- .textOverflow({ overflow: TextOverflow.Ellipsis })
- }
- }
- .alignSelf(ItemAlign.Start)
- .alignItems(VerticalAlign.Top)
- .width('100%')
- .margin({ top: '2vp' })
- }.width('100%')
- .height('100%')
- }
- .layoutWeight(1)
- .height('100%')
- .padding({ left: '12vp' })
-
- //CheckBox选择框
- if (this.isMultipleSelectState) {
- Toggle({ type: ToggleType.Checkbox, isOn: this.item.conversation.isCbChecked })
- .width('20vp')
- .height('20vp')
- .enabled(false)
- }
- }
- .width('100%')
- .height('100%')
- .translate({
- x: this.item.conversation.itemLeft
- })
- //左滑的删除图标
- if (!this.isMultipleSelectState) {
- Flex({
- direction: FlexDirection.Row,
- justifyContent: FlexAlign.Center,
- alignItems: ItemAlign.Center
- }) {
- if (this.item.conversation.countOfUnread > 0) {
- Image($rawfile("icon/msg_done.svg"))
- .width(40)
- .height(40)
- .margin({ right: 8 })
- .onClick(this.onClickFirstSlipBtn)
- }
- Image($rawfile("icon/msg_delete.svg"))
- .width(40)
- .height(40)
- .onClick(this.onClickSecondSlipBtn)
- }
- .width(this.item.countOfUnread > 0 ? 128 : 80)
- .height('100%')
- .backgroundColor($r("app.color.title_bar_background"))
- .padding({ right: '16vp' })
- .translate({
- x: this.item.conversation.itemLeft
- })
- }
- }
- .width('100%')
- .height('100%')
- .gesture(PanGesture({ direction: this.item.conversation.isDelShow ? PanDirection.Right : PanDirection.Left })
- .onActionStart(this.onTouchStart)
- .onActionUpdate(this.onTouchUpdate)
- .onActionEnd(this.onTouchEnd)
- )
- }
- .onClick(this.onClickBody)
- .gesture(LongPressGesture().onAction(this.onItemLongPress))
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/views/MmsMenu.ets b/entry/src/main/ets/default/views/MmsMenu.ets
deleted file mode 100644
index 028f522..0000000
--- a/entry/src/main/ets/default/views/MmsMenu.ets
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * 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
- 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;
- }
- }
- })
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/views/SettingItem.ets b/entry/src/main/ets/default/views/SettingItem.ets
deleted file mode 100644
index 8311cd1..0000000
--- a/entry/src/main/ets/default/views/SettingItem.ets
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * 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 MmsBoolean from '../data/MmsBoolean'
-/**
- * 设置项:双标题,1开关
- */
-@Component
-export struct SettingItemSwitch {
- primaryTitle: string | Resource;
- secondaryTitle?: string | Resource;
- @ObjectLink isEnable: MmsBoolean;
- showBottomDivider ?: boolean = false;
- visibility ?: Visibility = Visibility.Visible;
- onChange: (isOn: boolean) => void;
-
- build() {
- Column() {
- Flex({direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center}) {
- Flex({direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Start}) {
- Text(this.primaryTitle)
- .height($r('app.float.settings_item_primary_title_height'))
- .fontWeight(FontWeight.Medium)
- .fontSize($r('app.float.settings_item_primary_title_font_size'))
- .fontColor("#FF182431")
- // .fontColor($r('sys.color.id_color_primary'))
-
- if (this.secondaryTitle != undefined) {
- Text(this.secondaryTitle)
- .height($r('app.float.settings_item_secondary_title_height'))
- .margin({top: $r('app.float.settings_item_title_space')})
- .fontWeight(FontWeight.Regular)
- .fontSize($r('app.float.settings_item_secondary_title_font_size'))
- .fontColor("#66182431")
- // .fontColor($r('sys.color.id_color_tertiary'))
- }
- }
- .layoutWeight(1)
-
- Toggle({ type: ToggleType.Switch, isOn: this.isEnable.value })
- .width($r('app.float.settings_item_switch_width'))
- .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.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)
- }
-}
-
-/**
- * 设置项:双标题,一个状态、一个下页图标
- */
-@Component
-export struct SettingItemJump {
- primaryTitle : string | Resource;
- secondaryTitle ?: string | Resource;
- @State statusTitle ?: string | Resource = "";
- showBottomDivider ?: boolean = false;
- visibility ?: Visibility = Visibility.Visible;
- onClick: (event?: ClickEvent) => void;
-
- build() {
- Column() {
- Flex({direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center}) {
- Flex({direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Start}) {
- Text(this.primaryTitle)
- .height($r('app.float.settings_item_primary_title_height'))
- .fontWeight(FontWeight.Medium)
- .fontSize($r('app.float.settings_item_primary_title_font_size'))
- .fontColor("#FF182431")
- // .fontColor($r('sys.color.id_color_primary'))
-
- if (this.secondaryTitle != undefined) {
- Text(this.secondaryTitle)
- .height($r('app.float.settings_item_secondary_title_height'))
- .margin({top: $r('app.float.settings_item_title_space')})
- .fontWeight(FontWeight.Regular)
- .fontSize($r('app.float.settings_item_secondary_title_font_size'))
- .fontColor("#66182431")
- // .fontColor($r('sys.color.id_color_tertiary'))
- }
- }
- .layoutWeight(1)
-
- Row() {
- if (this.statusTitle != undefined) {
- Text(this.statusTitle)
- .height($r('app.float.settings_item_secondary_title_height'))
- .margin({right: $r('app.float.settings_item_status_title_margin_right')})
- .fontWeight(FontWeight.Regular)
- .fontSize($r('app.float.settings_item_secondary_title_font_size'))
- .fontColor("#99182431")
- // .fontColor($r('sys.color.id_color_secondary'))
- }
-
- Image($rawfile("icon/ic_next.svg"))
- .width($r('app.float.settings_item_next_image_width'))
- .height($r('app.float.settings_item_next_image_height'))
- }
- }
- .layoutWeight(1)
- .onClick(this.onClick)
-
- if (this.showBottomDivider) {
- 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)
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/views/receive/receive.ets b/entry/src/main/ets/default/views/receive/receive.ets
deleted file mode 100644
index 29a371d..0000000
--- a/entry/src/main/ets/default/views/receive/receive.ets
+++ /dev/null
@@ -1,206 +0,0 @@
-/**
- * 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 ReceiveController from './receiveController'
-import ConversationController from '../../pages/conversation/conversationController'
-
-@Component
-export struct Receive {
- @State mReceiveController: ReceiveController = ReceiveController.getInstance();
- @Link mConversationController: ConversationController;
-
- aboutToAppear() {
- this.mReceiveController.onInit((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) {
- 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 })
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/views/receive/receiveController.ets b/entry/src/main/ets/default/views/receive/receiveController.ets
deleted file mode 100644
index 3f6faaf..0000000
--- a/entry/src/main/ets/default/views/receive/receiveController.ets
+++ /dev/null
@@ -1,450 +0,0 @@
-/**
- * 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 appStorage from '../../utils/AppStorageUtil';
-import HiLog from '../../utils/HiLog';
-// 收件人
-import prompt from '@system.prompt';
-// JS公共常量
-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'
-
-let ReceiveCtrl;
-
-const TAG = 'ReceiveController';
-
-export default class ReceiveController {
- private static sInstance: ReceiveController;
- commonCtrl = commonCtrl.getInstance();
- refresh: boolean = false;
- // 收件人信息(已经选择)
- selectContacts: Array = [];
- contacts: Array = [];
- // 收件人列表信息(所有的)
- contactsTemp: Array = [];
- // 收件人内容
- myText: string = '';
- colorContact: string = '#000000';
- // true 焦点编辑状态(灰色), false无焦点状态(蓝色字体)
- isInputStatus: boolean = true;
- // true 显示搜索列表
- isShowSearch: boolean = true;
- strSelectContact: string = '';
- styleTextarea: string = 'select-contact-textarea';
- hasBlur: boolean = false;
- // 列表分页,页数
- page: number = 0;
- // 列表分页,数量
- limit: number = 10;
- // 联系人的总数
- totalMessage: number = 0;
-
- static getInstance() {
- if (ReceiveController.sInstance == null) {
- ReceiveController.sInstance = new ReceiveController();
- }
- return ReceiveController.sInstance;
- }
-
- onInit(call) {
- HiLog.i(TAG, "onInit()")
- // this.$watch('paramContact', 'onPropertyChange');
- this.selectContacts = this.commonCtrl.paramContact.transmitContracts;
- if (this.selectContacts.length > 0) {
- let that = this;
- setTimeout(function () {
- that.setContactValue(call);
- }, 200);
- this.isShowSearch = false;
- this.setInputStatus(false);
- }
- this.requestItem()
- this.refresh = !this.refresh;
- }
-
- requestItem() {
- let count = this.page * this.limit;
- if (this.page === 0) {
- this.page++;
- this.queryContacts();
- } else if (count < this.totalMessage && this.contacts.length > (this.page - 1) * this.limit) {
- // 对Contacts的限制,是防止初始化时多次刷新请求
- this.page++;
- this.queryContacts();
- }
- }
-
- queryContacts() {
- let actionData = {
- page: this.page,
- limit: this.limit
- };
- // 查询联系人
- contractService.queryContact(actionData, contacts => {
- if (common.int.SUCCESS == contacts.code) {
- let response = this.contacts.concat(contacts.response);
- this.contacts = [];
- this.contacts = response;
- this.contactsTemp = this.contacts.slice(0);
- } else {
- HiLog.w(TAG, 'queryContacts, fail');
- }
- });
- // 统计数量
- contractService.countContact(actionData, contacts => {
- this.totalMessage = contacts.response;
- });
- }
-
- searchContacts(textValue, callback) {
- HiLog.i(TAG, 'searchContacts start');
- let actionData = {
- telephone: textValue,
- };
- contractService.searchContracts(actionData, res => {
- let code = res.code;
- if (common.int.SUCCESS == res.code) {
- this.contacts = [];
- this.contacts = res.response;
- } else {
- HiLog.w(TAG, 'searchContacts fail');
- }
- callback(code);
- });
- }
- // 过滤搜索词匹配联系人
- filterContacts(textValue) {
- this.contacts = this.contactsTemp.filter((contact) => {
- if (contact.contactName && contact.contactName.toLowerCase().search(textValue) != -1) {
- HiLog.i(TAG, 'filterContacts, contactName');
- return true;
- } else if (contact.telephone && contact.telephone.toLowerCase().search(textValue) != -1) {
- HiLog.i(TAG, 'filterContacts, telephone');
- return true;
- }
- return false;
- });
- }
-
- isPhoneNumber(str) {
- // 判断是否是数字
- let reg = /^\d{1,}$/;
- let pattern = new RegExp(reg);
- return pattern.test(str);
- }
-
- setInputStatus(flag) {
- this.isInputStatus = flag;
- if (!flag) {
- this.strSelectContact = this.setShowContactName();
- }
- }
-
- checkReceive(call) {
- HiLog.i(TAG, 'checkReceive, isInputStatus: ' + this.isInputStatus);
- if (this.myText.trim() == common.string.EMPTY_STR) {
- this.setInputStatus(false);
- this.isShowSearch = false;
- return;
- }
- this.hasBlur = true;
- if (this.isPhoneNumber(this.myText)) {
- // 从联系人列表中获取信息
- let that = this;
- let selectContact: LooseObject = {};
- let hasSelect = false;
- for (let index in this.contacts) {
- let contract = this.contacts[index];
- if (contract.telephone == that.myText) {
- selectContact.headImage = 'icon/user_avatar_full_fill.svg';
- selectContact.contactName = contract.contactName;
- selectContact.telephone = contract.telephone;
- selectContact.telephoneFormat = contract.telephone;
- selectContact.select = false;
- hasSelect = true;
- break;
- }
- }
- if (!hasSelect) {
- selectContact.headImage = common.string.EMPTY_STR;
- selectContact.contactName = common.string.EMPTY_STR;
- selectContact.telephone = that.myText;
- selectContact.telephoneFormat = that.myText;
- selectContact.select = false;
- }
- HiLog.i(TAG, 'checkReceive, isPhoneNumber yes');
- this.selectContacts.push(selectContact);
- this.refresh = !this.refresh;
- this.setInputStatus(false);
- this.isShowSearch = false;
- this.setContactValue(call);
- } else {
- HiLog.i(TAG, 'checkReceive, isPhoneNumber no');
- prompt.showToast({
- // 无效收件人
- // @ts-ignore
- message: $r('app.string.invalid_receive', this.myText),
- duration: 1000,
- });
- 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.myText.trim() != "") {
- this.setContactValue(call);
- this.dealSearchData();
- this.setContactValue(call);
- } else {
- this.setContactValue(call);
- }
- });
- }
-
- dealSearchData() {
- if (this.myText.trim() == "") {
- this.contacts = this.contactsTemp.slice(0);
- // this.$element('receiveTxt').focus({
- // focus: true
- // });
- } else {
- let textValue = this.myText.trim().toLowerCase();
- // 过滤逻辑
- this.filterContacts(textValue);
- }
- }
-
- setContactValue(call) {
- // 将收件人信息,传给调用的父组件
- call({
- // 选择联系人之前的输入框的内容
- contactValue: this.myText,
- // 已经选择的收件人信息
- selectContacts: this.selectContacts,
- // 焦点是否丢失
- hasBlur: this.hasBlur
- });
- }
-
- 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
- });
- this.contacts.splice(index, 1);
- HiLog.i(TAG, 'addContact, length: ' + this.selectContacts.length);
- this.myText = '';
- if (this.selectContacts.length == 1) {
- this.setInputStatus(false);
- this.isShowSearch = false;
- this.setContactValue(call);
- } else {
- this.setInputStatus(true);
- this.isShowSearch = true;
- this.setContactValue(call);
- }
- HiLog.i(TAG, 'addContact, isInputStatus: ' + this.isInputStatus);
- }
-
- setShowContactName() {
- if (this.selectContacts.length == 0) {
- return '';
- }
- 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() {
- HiLog.i(TAG, 'myContactFocus, start');
- this.myText = common.string.EMPTY_STR;
- this.setInputStatus(true);
- this.isShowSearch = true;
- }
-
- myContactClick() {
- HiLog.i(TAG, 'myContactClick, start');
- if (!this.isInputStatus) {
- this.myText = common.string.EMPTY_STR;
- this.setInputStatus(true);
- this.isShowSearch = true;
- // TextArea控件暂不支持focus
- // this.$element('receiveTxt').focus({
- // focus: true
- // });
- }
- }
-
- nameClick(idx, call) {
- HiLog.i(TAG, "click-->" + idx)
- if (this.selectContacts[idx].select) {
- let item = this.selectContacts.splice(idx, 1);
- // 已经删除的添加到 需要搜索的集合
- this.contactsTemp.push(item);
- 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) {
- var actionData: LooseObject = {};
- actionData.pageFlag = common.contractPage.PAGE_FLAG_MULT_CHOOSE;
- this.jumpToContractForResult(actionData, call);
- }
- // 点击联系人头像,跳转至联系人详情
- titleBarAvatar(index) {
- var actionData: LooseObject = {};
- actionData.phoneNumber = this.contacts[index].telephone;
- actionData.pageFlag = common.contractPage.PAGE_FLAG_CONTACT_DETAILS;
- this.jumpToContract(actionData);
- }
- // 跳转联系人app
- jumpToContract(actionData) {
- let str = commonService.commonContractParam(actionData);
- featureAbility.startAbility(str).then((data) => {
- }).catch((error) => {
- HiLog.i(TAG, 'jumpToContract failed');
- });
- }
- // 跳转联系人app
- async jumpToContractForResult(actionData, call) {
- let str = commonService.commonContractParam(actionData);
- var data = await featureAbility.startAbilityForResult(str);
- if (data.resultCode == 0) {
- this.dealContractParams(data.want.parameters.contactObjects, call);
- }
- }
-
- dealContractParams(contactObjects, call) {
- let params = JSON.parse(contactObjects);
- if (params.length > 1 || this.checkSingle()) {
- return;
- }
- if (params.length == 1) {
- let element = params[0]
- let selectContact: LooseObject = {};
- selectContact.headImage = 'icon/user_avatar_full_fill.svg';
- selectContact.contactName = element.contactName;
- selectContact.telephone = element.telephone;
- selectContact.telephoneFormat = element.telephone;
- selectContact.select = false;
- this.selectContacts.push(selectContact);
- }
- if (this.selectContacts.length > 0) {
- this.deleteRepetitionContracts(this.contacts, this.selectContacts);
- this.setInputStatus(false);
- this.isShowSearch = false;
- this.setContactValue(call);
- }
- this.commonCtrl.paramContact.isSelectContact = false;
- this.commonCtrl.paramContact.isNewRecallMessagesFlag = false;
- }
-
- deleteRepetitionContracts(contacts, selectContacts) {
- let indexs = [];
- let count = 0;
- for (let item of contacts) {
- let telephone = item.telephone;
- for (let selectContact of selectContacts) {
- if (telephone == selectContact.telephone) {
- indexs.push(count);
- break;
- }
- }
- count++;
- }
- let selectContactIndexs = [];
- for (let i = 0; i < selectContacts.length; i++) {
- let telephone = selectContacts[i].telephone;
- for (let j = i + 1; j < selectContacts.length; j++) {
- if (telephone == selectContacts[j].telephone) {
- selectContactIndexs.push(i);
- break;
- }
- }
- }
- if (indexs.length > 0) {
- for (let index of indexs) {
- contacts.splice(index, 1);
- }
- }
- if (selectContactIndexs.length > 0) {
- for (let index of selectContactIndexs) {
- selectContacts.splice(index, 1);
- }
- }
- }
-
- // 目前只支持单个收件人,先规避操作只能输入一个收件人
- checkSingle() {
- if (this.selectContacts.length > 0) {
- prompt.showToast({
- // 无效收件人
- // @ts-ignore
- message: "只支持单个收件人",
- duration: 1000,
- });
- return true;
- } else {
- return false;
- }
- }
-}
\ No newline at end of file
diff --git a/entry/src/main/ets/model/BaseDataSource.ets b/entry/src/main/ets/model/BaseDataSource.ets
new file mode 100644
index 0000000..d6b8f1c
--- /dev/null
+++ b/entry/src/main/ets/model/BaseDataSource.ets
@@ -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.onDataAdd(index)
+ })
+ }
+
+ notifyDataChange(index: number): void {
+ this.listeners.forEach(listener => {
+ listener.onDataChange(index)
+ })
+ }
+
+ notifyDataDelete(index: number): void {
+ this.listeners.forEach(listener => {
+ listener.onDataDelete(index)
+ })
+ }
+
+ notifyDataMove(from: number, to: number): void {
+ this.listeners.forEach(listener => {
+ listener.onDataMove(from, to)
+ })
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/model/BaseModel.ets b/entry/src/main/ets/model/BaseModel.ets
similarity index 87%
rename from entry/src/main/ets/default/model/BaseModel.ets
rename to entry/src/main/ets/model/BaseModel.ets
index 52a52b6..ae6061e 100644
--- a/entry/src/main/ets/default/model/BaseModel.ets
+++ b/entry/src/main/ets/model/BaseModel.ets
@@ -12,18 +12,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import LooseObject from '../data/LooseObject';
+import LooseObject from "../data/LooseObject";
export default class BaseModel {
encapsulateReturnResult(code, abilityResult) {
- var result:LooseObject = {};
+ var result: LooseObject = {};
result.code = code;
result.abilityResult = abilityResult;
return result;
}
encapsulateReturnCode(code) {
- var result:LooseObject = {};
+ var result: LooseObject = {};
result.code = code;
return result;
}
diff --git a/entry/src/main/ets/default/model/CardModel.ets b/entry/src/main/ets/model/CardModel.ets
similarity index 61%
rename from entry/src/main/ets/default/model/CardModel.ets
rename to entry/src/main/ets/model/CardModel.ets
index e66f0d2..4ac22bc 100644
--- a/entry/src/main/ets/default/model/CardModel.ets
+++ b/entry/src/main/ets/model/CardModel.ets
@@ -13,53 +13,54 @@
* limitations under the License.
*/
-import BaseModel from './BaseModel';
-import common from '../data/commonData';
-import LooseObject from '../data/LooseObject'
-import HiLog from '../utils/HiLog';
-import telephonySMS from '@ohos.telephony.sms';
-import telephonySim from '@ohos.telephony.sim';
+import BaseModel from "./BaseModel";
+import common from "../data/commonData";
+import LooseObject from "../data/LooseObject"
+import HiLog from "../utils/HiLog";
+import MmsPreferences from "../utils/MmsPreferences";
+import telephonySMS from "@ohos.telephony.sms";
+import telephonySim from "@ohos.telephony.sim";
-const TAG = 'CardModel';
+const TAG = "CardModel";
export default class CardModel extends BaseModel {
- getSimSpn(preferences) {
+ getSimSpn() {
telephonySim.getSimSpn(common.int.SIM_ONE, (err, value) => {
if (err) {
- HiLog.e(TAG, 'getSimSpn, SIM_ONE error: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "getSimSpn, SIM_ONE error: " + JSON.stringify(err.message));
} else {
- preferences.setValueForSwitch(common.string.KEY_OF_SIM_0_SPN, value);
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_SIM_0_SPN, value);
}
});
telephonySim.getSimSpn(common.int.SIM_TWO, (err, value) => {
if (err) {
- HiLog.e(TAG, 'getSimSpn, SIM_TWO error: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "getSimSpn, SIM_TWO error: " + JSON.stringify(err.message));
} else {
- preferences.setValueForSwitch(common.string.KEY_OF_SIM_1_SPN, value);
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_SIM_1_SPN, value);
}
});
}
- getSmscNumber(slotId, preferences, callback) {
+ getSmscNumber(slotId, callback) {
let smsNumber = common.string.EMPTY_STR;
- let simOne = preferences.getNewSmscOfSim1();
- let simTwo = preferences.getNewSmscOfSim2();
+ let simOne = MmsPreferences.getInstance().getNewSmscOfSim1();
+ let simTwo = MmsPreferences.getInstance().getNewSmscOfSim2();
if (slotId == common.int.SIM_ONE && simOne != common.string.EMPTY_STR) {
smsNumber = simOne;
} else if (slotId == common.int.SIM_TWO && simTwo != common.string.EMPTY_STR) {
smsNumber = simTwo;
} else {
- // 调用API获取
+ // Invoke the API to obtain the information.
telephonySMS.getSmscAddr(slotId).then((simPhoneNumber) => {
smsNumber = simPhoneNumber;
if (slotId == common.int.SIM_ONE) {
- preferences.setValueForSwitch(common.string.KEY_OF_NEW_SIM_0_SMSC, simPhoneNumber);
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_NEW_SIM_0_SMSC, simPhoneNumber);
} else if (slotId == common.int.SIM_TWO) {
- preferences.setValueForSwitch(common.string.KEY_OF_NEW_SIM_1_SMSC, simPhoneNumber);
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_NEW_SIM_1_SMSC, simPhoneNumber);
}
callback(smsNumber);
}).catch((error) => {
- HiLog.e(TAG, 'getSmscNumber, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "get SMSC number error: " + JSON.stringify(error.message));
});
}
callback(smsNumber);
@@ -67,16 +68,16 @@ export default class CardModel extends BaseModel {
queryMessageInSimCard(actionData, callback) {
let index = actionData.index - 1;
- // 获取sim卡内信息的API目前未提供. 获取sim卡内短信
+ // Currently, the API for obtaining SIM card information is not provided. Obtaining SIM card SMS messages
let simMessageList = [];
telephonySMS.getAllSimMessages(index, (error, msgArray) => {
if (error) {
- HiLog.e(TAG, 'queryMessageInSimCard, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "queryMessageInSimCard, error: " + JSON.stringify(error.message));
return;
}
for (let i = 0;i < msgArray.length; i++) {
let data: LooseObject = {};
- data.image = '/common/icon/user_avatar_full_fill.svg';
+ data.image = "/common/icon/user_avatar_full_fill.svg";
data.date = common.string.EMPTY_STR;
data.time = common.string.EMPTY_STR;
data.timeMillisecond = msgArray[i].shortMessage.scTimestamp;
@@ -98,45 +99,45 @@ export default class CardModel extends BaseModel {
let msgIndex = actionData.indexOnSim;
telephonySMS.delSimMessage(index, msgIndex, (error, value) => {
if (error) {
- HiLog.e(TAG, 'delSimMessage, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "delSimMessage, error: " + JSON.stringify(error.message));
} else {
}
});
}
- getSimCardNum(preferences) {
+ getSimCardNum() {
telephonySim.hasSimCard(common.int.SIM_ONE, (error, value) => {
if (error) {
- HiLog.e(TAG, 'getSimCardNum, SIM_ONE error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "getSimCardNum, SIM_ONE error: " + JSON.stringify(error.message));
} else {
let result = value ? common.bool.TRUE : common.bool.FALSE;
- preferences.setValueForSwitch(common.string.KEY_OF_SIM_0_EXIST_FLAG, result);
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_SIM_0_EXIST_FLAG, result);
}
});
telephonySim.hasSimCard(common.int.SIM_TWO, (error, value) => {
if (error) {
- HiLog.e(TAG, 'getSimCardNum, SIM_TWO error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "getSimCardNum, SIM_TWO error: " + JSON.stringify(error.message));
} else {
let result = value ? common.bool.TRUE : common.bool.FALSE;
- preferences.setValueForSwitch(common.string.KEY_OF_SIM_1_EXIST_FLAG, result);
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_SIM_1_EXIST_FLAG, result);
}
});
}
- getSimTelephoneNumber(preferences) {
- HiLog.i(TAG, 'getSimTelephoneNumber start');
+ getSimTelephoneNumber() {
+ HiLog.i(TAG, "get sim telephone number start");
telephonySim.getSimTelephoneNumber(common.int.SIM_ONE, (error, value) => {
if (error) {
- HiLog.e(TAG, 'getSimTelephoneNumber, SIM_ONE error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "get SIM_ONE telephone number error: " + JSON.stringify(error.message));
} else {
- preferences.setValueForSwitch(common.string.KEY_OF_SIM_0_NUMBER, value);
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_SIM_0_NUMBER, value);
}
});
telephonySim.getSimTelephoneNumber(common.int.SIM_TWO, (error, value) => {
if (error) {
- HiLog.e(TAG, 'getSimTelephoneNumber, SIM_TWO error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "get SIM_TWO telephone number error: " + JSON.stringify(error.message));
} else {
- preferences.setValueForSwitch(common.string.KEY_OF_SIM_1_NUMBER, value);
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_SIM_1_NUMBER, value);
}
});
}
diff --git a/entry/src/main/ets/default/model/ContactsModel.ets b/entry/src/main/ets/model/ContactsModel.ets
similarity index 75%
rename from entry/src/main/ets/default/model/ContactsModel.ets
rename to entry/src/main/ets/model/ContactsModel.ets
index 86ea7da..3e91e3c 100644
--- a/entry/src/main/ets/default/model/ContactsModel.ets
+++ b/entry/src/main/ets/model/ContactsModel.ets
@@ -13,19 +13,19 @@
* limitations under the License.
*/
-import BaseModel from './BaseModel';
-import common from '../data/commonData';
-import HiLog from '../utils/HiLog';
-import mmsTable from '../data/tableData';
-import LooseObject from '../data/LooseObject'
-import featureAbility from '@ohos.ability.featureAbility';
-import dataAbility from '@ohos.data.dataAbility';
+import BaseModel from "./BaseModel";
+import common from "../data/commonData";
+import HiLog from "../utils/HiLog";
+import mmsTable from "../data/tableData";
+import LooseObject from "../data/LooseObject"
+import featureAbility from "@ohos.ability.featureAbility";
+import dataAbility from "@ohos.data.dataAbility";
-const TAG = 'ContactsModel';
+const TAG = "ContactsModel";
export default class ContactsModel extends BaseModel {
async queryContactDataByIds(actionData, callback) {
- let dataHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_ROW_CONTACTS);
+ let dataHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_ROW_CONTACTS);
let resultColumns = [
mmsTable.contactDataColumns.detailInfo,
mmsTable.contactDataColumns.displayName,
@@ -34,18 +34,19 @@ export default class ContactsModel extends BaseModel {
let contactDataUri = common.string.URI_ROW_CONTACTS + common.string.CONTACT_DATA_URI;
condition.in(mmsTable.contactDataColumns.contactId, actionData.contractIds);
condition.and();
- condition.equalTo(mmsTable.contactDataColumns.typeId, '5');
+ condition.equalTo(mmsTable.contactDataColumns.typeId, "5");
condition.and();
- condition.equalTo(mmsTable.contactDataColumns.hasDelete, '0');
+ condition.equalTo(mmsTable.contactDataColumns.hasDelete, "0");
dataHelper.query(contactDataUri, resultColumns, condition).then(resultSet => {
callback(this.dealResultSet(resultSet));
}).catch(error => {
- HiLog.e(TAG, 'queryContactDataByIds, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "queryContactDataByIds, error: " + JSON.stringify(error.message));
});
}
async queryContactDataByTelephone(actionData, callback) {
- let telephoneDataHelp = await featureAbility.acquireDataAbilityHelper(common.string.URI_ROW_CONTACTS);
+ let telephoneDataHelp = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext,
+ common.string.URI_ROW_CONTACTS);
let resultColumns = [
mmsTable.contactDataColumns.detailInfo,
mmsTable.contactDataColumns.displayName,
@@ -54,13 +55,13 @@ export default class ContactsModel extends BaseModel {
let contactDataUri = common.string.URI_ROW_CONTACTS + common.string.CONTACT_DATA_URI;
condition.in(mmsTable.contactDataColumns.detailInfo, actionData.telephones);
condition.and();
- condition.equalTo(mmsTable.contactDataColumns.typeId, '5');
+ condition.equalTo(mmsTable.contactDataColumns.typeId, "5");
condition.and();
- condition.equalTo(mmsTable.contactDataColumns.hasDelete, '0');
+ condition.equalTo(mmsTable.contactDataColumns.hasDelete, "0");
telephoneDataHelp.query(contactDataUri, resultColumns, condition).then(resultSet => {
callback(this.dealResultSet(resultSet));
}).catch(error => {
- HiLog.e(TAG, 'queryContactDataByTelephone, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "queryContactDataByTelephone, error: " + JSON.stringify(error.message));
callback([]);
});
}
@@ -77,7 +78,7 @@ export default class ContactsModel extends BaseModel {
}
async queryContact(actionData, callback) {
- let DAHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_ROW_CONTACTS);
+ let DAHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_ROW_CONTACTS);
let resultColumns = [
mmsTable.contactColumns.id
];
@@ -94,12 +95,12 @@ export default class ContactsModel extends BaseModel {
}
callback(rawContactIds);
}).catch(error => {
- HiLog.e(TAG, 'queryContact, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "queryContact, error: " + JSON.stringify(error.message));
});
}
async countContact(actionData, callback) {
- let DAHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_ROW_CONTACTS);
+ let DAHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_ROW_CONTACTS);
let resultColumns = [
mmsTable.contactColumns.id
];
@@ -113,19 +114,20 @@ export default class ContactsModel extends BaseModel {
}
callback(count);
}).catch(error => {
- HiLog.e(TAG, 'countContact, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "countContact, error: " + JSON.stringify(error.message));
});
}
async searchContracts(actionData, callback) {
- let searchDataHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_ROW_CONTACTS);
+ let searchDataHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext,
+ common.string.URI_ROW_CONTACTS);
let resultColumns = [
mmsTable.searchContactView.detailInfo,
mmsTable.searchContactView.displayName
];
let condition = new dataAbility.DataAbilityPredicates();
let searchContactsUri = common.string.URI_ROW_CONTACTS + common.string.CONTACT_SEARCHE;
- condition.equalTo(mmsTable.searchContactView.contentType, 'phone')
+ condition.equalTo(mmsTable.searchContactView.contentType, "phone")
.beginWrap()
.contains(mmsTable.searchContactView.displayName, actionData.telephone)
.or()
@@ -135,19 +137,19 @@ export default class ContactsModel extends BaseModel {
let contracts = this.dealResultSet(resultSet);
callback(this.encapsulateReturnResult(common.int.SUCCESS, contracts));
}).catch(error => {
- HiLog.e(TAG, 'searchContracts, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "searchContracts, error: " + JSON.stringify(error.message));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
/**
- * 查询名片数据
- * @param actionData 查询参数
- * @param callback 回调
+ * Querying Business Card Data
+ * @param actionData Query parameters
+ * @param callback
*/
async queryProfile(actionData, callback) {
- HiLog.i(TAG, 'queryProfile start ');
- let DAHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_ROW_CONTACTS);
+ HiLog.i(TAG, "queryProfile start ");
+ let DAHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_ROW_CONTACTS);
let resultColumns = [
mmsTable.contactDataColumns.id,
];
@@ -158,11 +160,11 @@ export default class ContactsModel extends BaseModel {
while (resultSet.goToNextRow()) {
count++;
}
- HiLog.i(TAG, 'queryProfile, goToNextRow: ' + count);
+ HiLog.i(TAG, "queryProfile, goToNextRow: " + count);
resultSet.close();
callback(count);
}).catch(error => {
- HiLog.e(TAG, 'queryProfile, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "queryProfile, error: " + JSON.stringify(error.message));
});
}
}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/model/ConversationListDataSource.ets b/entry/src/main/ets/model/ConversationListDataSource.ets
similarity index 89%
rename from entry/src/main/ets/default/model/ConversationListDataSource.ets
rename to entry/src/main/ets/model/ConversationListDataSource.ets
index 524856e..d080195 100644
--- a/entry/src/main/ets/default/model/ConversationListDataSource.ets
+++ b/entry/src/main/ets/model/ConversationListDataSource.ets
@@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import BaseDataSource from './BaseDataSource';
-import HiLog from '../utils/HiLog';
+import BaseDataSource from "./BaseDataSource";
+import HiLog from "../utils/HiLog";
const TAG = "ConversationListDataSource";
@@ -27,7 +27,6 @@ export default class ConversationListDataSource extends BaseDataSource {
}
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;
@@ -41,7 +40,7 @@ export default class ConversationListDataSource extends BaseDataSource {
}
public refresh(conversationList) {
- HiLog.i(TAG, ' refresh!');
+ HiLog.i(TAG, " refresh!");
this.mmsList = conversationList;
this.notifyDataReload();
}
diff --git a/entry/src/main/ets/default/model/ConversationListModel.ets b/entry/src/main/ets/model/ConversationListModel.ets
similarity index 68%
rename from entry/src/main/ets/default/model/ConversationListModel.ets
rename to entry/src/main/ets/model/ConversationListModel.ets
index 3a1e794..a71c818 100644
--- a/entry/src/main/ets/default/model/ConversationListModel.ets
+++ b/entry/src/main/ets/model/ConversationListModel.ets
@@ -13,29 +13,30 @@
* limitations under the License.
*/
-import BaseModel from './BaseModel';
-import common from '../data/commonData';
-import dataAbility from '@ohos.data.dataAbility';
-import mmsTable from '../data/tableData';
-import HiLog from '../utils/HiLog';
-import LooseObject from '../data/LooseObject'
-import rdbStore from '../utils/RdbStoreUtil';
-import featureAbility from '@ohos.ability.featureAbility';
+import BaseModel from "./BaseModel";
+import common from "../data/commonData";
+import dataAbility from "@ohos.data.dataAbility";
+import mmsTable from "../data/tableData";
+import HiLog from "../utils/HiLog";
+import LooseObject from "../data/LooseObject"
+import MmsDatabaseHelper from "../utils/MmsDatabaseHelper";
+import featureAbility from "@ohos.ability.featureAbility";
+import ohosDataRdb from "@ohos.data.rdb";
-const TAG = 'ConversationListModel';
+const TAG = "ConversationListModel";
export default class ConversationListModel extends BaseModel {
async querySessionList(actionData) {
- let predicates = rdbStore.getRdbPredicates(common.tableName.SESSION);
+ let predicates = new ohosDataRdb.RdbPredicates(MmsDatabaseHelper.TABLE.SESSION);
let numberType = actionData.numberType;
if (numberType != null) {
await predicates.equalTo(mmsTable.sessionField.smsType, numberType);
}
await predicates.orderByDesc(mmsTable.sessionField.time);
await predicates.limitAs(actionData.limit);
- let offset = (actionData.page - 1) * actionData.limit;
+ let offset = actionData.page < 3 ? (actionData.page - 1) * 50 : (actionData.page - 2) * 500 + 50;
await predicates.offsetAs(offset);
- let resultSet = await rdbStore.query(predicates);
+ let resultSet = await globalThis.MmsDatabaseHelper.query(predicates);
let sessionList = [];
while (resultSet.goToNextRow()) {
let item = await this.buildResultSet(resultSet);
@@ -48,37 +49,41 @@ export default class ConversationListModel extends BaseModel {
}
async querySessionByTelephone(telephone) {
- HiLog.i(TAG, ', querySessionByTelephone start')
- let predicates = rdbStore.getRdbPredicates(common.tableName.SESSION);
+ HiLog.i(TAG, "query session by telephone")
+ let predicates = new ohosDataRdb.RdbPredicates(MmsDatabaseHelper.TABLE.SESSION);
if (telephone) {
await predicates.equalTo(mmsTable.sessionField.telephone, telephone);
}
- let resultSet = await rdbStore.query(predicates);
+
+ let resultSet = await globalThis.MmsDatabaseHelper.query(predicates);
+ if(resultSet === null) {
+ return null;
+ }
resultSet.goToFirstRow();
let result = await this.buildResultSet(resultSet);
return result;
}
async querySessionById(threadId) {
- let predicates = rdbStore.getRdbPredicates(common.tableName.SESSION);
+ let predicates = new ohosDataRdb.RdbPredicates(MmsDatabaseHelper.TABLE.SESSION);
if (threadId) {
await predicates.equalTo(mmsTable.sessionField.id, threadId);
}
- let resultSet = await rdbStore.query(predicates);
+ let resultSet = await globalThis.MmsDatabaseHelper.query(predicates);
resultSet.goToFirstRow();
let result = await this.buildResultSet(resultSet);
return result;
}
async searchSessionByTelephone(telephone, numberType) {
- let predicates = rdbStore.getRdbPredicates(common.tableName.SESSION);
+ let predicates = new ohosDataRdb.RdbPredicates(MmsDatabaseHelper.TABLE.SESSION);
if (telephone != common.string.EMPTY_STR) {
- await predicates.like(mmsTable.sessionField.telephone, '%' + telephone + '%');
+ await predicates.like(mmsTable.sessionField.telephone, "%" + telephone + "%");
}
if (numberType != null) {
await predicates.equalTo(mmsTable.sessionField.smsType, numberType);
}
- let resultSet = await rdbStore.query(predicates);
+ let resultSet = await globalThis.MmsDatabaseHelper.query(predicates);
let sessionList = [];
while (resultSet.goToNextRow()) {
let item = await this.buildResultSet(resultSet);
@@ -107,12 +112,12 @@ export default class ConversationListModel extends BaseModel {
}
async countSessionList(actionData) {
- let predicates = rdbStore.getRdbPredicates(common.tableName.SESSION);
+ let predicates = new ohosDataRdb.RdbPredicates(MmsDatabaseHelper.TABLE.SESSION);
let numberType = actionData.numberType;
if (numberType != null) {
await predicates.equalTo(mmsTable.sessionField.smsType, numberType);
}
- let resultSet = await rdbStore.query(predicates);
+ let resultSet = await globalThis.MmsDatabaseHelper.query(predicates);
let count = 0;
while (resultSet.goToNextRow()) {
count++;
@@ -124,13 +129,17 @@ export default class ConversationListModel extends BaseModel {
}
async statisticalData(actionData, callback) {
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(
- common.string.URI_MESSAGE_LOG
- );
+ let mmsContext;
+ if (actionData.mmsContext) {
+ mmsContext = actionData.mmsContext;
+ } else {
+ mmsContext = globalThis.mmsContext;
+ }
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(mmsContext, common.string.URI_MESSAGE_LOG);
let resultColumns = [
- 'totalListCount',
- 'unreadCount',
- 'unreadTotalOfInfo'
+ "totalListCount",
+ "unreadCount",
+ "unreadTotalOfInfo"
];
let condition = new dataAbility.DataAbilityPredicates();
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_UNREAD_COUNT;
@@ -146,53 +155,53 @@ export default class ConversationListModel extends BaseModel {
}
async markAllAsRead(threadIds, valueBucket) {
- HiLog.i(TAG, 'markAllAsRead, threadIds:' + JSON.stringify(threadIds));
+ HiLog.i(TAG, "markAllAsRead, threadIds:" + JSON.stringify(threadIds));
this.updateById(threadIds, valueBucket);
}
async markAllToRead(smsType) {
- let predicates = rdbStore.getRdbPredicates(common.tableName.SESSION);
+ let predicates = new ohosDataRdb.RdbPredicates(MmsDatabaseHelper.TABLE.SESSION);
predicates.equalTo(mmsTable.sessionField.smsType, smsType);
predicates.greaterThan(mmsTable.sessionField.unreadCount, 0);
let valueBucket = {
- 'unread_count': 0
+ "unread_count": 0
};
- rdbStore.update(predicates, valueBucket);
+ globalThis.MmsDatabaseHelper.update(predicates, valueBucket);
}
async updateById(threadIds, valueBucket) {
- HiLog.i(TAG, ', updateById, threadIds: ' + JSON.stringify(threadIds))
+ HiLog.i(TAG, ", updateById, threadIds: " + JSON.stringify(threadIds))
if (threadIds.length != 0) {
for (let threadId of threadIds) {
- let predicates = rdbStore.getRdbPredicates(common.tableName.SESSION);
+ let predicates = new ohosDataRdb.RdbPredicates(MmsDatabaseHelper.TABLE.SESSION);
await predicates.equalTo(mmsTable.sessionField.id, threadId);
- rdbStore.update(predicates, valueBucket);
- HiLog.d(TAG, ', update SESSION TAB end')
+ globalThis.MmsDatabaseHelper.update(predicates, valueBucket);
+ HiLog.d(TAG, ", update session TAB end")
}
}
}
async deleteMessageById(threadIds) {
- HiLog.i(TAG, 'deleteMessageById, threadIds: ' + JSON.stringify(threadIds));
+ HiLog.i(TAG, "deleteMessageById, threadIds: " + JSON.stringify(threadIds));
if (threadIds.length != 0) {
for (let threadId of threadIds) {
- let predicates = rdbStore.getRdbPredicates(common.tableName.SESSION);
+ let predicates = new ohosDataRdb.RdbPredicates(MmsDatabaseHelper.TABLE.SESSION);
await predicates.equalTo(mmsTable.sessionField.id, threadId);
- rdbStore.deleteItem(predicates);
- HiLog.d(TAG, ', delete SESSION TAB end')
+ globalThis.MmsDatabaseHelper.deleteItem(predicates);
+ HiLog.d(TAG, ", delete session TAB end")
}
}
}
- insertSession(tableName, valueBucket, callback) {
- let insertPromise = rdbStore.insert(tableName, valueBucket);
+ insertSession(valueBucket, callback) {
+ let insertPromise = globalThis.MmsDatabaseHelper.insert(MmsDatabaseHelper.TABLE.SESSION, valueBucket);
let result: LooseObject = {};
insertPromise.then((ret) => {
result.code = common.int.SUCCESS;
result.rowId = ret;
callback(result);
}).catch((err) => {
- HiLog.e(TAG, 'insertSession, error: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "insertSession, error: " + JSON.stringify(err.message));
result.code = common.int.FAILURE;
callback(result);
});
diff --git a/entry/src/main/ets/default/model/ConversationModel.ets b/entry/src/main/ets/model/ConversationModel.ets
similarity index 80%
rename from entry/src/main/ets/default/model/ConversationModel.ets
rename to entry/src/main/ets/model/ConversationModel.ets
index 331d877..6053e71 100644
--- a/entry/src/main/ets/default/model/ConversationModel.ets
+++ b/entry/src/main/ets/model/ConversationModel.ets
@@ -13,29 +13,33 @@
* limitations under the License.
*/
-import BaseModel from './BaseModel';
-import MorkDataModel from './MorkDataModel';
-import common from '../data/commonData';
-import mmsTable from '../data/tableData';
-// log 工具类
-import HiLog from '../utils/HiLog'
-import LooseObject from '../data/LooseObject'
-import featureAbility from '@ohos.ability.featureAbility';
-import dataAbility from '@ohos.data.dataAbility';
+import BaseModel from "./BaseModel";
+import MorkDataModel from "./MorkDataModel";
+import common from "../data/commonData";
+import mmsTable from "../data/tableData";
+// log Tools
+import HiLog from "../utils/HiLog"
+import LooseObject from "../data/LooseObject"
+import featureAbility from "@ohos.ability.featureAbility";
+import dataAbility from "@ohos.data.dataAbility";
-const TAG = 'ConversationModel';
+const TAG = "ConversationModel";
let morkDataModel = new MorkDataModel();
export default class ConversationModel extends BaseModel {
async queryMessageDetail(actionData, callback) {
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
var resultColumns = this.buildResultColumns();
let condition = this.buildQueryCondition(actionData);
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.query(managerUri, resultColumns, condition).then(resultSet => {
let resultList = [];
- while (resultSet.goToNextRow()) {
+ if( !resultSet.goToFirstRow() ) {
+ callback(this.encapsulateReturnResult(common.int.SUCCESS, resultList));
+ return;
+ }
+ do{
let result: LooseObject = {};
this.dealBaseColumsData(result, resultSet);
result.operatorServiceNumber = resultSet.getString(resultSet.getColumnIndex("operator_service_number"));
@@ -51,10 +55,10 @@ export default class ConversationModel extends BaseModel {
result.isSender = resultSet.getString(resultSet.getColumnIndex("is_sender"));
result.isSendReport = resultSet.getString(resultSet.getColumnIndex("is_send_report"));
resultList.push(result);
- }
+ } while ( resultSet.goToNextRow() )
callback(this.encapsulateReturnResult(common.int.SUCCESS, resultList));
}).catch(error => {
- HiLog.e(TAG, 'queryMessageDetail, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "queryMessageDetail, error: " + JSON.stringify(error.message));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
@@ -88,7 +92,7 @@ export default class ConversationModel extends BaseModel {
buildBaseColumns() {
var resultColumns = [
mmsTable.messageInfo.msgId,
- // 接收者手机号
+ // Recipient Mobile Number
mmsTable.messageInfo.receiverNumber,
mmsTable.messageInfo.senderNumber,
mmsTable.messageInfo.startTime,
@@ -96,7 +100,7 @@ export default class ConversationModel extends BaseModel {
mmsTable.messageInfo.msgType,
// sms = 0,mms,
mmsTable.messageInfo.smsType,
- // 0-普通,1-通知
+ // 0: normal; 1: notification
mmsTable.messageInfo.msgTitle,
mmsTable.messageInfo.msgContent,
mmsTable.messageInfo.msgState
@@ -113,9 +117,9 @@ export default class ConversationModel extends BaseModel {
mmsTable.messageInfo.isRead,
mmsTable.messageInfo.isCollect,
mmsTable.messageInfo.sessionType,
- // 0 - 普通 1 - 广播 2 - 群发
+ // 0: common; 1: broadcast; 2: group-send
mmsTable.messageInfo.retryNumber,
- // 重发次数
+ // Number of resending times
mmsTable.messageInfo.isSubsection,
mmsTable.messageInfo.sessionId,
mmsTable.messageInfo.groupId,
@@ -126,10 +130,10 @@ export default class ConversationModel extends BaseModel {
}
async searchSmsMessageByContent(actionData, callback) {
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
var resultColumns = this.buildSearchResultColums();
let condition = new dataAbility.DataAbilityPredicates();
- condition.like(mmsTable.messageInfo.msgContent, '%' + actionData.content + '%');
+ condition.like(mmsTable.messageInfo.msgContent, "%" + actionData.content + "%");
condition.equalTo(mmsTable.messageInfo.msgType, 0);
if (actionData.numberType != null) {
condition.equalTo(mmsTable.messageInfo.smsType, actionData.numberType);
@@ -148,7 +152,7 @@ export default class ConversationModel extends BaseModel {
}
callback(this.encapsulateReturnResult(common.int.SUCCESS, resultList));
}).catch(error => {
- HiLog.e(TAG, 'searchSmsMessageByContent, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "searchSmsMessageByContent, error: " + JSON.stringify(error.message));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
@@ -178,30 +182,30 @@ export default class ConversationModel extends BaseModel {
}
async insertMessageDetail(actionData, callback) {
- HiLog.i(TAG, 'insertMessageDetail, start')
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ HiLog.i(TAG, "insertMessageDetail, start")
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.insert(managerUri, actionData.stringValue).then(data => {
callback(this.encapsulateReturnResult(common.int.SUCCESS, data));
}).catch(error => {
- HiLog.e(TAG, 'insertMessageDetail, fail: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "insertMessageDetail, fail: " + JSON.stringify(error.message));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
async updateLock(actionData, callback) {
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
var groupIds = this.groupIdToString(actionData.groupIds);
var condition = new dataAbility.DataAbilityPredicates();
condition.in(mmsTable.messageInfo.groupId, groupIds);
var stringValue = {
- 'is_lock': actionData.hasLock,
+ "is_lock": actionData.hasLock,
};
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.update(managerUri, stringValue, condition).then((data) => {
callback(this.encapsulateReturnCode(common.int.SUCCESS));
}).catch((err) => {
- HiLog.e(TAG, 'updateLock, err: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "updateLock, err: " + JSON.stringify(err.message));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
@@ -215,24 +219,24 @@ export default class ConversationModel extends BaseModel {
}
async updateCollect(actionData, callback) {
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
var groupIds = this.groupIdToString(actionData.groupIds);
var condition = new dataAbility.DataAbilityPredicates();
condition.in(mmsTable.messageInfo.groupId, groupIds);
var stringValue = {
- 'is_collect': actionData.hasCollect,
+ "is_collect": actionData.hasCollect,
};
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.update(managerUri, stringValue, condition).then((data) => {
callback(this.encapsulateReturnCode(common.int.SUCCESS));
}).catch((err) => {
- HiLog.e(TAG, 'updateCollect, err: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "updateCollect, err: " + JSON.stringify(err.message));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
async deleteMessageByIds(actionData) {
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
var msgIds = actionData.msgIds;
var condition = new dataAbility.DataAbilityPredicates();
condition.in(mmsTable.messageInfo.msgId, msgIds);
@@ -241,19 +245,19 @@ export default class ConversationModel extends BaseModel {
}
async deleteMessageByGroupIds(actionData) {
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
var groupIds = this.groupIdToString(actionData.groupIds);
var condition = new dataAbility.DataAbilityPredicates();
condition.in(mmsTable.messageInfo.groupId, groupIds);
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.delete(managerUri, condition).then((data) => {
}).catch((err) => {
- HiLog.e(TAG, 'deleteMessageByGroupIds, err: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "deleteMessageByGroupIds, err: " + JSON.stringify(err.message));
});
}
async deleteMessageBySessionIds(actionData) {
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
let threadIds = [];
for (let id of actionData.threadIds) {
let threadId = id + common.string.EMPTY_STR;
@@ -264,12 +268,12 @@ export default class ConversationModel extends BaseModel {
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.delete(managerUri, condition).then((data) => {
}).catch((err) => {
- HiLog.e(TAG, 'deleteMessageBySessionIds, err: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "deleteMessageBySessionIds, err: " + JSON.stringify(err.message));
});
}
async deleteMessageBySessionIdsAndLock(actionData) {
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
let threadIds = this.groupIdToString(actionData.threadIds);
var condition = new dataAbility.DataAbilityPredicates();
condition.equalTo(mmsTable.messageInfo.isLock, actionData.hasLock);
@@ -277,30 +281,30 @@ export default class ConversationModel extends BaseModel {
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.delete(managerUri, condition).then((data) => {
}).catch((err) => {
- HiLog.e(TAG, 'deleteMessageBySessionIdsAndLock, err: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "deleteMessageBySessionIdsAndLock, err: " + JSON.stringify(err.message));
});
}
async updateById(actionData, callback) {
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
var msgId = actionData.msgId;
var condition = new dataAbility.DataAbilityPredicates();
condition.equalTo(mmsTable.messageInfo.msgId, msgId);
var stringValue = {
- 'msg_state': actionData.sendStatus,
+ "msg_state": actionData.sendStatus,
};
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.update(managerUri, stringValue, condition).then((data) => {
- HiLog.i(TAG, 'updateById, end');
+ HiLog.i(TAG, "updateById, end");
callback(this.encapsulateReturnCode(common.int.SUCCESS));
}).catch((err) => {
- HiLog.e(TAG, 'updateById, err: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "updateById, err: " + JSON.stringify(err.message));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
async markAllAsRead(actionData) {
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
let threadIds = [];
for (let id of actionData.threadIds) {
let threadId = id + common.string.EMPTY_STR;
@@ -309,12 +313,12 @@ export default class ConversationModel extends BaseModel {
var condition = new dataAbility.DataAbilityPredicates();
condition.in(mmsTable.messageInfo.sessionId, threadIds);
var stringValue = {
- 'is_read': actionData.hasRead
+ "is_read": actionData.hasRead
};
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.update(managerUri, stringValue, condition).then((data) => {
}).catch((err) => {
- HiLog.e(TAG, 'markAllAsRead, err: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "markAllAsRead, err: " + JSON.stringify(err.message));
});
}
@@ -323,31 +327,31 @@ export default class ConversationModel extends BaseModel {
condition.equalTo(mmsTable.messageInfo.isRead, 0);
condition.equalTo(mmsTable.messageInfo.smsType, actionData.smsType);
var stringValue = {
- 'is_read': actionData.hasRead
+ "is_read": actionData.hasRead
};
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
dataAbilityHelper.update(managerUri, stringValue, condition).then((data) => {
}).catch((err) => {
- HiLog.e(TAG, 'markAllToRead, err: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "markAllToRead, err: " + JSON.stringify(err.message));
});
}
async queryMaxGroupId(actionData, callback) {
let resultColumns = [
- 'maxGroupId'
+ "maxGroupId"
];
let condition = new dataAbility.DataAbilityPredicates();
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_MAX_GROUP;
-// condition.orderByAsc(mmsTable.messageInfo.groupId);
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ // condition.orderByAsc(mmsTable.messageInfo.groupId);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
dataAbilityHelper.query(managerUri, resultColumns, condition, (err, resultSet) => {
- HiLog.i(TAG, 'queryMaxGroupId, query callback');
+ HiLog.i(TAG, "queryMaxGroupId, query callback");
let result: LooseObject = {};
while (resultSet.goToNextRow()) {
result.maxGroupId = resultSet.getString(0);
- HiLog.d(TAG, 'queryMaxGroupId, maxGroupId=' + result.maxGroupId);
+ HiLog.d(TAG, "queryMaxGroupId, maxGroupId=" + result.maxGroupId);
}
callback(this.encapsulateReturnResult(common.int.SUCCESS, result));
});
@@ -383,7 +387,7 @@ export default class ConversationModel extends BaseModel {
condition.equalTo(mmsTable.messageInfo.smsType, actionData.numberType);
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
dataAbilityHelper.query(managerUri, resultColumns, condition).then((resultSet) => {
let mmsList = [];
while (resultSet.goToNextRow()) {
@@ -394,12 +398,18 @@ export default class ConversationModel extends BaseModel {
}
callback(this.encapsulateReturnResult(common.int.SUCCESS, mmsList));
}).catch((err) => {
- HiLog.e(TAG, 'queryMessageThirty, err: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "queryMessageThirty, err: " + JSON.stringify(err.message));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
async statisticsUnreadNotify(actionData, callback) {
+ let mmsContext;
+ if (actionData.mmsContext) {
+ mmsContext = actionData.mmsContext;
+ } else {
+ mmsContext = globalThis.mmsContext;
+ }
var condition = new dataAbility.DataAbilityPredicates();
condition.equalTo(mmsTable.messageInfo.isRead, 0);
condition.equalTo(mmsTable.messageInfo.smsType, 1);
@@ -408,7 +418,7 @@ export default class ConversationModel extends BaseModel {
];
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(mmsContext, common.string.URI_MESSAGE_LOG);
dataAbilityHelper.query(managerUri, resultColumns, condition).then((resultSet) => {
let count = 0;
while (resultSet.goToNextRow()) {
@@ -416,7 +426,7 @@ export default class ConversationModel extends BaseModel {
}
callback(this.encapsulateReturnResult(common.int.SUCCESS, count));
}).catch((err) => {
- HiLog.e(TAG, 'statisticsUnreadNotify, err: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "statisticsUnreadNotify, err: " + JSON.stringify(err.message));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
@@ -424,15 +434,15 @@ export default class ConversationModel extends BaseModel {
async searchMmsPartByContent(actionData, callback) {
let resultColumns = this.buildMmsPartResultColumns();
let condition = new dataAbility.DataAbilityPredicates();
- condition.like(mmsTable.mmsPart.content, '%' + actionData.content + '%');
+ condition.like(mmsTable.mmsPart.content, "%" + actionData.content + "%");
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_MMS_PART;
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
dataAbilityHelper.query(managerUri, resultColumns, condition).then(resultSet => {
let resultList = this.dealMmsPartResult(resultSet);
callback(this.encapsulateReturnResult(common.int.SUCCESS, resultList));
}).catch(error => {
- HiLog.e(TAG, 'searchMmsPartByContent, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "searchMmsPartByContent, error: " + JSON.stringify(error.message));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
@@ -443,12 +453,12 @@ export default class ConversationModel extends BaseModel {
condition.in(mmsTable.mmsPart.msgId, actionData.msgIds);
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_MMS_PART;
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
dataAbilityHelper.query(managerUri, resultColumns, condition).then(resultSet => {
let resultList = this.dealMmsPartResult(resultSet);
callback(this.encapsulateReturnResult(common.int.SUCCESS, resultList));
}).catch(error => {
- HiLog.e(TAG, 'queryMmsPart, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "queryMmsPart, error: " + JSON.stringify(error.message));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
@@ -490,10 +500,10 @@ export default class ConversationModel extends BaseModel {
condition.in(mmsTable.mmsPart.groupId, groupIds);
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_MMS_PART;
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
dataAbilityHelper.delete(managerUri, condition).then((data) => {
}).catch((err) => {
- HiLog.e(TAG, 'deleteMmsPartByGroupIds, err: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "deleteMmsPartByGroupIds, err: " + JSON.stringify(err.message));
});
}
@@ -508,11 +518,11 @@ export default class ConversationModel extends BaseModel {
async insertMmsPart(actionData, stringValue, callback) {
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_MMS_PART;
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
dataAbilityHelper.insert(managerUri, stringValue).then(data => {
callback(this.encapsulateReturnResult(data, common.int.SUCCESS));
}).catch(error => {
- HiLog.e(TAG, 'insertMmsPart, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "insertMmsPart, error: " + JSON.stringify(error.message));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
@@ -524,7 +534,7 @@ export default class ConversationModel extends BaseModel {
condition.equalTo(mmsTable.messageInfo.sessionId, sessionId);
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
dataAbilityHelper.query(managerUri, resultColumns, condition).then(resultSet => {
let lockStatus = [];
while (resultSet.goToNextRow()) {
@@ -534,7 +544,7 @@ export default class ConversationModel extends BaseModel {
}
callback(this.encapsulateReturnResult(common.int.SUCCESS, lockStatus));
}).catch(error => {
- HiLog.e(TAG, 'queryMessageLockBySessionId, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "queryMessageLockBySessionId, error: " + JSON.stringify(error.message));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
@@ -546,7 +556,7 @@ export default class ConversationModel extends BaseModel {
condition.in(mmsTable.messageInfo.sessionId, threadIds);
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
- let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
+ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(globalThis.mmsContext, common.string.URI_MESSAGE_LOG);
dataAbilityHelper.query(managerUri, resultColumns, condition).then(resultSet => {
let groupIds = [];
resultSet.goToFirstRow();
@@ -556,7 +566,7 @@ export default class ConversationModel extends BaseModel {
} while (resultSet.goToNextRow());
callback(this.encapsulateReturnResult(common.int.SUCCESS, groupIds));
}).catch(error => {
- HiLog.e(TAG, 'queryGroupIdBySessionId, error: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "queryGroupIdBySessionId, error: " + JSON.stringify(error.message));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
diff --git a/entry/src/main/ets/default/model/MorkDataModel.ets b/entry/src/main/ets/model/MorkDataModel.ets
similarity index 80%
rename from entry/src/main/ets/default/model/MorkDataModel.ets
rename to entry/src/main/ets/model/MorkDataModel.ets
index 3b6a3c3..c44f015 100644
--- a/entry/src/main/ets/default/model/MorkDataModel.ets
+++ b/entry/src/main/ets/model/MorkDataModel.ets
@@ -20,37 +20,37 @@ var savedImageInfo = {
var pictureListFromGallery = [
{
- path: '/common/icon/add.png',
+ path: "/common/icon/add.png",
checkedValue: false,
- fileSize: 55.6, // 单位KB
- type: 1 // 1图片,3视频
+ fileSize: 55.6, // Unit:KB
+ type: 1 // 1 image, 3 video
},
{
- path: '/common/icon/up.png',
+ path: "/common/icon/up.png",
checkedValue: false,
fileSize: 95.6,
type: 1
},
{
- path: '/common/icon/vmall.png',
+ path: "/common/icon/vmall.png",
checkedValue: false,
fileSize: 75.6,
type: 1
},
{
- path: '/common/icon/pin.png',
+ path: "/common/icon/pin.png",
checkedValue: false,
fileSize: 55.6,
type: 1
},
{
- path: '/common/icon/delete.png',
+ path: "/common/icon/delete.png",
checkedValue: false,
fileSize: 55.6,
type: 1
},
{
- path: '/common/icon/ikea.png',
+ path: "/common/icon/ikea.png",
checkedValue: false,
fileSize: 55.6,
type: 1
@@ -58,7 +58,6 @@ var pictureListFromGallery = [
];
export default class MorkModel {
-
saveImage() {
return savedImageInfo;
}
diff --git a/entry/src/main/ets/model/SettingsModel.ets b/entry/src/main/ets/model/SettingsModel.ets
new file mode 100644
index 0000000..8d0c201
--- /dev/null
+++ b/entry/src/main/ets/model/SettingsModel.ets
@@ -0,0 +1,124 @@
+/**
+ * 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 BaseModel from "./BaseModel";
+import common from "../data/commonData"
+import HiLog from "../utils/HiLog";
+import MmsPreferences from "../utils/MmsPreferences";
+import telephonySMS from "@ohos.telephony.sms";
+import LooseObject from "../data/LooseObject"
+
+const TAG = "SettingModel";
+
+export default class SettingModel extends BaseModel {
+ setOnSettingValueListener(callback) {
+ let data: LooseObject = {};
+ data.integrationSwitch = MmsPreferences.getInstance().getValueOfIntegrationSwitch();
+ data.maliciousWebSwitch = MmsPreferences.getInstance().getValueOfMaliciousWebSwitch();
+ data.showContactSwitch = MmsPreferences.getInstance().getValueOfShowContactSwitch();
+ callback(data);
+ }
+
+ getSettingValue(callback) {
+ let settingValues: LooseObject = {};
+ settingValues.hasAggregate = MmsPreferences.getInstance().getValueOfIntegrationSwitch();
+ settingValues.isShowContactHeadIcon = MmsPreferences.getInstance().getValueOfShowContactSwitch();
+ settingValues.recallMessagesFlag = MmsPreferences.getInstance().getValueOfRecallMessageSwitch();
+ callback(this.encapsulateReturnResult(common.int.SUCCESS, settingValues));
+ }
+
+ getAdvancedPageSwitchValue(callback) {
+ let result: LooseObject = {
+ deliveryReportSwitch: false,
+ autoRetrieveMmsSwitch: false,
+ recallMessageSwitch: false,
+ autoDeleteInfoSwitch: false
+ };
+ result.deliveryReportSwitch = MmsPreferences.getInstance().getValueOfDeliveryReportSwitch();
+ result.autoRetrieveMmsSwitch = MmsPreferences.getInstance().getValueOfAutoRetrieveMmsSwitch();
+ if (MmsPreferences.getInstance().getValueOfRecallMessageSwitch() == common.bool.TRUE) {
+ result.recallMessageSwitch = true;
+ }
+ if (MmsPreferences.getInstance().getValueOfAutoDeleteInfoSwitch() == common.bool.TRUE) {
+ result.autoDeleteInfoSwitch = true;
+ }
+ result.simCount = MmsPreferences.getInstance().getCountOfSim();
+ if (result.simCount == common.int.SIM_COUNT) {
+ result.firstSpnNameOfTwoSimCard = MmsPreferences.getInstance().getSpnOfSim1();
+ result.secondSpnNameOfTwoSimCard = MmsPreferences.getInstance().getSpnOfSim2();
+ } else {
+ if (MmsPreferences.getInstance().getSim1ExistFlag() == common.bool.TRUE) {
+ result.spnNameOfOneSimCard = MmsPreferences.getInstance().getSpnOfSim1();
+ } else if (MmsPreferences.getInstance().getSim2ExistFlag() == common.bool.TRUE) {
+ result.spnNameOfOneSimCard = MmsPreferences.getInstance().getSpnOfSim2();
+ } else {
+ result.spnNameOfOneSimCard = common.string.EMPTY_STR;
+ }
+ }
+ callback(this.encapsulateReturnResult(common.int.SUCCESS, result));
+ }
+
+ updateSmscNumber(actionData, callback) {
+ let index = actionData.index - 1;
+ let newTelNum = actionData.number;
+// telephonySMS.setSmscAddr(index, newTelNum, (value) => {
+// // If card 1
+// if (index == common.int.SIM_ONE) {
+// MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_NEW_SIM_0_SMSC, newTelNum);
+// } else if (index == common.int.SIM_TWO) {
+// MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_NEW_SIM_1_SMSC, newTelNum);
+// }
+// callback(this.encapsulateReturnResult(common.int.SUCCESS, common.string.SUCCESS));
+// }).catch((error) => {
+// HiLog.e(TAG, "updateSmscNumber, setSmscAddr, error: " + JSON.stringify(error.message));
+// callback(this.encapsulateReturnCode(common.int.FAILURE));
+// });
+ telephonySMS.setSmscAddr(index, newTelNum).then( value => {
+ // If card 1
+ if (index == common.int.SIM_ONE) {
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_NEW_SIM_0_SMSC, newTelNum);
+ } else if (index == common.int.SIM_TWO) {
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_NEW_SIM_1_SMSC, newTelNum);
+ }
+ return this.encapsulateReturnResult(common.int.SUCCESS, common.string.SUCCESS)
+ }).catch((error) => {
+ HiLog.e(TAG, "updateSmscNumber, setSmscAddr, error: " + JSON.stringify(error.message));
+ return this.encapsulateReturnCode(common.int.FAILURE);
+ });
+ }
+
+ shareSmsEnterSelectedText(actionData, callback) {
+ // The sharing API is not provided.
+ callback(this.encapsulateReturnResult(common.int.SUCCESS, common.string.SUCCESS));
+ }
+
+ updateSwitchValue(keyOfSwitch, valueOfSwitch, callback) {
+ MmsPreferences.getInstance().setValueForSwitch(keyOfSwitch, valueOfSwitch);
+ callback(this.encapsulateReturnResult(common.int.SUCCESS, common.string.SUCCESS));
+ }
+
+ restoreSwitchValueToDefault(callback) {
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_INTEGRATION_SWITCH, common.bool.TRUE);
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_MALICIOUS_WEB_SWITCH, common.bool.FALSE);
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_SHOW_CONTACT_SWITCH, common.bool.TRUE);
+ MmsPreferences.getInstance()
+ .setValueForSwitch(common.string.KEY_OF_DELIVERY_REPORT_SWITCH, common.DELIVERY_REPORTS.DISABLED);
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_AUTO_RETRIEVE_SWITCH,
+ common.AUTO_RETRIEVE_MMS.NOT_WHEN_ROAMING);
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_RECALL_MESSAGE_SWITCH, common.bool.FALSE);
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_AUTO_DELETE_INFO_SWITCH, common.bool.FALSE);
+ callback(this.encapsulateReturnResult(common.int.SUCCESS, common.string.SUCCESS));
+ }
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/ets/test/List.test.ets b/entry/src/main/ets/model/common/AvatarColor.ets
similarity index 83%
rename from entry/src/ohosTest/ets/test/List.test.ets
rename to entry/src/main/ets/model/common/AvatarColor.ets
index ca2e71a..2d37d55 100644
--- a/entry/src/ohosTest/ets/test/List.test.ets
+++ b/entry/src/main/ets/model/common/AvatarColor.ets
@@ -12,8 +12,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import exampleJsunit from "../test/ExampleJsunit.test"
-export default function testsuite() {
- exampleJsunit()
-}
\ No newline at end of file
+export default {
+ background: {
+ Color: ["#98D4EF", "#9CC998", "#E8889C", "#C891F1", "#F9C273", "#92D6CC"],
+ }
+}
+
+
+
diff --git a/entry/src/main/ets/default/pages/conversation/common.ets b/entry/src/main/ets/pages/conversation/common.ets
similarity index 65%
rename from entry/src/main/ets/default/pages/conversation/common.ets
rename to entry/src/main/ets/pages/conversation/common.ets
index 62fd57f..b163751 100644
--- a/entry/src/main/ets/default/pages/conversation/common.ets
+++ b/entry/src/main/ets/pages/conversation/common.ets
@@ -13,16 +13,17 @@
* limitations under the License.
*/
-import LooseObject from '../../data/LooseObject'
+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();
+ private static sInstance: Common;
+ // Parameter data transferred to the receive module
+ paramContact: LooseObject = {};
+
+ static getInstance() {
+ if (Common.sInstance == null) {
+ Common.sInstance = new Common();
+ }
+ return Common.sInstance;
}
- return Common.sInstance;
- }
}
\ No newline at end of file
diff --git a/entry/src/main/ets/pages/conversation/conversation.ets b/entry/src/main/ets/pages/conversation/conversation.ets
new file mode 100644
index 0000000..97e5843
--- /dev/null
+++ b/entry/src/main/ets/pages/conversation/conversation.ets
@@ -0,0 +1,947 @@
+/**
+ * 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.
+ */
+/**
+ * Message/MMS viewing page
+ */
+import ConversationController from "./conversationController";
+import DeviceUtil from "../../utils/DeviceUtil";
+import { Receive } from "../../views/receive/receive";
+import LooseObject from "../../data/LooseObject";
+import { MoreMenu } from "../../views/MmsMenu";
+import Common from "./common";
+import router from "@system.router";
+
+@Entry
+@Component
+export struct Conversation {
+ @StorageLink('curBp') curBp: string = 'sm'
+ @State mConversationCtrl: ConversationController = ConversationController.getInstance();
+ @State mCommonCtrl: Common = Common.getInstance();
+ private gridColumns: GridRowColumnOption = { sm: 4, md: 8, lg: 12 };
+ private timeGirdSpan: GridColColumnOption = { sm: 4, md: 8, lg: 12 };
+ private messageGirdSpan: GridColColumnOption = { sm: 4, md: 6, lg: 8 };
+ private gridColOffset: GridColColumnOption = { sm: 0, md: 2, lg: 4 };
+ private gridGutter: string = "24vp";
+ private dialogGridCount: number = 4;
+ private menuItems: Array = [
+ {
+ value: $r("app.string.delete"),
+ action: () => {
+ this.mConversationCtrl.longPressMore(0);
+ },
+ enabled: true
+ },
+ {
+ value: $r("app.string.msg_pre_call_editor"),
+ action: () => {
+ this.mConversationCtrl.longPressMore(3);
+ },
+ enabled: true
+ }
+ ];
+
+ /** Message details dialog box */
+ dialogController: CustomDialogController = new CustomDialogController({
+ builder: DetailsDialog({
+ 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: $r("app.float.dialog_bottom_margin") },
+ gridCount: this.dialogGridCount
+ })
+
+ aboutToAppear() {
+ this.mConversationCtrl.onInit();
+ this.mConversationCtrl.onShow();
+
+ }
+
+ aboutToDisappear() {
+ this.mConversationCtrl.simChangeListenerOff();
+ }
+
+ onPageShow() {
+ }
+
+ onPageHide() {
+ this.mConversationCtrl.onHide()
+ }
+
+ onBackPress() {
+ return this.mConversationCtrl.onBackPress();
+ }
+
+ build() {
+ Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
+ Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
+ //
+ // New page
+ if (this.mConversationCtrl.isNewMsg) {
+ Row() {
+ Image($rawfile("icon/ic_message_back.svg"))
+ .width("24vp")
+ .height("24vp")
+ .onClick(() => {
+ // Click Return to restore the status of unselected SMs.
+ if (!this.mConversationCtrl.onBackPress()) {
+ router.back();
+ }
+ })
+
+ Row().width($r("app.float.space_16"))
+
+ Text($r("app.string.new_message"))
+ .fontSize(20)
+ .lineHeight(28)
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ .fontWeight(FontWeight.Bold)
+ }
+ .width("100%")
+ .height(56)
+ .flexShrink(0)
+ .padding({ left: "24vp", right: "24vp" })
+ .zIndex(2)
+ }
+ // Page for viewing SMS details
+ else {
+ Row() {
+ // Select Status
+ if (this.mConversationCtrl.isSelectStatus) {
+ Row() {
+ Image($rawfile("icon/ic_public_cancel.svg"))
+ .width(24)
+ .height(24)
+ .onClick(() => {
+ // Click Return to restore the status of unselected SMs.
+ this.mConversationCtrl.titleBarCancel()
+ })
+ 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("sys.color.ohos_id_color_text_primary"))
+ .fontWeight(FontWeight.Bold)
+ }
+ .alignItems(VerticalAlign.Center)
+ .width("100%")
+ }
+ // Non-Selected Status
+ else {
+ Row() {
+ Flex({
+ alignItems: ItemAlign.Center,
+ }) {
+ Row() {
+ Image($rawfile("icon/ic_message_back.svg"))
+ .width(24)
+ .height(24)
+ .margin({ right: 16 })
+ .onClick(() => {
+ if (!this.mConversationCtrl.onBackPress()) {
+ router.back();
+ }
+ })
+
+ if(this.mConversationCtrl.strContactsName === '' ||
+ this.mConversationCtrl.photoFirstName === "-1") {
+ Image($rawfile("icon/ic_user_portrait.svg"))
+ .objectFit(ImageFit.Fill)
+ .width(40)
+ .height(40)
+ .clip(new Circle({ width: 40, height: 40 }))
+ .backgroundColor(this.mConversationCtrl.portraitColor)
+ .onClick(() => {
+ this.mConversationCtrl.titleBarAvatar();
+ })
+ } else {
+ Text(this.mConversationCtrl.photoFirstName)
+ .fontSize("30vp")
+ .fontWeight(FontWeight.Bold)
+ .fontColor(Color.White)
+ .height("40vp")
+ .width("40vp")
+ .textAlign(TextAlign.Center)
+ .clip(new Circle({ width: "40vp", height: "40vp" }))
+ .backgroundColor(this.mConversationCtrl.portraitColor)
+ .onClick(() => {
+ this.mConversationCtrl.titleBarAvatar();
+ })
+ }
+ }
+ .flexBasis(80)
+
+ Column() {
+ Flex({
+ direction: FlexDirection.Column,
+ justifyContent: FlexAlign.Center,
+ alignItems: ItemAlign.Start
+ }) {
+ if (this.mConversationCtrl.contactsNum > 1) {
+ Text(this.mConversationCtrl.strContactsName)
+ .maxLines(1)
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
+ .fontSize(16)
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ Text($r("app.string.members", this.mConversationCtrl.contactsNum))
+ .maxLines(1)
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
+ .fontSize(14)
+ .fontColor($r("sys.color.ohos_id_color_text_tertiary"))
+ } else if (this.mConversationCtrl.strContactsName == '' ||
+ this.mConversationCtrl.strContactsName == null) {
+ Text(this.mConversationCtrl.strContactsNumberFormat)
+ .maxLines(1)
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
+ .fontSize(16)
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ .fontWeight(FontWeight.Medium)
+ } else {
+ Text(this.mConversationCtrl.strContactsName)
+ .maxLines(1)
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
+ .fontSize(20)
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ .fontWeight(FontWeight.Medium)
+ .lineHeight(28)
+ Text(this.mConversationCtrl.strContactsNumberFormat)
+ .maxLines(1)
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
+ .fontSize(14)
+ .fontColor($r("sys.color.ohos_id_color_text_tertiary"))
+ .lineHeight(19)
+ }
+ }
+ }
+ .flexGrow(1)
+ .flexShrink(1)
+ .alignItems(HorizontalAlign.Start)
+ .padding({ left: 12, right: 16 })
+
+ Row() {
+ Image($rawfile("icon/ic_message_phone.svg"))
+ .width(24)
+ .height(24)
+ .onClick(() => {
+ this.mConversationCtrl.clickCall();
+ })
+ Blank().width($r("app.float.space_16"))
+ Column() {
+ MoreMenu({
+ menuItems: this.menuItems
+ })
+ }
+ }
+ .flexShrink(0)
+ }.height("100%")
+ }
+ .width("100%")
+ }
+ }
+ .height(56)
+ .constraintSize({ minHeight: 56 })
+ .padding({ left: 24, right: 24 })
+ .zIndex(2)
+ }
+ //
+ Row() {
+ // New Message Content
+ if (this.mConversationCtrl.isNewMsg) {
+ Row() {
+ Receive({ mConversationController: $mConversationCtrl })
+ }.margin({ top: $r("app.float.new_message_margin_top") })
+ }
+ // SMS message content
+ //
+ if (!this.mConversationCtrl.isNewMsg) {
+ List({ space: 10, initialIndex: this.mConversationCtrl.mmsList.length - 1 }) {
+ ForEach(this.mConversationCtrl.mmsList, (item, index) => {
+ ListItem() {
+ Column() {
+ GridRow({ columns: this.gridColumns, gutter: this.gridGutter }) {
+ //
+ if (!item.isReceive && !item.isDraft) {
+ GridCol({ span: this.timeGirdSpan}) {
+ Flex({
+ direction: FlexDirection.Column,
+ justifyContent: FlexAlign.Center,
+ alignItems: ItemAlign.Center
+ }) {
+ // SMS/MMS
+ if (index == 0) {
+ Text($r("app.string.msg_note_mms"))
+ .fontSize(12)
+ .lineHeight(16)
+ .fontColor($r("sys.color.ohos_id_color_text_secondary"))
+ .margin({ bottom: 2 })
+ }
+ // Time
+ if (item.dateShow) {
+ Text() {
+ Span(item.date)
+ .fontSize(12)
+ .fontColor($r("sys.color.ohos_id_color_text_secondary"))
+ Span(item.week)
+ .fontSize(12)
+ .fontColor($r("sys.color.ohos_id_color_text_secondary"))
+ }.lineHeight(16).margin({ bottom: 8 })
+ }
+ }.width("100%")
+ }
+ GridCol({ span: this.messageGirdSpan, offset: this.gridColOffset }) {
+ Flex({
+ direction: FlexDirection.Column,
+ justifyContent: FlexAlign.Center,
+ alignItems: ItemAlign.Center
+ }) {
+ Flex({
+ justifyContent: FlexAlign.Center,
+ alignItems: ItemAlign.Start
+ }) {
+ Column() {
+ Flex({
+ justifyContent: FlexAlign.End,
+ alignItems: ItemAlign.End
+ }) {
+ //
+ Flex({
+ justifyContent: FlexAlign.End,
+ alignItems: ItemAlign.End
+ }) {
+ //
+ 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(20)
+ .height(20)
+ .objectFit(ImageFit.Fill)
+ }
+ .margin({ right: 8 })
+ .padding({ top: 9 })
+ }
+ // Message Bubble
+ bubbleText({
+ conversationCtrl: $mConversationCtrl,
+ bubbleTextBorderRadius: [4, 24],
+ bubbleTextDirection: "right",
+ content: item.content,
+ bubbleTextBackgroundColor: $r("app.color.sender_bubble"),
+ isShowMsgLongMenu: item.isShowMsgLongMenu,
+ itemIndex: index
+ })
+ }
+ }
+ //
+ Flex({
+ alignItems: ItemAlign.Center,
+ justifyContent: FlexAlign.End
+ }) {
+ if (this.mConversationCtrl.contactsNum == 1 &&
+ item.sendStatus != 1) {
+ Text(item.time)
+ .textAlign(TextAlign.Start)
+ .fontSize(10)
+ .lineHeight(13)
+ .fontColor($r("sys.color.ohos_id_color_text_secondary"))
+ .margin({ top: 8, right: 5 })
+ }
+ // Card 1 or Card 2
+ 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)
+ .margin({ top: 8, right: 5 })
+ }
+ // Locked
+ if (item.isLock) {
+ Image($rawfile("icon/msg_lock.svg"))
+ .width(10)
+ .height(10)
+ .margin({ top: 8, right: 5 })
+ }
+ Text($r("app.string.messageSendFailed"))
+ .textAlign(TextAlign.Start)
+ .fontSize(10)
+ .lineHeight(13)
+ .margin({ top: 8 })
+ .fontColor($r("sys.color.ohos_id_color_warning"))
+ .visibility(item.sendStatus == 2 ?
+ Visibility.Visible : Visibility.None)
+ Text($r("app.string.messageSending"))
+ .textAlign(TextAlign.Start)
+ .fontSize(10)
+ .fontColor($r("sys.color.ohos_id_color_text_secondary"))
+ .lineHeight(13)
+ .margin({ top: 8 })
+ .visibility(item.sendStatus == 1 ?
+ Visibility.Visible : Visibility.None)
+ Text($r("app.string.messageDeliver"))
+ .textAlign(TextAlign.Start)
+ .fontSize(10)
+ .fontColor($r("sys.color.ohos_id_color_text_secondary"))
+ .lineHeight(13)
+ .margin({ top: 8 })
+ .visibility(item.sendStatus == 0 ?
+ Visibility.Visible : Visibility.None)
+ }.width("100%").margin({ right: 12 })
+ }
+ .width("100%")
+ .alignItems(HorizontalAlign.End)
+ // Sender's avatar, which is available only for group messages.
+ Flex({ direction: FlexDirection.Column,
+ justifyContent: FlexAlign.Start,
+ alignItems: ItemAlign.Center }) {
+ Image($rawfile("icon/user_avatar_full_fill.svg"))
+ .width(30)
+ .height(30)
+ }
+ .width(50)
+ .height(30)
+ .visibility(this.mConversationCtrl.contactsNum > 1 ?
+ Visibility.Visible : Visibility.None)
+ // Information Checkbox
+ if (this.mConversationCtrl.isSelectStatus) {
+ Row() {
+ Toggle({
+ type: ToggleType.Checkbox,
+ isOn: item.isCbChecked
+ })
+ .selectedColor($r("sys.color.ohos_id_color_activated"))
+ .width(24)
+ .height(24)
+ .onChange(((isOn: boolean) => {
+ this.mConversationCtrl.listCheckBoxChange(index, isOn)
+ }))
+ }
+ .width(48)
+ .height(48)
+ .margin({ left: 4 })
+ }
+ }
+ }
+ .width("100%")
+ }
+ }
+ //
+ else if (item.isReceive) {
+ GridCol({ span: this.timeGirdSpan}) {
+ //
+ Flex({
+ direction: FlexDirection.Column,
+ justifyContent: FlexAlign.Center,
+ alignItems: ItemAlign.Center
+ }) {
+ // SMS/MMS
+ if (index == 0) {
+ Text($r("app.string.msg_note_mms"))
+ .fontSize(12)
+ .lineHeight(16)
+ .fontColor($r("sys.color.ohos_id_color_text_secondary"))
+ .margin({ bottom: 2 })
+ }
+ // Time
+ if (item.dateShow) {
+ Text() {
+ Span(item.date)
+ .fontSize(12)
+ .fontColor($r("sys.color.ohos_id_color_text_secondary"))
+ Span(item.week)
+ .fontSize(12)
+ .fontColor($r("sys.color.ohos_id_color_text_secondary"))
+ }.lineHeight(16).margin({ bottom: 8 })
+ }
+ }.width("100%")
+ }
+ GridCol({ span: this.messageGirdSpan }) {
+ Flex({
+ direction: FlexDirection.Column,
+ justifyContent: FlexAlign.Center,
+ alignItems: ItemAlign.Center
+ }) {
+ Flex({
+ justifyContent: FlexAlign.Center,
+ alignItems: ItemAlign.Start
+ }) {
+ Column() {
+ Flex({
+ alignItems: ItemAlign.Start,
+ justifyContent: FlexAlign.Start
+ }) {
+ // Message Bubble
+ bubbleText({
+ conversationCtrl: $mConversationCtrl,
+ bubbleTextBorderRadius: [4, 24],
+ bubbleTextDirection: "left",
+ content: item.content,
+ bubbleTextBackgroundColor: $r("sys.color.ohos_id_color_card_bg"),
+ isShowMsgLongMenu: item.isShowMsgLongMenu,
+ itemIndex: index
+ })
+ }
+ //
+ Flex({
+ alignItems: ItemAlign.Center,
+ justifyContent: FlexAlign.Start
+ }) {
+ Text(item.time)
+ .textAlign(TextAlign.Start)
+ .fontSize(10)
+ .lineHeight(13)
+ .fontColor($r("sys.color.ohos_id_color_text_secondary"))
+ .margin({ top: 8, right: 5 })
+ // Card 1 or Card 2
+ 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)
+ .margin({ top: 8, left: 5 })
+ }
+ // Locked
+ if (item.isLock) {
+ Image($rawfile("icon/msg_lock.svg"))
+ .width(10)
+ .height(10)
+ .margin({ top: 8, left: 5 })
+ }
+ }.width("70%").margin({ left: 12 })
+ }
+ .width("100%")
+ .alignItems(HorizontalAlign.Start)
+
+ if (this.mConversationCtrl.isSelectStatus) {
+ Row() {
+ Toggle({
+ type: ToggleType.Checkbox,
+ isOn: item.isCbChecked
+ })
+ .selectedColor($r("sys.color.ohos_id_color_activated"))
+ .width(24)
+ .height(24)
+ .onChange(((isOn: boolean) => {
+ this.mConversationCtrl.listCheckBoxChange(index, isOn)
+ }))
+ }
+ .margin({ left: 4 })
+ .width(48)
+ .height(48)
+ }
+ }
+ }.width("100%")
+ }
+ }
+ }
+ .margin(this.curBp === 'sm' ? { left: 16, right: 16 } : { left: 24, right: 24})
+ }
+ }.onClick(() => {
+ if (this.mConversationCtrl.isSelectStatus) {
+ this.mConversationCtrl.listCheckBoxChange(index,!item.isCbChecked)
+ }
+ })
+ .padding(index == this.mConversationCtrl.mmsList.length - 1 ? { bottom: 20 } : null)
+ }, item => item.id)
+ }
+ .listDirection(Axis.Vertical) // Arrange Direction
+ .edgeEffect(EdgeEffect.Spring) // Sliding to the edge has no effect
+ .width("100%")
+ .margin({ top: 16 })
+ }
+ }
+ .width("100%")
+ .flexBasis("auto")
+ .flexShrink(1)
+ }
+ .width("100%")
+ // Input box at the bottom
+ Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
+ // More options at the bottom
+ if (this.mConversationCtrl.isSelectStatus && !this.mConversationCtrl.hasDetailDelete) {
+ /** The Info button is checked at the bottom. */
+ Flex({
+ direction: FlexDirection.Row,
+ alignItems: ItemAlign.Center,
+ justifyContent: FlexAlign.SpaceBetween
+ }) {
+ /** Delete */
+ Column() {
+ Image($rawfile("icon/ic_public_delete.svg"))
+ .width(24)
+ .height(24)
+ Text($r("app.string.delete"))
+ .fontSize(10)
+ .margin({ top: 3})
+ .lineHeight(14)
+ .fontWeight(FontWeight.Medium)
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ }.width("25%").opacity(this.mConversationCtrl.selectDeleteMsgCount == 0 ? 0.4 : 1)
+ .onClick(() => {
+ if (this.mConversationCtrl.selectDeleteMsgCount != 0) {
+ this.mConversationCtrl.clickGroupDelete()
+ }
+ })
+ /** Forwarding */
+ Column() {
+ Image($rawfile("icon/ic_transfer.svg"))
+ .width(24)
+ .height(24)
+ Text($r("app.string.msg_transmit")) {
+
+ }.fontSize(10).margin({ top: 3 })
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ .fontWeight(FontWeight.Medium)
+ .lineHeight(14)
+ }.width("25%").opacity(this.mConversationCtrl.selectDeleteMsgCount == 0 ? 0.4 : 1)
+ .onClick(() => {
+
+ })
+ /** Favorites */
+ Column() {
+ Image($rawfile("icon/ic_msg_favorite_m.svg"))
+ .width(24)
+ .height(24)
+ Text($r("app.string.msg_star")) {
+
+ }.fontSize(10).margin({ top: 3 })
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ .fontWeight(FontWeight.Medium)
+ .lineHeight(14)
+ }.width("25%").opacity(this.mConversationCtrl.selectDeleteMsgCount == 0 ? 0.4 : 1)
+ .onClick(() => {
+
+ })
+ /** Select All */
+ Column() {
+ Image(this.mConversationCtrl.isMessageCheckAll ? $rawfile("icon/ic_select_all_filled.svg")
+ : $rawfile("icon/ic_select_all.svg"))
+ .width(24)
+ .height(24)
+ Text(this.mConversationCtrl.isMessageCheckAll ? $r("app.string.msg_deselect_all")
+ : $r("app.string.msg_select_all")) {
+ }
+ .fontSize(10)
+ .margin({ top: 3 })
+ .lineHeight(14)
+ .fontWeight(FontWeight.Medium)
+ .fontColor(this.mConversationCtrl.isMessageCheckAll ?
+ $r("sys.color.ohos_id_color_subtab_text_on") : $r("sys.color.ohos_id_color_text_primary"))
+ }.width("25%")
+ .onClick(() => {
+ this.mConversationCtrl.clickGroupCheckAll()
+ })
+ /** more */
+ Column() {
+ Image($rawfile("icon/ic_message_more1.svg"))
+ .width(24)
+ .height(24)
+ Text($r("app.string.more")) {
+ }.fontSize(10).margin({ top: 3 })
+ .lineHeight(14)
+ .fontWeight(FontWeight.Medium)
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ }
+ .width("25%")
+ .enabled(this.mConversationCtrl.selectDeleteMsgCount == 1 ? true : false)
+ // @ts-ignore
+ .bindMenu(this.MenuBuilder)
+ }
+ .width("100%")
+ .height(56)
+ }
+ //
+ if (!this.mConversationCtrl.isSelectStatus) {
+ Flex({ alignItems: ItemAlign.End, justifyContent: FlexAlign.Center }) {
+ //
+
+ Row() {
+ Image($rawfile("icon/msg_add.svg"))
+ .onClick(() => {
+
+ })
+ .width(24)
+ .height(24)
+ .visibility(Visibility.Visible)
+ .opacity(0.3)
+
+ Blank().width(16)
+
+ Row() {
+ Row() {
+ 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"))
+ .width(16)
+ .height(22)
+ }.visibility(this.mConversationCtrl.cardImage ? Visibility.Visible : Visibility.None)
+
+ Row() {
+ TextArea({
+ placeholder: $r("app.string.msg_note_mms"),
+ text: this.mConversationCtrl.textValue
+ })
+ .placeholderColor($r("sys.color.ohos_id_color_text_hint"))
+ .caretColor($r("sys.color.ohos_id_color_focused_outline"))
+ .backgroundColor($r("sys.color.ohos_id_color_background_transparent"))
+ .onChange(value => {
+ this.mConversationCtrl.changeValue(value);
+ })
+ .borderRadius(20)
+ .fontSize(16)
+ }.constraintSize({ minHeight: 40, maxHeight: 584 })
+ }
+ .backgroundColor($r("sys.color.ohos_id_color_text_field_sub_bg"))
+ .padding(this.mConversationCtrl.cardImage ? { left: 8, right: 8 } : 0)
+ .borderRadius(20)
+ .width(100)
+ .layoutWeight(1)
+
+ Image($rawfile("icon/ic_message_emoji.svg"))
+ .width(24)
+ .height(24)
+ .margin({left:16})
+ .visibility(Visibility.Visible)
+ .opacity(0.3)
+
+ //
+ Image(this.mConversationCtrl.canSendMessage ? $rawfile("icon/ic_message_send_filled.svg")
+ : $rawfile("icon/ic_message_send.svg"))
+ .onClick(() => {
+ // Click Send.
+ this.mConversationCtrl.send()
+ })
+ .width(24)
+ .height(24)
+ .margin({left:16})
+
+ }.width("100%")
+ }
+ .constraintSize({ minHeight: 56 })
+ .width("100%").padding({ bottom: 8, top: 8 })
+ }
+ }
+ .width("100%")
+ .padding({
+ left: this.mConversationCtrl.isSelectStatus && !this.mConversationCtrl.hasDetailDelete ? 0 :
+ $r("app.float.space_24"),
+ right: this.mConversationCtrl.isSelectStatus && !this.mConversationCtrl.hasDetailDelete ? 0 :
+ $r("app.float.bottom_send_bar_padding_right")
+ })
+ .clip(new Rect({
+ width: "100%",
+ height: "100%",
+ radius: this.mConversationCtrl.isSelectStatus ? [] : [[20, 20], [20, 20], [0, 0], [0, 0]]
+ }))
+ .backgroundColor(this.mConversationCtrl.isSelectStatus && !this.mConversationCtrl.hasDetailDelete ?
+ null : $r("sys.color.ohos_id_color_toolbar_bg"))
+ }
+ .backgroundColor($r("sys.color.ohos_id_color_sub_background"))
+ .width("100%")
+ .height("100%")
+ }
+
+ @Builder MenuBuilder() {
+ Column() {
+ Row() {
+ Text($r("app.string.query_details"))
+ .lineHeight(22)
+ .fontSize(16)
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ .margin({ left: 16, top: 13, bottom: 13 })
+ }
+ .width("100%")
+ .height(48)
+ .onClick(()=>{
+ this.dialogController.open()
+ this.mConversationCtrl.isSelectStatus = !this.mConversationCtrl.isSelectStatus
+ this.mConversationCtrl.isMessageCheckAll = false
+ this.mConversationCtrl.cancleCheckedAll()
+ })
+
+ if (this.mConversationCtrl.hasReport) {
+ Divider()
+ .margin({ left: 16, right: 16 })
+ .strokeWidth(0.5)
+ .color($r("sys.color.ohos_id_color_list_separator"))
+
+ Row() {
+ Text($r("app.string.query_report"))
+ .lineHeight(22)
+ .fontSize(16)
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ .margin({ left: 16, top: 13, bottom: 13 })
+ }.height(48)
+ .onClick(() => {
+ this.mConversationCtrl.moreSelected(6)
+ })
+ }
+ }.borderRadius(24)
+ .width(145)
+ .alignItems(HorizontalAlign.Start)
+ }
+}
+
+@CustomDialog
+struct DetailsDialog {
+ controller: CustomDialogController
+ item: LooseObject
+ receiver: string
+
+ build() {
+ Column() {
+ Text($r("app.string.msgDetails"))
+ .fontSize(20)
+ .lineHeight(28)
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ .fontWeight(FontWeight.Bold)
+ .fontFamily("HarmonyHeiTi")
+ .margin({ top: 14, bottom: 14 })
+ Text() {
+ Span($r("app.string.type")).fontSize(16)
+ Span($r("app.string.sms")).fontSize(16)
+ }
+ .fontSize(16)
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ .margin({ bottom: 4 })
+ .fontFamily("HarmonyHeiTi")
+
+ Text() {
+ Span($r("app.string.putAddresser")).fontSize(16)
+ Span(this.receiver).fontSize(16)
+ }
+ .fontSize(16)
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ .margin({ bottom: 4 })
+ .fontFamily("HarmonyHeiTi")
+
+ Text() {
+ Span($r("app.string.sendTime")).fontSize(16)
+ Span(this.item.date).fontSize(16)
+ }
+ .fontSize(16)
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ .margin({ bottom: 8 })
+ .fontFamily("HarmonyHeiTi")
+
+ Flex({ justifyContent: FlexAlign.Center }) {
+ Button() {
+ Text($r("app.string.msg_know"))
+ .fontFamily("HarmonyHeiTi")
+ .fontWeight(FontWeight.Medium)
+ .fontSize(16)
+ .fontColor($r("sys.color.ohos_id_color_floating_button_bg_normal"))
+ }
+ .width(200)
+ .backgroundColor($r("sys.color.ohos_id_color_dialog_bg"))
+ .onClick(() => {
+ this.controller.close()
+ })
+ }.height(40)
+ }
+ .borderRadius(24)
+ .padding({ left: 24, right: 24, bottom: 16 })
+ .alignItems(HorizontalAlign.Start)
+ }
+}
+
+// Custom Chat Bubble
+@Component
+struct bubbleText {
+ @Link conversationCtrl: ConversationController;
+ private bubbleTextBorderRadius: Array; // Fillet size, two parameters in total
+ private bubbleTextDirection: string; // left: upper left corner right: upper right corner
+ private content: string; // Bubble Display Content
+ private bubbleTextBackgroundColor: Resource | string; // Bubble background color
+ private isShowMsgLongMenu: boolean;
+ private itemIndex: number;
+ @State showMenu: boolean = false
+
+ @Builder MenuBuilder() {
+ Row() {
+ Button($r("app.string.delete"))
+ .fontSize(14)
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ .backgroundColor($r("sys.color.ohos_id_color_dialog_bg"))
+ .onClick(() => {
+ this.conversationCtrl.longPressSelected(2)
+ this.showMenu = false
+ })
+ Button($r("app.string.more"))
+ .fontSize(14)
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ .backgroundColor($r("sys.color.ohos_id_color_dialog_bg"))
+ .onClick(() => {
+ this.conversationCtrl.longPressSelected(4)
+ this.showMenu = false
+ })
+ }
+ .height(40)
+ .borderRadius(20)
+ .backgroundColor($r("sys.color.ohos_id_color_dialog_bg"))
+ }
+
+ build() {
+ Row() {
+ Text(this.content)
+ .onDragStart(() => {})
+ .fontSize(16)
+ .lineHeight(21)
+ .padding({ left: 12, right: 12, top: 8, bottom: 8 })
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ }
+ .backgroundColor(this.bubbleTextBackgroundColor)
+ .borderRadius(this.bubbleTextDirection == "right" ?
+ { topLeft: this.bubbleTextBorderRadius[1], topRight: this.bubbleTextBorderRadius[0],
+ bottomLeft: this.bubbleTextBorderRadius[1], bottomRight: this.bubbleTextBorderRadius[1] }:
+ { topLeft: this.bubbleTextBorderRadius[0], topRight: this.bubbleTextBorderRadius[1],
+ bottomLeft: this.bubbleTextBorderRadius[1], bottomRight: this.bubbleTextBorderRadius[1] })
+ .flexBasis("auto")
+ .gesture(
+ LongPressGesture({ repeat: false, duration: 500 })
+ //Touch and hold the action will be triggered continuously.
+ .onAction(() => {
+ if (!this.conversationCtrl.isSelectStatus) {
+ this.conversationCtrl.mmsListLongPress(this.itemIndex)
+ this.showMenu = true
+ }
+ })
+ )
+ .bindPopup(this.showMenu, {
+ builder: this.MenuBuilder,
+ placement: this.bubbleTextDirection == "left" ? Placement.TopRight : Placement.TopLeft,
+ maskColor: $r("sys.color.ohos_id_color_mask_thin"),
+ popupColor: $r("sys.color.ohos_id_color_background_transparent"),
+ enableArrow: false,
+ onStateChange: (e) => {
+ if (!e.isVisible) {
+ this.showMenu = false
+ }
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/pages/conversation/conversationController.ets b/entry/src/main/ets/pages/conversation/conversationController.ets
similarity index 70%
rename from entry/src/main/ets/default/pages/conversation/conversationController.ets
rename to entry/src/main/ets/pages/conversation/conversationController.ets
index ffef847..3fdd024 100644
--- a/entry/src/main/ets/default/pages/conversation/conversationController.ets
+++ b/entry/src/main/ets/pages/conversation/conversationController.ets
@@ -1,3 +1,4 @@
+// @ts-nocheck
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,203 +14,203 @@
* limitations under the License.
*/
// 会话列表
-import router from '@system.router';
-import Prompt from '@system.prompt';
-import HiLog from '../../utils/HiLog'
-import common from '../../data/commonData'
-import commonEvent from '@ohos.commonEvent';
-import conversationService from '../../service/ConversationService';
-import conversationListService from '../../service/ConversationListService';
-import LooseObject from '../../data/LooseObject'
-import commonService from '../../service/CommonService';
-import settingService from '../../service/SettingService';
-import {commonPasteboard} from '../../data/Pasteboard';
-import telephoneUtil from '../../utils/TelephoneUtil';
-import callService from '../../service/CallService';
-import sendMsgService from '../../service/SendMsgService'
-import preferences from '../../utils/PreferencesUtil';
-import dateUtil from '../../utils/DateUtil';
-import featureAbility from '@ohos.ability.featureAbility';
-import appStorage from '../../utils/AppStorageUtil';
-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';
+import router from "@system.router";
+import Prompt from "@system.prompt";
+import HiLog from "../../utils/HiLog"
+import common from "../../data/commonData"
+import commonEvent from "@ohos.commonEvent";
+import conversationService from "../../service/ConversationService";
+import conversationListService from "../../service/ConversationListService";
+import LooseObject from "../../data/LooseObject"
+import commonService from "../../service/CommonService";
+import settingService from "../../service/SettingService";
+import { commonPasteboard } from "../../data/Pasteboard";
+import telephoneUtil from "../../utils/TelephoneUtil";
+import callService from "../../service/CallService";
+import sendMsgService from "../../service/SendMsgService"
+import MmsPreferences from "../../utils/MmsPreferences";
+import dateUtil from "../../utils/DateUtil";
+import featureAbility from "@ohos.ability.featureAbility";
+import NotificationService from "../../service/NotificationService";
+import observer from "@ohos.telephony.observer";
+import telephonySim from "@ohos.telephony.sim";
+import commonCtrl from "./common"
+import AvatarColor from "../../model/common/AvatarColor"
-let commonEventData = null;
+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";
export default class ConversationController {
private static sInstance: ConversationController;
+ commonEventData: any = null;
commonCtrl = commonCtrl.getInstance();
- // 短信列表刷新flag
+ // SMS message list update flag
refresh: boolean = false;
- // 信息删除提示
+ // Message deletion prompt
strMsgDeleteDialogTip: Resource;
- // 点击状态
+ // Click Status
isClickStatus: boolean = false;
- // 信息是否加锁
+ // Whether information is locked
hasLockMsg: boolean = false;
- // 选择状态
+ // Select Status
isSelectStatus: boolean = false;
- // 是否选择加锁信息
+ // Whether to select lock information
isSelectLockMsg: boolean = false;
- // 更多操作
+ // More Actions
isShowMoreOperation: boolean = false;
- // 判断是否为同一天 默认为 false
+ // The default value is false for determining whether the current day is the same.
isLessOneDay: boolean = false;
- // 判断是否达到全屏条件
+ // Check whether full-screen conditions are met.
isShowFullScreen: boolean = false;
- // 判断是否达全选
+ // Check whether all the options are selected.
isMessageCheckAll: boolean = false;
- // 是否只是录音
+ // Is it just a recording?
isOnlyAudio: boolean = false;
- // 删除个数
+ // Deleted Count
selectDeleteMsgCount: number = 0;
- // 输入框输入的文本,也是要发送的短信的内容
+ // Text entered in the text box, which is also the content of the SMS message to be sent.
textValue: string = '';
- // 录音动画任务
+ // Recording Animation Tasks
drawRecordingTaskId: number = 0;
- // tab选项页,0拍摄照片,1图片,2录音,3更多
+ // Tab option page. 0: Take a photo; 1: Take a picture; 2: Record a record; 3: More
tabIndex: number = 1;
- // tab选项页文本内容
+ // Text content of the tab option page
tabTextList: Array = [];
- // 录音状态
+ // Recording Status
isRecordingStatus: boolean = true;
- // 当前录音时间
- curRecordingTime: string = '00:00';
- // 当前录音文件的大小(KB)
+ // Current recording time
+ curRecordingTime: string = "00:00";
+ // Size of the current recording file (KB)
curSize: number = 0;
- // 开始录音时间
+ // Recording Start Time
startRecordTime: number = 0;
- // 是否含有sim卡
+ // Whether the SIM card is contained
haveSimCard: boolean = false;
- // 是否显示卡图标
+ // Display Card Icon
cardImage: boolean = false;
- // 是否飞行模式
+ // Airplane mode
isFlightMode: boolean = false;
- // 信息附件大小提示
+ // Information Attachment Size Tips
msgSendTip: string = '';
- // 当前能否发送短信
+ // Whether SMS messages can be sent.
canSendMessage: boolean = false;
- // 当前编辑的是否为彩信
+ // Whether the currently edited message is an MMS message
isEditMms: boolean = false;
- // 当前编辑的彩信附件大小
+ // Size of the MM attachment to be edited.
curEdtFileSize: number = 0;
- // 获取单选的时间显示
+ // Obtains the time display of a single selection.
mmsTime: string = '';
- // 是否是短信和彩信
+ // SMS and MMS
isMmsType: Resource;
- // 是否收件人
+ // Recipient
isSendRecipient: boolean;
- // 联系人名字
+ // Contact First Name
strContactsName: string = '';
- // 联系人电话号码
+ // Contact Phone Number
strContactsNumber: string = '';
- // 联系人电话号码格式化
+ // Contact Phone Number Formatting
strContactsNumberFormat: string = '';
- // 附件类型为名片
+ // The attachment type is business card.
isVCard: boolean = false;
- // 是否是新建信息
+ // Indicates whether the information is created.
isNewMsg: boolean = false;
- // 联系人数量
+ // Number of Contacts
contactsNum: number = 0;
- // 名片
+ // business card
vCard: {};
- // 彩信编辑列表
+ // MM Edit List
mmsEditList: Array = [];
- // 信息列表
+ // Information List
mmsList: Array = [];
- // 当前选中信息index
+ // Index of the selected information
mmsIndex: number = 0;
- // 初始x位置
+ // Initial x-position
rawX: string = '';
- // 初始y位置
+ // Initial y-position
rawY: string = '';
- // 图库中的缩略图
+ // Thumbnails in Gallery
pictureListFromGallery: Array = [];
- // 选项卡标题
+ // Tab Title
tabTitleText: Resource;
- // 发送工具栏距离底部位置
+ // Send Toolbar Distance from Bottom Position
sendBarMarginBottom: number = 0;
- // 选项卡高度
+ // Tab Height
tabHeight: number = common.int.TAB_HEIGHT;
- // 恢复任务id
+ // Restoration task ID.
restoreTimeoutId: number = 0;
- // 是否真正执行动画
+ // Whether the animation is actually executed
isTabHeightAnimation: boolean = false;
- // 0默认状态,1滑动状态,2全屏状态
+ // 0: default; 1: slide; 2: full screen
tabSlideStatus: number = 0;
- // 滑动距离
+ // Sliding distance
slideDistance: number = 0;
- // 滑动的起点坐标
+ // Start point coordinate of the slide
slideStartPoint: LooseObject = {
x: 0,
y: 0
};
- // 是否上滑动
+ // Whether to slide up
isTabSlideUp: number = 0;
- // 联系人列表,从联系人app那里获取的,作为发彩信时的附件
+ // Contact list, which is obtained from the contact app and used as an attachment for sending MMS messages.
contactListFromContactApp: Array = [];
- // 卡槽
+ // Card slot
slotId: number = 0;
- // 选择的联系人
+ // Selected Contacts
selectContacts: Array = [];
- // 收件人输入框内容
+ // Content in the recipient text box
receiveContactValue: string = '';
- // 控制最后div显示与隐藏
+ // Controls the display and hiding of the last div.
isSendStatus: boolean = false;
- // 会话列表的id
+ // ID of the session list.
threadId: number = 0;
- // 是否是详情页面
+ // Indicates whether the page is a details page.
isDetail: boolean = true;
- // 需要重新发送的下标
+ // Subscript to be resent
reSendIndex: number = 0;
- // 复制选项是否可见
+ // Whether the replication option is visible
showText: boolean = true;
- // 搜索传来的值
+ // Search for the value passed
searchKey: string = '';
- // 是否是草搞
+ // Is it grass?
isDraft: boolean = false;
- // 草稿的内容
+ // Contents of the draft
draftContent: string = '';
draftGroupId: number = 0;
- // 是否可以双击取消发送
+ // Can I double-click to cancel sending
recallMessagesFlag: boolean = false;
- // 双击取消状态
+ // Double-click Cancel Status
doubleClickStatus: boolean = false;
- // 距离底部的动态变化标志
+ // Dynamic change sign from bottom
distanceBottomFlag: boolean = false;
- // 详情页删除
+ // Deleting a Details Page
hasDetailDelete: boolean = false;
- // 是否存在联系人
+ // Whether a contact exists
hasExitContract: boolean = false;
- // 新建页面进行取发送
+ // Create a page for fetching and sending.
isNewRecallMessagesFlag: boolean = false;
- // 录音动画
+ // Recording animation
recordingAnimation: LooseObject = {};
- // 动画样式属性
+ // Animation Style Properties
animationOptions: LooseObject = {};
- // 动画样式属性对象
+ // Animation Style Attribute Object
animationFrames: LooseObject = {};
- // 默认后置摄像头
- cameraPattern: string = 'back';
+ // Default rear camera
+ cameraPattern: string = "back";
pattern: string = '';
- // 是否锁
+ // Lock or Not
hasLock: boolean = false;
- // 高亮信息类型
+ // Highlight Message Type
highlightsType: number = 0;
- // 高亮信息内容
+ // Highlight Message Content
highlightsText: string = '';
- timeFormat: string = '00:01';
- // 0 - 普通,1 - 通知
+ timeFormat: string = "00:01";
+ // 0: normal; 1: notification
smsType: number = 0;
isPicCheckboxClicked: boolean = false;
- // 是否支持发送报告
+ // Whether to support sending reports
hasReport: boolean = false;
messageType: number = common.MESSAGE_TYPE.NORMAL;
textareaDatasource: Array = [];
@@ -224,8 +225,11 @@ export default class ConversationController {
slideDurations: Array = [];
hasDouble: boolean = true;
searchContent: string = '';
- // 时间
+ // Time
mmsDateSet: Set = new Set();
+ photoFirstName: string = '';
+ portraitColor: string = '';
+ reg: string = /^[a-zA-Z]+$/;
static getInstance() {
if (ConversationController.sInstance == null) {
@@ -235,7 +239,7 @@ export default class ConversationController {
}
onInit() {
- HiLog.i(TAG, 'onInit');
+ HiLog.i(TAG, "onInit");
this.initRouterData()
this.initData()
if (this.hasDouble) {
@@ -244,96 +248,100 @@ export default class ConversationController {
}
this.initSendTip();
// this.setTabTitleText();
- // 获取真实数据,新建无需查询数据
+ // Obtains the actual data. You do not need to query the data when creating new data.
if (!this.isNewMsg) {
- this.queryMessageDetail(this.strContactsNumber, this.threadId, () => {});
+ this.queryMessageDetail(this.strContactsNumber, this.threadId, () => {
+ });
}
}
onShow() {
- HiLog.i(TAG, 'onShow');
+ HiLog.i(TAG, "onShow");
this.addSimChangeListener();
- // 判断是否插入了电话卡
+ // Determine whether a phone card is inserted.
this.getSimState();
- // 判断发送按钮是否可点击
+ // Check whether the Send button can be clicked.
this.judgeSendBtnCanClicked();
- // 初始化转发的数据
- this.initTransmitMeg();
- // // 获取取消发送的状态
+ // // Obtains the status of canceling sending.
// this.getSettingFlagForConvListPage();
- // 订阅PA
+ // Subscribe to PA
this.subscribeDetail();
- // 判断联系人是否存在
+ // Check whether a contact exists.
this.judgeContactExists();
// if (this.$app.$def.isFromFullScreen) {
// this.$app.$def.isFromFullScreen = false;
- // // 判断是否是全屏发送
+ // // Check whether the message is sent in full screen mode.
// this.judgeFullScreenSend(this.$app.$def.textValueOther);
- // // 全屏页面的时候使用
+ // // Used for full-screen pages.
// this.fullScreenSend();
// }
- // // 转发发送
+ // // Forwarding and sending
// this.transmitSend();
- // // 外部应用获取数据
+ // // Obtaining data from external applications
// this.dataFromPick();
}
onHide() {
+ HiLog.i(TAG, "onHide");
this.unSubscribeDetail();
}
getSimState() {
telephonySim.getSimState(common.int.SIM_ONE, (err, value) => {
if (err) {
- HiLog.e(TAG, 'getSimState, SIM_ONE error: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "getSimState, SIM_ONE error: " + JSON.stringify(err.message));
} else {
- HiLog.i(TAG, 'getSimState, SIM_ONE value: ' + value);
+ 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);
+ HiLog.i(TAG, "haveSimCard1 = " + this.haveSimCard);
}
});
}
- // 监听SIM卡状态
+ // Listening to the SIM card status
addSimChangeListener() {
- observer.on('simStateChange', {
+ observer.on("simStateChange", {
slotId: common.int.SIM_ONE
}, data => {
let simState = data.state;
let isEffective: boolean;
- HiLog.i(TAG, 'addSimChangeListener simState = ' + simState);
+ 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);
+ HiLog.i(TAG, "simState is = " + isEffective);
+ MmsPreferences.getInstance().setValueForSwitch(common.string.KEY_OF_SIM_0_EXIST_FLAG, isEffective);
this.haveSimCard = isEffective;
this.initSendTip();
});
}
+ simChangeListenerOff() {
+ observer.off("simStateChange");
+ }
+
initData() {
- this.strMsgDeleteDialogTip = $r('app.string.msg_delete_dialog_tip2',
+ this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip2",
this.selectDeleteMsgCount
);
this.tabTextList = [
- // $r('app.string.msg_take_photos'),
- // $r('app.string.msg_picture'),
- // $r('app.string.msg_record'),
- // $r('app.string.more_low')
+ // $r("app.string.msg_take_photos"),
+ // $r("app.string.msg_picture"),
+ // $r("app.string.msg_record"),
+ // $r("app.string.more_low")
];
this.animationOptions = {
duration: ANIMATION_DURATION,
- easing: 'linear',
- fill: 'forwards',
- iterations: 'Infinity',
+ easing: "linear",
+ fill: "forwards",
+ iterations: "Infinity",
};
this.animationFrames = [
{
@@ -347,7 +355,7 @@ export default class ConversationController {
}
}
];
- // this.pattern = $r('app.string.camera_post');
+ // this.pattern = $r("app.string.camera_post");
this.initSlideDurations();
}
@@ -369,14 +377,15 @@ export default class ConversationController {
initNewPageContracts() {
let transmitContracts = [];
if (this.strContactsNumber) {
- let contactsNames = this.strContactsName.split(',');
- let telephones = this.strContactsNumber.split(',');
- let telephoneFormat = this.strContactsNumberFormat.split(',');
+ let contactsNames = this.strContactsName.split(",");
+ let telephones = this.strContactsNumber.split(",");
+ let telephoneFormat = this.strContactsNumberFormat.split(",");
for (let index in contactsNames) {
let item: LooseObject = {};
item.contactName = contactsNames[index];
item.telephone = telephones[index];
- if (contactsNames[index] == common.string.EMPTY_STR && telephoneFormat[index] == common.string.EMPTY_STR) {
+ if (contactsNames[index] == common.string.EMPTY_STR &&
+ telephoneFormat[index] == common.string.EMPTY_STR) {
item.telephoneFormat = telephones[index];
} else {
item.telephoneFormat = telephoneFormat[index];
@@ -392,86 +401,101 @@ export default class ConversationController {
}
initRouterData() {
+ let routerParams: LooseObject = router.getParams()
this.strContactsName =
- router.getParams().strContactsName == undefined ? '' : router.getParams().strContactsName;
+ routerParams.strContactsName == undefined ? '' : routerParams.strContactsName;
this.strContactsNumber =
- router.getParams().strContactsNumber == undefined ? '' : router.getParams().strContactsNumber;
+ routerParams.strContactsNumber == undefined ? '' : routerParams.strContactsNumber;
this.strContactsNumberFormat =
- router.getParams().strContactsNumberFormat == undefined ? '' : router.getParams().strContactsNumberFormat;
- this.contactsNum = router.getParams().contactsNum == undefined ? 0 : router.getParams().contactsNum;
- this.threadId = router.getParams().threadId == undefined ? 0 : router.getParams().threadId;
- this.isDraft = router.getParams().isDraft == undefined ? false : router.getParams().isDraft;
- this.draftContent = router.getParams().draftContent == undefined ? '' : router.getParams().draftContent;
- this.searchContent = router.getParams().searchContent == undefined ? '' : router.getParams().searchContent;
- this.isNewMsg = router.getParams().isNewMsg == undefined ? false : router.getParams().isNewMsg;
+ routerParams.strContactsNumberFormat == undefined ? '' : routerParams.strContactsNumberFormat;
+ this.contactsNum = routerParams.contactsNum == undefined ? 0 : routerParams.contactsNum;
+ this.threadId = routerParams.threadId == undefined ? 0 : routerParams.threadId;
+ this.isDraft = routerParams.isDraft == undefined ? false : routerParams.isDraft;
+ this.draftContent = routerParams.draftContent == undefined ? '' : routerParams.draftContent;
+ this.searchContent = routerParams.searchContent == undefined ? '' : routerParams.searchContent;
+ this.isNewMsg = routerParams.isNewMsg == undefined ? false : routerParams.isNewMsg;
+ this.portraitColor = AvatarColor.background.Color[Math.abs(parseInt(this.threadId, 10)) % 6];
+ this.photoFirstNameDeal(this.strContactsName);
+ this.dealSpecialPhoneNumber();
+ }
+ photoFirstNameDeal(strContactsName) {
+ if(strContactsName !== common.string.EMPTY_STR && this.reg.test(strContactsName.substring(0, 1))) {
+ this.photoFirstName = strContactsName.substring(0, 1).toUpperCase()
+ } else {
+ this.photoFirstName = '-1'
+ }
+ }
+
+ // Handle invalid phone numbers that contain #, *, and dots in redirection from other applications.
+ // Replace them with spaces.
+ dealSpecialPhoneNumber() {
+ if (!this.isPhoneNumber(this.strContactsNumber)) {
+ this.strContactsNumber = this.replaceCode(this.strContactsNumber);
+ this.strContactsNumberFormat = this.replaceCode(this.strContactsNumberFormat);
+ if (this.strContactsName != common.string.EMPTY_STR) {
+ this.strContactsName = common.string.EMPTY_STR;
+ }
+ }
+ }
+
+ replaceCode(str) {
+ if (str != null && str.length != 0) {
+ return str.replace(new RegExp(/e|-|#|\*|\./, "g"), common.string.EMPTY_STR);
+ } else {
+ return common.string.EMPTY_STR;
+ }
}
titleBarCancel() {
- // 取消按钮
+ // Cancel button
this.cancleCheckedAll();
this.setSelectStatus(false);
}
onBackPress() {
- // // 系统返回键,true代表拦截
+ // // Key returned by the system. The value true indicates interception.
// if (this.tabSlideStatus != 0) {
- // // tab全屏
+ // // Tab Full Screen
// this.restoreTabSlideStatus();
// return true;
// }
// if (this.isShowMoreOperation) {
- // // tab显示状态
+ // // Tab Display Status
// this.setTabOperationStatus(false);
// this.distanceBottomFlag = false;
// return true;
// }
if (this.isSelectStatus) {
- // 多选状态
+ // Multi-choice status
this.isSelectStatus = false;
this.cancleCheckedAll();
return true;
}
let source = this.getMmsSource();
- // 不存在草稿或者需要更新草稿的操作
- this.insertAndUpdateSessionDraft(source);
- // 存在草稿的情况下,需要做下面的操作
- this.dealSessionDraft(source);
- this.release();
- return false;
+ this.insertAndUpdateSessionDraft(source, ()=> {
+ this.release();
+ router.back();
+ });
+ return true;
}
- titleBarBack() {
- // if (this.tabSlideStatus != 0) {
- // // tab全屏
- // this.restoreTabSlideStatus();
- // return;
- // }
- // if (this.isShowMoreOperation) {
- // // tab显示状态
- // this.setTabOperationStatus(false);
- // this.distanceBottomFlag = false;
- // return;
- // }
- if (this.isSelectStatus) {
- // 多选状态
- this.isSelectStatus = false;
- this.cancleCheckedAll();
- return;
+ insertAndUpdateSessionDraft(source, callback) {
+ HiLog.i(TAG, "isNewMsg=" + this.isNewMsg + ", isDraft=" + this.isDraft);
+
+ // Create a draft. If the selected contact or content is empty, delete the draft.
+ if (this.isNewMsg && this.isDraft) {
+ if ((this.selectContacts.length == 0 && this.receiveContactValue == common.string.EMPTY_STR) ||
+ (this.textValue == common.string.EMPTY_STR && source.length == 0)) {
+ conversationListService.deleteMessageBySessionId([this.threadId]);
+ this.deleteDraftData();
+ }
}
- let source = this.getMmsSource();
- // 不存在草稿或者需要更新草稿的操作
- this.insertAndUpdateSessionDraft(source);
- // 存在草稿的情况下,需要做下面的操作
- this.dealSessionDraft(source);
- this.release();
- router.back();
- }
- insertAndUpdateSessionDraft(source) {
let hasReport = settingService.judgeIsDeliveryReport(this.isEditMms);
let hasAttachment = commonService.judgeIsAttachment(source);
let actionData: LooseObject = {};
actionData = {
+ threadId: this.threadId,
receiveContactValue: common.string.EMPTY_STR,
selectContacts: [],
content: this.textValue,
@@ -486,67 +510,74 @@ export default class ConversationController {
messageType: this.messageType,
hasAttachment: hasAttachment
}
- // 新建页面 草稿数据,需要进行保存
- if (this.isNewMsg && (this.textValue != common.string.EMPTY_STR || source.length !== 0)) {
- actionData.isNewMsg = true;
- HiLog.i(TAG, 'insertAndUpdateSessionDraft, isNewMsg=true')
- // 如果选择联系人不为空
- if (this.selectContacts.length > 0) {
- actionData.selectContacts = this.selectContacts;
- conversationListService.insertSessionDraft(actionData);
+
+ // The draft does not exist or the draft needs to be updated. The draft data on the new page needs to be saved.
+ if (this.textValue != common.string.EMPTY_STR || source.length !== 0) {
+ actionData.isNewMsg = this.isNewMsg;
+ if (this.isNewMsg) {
+ // If the selected contact is not empty
+ if (this.selectContacts.length > 0) {
+ actionData.selectContacts = this.selectContacts;
+ conversationListService.insertSessionDraft(actionData, callback);
+ }
+ // If the recipient input field is not empty
+ else if (this.receiveContactValue != common.string.EMPTY_STR) {
+ actionData.receiveContactValue = this.receiveContactValue;
+ // If the number entered in the text box is invalid, the system does not save the draft when the
+ // Back key is pressed.
+ if (this.isPhoneNumber(this.receiveContactValue)) {
+ conversationListService.insertSessionDraft(actionData, callback);
+ } else if (this.isDraft) {
+ // If the current draft is in draft state and the entered number is invalid, the current draft
+ // is deleted.
+ conversationListService.deleteMessageBySessionId([this.threadId]);
+ this.deleteDraftData();
+ callback();
+ } else {
+ callback();
+ }
+ } else {
+ callback();
+ }
+ } else {
+ // This is not a new scenario.
+ actionData.telephone = this.strContactsNumber;
+ conversationListService.insertSessionDraft(actionData, callback);
}
- // 如果收件人输入栏不为空
- else if (this.receiveContactValue != common.string.EMPTY_STR) {
- actionData.receiveContactValue = this.receiveContactValue;
- conversationListService.insertSessionDraft(actionData);
- }
- }
- // 这里不是新建的场景
- else if (this.textValue != common.string.EMPTY_STR || source.length !== 0) {
- actionData.isNewMsg = false;
- actionData.telephone = this.strContactsNumber;
- HiLog.i(TAG, 'insertAndUpdateSessionDraft, isNewMsg=false')
- conversationListService.insertSessionDraft(actionData);
+ } else if (!this.isNewMsg && this.isDraft) {
+ // If a draft exists, perform the following operations:
+ this.dealSessionDraft(source);
+ callback();
+ } else {
+ callback();
}
}
+ // When the draft logic is set, the text content is empty and the page is not created, the session list data needs
+ // to be updated.
dealSessionDraft(source) {
- // 新建存在草稿,只要选择的联系人或者内容为空,就要将草稿删除
- if (this.isNewMsg && this.isDraft) {
- HiLog.i(TAG, 'dealSessionDraft, start')
- if ((this.selectContacts.length == 0 && this.receiveContactValue == common.string.EMPTY_STR)
- || (this.textValue == common.string.EMPTY_STR && source.length == 0)) {
- let threadIds = [this.threadId];
- conversationListService.deleteMessageBySessionId(threadIds);
- this.deleteDraftData();
- }
+ // Query the last content in the list
+ let length = this.mmsList.length;
+ let item = this.mmsList[length - 1];
+ // Updating list data
+ let threadIds = [this.threadId];
+ let time = new Date();
+ let content = item.content;
+ let hasAttachment = false;
+ if (item.isMsm) {
+ content = commonService.getMmsContent(item.mms);
+ hasAttachment = commonService.judgeIsAttachment(source);
}
-
- // 设置草稿逻辑,文本内容为空,并且不是新建页面,需要更新会话列表数据
- if (!this.isNewMsg && this.isDraft && (this.textValue == common.string.EMPTY_STR && source.length == 0)) {
- // 先查询出列表中最后一个内容
- let length = this.mmsList.length;
- let item = this.mmsList[length - 1];
- // 在更新列表数据
- let threadIds = [this.threadId];
- let time = new Date();
- let content = item.content;
- let hasAttachment = false;
- if (item.isMsm) {
- content = commonService.getMmsContent(item.mms);
- hasAttachment = commonService.judgeIsAttachment(source);
- }
- let valueBucket = {
- 'content': item.content,
- 'has_draft': 0,
- 'time': time.getTime(),
- 'has_mms': item.isMsm ? 1 : 0,
- 'has_attachment': hasAttachment ? 1 : 0
- }
- conversationListService.updateById(threadIds, valueBucket);
- this.deleteDraftData();
- this.isDraft = false;
+ let valueBucket = {
+ "content": item.content,
+ "has_draft": 0,
+ "time": time.getTime(),
+ "has_mms": item.isMsm ? 1 : 0,
+ "has_attachment": hasAttachment ? 1 : 0
}
+ conversationListService.updateById(threadIds, valueBucket);
+ this.deleteDraftData();
+ this.isDraft = false;
}
cancleCheckedAll() {
@@ -567,17 +598,17 @@ export default class ConversationController {
}
setMessageCheckAll(type) {
- HiLog.i(TAG, 'setMessageCheckAll, isSelectStatus=' + this.isSelectStatus);
+ HiLog.i(TAG, "setMessageCheckAll, isSelectStatus=" + this.isSelectStatus);
if (!this.isSelectStatus) {
return;
}
if (type == common.int.CHECKBOX_SELECT_ALL) {
- HiLog.i(TAG, 'setMessageCheckAll, CHECKBOX_SELECT_ALL');
+ HiLog.i(TAG, "setMessageCheckAll, CHECKBOX_SELECT_ALL");
this.selectDeleteMsgCount = this.mmsList.length;
this.isMessageCheckAll = true;
this.hasReport = false;
let countLock = 0;
- // 判断一下是不是全部都被锁定
+ // Check whether all of them are locked.
for (let element of this.mmsList) {
if (element.isCbChecked && element.isLock) {
countLock++;
@@ -587,21 +618,21 @@ export default class ConversationController {
this.hasLock = true;
}
} else if (type == common.int.CHECKBOX_SELECT_NONE) {
- HiLog.i(TAG, 'setMessageCheckAll, CHECKBOX_SELECT_NONE');
+ HiLog.i(TAG, "setMessageCheckAll, CHECKBOX_SELECT_NONE");
this.selectDeleteMsgCount = 0;
this.isMessageCheckAll = false;
this.hasLock = false;
this.hasReport = false;
} else {
- // 默认为 CHECKBOX_SELECT_UNKNOWN,判断是否有未选中
- HiLog.i(TAG, 'setMessageCheckAll, else');
+ // The default value is CHECKBOX_SELECT_UNKNOWN. Check whether there is any unselected item.
+ HiLog.i(TAG, "setMessageCheckAll, else");
this.checkBoxSelectUnknow();
}
}
checkBoxSelectUnknow() {
- HiLog.i(TAG, 'checkBoxSelectUnknow, start');
- // 默认为 CHECKBOX_SELECT_UNKNOWN,判断是否有未选中
+ HiLog.i(TAG, "checkBoxSelectUnknow, start");
+ // The default value is CHECKBOX_SELECT_UNKNOWN. Check whether there is any unselected item.
this.isMessageCheckAll = true;
this.selectDeleteMsgCount = 0;
let countLock = 0;
@@ -619,13 +650,13 @@ export default class ConversationController {
countReport++;
}
}
- // 如果选择的是一个,并且存在锁
+ // If one is selected and there is a lock
if (this.selectDeleteMsgCount == 1 && countLock > 0) {
this.hasLock = true;
} else {
this.hasLock = false;
}
- // 如果全部选中了,并且全部锁定了
+ // If all are checked and all are locked
if (this.selectDeleteMsgCount == countLock) {
this.hasLock = true;
}
@@ -637,12 +668,13 @@ export default class ConversationController {
}
listCheckBoxChange(index, e) {
- // API 7的时候,这个isOn不是boolean类型,打印出来是number类型,直接使用会有问题
+ // When API 7 is used, the isOn type is not boolean but is of the number type. If the isOn type is displayed,
+ // an error may occur.
let isCheck: string = e
- // this.messageList[index].isCbChecked = isCheck == '1' ? true : false;
+ // this.messageList[index].isCbChecked = isCheck == "1" ? true : false;
let item = this.mmsList[index];
- item.isCbChecked = isCheck == '1' ? true : false;
- HiLog.i(TAG, 'listCheckBoxChange, isCbChecked=' + item.isCbChecked + ', index=' + index + ', mmsIndex=' + this.mmsIndex);
+ item.isCbChecked = isCheck == "1" ? true : false;
+ HiLog.i(TAG, `listCheckBoxChange, isCbChecked=${item.isCbChecked}, index=${index}, mmsIndex=${this.mmsIndex}`);
this.mmsIndex = index;
this.hasReport = item.hasReport;
this.setMessageCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN);
@@ -677,39 +709,39 @@ export default class ConversationController {
longPressSelected(index) {
switch (index) {
case 0:
- // 复制
+ // duplicating
this.copyText();
break;
case 1:
- // 转发
+ // Forwarding
// this.transmitMsgSingle();
break;
case 2:
- // 删除
+ // Delete
this.deleteDialogShow();
break;
case 3:
- // 选择文本
+ // Select Text
this.gotoTextSelect(this.mmsIndex);
break;
case 4:
- // 更多
+ // more
this.more();
break;
case 5:
- // 保存
+ // Save
this.saveImage();
break;
default:
break;
}
}
- // 删除弹框提示
+ // Delete a dialog box.
deleteDialogShow() {
this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip1");
let item = this.mmsList[this.mmsIndex];
item.isShowMsgLongMenu = false
- HiLog.i(TAG, 'deleteDialogShow, isShowMsgLongMenu=' + item.isShowMsgLongMenu);
+ HiLog.i(TAG, "deleteDialogShow, isShowMsgLongMenu=" + item.isShowMsgLongMenu);
this.hasLockMsg = item.isLock;
this.deleteDialog();
if (!item.isMsm) {
@@ -717,7 +749,7 @@ export default class ConversationController {
return;
}
}
- // 更多
+ // more
more() {
this.setTabOperationStatus(false);
this.distanceBottomFlag = false;
@@ -725,7 +757,7 @@ export default class ConversationController {
item.isCbChecked = !item.isCbChecked;
item.isShowMsgLongMenu = false;
- HiLog.i(TAG, 'more, isShowMsgLongMenu=' + item.isShowMsgLongMenu);
+ HiLog.i(TAG, "more, isShowMsgLongMenu=" + item.isShowMsgLongMenu);
this.setSelectStatus(true);
this.hasDetailDelete = false;
this.setMessageCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN);
@@ -735,7 +767,7 @@ export default class ConversationController {
setTabOperationStatus(flag) {
this.isShowMoreOperation = flag;
- // 数值类,hml页面才会刷新
+ // Value type. The HTML page is refreshed only when the value type is numeric.
if (flag) {
this.sendBarMarginBottom = common.int.TAB_HEIGHT;
} else {
@@ -746,7 +778,7 @@ export default class ConversationController {
setSelectStatus(isSelect) {
this.isSelectStatus = isSelect;
}
- // 短信内容长按事件
+ // Event of pressing and holding an SMS message
mmsListLongPress(index) {
for (let i = 0; i < this.mmsList.length; i++) {
if (index == i) {
@@ -768,9 +800,9 @@ export default class ConversationController {
let menuId = common.string.EMPTY_STR;
if (item.isMsm) {
this.setGroupMoreMenu(item);
- // menuId = 'menu_long_press_mms';
+ // menuId = "menu_long_press_mms";
} else {
- // menuId = 'menu_long_press';
+ // menuId = "menu_long_press";
}
// setTimeout(() => {
// this.$element(menuId).show({
@@ -787,17 +819,17 @@ export default class ConversationController {
}
deleteDialogCancel() {
- // 取消弹出
+ // Cancel Ejection
this.isSelectLockMsg = false;
- HiLog.i(TAG, 'deleteDialogCancel, isSelectLockMsg=false')
+ HiLog.i(TAG, "deleteDialogCancel, isSelectLockMsg=false")
}
deleteDialogConfirm() {
let groupIds = [];
let mmsListCopy = [];
- HiLog.i(TAG, 'deleteDialogConfirm, isSelectStatus=' + this.isSelectStatus);
+ HiLog.i(TAG, "deleteDialogConfirm, isSelectStatus=" + this.isSelectStatus);
if (this.isSelectStatus) {
- // 通过filter删除选中的item
+ // Delete the selected item through the filter.
for (let element of this.mmsList) {
if (!element.isCbChecked || (element.isLock && !this.isSelectLockMsg)) {
this.setDateShow(element, mmsListCopy);
@@ -806,7 +838,7 @@ export default class ConversationController {
groupIds.push(element.groupId);
}
}
- // 设置为非多选状态
+ // Set to non-multi-choice status
this.setSelectStatus(false);
this.mmsList = mmsListCopy;
} else if (!this.mmsList[this.mmsIndex].isLock || this.isSelectLockMsg) {
@@ -820,14 +852,14 @@ export default class ConversationController {
}
}
this.mmsList = mmsListCopy;
- HiLog.i(TAG, 'deleteDialogConfirm, mmsList.length=' + this.mmsList.length);
+ HiLog.i(TAG, "deleteDialogConfirm, mmsList.length=" + this.mmsList.length);
groupIds.push(item.groupId);
}
this.isSelectLockMsg = false;
this.cancleCheckedAll();
if (groupIds.length > 0) {
this.deleteMessageByGroupIds(groupIds);
- // 判断删除后list长度是否为0
+ // Check whether the length of the deleted list is 0.
if (this.mmsList.length === 0 && this.textValue === common.string.EMPTY_STR) {
router.back();
this.deleteMessageById(this.threadId);
@@ -836,25 +868,25 @@ export default class ConversationController {
this.updateLastItemContent();
}
}
- // 删除完成之后,需要判断数据是否全部删除
+ // After the deletion is complete, check whether all data is deleted.
}
deleteMessageByGroupIds(groupIds) {
let actionData = {
groupIds: groupIds,
};
- // 这里调用数据库的删除方法
+ // Invoke the database deletion method.
conversationService.deleteMessageByGroupIds(actionData);
}
- // 更新会话列表的锁状态
+ // Updates the lock status of the session list.
updateSessionLock(isLock) {
let threadIds = [this.threadId];
let hasLock = isLock ? 1 : 0;
let valueBucket = {
- 'has_lock': hasLock,
+ "has_lock": hasLock,
}
if (!isLock) {
- // 如果是取消锁定,必须是全部取消锁定,才可以将状态进行解锁
+ // If you want to unlock the status, you must unlock all the statuses before unlocking the statuses.
let unlockCount = 0;
for (let element of this.mmsList) {
if (!element.isLock) {
@@ -862,11 +894,11 @@ export default class ConversationController {
}
}
if (unlockCount != this.mmsList.length) {
- HiLog.w(TAG, 'updateSessionLock, it is not all select unlock');
+ HiLog.w(TAG, "updateSessionLock, it is not all select unlock");
return;
}
}
- // 如果是锁定,将状态更新为锁定
+ // If it is locked, update the status to locked.
conversationListService.updateById(threadIds, valueBucket);
}
@@ -880,7 +912,7 @@ export default class ConversationController {
deleteMessageById(threadId) {
let threadIds = [threadId];
- // 删除数据库数据
+ // Deleting Database Data
let actionData = {
threadIds: threadIds,
};
@@ -912,25 +944,25 @@ export default class ConversationController {
},
primaryButton: {
value: $r("app.string.cancel"),
- fontColor: $r("app.color.control_activated_color"),
+ fontColor: $r("sys.color.ohos_id_color_floating_button_bg_normal"),
action: () => {
this.deleteDialogCancel()
}
},
secondaryButton: {
value: $r("app.string.delete"),
- fontColor: $r("app.color.message_send_failed"),
+ fontColor: $r("sys.color.ohos_id_color_warning"),
action: () => {
this.deleteDialogConfirm()
}
},
cancel: () => {
- HiLog.i(TAG, 'deleteDialog, cancel')
+ HiLog.i(TAG, "deleteDialog, cancel")
}
}
)
}
- // 判断联系人是否存在
+ // Check whether a contact exists.
judgeContactExists() {
let telephones = [this.strContactsNumber];
let actionData = {
@@ -946,14 +978,14 @@ export default class ConversationController {
}
}
/**
- * 获取信息详情
- * @param params 电话号码/会话id
- * @param callback 返回信息内容
+ * Obtain information details.
+ * @param params Phone Number/Session ID
+ * @param callback Content of the returned information
* @return
*/
- // 查询信息会话列表
+ // Querying the Information Session List
queryMessageDetail(telephone, threadId, callback) {
- HiLog.i(TAG, 'queryMessageDetail, start');
+ HiLog.i(TAG, "queryMessageDetail, start 1111");
let actionData: LooseObject = {};
if (telephone != common.string.EMPTY_STR) {
actionData.telephone = telephone;
@@ -969,11 +1001,14 @@ export default class ConversationController {
this.dealMessageDetailTime(result);
this.dealMessageDetailContent(result);
if (this.mmsList.length == 0 && this.isDraft) {
- HiLog.i(TAG, 'queryMessageDetail, isNewMsg = true');
+ HiLog.i(TAG, "queryMessageDetail, isNewMsg = true");
this.isNewMsg = true;
}
} else {
- HiLog.w(TAG, 'queryMessageDetail, failed');
+ HiLog.w(TAG, "queryMessageDetail, failed");
+ }
+ if (this.isDraft) {
+ this.setDraft();
}
this.deleteDraftData();
callback();
@@ -990,15 +1025,15 @@ export default class ConversationController {
let strContent = content;
if (showType == common.MESSAGE_SHOW_TYPE.THEME_NO_IMAGE || showType == common.MESSAGE_SHOW_TYPE.THEME_IMAGE) {
if (content !== common.string.EMPTY_STR) {
- strContent = $r('app.string.msg_theme') + ': ' + content;
+ strContent = $r("app.string.msg_theme") + ": " + content;
}
} else if (showType == common.MESSAGE_SHOW_TYPE.PPT_NO_IMAGE) {
- strContent = (content == common.string.EMPTY_STR) ? $r('app.string.msg_slide') : content;
+ strContent = (content == common.string.EMPTY_STR) ? $r("app.string.msg_slide") : content;
} else if (showType == common.MESSAGE_SHOW_TYPE.PPT_IMAGE) {
if (mmsSource[0].msgType == common.MSG_ITEM_TYPE.THEME && content !== common.string.EMPTY_STR) {
- strContent = $r('app.string.msg_theme') + ': ' + content;
+ strContent = $r("app.string.msg_theme") + ": " + content;
} else {
- strContent = (content == common.string.EMPTY_STR) ? $r('app.string.msg_slide') : content;
+ strContent = (content == common.string.EMPTY_STR) ? $r("app.string.msg_slide") : content;
}
}
return strContent;
@@ -1055,14 +1090,14 @@ export default class ConversationController {
};
mms.push(mmsObj);
}
- let placeholder = $r('app.string.enter_text');
+ let placeholder = $r("app.string.enter_text");
if (source.msgType == common.MSG_ITEM_TYPE.THEME) {
- placeholder = $r('app.string.msg_theme');
+ placeholder = $r("app.string.msg_theme");
} else if (mmsSource[0].msgType == common.MSG_ITEM_TYPE.THEME && mmsSource.length == 2) {
if (mmsObj) {
- placeholder = $r('app.string.msg_note_mms2');
+ placeholder = $r("app.string.msg_note_mms2");
} else {
- placeholder = $r('app.string.msg_note_mms');
+ placeholder = $r("app.string.msg_note_mms");
}
this.pptTotalCount = 0;
}
@@ -1104,7 +1139,6 @@ export default class ConversationController {
this.isDraft = true;
this.draftContent = item.content;
this.draftGroupId = item.groupId;
- this.setDraft();
if (item.isMsm) {
this.isEditMms = true;
this.setMmsDataSource(item.mms);
@@ -1112,9 +1146,9 @@ export default class ConversationController {
this.messageType = common.MESSAGE_TYPE.NORMAL;
}
}
- // 设置草稿内容
+ // Set Draft Content
setDraft() {
- // 如果是草稿需要配展示草稿内容
+ // If the content is a draft, the draft content needs to be displayed.
if (this.isDraft) {
this.textValue = this.draftContent;
this.canSendMessage = this.haveSimCard;
@@ -1131,12 +1165,12 @@ export default class ConversationController {
}
conversationService.updateSessionAndDetail(actionData);
let sendStatus = sendResult.sendStatus
- let deliveryReportSwitch = preferences.getValueOfDeliveryReportSwitch();
- HiLog.i(TAG, 'updateDetail, sendStatus=' + sendStatus + ', deliveryReportSwitch=' + deliveryReportSwitch)
+ let deliveryReportSwitch = MmsPreferences.getInstance().getValueOfDeliveryReportSwitch();
+ HiLog.i(TAG, "updateDetail, sendStatus=" + sendStatus + ", deliveryReportSwitch=" + deliveryReportSwitch)
if ((deliveryReportSwitch == common.DELIVERY_REPORTS.SMS_AND_MMS ||
deliveryReportSwitch == common.DELIVERY_REPORTS.SMS) &&
sendStatus == common.int.SEND_MESSAGE_SUCCESS) {
- let msg = this.strContactsNumber + ' 已收到消息!'
+ let msg = this.strContactsNumber + " 已收到消息!"
this.showToast(msg)
}
}
@@ -1147,20 +1181,20 @@ export default class ConversationController {
duration: 2000,
});
}
- // 设置发送状态
+ // Setting the Sending Status
setCanSendMsgStatus() {
if (this.receiveContactValue == common.string.EMPTY_STR && this.selectContacts.length == 0) {
- HiLog.d(TAG, 'setCanSendMsgStatus: ' + this.canSendMessage);
+ HiLog.d(TAG, "setCanSendMsgStatus: " + this.canSendMessage);
this.canSendMessage = false;
}
}
initSendTip() {
if (this.isEditMms) {
- // 彩信
+ // MMS
this.getCurEdtFileSize();
this.canSendMessage = true;
- // 新建页面 收件人是否未空
+ // Check whether the recipient on the new page is empty.
if (this.isNewMsg) {
this.setCanSendMsgStatus();
}
@@ -1171,7 +1205,7 @@ export default class ConversationController {
}
setSmsTip(str) {
- // 设置短信提示信息
+ // Setting SMS Prompt Information
let len = str.length;
let msgSize;
let curCanInputSize;
@@ -1181,7 +1215,7 @@ export default class ConversationController {
return;
} else {
this.canSendMessage = this.haveSimCard && !this.isFlightMode;
- HiLog.i(TAG, 'setSmsTip, canSendMessage=' + this.canSendMessage + ', haveSimCard=' + this.haveSimCard);
+ HiLog.i(TAG, "setSmsTip, canSendMessage=" + this.canSendMessage + ", haveSimCard=" + this.haveSimCard);
}
if (this.isNewMsg) {
this.setCanSendMsgStatus();
@@ -1193,9 +1227,9 @@ export default class ConversationController {
msgSize = Math.ceil(len / 160);
curCanInputSize = len % 160 == 0 ? 0 : 160 - len % 160;
}
- this.msgSendTip = curCanInputSize + '/' + msgSize;
+ this.msgSendTip = curCanInputSize + "/" + msgSize;
}
- // 获取当前彩信编辑的文件大小
+ // Obtains the size of the current MMS file.
getCurEdtFileSize() {
this.curEdtFileSize = 0;
if (!this.isEditMms || this.mmsEditList.length == 0) {
@@ -1207,12 +1241,12 @@ export default class ConversationController {
}
dealMmsSendResult(sendNumber, item, sendResult) {
- HiLog.i(TAG, 'dealMmsSendResult, start')
- // 彩信发送
+ HiLog.i(TAG, "dealMmsSendResult, start")
+ // MMS Sending
sendResult.sendStatus = common.int.SEND_MESSAGE_SUCCESS;
item.sendStatus = common.int.SEND_MESSAGE_SUCCESS;
this.updateDetail(this.threadId, sendResult);
- // 这里会发送下彩信,用于接收使用
+ // The MMS message will be sent for receiving and using.
if (sendNumber.length == 1 && sendResult.sendStatus == common.int.SEND_MESSAGE_SUCCESS) {
setTimeout(() => {
// this.publishData(sendResult.telephone, item.mmsSource);
@@ -1226,16 +1260,16 @@ export default class ConversationController {
}
dealSmsSendResult(params, item, sendResult) {
- HiLog.i(TAG, 'dealSmsSendResult, start')
+ HiLog.i(TAG, "dealSmsSendResult, start")
sendMsgService.sendMessage(params, (sendStatus) => {
- HiLog.i(TAG, 'dealSmsSendResult, sendMessage sendStatus: ' + sendStatus);
+ HiLog.i(TAG, "dealSmsSendResult, sendMessage sendStatus: " + sendStatus);
item.sendStatus = sendStatus;
if (sendStatus === common.int.SEND_MESSAGE_FAILED) {
item.failuresNumber = item.failuresNumber + 1;
}
item.completeNumber = item.completeNumber + 1;
sendResult.sendStatus = sendStatus;
- // 更新发送的状态
+ // Update Sending Status
this.updateDetail(this.threadId, sendResult);
this.refresh = !this.refresh
});
@@ -1250,15 +1284,15 @@ export default class ConversationController {
}
convertingSms() {
- // 转化为短信
+ // Convert to SMS
this.isEditMms = false;
this.setSmsTip(this.textValue);
- this.showToast($r('app.string.converting_sms'));
+ this.showToast($r("app.string.converting_sms"));
}
dealSendResult(sendNumber, content, item, initDatas) {
- HiLog.i(TAG, 'dealSendResult, start')
- // 添加发送信息到list中
+ HiLog.i(TAG, "dealSendResult, start")
+ // Add sending information to the list.
for (let i = 0; i < sendNumber.length; i++) {
let params = {
slotId: this.slotId,
@@ -1281,7 +1315,7 @@ export default class ConversationController {
}
insertInitData(sendNumber, content, item, callback) {
- HiLog.i(TAG, 'insertInitData, start')
+ HiLog.i(TAG, "insertInitData, start")
let insertSendResults = [];
for (let i = 0; i < sendNumber.length; i++) {
let sendResult = {
@@ -1315,9 +1349,10 @@ export default class ConversationController {
}
updatePreview(idx) {
- // 删除预览
- HiLog.i(TAG, 'updatePreview, idx: ' + idx);
- // 如果预览这里删除的不是音频(图片或视频),还需要改变图库缩略图中checkbox的值
+ // Delete Preview
+ HiLog.i(TAG, "updatePreview, idx: " + idx);
+ // If not audio (picture or video) is deleted from the preview, you need to change the value of
+ // checkbox in the thumbnail of the gallery.
if (this.mmsEditList[idx].type != common.MSG_ITEM_TYPE.AUDIO) {
let that = this;
this.pictureListFromGallery.forEach(function (item) {
@@ -1335,8 +1370,8 @@ export default class ConversationController {
}
initSendItem() {
- // 获取当天是星期几
- HiLog.i(TAG, 'initSendItem, start')
+ // Obtains the day of the week.
+ HiLog.i(TAG, "initSendItem, start")
let item: LooseObject = {};
item.date = common.string.EMPTY_STR;
item.time = $r("app.string.justNow");
@@ -1369,7 +1404,7 @@ export default class ConversationController {
this.mmsList.push(item);
this.refresh = !this.refresh
}
- // 判断每条短信上方的时间是否显示
+ // Check whether the time on the top of each SMS message is displayed.
setDateShow(item, list) {
item.dateShow = true;
let tempDateId = item.date.id;
@@ -1380,8 +1415,9 @@ export default class ConversationController {
&& (tempWeekId != (list[list.length-1]).week.id)
}
}
+
getMmsSource() {
- HiLog.i(TAG, 'getMmsSource, start')
+ HiLog.i(TAG, "getMmsSource, start")
let sources = [];
this.dealTextareaDataSource();
if (this.messageType === common.MESSAGE_TYPE.NORMAL) {
@@ -1393,7 +1429,7 @@ export default class ConversationController {
}
dealTextareaDataSource() {
- HiLog.i(TAG, 'dealTextareaDataSource, start')
+ HiLog.i(TAG, "dealTextareaDataSource, start")
if (this.messageType == common.MESSAGE_TYPE.THEME) {
let first = this.textareaDatasource[0];
if (first.textValue == common.string.EMPTY_STR) {
@@ -1405,7 +1441,7 @@ export default class ConversationController {
}
dealMmsEditList() {
- HiLog.i(TAG, 'dealMmsEditList, start')
+ HiLog.i(TAG, "dealMmsEditList, start")
let sources = [];
if (this.mmsEditList.length != 0) {
this.mmsEditList.forEach((item, index) => {
@@ -1426,7 +1462,7 @@ export default class ConversationController {
}
getMmsSourceFromDataSource() {
- HiLog.i(TAG, 'getMmsSourceFromDataSource, start')
+ HiLog.i(TAG, "getMmsSourceFromDataSource, start")
let sources = [];
this.textareaDatasource.forEach((item, index) => {
let mms = {
@@ -1457,7 +1493,7 @@ export default class ConversationController {
}
getMmsSourceByTheme(sources, item, mms) {
- HiLog.i(TAG, 'getMmsSourceByTheme, start')
+ HiLog.i(TAG, "getMmsSourceByTheme, start")
if (this.mmsEditList.length === 1) {
let first = this.mmsEditList[0];
sources.unshift({
@@ -1475,7 +1511,7 @@ export default class ConversationController {
}
getMmsSourceByItem(sources, mms) {
- HiLog.i(TAG, 'getMmsSourceByItem, start')
+ HiLog.i(TAG, "getMmsSourceByItem, start")
this.mmsEditList.forEach((list, i) => {
if (i === 0) {
mms.msgType = list.type;
@@ -1496,9 +1532,9 @@ export default class ConversationController {
}
getMsgShowType(item) {
- HiLog.i(TAG, 'getMsgShowType, start')
+ HiLog.i(TAG, "getMsgShowType, start")
let type = common.MESSAGE_SHOW_TYPE.NORMAL;
- let slideString = 'msg_slide';
+ let slideString = "msg_slide";
if (this.messageType === common.MESSAGE_TYPE.NORMAL && this.mmsEditList.length <= 1) {
type = common.MESSAGE_SHOW_TYPE.NORMAL;
item.content = this.textValue;
@@ -1517,7 +1553,7 @@ export default class ConversationController {
}
getMsgShowTypePpt(item, slideString) {
- HiLog.i(TAG, 'getMsgShowTypePpt, start')
+ HiLog.i(TAG, "getMsgShowTypePpt, start")
let type = common.MESSAGE_SHOW_TYPE.NORMAL;
let hasSource = this.textareaDatasource.length > 0 ? true : false;
let firstStr = hasSource ? this.textareaDatasource[0].textValue : common.string.EMPTY_STR;
@@ -1537,7 +1573,7 @@ export default class ConversationController {
}
getPPTType() {
- HiLog.i(TAG, 'getPPTType, start')
+ HiLog.i(TAG, "getPPTType, start")
let type = common.MESSAGE_SHOW_TYPE.NORMAL;
if (this.messageType === common.MESSAGE_TYPE.NORMAL && this.mmsEditList.length > 0) {
type = common.MESSAGE_SHOW_TYPE.PPT_IMAGE;
@@ -1561,7 +1597,7 @@ export default class ConversationController {
}
getMsgShowTypeContent(item, firstStr, slideString) {
- HiLog.i(TAG, 'getMsgShowTypeContent, start')
+ HiLog.i(TAG, "getMsgShowTypeContent, start")
if (this.messageType === common.MESSAGE_TYPE.THEME_AND_PPT ||
this.messageType === common.MESSAGE_TYPE.THEME) {
item.content = this.getThemeContent();
@@ -1577,34 +1613,38 @@ export default class ConversationController {
}
getThemeContent() {
- HiLog.i(TAG, 'getThemeContent, start')
+ HiLog.i(TAG, "getThemeContent, start")
this.isEditMms = true;
let content = '';
let first = this.textareaDatasource[0].textValue;
let text = this.textareaDatasource[1].textValue;
if (first !== common.string.EMPTY_STR) {
- content = $r('app.string.msg_theme') + ': ' + first;
+ content = $r("app.string.msg_theme") + ": " + first;
}
if (text !== common.string.EMPTY_STR) {
if (content === common.string.EMPTY_STR) {
content = text;
} else {
- content = content + '\n' + text;
+ content = content + "\n" + text;
}
}
return content;
}
sendMassMessage(content, item, hosts) {
- HiLog.i(TAG, 'sendMassMessage, start')
+ HiLog.i(TAG, "sendMassMessage, start")
let sendNumber = hosts;
this.insertInitData(sendNumber, content, item, result => {
- // 处理发送的结果
+ // Processing the sent result
+ if (this.threadId != result.rowId) {
+ // When modifying the recipient information, click Send and delete the session before the modification.
+ conversationListService.deleteMessageBySessionId([this.threadId]);
+ }
this.threadId = result.rowId;
item.groupId = result.groupId;
item.id = result.initDatas[0].id;
this.refresh = !this.refresh
- // 发送及处理发送结果
+ // Sending and processing the sending result
this.dealSendResult(sendNumber, content, item, result.initDatas);
});
}
@@ -1613,7 +1653,7 @@ export default class ConversationController {
if (this.isEditMms) {
this.isEditMms = false;
}
- // 删除彩信发送时候的预览图片
+ // Deleting the preview image of an MMS message
if (this.mmsEditList.length != 0) {
for (let index in this.mmsEditList) {
this.updatePreview(index);
@@ -1631,15 +1671,15 @@ export default class ConversationController {
}
send() {
- HiLog.i(TAG, 'send, start');
- // 发送按钮置灰,不可发送信息
+ HiLog.i(TAG, "send, start");
+ // The Send button is dimmed and messages cannot be sent.
if (!this.canSendMessage) {
- HiLog.w(TAG, 'send, canSendMessage=false');
+ HiLog.w(TAG, "send, canSendMessage=false");
return;
}
- // 新建状态切换到会话状态
+ // Switching from the new state to the session state
if (this.isNewMsg) {
- HiLog.i(TAG, 'send, isNewMsg=true');
+ HiLog.i(TAG, "send, isNewMsg=true");
this.newSend(() => {
this.sendDataRefresh();
});
@@ -1650,7 +1690,7 @@ export default class ConversationController {
sendDataRefresh() {
this.isSendStatus = true;
- // 发送文本
+ // Send Text
if (this.textValue != common.string.EMPTY_STR || this.mmsEditList.length != 0 ||
this.textareaDatasource.length != 0) {
this.initSendItem();
@@ -1661,7 +1701,7 @@ export default class ConversationController {
content: this.textValue,
isEditMms: this.isEditMms
};
- // 真实的发送短信
+ // Real SMS Sending
this.sendInterval(actionData, this.mmsList);
this.textValue = common.string.EMPTY_STR;
this.canSendMessage = false;
@@ -1676,19 +1716,19 @@ export default class ConversationController {
}
isPhoneNumber(str) {
- // 判断是否是数字
+ // Determine whether the value is a number.
let reg = /^\d{1,}$/;
let pattern = new RegExp(reg);
return pattern.test(str);
}
newSend(callback) {
- // 先校验输入的内容是否有值
+ // Check whether the entered content has a value.
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');
+ // Invalid Recipient
+ this.showToast($r("app.string.invalid_receive", this.receiveContactValue))
+ HiLog.w(TAG, "newSend, PhoneNumber is invalidate");
return;
}
}
@@ -1708,41 +1748,45 @@ export default class ConversationController {
this.strContactsNumber = this.receiveContactValue;
this.strContactsNumberFormat = this.receiveContactValue;
} else {
- HiLog.w(TAG, 'newSend, the contact condition is not met.')
+ HiLog.w(TAG, "newSend, the contact condition is not met.")
return;
}
this.isNewMsg = false;
- // 如果设置取消发送,直接设置为true
+ // To cancel sending, set this parameter to true.
if (this.recallMessagesFlag) {
this.isNewRecallMessagesFlag = true;
this.commonCtrl.paramContact.isNewRecallMessagesFlag = true;
}
- // 当新建页面全屏跳转过来,需要获取下列表数据
+ // When the new page is displayed in full screen mode, the following table data needs to be obtained.
if (true) {
this.queryOldMessageList(this.strContactsNumber, callback);
}
}
queryOldMessageList(telephone, callback) {
- HiLog.i(TAG, 'queryOldMessageList, start');
+ HiLog.i(TAG, "queryOldMessageList, start");
if (telephone == common.string.EMPTY_STR) {
return;
}
let number = telephoneUtil.dealTelephoneSort(telephone);
conversationListService.querySessionByTelephone(number, res => {
- HiLog.i(TAG, 'queryOldMessageList, querySessionByTelephone res.response.id: ' + res.response.id)
+ HiLog.i(TAG, "queryOldMessageList, querySessionByTelephone res.response.id: " + res.response.id)
if (res.code == common.int.SUCCESS && res.response.id > 0) {
+ if (this.threadId != res.response.id) {
+ // When modifying the recipient information, click Send and delete the session before the
+ // modification.
+ conversationListService.deleteMessageBySessionId([this.threadId]);
+ }
this.threadId = res.response.id;
this.queryMessageDetail(telephone, res.response.id, callback);
} else {
- this.threadId = 0;
callback();
}
});
}
initNewSelectContacts(selectContacts) {
- HiLog.i(TAG, 'initNewSelectContacts, start');
+ HiLog.i(TAG, "initNewSelectContacts, start");
let contactsNumber = common.string.EMPTY_STR;
let contactsName = common.string.EMPTY_STR;
let contactsNumberFormat = common.string.EMPTY_STR;
@@ -1760,40 +1804,41 @@ export default class ConversationController {
}
this.strContactsNumber = contactsNumber.substring(0, contactsNumber.length - 1);
this.strContactsName = contactsName.substring(0, contactsName.length - 1);
+ this.photoFirstNameDeal(this.strContactsName);
this.strContactsNumberFormat = contactsNumberFormat.substring(0, contactsNumberFormat.length - 1);
this.contactsNum = length;
}
handleWithSend(actionData, item) {
HiLog.i(TAG, "handleWithSend, start")
- // 发送请求处理
+ // Sending request processing
let host = actionData.destinationHost;
- let index = host.indexOf(',');
+ let index = host.indexOf(",");
let hosts = [];
if (index == -1) {
- // 单发
+ // single-shot
hosts.push(actionData.destinationHost);
} else {
- // 群发
- hosts = actionData.destinationHost.split(',');
+ // Group Sending
+ hosts = actionData.destinationHost.split(",");
}
this.sendMassMessage(actionData.content, item, hosts);
}
sendInterval(actionData, mmsList) {
HiLog.i(TAG, "sendInterval, start");
- // 发送定时器
+ // Send Timer
let item = mmsList[mmsList.length - 1];
if (this.recallMessagesFlag) {
item.intervalSendStatus = true;
- // 点击发送按钮后,秒数倒计时定时器
+ // Second countdown timer after the Send button is clicked
item.sendIntervalId = setInterval(function () {
item.cancelTimeCount--;
}, 1000);
- // 发送定时器,超过6s发送
+ // Transmit timer, which is sent after 6s.
item.sendTimeoutId = setTimeout(() => {
item.cancelTimeCount = 0;
- // 清除定时器
+ // Clear Timer
clearTimeout(item.sendTimeoutId);
clearInterval(item.sendIntervalId);
this.handleWithSend(actionData, item);
@@ -1813,7 +1858,7 @@ export default class ConversationController {
}
return;
}
- // 是否显示全屏
+ // Whether to display full screen
if (this.isEditMms) {
this.isShowFullScreen = false;
} else {
@@ -1825,29 +1870,29 @@ export default class ConversationController {
return;
}
}
- // 设置短信的提示
+ // Setting SMS Notifications
this.setSmsTip(this.textValue);
}
setTabTitleText() {
- // 全局选择的tabTitleText
+ // TabTitleText selected globally
if (this.tabIndex != 1) {
- // 非图片页
+ // Non-picture page
this.tabTitleText = this.tabTextList[this.tabIndex];
return;
}
- // 图片选择页,显示选择个数size
+ // On the image selection page, the number of selected images is displayed.
let size = 0;
for (let element of this.pictureListFromGallery) {
if (element.checkedValue) {
size++;
}
}
- this.tabTitleText = size == 0 ? $r('app.string.msg_unselected_tip') : $r('app.string.msg_selected_tip', {
+ this.tabTitleText = size == 0 ? $r("app.string.msg_unselected_tip") : $r("app.string.msg_selected_tip", {
number: size
});
}
- // 检测发送图标是否可以高亮
+ // Check whether the sending icon can be highlighted.
judgeSendBtnCanClicked() {
if (this.haveSimCard &&
(this.mmsEditList.length != 0 ||
@@ -1863,42 +1908,31 @@ export default class ConversationController {
}
}
}
- // 初始化转发数据
- initTransmitMeg() {
- // if (AppStorage.getTransmitFlag()) {
- // this.threadId = AppStorage.getThreadId;
- // this.slotId = AppStorage.getSlotId;
- // this.contactsNum = AppStorage.getContactsNum;
- // this.strContactsName = AppStorage.getStrContactsName;
- // this.strContactsNumber = AppStorage.getStrContactsNumber;
- // this.strContactsNumberFormat = AppStorage.getStrContactsNumberFormat;
- // this.initNewPageContracts();
- // }
- }
- // 订阅公共事件
+ // Subscribing to Public Events
subscribeDetail() {
- HiLog.i(TAG, 'subscribeDetail, start');
+ HiLog.i(TAG, "subscribeDetail, start");
let events = [common.string.RECEIVE_TRANSMIT_EVENT]
let commonEventSubscribeInfo = {
events: events
};
- // 创建订阅信息
+ // Creating Subscription Information
commonEvent.createSubscriber(commonEventSubscribeInfo, this.createSubscriberCallBack.bind(this));
}
createSubscriberCallBack(err, data) {
- commonEventData = data;
- // 接收到订阅
- commonEvent.subscribe(commonEventData, this.subscriberCallBack.bind(this));
+ this.commonEventData = data;
+ // Received subscription
+ commonEvent.subscribe(this.commonEventData, this.subscriberCallBack.bind(this));
}
subscriberCallBack(err, data) {
- HiLog.i(TAG, 'subscriberCallBack, start');
- // 接收短信更新
+ HiLog.i(TAG, "subscriberCallBack, start");
+ // Receiving SMS Updates
setTimeout(() => {
- this.queryMessageDetail(this.strContactsNumber, this.threadId, () => {});
+ this.queryMessageDetail(this.strContactsNumber, this.threadId, () => {
+ });
let valueBucket = {
- 'unread_count': 0,
+ "unread_count": 0,
};
let actionData = {
threadIds: [this.threadId],
@@ -1911,56 +1945,58 @@ export default class ConversationController {
});
}, 500);
}
- // 取消订阅
+ // Unsubscribe
unSubscribeDetail() {
- commonEvent.unsubscribe(commonEventData, () => {
- HiLog.i(TAG, 'unSubscribeDetail, unsubscribe');
- });
+ if (this.commonEventData != null) {
+ commonEvent.unsubscribe(this.commonEventData, () => {
+ HiLog.i(TAG, "unSubscribeDetail, unsubscribe");
+ });
+ }
}
- // 在选择状态下,点击'更多'后弹出menu,然后选择
+ // In the selection mode, tap More. In the displayed menu, select
moreSelected(e) {
- HiLog.i(TAG, 'moreSelected, e: ' + JSON.stringify(e))
+ HiLog.i(TAG, "moreSelected, e: " + JSON.stringify(e))
switch (e) {
- case '0':
- // 复制
+ case "0":
+ // duplicating
this.copyText();
break;
case 1:
- // 分享
+ // Share
this.share();
break;
case 2:
- // 选择文本
+ // Select Text
this.gotoTextSelect(this.mmsIndex);
break;
case 3:
- // 锁定
+ // lock
this.lock();
break;
case 4:
- // 显示详情
+ // Show Details
this.showDetails();
break;
case 5:
- // 取消锁定
+ // Unlock
this.unlock();
break;
case 6:
- // 查看报告
+ // View Reports
this.showReport(this.mmsIndex);
break;
case 7:
- // 保存附件
+ // Save Attachments
this.saveImage();
break;
case 8:
- // 查询vCard详情
+ // Querying vCard Details
this.showVcarDetail(this.mmsIndex);
break;
default:
break;
}
- // 退出多选模式
+ // Exit the multi-selection mode.
this.exitMultiselect();
}
@@ -1974,7 +2010,7 @@ export default class ConversationController {
var actionData: LooseObject = {};
actionData.content = this.mmsList[i].content;
conversationService.gotoShare(actionData, function (data) {
- HiLog.i(TAG, 'share, gotoShare callback');
+ HiLog.i(TAG, "share, gotoShare callback");
});
}
}
@@ -1982,7 +2018,7 @@ export default class ConversationController {
gotoTextSelect(idx) {
router.push({
- uri: 'pages/text_select/text_select',
+ uri: "pages/text_select/text_select",
params: this.mmsList[idx]
})
}
@@ -1996,7 +2032,7 @@ export default class ConversationController {
}
updateLock(isLock) {
- // 选择内容锁定
+ // Select Content Lock
let groupIds = [];
for (let element of this.mmsList) {
if (element.isCbChecked) {
@@ -2013,15 +2049,15 @@ export default class ConversationController {
let that = this;
conversationService.updateLock(actionData, function (result) {
if (result.code == common.int.SUCCESS) {
- // 多选状态关闭
+ // Multi-Select Status Off
that.isSelectStatus = false;
that.cancleCheckedAll();
- HiLog.i(TAG, 'updateLock, Success');
+ HiLog.i(TAG, "updateLock, Success");
} else {
- HiLog.w(TAG, 'updateLock, failed');
+ HiLog.w(TAG, "updateLock, failed");
}
});
- // 更新锁定状态
+ // Update Lock Status
this.updateSessionLock(isLock);
}
@@ -2032,9 +2068,9 @@ export default class ConversationController {
var timeStash = this.getTime(time);
this.mmsTime = timeStash + this.mmsList[index].time;
if (this.mmsList[index].msgType == 0) {
- this.isMmsType = $r('app.string.sms');
+ this.isMmsType = $r("app.string.sms");
} else {
- this.isMmsType = $r('app.string.mms');
+ this.isMmsType = $r("app.string.mms");
}
if (this.mmsList[index].isReceive) {
@@ -2044,14 +2080,14 @@ export default class ConversationController {
}
}
}
- // this.$element('mms_details_dialog').show();
+ // this.$element("mms_details_dialog").show();
}
showReport(mmsIndex) {
- // 查看报告
+ // View Reports
let item = this.mmsList[mmsIndex];
router.push({
- uri: 'pages/query_report/query_report',
+ uri: "pages/queryreport/queryReport",
params: {
isMsm: item.isMsm,
telephone: this.strContactsNumber,
@@ -2075,7 +2111,7 @@ export default class ConversationController {
}
exitMultiselect() {
- // 退出多选状态
+ // Exit the multi-selection state.
this.isSelectStatus = false;
this.cancleCheckedAll();
}
@@ -2083,74 +2119,74 @@ export default class ConversationController {
longPressMore(e) {
switch (e) {
case 0:
- // 删除
+ // delete
this.deleteDetail();
break;
case 1:
- // 新建联系人
+ // New Contact
this.createNewContract(this.strContactsNumber);
break;
case 2:
- // 保存至已有联系人
+ // Save to Existing Contacts
this.existingContact(this.strContactsNumber);
break;
case 3:
- // 呼叫前编辑
+ // Edit Before Call
this.callEditor(this.strContactsNumber);
break;
case 4:
- // 加入黑名单
+ // Add to Blocklist
this.callEditor(this.strContactsNumber);
break;
case 5:
- // 查看联系人
+ // View Contacts
this.titleBarAvatar();
break;
default:
break;
}
}
- // 删除
+ // Delete
deleteDetail() {
if (this.mmsList.length == 1) {
- this.strMsgDeleteDialogTip = $r('app.string.msg_delete_dialog_tip3');
+ this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip3");
this.deleteDialog();
} else {
this.hasDetailDelete = false;
this.isSelectStatus = true;
}
}
- // 新建联系人
+ // New Contact
createNewContract(number) {
var actionData: LooseObject = {};
actionData.phoneNumber = number;
actionData.pageFlag = common.contractPage.PAGE_FLAG_SAVE_CONTACT;
this.jumpToContract(actionData);
}
- // 呼叫前编辑
+ // Edit Before Call
callEditor(number) {
var actionData: LooseObject = {};
actionData.phoneNumber = number;
actionData.pageFlag = common.contractPage.PAGE_FLAG_EDIT_BEFORE_CALLING;
this.jumpToContract(actionData);
}
- // 保存至已有联系人
+ // Save to Existing Contacts
existingContact(number) {
var actionData: LooseObject = {};
actionData.phoneNumber = number;
actionData.pageFlag = common.contractPage.PAGE_FLAG_SAVE_EXIST_CONTACT;
this.jumpToContract(actionData);
}
- // 跳转联系人app
+ // Switching to the Contacts app
jumpToContract(actionData) {
let str = commonService.commonContractParam(actionData);
- featureAbility.startAbility(str).then((data) => {
- HiLog.i(TAG, 'jumpToContract, startAbility Success');
+ globalThis.mmsContext.startAbility(str).then((data) => {
+ HiLog.i(TAG, "jumpToContract, startAbility Success");
}).catch((error) => {
- HiLog.e(TAG, 'jumpToContract, failed. Cause: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "jumpToContract, failed. Cause: " + JSON.stringify(error.message));
})
}
- // 点击联系人头像,跳转至联系人详情
+ // Tap a contact's avatar to go to the contact details page.
titleBarAvatar() {
var actionData = {
phoneNumber: this.strContactsNumber,
@@ -2164,19 +2200,16 @@ export default class ConversationController {
}
call(telephone) {
- // 打电话
- let param = {
- telephone: telephone
- };
- callService.call(param, result => {
+ // Calling
+ callService.call(telephone, result => {
if (result.code == common.int.SUCCESS) {
- HiLog.i(TAG, 'call, call success');
+ HiLog.i(TAG, "call success");
} else {
- HiLog.w(TAG, 'call, call failed');
+ HiLog.w(TAG, "call failed");
}
});
}
- // 判断字符串是否包含中文
+ // Check whether the character string contains Chinese characters.
checkChinese(str) {
return true;
}
@@ -2186,10 +2219,10 @@ export default class ConversationController {
var year = date.getFullYear();
var mon = date.getMonth() + 1;
var day = date.getDate();
- return year; // + $r('app.string.year') + mon + $r('app.string.month') + day + $r('app.string.day');
+ return year; // + $r("app.string.year") + mon + $r("app.string.month") + day + $r("app.string.day");
}
- // 新建页面,返回的联系人数据
+ // Contact data returned on the new page
setReceiveContactValue(receiverData) {
let selectContacts = receiverData.selectContacts;
let receiveContactValue = selectContacts.length > 0 ? common.string.EMPTY_STR : receiverData.contactValue;
@@ -2200,22 +2233,31 @@ export default class ConversationController {
let index = -1;
for (let i = 0; i < selectContacts.length; i++) {
let contact = selectContacts[i];
- if(contact.telephone == receiveContactValue) {
+ if (contact.telephone == receiveContactValue) {
index = i;
break;
}
}
- if(index >= 0) {
+ if (index >= 0) {
selectContacts.splice(index, 1);
}
}
- if(receiveContactValue != common.string.EMPTY_STR) {
+ if (receiveContactValue != common.string.EMPTY_STR) {
this.receiveContactValue = receiveContactValue;
} else {
this.receiveContactValue = common.string.EMPTY_STR;
}
if(selectContacts.length > 0) {
- this.selectContacts = selectContacts;
+ for (let item of selectContacts) {
+ if (!this.isPhoneNumber(item.telephone)) {
+ item.telephone = this.replaceCode(item.telephone);
+ item.telephoneFormat = this.replaceCode(item.telephoneFormat);
+ if (item.contactName != common.string.EMPTY_STR) {
+ item.contactName = common.string.EMPTY_STR;
+ }
+ }
+ this.selectContacts.push(item)
+ }
} else {
this.selectContacts = [];
}
@@ -2224,7 +2266,7 @@ export default class ConversationController {
telephone += element.telephone + common.string.COMMA;
}
}
- if(this.receiveContactValue != common.string.EMPTY_STR) {
+ if (this.receiveContactValue != common.string.EMPTY_STR) {
telephone += this.receiveContactValue + common.string.COMMA;
}
if (telephone != common.string.EMPTY_STR) {
diff --git a/entry/src/main/ets/pages/conversationlist/SearchResultPage.ets b/entry/src/main/ets/pages/conversationlist/SearchResultPage.ets
new file mode 100644
index 0000000..3679f6f
--- /dev/null
+++ b/entry/src/main/ets/pages/conversationlist/SearchResultPage.ets
@@ -0,0 +1,71 @@
+/**
+ * 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.
+ */
+@Component
+export struct SearchResultPage {
+ build() {
+ List() {
+ ListItem() { //Number of Searched Sessions
+ Text("找到2个会话").fontSize(10).fontColor(Color.Black).margin({ left: 24, top: 24 })
+
+ }
+
+ ListItem() { //Searched session item
+ SearchItem()
+ }
+
+ ListItem() { //Searched session item
+ SearchItem()
+ }
+
+ ListItem() { //Number of Searched Information
+ Text("找到2条信息").fontSize(10).fontColor(Color.Black).margin({ left: 24, top: 24 })
+ }
+
+ ListItem() { //Information item
+ SearchItem()
+ }
+
+ ListItem() { //Information item
+ SearchItem()
+ }
+ }
+
+ }
+}
+
+@Component
+struct SearchItem {
+ build() {
+ Column() {
+ Row() {
+ Image($rawfile("icon/user_avatar_full_fill.svg"))
+ .height(40)
+ .width(40)
+ Column() {
+ Row() {
+ Text("电话").fontSize(16).fontColor(Color.Black)
+ Blank()
+ Text("时间").fontSize(12).fontColor(Color.Gray)
+ }.width("100%")
+
+ Row() {
+ Text("内容").fontSize(14).fontColor(Color.Gray)
+
+ }.width("100%")
+ }.layoutWeight(1).margin({ left: 12 })
+ }.height(64).width("100%").padding({ left: 24, right: 24 })
+ }
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/pages/conversationlist/conversationList.ets b/entry/src/main/ets/pages/conversationlist/conversationList.ets
new file mode 100644
index 0000000..82480c6
--- /dev/null
+++ b/entry/src/main/ets/pages/conversationlist/conversationList.ets
@@ -0,0 +1,393 @@
+/**
+ * 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 router from "@system.router";
+import ConListController from "./conversationListController";
+import DeviceUtil from "../../utils/DeviceUtil";
+import HiLog from "../../utils/HiLog"
+import { DeleteDialog } from "../../views/MmsDialogs";
+import { MmsListItem } from "../../views/MmsListItem";
+import { MoreMenu } from "../../views/MmsMenu";
+
+const TAG = "ConversationList";
+
+@Component
+export default struct ConversationList {
+ @Link mConListCtrl: ConListController;
+ private dialogAlignment: DialogAlignment = DeviceUtil.isTablet() ? DialogAlignment.Center : DialogAlignment.Bottom;
+ private dialogOffset: Offset = DeviceUtil.isTablet() ? { dx: 0, dy: 0 } : { dx: 0, dy: -12 };
+ private dialogGridCount: number = 4;
+ delDialogController: CustomDialogController = null;
+
+ /**
+ * The function executes after a new instance of the custom component is created and before its build function
+ * is executed.
+ * You can change the state variable in the aboutToAppear function, and these changes will take effect in
+ * subsequent executions of the build function.
+ */
+ aboutToAppear() {
+ this.delDialogController = 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: this.dialogAlignment,
+ offset: this.dialogOffset,
+ gridCount: this.dialogGridCount
+ });
+
+ }
+
+ /**
+ * Function executes before custom component destructor consumption.
+ * Allow changes to state variables in the aboutToDisappear function, especially changes to the @Link variable,
+ * can cause erratic application behavior.
+ */
+ aboutToDisappear() {
+ }
+
+ build() {
+ Stack(){
+ Flex({
+ direction: FlexDirection.Column,
+ justifyContent: FlexAlign.Start,
+ alignItems: ItemAlign.Start
+ }) {
+ Column() {
+ // Menu Bar
+ 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(() => {
+ // The page for creating an SMS message is displayed.
+ router.push(
+ {
+ uri: "pages/conversation/conversation",
+ params: {
+ isNewMsg: true
+ }
+ })
+ })
+ Column() {
+ MoreMenu({
+ menuItems: [
+ {
+ value: $r("app.string.delete"),
+ action: () => {
+ this.mConListCtrl.showMultipleSelectView();
+ },
+ enabled: true
+ }, {
+ value: $r("app.string.markAllAsRead"),
+ action: () => {
+ this.mConListCtrl.clickToMarkAllAsRead();
+ },
+ enabled: this.mConListCtrl.unreadTotal == 0 ? false : true
+ }, {
+ value: $r("app.string.settings"),
+ action: () => {
+ this.mConListCtrl.jumpToSettingsPage();
+ },
+ enabled: true
+ }
+ ]
+ })
+ }
+ .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)
+ .margin({ left: 16 })
+ }
+ }
+ .width("100%")
+ .height($r("app.float.action_bar_height"))
+
+ // Title bar
+ Column() {
+ if (!this.mConListCtrl.isMultipleSelectState) {
+ Row() {
+ Text($r("app.string.messages"))
+ .fontSize($r("app.float.list_title_font_size_large"))
+ .fontColor($r("sys.color.ohos_id_color_foreground"))
+ .fontWeight(FontWeight.Bold)
+ .lineHeight(41)
+ }.margin({ top: 8 })
+
+ // Unread Message
+ Text($r("app.string.unread_messages", this.mConListCtrl.unreadTotal))
+ .fontSize($r("sys.float.ohos_id_text_size_over_line"))
+ .fontColor($r("sys.color.ohos_id_color_text_secondary"))
+ .fontWeight(FontWeight.Regular)
+ .margin({ top: 2 })
+ .visibility(this.mConListCtrl.unreadTotal == 0 ? Visibility.None : Visibility.Visible)
+ }
+ }
+ .height(this.mConListCtrl.unreadTotal == 0 ? 56 : $r("app.float.message_bar_height"))
+ .visibility(this.mConListCtrl.isMultipleSelectState
+ ? Visibility.None : Visibility.Visible)
+ }
+ .alignItems(HorizontalAlign.Start)
+ .flexShrink(0)
+
+ if (!(this.mConListCtrl.hasNoOrdinaryMsg && !(this.mConListCtrl.hasAggregate && this.mConListCtrl.hasInfoMsg
+ && this.mConListCtrl.isSearchStatus))) {
+ Column() {
+ //Search box
+ // @ts-ignore
+ Row() {
+ if (this.mConListCtrl.messageList.length != 0) {
+ Image($rawfile("icon/ic_message_search.svg"))
+ .width(17)
+ .height(18)
+ .fillColor($r("sys.color.ohos_id_color_activated"))
+ .margin({ left: 11.5 })
+
+ Text("搜索联系人")
+ .fontSize("16fp")
+ .fontColor($r("sys.color.ohos_id_color_text_secondary"))
+ .margin({ left: 7.5 })
+ }
+ }
+ .visibility(Visibility.None)
+ .height(40)
+ .width("100%")
+ .margin({ top: 8, bottom: 8 })
+ .borderWidth(1.5)
+ .borderRadius(20)
+ .borderColor("#33182431")
+
+ List() {
+ if (this.mConListCtrl.hasAggregate && this.mConListCtrl.hasInfoMsg
+ && this.mConListCtrl.isSearchStatus) {
+ ListItem() {
+ Column() {
+ Row() {
+ Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center }) {
+ if (this.mConListCtrl.unreadTotalOfInfo > 0) {
+ Text(this.mConListCtrl.unreadTotalOfInfo < 100 ?
+ this.mConListCtrl.unreadTotalOfInfo.toString() : "99+")
+ .fontSize(10)
+ .align(Alignment.Center)
+ .padding({ left: 5, right: 5 })
+ .height(20)
+ .backgroundColor($r("sys.color.ohos_id_color_badge_red"))
+ .fontColor($r("sys.color.ohos_id_color_background"))
+ .zIndex(2)
+ .position({ x: "60%", y: "8%" })
+ .border({
+ width: 2,
+ color: $r("sys.color.ohos_id_color_background"),
+ radius: 50
+ })
+ }
+ Image($rawfile("icon/entrance_icon01.svg"))
+ .width("40vp")
+ .height("40vp")
+ }.width("40vp").height("64vp")
+
+ Column() {
+ Row() {
+ Text($r("app.string.infoMessages"))
+ .fontSize('16fp')
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ .fontWeight(FontWeight.Medium)
+ Blank()
+ if (this.mConListCtrl.unreadTotalOfInfo > 0) {
+ Text(this.mConListCtrl.unreadTotalOfInfo + "")
+ .height("64vp")
+ .margin({
+ right: $r("app.float.settings_item_status_title_margin_right")
+ })
+ .fontSize($r("app.float.settings_item_secondary_title_font_size"))
+ .fontWeight(FontWeight.Regular)
+ .fontColor($r("sys.color.ohos_id_color_text_secondary"))
+ Image($rawfile("icon/ic_next.svg"))
+ .width($r("app.float.settings_item_next_image_width"))
+ .height($r("app.float.settings_item_next_image_height"))
+ }
+ }
+ .width("100%")
+ .height("100%")
+ .margin({ left: "4vp" })
+ }.layoutWeight(1)
+ .height("100%")
+ .padding({ left: "12vp" })
+ }.height("64vp")
+ .width("100%")
+ .onClick(() => {
+ this.mConListCtrl.clickToInfoMessages(this.mConListCtrl.hasAggregate,
+ this.mConListCtrl.hasInfoMsg,this.mConListCtrl.isSearchStatus)
+ })
+ }
+ }.opacity(this.mConListCtrl.isMultipleSelectState ? 0.4 : 1)
+ }
+
+ LazyForEach(this.mConListCtrl.conversationListDataSource, (item: any, index: number) => {
+ ListItem() {
+ MmsListItem({
+ item: item,
+ 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) => { //Read
+ this.mConListCtrl.markAllAsReadByIndex(item.index);
+ },
+ onClickSecondSlipBtn: (event: ClickEvent) => { //Delete
+ this.mConListCtrl.deleteAction(item.index);
+ this.delDialogController.open();
+ }
+ })
+ }.width("100%")
+ .height("64vp")
+ }, (item: any) => item.conversation.threadId.toString())
+ }
+ .edgeEffect(EdgeEffect.Spring)
+ .width("100%")
+ .align(Alignment.Top)
+ .divider({
+ strokeWidth: 1,
+ startMargin: this.mConListCtrl.isShowContactHeadIcon ? 52 : 12,
+ endMargin: 0
+ })
+ .flexShrink(1)
+
+ Blank()
+
+ /*Select All Delete button at the bottom*/
+ if (this.mConListCtrl.isMultipleSelectState) {
+ Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
+ Column() {
+ Image($rawfile("icon/ic_public_delete.svg")).height(24).width(24)
+ Text($r("app.string.delete")).fontSize(10).margin({ top: 3 }).lineHeight(13)
+ }
+ .width("50%")
+ .onClick(() => {
+ this.mConListCtrl.clickConversationDelete();
+ this.delDialogController.open();
+ })
+ .enabled(!(this.mConListCtrl.conversationSelectedNumber === 0))
+ .opacity(this.mConListCtrl.conversationSelectedNumber == 0 ? 0.5 : 1)
+ .alignItems(HorizontalAlign.Center)
+
+ Column() {
+ Image(this.mConListCtrl.isConversationCheckAll ?
+ $rawfile("icon/ic_select_all_filled.svg") : $rawfile("icon/ic_select_all.svg"))
+ .height(24).width(24)
+ Text(this.mConListCtrl.isConversationCheckAll ? $r("app.string.msg_deselect_all")
+ : $r("app.string.msg_select_all"))
+ .fontSize(10)
+ .margin({ top: 3 })
+ .lineHeight(13)
+ .fontColor(this.mConListCtrl.isConversationCheckAll ?
+ $r("sys.color.ohos_id_color_bottom_tab_text_on") :
+ $r("sys.color.ohos_id_color_bottom_tab_text_off"))
+ }
+ .width("50%")
+ .onClick(() => {
+ this.mConListCtrl.clickConversationCheckAll()
+ })
+ .alignItems(HorizontalAlign.Center)
+ }
+ .width("100%")
+ .height(56)
+ .padding({
+ left: $r("app.float.menu_layout_padding_left"),
+ right: $r("app.float.menu_layout_padding_right")
+ })
+ .flexBasis(56)
+ .flexShrink(0)
+ .backgroundColor($r("sys.color.ohos_id_color_background"))
+ }
+ }
+ .width("100%")
+ .height("100%")
+ }
+ }
+ .width("100%")
+ .height("100%")
+ if (this.mConListCtrl.hasNoOrdinaryMsg && !(this.mConListCtrl.hasAggregate && this.mConListCtrl.hasInfoMsg
+ && this.mConListCtrl.isSearchStatus)) {
+ EmptyView()
+ }
+ }
+ .width("100%")
+ .height("100%")
+ }
+}
+
+@Component
+struct EmptyView {
+
+ build() {
+ Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
+ Column() {
+ Image($rawfile("icon/ic_massage_m.svg"))
+ .width($r("app.float.empty_image_width"))
+ .height($r("app.float.empty_image_height"))
+ Text($r("app.string.noMessages"))
+ .margin({ top: $r("app.float.empty_text_top_margin") })
+ .fontWeight(FontWeight.Regular)
+ .fontFamily("HarmonyHeiTi")
+ .fontSize($r("app.float.conversation_list_no_message_fs"))
+ .fontColor($r("sys.color.ohos_id_color_text_tertiary"))
+ }
+ .margin({ top: '40%' })
+ .offset({ y: -60 })
+ }
+ .height("100%")
+ .width("100%")
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/pages/conversationlist/conversationListController.ets b/entry/src/main/ets/pages/conversationlist/conversationListController.ets
new file mode 100644
index 0000000..211ff60
--- /dev/null
+++ b/entry/src/main/ets/pages/conversationlist/conversationListController.ets
@@ -0,0 +1,936 @@
+// @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 common from "../../data/commonData"
+import router from "@system.router";
+import commonEvent from "@ohos.commonEvent";
+import DateUtil from "../../utils/DateUtil";
+import featureAbility from "@ohos.ability.featureAbility";
+import LooseObject from "../../data/LooseObject";
+import messageService from "../../service/ConversationListService";
+import HiLog from "../../utils/HiLog";
+import SettingService from "../../service/SettingService"
+import commonService from "../../service/CommonService";
+import NotificationService from "../../service/NotificationService";
+import ConversationListDataSource from "../../model/ConversationListDataSource"
+import AvatarColor from "../../model/common/AvatarColor"
+
+let ConversationCtrl;
+
+const TAG = "ConversationListController";
+
+export default class ConversationListController {
+ // Determine whether to perform initialization. (To avoid the onShow time sequence problem immediately after the
+ // index is started.)
+ isInited: boolean = false;
+
+ commonEventData: any = null;
+ svgDelete: string = '';
+ strCheckBoxSelectTip: Resource;
+ strMsgDeleteDialogTip: Resource = null;
+ // Total number of SMs
+ total: number = 0;
+ // Total number of notifications.
+ totalOfInfo: number = 0;
+ // Total number of unread messages.
+ unreadTotal: number = 0;
+ // Total number of unread notifications
+ unreadTotalOfInfo: number = 0;
+ // Number of selected sessions
+ conversationSelectedNumber: number = 0;
+ // Indicates whether the multi-select state is selected.
+ isMultipleSelectState: boolean = false;
+ // Indicates whether the session list is selected.
+ isConversationCheckAll: boolean = false;
+ // Value entered in the search box on the information list page
+ inputValueOfSearch: string = '';
+ inputValueOfSearchTemp: string = '';
+ // Mark as read is hidden in the row where the notification is located. When there is unread information,
+ // you can swipe left to view this icon.
+ markAllAsReadForInfo: boolean = false;
+ // Mark as read
+ showMarkAllAsRead: boolean = false;
+ // Delete. In each individual message line, swipe left on the screen.
+ showDelete: boolean = false;
+ // Indicates whether to lock. The default value is false. No.
+ hasLockMsg: boolean = false;
+ isSelectLockMsg: boolean = false;
+ // Dynamically setting the height of the deleted pop-up window
+ dialogHeight: string = '';
+ // Data in the notification message
+ messageListForInfo: Array = [];
+ // If the notification integration switch is turned on, the information is not a notification.
+ // If the notification integration switch is not turned on, the information is all data.
+ messageList: Array = [];
+ // List of search results
+ searchResultList: LooseObject = {
+ sessionList: [],
+ contentList: []
+ };
+ // Search Results Queue
+ searchResultListQueue: Array = [];
+ // Search Text Queue
+ searchTextQueue: Array = [];
+ // Queue start flag bit
+ queueFlag: boolean = false;
+ // Queue timer start flag bit
+ setTimeOutQueueFlag: boolean = false;
+ // Number of search results
+ countOfSearchResult: number = 0;
+ // Indicates whether to perform redirection to avoid repeated redirection.
+ isJumping: boolean = false;
+ // Indicates whether to enable the notification integration switch. This switch is in the Settings area.
+ hasAggregate: boolean = false;
+ // Display contact avatar
+ isShowContactHeadIcon: boolean = true;
+ // Indicates whether to display the search return button. By default, the button is not displayed.
+ isShowSearchBack: boolean = false;
+ isSearchFocusable: boolean = false;
+ // The transparent color of the mask is displayed during search.
+ isSearchCoverage: boolean = false;
+ // Display Query All Information
+ isSearchStatus: boolean = true;
+ // Whether to display session search
+ isSearchConversation: boolean = false;
+ // Show Spacer Lines
+ isSearchInterval: boolean = false;
+ // Display Single Information Search
+ isSearchSms: boolean = false;
+ // Show Search Status
+ showSearchStatus: Resource;
+ // Indicates whether to display the button for creating an SMS message.
+ isNewSms: boolean = true;
+ conversationName: string = '';
+ // Check whether a common message (non-notification message) exists.
+ hasNoOrdinaryMsg: boolean = false;
+ // Check whether notification information exists.
+ hasInfoMsg: boolean = true;
+ // Update the UI.
+ flushTranslate: boolean = true;
+ // Length of the operation button
+ operateBtnW: number = 145;
+ // Data index of the current touch
+ itemTouchedIdx: number = -1;
+ // Left margin of notification message
+ infoLeft: number = 0;
+ // List pagination, number of pages
+ page: number = 0;
+ // List pagination, quantity
+ limit: number = 0;
+ reg: string = /^[a-zA-Z]+$/;
+ // conversation list adapters
+ conversationListDataSource: ConversationListDataSource = new ConversationListDataSource();
+
+ static getInstance() {
+ if (ConversationCtrl == null) {
+ ConversationCtrl = new ConversationListController();
+ }
+ return ConversationCtrl;
+ }
+
+
+ onInit() {
+ HiLog.i(TAG, "onInit");
+ this.isInited = true;
+ this.svgDelete = "icon/ic_public_delete.svg";
+ this.strCheckBoxSelectTip = $r("app.string.msg_select_all");
+ this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip2", this.conversationSelectedNumber);
+ this.showSearchStatus = $r("app.string.noMessages");
+ }
+
+ onShow() {
+ HiLog.i(TAG, "onShow");
+ if (!this.isInited) {
+ HiLog.w(TAG, "is not init");
+ return;
+ }
+ this.subscribe();
+ this.isJumping = false;
+ this.getSettingFlagForConvListPage();
+ this.statisticalData();
+ if (globalThis.needToUpdate && this.page == 0) {
+ this.messageList = [];
+ this.requestItem();
+ }
+ }
+
+ onDestroy() {
+ HiLog.i(TAG, "onDestroy");
+ this.isInited = false;
+ }
+
+ onHide() {
+ HiLog.i(TAG, "onHide");
+ this.unSubscribe();
+ }
+
+ // Touch and hold a list to display the selection and deletion functions.
+ conversationLongPress(index) {
+ // Check whether the left slide button exists. If yes, the button cannot be clicked.
+ if (this.messageList[index].isDelShow) {
+ return;
+ }
+ // Touch and hold a list to display the selection and deletion functions.
+ HiLog.i(TAG, "conversationLongPress, index: " + index);
+ if (this.isMultipleSelectState) {
+ this.messageList[index].isCbChecked = !this.messageList[index].isCbChecked;
+ } else {
+ this.isMultipleSelectState = true;
+ this.messageList[index].isCbChecked = true;
+ }
+ this.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN);
+ }
+
+ setConversationCheckAll(selectType) {
+ // Check whether all items are selected.
+ if (!this.isMultipleSelectState) {
+ return;
+ }
+ if (selectType == common.int.CHECKBOX_SELECT_ALL) {
+ this.conversationSelectedNumber = this.messageList.length;
+ this.isConversationCheckAll = true;
+ } else if (selectType == common.int.CHECKBOX_SELECT_NONE) {
+ this.conversationSelectedNumber = common.int.MESSAGE_CODE_ZERO;
+ this.isConversationCheckAll = false;
+ } else {
+ // The default value is CHECKBOX_SELECT_UNKNOWN. Check whether there is any unselected item.
+ this.isConversationCheckAll = true;
+ this.conversationSelectedNumber = 0;
+ this.messageList.forEach((element, index, array) => {
+ if (element.isCbChecked) {
+ this.conversationSelectedNumber++;
+ } else if (this.isConversationCheckAll) {
+ this.isConversationCheckAll = false;
+ }
+ })
+ }
+ if (this.isConversationCheckAll) {
+ // Select All Status
+ this.strCheckBoxSelectTip = $r("app.string.msg_deselect_all");
+ } else {
+ // Non-Select All Status
+ this.strCheckBoxSelectTip = $r("app.string.msg_select_all");
+ }
+ }
+
+ backSearch() {
+ this.isShowSearchBack = false;
+ this.isSearchCoverage = false;
+ // this.$element("searchBox").focus({
+ // focus: false
+ // });
+ this.isSearchFocusable = false
+ this.inputValueOfSearch = common.string.EMPTY_STR;
+ this.isSearchStatus = true;
+ this.isNewSms = true;
+ this.searchResultList.sessionList = [];
+ this.searchResultList.contentList = [];
+ }
+
+ // Reset touch event, which is used to reset an item that has been moved by sliding left
+ // when other buttons are pressed.
+ resetTouch() {
+ if (this.itemTouchedIdx !== -1) {
+ let itemTouched = this.messageList[this.itemTouchedIdx];
+ if (itemTouched == undefined) {
+ return false;
+ }
+ if (itemTouched.isDelShow) {
+ itemTouched.isDelShow = false;
+ this.setListItemTransX(0);
+ return true;
+ }
+ } else if (this.showMarkAllAsRead) {
+ this.showMarkAllAsRead = false;
+ this.setInfoItemTransX(0);
+ return true;
+ }
+ return false;
+ }
+
+ // Touch event for information list
+ touchStart(event: GestureEvent, index: number) {
+ if (this.isMultipleSelectState) {
+ return;
+ }
+ if (this.showMarkAllAsRead) {
+ // If the last touch is a notification item, the notification item will be reset.
+ this.setInfoItemTransX(0);
+ setTimeout(() => {
+ this.showMarkAllAsRead = false;
+ }, 200);
+ } else {
+ // Check whether the current touch item is the same as that of a touch item.
+ // If not, reset the previous touch item.
+ if (this.itemTouchedIdx !== -1 && index !== this.itemTouchedIdx) {
+ let itemTouched = this.messageList[this.itemTouchedIdx];
+ if (itemTouched != undefined && itemTouched != null && itemTouched.isDelShow) {
+ this.setListItemTransX(0);
+ itemTouched.isDelShow = false;
+ }
+ }
+ }
+ this.itemTouchedIdx = index;
+ let item = this.messageList[this.itemTouchedIdx];
+ if (item.countOfUnread > 0) {
+ this.operateBtnW = common.int.OPERATE_UNREAD_WIDTH;
+ } else {
+ this.operateBtnW = common.int.OPERATE_DELETE_WIDTH;
+ }
+ }
+
+ touchMove(event: GestureEvent, index: number) {
+ if (this.isMultipleSelectState) {
+ return;
+ }
+ // offsetX indicates the offset. The value range is [-operateBtnW, 0].
+ let offsetX = event.offsetX;
+ // If the displacement is less than 2, there is no sliding.
+ if (Math.abs(offsetX) <= 2) {
+ return;
+ }
+ let item = this.messageList[this.itemTouchedIdx];
+ let transX = offsetX;
+ if (item.isDelShow) {
+ if (event.offsetX - this.operateBtnW <= 0) {
+ transX = event.offsetX - this.operateBtnW
+ } else {
+ // Slide right to close
+ transX = 0
+ }
+ } else {
+ if (event.offsetX + this.operateBtnW >= 0) {
+ transX = event.offsetX
+ } else {
+ // Slide left to maximum width
+ transX = 0 - this.operateBtnW;
+ }
+ }
+ this.setListItemTransX(transX);
+ }
+
+ touchEnd(event: GestureEvent, index: number) {
+ if (this.isMultipleSelectState) {
+ return;
+ }
+ // offsetX indicates the offset. The value range is [-operateBtnW, 0].
+ let offsetX = event.offsetX;
+ let item = this.messageList[this.itemTouchedIdx];
+ if (offsetX + (this.operateBtnW / 2) >= 0) {
+ this.setListItemTransX(0);
+ item.isDelShow = false;
+ } else {
+ this.setListItemTransX(0 - this.operateBtnW);
+ item.isDelShow = true;
+ }
+ }
+
+ setListItemTransX(transX) {
+ let item = this.messageList[this.itemTouchedIdx];
+ if (item) {
+ if (transX <= 0) {
+ item.itemLeft = transX;
+ } else {
+ item.itemLeft = 0;
+ }
+ }
+ // Used to refresh the interface.
+ this.flushTranslate = !this.flushTranslate;
+ }
+
+ setInfoItemTransX(disX) {
+ if (disX >= 0) {
+ this.infoLeft = -disX;
+ } else {
+ this.infoLeft = -this.operateBtnW - disX;
+ }
+ }
+
+ clickConversationCheckAll() {
+ // Select All/Deselect All
+ if (this.isConversationCheckAll) {
+ for (let element of this.messageList) {
+ element.isCbChecked = false;
+ }
+ this.setConversationCheckAll(common.int.CHECKBOX_SELECT_NONE);
+ } else {
+ // Not Select All --> Select All
+ for (let element of this.messageList) {
+ element.isCbChecked = true;
+ }
+ this.setConversationCheckAll(common.int.CHECKBOX_SELECT_ALL);
+ }
+ }
+
+ clickConversationDelete() {
+ // Button Delete
+ if (this.conversationSelectedNumber == common.int.MESSAGE_CODE_ZERO) {
+ return;
+ }
+ // Delete a record.
+ if (this.conversationSelectedNumber == common.int.MESSAGE_CODE_ONE) {
+ this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip1");
+ } else if (this.conversationSelectedNumber == this.messageList.length) {
+ // Delete All
+ this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip3");
+ } else {
+ // Delete multiple records.
+ this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip2", this.conversationSelectedNumber);
+ }
+ // Locked or not
+ this.hasLockMsg = this.judgehasLockMsg()
+ }
+
+ judgehasLockMsg() {
+ let hasLockMsg = false;
+ for (let element of this.messageList) {
+ if (element.isCbChecked && element.isLock) {
+ hasLockMsg = true;
+ break;
+ }
+ }
+ return hasLockMsg;
+ }
+
+ onBackPress() {
+ HiLog.i(TAG, "onBackPress");
+ // Key returned by the system. The value true indicates interception.
+ if (this.isMultipleSelectState) {
+ for (let element of this.messageList) {
+ element.isCbChecked = false;
+ }
+ this.isMultipleSelectState = false;
+ return true;
+ }
+ if (!this.isSearchStatus) {
+ this.backSearch();
+ return true;
+ }
+ return false;
+ }
+
+ deleteDialogConfirm() {
+ this.setDelShow();
+ let mmsList = [];
+ let threadIds = [];
+ let lockThreadIds = [];
+ for (let element of this.messageList) {
+ if (element.isCbChecked) {
+ if (element.isLock && !this.isSelectLockMsg) {
+ lockThreadIds.push(element.threadId);
+ mmsList.push(element);
+ } else {
+ threadIds.push(element.threadId);
+ }
+ } else {
+ mmsList.push(element);
+ }
+ }
+ // Set to non-multi-choice status
+ this.isMultipleSelectState = false;
+ this.isSelectLockMsg = false;
+ this.messageList = mmsList;
+ this.conversationListDataSource.refresh(this.messageList);
+ this.total = this.messageList.length;
+ this.hasNoOrdinaryMsg = this.total == 0 ? true : false;
+ this.deleteNotifyMessage(threadIds, lockThreadIds, () => {
+ this.deleteMessageByThreadIds(threadIds, lockThreadIds);
+ });
+ }
+
+ deleteNotifyMessage(threadIds, lockThreadIds, callback) {
+ let sessionIds = [];
+ if (threadIds.length > 0) {
+ sessionIds.push(threadIds);
+ }
+ if (lockThreadIds.length > 0) {
+ sessionIds.push(lockThreadIds);
+ }
+ this.cancelMessageNotify(sessionIds, callback);
+ }
+
+ deleteMessageByThreadIds(threadIds, lockThreadIds) {
+ let actionData: LooseObject = {};
+ if (threadIds.length > 0) {
+ actionData.threadIds = threadIds;
+ messageService.deleteMessageById(actionData);
+ }
+ if (lockThreadIds.length > 0) {
+ actionData.threadIds = lockThreadIds;
+ actionData.isMessageDetail = false;
+ messageService.dealMessageLockContent(actionData, res => {
+ actionData.hasLock = 0;
+ messageService.deleteMessageBySessionIdsAndLock(actionData);
+ });
+ }
+ }
+
+ deleteDialogCancel() {
+ // Cancel Ejection
+ if (this.isSelectLockMsg) {
+ this.isSelectLockMsg = false;
+ }
+ }
+
+ setDelShow() {
+ if (this.itemTouchedIdx >= 0) {
+ let item = this.messageList[this.itemTouchedIdx];
+ this.setListItemTransX(0);
+ item.isDelShow = false;
+ }
+ }
+
+ clickToMarkAllAsRead() {
+ // Mark unread as read. Here we deal with the values in the information list.
+ let threadIds = [];
+ for (let mms of this.messageList) {
+ if (mms.countOfUnread > common.int.MESSAGE_CODE_ZERO) {
+ threadIds.push(mms.threadId);
+ }
+ }
+
+ this.cancelMessageNotify(threadIds, () => {
+ // Marks the notification information as read.
+ let actionData = {
+ hasRead: 1,
+ smsType: 1,
+ }
+ messageService.markAllToRead(actionData);
+ this.unreadTotalOfInfo = 0;
+ this.unreadTotal = 0;
+ this.markAllAsRead(threadIds);
+ });
+ }
+
+ jumpToSettingsPage() {
+ router.push({
+ uri: "pages/settings/settings",
+ params: {
+ pageFlag: "settingsDetail",
+ }
+ });
+ }
+
+ subscribe() {
+ let events = [common.string.RECEIVE_TRANSMIT_EVENT]
+ let commonEventSubscribeInfo = {
+ events: events
+ };
+ commonEvent.createSubscriber(commonEventSubscribeInfo, this.createSubscriberCallBack.bind(this));
+
+ }
+
+ subscriberCallBack(err, data) {
+ this.page = 0;
+ this.messageList = [];
+ this.requestItem();
+ // Collecting Unread Information
+ this.statisticalData();
+ }
+
+ // Unsubscribe
+ unSubscribe() {
+ HiLog.i(TAG, "unSubscribe");
+ if (this.commonEventData != null) {
+ commonEvent.unsubscribe(this.commonEventData, () => {
+ HiLog.i(TAG, "unSubscribe, success");
+ });
+ }
+ }
+
+ createSubscriberCallBack(err, data) {
+ this.commonEventData = data;
+ // Received subscription
+ commonEvent.subscribe(this.commonEventData, this.subscriberCallBack.bind(this));
+ }
+
+ // statistical data
+ statisticalData() {
+ let actionData: LooseObject = {};
+ let that = this;
+ messageService.statisticalData(actionData, function (result) {
+ if (result.code == common.int.SUCCESS) {
+ // Total number of lists
+ that.unreadTotal = result.response.totalListCount;
+ // Unreading of notification messages
+ that.unreadTotalOfInfo = result.response.unreadTotalOfInfo;
+ } else {
+ HiLog.w(TAG, "statisticalData, failed");
+ }
+ });
+ }
+
+ // Obtains the switch value for integrating notification information and displaying contact avatars.
+ getSettingFlagForConvListPage() {
+ let that = this;
+ let result = SettingService.getSettingFlagForConvListPage();
+ if (result) {
+ that.hasAggregate = result.hasAggregate;
+ that.isShowContactHeadIcon = result.isShowContactHeadIcon;
+ }
+ }
+
+ // Obtaining List Data in Pagination Mode
+ requestItem() {
+ if (this.page === 0) {
+ this.page++;
+ this.queryAllMessages();
+ } else {
+ Hilog.i(TAG, "isLoading");
+ }
+ }
+
+ // The notification page is displayed.
+ clickToInfoMessages(hasAggregate, hasInfoMsg, isSearchStatus) {
+ if (this.resetTouch()) {
+ return;
+ }
+ if (this.isMultipleSelectState) {
+ return;
+ }
+ router.push({
+ uri: "pages/infomsg/InfoMsg"
+ })
+ }
+
+ // Tap the avatar to go to the contact details page or recipient list page.
+ clickToGroupDetail(index) {
+ if (this.isJumping) {
+ return;
+ }
+ this.isJumping = true;
+ // Determine whether to redirect to the contact details page or to the list page of multiple recipients.
+ var contactsNum = this.messageList[index].contactsNum;
+ var telephone = this.messageList[index].telephone;
+ if (contactsNum == common.int.MESSAGE_CODE_ONE) {
+ var actionData = {
+ phoneNumber: telephone,
+ pageFlag: common.contractPage.PAGE_FLAG_CONTACT_DETAILS
+ };
+ this.jumpToContract(actionData);
+ } else {
+ let threadId = this.messageList[index].threadId;
+ let contactsNum = this.messageList[index].contactsNum;
+ this.jumpToGroupDetail(threadId, contactsNum);
+ }
+ }
+
+ // Switching to the Contacts app
+ jumpToContract(actionData) {
+ let str = commonService.commonContractParam(actionData);
+ globalThis.mmsContext.startAbility(str).then((data) => {
+ HiLog.i(TAG, "jumpToContract, startAbility success");
+ }).catch((error) => {
+ HiLog.e(TAG, "jumpToContract, failed Cause: " + JSON.stringify(error.message));
+ })
+ this.isJumping = false;
+ }
+
+ // Go to the multi-faceted portrait list page.
+ jumpToGroupDetail(threadId, contactsNum) {
+ let actionData = {
+ uri: "pages/group_detail/group_detail",
+ params: {
+ threadId: threadId,
+ contactsNum: contactsNum
+ }
+ };
+ this.isJumping = false;
+ router.push(actionData);
+ }
+
+ setSelectLock() {
+ this.isSelectLockMsg = !this.isSelectLockMsg;
+ }
+
+ setSelectLockChange(e) {
+ // Delete the checkbox lockout event.
+ this.isSelectLockMsg = e.checked;
+ }
+
+
+ // Querying All Lists
+ queryAllMessages() {
+ HiLog.i(TAG, "queryAllMessages, start");
+ let that = this;
+ if (this.page == 1) {
+ this.limit = 50;
+ } else {
+ this.limit = 500;
+ }
+ let actionData: LooseObject = {};
+ // Whether notification information needs to be integrated
+ if (this.hasAggregate) {
+ // Only non-notification information is queried.
+ actionData.numberType = 0;
+ }
+ 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 = this.buildSessionList(result);
+ if (res.length != 0) {
+ this.messageList = this.messageList.concat(res);
+ this.conversationListDataSource.refresh(this.messageList);
+ }
+ this.total = result.total;
+ this.hasNoOrdinaryMsg = this.total == 0 ? true : false;
+ this.hasInfoMsg = result.hasInfoMsg;
+ if (this.messageList.length < this.total) {
+ this.page++;
+ setTimeout(() => {
+ this.queryAllMessages();
+ },this.page == 2 ? 200 : 1);
+ } else {
+ this.page = 0;
+ globalThis.needToUpdate = false;
+ }
+ }
+ });
+ }
+
+ buildSessionList(result) {
+ let res = [];
+ result.response.forEach(item => {
+ // Inherit selected items
+ this.messageList.some(oldItem => {
+ if (item.threadId === oldItem.threadId) {
+ item.isCbChecked = oldItem.isCbChecked;
+ return true;
+ }
+ });
+ let obj: LooseObject = {};
+ obj = item;
+ obj.isDelShow = false;
+ obj.itemLeft = 0;
+ obj.photoFirstName = common.string.EMPTY_STR;
+ if( obj.name !== common.string.EMPTY_STR && this.reg.test(obj.name.substring(0, 1))) {
+ obj.photoFirstName = obj.name.substring(0, 1).toUpperCase();
+ }
+ obj.portraitColor = AvatarColor.background.Color[Math.abs(parseInt(obj.threadId, 10)) % 6];
+ // Time Conversion
+ DateUtil.convertDateFormatForItem(item, false);
+ // Processes MMS content display.
+ this.dealMmsListContent(item);
+ res.push(obj);
+ });
+ return res;
+ }
+
+ dealMmsListContent(item) {
+ if (item.hasMms && item.hasAttachment) {
+ if (item.content == common.string.EMPTY_STR) {
+ item.content = $r("app.string.attachment_no_subject");
+ } else {
+ item.content = $r("app.string.attachment", item.content);
+ }
+ }
+ if (item.hasMms && !item.hasAttachment && item.content == common.string.EMPTY_STR) {
+ item.content = $r("app.string.no_subject");
+ }
+ }
+
+ // Mark all unread notifications as read.
+ clickToMarkAllAsReadForInfo() {
+ let actionData = {
+ hasRead: 1,
+ smsType: 1,
+ }
+ let threadIds = [];
+ for (let msg of this.messageList) {
+ msg.countOfUnread = common.int.MESSAGE_CODE_ZERO;
+ threadIds.push(msg.threadId);
+ }
+ this.cancelMessageNotify(threadIds, () => {
+ messageService.markAllToRead(actionData);
+ this.unreadTotalOfInfo = 0;
+ });
+ }
+
+ markAllAsRead(threadIds) {
+ let tempMsgList = this.messageList;
+ // Mark the information corresponding to threadIds as read.
+ let valueBucket = {
+ "unread_count": 0,
+ };
+ let actionData: LooseObject = {};
+ actionData.threadIds = threadIds;
+ actionData.valueBucket = valueBucket;
+ actionData.hasRead = 1;
+ // Update data marked read to 0
+ messageService.markAllAsRead(actionData);
+ for (let msg of tempMsgList) {
+ if (threadIds.indexOf(msg.threadId) > common.int.FAILURE) {
+ // Controls the display of unread icons in the list
+ msg.countOfUnread = common.int.MESSAGE_CODE_ZERO;
+ }
+ }
+ this.messageList = tempMsgList;
+ this.conversationListDataSource.refresh(this.messageList);
+ }
+
+ cancelMessageNotify(threadIds, callback) {
+ let actionData = {
+ threadIds: threadIds,
+ hasRead: 0
+ };
+ NotificationService.getInstance().cancelMessageNotify(actionData, res => {
+ callback();
+ });
+ }
+
+ // The SM details page is displayed.
+ clickInfoToConversation(index) {
+ if (this.resetTouch()) {
+ return;
+ }
+ // If multiple options are selected, the system responds to CheckBox.
+ if (this.isMultipleSelectState) {
+ this.messageList[index].isCbChecked = !this.messageList[index].isCbChecked;
+ this.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN);
+ return;
+ }
+ if (this.isJumping) {
+ return;
+ }
+ this.isJumping = true;
+ // If the contact has unread information, a message needs to be sent to the backend PA to mark all information
+ // of the contact as read.
+ if (this.messageList[index].countOfUnread > common.int.MESSAGE_CODE_ZERO) {
+ this.markAllAsReadByIndex(index);
+ }
+ this.jumpToConversationPage(this.messageList[index]);
+ }
+
+ // The session details page is displayed.
+ jumpToConversationPage(item) {
+ router.push({
+ uri: "pages/conversation/conversation",
+ params: {
+ strContactsNumber: item.telephone,
+ strContactsNumberFormat: item.telephoneFormat,
+ strContactsName: item.name,
+ contactsNum: item.contactsNum,
+ threadId: item.threadId,
+ isDraft: item.isDraft,
+ draftContent: item.content,
+ searchContent: this.inputValueOfSearch
+ }
+ });
+ }
+
+ markAllAsReadByIndex(index) {
+ let threadId = this.messageList[index].threadId;
+ let threadIds = [threadId];
+ this.cancelMessageNotify(threadIds, () => {
+ // Mark the information corresponding to the contact index as read.
+ this.markAllAsRead(threadIds);
+ this.setListItemTransX(0);
+ this.statisticalData();
+ });
+ }
+
+ deleteAction(idx) {
+ let element = this.messageList[idx];
+ this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip1");
+ element.isCbChecked = true;
+ this.hasLockMsg = this.judgehasLockMsg();
+ }
+
+ // 搜索
+ clickToSearch(inputContent) {
+ this.inputValueOfSearch = inputContent;
+ this.search(inputContent);
+ }
+
+ search(text) {
+ // 在信息列表页面搜索
+ let actionData: LooseObject = {}
+ actionData.inputValue = text
+ this.searchTextAsync(actionData);
+ }
+
+ searchTextAsync(actionData) {
+ messageService.searchMessageWithLike(actionData, result => {
+ if (result.code == common.int.SUCCESS) {
+ // 获取搜索返回的结果先做判空处理
+ if (this.inputValueOfSearch !== common.string.EMPTY_STR) {
+ this.dealSearchResult(result);
+ }
+ } else {
+ this.searchResultListEmpty();
+ }
+ });
+ }
+
+ searchResultListEmpty() {
+ this.searchResultList = {
+ contentList: [],
+ sessionList: []
+ }
+ this.isSearchStatus = true;
+ this.hasInfoMsg = true;
+ if (this.isShowSearchBack) {
+ this.isSearchCoverage = true;
+ } else {
+ this.isSearchCoverage = false;
+ }
+ }
+
+ dealSearchResult(result) {
+ this.searchResultList = {
+ contentList: [],
+ sessionList: []
+ }
+ this.hasInfoMsg = false;
+ this.isSearchStatus = false;
+ this.isSearchCoverage = false;
+ this.buildSearchResult(result);
+ if (this.inputValueOfSearch === result.search) {
+ this.searchResultList = result.resultMap;
+ }
+ }
+
+ buildSearchResult(result) {
+ if (result.resultMap.contentList) {
+ result.resultMap.contentList.forEach(content => {
+ content.timeMillisecond = parseInt(content.timeMillisecond);
+ DateUtil.convertDateFormatForItem(content, true);
+ if (content.isFavorite) {
+ content.name = $r("app.string.message_in_favorites");
+ }
+ });
+ }
+ if (result.resultMap.sessionList) {
+ result.resultMap.sessionList.forEach(session => {
+ session.timeMillisecond = parseInt(session.timeMillisecond);
+ DateUtil.convertDateFormatForItem(session, true);
+ });
+ }
+ }
+
+ checkHasCommonMessage() {
+ return this.messageList.length > 0;
+ }
+
+ showMultipleSelectView() {
+ this.resetTouch();
+ if (this.checkHasCommonMessage()) {
+ this.isMultipleSelectState = true;
+ this.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN)
+ }
+ }
+}
diff --git a/entry/src/main/ets/pages/index.ets b/entry/src/main/ets/pages/index.ets
new file mode 100644
index 0000000..6c01011
--- /dev/null
+++ b/entry/src/main/ets/pages/index.ets
@@ -0,0 +1,137 @@
+/**
+ * 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 mediaquery from '@ohos.mediaquery';
+import IndexController from "./indexController"
+import ConversationList from "./conversationlist/conversationList"
+import ConListController from "./conversationlist/conversationListController";
+import DeviceUtil from "../utils/DeviceUtil";
+import MmsPreferences from "../utils/MmsPreferences";
+import HiLog from "../utils/HiLog"
+
+const TAG = "Index";
+
+@Entry
+@Component
+struct Index {
+ @State mIndexCtrl: IndexController = IndexController.getInstance();
+ @State mConListCtrl: ConListController = ConListController.getInstance();
+ private gridColumns: GridRowColumnOption = { sm: 4, md: 8, lg: 12 };
+ private girdSpan: GridColColumnOption = { sm: 4, md: 8, lg: 12 };
+ private gridGutter: string = "24vp";
+ private gridMargin: string = "24vp";
+ private smListener: mediaquery.MediaQueryListener;
+ private mdListener: mediaquery.MediaQueryListener;
+ private lgListener: mediaquery.MediaQueryListener;
+
+ isBreakpointSM = (mediaQueryResult) => {
+ if (mediaQueryResult.matches) {
+ AppStorage.SetOrCreate('curBp', 'sm')
+ }
+ }
+ isBreakpointMD = (mediaQueryResult) => {
+ if (mediaQueryResult.matches) {
+ AppStorage.SetOrCreate('curBp', 'md')
+ }
+ }
+ isBreakpointLG = (mediaQueryResult) => {
+ if (mediaQueryResult.matches) {
+ AppStorage.SetOrCreate('curBp', 'lg')
+ }
+ }
+
+ /**
+ * The function executes after a new instance of the custom component is created and before its build function
+ * is executed.
+ * Allows state variables to be changed in the aboutToAppear function, and these changes will take effect in
+ * subsequent executions of the build function.
+ */
+ aboutToAppear() {
+ this.mIndexCtrl.onInit();
+ this.mConListCtrl.onInit();
+ this.smListener = mediaquery.matchMediaSync('(320vp {
+ this.mInfoMsgCtrl.delDialogShow = false;
+ this.mInfoMsgCtrl.deleteDialogCancel()
+ },
+ confirm: () => {
+ this.mInfoMsgCtrl.delDialogShow = false;
+ this.mInfoMsgCtrl.deleteDialogConfirm()
+ },
+ msg: this.mInfoMsgCtrl.strMsgDeleteDialogTip,
+ hasLockMsg: this.mInfoMsgCtrl.hasLockMsg,
+ setSelectLock: () => {
+ this.mInfoMsgCtrl.setSelectLock()
+ },
+ isSelectLockMsg: this.mInfoMsgCtrl.isSelectLockMsg,
+ setSelectLockChange: (isOn: boolean) => {
+ this.mInfoMsgCtrl.setSelectLockChange(isOn)
+ }
+ }),
+ autoCancel: false,
+ alignment: this.dialogAlignment,
+ offset: this.dialogOffset,
+ gridCount: this.dialogGridCount
+ })
+ private menuItems: Array = [
+ {
+ value: $r("app.string.delete"),
+ action: () => {
+ this.mInfoMsgCtrl.selectInMoreMenu(1);
+ },
+ enabled: true
+ }
+// ,
+// {
+// value: $r("app.string.blocked"),
+// action: () => {
+// this.mInfoMsgCtrl.selectInMoreMenu(2);
+// },
+// enabled: true
+// }
+ ];
+
+ /**
+ * The function executes after a new instance of the custom component is created and before its build function
+ * is executed.
+ * Allows state variables to be changed in the aboutToAppear function, and these changes will take effect in
+ * subsequent executions of the build function.
+ */
+ aboutToAppear() {
+ this.mInfoMsgCtrl.onInit()
+ }
+ /**
+ * Function executes before custom component destructor consumption.
+ * Allow changes to state variables in the aboutToDisappear function, especially changes to the @Link variable,
+ * can cause erratic application behavior.
+ */
+ aboutToDisappear() {
+ }
+ /**
+ * Triggers once when this page is displayed. In scenarios such as routing and application access to the
+ * foreground and background, only customized components modified by @Entry take effect.
+ */
+ onPageShow() {
+ this.mInfoMsgCtrl.onShow()
+ }
+ /**
+ * Triggers once when this page disappears. In scenarios such as routing and application access to the foreground
+ * and background, only customized components modified by @Entry take effect.
+ */
+ onPageHide() {
+ this.mInfoMsgCtrl.onHide()
+ }
+ /**
+ * Triggered when a user clicks the back button. Only the customized component modified by @Entry takes effect.
+ * If true is returned, the page processes the return logic and does not route the page
+ * 返If false is returned, the default return logic is used.
+ * If no value is returned, the value is treated as false.
+ */
+ onBackPress() {
+ // Key returned by the system. The value true indicates interception.
+ if (this.mInfoMsgCtrl.delDialogShow) {
+ this.delDialogController.close();
+ this.mInfoMsgCtrl.delDialogShow = false;
+ return true;
+ }
+ if (this.mInfoMsgCtrl.isMultipleSelectState) {
+ for (let element of this.mInfoMsgCtrl.messageList) {
+ element.isCbChecked = false;
+ }
+ this.mInfoMsgCtrl.isMultipleSelectState = false;
+ this.mInfoMsgCtrl.showToolBar = true;
+ return true;
+ }
+ return false;
+ }
+
+ build() {
+ GridRow({ columns: this.gridColumns, gutter: this.gridGutter }) {
+ GridCol({ span: this.girdSpan }) {
+ //Notification Information
+ Column() {
+ if (this.mInfoMsgCtrl.isMultipleSelectState) {
+ //Multi-Select Status Title
+ 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) {
+ //Header Row
+ 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")
+ }
+
+ Row() {
+ //Back button
+ if (this.mInfoMsgCtrl.isShowSearchBack) {
+ Image($rawfile("icon/ic_message_back.svg"))
+ .width(24)
+ .height(24)
+ .onClick((event: ClickEvent) => {
+ this.mInfoMsgCtrl.clickSearchBack();
+ })
+ }
+ //Search box
+ // @ts-ignore
+ Search({ value: this.mInfoMsgCtrl.inputValueOfSearch, placeholder: "搜索通知信息" })
+ .layoutWeight(1)
+ .height("40vp")
+ .border({ radius: "20vp" })
+ .enabled(!this.mInfoMsgCtrl.isMultipleSelectState)
+ .backgroundColor($r("sys.color.ohos_id_color_text_field_bg"))
+ .onChange((value: string) => {
+ this.mInfoMsgCtrl.clickToSearch(value);
+ })
+ .onSubmit((value: string) => {
+ this.mInfoMsgCtrl.clickToSearch(value);
+ })
+ }
+ .visibility(Visibility.None)
+ .width("100%")
+ .height("56vp")
+ .padding({ left: 24, right: 24 })
+ .alignItems(VerticalAlign.Center)
+
+ //SMS message display list
+ Stack({ alignContent: Alignment.Top }) {
+ Column() {
+ List({ initialIndex: 0 }) {
+ LazyForEach(this.mInfoMsgCtrl.conversationListDataSource, (item, index) => {
+ //A real list of information
+ if (this.mInfoMsgCtrl.isSearchStatus) {
+ ListItem() {
+ MmsListItem({
+ item: item,
+ 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();
+ this.mInfoMsgCtrl.delDialogShow = true;
+ }
+ })
+ }
+ .width("100%")
+ .height("64vp")
+ .alignSelf(ItemAlign.Start)
+ }
+ }, item => item.threadId)
+ }
+ .align(Alignment.Top)
+ .cachedCount(this.mInfoMsgCtrl.limit)
+ .divider({
+ strokeWidth: 1,
+ startMargin: this.mInfoMsgCtrl.isShowContactHeadIcon ? 52 : 12,
+ endMargin: 0
+ })
+ }.width("100%")
+ //Search Above
+ //SMS Search Session Item
+ //Left avatar
+ //Information on the right
+ //Name and date above
+ //Details of the information below
+ //intermediate spacing line
+ //Number of barcodes in the search information list
+ //Search Information List
+ //Left avatar
+ //Information on the right
+ //Name and date above
+ //Details of the information below
+ //If there is no session information, that is, {{total}} is 0, a blank image is displayed.
+ //Show Search Status
+ if (this.mInfoMsgCtrl.isSearchCoverage) {
+ //Display of layers for search
+ Flex()
+ .width("100%")
+ .height("100%")
+ .opacity(0.2)
+ .backgroundColor(Color.Gray)
+ .onTouch((event: TouchEvent) => {
+ if (event.type === TouchType.Down) {
+ this.mInfoMsgCtrl.searchCoverageClick()
+ }
+ })
+ }
+ }
+ .flexShrink(1)
+
+ Blank()
+
+ //Single session press and hold option
+ if (this.mInfoMsgCtrl.isMultipleSelectState) {
+ Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
+ //Delete
+ 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")
+ .fontWeight(FontWeight.Medium)
+ .fontFamily("HarmonyHeiTi")
+ .margin({ top: 3 })
+ }
+ .width("50%")
+ .opacity(this.mInfoMsgCtrl.checkSelectedNumberIsEmpty() ? 0.4 : 1)
+ .onClick(() => {
+ if (!this.mInfoMsgCtrl.checkSelectedNumberIsEmpty()) {
+ this.mInfoMsgCtrl.clickConversationDelete()
+ this.delDialogController.open()
+ this.mInfoMsgCtrl.delDialogShow = true;
+ }
+ })
+ //Select All
+ 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 ?
+ $r("sys.color.ohos_id_color_bottom_tab_text_on") :
+ $r("sys.color.ohos_id_color_bottom_tab_text_off"))
+ .fontWeight(FontWeight.Medium)
+ .fontFamily("HarmonyHeiTi")
+ .margin({ top: 3 })
+ }
+ .width("50%")
+ .onClick(() => {
+ this.mInfoMsgCtrl.clickConversationCheckAll()
+ })
+ }
+ .width("100%")
+ .height(56)
+ .padding({ left: $r("app.float.menu_layout_padding_left"),
+ right: $r("app.float.menu_layout_padding_right") })
+ .flexBasis(56)
+ .flexShrink(0)
+ }
+
+ //All read and more
+ if (!this.mInfoMsgCtrl.isMultipleSelectState && this.mInfoMsgCtrl.showToolBar) {
+ Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
+ //All read
+ 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()
+ })
+ //more
+ Flex({
+ direction: FlexDirection.Column,
+ justifyContent: FlexAlign.Center,
+ alignItems: ItemAlign.Center
+ }) {
+ MoreMenu({
+ menuItems: this.menuItems,
+ menuText: $r("app.string.more")
+ })
+ }
+ .width("50%")
+ }
+ .width("100%")
+ .height(56)
+ .padding({ left: $r("app.float.menu_layout_padding_left"),
+ right: $r("app.float.menu_layout_padding_right") })
+ .flexBasis(56)
+ .flexShrink(0)
+ }
+ //Setting the background of the navigation bar
+ //Delete pop-up dialog box
+ }
+ .width("100%")
+ .height("100%")
+ }
+ }
+ .margin({ left: this.gridMargin, right: this.gridMargin })
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/pages/info_msg/InfoMsgController.ets b/entry/src/main/ets/pages/infomsg/InfoMsgController.ets
similarity index 69%
rename from entry/src/main/ets/default/pages/info_msg/InfoMsgController.ets
rename to entry/src/main/ets/pages/infomsg/InfoMsgController.ets
index aad4bb1..18f6a7d 100644
--- a/entry/src/main/ets/default/pages/info_msg/InfoMsgController.ets
+++ b/entry/src/main/ets/pages/infomsg/InfoMsgController.ets
@@ -12,104 +12,104 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import appStorage from '../../utils/AppStorageUtil';
-import common from '../../data/commonData';
-import commonEvent from '@ohos.commonEvent';
-import commonService from '../../service/CommonService';
-import dateUtil from '../../utils/DateUtil';
-import featureAbility from '@ohos.ability.featureAbility';
-import LooseObject from '../../data/LooseObject'
-// 信息列表Service
-import messageService from '../../service/ConversationListService';
-// log工具类
-import HiLog from '../../utils/HiLog';
-import NotificationService from '../../service/NotificationService';
-// 通知信息
-import router from '@system.router';
-// 获取设置开关
-import settingService from '../../service/SettingService';
-import ConversationListDataSource from '../../model/ConversationListDataSource'
+import common from "../../data/commonData";
+import commonEvent from "@ohos.commonEvent";
+import commonService from "../../service/CommonService";
+import dateUtil from "../../utils/DateUtil";
+import featureAbility from "@ohos.ability.featureAbility";
+import LooseObject from "../../data/LooseObject"
+// Information List Service
+import messageService from "../../service/ConversationListService";
+// Log tool class
+import HiLog from "../../utils/HiLog";
+import MmsPreferences from "../../utils/MmsPreferences";
+import NotificationService from "../../service/NotificationService";
+// Notification Information
+import router from "@system.router";
+// Obtain the setting switch.
+import settingService from "../../service/SettingService";
+import ConversationListDataSource from "../../model/ConversationListDataSource"
-const TAG = 'InfoMsgController'
+const TAG = "InfoMsgController"
let sInfoMsgCtrl;
-let commonEventData = null;
-
export default class InfoMsgController {
- svgDelete: string = 'icon/ic_delete_m.svg'
+ delDialogShow: boolean = false;
+ commonEventData: any = null;
+ svgDelete: string = "icon/ic_public_delete.svg"
total: number = 0;
strCheckBoxSelectTip: Resource;
strMsgDeleteDialogTip: Resource;
- // 已经选中的会话条数
+ // Number of selected sessions
conversationSelectedNumber: number = 0;
- // 是否处于多选状态
+ // Indicates whether the multi-select state is selected.
isMultipleSelectState: boolean = false;
isSearchFocusable: boolean = false;
- // 否会话列表处于全选状态
+ // No The session list is selected.
isConversationCheckAll: boolean = false;
- // 信息列表页面搜索框输入的值
+ // Value entered in the search box on the information list page
inputValueOfSearch: string = '';
- // 是否锁定 默认false不锁定
+ // Indicates whether to lock. The default value is false. No.
hasLockMsg: boolean = false;
isSelectLockMsg: boolean = false;
- // 搜索结果列表
+ // List of search results
searchResultList: LooseObject = {
sessionList: [],
contentList: []
};
- // 搜索结果队列
+ // Search Results Queue
searchResultListQueue: Array = [];
- // 搜索文本队列
+ // Search Text Queue
searchTextQueue: Array = [];
- // 队列定时器启动标志位
+ // Queue timer start flag bit
setTimeOutQueueFlag: boolean = false;
- // 是否真正进行跳转,避免重复跳转
+ // Indicates whether to perform redirection to avoid repeated redirection.
isJumping: boolean = false;
- // 是否显示搜索返回按钮 默认不显示
+ // Indicates whether to display the search return button. By default, the button is not displayed.
isShowSearchBack: boolean = false;
- // 搜索的时候蒙层透明色展示
+ // The transparent color of the mask is displayed during search.
isSearchCoverage: boolean = false;
- // 是否展示查询全部信息
+ // Display Query All Information
isSearchStatus: boolean = true;
- // 是否展示会话搜索
+ // Whether to display session search
isSearchConversation: boolean = false;
- // 是否展示间隔线
+ // Show Spacer Lines
isSearchInterval: boolean = false;
- // 是否展示单个信息搜索
+ // Display Single Information Search
isSearchSms: boolean = false;
- // 搜索为空的时候展示短信
+ // Display SMS messages when the search result is empty.
isSearchNull: boolean = false;
- // 队列启动标志位
+ // Queue start flag bit
queueFlag: boolean = false;
- // 显示搜索状态*/
+ // Show Search Status
showSearchStatus: string = '';
conversationName: string = '';
- // 未读的通知信息的条数
+ // Number of unread notifications.
unreadTotalOfInfo: number = 0;
messageList: Array = [];
numberType: number = 1;
- // 是否显示联系人头像
+ // Indicates whether to display the contact profile picture.
isShowContactHeadIcon: boolean = true;
- // 搜索结果的个数
+ // Number of search results
countOfSearchResult: number = 0;
- // 是否显示导航栏
+ // Display Navigation Bar
isNavigationBar: boolean = false;
- // 搜索状态,点击搜索框时进入搜索状态
+ // Search status. Click the search box to enter the search status.
searchStatus: boolean = false;
- // 是否显示toolbar,搜索状态时不显示
+ // Indicates whether to display the toolbar. The toolbar is not displayed in the search state.
showToolBar: boolean = true;
- // 变化刷新UI
+ // Update the UI.
flushTranslate: boolean = true;
- // 操作按钮的长度
+ // Length of the operation button
operateBtnW: number = 145;
- // 当前触摸的数据索引
+ // Data index of the current touch
itemTouchedIdx: number = -1;
- // 列表分页,数量
+ // List pagination, quantity
limit: number = 1000;
- // 列表分页,页数
+ // List pagination, number of pages
page: number = 0;
- // 信息总数
+ // Total number of messages
totalMessage: number = 0;
// notification conversation list adapters
conversationListDataSource: ConversationListDataSource = new ConversationListDataSource();
@@ -117,25 +117,31 @@ export default class InfoMsgController {
static getInstance() {
if (sInfoMsgCtrl == null) {
sInfoMsgCtrl = new InfoMsgController();
- appStorage.setAndLink('InfoMsgController', sInfoMsgCtrl);
+ AppStorage.SetAndLink("InfoMsgController", sInfoMsgCtrl);
}
return sInfoMsgCtrl;
}
+
onInit() {
+ HiLog.i(TAG, "onInit");
this.strCheckBoxSelectTip = $r("app.string.msg_select_all");
this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip2", this.conversationSelectedNumber);
}
+
onShow() {
+ HiLog.i(TAG, "onShow");
this.isJumping = false;
this.getSettingFlagForConvListPage();
this.page = 0;
this.requestItem();
this.subscribeInfo();
}
+
onHide() {
+ HiLog.i(TAG, "onHide");
this.unsubscribeInfo();
}
- // 查询列表数据
+ // Querying List Data
queryAllMessages() {
let actionData: LooseObject = {
page: this.page,
@@ -144,7 +150,7 @@ export default class InfoMsgController {
actionData.numberType = this.numberType;
messageService.querySessionList(actionData, result => {
if (result.code == common.int.SUCCESS) {
- HiLog.i(TAG, 'queryAllMessages, Success');
+ HiLog.i(TAG, "queryAllMessages, Success");
let res = this.buildSessionList(result);
this.messageList = res;
this.conversationListDataSource.refresh(this.messageList);
@@ -154,25 +160,34 @@ export default class InfoMsgController {
this.countUnread();
}
} else {
- HiLog.w(TAG,'queryAllMessages, failed');
+ HiLog.w(TAG, "queryAllMessages, failed");
}
});
}
+
dealMmsListContent(element) {
if (element.hasMms && element.hasAttachment) {
if (element.content == common.string.EMPTY_STR) {
- element.content = $r('app.string.attachment_no_subject');
+ element.content = $r("app.string.attachment_no_subject");
} else {
- element.content = $r('app.string.attachment', element.content);
+ element.content = $r("app.string.attachment", element.content);
}
}
if (element.hasMms && !element.hasAttachment && element.content == common.string.EMPTY_STR) {
- element.content = $r('app.string.no_subject');
+ element.content = $r("app.string.no_subject");
}
}
+
buildSessionList(result) {
let res = [];
result.response.forEach(item => {
+ // Inherit selected items
+ this.messageList.some(oldItem => {
+ if (item.threadId === oldItem.threadId) {
+ item.isCbChecked = oldItem.isCbChecked;
+ return true;
+ }
+ });
let obj: LooseObject = {};
obj = item;
obj.itemLeft = 0;
@@ -183,33 +198,36 @@ export default class InfoMsgController {
});
return res;
}
+
requestItem() {
let count = this.page * this.limit;
if (this.page === 0) {
this.page++;
this.queryAllMessages();
} else if (count < this.totalMessage && this.messageList.length > (this.page - 1) * this.limit) {
- // 对messageList的限制,是防止初始化时多次刷新请求
+ // The restriction on messageList is to prevent multiple requests from being refreshed during initialization
this.page++;
this.queryAllMessages();
}
}
- // 返回信息列表页面
+ // Return to the information list page.
back() {
router.back();
}
- // 点击屏幕下方的更多
+ // Tap More at the bottom of the screen
clickMore() {
-// this.$element('moreDialog').show();
+ // this.$element("moreDialog").show();
}
- // 删除通知信息中的单条信息
+ // Delete a single piece of information from a notification.
clickToDelete() {
}
+
clickSearchBack() {
- // 点击搜索返回按钮后
+ // Click the search return button.
this.backSearch();
}
+
backSearch() {
this.isShowSearchBack = false;
this.isSearchCoverage = false;
@@ -220,22 +238,23 @@ export default class InfoMsgController {
this.searchStatus = false;
this.showToolBar = true;
}
- // 搜索
+ // Search
clickToSearch(text) {
this.inputValueOfSearch = text;
this.search(text);
}
- // 在通知信息页面搜索
+ // Search on the notification information page.
search(text) {
let actionData: LooseObject = {};
actionData.inputValue = text
this.searchTextAsync(actionData)
}
+
searchTextAsync(actionData) {
actionData.numberType = this.numberType;
messageService.searchMessageWithLike(actionData, result => {
if (result.code == common.int.SUCCESS) {
- // 获取搜索返回的结果先做判空处理
+ // Check whether the search result is empty before obtaining the search result.
if (this.inputValueOfSearch !== common.string.EMPTY_STR) {
this.dealSearchResult(result);
}
@@ -244,6 +263,7 @@ export default class InfoMsgController {
}
});
}
+
dealSearchResult(result) {
this.searchResultList = {
contentList: [],
@@ -256,6 +276,7 @@ export default class InfoMsgController {
this.searchResultList = result.resultMap;
}
}
+
dealSearchResultTimeAndName(result) {
if (result.resultMap.sessionList) {
result.resultMap.sessionList.forEach(session => {
@@ -267,18 +288,19 @@ export default class InfoMsgController {
result.resultMap.contentList.forEach(content => {
content.timeMillisecond = parseInt(content.timeMillisecond);
dateUtil.convertDateFormatForItem(content, true);
- if(content.isFavorite) {
- content.name = $r('app.string.message_in_favorites');
+ if (content.isFavorite) {
+ content.name = $r("app.string.message_in_favorites");
}
});
}
}
+
searchResultListEmpty() {
this.searchResultList = {
contentList: [],
sessionList: []
}
- // 显示信息列表
+ // Display Information List
this.isSearchStatus = true;
if (this.isShowSearchBack) {
this.isSearchCoverage = true;
@@ -286,37 +308,38 @@ export default class InfoMsgController {
this.isSearchCoverage = false;
}
}
- // 判断是否是多选状态
+ // Check whether the multi-choice status is selected.
searchTouchStart() {
if (this.isMultipleSelectState) {
return false;
}
this.searchStatus = true;
this.showToolBar = false;
- // 搜索区域touchStart监控x > 125 && x < 600) && (y < 70 && y > 20
-// var x = event.touches[0].x;
-// if (isSearchType && x > 80 && x < 560) {
- // 是否显示新建按钮
- this.isShowSearchBack = true;
- // 蒙层展示
- this.isSearchCoverage = true;
- // 拉起输入法
- setTimeout(() => {
- this.isSearchFocusable = true;
- }, common.int.MESSAGE_CODE_THREE_ZERO_ZERO);
-// }
+ // Search area touchStart monitoring
+ // x > 125 && x < 600) && (y < 70 && y > 20
+ // var x = event.touches[0].x;
+ // if (isSearchType && x > 80 && x < 560) {
+ // Show New Button
+ this.isShowSearchBack = true;
+ // Mask Display
+ this.isSearchCoverage = true;
+ // Start the input method.
+ setTimeout(() => {
+ this.isSearchFocusable = true;
+ }, common.int.MESSAGE_CODE_THREE_ZERO_ZERO);
+ // }
this.resetTouch();
return false;
}
- // 长按单个列表,展示全选和删除
+ // Touch and hold a list to display the selection and deletion functions.
conversationLongPress(index) {
- // 是否有左滑删除按钮存在,存在则不可点击
+ // Check whether the left slide button exists. If yes, the button cannot be clicked.
if (this.itemTouchedIdx >= 0 && this.messageList[this.itemTouchedIdx].isDelShow) {
return;
}
- // 长按单个列表,展示全选和删除
+ // Touch and hold a list to display the selection and deletion functions.
this.showToolBar = false;
- HiLog.i(TAG, 'conversationLongPress, index: ' + index);
+ HiLog.i(TAG, "conversationLongPress, index: " + index);
if (this.isMultipleSelectState) {
this.messageList[index].isCbChecked = !this.messageList[index].isCbChecked;
} else {
@@ -325,7 +348,7 @@ export default class InfoMsgController {
}
this.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN);
}
- // 检查是否全选
+ // Check whether all items are selected.
setConversationCheckAll(type) {
if (!this.isMultipleSelectState) {
return;
@@ -337,7 +360,7 @@ export default class InfoMsgController {
this.conversationSelectedNumber = this.messageList.length;
this.isConversationCheckAll = true;
} else {
- // 默认为 CHECKBOX_SELECT_UNKNOWN,判断是否有未选中
+ // The default value is CHECKBOX_SELECT_UNKNOWN. Check whether there is any unselected item.
this.isConversationCheckAll = true;
this.conversationSelectedNumber = common.int.MESSAGE_CODE_ZERO;
this.messageList.forEach((item, index, array) => {
@@ -349,19 +372,19 @@ export default class InfoMsgController {
});
}
if (!this.isConversationCheckAll) {
- // 非全选状态
- this.strCheckBoxSelectTip = $r('app.string.msg_select_all');
+ // Non-Select All Status
+ this.strCheckBoxSelectTip = $r("app.string.msg_select_all");
} else {
- // 全选状态
- this.strCheckBoxSelectTip = $r('app.string.msg_deselect_all');
+ // Select All Status
+ this.strCheckBoxSelectTip = $r("app.string.msg_deselect_all");
}
}
- // 跳转至短信详情页面
+ // The SM details page is displayed.
clickInfoToConversation(index) {
if (this.resetTouch()) {
return;
}
- // 如果处于多选状态,响应CheckBox
+ // If multiple options are selected, the system responds to CheckBox.
if (this.isMultipleSelectState) {
this.messageList[index].isCbChecked = !this.messageList[index].isCbChecked;
this.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN);
@@ -371,16 +394,17 @@ export default class InfoMsgController {
return;
}
this.isJumping = true;
- // 如果该联系人下有未读的信息,还需要向后端PA发送消息,使该联系人的所有信息标记为已读
+ // If the contact has unread information, a message needs to be sent to the backend PA to mark all information
+ // of the contact as read.
if (this.messageList[index].countOfUnread > common.int.MESSAGE_CODE_ZERO) {
this.markAllAsReadByIndex(index);
}
this.jumpToConversationPage(this.messageList[index]);
}
- // 跳转至会话详情页面
- jumpToConversationPage(item){
+ // The session details page is displayed.
+ jumpToConversationPage(item) {
router.push({
- uri: 'pages/conversation/conversation',
+ uri: "pages/conversation/conversation",
params: {
strContactsNumber: item.telephone,
strContactsNumberFormat: item.telephoneFormat,
@@ -393,22 +417,23 @@ export default class InfoMsgController {
}
});
}
- // 搜索会话头像点击
+ // Searching for a session avatar
searchConversationHeadClick(index) {
this.headClickedListener(this.searchResultList.sessionList[index]);
}
+
headClickedListener(item) {
- // 点击头像跳转至联系人详情页面或收件人列表页面
+ // Tap the avatar to go to the contact details page or recipient list page.
if (this.isJumping) {
return;
}
- if(item.isFavorite != null && item.isFavorite) {
+ if (item.isFavorite != null && item.isFavorite) {
return;
}
var telephone = item.telephone;
var contactsNum = item.contactsNum;
this.isJumping = true;
- if(contactsNum == common.int.MESSAGE_CODE_ONE) {
+ if (contactsNum == common.int.MESSAGE_CODE_ONE) {
var actionData: LooseObject = {};
actionData.phoneNumber = telephone;
actionData.pageFlag = common.contractPage.PAGE_FLAG_CONTACT_DETAILS;
@@ -419,26 +444,27 @@ export default class InfoMsgController {
this.jumpToGroupDetail(threadId, contactsNum);
}
}
- // 跳转多人头像列表页面
+ // Go to the multi-faceted portrait list page.
jumpToGroupDetail(threadId, contactsNum) {
let actionData = {
- uri: 'pages/group_detail/group_detail',
+ uri: "pages/group_detail/group_detail",
params: {
threadId: threadId,
contactsNum: contactsNum
}
};
+ this.isJumping = false;
router.push(actionData);
}
- // 跳转到会话详情
+ // Go to session details.
searchConversationClick(index) {
this.searchMmsClicked(this.searchResultList.sessionList[index]);
}
- // 跳转到短信详情
+ // Go to SMS details.
searchMmsClicked(item) {
- if(item.isFavorite) {
+ if (item.isFavorite) {
router.push({
- uri: 'pages/my_star/my_star',
+ uri: "pages/my_star/my_star",
params: {
searchContent: this.inputValueOfSearch
}
@@ -447,33 +473,33 @@ export default class InfoMsgController {
this.jumpToConversationPage(item);
}
}
- // 单条信息头像点击跳转 判断跳转到联系人详情还是跳转到多个收件人的列表页面
+ // Clicking a profile picture to jump to the contact details page or the list page of multiple recipients
searchSmsHeadClick(index) {
this.headClickedListener(this.searchResultList.contentList[index]);
}
- // 点击跳转到会话详情页面
+ // The session details page is displayed.
searchSmsClick(index) {
this.searchMmsClicked(this.searchResultList.contentList[index]);
}
- // 手指滑动蒙层退出搜索模式
+ // Slide your finger to exit the search mode.
searchCoverageClick() {
this.backSearch();
}
- // 统计未读个数
+ // Counting the number of unread messages
countUnread() {
- let actionData: LooseObject = {
- };
+ let actionData: LooseObject = {};
+ let that = this;
messageService.statisticalData(actionData, function (result) {
if (result.code == common.int.SUCCESS) {
- HiLog.i(TAG, 'countUnread, statisticalData Success');
- // 通知信息的未读数
- this.unreadTotalOfInfo = result.response.unreadTotalOfInfo;
+ // Unreading of notification messages
+ that.unreadTotalOfInfo = result.response.unreadTotalOfInfo;
+ HiLog.i(TAG, "countUnread = " + that.unreadTotalOfInfo);
} else {
- HiLog.w(TAG, 'countUnread, statisticalData failed');
+ HiLog.w(TAG, "countUnread, statisticalData failed");
}
});
}
- // 把通知信息中未读的都标记为已读
+ // Mark all unread notifications as read.
clickToMarkAllAsReadForInfo() {
let actionData = {
hasRead: 1,
@@ -489,17 +515,19 @@ export default class InfoMsgController {
this.unreadTotalOfInfo = 0;
});
}
+
markAllAsReadByIndex(index) {
let item = this.messageList[index];
let threadId = item.threadId;
let threadIds = [threadId];
this.cancelMessageInfoNotify(threadIds, () => {
- // 把联系人(参数类型为数组)的所有信息标记为已读
+ // Marks all information about a contact (argument type: array) as read.
this.markAllAsRead(threadIds);
this.setListItemTransX(0);
item.isDelShow = false;
});
}
+
cancelMessageInfoNotify(threadIds, callback) {
let actionData = {
threadIds: threadIds,
@@ -509,21 +537,22 @@ export default class InfoMsgController {
callback();
});
}
+
markAllAsRead(threadIds) {
let tempMsgList = this.messageList;
- // 把联系人(参数类型为数组)的所有信息标记为已读
+ // Marks all information about a contact (argument type: array) as read.
let valueBucket = {
- 'unread_count': 0,
+ "unread_count": 0,
};
let actionData: LooseObject = {};
actionData.threadIds = threadIds;
actionData.valueBucket = valueBucket;
actionData.hasRead = 1;
- // 将标记已读的数据更新为0
+ // Update data marked read to 0
messageService.markAllAsRead(actionData);
for (let msg of tempMsgList) {
- if(threadIds.indexOf(msg.threadId) > common.int.FAILURE) {
- // 控制列表的未读图标的显示
+ if (threadIds.indexOf(msg.threadId) > common.int.FAILURE) {
+ // Controls the display of unread icons in the list
msg.countOfUnread = common.int.MESSAGE_CODE_ZERO;
}
}
@@ -531,17 +560,18 @@ export default class InfoMsgController {
this.conversationListDataSource.refresh(this.messageList);
this.unreadTotalOfInfo = this.unreadTotalOfInfo - threadIds.length;
}
+
selectInMoreMenu(menuId: number) {
if (menuId == 1) {
- // 删除
+ // Delete
this.isMultipleSelectState = true;
this.showToolBar = false;
this.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN);
} else {
- // 跳转至骚扰拦截页面,该页面在'手机管家'app里
+ // The harassment blocking page is displayed, which is in the Phone Manager app.
}
}
- // 按钮删除
+ // Button Delete
clickConversationDelete() {
if (this.conversationSelectedNumber == common.int.MESSAGE_CODE_ZERO) {
return;
@@ -550,33 +580,35 @@ export default class InfoMsgController {
this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip1");
} else if (this.conversationSelectedNumber == this.messageList.length) {
this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip3");
- appStorage.setHasInfoMsg(false);
} else {
this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip2", this.conversationSelectedNumber);
}
this.hasLockMsg = (this.messageList.some((element, index) => element.isCbChecked && element.isLock));
}
+
checkSelectedNumberIsEmpty() {
return this.conversationSelectedNumber == common.int.MESSAGE_CODE_ZERO
}
- // 取消弹出
+ // Cancel Ejection
deleteDialogCancel() {
if (this.isSelectLockMsg) {
this.isSelectLockMsg = false;
}
}
+
setSelectLock() {
this.isSelectLockMsg = !this.isSelectLockMsg;
}
- // 删除锁定CheckBox勾选事件
+ // Delete the checkbox lockout event.
setSelectLockChange(event) {
this.isSelectLockMsg = event.checked;
}
+
deleteDialogConfirm() {
+ this.setDelShow();
let mmsList = [];
let threadIds = [];
let lockSessionIds = [];
- let actionData: LooseObject = {};
for (let item of this.messageList) {
if (item.isCbChecked) {
if (item.isLock && !this.isSelectLockMsg) {
@@ -598,16 +630,20 @@ export default class InfoMsgController {
if (this.total == 0) {
router.back();
}
- this.deleteNotifyMessageInfo(threadIds, lockSessionIds, actionData, () => {
- this.deleteMessageInfoByThreadIds(threadIds, lockSessionIds, actionData);
+ this.deleteNotifyMessageInfo(threadIds, lockSessionIds, () => {
+ this.deleteMessageInfoByThreadIds(threadIds, lockSessionIds);
});
+ }
+
+ setDelShow() {
if (this.itemTouchedIdx >= 0) {
let item = this.messageList[this.itemTouchedIdx];
this.setListItemTransX(0);
item.isDelShow = false;
}
- }
- deleteNotifyMessageInfo(threadIds, lockSessionIds, actionData, callback) {
+ };
+
+ deleteNotifyMessageInfo(threadIds, lockSessionIds, callback) {
let sessionIds = [];
if (lockSessionIds.length > 0) {
sessionIds.push(lockSessionIds);
@@ -615,11 +651,11 @@ export default class InfoMsgController {
if (threadIds.length > 0) {
sessionIds.push(threadIds);
}
- actionData.hasRead = 0;
- actionData.threadIds = sessionIds;
- this.cancelMessageInfoNotify(actionData, callback);
+ this.cancelMessageInfoNotify(sessionIds, callback);
}
- deleteMessageInfoByThreadIds(threadIds, lockSessionIds, actionData) {
+
+ deleteMessageInfoByThreadIds(threadIds, lockSessionIds) {
+ let actionData: LooseObject = {};
if (threadIds.length > 0) {
actionData.threadIds = threadIds;
messageService.deleteMessageById(actionData);
@@ -632,24 +668,25 @@ export default class InfoMsgController {
});
}
}
- // 全选/取消全选
+ // Select All/Deselect All
clickConversationCheckAll() {
if (this.isConversationCheckAll) {
- // 全选-->取消全选
+ // Select All --> Deselect All
for (let item of this.messageList) {
item.isCbChecked = false;
}
this.setConversationCheckAll(common.int.CHECKBOX_SELECT_NONE);
} else {
- // 非全选-->全选
+ // Not Select All --> Select All
for (let item of this.messageList) {
item.isCbChecked = true;
}
this.setConversationCheckAll(common.int.CHECKBOX_SELECT_ALL);
}
}
+
onBackPress() {
- // 系统返回键,true代表拦截
+ // Key returned by the system. The value true indicates interception.
if (this.isMultipleSelectState) {
for (let element of this.messageList) {
element.isCbChecked = false;
@@ -660,13 +697,13 @@ export default class InfoMsgController {
}
return false;
}
- // 点击头像跳转至联系人详情页面或收件人列表页面
+ // Tap the avatar to go to the contact details page or recipient list page.
clickToGroupDetail(index) {
if (this.isJumping) {
return;
}
this.isJumping = true;
- // 判断跳转到联系人详情还是跳转到多个收件人的列表页面
+ // Determine whether to redirect to the contact details page or to the list page of multiple recipients.
var contactsNum = this.messageList[index].contactsNum;
var telephone = this.messageList[index].telephone;
if (contactsNum == common.int.MESSAGE_CODE_ONE) {
@@ -681,18 +718,23 @@ export default class InfoMsgController {
this.jumpToGroupDetail(threadId, contactsNum);
}
}
+
exitConversationSelect() {
this.onBackPress();
}
+
touchStart(event: GestureEvent, index: number) {
if (this.isMultipleSelectState) {
return;
}
- // 查看当前触控的item是否是跟上一个触控的是同一个,若不是,将上一个复位
+ // Check whether the current touch item is the same as that of a touch item.
+ // If not, reset the previous touch item.
if (this.itemTouchedIdx !== -1 && index !== this.itemTouchedIdx) {
let itemTouched = this.messageList[this.itemTouchedIdx];
- this.setListItemTransX(0);
- itemTouched.isDelShow = false;
+ if (itemTouched != undefined && itemTouched != null && itemTouched.isDelShow) {
+ this.setListItemTransX(0);
+ itemTouched.isDelShow = false;
+ }
}
this.itemTouchedIdx = index;
let item = this.messageList[this.itemTouchedIdx];
@@ -702,9 +744,13 @@ export default class InfoMsgController {
this.operateBtnW = common.int.OPERATE_DELETE_WIDTH;
}
}
+
resetTouch() {
if (this.itemTouchedIdx !== -1) {
let item = this.messageList[this.itemTouchedIdx];
+ if (item == undefined) {
+ return false;
+ }
if (item.isDelShow) {
this.setListItemTransX(0);
item.isDelShow = false;
@@ -713,13 +759,14 @@ export default class InfoMsgController {
}
return false;
}
+
touchMove(event: GestureEvent, index: number) {
if (this.isMultipleSelectState) {
return;
}
- // offsetX是偏移量,值区间在[-operateBtnW, 0]
+ // offsetX indicates the offset. The value range is [-operateBtnW, 0].
let offsetX = event.offsetX;
- // 位移小于2,视为没有滑动
+ // If the displacement is less than 2, there is no sliding.
if (Math.abs(offsetX) <= 2) {
return;
}
@@ -729,30 +776,32 @@ export default class InfoMsgController {
if (event.offsetX - this.operateBtnW <= 0) {
transX = event.offsetX - this.operateBtnW
} else {
- // 右滑到关闭
+ // Slide right to close
transX = 0
}
} else {
if (event.offsetX + this.operateBtnW >= 0) {
transX = event.offsetX
} else {
- // 左滑到最大宽度
+ // Slide left to maximum width
transX = 0 - this.operateBtnW;
}
}
this.setListItemTransX(transX);
}
+
deleteAction(idx) {
let element = this.messageList[idx];
this.strMsgDeleteDialogTip = $r("app.string.msg_delete_dialog_tip1");
element.isCbChecked = true;
this.hasLockMsg = (this.messageList.some((element, index) => element.isCbChecked && element.isLock));
}
+
touchEnd(event: GestureEvent, index: number) {
if (this.isMultipleSelectState) {
return;
}
- // offsetX是偏移量,值区间在[-operateBtnW, 0]
+ // offsetX indicates the offset. The value range is [-operateBtnW, 0].
let offsetX = event.offsetX;
let item = this.messageList[this.itemTouchedIdx];
if (offsetX + (this.operateBtnW / 2) >= 0) {
@@ -763,15 +812,16 @@ export default class InfoMsgController {
item.isDelShow = true;
}
}
- // 订阅接收到的新消息
- subscribeInfo(){
- HiLog.i(TAG, 'subscribeInfo, start');
+ // Subscribe to New Messages Received
+ subscribeInfo() {
+ HiLog.i(TAG, "subscribeInfo, start");
let events = [common.string.RECEIVE_TRANSMIT_EVENT]
let commonEventSubscribeInfo = {
- events : events
+ events: events
};
commonEvent.createSubscriber(commonEventSubscribeInfo, this.createSubscriberCallBack.bind(this));
}
+
setListItemTransX(transX) {
let item = this.messageList[this.itemTouchedIdx];
if (item) {
@@ -781,36 +831,41 @@ export default class InfoMsgController {
item.itemLeft = 0;
}
}
- // 用来刷新界面
+ // Used to refresh the interface.
this.flushTranslate = !this.flushTranslate;
}
- createSubscriberCallBack(err, data){
- commonEventData = data;
- // 接收到订阅
- commonEvent.subscribe(commonEventData, this.subscriberCallBack.bind(this));
+
+ createSubscriberCallBack(err, data) {
+ this.commonEventData = data;
+ // Received subscription
+ commonEvent.subscribe(this.commonEventData, this.subscriberCallBack.bind(this));
}
- subscriberCallBack(err, data){
+
+ subscriberCallBack(err, data) {
this.page = 1;
this.queryAllMessages();
}
- // 取消订阅
- unsubscribeInfo(){
- commonEvent.unsubscribe(commonEventData, () => {
- HiLog.i(TAG, 'unsubscribeInfo, success');
- });
+ // Unsubscribe
+ unsubscribeInfo() {
+ if (this.commonEventData != null) {
+ commonEvent.unsubscribe(this.commonEventData, () => {
+ HiLog.i(TAG, "unsubscribeInfo, success");
+ });
+ }
}
- // 跳转联系人app
- jumpToContract(actionData){
+ // Switching to the Contacts app
+ jumpToContract(actionData) {
var str = commonService.commonContractParam(actionData);
- featureAbility.startAbility(str).then((data) => {
+ globalThis.mmsContext.startAbility(str).then((data) => {
}).catch((error) => {
- HiLog.e(TAG, 'jumpToContract, failed: ' + JSON.stringify(error.message));
+ HiLog.e(TAG, "jumpToContract, failed: " + JSON.stringify(error.message));
})
+ this.isJumping = false;
}
- // 获取整合通知信息和显示联系人头像的开关值
+ // Obtains the switch value for integrating notification information and displaying contact avatars.
getSettingFlagForConvListPage() {
let result = settingService.getSettingFlagForConvListPage();
- if(result) {
+ if (result) {
this.isShowContactHeadIcon = result.isShowContactHeadIcon;
}
}
diff --git a/entry/src/main/ets/pages/queryreport/queryReport.ets b/entry/src/main/ets/pages/queryreport/queryReport.ets
new file mode 100644
index 0000000..1d7a00c
--- /dev/null
+++ b/entry/src/main/ets/pages/queryreport/queryReport.ets
@@ -0,0 +1,96 @@
+/**
+ * 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 DeviceUtil from "../../utils/DeviceUtil";
+import router from "@system.router";
+import QueryReportController from "./queryReportController";
+
+@Entry
+@Component
+struct queryReport {
+ @StorageLink("QueryReportController") queryReportController: QueryReportController = QueryReportController.getInstance();
+ private gridColumns: GridRowColumnOption = { sm: 4, md: 8, lg: 12 };
+ private girdSpan: GridColColumnOption = { sm: 4, md: 8, lg: 12 };
+ private gridGutter: string = "24vp";
+ private gridMargin: string = "24vp";
+
+ onPageShow(): void {
+ this.queryReportController.onShow()
+ }
+
+ aboutToAppear(): void {
+ this.queryReportController.onInit()
+ }
+
+ build() {
+ GridRow({ columns: this.gridColumns, gutter: this.gridGutter }) {
+ GridCol({ span: this.girdSpan }) {
+ 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)
+ .height(56)
+ }
+ GridCol({ span: this.girdSpan }) {
+ Column() {
+ Text() {
+ 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 })
+ }
+ }
+ .width("100%")
+ .height("100%")
+ .margin({ left: this.gridMargin, right: this.gridMargin })
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/pages/queryreport/queryReportController.ets b/entry/src/main/ets/pages/queryreport/queryReportController.ets
new file mode 100644
index 0000000..377fbbf
--- /dev/null
+++ b/entry/src/main/ets/pages/queryreport/queryReportController.ets
@@ -0,0 +1,80 @@
+/**
+ * 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 common from "../../data/commonData";
+import dateUtil from "../../utils/DateUtil";
+import router from "@system.router";
+import HiLog from "../../utils/HiLog"
+
+const TAG = "QueryReportController";
+
+let queryReportCtrl;
+
+export default class QueryReportController {
+ // MMS or not
+ isMsm: boolean = true;
+ // Sending Status Description
+ sendStatusDesc: Resource;
+ // Sending Status
+ sendStatus: number = 0;
+ // Time
+ mmsTime: Resource;
+ // Specific morning and afternoon time
+ specificTime: Resource;
+ // Timestamp
+ timeMillisecond: string = "0";
+ // telephoneNo
+ telephone: string = '';
+
+ static getInstance() {
+ if (queryReportCtrl == null) {
+ queryReportCtrl = new QueryReportController();
+ AppStorage.SetAndLink("QueryReportController", queryReportCtrl);
+ }
+ return queryReportCtrl;
+ };
+
+ onInit() {
+ HiLog.i(TAG, "onInit")
+ this.isMsm = router.getParams().isMsm == undefined ? true : Boolean(router.getParams().isMsm);
+ this.sendStatus = router.getParams().sendStatus == undefined ? 0 : Number(router.getParams().sendStatus);
+ this.timeMillisecond =
+ router.getParams().timeMillisecond == undefined ? "0" : String(router.getParams().timeMillisecond);
+ this.telephone = router.getParams().telephone == undefined ? '' : String(router.getParams().telephone)
+ };
+
+ onShow() {
+ HiLog.i(TAG, "onShow")
+ // The status is changed to Chinese description.
+ this.dealSendStatus();
+ // Time Conversion
+ this.dealTime();
+ };
+
+ dealSendStatus() {
+ HiLog.i(TAG, "dealSendStatus sendStatus=" + this.sendStatus)
+ if (this.sendStatus == common.int.SEND_MESSAGE_SUCCESS) {
+ this.sendStatusDesc = $r("app.string.received");
+ } else if (this.sendStatus == common.int.SEND_MESSAGE_FAILED) {
+ this.sendStatusDesc = this.isMsm ? $r("app.string.refused") : $r("app.string.failed");
+ } else {
+ this.sendStatusDesc = $r("app.string.rending");
+ }
+ };
+
+ dealTime() {
+ this.mmsTime = dateUtil.convertTimeStampDate(this.timeMillisecond);
+ this.specificTime = dateUtil.convertTimeStampTime(this.timeMillisecond, false)
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/pages/settings/advancedSettings/advancedSettings.ets b/entry/src/main/ets/pages/settings/advancedSettings/advancedSettings.ets
new file mode 100644
index 0000000..9934585
--- /dev/null
+++ b/entry/src/main/ets/pages/settings/advancedSettings/advancedSettings.ets
@@ -0,0 +1,376 @@
+/**
+ * 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 AdvancedSettingsController from "./advancedSettingsController";
+import DeviceUtil from "../../../utils/DeviceUtil";
+import { MmsSimpleDialog } from "../../../views/MmsDialogs";
+import { MoreMenu } from "../../../views/MmsMenu";
+import router from "@system.router";
+import { SettingItemJump } from "../../../views/SettingItem";
+
+@Entry
+@Component
+struct AdvancedSettings {
+ @State mAdvancedSettingsCtrl: AdvancedSettingsController = AdvancedSettingsController.getInstance();
+ private gridColumns: GridRowColumnOption = { sm: 4, md: 8, lg: 12 };
+ private girdSpan: GridColColumnOption = { sm: 4, md: 6, lg: 8 };
+ private gridColOffset: GridColColumnOption = { md: 1, lg: 2 };
+ private gridGutter: string = "12vp";
+ private dialogGridCount: number = 4;
+ dialogAlignment: DialogAlignment = DeviceUtil.isTablet() ? DialogAlignment.Center : DialogAlignment.Bottom;
+ dialogOffset: Offset = DeviceUtil.isTablet() ? { dx: 0, dy: 0 } : { dx: 0, dy: -16 };
+ 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 = [
+ {
+ 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,
+ gridCount: this.dialogGridCount
+ })
+
+ /**
+ * The function executes after a new instance of the custom component is created and before its build function
+ * is executed.
+ * Allows state variables to be changed in the aboutToAppear function, and these changes will take effect in
+ * subsequent executions of the build function.
+ */
+ aboutToAppear() {
+ this.mAdvancedSettingsCtrl.onInit();
+ }
+ /**
+ * Triggers once when this page is displayed. In scenarios such as routing and application access to the foreground
+ * and background, only customized components modified by @Entry take effect.
+ */
+ onPageShow() {
+ this.mAdvancedSettingsCtrl.onShow()
+ }
+ /**
+ * Triggers once when this page disappears. In scenarios such as routing and application access to the foreground
+ * and background, only customized components modified by @Entry take effect.
+ */
+ onPageHide() {
+ }
+ /**
+ * Function executes before custom component destructor consumption.
+ * Changing state variables in the aboutToDisappear function is not allowed, especially changes to the @Link
+ * variable may cause unstable application behavior.
+ */
+ aboutToDisappear() {
+ }
+ /**
+ * Triggered when a user clicks the back button. Only the customized component modified by @Entry takes effect.
+ * If true is returned, the page processes the return logic and does not route the page.
+ * If false is returned, the default return logic is used.
+ * If no value is returned, the value is treated as false.
+ */
+ onBackPress() {
+ }
+
+ build() {
+ Column() {
+ // Top Device Title
+ 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")
+ })
+ .onClick(() => {
+ router.back()
+ })
+
+ Row().width($r("app.float.space_16"))
+
+ Text($r("app.string.advanced"))
+ .fontSize($r("app.float.action_bar_text_size"))
+ .fontColor(Color.Black)
+ .fontWeight(FontWeight.Bold)
+
+ Row().width("100%").flexShrink(1)
+
+ Column() {
+ MoreMenu({
+ menuItems: this.menuItems
+ })
+ }
+ .margin({ right: $r("app.float.action_bar_margin_right") })
+ }
+ .width("100%")
+ .height($r("app.float.action_bar_height"))
+
+ Scroll() {
+ GridRow({ columns: this.gridColumns, gutter: this.gridGutter }) {
+ GridCol({ span: this.girdSpan, offset: this.gridColOffset }) {
+ // All settings
+ Column({ space: 12 }) {
+ // Setting items of the first group
+ Column() {
+ // Delivery Report
+ 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();
+ }
+ })
+ // Automatically downloading MMs
+ SettingItemJump({
+ primaryTitle: $r("app.string.auto_retrieve_mms"),
+ statusTitle: this.mAdvancedSettingsCtrl.autoRetrieveMmsSwitchInText,
+ visibilityShow: 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("sys.color.ohos_id_color_text_field_bg")
+ })
+ .backgroundColor($r("sys.color.ohos_id_color_text_field_bg"))
+
+ // Setting items of the second group
+ 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("sys.color.ohos_id_color_text_field_bg")
+ })
+ .backgroundColor($r("sys.color.ohos_id_color_text_field_bg"))
+ .visibility(Visibility.None)
+
+ // Setting items of the third group
+ Column() {
+ // SMSC
+ SettingItemJump({
+ primaryTitle: $r("app.string.sms_center"),
+ showBottomDivider: true,
+ OnClick: (event?: ClickEvent) => {
+ this.mAdvancedSettingsCtrl.jumpToSmsCenterPage(1);
+ }
+ })
+ // Managing SIM Card Information
+ 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("sys.color.ohos_id_color_text_field_bg")
+ })
+ .backgroundColor($r("sys.color.ohos_id_color_text_field_bg"))
+ .visibility(Visibility.None)
+ }
+ .margin({
+ top: $r("app.float.settings_items_margin_top"),
+ bottom: $r("app.float.settings_items_margin_bottom")
+ })
+ }
+ }
+ }
+ .layoutWeight(1)
+ }
+ .width("100%")
+ .height("100%")
+ .padding({ left: $r("app.float.page_padding_left"), right: $r("app.float.page_padding_right") })
+ .backgroundColor($r("sys.color.ohos_id_color_sub_background"))
+ }
+}
+
+/**
+ * Delivery report selection box
+ */
+@CustomDialog
+struct DeliveryReportsDialog {
+ controller: CustomDialogController;
+ cancel: () => void;
+ confirm: (isOnOfSms: boolean, isOnOfMms: boolean) => void;
+ private isOnOfSms: boolean = false;
+ private isOnOfMms: boolean = false;
+
+ 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)
+ .offset({ x: 16, y: 0 })
+ .selectedColor($r("sys.color.ohos_id_color_activated"))
+ }
+ .width("100%")
+ .height(48)
+ .onClick((event: ClickEvent) => {
+ this.isOnOfSms = !this.isOnOfSms;
+ })
+
+ Divider()
+ .vertical(false)
+ .strokeWidth(0.5)
+ .width("100%")
+ .color($r("sys.color.ohos_id_color_list_separator"))
+
+ 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)
+ .offset({ x: 16, y: 0 })
+ .selectedColor($r("sys.color.ohos_id_color_activated"))
+ }
+ .width("100%")
+ .height(48)
+ .onClick((event: ClickEvent) => {
+ this.isOnOfMms = !this.isOnOfMms;
+ })
+
+ }
+ .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("sys.color.ohos_id_color_background_transparent"))
+ .layoutWeight(1)
+ .height(40)
+ .onClick(() => {
+ this.controller.close();
+ this.cancel();
+ })
+
+ Divider().vertical(true).strokeWidth(0.5).height(24).color($r("sys.color.ohos_id_color_list_separator"))
+ 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("sys.color.ohos_id_color_background_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("100%")
+ .backgroundColor($r("sys.color.ohos_id_color_dialog_bg"))
+ }
+}
diff --git a/entry/src/main/ets/pages/settings/advancedSettings/advancedSettingsController.ets b/entry/src/main/ets/pages/settings/advancedSettings/advancedSettingsController.ets
new file mode 100644
index 0000000..6e7a9e7
--- /dev/null
+++ b/entry/src/main/ets/pages/settings/advancedSettings/advancedSettingsController.ets
@@ -0,0 +1,321 @@
+/**
+ * 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"
+import HiLog from "../../../utils/HiLog";
+import router from "@system.router";
+import prompt from "@system.prompt";
+import settingService from "../../../service/SettingService"
+import common from "../../../data/commonData";
+
+const TAG = "AdvancedSettingsController";
+
+export default class AdvancedSettingsController {
+ private static sInstance: AdvancedSettingsController;
+ // Delivery Report SMS
+ checkedValueOfSms: boolean = false;
+ // Delivery Report MMS
+ checkedValueOfMms: boolean = false;
+ // Value of Delivery Report Switch
+ deliveryReportSwitch: string = common.DELIVERY_REPORTS.DISABLED;
+ // Delivery Report Text
+ deliveryReportSwitchInText: Resource | string = $r("app.string.disabled");
+ // Automatic MM Download Switch
+ autoRetrieveMmsSwitch: string = common.AUTO_RETRIEVE_MMS.OFF;
+ // Text for automatically downloading MMS messages
+ autoRetrieveMmsSwitchInText: Resource | string = $r("app.string.off");
+ // Cancel Sending Switch
+ recallMessageSwitch: string = common.bool.FALSE;
+ // Automatic Notification Deletion Switch
+ autoDeleteInfoSwitch: string = common.bool.FALSE;
+ // Indicates whether to automatically delete notification information. This parameter is a temporary variable.
+ tempAutoDeleteInfoSwitch: string = common.bool.FALSE;
+ // China Telecom
+ snpNameOfChinaTelecom: string = '';
+ // Number of SIM cards
+ simCount: number = 0;
+ // For one card, the name of the carrier.
+ spnNameOfOneSimCard: string = '';
+ // If there are two cards, the carrier name of card 1 is the name of card 1.
+ firstSpnNameOfTwoSimCard: string = '';
+ // If there are two cards, the carrier name of card 2 is the name of card 2.
+ secondSpnNameOfTwoSimCard: string = '';
+
+ static getInstance() {
+ if (AdvancedSettingsController.sInstance == null) {
+ AdvancedSettingsController.sInstance = new AdvancedSettingsController();
+ }
+ return AdvancedSettingsController.sInstance;
+ }
+
+ constructor() {
+ HiLog.i(TAG, "constructor, start");
+ this.getAdvancedPageSwitchValue();
+ }
+
+ onInit() {
+ HiLog.i(TAG, "onInit, start");
+ }
+
+ onShow() {
+ HiLog.i(TAG, "onShow, start");
+ }
+
+ getAdvancedPageSwitchValue() {
+ HiLog.i(TAG, "getAdvancedPageSwitchValue, start");
+ let that = this;
+ settingService.getAdvancedPageSwitchValue(function (result) {
+ if (result.code === common.int.SUCCESS) {
+ let switchValue = result.abilityResult;
+ that.deliveryReportSwitch = switchValue.deliveryReportSwitch;
+ that.returnDeliveryReportResultInText(that.deliveryReportSwitch);
+ that.autoRetrieveMmsSwitch = switchValue.autoRetrieveMmsSwitch;
+ that.returnAutoRetrieveMmsResultInText(that.autoRetrieveMmsSwitch);
+ that.recallMessageSwitch = switchValue.recallMessageSwitch;
+ that.autoDeleteInfoSwitch = switchValue.autoDeleteInfoSwitch;
+ that.tempAutoDeleteInfoSwitch = that.autoDeleteInfoSwitch;
+ // Change the SIM card to switchValue.simCount after the SIM card functions properly.
+ that.simCount = switchValue.simCount;
+ if (that.simCount === 2) {
+ that.firstSpnNameOfTwoSimCard = switchValue.firstSpnNameOfTwoSimCard;
+ that.secondSpnNameOfTwoSimCard = switchValue.secondSpnNameOfTwoSimCard;
+ } else {
+ that.spnNameOfOneSimCard = switchValue.spnNameOfOneSimCard;
+ }
+ } else {
+ HiLog.w(TAG, "getAdvancedPageSwitchValue, failed");
+ }
+ });
+ }
+ // Returns the text version of the delivery report result based on an integer value
+ returnDeliveryReportResultInText(intValue) {
+ let tempValue;
+ if (intValue == common.DELIVERY_REPORTS.DISABLED) {
+ tempValue = $r("app.string.disabled");
+ this.checkedValueOfSms = false;
+ this.checkedValueOfMms = false;
+ } else if (intValue == common.DELIVERY_REPORTS.SMS) {
+ tempValue = $r("app.string.sms");
+ this.checkedValueOfSms = true;
+ this.checkedValueOfMms = false;
+ } else if (intValue == common.DELIVERY_REPORTS.MMS) {
+ tempValue = $r("app.string.mms");
+ this.checkedValueOfSms = false;
+ this.checkedValueOfMms = true;
+ } else {
+ tempValue = $r("app.string.sms_and_mms");
+ this.checkedValueOfSms = true;
+ this.checkedValueOfMms = true;
+ }
+ this.deliveryReportSwitchInText = tempValue;
+ }
+ // Returns the text version of the delivery report result based on an integer value
+ returnAutoRetrieveMmsResultInText(intValue) {
+ let tempValue;
+ if (intValue == common.AUTO_RETRIEVE_MMS.OFF) {
+ tempValue = $r("app.string.off");
+ } else if (intValue == common.AUTO_RETRIEVE_MMS.NOT_WHEN_ROAMING) {
+ tempValue = $r("app.string.not_when_roaming");
+ } else {
+ tempValue = $r("app.string.always");
+ }
+ this.autoRetrieveMmsSwitchInText = tempValue;
+ }
+ // Back button
+ back() {
+ router.back();
+ }
+ // Restore the default values on the settings page.
+ restoreSettingPageSwitchValue() {
+ HiLog.i(TAG, "restoreSettingPageSwitchValue");
+ let that = this;
+ settingService.restoreSwitchValue(function (result) {
+ if (result.code === common.int.SUCCESS) {
+ that.deliveryReportSwitch = common.DELIVERY_REPORTS.DISABLED;
+ that.returnDeliveryReportResultInText(common.DELIVERY_REPORTS.DISABLED);
+ that.autoRetrieveMmsSwitch = common.AUTO_RETRIEVE_MMS.NOT_WHEN_ROAMING;
+ that.returnAutoRetrieveMmsResultInText(common.AUTO_RETRIEVE_MMS.NOT_WHEN_ROAMING);
+ that.recallMessageSwitch = common.bool.FALSE;
+ that.autoDeleteInfoSwitch = common.bool.FALSE;
+ that.tempAutoDeleteInfoSwitch = common.bool.FALSE;
+ HiLog.i(TAG, "restoreSettingPageSwitchValue, success");
+ } else {
+ HiLog.w(TAG, "restoreSettingPageSwitchValue, failed");
+ }
+ });
+ }
+ // Click the text line.
+ clickSmsDiv() {
+ this.checkedValueOfSms = !this.checkedValueOfSms;
+ }
+ // Click Checkbox in the line of the message.
+ clickSmsCheckbox(e) {
+ this.checkedValueOfSms = e.checked;
+ }
+ // Click the MMS line.
+ clickMmsDiv() {
+ this.checkedValueOfMms = !this.checkedValueOfMms;
+ }
+ // Click Checkbox in the MMS line.
+ clickMmsCheckbox(e) {
+ this.checkedValueOfMms = e.checked;
+ }
+ // Cancel the configuration restoration dialog box.
+ cancelRestore() {
+ this.returnDeliveryReportResultInText(this.deliveryReportSwitch);
+ }
+ // delivery report dialog, OK
+ 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;
+ } else if (this.checkedValueOfSms) {
+ this.deliveryReportSwitch = common.DELIVERY_REPORTS.SMS;
+ } else if (this.checkedValueOfMms) {
+ this.deliveryReportSwitch = common.DELIVERY_REPORTS.MMS;
+ } else {
+ this.deliveryReportSwitch = common.DELIVERY_REPORTS.DISABLED;
+ }
+ this.returnDeliveryReportResultInText(this.deliveryReportSwitch);
+ this.autoHandleDeliveryReportValueChange(this.deliveryReportSwitch);
+ }
+ // When the value of deliveryReportSwitch changes, this method is used to process the change.
+ autoHandleDeliveryReportValueChange(newValue) {
+ HiLog.i(TAG, "autoHandleDeliveryReportValueChange, newValue = " + newValue);
+ let messageCode = common.route.MESSAGE_CODE_UPDATE_DELIVERY_REPORTS_VALUE;
+ let actionData: LooseObject = {};
+ actionData.intValue = newValue;
+ this.updateAdvancedPageSwitchValue(messageCode, actionData);
+ }
+ // Displaying the "Automatic Download MMS" dialog
+ showAutoRetrieveMmsDialog() {
+ // this.$element("auto-retrieve-mms-dialog").show();
+ }
+ // Click the corresponding option in the dialog box for automatically downloading MMs.
+ clickDiv(idx) {
+ this.autoRetrieveMmsSwitch = idx + common.string.EMPTY_STR;
+ this.returnAutoRetrieveMmsResultInText(idx);
+ // this.$element("auto-retrieve-mms-dialog").close();
+ this.autoHandleAutoRetrieveMmsValueChange(this.autoRetrieveMmsSwitch);
+ }
+ // Disable the automatic MM download dialog box.
+ closeAutoRetrieveMmsDialog() {
+ // this.$element("auto-retrieve-mms-dialog").close();
+ }
+ // This method is used when the value of autoRetrieveMmsSwitch changes.
+ autoHandleAutoRetrieveMmsValueChange(newValue) {
+ HiLog.i(TAG, "autoHandleAutoRetrieveMmsValueChange, newValue = " + newValue);
+ let messageCode = common.route.MESSAGE_CODE_UPDATE_AUTO_RETRIEVE_MMS_VALUE;
+ let actionData: LooseObject = {};
+ actionData.intValue = newValue;
+ this.updateAdvancedPageSwitchValue(messageCode, actionData);
+ }
+ // Cancel Sending
+ recallMsg(e) {
+ let messageCode = common.route.MESSAGE_CODE_UPDATE_RECALL_MESSAGES_VALUE;
+ let actionData: LooseObject = {};
+ this.recallMessageSwitch = e.checked;
+ if (this.recallMessageSwitch) {
+ actionData.booleanValue = common.bool.TRUE;
+ } else {
+ actionData.booleanValue = common.bool.FALSE;
+ }
+ this.updateAdvancedPageSwitchValue(messageCode, actionData);
+ }
+ // Automatically delete notification information
+ autoDeleteInfo(e) {
+ let that = this;
+ that.tempAutoDeleteInfoSwitch = e.checked;
+ if (e.checked) {
+ prompt.showDialog({
+ title: $r("app.string.enable_auto_delete") + '',
+ message: $r("app.string.enable_auto_delete_hint") + '',
+ buttons: [
+ {
+ text: $r("app.string.cancel") + '', color: "#007DFF"
+ },
+ {
+ text: $r("app.string.enable") + '', color: "#007DFF"
+ }
+ ],
+ success: function (data) {
+ that.autoDeleteSuccess(data);
+ },
+ cancel: function () {
+ HiLog.i(TAG, "autoDeleteInfo, cancel");
+ that.tempAutoDeleteInfoSwitch = common.bool.FALSE;
+ that.autoDeleteInfoSwitch = common.bool.FALSE;
+ }
+ });
+ } else {
+ that.autoDeleteInfoSwitch = common.bool.FALSE;
+ that.autoHandleAutoDeleteInfoValueChange(common.bool.FALSE);
+ }
+ }
+
+ autoDeleteSuccess(data) {
+ if (data.index == 0) {
+ this.tempAutoDeleteInfoSwitch = common.bool.FALSE;
+ } else {
+ this.autoDeleteInfoSwitch = common.bool.TRUE;
+ this.autoHandleAutoDeleteInfoValueChange(common.bool.TRUE);
+ }
+ }
+ // This method is used when the value of autoDeleteInfoSwitch changes.
+ autoHandleAutoDeleteInfoValueChange(newValue) {
+ HiLog.i(TAG, "autoHandleAutoDeleteInfoValueChange, newValue = " + newValue);
+ let messageCode = common.route.MESSAGE_CODE_UPDATE_AUTO_DELETE_INFO_MESSAGES_VALUE;
+ let actionData: LooseObject = {};
+ actionData.booleanValue = newValue;
+ this.updateAdvancedPageSwitchValue(messageCode, actionData);
+ }
+ // The SMSC page is displayed.
+ jumpToSmsCenterPage(index) {
+ if (this.simCount == 0) {
+ return;
+ }
+ router.push({
+ uri: "pages/sms_center/sms_center",
+ params: {
+ idx: index,
+ countOfSim: this.simCount
+ }
+ });
+ }
+ // The Manage SIM Card page is displayed.
+ jumpToManageSimPage(index) {
+ if (this.simCount == 0) {
+ return;
+ }
+ router.push({
+ uri: "pages/manage_sim/manage_sim",
+ params: {
+ idx: index,
+ countOfSim: this.simCount
+ }
+ });
+ }
+ // Update Switch Value
+ updateAdvancedPageSwitchValue(messageCode, actionData) {
+ settingService.updateSettingValue(messageCode, actionData, function (result) {
+ if (result.code == common.int.SUCCESS) {
+ HiLog.i(TAG, "updateAdvancedPageSwitchValue, success");
+ } else {
+ HiLog.w(TAG, "updateAdvancedPageSwitchValue, failed");
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/pages/settings/ringtoneSettings/ringtoneSettings.ets b/entry/src/main/ets/pages/settings/ringtoneSettings/ringtoneSettings.ets
similarity index 68%
rename from entry/src/main/ets/default/pages/settings/ringtoneSettings/ringtoneSettings.ets
rename to entry/src/main/ets/pages/settings/ringtoneSettings/ringtoneSettings.ets
index e145232..a176a5d 100644
--- a/entry/src/main/ets/default/pages/settings/ringtoneSettings/ringtoneSettings.ets
+++ b/entry/src/main/ets/pages/settings/ringtoneSettings/ringtoneSettings.ets
@@ -15,13 +15,13 @@
@Entry
@Component
struct RingtoneSettings {
- build() {
- Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
- Text('这是铃声设置界面')
- .fontSize(50)
- .fontWeight(FontWeight.Bold)
+ build() {
+ Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
+ Text("这是铃声设置界面")
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ }
+ .width("100%")
+ .height("100%")
}
- .width('100%')
- .height('100%')
- }
}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/pages/settings/ringtoneSettings/ringtoneSettingsController.ets b/entry/src/main/ets/pages/settings/ringtoneSettings/ringtoneSettingsController.ets
similarity index 96%
rename from entry/src/main/ets/default/pages/settings/ringtoneSettings/ringtoneSettingsController.ets
rename to entry/src/main/ets/pages/settings/ringtoneSettings/ringtoneSettingsController.ets
index 3c483ec..039d9ce 100644
--- a/entry/src/main/ets/default/pages/settings/ringtoneSettings/ringtoneSettingsController.ets
+++ b/entry/src/main/ets/pages/settings/ringtoneSettings/ringtoneSettingsController.ets
@@ -12,7 +12,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-export default {
-
-
-}
\ No newline at end of file
+export default {}
\ No newline at end of file
diff --git a/entry/src/main/ets/pages/settings/settings.ets b/entry/src/main/ets/pages/settings/settings.ets
new file mode 100644
index 0000000..91900d0
--- /dev/null
+++ b/entry/src/main/ets/pages/settings/settings.ets
@@ -0,0 +1,246 @@
+/**
+ * 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 DeviceUtil from "../../utils/DeviceUtil";
+import { MmsSimpleDialog } from "../../views/MmsDialogs";
+import { MoreMenu } from "../../views/MmsMenu";
+import router from "@system.router";
+import { SettingItemSwitch, SettingItemJump } from "../../views/SettingItem";
+import SettingsController from "./settingsController";
+import HiLog from "../../utils/HiLog";
+const TAG = "Settings";
+@Entry
+@Component
+struct Settings {
+ @State mSettingsCtrl: SettingsController = SettingsController.getInstance();
+ private gridColumns: GridRowColumnOption = { sm: 4, md: 8, lg: 12 };
+ private girdSpan: GridColColumnOption = { sm: 4, md: 6, lg: 8 };
+ private gridColOffset: GridColColumnOption = { md: 1, lg: 2 };
+ private gridGutter: 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 = [
+ {
+ value: $r("app.string.restore_default_settings"),
+ action: () => {
+ this.restoreDialog.show();
+ },
+ enabled: true
+ }
+ ];
+
+ /**
+ * The function executes after a new instance of the custom component is created and before its build function
+ * is executed.
+ * Allows state variables to be changed in the aboutToAppear function, and these changes will take effect in
+ * subsequent executions of the build function.
+ */
+ aboutToAppear() {
+ this.mSettingsCtrl.onInit()
+ }
+
+ /**
+ * Function executes before custom component destructor consumption.
+ * Changing state variables in the aboutToDisappear function is not allowed, especially changes to the @Link
+ * variable may cause unstable application behavior.
+ */
+ aboutToDisappear() {
+ }
+
+ /**
+ * Triggers once when this page is displayed. In scenarios such as routing and application access to the foreground
+ * and background, only customized components modified by @Entry take effect.
+ */
+ onPageShow() {
+ this.mSettingsCtrl.onShow()
+ }
+
+ /**
+ * Triggers once when this page disappears. In scenarios such as routing and application access to the foreground
+ * and background, only customized components modified by @Entry take effect.
+ */
+ onPageHide() {
+ }
+
+ /**
+ * Triggered when a user clicks the back button. Only the customized component modified by @Entry takes effect.
+ * If true is returned, the page processes the return logic and does not route the page.
+ * If false is returned, the default return logic is used.
+ * If no value is returned, the value is treated as false.
+ */
+ onBackPress() {
+ }
+
+ build() {
+ Column() {
+ // Top Device Title
+ 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")
+ })
+ .onClick(() => {
+ router.back()
+ })
+
+ Row().width($r("app.float.space_16"))
+
+ Text($r("app.string.settings"))
+ .fontSize($r("app.float.action_bar_text_size"))
+ .fontColor(Color.Black)
+ .fontWeight(FontWeight.Bold)
+
+ Row().width("100%").flexShrink(1)
+
+ Column() {
+ MoreMenu({
+ menuItems: this.menuItems
+ })
+ }
+ .margin({ right: $r("app.float.action_bar_margin_right") })
+ }
+ .width("100%")
+ .height($r("app.float.action_bar_height"))
+
+ Scroll() {
+ GridRow({ columns: this.gridColumns, gutter: this.gridGutter }) {
+ GridCol({ span: this.girdSpan, offset: this.gridColOffset }) {
+ // All settings
+ Column() {
+ // Setting items of the first group
+ Column() {
+ // Enhanced Information
+ SettingItemJump({
+ primaryTitle: $r("app.string.enhanced_information"),
+ statusTitle: $r("app.string.enabled"),
+ visibilityShow: this.isEnhanceShow,
+ OnClick: (event?: ClickEvent) => {
+ // The page for setting enhanced information is displayed.
+ }
+ })
+
+ // Intelligent information
+ SettingItemJump({
+ primaryTitle: $r("app.string.intelligent_information"),
+ statusTitle: $r("app.string.enabled"),
+ OnClick: (event?: ClickEvent) => {
+ // The ringtone setting page is displayed.
+ }
+ })
+ }
+ .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("sys.color.ohos_id_color_text_field_bg")
+ })
+ .backgroundColor($r("sys.color.ohos_id_color_text_field_bg"))
+ .visibility(Visibility.None)
+
+ // Setting items of the second group
+ Column() {
+ // Notification information integration
+ 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("sys.color.ohos_id_color_text_field_bg")
+ })
+ .backgroundColor($r("sys.color.ohos_id_color_text_field_bg"))
+
+ // Setting items of the third group
+ Column() {
+ // Message ringtone
+ SettingItemJump({
+ primaryTitle: $r("app.string.message_tone"),
+ showBottomDivider: true,
+ visibilityShow: Visibility.None,
+ OnClick: (event?: ClickEvent) => {
+ // The ringtone setting page is displayed.
+ this.mSettingsCtrl.jumpToMessageTonePage()
+ }
+ })
+ // Advanced
+ SettingItemJump({
+ primaryTitle: $r("app.string.advanced"),
+ OnClick: (event?: ClickEvent) => {
+ // Go to the advanced settings screen.
+ 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")
+ })
+ .margin({ top: 12 })
+ .border({
+ radius: $r("app.float.settings_items_radius"),
+ color: $r("sys.color.ohos_id_color_text_field_bg")
+ })
+ .backgroundColor($r("sys.color.ohos_id_color_text_field_bg"))
+ }
+ .margin({
+ top: $r("app.float.settings_items_margin_top"),
+ bottom: $r("app.float.settings_items_margin_bottom")
+ })
+ }
+ }
+ }
+ .layoutWeight(1)
+ }
+ .width("100%")
+ .height("100%")
+ .padding({ left: $r("app.float.page_padding_left"), right: $r("app.float.page_padding_right") })
+ .backgroundColor($r("sys.color.ohos_id_color_sub_background"))
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/pages/settings/settingsController.ets b/entry/src/main/ets/pages/settings/settingsController.ets
new file mode 100644
index 0000000..f5d5acd
--- /dev/null
+++ b/entry/src/main/ets/pages/settings/settingsController.ets
@@ -0,0 +1,152 @@
+/**
+ * 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"
+import MmsBoolean from "../../data/MmsBoolean"
+import HiLog from "../../utils/HiLog";
+import router from "@system.router";
+// JS Common constants
+import common from "../../data/commonData";
+import settingService from "../../service/SettingService"
+
+const TAG = "SettingsController";
+
+export default class SettingsController {
+ private static sInstance: SettingsController;
+ // Notification information integration
+ integrationSwitch: MmsBoolean = new MmsBoolean(true);
+ // Malicious website selection
+ maliciousWebSwitch: boolean = false;
+ // Verification code security protection
+ verificationCodeSwitch: boolean = false;
+ // Display contact avatar
+ showContactSwitch: boolean = true
+
+ static getInstance() {
+ if (SettingsController.sInstance == null) {
+ SettingsController.sInstance = new SettingsController();
+ }
+ return SettingsController.sInstance;
+ }
+
+ constructor() {
+ HiLog.i(TAG, "constructor, start");
+ this.getSettingPageSwitchValue();
+ }
+
+ onInit() {
+ HiLog.i(TAG, "onInit, start");
+ };
+
+ onShow() {
+ HiLog.i(TAG, "onShow, start");
+ };
+
+ // Indicates whether to initialize the setting page.
+ getSettingPageSwitchValue() {
+ HiLog.i(TAG, "getSettingPageSwitchValue, start");
+ let that = this;
+ settingService.setOnSettingValueListener(function (result) {
+ that.integrationSwitch.value = result.integrationSwitch;
+ that.maliciousWebSwitch = result.maliciousWebSwitch;
+ that.showContactSwitch = result.showContactSwitch;
+ });
+ };
+
+ // Notification information integration
+ integration(isOn: boolean) {
+ let messageCode = common.route.MESSAGE_CODE_UPDATE_ARCHIVE_INFO_MESSAGES_VALUE;
+ let actionData: LooseObject = {};
+ this.integrationSwitch.value = isOn;
+ if (this.integrationSwitch.value) {
+ actionData.booleanValue = common.bool.TRUE;
+ } else {
+ actionData.booleanValue = common.bool.FALSE;
+ }
+ this.updateSettingPageSwitchValue(messageCode, actionData);
+ };
+
+ // Malicious website selection
+ maliciousWeb(e) {
+ HiLog.i(TAG, "maliciousWeb, checked = " + e.checked);
+ let messageCode = common.route.MESSAGE_CODE_UPDATE_MALICIOUS_WEBSITE_IDENTIFICATION_VALUE;
+ let actionData: LooseObject = {};
+ this.maliciousWebSwitch = e.checked;
+ if (this.maliciousWebSwitch) {
+ actionData.booleanValue = common.bool.TRUE;
+ } else {
+ actionData.booleanValue = common.bool.FALSE;
+ }
+ this.updateSettingPageSwitchValue(messageCode, actionData);
+ };
+
+ // Go to the Message Ring page. Choose Settings > Sound and Vibration > Message Ring.
+ jumpToMessageTonePage() {
+ HiLog.i(TAG, "jumpToMessageTonePage")
+ };
+
+ // Display a contact's avatar
+ showContact(e) {
+ HiLog.i(TAG, "showContact, checked = " + e.checked);
+ let messageCode = common.route.MESSAGE_CODE_UPDATE_SHOW_CONTACT_PROFILE_PICS_VALUE;
+ let actionData: LooseObject = {};
+ this.showContactSwitch = e.checked;
+ if (this.showContactSwitch) {
+ actionData.booleanValue = common.bool.TRUE;
+ } else {
+ actionData.booleanValue = common.bool.FALSE;
+ }
+ this.updateSettingPageSwitchValue(messageCode, actionData);
+ };
+
+ // Restore the default values on the settings page.
+ restoreSettingsPageSwitchValue() {
+ let that = this;
+ settingService.restoreSwitchValue(function (result) {
+ if (result.code === common.int.SUCCESS) {
+ that.integrationSwitch.value = true;
+ that.maliciousWebSwitch = false;
+ that.showContactSwitch = true;
+ HiLog.i(TAG, "restoreSettingsPageSwitchValue, success");
+ } else {
+ HiLog.w(TAG, "restoreSettingsPageSwitchValue, failed");
+ }
+ });
+ };
+
+ // Back button
+ back() {
+ router.back();
+ };
+
+ // Advanced page redirection
+ advancedSetting() {
+ HiLog.i(TAG, "advancedSetting")
+ router.push({
+ uri: "pages/settings/advancedSettings/advancedSettings"
+ });
+ };
+
+ // Update Switch Value
+ updateSettingPageSwitchValue(messageCode, actionData) {
+ HiLog.i(TAG, "updateSettingPageSwitchValue, messageCode = " + messageCode);
+ settingService.updateSettingValue(messageCode, actionData, function (result) {
+ if (result.code == common.int.SUCCESS) {
+ HiLog.i(TAG, "updateSettingPageSwitchValue, success");
+ } else {
+ HiLog.w(TAG, "updateSettingPageSwitchValue, failed");
+ }
+ });
+ };
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/service/CallService.ets b/entry/src/main/ets/service/CallService.ets
similarity index 63%
rename from entry/src/main/ets/default/service/CallService.ets
rename to entry/src/main/ets/service/CallService.ets
index d6ce385..a7da76a 100644
--- a/entry/src/main/ets/default/service/CallService.ets
+++ b/entry/src/main/ets/service/CallService.ets
@@ -13,30 +13,32 @@
* limitations under the License.
*/
-import call from '@ohos.telephony.call';
-import HiLog from '../utils/HiLog';
-import common from '../data/commonData';
-import LooseObject from '../data/LooseObject'
+import call from "@ohos.telephony.call";
+import HiLog from "../utils/HiLog";
+import common from "../data/commonData";
+import LooseObject from "../data/LooseObject"
+
+const TAG = "CallService";
-const TAG = 'CallService';
export default {
/**
- * 打电话
- * @param params 电话号码
+ * Calling
+ * @param params Phone number
* @return
*/
- call(params, callback) {
- if(params == null || params.telephone == common.string.EMPTY_STR) {
- HiLog.i(TAG, 'call, param is null');
+ call(telephone, callback) {
+ if (telephone == null || telephone == common.string.EMPTY_STR) {
+ HiLog.i(TAG, "telephone is null");
return;
}
let result: LooseObject = {};
- call.dial(params.telephone).then((value) => {
+ call.dial(telephone).then((value) => {
result.code = common.int.SUCCESS;
+ result.value = value;
callback(result);
}).catch((err) => {
- HiLog.e(TAG, 'call, dial error: ' + err.message);
+ HiLog.e(TAG, "dial error: " + err.message);
result.code = common.int.FAILURE;
callback(result);
});
diff --git a/entry/src/main/ets/default/service/CommonService.ets b/entry/src/main/ets/service/CommonService.ets
similarity index 83%
rename from entry/src/main/ets/default/service/CommonService.ets
rename to entry/src/main/ets/service/CommonService.ets
index 8b57a5b..c38764e 100644
--- a/entry/src/main/ets/default/service/CommonService.ets
+++ b/entry/src/main/ets/service/CommonService.ets
@@ -13,19 +13,17 @@
* limitations under the License.
*/
-import common from '../data/commonData';
+import common from "../data/commonData";
export default {
- commonContractParam(actionData){
+ commonContractParam(actionData) {
let str = {
- 'want': {
- 'bundleName': common.string.CONTRACT_BUNDLE_NAME,
- 'abilityName': common.string.CONTRACT_ABILITY_NAME,
- 'parameters' : actionData,
- 'entities': [
- common.string.COMMON_ENTITIES
- ]
- },
+ "bundleName": common.string.CONTRACT_BUNDLE_NAME,
+ "abilityName": common.string.CONTRACT_ABILITY_NAME,
+ "parameters": actionData,
+ "entities": [
+ common.string.COMMON_ENTITIES
+ ]
};
return str;
},
@@ -76,7 +74,7 @@ export default {
if (content == common.string.EMPTY_STR) {
item.content = secondContent;
} else {
- item.content = content + '\n' + secondContent;
+ item.content = content + "\n" + secondContent;
}
} else if (second.msgType == common.MSG_ITEM_TYPE.THEME && mmsParts.length === 3) {
item.msgUriPath = first.msgUriPath;
@@ -86,7 +84,7 @@ export default {
if (secondContent == common.string.EMPTY_STR) {
item.content = thirdContent;
} else {
- item.content = secondContent + '\n' + thirdContent;
+ item.content = secondContent + "\n" + thirdContent;
}
} else {
item.content = content;
@@ -110,9 +108,9 @@ export default {
},
getMmsContent(mmsSource) {
let content = common.string.EMPTY_STR;
- for(let mms of mmsSource) {
- // 代表存在主题
- if(mms.msgType == common.MSG_ITEM_TYPE.THEME) {
+ for (let mms of mmsSource) {
+ // Indicates that the topic exists.
+ if (mms.msgType == common.MSG_ITEM_TYPE.THEME) {
content = mms.content;
break;
}
@@ -120,7 +118,7 @@ export default {
return content;
},
checkIsMms(dataSource) {
- // 是否是普通短信
+ // Indicates whether the SMS message is a common message.
let isMsg = false;
for (let index = 0; index < dataSource.length; index++) {
let item = dataSource[index];
@@ -133,15 +131,15 @@ export default {
},
judgeIsSelectText(mmsSource) {
let flage = false;
- for(let item of mmsSource) {
+ for (let item of mmsSource) {
let msgType = item.msgType;
- if(common.MSG_ITEM_TYPE.THEME == msgType) {
+ if (common.MSG_ITEM_TYPE.THEME == msgType) {
flage = true;
}
- if(common.MSG_ITEM_TYPE.TEXT == msgType && item.content != common.string.EMPTY_STR) {
+ if (common.MSG_ITEM_TYPE.TEXT == msgType && item.content != common.string.EMPTY_STR) {
flage = true;
}
- if((common.MSG_ITEM_TYPE.IMAGE == msgType || common.MSG_ITEM_TYPE.AUDIO == msgType
+ if ((common.MSG_ITEM_TYPE.IMAGE == msgType || common.MSG_ITEM_TYPE.AUDIO == msgType
|| common.MSG_ITEM_TYPE.VIDEO == msgType) && item.content != common.string.EMPTY_STR) {
flage = true;
}
@@ -150,9 +148,9 @@ export default {
},
judgeIsImage(mmsSource) {
let flage = false;
- for(let item of mmsSource) {
+ for (let item of mmsSource) {
let msgType = item.msgType;
- if(common.MSG_ITEM_TYPE.IMAGE == msgType) {
+ if (common.MSG_ITEM_TYPE.IMAGE == msgType) {
flage = true;
}
}
@@ -180,12 +178,12 @@ export default {
},
judgeIsAttachment(mmsSource) {
let flage = false;
- if(mmsSource == null || mmsSource.length == 0) {
+ if (mmsSource == null || mmsSource.length == 0) {
return flage;
}
- for(let item of mmsSource) {
+ for (let item of mmsSource) {
let msgType = item.msgType;
- if(common.MSG_ITEM_TYPE.IMAGE == msgType || common.MSG_ITEM_TYPE.VIDEO == msgType
+ if (common.MSG_ITEM_TYPE.IMAGE == msgType || common.MSG_ITEM_TYPE.VIDEO == msgType
|| common.MSG_ITEM_TYPE.AUDIO == msgType) {
flage = true;
}
diff --git a/entry/src/main/ets/default/service/ContractService.ets b/entry/src/main/ets/service/ContractService.ets
similarity index 77%
rename from entry/src/main/ets/default/service/ContractService.ets
rename to entry/src/main/ets/service/ContractService.ets
index 709ae69..d3c1753 100644
--- a/entry/src/main/ets/default/service/ContractService.ets
+++ b/entry/src/main/ets/service/ContractService.ets
@@ -13,29 +13,29 @@
* limitations under the License.
*/
-import HiLog from '../utils/HiLog';
-import ContactsModel from '../model/ContactsModel';
-import common from '../data/commonData';
-import telephoneUtil from '../utils/TelephoneUtil';
-import LooseObject from '../data/LooseObject'
+import HiLog from "../utils/HiLog";
+import ContactsModel from "../model/ContactsModel";
+import common from "../data/commonData";
+import telephoneUtil from "../utils/TelephoneUtil";
+import LooseObject from "../data/LooseObject"
-const TAG = 'ContractService';
+const TAG = "ContractService";
let mContactsModel = new ContactsModel();
export default {
/**
- * 查询联系人列表
- * @param actionData 入参
- * @return 结果集
+ * Querying the Contact List
+ * @param actionData
+ * @return
*/
queryContact(actionData, callback) {
- // 获取rawContractIds,去查询联系人
+ // Obtain rawContractIds and query contacts.
mContactsModel.queryContact(actionData, rawContractIds => {
let result: LooseObject = {};
actionData.contractIds = rawContractIds;
- // 根据rawContractIds
+ // Based on rawContractIds
mContactsModel.queryContactDataByIds(actionData, contracts => {
result.code = common.int.SUCCESS;
this.convertContracts(contracts, messageList => {
@@ -47,12 +47,12 @@ export default {
},
/**
- * 统计联系人的行数
- * @param actionData 入参
- * @return 结果集
+ * Counting the number of rows of contacts
+ * @param actionData
+ * @return
*/
countContact(actionData, callback) {
- // 获取rawContractIds,去查询联系人
+ // Obtain rawContractIds and query contacts.
mContactsModel.countContact(actionData, count => {
let result: LooseObject = {};
result.code = common.int.SUCCESS;
@@ -62,16 +62,16 @@ export default {
},
/**
- * 转换联系人参数
- * @param contracts 联系人列表
- * @return 转换后的数据
+ * Convert Contact Parameters
+ * @param contracts
+ * @return
*/
async convertContracts(contracts, callback) {
let messageList = [];
for (let contract of contracts) {
let item: LooseObject = {};
item.contactName = contract.displayName;
- item.headImage = 'icon/user_avatar_full_fill.svg';
+ item.headImage = "icon/user_avatar_full_fill.svg";
item.telephone = contract.detailInfo;
item.telephoneFormat = contract.detailInfo;
item.select = false;
@@ -81,9 +81,9 @@ export default {
},
/**
- * 处理联系人参数
- * @param contactObjects 联系人数据
- * @return 解析出来的参数
+ * Process Contact Parameters
+ * @param contactObjects
+ * @return
*/
dealContractParams(contactObjects) {
if (contactObjects && contactObjects != common.string.EMPTY_STR) {
@@ -114,19 +114,19 @@ export default {
},
/**
- * 根据手机号,查询联系人
- * @param actionData 参数
- * @param callback 回调
+ * Query a contact by mobile number.
+ * @param actionData
+ * @param callback
*/
queryContactDataByTelephone(actionData, callback) {
mContactsModel.queryContactDataByTelephone(actionData, contracts => {
- HiLog.i(TAG, 'queryContactDataByTelephone, success');
+ HiLog.i(TAG, "queryContactDataByTelephone, success");
callback(contracts);
})
},
/**
- * 模糊查询联系人
+ * Fuzzy Search for Contacts
* @param actionData
* @param callback
*/
@@ -134,7 +134,7 @@ export default {
let result: LooseObject = {};
mContactsModel.searchContracts(actionData, res => {
result.code = res.code
- if(res.code == common.int.SUCCESS) {
+ if (res.code == common.int.SUCCESS) {
result.response = this.dealSearchContracts(res.abilityResult);
callback(result);
}
@@ -142,9 +142,9 @@ export default {
},
dealSearchContracts(contracts) {
let searchContracts = []
- for(let item of contracts) {
+ for (let item of contracts) {
let searchContract: LooseObject = {};
- searchContract.headImage = 'icon/user_avatar_full_fill.svg';
+ searchContract.headImage = "icon/user_avatar_full_fill.svg";
searchContract.contactName = item.displayName;
searchContract.telephone = item.detailInfo;
searchContract.telephoneFormat = item.detailInfo;
@@ -154,13 +154,13 @@ export default {
},
/**
- * 判断是否存在名片
+ * Check whether a business card exists.
*
- * @param {Object} actionData 数据
- * @param {Object} callback 回调函数
+ * @param {Object} actionData
+ * @param {Object} callback
*/
judgeIsExitProfile(actionData, callback) {
- HiLog.i(TAG, 'judgeIsExitProfile, start');
+ HiLog.i(TAG, "judgeIsExitProfile, start");
mContactsModel.queryProfile(actionData, res => {
let result = false;
if (res > 0) {
diff --git a/entry/src/main/ets/default/service/ConversationListService.ets b/entry/src/main/ets/service/ConversationListService.ets
similarity index 71%
rename from entry/src/main/ets/default/service/ConversationListService.ets
rename to entry/src/main/ets/service/ConversationListService.ets
index 13a3451..d37d386 100644
--- a/entry/src/main/ets/default/service/ConversationListService.ets
+++ b/entry/src/main/ets/service/ConversationListService.ets
@@ -13,37 +13,37 @@
* limitations under the License.
*/
-// log 工具类
-import HiLog from '../utils/HiLog';
-// 公共常量
-import common from '../data/commonData';
+// log Tools
+import HiLog from "../utils/HiLog";
+// Common constants
+import common from "../data/commonData";
-// 获取假数据
-import ConversationListModel from '../model/ConversationListModel';
+// Obtain fake data.
+import ConversationListModel from "../model/ConversationListModel";
let conversationListModel = new ConversationListModel();
-import conversationService from './ConversationService';
-import contractService from './ContractService';
-import commonService from './CommonService';
-import telephoneUtils from '../utils/TelephoneUtil';
-import LooseObject from '../data/LooseObject'
+import conversationService from "./ConversationService";
+import contractService from "./ContractService";
+import commonService from "./CommonService";
+import telephoneUtils from "../utils/TelephoneUtil";
+import LooseObject from "../data/LooseObject"
-const TAG = 'ConversationListService';
+const TAG = "ConversationListService";
export default {
/**
- * 查询列表数据
- * @param actionData 查询参数
- * @param tableName 表明
+ * Querying List Data
+ * @param actionData
+ * @param tableName
* @return
*/
querySessionList(actionData, callback) {
- // 查询数据列表
+ // Querying Data Lists
let result: LooseObject = {};
let queryPromise = conversationListModel.querySessionList(actionData);
- // 获取总的条数
+ // Obtains the total number of records.
let countPromise = conversationListModel.countSessionList(actionData);
- // 判断通知信息是否存在
+ // Check whether the notification information exists.
let notificationPromise = new Promise((resolve) => {
this.judgeIsNotificationData(res => {
resolve(res);
@@ -54,16 +54,16 @@ export default {
let telephones = [];
let messageList = this.convertSessionList(res[0].response, telephones);
result.total = res[1].total;
- result.showInfoDivWhenSearchFlag = res[2];
+ result.hasInfoMsg = res[2];
HiLog.i(TAG, "querySessionList, messageList length=" + messageList.length
- + ", total=" + result.total + ", showInfoDivWhenSearchFlag=" + result.showInfoDivWhenSearchFlag);
+ + ", total=" + result.total + ", hasInfoMsg=" + result.hasInfoMsg);
this.dealContactsName(telephones, actionData, messageList, sessionList => {
- HiLog.i(TAG, 'querySessionList, dealContactsName len=' + sessionList.length);
+ HiLog.i(TAG, "querySessionList, dealContactsName len=" + sessionList.length);
result.response = sessionList;
callback(result);
});
}).catch((err) => {
- HiLog.e(TAG, 'querySessionList, error: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "querySessionList, error: " + JSON.stringify(err.message));
result.code = common.int.FAILURE;
callback(result);
});
@@ -77,10 +77,11 @@ export default {
item.content = session.content;
item.countOfUnread = session.unreadCount;
if (session.smsType == 0) {
- item.icon = 'icon/user_avatar_full_fill.svg';
+ item.icon = "icon/user_avatar_full_fill.svg";
} else {
- item.icon = 'icon/entrance_icon01.svg';
+ item.icon = "icon/entrance_icon01.svg";
}
+ item.smsType = session.smsType;
item.isCbChecked = false;
item.isLock = false;
item.sendingFailed = session.sendStatus == common.int.SEND_MESSAGE_FAILED ? true : false;
@@ -108,17 +109,17 @@ export default {
},
dealContactsName(telephones, actionData, sessionLists, callback) {
actionData.telephones = telephones;
- if(telephones.length == 0) {
- HiLog.w(TAG, 'dealContactsName, has no 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');
+ if (contacts.length == 0) {
+ HiLog.w(TAG, "dealContactsName, has no contacts");
callback(sessionLists);
} else {
- // 将结果转换为Map,key:手机号,value: 名称
+ // Convert the result to Map, key: mobile number, value: name
let telephoneMap = this.getTelephoneMap(contacts);
this.buildName(sessionLists, telephoneMap);
callback(sessionLists);
@@ -127,7 +128,7 @@ export default {
},
getTelephoneMap(contacts) {
let telephoneMap = new Map();
- for(let item of contacts) {
+ for (let item of contacts) {
if (item.displayName == common.string.EMPTY_STR) {
telephoneMap.set(item.detailInfo, item.detailInfo);
} else {
@@ -137,9 +138,9 @@ export default {
return telephoneMap;
},
buildName(sessionLists, telephoneMap) {
- // 将结果根据手机号进行匹配
+ // Match the result based on the mobile number.
for (let session of sessionLists) {
- // 多人名称的组合,名称是需要组合展示
+ // Indicates the combination of multiple names. The names need to be displayed in combination.
if (session.contactsNum > 1) {
this.dealMultiName(session, telephoneMap);
} else if (telephoneMap.has(session.telephone)) {
@@ -150,8 +151,8 @@ export default {
dealMultiName(session, telephoneMap) {
let telephones = session.telephone.split(common.string.COMMA);
let name = common.string.EMPTY_STR;
- for(let telephone of telephones) {
- if(telephoneMap.has(telephone)) {
+ for (let telephone of telephones) {
+ if (telephoneMap.has(telephone)) {
name = name + telephoneMap.get(telephone) + common.string.COMMA;
} else {
name = name + telephone + common.string.COMMA;
@@ -161,8 +162,8 @@ export default {
},
/**
- * 判断是否存在通知信息的数据
- * @param callback 返回
+ * Check whether notification data exists.
+ * @param callback
*/
judgeIsNotificationData(callback) {
let param = {
@@ -171,7 +172,7 @@ export default {
page: 1
};
this.querySessionByNumberType(param, res => {
- if(res.code == common.int.SUCCESS && res.response.length > 0) {
+ if (res.code == common.int.SUCCESS && res.response.length > 0) {
callback(true);
} else {
callback(false);
@@ -180,9 +181,9 @@ export default {
},
/**
- * 统计数据
- * @param actionData 参数
- * @param callBack 回调
+ * statistical data
+ * @param actionData
+ * @param callBack
* @return
*/
statisticalData(actionData, callBack) {
@@ -194,7 +195,7 @@ export default {
result.response = res.abilityResult;
resolve(result.response);
} else {
- HiLog.w(TAG, 'statisticalData, failed');
+ HiLog.w(TAG, "statisticalData, failed");
}
});
});
@@ -207,17 +208,17 @@ export default {
let normalResult = res[0];
let notifyResult = res[1];
let response = {
- 'totalListCount': normalResult.totalListCount,
- 'unreadCount': (normalResult.totalListCount - notifyResult),
- 'unreadTotalOfInfo': notifyResult
+ "totalListCount": normalResult.totalListCount,
+ "unreadCount": (normalResult.totalListCount - notifyResult),
+ "unreadTotalOfInfo": notifyResult
}
let result = {
code: common.int.SUCCESS,
response: response
}
callBack(result);
- }).then(err => {
- HiLog.e(TAG, 'statisticalData, failed: ' + JSON.stringify(err));
+ }).catch(err => {
+ HiLog.e(TAG, "statisticalData, failed: " + JSON.stringify(err));
let result = {
code: common.int.FAILURE
}
@@ -227,53 +228,57 @@ export default {
},
/**
- * 根据主键ID,删除数据
- * @param threadIds 会话ID
+ * Delete data based on the primary key ID.
+ * @param threadIds Session ID
* @return
*/
deleteMessageById(actionData) {
- // 删除会话列表的数据
+ // Deletes data from the session list.
conversationListModel.deleteMessageById(actionData.threadIds);
- // 删除信息列表的数据
+ // Deletes data from the information list.
conversationService.deleteMessageBySessionIds(actionData);
},
/**
- * 根据主键ID,删除数据
- * @param threadIds 会话ID
+ * Delete data based on the primary key ID.
+ * @param threadIds Session ID
*/
deleteMessageBySessionId(threadIds) {
- // 删除会话列表的数据
+ // Deletes data from the session list.
conversationListModel.deleteMessageById(threadIds);
+ globalThis.needToUpdate = true;
},
/**
- * 根据主键ID,更新数据
- * @param threadIds 会话ID
+ * Update data based on the primary key ID.
+ * @param threadIds Session ID
* @return
*/
updateById(threadIds, valueBucket) {
conversationListModel.updateById(threadIds, valueBucket);
+ globalThis.needToUpdate = true;
},
/**
- * 标记已读短信
- * @param threadIds 会话ID
- * @param valueBucket 标记已读的数量
+ * Marking a read SMS message
+ * @param threadIds Session ID
+ * @param valueBucket Number of Marked Reads
* @return
*/
markAllAsRead(actionData) {
- if(actionData.threadIds.length == 0) {
+ if (actionData.threadIds.length == 0) {
return;
}
- // 会话列表上的标记已读
+ // Tag on session list read
conversationListModel.markAllAsRead(actionData.threadIds, actionData.valueBucket);
- // 短信信息的已读
+ // SMS message read
conversationService.markAllAsRead(actionData);
},
/**
- * 更新所有未读信息为已读
+ * Updates all unread information to read.
+
+
* @param actionData
*/
markAllToRead(actionData) {
@@ -288,101 +293,111 @@ export default {
* @return
*/
insertSession(valueBucket, callback) {
- conversationListModel.insertSession(common.tableName.SESSION, valueBucket, res => {
+ conversationListModel.insertSession(valueBucket, res => {
callback(res);
});
},
/**
- * 新增会话草稿列表
- * @param valueBucket 新增的数据
- * @param callback 回调
+ * Adding a session draft list
+ * @param valueBucket New Data
+ * @param callback Callback
* @return
*/
- insertSessionDraft(actionData) {
+ insertSessionDraft(actionData, callback) {
let param = this.dealSendResults(actionData);
- // 先判断是否创建过会话列表
+ // Check whether a session list has been created
this.querySessionByTelephone(param.telephone, res => {
let response = res.response;
if(res.code == common.int.SUCCESS && response.id <= 0) {
- this.dealInsertSession(param, actionData);
+ // If you modify the recipient in draft state and save the modification again, you need to delete the
+ // unnecessary session draft before modification.
+ if (actionData.threadId != 0) {
+ conversationListModel.deleteMessageById([actionData.threadId]);
+ }
+ this.dealInsertSession(param, actionData, callback);
} else {
- this.deleteDraftDataOrUpdate(actionData, response, param);
+ this.deleteDraftDataOrUpdate(actionData, response, param, callback);
}
+ globalThis.needToUpdate = true;
});
},
- dealInsertSession(param, actionData) {
+ dealInsertSession(param, actionData, callback) {
let valueBucket = {
- 'telephone': param.telephone,
- 'content': param.content,
- 'contacts_num': param.contractsNum,
- 'sms_type': param.smsType,
- 'unread_count': 0,
- 'sending_status': 1,
- 'has_draft': 1,
- 'time': param.timestamp,
- 'has_mms': param.hasMms,
- 'has_attachment': param.hasAttachment,
+ "telephone": param.telephone,
+ "content": param.content,
+ "contacts_num": param.contractsNum,
+ "sms_type": param.smsType,
+ "unread_count": 0,
+ "sending_status": 1,
+ "has_draft": 1,
+ "time": param.timestamp,
+ "has_mms": param.hasMms,
+ "has_attachment": param.hasAttachment,
}
this.insertSession(valueBucket, sessionResult => {
- // 这里调用短信数据库,插入短信信息
+ // Invoke the SMS database to insert SMS messages.
let sessionId = sessionResult.rowId;
conversationService.dealInsertMessageDetail(param, actionData, sessionId, res => {
+ callback();
});
});
},
- deleteDraftDataOrUpdate(actionData, response, param) {
- if(actionData.groupId > 0) {
+ deleteDraftDataOrUpdate(actionData, response, param, callback) {
+ if (actionData.groupId > 0) {
let groupIds = [actionData.groupId];
actionData.groupIds = groupIds;
- // 先删除原来的草稿
+ // Delete the original draft first.
conversationService.deleteMessageByGroupIds(actionData);
}
- if(actionData.content != common.string.EMPTY_STR || actionData.mmsSource.length > 0) {
- // 存入新的草稿
- this.updateDraftData(response, param, actionData);
+ if (actionData.content != common.string.EMPTY_STR || actionData.mmsSource.length > 0) {
+ // Save New Draft
+ this.updateDraftData(response, param, actionData, callback);
+ } else {
+ callback();
}
},
- updateDraftData(response, param ,actionData) {
+ updateDraftData(response, param, actionData, callback) {
let sessionId = response.id;
- // 这里调用短信数据库,插入短信信息
+ // Invoke the SMS database to insert SMS messages.
let threadIds = [sessionId];
let time = new Date();
let valueBucket = {
- 'content': param.content,
- 'has_draft': 1,
- 'time': time.getTime(),
- 'has_attachment': param.hasAttachment,
- 'has_mms': param.hasMms,
+ "content": param.content,
+ "has_draft": 1,
+ "time": time.getTime(),
+ "has_attachment": param.hasAttachment,
+ "has_mms": param.hasMms,
}
this.updateById(threadIds, valueBucket);
conversationService.dealInsertMessageDetail(param, actionData, sessionId, res => {
+ callback();
});
},
dealSendResults(actionData) {
let contractsNum = 1;
let telephone = common.string.EMPTY_STR;
- if(actionData.isNewMsg) {
+ if (actionData.isNewMsg) {
let selectContacts = actionData.selectContacts;
- if(selectContacts.length > 1) {
- for(let contact of selectContacts) {
+ if (selectContacts.length > 1) {
+ for (let contact of selectContacts) {
telephone = telephone + contact.telephone + common.string.COMMA;
}
- // 如果失败,那会话列表结果就是失败
- telephone = telephone.substring(0, telephone.length-1);
+ // If it fails, then the session list turns out to be a failure.
+ telephone = telephone.substring(0, telephone.length - 1);
contractsNum = selectContacts.length;
} else if (selectContacts.length == 1) {
telephone = selectContacts[0].telephone;
}
let receiveContactValue = actionData.receiveContactValue;
- if(receiveContactValue != common.string.EMPTY_STR) {
+ if (receiveContactValue != common.string.EMPTY_STR) {
telephone = actionData.receiveContactValue;
}
} else {
telephone = actionData.telephone;
}
let smsType = 0;
- if(contractsNum == 1 && telephoneUtils.judgeIsInfoMsg(telephone)) {
+ if (contractsNum == 1 && telephoneUtils.judgeIsInfoMsg(telephone)) {
smsType = 1;
}
let sendResult = {
@@ -396,7 +411,7 @@ export default {
result.contractsNum = contractsNum;
result.telephone = telephoneUtils.dealTelephoneSort(telephone);
result.content = actionData.content;
- if(actionData.isMms) {
+ if (actionData.isMms) {
result.content = commonService.getMmsContent(actionData.mmsSource);
}
result.sendStatus = 1;
@@ -408,8 +423,8 @@ export default {
},
/**
- * 根据手机号查询会话列表
- * @param telephone 手机号
+ * Querying the session list by mobile number
+ * @param telephone
* @return
*/
querySessionByNumberType(actionData, callback) {
@@ -421,32 +436,32 @@ export default {
HiLog.i(TAG, "querySessionList SUCCESS. len=" + result.response.length);
callback(result);
}).catch((err) => {
- HiLog.e(TAG, 'querySessionByNumberType, error: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "querySessionByNumberType, error: " + JSON.stringify(err.message));
result.code = common.int.FAILURE;
callback(result);
});
},
/**
- * 根据手机号查询会话列表
- * @param telephone 手机号
+ * Querying the session list by mobile number
+ * @param telephone
* @return
*/
querySessionByTelephone(telephone, callback) {
let result: LooseObject = {};
- if(telephone == null) {
- HiLog.w(TAG, 'querySessionByTelephone, telephone == null')
+ if (telephone == null) {
+ HiLog.w(TAG, "querySesByTele, telephone == null")
result.code = common.int.FAILURE;
callback(result);
} else {
- HiLog.i(TAG, 'querySessionByTelephone, telephone != null')
+ HiLog.i(TAG, "querySesByTele, telephone != null")
let queryPromise = conversationListModel.querySessionByTelephone(telephone);
Promise.all([queryPromise]).then((res) => {
result.code = common.int.SUCCESS;
result.response = res[0];
callback(result);
}).catch((err) => {
- HiLog.e(TAG, ', querySessionByTelephone, error: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "querySesByTele, error: " + JSON.stringify(err.message));
result.code = common.int.FAILURE;
callback(result);
});
@@ -454,20 +469,20 @@ export default {
},
/**
- * 根据手机号查询会话列表
- * @param telephone 手机号
+ * Querying the session list by mobile number
+ * @param telephone
* @return
*/
querySessionById(threadId, callback) {
let result: LooseObject = {};
- HiLog.i(TAG, 'querySessionById, threadId:' + threadId);
+ HiLog.i(TAG, "querySessionById, threadId:" + threadId);
let queryPromise = conversationListModel.querySessionById(threadId);
Promise.all([queryPromise]).then((res) => {
result.code = common.int.SUCCESS;
result.response = res[0];
callback(result);
}).catch((err) => {
- HiLog.e(TAG, 'querySessionById, error: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "querySessionById, error: " + JSON.stringify(err.message));
result.code = common.int.FAILURE;
callback(result);
});
@@ -486,7 +501,7 @@ export default {
}
conversationService.queryMessageDetail(actionData, res => {
if (res.code == common.int.SUCCESS && res.response.length > 0) {
- count ++;
+ count++;
actionData.mmsList = res.response;
this.updateLastItemContent(actionData);
}
@@ -507,23 +522,23 @@ export default {
hasAttachment = true;
}
let valueBucket = {
- 'content': content,
- 'sending_status': item.sendStatus,
- 'has_mms': item.isMsm ? 1 : 0,
- 'has_attachment': hasAttachment ? 1 : 0,
- 'message_count': length,
- 'unread_count': 0
+ "content": content,
+ "sending_status": item.sendStatus,
+ "has_mms": item.isMsm ? 1 : 0,
+ "has_attachment": hasAttachment ? 1 : 0,
+ "message_count": length,
+ "unread_count": 0
};
this.updateById(threadIds, valueBucket);
},
/**
- * 搜索
- * @param actionData 参数
- * @param callback 回调
+ * search
+ * @param actionData Parameters
+ * @param callback Callback
* @return
*/
searchMessageWithLike(actionData, callback) {
- // 会话详情搜索数据
+ // Session Details Search Data
let searchText = actionData.inputValue;
let sessionListPromise = new Promise((resolve, reject) => {
this.searchSessionByTelephone(actionData, res => {
@@ -534,7 +549,7 @@ export default {
}
});
});
- // 信息列表搜索的数据
+ // Information List Search Data
let contentListPromise = new Promise((resolve, reject) => {
conversationService.searchMessageByContent(actionData, res => {
if (res.code === common.int.SUCCESS) {
@@ -546,7 +561,7 @@ export default {
});
let resultMap: LooseObject = {};
let result: LooseObject = {};
- Promise.all([sessionListPromise,contentListPromise]).then((res) => {
+ Promise.all([sessionListPromise, contentListPromise]).then((res) => {
result.code = common.int.SUCCESS;
resultMap.sessionList = res[0];
resultMap.contentList = res[1];
@@ -554,15 +569,15 @@ export default {
result.search = searchText;
callback(result);
}).catch((err) => {
- HiLog.e(TAG, 'searchMessageWithLike, error: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "searchMessageWithLike, error: " + JSON.stringify(err.message));
result.code = common.int.FAILURE;
callback(result);
});
},
/**
- * 根据手机号模糊匹配会话列表
- * @param actionData 数据库实例
+ * Fuzzy match of the session list based on the mobile number
+ * @param actionData Database instance
*/
async searchSessionByTelephone(actionData, callback) {
let result: LooseObject = {};
@@ -578,7 +593,7 @@ export default {
callback(result);
});
}).catch((err) => {
- HiLog.e(TAG, 'searchSessionByTelephone, error: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "searchSessionByTelephone, error: " + JSON.stringify(err.message));
result.code = common.int.FAILURE;
callback(result);
});
@@ -600,9 +615,9 @@ export default {
let index = 0;
for (let name of names) {
nameFormatter += (name == null || name == common.string.EMPTY_STR ? telephones[index] : name);
- nameFormatter += '<';
+ nameFormatter += "<";
nameFormatter += telephoneFormats[index];
- nameFormatter += '>';
+ nameFormatter += ">";
if (index < telephones.length - 1) {
nameFormatter += common.string.COMMA;
}
diff --git a/entry/src/main/ets/default/service/ConversationService.ets b/entry/src/main/ets/service/ConversationService.ets
similarity index 76%
rename from entry/src/main/ets/default/service/ConversationService.ets
rename to entry/src/main/ets/service/ConversationService.ets
index 110777f..6059b83 100644
--- a/entry/src/main/ets/default/service/ConversationService.ets
+++ b/entry/src/main/ets/service/ConversationService.ets
@@ -13,19 +13,18 @@
* limitations under the License.
*/
-import ContactsModel from '../model/ContactsModel';
-import ConversationModel from '../model/ConversationModel';
-import common from '../data/commonData';
-import HiLog from '../utils//HiLog';
+import ContactsModel from "../model/ContactsModel";
+import ConversationModel from "../model/ConversationModel";
+import common from "../data/commonData";
+import HiLog from "../utils//HiLog";
+import conversationListService from "./ConversationListService";
+import telephoneUtils from "../utils/TelephoneUtil";
+import contractService from "./ContractService";
+import commonService from "./CommonService";
+import LooseObject from "../data/LooseObject"
+import MmsPreferences from "../utils/MmsPreferences";
-import conversationListService from './ConversationListService';
-import telephoneUtils from '../utils/TelephoneUtil';
-import contractService from './ContractService';
-import commonService from './CommonService';
-import LooseObject from '../data/LooseObject'
-import preferences from '../utils/PreferencesUtil';
-
-const TAG = 'ConversationService';
+const TAG = "ConversationService";
let mContactsModel = new ContactsModel();
let mConversationModel = new ConversationModel();
@@ -33,17 +32,17 @@ let mConversationModel = new ConversationModel();
export default {
/**
- * 判断联系人是否存在
- * @param params 联系人电话号码
- * @param callback 联系人是否存在
+ * Check whether a contact exists.
+ * @param params Contact Phone Number
+ * @param callback Whether the contact exists
* @return
*/
judgeContactExists(params, callback) {
mContactsModel.queryContactDataByTelephone(params, function (result) {
let hasExitContract = false;
if (result.length >= 1) {
- // 联系人是否存在
- HiLog.i(TAG, 'judgeContactExists, queryContactDataByTelephone success');
+ // Whether the contact exists
+ HiLog.i(TAG, "judgeContactExists, queryContactDataByTelephone success");
hasExitContract = true;
}
callback(hasExitContract);
@@ -51,16 +50,15 @@ export default {
},
/**
- * 获取信息详情
- * @param params 电话号码/会话id
- * @param callback 返回信息内容
+ * Obtain information details.
+ * @param params Phone Number/Session ID
+ * @param callback
* @return
*/
queryMessageDetail(actionData, callback) {
let result: LooseObject = {};
- HiLog.i(TAG, 'queryMessageDetail, start');
mConversationModel.queryMessageDetail(actionData, res => {
- HiLog.i(TAG, 'queryMessageDetail, queryMessageDetail success')
+ HiLog.i(TAG, "queryMessageDetail, queryMessageDetail success")
result.code = res.code;
if (res.code == common.int.SUCCESS) {
this.groupDetailMessage(res.abilityResult, actionData, resultList => {
@@ -68,7 +66,7 @@ export default {
callback(result);
});
} else {
- HiLog.w(TAG, 'groupDetailMessage, failed');
+ HiLog.w(TAG, "groupDetailMessage, failed");
callback(result);
}
});
@@ -81,15 +79,15 @@ export default {
result.content = item.msgContent;
result.isLock = item.isLock == 0 ? false : true;
result.isStared = item.isCollect == 0 ? false : true;
- // 彩信相关字段
+ // Fields related to MMS messages
result.msgType = 0;
result.isFullScreenImg = true;
- result.read = item.isRead == 0 ? '0' : '1';
+ result.read = item.isRead == 0 ? "0" : "1";
if (item.msgState == 0) {
result.sendStatus = common.int.SEND_MESSAGE_SUCCESS;
} else if (item.msgState == 2) {
result.sendStatus = common.int.SEND_MESSAGE_FAILED;
- } else if (item.msgState == 1){
+ } else if (item.msgState == 1) {
result.sendStatus = common.int.SEND_MESSAGE_SENDING;
} else {
result.sendStatus = common.int.SEND_DRAFT;
@@ -99,9 +97,9 @@ export default {
result.isMsm = item.msgType == 0 ? false : true;
result.isCbChecked = false;
result.isDraft = false;
- // 群发相关字段
+ // Fields related to group-sending
result.groupId = item.groupId;
- // 判断是接收方还是发送方
+ // Determine whether it is the receiver or sender.
result.isReceive = item.isSender == 0 ? false : true;
result.date = common.string.EMPTY_STR;
result.time = common.string.EMPTY_STR;
@@ -130,9 +128,9 @@ export default {
return;
}
let resultList = [];
- // 需要根据groupId 进行分组
+ // Group by groupId.
let detailMap = this.convertConversationMap(details);
- // 根据组进行
+ // By group
let groupIds = detailMap.keys();
for (let groupId of groupIds) {
let groups = detailMap.get(groupId);
@@ -181,7 +179,7 @@ export default {
for (let item of resultList) {
if (mmsPartMap.has(item.id)) {
let mmsParts = mmsPartMap.get(item.id);
- // 判断是否需要展示 0 普通样式, 1 主题, 2幻灯片,
+ // Determine whether to display 0 common style, 1 theme, and 2 slides,
item.mms = commonService.getMmsSource(mmsParts);
item.msgShowType = commonService.getDisplay(item.mms);
commonService.setItemMmsContent(item, item.mms);
@@ -192,7 +190,7 @@ export default {
},
convertConversationMap(details) {
let conversationMap = new Map();
- // 分组
+ // grouping
for (let element of details) {
if (conversationMap.has(element.groupId)) {
let groups = conversationMap.get(element.groupId);
@@ -207,22 +205,22 @@ export default {
},
/**
- * 插入会话详情及短信详情
- * @param sendResults 发送结果
- * @param threadId 会话列表ID
- * @param isReceive 是否接收
+ * Inserting Session Details and SMS Details
+ * @param sendResults Sending result
+ * @param threadId Session List ID
+ * @param isReceive Received or not
* @return
*/
insertSessionAndDetail(actionData, callback) {
- HiLog.i(TAG,'insertSessionAndDetail, start');
+ HiLog.i(TAG, "insertSessionAndDetail, start");
let sendResults = actionData.sendResults;
let isReceive = actionData.isReceive;
if (sendResults.length == 0) {
- HiLog.w(TAG,'insertSessionAndDetail, sendResults.length == 0');
+ HiLog.w(TAG, "insertSessionAndDetail, sendResults.length == 0");
return;
}
let param = this.dealSendResults(sendResults);
- // 先判断是否创建过会话列表
+ // Check whether a session list has been created.
conversationListService.querySessionByTelephone(param.telephone, res => {
let response = res.response;
if (res.code == common.int.SUCCESS && response.id <= 0) {
@@ -238,21 +236,21 @@ export default {
unreadCount = 1;
}
let valueBucket = {
- 'telephone': param.telephone,
- 'content': param.content,
- 'contacts_num': param.contractsNum,
- 'sms_type': param.smsType,
- 'unread_count': unreadCount,
- 'sending_status': param.sendStatus,
- 'has_draft': 0,
- 'time': param.timestamp,
- 'message_count': 1,
- 'has_mms': actionData.isMms ? 1 : 0,
- 'has_attachment': actionData.hasAttachment ? 1 : 0
+ "telephone": param.telephone,
+ "content": param.content,
+ "contacts_num": param.contractsNum,
+ "sms_type": param.smsType,
+ "unread_count": unreadCount,
+ "sending_status": param.sendStatus,
+ "has_draft": 0,
+ "time": param.timestamp,
+ "message_count": 1,
+ "has_mms": actionData.isMms ? 1 : 0,
+ "has_attachment": actionData.hasAttachment ? 1 : 0
}
conversationListService.insertSession(valueBucket, sessionResult => {
- HiLog.i(TAG, 'dealNoExitingSession, insertSession callback')
- // 这里调用短信数据库,插入短信信息
+ HiLog.i(TAG, "dealNoExitingSession, insertSession callback")
+ // Invoke the SMS database to insert SMS messages.
this.dealInsertMessageDetail(param, actionData, sessionResult.rowId, res => {
let result = {
rowId: sessionResult.rowId,
@@ -264,9 +262,9 @@ export default {
});
},
dealExitingSession(response, param, actionData, callback) {
- HiLog.i(TAG, 'dealExitingSession')
+ HiLog.i(TAG, "dealExitingSession")
let sessionId = response.id;
- // 这里调用短信数据库,插入短信信息
+ // Invoke the SMS database to insert SMS messages.
let threadIds = [sessionId];
let time = new Date();
let unreadCount = 0;
@@ -281,17 +279,17 @@ export default {
let messageCount = response.messageCount;
messageCount = messageCount + 1;
let valueBucket = {
- 'content': param.content,
- 'unread_count': unreadCount,
- 'time': time.getTime(),
- 'sending_status': param.sendStatus,
- 'has_draft': hasDraft,
- 'message_count': messageCount,
- 'has_attachment': actionData.hasAttachment ? 1 : 0,
- 'has_mms': actionData.isMms ? 1 : 0,
+ "content": param.content,
+ "unread_count": unreadCount,
+ "time": time.getTime(),
+ "sending_status": param.sendStatus,
+ "has_draft": hasDraft,
+ "message_count": messageCount,
+ "has_attachment": actionData.hasAttachment ? 1 : 0,
+ "has_mms": actionData.isMms ? 1 : 0,
}
conversationListService.updateById(threadIds, valueBucket);
- // 这里调用短信数据库,插入短信信息
+ // Invoke the SMS database to insert SMS messages.
this.dealInsertMessageDetail(param, actionData, sessionId, res => {
let result = {
rowId: sessionId,
@@ -302,15 +300,15 @@ export default {
});
},
dealInsertMessageDetail(param, actionData, threadId, callback) {
- HiLog.i(TAG, 'dealInsertMessageDetail')
+ HiLog.i(TAG, "dealInsertMessageDetail")
this.queryMaxGroupId(actionData, res => {
let maxGroupId = 0;
if (res.code === common.int.SUCCESS) {
- HiLog.i(TAG, 'dealInsertMessageDetail, queryMaxGroupId maxGroupId=' + res.response.maxGroupId)
+ HiLog.i(TAG, "dealInsertMessageDetail, queryMaxGroupId maxGroupId=" + res.response.maxGroupId)
maxGroupId = res.response.maxGroupId == common.string.EMPTY_STR ? 0 : Number(res.response.maxGroupId);
maxGroupId = maxGroupId + 1;
} else {
- HiLog.w(TAG,'dealInsertMessageDetail, queryMaxGroupId failed');
+ HiLog.w(TAG, "dealInsertMessageDetail, queryMaxGroupId failed");
callback();
}
this.insertMessageDetailByMaxGroupId(param, actionData, threadId, maxGroupId, result => {
@@ -345,7 +343,7 @@ export default {
insertDetail.time = sendResult.time;
}
this.insertMessageDetail(insertDetail, id => {
- HiLog.d(TAG, 'insertMessageDetailByMaxGroupId, insertMessageDetail id=' + id);
+ HiLog.d(TAG, "insertMessageDetailByMaxGroupId, insertMessageDetail id=" + id);
count++;
let initData = {
id: id,
@@ -360,7 +358,7 @@ export default {
})
},
initInsertDetail(param, actionData, threadId, maxGroupId) {
- HiLog.i(TAG, 'initInsertDetail')
+ HiLog.i(TAG, "initInsertDetail")
let insertDetail: LooseObject = {
receiverNumber: common.string.EMPTY_STR,
senderNumber: common.string.EMPTY_STR,
@@ -380,11 +378,11 @@ export default {
return insertDetail;
},
dealSendResults(sendResults) {
- HiLog.i(TAG, 'dealSendResults')
+ HiLog.i(TAG, "dealSendResults")
let contractsNum = sendResults.length;
let telephone = common.string.EMPTY_STR;
let content = common.string.EMPTY_STR;
- // 发送成功
+ // Sending succeeded.
let sendStatus = 0;
let failSum = 0;
let time = common.string.EMPTY_STR;
@@ -403,7 +401,7 @@ export default {
contractsNum = 1;
}
}
- // 如果失败,那会话列表结果就是失败
+ // If it fails, then the session list turns out to be a failure.
if (failSum > 0) {
sendStatus = common.int.SEND_MESSAGE_FAILED;
}
@@ -424,8 +422,8 @@ export default {
},
/**
- * 插入短信信息
- * @param actionData 会话IDs
+ * Inserting SMS Messages
+ * @param actionData Session IDs
* @return
*/
insertMessageDetail(param, callback) {
@@ -433,34 +431,34 @@ export default {
let time = new Date();
let timeStr = param.time != common.string.EMPTY_STR ? param.time : time.getTime() + common.string.EMPTY_STR;
var stringValue = {
- 'receiver_number': param.receiverNumber,
- 'sender_number': param.senderNumber,
- 'start_time': timeStr,
- 'end_time': timeStr,
- 'msg_type': param.isMms ? '1' : '0',
- 'sms_type': param.smsType,
- 'msg_title': param.content,
- 'msg_content': param.content,
- 'msg_state': param.sendStatus,
- 'operator_service_number': common.string.EMPTY_STR,
- 'msg_code': common.string.EMPTY_STR,
- 'session_id': param.threadId,
- 'is_lock': '0',
- 'is_read': param.isRead,
- 'is_collect': '0',
- 'session_type': param.sessionType,
- 'is_sender': param.isSender,
- 'group_id': param.groupId,
- 'is_send_report': param.hasReport
+ "receiver_number": param.receiverNumber,
+ "sender_number": param.senderNumber,
+ "start_time": timeStr,
+ "end_time": timeStr,
+ "msg_type": param.isMms ? "1" : "0",
+ "sms_type": param.smsType,
+ "msg_title": param.content,
+ "msg_content": param.content,
+ "msg_state": param.sendStatus,
+ "operator_service_number": common.string.EMPTY_STR,
+ "msg_code": common.string.EMPTY_STR,
+ "session_id": param.threadId,
+ "is_lock": "0",
+ "is_read": param.isRead,
+ "is_collect": "0",
+ "session_type": param.sessionType,
+ "is_sender": param.isSender,
+ "group_id": param.groupId,
+ "is_send_report": param.hasReport
};
actionData.stringValue = stringValue;
actionData.featureAbility = param.featureAbility;
mConversationModel.insertMessageDetail(actionData, result => {
if (result.code == common.int.SUCCESS) {
- HiLog.i(TAG, 'insertMessageDetail, callback success')
+ HiLog.i(TAG, "insertMessageDetail, callback success")
this.dealBatchInsertMmsPart(param, result, callback);
} else {
- HiLog.w(TAG, 'insertMessageDetail, fail');
+ HiLog.w(TAG, "insertMessageDetail, fail");
}
});
},
@@ -480,14 +478,14 @@ export default {
let bacthmsParts = [];
for (let mms of param.mmsSource) {
let stringValue = {
- 'msg_id': param.msgId,
- 'group_id': param.groupId,
- 'type': mms.msgType,
- 'location_path': mms.msgUriPath,
- 'content': mms.content,
- 'recording_time': mms.time,
- 'part_size': (mms.fileSize + ''),
- 'state': param.messageType
+ "msg_id": param.msgId,
+ "group_id": param.groupId,
+ "type": mms.msgType,
+ "location_path": mms.msgUriPath,
+ "content": mms.content,
+ "recording_time": mms.time,
+ "part_size": (mms.fileSize + ''),
+ "state": param.messageType
};
bacthmsParts.push(stringValue);
}
@@ -500,14 +498,14 @@ export default {
return;
}
let param = this.dealSendResults(sendResults);
- // 更新会话列表的状态
+ // Update the status of the session list.
let threadIds = [actionData.threadId];
let valueBucket = {
- 'sending_status': param.sendStatus,
- 'content': param.content
+ "sending_status": param.sendStatus,
+ "content": param.content
}
conversationListService.updateById(threadIds, valueBucket);
- // 更新信息列表的状态
+ // Update the status of the information list.
for (let sendResult of sendResults) {
actionData.sendStatus = sendResult.sendStatus;
if (sendResult.sendStatus == common.int.SEND_MESSAGE_FAILED) {
@@ -524,8 +522,8 @@ export default {
},
/**
- * 根据会话ID,批量删除列表数据
- * @param threadIds 会话IDs
+ * Deletes list data in batches based on session IDs.
+ * @param threadIds Session IDs
* @return
*/
deleteMessageBySessionIds(actionData) {
@@ -540,8 +538,8 @@ export default {
},
/**
- * 根据ID,批量删除列表数据
- * @param 主键ID 会话IDs
+ * Deletes list data in batches based on IDs.
+ * @param Primary Key ID Session IDs
* @return
*/
deleteMessageByIds(actionData) {
@@ -552,18 +550,18 @@ export default {
},
/**
- * 根据GroupID,批量删除列表数据
- * @param 主键ID 会话IDs
+ * Deletes list data in batches based on the group ID.
+ * @param Primary Key ID Session IDs
* @return
*/
deleteMessageByGroupIds(actionData) {
mConversationModel.deleteMessageByGroupIds(actionData);
- // 删除彩信的数据
+ // Deleting MMS Data
mConversationModel.deleteMmsPartByGroupIds(actionData);
},
/**
- * 根据批量标记
+ * Based on Batch Marking
* @param actionData
* @return
*/
@@ -572,7 +570,7 @@ export default {
},
/**
- * 根据批量标记
+ * Based on Batch Marking
* @param actionData
* @return
*/
@@ -581,7 +579,7 @@ export default {
},
/**
- * 根据单个id,进行更新
+ * Update based on a single ID.
* @param actionData
* @param callback
*/
@@ -590,16 +588,16 @@ export default {
mConversationModel.updateById(actionData, res => {
result.code = res.code;
callback(result);
- }).catch(e=> {
- HiLog.e(TAG, 'updateById, error: ' + JSON.stringify(e.message))
+ }).catch(e => {
+ HiLog.e(TAG, "updateById, error: " + JSON.stringify(e.message))
});
},
/**
- * 判断卡是否存在
+ * Check whether the card exists.
*/
judgeHasSimCard() {
- let count = preferences.getCountOfSim();
+ let count = MmsPreferences.getInstance().getCountOfSim();
if (count > 0) {
return true;
}
@@ -607,9 +605,9 @@ export default {
},
/**
- * 查询最大的groupId
- * @param actionData 参数
- * @param callBack 回调
+ * Query the maximum group ID.
+ * @param actionData
+ * @param callBack
* @return
*/
queryMaxGroupId(actionData, callBack) {
@@ -619,37 +617,37 @@ export default {
if (res.code == common.int.SUCCESS) {
result.response = res.abilityResult;
} else {
- HiLog.w(TAG, 'queryMaxGroupId, failed');
+ HiLog.w(TAG, "queryMaxGroupId, failed");
}
callBack(result);
});
},
/**
- * 保存图片
+ * Save Picture
* @param params threadId,pduId
- * @param callback 保存状态
+ * @param callback Save Status
* @return
*/
saveImage(params, callback) {
mConversationModel.saveImage(params, function (result) {
let message = '';
if (result.code == common.int.SUCCESS) {
- HiLog.i(TAG, 'saveImage, success');
- message = this.$t('strings.attachment_saved_to') + result.abilityResult.filePath
- + this.$t('strings.please_keep_it_secure');
+ HiLog.i(TAG, "saveImage, success");
+ message = this.$t("strings.attachment_saved_to") + result.abilityResult.filePath
+ + this.$t("strings.please_keep_it_secure");
} else {
- HiLog.w(TAG, 'saveImage, error');
- message = this.$t('string.save_img_failed');
+ HiLog.w(TAG, "saveImage, error");
+ message = this.$t("string.save_img_failed");
}
callback(message);
});
},
/**
- * 分享
- * @param actionData 参数
- * @param callback 回调
+ * Share
+ * @param actionData
+ * @param callback
* @return
*/
gotoShare(actionData, callback) {
@@ -662,8 +660,8 @@ export default {
/**
* 更新锁标记
- * @param actionData 参数
- * @param callback 回调
+ * @param actionData
+ * @param callback
* @return
*/
updateLock(actionData, callback) {
@@ -675,9 +673,9 @@ export default {
},
/**
- * 更新收藏
- * @param actionData 参数
- * @param callback 回调
+ * Update Favorites
+ * @param actionData
+ * @param callback
* @return
*/
updateCollect(actionData, callback) {
@@ -689,8 +687,8 @@ export default {
},
/**
- * 模糊搜索,根据内容
- * @param actionData 参数
+ * Fuzzy search, by content
+ * @param actionData
* @return
*/
searchMessageByContent(actionData, callback) {
@@ -703,7 +701,7 @@ export default {
}
});
});
- // 信息列表搜索的数据
+ // Information List Search Data
let mmsPartPromise = new Promise((resolve, reject) => {
this.searchMmsPartByContent(actionData, res => {
if (res.code === common.int.SUCCESS) {
@@ -714,7 +712,7 @@ export default {
});
});
let result: LooseObject = {};
- Promise.all([smsPromise,mmsPartPromise]).then((res) => {
+ Promise.all([smsPromise, mmsPartPromise]).then((res) => {
result.code = common.int.SUCCESS;
let resultList = [];
resultList = resultList.concat(res[0]);
@@ -722,7 +720,7 @@ export default {
result.response = this.dealMessageSort(resultList);
callback(result);
}).catch((err) => {
- HiLog.e(TAG, 'searchMessageByContent, error: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "searchMessageByContent, error: " + JSON.stringify(err.message));
result.code = common.int.FAILURE;
callback(result);
});
@@ -730,25 +728,25 @@ export default {
dealMessageSort(resultList) {
let favoriteList = [];
let messageList = [];
- for(let item of resultList) {
- if(item.isFavorite) {
+ for (let item of resultList) {
+ if (item.isFavorite) {
favoriteList.push(item);
} else {
messageList.push(item);
}
}
let response = [];
- // 收藏列表倒排
+ // Favorites list in reverse order
if (favoriteList.length > 0) {
- // 倒排
+ // inverted
favoriteList.sort((a, b) => {
return b.timeMillisecond - a.timeMillisecond
});
response = response.concat(favoriteList);
}
- // 普通短信列表倒排
+ // List of common SMs in reverse order
if (messageList.length > 0) {
- // 倒排
+ // inverted
messageList.sort((a, b) => {
return b.timeMillisecond - a.timeMillisecond
})
@@ -758,15 +756,15 @@ export default {
},
/**
- * 模糊搜索,根据内容
- * @param actionData 参数
+ * Fuzzy search, by content
+ * @param actionData
* @return
*/
searchSmsMessageByContent(actionData, callback) {
let searchText = actionData.inputValue;
actionData.content = searchText;
let result: LooseObject = {};
- // 这里需要掉用查询详情
+ // The query details need to be disabled.
mConversationModel.searchSmsMessageByContent(actionData, res => {
result.code = res.code;
if (res.code == common.int.SUCCESS) {
@@ -786,27 +784,27 @@ export default {
for (let item of mmsList) {
let map: LooseObject = {};
map.content = item.msgContent;
- if(mmsPartMap.has(item.msgId)) {
+ if (mmsPartMap.has(item.msgId)) {
map.content = mmsPartMap.get(item.msgId).content;
}
map.name = common.string.EMPTY_STR;
map.telephone = item.receiverNumber;
map.telephoneFormat = item.receiverNumber;
- if(item.isSender == 1) {
+ if (item.isSender == 1) {
map.telephone = item.senderNumber;
map.telephoneFormat = item.senderNumber;
}
telephones.push(map.telephone);
- map.nameFormatter = map.name + '<' + map.telephoneFormat + '>';
+ map.nameFormatter = map.name + "<" + map.telephoneFormat + ">";
map.date = common.string.EMPTY_STR;
map.time = common.string.EMPTY_STR;
map.timeMillisecond = item.startTime;
map.isFavorite = item.isCollect == 0 ? false : true;
map.threadId = item.sessionId;
if (item.smsType == 0) {
- map.icon = 'icon/user_avatar_full_fill.svg';
+ map.icon = "icon/user_avatar_full_fill.svg";
} else {
- map.icon = 'icon/entrance_icon01.svg';
+ map.icon = "icon/entrance_icon01.svg";
}
map.groupId = item.groupId;
resultList.push(map);
@@ -823,7 +821,7 @@ export default {
if (contacts.length == 0) {
groupIdMap = this.convertingMessageByGroup(resultList);
} else {
- // 将结果转换为Map,key:手机号,value: 名称
+ // Convert the result to Map, key: mobile number, value: name
let telephoneMap = new Map();
for (let item of contacts) {
if (item.displayName == common.string.EMPTY_STR) {
@@ -832,7 +830,7 @@ export default {
telephoneMap.set(item.detailInfo, item.displayName);
}
}
- // 将结果根据手机号进行匹配
+ // Match the result based on the mobile number.
groupIdMap = this.getGroupIdMap(resultList, telephoneMap);
}
let lists = [];
@@ -843,13 +841,13 @@ export default {
value.contactsNum = contactsNums.length;
if (value.isFavorite) {
let temp = JSON.parse(JSON.stringify(value));
- temp.icon = '/common/icon/icon_favorite.svg';
+ temp.icon = "/common/icon/icon_favorite.svg";
favoriteList.push(temp);
value.isFavorite = false;
}
lists.push(value);
}
- // 将收藏的数据,放入到搜索的列表中
+ // Add favorite data to the search list.
if (favoriteList.length > 0) {
lists = lists.concat(favoriteList);
}
@@ -859,10 +857,10 @@ export default {
getGroupIdMap(resultList, telephoneMap) {
let groupIdMap: LooseObject = {};
for (let map of resultList) {
- // 多人名称的组合,名称是需要组合展示
+ // Indicates the combination of multiple names. The names need to be displayed in combination.
if (telephoneMap.has(map.telephone)) {
map.name = telephoneMap.get(map.telephone);
- map.nameFormatter = map.name + '<' + map.telephoneFormat + '>';
+ map.nameFormatter = map.name + "<" + map.telephoneFormat + ">";
} else {
map.nameFormatter = map.telephoneFormat;
}
@@ -889,21 +887,21 @@ export default {
},
/**
- * 模糊搜索彩信,根据内容
- * @param actionData 参数
+ * Fuzzy search for MMS messages by content
+ * @param actionData
* @return
*/
searchMmsPartByContent(actionData, callback) {
let searchText = actionData.inputValue;
actionData.content = searchText;
- // 这里需要掉用查询详情
+ // The query details need to be disabled.
let result: LooseObject = {};
mConversationModel.searchMmsPartByContent(actionData, res => {
result.code = res.code;
if (res.code == common.int.SUCCESS) {
let mmsPartMap = this.getMmsPartMap(res.abilityResult);
actionData.msgIds = this.getMsgIds(mmsPartMap);
- if(actionData.msgIds.length == 0) {
+ if (actionData.msgIds.length == 0) {
result.response = [];
callback(result);
return;
@@ -913,7 +911,7 @@ export default {
callback(result);
});
} else {
- HiLog.w(TAG, 'searchMmsPartByContent, failed');
+ HiLog.w(TAG, "searchMmsPartByContent, failed");
callback(result);
}
});
@@ -930,7 +928,7 @@ export default {
},
getMmsPartMap(mmsParts) {
let mmsPartMap = new Map();
- // 分组
+ // grouping
for (let element of mmsParts) {
if (!mmsPartMap.has(element.msgId)) {
mmsPartMap.set(element.msgId, element);
@@ -940,16 +938,16 @@ export default {
},
getMsgIds(mmsPartMap) {
let msgIds = [];
- for(let msgId of mmsPartMap.keys()) {
+ for (let msgId of mmsPartMap.keys()) {
msgIds.push(msgId);
}
return msgIds;
},
/**
- * 从图库中获取图片和视频
- * @param actionData 参数
- * @param callback 回调
+ * Get pictures and videos from gallery
+ * @param actionData
+ * @param callback
* @return
*/
queryFromGallery(actionData, callback) {
@@ -962,9 +960,9 @@ export default {
},
/**
- * 查询最近30天的短信
- * @param actionData 参数
- * @param callBack 回调
+ * Querying SMS Messages in the Last 30 Days
+ * @param actionData
+ * @param callBack
* @return
*/
queryMessageThirty(actionData, callBack) {
@@ -974,22 +972,22 @@ export default {
if (res.code == common.int.SUCCESS) {
result.response = res.abilityResult;
} else {
- HiLog.w(TAG, 'queryMessageThirty, failed');
+ HiLog.w(TAG, "queryMessageThirty, failed");
}
callBack(result);
});
},
/**
- * 插入SIM卡中数据
- * @param actionData 参数
- * @param callback 回调
+ * Inserting data into the SIM card
+ * @param actionData
+ * @param callback
*/
insertManageSimData(actionData, callback) {
- HiLog.i(TAG, 'insertManageSimData')
+ HiLog.i(TAG, "insertManageSimData")
let sendResults = actionData.sendResults;
let value = this.dealSendResults(sendResults);
- // 先判断是否创建过会话列表
+ // Check whether a session list has been created.
conversationListService.querySessionByTelephone(value.telephone, res => {
let response = res.response;
if (res.code == common.int.SUCCESS && response.id < 0) {
@@ -1010,18 +1008,18 @@ export default {
insertManageSimNoExiting(value, actionData, callback) {
let valueBucket = {
- 'telephone': value.telephone,
- 'content': value.content,
- 'contacts_num': value.contractsNum,
- 'sms_type': value.smsType,
- 'unread_count': 0,
- 'sending_status': value.sendStatus,
- 'has_draft': 0,
- 'time': value.timestamp,
- 'message_count': 1
+ "telephone": value.telephone,
+ "content": value.content,
+ "contacts_num": value.contractsNum,
+ "sms_type": value.smsType,
+ "unread_count": 0,
+ "sending_status": value.sendStatus,
+ "has_draft": 0,
+ "time": value.timestamp,
+ "message_count": 1
}
conversationListService.insertSession(valueBucket, sessionResult => {
- // 这里调用短信数据库,插入短信信息
+ // Invoke the SMS database to insert SMS messages.
this.dealInsertMessageDetail(value, actionData, sessionResult.rowId, res => {
let result = {
rowId: sessionResult.rowId,
@@ -1034,7 +1032,7 @@ export default {
},
/**
- * 统计未读通知个数
+ * Counting the Number of Unread Notifications
* @param actionData
* @param callback
*/
@@ -1043,16 +1041,16 @@ export default {
if (res.code == common.int.SUCCESS) {
callback(res.abilityResult);
} else {
- HiLog.w(TAG,'statisticsUnreadNotify, failed');
+ HiLog.w(TAG, "statisticsUnreadNotify, failed");
callback(0);
}
});
},
/**
- * 根据groupId 查询彩信的信息
- * @param actionData 条件
- * @param callback 返回值
+ * This interface is used to query MMS information based on groupId.
+ * @param actionData
+ * @param callback
*/
queryMmsPartByIds(actionData, callback) {
let result: LooseObject = {};
@@ -1061,27 +1059,27 @@ export default {
if (res.code == common.int.SUCCESS) {
result.response = res.abilityResult;
} else {
- HiLog.w(TAG, 'queryMmsPartByIds, failed');
+ HiLog.w(TAG, "queryMmsPartByIds, failed");
}
callback(result);
});
},
/**
- * 根据SessionId获取锁的状态
- * @param actionData 参数
- * @param callback 返回信息内容
+ * Obtains the lock status based on SessionId.
+ * @param actionData
+ * @param callback
* @return
*/
queryMessageLockBySessionId(actionData, callback) {
let result: LooseObject = {};
- HiLog.i(TAG, 'queryMessageLockBySessionId');
+ HiLog.i(TAG, "queryMessageLockBySessionId");
mConversationModel.queryMessageLockBySessionId(actionData, res => {
result.code = res.code;
if (res.code == common.int.SUCCESS) {
callback(res.abilityResult);
} else {
- HiLog.w(TAG, 'queryMessageLockBySessionId, failed');
+ HiLog.w(TAG, "queryMessageLockBySessionId, failed");
callback(result);
}
});
diff --git a/entry/src/main/ets/default/service/NotificationService.ets b/entry/src/main/ets/service/NotificationService.ets
similarity index 81%
rename from entry/src/main/ets/default/service/NotificationService.ets
rename to entry/src/main/ets/service/NotificationService.ets
index a56af2a..e780eba 100644
--- a/entry/src/main/ets/default/service/NotificationService.ets
+++ b/entry/src/main/ets/service/NotificationService.ets
@@ -12,14 +12,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import WantAgent from '@ohos.wantAgent';
-import Notification from '@ohos.notification';
-import common from '../data/commonData';
-import HiLog from '../utils/HiLog';
-import conversationService from './ConversationService';
+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 TAG = 'NotificationService';
+const label = "notification_";
+const TAG = "NotificationService";
export default class NotificationService {
private static sInstance: NotificationService;
@@ -32,32 +32,33 @@ export default class NotificationService {
}
constructor() {
- HiLog.i(TAG, 'new start');
+ HiLog.i(TAG, "new start");
}
/**
- * 发送通知
- * @param actionData 通知参数
+ * Send Notifications
+ * @param actionData
* @return
*/
sendNotify(actionData) {
- // 创建Want信息
+ // Creating Want Information
let wantAgentInfo = this.buildWantAgentInfo(actionData);
- // 构建发送请求
+ // Constructing a Send Request
let notificationRequest = this.buildNotificationRequest(actionData);
this.getWantAgent(wantAgentInfo, (data) => {
notificationRequest.wantAgent = data;
notificationRequest.id = actionData.msgId;
notificationRequest.label = label + actionData.msgId;
+ notificationRequest.badgeNumber = Number(actionData.unreadTotal);
Notification.publish(notificationRequest);
- HiLog.i(TAG, 'sendNotify finished');
+ HiLog.i(TAG, "sendNotify finished");
});
}
/**
- * 创建需要发送的跳转的Want
- * @param agentInfo 参数
- * @param callback 回调
+ * Create a Wanted message to be sent.
+ * @param agentInfo
+ * @param callback
* @return
*/
getWantAgent(agentInfo, callback) {
@@ -67,8 +68,8 @@ export default class NotificationService {
}
/**
- * 构建分布式拉起参数
- * @param actionData 参数
+ * Constructing Distributed Startup Parameters
+ * @param actionData
* @return
*/
buildWantAgentInfo(actionData): any {
@@ -85,7 +86,7 @@ export default class NotificationService {
action: "mms.event.notification",
entities: [],
type: "MIMETYPE",
- uri: ""
+ uri: "",
}
],
operationType: WantAgent.OperationType.START_ABILITY,
@@ -97,8 +98,8 @@ export default class NotificationService {
}
/**
- * 构建通知参数
- * @param actionData 参数
+ * Building Notification Parameters
+ * @param actionData
* @return
*/
buildNotificationRequest(actionData): any {
@@ -139,7 +140,7 @@ export default class NotificationService {
cancelNotify(msgId, callback) {
Notification.cancel(msgId, label + msgId, (err, data) => {
if (err) {
- HiLog.w(TAG, 'cancelNotify, error: ' + JSON.stringify(err.message));
+ HiLog.w(TAG, "cancelNotify, error: " + JSON.stringify(err.message));
callback(common.int.FAILURE);
}
callback(common.int.SUCCESS);
@@ -150,7 +151,7 @@ export default class NotificationService {
let promise = Notification.cancelAll();
promise.then((ret) => {
}).catch((err) => {
- HiLog.e(TAG, 'cancelAllNotify, error: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "cancelAllNotify, error: " + JSON.stringify(err.message));
});
}
};
\ No newline at end of file
diff --git a/entry/src/main/ets/default/service/SendMsgService.ets b/entry/src/main/ets/service/SendMsgService.ets
similarity index 66%
rename from entry/src/main/ets/default/service/SendMsgService.ets
rename to entry/src/main/ets/service/SendMsgService.ets
index c26bf4d..71b88cf 100644
--- a/entry/src/main/ets/default/service/SendMsgService.ets
+++ b/entry/src/main/ets/service/SendMsgService.ets
@@ -13,27 +13,22 @@
* limitations under the License.
*/
-import sms from '@ohos.telephony.sms';
-import HiLog from '../utils/HiLog';
-import common from '../data/commonData';
-import http from '@ohos.net.http';
+import sms from "@ohos.telephony.sms";
+import HiLog from "../utils/HiLog";
+import common from "../data/commonData";
+import http from "@ohos.net.http";
-const TAG = 'SendMsgService'
+const TAG = "SendMsgService"
export default {
/**
- * 发送短信
- * @param params 包含卡槽,电话号码,短信内容
- * @param callback 返回发送信息状态
+ * Sending SMS Messages
+ * @param params Including the card slot, phone number, and SMS message content
+ * @param callback Return the message sending status.
* @return
*/
sendMessage(params, callback) {
-
-// let hasSmsCapability = sms.hasSmsCapability;
-// HiLog.i(TAG, 'sendMessage, hasSmsCapability: ' + hasSmsCapability)
-// sms.getDefaultSmsSlotId((err, data) => {
-// });
sms.sendMessage({
slotId: params.slotId,
destinationHost: params.destinationHost,
@@ -41,17 +36,17 @@ export default {
sendCallback: (err, value) => {
let sendStatus;
if (err) {
- HiLog.w(TAG, 'sendMessage, sendCallback failed err: ' + JSON.stringify(err.message));
- sendStatus = common.int.SEND_MESSAGE_SUCCESS;
+ HiLog.w(TAG, "sendMessage, sendCallback failed err: " + JSON.stringify(err.message));
+ sendStatus = common.int.SEND_MESSAGE_FAILED;
} else {
sendStatus = this.dealSendResult(value);
- HiLog.i(TAG, 'sendMessage, sendCallback success result=' + value.result + ', sendStatus=' + sendStatus);
+ HiLog.i(TAG, `sendMessage, sendCallback success result=${value.result}, sendStatus=${sendStatus}`);
}
callback(sendStatus);
},
deliveryCallback: (err, value) => {
if (err) {
- HiLog.w(TAG, 'sendMessage, deliveryCallback failed err: ' + JSON.stringify(err.message));
+ HiLog.w(TAG, "sendMessage, deliveryCallback failed err: " + JSON.stringify(err.message));
return;
}
}
@@ -72,9 +67,9 @@ export default {
{
method: http.RequestMethod.POST,
header: {
- 'Content-Type': 'application/vnd.wap.mms-message',
- 'Accept': 'Accept',
- 'Accept-Language': 'Accept-Language'
+ "Content-Type": "application/vnd.wap.mms-message",
+ "Accept": "Accept",
+ "Accept-Language": "Accept-Language"
},
extraData: JSON.stringify(params),
readTimeout: 60000,
@@ -82,7 +77,7 @@ export default {
}, (err, data) => {
let sendStatus;
if (err) {
- HiLog.i(TAG, 'sendMmsMessage, error: ' + JSON.stringify(err.message));
+ HiLog.i(TAG, "sendMmsMessage, error: " + JSON.stringify(err.message));
sendStatus = common.int.SEND_MESSAGE_FAILED;
} else {
sendStatus = common.int.SEND_MESSAGE_SUCCESS;
diff --git a/entry/src/main/ets/default/service/SettingService.ets b/entry/src/main/ets/service/SettingService.ets
similarity index 71%
rename from entry/src/main/ets/default/service/SettingService.ets
rename to entry/src/main/ets/service/SettingService.ets
index a8487eb..4a18372 100644
--- a/entry/src/main/ets/default/service/SettingService.ets
+++ b/entry/src/main/ets/service/SettingService.ets
@@ -13,21 +13,22 @@
* limitations under the License.
*/
-import SettingModel from '../model/SettingsModel';
+import SettingModel from "../model/SettingsModel";
let mSettingModel = new SettingModel();
-import HiLog from '../utils/HiLog';
-import common from '../data/commonData';
-import LooseObject from '../data/LooseObject'
-import preferences from '../utils/PreferencesUtil';
+import HiLog from "../utils/HiLog";
+import common from "../data/commonData";
+import LooseObject from "../data/LooseObject"
+import MmsPreferences from "../utils/MmsPreferences";
+
+const TAG = "SettingService";
-const TAG = 'SettingService';
export default {
/**
- * 设置初始值
+ * Set Initial Value
*
- * @param {Object} callback 回调函数
+ * @param {Object} callback
*/
setOnSettingValueListener(callback) {
let result: LooseObject = {
@@ -50,106 +51,106 @@ export default {
},
/**
- * 还原页面的默认值
+ * Restore Page Defaults
*
- * @param {Object} callback 回调函数
+ * @param {Object} callback
*/
restoreSwitchValue(callback) {
mSettingModel.restoreSwitchValueToDefault(callback);
},
/**
- * 更新相关的值
- * @param code 更新的code
- * @param actionData 更新的值
- * @param callback 回调函数
+ * Update related values
+ * @param code Updated code.
+ * @param actionData Updated Value
+ * @param callback
* @return
*/
updateSettingValue(code, actionData, callback) {
switch (code) {
case common.route.MESSAGE_CODE_UPDATE_DELIVERY_REPORTS_VALUE:
- // 送达报告
+ // Delivery Report
mSettingModel.updateSwitchValue(common.string.KEY_OF_DELIVERY_REPORT_SWITCH,
actionData.intValue, callback);
break;
case common.route.MESSAGE_CODE_UPDATE_AUTO_RETRIEVE_MMS_VALUE:
- // 自动下载彩信
+ // Automatically downloading MMs
mSettingModel.updateSwitchValue(common.string.KEY_OF_AUTO_RETRIEVE_SWITCH,
actionData.intValue, callback);
break;
case common.route.MESSAGE_CODE_UPDATE_RECALL_MESSAGES_VALUE:
- // 取消发送
+ // Cancel Sending
mSettingModel.updateSwitchValue(common.string.KEY_OF_RECALL_MESSAGE_SWITCH,
actionData.booleanValue, callback);
break;
case common.route.MESSAGE_CODE_UPDATE_AUTO_DELETE_INFO_MESSAGES_VALUE:
- // 自动删除通知信息
+ // Automatically delete notification information
mSettingModel.updateSwitchValue(common.string.KEY_OF_AUTO_DELETE_INFO_SWITCH,
actionData.booleanValue, callback);
break;
case common.route.MESSAGE_CODE_UPDATE_ARCHIVE_INFO_MESSAGES_VALUE:
- // 通知信息整合
+ // Notification information integration
mSettingModel.updateSwitchValue(common.string.KEY_OF_INTEGRATION_SWITCH,
actionData.booleanValue, callback);
break;
case common.route.MESSAGE_CODE_UPDATE_MALICIOUS_WEBSITE_IDENTIFICATION_VALUE:
- // 恶意网址识别
+ // Malicious Website Identification
mSettingModel.updateSwitchValue(common.string.KEY_OF_MALICIOUS_WEB_SWITCH,
actionData.booleanValue, callback);
break;
case common.route.MESSAGE_CODE_UPDATE_SHOW_CONTACT_PROFILE_PICS_VALUE:
- // 显示联系人头像
+ // Display contact avatar
mSettingModel.updateSwitchValue(common.string.KEY_OF_SHOW_CONTACT_SWITCH,
actionData.booleanValue, callback);
break;
default:
- HiLog.w(TAG, 'updateSettingValue, code is not exit');
+ HiLog.w(TAG, "updateSettingValue, code is not exit");
}
},
/**
- * 获取高级设置页面开关值
+ * Obtains the switch value on the advanced settings page.
*
- * @param {Object} callback 回调函数
+ * @param {Object} callback
*/
getAdvancedPageSwitchValue(callback) {
mSettingModel.getAdvancedPageSwitchValue(callback);
},
/**
- * 更新短信中心号码
- * @param actionData 参数
- * @param callback 回调
+ * Updating SMSC Numbers
+ * @param actionData
+ * @param callback
* @return
*/
updateSmscNumber(actionData) {
mSettingModel.updateSmscNumber(actionData, result => {
if (result.code == common.int.SUCCESS) {
- HiLog.i(TAG, 'updateSmscNumber, success');
+ HiLog.i(TAG, "updateSmscNumber, success");
} else {
- HiLog.w(TAG, 'updateSmscNumber, fail');
+ HiLog.w(TAG, "updateSmscNumber, fail");
}
});
},
/**
- * 分享短信中心dialog内选中的内容
- * @param actionData 参数
- * @param callback 回调
+ * Share the selected content in the SMSC dialog box.
+ * @param actionData
+ * @param callback
* @return
*/
shareSmsEnterSelectedText(actionData) {
- // 分享API目前未提供
+ // The sharing API is not provided.
mSettingModel.shareSmsEnterSelectedText(actionData, result => {
if (result.code == common.int.SUCCESS) {
- HiLog.i(TAG, 'shareSmsEnterSelectedText, success');
+ HiLog.i(TAG, "shareSmsEnterSelectedText, success");
} else {
}
});
},
/**
- * 通知信息整合开关、是否显示联系人头像开关的值
+ * Values of the notification information integration switch and whether to display contact avatars
*/
getSettingFlagForConvListPage() {
let result: LooseObject = {
@@ -159,7 +160,7 @@ export default {
};
mSettingModel.getSettingValue(settingValue => {
if (settingValue.code === common.int.SUCCESS) {
- HiLog.i(TAG, 'getSettingFlagForConvListPage, Success');
+ HiLog.i(TAG, "getSettingFlagForConvListPage, Success");
if (settingValue.abilityResult.isShowContactHeadIcon === common.bool.TRUE) {
result.isShowContactHeadIcon = true;
}
@@ -170,53 +171,53 @@ export default {
result.recallMessagesFlag = true;
}
} else {
- HiLog.w(TAG, 'getSettingFlagForConvListPage, fail');
+ HiLog.w(TAG, "getSettingFlagForConvListPage, fail");
}
});
return result;
},
/**
- * 判断是否需要送达报告
+ * Determine whether a delivery report is required.
*
- * @param {boolean} isMms 是否是彩信
+ * @param {boolean} isMms MMS or not
*/
judgeIsDeliveryReport(isMms) {
- let deliveryReportSwitch = preferences.getValueOfDeliveryReportSwitch();
+ let deliveryReportSwitch = MmsPreferences.getInstance().getValueOfDeliveryReportSwitch();
if (deliveryReportSwitch === common.DELIVERY_REPORTS.DISABLED) {
return false;
}
- // 如果是彩信和短息,直接返回true
+ // For MMS and SMS messages, true is returned.
if (deliveryReportSwitch === common.DELIVERY_REPORTS.SMS_AND_MMS) {
return true;
}
- // 单独只有短信的时候,才有送达报告
- if (deliveryReportSwitch == common.DELIVERY_REPORTS.SMS && !isMms){
+ // A delivery report is available only when a message is sent.
+ if (deliveryReportSwitch == common.DELIVERY_REPORTS.SMS && !isMms) {
return true;
}
- // 单独只有彩信的时候,才有送达报告
- if (deliveryReportSwitch == common.DELIVERY_REPORTS.MMS && isMms){
+ // Delivery reports are available only when MMS messages are sent.
+ if (deliveryReportSwitch == common.DELIVERY_REPORTS.MMS && isMms) {
return true;
}
return false;
},
/**
- * 计算被选中的值
+ * Calculate Selected Values
* @param mmsList
* @param isAllSelect
*/
- calculateChecked(simMessageList, isAllSelect){
+ calculateChecked(simMessageList, isAllSelect) {
let count = 0;
let checkedList = [];
let result: LooseObject = {};
let switchOff = false;
- for(let item of simMessageList) {
- // 如果全选
- if(isAllSelect || item.isCbChecked) {
+ for (let item of simMessageList) {
+ // If you select all
+ if (isAllSelect || item.isCbChecked) {
switchOff = true;
}
- if(switchOff) {
+ if (switchOff) {
checkedList.push(item);
count++;
}
diff --git a/entry/src/main/ets/default/service/SimCardService.ets b/entry/src/main/ets/service/SimCardService.ets
similarity index 60%
rename from entry/src/main/ets/default/service/SimCardService.ets
rename to entry/src/main/ets/service/SimCardService.ets
index c89b0f7..05c4815 100644
--- a/entry/src/main/ets/default/service/SimCardService.ets
+++ b/entry/src/main/ets/service/SimCardService.ets
@@ -13,37 +13,37 @@
* limitations under the License.
*/
-import CardModel from '../model/CardModel'
+import CardModel from "../model/CardModel"
+import common from "../data/commonData";
+import LooseObject from "../data/LooseObject"
+import HiLog from "../utils/HiLog";
let cardModel = new CardModel();
-import common from '../data/commonData';
-import LooseObject from '../data/LooseObject'
-import HiLog from '../utils/HiLog';
+const TAG = "SimCardService";
-const TAG = 'SimCardService';
export default {
/**
- * 设置SIM卡信息
+ * Setting SIM Card Information
*
- * @param {Object} preferences 偏量数据库
+ * @param {Object} preferences bias database
*/
- simInfoHandler(preferences) {
- cardModel.getSimSpn(preferences);
+ simInfoHandler() {
+ cardModel.getSimSpn();
},
/**
- * 查询短信中心号码
- * @param actionData 参数
- * @param callback 回调
+ * Querying SMSC Numbers
+ * @param actionData
+ * @param callback
* @return
*/
querySmscNumber(actionData, callback) {
let result: LooseObject = {};
let index = actionData.index - 1;
- HiLog.i(TAG, 'querySmscNumber, slotId=' + index);
- cardModel.getSmscNumber(index, actionData.preferences, smsNumber => {
+ HiLog.i(TAG, "query SMSC number, slotId=" + index);
+ cardModel.getSmscNumber(index, smsNumber => {
result.code = common.int.SUCCESS;
result.smsNumber = smsNumber;
callback(result);
@@ -51,9 +51,9 @@ export default {
},
/**
- * 查询sim卡短信信息
- * @param actionData 参数
- * @param callback 回调
+ * Querying SIM Card SMS Messages
+ * @param actionData
+ * @param callback
* @return
*/
queryMessageInSimCard(actionData, callback) {
@@ -61,12 +61,12 @@ export default {
},
/**
- * 获取sim卡的数量
+ * Obtains the number of SIM cards.
*
- * @param {Object} preferences 偏量数据库
+ * @param {Object} preferences
*/
- initSimCardNum(preferences) {
- cardModel.getSimCardNum(preferences);
+ initSimCardNum() {
+ cardModel.getSimCardNum();
},
delSimMessage(actionData) {
cardModel.delSimMessage(actionData);
diff --git a/entry/src/main/ets/default/utils/DateUtil.ets b/entry/src/main/ets/utils/DateUtil.ets
similarity index 70%
rename from entry/src/main/ets/default/utils/DateUtil.ets
rename to entry/src/main/ets/utils/DateUtil.ets
index 812b530..d917af5 100644
--- a/entry/src/main/ets/default/utils/DateUtil.ets
+++ b/entry/src/main/ets/utils/DateUtil.ets
@@ -12,20 +12,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import common from '../data/commonData';
-import HiLog from './HiLog';
-// 时间常量
+import common from "../data/commonData";
+import HiLog from "./HiLog";
+// Time constant
const ONE_MINUTE_IN_MILLISECOND = 60000;
const ONE_HOUR_IN_MILLISECOND = 3600000;
-const TAG = 'DateUtil';
+const TAG = "DateUtil";
+
export default {
/**
- * 将item的时间戳转化为时间(用于短信列表)
+ * Converts the timestamp of an item to a time (for the SMS message list).
*
- * @param messageItem 单个item
- * @param is24HourTime 是否是24小时
+ * @param messageItem
+ * @param is24HourTime
* @return
*/
convertDateFormatForItem(messageItem, is24HourTime) {
@@ -41,11 +42,11 @@ export default {
},
/**
- * 将时间戳转化为时间(用于短信列表)
+ * Converting a Timestamp to a Time (for SMS List)
*
- * @param timeStampFromDb 需转换的时间轴
- * @param currentDate 当前时间
- * @param is24HourTime 是否24小时制
+ * @param timeStampFromDb Timeline to be converted
+ * @param currentDate Current Time
+ * @param is24HourTime
* @return
*/
convertTimeStampToTime(timeStampFromDb, currentDate, is24HourTime) {
@@ -58,33 +59,33 @@ export default {
let minutesOfSms = sms.getMinutes();
let diff = currentDate.timeOfNow - timeStampOfSms;
if (currentDate.yearOfNow == yearOfSms && currentDate.monthOfNow == monthOfSms
- && currentDate.dayOfNow == dayOfSms) {
+ && currentDate.dayOfNow == dayOfSms) {
if (diff < ONE_MINUTE_IN_MILLISECOND) {
return $r("app.string.justNow");
} else if (diff < ONE_HOUR_IN_MILLISECOND) {
- return $r('app.string.minAgo', Math.floor(diff / ONE_MINUTE_IN_MILLISECOND));
+ return $r("app.string.minAgo", Math.floor(diff / ONE_MINUTE_IN_MILLISECOND));
} else {
let hoursOfSmsStr: string = '' + hoursOfSms;
let minutesOfSmsStr: string = '' + minutesOfSms;
if (hoursOfSms < 10) {
- hoursOfSmsStr = '0' + hoursOfSms;
+ hoursOfSmsStr = "0" + hoursOfSms;
}
if (minutesOfSms < 10) {
- minutesOfSmsStr = '0' + minutesOfSms;
+ minutesOfSmsStr = "0" + minutesOfSms;
}
if (is24HourTime) {
- return $r('app.string.hourAndMinute', hoursOfSmsStr, minutesOfSmsStr);
+ return $r("app.string.hourAndMinute", hoursOfSmsStr, minutesOfSmsStr);
} else {
return this.timeTwelveHourSystem(hoursOfSms, minutesOfSmsStr, hoursOfSmsStr);
}
}
} else if (currentDate.yearOfNow == yearOfSms && currentDate.monthOfNow == monthOfSms
- && currentDate.dayOfNow - dayOfSms == 1) {
- return $r('app.string.yesterday');
+ && currentDate.dayOfNow - dayOfSms == 1) {
+ return $r("app.string.yesterday");
} else if (currentDate.yearOfNow == yearOfSms) {
- return $r('app.string.monthDay', monthOfSms, dayOfSms);
+ return $r("app.string.monthDay", monthOfSms, dayOfSms);
} else {
- return $r('app.string.yearMonthDay', yearOfSms, monthOfSms, dayOfSms);
+ return $r("app.string.yearMonthDay", yearOfSms, monthOfSms, dayOfSms);
}
},
@@ -100,24 +101,24 @@ export default {
morningTimeTwelveHourSystem(hoursOfSms, minutesOfSmsStr, hoursOfSmsStr) {
let time: Resource = null;
- // 12小时制
+ // 12-hour clock
if (hoursOfSms < 1) {
- time = $r('app.string.postMidnight', 12 + '', minutesOfSmsStr);
+ time = $r("app.string.postMidnight", 12 + '', minutesOfSmsStr);
}
if (hoursOfSms >= 1 && hoursOfSms < 4) {
- time = $r('app.string.beforeDawn', hoursOfSmsStr, minutesOfSmsStr);
+ time = $r("app.string.beforeDawn", hoursOfSmsStr, minutesOfSmsStr);
}
if (hoursOfSms >= 4 && hoursOfSms < 6) {
- time = $r('app.string.earlyMorning', hoursOfSmsStr, minutesOfSmsStr);
+ time = $r("app.string.earlyMorning", hoursOfSmsStr, minutesOfSmsStr);
}
if (hoursOfSms >= 6 && hoursOfSms < 9) {
- time = $r('app.string.morning', hoursOfSmsStr, minutesOfSmsStr);
+ time = $r("app.string.morning", hoursOfSmsStr, minutesOfSmsStr);
}
if (hoursOfSms >= 9 && hoursOfSms < 11) {
- time = $r('app.string.forenoon', hoursOfSmsStr, minutesOfSmsStr);
+ time = $r("app.string.forenoon", hoursOfSmsStr, minutesOfSmsStr);
}
if (hoursOfSms >= 11 && hoursOfSms <= 12) {
- time = $r('app.string.preNoon', hoursOfSms + '', minutesOfSmsStr);
+ time = $r("app.string.preNoon", hoursOfSms + '', minutesOfSmsStr);
}
return time;
},
@@ -125,27 +126,27 @@ export default {
afterTimeTwelveHourSystem(hoursOfSms, minutesOfSmsStr, hoursOfSmsStr) {
let time: Resource = null;
if (hoursOfSms > 12 && hoursOfSms < 13) {
- time = $r('app.string.postNoon', hoursOfSms + '', minutesOfSmsStr);
+ time = $r("app.string.postNoon", hoursOfSms + '', minutesOfSmsStr);
}
if (hoursOfSms >= 13 && hoursOfSms < 17) {
- time = $r('app.string.afternoon', (hoursOfSms - 12) + '', minutesOfSmsStr);
+ time = $r("app.string.afternoon", (hoursOfSms - 12) + '', minutesOfSmsStr);
}
if (hoursOfSms >= 17 && hoursOfSms < 19) {
- time = $r('app.string.towardEvening', (hoursOfSms - 12) + '', minutesOfSmsStr);
+ time = $r("app.string.towardEvening", (hoursOfSms - 12) + '', minutesOfSmsStr);
}
if (hoursOfSms >= 19 && hoursOfSms < 23) {
- time = $r('app.string.evening', (hoursOfSms - 12) + '', minutesOfSmsStr);
+ time = $r("app.string.evening", (hoursOfSms - 12) + '', minutesOfSmsStr);
}
if (hoursOfSms >= 23) {
- time = $r('app.string.preMidnight', (hoursOfSms - 12) + '', minutesOfSmsStr);
+ time = $r("app.string.preMidnight", (hoursOfSms - 12) + '', minutesOfSmsStr);
}
return time;
},
/**
- * 将时间进行转化
- * @param messageItem 单个item
- * @param is24HourTime 是否是24小时
+ * Converting Time
+ * @param messageItem
+ * @param is24HourTime
* @param that
* @return
*/
@@ -159,7 +160,7 @@ export default {
},
/**
- * 把时间戳形式转换为日期形式
+ * Converts the timestamp form to the date form.
*/
convertTimeStampToDate(messageItem, timeStampFromDb, yearOfNow, monthOfNow, dayOfNow) {
let date: Resource = null;
@@ -169,20 +170,20 @@ export default {
let dayOfSms = sms.getDate();
let weekOfSms = sms.getDay();
if (yearOfNow == yearOfSms && monthOfNow == monthOfSms && dayOfNow == dayOfSms) {
- date = $r('app.string.recentDateToday', '');
+ date = $r("app.string.recentDateToday", '');
} else if (yearOfNow == yearOfSms && monthOfNow == monthOfSms && dayOfNow - dayOfSms == 1) {
- date = $r('app.string.recentDateYesterday', '');
+ date = $r("app.string.recentDateYesterday", '');
} else if (yearOfNow == yearOfSms) {
- date = $r('app.string.monthDayDate', monthOfSms, dayOfSms, '');
+ date = $r("app.string.monthDayDate", monthOfSms, dayOfSms, '');
} else {
- date = $r('app.string.yearMonthDayDate', yearOfSms, monthOfSms, dayOfSms, '');
+ date = $r("app.string.yearMonthDayDate", yearOfSms, monthOfSms, dayOfSms, '');
}
messageItem.date = date;
messageItem.week = this.getWeek(weekOfSms);
},
/**
- * 获取星期/周几
+ * Get Week/Day of the Week
* @param day
* @param that
* @return
@@ -191,25 +192,25 @@ export default {
let week: Resource = null;
switch (day) {
case 0:
- week = $r('app.string.Sunday');
+ week = $r("app.string.Sunday");
break;
case 1:
- week = $r('app.string.Monday');
+ week = $r("app.string.Monday");
break;
case 2:
- week = $r('app.string.Tuesday');
+ week = $r("app.string.Tuesday");
break;
case 3:
- week = $r('app.string.Wednesday');
+ week = $r("app.string.Wednesday");
break;
case 4:
- week = $r('app.string.Thursday');
+ week = $r("app.string.Thursday");
break;
case 5:
- week = $r('app.string.Friday');
+ week = $r("app.string.Friday");
break;
case 6:
- week = $r('app.string.Saturday');
+ week = $r("app.string.Saturday");
break;
}
@@ -222,9 +223,9 @@ export default {
let monthOfSms = sms.getMonth() + 1;
let dayOfSms = sms.getDate();
let weekOfSms = sms.getDay();
- let date = $r('app.string.yearMonthDayDate', yearOfSms, monthOfSms, dayOfSms, '');
-// let time = this.convertTimeStampTime(timeStampFromDb, false);
-// return date + ' ' + time;
+ let date = $r("app.string.yearMonthDayDate", yearOfSms, monthOfSms, dayOfSms, '');
+ // let time = this.convertTimeStampTime(timeStampFromDb, false);
+ // return date + " " + time;
return date;
},
@@ -242,14 +243,14 @@ export default {
let hoursOfSmsStr: string = hoursOfSms + '';
let minutesOfSmsStr: string = minutesOfSms + '';
if (hoursOfSms < 10) {
- hoursOfSmsStr = '0' + hoursOfSms;
+ hoursOfSmsStr = "0" + hoursOfSms;
}
if (minutesOfSms < 10) {
- minutesOfSmsStr = '0' + minutesOfSms;
+ minutesOfSmsStr = "0" + minutesOfSms;
}
if (is24HourTime) {
- // 24小时制
- return $r('app.string.hourAndMinute', hoursOfSmsStr, minutesOfSmsStr);
+ // 24-hour clock
+ return $r("app.string.hourAndMinute", hoursOfSmsStr, minutesOfSmsStr);
}
return this.timeTwelveHourSystem(hoursOfSms, minutesOfSmsStr, hoursOfSmsStr);
}
diff --git a/entry/src/main/ets/utils/DeviceUtil.ets b/entry/src/main/ets/utils/DeviceUtil.ets
new file mode 100644
index 0000000..c344baf
--- /dev/null
+++ b/entry/src/main/ets/utils/DeviceUtil.ets
@@ -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:Smartphones
+ * tablet:flat plate
+ * tv:Smart screen
+ * wearable:Smart Wear
+ * liteWearable:Lightweight intelligent wearable
+ * smartVision:Smart Vision Devices
+ */
+ 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";
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/utils/HiLog.ets b/entry/src/main/ets/utils/HiLog.ets
new file mode 100644
index 0000000..4048ae6
--- /dev/null
+++ b/entry/src/main/ets/utils/HiLog.ets
@@ -0,0 +1,61 @@
+/**
+ * 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.
+ */
+
+/**
+ * Log Util
+ *
+ * standard :
+ * 1. define TAG, recommend class name。
+ * 2. switch IS_DEBUG_ON as true, when debugging.
+ * 3. msg should be short and valuable.
+ * 4. choose appropriate function.
+ * 5. the function execute many times can not print.
+ * 6. uniqueness.
+ *
+ * @since 2022-02-18
+ */
+import Log from "@ohos.hilog";
+
+const TAG = "MmsLog";
+const DOMAIN = 0x0800;
+
+export default class HiLog {
+
+ private static readonly COLON: string = ": ";
+
+ constructor() {
+ }
+
+ private static prefix(tag: string) {
+ return tag + this.COLON;
+ }
+
+ static d(tag: string, msg: string, ...args: any[]) {
+ Log.debug(DOMAIN, TAG, this.prefix(tag) + msg, args);
+ }
+
+ static i(tag: string, msg: string, ...args: any[]) {
+ Log.info(DOMAIN, TAG, this.prefix(tag) + msg, args);
+ }
+
+ static w(tag: string, msg: string, ...args: any[]) {
+ Log.warn(DOMAIN, TAG, this.prefix(tag) + msg, args);
+ }
+
+ static e(tag: string, msg: string, ...args: any[]) {
+ Log.error(DOMAIN, TAG, this.prefix(tag) + msg, args);
+ }
+}
+
diff --git a/entry/src/main/ets/utils/MmsDatabaseHelper.ets b/entry/src/main/ets/utils/MmsDatabaseHelper.ets
new file mode 100644
index 0000000..810de6c
--- /dev/null
+++ b/entry/src/main/ets/utils/MmsDatabaseHelper.ets
@@ -0,0 +1,113 @@
+/**
+ * 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 "./HiLog";
+import mmsTable from "../data/tableData";
+import ohosDataRdb from "@ohos.data.rdb";
+
+const TAG = "MmsDatabaseHelper";
+
+export default class MmsDatabaseHelper {
+ public static TABLE = {
+ SESSION: "session"
+ };
+ private static sInstance: MmsDatabaseHelper;
+ private mRdbStore = null;
+
+
+ static getInstance() {
+ if (MmsDatabaseHelper.sInstance == null) {
+ MmsDatabaseHelper.sInstance = new MmsDatabaseHelper();
+ }
+ return MmsDatabaseHelper.sInstance;
+ }
+
+ /**
+ * Creating Database Tables
+ */
+ async createTable() {
+ if (this.mRdbStore == null) {
+ this.mRdbStore = await ohosDataRdb.getRdbStore(globalThis.mmsContext,
+ { name: mmsTable.DB.MMSSMS.config.name }, mmsTable.DB.MMSSMS.version);
+
+ await this.mRdbStore.executeSql(mmsTable.table.session, null);
+ HiLog.i(TAG, "create session table finish");
+ } else {
+ HiLog.i(TAG, " this.mRdbStore !== null ");
+ }
+ }
+
+ /**
+ * Query Interface
+ * @param predicates Search criteria
+ * @return
+ */
+ async query(predicates) {
+ if (this.mRdbStore !== null) {
+ return await this.mRdbStore.query(predicates);
+ } else {
+ HiLog.w(TAG, "mRdbStore is null, query fail.");
+ return null;
+ }
+ }
+
+ /**
+ * New data
+ */
+ async insert(tableName, valueBucket) {
+ let rowId = 0;
+ if (this.mRdbStore !== null) {
+ let insertPromise = this.mRdbStore.insert(tableName, valueBucket);
+ insertPromise.then((ret) => {
+ HiLog.i(TAG, "insert, first done: " + rowId);
+ rowId = ret;
+ }).catch((err) => {
+ HiLog.e(TAG, "insert, first fail: " + JSON.stringify(err.message));
+ })
+ await insertPromise;
+ } else {
+ HiLog.w(TAG, "mRdbStore is null, insert fail.");
+ }
+ return rowId;
+ }
+
+ /**
+ * Update Interface
+ * @param predicates
+ * @param predicates
+ * @return
+ */
+ async update(predicates, valueBucket) {
+ if (this.mRdbStore !== null) {
+ let changedRows = await this.mRdbStore.update(valueBucket, predicates);
+ HiLog.i(TAG, "update, changedRows=" + changedRows);
+ } else {
+ HiLog.w(TAG, "mRdbStore is null, update fail.");
+ }
+ }
+
+ /**
+ * Deleting an Interface
+ * @param predicates
+ * @return
+ */
+ async deleteItem(predicates) {
+ if (this.mRdbStore !== null) {
+ let deletedRows = await this.mRdbStore.delete(predicates);
+ HiLog.i(TAG, "deleteItem, deletedRows=" + deletedRows);
+ } else {
+ HiLog.w(TAG, "mRdbStore is null, delete item fail.");
+ }
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/utils/MmsPreferences.ets b/entry/src/main/ets/utils/MmsPreferences.ets
new file mode 100644
index 0000000..7a337f7
--- /dev/null
+++ b/entry/src/main/ets/utils/MmsPreferences.ets
@@ -0,0 +1,242 @@
+/**
+ * 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 common from "../data/commonData";
+import dataStorage from "@ohos.data.storage";
+import featureAbility from "@ohos.ability.featureAbility";
+import HiLog from "./HiLog";
+
+const TAG = "MmsPreferences";
+
+/**
+ * Obtaining a Lightweight Preference Database Instance
+ */
+export default class MmsPreferences {
+ private static sInstance: MmsPreferences;
+ private mPref = null;
+
+ static getInstance() {
+ if (MmsPreferences.sInstance == null) {
+ MmsPreferences.sInstance = new MmsPreferences();
+ }
+ return MmsPreferences.sInstance;
+ }
+
+ async initPreferences() {
+ if (this.mPref == null) {
+ let context = globalThis.mmsContext;
+ let path = await context.getFilesDir();
+ this.mPref = await dataStorage.getStorage(path + common.string.PATH_OF_PREFERENCES);
+ HiLog.i(TAG, "init preferences finish");
+ }
+ }
+
+ /**
+ * Obtaining Values
+ *
+ * @param {string} key value
+ */
+ getValue(key) {
+ if (this.mPref !== null) {
+ return this.mPref.getSync(key, common.string.EMPTY_STR);
+ } else {
+ HiLog.w(TAG, "mPref is null, get " + key + " fail.");
+ return common.string.EMPTY_STR;
+ }
+ }
+
+ /**
+ * Obtains the value of the notification integration switch.
+ */
+ getValueOfIntegrationSwitch() {
+ if (this.mPref !== null) {
+ return this.mPref.getSync(common.string.KEY_OF_INTEGRATION_SWITCH, common.bool.TRUE);
+ } else {
+ HiLog.w(TAG, "mPref is null, get " + common.string.KEY_OF_INTEGRATION_SWITCH + " fail.");
+ return common.bool.TRUE;
+ }
+ }
+
+ /**
+ * Obtains the value of the malicious URL identification switch.
+ */
+ getValueOfMaliciousWebSwitch() {
+ if (this.mPref !== null) {
+ return this.mPref.getSync(common.string.KEY_OF_MALICIOUS_WEB_SWITCH, common.bool.FALSE);
+ } else {
+ HiLog.w(TAG, "mPref is null, get " + common.string.KEY_OF_MALICIOUS_WEB_SWITCH + " fail.");
+ return common.bool.FALSE;
+ }
+ }
+
+ /**
+ * Obtains the value of the switch for displaying contact avatars.
+ */
+ getValueOfShowContactSwitch() {
+ if (this.mPref !== null) {
+ return this.mPref.getSync(common.string.KEY_OF_SHOW_CONTACT_SWITCH, common.bool.TRUE);
+ } else {
+ HiLog.w(TAG, "mPref is null, get " + common.string.KEY_OF_SHOW_CONTACT_SWITCH + " fail.");
+ return common.bool.TRUE;
+ }
+ }
+
+ /**
+ * Obtains the value of the delivery report switch.
+ */
+ getValueOfDeliveryReportSwitch() {
+ if (this.mPref !== null) {
+ return this.mPref.getSync(common.string.KEY_OF_DELIVERY_REPORT_SWITCH, common.DELIVERY_REPORTS.DISABLED);
+ } else {
+ HiLog.w(TAG, "mPref is null, get " + common.string.KEY_OF_DELIVERY_REPORT_SWITCH + " fail.");
+ return common.DELIVERY_REPORTS.DISABLED;
+ }
+ }
+
+ /**
+ * Obtains the value of the function of automatically downloading MMS messages.
+ */
+ getValueOfAutoRetrieveMmsSwitch() {
+ if (this.mPref !== null) {
+ return this.mPref.getSync(common.string.KEY_OF_AUTO_RETRIEVE_SWITCH,
+ common.AUTO_RETRIEVE_MMS.NOT_WHEN_ROAMING);
+ } else {
+ HiLog.w(TAG, "mPref is null, get " + common.string.KEY_OF_AUTO_RETRIEVE_SWITCH + " fail.");
+ return common.AUTO_RETRIEVE_MMS.NOT_WHEN_ROAMING;
+ }
+ }
+
+ /**
+ * Obtains the value of the send cancel switch.
+ */
+ getValueOfRecallMessageSwitch() {
+ if (this.mPref !== null) {
+ return this.mPref.getSync(common.string.KEY_OF_RECALL_MESSAGE_SWITCH, common.bool.FALSE);
+ } else {
+ HiLog.w(TAG, "mPref is null, get " + common.string.KEY_OF_RECALL_MESSAGE_SWITCH + " fail.");
+ return common.bool.FALSE;
+ }
+ }
+
+ /**
+ * Obtains the value of the automatic deletion notification switch.
+ */
+ getValueOfAutoDeleteInfoSwitch() {
+ if (this.mPref !== null) {
+ return this.mPref.getSync(common.string.KEY_OF_AUTO_DELETE_INFO_SWITCH, common.bool.FALSE);
+ } else {
+ HiLog.w(TAG, "mPref is null, get " + common.string.KEY_OF_AUTO_DELETE_INFO_SWITCH + " fail.");
+ return common.bool.FALSE;
+ }
+ }
+
+ /**
+ * Obtains the number of SIM cards.
+ */
+ getCountOfSim() {
+ let count = 0;
+ if (this.getSim1ExistFlag() === common.bool.TRUE) {
+ count++;
+ }
+ if (this.getSim2ExistFlag() == common.bool.TRUE) {
+ count++;
+ }
+ return count;
+ }
+
+ /**
+ * Check whether SIM card 1 exists.
+ */
+ getSim1ExistFlag() {
+ if (this.mPref !== null) {
+ return this.mPref.getSync(common.string.KEY_OF_SIM_0_EXIST_FLAG, common.bool.FALSE);
+ } else {
+ HiLog.w(TAG, "mPref is null, get " + common.string.KEY_OF_SIM_0_EXIST_FLAG + " fail.");
+ return common.bool.FALSE;
+ }
+ }
+
+ /**
+ * Check whether SIM card 2 exists.
+ */
+ getSim2ExistFlag() {
+ if (this.mPref !== null) {
+ return this.mPref.getSync(common.string.KEY_OF_SIM_1_EXIST_FLAG, common.bool.FALSE);
+ } else {
+ HiLog.w(TAG, "mPref is null, get " + common.string.KEY_OF_SIM_1_EXIST_FLAG + " fail.");
+ return common.bool.FALSE;
+ }
+ }
+
+ /**
+ * Obtain the carrier name of SIM card 1.
+ */
+ getSpnOfSim1() {
+ if (this.mPref !== null) {
+ return this.mPref.getSync(common.string.KEY_OF_SIM_0_SPN, common.string.EMPTY_STR);
+ } else {
+ HiLog.w(TAG, "mPref is null, get " + common.string.KEY_OF_SIM_0_SPN + " fail.");
+ return common.string.EMPTY_STR;
+ }
+ }
+
+ /**
+ * Obtain the carrier name of SIM card 2.
+ */
+ getSpnOfSim2() {
+ if (this.mPref !== null) {
+ return this.mPref.getSync(common.string.KEY_OF_SIM_1_SPN, common.string.EMPTY_STR);
+ } else {
+ HiLog.w(TAG, "mPref is null, get " + common.string.KEY_OF_SIM_1_SPN + " fail.");
+ return common.string.EMPTY_STR;
+ }
+ }
+
+ /**
+ * Obtain the new SMSC number of SIM card 1. If the number has been changed,
+ */
+ getNewSmscOfSim1() {
+ if (this.mPref !== null) {
+ return this.mPref.getSync(common.string.KEY_OF_NEW_SIM_0_SMSC, common.string.EMPTY_STR);
+ } else {
+ HiLog.w(TAG, "mPref is null, get " + common.string.KEY_OF_NEW_SIM_0_SMSC + " fail.");
+ return common.string.EMPTY_STR;
+ }
+ }
+
+ /**
+ * Obtain the new SMSC number of SIM card 2. If the number has been changed,
+ */
+ getNewSmscOfSim2() {
+ if (this.mPref !== null) {
+ return this.mPref.getSync(common.string.KEY_OF_NEW_SIM_1_SMSC, common.string.EMPTY_STR);
+ } else {
+ HiLog.w(TAG, "mPref is null, get " + common.string.KEY_OF_NEW_SIM_1_SMSC + " fail.");
+ return common.string.EMPTY_STR;
+ }
+ }
+
+ /**
+ * Set a value for
+ */
+ setValueForSwitch(keyOfSwitch, valueOfSwitch) {
+ if (this.mPref !== null) {
+ this.mPref.putSync(keyOfSwitch, valueOfSwitch);
+ this.mPref.flushSync();
+ } else {
+ HiLog.w(TAG, "mPref is null, set " + keyOfSwitch + " fail.");
+ }
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/utils/TelephoneUtil.ets b/entry/src/main/ets/utils/TelephoneUtil.ets
similarity index 62%
rename from entry/src/main/ets/default/utils/TelephoneUtil.ets
rename to entry/src/main/ets/utils/TelephoneUtil.ets
index 4fa967b..38eff50 100644
--- a/entry/src/main/ets/default/utils/TelephoneUtil.ets
+++ b/entry/src/main/ets/utils/TelephoneUtil.ets
@@ -12,27 +12,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import common from '../data/commonData';
-import HiLog from './HiLog';
-import call from '@ohos.telephony.call';
+import common from "../data/commonData";
+import HiLog from "./HiLog";
+import call from "@ohos.telephony.call";
-const TAG = 'TelephoneUtil';
+const TAG = "TelephoneUtil";
/**
* log package tool class
*/
const infoMegTelephone = [
- '1065796709202', '1065502043202', '1065902090202', '1069055999202',
- '106579670915', '106550204315', '106590209015', '106905599915',
- '106', '400', '111', '100', '118', '116', '12306', '12329', '12345',
- '12122', '12321', '12580', '12520', '12583', '02512329', '053287003810',
- '1258319559899', '1019', '12583110086', '000000', '95', '96',
+ "1065796709202", "1065502043202", "1065902090202", "1069055999202",
+ "106579670915", "106550204315", "106590209015", "106905599915",
+ "106", "400", "111", "100", "118", "116", "12306", "12329", "12345",
+ "12122", "12321", "12580", "12520", "12583", "02512329", "053287003810",
+ "1258319559899", "1019", "12583110086", "000000", "95", "96",
];
+
export default {
/**
- * 判断手机号是否是通知信息
- * @param telephone 手机号
- * @return 是或不是
+ * Check whether the mobile number is notification information.
+ * @param telephone
+ * @return Yes or no
*/
judgeIsInfoMsg(telephone) {
let result = false;
@@ -48,32 +49,32 @@ export default {
},
formatTelephone(telephone) {
- if(telephone == null || telephone == common.string.EMPTY_STR) {
+ if (telephone == null || telephone == common.string.EMPTY_STR) {
return common.string.EMPTY_STR;
}
- if(telephone.indexOf('+86') >= 0) {
+ if (telephone.indexOf("+86") >= 0) {
return telephone.substring(3);
}
return telephone;
},
dealSelectContactsSort(selectContacts) {
- if(selectContacts.length == 0) {
+ if (selectContacts.length == 0) {
return;
}
let result = [];
let telephone = common.string.EMPTY_STR;
let contactsMap = new Map();
- for(let item of selectContacts) {
+ for (let item of selectContacts) {
telephone = telephone + item.telephone + common.string.COMMA;
- if(!contactsMap.has(item.telephone)) {
+ if (!contactsMap.has(item.telephone)) {
contactsMap.set(item.telephone, item);
}
}
telephone = this.dealTelephoneSort(telephone.substring(0, telephone.length - 1));
let telephones = telephone.split(common.string.COMMA);
- for(let element of telephones) {
- if(contactsMap.has(element)) {
+ for (let element of telephones) {
+ if (contactsMap.has(element)) {
result.push(contactsMap.get(element));
}
}
@@ -81,26 +82,26 @@ export default {
},
/**
- * 手机号,从小到大进行排序
+ * Mobile number, sorted in ascending order.
* @param telephone
* @return
*/
- dealTelephoneSort(telephone){
- if(telephone == null || telephone == common.string.EMPTY_STR) {
+ dealTelephoneSort(telephone) {
+ if (telephone == null || telephone == common.string.EMPTY_STR) {
return common.string.EMPTY_STR;
}
let result = common.string.EMPTY_STR;
let telephones = telephone.split(common.string.COMMA);
- // 如果只有一个手机号,不需要进行排序
- if(telephones.length == 1) {
+ // If there is only one mobile number, no sorting is required.
+ if (telephones.length == 1) {
return telephone;
}
let telephoneMap = new Map();
let indexs = [];
let count = 0;
- // 分组
- for(let item of telephones) {
- if(telephoneMap.has(item.length)) {
+ // grouping
+ for (let item of telephones) {
+ if (telephoneMap.has(item.length)) {
let strings = telephoneMap.get(item.length);
strings.push(item);
} else {
@@ -110,33 +111,34 @@ export default {
indexs[count++] = item.length;
}
}
- // 从大到小排序
+ // Sort from Large to Small
this.bubbleSort(indexs, count);
- for(let index of indexs) {
+ for (let index of indexs) {
let arrs = telephoneMap.get(index);
this.bubbleSort(arrs, arrs.length);
for (let arr of arrs) {
result = result + arr + common.string.COMMA;
}
}
- // 取出对应的结果及进行配对
+ // Obtain the corresponding results and pair them.
return result.substring(0, result.length - 1);
},
/**
- * 冒泡排序, 从小到大排序
+ * Bubble sort, sorted in ascending order.
* @param arr
* @param length
* @return
*/
bubbleSort(arr, length) {
- // 每次从后往前冒一个最小值,且每次能确定一个数在序列中的最终位置
- for (let i = 0; i < length - 1; i++){
- // 冒泡的改进,若在一趟中没有发生逆序,则该序列已有序
- for (let j = length-1; j >i; j--){
- // 每次从后边冒出一个最小值
+ // A minimum value is generated from the back to the front at a time, and the final position of a number
+ // in the sequence can be determined at a time.
+ for (let i = 0; i < length - 1; i++) {
+ // Improvement of bubbling so that the sequence is ordered if no reversal occurs in one pass
+ for (let j = length - 1; j > i; j--) {
+ // A minimum value pops up from the back at a time.
if (arr[j] < arr[j - 1]) {
- // 发生逆序,则交换
+ // Reverse order occurs, then swap
let temple = arr[j];
arr[j] = arr[j - 1];
arr[j - 1] = temple;
@@ -146,7 +148,7 @@ export default {
},
async formatPhoneNumber(phoneNumber) {
if (phoneNumber == null || phoneNumber === common.string.EMPTY_STR) {
- HiLog.w(TAG, 'formatPhoneNumber, param is null');
+ HiLog.w(TAG, "formatPhoneNumber, param is null");
return common.string.EMPTY_STR;
}
let promise = call.formatPhoneNumber(phoneNumber);
@@ -154,7 +156,7 @@ export default {
promise.then((value) => {
formatPhoneNumber = value;
}).catch((err) => {
- HiLog.e(TAG, 'formatPhoneNumber, error: ' + JSON.stringify(err.message));
+ HiLog.e(TAG, "formatPhoneNumber, error: " + JSON.stringify(err.message));
});
await promise;
return formatPhoneNumber;
diff --git a/entry/src/main/ets/utils/WantUtil.ets b/entry/src/main/ets/utils/WantUtil.ets
new file mode 100644
index 0000000..668316f
--- /dev/null
+++ b/entry/src/main/ets/utils/WantUtil.ets
@@ -0,0 +1,94 @@
+/**
+ * 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 contactService from "../service/ContractService";
+import conversationListService from "../service/ConversationListService";
+import common from "../data/commonData";
+import featureAbility from "@ohos.ability.featureAbility";
+import HiLog from "./HiLog";
+import router from "@system.router";
+
+const TAG = "WantUtil";
+
+export default {
+ pageFlag: "0",
+ contractParams: {},
+
+ getWant() {
+ HiLog.i(TAG, "getWant start");
+ if (globalThis.abilityWant.hasOwnProperty("parameters")) {
+ let parameters = globalThis.abilityWant.parameters;
+ if (parameters.hasOwnProperty("pageFlag")) {
+ this.pageFlag = parameters.pageFlag;
+ HiLog.i(TAG, "pageFlag = " + this.pageFlag);
+ }
+ if (parameters.hasOwnProperty("contactObjects")) {
+ this.contractParams = contactService.dealContractParams(parameters.contactObjects);
+ }
+ }
+ // Page redirection
+ this.jump();
+ },
+
+ jump() {
+ let result = {
+ uri: '',
+ params: {}
+ };
+ HiLog.i(TAG, "want.pageFlag: " + this.pageFlag);
+ switch (this.pageFlag) {
+ case "conversation":
+ result.uri = "pages/conversation/conversation";
+ if (this.contractParams) {
+ result.params = this.contractParams;
+ this.jumpIsNewPage(result);
+ } else {
+ router.replace(result);
+ }
+ break;
+ default:
+ break;
+ }
+ },
+
+ async jumpIsNewPage(result) {
+ // Check whether a session has been created for the current phone number in the SMS message.
+ 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);
+ if (res.response.hasDraft && res.response.messageCount == 0) {
+ result.params.isNewMsg = true;
+ } else {
+ result.params.isNewMsg = false;
+ }
+ } else {
+ result.params.isNewMsg = true;
+ }
+ router.replace(result);
+ });
+ },
+
+ markAllAsRead(threadId) {
+ let actionData = {
+ threadIds: [threadId],
+ hasRead: 1,
+ valueBucket: {
+ "unread_count": 0
+ }
+ };
+ conversationListService.markAllAsRead(actionData);
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/default/views/MmsDialogs.ets b/entry/src/main/ets/views/MmsDialogs.ets
similarity index 59%
rename from entry/src/main/ets/default/views/MmsDialogs.ets
rename to entry/src/main/ets/views/MmsDialogs.ets
index 15e7a34..ca05a90 100644
--- a/entry/src/main/ets/default/views/MmsDialogs.ets
+++ b/entry/src/main/ets/views/MmsDialogs.ets
@@ -15,30 +15,30 @@
import DeviceUtil from "../utils/DeviceUtil";
/**
- * 弹框种类:无标题,1个消息,2个按钮
+ * Type of the dialog box: No title, 1 message, and 2 buttons
*/
@CustomDialog
export struct DeleteDialog {
controller: CustomDialogController;
/**
- * 取消事件
+ * Cancel Event
*/
cancel: () => void;
/**
- * 确认事件
+ * Acknowledge Event
*/
confirm: () => void;
/**
- * 消息内容
+ * Message content
*/
msg: string | Resource;
/**
- * 删除的信息中,是否包含锁定的信息
+ * Check whether the deleted information contains locked information.
*/
hasLockMsg: boolean;
setSelectLock?: () => void;
/**
- * 是否同步删除锁定信息勾选项
+ * Whether to delete lock information synchronously
*/
isSelectLockMsg?: boolean;
setSelectLockChange?: (isOn: boolean) => void;
@@ -46,26 +46,26 @@ export struct DeleteDialog {
build() {
Column() {
Text(this.msg)
- .width('100%')
+ .width("100%")
.margin({ bottom: 8 })
.textAlign(TextAlign.Center)
.fontSize(16)
- .fontColor('#182431')
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
.lineHeight(22)
.fontWeight(FontWeight.Regular)
- .fontFamily('HarmonyHeiTi')
+ .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')
+ .width("20vp")
+ .height("20vp")
.onChange((isOn: boolean) => {
this.setSelectLockChange(isOn)
})
- Text($r("app.string.msg_delete_dialog_cb_tip")).height('100%')
+ Text($r("app.string.msg_delete_dialog_cb_tip")).height("100%")
}
- .width('100%')
- .height('32vp')
+ .width("100%")
+ .height("32vp")
.onClick((event?: ClickEvent) => {
this.setSelectLock();
})
@@ -79,45 +79,50 @@ export struct DeleteDialog {
Text($r("app.string.cancel"))
.textAlign(TextAlign.Center)
.fontSize(16)
- .fontColor('#007DFF')
+ .fontColor($r("sys.color.ohos_id_color_floating_button_bg_normal"))
.fontWeight(FontWeight.Medium)
- .fontFamily('HarmonyHeiTi')
+ .fontFamily("HarmonyHeiTi")
.lineHeight(22)
}
- .backgroundColor($r("app.color.back_Transparent"))
+ .backgroundColor($r("sys.color.ohos_id_color_background_transparent"))
.layoutWeight(1)
.onClick(() => {
this.controller.close();
this.cancel();
})
- Divider().vertical(true).strokeWidth('2px').height('20vp').color(Color.Gray)
+ Divider()
+ .vertical(true)
+ .strokeWidth("1px")
+ .height("20vp")
+ .color($r("sys.color.ohos_id_color_list_separator"))
Button() {
Text($r("app.string.delete"))
.textAlign(TextAlign.Center)
.fontSize(16)
- .fontColor('#FA2A2D')
+ .fontColor($r("sys.color.ohos_id_color_warning"))
.fontWeight(FontWeight.Medium)
- .fontFamily('HarmonyHeiTi')
+ .fontFamily("HarmonyHeiTi")
.lineHeight(22)
}
- .backgroundColor($r("app.color.back_Transparent"))
+ .backgroundColor($r("sys.color.ohos_id_color_background_transparent"))
.layoutWeight(1)
.onClick(() => {
this.controller.close();
this.confirm();
})
}
- .width('100%')
+ .width("100%")
.height(40)
}
- .width('100%')
+ .width("100%")
.padding({ left: 24, right: 24, top: 24, bottom: 16 })
}
}
export class MmsSimpleDialog {
value: AlertDialogParamWithMms;
+ private dialogGridCount: number = 4;
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) {
@@ -131,20 +136,64 @@ export class MmsSimpleDialog {
autoCancel: false,
alignment: this.dialogAlignment,
offset: this.dialogOffset,
+ gridCount: this.dialogGridCount,
primaryButton: {
value: this.value.primaryButton.value,
- action: this.value.primaryButton.action
+ action: this.value.primaryButton.action,
+ fontColor: $r("sys.color.ohos_id_color_activated")
},
secondaryButton: {
value: this.value.secondaryButton.value,
action: this.value.secondaryButton.action,
- fontColor: $r("sys.color.ohos_id_color_handup")
+ fontColor: $r("sys.color.ohos_id_color_warning")
}
}
)
}
}
+
+@CustomDialog
+export struct SysSimpleExample {
+ controller: CustomDialogController
+ cancel: () => void
+ confirm: () => void
+
+ value: AlertDialogParamWithMms;
+ private dialogAlignment: DialogAlignment = DeviceUtil.isTablet() ? DialogAlignment.Center : DialogAlignment.Bottom;
+ private dialogOffset: Offset = DeviceUtil.isTablet() ? { dx: 0, dy: 0 } : { dx: 0, dy: -12 };
+
+ build() {
+ Column() {
+ Text(this.value.message)
+ .fontSize(16)
+ .fontWeight(FontWeight.Regular)
+ .margin({ top: 24, bottom: 8 })
+ Flex({ justifyContent: FlexAlign.SpaceAround ,alignItems: ItemAlign.Center}) {
+ Button($r("app.string.cancel"))
+ .onClick(() => {
+ this.controller.close()
+ this.cancel()
+ })
+ .backgroundColor(0xffffff)
+ .fontColor($r("sys.color.ohos_id_color_activated"))
+ .fontWeight(FontWeight.Medium)
+ .layoutWeight(1)
+ Text("|").fontSize(16).fontColor(Color.Gray)
+ Button($r("app.string.restore"))
+ .onClick(() => {
+ this.controller.close()
+ this.confirm()
+ })
+ .backgroundColor(0xffffff)
+ .fontColor($r("sys.color.ohos_id_color_warning"))
+ .fontWeight(FontWeight.Medium)
+ .layoutWeight(1)
+ }.margin({ bottom: 12 ,top:12})
+ }.borderRadius(24)
+ }
+}
+
declare interface AlertDialogParamWithMms {
message: ResourceStr;
primaryButton: {
@@ -164,41 +213,41 @@ export interface CheckBoxItem {
}
/**
- * 弹框种类:1标题,2个勾选项,2按钮
+ * Type of the dialog box: 1 title, 2 options, and 2 buttons
*/
@CustomDialog
export struct CheckBoxDialog {
controller: CustomDialogController;
/**
- * 取消事件
+ * Cancel Event
*/
cancel: () => void;
/**
- * 确认事件
+ * Acknowledge Event
*/
confirm: () => void;
/**
- * 标题
+ * Title
*/
title: string | Resource;
/**
- * 选项集合
+ * Option Collection
*/
@State itemList: Array = [];
build() {
Column() {
- // dialog标题
+ // dialog title
Text(this.title)
- .width('100%')
+ .width("100%")
.margin({ bottom: 8 })
.fontSize(16)
- .fontColor('#182431')
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
.lineHeight(22)
.fontWeight(FontWeight.Regular)
- .fontFamily('HarmonyHeiTi')
- // item勾选列表
+ .fontFamily("HarmonyHeiTi")
+ // item Checklist
ForEach(this.itemList, (item, index) => {
Flex({
direction: FlexDirection.Row,
@@ -207,15 +256,15 @@ export struct CheckBoxDialog {
}) {
Text(item.title)
Toggle({ type: ToggleType.Checkbox, isOn: item.isOn })
- .width('20vp')
- .height('20vp')
+ .width("20vp")
+ .height("20vp")
.enabled(false)
}
- .width('100%')
- .height('32vp')
+ .width("100%")
+ .height("32vp")
.onClick(item.onClick)
}, (item, index) => index.toString())
- // 确定和取消按钮
+ // OK and Cancel Buttons
Flex({
direction: FlexDirection.Row,
justifyContent: FlexAlign.SpaceEvenly,
@@ -225,35 +274,39 @@ export struct CheckBoxDialog {
Text($r("app.string.cancel"))
.textAlign(TextAlign.Center)
.fontSize(16)
- .fontColor('#007DFF')
+ .fontColor($r("sys.color.ohos_id_color_floating_button_bg_normal"))
.fontWeight(FontWeight.Medium)
- .fontFamily('HarmonyHeiTi')
+ .fontFamily("HarmonyHeiTi")
.lineHeight(22)
.onClick(() => {
this.controller.close();
this.cancel();
})
- }.backgroundColor($r("app.color.back_Transparent")).layoutWeight(1)
+ }.backgroundColor($r("sys.color.ohos_id_color_background_transparent")).layoutWeight(1)
- Divider().vertical(true).strokeWidth('2px').height('20vp').color(Color.Gray)
+ Divider()
+ .vertical(true)
+ .strokeWidth("1px")
+ .height("20vp")
+ .color($r("sys.color.ohos_id_color_list_separator"))
Button() {
Text($r("app.string.ok"))
.textAlign(TextAlign.Center)
.fontSize(16)
- .fontColor('#007DFF')
+ .fontColor($r("sys.color.ohos_id_color_floating_button_bg_normal"))
.fontWeight(FontWeight.Medium)
- .fontFamily('HarmonyHeiTi')
+ .fontFamily("HarmonyHeiTi")
.lineHeight(22)
.onClick(() => {
this.controller.close();
this.confirm();
})
- }.backgroundColor($r("app.color.back_Transparent")).layoutWeight(1)
+ }.backgroundColor($r("sys.color.ohos_id_color_background_transparent")).layoutWeight(1)
}
- .width('100%')
+ .width("100%")
.height(40)
}
- .width('100%')
+ .width("100%")
.padding({ left: 24, right: 24, top: 24, bottom: 16 })
}
}
\ No newline at end of file
diff --git a/entry/src/main/ets/views/MmsListItem.ets b/entry/src/main/ets/views/MmsListItem.ets
new file mode 100644
index 0000000..4204157
--- /dev/null
+++ b/entry/src/main/ets/views/MmsListItem.ets
@@ -0,0 +1,222 @@
+/**
+ * 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";
+
+@Component
+export struct MmsListItem {
+ @State item: LooseObject = {};
+ private isShowHead: boolean = true;
+ private isMultipleSelectState: boolean = false;
+ onClickHead: (event?: ClickEvent) => void;
+ onClickBody: (event?: ClickEvent) => void;
+ onItemLongPress: (event?: GestureEvent) => void;
+ onTouchStart: (event?: GestureEvent) => void;
+ onTouchUpdate: (event?: GestureEvent) => void;
+ onTouchEnd: (event?: GestureEvent) => void;
+ onClickFirstSlipBtn: (event?: ClickEvent) => void;
+ onClickSecondSlipBtn: (event?: ClickEvent) => void;
+
+ build() {
+ Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.End }) {
+ Row() {
+ Row() {
+ //avatar
+ if (this.isShowHead) {
+ //Whether to add a red dot to the unread flag
+ Stack() {
+ Column() {
+ Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
+ 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($r("sys.color.ohos_id_color_badge_red"))
+ .fontColor($r("sys.color.ohos_id_color_background"))
+ .zIndex(2)
+ .position({ x: "60%", y: "-10%" })
+ .border({
+ width: 2,
+ color: $r("sys.color.ohos_id_color_background"),
+ radius: 50
+ })
+ }
+ //SMS message type. 0: common; 1: notification
+ if(this.item.conversation.smsType === 0) {
+ if(this.item.conversation.photoFirstName === '') {
+ Image($rawfile("icon/ic_user_portrait.svg"))
+ .objectFit(ImageFit.Fill)
+ .width("40vp")
+ .height("40vp")
+ .clip(new Circle({ width: "40vp", height: "40vp" }))
+ .backgroundColor(this.item.conversation.portraitColor)
+ } else {
+ Text(this.item.conversation.photoFirstName)
+ .fontSize("30vp")
+ .fontWeight(FontWeight.Bold)
+ .fontColor(Color.White)
+ .height("40vp")
+ .width("40vp")
+ .textAlign(TextAlign.Center)
+ .clip(new Circle({ width: "40vp", height: "40vp" }))
+ .backgroundColor(this.item.conversation.portraitColor)
+ }
+ } else {
+ Image($rawfile(this.item.conversation.icon))
+ .objectFit(ImageFit.Fill)
+ .width("40vp")
+ .height("40vp")
+ }
+ }
+ .width("40vp")
+ .height("40vp")
+ .onClick(this.onClickHead)
+ }.height("100%").justifyContent(FlexAlign.Center)
+ }
+ }
+
+ //body
+ Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start }) {
+ Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center }) {
+ Flex({ direction: FlexDirection.Row,
+ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
+ //Phone number or first name
+ Text(this.item.conversation.name != '' ? this.item.conversation.name :
+ this.item.conversation.telephoneFormat)
+ .fontSize("16fp")
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+ .maxLines(1)
+ .fontWeight(FontWeight.Medium)
+ Text().width(16)
+ //Date Time
+ Text(this.item.conversation.time)
+ .fontColor($r("sys.color.ohos_id_color_text_tertiary"))
+ .fontSize("12fp")
+ .maxLines(1)
+ .flexShrink(0)
+ }.width("100%").height(22)
+
+ //Content Abbreviations for Latest News
+ Row() {
+ //Whether the latest message has not been sent successfully. If yes,
+ if (this.item.conversation.sendingFailed) {
+ Text($r("app.string.messageSendFailed"))
+ .fontSize("12fp")
+ .fontColor($r("sys.color.ohos_id_color_warning"))
+ } else {
+ //If it's not
+ Row() {
+ Text() {
+ //Whether the latest message is a draft, and if so
+ if (this.item.conversation.isDraft) {
+ Span($r("app.string.draft"))
+ .fontSize("14fp")
+ .fontColor(Color.Red)
+ }
+ }
+ .margin({ right: 2 })
+ .maxLines(1)
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
+
+ Text() {
+ //If no, and the number of unread messages is greater than 1.
+ if (!this.item.conversation.isDraft &&
+ this.item.conversation.countOfUnread > 1) {
+ Span($r("app.string.multiUnread", this.item.conversation.countOfUnread))
+ .fontSize("14fp")
+ .fontColor($r("sys.color.ohos_id_color_help_tip_bg"))
+ }
+ //Content Abbreviations for Latest News
+ Span(this.item.conversation.content)
+ .fontSize("14fp")
+ .fontColor($r("sys.color.ohos_id_color_text_tertiary"))
+ }
+ .maxLines(1)
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
+ }
+ }
+ }
+ .alignSelf(ItemAlign.Start)
+ .alignItems(VerticalAlign.Top)
+ .width("100%")
+ .height(19)
+ .margin({ top: "2vp" })
+ }.width("100%")
+ .height("100%")
+ }
+ .layoutWeight(1)
+ .height("100%")
+ .padding({ left: "12vp" })
+
+ //CheckBox
+ if (this.isMultipleSelectState) {
+ Toggle({ type: ToggleType.Checkbox, isOn: this.item.conversation.isCbChecked })
+ .width("20vp")
+ .height("20vp")
+ .selectedColor($r("sys.color.ohos_id_color_activated"))
+ .enabled(false)
+ .margin({ right: -14 })
+ }
+ }
+ .alignItems(VerticalAlign.Top)
+ .width("100%")
+ .height("100%")
+ .translate({
+ x: this.item.conversation.itemLeft
+ })
+ //Swipe left to delete icon
+ if (!this.isMultipleSelectState) {
+ Flex({
+ direction: FlexDirection.Row,
+ justifyContent: FlexAlign.SpaceEvenly,
+ alignItems: ItemAlign.Center
+ }) {
+ if (this.item.conversation.countOfUnread > 0) {
+ Image($rawfile("icon/msg_done.svg"))
+ .width(40)
+ .height(40)
+ .onClick(this.onClickFirstSlipBtn)
+ }
+ Image($rawfile("icon/msg_delete.svg"))
+ .width(40)
+ .height(40)
+ .onClick(this.onClickSecondSlipBtn)
+ }
+ .width(this.item.conversation.countOfUnread > 0 ? 128 : 80)
+ .height("100%")
+ .flexShrink(0)
+ .backgroundColor($r("sys.color.ohos_id_color_background"))
+ .translate({
+ x: this.item.conversation.itemLeft
+ })
+ }
+ }
+ .width("100%")
+ .height("100%")
+ .gesture(PanGesture({
+ direction: this.item.conversation.isDelShow ? PanDirection.Right : PanDirection.Left
+ })
+ .onActionStart(this.onTouchStart)
+ .onActionUpdate(this.onTouchUpdate)
+ .onActionEnd(this.onTouchEnd)
+ )
+ }
+ .onClick(this.onClickBody)
+ .gesture(LongPressGesture().onAction(this.onItemLongPress))
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/views/MmsMenu.ets b/entry/src/main/ets/views/MmsMenu.ets
new file mode 100644
index 0000000..d709fe5
--- /dev/null
+++ b/entry/src/main/ets/views/MmsMenu.ets
@@ -0,0 +1,89 @@
+/**
+ * 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 DeviceUtil from "../utils/DeviceUtil";
+
+/**
+ * Custom pop-up menu buttons
+ */
+@Component
+export struct MoreMenu {
+ @StorageLink('curBp') curBp: string = 'sm'
+ private menuItems: Array;
+ private menuImage: Resource = $rawfile("icon/ic_public_more.svg");
+ private placement: Placement = Placement.Bottom;
+ private defaultColor: Resource = $r("sys.color.ohos_id_color_dialog_bg");
+ private menuText: Resource = null;
+ private menuTextColor: Resource = $r("sys.color.ohos_id_color_text_primary");
+
+ @Builder PopupBuilder() {
+ Column() {
+ List() {
+ ForEach(this.menuItems, (item, index) => {
+ ListItem() {
+ Button({ type: ButtonType.Normal, stateEffect: item.enabled }) {
+ Text(item.value)
+ .fontSize(16)
+ .lineHeight(21)
+ .width("100%")
+ .height(48)
+ .padding({ left: 12, right: 12 })
+ .fontWeight(FontWeight.Regular)
+ .fontColor(item.enabled ? $r("sys.color.ohos_id_color_text_primary") :
+ $r("sys.color.ohos_id_color_text_tertiary"))
+ }
+ .width("100%")
+ .height(48)
+ .borderRadius(16)
+ .backgroundColor($r("sys.color.ohos_id_color_foreground_contrary"))
+ .onClick(() => {
+ if (item.enabled) {
+ item.action();
+ }
+ })
+ }
+ }, item => JSON.stringify(item))
+ }
+ .listDirection(Axis.Vertical) // Arrange Direction
+ .divider({
+ strokeWidth: 0.5,
+ color: $r("sys.color.ohos_id_color_list_separator"),
+ startMargin: 12,
+ endMargin: 12
+ }) // Demarcation line between each row
+ .edgeEffect(EdgeEffect.Spring) // Slide to Edge Effect
+ .chainAnimation(false) // Disable linkage special effects.
+ }
+ .backgroundColor(this.defaultColor)
+ .width(this.curBp == '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 })
+ }
+ }
+ .bindMenu(this.PopupBuilder)
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/views/SettingItem.ets b/entry/src/main/ets/views/SettingItem.ets
new file mode 100644
index 0000000..952f6d4
--- /dev/null
+++ b/entry/src/main/ets/views/SettingItem.ets
@@ -0,0 +1,167 @@
+/**
+ * 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 MmsBoolean from "../data/MmsBoolean"
+/**
+ * Options: dual title, 1 switch
+ */
+@Component
+export struct SettingItemSwitch {
+ primaryTitle: string | Resource;
+ secondaryTitle?: string | Resource;
+ @ObjectLink isEnable: MmsBoolean;
+ showBottomDivider ?: boolean = false;
+ visibilityShow ?: Visibility = Visibility.Visible;
+ onChange: (isOn: boolean) => void;
+
+ build() {
+ Column() {
+ Flex({
+ direction: FlexDirection.Row,
+ justifyContent: FlexAlign.SpaceBetween,
+ alignItems: ItemAlign.Center
+ }) {
+ Flex({
+ direction: FlexDirection.Column,
+ justifyContent: FlexAlign.Center,
+ alignItems: ItemAlign.Start
+ }) {
+ Text(this.primaryTitle)
+ .height($r("app.float.settings_item_primary_title_height"))
+ .fontWeight(FontWeight.Medium)
+ .fontSize($r("app.float.settings_item_primary_title_font_size"))
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+
+ if (this.secondaryTitle != undefined) {
+ Text(this.secondaryTitle)
+ .height($r("app.float.settings_item_secondary_title_height"))
+ .margin({ top: $r("app.float.settings_item_title_space") })
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r("app.float.settings_item_secondary_title_font_size"))
+ .fontColor($r("sys.color.ohos_id_color_text_tertiary"))
+ }
+ }
+ .layoutWeight(1)
+
+ Toggle({ type: ToggleType.Switch, isOn: this.isEnable.value })
+ .width($r("app.float.settings_item_switch_width"))
+ .offset({ x: 4, y: 0 })
+ .selectedColor($r("sys.color.ohos_id_color_activated"))
+ .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("sys.color.ohos_id_color_list_separator"))
+ .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.visibilityShow)
+ }
+}
+
+/**
+ * Setting items: double title, one status, and one next icon
+ */
+@Component
+export struct SettingItemJump {
+ primaryTitle: string | Resource;
+ secondaryTitle ?: string | Resource;
+ private statusTitle ?: string | Resource = "";
+ showBottomDivider ?: boolean = false;
+ visibilityShow ?: Visibility = Visibility.Visible;
+ OnClick: (event?: ClickEvent) => void;
+
+ build() {
+ Column() {
+ Flex({
+ direction: FlexDirection.Row,
+ justifyContent: FlexAlign.SpaceBetween,
+ alignItems: ItemAlign.Center
+ }) {
+ Flex({
+ direction: FlexDirection.Column,
+ justifyContent: FlexAlign.Center,
+ alignItems: ItemAlign.Start
+ }) {
+ Text(this.primaryTitle)
+ .height($r("app.float.settings_item_primary_title_height"))
+ .fontWeight(FontWeight.Medium)
+ .fontSize($r("app.float.settings_item_primary_title_font_size"))
+ .fontColor($r("sys.color.ohos_id_color_text_primary"))
+
+ if (this.secondaryTitle != undefined) {
+ Text(this.secondaryTitle)
+ .height($r("app.float.settings_item_secondary_title_height"))
+ .margin({ top: $r("app.float.settings_item_title_space") })
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r("app.float.settings_item_secondary_title_font_size"))
+ .fontColor($r("sys.color.ohos_id_color_text_tertiary"))
+ }
+ }
+ .layoutWeight(1)
+
+ Row() {
+ if (this.statusTitle != undefined) {
+ Text(this.statusTitle)
+ .height($r("app.float.settings_item_secondary_title_height"))
+ .margin({ right: $r("app.float.settings_item_status_title_margin_right") })
+ .fontWeight(FontWeight.Regular)
+ .fontSize($r("app.float.settings_item_secondary_title_font_size"))
+ .fontColor($r("sys.color.ohos_id_color_text_secondary"))
+ }
+
+ Image($rawfile("icon/ic_next.svg"))
+ .width($r("app.float.settings_item_next_image_width"))
+ .height($r("app.float.settings_item_next_image_height"))
+ }
+ }
+ .layoutWeight(1)
+ .onClick(this.OnClick)
+
+ if (this.showBottomDivider) {
+ Divider()
+ .vertical(false)
+ .strokeWidth(1)
+ .color($r("sys.color.ohos_id_color_list_separator"))
+ .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.visibilityShow)
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/views/receive/receive.ets b/entry/src/main/ets/views/receive/receive.ets
new file mode 100644
index 0000000..f0b286e
--- /dev/null
+++ b/entry/src/main/ets/views/receive/receive.ets
@@ -0,0 +1,218 @@
+/**
+ * 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 ReceiveController from "./receiveController"
+import ConversationController from "../../pages/conversation/conversationController"
+
+@Component
+export struct Receive {
+ @State mReceiveController: ReceiveController = ReceiveController.getInstance();
+ @Link mConversationController: ConversationController;
+
+ aboutToAppear() {
+ this.mReceiveController.onInit((receiverData) => {
+ this.mConversationController.setReceiveContactValue(receiverData)
+ })
+ }
+
+ build() {
+ Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
+ Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
+ Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
+ Text($r("app.string.putAddresser"))
+ .maxLines(1)
+ .lineHeight($r("app.float.addressee_line_height"))
+ .fontSize($r("app.float.addressee_font_size"))
+ .fontColor($r("sys.color.ohos_id_color_text_secondary"))
+ .fontWeight(FontWeight.Regular)
+ .fontFamily("HarmonyHeiTi")
+ .flexShrink(0)
+ Flex({ wrap: FlexWrap.NoWrap, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
+ // If a contact is selected
+ 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)
+ .maxLines(1)
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
+ .fontSize(12)
+ .flexShrink(1)
+ }
+ if (item.contactName != "" && item.contactName != null) {
+ Text(item.contactName)
+ .textAlign(TextAlign.Center)
+ .maxLines(1)
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
+ .fontSize(12)
+ .flexShrink(1)
+ }
+ if (item.select) {
+ Image($rawfile("icon/ic_public_cancel.svg"))
+ .width(16)
+ .height(16)
+ .flexShrink(1)
+ }
+ }
+ .padding({ left: 8, right: 8 })
+ .margin(8)
+ .backgroundColor($r("sys.color.ohos_id_color_component_normal"))
+ .borderRadius(24)
+ .height(28)
+ .alignItems(VerticalAlign.Center)
+ .constraintSize({ maxWidth: item.select ? 136 : 120 })
+ .onClick(() => {
+ this.mReceiveController.nameClick(index, (receiverData) => {
+ this.mConversationController.setReceiveContactValue(receiverData);
+ })
+ })
+ }, item => item.toString())
+ }
+ Flex() {
+ TextArea({ text: this.mReceiveController.myText })
+ .caretColor($r("sys.color.ohos_id_color_focused_outline"))
+ .placeholderColor($r("sys.color.ohos_id_color_text_hint"))
+ .backgroundColor($r("sys.color.ohos_id_color_background_transparent"))
+ .focusable(true)
+ .flexShrink(1)
+ .onChange((value) => {
+ this.mReceiveController.searchChange(value, (receiverData) => {
+ this.mConversationController.setReceiveContactValue(receiverData);
+ });
+ })
+ .onBlur(() => {
+ this.mReceiveController.checkReceive((receiverData) => {
+ this.mConversationController.setReceiveContactValue(receiverData);
+ });
+ })
+ .onFocus(() => {
+ this.mReceiveController.myContactFocus();
+ })
+ }
+ .flexShrink(1)
+ .constraintSize({ maxHeight: 120 })
+ }
+ else {
+ Text(this.mReceiveController.strSelectContact)
+ .fontColor($r("sys.color.ohos_id_color_text_primary_activated"))
+ .textAlign(TextAlign.Center)
+ .fontSize(16)
+ .lineHeight(22)
+ .maxLines(1)
+ .textAlign(TextAlign.Start)
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
+ .width("100%")
+ .padding({ top: 12, bottom: 12 })
+ .onClick(() => {
+ this.mReceiveController.myContactClick();
+ })
+ }
+ }
+ .flexShrink(1)
+ }
+ .flexBasis("auto")
+ .flexShrink(1)
+
+ // Contact icon on the right
+ Image($rawfile("icon/ic_about.svg"))
+ .width(24)
+ .height(24)
+ .onClick(() => {
+ // The page for selecting a contact is displayed.
+ this.mReceiveController.clickToContracts((receiverData) => {
+ this.mConversationController.setReceiveContactValue(receiverData);
+ })
+ })
+
+ }
+ .constraintSize({ minHeight: 56, maxHeight:200 })
+ .backgroundColor($r("sys.color.ohos_id_color_background"))
+ .borderRadius($r("app.float.settings_items_radius"))
+ .padding({ left: 12, right: 12 })
+
+ Column() {
+ // Indicates whether to display the recent contact list.
+ if (this.mReceiveController.isShowSearch && this.mReceiveController.contacts.length > 0) {
+ Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
+ Text("最近联系人")
+ .fontSize(16)
+ .fontColor($r("sys.color.ohos_id_color_text_tertiary"))
+ .fontWeight(FontWeight.Regular)
+ }
+ .height(48)
+ // List area
+ List({ space: 0, initialIndex: 0 }) {
+ ForEach(this.mReceiveController.contacts, (item, index) => {
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
+ Image($rawfile("icon/ic_user_portrait.svg"))
+ .objectFit(ImageFit.Fill)
+ .width("40vp")
+ .height("40vp")
+ .clip(new Circle({ width: "40vp", height: "40vp" }))
+ .backgroundColor($r("app.color.ic_user_head_color"))
+ .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("sys.color.ohos_id_color_text_primary"))
+ .maxLines(1)
+ .fontWeight(FontWeight.Medium)
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
+ }
+ Text(item.telephoneFormat)
+ .fontColor($r("sys.color.ohos_id_color_text_tertiary"))
+ .fontSize(14)
+ .maxLines(1)
+ .margin({ top: 4 })
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
+ }
+ .layoutWeight(1)
+ .margin({ left: 12 })
+ .onClick(() => {
+ this.mReceiveController.addContact(index, (receiverData) => {
+ this.mConversationController.setReceiveContactValue(receiverData);
+ })
+ })
+ }
+ .width('100%')
+ .height(64)
+ }
+ }, item => item.toString())
+ }
+ .listDirection(Axis.Vertical) // Arrange Direction
+ .edgeEffect(EdgeEffect.Spring) // Sliding to the edge has no effect
+ .divider({
+ strokeWidth: 1,
+ color: $r("sys.color.ohos_id_color_list_separator"),
+ startMargin: 52,
+ endMargin: 0
+ }) // Demarcation line between each row
+ }
+ }.padding({ left: 12, right: 12, bottom: 56 })
+ }
+ .width("100%")
+ .padding({ left: 12, right: 12 })
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/ets/views/receive/receiveController.ets b/entry/src/main/ets/views/receive/receiveController.ets
new file mode 100644
index 0000000..b93ec01
--- /dev/null
+++ b/entry/src/main/ets/views/receive/receiveController.ets
@@ -0,0 +1,456 @@
+/**
+ * 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";
+// Recipient
+import prompt from "@system.prompt";
+// JS public constant
+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"
+
+let ReceiveCtrl;
+
+const TAG = "ReceiveController";
+
+export default class ReceiveController {
+ private static sInstance: ReceiveController;
+ commonCtrl = commonCtrl.getInstance();
+ refresh: boolean = false;
+ // Recipient information (selected)
+ selectContacts: Array = [];
+ contacts: Array = [];
+ // Recipient list information (all)
+ contactsTemp: Array = [];
+ // Recipient Content
+ myText: string = '';
+ // true: focus editing status (gray); false: no focus (blue)
+ isInputStatus: boolean = true;
+ // true Show Search List
+ isShowSearch: boolean = true;
+ strSelectContact: string = '';
+ styleTextarea: string = "select-contact-textarea";
+ hasBlur: boolean = false;
+ // List pagination, number of pages
+ page: number = 0;
+ // List pagination, quantity
+ limit: number = 10;
+ // Total number of contacts
+ totalMessage: number = 0;
+
+ static getInstance() {
+ if (ReceiveController.sInstance == null) {
+ ReceiveController.sInstance = new ReceiveController();
+ }
+ return ReceiveController.sInstance;
+ }
+
+ onInit(call) {
+ HiLog.i(TAG, "onInit()")
+ // this.$watch("paramContact", "onPropertyChange");
+ this.selectContacts = this.commonCtrl.paramContact.transmitContracts;
+ if (this.selectContacts.length > 0) {
+ let that = this;
+ setTimeout(function () {
+ that.setContactValue(call);
+ }, 200);
+ this.isShowSearch = false;
+ this.setInputStatus(false);
+ }
+ this.requestItem()
+ this.refresh = !this.refresh;
+ }
+
+ requestItem() {
+ let count = this.page * this.limit;
+ if (this.page === 0) {
+ this.page++;
+ this.queryContacts();
+ } else if (count < this.totalMessage && this.contacts.length > (this.page - 1) * this.limit) {
+ // The restriction on Contacts is to prevent multiple refresh requests during initialization.
+ this.page++;
+ this.queryContacts();
+ }
+ }
+
+ queryContacts() {
+ let actionData = {
+ page: this.page,
+ limit: this.limit
+ };
+ // Querying Contacts
+ contractService.queryContact(actionData, contacts => {
+ if (common.int.SUCCESS == contacts.code) {
+ let response = this.contacts.concat(contacts.response);
+ this.contacts = [];
+ this.contacts = response;
+ this.contactsTemp = this.contacts.slice(0);
+ } else {
+ HiLog.w(TAG, "queryContacts, fail");
+ }
+ });
+ // Number of statistics
+ contractService.countContact(actionData, contacts => {
+ this.totalMessage = contacts.response;
+ });
+ }
+
+ searchContacts(textValue, callback) {
+ HiLog.i(TAG, "searchContacts start");
+ let actionData = {
+ telephone: textValue,
+ };
+ contractService.searchContracts(actionData, res => {
+ let code = res.code;
+ if (common.int.SUCCESS == res.code) {
+ this.contacts = [];
+ this.contacts = res.response;
+ } else {
+ HiLog.w(TAG, "searchContacts fail");
+ }
+ callback(code);
+ });
+ }
+ // Filter search terms to match contacts
+ filterContacts(textValue) {
+ this.contacts = this.contactsTemp.filter((contact) => {
+ if (contact.contactName && contact.contactName.toLowerCase().search(textValue) != -1) {
+ HiLog.i(TAG, "filterContacts, contactName");
+ return true;
+ } else if (contact.telephone && contact.telephone.toLowerCase().search(textValue) != -1) {
+ HiLog.i(TAG, "filterContacts, telephone");
+ return true;
+ }
+ return false;
+ });
+ }
+
+ isPhoneNumber(str) {
+ // Determine whether the value is a number.
+ let reg = /^\d{1,}$/;
+ let pattern = new RegExp(reg);
+ return pattern.test(str);
+ }
+
+ setInputStatus(flag) {
+ this.isInputStatus = flag;
+ if (!flag) {
+ this.strSelectContact = this.setShowContactName();
+ }
+ }
+
+ checkReceive(call) {
+ HiLog.i(TAG, "checkReceive, isInputStatus: " + this.isInputStatus);
+ if (this.myText.trim() == common.string.EMPTY_STR) {
+ this.setInputStatus(false);
+ this.isShowSearch = false;
+ return;
+ }
+ this.hasBlur = true;
+ if (this.isPhoneNumber(this.myText)) {
+ // Get information from the contact list
+ let that = this;
+ let selectContact: LooseObject = {};
+ let hasSelect = false;
+ for (let index in this.contacts) {
+ let contract = this.contacts[index];
+ if (contract.telephone == that.myText) {
+ selectContact.headImage = "icon/user_avatar_full_fill.svg";
+ selectContact.contactName = contract.contactName;
+ selectContact.telephone = contract.telephone;
+ selectContact.telephoneFormat = contract.telephone;
+ selectContact.select = false;
+ hasSelect = true;
+ break;
+ }
+ }
+ if (!hasSelect) {
+ selectContact.headImage = common.string.EMPTY_STR;
+ selectContact.contactName = common.string.EMPTY_STR;
+ selectContact.telephone = that.myText;
+ selectContact.telephoneFormat = that.myText;
+ selectContact.select = false;
+ }
+ HiLog.i(TAG, "checkReceive, isPhoneNumber yes");
+ this.selectContacts.push(selectContact);
+ this.refresh = !this.refresh;
+ this.setInputStatus(false);
+ this.isShowSearch = false;
+ this.setContactValue(call);
+ } else {
+ HiLog.i(TAG, "checkReceive, isPhoneNumber no");
+ prompt.showToast({
+ // Invalid Recipient
+ // @ts-ignore
+ message: $r("app.string.invalid_receive", this.myText),
+ duration: 1000,
+ });
+ 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.myText.trim() != "") {
+ this.setContactValue(call);
+ this.dealSearchData();
+ this.setContactValue(call);
+ } else {
+ this.setContactValue(call);
+ }
+ });
+ }
+
+ dealSearchData() {
+ if (this.myText.trim() == "") {
+ this.contacts = this.contactsTemp.slice(0);
+ // this.$element("receiveTxt").focus({
+ // focus: true
+ // });
+ } else {
+ let textValue = this.myText.trim().toLowerCase();
+ // Filtering logic
+ this.filterContacts(textValue);
+ }
+ }
+
+ setContactValue(call) {
+ // Send recipient information to the invoked parent component.
+ call({
+ // Select the content of the text box before the contact.
+ contactValue: this.myText,
+ // Selected recipient information
+ selectContacts: this.selectContacts,
+ // Whether the focus is lost
+ hasBlur: this.hasBlur
+ });
+ }
+
+ addContact(index, call) {
+ let curItem = this.contacts[index];
+ if (this.checkSingle()) {
+ return;
+ }
+ if (curItem.telephone.toString().trim() == "") {
+ prompt.showToast({
+ // Invalid Recipient
+ // @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
+ });
+ this.contacts.splice(index, 1);
+ HiLog.i(TAG, "addContact, length: " + this.selectContacts.length);
+ this.myText = '';
+ if (this.selectContacts.length == 1) {
+ this.setInputStatus(false);
+ this.isShowSearch = false;
+ this.setContactValue(call);
+ } else {
+ this.setInputStatus(true);
+ this.isShowSearch = true;
+ this.setContactValue(call);
+ }
+ HiLog.i(TAG, "addContact, isInputStatus: " + this.isInputStatus);
+ }
+
+ setShowContactName() {
+ if (this.selectContacts.length == 0) {
+ return '';
+ }
+ let myName = this.selectContacts[0].contactName.trim();
+ let telephone = this.selectContacts[0].telephone
+ if (!this.isPhoneNumber(telephone)) {
+ myName = telephone.replace(new RegExp(/e|-|#|\*|\./, "g"), common.string.EMPTY_STR);
+ } else {
+ if (myName == "") {
+ myName = telephone;
+ }
+ }
+ if (this.selectContacts.length >= 2) {
+ // name and other numbers
+ return $r("app.string.and_others", myName, this.selectContacts.length - 1)
+ } else {
+ return myName
+ }
+ }
+
+ myContactFocus() {
+ HiLog.i(TAG, "myContactFocus, start");
+ this.myText = common.string.EMPTY_STR;
+ this.setInputStatus(true);
+ this.isShowSearch = true;
+ }
+
+ myContactClick() {
+ HiLog.i(TAG, "myContactClick, start");
+ if (!this.isInputStatus) {
+ this.myText = common.string.EMPTY_STR;
+ this.setInputStatus(true);
+ this.isShowSearch = true;
+ // The TextArea control does not support focus.
+ // this.$element("receiveTxt").focus({
+ // focus: true
+ // });
+ }
+ }
+
+ nameClick(idx, call) {
+ HiLog.i(TAG, "click-->" + idx)
+ if (this.selectContacts[idx].select) {
+ let item = this.selectContacts.splice(idx, 1);
+ // Deleted items are added to the collection to be searched.
+ this.contactsTemp.push(item);
+ 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) {
+ var actionData: LooseObject = {};
+ actionData.pageFlag = common.contractPage.PAGE_FLAG_SINGLE_CHOOSE;
+ this.jumpToContractForResult(actionData, call);
+ }
+ // Tap a contact's avatar to go to the contact details page.
+ titleBarAvatar(index) {
+ var actionData: LooseObject = {};
+ actionData.phoneNumber = this.contacts[index].telephone;
+ actionData.pageFlag = common.contractPage.PAGE_FLAG_CONTACT_DETAILS;
+ this.jumpToContract(actionData);
+ }
+ // Switching to the Contacts app
+ jumpToContract(actionData) {
+ let str = commonService.commonContractParam(actionData);
+ globalThis.mmsContext.startAbility(str).then((data) => {
+ }).catch((error) => {
+ HiLog.i(TAG, "jumpToContract failed");
+ });
+ }
+ // Switching to the Contacts app
+ async jumpToContractForResult(actionData, call) {
+ let str = commonService.commonContractParam(actionData);
+ var data = await globalThis.mmsContext.startAbilityForResult(str);
+ if (data.resultCode == 0) {
+ this.dealContractParams(data.want.parameters.contactObjects, call);
+ }
+ }
+
+ dealContractParams(contactObjects, call) {
+ let params = JSON.parse(contactObjects);
+ if (this.checkSingle()) {
+ return;
+ }
+ for (let element of params) {
+ let selectContact: LooseObject = {};
+ selectContact.headImage = "icon/user_avatar_full_fill.svg";
+ selectContact.contactName = element.contactName;
+ selectContact.telephone = element.telephone;
+ selectContact.telephoneFormat = element.telephone;
+ selectContact.select = false;
+ this.selectContacts.push(selectContact);
+ }
+ if (params.length > 1 && this.checkSingle()) {
+ this.selectContacts = [];
+ return;
+ }
+ if (this.selectContacts.length > 0) {
+ this.deleteRepetitionContracts(this.contacts, this.selectContacts);
+ this.setInputStatus(false);
+ this.isShowSearch = false;
+ this.setContactValue(call);
+ }
+ this.commonCtrl.paramContact.isSelectContact = false;
+ this.commonCtrl.paramContact.isNewRecallMessagesFlag = false;
+ }
+
+ deleteRepetitionContracts(contacts, selectContacts) {
+ let indexs = [];
+ let count = 0;
+ for (let item of contacts) {
+ let telephone = item.telephone;
+ for (let selectContact of selectContacts) {
+ if (telephone == selectContact.telephone) {
+ indexs.push(count);
+ break;
+ }
+ }
+ count++;
+ }
+ let selectContactIndexs = [];
+ for (let i = 0; i < selectContacts.length; i++) {
+ let telephone = selectContacts[i].telephone;
+ for (let j = i + 1; j < selectContacts.length; j++) {
+ if (telephone == selectContacts[j].telephone) {
+ selectContactIndexs.push(i);
+ break;
+ }
+ }
+ }
+ if (indexs.length > 0) {
+ for (let index of indexs) {
+ contacts.splice(index, 1);
+ }
+ }
+ if (selectContactIndexs.length > 0) {
+ for (let index of selectContactIndexs) {
+ selectContacts.splice(index, 1);
+ }
+ }
+ }
+
+ // Currently, only one recipient is supported. You can enter only one recipient first.
+ checkSingle() {
+ if (this.selectContacts.length > 0) {
+ prompt.showToast({
+ // Invalid Recipient
+ // @ts-ignore
+ message: "只支持单个收件人",
+ duration: 1000,
+ });
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5
new file mode 100644
index 0000000..801a6c7
--- /dev/null
+++ b/entry/src/main/module.json5
@@ -0,0 +1,92 @@
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "srcEntrance": "./ets/Application/MyAbilityStage.ts",
+ "description": "$string:entry_description",
+ "mainElement": "com.ohos.mms.MainAbility",
+ "deviceTypes": [
+ "default",
+ "tablet",
+ "car"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "com.ohos.mms.MainAbility",
+ "srcEntrance": "./ets/MainAbility/MainAbility.ts",
+ "description": "$string:mainability_description",
+ "icon": "$media:smsmms",
+ "label": "$string:messages",
+ "startWindowIcon": "$media:smsmms",
+ "startWindowBackground": "$color:detail_main_background",
+ "visible": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [{
+ "description": "subscriber",
+ "icon": "$media:smsmms",
+ "metadata": [{
+ "name": "ohos.extension.staticSubscriber",
+ "resource": "$profile:static_subscriber_config"
+ }],
+ "name": "Subscriber",
+ "srcEntrance": "./ets/StaticSubscriber/MmsStaticSubscriber.ts",
+ "type": "staticSubscriber",
+ "visible": true
+ }],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
+ "reason": "$string:bundle_info_privileged"
+ },
+ {
+ "name": "ohos.permission.READ_CONTACTS",
+ "reason": "$string:permission_read_write_contacts"
+ },
+ {
+ "name": "ohos.permission.READ_MESSAGES",
+ "reason": "$string:permission_read_write_messages"
+ },
+ {
+ "name": "ohos.permission.SEND_MESSAGES",
+ "reason": "$string:permission_send_messages"
+ },
+ {
+ "name": "ohos.permission.SET_TELEPHONY_STATE",
+ "reason": "$string:permission_set_telephone_status"
+ },
+ {
+ "name": "ohos.permission.GET_TELEPHONY_STATE",
+ "reason": "$string:permission_get_telephone_status"
+ },
+ {
+ "name": "ohos.permission.RECEIVE_SMS",
+ "reason": "$string:permission_receive_message_service"
+ },
+ {
+ "name": "ohos.permission.PLACE_CALL",
+ "reason": "$string:permission_call_place"
+ },
+ {
+ "name": "ohos.permission.NOTIFICATION_CONTROLLER",
+ "reason": "$string:permission_notification_controller"
+ },
+ {
+ "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND",
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json
index 86fb1e9..18fbde8 100644
--- a/entry/src/main/resources/base/element/color.json
+++ b/entry/src/main/resources/base/element/color.json
@@ -1,72 +1,16 @@
{
"color": [
- {
- "name": "white",
- "value": "#FFFFFF"
- },
- {
- "name": "back_Transparent",
- "value": "#FFFFFFFF"
- },
{
"name": "sender_bubble",
"value": "#3300CB87"
},
{
- "name": "receiver_bubble",
- "value": "#FFFFFF"
- },
- {
- "name": "search_input_background",
- "value": "#F2F2F2"
- },
- {
- "name": "title_bar_background",
- "value": "#F2F2F2"
- },
- {
- "name": "message_send_failed",
- "value": "#FA2A2D"
- },
- {
- "name": "main_font_color",
- "value": "#182431"
- },
- {
- "name": "main_font_color_40",
- "value": "#66182431"
- },
- {
- "name": "main_font_color_60",
- "value": "#99182431"
- },
- {
- "name": "divider_color",
- "value": "#0D000000"
- },
- {
- "name": "control_activated_color",
- "value": "#007DFF"
- },
- {
- "name": "placeholder_color",
- "value": "#99000000"
- },
- {
- "name": "setting_background",
+ "name": "detail_main_background",
"value": "#F1F3F5"
},
{
- "name": "detail_main_background",
- "value": "#DAEFF9"
- },
- {
- "name": "transparent_color",
- "value": "#00FFFFFF"
- },
- {
- "name": "mask_color",
- "value": "#26000000"
+ "name": "ic_user_head_color",
+ "value": "#99007dff"
}
]
}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json
index dd5a5df..537c239 100644
--- a/entry/src/main/resources/base/element/float.json
+++ b/entry/src/main/resources/base/element/float.json
@@ -34,7 +34,7 @@
},
{
"name": "action_bar_space",
- "value": "16vp"
+ "value": "24vp"
},
{
"name": "action_bar_text_size",
@@ -50,7 +50,7 @@
},
{
"name": "settings_items_radius",
- "value": "16vp"
+ "value": "24vp"
},
{
"name": "settings_item_padding_left",
@@ -115,6 +115,34 @@
{
"name": "conversation_list_no_message_fs",
"value": "14fp"
+ },
+ {
+ "name": "empty_text_top_margin",
+ "value": "9vp"
+ },
+ {
+ "name": "space_24",
+ "value": "24vp"
+ },
+ {
+ "name": "space_16",
+ "value": "16vp"
+ },
+ {
+ "name": "menu_layout_padding_left",
+ "value": "24vp"
+ },
+ {
+ "name": "menu_layout_padding_right",
+ "value": "24vp"
+ },
+ {
+ "name": "page_padding_left",
+ "value": "12vp"
+ },
+ {
+ "name": "page_padding_right",
+ "value": "12vp"
}
]
}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json
index fd00c99..0ac378e 100644
--- a/entry/src/main/resources/base/element/string.json
+++ b/entry/src/main/resources/base/element/string.json
@@ -50,17 +50,17 @@
{"name": "yesterday", "value": "昨天"},
{"name": "monthAndDay", "value": "{month}/{day}"},
{"name": "yearAndMonthAndDay", "value": "{year}/{month}/{day}"},
- {"name": "postMidnight", "value": "半夜%s : %s"},
- {"name": "beforeDawn", "value": "凌晨%s : %s"},
- {"name": "earlyMorning", "value": "清晨%s : %s"},
- {"name": "morning", "value": "早上%s : %s"},
- {"name": "forenoon", "value": "上午%s : %s"},
- {"name": "preNoon", "value": "中午%s : %s"},
- {"name": "postNoon", "value": "中午%s : %s"},
- {"name": "afternoon", "value": "下午%s : %s"},
- {"name": "towardEvening", "value": "傍晚%s : %s"},
- {"name": "evening", "value": "晚上%s : %s"},
- {"name": "preMidnight", "value": "半夜%s : %s"},
+ {"name": "postMidnight", "value": "半夜 %s:%s"},
+ {"name": "beforeDawn", "value": "凌晨 %s:%s"},
+ {"name": "earlyMorning", "value": "清晨 %s:%s"},
+ {"name": "morning", "value": "早上 %s:%s"},
+ {"name": "forenoon", "value": "上午 %s:%s"},
+ {"name": "preNoon", "value": "中午 %s:%s"},
+ {"name": "postNoon", "value": "中午 %s:%s"},
+ {"name": "afternoon", "value": "下午 %s:%s"},
+ {"name": "towardEvening", "value": "傍晚 %s:%s"},
+ {"name": "evening", "value": "晚上 %s:%s"},
+ {"name": "preMidnight", "value": "半夜 %s:%s"},
{"name": "msg_new_contact", "value": "新建联系人"},
{"name": "view_contact", "value": "查看联系人"},
{"name": "msg_save_to_an_existing_contact", "value": "保存至已有联系人"},
@@ -205,7 +205,7 @@
{"name": "november", "value": "11月"},
{"name": "december", "value": "12月"},
{"name": "justNow", "value": "刚刚"},
- {"name": "hourAndMinute", "value": "%s : %s"},
+ {"name": "hourAndMinute", "value": "%s:%s"},
{"name": "today", "value": "今天"},
{"name": "recentDate", "value": "{recent}{week}"},
{"name": "monthDayDate", "value": "%d月%d日%s"},
@@ -284,12 +284,25 @@
{"name": "slide_duration_unit", "value": "秒"},
{"name": "slide_duration_title", "value": "幻灯片持续时间2/2"},
{"name": "mainability_description", "value": "ETS_Empty MainAbility"},
+ {"name": "entry_description", "value": "ETS_Empty MainAbility"},
{"name": "msg_know", "value": "知道了"},
{"name": "recentDateToday", "value": "今天%s"},
{"name": "recentDateYesterday", "value": "昨天%s"},
{"name": "monthDay", "value": "%d/%d"},
{"name": "yearMonthDay", "value": "%d/%d/%d"},
{"name": "smsmmsability_description", "value": "ETS_Empty SmsMmsability"},
- {"name": "mmsservice_description", "value": "MMS消息服务"}
+ {"name": "mmsservice_description", "value": "MMS消息服务"},
+ {"name": "unread_messages", "value": "%s条未读"},
+ {"name": "bundle_info_privileged", "value": "获取应用信息权限"},
+ {"name": "permission_read_write_contacts", "value": "用于管理联系人"},
+ {"name": "permission_read_write_messages", "value": "用于管理短信信息"},
+ {"name": "permission_read_storage", "value": "用于读取用户存储"},
+ {"name": "permission_write_storage", "value": "用于写入用户存储"},
+ {"name": "permission_send_messages", "value": "用于发送信息"},
+ {"name": "permission_set_telephone_status", "value": "用于设置电话状态"},
+ {"name": "permission_get_telephone_status", "value": "用于获取电话状态"},
+ {"name": "permission_receive_message_service", "value": "短信接收服务"},
+ {"name": "permission_call_place", "value": "归属地管理"},
+ {"name": "permission_notification_controller", "value": "用于通知管理"}
]
}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000..a476dec
--- /dev/null
+++ b/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,11 @@
+{
+ "src": [
+ "pages/index",
+ "pages/conversation/conversation",
+ "pages/infomsg/InfoMsg",
+ "pages/settings/settings",
+ "pages/settings/advancedSettings/advancedSettings",
+ "pages/settings/ringtoneSettings/ringtoneSettings",
+ "pages/queryreport/queryReport"
+ ]
+}
diff --git a/entry/src/main/resources/base/profile/static_subscriber_config.json b/entry/src/main/resources/base/profile/static_subscriber_config.json
new file mode 100644
index 0000000..c8046e3
--- /dev/null
+++ b/entry/src/main/resources/base/profile/static_subscriber_config.json
@@ -0,0 +1,12 @@
+{
+ "commonEvents": [
+ {
+ "name": "Subscriber",
+ "permission": "",
+ "types": [],
+ "events": [
+ "usual.event.SMS_RECEIVE_COMPLETED"
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json
index 87277f7..103192d 100644
--- a/entry/src/main/resources/en_US/element/string.json
+++ b/entry/src/main/resources/en_US/element/string.json
@@ -50,17 +50,17 @@
{"name": "yesterday", "value": "Yesterday"},
{"name": "monthAndDay", "value": "{month}/{day}"},
{"name": "yearAndMonthAndDay", "value": "{month}/{day}/{year}"},
- {"name": "postMidnight", "value": "%s : %s AM"},
- {"name": "beforeDawn", "value": "%s : %s AM"},
- {"name": "earlyMorning", "value": "%s : %s AM"},
- {"name": "morning", "value": "%s : %s AM"},
- {"name": "forenoon", "value": "%s : %s AM"},
- {"name": "preNoon", "value": "%s : %s AM"},
- {"name": "postNoon", "value": "%s : %s PM"},
- {"name": "afternoon", "value": "%s : %s PM"},
- {"name": "towardEvening", "value": "%s : %s PM"},
- {"name": "evening", "value": "%s : %s PM"},
- {"name": "preMidnight", "value": "%s : %s PM"},
+ {"name": "postMidnight", "value": "%s:%s AM"},
+ {"name": "beforeDawn", "value": "%s:%s AM"},
+ {"name": "earlyMorning", "value": "%s:%s AM"},
+ {"name": "morning", "value": "%s:%s AM"},
+ {"name": "forenoon", "value": "%s:%s AM"},
+ {"name": "preNoon", "value": "%s:%s AM"},
+ {"name": "postNoon", "value": "%s:%s PM"},
+ {"name": "afternoon", "value": "%s:%s PM"},
+ {"name": "towardEvening", "value": "%s:%s PM"},
+ {"name": "evening", "value": "%s:%s PM"},
+ {"name": "preMidnight", "value": "%s:%s PM"},
{"name": "msg_new_contact", "value": "Create new contact"},
{"name": "view_contact", "value": "View Contact"},
{"name": "msg_save_to_an_existing_contact", "value": "Add to existing contact"},
@@ -205,7 +205,7 @@
{"name": "november", "value": "November"},
{"name": "december", "value": "December"},
{"name": "justNow", "value": "Just now"},
- {"name": "hourAndMinute", "value": "%s : %s"},
+ {"name": "hourAndMinute", "value": "%s:%s"},
{"name": "today", "value": "Today"},
{"name": "recentDate", "value": "{week}, {recent}"},
{"name": "monthDayDate", "value": "%d month %d day %s"},
@@ -284,12 +284,25 @@
{"name": "slide_duration_unit", "value": "second"},
{"name": "slide_duration_title", "value": "slide duration 2/2"},
{"name": "mainability_description", "value": "ETS_Empty Ability"},
+ {"name": "entry_description", "value": "ETS_Empty MainAbility"},
{"name": "msg_know", "value": "Understand"},
{"name": "recentDateToday", "value": "recentDateToday %s"},
{"name": "recentDateYesterday", "value": "recentDateYesterday %s"},
{"name": "monthDay", "value": "%d/%d"},
{"name": "yearMonthDay", "value": "%d/%d/%d"},
{"name": "smsmmsability_description", "value": "ETS_Empty SmsMmsability"},
- {"name": "mmsservice_description", "value": "MMS message service"}
+ {"name": "mmsservice_description", "value": "MMS message service"},
+ {"name": "unread_messages", "value": "%s unread"},
+ {"name": "bundle_info_privileged", "value": "Bundle Information Privileged"},
+ {"name": "permission_read_write_contacts", "value": "Used to manage contacts"},
+ {"name": "permission_read_write_messages", "value": "Used to manage messages"},
+ {"name": "permission_read_storage", "value": "Used to read User Storage for users"},
+ {"name": "permission_write_storage", "value": "Used to write User Storage for users"},
+ {"name": "permission_send_messages", "value": "Used to send messages"},
+ {"name": "permission_set_telephone_status", "value": "Used to set telephone status"},
+ {"name": "permission_get_telephone_status", "value": "Used to get telephone status"},
+ {"name": "permission_receive_message_service", "value": "SMS message receiving service"},
+ {"name": "permission_call_place", "value": "Used to manage home location"},
+ {"name": "permission_notification_controller", "value": "Used to notification management"}
]
}
\ No newline at end of file
diff --git a/entry/src/main/resources/phone/element/float.json b/entry/src/main/resources/phone/element/float.json
new file mode 100644
index 0000000..fde634d
--- /dev/null
+++ b/entry/src/main/resources/phone/element/float.json
@@ -0,0 +1,60 @@
+{
+ "float": [
+ {
+ "name": "message_bar_height",
+ "value": "82vp"
+ },
+ {
+ "name": "empty_image_width",
+ "value": "120vp"
+ },
+ {
+ "name": "empty_image_height",
+ "value": "120vp"
+ },
+ {
+ "name": "addressee_font_size",
+ "value": "14vp"
+ },
+ {
+ "name": "addressee_line_height",
+ "value": "22vp"
+ },
+ {
+ "name": "new_message_margin_top",
+ "value": "0vp"
+ },
+ {
+ "name": "bottom_send_bar_padding_right",
+ "value": "16vp"
+ },
+ {
+ "name": "user_avatar_left_margin",
+ "value": "18vp"
+ },
+ {
+ "name": "settings_items_radius",
+ "value": "24vp"
+ },
+ {
+ "name": "settings_item_padding_left",
+ "value": "12vp"
+ },
+ {
+ "name": "settings_item_padding_right",
+ "value": "12vp"
+ },
+ {
+ "name": "dialog_bottom_margin",
+ "value": "-12vp"
+ },
+ {
+ "name": "menu_layout_padding_left",
+ "value": "24vp"
+ },
+ {
+ "name": "menu_layout_padding_right",
+ "value": "24vp"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/rawfile/icon/entrance_icon01.svg b/entry/src/main/resources/rawfile/icon/entrance_icon01.svg
index db0fa09..6edcdb5 100644
--- a/entry/src/main/resources/rawfile/icon/entrance_icon01.svg
+++ b/entry/src/main/resources/rawfile/icon/entrance_icon01.svg
@@ -1,17 +1,13 @@
-