diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7490d6d251e8b6b7068c8cd6d8e309ad303eefdf --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.multitarget", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1dbf1d89a60c68bf6d6eb7247c10ff49f8cfdb42 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MultiTarget" + }, + { + "name": "test_app_name", + "value": "Test Version" + }, + { + "name": "official_app_name", + "value": "Official Version" + } + ] +} diff --git a/AppScope/resources/base/media/app_icon.png b/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/AppScope/resources/base/media/app_icon.png differ diff --git a/AppScope/resources/base/media/startIcon.png b/AppScope/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/AppScope/resources/base/media/startIcon.png differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..338e5b0bc22082e0ffcc7121c2ed3897a3ddccb0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,78 @@ + Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +Apache License, Version 2.0 +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: +1.You must give any other recipients of the Work or Derivative Works a copy of this License; and +2.You must cause any modified files to carry prominent notices stating that You changed the files; and +3.You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +4.If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/README.md b/README.md index 26cf9e0c3de5645af84ef53f11f48c03e83d22d6..f920875e8f99678f0c507aa95945be17734d09c3 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,106 @@ -# MultiTarget +# 多目标产物 -#### 介绍 -{**以下是 Gitee 平台说明,您可以替换此简介** -Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} +### 介绍 -#### 软件架构 -软件架构说明 +本示例展示了如何配置多目标产物,通过该示例可以构建出official和test两个版本的代码工程。 +* official版本工程:工程会在首页中显示Official版本的资源,包含一段描述、 一张图片以及一个按钮。点击按钮会实现页面跳转,第二个页面包含一个运算器逻辑,official版本支持进行加法运算和减法运算。输入两个不超过五位的数字,点击对应按钮,弹窗显示计算结果。 +* test版本工程:工程会在首页中显示Test版本的资源,包含一段描述、 一张图片以及一个按钮。点击按钮会实现页面跳转,第二个页面包含一个运算器逻辑,test版本仅支持进行减法运算。输入两个不超过五位的数字,点击减法按钮,弹窗显示计算结果;点击加法按钮,弹窗显示不支持该功能。 +### 效果图预览 -#### 安装教程 +| official版本 | test版本 | +|----------------------------------------|----------------------------------| +| ![](screenshots/device/official.gif) | ![](screenshots/device/test.gif) | -1. xxxx -2. xxxx -3. xxxx -#### 使用说明 +**使用说明** -1. xxxx -2. xxxx -3. xxxx +需要先对每个porduct进行签名配置,然后构建对应的版本,查看页面效果。点击按钮,跳转下一个页面。在第二个页面输入参数,点击对应方法按钮,查看调用结果。 -#### 参与贡献 +**注意事项** -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request +该示例仅展示official版本与test版本内容对比,default版本未实现其逻辑,开发者请勿使用default版本运行。 +**多目标产物签名配置方案:** +1. 在工程级的build-profile.json5文件中,给每个需要构建的多目标product下配置如图所示参数: -#### 特技 +![](screenshots/device/signingConfigs.png) +2. 然后进入到签名配置页面,点击加号,添加签名信息: -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +![](screenshots/device/signingConfigs1.png) +3. 然后选择对应的bundle name,并填写上面配置的"signingConfigs"信息: + +![](screenshots/device/signingConfigs2.png) +4. 签名之后点击ok即可: + +![](screenshots/device/signingConfigs3.png) + +**工程构建方法:** + +首先点击DevEco Studio工具右上角的Product按钮,即图中的1号标识处,然后在2号标识处选择对应的Product工程,选择完工程之后会自动映射出我们文件中已经依赖的target,最后点击Apply应用。上述操作完成之后就可以点击运行按钮查看多目标产物的效果了。 +![](screenshots/device/product_build.png) + +### 实现思路 + +1. 在每个HAP,HAR模块的模块级build-profile.json文件中定制出official版本和test版本对应的target,然后为每个target进行资源的差异化定制。 +2. 在工程级build-profile.json文件中定制出official版本和test版本对应的product,并为每个product定制APP多目标资源,并将每个模块生成的target依赖到对应版本的product中。 + +### 高性能知识点 + +**不涉及** + +### 工程结构&模块类型 +``` +├──entry/src // entry模块 +│ ├──main +│ │ ├──ets/pages +│ │ │ └──Index.ets // 主页界面 +│ │ ├──resources // 共有资源目录 +│ │ ├──official +│ │ │ └──resources // official版本定制资源目录 +│ │ └──test +│ │ └──resources // test版本定制资源目录 +│ ├──official_pages +│ │ └──VersionInfo.ets // official版本定制页面信息 +│ └──test_pages +│ └──VersionInfo.ets // test版本定制页面信息 +└──myhar/src // Har模块 + ├──main + │ ├──cpp + │ │ ├──cpp/types // 三方库接口声明信息 + │ │ └──CmakeLists.txt // cmake配置文件 + │ ├──ets/components + │ │ └──MainPage.ets // Har包主页面 + │ ├──ets/view + │ │ └──ParamTextInputComponent.ets // 自定义组件页面 + │ ├──resources // 共有资源目录 + │ ├──official + │ │ └──resources // official版本定制资源目录 + │ └──test + │ └──resources // test版本定制资源目录 + ├──official_pages + │ └──OfficialSecondPages.ets // official版本Har包第二页面 + ├──test_pages + │ └──TestSecondPages.ets // test版本Har包第二页面 + └──BuildProfile.ets // 自定义参数文件 +``` + +### 模块依赖 + +**不涉及** + +### 相关权限 + +**不涉及** + +### 参考资料 + +**不涉及** + +### 约束与限制 + +1. 该示例仅展示official版本与test版本内容对比,default版本未实现其逻辑,开发者请勿使用default版本运行。 +2. 本示例仅支持标准系统上运行,支持设备:华为手机。 +3. HarmonyOS系统:HarmonyOS 5.0.0 Release及以上。 +4. DevEco Studio版本:DevEco Studio 5.0.0 Release及以上。 +5. HarmonyOS SDK版本:HarmonyOS 5.0.0 Release SDK及以上。 \ No newline at end of file diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5653ed880ca12edab4854bd5b6e19f022051ee6a --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,88 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "official", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + }, + "bundleName": "com.official.com", + "bundleType": "app", + "icon": "$media:startIcon", + "label": "$string:official_app_name" + }, + { + "name": "test", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + }, + "bundleName": "com.test.com", + "bundleType": "app", + "icon": "$media:app_icon", + "label": "$string:test_app_name" + }, + { + "name": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "official", + "applyToProducts": [ + "official" + ] + }, + { + "name": "test", + "applyToProducts": [ + "test" + ] + } + ] + }, + { + "name": "myhar", + "srcPath": "./myhar", + "targets": [ + { + "name": "official", + "applyToProducts": [ + "official" + ] + }, + { + "name": "test", + "applyToProducts": [ + "test" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..fb20b581509887918d9ba3a24cc15d0381bb7475 --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,56 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "official", + "source": { + "pages": [ + "pages/Index" + ], + "sourceRoots": [ + "./src/official_pages" + ] + }, + "resource": { + "directories": [ + "./src/main/official/resources", + "./src/main/resources" + ] + } + }, + { + "name": "test", + "source": { + "pages": [ + "pages/Index" + ], + "sourceRoots": [ + "./src/test_pages" + ] + }, + "resource": { + "directories": [ + "./src/main/test/resources", + "./src/main/resources" + ] + } + }, + ] +} \ No newline at end of file diff --git a/entry/hvigorfile.ts b/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..00bea88b45daf463e7cc6be618aa6a130e4a2ff0 --- /dev/null +++ b/entry/oh-package.json5 @@ -0,0 +1,12 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "myhar": "file:../myhar" + } +} + diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..a32a8361c7fcad66acf12208583e198fc4e68dab --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..be794f48ccffc46278e76ce3493088a647b0d470 --- /dev/null +++ b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e13a98bb3e0c5a0f24840857e7a272869d8ed302 --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MainPage } from 'myhar' +import { getName, getTitleName } from 'entry/VersionInfo' + +@Entry +@Component +struct Index { + @State message: string = getName(); + @State titleMessage: Resource = getTitleName(); + + build() { + Column() { + Column() { + Text(this.titleMessage) + .height(40) + .fontSize(30) + .fontWeight(FontWeight.Medium) + Text(this.message) + .fontSize(14) + .fontWeight(FontWeight.Normal) + .fontColor(Color.Black) + .opacity(0.6) + .height(19) + .margin({ top: 2 }) + } + .height(78) + .width('100%') + .alignItems(HorizontalAlign.Start) + .padding({ + left: 12, + right: 12, + top: 8, + bottom: 12 + }) + + Row() { + MainPage() + .backgroundColor('#F1F3F5') + } + .layoutWeight(1) + } + .width('100%') + .height('100%') + .backgroundColor('#F1F3F5') + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) + } +} \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9e8514dbd84df39a77bc37b3a2e03eb6f342bd8e --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,52 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", +// "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/entry/src/main/official/resources/base/element/string.json b/entry/src/main/official/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..12bde27416781b53ed94c2178cfd10ed16870ac7 --- /dev/null +++ b/entry/src/main/official/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "title", + "value": "Official Version" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/official/resources/base/media/startIcon.png b/entry/src/main/official/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/entry/src/main/official/resources/base/media/startIcon.png differ diff --git a/entry/src/main/official/resources/en_US/element/string.json b/entry/src/main/official/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..12bde27416781b53ed94c2178cfd10ed16870ac7 --- /dev/null +++ b/entry/src/main/official/resources/en_US/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "title", + "value": "Official Version" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/official/resources/zh_CN/element/string.json b/entry/src/main/official/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9832fd805ed66a78c629c058a0e11898257ce7e5 --- /dev/null +++ b/entry/src/main/official/resources/zh_CN/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "title", + "value": "官方版" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e644e3a258836d662d776904229e76299f251e7a --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "title", + "value": "Test Version" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/background.png b/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/entry/src/main/resources/base/media/background.png differ diff --git a/entry/src/main/resources/base/media/foreground.png b/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/entry/src/main/resources/base/media/foreground.png differ diff --git a/entry/src/main/resources/base/media/layered_image.json b/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/startIcon.png b/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/entry/src/main/resources/base/media/startIcon.png differ diff --git a/entry/src/main/resources/base/profile/backup_config.json b/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e644e3a258836d662d776904229e76299f251e7a --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "title", + "value": "Test Version" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9f1885c1250010c16616c1961c60bc84f247adb0 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "title", + "value": "测试版" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/test/resources/base/element/string.json b/entry/src/main/test/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a7dc5819248e7967135e83a5d048a089675408c9 --- /dev/null +++ b/entry/src/main/test/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "title", + "value": "Test Version" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/test/resources/base/media/startIcon.png b/entry/src/main/test/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/entry/src/main/test/resources/base/media/startIcon.png differ diff --git a/entry/src/main/test/resources/en_US/element/string.json b/entry/src/main/test/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a7dc5819248e7967135e83a5d048a089675408c9 --- /dev/null +++ b/entry/src/main/test/resources/en_US/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "title", + "value": "Test Version" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/test/resources/zh_CN/element/string.json b/entry/src/main/test/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1b61fa9e916cefc13aaa1eb45af96bcb126b0b12 --- /dev/null +++ b/entry/src/main/test/resources/zh_CN/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "title", + "value": "测试版" + } + ] +} \ No newline at end of file diff --git a/entry/src/official_pages/VersionInfo.ets b/entry/src/official_pages/VersionInfo.ets new file mode 100644 index 0000000000000000000000000000000000000000..ffbd127da422fcb1657aec5de867642ea4630341 --- /dev/null +++ b/entry/src/official_pages/VersionInfo.ets @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export const getName = () => "This is official version." +export const getTitleName = () => $r('app.string.title') \ No newline at end of file diff --git a/entry/src/test_pages/VersionInfo.ets b/entry/src/test_pages/VersionInfo.ets new file mode 100644 index 0000000000000000000000000000000000000000..c38a68b517274e806b6d1983df7b6880da2cfbce --- /dev/null +++ b/entry/src/test_pages/VersionInfo.ets @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export const getName = () => "This is test version." +export const getTitleName = () => $r('app.string.title') \ No newline at end of file diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..06b2783670a348f95533b352c1ceda909a842bbc --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/hvigorfile.ts b/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/myhar/BuildProfile.ets b/myhar/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..946d034059cd0dcd0165a3a04c0349cc78b02a7b --- /dev/null +++ b/myhar/BuildProfile.ets @@ -0,0 +1,19 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'official'; +export const productName = 'official'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; + static readonly productName = productName; +} \ No newline at end of file diff --git a/myhar/Index.ets b/myhar/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..10ebb3efed9a6e0ed13465ad26519d94270f1ca8 --- /dev/null +++ b/myhar/Index.ets @@ -0,0 +1 @@ +export { MainPage } from './src/main/ets/components/MainPage' diff --git a/myhar/build-profile.json5 b/myhar/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..95a23bdfb828ff83c348b8e504c419ad0d90b257 --- /dev/null +++ b/myhar/build-profile.json5 @@ -0,0 +1,84 @@ +{ + "apiType": "stageMode", + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "official", + "config": { + "buildOption": { + "arkOptions": { + "buildProfileFields": { + "productName": "official" + } + }, + "nativeLib": { + "filter": { + "excludes": [ + "../libs/arm64-v8a/libentry.so" + ] + } + } + } + }, + "runtimeOS": "HarmonyOS", + "output": { + "artifactName": "official" + }, + "source": { + "sourceRoots": [ + "./src/official_pages" + ] + }, + "resource": { + "directories": [ + "./src/main/official/resources", + "./src/main/resources" + ] + } + }, + { + "name": "test", + "config": { + "buildOption": { + "arkOptions": { + "buildProfileFields": { + "productName": "test" + } + } + } + }, + "runtimeOS": "HarmonyOS", + "output": { + "artifactName": "test" + }, + "source": { + "sourceRoots": [ + "./src/test_pages" + ] + }, + "resource": { + "directories": [ + "./src/main/test/resources", + "./src/main/resources" + ] + } + } + ] +} diff --git a/myhar/hvigorfile.ts b/myhar/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42187071482d292588ad40babeda74f7b8d97a23 --- /dev/null +++ b/myhar/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/myhar/libs/arm64-v8a/libAdd.so b/myhar/libs/arm64-v8a/libAdd.so new file mode 100644 index 0000000000000000000000000000000000000000..5775224983872a8efd1d48649f24c2a8b63c69c1 Binary files /dev/null and b/myhar/libs/arm64-v8a/libAdd.so differ diff --git a/myhar/libs/arm64-v8a/libSub.so b/myhar/libs/arm64-v8a/libSub.so new file mode 100644 index 0000000000000000000000000000000000000000..7058667268fa977e47cf2f983396a369619a048f Binary files /dev/null and b/myhar/libs/arm64-v8a/libSub.so differ diff --git a/myhar/libs/arm64-v8a/libc++_shared.so b/myhar/libs/arm64-v8a/libc++_shared.so new file mode 100644 index 0000000000000000000000000000000000000000..737c395840776cab9e36e793027ec4bde80121a4 Binary files /dev/null and b/myhar/libs/arm64-v8a/libc++_shared.so differ diff --git a/myhar/libs/arm64-v8a/libentry.so b/myhar/libs/arm64-v8a/libentry.so new file mode 100644 index 0000000000000000000000000000000000000000..7afcb71153db9ad1f7b1c1ba9579599207d132ff Binary files /dev/null and b/myhar/libs/arm64-v8a/libentry.so differ diff --git a/myhar/libs/x86_64/libAdd.so b/myhar/libs/x86_64/libAdd.so new file mode 100644 index 0000000000000000000000000000000000000000..27bfe9d03e193fbab0a99def3847d5ded1724ad7 Binary files /dev/null and b/myhar/libs/x86_64/libAdd.so differ diff --git a/myhar/libs/x86_64/libSub.so b/myhar/libs/x86_64/libSub.so new file mode 100644 index 0000000000000000000000000000000000000000..0b8e3f4dfe4b9fb578846ef7120f89db8c551d16 Binary files /dev/null and b/myhar/libs/x86_64/libSub.so differ diff --git a/myhar/libs/x86_64/libc++_shared.so b/myhar/libs/x86_64/libc++_shared.so new file mode 100644 index 0000000000000000000000000000000000000000..bdc63df5697931653c7b40e325c8a4ac7050c859 Binary files /dev/null and b/myhar/libs/x86_64/libc++_shared.so differ diff --git a/myhar/libs/x86_64/libentry.so b/myhar/libs/x86_64/libentry.so new file mode 100644 index 0000000000000000000000000000000000000000..bdc63df5697931653c7b40e325c8a4ac7050c859 Binary files /dev/null and b/myhar/libs/x86_64/libentry.so differ diff --git a/myhar/oh-package.json5 b/myhar/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3707b0d3138de9408309958359d65918837591d0 --- /dev/null +++ b/myhar/oh-package.json5 @@ -0,0 +1,12 @@ +{ + "name": "myhar", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": { + "libAdd.so": "file:./src/main/cpp/types/libAdd", + "libSub.so": "file:./src/main/cpp/types/libSub" + } +} \ No newline at end of file diff --git a/myhar/src/main/cpp/types/libAdd/Index.d.ts b/myhar/src/main/cpp/types/libAdd/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7f730f61dca891bd463444ec0bb01f5964c8ddb2 --- /dev/null +++ b/myhar/src/main/cpp/types/libAdd/Index.d.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export const add: (a: number, b: number) => number; \ No newline at end of file diff --git a/myhar/src/main/cpp/types/libAdd/oh-package.json5 b/myhar/src/main/cpp/types/libAdd/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..14f0602647999c1b0faf08db480ca854594457bb --- /dev/null +++ b/myhar/src/main/cpp/types/libAdd/oh-package.json5 @@ -0,0 +1,6 @@ +{ + "name": "libAdd.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/myhar/src/main/cpp/types/libSub/Index.d.ts b/myhar/src/main/cpp/types/libSub/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..307f96e9334fd60c3e363f77197381b45c899ec2 --- /dev/null +++ b/myhar/src/main/cpp/types/libSub/Index.d.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export const sub: (a: number, b: number) => number; \ No newline at end of file diff --git a/myhar/src/main/cpp/types/libSub/oh-package.json5 b/myhar/src/main/cpp/types/libSub/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7f46ae08a49255c9eeef04f4538a31a87d72435a --- /dev/null +++ b/myhar/src/main/cpp/types/libSub/oh-package.json5 @@ -0,0 +1,6 @@ +{ + "name": "libSub.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/myhar/src/main/ets/components/MainPage.ets b/myhar/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..4fed1c1172b5e4f9044de664ea328a55b0300d25 --- /dev/null +++ b/myhar/src/main/ets/components/MainPage.ets @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import BuildProfile from '../../../../BuildProfile'; +import { OfficialSecond } from '../../../official_pages/OfficialSecondPage'; +import { TestSecond } from '../../../test_pages/TestSecondPage'; + +@Component +export struct MainPage { + @Provide('pageInfos') pageInfos: NavPathStack = new NavPathStack(); + + @Builder + PagesMap(name: string) { + if (name == 'official') { + OfficialSecond(); + } else { + TestSecond(); + } + } + + build() { + Navigation(this.pageInfos) { + Row() { + Column() { + TextArea({ text: $r('app.string.title_description') }) + .fontSize(16) + .width('100%') + .fontColor('#e6000000') + .fontWeight(FontWeight.Normal) + .borderRadius(16) + .focusable(false) + Image($r('app.media.HarImage')) + .width('100%') + .borderRadius(12) + .padding({ top: 16 }) + Blank() + Button($r('app.string.button_describe')) + .fontSize(16) + .height(40) + .width('100%') + .onClick(() => { + this.pageInfos.pushPath({ name: BuildProfile.productName }); + }) + } + .width('100%') + .height('100%') + .padding({ left: 16, right: 16, bottom: 16 }) + } + .height('100%') + } + .navDestination(this.PagesMap) + .hideTitleBar(true) + } +} \ No newline at end of file diff --git a/myhar/src/main/ets/view/ParamTextInputComponent.ets b/myhar/src/main/ets/view/ParamTextInputComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..25cb6a2c4fb6a016164648b171244b07322a94b8 --- /dev/null +++ b/myhar/src/main/ets/view/ParamTextInputComponent.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Component +export struct ParamTextInputComponent { + @Link param: string; + @Prop paramName: Resource | string; + @Prop inputAlert: Resource | string; + judge = (str: string) => { + for (let i = 0; i < str.length; i++) { + if (str[i] !== '0') { + return false; + } + } + return true; + } + + build() { + Column() { + Text(this.paramName) + .fontSize(14) + .fontColor(Color.Black) + .fontWeight(500) + .opacity(0.6) + .height(20) + TextInput({ text: this.param, placeholder: this.inputAlert }) + .type(InputType.Number) + .maxLength(5) + .height(40) + .backgroundColor(Color.White) + .fontSize(16) + .fontColor(Color.Black) + .opacity(0.6) + .fontWeight(FontWeight.Normal) + .onChange((value) => { + if (value.length > 0 && this.judge(value)) { + this.param = '0'; + } else { + this.param = value.replace(/^0+/, ''); + } + }) + .backgroundColor(Color.White) + .borderRadius(24) + .margin({ top: 8, bottom: 8 }) + } + .padding({ left: 16, right: 16, top: 12 }) + .alignItems(HorizontalAlign.Start) + } +} \ No newline at end of file diff --git a/myhar/src/main/module.json5 b/myhar/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5ea21b06a7db77895904084788903b550eae21a6 --- /dev/null +++ b/myhar/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "myhar", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/myhar/src/main/official/resources/base/element/string.json b/myhar/src/main/official/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..35238800fc92cbf5d138ae629b7cdaf7151f4888 --- /dev/null +++ b/myhar/src/main/official/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "title_description", + "value": "This is the first page of the official HAR module. Click the button below to jump to the second page of the official HAR module - the calculator page." + } + ] +} diff --git a/myhar/src/main/official/resources/base/media/HarImage.jpg b/myhar/src/main/official/resources/base/media/HarImage.jpg new file mode 100644 index 0000000000000000000000000000000000000000..38ed1175b95245bbb3e93e745adfd4500f859535 Binary files /dev/null and b/myhar/src/main/official/resources/base/media/HarImage.jpg differ diff --git a/myhar/src/main/official/resources/en_US/element/string.json b/myhar/src/main/official/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..35238800fc92cbf5d138ae629b7cdaf7151f4888 --- /dev/null +++ b/myhar/src/main/official/resources/en_US/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "title_description", + "value": "This is the first page of the official HAR module. Click the button below to jump to the second page of the official HAR module - the calculator page." + } + ] +} diff --git a/myhar/src/main/official/resources/zh_CN/element/string.json b/myhar/src/main/official/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0dbdd3aefaee6326f2dcf399d284f5f2863e8223 --- /dev/null +++ b/myhar/src/main/official/resources/zh_CN/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "title_description", + "value": "这是官方版HAR模块的第一个页面,点击下方按钮跳转至官方版HAR模块第二个页面——运算器页面。" + } + ] +} diff --git a/myhar/src/main/resources/base/element/string.json b/myhar/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2e805adbb90f2963887581f51e747b5298ad0683 --- /dev/null +++ b/myhar/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + }, + { + "name": "button_describe", + "value": "Jump To The Calculator Page" + }, + { + "name": "default_describe", + "value": "This function is not supported in the default version." + }, + { + "name": "default_add", + "value": "Add" + }, + { + "name": "default_sub", + "value": "Sub" + }, + { + "name": "test_describe", + "value": "The test version will be replaced by the resource with the same name in resources_test." + } + ] +} diff --git a/myhar/src/main/resources/base/media/HarImage.jpg b/myhar/src/main/resources/base/media/HarImage.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f4d75a5d2060920b48dfe6b6ce3e013e1c4d2919 Binary files /dev/null and b/myhar/src/main/resources/base/media/HarImage.jpg differ diff --git a/myhar/src/main/resources/en_US/element/string.json b/myhar/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2e805adbb90f2963887581f51e747b5298ad0683 --- /dev/null +++ b/myhar/src/main/resources/en_US/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + }, + { + "name": "button_describe", + "value": "Jump To The Calculator Page" + }, + { + "name": "default_describe", + "value": "This function is not supported in the default version." + }, + { + "name": "default_add", + "value": "Add" + }, + { + "name": "default_sub", + "value": "Sub" + }, + { + "name": "test_describe", + "value": "The test version will be replaced by the resource with the same name in resources_test." + } + ] +} diff --git a/myhar/src/main/resources/zh_CN/element/string.json b/myhar/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ff8fc0dd5024c952483e6e064a8dfff918227228 --- /dev/null +++ b/myhar/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + }, + { + "name": "button_describe", + "value": "跳转运算器页面" + }, + { + "name": "default_describe", + "value": "Default 版本不支持此功能" + }, + { + "name": "default_add", + "value": "加法" + }, + { + "name": "default_sub", + "value": "减法" + }, + { + "name": "test_describe", + "value": "test 版本会被resources_test中的同名资源替换" + } + ] +} diff --git a/myhar/src/main/test/resources/base/element/string.json b/myhar/src/main/test/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..718c9d75714eb19c874f461836f32ad85b72ee76 --- /dev/null +++ b/myhar/src/main/test/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "title_description", + "value": "This is the first page of the beta version of the HAR module. Click the button below to jump to the second page of the beta version of the HAR module - the calculator page." + }, + { + "name": "test_describe", + "value": "This function is not supported in the test version." + } + ] +} diff --git a/myhar/src/main/test/resources/base/media/HarImage.jpg b/myhar/src/main/test/resources/base/media/HarImage.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f4d75a5d2060920b48dfe6b6ce3e013e1c4d2919 Binary files /dev/null and b/myhar/src/main/test/resources/base/media/HarImage.jpg differ diff --git a/myhar/src/main/test/resources/en_US/element/string.json b/myhar/src/main/test/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..718c9d75714eb19c874f461836f32ad85b72ee76 --- /dev/null +++ b/myhar/src/main/test/resources/en_US/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "title_description", + "value": "This is the first page of the beta version of the HAR module. Click the button below to jump to the second page of the beta version of the HAR module - the calculator page." + }, + { + "name": "test_describe", + "value": "This function is not supported in the test version." + } + ] +} diff --git a/myhar/src/main/test/resources/zh_CN/element/string.json b/myhar/src/main/test/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..cc2a409d7344c4d72b9d86ea1a57be3dcb34d31e --- /dev/null +++ b/myhar/src/main/test/resources/zh_CN/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "title_description", + "value": "这是测试版HAR模块的第一个页面,点击下方按钮跳转至测试版HAR模块第二个页面——运算器页面。" + }, + { + "name": "test_describe", + "value": "test 版本不支持此功能" + } + ] +} diff --git a/myhar/src/official_pages/OfficialSecondPage.ets b/myhar/src/official_pages/OfficialSecondPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..c5b9e430a6fa76448ddb7d1cc52561cfbc732971 --- /dev/null +++ b/myhar/src/official_pages/OfficialSecondPage.ets @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import libAdd from 'libAdd.so'; +import libSub from 'libSub.so'; +import { ParamTextInputComponent } from '../main/ets/view/ParamTextInputComponent'; +import { promptAction } from '@kit.ArkUI'; + +@Component +export struct OfficialSecond { + @Consume('pageInfos') pageInfos: NavPathStack; + @State paramX: string = ''; + @State paramY: string = ''; + + @Styles + customButtonStyle(){ + .height(40) + .width('100%') + } + + customToast(str: ResourceStr) { + promptAction.showToast({ message: str, duration: 2000, bottom: '80vp' }) + } + + build() { + NavDestination() { + Column() { + Column() { + ParamTextInputComponent({ + param: this.paramX, + paramName: 'parameter X', + inputAlert: 'Please input parameter X.', + }) + ParamTextInputComponent({ + param: this.paramY, + paramName: 'parameter Y', + inputAlert: 'Please input parameter Y.', + }) + } + .width('100%') + + Blank() + + Column({ space: 12 }) { + Button($r('app.string.default_add')) + .customButtonStyle() + .onClick(() => { + let context = 'parameter X + Y = '; + let result = libAdd.add(Number(this.paramX), Number(this.paramY)); + this.customToast(context + result.toString()); + }) + + Button($r('app.string.default_sub')) + .customButtonStyle() + .onClick(() => { + let context = 'parameter X - Y = '; + let result = libSub.sub(Number(this.paramX), Number(this.paramY)); + this.customToast(context + result.toString()); + }) + } + .width('100%') + .padding({ left: 16, right: 16, bottom: 16 }) + } + .height('100%') + .backgroundColor('#F1F3F5') + .expandSafeArea([SafeAreaType.SYSTEM],[SafeAreaEdge.BOTTOM]) + } + .hideTitleBar(true) + } +} \ No newline at end of file diff --git a/myhar/src/test_pages/TestSecondPage.ets b/myhar/src/test_pages/TestSecondPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..f6d492bed7a11cf44585713ae87a02806474c2fa --- /dev/null +++ b/myhar/src/test_pages/TestSecondPage.ets @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import libSub from 'libSub.so'; +import { ParamTextInputComponent } from '../main/ets/view/ParamTextInputComponent'; +import { promptAction } from '@kit.ArkUI'; + +@CustomDialog +struct CustomDialogExample { + controller: CustomDialogController = new CustomDialogController({ + builder: CustomDialogExample(), + }) + + build() { + Column() { + Text($r('app.string.test_describe')) + .fontSize(20) + .margin({ top: 10, bottom: 10 }) + } + } +} + +@Component +export struct TestSecond { + @Consume('pageInfos') pageInfos: NavPathStack; + @State paramX: string = ''; + @State paramY: string = ''; + + @Styles + customButtonStyle(){ + .height(40) + .width('100%') + } + + customToast(str: ResourceStr) { + promptAction.showToast({ message: str, duration: 2000, bottom: '80vp' }) + } + + build() { + NavDestination() { + Column() { + Column() { + ParamTextInputComponent({ + param: this.paramX, + paramName: 'parameter X', + inputAlert: 'Please input parameter X.', + }) + ParamTextInputComponent({ + param: this.paramY, + paramName: 'parameter Y', + inputAlert: 'Please input parameter Y.', + }) + } + .width('100%') + + Blank() + + Column({ space: 12 }) { + Button($r('app.string.default_add')) + .customButtonStyle() + .onClick(() => { + let context = $r('app.string.test_describe') + this.customToast(context); + }) + + Button($r('app.string.default_sub')) + .customButtonStyle() + .onClick(() => { + let context = 'parameter X - Y = '; + let result = libSub.sub(Number(this.paramX), Number(this.paramY)); + this.customToast(context + result.toString()); + }) + } + .width('100%') + .padding({ left: 16, right: 16, bottom: 16 }) + } + .height('100%') + .backgroundColor('#F1F3F5') + .expandSafeArea([SafeAreaType.SYSTEM],[SafeAreaEdge.BOTTOM]) + } + .hideTitleBar(true) + } +} \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..bb12751b97530b9a3504e56e8ed09d8c9ba1fa52 --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/screenshots/device/official.gif b/screenshots/device/official.gif new file mode 100644 index 0000000000000000000000000000000000000000..4af6bbf9130b947f73a1dfb23807153255d7184a Binary files /dev/null and b/screenshots/device/official.gif differ diff --git a/screenshots/device/product_build.png b/screenshots/device/product_build.png new file mode 100644 index 0000000000000000000000000000000000000000..1e32e9aa24233a7e467621d13a5bf55f8ba3ddff Binary files /dev/null and b/screenshots/device/product_build.png differ diff --git a/screenshots/device/signingConfigs.png b/screenshots/device/signingConfigs.png new file mode 100644 index 0000000000000000000000000000000000000000..92e8dd21bf346aa89a04f2fe897199327ee9d149 Binary files /dev/null and b/screenshots/device/signingConfigs.png differ diff --git a/screenshots/device/signingConfigs1.png b/screenshots/device/signingConfigs1.png new file mode 100644 index 0000000000000000000000000000000000000000..9bf23b5a1c4914bd00ebf3114d2130cc3277c5bb Binary files /dev/null and b/screenshots/device/signingConfigs1.png differ diff --git a/screenshots/device/signingConfigs2.png b/screenshots/device/signingConfigs2.png new file mode 100644 index 0000000000000000000000000000000000000000..d10f36d25c83096cfa9d404163ac02aee4a61c62 Binary files /dev/null and b/screenshots/device/signingConfigs2.png differ diff --git a/screenshots/device/signingConfigs3.png b/screenshots/device/signingConfigs3.png new file mode 100644 index 0000000000000000000000000000000000000000..ea137b79042001bb50ddbe3b1ae6fd2e5c210f06 Binary files /dev/null and b/screenshots/device/signingConfigs3.png differ diff --git a/screenshots/device/test.gif b/screenshots/device/test.gif new file mode 100644 index 0000000000000000000000000000000000000000..0d2bdf1349534a127aea2ed809d30c967ecfa324 Binary files /dev/null and b/screenshots/device/test.gif differ