diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..23b4224cb89de0ac0030f7b1578ecb335b89b5ae --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 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. + */ + +{ + "app": { + "bundleName": "com.samples.devicemanagementcollection", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true + } +} diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..5e28dc3ae0a364e5bdb0159a282daa742314f135 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "DeviceManagementCollection" + } + ] +} diff --git a/AppScope/resources/base/media/app_icon.png b/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..0210352ae2ade0dd7b4c841cb6e8ba08b4780038 --- /dev/null +++ b/LICENSE @@ -0,0 +1,78 @@ + Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. + + 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. + +Apache License, Version 2.0 +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: +1.You must give any other recipients of the Work or Derivative Works a copy of this License; and +2.You must cause any modified files to carry prominent notices stating that You changed the files; and +3.You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +4.If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 53302a24b1304bcd817d55b0358e10f50c4b718a..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# DeviceManagementCollection - -#### Description -{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md index 3779e654067a9dbed80839b3be5e06df3b104f70..dfb5b417385d0df90a6b63b1736850181d6a3b07 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,131 @@ -# DeviceManagementCollection +# 设备管理合集(非系统特性) -#### 介绍 -{**以下是 Gitee 平台说明,您可以替换此简介** -Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} +### 介绍 -#### 软件架构 -软件架构说明 +本示例集合设备管理相关(非系统特性)不需要复杂功能展示的模块,展示了各个模块的基础功能,包含: +- @ohos.batteryInfo (电量信息) +- @ohos.runningLock (Runninglock锁) +- @ohos.power (系统电源管理) +- @ohos.settings (设置数据项名称) +- @ohos.thermal (热管理) +- @ohos.usbManager (USB管理) -#### 安装教程 +### 效果预览 -1. xxxx -2. xxxx -3. xxxx +| **主页** | **电量信息** | **RunningLock锁** | **系统电源管理** | +|:------------------------------------------:|:------------------------------------------:|:---------------------------------------------------:|:--------------------------------------:| +| ![home](screenshots/devices/home.png) | ![battery](screenshots/devices/battery.png) | ![runninglock](screenshots/devices/runninglock.png) | ![power](screenshots/devices/power.png) | +| **设置数据项名称** | **热管理** | **USB管理** | +| ![settings](screenshots/devices/settings.png) | ![thermal](screenshots/devices/thermal.png) | ![usb](screenshots/devices/usb.png) | -#### 使用说明 +使用说明 -1. xxxx -2. xxxx -3. xxxx +1.首页展示语言基础类库各个子模块菜单,点击进入对应的模块页面。 -#### 参与贡献 +2.各个子模块界面中点击功能按钮完成各个功能。 -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request +3.电量信息:进入电量信息页面,展示设备电量相关信息。 +4.RunningLock锁:点击按钮实现设备支持的休眠锁类型。 -#### 特技 +5.系统电源管理:点击按钮分别实现获取亮灭屏状态、获取电源模式功能。 -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +6.设置数据项名称:点击按钮分别实现获取数据项uri。 + +7.热管理:进入热管理页面,展示当前设备热档位信息、设备过热时提示用户。 + +8.USB管理:打开监听开关后插入USB设备,会有提示并刷新设备列表,关闭监听后清空列表,再次插入USB设备不会提示和自动刷新,下拉设备列表可以手动刷新设备列表。 + +### 工程目录 + +``` + +├──common/src/main/ets/ // 公共组件及工具类 +│ ├──components +│ │ └──CustomDataSource.ets // 自定义DataSource,LazyForEach时使用 +│ └──util +│ ├──Logger.ets // 日志工具类 +│ └──ResourceUtil.ets // 资源管理工具类 +├──common/src/main/resource // 应用静态资源目录 +│ +├──entry/src/main/ets/ // 代码区 +│ ├──entryability +│ │ └──EntryAbility.ts // 程序入口类 +│ └──pages +│ ├──components +│ │ └──Capabilities.ets // 根据点击的菜单,展示对应的子界面 +│ └──Index.ets // 主页入口 +├──entry/src/main/resources // 应用静态资源目录 +│ +└──feature + ├──capabilities/src/main/ets/ // 功能集 + │ ├──capabilities // 各个子模块功能组件 + │ │ ├──BatteryInfo.ets // 电量信息 + │ │ ├──PowerManager.ets // 系统电源管理 + │ │ ├──RunningLockManager.ets // RunningLock锁 + │ │ ├──SettingsManager.ets // 设置数据项名称 + │ │ ├──Thermal.ets // 热管理 + │ │ └──UsbManager.ets // USB管理 + │ ├──components // 子模块相关组件 + │ │ ├──usbmanager // usbmanager相关组件 + │ │ │ ├──DeviceCustomDialog.ets + │ │ │ └──DeviceList.ets + │ │ ├──ColumnOperation.ets // 展示一列功能按钮的组件 + │ │ ├──InfoItemView.ets + │ │ └──RadiusColumn.ets // 白色圆角的自定义Columm组件 + │ ├──model // 相关数据模型 + │ │ ├──DeviceAttribute.ts + │ │ └──ListModel.ets + │ └──utils // 相关工具类 + │ ├──AlertDialogUtil.ets + │ ├──BatteryUtil.ets + │ ├──CheckEmptyUtils.ets + │ ├──PowerManagerUtil.ets + │ ├──ThermalUtil.ets + │ └──UsbManagerUtil.ets + ├──capabilities/src/main/resources // 应用静态资源目录 + │ + ├──menuitems/src/main/ets/ // 菜单 + │ ├──components // 菜单相关自定义组件 + │ │ ├──ItemGroup.ets + │ │ ├──MainItem.ets + │ │ └──MenuNavRouter.ets + │ └──menulist + │ └──MenuList.ets // 菜单组件 + └──menuitems/src/main/resources // 应用静态资源目录 +``` + +### 具体实现 + +1.首页菜单展示:使用一个module,menuitems完成菜单组件的实现,传入要展示的菜单的strarray类型的资源和菜单点击对应的组件即可。使用Navigation和NavRouter组件实现菜单点击进入功能界面,使用LocalStorage实现应用内Ability内数据共享,点击菜单时标记selectedLabel,在entry中的Capabilities组件中,通过selectedLabel显示对应的功能组件。 + +2.电量信息:使用@ohos.batteryInfo接口获取电池和充放电状态信息。 + +3.RunningLock锁:使用@ohos.runningLock实现对Runninglock锁的创建、查询等操作。 + +4.系统电源管理:使用@ohos.power实现获取亮灭屏状态、查询电源模式功能。 + +5.设置数据项名称:使用@ohos.settings实现获取获取数据项uri。 + +6.热管理:使用@ohos.thermal提供热管理相关的接口,查询热档位以及注册温控等级回调。 + +7.USB管理:使用@ohos.usbManager实现usb设备列表的获取,使用@ohos.commonEventManager订阅USB设备插入和拔出监听。 + +### 相关权限 + +1.允许应用获取运行锁权限:ohos.permission.RUNNING_LOCK + +### 依赖 + +不涉及。 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:华为手机。 + +2.HarmonyOS系统:HarmonyOS NEXT Developer Beta1及以上。 + +3.DevEco Studio版本:DevEco Studio NEXT Developer Beta1及以上。 + +4.HarmonyOS SDK版本:HarmonyOS NEXT Developer Beta1 SDK及以上。 \ No newline at end of file diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8a1ed641aad25106ee94a8a763b0bd43859f87e8 --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,39 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "menuitems", + "srcPath": "./feature/menuitems" + }, + { + "name": "capabilities", + "srcPath": "./feature/capabilities" + }, + { + "name": "common", + "srcPath": "./common" + } + ] +} \ No newline at end of file diff --git a/common/Index.ets b/common/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..5443b7acfbc7a8fdfb7130a7ef2d7f727973a255 --- /dev/null +++ b/common/Index.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2023 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 { logger } from './src/main/ets/util/Logger'; + +export { CustomDataSource } from './src/main/ets/components/CustomDataSource'; + +export { getString, getStringArray } from './src/main/ets/util/ResourceUtil'; \ No newline at end of file diff --git a/common/build-profile.json5 b/common/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..431999870d30f72c7c6e728d63eb40d9b271f976 --- /dev/null +++ b/common/build-profile.json5 @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2023 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. + */ + +{ + "apiType": "stageMode", + "buildOption": { + } +} diff --git a/common/hvigorfile.ts b/common/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..9c3992ac05f1a4b3c5c93a44388308fd1dc45aa8 --- /dev/null +++ b/common/hvigorfile.ts @@ -0,0 +1,17 @@ +/** + * Copyright (c) 2023 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. + */ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +module.exports = require('@ohos/hvigor-ohos-plugin').harTasks + diff --git a/common/oh-package.json5 b/common/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..accbc2f9733ce9467c2c29a094aa99cf692bce3c --- /dev/null +++ b/common/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "license": "ISC", + "types": "", + "devDependencies": {}, + "name": "@ohos/common", + "description": "a npm package which contains arkUI2.0 page", + "main": "Index.ets", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/common/src/main/ets/components/CustomDataSource.ets b/common/src/main/ets/components/CustomDataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..cc37523a0e5e75e32e47937dc3b6eec3b4139e9c --- /dev/null +++ b/common/src/main/ets/components/CustomDataSource.ets @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2023 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. + */ + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } +} + +export class CustomDataSource extends BasicDataSource { + public dataArray: string[] = []; + + constructor(ele: Array) { + super() + for (let index = 0; index < ele.length; index++) { + this.dataArray.push(ele[index]); + } + } + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0); + this.notifyDataAdd(index); + } +} \ No newline at end of file diff --git a/common/src/main/ets/util/Logger.ets b/common/src/main/ets/util/Logger.ets new file mode 100644 index 0000000000000000000000000000000000000000..4fb9f4e6d2e06c1148174711183ff15cafc184a1 --- /dev/null +++ b/common/src/main/ets/util/Logger.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: string[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: string[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: string[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: string[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + +export const logger = new Logger('Sample_DeviceManagement') \ No newline at end of file diff --git a/common/src/main/ets/util/ResourceUtil.ets b/common/src/main/ets/util/ResourceUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..1f32e6e569624975680cbf3822eb4b6a98943bf1 --- /dev/null +++ b/common/src/main/ets/util/ResourceUtil.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { common } from '@kit.AbilityKit'; + +export async function getStringArray(resource: Resource): Promise> { + let context = getContext() as common.UIAbilityContext; + let menuList: Array = await context.resourceManager.getStringArrayValue(resource); + return menuList; +} + +export function getString(resource: Resource): string { + let context = getContext() as common.UIAbilityContext; + return context.resourceManager.getStringSync(resource); +} diff --git a/common/src/main/module.json5 b/common/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a6dbb7681358d6fad5742e7b2c42dbe0a831fb47 --- /dev/null +++ b/common/src/main/module.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 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. + */ + +{ + "module": { + "name": "common", + "type": "har", + "deviceTypes": [ + "phone", + "tablet" + ] + } +} diff --git a/common/src/main/resources/base/element/color.json b/common/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..2de6679edfc567d5d41f6b7976b85eeec93a02ec --- /dev/null +++ b/common/src/main/resources/base/element/color.json @@ -0,0 +1,32 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFF" + }, + { + "name": "black", + "value": "#000" + }, + { + "name": "list_background", + "value": "#F1F3F5" + }, + { + "name": "list_title", + "value": "#1A1A1A" + }, + { + "name": "list_content", + "value": "#666" + }, + { + "name": "list_sub_content", + "value": "#999" + }, + { + "name": "divider", + "value": "#f1f1f1" + } + ] +} \ No newline at end of file diff --git a/common/src/main/resources/base/element/string.json b/common/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1e76de0c66777cfe83568615c5c2e68c61d23fed --- /dev/null +++ b/common/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + } + ] +} diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..88af87e8b017a66588612c6e988372fbf1039313 --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 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. + */ + +{ + "apiType": 'stageMode', + "buildOption": { +// "compileMode": "esmodule" + }, + "targets": [ + { + "name": "default", + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/entry/hvigorfile.ts b/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..27a66d9a3cbadf06e3a3857221a0a1b7c1087e89 --- /dev/null +++ b/entry/hvigorfile.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2023 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. + */ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { hapTasks } from '@ohos/hvigor-ohos-plugin'; diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..fab6d8f60b69e40b967579115c79e7efa4ef0e2f --- /dev/null +++ b/entry/oh-package.json5 @@ -0,0 +1,13 @@ +{ + "license": "ISC", + "devDependencies": {}, + "name": "entry", + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": { + "@ohos/capabilities": "file:../feature/capabilities", + "@ohos/menuitems": "../feature/menuitems", + "@ohos/common": "../common" + } +} diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd7b81e0629c6977b51da91b81c5b02854072be8 --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2023 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 { UIAbility,AbilityConstant,Want } from '@kit.AbilityKit'; +import { window,display } from '@kit.ArkUI'; +import { logger } from '@ohos/common'; + +const BREAKPOINT_MD: number = 600; +const BREAKPOINT_BIG: number = 840; +const PARAMS_PX_TO_VP: number = 160; +const TAG: string = 'EntryAbility'; + +export default class EntryAbility extends UIAbility { + windowSizeChangeCallback: Function | undefined = undefined; + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + logger.info(TAG, 'Ability onCreate'); + AppStorage.setOrCreate('selectedLabel', ''); + } + + updateBreakpoint(windowWidth: number): void { + let windowWidthVp: number = windowWidth / (display.getDefaultDisplaySync().densityDPI / PARAMS_PX_TO_VP); + let curBp: string; + if (windowWidthVp < BREAKPOINT_MD) { + curBp = 'sm'; + } else if (windowWidthVp < BREAKPOINT_BIG) { + curBp = 'md'; + } else { + curBp = 'lg'; + } + logger.info(TAG, 'window width: ' + windowWidth + ', window width vp: ' + windowWidthVp + ', breakpoint: ' + curBp); + AppStorage.setOrCreate('currentBreakpoint', curBp); + AppStorage.setOrCreate('windowWidth', windowWidthVp); + AppStorage.setOrCreate('isSplitMode', curBp === 'sm' ? false : true); + } + + onDestroy(): void { + logger.info(TAG, 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + logger.info(TAG, 'Ability onWindowStageCreate'); + + windowStage.getMainWindow().then((windowObj: window.Window) => { + let windowWidth: number = windowObj.getWindowProperties().windowRect.width; + this.updateBreakpoint(windowWidth); + windowObj.on('windowSizeChange', this.windowSizeChangeCallback = (newSize: window.Size) => { + let windowWidth: number = newSize.width; + this.updateBreakpoint(windowWidth); + + if (windowObj.getWindowProperties().isFullScreen) { + logger.info(TAG, 'isFullScreen'); + } + if (windowObj.getWindowProperties().isLayoutFullScreen) { + logger.info(TAG, 'isLayoutFullScreen'); + } + }); + }); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + logger.error(TAG, `Failed to load the content. Cause: ${JSON.stringify(err)}`); + return; + } + logger.info(TAG, `Succeeded in loading the content. Data: ${JSON.stringify(data)}`); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + logger.info(TAG, 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + logger.info(TAG, 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + logger.info(TAG, 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..d0fab3ddccca259f2490e34fd2f4c3e133743a31 --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023 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 { Capabilities } from './components/Capabilities'; +import { MenuList } from '@ohos/menuitems'; + +@Entry +@Component +struct Index { + @StorageProp('windowWidth') windowWidth: number = 300; + @StorageProp('isSplitMode') isSplitMode: boolean = false; + @State title: string = ''; + + aboutToAppear() { + this.title = getContext().resourceManager.getStringSync($r('app.string.device_management').id); + } + + build() { + Navigation() { + Column() { + MenuList({ menuList: $r('app.strarray.device_management_list') }) { + Capabilities() + } + } + .padding(16) + } + .title(this.CustomTitle()) + .mode(this.isSplitMode ? NavigationMode.Split : NavigationMode.Stack) + .navBarWidth(0.4 * this.windowWidth) + .titleMode(NavigationTitleMode.Full) + .hideToolBar(true) + .width('100%') + .height('100%') + .backgroundColor($r("app.color.list_background")) + } + + @Builder + CustomTitle() { + Row() { + Text(this.title) + .fontColor($r("app.color.list_title")) + .fontSize(26) + .fontWeight(FontWeight.Medium) + .padding({left: 16}) + .margin({bottom: 10}) + } + .width('100%') + .height('100%') + .alignItems(VerticalAlign.Bottom) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/components/Capabilities.ets b/entry/src/main/ets/pages/components/Capabilities.ets new file mode 100644 index 0000000000000000000000000000000000000000..25a0eaf90e2c87fe7a27a08d39df36f889824637 --- /dev/null +++ b/entry/src/main/ets/pages/components/Capabilities.ets @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2023 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 { getString } from '@ohos/common'; +import { + BatteryInfo, + RunningLockManager, + PowerManager, + SettingsManager, + Thermal, + UsbManager +} from '@ohos/capabilities'; + +@Component +export struct Capabilities { + @StorageLink('selectedLabel') selectedLabel: string = ''; + @State label: string = ''; + + aboutToAppear() { + // StorageLink会触发多次刷新,用State接收 + this.label = this.selectedLabel; + } + + build() { + Column() { + // 此处根据选中的菜单,显示对应的页面内容 + if (this.label === getString($r('app.string.battery_info'))) { + BatteryInfo() + } else if (this.label === getString($r('app.string.running_lock'))) { + RunningLockManager() + } else if (this.label === getString($r('app.string.power_manager'))) { + PowerManager() + } else if (this.label === getString($r('app.string.settings'))) { + SettingsManager() + } else if (this.label === getString($r('app.string.thermal'))) { + Thermal() + } else if (this.label === getString($r('app.string.usb_manager'))) { + UsbManager() + } + } + .padding({ left: 12, right: 12 }) + } +} \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3a072ddda86c6c21e60dc37878bcd75979e0d492 --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 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. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:device_management", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.RUNNING_LOCK" + } + ] + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/strarray.json b/entry/src/main/resources/base/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..51cfbedee3ef5ccfcc18e86781b0d9dcddd0daa6 --- /dev/null +++ b/entry/src/main/resources/base/element/strarray.json @@ -0,0 +1,27 @@ +{ + "strarray": [ + { + "name": "device_management_list", + "value": [ + { + "value": "Battery Information" + }, + { + "value": "Runninglock" + }, + { + "value": "System Power Management" + }, + { + "value": "Data Item Settings" + }, + { + "value": "Thermal Management" + }, + { + "value": "USB Management" + } + ] + } + ] +} \ 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 new file mode 100644 index 0000000000000000000000000000000000000000..e09bfe9b43d124f7c170b6f069add5136d25e0f6 --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,40 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "device_management", + "value": "Device Management" + }, + { + "name": "battery_info", + "value": "Battery Information" + }, + { + "name": "running_lock", + "value": "Runninglock" + }, + { + "name": "thermal", + "value": "Thermal Management" + }, + { + "name": "usb_manager", + "value": "USB Management" + }, + { + "name": "power_manager", + "value": "System Power Management" + }, + { + "name": "settings", + "value": "Data Item Settings" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/entry/src/main/resources/base/media/icon.png differ diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..55c3f007f87b7ce5206d325f968cc56f2f79441f --- /dev/null +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/strarray.json b/entry/src/main/resources/en_US/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..51cfbedee3ef5ccfcc18e86781b0d9dcddd0daa6 --- /dev/null +++ b/entry/src/main/resources/en_US/element/strarray.json @@ -0,0 +1,27 @@ +{ + "strarray": [ + { + "name": "device_management_list", + "value": [ + { + "value": "Battery Information" + }, + { + "value": "Runninglock" + }, + { + "value": "System Power Management" + }, + { + "value": "Data Item Settings" + }, + { + "value": "Thermal Management" + }, + { + "value": "USB Management" + } + ] + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..42dcd64469159fbbef46a20881db086d709fe862 --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,40 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "device_management", + "value": "Device Management" + }, + { + "name": "battery_info", + "value": "Battery Information" + }, + { + "name": "thermal", + "value": "Thermal Management" + }, + { + "name": "usb_manager", + "value": "USB Management" + }, + { + "name": "power_manager", + "value": "System Power Management" + }, + { + "name": "running_lock", + "value": "Runninglock" + }, + { + "name": "settings", + "value": "Data Item Settings" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/strarray.json b/entry/src/main/resources/zh_CN/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..57f210b802d2bf0570292c4bff782045be1dec59 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/strarray.json @@ -0,0 +1,27 @@ +{ + "strarray": [ + { + "name": "device_management_list", + "value": [ + { + "value": "电量信息" + }, + { + "value": "RunningLock锁" + }, + { + "value": "系统电源管理" + }, + { + "value": "设置数据项名称" + }, + { + "value": "热管理" + }, + { + "value": "USB管理" + } + ] + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d6a9cfef217142050f97fb017ed2e47fda47c5a9 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,40 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "device_management", + "value": "设备管理" + }, + { + "name": "battery_info", + "value": "电量信息" + }, + { + "name": "thermal", + "value": "热管理" + }, + { + "name": "usb_manager", + "value": "USB管理" + }, + { + "name": "power_manager", + "value": "系统电源管理" + }, + { + "name": "running_lock", + "value": "RunningLock锁" + }, + { + "name": "settings", + "value": "设置数据项名称" + } + ] +} \ No newline at end of file diff --git a/feature/capabilities/build-profile.json5 b/feature/capabilities/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..12fe2d844bdb69584fd05ebaa3e1cb197a25c3f1 --- /dev/null +++ b/feature/capabilities/build-profile.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 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. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "targets": [ + { + "name": "default" + } + ] +} diff --git a/feature/capabilities/hvigorfile.ts b/feature/capabilities/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6522df25794b80abde0b0aa8654f3970c4a35cfa --- /dev/null +++ b/feature/capabilities/hvigorfile.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2023 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. + */ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { harTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/feature/capabilities/index.ets b/feature/capabilities/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..3e87c38e0ebf914c268fbe988d78eca66347b108 --- /dev/null +++ b/feature/capabilities/index.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 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 { UsbManager } from './src/main/ets/capabilities/UsbManager'; + +export { PowerManager } from './src/main/ets/capabilities/PowerManager'; + +export { BatteryInfo } from './src/main/ets/capabilities/BatteryInfo'; + +export { Thermal } from './src/main/ets/capabilities/Thermal'; + +export { RunningLockManager } from './src/main/ets/capabilities/RunningLockManager'; + +export { SettingsManager } from './src/main/ets/capabilities/SettingsManager'; \ No newline at end of file diff --git a/feature/capabilities/oh-package.json5 b/feature/capabilities/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9969e0e44cf31c21c9f837bdb35e37d491284cfb --- /dev/null +++ b/feature/capabilities/oh-package.json5 @@ -0,0 +1,12 @@ +{ + "license": "ISC", + "types": "", + "devDependencies": {}, + "name": "@ohos/capabilities", + "description": "a npm package which contains arkUI2.0 page", + "main": "index.ets", + "version": "1.0.0", + "dependencies": { + "@ohos/common": "file:../../common" + } +} diff --git a/feature/capabilities/src/main/ets/capabilities/BatteryInfo.ets b/feature/capabilities/src/main/ets/capabilities/BatteryInfo.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd44e115b33ab174961cca2f018a4416b00591cc --- /dev/null +++ b/feature/capabilities/src/main/ets/capabilities/BatteryInfo.ets @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2023 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 { ListModel } from '../model/ListModel'; +import { BatteryUtil } from '../util/BatteryUtil'; + +@Extend(Text) function fancy() { + .height(50) + .fontSize(16) + .fontWeight(500) +} + +@Component +export struct BatteryInfo { + @State table: ListModel[] = [ + new ListModel('Battery SOC', BatteryUtil.batterySOC), + new ListModel('Charging Status', BatteryUtil.chargingStatus), + new ListModel('Health Status', BatteryUtil.healthStatus), + new ListModel('Plugged Type', BatteryUtil.pluggedType), + new ListModel('Voltage', BatteryUtil.voltage), + new ListModel('Technology', BatteryUtil.technology), + new ListModel('Battery Temperature', BatteryUtil.batteryTemperature), + new ListModel('Battery Present', BatteryUtil.isBatteryPresent), + new ListModel('Battery Capacity Level', BatteryUtil.batteryCapacityLevel) + ]; + + build() { + List() { + ForEach(this.table, (item: ListModel) => { + ListItem() { + Row() { + Text(item.title) + .textAlign(TextAlign.Start) + .fontSize(20) + .fontWeight(FontWeight.Medium) + .fontColor($r("app.color.list_title")) + Blank() + Text(item.getValue()) + .textAlign(TextAlign.End) + .fontSize(18) + .fontWeight(FontWeight.Regular) + .fontColor($r("app.color.list_sub_content")) + } + .padding({ + left: 16, + right: 16 + }) + .height(62) + .width('100%') + } + }) + } + .divider({ + strokeWidth: px2vp(1), + color: $r("app.color.divider"), + startMargin: 16, + endMargin: 16 + }) + .margin({ + top: 16, + bottom: 16, + left: 4, + right: 4 + }) + .width('100%') + .backgroundColor($r("app.color.white")) + .borderRadius(20) + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/capabilities/PowerManager.ets b/feature/capabilities/src/main/ets/capabilities/PowerManager.ets new file mode 100644 index 0000000000000000000000000000000000000000..6b737caa9b5ad891da2ba5326b6922842cb7e920 --- /dev/null +++ b/feature/capabilities/src/main/ets/capabilities/PowerManager.ets @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2023 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 { ColumnOperation } from '../components/ColumnOperation'; +import { getString } from '@ohos/common'; +import { PowerManagerUtil } from '../util/PowerManagerUtil'; + +@Component +export struct PowerManager { + @State result: string = ''; + + build() { + Scroll() { + Column() { + Row() { + Text(this.result) + .fontWeight(FontWeight.Medium) + .fontSize(20) + } + .alignItems(VerticalAlign.Top) + .width('100%') + .backgroundColor($r("app.color.white")) + .height(160) + .padding(16) + .borderRadius(20) + .margin({ top: 16 }) + ColumnOperation({ operationRes: $r('app.strarray.power_operations'), doOperation: this.doOperation }) + } + .width('100%') + .padding(4) + } + .scrollBar(BarState.Off) + } + + doOperation = async (index: number) => { + switch (index) { + case 0: + try { + let isActive = PowerManagerUtil.isActive(); + this.result = `${getString($r('app.string.screen_state'))}${isActive}`; + } catch (err) { + this.result = `isActive fail:${err}`; + } + break; + case 1: + try { + let modeName = await PowerManagerUtil.getPowerModeName(); + this.result = `${getString($r('app.string.power_mode'))}${modeName}`; + } catch (err) { + this.result = `getPowerModeName fail:${err}`; + } + break; + default: + break; + } + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/capabilities/RunningLockManager.ets b/feature/capabilities/src/main/ets/capabilities/RunningLockManager.ets new file mode 100644 index 0000000000000000000000000000000000000000..0be7dc08d7cd25f766d0394b199d423bc80cbf5f --- /dev/null +++ b/feature/capabilities/src/main/ets/capabilities/RunningLockManager.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 { runningLock } from '@kit.BasicServicesKit'; +import { ColumnOperation } from '../components/ColumnOperation'; +import { getString } from '@ohos/common'; + +@Component +export struct RunningLockManager { + @State result: string = ''; + private timeoutID: number = 0; + + aboutToDisappear() { + if (this.timeoutID) { + clearTimeout(this.timeoutID); + } + } + + build() { + Scroll() { + Column() { + Row() { + Text(this.result) + .fontWeight(FontWeight.Medium) + .fontSize(20) + } + .alignItems(VerticalAlign.Top) + .width('100%') + .backgroundColor($r("app.color.white")) + .height(160) + .padding(16) + .borderRadius(20) + .margin({ top: 16 }) + ColumnOperation({ operationRes: $r('app.strarray.running_lock_operations'), doOperation: this.doOperation }) + } + .width('100%') + .padding(4) + } + .scrollBar(BarState.Off) + } + + doOperation = async (index: number) => { + switch (index) { + case 0: + let res1 = runningLock.isSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL); + this.result = `${getString($r('app.string.running_lock_proximity_screen_control'))}${res1}`; + break; + default: + break; + } + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/capabilities/SettingsManager.ets b/feature/capabilities/src/main/ets/capabilities/SettingsManager.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac4dbe11db957cd4f5f162fd2605ed92aa01c50a --- /dev/null +++ b/feature/capabilities/src/main/ets/capabilities/SettingsManager.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 { settings } from '@kit.BasicServicesKit'; +import { ColumnOperation } from '../components/ColumnOperation'; + +@Component +export struct SettingsManager { + @State result: string = ''; + private enableAirplane: boolean = false; + + build() { + Scroll() { + Column() { + Row() { + Text(this.result) + .fontWeight(FontWeight.Medium) + .fontSize(20) + } + .alignItems(VerticalAlign.Top) + .width('100%') + .backgroundColor($r("app.color.white")) + .height(160) + .padding(16) + .borderRadius(20) + .margin({ top: 16 }) + ColumnOperation({ operationRes: $r('app.strarray.settings_operations'), doOperation: this.doOperation }) + } + .width('100%') + .padding(4) + } + .scrollBar(BarState.Off) + } + + doOperation = async (index: number) => { + switch (index) { + case 0: + let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); + this.result = `${uri}`; + break; + default: + break; + } + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/capabilities/Thermal.ets b/feature/capabilities/src/main/ets/capabilities/Thermal.ets new file mode 100644 index 0000000000000000000000000000000000000000..673d9a4dde9067652471f34c9539d6bc74e47cce --- /dev/null +++ b/feature/capabilities/src/main/ets/capabilities/Thermal.ets @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2023 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 { BusinessError, systemDateTime } from '@kit.BasicServicesKit'; +import { thermal } from '@kit.BasicServicesKit'; +import { logger } from '@ohos/common/Index'; +import { promptAction } from '@kit.ArkUI'; +import { ListModel } from '../model/ListModel'; +import { ThermalUtil } from '../util/ThermalUtil'; + +@Extend(Text) +function fancy() { + .height(50) + .fontSize(16) + .fontWeight(500) +} + +@Component +export struct Thermal { + @State table: ListModel[] = [ + new ListModel('Thermal level', ThermalUtil.getLevel), + new ListModel('Callback level', undefined), + new ListModel('Last callback time', undefined) + ]; + + aboutToAppear() { + this.initThermal(); + } + + aboutToDisappear() { + ThermalUtil.unregisterThermalLevelCallback(); + } + + build() { + List() { + ForEach(this.table, (item: ListModel) => { + ListItem() { + Row() { + Text(item.title) + .fontSize(20) + .fontWeight(FontWeight.Medium) + .fontColor($r("app.color.list_title")) + .textAlign(TextAlign.Start) + Blank() + Text(item.getValue()) + .fontSize(18) + .fontWeight(FontWeight.Medium) + .fontColor($r("app.color.list_sub_content")) + .textAlign(TextAlign.End) + } + .padding({ left: 16, right: 16 }) + .height(62) + .width('100%') + } + }) + } + .divider({ + strokeWidth: px2vp(1), + color: $r("app.color.divider"), + startMargin: 16, + endMargin: 16 + }) + .borderRadius(20) + .backgroundColor($r("app.color.white")) + .margin({ + top: 16, + bottom: 16, + left: 4, + right: 4 + }) + .width('100%') + } + + initThermal() { + const INDEX_0 = 0; + const INDEX_1 = 1; + ThermalUtil.registerThermalLevelCallback((level: number) => { + this.table[INDEX_0] = new ListModel('Thermal level', undefined, ThermalUtil.getLevel()); + this.table[INDEX_1] = new ListModel('Callback level', undefined, ThermalUtil.getStrLevel(level)); + this.getCurrentTime(); + if (level === thermal.ThermalLevel.WARNING) { + try { + promptAction.showToast({ + message: $r('app.string.thermal_warning'), + duration: 2000, + }); + } catch (error) { + logger.error(`showToast args error code is ${error?.code}, message is ${error?.message}`); + } + } + }) + } + + getCurrentTime() { + const INDEX_2 = 2; + try { + this.table[INDEX_2] = + new ListModel('Last callback time', undefined, ThermalUtil.timestampToTime(systemDateTime.getTime(false))); + } catch (e) { + let error = e as BusinessError; + logger.info(`Failed to get time. message: ${error.message}, code: ${error.code}`); + } + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/capabilities/UsbManager.ets b/feature/capabilities/src/main/ets/capabilities/UsbManager.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ad4bc6a1cc1c4d29dd7edbbda5746ac7e7c030e --- /dev/null +++ b/feature/capabilities/src/main/ets/capabilities/UsbManager.ets @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2023 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 { DeviceAttribute } from '../model/DeviceAttribute'; +import { DeviceCustomDialog } from '../components/usbmanager/DeviceCustomDialog'; +import { DeviceList } from '../components/usbmanager/DeviceList'; +import { createUsbSubscribe, cancelUsbSubscribe, getDeviceList } from '../util/UsbManagerUtil'; + +@Component +export struct UsbManager { + @State isListener: boolean = false; + @State isRefreshing: boolean = false; + @Provide('devicesList') devices: Array = []; + @State device: DeviceAttribute = new DeviceAttribute(); + private dialogController: CustomDialogController = new CustomDialogController({ + builder: DeviceCustomDialog({ device: this.device }), + autoCancel: true, + cancel: () => {} + }); + + build() { + Column({ space: 12 }) { + Row() { + Text($r('app.string.usb_listener')) + .fontSize(20) + .fontWeight(FontWeight.Medium) + Blank() + Toggle({ type: ToggleType.Switch, isOn: this.isListener }) + .onChange((isOn: boolean) => { + this.isListener = !this.isListener + this.listenerSwitch(this.isListener) + }) + } + .backgroundColor($r("app.color.white")) + .borderRadius(20) + .padding({ left: 16, right: 16 }) + .width('100%') + .height(60) + + + DeviceList({ + isRefreshing: $isRefreshing, + device: $device, + getDeviceList: () => { + this.devices = getDeviceList(); + }, + openDialog: () => { + this.dialogController.open(); + } + }) + } + .width('100%') + .height('100%') + .padding(16) + } + + @Builder + SingleAttribute(title: Resource, info: string) { + Row() { + Text(title) + .fontSize(20) + .width('100') + .fontWeight(FontWeight.Bold) + + Text(info) + .fontSize(20) + .layoutWeight(1) + .textAlign(TextAlign.Start) + } + .margin({ top: 10 }) + .alignSelf(ItemAlign.Start) + } + + listenerSwitch(isListener: boolean) { + if (isListener) { + this.devices = getDeviceList(); + createUsbSubscribe(() => { + this.devices = getDeviceList(); + }) + } else { + cancelUsbSubscribe(); + this.devices = []; + } + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/components/ColumnOperation.ets b/feature/capabilities/src/main/ets/components/ColumnOperation.ets new file mode 100644 index 0000000000000000000000000000000000000000..67c7bf9843e7ee1d114cde16043013f892cd9382 --- /dev/null +++ b/feature/capabilities/src/main/ets/components/ColumnOperation.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2023 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 { CustomDataSource, getStringArray } from '@ohos/common'; + +@Component +export struct ColumnOperation { + private operationRes?: Resource = undefined; + private operationSource: CustomDataSource = new CustomDataSource([]); + private doOperation: (index: number) => void = () => { + }; + + build() { + List() { + LazyForEach(this.operationSource, (item: string, index: number) => { + ListItem(){ + Row() { + Button() { + Text(item) + .fontSize(20) + .fontWeight(FontWeight.Medium) + .fontColor($r("app.color.list_title")) + .width('100%') + .padding({ + left: 16 + }) + .textAlign(TextAlign.Start) + } + .width('100%') + .height(68) + .borderRadius(20) + .type(ButtonType.Normal) + .backgroundColor($r("app.color.white")) + .margin({ top: 16 }) + .onClick(() => { + this.doOperation(index) + }) + } + .width('100%') + .justifyContent(FlexAlign.Start) + } + }, (index: number) => index.toString()) + } + .width('100%') + } + + async aboutToAppear() { + if (this.operationRes) { + let menuList = await getStringArray(this.operationRes); + this.operationSource.dataArray = menuList; + this.operationSource.notifyDataReload(); + } + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/components/InfoItemView.ets b/feature/capabilities/src/main/ets/components/InfoItemView.ets new file mode 100644 index 0000000000000000000000000000000000000000..f8ae465398b001ed20f4e38a431367538302a014 --- /dev/null +++ b/feature/capabilities/src/main/ets/components/InfoItemView.ets @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct InfoItemView { + private name: string | Resource = ''; + private value: string | Resource = ''; + + build() { + Row() { + Text(this.name) + .fontSize(16) + .lineHeight(22) + .fontWeight(FontWeight.Medium) + .fontFamily('HarmonyHeiTi') + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .align(Alignment.Start) + .margin({ left: 16 }) + Blank() + Text(this.value) + .fontSize(16) + .lineHeight(22) + .fontWeight(FontWeight.Medium) + .fontFamily('HarmonyHeiTi') + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .align(Alignment.Start) + .margin({ right: 16 }) + } + .alignItems(VerticalAlign.Center) + .width('100%') + .height(56) + .borderRadius(20) + .padding({ left: 8, right: 8 }) + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/components/RadiusColumn.ets b/feature/capabilities/src/main/ets/components/RadiusColumn.ets new file mode 100644 index 0000000000000000000000000000000000000000..943843aa4915cfbca9f3f747ef1152acc989d8bd --- /dev/null +++ b/feature/capabilities/src/main/ets/components/RadiusColumn.ets @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct RadiusColumn { + @BuilderParam noParam: () => void; + + build() { + Column() { + this.noParam(); + } + .width('100%') + .borderRadius(24) + .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) + .padding({ + left: 12, + right: 12, + top: 6, + bottom: 6 + }) + .margin({ top: 6, bottom: 6 }) + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/components/usbmanager/DeviceCustomDialog.ets b/feature/capabilities/src/main/ets/components/usbmanager/DeviceCustomDialog.ets new file mode 100644 index 0000000000000000000000000000000000000000..ff0865663d1b3e860141be9e1249189db62df414 --- /dev/null +++ b/feature/capabilities/src/main/ets/components/usbmanager/DeviceCustomDialog.ets @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2023 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 { DeviceAttribute } from '../../model/DeviceAttribute'; + +@Preview +@CustomDialog +export struct DeviceCustomDialog { + private device: DeviceAttribute = new DeviceAttribute(); + private controller?: CustomDialogController; + + build() { + Column() { + Column() { + Text(`${this.device.manufacturerName} ${this.device.productName}`) + .width('100%') + .fontSize(26) + .margin({ top: 22, bottom: 22 }) + .fontWeight(FontWeight.Medium) + .textAlign(TextAlign.Center) + + List() { + ListItem() { + this.SingleAttribute($r('app.string.bus_address'), this.device.busAddress.toString()); + } + ListItem() { + this.SingleAttribute($r('app.string.device_address'), this.device.deviceAddress.toString()); + } + ListItem() { + this.SingleAttribute($r('app.string.serial'), this.device.serial); + } + ListItem() { + this.SingleAttribute($r('app.string.device_name'), this.device.name); + } + ListItem() { + this.SingleAttribute($r('app.string.manufacturer_name'), this.device.manufacturerName); + } + ListItem() { + this.SingleAttribute($r('app.string.product_name'), this.device.productName); + } + ListItem() { + this.SingleAttribute($r('app.string.version'), this.device.version); + } + ListItem() { + this.SingleAttribute($r('app.string.vendor_id'), this.device.vendorId.toString()); + } + ListItem() { + this.SingleAttribute($r('app.string.product_id'), this.device.productId.toString()); + } + ListItem() { + this.SingleAttribute($r('app.string.device_class'), this.device.clazz.toString()); + } + } + .scrollBar(BarState.Off) + .divider({ + strokeWidth: px2vp(1), + color: $r("app.color.divider") + }) + .width('100%') + .backgroundColor($r("app.color.white")) + .borderRadius(20) + + } + .margin({ + left: 32, + right: 32, + bottom: 72 + }) + .layoutWeight(1) + + Text($r('app.string.confirm')) + .fontSize(20) + .height(62) + .margin({ top: 8, bottom: 8 }) + .fontColor($r("sys.color.ohos_id_color_activated")) + .onClick(() => { + this.controller?.close(); + }) + } + } + + @Builder + SingleAttribute(title: Resource, info: string) { + Row() { + Text(title) + .fontSize(20) + .fontColor($r("app.color.list_content")) + .fontWeight(FontWeight.Medium) + .layoutWeight(1) + + Text(info) + .fontSize(18) + .fontColor($r("app.color.list_sub_content")) + .fontWeight(FontWeight.Regular) + } + .height(48) + .alignSelf(ItemAlign.Start) + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/components/usbmanager/DeviceList.ets b/feature/capabilities/src/main/ets/components/usbmanager/DeviceList.ets new file mode 100644 index 0000000000000000000000000000000000000000..5f917618d43afef74f30a0a3032fb2e6678a245d --- /dev/null +++ b/feature/capabilities/src/main/ets/components/usbmanager/DeviceList.ets @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2023 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 { DeviceAttribute } from '../../model/DeviceAttribute'; + +@Component +export struct DeviceList { + @Link isRefreshing: boolean; + @Link device: DeviceAttribute; + @Consume('devicesList') devices: Array; + public getDeviceList: () => void = () => { + }; + public openDialog: () => void = () => { + }; + + build() { + Column() { + Text($r('app.string.device_list')) + .fontSize(16) + .fontColor($r('app.color.list_sub_content')) + .fontWeight(FontWeight.Medium) + .margin({ + left: 16, + top: 24, + bottom: 12 + }) + .width('100%') + + Refresh({ refreshing: this.isRefreshing, offset: 120, friction: 100 }) { + List() { + ForEach(this.devices, (item: DeviceAttribute, index: number) => { + ListItem() { + Text(`${item.manufacturerName} ${item.productName}`) + .height(60) + .fontSize(20) + .fontWeight(FontWeight.Medium) + .width('100%') + .fontColor($r("app.color.black")) + .backgroundColor($r("app.color.white")) + .padding({ left: 16, right: 16 }) + } + .onClick(() => { + this.device = this.devices[index] + this.openDialog() + }) + }) + } + .width('100%') + .borderRadius(20) + .divider({ + strokeWidth: px2vp(1), + color: $r("app.color.divider"), + startMargin: 16, + endMargin: 16 + }) + } + .width('100%') + .margin({ bottom: 20 }) + .layoutWeight(1) + .onRefreshing(() => { + this.isRefreshing = true; + this.getDeviceList(); + setTimeout(() => { + this.isRefreshing = false; + }, 1000) + }) + } + .width('100%') + .layoutWeight(1) + .borderRadius(20) + .backgroundColor($r('app.color.list_background')) + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/model/DeviceAttribute.ts b/feature/capabilities/src/main/ets/model/DeviceAttribute.ts new file mode 100644 index 0000000000000000000000000000000000000000..f824bf7c5ad8595606b6c8b3c93a17a3fd9c29a3 --- /dev/null +++ b/feature/capabilities/src/main/ets/model/DeviceAttribute.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 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 DeviceAttribute { + public busAddress: number; // 总线地址 + public deviceAddress: number; // 设备地址 + public serial: string; // 序列号 + public name: string; // 设备名字 + public manufacturerName: string; // 产商信息 + public productName: string; // 产品信息 + public version: string; // 版本 + public vendorId: number; // 厂商ID + public productId: number; // 产品ID + public clazz: number; // 设备类 + + constructor() { + this.busAddress = 0; + this.deviceAddress = 0; + this.serial = ''; + this.name = ''; + this.manufacturerName = ''; + this.productName = ''; + this.version = ''; + this.vendorId = 0; + this.productId = 0; + this.clazz = 0; + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/model/ListModel.ets b/feature/capabilities/src/main/ets/model/ListModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9bee907f72fa6847ae663e51cf0f6fcf9566188 --- /dev/null +++ b/feature/capabilities/src/main/ets/model/ListModel.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 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 ListModel { + title: string; + function: Function | undefined; + value: string; + + constructor(title: string, func: Function | undefined, value: string = '') { + this.title = title; + this.function = func; + this.value = value; + } + + setValue(value: string) { + this.value = value; + } + + getValue() { + if (this.function == undefined) { + return this.value; + } + this.value = this.function(); + return this.value; + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/util/AlertDialogUtil.ets b/feature/capabilities/src/main/ets/util/AlertDialogUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..2ff142d266fdfe9a6aae857a64ed252ee4703960 --- /dev/null +++ b/feature/capabilities/src/main/ets/util/AlertDialogUtil.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 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 function showAlertDialog(title: Resource | string, message: Resource | string, action: () => void) { + AlertDialog.show( + { + title: title, + message: message, + primaryButton: { + value: $r('app.string.cancel'), + action: () => { + } + }, + secondaryButton: { + value: $r('app.string.confirm'), + action: () => { + action(); + } + } + } + ) +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/util/BatteryUtil.ets b/feature/capabilities/src/main/ets/util/BatteryUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..17562f1faae5011bd5b7087a9a7f9b6b2439e314 --- /dev/null +++ b/feature/capabilities/src/main/ets/util/BatteryUtil.ets @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2023 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 { batteryInfo } from '@kit.BasicServicesKit'; + +export class BatteryUtil { + static batterySOC() { + return batteryInfo.batterySOC + ''; + } + + static chargingStatus() { + let value = 'NONE'; + switch (batteryInfo.chargingStatus) { + case batteryInfo.BatteryChargeState.NONE: + value = 'NONE'; + break; + case batteryInfo.BatteryChargeState.ENABLE: + value = 'ENABLE'; + break; + case batteryInfo.BatteryChargeState.DISABLE: + value = 'DISABLE'; + break; + case batteryInfo.BatteryChargeState.FULL: + value = 'FULL'; + break; + default: + break; + } + return value; + } + + static healthStatus() { + let value = 'UNKNOWN'; + switch (batteryInfo.healthStatus) { + case batteryInfo.BatteryHealthState.UNKNOWN: + value = 'UNKNOWN'; + break; + case batteryInfo.BatteryHealthState.GOOD: + value = 'GOOD'; + break; + case batteryInfo.BatteryHealthState.OVERVOLTAGE: + value = 'OVERVOLTAGE'; + break; + case batteryInfo.BatteryHealthState.OVERHEAT: + value = 'OVERHEAT'; + break; + case batteryInfo.BatteryHealthState.COLD: + value = 'COLD'; + break; + case batteryInfo.BatteryHealthState.DEAD: + value = 'DEAD'; + break; + default: + break; + } + return value; + } + + static pluggedType() { + let value = 'NONE'; + switch (batteryInfo.pluggedType) { + case batteryInfo.BatteryPluggedType.NONE: + value = 'NONE'; + break; + case batteryInfo.BatteryPluggedType.AC: + value = 'AC'; + break; + case batteryInfo.BatteryPluggedType.USB: + value = 'USB'; + break; + case batteryInfo.BatteryPluggedType.WIRELESS: + value = 'WIRELESS'; + break; + default: + break; + } + return value; + } + + static voltage() { + return batteryInfo.voltage + "(μV)"; + } + + static technology() { + return batteryInfo.technology; + } + + static batteryTemperature() { + return (batteryInfo.batteryTemperature / 10).toFixed(2) + "(℃)"; + } + + static isBatteryPresent() { + return batteryInfo.isBatteryPresent ? 'TRUE' : 'FALSE'; + } + + static batteryCapacityLevel() { + let value = 'NONE'; + switch (batteryInfo.batteryCapacityLevel) { + case batteryInfo.BatteryCapacityLevel.LEVEL_FULL: + value = 'LEVEL_FULL'; + break; + case batteryInfo.BatteryCapacityLevel.LEVEL_HIGH: + value = 'LEVEL_HIGH'; + break; + case batteryInfo.BatteryCapacityLevel.LEVEL_NORMAL: + value = 'LEVEL_NORMAL'; + break; + case batteryInfo.BatteryCapacityLevel.LEVEL_LOW: + value = 'LEVEL_LOW'; + break; + case batteryInfo.BatteryCapacityLevel.LEVEL_CRITICAL: + value = 'LEVEL_CRITICAL'; + break; + default: + break; + } + return value; + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/util/CheckEmptyUtils.ts b/feature/capabilities/src/main/ets/util/CheckEmptyUtils.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c6cb61bdc157ba4a57ef4ca1cea1fbbe9a6279a --- /dev/null +++ b/feature/capabilities/src/main/ets/util/CheckEmptyUtils.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 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 { usbManager } from '@kit.BasicServicesKit'; + +export default { + isEmpty(object: Object): boolean { + return (typeof object === 'undefined' || object === null || object === ''); + }, + + isEmptyArray(array: Array): boolean { + return (array.length === 0 ? true : false); + } +}; \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/util/PowerManagerUtil.ets b/feature/capabilities/src/main/ets/util/PowerManagerUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..0297a3065999621bcec78afe4aa0f2fa5b071b67 --- /dev/null +++ b/feature/capabilities/src/main/ets/util/PowerManagerUtil.ets @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 { power } from '@kit.BasicServicesKit'; +import { getStringArray } from '@ohos/common'; + +let powerModes: Array = [ +power.DevicePowerMode.MODE_NORMAL, +power.DevicePowerMode.MODE_POWER_SAVE, +power.DevicePowerMode.MODE_PERFORMANCE, +power.DevicePowerMode.MODE_EXTREME_POWER_SAVE +]; + +export class PowerManagerUtil { + + static isActive(): boolean { + return power.isActive(); + } + + /** + MODE_NORMAL 600 表示标准模式,默认值。 + MODE_POWER_SAVE 601 表示省电模式。 + MODE_PERFORMANCE 602 表示性能模式。 + MODE_EXTREME_POWER_SAVE 603 表示超级省电模式。 + */ + static async getPowerModeName(): Promise { + let powerModeNames = await getStringArray($r('app.strarray.power_mode')) + switch (power.getPowerMode()) { + case powerModes[0]: + return powerModeNames[0]; + case powerModes[1]: + return powerModeNames[1]; + case powerModes[2]: + return powerModeNames[2]; + case powerModes[3]: + return powerModeNames[3]; + default: + return '' + } + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/util/ThermalUtil.ets b/feature/capabilities/src/main/ets/util/ThermalUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..202356708ad59c2bb522d63d0b02a109b650c0c3 --- /dev/null +++ b/feature/capabilities/src/main/ets/util/ThermalUtil.ets @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2023 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 { thermal } from '@kit.BasicServicesKit'; + +export class ThermalUtil { + static getLevel(): string { + return ThermalUtil.getStrLevel(thermal.getLevel()); + } + + static getStrLevel(level: Number) { + let value = "NONE"; + switch (level) { + case thermal.ThermalLevel.COOL: + value = 'COOL 0'; + break; + case thermal.ThermalLevel.NORMAL: + value = 'NORMAL 1'; + break; + case thermal.ThermalLevel.WARM: + value = 'WARM 2'; + break; + case thermal.ThermalLevel.HOT: + value = 'HOT 3'; + break; + case thermal.ThermalLevel.OVERHEATED: + value = 'OVERHEATED 4'; + break; + case thermal.ThermalLevel.WARNING: + value = 'WARNING 5'; + break; + case thermal.ThermalLevel.EMERGENCY: + value = 'EMERGENCY 6'; + break; + default: + break; + } + return value + } + + static registerThermalLevelCallback(callback: (level: number) => void) { + thermal.registerThermalLevelCallback(callback); + } + + static unregisterThermalLevelCallback() { + thermal.unregisterThermalLevelCallback(); + } + + static timestampToTime(timestamp: number) { + let date = new Date(timestamp); + let Y = date.getFullYear() + '-'; + let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'; + let D = (date.getDate() < 10 ? ('0' + date.getDate()) : date.getDate()) + ' '; + let h = (date.getHours() < 10 ? ('0' + date.getHours()) : date.getHours()) + ':'; + let m = (date.getMinutes() < 10 ? ('0' + date.getMinutes()) : date.getMinutes()) + ':'; + let s = date.getSeconds() < 10 ? ('0' + date.getSeconds()) : date.getSeconds(); + return (Y + M + D + h + m + s) + ''; + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/ets/util/UsbManagerUtil.ets b/feature/capabilities/src/main/ets/util/UsbManagerUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac94f2957c827cfb36096dbe122e15fd1cb3cd70 --- /dev/null +++ b/feature/capabilities/src/main/ets/util/UsbManagerUtil.ets @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2023 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 { promptAction } from '@kit.ArkUI'; +import { usbManager,BusinessError,commonEventManager } from '@kit.BasicServicesKit'; +import CheckEmptyUtils from './CheckEmptyUtils'; +import { DeviceAttribute } from '../model/DeviceAttribute'; +import { logger } from '@ohos/common'; + +const TAG: string = 'UsbManagerUtil'; +let commonEventSubscriber : commonEventManager.CommonEventSubscriber | undefined = undefined; + +export function getDeviceList(): DeviceAttribute[] { + let usbDevices: usbManager.USBDevice[] = usbManager.getDevices(); + logger.info(TAG, `usb getDeviceList 000 is : ${JSON.stringify(usbDevices)}`); + if (CheckEmptyUtils.isEmpty(usbDevices)) { + logger.info(TAG, `usbDevices is null`); + return []; + } + if (CheckEmptyUtils.isEmptyArray(usbDevices)) { + logger.info(TAG, `usb getDeviceList is null`); + return []; + } + let devices: DeviceAttribute[] = []; + for (let index = 0;index < usbDevices.length; index++) { + logger.info(TAG, `usb devices ${index} : ${JSON.stringify(devices)}`); + let deviceAttribute: DeviceAttribute = { + version: usbDevices[index].version, + serial: usbDevices[index].serial, + productName: usbDevices[index].productName, + manufacturerName: usbDevices[index].manufacturerName, + name: usbDevices[index].name, + productId: usbDevices[index].productId, + vendorId: usbDevices[index].vendorId, + busAddress: usbDevices[index].busNum, + clazz: usbDevices[index].clazz, + deviceAddress: usbDevices[index].devAddress + }; + if (devices.indexOf(deviceAttribute) === -1) { + devices.push(deviceAttribute); + } + } + logger.info(TAG, `usb devices : ${JSON.stringify(devices)}`); + return devices; +} + +export function createUsbSubscribe(callback: () => void) { + if (!CheckEmptyUtils.isEmpty(commonEventSubscriber)) { + logger.info(TAG, `usb event not subscribed`); + return; + } + logger.info(TAG, 'usb subUsbListener....'); + let commonEventSubscribeInfo: commonEventManager.CommonEventSubscribeInfo = { + events: [commonEventManager.Support.COMMON_EVENT_USB_DEVICE_DETACHED, commonEventManager.Support.COMMON_EVENT_USB_DEVICE_ATTACHED] + }; + let promise = commonEventManager.createSubscriber(commonEventSubscribeInfo); + let usbSubscribeCallback = (err: BusinessError, data: commonEventManager.CommonEventData) => { + logger.info(TAG, `SubscriberCallBack data = ${JSON.stringify(data)}`); + if (data.event === 'usual.event.hardware.usb.action.USB_DEVICE_ATTACHED') { + promptAction.showToast({ message: $r('app.string.toast_inserted') }); + } else { + promptAction.showToast({ message: $r('app.string.toast_removed') }); + } + callback(); + }; + promise.then((data) => { + promptAction.showToast({ message: $r('app.string.toast_start_listening') }); + logger.info(TAG, 'usb CreateSubscriberCallBack....'); + commonEventSubscriber = data; + commonEventManager.subscribe(commonEventSubscriber, usbSubscribeCallback); + logger.info(TAG, 'Subscriber.subscribe success'); + }).catch((err: BusinessError) => { + logger.info(TAG, `Subscriber.createSubscriber promise err = ${JSON.stringify(err)}`); + }) +} + +export function cancelUsbSubscribe(): void { + if (CheckEmptyUtils.isEmpty(commonEventSubscriber)) { + logger.info(TAG, 'usb event already subscribed'); + return; + } + try { + commonEventManager.unsubscribe(commonEventSubscriber, () => { + logger.info(TAG, `usb event unsubscribed`); + commonEventSubscriber = undefined; + promptAction.showToast({ message: $r('app.string.toast_listening_cancel') }); + }) + } catch (err) { + logger.error(TAG, `usb event unsubscribed fail:${JSON.parse(err)}`); + } +} \ No newline at end of file diff --git a/feature/capabilities/src/main/module.json5 b/feature/capabilities/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4433d4295486efbe544d3a3d669b33b1b784764a --- /dev/null +++ b/feature/capabilities/src/main/module.json5 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 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. + */ + +{ + "module": { + "name": "capabilities", + "type": "har", + "deviceTypes": [ + "phone" + ], + "requestPermissions": [ + { + "name": "ohos.permission.RUNNING_LOCK" + } + ] + } +} diff --git a/feature/capabilities/src/main/resources/base/element/strarray.json b/feature/capabilities/src/main/resources/base/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..33d59bc38340c79ba65725292112c5485f850071 --- /dev/null +++ b/feature/capabilities/src/main/resources/base/element/strarray.json @@ -0,0 +1,48 @@ +{ + "strarray": [ + { + "name": "power_operations", + "value": [ + { + "value": "Check whether the screen is on or off" + }, + { + "value": "Get Power Mode" + } + ] + }, + { + "name": "running_lock_operations", + "value": [ + { + "value": "Supported runningLock" + } + ] + }, + { + "name": "power_mode", + "value": [ + { + "value": "normal" + }, + { + "value": "power save" + }, + { + "value": "performance" + }, + { + "value": "extreme power save" + } + ] + }, + { + "name": "settings_operations", + "value": [ + { + "value": "Get Settings Uri" + } + ] + } + ] +} \ No newline at end of file diff --git a/feature/capabilities/src/main/resources/base/element/string.json b/feature/capabilities/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d3c4616d2f723035ee8791ba535a34521f8b064f --- /dev/null +++ b/feature/capabilities/src/main/resources/base/element/string.json @@ -0,0 +1,124 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + }, + { + "name": "no_battery", + "value": "The battery is supported or present" + }, + { + "name": "battery_charge_percent", + "value": "Battery charge percent" + }, + { + "name": "charging_status", + "value": "ChargingStatus" + }, + { + "name": "usb_listener", + "value": "USB Listener" + }, + { + "name": "device_list", + "value": "device list" + }, + { + "name": "confirm", + "value": "confirm" + }, + { + "name": "bus_address", + "value": "bus address" + }, + { + "name": "device_address", + "value": "device address" + }, + { + "name": "serial", + "value": "serial" + }, + { + "name": "device_name", + "value": "device name" + }, + { + "name": "manufacturer_name", + "value": "manufacturer name" + }, + { + "name": "product_name", + "value": "product name" + }, + { + "name": "version", + "value": "version" + }, + { + "name": "vendor_id", + "value": "vendor id" + }, + { + "name": "product_id", + "value": "product id" + }, + { + "name": "device_class", + "value": "device class" + }, + { + "name": "toast_start_listening", + "value": "Start listening" + }, + { + "name": "toast_inserted", + "value": "USB inserted" + }, + { + "name": "toast_removed", + "value": "Device removed" + }, + { + "name": "toast_listening_cancel", + "value": "Cancel listening" + }, + { + "name": "cancel", + "value": "Cancel" + }, + { + "name": "screen_state", + "value": "The screen state:" + }, + { + "name": "power_mode", + "value": "current power mode:" + }, + { + "name": "running_lock_proximity_screen_control", + "value": "proximity screen control:" + }, + { + "name": "running_lock_background", + "value": "Background:" + }, + { + "name": "airplane_status", + "value": "Airplane status:" + }, + { + "name": "show_floating_status", + "value": "show floating status:" + }, + { + "name": "thermal_warning", + "value": "The current device battery temperature is too high!" + }, + { + "name": "no_usb_device", + "value": "No USB Device" + } + ] +} diff --git a/feature/capabilities/src/main/resources/base/media/icon.png b/feature/capabilities/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/feature/capabilities/src/main/resources/base/media/icon.png differ diff --git a/feature/capabilities/src/main/resources/en_US/element/strarray.json b/feature/capabilities/src/main/resources/en_US/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..33d59bc38340c79ba65725292112c5485f850071 --- /dev/null +++ b/feature/capabilities/src/main/resources/en_US/element/strarray.json @@ -0,0 +1,48 @@ +{ + "strarray": [ + { + "name": "power_operations", + "value": [ + { + "value": "Check whether the screen is on or off" + }, + { + "value": "Get Power Mode" + } + ] + }, + { + "name": "running_lock_operations", + "value": [ + { + "value": "Supported runningLock" + } + ] + }, + { + "name": "power_mode", + "value": [ + { + "value": "normal" + }, + { + "value": "power save" + }, + { + "value": "performance" + }, + { + "value": "extreme power save" + } + ] + }, + { + "name": "settings_operations", + "value": [ + { + "value": "Get Settings Uri" + } + ] + } + ] +} \ No newline at end of file diff --git a/feature/capabilities/src/main/resources/en_US/element/string.json b/feature/capabilities/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3003ed8526f4394583095946d5cdba01d3472701 --- /dev/null +++ b/feature/capabilities/src/main/resources/en_US/element/string.json @@ -0,0 +1,124 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + }, + { + "name": "no_battery", + "value": "The battery is supported or present" + }, + { + "name": "battery_charge_percent", + "value": "Battery charge percent" + }, + { + "name": "charging_status", + "value": "ChargingStatus" + }, + { + "name": "usb_listener", + "value": "USB Listener" + }, + { + "name": "device_list", + "value": "device list" + }, + { + "name": "confirm", + "value": "confirm" + }, + { + "name": "bus_address", + "value": "bus address" + }, + { + "name": "device_address", + "value": "device address" + }, + { + "name": "serial", + "value": "serial" + }, + { + "name": "device_name", + "value": "device name" + }, + { + "name": "manufacturer_name", + "value": "manufacturer name" + }, + { + "name": "product_name", + "value": "product name" + }, + { + "name": "version", + "value": "version" + }, + { + "name": "vendor_id", + "value": "vendor id" + }, + { + "name": "product_id", + "value": "product id" + }, + { + "name": "device_class", + "value": "device class" + }, + { + "name": "toast_start_listening", + "value": "Start listening" + }, + { + "name": "toast_inserted", + "value": "USB inserted" + }, + { + "name": "toast_removed", + "value": "Device removed" + }, + { + "name": "toast_listening_cancel", + "value": "Cancel listening" + }, + { + "name": "cancel", + "value": "Cancel" + }, + { + "name": "screen_state", + "value": "The screen state:" + }, + { + "name": "power_mode", + "value": "current power mode:" + }, + { + "name": "running_lock_proximity_screen_control", + "value": "proximity screen control:" + }, + { + "name": "running_lock_background", + "value": "Background:" + }, + { + "name": "airplane_status", + "value": "Airplane status:" + }, + { + "name": "thermal_warning", + "value": "The current device battery temperature is too high!" + }, + { + "name": "no_usb_device", + "value": "No USB Device" + }, + { + "name": "show_floating_status", + "value": "show floating status:" + } + ] +} diff --git a/feature/capabilities/src/main/resources/zh_CN/element/strarray.json b/feature/capabilities/src/main/resources/zh_CN/element/strarray.json new file mode 100644 index 0000000000000000000000000000000000000000..2b4343aaba3a88fbc24d6882a260942de3cab239 --- /dev/null +++ b/feature/capabilities/src/main/resources/zh_CN/element/strarray.json @@ -0,0 +1,48 @@ +{ + "strarray": [ + { + "name": "power_operations", + "value": [ + { + "value": "检测亮灭屏状态" + }, + { + "value": "获取电源模式" + } + ] + }, + { + "name": "running_lock_operations", + "value": [ + { + "value": "设备支持的休眠锁类型" + } + ] + }, + { + "name": "power_mode", + "value": [ + { + "value": "标准模式" + }, + { + "value": "省电模式" + }, + { + "value": "性能模式" + }, + { + "value": "超级省电模式" + } + ] + }, + { + "name": "settings_operations", + "value": [ + { + "value": "获取数据项uri" + } + ] + } + ] +} \ No newline at end of file diff --git a/feature/capabilities/src/main/resources/zh_CN/element/string.json b/feature/capabilities/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f7238657f54b230d0bd0d8f4106e5a1cd7494d8b --- /dev/null +++ b/feature/capabilities/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,124 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + }, + { + "name": "no_battery", + "value": "当前设备不支持电池或电池不在位" + }, + { + "name": "battery_charge_percent", + "value": "电池电量百分比" + }, + { + "name": "charging_status", + "value": "充电状态" + }, + { + "name": "usb_listener", + "value": "USB监听" + }, + { + "name": "device_list", + "value": "设备列表" + }, + { + "name": "confirm", + "value": "确定" + }, + { + "name": "bus_address", + "value": "总线地址" + }, + { + "name": "device_address", + "value": "设备地址" + }, + { + "name": "serial", + "value": "序列号" + }, + { + "name": "device_name", + "value": "设备名字" + }, + { + "name": "manufacturer_name", + "value": "产商信息" + }, + { + "name": "product_name", + "value": "产品信息" + }, + { + "name": "version", + "value": "版本" + }, + { + "name": "vendor_id", + "value": "厂商ID" + }, + { + "name": "product_id", + "value": "产品ID" + }, + { + "name": "device_class", + "value": "设备类" + }, + { + "name": "toast_start_listening", + "value": "开始监听" + }, + { + "name": "toast_inserted", + "value": "USB已插入" + }, + { + "name": "toast_removed", + "value": "设备已移除" + }, + { + "name": "toast_listening_cancel", + "value": "取消监听" + }, + { + "name": "cancel", + "value": "取消" + }, + { + "name": "screen_state", + "value": "亮灭屏状态:" + }, + { + "name": "power_mode", + "value": "当前电源模式:" + }, + { + "name": "running_lock_background", + "value": "阻止系统休眠的锁:" + }, + { + "name": "running_lock_proximity_screen_control", + "value": "通过接近或者远离状态来控制亮灭屏的锁:" + }, + { + "name": "airplane_status", + "value": "飞行模式状态:" + }, + { + "name": "thermal_warning", + "value": "当前设备电池温度过高!" + }, + { + "name": "no_usb_device", + "value": "暂无USB设备" + }, + { + "name": "show_floating_status", + "value": "应用是否能以悬浮窗形式显示:" + } + ] +} diff --git a/feature/menuitems/build-profile.json5 b/feature/menuitems/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..12fe2d844bdb69584fd05ebaa3e1cb197a25c3f1 --- /dev/null +++ b/feature/menuitems/build-profile.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 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. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "targets": [ + { + "name": "default" + } + ] +} diff --git a/feature/menuitems/hvigorfile.ts b/feature/menuitems/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..6522df25794b80abde0b0aa8654f3970c4a35cfa --- /dev/null +++ b/feature/menuitems/hvigorfile.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2023 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. + */ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { harTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/feature/menuitems/index.ets b/feature/menuitems/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0e02ba6f8124992edcf5a89f14484737a6944537 --- /dev/null +++ b/feature/menuitems/index.ets @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2023 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 { MenuList } from './src/main/ets/menulist/MenuList'; diff --git a/feature/menuitems/oh-package.json5 b/feature/menuitems/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c87ef18f196779f877dc8d89a9b495cade9e496e --- /dev/null +++ b/feature/menuitems/oh-package.json5 @@ -0,0 +1,12 @@ +{ + "license": "ISC", + "types": "", + "devDependencies": {}, + "name": "menuitems", + "description": "a npm package which contains arkUI2.0 page", + "main": "index.ets", + "version": "1.0.0", + "dependencies": { + "@ohos/common": "file:../../common" + } +} diff --git a/feature/menuitems/src/main/ets/components/ItemGroup.ets b/feature/menuitems/src/main/ets/components/ItemGroup.ets new file mode 100644 index 0000000000000000000000000000000000000000..8c0a6ba93d64782516c5044ce1c1c887cef89bd2 --- /dev/null +++ b/feature/menuitems/src/main/ets/components/ItemGroup.ets @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct ItemGroup { + @BuilderParam noParam: () => void; + + build() { + Column() { + this.noParam(); + } + .width('100%') + .borderRadius(20) + .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) + .margin({ bottom: 12 }) + } +} \ No newline at end of file diff --git a/feature/menuitems/src/main/ets/components/MainItem.ets b/feature/menuitems/src/main/ets/components/MainItem.ets new file mode 100644 index 0000000000000000000000000000000000000000..01d390439d7da6ea39ce9d6e341c25e972fabdc9 --- /dev/null +++ b/feature/menuitems/src/main/ets/components/MainItem.ets @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct MainItem { + private title?: string | Resource; + @LocalStorageProp('isSplitMode') isSplitMode: boolean = false; + @State isTouched: boolean = false; + + build() { + Row() { + Text(this.title) + .fontSize(20) + .lineHeight(22) + .fontWeight(FontWeight.Medium) + .fontColor($r("app.color.list_title")) + .align(Alignment.Start) + + Blank() + + Image($r('app.media.ic_arrow')) + .width(16) + .height(32) + .fillColor($r('sys.color.ohos_id_color_fourth')) + } + .alignItems(VerticalAlign.Center) + .width('100%') + .height(62) + .borderRadius(20) + .padding({ left: 16, right: 16 }) + .backgroundColor(this.isTouched ? $r('app.color.itemActivated') : $r('app.color.itemInactivated')) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isTouched = true; + } else if (event.type === TouchType.Up) { + this.isTouched = false; + } + }) + } +} \ No newline at end of file diff --git a/feature/menuitems/src/main/ets/components/MenuNavRouter.ets b/feature/menuitems/src/main/ets/components/MenuNavRouter.ets new file mode 100644 index 0000000000000000000000000000000000000000..832165997592414ec5c3d694c450c034f3a6acd2 --- /dev/null +++ b/feature/menuitems/src/main/ets/components/MenuNavRouter.ets @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2023 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 { ItemGroup } from './ItemGroup'; +import { logger } from '@ohos/common'; +import { MainItem } from './MainItem'; + +const TAG: string = 'MenuNavRouter'; + +@Component +export struct MenuNavRouter { + @StorageLink('selectedLabel') selectedLabel: string = ''; + @BuilderParam navDestination: () => void; + private childList: Array = []; + + @Builder CustomDivider() { + Divider() + .strokeWidth('1px') + .color($r("app.color.divider")) + .margin({ left: 16, right: 16 }) + } + + build() { + ItemGroup() { + Column() { + ForEach(this.childList, (item: string, index: number) => { + if (index > 0) { + this.CustomDivider(); + } + NavRouter() { + MainItem({ + title: item + }) + NavDestination() { + Column() { + this.navDestination(); + } + } + .title(item) + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } + .onStateChange((isActivated: boolean) => { + if (isActivated) { + this.selectedLabel = item; + logger.info(TAG, `NavRouter isActivated= ${isActivated}, selectedLabel=${item}`); + } + }) + }, (item: string) => JSON.stringify(item)) + } + } + } +} \ No newline at end of file diff --git a/feature/menuitems/src/main/ets/menulist/MenuList.ets b/feature/menuitems/src/main/ets/menulist/MenuList.ets new file mode 100644 index 0000000000000000000000000000000000000000..e0a6982e5168dd6730fb1b29dce3deac378343d6 --- /dev/null +++ b/feature/menuitems/src/main/ets/menulist/MenuList.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 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 { getStringArray } from '@ohos/common'; +import { MenuNavRouter } from '../components/MenuNavRouter'; + +@Component +export struct MenuList { + @State menuListData: Array = []; + @BuilderParam childNavDestination: () => void; + private menuList?: Resource = undefined; + + build() { + List() { + ListItem() { + if (this.menuListData.length > 0) { + MenuNavRouter({ childList: this.menuListData }) { + this.childNavDestination(); + } + } + } + } + .borderRadius(20) + .width('100%') + .scrollBar(BarState.Off) + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } + + aboutToAppear() { + this.getData(); + } + + getData = async () => { + if (this.menuList) { + this.menuListData = await getStringArray(this.menuList); + } + } +} \ No newline at end of file diff --git a/feature/menuitems/src/main/module.json5 b/feature/menuitems/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..057d4c8bffd8566e3d8c7bb4a9ed51a1614306fb --- /dev/null +++ b/feature/menuitems/src/main/module.json5 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023 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. + */ + +{ + "module": { + "name": "menuitems", + "type": "har", + "deviceTypes": [ + "phone" + ] + } +} \ No newline at end of file diff --git a/feature/menuitems/src/main/resources/base/element/color.json b/feature/menuitems/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..d652db2230e76039c0262d6880a291d1a8db7c93 --- /dev/null +++ b/feature/menuitems/src/main/resources/base/element/color.json @@ -0,0 +1,20 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + }, + { + "name": "itemActivated", + "value": "#335291FF" + }, + { + "name": "itemInactivated", + "value": "#FFFFFF" + }, + { + "name": "level_title", + "value": "#77000000" + } + ] +} \ No newline at end of file diff --git a/feature/menuitems/src/main/resources/base/element/string.json b/feature/menuitems/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1e76de0c66777cfe83568615c5c2e68c61d23fed --- /dev/null +++ b/feature/menuitems/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + } + ] +} diff --git a/feature/menuitems/src/main/resources/base/media/ic_arrow.svg b/feature/menuitems/src/main/resources/base/media/ic_arrow.svg new file mode 100644 index 0000000000000000000000000000000000000000..16246dd69c9d648803cc573e60252694661c868a --- /dev/null +++ b/feature/menuitems/src/main/resources/base/media/ic_arrow.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/feature/menuitems/src/main/resources/en_US/element/string.json b/feature/menuitems/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1e76de0c66777cfe83568615c5c2e68c61d23fed --- /dev/null +++ b/feature/menuitems/src/main/resources/en_US/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + } + ] +} diff --git a/feature/menuitems/src/main/resources/zh_CN/element/string.json b/feature/menuitems/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1e76de0c66777cfe83568615c5c2e68c61d23fed --- /dev/null +++ b/feature/menuitems/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + } + ] +} diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f70ecd4112d94f9aa555adf898d53f18bf58f3e9 --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,5 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + } +} \ No newline at end of file diff --git a/hvigorfile.ts b/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..988feb9d12f64df2ee8460ffcaee81e8c2a010c7 --- /dev/null +++ b/hvigorfile.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2023 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. + */ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { appTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..98842c689cd4a64df670a10f3fe313485b926a2c --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,12 @@ +{ + "modelVersion": "5.0.0", + "license": "ISC", + "devDependencies": { + "@ohos/hypium": "1.0.15" + }, + "name": "devicemanagementcollection", + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} \ No newline at end of file diff --git a/screenshots/devices/battery.png b/screenshots/devices/battery.png new file mode 100644 index 0000000000000000000000000000000000000000..cf7408f0c945e0622e9e2224e9c32478e541835d Binary files /dev/null and b/screenshots/devices/battery.png differ diff --git a/screenshots/devices/home.png b/screenshots/devices/home.png new file mode 100644 index 0000000000000000000000000000000000000000..ea2847d9c2847e6f7a4c2bb08002ee8b4be874b1 Binary files /dev/null and b/screenshots/devices/home.png differ diff --git a/screenshots/devices/power.png b/screenshots/devices/power.png new file mode 100644 index 0000000000000000000000000000000000000000..8712a2715c7aaa425300646284cd5c14549f7538 Binary files /dev/null and b/screenshots/devices/power.png differ diff --git a/screenshots/devices/runninglock.png b/screenshots/devices/runninglock.png new file mode 100644 index 0000000000000000000000000000000000000000..9a7bff1c7928fb54636723f8ccdff5faa92aec2e Binary files /dev/null and b/screenshots/devices/runninglock.png differ diff --git a/screenshots/devices/settings.png b/screenshots/devices/settings.png new file mode 100644 index 0000000000000000000000000000000000000000..5f0e507079d900ba4024983c4f89940745c3a851 Binary files /dev/null and b/screenshots/devices/settings.png differ diff --git a/screenshots/devices/thermal.png b/screenshots/devices/thermal.png new file mode 100644 index 0000000000000000000000000000000000000000..0adb638e0fc5e73a9aee2e506a3c00f4faeac133 Binary files /dev/null and b/screenshots/devices/thermal.png differ diff --git a/screenshots/devices/usb.png b/screenshots/devices/usb.png new file mode 100644 index 0000000000000000000000000000000000000000..cb5449245d923f8f2e22dda6936dee370c471fc0 Binary files /dev/null and b/screenshots/devices/usb.png differ