已合并
[新需求]: 应用接续数据迁移 首次提交代码 #1
sfchu创建于 6月23日
[新需求]: 应用接续数据迁移 首次提交代码 #1
已合并
共 51 个文件变更+2186-4
| @@ -0,0 +1,11 @@ | |||
| 1 | +{ | ||
| 2 | + "app": { | ||
| 3 | + "bundleName": "com.example.datamigration", | ||
| 4 | + "vendor": "example", | ||
| 5 | + "versionCode": 1000000, | ||
| 6 | + "versionName": "1.0.0", | ||
| 7 | + "buildVersion": "1", | ||
| 8 | + "icon": "$media:layered_image", | ||
| 9 | + "label": "$string:app_name" | ||
| 10 | + } | ||
| 11 | +} | ||
| @@ -0,0 +1,8 @@ | |||
| 1 | +{ | ||
| 2 | + "string": [ | ||
| 3 | + { | ||
| 4 | + "name": "app_name", | ||
| 5 | + "value": "DataMigration" | ||
| 6 | + } | ||
| 7 | + ] | ||
| 8 | +} | ||
| @@ -0,0 +1,7 @@ | |||
| 1 | +{ | ||
| 2 | + "layered-image": | ||
| 3 | + { | ||
| 4 | + "background" : "$media:background", | ||
| 5 | + "foreground" : "$media:foreground" | ||
| 6 | + } | ||
| 7 | +} | ||
| @@ -0,0 +1,78 @@ | |||
| 1 | + Copyright (c) 2026 Huawei Device Co., Ltd. All rights reserved. | ||
| 2 | + | ||
| 3 | + Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + you may not use this file except in compliance with the License. | ||
| 5 | + You may obtain a copy of the License at | ||
| 6 | + | ||
| 7 | + http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + | ||
| 9 | + Unless required by applicable law or agreed to in writing, software | ||
| 10 | + distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + See the License for the specific language governing permissions and | ||
| 13 | + limitations under the License. | ||
| 14 | + | ||
| 15 | +Apache License, Version 2.0 | ||
| 16 | +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | ||
| 17 | + | ||
| 18 | +1. Definitions. | ||
| 19 | + | ||
| 20 | +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. | ||
| 21 | + | ||
| 22 | +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. | ||
| 23 | + | ||
| 24 | +"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. | ||
| 25 | + | ||
| 26 | +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. | ||
| 27 | + | ||
| 28 | +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. | ||
| 29 | + | ||
| 30 | +"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. | ||
| 31 | + | ||
| 32 | +"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). | ||
| 33 | + | ||
| 34 | +"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. | ||
| 35 | + | ||
| 36 | +"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." | ||
| 37 | + | ||
| 38 | +"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. | ||
| 39 | + | ||
| 40 | +2. Grant of Copyright License. | ||
| 41 | + | ||
| 42 | +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. | ||
| 43 | + | ||
| 44 | +3. Grant of Patent License. | ||
| 45 | + | ||
| 46 | +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. | ||
| 47 | + | ||
| 48 | +4. Redistribution. | ||
| 49 | + | ||
| 50 | +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: | ||
| 51 | +1.You must give any other recipients of the Work or Derivative Works a copy of this License; and | ||
| 52 | +2.You must cause any modified files to carry prominent notices stating that You changed the files; and | ||
| 53 | +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 | ||
| 54 | +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. | ||
| 55 | + | ||
| 56 | +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. | ||
| 57 | + | ||
| 58 | +5. Submission of Contributions. | ||
| 59 | + | ||
| 60 | +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. | ||
| 61 | + | ||
| 62 | +6. Trademarks. | ||
| 63 | + | ||
| 64 | +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. | ||
| 65 | + | ||
| 66 | +7. Disclaimer of Warranty. | ||
| 67 | + | ||
| 68 | +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. | ||
| 69 | + | ||
| 70 | +8. Limitation of Liability. | ||
| 71 | + | ||
| 72 | +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. | ||
| 73 | + | ||
| 74 | +9. Accepting Warranty or Additional Liability. | ||
| 75 | + | ||
| 76 | +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. | ||
| 77 | + | ||
| 78 | +END OF TERMS AND CONDITIONS | ||
| @@ -0,0 +1,50 @@ | |||
| 1 | + | ||
| 2 | +<!-- Copyright (c) 2026 Huawei Device Co., Ltd. | ||
| 3 | + | ||
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + you may not use this file except in compliance with the License. | ||
| 6 | + You may obtain a copy of the License at | ||
| 7 | + | ||
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + | ||
| 10 | + Unless required by applicable law or agreed to in writing, software | ||
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + See the License for the specific language governing permissions and | ||
| 14 | + limitations under the License. | ||
| 15 | + | ||
| 16 | + This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README. | ||
| 17 | + | ||
| 18 | +--> | ||
| 19 | + | ||
| 20 | +<configuration> | ||
| 21 | + <oatconfig> | ||
| 22 | + <licensefile/> | ||
| 23 | + <policylist> | ||
| 24 | + <policy name="projectPolicy" desc=""> | ||
| 25 | + <!--policyitem type="compatibility" name="GPL-2.0+" path="abc/.*" desc="Process that runs independently, invoked by the X process."/--> | ||
| 26 | + <!--policyitem type="license" name="LGPL" path="abc/.*" desc="Dynamically linked by module X"/--> | ||
| 27 | + <!--policyitem type="copyright" name="xxx" path="abc/.*" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc="Developed by X Company"/--> | ||
| 28 | + <policyitem type="license" name="CC-BY-4.0" path=".*" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter" desc="License for documents"/> | ||
| 29 | + </policy> | ||
| 30 | + </policylist> | ||
| 31 | + <filefilterlist> | ||
| 32 | + <filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies"> | ||
| 33 | + <!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/--> | ||
| 34 | + <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/--> | ||
| 35 | + <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/--> | ||
| 36 | + <filteritem type="filename" name="*.jpg|*.png|*.gif|*.pdf|*.xlsm|*.zip|*.ogg" desc="already checked"/> | ||
| 37 | + </filefilter> | ||
| 38 | + </filefilterlist> | ||
| 39 | + <licensematcherlist> | ||
| 40 | + <!--licensematcher name="uvwxyz License" desc="If the scanning result is InvalidLicense, you can define matching rules here. Note that quotation marks must be escaped."> | ||
| 41 | + <licensetext name=" | ||
| 42 | + uvwxyz license textA xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | ||
| 43 | + " desc=""/> | ||
| 44 | + <licensetext name=" | ||
| 45 | + uvwxyz license textB xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | ||
| 46 | + " desc=""/> | ||
| 47 | + </licensematcher--> | ||
| 48 | + </licensematcherlist> | ||
| 49 | + </oatconfig> | ||
| 50 | +</configuration> | ||
| @@ -1,5 +1,97 @@ | |||
| 1 | -# DataMigration | 1 | +# 基于应用接续实现数据迁移功能 |
| 2 | 2 | ||
| 3 | -本示例展示了HarmonyOS应用接续的两种数据迁移方式: | 3 | +## 介绍 |
| 4 | -1.want.param数据迁移 | 4 | + |
| 5 | -2.分布式对象迁移数据(基础数据迁移、单个/多文件资产迁移) | 5 | +本示例基于应用接续、分布式数据对象功能,实现文本图片数据跨设备迁移。 通过want.param迁移简单数据、分布式数据对象迁移基础数据、迁移单/多图片文件。 |
| 6 | + | ||
| 7 | +## 效果图预览 | ||
| 8 | + | ||
| 9 | +| **主页** | **want.param迁移** | **分布式对象迁移** | **单文件迁移** | **多文件迁移** | | ||
| 10 | +|:--------------------------------------------------:|:--------------------------------------------------:|:--------------------------------------------------:|:--------------------------------------------------:|:---------:| | ||
| 11 | +| <img src='screenshots/device/home.png' width=160> | <img src='screenshots/device/want.png' width=160> | <img src='screenshots/device/dataDistributedBase.png' width=160> | <img src='screenshots/device/distributedMonoFile.png' width=160> |<img src='screenshots/device/distributedMultiFile.png' width=160>| | ||
| 12 | + | ||
| 13 | +## 使用说明 | ||
| 14 | + | ||
| 15 | +### 使用want.param迁移简单数据 | ||
| 16 | + | ||
| 17 | +1. 进入应用首页,点击"使用want.param迁移简单数据"按钮,进入want.param迁移页面。 | ||
| 18 | +2. 在输入框中输入需要迁移的数据。 | ||
| 19 | +3. 对端设备,点击系统Dock栏,触发应用接续,数据接续到对端设备。 | ||
| 20 | + | ||
| 21 | +### 使用分布式对象迁移基础数据 | ||
| 22 | + | ||
| 23 | +1. 进入应用首页,点击"使用分布式对象迁移基础数据"按钮,进入分布式对象迁移页面。 | ||
| 24 | +2. 在"基础数据"区域输入文字数据和数字数据。 | ||
| 25 | +3. 在"数据对象"区域输入分布式对象的文字数据和数字数据。 | ||
| 26 | +4. 对端设备,点击系统Dock栏,触发应用接续,数据接续到对端设备。 | ||
| 27 | + | ||
| 28 | +### 使用分布式对象进行单个文件资产迁移 | ||
| 29 | + | ||
| 30 | +1. 进入应用首页,点击"使用分布式对象单文件迁移"按钮,进入单文件迁移页面。 | ||
| 31 | +2. 在"基础数据"区域输入文字数据和数字数据。 | ||
| 32 | +3. 点击"添加优质首图"区域,弹出菜单选择从本地设备获取图片。 | ||
| 33 | +4. 选择图片后,图片显示在页面中。 | ||
| 34 | +5. 对端设备,点击系统Dock栏,触发应用接续,数据和图片数据接续到对端设备。 | ||
| 35 | + | ||
| 36 | +### 使用分布式对象进行多个文件资产迁移 | ||
| 37 | + | ||
| 38 | +1. 进入应用首页,点击"使用分布式对象多文件迁移"按钮,进入多文件迁移页面。 | ||
| 39 | +2. 在"基础数据"区域输入文字数据和数字数据。 | ||
| 40 | +3. 点击"添加图片"区域,弹出菜单选择从本地设备获取图片(最多支持9张)。 | ||
| 41 | +4. 选择图片后,图片列表横向显示在页面中。 | ||
| 42 | +5. 对端设备,点击系统Dock栏,触发应用接续,数据和图片数据接续到对端设备。 | ||
| 43 | + | ||
| 44 | +## 工程目录 | ||
| 45 | + | ||
| 46 | +``` | ||
| 47 | +├──entry/src/main/ets // 代码区 | ||
| 48 | +│ ├──constants | ||
| 49 | +│ │ └──CommonConstants.ets // 公共常量类 | ||
| 50 | +│ ├──entryability | ||
| 51 | +│ │ └──EntryAbility.ets // 应用入口,处理接续逻辑 | ||
| 52 | +│ ├──entrybackupability | ||
| 53 | +│ │ └──EntryBackupAbility.ets // 应用备份能力 | ||
| 54 | +│ ├──model | ||
| 55 | +│ │ └──CommModel.ets // 公共实体类 | ||
| 56 | +│ ├──pages | ||
| 57 | +│ │ └──Index.ets // 主页面 | ||
| 58 | +│ ├──utils | ||
| 59 | +│ │ ├──BreakpointSystem.ets // 断点适配工具类 | ||
| 60 | +│ │ ├──DebounceUtil.ets // 防抖工具类 | ||
| 61 | +│ │ └──FileUtil.ets // 文件选择工具类 | ||
| 62 | +│ ├──viewModel | ||
| 63 | +│ │ ├──AddPicViewModel.ets // 添加图片业务逻辑 | ||
| 64 | +│ │ ├──ContinuationViewModel.ets // 应用接续业务逻辑 | ||
| 65 | +│ │ └──ImageViewModel.ets // 图片处理业务逻辑 | ||
| 66 | +│ └──view | ||
| 67 | +│ ├──AddPic.ets // 添加图片组件 | ||
| 68 | +│ ├──MigrateDataWantParamView.ets // want.param迁移页面 | ||
| 69 | +│ ├──MigrateDataDistributedBaseView.ets // 分布式对象基础数据迁移页面 | ||
| 70 | +│ ├──MigrateDataDistributedMonoFileView.ets // 分布式对象单文件迁移页面 | ||
| 71 | +│ └──MigrateDataDistributedMultiFileView.ets // 分布式对象多文件迁移页面 | ||
| 72 | +└──entry/src/main/resources // 应用资源目录 | ||
| 73 | +``` | ||
| 74 | + | ||
| 75 | +## 相关权限 | ||
| 76 | + | ||
| 77 | +- 申请分布式数据同步权限:ohos.permission.DISTRIBUTED_DATASYNC。 | ||
| 78 | + | ||
| 79 | +## 依赖 | ||
| 80 | + | ||
| 81 | +不涉及 | ||
| 82 | + | ||
| 83 | +## 约束与限制 | ||
| 84 | + | ||
| 85 | +1. 本示例仅支持标准系统上运行,支持设备:手机。 | ||
| 86 | + | ||
| 87 | +2. HarmonyOS系统:HarmonyOS 6.1.0 Release及以上。 | ||
| 88 | + | ||
| 89 | +3. DevEco Studio版本:DevEco Studio 6.1.1 Release及以上。 | ||
| 90 | + | ||
| 91 | +4. HarmonyOS SDK版本:HarmonyOS 6.1.1 Release SDK及以上。 | ||
| 92 | + | ||
| 93 | +5. 双端设备需要登录同一华为账号。 | ||
| 94 | + | ||
| 95 | +6. 双端设备需要打开Wi-Fi和蓝牙开关。条件允许时,建议双端设备接入同一个局域网,可提升数据传输的速度。 | ||
| 96 | + | ||
| 97 | +7. 应用接续只能在同应用(UIAbility)之间触发,双端设备都需要有该应用。 | ||
| @@ -0,0 +1,42 @@ | |||
| 1 | +{ | ||
| 2 | + "app": { | ||
| 3 | + "signingConfigs": [], | ||
| 4 | + "products": [ | ||
| 5 | + { | ||
| 6 | + "name": "default", | ||
| 7 | + "signingConfig": "default", | ||
| 8 | + "targetSdkVersion": "6.1.1(24)", | ||
| 9 | + "compatibleSdkVersion": "6.1.0(23)", | ||
| 10 | + "runtimeOS": "HarmonyOS", | ||
| 11 | + "buildOption": { | ||
| 12 | + "strictMode": { | ||
| 13 | + "caseSensitiveCheck": true, | ||
| 14 | + "useNormalizedOHMUrl": true | ||
| 15 | + } | ||
| 16 | + } | ||
| 17 | + } | ||
| 18 | + ], | ||
| 19 | + "buildModeSet": [ | ||
| 20 | + { | ||
| 21 | + "name": "debug", | ||
| 22 | + }, | ||
| 23 | + { | ||
| 24 | + "name": "release" | ||
| 25 | + } | ||
| 26 | + ] | ||
| 27 | + }, | ||
| 28 | + "modules": [ | ||
| 29 | + { | ||
| 30 | + "name": "entry", | ||
| 31 | + "srcPath": "./entry", | ||
| 32 | + "targets": [ | ||
| 33 | + { | ||
| 34 | + "name": "default", | ||
| 35 | + "applyToProducts": [ | ||
| 36 | + "default" | ||
| 37 | + ] | ||
| 38 | + } | ||
| 39 | + ] | ||
| 40 | + } | ||
| 41 | + ] | ||
| 42 | +} | ||
| @@ -0,0 +1,30 @@ | |||
| 1 | +{ | ||
| 2 | + "apiType": "stageMode", | ||
| 3 | + "buildOption": { | ||
| 4 | + "resOptions": { | ||
| 5 | + "copyCodeResource": { | ||
| 6 | + "enable": false | ||
| 7 | + } | ||
| 8 | + } | ||
| 9 | + }, | ||
| 10 | + "buildOptionSet": [ | ||
| 11 | + { | ||
| 12 | + "name": "release", | ||
| 13 | + "arkOptions": { | ||
| 14 | + "obfuscation": { | ||
| 15 | + "ruleOptions": { | ||
| 16 | + "enable": false, | ||
| 17 | + "files": [ | ||
| 18 | + "./obfuscation-rules.txt" | ||
| 19 | + ] | ||
| 20 | + } | ||
| 21 | + } | ||
| 22 | + } | ||
| 23 | + }, | ||
| 24 | + ], | ||
| 25 | + "targets": [ | ||
| 26 | + { | ||
| 27 | + "name": "default" | ||
| 28 | + } | ||
| 29 | + ] | ||
| 30 | +} | ||
| @@ -0,0 +1,6 @@ | |||
| 1 | +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; | ||
| 2 | + | ||
| 3 | +export default { | ||
| 4 | + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ | ||
| 5 | + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ | ||
| 6 | +} | ||
| @@ -0,0 +1,23 @@ | |||
| 1 | +# Define project specific obfuscation rules here. | ||
| 2 | +# You can include the obfuscation configuration files in the current module's build-profile.json5. | ||
| 3 | +# | ||
| 4 | +# For more details, see | ||
| 5 | +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/source-obfuscation | ||
| 6 | + | ||
| 7 | +# Obfuscation options: | ||
| 8 | +# -disable-obfuscation: disable all obfuscations | ||
| 9 | +# -enable-property-obfuscation: obfuscate the property names | ||
| 10 | +# -enable-toplevel-obfuscation: obfuscate the names in the global scope | ||
| 11 | +# -compact: remove unnecessary blank spaces and all line feeds | ||
| 12 | +# -remove-log: remove all console.* statements | ||
| 13 | +# -print-namecache: print the name cache that contains the mapping from the old names to new names | ||
| 14 | +# -apply-namecache: reuse the given cache file | ||
| 15 | + | ||
| 16 | +# Keep options: | ||
| 17 | +# -keep-property-name: specifies property names that you want to keep | ||
| 18 | +# -keep-global-name: specifies names that you want to keep in the global scope | ||
| 19 | + | ||
| 20 | +-enable-property-obfuscation | ||
| 21 | +-enable-toplevel-obfuscation | ||
| 22 | +-enable-filename-obfuscation | ||
| 23 | +-enable-export-obfuscation | ||
| @@ -0,0 +1,10 @@ | |||
| 1 | +{ | ||
| 2 | + "name": "entry", | ||
| 3 | + "version": "1.0.0", | ||
| 4 | + "description": "Please describe the basic information.", | ||
| 5 | + "main": "", | ||
| 6 | + "author": "", | ||
| 7 | + "license": "", | ||
| 8 | + "dependencies": {} | ||
| 9 | +} | ||
| 10 | + | ||
| @@ -0,0 +1,36 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +export default class CommonConstants { | ||
| 17 | + public static readonly NAVIGATION_BUTTON_NAME: string[] = [ | ||
| 18 | + 'want', | ||
| 19 | + 'distributed_base', | ||
| 20 | + 'distributed_mono_file', | ||
| 21 | + 'distributed_multi_file' | ||
| 22 | + ]; | ||
| 23 | + public static readonly PAGE_STACK_PATHNAME: string[] = [ | ||
| 24 | + 'migrateDataWantParamView', | ||
| 25 | + 'migrateDataDistributedBaseView', | ||
| 26 | + 'migrateDataDistributedMonoFileView', | ||
| 27 | + 'migrateDataDistributedMultiFileView' | ||
| 28 | + ]; | ||
| 29 | + public static readonly BUTTON_NAME: string[] = [ | ||
| 30 | + 'migrate_data_want_param', | ||
| 31 | + 'migrate_data_distributed_base', | ||
| 32 | + 'migrate_data_distributed_mono_file', | ||
| 33 | + 'migrate_data_distributed_multi_file' | ||
| 34 | + ]; | ||
| 35 | + public static readonly FULL_PERCENT: string = '100%'; | ||
| 36 | +} | ||
| @@ -0,0 +1,185 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; | ||
| 17 | +import { commonType, distributedDataObject } from '@kit.ArkData'; | ||
| 18 | +import { BusinessError } from '@kit.BasicServicesKit'; | ||
| 19 | +import { hilog } from '@kit.PerformanceAnalysisKit'; | ||
| 20 | +import { window } from '@kit.ArkUI'; | ||
| 21 | +import { ContinuationData, ImageInfo } from '../model/CommModel'; | ||
| 22 | +import { ContinuationViewModel } from '../viewModel/ContinuationViewModel'; | ||
| 23 | + | ||
| 24 | +const DOMAIN = 0x0000; | ||
| 25 | +const TAG = 'EntryAbility'; | ||
| 26 | +const FORMAT = '%{public}s'; | ||
| 27 | + | ||
| 28 | +export default class EntryAbility extends UIAbility { | ||
| 29 | + private distributedObject: distributedDataObject.DataObject | undefined = undefined; | ||
| 30 | + private storage: LocalStorage = new LocalStorage(); | ||
| 31 | + private continuationViewModel: ContinuationViewModel | undefined = undefined; | ||
| 32 | + | ||
| 33 | + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { | ||
| 34 | + hilog.info(DOMAIN, TAG, FORMAT, `Ability onCreate`); | ||
| 35 | + this.continuationViewModel = new ContinuationViewModel(this.context); | ||
| 36 | + this.appContinuity(want, launchParam); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { | ||
| 40 | + hilog.info(DOMAIN, TAG, FORMAT, `Ability onNewWant`); | ||
| 41 | + this.appContinuity(want, launchParam); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + appContinuity(want: Want, launchParam: AbilityConstant.LaunchParam) { | ||
| 45 | + if (launchParam.launchReason === AbilityConstant.LaunchReason.CONTINUATION) { | ||
| 46 | + if (want.parameters !== undefined) { | ||
| 47 | + // Single data | ||
| 48 | + AppStorage.setOrCreate('basicDataStr', want.parameters.basicDataStr); | ||
| 49 | + AppStorage.setOrCreate('basicDataNum', want.parameters.basicDataNum); | ||
| 50 | + AppStorage.setOrCreate('wantBasicData', want.parameters.WantBasic); | ||
| 51 | + } | ||
| 52 | + let mailInfo: ContinuationData = new ContinuationData(undefined, undefined, undefined, undefined, undefined, | ||
| 53 | + undefined, undefined, undefined, undefined, undefined); | ||
| 54 | + this.distributedObject = distributedDataObject.create(this.context, mailInfo); | ||
| 55 | + // Add a data restored listener. | ||
| 56 | + try { | ||
| 57 | + this.distributedObject.on('status', | ||
| 58 | + (_sessionId: string, _networkId: string, status: 'online' | 'offline' | 'restored') => { | ||
| 59 | + hilog.info(DOMAIN, TAG, FORMAT, `status changed, sessionId: ****`); | ||
| 60 | + hilog.info(DOMAIN, TAG, FORMAT, `status changed, status: ${status}`); | ||
| 61 | + hilog.info(DOMAIN, TAG, FORMAT, `status changed, networkId: ****`); | ||
| 62 | + if (status === 'restored') { | ||
| 63 | + if (!this.distributedObject || !this.continuationViewModel) { | ||
| 64 | + return; | ||
| 65 | + } | ||
| 66 | + AppStorage.setOrCreate('basicDataStr', this.distributedObject['basicDataStr']); | ||
| 67 | + AppStorage.setOrCreate('basicDataNum', this.distributedObject['basicDataNum']); | ||
| 68 | + AppStorage.setOrCreate('distributedData', this.distributedObject['distributedData']); | ||
| 69 | + | ||
| 70 | + AppStorage.setOrCreate('monoFileStr', this.distributedObject['monoFileStr']); | ||
| 71 | + AppStorage.setOrCreate('monoFileNum', this.distributedObject['monoFileNum']); | ||
| 72 | + AppStorage.setOrCreate('attachment', this.distributedObject['attachment']); | ||
| 73 | + let attachment = this.distributedObject['attachment'] as commonType.Assets; | ||
| 74 | + for (const attachments of attachment) { | ||
| 75 | + this.continuationViewModel.fileCopy(attachments, true); | ||
| 76 | + } | ||
| 77 | + AppStorage.setOrCreate<ImageInfo>('imageUri', this.continuationViewModel.imageUri); | ||
| 78 | + | ||
| 79 | + AppStorage.setOrCreate('multiFileStr', this.distributedObject['multiFileStr']); | ||
| 80 | + AppStorage.setOrCreate('multiFileNum', this.distributedObject['multiFileNum']); | ||
| 81 | + AppStorage.setOrCreate('attachments', this.distributedObject['attachments']); | ||
| 82 | + let attachments = this.distributedObject['attachments'] as commonType.Assets; | ||
| 83 | + for (const attachment of attachments) { | ||
| 84 | + this.continuationViewModel.fileCopy(attachment); | ||
| 85 | + } | ||
| 86 | + AppStorage.setOrCreate<Array<ImageInfo>>('imageUriArray', this.continuationViewModel.imageUriArray); | ||
| 87 | + | ||
| 88 | + AppStorage.setOrCreate('curPageInfos', this.distributedObject['curPageInfos']); | ||
| 89 | + } | ||
| 90 | + }); | ||
| 91 | + } catch (err) { | ||
| 92 | + hilog.error(DOMAIN, TAG, FORMAT, `On status failed. Cause code: ${err.code}`); | ||
| 93 | + } | ||
| 94 | + let sessionId: string = want.parameters?.distributedSessionId as string; | ||
| 95 | + this.distributedObject.setSessionId(sessionId).catch((err: BusinessError) => { | ||
| 96 | + hilog.info(DOMAIN, TAG, FORMAT, `SetSessionId failed. Cause code: ${err.code}`); | ||
| 97 | + }); | ||
| 98 | + try { | ||
| 99 | + // Restore window stage with new LocalStorage instance | ||
| 100 | + this.context.restoreWindowStage(this.storage); | ||
| 101 | + } catch (err) { | ||
| 102 | + hilog.error(DOMAIN, TAG, FORMAT, `RestoreWindowStage failed. Cause: ${(err as BusinessError).code}`); | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + async onContinue(wantParam: Record<string, Object | undefined>): Promise<AbilityConstant.OnContinueResult> { | ||
| 108 | + if (!this.continuationViewModel) { | ||
| 109 | + return AbilityConstant.OnContinueResult.REJECT; | ||
| 110 | + } | ||
| 111 | + // Migrate simple data using wantParam.param | ||
| 112 | + wantParam.WantBasic = AppStorage.get('wantBasicData'); | ||
| 113 | + // Migrate basic data using distributed object | ||
| 114 | + wantParam.distributedData = AppStorage.get('distributedData'); | ||
| 115 | + // Migrate single file using distributed object | ||
| 116 | + wantParam.imageUri = AppStorage.get('imageUri'); | ||
| 117 | + // Migrate multiple files using distributed object | ||
| 118 | + wantParam.imageUriArray = AppStorage.get('imageUriArray'); | ||
| 119 | + let sessionId: string = distributedDataObject.genSessionId(); | ||
| 120 | + wantParam.distributedSessionId = sessionId; | ||
| 121 | + let imageUri = AppStorage.get<ImageInfo>('imageUri'); | ||
| 122 | + let asset = this.continuationViewModel.buildAssetsFromImageInfo(imageUri); | ||
| 123 | + | ||
| 124 | + let imageUriArray = AppStorage.get<Array<ImageInfo>>('imageUriArray'); | ||
| 125 | + let assets = this.continuationViewModel.buildAssetsFromImageArray(imageUriArray); | ||
| 126 | + | ||
| 127 | + let contentInfo: ContinuationData = new ContinuationData( | ||
| 128 | + AppStorage.get('basicDataStr'), | ||
| 129 | + AppStorage.get('basicDataNum'), | ||
| 130 | + AppStorage.get('distributedData'), | ||
| 131 | + | ||
| 132 | + AppStorage.get('monoFileStr'), | ||
| 133 | + AppStorage.get('monoFileNum'), | ||
| 134 | + asset, | ||
| 135 | + | ||
| 136 | + AppStorage.get('multiFileStr'), | ||
| 137 | + AppStorage.get('multiFileNum'), | ||
| 138 | + assets, | ||
| 139 | + | ||
| 140 | + (AppStorage.get('pageInfos') as NavPathStack).getAllPathName()[0] | ||
| 141 | + ); | ||
| 142 | + let source = contentInfo.flatAssets(); | ||
| 143 | + this.distributedObject = distributedDataObject.create(this.context, source); | ||
| 144 | + this.distributedObject.setSessionId(sessionId).catch((err: BusinessError) => { | ||
| 145 | + hilog.info(DOMAIN, TAG, FORMAT, `SetSessionId failed. Cause code: ${err.code}`); | ||
| 146 | + }); | ||
| 147 | + await this.distributedObject.save(wantParam.targetDevice as string).catch((err: BusinessError) => { | ||
| 148 | + hilog.info(DOMAIN, TAG, FORMAT, `Failed to save. Code: ${err.code}`); | ||
| 149 | + }); | ||
| 150 | + // Return AGREE to allow cross-device migration | ||
| 151 | + return AbilityConstant.OnContinueResult.AGREE; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + onDestroy(): void { | ||
| 155 | + hilog.info(DOMAIN, TAG, FORMAT, `Ability onDestroy`); | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + onWindowStageCreate(windowStage: window.WindowStage): void { | ||
| 159 | + // Main window is created, set main page for this ability | ||
| 160 | + hilog.info(DOMAIN, TAG, FORMAT, `Ability onWindowStageCreate`); | ||
| 161 | + | ||
| 162 | + windowStage.loadContent('pages/Index', (err) => { | ||
| 163 | + if (err.code) { | ||
| 164 | + hilog.error(DOMAIN, TAG, FORMAT, `Failed to load the content. Cause code: ${err.code}`); | ||
| 165 | + return; | ||
| 166 | + } | ||
| 167 | + hilog.info(DOMAIN, TAG, FORMAT, `Succeeded in loading the content`); | ||
| 168 | + }); | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + onWindowStageDestroy(): void { | ||
| 172 | + // Main window is destroyed, release UI related resources | ||
| 173 | + hilog.info(DOMAIN, TAG, FORMAT, `Ability onWindowStageDestroy`); | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + onForeground(): void { | ||
| 177 | + // Ability has brought to foreground | ||
| 178 | + hilog.info(DOMAIN, TAG, FORMAT, `Ability onForeground`); | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + onBackground(): void { | ||
| 182 | + // Ability has back to background | ||
| 183 | + hilog.info(DOMAIN, TAG, FORMAT, `Ability onBackground`); | ||
| 184 | + } | ||
| 185 | +} | ||
| @@ -0,0 +1,31 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; | ||
| 17 | +import { hilog } from '@kit.PerformanceAnalysisKit'; | ||
| 18 | + | ||
| 19 | +const DOMAIN = 0x0000; | ||
| 20 | +const TAG = 'EntryBackupAbility'; | ||
| 21 | +const FORMAT = '%{public}s'; | ||
| 22 | + | ||
| 23 | +export default class EntryBackupAbility extends BackupExtensionAbility { | ||
| 24 | + onBackup(): void { | ||
| 25 | + hilog.info(DOMAIN, TAG, FORMAT, `onBackup ok`); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + onRestore(): void { | ||
| 29 | + hilog.info(DOMAIN, TAG, FORMAT, `onRestore ok`); | ||
| 30 | + } | ||
| 31 | +} | ||
| @@ -0,0 +1,102 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +import { commonType } from '@kit.ArkData'; | ||
| 17 | + | ||
| 18 | +export interface DistributedData { | ||
| 19 | + str: string; | ||
| 20 | + num: number | null; | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +export interface ImageInfo { | ||
| 24 | + imagePixelMap: PixelMap; | ||
| 25 | + imageName: string; | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +export interface DistributedBaseData { | ||
| 29 | + basicDataStr: string | undefined; | ||
| 30 | + basicDataNum: number | undefined; | ||
| 31 | + distributedData: DistributedData | undefined; | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +export interface DistributedUniFileData { | ||
| 35 | + monoFileStr: string | undefined; | ||
| 36 | + monoFileNum: number | undefined; | ||
| 37 | + attachment: commonType.Assets | undefined; | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +export interface DistributedMultiFileData { | ||
| 41 | + multiFileStr: string | undefined; | ||
| 42 | + multiFileNum: number | undefined; | ||
| 43 | + attachments: commonType.Assets | undefined; | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | + | ||
| 47 | +export class ContinuationData { | ||
| 48 | + basicDataStr: string | undefined; | ||
| 49 | + basicDataNum: number | undefined; | ||
| 50 | + distributedData: DistributedData | undefined; | ||
| 51 | + | ||
| 52 | + monoFileStr: string | undefined; | ||
| 53 | + monoFileNum: number | undefined; | ||
| 54 | + attachment: commonType.Assets | undefined; | ||
| 55 | + | ||
| 56 | + multiFileStr: string | undefined; | ||
| 57 | + multiFileNum: number | undefined; | ||
| 58 | + attachments: commonType.Assets | undefined; | ||
| 59 | + | ||
| 60 | + curPageInfos: string | undefined; | ||
| 61 | + constructor( | ||
| 62 | + basicDataStr: string | undefined, | ||
| 63 | + basicDataNum: number | undefined, | ||
| 64 | + distributedData: DistributedData | undefined, | ||
| 65 | + | ||
| 66 | + monoFileStr: string | undefined, | ||
| 67 | + monoFileNum: number | undefined, | ||
| 68 | + attachment: commonType.Assets | undefined, | ||
| 69 | + | ||
| 70 | + multiFileStr: string | undefined, | ||
| 71 | + multiFileNum: number | undefined, | ||
| 72 | + attachments: commonType.Assets | undefined, | ||
| 73 | + | ||
| 74 | + curPageInfos: string | undefined | ||
| 75 | + ) { | ||
| 76 | + this.basicDataStr = basicDataStr; | ||
| 77 | + this.basicDataNum = basicDataNum; | ||
| 78 | + this.distributedData = distributedData; | ||
| 79 | + | ||
| 80 | + this.monoFileStr = monoFileStr; | ||
| 81 | + this.monoFileNum = monoFileNum; | ||
| 82 | + this.attachment = attachment; | ||
| 83 | + | ||
| 84 | + this.multiFileStr = multiFileStr; | ||
| 85 | + this.multiFileNum = multiFileNum; | ||
| 86 | + this.attachments = attachments; | ||
| 87 | + | ||
| 88 | + this.curPageInfos = curPageInfos; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + flatAssets(): object { | ||
| 92 | + let obj: object = this; | ||
| 93 | + if (!this.attachments) { | ||
| 94 | + return obj; | ||
| 95 | + } | ||
| 96 | + obj[`attachment`] = this.attachment; | ||
| 97 | + for (let i = 0; i < this.attachments.length; i++) { | ||
| 98 | + obj[`attachments${i}`] = this.attachments[i]; | ||
| 99 | + } | ||
| 100 | + return obj; | ||
| 101 | + } | ||
| 102 | +} | ||
| @@ -0,0 +1,55 @@ | |||
| 1 | +/* | ||
| 2 | +* Copyright (C) 2026 Huawei Device Co., Ltd. | ||
| 3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | +* you may not use this file except in compliance with the License. | ||
| 5 | +* You may obtain a copy of the License at | ||
| 6 | +* | ||
| 7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | +* | ||
| 9 | +* Unless required by applicable law or agreed to in writing, software | ||
| 10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | +* See the License for the specific language governing permissions and | ||
| 13 | +* limitations under the License. | ||
| 14 | +*/ | ||
| 15 | + | ||
| 16 | +import CommonConstants from '../constants/CommonConstants'; | ||
| 17 | + | ||
| 18 | +@Entry | ||
| 19 | +@Component | ||
| 20 | +struct Index { | ||
| 21 | + @StorageLink('pageInfos') pageInfos: NavPathStack = new NavPathStack(); | ||
| 22 | + | ||
| 23 | + aboutToAppear(): void { | ||
| 24 | + if (AppStorage.get('curPageInfos')) { | ||
| 25 | + this.pageInfos.pushPathByName(AppStorage.get('curPageInfos'), null); | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + build() { | ||
| 30 | + Navigation(this.pageInfos) { | ||
| 31 | + Column() { | ||
| 32 | + ForEach(CommonConstants.NAVIGATION_BUTTON_NAME, (item: string, index: number) => { | ||
| 33 | + Button($r('app.string.' + CommonConstants.BUTTON_NAME[index])) | ||
| 34 | + .width(CommonConstants.FULL_PERCENT) | ||
| 35 | + .height(40) | ||
| 36 | + .id(item) | ||
| 37 | + .margin({ bottom: index === CommonConstants.NAVIGATION_BUTTON_NAME.length - 1 ? 0 : 12 }) | ||
| 38 | + .backgroundColor($r('app.color.button_background')) | ||
| 39 | + .fontColor($r('app.color.button_font')) | ||
| 40 | + .onClick(() => { | ||
| 41 | + this.pageInfos.pushPathByName(CommonConstants.PAGE_STACK_PATHNAME[index], null); | ||
| 42 | + }) | ||
| 43 | + }, (name: string) => name.toString()) | ||
| 44 | + } | ||
| 45 | + .width(CommonConstants.FULL_PERCENT) | ||
| 46 | + .height(CommonConstants.FULL_PERCENT) | ||
| 47 | + .padding(16) | ||
| 48 | + .justifyContent(FlexAlign.End) | ||
| 49 | + } | ||
| 50 | + .title($r('app.string.EntryAbility_label')) | ||
| 51 | + .height(CommonConstants.FULL_PERCENT) | ||
| 52 | + .width(CommonConstants.FULL_PERCENT) | ||
| 53 | + .backgroundColor($r('app.color.page_background')) | ||
| 54 | + } | ||
| 55 | +} | ||
| @@ -0,0 +1,92 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +import { hilog } from '@kit.PerformanceAnalysisKit'; | ||
| 17 | +import { display, window } from '@kit.ArkUI'; | ||
| 18 | + | ||
| 19 | +const DOMAIN = 0x0000; | ||
| 20 | +const TAG = 'BreakpointSystem'; | ||
| 21 | +const FORMAT = '%{public}s'; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * Breakpoint type generic class | ||
| 25 | + * Used to store and return values of corresponding types based on different screen breakpoint sizes | ||
| 26 | + * Supports four breakpoint types: xs (ultra-small screen), sm (small screen), md (medium screen), lg (large screen) | ||
| 27 | + */ | ||
| 28 | +export class BreakpointType<T> { | ||
| 29 | + private xs: T; | ||
| 30 | + private sm: T; | ||
| 31 | + private md: T; | ||
| 32 | + private lg: T; | ||
| 33 | + | ||
| 34 | + constructor(xs: T, sm: T, md: T, lg: T) { | ||
| 35 | + this.xs = xs; | ||
| 36 | + this.sm = sm; | ||
| 37 | + this.md = md; | ||
| 38 | + this.lg = lg; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * Obtain the corresponding value based on the current breakpoint type | ||
| 43 | + */ | ||
| 44 | + getValue(currentBreakpoint: string): T { | ||
| 45 | + const validBreakpoints = ['xs', 'sm', 'md', 'lg']; | ||
| 46 | + // Check whether the incoming breakpoint type is valid | ||
| 47 | + if (!validBreakpoints.includes(currentBreakpoint)) { | ||
| 48 | + return this.xs; | ||
| 49 | + } | ||
| 50 | + // Return the corresponding value based on the breakpoint type | ||
| 51 | + switch (currentBreakpoint) { | ||
| 52 | + case 'xs': | ||
| 53 | + return this.xs; | ||
| 54 | + case 'sm': | ||
| 55 | + return this.sm; | ||
| 56 | + case 'md': | ||
| 57 | + return this.md; | ||
| 58 | + case 'lg': | ||
| 59 | + return this.lg; | ||
| 60 | + default: | ||
| 61 | + return this.lg; | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +/** | ||
| 67 | + * Update breakpoints based on current window size | ||
| 68 | + * Analyze window width to determine the breakpoint type for the current device and update global state | ||
| 69 | + */ | ||
| 70 | +export function updateBreakpoint(windowWidth: number, windowObj?: window.Window, curBp?: string): string { | ||
| 71 | + try { | ||
| 72 | + let displayId = windowObj?.getWindowProperties().displayId; | ||
| 73 | + let windowWidthVp = windowWidth / display.getDisplayByIdSync(displayId).densityPixels; | ||
| 74 | + let newBp: string = ''; | ||
| 75 | + if (windowWidthVp < 320) { | ||
| 76 | + newBp = 'xs'; | ||
| 77 | + } else if (windowWidthVp < 600) { | ||
| 78 | + newBp = 'sm'; | ||
| 79 | + } else if (windowWidthVp < 840) { | ||
| 80 | + newBp = 'md'; | ||
| 81 | + } else { | ||
| 82 | + newBp = 'lg'; | ||
| 83 | + } | ||
| 84 | + if (curBp !== newBp) { | ||
| 85 | + AppStorage.setOrCreate('currentBreakpoint', newBp); | ||
| 86 | + } | ||
| 87 | + return newBp; | ||
| 88 | + } catch (err) { | ||
| 89 | + hilog.error(DOMAIN, TAG, FORMAT, `GetDisplayByIdSync or getWindowProperties failed.`); | ||
| 90 | + return curBp ?? ''; | ||
| 91 | + } | ||
| 92 | +} | ||
| @@ -0,0 +1,30 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +export class DebounceUtil { | ||
| 17 | + private static timers: Map<string, number> = new Map<string, number>(); | ||
| 18 | + | ||
| 19 | + static debounce(key: string, callback: () => void, delay: number = 500): void { | ||
| 20 | + const existingTimer = DebounceUtil.timers.get(key); | ||
| 21 | + if (existingTimer) { | ||
| 22 | + clearTimeout(existingTimer); | ||
| 23 | + } | ||
| 24 | + const timer = setTimeout(() => { | ||
| 25 | + callback(); | ||
| 26 | + DebounceUtil.timers.delete(key); | ||
| 27 | + }, delay); | ||
| 28 | + DebounceUtil.timers.set(key, timer); | ||
| 29 | + } | ||
| 30 | +} | ||
| @@ -0,0 +1,45 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +import { photoAccessHelper } from '@kit.MediaLibraryKit'; | ||
| 17 | +import { hilog } from '@kit.PerformanceAnalysisKit'; | ||
| 18 | + | ||
| 19 | +const DOMAIN = 0x0000; | ||
| 20 | +const TAG = 'FileUtil'; | ||
| 21 | +const FORMAT = '%{public}s'; | ||
| 22 | + | ||
| 23 | +/* | ||
| 24 | + * Select a picture from the gallery. | ||
| 25 | + * @returns uri The uri for the selected file. | ||
| 26 | + */ | ||
| 27 | +export async function fileSelect(isSingleImage: boolean): Promise<Array<string>> { | ||
| 28 | + let imgUri: Array<string> = []; | ||
| 29 | + let PhotoSelectOptions = new photoAccessHelper.PhotoSelectOptions(); | ||
| 30 | + PhotoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE; | ||
| 31 | + PhotoSelectOptions.maxSelectNumber = (isSingleImage ? 1 : 9); | ||
| 32 | + let photoPicker = new photoAccessHelper.PhotoViewPicker(); | ||
| 33 | + try { | ||
| 34 | + let PhotoSelectResult = await photoPicker.select(PhotoSelectOptions); | ||
| 35 | + if (PhotoSelectResult && PhotoSelectResult.photoUris && PhotoSelectResult.photoUris.length > 0) { | ||
| 36 | + imgUri = PhotoSelectResult.photoUris; | ||
| 37 | + return imgUri; | ||
| 38 | + } else { | ||
| 39 | + return []; | ||
| 40 | + } | ||
| 41 | + } catch (error) { | ||
| 42 | + hilog.error(DOMAIN, TAG, FORMAT, `PhotoViewPicker failed with err code: ${error.code}`); | ||
| 43 | + return []; | ||
| 44 | + } | ||
| 45 | +} | ||
| @@ -0,0 +1,136 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +import { hilog } from '@kit.PerformanceAnalysisKit'; | ||
| 17 | +import { SymbolGlyphModifier } from '@kit.ArkUI'; | ||
| 18 | +import { common } from '@kit.AbilityKit'; | ||
| 19 | +import { ImageInfo } from '../model/CommModel'; | ||
| 20 | +import { AddPicViewModel } from '../viewModel/AddPicViewModel'; | ||
| 21 | +import { BreakpointType } from '../utils/BreakpointSystem'; | ||
| 22 | +import CommonConstants from '../constants/CommonConstants'; | ||
| 23 | + | ||
| 24 | +const DOMAIN = 0x0000; | ||
| 25 | +const TAG = 'AddPic'; | ||
| 26 | +const FORMAT = '%{public}s'; | ||
| 27 | + | ||
| 28 | +@Component | ||
| 29 | +export struct AddPic { | ||
| 30 | + @StorageLink('imageUri') imageUri: ImageInfo | null = null; | ||
| 31 | + @StorageLink('imageUriArray') imageUriArray: Array<ImageInfo> = []; | ||
| 32 | + @StorageLink('currentBreakpoint') currentBreakpoint: string = 'sm'; | ||
| 33 | + @Link isSingleImage: boolean; | ||
| 34 | + private context = this.getUIContext().getHostContext() as common.UIAbilityContext; | ||
| 35 | + private viewModel: AddPicViewModel = new AddPicViewModel(this.context, (message: ResourceStr) => { | ||
| 36 | + try { | ||
| 37 | + this.getUIContext().getPromptAction().showToast({ message: message }); | ||
| 38 | + } catch (err) { | ||
| 39 | + hilog.error(DOMAIN, TAG, FORMAT, `ShowToast failed. Cause ${err}`); | ||
| 40 | + } | ||
| 41 | + }); | ||
| 42 | + | ||
| 43 | + aboutToAppear(): void { | ||
| 44 | + this.viewModel.updateImageArray(this.imageUriArray); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + build() { | ||
| 48 | + this.addPic(); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Builder | ||
| 52 | + addPic() { | ||
| 53 | + Row() { | ||
| 54 | + if (this.isSingleImage) { | ||
| 55 | + if (this.imageUri) { | ||
| 56 | + Image(this.imageUri.imagePixelMap) | ||
| 57 | + .width(96) | ||
| 58 | + .height(96) | ||
| 59 | + .borderRadius(10) | ||
| 60 | + .visibility(Visibility.Visible) | ||
| 61 | + .draggable(false) | ||
| 62 | + .margin({ | ||
| 63 | + left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level8'), | ||
| 64 | + $r('sys.float.padding_level12'), $r('sys.float.padding_level16')).getValue(this.currentBreakpoint) | ||
| 65 | + }) | ||
| 66 | + } else { | ||
| 67 | + this.addDefaultPic() | ||
| 68 | + } | ||
| 69 | + } else { | ||
| 70 | + List({ space: 8 }) { | ||
| 71 | + ForEach(this.imageUriArray, (item: ImageInfo, index: number) => { | ||
| 72 | + ListItem() { | ||
| 73 | + Image(item.imagePixelMap) | ||
| 74 | + .width(96) | ||
| 75 | + .height(96) | ||
| 76 | + .borderRadius(10) | ||
| 77 | + .visibility(item ? Visibility.Visible : Visibility.None) | ||
| 78 | + .draggable(false) | ||
| 79 | + } | ||
| 80 | + .margin({ | ||
| 81 | + left: index === 0 ? new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level8'), | ||
| 82 | + $r('sys.float.padding_level12'), $r('sys.float.padding_level16')).getValue(this.currentBreakpoint) : 0 | ||
| 83 | + }) | ||
| 84 | + }, (item: ImageInfo, index: number) => JSON.stringify(item) + index) | ||
| 85 | + if ((this.imageUriArray.length === 0 && this.isSingleImage) || | ||
| 86 | + (this.imageUriArray.length < 9 && !this.isSingleImage)) { | ||
| 87 | + this.addDefaultPic() | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + .listDirection(Axis.Horizontal) | ||
| 91 | + .scrollBar(BarState.Off) | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + .height(96) | ||
| 95 | + .width(CommonConstants.FULL_PERCENT) | ||
| 96 | + .alignItems(VerticalAlign.Center) | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + @Builder | ||
| 100 | + MyTestMenu() { | ||
| 101 | + Menu() { | ||
| 102 | + MenuItem({ | ||
| 103 | + symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.picture_2')), | ||
| 104 | + content: $r('app.string.local_device') | ||
| 105 | + }) | ||
| 106 | + .onClick(() => { | ||
| 107 | + this.viewModel.updateImageArray(this.imageUriArray); | ||
| 108 | + this.viewModel.selectImage(this.isSingleImage); | ||
| 109 | + }) | ||
| 110 | + } | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + @Builder | ||
| 114 | + addDefaultPic() { | ||
| 115 | + Row() { | ||
| 116 | + Column() { | ||
| 117 | + SymbolGlyph($r('sys.symbol.plus')) | ||
| 118 | + .fontSize(26) | ||
| 119 | + .fontColor([$r('sys.color.font_primary')]) | ||
| 120 | + Text(this.viewModel.getButtonText(this.isSingleImage, this.imageUri !== null, this.imageUriArray.length)) | ||
| 121 | + .fontSize(12) | ||
| 122 | + .fontColor($r('app.color.text_font_gray')) | ||
| 123 | + .margin({ top: 8 }) | ||
| 124 | + } | ||
| 125 | + .justifyContent(FlexAlign.Center) | ||
| 126 | + .width(CommonConstants.FULL_PERCENT) | ||
| 127 | + } | ||
| 128 | + .borderStyle(BorderStyle.Dashed) | ||
| 129 | + .borderWidth(1) | ||
| 130 | + .borderColor($r('app.color.border_color')) | ||
| 131 | + .borderRadius(10) | ||
| 132 | + .width(96) | ||
| 133 | + .height(96) | ||
| 134 | + .bindMenu(this.MyTestMenu()) | ||
| 135 | + } | ||
| 136 | +} | ||
| @@ -0,0 +1,88 @@ | |||
| 1 | +/* | ||
| 2 | +* Copyright (C) 2026 Huawei Device Co., Ltd. | ||
| 3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | +* you may not use this file except in compliance with the License. | ||
| 5 | +* You may obtain a copy of the License at | ||
| 6 | +* | ||
| 7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | +* | ||
| 9 | +* Unless required by applicable law or agreed to in writing, software | ||
| 10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | +* See the License for the specific language governing permissions and | ||
| 13 | +* limitations under the License. | ||
| 14 | +*/ | ||
| 15 | + | ||
| 16 | +import CommonConstants from '../constants/CommonConstants'; | ||
| 17 | +import { DistributedData } from '../model/CommModel'; | ||
| 18 | +import { DebounceUtil } from '../utils/DebounceUtil'; | ||
| 19 | + | ||
| 20 | +@Builder | ||
| 21 | +export function migrateDataDistributedBaseViewBuilder() { | ||
| 22 | + MigrateDataDistributedBaseView() | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +@Component | ||
| 26 | +export struct MigrateDataDistributedBaseView { | ||
| 27 | + @StorageLink('basicDataStr') basicDataStr: string = ''; | ||
| 28 | + @StorageLink('basicDataNum') basicDataNum: number | null = null; | ||
| 29 | + @StorageLink('distributedData') distributedData: DistributedData = { str: '', num: null }; | ||
| 30 | + private debounceDelay: number = 300; | ||
| 31 | + | ||
| 32 | + build() { | ||
| 33 | + NavDestination() { | ||
| 34 | + Column({ space: 12 }) { | ||
| 35 | + Text($r('app.string.basic_data')) | ||
| 36 | + .alignSelf(ItemAlign.Start) | ||
| 37 | + .fontWeight(FontWeight.Medium) | ||
| 38 | + .margin({ top: 12 }) | ||
| 39 | + TextInput({ text: this.basicDataStr, placeholder: $r('app.string.input_text_data_to_migrate') }) | ||
| 40 | + .width(328) | ||
| 41 | + .height(40) | ||
| 42 | + .onChange(((value: string) => { | ||
| 43 | + DebounceUtil.debounce('basicDataStr', () => { | ||
| 44 | + this.basicDataStr = value; | ||
| 45 | + }, this.debounceDelay); | ||
| 46 | + })) | ||
| 47 | + TextInput({ text: `${this.basicDataNum}`, placeholder: $r('app.string.input_number_data_to_migrate') }) | ||
| 48 | + .type(InputType.Number) | ||
| 49 | + .width(328) | ||
| 50 | + .height(40) | ||
| 51 | + .onChange(((value: string) => { | ||
| 52 | + DebounceUtil.debounce('basicDataNum', () => { | ||
| 53 | + const num = Number(value); | ||
| 54 | + this.basicDataNum = value && !isNaN(num) ? num : null; | ||
| 55 | + }, this.debounceDelay); | ||
| 56 | + })) | ||
| 57 | + Text($r('app.string.data_object')) | ||
| 58 | + .alignSelf(ItemAlign.Start) | ||
| 59 | + .fontWeight(FontWeight.Medium) | ||
| 60 | + .margin({ top: 12 }) | ||
| 61 | + TextInput({ text: this.distributedData.str, placeholder: $r('app.string.input_text_data_to_migrate') }) | ||
| 62 | + .width(328) | ||
| 63 | + .height(40) | ||
| 64 | + .onChange(((value: string) => { | ||
| 65 | + DebounceUtil.debounce('distributedDataStr', () => { | ||
| 66 | + this.distributedData.str = value; | ||
| 67 | + }, this.debounceDelay); | ||
| 68 | + })) | ||
| 69 | + TextInput({ text: `${this.distributedData.num}`, placeholder: $r('app.string.input_number_data_to_migrate') }) | ||
| 70 | + .type(InputType.Number) | ||
| 71 | + .width(328) | ||
| 72 | + .height(40) | ||
| 73 | + .onChange(((value: string) => { | ||
| 74 | + DebounceUtil.debounce('distributedDataNum', () => { | ||
| 75 | + const num = Number(value); | ||
| 76 | + this.distributedData.num = value && !isNaN(num) ? num : null; | ||
| 77 | + }, this.debounceDelay); | ||
| 78 | + })) | ||
| 79 | + } | ||
| 80 | + .width(CommonConstants.FULL_PERCENT) | ||
| 81 | + .padding({ left: 16, right: 16 }) | ||
| 82 | + } | ||
| 83 | + .title($r('app.string.migrate_data_distributed_base')) | ||
| 84 | + .width(CommonConstants.FULL_PERCENT) | ||
| 85 | + .height(CommonConstants.FULL_PERCENT) | ||
| 86 | + .backgroundColor($r('app.color.page_background')) | ||
| 87 | + } | ||
| 88 | +} | ||
| @@ -0,0 +1,70 @@ | |||
| 1 | +/* | ||
| 2 | +* Copyright (C) 2026 Huawei Device Co., Ltd. | ||
| 3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | +* you may not use this file except in compliance with the License. | ||
| 5 | +* You may obtain a copy of the License at | ||
| 6 | +* | ||
| 7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | +* | ||
| 9 | +* Unless required by applicable law or agreed to in writing, software | ||
| 10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | +* See the License for the specific language governing permissions and | ||
| 13 | +* limitations under the License. | ||
| 14 | +*/ | ||
| 15 | + | ||
| 16 | +import CommonConstants from '../constants/CommonConstants'; | ||
| 17 | +import { DebounceUtil } from '../utils/DebounceUtil'; | ||
| 18 | +import { AddPic } from './AddPic'; | ||
| 19 | + | ||
| 20 | +@Builder | ||
| 21 | +export function migrateDataDistributedMonoFileViewBuilder() { | ||
| 22 | + MigrateDataDistributedMonoFileView() | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +@Component | ||
| 26 | +export struct MigrateDataDistributedMonoFileView { | ||
| 27 | + @State isSingleImage: boolean = true; | ||
| 28 | + @StorageLink('monoFileStr') monoFileStr: string = ''; | ||
| 29 | + @StorageLink('monoFileNum') monoFileNum: number | null = null; | ||
| 30 | + private debounceDelay: number = 300; | ||
| 31 | + | ||
| 32 | + build() { | ||
| 33 | + NavDestination() { | ||
| 34 | + Column({ space: 12 }) { | ||
| 35 | + Text($r('app.string.basic_data')) | ||
| 36 | + .alignSelf(ItemAlign.Start) | ||
| 37 | + .fontWeight(FontWeight.Medium) | ||
| 38 | + .margin({ top: 12 }) | ||
| 39 | + TextInput({ text: this.monoFileStr, placeholder: $r('app.string.input_text_data_to_migrate') }) | ||
| 40 | + .width(328) | ||
| 41 | + .height(40) | ||
| 42 | + .onChange(((value: string) => { | ||
| 43 | + DebounceUtil.debounce('monoFileStr', () => { | ||
| 44 | + this.monoFileStr = value; | ||
| 45 | + }, this.debounceDelay); | ||
| 46 | + })) | ||
| 47 | + TextInput({ text: `${this.monoFileNum}`, placeholder: $r('app.string.input_number_data_to_migrate') }) | ||
| 48 | + .type(InputType.Number) | ||
| 49 | + .width(328) | ||
| 50 | + .height(40) | ||
| 51 | + .onChange(((value: string) => { | ||
| 52 | + DebounceUtil.debounce('monoFileNum', () => { | ||
| 53 | + const num = Number(value); | ||
| 54 | + this.monoFileNum = value && !isNaN(num) ? num : null; | ||
| 55 | + }, this.debounceDelay); | ||
| 56 | + })) | ||
| 57 | + Text($r('app.string.image_file')) | ||
| 58 | + .alignSelf(ItemAlign.Start) | ||
| 59 | + .fontWeight(FontWeight.Medium) | ||
| 60 | + AddPic({ isSingleImage: this.isSingleImage }) | ||
| 61 | + } | ||
| 62 | + .width(CommonConstants.FULL_PERCENT) | ||
| 63 | + .padding({ left: 16, right: 16 }) | ||
| 64 | + } | ||
| 65 | + .title($r('app.string.migrate_data_distributed_mono_file')) | ||
| 66 | + .width(CommonConstants.FULL_PERCENT) | ||
| 67 | + .height(CommonConstants.FULL_PERCENT) | ||
| 68 | + .backgroundColor($r('app.color.page_background')) | ||
| 69 | + } | ||
| 70 | +} | ||
| @@ -0,0 +1,70 @@ | |||
| 1 | +/* | ||
| 2 | +* Copyright (C) 2026 Huawei Device Co., Ltd. | ||
| 3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | +* you may not use this file except in compliance with the License. | ||
| 5 | +* You may obtain a copy of the License at | ||
| 6 | +* | ||
| 7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | +* | ||
| 9 | +* Unless required by applicable law or agreed to in writing, software | ||
| 10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | +* See the License for the specific language governing permissions and | ||
| 13 | +* limitations under the License. | ||
| 14 | +*/ | ||
| 15 | + | ||
| 16 | +import CommonConstants from '../constants/CommonConstants'; | ||
| 17 | +import { DebounceUtil } from '../utils/DebounceUtil'; | ||
| 18 | +import { AddPic } from './AddPic'; | ||
| 19 | + | ||
| 20 | +@Builder | ||
| 21 | +export function migrateDataDistributedMultiFileViewBuilder() { | ||
| 22 | + MigrateDataDistributedMultiFileView() | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +@Component | ||
| 26 | +export struct MigrateDataDistributedMultiFileView { | ||
| 27 | + @State isSingleImage: boolean = false; | ||
| 28 | + @StorageLink('multiFileStr') multiFileStr: string = ''; | ||
| 29 | + @StorageLink('multiFileNum') multiFileNum: number | null = null; | ||
| 30 | + private debounceDelay: number = 300; | ||
| 31 | + | ||
| 32 | + build() { | ||
| 33 | + NavDestination() { | ||
| 34 | + Column({ space: 12 }) { | ||
| 35 | + Text($r('app.string.basic_data')) | ||
| 36 | + .alignSelf(ItemAlign.Start) | ||
| 37 | + .fontWeight(FontWeight.Medium) | ||
| 38 | + .margin({ top: 12 }) | ||
| 39 | + TextInput({ text: this.multiFileStr, placeholder: $r('app.string.input_text_data_to_migrate') }) | ||
| 40 | + .width(328) | ||
| 41 | + .height(40) | ||
| 42 | + .onChange(((value: string) => { | ||
| 43 | + DebounceUtil.debounce('multiFileStr', () => { | ||
| 44 | + this.multiFileStr = value; | ||
| 45 | + }, this.debounceDelay); | ||
| 46 | + })) | ||
| 47 | + TextInput({ text: `${this.multiFileNum}`, placeholder: $r('app.string.input_number_data_to_migrate') }) | ||
| 48 | + .type(InputType.Number) | ||
| 49 | + .width(328) | ||
| 50 | + .height(40) | ||
| 51 | + .onChange(((value: string) => { | ||
| 52 | + DebounceUtil.debounce('multiFileNum', () => { | ||
| 53 | + const num = Number(value); | ||
| 54 | + this.multiFileNum = value && !isNaN(num) ? num : null; | ||
| 55 | + }, this.debounceDelay); | ||
| 56 | + })) | ||
| 57 | + Text($r('app.string.image_file')) | ||
| 58 | + .alignSelf(ItemAlign.Start) | ||
| 59 | + .fontWeight(FontWeight.Medium) | ||
| 60 | + AddPic({ isSingleImage: this.isSingleImage }) | ||
| 61 | + } | ||
| 62 | + .width(CommonConstants.FULL_PERCENT) | ||
| 63 | + .padding({ left: 16, right: 16 }) | ||
| 64 | + } | ||
| 65 | + .title($r('app.string.migrate_data_distributed_multi_file')) | ||
| 66 | + .width(CommonConstants.FULL_PERCENT) | ||
| 67 | + .height(CommonConstants.FULL_PERCENT) | ||
| 68 | + .backgroundColor($r('app.color.page_background')) | ||
| 69 | + } | ||
| 70 | +} | ||
| @@ -0,0 +1,52 @@ | |||
| 1 | +/* | ||
| 2 | +* Copyright (C) 2026 Huawei Device Co., Ltd. | ||
| 3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | +* you may not use this file except in compliance with the License. | ||
| 5 | +* You may obtain a copy of the License at | ||
| 6 | +* | ||
| 7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | +* | ||
| 9 | +* Unless required by applicable law or agreed to in writing, software | ||
| 10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | +* See the License for the specific language governing permissions and | ||
| 13 | +* limitations under the License. | ||
| 14 | +*/ | ||
| 15 | +import CommonConstants from '../constants/CommonConstants'; | ||
| 16 | +import { DebounceUtil } from '../utils/DebounceUtil'; | ||
| 17 | + | ||
| 18 | +@Builder | ||
| 19 | +export function migrateDataWantParamViewBuilder() { | ||
| 20 | + MigrateDataWantParamView() | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +@Component | ||
| 24 | +export struct MigrateDataWantParamView { | ||
| 25 | + @StorageLink('wantBasicData') wantBasicData: string = ''; | ||
| 26 | + private debounceDelay: number = 300; | ||
| 27 | + | ||
| 28 | + build() { | ||
| 29 | + NavDestination() { | ||
| 30 | + Column({ space: 12 }) { | ||
| 31 | + Text($r('app.string.basic_data')) | ||
| 32 | + .alignSelf(ItemAlign.Start) | ||
| 33 | + .fontWeight(FontWeight.Medium) | ||
| 34 | + .margin({ top: 12 }) | ||
| 35 | + TextInput({ text: this.wantBasicData, placeholder: $r('app.string.input_data_to_migrate') }) | ||
| 36 | + .width(328) | ||
| 37 | + .height(40) | ||
| 38 | + .onChange(((value: string) => { | ||
| 39 | + DebounceUtil.debounce('wantBasicData', () => { | ||
| 40 | + this.wantBasicData = value; | ||
| 41 | + }, this.debounceDelay); | ||
| 42 | + })) | ||
| 43 | + } | ||
| 44 | + .width(CommonConstants.FULL_PERCENT) | ||
| 45 | + .padding({ left: 16, right: 16 }) | ||
| 46 | + } | ||
| 47 | + .title($r('app.string.migrate_data_want_param')) | ||
| 48 | + .width(CommonConstants.FULL_PERCENT) | ||
| 49 | + .height(CommonConstants.FULL_PERCENT) | ||
| 50 | + .backgroundColor($r('app.color.page_background')) | ||
| 51 | + } | ||
| 52 | +} | ||
| @@ -0,0 +1,78 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +import { BusinessError } from '@kit.BasicServicesKit'; | ||
| 17 | +import { hilog } from '@kit.PerformanceAnalysisKit'; | ||
| 18 | +import { common } from '@kit.AbilityKit'; | ||
| 19 | +import { ImageViewModel } from './ImageViewModel'; | ||
| 20 | +import { ImageInfo } from '../model/CommModel'; | ||
| 21 | + | ||
| 22 | +const DOMAIN = 0x0000; | ||
| 23 | +const TAG = 'AddPicViewModel'; | ||
| 24 | +const FORMAT = '%{public}s'; | ||
| 25 | +const MAX_IMAGE_COUNT = 9; | ||
| 26 | + | ||
| 27 | +export class AddPicViewModel { | ||
| 28 | + private context: common.UIAbilityContext; | ||
| 29 | + private imageViewModel: ImageViewModel; | ||
| 30 | + private showToastCallback: (message: ResourceStr) => void; | ||
| 31 | + public imageUriArray: Array<ImageInfo> = []; | ||
| 32 | + | ||
| 33 | + constructor(context: common.UIAbilityContext, showToastCallback: (message: ResourceStr) => void) { | ||
| 34 | + this.context = context; | ||
| 35 | + this.imageViewModel = new ImageViewModel(this.context); | ||
| 36 | + this.showToastCallback = showToastCallback; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + private showToast(message: ResourceStr): void { | ||
| 40 | + try { | ||
| 41 | + this.showToastCallback(message); | ||
| 42 | + } catch (err) { | ||
| 43 | + hilog.error(DOMAIN, TAG, FORMAT, `ShowToast failed. Cause code: ${(err as BusinessError).code}`); | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + canAddMoreImages(isSingleImage: boolean): boolean { | ||
| 48 | + return this.imageUriArray.length < (isSingleImage ? 1 : MAX_IMAGE_COUNT); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + getButtonText(isSingleImage: boolean, hasImage: boolean, imageCount: number): Resource { | ||
| 52 | + if (isSingleImage) { | ||
| 53 | + return hasImage ? $r('app.string.image_add') : $r('app.string.add_high_img'); | ||
| 54 | + } | ||
| 55 | + if (imageCount === 0) { | ||
| 56 | + return $r('app.string.add_high_img'); | ||
| 57 | + } else if (imageCount < MAX_IMAGE_COUNT) { | ||
| 58 | + return $r('app.string.continue_add'); | ||
| 59 | + } else { | ||
| 60 | + return $r('app.string.image_add'); | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + selectImage(isSingleImage: boolean): void { | ||
| 65 | + if (!this.canAddMoreImages(isSingleImage)) { | ||
| 66 | + return; | ||
| 67 | + } | ||
| 68 | + this.imageViewModel.imageUriArray = this.imageUriArray; | ||
| 69 | + this.imageViewModel.selectImage(isSingleImage, () => { | ||
| 70 | + this.showToast($r('app.string.add_picture_prompt')); | ||
| 71 | + }); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + updateImageArray(imageUriArray: Array<ImageInfo>): void { | ||
| 75 | + this.imageUriArray = imageUriArray; | ||
| 76 | + this.imageViewModel.imageUriArray = imageUriArray; | ||
| 77 | + } | ||
| 78 | +} | ||
| @@ -0,0 +1,142 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +import { commonType } from '@kit.ArkData'; | ||
| 17 | +import { BusinessError } from '@kit.BasicServicesKit'; | ||
| 18 | +import { hilog } from '@kit.PerformanceAnalysisKit'; | ||
| 19 | +import { fileIo, fileUri } from '@kit.CoreFileKit'; | ||
| 20 | +import { image } from '@kit.ImageKit'; | ||
| 21 | +import { common } from '@kit.AbilityKit'; | ||
| 22 | +import { ImageInfo } from '../model/CommModel'; | ||
| 23 | + | ||
| 24 | +const DOMAIN = 0x0000; | ||
| 25 | +const TAG = 'ContinuationViewModel'; | ||
| 26 | +const FORMAT = '%{public}s'; | ||
| 27 | + | ||
| 28 | +export class ContinuationViewModel { | ||
| 29 | + private context: common.UIAbilityContext; | ||
| 30 | + public imageUriArray: Array<ImageInfo> = []; | ||
| 31 | + public imageUri: ImageInfo | undefined = undefined; | ||
| 32 | + | ||
| 33 | + constructor(context: common.UIAbilityContext) { | ||
| 34 | + this.context = context; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + getAssetInfo(append: ImageInfo): commonType.Asset | undefined { | ||
| 38 | + let filePath = this.context.distributedFilesDir + '/' + append.imageName; | ||
| 39 | + let attachment: commonType.Asset; | ||
| 40 | + try { | ||
| 41 | + let uri: string = fileUri.getUriFromPath(filePath); | ||
| 42 | + let stat = fileIo.statSync(filePath); | ||
| 43 | + attachment = { | ||
| 44 | + name: append.imageName, | ||
| 45 | + uri: uri, | ||
| 46 | + path: filePath, | ||
| 47 | + createTime: stat.ctime.toString(), | ||
| 48 | + modifyTime: stat.ctime.toString(), | ||
| 49 | + size: stat.size.toString() | ||
| 50 | + }; | ||
| 51 | + hilog.info(DOMAIN, TAG, FORMAT, `[getAssetInfo] attachments name: ${attachment.name}`); | ||
| 52 | + return attachment; | ||
| 53 | + } catch (err) { | ||
| 54 | + hilog.error(DOMAIN, TAG, FORMAT, `StatSync failed. Cause code: ${err.code}`); | ||
| 55 | + return undefined; | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + fileCopy(attachment: commonType.Asset, isUniFile?: boolean): void { | ||
| 60 | + if (!canIUse('SystemCapability.DistributedDataManager.CommonType')) { | ||
| 61 | + return; | ||
| 62 | + } | ||
| 63 | + let filePath: string = this.context.distributedFilesDir + '/' + attachment.name; | ||
| 64 | + let savePath: string = this.context.filesDir + '/' + attachment.name; | ||
| 65 | + let file: fileIo.File | undefined = undefined; | ||
| 66 | + let saveFile: fileIo.File | undefined = undefined; | ||
| 67 | + try { | ||
| 68 | + if (!fileIo.accessSync(filePath)) { | ||
| 69 | + return; | ||
| 70 | + } | ||
| 71 | + const fileSize = Number(attachment.size); | ||
| 72 | + if (!attachment.size || isNaN(fileSize) || fileSize <= 0) { | ||
| 73 | + hilog.error(DOMAIN, TAG, FORMAT, `Invalid file size: ${attachment.size}`); | ||
| 74 | + return; | ||
| 75 | + } | ||
| 76 | + saveFile = fileIo.openSync(savePath, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); | ||
| 77 | + file = fileIo.openSync(filePath, fileIo.OpenMode.READ_WRITE); | ||
| 78 | + let buf: ArrayBuffer = new ArrayBuffer(fileSize); | ||
| 79 | + let readSize = 0; | ||
| 80 | + let readLen = fileIo.readSync(file.fd, buf, { | ||
| 81 | + offset: readSize | ||
| 82 | + }); | ||
| 83 | + let sourceOptions: image.SourceOptions = { | ||
| 84 | + sourceDensity: 120 | ||
| 85 | + }; | ||
| 86 | + let imageSourceApi: image.ImageSource = image.createImageSource(buf, sourceOptions); | ||
| 87 | + if (isUniFile) { | ||
| 88 | + this.imageUri = ({ | ||
| 89 | + imagePixelMap: imageSourceApi.createPixelMapSync(), | ||
| 90 | + imageName: attachment.name | ||
| 91 | + }); | ||
| 92 | + } else { | ||
| 93 | + this.imageUriArray.push({ | ||
| 94 | + imagePixelMap: imageSourceApi.createPixelMapSync(), | ||
| 95 | + imageName: attachment.name | ||
| 96 | + }); | ||
| 97 | + } | ||
| 98 | + while (readLen > 0) { | ||
| 99 | + readSize += readLen; | ||
| 100 | + fileIo.writeSync(saveFile.fd, buf); | ||
| 101 | + readLen = fileIo.readSync(file.fd, buf, { | ||
| 102 | + offset: readSize | ||
| 103 | + }); | ||
| 104 | + } | ||
| 105 | + hilog.info(DOMAIN, TAG, FORMAT, `synchronized successfully`); | ||
| 106 | + } catch (error) { | ||
| 107 | + let err: BusinessError = error as BusinessError; | ||
| 108 | + hilog.error(DOMAIN, TAG, FORMAT, `fileCopy failed with err code: ${err.code}`); | ||
| 109 | + } finally { | ||
| 110 | + if (file) { | ||
| 111 | + fileIo.closeSync(file); | ||
| 112 | + } | ||
| 113 | + if (saveFile) { | ||
| 114 | + fileIo.closeSync(saveFile); | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + buildAssetsFromImageInfo(imageUri: ImageInfo | undefined): commonType.Assets { | ||
| 120 | + let assets: commonType.Assets = []; | ||
| 121 | + if (imageUri) { | ||
| 122 | + let attachment = this.getAssetInfo(imageUri); | ||
| 123 | + if (attachment) { | ||
| 124 | + assets.push(attachment); | ||
| 125 | + } | ||
| 126 | + } | ||
| 127 | + return assets; | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + buildAssetsFromImageArray(imageUriArray: Array<ImageInfo> | undefined): commonType.Assets { | ||
| 131 | + let assets: commonType.Assets = []; | ||
| 132 | + if (imageUriArray) { | ||
| 133 | + for (let i = 0; i < imageUriArray.length; i++) { | ||
| 134 | + let attachment = this.getAssetInfo(imageUriArray[i]); | ||
| 135 | + if (attachment) { | ||
| 136 | + assets.push(attachment); | ||
| 137 | + } | ||
| 138 | + } | ||
| 139 | + } | ||
| 140 | + return assets; | ||
| 141 | + } | ||
| 142 | +} | ||
| @@ -0,0 +1,144 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +import { dataSharePredicates, unifiedDataChannel } from '@kit.ArkData'; | ||
| 17 | +import { photoAccessHelper } from '@kit.MediaLibraryKit'; | ||
| 18 | +import { BusinessError } from '@kit.BasicServicesKit'; | ||
| 19 | +import { hilog } from '@kit.PerformanceAnalysisKit'; | ||
| 20 | +import { fileIo } from '@kit.CoreFileKit'; | ||
| 21 | +import { common } from '@kit.AbilityKit'; | ||
| 22 | +import { image } from '@kit.ImageKit'; | ||
| 23 | +import { fileSelect } from '../utils/FileUtil'; | ||
| 24 | +import { ImageInfo } from '../model/CommModel'; | ||
| 25 | + | ||
| 26 | +const DOMAIN = 0x0000; | ||
| 27 | +const TAG = 'ImageViewModel'; | ||
| 28 | +const FORMAT = '%{public}s'; | ||
| 29 | + | ||
| 30 | +export class ImageViewModel { | ||
| 31 | + public context: common.UIAbilityContext; | ||
| 32 | + public imageUriArray: Array<ImageInfo> = []; | ||
| 33 | + | ||
| 34 | + constructor(context: common.UIAbilityContext) { | ||
| 35 | + this.context = context; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + selectImage(isSingleImage: boolean, onLimitReached?: () => void): void { | ||
| 39 | + fileSelect(isSingleImage).then((uri: Array<ResourceStr>) => { | ||
| 40 | + if ((this.imageUriArray.length + uri.length) > (isSingleImage ? 1 : 9)) { | ||
| 41 | + uri.length = (isSingleImage ? 1 : 9) - this.imageUriArray.length; | ||
| 42 | + if (onLimitReached) { | ||
| 43 | + onLimitReached(); | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + uri.forEach((item: ResourceStr) => { | ||
| 47 | + this.getThumbnail(item as string, isSingleImage); | ||
| 48 | + }); | ||
| 49 | + }); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + private async getThumbnail(uri: string, isSingleImage: boolean): Promise<void> { | ||
| 53 | + let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(this.context); | ||
| 54 | + let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); | ||
| 55 | + predicates.equalTo('uri', uri); | ||
| 56 | + let fetchOption: photoAccessHelper.FetchOptions = { | ||
| 57 | + fetchColumns: [], | ||
| 58 | + predicates: predicates | ||
| 59 | + }; | ||
| 60 | + try { | ||
| 61 | + let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = | ||
| 62 | + await phAccessHelper.getAssets(fetchOption); | ||
| 63 | + let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); | ||
| 64 | + let pixelMap = await asset.getThumbnail(); | ||
| 65 | + hilog.info(DOMAIN, TAG, FORMAT, 'getThumbnail successful'); | ||
| 66 | + let displayName = asset.displayName || ''; | ||
| 67 | + if (!displayName) { | ||
| 68 | + hilog.error(DOMAIN, TAG, FORMAT, 'displayName is empty'); | ||
| 69 | + return; | ||
| 70 | + } | ||
| 71 | + let dotIndex = displayName.indexOf('.'); | ||
| 72 | + let imageName = dotIndex > 0 ? displayName.substring(0, dotIndex) : displayName; | ||
| 73 | + this.pixelMapToBuffer(pixelMap, imageName); | ||
| 74 | + if (isSingleImage) { | ||
| 75 | + AppStorage.setOrCreate('imageUri', { imagePixelMap: pixelMap, imageName: imageName }); | ||
| 76 | + } else { | ||
| 77 | + this.imageUriArray.push({ imagePixelMap: pixelMap, imageName: imageName }); | ||
| 78 | + AppStorage.setOrCreate('imageUriArray', this.imageUriArray); | ||
| 79 | + } | ||
| 80 | + } catch (err) { | ||
| 81 | + hilog.error(DOMAIN, TAG, FORMAT, `GetThumbnail failed. Cause code: ${(err as BusinessError).code}`); | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + private pixelMapToBuffer(pixelMap: image.PixelMap, displayName: string): void { | ||
| 86 | + const imagePackerApi: image.ImagePacker = image.createImagePacker(); | ||
| 87 | + let packOpts: image.PackingOption = { format: 'image/jpeg', quality: 100 }; | ||
| 88 | + imagePackerApi.packToData(pixelMap, packOpts).then((data: ArrayBuffer) => { | ||
| 89 | + this.writeDistributedFile(data, displayName); | ||
| 90 | + }).catch((err: BusinessError) => { | ||
| 91 | + hilog.error(DOMAIN, TAG, FORMAT, `PackToData failed. Cause code: ${err.code}`); | ||
| 92 | + }); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + private writeDistributedFile(buf: ArrayBuffer, displayName: string): void { | ||
| 96 | + let distributedDir: string = this.context.distributedFilesDir; | ||
| 97 | + let fileName: string = '/' + displayName; | ||
| 98 | + let filePath: string = distributedDir + fileName; | ||
| 99 | + let file: fileIo.File | undefined = undefined; | ||
| 100 | + try { | ||
| 101 | + file = fileIo.openSync(filePath, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); | ||
| 102 | + hilog.info(DOMAIN, TAG, FORMAT, 'Create file success.'); | ||
| 103 | + fileIo.writeSync(file.fd, buf); | ||
| 104 | + } catch (error) { | ||
| 105 | + let err: BusinessError = error as BusinessError; | ||
| 106 | + hilog.error(DOMAIN, TAG, FORMAT, `Failed to openSync / writeSync. Code: ${err.code}`); | ||
| 107 | + } finally { | ||
| 108 | + if (file) { | ||
| 109 | + try { | ||
| 110 | + fileIo.closeSync(file.fd); | ||
| 111 | + } catch (err) { | ||
| 112 | + hilog.error(DOMAIN, TAG, FORMAT, `Failed to closeSync. Code: ${(err as BusinessError).code}`); | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + getDataFromUdmf(event: DragEvent, callback: (data: DragEvent) => void): void { | ||
| 119 | + if (this.getDataFromUdmfRetry(event, callback)) { | ||
| 120 | + return; | ||
| 121 | + } | ||
| 122 | + setTimeout(() => { | ||
| 123 | + this.getDataFromUdmfRetry(event, callback); | ||
| 124 | + }, 1500); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + private getDataFromUdmfRetry(event: DragEvent, callback: (data: DragEvent) => void): boolean { | ||
| 128 | + try { | ||
| 129 | + let data: UnifiedData = event.getData(); | ||
| 130 | + if (!data) { | ||
| 131 | + return false; | ||
| 132 | + } | ||
| 133 | + let records: Array<unifiedDataChannel.UnifiedRecord> = data.getRecords(); | ||
| 134 | + if (!records || records.length <= 0) { | ||
| 135 | + return false; | ||
| 136 | + } | ||
| 137 | + callback(event); | ||
| 138 | + return true; | ||
| 139 | + } catch (e) { | ||
| 140 | + hilog.error(DOMAIN, TAG, FORMAT, `getData failed, code = ${(e as BusinessError).code}`); | ||
| 141 | + return false; | ||
| 142 | + } | ||
| 143 | + } | ||
| 144 | +} | ||
| @@ -0,0 +1,65 @@ | |||
| 1 | +{ | ||
| 2 | + "module": { | ||
| 3 | + "name": "entry", | ||
| 4 | + "type": "entry", | ||
| 5 | + "description": "$string:module_desc", | ||
| 6 | + "mainElement": "EntryAbility", | ||
| 7 | + "deviceTypes": [ | ||
| 8 | + "phone" | ||
| 9 | + ], | ||
| 10 | + "deliveryWithInstall": true, | ||
| 11 | + "installationFree": false, | ||
| 12 | + "pages": "$profile:main_pages", | ||
| 13 | + "routerMap": "$profile:router_map", | ||
| 14 | + "abilities": [ | ||
| 15 | + { | ||
| 16 | + "name": "EntryAbility", | ||
| 17 | + "srcEntry": "./ets/entryability/EntryAbility.ets", | ||
| 18 | + "description": "$string:EntryAbility_desc", | ||
| 19 | + "icon": "$media:layered_image", | ||
| 20 | + "label": "$string:EntryAbility_label", | ||
| 21 | + "startWindowIcon": "$media:startIcon", | ||
| 22 | + "startWindowBackground": "$color:start_window_background", | ||
| 23 | + "exported": true, | ||
| 24 | + "skills": [ | ||
| 25 | + { | ||
| 26 | + "entities": [ | ||
| 27 | + "entity.system.home" | ||
| 28 | + ], | ||
| 29 | + "actions": [ | ||
| 30 | + "ohos.want.action.home" | ||
| 31 | + ] | ||
| 32 | + } | ||
| 33 | + ], | ||
| 34 | + "continuable": true, | ||
| 35 | + "launchType": "singleton" | ||
| 36 | + } | ||
| 37 | + ], | ||
| 38 | + "requestPermissions": [ | ||
| 39 | + { | ||
| 40 | + "name": "ohos.permission.DISTRIBUTED_DATASYNC", | ||
| 41 | + "reason": "$string:permission_distributed_datasync", | ||
| 42 | + "usedScene": { | ||
| 43 | + "abilities": [ | ||
| 44 | + "EntryAbility" | ||
| 45 | + ], | ||
| 46 | + "when": "inuse" | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | + ], | ||
| 50 | + "extensionAbilities": [ | ||
| 51 | + { | ||
| 52 | + "name": "EntryBackupAbility", | ||
| 53 | + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", | ||
| 54 | + "type": "backup", | ||
| 55 | + "exported": false, | ||
| 56 | + "metadata": [ | ||
| 57 | + { | ||
| 58 | + "name": "ohos.extension.backup", | ||
| 59 | + "resource": "$profile:backup_config" | ||
| 60 | + } | ||
| 61 | + ], | ||
| 62 | + } | ||
| 63 | + ] | ||
| 64 | + } | ||
| 65 | +} | ||
| @@ -0,0 +1,28 @@ | |||
| 1 | +{ | ||
| 2 | + "color": [ | ||
| 3 | + { | ||
| 4 | + "name": "start_window_background", | ||
| 5 | + "value": "#FFFFFF" | ||
| 6 | + }, | ||
| 7 | + { | ||
| 8 | + "name": "page_background", | ||
| 9 | + "value": "#F1F3F5" | ||
| 10 | + }, | ||
| 11 | + { | ||
| 12 | + "name": "button_background", | ||
| 13 | + "value": "#E6E7E9" | ||
| 14 | + }, | ||
| 15 | + { | ||
| 16 | + "name": "button_font", | ||
| 17 | + "value": "#0A59F7" | ||
| 18 | + }, | ||
| 19 | + { | ||
| 20 | + "name": "text_font_gray", | ||
| 21 | + "value": "#A2A6AC" | ||
| 22 | + }, | ||
| 23 | + { | ||
| 24 | + "name": "border_color", | ||
| 25 | + "value": "#CCCCCC" | ||
| 26 | + } | ||
| 27 | + ] | ||
| 28 | +} | ||
| @@ -0,0 +1,8 @@ | |||
| 1 | +{ | ||
| 2 | + "float": [ | ||
| 3 | + { | ||
| 4 | + "name": "page_text_font_size", | ||
| 5 | + "value": "50fp" | ||
| 6 | + } | ||
| 7 | + ] | ||
| 8 | +} | ||
| @@ -0,0 +1,84 @@ | |||
| 1 | +{ | ||
| 2 | + "string": [ | ||
| 3 | + { | ||
| 4 | + "name": "module_desc", | ||
| 5 | + "value": "module description" | ||
| 6 | + }, | ||
| 7 | + { | ||
| 8 | + "name": "EntryAbility_desc", | ||
| 9 | + "value": "description" | ||
| 10 | + }, | ||
| 11 | + { | ||
| 12 | + "name": "EntryAbility_label", | ||
| 13 | + "value": "DataMigration" | ||
| 14 | + }, | ||
| 15 | + { | ||
| 16 | + "name": "migrate_data_want_param", | ||
| 17 | + "value": "Migrate simple data using want.param" | ||
| 18 | + }, | ||
| 19 | + { | ||
| 20 | + "name": "migrate_data_distributed_base", | ||
| 21 | + "value": "Use distributed object migration to transfer basic data" | ||
| 22 | + }, | ||
| 23 | + { | ||
| 24 | + "name": "migrate_data_distributed_mono_file", | ||
| 25 | + "value": "Using distributed object single-file migration" | ||
| 26 | + }, | ||
| 27 | + { | ||
| 28 | + "name": "migrate_data_distributed_multi_file", | ||
| 29 | + "value": "Using distributed object multi-file migration" | ||
| 30 | + }, | ||
| 31 | + { | ||
| 32 | + "name": "local_device", | ||
| 33 | + "value": "Local Devices" | ||
| 34 | + }, | ||
| 35 | + { | ||
| 36 | + "name": "add_picture_prompt", | ||
| 37 | + "value": "The number of added pictures reaches the upper limit." | ||
| 38 | + }, | ||
| 39 | + { | ||
| 40 | + "name": "continue_add", | ||
| 41 | + "value": "Continue Add" | ||
| 42 | + }, | ||
| 43 | + { | ||
| 44 | + "name": "image_add", | ||
| 45 | + "value": "Upper Limit" | ||
| 46 | + }, | ||
| 47 | + { | ||
| 48 | + "name": "add_high_img", | ||
| 49 | + "value": "Add Image" | ||
| 50 | + }, | ||
| 51 | + { | ||
| 52 | + "name": "permission_distributed_datasync", | ||
| 53 | + "value": "Allow data exchange between different devices" | ||
| 54 | + }, | ||
| 55 | + { | ||
| 56 | + "name": "basic_data", | ||
| 57 | + "value": "Basic Data" | ||
| 58 | + }, | ||
| 59 | + { | ||
| 60 | + "name": "data_object", | ||
| 61 | + "value": "Data Object" | ||
| 62 | + }, | ||
| 63 | + { | ||
| 64 | + "name": "image_file", | ||
| 65 | + "value": "Image File" | ||
| 66 | + }, | ||
| 67 | + { | ||
| 68 | + "name": "input_data_to_migrate", | ||
| 69 | + "value": "Enter data to migrate" | ||
| 70 | + }, | ||
| 71 | + { | ||
| 72 | + "name": "input_text_data_to_migrate", | ||
| 73 | + "value": "Enter text data to migrate" | ||
| 74 | + }, | ||
| 75 | + { | ||
| 76 | + "name": "input_number_data_to_migrate", | ||
| 77 | + "value": "Enter number data to migrate" | ||
| 78 | + }, | ||
| 79 | + { | ||
| 80 | + "name": "permission_read_imagevideo", | ||
| 81 | + "value": "Allow reading of image or video files in the user's public directory" | ||
| 82 | + } | ||
| 83 | + ] | ||
| 84 | +} | ||
| @@ -0,0 +1,7 @@ | |||
| 1 | +{ | ||
| 2 | + "layered-image": | ||
| 3 | + { | ||
| 4 | + "background" : "$media:background", | ||
| 5 | + "foreground" : "$media:foreground" | ||
| 6 | + } | ||
| 7 | +} | ||
| @@ -0,0 +1,3 @@ | |||
| 1 | +{ | ||
| 2 | + "allowToBackupRestore": true | ||
| 3 | +} | ||
| @@ -0,0 +1,5 @@ | |||
| 1 | +{ | ||
| 2 | + "src": [ | ||
| 3 | + "pages/Index" | ||
| 4 | + ] | ||
| 5 | +} | ||
| @@ -0,0 +1,36 @@ | |||
| 1 | +{ | ||
| 2 | + "routerMap": [ | ||
| 3 | + { | ||
| 4 | + "name": "migrateDataWantParamView", | ||
| 5 | + "pageSourceFile": "src/main/ets/view/MigrateDataWantParamView.ets", | ||
| 6 | + "buildFunction": "migrateDataWantParamViewBuilder", | ||
| 7 | + "data": { | ||
| 8 | + "description": "$string:migrate_data_want_param" | ||
| 9 | + } | ||
| 10 | + }, | ||
| 11 | + { | ||
| 12 | + "name": "migrateDataDistributedBaseView", | ||
| 13 | + "pageSourceFile": "src/main/ets/view/MigrateDataDistributedBaseView.ets", | ||
| 14 | + "buildFunction": "migrateDataDistributedBaseViewBuilder", | ||
| 15 | + "data": { | ||
| 16 | + "description": "$string:migrate_data_distributed_base" | ||
| 17 | + } | ||
| 18 | + }, | ||
| 19 | + { | ||
| 20 | + "name": "migrateDataDistributedMonoFileView", | ||
| 21 | + "pageSourceFile": "src/main/ets/view/MigrateDataDistributedMonoFileView.ets", | ||
| 22 | + "buildFunction": "migrateDataDistributedMonoFileViewBuilder", | ||
| 23 | + "data": { | ||
| 24 | + "description": "$string:migrate_data_distributed_mono_file" | ||
| 25 | + } | ||
| 26 | + }, | ||
| 27 | + { | ||
| 28 | + "name": "migrateDataDistributedMultiFileView", | ||
| 29 | + "pageSourceFile": "src/main/ets/view/MigrateDataDistributedMultiFileView.ets", | ||
| 30 | + "buildFunction": "migrateDataDistributedMultiFileViewBuilder", | ||
| 31 | + "data": { | ||
| 32 | + "description": "$string:migrate_data_distributed_multi_file" | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + ] | ||
| 36 | +} | ||
| @@ -0,0 +1,28 @@ | |||
| 1 | +{ | ||
| 2 | + "color": [ | ||
| 3 | + { | ||
| 4 | + "name": "start_window_background", | ||
| 5 | + "value": "#000000" | ||
| 6 | + }, | ||
| 7 | + { | ||
| 8 | + "name": "page_background", | ||
| 9 | + "value": "#1A1A1A" | ||
| 10 | + }, | ||
| 11 | + { | ||
| 12 | + "name": "button_background", | ||
| 13 | + "value": "#2A2A2A" | ||
| 14 | + }, | ||
| 15 | + { | ||
| 16 | + "name": "button_font", | ||
| 17 | + "value": "#6BB3F7" | ||
| 18 | + }, | ||
| 19 | + { | ||
| 20 | + "name": "text_font_gray", | ||
| 21 | + "value": "#8A8E94" | ||
| 22 | + }, | ||
| 23 | + { | ||
| 24 | + "name": "border_color", | ||
| 25 | + "value": "#4C4C4C" | ||
| 26 | + } | ||
| 27 | + ] | ||
| 28 | +} | ||
| @@ -0,0 +1,84 @@ | |||
| 1 | +{ | ||
| 2 | + "string": [ | ||
| 3 | + { | ||
| 4 | + "name": "module_desc", | ||
| 5 | + "value": "module description" | ||
| 6 | + }, | ||
| 7 | + { | ||
| 8 | + "name": "EntryAbility_desc", | ||
| 9 | + "value": "description" | ||
| 10 | + }, | ||
| 11 | + { | ||
| 12 | + "name": "EntryAbility_label", | ||
| 13 | + "value": "DataMigration" | ||
| 14 | + }, | ||
| 15 | + { | ||
| 16 | + "name": "migrate_data_want_param", | ||
| 17 | + "value": "Migrate simple data using want.param" | ||
| 18 | + }, | ||
| 19 | + { | ||
| 20 | + "name": "migrate_data_distributed_base", | ||
| 21 | + "value": "Use distributed object migration to transfer basic data" | ||
| 22 | + }, | ||
| 23 | + { | ||
| 24 | + "name": "migrate_data_distributed_mono_file", | ||
| 25 | + "value": "Using distributed object single-file migration" | ||
| 26 | + }, | ||
| 27 | + { | ||
| 28 | + "name": "migrate_data_distributed_multi_file", | ||
| 29 | + "value": "Using distributed object multi-file migration" | ||
| 30 | + }, | ||
| 31 | + { | ||
| 32 | + "name": "local_device", | ||
| 33 | + "value": "Local Devices" | ||
| 34 | + }, | ||
| 35 | + { | ||
| 36 | + "name": "add_picture_prompt", | ||
| 37 | + "value": "The number of added pictures reaches the upper limit." | ||
| 38 | + }, | ||
| 39 | + { | ||
| 40 | + "name": "continue_add", | ||
| 41 | + "value": "Continue Add" | ||
| 42 | + }, | ||
| 43 | + { | ||
| 44 | + "name": "image_add", | ||
| 45 | + "value": "Upper Limit" | ||
| 46 | + }, | ||
| 47 | + { | ||
| 48 | + "name": "add_high_img", | ||
| 49 | + "value": "Add Image" | ||
| 50 | + }, | ||
| 51 | + { | ||
| 52 | + "name": "permission_distributed_datasync", | ||
| 53 | + "value": "Allow data exchange between different devices" | ||
| 54 | + }, | ||
| 55 | + { | ||
| 56 | + "name": "basic_data", | ||
| 57 | + "value": "Basic Data" | ||
| 58 | + }, | ||
| 59 | + { | ||
| 60 | + "name": "data_object", | ||
| 61 | + "value": "Data Object" | ||
| 62 | + }, | ||
| 63 | + { | ||
| 64 | + "name": "image_file", | ||
| 65 | + "value": "Image File" | ||
| 66 | + }, | ||
| 67 | + { | ||
| 68 | + "name": "input_data_to_migrate", | ||
| 69 | + "value": "Enter data to migrate" | ||
| 70 | + }, | ||
| 71 | + { | ||
| 72 | + "name": "input_text_data_to_migrate", | ||
| 73 | + "value": "Enter text data to migrate" | ||
| 74 | + }, | ||
| 75 | + { | ||
| 76 | + "name": "input_number_data_to_migrate", | ||
| 77 | + "value": "Enter number data to migrate" | ||
| 78 | + }, | ||
| 79 | + { | ||
| 80 | + "name": "permission_read_imagevideo", | ||
| 81 | + "value": "Allow reading of image or video files in the user's public directory" | ||
| 82 | + } | ||
| 83 | + ] | ||
| 84 | +} | ||
| @@ -0,0 +1,84 @@ | |||
| 1 | +{ | ||
| 2 | + "string": [ | ||
| 3 | + { | ||
| 4 | + "name": "module_desc", | ||
| 5 | + "value": "module description" | ||
| 6 | + }, | ||
| 7 | + { | ||
| 8 | + "name": "EntryAbility_desc", | ||
| 9 | + "value": "description" | ||
| 10 | + }, | ||
| 11 | + { | ||
| 12 | + "name": "EntryAbility_label", | ||
| 13 | + "value": "应用接续数据迁移" | ||
| 14 | + }, | ||
| 15 | + { | ||
| 16 | + "name": "migrate_data_want_param", | ||
| 17 | + "value": "使用want.param迁移简单数据" | ||
| 18 | + }, | ||
| 19 | + { | ||
| 20 | + "name": "migrate_data_distributed_base", | ||
| 21 | + "value": "使用分布式对象迁移基础数据" | ||
| 22 | + }, | ||
| 23 | + { | ||
| 24 | + "name": "migrate_data_distributed_mono_file", | ||
| 25 | + "value": "使用分布式对象单文件迁移" | ||
| 26 | + }, | ||
| 27 | + { | ||
| 28 | + "name": "migrate_data_distributed_multi_file", | ||
| 29 | + "value": "使用分布式对象多文件迁移" | ||
| 30 | + }, | ||
| 31 | + { | ||
| 32 | + "name": "local_device", | ||
| 33 | + "value": "从本地设备获取" | ||
| 34 | + }, | ||
| 35 | + { | ||
| 36 | + "name": "add_picture_prompt", | ||
| 37 | + "value": "添加图片达到上限" | ||
| 38 | + }, | ||
| 39 | + { | ||
| 40 | + "name": "continue_add", | ||
| 41 | + "value": "继续添加" | ||
| 42 | + }, | ||
| 43 | + { | ||
| 44 | + "name": "image_add", | ||
| 45 | + "value": "添加已达上限" | ||
| 46 | + }, | ||
| 47 | + { | ||
| 48 | + "name": "add_high_img", | ||
| 49 | + "value": "添加优质首图" | ||
| 50 | + }, | ||
| 51 | + { | ||
| 52 | + "name": "permission_distributed_datasync", | ||
| 53 | + "value": "允许不同设备间的数据交换。" | ||
| 54 | + }, | ||
| 55 | + { | ||
| 56 | + "name": "basic_data", | ||
| 57 | + "value": "基础数据" | ||
| 58 | + }, | ||
| 59 | + { | ||
| 60 | + "name": "data_object", | ||
| 61 | + "value": "数据对象" | ||
| 62 | + }, | ||
| 63 | + { | ||
| 64 | + "name": "image_file", | ||
| 65 | + "value": "图片文件" | ||
| 66 | + }, | ||
| 67 | + { | ||
| 68 | + "name": "input_data_to_migrate", | ||
| 69 | + "value": "请输入需迁移的数据" | ||
| 70 | + }, | ||
| 71 | + { | ||
| 72 | + "name": "input_text_data_to_migrate", | ||
| 73 | + "value": "请输入需迁移的文字数据" | ||
| 74 | + }, | ||
| 75 | + { | ||
| 76 | + "name": "input_number_data_to_migrate", | ||
| 77 | + "value": "请输入需迁移的数字数据" | ||
| 78 | + }, | ||
| 79 | + { | ||
| 80 | + "name": "permission_read_imagevideo", | ||
| 81 | + "value": "允许读取用户公共目录的图片或视频文件" | ||
| 82 | + } | ||
| 83 | + ] | ||
| 84 | +} | ||
| @@ -0,0 +1,23 @@ | |||
| 1 | +{ | ||
| 2 | + "modelVersion": "6.1.1", | ||
| 3 | + "dependencies": { | ||
| 4 | + }, | ||
| 5 | + "execution": { | ||
| 6 | + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | "ultrafine" | false ]. Default: "normal" */ | ||
| 7 | + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ | ||
| 8 | + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ | ||
| 9 | + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ | ||
| 10 | + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ | ||
| 11 | + // "optimizationStrategy": "memory" /* Define the optimization strategy. Value: [ "memory" | "performance" ]. Default: "memory" */ | ||
| 12 | + }, | ||
| 13 | + "logging": { | ||
| 14 | + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ | ||
| 15 | + }, | ||
| 16 | + "debugging": { | ||
| 17 | + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ | ||
| 18 | + }, | ||
| 19 | + "nodeOptions": { | ||
| 20 | + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ | ||
| 21 | + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ | ||
| 22 | + } | ||
| 23 | +} | ||
| @@ -0,0 +1,6 @@ | |||
| 1 | +import { appTasks } from '@ohos/hvigor-ohos-plugin'; | ||
| 2 | + | ||
| 3 | +export default { | ||
| 4 | + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ | ||
| 5 | + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ | ||
| 6 | +} | ||