diff --git a/README.md b/README.md index 7aa6d502..c7013e42 100755 --- a/README.md +++ b/README.md @@ -1,400 +1,46 @@ -# Settings 源码开发说明 +# Settings -## 1. 项目介绍 -Settings是基于 OpenHarmony 平台开发的基于OHOS提供基础设置功能。主要包括页面展示跳转逻辑、基础设置项(wifi设置、亮度设置、应用管理、日期和时间、关于手机)以及本设备其他应用设置项的收集、其他设备设置项收集的实现。项目采用MVVM架构模式,让各个层级之间不直接访问减少相互依赖。 +- [Introduction](#section11660541593) + - [Architecture](#section48896451454) -Settings采用纯 ETS 语言开发,开发过程中不涉及任何 Java 部分的代码。 +- [Directory Structure](#section161941989596) +- [Repositories Involved](#section1371113476307) -## 2. 工程结构 -### 目录结构 +## Introduction +The Settings is a system application prebuilt in OpenHarmony. It provides a human-machine interactions entry for users to set system configs like settings system time, lightness of screen and etc. - /applications/standard/settings - ├── entry # 主entry模块目录 - │ └── src - │ ├── main - │ ├── ets # ets模块目录 - │ ├── default - │ ├── common # 公共工具存放目录 - │ ├── model # 数据管理和决策逻辑存放目录 - │ ├── pages # 组件页面存放目录 - │ ├── res # 部分图片资源 - │ ├── resources # 其它共用资源 - │ ├── app.ets # 全局ets逻辑和应用生命周期管理文件 - │ ├── resources # 资源配置文件存放目录 - │ ├── base # 默认语言场景,图片资源,字体大小,颜色资源内容存放目录 - │ ├── en_AS.element # 英文语言场景资源内容存放目录 - │ ├── rawfile # 本地配置文件存放目录 - │ ├── zh_CN.element # 中文语言场景资源内容存放目录 - │ └── config.json # 全局配置文件 - ├── signature # 证书文件目录 - ├── LICENSE # 许可文件 +### Architecture -### 整体架构 +![](figures/en-us_image_0000001153225717.png) -![](./figures/en-us_image_0000001153225717.png) - -设置 整体是 openHarmony 系统中预置的系统应用,为用户提供设置系统属性的交互界面。例如设置wifi状态,系统时间,屏幕亮度等系统属性。 - -Settings整体采用MVVM架构设计。关于MVVM架构中各层级的描述如下: - -View:视图层,负责界面数据的展示,与用户进行交互。 - -ViewModel:视图模型,用UI Component将公用逻辑抽离,建立一套公用的ui引擎处理视图层(View)发送的业务逻辑处理请求,并连通 Model 层获取数据。 - -Model:模型层,负责处理数据,包括wifi的model,应用管理model,日期时间model等。 - -## 3. 代码使用 -### 代码下载 -基于L2的 Settings代码可以采用从码云上克隆的方式下载。 -[下载地址](https://gitee.com/openharmony/applications_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公钥 - > - > ![](./figures/git_ssh_pub_key.png) - > - > 2. 复制公钥内容 - > 输入`cat .ssh/id_rsa.pub`,复制打印内容。 - > ![](./figures/3-1.png) - > 3. 在设置->安全设置->SSH公钥 中设置 SSH公钥 - > 将第二步中复制的内容按照画面提示粘贴到码云上相应的内容区域,并点击确定。 - > ![](./figures/3-2.png) - > 注意,在码云中,添加SSH公钥之后,需要进行账号的密码验证,验证通过才能成功添加。 -##### 2.下载代码 -1. 浏览器打开[下载地址](https://gitee.com/openharmony/applications_settings)。 -2. 点击“克隆/下载”按钮,选择 SSH,点击“复制”按钮。 - ![](./figures/source_download_1.png) -3. 在本地新建 Settings 目录,在 Settings 目录中执行如下命令 - ``` - git clone 步骤2中复制的地址 - ``` - -## 4. 基础开发说明 - - -### 多语言支持 - -#### 定义资源文件 - -- 在 `src/main/ets/resources/`目录下,根据不同的语言定义不同的文件夹下面的 `string.json` 资源文件。 - ![](./figures/ds_i18n_files.png) - -#### 引用资源 - -- 在对应ets文件中,可直接通过`$r()`引用。 - - ```` - this.title = $r('app.string.world'); - this.icon = $r('app.media.icon'); - ```` - -## 5. 典型接口的使用 - -1. 读取json配置文件 +## Directory Structure ``` - import fileio from '@ohos.fileio'; - - readLocalFile(fileName): any[]{ - try { - let stream = FileIo.createStreamSync(fileName, 'r'); - LogUtil.info('settings readLocalFile stream:' + stream); - let buf = new ArrayBuffer(4096); - let len = stream.readSync(buf); - LogUtil.info('settings readLocalFile 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); - stream.closeSync(); - LogUtil.info('settings readLocalFile content:' + JSON.stringify(content)); - return JSON.parse(content); - } catch (jsonError) { - LogUtil.info('settings readLocalFile jsonError:' + jsonError); - } - } +/applications/standard/settings +├── entry # main entry module +│ └── src +│ ├── main +│ ├── ets # ets module +│ ├── default +│ ├── common # common code and utils +│ ├── model # data management and logic control +│ ├── pages # code of view components +│ ├── res # some image resources +│ ├── resources # other resources +│ ├── app.ets # main process +│ ├── resources # resources configs +│ ├── base # default language, image resources, font size and colors +│ ├── en_AS.element # English resources +│ ├── rawfile # local configs +│ ├── zh_CN.element # Chinese resources +│ └── config.json # global configs +├── signature # Certificate files +├── LICENSE # Copyright license file ``` +## Repositories Involved -2. 查询所有应用信息 - -``` -import Bundle from '@ohos.bundle'; - -Bundle.getAllBundleInfo(0) - .then((data) => { - console.info('Settings getAllBundleInfo: '+JSON.stringify(data)); - } - ); -``` - -3. 获取wifi扫描信息 - -``` -import wifi_native_js from '@ohos.wifi_native_js'; - -getScanInfos() { - wifi_native_js.getScanInfos(result => { - this.animator_on = false; - var clen = Object.keys(result).length; - console.log("[wifi_js_test] wifi received scan info call back: " + clen); - for (var j = 0; j < clen; j++) { - console.log("result[0].ssid :" + result[j].ssid); - console.info("securityType: " + result[j].securityType); - console.info("rssi: " + result[j].rssi); - console.info("band: " + result[j].band); - } - }); -} -``` - -4. Preferences 存取数据 - -``` -import storage from '@ohos.data.storage'; -// 数据存放路径 -const PREFERENCES_PATH = '/data/accounts/account_0/appdata/com.ohos.settings/sharedPreference/SettingsPreference'; -let mPreferences = Storage.getStorageSync(PREFERENCES_PATH); - -save(key,value) { - mPreferences.putSync(key, value); - mPreferences.flushSync(); -} - -get(key,defaultValue): any { - return mPreferences.getSync(key, defaultValue); -} -``` - - -## 6. 签名打包 - -### 签名 - -#### 签名文件的获取 - -1. 拷贝 OpenHarmony 标准版的 prebuilts\signcenter 目录到操作目录 -2. 拷贝Settings工程的 signature\settings.p7b 到该目录下 - -#### 签名文件的配置 - -打开项目工程,选择 File → Project Structure - -![](./figures/signature_1.png) - -选择 Modules → Signing Configs,将对应的签名文件配置如下,完成后点击Apply,再点击OK。 - -![](./figures/signature_2.png) - -配置完成后,对应的build.gradle文件中会出现如下内容 - -![](./figures/signature_3.png) - -### 打包 - -DevEco Studio 支持 debug 与 release 两种打包类型。可以在 OhosBuild Variants 窗口中进行切换。 - - ![](./figures/ds_ohosbuild_variants.png) - -#### debug打包 - -1. 代码准备完成后,在 OhosBuild Variants 窗口的 Selected Variant 中选择 debug。 - - ![](./figures/ds_ohosbuild_variants_debug.png) - -2. 选择Build → Build Haps(s)/APP(s) → Build Hap(s) - - ![](./figures/ds_build_haps.png) - -3. 编译完成后,hap包会生成在工程目录下的 `\build\outputs\hap\debug\phone\`路径下(如果没有配置签名,则只会生成未签名的hap包) - - ![](./figures/ds_ohosbuild_output_dir.png) - -#### release打包 - -1. 代码准备完成后,在 OhosBuild Variants 窗口的 Selected Variant 中选择 release - - ![](./figures/ds_ohosbuild_variants_release.png) - -2. 选择Build → Build Haps(s)/APP(s) → Build Hap(s) - - ![](./figures/ds_build_haps.png) - -3. 编译完成后,hap包会生成在工程目录下的 `\build\outputs\hap\release\phone\`路径下(如果没有配置签名,则只会生成未签名的hap包) - - ![](./figures/ds_ohosbuild_output_dir.png) - - - -## 7. 安装、运行、调试 - -## 应用安装 - -配置 hdc: -进入SDK目录中的toolchains文件夹下,获取文件路径: - -![](./figures/sdk_catalogue.png) - -> 注意,此处的hdc.exe如果版本较老,可能不能正常使用,需要获取新的hdc.exe文件 - -并将此路径配置到环境变量中: - -![](./figures/sdk_environment_variable.png) - -重启电脑使环境变量生效 - -连接开发板,打开cmd命令窗口,执行hdc list targets,弹出窗口如下: - -![](./figures/cmd1.png) - -等待一段时间后,窗口出现如下打印,可回到输入 hdc list targets 的命令窗口继续操作: - -![](./figures/cmd2.png) - -再次输入hdc list targets,出现如下结果,说明hdc连接成功 - -![](./figures/cmd3.png) - -获取 root 权限与读写权限: - -``` -hdc smode(当前版本可能仍不稳定,执行此命令可能导致后续的hdc target mount 失败,可不执行) -hdc target mount(效果与remount类似) -``` - -将签名好的 hap 包放入设备的 `/system/app` 目录下,并修改hap包的权限 - -``` -hdc file send 本地hap包路径 /system/app/hap包名称 -例如:hdc file send Settings.hap /system/app/Settings.hap -``` - -> 注意,如果设备不存在 `/system/app` 目录,则需要手动创建该目录并修改权限。 -> -> ``` -> hdc shell -> cd system -> mkdir app -> chmod 777 app -> ``` -> -> `/system/app` 目录放置系统应用,例如:Launcher,SystemUI,Settings 等。 -> -> 但hap包需要在该目录下手动设置权限 -> -> ``` -> chmod 666 hap包名 -> ``` -> -> 此目录应用不用手动安装,系统自动拉起。 - -## 应用运行 - -Settings 属于系统应用,在将签名的 hap 包放入 `/system/app` 目录后,重启系统,应用会自动拉起。 - -``` -hdc shell reboot (不可以直接执行hdc reboot,命令是无效的) -``` - -> 注意,如果设备之前安装过系统应用,则需要执行如下两条命令清除设备中存储的应用信息,才能够在设备重启的时候将最新装入设备的新 hap 包正常拉起。 -> -> ``` -> hdc shell rm -rf /data/misc_de/0/mdds/0/default/bundle_manager_service -> hdc shell rm -rf /data/accounts -> ``` - -## 应用调试 - -#### log打印 -- 在程序中添加 log -``` -console.info("Setting log info"); -``` -#### log获取及过滤 -- log获取 - -将log输出至文件 -``` -hdc shell hilog > 输出文件名称 -``` - -例: -在真实环境查看log,将全log输出到当前目录的hilog.log文件中 - -``` -hdc shell hilog > hilog.log -``` - -- log过滤 - -在命令行窗口中过滤log -``` -hilog | grep 过滤信息 -``` - -例:过滤包含信息 Label 的 hilog -``` -hilog | grep Label -``` - -## 8. 贡献代码 - -### Fork 代码仓库 - -1. 在码云上打开 Settings 代码仓库([仓库地址](https://gitee.com/openharmony/applications_settings))。 -2. 点击仓库右上角的 Forked 按钮 - ![](./figures/commit_source_fork_button.png) -3. 在弹出的画面中,选择将仓库 fork 到哪里,点击确认。 - ![](./figures/commit_source_fork_confirm.png) -4. Fork 成功之后,会在自己的账号下看见 fork 的代码仓库。 - ![](./figures/commit_source_forked_repo1.png) - -### 提交代码 - -1. 访问我们自己在码云账号上 fork 的代码仓库,点击“克隆/下载”按钮,选择 SSH,点击“复制”按钮。 - ![](./figures/commit_source_clone_page.png) - -2. 在本地新建 Settings 目录,在 Settings 目录中执行如下命令 - - ``` - git clone 步骤1中复制的地址 - ``` - -3. 修改代码。 - - > 将代码引入工程,以及编译工程等相关内容请参见 **3. 代码使用** 部分的相关内容。 - -4. 提交代码到 fork 仓库。 - - > 修改后的代码,首先执行 `git add` 命令,然后执行 `git commit -s` 命令与 `git push` 命令,将代码 push 到我们自己的 fork 仓中。 - > 关于代码提交的这部分内容涉及 git 的使用,可以参照 [git官网](https://git-scm.com/) 的内容,在此不再赘述。 - -### 发起 Pull Request (PR) - -在将代码提交到 fork 仓之后,我们可以通过发起 Pull Request(PR)的方式来为 OpenHarmony 的相关项目贡献代码。 - -1. 打开 fork 仓库。选择 `Pull Requests` → `新建 Pull Request` - - ![](./figures/commit_source_new_pull_request.png) - -2. 在 `新建 Pull Request` 画面填入标题与说明,点击 `创建` 按钮。 - - ![](./figures/commit_source_new_pull_request_confirm.png) - -3. 创建 Pull Request 完成。 PR 创建完成后,会有专门的代码审查人员对代码进行评审,评审通过之后会合入相应的代码库。 - - ![](./figures/commit_source_new_pr_done.png) - -系统应用 +System apps **applications\_settings** + diff --git a/build.gradle b/build.gradle index 5ab79aa5..61859631 100755 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ ohos { buildscript { repositories { maven { - url 'http://repo.ark.tools.huawei.com/artifactory/maven-public/' + url 'https://repo.ark.tools.huawei.com/artifactory/maven-public/' } maven { url 'https://mirrors.huaweicloud.com/repository/maven/' @@ -30,7 +30,7 @@ buildscript { allprojects { repositories { maven { - url 'http://repo.ark.tools.huawei.com/artifactory/maven-public/' + url 'https://repo.ark.tools.huawei.com/artifactory/maven-public/' } maven { url 'https://mirrors.huaweicloud.com/repository/maven/' diff --git a/common/component/build.gradle b/common/component/build.gradle new file mode 100644 index 00000000..525fd4ec --- /dev/null +++ b/common/component/build.gradle @@ -0,0 +1,20 @@ +apply plugin: 'com.huawei.ohos.library' +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 7 + defaultConfig { + compatibleSdkVersion 6 + } + + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } +} + +dependencies { +} diff --git a/entry/proguard-rules.pro b/common/component/proguard-rules.pro similarity index 100% rename from entry/proguard-rules.pro rename to common/component/proguard-rules.pro diff --git a/common/component/src/main/config.json b/common/component/src/main/config.json new file mode 100644 index 00000000..1e672ec6 --- /dev/null +++ b/common/component/src/main/config.json @@ -0,0 +1,22 @@ +{ + "app": { + "bundleName": "com.ohos.settings", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.settings.common", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "component", + "moduleType": "har" + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/default/common/baseUtil/ConfigData.ets b/common/component/src/main/ets/default/ComponentConfig.ets similarity index 52% rename from entry/src/main/ets/default/common/baseUtil/ConfigData.ets rename to common/component/src/main/ets/default/ComponentConfig.ets index 0a2946e7..fa2dab61 100644 --- a/entry/src/main/ets/default/common/baseUtil/ConfigData.ets +++ b/common/component/src/main/ets/default/ComponentConfig.ets @@ -13,24 +13,10 @@ * 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'; - VOLUME_SAVE_VALUE_KEY = 'VolumeSaveValue'; - SENT_EVENT_BROADCAST_BRIGHTNESS_VALUE = 'BRIGHTNESS_VALUE'; - SENT_EVENT_BROADCAST_VOLUME_VALUE = 'VOLUME_VALUE'; - SENT_EVENT_WIFI_CONNECT_NAME = 'WIFI_CONNECT_NAME'; - BRIGHTNESS_DEFAULT_VALUE = 50; - DEFAULT_BUNDLE_NAME = 'com.ohos.settings'; - DATE_AND_TIME_YEAR='DATE_AND_TIME_YEAR' - DATE_AND_TIME_MONTH='DATE_AND_TIME_MONTH' - DATE_AND_TIME_DAY='DATE_AND_TIME_DAY' - TAG='Settings ' - +export class ComponentConfig { WH_100_100 = '100%'; WH_30_100 = '30%'; + WH_33_100 = '33%'; WH_35_100 = '35%'; WH_40_100 = '40%'; WH_45_100 = '45%'; @@ -48,6 +34,5 @@ export class ConfigData { DURATION_TIME = 200; } -let configData = new ConfigData(); -export default configData as ConfigData -; \ No newline at end of file +let componentConfig = new ComponentConfig(); +export default componentConfig as ComponentConfig; \ No newline at end of file diff --git a/common/component/src/main/ets/default/controller/BaseSettingsController.ets b/common/component/src/main/ets/default/controller/BaseSettingsController.ets new file mode 100644 index 00000000..d50702b5 --- /dev/null +++ b/common/component/src/main/ets/default/controller/BaseSettingsController.ets @@ -0,0 +1,86 @@ +/** + * 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 ISettingsController from './ISettingsController' + +export default abstract class BaseSettingsController implements ISettingsController { + protected getComponent: () => any; + + /** + * Bind component. + */ + bindComponent(component: any): ISettingsController{ + this.getComponent = () => component; + + // set default property values by component + for (var key in this) { + if (key in component) { + this[key] = component[key]; + } + } + + return this; + } + + /** + * Bind component's properties. + */ + bindProperties(componentProperties: string[], controllerProperties?: string[]): ISettingsController { + for (let i = 0; i < componentProperties.length; i++) { + this.defineBoundProperty(componentProperties[i], controllerProperties ? controllerProperties[i] : componentProperties[i]); + } + + return this; + } + + /** + * Initialize data. + */ + initData(): ISettingsController { + return this; + }; + + /** + * Subscribe listeners. + */ + subscribe(): ISettingsController { + return this; + }; + + /** + * Unsubscribe listeners. + */ + unsubscribe(): ISettingsController { + return this; + }; + + /** + * Define bound properties. + */ + private defineBoundProperty(componentProperty: string, controllerProperty: string): void { + let __v = this[controllerProperty]; + + Object.defineProperty(this, controllerProperty, { + get: function () { + return __v; + }, + set: function (value) { + __v = value; + this.getComponent()[componentProperty] = value; + } + }); + } + +} \ No newline at end of file diff --git a/common/component/src/main/ets/default/controller/ISettingsController.ts b/common/component/src/main/ets/default/controller/ISettingsController.ts new file mode 100644 index 00000000..7a59b623 --- /dev/null +++ b/common/component/src/main/ets/default/controller/ISettingsController.ts @@ -0,0 +1,43 @@ +/** + * 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 interface ISettingsController { + + /** + * Bind component. + */ + bindComponent(component: any): ISettingsController; + + /** + * Bind component's properties. + */ + bindProperties(componentProperties: string[], controllerProperties?: string[]): ISettingsController + + /** + * Initialize data. + */ + initData(): ISettingsController; + + /** + * Subscribe listeners. + */ + subscribe(): ISettingsController; + + /** + * Unsubscribe listeners. + */ + unsubscribe(): ISettingsController; + +} \ No newline at end of file diff --git a/common/component/src/main/ets/default/controller/SwitchController.ets b/common/component/src/main/ets/default/controller/SwitchController.ets new file mode 100644 index 00000000..db302562 --- /dev/null +++ b/common/component/src/main/ets/default/controller/SwitchController.ets @@ -0,0 +1,35 @@ +/** + * 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 BaseSettingsController from './BaseSettingsController.ets' + +/** + * Switch controller + */ +export default abstract class SwitchController extends BaseSettingsController { + protected isOn: boolean = false; + + /** + * Set toggle value + */ + toggleValue(isOn: boolean) { + this.isOn = new Boolean(isOn).valueOf() + this.afterCurrentValueChanged(); + } + + /** + * After current value changed + */ + abstract afterCurrentValueChanged(); +} \ No newline at end of file diff --git a/entry/src/main/ets/default/pages/component/entryComponent.ets b/common/component/src/main/ets/default/entryComponent.ets similarity index 88% rename from entry/src/main/ets/default/pages/component/entryComponent.ets rename to common/component/src/main/ets/default/entryComponent.ets index bda03321..f4ab4c70 100644 --- a/entry/src/main/ets/default/pages/component/entryComponent.ets +++ b/common/component/src/main/ets/default/entryComponent.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import ConfigData from '../../common/baseUtil/ConfigData.ets'; +import ComponentConfig from './ComponentConfig.ets'; /** * item custom component @@ -29,6 +29,9 @@ struct EntryComponent { @Prop settingArrow: string; @Prop settingArrowStyle: string; @Prop settingUri: string; + @State titleFontColor: Color | number | string | Resource = $r('app.color.color_333333_grey'); + private enabled : boolean = true; + private onArrowClick?: () => void; build() { Flex({ justifyContent: FlexAlign.SpaceBetween }) { @@ -41,10 +44,11 @@ struct EntryComponent { .objectFit(ImageFit.Contain); Column() { Text(this.settingTitle) + .fontColor(this.titleFontColor) .fontColor($r('app.color.color_333333_grey')) .fontSize($r('app.float.font_20')) .textAlign(TextAlign.Start) - .maxLines(ConfigData.MAX_LINES_3) + .maxLines(ComponentConfig.MAX_LINES_3) .textOverflow({ overflow: TextOverflow.Ellipsis }) .margin({ top: $r('app.float.wh_value_10'), bottom: $r('app.float.wh_value_5') }); Row() { @@ -52,7 +56,7 @@ struct EntryComponent { .fontColor($r('app.color.color_999999_grey')) .fontSize($r('app.float.font_18')) .textAlign(TextAlign.Start) - .maxLines(ConfigData.MAX_LINES_1) + .maxLines(ComponentConfig.MAX_LINES_1) .textOverflow({ overflow: TextOverflow.Ellipsis }) .visibility('pages/applicationInfo' === this.settingUri ? Visibility.Visible : Visibility.None) .margin({ bottom: $r('app.float.wh_value_10') }); @@ -60,7 +64,7 @@ struct EntryComponent { .fontColor($r('app.color.color_999999_grey')) .fontSize($r('app.float.font_18')) .textAlign(TextAlign.Start) - .maxLines(ConfigData.MAX_LINES_1) + .maxLines(ComponentConfig.MAX_LINES_1) .textOverflow({ overflow: TextOverflow.Ellipsis }) .visibility('' === this.settingSummary || undefined === this.settingSummary ? Visibility.None : Visibility.Visible) .margin({ bottom: $r('app.float.wh_value_10') }); @@ -88,6 +92,6 @@ struct EntryComponent { .align(Alignment.End); } .margin({ left: $r('app.float.wh_value_15') }) - .width(ConfigData.WH_100_100); + .enabled(this.enabled); } } \ No newline at end of file diff --git a/entry/src/main/ets/default/pages/component/headComponent.ets b/common/component/src/main/ets/default/headComponent.ets similarity index 73% rename from entry/src/main/ets/default/pages/component/headComponent.ets rename to common/component/src/main/ets/default/headComponent.ets index 9766554b..a2d2d8db 100644 --- a/entry/src/main/ets/default/pages/component/headComponent.ets +++ b/common/component/src/main/ets/default/headComponent.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import ConfigData from '../../common/baseUtil/ConfigData.ets'; +import ComponentConfig from './ComponentConfig.ets'; import Router from '@system.router'; /** @@ -33,27 +33,32 @@ struct HeadComponent { .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') - }) + 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; - AppStorage.SetOrCreate('wifiPsd', ''); - Router.back(); - }) + .onClick(()=>{ + Router.back(); + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isTouch = true; + } + if (event.type === TouchType.Up) { + this.isTouch = false; + } + }); 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) + .width(ComponentConfig.WH_90_100) + .maxLines(ComponentConfig.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) + .width(ComponentConfig.WH_100_100) .height($r('app.float.wh_value_70')) .alignItems(VerticalAlign.Center) .align(Alignment.Start); diff --git a/entry/src/main/ets/default/pages/component/imageAnimatorComponent.ets b/common/component/src/main/ets/default/imageAnimatorComponent.ets similarity index 84% rename from entry/src/main/ets/default/pages/component/imageAnimatorComponent.ets rename to common/component/src/main/ets/default/imageAnimatorComponent.ets index af0da4ad..10e754e1 100644 --- a/entry/src/main/ets/default/pages/component/imageAnimatorComponent.ets +++ b/common/component/src/main/ets/default/imageAnimatorComponent.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import ConfigData from '../../common/baseUtil/ConfigData.ets'; +import ComponentConfig from './ComponentConfig.ets'; /** * ImageAnimator component @@ -22,7 +22,7 @@ export default struct ImageAnimatorComponent { @State imageWidth: number = 0 @State imageHeight: number = 0 - @State whtl: number = ConfigData.value_20; + @State whtl: number = ComponentConfig.value_20; build() { Column() { @@ -30,7 +30,7 @@ struct ImageAnimatorComponent { .images([ { src: 'res/image/xxxhdpi/ic_loading01.png', - duration: ConfigData.DURATION_TIME, + duration: ComponentConfig.DURATION_TIME, width: this.whtl, height: this.whtl, top: this.whtl, @@ -38,7 +38,7 @@ struct ImageAnimatorComponent { }, { src: 'res/image/xxxhdpi/ic_loading02.png', - duration: ConfigData.DURATION_TIME, + duration: ComponentConfig.DURATION_TIME, width: this.whtl, height: this.whtl, top: this.whtl, @@ -46,7 +46,7 @@ struct ImageAnimatorComponent { }, { src: 'res/image/xxxhdpi/ic_loading03.png', - duration: ConfigData.DURATION_TIME, + duration: ComponentConfig.DURATION_TIME, width: this.whtl, height: this.whtl, top: this.whtl, @@ -54,7 +54,7 @@ struct ImageAnimatorComponent { }, { src: 'res/image/xxxhdpi/ic_loading04.png', - duration: ConfigData.DURATION_TIME, + duration: ComponentConfig.DURATION_TIME, width: this.whtl, height: this.whtl, top: this.whtl, @@ -62,7 +62,7 @@ struct ImageAnimatorComponent { }, { src: 'res/image/xxxhdpi/ic_loading05.png', - duration: ConfigData.DURATION_TIME, + duration: ComponentConfig.DURATION_TIME, width: this.whtl, height: this.whtl, top: this.whtl, @@ -70,7 +70,7 @@ struct ImageAnimatorComponent { }, { src: 'res/image/hdpi/ic_loading06.png', - duration: ConfigData.DURATION_TIME, + duration: ComponentConfig.DURATION_TIME, width: this.whtl, height: this.whtl, top: this.whtl, diff --git a/common/component/src/main/ets/default/radioListComponent.ets b/common/component/src/main/ets/default/radioListComponent.ets new file mode 100644 index 00000000..84ddea70 --- /dev/null +++ b/common/component/src/main/ets/default/radioListComponent.ets @@ -0,0 +1,135 @@ +/** + * 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 ComponentConfig from './ComponentConfig.ets'; +import LogUtil from '../../../../../utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import Log from '../../../../../utils/src/main/ets/default/baseUtil/LogDecorator.ets'; + +/** + * Radio component + */ +@Component +export default +struct RadioListComponent { + @State dataList: any[] = []; + @State checkedValue: string = ''; + private showRadio: boolean = true; + private onChange?: (item : any) => void; + + build() { + Column() { + List() { + ForEach(this.dataList, (item: any) => { + ListItem() { + RadioComponent({ + settingIcon: item.settingIcon, + settingTitle: item.settingTitle, + settingSummary: item.settingSummary, + settingValue: item.settingValue, + showRadio: this.showRadio, + isChecked: (this.checkedValue == item.settingValue), + onChange:() => { + this.checkedValue = item.settingValue; + if (this.onChange) { + LogUtil.info('settings RadioListComponent : onChange: settingValue = ' + item.settingValue) + this.onChange(item); + } + } + }); + } + .height(item.settingIcon ? $r('app.float.audio_no_icon_height') : $r('app.float.audio_icon_height')); + }); + } + .divider({ + strokeWidth: 1, + color: $r('app.color.color_E3E3E3_grey'), + startMargin: $r('app.float.audio_start_end_margin_left'), + endMargin: $r('app.float.audio_start_end_margin_left') + }) + .width(ComponentConfig.WH_100_100) + .alignSelf(ItemAlign.Start); + } + .width(ComponentConfig.WH_100_100); + } +} + +/** + * set up radio component + */ +@Component +struct RadioComponent { + private settingIcon: string = ''; + private settingTitle: string = ''; + private settingSummary: string = ''; + private settingValue: string = ''; + private isChecked: boolean = false; + private onChange?: () => void; + private showRadio: boolean = true; + + build() { + Flex({ justifyContent: FlexAlign.SpaceBetween }) { + Row() { + Image(this.settingIcon) + .width($r('app.float.audio_image_common_size')) + .height($r('app.float.audio_image_common_size')) + .margin({ right: $r('app.float.audio_image_margin_right') }) + .visibility(this.settingIcon ? Visibility.Visible : Visibility.None) + .objectFit(ImageFit.Contain); + Column() { + Text(this.settingTitle) + .fontColor($r('app.color.color_333333_grey')) + .fontSize($r('app.float.control_common_font_size')) + .textAlign(TextAlign.Start) + .maxLines(ComponentConfig.MAX_LINES_3) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .margin({ top: $r('app.float.audio_subtitle_margin_top'), bottom: $r('app.float.audio_subtitle_margin_bottom') }); + + Text(this.settingSummary) + .fontColor($r('app.color.color_999999_grey')) + .fontSize($r('app.float.audio_subtitle_font_size')) + .textAlign(TextAlign.Start) + .maxLines(ComponentConfig.MAX_LINES_1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .visibility(this.settingSummary ? Visibility.Visible : Visibility.None) + .margin({ bottom: $r('app.float.audio_summary_subtitle_margin_bottom') }); + } + .margin({ left: $r('app.float.audio_title_summary_margin_left') }) + .alignItems(HorizontalAlign.Start); + } + .flexShrink(0) + .alignItems(VerticalAlign.Center) + .align(Alignment.Start); + + Row() { + Radio( {value: this.settingValue} ) + .height($r('app.float.radio_component_height')) + .margin({ right: $r('app.float.radio_component_margin_bottom_right') }) + .align(Alignment.End) + .enabled(false) + .checked(this.isChecked) + .visibility(this.showRadio ? Visibility.Visible : Visibility.None) + } + .align(Alignment.End); + } + .margin({ left: $r('app.float.audio_margin_left') }) + .width(ComponentConfig.WH_100_100) + .onClick(() => { + LogUtil.info('settings RadioComponent : call onClick.') + if (this.onChange) { + this.onChange() + } + }); + } + +} diff --git a/common/component/src/main/ets/default/sliderComponent.ets b/common/component/src/main/ets/default/sliderComponent.ets new file mode 100644 index 00000000..f82c3c04 --- /dev/null +++ b/common/component/src/main/ets/default/sliderComponent.ets @@ -0,0 +1,103 @@ +/** + * 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 ComponentConfig from './ComponentConfig.ets'; + +/** + * Slider component + */ +@Component +export default struct SliderComponent { + private visible: boolean = true; + private min: number = 0; + private max: number = 100; + private step?: number = 1; + private leftImage: string = ''; + private rightImage: string = ''; + @State clickConfirm: boolean = true; + @State showStep: boolean = false; + @State value: number = 0; + private onChange?: (value: number, mode: SliderChangeMode) => void + private summary: string | Resource; // Text details + @State fontSize: number = 18; // Font size + + build() { + Flex({ direction: FlexDirection.Row }) { + Column() { + Image(this.leftImage) + .width($r('app.float.slider_image_width')) + .height($r('app.float.slider_image_height')) + .objectFit(ImageFit.Contain); + }.align(Alignment.TopStart).visibility(this.visible ? Visibility.Visible : Visibility.None) + .padding({ left: $r('app.float.slider_image_margin') }) + .onClick(() => { + if (this.value != this.min && this.clickConfirm) { + this.value = Math.max(this.min, this.value - this.step); + this.onChangeHandler(this.value, SliderChangeMode.END); + } + }).align(Alignment.Center) + + Column() { + Row() { + Text(this.summary) + .fontSize(this.fontSize) + .textAlign(TextAlign.Start); + } + .width(ComponentConfig.WH_83_100) + + Slider({ + value: this.value, + min: this.min, + max: this.max, + step: this.step + }) + .selectedColor(Color.Blue) + .blockColor(Color.Blue) + .width(ComponentConfig.WH_100_100) + .showSteps(this.showStep) + .onChange((value, mode) => { + this.onChangeHandler(value, mode) + }); + }.align(Alignment.Center).flexGrow(1) + + Column() { + Image(this.rightImage) + .width($r('app.float.slider_image_width')) + .height($r('app.float.slider_image_height')) + .align(Alignment.Start) + .objectFit(ImageFit.Contain); + }.align(Alignment.TopEnd).visibility(this.visible ? Visibility.Visible : Visibility.None) + .padding({ right: $r('app.float.slider_image_margin') }) + .onClick(() => { + if (this.value != this.max && this.clickConfirm) { + this.value = Math.min(this.max, this.value + this.step); + this.onChangeHandler(this.value, SliderChangeMode.END); + } + }).align(Alignment.Center) + + }.width(ComponentConfig.WH_100_100).align(Alignment.TopStart) + } + +/** + * Change handler + * + * @param value - Change value + * @param mode - State + */ + onChangeHandler(value, mode) { + if (this.onChange) { + this.onChange(value, mode); + } + } +} \ No newline at end of file diff --git a/common/component/src/main/ets/default/switchComponent.ets b/common/component/src/main/ets/default/switchComponent.ets new file mode 100644 index 00000000..a4b2febc --- /dev/null +++ b/common/component/src/main/ets/default/switchComponent.ets @@ -0,0 +1,92 @@ +/** + * 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 ComponentConfig from './ComponentConfig.ets'; +import SwitchController from './controller/switchController.ets' + +/** + * Toggle component + */ +@Component +export default struct SwitchComponent { + @Link isOn: boolean; + @Prop title: string; + private toggleValue: (isOn: boolean) => void; + private controller: SwitchController; + private cssValue: { + fontSize?: number | string | Resource, + height?: number | string | Resource, + width?: number | string | Resource, + margin?: { + top?: number | string | Resource, + right?: number | string | Resource, + bottom?: number | string | Resource, + left?: number | string | Resource + } | number | string | Resource, + padding: { + top?: number | string | Resource, + right?: number | string | Resource, + bottom?: number | string | Resource, + left?: number | string | Resource + } | number | string | Resource, + }; + + build() { + Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text(this.title) + .cssSwitchComponentTiTle(this.cssValue?.fontSize) + Toggle({ type: ToggleType.Switch, isOn: this.isOn }) + .cssSwitchComponentToggle() + .onChange((isOn: boolean) => { + this.isOn = new Boolean(isOn).valueOf(); + if (this.toggleValue) { + this.toggleValue(isOn); + } + }); + } + .cssSwitchComponentFlex(this.cssValue?.margin, this.cssValue?.padding, this.cssValue?.width, this.cssValue?.height); + } + + aboutToAppear() { + if (this.controller) { + // bind event handlers + this.toggleValue = this.controller.toggleValue.bind(this.controller); + + // bind component and initialize + this.controller.bindComponent(this) + .bindProperties(["isOn"]) + .initData(); + } + } +} + +@Extend(Text) function cssSwitchComponentTiTle (fontSize: number | string | Resource=$r('app.float.switch_title_subtitle_size')) { + .fontColor(Color.Black) + .fontStyle(FontStyle.Normal) + .padding({ left: $r('app.float.switch_component_margin') }) + .fontSize(fontSize) +} + +@Extend(Toggle) function cssSwitchComponentToggle () { + .width($r('app.float.switch_toggle_width')) + .height($r('app.float.switch_toggle_height')) + .padding({ right: $r('app.float.switch_component_margin') }) +} + +@Extend(Flex) function cssSwitchComponentFlex (margin: any, padding: any, width: number | string | Resource=ComponentConfig.WH_100_100, height: number | string | Resource=$r('app.float.switch_component_height')) { + .width(width) + .height(height) + .margin(margin) + .padding(padding) +} \ No newline at end of file diff --git a/entry/src/main/ets/default/pages/component/textInputComponent.ets b/common/component/src/main/ets/default/textInputComponent.ets similarity index 92% rename from entry/src/main/ets/default/pages/component/textInputComponent.ets rename to common/component/src/main/ets/default/textInputComponent.ets index 29183679..b18bf427 100644 --- a/entry/src/main/ets/default/pages/component/textInputComponent.ets +++ b/common/component/src/main/ets/default/textInputComponent.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import ConfigData from '../../common/baseUtil/ConfigData.ets'; +import ComponentConfig from './ComponentConfig.ets'; /** * TextInput component @@ -30,7 +30,7 @@ export default struct textInputComponent { .height($r('app.float.wh_value_70')) .backgroundColor(Color.White) .type(InputType.Password) - .width(ConfigData.WH_100_100) + .width(ComponentConfig.WH_100_100) .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }) .onChange((value: string) => { this.contextText = value; diff --git a/common/component/src/main/resources/base/element/string.json b/common/component/src/main/resources/base/element/string.json new file mode 100644 index 00000000..bc311734 --- /dev/null +++ b/common/component/src/main/resources/base/element/string.json @@ -0,0 +1,4 @@ +{ + "string": [ + ] +} \ No newline at end of file diff --git a/common/search/build.gradle b/common/search/build.gradle new file mode 100644 index 00000000..525fd4ec --- /dev/null +++ b/common/search/build.gradle @@ -0,0 +1,20 @@ +apply plugin: 'com.huawei.ohos.library' +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 7 + defaultConfig { + compatibleSdkVersion 6 + } + + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } +} + +dependencies { +} diff --git a/common/search/proguard-rules.pro b/common/search/proguard-rules.pro new file mode 100644 index 00000000..f7666e47 --- /dev/null +++ b/common/search/proguard-rules.pro @@ -0,0 +1 @@ +# config module specific ProGuard rules here. \ No newline at end of file diff --git a/common/search/src/main/config.json b/common/search/src/main/config.json new file mode 100644 index 00000000..ccb0ae17 --- /dev/null +++ b/common/search/src/main/config.json @@ -0,0 +1,22 @@ +{ + "app": { + "bundleName": "com.ohos.settings", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.settings.common", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "search", + "moduleType": "har" + } + } +} \ No newline at end of file diff --git a/common/search/src/main/ets/default/common/ResourceUtil.ets b/common/search/src/main/ets/default/common/ResourceUtil.ets new file mode 100644 index 00000000..b55ab528 --- /dev/null +++ b/common/search/src/main/ets/default/common/ResourceUtil.ets @@ -0,0 +1,50 @@ +// @ts-nocheck +/** + * 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 '../../../../../../utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import ResMgr from '@ohos.resourceManager'; +import Log from '../../../../../../utils/src/main/ets/default/baseUtil/LogDecorator.ets'; + +/** + * Resource util + */ +export class ResourceUtil { + private resMgr: ResMgr.ResourceManager; + + /** + * Initialize ResourceManager + */ + @Log + async initResourceManager(): Promise { + if (!this.resMgr) { + this.resMgr = await ResMgr.getResourceManager(ConfigData.DEFAULT_BUNDLE_NAME); + } + } + + /** + * Get string value from NormalResource instance + * + * @param resource - NormalResource instance + */ + @Log + async getString(resource): Promise { + await this.initResourceManager(); + return await this.resMgr.getString(resource.id); + } + +} + +let resourceUtil = new ResourceUtil(); +export default resourceUtil as ResourceUtil; diff --git a/common/search/src/main/ets/default/common/SearchConfig.ets b/common/search/src/main/ets/default/common/SearchConfig.ets new file mode 100644 index 00000000..4d960883 --- /dev/null +++ b/common/search/src/main/ets/default/common/SearchConfig.ets @@ -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. + */ + +/** + * Search config + */ +export default { + RDB_NAME: 'settings.db', + search: { + TABLE_NAME: 'SEARCH_DATA', + FIELD_ID: 'ID', + FIELD_ICON: 'ICON', + FIELD_TITLE: 'TITLE', + FIELD_KEYWORD: 'KEYWORD', + FIELD_SUMMARY: 'SUMMARY', + FIELD_SYNONYM: 'SYNONYM', + FIELD_URI: 'URI', + DDL_TABLE_CREATE: 'CREATE TABLE IF NOT EXISTS SEARCH_DATA (' + + 'ID INTEGER PRIMARY KEY AUTOINCREMENT, ' + + 'URI VARCHAR(200) NOT NULL, ' + + 'ICON VARCHAR(200), ' + + 'TITLE TEXT NOT NULL COLLATE NOCASE, ' + + 'KEYWORD TEXT NOT NULL COLLATE NOCASE, ' + + 'SUMMARY TEXT, ' + + 'SYNONYM TEXT )', + SQL_DELETE_ALL: 'DELETE FROM SEARCH_DATA', + PATH_SEPARATOR: ' > ' + } +} diff --git a/common/search/src/main/ets/default/common/SearchUtil.ets b/common/search/src/main/ets/default/common/SearchUtil.ets new file mode 100644 index 00000000..38b8f09f --- /dev/null +++ b/common/search/src/main/ets/default/common/SearchUtil.ets @@ -0,0 +1,77 @@ +/** + * 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 SearchData from '../model/SearchData'; +import Log from '../../../../../../utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import ResourceUtil from './ResourceUtil.ets'; + +/** + * Search util + */ +export class SearchUtil { + + /** + * Convert json to instance + */ + @Log + convertJsonToInstance (json: any, t: {new(): T}): T { + var instance = new t(); + + for (var key in json) { + if (instance.hasOwnProperty(key)) { + instance[key] = json[key]; + } + } + + return instance; + } + + /** + * Convert json to SearchData instance + */ + @Log + async convertToSearchData(rawData): Promise { + let result: Array = []; + + for (let jsonData of rawData.data) { + let searchData: SearchData = new SearchData(); + searchData.title = await ResourceUtil.getString(rawData.title); + searchData.keyword = await ResourceUtil.getString(jsonData.keyword); + searchData.summary = jsonData.summary ? await ResourceUtil.getString(jsonData.summary) : jsonData.summary; + searchData.synonym = jsonData.synonym ? await ResourceUtil.getString(jsonData.synonym) : jsonData.synonym; + + result.push(searchData); + }; + + return result; + } + + /** + * Delete illegal characters from search keyword + * + * @param text + */ + stripKeyword(text: string): string { + var pattern = new RegExp("[`~!@#$%^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]") + var rs = ""; + for (var i = 0; i < text.length; i++) { + rs = rs + text.substr(i, 1).replace(pattern, ''); + } + return rs; + } + +} + +let searchUtil = new SearchUtil(); +export default searchUtil as SearchUtil; diff --git a/common/search/src/main/ets/default/model/SearchData.ts b/common/search/src/main/ets/default/model/SearchData.ts new file mode 100644 index 00000000..a02545f8 --- /dev/null +++ b/common/search/src/main/ets/default/model/SearchData.ts @@ -0,0 +1,29 @@ +/** + * 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. + */ + +/** + * Search data dto class + */ +export default class SearchData { + uri: string = ''; + icon: string = ''; + title: string = ''; + keyword: string = ''; + summary: string = ''; + synonym: string = ''; + + constructor() { + } +} \ No newline at end of file diff --git a/common/search/src/main/ets/default/model/SearchModel.ets b/common/search/src/main/ets/default/model/SearchModel.ets new file mode 100644 index 00000000..d5d82e6a --- /dev/null +++ b/common/search/src/main/ets/default/model/SearchModel.ets @@ -0,0 +1,220 @@ +/** + * 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 '../../../../../../utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import Log from '../../../../../../utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import { BaseData } from '../../../../../../utils/src/main/ets/default/model/BaseData.ets'; +import LogUtil from '../../../../../../utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import SearchConfig from '../common/SearchConfig.ets'; +import SearchData from '../model/SearchData'; +import SearchDataProvider from '../provider/SearchDataProvider'; +import BaseParseConfModel from '../../../../../../utils/src/main/ets/default/model/BaseParseConfModel.ets'; +import ohosDataRdb from '@ohos.data.rdb'; + +/** + * Search service class + */ +export default class SearchModel { + private rdbStore; + private searchDataConfig; + + constructor(configData: Array) { + this.searchDataConfig = configData; + } + + /** + * Initialize rdb + */ + @Log + private async initRdb(): Promise { + LogUtil.log('settings initRdb.'); + + if (!this.rdbStore) { + LogUtil.log('settings RDB has not been initialized yet.'); + + // database init + const STORE_CONFIG = { name: SearchConfig.RDB_NAME}; + this.rdbStore = await ohosDataRdb.getRdbStore(STORE_CONFIG, 1); + LogUtil.log('settings SettingsSearch.db is ready.'); + + // table SEARCH_DATA init + await this.rdbStore.executeSql(SearchConfig.search.DDL_TABLE_CREATE, null); + console.log('settings table SEARCH_DATA is ready.'); + } + } + + /** + * Initialize search data + */ + @Log + public async initSearchData(): Promise { + const searchData = await this.gatherSearchData(); + await this.initRdbSearchData(searchData); + } + + /** + * Search + * + * @param query - query content + */ + @Log + public async search(query: string): Promise { + if (!query) { + return [] + } + + await this.initRdb(); + + // query search data + let predicates = new ohosDataRdb.RdbPredicates(SearchConfig.search.TABLE_NAME); + predicates.like(SearchConfig.search.FIELD_KEYWORD, `%${query}%`) + .or().like(SearchConfig.search.FIELD_SUMMARY, `%${query}%`) + .or().like(SearchConfig.search.FIELD_SYNONYM, `%${query}%`) + .orderByAsc(SearchConfig.search.FIELD_URI); + + let resultSet = await this.rdbStore.query(predicates, [ + SearchConfig.search.FIELD_ICON, + SearchConfig.search.FIELD_TITLE, + SearchConfig.search.FIELD_KEYWORD, + SearchConfig.search.FIELD_SUMMARY, + SearchConfig.search.FIELD_URI + ]); + + // build search data from resultSet + let searchData: SearchData[] = []; + while (resultSet.goToNextRow()) { + const data = new SearchData(); + data.icon = resultSet.getString(0); + data.title = resultSet.getString(1); + data.keyword = resultSet.getString(2); + data.summary = resultSet.getString(3); + data.uri = resultSet.getString(4); + searchData.push(data); + } + resultSet.close(); + resultSet = null; + + return searchData; + } + + /** + * Gather search data from providers + * + * @param searchData - search data to be grouped + */ + @Log + private async gatherSearchData(): Promise { + // init uriConfigMapping + const uriConfigMapping = new Map(); + this.searchDataConfig.forEach(config => { + uriConfigMapping.set(config.settingUri, config); + }) + + // get searchData (note: settingList must be the first) + let searchData: SearchData[] = await this.getSearchData(this.searchDataConfig[0].settingUri, '', uriConfigMapping); + LogUtil.log('settings search searchData: ' + JSON.stringify(searchData)); + + return searchData; + } + + /** + * Initialize rdb search data + * + * @param searchData - search data + */ + @Log + private async initRdbSearchData(searchData: SearchData[]): Promise { + LogUtil.log('settings search old data if exists.'); + await this.initRdb(); + + // delete old data if exists + await this.rdbStore.executeSql(SearchConfig.search.SQL_DELETE_ALL, null); + LogUtil.log('settings search old data if exists.'); + + // insert new data into table + for (let data of searchData) { + const valueBucket = {}; + valueBucket[SearchConfig.search.FIELD_URI] = data.uri; + valueBucket[SearchConfig.search.FIELD_ICON] = data.icon; + valueBucket[SearchConfig.search.FIELD_TITLE] = data.title; + valueBucket[SearchConfig.search.FIELD_KEYWORD] = data.keyword; + valueBucket[SearchConfig.search.FIELD_SUMMARY] = data.summary; + valueBucket[SearchConfig.search.FIELD_SYNONYM] = data.synonym; + let ret = await this.rdbStore.insert(SearchConfig.search.TABLE_NAME, valueBucket) + LogUtil.log("settings: search insert data: " + ret) + } + } + + /** + * Get search data + * + * @param settingUri - setting uri + * @param settingIcon - setting icon + * @param uriConfigMapping - uri config mapping + */ + @Log + private async getSearchData(settingUri: string, settingIcon: string, uriConfigMapping: Map): Promise { + if (!uriConfigMapping.get(settingUri)) { + return []; + } + + // get search data from provider + const provider: SearchDataProvider = uriConfigMapping.get(settingUri).provider; + let searchProviderData: SearchData[] = await provider.getSearchData(); + + // set uri, icon + searchProviderData.forEach(providerData => { + if (!providerData.uri) { + providerData.uri = settingUri; + } + providerData.icon = settingIcon; + }); + + // get setting list + let settingConfig = ConfigData.FILE_URI.concat(uriConfigMapping.get(settingUri).settingRawJson) + let settingList: BaseData[] = this.getSettingList(settingConfig); + + // get child page search + for (const setting of settingList) { + const icon = settingIcon ? settingIcon : setting.settingIcon; // higher priority for parent icon + const childData = await this.getSearchData(setting.settingUri, icon, uriConfigMapping); + searchProviderData = searchProviderData.concat(childData); + }; + + return searchProviderData; + } + + /** + * Get setting list which includes settingUri in each setting + * + * @param settingConfig - setting config path + */ + @Log + private getSettingList(settingConfig: string): BaseData[] { + let result = []; + + let settingList: any[] = BaseParseConfModel.getJsonData(settingConfig); + settingList.forEach(setting => { + if (setting.settingUri) { + let baseData = new BaseData(); + baseData.settingIcon = setting.settingIcon; + baseData.settingUri = setting.settingUri; + result.push(baseData); + } + }); + + return result; + } + +} diff --git a/common/search/src/main/ets/default/page/resultComponent.ets b/common/search/src/main/ets/default/page/resultComponent.ets new file mode 100644 index 00000000..e4852a61 --- /dev/null +++ b/common/search/src/main/ets/default/page/resultComponent.ets @@ -0,0 +1,135 @@ +/** + * 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 SearchData from '../model/SearchData'; +import LogUtil from '../../../../../../utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import Log from '../../../../../../utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import ConfigData from '../../../../../../utils/src/main/ets/default/baseUtil/ConfigData.ets'; + +/** + * result component + */ +@Component +export default struct ResultComponent { + private TEXT_TYPE_NORMAL = 1 + private TEXT_TYPE_KEYWORD = 2 + @Link highlightKeyword: string + @State icon: string = '' + @State data: SearchData = new SearchData() + + @Builder HighlightText( + spans: string[], + fontColor: Color | Resource, + fontSize: Resource, + highlightFontColor: Color | Resource) { + + Text() { + ForEach(spans.map((item1, index1) => { + return { index: index1, data: item1 }; + }), item => { + + if (item.data.type == this.TEXT_TYPE_NORMAL) { + Span(item.data.text).fontColor(fontColor).fontSize(fontSize) + } else if (item.data.type == this.TEXT_TYPE_KEYWORD) { + Span(item.data.text).fontColor(highlightFontColor).fontSize(fontSize) + } + }, + item => item.index) + } + .textAlign(TextAlign.Start) + .maxLines(3) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .margin({ top: $r('app.float.wh_value_10'), bottom: $r('app.float.wh_value_5') }) + } + + build() { + Row() { + Image(this.icon) + .width($r('app.float.wh_value_50')) + .height($r('app.float.wh_value_50')) + .margin({ right: $r('app.float.wh_value_10') }) + .visibility(this.icon ? Visibility.Visible : Visibility.Hidden) + .objectFit(ImageFit.Contain); + + Column() { + this.HighlightText( + this.splitToHighlightText(this.data.keyword), + $r('app.color.color_333333_grey'), + $r('app.float.search_result_item_title_font_size'), + Color.Blue + ) + + if (this.data.summary) { + this.HighlightText( + this.splitToHighlightText(this.data.summary), + $r('app.color.color_666666_grey'), + $r('app.float.search_result_item_summary_font_size'), + Color.Blue + ) + } + } + .layoutWeight(1) + .alignItems(HorizontalAlign.Start); + + Image("/res/image/ic_settings_arrow.svg") + .width($r('app.float.wh_value_40')) + .height($r('app.float.wh_value_40')) + } + .padding({ + left: $r('app.float.item_common_horizontal_margin'), + right: $r('app.float.item_common_horizontal_margin') + }) + .flexShrink(0) + .alignItems(VerticalAlign.Center) + .align(Alignment.Start) + } + + /** + * split to highlight text + * @param text + */ + @Log + splitToHighlightText(text: string): any[] { + let spans: any[] = [] + + var lowerSpans: string[] = text.toLowerCase().split(this.highlightKeyword.toLowerCase()) + var keywordStartIndex = 0 + var keywordLength = this.highlightKeyword.length + + for (var i = 0; i < lowerSpans.length; i++) { + var normalText = text.substr(keywordStartIndex, lowerSpans[i].length) + spans.push({ + type: this.TEXT_TYPE_NORMAL, + text: normalText + }) + LogUtil.debug(ConfigData.TAG + 'ResultComponent splitToHighlightText : i = [' + i + '] push normal : ' + + JSON.stringify(normalText)); + + // if not at last, append highlight keyword + if (i != lowerSpans.length - 1) { + keywordStartIndex += lowerSpans[i].length + var keywordText = text.substr(keywordStartIndex, keywordLength) + spans.push({ + type: this.TEXT_TYPE_KEYWORD, + text: keywordText + }) + LogUtil.debug(ConfigData.TAG + 'ResultComponent splitToHighlightText : i = [' + i + '] push keyword : ' + + JSON.stringify(keywordText)); + keywordStartIndex += keywordLength + } + } + + return spans + } +} \ No newline at end of file diff --git a/common/search/src/main/ets/default/page/searchHeader.ets b/common/search/src/main/ets/default/page/searchHeader.ets new file mode 100644 index 00000000..62aa99b2 --- /dev/null +++ b/common/search/src/main/ets/default/page/searchHeader.ets @@ -0,0 +1,85 @@ +/** + * 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 ResourceUtil from '../common/ResourceUtil.ets'; +import LogUtil from '../../../../../../utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import Log from '../../../../../../utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import ConfigData from '../../../../../../utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import Router from '@system.router' + +/** + * Search header component + */ +@Component +export default struct SearchHeader { + @Link inputKeyword: string + @State placeholder: string = '' + + build() { + Row() { + + // back + Image($r('app.media.ic_back')) + .width($r('app.float.wh_value_50')) + .height($r('app.float.wh_value_50')) + .objectFit(ImageFit.Contain) + .onClick(() => { + LogUtil.debug(ConfigData.TAG + 'searchPage SearchHeader : back clicked.'); + Router.back() + }) + + // text input + Stack({ alignContent: Alignment.End }) { + TextInput({ placeholder: this.placeholder, text: this.inputKeyword }) + .margin({ + left: $r('app.float.search_input_horizontal_margin'), + right: $r('app.float.search_input_horizontal_margin') + }) + .placeholderFont({size:10,weight:FontWeight.Normal,style:FontStyle.Normal}) + .type(InputType.Normal) + .enterKeyType(EnterKeyType.Search) + .layoutWeight(1) + .height($r("app.float.search_input_height")) + .borderRadius($r("app.float.search_input_border_radius")) + .backgroundColor(Color.White) + .onChange((value: string) => { + LogUtil.debug(ConfigData.TAG + 'searchPage SearchHeader : text input on change :value = ' + JSON.stringify(value)); + this.inputKeyword = value + }) + + if (this.inputKeyword) { + + // input text clear + Text('×') + .fontSize($r('app.float.font_28')) + .width($r('app.float.wh_value_60')) + .height($r('app.float.wh_value_60')) + .backgroundColor($r('app.color.color_00000000_transparent')) + .textAlign(TextAlign.Center) + .onClick(() => { + LogUtil.debug(ConfigData.TAG + 'searchPage SearchHeader : clear search key clicked.'); + this.inputKeyword = '' + }) + } + } + } + .height($r('app.float.page_header_height')) + .padding({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_60') }) + } + + @Log + aboutToAppear() { + ResourceUtil.getString($r("app.string.searchHint")).then(value => this.placeholder = value) + } +} \ No newline at end of file diff --git a/common/search/src/main/ets/default/provider/PageSearchDataProvider.ets b/common/search/src/main/ets/default/provider/PageSearchDataProvider.ets new file mode 100644 index 00000000..e75f9151 --- /dev/null +++ b/common/search/src/main/ets/default/provider/PageSearchDataProvider.ets @@ -0,0 +1,34 @@ +/** + * 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 Log from '../../../../../../utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import SearchUtil from '../common/SearchUtil.ets'; +import SearchData from '../model/SearchData'; +import SearchDataProvider from './SearchDataProvider'; + +/** + * Page search data provider + */ +export default abstract class PageSearchDataProvider implements SearchDataProvider { + abstract getPageSearchData(): any; + + /** + * Get search data + */ + @Log + async getSearchData(): Promise { + return await SearchUtil.convertToSearchData(this.getPageSearchData()); + } + +} \ No newline at end of file diff --git a/common/search/src/main/ets/default/provider/SearchDataProvider.ts b/common/search/src/main/ets/default/provider/SearchDataProvider.ts new file mode 100644 index 00000000..97401791 --- /dev/null +++ b/common/search/src/main/ets/default/provider/SearchDataProvider.ts @@ -0,0 +1,26 @@ +/** + * 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 SearchData from '../model/SearchData'; + +/** + * Search data provider + */ +export default interface SearchDataProvider { + + /** + * Get search data + */ + getSearchData(): Promise; +} \ No newline at end of file diff --git a/common/search/src/main/resources/base/element/string.json b/common/search/src/main/resources/base/element/string.json new file mode 100644 index 00000000..bc311734 --- /dev/null +++ b/common/search/src/main/resources/base/element/string.json @@ -0,0 +1,4 @@ +{ + "string": [ + ] +} \ No newline at end of file diff --git a/common/settingsBase/build.gradle b/common/settingsBase/build.gradle new file mode 100644 index 00000000..525fd4ec --- /dev/null +++ b/common/settingsBase/build.gradle @@ -0,0 +1,20 @@ +apply plugin: 'com.huawei.ohos.library' +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 7 + defaultConfig { + compatibleSdkVersion 6 + } + + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } +} + +dependencies { +} diff --git a/common/settingsBase/proguard-rules.pro b/common/settingsBase/proguard-rules.pro new file mode 100644 index 00000000..f7666e47 --- /dev/null +++ b/common/settingsBase/proguard-rules.pro @@ -0,0 +1 @@ +# config module specific ProGuard rules here. \ No newline at end of file diff --git a/common/settingsBase/src/main/config.json b/common/settingsBase/src/main/config.json new file mode 100644 index 00000000..778f46f7 --- /dev/null +++ b/common/settingsBase/src/main/config.json @@ -0,0 +1,22 @@ +{ + "app": { + "bundleName": "com.ohos.settings", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.settings.common", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "settingsBase", + "moduleType": "har" + } + } +} \ No newline at end of file diff --git a/common/settingsBase/src/main/resources/base/element/string.json b/common/settingsBase/src/main/resources/base/element/string.json new file mode 100644 index 00000000..bc311734 --- /dev/null +++ b/common/settingsBase/src/main/resources/base/element/string.json @@ -0,0 +1,4 @@ +{ + "string": [ + ] +} \ No newline at end of file diff --git a/common/utils/build.gradle b/common/utils/build.gradle new file mode 100644 index 00000000..525fd4ec --- /dev/null +++ b/common/utils/build.gradle @@ -0,0 +1,20 @@ +apply plugin: 'com.huawei.ohos.library' +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 7 + defaultConfig { + compatibleSdkVersion 6 + } + + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } +} + +dependencies { +} diff --git a/common/utils/proguard-rules.pro b/common/utils/proguard-rules.pro new file mode 100644 index 00000000..f7666e47 --- /dev/null +++ b/common/utils/proguard-rules.pro @@ -0,0 +1 @@ +# config module specific ProGuard rules here. \ No newline at end of file diff --git a/common/utils/src/main/config.json b/common/utils/src/main/config.json new file mode 100644 index 00000000..3d227483 --- /dev/null +++ b/common/utils/src/main/config.json @@ -0,0 +1,22 @@ +{ + "app": { + "bundleName": "com.ohos.settings", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.settings.common", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "utils", + "moduleType": "har" + } + } +} \ No newline at end of file diff --git a/common/utils/src/main/ets/default/baseUtil/ConfigData.ets b/common/utils/src/main/ets/default/baseUtil/ConfigData.ets new file mode 100644 index 00000000..a9fdc5cb --- /dev/null +++ b/common/utils/src/main/ets/default/baseUtil/ConfigData.ets @@ -0,0 +1,95 @@ +/** + * 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/phone/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_BROADCAST_VOLUME_VALUE = 'VOLUME_VALUE'; + SENT_EVENT_WIFI_CONNECT_NAME = 'WIFI_CONNECT_NAME'; + SENT_EVENT_AUDIO_RINGER_MODE = 'AUDIO_RINGER_MODE'; + SENT_EVENT_AUDIO_VOLUME_VALUE = 'AUDIO_VOLUME_VALUE'; + + BRIGHTNESS_DEFAULT_VALUE = 50; + DEFAULT_BUNDLE_NAME = 'com.ohos.settings'; + DATE_AND_TIME_YEAR='DATE_AND_TIME_YEAR' + DATE_AND_TIME_MONTH='DATE_AND_TIME_MONTH' + DATE_AND_TIME_DAY='DATE_AND_TIME_DAY' + TAG='Settings ' + + // page request + PAGE_REQUEST_CODE_KEY = 'pageRequestCode' + PAGE_RESULT_KEY = 'pageResult' + PAGE_RESULT_OK = -1 + PAGE_RESULT_NG = 0 + + // password request code + PAGE_REQUEST_CODE_PASSWORD_FACE = 10001 + PAGE_REQUEST_CODE_PASSWORD_CREATE = 20001 + PAGE_REQUEST_CODE_PASSWORD_CHANGE = 20003 + PAGE_REQUEST_CODE_PASSWORD_DISABLE = 20004 + + WH_100_100 = '100%'; + WH_30_100 = '30%'; + WH_33_100 = '33%'; + WH_35_100 = '35%'; + 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_20 = 20; + font_20 = 20; + + MAX_LINES_1 = 1; + MAX_LINES_2 = 2; + MAX_LINES_3 = 3; + DURATION_TIME = 200; + FUNCTION_TYPE_HDC = 4; + + TIME_FORMAT_24 = "24"; + TIME_FORMAT_12 = "12"; + TIME_PREFIX_MORNING = "上午" ; + TIME_PREFIX_AFTERNOON = "下午"; + TIME_FORMAT_URI = "dataability:///com.ohos.settingsdata.DataAbility"; + TIME_FORMAT_KEY = 'settings.time.format'; + SETTINGSDATA_BRIGHTNESS = 'settings.screen.brightness'; + SETTINGSDATA_VOLUME_RINGTONE = 'settings.audio.ringtone'; + SETTINGSDATA_VOLUME_MEDIA = 'settings.audio.media'; + SETTINGSDATA_VOLUME_CALL = 'settings.audio.voicecall'; + SLIDER_CHANG_MODE_MOVING = 1; + SLIDER_CHANG_MODE_END = 2; + + //Language And Region + ADDLANGUAGES = 'addedLanguages'; + CURRENTREGION = 'currentRegion'; + + //Storage Path + STORAGEPATH = '/data/accounts/account_0/appdata/com.ohos.settings/files'; + + //StartAbility + FACEAUTH_BUNDLE_NAME = 'com.ohos.settings.faceauth'; + FACEAUTH_ABILITY_NAME = 'com.ohos.settings.faceauth.enrollmentstartview'; + PERMISSION_MANAGER_BUNDLE_NAME = 'com.ohos.permissionmanager'; + PERMISSION_MANAGER_ABILITY_NAME = 'com.ohos.permissionmanager.MainAbility'; +} + +let configData = new ConfigData(); +export default configData as ConfigData; \ No newline at end of file diff --git a/entry/src/main/ets/default/common/baseUtil/DateAndTimeUtil.ets b/common/utils/src/main/ets/default/baseUtil/DateAndTimeUtil.ets similarity index 77% rename from entry/src/main/ets/default/common/baseUtil/DateAndTimeUtil.ets rename to common/utils/src/main/ets/default/baseUtil/DateAndTimeUtil.ets index d90195e3..66cf3cad 100644 --- a/entry/src/main/ets/default/common/baseUtil/DateAndTimeUtil.ets +++ b/common/utils/src/main/ets/default/baseUtil/DateAndTimeUtil.ets @@ -17,13 +17,24 @@ */ import ConfigData from './ConfigData.ets'; -import BrightnessSettingModel from '../../model/brightnessImpl/BrightnessSettingModel.ets'; +import PreferenceUtil from './PreferenceUtil.ets'; + export class DateAndTimeUtil { - getSystemTime() { + getSystemTime(isUsing24hFormat: boolean) { let datetime = new Date(); let hours = datetime.getHours(); let minutes = datetime.getMinutes(); + let time = this.concatTime(hours, minutes) + if (isUsing24hFormat === false) { + if (hours < 12) { + time = ConfigData.TIME_PREFIX_MORNING + this.concatTime(hours, minutes); + } else if (hours === 12) { + time = ConfigData.TIME_PREFIX_AFTERNOON + this.concatTime(hours, minutes); + } else { + time = ConfigData.TIME_PREFIX_AFTERNOON + this.concatTime((hours % 12), minutes); + } + } return time; } @@ -41,9 +52,9 @@ export class DateAndTimeUtil { }; concatDate(year, month, date) { - let nYear = BrightnessSettingModel.getStorageValue(ConfigData.DATE_AND_TIME_YEAR,''); - let nMonth = BrightnessSettingModel.getStorageValue(ConfigData.DATE_AND_TIME_MONTH,''); - let nDay = BrightnessSettingModel.getStorageValue(ConfigData.DATE_AND_TIME_DAY,''); + let nYear = PreferenceUtil.getStorageValue(ConfigData.DATE_AND_TIME_YEAR,''); + let nMonth = PreferenceUtil.getStorageValue(ConfigData.DATE_AND_TIME_MONTH,''); + let nDay = PreferenceUtil.getStorageValue(ConfigData.DATE_AND_TIME_DAY,''); console.info('SettingList concatDate day:'+ nDay) return year + nYear + month + nMonth + date + nDay; }; diff --git a/entry/src/main/ets/default/common/baseUtil/Global.ets b/common/utils/src/main/ets/default/baseUtil/Global.ets similarity index 100% rename from entry/src/main/ets/default/common/baseUtil/Global.ets rename to common/utils/src/main/ets/default/baseUtil/Global.ets diff --git a/entry/src/main/ets/default/common/baseUtil/GlobalResourceManager.ets b/common/utils/src/main/ets/default/baseUtil/GlobalResourceManager.ets similarity index 97% rename from entry/src/main/ets/default/common/baseUtil/GlobalResourceManager.ets rename to common/utils/src/main/ets/default/baseUtil/GlobalResourceManager.ets index e7fe8078..4e2e5db1 100644 --- a/entry/src/main/ets/default/common/baseUtil/GlobalResourceManager.ets +++ b/common/utils/src/main/ets/default/baseUtil/GlobalResourceManager.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import BaseModel from '../../model/BaseModel.ets'; +import BaseModel from '../model/BaseModel.ets'; import Rsm from '@ohos.resourceManager'; import ConfigData from './ConfigData.ets'; diff --git a/common/utils/src/main/ets/default/baseUtil/LogDecorator.ets b/common/utils/src/main/ets/default/baseUtil/LogDecorator.ets new file mode 100644 index 00000000..d084cb4f --- /dev/null +++ b/common/utils/src/main/ets/default/baseUtil/LogDecorator.ets @@ -0,0 +1,63 @@ +/** + * 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 './LogUtil.ets'; +import ConfigData from './ConfigData.ets'; + +/** + * Method log decorator + */ +const LogMethod = (target: Object, methodName: string, propertyDescriptor: PropertyDescriptor): PropertyDescriptor => { + const method = propertyDescriptor.value; + + propertyDescriptor.value = function (...args: any[]) { + const params = args.map(a => JSON.stringify(a)).join(); + LogUtil.info(ConfigData.TAG + `${target.constructor.name}#${methodName}(${params}) in `); + + const result = method.apply(this, args); + const r = JSON.stringify(result); + + LogUtil.info(ConfigData.TAG + `${target.constructor.name}#${methodName}(${params}) out => ${r}`); + return result; + } + + return propertyDescriptor; +}; + +/** + * Class decorator to log all methods + */ +export const LogAll = (target: any) => { + Reflect.ownKeys(target.prototype).forEach(propertyKey => { + let propertyDescriptor: PropertyDescriptor = Object.getOwnPropertyDescriptor(target.prototype, propertyKey); + const method = propertyDescriptor.value; + + if (method) { + propertyDescriptor.value = function (...args: any[]) { + const params = args.map(a => JSON.stringify(a)).join(); + LogUtil.info(ConfigData.TAG + `${target.name}#${propertyKey.toString()}(${params}) in `); + + const result = method.apply(this, args); + const r = JSON.stringify(result); + + LogUtil.info(ConfigData.TAG + `${target.name}#${propertyKey.toString()}(${params}) out => ${r}`); + return result; + } + + Object.defineProperty(target.prototype, propertyKey, propertyDescriptor); + } + }); +} + +export default LogMethod; diff --git a/entry/src/main/ets/default/common/baseUtil/LogUtil.ets b/common/utils/src/main/ets/default/baseUtil/LogUtil.ets similarity index 96% rename from entry/src/main/ets/default/common/baseUtil/LogUtil.ets rename to common/utils/src/main/ets/default/baseUtil/LogUtil.ets index e2ccf50c..045c3063 100644 --- a/entry/src/main/ets/default/common/baseUtil/LogUtil.ets +++ b/common/utils/src/main/ets/default/baseUtil/LogUtil.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import BaseModel from '../../model/BaseModel.ets'; +import BaseModel from '../model/BaseModel.ets'; /** * Log level @@ -54,7 +54,6 @@ export class LogUtil extends BaseModel { log(msg): void { console.log(msg); - } info(msg): void { diff --git a/common/utils/src/main/ets/default/baseUtil/PreferenceUtil.ets b/common/utils/src/main/ets/default/baseUtil/PreferenceUtil.ets new file mode 100644 index 00000000..38470a1c --- /dev/null +++ b/common/utils/src/main/ets/default/baseUtil/PreferenceUtil.ets @@ -0,0 +1,49 @@ +/** + * 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 './ConfigData.ets'; +import LogUtil from './LogUtil.ets' +import Storage from '@ohos.data.storage'; + +let preference = Storage.getStorageSync(ConfigData.PREFERENCES_PATH); + +export class PreferenceUtil { + /** + * Set up storage data + * + * @param key - key + * @param value - value + */ + setStorageValue(key,value): void { + LogUtil.info(`Set preference, key: ${key}, value: ${value}")`); + preference.putSync(key, value); + preference.flushSync(); + } + + /** + * Get stored data + * + * @param key - key + * @param defaultValue - defaultValue + */ + getStorageValue(key,defaultValue): any { + let value = preference.getSync(key, defaultValue); + LogUtil.info(`Get storage value, key: ${key}, value: ${value}`); + return value; + } +} + +let preferenceUtil = new PreferenceUtil(); +export default preferenceUtil as PreferenceUtil \ No newline at end of file diff --git a/entry/src/main/ets/default/common/baseUtil/RdbStoreUtil.ets b/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets similarity index 98% rename from entry/src/main/ets/default/common/baseUtil/RdbStoreUtil.ets rename to common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets index 30214b5c..3b5620fe 100644 --- a/entry/src/main/ets/default/common/baseUtil/RdbStoreUtil.ets +++ b/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import BaseModel from '../../model/BaseModel.ets'; +import BaseModel from '../model/BaseModel.ets'; import LogUtil from './LogUtil.ets'; import ohosDataRdb from '@ohos.data.rdb'; diff --git a/entry/src/main/ets/default/common/baseUtil/Secure.ets b/common/utils/src/main/ets/default/baseUtil/Secure.ets similarity index 100% rename from entry/src/main/ets/default/common/baseUtil/Secure.ets rename to common/utils/src/main/ets/default/baseUtil/Secure.ets diff --git a/common/utils/src/main/ets/default/baseUtil/SubscriberUtil.ets b/common/utils/src/main/ets/default/baseUtil/SubscriberUtil.ets new file mode 100644 index 00000000..5407fcf7 --- /dev/null +++ b/common/utils/src/main/ets/default/baseUtil/SubscriberUtil.ets @@ -0,0 +1,96 @@ +/** + * 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 './ConfigData.ets'; +import CommonEvent from '@ohos.commonevent'; + +let mCommonEventSubscribeInfo = { + events: ['BRIGHTNESS_VALUE_SYSTEM_UI'] +}; + +let mCommonEventSubscriber = null; +let mCustomStatusSubscriberCallBack = null; + +/** + * broadcast + */ +export class SubscriberUtils { + /** + * Send broadcast + * + * @param value - value + * @param broadcastName - broadcastName + */ + sendEvent(value, broadcastName) { + console.log(`settings SubscriberUtils sendEvent ets in value:` + value + "|broadcastName:" + broadcastName); + let commonEventPublishData = { + data: value + }; + CommonEvent.publish(broadcastName, commonEventPublishData, (err, data) => { + console.log(`settings SubscriberUtils sendEvent ets ${JSON.stringify(err)}`); + console.log(`settings SubscriberUtils sendEvent ets ${JSON.stringify(data)}`); + }); + console.log(`settings SubscriberUtils sendEvent ets out`); + } + + /** + * Register to broadcast + */ + registerStatusListener(pCommonEventSubscribeInfo?, pCallback?) { + console.info(`settings SubscriberUtils Subscriberregister status listener in`); + + mCustomStatusSubscriberCallBack = pCallback; + + var subscribeInfo = pCommonEventSubscribeInfo ? pCommonEventSubscribeInfo : mCommonEventSubscribeInfo; + CommonEvent.createSubscriber( + subscribeInfo, + this.createStatusSubscriberCallBack.bind(this) + ); + + console.info(`settings SubscriberUtils Subscriberregister status listener out`); + } + + createStatusSubscriberCallBack(err, data) { + console.info(`settings SubscriberUtils Subscriberregister in ets ${JSON.stringify(err)} ${JSON.stringify(data)}`); + mCommonEventSubscriber = data; + CommonEvent.subscribe(mCommonEventSubscriber, this.statusSubscriberCallBack.bind(this)); + console.info(`settings SubscriberUtils Subscriberregister in`); + } + + statusSubscriberCallBack(err, data) { + console.info(`settings SubscriberUtils statusSubscriberCallBack data ets : ${JSON.stringify(data)}`); + console.info(`settings SubscriberUtils statusSubscriberCallBack err ets : ${JSON.stringify(err)}`); + console.log(`settings SubscriberUtils statusSubscriberCallBack data.event ets : ${data.event} `); + if (mCustomStatusSubscriberCallBack) { + mCustomStatusSubscriberCallBack(err, data); + } + if (err) { + console.info(`settings SubscriberUtils statusSubscriberCallBack error : ${err}`) + return; + } + console.log(`settings SubscriberUtils statusSubscriberCallBack out`); + } + + /** + * unRegister to broadcast + */ + unSubscriberListener() { + CommonEvent.unsubscribe(mCommonEventSubscriber, () => { + console.info('settings SubscriberUtils unSubscriberListener'); + }); + } +} + +let subscriberUtils = new SubscriberUtils(); +export default subscriberUtils as SubscriberUtils; \ No newline at end of file diff --git a/entry/src/main/ets/default/common/baseUtil/System.ets b/common/utils/src/main/ets/default/baseUtil/System.ets similarity index 100% rename from entry/src/main/ets/default/common/baseUtil/System.ets rename to common/utils/src/main/ets/default/baseUtil/System.ets diff --git a/entry/src/main/ets/default/model/BaseData.ets b/common/utils/src/main/ets/default/model/BaseData.ets similarity index 100% rename from entry/src/main/ets/default/model/BaseData.ets rename to common/utils/src/main/ets/default/model/BaseData.ets diff --git a/entry/src/main/ets/default/model/BaseModel.ets b/common/utils/src/main/ets/default/model/BaseModel.ets similarity index 100% rename from entry/src/main/ets/default/model/BaseModel.ets rename to common/utils/src/main/ets/default/model/BaseModel.ets diff --git a/entry/src/main/ets/default/model/baseParseConfImpl/BaseParseConfModel.ets b/common/utils/src/main/ets/default/model/BaseParseConfModel.ets similarity index 95% rename from entry/src/main/ets/default/model/baseParseConfImpl/BaseParseConfModel.ets rename to common/utils/src/main/ets/default/model/BaseParseConfModel.ets index 33222dc3..81b33705 100644 --- a/entry/src/main/ets/default/model/baseParseConfImpl/BaseParseConfModel.ets +++ b/common/utils/src/main/ets/default/model/BaseParseConfModel.ets @@ -12,8 +12,8 @@ * 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 BaseModel from './BaseModel.ets'; +import LogUtil from '../baseUtil/LogUtil.ets'; import FileIo from '@ohos.fileio'; const DFAULT_SIZE = 4096; diff --git a/common/utils/src/main/ets/default/model/BasicDataSource.ets b/common/utils/src/main/ets/default/model/BasicDataSource.ets new file mode 100644 index 00000000..7c41175c --- /dev/null +++ b/common/utils/src/main/ets/default/model/BasicDataSource.ets @@ -0,0 +1,70 @@ +/** + * 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 BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): any { + return undefined; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const position = this.listeners.indexOf(listener); + if (position >= 0) { + this.listeners.splice(position, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdded(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChanged(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDeleted(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMoved(from, to); + }) + } +} \ No newline at end of file diff --git a/common/utils/src/main/resources/base/element/string.json b/common/utils/src/main/resources/base/element/string.json new file mode 100644 index 00000000..bc311734 --- /dev/null +++ b/common/utils/src/main/resources/base/element/string.json @@ -0,0 +1,4 @@ +{ + "string": [ + ] +} \ No newline at end of file diff --git a/entry/.gitignore b/entry/.gitignore deleted file mode 100644 index 7d5b7a94..00000000 --- a/entry/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/build -/node_modules diff --git a/entry/src/main/ets/default/common/baseUtil/SubscriberUtil.ets b/entry/src/main/ets/default/common/baseUtil/SubscriberUtil.ets deleted file mode 100644 index 28811d87..00000000 --- a/entry/src/main/ets/default/common/baseUtil/SubscriberUtil.ets +++ /dev/null @@ -1,99 +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 BrightnessSettingModel from '../../model/brightnessImpl/BrightnessSettingModel.ets'; -import ConfigData from './ConfigData.ets'; -import CommonEvent from '@ohos.commonevent'; - -let mCommonEventSubscribeInfo = { - events: ['BRIGHTNESS_VALUE_SYSTEM_UI','VOLUME_VALUE_SYSTEM_UI'] -}; - -let mCommonEventSubscriber = null; - -/** - * broadcast - */ -export class SubscriberUtils { - /** - * Send broadcast - * - * @param value - value - * @param broadcastName - broadcastName - */ - 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`); - } - - /** - * Register to broadcast - */ - 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) { - console.log(`settings settingList statusSubscriberCallBack data.data ets : ${data.data} `); - let mBrightnessSetValue = AppStorage.SetAndLink('BrightnessSetValue', 150); - mBrightnessSetValue.set(parseInt(data.data)); - BrightnessSettingModel.setBrightnessListener(parseInt(data.data)); - BrightnessSettingModel.setStorageValue(ConfigData.BRIGHTNESS_SAVE_VALUE_KEY,parseInt(data.data)); - } else if ("VOLUME_VALUE_SYSTEM_UI" === data.event) { - console.log(`settings settingList statusSubscriberCallBack data.data volume : ${data.data} `); - let mVolumeSetValue = AppStorage.SetAndLink('VolumeSetValue', 50); - mVolumeSetValue.set(data.data); - } - if (err) { - console.info(`settings settingList statusSubscriberCallBack error : ${err}`) - return; - } - console.log(`settings settingList statusSubscriberCallBack out`); - } - - /** - * unRegister to broadcast - */ - unSubscriberListener() { - CommonEvent.unsubscribe(mCommonEventSubscriber, () => { - console.info('settings settingList unSubscriberListener'); - }); - } -} - -let subscriberUtils = new SubscriberUtils(); -export default subscriberUtils as SubscriberUtils; \ No newline at end of file diff --git a/entry/src/main/ets/default/model/brightnessImpl/BrightnessSettingModel.ets b/entry/src/main/ets/default/model/brightnessImpl/BrightnessSettingModel.ets deleted file mode 100644 index 3fae4f20..00000000 --- a/entry/src/main/ets/default/model/brightnessImpl/BrightnessSettingModel.ets +++ /dev/null @@ -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. - */ -import BaseModel from '../BaseModel.ets'; -import LogUtil from '../../common/baseUtil/LogUtil.ets'; -import ConfigData from '../../common/baseUtil/ConfigData.ets'; -import Brightness from '@ohos.brightness'; -import Storage from '@ohos.data.storage'; - -let mBrightnessPreferences = Storage.getStorageSync(ConfigData.PREFERENCES_PATH); - -/** - * Brightness setting - * - * @param brightnessValue - Brightness value - */ -export class BrightnessSettingModel extends BaseModel { - setBrightnessListener(brightnessValue) { - LogUtil.info('settings settingList BrightnessSettingModel Brightness:' + brightnessValue); - Brightness.setValue(brightnessValue); - LogUtil.info('settings settingList BrightnessSettingModel end'); - } - - /** - * Set up storage data - * - * @param key - key - * @param brightnessValue - value - */ - setStorageValue(key,value) { - LogUtil.info('settings BrightnessSettingModel setStorageValue Storage:' + value); - ConfigData.BRIGHTNESS_SAVE_VALUE_KEY - mBrightnessPreferences.putSync(key, value); - mBrightnessPreferences.flushSync(); - } - - /** - * Get stored data - * - * @param key - key - * @param defaultValue - defaultValue - */ - getStorageValue(key,defaultValue): any { - LogUtil.info('settings BrightnessSettingModel getStorageValue in' + - mBrightnessPreferences.getSync(key, defaultValue)); - return mBrightnessPreferences.getSync(key, defaultValue); - } -} - -let brightnessSettingModel = new BrightnessSettingModel(); -export default brightnessSettingModel as BrightnessSettingModel; \ No newline at end of file diff --git a/entry/src/main/ets/default/model/dateAndTimeImpl/DateAndTimeModel.ets b/entry/src/main/ets/default/model/dateAndTimeImpl/DateAndTimeModel.ets deleted file mode 100644 index 0006a441..00000000 --- a/entry/src/main/ets/default/model/dateAndTimeImpl/DateAndTimeModel.ets +++ /dev/null @@ -1,44 +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'; -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'; -/** - * Set date and time - */ -export class DateAndTimeModel extends BaseModel { - setTime(time) { - LogUtil.info('DateAndTimeModel setTime in :' + time); - 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 -; \ No newline at end of file diff --git a/entry/src/main/ets/default/model/volumeControlImpl/VolumeModel.ets b/entry/src/main/ets/default/model/volumeControlImpl/VolumeModel.ets deleted file mode 100644 index f5c90850..00000000 --- a/entry/src/main/ets/default/model/volumeControlImpl/VolumeModel.ets +++ /dev/null @@ -1,66 +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 LogUtil from '../../common/baseUtil/LogUtil.ets'; -import ConfigData from '../../common/baseUtil/ConfigData.ets'; -import Audio from '@ohos.multimedia.audio'; - -export default class VolumeModel { - constructor() { - } - - setVolume(volumeValue, volumeType){ - LogUtil.info(`settings setVolume volumeValue: ${JSON.stringify(volumeValue)} volumeType:${JSON.stringify(volumeType)} `); - - Audio.getAudioManager().setVolume(volumeType, volumeValue).then(() => { - LogUtil.info('settings Promise returned to indicate a successful volume setting.') - }); - } - - getVolume(callback, volumeType) { - LogUtil.info(`settings getVolume volumeType:${volumeType} `); - Audio.getAudioManager().getVolume(volumeType, (err, value) => { - if (err) { - LogUtil.info(`settings Failed to obtain the volume. ${err.message}`); - return; - } - LogUtil.info('settings Callback invoked to indicate that the volume is obtained.' + value); - callback(value); - }) - } - - getMaxVolume(callback, volumeType) { - LogUtil.info(`settings getMaxVolume volumeType:${volumeType} `); - Audio.getAudioManager().getMaxVolume(volumeType, (err, value) => { - if (err) { - LogUtil.info(`settings Failed to obtain the volume. ${err.message}`); - return; - } - LogUtil.info('settings Callback invoked to indicate that the volume is obtained.' + value); - callback(value); - }) - } - - getMinVolume(callback, volumeType) { - LogUtil.info(`settings getMaxVolume volumeType:${volumeType} `); - Audio.getAudioManager().getMinVolume(volumeType, (err, value) => { - if (err) { - LogUtil.info(`settings Failed to obtain the volume. ${err.message}`); - return; - } - LogUtil.info('settings Callback invoked to indicate that the volume is obtained.' + value); - callback(value); - }) - } -} diff --git a/entry/src/main/ets/default/model/wifiImpl/WifiModel.ets b/entry/src/main/ets/default/model/wifiImpl/WifiModel.ets deleted file mode 100644 index 94ead13f..00000000 --- a/entry/src/main/ets/default/model/wifiImpl/WifiModel.ets +++ /dev/null @@ -1,250 +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 LogUtil from '../../common/baseUtil/LogUtil.ets'; -import WifiNativeJs from '@ohos.wifi_native_js'; -import BaseParseConfModel from '../baseParseConfImpl/BaseParseConfModel.ets'; -import BaseModel from '../BaseModel.ets'; -import BrightnessSettingModel from '../brightnessImpl/BrightnessSettingModel.ets'; - -export class WifiModel extends BaseModel { - private mWifiList: any[] = []; - private remdupWifiList: any[] = []; - private linkedInfoList: any[] = []; - /** - * Get WiFi switch status - */ - getWifiStatus() { - LogUtil.info('WifiNativeJs isWifiActive'); - return WifiNativeJs.isWifiActive(); - } - /** - * WiFi enable - */ - getEnableWifi() { - LogUtil.info('WifiNativeJs enableWifi'); - return WifiNativeJs.enableWifi(); - } - /** - * WiFi disable - */ - disableWifi() { - this.linkedInfoList = []; - LogUtil.info('WifiNativeJs disableWifi'); - return WifiNativeJs.disableWifi(); - } - /** - * Scan WiFi - */ - getScanWifi() { - LogUtil.info('WifiNativeJs scan'); - return WifiNativeJs.scan(); - } - /** - * Get WiFi scan information - */ - getScanInfoCallBack() { - LogUtil.info('get to wifi info start'); - this.mWifiList = []; - this.remdupWifiList = []; - WifiNativeJs.getScanInfos(result => { - LogUtil.info('[wifi_js_test] wifi received scan info call back results1:' + JSON.stringify(result)); - if (result === null) { - return; - } - LogUtil.info('[wifi_js_test] wifi received scan info call back results2:' + 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, - settingBand: result[j].band, - 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]); - } - } - LogUtil.info('get linkedList info before0 :' + JSON.stringify(this.linkedInfoList)); - LogUtil.info('get linkedList info before1 :' + this.linkedInfoList.length); - if (this.linkedInfoList.length === 0) { - LogUtil.info('get linkedList info linkedInfoList empty :'); - } else { - if (this.linkedInfoList[0].settingTitle !== '' && clen > 0) { - LogUtil.info('get linkedList info start :'); - let index = this.getItemPosition(this.remdupWifiList, this.linkedInfoList[0].settingTitle) - let settingTitle = this.linkedInfoList[0].settingTitle; - let settingArrow = this.remdupWifiList[index].settingArrow; - let settingRssi = this.linkedInfoList[0].settingRssi; - let settingBand = this.linkedInfoList[0].settingBand; - let bssid = this.linkedInfoList[0].bssid; - let securityType = this.remdupWifiList[index].securityType; - this.remdupWifiList.splice(index, 1); - this.remdupWifiList.unshift({ - settingSummary: $r('app.string.connected'), - settingTitle: settingTitle, - settingValue: '', - settingArrow: settingArrow, - settingArrowStyle: 'wifi', - settingRssi: settingRssi, - settingBand: settingBand, - bssid: bssid, - securityType: securityType, - }); - } else { - LogUtil.info('get linkedList info linkedInfoList settingTitle is empty :'); - } - } - AppStorage.SetOrCreate('WifiList', this.remdupWifiList); - LogUtil.info('remove duplicate ssid remdupWifiList: ' + JSON.stringify(this.remdupWifiList)); - }); - LogUtil.info('get to wifi information end ---->'); - } - /** - * Gets the subscript of the specified WiFi - * @param list - * @param ssid - */ - getItemPosition(list, ssid) { - for (let i = 0; i < list.length; i++) { - if (ssid === list[i].settingTitle) { - return i; - } - } - return -1; - } - /** - * Connecting equipment - * @param obj - */ - connectToDevice(obj) { - LogUtil.info('[wifi_js_test] connect to wifi'); - return WifiNativeJs.connectToDevice(obj); - } - /** - * Disconnect wifi - */ - disConnect() { - LogUtil.info('netWork disconnect'); - return WifiNativeJs.disConnect(); - } - /** - * Get connected WiFi information - */ - getLinkedInfo() { - this.linkedInfoList = []; - LogUtil.info('[wifi_js] get wifi linked info start'); - WifiNativeJs.getLinkedInfo() - .then(data => { - LogUtil.info("[wifi_js] get wifi linked info [promise] -> " + JSON.stringify(data)); - LogUtil.info("[wifi_js] get wifi linked info [promise] -> " + JSON.stringify(data.ssid)); - LogUtil.info('data result[0].ssid: ' + data.ssid); - LogUtil.info('data rssi: ' + data.rssi); - LogUtil.info('data bssid: ' + data.bssid); - LogUtil.info('data band: ' + data.band); - this.linkedInfoList.push({ - settingSummary: '', - settingTitle: data.ssid, - settingValue: '', - settingArrow: '', - settingRssi: data.rssi, - settingBand: data.band, - bssid: data.bssid, - securityType: '', - signalLevel: WifiNativeJs.getSignalLevel(data.rssi, data.band), - }); - LogUtil.info("[wifi_js] get wifi linked info linkedInfoList 1" + JSON.stringify(this.linkedInfoList)) - AppStorage.SetOrCreate('linkedInfoList', this.linkedInfoList); - LogUtil.info("[wifi_js] get wifi linked info linkedInfoList 2" + JSON.stringify(this.linkedInfoList)) - }) - .catch(error => { - LogUtil.info("[wifi_js] linked info promise then error" + error); - }) - LogUtil.info('[wifi_js] get wifi linked info end'); - } -} - -let wifiModel = new WifiModel(); -export default wifiModel as WifiModel -; \ No newline at end of file diff --git a/entry/src/main/ets/default/pages/applicationInfo.ets b/entry/src/main/ets/default/pages/applicationInfo.ets deleted file mode 100644 index 3e08b552..00000000 --- a/entry/src/main/ets/default/pages/applicationInfo.ets +++ /dev/null @@ -1,56 +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 LogUtil from '../common/baseUtil/LogUtil.ets'; -import EntryComponent from './component/entryComponent.ets'; -import HeadComponent from './component/headComponent.ets'; -import Router from '@system.router' - -let appInfo; - -/** - * application details - */ -@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: '', - settingUri: appInfo.settingUri - }); - } - } - } - - 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'); - } -} \ No newline at end of file diff --git a/entry/src/main/ets/default/pages/brightnessSettings.ets b/entry/src/main/ets/default/pages/brightnessSettings.ets deleted file mode 100644 index c95d1124..00000000 --- a/entry/src/main/ets/default/pages/brightnessSettings.ets +++ /dev/null @@ -1,89 +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 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 = 255; -const BRIGHTNESS_STEP_VALUE = 10; -const SENT_EVENT_IN_BRIGHTNESS_PAGES = '-1'; - -/** - * brightness setting - */ -@Entry -@Component -struct BrightnessSettings { - @StorageLink('BrightnessSetValue') bright: number= 150; - - 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) => { - this.bright = Math.round(number); - BrightnessSettingModel.setBrightnessListener(this.bright); - BrightnessSettingModel.setStorageValue(ConfigData.BRIGHTNESS_SAVE_VALUE_KEY, 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(ConfigData.BRIGHTNESS_SAVE_VALUE_KEY, - ConfigData.BRIGHTNESS_DEFAULT_VALUE); - SubscriberUtils.sendEvent(SENT_EVENT_IN_BRIGHTNESS_PAGES, ConfigData.SENT_EVENT_BROADCAST_BRIGHTNESS_VALUE); - 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'); - } -} \ No newline at end of file diff --git a/entry/src/main/ets/default/pages/component/switchComponent.ets b/entry/src/main/ets/default/pages/component/switchComponent.ets deleted file mode 100644 index ab3677d9..00000000 --- a/entry/src/main/ets/default/pages/component/switchComponent.ets +++ /dev/null @@ -1,44 +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 ConfigData from '../../common/baseUtil/ConfigData.ets'; - -/** - * Toggle component - */ -@Component -export default -struct SwitchComponent { - private isOn: boolean= false; - private title: ''; - - build() { - Row() { - Text(this.title) - .fontSize($r('app.float.font_20')) - .fontColor(Color.Black) - .align(Alignment.Start) - - Toggle({ type: ToggleType.Switch, isOn: false }) - .align(Alignment.End) - .width($r('app.float.wh_value_60')) - .height($r('app.float.wh_value_40')) - - } - .width(ConfigData.WH_100_100) - .height($r('app.float.wh_value_70')) - .alignItems(VerticalAlign.Center) - .padding({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }) - } -} \ No newline at end of file diff --git a/entry/src/main/ets/default/pages/volumeControl.ets b/entry/src/main/ets/default/pages/volumeControl.ets deleted file mode 100644 index 69968c25..00000000 --- a/entry/src/main/ets/default/pages/volumeControl.ets +++ /dev/null @@ -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 VolumeModel from '../model/volumeControlImpl/VolumeModel.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'; -import Audio from '@ohos.multimedia.audio'; - -const VOLUME_TYPE = Audio.AudioVolumeType.MEDIA; -const SENT_EVENT_IN_VOLUME_PAGES = '-1'; - -@Entry -@Component -export -struct VolumeControl { - @State minVol: number = 0; - @State maxVol: number = 10; - @StorageLink('VolumeSetValue') currentVol: number = 0; - private audioManager = Audio.getAudioManager(); - private volumeModel = new VolumeModel(); - - initVolume() { - this.volumeModel.getMaxVolume(this.getMaxVolumeCallback.bind(this), VOLUME_TYPE); - this.volumeModel.getMinVolume(this.getMinVolumeCallback.bind(this), VOLUME_TYPE); - this.volumeModel.getVolume(this.getCurrentVolumeCallback.bind(this), VOLUME_TYPE); - } - - getMinVolumeCallback(val) { - this.minVol = val; - LogUtil.info(`settings getMinVolumeCallback ${this.minVol} `); - } - - getMaxVolumeCallback(val) { - this.maxVol = val; - LogUtil.info(`settings getMaxVolumeCallback ${this.maxVol} `); - } - - getCurrentVolumeCallback(val) { - this.currentVol = val; - LogUtil.info(`settings getCurrentVolumeCallback ${this.currentVol} `); - } - - setVolume(volumeValue, volumeType) { - LogUtil.info(`settings setVolume = ${volumeValue} Type = ${volumeType}`) - Audio.getAudioManager().setVolume(volumeType, volumeValue).then(() => { - this.currentVol = volumeValue; - LogUtil.info('settings Promise returned to indicate a successful volume setting') - }) - } - - aboutToAppear() { - LogUtil.info('settings Start init Volume!') - this.initVolume() - SubscriberUtils.sendEvent(SENT_EVENT_IN_VOLUME_PAGES, ConfigData.SENT_EVENT_BROADCAST_VOLUME_VALUE); - SubscriberUtils.registerStatusListener(); - LogUtil.info('settings Finished init Volume!') - } - - build() { - Column() { - HeadComponent({ headName: $r('app.string.volumeControl'), isActive: true }); - Row() { - Slider({ - value: this.currentVol, - min: this.minVol, - max: this.maxVol, - step: 1, - style: SliderStyle.INSET - }) - .size({ width: 300 }) - .width('100%') - .blockColor(Color.Blue) - .trackColor(Color.Grey) - .selectedColor(Color.Blue) - .onChange((value: number) => { - this.setVolume(value, VOLUME_TYPE) - }) - } - .padding({ - left: $r('app.float.wh_value_15'), - right: $r('app.float.wh_value_15') - }); - } - .width('85%') - .align(Alignment.Center) - .width(ConfigData.WH_100_100) - .height(ConfigData.WH_100_100); - } -} diff --git a/entry/src/main/ets/default/pages/wifi.ets b/entry/src/main/ets/default/pages/wifi.ets deleted file mode 100644 index c7730af1..00000000 --- a/entry/src/main/ets/default/pages/wifi.ets +++ /dev/null @@ -1,381 +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 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 BrightnessSettingModel from '../model/brightnessImpl/BrightnessSettingModel.ets'; -import Subscriber from '@ohos.commonevent'; -import router from '@system.router'; - - -@Entry -@Component -struct Index { - @StorageLink('WifiList') wifiList: any[] = []; - @StorageLink('wifiPsd') password: string = ''; - private isOn: boolean = true; - @State isShow: boolean = true; - private connectPsd: string = ''; - private mIndex: number = -1; - private timeoutFlag; - private timeoutMark; - private intervalFlag; - @State connectRssi: number = -1; - @State connectBand: number = -1; - @State connectImage: string = ''; - @State connectName: string = ''; - @State connectBssid: string = ''; - @State connectSecurityType: number = -1; - private mCommonEventSubscriber = null; - private wifiIsFirstConnect: boolean = false; - private mCommonEventSubscribeInfo = { - events: ["usual.event.wifi.CONN_STATE"] - }; - build() { - Column() { - HeadComponent({ headName: $r('app.string.wifiTab'), isActive: true }); - Flex({ justifyContent: FlexAlign.SpaceBetween }) { - Row() { - Text($r('app.string.wifiTab')) - .fontSize($r('app.float.font_22')) - .fontColor(Color.Black) - .textAlign(TextAlign.Start); - }.alignItems(VerticalAlign.Center); - Toggle({ type: ToggleType.Switch, isOn: this.isOn }) - .width($r('app.float.wh_value_50')) - .height($r('app.float.wh_value_40')) - .onChange((isOn: boolean) => { - this.isOn = !this.isOn; - LogUtil.info('Toggle onChange this.isOn:' + this.isOn); - if (this.isOn) { - this.switchOn(); - } else { - this.switchOff(); - } - }); - } - .height($r('app.float.wh_value_70')) - .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }); - Flex({ alignItems: ItemAlign.Start }) { - Text($r('app.string.tipsContent')) - .fontSize($r('app.float.font_20')); - } - .visibility(this.isOn ? Visibility.None : Visibility.Visible) - .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }); - Column() { - Flex({ justifyContent: FlexAlign.SpaceBetween }) { - Text($r('app.string.wifiList')) - .fontSize($r('app.float.font_24')) - .align(Alignment.Start); - Row() { - ImageAnimatorComponent({ imageWidth: $r('app.float.wh_value_40'), - imageHeight: $r('app.float.wh_value_40') }) - } - .width($r('app.float.wh_value_40')) - .visibility(this.isShow ? Visibility.Visible : Visibility.None); - } - .width(ConfigData.WH_100_100) - .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }); - List() { - ForEach(this.wifiList, (item) => { - ListItem() { - EntryComponent({ - settingIcon: '', - settingTitle: item.settingTitle, - settingSummary: item.settingSummary, - settingValue: '', - settingArrow: item.settingArrow, - settingArrowStyle: 'wifi', - settingUri: '' - }); - }.onClick(() => { - this.connectName = item.settingTitle - this.connectImage = item.settingArrow - this.connectBssid = item.bssid - this.connectSecurityType = item.securityType - this.connectRssi = item.settingRssi - this.connectBand = item.settingBand - this.connectWifi(); - }) - .height($r('app.float.wh_value_60')) - }, item => JSON.stringify(item)); - } - .divider({ - strokeWidth: $r('app.float.wh_value_1'), - color: $r('app.color.color_E3E3E3_grey'), - startMargin: $r('app.float.wh_value_15'), - endMargin: $r('app.float.wh_value_15') - }) - .width(ConfigData.WH_100_100) - .margin({top:$r('app.float.wh_value_20')}); - } - .width(ConfigData.WH_100_100) - .margin({bottom:$r('app.float.wh_value_20')}) - .layoutWeight(1) - .visibility(this.isOn ? Visibility.Visible : Visibility.None); - } - .width(ConfigData.WH_100_100) - .height(ConfigData.WH_100_100) - } - - aboutToAppear(): void { - LogUtil.info('init wifi get in'); - 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; - AppStorage.SetOrCreate('WifiList', []); - clearTimeout(this.timeoutFlag); - clearTimeout(that.timeoutMark); - LogUtil.info('init wifi wifiList' + this.wifiList); - }, 3000); - } else { - LogUtil.info('init scan wifiList fail'); - } - }, 5000); - } else { - LogUtil.info('init wifi isOn is false'); - } - } - /** - * Connect WiFi - */ - 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 - } - - 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'); - return; - } - 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:'); - } - /** - * Get switch status - */ - getSwitchStatus() { - if (WifiModel.getWifiStatus()) { - this.isOn = true; - } else { - this.isOn = false; - } - } - /** - * delay time - * @param delay - */ - private sleep(delay) { - let start = (new Date()).getTime(); - while ((new Date()).getTime() - start < delay) { - continue; - } - } - /** - * The switch is on - */ - private switchOn() { - LogUtil.info('switchClick wifi start ---->'); - if(this.wifiList.length > 0){ - console.info('come on one'); - return; - } - LogUtil.info('switchClick wifi start 1---->'); - this.clearScanInfo(); - this.isShow = true; - this.sleep(2000); - 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 ---->'); - } - }, 5000); - } else { - LogUtil.info('switchClick wifi fail to enableWifi ---->'); - } - } - /** - * The switch is off - */ - private switchOff() { - LogUtil.info('switchClick wifi off start ---->'); - if (WifiModel.disableWifi()) { - LogUtil.info('switchClick wifi enter to disableWifi ---->'); - AppStorage.SetOrCreate('WifiList', []); - BrightnessSettingModel.setStorageValue('wifiConnectName', ''); - this.clearScanInfo(); - } else { - LogUtil.info('switchClick wifi off end ---->'); - } - } - /** - * WiFi status monitoring - */ - 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); - LogUtil.info('SubscriberCallBack this.wifiList:' + JSON.stringify(this.wifiList)); - if (this.connectName !== '' && (data.code === 1 || data.code === 3 || data.code === 4)) { - let wifi = { 'name': '', 'rssi': -1, 'band': -1 }; - wifi.name = this.connectName; - wifi.rssi = this.connectRssi; - wifi.band = this.connectBand; - SubscriberUtils.sendEvent(JSON.stringify(wifi), ConfigData.SENT_EVENT_WIFI_CONNECT_NAME); - BrightnessSettingModel.setStorageValue('wifiConnectName', this.connectName); - let index = WifiModel.getItemPosition(this.wifiList, this.connectName); - LogUtil.info('subscriber connected -1:' + JSON.stringify(this.wifiList)); - this.wifiList.splice(index, 1); - LogUtil.info('subscriber connected 0:' + JSON.stringify(this.wifiList)); - this.wifiList.unshift({ - settingSummary: $r('app.string.connected'), - settingTitle: this.connectName, - settingValue: '', - settingArrow: this.connectImage, - settingArrowStyle: 'wifi', - settingRssi: this.connectRssi, - settingBand: this.connectBand, - bssid: this.connectBssid, - securityType: this.connectSecurityType, - }); - LogUtil.info('subscriber connected 1:' + JSON.stringify(this.wifiList)); - this.wifiList[1].settingSummary = ''; - LogUtil.info('subscriber connected 2' + JSON.stringify(this.wifiList)); - } - - if (data.code === 7) { - BrightnessSettingModel.setStorageValue('wifiConnectName', ''); - } - if (data.code === 8) { - this.connectPsd = ''; - AppStorage.SetOrCreate('wifiPsd', ''); - } - 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); - } - } - /** - * Cancel WiFi status listening - */ - unSubscriberListener() { - Subscriber.unsubscribe(this.mCommonEventSubscriber, () => { - LogUtil.info('wifi unsubscribe'); - }); - } - /** - * Clear scan information - */ - clearScanInfo() { - LogUtil.info('clear scan wifiList start---->'); - this.wifiList = []; - LogUtil.info('clear scan wifiList end---->'); - } - - private aboutToDisappear(): void { - AppStorage.SetOrCreate('wifiPsd', ''); - - this.unSubscriberListener; - this.connectPsd = ''; - } - - onPageShow() { - LogUtil.info('wifi onPageShow this.password:' + this.password); - this.connectPsd = this.password; - if (this.connectPsd !== '') { - this.connectWifi(); - } - } - - onBackPress() { - AppStorage.SetOrCreate('wifiPsd', ''); - Navigator().active(true); - } -} - - - - diff --git a/entry/src/main/ets/default/pages/wifiPsd.ets b/entry/src/main/ets/default/pages/wifiPsd.ets deleted file mode 100644 index 6044a09e..00000000 --- a/entry/src/main/ets/default/pages/wifiPsd.ets +++ /dev/null @@ -1,115 +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 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 = ''; - -let name; -let title; - -/** - * wifi password setting page - */ -@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, family: "sans-serif", style: FontStyle.Normal }) - .caretColor(Color.Blue) - .height($r('app.float.wh_value_70')) - .backgroundColor(Color.White) - .type(InputType.Password) - .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'); - } -} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json deleted file mode 100644 index 6f8d0c20..00000000 --- a/entry/src/main/resources/base/element/float.json +++ /dev/null @@ -1,124 +0,0 @@ -{ - "float": [ - { - "name": "wh_value_1", - "value": "1" - }, - { - "name": "wh_value_5", - "value": "5" - }, - { - "name": "wh_value_10", - "value": "10" - }, - { - "name": "wh_value_15", - "value": "15" - }, - { - "name": "wh_value_20", - "value": "20" - }, - { - "name": "wh_value_30", - "value": "30" - }, - { - "name": "wh_value_40", - "value": "40" - }, - { - "name": "wh_value_50", - "value": "50" - }, - { - "name": "wh_value_60", - "value": "60" - }, - { - "name": "wh_value_65", - "value": "65" - }, - { - "name": "wh_value_70", - "value": "70" - }, - { - "name": "wh_value_80", - "value": "80" - }, - { - "name": "wh_value_100", - "value": "100" - }, - { - "name": "wh_value_130", - "value": "1300" - }, - { - "name": "wh_value_160", - "value": "160" - }, - { - "name": "wh_value_230", - "value": "230" - }, - { - "name": "wh_value_280", - "value": "280" - }, - { - "name": "wh_value_390", - "value": "390" - }, - { - "name": "wh_value_400", - "value": "400" - }, - { - "name": "font_35", - "value": "35" - }, - { - "name": "font_18", - "value": "18" - }, - { - "name": "font_20", - "value": "20" - }, - { - "name": "font_21", - "value": "21" - }, - { - "name": "font_22", - "value": "22" - }, - { - "name": "font_24", - "value": "24" - }, - { - "name": "font_28", - "value": "28" - }, - { - "name": "font_50", - "value": "50" - }, - { - "name": "control_common_font_size", - "value": "20" - }, - { - "name": "slider_text_padding_left", - "value": "5" - }, - { - "name": "volume_border_radius", - "value": "15" - } - ] -} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json deleted file mode 100755 index a255df44..00000000 --- a/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,160 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "设置" - }, - { - "name": "mainability_description", - "value": "ETS_Empty Feature Ability" - }, - { - "name": "enabled", - "value": "已开启" - }, - { - "name": "disabled", - "value": "已关闭" - }, - { - "name": "settings", - "value": "设置" - }, - { - "name": "wifiTab", - "value": "WLAN" - }, - { - "name": "brightnessTab", - "value": "亮度" - }, - { - "name": "applyTab", - "value": "应用" - }, - { - "name": "dateAndTimeTab", - "value": "日期和时间" - }, - { - "name": "aboutTab", - "value": "关于手机" - }, - { - "name": "volumeControlTab", - "value": "音量调节" - }, - { - "name": "volumeControl", - "value": "音量" - }, - { - "name": "applicationInfo", - "value": "应用信息" - }, - { - "name": "appManagement", - "value": "应用管理" - }, - { - "name": "cancel", - "value": "取消" - }, - { - "name": "confirm", - "value": "确定" - }, - { - "name": "wifiPassword", - "value": "密码" - }, - { - "name": "date", - "value": "日期" - }, - { - "name": "time", - "value": "时间" - }, - { - "name": "year", - "value": "年" - }, - { - "name": "month", - "value": "月" - }, - { - "name": "day", - "value": "日" - }, - { - "name": "tipsContent", - "value": "为提高位置信息的精确度,应用和服务仍然会扫描WLAN网络.您可以在提高精确度中更改此设置" - }, - { - "name": "wifiList", - "value": "可用WLAN列表" - }, - { - "name": "systemName", - "value": "系统名称" - }, - { - "name": "model", - "value": "型号" - }, - { - "name": "companyInfo", - "value": "厂家信息" - }, - { - "name": "deviceId", - "value": "设备" - }, - { - "name": "softwareVersion", - "value": "软件版本" - }, - { - "name": "version", - "value": "版本 " - }, - { - "name": "password", - "value": "密码" - }, - { - "name": "connected", - "value": "已连接" - }, - { - "name": "monday", - "value": "星期一" - }, - { - "name": "tuesday", - "value": "星期二" - }, - { - "name": "wednesday", - "value": "星期三" - }, - { - "name": "thursday", - "value": "星期四" - }, - { - "name": "friday", - "value": "星期五" - }, - { - "name": "saturday", - "value": "星期六" - }, - { - "name": "sunday", - "value": "星期日" - } - ] -} \ No newline at end of file diff --git a/entry/src/main/resources/en_AS/element/string.json b/entry/src/main/resources/en_AS/element/string.json deleted file mode 100644 index 0774f454..00000000 --- a/entry/src/main/resources/en_AS/element/string.json +++ /dev/null @@ -1,156 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "设置" - }, - { - "name": "mainability_description", - "value": "ETS_Empty Feature Ability" - }, - { - "name": "enabled", - "value": "Enabled" - }, - { - "name": "disabled", - "value": "Disabled" - }, - { - "name": "settings", - "value": "Settings" - }, - { - "name": "wifiTab", - "value": "WLANTab" - }, - { - "name": "brightnessTab", - "value": "brightnessTab" - }, - { - "name": "volumeControl", - "value": "volumeControl" - }, - { - "name": "volumeControlTab", - "value": "volumeControlTab" - }, - { - "name": "applyTab", - "value": "applyTab" - }, - { - "name": "dateAndTimeTab", - "value": "dateAndTimeTab" - }, - { - "name": "aboutTab", - "value": "aboutTab" - }, - { - "name": "applicationInfo", - "value": "App info" - }, - { - "name": "appManagement", - "value": "Apps" - }, - { - "name": "cancel", - "value": "Cancel" - }, - { - "name": "confirm", - "value": "Confirm" - }, - { - "name": "wifiPassword", - "value": "Password" - }, - { - "name": "date", - "value": "Date" - }, - { - "name": "time", - "value": "Time" - }, - { - "name": "year", - "value": "year" - }, - { - "name": "month", - "value": "month" - }, - { - "name": "day", - "value": "date" - }, - { - "name": "wifiList", - "value": "WLAN-List which can be used" - }, - { - "name": "systemName", - "value": "SystemName" - }, - { - "name": "model", - "value": "Model" - }, - { - "name": "companyInfo", - "value": "CompanyInfo" - }, - { - "name": "deviceId", - "value": "DeviceId" - }, - { - "name": "softwareVersion", - "value": "SoftwareVersion" - }, - { - "name": "version", - "value": "version " - }, - { - "name": "password", - "value": "password" - }, - { - "name": "connected", - "value": "connected" - }, - { - "name": "monday", - "value": "monday" - }, - { - "name": "tuesday", - "value": "tuesday" - }, - { - "name": "wednesday", - "value": "wednesday" - }, - { - "name": "thursday", - "value": "thursday" - }, - { - "name": "friday", - "value": "friday" - }, - { - "name": "saturday", - "value": "saturday" - }, - { - "name": "sunday", - "value": "sunday" - } - ] -} \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/settinglist.json b/entry/src/main/resources/rawfile/settinglist.json deleted file mode 100755 index 784938ca..00000000 --- a/entry/src/main/resources/rawfile/settinglist.json +++ /dev/null @@ -1,55 +0,0 @@ -[ - { - "settingIcon": "/res/image/ic_settings_wifi.svg", - "settingTitle": "WLAN", - "settingAlias": "wifiTab", - "settingValue": "", - "settingArrow": "/res/image/ic_settings_arrow.svg", - "settingSummary": "", - "settingUri": "pages/wifi" - },{ - "settingIcon": "/res/image/ic_settings_display.svg", - "settingTitle": "", - "settingAlias": "brightnessTab", - "settingValue": "", - "settingArrow": "/res/image/ic_settings_arrow.svg", - "settingSummary": "", - "settingUri": "pages/brightnessSettings" -}, - { - "settingIcon": "res/image/ic_settings_applications.svg", - "settingTitle": "", - "settingAlias": "applyTab", - "settingValue": "", - "settingArrow": "res/image/ic_settings_arrow.svg", - "settingSummary": "", - "settingUri": "pages/appManagement" - }, - { - "settingIcon": "/res/image/ic_settings_advanced.svg", - "settingTitle": "", - "settingAlias": "dateAndTimeTab", - "settingValue": "", - "settingArrow": "/res/image/ic_settings_arrow.svg", - "settingSummary": "", - "settingUri": "pages/dateAndTime" - }, - { - "settingIcon": "/res/image/ic_settings_about.svg", - "settingTitle": "", - "settingAlias": "aboutTab", - "settingValue": "", - "settingArrow": "/res/image/ic_settings_arrow.svg", - "settingSummary": "", - "settingUri": "pages/aboutDevice" - }, - { - "settingIcon": "/res/image/ic_settings_volume.svg", - "settingTitle": "", - "settingAlias": "volumeControlTab", - "settingValue": "", - "settingArrow": "/res/image/ic_settings_arrow.svg", - "settingSummary": "", - "settingUri": "pages/volumeControl" - } -] diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json deleted file mode 100644 index 2e771d47..00000000 --- a/entry/src/main/resources/zh_CN/element/string.json +++ /dev/null @@ -1,160 +0,0 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "设置" - }, - { - "name": "mainability_description", - "value": "ETS_Empty Feature Ability" - }, - { - "name": "enabled", - "value": "已开启" - }, - { - "name": "disabled", - "value": "已关闭" - }, - { - "name": "settings", - "value": "设置" - }, - { - "name": "wifiTab", - "value": "WLAN" - }, - { - "name": "brightnessTab", - "value": "亮度" - }, - { - "name": "applyTab", - "value": "应用" - }, - { - "name": "dateAndTimeTab", - "value": "日期和时间" - }, - { - "name": "aboutTab", - "value": "关于手机" - }, - { - "name": "volumeControlTab", - "value": "音量调节" - }, - { - "name": "volumeControl", - "value": "音量" - }, - { - "name": "applicationInfo", - "value": "应用信息" - }, - { - "name": "appManagement", - "value": "应用管理" - }, - { - "name": "cancel", - "value": "取消" - }, - { - "name": "confirm", - "value": "确定" - }, - { - "name": "wifiPassword", - "value": "密码" - }, - { - "name": "date", - "value": "日期" - }, - { - "name": "time", - "value": "时间" - }, - { - "name": "year", - "value": "年" - }, - { - "name": "month", - "value": "月" - }, - { - "name": "day", - "value": "日" - }, - { - "name": "tipsContent", - "value": "为提高位置信息的精确度,应用和服务仍然会扫描WLAN网络.您可以在提高精确度中更改此设置" - }, - { - "name": "wifiList", - "value": "可用WLAN列表" - }, - { - "name": "systemName", - "value": "系统名称" - }, - { - "name": "model", - "value": "型号" - }, - { - "name": "companyInfo", - "value": "厂家信息" - }, - { - "name": "deviceId", - "value": "设备" - }, - { - "name": "softwareVersion", - "value": "软件版本" - }, - { - "name": "version", - "value": "版本 " - }, - { - "name": "password", - "value": "密码" - }, - { - "name": "connected", - "value": "已连接" - }, - { - "name": "monday", - "value": "星期一" - }, - { - "name": "tuesday", - "value": "星期二" - }, - { - "name": "wednesday", - "value": "星期三" - }, - { - "name": "thursday", - "value": "星期四" - }, - { - "name": "friday", - "value": "星期五" - }, - { - "name": "saturday", - "value": "星期六" - }, - { - "name": "sunday", - "value": "星期日" - } - ] -} \ No newline at end of file diff --git a/figures/hw_register.png b/figures/hw_register.png deleted file mode 100644 index 472d0bab..00000000 Binary files a/figures/hw_register.png and /dev/null differ diff --git a/entry/build.gradle b/product/phone/build.gradle old mode 100755 new mode 100644 similarity index 87% rename from entry/build.gradle rename to product/phone/build.gradle index ff4410f4..bb029b4c --- a/entry/build.gradle +++ b/product/phone/build.gradle @@ -1,13 +1,13 @@ -apply plugin: 'com.huawei.ohos.hap' -ohos { - compileSdkVersion 7 - defaultConfig { - compatibleSdkVersion 6 - } - arkEnabled false -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - testCompile 'junit:junit:4.12' +apply plugin: 'com.huawei.ohos.hap' +ohos { + compileSdkVersion 7 + defaultConfig { + compatibleSdkVersion 6 + } + arkEnabled true +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) + testCompile 'junit:junit:4.12' } \ No newline at end of file diff --git a/product/phone/proguard-rules.pro b/product/phone/proguard-rules.pro new file mode 100644 index 00000000..f7666e47 --- /dev/null +++ b/product/phone/proguard-rules.pro @@ -0,0 +1 @@ +# config module specific ProGuard rules here. \ No newline at end of file diff --git a/product/phone/src/main/config.json b/product/phone/src/main/config.json new file mode 100644 index 00000000..430a10a9 --- /dev/null +++ b/product/phone/src/main/config.json @@ -0,0 +1,107 @@ +{ + "app": { + "bundleName": "com.ohos.settings", + "vendor": "ohos", + "version": { + "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": "phone", + "moduleType": "entry", + "installationFree": true + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": "com.ohos.settings.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard", + "srcPath": "default", + "srcLanguage": "ets", + "metaData": { + "customizeData": [ + { + "name": "hwc-theme" + } + ] + } + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/settingList", + "pages/searchPage", + "pages/dateAndTime", + "pages/application", + "pages/applicationInfo", + "pages/applicationStorage", + "pages/brightnessSettings", + "pages/aboutDevice", + "pages/appManagement", + "pages/wifi", + "pages/wifiPsd", + "pages/volumeControl", + "pages/developerOptions", + "pages/restoreFactorySettings", + "pages/usersAccounts", + "pages/multipleUsers", + "pages/system/homePage", + "pages/system/languageSettings/homePage", + "pages/system/languageSettings/languageAndRegion/homePage", + "pages/system/languageSettings/languageAndRegion/addLanguage", + "pages/system/languageSettings/languageAndRegion/editLanguage", + "pages/system/languageSettings/languageAndRegion/selectRegion", + "pages/storage", + "pages/locationServices", + "pages/privacy", + "pages/passwordSetting", + "pages/passwordCheck", + "pages/passwordInput", + "pages/passwordRepeat" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS" + }, + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC" + } + ] + } +} \ No newline at end of file diff --git a/entry/src/main/ets/default/app.ets b/product/phone/src/main/ets/default/app.ets similarity index 100% rename from entry/src/main/ets/default/app.ets rename to product/phone/src/main/ets/default/app.ets diff --git a/product/phone/src/main/ets/default/controller/application/ApplicationInfoController.ets b/product/phone/src/main/ets/default/controller/application/ApplicationInfoController.ets new file mode 100644 index 00000000..dafae4f0 --- /dev/null +++ b/product/phone/src/main/ets/default/controller/application/ApplicationInfoController.ets @@ -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 {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import AppManagementModel from '../../model/appManagementImpl/AppManagementModel.ets'; +import BaseSettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/BaseSettingsController.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; + +@LogAll +export default class ApplicationInfoController extends BaseSettingsController { + + /** + * Get Uninstall api + */ + uninstall(bundleName: string) { + AppManagementModel.uninstall(bundleName, (err) => { + LogUtil.info(ConfigData.TAG + 'uninstall err : ' + JSON.stringify(err) + 'bundleName:' + bundleName); + }); + } + + /** + * Kill processes by bundle name + */ + killProcessesByBundleName(bundleName: string) { + AppManagementModel.killProcessesByBundleName(bundleName, (err) => { + LogUtil.info(ConfigData.TAG + 'killProcessesByBundleName err : ' + JSON.stringify(err) + 'bundleName:' + bundleName); + }); + } +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/controller/application/ApplicationStorageController.ets b/product/phone/src/main/ets/default/controller/application/ApplicationStorageController.ets new file mode 100644 index 00000000..03ca74d6 --- /dev/null +++ b/product/phone/src/main/ets/default/controller/application/ApplicationStorageController.ets @@ -0,0 +1,51 @@ +/** + * 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 {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import AppManagementModel from '../../model/appManagementImpl/AppManagementModel.ets'; +import BaseSettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/BaseSettingsController.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; + +@LogAll +export default class ApplicationStorageController extends BaseSettingsController { + + /** + * Clear up application data by bundle name + * @param bundleName bundle name + */ + clearUpApplicationData(bundleName: string) { + AppManagementModel.clearUpApplicationData(bundleName, (err) => { + LogUtil.info(ConfigData.TAG + 'clearUpApplicationData err : ' + JSON.stringify(err) + 'bundleName:' + bundleName); + }); + } + + /** + * Clears cache data of a specified application + * @param bundleName bundle name + */ + cleanBundleCacheFiles(bundleName: string) { + AppManagementModel.cleanBundleCacheFiles(bundleName, (err) => { + LogUtil.info(ConfigData.TAG + 'cleanBundleCacheFiles err : ' + JSON.stringify(err) + 'bundleName:' + bundleName); + }); + } + + /** + * Get storageList + */ + getStorageList() { + return AppManagementModel.getStorageList(); + } +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/controller/developerOptions/UsbDebuggingController.ets b/product/phone/src/main/ets/default/controller/developerOptions/UsbDebuggingController.ets new file mode 100644 index 00000000..3a71d8e2 --- /dev/null +++ b/product/phone/src/main/ets/default/controller/developerOptions/UsbDebuggingController.ets @@ -0,0 +1,49 @@ +/** + * 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/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import DeveloperOptionsModel from '../../model/developerOptionsImpl/DeveloperOptionsModel.ets' +import ISettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/ISettingsController' +import SwitchController from '../../../../../../../../common/component/src/main/ets/default/controller/SwitchController.ets' +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; + +@LogAll +export default class UsbDebuggingController extends SwitchController { + /** + * Initialize data. + */ + initData(): ISettingsController { + super.initData(); + // usb current state + let state = new Boolean(this.getUsbCurrentFunctions() & ConfigData.FUNCTION_TYPE_HDC).valueOf(); + this.isOn = state; + LogUtil.info(ConfigData.TAG + `initData isOn:` + this.isOn); + return this; + } + + /** + * Get usb current functions state + */ + getUsbCurrentFunctions() { + return DeveloperOptionsModel.getUsbCurrentFunctions(); + } + + /** + * After current value changed event + */ + afterCurrentValueChanged() { + DeveloperOptionsModel.setCurrentFunctions(this.isOn); + } +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/controller/locationServices/LocationServicesController.ets b/product/phone/src/main/ets/default/controller/locationServices/LocationServicesController.ets new file mode 100644 index 00000000..f287734f --- /dev/null +++ b/product/phone/src/main/ets/default/controller/locationServices/LocationServicesController.ets @@ -0,0 +1,101 @@ +/** + * 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 LocationServicesModel from '../../model/locationServicesImpl/LocationServicesModel.ets' +import ISettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/ISettingsController' +import {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import SwitchController from '../../../../../../../../common/component/src/main/ets/default/controller/SwitchController.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; + +@LogAll +export default class LocationServicesController extends SwitchController { + + /** + * Initialize data. + */ + initData(): ISettingsController { + super.initData(); + this.isLocationEnabled((err, value) => { + if (err) { + LogUtil.info(ConfigData.TAG + 'initData -> isLocationEnabled err:' + JSON.stringify(err)); + this.isOn = false; + } else { + this.isOn = value; + } + }) + return this; + } + + /** + * obtain current location switch status + */ + isLocationEnabled(callback) { + LocationServicesModel.isLocationEnabled(callback); + } + + /** + * subscribe location switch changed + */ + subscribe(): ISettingsController { + LocationServicesModel.onLocationServiceState((value) => { + this.isOn = value; + }) + return this; + } + + /** + * unsubscribe location switch changed + */ + unsubscribe(): ISettingsController { + LocationServicesModel.offLocationServiceState((value) => { + this.isOn = value; + }) + return this; + } + + afterCurrentValueChanged() { + if (this.isOn) { + LocationServicesModel.enableLocation((err, data) => { + LogUtil.info(ConfigData.TAG + 'afterCurrentValueChanged -> enableLocation err:' + JSON.stringify(err) + ',data:' + JSON.stringify(data)); + this.location(err, true); + }) + } else { + LocationServicesModel.disableLocation((err, data) => { + LogUtil.info(ConfigData.TAG + 'afterCurrentValueChanged -> disableLocation err:' + JSON.stringify(err) + ',data:' + JSON.stringify(data)); + this.location(err, false); + }) + } + } + + /** + * location switch + */ + location(err, data) { + if (err) { + this.isLocationEnabled((err, value) => { + if (err) { + LogUtil.info(ConfigData.TAG + 'afterCurrentValueChanged -> isLocationEnabled err:' + JSON.stringify(err)); + if (this.isOn) { + this.isOn = false; + } + } else { + this.isOn = value; + } + }) + } else { + this.isOn = data; + } + } +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/controller/password/PasswordCheckController.ets b/product/phone/src/main/ets/default/controller/password/PasswordCheckController.ets new file mode 100644 index 00000000..a78aad2d --- /dev/null +++ b/product/phone/src/main/ets/default/controller/password/PasswordCheckController.ets @@ -0,0 +1,259 @@ +/** + * 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 BaseSettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/BaseSettingsController.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import ISettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/ISettingsController'; +import PasswordModel, {ResultCode, PinSubType} from '../../model/passwordImpl/PasswordModel.ets'; +import Router from '@system.router'; +import prompt from '@system.prompt'; + +@LogAll +export default class PasswordCheckController extends BaseSettingsController { + private TAG = ConfigData.TAG + 'PasswordCheckController '; + private pageRequestCode: number = -1 + private prevPageUri: string = undefined + private pinChallenge: string = undefined + private pinToken: string = undefined + private passwordType: number = -1 + private freezingTime: number = 0 + private remainTimes: number = 0; + private lockUi: boolean = false + private authOk = false; + +// private Properties + private password: string = '' + + initData(): ISettingsController { + this.loadData() + return this + } + + subscribe(): ISettingsController { + PasswordModel.registerInputer(); + return this; + }; + + unsubscribe(): ISettingsController { + PasswordModel.unregisterInputer(); + return this; + }; + +//------------------------------ Handler --------------------------- +/** + * change password type. + * + * @param value : inputting password + */ + passwordOnChange(value: string) { + if (this.lockUi) { + return + } + this.password = value; + LogUtil.info(this.TAG + 'passwordOnChange : passwordType = ' + this.passwordType + ', password = ' + this.password) + this.checkInputDigits(value) + } + +/** + * Check input password digits. + * When password type is PIN_SIX, password should be 6 digit numbers. + * When password type is number or mixed, password should be fewer than 33 digits. + * + * @param value : inputting password + */ + checkInputDigits(value: string) { + if (this.passwordType == PinSubType.PIN_SIX) { + if (value.length >= 6) { + this.inputFinish(); + } + } + } + +//------------------------------ check --------------------------- +/** + * Input finish. Start simple check. + */ + inputFinish(event?: ClickEvent) { + if (this.lockUi) { + return + } + this.lockUi = true + LogUtil.info(this.TAG + 'inputFinish : password = ' + this.password) + + if (!this.password) { + LogUtil.info(this.TAG + 'inputFinish return : password is none.') + this.lockUi = false + return; + } + + // clear page data + this.freezingTime = -1 + this.remainTimes = -1; + + this.checkInputSuccess() + } + +/** + * Input check success. + */ + checkInputSuccess() { + this.checkPasswordCorrect((result, extraInfo) => { + LogUtil.info(this.TAG + 'checkInputSuccess : checkPasswordCorrect callback : result = ' + result + ', extraInfo = ' + JSON.stringify(extraInfo)); + + if (result === ResultCode.SUCCESS) { + if (extraInfo) { + if (this.pinChallenge) { + this.pinToken = extraInfo.token; + } + } + LogUtil.info(this.TAG + 'checkInputSuccess : callback success. pinChallenge = ' + this.pinChallenge + ', pinToken = ' + this.pinToken); + this.authSuccess() + return; + } else { + if (extraInfo) { + this.freezingTime = extraInfo.freezingTime; + this.remainTimes = extraInfo.remainTimes; + } + this.lockUi = false + } + }); + } + +/** + * Check password result changed. + */ + authSuccess() { + LogUtil.info(`${this.TAG}resultChanged: pageRequestCode = ${this.pageRequestCode}`); + if (this.pinToken && this.pageRequestCode == ConfigData.PAGE_REQUEST_CODE_PASSWORD_CHANGE) { + prompt.showToast({ message: "auth success!!", duration: 3500 }) + this.authOk = true; + + } else if (this.pinToken && this.pageRequestCode == ConfigData.PAGE_REQUEST_CODE_PASSWORD_DISABLE) { + this.delCredential(() => { + this.goBackCorrect(); + }); + + } else { + this.goBackCorrect(); + } + } + +//------------------------------ Router ----------------------------- +/** + * Go to password create page + */ + gotoPasswordCreatePage() { + if (!this.authOk) { + prompt.showToast({ message: "auth not succeed", duration: 3500 }) + return + } + LogUtil.info(`${this.TAG}gotoPasswordCreatePage : pageRequestCode: ${this.pageRequestCode}, prevPageUri = ${this.prevPageUri}, pageRequestCode: ${this.pageRequestCode}, pinChallenge: ${this.pinChallenge}, pinToken: ${this.pinToken}`); + Router.replace({ + uri: 'pages/passwordInput', + params: { + 'pageRequestCode': this.pageRequestCode, + 'prevPageUri': this.prevPageUri, + 'pinChallenge': this.pinChallenge, + 'pinToken': this.pinToken + }, + }) + } + +/** + * Auth check ok, return OK result. + */ + goBackCorrect() { + Router.back() + } + +//------------------------------ api --------------------------- +/** + * Call api to check if has the password + */ + loadData() { + PasswordModel.hasPinPassword((havePassword) => { + LogUtil.info(this.TAG + 'hasPinPassword : havePassword = ' + havePassword); + if (havePassword) { + this.getAuthProperty(); + } else { + this.goBackCorrect(); + } + }); + } + +/** + * Call api to check the password + * + * @param value : password type + */ + checkPasswordCorrect(successCallback: (result: number, extraInfo: any) => void): void { + PasswordModel.authPin(this.pinChallenge, this.password, (result, extraInfo) => { + LogUtil.info(this.TAG + 'checkPasswordCorrect : result = ' + JSON.stringify(result) + ', extraInfo = ' + JSON.stringify(extraInfo)); + if (result === ResultCode.SUCCESS) { + LogUtil.info(`${this.TAG}checkPasswordCorrect success`); + } else { + LogUtil.info(`${this.TAG}checkPasswordCorrect failed`); + } + successCallback(result, extraInfo) + }); + } + +/** + * Call api to get passwordType, freezingTime and remainTimes + * + * @param successCallback: api success callback + */ + getAuthProperty() { + // todo for debug + let data = JSON.parse('{"result":0,"authSubType":10001,"remainTimes":0,"freezingTime":0}'); + LogUtil.info(this.TAG + `getAuthProperty dummy data:${JSON.stringify(data)}`); + this.passwordType = data.authSubType; + this.freezingTime = data.freezingTime; + this.remainTimes = data.remainTimes; + // todo for debug + + // //todo 调用该api之后,回调log能打出来,但是app崩溃 + // PasswordModel.getAuthProperty((data: any) => { + // LogUtil.info(this.TAG + `getAuthProperty data:${JSON.stringify(data)}`); + // this.passwordType = data.authSubType; + // this.freezingTime = data.freezingTime; + // this.remainTimes = data.remainTimes; + // if (data.result === ResultCode.SUCCESS) { + // LogUtil.info(`${this.TAG}getAuthProperty success`); + // } else { + // LogUtil.info(`${this.TAG}getAuthProperty failed`); + // } + // }); + } + +/** + * Call api to delete the credential + * + * @param successCallback: api success callback + */ + delCredential(successCallback) { + PasswordModel.delAllCredential(this.pinToken, (result, extraInfo) => { + LogUtil.info(`${this.TAG}delAllCredential->result:${result}, extraInfo:${JSON.stringify(extraInfo)}`); + if (result === ResultCode.SUCCESS) { + LogUtil.info(`${this.TAG}delAllCredential success`); + this.pinToken = ''; + successCallback(); + } else { + LogUtil.info(`${this.TAG}delAllCredential failed`); + } + }) + } +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/controller/password/PasswordInputController.ets b/product/phone/src/main/ets/default/controller/password/PasswordInputController.ets new file mode 100644 index 00000000..d01b455b --- /dev/null +++ b/product/phone/src/main/ets/default/controller/password/PasswordInputController.ets @@ -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 BaseSettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/BaseSettingsController.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ISettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/ISettingsController'; +import { LogAll } from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import { PinSubType } from '../../model/passwordImpl/PasswordModel.ets'; +import Router from '@system.router'; + +let PASSWORD_MAX_LENGTH = 32 +let AUTH_SUB_TYPE_DEFAULT = PinSubType.PIN_SIX + +@LogAll +export default class PasswordInputController extends BaseSettingsController { + private TAG = ConfigData.TAG + 'PasswordInputController '; + private pageRequestCode: number = -1 + private prevPageUri: string = undefined + private pinChallenge: string = undefined + private pinToken: string = undefined + private password: string = '' + private passwordType: number = -1 + private checkMessage: string | Resource = '' + +/** + * Initialize data. + */ + initData(): ISettingsController { + + LogUtil.info(this.TAG + 'initData start : passwordType = ' + this.passwordType) + if (!this.passwordType || this.passwordType < 0) { + LogUtil.info(this.TAG + 'initData : passwordType set DEFAULT') + this.passwordType = AUTH_SUB_TYPE_DEFAULT; + } + + LogUtil.info(this.TAG + 'initData : passwordType = ' + this.passwordType) + + return super.initData(); + } + +//------------------------------ Handler --------------------------- +/** + * Change password type + * + * @param value : password type + */ + changePasswordType(value) { + this.passwordType = value; + } + +/** + * Password + * + * @param value : inputting password + */ + passwordOnChange(value: string) { + this.password = value; + LogUtil.info(this.TAG + 'passwordOnChange : passwordType = ' + this.passwordType + ', password = ' + this.password) + this.checkMessage = '' + this.checkInputDigits(value) + } + +/** + * Check input password digits. + * When password type is PIN_SIX, password should be 6 digit numbers. + * When password type is number or mixed, password should be fewer than 33 digits. + * + * @param value : inputting password + */ + checkInputDigits(value: string) { + + // When password type is PIN_SIX, check number 6 digits + if (this.passwordType == PinSubType.PIN_SIX) { + this.checkMessage = '' + if (value.length == 6) { + this.inputFinish(); + } + } + + // Other type, check PIN fewer than 33 digits + else if (this.checkMaxDigits(value)) { + this.checkMessage = '' + } + + // 33 digits check error, show message + else if (this.passwordType == PinSubType.PIN_NUMBER) { + this.checkMessage = $r('app.string.password_PIN_check_max_error') + } else if (this.passwordType == PinSubType.PIN_MIXED) { + this.checkMessage = $r('app.string.password_check_max_error') + } + + LogUtil.info(this.TAG + 'checkInputDigits : checkMessage = ' + JSON.stringify(this.checkMessage)); + } + +//------------------------------ check --------------------------- +/** + * check if the password less than 33 digits + * + * @param value : inputting password + */ + checkMaxDigits(value: string): boolean { + return value.length <= PASSWORD_MAX_LENGTH; + } + +/** + * Input finish. Start simple check. + */ + inputFinish() { + LogUtil.info(this.TAG + 'inputFinish : password = ' + this.password) + + if (!this.password) { + LogUtil.info(this.TAG + 'inputFinish return : password is none.') + return; + } + + if (this.checkMessage) { + LogUtil.info(this.TAG + 'inputFinish return : has error yet.') + return; + } + + this.checkInputSuccess() + } + +/** + * Input check success. + */ + checkInputSuccess() { + this.gotoRepeatPage(); + } + +//------------------------------ Router --------------------------- +/** + * When password illegality check is ok, go to repeat input password page. + */ + gotoRepeatPage() { + Router.replace({ + uri: 'pages/passwordRepeat', + params: { + 'prevPageUri': this.prevPageUri, + 'pageRequestCode': this.pageRequestCode, + 'pinChallenge': this.pinChallenge, + 'pinToken': this.pinToken, + 'inputPassword': this.password, + 'passwordType': this.passwordType + } + }); + } + +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/controller/password/PasswordRepeatController.ets b/product/phone/src/main/ets/default/controller/password/PasswordRepeatController.ets new file mode 100644 index 00000000..1a52dbc2 --- /dev/null +++ b/product/phone/src/main/ets/default/controller/password/PasswordRepeatController.ets @@ -0,0 +1,173 @@ +/** + * 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 BaseSettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/BaseSettingsController.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ISettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/ISettingsController'; +import {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import PasswordModel, {PinSubType, ResultCode} from '../../model/passwordImpl/PasswordModel.ets'; +import Router from '@system.router'; + +let PASSWORD_MAX_LENGTH = 32 + +@LogAll +export default class PasswordRepeatController extends BaseSettingsController { + private TAG = ConfigData.TAG + 'PasswordRepeatController '; + private pinToken: string = undefined + private passwordType: number = -1 + private inputPassword: string = undefined + private checkMessage: string | Resource = '' + private password: string = '' + + subscribe(): ISettingsController { + PasswordModel.registerInputer(); + return this; + }; + + unsubscribe(): ISettingsController { + PasswordModel.unregisterInputer(); + return this; + }; + +//------------------------------ Handler --------------------------- +/** + * Password + * + * @param value : inputting password + */ + passwordOnChange(value: string) { + this.password = value; + LogUtil.info(this.TAG + 'passwordOnChange : passwordType = ' + this.passwordType + ', password = ' + this.password) + this.checkMessage = '' + this.checkInputDigits(value) + } + +/** + * Check input password digits. + * When password type is PIN_SIX, password should be 6 digit numbers. + * When password type is number or mixed, password should be fewer than 33 digits. + * + * @param value : inputting password + */ + checkInputDigits(value: string) { + + // When password type is PIN_SIX, check number 6 digits + if (this.passwordType == PinSubType.PIN_SIX) { + this.checkMessage = '' + if (value.length == 6) { + this.inputFinish(); + } + } + + // Other type, check PIN fewer than 33 digits + else if (this.checkMaxDigits(value)) { + this.checkMessage = '' + } + + // 33 digits check error, show message + else if (this.passwordType == PinSubType.PIN_NUMBER) { + this.checkMessage = $r('app.string.password_PIN_check_max_error') + } else if (this.passwordType == PinSubType.PIN_MIXED) { + this.checkMessage = $r('app.string.password_check_max_error') + } + + LogUtil.info(this.TAG + 'checkInputDigits : checkMessage = ' + JSON.stringify(this.checkMessage)); + } + +//------------------------------ check --------------------------- +/** + * check if the password less than 33 digits + * + * @param value : inputting password + */ + checkMaxDigits(value: string): boolean { + return value.length <= PASSWORD_MAX_LENGTH; + } + +/** + * Input finish. Start simple check. + */ + inputFinish() { + LogUtil.info(this.TAG + 'inputFinish : password = ' + this.password + ', inputPassword = ' + this.inputPassword) + + if (!this.password) { + LogUtil.info(this.TAG + 'inputFinish return : password is none.') + return; + } + + if (this.checkMessage) { + LogUtil.info(this.TAG + 'inputFinish return : has error yet.') + return; + } + + if (this.password == this.inputPassword) { + if (this.pinToken) { + this.updatePassword() + } else { + this.createPassword() + } + } else { + // not match + LogUtil.info(this.TAG + 'inputFinish : not match') + this.checkMessage = $r('app.string.password_message_repeat_error') + } + } + +//------------------------------ Router ----------------------------- +/** + * Return OK result. + */ + goBackCorrect() { + Router.back() + } + +//------------------------------ api --------------------------- +/** + * Call api to create password + */ + createPassword() { + PasswordModel.addPinCredential(this.passwordType, this.password, (result) => { + LogUtil.info(this.TAG + 'createPassword->result = ' + JSON.stringify(result)); + if (result === ResultCode.SUCCESS) { + LogUtil.info(`${this.TAG}createPassword success`); + this.goBackCorrect() + } else { + LogUtil.info(`${this.TAG}createPassword failed`); + //TODO show api message to view + this.checkMessage = 'create failed.' + } + }); + } + +/** + * Call api to update password + */ + updatePassword() { + PasswordModel.updateCredential(this.passwordType, this.password, this.pinToken, (result, extraInfo) => { + LogUtil.info(this.TAG + 'updateCredential->result = ' + JSON.stringify(result)); + LogUtil.info(this.TAG + 'updateCredential->extraInfo = ' + JSON.stringify(extraInfo)); + if (result === ResultCode.SUCCESS) { + LogUtil.info(`${this.TAG}updatePassword success`); + this.goBackCorrect() + } else { + LogUtil.info(`${this.TAG}updatePassword failed`); + //TODO show error message to view + this.checkMessage = 'update failed.' + } + }); + } + +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/controller/password/PasswordSettingController.ets b/product/phone/src/main/ets/default/controller/password/PasswordSettingController.ets new file mode 100644 index 00000000..1e9330e5 --- /dev/null +++ b/product/phone/src/main/ets/default/controller/password/PasswordSettingController.ets @@ -0,0 +1,188 @@ +/** + * 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 BaseSettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/BaseSettingsController.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import ISettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/ISettingsController'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import PasswordModel from '../../model/passwordImpl/PasswordModel.ets'; + +@LogAll +export default class PasswordSettingController extends BaseSettingsController { + private TAG = ConfigData.TAG + 'PasswordSettingController '; + private pinChallenge: string = ''; + private passwordList: any[] = []; + + subscribe(): ISettingsController { + PasswordModel.closeSession(); + PasswordModel.openSession((data) => { + LogUtil.info(`${this.TAG}subscribe->openSession data:${data}`); + if (data === '0') { + LogUtil.info(`${this.TAG}subscribe->openSession failed`); + } else { + LogUtil.info(`${this.TAG}subscribe->openSession success`); + } + this.pinChallenge = data; + }); + return this; + }; + + unsubscribe(): ISettingsController { + PasswordModel.closeSession(); + return this; + }; + +/** + * Load page data. + * Get password from api. create data list of + */ + loadData() { + // get password + PasswordModel.hasPinPassword((passwordHasSet) => { + + // update password settings list + this.getListData(passwordHasSet , (list) => { + LogUtil.info(this.TAG + 'getListData callback : list = ' + JSON.stringify(list)); + this.passwordList = list + LogUtil.info(this.TAG + 'getListData callback : end '); + }); + }); + } + +/** + * When receive next page's result is ok, do here. + * + * @param routerParam : next page's result + */ + getListData(passwordHasSet: boolean, callback) { + let list = this.getPageData(); + + for (let key in list) { + let settingAlias = list[key].settingAlias; + let shouldDisplay = true; + let title; + let requestCode = -1; + switch (settingAlias) { + case 'biometrics_section_title': + shouldDisplay = passwordHasSet; + title = $r('app.string.biometrics'); + break; + + case 'face_recognition': + title = $r('app.string.face_recognition') + requestCode = ConfigData.PAGE_REQUEST_CODE_PASSWORD_FACE; + break; + + case 'password_section_title': + shouldDisplay = passwordHasSet; + title = $r('app.string.password'); + break; + + case 'password_lock_screen': + shouldDisplay = !passwordHasSet; + title = $r('app.string.password_lock_screen'); + requestCode = ConfigData.PAGE_REQUEST_CODE_PASSWORD_CREATE; + break; + + case 'password_change_password': + shouldDisplay = passwordHasSet; + title = $r('app.string.password_change_password') + requestCode = ConfigData.PAGE_REQUEST_CODE_PASSWORD_CHANGE; + break; + + case 'password_disable_password': + shouldDisplay = passwordHasSet; + title = $r('app.string.password_disable_password') + requestCode = ConfigData.PAGE_REQUEST_CODE_PASSWORD_DISABLE; + break; + } + + list[key].settingShouldDisplay = shouldDisplay; + list[key].settingTitle = title; + list[key].settingRequestCode = requestCode; + + } + callback(list) + + } + + getPageData(): any[] { + let list = [ + { + settingIsSectionTitle: true, + settingShouldDisplay: false, + settingTitle: "", + settingAlias: "biometrics_section_title", + settingValue: "", + settingArrow: "", + settingRequestCode: "", + settingUri: "" + }, + { + settingIsSectionTitle: false, + settingShouldDisplay: true, + settingTitle: "", + settingAlias: "face_recognition", + settingValue: "", + settingArrow: "/res/image/ic_settings_arrow.svg", + settingRequestCode: "", + settingUri: "" + }, + { + settingIsSectionTitle: true, + settingShouldDisplay: false, + settingTitle: "", + settingAlias: "password_section_title", + settingValue: "", + settingArrow: "", + settingRequestCode: "", + settingUri: "" + }, + { + settingIsSectionTitle: false, + settingShouldDisplay: true, + settingTitle: "", + settingAlias: "password_lock_screen", + settingValue: "", + settingArrow: "/res/image/ic_settings_arrow.svg", + settingRequestCode: "", + settingUri: "pages/passwordInput" + }, + { + settingIsSectionTitle: false, + settingShouldDisplay: false, + settingTitle: "", + settingAlias: "password_change_password", + settingValue: "", + settingArrow: "/res/image/ic_settings_arrow.svg", + settingRequestCode: "", + settingUri: "pages/passwordCheck" + }, + { + settingIsSectionTitle: false, + settingShouldDisplay: false, + settingTitle: "", + settingAlias: "password_disable_password", + settingValue: "", + settingArrow: "", + settingRequestCode: "", + settingUri: "pages/passwordCheck" + } + ] + + return list + } + +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/controller/restoreFactorySettings/RestoreFactorySettingsController.ets b/product/phone/src/main/ets/default/controller/restoreFactorySettings/RestoreFactorySettingsController.ets new file mode 100644 index 00000000..e2d91c31 --- /dev/null +++ b/product/phone/src/main/ets/default/controller/restoreFactorySettings/RestoreFactorySettingsController.ets @@ -0,0 +1,28 @@ +/** + * 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 RestoreFactorySettingsModel from '../../model/restoreFactorySettingsImpl/RestoreFactorySettingsModel.ets' +import {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import BaseSettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/BaseSettingsController' + +@LogAll +export default class RestoreFactorySettingsController extends BaseSettingsController { + + /** + * Restore factorySettings + */ + restoreFactorySettings() { + return RestoreFactorySettingsModel.rebootAndCleanUserData(); + } +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/controller/storage/storageController.ets b/product/phone/src/main/ets/default/controller/storage/storageController.ets new file mode 100644 index 00000000..ccb2fc2a --- /dev/null +++ b/product/phone/src/main/ets/default/controller/storage/storageController.ets @@ -0,0 +1,143 @@ +/** + * 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 StorageModel from '../../model/StorageImpl/StorageModel.ets' +import {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import BaseSettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/BaseSettingsController.ets'; +import ISettingsController from '../../../../../../../../common/component/src/main/ets/default/controller/ISettingsController' + +enum Space { + /** + * Total space + */ + TOTAL_SPACE = '0', + /** + * Used space + */ + USED_SPACE = '1', + /** + * Remaining space + */ + REMAINING_SPACE = '2' +} + +@LogAll +export default class storageController extends BaseSettingsController { + private storageList: any[] = []; + private totalSpace: number; + private freeBytes: number; + private usedSpace: number; + + initData(): ISettingsController{ + super.initData(); + this.getTotalSpace(); + return this; + } + + /** + * get TotalSpace + */ + getTotalSpace() { + StorageModel.getStorageDataDir((err, data: string) => { + LogUtil.info(ConfigData.TAG + 'getStorageDataDir err: ' + JSON.stringify(err)); + LogUtil.info(ConfigData.TAG + 'getStorageDataDir data: ' + JSON.stringify(data)); + if (data && data.length > 0) { + StorageModel.getTotalSpace(data, (err, data) => { + LogUtil.info(ConfigData.TAG + 'getTotalSpace err: ' + JSON.stringify(err)); + LogUtil.info(ConfigData.TAG + 'getTotalSpace data: ' + JSON.stringify(data)); + if (data && data >= 0) { + LogUtil.info(ConfigData.TAG + 'getTotalSpace success'); + this.totalSpace = data; + this.getFreeBytes(); + } + }); + } + }); + } + + /** + * get RemainingSpace + */ + getFreeBytes() { + StorageModel.getStorageDataDir((err, data) => { + LogUtil.info(ConfigData.TAG + 'getStorageDataDir err: ' + JSON.stringify(err)); + LogUtil.info(ConfigData.TAG + 'getStorageDataDir data: ' + JSON.stringify(data)); + if (data && data.length > 0) { + StorageModel.getFreeBytes(data, (err, data) => { + LogUtil.info(ConfigData.TAG + 'getFreeBytes err: ' + JSON.stringify(err)); + LogUtil.info(ConfigData.TAG + 'getFreeBytes data: ' + JSON.stringify(data)); + if (data && data >= 0) { + this.storageList = []; + LogUtil.info(ConfigData.TAG + 'getFreeBytes success'); + this.freeBytes = data; + this.getUsedSpace(); + this.storageList = this.getStorageList(); + } + }); + } + }); + } + + /** + * get UsedSpace + */ + getUsedSpace(){ + this.usedSpace = this.totalSpace - this.freeBytes; + } + + /** + * Get storage List + */ + getStorageList() { + let storageList = StorageModel.getStorageItemList(); + for (let key in storageList) { + LogUtil.info(ConfigData.TAG + 'Storage getStorageList key:' + key); + switch (key) { + case Space.TOTAL_SPACE: + storageList[key].settingTitle = $r('app.string.totalSpace') + storageList[key].settingValue = this.formatData(this.totalSpace); + break; + case Space.USED_SPACE: + storageList[key].settingTitle = $r('app.string.usedSpace'); + storageList[key].settingValue = this.formatData(this.usedSpace); + break; + case Space.REMAINING_SPACE: + storageList[key].settingTitle = $r('app.string.remainingSpace'); + storageList[key].settingValue = this.formatData(this.freeBytes); + break; + } + } + LogUtil.info(ConfigData.TAG + 'Storage getStorageList storageTitleValue out:' + JSON.stringify(storageList)); + return storageList; + } + + /** + * format data + */ + formatData(val) { + let result = ''; + if (val < 1024) { + result = `${val} B`; + } else if (val < 1024 * 1024) { + result = `${(val / 1024).toFixed(2)} KB`; + } else if (val < 1024 * 1024 * 1024) { + result = `${(val / (1024 * 1024)).toFixed(2)} MB`; + } else if (val < 1024 * 1024 * 1024 * 1024) { + result = `${(val / (1024 * 1024 * 1024)).toFixed(2)} GB`; + } + return result; + } +} \ No newline at end of file diff --git a/entry/src/main/ets/default/model/abilityInfoImpl/AbilityInfoModel.ets b/product/phone/src/main/ets/default/model/abilityInfoImpl/AbilityInfoModel.ets similarity index 95% rename from entry/src/main/ets/default/model/abilityInfoImpl/AbilityInfoModel.ets rename to product/phone/src/main/ets/default/model/abilityInfoImpl/AbilityInfoModel.ets index 91767fe3..8ee9baf4 100644 --- a/entry/src/main/ets/default/model/abilityInfoImpl/AbilityInfoModel.ets +++ b/product/phone/src/main/ets/default/model/abilityInfoImpl/AbilityInfoModel.ets @@ -12,11 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import BaseModel from '../BaseModel'; +import BaseModel from '../../../../../../../../common/utils/src/main/ets/default/model/BaseModel.ets'; import Bundle from '@ohos.bundle'; import ResMgr from '@ohos.resourceManager'; -import LogUtil from '../../common/baseUtil/LogUtil.ets'; -import {BaseData} from '../BaseData.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import {BaseData} from '../../../../../../../../common/utils/src/main/ets/default/model/BaseData.ets'; import {MetaDataModel} from './MetaDataModel.ets'; let icon_arrow = $r('app.media.ic_settings_arrow'); diff --git a/entry/src/main/ets/default/model/abilityInfoImpl/MetaDataModel.ets b/product/phone/src/main/ets/default/model/abilityInfoImpl/MetaDataModel.ets similarity index 88% rename from entry/src/main/ets/default/model/abilityInfoImpl/MetaDataModel.ets rename to product/phone/src/main/ets/default/model/abilityInfoImpl/MetaDataModel.ets index 5eed50ee..f5404527 100644 --- a/entry/src/main/ets/default/model/abilityInfoImpl/MetaDataModel.ets +++ b/product/phone/src/main/ets/default/model/abilityInfoImpl/MetaDataModel.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import LogUtil from '../../common/baseUtil/LogUtil.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; export class MetaDataModel { constructor(jsonData: string) { diff --git a/entry/src/main/ets/default/model/aboutDeviceImpl/AboutDeviceModel.ets b/product/phone/src/main/ets/default/model/aboutDeviceImpl/AboutDeviceModel.ets similarity index 75% rename from entry/src/main/ets/default/model/aboutDeviceImpl/AboutDeviceModel.ets rename to product/phone/src/main/ets/default/model/aboutDeviceImpl/AboutDeviceModel.ets index 0c8fe151..247e1f55 100644 --- a/entry/src/main/ets/default/model/aboutDeviceImpl/AboutDeviceModel.ets +++ b/product/phone/src/main/ets/default/model/aboutDeviceImpl/AboutDeviceModel.ets @@ -12,10 +12,10 @@ * 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 BaseModel from '../../../../../../../../common/utils/src/main/ets/default/model/BaseModel.ets'; +import BaseParseConfModel from '../../../../../../../../common/utils/src/main/ets/default/model/BaseParseConfModel.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; import deviceInfo from '@ohos.deviceInfo'; /** diff --git a/entry/src/main/ets/default/model/appManagementImpl/AppManagementModel.ets b/product/phone/src/main/ets/default/model/appManagementImpl/AppManagementModel.ets similarity index 70% rename from entry/src/main/ets/default/model/appManagementImpl/AppManagementModel.ets rename to product/phone/src/main/ets/default/model/appManagementImpl/AppManagementModel.ets index 717e19ce..04a7d393 100644 --- a/entry/src/main/ets/default/model/appManagementImpl/AppManagementModel.ets +++ b/product/phone/src/main/ets/default/model/appManagementImpl/AppManagementModel.ets @@ -12,10 +12,14 @@ * 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 BaseModel from '../../../../../../../../common/utils/src/main/ets/default/model/BaseModel.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; import Bundle from '@ohos.bundle'; import ResMgr from '@ohos.resourceManager'; +import AbilityManager from '@ohos.app.abilityManager' +import BaseParseConfModel from '../../../../../../../../common/utils/src/main/ets/default/model/BaseParseConfModel.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; const INDEX = 0; const IS_INCLUDE_ABILITY_INFO = 0; @@ -26,6 +30,7 @@ let icon_default = $r('app.media.icon_default'); /** * app management service class */ +@LogAll export class AppManagementModel extends BaseModel { private mBundleInfoList: any[]= []; /** @@ -145,6 +150,83 @@ export class AppManagementModel extends BaseModel { } LogUtil.info('settings appManagement AppManagementModel getIconItem end'); } + + /** + * Get storageList + */ + getStorageList() { + BaseParseConfModel.getJsonDataBase(ConfigData.FILE_URI.concat('applicationStorage.json'), baseData => { + let applicationStorageList = this.setTitleValue(baseData); + AppStorage.SetOrCreate('applicationStorageList', applicationStorageList); + }) + } + + /** + * Set titleValue + */ + setTitleValue(baseData) { + let titleValue; + for (let key in baseData) { + let settingAlias = baseData[key].settingAlias; + if ('storageTab' === settingAlias) { + baseData[key].settingSummary = $r('app.string.storageTab') + } else if ('totalTab' === settingAlias) { + titleValue = $r('app.string.totalTab') + } else if ('applyTab' === settingAlias) { + titleValue = $r('app.string.applyTab') + } else if ('dataTab' === settingAlias) { + titleValue = $r('app.string.dataTab') + } else if ('deleteDataTab' === settingAlias) { + titleValue = $r('app.string.deleteDataTab') + } else if ('cacheTab' === settingAlias) { + titleValue = $r('app.string.cacheTab') + } else if ('clearCacheTab' === settingAlias) { + titleValue = $r('app.string.clearCacheTab') + } + baseData[key].settingTitle = titleValue + } + return baseData; + } + + + /** + * Clear up application data by bundle name + * @param bundleName bundle name + */ + clearUpApplicationData(bundleName: string, callback) { + AbilityManager.clearUpApplicationData(bundleName, callback); + } + + /** + * Clears cache data of a specified application. + * @param bundleName bundle name + */ + cleanBundleCacheFiles(bundleName: string, callback) { + Bundle.cleanBundleCacheFiles(bundleName, callback); + } + + /** + * Uninstall an application. + * @param bundleName bundle name + */ + uninstall(bundleName: string, callback) { + Bundle.getBundleInstaller((err: Error, bundleInstaller) => { + if (err) { + LogUtil.info(ConfigData.TAG + 'getBundleInstaller err : ' + JSON.stringify(err)); + } + let installParam = { userId: 0, installFlag: 0, isKeepData: false }; + bundleInstaller.uninstall(bundleName, installParam, callback); + }); + } + + /** + * Kill processes by bundle name + * @param bundleName bundle name + */ + killProcessesByBundleName(bundleName: string, callback) { + AbilityManager.killProcessesByBundleName(bundleName, callback); + } + } let appManagementModel = new AppManagementModel(); diff --git a/product/phone/src/main/ets/default/model/brightnessImpl/BrightnessSettingModel.ets b/product/phone/src/main/ets/default/model/brightnessImpl/BrightnessSettingModel.ets new file mode 100644 index 00000000..144c2e4f --- /dev/null +++ b/product/phone/src/main/ets/default/model/brightnessImpl/BrightnessSettingModel.ets @@ -0,0 +1,122 @@ +/** + * 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 '../../../../../../../../common/utils/src/main/ets/default/model/BaseModel.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import Log from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import settings from '@ohos.settings'; +import Brightness from '@ohos.brightness'; +import featureAbility from '@ohos.ability.featureAbility'; + +/** + * Brightness setting + * + * @param brightnessValue - Brightness value + */ +export class BrightnessSettingModel extends BaseModel{ + private dataAbilityHelper; + private urivar:string; + private settingsDataKey:string = ConfigData.SETTINGSDATA_BRIGHTNESS; + private brightness:number = 5; + private defaultBrightnessStr = '5'; + private TAG = ConfigData.TAG + 'BrightnessSettingModel '; + + constructor() { + super(); + this.urivar = settings.getUri(this.settingsDataKey); + this.dataAbilityHelper = featureAbility.acquireDataAbilityHelper(this.urivar); + this.updateValue(); + } + + /** + * Get brightness value in the BrightnessSettingModel + */ + @Log + public getValue(){ + return this.brightness; + } + + /** + * Set value + */ + @Log + public setValue(brightness:number, sliderChangeMode:number){ + if(sliderChangeMode === ConfigData.SLIDER_CHANG_MODE_END){ + LogUtil.info(this.TAG + `setValue [brightness:${brightness}, sliderChangeMode:${sliderChangeMode}]`); + this.setSettingsData(brightness); + }else{ + this.setSystemBrightness(brightness); + } + return; + } + + /** + * Set brightness value in the SettingsData + */ + @Log + private setSettingsData(brightness:number){ + LogUtil.info(this.TAG + `setSettingsData [brightness:${brightness}]`); + this.brightness = brightness; + settings.setValue(this.dataAbilityHelper, this.settingsDataKey, brightness.toString()); + LogUtil.info(this.TAG + `setSettingsData success`); + } + + /** + * Set system brightness value + */ + @Log + private setSystemBrightness(brightness:number){ + this.brightness = brightness; + Brightness.setValue(brightness); + return; + } + + /** + * Update brightness value in the BrightnessSettingModel + */ + @Log + private updateValue(){ + LogUtil.info(this.TAG + 'updateValue'); + this.brightness = parseInt(settings.getValue(this.dataAbilityHelper, this.settingsDataKey, this.defaultBrightnessStr)); + LogUtil.info(this.TAG + `updateValue success, [brightness:${this.brightness}]`); + return; + } + + /** + * Register observer + */ + @Log + public registerObserver(){ + LogUtil.info(this.TAG + 'registerObserver'); + this.dataAbilityHelper.on("dataChange", this.urivar, (err)=>{ + this.updateValue(); + }) + LogUtil.info(this.TAG + 'registerObserver success'); + return; + } + + /** + * Unregister observer + */ + @Log + public unregisterObserver() { + LogUtil.info(this.TAG + 'unregisterObserver'); + this.dataAbilityHelper.off("dataChange", this.urivar, (err)=>{ + LogUtil.info(this.TAG + 'unregisterObserver success'); + }) + return; + } +} \ No newline at end of file diff --git a/entry/src/main/ets/default/model/dataRdbImpl/DataRdbModel.ets b/product/phone/src/main/ets/default/model/dataRdbImpl/DataRdbModel.ets similarity index 90% rename from entry/src/main/ets/default/model/dataRdbImpl/DataRdbModel.ets rename to product/phone/src/main/ets/default/model/dataRdbImpl/DataRdbModel.ets index 307864a1..1248710d 100644 --- a/entry/src/main/ets/default/model/dataRdbImpl/DataRdbModel.ets +++ b/product/phone/src/main/ets/default/model/dataRdbImpl/DataRdbModel.ets @@ -12,10 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import Stable from '../../common/baseUtil/Global.ets' -import rdbStore from '../../common/baseUtil/RdbStoreUtil.ets' -import LogUtil from '../../common/baseUtil/LogUtil.ets'; -import ConfigData from '../../common/baseUtil/ConfigData.ets'; +import Stable from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/Global.ets'; +import rdbStore from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; class DataRdbModel { insertValues: any[] = [ diff --git a/entry/src/main/ets/default/model/dataRdbImpl/DataRdbService.ets b/product/phone/src/main/ets/default/model/dataRdbImpl/DataRdbService.ets similarity index 87% rename from entry/src/main/ets/default/model/dataRdbImpl/DataRdbService.ets rename to product/phone/src/main/ets/default/model/dataRdbImpl/DataRdbService.ets index aebe1ce6..0848eace 100644 --- a/entry/src/main/ets/default/model/dataRdbImpl/DataRdbService.ets +++ b/product/phone/src/main/ets/default/model/dataRdbImpl/DataRdbService.ets @@ -13,9 +13,9 @@ * limitations under the License. */ import DataRdbModel from './DataRdbModel.ets'; -import Stable from '../../common/baseUtil/Global.ets'; -import LogUtil from '../../common/baseUtil/LogUtil.ets'; -import ConfigData from '../../common/baseUtil/ConfigData.ets'; +import Stable from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/Global.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; class DataRdbService { /** diff --git a/product/phone/src/main/ets/default/model/dateAndTimeImpl/DateAndTimeModel.ets b/product/phone/src/main/ets/default/model/dateAndTimeImpl/DateAndTimeModel.ets new file mode 100644 index 00000000..31ecf4a6 --- /dev/null +++ b/product/phone/src/main/ets/default/model/dateAndTimeImpl/DateAndTimeModel.ets @@ -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 BaseModel from '../../../../../../../../common/utils/src/main/ets/default/model/BaseModel.ets'; +import BaseParseConfModel from '../../../../../../../../common/utils/src/main/ets/default/model/BaseParseConfModel.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import SystemTime from '@ohos.systemTime'; +import settings from '@ohos.settings'; +import featureAbility from '@ohos.ability.featureAbility' + +/** + * Set date and time + */ +export class DateAndTimeModel extends BaseModel { + timeFormat = null; + + setTime(time) { + LogUtil.info('DateAndTimeModel setTime in :' + time); + 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'); + } + + getTimeFormat() : string { + if (this.timeFormat === null) { + let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(ConfigData.TIME_FORMAT_URI); + this.timeFormat = settings.getValue(dataAbilityHelper, ConfigData.TIME_FORMAT_KEY, ConfigData.TIME_FORMAT_24); + LogUtil.info('DateAndTimeModel get time format is ' + this.timeFormat); + } + return this.timeFormat; + } + + setTimeFormatAs12H() : boolean { + return this.setTimeFormat(ConfigData.TIME_FORMAT_12); + } + + setTimeFormatAs24H() : boolean { + return this.setTimeFormat(ConfigData.TIME_FORMAT_24); + } + + public dateAndTimeListener(): any[] { + LogUtil.info('getAboutDeviceInfoListener come in'); + return BaseParseConfModel.getJsonData(ConfigData.FILE_URI.concat('dateAndTime.json')); + } + + private setTimeFormat(format: string) : boolean { + LogUtil.info('DateAndTimeModel set time format to ' + format); + if (format != ConfigData.TIME_FORMAT_12 && format != ConfigData.TIME_FORMAT_24) { + return false; + } + if (format === this.timeFormat) { + return true; + } + let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(ConfigData.TIME_FORMAT_URI); + let ret = settings.setValue(dataAbilityHelper, ConfigData.TIME_FORMAT_KEY, format); + if (ret === true) { + this.timeFormat = format; + } + return ret; + } +} + +let dateAndTimeModel = new DateAndTimeModel(); +export default dateAndTimeModel as DateAndTimeModel +; \ No newline at end of file diff --git a/product/phone/src/main/ets/default/model/developerOptionsImpl/DeveloperOptionsModel.ets b/product/phone/src/main/ets/default/model/developerOptionsImpl/DeveloperOptionsModel.ets new file mode 100644 index 00000000..17b456ca --- /dev/null +++ b/product/phone/src/main/ets/default/model/developerOptionsImpl/DeveloperOptionsModel.ets @@ -0,0 +1,56 @@ +/** + * 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 '../../../../../../../../common/utils/src/main/ets/default/model/BaseModel.ets'; +import usb from '@ohos.usb'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; + +/** + * Developer options model + */ +@LogAll +export class DeveloperOptionsModel extends BaseModel { + + /** + * Get usb current functions state + * @return state + */ + getUsbCurrentFunctions() { + return usb.getCurrentFunctions() + } + + /** + * set current functions + * @param usbDebuggingState UsbDebugging state + */ + setCurrentFunctions(usbDebuggingState) { + let funcs; + if (usbDebuggingState) { + funcs = ConfigData.FUNCTION_TYPE_HDC | this.getUsbCurrentFunctions() + } else { + funcs = (ConfigData.FUNCTION_TYPE_HDC | this.getUsbCurrentFunctions()) - ConfigData.FUNCTION_TYPE_HDC + } + usb.setCurrentFunctions(funcs).then((val) => { + }).catch((err) => { + LogUtil.info(ConfigData.TAG + `setCurrentFunctions fail:` + err); + }) + } +} + +let developerOptionsModel = new DeveloperOptionsModel(); + +export default developerOptionsModel as DeveloperOptionsModel +; \ No newline at end of file diff --git a/product/phone/src/main/ets/default/model/locationServicesImpl/LocationService.ets b/product/phone/src/main/ets/default/model/locationServicesImpl/LocationService.ets new file mode 100644 index 00000000..86033b6a --- /dev/null +++ b/product/phone/src/main/ets/default/model/locationServicesImpl/LocationService.ets @@ -0,0 +1,85 @@ +/** + * 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 geolocation from '@ohos.geolocation'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; + +export class LocationService { + mIsStart: boolean = false; + mListener: any; + mLocationEventListener = geolocation?.LocationEventListener ? new (geolocation?.LocationEventListener)() : + { + on: (...args) => { + }, + off: (...args) => { + } + }; + + startService() { + if (this.mIsStart) { + return; + } + LogUtil.info(ConfigData.TAG + 'start location service') + this.mIsStart = true; + this.getServiceState(); + this.mLocationEventListener.on('locationServiceState', (state) => { + LogUtil.info(ConfigData.TAG + `start location service state: ${JSON.stringify(state)}`) + this.mListener?.updateServiceState(state); + }); + } + + stopService() { + if (!this.mIsStart) { + return; + } + LogUtil.info(ConfigData.TAG + 'stop location service') + this.mIsStart = false; + this.mLocationEventListener.off('locationServiceState', (state) => { + LogUtil.info(ConfigData.TAG + `stop location service state: ${JSON.stringify(state)}`) + }); + } + + registerListener(listener: { + 'updateServiceState': Function, + }) { + LogUtil.info(ConfigData.TAG + `register locations listener : ${listener}`) + this.mListener = listener; + } + + getServiceState() { + LogUtil.info(ConfigData.TAG + 'get location state') + geolocation.isLocationEnabled().then((data) => { + LogUtil.info(ConfigData.TAG + `get location state, data: ${JSON.stringify(data)}`) + this.mListener?.updateServiceState(data); + }); + } + + enableLocation() { + LogUtil.info(ConfigData.TAG + 'enable location') + geolocation.enableLocation() + .then((res) => LogUtil.info(ConfigData.TAG + `enable location, result: ${JSON.stringify(res)}`)); + } + + disableLocation() { + LogUtil.info(ConfigData.TAG + 'disable location') + geolocation.disableLocation() + .then((res) => LogUtil.info(ConfigData.TAG + `disable location, result: ${JSON.stringify(res)}`)); + } +} + +let locationService = new LocationService(); + +export default locationService as LocationService; diff --git a/product/phone/src/main/ets/default/model/locationServicesImpl/LocationViewModel.ets b/product/phone/src/main/ets/default/model/locationServicesImpl/LocationViewModel.ets new file mode 100644 index 00000000..e1f57109 --- /dev/null +++ b/product/phone/src/main/ets/default/model/locationServicesImpl/LocationViewModel.ets @@ -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 LocationService from './LocationService.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; + +export const LocationServiceOpenStatusKey = "LocationServiceStatus"; + +export class LocationVM { + mIsStart: boolean = false; + + initViewModel() { + if (this.mIsStart) { + return; + } + LogUtil.info(ConfigData.TAG + 'init location view model') + this.mIsStart = true; + LocationService.registerListener(this); + LocationService.startService(); + } + + updateServiceState(state) { + LogUtil.info(ConfigData.TAG + `update location service state, state: ${state} `) + AppStorage.SetOrCreate(LocationServiceOpenStatusKey, state); + } + + enableLocation() { + LogUtil.info(ConfigData.TAG + 'enable location') + LocationService.enableLocation(); + } + + disableLocation() { + LogUtil.info(ConfigData.TAG + 'disable location') + LocationService.disableLocation(); + } +} + +let locationVM = new LocationVM(); + +export default locationVM as LocationVM; diff --git a/product/phone/src/main/ets/default/model/passwordImpl/PasswordModel.ets b/product/phone/src/main/ets/default/model/passwordImpl/PasswordModel.ets new file mode 100644 index 00000000..37ee29aa --- /dev/null +++ b/product/phone/src/main/ets/default/model/passwordImpl/PasswordModel.ets @@ -0,0 +1,489 @@ +/** + * 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 '../../../../../../../../common/utils/src/main/ets/default/model/BaseModel.ets'; +import { LogAll } from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import util from '@ohos.util'; +import UserIDM from '@ohos.useridm' +import UserAuth from '@ohos.userauth' +import PinAuth from '@ohos.pinauth' + +/** + * Credential type for authentication + */ +export enum AuthType { + /** + * Authentication type pin. + */ + PIN = 1, + /** + * Authentication type face. + */ + FACE = 2 +} + +export enum PinSubType { + /** + * Authentication sub type six number pin. + */ + PIN_SIX = 10000, + /** + * Authentication sub type self defined number pin. + */ + PIN_NUMBER = 10001, + /** + * Authentication sub type self defined mixed pin. + */ + PIN_MIXED = 10002, +} + +/** + * Result code + */ +export enum ResultCode { + /** + * success + */ + SUCCESS = 0, + /** + * fails + */ + FAIL = 1, +} + +/** + * Authentication method + */ +export enum AuthMethod { + /** + * Authentication method PIN. + */ + PIN_ONLY = 0xF, + /** + * Authentication method face. + */ + FACE_ONLY = 0xF0 +} + +/** + * Credibility level of certification results + */ +enum AuthTrustLevel { + /** + * Authentication result trusted level 1. + */ + ATL1 = 10000, + /** + * Authentication result trusted level 2. + */ + ATL2 = 20000, + /** + * Authentication result trusted level 3. + */ + ATL3 = 30000, + /** + * Authentication result trusted level 4. + */ + ATL4 = 40000 +} + +/** + * Actuator attribute list + */ +enum GetPropertyType { + /** + * Authentication remain times. + */ + AUTH_SUB_TYPE = 1, + /** + * Authentication remain times. + */ + REMAIN_TIMES = 2, + /** + * Authentication freezing time. + */ + FREEZING_TIME = 3 +} + +@LogAll +export class PasswordModel extends BaseModel { + private TAG = ConfigData.TAG + 'PasswordModel#'; + pinAuth: any; + userAuth: any; + userIdentityManager: any; + password: string; + pinSubType: number; + + /** + * constructor + */ + constructor() { + super(); + this.userIdentityManager = UserIDM.constructor(); + this.pinAuth = PinAuth.constructor(); + this.userAuth = UserAuth.constructor(); + } + + u8AToStr(val: Uint8Array): any{ + var dataString = ""; + var arrNumber = []; + for (var i = 0; i < val.length; i++) { + arrNumber.push(val[i]); + } + dataString = JSON.stringify(arrNumber); + return dataString + } + + /** + * Convert array json to Uint8Array + * + * @return Uint8Array + */ + strToU8A(val: string): Uint8Array{ + var arr = JSON.parse(val); + var tmpUint8Array = new Uint8Array(arr); + return tmpUint8Array + } + + /** + * Convert encode string to Uint8Array + * + * @return Uint8Array + */ + encodeToU8A(val: string): Uint8Array{ + var textEncoder = new util.TextEncoder(); + return textEncoder.encode(val); + } + + /** + * Register Inputer + */ + registerInputer(): boolean { + let result = false; + try { + result = this.pinAuth.registerInputer({ + onGetData: (authSubType, inputData) => { + LogUtil.info(`${this.TAG}registerInputer->onGetData pAuthSubType:${authSubType}`); + LogUtil.info(`${this.TAG}registerInputer->onGetData inAuthSubType:${this.pinSubType}`); + LogUtil.info(`${this.TAG}registerInputer->onGetData inPassword:${this.password}`); + let u8aPwd = this.encodeToU8A(this.password); + LogUtil.info(`${this.TAG}registerInputer->onGetData inputData.onSetData : encodeToU8A password:${u8aPwd}`); + inputData.onSetData(this.pinSubType, u8aPwd); + } + }); + LogUtil.info(`${this.TAG}registerInputer->result:${result}`); + if(!result){ + this.unregisterInputer(); + result = this.pinAuth.registerInputer({ + onGetData: (authSubType, inputData) => { + LogUtil.info(`${this.TAG}registerInputer->onGetData(retry) pAuthSubType:${authSubType}`); + LogUtil.info(`${this.TAG}registerInputer->onGetData(retry) inAuthSubType:${this.pinSubType}`); + LogUtil.info(`${this.TAG}registerInputer->onGetData(retry) inPassword:${this.password}`); + let u8aPwd = this.encodeToU8A(this.password); + LogUtil.info(`${this.TAG}registerInputer->onGetData(retry) inputData.onSetData : encodeToU8A password:${u8aPwd}`); + inputData.onSetData(this.pinSubType, u8aPwd); + } + }); + LogUtil.info(`${this.TAG}registerInputer->result(retry):${result}`); + } + } catch { + LogUtil.info(`${this.TAG}registerInputer failed`); + } + return result; + } + + /** + * UnregisterInputer + */ + unregisterInputer(): void { + try { + this.pinAuth.unregisterInputer(); + } catch { + LogUtil.info(`${this.TAG}unregisterInputer failed`); + } + } + + /** + * Open Session + * A challenge value of 0 indicates that opensession failed + * + * @returns challenge value + */ + openSession(callback: (challenge: string) => void): void { + try { + this.userIdentityManager.openSession((data) => { + LogUtil.info(`${this.TAG}openSession challenge:${data}`); + callback(this.u8AToStr(data)); + }) + } catch { + LogUtil.info(`${this.TAG}openSession failed`); + callback('0'); + } + } + + /** + * Close session + */ + closeSession(): void { + try { + this.userIdentityManager.closeSession() + LogUtil.info(`${this.TAG}closeSession success`); + } catch (e) { + LogUtil.info(`${this.TAG}closeSession failed:` + e); + } + } + + /** + * Cancel entry and pass in challenge value + * + * @param challenge challenge value. + */ + cancel(challenge: string): number { + let result = ResultCode.FAIL; + try { + let data = this.strToU8A(challenge); + let result = this.userIdentityManager.cancel(data) + LogUtil.info(`${this.TAG}cancel success`); + } catch (e) { + LogUtil.info(`${this.TAG}cancel failed:` + e); + } + return result; + } + + /** + * Add user credential information, pass in credential addition method and credential information + * (credential type, subclass, if adding user's non password credentials, pass in password authentication token), + * and get the result callback + * + * @param pinSubType pinSubType + * @param password password + * @param onResultCall Get results callback. + */ + addPinCredential(pinSubType: number, password: string, onResultCall: (result: number) => void): void { + try { + this.pinSubType = pinSubType; + this.password = password; + let token = new Uint8Array([]); + let credentialInfo = { + credType: AuthType.PIN, credSubType: pinSubType, token: token + } + let callback = { + onResult: (result, extraInfo) => { + LogUtil.info(`${this.TAG}addPinCredential result:${JSON.stringify(result)}, extraInfo:${JSON.stringify(extraInfo)}`); + onResultCall(result); + } + }; + this.userIdentityManager.addCredential(credentialInfo, callback); + } catch (e) { + LogUtil.info(`${this.TAG}addPinCredential failed:` + e); + } + } + + /** + * Update user credential information + * + * @param credentialInfo (credential type, subclass, password authentication token). + * @param onResult Get results callback. + */ + updateCredential(pinSubType: number, password: string, token: string, onResultCall: (result: number, extraInfo: { + credentialId?: string; + }) => void): void { + try { + this.pinSubType = pinSubType; + this.password = password; + let dataToken = this.strToU8A(token); + let credentialInfo = { + credType: AuthType.PIN, credSubType: pinSubType, token: dataToken + } + let callback = { + onResult: (result, extraInfo) => { + LogUtil.info(`${this.TAG}updateCredential result:${JSON.stringify(result)}`); + LogUtil.info(`${this.TAG}updateCredential extraInfo:${JSON.stringify(extraInfo)}`); + let retExtraInfo = {} + onResultCall(result, retExtraInfo); + } + }; + this.userIdentityManager.updateCredential(credentialInfo, callback); + } catch (e) { + LogUtil.info(`${this.TAG}updateCredential failed:` + e); + } + } + + /** + * Delete all credential information + * + * @param token Password authentication token. + * @param onResultCallback Get results callback. + */ + delAllCredential(token: string, onResultCallback: (result: number, extraInfo: {}) => void): void { + try{ + let callback = { + onResult:(result, extraInfo) => { + LogUtil.info(`${this.TAG}delAllCredential result:${JSON.stringify(result)}`); + LogUtil.info(`${this.TAG}delAllCredential extraInfo:${JSON.stringify(extraInfo)}`); + let retExtraInfo = {} + onResultCallback(result, retExtraInfo); + } + }; + let data = this.strToU8A(token); + this.userIdentityManager.delUser(data, callback); + } catch (e) { + LogUtil.info(`${this.TAG}updateCredential failed:` + e); + } + } + + /** + * Check if has pin password + * + * @param callback Get results callback. + */ + hasPinPassword(callback: (havePassword: boolean) => void): void { + this.getPinAuthInfo((data) => { + LogUtil.info(`${this.TAG}hasPinPassword->getPinAuthInfo data:${JSON.stringify(data)}`); + let passwordHasSet = false; + if(data?.length && data.length > 0){ + passwordHasSet = true; + } + LogUtil.info(`${this.TAG}hasPinPassword->getPinAuthInfo : before callback: passwordHasSet = ${passwordHasSet}`); + callback(passwordHasSet) + }); + } + + /** + * Get AuthInfo + * + * @param authType Credential type. + * @returns Returns all registered credential information of this type for the current user + */ + getPinAuthInfo(callback: (data: Array<{ + authType: number; + authSubType: number; + }>) => void): void { + try { + this.userIdentityManager.getAuthInfo(AuthType.PIN, (data) => { + LogUtil.info(`${this.TAG}getPinAuthInfo->getAuthInfo data:${JSON.stringify(data)}`); + let arrCredInfo = []; + try{ + for(let i = 0; i < data.length; i++) { + let credInfo = { + 'authType': data[i].authType, + 'authSubType': data[i].authSubType + }; + arrCredInfo.push(credInfo); + } + } catch(e) { + console.info('faceDemo pin.getAuthInfo error = ' + e); + } + LogUtil.info(`${this.TAG}getPinAuthInfo->getAuthInfo before callback: data array:${JSON.stringify(arrCredInfo)}`); + callback(arrCredInfo); + }) + } catch (e) { + LogUtil.info(`${this.TAG}getPinAuthInfo failed:` + e); + } + } + + /** + * Auth + * + * @param challenge pass in challenge value. + * @param password password + * @param onResult Return results through callback. + */ + authPin(challenge: string, password: string, onResult: (result: number, extraInfo: { + token?: string; + remainTimes?: number; + freezingTime?: number; + }) => void): void { + this.password = password; + try { + LogUtil.info(`${this.TAG}authPin : ( ${challenge}, ${AuthType.PIN}, ${AuthTrustLevel.ATL4} )`); + this.userAuth.auth(this.strToU8A(challenge), AuthType.PIN, AuthTrustLevel.ATL4, { + onResult: (result, extraInfo) => { + try{ + LogUtil.info(`${this.TAG}userAuth.auth onResult: challenge = ${challenge}, result:${result}, extraInfo:${extraInfo}`); + let info + if (result === ResultCode.SUCCESS) { + LogUtil.info(`${this.TAG}userAuth.auth onResult: result = success`); + info = { + 'token': this.u8AToStr(extraInfo?.token), + 'remainTimes': extraInfo?.remainTimes, + 'freezingTime': extraInfo?.freezingTime + } + } else { + LogUtil.info(`${this.TAG}userAuth.auth onResult: result = failed`); + } + onResult(result, info) + } + catch(e) { + LogUtil.info(`${this.TAG}userAuth.auth onResult error = ${JSON.stringify(e)}`); + } + }, + + onAcquireInfo: (acquireModule, acquire, extraInfo) => { + try{ + LogUtil.info(this.TAG + 'faceDemo pin.auth onAcquireInfo acquireModule = ' + acquireModule); + console.info(this.TAG + 'faceDemo pin.auth onAcquireInfo acquire = ' + acquire); + LogUtil.info(this.TAG + 'faceDemo pin.auth onAcquireInfo extraInfo = ' + JSON.stringify(extraInfo)); + } + catch(e) { + LogUtil.info(this.TAG + 'faceDemo pin.auth onAcquireInfo error = ' + e); + } + } + }) + + } catch (e) { + LogUtil.info(`${this.TAG}AuthPin failed:` + e); + } + } + + /** + * getProperty + * + * @param callback Return results through callback. + */ + getAuthProperty(callback: (data: { + result: number; + authSubType: number; + remainTimes ?: number; + freezingTime ?: number; + }) => void): void { + try { + let request = { + 'authType': AuthType.PIN, + 'keys': [GetPropertyType.AUTH_SUB_TYPE, GetPropertyType.REMAIN_TIMES, GetPropertyType.FREEZING_TIME] + } + LogUtil.info(`${this.TAG}getAuthProperty->call api request = ${JSON.stringify(request)}`); + + this.userAuth.getProperty(request) + .then((data)=> { + let i = JSON.stringify(data); + console.info('faceDemo promise.getProperty result i = ' + i); + console.info('faceDemo promise.getProperty result = ' + data); + + LogUtil.info(`${this.TAG}getAuthProperty->getProperty data:${JSON.stringify(data)}`); + callback(data); + }) + .catch(e =>{ + LogUtil.info(`${this.TAG}getAuthProperty->getProperty failed:` + e); + }); + } catch (e) { + LogUtil.info(`${this.TAG}getAuthProperty failed:` + e); + } + }; +} + +let passwordModel = new PasswordModel(); +export default passwordModel as PasswordModel; \ No newline at end of file diff --git a/product/phone/src/main/ets/default/model/restoreFactorySettingsImpl/RestoreFactorySettingsModel.ets b/product/phone/src/main/ets/default/model/restoreFactorySettingsImpl/RestoreFactorySettingsModel.ets new file mode 100644 index 00000000..4db66c38 --- /dev/null +++ b/product/phone/src/main/ets/default/model/restoreFactorySettingsImpl/RestoreFactorySettingsModel.ets @@ -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 BaseModel from '../../../../../../../../common/utils/src/main/ets/default/model/BaseModel.ets'; +import Updater from '@ohos.update'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; + +/** + * Restore factorySettings model + */ +@LogAll +export class RestoreFactorySettingsModel extends BaseModel { + + + /** + * Reboot and clean userData + */ + rebootAndCleanUserData(callback?: (value) => void) { + Updater.getUpdater('/data/updater/updater.zip', 'OTA').rebootAndCleanUserData().then((value) => { + LogUtil.log(ConfigData.TAG + "rebootAndCleanUserData value:" + value) + }) + } +} + +let restoreFactorySettingsModel = new RestoreFactorySettingsModel(); + +export default restoreFactorySettingsModel as RestoreFactorySettingsModel +; \ No newline at end of file diff --git a/product/phone/src/main/ets/default/model/search/DummyProvider.ets b/product/phone/src/main/ets/default/model/search/DummyProvider.ets new file mode 100644 index 00000000..2cf2da80 --- /dev/null +++ b/product/phone/src/main/ets/default/model/search/DummyProvider.ets @@ -0,0 +1,60 @@ +/** + * 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 Log from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import PageSearchDataProvider from '../../../../../../../../common/search/src/main/ets/default/provider/PageSearchDataProvider.ets'; +import WifiModel from '../../model/wifiImpl/WifiModel.ets'; + +const SEARCH_DATA = { + title: $r('app.string.wifiTab'), + data: [ + { + keyword: $r('app.string.wifiTab'), + summary: $r('app.string.tipsContent'), + synonym: $r('app.string.wifiSynonym') + } + ] +}; + +/** + * Dummy provider as an example, and should be removed in the further. + * + */ +export class DummyProvider extends PageSearchDataProvider { + + /** + * Get page search data + */ + @Log + getPageSearchData(): any { + let searchData = SEARCH_DATA + + if (WifiModel.isWiFiActive()) { + searchData.data.push( + { + keyword: $r('app.string.wifiList'), + summary: undefined, + synonym: $r('app.string.wifiListSynonym') + } + ) + } + + return searchData; + } + +} + +let dummyProvider = new DummyProvider(); +export default dummyProvider as DummyProvider +; \ No newline at end of file diff --git a/product/phone/src/main/ets/default/model/search/SearchDataConfig.ets b/product/phone/src/main/ets/default/model/search/SearchDataConfig.ets new file mode 100644 index 00000000..75944943 --- /dev/null +++ b/product/phone/src/main/ets/default/model/search/SearchDataConfig.ets @@ -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 SettingListProvider from '../../model/settingListImpl/SettingListProvider.ets'; +import WifiProvider from '../../model/wifiImpl/WifiProvider.ets'; +import DummyProvider from './DummyProvider.ets'; + +/** + * Search data config + */ +const SEARCH_DATA_CONFIG = [ + { + settingUri: 'pages/settingList', + settingRawJson: 'settinglist.json', + provider: SettingListProvider + }, + { + settingUri: 'pages/wifi', + settingRawJson: 'wifi.json', + provider: WifiProvider + }, + // DummyProvider as example, and should be removed in the further. + { + settingUri: 'pages/wifi', + settingRawJson: 'wifi.json', + provider: DummyProvider + } +]; + +export default SEARCH_DATA_CONFIG; diff --git a/entry/src/main/ets/default/model/settingListImpl/SettingListModel.ets b/product/phone/src/main/ets/default/model/settingListImpl/SettingListModel.ets similarity index 80% rename from entry/src/main/ets/default/model/settingListImpl/SettingListModel.ets rename to product/phone/src/main/ets/default/model/settingListImpl/SettingListModel.ets index af3bbd13..c2d0eba8 100644 --- a/entry/src/main/ets/default/model/settingListImpl/SettingListModel.ets +++ b/product/phone/src/main/ets/default/model/settingListImpl/SettingListModel.ets @@ -12,10 +12,10 @@ * 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 ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import BaseParseConfModel from '../../../../../../../../common/utils/src/main/ets/default/model/BaseParseConfModel.ets'; +import BaseModel from '../../../../../../../../common/utils/src/main/ets/default/model/BaseModel.ets'; import FeatureAbility from '@ohos.ability.featureAbility'; import WifiModel from '../wifiImpl/WifiModel.ets'; import AbilityInfoModel from '../abilityInfoImpl/AbilityInfoModel.ets'; @@ -82,7 +82,7 @@ export class SettingListModel extends BaseModel { for (let key in settingsList) { let settingAlias = settingsList[key].settingAlias; let value; - let wifiStatus = WifiModel.getWifiStatus(); + let wifiStatus = WifiModel.isWiFiActive(); if ('wifiTab' === settingAlias) { value = $r('app.string.wifiTab'); if (wifiStatus) { @@ -90,9 +90,10 @@ export class SettingListModel extends BaseModel { } else { settingsList[key].settingValue = $r('app.string.disabled'); } - } - else if ('brightnessTab' === settingAlias) { + } else if ('brightnessTab' === settingAlias) { value = $r('app.string.brightnessTab'); + } else if ('biometricsAndPasswordTab' === settingAlias) { + value = $r('app.string.biometricsAndPassword'); } else if ('applyTab' === settingAlias) { value = $r('app.string.applyTab'); } else if ('dateAndTimeTab' === settingAlias) { @@ -101,6 +102,18 @@ export class SettingListModel extends BaseModel { value = $r('app.string.aboutTab'); } else if ('volumeControlTab' === settingAlias) { value = $r('app.string.volumeControlTab'); + } else if ('developerOptionsTab' === settingAlias) { + value = $r('app.string.developerOptionsTab'); + } else if ('restoreFactoryTab' === settingAlias) { + value = $r('app.string.restoreFactoryTab'); + } else if('usersAccountsTab' == settingAlias) { + value = $r("app.string.usersAccountsTab"); + } else if ('systemTab' === settingAlias) { + value = $r('app.string.systemTab'); + } else if ('privacyTab' === settingAlias) { + value = $r('app.string.privacy'); + } else if ('storageTab' === settingAlias) { + value = $r('app.string.storageTab'); } settingsList[key].settingTitle = value; } diff --git a/product/phone/src/main/ets/default/model/settingListImpl/SettingListProvider.ets b/product/phone/src/main/ets/default/model/settingListImpl/SettingListProvider.ets new file mode 100644 index 00000000..3ec9d696 --- /dev/null +++ b/product/phone/src/main/ets/default/model/settingListImpl/SettingListProvider.ets @@ -0,0 +1,38 @@ +/** + * 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 Log from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import PageSearchDataProvider from '../../../../../../../../common/search/src/main/ets/default/provider/PageSearchDataProvider'; + +const SEARCH_DATA = { + data: [] +}; + +/** + * Search data provider for settings list + */ +export class SettingListProvider extends PageSearchDataProvider { + + /** + * Get page search data + */ + @Log + getPageSearchData(): any { + return SEARCH_DATA; + } +} + +let settingListProvider = new SettingListProvider(); +export default settingListProvider as SettingListProvider +; \ No newline at end of file diff --git a/product/phone/src/main/ets/default/model/storageImpl/StorageModel.ets b/product/phone/src/main/ets/default/model/storageImpl/StorageModel.ets new file mode 100644 index 00000000..bd21e74f --- /dev/null +++ b/product/phone/src/main/ets/default/model/storageImpl/StorageModel.ets @@ -0,0 +1,62 @@ +/** + * 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 '../../../../../../../../common/utils/src/main/ets/default/model/BaseModel.ets'; +import {LogAll} from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import BaseParseConfModel from '../../../../../../../../common/utils/src/main/ets/default/model/BaseParseConfModel.ets'; +import storage from '@ohos.statfs'; +import Environment from '@ohos.environment' + +/** + * read local file + */ +@LogAll +export class StorageModel extends BaseModel { + + /** + * Get Storage ItemList + */ + getStorageItemList(): any[] { + return BaseParseConfModel.getJsonData(ConfigData.FILE_URI.concat('storage.json')); + } + + /** + * Get storage dataDir + */ + getStorageDataDir(callback){ + Environment.getStorageDataDir(callback); + } + + /** + * get TotalSpace + */ + getTotalSpace(storageDataDir, callback){ + storage.getTotalBytes(storageDataDir, callback); + } + + /** + * get FreeBytes + */ + getFreeBytes(storageDataDir, callback){ + storage.getFreeBytes(storageDataDir, callback); + } + +} + +let storageModel = new StorageModel(); + +export default storageModel as StorageModel +; \ No newline at end of file diff --git a/product/phone/src/main/ets/default/model/systemImpl/languageSettings/LanguageAndRegionModel.ets b/product/phone/src/main/ets/default/model/systemImpl/languageSettings/LanguageAndRegionModel.ets new file mode 100644 index 00000000..3a9bc08f --- /dev/null +++ b/product/phone/src/main/ets/default/model/systemImpl/languageSettings/LanguageAndRegionModel.ets @@ -0,0 +1,223 @@ +/** + * 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 i18n from '@ohos.i18n'; +import data_storage from '@ohos.data.storage'; +import LogUtil from '../../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import BaseModel from '../../../../../../../../../common/utils/src/main/ets/default/model/BaseModel.ets'; +import ConfigData from '../../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import Log from '../../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; + +/** + * Language And Region Model + */ +class LanguageAndRegionModel extends BaseModel { + private addedLanguages: Array = []; + private allLanguages: Array = []; + private addStr = ConfigData.ADDLANGUAGES; + private regionStr = ConfigData.CURRENTREGION; + private storage = data_storage.getStorageSync(ConfigData.STORAGEPATH + '/languageAndRegion'); + private TAG = `${ConfigData.TAG} LanguageAndRegionModel`; + + constructor(){ + super(); + LogUtil.info(`${this.TAG} init in`); + this.initAppStorage(); + LogUtil.info(`${this.TAG} init sucess`); + } + +/** + * Get added languages + */ + @Log + getAddedLanguages():Array{ + LogUtil.info(`${this.TAG} getAddedLanguages`); + return AppStorage.Get(this.addStr); + } + +/** + * Get all languages + */ + @Log + getAllLanguages():Array{ + LogUtil.info(`${this.TAG} getAllLanguages`); + return i18n.getSystemLanguages(); + } + +/** + * Init App Storage + */ + @Log + initAppStorage():void{ + LogUtil.info(`${this.TAG} initAppStorage in`); + if(!this.storage.hasSync(this.addStr)){ + LogUtil.info(`${this.TAG} initStorage addStr`); + this.storage.putSync(this.addStr, JSON.stringify([i18n.getSystemLanguage()])) + this.storage.flushSync(); + LogUtil.info(`${this.TAG} initStorage addStr sucess`); + } + + if(!AppStorage.Has(this.addStr)){ + LogUtil.info(`${this.TAG} initAppStorage addedLanguage`); + AppStorage.SetOrCreate(this.addStr, JSON.parse(this.storage.getSync(this.addStr, 'fail' )) ); + LogUtil.info(`${this.TAG} initAppStorage addedLanguage sucess`); + } + + if(!AppStorage.Has(this.regionStr)){ + LogUtil.info(`${this.TAG} initAppStorage currentRegion`); + AppStorage.SetOrCreate(this.regionStr, this.getSysDisplayRegion()); + LogUtil.info(`${this.TAG} initAppStorage currentRegion sucess`); + } + LogUtil.info(`${this.TAG} initAppStorage out`); + return; + } + +/** + * Set system language + */ + @Log + setSystemLanguage(language:string):void{ + LogUtil.info(`${this.TAG} setSystemLanguage in`); + this.addedLanguages = this.getAddedLanguages(); + this.addedLanguages.splice(this.addedLanguages.indexOf(language), 1); + this.addedLanguages.unshift(language); + i18n.setSystemLanguage(language); + AppStorage.Set(this.regionStr, this.getSysDisplayRegion()); + AppStorage.Set(this.addStr, this.addedLanguages); + this.storage.putSync(this.addStr, JSON.stringify(AppStorage.Get(this.addStr))); + this.storage.flushSync(); + LogUtil.info(`${this.TAG} setSystemLanguage sucess`); + return; + } + +/** + * Add language to the addedLanguages list + */ + @Log + addLanguage(language:string):void{ + LogUtil.info(`${this.TAG} addLanguage in, language: ${language}` ); + this.addedLanguages = AppStorage.Get(this.addStr); + this.addedLanguages.push(language); + AppStorage.Set(this.addStr, this.addedLanguages); + this.storage.putSync(this.addStr, JSON.stringify(AppStorage.Get(this.addStr))); + this.storage.flushSync(); + LogUtil.info(`${this.TAG} addLanguage sucess`); + return; + } + +/** + * Remove language from the addedLanguages list + */ + @Log + deleteLanguage(language:string):void{ + LogUtil.info(`${this.TAG} deleteLanguage in`); + this.addedLanguages = AppStorage.Get(this.addStr); + this.addedLanguages.splice(this.addedLanguages.indexOf(language), 1); + this.setSystemLanguage(this.addedLanguages[0]); + AppStorage.Set(this.addStr, this.addedLanguages); + this.storage.putSync(this.addStr, JSON.stringify(AppStorage.Get(this.addStr))); + this.storage.flushSync(); + LogUtil.info(`${this.TAG} deleteLanguage sucess`); + return; + } + +/** + * Display in the system language + */ + @Log + getSysDisplayLanguage(language:string){ + LogUtil.info(`${this.TAG} getSysDisplayLanguage`); + return i18n.getDisplayLanguage(language, i18n.getSystemLanguage(), true); + } + +/** + * Display the language + */ + @Log + getDisplayLanguage(language:string):string{ + LogUtil.info(`${this.TAG} getDisplayLanguage`); + return i18n.getDisplayLanguage(language, language, true); + } + +/** + * Display the region + */ + @Log + getDisplayRegion(country:string):string{ + LogUtil.info(`${this.TAG} getDisplayRegion`); + return i18n.getDisplayCountry(country, i18n.getSystemLanguage(),true); + } + +/** + * Display the system region + */ + @Log + getSysDisplayRegion():string{ + LogUtil.info(`${this.TAG} getSysDisplayRegion`); + return i18n.getDisplayCountry(i18n.getSystemRegion(), i18n.getSystemLanguage(),true); + } + +/** + * get system countries + */ + @Log + getSystemCountries():Array{ + LogUtil.info(`${this.TAG} getSystemCountries`); + return i18n.getSystemCountries(i18n.getSystemLanguage()); + } + +/** + * set system region + */ + @Log + setSystemRegion(region:string):void{ + LogUtil.info(`${this.TAG} setSystemRegion`); + i18n.setSystemRegion(region); + AppStorage.Set(this.regionStr, this.getSysDisplayRegion()); + return; + } + +/** + * Determine if it is the system language + */ + @Log + isSystemLanguage(language:string):boolean{ + return language === i18n.getSystemLanguage(); + } + +/** + * Determine if it is in the addedLanguages + */ + @Log + isInAddedLanguage(language:string):boolean{ + this.addedLanguages = AppStorage.Get(this.addStr); + if(this.addedLanguages.indexOf(language) === -1){ + return false; + }else{ + return true; + } + } + +/** + * Determine if it is the system region + */ + @Log + isSystemRegion(region:string):boolean{ + return region === i18n.getSystemRegion(); + } + +} + +let languageAndRegionModel = new LanguageAndRegionModel(); +export default languageAndRegionModel as LanguageAndRegionModel; \ No newline at end of file diff --git a/product/phone/src/main/ets/default/model/usersAndAccounts/SystemAccountController.ets b/product/phone/src/main/ets/default/model/usersAndAccounts/SystemAccountController.ets new file mode 100644 index 00000000..a839ec39 --- /dev/null +++ b/product/phone/src/main/ets/default/model/usersAndAccounts/SystemAccountController.ets @@ -0,0 +1,216 @@ +// @ts-nocheck +/** + * 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 account_osAccount from '@ohos.account.osAccount'; +import featureAbility from '@ohos.ability.featureAbility'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import GlobalResourceManager from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/GlobalResourceManager.ets'; +import SystemAccountModel from './systemAccountModel.ets' + +export class SystemAccountController { + private currentAccount: account_osAccount.OsAccountInfo; + private accountList: account_osAccount.OsAccountInfo[] = []; + + constructor() { + } + + /** + * Get all created system account name. + */ + async refreshSystemAccountList() { + LogUtil.info("Refresh system account list."); + AppStorage.SetOrCreate("systemAccoutList", []); + this.accountList = await account_osAccount.getAccountManager().queryAllCreatedOsAccounts(); + LogUtil.info("before sort account list, length: " + this.accountList.length + ", list: " + JSON.stringify(this.accountList)); + this.currentAccount = SystemAccountModel.getCurrentAccount(this.accountList); + LogUtil.info("Current account localId: " + this.currentAccount.localId); + this.accountList.sort(SystemAccountModel.sortAccount.bind(this)); + LogUtil.info("Successfully sort account list, length: " + this.accountList.length); + AppStorage.SetOrCreate("systemAccoutList", this.accountList); + AppStorage.SetOrCreate("isShowAddUser", this.isShowAddUser()); + AppStorage.SetOrCreate("isShowAddGuest", this.isShowAddQuest()); + AppStorage.SetOrCreate("isShowDelete",!this.isCurrentAdministrator()); + } + + /** + * Whether to show system account type. + * + * @return true if current account is administrator. + */ + isShowIdentity(accountInfo) { + return accountInfo.type.ADMIN == 0; + } + + /** + * Whether to show add normal user item. + * + * @return true if current user is administrator. + */ + isShowAddUser() { + return this.currentAccount.type.ADMIN == 0; + } + + /** + * Whether to show add create normal account list item. + * + * @return true when created account list no contains quest account. + */ + isShowAddQuest() { + for (let index = 0; index < this.accountList.length; index++) { + LogUtil.info("Is show add quest, system account type: " + this.accountList[index].type); + if (this.accountList[index].type.GUEST == 2) { + return false; + } + } + return true; + } + + /** + * Whether is current system account. + * + * @return true when clicked item is system account. + */ + isCurrentUser(accountInfo: account_osAccount.OsAccountInfo) { + LogUtil.info("Is current user, account id: " + accountInfo.localId); + return accountInfo.localId == this.currentAccount.localId; + } + + /** + * Whether current account is administrator type. + * + * @return true when current account type is administrator. + */ + isCurrentAdministrator() { + LogUtil.info("Is current user administrator.") + return this.currentAccount.type.ADMIN == 0; + } + + /** + * Whether current account is quest type. + * + * @return true when current account type is quest. + */ + isCurrentQuest() { + return this.currentAccount.type.GUEST == 2; + } + + /** + * Whether the account is quest. + * + * @param account input system account. + */ + isGuestAccount(account: account_osAccount.OsAccountInfo) { + return account.type.GUEST == 2; + } + + /** + * Get new created account. + * + * @return the local id of newly created system account. + */ + switchToCreatedAccount(): number { + this.accountList.sort((account1, account2) => { + return account2.serialNumber - account1.serialNumber; + }); + let newlyId = this.accountList[0].localId; + LogUtil.info("Newly created local id: " + newlyId); + this.switchUser(newlyId); + } + + /** + * Create the quest system account. + */ + async createQuest() { + LogUtil.info("Create quest account."); + let localName = GlobalResourceManager.getStringByResource($r("app.string.quest")); + localName.then(name => { + account_osAccount.getAccountManager().createOsAccount(name, 2).then(() => { + LogUtil.info("Create quest system account."); + this.refreshSystemAccountList(); + }); + }) + } + + /** + * Create the normal system account. + * + * @param localName create name of normal system account. + */ + async createSystemAccount(localName: string) { + LogUtil.info("Create system account."); + account_osAccount.getAccountManager().createOsAccount(localName, 1).then(accountInfo => { + this.refreshSystemAccountList(); + }); + } + + /** + * To set the system account name. + * + * @param localId local id of system account. + * @param name name of system account. + */ + async setAccountName(localId: number, name: string) { + LogUtil.info("Set system account name."); + account_osAccount.getAccountManager().setOsAccountName(localId, name).then(() => { + this.refreshSystemAccountList(); + }); + } + + /** + * Switch to other system account. + * + * @param localId local id of object system account. + */ + switchUser(localId: number) { + LogUtil.info("Switch system account."); + account_osAccount.getAccountManager().activateOsAccount(localId).then(() => { + LogUtil.info("Successfully switched to account: " + localId); + this.refreshSystemAccountList(); + setTimeout(this.startLockScreenAbility(), 500); + }); + } + + /** + * Remove system account by local id. + * + * @param localId local id of this system account, if not set, set it current local id. + */ + async removeAccount(localId?: number) { + let removeId = localId ? localId : this.currentAccount.localId; + LogUtil.info("Remove system account, local Id: " + removeId); + account_osAccount.getAccountManager().removeOsAccount(removeId); + this.refreshSystemAccountList(); + } + + private startLockScreenAbility() { + var abilityParam = { + "want": { + "bundleName": "com.ohos.screenlock", + "abilityName": "com.ohos.screenlock.MainAbility" + }, + "abilityStartSetting": {} + }; + featureAbility.startAbility(abilityParam) + .then((data) => { + console.info('Start lockscreen successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.error('Start lockscreen failed. Cause: ' + JSON.stringify(error)); + }) + } +} + +let systemAccountController = new SystemAccountController(); +export default systemAccountController as SystemAccountController; diff --git a/product/phone/src/main/ets/default/model/usersAndAccounts/systemAccountModel.ets b/product/phone/src/main/ets/default/model/usersAndAccounts/systemAccountModel.ets new file mode 100644 index 00000000..3dc8792a --- /dev/null +++ b/product/phone/src/main/ets/default/model/usersAndAccounts/systemAccountModel.ets @@ -0,0 +1,95 @@ +// @ts-nocheck +/** + * 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 account_osAccount from '@ohos.account.osAccount'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; + +export class SystemAccoutModel { + /** + * Get current account name and do callback. + * + * @param callback related callback when current system account is obtained. + */ + updateAccountName(callback: (name: string) => void) { + LogUtil.info("Update account name."); + account_osAccount.getAccountManager().queryAllCreatedOsAccounts().then(list => { + let info = this.getCurrentAccount(list); + LogUtil.info("Current os name: " + info.localName); + callback(info.localName); + }); + } + + /** + * Get current account name from created account list. + * + * @param accountList created system account list. + */ + getCurrentAccount(accountList: account_osAccount.OsAccountInfo[]): account_osAccount.OsAccountInfo { + for (let index = 0; index < accountList.length; index++) { + if (accountList[index].isActived) { + return accountList[index]; + } + } + return {}; + } + + /** + * Sort the account info list according to following rules: + * 1. If this account is current user, then put it first. + * 2. If this administrator, then place it after the current user. + * 2. If this account is quest user, then put it last. + * 3. If this account is normal user, place it in chronological order of creation. + * + * @param info1 input param 1. + * @param info2 input param 2. + */ + sortAccount(info1: account_osAccount.OsAccountInfo, info2: account_osAccount.OsAccountInfo): number { + if (info1.localId == this.currentAccount.localId || info2.localId == this.currentAccount.localId) { + LogUtil.info("Sort current account, info: " + info1.localName); + return info1.localId == this.currentAccount.localId ? -1 : 1; + } else if (info1.type.ADMIN == 0 || info2.type.ADMIN == 0) { + LogUtil.info("Sort administrator account, info: " + info1.localName); + return info1.type.ADMIN == 0 ? -1 : 1; + } else if ( info1.type.GUEST == 2 || info2.type.GUEST == 2) { + LogUtil.info("Sort quest account, info: " + info1.localName); + return info1.type.GUEST == 2 ? 1 : -1; + } else { + return info2.localId - info1.localId; + } + } + + /** + * Get identity from account info type. + * + * @param type int type, like admin, quest. + * @return identity string of different account type. + */ + getIdentityFromMap(accountType: account_osAccount.OsAccountType): string | Resource { + LogUtil.info("Get identity from map, type: " + JSON.stringify(accountType)); + if (accountType.ADMIN == 0) { + return $r("app.string.administrator"); + } else if (accountType.NORMAL == 1) { + return ""; + } else if (accountType.GUEST == 2) { + return $r("app.string.quest"); + } else { + LogUtil.info("Unknown system account type.") + return "未知用户"; + } + } +} + +let systemAccountModel = new SystemAccoutModel(); +export default systemAccountModel as SystemAccoutModel; \ No newline at end of file diff --git a/product/phone/src/main/ets/default/model/volumeControlImpl/VolumeControlModel.ets b/product/phone/src/main/ets/default/model/volumeControlImpl/VolumeControlModel.ets new file mode 100644 index 00000000..60d2e3d9 --- /dev/null +++ b/product/phone/src/main/ets/default/model/volumeControlImpl/VolumeControlModel.ets @@ -0,0 +1,155 @@ +/** + * 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 '../../../../../../../../common/utils/src/main/ets/default/model/BaseModel.ets'; +import LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import Log from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import Audio from '@ohos.multimedia.audio'; +import settings from '@ohos.settings'; +import featureAbility from '@ohos.ability.featureAbility'; + +export class VolumeModel extends BaseModel{ + private dataAbilityHelper; + private urivar:string; + private settingsDataKey:string; + private volume:number = 150; + private defaultVolumeStr = '150'; + private volumeType; + private str2Enum = { + 'settings.audio.ringtone': Audio.AudioVolumeType.RINGTONE, + 'settings.audio.media': Audio.AudioVolumeType.MEDIA, + 'settings.audio.voicecall': Audio.AudioVolumeType.VOICE_CALL + } + private TAG = ConfigData.TAG + 'VolumeModel '; + + constructor(settingsDataKey:string){ + super(); + this.settingsDataKey = settingsDataKey; + this.volumeType = this.str2Enum[this.settingsDataKey]; + this.urivar = settings.getUri(this.settingsDataKey); + this.dataAbilityHelper = featureAbility.acquireDataAbilityHelper(this.urivar); + this.updateValue(); + } + + /** + * Get volume value in the VolumeModel + */ + @Log + public getValue(){ + return this.volume; + } + + /** + * Set value + */ + @Log + public setValue(volume:number, sliderChangeMode:number){ + if(sliderChangeMode === ConfigData.SLIDER_CHANG_MODE_END){ + LogUtil.info(this.TAG + `setValue [volume:${volume}, sliderChangeMode:${sliderChangeMode}]`); + this.setSettingsData(volume); + }else{ + this.setSystemVolume(volume); + } + return; + } + + /** + * Set the volume value in the SettingsData + */ + @Log + private setSettingsData(volume:number){ + LogUtil.info(this.TAG + `setSettingsData [type:${this.volumeType}, value:${volume}]`); + this.volume = volume; + settings.setValue(this.dataAbilityHelper, this.settingsDataKey, volume.toString()); + LogUtil.info(this.TAG + `setSettingsData [type:${this.volumeType}, value:${volume}] success`); + return; + } + + /** + * Set the system volume value + */ + @Log + private setSystemVolume(volume:number){ + this.volume = volume; + Audio.getAudioManager().setVolume(this.volumeType, volume).then(() => { + }); + return; + } + + /** + * Update the volume value in the VolumeModel + */ + @Log + private updateValue(){ + LogUtil.info(this.TAG + 'updateValue'); + this.volume = parseInt(settings.getValue(this.dataAbilityHelper, this.settingsDataKey, this.defaultVolumeStr)); + LogUtil.info(this.TAG + `updateValue success, [volume:${this.volume}]`); + return; + } + + /** + * Register observer + */ + @Log + public registerObserver(){ + LogUtil.info(this.TAG + 'registerObserver'); + this.dataAbilityHelper.on("dataChange", this.urivar, (err)=>{ + this.updateValue(); + }) + LogUtil.info(this.TAG + 'registerObserver success'); + return; + } + + /** + * Unregister observer + */ + @Log + public unregisterObserver() { + LogUtil.info(this.TAG + 'unregisterObserver'); + this.dataAbilityHelper.off("dataChange", this.urivar, (err)=>{ + LogUtil.info(this.TAG + 'unregisterObserver success'); + }) + return; + } +} + +export class RingerModel extends BaseModel{ + private TAG = ConfigData.TAG + 'RingerModel '; + + /** + * Set volume ringer volume + */ + @Log + public setRingerMode(audioRingMode/* AudioRingMode */, callback: (value: number) => void) { + Audio.getAudioManager().setRingerMode(audioRingMode).then(() => { + LogUtil.info(this.TAG + `setRingerMode [mode:${audioRingMode}] success`); + callback(audioRingMode); + }); + return; + } + + /** + * Get volume ringer volume + */ + @Log + public getRingerMode(callback: (value: number) => void) { + Audio.getAudioManager().getRingerMode().then((value/*AudioRingMode*/) => { + LogUtil.info(this.TAG + `getRingerMode success : value = ${value}`); + callback(value); + }) + return; + } +} + diff --git a/product/phone/src/main/ets/default/model/wifiImpl/WifiModel.ets b/product/phone/src/main/ets/default/model/wifiImpl/WifiModel.ets new file mode 100644 index 00000000..3cb8730d --- /dev/null +++ b/product/phone/src/main/ets/default/model/wifiImpl/WifiModel.ets @@ -0,0 +1,381 @@ +/** + * 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/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import WifiNativeJs from '@ohos.wifi_native_js'; +import BaseModel from '../../../../../../../../common/utils/src/main/ets/default/model/BaseModel.ets'; +import settings from '@ohos.settings'; +import featureAbility from '@ohos.ability.featureAbility' + +const MODULE_TAG = ConfigData.TAG + '.WifiModel -> '; + +export class ApScanResult { + private apInfo = { + ssid:'', + bssid: '', + rssi: -100, + band: 0, + frequency: 0, + timestamp: 0, + securityType: 1, + }; + private summary: string = ''; + private connectFlag: boolean = false; + + constructor(apInfo?: any); + + constructor(apInfo: any) { + if (apInfo === null || apInfo === undefined) { + return; + } + this.apInfo = apInfo; + }; + + getApInfo() { + return this.apInfo; + } + + getSSID() { + return this.apInfo.ssid; + } + + getSignalLevel(): number { + return WifiNativeJs.getSignalLevel(this.apInfo.rssi, this.apInfo.band);; + } + + isConnected() : boolean { + return (this.connectFlag === true); + } + + setConnectStatus(status: boolean) { + this.connectFlag = status; + } + + updateSummary(summary: string) { + this.summary = summary; + } + + getSummary(): string { + return this.summary; + } + + isSecurityAp(): boolean { + // WiFiSecurityType is enum from 0 to 4, 0 is `Invalid`, 1 is `Open`, 2 to 4 is `Encrypted` + return (this.apInfo.securityType !== 1); + } + + isValidAp() : boolean { + // no ssid or signal level 0 is invalid + return (this.apInfo.ssid !== '' && this.getSignalLevel() != 0); + } + + renderToListModel(): any { + function generateArrow(that: ApScanResult): string { + let signalLevle: string = that.getSignalLevel().toString(); + let lockPrefix: string = 'lock_'; + // connected and not encrypted connection do not add lock on icon + if (that.isSecurityAp() !== true || that.isConnected() === true) { + lockPrefix = ''; + } + let result: string = `/res/image/ic_wifi_${lockPrefix}signal_${signalLevle}_dark.svg`; + return result; + } + + let ret = { + settingIcon: '', + settingSummary: this.summary, + settingTitle: this.apInfo.ssid, + settingValue: '', + settingArrow: generateArrow(this), + settingArrowStyle: 'wifi', + settingUri: '', + apInfo: this.apInfo, + }; + return ret; + } + + toString(): string { + return JSON.stringify(this.apInfo); + } + + static compare(x: ApScanResult, y: ApScanResult): number { + let xApInfo = x.getApInfo(); + let yApInfo = y.getApInfo(); + // rssi value is negative number + return ((-xApInfo.rssi) - (-yApInfo.rssi)); + } + + static filter(arr: ApScanResult[]): ApScanResult[] { + let hash = {}; + return arr.reduce((total, currItem) => { + if (!hash[currItem.getSSID()]) { + hash[currItem.getSSID()] = true; + total.push(currItem); + } + return total; + }, []); + } + + static index(arr: ApScanResult[], target: ApScanResult): number { + return arr.map((item) => { + return item.getSSID(); + }).indexOf(target.getSSID()); + } +} + +export class WifiModel extends BaseModel { + public wiFiStatusEnum = { + 'Connecting': 1, + 'UnknownState': 3, + 'ApConnected': 4, + 'Disconnecting': 5, + 'Disconnected': 6, + }; + private userSelectedAp: ApScanResult = new ApScanResult(); + private apScanResults: ApScanResult[] = []; + private scanIntervalId: number = -1; + private scanStatus: boolean = false; + + setUserSelectedAp(apInfo?: any) { + if (apInfo === null || typeof apInfo === 'undefined') { + this.userSelectedAp = new ApScanResult(); + } + LogUtil.info(MODULE_TAG + "set user selected apInfo is : " + JSON.stringify(apInfo)); + this.userSelectedAp = new ApScanResult(apInfo); + } + + getUserSelectedAp(): ApScanResult { + return this.userSelectedAp; + } + + isWiFiActive(): boolean { + const isActive: boolean = WifiNativeJs.isWifiActive(); + LogUtil.info(MODULE_TAG + 'check WiFi active status is : ' + isActive); + return isActive; + } + + enableWiFi(): boolean { + const ret: boolean = WifiNativeJs.enableWifi(); + LogUtil.info(MODULE_TAG + 'enable WiFi result is : ' + ret); + return ret; + } + + disableWifi(): boolean { + this.setUserSelectedAp(null); + const ret: boolean = WifiNativeJs.disableWifi(); + LogUtil.info(MODULE_TAG + 'disable WiFi result is : ' + ret); + return ret; + } + + scanWiFi(): boolean { + const ret: boolean = WifiNativeJs.scan(); + LogUtil.info(MODULE_TAG + 'start scan WiFi result is : ' + ret); + return ret; + } + + connectWiFi(password: string) { + let apInfo = this.getPrimaryApInfo().getApInfo(); + let obj: any = { + "ssid": apInfo.ssid, + "bssid": apInfo.bssid, + "preSharedKey": password, + "isHiddenSsid": false, + "securityType": apInfo.securityType + }; + LogUtil.info(MODULE_TAG + 'start to connect WiFi, the parameter is : ' + JSON.stringify(obj)); + // avoid connect the same AP multi times + WifiNativeJs.disconnect(); + let ret = WifiNativeJs.connectToDevice(obj); + LogUtil.info(MODULE_TAG + 'connect WiFi ret is ' + ret); + return ret; + } + + /** + * Disconnect wifi + */ + disconnectWiFi() { + this.setUserSelectedAp(null); + let ret = WifiNativeJs.disconnect(); + LogUtil.info(MODULE_TAG + 'disconnect WiFi result is : ' + ret); + return ret; + } + + /** + * Get connected WiFi information + */ + getWiFiLinkedInfo() { + WifiNativeJs.getWiFiLinkedInfo(results => { + LogUtil.info(MODULE_TAG + ' get linked info is : ' + results); + }); + } + + refreshApScanResults() { + WifiNativeJs.getScanInfos((err, results) => { + if (err) { + LogUtil.info(MODULE_TAG + "get scan info error : " + JSON.stringify(err)); + return; + } + + function removeDuplicateResults(arr: any[]): ApScanResult[] { + let len: number = Object.keys(arr).length; + let results: ApScanResult[] = []; + for (let i = 0; i < len; i++) { + let item = new ApScanResult(arr[i]); + if (item.isValidAp() === true) { + results.push(item); + } + } + results.sort(ApScanResult.compare); + return ApScanResult.filter(results); + }; + + // make the connected wifi item at the head of the array as + // the connected wifi need to be shown at top of list-view + function unshiftPrimaryApScanResult(newResults: any[], oldResults: any[], + primaryApInfo: ApScanResult): ApScanResult[] { + let idxInNew = ApScanResult.index(newResults, primaryApInfo); + let idxInOld = ApScanResult.index(oldResults, primaryApInfo); + // direct return the scan results + if (idxInNew === -1 && idxInOld === -1) { + return newResults; + } + // new scan results not contains the primary ap info, + // but old results had it, using old one + if (idxInNew === -1 && idxInOld !== -1) { + newResults.unshift(oldResults[idxInOld]); + return newResults; + } + // new scan results contains the primary ap info, + // and the old results is not, using new one + if (idxInNew !== -1 && idxInOld === -1) { + newResults.splice(idxInNew, 1); + newResults.unshift(primaryApInfo); + } + // new scan results and old results both had primary ap info, + // update new one's summary and connected status by old one + if (idxInNew !== -1 && idxInOld !== -1) { + let temp = newResults[idxInNew]; + temp.setConnectStatus(oldResults[idxInOld].isConnected()); + temp.updateSummary(oldResults[idxInOld].getSummary()); + newResults.splice(idxInNew, 1); + newResults.unshift(temp); + } + return newResults; + } + + let scanResults: ApScanResult[] = removeDuplicateResults(results); + scanResults = unshiftPrimaryApScanResult(scanResults, this.apScanResults, this.getPrimaryApInfo()); + this.apScanResults = scanResults; + let listModelRestuls = this.apScanResults.map((item) => { + return item.renderToListModel(); + }); + AppStorage.SetOrCreate('slWiFiLists', listModelRestuls); + }); + } + + private getPrimaryApInfo(): ApScanResult { + function loadPrimaryApInfo(): ApScanResult { + let urivar = settings.getUri('settings.wifi.lastConnected'); + let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(urivar); + let apInfoStr: string = settings.getValue(dataAbilityHelper, 'settings.wifi.lastConnected', ''); + let result = new ApScanResult(); + if (apInfoStr !== '') { + result = new ApScanResult(JSON.parse(apInfoStr)); + } + LogUtil.info(MODULE_TAG + 'get stored primary ap info str is : ' + apInfoStr + + ' and it to string is :' + result.toString()); + return result; + } + + if (this.userSelectedAp.isValidAp()) { + return this.userSelectedAp; + } + let primary = new ApScanResult(); + let loadedApInfo = loadPrimaryApInfo(); + if (loadedApInfo.isValidAp()) { + primary = loadedApInfo; + } + return primary; + } + + removePrimaryApInfo() { + let primaryApInfo = this.getPrimaryApInfo(); + if (primaryApInfo.isValidAp() !== true) { + return; + } + let index = ApScanResult.index(this.apScanResults, primaryApInfo); + LogUtil.info(MODULE_TAG + 'find primary ap info in scan result is' + index); + if (index !== -1) { + this.apScanResults[index].setConnectStatus(false); + this.apScanResults[index].updateSummary(''); + } + } + + updatePrimaryApInfo(summary: any) { + function storePrimaryApInfo(primary: ApScanResult) { + LogUtil.info(MODULE_TAG + 'start to store primary ap info : ' + primary.toString()); + if (!primary.isValidAp()) { + LogUtil.info(MODULE_TAG + 'we do not save the invalid ap info'); + return; + } + let urivar = settings.getUri('settings.wifi.lastConnected'); + let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(urivar); + let ret = settings.setValue(dataAbilityHelper, 'settings.wifi.lastConnected', primary.toString()); + LogUtil.info(MODULE_TAG + 'ret of store primary ap info is : ' + ret); + }; + + let primary = this.getPrimaryApInfo(); + if (primary.isValidAp() !== true) { + LogUtil.info(MODULE_TAG + 'unknown status, disconnect and break'); + this.disconnectWiFi(); + return; + } + let index = ApScanResult.index(this.apScanResults, primary); + if (index !== -1) { + this.apScanResults[index].updateSummary(summary); + this.apScanResults[index].setConnectStatus(true); + let temp = this.apScanResults[index]; + this.apScanResults.splice(index, 1); + this.apScanResults.unshift(temp); + } + // store primary ap info into settings data + storePrimaryApInfo(primary); + } + + setIntervalScanTask() { + LogUtil.info(MODULE_TAG + 'start set scan interval task'); + this.scanIntervalId = setInterval(() => { + if (this.scanStatus === true) { + LogUtil.info(MODULE_TAG + 'direct get scan result'); + this.refreshApScanResults(); + return; + } + if (this.isWiFiActive() === true && this.scanWiFi() === true) { + LogUtil.info(MODULE_TAG + 'call scan wifi to get scan result'); + this.scanStatus = true; + this.refreshApScanResults(); + } + }, 3000); + } + + clearIntervalScanTask() { + this.scanStatus = false; + clearInterval(this.scanIntervalId); + LogUtil.info(MODULE_TAG + 'clear the scan interval id'); + } +} + +let wifiModel = new WifiModel(); +export default wifiModel as WifiModel; diff --git a/product/phone/src/main/ets/default/model/wifiImpl/WifiProvider.ets b/product/phone/src/main/ets/default/model/wifiImpl/WifiProvider.ets new file mode 100644 index 00000000..8698d1a9 --- /dev/null +++ b/product/phone/src/main/ets/default/model/wifiImpl/WifiProvider.ets @@ -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 Log from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import PageSearchDataProvider from '../../../../../../../../common/search/src/main/ets/default/provider/PageSearchDataProvider'; + +const SEARCH_DATA = { + data: [] +}; + +/** + * Search data provider for wifi + */ +export class WifiProvider extends PageSearchDataProvider { + + /** + * Get page search data + */ + @Log + getPageSearchData(): any { + return SEARCH_DATA; + } + +} + +let wifiProvider = new WifiProvider(); +export default wifiProvider as WifiProvider +; \ No newline at end of file diff --git a/entry/src/main/ets/default/pages/aboutDevice.ets b/product/phone/src/main/ets/default/pages/aboutDevice.ets similarity index 92% rename from entry/src/main/ets/default/pages/aboutDevice.ets rename to product/phone/src/main/ets/default/pages/aboutDevice.ets index 1d6b9158..42e79bc1 100644 --- a/entry/src/main/ets/default/pages/aboutDevice.ets +++ b/product/phone/src/main/ets/default/pages/aboutDevice.ets @@ -12,8 +12,8 @@ * 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 ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; import AboutDeviceModel from '../model/aboutDeviceImpl/AboutDeviceModel.ets' /** @@ -52,9 +52,8 @@ struct Index { }) } .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') }) + .margin({ left: $r('app.float.wh_value_20'), right: $r('app.float.wh_value_20') }) .align(Alignment.TopStart); } } diff --git a/entry/src/main/ets/default/pages/appManagement.ets b/product/phone/src/main/ets/default/pages/appManagement.ets similarity index 86% rename from entry/src/main/ets/default/pages/appManagement.ets rename to product/phone/src/main/ets/default/pages/appManagement.ets index 8b2d1f78..7b0311d2 100644 --- a/entry/src/main/ets/default/pages/appManagement.ets +++ b/product/phone/src/main/ets/default/pages/appManagement.ets @@ -12,12 +12,12 @@ * 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 ImageAnimatorComponent from '../../../../../../../common/component/src/main/ets/default/imageAnimatorComponent.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/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 EntryComponent from '../../../../../../../common/component/src/main/ets/default/entryComponent.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; import Router from '@system.router'; /** @@ -69,8 +69,6 @@ struct AppManagement { 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); diff --git a/product/phone/src/main/ets/default/pages/application.ets b/product/phone/src/main/ets/default/pages/application.ets new file mode 100644 index 00000000..7f79bfb8 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/application.ets @@ -0,0 +1,52 @@ +/** + * 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 EntryComponent from '../../../../../../../common/component/src/main/ets/default/entryComponent.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; + +/** + * Application + */ +@Entry +@Component +struct Application { + build() { + Column() { + HeadComponent({ headName: $r('app.string.applyTab'), isActive: true }); + Navigator({ target: 'pages/appManagement' }) { + EntryComponent({ + settingIcon: '', + settingTitle: $r('app.string.appManagement'), + settingSummary: '', + settingValue: '', + settingArrow: '/res/image/ic_settings_arrow.svg', + settingArrowStyle: '', + settingUri: '' + }); + } + Navigator({ target: '' }) { + EntryComponent({ + settingIcon: '', + settingTitle: $r("app.string.authorityManagement"), + settingSummary: '', + settingValue: '', + settingArrow: '/res/image/ic_settings_arrow.svg', + settingArrowStyle: '', + settingUri: '' + }); + } + } + } + +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/pages/applicationInfo.ets b/product/phone/src/main/ets/default/pages/applicationInfo.ets new file mode 100644 index 00000000..d38b46c9 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/applicationInfo.ets @@ -0,0 +1,211 @@ +/** + * 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/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import EntryComponent from '../../../../../../../common/component/src/main/ets/default/entryComponent.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import Router from '@system.router' +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import ApplicationInfoController from '../controller/application/ApplicationInfoController.ets' +import Log from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; + +let appInfo; + +/** + * Application Info + */ +@Entry +@Component +struct ApplicationInfo { + private controller: ApplicationInfoController = new ApplicationInfoController(); + showDialog: CustomDialogController = new CustomDialogController({ + builder: ShowDialog({ + action: () => { + this.controller.uninstall(appInfo.settingBundleName) + } + }), + alignment: DialogAlignment.Bottom, + autoCancel: true + }); + + build() { + Column() { + HeadComponent({ headName: $r('app.string.applicationInfo'), isActive: true }); + Row() { + EntryComponent({ + settingIcon: appInfo.settingIcon, + settingTitle: appInfo.settingTitle, + settingSummary: appInfo.settingSummary, + settingValue: '', + settingArrow: '', + settingArrowStyle: '', + settingUri: appInfo.settingUri + }); + } + + Flex({ direction: FlexDirection.Row }) { + Button() { + Text($r("app.string.uninstall")) + .fontSize($r('app.float.application_button_subtitle_size')) + .fontColor(Color.Blue) + } + .backgroundColor($r('app.color.color_E3E3E3_grey')) + .width('150') + .height($r('app.float.application_button_height')) + .align(Alignment.BottomStart) + .flexGrow(1) + .onClick(() => { + this.showDialog.open(); + }) + Button() { + Text($r("app.string.forcedStop")) + .fontSize($r('app.float.application_button_subtitle_size')) + .fontColor(Color.Blue) + } + .backgroundColor($r('app.color.color_E3E3E3_grey')) + .width($r("app.float.wh_value_160")) + .height($r('app.float.application_button_height')) + .align(Alignment.BottomEnd) + .flexGrow(1) + .onClick(()=>{ + this.showPromptDialog(this.controller.killProcessesByBundleName.bind(this, appInfo.settingBundleName)); + }) + } + .width(ConfigData.WH_90_100) + .margin({ top: $r('app.float.item_common_vertical_margin'), bottom: $r('app.float.item_common_vertical_margin') }) + + Row() { + EntryComponent({ + settingIcon: '', + settingTitle: $r("app.string.storageTab"), + settingSummary: '', + settingValue: '', + settingArrow: '/res/image/ic_settings_arrow.svg', + settingArrowStyle: '', + settingUri: '' + }) + } + .width(ConfigData.WH_90_100) + .onClick(() => { + Router.push({ uri: 'pages/applicationStorage', params: appInfo }); + }) + } + } + @Log + aboutToAppear(): void{ + appInfo = Router.getParams(); + LogUtil.info('settings ApplicationInfo aboutToAppear this.item:' + JSON.stringify(appInfo)); + } + + @Log + onBackPress() { + Router.back(); + } + + /** + * Stop exception prompt Dialog + */ + @Log + showPromptDialog(callback) { + AlertDialog.show({ + message: $r("app.string.Stop_exception_prompt"), + primaryButton: { + value: $r('app.string.cancel'), + action: () => { + LogUtil.info(ConfigData.TAG + 'Closed callbacks'); + } + }, + secondaryButton: { + value: $r('app.string.forcedStop'), + action: () => { + LogUtil.info(ConfigData.TAG + `AlertDialog success:`); + callback(); + } + }, + alignment: DialogAlignment.Bottom + }) + } +} + +/** + * Show dialog + */ +@CustomDialog +struct ShowDialog { + dialogController: CustomDialogController; + action: () => void; + private uirBack: string = 'pages/appManagement' + + build() { + Column() { + Image(`${appInfo.settingIcon}`) + .height($r("app.float.application_common_size")) + .width($r("app.float.application_common_size")) + .margin({ + top: $r('app.float.item_common_vertical_margin'), + bottom: $r('app.float.item_common_vertical_margin') + }) + + Text(`${appInfo.settingTitle}`) + .dialogMsg() + + Text($r("app.string.uninstall_prompt")) + .dialogMsg() + + // button + Flex({ justifyContent: FlexAlign.SpaceEvenly }) { + + Button() { + Text($r('app.string.cancel')).dialogBtnName() + }.dialogBtn() + .onClick(() => { + this.dialogController.close(); + }) + + Button() { + Text($r('app.string.uninstall')).dialogBtnName() + }.dialogBtn() + .onClick(() => { + this.action(); + this.dialogController.close(); + Router.back({ uri: this.uirBack }); + }) + + } + .width(ConfigData.WH_100_100) + .height($r('app.float.wh_value_60')); + } + .alignItems(HorizontalAlign.Center) + .width(ConfigData.WH_100_100); + } +} + +@Extend(Text) function dialogBtnName () { + .fontSize($r('app.float.application_button_subtitle_size')) + .fontColor(Color.Blue) +} + +@Extend(Button) function dialogBtn () { + .backgroundColor($r('app.color.color_E3E3E3_grey')) + .width($r("app.float.wh_value_160")) + .height($r("app.float.wh_value_40")) +} + +@Extend(Text) function dialogMsg () { + .fontSize($r('app.float.font_18')) + .align(Alignment.Center) + .margin({ + bottom: $r('app.float.item_common_vertical_margin') + }) +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/pages/applicationStorage.ets b/product/phone/src/main/ets/default/pages/applicationStorage.ets new file mode 100644 index 00000000..d34e57e6 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/applicationStorage.ets @@ -0,0 +1,144 @@ +/** + * 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/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import EntryComponent from '../../../../../../../common/component/src/main/ets/default/entryComponent.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import Router from '@system.router'; +import ApplicationStorageController from '../controller/application/ApplicationStorageController.ets' +import Log from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; + +let appInfo; +/** + * Application storage + */ +@Entry +@Component +struct ApplicationStorage { + @StorageLink('applicationStorageList') storageList: any[]= []; + private controller: ApplicationStorageController = new ApplicationStorageController(); + + build() { + Column() { + HeadComponent({ headName: $r('app.string.applyTab'), isActive: true }); + // head + Row() { + EntryComponent({ + settingIcon: appInfo.settingIcon, + settingTitle: appInfo.settingTitle, + settingSummary: appInfo.settingSummary, + settingValue: '', + settingArrow: '', + settingArrowStyle: '', + settingUri: appInfo.settingUri + }); + } + // body + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) { + List() { + ForEach(this.storageList, (item) => { + if (item.settingButtonFlag) { + ListItem() { + EntryComponent({ + settingIcon: '', + settingTitle: item.settingTitle, + settingSummary: item.settingSummary, + settingValue: item.settingValue, + settingArrow: item.settingArrow, + settingArrowStyle: '', + settingUri: '' + }); + } + } else { + ListItem() { + Button() { + Text(item.settingTitle) + .fontSize($r('app.float.application_button_subtitle_size')) + .fontColor(Color.Blue) + } + .backgroundColor($r('app.color.color_E3E3E3_grey')) + .height($r('app.float.application_button_height')) + .align(Alignment.BottomStart) + .width($r("app.float.wh_value_160")) + .margin({ top: 10, bottom: 10 }) + .onClick(() => { + this.onClickController(item.settingAlias); + }); + }.width(ConfigData.WH_100_100) + } + }); + } + .divider({ + strokeWidth: 1, + color: $r('app.color.color_E3E3E3_grey'), + startMargin: $r('app.float.storage_common_margin'), + endMargin: $r('app.float.storage_common_margin') + }) + .width(ConfigData.WH_100_100) + .alignSelf(ItemAlign.Start); + } + .width(ConfigData.WH_100_100) + .margin({ top: $r('app.float.item_common_vertical_margin'), bottom: $r('app.float.item_common_vertical_margin') }) + } + } + + @Log + aboutToAppear() { + this.controller.getStorageList(); + appInfo = Router.getParams(); + LogUtil.info('settings ApplicationInfo aboutToAppear this.item:' + JSON.stringify(appInfo)); + } + + @Log + onBackPress() { + Router.back(); + } + + @Log + onClickController(settingAlias){ + LogUtil.info(ConfigData.TAG + 'onClickController settingBundleName:' + JSON.stringify(appInfo.settingBundleName)); + if ('deleteDataTab' === settingAlias) { + this.showDialog(this.controller.clearUpApplicationData.bind(this, appInfo.settingBundleName)) + } else if ('clearCacheTab' === settingAlias) { + this.controller.cleanBundleCacheFiles(appInfo.settingBundleName); + } + } + + /** + * Disconnect Dialog + */ + @Log + showDialog(callback) { + AlertDialog.show({ + title: $r('app.string.delete_data_prompt_title'), + message: $r("app.string.delete_data_prompt"), + primaryButton: { + value: $r('app.string.cancel'), + action: () => { + LogUtil.info(ConfigData.TAG + 'Closed callbacks'); + } + }, + secondaryButton: { + value: $r('app.string.confirm'), + action: () => { + LogUtil.info(ConfigData.TAG + `AlertDialog success:`); + callback(); + LogUtil.info(ConfigData.TAG + `callback success:`); + } + }, + alignment: DialogAlignment.Bottom + }) + } +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/pages/biometricsAndPassword.ets b/product/phone/src/main/ets/default/pages/biometricsAndPassword.ets new file mode 100644 index 00000000..8885c852 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/biometricsAndPassword.ets @@ -0,0 +1,90 @@ +/** + * 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 prompt from '@system.prompt'; +import FeatureAbility from '@ohos.ability.featureAbility'; +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; + +/** + * Home Page Of Biometrics And Password + */ +@Entry +@Component +struct BiometricsAndPassword { + @State touchedItem:boolean = false; + private TAG = `${ConfigData.TAG} BiometricsAndPassword`; + + build() { + Column() { + HeadComponent({ headName: $r('app.string.biometricsAndPassword'), isActive: true }) + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems:ItemAlign.Center }) { + Row() { + Text($r('app.string.faceRecognition')) + .fontSize($r('app.float.font_22')) + .fontColor($r('app.color.font_color_182431')) + .margin({left:$r('app.float.distance_24'), top:$r('app.float.distance_8'), bottom:$r('app.float.distance_8'), right:0}) + .textAlign(TextAlign.Start); + } + Image('/res/image/ic_settings_arrow.svg') + .width($r('app.float.wh_value_40')) + .height($r('app.float.wh_value_40')); + } + .backgroundColor(this.touchedItem? $r("app.color.color_D8D8D8_grey"):$r("app.color.white_bg_color")) + .height($r('app.float.wh_value_56')) + .margin({left:$r('app.float.distance_24'), right:$r('app.float.distance_24'), top:$r('app.float.distance_16')}) + .borderRadius($r('app.float.radius_24')) + .onClick(()=>{ + FeatureAbility.startAbility({ + want: { + bundleName: ConfigData.FACEAUTH_BUNDLE_NAME, + abilityName: ConfigData.FACEAUTH_ABILITY_NAME + } + }) + .then((data) => { + LogUtil.info(`${this.TAG}, ${ConfigData.FACEAUTH_BUNDLE_NAME} start successful. Data: ${JSON.stringify(data)}`); + }) + .catch((error) => { + prompt.showToast({ + message: $r("app.string.faceauthFailed"), + duration: 2000 + }) + LogUtil.error(`${this.TAG}, ${ConfigData.FACEAUTH_BUNDLE_NAME} start failed. Cause: ${JSON.stringify(error)}`); + }) + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.touchedItem = true; + } + if (event.type === TouchType.Up) { + this.touchedItem = false; + } + }); + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100) + .backgroundColor($r("app.color.color_E3E3E3_grey")); + } + + aboutToAppear(){ + LogUtil.info(`${this.TAG} aboutToAppear in`); + LogUtil.info(`${this.TAG} aboutToAppear out`); + } + + aboutToDisappear(){ + LogUtil.info(`${this.TAG} aboutToDisappear in`); + LogUtil.info(`${this.TAG} aboutToDisappear out`); + } +} diff --git a/product/phone/src/main/ets/default/pages/brightnessSettings.ets b/product/phone/src/main/ets/default/pages/brightnessSettings.ets new file mode 100644 index 00000000..1164a0ed --- /dev/null +++ b/product/phone/src/main/ets/default/pages/brightnessSettings.ets @@ -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 LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import Log from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import {BrightnessSettingModel} from '../model/brightnessImpl/BrightnessSettingModel.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; + + +const BRIGHTNESS_MIN_VALUE = 0; +const BRIGHTNESS_MAX_VALUE = 100; +const BRIGHTNESS_STEP_VALUE = 1; + +/** + * brightness setting + */ +@Entry +@Component +struct BrightnessSettings { + @State brightnessSettingModel:BrightnessSettingModel = new BrightnessSettingModel(); + private TAG = ConfigData.TAG + 'BrightnessSettings '; + + 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.brightnessSettingModel.getValue(), + 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, mode:SliderChangeMode) => { + this.brightnessSettingModel.setValue(number, mode); + }); + 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); + } + + @Log + private aboutToAppear(): void{ + LogUtil.info(this.TAG + 'aboutToAppear in'); + this.brightnessSettingModel.registerObserver(); + LogUtil.info(this.TAG + 'aboutToAppear out'); + } + + @Log + private aboutToDisappear(): void{ + LogUtil.info(this.TAG + 'aboutToDisappear in'); + this.brightnessSettingModel.unregisterObserver(); + LogUtil.info(this.TAG + 'aboutToDisappear out'); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/default/pages/dateAndTime.ets b/product/phone/src/main/ets/default/pages/dateAndTime.ets similarity index 63% rename from entry/src/main/ets/default/pages/dateAndTime.ets rename to product/phone/src/main/ets/default/pages/dateAndTime.ets index 788ddc10..f8094d98 100644 --- a/entry/src/main/ets/default/pages/dateAndTime.ets +++ b/product/phone/src/main/ets/default/pages/dateAndTime.ets @@ -12,11 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import HeadComponent from './component/headComponent.ets'; -import ConfigData from '../common/baseUtil/ConfigData.ets'; -import DateAndTime from '../common/baseUtil/DateAndTimeUtil.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import DateAndTime from '../../../../../../../common/utils/src/main/ets/default/baseUtil/DateAndTimeUtil.ets'; import DateAndTimeModel from '../model/dateAndTimeImpl/DateAndTimeModel.ets' -import LogUtil from '../common/baseUtil/LogUtil.ets'; +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; /** * date and time @@ -30,9 +30,10 @@ struct dateAndTime { private dateMark: string = 'date'; private timeMark: string = 'time'; private intervalFlag; + @State dateAndTimeList: any[] = []; timeDialogController: CustomDialogController = new CustomDialogController({ - builder: TimeDialog({ action: this.onAccept }), + builder: TimeDialog24H({ action: this.onAccept }), cancel: this.existApp, autoCancel: true }); @@ -45,49 +46,72 @@ struct dateAndTime { build() { Column() { HeadComponent({ headName: $r('app.string.dateAndTimeTab'), isActive: true }) - List() { - ForEach(this.dateAndTimeList, (item) => { - ListItem() { - Row() { - Text(item.settingTitle) - .fontSize($r('app.float.font_22')) - .fontColor($r('app.color.color_333333_grey')) - .width(ConfigData.WH_45_100) - .textAlign(TextAlign.Start); - Text(item.settingValue) - .fontSize($r('app.float.font_20')) - .fontColor($r('app.color.color_666666_grey')) - .width(ConfigData.WH_45_100) - .textAlign(TextAlign.End); - Image(item.settingArrow) - .width($r('app.float.wh_value_40')) - .height($r('app.float.wh_value_40')); + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems:ItemAlign.Center}) { + Text($r('app.string.timeFormat')) + .fontSize($r('app.float.font_22')) + .fontColor($r('app.color.color_333333_grey')) + .textAlign(TextAlign.Start) + .margin({left: $r('app.float.wh_value_12')}); + Toggle({ type: ToggleType.Switch, isOn: this.is24hTimeFormat() }) + .width($r('app.float.wh_value_50')) + .height($r('app.float.wh_value_40')) + .onChange((isOn: boolean) => { + if (this.is24hTimeFormat()) { + this.setTimeFormatAs12H(); + } else { + this.setTimeFormatAs24H(); } - } - .width(ConfigData.WH_100_100) - .height($r('app.float.wh_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($r('app.float.wh_value_70')); - }, item => JSON.stringify(item)) + }); } - .divider({ strokeWidth: $r('app.float.wh_value_1'), color: $r('app.color.color_E3E3E3_grey'), - startMargin: $r('app.float.wh_value_15'), endMargin: $r('app.float.wh_value_15') }) - .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); + .height($r('app.float.wh_value_80')) + .margin({ top: $r('app.float.wh_value_8'), bottom: $r('app.float.wh_value_12'), + left: $r('app.float.wh_value_12'), right: $r('app.float.wh_value_12') }) + .borderRadius($r('app.float.wh_value_15')); + + List() { + ForEach(this.dateAndTimeList, (item) => { + ListItem() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems:ItemAlign.Center }) { + Row() { + Text(item.settingTitle) + .fontSize($r('app.float.font_22')) + .fontColor($r('app.color.color_333333_grey')) + .width(ConfigData.WH_45_100) + .padding({ left: $r('app.float.wh_value_12') }) + .textAlign(TextAlign.Start); + Text(item.settingValue) + .fontSize($r('app.float.font_20')) + .fontColor($r('app.color.color_666666_grey')) + .width(ConfigData.WH_55_100) + .textAlign(TextAlign.End); + } + Image(item.settingArrow) + .width($r('app.float.wh_value_40')) + .height($r('app.float.wh_value_40')); + } + } + .width(ConfigData.WH_100_100) + .height($r('app.float.wh_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() + } + }) + }, item => JSON.stringify(item)) + } + .divider({ strokeWidth: $r('app.float.wh_value_1'), color: $r('app.color.color_E3E3E3_grey'), + startMargin: $r('app.float.wh_value_15'), endMargin: $r('app.float.wh_value_15') }) + .height($r('app.float.wh_value_160')) + .margin({left: $r('app.float.wh_value_12'), right: $r('app.float.wh_value_12'), + top: $r('app.float.wh_value_8'), bottom: $r('app.float.wh_value_12') }) + .align(Alignment.TopStart) + .borderRadius($r('app.float.wh_value_15')); } } /** @@ -130,7 +154,7 @@ struct dateAndTime { private aboutToAppear(): void { this.dateAndTimeList = DateAndTimeModel.dateAndTimeListener(); this.image = this.dateAndTimeList[0].settingArrow; - this.time = DateAndTime.getSystemTime(); + this.time = DateAndTime.getSystemTime(this.is24hTimeFormat()); this.date = DateAndTime.getSystemDate(); this.changeValue(); this.getNowTime(); @@ -142,9 +166,10 @@ struct dateAndTime { private getNowTime(): void { this.intervalFlag = setInterval(() => { console.log('get time come in'); - this.time = DateAndTime.getSystemTime(); + this.time = DateAndTime.getSystemTime(this.is24hTimeFormat()); this.date = DateAndTime.getSystemDate(); - console.log('get time end in' + this.time); + console.log('get time end in date=' + this.date); + console.log('get time end in time=' + this.time); this.changeValue(); }, 1000); } @@ -156,14 +181,30 @@ struct dateAndTime { onBackPress() { Navigator().active(true); } + + private setTimeFormatAs24H() { + DateAndTimeModel.setTimeFormatAs24H(); + } + + private setTimeFormatAs12H() { + DateAndTimeModel.setTimeFormatAs12H(); + } + + private is24hTimeFormat() : boolean { + let result = DateAndTimeModel.getTimeFormat(); + if (result === ConfigData.TIME_FORMAT_24) { + return true; + } + return false; + } } /** - * set time dialog + * set time 24h format dialog */ @CustomDialog @Component -struct TimeDialog { +struct TimeDialog24H { controller: CustomDialogController; action: () => void; private currentTime; @@ -172,13 +213,14 @@ struct TimeDialog { build() { Column() { Column() { - Text($r('app.string.time')) + Text($r('app.string.settingTime')) + .height($r('app.float.wh_value_60')) .margin({ left: $r('app.float.wh_value_30') }) .width(ConfigData.WH_100_100) .fontSize($r('app.float.font_28')); DatePicker({ selected: this.currentTime, type: DatePickerType.Time }) - .useMilitaryTime(true) + .useMilitaryTime(this.isNeedMilitaryTime()) .onChange((date: DatePickerResult) => { this.currentTime = DateAndTime.concatTime(date.hour, date.minute); console.info("onchange currentTime" + this.currentTime); @@ -201,7 +243,8 @@ struct TimeDialog { .width(ConfigData.WH_50_100); Column() { Text($r('app.string.confirm')) - .fontSize($r('app.float.font_24')) + + .fontSize($r('app.float.font_24')) .fontColor(Color.Blue) .onClick(() => { LogUtil.info("button confirm"); @@ -228,6 +271,15 @@ struct TimeDialog { .height($r('app.float.wh_value_400')) .width(ConfigData.WH_100_100) } + + private isNeedMilitaryTime() : boolean { + let result = DateAndTimeModel.getTimeFormat(); + // 24h time format need using military time + if (result === ConfigData.TIME_FORMAT_24) { + return true; + } + return false; + } } /** @@ -323,3 +375,4 @@ struct DateDialog { + diff --git a/product/phone/src/main/ets/default/pages/developerOptions.ets b/product/phone/src/main/ets/default/pages/developerOptions.ets new file mode 100644 index 00000000..f6313d40 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/developerOptions.ets @@ -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 HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import SwitchComponent from '../../../../../../../common/component/src/main/ets/default/switchComponent.ets'; +import UsbDebuggingController from '../controller/developerOptions/UsbDebuggingController.ets' + +/** + * Developer options + */ +@Entry +@Component +struct developerOptions { + @State isOn: boolean = false; + private controller: UsbDebuggingController = new UsbDebuggingController(); + + build() { + Column() { + HeadComponent({ headName: $r("app.string.developerOptionsTab"), isActive: true }); + SwitchComponent({ + title: $r("app.string.usbDebugging"), + isOn: $isOn, + controller: this.controller + }) + } + } +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/pages/locationServices.ets b/product/phone/src/main/ets/default/pages/locationServices.ets new file mode 100644 index 00000000..0d1c6180 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/locationServices.ets @@ -0,0 +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 HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import ViewModel from '../model/locationServicesImpl/LocationViewModel.ets' +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; + +/** + * LocationServices + */ +@Entry +@Component +struct LocationServices { + @StorageLink('LocationServiceStatus') locationServiceStatus: boolean = false; + + aboutToAppear(): void { + LogUtil.info(ConfigData.TAG + 'location service about to appear'); + ViewModel.initViewModel(); + } + + aboutToDisappear(): void { + LogUtil.info(ConfigData.TAG + 'location service about to disappear'); + } + + build() { + Column() { + HeadComponent({ headName: $r('app.string.locationServicesTab'), isActive: true }); + Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text($r('app.string.positionInformation')) + .fontColor(Color.Black) + .fontStyle(FontStyle.Normal) + .padding({ left: $r('app.float.switch_component_margin') }) + .fontSize('20') + Toggle({ type: ToggleType.Switch, isOn: this.locationServiceStatus }) + .width($r('app.float.switch_toggle_width')) + .height($r('app.float.switch_toggle_height')) + .padding({ right: $r('app.float.switch_component_margin') }) + .onChange((isOn: boolean) => { + LogUtil.info(ConfigData.TAG + 'location service status is :'+ this.locationServiceStatus); + if(this.locationServiceStatus === true){ + ViewModel.disableLocation(); + }else{ + ViewModel.enableLocation(); + } + }); + } + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start }) { + Text() { + Span($r('app.string.positionContent')) + .fontSize($r('app.float.location_font_size')); + Span($r('app.string.statement')) + .fontColor(Color.Blue) + .fontSize($r('app.float.location_font_size')) + .onClick(() => { + }) + } + } + .visibility(this.locationServiceStatus ? Visibility.None : Visibility.Visible) + .margin({ left: $r('app.float.location_common_margin'), right: $r('app.float.location_common_margin') }); + } + } +} diff --git a/product/phone/src/main/ets/default/pages/multipleUsers.ets b/product/phone/src/main/ets/default/pages/multipleUsers.ets new file mode 100644 index 00000000..ed3d9196 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/multipleUsers.ets @@ -0,0 +1,480 @@ +// @ts-nocheck +/** + * 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 '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import SystemAccountController from '../model/usersAndAccounts/systemAccountController.ets'; +import SystemAccountModel from '../model/usersAndAccounts/systemAccountModel.ets'; +import router from '@system.router'; + +@Entry +@Component +struct MultipleUsers { + @StorageLink("isShowAddUser") isShowAddUser: boolean = false; + @StorageLink("isShowAddGuest") isShowAddGuest: boolean = false; + @StorageLink("systemAccoutList") userList: any[] = []; + @StorageLink("isShowDelete") isShowDelete: boolean = false; + private addUserDialogController: CustomDialogController = new CustomDialogController({ + builder: AddUserDialog({ controller: this.addUserDialogController, account: {} }) + }); + + build() { + Flex({ direction: FlexDirection.Column, alignItems: Alignment.Center, justifyContent: FlexAlign.SpaceBetween }) { + Column() { + // head + HeadComponent({ headName: $r('app.string.user'), isActive: true }); + + // user list + List() { + ForEach(this.userList, userItem => { + ListItem() { + UserItem({ user: userItem }) + } + }) + } + .divider({ strokeWidth: $r('app.float.wh_value_1'), color: $r('app.color.color_E3E3E3_grey'), + startMargin: $r('app.float.wh_value_20'), endMargin: $r('app.float.wh_value_20') }) + + // Add user, shown when is administrator + Text($r("app.string.addUser")) + .fontSize($r("app.float.font_28")) + .fontColor(Color.Blue) + .margin({ left: $r("app.float.wh_value_20"), + right: $r("app.float.wh_value_20"), + top: $r("app.float.wh_value_20") + }) + .height($r("app.float.wh_value_50")) + .textAlign(TextAlign.Start) + .visibility(this.isShowAddUser ? Visibility.Visible : Visibility.None) + .onClick(() => { + LogUtil.info("Add user."); + this.addUserDialogController.open(); + }) + + /** + * Add guest, shown with conditions: + * 1. Current user is administrator + * 2. Guest is not created. + */ + Text($r("app.string.addGuest")) + .fontSize($r("app.float.font_28")) + .fontColor(Color.Blue) + .margin({ left: $r("app.float.wh_value_20"), + right: $r("app.float.wh_value_20"), + top: $r("app.float.wh_value_20") + }) + .height($r("app.float.wh_value_50")) + .textAlign(TextAlign.Start) + .visibility(this.isShowAddGuest ? Visibility.Visible : Visibility.None) + .onClick((event) => { + AlertDialog.show({ + message: $r("app.string.askAddGuest"), + primaryButton: { + value: $r("app.string.cancel"), + action: () => { + LogUtil.info("Cancel add guest."); + } + }, + secondaryButton: { + value: $r("app.string.confirm"), + action: () => { + LogUtil.info("Confirm add guest user."); + SystemAccountController.createQuest(); + } + }, + cancel: () => { + LogUtil.info("Cancel dialog.") + } + }) + }) + } + .height(ConfigData.WH_100_100) + .alignItems(HorizontalAlign.Start) + + if (this.isShowDelete) { + Column() { + Image($r("app.media.ic_delete")) + .height($r("app.float.wh_value_40")) + .width($r("app.float.wh_value_40")) + .margin({ top: $r("app.float.wh_value_20"), bottom: $r("app.float.wh_value_20") }) + Text($r("app.string.deleteButton")) + .fontSize($r("app.float.font_20")) + .fontColor(Color.Black) + } + .width(ConfigData.WH_100_100) + .alignItems(HorizontalAlign.Center) + .margin({top: $r("app.float.wh_value_20"), bottom: $r("app.float.wh_value_20")}) + .onClick(() => { + AlertDialog.show({ + message: $r("app.string.deleteUserWarn"), + primaryButton: { + value: $r("app.string.cancel"), + action: () => { + LogUtil.info("Cancel delete user."); + } + }, + secondaryButton: { + value: $r("app.string.deleteButton"), + action: () => { + LogUtil.info("Confirm delete user."); + SystemAccountController.removeAccount(); + } + } + }); + }) + } + } + .height(ConfigData.WH_100_100) + } + + aboutToAppear() { + LogUtil.info("Multiple user list about to appear.") + SystemAccountController.refreshSystemAccountList(); + LogUtil.info("after appear."); + } + + aboutToDisappear() { + LogUtil.info('multiple user about to disappear.'); + AppStorage.SetOrCreate("systemAccoutList", []); + } + + onBackPress() { + LogUtil.info('multiple user on back press.'); + AppStorage.SetOrCreate("systemAccoutList", []); + Router.back(); + } + +} + +@Component +struct UserItem { + private user: any; + private dialogController: CustomDialogController = new CustomDialogController({ + builder: UserItemDialog({ dialogController: this.dialogController, user: this.user }), + autoCancel: false + }); + + build() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Row() { + Image("/res/image/ic_user_portrait.svg") + .width($r("app.float.wh_value_50")) + .height($r("app.float.wh_value_50")) + .margin({ right: $r("app.float.wh_value_12") }) + Column() { + Text(this.user.localName) + .fontSize($r("app.float.font_24")) + .fontColor(Color.Black) + if (SystemAccountController.isShowIdentity(this.user)) { + Text(SystemAccountModel.getIdentityFromMap(this.user.type)) + .fontSize($r("app.float.font_22")) + .fontColor(Color.Black) + } + } + } + + Image($r("app.media.ic_settings_arrow")) + .width($r("app.float.wh_value_40")) + .height($r("app.float.wh_value_40")) + .margin({ right: $r("app.float.wh_value_20") }) + } + .margin({ left: $r("app.float.wh_value_10"), right: $r("app.float.wh_value_10") }) + .height($r("app.float.wh_value_100")) + .onClick(event => { + LogUtil.info("Click the multiple user item."); + if (SystemAccountController.isCurrentAdministrator() || SystemAccountController.isCurrentUser(this.user) + && !SystemAccountController.isGuestAccount(this.user)) { + this.dialogController.open(); + return; + } + if (!SystemAccountController.isCurrentQuest() || !SystemAccountController.isGuestAccount(this.user)) { + AlertDialog.show({ + message: $r("app.string.switchUser"), + primaryButton: { + value: $r("app.string.cancel"), + action: () => { + LogUtil.info("Cancel switch to user."); + } + }, + secondaryButton: { + value: $r("app.string.confirm"), + action: () => { + SystemAccountController.switchUser(this.user.localId); + } + } + }); + } + }) + } +} + +// Current user item dialog, allow user to set user name and profile image. +@CustomDialog +struct UserItemDialog { + private user: UserData; + private dialogController: CustomDialogController; + + build() { + if (SystemAccountController.isCurrentUser(this.user)) { + CurrentDialogBuilder({ controller: this.dialogController, user: this.user }); + } else { + UserDialogBuilder({ controller: this.dialogController, user: this.user }); + } + } +} + +@Component +struct CurrentDialogBuilder { + private controller: CustomDialogController; + private user: UserData; + private tempName: string = ""; + + build() { + Column() { + Image("/res/image/ic_user_portrait.svg") + .width($r("app.float.wh_value_60")) + .height($r("app.float.wh_value_60")) + .margin({ top: $r("app.float.wh_value_20"), bottom: $r("app.float.wh_value_20") }) + .onClick((event) => { + LogUtil.info("Click to modify user image.") + new CustomDialogController({ + builder: ChooseImageDialog({ controller: this.controller }) + }).open(); + }) + Text($r("app.string.addUserImage")) + .fontSize($r("app.float.font_22")) + .fontColor(Color.Black) + .margin({ bottom: $r("app.float.wh_value_20") }) + TextInput({ text: this.user.localName }) + .placeholderColor(Color.Black) + .placeholderFont({ size: $r("app.float.font_24"), weight: FontWeight.Normal, style: FontStyle.Normal }) + .width(ConfigData.WH_100_100) + .borderRadius($r("app.float.search_input_border_radius")) + .margin({ bottom: $r("app.float.wh_value_20") }) + .onChange((value: string) => { + LogUtil.info("Set current account name, name: " + value); + this.tempName = value; + }) + Flex({ justifyContent: FlexAlign.SpaceAround }) { + Button($r("app.string.cancel")) + .backgroundColor(Color.White) + .fontSize($r("app.float.font_35")) + .fontColor(Color.Blue) + .fontWeight(FontWeight.Medium) + .width(ConfigData.WH_50_100) + .onClick(() => { + LogUtil.info("Cancel current user modify dialog."); + this.controller.close(); + }) + Button($r("app.string.confirm")) + .backgroundColor(Color.White) + .fontSize($r("app.float.font_35")) + .fontColor(Color.Blue) + .fontWeight(FontWeight.Medium) + .width(ConfigData.WH_50_100) + .onClick(() => { + LogUtil.info("Confirm current user modify dialog."); + this.controller.close(); + SystemAccountController.setAccountName(this.user.localId, this.tempName); + }) + }.margin({ bottom: $r("app.float.wh_value_40") }) + } + .margin({ left: $r("app.float.wh_value_20"), right: $r("app.float.wh_value_20") }) + } +} + +// Current user item dialog, allow user to set user name and profile image. +@Component +struct UserDialogBuilder { + private controller: CustomDialogController; + private user: any; + + build() { + Column() { + Text(this.user.localName) + .fontSize($r("app.float.font_35")) + .fontWeight(FontWeight.Medium) + .fontColor(Color.Black) + .margin({ bottom: $r("app.float.wh_value_20"), top: $r("app.float.wh_value_20") }) + + Text($r("app.string.switchUser")) + .fontSize($r("app.float.font_24")) + .fontColor(Color.Black) + .margin({ bottom: $r("app.float.wh_value_10") }) + .height($r("app.float.wh_value_50")) + .width(ConfigData.WH_100_100) + .textAlign(TextAlign.Start) + .onClick((event) => { + this.controller.close(); + SystemAccountController.switchUser(this.user.localId); + }) + + Divider() + + Text($r("app.string.removeUser")) + .fontSize($r("app.float.font_24")) + .fontColor(Color.Black) + .height($r("app.float.wh_value_50")) + .margin({ top: $r("app.float.wh_value_10") }) + .width(ConfigData.WH_100_100) + .textAlign(TextAlign.Start) + .onClick(() => { + AlertDialog.show({ + message: $r("app.string.deleteUserWarn"), + primaryButton: { + value: $r("app.string.cancel"), + action: () => { + LogUtil.info("Cancel delete user."); + } + }, + secondaryButton: { + value: $r("app.string.deleteButton"), + action: () => { + LogUtil.info("Confirm delete user."); + SystemAccountController.removeAccount(this.user.localId); + } + }, + }); + this.controller.close(); + }) + + Button($r("app.string.cancel")) + .fontSize($r("app.float.font_24")) + .fontColor(Color.Blue) + .backgroundColor(Color.White) + .margin({ top: $r("app.float.wh_value_20"), bottom: $r("app.float.wh_value_20") }) + .width(ConfigData.WH_100_100) + .onClick(() => { + LogUtil.info("Cancel user operation dialog."); + this.controller.close(); + }) + } + .alignItems(HorizontalAlign.Start) + .margin({ left: $r("app.float.wh_value_40"), right: $r("app.float.wh_value_40") }) + } +} + +@CustomDialog +struct AddUserDialog { + @State buttonState: boolean = false; + private controller: CustomDialogController; + private account; + + build() { + Column() { + Text($r("app.string.addNewUser")) + .fontSize($r("app.float.font_35")) + .fontWeight(FontWeight.Medium) + .fontColor(Color.Black) + .margin({ top: $r("app.float.wh_value_40"), bottom: $r("app.float.wh_value_20") }) + Image("/res/image/ic_user_portrait.svg") + .width($r("app.float.wh_value_60")) + .height($r("app.float.wh_value_60")) + .margin({ top: $r("app.float.wh_value_20"), bottom: $r("app.float.wh_value_40") }) + TextInput({ + placeholder: '昵称' + }) + .placeholderFont({ size: $r("app.float.font_24") }) + .placeholderColor(Color.Brown) + .margin({ + bottom: $r("app.float.wh_value_20"), + left: $r("app.float.wh_value_20"), + right: $r("app.float.wh_value_20") + }) + .borderRadius($r("app.float.search_input_border_radius")) + .onChange((value: string) => { + LogUtil.info("Set the user name: " + value); + this.account.localName = value; + this.buttonState = value != ""; + LogUtil.info("Set the user name, name: " + this.account.localName); + }) + Text($r("app.string.addUserDescription")) + Flex({ direction: FlexDirection.Row, alignItems: Alignment.Center }) { + Button($r("app.string.cancel")) + .backgroundColor(Color.White) + .fontSize($r("app.float.font_35")) + .fontColor(Color.Blue) + .fontWeight(FontWeight.Medium) + .width(ConfigData.WH_50_100) + .onClick(() => { + LogUtil.info("Cancel add new user."); + this.controller.close(); + }) + + Button($r("app.string.confirm")) + .backgroundColor(Color.White) + .fontSize($r("app.float.font_35")) + .fontColor(Color.Blue) + .fontWeight(FontWeight.Medium) + .width(ConfigData.WH_50_100) + .enabled(this.buttonState) + .opacity(this.buttonState ? 1 : 0.5) + .onClick(() => { + LogUtil.info("Confirm Add new user."); + this.controller.close(); + SystemAccountController.createSystemAccount(this.account.localName); + AlertDialog.show({ + message: $r("app.string.askSwitchUser"), + primaryButton: { + value: $r("app.string.cancel"), + action: () => { + LogUtil.info("Cancel switch to new user."); + } + }, + secondaryButton: { + value: $r("app.string.switchButton"), + action: () => { + LogUtil.info("Confirm switch to new user."); + SystemAccountController.switchToCreatedAccount(); + } + }, + cancel: () => { + LogUtil.info("Cancel dialog.") + } + }) + }) + } + .margin({ + bottom: $r("app.float.wh_value_40"), + top: $r("app.float.wh_value_20"), + left: $r("app.float.wh_value_20"), + right: $r("app.float.wh_value_20") + }) + } + } +} + +@CustomDialog +struct ChooseImageDialog { + private controller: CustomDialogController; + + build() { + Column() { + Text($r("app.string.takePhoto")) + .fontSize($r("app.float.font_24")) + .fontColor(Color.Black) + .onClick(() => { + router.push({ uri: "" }); + }) + Text($r("app.string.chooseFromShop")) + .fontSize($r("app.float.font_24")) + .fontColor(Color.Black) + .onClick(() => { + router.push({ uri: "" }) + }) + } + } +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/pages/passwordCheck.ets b/product/phone/src/main/ets/default/pages/passwordCheck.ets new file mode 100644 index 00000000..933c290e --- /dev/null +++ b/product/phone/src/main/ets/default/pages/passwordCheck.ets @@ -0,0 +1,294 @@ +/** + * 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/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import Log from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import {PinSubType} from '../model/passwordImpl/PasswordModel.ets'; +import PasswordCheckController from '../controller/password/PasswordCheckController.ets' +import Router from '@system.router'; + +let param; + +@Entry +@Component +struct PasswordCheck { + private TAG_PAGE = ConfigData.TAG + 'PasswordCheck page '; + private mController: PasswordCheckController = new PasswordCheckController() + +// bind Properties + private pinToken: string = undefined + @State @Watch("freezeView") private freezingTime: number = 0 + @State @Watch("getPromptMessage") private remainTimes: number = -1 + + +// handler + private passwordOnChangeHandler: (value: string) => void; + private okOnClickHandler: (event?: ClickEvent) => void; + +// private Properties + private pageRequestCode: number = -1 + private prevPageUri: string = undefined + private pinChallenge: string = undefined + @State private passwordType: number = -1 + @State private promptMessage: string | Resource = '' + @State private buttonVisibility: Visibility = Visibility.Visible + @State private freezingTimeForView: number = -1; + @State private password: string = '' + private timerId: number = -1 + + @Log + aboutToAppear(): void { + + this.getRouterParam(); + + // bind event handlers + this.passwordOnChangeHandler = this.mController.passwordOnChange.bind(this.mController); + this.okOnClickHandler = this.mController.inputFinish.bind(this.mController); + + // bind component and initialize + this.mController.bindComponent(this) + .bindProperties(["freezingTime", "remainTimes", "pinToken"]) + .initData() + .subscribe(); + + this.updateView(); + } + + @Log + aboutToDisappear(): void { + this.mController.unsubscribe(); + this.stopCountDown(); + } + +/** + * Get the params from router + */ + @Log + getRouterParam() { + param = Router.getParams() + LogUtil.info(this.TAG_PAGE + ' getRouterParam : Router param = ' + JSON.stringify(param)) + if (!param) { + return; + } + this.pageRequestCode = param.pageRequestCode; + this.prevPageUri = param.prevPageUri; + this.pinChallenge = param.pinChallenge; + this.passwordType = param.passwordType; + LogUtil.info(this.TAG_PAGE + ' getRouterParam : from router : pageRequestCode = ' + this.pageRequestCode + + ', prevPageUri = ' + this.prevPageUri + + ', pinChallenge = ' + this.pinChallenge) + } + + build() { + Column() { + // head + HeadComponent({ headName: $r('app.string.password_enter_password'), isActive: true }) + + // freeze view + if (this.freezingTime > 0) { + + Row() { + // attempt seconds + Text($r('app.string.password_remain_times', this.freezingTimeForView)) + .freezingTime() + } + .backgroundColor(Color.Gray) + .margin({ + left: $r('app.float.password_count_down_view_vertical_margin'), + right: $r('app.float.password_count_down_view_vertical_margin') + }) + + // input + } else { + Column() { + // input message + Text(' ') + .inputMsg() + .visibility(Visibility.Hidden) + + // input password + Row() { + TextInput({ placeholder: '', text: this.password }) + .height($r('app.float.wh_value_70')) + .layoutWeight(1) + .backgroundColor(Color.White) + .type(InputType.Password) + .enterKeyType(EnterKeyType.Done) + .onChange(this.passwordOnChangeHandler) + //TODO max length : wait ACE + } + + // prompt message + Text(this.promptMessage) + .promptMsg() + + // button + Flex({ justifyContent: FlexAlign.SpaceAround }) { + Button() { + Text($r('app.string.cancel')).dialogBtnName() + } + .dialogBtn() + .onClick(() => { + Router.back(); + }) + + Button() { + Text($r('app.string.next')).dialogBtnName() + } + .dialogBtn() + .onClick(this.okOnClickHandler); + + + Button() { + Text($r('app.string.password_title_character')).dialogBtnName() + } + .dialogBtn() + .onClick(() => { + this.mController.gotoPasswordCreatePage() + }) + + } + .margin({ top: $r('app.float.password_input_button_space') }) + .visibility(this.buttonVisibility) + + } + .width(ConfigData.WH_100_100) + .margin({ top: $r('app.float.password_input_button_margin_top') }) + .padding({ + left: $r('app.float.item_common_horizontal_margin'), + right: $r('app.float.item_common_horizontal_margin'), + }) + } + } + } + +// --------------------------- updateView ----------------------- +/** + * Update view + */ + @Log + updateView() { + this.promptMessage = this.getPromptMessage(); + this.buttonVisibility = this.getButtonVisibility(); + } + +/** + * Get prompt message + * + * @return : message + */ + @Log + getPromptMessage(): string | Resource { + return this.remainTimes > 0 ? $r('app.string.password_message_incorrect', this.remainTimes) : ''; + } + +/** + * Get button visibility + * + * @return : button visibility + */ + @Log + getButtonVisibility(): Visibility { + return this.passwordType == PinSubType.PIN_SIX ? Visibility.Hidden : Visibility.Visible + } + +/** + * When freezing time is greater than 0, start count down view. + * + * @return : button visibility + */ + @Log + freezeView() { + if (this.freezingTime <= 0) { + this.stopCountDown() + return; + } + this.freezingTimeForView = this.freezingTime + LogUtil.info(this.TAG_PAGE + `freezeView freezingTimeForView = ${this.freezingTimeForView}`); + this.timerId = setInterval(() => { + if (this.freezingTimeForView <= 0) { + this.stopCountDown() + this.timerId = -1 + this.freezingTimeForView = 0 + this.freezingTime = 0 + this.updateView() + } else { + this.freezingTimeForView -= 1 + } + }, 1000) + } + +/** + * Stop count down view. + */ + @Log + stopCountDown() { + // for freezing view + if (this.timerId > 0) { + clearTimeout(this.timerId) + clearInterval(this.freezingTimeForView) + } + } + +} + +@Extend(Text) function freezingTime () { + .fontSize($r('app.float.font_28')) + .fontColor(Color.Blue) + .textCase(TextCase.UpperCase) + .margin({ + top: $r('app.float.password_input_message_vertical_margin'), + bottom: $r('app.float.password_input_message_vertical_margin') + }) + .padding({ + left: $r('app.float.item_common_horizontal_margin'), + right: $r('app.float.item_common_horizontal_margin') + }) + .align(Alignment.Center) +} + +@Extend(Text) function inputMsg () { + .fontSize($r('app.float.font_20')) + .fontColor($r('app.color.color_666666_grey')) + .margin({ + top: $r('app.float.password_input_message_vertical_margin'), + bottom: $r('app.float.password_input_message_vertical_margin') + }) + .align(Alignment.Center) +} + +@Extend(Text) function promptMsg () { + .fontSize($r('app.float.font_18')) + .width(ConfigData.WH_83_100) + .fontColor(Color.Red) + .align(Alignment.Start) + .textAlign(TextAlign.Start) + .margin({ + top: $r('app.float.password_input_message_vertical_margin') + }) +} + +@Extend(Text) function dialogBtnName () { + .fontSize($r('app.float.application_button_subtitle_size')) + .fontColor(Color.Blue) + .textCase(TextCase.UpperCase) +} + +@Extend(Button) function dialogBtn () { + .backgroundColor($r('app.color.color_E3E3E3_grey')) + .width($r("app.float.wh_value_210")) + .height($r("app.float.wh_value_60")) +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/pages/passwordInput.ets b/product/phone/src/main/ets/default/pages/passwordInput.ets new file mode 100644 index 00000000..ba1463b6 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/passwordInput.ets @@ -0,0 +1,405 @@ +/** + * 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/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import Log from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import { BaseData } from '../../../../../../../common/utils/src/main/ets/default/model/BaseData.ets' +import { PinSubType } from '../model/passwordImpl/PasswordModel.ets'; +import PasswordInputController from '../controller/password/PasswordInputController.ets' +import RadioListComponent from '../../../../../../../common/component/src/main/ets/default/radioListComponent.ets'; +import Router from '@system.router'; + +let param; + +@Entry +@Component +struct PasswordInput { + private TAG_PAGE = ConfigData.TAG + 'PasswordInput page' + private mController: PasswordInputController = new PasswordInputController() + +// bind Properties + @State @Watch("clearViewData")private passwordType: number = -1 + @State private checkMessage: string | Resource = '' + private password: string = '' + +// private Properties + private pageRequestCode: number = -1 + private prevPageUri: string = undefined + private pinChallenge: string = undefined + private pinToken: string = undefined + @State private pageTitle: string | Resource = '' + @State private inputMessage: string | Resource = '' + @State private unlockMethodList: BaseData[] = [] + @State private buttonVisibility: Visibility = Visibility.Visible + +// handler + private passwordOnChangeHandler: (value: string) => void; + private okOnClickHandler: (event?: ClickEvent) => void; + private unlockMethodChosenHandler: (value: number) => void; + +//dialog + private chooseUnlockMethodDialog: CustomDialogController = new CustomDialogController({ + builder: chooseUnlockMethodDialog({ + dataList: $unlockMethodList, + checkedValue: $passwordType, + chosenAction: (value) => { + this.unlockMethodChosenHandler(value) + } + }), + autoCancel: true + }); + + @Log + aboutToAppear(): void { + this.getRouterParam() + + // bind event handlers + this.passwordOnChangeHandler = this.mController.passwordOnChange.bind(this.mController); + this.okOnClickHandler = this.mController.inputFinish.bind(this.mController); + this.unlockMethodChosenHandler = this.mController.changePasswordType.bind(this.mController); + + // bind component and initialize + this.mController.bindComponent(this) + .bindProperties(["passwordType", "checkMessage", "password"]) + .initData() + .subscribe(); + + this.updateView(); + } + + @Log + aboutToDisappear(): void { + this.mController.unsubscribe(); + } + +/** + * Get the params from router + */ + @Log + getRouterParam() { + param = Router.getParams() + LogUtil.info(this.TAG_PAGE + 'aboutToAppear : Router param = ' + JSON.stringify(param)) + if (!param) { + return; + } + this.pageRequestCode = param.pageRequestCode; + this.prevPageUri = param.prevPageUri; + this.pinChallenge = param.pinChallenge; + this.pinToken = param.pinToken; + this.passwordType = param.passwordType; + LogUtil.info(this.TAG_PAGE + 'aboutToAppear : from router : pageRequestCode = ' + this.pageRequestCode + + ', prevPageUri = ' + this.prevPageUri + + ', pinChallenge = ' + this.pinChallenge + + ', pinToken = ' + this.pinToken + + ', passwordType = ' + this.passwordType) + } + + build() { + Column() { + // head + HeadComponent({ headName: this.pageTitle, isActive: true }) + + Column() { + // input message + Text(this.inputMessage) + .inputMsg() + + // input password + Row() { + TextInput({ placeholder: '', text: this.password }) + .height($r('app.float.wh_value_70')) + .layoutWeight(1) + .backgroundColor(Color.White) + .type(InputType.Password) + .enterKeyType(EnterKeyType.Done) + .onChange(this.passwordOnChangeHandler); + //todo max length : wait ACE + } + + // prompt message + Text(this.checkMessage ? this.checkMessage : $r('app.string.password_set_prompt')) + .promptMsg() + + // change unlock method + Text($r('app.string.password_change_unlock_method')) + .changeUnlockMethod() + .onClick(() => { + this.chooseUnlockMethodDialog.open() + }) + + // button + Flex( { justifyContent: FlexAlign.SpaceAround } ) { + Button() { + Text($r('app.string.cancel')).dialogBtnName() + } + .dialogBtn() + .onClick(() => { + Router.back(); + }) + + Button() { + Text($r('app.string.continue_')).dialogBtnName() + } + .dialogBtn() + .onClick(this.okOnClickHandler); + } + .margin({ top: $r('app.float.password_input_button_space') }) + .visibility(this.buttonVisibility) + + } + .width(ConfigData.WH_100_100) + .margin({ top: $r('app.float.password_input_button_margin_top') }) + .padding({ + left:$r('app.float.item_common_horizontal_margin'), + right:$r('app.float.item_common_horizontal_margin'), + }) + } + } + +// --------------------------- updateView ----------------------- +/** + * Update view data + */ + @Log + clearViewData() { + this.checkMessage = '' + this.password = '' + this.mController.bindComponent(this).initData() + this.updateView() + } + +/** + * Update view + */ + @Log + updateView() { + this.pageTitle = this.getPageTitle(); + this.inputMessage = this.getInputMessage(); + this.unlockMethodList = this.getUnlockMethodList(); + this.buttonVisibility = this.getButtonVisibility(); + } + +/** + * Get page title + * + * @return : page title + */ + @Log + getPageTitle(): string | Resource { + LogUtil.info(this.TAG_PAGE + 'getPageTitle : passwordType = ' + this.passwordType) + + let title: Resource = $r('app.string.password_enter_password'); + switch (this.passwordType) { + case PinSubType.PIN_SIX: + case PinSubType.PIN_NUMBER: + title = $r('app.string.password_title_number'); + break; + case PinSubType.PIN_MIXED: + title = $r('app.string.password_title_character'); + break; + } + return title; + } + +/** + * Get input message + * + * @return : message + */ + @Log + getInputMessage(): string | Resource { + LogUtil.info(this.TAG_PAGE + 'getInputMessage : passwordType = ' + this.passwordType) + + let inputMessage: string | Resource = ''; + switch (this.passwordType) { + case PinSubType.PIN_SIX: + inputMessage = $r('app.string.password_message_number_6') + break; + + case PinSubType.PIN_NUMBER: + inputMessage = $r('app.string.password_message_custom') + break; + + case PinSubType.PIN_MIXED: + inputMessage = $r('app.string.password_message_character') + break; + } + return inputMessage; + } + +/** + * Get unlock method list. + * + * @return : unlock method list + */ + @Log + getUnlockMethodList(): any[] { + LogUtil.info(this.TAG_PAGE + `setUnlockMethodList : passwordType = ${this.passwordType}`) + + var list : any[] = []; + if (this.passwordType != PinSubType.PIN_SIX) { + list.push({ + settingValue: PinSubType.PIN_SIX, + settingTitle: $r('app.string.password_item_text_number_6'), + settingIcon: '', + settingAlias: '', + settingSummary: '' + }) + } + if (this.passwordType != PinSubType.PIN_NUMBER) { + list.push({ + settingValue: PinSubType.PIN_NUMBER, + settingTitle: $r('app.string.password_item_text_custom'), + settingIcon: '', + settingAlias: '', + settingSummary: '' + }) + } + if (this.passwordType != PinSubType.PIN_MIXED) { + list.push({ + settingValue: PinSubType.PIN_MIXED, + settingTitle: $r('app.string.password_item_text_character') , + settingIcon: '', + settingAlias: '', + settingSummary: '' + }) + } + + LogUtil.info(this.TAG_PAGE + 'setUnlockMethodList : unlockMethodList = ' + JSON.stringify(this.unlockMethodList)) + return list; + } + +/** + * Get button visibility + * + * @return : button visibility + * + */ + @Log + getButtonVisibility(): Visibility { + return this.passwordType == PinSubType.PIN_SIX ? Visibility.Hidden : Visibility.Visible + } + +} + +/** + * Choose Unlock Method Dialog + */ +@CustomDialog +struct chooseUnlockMethodDialog { + controller: CustomDialogController; + @Link dataList: BaseData[]; + @Link checkedValue: string; + private dialogTitle: string= ""; + private chosenAction: (value: number) => void; + + @Log + closeDialog() { + this.controller.close(); + } + + build() { + Column() { + Row() { + Text(this.dialogTitle) + .height($r('app.float.wh_value_60')) + .margin({ left: $r('app.float.wh_value_30') }) + .width(ConfigData.WH_100_100) + .fontSize($r('app.float.font_28')); + } + + Row() { + RadioListComponent({ + dataList: this.dataList, + checkedValue: this.checkedValue, + showRadio: false, + onChange: (item) => { + LogUtil.info(ConfigData.TAG + 'chooseUnlockMethodDialog : onCheckedAction : item = ' + JSON.stringify(item)); + if (this.chosenAction != null) { + LogUtil.info(ConfigData.TAG + 'chooseUnlockMethodDialog : onCheckedAction : call back'); + this.chosenAction(item.settingValue); + } + this.closeDialog(); + } + }) + } + + Column() { + Button() { + Text($r('app.string.cancel')) + .dialogBtnName() + } + .dialogBtn() + .align(Alignment.Bottom) + .onClick(() => { + this.closeDialog(); + }); + } + .width(ConfigData.WH_100_100) + .alignItems(HorizontalAlign.Center) + .margin({ + top: $r('app.float.item_common_vertical_margin'), + bottom: $r('app.float.item_common_vertical_margin') + }) + } + } +} + +@Extend(Text) function inputMsg () { + .fontSize($r('app.float.font_20')) + .fontColor($r('app.color.color_666666_grey')) + .margin({ + top: $r('app.float.password_input_message_vertical_margin'), + bottom: $r('app.float.password_input_message_vertical_margin') + }) + .align(Alignment.Center) +} + +@Extend(Text) function promptMsg () { + .fontSize($r('app.float.font_18')) + .width(ConfigData.WH_83_100) + .fontColor(Color.Red) + .align(Alignment.Start) + .textAlign(TextAlign.Start) + .margin({ + top: $r('app.float.password_input_message_vertical_margin') + }) +} + +@Extend(Text) function changeUnlockMethod () { + .width(ConfigData.WH_100_100) + .fontSize($r('app.float.font_20')) + .fontColor(Color.Blue) + .align(Alignment.Center) + .textAlign(TextAlign.Center) + .visibility(Visibility.Visible) + .padding({ + top: $r('app.float.password_input_message_vertical_margin'), + bottom: $r('app.float.password_input_message_vertical_margin') + }) +} + +@Extend(Text) function dialogBtnName () { + .fontSize($r('app.float.application_button_subtitle_size')) + .fontColor(Color.Blue) + .textCase(TextCase.UpperCase) +} + +@Extend(Button) function dialogBtn () { + .backgroundColor($r('app.color.color_E3E3E3_grey')) + .width($r("app.float.wh_value_210")) + .height($r("app.float.wh_value_60")) +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/pages/passwordRepeat.ets b/product/phone/src/main/ets/default/pages/passwordRepeat.ets new file mode 100644 index 00000000..ff9466ae --- /dev/null +++ b/product/phone/src/main/ets/default/pages/passwordRepeat.ets @@ -0,0 +1,246 @@ +/** + * 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/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import Log from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import { PinSubType } from '../model/passwordImpl/PasswordModel.ets'; +import PasswordRepeatController from '../controller/password/PasswordRepeatController.ets' +import Router from '@system.router'; + +let param; + +@Entry +@Component +struct PasswordRepeat { + private TAG_PAGE = ConfigData.TAG + 'PasswordRepeat page '; + mController: PasswordRepeatController = new PasswordRepeatController() + +// bind Properties + private pinToken: string = undefined + @State private passwordType: number = -1 + @State private inputPassword: string = '' + @State private checkMessage: string | Resource = '' + private password: string = '' + +// handler + private pageRequestCode: number = -1 + private prevPageUri: string = undefined + private pinChallenge: string = undefined + private passwordOnEditChangedHandler: (isEditing: boolean) => void + private passwordOnChangeHandler: (value: string) => void; + private okOnClickHandler: (event?: ClickEvent) => void; + private continueOnClickHandler: (event?: ClickEvent) => void; + +// private Properties + @State private pageTitle: string | Resource = '' + @State private buttonVisibility: Visibility = Visibility.Visible + + @Log + aboutToAppear(): void { + + this.getRouterParam(); + + // bind event handlers + this.passwordOnChangeHandler = this.mController.passwordOnChange.bind(this.mController); + this.okOnClickHandler = this.mController.inputFinish.bind(this.mController); + + // bind component and initialize + this.mController.bindComponent(this) + .bindProperties([ + "pinToken", "passwordType", "inputPassword", "checkMessage", "password" + ]) + .initData() + .subscribe(); + + this.updateView(); + } + + @Log + aboutToDisappear(): void { + this.mController.unsubscribe(); + } + +/** + * Get the params from router + */ + @Log + getRouterParam() { + param = Router.getParams() + LogUtil.info(this.TAG_PAGE + 'aboutToAppear : Router param = ' + JSON.stringify(param)) + + if (!param) { + return; + } + this.pageRequestCode = param.pageRequestCode; + this.prevPageUri = param.prevPageUri; + this.pinChallenge = param.pinChallenge; + this.pinToken = param.pinToken; + this.inputPassword = param.inputPassword; + this.passwordType = param.passwordType; + LogUtil.info(this.TAG_PAGE + 'aboutToAppear : from router : pageRequestCode = ' + this.pageRequestCode + + ', prevPageUri = ' + this.prevPageUri + + ', pinChallenge = ' + this.pinChallenge + + ', pinToken = ' + this.pinToken + + ', inputPassword = ' + this.inputPassword + + ', passwordType = ' + this.passwordType) + } + + build() { + Column() { + // head + HeadComponent({ headName: this.pageTitle, isActive: true }) + + Column() { + // input message + Text($r('app.string.password_message_repeat')) + .inputMsg() + + // input password + Row() { + TextInput({ placeholder: '', text: this.password }) + .height($r('app.float.wh_value_70')) + .layoutWeight(1) + .backgroundColor(Color.White) + .type(InputType.Password) + .enterKeyType(EnterKeyType.Done) + .onChange(this.passwordOnChangeHandler); + } + + // prompt message + Text(this.checkMessage ? this.checkMessage : $r("app.string.password_set_prompt")) + .promptMsg() + + // change unlock method (Hidden) + Text($r('app.string.password_change_unlock_method')) + .changeUnlockMethod() + + // button + Flex( { justifyContent: FlexAlign.SpaceAround } ) { + Button() { + Text($r('app.string.cancel')).dialogBtnName() + } + .dialogBtn() + .onClick(() => { + Router.back(); + }) + + Button() { + Text($r('app.string.confirm')).dialogBtnName() + } + .dialogBtn() + .onClick(this.okOnClickHandler); + } + .margin({ top: $r('app.float.password_input_button_space') }) + .visibility(this.buttonVisibility) + + } + .width(ConfigData.WH_100_100) + .margin({ top: $r('app.float.password_input_button_margin_top') }) + .padding({ + left:$r('app.float.item_common_horizontal_margin'), + right:$r('app.float.item_common_horizontal_margin'), + }) + } + } + +// --------------------------- updateView ----------------------- +/** + * Update view + */ + @Log + updateView() { + this.pageTitle = this.getPageTitle(); + this.buttonVisibility = this.getButtonVisibility(); + } + +/** + * Get page title + * + * @return : page title + */ + @Log + getPageTitle(): string | Resource { + let title: Resource = $r('app.string.password_enter_password'); + + switch (this.passwordType) { + case PinSubType.PIN_SIX: + case PinSubType.PIN_NUMBER: + title = $r('app.string.password_title_number'); + break; + case PinSubType.PIN_MIXED: + title = $r('app.string.password_title_character'); + break; + } + return title; + } + +/** + * Get button visibility + * + * @return : button visibility + */ + @Log + getButtonVisibility(): Visibility { + return this.passwordType == PinSubType.PIN_SIX ? Visibility.Hidden : Visibility.Visible; + } + +} + +@Extend(Text) function inputMsg () { + .fontSize($r('app.float.font_20')) + .fontColor($r('app.color.color_666666_grey')) + .margin({ + top: $r('app.float.password_input_message_vertical_margin'), + bottom: $r('app.float.password_input_message_vertical_margin') + }) + .align(Alignment.Center) +} + +@Extend(Text) function promptMsg () { + .fontSize($r('app.float.font_18')) + .width(ConfigData.WH_83_100) + .fontColor(Color.Red) + .align(Alignment.Start) + .textAlign(TextAlign.Start) + .margin({ + top: $r('app.float.password_input_message_vertical_margin') + }) +} + +@Extend(Text) function changeUnlockMethod () { + .width(ConfigData.WH_100_100) + .fontSize($r('app.float.font_20')) + .fontColor(Color.Blue) + .align(Alignment.Center) + .textAlign(TextAlign.Center) + .visibility(Visibility.Hidden) + .padding({ + top: $r('app.float.password_input_message_vertical_margin'), + bottom: $r('app.float.password_input_message_vertical_margin') + }) +} + +@Extend(Text) function dialogBtnName () { + .fontSize($r('app.float.application_button_subtitle_size')) + .fontColor(Color.Blue) + .textCase(TextCase.UpperCase) +} + +@Extend(Button) function dialogBtn () { + .backgroundColor($r('app.color.color_E3E3E3_grey')) + .width($r("app.float.wh_value_210")) + .height($r("app.float.wh_value_60")) +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/pages/passwordSetting.ets b/product/phone/src/main/ets/default/pages/passwordSetting.ets new file mode 100644 index 00000000..52d9480c --- /dev/null +++ b/product/phone/src/main/ets/default/pages/passwordSetting.ets @@ -0,0 +1,285 @@ +/** + * 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 prompt from '@system.prompt'; +import FeatureAbility from '@ohos.ability.featureAbility'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import Log from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import PasswordListController from '../controller/password/PasswordSettingController.ets'; +import EntryComponent from '../../../../../../../common/component/src/main/ets/default/entryComponent.ets'; +import Router from '@system.router'; + +@Entry +@Component +struct PasswordSetting { + private TAG_PAGE = ConfigData.TAG + 'PasswordSetting page '; + private mController: PasswordListController = new PasswordListController(); + +// bind Properties + @State private passwordList: any[] = []; + private pinChallenge: string = ''; + +// private Properties + private lockUi: boolean = false // prevent continuous and multiple clicks + private delItem: any; + +// dialog + private unlockDialog : CustomDialogController = new CustomDialogController({ + builder: UnlockDialog({ + confirmAction: (item) => { + LogUtil.info(this.TAG_PAGE + ' dialog disable button onclick.') + this.gotoNextPage(this.delItem); + } + }), + autoCancel: true + }); + + @Log + aboutToAppear(): void { + + // bind component and initialize + this.mController.bindComponent(this) + .bindProperties(["passwordList", "pinChallenge"]) + .initData() + .subscribe(); + } + + @Log + aboutToDisappear(): void { + this.mController.unsubscribe(); + } + + @Log + onPageShow(): void { + this.mController.loadData(); + } + + build() { + Column() { + HeadComponent({ headName: $r('app.string.biometricsAndPassword'), isActive: true }) + + List() { + ForEach(this.passwordList, (item) => { + + if (item.settingShouldDisplay) { + + if (item.settingIsSectionTitle) { + ListItem() { + Text(item.settingTitle).sectionTitle() + } + + } else if (item.settingAlias == 'password_disable_password') { + ListItem() { + EntryComponent({ + settingIcon: '', + settingTitle: item.settingTitle, + settingSummary: '', + settingValue: item.settingValue, + settingArrow: item.settingArrow, + settingArrowStyle: '', + settingUri: item.settingUri, + titleFontColor: Color.Blue + }); + } + .height($r('app.float.wh_value_70')) + .onClick(() => { + if (this.lockUi) { + return; + } + this.lockUi = true + LogUtil.info(this.TAG_PAGE + ' disable password onclick : item = ' + JSON.stringify(item)) + this.delItem = item + this.unlockDialog.open(); + this.lockUi = false + }); + + } else if (item.settingAlias == "face_recognition") { + ListItem() { + EntryComponent({ + settingIcon: '', + settingTitle: item.settingTitle, + settingSummary: '', + settingValue: item.settingValue, + settingArrow: item.settingArrow, + settingArrowStyle: '', + settingUri: item.settingUri, + titleFontColor: Color.Blue + }); + } + .height($r('app.float.wh_value_70')) + .onClick(()=>{ + FeatureAbility.startAbility({ + want: { + bundleName: ConfigData.FACEAUTH_BUNDLE_NAME, + abilityName: ConfigData.FACEAUTH_ABILITY_NAME + } + }) + .then((data) => { + LogUtil.info(`${this.TAG_PAGE}, ${ConfigData.FACEAUTH_BUNDLE_NAME} start successful. Data: ${JSON.stringify(data)}`); + }) + .catch((error) => { + prompt.showToast({ + message: $r("app.string.faceauthFailed"), + duration: 2000 + }) + LogUtil.error(`${this.TAG_PAGE}, ${ConfigData.FACEAUTH_BUNDLE_NAME} start failed. Cause: ${JSON.stringify(error)}`); + }) + }) + } else { + ListItem() { + EntryComponent({ + settingIcon: '', + settingTitle: item.settingTitle, + settingSummary: '', + settingValue: item.settingValue, + settingArrow: item.settingArrow, + settingArrowStyle: '', + settingUri: item.settingUri, + }); + } + .height($r('app.float.wh_value_70')) + .onClick(() => { + if (this.lockUi) { + return; + } + this.lockUi = true + LogUtil.info(this.TAG_PAGE + ' item onclick : item = ' + JSON.stringify(item)) + this.gotoNextPage(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) + .alignSelf(ItemAlign.Start); + + } + } + +//------------------------------ Router --------------------------- +/** + * Go to password page + * + * @param uri : page uri + * @param pageRequestCode : page request code + */ + @Log + gotoNextPage(item: any) { + if (!item.settingUri) { + return + } + Router.push({ + uri: item.settingUri, + params: { + 'pageRequestCode': item.settingRequestCode, + 'prevPageUri': 'pages/passwordSetting', + 'pinChallenge': this.pinChallenge + }, + }); + } +} + +@CustomDialog +struct UnlockDialog { + controller: CustomDialogController; + item: any; + confirmAction: (item: any) => void; + + @Log + closeDialog() { + this.controller.close(); + } + + build() { + Column() { + // title + Row() { + Text($r("app.string.password_select_unlock_method")) + .height($r('app.float.wh_value_60')) + .margin({ left: $r('app.float.wh_value_30') }) + .width(ConfigData.WH_100_100) + .fontSize($r('app.float.font_28')); + } + + // message + Row() { + Text($r("app.string.password_disable_prompt")) + .margin({ + top: $r('app.float.item_common_vertical_margin'), + bottom: $r('app.float.item_common_vertical_margin'), + left: $r('app.float.wh_value_30') }) + .fontSize($r('app.float.font_22')); + } + + Flex({ justifyContent: FlexAlign.SpaceAround }) { + Button() { + Text($r('app.string.cancel')) + .dialogBtnName() + } + .dialogBtn() + .align(Alignment.Bottom) + .onClick(() => { + this.closeDialog(); + }); + Button() { + Text($r('app.string.disable_')) + .dialogBtnName() + } + .dialogBtn() + .align(Alignment.Bottom) + .onClick(() => { + this.confirmAction(this.item) + this.closeDialog(); + }); + } + .width(ConfigData.WH_100_100) + .margin({ + top: $r('app.float.item_common_vertical_margin'), + bottom: $r('app.float.item_common_vertical_margin') }) + } + } +} + +@Extend(Text) function sectionTitle () { + .width(ConfigData.WH_100_100) + .height($r('app.float.wh_value_60')) + .fontSize($r('app.float.font_20')) + .fontWeight(FontWeight.Normal) + .fontColor(Color.Grey) + .maxLines(ConfigData.MAX_LINES_1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }) +} + +@Extend(Text) function dialogBtnName () { + .fontSize($r('app.float.application_button_subtitle_size')) + .fontColor(Color.Blue) + .textCase(TextCase.UpperCase) +} + +@Extend(Button) function dialogBtn () { + .backgroundColor($r('app.color.color_E3E3E3_grey')) + .width($r("app.float.wh_value_210")) + .height($r("app.float.wh_value_60")) +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/pages/privacy.ets b/product/phone/src/main/ets/default/pages/privacy.ets new file mode 100644 index 00000000..3a60e12e --- /dev/null +++ b/product/phone/src/main/ets/default/pages/privacy.ets @@ -0,0 +1,108 @@ +/** + * 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 prompt from '@system.prompt'; +import FeatureAbility from '@ohos.ability.featureAbility'; +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; + +/** + * Home Page Of Privacy Settings + */ +@Entry +@Component +struct PrivacySettings { + private TAG = `${ConfigData.TAG} PrivacySettings`; + + build() { + Column() { + HeadComponent({ headName: $r('app.string.privacy'), isActive: true }) + Row(){ + ChildComponent({textStr: $r('app.string.permissionManager')}) + } + .onClick(()=>{ + FeatureAbility.startAbility({ + want: { + bundleName: ConfigData.PERMISSION_MANAGER_BUNDLE_NAME, + abilityName: ConfigData.PERMISSION_MANAGER_ABILITY_NAME, + } + }) + .then((data) => { + LogUtil.info(`${this.TAG}, ${ConfigData.PERMISSION_MANAGER_BUNDLE_NAME} start successful. Data: ${JSON.stringify(data)}`); + }) + .catch((error) => { + prompt.showToast({ + message: $r("app.string.permissionFailed"), + duration: 2000, + }); + LogUtil.error(`${this.TAG}, ${ConfigData.PERMISSION_MANAGER_BUNDLE_NAME} start failed. Cause: ${JSON.stringify(error)}`); + }) + }); + + Navigator({ target: 'pages/locationServices' }) { + ChildComponent({ textStr: $r('app.string.locationServicesTab') }); + } + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100) + .backgroundColor($r("app.color.color_E3E3E3_grey")); + } + + aboutToAppear(){ + LogUtil.info(`${this.TAG} aboutToAppear in`); + LogUtil.info(`${this.TAG} aboutToAppear out`); + } + + aboutToDisappear(){ + LogUtil.info(`${this.TAG} aboutToDisappear in`); + LogUtil.info(`${this.TAG} aboutToDisappear out`); + } + +} + + +@Component +struct ChildComponent{ + private textStr; + @State isTouched:boolean = false; + + build(){ + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems:ItemAlign.Center }) { + Row() { + Text(this.textStr) + .fontSize($r('app.float.font_22')) + .fontColor($r('app.color.font_color_182431')) + .margin({left:$r('app.float.distance_24'), top:$r('app.float.distance_8'), bottom:$r('app.float.distance_8'), right:0}) + .textAlign(TextAlign.Start); + } + Image('/res/image/ic_settings_arrow.svg') + .width($r('app.float.wh_value_40')) + .height($r('app.float.wh_value_40')); + } + .backgroundColor(this.isTouched ? $r("app.color.color_D8D8D8_grey"):$r("app.color.white_bg_color")) + .height($r('app.float.wh_value_56')) + .margin({left:$r('app.float.distance_24'), right:$r('app.float.distance_24'), top:$r('app.float.distance_16')}) + .borderRadius($r('app.float.radius_24')) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isTouched = true; + } + if (event.type === TouchType.Up) { + this.isTouched = false; + } + }); + } +} + diff --git a/product/phone/src/main/ets/default/pages/restoreFactorySettings.ets b/product/phone/src/main/ets/default/pages/restoreFactorySettings.ets new file mode 100644 index 00000000..af835eef --- /dev/null +++ b/product/phone/src/main/ets/default/pages/restoreFactorySettings.ets @@ -0,0 +1,68 @@ +/** + * 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 '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import RestoreFactorySettingsController from '../controller/restoreFactorySettings/restoreFactorySettingsController.ets' +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; + +/** + * Developer options + */ +@Entry +@Component +struct restoreFactorySettings { + private controller: RestoreFactorySettingsController = new RestoreFactorySettingsController(); + + build() { + Column() { + HeadComponent({ headName: $r("app.string.restoreFactoryTab"), isActive: true }); + Button() { + Text($r("app.string.restoreFactoryTab")) + .fontSize($r('app.float.restore_factory_font_size')) + .fontColor(Color.Blue) + } + .backgroundColor($r('app.color.color_E3E3E3_grey')) + .width($r('app.float.restore_factory_button_width')) + .height($r('app.float.restore_factory_button_height')) + .align(Alignment.Bottom) + .onClick(this.getRestoreFactory); + } + } + + /** + * Get restoreFactory + */ + private getRestoreFactory = (event) => { + AlertDialog.show({ + title: $r('app.string.restoreFactoryTab'), + message: $r("app.string.restoreFactory"), + primaryButton: { + value: $r('app.string.confirm'), + action: () => { + // TODO need PW + this.controller.restoreFactorySettings(); + LogUtil.info(ConfigData.TAG + `AlertDialog success:`); + } + }, + secondaryButton: { + value: $r('app.string.cancel'), + action: () => { + LogUtil.info(ConfigData.TAG + 'Closed callbacks'); + } + } + }) + } +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/pages/searchPage.ets b/product/phone/src/main/ets/default/pages/searchPage.ets new file mode 100644 index 00000000..865d86b5 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/searchPage.ets @@ -0,0 +1,133 @@ +/** + * 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/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import Log from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import ResultComponent from '../../../../../../../common/search/src/main/ets/default/page/resultComponent.ets'; +import SearchHeader from '../../../../../../../common/search/src/main/ets/default/page/searchHeader.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import SearchModel from '../../../../../../../common/search/src/main/ets/default/model/SearchModel.ets'; +import SearchUtil from '../../../../../../../common/search/src/main/ets/default/common/SearchUtil.ets'; +import SearchData from '../../../../../../../common/search/src/main/ets/default/model/SearchData'; +import SEARCH_DATA_CONFIG from '../model/search/SearchDataConfig.ets'; +import Router from '@system.router' + +let SEARCH_INPUT_MAX_LENGTH = 100; + +/** + * search page + */ +@Entry +@Component +struct SearchPage { + @State @Watch('setSearchKeyword') inputKeyword: string = '' + @State @Watch('doSearch') searchKeyword: string = '' + @State searchResultList: SearchData[] = [] + + private searchModel: SearchModel; + + build() { + Column() { + SearchHeader({ inputKeyword: $inputKeyword }) + + if (this.searchKeyword) { + + // search result exist + if (this.searchResultList && this.searchResultList.length > 0) { + + // search result list + List() { + + // item + ForEach(this.searchResultList.map((item1, index1) => { + return { index: index1, data: item1 } + }), item => { + + ListItem() { + Column() { + Navigator({ target: item.data.uri }) { + ResultComponent({ + highlightKeyword: $searchKeyword, + icon: item.index == 0 ? item.data.icon : '', + data: item.data + }); + } + + if (item.index != (this.searchResultList.length - 1)) { + Divider() + .strokeWidth(1) + .color($r("app.color.color_E3E3E3_grey")) + .margin({ left: $r('app.float.wh_value_65') }) + } + } + } + }) + } + .width(ConfigData.WH_100_100) + .layoutWeight(1) + .alignSelf(ItemAlign.Start) + + } else { + + // search no match + Text($r('app.string.searchNoResult')) + .height($r("app.float.search_no_result_height")) + .fontSize($r('app.float.font_24')) + .fontColor($r("app.color.color_E3E3E3_grey")) + .fontWeight(FontWeight.Medium) + .alignSelf(ItemAlign.Center); + } + } + } + } + + @Log + aboutToAppear(): void { + + // init search data + this.searchModel = new SearchModel(SEARCH_DATA_CONFIG); + this.searchModel.initSearchData() + .then(() => { + LogUtil.debug(ConfigData.TAG + 'searchPage aboutToAppear initSearchData complete'); + this.doSearch() + }) + } + + @Log + onBackPress() { + Router.back(); + } + + /** + * set search keyword + */ + @Log + setSearchKeyword() { + this.searchKeyword = SearchUtil.stripKeyword(this.inputKeyword).trim() + } + + /** + * search + */ + @Log + doSearch() { + this.searchModel.search(this.searchKeyword) + .then((result: SearchData[]) => { + LogUtil.debug(ConfigData.TAG + 'searchPage doSearch : search : searchKeyword = ' + + this.searchKeyword + '; => then data = ' + JSON.stringify(result)); + this.searchResultList = undefined + this.searchResultList = result + }) + } +} diff --git a/entry/src/main/ets/default/pages/settingList.ets b/product/phone/src/main/ets/default/pages/settingList.ets similarity index 75% rename from entry/src/main/ets/default/pages/settingList.ets rename to product/phone/src/main/ets/default/pages/settingList.ets index 562a932d..8c3511af 100644 --- a/entry/src/main/ets/default/pages/settingList.ets +++ b/product/phone/src/main/ets/default/pages/settingList.ets @@ -12,23 +12,25 @@ * 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 LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import EntryComponent from '../../../../../../../common/component/src/main/ets/default/entryComponent.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; import SettingListModel from '../model/settingListImpl/SettingListModel.ets'; import WifiModel from '../model/wifiImpl/WifiModel.ets'; -import SubscriberUtils from '../common/baseUtil/SubscriberUtil.ets'; -import GlobalResourceManager from '../common/baseUtil/GlobalResourceManager.ets'; -import BrightnessSettingModel from '../model/brightnessImpl/BrightnessSettingModel.ets'; +import SubscriberUtils from '../../../../../../../common/utils/src/main/ets/default/baseUtil/SubscriberUtil.ets'; +import GlobalResourceManager from '../../../../../../../common/utils/src/main/ets/default/baseUtil/GlobalResourceManager.ets'; +import PreferenceUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/PreferenceUtil.ets'; import DataRdbService from '../model/dataRdbImpl/DataRdbService.ets'; import DataRdbModel from '../model/dataRdbImpl/DataRdbModel.ets'; -import Stable from '../common/baseUtil/Global.ets'; -import RdbStoreUtil from '../common/baseUtil/RdbStoreUtil.ets'; +import Stable from '../../../../../../../common/utils/src/main/ets/default/baseUtil/Global.ets'; +import RdbStoreUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets'; +import ResourceUtil from '../../../../../../../common/search/src/main/ets/default/common/ResourceUtil.ets'; import Router from '@system.router'; const SETTING_LIST_INDEX = 0; const PAGE_WIFI = 'pages/wifi'; +const PAGE_SEARCH = 'pages/searchPage'; // for search /** * setting home page @@ -39,10 +41,32 @@ struct SettingList { @StorageLink('settingsList') settingsList: any[]= []; @State wifiStatus: boolean= false; @State status: any= ''; + @State placeholder: string= ''; // for search build() { Column() { HeadComponent({ icBackIsVisibility: false, headName: $r('app.string.settings'), isActive: false }); + + // for search + Navigator({ target: PAGE_SEARCH }) { + TextInput({ placeholder: this.placeholder, text: '' }) + .margin({ left: $r('app.float.item_common_horizontal_margin'), right: $r('app.float.item_common_horizontal_margin') }) + .placeholderFont({size:10,weight:FontWeight.Normal,style:FontStyle.Normal}) + .type(InputType.Normal) + .enterKeyType(EnterKeyType.Search) + .caretColor(Color.Green) + .layoutWeight(1) + .height($r("app.float.search_input_height")) + .borderRadius($r("app.float.search_input_border_radius")) + .backgroundColor(Color.White) + .enabled(false) + }.onClick(() => { + LogUtil.info('On click the search editText.'); + Router.push({ + uri: PAGE_SEARCH + }) + }) + List() { ForEach(this.settingsList, (item) => { ListItem() { @@ -88,14 +112,15 @@ struct SettingList { LogUtil.info('settings SettingList aboutToAppear startPage'); SettingListModel.startPage(this.jumpPage); let nYear = GlobalResourceManager.getStringByResource($r('app.string.year')); - nYear.then(resp => BrightnessSettingModel.setStorageValue(ConfigData.DATE_AND_TIME_YEAR, resp)); + nYear.then(resp => PreferenceUtil.setStorageValue(ConfigData.DATE_AND_TIME_YEAR, resp)); let nMonth = GlobalResourceManager.getStringByResource($r('app.string.month')); - nMonth.then(resp => BrightnessSettingModel.setStorageValue(ConfigData.DATE_AND_TIME_MONTH, resp)); + nMonth.then(resp => PreferenceUtil.setStorageValue(ConfigData.DATE_AND_TIME_MONTH, resp)); let nDay = GlobalResourceManager.getStringByResource($r('app.string.day')); nDay.then(resp => { - BrightnessSettingModel.setStorageValue(ConfigData.DATE_AND_TIME_DAY, resp); - LogUtil.info('SettingList day:' + BrightnessSettingModel.getStorageValue(ConfigData.DATE_AND_TIME_DAY, '')); + PreferenceUtil.setStorageValue(ConfigData.DATE_AND_TIME_DAY, resp); + LogUtil.info('SettingList day:' + PreferenceUtil.getStorageValue(ConfigData.DATE_AND_TIME_DAY, '')); }) + ResourceUtil.getString($r("app.string.searchHint")).then(value => this.placeholder = value) // for search LogUtil.info('settings SettingList aboutToAppear end'); } @@ -148,7 +173,7 @@ struct SettingList { }, 7000); LogUtil.info('settings SettingList onPageShow in:' + JSON.stringify(this.settingsList)); - this.wifiStatus = WifiModel.getWifiStatus(); + this.wifiStatus = WifiModel.isWiFiActive(); LogUtil.info('settings SettingList onPageShow this.wifiStatus:' + this.wifiStatus); for (let key in this.settingsList) { let settingAlias = this.settingsList[key].settingAlias; diff --git a/product/phone/src/main/ets/default/pages/storage.ets b/product/phone/src/main/ets/default/pages/storage.ets new file mode 100644 index 00000000..f1ce9cd5 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/storage.ets @@ -0,0 +1,74 @@ +/** + * 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 '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import EntryComponent from '../../../../../../../common/component/src/main/ets/default/entryComponent.ets'; +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import StorageController from '../controller/storage/storageController.ets'; + +/** + * Storage + */ +@Entry +@Component +struct Storage { + @State storageList: any[] = []; + private controller: StorageController = new StorageController(); + + build() { + Column() { + HeadComponent({ headName: $r('app.string.storageTab'), isActive: true }); + // TODO need UX + List() { + ForEach(this.storageList, (item) => { + ListItem() { + EntryComponent({ + settingIcon: '', + settingTitle: item.settingTitle, + settingSummary: '', + settingValue: item.settingValue, + settingArrow: '', + settingArrowStyle: '', + settingUri: '' + }); + } + }); + } + .divider({ + strokeWidth: 1, + color: $r('app.color.color_E3E3E3_grey'), + startMargin: $r('app.float.storage_common_margin'), + endMargin: $r('app.float.storage_common_margin') + }) + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100) + .alignSelf(ItemAlign.Start); + } + } + + aboutToAppear(): void{ + // bind component and initialize + if (this.controller) { + this.controller.bindComponent(this) + .bindProperties(["storageList"]) + .initData(); + } + LogUtil.info(ConfigData.TAG + 'aboutToAppear storageList in' + JSON.stringify(this.storageList)); + } +} + + + diff --git a/product/phone/src/main/ets/default/pages/system/homePage.ets b/product/phone/src/main/ets/default/pages/system/homePage.ets new file mode 100644 index 00000000..91771417 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/system/homePage.ets @@ -0,0 +1,72 @@ +/** + * 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/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import HeadComponent from '../../../../../../../../common/component/src/main/ets/default/headComponent.ets'; + +/** + * Home Page Of System Settings + */ +@Entry +@Component +struct SystemSettings { + @State touchedItem:boolean = false; + private TAG = `${ConfigData.TAG} SystemSettings`; + + build() { + Column() { + HeadComponent({ headName: $r('app.string.systemTab'), isActive: true }) + Navigator({target: 'pages/system/languageSettings/homePage'}) { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems:ItemAlign.Center }) { + Row() { + Text($r("app.string.setlanguage")) + .fontSize($r('app.float.font_22')) + .fontColor($r('app.color.font_color_182431')) + .margin({left:$r('app.float.distance_24'), top:$r('app.float.distance_8'), bottom:$r('app.float.distance_8'), right:0}) + .textAlign(TextAlign.Start); + } + Image('/res/image/ic_settings_arrow.svg') + .width($r('app.float.wh_value_40')) + .height($r('app.float.wh_value_40')); + } + .backgroundColor(this.touchedItem? $r("app.color.color_D8D8D8_grey"):$r("app.color.white_bg_color")) + .height($r('app.float.wh_value_56')) + .margin({left:$r('app.float.distance_24'), right:$r('app.float.distance_24'), top:$r('app.float.distance_16')}) + .borderRadius($r('app.float.radius_24')) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.touchedItem = true; + } + if (event.type === TouchType.Up) { + this.touchedItem = false; + } + }); + } + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100) + .backgroundColor($r("app.color.color_E3E3E3_grey")); + } + + aboutToAppear(){ + LogUtil.info(`${this.TAG} aboutToAppear in`); + LogUtil.info(`${this.TAG} aboutToAppear out`); + } + + aboutToDisappear(){ + LogUtil.info(`${this.TAG} aboutToDisappear in`); + LogUtil.info(`${this.TAG} aboutToDisappear out`); + } +} diff --git a/product/phone/src/main/ets/default/pages/system/languageSettings/homePage.ets b/product/phone/src/main/ets/default/pages/system/languageSettings/homePage.ets new file mode 100644 index 00000000..3788b358 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/system/languageSettings/homePage.ets @@ -0,0 +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 LogUtil from '../../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import HeadComponent from '../../../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import ConfigData from '../../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; + +/** + * Home Page Of Language Settings + */ +@Entry +@Component +struct LanguageSettings { + @State touchedItem:boolean = false; + private TAG = `${ConfigData.TAG} LanguageSettings`; + + build() { + Column() { + HeadComponent({ headName: $r('app.string.setlanguage'), isActive: true }) + Navigator({target: 'pages/system/languageSettings/languageAndRegion/homePage'}){ + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems:ItemAlign.Center }) { + Row() { + Text($r("app.string.languageAndRegion")) + .fontSize($r("app.float.font_22")) + .fontColor($r("app.color.font_color_182431")) + .margin({left:$r('app.float.distance_24'), top:$r('app.float.distance_8'), bottom:$r('app.float.distance_8')}) + .textAlign(TextAlign.Start); + } + Image('/res/image/ic_settings_arrow.svg') + .width($r('app.float.wh_value_40')) + .height($r('app.float.wh_value_40')); + } + .height($r('app.float.wh_value_56')) + .backgroundColor(this.touchedItem? $r("app.color.color_D8D8D8_grey"):$r("app.color.white_bg_color")) + .margin({left:$r('app.float.distance_24'), right:$r('app.float.distance_24'), top:$r('app.float.distance_16')}) + .borderRadius($r('app.float.radius_24')) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.touchedItem = true; + } + if (event.type === TouchType.Up) { + this.touchedItem = false; + } + }) + + } + } + .height(ConfigData.WH_100_100) + .width(ConfigData.WH_100_100) + .backgroundColor($r("app.color.color_E3E3E3_grey")); + } + + aboutToAppear(){ + LogUtil.info(`${this.TAG} aboutToAppear in`); + LogUtil.info(`${this.TAG} aboutToAppear out`); + } + + aboutToDisappear(){ + LogUtil.info(`${this.TAG} aboutToDisappear in`); + LogUtil.info(`${this.TAG} aboutToDisappear out`); + } + +} + diff --git a/product/phone/src/main/ets/default/pages/system/languageSettings/languageAndRegion/addLanguage.ets b/product/phone/src/main/ets/default/pages/system/languageSettings/languageAndRegion/addLanguage.ets new file mode 100644 index 00000000..86a0c514 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/system/languageSettings/languageAndRegion/addLanguage.ets @@ -0,0 +1,234 @@ +/** + * 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 prompt from '@system.prompt'; +import LogUtil from '../../../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import HeadComponent from '../../../../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import ConfigData from '../../../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import BasicDataSource from '../../../../../../../../../../common/utils/src/main/ets/default/model/BasicDataSource.ets'; +import LanguageAndRegionModel from '../../../../../default/model/systemImpl/languageSettings/LanguageAndRegionModel.ets' + +/** + * Home Page Of AddLanguage + */ +@Entry +@Component +struct AddLanguage { + private TAG = `${ConfigData.TAG} AddLanguage`; + + build() { + Column() { + HeadComponent({ headName: $r('app.string.addLanguage'), isActive: true }) + List({space: 10, initialIndex: 0}){ + ListItem() { + Text($r("app.string.addedLanguage")) + .fontSize($r("app.float.font_22")) + .fontColor($r("app.color.font_color_182431")) + .width(ConfigData.WH_100_100) + .height($r("app.float.wh_value_26")) + .textAlign(TextAlign.Start) + }.padding($r("app.float.distance_24")); + + ListItem() { + AddedLanguagesList(); + } + + ListItem() { + Text($r("app.string.allLanguage")) + .fontSize($r("app.float.font_22")) + .fontColor($r("app.color.font_color_182431")) + .width(ConfigData.WH_100_100) + .height($r("app.float.wh_value_26")) + .textAlign(TextAlign.Start) + }.padding($r("app.float.distance_24")); + + ListItem() { + AllLanguagesList(); + } + } + .margin({ left:$r("app.float.distance_24"), right:$r("app.float.distance_24"), top:$r("app.float.distance_16"), bottom:$r("app.float.distance_80") }) + .edgeEffect(EdgeEffect.Spring); + } + .height(ConfigData.WH_100_100) + .width(ConfigData.WH_100_100) + .backgroundColor($r("app.color.color_E3E3E3_grey")); + } + + aboutToAppear(){ + LogUtil.info(`${this.TAG} aboutToAppear in`); + LogUtil.info(`${this.TAG} aboutToAppear out`); + } + + aboutToDisappear(){ + LogUtil.info(`${this.TAG} aboutToDisappear in`); + LogUtil.info(`${this.TAG} aboutToDisappear out`); + } + +} + + +/** + * List Of Added Language + */ +@Component +struct AddedLanguagesList { + @StorageLink('addedLanguages') addedLanguages:Array = LanguageAndRegionModel.getAddedLanguages(); + @State touchedItem:string = ''; + + build(){ + List({space:0}){ + ForEach(this.addedLanguages, (item) => { + ListItem(){ + Column(){ + Text(LanguageAndRegionModel.getSysDisplayLanguage(item)) + .fontSize($r("app.float.font_28")) + .height($r("app.float.wh_value_32")) + .margin({right:$r("app.float.distance_16"),top:$r("app.float.distance_20"),bottom:$r("app.float.distance_8")}) + .fontColor($r("app.color.font_color_182431")) + .textAlign(TextAlign.Start); + Text(LanguageAndRegionModel.getDisplayLanguage(item)) + .fontSize($r("app.float.font_22")) + .height($r("app.float.wh_value_26")) + .margin({right:$r("app.float.distance_16"),bottom:$r("app.float.distance_20")}) + .fontColor($r("app.color.font_color_182431")) + .textAlign(TextAlign.Start); + } + .alignItems(HorizontalAlign.Start); + } + .align(Alignment.Start) + .width(ConfigData.WH_100_100) + .padding({ left: $r("app.float.distance_16"), right: $r("app.float.distance_16") }) + .borderRadius($r("app.float.radius_24")) + .backgroundColor(item === this.touchedItem ? $r("app.color.color_D8D8D8_grey"):$r("app.color.white_bg_color")) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.touchedItem = item; + } + if (event.type === TouchType.Up) { + this.touchedItem = ''; + } + }) + }, item => item); + } + .padding($r("app.float.distance_8")) + .borderRadius($r("app.float.radius_40")) + .divider({strokeWidth: 1, color: $r("app.color.color_E3E3E3_grey"), startMargin:$r("app.float.distance_16"), endMargin:$r("app.float.distance_16")}) + .backgroundColor($r("app.color.white_bg_color")); + } +} + + +/** + * List Of All Language + */ +@Component +struct AllLanguagesList { + private allLanguages: AllLanguages = new AllLanguages(LanguageAndRegionModel.getAllLanguages()); + @State touchedItem:string = ''; + + build(){ + List({space:0}){ + LazyForEach(this.allLanguages, (item) => { + ListItem(){ + Column(){ + Text(LanguageAndRegionModel.getSysDisplayLanguage(item)) + .fontSize($r("app.float.font_28")) + .height($r("app.float.wh_value_32")) + .margin({right:$r("app.float.distance_16"),top:$r("app.float.distance_20"),bottom:$r("app.float.distance_8")}) + .fontColor($r("app.color.font_color_182431")) + .textAlign(TextAlign.Start); + Text(LanguageAndRegionModel.getDisplayLanguage(item)) + .fontSize($r("app.float.font_22")) + .height($r("app.float.wh_value_26")) + .margin({right:$r("app.float.distance_16"),bottom:$r("app.float.distance_20")}) + .fontColor($r("app.color.font_color_182431")) + .textAlign(TextAlign.Start); + } + .alignItems(HorizontalAlign.Start); + } + .align(Alignment.Start) + .width(ConfigData.WH_100_100) + .padding({ left: $r("app.float.distance_16"), right: $r("app.float.distance_16") }) + .borderRadius($r("app.float.radius_24")) + .backgroundColor(item === this.touchedItem ? $r("app.color.color_D8D8D8_grey"):$r("app.color.white_bg_color")) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.touchedItem = item; + } + if (event.type === TouchType.Up) { + this.touchedItem = ''; + } + }) + .onClick(() => { + if(! LanguageAndRegionModel.isInAddedLanguage(item)){ + LanguageAndRegionModel.addLanguage(item); + AlertDialog.show( + { + message: $r("app.string.changeLanguage", LanguageAndRegionModel.getSysDisplayLanguage(item)), + primaryButton:{ + value: $r("app.string.keepCurrent"), + action:() => { + router.back(); + console.log('callback when first button clicked'); + } + }, + secondaryButton:{ + value: $r("app.string.change"), + action:() => { + LanguageAndRegionModel.setSystemLanguage(item); + router.back(); + console.log('callback when first button clicked'); + } + }, + cancel: () => { + console.info('cancel'); + } + } + ) + }else{ + prompt.showToast({ + message: $r("app.string.hasAdded"), + duration: 2000, + }) + } + }) + }, item => item); + } + .padding($r("app.float.distance_8")) + .backgroundColor($r("app.color.white_bg_color")) + .borderRadius($r("app.float.radius_40")) + .divider({strokeWidth: 1, color: $r("app.color.color_E3E3E3_grey"), startMargin:$r("app.float.distance_16"), endMargin:$r("app.float.distance_16")}); + } +} + +/** + * Array Of AllLanguages For Lazy Loading + */ +class AllLanguages extends BasicDataSource { + private languagesArray: string[] = []; + + constructor(languagesArray:string[]){ + super(); + this.languagesArray = languagesArray; + } + + public totalCount(): number { + return this.languagesArray.length; + } + + public getData(index: number): any { + return this.languagesArray[index]; + } +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/pages/system/languageSettings/languageAndRegion/editLanguage.ets b/product/phone/src/main/ets/default/pages/system/languageSettings/languageAndRegion/editLanguage.ets new file mode 100644 index 00000000..c60d195c --- /dev/null +++ b/product/phone/src/main/ets/default/pages/system/languageSettings/languageAndRegion/editLanguage.ets @@ -0,0 +1,119 @@ +/** + * 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/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import HeadComponent from '../../../../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import ConfigData from '../../../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import LanguageAndRegionModel from '../../../../../default/model/systemImpl/languageSettings/LanguageAndRegionModel.ets' + +/** + * Home Page Of EditLanguage + */ +@Entry +@Component +struct EditLanguage { + private TAG = `${ConfigData.TAG} EditLanguage`; + + build() { + Column() { + HeadComponent({ headName: $r('app.string.editLanguage'), isActive: true }); + EditList(); + } + .height(ConfigData.WH_100_100) + .width(ConfigData.WH_100_100) + .backgroundColor($r("app.color.color_E3E3E3_grey")); + } + + aboutToAppear(){ + LogUtil.info(`${this.TAG} aboutToAppear in`); + LogUtil.info(`${this.TAG} aboutToAppear out`); + } + + aboutToDisappear(){ + LogUtil.info(`${this.TAG} aboutToDisappear in`); + LogUtil.info(`${this.TAG} aboutToDisappear out`); + } + +} + +/** + * Edit List Of Added Language + */ +@Component +struct EditList { + @StorageLink('addedLanguages') addedLanguages:Array = LanguageAndRegionModel.getAddedLanguages(); + @State touchedItem:string = '' + + build(){ + List({space:0}){ + ForEach(this.addedLanguages, (item) => { + ListItem(){ + Flex({justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center}){ + Column(){ + Text(LanguageAndRegionModel.getSysDisplayLanguage(item)) + .fontSize($r("app.float.font_28")) + .height($r("app.float.wh_value_32")) + .margin({right:$r("app.float.distance_16"),top:$r("app.float.distance_20"),bottom:$r("app.float.distance_8")}) + .fontColor($r("app.color.font_color_182431")) + .textAlign(TextAlign.Start); + Text(LanguageAndRegionModel.getDisplayLanguage(item)) + .fontSize($r("app.float.font_22")) + .height($r("app.float.wh_value_26")) + .margin({right:$r("app.float.distance_16"),bottom:$r("app.float.distance_20")}) + .fontColor($r("app.color.font_color_182431")) + .textAlign(TextAlign.Start); + } + .alignItems(HorizontalAlign.Start); + + Text($r("app.string.delete")) + .fontSize($r("app.float.font_28")) + .onClick(() => { + if(this.addedLanguages.length <= 1){ + AlertDialog.show({ + message: $r("app.string.saveLanguage"), + confirm: { + value: $r("app.string.confirm"), + action: () => { + console.log('button clicked'); + } + } + }) + }else{ + LanguageAndRegionModel.deleteLanguage(item); + } + }); + } + } + .align(Alignment.Start) + .width(ConfigData.WH_100_100) + .padding({ left: $r("app.float.distance_16"), right: $r("app.float.distance_16") }) + .borderRadius($r("app.float.radius_24")) + .backgroundColor(item === this.touchedItem ? $r("app.color.color_D8D8D8_grey"):$r("app.color.white_bg_color")) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.touchedItem = item; + } + if (event.type === TouchType.Up) { + this.touchedItem = ''; + } + }) + }, item => item); + } + .margin({left:$r("app.float.distance_24"), right:$r("app.float.distance_24"), top:$r("app.float.distance_16")}) + .padding($r("app.float.distance_8")) + .backgroundColor($r("app.color.white_bg_color")) + .borderRadius($r("app.float.radius_40")) + .divider({strokeWidth:1, color: $r("app.color.color_E3E3E3_grey"), startMargin:$r("app.float.distance_16"), endMargin:$r("app.float.distance_16")}) + } +} diff --git a/product/phone/src/main/ets/default/pages/system/languageSettings/languageAndRegion/homePage.ets b/product/phone/src/main/ets/default/pages/system/languageSettings/languageAndRegion/homePage.ets new file mode 100644 index 00000000..105e37ee --- /dev/null +++ b/product/phone/src/main/ets/default/pages/system/languageSettings/languageAndRegion/homePage.ets @@ -0,0 +1,225 @@ +/** + * 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/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import HeadComponent from '../../../../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import ConfigData from '../../../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import LanguageAndRegionModel from '../../../../../default/model/systemImpl/languageSettings/LanguageAndRegionModel.ets' + +/** + * Home Page Of LanguageAndRegion Settings + */ +@Entry +@Component +struct LanguageAndRegion { + private TAG = `${ConfigData.TAG} LanguageAndRegion`; + + build() { + Column() { + HeadComponent({ headName: $r('app.string.languageAndRegion'), isActive: true }); + List({space:10, initialIndex:0}){ + ListItem(){ + Flex({justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center}){ + Text($r("app.string.languageTab")) + .fontSize($r("app.float.font_22")) + .fontColor($r("app.color.font_color_182431")) + .textAlign(TextAlign.Start) + .height(ConfigData.WH_100_100); + Navigator({target: 'pages/system/languageSettings/languageAndRegion/editLanguage'}){ + Text($r("app.string.edit")) + .fontSize($r("app.float.font_22")) + .fontColor($r("app.color.font_color_007DFF")) + .textAlign(TextAlign.End) + .height(ConfigData.WH_100_100); + } + } + .margin({left:$r("app.float.distance_24"),right:$r("app.float.distance_24"), bottom:$r("app.float.distance_8")}) + .height($r("app.float.wh_value_56")); + } + + ListItem(){ + AddedList(); + } + + ListItem(){ + AddText(); + } + + ListItem(){ + Text($r("app.string.region")) + .fontSize($r("app.float.font_22")) + .fontColor($r("app.color.font_color_182431")) + .textAlign(TextAlign.Start) + .padding({left:$r("app.float.distance_24"), right:$r("app.float.distance_24"), top:$r("app.float.distance_8"), bottom:$r("app.float.distance_8")}) + .height($r("app.float.wh_value_56")); + } + + ListItem(){ + Region(); + } + } + .margin({left:$r("app.float.distance_24"), right:$r("app.float.distance_24"), top:$r("app.float.distance_16")}); + } + .height(ConfigData.WH_100_100) + .width(ConfigData.WH_100_100) + .backgroundColor($r("app.color.color_E3E3E3_grey")); + } + + aboutToAppear(){ + LogUtil.info(`${this.TAG} aboutToAppear in`); + LogUtil.info(`${this.TAG} aboutToAppear out`); + } + + aboutToDisappear(){ + LogUtil.info(`${this.TAG} aboutToDisappear in`); + LogUtil.info(`${this.TAG} aboutToDisappear out`); + } + +} + + +/** + * List Of Added Languages + */ +@Component +struct AddedList { + @StorageLink('addedLanguages') addedLanguages:Array = LanguageAndRegionModel.getAddedLanguages(); + @State touchedItem:string = ''; + + build(){ + List({space:0}){ + ForEach(this.addedLanguages, (item) => { + ListItem(){ + Column(){ + Text(LanguageAndRegionModel.getSysDisplayLanguage(item)) + .fontSize($r("app.float.font_28")) + .height(LanguageAndRegionModel.isSystemLanguage(item) ? $r("app.float.wh_value_56") : $r("app.float.wh_value_44")) + .padding({left:$r("app.float.distance_16"),right:$r("app.float.distance_16")}) + .fontColor($r("app.color.font_color_182431")) + .textAlign(TextAlign.Start); + Text(LanguageAndRegionModel.getDisplayLanguage(item)) + .fontSize($r("app.float.font_22")) + .height($r("app.float.wh_value_32")) + .padding({left:$r("app.float.distance_16"),right:$r("app.float.distance_16"),bottom:$r("app.float.distance_8")}) + .fontColor($r("app.color.font_color_182431")) + .textAlign(TextAlign.Start) + .visibility(LanguageAndRegionModel.isSystemLanguage(item) ? Visibility.None : Visibility.Visible); + } + .alignItems(HorizontalAlign.Start) + } + .align(Alignment.Start) + .borderRadius($r("app.float.radius_24")) + .backgroundColor(item === this.touchedItem ? $r("app.color.color_D8D8D8_grey"):$r("app.color.white_bg_color")) + .width(ConfigData.WH_100_100) + .onClick(()=>{ + LanguageAndRegionModel.setSystemLanguage(item); + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.touchedItem = item; + } + if (event.type === TouchType.Up) { + this.touchedItem = ''; + } + }) + }, item => item); + } + .borderRadius($r("app.float.radius_40")) + .padding({left:$r("app.float.distance_8"),right:$r("app.float.distance_8"),top:$r("app.float.distance_24"),bottom:$r("app.float.distance_24")}) + .divider({strokeWidth: 1, color: $r("app.color.color_E3E3E3_grey"), startMargin:$r("app.float.distance_16"), endMargin:$r("app.float.distance_16")}) + .backgroundColor($r("app.color.white_bg_color")); + } +} + + +/** + * Text Component + */ +@Component +struct AddText { + @State touched:boolean = false; + + build(){ + Navigator({ target: 'pages/system/languageSettings/languageAndRegion/addLanguage' }) { + Row(){ + Text($r("app.string.addLanguage")) + .fontSize($r("app.float.font_28")) + .fontColor($r("app.color.font_color_007DFF")) + .padding({left:$r("app.float.distance_16"),right:$r("app.float.distance_16")}) + .height($r("app.float.wh_value_70")) + .width(ConfigData.WH_100_100) + .textAlign(TextAlign.Start) + .backgroundColor(this.touched ? $r("app.color.color_D8D8D8_grey"):$r("app.color.white_bg_color")) + .borderRadius($r("app.float.radius_24")) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.touched = true; + } + if (event.type === TouchType.Up) { + this.touched = false; + } + }); + } + .borderRadius($r("app.float.radius_24")) + .padding({ left: $r("app.float.distance_8"), right: $r("app.float.distance_8"), top: $r("app.float.distance_8"), bottom: $r("app.float.distance_8") }) + .backgroundColor($r("app.color.white_bg_color")); + } + } +} + + +/** + * Region Component + */ +@Component +struct Region { + @StorageLink('currentRegion') currentRegion:string = LanguageAndRegionModel.getSysDisplayRegion(); + @State touched:boolean = false; + + build(){ + Navigator({ target: 'pages/system/languageSettings/languageAndRegion/selectRegion' }) { + Row(){ + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text($r("app.string.currentRegion")) + .fontSize($r("app.float.font_28")) + .fontColor($r("app.color.font_color_182431")) + .textAlign(TextAlign.Start); + Row() { + Text(this.currentRegion) + .fontSize($r("app.float.font_28")) + .fontColor($r("app.color.font_color_007DFF")); + Image('/res/image/ic_settings_arrow.svg') + .width($r('app.float.wh_value_40')) + .height($r('app.float.wh_value_40')); + } + } + .height($r("app.float.wh_value_70")) + .backgroundColor(this.touched ? $r("app.color.color_D8D8D8_grey"):$r("app.color.white_bg_color")) + .borderRadius($r("app.float.radius_24")) + .padding({left:$r("app.float.distance_16"),right:$r("app.float.distance_16")}) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.touched = true; + } + if (event.type === TouchType.Up) { + this.touched = false; + } + }); + } + .borderRadius($r("app.float.radius_24")) + .padding({ left: $r("app.float.distance_8"), right: $r("app.float.distance_8"), top: $r("app.float.distance_8"), bottom: $r("app.float.distance_8") }) + .backgroundColor($r("app.color.white_bg_color")); + } + } +} diff --git a/product/phone/src/main/ets/default/pages/system/languageSettings/languageAndRegion/selectRegion.ets b/product/phone/src/main/ets/default/pages/system/languageSettings/languageAndRegion/selectRegion.ets new file mode 100644 index 00000000..665d7598 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/system/languageSettings/languageAndRegion/selectRegion.ets @@ -0,0 +1,101 @@ +/** + * 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 LogUtil from '../../../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import ConfigData from '../../../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import HeadComponent from '../../../../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import BasicDataSource from '../../../../../../../../../../common/utils/src/main/ets/default/model/BasicDataSource.ets'; +import LanguageAndRegionModel from '../../../../../default/model/systemImpl/languageSettings/LanguageAndRegionModel.ets' + + +/** + * Home Page of Select Region + */ +@Entry +@Component +struct SelectRegion { + @State touchedItemName:string = ''; + private regionList: RegionDataSource = new RegionDataSource(LanguageAndRegionModel.getSystemCountries()); + private TAG = `${ConfigData.TAG} SelectRegion`; + + build(){ + Column(){ + HeadComponent({ headName: $r('app.string.selectRegion'), isActive: true }) + List(){ + LazyForEach(this.regionList, (item) => { + ListItem(){ + Text(LanguageAndRegionModel.getDisplayRegion(item)) + .fontSize($r("app.float.font_28")) + .height($r("app.float.wh_value_56")) + .width(ConfigData.WH_100_100) + .fontColor(LanguageAndRegionModel.isSystemRegion(item) ? $r("app.color.font_color_007DFF") : $r("app.color.font_color_182431")) + .textAlign(TextAlign.Start); + } + .padding({left:$r("app.float.distance_16"),right:$r("app.float.distance_16")}) + .borderRadius($r("app.float.radius_24")) + .backgroundColor(item === this.touchedItemName ? $r("app.color.color_D8D8D8_grey"):$r("app.color.white_bg_color")) + .width(ConfigData.WH_100_100) + .onClick(() => { + LanguageAndRegionModel.setSystemRegion(item); + router.back(); + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.touchedItemName = item; + } + if (event.type === TouchType.Up) { + this.touchedItemName = ''; + } + }) + }, item => item); + } + .divider({strokeWidth: 1, color: $r("app.color.color_E3E3E3_grey"), startMargin:$r("app.float.distance_16"), endMargin:$r("app.float.distance_16")}); + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100) + .backgroundColor($r("app.color.color_E3E3E3_grey")); + } + + aboutToAppear(){ + LogUtil.info(`${this.TAG} aboutToAppear in`); + LogUtil.info(`${this.TAG} aboutToAppear out`); + } + + aboutToDisappear(){ + LogUtil.info(`${this.TAG} aboutToDisappear in`); + LogUtil.info(`${this.TAG} aboutToDisappear out`); + } +} + + +/** + * RegionDataSource For Lazy Loading + */ +class RegionDataSource extends BasicDataSource { + private regionArray: string[] = []; + + constructor(regionArray:string[]){ + super(); + this.regionArray = regionArray; + } + + public totalCount(): number { + return this.regionArray.length; + } + + public getData(index: number): any { + return this.regionArray[index]; + } +} diff --git a/product/phone/src/main/ets/default/pages/usersAccounts.ets b/product/phone/src/main/ets/default/pages/usersAccounts.ets new file mode 100644 index 00000000..1a8463f7 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/usersAccounts.ets @@ -0,0 +1,86 @@ +// @ts-nocheck +/** + * 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 '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import SystemAccount from '../model/usersAndAccounts/systemAccountModel.ets' +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import router from '@system.router'; + +@Entry +@Component +struct UsersAccounts { + @State accountName: string = ""; + + build() { + Column() { + // head + HeadComponent({ headName: $r("app.string.usersAccountsTab"), isActive: true }); + // current user + UserComponent({ accountName: this.accountName }); + } + } + + onPageShow() { + LogUtil.info("User account page on show."); + SystemAccount.updateAccountName(name => { + this.accountName = name; + }); + } +} + +@Component +struct UserComponent { + @Prop accountName: string; + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start }) { + Text($r('app.string.user')) + .margin({ left: $r('app.float.wh_value_20'), bottom: $r('app.float.wh_value_12') }) + .fontSize($r('app.float.font_24')) + .fontColor(Color.Black) + + Flex({ justifyContent: FlexAlign.SpaceBetween }) { + Text($r("app.string.currentLogin")) + .fontSize($r("app.float.font_24")) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Start) + .align(ItemAlign.Start) + .width(ConfigData.WH_40_100) + Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.End }) { + Text(this.accountName) + .fontSize($r("app.float.font_24")) + .fontColor(Color.Black) + .align(Alignment.Start) + .margin({ right: $r("app.float.wh_value_5") }) + Image($r("app.media.ic_settings_arrow")) + .width($r("app.float.wh_value_20")) + .height($r("app.float.wh_value_20")) + } + } + .margin({ left: $r("app.float.wh_value_20"), right: $r("app.float.wh_value_20") }) + .height($r("app.float.wh_value_70")) + .onClick(() => { + router.push({ uri: "pages/multipleUsers" }) + }) + } + .width(ConfigData.WH_100_100) + } + + aboutToAppear() { + LogUtil.info("User account about to appear.") + } +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/pages/volumeControl.ets b/product/phone/src/main/ets/default/pages/volumeControl.ets new file mode 100644 index 00000000..c7c77926 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/volumeControl.ets @@ -0,0 +1,300 @@ +/** + * 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 {VolumeModel, RingerModel} from '../model/volumeControlImpl/VolumeControlModel.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import SliderComponent from '../../../../../../../common/component/src/main/ets/default/sliderComponent.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import SubscriberUtils from '../../../../../../../common/utils/src/main/ets/default/baseUtil/SubscriberUtil.ets'; +import Log from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogDecorator.ets'; +import Audio from '@ohos.multimedia.audio'; + +const SUBSCRIBE_INFO_EVENT_VOLUME_TYPE = "AUDIO_VOLUME_TYPE_SYSTEM_UI" +const SUBSCRIBE_INFO_EVENT_RING_MODE = "AUDIO_RING_MODE_SYSTEM_UI" +const mCommonEventSubscribeInfo = { + events: [SUBSCRIBE_INFO_EVENT_VOLUME_TYPE, SUBSCRIBE_INFO_EVENT_RING_MODE] +}; +const VOLUME_MIN_VALUE = 0; +const VOLUME_MAX_VALUE = 15; + +/** + * Volume control + */ +@Entry +@Component +export struct VolumeControl { + + build() { + Column() { + // head + HeadComponent({ headName: $r('app.string.volumeAndVibrationControl'), isActive: true }); + // sound mode + AudioRingerModeComponent(); + // volume control + VolumeControlComponent(); + } + } +} + +/** + * AudioRingerMode component + */ +@Component +struct AudioRingerModeComponent { + @StorageLink('AudioRingerMode') audioRingerMode: number = Audio.AudioRingMode.RINGER_MODE_NORMAL; + private ringerModel = new RingerModel(); + private TAG = ConfigData.TAG + 'AudioRingerModeComponent '; + + @Log + private aboutToAppear() { + LogUtil.info(this.TAG + 'aboutToAppear in'); + SubscriberUtils.registerStatusListener(mCommonEventSubscribeInfo, this.commonEventCallback.bind(this)); + this.updateRingerMode(); + LogUtil.info(this.TAG + 'aboutToAppear out'); + } + + @Log + private aboutToDisappear(): void { + LogUtil.info(this.TAG + 'aboutToDisappear in'); + AppStorage.SetOrCreate('AudioRingerMode', ''); + SubscriberUtils.unSubscriberListener(); + LogUtil.info(this.TAG + 'aboutToDisappear out'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start }) { + Text($r('app.string.soundMode')) + .margin({ + left: $r('app.float.audio_subtitle_margin_left'), + bottom: $r('app.float.audio_subtitle_margin_bottom') + }) + .fontSize($r('app.float.audio_subtitle_font')) + .fontColor($r('app.color.color_333333_grey')); + + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + RowSplit() { + AudioRingerModeItem({ + image: $r('app.media.ic_settings_audio_sound_mode_sound'), + desc: $r('app.string.soundModeSound'), + value: Audio.AudioRingMode.RINGER_MODE_NORMAL, + checkedValue: $audioRingerMode, + onItemClick: (ringerMode) => { this.onItemClick(ringerMode) } + }) + AudioRingerModeItem({ + image: $r('app.media.ic_settings_audio_sound_mode_vibration'), + desc: $r('app.string.soundModeVibration'), + value: Audio.AudioRingMode.RINGER_MODE_VIBRATE, + checkedValue: $audioRingerMode, + onItemClick: (ringerMode) => { this.onItemClick(ringerMode) } + }) + AudioRingerModeItem({ + image: $r('app.media.ic_settings_audio_sound_mode_silent'), + desc: $r('app.string.soundModeSilent'), + value: Audio.AudioRingMode.RINGER_MODE_SILENT, + checkedValue: $audioRingerMode, + onItemClick: (ringerMode) => { this.onItemClick(ringerMode) } + }) + } + .resizeable(false) + .align(Alignment.BottomEnd) + .alignSelf(ItemAlign.End); + } + .margin({top: $r('app.float.audio_subtitle_margin_top') }) + .padding({ + top: $r('app.float.audio_sound_mode_inner_padding_top'), + bottom: $r('app.float.audio_sound_mode_inner_padding_bottom') + }) + .border({ + width: $r('app.float.audio_sound_mode_border_width'), + color: $r('app.color.color_999999_grey'), + radius: $r('app.float.audio_sound_mode_border_radius') + }); + } + .padding($r('app.float.audio_sound_mode_outer_padding')) + .height($r('app.float.audio_sound_mode_outer_height')) + .margin({ bottom: $r('app.float.item_common_vertical_margin') }); + } + +/** + * AudioRingerMode Change + */ + @Log + onItemClick(audioRingerMode: number) { + LogUtil.info(this.TAG + `onItemClick: ${audioRingerMode} `); + this.ringerModeCheckedCallback(audioRingerMode); + } + +/** + * common event callback + */ + @Log + commonEventCallback(err, data) { + LogUtil.info(this.TAG + `SubscriberUtils statusSubscriberCallBack data.data volume : ` + JSON.stringify(data)); + this.updateRingerMode(); + } + +/** + * update RingerMode + */ + @Log + updateRingerMode() { + this.ringerModel.getRingerMode((audioRingMode/* AudioRingMode */) => { + this.audioRingerMode = audioRingMode; + AppStorage.SetOrCreate('AudioRingerMode', audioRingMode); + LogUtil.info(this.TAG + 'updateRingerMode : AppStorage audioRingMode:' + audioRingMode); + }); + } + +/** + * ringer mode checked callback + */ + @Log + ringerModeCheckedCallback(audioRingerMode/* AudioRingerMode */) { + LogUtil.info(this.TAG + `AudioRingerModeChangeCallback init: ${audioRingerMode} `); + this.ringerModel.setRingerMode(audioRingerMode, (value) => { + this.audioRingerMode = value; + AppStorage.SetOrCreate('AudioRingerMode', value); + + // send event + let info = { 'value': 0 }; + info.value = value; + SubscriberUtils.sendEvent(JSON.stringify(info), ConfigData.SENT_EVENT_AUDIO_RINGER_MODE); + }); + } +} + +/** + * AudioRingerMode item + */ +@Component +struct AudioRingerModeItem { + private image: PixelMap; + private desc: string; + private value: number; + @Link checkedValue: number; + private onItemClick?: (ringerMode) => void; + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Image(this.image) + .width($r('app.float.audio_sound_mode_image_size')) + .height($r('app.float.audio_sound_mode_image_size')) + .objectFit(ImageFit.Contain); + + Text(this.desc) + .margin({ top: $r('app.float.audio_sound_mode_text_margin_top') }) + .fontSize($r('app.float.audio_sound_mode_font_size')) + .fontColor($r('app.color.color_333333_grey')) + .textAlign(TextAlign.Center) + .align(Alignment.Center); + + Radio({ value: this.value.toString() }) + .width($r('app.float.audio_sound_mode_radio_size')) + .height($r('app.float.audio_sound_mode_radio_size')) + .checked(this.checkedValue === this.value) + .enabled(false); + } + .width(ConfigData.WH_33_100) + .height(ConfigData.WH_100_100) + .padding({ top: $r('app.float.audio_sound_mode_item_inner_padding_top') }) + .onClick(() => { + LogUtil.info(ConfigData.TAG + 'AudioRingerModeItem : item is clicked : ' + this.value) + this.onItemClick(this.value); + }); + } +} + + +/** + * Volume control component + */ +@Component +struct VolumeControlComponent { + @State ringtoneModel:VolumeModel = new VolumeModel(ConfigData.SETTINGSDATA_VOLUME_RINGTONE); + @State mediaModel:VolumeModel = new VolumeModel(ConfigData.SETTINGSDATA_VOLUME_MEDIA); + @State voiceCallModel:VolumeModel = new VolumeModel(ConfigData.SETTINGSDATA_VOLUME_CALL); + private TAG = ConfigData.TAG + 'VolumeControlComponent '; + + @Log + private aboutToAppear(): void{ + LogUtil.info(this.TAG + 'aboutToAppear in'); + this.ringtoneModel.registerObserver(); + this.mediaModel.registerObserver(); + this.voiceCallModel.registerObserver(); + LogUtil.info(this.TAG + 'aboutToAppear out'); + } + + @Log + private aboutToDisappear(): void{ + LogUtil.info(this.TAG + 'aboutToDisappear in'); + this.ringtoneModel.unregisterObserver(); + this.mediaModel.unregisterObserver(); + this.voiceCallModel.unregisterObserver(); + LogUtil.info(this.TAG + 'aboutToDisappear out'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start }) { + Text($r('app.string.volumeControl')) + .margin({ + left: $r('app.float.audio_subtitle_margin_left'), + bottom: $r('app.float.audio_subtitle_margin_bottom') + }) + .fontSize($r('app.float.audio_subtitle_font')) + .fontColor($r('app.color.color_333333_grey')); + + Column() { + SliderComponent({ + summary: $r('app.string.volumeControlRing'), + min: VOLUME_MIN_VALUE, + max: VOLUME_MAX_VALUE, + value: this.ringtoneModel.getValue(), + visible: false, + onChange: (value: number, mode: SliderChangeMode) => { + this.ringtoneModel.setValue(value, mode); + } + }); + SliderComponent({ + summary: $r('app.string.volumeControlMedia'), + min: VOLUME_MIN_VALUE, + max: VOLUME_MAX_VALUE, + value: this.mediaModel.getValue(), + visible: false, + onChange: (value: number, mode: SliderChangeMode) => { + this.mediaModel.setValue(value, mode); + } + }); + SliderComponent({ + summary: $r('app.string.volumeControlCall'), + min: VOLUME_MIN_VALUE, + max: VOLUME_MAX_VALUE, + value: this.voiceCallModel.getValue(), + visible: false, + onChange: (value: number, mode: SliderChangeMode) => { + this.voiceCallModel.setValue(value, mode); + } + }); + } + .margin({top: $r('app.float.audio_subtitle_margin_top')}) + .border({ + width: $r('app.float.audio_border_width'), + color: Color.Gray, + radius: $r('app.float.audio_border_radius') + }) + .padding($r('app.float.item_common_vertical_margin')) + } + .padding($r('app.float.audio_volume_component_padding')) + } +} \ No newline at end of file diff --git a/product/phone/src/main/ets/default/pages/wifi.ets b/product/phone/src/main/ets/default/pages/wifi.ets new file mode 100644 index 00000000..a978c887 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/wifi.ets @@ -0,0 +1,271 @@ +/** + * 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/utils/src/main/ets/default/baseUtil/SubscriberUtil.ets'; +import PreferenceUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/PreferenceUtil.ets'; +import WifiModel from '../model/wifiImpl/WifiModel.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import EntryComponent from '../../../../../../../common/component/src/main/ets/default/entryComponent.ets'; +import ImageAnimatorComponent from '../../../../../../../common/component/src/main/ets/default/imageAnimatorComponent.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import Subscriber from '@ohos.commonevent'; +import router from '@system.router'; + +const MODULE_TAG = ConfigData.TAG + '.Wifi -> '; + +@Entry +@Component +struct Index { + @StorageLink('slWiFiLists') scanWiFiResults: [] = []; + + private isWlanEnable: boolean = true; + @State isWlanListShown: boolean = true; + @State refreshFlag: boolean = true; + private intervalStatus : number = -1; + + private wifiEventsSubscriber = null; + private wifiEvents = { + events: ["usual.event.wifi.CONN_STATE", "usual.event.wifi.SCAN_FINISHED"], + }; + + build() { + Column() { + HeadComponent({ headName: $r('app.string.wifiTab'), isActive: true }); + Flex({ justifyContent: FlexAlign.SpaceBetween }) { + Row() { + Text($r('app.string.wifiTab')) + .fontSize($r('app.float.font_24')) + .fontColor(Color.Black) + .textAlign(TextAlign.Start); + }.alignItems(VerticalAlign.Center); + Toggle({ type: ToggleType.Switch, isOn: this.isWlanEnable }) + .width($r('app.float.wh_value_50')) + .height($r('app.float.wh_value_40')) + .onChange((isOn: boolean) => { + this.isWlanEnable = !this.isWlanEnable; + LogUtil.info(MODULE_TAG + 'Toggle onChange for Wlan Enable:' + this.isWlanEnable); + if (this.isWlanEnable) { + this.switchOn(); + } else { + this.switchOff(); + } + }); + } + .height($r('app.float.wh_value_70')) + .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }); + + Flex({ alignItems: ItemAlign.Start }) { + Text($r('app.string.tipsContent')) + .fontSize($r('app.float.font_20')); + } + .visibility(this.isWlanEnable ? Visibility.None : Visibility.Visible) + .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }); + + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween }) { + Text($r('app.string.wifiList')) + .fontSize($r('app.float.font_24')) + .align(Alignment.Start); + Row() { + ImageAnimatorComponent({ imageWidth: $r('app.float.wh_value_40'), + imageHeight: $r('app.float.wh_value_40') }) + } + .width($r('app.float.wh_value_40')) + .visibility(this.isWlanListShown ? Visibility.Visible : Visibility.None); + } + .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }); + + List() { + ForEach(this.scanWiFiResults, (item) => { + ListItem() { + EntryComponent({ + settingIcon: item.settingIcon, + settingTitle: item.settingTitle, + settingSummary: item.settingSummary, + settingValue: item.settingValue, + settingArrow: item.settingArrow, + settingArrowStyle: item.settingArrowStyle, + settingUri: item.settingUri + }); + } + .onClick(() => { + this.jumpToApDetails(item.apInfo); + }) + .height($r('app.float.wh_value_60')) + }, item => JSON.stringify(item)); + } + .divider({ + strokeWidth: $r('app.float.wh_value_1'), + color: $r('app.color.color_E3E3E3_grey'), + startMargin: $r('app.float.wh_value_15'), + endMargin: $r('app.float.wh_value_15') + }) + .margin({top:$r('app.float.wh_value_20')}); + } + .margin({bottom:$r('app.float.wh_value_20')}) + .layoutWeight(1) + .visibility(this.isWlanEnable ? Visibility.Visible : Visibility.None); + } + .height(ConfigData.WH_100_100) + } + + jumpToApDetails(apInfo: any) { + LogUtil.info(MODULE_TAG + 'start to connect WiFi'); + WifiModel.setUserSelectedAp(apInfo); + LogUtil.info(MODULE_TAG + 'start to jump to wifiPsd page : ' + JSON.stringify(apInfo)); + router.push({ + uri: 'pages/wifiPsd', + params: apInfo, + }); + } + + private switchOn() { + LogUtil.info(MODULE_TAG + 'WLAN switch on'); + this.setIntervalTask(); + if (WifiModel.isWiFiActive() === true) { + LogUtil.info(MODULE_TAG + 'WLAN already is on'); + this.isWlanListShown = true; + return; + } + let ret = WifiModel.enableWiFi(); + LogUtil.info(MODULE_TAG + 'enable wifi ret is : ' + ret); + if (ret === true) { + this.isWlanListShown = true; + } + } + + private switchOff() { + LogUtil.info(MODULE_TAG + 'WLAN switch off'); + this.clearIntervalTask(); + if (WifiModel.isWiFiActive() === false) { + LogUtil.info(MODULE_TAG + 'WLAN already is off'); + this.isWlanListShown = false; + return; + } + // disconnect the connection before wifi disable + WifiModel.disconnectWiFi(); + let ret = WifiModel.disableWifi(); + LogUtil.info(MODULE_TAG + 'disable wifi ret is : ' + ret); + if (ret === false) { + this.isWlanListShown = false; + } + } + + wifiConnectStatusCallback(err, data) { + LogUtil.info(MODULE_TAG + 'subscriber callback called ' + JSON.stringify(data)); + // connecting + if (data.code === WifiModel.wiFiStatusEnum.Connecting) { + LogUtil.info(MODULE_TAG + 'code 1 : connecting'); + } + // connected + if (data.code === WifiModel.wiFiStatusEnum.ApConnected) { + LogUtil.info(MODULE_TAG + 'code 4 : connected'); + WifiModel.updatePrimaryApInfo($r('app.string.connected')); + WifiModel.refreshApScanResults(); + } + // disconnected + if (data.code === WifiModel.wiFiStatusEnum.Disconnecting || + data.code === WifiModel.wiFiStatusEnum.Disconnected) { + LogUtil.info(MODULE_TAG + 'code 5, 6 : disconnected'); + WifiModel.removePrimaryApInfo(); + WifiModel.refreshApScanResults(); + } + // refresh the page contents + this.refreshFlag = !this.refreshFlag; + } + + wifiEventsCallbackCreator(err, data) { + LogUtil.info(MODULE_TAG + 'create create Subscriber CallBack'); + this.wifiEventsSubscriber = data; + Subscriber.subscribe(this.wifiEventsSubscriber, this.wifiConnectStatusCallback.bind(this)); + } + + /** + * WiFi status monitoring + */ + createWiFiStatusListener() { + LogUtil.info(MODULE_TAG + 'create wifi status listener'); + Subscriber.createSubscriber(this.wifiEvents, this.wifiEventsCallbackCreator.bind(this)); + } + + /** + * Cancel WiFi status listening + */ + destroyWiFiStatusListener() { + Subscriber.unsubscribe(this.wifiEventsSubscriber, () => { + LogUtil.info(MODULE_TAG + 'unsubscribe wifi listener'); + }); + } + + aboutToAppear(): void { + LogUtil.info(MODULE_TAG + 'about to appear wifi page'); + this.createWiFiStatusListener(); + if (WifiModel.isWiFiActive()) { + this.isWlanEnable = true; + this.isWlanListShown = true; + } else { + this.isWlanEnable = false; + this.isWlanListShown = false; + } + } + + aboutToDisappear(): void { + LogUtil.info(MODULE_TAG + 'about to disappear wifi page'); + this.destroyWiFiStatusListener(); + } + + onPageShow() { + LogUtil.info(MODULE_TAG + 'on page show wifi'); + this.setIntervalTask(); + WifiModel.setIntervalScanTask(); + + let params = router.getParams(); + if (params !== null && typeof params !== 'undefined') { + LogUtil.info(MODULE_TAG + 'settings wifiPsd page params is : ' + JSON.stringify(params)); + let opType = params.opType; + if (opType === 'disconnect') { + WifiModel.disconnectWiFi(); + } + if (opType === 'connect') { + let ret = WifiModel.connectWiFi(params.password); + LogUtil.info(MODULE_TAG + 'ret of confirm connect to is : ' + ret); + } + } + } + + onPageHide(): void { + LogUtil.info(MODULE_TAG + 'on page hide wifi'); + this.clearIntervalTask(); + WifiModel.clearIntervalScanTask(); + } + + onBackPress() { + Navigator().active(true); + } + + clearIntervalTask() { + if (this.intervalStatus !== -1) { + LogUtil.info(MODULE_TAG + 'clear interval status'); + clearInterval(this.intervalStatus); + } + } + + setIntervalTask() { + this.clearIntervalTask(); + this.intervalStatus = setInterval(() => { + this.refreshFlag = !this.refreshFlag; + }, 3000); + } +} diff --git a/product/phone/src/main/ets/default/pages/wifiPsd.ets b/product/phone/src/main/ets/default/pages/wifiPsd.ets new file mode 100644 index 00000000..6bff7385 --- /dev/null +++ b/product/phone/src/main/ets/default/pages/wifiPsd.ets @@ -0,0 +1,205 @@ +/** + * 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/utils/src/main/ets/default/baseUtil/LogUtil.ets'; +import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent.ets'; +import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData.ets'; +import router from '@system.router' + +const MODULE_TAG = ConfigData.TAG + '.WifiPasswd -> '; + +/** + * wifi password setting page + */ +@Entry +@Component +struct WifiPsd { + @State text: string= ''; + apInfo: any = null; + + build() { + Column() { + HeadComponent({ + icBackIsVisibility: true, + headName: this.apInfo.ssid, + isActive: true + }); + + Column() { + Row() { + Text($r('app.string.wifiMAC')) + .fontSize($r('app.float.font_28')) + .fontColor(Color.Black) + .textAlign(TextAlign.Start); + Text(':') + .margin({ + left: $r('app.float.wh_value_15'), + right: $r('app.float.wh_value_15') + }); + Text(this.apInfo.bssid) + .fontSize($r('app.float.font_28')) + .fontColor(Color.Black) + .textAlign(TextAlign.Start); + } + .margin({ + left: $r('app.float.wh_value_15'), + top: $r('app.float.wh_value_20'), + right: $r('app.float.wh_value_15')}); + + Row() { + Text($r('app.string.signalLevel')) + .fontSize($r('app.float.font_28')) + .fontColor(Color.Black) + .textAlign(TextAlign.Start); + Text(':') + .margin({ + left: $r('app.float.wh_value_15'), + right: $r('app.float.wh_value_15') + }); + Text(this.apInfo.rssi.toString()) + .fontSize($r('app.float.font_28')) + .fontColor(Color.Black) + .textAlign(TextAlign.Start); + } + .margin({ + left: $r('app.float.wh_value_15'), + top: $r('app.float.wh_value_20'), + right: $r('app.float.wh_value_15')}); + + Row() { + Text($r('app.string.signalBand')) + .fontSize($r('app.float.font_28')) + .fontColor(Color.Black) + .textAlign(TextAlign.Start); + Text(':') + .margin({ + left: $r('app.float.wh_value_15'), + right: $r('app.float.wh_value_15') + }); + Text(this.apInfo.band.toString()) + .fontSize($r('app.float.font_28')) + .fontColor(Color.Black) + .textAlign(TextAlign.Start); + } + .margin({ + left: $r('app.float.wh_value_15'), + top: $r('app.float.wh_value_20'), + right: $r('app.float.wh_value_15')}) + + Row() { + Text($r('app.string.encryptMethod')) + .fontSize($r('app.float.font_28')) + .fontColor(Color.Black) + .textAlign(TextAlign.Start); + Text(':') + .margin({ + left: $r('app.float.wh_value_15'), + right: $r('app.float.wh_value_15') + }); + Text(this.apInfo.securityType.toString()) + .fontSize($r('app.float.font_28')) + .fontColor(Color.Black) + .textAlign(TextAlign.Start); + } + .margin({ + left: $r('app.float.wh_value_15'), + top: $r('app.float.wh_value_20'), + right: $r('app.float.wh_value_15')}) + } + .alignItems(HorizontalAlign.Start) + .backgroundColor(Color.White) + .width(ConfigData.WH_100_100) + .margin({ top: $r('app.float.wh_value_20') }); + + TextInput({ placeholder: '密码', text: this.text }) + .type(InputType.Password) + .placeholderColor(Color.Blue) + .placeholderFont({ size: ConfigData.font_20, weight: 2, family: "sans-serif", style: FontStyle.Normal }) + .caretColor(Color.Blue) + .backgroundColor(Color.White) + .height($r('app.float.wh_value_70')) + .margin({ + top:$r('app.float.wh_value_20'), + left: $r('app.float.wh_value_15'), + right: $r('app.float.wh_value_15') + }) + .borderRadius($r('app.float.wh_value_15')) + .onChange((inputs: string) => { + this.text = inputs; + }); + + Row() { + Button() { + Text($r('app.string.cancel')) + .fontSize($r('app.float.font_24')) + .fontColor(Color.Blue) + } + .backgroundColor($r('app.color.color_E3E3E3_grey')) + .width($r('app.float.wh_value_160')) + .align(Alignment.Center) + .margin({left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15')}) + .onClick(() => { + router.back(); + }); + Button() { + Text($r('app.string.confirm')) + .fontSize($r('app.float.font_24')) + .fontColor(Color.Blue) + } + .backgroundColor($r('app.color.color_E3E3E3_grey')) + .width($r('app.float.wh_value_160')) + .align(Alignment.Center) + .margin({left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15')}) + .onClick(() => { + router.back({ + uri: 'pages/wifi', + params: { + opType: 'connect', + password: this.text + } + }); + }); + Button() { + Text($r('app.string.disconnect')) + .fontSize($r('app.float.font_24')) + .fontColor(Color.Blue) + } + .backgroundColor($r('app.color.color_E3E3E3_grey')) + .width($r('app.float.wh_value_160')) + .align(Alignment.Center) + .margin({left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15')}) + .onClick(() => { + router.back({ + uri: 'pages/wifi', + params: {opType: 'disconnect'} + }); + }); + } + .alignItems(VerticalAlign.Center) + .width(ConfigData.WH_100_100) + .margin({ top: $r('app.float.wh_value_20')}) + } + .alignItems(HorizontalAlign.Start) + .backgroundColor(Color.White); + } + + aboutToAppear(): void { + this.apInfo = router.getParams(); + LogUtil.info(MODULE_TAG + 'settings wifiPsd aboutToAppear apInfo : ' + JSON.stringify(this.apInfo)); + } + + onBackPress() { + router.back(); + } +} diff --git a/entry/src/main/ets/default/res/image/hdpi/ic_loading01.png b/product/phone/src/main/ets/default/res/image/hdpi/ic_loading01.png similarity index 100% rename from entry/src/main/ets/default/res/image/hdpi/ic_loading01.png rename to product/phone/src/main/ets/default/res/image/hdpi/ic_loading01.png diff --git a/entry/src/main/ets/default/res/image/hdpi/ic_loading02.png b/product/phone/src/main/ets/default/res/image/hdpi/ic_loading02.png similarity index 100% rename from entry/src/main/ets/default/res/image/hdpi/ic_loading02.png rename to product/phone/src/main/ets/default/res/image/hdpi/ic_loading02.png diff --git a/entry/src/main/ets/default/res/image/hdpi/ic_loading03.png b/product/phone/src/main/ets/default/res/image/hdpi/ic_loading03.png similarity index 100% rename from entry/src/main/ets/default/res/image/hdpi/ic_loading03.png rename to product/phone/src/main/ets/default/res/image/hdpi/ic_loading03.png diff --git a/entry/src/main/ets/default/res/image/hdpi/ic_loading04.png b/product/phone/src/main/ets/default/res/image/hdpi/ic_loading04.png similarity index 100% rename from entry/src/main/ets/default/res/image/hdpi/ic_loading04.png rename to product/phone/src/main/ets/default/res/image/hdpi/ic_loading04.png diff --git a/entry/src/main/ets/default/res/image/hdpi/ic_loading05.png b/product/phone/src/main/ets/default/res/image/hdpi/ic_loading05.png similarity index 100% rename from entry/src/main/ets/default/res/image/hdpi/ic_loading05.png rename to product/phone/src/main/ets/default/res/image/hdpi/ic_loading05.png diff --git a/entry/src/main/ets/default/res/image/hdpi/ic_loading06.png b/product/phone/src/main/ets/default/res/image/hdpi/ic_loading06.png similarity index 100% rename from entry/src/main/ets/default/res/image/hdpi/ic_loading06.png rename to product/phone/src/main/ets/default/res/image/hdpi/ic_loading06.png diff --git a/entry/src/main/ets/default/res/image/ic_settings_about.svg b/product/phone/src/main/ets/default/res/image/ic_settings_about.svg similarity index 100% rename from entry/src/main/ets/default/res/image/ic_settings_about.svg rename to product/phone/src/main/ets/default/res/image/ic_settings_about.svg diff --git a/entry/src/main/ets/default/res/image/ic_settings_advanced.svg b/product/phone/src/main/ets/default/res/image/ic_settings_advanced.svg similarity index 100% rename from entry/src/main/ets/default/res/image/ic_settings_advanced.svg rename to product/phone/src/main/ets/default/res/image/ic_settings_advanced.svg diff --git a/entry/src/main/ets/default/res/image/ic_settings_applications.svg b/product/phone/src/main/ets/default/res/image/ic_settings_applications.svg similarity index 100% rename from entry/src/main/ets/default/res/image/ic_settings_applications.svg rename to product/phone/src/main/ets/default/res/image/ic_settings_applications.svg diff --git a/entry/src/main/ets/default/res/image/ic_settings_arrow.svg b/product/phone/src/main/ets/default/res/image/ic_settings_arrow.svg similarity index 100% rename from entry/src/main/ets/default/res/image/ic_settings_arrow.svg rename to product/phone/src/main/ets/default/res/image/ic_settings_arrow.svg diff --git a/product/phone/src/main/ets/default/res/image/ic_settings_developer.svg b/product/phone/src/main/ets/default/res/image/ic_settings_developer.svg new file mode 100644 index 00000000..72b7056a --- /dev/null +++ b/product/phone/src/main/ets/default/res/image/ic_settings_developer.svg @@ -0,0 +1,38 @@ + + + Artboard + + + + + + + \ No newline at end of file diff --git a/entry/src/main/ets/default/res/image/ic_settings_display.svg b/product/phone/src/main/ets/default/res/image/ic_settings_display.svg similarity index 100% rename from entry/src/main/ets/default/res/image/ic_settings_display.svg rename to product/phone/src/main/ets/default/res/image/ic_settings_display.svg diff --git a/product/phone/src/main/ets/default/res/image/ic_settings_password.svg b/product/phone/src/main/ets/default/res/image/ic_settings_password.svg new file mode 100644 index 00000000..6bb0a364 --- /dev/null +++ b/product/phone/src/main/ets/default/res/image/ic_settings_password.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/product/phone/src/main/ets/default/res/image/ic_settings_privacy.svg b/product/phone/src/main/ets/default/res/image/ic_settings_privacy.svg new file mode 100644 index 00000000..3b1e6718 --- /dev/null +++ b/product/phone/src/main/ets/default/res/image/ic_settings_privacy.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/product/phone/src/main/ets/default/res/image/ic_settings_restore.svg b/product/phone/src/main/ets/default/res/image/ic_settings_restore.svg new file mode 100644 index 00000000..72b7056a --- /dev/null +++ b/product/phone/src/main/ets/default/res/image/ic_settings_restore.svg @@ -0,0 +1,38 @@ + + + Artboard + + + + + + + \ No newline at end of file diff --git a/product/phone/src/main/ets/default/res/image/ic_settings_storage.svg b/product/phone/src/main/ets/default/res/image/ic_settings_storage.svg new file mode 100644 index 00000000..e0802ea3 --- /dev/null +++ b/product/phone/src/main/ets/default/res/image/ic_settings_storage.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/product/phone/src/main/ets/default/res/image/ic_settings_users.svg b/product/phone/src/main/ets/default/res/image/ic_settings_users.svg new file mode 100644 index 00000000..9c0e534b --- /dev/null +++ b/product/phone/src/main/ets/default/res/image/ic_settings_users.svg @@ -0,0 +1,15 @@ + + + 用户和账户 + + + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/ets/default/res/image/ic_settings_volume.svg b/product/phone/src/main/ets/default/res/image/ic_settings_volume.svg similarity index 100% rename from entry/src/main/ets/default/res/image/ic_settings_volume.svg rename to product/phone/src/main/ets/default/res/image/ic_settings_volume.svg diff --git a/entry/src/main/ets/default/res/image/ic_settings_wifi.svg b/product/phone/src/main/ets/default/res/image/ic_settings_wifi.svg similarity index 100% rename from entry/src/main/ets/default/res/image/ic_settings_wifi.svg rename to product/phone/src/main/ets/default/res/image/ic_settings_wifi.svg diff --git a/product/phone/src/main/ets/default/res/image/ic_user_portrait.svg b/product/phone/src/main/ets/default/res/image/ic_user_portrait.svg new file mode 100644 index 00000000..26a66b69 --- /dev/null +++ b/product/phone/src/main/ets/default/res/image/ic_user_portrait.svg @@ -0,0 +1,16 @@ + + + IC/ic_user_portrait + + + + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/ets/default/res/image/ic_wifi_lock_signal_1_dark.svg b/product/phone/src/main/ets/default/res/image/ic_wifi_lock_signal_1_dark.svg similarity index 100% rename from entry/src/main/ets/default/res/image/ic_wifi_lock_signal_1_dark.svg rename to product/phone/src/main/ets/default/res/image/ic_wifi_lock_signal_1_dark.svg diff --git a/entry/src/main/ets/default/res/image/ic_wifi_lock_signal_2_dark.svg b/product/phone/src/main/ets/default/res/image/ic_wifi_lock_signal_2_dark.svg similarity index 100% rename from entry/src/main/ets/default/res/image/ic_wifi_lock_signal_2_dark.svg rename to product/phone/src/main/ets/default/res/image/ic_wifi_lock_signal_2_dark.svg diff --git a/entry/src/main/ets/default/res/image/ic_wifi_lock_signal_3_dark.svg b/product/phone/src/main/ets/default/res/image/ic_wifi_lock_signal_3_dark.svg similarity index 100% rename from entry/src/main/ets/default/res/image/ic_wifi_lock_signal_3_dark.svg rename to product/phone/src/main/ets/default/res/image/ic_wifi_lock_signal_3_dark.svg diff --git a/entry/src/main/ets/default/res/image/ic_wifi_lock_signal_4_dark.svg b/product/phone/src/main/ets/default/res/image/ic_wifi_lock_signal_4_dark.svg similarity index 100% rename from entry/src/main/ets/default/res/image/ic_wifi_lock_signal_4_dark.svg rename to product/phone/src/main/ets/default/res/image/ic_wifi_lock_signal_4_dark.svg diff --git a/entry/src/main/ets/default/res/image/ic_wifi_signal_1_dark.svg b/product/phone/src/main/ets/default/res/image/ic_wifi_signal_1_dark.svg similarity index 100% rename from entry/src/main/ets/default/res/image/ic_wifi_signal_1_dark.svg rename to product/phone/src/main/ets/default/res/image/ic_wifi_signal_1_dark.svg diff --git a/entry/src/main/ets/default/res/image/ic_wifi_signal_2_dark.svg b/product/phone/src/main/ets/default/res/image/ic_wifi_signal_2_dark.svg similarity index 100% rename from entry/src/main/ets/default/res/image/ic_wifi_signal_2_dark.svg rename to product/phone/src/main/ets/default/res/image/ic_wifi_signal_2_dark.svg diff --git a/entry/src/main/ets/default/res/image/ic_wifi_signal_3_dark.svg b/product/phone/src/main/ets/default/res/image/ic_wifi_signal_3_dark.svg similarity index 100% rename from entry/src/main/ets/default/res/image/ic_wifi_signal_3_dark.svg rename to product/phone/src/main/ets/default/res/image/ic_wifi_signal_3_dark.svg diff --git a/entry/src/main/ets/default/res/image/ic_wifi_signal_4_dark.svg b/product/phone/src/main/ets/default/res/image/ic_wifi_signal_4_dark.svg similarity index 100% rename from entry/src/main/ets/default/res/image/ic_wifi_signal_4_dark.svg rename to product/phone/src/main/ets/default/res/image/ic_wifi_signal_4_dark.svg diff --git a/entry/src/main/ets/default/res/image/mdpi/ic_loading01.png b/product/phone/src/main/ets/default/res/image/mdpi/ic_loading01.png similarity index 100% rename from entry/src/main/ets/default/res/image/mdpi/ic_loading01.png rename to product/phone/src/main/ets/default/res/image/mdpi/ic_loading01.png diff --git a/entry/src/main/ets/default/res/image/mdpi/ic_loading02.png b/product/phone/src/main/ets/default/res/image/mdpi/ic_loading02.png similarity index 100% rename from entry/src/main/ets/default/res/image/mdpi/ic_loading02.png rename to product/phone/src/main/ets/default/res/image/mdpi/ic_loading02.png diff --git a/entry/src/main/ets/default/res/image/mdpi/ic_loading03.png b/product/phone/src/main/ets/default/res/image/mdpi/ic_loading03.png similarity index 100% rename from entry/src/main/ets/default/res/image/mdpi/ic_loading03.png rename to product/phone/src/main/ets/default/res/image/mdpi/ic_loading03.png diff --git a/entry/src/main/ets/default/res/image/mdpi/ic_loading04.png b/product/phone/src/main/ets/default/res/image/mdpi/ic_loading04.png similarity index 100% rename from entry/src/main/ets/default/res/image/mdpi/ic_loading04.png rename to product/phone/src/main/ets/default/res/image/mdpi/ic_loading04.png diff --git a/entry/src/main/ets/default/res/image/mdpi/ic_loading05.png b/product/phone/src/main/ets/default/res/image/mdpi/ic_loading05.png similarity index 100% rename from entry/src/main/ets/default/res/image/mdpi/ic_loading05.png rename to product/phone/src/main/ets/default/res/image/mdpi/ic_loading05.png diff --git a/entry/src/main/ets/default/res/image/mdpi/ic_loading06.png b/product/phone/src/main/ets/default/res/image/mdpi/ic_loading06.png similarity index 100% rename from entry/src/main/ets/default/res/image/mdpi/ic_loading06.png rename to product/phone/src/main/ets/default/res/image/mdpi/ic_loading06.png diff --git a/entry/src/main/ets/default/res/image/xhdpi/ic_loading01.png b/product/phone/src/main/ets/default/res/image/xhdpi/ic_loading01.png similarity index 100% rename from entry/src/main/ets/default/res/image/xhdpi/ic_loading01.png rename to product/phone/src/main/ets/default/res/image/xhdpi/ic_loading01.png diff --git a/entry/src/main/ets/default/res/image/xhdpi/ic_loading02.png b/product/phone/src/main/ets/default/res/image/xhdpi/ic_loading02.png similarity index 100% rename from entry/src/main/ets/default/res/image/xhdpi/ic_loading02.png rename to product/phone/src/main/ets/default/res/image/xhdpi/ic_loading02.png diff --git a/entry/src/main/ets/default/res/image/xhdpi/ic_loading03.png b/product/phone/src/main/ets/default/res/image/xhdpi/ic_loading03.png similarity index 100% rename from entry/src/main/ets/default/res/image/xhdpi/ic_loading03.png rename to product/phone/src/main/ets/default/res/image/xhdpi/ic_loading03.png diff --git a/entry/src/main/ets/default/res/image/xhdpi/ic_loading04.png b/product/phone/src/main/ets/default/res/image/xhdpi/ic_loading04.png similarity index 100% rename from entry/src/main/ets/default/res/image/xhdpi/ic_loading04.png rename to product/phone/src/main/ets/default/res/image/xhdpi/ic_loading04.png diff --git a/entry/src/main/ets/default/res/image/xhdpi/ic_loading05.png b/product/phone/src/main/ets/default/res/image/xhdpi/ic_loading05.png similarity index 100% rename from entry/src/main/ets/default/res/image/xhdpi/ic_loading05.png rename to product/phone/src/main/ets/default/res/image/xhdpi/ic_loading05.png diff --git a/entry/src/main/ets/default/res/image/xhdpi/ic_loading06.png b/product/phone/src/main/ets/default/res/image/xhdpi/ic_loading06.png similarity index 100% rename from entry/src/main/ets/default/res/image/xhdpi/ic_loading06.png rename to product/phone/src/main/ets/default/res/image/xhdpi/ic_loading06.png diff --git a/entry/src/main/ets/default/res/image/xxhdpi/ic_loading01.png b/product/phone/src/main/ets/default/res/image/xxhdpi/ic_loading01.png similarity index 100% rename from entry/src/main/ets/default/res/image/xxhdpi/ic_loading01.png rename to product/phone/src/main/ets/default/res/image/xxhdpi/ic_loading01.png diff --git a/entry/src/main/ets/default/res/image/xxhdpi/ic_loading02.png b/product/phone/src/main/ets/default/res/image/xxhdpi/ic_loading02.png similarity index 100% rename from entry/src/main/ets/default/res/image/xxhdpi/ic_loading02.png rename to product/phone/src/main/ets/default/res/image/xxhdpi/ic_loading02.png diff --git a/entry/src/main/ets/default/res/image/xxhdpi/ic_loading03.png b/product/phone/src/main/ets/default/res/image/xxhdpi/ic_loading03.png similarity index 100% rename from entry/src/main/ets/default/res/image/xxhdpi/ic_loading03.png rename to product/phone/src/main/ets/default/res/image/xxhdpi/ic_loading03.png diff --git a/entry/src/main/ets/default/res/image/xxhdpi/ic_loading04.png b/product/phone/src/main/ets/default/res/image/xxhdpi/ic_loading04.png similarity index 100% rename from entry/src/main/ets/default/res/image/xxhdpi/ic_loading04.png rename to product/phone/src/main/ets/default/res/image/xxhdpi/ic_loading04.png diff --git a/entry/src/main/ets/default/res/image/xxhdpi/ic_loading05.png b/product/phone/src/main/ets/default/res/image/xxhdpi/ic_loading05.png similarity index 100% rename from entry/src/main/ets/default/res/image/xxhdpi/ic_loading05.png rename to product/phone/src/main/ets/default/res/image/xxhdpi/ic_loading05.png diff --git a/entry/src/main/ets/default/res/image/xxhdpi/ic_loading06.png b/product/phone/src/main/ets/default/res/image/xxhdpi/ic_loading06.png similarity index 100% rename from entry/src/main/ets/default/res/image/xxhdpi/ic_loading06.png rename to product/phone/src/main/ets/default/res/image/xxhdpi/ic_loading06.png diff --git a/entry/src/main/ets/default/res/image/xxxhdpi/ic_loading01.png b/product/phone/src/main/ets/default/res/image/xxxhdpi/ic_loading01.png similarity index 100% rename from entry/src/main/ets/default/res/image/xxxhdpi/ic_loading01.png rename to product/phone/src/main/ets/default/res/image/xxxhdpi/ic_loading01.png diff --git a/entry/src/main/ets/default/res/image/xxxhdpi/ic_loading02.png b/product/phone/src/main/ets/default/res/image/xxxhdpi/ic_loading02.png similarity index 100% rename from entry/src/main/ets/default/res/image/xxxhdpi/ic_loading02.png rename to product/phone/src/main/ets/default/res/image/xxxhdpi/ic_loading02.png diff --git a/entry/src/main/ets/default/res/image/xxxhdpi/ic_loading03.png b/product/phone/src/main/ets/default/res/image/xxxhdpi/ic_loading03.png similarity index 100% rename from entry/src/main/ets/default/res/image/xxxhdpi/ic_loading03.png rename to product/phone/src/main/ets/default/res/image/xxxhdpi/ic_loading03.png diff --git a/entry/src/main/ets/default/res/image/xxxhdpi/ic_loading04.png b/product/phone/src/main/ets/default/res/image/xxxhdpi/ic_loading04.png similarity index 100% rename from entry/src/main/ets/default/res/image/xxxhdpi/ic_loading04.png rename to product/phone/src/main/ets/default/res/image/xxxhdpi/ic_loading04.png diff --git a/entry/src/main/ets/default/res/image/xxxhdpi/ic_loading05.png b/product/phone/src/main/ets/default/res/image/xxxhdpi/ic_loading05.png similarity index 100% rename from entry/src/main/ets/default/res/image/xxxhdpi/ic_loading05.png rename to product/phone/src/main/ets/default/res/image/xxxhdpi/ic_loading05.png diff --git a/entry/src/main/ets/default/res/image/xxxhdpi/ic_loading06.png b/product/phone/src/main/ets/default/res/image/xxxhdpi/ic_loading06.png similarity index 100% rename from entry/src/main/ets/default/res/image/xxxhdpi/ic_loading06.png rename to product/phone/src/main/ets/default/res/image/xxxhdpi/ic_loading06.png diff --git a/entry/src/main/ets/default/resources/res-hdpi.json b/product/phone/src/main/ets/default/resources/res-hdpi.json similarity index 100% rename from entry/src/main/ets/default/resources/res-hdpi.json rename to product/phone/src/main/ets/default/resources/res-hdpi.json diff --git a/entry/src/main/ets/default/resources/res-mdpi.json b/product/phone/src/main/ets/default/resources/res-mdpi.json similarity index 100% rename from entry/src/main/ets/default/resources/res-mdpi.json rename to product/phone/src/main/ets/default/resources/res-mdpi.json diff --git a/entry/src/main/ets/default/resources/res-xhdpi.json b/product/phone/src/main/ets/default/resources/res-xhdpi.json similarity index 100% rename from entry/src/main/ets/default/resources/res-xhdpi.json rename to product/phone/src/main/ets/default/resources/res-xhdpi.json diff --git a/entry/src/main/ets/default/resources/res-xxhdpi.json b/product/phone/src/main/ets/default/resources/res-xxhdpi.json similarity index 100% rename from entry/src/main/ets/default/resources/res-xxhdpi.json rename to product/phone/src/main/ets/default/resources/res-xxhdpi.json diff --git a/entry/src/main/ets/default/resources/res-xxxhdpi.json b/product/phone/src/main/ets/default/resources/res-xxxhdpi.json similarity index 100% rename from entry/src/main/ets/default/resources/res-xxxhdpi.json rename to product/phone/src/main/ets/default/resources/res-xxxhdpi.json diff --git a/entry/src/main/resources/base/element/color.json b/product/phone/src/main/resources/base/element/color.json similarity index 61% rename from entry/src/main/resources/base/element/color.json rename to product/phone/src/main/resources/base/element/color.json index d1680695..2b5a5277 100644 --- a/entry/src/main/resources/base/element/color.json +++ b/product/phone/src/main/resources/base/element/color.json @@ -16,6 +16,10 @@ "name": "color_E3E3E3_grey", "value": "#E3E3E3" }, + { + "name": "color_D8D8D8_grey", + "value": "#D8D8D8" + }, { "name": "color_00000000_transparent", "value": "#00000000" @@ -23,6 +27,18 @@ { "name": "volume_bg_color", "value": "#CCFFFFFF" + }, + { + "name": "white_bg_color", + "value": "#FFFFFF" + }, + { + "name": "font_color_182431", + "value": "#182431" + }, + { + "name": "font_color_007DFF", + "value": "#007DFF" } ] } \ No newline at end of file diff --git a/product/phone/src/main/resources/base/element/float.json b/product/phone/src/main/resources/base/element/float.json new file mode 100644 index 00000000..9c648faa --- /dev/null +++ b/product/phone/src/main/resources/base/element/float.json @@ -0,0 +1,432 @@ +{ + "float": [ + { + "name": "wh_value_1", + "value": "1" + }, + { + "name": "wh_value_5", + "value": "5" + }, + { + "name": "wh_value_8", + "value": "8" + }, + { + "name": "wh_value_10", + "value": "10" + }, + { + "name": "wh_value_12", + "value": "12" + }, + { + "name": "wh_value_15", + "value": "15" + }, + { + "name": "wh_value_20", + "value": "20" + }, + { + "name": "wh_value_26", + "value": "26" + }, + { + "name": "wh_value_30", + "value": "30" + }, + { + "name": "wh_value_32", + "value": "32" + }, + { + "name": "wh_value_40", + "value": "40" + }, + { + "name": "wh_value_44", + "value": "44" + }, + { + "name": "wh_value_50", + "value": "50" + }, + { + "name": "wh_value_56", + "value": "56" + }, + { + "name": "wh_value_60", + "value": "60" + }, + { + "name": "wh_value_65", + "value": "65" + }, + { + "name": "wh_value_70", + "value": "70" + }, + { + "name": "wh_value_80", + "value": "80" + }, + { + "name": "wh_value_100", + "value": "100" + }, + { + "name": "wh_value_130", + "value": "1300" + }, + { + "name": "wh_value_160", + "value": "160" + }, + { + "name": "wh_value_210", + "value": "210" + }, + { + "name": "wh_value_230", + "value": "230" + }, + { + "name": "wh_value_280", + "value": "280" + }, + { + "name": "wh_value_390", + "value": "390" + }, + { + "name": "wh_value_400", + "value": "400" + }, + { + "name": "font_35", + "value": "35" + }, + { + "name": "font_10", + "value": "10" + }, + { + "name": "font_18", + "value": "18" + }, + { + "name": "font_20", + "value": "20" + }, + { + "name": "font_21", + "value": "21" + }, + { + "name": "font_22", + "value": "22" + }, + { + "name": "font_24", + "value": "24" + }, + { + "name": "font_28", + "value": "28" + }, + { + "name": "font_50", + "value": "50" + }, + { + "name": "distance_8", + "value": "8" + }, + { + "name": "distance_16", + "value": "16" + }, + { + "name": "distance_20", + "value": "20" + }, + { + "name": "distance_24", + "value": "24" + }, + { + "name": "distance_80", + "value": "80" + }, + { + "name": "item_common_vertical_margin", + "value": "20" + }, + { + "name": "control_common_font_size", + "value": "20" + }, + { + "name": "item_common_horizontal_margin", + "value": "16" + }, + { + "name": "slider_text_padding_left", + "value": "5" + }, + { + "name": "page_header_height", + "value": "70" + }, + { + "name": "volume_border_radius", + "value": "15" + }, + { + "name": "radius_24", + "value": "24" + }, + { + "name": "radius_40", + "value": "40" + }, + { + "name": "search_input_height", + "value": "40vp" + }, + { + "name": "search_input_horizontal_margin", + "value": "8vp" + }, + { + "name": "search_input_border_radius", + "value": "20vp" + }, + { + "name": "search_no_result_height", + "value": "50vp" + }, + { + "name": "search_result_item_title_font_size", + "value": "19vp" + }, + { + "name": "search_result_item_summary_font_size", + "value": "18vp" + }, + { + "name": "slider_image_width", + "value": "40" + }, + { + "name": "slider_image_height", + "value": "40" + }, + { + "name": "slider_image_margin", + "value": "15" + }, + { + "name": "audio_subtitle_font", + "value": "18" + }, + { + "name": "audio_subtitle_margin_left", + "value": "10" + }, + { + "name": "audio_subtitle_margin_bottom", + "value": "5" + }, + { + "name": "audio_title_summary_margin_left", + "value": "15" + }, + { + "name": "audio_summary_subtitle_margin_bottom", + "value": "10" + }, + { + "name": "audio_subtitle_margin_top", + "value": "10" + }, + { + "name": "audio_sound_mode_outer_height", + "value": "280" + }, + { + "name": "audio_sound_mode_inner_padding_top", + "value": "15" + }, + { + "name": "audio_sound_mode_inner_padding_bottom", + "value": "15" + }, + { + "name": "audio_sound_mode_outer_padding", + "value": "16" + }, + { + "name": "audio_sound_mode_item_inner_padding_top", + "value": "5" + }, + { + "name": "audio_sound_mode_border_width", + "value": "1" + }, + { + "name": "audio_sound_mode_border_radius", + "value": "15" + }, + { + "name": "audio_sound_mode_image_size", + "value": "40" + }, + { + "name": "audio_sound_mode_text_margin_top", + "value": "16" + }, + { + "name": "audio_sound_mode_font_size", + "value": "20" + }, + { + "name": "audio_sound_mode_radio_size", + "value": "36" + }, + { + "name": "audio_image_common_size", + "value": "50" + }, + { + "name": "audio_image_margin_right", + "value": "10" + }, + { + "name": "audio_subtitle_font_size", + "value": "18" + }, + { + "name": "audio_margin_left", + "value": "15" + }, + { + "name": "audio_start_end_margin_left", + "value": "15" + }, + { + "name": "audio_icon_height", + "value": "60" + }, + { + "name": "audio_no_icon_height", + "value": "70" + }, + { + "name": "audio_slider_height", + "value": "250" + }, + { + "name": "audio_volume_height", + "value": "280" + }, + { + "name": "audio_border_width", + "value": "1" + }, + { + "name": "audio_border_radius", + "value": "15" + }, + { + "name": "audio_volume_component_padding", + "value": "16" + }, + { + "name": "restore_factory_font_size", + "value": "20" + }, + { + "name": "restore_factory_button_width", + "value": "160" + }, + { + "name": "restore_factory_button_height", + "value": "40" + }, + { + "name": "switch_title_subtitle_size", + "value": "20" + }, + { + "name": "switch_component_margin", + "value": "15" + }, + { + "name": "switch_toggle_width", + "value": "60" + }, + { + "name": "switch_toggle_height", + "value": "40" + }, + { + "name": "switch_component_height", + "value": "70" + }, + { + "name": "application_common_size", + "value": "45" + }, + { + "name": "application_button_subtitle_size", + "value": "20" + }, + { + "name": "application_button_height", + "value": "40" + }, + { + "name": "storage_common_margin", + "value": "15" + }, + { + "name": "location_font_size", + "value": "18" + }, + { + "name": "location_common_margin", + "value": "15" + }, + { + "name": "storage_data_panel_height", + "value": "230" + }, + { + "name": "password_input_message_vertical_margin", + "value": "20" + }, + { + "name": "password_count_down_view_vertical_margin", + "value": "20" + }, + { + "name": "password_input_button_space", + "value": "10" + }, + { + "name": "password_input_button_margin_top", + "value": "40" + }, + { + "name": "radio_component_height", + "value": "30" + }, + { + "name": "radio_component_margin_bottom_right", + "value": "15" + } + ] +} \ No newline at end of file diff --git a/product/phone/src/main/resources/base/element/string.json b/product/phone/src/main/resources/base/element/string.json new file mode 100644 index 00000000..f9f69565 --- /dev/null +++ b/product/phone/src/main/resources/base/element/string.json @@ -0,0 +1,664 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "设置" + }, + { + "name": "mainability_description", + "value": "ETS_Empty Feature Ability" + }, + { + "name": "enabled", + "value": "已开启" + }, + { + "name": "disable_", + "value": "关闭" + }, + { + "name": "disabled", + "value": "已关闭" + }, + { + "name": "settings", + "value": "设置" + }, + { + "name": "searchHint", + "value": "搜索设置项" + }, + { + "name": "searchNoResult", + "value": "没有匹配的结果" + }, + { + "name": "wifiTab", + "value": "WLAN" + }, + { + "name": "brightnessTab", + "value": "亮度" + }, + { + "name": "applyTab", + "value": "应用" + }, + { + "name": "dateAndTimeTab", + "value": "日期和时间" + }, + { + "name": "aboutTab", + "value": "关于手机" + }, + { + "name": "volumeControlTab", + "value": "音量调节" + }, + { + "name": "volumeControl", + "value": "音量" + }, + { + "name": "volumeAndVibrationControl", + "value": "声音和振动" + }, + { + "name": "volumeControlRing", + "value": "来电、信息、通知" + }, + { + "name": "volumeControlMedia", + "value": "音乐、视频、游戏" + }, + { + "name": "volumeControlCall", + "value": "通话" + }, + { + "name": "soundMode", + "value": "声音模式" + }, + { + "name": "soundModeSound", + "value": "响铃" + }, + { + "name": "soundModeVibration", + "value": "振动" + }, + { + "name": "soundModeSilent", + "value": "静音" + }, + { + "name": "applicationInfo", + "value": "应用信息" + }, + { + "name": "appManagement", + "value": "应用管理" + }, + { + "name": "cancel", + "value": "取消" + }, + { + "name": "continue_", + "value": "继续" + }, + { + "name": "confirm", + "value": "确定" + }, + { + "name": "ok", + "value": "确定" + }, + { + "name": "next", + "value": "下一步" + }, + { + "name": "clear", + "value": "清空" + }, + { + "name": "wifiPassword", + "value": "密码" + }, + { + "name": "wifiMAC", + "value": "MAC地址" + }, + { + "name": "signalLevel", + "value": "信号强度" + }, + { + "name": "signalBand", + "value": "信号带宽" + }, + { + "name": "encryptMethod", + "value": "加密方式" + }, + { + "name": "disconnect", + "value": "断开连接" + }, + { + "name": "timeMorning", + "value": "上午" + }, + { + "name": "timeAfternoon", + "value": "下午" + }, + { + "name": "settingTime", + "value": "设置时间" + }, + { + "name": "timeFormat", + "value": "24小时制" + }, + { + "name": "timeZone", + "value": "时区" + }, + { + "name": "date", + "value": "日期" + }, + { + "name": "time", + "value": "时间" + }, + { + "name": "year", + "value": "年" + }, + { + "name": "month", + "value": "月" + }, + { + "name": "day", + "value": "日" + }, + { + "name": "tipsContent", + "value": "为提高位置信息的精确度,应用和服务仍然会扫描WLAN网络.您可以在提高精确度中更改此设置" + }, + { + "name": "wifiSynonym", + "value": "网络,上网,连接,www,http" + }, + { + "name": "wifiList", + "value": "可用WLAN列表" + }, + { + "name": "wifiListSynonym", + "value": "wifi,liebiao" + }, + { + "name": "systemName", + "value": "系统名称" + }, + { + "name": "model", + "value": "型号" + }, + { + "name": "companyInfo", + "value": "厂家信息" + }, + { + "name": "deviceId", + "value": "设备" + }, + { + "name": "softwareVersion", + "value": "软件版本" + }, + { + "name": "version", + "value": "版本 " + }, + { + "name": "password", + "value": "密码" + }, + { + "name": "connected", + "value": "已连接" + }, + { + "name": "monday", + "value": "星期一" + }, + { + "name": "tuesday", + "value": "星期二" + }, + { + "name": "wednesday", + "value": "星期三" + }, + { + "name": "thursday", + "value": "星期四" + }, + { + "name": "friday", + "value": "星期五" + }, + { + "name": "saturday", + "value": "星期六" + }, + { + "name": "sunday", + "value": "星期日" + }, + { + "name": "restoreFactoryTab", + "value": "恢复出厂设置" + }, + { + "name": "restoreFactory", + "value": "是否要恢复出厂设置" + }, + { + "name": "developerOptionsTab", + "value": "开发者选项" + }, + { + "name": "usbDebugging", + "value": "USB调试" + }, + { + "name": "usersAccountsTab", + "value": "用户和账号" + }, + { + "name": "user", + "value": "用户" + }, + { + "name": "administrator", + "value": "管理员" + }, + { + "name": "quest", + "value": "访客" + }, + { + "name": "you", + "value": "您" + }, + { + "name": "currentLogin", + "value": "当前登录" + }, + { + "name": "addUser", + "value": "添加用户" + }, + { + "name": "addGuest", + "value": "添加访客" + }, + { + "name": "removeUser", + "value": "删除用户" + }, + { + "name": "addUserImage", + "value": "点击图标更换用户图象" + }, + { + "name": "switchUser", + "value": "切换用户" + }, + { + "name": "askAddGuest", + "value": "是否添加访客?" + }, + { + "name": "addNewUser", + "value": "添加新用户" + }, + { + "name": "addUserDescription", + "value": "新用户添加后,该用户需设置自己的空间。" + }, + { + "name": "askSwitchUser", + "value": "切换到新用户吗?" + }, + { + "name": "switchButton", + "value": "切换" + }, + { + "name": "deleteUserWarn", + "value": "删除该用户并移除所有用户数据?" + }, + { + "name": "deleteButton", + "value": "删除" + }, + { + "name": "takePhoto", + "value": "拍照" + }, + { + "name": "chooseFromShop", + "value": "从图库中选择" + }, + { + "name": "systemTab", + "value": "系统" + }, + { + "name": "languageTab", + "value": "语言" + }, + { + "name": "setlanguage", + "value": "语言设置" + }, + { + "name": "languageAndRegion", + "value": "语言与地区" + }, + { + "name": "editLanguage", + "value": "编辑语言" + }, + { + "name": "addLanguage", + "value": "添加语言" + }, + { + "name": "edit", + "value": "编辑" + }, + { + "name": "delete", + "value": "删除" + }, + { + "name": "region", + "value": "地区" + }, + { + "name": "currentRegion", + "value": "当前地区" + }, + { + "name": "addedLanguage", + "value": "已添加语言" + }, + { + "name": "hasAdded", + "value": "已添加为偏好语言" + }, + { + "name": "allLanguage", + "value": "所有语言" + }, + { + "name": "saveLanguage", + "value": "请保留至少一种语言" + }, + { + "name": "changeLanguage", + "value": "是否将系统语言更改为%s?" + }, + { + "name": "change", + "value": "更改" + }, + { + "name": "keepCurrent", + "value": "保留当前" + }, + { + "name": "selectRegion", + "value": "选取地区" + }, + { + "name": "allRegion", + "value": "所有地区" + }, + { + "name": "faceRecognition", + "value": "人脸识别" + }, + { + "name": "faceauthFailed", + "value": "人脸识别启动失败,请确定该功能是否可用" + }, + { + "name": "privacy", + "value": "隐私" + }, + { + "name": "permissionManager", + "value": "权限管理" + }, + { + "name": "permissionFailed", + "value": "权限管理启动失败,请确定该功能是否可用" + }, + { + "name": "storageTab", + "value": "存储" + }, + { + "name": "totalSpace", + "value": "总空间" + }, + { + "name": "usedSpace", + "value": "已使用空间" + }, + { + "name": "remainingSpace", + "value": "剩余空间信息" + }, + { + "name": "authorityManagement", + "value": "权限管理" + }, + { + "name": "deleteDataTab", + "value": "删除数据" + }, + { + "name": "delete_data_prompt_title", + "value": "是否删除所选应用数据?" + }, + { + "name": "delete_data_prompt", + "value": "应用的全部数据删除后不可恢复,包括所有文件、设置、账户、数据库等。" + }, + { + "name": "clearCacheTab", + "value": "清空缓存" + }, + { + "name": "totalTab", + "value": "总计" + }, + { + "name": "dataTab", + "value": "数据" + }, + { + "name": "cacheTab", + "value": "缓存" + }, + { + "name": "uninstall", + "value": "卸载" + }, + { + "name": "uninstall_prompt", + "value": "是否卸载此应用?" + }, + { + "name": "forcedStop", + "value": "强行停止" + }, + { + "name": "Stop_exception_prompt", + "value": "可能导致异常。是否强行停止该应用?" + }, + { + "name": "privacyTab", + "value": "隐私" + }, + { + "name": "locationServicesTab", + "value": "定位服务" + }, + { + "name": "positionInformation", + "value": "访问我的位置信息" + }, + { + "name": "positionContent", + "value": "“定位服务”基于GNSS、网络信息(WLAN/蜂窝网络/蓝牙/IP)等来提供。启用后,您的位置可能会分享给已授权定位权限的服务。我们可能会从您的设备收集网络信息,以提高定位精度。这些信息无法识别或定位到您个人。您可以在“提高精确度”中进一步选择,以提高定位精度或关闭某些功能。更多信息,请阅读" + }, + { + "name": "statement", + "value": "关于定位服务和隐私的声明。" + }, + { + "name": "biometrics", + "value": "生物识别" + }, + { + "name":"face_recognition", + "value":"人脸识别" + }, + { + "name":"password_lock_screen", + "value":"锁屏密码" + }, + { + "name":"password_change_password", + "value":"更改锁屏密码" + }, + { + "name":"password_disable_password", + "value":"关闭锁屏密码" + }, + { + "name":"password_enter_password", + "value":"输入锁屏密码" + }, + { + "name":"password_change_unlock_method", + "value":"其他密码类型" + }, + { + "name":"password_select_unlock_method", + "value":"其他密码类型" + }, + { + "name":"password_title_number", + "value":"设置锁屏数字密码" + }, + { + "name":"password_title_character", + "value":"设置锁屏密码" + }, + { + "name":"password_message_number_6", + "value":"密码由6位数字组成" + }, + { + "name":"password_message_custom", + "value":"密码由4-32位数字组成" + }, + { + "name":"password_message_character", + "value":"密码由4-32字符字组成,需至少包含1个字母" + }, + { + "name":"password_message_repeat", + "value":"请再次输入密码" + }, + { + "name":"password_set_prompt", + "value":"请牢记您的锁屏密码,忘记后无法找回" + }, + { + "name":"password_message_repeat_error", + "value":"密码不一致,请重新输入" + }, + { + "name":"password_item_text_number_4", + "value":"4位数字密码" + }, + { + "name":"password_item_text_number_6", + "value":"6位数字密码" + }, + { + "name":"password_item_text_custom", + "value":"自定义数字密码" + }, + { + "name":"password_item_text_character", + "value":"混合密码" + }, + { + "name":"password_disable_prompt", + "value":"关闭密码后,任何拿到此设备的人都能够查看您的数据,设备无法收到保护。是否关闭?" + }, + { + "name":"password_message_incorrect", + "value":"密码错误,还可尝试 %d 次" + }, + { + "name":"password_remain_times", + "value":"请 %d秒 后重试" + }, + { + "name":"password_PIN_6_error", + "value":"PIN 应为 6 位数字" + }, + { + "name":"password_PIN_check_min_error", + "value":"PIN 至少应为 4 位" + }, + { + "name":"password_PIN_check_max_error", + "value":"PIN 必须少于 33 位数" + }, + { + "name":"password_check_min_error", + "value":"混合密码必须至少包含 4 个字符" + }, + { + "name":"password_check_max_error", + "value":"密码必须少于 33 个字符" + }, + { + "name":"password_check_char_error", + "value":"请至少包含 1 个字母" + }, + { + "name": "biometricsAndPassword", + "value": "生物识别和密码" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_back.svg b/product/phone/src/main/resources/base/media/ic_back.svg similarity index 100% rename from entry/src/main/resources/base/media/ic_back.svg rename to product/phone/src/main/resources/base/media/ic_back.svg diff --git a/product/phone/src/main/resources/base/media/ic_delete.svg b/product/phone/src/main/resources/base/media/ic_delete.svg new file mode 100644 index 00000000..17176152 --- /dev/null +++ b/product/phone/src/main/resources/base/media/ic_delete.svg @@ -0,0 +1,13 @@ + + + xxxhdpi/ic_delete + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_settings_arrow.svg b/product/phone/src/main/resources/base/media/ic_settings_arrow.svg similarity index 100% rename from entry/src/main/resources/base/media/ic_settings_arrow.svg rename to product/phone/src/main/resources/base/media/ic_settings_arrow.svg diff --git a/product/phone/src/main/resources/base/media/ic_settings_audio_sound_mode_silent.svg b/product/phone/src/main/resources/base/media/ic_settings_audio_sound_mode_silent.svg new file mode 100644 index 00000000..bec45e25 --- /dev/null +++ b/product/phone/src/main/resources/base/media/ic_settings_audio_sound_mode_silent.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/product/phone/src/main/resources/base/media/ic_settings_audio_sound_mode_sound.svg b/product/phone/src/main/resources/base/media/ic_settings_audio_sound_mode_sound.svg new file mode 100644 index 00000000..bec45e25 --- /dev/null +++ b/product/phone/src/main/resources/base/media/ic_settings_audio_sound_mode_sound.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/product/phone/src/main/resources/base/media/ic_settings_audio_sound_mode_vibration.svg b/product/phone/src/main/resources/base/media/ic_settings_audio_sound_mode_vibration.svg new file mode 100644 index 00000000..bec45e25 --- /dev/null +++ b/product/phone/src/main/resources/base/media/ic_settings_audio_sound_mode_vibration.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_settings_brightness_maximum.svg b/product/phone/src/main/resources/base/media/ic_settings_brightness_maximum.svg similarity index 100% rename from entry/src/main/resources/base/media/ic_settings_brightness_maximum.svg rename to product/phone/src/main/resources/base/media/ic_settings_brightness_maximum.svg diff --git a/entry/src/main/resources/base/media/ic_settings_brightness_minimum.svg b/product/phone/src/main/resources/base/media/ic_settings_brightness_minimum.svg similarity index 100% rename from entry/src/main/resources/base/media/ic_settings_brightness_minimum.svg rename to product/phone/src/main/resources/base/media/ic_settings_brightness_minimum.svg diff --git a/entry/src/main/resources/base/media/icon.png b/product/phone/src/main/resources/base/media/icon.png old mode 100755 new mode 100644 similarity index 100% rename from entry/src/main/resources/base/media/icon.png rename to product/phone/src/main/resources/base/media/icon.png diff --git a/entry/src/main/resources/base/media/icon_default.png b/product/phone/src/main/resources/base/media/icon_default.png similarity index 100% rename from entry/src/main/resources/base/media/icon_default.png rename to product/phone/src/main/resources/base/media/icon_default.png diff --git a/product/phone/src/main/resources/en_AS/element/string.json b/product/phone/src/main/resources/en_AS/element/string.json new file mode 100644 index 00000000..20f4d11d --- /dev/null +++ b/product/phone/src/main/resources/en_AS/element/string.json @@ -0,0 +1,660 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "设置" + }, + { + "name": "mainability_description", + "value": "ETS_Empty Feature Ability" + }, + { + "name": "enabled", + "value": "Enabled" + }, + { + "name": "disable_", + "value": "Disable" + }, + { + "name": "disabled", + "value": "Disabled" + }, + { + "name": "settings", + "value": "Settings" + }, + { + "name": "searchHint", + "value": "Search" + }, + { + "name": "searchNoResult", + "value": "No search result " + }, + { + "name": "wifiTab", + "value": "WLAN" + }, + { + "name": "brightnessTab", + "value": "brightness" + }, + { + "name": "volumeControl", + "value": "volumeControl" + }, + { + "name": "volumeAndVibrationControl", + "value": "volumeAndVibration" + }, + { + "name": "volumeControlTab", + "value": "volumeControl" + }, + { + "name": "volumeControlRing", + "value": "Ringer, Messages, Notifications" + }, + { + "name": "volumeControlMedia", + "value": "Music, Videos, games" + }, + { + "name": "volumeControlCall", + "value": "Calls" + }, + { + "name": "soundMode", + "value": "Sound Mode" + }, + { + "name": "soundModeSound", + "value": "Sound" + }, + { + "name": "soundModeVibration", + "value": "Vibration" + }, + { + "name": "soundModeSilent", + "value": "Silent" + }, + { + "name": "applyTab", + "value": "apply" + }, + { + "name": "dateAndTimeTab", + "value": "dateAndTime" + }, + { + "name": "aboutTab", + "value": "about" + }, + { + "name": "applicationInfo", + "value": "App info" + }, + { + "name": "appManagement", + "value": "Apps" + }, + { + "name": "cancel", + "value": "Cancel" + }, + { + "name": "continue_", + "value": "continue" + }, + { + "name": "confirm", + "value": "Confirm" + }, + { + "name": "ok", + "value": "ok" + }, + { + "name": "next", + "value": "next" + }, + { + "name": "clear", + "value": "Clear" + }, + { + "name": "wifiPassword", + "value": "Password" + }, + { + "name": "wifiMAC", + "value": "BSSID" + }, + { + "name": "signalLevel", + "value": "RSSI" + }, + { + "name": "signalBand", + "value": "BAND" + }, + { + "name": "encryptMethod", + "value": "EncryptType" + }, + { + "name": "disconnect", + "value": "disconnect" + }, + { + "name": "timeMorning", + "value": "AM" + }, + { + "name": "timeAfternoon", + "value": "PM" + }, + { + "name": "settingTime", + "value": "settingTime" + }, + { + "name": "timeFormat", + "value": "militaryTime" + }, + { + "name": "timeZone", + "value": "TimeZone" + }, + { + "name": "date", + "value": "Date" + }, + { + "name": "time", + "value": "Time" + }, + { + "name": "year", + "value": "year" + }, + { + "name": "month", + "value": "month" + }, + { + "name": "day", + "value": "date" + }, + { + "name": "wifiSynonym", + "value": "net,network,connect,www,http" + }, + { + "name": "wifiList", + "value": "WLAN-List which can be used" + }, + { + "name": "wifiListSynonym", + "value": "wifi,liebiao" + }, + { + "name": "systemName", + "value": "SystemName" + }, + { + "name": "model", + "value": "Model" + }, + { + "name": "companyInfo", + "value": "CompanyInfo" + }, + { + "name": "deviceId", + "value": "DeviceId" + }, + { + "name": "softwareVersion", + "value": "SoftwareVersion" + }, + { + "name": "version", + "value": "version " + }, + { + "name": "password", + "value": "password" + }, + { + "name": "connected", + "value": "connected" + }, + { + "name": "monday", + "value": "monday" + }, + { + "name": "tuesday", + "value": "tuesday" + }, + { + "name": "wednesday", + "value": "wednesday" + }, + { + "name": "thursday", + "value": "thursday" + }, + { + "name": "friday", + "value": "friday" + }, + { + "name": "saturday", + "value": "saturday" + }, + { + "name": "sunday", + "value": "sunday" + }, + { + "name": "restoreFactoryTab", + "value": "restoreFactorySettings" + }, + { + "name": "restoreFactory", + "value": "Do you want to restore factory settings" + }, + { + "name": "developerOptionsTab", + "value": "developerOptions" + }, + { + "name": "usbDebugging", + "value": "USB Debugging" + }, + { + "name": "usersAccountsTab", + "value": "Users & Accounts" + }, + { + "name": "user", + "value": "User" + }, + { + "name": "administrator", + "value": "Administrator" + }, + { + "name": "quest", + "value": "Quest" + }, + { + "name": "you", + "value": "You" + }, + { + "name": "currentLogin", + "value": "Current Login" + }, + { + "name": "addUser", + "value": "Add user" + }, + { + "name": "addGuest", + "value": "Add guest" + }, + { + "name": "removeUser", + "value": "Remove user" + }, + { + "name": "addUserImage", + "value": "Touch icon to set a profile picture" + }, + { + "name": "switchUser", + "value": "Switch user" + }, + { + "name": "askAddGuest", + "value": "Add guest user?" + }, + { + "name": "addNewUser", + "value": "Add New User" + }, + { + "name": "addUserDescription", + "value": "When you add a new user, that person needs to set up their space." + }, + { + "name": "askSwitchUser", + "value": "Switch to new user?" + }, + { + "name": "switchButton", + "value": "SWITCH" + }, + { + "name": "deleteUserWarn", + "value": "Delete this user and all related data?" + }, + { + "name": "deleteButton", + "value": "DELETE" + }, + { + "name": "takePhoto", + "value": "Take photo" + }, + { + "name": "chooseFromShop", + "value": "Choose from photoshop" + }, + { + "name": "systemTab", + "value": "system" + }, + { + "name": "languageTab", + "value": "language" + }, + { + "name": "setlanguage", + "value": "Set Language" + }, + { + "name": "languageAndRegion", + "value": "LANGUAGE" + }, + { + "name": "editLanguage", + "value": "Edit Language" + }, + { + "name": "addLanguage", + "value": "Add Language" + }, + { + "name": "edit", + "value": "EDIT" + }, + { + "name": "delete", + "value": "DELETE" + }, + { + "name": "region", + "value": "REGION" + }, + { + "name": "currentRegion", + "value": "Current Region" + }, + { + "name": "addedLanguage", + "value": "ADDED" + }, + { + "name": "hasAdded", + "value": "Added to preferred languages." + }, + { + "name": "allLanguage", + "value": "ALL LANGUAGES" + }, + { + "name": "saveLanguage", + "value": "Please keep at least one language" + }, + { + "name": "changeLanguage", + "value": "Are you sure you want to change your system language to %s?" + }, + { + "name": "change", + "value": "CHANGE" + }, + { + "name": "keepCurrent", + "value": "CANCEL" + }, + { + "name": "selectRegion", + "value": "Select Region" + }, + { + "name": "allRegion", + "value": "ALL REGION" + }, + { + "name": "faceRecognition", + "value": "Face Recognition" + }, + { + "name": "faceauthFailed", + "value": "Face recognition failed to start, please make sure the function is available." + }, + { + "name": "privacy", + "value": "Privacy" + }, + { + "name": "permissionManager", + "value": "Permission Manager" + }, + { + "name": "permissionFailed", + "value": "Permission management failed to start, please make sure the function is available." + }, + { + "name": "storageTab", + "value": "storageTab" + }, + { + "name": "totalSpace", + "value": "totalSpace" + }, + { + "name": "usedSpace", + "value": "usedSpace" + }, + { + "name": "remainingSpace", + "value": "remainingSpaceInformation" + }, + { + "name": "authorityManagement", + "value": "authorityManagement" + }, + { + "name": "deleteDataTab", + "value": "deleteData" + }, + { + "name": "delete_data_prompt_title", + "value": "Delete the selected application data" + }, + { + "name": "delete_data_prompt", + "value": "This will permanently delete all of this app's data,including files,settings and accounts" + }, + { + "name": "clearCacheTab", + "value": "clearCache" + }, + { + "name": "totalTab", + "value": "total" + }, + { + "name": "dataTab", + "value": "data" + }, + { + "name": "cacheTab", + "value": "cache" + }, + { + "name": "uninstall", + "value": "uninstall" + }, + { + "name": "uninstall_prompt", + "value": "Do you want to uninstall this app?" + }, + { + "name": "forcedStop", + "value": "forcedStop" + }, + { + "name": "Stop_exception_prompt", + "value": "This app may stop working properly if you force stop it." + }, + { + "name": "privacyTab", + "value": "privacyTab" + }, + { + "name": "locationServicesTab", + "value": "locationServicesTab" + }, + { + "name": "positionInformation", + "value": "positionInformation" + }, + { + "name": "positionContent", + "value": "\"Location service\" is provided based on GNSS, network information (WLAN / cellular network / Bluetooth / IP), etc. When enabled, your location may be shared with services authorized to locate. We may collect network information from your device to improve positioning accuracy. These information can not be identified or located to you personally. You can further select in \"improve accuracy\" to improve positioning accuracy or turn off some functions. For more information, see" + }, + { + "name": "statement", + "value": "Statement on location services and privacy。" + }, + { + "name": "biometrics", + "value": "biometrics" + }, + { + "name":"face_recognition", + "value":"Face Recognition" + }, + { + "name":"password_lock_screen", + "value":"Lock screen password" + }, + { + "name":"password_change_password", + "value":"Change lock screen password" + }, + { + "name":"password_disable_password", + "value":"Disable lock screen password" + }, + { + "name":"password_enter_password", + "value":"Enter lock screen password" + }, + { + "name":"password_change_unlock_method", + "value":"change unlock method" + }, + { + "name":"password_select_unlock_method", + "value":"Select unlock method" + }, + { + "name":"password_title_number", + "value":"Set new password" + }, + { + "name":"password_title_character", + "value":"Set new password" + }, + { + "name":"password_message_number_6", + "value":"Set a 6-digit PIN" + }, + { + "name":"password_message_custom", + "value":"Enter a 4 to 32-digit PIN" + }, + { + "name":"password_message_character", + "value":"Set a 4 to 32-character password (including at least 1 letter)" + }, + { + "name":"password_message_repeat", + "value":"Enter the PIN again" + }, + { + "name":"password_set_prompt", + "value":"Try not to forget your password. There is no way to recover it if you do." + }, + { + "name":"password_message_repeat_error", + "value":"PINs do not match, Please try again." + }, + { + "name":"password_item_text_number_4", + "value":"4-digit PIN" + }, + { + "name":"password_item_text_number_6", + "value":"6-digit PIN" + }, + { + "name":"password_item_text_custom", + "value":"Custom PIN" + }, + { + "name":"password_item_text_character", + "value":"Password" + }, + { + "name":"password_disable_prompt", + "value":"Your personal data can be used by anyone who has access to your phone if you disable your lock screen password." + }, + { + "name":"password_message_incorrect", + "value":"Incorrect password. %d attempts remaining." + }, + { + "name":"password_remain_times", + "value":"PLEASE TRY AGAIN AFTER %dS." + }, + { + "name":"password_PIN_6_error", + "value":"PIN must be 6 digits numbers." + }, + { + "name":"password_PIN_check_min_error", + "value":"PIN must be at least 4 digits." + }, + { + "name":"password_PIN_check_max_error", + "value":"PIN must be fewer than 33 digits." + }, + { + "name":"password_check_min_error", + "value":"password must be at least 4 characters." + }, + { + "name":"password_check_max_error", + "value":"password must be fewer than 33 characters." + }, + { + "name":"password_check_char_error", + "value":"Must include at least 1 letter." + }, + { + "name": "biometricsAndPassword", + "value": "Biometrics & Password" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/aboutDevice.json b/product/phone/src/main/resources/rawfile/aboutDevice.json old mode 100755 new mode 100644 similarity index 94% rename from entry/src/main/resources/rawfile/aboutDevice.json rename to product/phone/src/main/resources/rawfile/aboutDevice.json index f936afed..108a601b --- a/entry/src/main/resources/rawfile/aboutDevice.json +++ b/product/phone/src/main/resources/rawfile/aboutDevice.json @@ -1,27 +1,27 @@ -[ - { - "settingAlias": "systemName", - "settingTitle": "", - "settingValue": "OpenHarmony" - }, - { - "settingAlias": "model", - "settingTitle": "", - "settingValue": "" - }, - { - "settingAlias": "companyInfo", - "settingTitle": "", - "settingValue": "" - }, - { - "settingAlias": "deviceId", - "settingTitle": "", - "settingValue": "00000000000000" - }, - { - "settingAlias": "softwareVersion", - "settingTitle": "", - "settingValue": "" - } +[ + { + "settingAlias": "systemName", + "settingTitle": "", + "settingValue": "OpenHarmony" + }, + { + "settingAlias": "model", + "settingTitle": "", + "settingValue": "" + }, + { + "settingAlias": "companyInfo", + "settingTitle": "", + "settingValue": "" + }, + { + "settingAlias": "deviceId", + "settingTitle": "", + "settingValue": "00000000000000" + }, + { + "settingAlias": "softwareVersion", + "settingTitle": "", + "settingValue": "" + } ] \ No newline at end of file diff --git a/product/phone/src/main/resources/rawfile/applicationStorage.json b/product/phone/src/main/resources/rawfile/applicationStorage.json new file mode 100644 index 00000000..10011a4a --- /dev/null +++ b/product/phone/src/main/resources/rawfile/applicationStorage.json @@ -0,0 +1,65 @@ +[ + { + "settingButtonFlag": true, + "settingTitle": "", + "settingSummary": "", + "settingValue": "", + "settingArrow": "", + "settingArrowStyle": "", + "settingAlias": "storageTab" + }, + { + "settingButtonFlag": true, + "settingTitle": "", + "settingSummary": "", + "settingValue": "", + "settingArrow": "", + "settingArrowStyle": "", + "settingAlias": "totalTab" + }, + { + "settingButtonFlag": true, + "settingTitle": "", + "settingSummary": "", + "settingValue": "", + "settingArrow": "", + "settingArrowStyle": "", + "settingAlias": "applyTab" + }, + { + "settingButtonFlag": true, + "settingTitle": "", + "settingSummary": "", + "settingValue": "", + "settingArrow": "", + "settingArrowStyle": "", + "settingAlias": "dataTab" + }, + { + "settingButtonFlag": false, + "settingTitle": "", + "settingSummary": "", + "settingValue": "", + "settingArrow": "", + "settingArrowStyle": "", + "settingAlias": "deleteDataTab" + }, + { + "settingButtonFlag": true, + "settingTitle": "", + "settingSummary": "", + "settingValue": "", + "settingArrow": "", + "settingArrowStyle": "", + "settingAlias": "cacheTab" + }, + { + "settingButtonFlag": false, + "settingTitle": "", + "settingSummary": "", + "settingValue": "", + "settingArrow": "", + "settingArrowStyle": "", + "settingAlias": "clearCacheTab" + } +] \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/brightness.json b/product/phone/src/main/resources/rawfile/brightness.json old mode 100755 new mode 100644 similarity index 94% rename from entry/src/main/resources/rawfile/brightness.json rename to product/phone/src/main/resources/rawfile/brightness.json index d2c18ac9..001c0ac7 --- a/entry/src/main/resources/rawfile/brightness.json +++ b/product/phone/src/main/resources/rawfile/brightness.json @@ -1,10 +1,10 @@ -[ - { - "settingIcon": "", - "settingTitle": "", - "settingAlias": "brightnessMode", - "settingSwitchValue": true, - "settingSwitchModeValue": 1, - "settingValue": "" - } +[ + { + "settingIcon": "", + "settingTitle": "", + "settingAlias": "brightnessMode", + "settingSwitchValue": true, + "settingSwitchModeValue": 1, + "settingValue": "" + } ] \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/dateAndTime.json b/product/phone/src/main/resources/rawfile/dateAndTime.json old mode 100755 new mode 100644 similarity index 95% rename from entry/src/main/resources/rawfile/dateAndTime.json rename to product/phone/src/main/resources/rawfile/dateAndTime.json index 5b16d6cd..db1416ea --- a/entry/src/main/resources/rawfile/dateAndTime.json +++ b/product/phone/src/main/resources/rawfile/dateAndTime.json @@ -1,20 +1,20 @@ -[ - { - "settingIcon": "", - "settingAlias": "date", - "settingItemIsShow": true, - "settingTitle": "", - "settingSummary": "", - "settingValue": "", - "settingArrow": "/res/image/ic_settings_arrow.svg" - }, - { - "settingIcon": "", - "settingAlias": "time", - "settingItemIsShow": true, - "settingTitle": "", - "settingSummary": "", - "settingValue": "", - "settingArrow": "/res/image/ic_settings_arrow.svg" - } +[ + { + "settingIcon": "", + "settingAlias": "date", + "settingItemIsShow": true, + "settingTitle": "", + "settingSummary": "", + "settingValue": "", + "settingArrow": "/res/image/ic_settings_arrow.svg" + }, + { + "settingIcon": "", + "settingAlias": "time", + "settingItemIsShow": true, + "settingTitle": "", + "settingSummary": "", + "settingValue": "", + "settingArrow": "/res/image/ic_settings_arrow.svg" + } ] \ No newline at end of file diff --git a/product/phone/src/main/resources/rawfile/settinglist.json b/product/phone/src/main/resources/rawfile/settinglist.json new file mode 100644 index 00000000..4d08fac9 --- /dev/null +++ b/product/phone/src/main/resources/rawfile/settinglist.json @@ -0,0 +1,119 @@ +[ + { + "settingIcon": "/res/image/ic_settings_wifi.svg", + "settingTitle": "WLAN", + "settingAlias": "wifiTab", + "settingValue": "", + "settingArrow": "/res/image/ic_settings_arrow.svg", + "settingSummary": "", + "settingUri": "pages/wifi" + }, + { + "settingIcon": "/res/image/ic_settings_display.svg", + "settingTitle": "", + "settingAlias": "brightnessTab", + "settingValue": "", + "settingArrow": "/res/image/ic_settings_arrow.svg", + "settingSummary": "", + "settingUri": "pages/brightnessSettings" + }, + { + "settingIcon": "/res/image/ic_settings_password.svg", + "settingTitle": "", + "settingAlias": "biometricsAndPasswordTab", + "settingValue": "", + "settingArrow": "/res/image/ic_settings_arrow.svg", + "settingSummary": "", + "settingUri": "pages/passwordSetting" + }, + { + "settingIcon": "res/image/ic_settings_applications.svg", + "settingTitle": "", + "settingAlias": "applyTab", + "settingValue": "", + "settingArrow": "res/image/ic_settings_arrow.svg", + "settingSummary": "", + "settingUri": "pages/application" + }, + { + "settingIcon": "/res/image/ic_settings_advanced.svg", + "settingTitle": "", + "settingAlias": "dateAndTimeTab", + "settingValue": "", + "settingArrow": "/res/image/ic_settings_arrow.svg", + "settingSummary": "", + "settingUri": "pages/dateAndTime" + }, + { + "settingIcon": "/res/image/ic_settings_about.svg", + "settingTitle": "", + "settingAlias": "aboutTab", + "settingValue": "", + "settingArrow": "/res/image/ic_settings_arrow.svg", + "settingSummary": "", + "settingUri": "pages/aboutDevice" + }, + { + "settingIcon": "/res/image/ic_settings_volume.svg", + "settingTitle": "", + "settingAlias": "volumeControlTab", + "settingValue": "", + "settingArrow": "/res/image/ic_settings_arrow.svg", + "settingSummary": "", + "settingUri": "pages/volumeControl" + }, + { + "settingIcon": "/res/image/ic_settings_about.svg", + "settingTitle": "", + "settingAlias": "developerOptionsTab", + "settingValue": "", + "settingArrow": "/res/image/ic_settings_arrow.svg", + "settingSummary": "", + "settingUri": "pages/developerOptions" + }, + { + "settingIcon": "/res/image/ic_settings_about.svg", + "settingTitle": "", + "settingAlias": "restoreFactoryTab", + "settingValue": "", + "settingArrow": "/res/image/ic_settings_arrow.svg", + "settingSummary": "", + "settingUri": "pages/restoreFactorySettings" + }, + { + "settingIcon": "/res/image/ic_settings_users.svg", + "settingTitle": "", + "settingAlias": "usersAccountsTab", + "settingValue": "", + "settingArrow": "/res/image/ic_settings_arrow.svg", + "settingSummary": "", + "settingUri": "pages/usersAccounts" + }, + { + "settingIcon": "/res/image/ic_settings_about.svg", + "settingTitle": "", + "settingAlias": "systemTab", + "settingValue": "", + "settingArrow": "/res/image/ic_settings_arrow.svg", + "settingSummary": "", + "settingUri": "pages/system/homePage" + }, + { + "settingIcon": "/res/image/ic_settings_storage.svg", + "settingTitle": "", + "settingAlias": "storageTab", + "settingValue": "", + "settingArrow": "/res/image/ic_settings_arrow.svg", + "settingSummary": "", + "settingUri": "pages/storage" + }, + { + "settingIcon": "/res/image/ic_settings_privacy.svg", + "settingTitle": "", + "settingAlias": "privacyTab", + "settingValue": "", + "settingArrow": "/res/image/ic_settings_arrow.svg", + "settingSummary": "", + "settingUri": "pages/privacy" + } +] diff --git a/product/phone/src/main/resources/rawfile/storage.json b/product/phone/src/main/resources/rawfile/storage.json new file mode 100644 index 00000000..686939b5 --- /dev/null +++ b/product/phone/src/main/resources/rawfile/storage.json @@ -0,0 +1,29 @@ +[ + { + "settingIcon": "", + "settingTitle": "", + "settingAlias": "", + "settingValue": "", + "settingArrow": "", + "settingSummary": "", + "settingUri": "" + }, + { + "settingIcon": "", + "settingTitle": "", + "settingAlias": "", + "settingValue": "", + "settingArrow": "", + "settingSummary": "", + "settingUri": "" + }, + { + "settingIcon": "", + "settingTitle": "", + "settingAlias": "", + "settingValue": "", + "settingArrow": "", + "settingSummary": "", + "settingUri": "" + } +] diff --git a/entry/src/main/resources/rawfile/wifi.json b/product/phone/src/main/resources/rawfile/wifi.json old mode 100755 new mode 100644 similarity index 93% rename from entry/src/main/resources/rawfile/wifi.json rename to product/phone/src/main/resources/rawfile/wifi.json index 931c4bfa..a308844c --- a/entry/src/main/resources/rawfile/wifi.json +++ b/product/phone/src/main/resources/rawfile/wifi.json @@ -1,9 +1,9 @@ -[ - { - "settingAlias": "wifi", - "settingIcon": "", - "settingTitle": "", - "settingSummary": "", - "settingArrow": "" - } -] +[ + { + "settingAlias": "wifi", + "settingIcon": "", + "settingTitle": "", + "settingSummary": "", + "settingArrow": "" + } +] diff --git a/product/phone/src/main/resources/zh_CN/element/string.json b/product/phone/src/main/resources/zh_CN/element/string.json new file mode 100644 index 00000000..317fbb43 --- /dev/null +++ b/product/phone/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,664 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "设置" + }, + { + "name": "mainability_description", + "value": "ETS_Empty Feature Ability" + }, + { + "name": "enabled", + "value": "已开启" + }, + { + "name": "disabled", + "value": "已关闭" + }, + { + "name": "disable_", + "value": "关闭" + }, + { + "name": "settings", + "value": "设置" + }, + { + "name": "searchHint", + "value": "搜索设置项" + }, + { + "name": "searchNoResult", + "value": "没有匹配的结果" + }, + { + "name": "wifiTab", + "value": "WLAN" + }, + { + "name": "brightnessTab", + "value": "亮度" + }, + { + "name": "applyTab", + "value": "应用" + }, + { + "name": "dateAndTimeTab", + "value": "日期和时间" + }, + { + "name": "aboutTab", + "value": "关于手机" + }, + { + "name": "volumeControlTab", + "value": "音量调节" + }, + { + "name": "volumeControl", + "value": "音量" + }, + { + "name": "volumeAndVibrationControl", + "value": "声音和振动" + }, + { + "name": "volumeControlRing", + "value": "来电、信息、通知" + }, + { + "name": "volumeControlMedia", + "value": "音乐、视频、游戏" + }, + { + "name": "volumeControlCall", + "value": "通话" + }, + { + "name": "soundMode", + "value": "声音模式" + }, + { + "name": "soundModeSound", + "value": "响铃" + }, + { + "name": "soundModeVibration", + "value": "振动" + }, + { + "name": "soundModeSilent", + "value": "静音" + }, + { + "name": "applicationInfo", + "value": "应用信息" + }, + { + "name": "appManagement", + "value": "应用管理" + }, + { + "name": "cancel", + "value": "取消" + }, + { + "name": "continue_", + "value": "继续" + }, + { + "name": "confirm", + "value": "确定" + }, + { + "name": "ok", + "value": "确定" + }, + { + "name": "next", + "value": "下一步" + }, + { + "name": "clear", + "value": "清空" + }, + { + "name": "wifiPassword", + "value": "密码" + }, + { + "name": "wifiMAC", + "value": "MAC地址" + }, + { + "name": "signalLevel", + "value": "信号强度" + }, + { + "name": "signalBand", + "value": "信号带宽" + }, + { + "name": "encryptMethod", + "value": "加密方式" + }, + { + "name": "disconnect", + "value": "断开连接" + }, + { + "name": "timeMorning", + "value": "上午" + }, + { + "name": "timeAfternoon", + "value": "下午" + }, + { + "name": "settingTime", + "value": "设置时间" + }, + { + "name": "timeFormat", + "value": "24小时制" + }, + { + "name": "timeZone", + "value": "时区" + }, + { + "name": "date", + "value": "日期" + }, + { + "name": "time", + "value": "时间" + }, + { + "name": "year", + "value": "年" + }, + { + "name": "month", + "value": "月" + }, + { + "name": "day", + "value": "日" + }, + { + "name": "tipsContent", + "value": "为提高位置信息的精确度,应用和服务仍然会扫描WLAN网络.您可以在提高精确度中更改此设置" + }, + { + "name": "wifiSynonym", + "value": "网络,上网,连接,www,http" + }, + { + "name": "wifiList", + "value": "可用WLAN列表" + }, + { + "name": "wifiListSynonym", + "value": "wifi,liebiao" + }, + { + "name": "systemName", + "value": "系统名称" + }, + { + "name": "model", + "value": "型号" + }, + { + "name": "companyInfo", + "value": "厂家信息" + }, + { + "name": "deviceId", + "value": "设备" + }, + { + "name": "softwareVersion", + "value": "软件版本" + }, + { + "name": "version", + "value": "版本 " + }, + { + "name": "password", + "value": "密码" + }, + { + "name": "connected", + "value": "已连接" + }, + { + "name": "monday", + "value": "星期一" + }, + { + "name": "tuesday", + "value": "星期二" + }, + { + "name": "wednesday", + "value": "星期三" + }, + { + "name": "thursday", + "value": "星期四" + }, + { + "name": "friday", + "value": "星期五" + }, + { + "name": "saturday", + "value": "星期六" + }, + { + "name": "sunday", + "value": "星期日" + }, + { + "name": "restoreFactoryTab", + "value": "恢复出厂设置" + }, + { + "name": "restoreFactory", + "value": "是否要恢复出厂设置" + }, + { + "name": "developerOptionsTab", + "value": "开发者选项" + }, + { + "name": "usbDebugging", + "value": "USB调试" + }, + { + "name": "usersAccountsTab", + "value": "用户和账号" + }, + { + "name": "user", + "value": "用户" + }, + { + "name": "administrator", + "value": "管理员" + }, + { + "name": "quest", + "value": "访客" + }, + { + "name": "you", + "value": "您" + }, + { + "name": "currentLogin", + "value": "当前登录" + }, + { + "name": "addUser", + "value": "添加用户" + }, + { + "name": "addGuest", + "value": "添加访客" + }, + { + "name": "removeUser", + "value": "删除用户" + }, + { + "name": "addUserImage", + "value": "点击图标更换用户图象" + }, + { + "name": "switchUser", + "value": "切换用户" + }, + { + "name": "askAddGuest", + "value": "是否添加访客?" + }, + { + "name": "addNewUser", + "value": "添加新用户" + }, + { + "name": "addUserDescription", + "value": "新用户添加后,该用户需设置自己的空间。" + }, + { + "name": "askSwitchUser", + "value": "切换到新用户吗?" + }, + { + "name": "switchButton", + "value": "切换" + }, + { + "name": "deleteUserWarn", + "value": "删除该用户并移除所有用户数据?" + }, + { + "name": "deleteButton", + "value": "删除" + }, + { + "name": "takePhoto", + "value": "拍照" + }, + { + "name": "chooseFromShop", + "value": "从图库中选择" + }, + { + "name": "systemTab", + "value": "系统" + }, + { + "name": "languageTab", + "value": "语言" + }, + { + "name": "languageAndRegion", + "value": "语言与地区" + }, + { + "name": "setlanguage", + "value": "语言设置" + }, + { + "name": "editLanguage", + "value": "编辑语言" + }, + { + "name": "addLanguage", + "value": "添加语言" + }, + { + "name": "edit", + "value": "编辑" + }, + { + "name": "delete", + "value": "删除" + }, + { + "name": "region", + "value": "地区" + }, + { + "name": "currentRegion", + "value": "当前地区" + }, + { + "name": "addedLanguage", + "value": "已添加语言" + }, + { + "name": "hasAdded", + "value": "已添加为偏好语言" + }, + { + "name": "allLanguage", + "value": "所有语言" + }, + { + "name": "saveLanguage", + "value": "请保留至少一种语言" + }, + { + "name": "changeLanguage", + "value": "是否将系统语言更改为%s?" + }, + { + "name": "change", + "value": "更改" + }, + { + "name": "keepCurrent", + "value": "保留当前" + }, + { + "name": "selectRegion", + "value": "选取地区" + }, + { + "name": "allRegion", + "value": "所有地区" + }, + { + "name": "faceRecognition", + "value": "人脸识别" + }, + { + "name": "faceauthFailed", + "value": "人脸识别启动失败,请确定该功能是否可用" + }, + { + "name": "privacy", + "value": "隐私" + }, + { + "name": "permissionManager", + "value": "权限管理" + }, + { + "name": "permissionFailed", + "value": "权限管理启动失败,请确定该功能是否可用" + }, + { + "name": "storageTab", + "value": "存储" + }, + { + "name": "totalSpace", + "value": "总空间" + }, + { + "name": "usedSpace", + "value": "已使用空间" + }, + { + "name": "remainingSpace", + "value": "剩余空间信息" + }, + { + "name": "authorityManagement", + "value": "权限管理" + }, + { + "name": "deleteDataTab", + "value": "删除数据" + }, + { + "name": "delete_data_prompt_title", + "value": "是否删除所选应用数据?" + }, + { + "name": "delete_data_prompt", + "value": "应用的全部数据删除后不可恢复,包括所有文件、设置、账户、数据库等。" + }, + { + "name": "clearCacheTab", + "value": "清空缓存" + }, + { + "name": "totalTab", + "value": "总计" + }, + { + "name": "dataTab", + "value": "数据" + }, + { + "name": "cacheTab", + "value": "缓存" + }, + { + "name": "uninstall", + "value": "卸载" + }, + { + "name": "uninstall_prompt", + "value": "是否卸载此应用?" + }, + { + "name": "forcedStop", + "value": "强行停止" + }, + { + "name": "Stop_exception_prompt", + "value": "可能导致异常。是否强行停止该应用?" + }, + { + "name": "privacyTab", + "value": "隐私" + }, + { + "name": "locationServicesTab", + "value": "定位服务" + }, + { + "name": "positionInformation", + "value": "访问我的位置信息" + }, + { + "name": "positionContent", + "value": "“定位服务”基于GNSS、网络信息(WLAN/蜂窝网络/蓝牙/IP)等来提供。启用后,您的位置可能会分享给已授权定位权限的服务。我们可能会从您的设备收集网络信息,以提高定位精度。这些信息无法识别或定位到您个人。您可以在“提高精确度”中进一步选择,以提高定位精度或关闭某些功能。更多信息,请阅读" + }, + { + "name": "statement", + "value": "关于定位服务和隐私的声明。" + }, + { + "name": "biometrics", + "value": "生物识别" + }, + { + "name":"face_recognition", + "value":"人脸识别" + }, + { + "name":"password_lock_screen", + "value":"锁屏密码" + }, + { + "name":"password_change_password", + "value":"更改锁屏密码" + }, + { + "name":"password_disable_password", + "value":"关闭锁屏密码" + }, + { + "name":"password_enter_password", + "value":"输入锁屏密码" + }, + { + "name":"password_change_unlock_method", + "value":"其他密码类型" + }, + { + "name":"password_select_unlock_method", + "value":"其他密码类型" + }, + { + "name":"password_title_number", + "value":"设置锁屏数字密码" + }, + { + "name":"password_title_character", + "value":"设置锁屏密码" + }, + { + "name":"password_message_number_6", + "value":"密码由6位数字组成" + }, + { + "name":"password_message_custom", + "value":"密码由4-32位数字组成" + }, + { + "name":"password_message_character", + "value":"密码由4-32字符字组成,需至少包含1个字母" + }, + { + "name":"password_message_repeat", + "value":"请再次输入密码" + }, + { + "name":"password_set_prompt", + "value":"请牢记您的锁屏密码,忘记后无法找回" + }, + { + "name":"password_message_repeat_error", + "value":"密码不一致,请重新输入" + }, + { + "name":"password_item_text_number_4", + "value":"4位数字密码" + }, + { + "name":"password_item_text_number_6", + "value":"6位数字密码" + }, + { + "name":"password_item_text_custom", + "value":"自定义数字密码" + }, + { + "name":"password_item_text_character", + "value":"混合密码" + }, + { + "name":"password_disable_prompt", + "value":"关闭密码后,任何拿到此设备的人都能够查看您的数据,设备无法收到保护。是否关闭?" + }, + { + "name":"password_message_incorrect", + "value":"密码错误,还可尝试 %d 次" + }, + { + "name":"password_remain_times", + "value":"请 %d秒 后重试" + }, + { + "name":"password_PIN_6_error", + "value":"PIN 应为 6 位数字" + }, + { + "name":"password_PIN_check_min_error", + "value":"PIN 至少应为 4 位" + }, + { + "name":"password_PIN_check_max_error", + "value":"PIN 必须少于 33 位数" + }, + { + "name":"password_check_min_error", + "value":"混合密码必须至少包含 4 个字符" + }, + { + "name":"password_check_max_error", + "value":"密码必须少于 33 个字符" + }, + { + "name":"password_check_char_error", + "value":"请至少包含 1 个字母" + }, + { + "name": "biometricsAndPassword", + "value": "生物识别和密码" + } + ] +} \ No newline at end of file diff --git a/product/wearable/build.gradle b/product/wearable/build.gradle new file mode 100644 index 00000000..db629650 --- /dev/null +++ b/product/wearable/build.gradle @@ -0,0 +1,20 @@ +apply plugin: 'com.huawei.ohos.hap' +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 7 + defaultConfig { + compatibleSdkVersion 4 + } + + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } +} + +dependencies { +} diff --git a/entry/src/main/config.json b/product/wearable/src/main/config.json old mode 100755 new mode 100644 similarity index 81% rename from entry/src/main/config.json rename to product/wearable/src/main/config.json index a5575277..b15d0d72 --- a/entry/src/main/config.json +++ b/product/wearable/src/main/config.json @@ -13,11 +13,11 @@ "name": ".MyApplication", "mainAbility": "com.ohos.settings.MainAbility", "deviceType": [ - "phone" + "wearable" ], "distro": { "deliveryWithInstall": true, - "moduleName": "entry", + "moduleName": "wearable", "moduleType": "entry", "installationFree": true }, @@ -58,15 +58,7 @@ "type": "pageAbility" }, "pages": [ - "pages/settingList", - "pages/dateAndTime", - "pages/applicationInfo", - "pages/brightnessSettings", - "pages/aboutDevice", - "pages/appManagement", - "pages/wifi", - "pages/wifiPsd", - "pages/volumeControl" + "pages/index" ], "name": "default", "window": { diff --git a/product/wearable/src/main/ets/default/app.ets b/product/wearable/src/main/ets/default/app.ets new file mode 100644 index 00000000..8fa46789 --- /dev/null +++ b/product/wearable/src/main/ets/default/app.ets @@ -0,0 +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('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} diff --git a/product/wearable/src/main/ets/default/pages/index.ets b/product/wearable/src/main/ets/default/pages/index.ets new file mode 100644 index 00000000..63827718 --- /dev/null +++ b/product/wearable/src/main/ets/default/pages/index.ets @@ -0,0 +1,24 @@ +/** + * 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. + */ +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/product/wearable/src/main/resources/base/element/string.json b/product/wearable/src/main/resources/base/element/string.json new file mode 100644 index 00000000..c2b4a007 --- /dev/null +++ b/product/wearable/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "设置" + }, + { + "name": "mainability_description", + "value": "ETS_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/product/wearable/src/main/resources/base/media/icon.png b/product/wearable/src/main/resources/base/media/icon.png new file mode 100644 index 00000000..ce307a88 Binary files /dev/null and b/product/wearable/src/main/resources/base/media/icon.png differ diff --git a/settings.gradle b/settings.gradle index 70c6e4e6..1148b567 100755 --- a/settings.gradle +++ b/settings.gradle @@ -13,4 +13,7 @@ * limitations under the License. */ -include ':entry' +include ':phone', ':wearable', 'common:settingsBase', ':common:utils', ':common:component', ':common:search' + +project(':phone').projectDir = new File('./product/phone') +project(':wearable').projectDir = new File('./product/wearable')