settings 2.0
Signed-off-by: wshj-HuangJian <huangjian68@huawei.com>
37
BUILD.gn
@ -1,37 +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("//build/ohos.gni")
|
||||
|
||||
ohos_hap("ark_settings") {
|
||||
hap_profile = "entry/src/main/config.json"
|
||||
deps = [
|
||||
":settings_js_assets",
|
||||
":settings_resources",
|
||||
]
|
||||
js2abc = false
|
||||
shared_libraries = [ "//third_party/libpng:libpng" ]
|
||||
certificate_profile = "signature/settings.p7b"
|
||||
hap_name = "ark_settings"
|
||||
part_name = "prebuilt_hap"
|
||||
subsystem_name = "applications"
|
||||
}
|
||||
|
||||
ohos_js_assets("settings_js_assets") {
|
||||
source_dir = "entry/src/main/js/default"
|
||||
}
|
||||
|
||||
ohos_resources("settings_resources") {
|
||||
sources = [ "entry/src/main/resources" ]
|
||||
hap_profile = "entry/src/main/config.json"
|
||||
}
|
297
README.md
@ -1,37 +1,280 @@
|
||||
# Settings<a name="EN-US_TOPIC_0000001103421572"></a>
|
||||
# Settings 源码开发说明
|
||||
大纲:
|
||||
1. 项目介绍
|
||||
2. 工程结构
|
||||
1. 目录结构
|
||||
2. 整体架构
|
||||
3. 代码使用
|
||||
1. 代码下载
|
||||
1. 从码云clone代码(配置ssh,下载代码)
|
||||
2. 环境搭建
|
||||
1. 下载DevEco Studio
|
||||
2. 安装开发SDK
|
||||
3. 更新 ace-loader
|
||||
3. 工程导入DevEco Studio
|
||||
1. 如何build项目
|
||||
4. 基础开发说明
|
||||
1. NAPI 接口调用
|
||||
2. 异步回调的使用
|
||||
3. 如何引用资源文件
|
||||
5. 典型接口的使用
|
||||
6. 签名打包
|
||||
1. 签名
|
||||
1. 签名文件的获取
|
||||
2. 签名文件的配置
|
||||
2. 打包
|
||||
1. debug打包
|
||||
2. release打包
|
||||
7. 安装、运行、调试
|
||||
1. 应用安装、运行
|
||||
1. 重新安装需要清理缓存的内容
|
||||
2. 应用调试
|
||||
1. log打印
|
||||
2. log获取及过滤
|
||||
8. 发布hap包
|
||||
1. 发布到码云
|
||||
## 1. 项目介绍
|
||||
Settings是基于Harmony OS平台开发的基于OHOS提供基础设置功能。主要包括页面展示跳转逻辑、基础设置项(wlan设置、亮度设置、应用管理、日期和时间、关于手机)以及本设备其他应用设置项的收集、其他设备设置项收集的实现。项目采用MVVM架构模式,让各个层级之间不直接访问减少相互依赖。
|
||||
|
||||
- [Introduction](#section11660541593)
|
||||
- [Architecture](#section48896451454)
|
||||
Settings采用纯 JS 语言开发,开发过程中不涉及任何 Java 部分的代码。
|
||||
|
||||
- [Directory Structure](#section161941989596)
|
||||
- [Repositories Involved](#section1371113476307)
|
||||
|
||||
## Introduction<a name="section11660541593"></a>
|
||||
|
||||
Settings is a system app preinstalled in OpenHarmony to provide an interactive UI for users to set system attributes, such as the system time and screen brightness.
|
||||
|
||||
### Architecture<a name="section48896451454"></a>
|
||||
|
||||
![](figures/en-us_image_0000001153225717.png)
|
||||
|
||||
## Directory Structure<a name="section161941989596"></a>
|
||||
## 2. 工程结构
|
||||
### 目录结构
|
||||
|
||||
```
|
||||
/applications/standard/settings
|
||||
├── figures # Architecture figures
|
||||
├── entry # Main entry module code
|
||||
│ ├── src
|
||||
│ ├── main
|
||||
│ └── js # JavaScript code
|
||||
│ └── resources # Resources
|
||||
│ └── config.json # Global configuration files
|
||||
├── signature # Certificate files
|
||||
├── LICENSE # License files
|
||||
├── entry/src/main
|
||||
│ └── js/default
|
||||
│ ├── common # 公共代码存在目录
|
||||
│ ├── pages # 界面源代码文件存放目录
|
||||
│ ├── models # 数据模型源代码存放目录
|
||||
│ ├── component # UI组件源代码存放目录
|
||||
│ ├── i18n # 全球化资源文件存放目录
|
||||
│ └── app.js
|
||||
│ └── resources # 资源存放目录
|
||||
│ └── config.json # 应用信息及组件信息清单
|
||||
```
|
||||
|
||||
## Repositories Involved<a name="section1371113476307"></a>
|
||||
### 整体架构
|
||||
|
||||
![settings_en](./img/settings_en.png)
|
||||
|
||||
## 3. 代码使用
|
||||
### 代码下载
|
||||
基于L2的 Settings代码可以采用从码云上克隆的方式下载。
|
||||
[下载地址](https://gitee.com/OHOS_STD/applications_standard_settings)
|
||||
|
||||
#### 从码云克隆代码
|
||||
##### 1.配置SSH公钥
|
||||
1. 通过[登录网址](https://gitee.com/login)登录码云
|
||||
2. 在码云的个人设置中设置SSH公钥
|
||||
1. 生成SSH公私钥
|
||||
在命令窗口输入以下命令,邮箱地址替换为自己的邮箱地址,一直回车直至完成为止。
|
||||
```
|
||||
ssh-keygen -t rsa -C "xxxx@xxxx.com"
|
||||
```
|
||||
> 执行完成后,会在用户目录下的.ssh文件夹内生成 `id_rsa` 与 `id_rsa.pub` 两个文件,其中的 `id_rsa.pub` 即为生成的 SSH公钥
|
||||
2. 复制公钥内容
|
||||
输入`cat .ssh/id_rsa.pub`,复制打印内容。
|
||||
![](./img/3-1.png)
|
||||
3. 在设置->安全设置->SSH公钥 中设置 SSH公钥
|
||||
将第二步中复制的内容按照画面提示粘贴到码云上相应的内容区域,并点击确定。
|
||||
![](./img/3-2.png)
|
||||
> 注意,在码云中,添加SSH公钥之后,需要进行账号的密码验证,验证通过才能成功添加。
|
||||
##### 2.下载代码
|
||||
1. 浏览器打开[下载地址](https://gitee.com/OHOS_STD/applications_standard_settings)。
|
||||
2. 点击“克隆/下载”按钮,选择 SSH,点击“复制”按钮。
|
||||
![](./img/source_download_1.png)
|
||||
3. 在本地新建 Launcher 目录,在 Settings 目录中执行如下命令
|
||||
```
|
||||
git clone 步骤2中复制的地址
|
||||
```
|
||||
### 环境搭建
|
||||
#### 1. 下载安装 DevEco Studio
|
||||
Settings使用 DevEco Studio 进行开发,开发前需要下载 DevEco Studio 。
|
||||
|
||||
**1)下载**
|
||||
|
||||
在下载页面下载 DevEco Studio 的安装包压缩文件([下载地址](https://developer.harmonyos.com/cn/develop/deveco-studio#download))。
|
||||
下载页面如下:
|
||||
|
||||
![](./img/ds_download.png)
|
||||
|
||||
> 注:下载 DevEco Studio 需要注册华为账号。
|
||||
> ![](img/hw_register.png)
|
||||
|
||||
**2)安装**
|
||||
|
||||
将下载下来的压缩包解压,得到安装文件如图:
|
||||
|
||||
![](./img/ds_exe.png)
|
||||
|
||||
双击安装文件进行安装,安装过程如图所示:
|
||||
|
||||
![](./img/ds_install_1.png)
|
||||
|
||||
![](./img/ds_install_2.png)
|
||||
|
||||
#### 2. 安装开发 SDK
|
||||
DevEco Studio 在安装完成之后会自动下载开发 SDK 下载过程如下图所示:
|
||||
|
||||
![](./img/sdk_downloading.png)
|
||||
|
||||
#### 3. 更新 ace-loader
|
||||
> 由于最新的 ace 框架尚未发布到公开版 sdk 中,所以为了让应用能够顺利编译,需要替换 sdk 中的 ace-loader。
|
||||
|
||||
替换下面两个路径下的 ace-loader 文件夹。
|
||||
```
|
||||
Sdk\js\2.1.1.20\build-tools
|
||||
Sdk\js\2.0.1.95\build-tools
|
||||
```
|
||||
// TODO 这里是否需要npm install?
|
||||
|
||||
### 工程导入 DevEco Studio
|
||||
> 由于 Settings 的开源代码中删除了工程中的 `build.gradle` 文件,所以我们需要在相应的目录创建 `build.gradle` 文件以保证工程可以被正确导入 DevEco Studio 。
|
||||
|
||||
#### 1. 为 Settings工程添加 `build.gradle`
|
||||
|
||||
|
||||
#### 2. build Settings 工程
|
||||
|
||||
## 4. 基础开发说明
|
||||
## 5. 典型接口的使用
|
||||
|
||||
|
||||
## 6. 签名打包
|
||||
|
||||
### **1)签名 **
|
||||
|
||||
> 打开项目工程,选择File → Project Structure
|
||||
>
|
||||
> ![](./img/6-1.png)
|
||||
>
|
||||
> 选择Modules → Signing Configs
|
||||
> 将对应的签名文件配置如下,完成后点击Apply,再点击OK
|
||||
>
|
||||
> ![](./img/6-2.png)
|
||||
>
|
||||
> 注:签名文件请参考 ([华为开发者官网](https://developer.huawei.com/consumer/cn/))
|
||||
>
|
||||
> 配置完成后,对应的build.gradle文件中会出现如下内容
|
||||
>
|
||||
> ![](./img/6-3.png)
|
||||
>
|
||||
>
|
||||
|
||||
### 打包
|
||||
|
||||
> 编译hap包
|
||||
>
|
||||
> 签名准备完成后,选择Build → Build Haps(s)/APP(s) → Build Hap(s)
|
||||
>
|
||||
> ![](./img/6-4.png)
|
||||
>
|
||||
> 编译完成后,hap包会生成在entry\build\outputs\hap\debug\phone\路径下(如果没有配置签名,则只会生成未签名的hap包)
|
||||
>
|
||||
> ![](./img/6-5.png)
|
||||
|
||||
|
||||
|
||||
## 7. 安装、运行、调试
|
||||
|
||||
### 应用安装、运行
|
||||
#### 应用安装
|
||||
获取 root 权限与读写权限:
|
||||
|
||||
```
|
||||
adb root
|
||||
adb remount
|
||||
```
|
||||
将签名好的 hap 包放入设备的 `/system/app` 目录下。
|
||||
|
||||
```
|
||||
adb push settings.hap /system/app
|
||||
```
|
||||
> 注意,如果设备不存在 `/system/app` 目录,则需要手动创建该目录。
|
||||
> ```
|
||||
> cd system
|
||||
> mkdir app
|
||||
> ```
|
||||
> `/system/app` 目录放置系统应用,例如:Launcher,SystemUI,Settings 等。此目录应用不用安装系统自动拉起。
|
||||
|
||||
|
||||
#### 应用运行
|
||||
Launcher属于系统应用,在将签名的 hap 包放入 `/system/app` 目录后,重启系统,应用会自动拉起。
|
||||
```
|
||||
adb reboot
|
||||
```
|
||||
> 注意,如果设备之前安装过 Launcher 应用,则需要执行如下两条命令清除设备中存储的应用信息才能够在应用重启的时候将我们装入设备的新 hap 包正常拉起。
|
||||
> ```
|
||||
> adb shell rm -rf /data/accounts/
|
||||
> adb shell rm -rf /data/bundlemgr/
|
||||
> ```
|
||||
### 应用调试
|
||||
#### log打印
|
||||
- 在程序中添加 log
|
||||
```JS
|
||||
console.info("Setting log info");
|
||||
```
|
||||
可以在DevEco Studio中查看log
|
||||
![](./img/ds_hilog_window.png)
|
||||
|
||||
#### log获取及过滤
|
||||
- log获取
|
||||
|
||||
将log输出至文件
|
||||
```
|
||||
adb shell hilog > 输出文件名称
|
||||
```
|
||||
|
||||
例:
|
||||
在真实环境查看log,将全log输出到当前目录的hilog.log文件中
|
||||
```
|
||||
adb shell hilog > hilog.log
|
||||
```
|
||||
|
||||
- log过滤
|
||||
|
||||
在命令行窗口中过滤log
|
||||
```
|
||||
hilog | grep 过滤信息
|
||||
```
|
||||
|
||||
例:过滤包含信息 Label 的 hilog
|
||||
```
|
||||
hilog | grep Label
|
||||
```
|
||||
|
||||
## 8. 发布hap包
|
||||
### 重命名hap包
|
||||
将编译生成的 hap 包按照如下规则重命名:
|
||||
|模块|包名|
|
||||
|:--|-|
|
||||
|settings|Settings.hap|
|
||||
|
||||
### 发布到码云
|
||||
1. 访问码云的hap包仓库([仓库地址](https://gitee.com/OHOS_STD/applications_standard_hap))。
|
||||
|
||||
2. 将仓库克隆到本地
|
||||
点击“克隆/下载”按钮,选择SSH标签,点击复制,使用 `git clone` 命令将复制的地址克隆到本地目录。
|
||||
![](./img/hap_repo.png)
|
||||
|
||||
```
|
||||
git clone 复制的地址
|
||||
```
|
||||
|
||||
3. 将签名后的 hap 包放入本地目录,并提交。
|
||||
```
|
||||
git add .
|
||||
git commit -m "提交信息"
|
||||
```
|
||||
|
||||
4. 使用 git push 命令将其推送到 hap 包仓库。
|
||||
```
|
||||
git push
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
System apps
|
||||
|
||||
**applications\_settings**
|
||||
|
||||
|
@ -1,6 +1,3 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
apply plugin: 'com.huawei.ohos.app'
|
||||
|
||||
ohos {
|
||||
compileSdkVersion 6
|
||||
defaultConfig {
|
||||
@ -22,7 +19,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.huawei.ohos:hap:2.4.4.3-RC'
|
||||
classpath 'com.huawei.ohos:hap:3.0.1.6'
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,4 +36,4 @@ allprojects {
|
||||
}
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
}
|
2
entry/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/build
|
||||
/node_modules
|
@ -2,10 +2,12 @@ apply plugin: 'com.huawei.ohos.hap'
|
||||
ohos {
|
||||
compileSdkVersion 6
|
||||
defaultConfig {
|
||||
compatibleSdkVersion 6
|
||||
compatibleSdkVersion 4
|
||||
}
|
||||
supportSystem "standard"
|
||||
supportSystem "standard"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
}
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
@ -1 +0,0 @@
|
||||
{}
|
1
entry/proguard-rules.pro
vendored
Normal file
@ -0,0 +1 @@
|
||||
# config module specific ProGuard rules here.
|
@ -3,25 +3,23 @@
|
||||
"bundleName": "com.ohos.settings",
|
||||
"vendor": "ohos",
|
||||
"version": {
|
||||
"code": 1,
|
||||
"name": "1.0"
|
||||
},
|
||||
"apiVersion": {
|
||||
"compatible": 3,
|
||||
"target": 3
|
||||
"code": 1000000,
|
||||
"name": "1.0.0"
|
||||
}
|
||||
},
|
||||
"deviceConfig": {},
|
||||
"module": {
|
||||
"package": "com.ohos.settings",
|
||||
"name": ".MyApplication",
|
||||
"mainAbility": "com.ohos.settings.MainAbility",
|
||||
"deviceType": [
|
||||
"phone"
|
||||
],
|
||||
"distro": {
|
||||
"deliveryWithInstall": true,
|
||||
"moduleName": "entry",
|
||||
"moduleType": "entry"
|
||||
"moduleType": "entry",
|
||||
"installationFree": true
|
||||
},
|
||||
"abilities": [
|
||||
{
|
||||
@ -35,30 +33,35 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"visible": true,
|
||||
"name": "com.ohos.settings.MainAbility",
|
||||
"icon": "$media:icon",
|
||||
"description": "$string:mainability_description",
|
||||
"label": "$string:app_name",
|
||||
"label": "$string:entry_MainAbility",
|
||||
"type": "page",
|
||||
"launchType": "standard"
|
||||
}
|
||||
],
|
||||
"js": [
|
||||
{
|
||||
"mode": {
|
||||
"syntax": "ets",
|
||||
"type": "pageAbility"
|
||||
},
|
||||
"pages": [
|
||||
"pages/settingList/settingList",
|
||||
"pages/wifi/wifi",
|
||||
"pages/dateAndTime/dateAndTime",
|
||||
"pages/brightness/brightnessSettings",
|
||||
"pages/searchInfo/searchInfo",
|
||||
"pages/appManagement/appManagement",
|
||||
"pages/aboutDevice/aboutDevice",
|
||||
"pages/applicationInfo/applicationInfo"
|
||||
"pages/settingList",
|
||||
"pages/dateAndTime",
|
||||
"pages/applicationInfo",
|
||||
"pages/brightnessSettings",
|
||||
"pages/aboutDevice",
|
||||
"pages/appManagement",
|
||||
"pages/wifi",
|
||||
"pages/wifiPsd"
|
||||
],
|
||||
"name": "default",
|
||||
"window": {
|
||||
"designWidth": 720,
|
||||
"autoDesignWidth": true
|
||||
"autoDesignWidth": false
|
||||
}
|
||||
}
|
||||
]
|
||||
|
45
entry/src/main/js/default/app.js → entry/src/main/ets/default/app.ets
Executable file → Normal file
@ -1,23 +1,22 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export default {
|
||||
onCreate() {
|
||||
console.info('AceApplication onCreate');
|
||||
},
|
||||
onDestroy() {
|
||||
console.info('AceApplication onDestroy');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export default {
|
||||
onCreate() {
|
||||
console.info('Application onCreate')
|
||||
},
|
||||
onDestroy() {
|
||||
console.info('Application onDestroy')
|
||||
},
|
||||
}
|
106
entry/src/main/ets/default/common/baseUtil/ConfigData.ets
Normal file
@ -0,0 +1,106 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export class ConfigData {
|
||||
FILE_URI = '/data/accounts/account_0/applications/com.ohos.settings'
|
||||
+ '/com.ohos.settings/assets/entry/resources/rawfile/';
|
||||
PREFERENCES_PATH = '/data/accounts/account_0/appdata/com.ohos.settings/sharedPreference/SettingPreferences';
|
||||
BRIGHTNESS_SAVE_VALUE_KEY = 'BrightnessSaveValue';
|
||||
SENT_EVENT_BROADCAST_BRIGHTNESS_VALUE = 'BRIGHTNESS_VALUE';
|
||||
SENT_EVENT_WIFI_CONNECT_NAME = 'WIFI_CONNECT_NAME';
|
||||
BRIGHTNESS_DEFAULT_VALUE = 50;
|
||||
|
||||
WH_100_100 = '100%';
|
||||
WH_30_100 = '30%';
|
||||
WH_40_100 = '40%';
|
||||
WH_45_100 = '45%';
|
||||
WH_50_100 = '50%';
|
||||
WH_55_100 = '55%';
|
||||
WH_83_100 = '83%';
|
||||
WH_90_100 = '90%';
|
||||
value_1 = 1;
|
||||
value_5 = 5;
|
||||
value_10 = 10;
|
||||
value_15 = 15;
|
||||
value_20 = 20;
|
||||
value_40 = 40;
|
||||
value_50 = 50;
|
||||
value_60 = 60;
|
||||
value_65 = 65;
|
||||
value_70 = 70;
|
||||
value_80 = 80;
|
||||
value_130 = 130;
|
||||
value_160 = 160;
|
||||
font_18 = 18;
|
||||
font_20 = 20;
|
||||
font_22 = 22;
|
||||
font_24 = 24;
|
||||
|
||||
ONE_HUNDRED_PERCENT = '100%';
|
||||
THIRTY_PERCENT = '30%';
|
||||
FORTY_PERCENT = '40%';
|
||||
FIFTY_PERCENT = '50%';
|
||||
FORTY_FIVE_PERCENT = '45%';
|
||||
FIFTY_FIVE_PERCENT = '55%';
|
||||
|
||||
height_value_1 = 1;
|
||||
height_value_5 = 5;
|
||||
height_value_10 = 10;
|
||||
height_value_15 = 15;
|
||||
height_value_20 = 20;
|
||||
height_value_40 = 40;
|
||||
height_value_60 = 60;
|
||||
height_value_65 = 65;
|
||||
height_value_70 = 70;
|
||||
height_value_80 = 80;
|
||||
height_value_160 = 160;
|
||||
|
||||
width_value_1 = 1;
|
||||
width_value_5 = 5;
|
||||
width_value_10 = 10;
|
||||
width_value_15 = 15;
|
||||
width_value_20 = 20;
|
||||
width_value_40 = 40;
|
||||
width_value_60 = 60;
|
||||
width_value_65 = 65;
|
||||
width_value_70 = 70;
|
||||
width_value_80 = 80;
|
||||
width_value_160 = 160;
|
||||
|
||||
font_size_18 = 18;
|
||||
font_size_20 = 20;
|
||||
font_size_22 = 22;
|
||||
font_size_24 = 24;
|
||||
|
||||
color_333333_grey = '#333333';
|
||||
color_666666_grey = '#666666';
|
||||
color_999999_grey = '#999999';
|
||||
color_E3E3E3_grey = '#E3E3E3';
|
||||
color_00000000_white = '#00000000';
|
||||
|
||||
color_333333 = '#333333';
|
||||
color_666666 = '#666666';
|
||||
color_999999 = '#999999';
|
||||
color_E3E3E3 = '#E3E3E3';
|
||||
color_00000000 = '#00000000';
|
||||
MAX_LINES_1 = 1;
|
||||
MAX_LINES_2 = 2;
|
||||
MAX_LINES_3 = 3;
|
||||
DURATION_TIME = 200;
|
||||
}
|
||||
|
||||
let configData = new ConfigData();
|
||||
export default configData as ConfigData
|
||||
;
|
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/**
|
||||
* date package tool class
|
||||
*/
|
||||
export class DateAndTimeUtil{
|
||||
/**
|
||||
*
|
||||
* Get the current time
|
||||
*/
|
||||
getSystemTime() {
|
||||
let datetime = new Date();
|
||||
let hours = datetime.getHours();
|
||||
let minutes = datetime.getMinutes();
|
||||
let time = this.concatTime(hours, minutes)
|
||||
return time;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Get the current date
|
||||
*/
|
||||
getSystemDate() {
|
||||
let dateTime = new Date();
|
||||
let year = dateTime.getFullYear();
|
||||
let month = dateTime.getMonth() + 1;
|
||||
let day = dateTime.getDate();
|
||||
let date = this.concatDate(year,month,day)
|
||||
return date
|
||||
}
|
||||
/**
|
||||
* format
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
fill(value) {
|
||||
return (value > 9 ? "" : "0") + value;
|
||||
};
|
||||
/**
|
||||
* concat date
|
||||
* @param year m d
|
||||
* @return
|
||||
*/
|
||||
concatDate(year, month, date) {
|
||||
return year + '年' + month + '月' + date + '日';
|
||||
};
|
||||
|
||||
concatTime(hours, minutes) {
|
||||
return `${this.fill(hours)}:${this.fill(minutes)}`;
|
||||
};
|
||||
}
|
||||
|
||||
let dateAndTimeUtil = new DateAndTimeUtil();
|
||||
export default dateAndTimeUtil as DateAndTimeUtil
|
146
entry/src/main/js/default/common/baseUtil/LogUtil.js → entry/src/main/ets/default/common/baseUtil/LogUtil.ets
Executable file → Normal file
@ -1,71 +1,75 @@
|
||||
/**
|
||||
* 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 BaseModel from '../../model/BaseModel.js';
|
||||
|
||||
/**
|
||||
* Log level
|
||||
*/
|
||||
let LOG_LEVEL = {
|
||||
/**
|
||||
* debug
|
||||
*/
|
||||
DEBUG: 'debug',
|
||||
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
LOG: 'log',
|
||||
|
||||
/**
|
||||
* info
|
||||
*/
|
||||
INFO: 'info',
|
||||
|
||||
/**
|
||||
* warn
|
||||
*/
|
||||
WARN: 'warn',
|
||||
|
||||
/**
|
||||
* error
|
||||
*/
|
||||
ERROR: 'error'
|
||||
};
|
||||
|
||||
/**
|
||||
* log package tool class
|
||||
*/
|
||||
export default class LogUtil extends BaseModel {
|
||||
debug(msg) {
|
||||
console.info(msg);
|
||||
}
|
||||
|
||||
log(msg) {
|
||||
console.log(msg);
|
||||
|
||||
}
|
||||
|
||||
info(msg) {
|
||||
console.info(msg);
|
||||
}
|
||||
|
||||
warn(msg) {
|
||||
console.warn(msg);
|
||||
}
|
||||
|
||||
error(msg) {
|
||||
console.error(msg);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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 BaseModel from '../../model/BaseModel.ets';
|
||||
|
||||
/**
|
||||
* Log level
|
||||
*/
|
||||
let LOG_LEVEL = {
|
||||
/**
|
||||
* debug
|
||||
*/
|
||||
DEBUG: 'debug',
|
||||
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
LOG: 'log',
|
||||
|
||||
/**
|
||||
* info
|
||||
*/
|
||||
INFO: 'info',
|
||||
|
||||
/**
|
||||
* warn
|
||||
*/
|
||||
WARN: 'warn',
|
||||
|
||||
/**
|
||||
* error
|
||||
*/
|
||||
ERROR: 'error'
|
||||
};
|
||||
|
||||
/**
|
||||
* log package tool class
|
||||
*/
|
||||
export class LogUtil extends BaseModel {
|
||||
debug(msg): void {
|
||||
console.info(msg);
|
||||
}
|
||||
|
||||
log(msg): void {
|
||||
console.log(msg);
|
||||
|
||||
}
|
||||
|
||||
info(msg): void {
|
||||
console.info(msg);
|
||||
}
|
||||
|
||||
warn(msg): void {
|
||||
console.warn(msg);
|
||||
}
|
||||
|
||||
error(msg): void {
|
||||
console.error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
let mLogUtil = new LogUtil();
|
||||
export default mLogUtil as LogUtil
|
||||
;
|
@ -0,0 +1,78 @@
|
||||
/**
|
||||
* 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 BrightnessSettingModel from '../../model/brightnessImpl/BrightnessSettingModel.ets';
|
||||
import CommonEvent from '@ohos.commonevent';
|
||||
|
||||
let mCommonEventSubscribeInfo = {
|
||||
events: ['usual.event.wifi.CONN_STATE', 'BRIGHTNESS_VALUE_SYSTEM_UI']
|
||||
};
|
||||
|
||||
let mCommonEventSubscriber = null;
|
||||
let eventSubscriber = null;
|
||||
|
||||
export class SubscriberUtils {
|
||||
sendEvent(value, broadcastName) {
|
||||
console.log(`settings settingList sendEvent ets in value:` + value + "|broadcastName:" + broadcastName);
|
||||
let commonEventPublishData = {
|
||||
data: value
|
||||
};
|
||||
CommonEvent.publish(broadcastName, commonEventPublishData, (err, data) => {
|
||||
console.log(`settings settingList sendEvent ets ${JSON.stringify(err)}`);
|
||||
console.log(`settings settingList sendEvent ets ${JSON.stringify(data)}`);
|
||||
});
|
||||
console.log(`settings settingList sendEvent ets out`);
|
||||
}
|
||||
|
||||
registerStatusListener() {
|
||||
console.info(`settings settingList Subscriberregister status listener in`);
|
||||
CommonEvent.createSubscriber(
|
||||
mCommonEventSubscribeInfo,
|
||||
this.createStatusSubscriberCallBack.bind(this)
|
||||
);
|
||||
console.info(`settings settingList Subscriberregister status listener out`);
|
||||
}
|
||||
|
||||
createStatusSubscriberCallBack(err, data) {
|
||||
console.info(`settings settingList Subscriberregister in ets ${JSON.stringify(err)} ${JSON.stringify(data)}`);
|
||||
mCommonEventSubscriber = data;
|
||||
CommonEvent.subscribe(mCommonEventSubscriber, this.statusSubscriberCallBack.bind(this));
|
||||
console.info(`settings settingList Subscriberregister in`);
|
||||
}
|
||||
|
||||
statusSubscriberCallBack(err, data) {
|
||||
console.info(`settings settingList statusSubscriberCallBack data ets : ${JSON.stringify(data)}` );
|
||||
console.info(`settings settingList statusSubscriberCallBack err ets : ${JSON.stringify(err)}`);
|
||||
console.log(`settings settingList statusSubscriberCallBack data.event ets : ${data.event} `);
|
||||
if ("BRIGHTNESS_VALUE_SYSTEM_UI" === data.event) {
|
||||
BrightnessSettingModel.setBrightnessListener(data.data + '');
|
||||
BrightnessSettingModel.setStorageValue(data.data);
|
||||
}
|
||||
if (err) {
|
||||
console.info(`settings settingList statusSubscriberCallBack error : ${err}`)
|
||||
return;
|
||||
}
|
||||
console.log(`settings settingList statusSubscriberCallBack out`);
|
||||
}
|
||||
|
||||
unSubscriberListener() {
|
||||
CommonEvent.unsubscribe(eventSubscriber, () => {
|
||||
console.info('settings settingList unSubscriberListener');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let subscriberUtils = new SubscriberUtils();
|
||||
export default subscriberUtils as SubscriberUtils
|
||||
;
|
36
entry/src/main/js/default/model/BaseModel.js → entry/src/main/ets/default/model/BaseModel.ets
Executable file → Normal file
@ -1,19 +1,19 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export default class BaseModel {
|
||||
constructor() {
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export default class BaseModel {
|
||||
constructor() {
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 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 BaseModel from '../BaseModel';
|
||||
import BaseParseConfModel from '../baseParseConfImpl/BaseParseConfModel.ets';
|
||||
import ConfigData from '../../common/baseUtil/ConfigData.ets';
|
||||
import LogUtil from '../../common/baseUtil/LogUtil.ets';
|
||||
import deviceInfo from '@ohos.deviceInfo';
|
||||
|
||||
/**
|
||||
* about device service class
|
||||
*/
|
||||
export class AboutDeviceModel extends BaseModel {
|
||||
setOnAboutDeviceListener(): any {
|
||||
LogUtil.info('settings setOnAboutDeviceListener in');
|
||||
LogUtil.info('settings setOnAboutDeviceListener deviceInfo ' + JSON.stringify(deviceInfo));
|
||||
return deviceInfo;
|
||||
}
|
||||
|
||||
public getAboutDeviceInfoListener(): any[] {
|
||||
LogUtil.info('settings getAboutDeviceInfoListener come in');
|
||||
return BaseParseConfModel.getJsonData(ConfigData.FILE_URI.concat('aboutDevice.json'));
|
||||
}
|
||||
}
|
||||
|
||||
let aboutDeviceModel = new AboutDeviceModel();
|
||||
export default aboutDeviceModel as AboutDeviceModel
|
||||
;
|
@ -0,0 +1,104 @@
|
||||
/**
|
||||
* 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 ConfigData from '../../common/baseUtil/ConfigData.ets';
|
||||
import BaseModel from '../BaseModel.ets';
|
||||
import LogUtil from '../../common/baseUtil/LogUtil.ets';
|
||||
import Bundle from '@ohos.bundle';
|
||||
import ResMgr from '@ohos.resourceManager';
|
||||
|
||||
|
||||
const INDEX = 0;
|
||||
const IS_INCLUDE_ABILITY_INFO = 0;
|
||||
/**
|
||||
* app management service class
|
||||
*/
|
||||
export class AppManagementModel extends BaseModel {
|
||||
private mBundleInfoList: any[]= [];
|
||||
|
||||
setAppManagementListener() {
|
||||
LogUtil.info('settings AppManagementModel getIconItem ResMgr:' + JSON.stringify(ResMgr));
|
||||
Bundle.getBundleInfos(IS_INCLUDE_ABILITY_INFO)
|
||||
.then((data) => {
|
||||
LogUtil.info('settings AppManagementModel setAppManagementListener getBundleInfos() start ');
|
||||
LogUtil.info('settings AppManagementModel data.length: ' + data.length + ' data: ' + JSON.stringify(data));
|
||||
this.getIconItem(INDEX, data.length, data);
|
||||
});
|
||||
LogUtil.info('settings appManagement init AppManagementModel setAppManagementListener end');
|
||||
}
|
||||
|
||||
getIconItem(index, count, data) {
|
||||
LogUtil.info('settings AppManagementModel getIconItem start data.length' + data.length);
|
||||
let imageValue = '';
|
||||
let label = '';
|
||||
let that = this;
|
||||
LogUtil.info('settings AppManagementModel data[index].name :' + data[index].name);
|
||||
try {
|
||||
ResMgr.getResourceManager(data[index].name, (error, item) => {
|
||||
LogUtil.info('settings AppManagementModel getResourceManager item' + JSON.stringify(item) + "|error:" + error);
|
||||
let appInfo = data[index].appInfo;
|
||||
if (appInfo.labelId > 0) {
|
||||
item.getString(appInfo.labelId, (error, value) => {
|
||||
LogUtil.info('settings AppManagementModel getResourceManager value.length:' + value.length);
|
||||
if (value != null) {
|
||||
LogUtil.info('settings AppManagementModel getResourceManager getString() value:' + value);
|
||||
label = value;
|
||||
LogUtil.info('settings AppManagementModel getResourceManager getString() label:' + label);
|
||||
} else {
|
||||
LogUtil.info('settings AppManagementModel getResourceManager getString() error:' + error);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
LogUtil.info('settings AppManagementModel getResourceManager getString() label:' + appInfo.label);
|
||||
label = appInfo.label;
|
||||
}
|
||||
LogUtil.info('settings AppManagementModel getResourceManager getString() finish label:' + label);
|
||||
item.getMediaBase64(appInfo.iconId, (error, value) => {
|
||||
LogUtil.info('settings AppManagementModel getResourceManager getMediaBase64() :' + value.length);
|
||||
if (value.length > 0) {
|
||||
imageValue = value;
|
||||
LogUtil.info('settings AppManagementModel getResourceManager getMediaBase64() imageValue:' + imageValue);
|
||||
}
|
||||
LogUtil.info('settings AppManagementModel getResourceManager getMediaBase64() end');
|
||||
this.mBundleInfoList.push({
|
||||
settingIcon: imageValue,
|
||||
settingTitle: label,
|
||||
settingValue: '',
|
||||
settingArrow: $r('app.media.ic_settings_arrow'),
|
||||
settingSummary: '版本:' + data[index].versionName,
|
||||
settingBundleName: data[index].name,
|
||||
settingIconId: appInfo.iconId,
|
||||
settingUri: 'pages/applicationInfo'
|
||||
});
|
||||
if (count - 1 > index) {
|
||||
LogUtil.info('settings AppManagementModel getMediaBase64() if index:' + index + ' | count:' + count);
|
||||
index = index + 1;
|
||||
that.getIconItem(index, count, data);
|
||||
} else {
|
||||
LogUtil.info('settings AppManagementModel getMediaBase64() else index:' + index + ' | count:' + count);
|
||||
LogUtil.info('settings AppManagementModel mBundleInfoList[i]: ' + JSON.stringify(this.mBundleInfoList));
|
||||
AppStorage.SetOrCreate('appManagementList', this.mBundleInfoList);
|
||||
}
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
LogUtil.info('settings AppManagementModel catch error:' + error);
|
||||
}
|
||||
LogUtil.info('settings appManagement AppManagementModel getIconItem end');
|
||||
}
|
||||
}
|
||||
|
||||
let appManagementModel = new AppManagementModel();
|
||||
export default appManagementModel as AppManagementModel
|
||||
;
|
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* 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 BaseModel from '../BaseModel.ets';
|
||||
import LogUtil from '../../common/baseUtil/LogUtil.ets';
|
||||
import FileIo from '@ohos.fileio';
|
||||
|
||||
const DFAULT_SIZE = 4096;
|
||||
const CHAR_CODE_AT_INDEX = 0;
|
||||
|
||||
export class BaseParseConfModel extends BaseModel {
|
||||
public getJsonData(fileName: string): any[]{
|
||||
LogUtil.info('settings BaseParseConfModel in');
|
||||
try {
|
||||
let stream = FileIo.createStreamSync(fileName, 'r');
|
||||
LogUtil.info('settings BaseParseConfModel getJsonData try stream:' + stream);
|
||||
let buf = new ArrayBuffer(DFAULT_SIZE);
|
||||
let len = stream.readSync(buf);
|
||||
LogUtil.info('settings BaseParseConfModel getJsonData try len:' + len);
|
||||
let arr = new Uint8Array(buf);
|
||||
let charAt = ' '.charCodeAt(CHAR_CODE_AT_INDEX);
|
||||
for (let i = len;i < DFAULT_SIZE; i++) {
|
||||
arr[i] = charAt;
|
||||
}
|
||||
let content = String.fromCharCode.apply(null, arr);
|
||||
stream.closeSync();
|
||||
LogUtil.info('settings BaseParseConfModel getJsonData try content:' + JSON.stringify(content));
|
||||
return JSON.parse(content);
|
||||
} catch (jsonError) {
|
||||
LogUtil.info('settings BaseParseConfModel getJsonData catch jsonError:' + jsonError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let baseParseConfModel = new BaseParseConfModel();
|
||||
export default baseParseConfModel as BaseParseConfModel
|
||||
;
|
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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 BaseModel from '../BaseModel.ets';
|
||||
import LogUtil from '../../common/baseUtil/LogUtil.ets';
|
||||
import ConfigData from '../../common/baseUtil/ConfigData.ets';
|
||||
import SubscriberUtils from '../../common/baseUtil/SubscriberUtil.ets';
|
||||
import Brightness from '@ohos.brightness';
|
||||
import Storage from '@ohos.data.storage';
|
||||
|
||||
let mBrightnessPreferences = Storage.getStorageSync(ConfigData.PREFERENCES_PATH);
|
||||
|
||||
export class BrightnessSettingModel extends BaseModel {
|
||||
setBrightnessListener(brightnessValue) {
|
||||
LogUtil.info('settings settingList BrightnessSettingModel Brightness:'+brightnessValue);
|
||||
Brightness.setValue(brightnessValue);
|
||||
LogUtil.info('settings settingList BrightnessSettingModel end');
|
||||
}
|
||||
|
||||
setStorageValue(brightnessValue) {
|
||||
LogUtil.info('settings BrightnessSettingModel setStorageValue Storage:'+brightnessValue);
|
||||
mBrightnessPreferences.putSync(ConfigData.BRIGHTNESS_SAVE_VALUE_KEY, brightnessValue);
|
||||
mBrightnessPreferences.flushSync();
|
||||
}
|
||||
|
||||
getStorageValue(): any {
|
||||
LogUtil.info('settings BrightnessSettingModel getStorageValue in');
|
||||
mBrightnessPreferences.getSync(ConfigData.BRIGHTNESS_SAVE_VALUE_KEY, ConfigData.BRIGHTNESS_DEFAULT_VALUE));
|
||||
return mBrightnessPreferences.getSync(ConfigData.BRIGHTNESS_SAVE_VALUE_KEY, ConfigData.BRIGHTNESS_DEFAULT_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
let brightnessSettingModel = new BrightnessSettingModel();
|
||||
export default brightnessSettingModel as BrightnessSettingModel;
|
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 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 BaseModel from '../BaseModel';
|
||||
import BaseParseConfModel from '../baseParseConfImpl/BaseParseConfModel.ets';
|
||||
import ConfigData from '../../common/baseUtil/ConfigData.ets';
|
||||
import LogUtil from '../../common/baseUtil/LogUtil.ets';
|
||||
import SystemTime from '@ohos.systemTime';
|
||||
|
||||
export class DateAndTimeModel extends BaseModel {
|
||||
setTime(time) {
|
||||
LogUtil.info('DateAndTimeModel setTime in');
|
||||
SystemTime.setTime(time).then(data => {
|
||||
LogUtil.info(`DateAndTimeModel setTime promise then : ${data}`);
|
||||
})
|
||||
.catch(error => {
|
||||
LogUtil.info(`DateAndTimeModel setTime promise1 catch : ${error}`);
|
||||
}
|
||||
);
|
||||
LogUtil.info('DateAndTimeModel setTime out');
|
||||
}
|
||||
|
||||
public dateAndTimeListener(): any[] {
|
||||
LogUtil.info('getAboutDeviceInfoListener come in');
|
||||
return BaseParseConfModel.getJsonData(ConfigData.FILE_URI.concat('dateAndTime.json'));
|
||||
}
|
||||
}
|
||||
|
||||
let dateAndTimeModel = new DateAndTimeModel();
|
||||
export default dateAndTimeModel as DateAndTimeModel
|
||||
;
|
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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 ConfigData from '../../common/baseUtil/ConfigData.ets';
|
||||
import LogUtil from '../../common/baseUtil/LogUtil.ets';
|
||||
import BaseParseConfModel from '../baseParseConfImpl/BaseParseConfModel.ets';
|
||||
import BaseModel from '../BaseModel.ets';
|
||||
import FeatureAbility from '@ohos.ability.featureAbility';
|
||||
|
||||
/**
|
||||
* app setting homepage service class
|
||||
*/
|
||||
export class SettingListModel extends BaseModel {
|
||||
setSettingListener(): any[]{
|
||||
LogUtil.info('settings SettingListModel setSettingListener in');
|
||||
return BaseParseConfModel.getJsonData(ConfigData.FILE_URI.concat('settinglist.json'));
|
||||
}
|
||||
|
||||
startPage(callback): void{
|
||||
LogUtil.info('settings SettingList startPage start');
|
||||
FeatureAbility.getWant().then((Want) => {
|
||||
LogUtil.info(`settings SettingList startWifiPage successful. Data: ${ JSON.stringify(Want) }`);
|
||||
LogUtil.info(`settings SettingList startWifiPage successful. Want.uri: ${ Want.uri }`);
|
||||
callback( Want.uri);
|
||||
})
|
||||
.catch((error) => {
|
||||
LogUtil.error('settings SettingList startWifiPage failed. Cause: ' + JSON.stringify(error));
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
let settingListModel = new SettingListModel();
|
||||
export default settingListModel as SettingListModel
|
||||
;
|
162
entry/src/main/ets/default/model/wifiImpl/WifiModel.ets
Normal file
@ -0,0 +1,162 @@
|
||||
/**
|
||||
* 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 LogUtil from '../../common/baseUtil/LogUtil.ets';
|
||||
import WifiNativeJs from '@ohos.wifi_native_js';
|
||||
import BaseParseConfModel from '../baseParseConfImpl/BaseParseConfModel.ets';
|
||||
import BaseModel from '../BaseModel.ets';
|
||||
|
||||
export class WifiModel extends BaseModel {
|
||||
private mWifiList: any[] = [];
|
||||
private remdupWifiList: any[] = [];
|
||||
|
||||
getWifiStatus() {
|
||||
LogUtil.info('WifiNativeJs isWifiActive');
|
||||
return WifiNativeJs.isWifiActive();
|
||||
}
|
||||
|
||||
getEnableWifi() {
|
||||
LogUtil.info('WifiNativeJs enableWifi');
|
||||
return WifiNativeJs.enableWifi();
|
||||
}
|
||||
|
||||
disableWifi() {
|
||||
LogUtil.info('WifiNativeJs enableWifi');
|
||||
return WifiNativeJs.disableWifi();
|
||||
}
|
||||
|
||||
getScanWifi() {
|
||||
LogUtil.info('WifiNativeJs scan');
|
||||
return WifiNativeJs.scan();
|
||||
}
|
||||
|
||||
getScanInfoCallBack() {
|
||||
LogUtil.info('get to wifi info start');
|
||||
this.mWifiList = [];
|
||||
this.remdupWifiList = [];
|
||||
WifiNativeJs.getScanInfos(result => {
|
||||
if (result === null) {
|
||||
return;
|
||||
}
|
||||
LogUtil.info('[wifi_js_test] wifi received scan info call back results:' + JSON.stringify(result));
|
||||
let clen = Object.keys(result)
|
||||
.length;
|
||||
let image;
|
||||
LogUtil.info('[wifi_js_test] wifi received scan info call back length:' + clen);
|
||||
for (let j = 0; j < clen; j++) {
|
||||
LogUtil.info('result[0].ssid: ' + result[j].ssid);
|
||||
LogUtil.info('securityType: ' + result[j].securityType);
|
||||
LogUtil.info('rssi: ' + result[j].rssi);
|
||||
LogUtil.info('bssid: ' + result[j].bssid);
|
||||
LogUtil.info('band: ' + result[j].band);
|
||||
LogUtil.info('frequency: ' + result[j].frequency);
|
||||
LogUtil.info('timestamp: ' + result[j].timestamp);
|
||||
LogUtil.info('SignalLevel: ' + WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band));
|
||||
if (result[j].securityType === 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 4) {
|
||||
image = '/res/image/ic_wifi_signal_4_dark.svg';
|
||||
LogUtil.info('securityType 1 and signal level 4');
|
||||
}
|
||||
if (result[j].securityType === 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 3) {
|
||||
image = '/res/image/ic_wifi_signal_3_dark.svg';
|
||||
LogUtil.info('securityType 1 and signal level 3');
|
||||
}
|
||||
if (result[j].securityType === 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 2) {
|
||||
image = '/res/image/ic_wifi_signal_2_dark.svg';
|
||||
LogUtil.info('securityType 1 and signal level 2');
|
||||
}
|
||||
if (result[j].securityType === 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 1) {
|
||||
image = '/res/image/ic_wifi_signal_1_dark.svg';
|
||||
LogUtil.info('securityType 1 and signal level 1');
|
||||
}
|
||||
if (result[j].securityType === 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 0) {
|
||||
image = '/res/image/ic_wifi_signal_1_dark.svg';
|
||||
LogUtil.info('securityType 1 and signal level 1');
|
||||
}
|
||||
if (result[j].securityType !== 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 4) {
|
||||
image = '/res/image/ic_wifi_lock_signal_4_dark.svg';
|
||||
LogUtil.info('securityType lock and level 4');
|
||||
}
|
||||
if (result[j].securityType !== 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 3) {
|
||||
image = '/res/image/ic_wifi_lock_signal_3_dark.svg';
|
||||
LogUtil.info('securityType lock and level 3');
|
||||
}
|
||||
if (result[j].securityType !== 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 2) {
|
||||
image = '/res/image/ic_wifi_lock_signal_2_dark.svg';
|
||||
LogUtil.info('securityType lock and level 2');
|
||||
}
|
||||
if (result[j].securityType !== 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 1) {
|
||||
image = '/res/image/ic_wifi_lock_signal_1_dark.svg';
|
||||
LogUtil.info('securityType lock and level 1');
|
||||
}
|
||||
if (result[j].securityType !== 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 0) {
|
||||
image = '/res/image/ic_wifi_lock_signal_1_dark.svg';
|
||||
LogUtil.info('securityType lock and level 1');
|
||||
}
|
||||
|
||||
if (result[j].ssid === '' || result[j] === null) {
|
||||
LogUtil.info('result ssid empty');
|
||||
} else {
|
||||
this.mWifiList.push({
|
||||
settingSummary: '',
|
||||
settingTitle: result[j].ssid,
|
||||
settingValue: '',
|
||||
settingArrow: image,
|
||||
settingRssi : result[j].rssi,
|
||||
bssid: result[j].bssid,
|
||||
securityType: result[j].securityType,
|
||||
signalLevel: WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band),
|
||||
});
|
||||
}
|
||||
}
|
||||
LogUtil.info('original mWifiList :' + JSON.stringify(this.mWifiList));
|
||||
for (let i = 0; i < this.mWifiList.length; i++) {
|
||||
let position = this.getItemPosition(this.remdupWifiList, this.mWifiList[i].settingTitle);
|
||||
if (position !== -1) {
|
||||
if (this.remdupWifiList[position].signalLevel < this.mWifiList[i].signalLevel) {
|
||||
this.remdupWifiList.splice(position, 1);
|
||||
this.remdupWifiList.splice(position, 0, this.mWifiList[i]);
|
||||
}
|
||||
} else {
|
||||
this.remdupWifiList.push(this.mWifiList[i]);
|
||||
}
|
||||
}
|
||||
AppStorage.SetOrCreate('WifiList', this.remdupWifiList);
|
||||
LogUtil.info('remove duplicate ssid remdupWifiList: ' + JSON.stringify(this.remdupWifiList));
|
||||
});
|
||||
LogUtil.info('get to wifi information end ---->');
|
||||
}
|
||||
|
||||
getItemPosition(list, ssid) {
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (ssid === list[i].settingTitle) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
connectToDevice(obj) {
|
||||
LogUtil.info('[wifi_js_test] connect to wifi');
|
||||
return WifiNativeJs.connectToDevice(obj);
|
||||
}
|
||||
|
||||
disConnect() {
|
||||
LogUtil.info('netWork disconnect');
|
||||
return WifiNativeJs.disConnect();
|
||||
}
|
||||
}
|
||||
|
||||
let wifiModel = new WifiModel();
|
||||
export default wifiModel as WifiModel
|
||||
;
|
98
entry/src/main/ets/default/pages/aboutDevice.ets
Normal file
@ -0,0 +1,98 @@
|
||||
/**
|
||||
* 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 ConfigData from '../common/baseUtil/ConfigData.ets';
|
||||
import HeadComponent from './component/headComponent.ets';
|
||||
import AboutDeviceModel from '../model/aboutDeviceImpl/AboutDeviceModel.ets'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
private systemName: any = 'OpenHarmony'
|
||||
private deviceInfo: any = ''
|
||||
private aboutDeviceList: any[] = []
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.aboutTab'), isActive: true })
|
||||
List() {
|
||||
ForEach(this.aboutDeviceList, (item) => {
|
||||
ListItem() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween }) {
|
||||
Text(item.settingTitle)
|
||||
.fontSize($r('app.float.font_22'))
|
||||
.fontColor($r('app.color.color_333333_grey'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.align(Alignment.Center)
|
||||
.flexShrink(0)
|
||||
.alignSelf(ItemAlign.Center);
|
||||
Text(item.settingValue)
|
||||
.fontSize($r('app.float.font_20'))
|
||||
.fontColor($r('app.color.color_666666_grey'))
|
||||
.align(Alignment.BottomEnd)
|
||||
.textAlign(TextAlign.End);
|
||||
}
|
||||
.width(ConfigData.WH_100_100)
|
||||
}
|
||||
.height($r('app.float.wh_value_70'))
|
||||
})
|
||||
}
|
||||
.divider({ strokeWidth: 1, color: $r('app.color.color_E3E3E3_grey') })
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.WH_100_100)
|
||||
.margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') })
|
||||
.align(Alignment.TopStart);
|
||||
}
|
||||
}
|
||||
|
||||
private getDeviceInfo(): void {
|
||||
for (let key in this.aboutDeviceList) {
|
||||
let value = this.aboutDeviceList[key].settingAlias;
|
||||
if ('systemName' === value) {
|
||||
this.aboutDeviceList[key].settingTitle = $r('app.string.systemName');
|
||||
}
|
||||
if ('model' === value) {
|
||||
this.aboutDeviceList[key].settingValue = this.deviceInfo.productModel;
|
||||
this.aboutDeviceList[key].settingTitle = $r('app.string.model');
|
||||
}
|
||||
if ('companyInfo' === value) {
|
||||
this.aboutDeviceList[key].settingValue = this.deviceInfo.manufacture;
|
||||
this.aboutDeviceList[key].settingTitle = $r('app.string.companyInfo');
|
||||
}
|
||||
if ('deviceId' === value) {
|
||||
this.aboutDeviceList[key].settingValue = this.deviceInfo.serial;
|
||||
this.aboutDeviceList[key].settingTitle = $r('app.string.deviceId');
|
||||
}
|
||||
if ('softwareVersion' === value) {
|
||||
this.aboutDeviceList[key].settingValue = this.deviceInfo.displayVersion;
|
||||
this.aboutDeviceList[key].settingTitle = $r('app.string.softwareVersion');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private aboutToAppear(): void {
|
||||
console.log('settings get device info come in');
|
||||
this.deviceInfo = AboutDeviceModel.setOnAboutDeviceListener();
|
||||
this.aboutDeviceList = AboutDeviceModel.getAboutDeviceInfoListener();
|
||||
this.getDeviceInfo();
|
||||
console.log('settings get device info' + JSON.stringify(AboutDeviceModel.setOnAboutDeviceListener()));
|
||||
console.log('settings get device info end in');
|
||||
}
|
||||
|
||||
onBackPress() {
|
||||
console.log('settings get device onBackPress in');
|
||||
Navigator().active(true);
|
||||
console.log('settings get device onBackPress out');
|
||||
}
|
||||
}
|
98
entry/src/main/ets/default/pages/appManagement.ets
Normal file
@ -0,0 +1,98 @@
|
||||
/**
|
||||
* 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 ImageAnimatorComponent from './component/imageAnimatorComponent.ets';
|
||||
import ConfigData from '../common/baseUtil/ConfigData.ets';
|
||||
import AppManagementModel from '../model/appManagementImpl/AppManagementModel.ets';
|
||||
import EntryComponent from './component/entryComponent.ets';
|
||||
import HeadComponent from './component/headComponent.ets';
|
||||
import LogUtil from '../common/baseUtil/LogUtil.ets';
|
||||
import Router from '@system.router';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct AppManagement {
|
||||
@StorageLink('appManagementList') appList: any[]= [];
|
||||
@State animatorIsShow: boolean= [] === this.appList ? true : false;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.appManagement'), isActive: true });
|
||||
Stack() {
|
||||
Column() {
|
||||
ImageAnimatorComponent({ imageWidth: $r('app.float.wh_value_160'),
|
||||
imageHeight: $r('app.float.wh_value_160') });
|
||||
}
|
||||
.zIndex(1)
|
||||
.visibility(this.animatorIsShow ? Visibility.Visible : Visibility.None)
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.WH_100_100);
|
||||
|
||||
List() {
|
||||
ForEach(this.appList, (item) => {
|
||||
ListItem() {
|
||||
EntryComponent({
|
||||
settingIcon: item.settingIcon,
|
||||
settingTitle: item.settingTitle + '',
|
||||
settingSummary: item.settingSummary,
|
||||
settingValue: item.settingValue,
|
||||
settingArrow: item.settingArrow,
|
||||
settingArrowStyle: ''
|
||||
});
|
||||
}
|
||||
.onClick(() => {
|
||||
Router.push({ uri: item.settingUri, params: item });
|
||||
})
|
||||
.height($r('app.float.wh_value_70'));
|
||||
}, item => JSON.stringify(item));
|
||||
}
|
||||
.divider({
|
||||
strokeWidth: 1,
|
||||
color: $r('app.color.color_E3E3E3_grey'),
|
||||
startMargin: $r('app.float.wh_value_65'),
|
||||
endMargin: $r('app.float.wh_value_15')
|
||||
})
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.WH_100_100)
|
||||
.margin({ bottom: $r('app.float.wh_value_70') })
|
||||
.visibility(this.animatorIsShow ? Visibility.None : Visibility.Visible)
|
||||
.zIndex(0);
|
||||
}
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.WH_100_100)
|
||||
.alignContent(Alignment.Center);
|
||||
}
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.WH_100_100);
|
||||
}
|
||||
|
||||
private aboutToAppear(): void{
|
||||
LogUtil.info('settings AppManagement aboutToAppear in');
|
||||
AppManagementModel.setAppManagementListener();
|
||||
LogUtil.info('settings AppManagement aboutToAppear appList:' + JSON.stringify(this.appList));
|
||||
}
|
||||
|
||||
onBackPress() {
|
||||
LogUtil.info('settings AppManagement onBackPress in');
|
||||
AppStorage.SetOrCreate('appManagementList', []);
|
||||
Router.back();
|
||||
LogUtil.info('settings AppManagement onBackPress out');
|
||||
}
|
||||
|
||||
private aboutToDisappear(): void{
|
||||
LogUtil.info('settings AppManagement aboutToDisappear in');
|
||||
AppStorage.SetOrCreate('appManagementList', []);
|
||||
LogUtil.info('settings AppManagement aboutToDisappear out');
|
||||
}
|
||||
}
|
53
entry/src/main/ets/default/pages/applicationInfo.ets
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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 LogUtil from '../common/baseUtil/LogUtil.ets';
|
||||
import EntryComponent from './component/entryComponent.ets';
|
||||
import HeadComponent from './component/headComponent.ets';
|
||||
import ConfigData from '../common/baseUtil/ConfigData.ets';
|
||||
import Router from '@system.router'
|
||||
|
||||
let appInfo;
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct ApplicationInfo {
|
||||
build() {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.applicationInfo'), isActive: true });
|
||||
Row() {
|
||||
EntryComponent({
|
||||
settingIcon: appInfo.settingIcon,
|
||||
settingTitle: appInfo.settingTitle,
|
||||
settingSummary: appInfo.settingSummary,
|
||||
settingValue: '',
|
||||
settingArrow: '',
|
||||
settingArrowStyle: ''
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aboutToAppear(): void{
|
||||
LogUtil.info('settings ApplicationInfo aboutToAppear in');
|
||||
appInfo = Router.getParams();
|
||||
LogUtil.info('settings ApplicationInfo aboutToAppear this.item:' + JSON.stringify(appInfo));
|
||||
}
|
||||
|
||||
onBackPress() {
|
||||
LogUtil.info('settings ApplicationInfo onBackPress in');
|
||||
Router.back();
|
||||
LogUtil.info('settings ApplicationInfo onBackPress out');
|
||||
}
|
||||
}
|
82
entry/src/main/ets/default/pages/brightnessSettings.ets
Normal file
@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 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 BrightnessSettingModel from '../model/brightnessImpl/BrightnessSettingModel.ets';
|
||||
import HeadComponent from './component/headComponent.ets';
|
||||
import ConfigData from '../common/baseUtil/ConfigData.ets';
|
||||
import LogUtil from '../common/baseUtil/LogUtil.ets';
|
||||
import SubscriberUtils from '../common/baseUtil/SubscriberUtil.ets';
|
||||
import Router from '@system.router';
|
||||
|
||||
const BRIGHTNESS_MIN_VALUE = 0;
|
||||
const BRIGHTNESS_MAX_VALUE = 100;
|
||||
const BRIGHTNESS_STEP_VALUE = 10;
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct BrightnessSettings {
|
||||
@State bright: number= 50;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.brightnessTab'), isActive: true });
|
||||
Row() {
|
||||
Image($r('app.media.ic_settings_brightness_minimum'))
|
||||
.width($r('app.float.wh_value_40'))
|
||||
.height($r('app.float.wh_value_40'))
|
||||
.objectFit(ImageFit.Contain);
|
||||
Slider({
|
||||
value: this.bright,
|
||||
min: BRIGHTNESS_MIN_VALUE,
|
||||
max: BRIGHTNESS_MAX_VALUE,
|
||||
step: BRIGHTNESS_STEP_VALUE
|
||||
})
|
||||
.selectedColor(Color.Blue)
|
||||
.blockColor(Color.Blue)
|
||||
.width(ConfigData.WH_83_100)
|
||||
.onChange((number, SliderChangeMode) => {
|
||||
BrightnessSettingModel.setBrightnessListener(number);
|
||||
BrightnessSettingModel.setStorageValue(this.bright);
|
||||
SubscriberUtils.sendEvent(this.bright + '', ConfigData.SENT_EVENT_BROADCAST_BRIGHTNESS_VALUE);
|
||||
});
|
||||
Image($r('app.media.ic_settings_brightness_maximum'))
|
||||
.width($r('app.float.wh_value_40'))
|
||||
.height($r('app.float.wh_value_40'))
|
||||
.objectFit(ImageFit.Contain);
|
||||
}.padding({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') });
|
||||
}
|
||||
.align(Alignment.Center)
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.WH_100_100);
|
||||
}
|
||||
|
||||
private aboutToAppear(): void{
|
||||
LogUtil.info('settings BrightnessSettings aboutToDisappear in');
|
||||
this.bright = BrightnessSettingModel.getStorageValue();
|
||||
SubscriberUtils.registerStatusListener();
|
||||
LogUtil.info('settings BrightnessSettings aboutToDisappear out');
|
||||
}
|
||||
|
||||
onBackPress() {
|
||||
LogUtil.info('settings BrightnessSettings onBackPress in');
|
||||
Router.back();
|
||||
LogUtil.info('settings BrightnessSettings onBackPress out');
|
||||
}
|
||||
|
||||
aboutToDisappear(): void{
|
||||
LogUtil.info('settings BrightnessSettings aboutToDisappear in');
|
||||
SubscriberUtils.unSubscriberListener();
|
||||
LogUtil.info('settings BrightnessSettings aboutToDisappear out');
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
/**
|
||||
* 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 ConfigData from '../../common/baseUtil/ConfigData.ets';
|
||||
|
||||
@Component
|
||||
export default
|
||||
struct EntryComponent {
|
||||
@State isShow: Boolean = true;
|
||||
@Prop settingIcon: string;
|
||||
@State endTextIsShow: Boolean= true;
|
||||
@Prop settingTitle: string;
|
||||
@Prop settingSummary: string;
|
||||
@Prop settingValue: string;
|
||||
@Prop settingArrow: string;
|
||||
@Prop settingArrowStyle: string;
|
||||
|
||||
build() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween }) {
|
||||
Row() {
|
||||
Image(this.settingIcon)
|
||||
.width($r('app.float.wh_value_50'))
|
||||
.height($r('app.float.wh_value_50'))
|
||||
.margin({ right: $r('app.float.wh_value_10') })
|
||||
.visibility('' === this.settingIcon ? Visibility.None : Visibility.Visible)
|
||||
.objectFit(ImageFit.Contain);
|
||||
Column() {
|
||||
Text(this.settingTitle)
|
||||
.fontColor($r('app.color.color_333333_grey'))
|
||||
.fontSize($r('app.float.font_20'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.maxLines(ConfigData.MAX_LINES_3)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.margin({ top: $r('app.float.wh_value_10'), bottom: $r('app.float.wh_value_5') });
|
||||
Text(this.settingSummary)
|
||||
.fontColor($r('app.color.color_999999_grey'))
|
||||
.fontSize($r('app.float.font_18'))
|
||||
.textAlign(TextAlign.Start)
|
||||
.maxLines(ConfigData.MAX_LINES_1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.visibility('' === this.settingSummary ? Visibility.None : Visibility.Visible)
|
||||
.margin({ bottom: $r('app.float.wh_value_10') });
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start);
|
||||
}
|
||||
.flexShrink(0)
|
||||
.alignItems(VerticalAlign.Center)
|
||||
.align(Alignment.Start)
|
||||
|
||||
Row() {
|
||||
Text(this.settingValue)
|
||||
.fontSize($r('app.float.font_18'))
|
||||
.fontColor($r('app.color.color_999999_grey'))
|
||||
.height($r('app.float.wh_value_40'))
|
||||
.margin({ right: $r('app.float.wh_value_10') })
|
||||
.align(Alignment.End);
|
||||
Image(this.settingArrow)
|
||||
.width(this.settingArrowStyle === '' ? $r('app.float.wh_value_20') : $r('app.float.wh_value_40'))
|
||||
.height($r('app.float.wh_value_40'))
|
||||
.visibility('' === this.settingArrow ? Visibility.None : Visibility.Visible);
|
||||
}
|
||||
.margin({ right: $r('app.float.wh_value_15') })
|
||||
.align(Alignment.End);
|
||||
}
|
||||
.margin({ left: $r('app.float.wh_value_15') })
|
||||
.width(ConfigData.WH_100_100);
|
||||
}
|
||||
}
|
58
entry/src/main/ets/default/pages/component/headComponent.ets
Normal file
@ -0,0 +1,58 @@
|
||||
/**
|
||||
* 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 ConfigData from '../../common/baseUtil/ConfigData.ets';
|
||||
import Router from '@system.router';
|
||||
|
||||
@Component
|
||||
export default
|
||||
struct HeadComponent {
|
||||
private isActive: boolean= true;
|
||||
private icBackIsVisibility: boolean= true;
|
||||
private headName: string= '';
|
||||
@State isTouch: boolean= false;
|
||||
@StorageLink('wifiPsd') wifiPsd: string= ''
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Image($r('app.media.ic_back'))
|
||||
.width($r('app.float.wh_value_50'))
|
||||
.height($r('app.float.wh_value_50'))
|
||||
.borderRadius($r('app.float.wh_value_15'))
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_15'),
|
||||
top: $r('app.float.wh_value_5'),
|
||||
bottom: $r('app.float.wh_value_5')
|
||||
})
|
||||
.backgroundColor(this.isTouch ? $r('app.color.color_E3E3E3_grey') : $r('app.color.color_00000000_transparent'))
|
||||
.visibility(this.icBackIsVisibility ? Visibility.Visible : Visibility.None)
|
||||
.onTouch(() => {
|
||||
this.isTouch = true;
|
||||
Router.back();
|
||||
})
|
||||
Text(this.headName)
|
||||
.fontSize($r('app.float.font_24'))
|
||||
.fontWeight(FontWeight.Bold)
|
||||
.fontColor(Color.Black)
|
||||
.width(ConfigData.WH_90_100)
|
||||
.maxLines(ConfigData.MAX_LINES_1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') });
|
||||
}
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height($r('app.float.wh_value_70'))
|
||||
.alignItems(VerticalAlign.Center)
|
||||
.align(Alignment.Start);
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* 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 ConfigData from '../../common/baseUtil/ConfigData.ets';
|
||||
|
||||
@Component
|
||||
export default
|
||||
struct ImageAnimatorComponent {
|
||||
@State imageWidth: number = 0
|
||||
@State imageHeight: number = 0
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
ImageAnimator()
|
||||
.images([
|
||||
{
|
||||
src: 'res/image/xxxhdpi/ic_loading01.png',
|
||||
duration: ConfigData.DURATION_TIME,
|
||||
width: ConfigData.value_20,
|
||||
height: ConfigData.value_20,
|
||||
top: ConfigData.value_20,
|
||||
left: ConfigData.value_20
|
||||
},
|
||||
{
|
||||
src: 'res/image/xxxhdpi/ic_loading02.png',
|
||||
duration: ConfigData.DURATION_TIME,
|
||||
width: ConfigData.value_20,
|
||||
height: ConfigData.value_20,
|
||||
top: ConfigData.value_20,
|
||||
left: ConfigData.value_20
|
||||
},
|
||||
{
|
||||
src: 'res/image/xxxhdpi/ic_loading03.png',
|
||||
duration: ConfigData.DURATION_TIME,
|
||||
width: ConfigData.value_20,
|
||||
height: ConfigData.value_20,
|
||||
top: ConfigData.value_20,
|
||||
left: ConfigData.value_20
|
||||
},
|
||||
{
|
||||
src: 'res/image/xxxhdpi/ic_loading04.png',
|
||||
duration: ConfigData.DURATION_TIME,
|
||||
width: ConfigData.value_20,
|
||||
height: ConfigData.value_20,
|
||||
top: ConfigData.value_20,
|
||||
left: ConfigData.value_20
|
||||
},
|
||||
{
|
||||
src: 'res/image/xxxhdpi/ic_loading05.png',
|
||||
duration: ConfigData.DURATION_TIME,
|
||||
width: ConfigData.value_20,
|
||||
height: ConfigData.value_20,
|
||||
top: ConfigData.value_20,
|
||||
left: ConfigData.value_20
|
||||
},
|
||||
{
|
||||
src: 'res/image/hdpi/ic_loading06.png',
|
||||
duration: ConfigData.DURATION_TIME,
|
||||
width: ConfigData.value_20,
|
||||
height: ConfigData.value_20,
|
||||
top: ConfigData.value_20,
|
||||
left: ConfigData.value_20
|
||||
}])
|
||||
.width(this.imageWidth)
|
||||
.height(this.imageHeight)
|
||||
.iterations(-1)
|
||||
.fixedSize(true)
|
||||
.reverse(true)
|
||||
.fillMode(FillMode.None)
|
||||
.state(AnimationStatus.Running)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* 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 ConfigData from '../../common/baseUtil/ConfigData.ets';
|
||||
|
||||
@Component
|
||||
export default
|
||||
struct SwitchComponent {
|
||||
private isOn: boolean= false;
|
||||
private title: '';
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Text(this.title)
|
||||
.fontSize(ConfigData.font_20)
|
||||
.fontColor(Color.Black)
|
||||
.align(Alignment.Start)
|
||||
|
||||
Toggle({ type: ToggleType.Switch, isOn: false })
|
||||
.align(Alignment.End)
|
||||
.width(ConfigData.value_60)
|
||||
.height(ConfigData.value_40)
|
||||
|
||||
}
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.value_70)
|
||||
.alignItems(VerticalAlign.Center)
|
||||
.padding({ left: ConfigData.value_15, right: ConfigData.value_15 })
|
||||
}
|
||||
}
|
264
entry/src/main/ets/default/pages/dateAndTime.ets
Normal file
@ -0,0 +1,264 @@
|
||||
/**
|
||||
* 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 HeadComponent from './component/headComponent.ets';
|
||||
import EntryComponent from './component/entryComponent.ets';
|
||||
import AboutDeviceModel from '../model/dateAndTimeImpl/DateAndTimeModel.ets'
|
||||
import ConfigData from '../common/baseUtil/ConfigData.ets';
|
||||
import DateAndTime from '../common/baseUtil/DateAndTimeUtil.ets';
|
||||
import DateAndTimeModel from '../model/dateAndTimeImpl/DateAndTimeModel.ets'
|
||||
import LogUtil from '../common/baseUtil/LogUtil.ets';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct dateAndTime {
|
||||
private arr: number[] = [1, 2];
|
||||
private date: string = '';
|
||||
private time: string = '';
|
||||
private image: string = '';
|
||||
private dateMark: string = 'date';
|
||||
private timeMark: string = 'time';
|
||||
private intervalFlag;
|
||||
private setTimeoutFlag;
|
||||
@State dateAndTimeList: any[] = [];
|
||||
timeDialogController : CustomDialogController = new CustomDialogController({
|
||||
builder: TimeDialog({action: this.onAccept}),
|
||||
cancel: this.existApp,
|
||||
autoCancel: true
|
||||
});
|
||||
dateDialogController : CustomDialogController = new CustomDialogController({
|
||||
builder: DateDialog({action: this.onAccept}),
|
||||
cancel: this.existApp,
|
||||
autoCancel: true
|
||||
});
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.dateAndTimeTab'), isActive: true })
|
||||
List() {
|
||||
ForEach(this.dateAndTimeList, (item) => {
|
||||
ListItem() {
|
||||
Row() {
|
||||
Text(item.settingTitle)
|
||||
.fontSize(ConfigData.font_22)
|
||||
.fontColor(ConfigData.color_333333)
|
||||
.width(ConfigData.WH_45_100)
|
||||
.textAlign(TextAlign.Start);
|
||||
Text(item.settingValue)
|
||||
.fontSize(ConfigData.font_22)
|
||||
.fontColor(ConfigData.color_999999)
|
||||
.width(ConfigData.WH_45_100)
|
||||
.textAlign(TextAlign.End);
|
||||
Image(item.settingArrow)
|
||||
.width(ConfigData.value_40)
|
||||
.height(ConfigData.value_40);
|
||||
}
|
||||
}
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.value_80)
|
||||
.onClick(() => {
|
||||
LogUtil.info('dialog come in' + JSON.stringify(item))
|
||||
if (item.settingAlias === 'date') {
|
||||
LogUtil.info('date dialog come in')
|
||||
this.dateDialogController.open()
|
||||
}
|
||||
if (item.settingAlias === 'time') {
|
||||
LogUtil.info('time dialog come in')
|
||||
this.timeDialogController.open()
|
||||
}
|
||||
})
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.value_70);
|
||||
},item => JSON.stringify(item))
|
||||
}
|
||||
.divider({ strokeWidth: ConfigData.value_1, color: ConfigData.color_E3E3E3, startMargin: ConfigData.value_15, endMargin: ConfigData.value_15 })
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height('100%')
|
||||
.margin({ left: ConfigData.value_15, right: ConfigData.value_15 })
|
||||
.align(Alignment.TopStart);
|
||||
}
|
||||
}
|
||||
|
||||
onAccept() {
|
||||
console.log("onAccept");
|
||||
}
|
||||
existApp() {
|
||||
console.log("Cancel dialog!");
|
||||
}
|
||||
|
||||
changeValue() {
|
||||
this.dateAndTimeList = [];
|
||||
this.dateAndTimeList.push(
|
||||
{
|
||||
settingSummary: '',
|
||||
settingTitle: $r('app.string.date'),
|
||||
settingValue: this.date,
|
||||
settingAlias: this.dateMark,
|
||||
settingArrow: this.image,
|
||||
},
|
||||
{
|
||||
settingSummary: '',
|
||||
settingTitle: $r('app.string.time'),
|
||||
settingValue: this.time,
|
||||
settingAlias: this.timeMark,
|
||||
settingArrow: this.image,
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
private aboutToAppear(): void {
|
||||
this.dateAndTimeList = AboutDeviceModel.dateAndTimeListener();
|
||||
this.image = this.dateAndTimeList[0].settingArrow;
|
||||
this.time = DateAndTime.getSystemTime();
|
||||
this.date = DateAndTime.getSystemDate();
|
||||
this.changeValue();
|
||||
this.getNowTime();
|
||||
}
|
||||
|
||||
private getNowTime(): void {
|
||||
this.intervalFlag = setInterval(() => {
|
||||
console.log('get time come in');
|
||||
this.time = DateAndTime.getSystemTime();
|
||||
this.date = DateAndTime.getSystemDate();
|
||||
console.log('get time end in' + this.time);
|
||||
this.changeValue();
|
||||
},1000);
|
||||
}
|
||||
|
||||
|
||||
private aboutToDisappear(): void {
|
||||
clearInterval(this.intervalFlag);
|
||||
}
|
||||
|
||||
onBackPress() {
|
||||
Navigator().active(true);
|
||||
}
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
@Component
|
||||
struct TimeDialog {
|
||||
controller: CustomDialogController;
|
||||
action: () => void;
|
||||
private currentTime;
|
||||
private formatTime;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Column() {
|
||||
Text($r('app.string.time'))
|
||||
.height(60)
|
||||
.margin({left:30})
|
||||
.width('100%')
|
||||
.fontSize(28);
|
||||
DatePicker({selected: this.currentTime,type: DatePickerType.Time })
|
||||
.useMilitaryTime(true)
|
||||
.onChange((date: DatePickerResult)=>{
|
||||
this.currentTime = DateAndTime.fill(date.hour) + ':' + DateAndTime.fill(date.minute)
|
||||
console.info("JDY::onchange " + this.currentTime);
|
||||
})
|
||||
.width('100%')
|
||||
.height(280)
|
||||
}
|
||||
Row() {
|
||||
Button('取消')
|
||||
.margin({left:80})
|
||||
.onClick(() => {
|
||||
this.controller.close();
|
||||
this.action();
|
||||
})
|
||||
Button('确定')
|
||||
.margin({left: 160})
|
||||
.onClick(() => {
|
||||
LogUtil.info("button confirm");
|
||||
let datetime = new Date();
|
||||
let y = datetime.getFullYear();
|
||||
let m = datetime.getMonth() + 1;
|
||||
let d = datetime.getDate();
|
||||
this.formatTime = y + '-' + DateAndTime.fill(m) + '-' + DateAndTime.fill(d)
|
||||
+ 'T' + this.currentTime + ':' + '00';
|
||||
LogUtil.info("format time" + this.formatTime);
|
||||
let s = (new Date(this.formatTime)).getTime();
|
||||
LogUtil.info("change time second" + this.formatTime);
|
||||
DateAndTimeModel.setTime(s);
|
||||
this.controller.close();
|
||||
this.action();
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.height(60)
|
||||
}
|
||||
.height(400)
|
||||
.width('100%')
|
||||
}
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
@Component
|
||||
struct DateDialog {
|
||||
controller: CustomDialogController;
|
||||
action: () => void;
|
||||
private currentDate;
|
||||
private formatDate;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Column() {
|
||||
Text($r('app.string.date'))
|
||||
.height(60)
|
||||
.margin({left:15})
|
||||
.width('100%')
|
||||
.fontSize(28)
|
||||
DatePicker({ start: new Date('2008-12-21'), end: new Date('2030-12-12'),
|
||||
selected: this.currentDate,type: DatePickerType.Date})
|
||||
.onChange((date: DatePickerResult)=>{
|
||||
let datetime = new Date();
|
||||
let h = datetime.getHours();
|
||||
let min = datetime.getMinutes();
|
||||
let s = datetime.getSeconds();
|
||||
this.formatDate = date.year + '-' + DateAndTime.fill(date.month+1) + '-' + DateAndTime.fill(date.day) + 'T' +
|
||||
DateAndTime.fill(h) + ':' + DateAndTime.fill(min) + ':' + DateAndTime.fill(s);
|
||||
console.info("onchange " + this.formatDate);
|
||||
})
|
||||
.width('100%')
|
||||
.height(280);
|
||||
}
|
||||
Row() {
|
||||
Button('取消')
|
||||
.margin({left:80})
|
||||
.onClick(() => {
|
||||
this.controller.close();
|
||||
this.action();
|
||||
})
|
||||
Button('确定')
|
||||
.margin({left: 160})
|
||||
.onClick(() => {
|
||||
let s = (new Date(this.formatDate)).getTime();
|
||||
DateAndTimeModel.setTime(s);
|
||||
this.controller.close();
|
||||
this.action();
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.height(60);
|
||||
}
|
||||
.height(400)
|
||||
.width('100%');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
153
entry/src/main/ets/default/pages/settingList.ets
Normal file
@ -0,0 +1,153 @@
|
||||
/**
|
||||
* 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 LogUtil from '../common/baseUtil/LogUtil.ets';
|
||||
import ConfigData from '../common/baseUtil/ConfigData.ets';
|
||||
import EntryComponent from './component/entryComponent.ets';
|
||||
import HeadComponent from './component/headComponent.ets';
|
||||
import SettingListModel from '../model/settingListImpl/SettingListModel.ets';
|
||||
import WifiModel from '../model/wifiImpl/WifiModel.ets';
|
||||
import SubscriberUtils from '../common/baseUtil/SubscriberUtil.ets';
|
||||
import Router from '@system.router';
|
||||
|
||||
const SETTING_LIST_INDEX = 0;
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct SettingList {
|
||||
@State settingsList: any[]= [];
|
||||
@State wifiStatus: boolean= false;
|
||||
@State status: any= '';
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
HeadComponent({ icBackIsVisibility: false, headName: $r('app.string.settings'), isActive: false });
|
||||
List() {
|
||||
ForEach(this.settingsList, (item) => {
|
||||
ListItem() {
|
||||
Navigator({ target: item.settingUri }) {
|
||||
EntryComponent({
|
||||
settingIcon: item.settingIcon,
|
||||
settingTitle: item.settingTitle,
|
||||
settingSummary: item.settingSummary,
|
||||
settingValue: item.settingValue,
|
||||
settingArrow: item.settingArrow,
|
||||
settingArrowStyle: ''
|
||||
});
|
||||
}
|
||||
}
|
||||
.onTouch(() => {
|
||||
Router.push({
|
||||
uri: item.settingUri,
|
||||
});
|
||||
})
|
||||
.height($r('app.float.wh_value_70'));
|
||||
});
|
||||
}
|
||||
.divider({
|
||||
strokeWidth: 1,
|
||||
color: $r('app.color.color_E3E3E3_grey'),
|
||||
startMargin: $r('app.float.wh_value_65'),
|
||||
endMargin: $r('app.float.wh_value_15')
|
||||
})
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.WH_100_100)
|
||||
.alignSelf(ItemAlign.Start);
|
||||
}
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.WH_100_100);
|
||||
}
|
||||
|
||||
aboutToAppear(): void{
|
||||
LogUtil.info('settings SettingList aboutToAppear enter');
|
||||
this.settingsList = SettingListModel.setSettingListener();
|
||||
SubscriberUtils.registerStatusListener();
|
||||
LogUtil.info('settings SettingList aboutToAppear startPage');
|
||||
SettingListModel.startPage(this.pageValue);
|
||||
this.setTitleValue();
|
||||
LogUtil.info('settings SettingList aboutToAppear end');
|
||||
}
|
||||
|
||||
pageValue(pagePath): void{
|
||||
LogUtil.info('settings settingList pageValue pagePath:' + pagePath);
|
||||
if ('pages/wifi' === pagePath) {
|
||||
Router.push({
|
||||
uri: 'pages/wifi',
|
||||
});
|
||||
}
|
||||
LogUtil.info('settings settingList pageValue end');
|
||||
}
|
||||
|
||||
setTitleValue() {
|
||||
LogUtil.info('SettingList setTitleValue this.settingsList:' + JSON.stringify(this.settingsList));
|
||||
for (let key in this.settingsList) {
|
||||
let settingAlias = this.settingsList[key].settingAlias;
|
||||
let value;
|
||||
this.wifiStatus = WifiModel.getWifiStatus();
|
||||
if ('wifiTab' === settingAlias) {
|
||||
value = $r('app.string.wifiTab');
|
||||
if (this.wifiStatus) {
|
||||
this.settingsList[key].settingValue = $r('app.string.enabled');
|
||||
} else {
|
||||
this.settingsList[key].settingValue = $r('app.string.disabled');
|
||||
}
|
||||
}
|
||||
else if ('brightnessTab' === settingAlias) {
|
||||
value = $r('app.string.brightnessTab');
|
||||
} else if ('applyTab' === settingAlias) {
|
||||
value = $r('app.string.applyTab');
|
||||
} else if ('dateAndTimeTab' === settingAlias) {
|
||||
value = $r('app.string.dateAndTimeTab');
|
||||
} else if ('aboutTab' === settingAlias) {
|
||||
value = $r('app.string.aboutTab');
|
||||
}
|
||||
this.settingsList[key].settingTitle = value;
|
||||
}
|
||||
LogUtil.info('SettingList setTitleValue this.settingsList:' + JSON.stringify(this.settingsList));
|
||||
}
|
||||
|
||||
onPageShow(): void{
|
||||
LogUtil.info('SettingList onPageShow in:' + JSON.stringify(this.settingsList));
|
||||
this.wifiStatus = WifiModel.getWifiStatus();
|
||||
LogUtil.info('SettingList onPageShow this.wifiStatus:' + this.wifiStatus);
|
||||
for (let key in this.settingsList) {
|
||||
let settingAlias = this.settingsList[key].settingAlias;
|
||||
if ('wifiTab' === settingAlias) {
|
||||
if (this.wifiStatus) {
|
||||
this.status = $r('app.string.enabled');
|
||||
} else {
|
||||
this.status = $r('app.string.disabled');
|
||||
}
|
||||
LogUtil.info('SettingList onPageShow settingValue:' + this.settingsList[key].settingValue);
|
||||
}
|
||||
}
|
||||
this.settingsList.unshift({
|
||||
settingSummary: '',
|
||||
settingTitle: this.settingsList[SETTING_LIST_INDEX].settingTitle,
|
||||
settingValue: this.status,
|
||||
settingAlias: this.settingsList[SETTING_LIST_INDEX].settingAlias,
|
||||
settingIcon: this.settingsList[SETTING_LIST_INDEX].settingIcon,
|
||||
settingArrow: this.settingsList[SETTING_LIST_INDEX].settingArrow,
|
||||
settingUri: this.settingsList[SETTING_LIST_INDEX].settingUri,
|
||||
});
|
||||
this.settingsList.splice(1, 1);
|
||||
LogUtil.info('SettingList onPageShow out:' + +JSON.stringify(this.settingsList));
|
||||
}
|
||||
|
||||
aboutToDisappear(): void{
|
||||
LogUtil.info('settingList aboutToDisappear in');
|
||||
SubscriberUtils.unSubscriberListener();
|
||||
LogUtil.info('settingList aboutToDisappear out');
|
||||
}
|
||||
}
|
331
entry/src/main/ets/default/pages/wifi.ets
Normal file
@ -0,0 +1,331 @@
|
||||
/**
|
||||
* 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 SubscriberUtils from '../common/baseUtil/SubscriberUtil.ets';
|
||||
import WifiModel from '../model/wifiImpl/WifiModel.ets';
|
||||
import HeadComponent from './component/headComponent.ets';
|
||||
import EntryComponent from './component/entryComponent.ets';
|
||||
import ImageAnimatorComponent from './component/imageAnimatorComponent.ets';
|
||||
import ConfigData from '../common/baseUtil/ConfigData.ets';
|
||||
import LogUtil from '../common/baseUtil/LogUtil.ets';
|
||||
import Subscriber from '@ohos.commonevent';
|
||||
import router from '@system.router';
|
||||
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
@StorageLink('WifiList') wifiList: any[] = [];
|
||||
@StorageLink('wifiPsd') password: string = '';
|
||||
@State isOn: boolean = true;
|
||||
@State isShow: boolean = true;
|
||||
private connectPsd: string = '';
|
||||
private mIndex: number = -1;
|
||||
private timeoutFlag;
|
||||
private timeoutMark;
|
||||
@State connectRssi: number = -1;
|
||||
@State connectImage: string = '';
|
||||
@State connectName: string = '';
|
||||
@State connectBssid: string = '';
|
||||
@State connectSecurityType: number = -1;
|
||||
private mCommonEventSubscriber = null;
|
||||
private mCommonEventSubscribeInfo = {
|
||||
events: ["usual.event.wifi.CONN_STATE"]
|
||||
};
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.wifiTab'), isActive: true });
|
||||
Row() {
|
||||
Text($r('app.string.wifiTab'))
|
||||
.fontSize(ConfigData.font_22)
|
||||
.fontColor(Color.Black)
|
||||
.textAlign(TextAlign.Start)
|
||||
Toggle({ type: ToggleType.Switch, isOn: this.isOn })
|
||||
.width(390)
|
||||
.margin({ left: 280 })
|
||||
.height(ConfigData.value_40)
|
||||
.onChange((isOn: boolean) => {
|
||||
this.isOn = !this.isOn;
|
||||
if (this.isOn) {
|
||||
this.switchOn();
|
||||
} else {
|
||||
this.switchOff();
|
||||
}
|
||||
});
|
||||
}
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.value_70)
|
||||
.margin({ left: ConfigData.value_15, right: ConfigData.value_15 });
|
||||
|
||||
Text($r('app.string.tipsContent'))
|
||||
.visibility(this.isOn ? Visibility.None : Visibility.Visible)
|
||||
.fontSize(ConfigData.font_20)
|
||||
.align(Alignment.Start)
|
||||
.margin({ left: ConfigData.value_15, right: ConfigData.value_15 });
|
||||
Column() {
|
||||
Row() {
|
||||
Text($r('app.string.wifiList'))
|
||||
.fontSize(ConfigData.font_24)
|
||||
.align(Alignment.Start);
|
||||
Row() {
|
||||
ImageAnimatorComponent({ imageWidth: ConfigData.value_40,
|
||||
imageHeight: ConfigData.value_40 })
|
||||
}
|
||||
.width(280)
|
||||
.margin({ left: 230 })
|
||||
.visibility(this.isShow ? Visibility.Visible : Visibility.None);
|
||||
}
|
||||
.width('100%')
|
||||
.margin({ left: ConfigData.value_15, right: ConfigData.value_15 });
|
||||
|
||||
List() {
|
||||
ForEach(this.wifiList, (item) => {
|
||||
ListItem() {
|
||||
EntryComponent({
|
||||
settingIcon: '',
|
||||
settingTitle: item.settingTitle,
|
||||
settingSummary: item.settingSummary,
|
||||
settingValue: '',
|
||||
settingArrow: item.settingArrow,
|
||||
settingArrowStyle: 'wifi'
|
||||
});
|
||||
}.onClick(() => {
|
||||
this.connectName = item.settingTitle
|
||||
this.connectImage = item.settingArrow
|
||||
this.connectBssid = item.bssid
|
||||
this.connectSecurityType = item.securityType
|
||||
this.connectRssi = item.settingRssi
|
||||
this.connectWifi();
|
||||
})
|
||||
.height(ConfigData.value_60)
|
||||
}, item => JSON.stringify(item));
|
||||
}
|
||||
.divider({
|
||||
strokeWidth: ConfigData.value_1,
|
||||
color: ConfigData.color_E3E3E3,
|
||||
startMargin: ConfigData.value_15,
|
||||
endMargin: ConfigData.value_15
|
||||
})
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.WH_100_100)
|
||||
.align(Alignment.Top)
|
||||
.margin({ bottom: ConfigData.value_70, top: ConfigData.value_20 });
|
||||
}
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.WH_100_100)
|
||||
.visibility(this.isOn ? Visibility.Visible : Visibility.None);
|
||||
}
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.WH_100_100);
|
||||
}
|
||||
|
||||
private aboutToAppear(): void {
|
||||
this.wifiStatusListener();
|
||||
this.getSwitchStatus();
|
||||
this.clearScanInfo();
|
||||
LogUtil.info('init wifi get switch status');
|
||||
if (this.isOn) {
|
||||
LogUtil.info('init wifi isOn is true');
|
||||
let that = this
|
||||
this.timeoutFlag = setTimeout(() => {
|
||||
if (WifiModel.getScanWifi()) {
|
||||
LogUtil.info('init wifi start scan');
|
||||
that.timeoutMark = setTimeout(() => {
|
||||
WifiModel.getScanInfoCallBack();
|
||||
that.isShow = false;
|
||||
clearTimeout(this.timeoutFlag);
|
||||
clearTimeout(that.timeoutMark);
|
||||
LogUtil.info('init wifi wifiList' + this.wifiList);
|
||||
}, 3000);
|
||||
} else {
|
||||
LogUtil.info('init scan wifiList fail');
|
||||
}
|
||||
}, 3000);
|
||||
} else {
|
||||
LogUtil.info('init wifi isOn is false');
|
||||
}
|
||||
}
|
||||
|
||||
connectWifi() {
|
||||
LogUtil.info('[wifi_js_test] connect to wifi come in');
|
||||
let index = WifiModel.getItemPosition(this.wifiList, this.connectName);
|
||||
if (this.mIndex !== index) {
|
||||
this.connectPsd = '';
|
||||
this.mIndex = index;
|
||||
}
|
||||
let obj = {
|
||||
"ssid": this.connectName,
|
||||
"bssid": this.connectBssid,
|
||||
"preSharedKey": this.connectPsd,
|
||||
"isHiddenSsid": false,
|
||||
"securityType": this.connectSecurityType
|
||||
}
|
||||
if (!WifiModel.connectToDevice(obj)) {
|
||||
LogUtil.info("[wifi_js_test] connect to wifi failed");
|
||||
return;
|
||||
}
|
||||
|
||||
LogUtil.info('[wifi_js_test] connectSecurityType' + this.connectSecurityType);
|
||||
LogUtil.info('[wifi_js_test] connectPsd' + this.connectPsd);
|
||||
LogUtil.info('[wifi_js_test] connectName' + this.connectName);
|
||||
if (this.connectSecurityType !== 1 && '' == this.connectPsd) {
|
||||
LogUtil.info('click to detail wifiPsd');
|
||||
let name = { 'connectName': this.connectName };
|
||||
this.mIndex = index;
|
||||
router.push({
|
||||
uri: 'pages/wifiPsd',
|
||||
params: name,
|
||||
});
|
||||
LogUtil.info('jump to detail end');
|
||||
}
|
||||
if (WifiModel.connectToDevice(obj)) {
|
||||
LogUtil.info('[wifi_js_test] connect to come in');
|
||||
LogUtil.info('[wifi_js_test] connect to come in obj' + JSON.stringify(obj));
|
||||
LogUtil.info('[wifi_js_test] connect to wifiList ' + JSON.stringify(this.wifiList));
|
||||
}
|
||||
LogUtil.info('clickToSecret end:');
|
||||
}
|
||||
|
||||
getSwitchStatus() {
|
||||
if (WifiModel.getWifiStatus()) {
|
||||
this.isOn = true;
|
||||
} else {
|
||||
this.isOn = false;
|
||||
}
|
||||
}
|
||||
|
||||
private switchOn() {
|
||||
LogUtil.info('switchClick wifi start ---->');
|
||||
this.clearScanInfo();
|
||||
this.isShow = true;
|
||||
if (WifiModel.getEnableWifi()) {
|
||||
LogUtil.info('switchClick wifi enableWifi enter ---->');
|
||||
let that = this;
|
||||
this.timeoutFlag = setTimeout(() => {
|
||||
if (WifiModel.getScanWifi()) {
|
||||
that.timeoutMark = setTimeout(() => {
|
||||
WifiModel.getScanInfoCallBack();
|
||||
that.isShow = false;
|
||||
clearTimeout(this.timeoutFlag);
|
||||
clearTimeout(that.timeoutMark);
|
||||
LogUtil.info('switchClick wifi wifiList' + JSON.stringify(this.wifiList));
|
||||
}, 3000);
|
||||
} else {
|
||||
LogUtil.info('switchClick wifi fail to scan ---->');
|
||||
}
|
||||
}, 3000);
|
||||
} else {
|
||||
LogUtil.info('switchClick wifi fail to enableWifi ---->');
|
||||
}
|
||||
}
|
||||
|
||||
private switchOff() {
|
||||
LogUtil.info('switchClick wifi off start ---->');
|
||||
if (WifiModel.disableWifi()) {
|
||||
LogUtil.info('switchClick wifi enter to disableWifi ---->');
|
||||
this.clearScanInfo();
|
||||
} else {
|
||||
LogUtil.info('switchClick wifi off end ---->');
|
||||
}
|
||||
}
|
||||
|
||||
wifiStatusListener() {
|
||||
LogUtil.info('wifi status listener');
|
||||
Subscriber.createSubscriber(this.mCommonEventSubscribeInfo,
|
||||
this.CreateSubscriberCallBack.bind(this));
|
||||
}
|
||||
|
||||
CreateSubscriberCallBack(err, data) {
|
||||
LogUtil.info('subscriber subscribe');
|
||||
this.mCommonEventSubscriber = data;
|
||||
Subscriber.subscribe(this.mCommonEventSubscriber, this.SubscriberCallBack.bind(this));
|
||||
}
|
||||
|
||||
SubscriberCallBack(err, data) {
|
||||
LogUtil.info('subscriber call back');
|
||||
LogUtil.info('==========================>SubscriberCallBack event = ' + data.event);
|
||||
LogUtil.info('==========================>SubscriberCallBack data = ' + JSON.stringify(data));
|
||||
LogUtil.info('==========================>SubscriberCallBack data code = ' + data.code);
|
||||
|
||||
if (data.code === 3) {
|
||||
let wifi = { 'name': '', 'rssi': 0 };
|
||||
wifi.name = this.connectName;
|
||||
wifi.rssi = this.connectRssi;
|
||||
SubscriberUtils.sendEvent(JSON.stringify(wifi), ConfigData.SENT_EVENT_WIFI_CONNECT_NAME);
|
||||
let index = WifiModel.getItemPosition(this.wifiList, this.connectName);
|
||||
this.wifiList.splice(index, 1);
|
||||
this.wifiList.unshift({
|
||||
settingSummary: '已连接',
|
||||
settingTitle: this.connectName,
|
||||
settingValue: '',
|
||||
settingArrow: this.connectImage,
|
||||
settingArrowStyle: 'wifi',
|
||||
settingRssi: this.connectRssi,
|
||||
bssid: this.connectBssid,
|
||||
securityType: this.connectSecurityType,
|
||||
});
|
||||
this.wifiList[1].settingSummary = '';
|
||||
LogUtil.info('subscriber connected' + JSON.stringify(this.wifiList));
|
||||
}
|
||||
;
|
||||
if (data.code === 9) {
|
||||
LogUtil.info("subscriber code nine disconnected");
|
||||
this.wifiList.unshift({
|
||||
settingSummary: '',
|
||||
settingTitle: this.wifiList[0].settingTitle,
|
||||
settingValue: '',
|
||||
settingArrow: this.wifiList[0].settingArrow,
|
||||
settingArrowStyle: 'wifi',
|
||||
settingRssi: this.wifiList[0].settingRssi,
|
||||
bssid: this.wifiList[0].bssid,
|
||||
securityType: this.wifiList[0].securityType,
|
||||
});
|
||||
this.wifiList.splice(1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
unSubscriberListener() {
|
||||
Subscriber.unsubscribe(this.mCommonEventSubscriber, () => {
|
||||
LogUtil.info('wifi unsubscribe');
|
||||
});
|
||||
}
|
||||
|
||||
clearScanInfo() {
|
||||
LogUtil.info('clear scan wifiList start---->');
|
||||
this.wifiList = [];
|
||||
LogUtil.info('clear scan wifiList end---->');
|
||||
}
|
||||
|
||||
private aboutToDisappear(): void {
|
||||
this.unSubscriberListener();
|
||||
this.connectPsd = '';
|
||||
}
|
||||
|
||||
onPageShow() {
|
||||
LogUtil.info('wifi onPageShow this.password:' + this.password);
|
||||
this.connectPsd = this.password;
|
||||
if (this.connectPsd !== '') {
|
||||
this.connectWifi();
|
||||
}
|
||||
}
|
||||
|
||||
onBackPress() {
|
||||
Navigator().active(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
113
entry/src/main/ets/default/pages/wifiPsd.ets
Normal file
@ -0,0 +1,113 @@
|
||||
/**
|
||||
* 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 LogUtil from '../common/baseUtil/LogUtil.ets';
|
||||
import HeadComponent from './component/headComponent.ets';
|
||||
import ConfigData from '../common/baseUtil/ConfigData.ets';
|
||||
import Router from '@system.router'
|
||||
|
||||
const WIFI_DEFAULT_PSD = '12345678';
|
||||
|
||||
let name;
|
||||
let title;
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct WifiPsd {
|
||||
@State text: string= '';
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
HeadComponent({
|
||||
icBackIsVisibility: true,
|
||||
headName: null === title ? $r('app.string.wifiPassword') : title,
|
||||
isActive: true
|
||||
});
|
||||
|
||||
TextInput({ placeholder: '密码', text: this.text })
|
||||
.placeholderColor(Color.Blue)
|
||||
.placeholderFont({ size: ConfigData.font_20, weight: 2, fontFamily: "sans-serif", style: FontStyle.Normal })
|
||||
.inputFilter(false)
|
||||
.caretColor(Color.Blue)
|
||||
.correction(true)
|
||||
.height($r('app.float.wh_value_70'))
|
||||
.backgroundColor(Color.White)
|
||||
.width(ConfigData.WH_100_100)
|
||||
.margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') })
|
||||
.onChange((value: string) => {
|
||||
this.text = value;
|
||||
});
|
||||
Text()
|
||||
.backgroundColor(Color.Black)
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height($r('app.float.wh_value_1'))
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_15'),
|
||||
right: $r('app.float.wh_value_15')
|
||||
});
|
||||
|
||||
Row() {
|
||||
Button() {
|
||||
Text($r('app.string.cancel')).fontSize($r('app.float.font_20'))
|
||||
.fontColor(Color.Blue)
|
||||
}
|
||||
.backgroundColor($r('app.color.color_E3E3E3_grey'))
|
||||
.width($r('app.float.wh_value_160'))
|
||||
.height($r('app.float.wh_value_40'))
|
||||
.align(Alignment.Center)
|
||||
.onClick(() => {
|
||||
Router.back();
|
||||
});
|
||||
Blank().width($r('app.float.wh_value_50'));
|
||||
Button() {
|
||||
Text($r('app.string.confirm')).fontSize($r('app.float.font_20'))
|
||||
.fontColor(Color.Blue)
|
||||
}
|
||||
.backgroundColor($r('app.color.color_E3E3E3_grey'))
|
||||
.width($r('app.float.wh_value_160'))
|
||||
.height($r('app.float.wh_value_40'))
|
||||
.align(Alignment.Center)
|
||||
.onClick(() => {
|
||||
AppStorage.SetOrCreate('wifiPsd', '' === this.text ? WIFI_DEFAULT_PSD : this.text);
|
||||
Router.back();
|
||||
});
|
||||
}
|
||||
.margin({
|
||||
left: $r('app.float.wh_value_15'),
|
||||
top: $r('app.float.wh_value_20'),
|
||||
right: $r('app.float.wh_value_15')
|
||||
})
|
||||
.width(ConfigData.WH_100_100)
|
||||
.align(Alignment.Bottom);
|
||||
}
|
||||
.backgroundColor(Color.White)
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.WH_100_100);
|
||||
}
|
||||
|
||||
aboutToAppear(): void{
|
||||
LogUtil.info('settings wifiPsd aboutToAppear start');
|
||||
name = Router.getParams();
|
||||
LogUtil.info('settings wifiPsd aboutToAppear name:' + JSON.stringify(name));
|
||||
title = name.connectName;
|
||||
LogUtil.info('settings wifiPsd aboutToAppear title:' + title);
|
||||
AppStorage.SetOrCreate('wifiPsd', '');
|
||||
}
|
||||
|
||||
onBackPress() {
|
||||
LogUtil.info('settings wifiPsd onBackPress start');
|
||||
Router.back();
|
||||
LogUtil.info('settings wifiPsd onBackPress start');
|
||||
}
|
||||
}
|
BIN
entry/src/main/ets/default/res/image/float_right_arrow.png
Normal file
After Width: | Height: | Size: 144 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 681 B After Width: | Height: | Size: 681 B |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 993 B After Width: | Height: | Size: 993 B |
Before Width: | Height: | Size: 894 B After Width: | Height: | Size: 894 B |
Before Width: | Height: | Size: 912 B After Width: | Height: | Size: 912 B |
Before Width: | Height: | Size: 904 B After Width: | Height: | Size: 904 B |
Before Width: | Height: | Size: 887 B After Width: | Height: | Size: 887 B |
Before Width: | Height: | Size: 942 B After Width: | Height: | Size: 942 B |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@ -1,150 +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.
|
||||
*/
|
||||
const twelve = 12;
|
||||
/**
|
||||
* date package tool class
|
||||
*/
|
||||
export default class DateAndTimeUtil{
|
||||
constructor() {
|
||||
console.log('DateAndTimeUtil constructor start globalThis.$globalT:'+globalThis.$globalT);
|
||||
if (globalThis.$globalT) {
|
||||
this.monday = globalThis.$globalT('strings.monday');
|
||||
this.tuesday = globalThis.$globalT('strings.tuesday');
|
||||
this.wednesday = globalThis.$globalT('strings.wednesday');
|
||||
this.thursday = globalThis.$globalT('strings.thursday');
|
||||
this.friday = globalThis.$globalT('strings.friday');
|
||||
this.saturday = globalThis.$globalT('strings.saturday');
|
||||
this.sunday = globalThis.$globalT('strings.sunday');
|
||||
this.morning = globalThis.$globalT('strings.morning');
|
||||
this.afternoon = globalThis.$globalT('strings.afternoon');
|
||||
this.year = globalThis.$globalT('strings.year');
|
||||
this.month = globalThis.$globalT('strings.month');
|
||||
this.day = globalThis.$globalT('strings.day');
|
||||
console.log('DateAndTimeUtil constructor this.monday:' + this.monday);
|
||||
}
|
||||
console.log('DateAndTimeUtil constructor end');
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Get the current time
|
||||
*/
|
||||
now() {
|
||||
const datetime = new Date();
|
||||
const hours = datetime.getHours();
|
||||
const minutes = datetime.getMinutes();
|
||||
return this.concatTime(hours, minutes);
|
||||
};
|
||||
/**
|
||||
* format
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
fill(value) {
|
||||
return (value > 9 ? "" : "0") + value;
|
||||
};
|
||||
/**
|
||||
* concat date
|
||||
* @param year m d
|
||||
* @return
|
||||
*/
|
||||
concatDate(year, month, date) {
|
||||
return year + this.year + month + this.month + date + this.day;
|
||||
};
|
||||
|
||||
concatTime(hours, minutes) {
|
||||
return `${this.fill(hours)}:${this.fill(minutes)}`;
|
||||
};
|
||||
/**
|
||||
* Turn to 24-hour clock
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
transform24(str) {
|
||||
const timeFlag = str.substr(0, 2);
|
||||
if (timeFlag == this.morning) {
|
||||
const h = str.substr(2).split(":")[0];
|
||||
if (h == twelve) {
|
||||
const time = "0" + ":" + str.substr(2).split(":")[1];
|
||||
return time;
|
||||
} else {
|
||||
return h + ":" + str.substr(2).split(":")[1];
|
||||
}
|
||||
} else {
|
||||
const h = str.substr(2).split(":")[0];
|
||||
const h1 = parseInt(h) + twelve;
|
||||
if (h != twelve) {
|
||||
const time = h1 + ":" + str.substr(2).split(":")[1];
|
||||
return time;
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Turn to 12-hour clock
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
transform12(str) {
|
||||
const hours = str.substring(0, str.indexOf(":"));
|
||||
const minutes = str.split(":")[1];
|
||||
if (hours < twelve) {
|
||||
return this.morning.concat(`${hours}:${minutes}`);
|
||||
}
|
||||
if (hours == twelve) {
|
||||
return this.afternoon.concat(`${hours}:${minutes}`);
|
||||
} else {
|
||||
const reduceHours = parseInt(hours) - twelve;
|
||||
return this.afternoon.concat(`${reduceHours}:${minutes}`);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Calculate the week base on date
|
||||
* @param y
|
||||
* @param m
|
||||
* @param d
|
||||
* @return
|
||||
*/
|
||||
convert(y, m, d) {
|
||||
if (!globalThis.$globalT) {
|
||||
return;
|
||||
}
|
||||
const week = (d + 2 * m + parseInt(3 * (m + 1) / 5) + y + parseInt(y / 4)
|
||||
- parseInt(y / 100) + parseInt(y / 400)) % 7;
|
||||
switch (week) {
|
||||
case 0:
|
||||
return this.monday;
|
||||
break;
|
||||
case 1:
|
||||
return this.tuesday;
|
||||
break;
|
||||
case 2:
|
||||
return this.wednesday;
|
||||
break;
|
||||
case 3:
|
||||
return this.thursday;
|
||||
break;
|
||||
case 4:
|
||||
return this.friday;
|
||||
break;
|
||||
case 5:
|
||||
return this.saturday;
|
||||
break;
|
||||
case 6:
|
||||
return this.sunday;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
{
|
||||
"strings": {
|
||||
"enable": "ENABLE",
|
||||
"enabled": "Enabled",
|
||||
"disable": "DISABLE",
|
||||
"disabled": "Disabled",
|
||||
"restore": "RESTORE",
|
||||
"on": "On",
|
||||
"off": "Off",
|
||||
"ok": "OK",
|
||||
"setting": "Settings",
|
||||
"search": "Search",
|
||||
"buttonValue1Right": ">",
|
||||
"buttonValue1Left": "<",
|
||||
"buttonValue2Left": "⇦",
|
||||
"more-wifi-settings": "More WLAN Settings",
|
||||
"wifi-list": "WLAN-List which can be used",
|
||||
"autoset": "Autoset",
|
||||
"autoset-require": "date、time and time zone",
|
||||
"date": "Date",
|
||||
"time": "Time",
|
||||
"time-zone": "Time Zone",
|
||||
"cancel": "Cancel",
|
||||
"confirm": "Confirm",
|
||||
"brightnessMode": "brightnessMode",
|
||||
"settings": "Settings",
|
||||
"wifiTab": "WLANTab",
|
||||
"brightnessTab": "brightnessTab",
|
||||
"applyTab": "applyTab",
|
||||
"dateAndTimeTab": "dateAndTimeTab",
|
||||
"aboutTab": "aboutTab",
|
||||
"applicationInfo": "App info",
|
||||
"appManagement": "Apps",
|
||||
"24Hour": "24 Hour",
|
||||
"deviceId": "DeviceId",
|
||||
"companyInfo": "CompanyInfo",
|
||||
"hardwareVersion": "HardwareVersion",
|
||||
"systemName": "SystemName",
|
||||
"softwareVersion": "SoftwareVersion",
|
||||
"adjust": "Automatic adjustment",
|
||||
"model": "Model",
|
||||
"brand": "Brand",
|
||||
"manufacturer": "Manufacturer",
|
||||
"wifi": "WLAN",
|
||||
"version": "version",
|
||||
"monday": "Monday",
|
||||
"tuesday": "Tuesday",
|
||||
"wednesday": "Wednesday",
|
||||
"thursday": "Thursday",
|
||||
"friday": "Friday",
|
||||
"saturday": "Saturday",
|
||||
"sunday": "Sunday",
|
||||
"year": "year",
|
||||
"month": "month",
|
||||
"day": "date",
|
||||
"morning": "morning",
|
||||
"afternoon": "afternoon",
|
||||
"connected": "connected",
|
||||
"loading": "Loading..."
|
||||
},
|
||||
"png": {
|
||||
"info": {
|
||||
"back": "/res/image/ic_back.svg"
|
||||
},
|
||||
"new": {
|
||||
}
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
{
|
||||
"strings": {
|
||||
"enable": "开启",
|
||||
"enabled": "已开启",
|
||||
"disable": "关闭",
|
||||
"disabled": "已关闭",
|
||||
"restore": "还原",
|
||||
"on": "开启",
|
||||
"off": "关闭",
|
||||
"ok": "确定",
|
||||
"setting": "设置",
|
||||
"search": "搜索",
|
||||
"buttonValue1Right": ">",
|
||||
"buttonValue1Left": "<",
|
||||
"buttonValue2Left": "⇦",
|
||||
"more-wifi-settings": "更多WLAN设置",
|
||||
"tips-content": "为提高位置信息的精确度,应用和服务仍然会扫描WLAN网络.您可以在提高精确度中更改此设置",
|
||||
"wifi-list": "可用WLAN列表",
|
||||
"wifi-advanced-options": "显示高级选项",
|
||||
"wifi-pass-details": "请至少输入8个字符",
|
||||
"wifi-link": "连接",
|
||||
"autoset": "自动设置",
|
||||
"autoset-require": "日期、时间和时区",
|
||||
"date": "日期",
|
||||
"time": "时间",
|
||||
"time-zone": "时区",
|
||||
"location-service": "打开定位服务,自动定位所在时区",
|
||||
"cancel": "取消",
|
||||
"confirm": "确定",
|
||||
"brightnessMode": "自动调节",
|
||||
"settings": "设置",
|
||||
"wifiTab": "WLAN",
|
||||
"brightnessTab": "亮度",
|
||||
"applyTab": "应用",
|
||||
"dateAndTimeTab": "日期和时间",
|
||||
"aboutTab": "关于手机",
|
||||
"wifi-pass": "密码",
|
||||
"displayMode": "显示模式",
|
||||
"applicationInfo": "应用信息",
|
||||
"appManagement": "应用管理",
|
||||
"24Hour": "24小时制",
|
||||
"deviceId": "设备ID",
|
||||
"companyInfo": "厂家信息",
|
||||
"hardwareVersion": "硬件版本",
|
||||
"systemName": "系统名称",
|
||||
"softwareVersion": "软件版本",
|
||||
"model": "型号",
|
||||
"brand": "品牌",
|
||||
"manufacturer": "生产商",
|
||||
"wifi": "WLAN",
|
||||
"version": "版本 ",
|
||||
"monday": "星期一",
|
||||
"tuesday": "星期二",
|
||||
"wednesday": "星期三",
|
||||
"thursday": "星期四",
|
||||
"friday": "星期五",
|
||||
"saturday": "星期六",
|
||||
"sunday": "星期日",
|
||||
"year": "年",
|
||||
"month": "月",
|
||||
"day": "日",
|
||||
"morning": "上午",
|
||||
"afternoon": "下午",
|
||||
"connected": "已连接",
|
||||
"loading": "正在加载..."
|
||||
},
|
||||
"png": {
|
||||
"info": {
|
||||
"back": "/res/image/ic_back.svg"
|
||||
},
|
||||
"new": {
|
||||
}
|
||||
}
|
||||
}
|
@ -1,36 +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 BaseModel from '../BaseModel.js';
|
||||
import LogUtil from '../../common/baseUtil/LogUtil.js';
|
||||
import DeviceInfo from '@ohos.deviceInfo';
|
||||
|
||||
let mLogUtil = null;
|
||||
|
||||
/**
|
||||
* about device service class
|
||||
*/
|
||||
export default class AboutDeviceModel extends BaseModel {
|
||||
constructor() {
|
||||
super();
|
||||
mLogUtil = new LogUtil();
|
||||
}
|
||||
|
||||
setOnAboutDeviceListener(callback) {
|
||||
mLogUtil.info('settings aboutDevice get deviceInfo start');
|
||||
this.text = DeviceInfo.productModel;
|
||||
mLogUtil.info('settings aboutDevice get deviceInfo:' + JSON.stringify(DeviceInfo));
|
||||
callback(DeviceInfo);
|
||||
}
|
||||
}
|
@ -1,103 +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 BaseModel from '../BaseModel.js';
|
||||
import LogUtil from '../../common/baseUtil/LogUtil.js';
|
||||
import Bundle from '@ohos.bundle';
|
||||
import Resmgr from '@ohos.resourceManager';
|
||||
|
||||
let mLogUtil = null;
|
||||
|
||||
const INDEX = 0;
|
||||
const IS_INCLUDE_ABILITY_INFO = 0;
|
||||
/**
|
||||
* app management service class
|
||||
*
|
||||
*/
|
||||
let mBundleInfoList = [];
|
||||
|
||||
export default class AppManagementModel extends BaseModel {
|
||||
constructor() {
|
||||
super();
|
||||
mLogUtil = new LogUtil();
|
||||
}
|
||||
|
||||
setAppManagementListener(callback) {
|
||||
mLogUtil.info('setting appManagement init AppManagementModel setAppManagementListener start');
|
||||
Bundle.getBundleInfos(IS_INCLUDE_ABILITY_INFO).then((data) => {
|
||||
mLogUtil.info('AppManagementModel setAppManagementListener getBundleInfos() start ');
|
||||
mLogUtil.info('AppManagementModel data.length: ' + data.length + ' data: ' + JSON.stringify(data));
|
||||
this.getIconItem(INDEX, data.length, data, callback);
|
||||
});
|
||||
mLogUtil.info('setting appManagement init AppManagementModel setAppManagementListener end');
|
||||
}
|
||||
|
||||
getIconItem(index, count, data, callback) {
|
||||
mLogUtil.info('AppManagementModel getIconItem start data.length' + data.length);
|
||||
let imageValue = '';
|
||||
let label = '';
|
||||
let that = this;
|
||||
Resmgr.getResourceManager(data[index].name, (error, item) => {
|
||||
mLogUtil.info('AppManagementModel getIconItem getResourceManager start item' + JSON.stringify(item));
|
||||
let appInfo = data[index].appInfo;
|
||||
if (appInfo.labelId > 0) {
|
||||
item.getString(appInfo.labelId, (error, value) => {
|
||||
mLogUtil.info('AppManagementModel getIconItem getResourceManager value.length:' + value.length);
|
||||
if (value != null) {
|
||||
mLogUtil.info('AppManagementModel getIconItem getResourceManager getString() value:' + value);
|
||||
label = value;
|
||||
mLogUtil.info('AppManagementModel getIconItem getResourceManager getString() label:' + label);
|
||||
} else {
|
||||
mLogUtil.info('AppManagementModel getIconItem getResourceManager getString() error:' + error);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mLogUtil.info('AppManagementModel getIconItem getResourceManager getString() label:' + appInfo.label);
|
||||
label = appInfo.label;
|
||||
}
|
||||
mLogUtil.info('AppManagementModel getIconItem getResourceManager getString() finish label:' + label);
|
||||
item.getMediaBase64(appInfo.iconId, (error, value) => {
|
||||
mLogUtil.info('AppManagementModel getIconItem getResourceManager getMediaBase64() :' + value.length);
|
||||
if (value.length > 0) {
|
||||
imageValue = value;
|
||||
}
|
||||
mLogUtil.info('AppManagementModel getIconItem getResourceManager getMediaBase64() end');
|
||||
mBundleInfoList.push({
|
||||
settingIcon: imageValue,
|
||||
settingTitle: label,
|
||||
settingValue: '',
|
||||
settingArrow: '/res/image/ic_settings_arrow.svg',
|
||||
settingDefaultValue: false,
|
||||
settingSummary: data[index].versionName,
|
||||
dividerIsShow: true,
|
||||
settingType: 1,
|
||||
settingBundleName: data[index].name,
|
||||
item: data[index],
|
||||
settingUri: 'pages/applicationInfo/applicationInfo'
|
||||
})
|
||||
if (count - 1 > index) {
|
||||
setTimeout(function () {
|
||||
mLogUtil.info('AppManagementModel getMediaBase64() if index:' + index + ' | count:' + count);
|
||||
index = index + 1;
|
||||
that.getIconItem(index, count, data, callback);
|
||||
}, 100);
|
||||
} else {
|
||||
mLogUtil.info('AppManagementModel getMediaBase64() else index:' + index + ' | count:' + count);
|
||||
callback(mBundleInfoList);
|
||||
}
|
||||
});
|
||||
});
|
||||
mLogUtil.info('setting appManagement init AppManagementModel getIconItem end');
|
||||
}
|
||||
}
|
@ -1,48 +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 BaseModel from '../BaseModel.js';
|
||||
import LogUtil from '../../common/baseUtil/LogUtil.js';
|
||||
import Fileio from '@ohos.fileio';
|
||||
|
||||
let mLogUtil = null;
|
||||
|
||||
export default class BaseParseConfModel extends BaseModel {
|
||||
constructor() {
|
||||
super();
|
||||
mLogUtil = new LogUtil();
|
||||
}
|
||||
|
||||
getJsonData(fileName) {
|
||||
mLogUtil.info('settings dateAndTime BaseParseConfModel getJsonData start');
|
||||
try {
|
||||
mLogUtil.info('settings dateAndTime BaseParseConfModel getJsonDat start try');
|
||||
let ss = Fileio.createStreamSync(fileName, 'r');
|
||||
let buf = new ArrayBuffer(4096);
|
||||
let len = ss.readSync(buf);
|
||||
mLogUtil.info('settings dateAndTime BaseParseConfModel getJsonData len' + JSON.stringify(len) + len);
|
||||
let arr = new Uint8Array(buf);
|
||||
let charAt = ' '.charCodeAt(0);
|
||||
for (let i = len; i < 4096; i++) {
|
||||
arr[i] = charAt;
|
||||
}
|
||||
let content = String.fromCharCode.apply(null, arr);
|
||||
mLogUtil.info('settings dateAndTime BaseParseConfModel getJsonData content:' + content);
|
||||
ss.closeSync();
|
||||
return JSON.parse(content);
|
||||
} catch (jsonError) {
|
||||
mLogUtil.info('settings dateAndTime BaseParseConfModel getJsonData catch jsonError:' + jsonError);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,52 +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 BaseModel from '../BaseModel.js';
|
||||
import Brightness from '@ohos.brightness';
|
||||
import Storage from '@ohos.data.storage';
|
||||
import LogUtil from '../../common/baseUtil/LogUtil.js';
|
||||
|
||||
const BRIGHTNESS_SAVE_VALUE = 'BrightnessSaveValue';
|
||||
const PREFERENCES_PATH = '/data/accounts/account_0/appdata/com.ohos.settings/sharedPreference/SettingPreferences';
|
||||
|
||||
let mBrightnessPreferences = Storage.getStorageSync(PREFERENCES_PATH);
|
||||
let mLogUtil = null;
|
||||
|
||||
/**
|
||||
* brightness service class
|
||||
*/
|
||||
export default class BrightnessSettingModel extends BaseModel {
|
||||
constructor() {
|
||||
super();
|
||||
mLogUtil = new LogUtil();
|
||||
}
|
||||
|
||||
setBrightnessListener(brightnessValue) {
|
||||
mLogUtil.log('setting setBrightnessListener BrightnessSettingModel start');
|
||||
Brightness.setValue(brightnessValue);
|
||||
mLogUtil.log('setting setBrightnessListener BrightnessSettingModel end');
|
||||
}
|
||||
|
||||
setStorageValue(brightnessValue) {
|
||||
mLogUtil.log('setting setBrightnessListener setStorageListener start brightnessValue:' + brightnessValue);
|
||||
mBrightnessPreferences.putSync(BRIGHTNESS_SAVE_VALUE, brightnessValue);
|
||||
mBrightnessPreferences.flushSync();
|
||||
mLogUtil.log('setting setBrightnessListener setStorageListener end');
|
||||
}
|
||||
|
||||
getStorageValue() {
|
||||
mLogUtil.log('setting setBrightnessListener getStorageValue start');
|
||||
return mBrightnessPreferences.getSync(BRIGHTNESS_SAVE_VALUE, 0);
|
||||
}
|
||||
}
|
@ -1,38 +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 BaseModel from '../BaseModel.js';
|
||||
import LogUtil from '../../common/baseUtil/LogUtil.js';
|
||||
import SystemTime from '@ohos.systemTime';
|
||||
|
||||
let mLogUtil = null;
|
||||
|
||||
export default class DateAndTimeModel extends BaseModel {
|
||||
constructor() {
|
||||
super();
|
||||
mLogUtil = new LogUtil();
|
||||
}
|
||||
|
||||
setTime(time) {
|
||||
mLogUtil.info('setting dateAndTime setTime start');
|
||||
SystemTime.setTime(time).then(data => {
|
||||
mLogUtil.info('setting dateAndTime AceApplication promise1::then ' + data);
|
||||
})
|
||||
.catch(error => {
|
||||
mLogUtil.info('setting dateAndTime AceApplication promise1::catch ' + error);
|
||||
}
|
||||
);
|
||||
mLogUtil.info('setting dateAndTime setTime end');
|
||||
}
|
||||
}
|
@ -1,39 +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 BaseModel from '../BaseModel.js';
|
||||
import BaseParseConfModel from '../baseParseConfImpl/BaseParseConfModel.js';
|
||||
import LogUtil from '../../common/baseUtil/LogUtil.js';
|
||||
|
||||
/**
|
||||
* app setting homepage service class
|
||||
*/
|
||||
let mBaseParseConfModel = null;
|
||||
let mLogUtil = null;
|
||||
let mSettingList = null;
|
||||
|
||||
export default class SettingListModel extends BaseModel {
|
||||
constructor() {
|
||||
super();
|
||||
mBaseParseConfModel = new BaseParseConfModel();
|
||||
mLogUtil = new LogUtil();
|
||||
}
|
||||
|
||||
setSettingListener(callback) {
|
||||
mSettingList = mBaseParseConfModel.getJsonData('/data/accounts/account_0/applications/com.ohos.settings'
|
||||
+ '/com.ohos.settings/assets/entry/resources/rawfile/settinglist.json');
|
||||
mLogUtil.info('settings settingList get by json:' + JSON.stringify(mSettingList));
|
||||
callback(mSettingList);
|
||||
}
|
||||
}
|
@ -1,164 +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 BaseModel from '../BaseModel.js';
|
||||
import LogUtil from '../../common/baseUtil/LogUtil.js';
|
||||
import WifiNativeJs from '@ohos.wifi_native_js';
|
||||
|
||||
let mLogUtil = null;
|
||||
let mWifiList = [];
|
||||
let remdupWifiList = [];
|
||||
|
||||
export default class WifiModel extends BaseModel {
|
||||
constructor() {
|
||||
super();
|
||||
mLogUtil = new LogUtil();
|
||||
}
|
||||
|
||||
getWifiStatus() {
|
||||
mLogUtil.info('WifiNativeJs isWifiActive');
|
||||
return WifiNativeJs.isWifiActive();
|
||||
}
|
||||
|
||||
getEnableWifi() {
|
||||
mLogUtil.info('WifiNativeJs enableWifi');
|
||||
return WifiNativeJs.enableWifi();
|
||||
}
|
||||
disableWifi() {
|
||||
mLogUtil.info('WifiNativeJs enableWifi');
|
||||
return WifiNativeJs.disableWifi();
|
||||
}
|
||||
getScanWifi() {
|
||||
mLogUtil.info('WifiNativeJs scan');
|
||||
return WifiNativeJs.scan();
|
||||
}
|
||||
getScanInfoCallBack() {
|
||||
mLogUtil.info('get to wifi info start');
|
||||
mWifiList = [];
|
||||
remdupWifiList = [];
|
||||
WifiNativeJs.getScanInfos(result => {
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
mLogUtil.info('[wifi_js_test] wifi received scan info call back results:' + JSON.stringify(result));
|
||||
let clen = Object.keys(result).length;
|
||||
let image;
|
||||
mLogUtil.info('[wifi_js_test] wifi received scan info call back length:' + clen);
|
||||
for (let j = 0; j < clen; j++) {
|
||||
mLogUtil.info('result[0].ssid: ' + result[j].ssid);
|
||||
mLogUtil.info('securityType: ' + result[j].securityType);
|
||||
mLogUtil.info('rssi: ' + result[j].rssi);
|
||||
mLogUtil.info('bssid: ' + result[j].bssid);
|
||||
mLogUtil.info('band: ' + result[j].band);
|
||||
mLogUtil.info('frequency: ' + result[j].frequency);
|
||||
mLogUtil.info('timestamp: ' + result[j].timestamp);
|
||||
mLogUtil.info('SignalLevel: ' + WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band));
|
||||
if (result[j].securityType === 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 4) {
|
||||
image = '/res/image/ic_wifi_signal_4_dark.svg';
|
||||
mLogUtil.info('securityType 1 and signal level 4');
|
||||
}
|
||||
if (result[j].securityType === 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 3) {
|
||||
image = '/res/image/ic_wifi_signal_3_dark.svg';
|
||||
mLogUtil.info('securityType 1 and signal level 3');
|
||||
}
|
||||
if (result[j].securityType === 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 2) {
|
||||
image = '/res/image/ic_wifi_signal_2_dark.svg';
|
||||
mLogUtil.info('securityType 1 and signal level 2');
|
||||
}
|
||||
if (result[j].securityType === 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 1) {
|
||||
image = '/res/image/ic_wifi_signal_1_dark.svg';
|
||||
mLogUtil.info('securityType 1 and signal level 1');
|
||||
}
|
||||
if (result[j].securityType === 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 0) {
|
||||
image = '/res/image/ic_wifi_signal_1_dark.svg';
|
||||
mLogUtil.info('securityType 1 and signal level 1');
|
||||
}
|
||||
if (result[j].securityType !== 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 4) {
|
||||
image = '/res/image/ic_wifi_lock_signal_4_dark.svg';
|
||||
mLogUtil.info('securityType lock and level 4');
|
||||
}
|
||||
if (result[j].securityType !== 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 3) {
|
||||
image = '/res/image/ic_wifi_lock_signal_3_dark.svg';
|
||||
mLogUtil.info('securityType lock and level 3');
|
||||
}
|
||||
if (result[j].securityType !== 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 2) {
|
||||
image = '/res/image/ic_wifi_lock_signal_2_dark.svg';
|
||||
mLogUtil.info('securityType lock and level 2');
|
||||
}
|
||||
if (result[j].securityType !== 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 1) {
|
||||
image = '/res/image/ic_wifi_lock_signal_1_dark.svg';
|
||||
mLogUtil.info('securityType lock and level 1');
|
||||
}
|
||||
if (result[j].securityType !== 1 && WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band) === 0) {
|
||||
image = '/res/image/ic_wifi_lock_signal_1_dark.svg';
|
||||
mLogUtil.info('securityType lock and level 1');
|
||||
}
|
||||
|
||||
if (result[j].ssid === '' || result[j] === null) {
|
||||
mLogUtil.info('result ssid empty');
|
||||
} else {
|
||||
mWifiList.push({
|
||||
settingIcon: '',
|
||||
settingSummary: '',
|
||||
settingTitle: result[j].ssid,
|
||||
settingValue: '',
|
||||
settingArrow: image,
|
||||
settingDefaultValue: '',
|
||||
settingArrowStyle: 'commonHeadImage',
|
||||
dividerIsShow: true,
|
||||
settingType: 1,
|
||||
bssid: result[j].bssid,
|
||||
securityType: result[j].securityType,
|
||||
signalLevel: WifiNativeJs.getSignalLevel(result[j].rssi, result[j].band),
|
||||
});
|
||||
}
|
||||
}
|
||||
mLogUtil.info('original mWifiList :' + JSON.stringify(mWifiList));
|
||||
for (let i = 0; i < mWifiList.length; i++) {
|
||||
let position = this.getItemPosition(remdupWifiList, mWifiList[i].settingTitle);
|
||||
if (position !== -1) {
|
||||
// the same SSID,Take the strong signal
|
||||
if (remdupWifiList[position].signalLevel < mWifiList[i].signalLevel) {
|
||||
remdupWifiList.splice(position, 1);
|
||||
remdupWifiList.splice(position, 0, mWifiList[i]);
|
||||
}
|
||||
} else {
|
||||
remdupWifiList.push(mWifiList[i]);
|
||||
}
|
||||
}
|
||||
mLogUtil.info('remove duplicate ssid remdupWifiList: ' + JSON.stringify(remdupWifiList));
|
||||
});
|
||||
mLogUtil.info('get to wifi information end ---->');
|
||||
return remdupWifiList;
|
||||
}
|
||||
|
||||
getItemPosition(list, ssid) {
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (ssid === list[i].settingTitle) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
connectToDevice(obj) {
|
||||
mLogUtil.info('[wifi_js_test] connect to wifi');
|
||||
return WifiNativeJs.connectToDevice(obj);
|
||||
}
|
||||
|
||||
disConnect() {
|
||||
mLogUtil.info('netWork disconnect');
|
||||
return WifiNativeJs.disConnect();
|
||||
}
|
||||
}
|
@ -1,20 +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.
|
||||
*/
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
@ -1,32 +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.
|
||||
*/-->
|
||||
<element name='head-component' src='../component/headComponent/headComponent.hml' ></element>
|
||||
<element name = "entry-component" src = "../component/entryComponent/entryComponent.hml"></element>
|
||||
<div class="container">
|
||||
<head-component title-name="{{$t('strings.aboutTab')}}" back-icon="{{$t('png.info.back')}}" @back-type="aboutDeviceBack"></head-component>
|
||||
<!--List item-->
|
||||
<list >
|
||||
<list-item id="item" class="list-item-background-color" for="{{aboutDeviceList}}" clickeffect="false" >
|
||||
<entry-component item="{{$item.settingType==1?$item:''}}" icon="{{$item.settingIcon}}"
|
||||
icon-show="{{$item.settingIcon==''?false:true}}" summary="{{$item.settingSummary}}"
|
||||
title="{{$item.settingTitle}}" is-summary-show="{{$item.settingSummary==''?false:true}}"
|
||||
model-state-describe="{{$item.settingValue}}" divider-show="{{$item.settingShowDivider}}"
|
||||
state-description-show="{{$item.settingValue==''?false:true}}"
|
||||
entrance-to-item-icon="{{$item.settingArrow}}" entrance-to-item-show="{{$item.settingType==1}}"
|
||||
switches-is-show="{{$item.settingType==2}}" switch-default-value="{{$item.settingDefaultValue}}"
|
||||
switch-on-change-value="{{switchChangeValue}}"></entry-component>
|
||||
</list-item>
|
||||
</list>
|
||||
</div>
|
@ -1,85 +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 Router from '@system.router';
|
||||
import AboutDeviceModel from '../../model/aboutDeviceImpl/AboutDeviceModel.js';
|
||||
import BaseParseConfModel from '../../model/baseParseConfImpl/BaseParseConfModel.js';
|
||||
import LogUtil from '../../common/baseUtil/LogUtil.js';
|
||||
|
||||
let mAboutDeviceModel = null;
|
||||
let mBaseParseConfModel = null;
|
||||
let mLogUtil = null;
|
||||
export default {
|
||||
data: {
|
||||
aboutDeviceList: [],
|
||||
text: ''
|
||||
},
|
||||
onInit() {
|
||||
mLogUtil = new LogUtil();
|
||||
mLogUtil.info('aboutDevice onInit start:');
|
||||
mAboutDeviceModel = new AboutDeviceModel();
|
||||
mBaseParseConfModel = new BaseParseConfModel();
|
||||
this.aboutDeviceList = mBaseParseConfModel.getJsonData('/data/accounts/account_0/applications/'
|
||||
+ 'com.ohos.settings/com.ohos.settings/assets/entry/resources/rawfile/aboutDevice.json');
|
||||
mLogUtil.info('settings aboutDevice get aboutDeviceList by json:' + JSON.stringify(this.aboutDeviceList));
|
||||
for (let key in this.aboutDeviceList) {
|
||||
let settingAlias = this.aboutDeviceList[key].settingAlias;
|
||||
this.aboutDeviceList[key].settingTitle = this.$t('strings.'.concat(settingAlias));
|
||||
}
|
||||
mAboutDeviceModel.setOnAboutDeviceListener(this.aboutDevice);
|
||||
mLogUtil.info('aboutDevice onInit end:');
|
||||
},
|
||||
aboutDevice(data) {
|
||||
mLogUtil.info('aboutDeviceList start:' + JSON.stringify(data));
|
||||
for (let key in this.aboutDeviceList) {
|
||||
let value = this.aboutDeviceList[key];
|
||||
if ('model' === value.settingAlias) {
|
||||
value.settingValue = data.productModel;
|
||||
}
|
||||
if ('companyInfo' === value.settingAlias) {
|
||||
value.settingValue = data.manufacture;
|
||||
}
|
||||
if ('deviceId' === value.settingAlias) {
|
||||
value.settingValue = data.serial;
|
||||
}
|
||||
if ('softwareVersion' === value.settingAlias) {
|
||||
value.settingValue = data.displayVersion;
|
||||
}
|
||||
}
|
||||
},
|
||||
aboutDeviceBack() {
|
||||
mLogUtil.info('settings aboutDevice back start');
|
||||
Router.back();
|
||||
mLogUtil.info('settings aboutDevice back end');
|
||||
},
|
||||
onBackPress() {
|
||||
mLogUtil.info('settings aboutDevice onBackPress');
|
||||
Router.back();
|
||||
},
|
||||
onCreate() {
|
||||
mLogUtil.info('setting aboutDevice onCreate');
|
||||
},
|
||||
onReady() {
|
||||
mLogUtil.info('setting aboutDevice onReady');
|
||||
},
|
||||
onShow() {
|
||||
mLogUtil.info('setting aboutDevice onShow');
|
||||
},
|
||||
onHide() {
|
||||
mLogUtil.info('setting aboutDevice onHide');
|
||||
},
|
||||
onDestroy() {
|
||||
mLogUtil.info('setting aboutDevice onDestroy');
|
||||
}
|
||||
};
|
@ -1,51 +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.
|
||||
*/
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.search {
|
||||
width: 100%;
|
||||
height: 70px;
|
||||
align-items: center;
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
.animator-div {
|
||||
width: 100%;
|
||||
height: 98%;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.animator {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
margin-top: 10px;
|
||||
font-size: 18px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,34 +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.
|
||||
*/-->
|
||||
<element name = 'head-component' src = '../component/headComponent/headComponent.hml'></element>
|
||||
<element name='settings-list-component' src = '../component/settingsListComponent/settingsListComponent.hml'></element>
|
||||
<div class = "container">
|
||||
<head-component title-name = "{{ $t('strings.appManagement') }}" back-icon = "{{ $t('png.info.back') }}"
|
||||
@back-type = "appInfoBack"></head-component>
|
||||
|
||||
<!-- search bar-->
|
||||
<div class = "search" show = "false">
|
||||
<search id = "search" style = "height : 60px;" hint = "{{ $t('strings.search') }}" focusable = "false"
|
||||
value = "{{ inputSearchValue }}" ontouchstart = "onClick"></search>
|
||||
</div>
|
||||
<div show = "{{ animatorOn }}" class = "animator-div">
|
||||
<image-animator class = "animator" ref = "animator" images = "{{ frames }}" duration="1s"/>
|
||||
<text class = "loading-text">{{ $t('strings.loading') }}</text>
|
||||
</div>
|
||||
|
||||
<!--List item-->
|
||||
<settings-list-component list-show = "{{ contentViewIsShow }}" parent-data = "{{ appList }}"></settings-list-component>
|
||||
</div>
|
||||
|
@ -1,145 +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 AppManagementModel from '../../model/appManagementImpl/AppManagementModel.js';
|
||||
import LogUtil from '../../common/baseUtil/LogUtil.js';
|
||||
import Router from '@system.router';
|
||||
|
||||
const DATA_PAGE_SOURCE_APP_PAGE = 'appPage';
|
||||
|
||||
let mAppManagementModel = null;
|
||||
let mLogUtil = null;
|
||||
globalThis.$globalR = null;
|
||||
|
||||
export default {
|
||||
data: {
|
||||
animatorOn: true,
|
||||
contentViewIsShow: false,
|
||||
appList: [],
|
||||
frames: null,
|
||||
},
|
||||
onInit() {
|
||||
mLogUtil = new LogUtil();
|
||||
mLogUtil.info('setting appManagement init start');
|
||||
this.initFrames();
|
||||
mAppManagementModel = new AppManagementModel();
|
||||
globalThis.$globalR = this.$r.bind(this);
|
||||
mAppManagementModel.setAppManagementListener(this.appListData);
|
||||
mLogUtil.info('setting appManagement init end');
|
||||
},
|
||||
appListData(appListData) {
|
||||
if (null === appListData) {
|
||||
mLogUtil.info('setting appManagement appListData is null');
|
||||
return;
|
||||
}
|
||||
this.handleStop();
|
||||
this.animatorOn = false;
|
||||
this.contentViewIsShow = true;
|
||||
mLogUtil.info('setting appManagement appListData start:' + JSON.stringify(appListData.length));
|
||||
for (let i = 0; i < appListData.length; i++) {
|
||||
let settingSummary = appListData[i].settingSummary;
|
||||
appListData[i].settingSummary = this.$t('strings.version').concat(settingSummary);
|
||||
}
|
||||
this.appList = appListData;
|
||||
mLogUtil.info('setting appManagement appListData end');
|
||||
},
|
||||
|
||||
/**
|
||||
* Jump to search page
|
||||
*/
|
||||
onClick() {
|
||||
mLogUtil.info('setting appManagement onClick start pages/searchInfo/searchInfo ');
|
||||
Router.push({
|
||||
uri: 'pages/searchInfo/searchInfo',
|
||||
params: {
|
||||
appData: this.appList,
|
||||
type: DATA_PAGE_SOURCE_APP_PAGE
|
||||
}
|
||||
});
|
||||
mLogUtil.info('setting appManagement onClick end');
|
||||
},
|
||||
appInfoBack() {
|
||||
mLogUtil.info('setting appManagement appInfoBack start');
|
||||
Router.back();
|
||||
mLogUtil.info('setting appManagement appInfoBack end');
|
||||
},
|
||||
onBackPress() {
|
||||
mLogUtil.info('setting appManagement onBackPress start');
|
||||
Router.back();
|
||||
mLogUtil.info('setting appManagement onBackPress end');
|
||||
},
|
||||
onCreate() {
|
||||
mLogUtil.info('setting appManagement onCreate');
|
||||
},
|
||||
onReady() {
|
||||
mLogUtil.info('setting appManagement onReady');
|
||||
},
|
||||
onShow() {
|
||||
mLogUtil.info('setting appManagement onShow');
|
||||
},
|
||||
onHide() {
|
||||
mLogUtil.info('setting appManagement onHide');
|
||||
},
|
||||
onDestroy() {
|
||||
mLogUtil.info('setting appManagement onDestroy');
|
||||
},
|
||||
initFrames() {
|
||||
mLogUtil.info('setting appManagement initFrames Start');
|
||||
this.frames = [
|
||||
{
|
||||
src: this.$r('image.icLoading01'),
|
||||
},
|
||||
{
|
||||
src: this.$r('image.icLoading02'),
|
||||
},
|
||||
{
|
||||
src: this.$r('image.icLoading03'),
|
||||
},
|
||||
{
|
||||
src: this.$r('image.icLoading04'),
|
||||
},
|
||||
{
|
||||
src: this.$r('image.icLoading05'),
|
||||
},
|
||||
{
|
||||
src: this.$r('image.icLoading06'),
|
||||
}
|
||||
];
|
||||
},
|
||||
handleStart() {
|
||||
mLogUtil.info('setting appManagement handleStart');
|
||||
this.$refs.animator.start();
|
||||
},
|
||||
handlePause() {
|
||||
mLogUtil.info('setting appManagement handlePause');
|
||||
this.$refs.animator.pause();
|
||||
},
|
||||
handleResume() {
|
||||
mLogUtil.info('setting appManagement handleResume');
|
||||
this.$refs.animator.resume();
|
||||
},
|
||||
handleStop() {
|
||||
mLogUtil.info('setting appManagement handleStop');
|
||||
this.$refs.animator.stop();
|
||||
},
|
||||
handleClose() {
|
||||
mLogUtil.info('setting appManagement handleClose');
|
||||
this.$refs.animator.close();
|
||||
},
|
||||
handleFinish() {
|
||||
mLogUtil.info('setting appManagement handleFinish');
|
||||
this.$refs.animator.finish();
|
||||
},
|
||||
};
|
||||
|
@ -1,62 +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.
|
||||
*/
|
||||
.container {
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.preference {
|
||||
width: 100%;
|
||||
height: 70px;
|
||||
flex-direction: row;
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
align-items: center;
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
.preference-title {
|
||||
width: 80%;
|
||||
flex-direction: column;
|
||||
weights: 1;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.title-style {
|
||||
font-family: Courier;
|
||||
font-size: 22px;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.text-style-empty {
|
||||
weights: 1;
|
||||
}
|
||||
|
||||
.text-style-version {
|
||||
font-size: 18px;
|
||||
margin-top: 1px;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.head-image-pin {
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
justify-content: center;
|
||||
margin-right: 20px;
|
||||
align-items: center;
|
||||
}
|