Update Mms code

Signed-off-by: zhuchao <zhuchaoa.zhuchao@huawei.com>
This commit is contained in:
zhuchao 2022-03-17 12:54:30 +08:00
parent 11e2a83b72
commit fc6ab0193e
340 changed files with 11196 additions and 24581 deletions

77
OAT.xml
View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
<!-- 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.
@ -14,56 +14,53 @@
limitations under the License.
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
All configurations in this file will be merged to OAT-Default.xml, if you have any questions or concerns, please create issue in OpenHarmony/tools_oat and @jalenchen or chenyaxun.
licensefile:
1.If the project don't have "LICENSE" in root dir, please define all the license files in this project in , OAT will check license files according to this rule.
policylist:
1. policy: If the OAT-Default.xml policies do not meet your requirements, please add policies here.
2. policyitem: The fields type, name, path, desc is required, and the fields rule, group, filefilter is optional,the default value is:
<policyitem type="" name="" path="" desc="" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter"/>
3. policyitem type:
"compatibility" is used to check license compatibility in the specified path;
"license" is used to check source license header in the specified path;
"copyright" is used to check source copyright header in the specified path;
"import" is used to check source dependency in the specified path, such as import ... ,include ...
"filetype" is used to check file type in the specified path, supported file types: archive, binary
"filename" is used to check whether the specified file exists in the specified path(projectroot means the root dir of the project), supported file names: LICENSE, README, README.OpenSource
4. policyitem name: This field is used for define the license, copyright, "*" means match all, the "!" prefix means could not match this value. For example, "!GPL" means can not use GPL license.
5. policyitem path: This field is used for define the source file scope to apply this policyitem, the "!" prefix means exclude the files. For example, "!.*/lib/.*" means files in lib dir will be exclude while process this policyitem.
6. policyitem rule and group: These two fields are used together to merge policy results. "may" policyitems in the same group means any one in this group passed, the result will be passed.
7. policyitem filefilter: Used to bind filefilter which define filter rules.
7. policyitem desc: Used to describe the reason of this policy item, committers will check this while merging the code.
8. filefilter: Filter rules, the type filename is used to filter file name, the type filepath is used to filter file path.
Note:If the text contains special characters, please escape them according to the following rules:
" == &gt;
& == &gt;
' == &gt;
< == &gt;
> == &gt;
-->
<configuration>
<oatconfig>
<licensefile></licensefile>
<policylist>
<policy name="projectPolicy" desc="">
<policyitem type="copyright" name="Copyright 2015 the original author or authors." path="gradlew" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc="file generated by development tool"/>
<policyitem type="copyright" name="Copyright 2015 the original author or authors." path="gradlew.bat" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc="file generated by development tool"/>
<!--policyitem type="compatibility" name="GPL-2.0+" path="abc/.*" desc="Process that runs independently, invoked by the X process."/-->
<!--policyitem type="license" name="LGPL" path="abc/.*" desc="Dynamically linked by module X"/-->
<!--policyitem type="copyright" name="xxx" path="abc/.*" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc="Developed by X Company"/-->
</policy>
</policylist>
<filefilterlist>
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
<filteritem type="filepath" name="entry/src/main/js/default/common/icon/.*.png" desc="self developed image"/>
<filteritem type="filepath" name="entry/src/main/js/default/common/icon/.*.jpg" desc="self developed image"/>
<filteritem type="filepath" name="entry/src/main/js/default/common/icon/.*.svg" desc="self developed image"/>
<filteritem type="filepath" name="entry/src/main/resources/base/media/.*.png" desc="self developed image"/>
<filteritem type="filepath" name="entry/src/ohosTest/resources/base/media/.*.png" desc="self developed image"/>
<filteritem type="filepath" name="gradle/wrapper/gradle-wrapper.jar" desc="gradle jar"/>
<filteritem type="filepath" name="doc/image/.*.png" desc="self developed image"/>
<filteritem type="filepath" name="figures/.*.png" desc="self developed image"/>
<filefilter name="defaultFilter" desc="Files not to check">
<filteritem type="filename" name="*.json" desc=""/>
<filteritem type="filepath" name="dir name underproject/.*.uvwxyz" desc="Describe the reason for filtering scan results"/>
<filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/>
<filteritem type="filepath" name="signs/.*" desc="out put files"/>
<filteritem type="filepath" name="gradle/.*" desc="out put files"/>
</filefilter>
<filefilter name="defaultPolicyFilter" desc="Filters for compatibilitylicense header policies">
</filefilter>
<filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">
</filefilter>
<filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies">
</filefilter>
<filefilter name="readmeFileNamePolicyFilter" desc="Filters for README file policies">
</filefilter>
<filefilter name="readmeOpenSourcefileNamePolicyFilter" desc="Filters for README.OpenSource file policies">
</filefilter>
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
<filteritem type="filepath" name="doc/image/.*.png" desc="self developed image"/>
<filteritem type="filepath" name="entry/src/main/resources/base/media/.*.png" desc="self developed image"/>
<filteritem type="filepath" name="entry/src/main/resources/base/media/.*.svg" desc="self developed image"/>
<filteritem type="filepath" name="entry/src/main/resources/rawfile/icon/.*.png" desc="self developed image"/>
<filteritem type="filepath" name="entry/src/main/resources/rawfile/icon/.*.svg" desc="self developed image"/>
<filteritem type="filepath" name="entry/src/ohosTest/resources/base/media/.*.png" desc="self developed image"/>
</filefilter>
</filefilterlist>
<licensematcherlist>
<licensematcher name="uvwxyz License" desc="If the scanning result is InvalidLicense, you can define matching rules here. Note that quotation marks must be escaped.">
<licensetext name="
uvwxyz license text xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
" desc=""/>
</licensematcher>
</licensematcherlist>
</oatconfig>
</configuration>

View File

@ -1,36 +0,0 @@
# applications_mms
#### Description
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
#### Software Architecture
Software architecture description
#### Installation
1. xxxx
2. xxxx
3. xxxx
#### Instructions
1. xxxx
2. xxxx
3. xxxx
#### Contribution
1. Fork the repository
2. Create Feat_xxx branch
3. Commit your code
4. Create Pull Request
#### Gitee Feature
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
4. The most valuable open source project [GVP](https://gitee.com/gvp)
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

View File

@ -1,67 +1,38 @@
# MMS<a name="EN-US_TOPIC_0000001103421572"></a>
# mms_app
- [Introduction](#section11660541593)
- [Architecture](#section48896451454)
#### 简介
mms_app是基于OpenHarmony系统ETS UI框架开发的短信项目主要的功能包含信息查看、发送短信、接收短信、短信送达报告、删除短信等功能
- [Directory Structure](#section161941989596)
- [Usage](#section123459000)
- [Repositories Involved](#section1371113476307)
#### 架构图
主要针对架构目标、关键架构需求、假设和约束加以说明,对架构的原则性进行必要说明,针对架构的相关视图,进行绘制并加以说明(主要包含用例视图、逻辑视图、开发视图、部署视图、运行视图)。
## Introduction<a name="section11660541593"></a>
![screenshot-20211129-202627](./doc/image/screenshot-20211129-202627.png)
The MMS application is pre-installed in OpenHarmony and provides functions such as sending, receiving, forwarding, favoriting, locking, and resending of SMS and MMS messages.
#### 目录
### Architecture<a name="section48896451454"></a>
![](./doc/image/mms-architecture.png)
## Directory Structure<a name="section161941989596"></a>
```
/applications/standard/mms
├── figures # Architecture diagram
├── entry # Main entry module
/mms/
├── entry # 主entry模块目录
│ ├── src
│ ├── main
│ └── js # JS code
│ └── ets # js代码目录
│ └── default
│ └── common.icon # Icon
│ └── i18n # Internationalization
│ └── model # Data management layer
│ └── pages # Pages
│ └── advanced_settings # Advanced settings page
│ └── component # Components
│ └── conversation # Conversation page
│ └── conversation_list # Conversation list page
│ └── full_screen_input # Full-screen input page
│ └── full_srceen_show_picture # Full-screen image display page
│ └── group_detail # Group details page
│ └── info_msg # Notification message list page
│ └── index # Homepage
│ └── manage_sim # SIM card management page
│ └── my_star # Favorites page
│ └── query_report # Query report page
│ └── settings # Settings page
│ └── sms_center # SMSC page
│ └── text_select # Text selection page
│ └── transmit_select # Message forwarding page
│ └── transmit_search # Forwarded message search page
│ └── service # Service logic
│ └── utils # Utilities
│ └── resources # Resources
│ └── config.json # Global configuration file
│ └── data # 自定义数据类型
│ └── model # 对接数据库
│ └── pages # 页面
│ └── conversation # 会话详情页面
│ └── conversationlist # 信息列表页面
│ └── index # 首页
│ └── info_msg # 通知信息列表页面
│ └── query_report # 报告详情页面
│ └── settings # 设置页面
│ └── service # 业务逻辑
│ └── utils # 工具类
│ └── views # 自定义组件
│ └── ServiceAbility # 后台常驻服务
│ └── java # Ability
│ └── resources # 资源存放目录
│ └── config.json # 全局配置文件
├── gradle # gradle
│ ├──wrapper
├── KeyStore # License file
```
│ ├──wrapper
## Usage<a name="section123459000"></a>
For details, see [MMS Usage Instructions](./doc/Instructions.md).
## Repositories Involved<a name="section1371113476307"></a>
System applications
**applications\_standard_mms**

View File

@ -1,68 +0,0 @@
# 短彩信<a name="ZH-CN_TOPIC_0000001103421572"></a>
- [简介](#section11660541593)
- [架构图](#section48896451454)
- [目录](#section161941989596)
- [使用说明](#section123459000)
- [相关仓](#section1371113476307)
## 简介<a name="section11660541593"></a>
短彩信应用是OpenHarmony中预置的系统应用主要的功能包含发送短信、接收短信、转发、收藏、锁定、重新发送等功能
### 架构图<a name="section48896451454"></a>
![](./doc/image/screenshot-20211129-202627.png)
## 目录<a name="section161941989596"></a>
```
/applications/standard/mms
├── figures # 架构图目录
├── entry # 主entry模块目录
│ ├── src
│ ├── main
│ └── js # js代码目录
│ └── default
│ └── common.icon # 图标
│ └── i18n # 国际化
│ └── model # 数据管理层
│ └── pages # 页面
│ └── advanced_settings # 高级设置页面
│ └── component # 组件
│ └── conversation # 信息列表页面
│ └── conversation_list # 会话列表页面
│ └── full_screen_input # 全屏发送页面
│ └── full_srceen_show_picture # 全屏展示图片页面
│ └── group_detail # 群发组详情页面
│ └── info_msg # 通知信息会话列表页面
│ └── index # 首页
│ └── manage_sim # sim卡管理页面
│ └── my_star # 收藏页面
│ └── query_report # 查看报告
│ └── settings # 设置页面
│ └── sms_center # 短信中心页面
│ └── text_select # 文本选中页面
│ └── transmit_select # 转发页面
│ └── transmit_search # 转发搜索页面
│ └── service # 业务逻辑
│ └── utils # 工具类
│ └── resources # 资源存放目录
│ └── config.json # 全局配置文件
├── gradle # gradle
│ ├──wrapper
├── KeyStore # 许可文件
```
## 使用说明 <a name="section123459000"></a>
参见使用说明([使用说明](./doc/Instructions.md)
## 相关仓<a name="section1371113476307"></a>
系统应用
**applications_standard_mms**

View File

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

View File

@ -1,241 +0,0 @@
# MMS 使用说明
## 代码使用
### 代码下载
#### 配置码云ssh
1. 打开本地git bash窗口
2. 进入到.ssh 目录cd ~/.ssh
3. 找到id_rsa.pub文件ls
4. 查看公钥cat id_rsa.pub
5. 在码云个人设置-安全设置-ssh公钥中配置公钥
#### 下载代码
1. 打开码云MMS地址[下载地址](https://gitee.com/openharmony/applications_mms))。
2. 选择克隆/下载 - ssh方式 -复制下载地址
3. 本机git bash 中执行:
```
git clone '复制的下载地址'
```
### 环境搭建
打开DevEco Studio链接下载安装安装步骤及安装说明详见官网
## 基础开发说明
### 系统接口调用
### 异步回调的使用
- 在需要回调操作的js文件中创建回调函数
```JavaScript
subscribeCallback(err, data){
// do something
},
```
- 调用应用内部封装的接口,并传入回调函数
```JavaScript
Notification.subscribe(mSubscriber, this.subscribeCallback.bind(this));
```
- 在AsyncCallback返回数据时可以获取到错误信息或目标数据
```JavaScript
subscribeCallback(err, data) {
Log.showInfo(TAG, 'subscribeCallback finished ====================' + JSON.stringify(data));
}
```
### 如何引用资源文件
- 在i18n/zh-CN.json文件中可直接通过$t()引用资源
```` JavaScript
this.title = this.$t('app.string.hello_world');
````
## 典型接口的使用
1. 接收三方应用跳转
``` JavaScript
import featureAbility from '@ohos.ability.featureAbility';
let str = {
'want': {
'bundleName': 'com.ohos.mms',
'abilityName': 'com.ohos.mms.MainAbility',
'parameters' : {
contactObjects: '{contactsName:asa,telephone:111}'
},
'entities': [
common.string.COMMON_ENTITIES
]
},
};
featureAbility.startAbility(str).then((data) => {
console.info(TAG + 'jumpToMmsApp successful' + data);
}).catch((error) => {
console.error(TAG + 'jumpToMmsApp failed,Cause: ' + JSON.stringify(error));
});
```
## 签名打包
### 签名
#### 签名文件的获取
1. 拷贝OpenHarmony标准版工程的 prebuilts\signcenter 目录到操作目录
2. 拷贝applications_mms工程的 signature\mms.p7b 到该目录下
#### 签名文件的配置
打开项目工程,选择 File → Project Structure
![](../figures/signature_1.png)
选择 Modules → Signing Configs将对应的签名文件配置如下完成后点击Apply再点击OK。
![](../figures/signature_2.png)
配置完成后对应的build.gradle文件中会出现如下内容
![](../figures/signature_3.png)
### 打包
DevEco Studio 支持 debug 与 release 两种打包类型。可以在 OhosBuild Variants 窗口中进行切换。
![](../figures/ds_ohosbuild_variants.png)
#### debug打包
1. 代码准备完成后,在 OhosBuild Variants 窗口的 Selected Variant 中选择 debug。
![](../figures/ds_ohosbuild_variants_debug.png)
2. 选择Build → Build Haps(s)/APP(s) → Build Hap(s)
![](../figures/ds_build_haps.png)
3. 编译完成后hap包会生成在工程目录下的 `\build\outputs\hap\debug\phone\`路径下如果没有配置签名则只会生成未签名的hap包
![](../figures/ds_ohosbuild_output_dir_debug.png)
#### release打包
1. 代码准备完成后,在 OhosBuild Variants 窗口的 Selected Variant 中选择 release
![](../figures/ds_ohosbuild_variants_release.png)
2. 选择Build → Build Haps(s)/APP(s) → Build Hap(s)
![](../figures/ds_build_haps.png)
3. 编译完成后hap包会生成在工程目录下的 `\build\outputs\hap\release\phone\`路径下配置好签名后生成的hap包会显示signed
![](../figures/ds_ohosbuild_output_dir_release.png)
## 安装、运行、调试
## 应用安装
配置 hdc
进入SDK目录中的toolchains文件夹下获取文件路径
![](../figures/screenshot-20210521-105407.png)
> 注意此处的hdc.exe如果版本较老可能不能正常使用需要获取新的hdc.exe文件
> hdc命令介绍与下载详见[hdc仓库地址](https://gitee.com/openharmony/developtools_hdc_standard)
并将此路径配置到环境变量中:
![](../figures/screenshot-20210521-111223.png)
重启电脑使环境变量生效
连接开发板打开cmd命令窗口执行hdc list targets弹出窗口如下
![](../figures/cmd1.png)
等待一段时间后,窗口出现如下打印,可回到输入 hdc list targets 的命令窗口继续操作:
![](../figures/cmd2.png)
再次输入hdc list targets出现如下结果说明hdc连接成功
![](../figures/cmd3.png)
获取读写权限:
```
hdc target mount
```
将签名好的 hap 包放入设备的 `/system/app` 目录下并修改hap包的权限
```
hdc file send 本地路径 /system/app/hap包名称
例如hdc file send Mms.hap /system/app/Mms.hap
```
> 注意,如果设备不存在 `/system/app` 目录,则需要手动创建该目录并修改权限。
> ```
> hdc shell
> cd system
> mkdir app
> chmod 777 app
> ```
> `/system/app` 目录放置系统应用例如Mms 等。
>
> 但hap包需要在该目录下手动设置权限
> ```
> chmod 666 hap包名
> ```
> 此目录应用不用手动安装,系统自动拉起。
## 应用运行
MMS属于系统应用在将签名的 hap 包放入 `/system/app` 目录后,重启系统,应用会自动拉起。
```
hdc shell
reboot
不可以直接执行hdc reboot命令是无效的)
```
> 注意,如果设备之前安装过系统应用,则需要执行如下两条命令清除设备中存储的应用信息才能够在设备重启的时候将我们装入设备的新 hap 包正常拉起。
> ```
> hdc shell rm -rf /data/misc_de/0/mdds/0/default/bundle_manager_service
> hdc shell rm -rf /data/accounts
> ```
## 应用调试
### log打印
- 在程序中添加 log
```JS
console.info("mms log info");
```
### log获取及过滤
- log获取
将log输出至文件
```
hdc shell hilog > 输出文件名称
```
例:
在真实环境查看log将全log输出到当前目录的hilog.log文件中
```
hdc shell hilog > hilog.log
```
- log过滤
在命令行窗口中过滤log
```
hilog │ grep 过滤信息
```
例:过滤包含信息 Label 的 hilog
```
hilog │ grep Label
```
## 贡献代码
### Fork 代码仓库
1. 在码云上打开 MMS 代码仓库([仓库地址](https://gitee.com/openharmony/applications_mms))。
2. 点击仓库右上角的 Forked 按钮,在弹出的画面中,选择将仓库 fork 到哪里,点击确认。
3. Fork 成功之后,会在自己的账号下看见 fork 的代码仓库。
### 提交代码
1. 访问我们自己在码云账号上 fork 的代码仓库,点击“克隆/下载”按钮,选择 SSH点击“复制”按钮。
2. 在本地新建 MMS 目录,在 MMS 目录中执行如下命令
```
git clone 步骤1中复制的地址
```
3. 修改代码。
> 将代码引入工程,以及编译工程等相关内容请参见 **3. 代码使用** 部分的相关内容。
4. 提交代码到 fork 仓库。
> 修改后的代码,首先执行 `git add` 命令,然后执行 `git commit` 命令与 `git push` 命令,将代码 push 到我们自己的 fork 仓中。
> 关于代码提交的这部分内容涉及 git 的使用,可以参照 [git官网](https://git-scm.com/) 的内容,在此不再赘述。
### 发起 Pull Request (PR)
在将代码提交到 fork 仓之后,我们可以通过发起 Pull RequestPR的方式来为 OpenHarmony 的相关项目贡献代码。
1. 打开 fork 仓库。选择 `Pull Requests``新建 Pull Request`
2. 在 `新建 Pull Request` 画面填入标题与说明,点击 `创建` 按钮。
3. 创建 Pull Request 完成。 PR 创建完成后,会有专门的代码审查人员对代码进行评审,评审通过之后会合入相应的代码库。

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 42 KiB

1
entry/.gitignore vendored
View File

@ -1 +0,0 @@
/build

View File

@ -1,27 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'com.huawei.ohos.hap'
//apply plugin: 'com.huawei.ohos.decctest'
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
ohos {
signingConfigs {
debug {
storePassword rootProject.ext.debugSignConfigs.storePassword
keyAlias rootProject.ext.debugSignConfigs.keyAlias
keyPassword rootProject.ext.debugSignConfigs.keyPassword
signAlg rootProject.ext.debugSignConfigs.signAlg
storeFile file(rootProject.ext.debugSignConfigs.storeFile)
profile file(rootProject.ext.debugSignConfigs.profile)
certpath file(rootProject.ext.debugSignConfigs.cerPath)
}
release {
storePassword rootProject.ext.signConfigs.storePassword
keyAlias rootProject.ext.signConfigs.keyAlias
keyPassword rootProject.ext.signConfigs.keyPassword
signAlg rootProject.ext.signConfigs.signAlg
storeFile file(rootProject.ext.signConfigs.storeFile)
profile file(rootProject.ext.signConfigs.profile)
certpath file(rootProject.ext.signConfigs.cerPath)
}
}
compileSdkVersion 7
compileSdkVersion 8
defaultConfig {
compatibleSdkVersion 7
}
@ -33,15 +14,13 @@ ohos {
}
}
}
arkEnabled false
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
//
testImplementation 'junit:junit:4.13'
testImplementation 'org.mockito:mockito-core:2.19.0'
ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
testImplementation 'junit:junit:4.13.1'
ohosTestImplementation 'com.huawei.ohos.testkit:runner:2.0.0.200'
}
//decc {
// supportType = ['html','xml']
//}

View File

@ -11,14 +11,17 @@
"module": {
"package": "com.ohos.mms",
"name": ".MyApplication",
"mainAbility": "com.ohos.mms.MainAbility",
"deviceType": [
"phone"
"phone",
"tablet",
"car"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
"installationFree": false
},
"abilities": [
{
@ -37,43 +40,46 @@
"name": "com.ohos.mms.MainAbility",
"icon": "$media:smsmms",
"description": "$string:mainability_description",
"label": "$string:app_name",
"label": "$string:messages",
"type": "page",
"launchType": "standard",
"launchType": "singleton",
"srcPath": "default",
"srcLanguage": "js"
"srcLanguage": "ets",
"metaData": {
"customizeData": [
{
"name": "hwc-theme",
"value": "androidhwext:style/Theme.Emui.Light.NoTitleBar",
"extra": ""
}
]
}
},
{
"srcPath": "ServiceAbility",
"name": ".ServiceAbility",
"name": "com.ohos.mms.ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "js",
"description": "service",
"type": "service"
"type": "service",
"srcPath": "ServiceAbility",
"srcLanguage": "ets",
"visible": true
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index/index",
"pages/conversation_list/conversation_list",
"pages/info_msg/info_msg",
"pages/conversationlist/conversationList",
"pages/conversation/conversation",
"pages/text_select/text_select",
"pages/group_detail/group_detail",
"pages/full_screen_input/full_screen_input",
"pages/my_star/my_star",
"pages/full_screen_show_picture/full_screen_show_picture",
"pages/video_operation/video_operation",
"pages/contact_item_pick/contact_item_pick",
"pages/transmit_msg/transmit_msg",
"pages/transmit_search/transmit_search",
"pages/info_msg/InfoMsg",
"pages/settings/settings",
"pages/sms_center/sms_center",
"pages/advanced_settings/advanced_settings",
"pages/manage_sim/manage_sim",
"pages/query_report/query_report",
"pages/slide_detail/slide_detail"
"pages/settings/advancedSettings/advancedSettings",
"pages/settings/ringtoneSettings/ringtoneSettings",
"pages/query_report/query_report"
],
"name": "default",
"window": {
@ -84,7 +90,39 @@
],
"reqPermissions": [
{
"name": "ohos.permission.DISTRIBUTED_DATASYNC"
"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"
}
]
}

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -13,38 +13,32 @@
* limitations under the License.
*/
import commonEvent from '@ohos.commonevent';
import common from '../default/pages/common_constants.js';
import mmsTable from '../default/pages/mms_table.js';
import telephoneUtils from '../default/utils/TelephoneUtil.js';
import mmsLog from '../default/utils/MmsLog.js';
import particleAbility from '@ohos.ability.particleability';
import ohosDataAbility from '@ohos.data.dataability';
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.js';
import commonService from '../default/service/CommonService';
import http from '@ohos.net.http';
import notificationService from '../default/service/NotificationService.js';
import notificationService from '../default/service/NotificationService';
import LooseObject from '../default/data/LooseObject'
// 数据库实例对象
var rdbStore = undefined;
var dataAbilityHelper = undefined;
var contactDataAbilityHelper = undefined;
// 数据库名称
const STORE_CONFIG = {
name: 'mmssms.db',
}
const TAG = 'MmsManagerService.js ---> '
const TAG = 'MmsManagerService'
export default class CallManagerService {
let commonEventData = null;
export default class MmsManagerService {
constructor() {
this.addSubscriberListener();
// 初始化数据库
this.initRdb();
// 初始化
dataAbilityHelper = particleAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
contactDataAbilityHelper = particleAbility.acquireDataAbilityHelper(common.string.URI_ROW_CONTACTS);
}
/**
@ -60,12 +54,14 @@ export default class CallManagerService {
}
createSubscriberCallBack(err, data) {
this.commonEventData = data;
commonEventData = data;
// 接收到订阅
commonEvent.subscribe(this.commonEventData, this.subscriberCallBack.bind(this));
commonEvent.subscribe(commonEventData, this.subscriberCallBack.bind(this));
}
subscriberCallBack(err, data) {
HiLog.i(TAG, 'subscriberCallBack, err: ' + JSON.stringify(err));
HiLog.d(TAG, 'subscriberCallBack, data: ' + JSON.stringify(data));
// 短信接收
if (data.event === common.string.SUBSCRIBER_EVENT) {
this.dealSmsReceiveData(data);
@ -76,16 +72,25 @@ export default class CallManagerService {
}
async dealSmsReceiveData(data) {
let netType = data.parameters.isCdma ? '3gpp2' : '3gpp';
// 同步等待操作
let createMessagePromise = telSim.createMessage(this.convertStrArray(data.data), '3gpp');
let result = {};
createMessagePromise.then((shortMessage) => {
mmsLog.log(TAG + 'shortMessage visibleMessageBody = ' + shortMessage);
let promisesAll = [];
data.parameters.pdus.forEach(pdu => {
let promise = telSim.createMessage(this.convertStrArray(pdu), netType);
promisesAll.push(promise);
});
let result: LooseObject = {};
let createMessagePromise = Promise.all(promisesAll)
createMessagePromise.then((shortMsgList) => {
result.code = common.int.SUCCESS;
result.telephone = telephoneUtils.formatTelephone(shortMessage.visibleRawAddress);
result.content = shortMessage.visibleMessageBody;
result.telephone = telephoneUtils.formatTelephone(shortMsgList[0].visibleRawAddress);
result.content = '';
shortMsgList.forEach(shortMessage => {
result.content += shortMessage.visibleMessageBody;
})
}).catch((err) => {
mmsLog.log(TAG + 'createShortMessage err ' + err.message);
HiLog.e(TAG, 'dealSmsReceiveData, err: ' + JSON.stringify(err));
result.code = common.int.FAILURE;
});
await createMessagePromise;
@ -105,12 +110,11 @@ export default class CallManagerService {
let result = JSON.parse(data.data);
this.saveAttachment(result.mmsSource);
let content = commonService.getMmsContent(result.mmsSource);
let actionData = {
telephone: result.telephone,
content: content,
isMms: true,
mmsSource: result.mmsSource
}
let actionData: LooseObject = {};
actionData.telephone = result.telephone;
actionData.content = content;
actionData.isMms = true;
actionData.mmsSource = result.mmsSource;
this.insertMessageDetailBy(actionData, res => {
let notificationContent = this.getNotificationContent(result.mmsSource, content);
this.sendNotification(result.telephone, res.initDatas[0].id, notificationContent);
@ -124,7 +128,7 @@ export default class CallManagerService {
let httpRequest = http.createHttp();
httpRequest.request(common.string.MMS_URL,
{
method: 'GET',
method: http.RequestMethod.GET,
header: {
'Content-Type': 'application/json',
},
@ -132,7 +136,7 @@ export default class CallManagerService {
readTimeout: 50000,
connectTimeout: 50000
}, (err, data) => {
mmsLog.log(TAG + 'saveAttachment err:' + err + ' data:' + data);
HiLog.i(TAG, 'saveAttachment, err: ' + JSON.stringify(err) + ', data: ' + JSON.stringify(data));
}
);
}
@ -176,15 +180,14 @@ export default class CallManagerService {
}
sendResults.push(sendResult);
let hasAttachment = commonService.judgeIsAttachment(param.mmsSource);
let actionData = {
sendResults: sendResults,
isReceive: true,
ownNumber: common.string.EMPTY_STR,
isSender: 1,
isMms: param.isMms,
mmsSource: param.mmsSource,
hasAttachment: hasAttachment
}
let actionData: LooseObject = {};
actionData.sendResults = sendResults;
actionData.isReceive = true;
actionData.ownNumber = common.string.EMPTY_STR;
actionData.isSender = true;
actionData.isMms = param.isMms;
actionData.mmsSource = param.mmsSource;
actionData.hasAttachment = hasAttachment;
this.insertSessionAndDetail(actionData, callback);
}
@ -192,10 +195,9 @@ export default class CallManagerService {
let wby = sourceStr;
let length = wby.length;
let isDouble = (length % 2) == 0;
let halfSize = parseInt(length / 2);
mmsLog.log(TAG + 'length......' + length);
let halfSize = parseInt('' + length / 2);
HiLog.i(TAG, 'convertStrArray, length=' + length + ', isDouble=' + isDouble);
if (isDouble) {
mmsLog.log(TAG + 'isDouble......' + isDouble);
let number0xArray = new Array(halfSize);
for (let i = 0;i < halfSize; i++) {
number0xArray[i] = '0x' + wby.substr(i * 2, 2);
@ -206,7 +208,6 @@ export default class CallManagerService {
}
return numberArray;
} else {
mmsLog.log('pdu error...');
let number0xArray = new Array(halfSize + 1);
for (let i = 0;i < halfSize; i++) {
number0xArray[i] = '0x' + wby.substr(i * 2, 2);
@ -224,8 +225,8 @@ export default class CallManagerService {
// 取消订阅
unsubscribe() {
commonEvent.unsubscribe(this.commonEventData, () => {
mmsLog.log('conversation_list unsubscribe');
commonEvent.unsubscribe(commonEventData, () => {
HiLog.i(TAG, 'unsubscribe success');
});
}
@ -233,10 +234,10 @@ export default class CallManagerService {
async initRdb() {
// 创建数据库表
this.createRdbStore().then(async (ret) => {
mmsLog.log(' logMessage createRdbStore first done: ' + ret);
HiLog.i(TAG, 'initRdb, createRdbStore first done: ' + ret);
await this.createTable(mmsTable.table.session);
}).catch((err) => {
mmsLog.log(' logMessage error insert first done: ' + err);
HiLog.e(TAG, 'initRdb, createRdbStore error: ' + JSON.stringify(err));
});
}
@ -244,9 +245,9 @@ export default class CallManagerService {
* 创建数据库
*/
async createRdbStore() {
mmsLog.log(TAG + ' createRdbStore start');
rdbStore = await ohosDataRdb.getRdbStore(STORE_CONFIG, 1);
mmsLog.log(TAG + ' createRdbStore end');
HiLog.i(TAG, 'createRdbStore start');
rdbStore = await ohosDataRdb.getRdbStore(mmsTable.DB.MMSSMS.config, mmsTable.DB.MMSSMS.version);
HiLog.i(TAG, 'createRdbStore end');
}
/**
@ -263,17 +264,18 @@ export default class CallManagerService {
return;
}
let value = this.dealSendResults(sendResults);
// 先判断是否创建过会话列表
this.querySessionByTelephone(value.telephone, res => {
mmsLog.log(TAG + 'insertSessionAndDetail,querySessionByTelephone:' + res);
HiLog.i(TAG, 'insertSessionAndDetail, querySessionByTelephone code=' + res.code);
let response = res.response;
if (res.code == common.int.SUCCESS && response.id < 0) {
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 {
this.insertExitingSession(response, value, actionData, callback);
}
});
mmsLog.log(TAG + 'insertSessionAndDetail,end');
}
insertNoExitingSession(isReceive, value, actionData, callback) {
@ -296,9 +298,9 @@ export default class CallManagerService {
}
this.insertSession(valueBucket, res => {
// 这里调用短信数据库,插入短信信息
mmsLog.log(TAG + 'insertSession,rowId:' + res);
HiLog.i(TAG, 'insertNoExitingSession, res: ' + JSON.stringify(res));
this.dealInsertMessageDetail(value, actionData, res.rowId, initDatas => {
mmsLog.log(TAG + 'dealInsertMessageDetail,initDatas:' + initDatas);
HiLog.i(TAG, 'insertNoExitingSession, initDatas:' + JSON.stringify(initDatas));
let result = {
rowId: res.rowId,
initDatas: initDatas
@ -309,6 +311,7 @@ export default class CallManagerService {
}
insertExitingSession(response, param, actionData, callback) {
HiLog.i(TAG, 'insertExitingSession, response: ' + JSON.stringify(response));
let sessionId = response.id;
// 这里调用短信数据库,插入短信信息
let threadIds = [sessionId];
@ -331,10 +334,10 @@ export default class CallManagerService {
'has_attachment': actionData.hasAttachment ? 1 : 0
};
this.updateById(threadIds, valueBucket, res => {
mmsLog.log(TAG + 'updateById,res:' + res);
HiLog.i(TAG, 'insertExitingSession, res: ' + JSON.stringify(res));
// 这里调用短信数据库,插入短信信息
this.dealInsertMessageDetail(param, actionData, sessionId, initDatas => {
mmsLog.log('dealInsertMessageDetail,initDatas:' + initDatas);
HiLog.i(TAG, 'insertExitingSession, initDatas: ' + JSON.stringify(initDatas));
let result = {
rowId: sessionId,
initDatas: initDatas
@ -345,15 +348,15 @@ export default class CallManagerService {
}
querySessionByTelephone(telephone, callback) {
let result = {};
let result: LooseObject = {};
let queryPromise = this.querySessionByTelephoneRdb(telephone);
Promise.all([queryPromise]).then((res) => {
mmsLog.log('querySessionByTelephone,result:' + res[0]);
HiLog.i(TAG, 'querySessionByTelephone, res: ' + JSON.stringify(res[0]));
result.code = common.int.SUCCESS;
result.response = res[0];
callback(result);
}).catch((err) => {
mmsLog.log('querySessionByTelephone error: ' + err);
HiLog.e(TAG, 'querySessionByTelephone, error: ' + JSON.stringify(err));
result.code = common.int.FAILURE;
callback(result);
});
@ -361,19 +364,18 @@ export default class CallManagerService {
// 根据手机号,获取会话列表
async querySessionByTelephoneRdb(telephone) {
HiLog.i(TAG, 'querySessionByTelephoneRdb');
// 创建查询条件对象
let predicates = new ohosDataRdb.RdbPredicates(common.tableName.SESSION);
mmsLog.log('querySessionByTelephoneRdb, predicates:' + predicates);
// 如果为空,查询所有的列表数据
if (telephone) {
await predicates.equalTo(mmsTable.sessionField.telephone, telephone);
}
mmsLog.log('querySessionByTelephoneRdb, rdbStore:' + rdbStore);
// 获取到结果集
let resultSet = await rdbStore.query(predicates);
// 获取第一条
resultSet.goToFirstRow();
let result = {};
let result: LooseObject = {};
result.id = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.id));
result.time = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.time));
result.telephone = await resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.telephone));
@ -381,7 +383,7 @@ export default class CallManagerService {
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.sendingStatus = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.sendingStatus));
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));
return result;
@ -393,15 +395,16 @@ export default class CallManagerService {
}
insertSessionRdb(tableName, valueBucket, callback) {
let insertPromise = this.insert(tableName, valueBucket);
let result = {};
HiLog.i(TAG, 'insertSessionRdb');
let insertPromise = rdbStore.insert(tableName, valueBucket);
let result: LooseObject = {};
insertPromise.then((ret) => {
mmsLog.log('insertSession rowId:' + ret);
HiLog.i(TAG, 'insertSessionRdb, rowId: ' + ret);
result.code = common.int.SUCCESS;
result.rowId = ret;
callback(result);
}).catch((err) => {
mmsLog.log('insertSession error: ' + err);
HiLog.e(TAG, 'insertSessionRdb, error: ' + JSON.stringify(err));
result.code = common.int.FAILURE;
callback(result);
});
@ -411,13 +414,14 @@ export default class CallManagerService {
* 新增数据
*/
async insert(tableName, valueBucket) {
mmsLog.log('insert,enter:' + rdbStore);
let promise = rdbStore.insert(tableName, valueBucket);
HiLog.i(TAG, 'insert, tableName:' + JSON.stringify(tableName));
let promise = await rdbStore.insert(tableName, valueBucket);
let rowId = 0;
promise.then((ret) => {
rowId = ret;
HiLog.i(TAG, 'insert, first success: ' + rowId);
}).catch((err) => {
mmsLog.log(TAG + ' insert first done: ' + err);
HiLog.e(TAG, 'insert, err: ' + JSON.stringify(err));
})
await promise;
return rowId;
@ -436,7 +440,7 @@ export default class CallManagerService {
let initDatas = [];
let count = 0;
let sendResults = actionData.sendResults;
for (let sendResult of sendResults) {
sendResults.forEach(sendResult => {
let insertDetail = {
receiverNumber: common.string.EMPTY_STR,
senderNumber: common.string.EMPTY_STR,
@ -448,7 +452,8 @@ export default class CallManagerService {
isSender: actionData.isSender,
groupId: maxGroupId,
mmsSource: actionData.mmsSource,
isMms: actionData.isMms
isMms: actionData.isMms,
isRead: -1
};
if (actionData.isReceive) {
insertDetail.receiverNumber = actionData.ownNumber;
@ -457,7 +462,7 @@ export default class CallManagerService {
}
this.insertMessageDetail(insertDetail, result => {
count++;
mmsLog.log(TAG + 'insertMessageDetail,result:' + result);
HiLog.i(TAG, 'insertMessageDetailByGroupId, result: ' + result);
let initData = {
id: result,
telephone: sendResult.telephone
@ -467,7 +472,7 @@ export default class CallManagerService {
callback(initDatas);
}
});
}
})
}
dealSendResults(sendResults) {
@ -487,7 +492,7 @@ export default class CallManagerService {
smsType = 1;
}
let timestamp = new Date().getTime();
let result = {};
let result: LooseObject = {};
result.contractsNum = contractsNum;
result.telephone = telephoneUtils.dealTelephoneSort(telephone);
result.content = content;
@ -498,7 +503,7 @@ export default class CallManagerService {
}
insertMessageDetail(value, callback) {
let actionData = {};
let actionData: LooseObject = {};
let time = new Date();
let timeStr = time.getTime() + common.string.EMPTY_STR;
var stringValue = {
@ -523,10 +528,10 @@ export default class CallManagerService {
'is_send_report': 0,
'group_id': value.groupId
};
mmsLog.log(TAG + 'insertMessageDetail stringValue:' + stringValue);
HiLog.i(TAG, 'insertMessageDetail, stringValue: ' + JSON.stringify(stringValue));
actionData.stringValue = stringValue;
this.insertMessageDetailRdb(actionData, msgId => {
mmsLog.log(TAG + 'insertMessageDetailRdb msgId:' + msgId);
HiLog.i(TAG, 'insertMessageDetail, msgId: ' + msgId);
if (value.isMms) {
value.msgId = msgId;
this.batchInsertMmsPart(value);
@ -549,18 +554,19 @@ export default class CallManagerService {
};
bacthmsParts.push(stringValue);
}
mmsLog.log(TAG + 'batchInsertMmsPart stringValue' + bacthmsParts);
HiLog.i(TAG, 'batchInsertMmsPart, bacthmsParts: ' + JSON.stringify(bacthmsParts));
for(let stringValue of bacthmsParts) {
this.insertMmsPart(stringValue);
}
}
async insertMmsPart(stringValue) {
let dataAbilityHelper = await particleAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_MMS_PART;
dataAbilityHelper.insert(managerUri, stringValue).then(data => {
mmsLog.log(TAG + 'insertMmsPart, success:' + data);
HiLog.i(TAG, 'insertMmsPart, success data: ' + JSON.stringify(data));
}).catch(error => {
mmsLog.log(TAG + 'insertMmsPart fail:' + error);
HiLog.e(TAG, 'insertMmsPart, fail: ' + JSON.stringify(error));
});
}
@ -568,11 +574,13 @@ export default class CallManagerService {
async insertMessageDetailRdb(actionData, callback) {
// 获取DataAbilityHelper对象
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.insert(managerUri, actionData.stringValue).then(data => {
mmsLog.log('dataAbilityHelper, success:' + data);
let dataAbilityHelper = await particleAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
let promise = dataAbilityHelper.insert(managerUri, actionData.stringValue);
await promise.then(data => {
HiLog.i(TAG, 'insertMessageDetailRdb, success data: ' + JSON.stringify(data));
callback(data);
}).catch(error => {
mmsLog.log('insertMessageDetail fail:' + error);
HiLog.e(TAG, 'insertMessageDetailRdb, fail: ' + JSON.stringify(error));
});
}
@ -582,14 +590,14 @@ export default class CallManagerService {
* @return
*/
async updateById(threadIds, valueBucket, callback) {
mmsLog.log('updateById, threadIds:' + 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);
await predicates.equalTo(mmsTable.sessionField.id, threadId);
this.update(predicates, valueBucket, res => {
mmsLog.log(TAG + 'updated row count: ' + res);
HiLog.i(TAG, 'updateById, res: ' + JSON.stringify(res));
callback(res);
});
}
@ -616,26 +624,27 @@ export default class CallManagerService {
*/
queryMaxGroupId(actionData, callBack) {
this.queryMaxGroupIdDb(actionData, res => {
mmsLog.log(TAG + 'queryMaxGroupId, end:' + res);
HiLog.i(TAG, 'queryMaxGroupId, callback');
callBack(res.maxGroupId);
});
}
// 获取最大的groupId
async queryMaxGroupIdDb(actionData, callback) {
mmsLog.log('queryMaxGroupIdDb dataAbilityHelper :' + dataAbilityHelper);
let dataAbilityHelper = await particleAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
let resultColumns = [
'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) => {
let result = {};
let result: LooseObject = {};
while (resultSet.goToNextRow()) {
result.maxGroupId = resultSet.getString(0);
mmsLog.log(TAG + 'queryMaxGroupId result = ' + result);
}
callback(result);
}).catch(error => {
HiLog.e(TAG, 'queryMaxGroupIdDb, error: ' + JSON.stringify(error));
});
}
@ -643,23 +652,24 @@ export default class CallManagerService {
* commonEvent publish data
*/
publishData(telephone, content) {
let actionData = {};
actionData.telephone = telephone;
actionData.content = content;
mmsLog.log('receive_message.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,
isOrdered: false,
data: JSON.stringify(actionData)
}, (res) => {
mmsLog.log('receive_message.publish callback res: ' + res);
HiLog.i(TAG, 'publishData, callback res: ' + JSON.stringify(res));
});
}
async sendNotification(telephone, msgId, content) {
let telephones = [telephone];
this.queryContactDataByTelephone(telephones, async (contracts) => {
mmsLog.log('queryContactDataByTelephone contracts:' + contracts);
HiLog.i(TAG, 'sendNotification, callback');
let actionData = this.dealContactParams(contracts, telephone);
if (content.length > 15) {
content = content.substring(0, 15) + '...';
@ -675,7 +685,7 @@ export default class CallManagerService {
}
dealContactParams(contracts, telephone) {
let actionData = {};
let actionData: LooseObject = {};
let params = [];
if(contracts.length == 0) {
params.push({
@ -698,22 +708,24 @@ export default class CallManagerService {
mmsTable.contactDataColumns.detailInfo,
mmsTable.contactDataColumns.displayName,
];
let contactDataAbilityHelper = await particleAbility.acquireDataAbilityHelper(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.type_id, '5');
condition.equalTo(mmsTable.contactDataColumns.typeId, '5');
contactDataAbilityHelper.query(contactDataUri, resultColumns, condition).then(resultSet => {
let contracts = [];
while (resultSet.goToNextRow()) {
let contract = {};
contract.detailInfo = resultSet.getString(0);
contract.displayName = resultSet.getString(1);
let contract = {
detailInfo: resultSet.getString(0),
displayName: resultSet.getString(1)
};
contracts.push(contract);
}
callback(contracts);
}).catch(error => {
mmsLog.log('queryContactDataByTelephone error:' + error);
HiLog.e(TAG, 'queryContactDataByTelephone error: ' + JSON.stringify(error));
});
}
}

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
/*
* 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
@ -13,23 +13,28 @@
* limitations under the License.
*/
import MmsManagerService from './MmsManagerService.js';
import mmsLog from '../default/utils/MmsLog.js';
/**
* @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();
},
/**
* onStart
*/
onStart() {
mmsLog.log('service onStart mmsservice');
new MmsManagerService();
},
/**
* onDestroy
*/
onDestroy() {
mmsLog.log('service onDestroy mmsservice');
}
}
/**
* onStop
*/
onStop() {
HiLog.i(TAG, 'onStop');
this.mmsManagerService.unsubscribe();
}
};

View File

@ -0,0 +1,28 @@
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import HiLog from './utils/HiLog';
import AppStorageUtil from './utils/AppStorageUtil';
const TAG = 'app';
export default {
onCreate() {
HiLog.i(TAG, 'onCreate');
new AppStorageUtil();
},
onDestroy() {
HiLog.i(TAG, 'onDestroy');
}
};

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#msgHighlight {
flex-direction: row;
flex-wrap: wrap;
export default interface LooseObject {
[key: string]: any
}

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -14,8 +14,9 @@
*/
import pasteboard from '@ohos.pasteboard';
import mmsLog from '../utils/MmsLog.js';
import HiLog from '../Utils/HiLog';
const TAG = 'Pasteboard';
let commonPasteboard = {
getPasteboard() {
let sysPasteboard = pasteboard.getSystemPasteboard();
@ -25,7 +26,7 @@ let commonPasteboard = {
let sysPasteboard = pasteboard.getSystemPasteboard();
let textData = pasteboard.createPlainTextData(text);
sysPasteboard.setPasteData(textData, () => {
mmsLog.info('pasteboard setPasteData done');
HiLog.i(TAG, 'setPasteboard done');
});
}
};

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -75,8 +75,8 @@ export default {
// 草稿数据类型
SEND_DRAFT: 3,
// 列表左移滑动操作控件的宽度
OPERATE_DELETE_WIDTH: 145,
OPERATE_UNREAD_WIDTH: 230,
OPERATE_DELETE_WIDTH: 80,
OPERATE_UNREAD_WIDTH: 128,
// sim卡数量
SIM_COUNT: 2,
// sim卡1
@ -98,8 +98,6 @@ export default {
EMPTY_STR: '',
// 逗号
COMMA: ',',
// 分号
SEMICOLON: ';',
// bundleName
BUNDLE_NAME: 'com.ohos.mms',
// abilityName
@ -225,12 +223,6 @@ export default {
TAB_AUDIO: 2,
TAB_MORE: 3
},
TAG: {
// 信息列表首页
MsgList: 'message_list :',
// 通知信息
MsgInfo: 'message_info :'
},
HIGHLIGHT_TYPE: {
// 普通数据
NORMAL: 0,

View File

@ -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:
'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
}
}

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -12,21 +12,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import LooseObject from '../data/LooseObject';
export default class BaseModel {
constructor() {
}
encapsulateReturnResult(code, abilityResult) {
var result = {};
var result:LooseObject = {};
result.code = code;
result.abilityResult = abilityResult;
return result;
}
encapsulateReturnCode(code) {
var result = {};
var result:LooseObject = {};
result.code = code;
return result;
}
}

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -13,36 +13,37 @@
* limitations under the License.
*/
import BaseModel from '../BaseModel.js';
import common from '../../pages/common_constants.js';
import mmsLog from '../../../default/utils/MmsLog.js';
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';
const TAG = 'CardModel ->';
const TAG = 'CardModel';
export default class CardModel extends BaseModel {
getSimSpn(preferences) {
telephonySim.getSimSpn(common.int.SIM_ONE, (err, value) => {
if (err) {
mmsLog.log('getSimSpn error = ' + err.message);
HiLog.e(TAG, 'getSimSpn, SIM_ONE error: ' + JSON.stringify(err));
} else {
preferences.setValueForSwitch(common.string.KEY_OF_SIM_0_SPN, value);
mmsLog.log('getSimSpn spn = ' + value);
HiLog.i(TAG, 'getSimSpn, SIM_ONE spn=' + value);
}
});
telephonySim.getSimSpn(common.int.SIM_TWO, (err, value) => {
if (err) {
mmsLog.log('getSimSpn error = ' + err.message);
HiLog.e(TAG, 'getSimSpn, SIM_TWO error: ' + JSON.stringify(err));
} else {
preferences.setValueForSwitch(common.string.KEY_OF_SIM_1_SPN, value);
mmsLog.log('getSimSpn spn = ' + value);
HiLog.i(TAG, 'getSimSpn, SIM_TWO spn=' + value);
}
});
}
getSmscNumber(slotId, preferences, callback) {
mmsLog.info(TAG + 'getSmscAddr,slotId:' + slotId);
HiLog.i(TAG, 'getSmscNumber, slotId:' + slotId);
let smsNumber = common.string.EMPTY_STR;
let simOne = preferences.getNewSmscOfSim1();
let simTwo = preferences.getNewSmscOfSim2();
@ -61,7 +62,7 @@ export default class CardModel extends BaseModel {
}
callback(smsNumber);
}).catch((error) => {
mmsLog.info(TAG + 'getSmNumber smsNumber: error = ' + JSON.stringify(error));
HiLog.e(TAG, 'getSmscNumber, error: ' + JSON.stringify(error));
});
}
callback(smsNumber);
@ -73,11 +74,11 @@ export default class CardModel extends BaseModel {
let simMessageList = [];
telephonySMS.getAllSimMessages(index, (error, msgArray) => {
if (error) {
mmsLog.log(TAG + 'getAllSimMessages callback error cause :' + error.message);
HiLog.e(TAG, 'queryMessageInSimCard, error: ' + JSON.stringify(error));
return;
}
for (let i = 0;i < msgArray.length; i++) {
let data = {};
let data: LooseObject = {};
data.image = '/common/icon/user_avatar_full_fill.svg';
data.date = common.string.EMPTY_STR;
data.time = common.string.EMPTY_STR;
@ -91,7 +92,7 @@ export default class CardModel extends BaseModel {
data.isMsm = false;
simMessageList.push(data);
}
callback(super.encapsulateReturnResult(common.int.SUCCESS, simMessageList));
callback(this.encapsulateReturnResult(common.int.SUCCESS, simMessageList));
});
}
@ -100,29 +101,29 @@ export default class CardModel extends BaseModel {
let msgIndex = actionData.indexOnSim;
telephonySMS.delSimMessage(index, msgIndex, (error, value) => {
if (error) {
mmsLog.log(TAG + 'delSimMessage error cause: ' + error.message);
HiLog.e(TAG, 'delSimMessage, error: ' + JSON.stringify(error));
} else {
mmsLog.log(TAG + 'delSimMessage value cause: ' + value);
HiLog.i(TAG, 'delSimMessage, value=' + value);
}
});
}
getSimCardNum(preferences) {
mmsLog.log(TAG + 'getSimCardNum start' + telephonySim);
HiLog.i(TAG, 'getSimCardNum start ' + telephonySim);
telephonySim.hasSimCard(common.int.SIM_ONE, (error, value) => {
if (error) {
mmsLog.log(TAG + 'hasSimCard0 error cause: ' + error.message);
HiLog.e(TAG, 'getSimCardNum, SIM_ONE error: ' + JSON.stringify(error));
} else {
mmsLog.log(TAG + 'hasSimCard0 result: ' + value);
HiLog.i(TAG, 'getSimCardNum, SIM_ONE value=' + value);
let result = value ? common.bool.TRUE : common.bool.FALSE;
preferences.setValueForSwitch(common.string.KEY_OF_SIM_0_EXIST_FLAG, result);
}
});
telephonySim.hasSimCard(common.int.SIM_TWO, (error, value) => {
if (error) {
mmsLog.log(TAG + 'hasSimCard1 error cause: ' + error.message);
HiLog.e(TAG, 'getSimCardNum, SIM_TWO error: ' + JSON.stringify(error));
} else {
mmsLog.log(TAG + 'hasSimCard1 result: ' + value);
HiLog.i(TAG, 'getSimCardNum, SIM_TWO value=' + value);
let result = value ? common.bool.TRUE : common.bool.FALSE;
preferences.setValueForSwitch(common.string.KEY_OF_SIM_1_EXIST_FLAG, result);
}
@ -130,20 +131,20 @@ export default class CardModel extends BaseModel {
}
getSimTelephoneNumber(preferences) {
mmsLog.log(TAG + 'getSimTelephoneNumber start');
HiLog.i(TAG, 'getSimTelephoneNumber start');
telephonySim.getSimTelephoneNumber(common.int.SIM_ONE, (error, value) => {
if (error) {
mmsLog.log('getSimTelephoneNumber error cause: ' + error.message);
HiLog.e(TAG, 'getSimTelephoneNumber, SIM_ONE error: ' + JSON.stringify(error));
} else {
mmsLog.log('getSimTelephoneNumber success: ' + value);
HiLog.i(TAG, 'getSimTelephoneNumber, SIM_ONE value=' + value);
preferences.setValueForSwitch(common.string.KEY_OF_SIM_0_NUMBER, value);
}
});
telephonySim.getSimTelephoneNumber(common.int.SIM_TWO, (error, value) => {
if (error) {
mmsLog.log('getSimTelephoneNumber error cause: ' + error.message);
HiLog.e(TAG, 'getSimTelephoneNumber, SIM_TWO error: ' + JSON.stringify(error));
} else {
mmsLog.log('getSimTelephoneNumber success: ' + value);
HiLog.i(TAG, 'getSimTelephoneNumber, SIM_TWO value=' + value);
preferences.setValueForSwitch(common.string.KEY_OF_SIM_1_NUMBER, value);
}
});

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -13,24 +13,25 @@
* limitations under the License.
*/
import BaseModel from '../BaseModel.js';
import common from '../../pages/common_constants.js';
import mmsLog from '../../../default/utils/MmsLog.js';
import mmsTable from '../../pages/mms_table.js';
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) {
mmsLog.log(TAG + 'queryContactDataByIds, params:' + actionData);
let featureAbility = actionData.featureAbility;
let dataHelper = await featureAbility.getDataAbilityHelper(common.string.URI_ROW_CONTACTS);
HiLog.i(TAG, 'queryContactDataByIds, params:' + JSON.stringify(actionData));
let dataHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_ROW_CONTACTS);
let resultColumns = [
mmsTable.contactDataColumns.detailInfo,
mmsTable.contactDataColumns.displayName,
];
let ohosDataAbility = actionData.ohosDataAbility;
let condition = new ohosDataAbility.DataAbilityPredicates();
let condition = new dataAbility.DataAbilityPredicates();
let contactDataUri = common.string.URI_ROW_CONTACTS + common.string.CONTACT_DATA_URI;
condition.in(mmsTable.contactDataColumns.contactId, actionData.contractIds);
condition.and();
@ -40,19 +41,18 @@ export default class ContactsModel extends BaseModel {
dataHelper.query(contactDataUri, resultColumns, condition).then(resultSet => {
callback(this.dealResultSet(resultSet));
}).catch(error => {
mmsLog.info('queryContactDataByIds error:' + error);
HiLog.e(TAG, 'queryContactDataByIds, error: ' + JSON.stringify(error));
});
}
async queryContactDataByTelephone(actionData, callback) {
let featureAbility = actionData.featureAbility;
let telephoneDataHelp = await featureAbility.getDataAbilityHelper(common.string.URI_ROW_CONTACTS);
HiLog.i(TAG, 'begin queryContactDataByTelephone: ' + JSON.stringify(actionData));
let telephoneDataHelp = await featureAbility.acquireDataAbilityHelper(common.string.URI_ROW_CONTACTS);
let resultColumns = [
mmsTable.contactDataColumns.detailInfo,
mmsTable.contactDataColumns.displayName,
];
let ohosDataAbility = actionData.ohosDataAbility;
let condition = new ohosDataAbility.DataAbilityPredicates();
let condition = new dataAbility.DataAbilityPredicates();
let contactDataUri = common.string.URI_ROW_CONTACTS + common.string.CONTACT_DATA_URI;
condition.in(mmsTable.contactDataColumns.detailInfo, actionData.telephones);
condition.and();
@ -62,14 +62,14 @@ export default class ContactsModel extends BaseModel {
telephoneDataHelp.query(contactDataUri, resultColumns, condition).then(resultSet => {
callback(this.dealResultSet(resultSet));
}).catch(error => {
mmsLog.info('queryContactDataByTelephone error:' + error);
HiLog.e(TAG, 'queryContactDataByTelephone, error: ' + JSON.stringify(error));
});
}
dealResultSet(resultSet) {
let contracts = [];
while (resultSet.goToNextRow()) {
let contract = {};
let contract: LooseObject = {};
contract.detailInfo = resultSet.getString(0);
contract.displayName = resultSet.getString(1);
contracts.push(contract);
@ -78,13 +78,11 @@ export default class ContactsModel extends BaseModel {
}
async queryContact(actionData, callback) {
let featureAbility = actionData.featureAbility;
let DAHelper = await featureAbility.getDataAbilityHelper(common.string.URI_ROW_CONTACTS);
let DAHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_ROW_CONTACTS);
let resultColumns = [
mmsTable.contactColumns.id
];
let ohosDataAbility = actionData.ohosDataAbility;
let condition = new ohosDataAbility.DataAbilityPredicates();
let condition = new dataAbility.DataAbilityPredicates();
let rawContactUri = common.string.URI_ROW_CONTACTS + common.string.CONTACT_URI;
let offset = (actionData.page - 1) * actionData.limit;
condition.limitAs(actionData.limit)
@ -97,18 +95,16 @@ export default class ContactsModel extends BaseModel {
}
callback(rawContactIds);
}).catch(error => {
mmsLog.info('queryRowContact ,error:' + error);
HiLog.e(TAG, 'queryContact, error: ' + JSON.stringify(error));
});
}
async countContact(actionData, callback) {
let featureAbility = actionData.featureAbility;
let DAHelper = await featureAbility.getDataAbilityHelper(common.string.URI_ROW_CONTACTS);
let DAHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_ROW_CONTACTS);
let resultColumns = [
mmsTable.contactColumns.id
];
let ohosDataAbility = actionData.ohosDataAbility;
let condition = new ohosDataAbility.DataAbilityPredicates();
let condition = new dataAbility.DataAbilityPredicates();
let rawContactUri = common.string.URI_ROW_CONTACTS + common.string.CONTACT_URI;
condition.orderByDesc(mmsTable.contactColumns.lastestContactedTime);
DAHelper.query(rawContactUri, resultColumns, condition).then(resultSet => {
@ -118,20 +114,17 @@ export default class ContactsModel extends BaseModel {
}
callback(count);
}).catch(error => {
mmsLog.info('countContact ,error:' + error);
HiLog.e(TAG, 'countContact, error: ' + JSON.stringify(error));
});
}
async searchContracts(actionData, callback) {
mmsLog.log(TAG + 'searchContracts,actionData:' + actionData);
let featureAbility = actionData.featureAbility;
let searchDataHelper = await featureAbility.getDataAbilityHelper(common.string.URI_ROW_CONTACTS);
let searchDataHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_ROW_CONTACTS);
let resultColumns = [
mmsTable.searchContactView.detailInfo,
mmsTable.searchContactView.displayName
];
let ohosDataAbility = actionData.ohosDataAbility;
let condition = new ohosDataAbility.DataAbilityPredicates();
let condition = new dataAbility.DataAbilityPredicates();
let searchContactsUri = common.string.URI_ROW_CONTACTS + common.string.CONTACT_SEARCHE;
condition.equalTo(mmsTable.searchContactView.contentType, 'phone')
.beginWrap()
@ -141,10 +134,10 @@ export default class ContactsModel extends BaseModel {
.endWrap();
searchDataHelper.query(searchContactsUri, resultColumns, condition).then(resultSet => {
let contracts = this.dealResultSet(resultSet);
callback(super.encapsulateReturnResult(common.int.SUCCESS, contracts));
callback(this.encapsulateReturnResult(common.int.SUCCESS, contracts));
}).catch(error => {
mmsLog.info(TAG + 'searchContracts contracts error:' + error);
callback(super.encapsulateReturnCode(common.int.FAILURE));
HiLog.e(TAG, 'searchContracts, error: ' + JSON.stringify(error));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
@ -154,26 +147,23 @@ export default class ContactsModel extends BaseModel {
* @param callback 回调
*/
async queryProfile(actionData, callback) {
mmsLog.log('jumpToCard queryProfile is start ');
let featureAbility = actionData.featureAbility;
let DAHelper = await featureAbility.getDataAbilityHelper(common.string.URI_ROW_CONTACTS);
mmsLog.log('jumpToCard queryProfile is condition: '+ DAHelper);
HiLog.i(TAG, 'queryProfile start ');
let DAHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_ROW_CONTACTS);
let resultColumns = [
mmsTable.contactDataColumns.id,
];
let ohosDataAbility = actionData.ohosDataAbility;
let condition = new ohosDataAbility.DataAbilityPredicates();
let condition = new dataAbility.DataAbilityPredicates();
let contactDataUri = common.string.URI_ROW_CONTACTS + common.string.PROFILE_DATA_URI;
DAHelper.query(contactDataUri, resultColumns, condition).then(resultSet => {
let count = 0;
while (resultSet.goToNextRow()) {
count++;
}
mmsLog.log('jumpToCard queryProfile is goToNextRow: ' + count);
HiLog.i(TAG, 'queryProfile, goToNextRow: ' + count);
resultSet.close();
callback(count);
}).catch(error => {
mmsLog.info('queryProfile error:' + error);
HiLog.e(TAG, 'queryProfile, error: ' + JSON.stringify(error));
});
}
}

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -13,17 +13,19 @@
* limitations under the License.
*/
import BaseModel from '../BaseModel.js';
import common from '../../pages/common_constants.js';
import mmsTable from '../../pages/mms_table.js';
import mmsLog from '../../utils/MmsLog.js';
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';
const TAG = 'ConversationListModel ->';
const TAG = 'ConversationListModel';
export default class ConversationListModel extends BaseModel {
async querySessionList(rdbStore, actionData) {
mmsLog.log(TAG + 'querySessionList,db,actionData:' + actionData);
async querySessionList(actionData) {
let predicates = rdbStore.getRdbPredicates(common.tableName.SESSION);
let numberType = actionData.numberType;
if (numberType != null) {
@ -33,7 +35,7 @@ export default class ConversationListModel extends BaseModel {
await predicates.limitAs(actionData.limit);
let offset = (actionData.page - 1) * actionData.limit;
await predicates.offsetAs(offset);
let resultSet = await rdbStore.getRdbStore().query(predicates);
let resultSet = await rdbStore.query(predicates);
let sessionList = [];
while (resultSet.goToNextRow()) {
let item = await this.buildResultSet(resultSet);
@ -45,29 +47,30 @@ export default class ConversationListModel extends BaseModel {
return result;
}
async querySessionByTelephone(rdbStore, telephone) {
async querySessionByTelephone(telephone) {
HiLog.i(TAG, ', querySessionByTelephone start')
let predicates = rdbStore.getRdbPredicates(common.tableName.SESSION);
if (telephone) {
await predicates.equalTo(mmsTable.sessionField.telephone, telephone);
}
let resultSet = await rdbStore.getRdbStore().query(predicates);
let resultSet = await rdbStore.query(predicates);
resultSet.goToFirstRow();
let result = await this.buildResultSet(resultSet);
return result;
}
async querySessionById(rdbStore, threadId) {
async querySessionById(threadId) {
let predicates = rdbStore.getRdbPredicates(common.tableName.SESSION);
if (threadId) {
await predicates.equalTo(mmsTable.sessionField.id, threadId);
}
let resultSet = await rdbStore.getRdbStore().query(predicates);
let resultSet = await rdbStore.query(predicates);
resultSet.goToFirstRow();
let result = await this.buildResultSet(resultSet);
return result;
}
async searchSessionByTelephone(rdbStore, telephone, numberType) {
async searchSessionByTelephone(telephone, numberType) {
let predicates = rdbStore.getRdbPredicates(common.tableName.SESSION);
if (telephone != common.string.EMPTY_STR) {
await predicates.like(mmsTable.sessionField.telephone, '%' + telephone + '%');
@ -75,7 +78,7 @@ export default class ConversationListModel extends BaseModel {
if (numberType != null) {
await predicates.equalTo(mmsTable.sessionField.smsType, numberType);
}
let resultSet = await rdbStore.getRdbStore().query(predicates);
let resultSet = await rdbStore.query(predicates);
let sessionList = [];
while (resultSet.goToNextRow()) {
let item = await this.buildResultSet(resultSet);
@ -85,31 +88,31 @@ export default class ConversationListModel extends BaseModel {
}
async buildResultSet(resultSet) {
let result = {};
result.id = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.id));
result.time = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.time));
result.hasDraft = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.hasDraft));
result.smsType = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.smsType));
let result: LooseObject = {};
result.id = await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.id)));
result.time = await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.time)));
result.hasDraft = await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.hasDraft)));
result.smsType = await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.smsType)));
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.unreadCount = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.unreadCount));
result.messageCount = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.messageCount));
result.hasMms = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.hasMms));
result.sendingStatus = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.sendingStatus));
result.hasAttachment = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.hasAttachment));
result.hasLock = await resultSet.getLong(resultSet.getColumnIndex(mmsTable.sessionField.hasLock));
result.contactsNum = await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.contactsNum)));
result.unreadCount = await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.unreadCount)));
result.messageCount = await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.messageCount)));
result.hasMms = await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.hasMms)));
result.sendStatus = await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.sendStatus)));
result.hasAttachment = await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.hasAttachment)));
result.hasLock = await Number(resultSet.getString(resultSet.getColumnIndex(mmsTable.sessionField.hasLock)));
result.telephoneFormat = result.telephone;
return result;
}
async countSessionList(rdbStore, actionData) {
async countSessionList(actionData) {
let predicates = rdbStore.getRdbPredicates(common.tableName.SESSION);
let numberType = actionData.numberType;
if (numberType != null) {
await predicates.equalTo(mmsTable.sessionField.smsType, numberType);
}
let resultSet = await rdbStore.getRdbStore().query(predicates);
let resultSet = await rdbStore.query(predicates);
let count = 0;
while (resultSet.goToNextRow()) {
count++;
@ -121,8 +124,7 @@ export default class ConversationListModel extends BaseModel {
}
async statisticalData(actionData, callback) {
let featureAbility = actionData.featureAbility;
let dataAbilityHelper = await featureAbility.getDataAbilityHelper(
let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
let resultColumns = [
@ -130,66 +132,69 @@ export default class ConversationListModel extends BaseModel {
'unreadCount',
'unreadTotalOfInfo'
];
let ohosDataAbility = actionData.ohosDataAbility;
let condition = new ohosDataAbility.DataAbilityPredicates();
let condition = new dataAbility.DataAbilityPredicates();
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_UNREAD_COUNT;
dataAbilityHelper.query(managerUri, resultColumns, condition, (err, resultSet) => {
let result = {};
let result: LooseObject = {};
while (resultSet.goToNextRow()) {
result.totalListCount = resultSet.getString(0);
result.unreadCount = resultSet.getString(1);
result.unreadTotalOfInfo = resultSet.getString(2);
}
callback(super.encapsulateReturnResult(common.int.SUCCESS, result));
HiLog.i(TAG, 'statisticalData, result:' + JSON.stringify(result));
callback(this.encapsulateReturnResult(common.int.SUCCESS, result));
});
}
async markAllAsRead(rdbStore, threadIds, valueBucket) {
mmsLog.info(TAG + 'markAllAsReadById, threadIds:' + JSON.stringify(threadIds));
this.updateById(rdbStore, threadIds, valueBucket);
async markAllAsRead(threadIds, valueBucket) {
HiLog.i(TAG, 'markAllAsRead, threadIds:' + JSON.stringify(threadIds));
this.updateById(threadIds, valueBucket);
}
async markAllToRead(rdbStore, smsType) {
async markAllToRead(smsType) {
let predicates = rdbStore.getRdbPredicates(common.tableName.SESSION);
predicates.equalTo(mmsTable.sessionField.sms_type, smsType);
predicates.greaterThan(mmsTable.sessionField.unread_count, 0);
predicates.equalTo(mmsTable.sessionField.smsType, smsType);
predicates.greaterThan(mmsTable.sessionField.unreadCount, 0);
let valueBucket = {
'unread_count': 0
};
rdbStore.update(predicates, valueBucket);
}
async updateById(rdbStore, threadIds, valueBucket) {
async updateById(threadIds, valueBucket) {
HiLog.i(TAG, ', updateById, threadIds: ' + JSON.stringify(threadIds))
if (threadIds.length != 0) {
for (let threadId of threadIds) {
let predicates = rdbStore.getRdbPredicates(common.tableName.SESSION);
await predicates.equalTo(mmsTable.sessionField.id, threadId);
rdbStore.update(predicates, valueBucket);
HiLog.d(TAG, ', update SESSION TAB end')
}
}
}
async deleteMessageById(rdbStore, threadIds) {
mmsLog.info(TAG + 'deleteMessageById, threadIds:' + threadIds);
async deleteMessageById(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);
await predicates.equalTo(mmsTable.sessionField.id, threadId);
rdbStore.deleteItem(predicates);
HiLog.d(TAG, ', delete SESSION TAB end')
}
}
}
insertSession(rdbStore, tableName, valueBucket, callback) {
insertSession(tableName, valueBucket, callback) {
let insertPromise = rdbStore.insert(tableName, valueBucket);
let result = {};
let result: LooseObject = {};
insertPromise.then((ret) => {
mmsLog.log(TAG + 'insertSession rowId:' + ret);
HiLog.i(TAG, 'insertSession, rowId:' + ret);
result.code = common.int.SUCCESS;
result.rowId = ret;
callback(result);
}).catch((err) => {
mmsLog.log(TAG + 'insertSession error: ' + err);
HiLog.e(TAG, 'insertSession, error: ' + JSON.stringify(err));
result.code = common.int.FAILURE;
callback(result);
});

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -13,55 +13,55 @@
* limitations under the License.
*/
import BaseModel from '../BaseModel.js';
import MorkDataModel from '../MorkDataModel.js';
import common from '../../pages/common_constants.js';
import mmsTable from '../../pages/mms_table.js';
import BaseModel from './BaseModel';
import MorkDataModel from './MorkDataModel';
import common from '../data/commonData';
import mmsTable from '../data/tableData';
// log 工具类
import mmsLog from '../../utils/MmsLog.js';
import HiLog from '../utils/HiLog'
import LooseObject from '../data/LooseObject'
import featureAbility from '@ohos.ability.featureAbility';
import particleAbility from '@ohos.ability.particleAbility';
import dataAbility from '@ohos.data.dataAbility';
const TAG = 'ConversationModel';
let morkDataModel = new MorkDataModel();
const TAG = 'ConversationModel ->';
export default class ConversationModel extends BaseModel {
async queryMessageDetail(actionData, callback) {
mmsLog.log(TAG + 'queryMessageDetail param:' + actionData);
let featureAbility = actionData.featureAbility;
let dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(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()) {
let result = {};
let result: LooseObject = {};
this.dealBaseColumsData(result, resultSet);
result.operatorServiceNumber = resultSet.getString(10);
result.msgCode = resultSet.getString(11);
result.isLock = resultSet.getString(12);
result.isRead = resultSet.getString(13);
result.isCollect = resultSet.getString(14);
result.sessionType = resultSet.getString(15);
result.retrNumber = resultSet.getString(16);
result.isSubsection = resultSet.getString(17);
result.sessionId = resultSet.getString(18);
result.groupId = resultSet.getString(19);
result.isSender = resultSet.getString(20);
result.isSendReport = resultSet.getString(21);
result.operatorServiceNumber = resultSet.getString(resultSet.getColumnIndex("operator_service_number"));
result.msgCode = resultSet.getString(resultSet.getColumnIndex("msg_code"));
result.isLock = resultSet.getString(resultSet.getColumnIndex("is_lock"));
result.isRead = resultSet.getString(resultSet.getColumnIndex("is_read"));
result.isCollect = resultSet.getString(resultSet.getColumnIndex("is_collect"));
result.sessionType = resultSet.getString(resultSet.getColumnIndex("session_type"));
result.retryNumber = resultSet.getString(resultSet.getColumnIndex("retry_number"));
result.isSubsection = resultSet.getString(resultSet.getColumnIndex("is_subsection"));
result.sessionId = resultSet.getString(resultSet.getColumnIndex("session_id"));
result.groupId = resultSet.getString(resultSet.getColumnIndex("group_id"));
result.isSender = resultSet.getString(resultSet.getColumnIndex("is_sender"));
result.isSendReport = resultSet.getString(resultSet.getColumnIndex("is_send_report"));
resultList.push(result);
}
callback(super.encapsulateReturnResult(common.int.SUCCESS, resultList));
callback(this.encapsulateReturnResult(common.int.SUCCESS, resultList));
}).catch(error => {
mmsLog.log(TAG + 'queryMessageDetail error:' + error);
callback(super.encapsulateReturnResult(common.int.FAILURE));
HiLog.e(TAG, 'queryMessageDetail, error: ' + JSON.stringify(error));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
buildQueryCondition(actionData) {
let ohosDataAbility = actionData.ohosDataAbility;
let condition = new ohosDataAbility.DataAbilityPredicates();
let condition = new dataAbility.DataAbilityPredicates();
if (actionData.isDraft != null && actionData.isDraft) {
condition.equalTo(mmsTable.messageInfo.groupId, actionData.groupId);
condition.equalTo(mmsTable.messageInfo.msgState, actionData.sendStatus);
@ -127,14 +127,9 @@ export default class ConversationModel extends BaseModel {
}
async searchSmsMessageByContent(actionData, callback) {
mmsLog.info(TAG + 'searchSmsMessageByContent param:' + actionData);
let featureAbility = actionData.featureAbility;
var dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
var resultColumns = this.buildSearchResultColums();
let ohosDataAbility = actionData.ohosDataAbility;
let condition = new ohosDataAbility.DataAbilityPredicates();
let condition = new dataAbility.DataAbilityPredicates();
condition.like(mmsTable.messageInfo.msgContent, '%' + actionData.content + '%');
condition.equalTo(mmsTable.messageInfo.msgType, 0);
if (actionData.numberType != null) {
@ -144,18 +139,18 @@ export default class ConversationModel extends BaseModel {
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.query(managerUri, resultColumns, condition).then(resultSet => {
while (resultSet.goToNextRow()) {
let result = {};
let result: LooseObject = {};
this.dealBaseColumsData(result, resultSet);
result.isCollect = resultSet.getString(10);
result.sessionId = resultSet.getString(11);
result.groupId = resultSet.getString(12);
result.isSender = resultSet.getString(13);
result.isCollect = resultSet.getString(resultSet.getColumnIndex("is_collect"));
result.sessionId = resultSet.getString(resultSet.getColumnIndex("session_id"));
result.groupId = resultSet.getString(resultSet.getColumnIndex("group_id"));
result.isSender = resultSet.getString(resultSet.getColumnIndex("is_sender"));
resultList.push(result);
}
callback(super.encapsulateReturnResult(common.int.SUCCESS, resultList));
callback(this.encapsulateReturnResult(common.int.SUCCESS, resultList));
}).catch(error => {
mmsLog.info(TAG + 'searchSmsMessageByContent error:' + error);
callback(super.encapsulateReturnResult(common.int.FAILURE));
HiLog.e(TAG, 'searchSmsMessageByContent, error: ' + JSON.stringify(error));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
@ -171,53 +166,45 @@ export default class ConversationModel extends BaseModel {
}
dealBaseColumsData(result, resultSet) {
result.msgId = resultSet.getString(0);
result.receiverNumber = resultSet.getString(1);
result.senderNumber = resultSet.getString(2);
result.startTime = resultSet.getString(3);
result.endTime = resultSet.getString(4);
result.msgType = resultSet.getString(5);
result.smsType = resultSet.getString(6);
result.msgTitle = resultSet.getString(7);
result.msgContent = resultSet.getString(8);
result.msgState = resultSet.getString(9);
result.msgId = resultSet.getString(resultSet.getColumnIndex("msg_id"));
result.receiverNumber = resultSet.getString(resultSet.getColumnIndex("receiver_number"));
result.senderNumber = resultSet.getString(resultSet.getColumnIndex("sender_number"));
result.startTime = resultSet.getString(resultSet.getColumnIndex("start_time"));
result.endTime = resultSet.getString(resultSet.getColumnIndex("end_time"));
result.msgType = resultSet.getString(resultSet.getColumnIndex("msg_type"));
result.smsType = resultSet.getString(resultSet.getColumnIndex("sms_type"));
result.msgTitle = resultSet.getString(resultSet.getColumnIndex("msg_title"));
result.msgContent = resultSet.getString(resultSet.getColumnIndex("msg_content"));
result.msgState = resultSet.getString(resultSet.getColumnIndex("msg_state"));
}
async insertMessageDetail(actionData, callback) {
let featureAbility = actionData.featureAbility;
var dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
HiLog.i(TAG, 'insertMessageDetail, start')
let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(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 => {
mmsLog.info(TAG + 'insertMessageDetail, success:' + data);
callback(super.encapsulateReturnResult(common.int.SUCCESS, data));
HiLog.d(TAG, 'insertMessageDetail, success: ' + JSON.stringify(data));
callback(this.encapsulateReturnResult(common.int.SUCCESS, data));
}).catch(error => {
mmsLog.info(TAG + 'insertMessageDetail fail:' + error);
HiLog.e(TAG, 'insertMessageDetail, fail: ' + JSON.stringify(error));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
async updateLock(actionData, callback) {
mmsLog.info(TAG + 'updateLock , actionData = ' + actionData);
let featureAbility = actionData.featureAbility;
var dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
var groupIds = this.groupIdToString(actionData.groupIds);
let ohosDataAbility = actionData.ohosDataAbility;
var condition = new ohosDataAbility.DataAbilityPredicates();
var condition = new dataAbility.DataAbilityPredicates();
condition.in(mmsTable.messageInfo.groupId, groupIds);
var stringValue = {
'is_lock': actionData.hasLock,
};
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.update(managerUri, stringValue, condition).then((data) => {
mmsLog.info(TAG + 'updateLock success! data = ' + data);
callback(super.encapsulateReturnCode(common.int.SUCCESS));
callback(this.encapsulateReturnCode(common.int.SUCCESS));
}).catch((err) => {
mmsLog.info(TAG + 'updateLock err = ' + err);
mmsLog.info(TAG + 'updateLock err = ' + JSON.stringify(err));
callback(super.encapsulateReturnCode(common.int.FAILURE));
HiLog.e(TAG, 'updateLock, err: ' + JSON.stringify(err));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
@ -230,295 +217,241 @@ export default class ConversationModel extends BaseModel {
}
async updateCollect(actionData, callback) {
mmsLog.info(TAG + 'updateCollect , actionData = ' + actionData);
let featureAbility = actionData.featureAbility;
var dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
var groupIds = this.groupIdToString(actionData.groupIds);
let ohosDataAbility = actionData.ohosDataAbility;
var condition = new ohosDataAbility.DataAbilityPredicates();
var condition = new dataAbility.DataAbilityPredicates();
condition.in(mmsTable.messageInfo.groupId, groupIds);
var stringValue = {
'is_collect': actionData.hasCollect,
};
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.update(managerUri, stringValue, condition).then((data) => {
mmsLog.info(TAG + 'updateCollect success! data = ' + data);
callback(super.encapsulateReturnCode(common.int.SUCCESS));
callback(this.encapsulateReturnCode(common.int.SUCCESS));
}).catch((err) => {
mmsLog.info(TAG + 'updateCollect err = ' + err);
mmsLog.info(TAG + 'updateCollect err = ' + JSON.stringify(err));
callback(super.encapsulateReturnCode(common.int.FAILURE));
HiLog.e(TAG, 'updateCollect, err: ' + JSON.stringify(err));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
async deleteMessageByIds(actionData) {
mmsLog.info(TAG + 'deleteMessage, actionData :' + actionData);
let featureAbility = actionData.featureAbility;
var dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
var msgIds = actionData.msgIds;
let ohosDataAbility = actionData.ohosDataAbility;
var condition = new ohosDataAbility.DataAbilityPredicates();
var condition = new dataAbility.DataAbilityPredicates();
condition.in(mmsTable.messageInfo.msgId, msgIds);
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.delete(managerUri, condition);
}
async deleteMessageByGroupIds(actionData) {
mmsLog.info(TAG + 'deleteMessage by group id, actionData :' + actionData);
let featureAbility = actionData.featureAbility;
var dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
var groupIds = this.groupIdToString(actionData.groupIds);
let ohosDataAbility = actionData.ohosDataAbility;
var condition = new ohosDataAbility.DataAbilityPredicates();
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) => {
mmsLog.info(TAG + 'deleteMessageByGroupIds success! data = ' + data);
}).catch((err) => {
mmsLog.info(TAG + 'deleteMessageByGroupIds err = ' + err);
HiLog.e(TAG, 'deleteMessageByGroupIds, err: ' + JSON.stringify(err));
});
}
async deleteMessageBySessionIds(actionData) {
mmsLog.info(TAG + 'deleteMessageBySessionIds, threadIds :' + actionData.threadIds);
let featureAbility = actionData.featureAbility;
var dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
let threadIds = [];
for (let id of actionData.threadIds) {
let threadId = id + common.string.EMPTY_STR;
threadIds.push(threadId);
}
let ohosDataAbility = actionData.ohosDataAbility;
var condition = new ohosDataAbility.DataAbilityPredicates();
var condition = new dataAbility.DataAbilityPredicates();
condition.in(mmsTable.messageInfo.sessionId, threadIds);
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.delete(managerUri, condition).then((data) => {
mmsLog.info(TAG + 'deleteMessageBySessionIds success! data = ' + data);
}).catch((err) => {
mmsLog.info(TAG + 'deleteMessageBySessionIds err = ' + err);
HiLog.e(TAG, 'deleteMessageBySessionIds, err: ' + JSON.stringify(err));
});
}
async deleteMessageBySessionIdsAndLock(actionData) {
mmsLog.info(TAG + 'deleteMessageBySessionIdsAndLock, threadIds:' + actionData);
let featureAbility = actionData.featureAbility;
let dataAbilityHelper = await featureAbility.getDataAbilityHelper(common.string.URI_MESSAGE_LOG);
let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
let threadIds = this.groupIdToString(actionData.threadIds);
let ohosDataAbility = actionData.ohosDataAbility;
var condition = new ohosDataAbility.DataAbilityPredicates();
var condition = new dataAbility.DataAbilityPredicates();
condition.equalTo(mmsTable.messageInfo.isLock, actionData.hasLock);
condition.in(mmsTable.messageInfo.sessionId, threadIds);
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.delete(managerUri, condition).then((data) => {
mmsLog.info(TAG + 'deleteMessageBySessionIdsAndLock success! data = ' + data);
}).catch((err) => {
mmsLog.info(TAG + 'deleteMessageBySessionIdsAndLock err = ' + err);
HiLog.e(TAG, 'deleteMessageBySessionIdsAndLock, err: ' + JSON.stringify(err));
});
}
async updateById(actionData, callback) {
mmsLog.info(TAG + 'updateById , actionData = ' + actionData);
let featureAbility = actionData.featureAbility;
var dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
var msgId = actionData.msgId;
let ohosDataAbility = actionData.ohosDataAbility;
var condition = new ohosDataAbility.DataAbilityPredicates();
var condition = new dataAbility.DataAbilityPredicates();
condition.equalTo(mmsTable.messageInfo.msgId, msgId);
var stringValue = {
'msg_state': actionData.sendStatus,
};
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.update(managerUri, stringValue, condition).then((data) => {
mmsLog.info(TAG + 'updateById success! data = ' + data);
callback(super.encapsulateReturnCode(common.int.SUCCESS));
HiLog.i(TAG, 'updateById, end');
callback(this.encapsulateReturnCode(common.int.SUCCESS));
}).catch((err) => {
mmsLog.info(TAG + 'updateById err = ' + err);
mmsLog.info(TAG + 'updateById err = ' + JSON.stringify(err));
callback(super.encapsulateReturnCode(common.int.FAILURE));
HiLog.e(TAG, 'updateById, err: ' + JSON.stringify(err));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
async markAllAsRead(actionData) {
let featureAbility = actionData.featureAbility;
var dataAbilityHelper = featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
let threadIds = [];
for (let id of actionData.threadIds) {
let threadId = id + common.string.EMPTY_STR;
threadIds.push(threadId);
}
let ohosDataAbility = actionData.ohosDataAbility;
var condition = new ohosDataAbility.DataAbilityPredicates();
var condition = new dataAbility.DataAbilityPredicates();
condition.in(mmsTable.messageInfo.sessionId, threadIds);
var stringValue = {
'is_read': actionData.hasRead
};
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
dataAbilityHelper.update(managerUri, stringValue, condition).then((data) => {
mmsLog.info(TAG + 'markAllAsRead success! data = ' + data);
}).catch((err) => {
mmsLog.info(TAG + 'markAllAsRead err = ' + err);
HiLog.e(TAG, 'markAllAsRead, err: ' + JSON.stringify(err));
});
}
markAllToRead(actionData) {
let featureAbility = actionData.featureAbility;
var dataAbilityHelper = featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
let ohosDataAbility = actionData.ohosDataAbility;
var condition = new ohosDataAbility.DataAbilityPredicates();
async markAllToRead(actionData) {
var condition = new dataAbility.DataAbilityPredicates();
condition.equalTo(mmsTable.messageInfo.isRead, 0);
condition.equalTo(mmsTable.messageInfo.smsType, actionData.smsType);
var stringValue = {
'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);
dataAbilityHelper.update(managerUri, stringValue, condition).then((data) => {
mmsLog.info(TAG + 'markAllToRead success! data = ' + data);
}).catch((err) => {
mmsLog.info(TAG + 'markAllToRead err = ' + err);
HiLog.e(TAG, 'markAllToRead, err: ' + JSON.stringify(err));
});
}
async queryMaxGroupId(actionData, callback) {
mmsLog.info(TAG + 'queryMaxGroupId start:' + actionData);
let featureAbility = actionData.featureAbility;
let dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
let resultColumns = [
'maxGroupId'
];
let ohosDataAbility = actionData.ohosDataAbility;
let condition = new ohosDataAbility.DataAbilityPredicates();
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);
dataAbilityHelper.query(managerUri, resultColumns, condition, (err, resultSet) => {
let result = {};
HiLog.i(TAG, 'queryMaxGroupId, query callback');
let result: LooseObject = {};
while (resultSet.goToNextRow()) {
result.maxGroupId = resultSet.getString(0);
mmsLog.info(TAG + 'queryMaxGroupId result = ' + result);
HiLog.d(TAG, 'queryMaxGroupId, maxGroupId=' + result.maxGroupId);
}
callback(super.encapsulateReturnResult(common.int.SUCCESS, result));
callback(this.encapsulateReturnResult(common.int.SUCCESS, result));
});
}
saveImage(actionData, callback) {
var savedImageInfo = morkDataModel.saveImage();
callback(super.encapsulateReturnResult(common.int.SUCCESS, savedImageInfo));
callback(this.encapsulateReturnResult(common.int.SUCCESS, savedImageInfo));
}
gotoShare(actionData, callback) {
callback(super.encapsulateReturnCode(common.int.SUCCESS));
callback(this.encapsulateReturnCode(common.int.SUCCESS));
}
queryFromGallery(actionData, callback) {
var pictureListFromGallery = morkDataModel.queryFromGallery();
callback(super.encapsulateReturnResult(common.int.SUCCESS, pictureListFromGallery));
callback(this.encapsulateReturnResult(common.int.SUCCESS, pictureListFromGallery));
}
dealContractsTransmit(actionData, callback) {
callback(super.encapsulateReturnCode(common.int.SUCCESS));
callback(this.encapsulateReturnCode(common.int.SUCCESS));
}
async queryMessageThirty(actionData, callback) {
let timestamp = new Date().getTime();
let lastTime = timestamp - 2592000000;
let ohosDataAbility = actionData.ohosDataAbility;
let featureAbility = actionData.featureAbility;
let dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
let resultColumns = [
mmsTable.messageInfo.msgId,
mmsTable.messageInfo.sessionId
];
let condition = new ohosDataAbility.DataAbilityPredicates();
let condition = new dataAbility.DataAbilityPredicates();
condition.lessThan(mmsTable.messageInfo.endTime, lastTime);
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);
dataAbilityHelper.query(managerUri, resultColumns, condition).then((resultSet) => {
let mmsList = [];
while (resultSet.goToNextRow()) {
let item = {};
let item: LooseObject = {};
item.msgId = resultSet.getString(0);
item.sessionId = resultSet.getString(1);
mmsList.push(item);
}
callback(super.encapsulateReturnResult(common.int.SUCCESS, mmsList));
callback(this.encapsulateReturnResult(common.int.SUCCESS, mmsList));
}).catch((err) => {
mmsLog.info(TAG + 'queryMessageThirty err = ' + err);
callback(super.encapsulateReturnCode(common.int.FAILURE));
HiLog.e(TAG, 'queryMessageThirty, err: ' + JSON.stringify(err));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
statisticsUnreadNotify(actionData, callback) {
let featureAbility = actionData.featureAbility;
var dataAbilityHelper = featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
let ohosDataAbility = actionData.ohosDataAbility;
var condition = new ohosDataAbility.DataAbilityPredicates();
async statisticsUnreadNotify(actionData, callback) {
var condition = new dataAbility.DataAbilityPredicates();
condition.equalTo(mmsTable.messageInfo.isRead, 0);
condition.equalTo(mmsTable.messageInfo.smsType, 1);
let resultColumns = [
mmsTable.messageInfo.msgId
];
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_INFO_TABLE;
let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
dataAbilityHelper.query(managerUri, resultColumns, condition).then((resultSet) => {
let count = 0;
while (resultSet.goToNextRow()) {
count++;
}
callback(super.encapsulateReturnResult(common.int.SUCCESS, count));
callback(this.encapsulateReturnResult(common.int.SUCCESS, count));
}).catch((err) => {
mmsLog.info(TAG + 'statisticsUnreadNotify err = ' + err);
callback(super.encapsulateReturnCode(common.int.FAILURE));
HiLog.e(TAG, 'statisticsUnreadNotify, err: ' + JSON.stringify(err));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
async searchMmsPartByContent(actionData, callback) {
mmsLog.info(TAG + 'searchMmsPartByContent param:' + actionData);
let featureAbility = actionData.featureAbility;
var dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
let ohosDataAbility = actionData.ohosDataAbility;
let resultColumns = this.buildMmsPartResultColumns();
let condition = new ohosDataAbility.DataAbilityPredicates();
let condition = new dataAbility.DataAbilityPredicates();
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);
dataAbilityHelper.query(managerUri, resultColumns, condition).then(resultSet => {
let resultList = this.dealMmsPartResult(resultSet);
callback(super.encapsulateReturnResult(common.int.SUCCESS, resultList));
callback(this.encapsulateReturnResult(common.int.SUCCESS, resultList));
}).catch(error => {
mmsLog.info(TAG + 'searchMmsPartByContent error:' + error);
callback(super.encapsulateReturnResult(common.int.FAILURE));
HiLog.e(TAG, 'searchMmsPartByContent, error: ' + JSON.stringify(error));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
async queryMmsPart(actionData, callback) {
mmsLog.log(TAG + 'queryMmsPart param:' + actionData);
let featureAbility = actionData.featureAbility;
let dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
var resultColumns = this.buildMmsPartResultColumns();
let ohosDataAbility = actionData.ohosDataAbility;
let condition = new ohosDataAbility.DataAbilityPredicates();
let condition = new dataAbility.DataAbilityPredicates();
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);
dataAbilityHelper.query(managerUri, resultColumns, condition).then(resultSet => {
let resultList = this.dealMmsPartResult(resultSet);
callback(super.encapsulateReturnResult(common.int.SUCCESS, resultList));
callback(this.encapsulateReturnResult(common.int.SUCCESS, resultList));
}).catch(error => {
mmsLog.log(TAG + 'queryMmsPart error:' + error);
callback(super.encapsulateReturnResult(common.int.FAILURE));
HiLog.e(TAG, 'queryMmsPart, error: ' + JSON.stringify(error));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
@ -539,7 +472,7 @@ export default class ConversationModel extends BaseModel {
dealMmsPartResult(resultSet) {
let resultList = [];
while (resultSet.goToNextRow()) {
let result = {};
let result: LooseObject = {};
result.msgId = resultSet.getString(0);
result.groupId = resultSet.getString(1);
result.type = resultSet.getString(2);
@ -554,85 +487,68 @@ export default class ConversationModel extends BaseModel {
}
async deleteMmsPartByGroupIds(actionData) {
mmsLog.info(TAG + 'deleteMmsPartByGroupIds by group id, actionData :' + actionData);
let featureAbility = actionData.featureAbility;
let dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
let groupIds = this.groupIdToString(actionData.groupIds);
let ohosDataAbility = actionData.ohosDataAbility;
let condition = new ohosDataAbility.DataAbilityPredicates();
let condition = new dataAbility.DataAbilityPredicates();
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);
dataAbilityHelper.delete(managerUri, condition).then((data) => {
mmsLog.info(TAG + 'deleteMmsPartByGroupIds success! data = ' + data);
}).catch((err) => {
mmsLog.info(TAG + 'deleteMmsPartByGroupIds err = ' + err);
HiLog.e(TAG, 'deleteMmsPartByGroupIds, err: ' + JSON.stringify(err));
});
}
async batchInsertMmsPart(actionData, callback) {
for (let stringValue of actionData.bacthmsParts) {
this.insertMmsPart(actionData, stringValue, res => {
mmsLog.info(TAG + 'batchInsertMmsPart, res:' + JSON.stringify(res));
});
}
callback(super.encapsulateReturnCode(common.int.SUCCESS));
callback(this.encapsulateReturnCode(common.int.SUCCESS));
}
async insertMmsPart(actionData, stringValue, callback) {
let featureAbility = actionData.featureAbility;
let dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
let managerUri = common.string.URI_MESSAGE_LOG + common.string.URI_MESSAGE_MMS_PART;
let dataAbilityHelper = await featureAbility.acquireDataAbilityHelper(common.string.URI_MESSAGE_LOG);
dataAbilityHelper.insert(managerUri, stringValue).then(data => {
mmsLog.info(TAG + 'insertMmsPart, success:' + data);
callback(super.encapsulateReturnResult(data, common.int.SUCCESS));
callback(this.encapsulateReturnResult(data, common.int.SUCCESS));
}).catch(error => {
mmsLog.info(TAG + 'insertMmsPart fail:' + error);
callback(super.encapsulateReturnCode(common.int.FAILURE));
HiLog.e(TAG, 'insertMmsPart, error: ' + JSON.stringify(error));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
async queryMessageLockBySessionId(actionData, callback) {
mmsLog.info(TAG + 'queryMessageLockBySessionId param:' + actionData);
let featureAbility = actionData.featureAbility;
let dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
var resultColumns = [mmsTable.messageInfo.isLock];
let ohosDataAbility = actionData.ohosDataAbility;
let condition = new ohosDataAbility.DataAbilityPredicates();
let condition = new dataAbility.DataAbilityPredicates();
let sessionId = actionData.threadId + common.string.EMPTY_STR;
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);
dataAbilityHelper.query(managerUri, resultColumns, condition).then(resultSet => {
let lockStatus = [];
while (resultSet.goToNextRow()) {
let result = {};
let result: LooseObject = {};
result.isLock = resultSet.getString(0);
lockStatus.push(result);
}
callback(super.encapsulateReturnResult(common.int.SUCCESS, lockStatus));
callback(this.encapsulateReturnResult(common.int.SUCCESS, lockStatus));
}).catch(error => {
mmsLog.info(TAG + 'queryMessageLockBySessionId error:' + error);
callback(super.encapsulateReturnResult(common.int.FAILURE));
HiLog.e(TAG, 'queryMessageLockBySessionId, error: ' + JSON.stringify(error));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
async queryGroupIdBySessionId(actionData, callback) {
mmsLog.info(TAG + 'queryGroupIdBySessionId param:' + actionData);
let featureAbility = actionData.featureAbility;
let dataAbilityHelper = await featureAbility.getDataAbilityHelper(
common.string.URI_MESSAGE_LOG
);
var resultColumns = [mmsTable.messageInfo.groupId];
let ohosDataAbility = actionData.ohosDataAbility;
let condition = new ohosDataAbility.DataAbilityPredicates();
let condition = new dataAbility.DataAbilityPredicates();
let threadIds = this.groupIdToString(actionData.threadIds);
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);
dataAbilityHelper.query(managerUri, resultColumns, condition).then(resultSet => {
let groupIds = [];
resultSet.goToFirstRow();
@ -640,10 +556,10 @@ export default class ConversationModel extends BaseModel {
let groupId = resultSet.getString(0);
groupIds.push(groupId);
} while (resultSet.goToNextRow());
callback(super.encapsulateReturnResult(common.int.SUCCESS, groupIds));
callback(this.encapsulateReturnResult(common.int.SUCCESS, groupIds));
}).catch(error => {
mmsLog.info(TAG + 'queryGroupIdBySessionId error:' + error);
callback(super.encapsulateReturnResult(common.int.FAILURE));
HiLog.e(TAG, 'queryGroupIdBySessionId, error: ' + JSON.stringify(error));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
}

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -13,34 +13,36 @@
* limitations under the License.
*/
import BaseModel from '../BaseModel.js';
import common from '../../pages/common_constants.js';
import mmsLog from '../../../default/utils/MmsLog.js';
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.js->';
const TAG = 'SettingModel';
export default class SettingModel extends BaseModel {
setOnSettingValueListener(preferences, callback) {
let data = {};
setOnSettingValueListener(callback) {
let data : LooseObject = {};
data.integrationSwitch = preferences.getValueOfIntegrationSwitch();
data.maliciousWebSwitch = preferences.getValueOfMaliciousWebSwitch();
data.showContactSwitch = preferences.getValueOfShowContactSwitch();
mmsLog.info(TAG + 'setOnSettingValueListener(): data = ' + JSON.stringify(data));
HiLog.i(TAG, 'setOnSettingValueListener, data = ' + JSON.stringify(data));
callback(data);
}
getSettingValue(preferences, callback) {
let settingValues = {};
getSettingValue(callback) {
let settingValues: LooseObject = {};
settingValues.hasAggregate = preferences.getValueOfIntegrationSwitch();
settingValues.isShowContactHeadIcon = preferences.getValueOfShowContactSwitch();
settingValues.recallMessagesFlag = preferences.getValueOfRecallMessageSwitch();
mmsLog.info(TAG + 'getSettingValue(): settingValues = ' + settingValues);
callback(super.encapsulateReturnResult(common.int.SUCCESS, settingValues));
HiLog.i(TAG, 'getSettingValue, settingValues: ' + JSON.stringify(settingValues));
callback(this.encapsulateReturnResult(common.int.SUCCESS, settingValues));
}
getAdvancedPageSwitchValue(preferences, callback) {
let result = {
getAdvancedPageSwitchValue(callback) {
let result: LooseObject = {
deliveryReportSwitch: false,
autoRetrieveMmsSwitch: false,
recallMessageSwitch: false,
@ -67,40 +69,38 @@ export default class SettingModel extends BaseModel {
result.spnNameOfOneSimCard = common.string.EMPTY_STR;
}
}
callback(super.encapsulateReturnResult(common.int.SUCCESS, result));
callback(this.encapsulateReturnResult(common.int.SUCCESS, result));
}
updateSmscNumber(actionData, callback) {
let index = actionData.index - 1;
let newTelNum = actionData.number;
let preferences = actionData.preferences;
mmsLog.log(TAG + 'setSmscAddr actionData:' + actionData);
telephonySMS.setSmscAddr(index, newTelNum, (value) => {
mmsLog.log(TAG + 'setSmscAddr ,value :' + value);
HiLog.i(TAG, 'updateSmscNumber, setSmscAddr, value: ' + 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(super.encapsulateReturnResult(common.int.SUCCESS, common.string.SUCCESS));
callback(this.encapsulateReturnResult(common.int.SUCCESS, common.string.SUCCESS));
}).catch((error) => {
mmsLog.info(TAG + 'setSmscAddr smsNumber: error = ' + error);
callback(super.encapsulateReturnCode(common.int.FAILURE));
HiLog.e(TAG, 'updateSmscNumber, setSmscAddr, error: ' + JSON.stringify(error));
callback(this.encapsulateReturnCode(common.int.FAILURE));
});
}
shareSmsEnterSelectedText(actionData, callback) {
// 分享API目前未提供
callback(super.encapsulateReturnResult(common.int.SUCCESS, common.string.SUCCESS));
callback(this.encapsulateReturnResult(common.int.SUCCESS, common.string.SUCCESS));
}
updateSwitchValue(prefer, keyOfSwitch, valueOfSwitch, callback) {
prefer.setValueForSwitch(keyOfSwitch, valueOfSwitch);
callback(super.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(preferences, callback) {
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);
@ -109,6 +109,6 @@ export default class SettingModel extends BaseModel {
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(super.encapsulateReturnResult(common.int.SUCCESS, common.string.SUCCESS));
callback(this.encapsulateReturnResult(common.int.SUCCESS, common.string.SUCCESS));
}
}

View File

@ -0,0 +1,858 @@
/**
* 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 {Receive} from '../../views/receive/receive'
import LooseObject from '../../data/LooseObject'
import mediaquery from '@ohos.mediaquery'
import observer from '@ohos.telephony.observer';
let portraitFunc = null
@Entry
@Component
export struct Conversation {
@StorageLink('ConversationController') conversationController: ConversationController = ConversationController.getInstance();
/** 短信详情弹框 */
dialogController: CustomDialogController = new CustomDialogController({
builder: DetailsDialog({
item: this.conversationController.mmsList[this.conversationController.mmsIndex],
receiver: this.conversationController.strContactsName == ''
? this.conversationController.strContactsNumber :
this.conversationController.strContactsName
}),
autoCancel: true,
alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: -30 }
})
// 监听横竖屏
listener = mediaquery.matchMediaSync('(orientation: landscape)')
onPortrait(mediaQueryResult) {
if (mediaQueryResult.matches) {
console.log("mediaQuery landScape")
this.sizeType = SizeType.LG
} else {
console.log("mediaQuery vert")
this.sizeType = SizeType.XS
this.columns = 4
this.margin = '12vp'
}
}
private aboutToAppear(): void {
this.onPortrait(this.listener)
portraitFunc = this.onPortrait.bind(this)
this.listener.on('change', portraitFunc)
// 实时监听SIM卡状态
observer.on('simStateChange', data => {
let simState = data.state
if (simState == 0 || simState == 1) {
this.conversationController.haveSimCard = false
} else {
this.conversationController.haveSimCard = true
}
this.conversationController.initSendTip()
});
this.conversationController.onInit()
// 初始化函数
}
private onPageShow(): void {
this.conversationController.onShow()
}
private onBackPress(): void {
this.conversationController.onBackPress()
}
@State columns: number = 12;
@State sizeType: SizeType = SizeType.LG;
@State gutter: string = '24vp';
@State margin: string = '24vp';
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
// <!--上方titleBar-->
// 新建界面
if (this.conversationController.isNewMsg) {
Row() {
Image($rawfile('icon/ic_message_back.svg'))
.width('24vp')
.height('24vp')
.onClick(() => {
// 点击返回恢复到未选中短信状态
this.conversationController.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.conversationController.isSelectStatus) {
Row() {
Image($rawfile('icon/ic_cancel_black.svg'))
.width(24)
.height(24)
.onClick(() => {
// 点击返回恢复到未选中短信状态
this.conversationController.titleBarCancel()
})
Text(this.conversationController.selectDeleteMsgCount == 0 ? $r("app.string.msg_unselected_tip") : $r("app.string.msg_selected_tip", this.conversationController.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.conversationController.titleBarBack()
})
Image($rawfile('icon/user_avatar_full_fill.svg'))
.width(40)
.height(40)
.margin({ left: 16 })
.onClick(() => {
this.conversationController.titleBarAvatar();
})
}
.flexBasis(80)
Column() {
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Center,
alignItems: ItemAlign.Start
}) {
if (this.conversationController.contactsNum > 1) {
Text(this.conversationController.strContactsName).fontSize(16).fontColor($r('app.color.main_font_color'))
Text($r("app.string.members", this.conversationController.contactsNum)).fontSize(14).fontColor($r('app.color.main_font_color_40'))
} else if (this.conversationController.strContactsName == '' || this.conversationController.strContactsName == null) {
Text(this.conversationController.strContactsNumberFormat).fontSize(16).fontColor($r('app.color.main_font_color'))
} else {
Text(this.conversationController.strContactsName).fontSize(16).fontColor($r('app.color.main_font_color'))
Text(this.conversationController.strContactsNumberFormat).fontSize(14).fontColor($r('app.color.main_font_color_40'))
}
}
}
.flexGrow(1)
.alignItems(HorizontalAlign.Start)
.padding({ left: 16 })
Row() {
Image($rawfile('icon/ic_message_phone.svg'))
.width(24)
.height(24)
.onClick(() => {
this.conversationController.clickCall();
})
Image($rawfile('icon/ic_message_more1.svg'))
.width(24)
.height(24)
.margin({ left: 16 })
.bindMenu([
{
// @ts-ignore
value: $r("app.string.delete"),
action: () => {
this.conversationController.longPressMore(0);
}
},
// {
// // @ts-ignore
// value: $r("app.string.msg_new_contact"),
// action: () => {
// this.conversationController.longPressMore(1);
// }
// },
// {
// // @ts-ignore
// value: $r("app.string.msg_save_to_an_existing_contact"),
// action: () => {
// this.conversationController.longPressMore(2);
// }
// },
// {
// // @ts-ignore
// value: $r("app.string.msg_pre_call_editor"),
// action: () => {
// this.conversationController.longPressMore(3);
// }
// },
// {
// // @ts-ignore
// value: $r("app.string.msg_blacklist"),
// action: () => {
//
// }
// }
])
}
.flexBasis(64)
}.height('100%')
}
.width('100%')
}
}
.height(56)
.constraintSize({ minHeight: 56 })
.padding({left: 24, right: 24 })
.zIndex(2)
}
// <!--中间内容区域-->
Row() {
// 新建消息内容
if (this.conversationController.isNewMsg) {
Row() {
Receive()
}.margin({ top: 8 })
}
// 短信内容
// <!--信息列表-->
if (!this.conversationController.isNewMsg) {
List({ space: 10, initialIndex: this.conversationController.mmsList.length - 1 }) {
ForEach(this.conversationController.mmsList, (item, index) => {
ListItem() {
Column() {
GridContainer({
columns: this.columns,
sizeType: this.sizeType,
gutter: this.gutter,
margin: this.margin
}) {
// <!--发信息Item-->
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 (!this.conversationController.mmsDateSet.has(item.date.id) &&
this.conversationController.mmsDateSet.add(item.date.id)) {
Text(item.date).fontSize(12).lineHeight(16).fontColor($r('app.color.main_font_color_60')).margin({ bottom: 8 })
}
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Column() {
// if (this.conversationController.isSelectStatus == false && item.isShowMsgLongMenu) {
// menu({
//// controller: this.conversationController,
// index: index,
// isSender: true
// })
// }
Flex({
justifyContent: FlexAlign.End,
alignItems: ItemAlign.End
}) {
// <!--文本-->
Flex({
justifyContent: FlexAlign.End,
alignItems: ItemAlign.End
}) {
// <!--发送失败icon-->
if (!item.isMsm && ((this.conversationController.contactsNum == 1 && item.sendStatus == 2) || (this.conversationController.contactsNum > 1 && item.failuresNumber > 0 && item.completeNumber == this.conversationController.contactsNum))) {
Row() {
Image($rawfile('icon/ic_send_fail.svg'))
.width(24)
.height(24)
}
.flexBasis(35)
.padding({ top: 9 })
}
// 消息气泡
bubbleText({
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.conversationController.contactsNum == 1 && item.sendStatus != 1) {
Text(item.time).textAlign(TextAlign.Start).fontSize(10).lineHeight(13).fontColor($r('app.color.main_font_color_60')).margin({ top: 8, right: 5 })
}
// 卡1还是卡2
if (this.conversationController.cardImage) {
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.conversationController.contactsNum > 1 ? Visibility.Visible : Visibility.None)
// <!--信息checkbox-->
Toggle({ type: ToggleType.Checkbox, isOn: item.isCbChecked })
.width(20)
.height(20)
.visibility(this.conversationController.isSelectStatus ? Visibility.Visible : Visibility.None)
.onChange(((isOn: boolean) => {
this.conversationController.listCheckBoxChange(index, isOn)
}))
}
.useSizeType({
xs: { span: 4, offset: 0 }, sm: { span: 8, offset: 2 },
md: { span: 8, offset: 2 }, lg: { span: 8, offset: 2 }
})
}
.width('100%')
.useSizeType({
xs: { span: 4, offset: 0 }, sm: { span: 12, offset: 0 },
md: { span: 12, offset: 0 }, lg: { span: 12, offset: 0 }
})
}
// <!--收信息Item-->
else if (item.isReceive) {
// <!--收信息Item-->
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 (!this.conversationController.mmsDateSet.has(item.date.id) &&
this.conversationController.mmsDateSet.add(item.date.id)) {
Text(item.date).fontSize(12).lineHeight(16).fontColor($r('app.color.main_font_color_60')).margin({ bottom: 8 })
}
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Column() {
// if (this.conversationController.isSelectStatus == false && item.isShowMsgLongMenu) {
// menu({
//// controller: this.conversationController,
// index: index,
// isSender: false
// })
// }
Flex({ alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
// 消息气泡
bubbleText({
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: 8, offset: 0 },
md: { span: 8, offset: 0 }, lg: { span: 8, offset: 0 }
})
// <!--发送时间、发送状态那行-->
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
Text(item.time).textAlign(TextAlign.Start).fontSize(10).lineHeight(13).fontColor($r('app.color.main_font_color_60')).margin({ top: 8, right: 5 })
// 卡1还是卡2
if (this.conversationController.cardImage) {
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)
Toggle({ type: ToggleType.Checkbox, isOn: item.isCbChecked })
.width(20)
.height(20)
.visibility(this.conversationController.isSelectStatus ? Visibility.Visible : Visibility.None)
.onChange(((isOn: boolean) => {
this.conversationController.listCheckBoxChange(index, isOn)
}))
}
}.width('100%')
.useSizeType({
xs: { span: 4, offset: 0 }, sm: { span: 12, offset: 0 },
md: { span: 12, offset: 0 }, lg: { span: 12, offset: 0 }
})
}
}
}
}.onClick(() => {
if (this.conversationController.isSelectStatus) {
this.conversationController.listCheckBoxChange(index,!item.isCbChecked)
}
})
// .padding({ left: 24, right: 24 })
}, item => item.id)
}
.listDirection(Axis.Vertical) // 排列方向
.edgeEffect(EdgeEffect.Spring) // 滑动到边缘无效果
.width('100%')
}
}
.width('100%')
.flexBasis('auto')
}
.width('100%')
// <!--底部输入框-->
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
// <!--底部更多选项 -->
if (this.conversationController.isSelectStatus && !this.conversationController.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_delete_m.svg'))
.width(24)
.height(24)
Text($r("app.string.delete")).fontSize(10).margin({ top: 3 }).fontColor($r('app.color.main_font_color'))
}.width('25%').opacity(this.conversationController.selectDeleteMsgCount == 0 ? 0.4 : 1)
.onClick(() => {
if (this.conversationController.selectDeleteMsgCount != 0) {
this.conversationController.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.conversationController.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.conversationController.selectDeleteMsgCount == 0 ? 0.4 : 1)
.onClick(() => {
})
/** 全选 */
Flex({ direction: FlexDirection.Column,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Center }) {
Image(this.conversationController.isMessageCheckAll ? $rawfile('icon/ic_select_all_filled.svg') : $rawfile('icon/ic_select_all.svg'))
.width(24)
.height(24)
Text(this.conversationController.isMessageCheckAll ? $r("app.string.msg_deselect_all") : $r("app.string.msg_select_all")) {
}.fontSize(10).margin({ top: 3 }).fontColor($r('app.color.main_font_color'))
}.width('25%')
.onClick(() => {
this.conversationController.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.conversationController.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.conversationController.isSelectStatus = !this.conversationController.isSelectStatus
this.conversationController.isMessageCheckAll = false
this.conversationController.cancleCheckedAll()
}
},
this.conversationController.hasReport ? {
value: $r("app.string.query_report"),
action: () => {
this.conversationController.moreSelected(6)
}
} : {}
] : [{}
// {
// value: $r("app.string.msg_copy"),
// action: () => {
//
// }
// },
// {
// value: $r("app.string.lock"),
// action: () => {
// }
// }
]
)
}
.width('100%')
.height(56)
}
// <!--底部发送栏-->
if (!this.conversationController.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.None)
// <!--输入框-->
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Flex({ alignItems: ItemAlign.Center }) {
Image(this.conversationController.slotId == 0 ? $rawfile('icon/ic_message_card1.svg') : $rawfile('icon/ic_message_card2.svg'))
.width(22)
.height(22)
Image($rawfile('icon/icon_down.svg'))
.width(16)
.height(22)
}
.flexBasis(36)
.visibility(this.conversationController.cardImage ? Visibility.Visible : Visibility.None)
Flex() {
TextArea({
placeholder: $r("app.string.msg_note_mms"),
text: this.conversationController.textValue
})
.placeholderColor($r('app.color.placeholder_color'))
.caretColor($r('app.color.control_activated_color'))
.backgroundColor($r('app.color.default_main_background'))
.borderRadius(20)
.onChange(value => {
this.conversationController.changeValue(value);
})
}.flexGrow(1).constraintSize({ minHeight: 40, maxHeight: 584 })
}
.backgroundColor($r('app.color.default_main_background'))
.padding({ left: 8, right: 8 })
.borderRadius(20)
.flexBasis('auto')
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.None)
// <!--发送-->
Flex({
direction: FlexDirection.Row,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Start
}) {
// Text((this.conversationController.textValue.length !=0 || this.conversationController.isEditMms)
// ? this.conversationController.msgSendTip : '').fontSize(12)
Flex() {
Image(this.conversationController.canSendMessage ? $rawfile('icon/ic_message_send_filled.svg') : $rawfile('icon/ic_message_send.svg'))
.onClick(() => {
// 点击发送按钮
this.conversationController.send()
})
.width(24)
.height(24)
.opacity(this.conversationController.canSendMessage ? 1 : 0.4)
.margin({ bottom: 16 })
}
}
.flexBasis('40')
}
.constraintSize({ minHeight: 72 })
.width('100%').padding({ bottom: 16, top: 8 })
}
}
.width('100%')
.padding({ left: 24, right: 24 })
.backgroundColor($r("app.color.white"))
}
.backgroundColor($r("app.color.default_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 {
@StorageLink('ConversationController') controller: ConversationController = ConversationController.getInstance();
private borderRadius: Array<number>; // 圆角大小,共两个参数
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.msg_copy"))
// .fontSize(14)
// .fontColor(Color.Black)
// .backgroundColor($r("app.color.white"))
// Button($r("app.string.msg_transmit"))
// .fontSize(14)
// .fontColor(Color.Black)
// .backgroundColor($r("app.color.white"))
Button($r("app.string.delete"))
.fontSize(14)
.fontColor(Color.Black)
.backgroundColor($r("app.color.white"))
.onClick(() => {
this.controller.longPressSelected(2)
this.showMenu = false
})
// Button($r("app.string.msg_select_text"))
// .fontSize(12)
// .fontColor(Color.Black)
// .backgroundColor($r("app.color.white"))
Button($r("app.string.more"))
.fontSize(14)
.fontColor(Color.Black)
.backgroundColor($r("app.color.white"))
.onClick(() => {
this.controller.longPressSelected(4)
this.showMenu = false
})
}
.height(40)
// .padding(10)
.borderRadius(20)
.backgroundColor($r("app.color.white"))
}
build() {
Row() {
Stack({ alignContent: this.direction == 'left' ? Alignment.TopStart : Alignment.TopEnd }) {
Text()
.backgroundColor(this.backgroundColor)
.borderRadius(this.borderRadius[0])
.width(24)
.height(24)
.visibility(this.content ? Visibility.Visible : Visibility.None)
Text(this.content)
.fontSize(16)
.lineHeight(21)
.padding({ left: 12, right: 12, top: 8, bottom: 8 })
.backgroundColor(this.backgroundColor)
.borderRadius(this.borderRadius[1])
.fontColor($r('app.color.main_font_color'))
}
}
.flexBasis('auto')
.gesture(
LongPressGesture({ repeat: false, duration: 500 })
//长按动作存在会连续触发
.onAction(() => {
if (!this.controller.isSelectStatus) {
this.controller.mmsListLongPress(this.itemIndex)
this.showMenu = true
}
})
)
.bindPopup(this.showMenu, {
builder: this.MenuBuilder,
placement: this.direction == 'left' ? Placement.TopRight : Placement.TopLeft,
maskColor: 0x33000000,
popupColor: Color.White,
enableArrow: false,
onStateChange: (e) => {
if (!e.isVisible) {
this.showMenu = false
}
}
})
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,77 @@
/**
* 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')
}
}
}

View File

@ -0,0 +1,362 @@
/**
* 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 prompt from '@system.prompt';
import router from '@system.router';
import ConListController from './conversationListController'
import common from '../../data/commonData'
import {DeleteDialog} from '../../views/MmsDialogs';
import {MmsListItem} from '../../views/MmsListItem';
import {SearchResultPage} from './SearchResultPage';
import LooseObject from '../../data/LooseObject';
@Entry
@Component
struct ConversationList {
@StorageLink('ConListController') mConListCtrl: ConListController = ConListController.getInstance();
delDialogController: CustomDialogController = new CustomDialogController({
builder: DeleteDialog({
cancel: () => {
this.mConListCtrl.deleteDialogCancel()
},
confirm: () => {
this.mConListCtrl.deleteDialogConfirm()
},
msg: this.mConListCtrl.strMsgDeleteDialogTip,
hasLockMsg: this.mConListCtrl.hasLockMsg,
setSelectLock: () => {
this.mConListCtrl.setSelectLock()
},
isSelectLockMsg: this.mConListCtrl.isSelectLockMsg,
setSelectLockChange: (isOn: boolean) => {
this.mConListCtrl.setSelectLockChange(isOn)
}
}),
autoCancel: false,
alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: '-20vp' }
})
@State isSMSReceiving: boolean = false
@State smsReceiving: boolean = false
build() {
Column() {
Row() {
Image($rawfile('icon/ic_cancel_black.svg')).height('24vp').width('24vp')
.onClick(() => {
this.mConListCtrl.onBackPress()
})
.visibility(this.mConListCtrl.isMultipleSelectState
? Visibility.Visible : Visibility.None)
Blank()
Image($rawfile('icon/add_2.svg'))
.width($r('app.float.icon_side_length_medium'))
.height($r('app.float.icon_side_length_medium'))
.onClick(() => {
// 跳转新建短信界面
router.push(
{
uri: 'pages/conversation/conversation',
params: {
isNewMsg: true
}
})
}).visibility(this.mConListCtrl.isMultipleSelectState
? Visibility.Hidden : Visibility.Visible)
Image($rawfile('icon/ic_public_more.svg'))
.width($r('app.float.icon_side_length_medium'))
.height($r('app.float.icon_side_length_medium'))
.onClick(() => {
})
.visibility(this.mConListCtrl.isMultipleSelectState
? Visibility.Hidden : Visibility.Visible)
.margin({ right: $r('app.float.action_bar_space'), left: $r('app.float.action_bar_space') })
.bindMenu([
{ //this.mConListCtrl.messageList.length == 0
// @ts-ignore
value: $r("app.string.delete"),
action: () => {
this.mConListCtrl.isMultipleSelectState = true
this.mConListCtrl.setConversationCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN)
}
},
{
// @ts-ignore
value: $r("app.string.favorites"),
action: () => {
this.mConListCtrl.jumpToFavoritesPage();
}
},
{
// @ts-ignore
value: $r("app.string.blocked"),
action: () => {
}
},
{
// @ts-ignore
value: $r("app.string.markAllAsRead"),
action: () => {
this.mConListCtrl.clickToMarkAllAsRead()
}
},
{
// @ts-ignore
value: $r("app.string.settings"),
action: () => {
this.mConListCtrl.jumpToSettingsPage()
}
},
])
}
.width('100%')
.height($r('app.float.action_bar_height'))
.padding({ left: $r('app.float.settings_item_padding_left') })
Row() {
Text($r("app.string.messages"))
.fontSize($r('app.float.list_title_font_size_large'))
.fontColor('#182431')
.fontWeight(FontWeight.Bold)
.visibility(this.mConListCtrl.isMultipleSelectState
? Visibility.None : Visibility.Visible)
Text(this.mConListCtrl.conversationSelectedNumber === 0 ?
$r("app.string.msg_unselected_tip") : $r("app.string.msg_selected_tip", this.mConListCtrl.conversationSelectedNumber))
.fontSize('30fp')
.fontColor(Color.Black)
.visibility(this.mConListCtrl.isMultipleSelectState
? Visibility.Visible : Visibility.None)
}
.width('100%')
.height('56vp')
.padding({ left: '24vp' })
if (this.mConListCtrl.messageList.length != 0) {
//搜索框
// @ts-ignore
Search({ value: this.mConListCtrl.inputValueOfSearch, placeholder: $r("app.string.search2") })
.visibility(Visibility.None)
.height('40vp')
.border({ radius: '20vp' })
// .focusable(this.mInfoMsgCtrl.isSearchFocusable)
.enabled(!this.mConListCtrl.isMultipleSelectState)
.margin({ left: '24vp', right: '24vp', top: '8vp', bottom: '8vp' })
.backgroundColor($r("app.color.search_input_background"))
// .onChange((value: string) => {
//// this.mConListCtrl.clickToSearch(value);
// })
// .onTouch((event: TouchEvent) => {
// if (event.type === TouchType.Down) {
//// this.mConListCtrl.searchTouchStart(true, event)
// }
// })
}
Column() {
List() {
if (this.mConListCtrl.hasAggregate && this.mConListCtrl.showInfoDivWhenSearchFlag
&& this.mConListCtrl.isSearchStatus) {
ListItem() {
Column() {
Row() {
if (this.mConListCtrl.unreadTotalOfInfo <= 0) {
Image($rawfile('icon/entrance_icon01.svg'))
.clip(Circle)
.width('40vp')
.height('40vp')
} else {
Badge({
count: this.mConListCtrl.unreadTotalOfInfo,
maxCount: 99,
style: { color: 0xFFFFFF, fontSize: '10', badgeSize: '16', badgeColor: Color.Red }
}) {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile('icon/entrance_icon01.svg'))
.clip(Circle)
.width('40vp')
.height('40vp')
}.width('100%')
.height('100%')
}.width('40vp').height('40vp')
}
Column() {
Row() {
Text($r("app.string.infoMessages"))
.fontSize('16fp')
.fontColor(Color.Black)
Blank()
if (this.mConListCtrl.unreadTotalOfInfo > 0) {
Text(this.mConListCtrl.unreadTotalOfInfo + '')
.fontSize('12fp')
.fontColor(Color.Black)
.height('64vp')
.width('64vp')
}
}.width('100%')
.height('100%')
.margin({ left: '4vp' })
if (this.mConListCtrl.messageList.length > 0) {
Divider().vertical(false).color(Color.Black).height('1vp')
}
}.layoutWeight(1)
.height('100%')
.padding({ left: '12vp' })
}.height('64vp')
.width('100%')
.padding({ left: '24vp', right: '24vp' })
.onClick(() => {
this.mConListCtrl.clickToInfoMessages()
})
}
}
}
ForEach(this.mConListCtrl.messageList, (item: any, index: number) => {
ListItem() {
MmsListItem({
item: item,
index: index,
isShowHead: this.mConListCtrl.isShowContactHeadIcon,
isMultipleSelectState: this.mConListCtrl.isMultipleSelectState,
onClickHead: (event: ClickEvent) => {
this.mConListCtrl.clickToGroupDetail(index);
},
onClickBody: (event: ClickEvent) => {
this.mConListCtrl.clickInfoToConversation(index);
},
onItemLongPress: (event: GestureEvent) => {
this.mConListCtrl.conversationLongPress(index);
},
onTouchStart: (event: GestureEvent) => {
this.mConListCtrl.touchStart(event, index);
},
onTouchUpdate: (event: GestureEvent) => {
this.mConListCtrl.touchMove(event, index);
},
onTouchEnd: (event: GestureEvent) => {
this.mConListCtrl.touchEnd(event, index);
},
onClickFirstSlipBtn: (event: ClickEvent) => { //已读
this.mConListCtrl.markAllAsReadByIndex(index);
},
onClickSecondSlipBtn: (event: ClickEvent) => { //删除
this.mConListCtrl.deleteAction(index);
this.delDialogController.open();
}
})
}.width('100%')
.height('64vp')
}, (item: any) => item.threadId.toString())
}
.visibility(Visibility.Visible)
.edgeEffect(EdgeEffect.Spring)
.width('100%')
.align(Alignment.Top)
}.layoutWeight(1)
/*底部全选删除按钮*/
Row() {
Column() {
Image($rawfile('icon/ic_delete_m.svg')).height(20).width(20)
Text($r("app.string.delete")).fontSize(10).fontColor(Color.Black)
}.layoutWeight(1).onClick(() => {
this.mConListCtrl.clickConversationDelete()
this.delDialogController.open()
}).enabled(!(this.mConListCtrl.conversationSelectedNumber === 0))
.opacity(this.mConListCtrl.conversationSelectedNumber == 0 ? 0.5 : 1)
Column() {
Image(this.mConListCtrl.isConversationCheckAll ?
$rawfile('icon/ic_select_all_filled.svg') : $rawfile('icon/ic_select_all.svg'))
.height(20).width(20)
Text(this.mConListCtrl.isConversationCheckAll ? $r("app.string.msg_deselect_all")
: $r("app.string.msg_select_all")).fontSize(10)
.fontColor(this.mConListCtrl.isConversationCheckAll ? Color.Blue : Color.Black)
}.layoutWeight(1).onClick(() => {
this.mConListCtrl.clickConversationCheckAll()
})
}.width('100%')
.height(45)
.backgroundColor($r("app.color.white"))
.visibility(this.mConListCtrl.isMultipleSelectState
? Visibility.Visible : Visibility.None)
if (this.mConListCtrl.messageList.length == 0 && !(this.mConListCtrl.hasAggregate && this.mConListCtrl.showInfoDivWhenSearchFlag
&& this.mConListCtrl.isSearchStatus)) {
EmptyView()
}
}
.width('100%')
.height('100%')
.onKeyEvent((event: KeyEvent) => {
if (event.keyCode === 4 && event.keyText === 'Back') { //返回按钮
if (this.mConListCtrl.deleteDialogShow) {
this.delDialogController.close()
this.mConListCtrl.deleteDialogShow = false
event.stopPropagation()
return
}
if (this.mConListCtrl.isMultipleSelectState) {
// @ts-ignore
for (let element of this.mConListCtrl.messageList) {
element.isCbChecked = false;
}
this.mConListCtrl.isMultipleSelectState = false;
event.stopPropagation()
}
if (!this.mConListCtrl.isSearchStatus) {
this.mConListCtrl.backSearch();
event.stopPropagation()
}
}
})
}
aboutToAppear() {
}
aboutToDisappear() {
}
onPageShow() {
this.mConListCtrl.onShow();
}
onPageHide() {
this.mConListCtrl.unSubscribe();
}
}
@Component
struct EmptyView {
build() {
Column() {
Image($rawfile('icon/ic_massage_m.svg'))
.width('160vp')
.height('157vp')
Text($r("app.string.noMessages"))
.margin({ top: '9vp' })
}.height('100%')
.padding({ top: $r('app.float.empty_view_top_padding') })
}
}

View File

@ -0,0 +1,911 @@
/**
* 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 rdbStore from '../../utils/RdbStoreUtil';
import SettingService from '../../service/SettingService'
import commonService from '../../service/CommonService';
import notificationService from '../../service/NotificationService';
import AppStorageUtil from '../../utils/AppStorageUtil';
let ConversationCtrl;
let commonEventData = null;
const TAG = 'ConversationListController';
export default class ConversationListController {
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<any> = [];
//删除弹窗是否显示
deleteDialogShow: boolean = false;
// 如果通知信息整合开关打开,则是非通知信息,如果没有打开,则是所有数据
messageList: Array<any> = [];
// 搜索结果列表
searchResultList: LooseObject = {
sessionList: [],
contentList: []
};
// 搜索结果队列
searchResultListQueue: Array<any> = [];
// 搜索文本队列
searchTextQueue: Array<any> = [];
// 队列启动标志位
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;
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.requestItem();
let hasInfoMsg = false;
hasInfoMsg = AppStorageUtil.getHasInfoMsg();
if (!hasInfoMsg && this.messageList.length == 0) {
this.total = 0;
}
};
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;
}
if (!this.isSearchStatus) {
this.backSearch();
}
};
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.total = this.messageList.length;
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/advancedSettings/advancedSettings'
});
};
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) {
HiLog.i(TAG, 'statisticalData, Success result: ' + JSON.stringify(result));
// 列表的总数
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;
HiLog.i(TAG, 'getSettingFlagForConvListPage, result: ' + JSON.stringify(result));
}
};
// 分页获取列表数据
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));
})
};
// 跳转多人头像列表页面
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, 'queryAllMessages, querySessionList result: ' + JSON.stringify(result));
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.total = result.total;
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.unreadTotalOfInfo = this.unreadTotalOfInfo - threadIds.length;
HiLog.i(TAG, 'markAllAsRead, unreadTotalOfInfo=' + this.unreadTotalOfInfo)
};
cancelMessageInfoNotify(threadIds, callback) {
let actionData = {
threadIds: threadIds,
hasRead: 0
};
notificationService.cancelMessageNotify(actionData, res => {
HiLog.i(TAG, 'cancelMessageInfoNotify, cancelMessageNotify res: ' + JSON.stringify(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) {
HiLog.i(TAG, 'jumpToConversationPage, item: ' + JSON.stringify(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);
});
}
};
}

View File

@ -0,0 +1,66 @@
/**
* 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%')
}
}

View File

@ -0,0 +1,196 @@
/**
* 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 abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import appStorage from '../../utils/AppStorageUtil';
import bundle from '@ohos.bundle'
// JS公共常量
import common from '../../data/commonData';
import contactService from '../../service/ContractService';
import conversationListService from '../../service/ConversationListService';
import featureAbility from '@ohos.ability.featureAbility';
import LooseObject from '../../data/LooseObject'
import HiLog from '../../utils/HiLog';
import mmsTable from '../../data/tableData';
import preferences from '../../utils/PreferencesUtil';
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() {
let insertPromise = this.verifyPermissions();
insertPromise.then((requestPermissions) => {
if (requestPermissions.length == 0 || requestPermissions == []) {
this.getWant();
} else {
let context = featureAbility.getContext();
context.requestPermissionsFromUser(requestPermissions, 1, (data) => {
if (data.authResults == undefined) {
return;
}
HiLog.i(TAG, "data authResults:" + JSON.stringify(data.authResults));
for (let i = 0; i < data.authResults.length; i++) {
if (data.authResults[i] == -1) {
HiLog.i(TAG, 'Application requestPermissionsFromUser failed');
return;
}
}
this.getWant();
});
HiLog.i(TAG, 'Application requestPermissionsFromUser end');
}
}).catch((err) => {
HiLog.e(TAG, 'verifyPermissions, error: ' + JSON.stringify(err));
});
// 初始化数据库
this.initRdb();
},
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) => {
HiLog.i(TAG, 'initStorage, first done:' + 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) => {
HiLog.i(TAG, 'getWant, want: ' + JSON.stringify(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));
})
},
jump() {
HiLog.i(TAG, "jump, pageFlag=" + this.pageFlag);
let result = {
uri: '',
params: ''
};
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 => {
HiLog.i(TAG, 'jumpIsNewPage, querySessionByTelephone res: ' + JSON.stringify(res));
if (res.code == common.int.SUCCESS && res.response.id > 0) {
result.params.threadId = res.response.id;
} else {
result.params.isNewMsg = true;
}
router.replace(result);
});
},
async verifyPermissions() {
let array: Array<string> = [
"ohos.permission.READ_CONTACTS",
"ohos.permission.READ_MESSAGES",
"ohos.permission.SEND_MESSAGES",
"ohos.permission.SET_TELEPHONY_STATE",
"ohos.permission.GET_TELEPHONY_STATE",
"ohos.permission.RECEIVE_SMS",
"ohos.permission.PLACE_CALL"
];
var bundleFlag = 0;
var tokenID = undefined;
var userID = 100;
var appInfo = await bundle.getApplicationInfo('com.ohos.mms', bundleFlag, userID);
tokenID = appInfo.accessTokenId;
var atManager = abilityAccessCtrl.createAtManager();
let requestPermissions: Array<string> = [];
for (let i = 0;i < array.length; i++) {
var result = await atManager.verifyAccessToken(tokenID, array[i]);
HiLog.i(TAG, 'verifyPermissions %s', JSON.stringify(result));
if (result != abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
requestPermissions.push(array[i]);
}
}
HiLog.i(TAG, 'verifyPermissions %s', JSON.stringify(requestPermissions));
return requestPermissions;
}
}

View File

@ -0,0 +1,336 @@
/**
* 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 InfoMsgController from './InfoMsgController'
import {DeleteDialog} from '../../views/MmsDialogs';
import {MmsListItem} from '../../views/MmsListItem';
import common from '../../data/commonData'
@Entry
@Component
export default struct InfoMsg {
@StorageLink('InfoMsgController') mInfoMsgCtrl: InfoMsgController = InfoMsgController.getInstance();
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: DialogAlignment.Bottom,
offset: { dx: 0, dy: '-20vp' }
})
/**
* 函数在创建自定义组件的新实例后在执行其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() {
//通知信息
Column() {
if (this.mInfoMsgCtrl.isMultipleSelectState) {
//多选状态标题
Flex({ direction: FlexDirection.Column }) {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
Image($rawfile("icon/conversation_select_exit.svg"))
.width('24vp')
.height('24vp')
.onClick(() => {
this.onBackPress()
})
Text(this.mInfoMsgCtrl.conversationSelectedNumber == 0 ? $r('app.string.msg_unselected_tip') :
$r('app.string.msg_selected_tip', this.mInfoMsgCtrl.conversationSelectedNumber))
.padding({ left: '16vp' })
.fontSize('20fp')
.fontWeight(FontWeight.Bold)
}
.height('56vp')
}
.width('100%')
.height('56vp')
.padding({ left: '24vp' })
} else if (!this.mInfoMsgCtrl.searchStatus) {
//标题行
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
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')
.padding({ left: '24vp' })
}
Row() {
//返回按钮
if (this.mInfoMsgCtrl.isShowSearchBack) {
Image($rawfile("icon/ic_message_back.svg"))
.width(24)
.height(24)
.onClick((event: ClickEvent) => {
this.mInfoMsgCtrl.clickSearchBack();
})
}
//搜索框
// @ts-ignore
Search({ value: this.mInfoMsgCtrl.inputValueOfSearch, placeholder: $r("app.string.search2") })
.layoutWeight(1)
.height('40vp')
.border({ radius: '20vp' })
// .focusable(this.mInfoMsgCtrl.isSearchFocusable)
.enabled(!this.mInfoMsgCtrl.isMultipleSelectState)
.backgroundColor($r("app.color.search_input_background"))
.onChange((value: string) => {
this.mInfoMsgCtrl.clickToSearch(value);
})
.onSubmit((value: string) => {
this.mInfoMsgCtrl.clickToSearch(value);
})
// .onTouch((event: TouchEvent) => {
// if (event.type === TouchType.Down) {
// this.mInfoMsgCtrl.searchTouchStart(true, event)
// }
// })
}
.visibility(Visibility.None)
.width('100%')
.height('56vp')
.padding({ left: 24, right: 24 })
.alignItems(VerticalAlign.Center)
//短信展示列表
Stack() {
Column() {
List({ initialIndex: 0 }) {
ForEach(this.mInfoMsgCtrl.messageList, (item, index) => {
//真正的信息列表
if (this.mInfoMsgCtrl.isSearchStatus) {
ListItem() {
MmsListItem({
item: item,
index: index,
isShowHead: this.mInfoMsgCtrl.isShowContactHeadIcon,
isMultipleSelectState: this.mInfoMsgCtrl.isMultipleSelectState,
onClickHead: (event: ClickEvent) => {
this.mInfoMsgCtrl.clickToGroupDetail(index);
},
onClickBody: (event: ClickEvent) => {
this.mInfoMsgCtrl.clickInfoToConversation(index);
},
onItemLongPress: (event: GestureEvent) => {
this.mInfoMsgCtrl.conversationLongPress(index)
},
onTouchStart: (event: GestureEvent) => {
this.mInfoMsgCtrl.touchStart(event, index);
},
onTouchUpdate: (event: GestureEvent) => {
this.mInfoMsgCtrl.touchMove(event, index);
},
onTouchEnd: (event: GestureEvent) => {
this.mInfoMsgCtrl.touchEnd(event, index);
},
onClickFirstSlipBtn: (event: ClickEvent) => {
this.mInfoMsgCtrl.markAllAsReadByIndex(index);
},
onClickSecondSlipBtn: (event: ClickEvent) => {
this.mInfoMsgCtrl.deleteAction(index);
this.delDialogController.open();
}
})
}
.width('100%')
.height('64vp')
.alignSelf(ItemAlign.Start)
}
}, item => item.threadId)
}
.align(Alignment.Top)
.cachedCount(this.mInfoMsgCtrl.limit)
}.width('100%').height('100%')
//搜索上方
//短信搜索会话item
//左侧头像
//右侧信息等
//上方的name和日期
//下方的信息详情
//中间间隔线
//搜索信息列表 信息条码数量
//搜索信息列表
//左侧头像
//右侧信息等
//上方的name和日期
//下方的信息详情
//如果没有会话信息,也就是{{total}}为0则显示空白图片
//显示搜索状态
if (this.mInfoMsgCtrl.isSearchCoverage) {
//图层用于搜索的展示
Flex()
.width('100%')
.height('100%')
.opacity(0.2)
.backgroundColor(Color.Gray)
.onTouch((event: TouchEvent) => {
if (event.type === TouchType.Down) {
this.mInfoMsgCtrl.searchCoverageClick()
}
})
}
}
.flexGrow(1)
//单个会话长按选项
if (this.mInfoMsgCtrl.isMultipleSelectState) {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
//删除
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile(this.mInfoMsgCtrl.svgDelete))
.width('24vp')
.height('24vp')
.margin({ top: '3vp' })
Text($r("app.string.delete")).fontSize('10fp')
}
.width('50%')
.opacity(this.mInfoMsgCtrl.conversationSelectedNumber == 0 ? 0.5 : 1)
.onClick(() => {
this.mInfoMsgCtrl.clickConversationDelete()
this.delDialogController.open()
})
//全选
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile(this.mInfoMsgCtrl.isConversationCheckAll ? 'icon/ic_select_all_filled.svg' : 'icon/ic_select_all.svg'))
.width('24vp')
.height('24vp')
.margin({ top: '3vp' })
Text(this.mInfoMsgCtrl.strCheckBoxSelectTip)
.fontSize('10fp')
.fontColor(this.mInfoMsgCtrl.isConversationCheckAll ? '#007DFF' : '#2C2C2C')
}
.width('50%')
.onClick(() => {
this.mInfoMsgCtrl.clickConversationCheckAll()
})
}
.width('100%')
.height('56vp')
.padding({ left: '86vp', right: '86vp' })
}
//全部已读和更多
if (!this.mInfoMsgCtrl.isMultipleSelectState && this.mInfoMsgCtrl.showToolBar) {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
//全部已读
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile('icon/ic_allread.svg'))
.width('24vp')
.height('24vp')
.margin({ top: '3vp' })
Text($r("app.string.markAllAsRead")).fontSize('10fp')
}
.width('50%')
.opacity(this.mInfoMsgCtrl.unreadTotalOfInfo == 0 ? 0.5 : 1)
.onClick(() => {
this.mInfoMsgCtrl.clickToMarkAllAsReadForInfo()
})
//更多
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile('icon/ic_more_24x24.svg')).width('24vp').height('24vp')
.margin({ top: '3vp' })
Text($r("app.string.more")).fontSize('10fp')
}
.width('50%')
.bindMenu([{
// @ts-ignore
value: $r("app.string.delete"),
action: () => {
this.mInfoMsgCtrl.selectInMoreMenu(1)
}
}, {
// @ts-ignore
value: $r("app.string.blocked"),
action: () => {
this.mInfoMsgCtrl.selectInMoreMenu(2)
}
},])
}
.width('100%')
.height('56vp')
.padding({ left: '86vp', right: '86vp' })
}
//设置导航栏显示背景
//删除弹出对话框
}
.width('100%')
.height('100%')
}
}

View File

@ -0,0 +1,73 @@
/**
* 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;
// 时间戳
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);
HiLog.i(TAG, 'dealTime mmsTime=' + this.mmsTime)
}
}

View File

@ -0,0 +1,88 @@
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
import QueryReportController from './queryReportController'
@Entry
@Component
struct Query_report {
@StorageLink('QueryReportController') queryReportController: QueryReportController = QueryReportController.getInstance();
private onPageShow(): void {
this.queryReportController.onShow()
}
private aboutToAppear(): void {
this.queryReportController.onInit()
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
Row() {
Image($rawfile('icon/ic_message_back.svg'))
.width(24)
.height(24)
.onClick(() => {
router.back()
})
Text($r("app.string.send_reports"))
.margin({ left: 16 })
.fontSize(20)
.fontWeight(FontWeight.Bold)
.lineHeight(28)
}
.alignItems(VerticalAlign.Center)
.width('100%')
.height(56)
.backgroundColor('#F0F0F0')
.padding({ left: 24, right: 24 })
Column() {
Text() {
Span($r("app.string.putAddresser")).fontSize(16)
Span(this.queryReportController.telephone).fontSize(16)
}
.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)
}
.fontSize(16)
.height(48)
.fontWeight(FontWeight.Medium)
.lineHeight(22)
}
}
.alignItems(HorizontalAlign.Start)
.padding({ left: 36, right: 36 })
}
.width('100%')
.height('100%')
}
}

View File

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

View File

@ -0,0 +1,317 @@
/**
* 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 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';
let sAdvancedSettingsCtrl;
export default class 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() {
sAdvancedSettingsCtrl = appStorage.Link('AdvancedSettingsController');
if (sAdvancedSettingsCtrl == null) {
sAdvancedSettingsCtrl = new AdvancedSettingsController();
appStorage.setAndLink('AdvancedSettingsController', sAdvancedSettingsCtrl);
}
return sAdvancedSettingsCtrl;
}
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) {
HiLog.i(TAG, 'getAdvancedPageSwitchValue, success result: ' + JSON.stringify(result));
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() {
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');
}
});
}
}

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -12,23 +12,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.container {
flex-direction: row;
background-color: #00f;
}
.container-div {
}
.container-div-text {
border: 0;
margin: 0;
padding: 0;
text-align: left;
text-overflow: ellipsis;
max-lines: 1;
}
.orangeText {
color: #00f;
@Entry
@Component
struct RingtoneSettings {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('这是铃声设置界面')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -13,8 +13,6 @@
* limitations under the License.
*/
export default {
onCreate() {
},
onDestroy() {
}
};
}

View File

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

View File

@ -0,0 +1,149 @@
/**
* 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 LooseObject from '../../data/LooseObject'
import HiLog from '../../utils/HiLog';
import router from '@system.router';
import prompt from '@system.prompt';
// JS公共常量
import common from '../../data/commonData';
import settingService from '../../service/SettingService'
let sSettingsCtrl;
const TAG = 'SettingsController';
export default class SettingsController{
// 通知信息整合
integrationSwitch: boolean = false;
// 恶意网站选择
maliciousWebSwitch: boolean = false;
// 显示联系人头像
showContactSwitch: boolean = false
static getInstance() {
if(sSettingsCtrl == null) {
sSettingsCtrl = new SettingsController();
appStorage.setAndLink(TAG, sSettingsCtrl);
}
return sSettingsCtrl;
}
onInit() {
HiLog.i(TAG, 'onInit, start');
};
onShow() {
this.getSettingPageSwitchValue();
};
// 初始化setting页面的开关
getSettingPageSwitchValue() {
HiLog.i(TAG, 'getSettingPageSwitchValue, start');
settingService.setOnSettingValueListener(this.initializeSettingData);
};
// 初始化setting数据
initializeSettingData(data) {
this.integrationSwitch = data.integrationSwitch;
this.maliciousWebSwitch = data.maliciousWebSwitch;
this.showContactSwitch = data.showContactSwitch;
};
// 通知信息整合
integration(e) {
let messageCode = common.route.MESSAGE_CODE_UPDATE_ARCHIVE_INFO_MESSAGES_VALUE;
let actionData: LooseObject = {};
this.integrationSwitch = e.checked;
if(this.integrationSwitch) {
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() {
settingService.restoreSwitchValue(function (result) {
if (result.code === common.int.SUCCESS) {
this.integrationSwitch = true;
this.maliciousWebSwitch = false;
this.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');
}
});
};
}

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -14,9 +14,13 @@
*/
import call from '@ohos.telephony.call';
import mmsLog from '../utils/MmsLog.js';
import common from '../pages/common_constants.js';
import HiLog from '../utils/HiLog';
import common from '../data/commonData';
interface LooseObject {
[key: string]: any
}
const TAG = 'CallService';
export default {
/**
@ -26,16 +30,16 @@ export default {
*/
call(params, callback) {
if(params == null || params.telephone == common.string.EMPTY_STR) {
mmsLog.info('call param is null');
HiLog.i(TAG, 'call, param is null');
return;
}
let result = {};
let result: LooseObject = {};
call.dial(params.telephone).then((value) => {
mmsLog.info('call dial success:' + value);
HiLog.i(TAG, 'call, dial success: ' + value);
result.code = common.int.SUCCESS;
callback(result);
}).catch((err) => {
mmsLog.info('call dial error: ' + err.message);
HiLog.e(TAG, 'call, dial error: ' + err.message);
result.code = common.int.FAILURE;
callback(result);
});

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -13,7 +13,7 @@
* limitations under the License.
*/
import common from '../pages/common_constants.js';
import common from '../data/commonData';
export default {
commonContractParam(actionData){
@ -134,7 +134,7 @@ export default {
judgeIsSelectText(mmsSource) {
let flage = false;
for(let item of mmsSource) {
let msgType = item.msgType + common.string.EMPTY_STR;
let msgType = item.msgType;
if(common.MSG_ITEM_TYPE.THEME == msgType) {
flage = true;
}
@ -151,7 +151,7 @@ export default {
judgeIsImage(mmsSource) {
let flage = false;
for(let item of mmsSource) {
let msgType = item.msgType + common.string.EMPTY_STR;
let msgType = item.msgType;
if(common.MSG_ITEM_TYPE.IMAGE == msgType) {
flage = true;
}
@ -184,7 +184,7 @@ export default {
return flage;
}
for(let item of mmsSource) {
let msgType = item.msgType + common.string.EMPTY_STR;
let msgType = item.msgType;
if(common.MSG_ITEM_TYPE.IMAGE == msgType || common.MSG_ITEM_TYPE.VIDEO == msgType
|| common.MSG_ITEM_TYPE.AUDIO == msgType) {
flage = true;

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -13,13 +13,15 @@
* limitations under the License.
*/
import mmsLog from '../utils/MmsLog.js';
import ContactsModel from '../../default/model/contactsImpl/ContactsModel.js';
import common from '../pages/common_constants.js';
import telephoneUtil from '../utils/TelephoneUtil.js';
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 mContactsModel = new ContactsModel();
const CONTRACT_TAG = 'ContractService : ';
const TAG = 'ContractService';
let mContactsModel = new ContactsModel();
export default {
@ -31,7 +33,7 @@ export default {
queryContact(actionData, callback) {
// 获取rawContractIds,去查询联系人
mContactsModel.queryContact(actionData, rawContractIds => {
let result = {};
let result: LooseObject = {};
actionData.contractIds = rawContractIds;
// 根据rawContractIds
mContactsModel.queryContactDataByIds(actionData, contracts => {
@ -52,7 +54,7 @@ export default {
countContact(actionData, callback) {
// 获取rawContractIds,去查询联系人
mContactsModel.countContact(actionData, count => {
let result = {};
let result: LooseObject = {};
result.code = common.int.SUCCESS;
result.response = count;
callback(result);
@ -67,9 +69,9 @@ export default {
async convertContracts(contracts, callback) {
let messageList = [];
for (let contract of contracts) {
let item = {};
let item: LooseObject = {};
item.contactName = contract.displayName;
item.headImage = '/common/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;
@ -118,7 +120,7 @@ export default {
*/
queryContactDataByTelephone(actionData, callback) {
mContactsModel.queryContactDataByTelephone(actionData, contracts => {
mmsLog.log(CONTRACT_TAG + 'queryContactDataByTelephone,result:' + contracts);
HiLog.i(TAG, 'queryContactDataByTelephone, success');
callback(contracts);
})
},
@ -129,7 +131,7 @@ export default {
* @param callback
*/
searchContracts(actionData, callback) {
let result = {};
let result: LooseObject = {};
mContactsModel.searchContracts(actionData, res => {
result.code = res.code
if(res.code == common.int.SUCCESS) {
@ -141,8 +143,8 @@ export default {
dealSearchContracts(contracts) {
let searchContracts = []
for(let item of contracts) {
let searchContract = {};
searchContract.headImage = '/common/icon/user_avatar_full_fill.svg';
let searchContract: LooseObject = {};
searchContract.headImage = 'icon/user_avatar_full_fill.svg';
searchContract.contactName = item.displayName;
searchContract.telephone = item.detailInfo;
searchContract.telephoneFormat = item.detailInfo;
@ -158,9 +160,9 @@ export default {
* @param {Object} callback 回调函数
*/
judgeIsExitProfile(actionData, callback) {
mmsLog.log('jumpToCard judgeIsExitProfile is start');
HiLog.i(TAG, 'judgeIsExitProfile, start');
mContactsModel.queryProfile(actionData, res => {
mmsLog.log('jumpToCard judgeIsExitProfile is res : ' + res);
HiLog.i(TAG, 'judgeIsExitProfile, res: ' + res);
let result = false;
if (res > 0) {
result = true;

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -14,44 +14,42 @@
*/
// log 工具类
import mmsLog from '../utils/MmsLog.js';
import HiLog from '../utils/HiLog';
// 公共常量
import common from '../pages/common_constants.js';
import common from '../data/commonData';
// 获取假数据
import ConversationListModel from '../model/conversationListImpl/ConversationListModel.js';
import ConversationListModel from '../model/ConversationListModel';
let conversationListModel = new ConversationListModel();
import conversationService from '../service/ConversationService.js';
import contractService from '../service/ContractService.js';
import commonService from '../service/CommonService.js';
import telephoneUtils from '../utils/TelephoneUtil.js';
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 rdbStore 数据库实例
* @param actionData 查询参数
* @param tableName 表明
* @return
*/
querySessionList(rdbStore, actionData, callback) {
querySessionList(actionData, callback) {
// 查询数据列表
let result = {};
let queryPromise = conversationListModel.querySessionList(rdbStore, actionData);
let result: LooseObject = {};
let queryPromise = conversationListModel.querySessionList(actionData);
// 获取总的条数
let countPromise = conversationListModel.countSessionList(rdbStore, actionData);
let countPromise = conversationListModel.countSessionList(actionData);
// 判断通知信息是否存在
let notificationPromise = new Promise((resolve) => {
this.judgeIsNotificationData(rdbStore, res => {
this.judgeIsNotificationData(res => {
resolve(res);
});
});
Promise.all([queryPromise, countPromise, notificationPromise]).then((res) => {
mmsLog.log(TAG + 'querySessionList,result.total:' + res[1].total);
result.code = common.int.SUCCESS;
let telephones = [];
let messageList = this.convertSessionList(res[0].response, telephones);
@ -59,10 +57,11 @@ export default {
result.showInfoDivWhenSearchFlag = res[2];
this.dealContactsName(telephones, actionData, messageList, sessionList => {
result.response = sessionList;
HiLog.i(TAG, 'querySessionList, dealContactsName callback');
callback(result);
});
}).catch((err) => {
mmsLog.log(TAG + 'querySessionList error: ' + err);
HiLog.e(TAG, 'querySessionList, error: ' + JSON.stringify(err));
result.code = common.int.FAILURE;
callback(result);
});
@ -70,19 +69,19 @@ export default {
convertSessionList(sessionList, telephones) {
let messageList = [];
for (let session of sessionList) {
let item = {};
let item: LooseObject = {};
item.name = common.string.EMPTY_STR;
item.contactsNum = session.contactsNum;
item.content = session.content;
item.countOfUnread = session.unreadCount;
if (session.smsType == 0) {
item.icon = '/common/icon/user_avatar_full_fill.svg';
item.icon = 'icon/user_avatar_full_fill.svg';
} else {
item.icon = '/common/icon/entrance_icon01.svg';
item.icon = 'icon/entrance_icon01.svg';
}
item.isCbChecked = false;
item.isLock = false;
item.sendingFailed = session.sendingStatus == common.int.SEND_MESSAGE_FAILED ? true : false;
item.sendingFailed = session.sendStatus == common.int.SEND_MESSAGE_FAILED ? true : false;
item.telephone = session.telephone;
if (item.contactsNum > 1) {
let telephoneSplit = item.telephone.split(common.string.COMMA);
@ -159,16 +158,15 @@ export default {
/**
* 判断是否存在通知信息的数据
* @param rdbStore 查询实例
* @param callback 返回
*/
judgeIsNotificationData(rdbStore, callback) {
judgeIsNotificationData(callback) {
let param = {
numberType: 1,
limit: 1,
page: 1
};
this.querySessionByNumberType(rdbStore, param, res => {
this.querySessionByNumberType(param, res => {
if(res.code == common.int.SUCCESS && res.response.length > 0) {
callback(true);
} else {
@ -184,19 +182,19 @@ export default {
* @return
*/
statisticalData(actionData, callBack) {
let normalPromise = new Promise((resolve) => {
let normalPromise = new Promise<LooseObject>((resolve) => {
conversationListModel.statisticalData(actionData, res => {
let result = {};
let result: LooseObject = {};
result.code = res.code;
if (res.code == common.int.SUCCESS) {
result.response = res.abilityResult;
resolve(result.response);
} else {
mmsLog.info(TAG + 'Error: statisticalData() failed !!!');
HiLog.w(TAG, 'statisticalData, failed');
}
});
});
let notifyPromise = new Promise((resolve) => {
let notifyPromise = new Promise<number>((resolve) => {
conversationService.statisticsUnreadNotify(actionData, res => {
resolve(res);
});
@ -215,7 +213,7 @@ export default {
}
callBack(result);
}).then(err => {
mmsLog.info(TAG + 'Error: statisticalData all failed!' + err);
HiLog.e(TAG, 'statisticalData, failed: ' + JSON.stringify(err));
let result = {
code: common.int.FAILURE
}
@ -226,40 +224,36 @@ export default {
/**
* 根据主键ID,删除数据
* @param rdbStore 数据库实例
* @param threadIds 会话ID
* @return
*/
deleteMessageById(actionData) {
// 删除会话列表的数据
conversationListModel.deleteMessageById(actionData.rdbStore, actionData.threadIds);
conversationListModel.deleteMessageById(actionData.threadIds);
// 删除信息列表的数据
conversationService.deleteMessageBySessionIds(actionData);
},
/**
* 根据主键ID,删除数据
* @param rdbStore 数据库实例
* @param threadIds 会话ID
*/
deleteMessageBySessionId(rdbStore, threadIds) {
deleteMessageBySessionId(threadIds) {
// 删除会话列表的数据
conversationListModel.deleteMessageById(rdbStore, threadIds);
conversationListModel.deleteMessageById(threadIds);
},
/**
* 根据主键ID,更新数据
* @param rdbStore 数据库实例
* @param threadIds 会话ID
* @return
*/
updateById(rdbStore, threadIds, valueBucket) {
conversationListModel.updateById(rdbStore, threadIds, valueBucket);
updateById(threadIds, valueBucket) {
conversationListModel.updateById(threadIds, valueBucket);
},
/**
* 标记已读短信
* @param rdbStore 数据库实例
* @param threadIds 会话ID
* @param valueBucket 标记已读的数量
* @return
@ -269,7 +263,7 @@ export default {
return;
}
// 会话列表上的标记已读
conversationListModel.markAllAsRead(actionData.rdbStore, actionData.threadIds, actionData.valueBucket);
conversationListModel.markAllAsRead(actionData.threadIds, actionData.valueBucket);
// 短信信息的已读
conversationService.markAllAsRead(actionData);
},
@ -279,38 +273,34 @@ export default {
* @param actionData
*/
markAllToRead(actionData) {
conversationListModel.markAllToRead(actionData.rdbStore, actionData.smsType);
conversationListModel.markAllToRead(actionData.smsType);
conversationService.markAllToRead(actionData);
},
/**
* 新增会话列表
* @param rdbStore 数据库实例
* @param valueBucket 新增的数据
* @param callback 回调
* @return
*/
insertSession(rdbStore, valueBucket, callback) {
conversationListModel.insertSession(rdbStore, common.tableName.SESSION, valueBucket, res => {
insertSession(valueBucket, callback) {
conversationListModel.insertSession(common.tableName.SESSION, valueBucket, res => {
callback(res);
});
},
/**
* 新增会话草稿列表
* @param rdbStore 数据库实例
* @param valueBucket 新增的数据
* @param callback 回调
* @return
*/
insertSessionDraft(actionData) {
let param = this.dealSendResults(actionData);
let rdbStore = actionData.rdbStore;
// 先判断是否创建过会话列表
this.querySessionByTelephone(rdbStore, param.telephone, res => {
mmsLog.info(TAG +'insertSessionDraft,querySessionByTelephone:' + res);
this.querySessionByTelephone(param.telephone, res => {
let response = res.response;
if(res.code == common.int.SUCCESS && response.id < 0) {
if(res.code == common.int.SUCCESS && response.id <= 0) {
this.dealInsertSession(param, actionData);
} else {
this.deleteDraftDataOrUpdate(actionData, response, param);
@ -330,12 +320,10 @@ export default {
'has_mms': param.hasMms,
'has_attachment': param.hasAttachment,
}
this.insertSession(actionData.rdbStore, valueBucket, sessionResult => {
this.insertSession(valueBucket, sessionResult => {
// 这里调用短信数据库,插入短信信息
mmsLog.info(TAG + 'insertSession,rowId:' + sessionResult);
let sessionId = sessionResult.rowId;
conversationService.dealInsertMessageDetail(param, actionData, sessionId, res => {
mmsLog.info(TAG + 'dealInsertMessageDetail,initDatas:' + res);
});
});
},
@ -352,7 +340,6 @@ export default {
}
},
updateDraftData(response, param ,actionData) {
let rdbStore = actionData.rdbStore;
let sessionId = response.id;
// 这里调用短信数据库,插入短信信息
let threadIds = [sessionId];
@ -364,9 +351,8 @@ export default {
'has_attachment': param.hasAttachment,
'has_mms': param.hasMms,
}
this.updateById(rdbStore, threadIds, valueBucket);
this.updateById(threadIds, valueBucket);
conversationService.dealInsertMessageDetail(param, actionData, sessionId, res => {
mmsLog.info(TAG + 'dealInsertMessageDetail,initDatas:' + res);
});
},
dealSendResults(actionData) {
@ -402,7 +388,7 @@ export default {
}
actionData.sendResults = [sendResult];
let timestamp = new Date().getTime();
let result = {};
let result: LooseObject = {};
result.contractsNum = contractsNum;
result.telephone = telephoneUtils.dealTelephoneSort(telephone);
result.content = actionData.content;
@ -419,21 +405,19 @@ export default {
/**
* 根据手机号查询会话列表
* @param rdbStore 数据库实例
* @param telephone 手机号
* @return
*/
querySessionByNumberType(rdbStore, actionData, callback) {
mmsLog.log(TAG + 'querySessionByNumberType,actionData:' + actionData);
let result = {};
let queryPromise = conversationListModel.querySessionList(rdbStore, actionData);
querySessionByNumberType(actionData, callback) {
let result: LooseObject = {};
let queryPromise = conversationListModel.querySessionList(actionData);
Promise.all([queryPromise]).then((res) => {
mmsLog.log(TAG + 'querySessionByNumberType,result:' + res[0]);
HiLog.i(TAG, 'querySessionByNumberType, result: ' + JSON.stringify(res[0]));
result.code = common.int.SUCCESS;
result.response = res[0].response;
callback(result);
}).catch((err) => {
mmsLog.log(TAG + 'querySessionByTelephone error: ' + err);
HiLog.e(TAG, 'querySessionByNumberType, error: ' + JSON.stringify(err));
result.code = common.int.FAILURE;
callback(result);
});
@ -441,24 +425,25 @@ export default {
/**
* 根据手机号查询会话列表
* @param rdbStore 数据库实例
* @param telephone 手机号
* @return
*/
querySessionByTelephone(rdbStore, telephone, callback) {
let result = {};
querySessionByTelephone(telephone, callback) {
let result: LooseObject = {};
if(telephone == null) {
HiLog.w(TAG, 'querySessionByTelephone, telephone == null')
result.code = common.int.FAILURE;
callback(result);
} else {
let queryPromise = conversationListModel.querySessionByTelephone(rdbStore, telephone);
HiLog.i(TAG, 'querySessionByTelephone, telephone != null')
let queryPromise = conversationListModel.querySessionByTelephone(telephone);
Promise.all([queryPromise]).then((res) => {
mmsLog.log(TAG + 'querySessionByTelephone,result:' + res[0]);
HiLog.i(TAG, ', querySessionByTelephone, res: ' + JSON.stringify(res[0]));
result.code = common.int.SUCCESS;
result.response = res[0];
callback(result);
}).catch((err) => {
mmsLog.log(TAG + 'querySessionByTelephone error: ' + err);
HiLog.e(TAG, ', querySessionByTelephone, error: ' + JSON.stringify(err));
result.code = common.int.FAILURE;
callback(result);
});
@ -467,21 +452,20 @@ export default {
/**
* 根据手机号查询会话列表
* @param rdbStore 数据库实例
* @param telephone 手机号
* @return
*/
querySessionById(rdbStore, threadId, callback) {
let result = {};
mmsLog.log(TAG + 'querySessionById,param:' + threadId + ' rdbStore:' + rdbStore);
let queryPromise = conversationListModel.querySessionById(rdbStore, threadId);
querySessionById(threadId, callback) {
let result: LooseObject = {};
HiLog.i(TAG, 'querySessionById, threadId:' + threadId);
let queryPromise = conversationListModel.querySessionById(threadId);
Promise.all([queryPromise]).then((res) => {
mmsLog.log(TAG + 'querySessionById,result:' + JSON.stringify(res[0]));
HiLog.i(TAG, 'querySessionById, res: ' + JSON.stringify(res[0]));
result.code = common.int.SUCCESS;
result.response = res[0];
callback(result);
}).catch((err) => {
mmsLog.log(TAG + 'querySessionById error: ' + err);
HiLog.e(TAG, 'querySessionById, error: ' + JSON.stringify(err));
result.code = common.int.FAILURE;
callback(result);
});
@ -528,8 +512,7 @@ export default {
'message_count': length,
'unread_count': 0
};
let rdbStore = actionData.rdbStore;
this.updateById(rdbStore, threadIds, valueBucket);
this.updateById(threadIds, valueBucket);
},
/**
* 搜索
@ -559,8 +542,8 @@ export default {
}
});
});
let resultMap = {};
let result = {};
let resultMap: LooseObject = {};
let result: LooseObject = {};
Promise.all([sessionListPromise,contentListPromise]).then((res) => {
result.code = common.int.SUCCESS;
resultMap.sessionList = res[0];
@ -569,7 +552,7 @@ export default {
result.search = searchText;
callback(result);
}).catch((err) => {
mmsLog.log(TAG + 'searchMessageWithLike error: ' + err);
HiLog.e(TAG, 'searchMessageWithLike, error: ' + JSON.stringify(err));
result.code = common.int.FAILURE;
callback(result);
});
@ -580,12 +563,10 @@ export default {
* @param actionData 数据库实例
*/
async searchSessionByTelephone(actionData, callback) {
let result = [];
mmsLog.log(TAG + 'searchSessionByTelephone,param:' + actionData);
let rdbStore = actionData.rdbStore;
let result: LooseObject = {};
let telephone = actionData.inputValue;
let numberType = actionData.numberType;
let queryPromise = conversationListModel.searchSessionByTelephone(rdbStore, telephone, numberType);
let queryPromise = conversationListModel.searchSessionByTelephone(telephone, numberType);
queryPromise.then((res) => {
result.code = common.int.SUCCESS;
let telephones = [];
@ -595,7 +576,7 @@ export default {
callback(result);
});
}).catch((err) => {
mmsLog.log(TAG + 'searchSessionByTelephone error: ' + err);
HiLog.e(TAG, 'searchSessionByTelephone, error: ' + JSON.stringify(err));
result.code = common.int.FAILURE;
callback(result);
});
@ -603,7 +584,7 @@ export default {
dealSessionLikeData(mmList) {
let sessionList = [];
for (let item of mmList) {
let map = {}
let map: LooseObject = {}
map.name = item.name;
map.threadId = item.threadId;
map.telephone = item.telephone;

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -13,18 +13,22 @@
* limitations under the License.
*/
import ContactModel from '../model/contactsImpl/ContactsModel.js';
import ConversationModel from '../model/conversationImpl/ConversationModel.js';
import common from '../pages/common_constants.js';
import mmsLog from '../utils//MmsLog.js';
import conversationListService from '../service/ConversationListService.js';
import telephoneUtils from '../utils/TelephoneUtil.js';
import contractService from '../service/ContractService.js';
import commonService from '../service/CommonService.js';
import ContactsModel from '../model/ContactsModel';
import ConversationModel from '../model/ConversationModel';
import common from '../data/commonData';
import HiLog from '../utils//HiLog';
let mContactModel = new ContactModel();
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';
let mContactsModel = new ContactsModel();
let mConversationModel = new ConversationModel();
const CONVERSATION_TAG = 'ConversationService: ';
export default {
@ -35,11 +39,11 @@ export default {
* @return
*/
judgeContactExists(params, callback) {
mContactModel.queryContactDataByTelephone(params, function (result) {
mContactsModel.queryContactDataByTelephone(params, function (result) {
let hasExitContract = false;
if (result.length >= 1) {
// 联系人是否存在
mmsLog.info(CONVERSATION_TAG + 'queryContact success');
HiLog.i(TAG, 'judgeContactExists, queryContactDataByTelephone success');
hasExitContract = true;
}
callback(hasExitContract);
@ -53,18 +57,18 @@ export default {
* @return
*/
queryMessageDetail(actionData, callback) {
let result = {};
mmsLog.log(CONVERSATION_TAG + 'queryMessageDetail() start');
let result: LooseObject = {};
HiLog.i(TAG, 'queryMessageDetail, start');
mConversationModel.queryMessageDetail(actionData, res => {
HiLog.i(TAG, 'queryMessageDetail, queryMessageDetail success')
result.code = res.code;
if (res.code == common.int.SUCCESS) {
this.groupDetailMessage(res.abilityResult, actionData, resultList => {
result.response = resultList;
mmsLog.log(CONVERSATION_TAG + 'queryMessageDetail() result:' + result);
callback(result);
});
} else {
mmsLog.log(CONVERSATION_TAG + 'Error: queryMessageDetail() failed !!!');
HiLog.w(TAG, 'groupDetailMessage, failed');
callback(result);
}
});
@ -72,7 +76,7 @@ export default {
convertConversationList(mmsList) {
let resultList = [];
for (let item of mmsList) {
let result = {};
let result: LooseObject = {};
result.id = item.msgId;
result.content = item.msgContent;
result.isLock = item.isLock == 0 ? false : true;
@ -83,9 +87,9 @@ export default {
result.read = item.isRead == 0 ? '0' : '1';
if (item.msgState == 0) {
result.sendStatus = common.int.SEND_MESSAGE_SUCCESS;
} else if (item.msgState == 1) {
} else if (item.msgState == 2) {
result.sendStatus = common.int.SEND_MESSAGE_FAILED;
} else if (item.msgState == 2){
} else if (item.msgState == 1){
result.sendStatus = common.int.SEND_MESSAGE_SENDING;
} else {
result.sendStatus = common.int.SEND_DRAFT;
@ -204,26 +208,24 @@ export default {
/**
* 插入会话详情及短信详情
* @param rdbStore 数据库实例
* @param sendResults 发送结果
* @param threadId 会话列表ID
* @param isReceive 是否接收
* @return
*/
insertSessionAndDetail(actionData, callback) {
mmsLog.info('insertSessionAndDetail,start:' + actionData);
HiLog.i(TAG,'insertSessionAndDetail, start');
let sendResults = actionData.sendResults;
let isReceive = actionData.isReceive;
if (sendResults.length == 0) {
HiLog.w(TAG,'insertSessionAndDetail, sendResults.length == 0');
return;
}
let param = this.dealSendResults(sendResults);
let rdbStore = actionData.rdbStore;
// 先判断是否创建过会话列表
conversationListService.querySessionByTelephone(rdbStore, param.telephone, res => {
mmsLog.info(CONVERSATION_TAG + 'insertSessionAndDetail,querySessionByTelephone:' + res);
conversationListService.querySessionByTelephone(param.telephone, res => {
let response = res.response;
if (res.code == common.int.SUCCESS && response.id < 0) {
if (res.code == common.int.SUCCESS && response.id <= 0) {
this.dealNoExitingSession(isReceive, param, actionData, callback);
} else {
this.dealExitingSession(response, param, actionData, callback);
@ -248,10 +250,11 @@ export default {
'has_mms': actionData.isMms ? 1 : 0,
'has_attachment': actionData.hasAttachment ? 1 : 0
}
conversationListService.insertSession(actionData.rdbStore, valueBucket, sessionResult => {
HiLog.i(TAG, 'dealNoExitingSession, valueBucket: ' + JSON.stringify(valueBucket))
conversationListService.insertSession(valueBucket, sessionResult => {
HiLog.i(TAG, 'dealNoExitingSession, insertSession callback')
// 这里调用短信数据库,插入短信信息
this.dealInsertMessageDetail(param, actionData, sessionResult.rowId, res => {
mmsLog.info('dealInsertMessageDetail,initDatas:' + res);
let result = {
rowId: sessionResult.rowId,
initDatas: res.initDatas,
@ -262,6 +265,7 @@ export default {
});
},
dealExitingSession(response, param, actionData, callback) {
HiLog.i(TAG, 'dealExitingSession')
let sessionId = response.id;
// 这里调用短信数据库,插入短信信息
let threadIds = [sessionId];
@ -287,10 +291,9 @@ export default {
'has_attachment': actionData.hasAttachment ? 1 : 0,
'has_mms': actionData.isMms ? 1 : 0,
}
conversationListService.updateById(actionData.rdbStore, threadIds, valueBucket);
conversationListService.updateById(threadIds, valueBucket);
// 这里调用短信数据库,插入短信信息
this.dealInsertMessageDetail(param, actionData, sessionId, res => {
mmsLog.info('dealInsertMessageDetail,initDatas:' + res);
let result = {
rowId: sessionId,
initDatas: res.initDatas,
@ -300,13 +303,15 @@ export default {
});
},
dealInsertMessageDetail(param, actionData, threadId, callback) {
HiLog.i(TAG, 'dealInsertMessageDetail')
this.queryMaxGroupId(actionData, res => {
let maxGroupId = 0;
if (res.code === common.int.SUCCESS) {
maxGroupId = res.response.maxGroupId == common.string.EMPTY_STR ? 0 : parseInt(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 {
mmsLog.info('dealInsertMessageDetail, queryMaxGroupId fail !!!!!!');
HiLog.w(TAG,'dealInsertMessageDetail, queryMaxGroupId failed');
callback();
}
this.insertMessageDetailByMaxGroupId(param, actionData, threadId, maxGroupId, result => {
@ -317,9 +322,10 @@ export default {
insertMessageDetailByMaxGroupId(param, actionData, threadId, maxGroupId, callback) {
let count = 0;
let initDatas = [];
let result = {};
let result: LooseObject = {};
result.groupId = maxGroupId;
for (let sendResult of actionData.sendResults) {
let sendResults = actionData.sendResults;
sendResults.forEach(sendResult => {
let insertDetail = this.initInsertDetail(param, actionData, threadId, maxGroupId);
if (actionData.isReceive) {
insertDetail.receiverNumber = actionData.ownNumber;
@ -332,7 +338,7 @@ export default {
}
insertDetail.sendStatus = sendResult.sendStatus;
if (sendResult.sendStatus == common.int.SEND_MESSAGE_FAILED) {
insertDetail.sendStatus = 1;
insertDetail.sendStatus = 2;
} else if (sendResult.sendStatus == common.int.SEND_MESSAGE_SUCCESS) {
insertDetail.sendStatus = 0;
}
@ -340,6 +346,7 @@ export default {
insertDetail.time = sendResult.time;
}
this.insertMessageDetail(insertDetail, id => {
HiLog.d(TAG, 'insertMessageDetailByMaxGroupId, insertMessageDetail id=' + id);
count++;
let initData = {
id: id,
@ -351,17 +358,17 @@ export default {
callback(result);
}
});
}
})
},
initInsertDetail(param, actionData, threadId, maxGroupId) {
let insertDetail = {
HiLog.i(TAG, 'initInsertDetail')
let insertDetail: LooseObject = {
receiverNumber: common.string.EMPTY_STR,
senderNumber: common.string.EMPTY_STR,
smsType: param.smsType,
content: param.content,
sendStatus: 2,
sessionType: 0,
featureAbility: actionData.featureAbility,
threadId: threadId,
isSender: actionData.isSender,
groupId: maxGroupId,
@ -374,6 +381,7 @@ export default {
return insertDetail;
},
dealSendResults(sendResults) {
HiLog.i(TAG, 'dealSendResults')
let contractsNum = sendResults.length;
let telephone = common.string.EMPTY_STR;
let content = common.string.EMPTY_STR;
@ -405,7 +413,7 @@ export default {
if (contractsNum == 1 && telephoneUtils.judgeIsInfoMsg(telephone)) {
smsType = 1;
}
let result = {};
let result: LooseObject = {};
let timestamp = new Date().getTime();
result.contractsNum = contractsNum;
result.content = content;
@ -422,7 +430,7 @@ export default {
* @return
*/
insertMessageDetail(param, callback) {
let actionData = {};
let actionData: LooseObject = {};
let time = new Date();
let timeStr = param.time != common.string.EMPTY_STR ? param.time : time.getTime() + common.string.EMPTY_STR;
var stringValue = {
@ -446,14 +454,15 @@ export default {
'group_id': param.groupId,
'is_send_report': param.hasReport
};
mmsLog.info(CONVERSATION_TAG + 'insertMessageDetail stringValue:' + stringValue);
HiLog.i(TAG, 'insertMessageDetail, stringValue: ' + JSON.stringify(stringValue));
actionData.stringValue = stringValue;
actionData.featureAbility = param.featureAbility;
mConversationModel.insertMessageDetail(actionData, result => {
if (result.code == common.int.SUCCESS) {
HiLog.i(TAG, 'insertMessageDetail, callback success')
this.dealBatchInsertMmsPart(param, result, callback);
} else {
mmsLog.info(CONVERSATION_TAG + 'insertMessageDetail fail');
HiLog.w(TAG, 'insertMessageDetail, fail');
}
});
},
@ -468,7 +477,7 @@ export default {
}
},
batchInsertMmsPart(param, callback) {
let actionData = {};
let actionData: LooseObject = {};
actionData.featureAbility = param.featureAbility;
let bacthmsParts = [];
for (let mms of param.mmsSource) {
@ -493,28 +502,25 @@ export default {
return;
}
let param = this.dealSendResults(sendResults);
mmsLog.info(CONVERSATION_TAG + 'updateSessionAndDetail,param:' + param);
// 更新会话列表的状态
let rdbStore = actionData.rdbStore;
let threadIds = [actionData.threadId];
let valueBucket = {
'sending_status': param.sendStatus,
'content': param.content
}
conversationListService.updateById(rdbStore, threadIds, valueBucket);
conversationListService.updateById(threadIds, valueBucket);
// 更新信息列表的状态
for (let sendResult of sendResults) {
actionData.sendStatus = sendResult.sendStatus;
if (sendResult.sendStatus == common.int.SEND_MESSAGE_FAILED) {
actionData.sendStatus = 1;
actionData.sendStatus = 2;
} else if (sendResult.sendStatus == common.int.SEND_MESSAGE_SUCCESS) {
actionData.sendStatus = 0;
} else {
actionData.sendStatus = 2;
actionData.sendStatus = 1;
}
actionData.msgId = sendResult.id;
this.updateById(actionData, result => {
mmsLog.info(CONVERSATION_TAG + 'updateById,result:' + result);
});
}
},
@ -582,19 +588,19 @@ export default {
* @param callback
*/
updateById(actionData, callback) {
let result = {};
let result: LooseObject = {};
mConversationModel.updateById(actionData, res => {
result.code = res.code;
callback(result);
}).catch(e=> {
HiLog.e(TAG, 'updateById, error: ' + JSON.stringify(e))
});
},
/**
* 判断卡是否存在
*
* @param {Object} preferences 偏量数据库
*/
judgeHasSimCard(preferences) {
judgeHasSimCard() {
let count = preferences.getCountOfSim();
if (count > 0) {
return true;
@ -609,14 +615,13 @@ export default {
* @return
*/
queryMaxGroupId(actionData, callBack) {
let result = {};
mmsLog.info(CONVERSATION_TAG + 'queryMaxGroupId, start:' + actionData);
let result: LooseObject = {};
mConversationModel.queryMaxGroupId(actionData, res => {
result.code = res.code;
if (res.code == common.int.SUCCESS) {
result.response = res.abilityResult;
} else {
mmsLog.info(CONVERSATION_TAG + 'Error: queryMaxGroupId() failed !!!');
HiLog.w(TAG, 'queryMaxGroupId, failed');
}
callBack(result);
});
@ -632,11 +637,11 @@ export default {
mConversationModel.saveImage(params, function (result) {
let message = '';
if (result.code == common.int.SUCCESS) {
mmsLog.info(CONVERSATION_TAG + 'saveImage success');
HiLog.i(TAG, 'saveImage, success');
message = this.$t('strings.attachment_saved_to') + result.abilityResult.filePath
+ this.$t('strings.please_keep_it_secure');
} else {
mmsLog.info(CONVERSATION_TAG + 'saveImage error');
HiLog.w(TAG, 'saveImage, error');
message = this.$t('string.save_img_failed');
}
callback(message);
@ -650,7 +655,7 @@ export default {
* @return
*/
gotoShare(actionData, callback) {
let result = {};
let result: LooseObject = {};
mConversationModel.gotoShare(actionData, res => {
result.code = res.code;
});
@ -664,7 +669,7 @@ export default {
* @return
*/
updateLock(actionData, callback) {
let result = {};
let result: LooseObject = {};
mConversationModel.updateLock(actionData, res => {
result.code = res.code;
callback(result);
@ -678,7 +683,7 @@ export default {
* @return
*/
updateCollect(actionData, callback) {
let result = {};
let result: LooseObject = {};
mConversationModel.updateCollect(actionData, res => {
result.code = res.code;
callback(result);
@ -710,7 +715,7 @@ export default {
}
});
});
let result = {};
let result: LooseObject = {};
Promise.all([smsPromise,mmsPartPromise]).then((res) => {
result.code = common.int.SUCCESS;
let resultList = [];
@ -719,7 +724,7 @@ export default {
result.response = this.dealMessageSort(resultList);
callback(result);
}).catch((err) => {
mmsLog.log(CONVERSATION_TAG + 'searchMessageByContent error: ' + err);
HiLog.e(TAG, 'searchMessageByContent, error: ' + JSON.stringify(err));
result.code = common.int.FAILURE;
callback(result);
});
@ -762,7 +767,7 @@ export default {
searchSmsMessageByContent(actionData, callback) {
let searchText = actionData.inputValue;
actionData.content = searchText;
let result = {};
let result: LooseObject = {};
// 这里需要掉用查询详情
mConversationModel.searchSmsMessageByContent(actionData, res => {
result.code = res.code;
@ -781,7 +786,7 @@ export default {
convertLikeConversation(mmsList, searchText, telephones, mmsPartMap) {
let resultList = [];
for (let item of mmsList) {
let map = {};
let map: LooseObject = {};
map.content = item.msgContent;
if(mmsPartMap.has(item.msgId)) {
map.content = mmsPartMap.get(item.msgId).content;
@ -801,9 +806,9 @@ export default {
map.isFavorite = item.isCollect == 0 ? false : true;
map.threadId = item.sessionId;
if (item.smsType == 0) {
map.icon = '/common/icon/user_avatar_full_fill.svg';
map.icon = 'icon/user_avatar_full_fill.svg';
} else {
map.icon = '/common/icon/entrance_icon01.svg';
map.icon = 'icon/entrance_icon01.svg';
}
map.groupId = item.groupId;
resultList.push(map);
@ -816,7 +821,7 @@ export default {
callback(resultList);
}
contractService.queryContactDataByTelephone(actionData, contacts => {
let groupIdMap = {};
let groupIdMap: LooseObject = {};
if (contacts.length == 0) {
groupIdMap = this.convertingMessageByGroup(resultList);
} else {
@ -854,7 +859,7 @@ export default {
});
},
getGroupIdMap(resultList, telephoneMap) {
let groupIdMap = {};
let groupIdMap: LooseObject = {};
for (let map of resultList) {
// 多人名称的组合,名称是需要组合展示
if (telephoneMap.has(map.telephone)) {
@ -876,7 +881,7 @@ export default {
return groupIdMap;
},
convertingMessageByGroup(resultList) {
let groupIdMap = {};
let groupIdMap: LooseObject = {};
for (let element of resultList) {
if (Object.keys(groupIdMap).indexOf(element.groupId) == -1) {
groupIdMap[element.groupId] = element;
@ -894,7 +899,7 @@ export default {
let searchText = actionData.inputValue;
actionData.content = searchText;
// 这里需要掉用查询详情
let result = {};
let result: LooseObject = {};
mConversationModel.searchMmsPartByContent(actionData, res => {
result.code = res.code;
if (res.code == common.int.SUCCESS) {
@ -910,7 +915,7 @@ export default {
callback(result);
});
} else {
mmsLog.info(CONVERSATION_TAG + 'Error: searchMmsPartByContent() failed !!!');
HiLog.w(TAG, 'searchMmsPartByContent, failed');
callback(result);
}
});
@ -950,7 +955,7 @@ export default {
* @return
*/
queryFromGallery(actionData, callback) {
let result = {};
let result: LooseObject = {};
mConversationModel.queryFromGallery(actionData, res => {
result.code = res.code;
result.pictureListFromGallery = res.abilityResult;
@ -965,15 +970,13 @@ export default {
* @return
*/
queryMessageThirty(actionData, callBack) {
let result = {};
mmsLog.info(CONVERSATION_TAG + 'queryMessageThirty, start:' + actionData);
let result: LooseObject = {};
mConversationModel.queryMessageThirty(actionData, res => {
mmsLog.info(CONVERSATION_TAG + 'queryMessageThirty, end:' + res);
result.code = res.code;
if (res.code == common.int.SUCCESS) {
result.response = res.abilityResult;
} else {
mmsLog.info(CONVERSATION_TAG + 'Error: queryMessageThirty() failed !!!');
HiLog.w(TAG, 'queryMessageThirty, failed');
}
callBack(result);
});
@ -985,12 +988,11 @@ export default {
* @param callback 回调
*/
insertManageSimData(actionData, callback) {
let rdbStore = actionData.rdbStore;
HiLog.i(TAG, 'insertManageSimData')
let sendResults = actionData.sendResults;
let value = this.dealSendResults(sendResults);
// 先判断是否创建过会话列表
conversationListService.querySessionByTelephone(rdbStore, value.telephone, res => {
mmsLog.info(CONVERSATION_TAG + 'insertManageSimData,querySessionByTelephone:' + res);
conversationListService.querySessionByTelephone(value.telephone, res => {
let response = res.response;
if (res.code == common.int.SUCCESS && response.id < 0) {
this.insertManageSimNoExiting(value, actionData, callback);
@ -1020,11 +1022,9 @@ export default {
'time': value.timestamp,
'message_count': 1
}
conversationListService.insertSession(actionData.rdbStore, valueBucket, sessionResult => {
conversationListService.insertSession(valueBucket, sessionResult => {
// 这里调用短信数据库,插入短信信息
mmsLog.info(CONVERSATION_TAG + 'insertSession,rowId:' + sessionResult);
this.dealInsertMessageDetail(value, actionData, sessionResult.rowId, res => {
mmsLog.info(CONVERSATION_TAG + 'dealInsertMessageDetail,initDatas:' + res);
let result = {
rowId: sessionResult.rowId,
initDatas: res.initDatas,
@ -1043,10 +1043,9 @@ export default {
statisticsUnreadNotify(actionData, callback) {
mConversationModel.statisticsUnreadNotify(actionData, res => {
if (res.code == common.int.SUCCESS) {
mmsLog.info('statisticsUnreadNotify result success ' + res);
callback(res.abilityResult);
} else {
mmsLog.info('statisticsUnreadNotify result err');
HiLog.w(TAG,'statisticsUnreadNotify, failed');
callback(0);
}
});
@ -1058,13 +1057,13 @@ export default {
* @param callback 返回值
*/
queryMmsPartByIds(actionData, callback) {
let result = {};
let result: LooseObject = {};
mConversationModel.queryMmsPart(actionData, res => {
result.code = res.code;
if (res.code == common.int.SUCCESS) {
result.response = res.abilityResult;
} else {
mmsLog.log(CONVERSATION_TAG + 'Error: queryMessageDetail() failed !!!');
HiLog.w(TAG, 'queryMmsPartByIds, failed');
}
callback(result);
});
@ -1077,14 +1076,14 @@ export default {
* @return
*/
queryMessageLockBySessionId(actionData, callback) {
let result = {};
mmsLog.info(CONVERSATION_TAG + 'queryMessageLockBySessionId() start');
let result: LooseObject = {};
HiLog.i(TAG, 'queryMessageLockBySessionId');
mConversationModel.queryMessageLockBySessionId(actionData, res => {
result.code = res.code;
if (res.code == common.int.SUCCESS) {
callback(res.abilityResult);
} else {
mmsLog.info(CONVERSATION_TAG + 'Error: queryMessageLockBySessionId() failed !!!');
HiLog.w(TAG, 'queryMessageLockBySessionId, failed');
callback(result);
}
});

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -14,11 +14,13 @@
*/
import wantAgent from '@ohos.wantAgent';
import notify from '@ohos.notification';
import common from '../pages/common_constants.js';
import mmsLog from '../utils/MmsLog.js';
import conversationService from '../service/ConversationService.js';
import common from '../data/commonData';
import HiLog from '../utils/HiLog';
import conversationService from './ConversationService';
const label = 'notification_';
const TAG = 'NotificationService';
export default {
/**
@ -36,8 +38,8 @@ export default {
notificationRequest.wantAgent = data;
notificationRequest.id = actionData.msgId;
notificationRequest.label = label + actionData.msgId;
notify.publish(notificationRequest);
mmsLog.log('notification finished');
// notify.publish(notificationRequest);
HiLog.i(TAG, 'sendNotify finished');
});
},
@ -48,7 +50,7 @@ export default {
* @return
*/
getWantAgent(agentInfo, callback) {
mmsLog.log('notification start:' + agentInfo);
HiLog.i(TAG, 'getWantAgent, agentInfo: ' + JSON.stringify(agentInfo));
wantAgent.getWantAgent(agentInfo).then(data1 => {
callback(data1);
});
@ -60,7 +62,10 @@ export default {
* @return
*/
buildWantAgentInfo(actionData) {
let parameters = {};
let parameters = {
pageFlag: '',
contactObjects: ''
};
parameters.pageFlag = 'conversation';
parameters.contactObjects = actionData.contactObjects;
let wantAgentInfo = {
@ -110,7 +115,7 @@ export default {
let count = 0;
for(let item of res.response) {
this.cancelNotify(parseInt(item.id), result => {
mmsLog.log('cancelNotify, success: ' + result);
HiLog.i(TAG, 'cancelMessageNotify, result: ' + JSON.stringify(result));
count ++;
if (count == res.response.length) {
callback(common.int.SUCCESS);
@ -122,19 +127,19 @@ export default {
cancelNotify(msgId, callback) {
notify.cancel(msgId, label + msgId, (err, data) => {
if (err) {
mmsLog.log('cancelNotify, error: ' + err);
HiLog.w(TAG, 'cancelNotify, error: ' + JSON.stringify(err));
callback(common.int.FAILURE);
}
mmsLog.log('cancelNotify success: ' + data);
HiLog.i(TAG, 'cancelNotify, success data: ' + JSON.stringify(data));
callback(common.int.SUCCESS);
});
},
cancelAllNotify() {
let promise = notify.cancelAll();
promise.then((ret) => {
mmsLog.log('cancelAllNotify success: ' + ret);
HiLog.i(TAG, 'cancelAllNotify, success ret: ' + JSON.stringify(ret));
}).catch((err) => {
mmsLog.log('cancelAllNotify, error: ' + err);
HiLog.e(TAG, 'cancelAllNotify, error: ' + JSON.stringify(err));
});
}
};

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -14,10 +14,12 @@
*/
import sms from '@ohos.telephony.sms';
import mmsLog from '../utils/MmsLog.js';
import common from '../pages/common_constants.js';
import HiLog from '../utils/HiLog';
import common from '../data/commonData';
import http from '@ohos.net.http';
const TAG = 'SendMsgService'
export default {
/**
@ -27,7 +29,13 @@ export default {
* @return
*/
sendMessage(params, callback) {
mmsLog.info('sendMessage,params:' + params);
HiLog.i(TAG, 'sendMessage, params: ' + JSON.stringify(params));
// let hasSmsCapability = sms.hasSmsCapability;
// HiLog.i(TAG, 'sendMessage, hasSmsCapability: ' + hasSmsCapability)
// sms.getDefaultSmsSlotId((err, data) => {
// HiLog.i(TAG, 'sendMessage, getDefaultSmsSlotId err: ' + JSON.stringify(err) + ', data: ' + JSON.stringify(data))
// });
sms.sendMessage({
slotId: params.slotId,
destinationHost: params.destinationHost,
@ -35,20 +43,20 @@ export default {
sendCallback: (err, value) => {
let sendStatus;
if (err) {
mmsLog.info('sendMessageService send message call back error');
sendStatus = common.int.SEND_MESSAGE_FAILED;
HiLog.w(TAG, 'sendMessage, sendCallback failed err: ' + JSON.stringify(err));
sendStatus = common.int.SEND_MESSAGE_SUCCESS;
} else {
mmsLog.info('sendMessageService send message call back success result = ' + value.result);
sendStatus = this.dealSendResult(value);
HiLog.i(TAG, 'sendMessage, sendCallback success result=' + value.result + ', sendStatus=' + sendStatus);
}
callback(sendStatus);
},
deliveryCallback: (err, value) => {
if (err) {
mmsLog.info('sendMessageService send message deliveryCallback err');
HiLog.w(TAG, 'sendMessage, deliveryCallback failed err: ' + JSON.stringify(err));
return;
}
mmsLog.info('sendMessageService send message deliveryCallback success sendResult = ' + value.pdu);
HiLog.i(TAG, 'sendMessage, deliveryCallback value: ' + JSON.stringify(value));
}
});
},
@ -62,11 +70,11 @@ export default {
return sendStatus;
},
sendMmsMessage(params, callback) {
mmsLog.info('sendMmsMessage,params:' + params);
HiLog.i(TAG, 'sendMmsMessage, params: ' + JSON.stringify(params));
let httpRequest = http.createHttp();
httpRequest.request(common.string.MMS_URL,
{
method: 'POST',
method: http.RequestMethod.POST,
header: {
'Content-Type': 'application/vnd.wap.mms-message',
'Accept': 'Accept',
@ -77,11 +85,11 @@ export default {
connectTimeout: 60000
}, (err, data) => {
let sendStatus;
if (!err) {
mmsLog.info('sendMmsMessage error:' + JSON.stringify(data));
sendStatus = common.int.SEND_MESSAGE_SUCCESS;
if (err) {
HiLog.i(TAG, 'sendMmsMessage, error: ' + JSON.stringify(err));
sendStatus = common.int.SEND_MESSAGE_FAILED;
} else {
mmsLog.info('error:' + err.data);
HiLog.w(TAG, 'sendMmsMessage, success data: ' + JSON.stringify(data));
sendStatus = common.int.SEND_MESSAGE_SUCCESS;
}
callback(sendStatus);

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -13,29 +13,29 @@
* limitations under the License.
*/
import SettingModel from '../model/settingsImpl/SettingsModel.js';
import SettingModel from '../model/SettingsModel';
let mSettingModel = new SettingModel();
import mmsLog from '../utils/MmsLog.js';
import common from '../pages/common_constants.js';
const TAG = 'JS->SettingService->';
import HiLog from '../utils/HiLog';
import common from '../data/commonData';
import LooseObject from '../data/LooseObject'
import preferences from '../utils/PreferencesUtil';
const TAG = 'SettingService';
export default {
/**
* 设置初始值
*
* @param {Object} preferences 偏量数据库
* @param {Object} callback 回调函数
*/
setOnSettingValueListener(preferences, callback) {
let result = {
setOnSettingValueListener(callback) {
let result: LooseObject = {
integrationSwitch: false,
maliciousWebSwitch: false,
showContactSwitch: false,
};
mSettingModel.setOnSettingValueListener(preferences, settingValue => {
mSettingModel.setOnSettingValueListener(settingValue => {
if (settingValue.integrationSwitch === common.bool.TRUE) {
result.integrationSwitch = true;
}
@ -52,11 +52,10 @@ export default {
/**
* 还原页面的默认值
*
* @param {Object} preferences 偏量数据库
* @param {Object} callback 回调函数
*/
restoreSwitchValue(preferences, callback) {
mSettingModel.restoreSwitchValueToDefault(preferences, callback);
restoreSwitchValue(callback) {
mSettingModel.restoreSwitchValueToDefault(callback);
},
/**
@ -67,56 +66,54 @@ export default {
* @return
*/
updateSettingValue(code, actionData, callback) {
let preferences = actionData.preferences;
switch (code) {
case common.route.MESSAGE_CODE_UPDATE_DELIVERY_REPORTS_VALUE:
// 送达报告
mSettingModel.updateSwitchValue(preferences, common.string.KEY_OF_DELIVERY_REPORT_SWITCH,
mSettingModel.updateSwitchValue(common.string.KEY_OF_DELIVERY_REPORT_SWITCH,
actionData.intValue, callback);
break;
case common.route.MESSAGE_CODE_UPDATE_AUTO_RETRIEVE_MMS_VALUE:
// 自动下载彩信
mSettingModel.updateSwitchValue(preferences, common.string.KEY_OF_AUTO_RETRIEVE_MMS_SWITCH,
mSettingModel.updateSwitchValue(common.string.KEY_OF_AUTO_RETRIEVE_SWITCH,
actionData.intValue, callback);
break;
case common.route.MESSAGE_CODE_UPDATE_RECALL_MESSAGES_VALUE:
// 取消发送
mSettingModel.updateSwitchValue(preferences, common.string.KEY_OF_RECALL_MESSAGE_SWITCH,
mSettingModel.updateSwitchValue(common.string.KEY_OF_RECALL_MESSAGE_SWITCH,
actionData.booleanValue, callback);
break;
case common.route.MESSAGE_CODE_UPDATE_AUTO_DELETE_INFO_MESSAGES_VALUE:
// 自动删除通知信息
mSettingModel.updateSwitchValue(preferences, common.string.KEY_OF_AUTO_DELETE_INFO_SWITCH,
mSettingModel.updateSwitchValue(common.string.KEY_OF_AUTO_DELETE_INFO_SWITCH,
actionData.booleanValue, callback);
break;
case common.route.MESSAGE_CODE_UPDATE_ARCHIVE_INFO_MESSAGES_VALUE:
// 通知信息整合
mSettingModel.updateSwitchValue(preferences, common.string.KEY_OF_INTEGRATION_SWITCH,
mSettingModel.updateSwitchValue(common.string.KEY_OF_INTEGRATION_SWITCH,
actionData.booleanValue, callback);
break;
case common.route.MESSAGE_CODE_UPDATE_MALICIOUS_WEBSITE_IDENTIFICATION_VALUE:
// 恶意网址识别
mSettingModel.updateSwitchValue(preferences, common.string.KEY_OF_MALICIOUS_WEB_SWITCH,
mSettingModel.updateSwitchValue(common.string.KEY_OF_MALICIOUS_WEB_SWITCH,
actionData.booleanValue, callback);
break;
case common.route.MESSAGE_CODE_UPDATE_SHOW_CONTACT_PROFILE_PICS_VALUE:
// 显示联系人头像
mSettingModel.updateSwitchValue(preferences, common.string.KEY_OF_SHOW_CONTACT_SWITCH,
mSettingModel.updateSwitchValue(common.string.KEY_OF_SHOW_CONTACT_SWITCH,
actionData.booleanValue, callback);
break;
default:
mmsLog.info('updateSettingValue code is not exit');
HiLog.w(TAG, 'updateSettingValue, code is not exit');
}
},
/**
* 获取高级设置页面开关值
*
* @param {Object} preferences 偏量数据库
* @param {Object} callback 回调函数
*/
getAdvancedPageSwitchValue(preferences, callback) {
mSettingModel.getAdvancedPageSwitchValue(preferences, callback);
getAdvancedPageSwitchValue(callback) {
mSettingModel.getAdvancedPageSwitchValue(callback);
},
/**
@ -128,9 +125,9 @@ export default {
updateSmscNumber(actionData) {
mSettingModel.updateSmscNumber(actionData, result => {
if (result.code == common.int.SUCCESS) {
mmsLog.info(TAG + 'autoHandleNumberChanged(): success');
HiLog.i(TAG, 'updateSmscNumber, success');
} else {
mmsLog.info(TAG + 'autoHandleNumberChanged(): fail');
HiLog.w(TAG, 'updateSmscNumber, fail');
}
});
},
@ -145,27 +142,25 @@ export default {
// 分享API目前未提供
mSettingModel.shareSmsEnterSelectedText(actionData, result => {
if (result.code == common.int.SUCCESS) {
mmsLog.info(TAG + 'shareInSmsCenter(): success');
HiLog.i(TAG, 'shareSmsEnterSelectedText, success');
} else {
mmsLog.info(TAG + 'shareInSmsCenter(): fail' + JSON.stringify(result.abilityResult));
HiLog.w(TAG, 'shareSmsEnterSelectedText, fail: ' + JSON.stringify(result.abilityResult));
}
});
},
/**
* 通知信息整合开关、是否显示联系人头像开关的值
*
* @param {Object} preferences 偏量数据库
*/
getSettingFlagForConvListPage(preferences) {
let result = {
getSettingFlagForConvListPage() {
let result: LooseObject = {
isShowContactHeadIcon: false,
hasAggregate: false,
recallMessagesFlag: false,
};
mSettingModel.getSettingValue(preferences, settingValue => {
mSettingModel.getSettingValue(settingValue => {
if (settingValue.code === common.int.SUCCESS) {
mmsLog.info('getSettingFlagForConvListPage(): Success');
HiLog.i(TAG, 'getSettingFlagForConvListPage, Success');
if (settingValue.abilityResult.isShowContactHeadIcon === common.bool.TRUE) {
result.isShowContactHeadIcon = true;
}
@ -176,7 +171,7 @@ export default {
result.recallMessagesFlag = true;
}
} else {
mmsLog.info('getSettingFlagForConvListPage(): fail');
HiLog.w(TAG, 'getSettingFlagForConvListPage, fail');
}
});
return result;
@ -185,10 +180,9 @@ export default {
/**
* 判断是否需要送达报告
*
* @param {Object} preferences 偏量数据库
* @param {boolean} isMms 是否是彩信
*/
judgeIsDeliveryReport(preferences, isMms) {
judgeIsDeliveryReport(isMms) {
let deliveryReportSwitch = preferences.getValueOfDeliveryReportSwitch();
if (deliveryReportSwitch === common.DELIVERY_REPORTS.DISABLED) {
return false;
@ -216,7 +210,7 @@ export default {
calculateChecked(simMessageList, isAllSelect){
let count = 0;
let checkedList = [];
let result = {};
let result: LooseObject = {};
let switchOff = false;
for(let item of simMessageList) {
// 如果全选

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -13,13 +13,15 @@
* limitations under the License.
*/
import CardModel from '../model/cardInfoImpl/CardModel.js'
import CardModel from '../model/CardModel'
let cardModel = new CardModel();
import common from '../pages/common_constants.js';
import mmsLog from '../utils/MmsLog.js';
import common from '../data/commonData';
import LooseObject from '../data/LooseObject'
import HiLog from '../utils/HiLog';
const TAG = 'SimCardService';
export default {
/**
@ -38,9 +40,9 @@ export default {
* @return
*/
querySmscNumber(actionData, callback) {
let result = {};
let result: LooseObject = {};
let index = actionData.index - 1;
mmsLog.log('querySmscNumber,slotId:' + index);
HiLog.i(TAG, 'querySmscNumber, slotId=' + index);
cardModel.getSmscNumber(index, actionData.preferences, smsNumber => {
result.code = common.int.SUCCESS;
result.smsNumber = smsNumber;

View File

@ -0,0 +1,461 @@
/**
* 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';
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)
}
}

View File

@ -0,0 +1,255 @@
/**
* 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 HiLog from './HiLog';
// 时间常量
const ONE_MINUTE_IN_MILLISECOND = 60000;
const ONE_HOUR_IN_MILLISECOND = 3600000;
const TAG = 'DateUtil';
export default {
/**
* 将item的时间戳转化为时间用于短信列表
*
* @param messageItem 单个item
* @param is24HourTime 是否是24小时
* @return
*/
convertDateFormatForItem(messageItem, is24HourTime) {
let now = new Date();
let currentDate = {
timeOfNow: now.getTime(),
yearOfNow: now.getFullYear(),
monthOfNow: now.getMonth() + 1,
dayOfNow: now.getDate()
};
let timeMillisecond = messageItem.timeMillisecond;
messageItem.time = this.convertTimeStampToTime(timeMillisecond, currentDate, is24HourTime);
},
/**
* 将时间戳转化为时间(用于短信列表)
*
* @param timeStampFromDb 需转换的时间轴
* @param currentDate 当前时间
* @param is24HourTime 是否24小时制
* @return
*/
convertTimeStampToTime(timeStampFromDb, currentDate, is24HourTime) {
let sms = new Date(timeStampFromDb);
let timeStampOfSms = sms.getTime();
let yearOfSms = sms.getFullYear();
let monthOfSms = sms.getMonth() + 1;
let dayOfSms = sms.getDate();
let hoursOfSms = sms.getHours();
let minutesOfSms = sms.getMinutes();
let diff = currentDate.timeOfNow - timeStampOfSms;
if (currentDate.yearOfNow == yearOfSms && currentDate.monthOfNow == monthOfSms
&& 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));
} else {
let hoursOfSmsStr: string = '' + hoursOfSms;
let minutesOfSmsStr: string = '' + minutesOfSms;
if (hoursOfSms < 10) {
hoursOfSmsStr = '0' + hoursOfSms;
}
if (minutesOfSms < 10) {
minutesOfSmsStr = '0' + minutesOfSms;
}
if (is24HourTime) {
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');
} else if (currentDate.yearOfNow == yearOfSms) {
return $r('app.string.monthDay', monthOfSms, dayOfSms);
} else {
return $r('app.string.yearMonthDay', yearOfSms, monthOfSms, dayOfSms);
}
},
timeTwelveHourSystem(hoursOfSms, minutesOfSmsStr, hoursOfSmsStr) {
let time = common.string.EMPTY_STR;
if (hoursOfSms <= 12) {
time = this.morningTimeTwelveHourSystem(hoursOfSms, minutesOfSmsStr, hoursOfSmsStr);
} else {
time = this.afterTimeTwelveHourSystem(hoursOfSms, minutesOfSmsStr, hoursOfSmsStr);
}
return time;
},
morningTimeTwelveHourSystem(hoursOfSms, minutesOfSmsStr, hoursOfSmsStr) {
let time: Resource = null;
// 12小时制
if (hoursOfSms < 1) {
time = $r('app.string.postMidnight', 12 + '', minutesOfSmsStr);
}
if (hoursOfSms >= 1 && hoursOfSms < 4) {
time = $r('app.string.beforeDawn', hoursOfSmsStr, minutesOfSmsStr);
}
if (hoursOfSms >= 4 && hoursOfSms < 6) {
time = $r('app.string.earlyMorning', hoursOfSmsStr, minutesOfSmsStr);
}
if (hoursOfSms >= 6 && hoursOfSms < 9) {
time = $r('app.string.morning', hoursOfSmsStr, minutesOfSmsStr);
}
if (hoursOfSms >= 9 && hoursOfSms < 11) {
time = $r('app.string.forenoon', hoursOfSmsStr, minutesOfSmsStr);
}
if (hoursOfSms >= 11 && hoursOfSms <= 12) {
time = $r('app.string.preNoon', hoursOfSms + '', minutesOfSmsStr);
}
return time;
},
afterTimeTwelveHourSystem(hoursOfSms, minutesOfSmsStr, hoursOfSmsStr) {
let time: Resource = null;
if (hoursOfSms > 12 && hoursOfSms < 13) {
time = $r('app.string.postNoon', hoursOfSms + '', minutesOfSmsStr);
}
if (hoursOfSms >= 13 && hoursOfSms < 17) {
time = $r('app.string.afternoon', (hoursOfSms - 12) + '', minutesOfSmsStr);
}
if (hoursOfSms >= 17 && hoursOfSms < 19) {
time = $r('app.string.towardEvening', (hoursOfSms - 12) + '', minutesOfSmsStr);
}
if (hoursOfSms >= 19 && hoursOfSms < 23) {
time = $r('app.string.evening', (hoursOfSms - 12) + '', minutesOfSmsStr);
}
if (hoursOfSms >= 23) {
time = $r('app.string.preMidnight', (hoursOfSms - 12) + '', minutesOfSmsStr);
}
return time;
},
/**
* 将时间进行转化
* @param messageItem 单个item
* @param is24HourTime 是否是24小时
* @param that
* @return
*/
convertTimeStampToDateWeek(messageItem, is24HourTime) {
let now = new Date();
let yearOfNow = now.getFullYear();
let monthOfNow = now.getMonth() + 1;
let dayOfNow = now.getDate();
let timeMillisecond = messageItem.timeMillisecond;
messageItem.date = this.convertTimeStampToDate(timeMillisecond, yearOfNow, monthOfNow, dayOfNow);
},
/**
* 把时间戳形式转换为日期形式
*/
convertTimeStampToDate(timeStampFromDb, yearOfNow, monthOfNow, dayOfNow) {
let date: Resource = null;
let sms = new Date(timeStampFromDb);
let yearOfSms = sms.getFullYear();
let monthOfSms = sms.getMonth() + 1;
let dayOfSms = sms.getDate();
let weekOfSms = sms.getDay();
if (yearOfNow == yearOfSms && monthOfNow == monthOfSms && dayOfNow == dayOfSms) {
date = $r('app.string.recentDateToday', this.getWeek(weekOfSms));
} else if (yearOfNow == yearOfSms && monthOfNow == monthOfSms && dayOfNow - dayOfSms == 1) {
date = $r('app.string.recentDateYesterday', this.getWeek(weekOfSms));
} else if (yearOfNow == yearOfSms) {
date = $r('app.string.monthDayDate', monthOfSms, dayOfSms, this.getWeek(weekOfSms));
} else {
date = $r('app.string.yearMonthDayDate', yearOfSms, monthOfSms, dayOfSms, this.getWeek(weekOfSms));
}
return date;
},
/**
* 获取星期/周几
* @param day
* @param that
* @return
*/
getWeek(day) {
let week: Resource = null;
switch (day) {
case 0:
week = $r('app.string.Sunday');
break;
case 1:
week = $r('app.string.Monday');
break;
case 2:
week = $r('app.string.Tuesday');
break;
case 3:
week = $r('app.string.Wednesday');
break;
case 4:
week = $r('app.string.Thursday');
break;
case 5:
week = $r('app.string.Friday');
break;
case 6:
week = $r('app.string.Saturday');
break;
}
return week;
},
convertTimeStampDate(timeStampFromDb) {
let sms = new Date(timeStampFromDb);
let yearOfSms = sms.getFullYear();
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;
return date;
},
/**
*
* @param timeStampFromDb
* @param is24HourTime
* @param that
* @return
*/
convertTimeStampTime(timeStampFromDb, is24HourTime) {
let sms = new Date(timeStampFromDb);
let hoursOfSms = sms.getHours();
let minutesOfSms = sms.getMinutes();
let hoursOfSmsStr: string = hoursOfSms + '';
let minutesOfSmsStr: string = minutesOfSms + '';
if (hoursOfSms < 10) {
hoursOfSmsStr = '0' + hoursOfSms;
}
if (minutesOfSms < 10) {
minutesOfSmsStr = '0' + minutesOfSms;
}
if (is24HourTime) {
// 24小时制
return $r('app.string.hourAndMinute', hoursOfSmsStr, minutesOfSmsStr);
}
return this.timeTwelveHourSystem(hoursOfSms, minutesOfSmsStr, hoursOfSmsStr);
}
}

View File

@ -0,0 +1,62 @@
/**
* 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.
*
* @author m00445151
* @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);
}
}

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -13,30 +13,28 @@
* limitations under the License.
*/
import common from '../../default/pages/common_constants.js';
import appStorage from './AppStorageUtil';
import common from '../data/commonData';
import dataStorage from '@ohos.data.storage';
import featureAbility from '@ohos.ability.featureAbility';
import mmsLog from '../utils/MmsLog.js';
const TAG = 'PreferencesUtil.js->';
import HiLog from './HiLog';
const TAG = 'PreferencesUtil';
var prefIns = undefined;
/**
* 获取轻量级偏好数据库实例
*/
export default {
async initDataStorage() {
let context = featureAbility.getContext();
let path = await context.getFilesDir();
prefIns = dataStorage.getStorageSync(path + common.string.PATH_OF_PREFERENCES);
return dataStorage.getStorageSync(path + common.string.PATH_OF_PREFERENCES);
},
getPreferencesInstance() {
if (prefIns == null) {
mmsLog.error(TAG + 'getPreferencesInstance(): failed to get preferences instance');
}
return prefIns;
return appStorage.getPreferences();
},
/**
@ -49,41 +47,65 @@ export default {
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) {
@ -103,26 +125,41 @@ export default {
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);
@ -132,8 +169,9 @@ export default {
* 给设置值
*/
setValueForSwitch(keyOfSwitch, valueOfSwitch) {
mmsLog.info('setValueForSwitch start:' + keyOfSwitch + 'valueOfSwitch:' + valueOfSwitch);
let prefIns = this.getPreferencesInstance();
HiLog.i(TAG, 'setValueForSwitch, keyOfSwitch=' + keyOfSwitch + ', valueOfSwitch=' + valueOfSwitch);
prefIns.putSync(keyOfSwitch, valueOfSwitch);
prefIns.flushSync();
}
};
}

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -13,56 +13,43 @@
* limitations under the License.
*/
import ohosDataRdb from '@ohos.data.rdb';
import mmsLog from '../utils/MmsLog.js';
import HiLog from './HiLog';
import mmsTable from '../data/tableData';
const TAG = 'RdbStoreUtil.js->';
const TAG = 'RdbStoreUtil';
// 数据库名称
const STORE_CONFIG = {
name: 'mmssms.db',
}
// 数据库实例对象
var rdbStore = undefined;
/**
* 创建数据库
*/
var getRdbStore = async function () {
if (rdbStore == null) {
rdbStore = await ohosDataRdb.getRdbStore(STORE_CONFIG, 1);
}
return rdbStore;
}
export default {
/**
* 创建数据库
*/
async createRdbStore() {
mmsLog.log(TAG + ' createRdbStore start');
rdbStore = await ohosDataRdb.getRdbStore(STORE_CONFIG, 1);
mmsLog.log(TAG + ' createRdbStore end');
},
/**
* 创建数据库表
*/
async createTable(table) {
await rdbStore.executeSql(table, null);
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) => {
mmsLog.log(TAG + ' insert first done: ' + rowId);
HiLog.i(TAG, 'insert, first done: ' + rowId);
rowId = ret;
}).catch((err) => {
mmsLog.log(TAG + ' insert first done: ' + err);
HiLog.e(TAG, 'insert, first fail: ' + JSON.stringify(err));
})
await insertPromise;
return rowId;
@ -75,8 +62,9 @@ export default {
* @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);
mmsLog.log(TAG + 'updated row count: ' + changedRows);
HiLog.i(TAG, 'update, changedRows=' + changedRows);
},
/**
@ -85,8 +73,9 @@ export default {
* @return
*/
async deleteItem(predicates) {
let rdbStore = await ohosDataRdb.getRdbStore(mmsTable.DB.MMSSMS.config, mmsTable.DB.MMSSMS.version);
let deletedRows = await rdbStore.delete(predicates);
mmsLog.log(TAG + 'deleted row count: ' + deletedRows);
HiLog.i(TAG, 'deleteItem, deletedRows=' + deletedRows);
},
/**
@ -97,14 +86,5 @@ export default {
getRdbPredicates(tableName){
let predicates = new ohosDataRdb.RdbPredicates(tableName);
return predicates;
},
/**
* 获取数据库实例
* @param tableName 表名
* @return
*/
getRdbStore() {
return rdbStore;
}
}

View File

@ -0,0 +1,76 @@
/**
* 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<void> {
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<string> {
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<string> {
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<string> {
await this.initResourceManager();
return await this.resMgr.getConfiguration();
}
}
let resourceUtil = new ResourceUtil();
export default resourceUtil as ResourceUtil;

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
@ -12,11 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const APP_TAG = 'Telephone: js ';
import common from '../pages/common_constants.js';
import mmsLog from '../utils/MmsLog.js';
import common from '../data/commonData';
import HiLog from './HiLog';
import call from '@ohos.telephony.call';
const TAG = 'TelephoneUtil';
/**
* log package tool class
*/
@ -146,7 +146,7 @@ export default {
},
async formatPhoneNumber(phoneNumber) {
if (phoneNumber == null || phoneNumber === common.string.EMPTY_STR) {
mmsLog.info('formatPhoneNumber param is null');
HiLog.w(TAG, 'formatPhoneNumber, param is null');
return common.string.EMPTY_STR;
}
let promise = call.formatPhoneNumber(phoneNumber);
@ -154,7 +154,7 @@ export default {
promise.then((value) => {
formatPhoneNumber = value;
}).catch((err) => {
mmsLog.info('formatPhoneNumber error: ' + err.message);
HiLog.e(TAG, 'formatPhoneNumber, error: ' + JSON.stringify(err));
});
await promise;
return formatPhoneNumber;

View File

@ -0,0 +1,238 @@
/**
* 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.
*/
/**
* 弹框种类无标题1个消息2个按钮
*/
@CustomDialog
export struct DeleteDialog {
controller: CustomDialogController;
/**
* 取消事件
*/
cancel: () => void;
/**
* 确认事件
*/
confirm: () => void;
/**
* 消息内容
*/
msg: string | Resource;
/**
* 删除的信息中,是否包含锁定的信息
*/
hasLockMsg: boolean;
setSelectLock?: () => void;
/**
* 是否同步删除锁定信息勾选项
*/
isSelectLockMsg?: boolean;
setSelectLockChange?: (isOn: boolean) => void;
build() {
Column() {
Text(this.msg).width('100%').margin({ bottom: 8 }).textAlign(TextAlign.Center).fontSize(16)
.fontColor('#182431').lineHeight(22).fontWeight(FontWeight.Regular).fontFamily('HarmonyHeiTi')
if (this.hasLockMsg) {
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Toggle({ type: ToggleType.Checkbox, isOn: this.isSelectLockMsg })
.width('20vp')
.height('20vp')
.onChange((isOn: boolean) => {
this.setSelectLockChange(isOn)
})
Text($r("app.string.msg_delete_dialog_cb_tip")).height('100%')
}
.width('100%')
.height('32vp')
.onClick((event?: ClickEvent) => {
this.setSelectLock();
})
}
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {
Button() {
Text($r("app.string.cancel"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor('#007DFF')
.fontWeight(FontWeight.Medium)
.fontFamily('HarmonyHeiTi')
.lineHeight(22)
.onClick(() => {
this.controller.close();
this.cancel();
})
}.backgroundColor($r("app.color.back_Transparent")).layoutWeight(1)
Divider().vertical(true).strokeWidth('2px').height('20vp').color(Color.Gray)
Button() {
Text($r("app.string.delete"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor('#FA2A2D')
.fontWeight(FontWeight.Medium)
.fontFamily('HarmonyHeiTi')
.lineHeight(22)
.onClick(() => {
this.controller.close();
this.confirm();
})
}.backgroundColor($r("app.color.back_Transparent")).layoutWeight(1)
}
.width('100%')
.height(40)
}
.width('100%')
.padding( {left: 24, right: 24, top: 24, bottom: 16} )
}
}
/**
* 弹框种类:重置弹框
*/
@CustomDialog
export struct RestoreDialogs {
controller: CustomDialogController
/**
* 取消事件
*/
cancel: () => void
/**
* 确认事件
*/
confirm: () => void
/**
* 消息内容
*/
msg: string | Resource
build() {
// Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.End }) {
Column() {
Text(this.msg).width('100%').margin({ top: '16vp', bottom: '8vp' }).textAlign(TextAlign.Center).fontSize(14)
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {
Text($r("app.string.cancel"))
.fontSize(16)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.fontColor(Color.Blue)
.onClick(() => {
this.controller.close()
this.cancel()
})
Divider().vertical(true).strokeWidth('2px').height('20vp').color(Color.Gray)
Text($r("app.string.restore"))
.fontSize(16)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Center)
.fontColor(Color.Blue)
.onClick(() => {
this.controller.close()
this.confirm()
})
}
.margin({ top: '4vp', bottom: '16vp' })
}
.width('100%')
.padding('8vp')
}
}
export interface CheckBoxItem {
title: string | Resource;
isOn: boolean;
onClick: (event?: ClickEvent) => void;
}
/**
* 弹框种类1标题2个勾选项2按钮
*/
@CustomDialog
export struct CheckBoxDialog {
controller: CustomDialogController;
/**
* 取消事件
*/
cancel: () => void;
/**
* 确认事件
*/
confirm: () => void;
/**
* 标题
*/
title: string | Resource;
/**
* 选项集合
*/
@State itemList: Array<CheckBoxItem> = [];
build() {
Column() {
// dialog标题
Text(this.title).width('100%').margin({ bottom: 8 }).fontSize(16)
.fontColor('#182431').lineHeight(22).fontWeight(FontWeight.Regular).fontFamily('HarmonyHeiTi')
// item勾选列表
ForEach(this.itemList, (item, index) => {
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Text(item.title)
Toggle({ type: ToggleType.Checkbox, isOn: item.isOn})
.width('20vp')
.height('20vp')
.enabled(false)
}
.width('100%')
.height('32vp')
.onClick(item.onClick)
}, (item, index) => index.toString())
// 确定和取消按钮
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {
Button() {
Text($r("app.string.cancel"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor('#007DFF')
.fontWeight(FontWeight.Medium)
.fontFamily('HarmonyHeiTi')
.lineHeight(22)
.onClick(() => {
this.controller.close();
this.cancel();
})
}.backgroundColor($r("app.color.back_Transparent")).layoutWeight(1)
Divider().vertical(true).strokeWidth('2px').height('20vp').color(Color.Gray)
Button() {
Text($r("app.string.ok"))
.textAlign(TextAlign.Center)
.fontSize(16)
.fontColor('#007DFF')
.fontWeight(FontWeight.Medium)
.fontFamily('HarmonyHeiTi')
.lineHeight(22)
.onClick(() => {
this.controller.close();
this.confirm();
})
}.backgroundColor($r("app.color.back_Transparent")).layoutWeight(1)
}
.width('100%')
.height(40)
}
.width('100%')
.padding( {left: 24, right: 24, top: 24, bottom: 16} )
}
}

View File

@ -0,0 +1,180 @@
/**
* 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) {
//是否需要加未读标志红点
if (this.item.countOfUnread > 0) {
Badge({
count: this.item.countOfUnread,
maxCount: 99,
style: { color: 0xFFFFFF, fontSize: '10fp', badgeSize: '16vp', badgeColor: Color.Red }
}) {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile(this.item.icon))
.width('40vp')
.height('40vp')
}
.onClick(this.onClickHead)
}
.width('40vp')
.height('40vp')
} else {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Image($rawfile(this.item.icon))
}
.width('40vp')
.height('40vp')
.onClick(this.onClickHead)
}
}
//body
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Start }) {
if (this.index != 0) {
Divider().vertical(false)
.width('100%').height('1vp')
.color(Color.Gray)
}
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center }) {
Flex({ direction: FlexDirection.Row,
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
//电话号码或名字
Text(this.item.name != '' ? this.item.name : this.item.telephoneFormat)
.fontSize('16fp')
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontColor('#191919')
.maxLines(1)
//日期时间
Text(this.item.time)
.fontColor(Color.Gray)
.fontSize('12fp')
}.width('100%')
//最新消息的内容缩略语
Row() {
//最新的消息是否未发送成功,如果是
if (this.item.sendingFailed) {
Text($r("app.string.messageSendFailed"))
.fontSize('12fp')
.fontColor(Color.Red)
} else {
//如果不是
Text() {
//最新的消息是否是草稿,如果是
if (this.item.isDraft) {
Span($r("app.string.draft"))
.fontSize('14fp')
.fontColor(Color.Red)
}
//如果不是,且未读的消息个数>1条
if (!this.item.isDraft && this.item.countOfUnread > 1) {
Span($r("app.string.multiUnread", this.item.countOfUnread))
.fontSize('14fp')
.fontColor('#666666')
}
//最新消息的内容缩略语
Span(this.item.content)
.fontSize('14fp')
.fontColor('#666666')
}
.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.isCbChecked })
.width('20vp')
.height('20vp')
.enabled(false)
}
}
.width('100%')
.height('100%')
.padding({ left: '24vp', right: '24vp' })
.translate({
x: this.item.itemLeft
})
//左滑的删除图标
if (!this.isMultipleSelectState) {
Flex({
direction: FlexDirection.Row,
justifyContent: FlexAlign.Center,
alignItems: ItemAlign.Center
}) {
if (this.item.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: '24vp' })
.translate({
x: this.item.itemLeft
})
}
}
.width('100%')
.height('100%')
.gesture(PanGesture({ direction: this.item.isDelShow ? PanDirection.Right : PanDirection.Left })
.onActionStart(this.onTouchStart)
.onActionUpdate(this.onTouchUpdate)
.onActionEnd(this.onTouchEnd)
)
}
.onClick(this.onClickBody)
.gesture(LongPressGesture().onAction(this.onItemLongPress))
}
}

View File

@ -0,0 +1,126 @@
/**
* 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.
*/
/**
* 设置项双标题1开关
*/
@Component
export struct SettingItemSwitch {
primaryTitle: string | Resource;
secondaryTitle?: string | Resource;
isEnable: boolean;
showBottomDivider ?: boolean = false;
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 })
.width($r('app.float.settings_item_switch_width'))
.onChange(this.onChange)
}
.layoutWeight(1)
if (this.showBottomDivider) {
Divider().vertical(false).strokeWidth(1).color($r("app.color.default_main_background")).lineCap(LineCapStyle.Round)
}
}
.width('100%')
.height(this.secondaryTitle != undefined ? $r('app.float.settings_item_height_2') : $r('app.float.settings_item_height_1'))
}
}
/**
* 设置项:双标题,一个状态、一个下页图标
*/
@Component
export struct SettingItemJump {
primaryTitle : string | Resource;
secondaryTitle ?: string | Resource;
@State statusTitle ?: string | Resource = "";
showBottomDivider ?: boolean = false;
onClick: (event?: ClickEvent) => void;
isVisible: Visibility = Visibility.Visible;
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.default_main_background")).lineCap(LineCapStyle.Round)
}
}
.width('100%')
.height(this.secondaryTitle != undefined ? $r('app.float.settings_item_height_2') : $r('app.float.settings_item_height_1'))
.visibility(this.isVisible)
}
}

View File

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

View File

@ -0,0 +1,414 @@
/**
* 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 featureAbility from '@ohos.ability.featureAbility';
import LooseObject from '../../data/LooseObject'
let ReceiveCtrl;
const TAG = 'ReceiveController';
export default class ReceiveController {
paramContact: LooseObject = {};
// 收件人信息(已经选择)
selectContacts: Array<any> = [];
contacts: Array<any> = [];
// 收件人列表信息(所有的)
contactsTemp: Array<any> = [];
// 收件人内容
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 (ReceiveCtrl == null) {
ReceiveCtrl = new ReceiveController();
appStorage.setAndLink('ReceiveController', ReceiveCtrl);
}
return ReceiveCtrl;
}
onInit(call) {
this.selectContacts = this.paramContact.transmitContracts;
// this.$watch('paramContact', 'onPropertyChange');
if (this.selectContacts.length > 0) {
let that = this;
setTimeout(function () {
that.setContactValue(call);
}, 200);
this.isShowSearch = false;
this.setInputStatus(false);
}
this.requestItem()
}
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();
}
}
changeMyText(value) {
HiLog.i(TAG, 'changeMyText: ' + value);
this.myText = value;
}
queryContacts() {
let actionData = {
page: this.page,
limit: this.limit
};
// 查询联系人
contractService.queryContact(actionData, contacts => {
HiLog.i(TAG, 'queryContact, contracts:' + JSON.stringify(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.styleTextarea = 'select-contact-textarea';
} else {
this.styleTextarea = 'content-addressee-text';
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 = '/common/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.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.setInputStatus(false);
this.isShowSearch = false;
}
}
searchChange(text, call) {
HiLog.d(TAG, 'searchChange, start');
this.myText = text;
if (!this.isInputStatus) {
HiLog.w(TAG, 'searchChange, isInputStatus false');
return;
}
// this.searchContacts(this.myText, code => {
// if (code == common.int.SUCCESS) {
this.setContactValue(call);
HiLog.d(TAG, 'searchChange, textValue: ' + this.myText);
this.dealSearchData();
this.setContactValue(call);
// }
// });
}
dealSearchData() {
if (false) {
this.contacts = this.contactsTemp.slice(0);
// this.$element('receiveTxt').focus({
// focus: true
// });
} else {
let textValue = this.myText.toLowerCase();
// 过滤逻辑
this.filterContacts(textValue);
HiLog.d(TAG, 'dealSearchData, contact: ' + JSON.stringify(this.contacts))
}
}
setContactValue(call) {
// 将收件人信息,传给调用的父组件
call({
// 输入框的内容
contactValue: this.myText,
// 已经选择的收件人信息
selectContacts: this.selectContacts,
// 焦点是否丢失
hasBlur: this.hasBlur
});
}
addContact(index) {
let curItem = this.contacts[index];
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;
// 未开发list区域暂传null
this.setContactValue(null);
} else {
this.setInputStatus(true);
this.isShowSearch = true;
// 未开发list区域暂传null
this.setContactValue(null);
}
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) {
if (this.selectContacts[idx].select) {
let item = this.selectContacts.splice(idx, 1);
// 已经删除的添加到 需要搜索的集合
this.contactsTemp.push(item);
this.contacts.push(item[0]);
return;
}
for (let element of this.selectContacts) {
element.select = false;
}
this.selectContacts[idx].select = true;
}
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) => {
HiLog.i(TAG, 'jumpToContract, data: ' + JSON.stringify(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);
for (let element of params) {
let selectContact: LooseObject = {};
selectContact.headImage = '/common/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.paramContact.isSelectContact = false;
this.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);
}
}
}
}

View File

@ -1,92 +0,0 @@
/**
* Copyright (c) 2021 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 mmsLog from '../default/utils/MmsLog.js';
import featureAbility from '@ohos.ability.featureAbility';
import ohosDataAbility from '@ohos.data.dataability';
import sendMsgService from '../default/service/SendMsgService.js';
import conversationListService from '../default/service/ConversationListService.js';
import notificationService from '../default/service/NotificationService.js';
import commonService from '../default/service/CommonService.js';
import rdbStore from '../default/utils/RdbStoreUtil.js';
import dateUtil from '../../js/default/pages/DateUtil.js';
import preferences from '../default/utils/PreferencesUtil.js';
const TAG = 'app.js->';
export default {
globalData: {
// 是否展示通知信息
hasInfoMsg: true,
},
onCreate() {
mmsLog.info(TAG + 'onCreate(): start, AceApplication onCreate');
mmsLog.info(TAG + 'onCreate(): end, AceApplication onCreate');
},
onDestroy() {
mmsLog.info(TAG + 'onDestroy(): AceApplication onDestroy');
},
// full_screen_show_picture页面中图片或视频的index
indexInShowPicPage: null,
// full_screen_show_picture页面中图片或视频的checkbox的值
checkedValueInShowPicPage: null,
// contact_item_pick页面中的电话号码列表
oneContactInContactItemPickPage: null,
// 全屏发送值
textValueOther: '',
// 全屏发送标记
sendFlag: false,
// 转发发送的标记
transmitFlag: false,
// 转发内容
transmitContent: '',
// 转发的内容包含彩信
transmitContents: [],
isSlideDetail: false,
mmsSource: [],
transmitSource: [],
isContainerOriginSource: false,
// 卡的槽位
slotId: 0,
// 列表Id
threadId: '',
// 联系人数量
contactsNum: 0,
// 联系人名称
strContactsName: '',
// 联系人号码
strContactsNumber: '',
// 格式化联系人号码
strContactsNumberFormat: '',
// 跳转三方应用使用
featureAbility: featureAbility,
// 查询数据库使用
ohosDataAbility: ohosDataAbility,
// 发送短信的服务
sendMsgService: sendMsgService,
// 消息通知
notificationService: notificationService,
// 列表数据查询
conversationListService: conversationListService,
// 公共的服务处理
commonService: commonService,
// 数据库操作
rdbStore: rdbStore,
// 时间类转化
dateUtil: dateUtil,
// 是否从全屏界面回来
isFromFullScreen: false,
// 偏量数据库
preferences: preferences
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

View File

@ -1,45 +0,0 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg t="1619159496732"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="6051"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<defs>
<style type="text/css"></style>
</defs>
<path
d="M277.9 742s167.9-294.1 465.3-465.3C575.7 577.8 277.9 742 277.9 742z"
fill="#FFFFFF"
p-id="6052"></path>
<path
d="M743.1 742S575.2 447.9 277.8 276.7C445.3 577.8 743.1 742 743.1 742z"
fill="#FFFFFF"
p-id="6053"></path>
<path
d="M284.1 343m-49 0a49 49 0 1 0 98 0 49 49 0 1 0-98 0Z"
fill="#FFFFFF"
p-id="6054"></path>
<path
d="M284.1 515.5m-49 0a49 49 0 1 0 98 0 49 49 0 1 0-98 0Z"
fill="#FFFFFF"
p-id="6055"></path>
<path
d="M284.1 683.5m-49 0a49 49 0 1 0 98 0 49 49 0 1 0-98 0Z"
fill="#FFFFFF"
p-id="6056"></path>
<path
d="M808.4 341.6s-208.5-61.2-420 0c211.5 64.8 420 0 420 0zM808.4 516.6s-208.5-61.2-420 0c211.5 64.8 420 0 420 0zM808.4 684.6s-208.5-61.2-420 0c211.5 64.8 420 0 420 0z"
fill="#FFFFFF"
p-id="6057"></path>
<path
d="M512 512m-448 0a448 448 0 1 0 896 0 448 448 0 1 0-896 0Z"
fill="#0EC469"
p-id="6058"></path>
<path
d="M701.4 786.8h-0.3c-3.2-0.3-6.4-0.8-9.5-1.4C290 725.2 237.2 331.5 237.2 331.5h0.1c-5.9-27.8 0.8-56.8 22.5-78.5 9.5-9.5 22.5-18.1 31.3-19.2l111.6 111.6c-1.1 8.8-9.6 21.7-19.1 31.2-8.5 8.5-17.9 14.4-28.4 18.6 57.7 214.5 272.1 271.5 272.1 271.5l0.3 0.2c4.2-10.5 9.6-19.3 18.1-27.8 9.5-9.5 22.6-18.1 31.4-19.2l111.6 111.6c-1.1 8.8-9.6 21.7-19.1 31.2-18.9 19-43.4 26.3-68.2 24.1z"
fill="#FFFFFF"
p-id="6059"></path>
</svg>

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -1 +0,0 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1614067034652" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2953" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><style type="text/css"></style></defs><path d="M508.825 348.442c-105.26 0-190.923 85.173-190.923 189.871 0 104.699 85.664 189.906 190.923 189.906 105.259 0 190.892-85.207 190.892-189.906s-85.633-189.871-190.892-189.871M508.825 669.607c-72.846 0-132.082-58.91-132.082-131.295 0-72.383 59.236-131.261 132.082-131.261 72.814 0 132.081 58.876 132.081 131.261 0.001 72.385-59.267 131.295-132.081 131.295z" p-id="2954"></path><path d="M964.276 772.070h-0.756c-0.229 0.623-0.623 1.217-0.954 1.775v-483.918c0-30.588-25.015-55.472-55.751-55.472h-168.93l-0.955-1.841-21.827-43.391c-2.497-5.556-24.819-53.024-55.227-53.024h-296.381c-31.097 0-54.009 50.361-54.962 52.514l-22.090 43.901-0.955 1.841h-168.964c-30.734 0-55.751 24.884-55.751 55.472v540.229c0 30.605 25.018 55.489 55.751 55.489h790.291c30.735 0 55.751-24.884 55.751-55.489v-55.718c0.559-0.79 1.215-1.514 1.709-2.368M900.438 805.601c0 10.027-8.218 18.211-18.343 18.211h-740.867c-10.091 0-18.342-8.185-18.342-18.211v-495.26c0-10.043 8.251-18.179 18.342-18.179h170.724l9.697-8.317 37.573-58.365c4.374-7.545 19.166-27.418 33.958-27.418h237.045c17.814 0 34.121 27.647 34.317 27.909l37.541 58.415 8.383 6.394 171.726-0.607c10.123 0 18.342 8.166 18.342 18.211v452.54c0 0.163-0.098 0.295-0.098 0.461v44.215z" p-id="2955"></path><path d="M897.38 771.183h0.066v-0.394l-0.066 0.394z" p-id="2956"></path></svg>

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

View File

@ -1,23 +0,0 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg t="1613336499825"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="26801"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<defs>
<style type="text/css"></style>
</defs>
<path
d="M938.666667 512c0 235.648-191.018667 426.666667-426.666667 426.666667S85.333333 747.648 85.333333 512 276.352 85.333333 512 85.333333s426.666667 191.018667 426.666667 426.666667z"
fill="#007DFF"
p-id="26802">
</path>
<path
d="M725.333333 512a213.333333 213.333333 0 1 1-426.666666 0 213.333333 213.333333 0 0 1 426.666666 0z"
fill="#FFFFFF"
p-id="26803">
</path>
</svg>

Before

Width:  |  Height:  |  Size: 843 B

View File

@ -1,18 +0,0 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg t="1613336799963"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="29625"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<style type="text/css"></style>
</defs>
<path
d="M512 896a384 384 0 1 1 0-768 384 384 0 0 1 0 768z m0 42.666667c235.648 0 426.666667-191.018667 426.666667-426.666667S747.648 85.333333 512 85.333333 85.333333 276.352 85.333333 512s191.018667 426.666667 426.666667 426.666667z"
fill="#2c2c2c"
fill-opacity=".5"
p-id="29626">
</path>
</svg>

Before

Width:  |  Height:  |  Size: 732 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="160px" height="160px" viewBox="0 0 160 160" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 64 (93537) - https://sketch.com -->
<title>delete</title>
<desc>Created with Sketch.</desc>
<defs>
<circle id="path-1" cx="80" cy="80" r="80"></circle>
<path d="M68.7945672,19.3089519 L64.6613061,70.5361569 C64.3819152,73.9988988 61.4902292,76.6666667 58.0162343,76.6666667 L21.9951565,76.6666667 C18.5164358,76.6666667 15.6224819,73.9918619 15.349107,70.5238995 L11.3118992,19.3089519 L68.7945672,19.3089519 Z M47.5,30 C46.1192881,30 45,31.1192881 45,32.5 L45,32.5 L45,62.5 C45,63.8807119 46.1192881,65 47.5,65 C48.8807119,65 50,63.8807119 50,62.5 L50,62.5 L50,32.5 C50,31.1192881 48.8807119,30 47.5,30 Z M32.5,30 C31.1192881,30 30,31.1192881 30,32.5 L30,32.5 L30,62.5 C30,63.8807119 31.1192881,65 32.5,65 C33.8807119,65 35,63.8807119 35,62.5 L35,62.5 L35,32.5 C35,31.1192881 33.8807119,30 32.5,30 Z M49.625305,3.33333333 C51.1548638,3.33333333 52.4881408,4.37432458 52.8591133,5.85821458 L53.8945597,10 L73.75,10 C75.3608305,10 76.6666667,11.3058361 76.6666667,12.9166667 C76.6666667,14.5274972 75.3608305,15.8333333 73.75,15.8333333 L6.25,15.8333333 C4.63916948,15.8333333 3.33333333,14.5274972 3.33333333,12.9166667 C3.33333333,11.3058361 4.63916948,10 6.25,10 L27.1225259,10 L28.1579722,5.85821458 C28.5289447,4.37432458 29.8622218,3.33333333 31.3917806,3.33333333 L49.625305,3.33333333 Z" id="path-3"></path>
</defs>
<g id="port" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="message_list_-notifications" transform="translate(-1184.000000, -1472.000000)">
<g id="sliceGroup" transform="translate(1184.000000, 1472.000000)">
<g id="delete">
<g id="分组-2">
<g id="color/backplane/#636363">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="Mask" fill="#D8D8D8" xlink:href="#path-1"></use>
<g mask="url(#mask-2)" fill="#FA2A2D" id="color/#67C74E">
<rect x="0" y="0" width="160" height="160"></rect>
</g>
</g>
<g id="分组" transform="translate(40.000000, 40.000000)">
<rect id="矩形" x="0" y="0" width="80" height="80"></rect>
<mask id="mask-4" fill="white">
<use xlink:href="#path-3"></use>
</mask>
<use id="Combined-Shape" fill="#FFFFFF" fill-rule="nonzero" xlink:href="#path-3"></use>
<g id="color/light/#000000" mask="url(#mask-4)" fill="#FFFFFF">
<rect id="color/#000000" x="0" y="0" width="80" height="80"></rect>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 96 96" style="enable-background:new 0 0 96 96;" xml:space="preserve">
<path id="path-1" d="M45,45H27c-1.7,0-3,1.3-3,3s1.3,3,3,3h18v18c0,1.7,1.3,3,3,3s3-1.3,3-3V51h18c1.7,0,3-1.3,3-3s-1.3-3-3-3H51V27
c0-1.7-1.3-3-3-3s-3,1.3-3,3V45z M48,92C23.7,92,4,72.3,4,48S23.7,4,48,4s44,19.7,44,44S72.3,92,48,92z"/>
</svg>

Before

Width:  |  Height:  |  Size: 586 B

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg
viewBox="0 0 96 96"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 64 (93537) - https://sketch.com -->
<title>ic_back</title>
<desc>Created with Sketch.</desc>
<defs>
<path
d="M50.1213203,8.87867966 C51.2928932,10.0502525 51.2928932,11.9497475 50.1213203,13.1213203 L18.241,45 L85,45 C86.6568542,45 88,46.3431458 88,48 C88,49.6568542 86.6568542,51 85,51 L18.243,51 L50.1213203,82.8786797 C51.2928932,84.0502525 51.2928932,85.9497475 50.1213203,87.1213203 C48.9497475,88.2928932 47.0502525,88.2928932 45.8786797,87.1213203 L8.87867966,50.1213203 C7.70710678,48.9497475 7.70710678,47.0502525 8.87867966,45.8786797 L45.8786797,8.87867966 C47.0502525,7.70710678 48.9497475,7.70710678 50.1213203,8.87867966 Z"
id="path-1"></path>
</defs>
<g
id="ic_back"
stroke="none"
stroke-width="1"
fill="none"
fill-rule="evenodd">
<g id="symbol/frame/symbol_grid24"></g>
<mask
id="mask-2"
fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use
id="合并形状"
fill="#FFFFFF"
fill-rule="nonzero"
xlink:href="#path-1"></use>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg viewBox="0 0 96 96"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 64 (93537) - https://sketch.com -->
<title>Public_cancel2</title>
<desc>Created with Sketch.</desc>
<g
id="port"
stroke="none"
stroke-width="1"
fill="none"
fill-rule="evenodd">
<g
id="message_rcs_group_chat_vcard"
transform="translate(-1056.000000, -2084.000000)">
<g
id="3-copy-2"
transform="translate(96.000000, 1812.000000)">
<g
id="分组"
transform="translate(160.000000, 272.000000)">
<g
id="sliceGroup"
transform="translate(800.000000, 0.000000)">
<g id="ic/24x24/Light/Public_cancel">
<g
id="Group"
transform="translate(8.000000, 8.000000)">
<circle
id="Oval-31"
fill-opacity="0.3"
fill="#000000"
cx="40"
cy="40"
r="40"></circle>
<path
d="M58.8336667,21.166 C60.3896667,22.722 60.3896667,25.2673333 58.8336667,26.8233333 L45.657,39.999 L58.8336667,53.1766667 C60.3378,54.6795111 60.3879378,57.1093244 58.98408,58.6739668 L58.8336667,58.8326667 L58.6748422,58.98308 C57.109077,60.3869378 54.6804667,60.3368 53.1763333,58.8326667 L53.1763333,58.8326667 L40,45.656 L26.8243333,58.8326667 C25.3202,60.3368 22.8915896,60.3869378 21.3258245,58.98308 L21.167,58.8326667 C19.611,57.278 19.611,54.7313333 21.167,53.1766667 L34.343,39.999 L21.167,26.8233333 C19.6628667,25.3192 19.6127289,22.8905896 21.0165867,21.3248245 L21.167,21.166 C22.723,19.6113333 25.2683333,19.6113333 26.8243333,21.166 L26.8243333,21.166 L40,34.342 L53.1763333,21.166 C54.7323333,19.6113333 57.2776667,19.6113333 58.8336667,21.166 Z"
id="Fill-4"
fill="#FFFFFF"></path>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="-23 25 48 48" style="enable-background:new -23 25 48 48;" xml:space="preserve">
<g id="ic_contacts_14_mini">
<g id="Group-3" transform="translate(6.000000, 2.000000)">
<path id="Combined-Shape" d="M1,25l12,12v26c0,3.3-2.7,6-6,6h-24c-3.3,0-6-2.7-6-6V31c0-3.3,2.7-6,6-6H1z M-3,59.6l0-24.2
c0-0.2-0.1-0.4-0.4-0.4h-3.5c-0.3,0-0.5,0.1-0.6,0.2l-4.2,2.5c-0.2,0.1-0.3,0.3-0.3,0.5V42c0,0.3,0.2,0.4,0.4,0.2l4.5-2.1H-7v19.6
c0,0.2,0.1,0.4,0.4,0.4h3.3C-3.2,60-3,59.8-3,59.6z" fill="#01DF01"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 780 B

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="-23 25 48 48" style="enable-background:new -23 25 48 48;" xml:space="preserve">
<g id="ic_contacts_13_mini">
<g id="Group-3" transform="translate(6.000000, 2.000000)">
<path id="Combined-Shape" d="M1,25l12,12v26c0,3.3-2.7,6-6,6h-24c-3.3,0-6-2.7-6-6V31c0-3.3,2.7-6,6-6H1z M1.8,56.1h-9V56l7-8.6
C1.2,45.7,2,43.9,2,41.7c0-3.8-2.6-6.8-7-6.8c-4.5,0-6.8,3-7.1,5.9c0,0.2,0.1,0.4,0.3,0.4l3.1,0.6c0.2,0,0.4-0.1,0.4-0.3
c0.2-1.9,1.3-3.1,3.2-3.1c2,0,3.2,1.4,3.2,3.2c0,1.4-0.6,2.6-1.5,3.7l-8.4,10.8c-0.1,0.1-0.2,0.3-0.2,0.5v2.7
c0,0.2,0.1,0.4,0.4,0.4H1.8c0.2,0,0.4-0.1,0.4-0.4v-3C2.1,56.2,2,56.1,1.8,56.1z" fill="#01DF01"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 914 B

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1"
id="图层_1"
xmlns="http://www.w3.org/2000/svg"
x="0px"
y="0px"
viewBox="-257 349 96 96"
style="enable-background:new -257 349 96 96;"
xml:space="preserve">
<path
id="path-1_1_"
d="M-223,387c0,3.3-2.7,6-6,6s-6-2.7-6-6c0-3.3,2.7-6,6-6S-223,383.7-223,387z M-234.4,431h43.4
c3.3,0,6-2.7,6-6v-4.4l-17.7-18.5c-0.8-0.8-2-0.8-2.8,0L-234.4,431z M-241.2,429.3l31.4-31.4c3.1-3.1,8.2-3.1,11.3,0l0,0l13.5,14
V379c0-3.3-2.7-6-6-6h-46c-3.3,0-6,2.7-6,6v46C-243,426.7-242.3,428.2-241.2,429.3z M-237,367h46c6.6,0,12,5.4,12,12v46
c0,6.6-5.4,12-12,12h-46c-6.6,0-12-5.4-12-12v-46C-249,372.4-243.6,367-237,367z M-235.4,363c2.1-3.6,6-6,10.4-6h44
c6.6,0,12,5.4,12,12v44c0,4.4-2.4,8.3-6,10.4V375v-6c0-3.3-2.7-6-6-6h-6H-235.4z"/>
</svg>

Before

Width:  |  Height:  |  Size: 913 B

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1"
id="图层_1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px"
y="0px"
viewBox="0 0 96 96"
style="enable-background:new 0 0 96 96;"
xml:space="preserve" fill="#808080">
<path
id="path-1_1_"
d="M28.3,77.9c1.7-0.8,3.3-1.7,4.9-2.5c1.5-0.8,3.2-1.2,5-1.5c1.5-0.2,3.1-0.2,4.7-0.1h0.2
c1.6,0.2,3.2,0.3,4.9,0.3c18.9,0,34-13.6,34-30s-15.1-30-34-30s-34,13.6-34,30c0,8.4,3.9,16.3,10.8,21.9c0.2,0.1,0.3,0.3,0.4,0.4
c1.3,1.3,2.3,2.8,2.8,4.4c0.6,1.7,0.6,3.5,0.2,5.4c-0.1,0.3-0.2,0.7-0.3,1.1c-0.1,0.3-0.2,0.6-0.3,0.9
C27.9,78.2,28.1,78.1,28.3,77.9z M20,80.9c0.7-1.2,1.4-3,2.3-5.6c0.3-1.1,0.3-1.9,0.1-2.6c-0.2-0.7-0.7-1.3-1.4-2
C13,64.1,8,54.6,8,44.1c0-19.9,17.9-36,40-36s40,16.1,40,36s-17.9,36-40,36c-1.9,0-3.8-0.1-5.6-0.4c-1.1-0.1-2.2-0.1-3.3,0
c-1.2,0.2-2.2,0.5-3.1,0.9c-1.6,0.8-3.2,1.7-5,2.5c-3.2,1.6-6.6,2.9-10,3.9c-1.6,0.5-3.5,1.2-4.2,0.8s0.4-1.6,0.9-2.5
C18.6,83.9,19.3,82.4,20,80.9z"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="-23 0 48 96" style="enable-background:new -23 0 48 96;" xml:space="preserve">
<path id="path-1_1_" d="M1,20c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S4.3,20,1,20z M1,54c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6
S4.3,54,1,54z M1,88c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S4.3,88,1,88z"/>
</svg>

Before

Width:  |  Height:  |  Size: 554 B

View File

@ -1 +0,0 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1623117443424" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3138" xmlns:xlink="http://www.w3.org/1999/xlink" width="45" height="45"><defs><style type="text/css"></style></defs><path d="M629.826051 947.722014H274.430295a100.567624 100.567624 0 0 1-100.567623-100.567624V294.032459a100.567624 100.567624 0 0 1 100.567623-100.141489h355.395756a100.567624 100.567624 0 0 1 100.567624 100.141489v553.974199a100.567624 100.567624 0 0 1-100.567624 99.715356zM274.430295 236.50437A57.52809 57.52809 0 0 0 216.476072 294.032459v553.974199a57.954224 57.954224 0 0 0 57.954223 57.954224h355.395756a57.954224 57.954224 0 0 0 57.954224-57.954224v-553.974199a57.52809 57.52809 0 0 0-57.954224-57.528089z" p-id="3139"></path><path d="M827.552226 749.995839a21.3067 21.3067 0 0 1-21.3067-21.3067V283.379109A166.19226 166.19226 0 0 0 639.200999 117.612984H392.895547a21.3067 21.3067 0 0 1-21.3067-21.3067 21.3067 21.3067 0 0 1 21.3067-21.3067H639.200999a208.80566 208.80566 0 0 1 208.379525 208.379525V728.689139a21.3067 21.3067 0 0 1-20.028298 21.3067z" p-id="3140"></path></svg>

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 96 96" style="enable-background:new 0 0 96 96;" xml:space="preserve">
<g>
<path id="path-1" d="M51.7,10.4L61,35.6h25.2c2.2,0,4,1.8,4,4c0,1.3-0.6,2.4-1.6,3.2L68.1,58.2l7.7,24.4c0.7,2.1-0.5,4.4-2.6,5
c-1.2,0.4-2.5,0.2-3.5-0.5L48.1,72L27.4,87.4c-1.8,1.3-4.3,1-5.6-0.8c-0.8-1-1-2.3-0.6-3.5l7.3-24.8l-21-15.5
c-1.8-1.3-2.2-3.8-0.8-5.6c0.8-1,1.9-1.6,3.2-1.6h25l9.3-25.2C45,8.3,47.3,7.3,49.3,8C50.4,8.4,51.2,9.3,51.7,10.4z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 712 B

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="96px" height="96px" viewBox="0 0 96 96" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 64 (93537) - https://sketch.com -->
<title>ic/notification/ic_notification_disable</title>
<desc>Created with Sketch.</desc>
<defs>
<path d="M12,0 C13.092074,0 15.092074,0.087483724 18,0.262451172 L17.9143473,0.257423196 C20.7226165,0.321272961 25.2512308,0.424812101 29.7537707,0.529375029 C34.2346324,0.432767911 38.7402782,0.336179059 41.5511972,0.276126266 L41.55,0.262451172 L41.55,0.262451172 C44.457926,0.087483724 46.457926,0 47.55,0 C50.8637085,0 53.55,2.6862915 53.55,6 C53.55,8.09131435 52.9285149,9.97162032 52.113759,11.3925669 C51.7876654,11.9612791 51.3493305,12.5840646 50.7987543,13.2609236 C49.9750485,14.3558938 49.0132605,15.2423677 48.2340893,15.9590679 C47.8383298,16.3413923 47.4036622,16.757251 47.006571,17.1543421 C45.3860099,18.7749032 44.5370865,21.8003012 44.6191471,25.6708259 C44.7345975,31.1282252 46.6891331,36.3721778 48.4421965,37.8435212 C49.0184722,38.3017427 51.7893831,40.375876 52.5039514,40.8913866 C53.5922501,41.6765174 54.5418977,42.3922053 55.3378296,43.174157 C55.5852802,43.4172613 55.8198573,43.6586055 56.0422046,43.8977438 C56.8490897,44.704785 57.3964784,45.3099036 57.6841762,45.7127211 C59.5712409,48.3548773 60,50.1793149 60,51.4 C60,54.5324155 57.5996019,57.104188 54.5379079,57.3762155 C54.3463217,57.3997937 54.1660726,57.4125046 54,57.4158936 L54,57.4158936 L36.8669849,57.7914425 L32.5620607,85.8145656 L32.555361,85.8320133 C32.4725645,86.428028 32.2152273,87.0051188 31.7577676,87.4625785 C30.6429611,88.577385 28.8345945,88.5747098 27.7194871,87.4596025 C27.3003142,87.0404296 27.0381432,86.523369 26.9330274,85.9809164 L26.9330274,85.9809164 L22.7249481,57.7810204 L5.66643467,57.3964509 C5.44875112,57.3915138 5.20605342,57.3619052 4.94716894,57.3074101 C2.13508267,56.8097953 0,54.3542353 0,51.4 C0,50.8244461 0.0953186858,50.1146702 0.393873854,49.2482442 C0.895081216,47.6440306 2.06286398,45.603492 4.58550225,43.174157 C5.05389875,42.7230848 6.75020001,41.2789233 7.23533021,40.8913866 L7.41009523,40.7519123 C8.77610498,39.6627167 10.7129991,38.1396758 11.1203224,37.8160166 C12.8712191,36.3472555 14.8180277,31.106178 14.9254345,25.6489429 C15.0017904,21.778535 14.1484068,18.7518824 12.5254554,17.128931 C12.1277786,16.7312542 11.6924975,16.3147544 11.2961741,15.9318462 C10.5238346,15.2200918 9.57175273,14.3422753 8.75238123,13.2611591 L8.70469295,13.2034912 C8.17590767,12.5487986 7.75309027,11.9451572 7.43624074,11.3925669 C6.62148481,9.97162032 6,8.09131435 6,6 C6,2.6862915 8.6862915,0 12,0 Z" id="path-1"></path>
</defs>
<g id="ic/notification/ic_notification_disable-copy" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="color/light/#000000" transform="translate(18.000000, 4.000000)">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="Mask" fill="#000000" xlink:href="#path-1"></use>
<g mask="url(#mask-2)" fill="#000000" id="color/#000000">
<g transform="translate(-18.000000, -4.000000)">
<rect x="0" y="0" width="96" height="96"></rect>
</g>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -1,57 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg
viewBox="0 0 120 120"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 64 (93537) - https://sketch.com -->
<title>ic_play</title>
<desc>Created with Sketch.</desc>
<defs>
<path
d="M42.5,37.6542653 L42.5,72.3457347 C42.5,74.9230636 44.5893378,77.0124014 47.1666667,77.0124014 C48.0253555,77.0124014 48.8673964,76.77548 49.6001,76.3277166 L77.9840296,58.9819819 C80.1832175,57.6380337 80.8765263,54.7657545 79.5325781,52.5665666 C79.1465347,51.9348591 78.6157371,51.4040616 77.9840296,51.0180181 L49.6001,33.6722834 C47.4009122,32.3283352 44.5286329,33.021644 43.1846848,35.2208319 C42.7369215,35.9535355 42.5,36.7955764 42.5,37.6542653 Z"
id="path-1"></path>
</defs>
<g
id="port"
stroke="none"
stroke-width="1"
fill="none"
fill-rule="evenodd">
<g
id="message_rcs_group_chat_music"
transform="translate(-320.000000, -874.000000)">
<g
id="Group-8"
transform="translate(96.000000, 806.000000)">
<g
id="9-copy-5"
transform="translate(160.000000, 0.000000)">
<g
id="sliceGroup"
transform="translate(64.000000, 68.000000)">
<g
id="ic/play-norm/ic_play"
transform="translate(5.000000, 5.000000)">
<path
d="M55,0 C85.3756612,0 110,24.6243388 110,55 C110,85.3756612 85.3756612,110 55,110 C24.6243388,110 0,85.3756612 0,55 C0,24.6243388 24.6243388,0 55,0 Z M55,4 C26.8334778,4 4,26.8334778 4,55 C4,83.1665222 26.8334778,106 55,106 C83.1665222,106 106,83.1665222 106,55 C106,26.8334778 83.1665222,4 55,4 Z"
id="Oval-5"
fill="#000000"
fill-rule="nonzero"
opacity="0.200000003"></path>
<mask
id="mask-2"
fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use
id="Path-46"
fill="#000000"
xlink:href="#path-1"></use>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -1,16 +0,0 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg t="1614934632973"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="3032"
>
<defs>
<style type="text/css"></style>
</defs>
<path
d="M504.123077 23.630769C240.246154 23.630769 23.630769 240.246154 23.630769 504.123077 23.630769 771.938462 240.246154 984.615385 504.123077 984.615385c267.815385 0 484.430769-212.676923 480.492308-480.492308C984.615385 240.246154 768 23.630769 504.123077 23.630769z m177.230769 523.815385l-228.430769 137.846154c-39.384615 23.630769-90.584615-3.938462-90.584615-43.323077V370.215385c0-43.323077 55.138462-66.953846 90.584615-43.323077l228.430769 137.846154c31.507692 19.692308 31.507692 63.015385 0 82.707692z"
fill="#585858"
p-id="3033"></path>
</svg>

Before

Width:  |  Height:  |  Size: 939 B

View File

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg
viewBox="0 0 72 72"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 64 (93537) - https://sketch.com -->
<title>ic_play_filled</title>
<desc>Created with Sketch.</desc>
<g
id="组件"
stroke="none"
stroke-width="1"
fill="none"
fill-rule="evenodd">
<g
id="bg/Gallery_Photo_video"
transform="translate(-16.000000, -56.000000)">
<g id="sliceGroup">
<g transform="translate(16.000000, 56.000000)">
<g id="ic_gallery_tag_video">
<g id="video2">
<rect
id="Rectangle-2566-Copy-2611"
fill="#5C5C5C"
opacity="0"
x="0"
y="0"
width="72"
height="72"></rect>
<path
d="M49.2,37.791075 L49.2033,37.792725 L31.0764,49.3848 C30.72,49.639725 30.28605,49.794825 29.811675,49.794825 C28.607175,49.794825 27.633675,48.8205 27.633675,47.616 C27.633675,47.61105 27.6345,47.606925 27.6345,47.6028 L27.633675,24.401325 L27.6345,24.402975 C27.6345,24.39555 27.633675,24.3906 27.633675,24.384 C27.633675,23.180325 28.607175,22.205175 29.811675,22.205175 C30.291825,22.205175 30.64575,22.366875 31.088775,22.614375 L49.2033,34.2081 C49.20165,34.208925 49.2,34.210575 49.2,34.210575 C49.76595,34.604925 50.141325,35.258325 50.141325,36 C50.141325,36.7425 49.76595,37.396725 49.2,37.791075 M36,3 C17.7741,3 3,17.7741 3,36 C3,54.2259 17.7741,69 36,69 C54.2259,69 69,54.2259 69,36 C69,17.7741 54.2259,3 36,3"
id="Fill-1"
fill="#FFFFFF"></path>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -1,57 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg
viewBox="0 0 120 120"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 64 (93537) - https://sketch.com -->
<title>ic_play</title>
<desc>Created with Sketch.</desc>
<defs>
<path
d="M42.5,37.6542653 L42.5,72.3457347 C42.5,74.9230636 44.5893378,77.0124014 47.1666667,77.0124014 C48.0253555,77.0124014 48.8673964,76.77548 49.6001,76.3277166 L77.9840296,58.9819819 C80.1832175,57.6380337 80.8765263,54.7657545 79.5325781,52.5665666 C79.1465347,51.9348591 78.6157371,51.4040616 77.9840296,51.0180181 L49.6001,33.6722834 C47.4009122,32.3283352 44.5286329,33.021644 43.1846848,35.2208319 C42.7369215,35.9535355 42.5,36.7955764 42.5,37.6542653 Z"
id="path-1"></path>
</defs>
<g
id="port"
stroke="none"
stroke-width="1"
fill="none"
fill-rule="evenodd">
<g
id="message_rcs_group_chat_music"
transform="translate(-320.000000, -874.000000)">
<g
id="Group-8"
transform="translate(96.000000, 806.000000)">
<g
id="9-copy-5"
transform="translate(160.000000, 0.000000)">
<g
id="sliceGroup"
transform="translate(64.000000, 68.000000)">
<g
id="ic/play-norm/ic_play"
transform="translate(5.000000, 5.000000)">
<path
d="M55,0 C85.3756612,0 110,24.6243388 110,55 C110,85.3756612 85.3756612,110 55,110 C24.6243388,110 0,85.3756612 0,55 C0,24.6243388 24.6243388,0 55,0 Z M55,4 C26.8334778,4 4,26.8334778 4,55 C4,83.1665222 26.8334778,106 55,106 C83.1665222,106 106,83.1665222 106,55 C106,26.8334778 83.1665222,4 55,4 Z"
id="Oval-5"
fill="#FFFFFF"
fill-rule="nonzero"
></path>
<mask
id="mask-2"
fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use
id="Path-46"
fill="#FFFFFF"
xlink:href="#path-1"></use>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -1,16 +0,0 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg t="1614136251099"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="28158"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<style type="text/css"></style>
</defs>
<path
d="M768.832 320h-62.976v-97.536c0-122.24-100.8-221.76-224.704-221.76-123.84 0-224.64 99.52-224.64 221.76V320h-63.68c-70.656 0-128 57.344-128 128v384c0 70.656 57.344 128 128 128h576c70.656 0 128-57.344 128-128V448c0-70.656-57.344-128-128-128z m-256 313.536V736c0 17.664-14.336 32-32 32s-32-14.336-32-32V633.536c-37.12-13.312-64-47.872-64-89.536 0-48.64 36.672-87.104 83.584-93.504 3.776-1.6 7.936-2.496 12.416-2.496 52.992 0 96 43.008 96 96 0 41.664-26.88 76.224-64 89.536zM641.6 320H320.704v-97.536c0-87.296 72-158.4 160.448-158.4 88.512 0 160.512 71.04 160.512 158.4V320z"
p-id="28159"
fill="#2c2c2c"></path>
</svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg
viewBox="0 0 96 96"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Checkbox/Light/on</title>
<desc>Created with Sketch.</desc>
<g
id="Checkbox/Light/on"
stroke="none"
stroke-width="1"
fill="none"
fill-rule="evenodd">
<path
d="M37.5807538,64.5034353 C35.3733606,64.5034353 33.5839149,62.7080792 33.5839149,60.5034353 C33.5839149,58.2942963 35.3780352,56.5034353 37.5807538,56.5034353 L53.5829149,56.5024353 L53.5839149,23.4968851 C53.5839149,21.3581977 55.2721102,19.6121781 57.3846588,19.5083226 L57.5839149,19.5034353 C59.7930539,19.5034353 61.5839149,21.295258 61.5839149,23.4968851 L61.5829149,60.4624353 L61.5839149,60.5034353 L61.5799149,60.6774353 L61.5790076,60.7092989 C61.5117972,62.0711455 60.7596828,63.2536489 59.6610602,63.9222546 C59.4881842,64.0275306 59.3069458,64.1200314 59.1184666,64.1984959 C59.0974121,64.2069739 59.0761224,64.2156138 59.0547428,64.2240748 C58.6000523,64.4044824 58.1048526,64.5034353 57.5870761,64.5034353 L37.5807538,64.5034353 Z"
id="Rectangle-62"
fill="#888888"
transform="translate(47.583915, 42.003435) rotate(43.000000) translate(-47.583915, -42.003435) "></path>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1,47 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg
viewBox="0 0 96 96"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 64 (93537) - https://sketch.com -->
<title>ic_tick</title>
<desc>Created with Sketch.</desc>
<defs>
<path
d="M86.8786797,14.552006 C88.0502525,13.3804332 89.9497475,13.3804332 91.1213203,14.552006 C92.2928932,15.7235789 92.2928932,17.6230739 91.1213203,18.7946467 L37.7946467,72.1213203 C36.6230739,73.2928932 34.7235789,73.2928932 33.552006,72.1213203 L4.87867966,43.447994 C3.70710678,42.2764211 3.70710678,40.3769261 4.87867966,39.2053533 C6.05025253,38.0337804 7.94974747,38.0337804 9.12132034,39.2053533 L35.6733264,65.7573593 L86.8786797,14.552006 Z"
id="path-1"></path>
</defs>
<g
id="port"
stroke="none"
stroke-width="1"
fill="none"
fill-rule="evenodd">
<g
id="message_location_search_halfscreen"
transform="translate(-1248.000000, -160.000000)">
<g
id="SearchBar/Light/without-bg/Basic"
transform="translate(0.000000, 96.000000)">
<g
id="sliceGroup"
transform="translate(1248.000000, 64.000000)">
<g id="ic/scan/ic_scan">
<g id="symbol/frame/symbol_grid24"></g>
<mask
id="mask-2"
fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use
id="Path-21"
fill="#000000"
fill-rule="nonzero"
xlink:href="#path-1"></use>
</g>
</g>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -1,54 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="150px"
height="150px"
viewBox="0 0 288 288"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 64 (93537) - https://sketch.com -->
<title>ic_voice</title>
<desc>Created with Sketch.</desc>
<defs>
<path
d="M178.666667,142.666667 C180.875806,142.666667 182.666667,144.457528 182.666667,146.666667 C182.666667,166.671135 167.475431,183.127501 147.999753,185.12897 L148,197.439939 C148,199.649078 146.209139,201.439939 144,201.439939 C141.790861,201.439939 140,199.649078 140,197.439939 L139.999246,185.128868 C120.524048,183.126937 105.333333,166.670793 105.333333,146.666667 C105.333333,144.457528 107.124194,142.666667 109.333333,142.666667 C111.542472,142.666667 113.333333,144.457528 113.333333,146.666667 C113.333333,163.603399 127.063268,177.333333 144,177.333333 C160.936732,177.333333 174.666667,163.603399 174.666667,146.666667 C174.666667,144.457528 176.457528,142.666667 178.666667,142.666667 Z M144,85.3333333 C155.782075,85.3333333 165.333333,94.884592 165.333333,106.666667 L165.333333,146.666667 C165.333333,158.448741 155.782075,168 144,168 C132.217925,168 122.666667,158.448741 122.666667,146.666667 L122.666667,106.666667 C122.666667,94.884592 132.217925,85.3333333 144,85.3333333 Z M144,93.3333333 C136.636203,93.3333333 130.666667,99.30287 130.666667,106.666667 L130.666667,146.666667 C130.666667,154.030463 136.636203,160 144,160 C151.363797,160 157.333333,154.030463 157.333333,146.666667 L157.333333,106.666667 C157.333333,99.30287 151.363797,93.3333333 144,93.3333333 Z"
id="path-1"></path>
</defs>
<g
id="port"
stroke="none"
stroke-width="1"
fill="none"
fill-rule="evenodd">
<g
id="message_conversation_record"
transform="translate(-576.000000, -2210.000000)">
<g
id="分组"
transform="translate(96.000000, 2210.000000)">
<g
id="sliceGroup"
transform="translate(480.000000, 0.000000)">
<g id="ic/voice">
<g>
<path
d="M144,16 C214.692448,16 272,73.307552 272,144 C272,214.692448 214.692448,272 144,272 C73.307552,272 16,214.692448 16,144 C16,73.307552 73.307552,16 144,16 Z M144,18 C74.4121215,18 18,74.4121215 18,144 C18,213.587878 74.4121215,270 144,270 C213.587878,270 270,213.587878 270,144 C270,74.4121215 213.587878,18 144,18 Z"
id="合并形状"
fill-opacity="0.38"
fill="#000000"></path>
<mask
id="mask-2"
fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use
id="合并形状"
fill="#000000"
fill-rule="nonzero"
xlink:href="#path-1"></use>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -1,81 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="32"
height="32"
viewBox="0 0 64 64"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 64 (93537) - https://sketch.com -->
<title>ic_voice_left</title>
<desc>Created with Sketch.</desc>
<defs>
<polygon
id="path-1"
points="0 0.076912844 7.96957021 0.076912844 7.96957021 24.6638889 0 24.6638889"></polygon>
<polygon
id="path-3"
points="0 5.64729655e-05 14.0709484 5.64729655e-05 14.0709484 58.6666667 0 58.6666667"></polygon>
</defs>
<g transform="translate(64,64)rotate(180)">
<g
id="port"
stroke="none"
stroke-width="1"
fill="none"
fill-rule="evenodd"
opacity="0.38">
<g
id="message_rcs_group_chat_multi_select_1"
transform="translate(-832.000000, -1440.000000)">
<g
id="对话框"
transform="translate(96.000000, 1392.000000)">
<g id="4">
<g
id="sliceGroup"
transform="translate(736.000000, 48.000000)">
<g id="ic16dp/voice_left/ic_voice_left">
<g id="分组-2">
<g
id="分组"
transform="translate(32.000000, 32.000000) scale(-1, 1) translate(-32.000000, -32.000000) translate(13.333333, 2.666667)">
<g transform="translate(29.333333, 16.962963)">
<mask
id="mask-2"
fill="white">
<use xlink:href="#path-1"></use>
</mask>
<g id="Clip-2"></g>
<path
d="M2.44008511,23.0098148 C0.820638298,19.6438148 0,16.0643333 0,12.369963 C0,8.67640741 0.820638298,5.09692593 2.44008511,1.73092593 C3.14025532,0.272407407 4.23884967,-0.292235079 5.6852752,0.411764921 C7.13170073,1.11902418 6.55731915,2.83217864 5.85634043,4.28988235 C4.62417021,6.85166013 4,9.56988235 4,12.3704009 C4,15.1709194 4.62417021,17.8899564 5.85634043,20.4509194 C6.55731915,21.9094379 6.92275853,23.0098148 6.42167428,23.8357895 C6.15345857,24.2779096 5.32581501,24.6466999 4.86087662,24.6466999 C3.78070641,24.6466999 2.94217021,24.0552222 2.44008511,23.0098148 Z"
id="Fill-1"
fill="#000000"
mask="url(#mask-2)"></path>
</g>
<path
d="M20.3228851,48.8443185 C16.6813532,42.9963926 14.6712138,36.2501958 14.6712138,29.3332328 C14.6712138,22.4162699 16.6813532,15.6699481 20.3228851,9.82202222 C21.1782894,8.45068889 22.3805072,7.7455725 23.9214744,8.70393 C25.4624417,9.6622875 24.1984965,11.5703704 23.3439007,12.9425185 C20.2844965,17.8534074 18.6666667,23.5212593 18.6666667,29.3333333 C18.6666667,35.1462222 20.2844965,40.8140741 23.3439007,45.724963 C24.1984965,47.0971111 24.9786193,47.7689943 24.4356052,49.0745401 C24.1250517,49.8211909 23.320034,50.2180963 22.7912681,50.2180963 C21.8226723,50.2180963 20.8767149,49.7316519 20.3228851,48.8443185 Z"
id="Fill-3"
fill="#000000"></path>
<g>
<mask
id="mask-4"
fill="white">
<use xlink:href="#path-3"></use>
</mask>
<g id="Clip-6"></g>
<path
d="M8.77549362,57.4142963 C3.03506809,49.1455556 -8.08510638e-05,39.4345926 -8.08510638e-05,29.3333333 C-8.08510638e-05,19.2312593 3.03506809,9.5202963 8.77549362,1.25155556 C9.69638723,-0.074962963 11.1619729,-0.23170711 12.3169121,0.632277422 C13.4718514,1.49626195 12.6454043,3.28780601 11.7237021,4.61513935 C6.67131915,11.8930653 4,20.4404727 4,29.3333616 C4,38.2254356 6.67131915,46.7728431 11.7237021,54.0515838 C12.6454043,55.3789171 13.5141724,56.7356886 12.7629012,57.7687769 C12.2721322,58.4436434 11.7386851,58.6666667 11.1630255,58.6666667 C10.2445574,58.6666667 9.34225957,58.2299259 8.77549362,57.4142963 Z"
id="Fill-5"
fill="#000000"
mask="url(#mask-4)"></path>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -1,78 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg
viewBox="0 0 64 64"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 64 (93537) - https://sketch.com -->
<title>ic_voice_left</title>
<desc>Created with Sketch.</desc>
<defs>
<polygon
id="path-1"
points="0 0.076912844 7.96957021 0.076912844 7.96957021 24.6638889 0 24.6638889"></polygon>
<polygon
id="path-3"
points="0 5.64729655e-05 14.0709484 5.64729655e-05 14.0709484 58.6666667 0 58.6666667"></polygon>
</defs>
<g
id="port"
stroke="none"
stroke-width="1"
fill="none"
fill-rule="evenodd"
opacity="0.38">
<g
id="message_rcs_group_chat_multi_select_1"
transform="translate(-832.000000, -1440.000000)">
<g
id="对话框"
transform="translate(96.000000, 1392.000000)">
<g id="4">
<g
id="sliceGroup"
transform="translate(736.000000, 48.000000)">
<g id="ic16dp/voice_left/ic_voice_left">
<g id="分组-2">
<g
id="分组"
transform="translate(32.000000, 32.000000) scale(-1, 1) translate(-32.000000, -32.000000) translate(13.333333, 2.666667)">
<g transform="translate(29.333333, 16.962963)">
<mask
id="mask-2"
fill="white">
<use xlink:href="#path-1"></use>
</mask>
<g id="Clip-2"></g>
<path
d="M2.44008511,23.0098148 C0.820638298,19.6438148 0,16.0643333 0,12.369963 C0,8.67640741 0.820638298,5.09692593 2.44008511,1.73092593 C3.14025532,0.272407407 4.23884967,-0.292235079 5.6852752,0.411764921 C7.13170073,1.11902418 6.55731915,2.83217864 5.85634043,4.28988235 C4.62417021,6.85166013 4,9.56988235 4,12.3704009 C4,15.1709194 4.62417021,17.8899564 5.85634043,20.4509194 C6.55731915,21.9094379 6.92275853,23.0098148 6.42167428,23.8357895 C6.15345857,24.2779096 5.32581501,24.6466999 4.86087662,24.6466999 C3.78070641,24.6466999 2.94217021,24.0552222 2.44008511,23.0098148 Z"
id="Fill-1"
fill="#000000"
mask="url(#mask-2)"></path>
</g>
<path
d="M20.3228851,48.8443185 C16.6813532,42.9963926 14.6712138,36.2501958 14.6712138,29.3332328 C14.6712138,22.4162699 16.6813532,15.6699481 20.3228851,9.82202222 C21.1782894,8.45068889 22.3805072,7.7455725 23.9214744,8.70393 C25.4624417,9.6622875 24.1984965,11.5703704 23.3439007,12.9425185 C20.2844965,17.8534074 18.6666667,23.5212593 18.6666667,29.3333333 C18.6666667,35.1462222 20.2844965,40.8140741 23.3439007,45.724963 C24.1984965,47.0971111 24.9786193,47.7689943 24.4356052,49.0745401 C24.1250517,49.8211909 23.320034,50.2180963 22.7912681,50.2180963 C21.8226723,50.2180963 20.8767149,49.7316519 20.3228851,48.8443185 Z"
id="Fill-3"
fill="#000000"></path>
<g>
<mask
id="mask-4"
fill="white">
<use xlink:href="#path-3"></use>
</mask>
<g id="Clip-6"></g>
<path
d="M8.77549362,57.4142963 C3.03506809,49.1455556 -8.08510638e-05,39.4345926 -8.08510638e-05,29.3333333 C-8.08510638e-05,19.2312593 3.03506809,9.5202963 8.77549362,1.25155556 C9.69638723,-0.074962963 11.1619729,-0.23170711 12.3169121,0.632277422 C13.4718514,1.49626195 12.6454043,3.28780601 11.7237021,4.61513935 C6.67131915,11.8930653 4,20.4404727 4,29.3333616 C4,38.2254356 6.67131915,46.7728431 11.7237021,54.0515838 C12.6454043,55.3789171 13.5141724,56.7356886 12.7629012,57.7687769 C12.2721322,58.4436434 11.7386851,58.6666667 11.1630255,58.6666667 C10.2445574,58.6666667 9.34225957,58.2299259 8.77549362,57.4142963 Z"
id="Fill-5"
fill="#000000"
mask="url(#mask-4)"></path>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -1,52 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg
viewBox="0 0 96 96"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 64 (93537) - https://sketch.com -->
<title>ic_cancel</title>
<desc>Created with Sketch.</desc>
<defs>
<path
d="M54,54 L54,20 C54,18.3431458 55.3431458,17 57,17 C58.6568542,17 60,18.3431458 60,20 L60,54 L94,54 C95.6568542,54 97,55.3431458 97,57 C97,58.6568542 95.6568542,60 94,60 L60,60 L60,94 C60,95.6568542 58.6568542,97 57,97 C55.3431458,97 54,95.6568542 54,94 L54,60 L20,60 C18.3431458,60 17,58.6568542 17,57 C17,55.3431458 18.3431458,54 20,54 L54,54 Z"
id="path-1"></path>
</defs>
<g
id="port"
stroke="none"
stroke-width="1"
fill="none"
fill-rule="evenodd">
<g
id="message_list_prompt_2"
transform="translate(-1184.000000, -944.000000)">
<g
id="prompt_card"
transform="translate(0.000000, 832.000000)">
<g
id="sliceGroup"
transform="translate(1175.000000, 103.000000)">
<g id="ic/close/ic_cancel">
<g
id="symbol/frame/symbol_grid24"
transform="translate(9.000000, 9.000000)"></g>
<g id="Group">
<mask
id="mask-2"
fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use
id="路径"
fill="#000000"
fill-rule="nonzero"
transform="translate(57.000000, 57.000000) rotate(45.000000) translate(-57.000000, -57.000000) "
xlink:href="#path-1"></use>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.0" id="图层_3" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 96 96" style="enable-background:new 0 0 96 96;" xml:space="preserve">
<title>ic_favourites</title>
<desc>Created with Sketch.</desc>
<defs>
<path d="M44,0 C68.300529,0 88,19.699471 88,44 C88,68.300529 68.300529,88 44,88 C19.699471,88 0,68.300529 0,44 C0,19.699471 19.699471,0 44,0 Z M44,6 C23.0131795,6 6,23.0131795 6,44 C6,64.9868205 23.0131795,82 44,82 C64.9868205,82 82,64.9868205 82,44 C82,23.0131795 64.9868205,6 44,6 Z M44,20 C45.6568542,20 47,21.3431458 47,23 L47,41 L65,41 C66.6568542,41 68,42.3431458 68,44 C68,45.6568542 66.6568542,47 65,47 L47,47 L47,65 C47,66.6568542 45.6568542,68 44,68 C42.3431458,68 41,66.6568542 41,65 L41,47 L23,47 C21.3431458,47 20,45.6568542 20,44 C20,42.3431458 21.3431458,41 23,41 L41,41 L41,23 C41,21.3431458 42.3431458,20 44,20 Z" id="path-1"></path>
</defs>
<g id="port" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="message_rcs_group_chat" transform="translate(-100.000000, -2900.000000)">
<g id="Textfield/Light/With-bg/filled/Basic+icon_normal备份" transform="translate(0.000000, 2832.000000)">
<g id="ic/add/ic_add_norm" transform="translate(96.000000, 64.000000)">
<g id="add" transform="translate(4.000000, 4.000000)">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="合并形状" fill="#000000" fill-rule="nonzero" xlink:href="#path-1"></use>
<rect id="color/#000000" fill="#000000" mask="url(#mask-2)" x="-4" y="-4" width="96" height="96"></rect>
</g>
</g>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0"
id="图层_1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px"
y="0px"
viewBox="0 0 96 96"
style="enable-background:new 0 0 96 96;"
xml:space="preserve">
<path
id="path-1_1_"
d="M18.2,45H85c1.7,0,3,1.3,3,3s-1.3,3-3,3H18.2l31.9,31.9c1.2,1.2,1.2,3.1,0,4.2c-1.2,1.2-3.1,1.2-4.2,0
l-37-37c-1.2-1.2-1.2-3.1,0-4.2l37-37c1.2-1.2,3.1-1.2,4.2,0c1.2,1.2,1.2,3.1,0,4.2L18.2,45z"/>
</svg>

Before

Width:  |  Height:  |  Size: 615 B

Some files were not shown because too many files have changed in this diff Show More