diff --git a/AnimationDemo/LICENSE b/AnimationDemo/LICENSE deleted file mode 100644 index 7c357dc828cf7d8c783f10ed6bb1bac8a1e903c1..0000000000000000000000000000000000000000 --- a/AnimationDemo/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - Copyright (c) 2021 Huawei Device Co., Ltd. - - Licensed under the Apache License,Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -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/AnimationDemo/README.md b/AnimationDemo/README.md deleted file mode 100644 index dca5d5e4acedf88f26ea2adf6c485a87b6be6258..0000000000000000000000000000000000000000 --- a/AnimationDemo/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# AnimationDemo -简介 -• 此demo使用的是通用动画样式,我们通过一个简单的样例,实现了平移、旋转、缩放以及透明度变化的效果。 - -安装要求 -• 安装DevEco Studio -• 设置DevEco Studio开发环境。DevEco Studio开发环境需要连接到网络,以确保该正常使用。可以根据以下两种情况配置开发环境: - 1.如果您可以直接访问Internet,则只需下载HarmonyOS SDK - 2.如果网络无法直接访问Internet,则可以通过代理服务器进行访问 -• 生成密钥并申请证书 - -用户指南 -• 下载此项目 -• 打开HUAWEI DevEco Studio,单击File> Open选择此ComponentCodelab -• 单击Build> Build App(s)/Hap(s)>Build Debug Hap(s)以编译hap软件包 -• 单击Run> Run 'entry'以运行hap包 - -注意 -• 您可以选择在模拟器或真机上运行hap软件包。 -• 如果在真机上运行它,则需要在项目的File> Project Structure> Modules> Signing Configs中配置签名和证书信息。 - -许可 -请参阅LICENSE文件以获得更多信息。 - -What is it? -This demo uses the general animation style. We use a simple example to implement translation, rotation, scaling, and transparency changes. - -Installation requirements -• Install DevEco Studio -• Set up the DevEco Studio development environment.The DevEco Studio development environment needs to depend on the network environment. It needs to be connected to the network to ensure the normal use of the tool.The development environment can be configured according to the following two situations - 1.If you can directly access the Internet, just download the HarmonyOS SDK - 2.If the network cannot access the Internet directly, it can be accessed through a proxy server -• Generate secret key and apply for certificate - -User guide -• Download this Project -• Open HUAWEI DevEco Studio, click File> Open> Then select and open this Project -• Click Build> Build App(s)/Hap(s)>Build Debug Hap(s) to compile the hap package -• Click Run> Run 'entry' to run the hap package - -Note -• You can choose to run the hap package on the simulator or the phone. -• If you run it on the phone, you need to configure the signature and certificate information in the project's File> Project Structure> Modules> Signing Configs. - -Licensing -Please see LICENSE for more info. - diff --git a/AnimationDemo/RELEASE-NOTES.MD b/AnimationDemo/RELEASE-NOTES.MD deleted file mode 100644 index 9087a1482627f316280b762b6c5adc73c0d438d1..0000000000000000000000000000000000000000 --- a/AnimationDemo/RELEASE-NOTES.MD +++ /dev/null @@ -1 +0,0 @@ -1.0.0.1 Initial version \ No newline at end of file diff --git a/AnimationDemo/build.gradle b/AnimationDemo/build.gradle index 053b598314427762ef9ed02bced2d2b234093d42..9cf74c205fc884ae2c6796ce2298ecbe3f40672d 100644 --- a/AnimationDemo/build.gradle +++ b/AnimationDemo/build.gradle @@ -3,10 +3,7 @@ apply plugin: 'com.huawei.ohos.app' //For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 4 - } + compileSdkVersion 6 } buildscript { @@ -19,8 +16,8 @@ buildscript { } } dependencies { - classpath 'com.huawei.ohos:hap:2.4.5.0' - classpath 'com.huawei.ohos:decctest:1.2.4.1' + classpath 'com.huawei.ohos:hap:2.4.5.5' + classpath 'com.huawei.ohos:decctest:1.2.5.1' } } diff --git a/ToolbarApplication/entry/.gitignore b/AnimationDemo/entry/.gitignore similarity index 100% rename from ToolbarApplication/entry/.gitignore rename to AnimationDemo/entry/.gitignore diff --git a/AnimationDemo/entry/build.gradle b/AnimationDemo/entry/build.gradle index 6618a979327905114e1a5efa61aca8805144d664..cccb71cae91018743841ab76aeb19c595f4ed847 100644 --- a/AnimationDemo/entry/build.gradle +++ b/AnimationDemo/entry/build.gradle @@ -1,10 +1,9 @@ apply plugin: 'com.huawei.ohos.hap' -apply plugin: 'com.huawei.ohos.decctest' //For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 ohos { - compileSdkVersion 5 + compileSdkVersion 6 defaultConfig { - compatibleSdkVersion 4 + compatibleSdkVersion 6 } buildTypes { release { @@ -14,13 +13,11 @@ ohos { } } } + + supportSystem "standard" } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) testImplementation 'junit:junit:4.13' - ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.200' -} -decc { - supportType = ['html', 'xml'] } diff --git a/AnimationDemo/entry/src/main/config.json b/AnimationDemo/entry/src/main/config.json index dcd3b9daf8d4224dabc681cceb30fc5dd52d8108..0e3106cec6b0a40eb2ea7bd1cf28e3acab4d8b19 100644 --- a/AnimationDemo/entry/src/main/config.json +++ b/AnimationDemo/entry/src/main/config.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.huawei.codelab", + "bundleName": "com.huawei.cookbook", "vendor": "huawei", "version": { "code": 1000000, @@ -9,9 +9,9 @@ }, "deviceConfig": {}, "module": { - "package": "com.huawei.codelab", + "package": "com.huawei.animationdemo", "name": ".MyApplication", - "mainAbility": "com.huawei.codelab.MainAbility", + "mainAbility": "com.huawei.animationdemo.MainAbility", "deviceType": [ "phone" ], @@ -19,7 +19,7 @@ "deliveryWithInstall": true, "moduleName": "entry", "moduleType": "entry", - "installationFree": true + "installationFree": false }, "abilities": [ { @@ -33,9 +33,11 @@ ] } ], - "name": "com.huawei.codelab.MainAbility", + "orientation": "unspecified", + "name": "com.huawei.animationdemo.MainAbility", "icon": "$media:icon", "description": "$string:mainability_description", + "formsEnabled": false, "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" @@ -44,12 +46,13 @@ "js": [ { "pages": [ - "pages/index/index" + "pages/index/index", + "pages/second/second" ], "name": "default", "window": { "designWidth": 720, - "autoDesignWidth": true + "autoDesignWidth": false } } ] diff --git a/AnimationDemo/entry/src/main/java/com/huawei/codelab/MainAbility.java b/AnimationDemo/entry/src/main/java/com/huawei/codelab/MainAbility.java deleted file mode 100644 index dc322f31e26af610b5dc38d763fb0499fc5768bd..0000000000000000000000000000000000000000 --- a/AnimationDemo/entry/src/main/java/com/huawei/codelab/MainAbility.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab; - -import ohos.aafwk.content.Intent; -import ohos.ace.ability.AceAbility; - -/** - * MainAbility - * - * @since 2021-08-13 - */ -public class MainAbility extends AceAbility { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - } - - @Override - public void onStop() { - super.onStop(); - } -} diff --git a/AnimationDemo/entry/src/main/java/com/huawei/codelab/MyApplication.java b/AnimationDemo/entry/src/main/java/com/huawei/codelab/MyApplication.java deleted file mode 100644 index 187dc063c4a35a429e2be829805292c21a510910..0000000000000000000000000000000000000000 --- a/AnimationDemo/entry/src/main/java/com/huawei/codelab/MyApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab; - -import ohos.aafwk.ability.AbilityPackage; - -/** - * MyApplication - * - * @since 2021-08-13 - */ -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/AnimationDemo/entry/src/main/js/default/app.js b/AnimationDemo/entry/src/main/js/default/app.js index b6ace9fa8c02f05c988f27c74b5552bfc26dac95..6d060ffe5682c19fc83e2274a9e62cbc40a655f8 100644 --- a/AnimationDemo/entry/src/main/js/default/app.js +++ b/AnimationDemo/entry/src/main/js/default/app.js @@ -1,23 +1,8 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } }; diff --git a/AnimationDemo/entry/src/main/js/default/i18n/en-US.json b/AnimationDemo/entry/src/main/js/default/i18n/en-US.json index e63c70d978a3a53be988388c87182f81785e170c..08e34eac912bf2651eefc20e26aa479b5e4e7ec2 100644 --- a/AnimationDemo/entry/src/main/js/default/i18n/en-US.json +++ b/AnimationDemo/entry/src/main/js/default/i18n/en-US.json @@ -1,6 +1,11 @@ { "strings": { "hello": "Hello", - "world": "World" + "world": "World", + "page": "Second Page", + "next": "Next Page", + "back": "Back" + }, + "Files": { } } \ No newline at end of file diff --git a/AnimationDemo/entry/src/main/js/default/i18n/zh-CN.json b/AnimationDemo/entry/src/main/js/default/i18n/zh-CN.json index de6ee5748322f44942c1b003319d8e66c837675f..3dd53b3a8b808aec9396fa663cb00ef22ba61e0a 100644 --- a/AnimationDemo/entry/src/main/js/default/i18n/zh-CN.json +++ b/AnimationDemo/entry/src/main/js/default/i18n/zh-CN.json @@ -1,6 +1,11 @@ { "strings": { "hello": "您好", - "world": "世界" + "world": "世界", + "page": "第二页", + "next": "下一页", + "back": "返回" + }, + "Files": { } } \ No newline at end of file diff --git a/AnimationDemo/entry/src/main/js/default/pages/index/index.css b/AnimationDemo/entry/src/main/js/default/pages/index/index.css index d94b82e831ac9c1f9cb3441bab4f7ed0efa47b69..1bdd23324887c7a53bf512a796910ecb235ff36d 100644 --- a/AnimationDemo/entry/src/main/js/default/pages/index/index.css +++ b/AnimationDemo/entry/src/main/js/default/pages/index/index.css @@ -1,23 +1,10 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - .container { background-color: #F8FCF5; flex-direction: column; justify-content: center; align-items: center; + height: 100%; + width: 100%; } .img { @@ -112,6 +99,4 @@ to { opacity: 1; } -} - - +} \ No newline at end of file diff --git a/AnimationDemo/entry/src/main/js/default/pages/index/index.hml b/AnimationDemo/entry/src/main/js/default/pages/index/index.hml index 0cef0f1c9f7af94237fb319af366bafa964465c5..48aadd9c129ab2f362381b0d08e68d576303ea5a 100644 --- a/AnimationDemo/entry/src/main/js/default/pages/index/index.hml +++ b/AnimationDemo/entry/src/main/js/default/pages/index/index.hml @@ -1,16 +1,3 @@ - -
translate diff --git a/AnimationDemo/entry/src/main/js/default/pages/index/index.js b/AnimationDemo/entry/src/main/js/default/pages/index/index.js index c89a4e391f4a1ea4cd60dce468d20d61ec781ca7..b1c6ea436a540020ff61f01dea449d5b39367b27 100644 --- a/AnimationDemo/entry/src/main/js/default/pages/index/index.js +++ b/AnimationDemo/entry/src/main/js/default/pages/index/index.js @@ -1,16 +1 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - export default {} diff --git a/ToolbarApplication/entry/src/main/js/default/common/fifth/second.css b/AnimationDemo/entry/src/main/js/default/pages/second/second.css similarity index 43% rename from ToolbarApplication/entry/src/main/js/default/common/fifth/second.css rename to AnimationDemo/entry/src/main/js/default/pages/second/second.css index ce4a2184b50f8339f6b31ae524ad77e22a1cd531..31a367638424feefb8cc68f60cb809bef8443197 100644 --- a/ToolbarApplication/entry/src/main/js/default/common/fifth/second.css +++ b/AnimationDemo/entry/src/main/js/default/pages/second/second.css @@ -1,5 +1,6 @@ .container { display: flex; + flex-direction: column; justify-content: center; align-items: center; left: 0px; @@ -8,3 +9,16 @@ height: 100%; } +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} + +.btn { + width: 50%; + height: 100px; + font-size: 40px; +} diff --git a/AnimationDemo/entry/src/ohosTest/js/default/pages/index/index.hml b/AnimationDemo/entry/src/main/js/default/pages/second/second.hml similarity index 34% rename from AnimationDemo/entry/src/ohosTest/js/default/pages/index/index.hml rename to AnimationDemo/entry/src/main/js/default/pages/second/second.hml index f64b040a5ae394dbaa5e185e1ecd4f4556b92184..d75ce9375e151799d8f0a9ad4cb56138751561d3 100644 --- a/AnimationDemo/entry/src/ohosTest/js/default/pages/index/index.hml +++ b/AnimationDemo/entry/src/main/js/default/pages/second/second.hml @@ -1,5 +1,6 @@
- {{ $t('strings.hello') }} {{ title }} + {{ $t('strings.page') }} +
diff --git a/AnimationDemo/entry/src/main/js/default/pages/second/second.js b/AnimationDemo/entry/src/main/js/default/pages/second/second.js new file mode 100644 index 0000000000000000000000000000000000000000..ac4f4f83da1d046e0dd8f5aa7d625092e99cc805 --- /dev/null +++ b/AnimationDemo/entry/src/main/js/default/pages/second/second.js @@ -0,0 +1,12 @@ +import router from '@system.router' + +export default { + data: { + title: 'World' + }, + onclick: function () { + router.replace({ + uri: "pages/index/index" + }) + } +} diff --git a/AnimationDemo/entry/src/ohosTest/java/com/huawei/codelab/ExampleOhosTest.java b/AnimationDemo/entry/src/ohosTest/java/com/huawei/codelab/ExampleOhosTest.java deleted file mode 100644 index ac163632818a978d48332f85e6c6b4fb366af624..0000000000000000000000000000000000000000 --- a/AnimationDemo/entry/src/ohosTest/java/com/huawei/codelab/ExampleOhosTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.huawei.codelab; - -import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class ExampleOhosTest { - @Test - public void testBundleName() { - final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName(); - assertEquals("com.huawei.cookbook", actualBundleName); - } -} \ No newline at end of file diff --git a/AnimationDemo/entry/src/ohosTest/js/default/app.js b/AnimationDemo/entry/src/ohosTest/js/default/app.js deleted file mode 100644 index 55b67e96deb821033f71d30b6fff05efdeb0d901..0000000000000000000000000000000000000000 --- a/AnimationDemo/entry/src/ohosTest/js/default/app.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - onCreate() { - console.info('TestApplication onCreate'); - }, - onDestroy() { - console.info('TestApplication onDestroy'); - } -}; diff --git a/AnimationDemo/entry/src/ohosTest/js/default/pages/index/index.css b/AnimationDemo/entry/src/ohosTest/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/AnimationDemo/entry/src/ohosTest/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/AnimationDemo/entry/src/ohosTest/js/default/pages/index/index.js b/AnimationDemo/entry/src/ohosTest/js/default/pages/index/index.js deleted file mode 100644 index 8be2df2479a8da755ed800ad70d2b6247e21b8a2..0000000000000000000000000000000000000000 --- a/AnimationDemo/entry/src/ohosTest/js/default/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -import file from '@system.file' -import app from '@system.app' -import device from '@system.device' -import router from '@system.router' -import {Core, Constant, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - const reportExtend = new ReportExtend(file) - const instrumentLog = new InstrumentLog({ - 'id': 'report', - 'version': '1.0.3' - }) - core.addService('expect', expectExtend) - core.addService('report', reportExtend) - core.addService('report', instrumentLog) - core.init() - core.subscribeEvent('spec', instrumentLog) - core.subscribeEvent('suite', instrumentLog) - core.subscribeEvent('task', instrumentLog) - - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} \ No newline at end of file diff --git a/AnimationDemo/entry/src/ohosTest/js/test/ExampleJsunit.test.js b/AnimationDemo/entry/src/ohosTest/js/test/ExampleJsunit.test.js deleted file mode 100644 index b6d74caed96ddede98edd1bc9292f6568cd1cfd1..0000000000000000000000000000000000000000 --- a/AnimationDemo/entry/src/ohosTest/js/test/ExampleJsunit.test.js +++ /dev/null @@ -1,10 +0,0 @@ -import app from '@system.app' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -describe('appInfoTest', function () { - it('app_info_test_001', 0, function () { - var info = app.getInfo() - expect(info.versionName).assertEqual('1.0') - expect(info.versionCode).assertEqual('3') - }) -}) \ No newline at end of file diff --git a/AnimationDemo/entry/src/ohosTest/js/test/List.test.js b/AnimationDemo/entry/src/ohosTest/js/test/List.test.js deleted file mode 100644 index 305eb5bb254cd4802afaffebe68fca2f9436159f..0000000000000000000000000000000000000000 --- a/AnimationDemo/entry/src/ohosTest/js/test/List.test.js +++ /dev/null @@ -1 +0,0 @@ -require('./ExampleJsunit.test.js') \ No newline at end of file diff --git a/AnimationDemo/entry/src/ohosTest/resources/base/element/string.json b/AnimationDemo/entry/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index c9a7178aa896d985f3ae55b48178b37de4380c77..0000000000000000000000000000000000000000 --- a/AnimationDemo/entry/src/ohosTest/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "AnimationDemo" - }, - { - "name": "mainability_description", - "value": "hap sample empty page" - } - ] -} diff --git a/AudioDemo/LICENSE b/AudioDemo/LICENSE deleted file mode 100644 index b36a10d589119cb8557ff572ca3f5b0aab970604..0000000000000000000000000000000000000000 --- a/AudioDemo/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - Copyright (c) 2021 Huawei Device Co., Ltd. - - Licensed under the Apache License,Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -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 diff --git a/AudioDemo/README.md b/AudioDemo/README.md deleted file mode 100644 index f956cc95f3411aca797d9b922a93e861aab48db9..0000000000000000000000000000000000000000 --- a/AudioDemo/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# AudioDemo -简介 -• 此Demo用于使用播放器播放音乐、声音采集、录音播放和多媒体音量控制。 - -安装要求 -• 安装DevEco Studio -• 设置DevEco Studio开发环境。DevEco Studio开发环境需要连接到网络,以确保该正常使用。可以根据以下两种情况配置开发环境: - 1.如果您可以直接访问Internet,则只需下载HarmonyOS SDK - 2.如果网络无法直接访问Internet,则可以通过代理服务器进行访问 -• 生成密钥并申请证书 - -用户指南 -• 下载此项目 -• 打开HUAWEI DevEco Studio,单击File> Open选择此项目 -• 单击Build> Build App(s)/Hap(s)>Build Debug Hap(s)以编译hap软件包 -• 单击Run> Run 'entry'以运行hap包 - -注意 -• 您可以选择在模拟器或真机上运行hap软件包。 -• 如果在真机上运行它,则需要在项目的File> Project Structure> Modules> Signing Configs中配置签名和证书信息。 - -许可 -请参阅LICENSE文件以获得更多信息。 - -What is it? -This demo is used to play music using the player, capture sound, record playback, and multimedia volume control. - -Installation requirements -• Install DevEco Studio -• Set up the DevEco Studio development environment.The DevEco Studio development environment needs to depend on the network environment. It needs to be connected to the network to ensure the normal use of the tool.The development environment can be configured according to the following two situations - 1.If you can directly access the Internet, just download the HarmonyOS SDK - 2.If the network cannot access the Internet directly, it can be accessed through a proxy server -• Generate secret key and apply for certificate - -User guide -• Download this Project -• Open HUAWEI DevEco Studio, click File> Open> Then select and open this Project -• Click Build> Build App(s)/Hap(s)>Build Debug Hap(s) to compile the hap package -• Click Run> Run 'entry' to run the hap package - -Note -• You can choose to run the hap package on the simulator or the phone. -• If you run it on the phone, you need to configure the signature and certificate information in the project's File> Project Structure> Modules> Signing Configs. - -Licensing -Please see LICENSE for more info. diff --git a/AudioDemo/RELEASE-NOTES.md b/AudioDemo/RELEASE-NOTES.md deleted file mode 100644 index ea23a13e3d4407d06cba3aa7155a23e5081b50b4..0000000000000000000000000000000000000000 --- a/AudioDemo/RELEASE-NOTES.md +++ /dev/null @@ -1,2 +0,0 @@ -1.0.0 -1.Initial version \ No newline at end of file diff --git a/AudioDemo/build.gradle b/AudioDemo/build.gradle deleted file mode 100644 index 06dd00dc762e906aae9d3bbe99b958eb024f1999..0000000000000000000000000000000000000000 --- a/AudioDemo/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -apply plugin: 'com.huawei.ohos.app' - -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 5 - } -} - -buildscript { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } - dependencies { - classpath 'com.huawei.ohos:hap:2.4.2.7' - classpath 'com.huawei.ohos:decctest:1.0.0.7' - } -} - -allprojects { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } -} diff --git a/AudioDemo/entry/build.gradle b/AudioDemo/entry/build.gradle deleted file mode 100644 index 09716d2e58d750c54a41fff04b066ac4ddf8fafe..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -apply plugin: 'com.huawei.ohos.hap' -apply plugin: 'com.huawei.ohos.decctest' -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 5 - } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - testCompile'junit:junit:4.12' -} -decc { - supportType = ['html','xml'] -} diff --git a/AudioDemo/entry/src/main/config.json b/AudioDemo/entry/src/main/config.json deleted file mode 100644 index 7dbd6ba8152861f7b56a2f9298b637b15b4062df..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/config.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "app": { - "bundleName": "com.huawei.cookbook", - "vendor": "huawei", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.huawei.harmonyaudiodemo", - "name": ".MyApplication", - "deviceType": [ - "default" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": false - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home", - "action.sound.play.system", - "action.sound.play.music", - "action.sound.record", - "action.sound.volume" - ] - } - ], - "orientation": "unspecified", - "name": "com.huawei.harmonyaudiodemo.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "formsEnabled": true, - "launchType": "standard" - } - ], - "reqPermissions": [ - { - "name": "ohos.permission.MICROPHONE" - }, - { - "name": "ohos.permission.WRITE_MEDIA" - }, - { - "name": "ohos.permission.WRITE_USER_STORAGE" - }, - { - "name": "ohos.permission.READ_USER_STORAGE" - }, - { - "name": "ohos.permission.READ_MEDIA" - } - ] - } -} \ No newline at end of file diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/MainAbility.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/MainAbility.java deleted file mode 100644 index d844f291acea6981eb6e45b4f60806ceb42636ec..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/MainAbility.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo; - -import static ohos.bundle.IBundleManager.PERMISSION_GRANTED; - -import com.huawei.harmonyaudiodemo.slice.MainAbilitySlice; -import com.huawei.harmonyaudiodemo.slice.MusicPlayerAbilitySlice; -import com.huawei.harmonyaudiodemo.slice.SoundRecordSlice; -import com.huawei.harmonyaudiodemo.slice.SoundSystemSlice; -import com.huawei.harmonyaudiodemo.slice.SoundVolumeSlice; -import com.huawei.harmonyaudiodemo.util.LogUtil; - -import ohos.aafwk.ability.Ability; -import ohos.aafwk.content.Intent; -import ohos.security.SystemPermission; - -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -/** - * MainAbility - * - * @since 2021-04-04 - */ -public class MainAbility extends Ability { - private static final String TAG = MainAbility.class.getSimpleName(); - private static final int PERMISSION_REQUEST_CODE = 1; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setMainRoute(MainAbilitySlice.class.getName()); - addActionRoute("action.sound.play.music", MusicPlayerAbilitySlice.class.getName()); - addActionRoute("action.sound.play.system", SoundSystemSlice.class.getName()); - addActionRoute("action.sound.record", SoundRecordSlice.class.getName()); - addActionRoute("action.sound.volume", SoundVolumeSlice.class.getName()); - - requestPermission(); - } - - private void requestPermission() { - List permissions; - permissions = new LinkedList<>( - Arrays.asList( - SystemPermission.WRITE_MEDIA, - SystemPermission.READ_MEDIA, - SystemPermission.WRITE_USER_STORAGE, - SystemPermission.READ_USER_STORAGE, - SystemPermission.MICROPHONE)); - permissions.removeIf(permission -> - verifySelfPermission(permission) == PERMISSION_GRANTED || !canRequestPermission(permission)); - if (!permissions.isEmpty()) { - requestPermissionsFromUser(permissions.toArray(new String[0]), PERMISSION_REQUEST_CODE); - } - } - - @Override - public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions, int[] grantResults) { - if (requestCode != PERMISSION_REQUEST_CODE) { - return; - } - for (int grantResult : grantResults) { - if (grantResult != PERMISSION_GRANTED) { - LogUtil.info(TAG, grantResult + " is denied , Some functions may be affected."); - } - } - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/MyApplication.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/MyApplication.java deleted file mode 100644 index a7fcbd9bd6ecced2315f7ac86e1fc6491670d728..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/MyApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo; - -import ohos.aafwk.ability.AbilityPackage; - -/** - * MyApplication - * - * @since 2021-04-04 - */ -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/constant/Const.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/constant/Const.java deleted file mode 100644 index 819cad4d92a379a3c7392acb6e6a855f97a32f02..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/constant/Const.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.constant; - -/** - * HmSounder Const - * - * @since 2021-01-17 - */ -public class Const { - /** - * -1 - */ - public static final int NUMBER_NEGATIVE_1 = -1; - /** - * 100 - */ - public static final int NUMBER_100 = 100; - /** - * 60 - */ - public static final int NUMBER_60 = 60; - /** - * 114 - */ - public static final int NUMBER_114 = 114; - /** - * 300 - */ - public static final int NUMBER_300 = 300; - /** - * 500 - */ - public static final int NUMBER_500 = 500; - /** - * BUFFERSIZE - */ - public static final int BUFFERSIZE = 1024; - - /** - * SAMPLE RATE - */ - public static final int SAMPLE_RATE = 44100; - - /** - * BUFFER SIZE IN BYTES - */ - public static final int BUFFER_SIZE_IN_BYTES = 100; - - /** - * VOICE FILE PREFIX - */ - public static final String VOICE_FILE_PREFIX = "VID_"; - - /** - * VOICE FILE PREFIX - */ - public static final String VOICE_FILE_MUSIC = "MUSIC_"; - - /** - * VOICE FILE NAME - */ - public static final String VOICE_FILE_NAME = "test"; - - /** - * VOICE FILE TYPE - */ - public static final String VOICE_FILE_TYPE_MP3 = ".mp3"; - - /** - * VOICE FILE TYPE - */ - public static final String VOICE_FILE_TYPE_M4A = ".m4a"; - - private Const() { - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/AudioRecorder.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/AudioRecorder.java deleted file mode 100644 index cae4e517fd3566544c991a7952293f5aeb7944a5..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/AudioRecorder.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.media; - -import com.huawei.harmonyaudiodemo.constant.Const; -import com.huawei.harmonyaudiodemo.media.api.AudioRecordListener; -import com.huawei.harmonyaudiodemo.media.constant.MediaConst; -import com.huawei.harmonyaudiodemo.util.LogUtil; - -import ohos.agp.utils.TextTool; -import ohos.eventhandler.EventHandler; -import ohos.eventhandler.EventRunner; -import ohos.media.audio.AudioCapturer; -import ohos.media.audio.AudioCapturerInfo; -import ohos.media.audio.AudioStreamInfo; - -import java.io.BufferedOutputStream; -import java.io.FileOutputStream; -import java.io.IOException; - -/** - * Hm AudioRecorder - * - * @since 2021-04-04 - */ -public class AudioRecorder { - private static final String TAG = AudioRecorder.class.getSimpleName(); - private AudioCapturer audioCapturer; - private AudioStreamInfo audioStreamInfo; - private EventHandler audioRecorderHandler; - private Builder builder; - private int bufferSize; - private boolean isRecording; - private boolean isSaveFile; - - private AudioRecordListener audioRecordListener; - - private AudioRecorder(Builder builder) { - this.builder = builder; - isSaveFile = !TextTool.isNullOrEmpty(builder.savefilePath); - bufferSize = - AudioCapturer.getMinBufferSize( - builder.inputSampleRate, - AudioStreamInfo.getChannelCount(builder.channelMask), - builder.encodingFormat.getValue()); - audioRecorderHandler = new EventHandler(EventRunner.create(AudioRecorder.class.getSimpleName())); - initRecord(); - } - - private void initRecord() { - if (audioStreamInfo == null) { - audioStreamInfo = new AudioStreamInfo.Builder() - .encodingFormat(builder.encodingFormat) - .channelMask(builder.channelMask) - .sampleRate(builder.inputSampleRate) - .build(); - AudioCapturerInfo audioCapturerInfo = new AudioCapturerInfo.Builder() - .audioStreamInfo(audioStreamInfo) - .audioInputSource(builder.inputSource) - .build(); - audioCapturer = new AudioCapturer(audioCapturerInfo); - } - } - - private void startRecord() { - isRecording = true; - BufferedOutputStream dos = null; - try { - if (isSaveFile) { - dos = new BufferedOutputStream(new FileOutputStream(builder.savefilePath)); - } - byte[] buffers = new byte[bufferSize]; - int length = audioCapturer.read(buffers, 0, bufferSize); - while (length != Const.NUMBER_NEGATIVE_1) { - if (audioRecordListener != null) { - audioRecordListener.onGetRecordBuffer(buffers, length); - } - if (dos != null) { - dos.write(buffers); - } - length = audioCapturer.read(buffers, 0, bufferSize); - } - } catch (IOException e) { - LogUtil.error(TAG, "start record failed!"); - } finally { - if (dos != null) { - try { - dos.close(); - } catch (IOException e) { - LogUtil.error(TAG, "start record failed!"); - } - } - } - } - - /** - * record - */ - public void record() { - if (!isRecording) { - initRecord(); - audioRecorderHandler.postTask(() -> { - if (audioCapturer.start()) { - startRecord(); - } - }); - } - } - - /** - * stopRecord - */ - public void stopRecord() { - if (isRecording && audioCapturer.stop()) { - isRecording = false; - } - } - - /** - * setAudioRecordListener - * - * @param listener listener - */ - public void setAudioRecordListener(AudioRecordListener listener) { - audioRecordListener = listener; - } - - /** - * release recorder - */ - public void release() { - stopRecord(); - if (audioCapturer != null) { - audioCapturer.release(); - } - audioStreamInfo = null; - } - - /** - * is recording in current time - * - * @return isRecording - */ - public boolean isRecording() { - return isRecording; - } - - /** - * Builder - * - * @since 2020-12-04 - */ - public static class Builder { - private String savefilePath; - private AudioStreamInfo.EncodingFormat encodingFormat; - private AudioStreamInfo.ChannelMask channelMask; - private AudioCapturerInfo.AudioInputSource inputSource; - private int inputSampleRate; - - /** - * constructor of Builder - */ - public Builder() { - encodingFormat = AudioStreamInfo.EncodingFormat.ENCODING_PCM_16BIT; // 16-bit PCM - channelMask = AudioStreamInfo.ChannelMask.CHANNEL_IN_STEREO; // 双声道 - inputSource = AudioCapturerInfo.AudioInputSource.AUDIO_INPUT_SOURCE_VOICE_COMMUNICATION; // 消除回声,降噪 - inputSampleRate = MediaConst.SAMPLE_RATE; - } - - /** - * setSaveFilePath of Builder - * - * @param filePath filePath - * @return builder - */ - public Builder setSaveFilePath(String filePath) { - this.savefilePath = filePath; - return this; - } - - /** - * create of Builder - * - * @return AudioRecorder - */ - public AudioRecorder create() { - return new AudioRecorder(this); - } - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/AudioRender.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/AudioRender.java deleted file mode 100644 index d45b76e6c97c4ad2656e7bb1432971cbdf70713e..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/AudioRender.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.media; - -import com.huawei.harmonyaudiodemo.media.api.AudioPlayListener; -import com.huawei.harmonyaudiodemo.media.constant.MediaConst; -import com.huawei.harmonyaudiodemo.media.constant.MediaStatu; - -import ohos.eventhandler.EventHandler; -import ohos.eventhandler.EventRunner; -import ohos.media.audio.AudioCapturer; -import ohos.media.audio.AudioRenderer; -import ohos.media.audio.AudioRendererInfo; -import ohos.media.audio.AudioStreamInfo; - -/** - * AudioRender - * - * @since 2021-04-09 - */ -public class AudioRender { - private static final String TAG = AudioRender.class.getSimpleName(); - private AudioRendererInfo audioRenderInfo; - private AudioRenderer audioRender; - private EventHandler audioRenderHandler; - private MediaStatu audioRenderStatu = MediaStatu.IDEL; - private Builder builder; - private int bufferSize; - private AudioPlayListener audioPlayListener; - - private AudioRender(Builder builder) { - this.builder = builder; - bufferSize = - AudioCapturer.getMinBufferSize( - builder.inputSampleRate, - AudioStreamInfo.getChannelCount(builder.channelMask), - builder.encodingFormat.getValue()); - audioRenderHandler = new EventHandler(EventRunner.create(AudioRender.class.getSimpleName())); - initRender(); - } - - private void initRender() { - AudioStreamInfo asi = new AudioStreamInfo.Builder() - .encodingFormat(builder.encodingFormat) - .channelMask(builder.channelMask) - .sampleRate(builder.inputSampleRate) - .audioStreamFlag(builder.streamFlag) - .streamUsage(builder.streamUsage) - .build(); - audioRenderInfo = new AudioRendererInfo.Builder() - .audioStreamInfo(asi) - .audioStreamOutputFlag(builder.streamOutputFlag) - .bufferSizeInBytes(bufferSize) - .isOffload(builder.isOneOffLoad) // false表示分段传输buffer并播放,true表示整个音频流一次性传输到HAL层播放 - .build(); - audioRender = new AudioRenderer(audioRenderInfo, AudioRenderer.PlayMode.MODE_STREAM); - audioRender.setFrameIntervalObserver(() -> { - if (audioRender.getAudioTime().getFramePosition() != 0) { - if (audioPlayListener != null) { - audioPlayListener.onComplete(); - } - release(); - } - }, MediaConst.READ_RENDER_INTERVAL, audioRenderHandler); - } - - /** - * start - */ - public void start() { - if (audioRenderStatu == MediaStatu.STOP || audioRenderStatu == MediaStatu.IDEL) { - if (audioRender != null) { - if (audioRender.start()) { - audioRenderStatu = MediaStatu.START; - } - } - } - } - - /** - * pause - */ - public void pause() { - if (audioRender != null) { - if (audioRender.pause()) { - audioRenderStatu = MediaStatu.PAUSE; - } - } - } - - /** - * setSpeed - * - * @param speed speed - */ - public void setSpeed(float speed) { - if (audioRender != null) { - audioRender.setSpeed(speed); - } - } - - /** - * setVolume - * - * @param volume volume - */ - public void setVolume(float volume) { - if (audioRender != null) { - audioRender.setVolume(volume); - } - } - - /** - * stop - */ - public void stop() { - if (audioRender != null) { - if (audioRender.stop()) { - audioRenderStatu = MediaStatu.STOP; - if (audioPlayListener != null) { - audioPlayListener.onComplete(); - } - } - } - } - - /** - * playRecord - * - * @param bytes bytes - * @param length length - */ - public void play(byte[] bytes, int length) { - if (audioRenderInfo == null) { - initRender(); - } - start(); - audioRenderHandler.postTask(() -> { - byte[] datas = new byte[length]; - System.arraycopy(bytes, 0, datas, 0, datas.length); - audioRender.write(datas, 0, datas.length); - }); - } - - /** - * release recorder - */ - public void release() { - if (audioRender != null) { - if (audioRender.release()) { - audioRenderStatu = MediaStatu.IDEL; - audioRenderInfo = null; - } - } - } - - /** - * release recorder - * - * @param listener listener - */ - public void setPlayListener(AudioPlayListener listener) { - audioPlayListener = listener; - } - - /** - * Builder - * - * @since 2020-12-04 - */ - public static class Builder { - private boolean isOneOffLoad; - private AudioStreamInfo.EncodingFormat encodingFormat; - private AudioStreamInfo.ChannelMask channelMask; - private int inputSampleRate; - private AudioStreamInfo.AudioStreamFlag streamFlag; - private AudioStreamInfo.StreamUsage streamUsage; - private AudioRendererInfo.AudioStreamOutputFlag streamOutputFlag; - - /** - * constructor of Builder - */ - public Builder() { - isOneOffLoad = true; - encodingFormat = AudioStreamInfo.EncodingFormat.ENCODING_PCM_16BIT; // 16-bit PCM - channelMask = AudioStreamInfo.ChannelMask.CHANNEL_OUT_STEREO; // 双声道 - inputSampleRate = MediaConst.SAMPLE_RATE; - streamFlag = AudioStreamInfo.AudioStreamFlag.AUDIO_STREAM_FLAG_MAY_DUCK; // 混音 - streamUsage = AudioStreamInfo.StreamUsage.STREAM_USAGE_MEDIA; // 媒体类音频 - streamOutputFlag = AudioRendererInfo.AudioStreamOutputFlag.AUDIO_STREAM_OUTPUT_FLAG_DIRECT_PCM; - } - - /** - * setOneOffLoad of Builder - * - * @param isOneOffLoadDatas isOneOffLoad - * @return builder - */ - public Builder setOneOffLoad(boolean isOneOffLoadDatas) { - this.isOneOffLoad = isOneOffLoadDatas; - return this; - } - - /** - * create of Builder - * - * @return AudioRender - */ - public AudioRender create() { - return new AudioRender(this); - } - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/api/AudioPlayListener.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/api/AudioPlayListener.java deleted file mode 100644 index 12981f05636407cd326bfaee04f11324e0aa5509..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/api/AudioPlayListener.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.media.api; - -/** - * AudioPlayListener - * - * @since 2021-04-09 - */ -public interface AudioPlayListener { - /** - * onComplete - */ - void onComplete(); -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/api/AudioRecordListener.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/api/AudioRecordListener.java deleted file mode 100644 index bb9111a6c83031cf271878846c60bf60281a2870..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/api/AudioRecordListener.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.media.api; - -/** - * AudioRecordListener - * - * @since 2021-04-09 - */ -public interface AudioRecordListener { - /** - * onGetRecordBuffer - * - * @param length length - * @param buffer buffer - */ - void onGetRecordBuffer(byte[] buffer, int length); -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/constant/MediaConst.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/constant/MediaConst.java deleted file mode 100644 index a586540651ca5624acd72bc09783895f69c8d162..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/constant/MediaConst.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.media.constant; - -/** - * Camera ConstUtil - * - * @since 2021-01-17 - */ -public class MediaConst { - /** - * read render interval - */ - public static final int READ_RENDER_INTERVAL = 1024; - /** - * VOICE FILE PREFIX - */ - public static final String VOICE_FILE_MUSIC = "MUSIC_"; - - /** - * VOICE FILE TYPE - */ - public static final String VOICE_FILE_TYPE_MP3 = ".mp3"; - - /** - * recorder fps - */ - public static final int RECORDER_FPS = 30; - - /** - * recorder bit rate - */ - public static final int RECORDER_BIT_RATE = 10000000; - - /** - * recorder frame rate - */ - public static final int RECORDER_FRAME_RATE = 25; - - /** - * BUFFERSIZE - */ - public static final int BUFFERSIZE = 1024; - - /** - * SAMPLE RATE - */ - public static final int SAMPLE_RATE = 44100; - - private MediaConst() { - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/constant/MediaStatu.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/constant/MediaStatu.java deleted file mode 100644 index c4e856c98fb803de11f7e1e65df1d6958f943417..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/media/constant/MediaStatu.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.media.constant; - -/** - * PlayerStatu enum - * - * @since 2021-04-04 - */ -public enum MediaStatu { - /** - * idel - */ - IDEL, - /** - * preparing - */ - PREPARED, - /** - * start - */ - START, - /** - * pause - */ - PAUSE, - /** - * stop - */ - STOP -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/HmPlayer.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/HmPlayer.java deleted file mode 100644 index 02c7f88e03acf7c9e1fc2474542207884d270f04..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/HmPlayer.java +++ /dev/null @@ -1,505 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.player; - -import com.huawei.harmonyaudiodemo.constant.Const; -import com.huawei.harmonyaudiodemo.player.api.ImplHmPlayer; -import com.huawei.harmonyaudiodemo.player.api.ImplLifecycle; -import com.huawei.harmonyaudiodemo.player.api.ScreenChangeListener; -import com.huawei.harmonyaudiodemo.player.api.StatuChangeListener; -import com.huawei.harmonyaudiodemo.player.constant.PlayerStatu; -import com.huawei.harmonyaudiodemo.player.factory.SourceFactory; -import com.huawei.harmonyaudiodemo.player.manager.HmPlayerLifecycle; -import com.huawei.harmonyaudiodemo.util.LogUtil; - -import ohos.agp.graphics.Surface; -import ohos.app.Context; -import ohos.app.dispatcher.task.TaskPriority; -import ohos.media.common.Source; -import ohos.media.player.Player; - -import java.util.ArrayList; -import java.util.List; - -/** - * Hm player - * - * @since 2021-04-04 - */ -public class HmPlayer implements ImplHmPlayer { - private static final String TAG = HmPlayer.class.getSimpleName(); - private static final int MICRO_MILLI_RATE = 1000; - private Player mPlayer; - private Surface surface; - private HmPlayerLifecycle mLifecycle; - private Builder mBuilder; - private PlayerStatu mStatu = PlayerStatu.IDEL; - private float currentVolume = 1; - private double videoScale = Const.NUMBER_NEGATIVE_1; - private boolean isGestureOpen = true; - - private List statuChangeCallbacks = new ArrayList<>(0); - private List screenChangeCallbacks = new ArrayList<>(0); - - /** - * constructor of HmPlayer - * - * @param builder builder - */ - private HmPlayer(Builder builder) { - mBuilder = builder; - mLifecycle = new HmPlayerLifecycle(this); - } - - private void initBasePlayer() { - mPlayer = new Player(mBuilder.mContext); - Source source = new SourceFactory(mBuilder.mContext, mBuilder.filePath).getSource(); - mPlayer.setSource(source); - mPlayer.setPlayerCallback(new HmPlayerCallback()); - } - - /** - * HmPlayer Callback - * - * @since 2020-12-04 - */ - private class HmPlayerCallback implements Player.IPlayerCallback { - @Override - public void onPrepared() { - LogUtil.info(TAG, "onPrepared is called "); - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.PREPARED; - callback.statuCallback(PlayerStatu.PREPARED); - } - } - - @Override - public void onMessage(int info, int i1) { - LogUtil.info(TAG, "onMessage info is " + info + ",i1 is" + i1); - if (i1 == 0) { - switch (info) { - case Player.PLAYER_INFO_VIDEO_RENDERING_START: - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.PLAY; - callback.statuCallback(PlayerStatu.PLAY); - } - if (mBuilder.isPause) { - pause(); - } - break; - case Player.PLAYER_INFO_BUFFERING_START: - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.BUFFERING; - callback.statuCallback(PlayerStatu.BUFFERING); - } - break; - case Player.PLAYER_INFO_BUFFERING_END: - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.PLAY; - callback.statuCallback(PlayerStatu.PLAY); - } - break; - default: - break; - } - } - } - - @Override - public void onError(int type, int extra) { - LogUtil.info(TAG, "onError is called ,i is " + type + ",i1 is " + extra); - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.ERROR; - callback.statuCallback(PlayerStatu.ERROR); - } - release(); - } - - @Override - public void onResolutionChanged(int videoX, int videoY) { - LogUtil.info(TAG, "onResolutionChanged videoX is " + videoX + ",videoY is " + videoY); - if (!mBuilder.isStretch && videoX != 0 && videoY != 0) { - videoScale = (double) videoX / videoY; - for (ScreenChangeListener screenChangeCallback : screenChangeCallbacks) { - screenChangeCallback.screenCallback(0, 0); - } - } - } - - @Override - public void onPlayBackComplete() { - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.COMPLETE; - callback.statuCallback(PlayerStatu.COMPLETE); - } - } - - @Override - public void onRewindToComplete() { - resume(); - } - - @Override - public void onBufferingChange(int value) { - } - - @Override - public void onNewTimedMetaData(Player.MediaTimedMetaData mediaTimedMetaData) { - } - - @Override - public void onMediaTimeIncontinuity(Player.MediaTimeInfo mediaTimeInfo) { - LogUtil.info(TAG, "onMediaTimeIncontinuity is called"); - for (Player.StreamInfo streanInfo : mPlayer.getStreamInfo()) { - int streamType = streanInfo.getStreamType(); - if (streamType == Player.StreamInfo.MEDIA_STREAM_TYPE_AUDIO && mStatu == PlayerStatu.PREPARED) { - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.PLAY; - callback.statuCallback(PlayerStatu.PLAY); - } - if (mBuilder.isPause) { - pause(); - } - } - } - } - } - - /** - * start time consuming operation - */ - private void start() { - if (mPlayer != null) { - mBuilder.mContext.getGlobalTaskDispatcher(TaskPriority.DEFAULT).asyncDispatch(() -> { - if (surface != null) { - mPlayer.setVideoSurface(surface); - } else { - LogUtil.error(TAG, "The surface has not been initialized."); - } - mPlayer.prepare(); - if (mBuilder.startMillisecond > 0) { - int microsecond = mBuilder.startMillisecond * MICRO_MILLI_RATE; - mPlayer.rewindTo(microsecond); - } - mPlayer.play(); - }); - } - } - - @Override - public ImplLifecycle getLifecycle() { - return mLifecycle; - } - - @Override - public void addSurface(Surface videoSurface) { - this.surface = videoSurface; - } - - @Override - public void addPlayerStatuCallback(StatuChangeListener callback) { - if (callback != null) { - statuChangeCallbacks.add(callback); - } - } - - @Override - public void removePlayerStatuCallback(StatuChangeListener callback) { - statuChangeCallbacks.remove(callback); - } - - @Override - public void addPlayerViewCallback(ScreenChangeListener callback) { - if (callback != null) { - screenChangeCallbacks.add(callback); - } - } - - @Override - public void removePlayerViewCallback(ScreenChangeListener callback) { - screenChangeCallbacks.remove(callback); - } - - @Override - public Builder getBuilder() { - return mBuilder; - } - - @Override - public PlayerStatu getPlayerStatu() { - return mStatu; - } - - @Override - public void resizeScreen(int width, int height) { - for (ScreenChangeListener screenChangeCallback : screenChangeCallbacks) { - screenChangeCallback.screenCallback(width, height); - } - } - - @Override - public void gestureSwitch(boolean isOpen) { - isGestureOpen = isOpen; - } - - @Override - public boolean isGestureOpen() { - return isGestureOpen; - } - - @Override - public void play() { - if (mPlayer != null) { - mPlayer.reset(); - } - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.PREPARING; - callback.statuCallback(PlayerStatu.PREPARING); - } - initBasePlayer(); - start(); - } - - @Override - public void replay() { - if (isPlaying()) { - rewindTo(0); - } else { - reload(mBuilder.filePath, 0); - } - } - - @Override - public void reload(String filepath, int startMillisecond) { - mBuilder.filePath = filepath; - mBuilder.startMillisecond = startMillisecond; - play(); - } - - @Override - public void stop() { - if (mPlayer == null) { - return; - } - mPlayer.stop(); - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.STOP; - callback.statuCallback(PlayerStatu.STOP); - } - } - - @Override - public void release() { - if (mPlayer == null) { - return; - } - if (mStatu != PlayerStatu.IDEL) { - videoScale = Const.NUMBER_NEGATIVE_1; - mPlayer.release(); - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.IDEL; - callback.statuCallback(PlayerStatu.IDEL); - } - } - } - - @Override - public void resume() { - if (mPlayer == null) { - return; - } - if (mStatu != PlayerStatu.IDEL) { - if (!isPlaying()) { - mPlayer.play(); - } - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.PLAY; - callback.statuCallback(PlayerStatu.PLAY); - } - } - } - - @Override - public void pause() { - if (mPlayer == null) { - return; - } - if (isPlaying()) { - mPlayer.pause(); - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.PAUSE; - callback.statuCallback(PlayerStatu.PAUSE); - } - } - } - - @Override - public int getCurrentPosition() { - if (mPlayer == null) { - return 0; - } - return mPlayer.getCurrentTime(); - } - - @Override - public int getDuration() { - if (mPlayer == null) { - return 0; - } - return mPlayer.getDuration(); - } - - @Override - public float getVolume() { - return currentVolume; - } - - @Override - public void setVolume(float volume) { - if (mPlayer != null && mPlayer.setVolume(volume)) { - currentVolume = volume; - } - } - - @Override - public void setPlaySpeed(float speed) { - if (mPlayer == null) { - return; - } - if (mStatu != PlayerStatu.IDEL) { - mPlayer.setPlaybackSpeed(speed); - } - } - - @Override - public double getVideoScale() { - return videoScale; - } - - @Override - public boolean isPlaying() { - return mPlayer.isNowPlaying(); - } - - @Override - public void rewindTo(int startMicrosecond) { - if (mPlayer == null) { - return; - } - if (mStatu != PlayerStatu.IDEL) { - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.BUFFERING; - callback.statuCallback(PlayerStatu.BUFFERING); - } - mPlayer.rewindTo(startMicrosecond * MICRO_MILLI_RATE); - } - } - - /** - * Builder - * - * @since 2020-12-04 - */ - public static class Builder { - private Context mContext; - private String filePath; - private int startMillisecond; - private boolean isStretch; - private boolean isPause; - - /** - * constructor of Builder - * - * @param context context - */ - public Builder(Context context) { - mContext = context; - filePath = ""; - startMillisecond = 0; - } - - /** - * setFilePath of Builder - * - * @param filePath filePath - * @return builder - */ - public Builder setFilePath(String filePath) { - this.filePath = filePath; - return this; - } - - /** - * getFilePath of Builder - * - * @return filePath - */ - public String getFilePath() { - return filePath; - } - - /** - * setStartMillisecond of Builder - * - * @param startMillisecond startMillisecond - * @return builder - */ - public Builder setStartMillisecond(int startMillisecond) { - this.startMillisecond = startMillisecond; - return this; - } - - /** - * getStartMillisecond of Builder - * - * @return startMillisecond - */ - public int getStartMillisecond() { - return startMillisecond; - } - - /** - * setStretch of Builder - * - * @param isS isStretch - * @return Builder - */ - public Builder setStretch(boolean isS) { - this.isStretch = isS; - return this; - } - - /** - * setPause of Builder - * - * @param isP isPause - * @return Builder - */ - public Builder setPause(boolean isP) { - this.isPause = isP; - return this; - } - - /** - * create of Builder - * - * @return IPlayer - */ - public ImplHmPlayer create() { - return new HmPlayer(this); - } - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/api/HmPlayModuler.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/api/HmPlayModuler.java deleted file mode 100644 index b019323005100927bf5f5d6ef892c390579d14d3..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/api/HmPlayModuler.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.player.api; - -/** - * IPlayModuler - * - * @since 2021-04-09 - * - */ -public interface HmPlayModuler { - /** - * bind - * - * @param player player - */ - void bind(ImplHmPlayer player); - - /** - * unbind - * - */ - void unbind(); -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/api/ImplHmPlayer.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/api/ImplHmPlayer.java deleted file mode 100644 index 832f4bc427d0d31fcaee8b5ef7e0e458a83985d2..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/api/ImplHmPlayer.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.player.api; - -import com.huawei.harmonyaudiodemo.player.HmPlayer; -import com.huawei.harmonyaudiodemo.player.constant.PlayerStatu; - -import ohos.agp.graphics.Surface; - -/** - * IPlayer interface - * - * @since 2021-04-04 - */ -public interface ImplHmPlayer { - /** - * addSurface - * - * @param surface surface - */ - void addSurface(Surface surface); - - /** - * addPlayerStatuCallback - * - * @param callback callback - */ - void addPlayerStatuCallback(StatuChangeListener callback); - - /** - * removePlayerStatuCallback - * - * @param callback callback - */ - void removePlayerStatuCallback(StatuChangeListener callback); - - /** - * addPlayerViewCallback - * - * @param callback callback - */ - void addPlayerViewCallback(ScreenChangeListener callback); - - /** - * removePlayerViewCallback - * - * @param callback callback - */ - void removePlayerViewCallback(ScreenChangeListener callback); - - /** - * play - */ - void play(); - - /** - * replay - */ - void replay(); - - /** - * reload - * - * @param filepath filepath - * @param startMillisecond startMillisecond - */ - void reload(String filepath, int startMillisecond); - - /** - * resume - */ - void resume(); - - /** - * pause - */ - void pause(); - - /** - * getCurrentPosition - * - * @return current position - */ - int getCurrentPosition(); - - /** - * getDuration - * - * @return duration - */ - int getDuration(); - - /** - * getVolume - * - * @return float - */ - float getVolume(); - - /** - * set play volume - * - * @param volume 0~1 - */ - void setVolume(float volume); - - /** - * set play speed - * - * @param speed 0~12 - */ - void setPlaySpeed(float speed); - - /** - * getVideoScale - * - * @return double - */ - double getVideoScale(); - - /** - * rewindTo - * - * @param startMicrosecond startMicrosecond(ms) - */ - void rewindTo(int startMicrosecond); - - /** - * isPlaying - * - * @return isPlaying - */ - boolean isPlaying(); - - /** - * stop - */ - void stop(); - - /** - * release - */ - void release(); - - /** - * getLifecycle - * - * @return ImplLifecycle - */ - ImplLifecycle getLifecycle(); - - /** - * getBuilder - * - * @return Builder - */ - HmPlayer.Builder getBuilder(); - - /** - * getPlayerStatu - * - * @return PlayerStatu - */ - PlayerStatu getPlayerStatu(); - - /** - * resizeScreen - * - * @param width width - * @param height height - */ - void resizeScreen(int width, int height); - - /** - * openGesture - * - * @param isOpen isOpen - */ - void gestureSwitch(boolean isOpen); - - /** - * openGesture - * - * @return isGestureOpen - */ - boolean isGestureOpen(); -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/api/ImplLifecycle.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/api/ImplLifecycle.java deleted file mode 100644 index 709f0bd45da46d51f5c59fd31480926753353630..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/api/ImplLifecycle.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.player.api; - -/** - * ImplLifecycle - * - * @since 2021-04-09 - * - */ -public interface ImplLifecycle { - /** - * onStart - * - */ - void onStart(); - - /** - * onForeground - * - */ - void onForeground(); - - /** - * onBackground - * - */ - void onBackground(); - - /** - * onStop - * - */ - void onStop(); -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/api/ScreenChangeListener.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/api/ScreenChangeListener.java deleted file mode 100644 index 5da18584ecabf6d633f139002a35e470f39ed521..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/api/ScreenChangeListener.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.player.api; - -/** - * ScreenChangeListener interface - * - * @since 2021-04-04 - * - */ -public interface ScreenChangeListener { - /** - * screenCallback - * - * @param width width - * @param height height - */ - void screenCallback(int width, int height); -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/api/StatuChangeListener.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/api/StatuChangeListener.java deleted file mode 100644 index 9ee167fc4ef0c3818a9a7d6c593c6b3be4758686..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/api/StatuChangeListener.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.player.api; - -import com.huawei.harmonyaudiodemo.player.constant.PlayerStatu; - -/** - * StatuChangeListener interface - * - * @since 2021-04-04 - * - */ -public interface StatuChangeListener { - /** - * statuCallback - * - * @param statu statu - */ - void statuCallback(PlayerStatu statu); -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/constant/Constants.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/constant/Constants.java deleted file mode 100644 index 6545705d03aa217639657b49084cba98fd910949..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/constant/Constants.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.player.constant; - -/** - * Constants - * - * @since 2021-04-04 - */ -public class Constants { - /** - * running - */ - public static final int PLAYER_PROGRESS_RUNNING = 0; - /** - * hide - */ - public static final int PLAYER_CONTROLLER_HIDE = 1; - /** - * hide - */ - public static final int PLAYER_CONTROLLER_SHOW = 2; - /** - * 100 - */ - public static final int ONE_HUNDRED_PERCENT = 100; - /** - * rewind step - */ - public static final int REWIND_STEP = 5000; - /** - * volume step - */ - public static final int VOLUME_STEP = 5; - /** - * INTENT STARTTIME PARAM - */ - public static final String INTENT_STARTTIME_PARAM = "intetn_starttime_param"; - /** - * INTENT PLAYURL PARAM - */ - public static final String INTENT_PLAYURL_PARAM = "intetn_playurl_param"; - /** - * INTENT PLAYSTATU PARAM - */ - public static final String INTENT_PLAYSTATU_PARAM = "intetn_playstatu_param"; - /** - * INTENT LANDSCREEN REQUEST CODE - */ - public static final int INTENT_LANDSCREEN_REQUEST_CODE = 1001; - - private Constants() { - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/constant/PlayerStatu.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/constant/PlayerStatu.java deleted file mode 100644 index 55dd7eae74793b8527c046362b697d915bd63a1f..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/constant/PlayerStatu.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.player.constant; - -/** - * PlayerStatu enum - * - * @since 2021-04-04 - * - */ -public enum PlayerStatu { - /** - * idel - * - */ - IDEL, - /** - * preparing - * - */ - PREPARING, - /** - * prepared - * - */ - PREPARED, - /** - * play - * - */ - PLAY, - /** - * pause - * - */ - PAUSE, - /** - * stop - * - */ - STOP, - /** - * complete - * - */ - COMPLETE, - /** - * error - * - */ - ERROR, - /** - * buffering - * - */ - BUFFERING -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/factory/SourceFactory.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/factory/SourceFactory.java deleted file mode 100644 index 22597d7b0b96de58133d4ebe60bacfc6b7d30a43..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/factory/SourceFactory.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.player.factory; - -import com.huawei.harmonyaudiodemo.util.LogUtil; - -import ohos.app.Context; -import ohos.global.resource.RawFileDescriptor; -import ohos.media.common.Source; - -import java.io.File; -import java.io.FileDescriptor; -import java.io.FileInputStream; -import java.io.IOException; - -/** - * SourceFactory - * - * @since 2021-04-04 - * - */ -public class SourceFactory { - private static final String TAG = "SourceFactory"; - private static final String NET_HTTP_MATCH = "http"; - private static final String NET_RTMP_MATCH = "rtmp"; - private static final String NET_RTSP_MATCH = "rtsp"; - private static final String STORAGE_MATCH = "/storage/"; - - private Source mPlayerSource; - - /** - * constructor of SourceFactory - * - * @param context context - * @param path path - */ - public SourceFactory(Context context, String path) { - try { - initSourceType(context, path); - } catch (IOException e) { - LogUtil.error(TAG, "Audio resource is unavailable: "); - } - } - - private void initSourceType(Context context, String path) throws IOException { - if (context == null || path == null) { - return; - } - if (path.substring(0, NET_HTTP_MATCH.length()).equalsIgnoreCase(NET_HTTP_MATCH) - || path.substring(0, NET_RTMP_MATCH.length()).equalsIgnoreCase(NET_RTMP_MATCH) - || path.substring(0, NET_RTSP_MATCH.length()).equalsIgnoreCase(NET_RTSP_MATCH)) { - mPlayerSource = new Source(path); - } else if (path.startsWith(STORAGE_MATCH)) { - File file = new File(path); - if (file.exists()) { - FileInputStream fileInputStream = new FileInputStream(file); - FileDescriptor fileDescriptor = fileInputStream.getFD(); - mPlayerSource = new Source(fileDescriptor); - } - } else { - RawFileDescriptor fd = context.getResourceManager().getRawFileEntry(path).openRawFileDescriptor(); - mPlayerSource = new Source(fd.getFileDescriptor(), fd.getStartPosition(), fd.getFileSize()); - } - } - - /** - * getSource - * - * @return Source Source - */ - public Source getSource() { - return mPlayerSource; - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/manager/HmPlayerLifecycle.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/manager/HmPlayerLifecycle.java deleted file mode 100644 index 273021ca3cf00ab53bd58d9df05d8b8733c52067..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/manager/HmPlayerLifecycle.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.player.manager; - -import com.huawei.harmonyaudiodemo.player.api.ImplHmPlayer; -import com.huawei.harmonyaudiodemo.player.api.ImplLifecycle; -import com.huawei.harmonyaudiodemo.player.constant.PlayerStatu; - -/** - * HmPlayerLifecycle - * - * @since 2021-04-09 - * - */ -public class HmPlayerLifecycle implements ImplLifecycle { - private static final String TAG = HmPlayerLifecycle.class.getSimpleName(); - private ImplHmPlayer mPlayer; - - /** - * HmPlayerLifecycle - * - * @param player player - */ - public HmPlayerLifecycle(ImplHmPlayer player) { - mPlayer = player; - } - - @Override - public void onStart() { - } - - @Override - public void onForeground() { - String url = mPlayer.getBuilder().getFilePath(); - int startMillisecond = mPlayer.getBuilder().getStartMillisecond(); - mPlayer.reload(url, startMillisecond); - } - - @Override - public void onBackground() { - mPlayer.getBuilder().setPause(mPlayer.getPlayerStatu() == PlayerStatu.PAUSE); - mPlayer.getBuilder().setStartMillisecond(mPlayer.getCurrentPosition()); - mPlayer.release(); - } - - @Override - public void onStop() { - mPlayer.release(); - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/util/DateUtils.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/util/DateUtils.java deleted file mode 100644 index f616b3565af0c8fd530a68ed0c552a308d3a62ae..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/util/DateUtils.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.player.util; - -import java.util.Locale; - -/** - * Date util - * - * @since 2021-04-04 - */ -public class DateUtils { - private static final int ONE_SECONDS_MS = 1000; - private static final int ONE_MINS_MINUTES = 60; - private static final int NUMBER = 16; - private static final String TIME_FORMAT = "%02d"; - private static final String SEMICOLON = ":"; - - private DateUtils() { - } - - /** - * conversion of msToString - * - * @param ms ms - * @return string - */ - public static String msToString(int ms) { - StringBuilder sb = new StringBuilder(NUMBER); - int seconds = ms / ONE_SECONDS_MS; - int minutes = seconds / ONE_MINS_MINUTES; - if (minutes > ONE_MINS_MINUTES) { - sb.append(String.format(Locale.ENGLISH, TIME_FORMAT, minutes / ONE_MINS_MINUTES)); - sb.append(SEMICOLON); - sb.append(String.format(Locale.ENGLISH, TIME_FORMAT, minutes % ONE_MINS_MINUTES)); - sb.append(SEMICOLON); - } else { - sb.append("00:"); - sb.append(String.format(Locale.ENGLISH, TIME_FORMAT, minutes)); - sb.append(SEMICOLON); - } - - if (seconds > minutes * ONE_MINS_MINUTES) { - sb.append(String.format(Locale.ENGLISH, TIME_FORMAT, seconds - minutes * ONE_MINS_MINUTES)); - } else { - sb.append("00"); - } - return sb.toString(); - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/view/PlayerLoading.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/view/PlayerLoading.java deleted file mode 100644 index 71033b6c890195b584e1b92efb868510f5922ce7..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/view/PlayerLoading.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.player.view; - -import com.huawei.harmonyaudiodemo.ResourceTable; -import com.huawei.harmonyaudiodemo.player.api.HmPlayModuler; -import com.huawei.harmonyaudiodemo.player.api.ImplHmPlayer; - -import ohos.agp.animation.AnimatorProperty; -import ohos.agp.components.AttrSet; -import ohos.agp.components.Component; -import ohos.agp.components.Component.TouchEventListener; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.Image; -import ohos.agp.components.LayoutScatter; -import ohos.app.Context; -import ohos.multimodalinput.event.TouchEvent; - -/** - * PlayerLoading - * - * @since 2021-04-04 - */ -public class PlayerLoading extends ComponentContainer implements HmPlayModuler, TouchEventListener { - private static final int HALF_NUMBER = 2; - private static final int ANIM_ROTATE = 360; - private static final int ANIM_DURATION = 2000; - private static final int ANIM_LOOPED_COUNT = -1; - private ImplHmPlayer mPlayer; - private Image mLoading; - private AnimatorProperty mLoadingAnim; - - /** - * constructor of PlayerLoading - * - * @param context context - */ - public PlayerLoading(Context context) { - this(context, null); - } - - /** - * constructor of PlayerLoading - * - * @param context context - * @param attrSet attSet - */ - public PlayerLoading(Context context, AttrSet attrSet) { - this(context, attrSet, null); - } - - /** - * constructor of PlayerLoading - * - * @param context context - * @param attrSet attSet - * @param styleName styleName - */ - public PlayerLoading(Context context, AttrSet attrSet, String styleName) { - super(context, attrSet, styleName); - initView(context); - } - - private void initView(Context context) { - Component loadingContainer = - LayoutScatter.getInstance(context).parse(ResourceTable.Layout_player_loading_layout, null, false); - if (loadingContainer.findComponentById(ResourceTable.Id_image_loading) instanceof Image) { - mLoading = (Image) loadingContainer.findComponentById(ResourceTable.Id_image_loading); - initAnim(); - } - addComponent(loadingContainer); - hide(); - setTouchEventListener(this); - } - - private void initAnim() { - int with = mLoading.getWidth() / HALF_NUMBER; - int height = mLoading.getHeight() / HALF_NUMBER; - mLoading.setPivotX(with); - mLoading.setPivotY(height); - mLoadingAnim = mLoading.createAnimatorProperty(); - mLoadingAnim.rotate(ANIM_ROTATE).setDuration(ANIM_DURATION).setLoopedCount(ANIM_LOOPED_COUNT); - } - - private void initListener() { - mPlayer.addPlayerStatuCallback(statu -> mContext.getUITaskDispatcher().asyncDispatch(() -> { - switch (statu) { - case PREPARING: - case BUFFERING: - show(); - break; - case PLAY: - hide(); - break; - default: - break; - } - })); - } - - /** - * show of PlayerLoading - */ - public void show() { - if (mLoadingAnim.isPaused()) { - mLoadingAnim.resume(); - } else { - mLoadingAnim.start(); - } - setVisibility(VISIBLE); - } - - /** - * hide of PlayerLoading - */ - public void hide() { - setVisibility(INVISIBLE); - mLoadingAnim.pause(); - } - - @Override - public void bind(ImplHmPlayer player) { - mPlayer = player; - initListener(); - } - - @Override - public void unbind() { - mLoadingAnim.release(); - } - - @Override - public boolean onTouchEvent(Component component, TouchEvent touchEvent) { - return true; - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/view/SimplePlayerController.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/view/SimplePlayerController.java deleted file mode 100644 index 3a066f32f6029ee18877c8d2c3bdde0df0637cf2..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/player/view/SimplePlayerController.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.player.view; - -import com.huawei.harmonyaudiodemo.ResourceTable; -import com.huawei.harmonyaudiodemo.player.api.HmPlayModuler; -import com.huawei.harmonyaudiodemo.player.api.ImplHmPlayer; -import com.huawei.harmonyaudiodemo.player.api.StatuChangeListener; -import com.huawei.harmonyaudiodemo.player.constant.Constants; -import com.huawei.harmonyaudiodemo.player.constant.PlayerStatu; -import com.huawei.harmonyaudiodemo.player.util.DateUtils; - -import ohos.agp.colors.RgbColor; -import ohos.agp.components.AttrSet; -import ohos.agp.components.Component; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.DependentLayout; -import ohos.agp.components.DirectionalLayout; -import ohos.agp.components.Image; -import ohos.agp.components.LayoutScatter; -import ohos.agp.components.Slider; -import ohos.agp.components.Text; -import ohos.agp.components.element.ShapeElement; -import ohos.app.Context; -import ohos.eventhandler.EventHandler; -import ohos.eventhandler.EventRunner; -import ohos.eventhandler.InnerEvent; - -/** - * PlayerController - * - * @since 2021-04-04 - */ -public class SimplePlayerController extends ComponentContainer implements HmPlayModuler { - private static final int THUMB_RED = 255; - private static final int THUMB_GREEN = 255; - private static final int THUMB_BLUE = 240; - private static final int THUMB_WIDTH = 40; - private static final int THUMB_HEIGHT = 40; - private static final int THUMB_RADIUS = 20; - private static final int CONTROLLER_HIDE_DLEY_TIME = 5000; - private static final int PROGRESS_RUNNING_TIME = 1000; - private boolean mIsDragMode = false; - private Context mContext; - private ImplHmPlayer mPlayer; - private DependentLayout topLayout; - private DirectionalLayout bottomLayout; - private Image mBack; - private Image mPlayToogle; - private Image mForward; - private Image mBackward; - private Slider mProgressBar; - private Text mCurrentTime; - private Text mTotleTime; - private ControllerHandler mHandler; - private StatuChangeListener mStatuChangeListener = new StatuChangeListener() { - @Override - public void statuCallback(PlayerStatu statu) { - mContext.getUITaskDispatcher().asyncDispatch(() -> { - switch (statu) { - case PREPARING: - mPlayToogle.setClickable(false); - mProgressBar.setEnabled(false); - mProgressBar.setProgressValue(0); - break; - case PREPARED: - mProgressBar.setMaxValue(mPlayer.getDuration()); - mTotleTime.setText(DateUtils.msToString(mPlayer.getDuration())); - break; - case PLAY: - showController(false); - mPlayToogle.setPixelMap(ResourceTable.Media_ic_music_stop); - mPlayToogle.setClickable(true); - mProgressBar.setEnabled(true); - break; - case PAUSE: - mPlayToogle.setPixelMap(ResourceTable.Media_ic_music_play); - break; - case STOP: - case COMPLETE: - mPlayToogle.setPixelMap(ResourceTable.Media_ic_update); - mProgressBar.setEnabled(false); - break; - default: - break; - } - }); - } - }; - - /** - * constructor of SimplePlayerController - * - * @param context context - */ - public SimplePlayerController(Context context) { - this(context, null); - } - - /** - * constructor of SimplePlayerController - * - * @param context context - * @param attrSet attSet - */ - public SimplePlayerController(Context context, AttrSet attrSet) { - this(context, attrSet, null); - } - - /** - * constructor of SimplePlayerController - * - * @param context context - * @param attrSet attSet - * @param styleName styleName - */ - public SimplePlayerController(Context context, AttrSet attrSet, String styleName) { - super(context, attrSet, styleName); - mContext = context; - createHandler(); - initView(); - initListener(); - } - - private void createHandler() { - EventRunner runner = EventRunner.create(true); - if (runner == null) { - return; - } - mHandler = new ControllerHandler(runner); - } - - private void initView() { - Component playerController = - LayoutScatter.getInstance(mContext) - .parse(ResourceTable.Layout_simple_player_controller_layout, null, false); - addComponent(playerController); - if (playerController.findComponentById(ResourceTable.Id_controller_top_layout) instanceof DependentLayout) { - topLayout = (DependentLayout) playerController.findComponentById(ResourceTable.Id_controller_top_layout); - } - if (playerController.findComponentById(ResourceTable.Id_controller_bottom_layout) - instanceof DirectionalLayout) { - bottomLayout = (DirectionalLayout) playerController - .findComponentById(ResourceTable.Id_controller_bottom_layout); - } - if (playerController.findComponentById(ResourceTable.Id_back) instanceof Image) { - mBack = (Image) playerController.findComponentById(ResourceTable.Id_back); - } - if (playerController.findComponentById(ResourceTable.Id_play_controller) instanceof Image) { - mPlayToogle = (Image) playerController.findComponentById(ResourceTable.Id_play_controller); - } - if (playerController.findComponentById(ResourceTable.Id_play_forward) instanceof Image) { - mForward = (Image) playerController.findComponentById(ResourceTable.Id_play_forward); - } - if (playerController.findComponentById(ResourceTable.Id_play_backward) instanceof Image) { - mBackward = (Image) playerController.findComponentById(ResourceTable.Id_play_backward); - } - if (playerController.findComponentById(ResourceTable.Id_progress) instanceof Slider) { - mProgressBar = (Slider) playerController.findComponentById(ResourceTable.Id_progress); - } - ShapeElement shapeElement = new ShapeElement(); - shapeElement.setRgbColor(new RgbColor(THUMB_RED, THUMB_GREEN, THUMB_BLUE)); - shapeElement.setBounds(0, 0, THUMB_WIDTH, THUMB_HEIGHT); - shapeElement.setCornerRadius(THUMB_RADIUS); - mProgressBar.setThumbElement(shapeElement); - if (playerController.findComponentById(ResourceTable.Id_current_time) instanceof Text) { - mCurrentTime = (Text) playerController.findComponentById(ResourceTable.Id_current_time); - } - if (playerController.findComponentById(ResourceTable.Id_end_time) instanceof Text) { - mTotleTime = (Text) playerController.findComponentById(ResourceTable.Id_end_time); - } - } - - private void initListener() { - topLayout.setTouchEventListener((component, touchEvent) -> true); - bottomLayout.setTouchEventListener((component, touchEvent) -> true); - mBack.setClickedListener(component -> mContext.terminateAbility()); - } - - private void initPlayListener() { - mPlayer.addPlayerStatuCallback(mStatuChangeListener); - mPlayToogle.setClickedListener(component -> { - if (mPlayer.isPlaying()) { - mPlayer.pause(); - } else { - if (mPlayer.getPlayerStatu() == PlayerStatu.STOP) { - mPlayer.replay(); - } else { - mPlayer.resume(); - } - } - }); - mForward.setClickedListener(component -> - mPlayer.rewindTo(mPlayer.getCurrentPosition() + Constants.REWIND_STEP)); - mBackward.setClickedListener(component -> - mPlayer.rewindTo(mPlayer.getCurrentPosition() - Constants.REWIND_STEP)); - mProgressBar.setValueChangedListener( - new Slider.ValueChangedListener() { - @Override - public void onProgressUpdated(Slider slider, int value, boolean isB) { - mContext.getUITaskDispatcher().asyncDispatch(() -> - mCurrentTime.setText(DateUtils.msToString(value))); - } - - @Override - public void onTouchStart(Slider slider) { - mIsDragMode = true; - mHandler.removeEvent(Constants.PLAYER_PROGRESS_RUNNING, EventHandler.Priority.IMMEDIATE); - } - - @Override - public void onTouchEnd(Slider slider) { - mIsDragMode = false; - if (slider.getProgress() == mPlayer.getDuration()) { - mPlayer.stop(); - } else { - mPlayer.rewindTo(slider.getProgress()); - } - } - }); - } - - /** - * showController of PlayerController - * - * @param isAutoHide isAutoHide - */ - public void showController(boolean isAutoHide) { - mHandler.sendEvent(Constants.PLAYER_CONTROLLER_SHOW, EventHandler.Priority.HIGH); - if (isAutoHide) { - hideController(CONTROLLER_HIDE_DLEY_TIME); - } else { - mHandler.removeEvent(Constants.PLAYER_CONTROLLER_HIDE); - } - } - - /** - * hideController of PlayerController - * - * @param delay delay - */ - public void hideController(int delay) { - mHandler.removeEvent(Constants.PLAYER_CONTROLLER_HIDE); - mHandler.sendEvent(Constants.PLAYER_CONTROLLER_HIDE, delay, EventHandler.Priority.HIGH); - } - - @Override - public void bind(ImplHmPlayer player) { - mPlayer = player; - initPlayListener(); - } - - @Override - public void unbind() { - mHandler.removeAllEvent(); - mHandler = null; - } - - /** - * ControllerHandler - * - * @author chenweiquan - * @since 2020-12-04 - */ - private class ControllerHandler extends EventHandler { - private ControllerHandler(EventRunner runner) { - super(runner); - } - - @Override - public void processEvent(InnerEvent event) { - super.processEvent(event); - if (event == null) { - return; - } - switch (event.eventId) { - case Constants.PLAYER_PROGRESS_RUNNING: - if (mPlayer != null && mPlayer.isPlaying() && !mIsDragMode) { - mContext.getUITaskDispatcher().asyncDispatch(() -> { - mProgressBar.setProgressValue(mPlayer.getCurrentPosition()); - mCurrentTime.setText(DateUtils.msToString(mPlayer.getCurrentPosition())); - }); - mHandler.sendEvent( - Constants.PLAYER_PROGRESS_RUNNING, PROGRESS_RUNNING_TIME, Priority.IMMEDIATE); - } - break; - case Constants.PLAYER_CONTROLLER_HIDE: - mContext.getUITaskDispatcher().asyncDispatch(() -> setVisibility(INVISIBLE)); - mHandler.removeEvent(Constants.PLAYER_PROGRESS_RUNNING); - break; - case Constants.PLAYER_CONTROLLER_SHOW: - mHandler.removeEvent(Constants.PLAYER_PROGRESS_RUNNING); - mHandler.sendEvent(Constants.PLAYER_PROGRESS_RUNNING, Priority.IMMEDIATE); - mContext.getUITaskDispatcher().asyncDispatch(() -> setVisibility(VISIBLE)); - break; - default: - break; - } - } - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/slice/MainAbilitySlice.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/slice/MainAbilitySlice.java deleted file mode 100644 index 9df0bbeafeebc8b220c22dec657b313d3f5eac1a..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/slice/MainAbilitySlice.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.slice; - -import com.huawei.harmonyaudiodemo.MainAbility; -import com.huawei.harmonyaudiodemo.ResourceTable; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.aafwk.content.Operation; -import ohos.agp.components.Component; - -/** - * MainAbilitySlice - * - * @since 2021-04-04 - */ -public class MainAbilitySlice extends AbilitySlice implements Component.ClickedListener { - @Override - protected void onStart(Intent intent) { - super.onStart(intent); - setUIContent(ResourceTable.Layout_ability_main); - initView(); - } - - @Override - protected void onStop() { - super.onStop(); - } - - private void initView() { - findComponentById(ResourceTable.Id_sound_music_play_btn).setClickedListener(this); - findComponentById(ResourceTable.Id_sound_system_play_btn).setClickedListener(this); - findComponentById(ResourceTable.Id_sound_record_btn).setClickedListener(this); - findComponentById(ResourceTable.Id_sound_volume_btn).setClickedListener(this); - } - - @Override - public void onClick(Component view) { - Intent intent = new Intent(); - String actionName = ""; - switch (view.getId()) { - case ResourceTable.Id_sound_music_play_btn: - actionName = "action.sound.play.music"; - break; - case ResourceTable.Id_sound_system_play_btn: - actionName = "action.sound.play.system"; - break; - case ResourceTable.Id_sound_record_btn: - actionName = "action.sound.record"; - break; - case ResourceTable.Id_sound_volume_btn: - actionName = "action.sound.volume"; - break; - default: - break; - } - Operation operation = - new Intent.OperationBuilder() - .withBundleName(getBundleName()) - .withAbilityName(MainAbility.class.getName()) - .withAction(actionName) - .build(); - intent.setOperation(operation); - startAbility(intent); - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/slice/MusicPlayerAbilitySlice.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/slice/MusicPlayerAbilitySlice.java deleted file mode 100644 index 388e039b32a556a6db484d3a588534dda736d0e8..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/slice/MusicPlayerAbilitySlice.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.slice; - -import com.huawei.harmonyaudiodemo.ResourceTable; -import com.huawei.harmonyaudiodemo.constant.Const; -import com.huawei.harmonyaudiodemo.player.HmPlayer; -import com.huawei.harmonyaudiodemo.player.api.ImplHmPlayer; -import com.huawei.harmonyaudiodemo.player.view.PlayerLoading; -import com.huawei.harmonyaudiodemo.player.view.SimplePlayerController; -import com.huawei.harmonyaudiodemo.util.LogUtil; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.app.dispatcher.task.TaskPriority; -import ohos.global.resource.NotExistException; -import ohos.global.resource.WrongTypeException; - -import java.io.IOException; - -/** - * SimplePlayerAbilitySlice - * - * @since 2021-04-04 - */ -public class MusicPlayerAbilitySlice extends AbilitySlice { - private static final String TAG = MusicPlayerAbilitySlice.class.getSimpleName(); - private ImplHmPlayer player; - private PlayerLoading playerLoading; - private SimplePlayerController controllerView; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setUIContent(ResourceTable.Layout_ability_music_player); - try { - String mUrl = getResourceManager().getMediaPath(ResourceTable.Media_test); - player = new HmPlayer.Builder(this) - .setFilePath(mUrl) - .create(); - initView(); - getGlobalTaskDispatcher(TaskPriority.DEFAULT).delayDispatch(() -> player.play(), Const.NUMBER_100); - } catch (IOException | NotExistException | WrongTypeException e) { - LogUtil.error(TAG, "get media path failed!"); - } - } - - private void initView() { - if (findComponentById(ResourceTable.Id_loadint_view) instanceof PlayerLoading) { - playerLoading = (PlayerLoading) findComponentById(ResourceTable.Id_loadint_view); - } - if (findComponentById(ResourceTable.Id_controller_view) instanceof SimplePlayerController) { - controllerView = (SimplePlayerController) findComponentById(ResourceTable.Id_controller_view); - } - playerLoading.bind(player); - controllerView.bind(player); - } - - @Override - public void onActive() { - super.onActive(); - } - - @Override - protected void onInactive() { - LogUtil.info(TAG, "onInactive is called"); - super.onInactive(); - } - - @Override - public void onForeground(Intent intent) { - player.getLifecycle().onForeground(); - super.onForeground(intent); - } - - @Override - protected void onBackground() { - LogUtil.info(TAG, "onBackground is called"); - player.getLifecycle().onBackground(); - super.onBackground(); - } - - @Override - protected void onStop() { - LogUtil.info(TAG, "onStop is called"); - playerLoading.unbind(); - controllerView.unbind(); - super.onStop(); - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/slice/SoundRecordSlice.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/slice/SoundRecordSlice.java deleted file mode 100644 index c1362e975ac187f3188c855d46889daa5ffa0931..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/slice/SoundRecordSlice.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.slice; - -import com.huawei.harmonyaudiodemo.ResourceTable; -import com.huawei.harmonyaudiodemo.constant.Const; -import com.huawei.harmonyaudiodemo.media.AudioRecorder; -import com.huawei.harmonyaudiodemo.media.AudioRender; -import com.huawei.harmonyaudiodemo.util.LogUtil; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.agp.components.Button; -import ohos.agp.components.Component; -import ohos.agp.components.LayoutScatter; -import ohos.agp.components.RoundProgressBar; -import ohos.agp.components.SlideDrawer; -import ohos.agp.components.Switch; -import ohos.agp.components.element.FrameAnimationElement; -import ohos.app.Environment; -import ohos.multimodalinput.event.TouchEvent; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; - -/** - * SoundRecordSlice - * - * @since 2021-04-04 - */ -public class SoundRecordSlice extends AbilitySlice { - private static final String TAG = SoundRecordSlice.class.getSimpleName(); - private FrameAnimationElement frameAnimationElement; - private RoundProgressBar recordProgressBar; - private Button recordButton; - private SlideDrawer slideDrawer; - private Component playAnimView; - private AudioRecorder audioRecorder; - private AudioRender recordWithPlayRender; - private AudioRender oneOffLoadRender; - private boolean isRealTimePlay; - private String savefilePath; - private int recordTag; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setUIContent(ResourceTable.Layout_media_sound_audio); - initAnimation(); - initView(); - initListener(); - initRecorder(); - setupRecordWithPlayRender(); - setupOneOffLoadRender(); - } - - private void initAnimation() { - frameAnimationElement = new FrameAnimationElement(getContext(), ResourceTable.Graphic_animation_record_play); - } - - private void initView() { - if (findComponentById(ResourceTable.Id_real_time_switch) instanceof Switch) { - Switch realTimeSwitch = (Switch) findComponentById(ResourceTable.Id_real_time_switch); - realTimeSwitch.setCheckedStateChangedListener((absButton, bool) -> { - isRealTimePlay = bool; - if (isRealTimePlay) { - slideDrawer.closeSmoothly(); - oneOffLoadRender.stop(); - } - }); - } - initRecordView(); - initPlayView(); - } - - private void initListener() { - recordButton.setTouchEventListener(new Component.TouchEventListener() { - private int progress = 0; - - @Override - public boolean onTouchEvent(Component component, TouchEvent touchEvent) { - if (touchEvent.getAction() == TouchEvent.PRIMARY_POINT_DOWN - || touchEvent.getAction() == TouchEvent.OTHER_POINT_DOWN) { - progress = 0; - oneOffLoadRender.stop(); - recordWithPlayRender.stop(); - } - int action = progress >= Const.NUMBER_500 ? TouchEvent.CANCEL : touchEvent.getAction(); - recordButton.setPressState(true); - switch (action) { - case TouchEvent.PRIMARY_POINT_UP: - case TouchEvent.OTHER_POINT_UP: - case TouchEvent.CANCEL: - recordButton.setPressState(false); - recordProgressBar.setProgressValue(0); - shutdownRecord(); - return false; - default: - progress++; - beginRecord(); - break; - } - recordProgressBar.setProgressValue(progress); - return true; - } - }); - } - - private void initRecordView() { - if (findComponentById(ResourceTable.Id_progressbar_record) instanceof RoundProgressBar) { - recordProgressBar = (RoundProgressBar) findComponentById(ResourceTable.Id_progressbar_record); - } - if (findComponentById(ResourceTable.Id_button_record) instanceof Button) { - recordButton = (Button) findComponentById(ResourceTable.Id_button_record); - } - recordProgressBar.setMaxValue(Const.NUMBER_500); - } - - private void initPlayView() { - if (findComponentById(ResourceTable.Id_slide_drawer_record) instanceof SlideDrawer) { - slideDrawer = (SlideDrawer) findComponentById(ResourceTable.Id_slide_drawer_record); - } - slideDrawer.setDisplayMode(SlideDrawer.DisplayMode.WITH_ANIMATION); - slideDrawer.setSlideEnabled(false); - slideDrawer.setTouchForClose(false); - Component playButton = LayoutScatter - .getInstance(this) - .parse(ResourceTable.Layout_record_play_button, null, false); - playAnimView = playButton.findComponentById(ResourceTable.Id_animation_view); - playAnimView.setBackground(frameAnimationElement); - SlideDrawer.LayoutConfig layoutConfig = new SlideDrawer - .LayoutConfig(Const.NUMBER_300, Const.NUMBER_114, SlideDrawer.SlideDirection.START); - layoutConfig.setMarginsLeftAndRight(Const.NUMBER_60, 0); - playButton.setLayoutConfig(layoutConfig); - slideDrawer.addComponent(playButton); - playButton.setClickedListener(component -> { - oneOffLoadRender.stop(); - getUITaskDispatcher().asyncDispatch(() -> playAnimView.setVisibility(Component.VISIBLE)); - frameAnimationElement.start(); - playLocalAudioFile(); - }); - } - - private void initRecorder() { - savefilePath = getExternalFilesDir(Environment.DIRECTORY_MUSIC) + File.separator + "AudioTest.mp3"; - audioRecorder = new AudioRecorder.Builder().setSaveFilePath(savefilePath).create(); - } - - private void setupRecordWithPlayRender() { - recordWithPlayRender = new AudioRender.Builder().setOneOffLoad(false).create(); - audioRecorder.setAudioRecordListener((buffer, length) -> { - if (recordTag == 0) { - recordWithPlayRender.play(buffer, length); - } - }); - } - - private void setupOneOffLoadRender() { - oneOffLoadRender = new AudioRender.Builder().create(); - oneOffLoadRender.setPlayListener(() -> { - frameAnimationElement.stop(); - getUITaskDispatcher().asyncDispatch(() -> playAnimView.setVisibility(Component.INVISIBLE)); - }); - } - - private void shutdownRecord() { - if (audioRecorder.isRecording()) { - audioRecorder.stopRecord(); - } - if (!isRealTimePlay) { - slideDrawer.openSmoothly(); - } - } - - private void beginRecord() { - if (!audioRecorder.isRecording()) { - recordTag = isRealTimePlay ? 0 : 1; - audioRecorder.record(); - } - } - - private void playLocalAudioFile() { - BufferedInputStream bis = null; - try { - bis = new BufferedInputStream(new FileInputStream(savefilePath)); - byte[] buffers = new byte[bis.available()]; - int len; - while ((len = bis.read(buffers)) != Const.NUMBER_NEGATIVE_1) { - oneOffLoadRender.play(buffers, len); - } - } catch (IOException e) { - LogUtil.error(TAG, "play local audio file failed"); - } finally { - if (bis != null) { - try { - bis.close(); - } catch (IOException e) { - LogUtil.error(TAG, "play local audio file failed"); - } - } - } - } - - @Override - public void onActive() { - super.onActive(); - } - - @Override - public void onForeground(Intent intent) { - super.onForeground(intent); - } - - @Override - protected void onStop() { - recordWithPlayRender.release(); - oneOffLoadRender.release(); - audioRecorder.stopRecord(); - super.onStop(); - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/slice/SoundSystemSlice.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/slice/SoundSystemSlice.java deleted file mode 100644 index 543e740995feac77874522e832eb81db3f166da8..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/slice/SoundSystemSlice.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.slice; - -import com.huawei.harmonyaudiodemo.ResourceTable; -import com.huawei.harmonyaudiodemo.constant.Const; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.agp.components.Component; -import ohos.media.audio.SoundPlayer; -import ohos.media.audio.ToneDescriptor; - -/** - * SoundSystemSlice - * - * @since 2021-04-04 - */ -public class SoundSystemSlice extends AbilitySlice implements Component.ClickedListener { - private SoundPlayer soundPlayer; - - @Override - protected void onStart(Intent intent) { - super.onStart(intent); - setUIContent(ResourceTable.Layout_media_sound_tone); - initView(); - initPlayer(); - } - - private void initView() { - findComponentById(ResourceTable.Id_sound0).setClickedListener(this); - findComponentById(ResourceTable.Id_sound1).setClickedListener(this); - findComponentById(ResourceTable.Id_sound2).setClickedListener(this); - findComponentById(ResourceTable.Id_sound3).setClickedListener(this); - findComponentById(ResourceTable.Id_sound4).setClickedListener(this); - findComponentById(ResourceTable.Id_sound5).setClickedListener(this); - findComponentById(ResourceTable.Id_sound6).setClickedListener(this); - findComponentById(ResourceTable.Id_sound7).setClickedListener(this); - findComponentById(ResourceTable.Id_sound8).setClickedListener(this); - findComponentById(ResourceTable.Id_sound9).setClickedListener(this); - } - - private void initPlayer() { - soundPlayer = new SoundPlayer(); - } - - @Override - public void onClick(Component view) { - switch (view.getId()) { - case ResourceTable.Id_sound0: - soundPlayer.createSound(ToneDescriptor.ToneType.DTMF_0, Const.NUMBER_500); - soundPlayer.play(); - break; - case ResourceTable.Id_sound1: - soundPlayer.createSound(ToneDescriptor.ToneType.DTMF_1, Const.NUMBER_500); - soundPlayer.play(); - break; - case ResourceTable.Id_sound2: - soundPlayer.createSound(ToneDescriptor.ToneType.DTMF_2, Const.NUMBER_500); - soundPlayer.play(); - break; - case ResourceTable.Id_sound3: - soundPlayer.createSound(ToneDescriptor.ToneType.DTMF_3, Const.NUMBER_500); - soundPlayer.play(); - break; - case ResourceTable.Id_sound4: - soundPlayer.createSound(ToneDescriptor.ToneType.DTMF_4, Const.NUMBER_500); - soundPlayer.play(); - break; - case ResourceTable.Id_sound5: - soundPlayer.createSound(ToneDescriptor.ToneType.DTMF_5, Const.NUMBER_500); - soundPlayer.play(); - break; - case ResourceTable.Id_sound6: - soundPlayer.createSound(ToneDescriptor.ToneType.DTMF_6, Const.NUMBER_500); - soundPlayer.play(); - break; - case ResourceTable.Id_sound7: - soundPlayer.createSound(ToneDescriptor.ToneType.DTMF_7, Const.NUMBER_500); - soundPlayer.play(); - break; - case ResourceTable.Id_sound8: - soundPlayer.createSound(ToneDescriptor.ToneType.DTMF_8, Const.NUMBER_500); - soundPlayer.play(); - break; - case ResourceTable.Id_sound9: - soundPlayer.createSound(ToneDescriptor.ToneType.DTMF_9, Const.NUMBER_500); - soundPlayer.play(); - break; - default: - break; - } - } - - @Override - protected void onStop() { - if (soundPlayer != null) { - soundPlayer.release(); - soundPlayer = null; - } - super.onStop(); - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/slice/SoundVolumeSlice.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/slice/SoundVolumeSlice.java deleted file mode 100644 index 8e295f054de7ebe323fc6eaa271932b385070ff4..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/slice/SoundVolumeSlice.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.slice; - -import com.huawei.harmonyaudiodemo.ResourceTable; -import com.huawei.harmonyaudiodemo.util.LogUtil; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.agp.components.Slider; -import ohos.agp.components.Slider.ValueChangedListener; -import ohos.media.audio.AudioManager; -import ohos.media.audio.AudioRemoteException; - -/** - * SoundVolumeSlice - * - * @since 2021-04-04 - */ -public class SoundVolumeSlice extends AbilitySlice implements ValueChangedListener { - private static final String TAG = SoundVolumeSlice.class.getName(); - private AudioManager audioManager; - private int dtmfVolume; - private int musicVolume; - private int callVolume; - - @Override - protected void onStart(Intent intent) { - super.onStart(intent); - setUIContent(ResourceTable.Layout_media_sound_volume); - audioManager = new AudioManager(); - initView(); - } - - private void initView() { - try { - initSlider(ResourceTable.Id_sound_volume_bar); - initSlider(ResourceTable.Id_sound_volume_bar2); - initSlider(ResourceTable.Id_sound_volume_bar3); - } catch (AudioRemoteException e) { - LogUtil.error(TAG, "audio remote exception"); - } - } - - private void initSlider(int id) throws AudioRemoteException { - Slider slider = null; - if (findComponentById(id) instanceof Slider) { - slider = (Slider) findComponentById(id); - } - int maxValue = 0; - int currentValue = 0; - switch (id) { - case ResourceTable.Id_sound_volume_bar: - maxValue = audioManager.getMaxVolume(AudioManager.AudioVolumeType.STREAM_DTMF); - currentValue = audioManager.getVolume(AudioManager.AudioVolumeType.STREAM_DTMF); - dtmfVolume = currentValue; - break; - case ResourceTable.Id_sound_volume_bar2: - maxValue = audioManager.getMaxVolume(AudioManager.AudioVolumeType.STREAM_MUSIC); - currentValue = audioManager.getVolume(AudioManager.AudioVolumeType.STREAM_MUSIC); - musicVolume = currentValue; - break; - case ResourceTable.Id_sound_volume_bar3: - maxValue = audioManager.getMaxVolume(AudioManager.AudioVolumeType.STREAM_VOICE_CALL); - currentValue = audioManager.getVolume(AudioManager.AudioVolumeType.STREAM_VOICE_CALL); - callVolume = currentValue; - break; - default: - break; - } - if (slider != null) { - slider.setMaxValue(maxValue); - slider.setProgressValue(currentValue); - slider.setValueChangedListener(this); - } - } - - @Override - public void onProgressUpdated(Slider slider, int info, boolean isBool) { - } - - @Override - public void onTouchStart(Slider slider) { - } - - @Override - public void onTouchEnd(Slider slider) { - int progress = slider.getProgress(); - switch (slider.getId()) { - case ResourceTable.Id_sound_volume_bar: - try { - if (audioManager.setVolume(AudioManager.AudioVolumeType.STREAM_DTMF, progress)) { - dtmfVolume = progress; - } else { - audioManager.setVolume(AudioManager.AudioVolumeType.STREAM_DTMF, dtmfVolume); - } - } catch (SecurityException e) { - LogUtil.error(TAG, "set dtmf volume error"); - } - break; - case ResourceTable.Id_sound_volume_bar2: - try { - if (audioManager.setVolume(AudioManager.AudioVolumeType.STREAM_MUSIC, progress)) { - musicVolume = progress; - } else { - audioManager.setVolume(AudioManager.AudioVolumeType.STREAM_MUSIC, musicVolume); - } - } catch (SecurityException e) { - LogUtil.error(TAG, "set music volume error"); - } - break; - case ResourceTable.Id_sound_volume_bar3: - try { - if (audioManager.setVolume(AudioManager.AudioVolumeType.STREAM_VOICE_CALL, progress)) { - callVolume = progress; - } else { - audioManager.setVolume(AudioManager.AudioVolumeType.STREAM_VOICE_CALL, callVolume); - } - } catch (SecurityException e) { - LogUtil.error(TAG, "set call volume error"); - } - break; - default: - break; - } - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/util/LogUtil.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/util/LogUtil.java deleted file mode 100644 index 65d08bd0320d62a395b758e83d236470344199a9..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/util/LogUtil.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.util; - -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; - -/** - * Log util - * - * @since 2021-04-04 - */ -public class LogUtil { - private static final String TAG_LOG = "LogUtil"; - - private static final HiLogLabel LABEL_LOG = new HiLogLabel(0, 0, LogUtil.TAG_LOG); - - private static final String LOG_FORMAT = "%{public}s: %{public}s"; - - private LogUtil() { - } - - /** - * Print debug log - * - * @param tag log tag - * @param msg log message - */ - public static void debug(String tag, String msg) { - HiLog.debug(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print info log - * - * @param tag log tag - * @param msg log message - */ - public static void info(String tag, String msg) { - HiLog.info(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print warn log - * - * @param tag log tag - * @param msg log message - */ - public static void warn(String tag, String msg) { - HiLog.warn(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print error log - * - * @param tag log tag - * @param msg log message - */ - public static void error(String tag, String msg) { - HiLog.error(LABEL_LOG, LOG_FORMAT, tag, msg); - } -} diff --git a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/util/ScreenUtils.java b/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/util/ScreenUtils.java deleted file mode 100644 index f2cc386daad3fdd329dd6094734b9e6e416ba73a..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/java/com/huawei/harmonyaudiodemo/util/ScreenUtils.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.harmonyaudiodemo.util; - -import ohos.agp.utils.Point; -import ohos.agp.window.service.Display; -import ohos.agp.window.service.DisplayManager; -import ohos.app.Context; -import ohos.global.configuration.DeviceCapability; - -import java.util.Optional; - -/** - * Screen util - * - * @since 2021-04-04 - */ -public class ScreenUtils { - private ScreenUtils() { - } - - /** - * getScreenHeight - * - * @param context context - * @return Screen Height - */ - public static int getScreenHeight(Context context) { - DisplayManager displayManager = DisplayManager.getInstance(); - Optional optDisplay = displayManager.getDefaultDisplay(context); - Point point = new Point(0, 0); - if (!optDisplay.isPresent()) { - return (int) point.position[1]; - } else { - Display display = optDisplay.get(); - display.getSize(point); - return (int) point.position[1]; - } - } - - /** - * getScreenWidth - * - * @param context context - * @return Screen Width - */ - public static int getScreenWidth(Context context) { - DisplayManager displayManager = DisplayManager.getInstance(); - Optional optDisplay = displayManager.getDefaultDisplay(context); - Point point = new Point(0, 0); - if (!optDisplay.isPresent()) { - return (int) point.position[0]; - } else { - Display display = optDisplay.get(); - display.getSize(point); - return (int) point.position[0]; - } - } - - /** - * dp2px - * - * @param context context - * @param size size - * @return int - */ - public static int dp2px(Context context, int size) { - int density = context.getResourceManager().getDeviceCapability().screenDensity / DeviceCapability.SCREEN_MDPI; - return size * density; - } - - /** - * px2dip - * - * @param context context - * @param size size - * @return int - */ - public static int px2dip(Context context, int size) { - int density = context.getResourceManager().getDeviceCapability().screenDensity / DeviceCapability.SCREEN_MDPI; - return size / density; - } -} diff --git a/AudioDemo/entry/src/main/resources/base/element/color.json b/AudioDemo/entry/src/main/resources/base/element/color.json deleted file mode 100644 index d4e835bddf1c1ea9ceb11cd87238bd3021e92515..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "color": [ - { - "name": "red", - "value": "#FF0000" - }, - { - "name": "blue", - "value": "#0000FF" - }, - { - "name": "white", - "value": "#ffffff" - } - ] -} \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/element/string.json b/AudioDemo/entry/src/main/resources/base/element/string.json deleted file mode 100644 index bb076ba2d5a9f3a2987a43f259d17da119863aa6..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string":[ - { - "name":"app_name", - "value":"HarmonyAudioDemo" - }, - { - "name":"mainability_description", - "value":"Java_Phone_Empty Feature Ability" - } - ] -} \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/graphic/animation_record_play.xml b/AudioDemo/entry/src/main/resources/base/graphic/animation_record_play.xml deleted file mode 100644 index e90863d7699ce5a13cedaf94419f98e9c72b3f11..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/animation_record_play.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/graphic/background_ability_main.xml b/AudioDemo/entry/src/main/resources/base/graphic/background_ability_main.xml deleted file mode 100644 index 47a2d3e00aea59206e521f2e2c2491c629528df9..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/background_ability_main.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/graphic/background_record_progress.xml b/AudioDemo/entry/src/main/resources/base/graphic/background_record_progress.xml deleted file mode 100644 index 98942569f9cc93e902efc047a6fe9c3fd9b56c0b..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/background_record_progress.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/graphic/button_normal_ability_main.xml b/AudioDemo/entry/src/main/resources/base/graphic/button_normal_ability_main.xml deleted file mode 100644 index 72106aa48fd77c9124c3cc99126627d562cbeada..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/button_normal_ability_main.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/graphic/button_pressed_ability_main.xml b/AudioDemo/entry/src/main/resources/base/graphic/button_pressed_ability_main.xml deleted file mode 100644 index a29a1da66db5c0c9f5e67bfcd580f61267d4b59f..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/button_pressed_ability_main.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/graphic/button_record_normal.xml b/AudioDemo/entry/src/main/resources/base/graphic/button_record_normal.xml deleted file mode 100644 index 82fa87c355a32b377dde3298dbd713c9c7bebbd3..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/button_record_normal.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/graphic/button_record_pressed.xml b/AudioDemo/entry/src/main/resources/base/graphic/button_record_pressed.xml deleted file mode 100644 index 884334598914ae48bf533db9f931bd677a84a8c3..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/button_record_pressed.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/graphic/corner_yellow_bg.xml b/AudioDemo/entry/src/main/resources/base/graphic/corner_yellow_bg.xml deleted file mode 100644 index 9bbecb50641c449f4d12f079d06888d614031415..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/corner_yellow_bg.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/AudioDemo/entry/src/main/resources/base/graphic/gray_thumb.xml b/AudioDemo/entry/src/main/resources/base/graphic/gray_thumb.xml deleted file mode 100644 index d417a8323687bfb6403316072e2ac50b0a0befcd..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/gray_thumb.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/graphic/gray_track.xml b/AudioDemo/entry/src/main/resources/base/graphic/gray_track.xml deleted file mode 100644 index 2235f61227ed99cbe9dd13b183d8d3eb257c2ec2..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/gray_track.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/graphic/green_thumb.xml b/AudioDemo/entry/src/main/resources/base/graphic/green_thumb.xml deleted file mode 100644 index f1d6074ab039aefb1826442ccf765b9963e8f12a..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/green_thumb.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/graphic/green_track.xml b/AudioDemo/entry/src/main/resources/base/graphic/green_track.xml deleted file mode 100644 index 4854f4e01f75d959d381e8ccbd739932a8f31473..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/green_track.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/graphic/selector_ability_main.xml b/AudioDemo/entry/src/main/resources/base/graphic/selector_ability_main.xml deleted file mode 100644 index 603ed1fbca321ba08d2f00aa83089b9cfc79ea1f..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/selector_ability_main.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/graphic/selector_button_record.xml b/AudioDemo/entry/src/main/resources/base/graphic/selector_button_record.xml deleted file mode 100644 index 120009d0731bcb3d372cf62ed24b4d1492076086..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/selector_button_record.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/graphic/thumb.xml b/AudioDemo/entry/src/main/resources/base/graphic/thumb.xml deleted file mode 100644 index 1c42512863fc7196a8f326be27b340bac03784f1..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/thumb.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/graphic/track.xml b/AudioDemo/entry/src/main/resources/base/graphic/track.xml deleted file mode 100644 index ecb569ed0ad2ca43aafd7a7157301ee3e8d29829..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/graphic/track.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/AudioDemo/entry/src/main/resources/base/layout/ability_main.xml b/AudioDemo/entry/src/main/resources/base/layout/ability_main.xml deleted file mode 100644 index fde80782cbce9ad596f34b753e76df0254bd06ac..0000000000000000000000000000000000000000 --- a/AudioDemo/entry/src/main/resources/base/layout/ability_main.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - -
- {{imageNormal.title}} + {{imageNormal.title}}
@@ -13,7 +13,7 @@
- {{imageSelect.title}} + {{imageSelect.title}}
@@ -23,7 +23,7 @@
- {{frameContainerPhone.title}} + {{frameContainerPhone.title}}
@@ -31,7 +31,7 @@
- {{frameContainerState.title}} + {{frameContainerState.title}}
diff --git a/ClickableJsDemo/entry/src/main/js/default/pages/index/index.js b/ClickableJsDemo/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..1c4153a857e9b1ff8d7dcb3a78b04374f0346376 --- /dev/null +++ b/ClickableJsDemo/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,140 @@ +export default { + data: { + imageNormal: { + classType: 'main-img-unTouch', + src: '/common/images/sky_blue.png', + title: '点击阴影' + }, + imageSelect: { + src: '/common/images/hook.png', + title: '点击切换状态', + hook: true + }, + frameContainerPhone: { + frames: [ + {src: '/common/images/frames/phone/phone_0.png'}, + {src: '/common/images/frames/phone/phone_1.png'}, + {src: '/common/images/frames/phone/phone_2.png'}, + {src: '/common/images/frames/phone/phone_3.png'}, + {src: '/common/images/frames/phone/phone_4.png'}, + {src: '/common/images/frames/phone/phone_5.png'}, + {src: '/common/images/frames/phone/phone_6.png'}, + {src: '/common/images/frames/phone/phone_7.png'}, + {src: '/common/images/frames/phone/phone_8.png'}, + {src: '/common/images/frames/phone/phone_9.png'}, + {src: '/common/images/frames/phone/phone_10.png'}, + {src: '/common/images/frames/phone/phone_11.png'}, + {src: '/common/images/frames/phone/phone_12.png'}, + {src: '/common/images/frames/phone/phone_13.png'}, + {src: '/common/images/frames/phone/phone_14.png'}, + {src: '/common/images/frames/phone/phone_15.png'}, + {src: '/common/images/frames/phone/phone_16.png'}, + {src: '/common/images/frames/phone/phone_17.png'}, + {src: '/common/images/frames/phone/phone_18.png'}, + {src: '/common/images/frames/phone/phone_19.png'}, + {src: '/common/images/frames/phone/phone_20.png'}, + {src: '/common/images/frames/phone/phone_21.png'}, + {src: '/common/images/frames/phone/phone_22.png'}, + {src: '/common/images/frames/phone/phone_23.png'}, + {src: '/common/images/frames/phone/phone_24.png'}, + {src: '/common/images/frames/phone/phone_25.png'}, + {src: '/common/images/frames/phone/phone_26.png'}, + {src: '/common/images/frames/phone/phone_27.png'}, + {src: '/common/images/frames/phone/phone_28.png'}, + {src: '/common/images/frames/phone/phone_29.png'}, + {src: '/common/images/frames/phone/phone_30.png'}, + {src: '/common/images/frames/phone/phone_31.png'}, + {src: '/common/images/frames/phone/phone_32.png'}, + {src: '/common/images/frames/phone/phone_33.png'}, + {src: '/common/images/frames/phone/phone_34.png'}, + {src: '/common/images/frames/phone/phone_35.png'} + ], + title: '点击动画效果', + durationTime: 3600 + }, + frameContainerState: { + frames: [], + title: '点击切换状态动效', + durationTime: 0, + flag: true + }, + durationTimeArray: [1400, 1400], + back: [ + {src: '/common/images/frames/arrowheadBack/arrowhead_back_0.png'}, + {src: '/common/images/frames/arrowheadBack/arrowhead_back_1.png'}, + {src: '/common/images/frames/arrowheadBack/arrowhead_back_2.png'}, + {src: '/common/images/frames/arrowheadBack/arrowhead_back_3.png'}, + {src: '/common/images/frames/arrowheadBack/arrowhead_back_4.png'}, + {src: '/common/images/frames/arrowheadBack/arrowhead_back_5.png'}, + {src: '/common/images/frames/arrowheadBack/arrowhead_back_6.png'}, + {src: '/common/images/frames/arrowheadBack/arrowhead_back_7.png'}, + {src: '/common/images/frames/arrowheadBack/arrowhead_back_8.png'}, + {src: '/common/images/frames/arrowheadBack/arrowhead_back_9.png'}, + {src: '/common/images/frames/arrowheadBack/arrowhead_back_10.png'}, + {src: '/common/images/frames/arrowheadBack/arrowhead_back_11.png'}, + {src: '/common/images/frames/arrowheadBack/arrowhead_back_12.png'}, + {src: '/common/images/frames/arrowheadBack/arrowhead_back_13.png'} + ], + collapse: [ + {src: '/common/images/frames/arrowheadCollapse/arrowhead_collapse_0.png'}, + {src: '/common/images/frames/arrowheadCollapse/arrowhead_collapse_1.png'}, + {src: '/common/images/frames/arrowheadCollapse/arrowhead_collapse_2.png'}, + {src: '/common/images/frames/arrowheadCollapse/arrowhead_collapse_3.png'}, + {src: '/common/images/frames/arrowheadCollapse/arrowhead_collapse_4.png'}, + {src: '/common/images/frames/arrowheadCollapse/arrowhead_collapse_5.png'}, + {src: '/common/images/frames/arrowheadCollapse/arrowhead_collapse_6.png'}, + {src: '/common/images/frames/arrowheadCollapse/arrowhead_collapse_7.png'}, + {src: '/common/images/frames/arrowheadCollapse/arrowhead_collapse_8.png'}, + {src: '/common/images/frames/arrowheadCollapse/arrowhead_collapse_9.png'}, + {src: '/common/images/frames/arrowheadCollapse/arrowhead_collapse_10.png'}, + {src: '/common/images/frames/arrowheadCollapse/arrowhead_collapse_11.png'}, + {src: '/common/images/frames/arrowheadCollapse/arrowhead_collapse_12.png'}, + {src: '/common/images/frames/arrowheadCollapse/arrowhead_collapse_13.png'} + ] + }, +// 初始化 + onInit() { + this.frameContainerState.frames = this.back; + this.frameContainerState.durationTime = 0; + this.frameContainerPhone.durationTime = 0; + }, +// 触碰阴影方法 + changeHookState() { + if (this.imageSelect.hook) { + this.imageSelect.src = '/common/images/fork.png'; + this.imageSelect.hook = false; + } else { + this.imageSelect.src = '/common/images/hook.png'; + this.imageSelect.hook = true; + } + }, +// 点击切换状态 + changeShadow(flag) { + if (flag) { + this.imageNormal.classType = 'main-img-touch'; + } else { + this.imageNormal.classType = 'main-img-unTouch'; + } + }, +// 点击动画效果方法 + handleStartFrameContainerPhone() { + this.frameContainerPhone.durationTime = 3600; + this.$refs.frameContainerPhone.start(); + }, +// 点击切换状态动效方法 + handleStartFrameContainerState() { + if (this.frameContainerState.flag) { + this.frameContainerState.frames = this.collapse; + this.frameContainerState.durationTime = this.durationTimeArray[0]; + this.$refs.frameContainerState.start(); + this.frameContainerState.flag = false; + this.$refs.frameContainerState.stop(); + } else { + this.frameContainerState.frames = this.back; + this.frameContainerState.durationTime = this.durationTimeArray[1]; + this.$refs.frameContainerState.start(); + this.frameContainerState.flag = true; + this.$refs.frameContainerState.stop(); + } + } +}; diff --git a/DialogDemo/entry/src/main/resources/base/element/string.json b/ClickableJsDemo/entry/src/main/resources/base/element/string.json similarity index 100% rename from DialogDemo/entry/src/main/resources/base/element/string.json rename to ClickableJsDemo/entry/src/main/resources/base/element/string.json diff --git a/AnimationDemo/entry/src/ohosTest/resources/base/media/icon.png b/ClickableJsDemo/entry/src/main/resources/base/media/icon.png similarity index 100% rename from AnimationDemo/entry/src/ohosTest/resources/base/media/icon.png rename to ClickableJsDemo/entry/src/main/resources/base/media/icon.png diff --git a/AudioDemo/gradle/wrapper/gradle-wrapper.jar b/ClickableJsDemo/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from AudioDemo/gradle/wrapper/gradle-wrapper.jar rename to ClickableJsDemo/gradle/wrapper/gradle-wrapper.jar diff --git a/AudioDemo/gradle/wrapper/gradle-wrapper.properties b/ClickableJsDemo/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from AudioDemo/gradle/wrapper/gradle-wrapper.properties rename to ClickableJsDemo/gradle/wrapper/gradle-wrapper.properties diff --git a/AudioDemo/settings.gradle b/ClickableJsDemo/settings.gradle similarity index 100% rename from AudioDemo/settings.gradle rename to ClickableJsDemo/settings.gradle diff --git a/ClockFACardDemo/LICENSE b/ClockFACardDemo/LICENSE deleted file mode 100644 index 0d157f823e33378716f6abc657afe78e9b147793..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - Copyright (c) 2021 Huawei Device Co., Ltd. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -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/ClockFACardDemo/README.md b/ClockFACardDemo/README.md deleted file mode 100644 index 333df7aa67004d47e2fea4dd2d2e80df8ae0a076..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# ClockFACardDemo -简介 -• 本codelab旨在使开发人员了解HarmonyOS中JAVA卡片的开发,包含卡片的创建、更新、删除功能,实现了时分秒,年月日,星期的实时刷新效果。 - -安装要求 -• 安装DevEco Studio -• 设置DevEco Studio开发环境。DevEco Studio开发环境需要连接到网络,以确保该正常使用。可以根据以下两种情况配置开发环境: - 1.如果您可以直接访问Internet,则只需下载HarmonyOS SDK - 2.如果网络无法直接访问Internet,则可以通过代理服务器进行访问 -• 生成密钥并申请证书 - -用户指南 -• 下载此项目 -• 打开HUAWEI DevEco Studio,单击File> Open选择此ClockFACardDemo -• 单击Build> Build App(s)/Hap(s)>Build Debug Hap(s)以编译hap软件包 -• 单击Run> Run 'entry'以运行hap包 - -注意 -• 您可以选择在模拟器或真机上运行hap软件包。 -• 如果在真机上运行它,则需要在项目的File> Project Structure> Modules> Signing Configs中配置签名和证书信息。 -• 由于目前暂无办法保证卡片服务不被系统销毁,需要通过手机管家> 应用启动管理> 时钟服务卡片> 点击右侧滑块> 选择开启“允许后台活动”开启后台运行权限,如需要也可开启“运行自启动”。 - -许可 -请参阅LICENSE文件以获得更多信息。 - -What is it? -This codelab is designed to enable developers to understand the development of Java cards in HarmonyOS, including the creation, update, and deletion of cards, and the real-time refresh effect of hour, second, year, month, day, and week. - -Installation requirements -• Install DevEco Studio -• Set up the DevEco Studio development environment.The DevEco Studio development environment needs to depend on the network environment. It needs to be connected to the network to ensure the normal use of the tool.The development environment can be configured according to the following two situations - 1.If you can directly access the Internet, just download the HarmonyOS SDK - 2.If the network cannot access the Internet directly, it can be accessed through a proxy server -• Generate secret key and apply for certificate - -User guide -• Download this Project -• Open HUAWEI DevEco Studio, click File> Open> Then select and open this Project -• Click Build> Build App(s)/Hap(s)>Build Debug Hap(s) to compile the hap package -• Click Run> Run 'entry' to run the hap package - -Note -• You can choose to run the hap package on the simulator or the phone. -• If you run it on the phone, you need to configure the signature and certificate information in the project's File> Project Structure> Modules> Signing Configs. -• Currently, there is no way to ensure that the card service will not be destroyed by the system. Go to Phone Manager > App Startup Management > Pedometer Service Card, touch the slider on the right, and select Enable Background Activities to enable the background running permission. You can also enable Auto Start if necessary. - -Licensing -Please see LICENSE for more info. - diff --git a/ClockFACardDemo/RELEASE-NOTES.md b/ClockFACardDemo/RELEASE-NOTES.md deleted file mode 100644 index ea23a13e3d4407d06cba3aa7155a23e5081b50b4..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/RELEASE-NOTES.md +++ /dev/null @@ -1,2 +0,0 @@ -1.0.0 -1.Initial version \ No newline at end of file diff --git a/ClockFACardDemo/build.gradle b/ClockFACardDemo/build.gradle deleted file mode 100644 index 859953eaf84cc3cff308056e618b42de0ed752e6..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -apply plugin: 'com.huawei.ohos.app' - -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 4 - } -} - -buildscript { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } - dependencies { - classpath 'com.huawei.ohos:hap:2.4.4.2' - classpath 'com.huawei.ohos:decctest:1.0.0.7' - } -} - -allprojects { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } -} diff --git a/ClockFACardDemo/entry/build.gradle b/ClockFACardDemo/entry/build.gradle deleted file mode 100644 index 90d8c89d8096320385b29451a9e804b30d7cf853..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/build.gradle +++ /dev/null @@ -1,23 +0,0 @@ -apply plugin: 'com.huawei.ohos.hap' -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 4 - } - buildTypes { - release { - proguardOpt { - proguardEnabled false - rulesFiles 'proguard-rules.pro' - } - } - } - compileOptions { annotationEnabled true } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - implementation 'android.arch.persistence.room:runtime:1.1.1' - testCompile 'junit:junit:4.12' -} - diff --git a/ClockFACardDemo/entry/src/main/config.json b/ClockFACardDemo/entry/src/main/config.json deleted file mode 100644 index 23571a7d77d248590f8a76c1337b89ba84da018c..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/config.json +++ /dev/null @@ -1,109 +0,0 @@ -{ - "app": { - "bundleName": "com.huawei.cookbook", - "vendor": "huawei", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": { - "default": { - "keepAlive": true - } - }, - "module": { - "package": "com.huawei.cookbooks", - "name": ".MyApplication", - "mainAbility": "com.huawei.cookbooks.MainAbility", - "deviceType": [ - "default" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": false - }, - "reqPermissions": [ - { - "name": "ohos.permission.KEEP_BACKGROUND_RUNNING", - "reason": "keep service ability backgroud running", - "usedScene": { - "ability": [ - ".TimerAbility" - ], - "when": "always" - } - } - ], - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "orientation": "unspecified", - "name": "com.huawei.cookbooks.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "singleton", - "formsEnabled": true, - "visible": true, - "forms": [ - { - "landscapeLayouts": [ - "$layout:form_image_with_info_date_card_2_2", - "$layout:form_image_with_info_date_card_2_4" - ], - "isDefault": true, - "scheduledUpdateTime": "11:30", - "defaultDimension": "2*2", - "name": "DateCard", - "description": "This is a service widget", - "colorMode": "auto", - "type": "Java", - "supportDimensions": [ - "2*2", - "2*4" - ], - "portraitLayouts": [ - "$layout:form_image_with_info_date_card_2_2", - "$layout:form_image_with_info_date_card_2_4" - ], - "updateEnabled": true, - "updateDuration": 1, - "formVisibleNotify": true, - "metaData": { - "customizeData": [ - { - "name": "needBlurBackgroundForLauncher", - "value": "true" - } - ] - } - } - ] - }, - { - "name": "com.huawei.cookbooks.TimerAbility", - "icon": "$media:icon", - "description": "$string:TimeAbility_description", - "type": "service", - "visible": true, - "backgroundModes": [ - "dataTransfer", - "location" - ] - } - ] - } -} \ No newline at end of file diff --git a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/MainAbility.java b/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/MainAbility.java deleted file mode 100644 index cdfa9f286a7b14510733e001281e20a478e70901..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/MainAbility.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbooks; - -import com.huawei.cookbooks.database.Form; -import com.huawei.cookbooks.database.FormDatabase; -import com.huawei.cookbooks.slice.ClockCardSlice; -import com.huawei.cookbooks.utils.ComponentProviderUtils; -import com.huawei.cookbooks.utils.DatabaseUtils; - -import ohos.aafwk.ability.Ability; -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.ability.ProviderFormInfo; -import ohos.aafwk.content.Intent; -import ohos.aafwk.content.Operation; -import ohos.agp.components.ComponentProvider; -import ohos.data.DatabaseHelper; -import ohos.data.orm.OrmContext; -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; - -/** - * Card Main Ability - */ -public class MainAbility extends Ability { - private static final HiLogLabel LABEL_LOG = new HiLogLabel(0, 0, "com.huawei.cookbooks.MainAbility"); - private static final int DEFAULT_DIMENSION_2X2 = 2; - private static final int DEFAULT_DIMENSION_2X4 = 3; - private static final String EMPTY_STRING = ""; - private static final int INVALID_FORM_ID = -1; - private long formId; - private ProviderFormInfo formInfo; - private DatabaseHelper helper = new DatabaseHelper(this); - private OrmContext connect; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - connect = helper.getOrmContext("FormDatabase", "FormDatabase.db", FormDatabase.class); - // 启动TimerAbility - Intent intentService = new Intent(); - Operation operation = - new Intent.OperationBuilder() - .withDeviceId("") - .withBundleName(getBundleName()) - .withAbilityName(TimerAbility.class.getName()) - .build(); - intentService.setOperation(operation); - startAbility(intentService); - super.setMainRoute(ClockCardSlice.class.getName()); - } - - @Override - protected ProviderFormInfo onCreateForm(Intent intent) { - if (intent == null) { - return new ProviderFormInfo(); - } - // 获取卡片id - formId = INVALID_FORM_ID; - if (intent.hasParameter(AbilitySlice.PARAM_FORM_IDENTITY_KEY)) { - formId = intent.getLongParam(AbilitySlice.PARAM_FORM_IDENTITY_KEY, INVALID_FORM_ID); - } else { - return new ProviderFormInfo(); - } - // 获取卡片名称 - String formName = EMPTY_STRING; - if (intent.hasParameter(AbilitySlice.PARAM_FORM_NAME_KEY)) { - formName = intent.getStringParam(AbilitySlice.PARAM_FORM_NAME_KEY); - } - // 获取卡片规格 - int dimension = DEFAULT_DIMENSION_2X2; - if (intent.hasParameter(AbilitySlice.PARAM_FORM_DIMENSION_KEY)) { - dimension = intent.getIntParam(AbilitySlice.PARAM_FORM_DIMENSION_KEY, DEFAULT_DIMENSION_2X2); - } - int layoutId = ResourceTable.Layout_form_image_with_info_date_card_2_2; - if (dimension == DEFAULT_DIMENSION_2X4) { - layoutId = ResourceTable.Layout_form_image_with_info_date_card_2_4; - } - formInfo = new ProviderFormInfo(layoutId, this); - // 存储卡片信息 - Form form = new Form(formId, formName, dimension); - ComponentProvider componentProvider = ComponentProviderUtils.getComponentProvider(form, this); - formInfo.mergeActions(componentProvider); - if (connect == null) { - connect = - helper.getOrmContext("FormDatabase", "FormDatabase.db", FormDatabase.class); - } - try { - DatabaseUtils.insertForm(form, connect); - } catch (Exception e) { - DatabaseUtils.deleteFormData(form.getFormId(), connect); - } - return formInfo; - } - - @Override - protected void onDeleteForm(long formId) { - super.onDeleteForm(formId); - // 删除数据库中的卡片信息 - DatabaseUtils.deleteFormData(formId, connect); - } -} diff --git a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/MyApplication.java b/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/MyApplication.java deleted file mode 100644 index f85d694ae60537b43c057d0bbd14690f95a6c228..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/MyApplication.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbooks; - -import ohos.aafwk.ability.AbilityPackage; - -/** - * MyApplication - */ -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/TimerAbility.java b/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/TimerAbility.java deleted file mode 100644 index 662c82c95a9a483926496d8d5e4c43377bc13ea1..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/TimerAbility.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbooks; - -import com.huawei.cookbooks.database.Form; -import com.huawei.cookbooks.database.FormDatabase; -import com.huawei.cookbooks.utils.ComponentProviderUtils; -import com.huawei.cookbooks.utils.DatabaseUtils; - -import com.huawei.cookbooks.utils.DateUtils; -import ohos.aafwk.ability.Ability; -import ohos.aafwk.ability.FormException; -import ohos.aafwk.content.Intent; -import ohos.agp.components.ComponentProvider; -import ohos.data.DatabaseHelper; -import ohos.data.orm.OrmContext; -import ohos.data.orm.OrmPredicates; -import ohos.event.notification.NotificationRequest; -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; -import ohos.rpc.IRemoteObject; - -import java.util.List; -import java.util.Timer; -import java.util.TimerTask; - -/** - * Time PA - */ -public class TimerAbility extends Ability { - private static final HiLogLabel LABEL_LOG = new HiLogLabel(3, 0xD001100, "Demo"); - private static final long SEND_PERIOD = 1000L; - private static final int NOTICE_ID = 1005; - private DatabaseHelper helper = new DatabaseHelper(this); - private OrmContext connect; - - @Override - public void onStart(Intent intent) { - HiLog.info(LABEL_LOG, "TimerAbility::onStart"); - connect = helper.getOrmContext("FormDatabase", "FormDatabase.db", FormDatabase.class); - startTimer(); - super.onStart(intent); - - } - private void notice() { - // 创建通知 - NotificationRequest request = new NotificationRequest(NOTICE_ID); - request.setAlertOneTime(true); - NotificationRequest.NotificationNormalContent content = new NotificationRequest.NotificationNormalContent(); - content.setText(DateUtils.getCurrentDate("yyyy-MM-dd HH:mm:ss")); - NotificationRequest.NotificationContent notificationContent = new NotificationRequest.NotificationContent(content); - request.setContent(notificationContent); - // 绑定通知 - keepBackgroundRunning(NOTICE_ID, request); - } - // 卡片更新定时器,每秒更新一次 - private void startTimer() { - Timer timer = new Timer(); - timer.schedule( - new TimerTask() { - @Override - public void run() { - updateForms(); - notice(); - } - }, - 0, - SEND_PERIOD); - } - - private void updateForms() { - // 从数据库中获取卡片信息 - OrmPredicates ormPredicates = new OrmPredicates(Form.class); - List
formList = connect.query(ormPredicates); - // 更新时分秒 - if (formList.size() <= 0) { - return; - } - for (Form form : formList) { - // 遍历卡片列表更新卡片 - ComponentProvider componentProvider = ComponentProviderUtils.getComponentProvider(form, this); - try { - Long updateFormId = form.getFormId(); - updateForm(updateFormId, componentProvider); - } catch (FormException e) { - // 删除不存在的卡片 - DatabaseUtils.deleteFormData(form.getFormId(), connect); - HiLog.error(LABEL_LOG, "onUpdateForm updateForm error"); - } - } - } - - @Override - public void onBackground() { - super.onBackground(); - HiLog.info(LABEL_LOG, "TimerAbility::onBackground"); - } - - @Override - public void onStop() { - super.onStop(); - HiLog.info(LABEL_LOG, "TimerAbility::onStop"); - } -} diff --git a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/database/Form.java b/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/database/Form.java deleted file mode 100644 index 64c77fb6355ee6dbe4e8dc5eb5c7ec830e9707de..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/database/Form.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbooks.database; - -import ohos.data.orm.OrmObject; -import ohos.data.orm.annotation.Entity; -import ohos.data.orm.annotation.PrimaryKey; - -/** - * Card Table - */ -@Entity(tableName = "form") -public class Form extends OrmObject { - @PrimaryKey() - private Long formId; - private String formName; - private Integer dimension; - - public Form(Long formId, String formName, Integer dimension) { - this.formId = formId; - this.formName = formName; - this.dimension = dimension; - } - - public Form() { } - - public Integer getDimension() { - return dimension; - } - - public void setDimension(Integer dimension) { - this.dimension = dimension; - } - - public Long getFormId() { - return formId; - } - - public void setFormId(Long formId) { - this.formId = formId; - } - - public String getFormName() { - return formName; - } - - public void setFormName(String formName) { - this.formName = formName; - } -} diff --git a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/database/FormDatabase.java b/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/database/FormDatabase.java deleted file mode 100644 index b69fc36bb032861467031fb052681ef9f7788a7b..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/database/FormDatabase.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbooks.database; - -import ohos.data.orm.OrmDatabase; -import ohos.data.orm.annotation.Database; - -/** - * Card Database - */ -@Database( - entities = {Form.class}, - version = 1) -public abstract class FormDatabase extends OrmDatabase { } diff --git a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/slice/ClockCardSlice.java b/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/slice/ClockCardSlice.java deleted file mode 100644 index 26a1d8d91d64f1681c0dc05c965e2b3c729c0788..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/slice/ClockCardSlice.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbooks.slice; - -import com.huawei.cookbooks.ResourceTable; -import com.huawei.cookbooks.utils.ComponentProviderUtils; -import com.huawei.cookbooks.utils.DateUtils; -import com.huawei.cookbooks.utils.LogUtils; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.agp.components.Component; -import ohos.agp.components.Text; -import ohos.agp.utils.Color; -import ohos.eventhandler.EventHandler; -import ohos.eventhandler.EventRunner; -import ohos.eventhandler.InnerEvent; -import ohos.hiviewdfx.HiLogLabel; - -import java.util.Calendar; -import java.util.Timer; -import java.util.TimerTask; - -/** - * Clock Card Slice - */ -public class ClockCardSlice extends AbilitySlice { - private static final HiLogLabel LABEL_LOG = new HiLogLabel(0, 0, ClockCardSlice.class.getName()); - private static final long SEND_PERIOD = 1000L; - private static final int COLOR_RGB = 192; - private static final int TIME_LENGTH = 2; - private Text dateText; - private Text hourText; - private Text minText; - private Text secondText; - private EventRunner runner; - private MyEventHandle myEventHandle; - private AbilitySlice slice = this; - private Timer timer; - private Runnable runnable = new Runnable() { - private void initHandler() { - runner = EventRunner.getMainEventRunner(); - if (runner == null) { - return; - } - myEventHandle = new MyEventHandle(runner); - } - - @Override - public void run() { - // 初始化认证对象 - initHandler(); - } - }; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setUIContent(ResourceTable.Layout_form_image_with_info_date_card_2_2); - initComponent(); - startTimer(); - } - - private void startTimer() { - timer = new Timer(); - timer.schedule( - new TimerTask() { - @Override - public void run() { - runnable.run(); - myEventHandle.sendEvent(1); - } - }, - 0, - SEND_PERIOD); - } - - /** - * Init Component - */ - private void initComponent() { - Calendar now = Calendar.getInstance(); - Component dateComponent = slice.findComponentById(ResourceTable.Id_date); - if (dateComponent != null && dateComponent instanceof Text) { - dateText = (Text) dateComponent; - dateText.setText(DateUtils.getCurrentDate("yyyy-MM-dd")); - } - Component hourComponent = slice.findComponentById(ResourceTable.Id_hour); - if (hourComponent != null && hourComponent instanceof Text) { - hourText = (Text) hourComponent; - int hour = now.get(Calendar.HOUR_OF_DAY); - setTextValue(hour, hourText); - } - Component minComponent = findComponentById(ResourceTable.Id_min); - if (minComponent != null && minComponent instanceof Text) { - minText = (Text) minComponent; - int min = now.get(Calendar.MINUTE); - setTextValue(min, minText); - } - Component secComponent = findComponentById(ResourceTable.Id_sec); - if (secComponent != null && secComponent instanceof Text) { - secondText = (Text) secComponent; - int second = now.get(Calendar.SECOND); - setTextValue(second, secondText); - } - int weekId = ComponentProviderUtils.getWeekDayId(); - Component weekComponent = slice.findComponentById(weekId); - if (weekComponent != null && weekComponent instanceof Text) { - Text week = (Text) weekComponent; - week.setTextColor(new Color(Color.rgb(0, 0, 0))); - } - int lastWeekDayId = ComponentProviderUtils.getLastWeekDayId(); - Component lastWeekComponent = slice.findComponentById(lastWeekDayId); - if (weekComponent != null && lastWeekComponent instanceof Text) { - Text lastWeek = (Text) lastWeekComponent; - lastWeek.setTextColor(new Color(Color.rgb(COLOR_RGB, COLOR_RGB, COLOR_RGB))); - } - } - - private void setTextValue(int now, Text text) { - if (String.valueOf(now).length() < TIME_LENGTH) { - text.setText("0" + now); - } else { - text.setText(now + ""); - } - } - - @Override - public void onActive() { - super.onActive(); - } - - @Override - public void onForeground(Intent intent) { - super.onForeground(intent); - } - - private class MyEventHandle extends EventHandler { - MyEventHandle(EventRunner runner) throws IllegalArgumentException { - super(runner); - } - - @Override - protected void processEvent(InnerEvent event) { - super.processEvent(event); - int eventId = event.eventId; - if (eventId == 1) { - // 更新页面 - initComponent(); - } - } - } - - @Override - protected void onStop() { - LogUtils.info("onStop", " start to destroy slice"); - timer.cancel(); - } -} diff --git a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/utils/ComponentProviderUtils.java b/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/utils/ComponentProviderUtils.java deleted file mode 100644 index 3ae843ac0aa37b9f01aff9d445fcaf480c600122..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/utils/ComponentProviderUtils.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbooks.utils; - -import com.huawei.cookbooks.ResourceTable; -import com.huawei.cookbooks.database.Form; - -import ohos.agp.components.ComponentProvider; -import ohos.agp.utils.Color; -import ohos.app.Context; - -import java.util.Calendar; - -/** - * Component ProviderUtils - */ -public class ComponentProviderUtils { - // 当前星期颜色 - private static Color nowWeekColor = new Color(Color.rgb(255, 245, 238)); - - // 原色星期 - private static Color primaryWeekColor = new Color(Color.rgb(192, 192, 192)); - - private static final int WEEK_DAYS = 7; - private static final int STRING_LENGTH = 2; - private static final int DIM_VERSION = 3; - private static final int SUNDAY = 1; - private static final int MONDAY = 2; - private static final int TUESDAY = 3; - private static final int WEDNESDAY = 4; - private static final int THURSDAY = 5; - private static final int FRIDAY = 6; - private static final int SATURDAY = 7; - - /** - * Obtain the day of the week - * - * @return week - */ - public static int getWeekDayId() { - Calendar calendar = Calendar.getInstance(); - int week = calendar.get(Calendar.DAY_OF_WEEK); - int result = getWeekIdResult(week); - return result; - } - - /** - * get week component id - * - * @param week week - * @return component id - */ - private static int getWeekIdResult(int week) { - int result = ResourceTable.Id_mon; - switch (week) { - case SUNDAY: - result = ResourceTable.Id_sun; - break; - case MONDAY: - result = ResourceTable.Id_mon; - break; - case TUESDAY: - result = ResourceTable.Id_tue; - break; - case WEDNESDAY: - result = ResourceTable.Id_wed; - break; - case THURSDAY: - result = ResourceTable.Id_thu; - break; - case FRIDAY: - result = ResourceTable.Id_fri; - break; - case SATURDAY: - result = ResourceTable.Id_sat; - break; - default: - result = ResourceTable.Id_sun; - break; - } - return result; - } - - /** - * Obtains the ComponentProvider object - * - * @param form form info - * @param context context - * @return component provider - */ - public static ComponentProvider getComponentProvider(Form form, Context context) { - int layoutId = ResourceTable.Layout_form_image_with_info_date_card_2_2; - if (form.getDimension() == DIM_VERSION) { - layoutId = ResourceTable.Layout_form_image_with_info_date_card_2_4; - } - ComponentProvider componentProvider = new ComponentProvider(layoutId, context); - setComponentProviderValue(componentProvider); - return componentProvider; - } - - /** - * Time converted to string - * - * @param time time - * @return time string - */ - private static String int2String(int time) { - String timeString; - if (String.valueOf(time).length() < STRING_LENGTH) { - timeString = "0" + time; - } else { - timeString = time + ""; - } - return timeString; - } - - /** - * Set the value of componentProvider - * - * @param componentProvider component provider - */ - private static void setComponentProviderValue(ComponentProvider componentProvider) { - Calendar now = Calendar.getInstance(); - int hour = now.get(Calendar.HOUR_OF_DAY); - int min = now.get(Calendar.MINUTE); - int second = now.get(Calendar.SECOND); - String hourString = int2String(hour); - String minString = int2String(min); - String secondString = int2String(second); - componentProvider.setText(ResourceTable.Id_date, DateUtils.getCurrentDate("yyyy-MM-dd")); - componentProvider.setText(ResourceTable.Id_hour, hourString); - componentProvider.setText(ResourceTable.Id_min, minString); - componentProvider.setText(ResourceTable.Id_sec, secondString); - - // 获取当前星期 - int weekDayId = getWeekDayId(); - componentProvider.setTextColor(weekDayId, nowWeekColor); - - // 将前一天的星期改回原色 - int lastWeekId = getLastWeekDayId(); - componentProvider.setTextColor(lastWeekId, primaryWeekColor); - } - - /** - * obtain previous day of the week - * - * @return previous day of the week - */ - public static int getLastWeekDayId() { - Calendar calendar = Calendar.getInstance(); - int week = calendar.get(Calendar.DAY_OF_WEEK); - int lastWeek; - if (week == 1) { - lastWeek = WEEK_DAYS; - } else { - lastWeek = week - 1; - } - return getWeekIdResult(lastWeek); - } -} diff --git a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/utils/DatabaseUtils.java b/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/utils/DatabaseUtils.java deleted file mode 100644 index 1c1d5238b74fac54d300d29b657b25b2261d6973..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/utils/DatabaseUtils.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbooks.utils; - -import com.huawei.cookbooks.database.Form; - -import ohos.data.orm.OrmContext; -import ohos.data.orm.OrmPredicates; - -import java.util.List; - -/** - * Card Database Operations - */ -public class DatabaseUtils { - /** - * delete data - * - * @param formId form id - * @param connect data connection - */ - public static void deleteFormData(long formId, OrmContext connect) { - OrmPredicates where = connect.where(Form.class); - where.equalTo("formId", formId); - List query = connect.query(where); - if (!query.isEmpty()) { - connect.delete(query.get(0)); - connect.flush(); - } - } - - /** - * add card info - * - * @param form card object - * @param connect data connection - */ - public static void insertForm(Form form, OrmContext connect) { - connect.insert(form); - connect.flush(); - } -} diff --git a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/utils/DateUtils.java b/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/utils/DateUtils.java deleted file mode 100644 index b333f12fc4edd8d6ba932d618841d3d5e65cf08d..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/utils/DateUtils.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbooks.utils; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * Date time util - */ -public class DateUtils { - /** - * current time - * - * @param format format - * @return corresponding format string - */ - public static String getCurrentDate(String format) { - DateFormat dateFormat = new SimpleDateFormat(format); - Date date = new Date(); - String formatDate = dateFormat.format(date); - return formatDate; - } -} diff --git a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/utils/LogUtils.java b/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/utils/LogUtils.java deleted file mode 100644 index baaea54df5ecde61a3fa998d43942c4d67eb236f..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/java/com/huawei/cookbooks/utils/LogUtils.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbooks.utils; - -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; - -/** - * LogUtils - */ -public class LogUtils { - private static final String TAG_LOG = "LogUtil"; - - private static final HiLogLabel LABEL_LOG = new HiLogLabel(0, 0, LogUtils.TAG_LOG); - - private static final String LOG_FORMAT = "%{public}s: %{public}s"; - - private LogUtils() { } - - /** - * Print debug log - * - * @param tag log tag - * @param msg log message - */ - public static void debug(String tag, String msg) { - HiLog.debug(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print info log - * - * @param tag log tag - * @param msg log message - */ - public static void info(String tag, String msg) { - HiLog.info(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print warn log - * - * @param tag log tag - * @param msg log message - */ - public static void warn(String tag, String msg) { - HiLog.warn(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print error log - * - * @param tag log tag - * @param msg log message - */ - public static void error(String tag, String msg) { - HiLog.error(LABEL_LOG, LOG_FORMAT, tag, msg); - } -} diff --git a/ClockFACardDemo/entry/src/main/resources/base/element/string.json b/ClockFACardDemo/entry/src/main/resources/base/element/string.json deleted file mode 100644 index cbe21bace5ea1cb0f8d6b52e7fbd93b0457b459c..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "时钟服务卡片" - }, - { - "name": "mainability_description", - "value": "Java_Phone_Empty Feature Ability" - }, - { - "name": "HelloWorld", - "value": "Hello World" - }, - { - "name": "TimeAbility_description", - "value": "hap sample empty service" - } - ] -} \ No newline at end of file diff --git a/ClockFACardDemo/entry/src/main/resources/base/graphic/background_ability_main.xml b/ClockFACardDemo/entry/src/main/resources/base/graphic/background_ability_main.xml deleted file mode 100644 index c0c0a3df480fa387a452b9c40ca191cc918a3fc0..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/resources/base/graphic/background_ability_main.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/ClockFACardDemo/entry/src/main/resources/base/layout/ability_main.xml b/ClockFACardDemo/entry/src/main/resources/base/layout/ability_main.xml deleted file mode 100644 index adab58cdd70238cd3f4f9a6a8fbe81755a036172..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/resources/base/layout/ability_main.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - \ No newline at end of file diff --git a/ClockFACardDemo/entry/src/main/resources/base/layout/form_image_with_info_date_card_2_2.xml b/ClockFACardDemo/entry/src/main/resources/base/layout/form_image_with_info_date_card_2_2.xml deleted file mode 100644 index 679a3a2d074ccd866e824e7d3d70a90964faab14..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/resources/base/layout/form_image_with_info_date_card_2_2.xml +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ClockFACardDemo/entry/src/main/resources/base/layout/form_image_with_info_date_card_2_4.xml b/ClockFACardDemo/entry/src/main/resources/base/layout/form_image_with_info_date_card_2_4.xml deleted file mode 100644 index c97b3f31e87863f9a65b70ae2524fbe8e7bba17c..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/main/resources/base/layout/form_image_with_info_date_card_2_4.xml +++ /dev/null @@ -1,216 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ClockFACardDemo/entry/src/main/resources/base/media/form_image_with_info_datecard_default_image_2.png b/ClockFACardDemo/entry/src/main/resources/base/media/form_image_with_info_datecard_default_image_2.png deleted file mode 100644 index 64d3f425041c3dc993e82b45f1f5e7c56804db70..0000000000000000000000000000000000000000 Binary files a/ClockFACardDemo/entry/src/main/resources/base/media/form_image_with_info_datecard_default_image_2.png and /dev/null differ diff --git a/ClockFACardDemo/entry/src/main/resources/base/media/form_image_with_info_form_card_default_image_2.png b/ClockFACardDemo/entry/src/main/resources/base/media/form_image_with_info_form_card_default_image_2.png deleted file mode 100644 index 64d3f425041c3dc993e82b45f1f5e7c56804db70..0000000000000000000000000000000000000000 Binary files a/ClockFACardDemo/entry/src/main/resources/base/media/form_image_with_info_form_card_default_image_2.png and /dev/null differ diff --git a/ClockFACardDemo/entry/src/ohosTest/config.json b/ClockFACardDemo/entry/src/ohosTest/config.json deleted file mode 100644 index a5df38c4a0039b030393cea561c6568fc0866430..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/ohosTest/config.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "app": { - "bundleName": "com.huawei.cookbooks", - "vendor": "huawei", - "version": { - "code": 1, - "name": "1.0" - }, - "apiVersion": { - "compatible": 4, - "target": 5 - } - }, - "deviceConfig": {}, - "module": { - "package": "com.huawei.cookbooks", - "name": "testModule", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry_test", - "moduleType": "feature" - }, - "abilities": [ - { - "name": "decc.testkit.runner.EntryAbility", - "description": "Test Entry Ability", - "icon": "$media:icon", - "label": "TestAbility", - "launchType": "standard", - "orientation": "landscape", - "visible": true, - "type": "page" - } - ] - } -} \ No newline at end of file diff --git a/ClockFACardDemo/entry/src/ohosTest/java/com/huawei/cookbooks/ExampleOhosTest.java b/ClockFACardDemo/entry/src/ohosTest/java/com/huawei/cookbooks/ExampleOhosTest.java deleted file mode 100644 index b88edd22bdf50501a3c190d1a2edb809141d8646..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/ohosTest/java/com/huawei/cookbooks/ExampleOhosTest.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.huawei.cookbooks; - -import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry; - - -public class ExampleOhosTest { - @Test - public void testBundleName() { - final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName(); - assertEquals("com.huawei.clockcard", actualBundleName); - } -} \ No newline at end of file diff --git a/ClockFACardDemo/entry/src/test/java/com/huawei/cookbooks/ExampleTest.java b/ClockFACardDemo/entry/src/test/java/com/huawei/cookbooks/ExampleTest.java deleted file mode 100644 index 790846344f6fdfb7eb978df65a7712f030cf2056..0000000000000000000000000000000000000000 --- a/ClockFACardDemo/entry/src/test/java/com/huawei/cookbooks/ExampleTest.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.huawei.cookbooks; - -import org.junit.Test; - -public class ExampleTest { - @Test - public void onStart() { - } -} diff --git a/CodecDemo/LICENSE b/CodecDemo/LICENSE deleted file mode 100644 index b36a10d589119cb8557ff572ca3f5b0aab970604..0000000000000000000000000000000000000000 --- a/CodecDemo/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - Copyright (c) 2021 Huawei Device Co., Ltd. - - Licensed under the Apache License,Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -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 diff --git a/CodecDemo/README.md b/CodecDemo/README.md deleted file mode 100644 index c59d208a48baf058f9cb0a3c00efca645f8fec19..0000000000000000000000000000000000000000 --- a/CodecDemo/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# CodecDemo -简介 -• 此Demo用于捕获预览帧,转换为视频原始数据并使用HamonyOS视频解码能力播放预览画面。 - -安装要求 -• 安装DevEco Studio -• 设置DevEco Studio开发环境。DevEco Studio开发环境需要连接到网络,以确保该正常使用。可以根据以下两种情况配置开发环境: - 1.如果您可以直接访问Internet,则只需下载HarmonyOS SDK - 2.如果网络无法直接访问Internet,则可以通过代理服务器进行访问 -• 生成密钥并申请证书 - -用户指南 -• 下载此项目 -• 打开HUAWEI DevEco Studio,单击File> Open选择此项目 -• 单击Build> Build App(s)/Hap(s)>Build Debug Hap(s)以编译hap软件包 -• 单击Run> Run 'entry'以运行hap包 - -注意 -• 您可以选择在模拟器或真机上运行hap软件包。 -• 如果在真机上运行它,则需要在项目的File> Project Structure> Modules> Signing Configs中配置签名和证书信息。 - -许可 -请参阅LICENSE文件以获得更多信息。 - -What is it? -This demo is used to capture preview frames, convert them into raw video data, and play preview images using HarmonyOS video decoding capabilities. - -Installation requirements -• Install DevEco Studio -• Set up the DevEco Studio development environment.The DevEco Studio development environment needs to depend on the network environment. It needs to be connected to the network to ensure the normal use of the tool.The development environment can be configured according to the following two situations - 1.If you can directly access the Internet, just download the HarmonyOS SDK - 2.If the network cannot access the Internet directly, it can be accessed through a proxy server -• Generate secret key and apply for certificate - -User guide -• Download this Project -• Open HUAWEI DevEco Studio, click File> Open> Then select and open this Project -• Click Build> Build App(s)/Hap(s)>Build Debug Hap(s) to compile the hap package -• Click Run> Run 'entry' to run the hap package - -Note -• You can choose to run the hap package on the simulator or the phone. -• If you run it on the phone, you need to configure the signature and certificate information in the project's File> Project Structure> Modules> Signing Configs. - -Licensing -Please see LICENSE for more info. \ No newline at end of file diff --git a/CodecDemo/RELEASE-NOTES.md b/CodecDemo/RELEASE-NOTES.md deleted file mode 100644 index ea23a13e3d4407d06cba3aa7155a23e5081b50b4..0000000000000000000000000000000000000000 --- a/CodecDemo/RELEASE-NOTES.md +++ /dev/null @@ -1,2 +0,0 @@ -1.0.0 -1.Initial version \ No newline at end of file diff --git a/CodecDemo/build.gradle b/CodecDemo/build.gradle deleted file mode 100644 index 29a385a0c420a6de41ee2f12ce07158a8533cd9c..0000000000000000000000000000000000000000 --- a/CodecDemo/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -apply plugin: 'com.huawei.ohos.app' - -ohos { - compileSdkVersion 4 - defaultConfig { - compatibleSdkVersion 4 - } -} - -buildscript { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } - dependencies { - classpath 'com.huawei.ohos:hap:2.4.4.2' - classpath 'com.huawei.ohos:decctest:1.0.0.7' - } -} - -allprojects { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } -} diff --git a/CodecDemo/entry/build.gradle b/CodecDemo/entry/build.gradle deleted file mode 100644 index 26f565f9e4753da52f3596bb203ebf7aa59e3d5a..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/build.gradle +++ /dev/null @@ -1,17 +0,0 @@ -apply plugin: 'com.huawei.ohos.hap' -apply plugin: 'com.huawei.ohos.decctest' -ohos { - compileSdkVersion 4 - defaultConfig { - compatibleSdkVersion 4 - } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - testImplementation 'junit:junit:4.13' - ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' -} -decc { - supportType = ['html','xml'] -} diff --git a/CodecDemo/entry/src/main/config.json b/CodecDemo/entry/src/main/config.json deleted file mode 100644 index 38898819056f909e6c11b48e8ca56de1b49c90da..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/config.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "app": { - "bundleName": "com.huawei.cookbook", - "vendor": "huawei", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.huawei.codecdemo", - "name": ".MyApplication", - "deviceType": [ - "default" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": false - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "orientation": "unspecified", - "name": ".MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "formsEnabled": true, - "type": "page", - "launchType": "standard" - }, - { - "orientation": "portrait", - "name": ".CodecAbility", - "icon": "$media:icon", - "description": "$string:codecability_description", - "label": "$string:app_entry", - "formsEnabled": true, - "type": "page", - "launchType": "standard" - } - ], - "reqPermissions": [ - { - "name": "ohos.permission.CAMERA" - }, - { - "name": "ohos.permission.MICROPHONE" - } - ] - } -} \ No newline at end of file diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/CodecAbility.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/CodecAbility.java deleted file mode 100644 index 2a38b0b7295948b55cc5c6eee7f8f2c094df5b2e..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/CodecAbility.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo; - -import com.huawei.codecdemo.slice.CodecAbilitySlice; - -import ohos.aafwk.ability.Ability; -import ohos.aafwk.content.Intent; -import ohos.agp.window.service.WindowManager; - -/** - * CodecAbility - * - * @since 2021-04-09 - */ -public class CodecAbility extends Ability { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setMainRoute(CodecAbilitySlice.class.getName()); - WindowManager.getInstance().getTopWindow().get().setTransparent(true); - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/MainAbility.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/MainAbility.java deleted file mode 100644 index 0d3cb5bd2de5a5aa3aa07fb7a082aa10acfbe9d3..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/MainAbility.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo; - -import static ohos.bundle.IBundleManager.PERMISSION_GRANTED; - -import com.huawei.codecdemo.slice.MainAbilitySlice; -import com.huawei.codecdemo.utils.LogUtil; - -import ohos.aafwk.ability.Ability; -import ohos.aafwk.content.Intent; -import ohos.security.SystemPermission; - -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -/** - * MainAbility - * - * @since 2021-04-09 - */ -public class MainAbility extends Ability { - private static final String TAG = MainAbilitySlice.class.getSimpleName(); - private static final int PERMISSION_REQUEST_CODE = 1; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setMainRoute(MainAbilitySlice.class.getName()); - requestCameraPermission(); - } - - private void requestCameraPermission() { - List permissions = - new LinkedList<>(Arrays.asList(SystemPermission.CAMERA, SystemPermission.MICROPHONE)); - permissions.removeIf(permission -> - verifySelfPermission(permission) == PERMISSION_GRANTED || !canRequestPermission(permission)); - if (!permissions.isEmpty()) { - requestPermissionsFromUser(permissions.toArray(new String[0]), PERMISSION_REQUEST_CODE); - } - } - - @Override - public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions, int[] grantResults) { - if (requestCode != PERMISSION_REQUEST_CODE) { - return; - } - for (int grantResult : grantResults) { - if (grantResult != PERMISSION_GRANTED) { - LogUtil.info(TAG, grantResult + " is denied , Some functions may be affected."); - } - } - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/MyApplication.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/MyApplication.java deleted file mode 100644 index ffe392676a69af85bab766cf25e25f5635bc7819..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/MyApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo; - -import ohos.aafwk.ability.AbilityPackage; - -/** - * MyApplication - * - * @since 2021-04-09 - */ -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/CameraController.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/CameraController.java deleted file mode 100644 index 226e9b6a630604f6c17dee865599d973a4419cdf..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/CameraController.java +++ /dev/null @@ -1,469 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.camera; - -import com.huawei.codecdemo.camera.api.CameraListener; -import com.huawei.codecdemo.camera.api.CameraStateListener; -import com.huawei.codecdemo.camera.constant.CameraConst; -import com.huawei.codecdemo.camera.constant.CameraType; -import com.huawei.codecdemo.camera.constant.CaptureMode; -import com.huawei.codecdemo.camera.utils.Nv21Handler; -import com.huawei.codecdemo.media.VideoRecorder; -import com.huawei.codecdemo.media.constant.MediaStatu; -import com.huawei.codecdemo.utils.LogUtil; - -import ohos.agp.components.surfaceprovider.SurfaceProvider; -import ohos.agp.graphics.Surface; -import ohos.agp.graphics.SurfaceOps; -import ohos.app.Context; -import ohos.app.Environment; -import ohos.eventhandler.EventHandler; -import ohos.eventhandler.EventRunner; -import ohos.media.camera.CameraKit; -import ohos.media.camera.device.Camera; -import ohos.media.camera.device.CameraAbility; -import ohos.media.camera.device.CameraConfig; -import ohos.media.camera.device.CameraStateCallback; -import ohos.media.camera.device.FrameConfig; -import ohos.media.camera.params.ParameterKey; -import ohos.media.image.Image; -import ohos.media.image.ImageReceiver; -import ohos.media.image.common.ImageFormat; -import ohos.media.image.common.Size; - -import java.io.File; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.UUID; - -/** - * CameraController - * - * @since 2021-04-09 - */ -public class CameraController implements CameraListener { - private static final String TAG = CameraController.class.getName(); - private static final int NUMBER_INT_2 = 2; - private static final int NUMBER_INT_3 = 3; - private static final int NUMBER_INT_5 = 5; - private static final int NUMBER_INT_10 = 10; - private static final int NUMBER_INT_90 = 90; - private static final int NUMBER_INT_270 = 270; - private Context context; - private CameraAbility cameraSupportor; - private Camera cameraDevice; - private CameraConfig.Builder cameraConfigBuilder; - private FrameConfig.Builder frameConfigBuilder; - private ImageReceiver imageReceiver; - private EventHandler eventHandler; - - private boolean isCameraCreated; - private boolean isPrepared; - private boolean isCapturing; - private boolean isMirror; - private Surface recorderSurface; - private Surface previewSurface; - private int cameraType; - private int previewWidth; - private int previewHeight; - private int resoluteX; - private int resoluteY; - - private CaptureMode captureMode = CaptureMode.SINGLE_SHOT; - private VideoRecorder videoRecorder; - private CameraStateListener cameraCallback; - - /** - * CameraListenerController - * - * @param context context - * @param isFrontCamera isFrontCamera - */ - public CameraController(Context context, boolean isFrontCamera) { - this.context = context; - this.cameraType = isFrontCamera ? CameraType.FRONT.getType() : CameraType.BACK.getType(); - eventHandler = new EventHandler(EventRunner.current()); - } - - @Override - public void bind(SurfaceProvider surfaceProvider) { - if (surfaceProvider.getSurfaceOps().isPresent()) { - this.previewSurface = surfaceProvider.getSurfaceOps().get().getSurface(); - this.previewWidth = surfaceProvider.getWidth(); - this.previewHeight = surfaceProvider.getHeight(); - context.getUITaskDispatcher().asyncDispatch(this::cameraInit); - } - } - - private void cameraInit() { - isPrepared = false; - CameraKit camerakit = CameraKit.getInstance(context.getApplicationContext()); - if (camerakit != null && camerakit.getCameraIds().length > cameraType) { - String cameraId = camerakit.getCameraIds()[cameraType]; - cameraSupportor = camerakit.getCameraAbility(cameraId); - CameraStateCallback cameraStateCallback = new MyCameraStatuCallback(); - camerakit.createCamera(cameraId, cameraStateCallback, eventHandler); - captureInit(); - } - } - - private void captureInit() { - setResolution(); - int imageFormat = ImageFormat.JPEG; - switch (captureMode) { - case PUSH_FLOW: - imageFormat = ImageFormat.YUV420_888; - break; - case VIDEO_RECORD: - recorderInit(); - break; - default: - break; - } - receiverInit(imageFormat); - } - - private void receiverInit(int imageFormat) { - imageReceiver = - ImageReceiver.create( - Math.max(resoluteX, resoluteY), - Math.min(resoluteX, resoluteY), - imageFormat, - CameraConst.IMAGE_RCV_CAPACITY); - imageReceiver.setImageArrivalListener(new MyImageArrivalListener()); - } - - private void recorderInit() { - VideoRecorder.Builder builder = new VideoRecorder.Builder(context); - builder.setResolution(new Size(resoluteX, resoluteY)); - builder.setDegrees(isFrontCamera() ? NUMBER_INT_270 : NUMBER_INT_90); - String child = CameraConst.VIDEO_FILE_PREFIX + UUID.randomUUID() + CameraConst.VIDEO_FILE_TYPE; - File file = new File(context.getExternalFilesDir(Environment.DIRECTORY_MOVIES), child); - builder.setSaveFilePath(file.getPath()); - if (videoRecorder == null) { - videoRecorder = builder.create(); - videoRecorder.prepare(); - } else { - videoRecorder.reset(builder); - } - } - - // 选择最合适分辨率 - private void setResolution() { - List resolutions = getResolutions(); - if (resolutions != null) { - LogUtil.info(TAG, "takePictureInit pictureSizes :" + Arrays.toString(resolutions.toArray())); - double baseResolution = - (double) Math.max(previewHeight, previewWidth) / Math.min(previewHeight, previewWidth); - double minDefference = baseResolution; - for (Size resolution : resolutions) { - double resolutionTemp = (double) resolution.width / resolution.height; - double difference = Math.abs(baseResolution - resolutionTemp); - if (difference < minDefference) { - minDefference = difference; - resoluteX = resolution.width; - resoluteY = resolution.height; - } - } - } - } - - /** - * MyCameraStatuCallback - * - * @since 2020-04-09 - */ - private class MyCameraStatuCallback extends CameraStateCallback { - @Override - public void onCreated(Camera camera) { - super.onCreated(camera); - isCameraCreated = true; - cameraDevice = camera; - cameraConfigBuilder = camera.getCameraConfigBuilder(); - if (cameraConfigBuilder == null) { - return; - } - CameraConfig cameraConfig = - cameraConfigBuilder - .addSurface(previewSurface) // 配置预览的Surface - .addSurface(imageReceiver.getRecevingSurface()) // 配置拍照的Surface - .build(); - camera.configure(cameraConfig); - } - - @Override - public void onCreateFailed(String cameraId, int errorCode) { - super.onCreateFailed(cameraId, errorCode); - isCameraCreated = false; - } - - @Override - public void onConfigured(Camera camera) { - isPrepared = true; - frameConfigBuilder = camera.getFrameConfigBuilder(Camera.FrameConfigType.FRAME_CONFIG_PREVIEW); - frameConfigBuilder.addSurface(previewSurface); - if (isRecording() && recorderSurface != null) { - frameConfigBuilder.addSurface(recorderSurface); - videoRecorder.start(); - } - camera.triggerLoopingCapture(frameConfigBuilder.build()); - if (cameraCallback != null) { - cameraCallback.onCameraConfigured(CameraController.this); - } - } - - @Override - public void onConfigureFailed(Camera camera, int errorCode) { - isCameraCreated = false; - } - - @Override - public void onReleased(Camera camera) { - isCameraCreated = false; - isPrepared = false; - stopCapture(); - if (videoRecorder != null) { - videoRecorder.release(); - } - if (cameraCallback != null) { - cameraCallback.onCameraReleased(); - } - } - - @Override - public void onFatalError(Camera camera, int errorCode) { - super.onFatalError(camera, errorCode); - isCameraCreated = false; - isPrepared = false; - } - } - - /** - * MyImageArrivalListener - * - * @since 2020-04-09 - */ - private class MyImageArrivalListener implements ImageReceiver.IImageArrivalListener { - private static final int BUFFER_NUM = 5; - - private List buffers = new ArrayList<>(NUMBER_INT_5); - - private int index; - - MyImageArrivalListener() { - for (int i = 0; i < BUFFER_NUM; i++) { - buffers.add(new byte[resoluteX * resoluteY * NUMBER_INT_3 / NUMBER_INT_2]); - } - } - - @Override - public void onImageArrival(ImageReceiver receiver) { - LogUtil.info(TAG, "onImageArrival is called"); - byte[] bytes; - Image image = imageReceiver.readNextImage(); - if (captureMode == CaptureMode.PUSH_FLOW) { - bytes = getBuffer(); - Image.Component component = image.getComponent(ImageFormat.ComponentType.YUV_Y); - component.read(bytes, 0, component.remaining()); - component = image.getComponent(ImageFormat.ComponentType.YUV_U); - ByteBuffer mBuffer = component.getBuffer(); - mBuffer.get( - bytes, - resoluteX * resoluteY, - Math.min(mBuffer.remaining(), resoluteX * resoluteY / NUMBER_INT_2)); - if (isFrontCamera()) { - bytes = isMirror - ? Nv21Handler.rotateYuvDegree270AndMirror(bytes, resoluteX, resoluteY) - : Nv21Handler.rotateYuv420Degree270(bytes, resoluteX, resoluteY); - } else { - bytes = Nv21Handler.rotateYuv420Degree90(bytes, resoluteX, resoluteY); - } - } else { - Image.Component component = image.getComponent(ImageFormat.ComponentType.JPEG); - bytes = new byte[component.remaining()]; - component.read(bytes); - } - image.release(); - if (cameraCallback != null) { - cameraCallback.onGetFrameResult(bytes); - } - } - - private byte[] getBuffer() { - index++; - if (index == BUFFER_NUM) { - index = 0; - } - return buffers.get(index); - } - } - - private void takeSinglePhoto() { - frameConfigBuilder = cameraDevice.getFrameConfigBuilder(Camera.FrameConfigType.FRAME_CONFIG_PICTURE); - if (isMirror) { - frameConfigBuilder.setParameter(ParameterKey.IMAGE_MIRROR, true); - } - frameConfigBuilder.addSurface(imageReceiver.getRecevingSurface()); - frameConfigBuilder.setImageRotation(isFrontCamera() ? NUMBER_INT_270 : NUMBER_INT_90); - try { - cameraDevice.triggerSingleCapture(frameConfigBuilder.build()); - } catch (IllegalArgumentException e) { - LogUtil.info(TAG, "takeSinglePhoto is failed," + e.getMessage()); - } - } - - private void takeMultiPhoto(int size) { - frameConfigBuilder = cameraDevice.getFrameConfigBuilder(Camera.FrameConfigType.FRAME_CONFIG_PICTURE); - if (isMirror) { - frameConfigBuilder.setParameter(ParameterKey.IMAGE_MIRROR, true); - } - frameConfigBuilder.addSurface(imageReceiver.getRecevingSurface()); - frameConfigBuilder.setImageRotation(isFrontCamera() ? NUMBER_INT_270 : NUMBER_INT_90); - try { - cameraDevice.triggerLoopingCapture(frameConfigBuilder.build()); - } catch (IllegalArgumentException e) { - LogUtil.info(TAG, "takeMultiPhoto is failed," + e.getMessage()); - } - } - - private void pushFlow() { - frameConfigBuilder.addSurface(imageReceiver.getRecevingSurface()); - try { - cameraDevice.triggerLoopingCapture(frameConfigBuilder.build()); - } catch (IllegalArgumentException e) { - LogUtil.info(TAG, "pushFlow is failed," + e.getMessage()); - } - } - - private void startRecord() { - if (!isRecording() && videoRecorder.getStatu() != MediaStatu.IDEL) { - if (videoRecorder.getStatu() == MediaStatu.STOP) { - recorderInit(); - } - Optional optional = videoRecorder.getRecordSurface(); - optional.ifPresent(surface -> { - recorderSurface = optional.get(); - cameraConfigBuilder.addSurface(previewSurface); - cameraConfigBuilder.addSurface(recorderSurface); - cameraDevice.configure(cameraConfigBuilder.build()); - }); - } - } - - @Override - public void setMode(CaptureMode mode) { - captureMode = mode; - } - - @Override - public void switchCamera(CameraType type) { - if (isPrepared) { - cameraType = type.getType(); - cameraInit(); - } - } - - @Override - public void setMirrorEffect(boolean isMirrorEffect) { - this.isMirror = isMirrorEffect; - } - - @Override - public void capture() { - if (isCameraCreated) { - isCapturing = true; - switch (captureMode) { - case SINGLE_SHOT: - takeSinglePhoto(); - break; - case MULTI_SHOT: - takeMultiPhoto(NUMBER_INT_10); - break; - case VIDEO_RECORD: - startRecord(); - break; - case PUSH_FLOW: - pushFlow(); - break; - default: - break; - } - } - } - - @Override - public void stopCapture() { - if (isCameraCreated && isCapturing) { - isCapturing = false; - if (captureMode == CaptureMode.VIDEO_RECORD) { - videoRecorder.stop(); - if (recorderSurface != null) { - cameraConfigBuilder.removeSurface(recorderSurface); - recorderSurface = null; - } - } - cameraDevice.configure(cameraConfigBuilder.build()); - } - } - - private boolean isRecording() { - return isCapturing && captureMode == CaptureMode.VIDEO_RECORD; - } - - @Override - public boolean isCapturing() { - return isCapturing; - } - - @Override - public boolean isFrontCamera() { - return cameraType == CameraType.FRONT.getType(); - } - - @Override - public CaptureMode getCaptureMode() { - return captureMode; - } - - @Override - public Size getResolution() { - return new Size(resoluteX, resoluteY); - } - - @Override - public List getResolutions() { - List sizes = null; - if (cameraSupportor != null) { - sizes = cameraSupportor.getSupportedSizes(SurfaceOps.class); - } - return sizes; - } - - @Override - public void setCameraListener(CameraStateListener listener) { - cameraCallback = listener; - } - - @Override - public void unBind() { - if (cameraDevice != null) { - cameraDevice.release(); - } - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/api/CameraListener.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/api/CameraListener.java deleted file mode 100644 index d503df781b0758c40cdfd4b7bdeb1a21a0952f76..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/api/CameraListener.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.camera.api; - -import com.huawei.codecdemo.camera.constant.CameraType; -import com.huawei.codecdemo.camera.constant.CaptureMode; - -import ohos.agp.components.surfaceprovider.SurfaceProvider; -import ohos.media.image.common.Size; - -import java.util.List; - -/** - * CameraListener - * - * @since 2021-04-09 - * - */ -public interface CameraListener { - /** - * bind - * - * @param surfaceProvider surfaceProvider - */ - void bind(SurfaceProvider surfaceProvider); - - /** - * unBind - */ - void unBind(); - - /** - * setCameraListener - * - * @param cameraStateListener cameraStateListener - */ - void setCameraListener(CameraStateListener cameraStateListener); - - /** - * setMode - * - * @param mode mode - */ - void setMode(CaptureMode mode); - - /** - * getResolution - * - * @return Size - */ - Size getResolution(); - - /** - * getResolutions - * - * @return Sizes - */ - List getResolutions(); - - /** - * getCaptureMode - * - * @return CaptureMode - */ - CaptureMode getCaptureMode(); - - /** - * isRecording - * - * @return isRecording - */ - boolean isCapturing(); - - /** - * isFrontCamera - * - * @return isFrontCamera - */ - boolean isFrontCamera(); - - /** - * stopCapture - */ - void stopCapture(); - - /** - * capture - */ - void capture(); - - /** - * switchCamera - * - * @param type type - */ - void switchCamera(CameraType type); - - /** - * setMirrorEffect - * - * @param isMirror isMirror - */ - void setMirrorEffect(boolean isMirror); -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/api/CameraStateListener.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/api/CameraStateListener.java deleted file mode 100644 index 7724d60a4a3af4f1c776cb9f7ae6aae831321525..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/api/CameraStateListener.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.camera.api; - -import com.huawei.codecdemo.camera.CameraController; - -/** - * CameraStateListener - * - * @since 2021-04-09 - * - */ -public interface CameraStateListener { - /** - * onCameraConfigured - * - * @param cameraController cameraController - */ - void onCameraConfigured(CameraController cameraController); - - /** - * onCameraReleased - * - */ - void onCameraReleased(); - - /** - * onCameraConfigured - * - * @param frame frame - */ - void onGetFrameResult(byte[] frame); -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/constant/CameraConst.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/constant/CameraConst.java deleted file mode 100644 index 1f87a97b1db2380284c841ecd3e8c60625dc2879..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/constant/CameraConst.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.camera.constant; - -/** - * CameraConst - * - * @since 2021-04-09 - */ -public class CameraConst { - /** - * codec color model - */ - public static final int CODEC_COLOR_MODEL = 21; - - /** - * codec frame interval - */ - public static final int CODEC_FRAME_INTERVAL = 1; - - /** - * codec bitrate mode - */ - public static final int CODEC_BITRATE_MODE = 1; - - /** - * image capacity - */ - public static final int IMAGE_RCV_CAPACITY = 4; - - /** - * video file prefix - */ - public static final String VIDEO_FILE_PREFIX = "VID_"; - - /** - * video file type - */ - public static final String VIDEO_FILE_TYPE = ".mp4"; - - private CameraConst() { - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/constant/CameraType.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/constant/CameraType.java deleted file mode 100644 index 23b8aeb9a127f3ff2b7ca0251a53704f8a4d3748..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/constant/CameraType.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.camera.constant; - -/** - * CameraType - * - * @since 2021-01-17 - */ -public enum CameraType { - /** - * camera back type - */ - BACK(0), - /** - * camera front type - */ - FRONT(1); - - private int type; - - CameraType(int type) { - this.type = type; - } - - public int getType() { - return this.type; - } -} \ No newline at end of file diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/constant/CaptureMode.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/constant/CaptureMode.java deleted file mode 100644 index 9b3d15dfd0aa12058c3b30eab2a4f55be31c1ce8..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/constant/CaptureMode.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.camera.constant; - -/** - * CaptureMode - * - * @since 2021-04-09 - * - */ -public enum CaptureMode { - /** - * SINGLE_SHOT - */ - SINGLE_SHOT, - - /** - * MULTI_SHOT - */ - MULTI_SHOT, - - /** - * VIDEO_RECORD - */ - VIDEO_RECORD, - - /** - * PUSH_FLOW - */ - PUSH_FLOW -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/utils/DateUtils.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/utils/DateUtils.java deleted file mode 100644 index 2f2d3003e41184e9638ab94495909b89947cb681..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/utils/DateUtils.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.camera.utils; - -import java.util.Locale; - -/** - * DateUtils - * - * @since 2021-04-09 - */ -public class DateUtils { - private static final int ONE_SECONDS_MS = 1000; - private static final int ONE_MINS_MINUTES = 60; - private static final int NUMBER = 16; - private static final String TIME_FORMAT = "%02d"; - private static final String SEMICOLON = ":"; - - private DateUtils() { - } - - /** - * conversion of msToString - * - * @param ms ms - * @return string - */ - public static String msToString(int ms) { - StringBuilder sb = new StringBuilder(NUMBER); - int seconds = ms / ONE_SECONDS_MS; - int minutes = seconds / ONE_MINS_MINUTES; - if (minutes > ONE_MINS_MINUTES) { - sb.append(String.format(Locale.ENGLISH, TIME_FORMAT, minutes / ONE_MINS_MINUTES)); - sb.append(SEMICOLON); - sb.append(String.format(Locale.ENGLISH, TIME_FORMAT, minutes % ONE_MINS_MINUTES)); - sb.append(SEMICOLON); - } else { - sb.append("00:"); - sb.append(String.format(Locale.ENGLISH, TIME_FORMAT, minutes)); - sb.append(SEMICOLON); - } - - if (seconds > minutes * ONE_MINS_MINUTES) { - sb.append(String.format(Locale.ENGLISH, TIME_FORMAT, seconds - minutes * ONE_MINS_MINUTES)); - } else { - sb.append("00"); - } - return sb.toString(); - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/utils/Nv21Handler.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/utils/Nv21Handler.java deleted file mode 100644 index ee48427dca55c3b9cd8036061f9bf9a9d7194dd4..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/utils/Nv21Handler.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.camera.utils; - -/** - * Nv21Handler 视频采集格式是NV21,(属于YUV420) - * - * @since 2021-04-09 - */ -public class Nv21Handler { - private static final int NUMBER_2 = 2; - private static final int NUMBER_3 = 3; - - private Nv21Handler() { - } - - /** - * 420p旋转90度 - * - * @param data data - * @param imageWidth imageWidth - * @param imageHeight imageHeight - * @return byte[] - */ - public static byte[] rotateYuv420Degree90(byte[] data, int imageWidth, int imageHeight) { - byte[] yuvs = new byte[imageWidth * imageHeight * NUMBER_3 / NUMBER_2]; - int temp = 0; - for (int x = 0; x < imageWidth; x++) { - for (int y = imageHeight - 1; y >= 0; y--) { - yuvs[temp] = data[y * imageWidth + x]; - temp++; - } - } - temp = imageWidth * imageHeight * NUMBER_3 / NUMBER_2 - 1; - for (int x = imageWidth - 1; x > 0; x = x - NUMBER_2) { - for (int y = 0; y < imageHeight / NUMBER_2; y++) { - yuvs[temp] = data[(imageWidth * imageHeight) + (y * imageWidth) + x]; - temp--; - yuvs[temp] = data[(imageWidth * imageHeight) + (y * imageWidth) + (x - 1)]; - temp--; - } - } - return yuvs; - } - - /** - * 420p旋转270度 - * - * @param data data - * @param imageWidth imageWidth - * @param imageHeight imageHeight - * @return byte[] - */ - public static byte[] rotateYuv420Degree270(byte[] data, int imageWidth, int imageHeight) { - byte[] yuvs = new byte[imageWidth * imageHeight * NUMBER_3 / NUMBER_2]; - int temp = 0; - for (int x = imageWidth - 1; x >= 0; x--) { - for (int y = 0; y < imageHeight; y++) { - yuvs[temp] = data[y * imageWidth + x]; - temp++; - } - } - for (int x = imageWidth - 1; x > 0; x = x - NUMBER_2) { - for (int y = 0; y < imageHeight / NUMBER_2; y++) { - yuvs[temp] = data[(imageWidth * imageHeight) + (y * imageWidth) + (x - 1)]; - temp++; - yuvs[temp] = data[(imageWidth * imageHeight) + (y * imageWidth) + x]; - temp++; - } - } - return yuvs; - } - - /** - * yuv420数据镜像 - * - * @param data data 原始数据 - * @param imageW imageWidth - * @param imageH imageHeight - */ - public static void mirrorYuv420(byte[] data, int imageW, int imageH) { - byte temp; - int current; - int next; - for (int i = 0; i < imageH; i++) { - current = i * imageW; - next = (i + 1) * imageW - 1; - while (current < next) { - temp = data[current]; - data[current] = data[next]; - data[next] = temp; - current++; - next--; - } - } - int index = imageW * imageH; - for (int i = 0; i < imageH / NUMBER_2; i++) { - current = i * imageW; - next = (i + 1) * imageW - NUMBER_2; - while (current < next) { - temp = data[current + index]; - data[current + index] = data[next + index]; - data[next + index] = temp; - - temp = data[current + index + 1]; - data[current + index + 1] = data[next + index + 1]; - data[next + index + 1] = temp; - current += NUMBER_2; - next -= NUMBER_2; - } - } - } - - /** - * yuv420数据旋转270并镜像 - * - * @param data data 原始数据 - * @param imageW imageWidth - * @param imageH imageHeight - * @return byte[] - */ - public static byte[] rotateYuvDegree270AndMirror(byte[] data, int imageW, int imageH) { - byte[] yuvs = new byte[imageW * imageH * NUMBER_3 / NUMBER_2]; - int temp = 0; - int maxY; - for (int x = imageW - 1; x >= 0; x--) { - maxY = imageW * (imageH - 1) + x * NUMBER_2; - for (int y = 0; y < imageH; y++) { - yuvs[temp] = data[maxY - (y * imageW + x)]; - temp++; - } - } - // Rotate and mirror the U and V color components - int uvSize = imageW * imageH; - temp = uvSize; - int maxUv; - for (int x = imageW - 1; x > 0; x = x - NUMBER_2) { - maxUv = imageW * (imageH / NUMBER_2 - 1) + x * NUMBER_2 + uvSize; - for (int y = 0; y < imageH / NUMBER_2; y++) { - yuvs[temp] = data[maxUv - NUMBER_2 - (y * imageW + x - 1)]; - temp++; - yuvs[temp] = data[maxUv - (y * imageW + x)]; - temp++; - } - } - return yuvs; - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/view/CameraView.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/view/CameraView.java deleted file mode 100644 index 0e3de8e2ecf7a31692bf9ca410830818e165d6d9..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/view/CameraView.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.camera.view; - -import com.huawei.codecdemo.camera.CameraController; -import com.huawei.codecdemo.camera.api.CameraListener; - -import ohos.agp.components.Attr; -import ohos.agp.components.AttrSet; -import ohos.agp.components.Component; -import ohos.agp.components.surfaceprovider.SurfaceProvider; -import ohos.agp.graphics.SurfaceOps; -import ohos.app.Context; - -import java.util.Optional; - -/** - * CameraView 视频采集格式是NV21,(属于YUV420) - * - * @since 2021-04-09 - */ -public class CameraView extends SurfaceProvider implements SurfaceOps.Callback { - private static final String TAG = CameraView.class.getName(); - private CameraListener cameraController; - - /** - * CameraView - * - * @param context context - */ - public CameraView(Context context) { - this(context, null); - } - - /** - * CameraView - * - * @param context context - * @param attrSet attrSet - */ - public CameraView(Context context, AttrSet attrSet) { - this(context, attrSet, null); - } - - /** - * CameraView - * - * @param context context - * @param attrSet attrSet - * @param styleName styleName - */ - public CameraView(Context context, AttrSet attrSet, String styleName) { - super(context, attrSet, styleName); - boolean isFront = false; - Optional optIsFront = attrSet.getAttr("front_camera"); - if (optIsFront.isPresent()) { - isFront = "true".equals(optIsFront.get().getStringValue()); - } - cameraController = new CameraController(mContext, isFront); - initView(); - } - - private void initView() { - setVisibility(Component.VISIBLE); - setFocusable(Component.FOCUS_ENABLE); // 设置可聚焦 - setTouchFocusable(true); // 设置触摸模式 - requestFocus(); - pinToZTop(false); - if (getSurfaceOps().isPresent()) { - getSurfaceOps().get().addCallback(CameraView.this); // 添加回调事件 - } - } - - @Override - public void surfaceCreated(SurfaceOps surfaceOps) { - surfaceOps.setFixedSize(getHeight(), getWidth()); - cameraController.bind(this); - } - - @Override - public void surfaceChanged(SurfaceOps surfaceOps, int tag, int width, int height) { - } - - @Override - public void surfaceDestroyed(SurfaceOps surfaceOps) { - cameraController.unBind(); - } - - /** - * 获取控制器 - * - * @return ICamera - */ - public CameraListener getController() { - return cameraController; - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/view/CaptureButton.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/view/CaptureButton.java deleted file mode 100644 index ca48013f8e50c55fb3b8c848fb2d49d6a57254a0..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/camera/view/CaptureButton.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.camera.view; - -import com.huawei.codecdemo.utils.LogUtil; - -import ohos.agp.colors.RgbColor; -import ohos.agp.components.AttrSet; -import ohos.agp.components.Button; -import ohos.agp.components.Component; -import ohos.agp.components.Component.TouchEventListener; -import ohos.agp.components.element.ShapeElement; -import ohos.app.Context; -import ohos.app.dispatcher.task.TaskPriority; -import ohos.multimodalinput.event.TouchEvent; - -/** - * CaptureButton 采集按钮 - * - * @since 2021-04-09 - */ -public class CaptureButton extends Button implements TouchEventListener { - private static final String TAG = CaptureButton.class.getSimpleName(); - - private static final float NUMBER_FLOAT_POINT_8 = 0.8f; - private static final float NUMBER_FLOAT_POINT_4 = 0.4f; - private static final int NUMBER_INT_2 = 2; - private static final int NUMBER_INT_255 = 255; - - private Context context; - private float currentCorner; - - /** - * CaptureButton - * - * @param context context - */ - public CaptureButton(Context context) { - this(context, null); - } - - /** - * CaptureButton - * - * @param context context - * @param attrSet attrSet - */ - public CaptureButton(Context context, AttrSet attrSet) { - this(context, attrSet, null); - } - - /** - * CaptureButton - * - * @param context context - * @param attrSet attrSet - * @param styleName styleName - */ - public CaptureButton(Context context, AttrSet attrSet, String styleName) { - super(context, attrSet, styleName); - this.context = context; - initView(); - initListener(); - } - - private void initView() { - currentCorner = (float) getHeight() / NUMBER_INT_2; - } - - private void initListener() { - setTouchEventListener(this); - } - - @Override - public boolean onTouchEvent(Component component, TouchEvent touchEvent) { - switch (touchEvent.getAction()) { - case TouchEvent.PRIMARY_POINT_DOWN: - setAlpha(NUMBER_FLOAT_POINT_8); - break; - case TouchEvent.PRIMARY_POINT_UP: - setAlpha(1.0f); - break; - default: - break; - } - return true; - } - - /** - * captrue样式切换,圆形转矩形 - */ - public void capture2Rect() { - context.getGlobalTaskDispatcher(TaskPriority.DEFAULT).asyncDispatch(() -> { - int temp = getHeight() / NUMBER_INT_2; - ShapeElement rectElement = new ShapeElement(); - rectElement.setRgbColor(new RgbColor(NUMBER_INT_255, 0, 0)); - while (currentCorner >= 0) { - context.getUITaskDispatcher().syncDispatch(() -> { - rectElement.setCornerRadius(currentCorner); - setBackground(rectElement); - setScaleX(1 - (NUMBER_FLOAT_POINT_4 - NUMBER_FLOAT_POINT_4 / temp * currentCorner)); - setScaleY(1 - (NUMBER_FLOAT_POINT_4 - NUMBER_FLOAT_POINT_4 / temp * currentCorner)); - }); - try { - Thread.sleep(1); - } catch (InterruptedException e) { - LogUtil.error(TAG, "capture2Rect failed,exception is " + e.getMessage()); - } - currentCorner--; - } - }); - } - - /** - * captrue样式切换,矩形转圆形 - */ - public void capture2round() { - context.getGlobalTaskDispatcher(TaskPriority.DEFAULT).asyncDispatch(() -> { - int temp = getHeight() / NUMBER_INT_2; - ShapeElement roundElement = new ShapeElement(); - roundElement.setRgbColor(new RgbColor(NUMBER_INT_255, NUMBER_INT_255, NUMBER_INT_255)); - while (currentCorner <= (float) temp) { - context.getUITaskDispatcher().syncDispatch(() -> { - roundElement.setCornerRadius(currentCorner); - setBackground(roundElement); - setScaleX(1 - (NUMBER_FLOAT_POINT_4 - NUMBER_FLOAT_POINT_4 / temp * currentCorner)); - setScaleY(1 - (NUMBER_FLOAT_POINT_4 - NUMBER_FLOAT_POINT_4 / temp * currentCorner)); - }); - try { - Thread.sleep(1); - } catch (InterruptedException e) { - LogUtil.error(TAG, "InterruptedException is " + e.getMessage()); - } - currentCorner++; - } - }); - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/codec/CodecDecoder.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/codec/CodecDecoder.java deleted file mode 100644 index 2c5a4aa1e20260cb5e177a58c6870370d0a2471c..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/codec/CodecDecoder.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.codec; - -import com.huawei.codecdemo.codec.api.CodecListener; -import com.huawei.codecdemo.utils.LogUtil; - -import ohos.agp.graphics.Surface; -import ohos.eventhandler.EventHandler; -import ohos.eventhandler.EventRunner; -import ohos.eventhandler.InnerEvent; -import ohos.media.codec.Codec; -import ohos.media.common.BufferInfo; -import ohos.media.common.Format; -import ohos.media.muxer.Muxer; - -import java.io.File; -import java.nio.ByteBuffer; - -/** - * CodecDecoder - * - * @since 2021-04-09 - */ -public class CodecDecoder { - private static final String TAG = CodecDecoder.class.getSimpleName(); - private static final long NUMBER_LONG_100 = 100L; - private static final int WRITE_BUFFER = 1; - private static final int STOP_CODEC = 2; - private Codec decoder; - private EventHandler decoderHandler; - private CodecListener callback; - private Muxer muxer; - private int trackIndex; - private boolean isOpen; - private boolean isSaveFile; - private File decodeFile; - - private CodecDecoder(Builder builder) { - initDecoder(builder.format, builder.surface); - if (builder.filePath != null) { - isSaveFile = true; - initMuxer(builder.format, builder.filePath); - } - decoderHandler = new MyEventHandler(EventRunner.create(CodecDecoder.class.getSimpleName())); - } - - /** - * MyEventHandler - * - * @since 2021-04-09 - */ - private class MyEventHandler extends EventHandler { - MyEventHandler(EventRunner eventRunner) { - super(eventRunner); - } - - @Override - protected void processEvent(InnerEvent event) { - switch (event.eventId) { - case WRITE_BUFFER: - LogUtil.info(TAG, "begin decode"); - if (event.object instanceof byte[]) { - byte[] bytes = (byte[]) (event.object); - int size = (int) event.param; - ByteBuffer byteBuffer = decoder.getAvailableBuffer(NUMBER_LONG_100); - if (byteBuffer != null) { - byteBuffer.clear(); - byteBuffer.put(bytes); - BufferInfo bufferInfo = new BufferInfo(); - bufferInfo.offset = 0; - bufferInfo.size = size; - boolean isSuccess = decoder.writeBuffer(byteBuffer, bufferInfo); - LogUtil.info(TAG, "end decode,result is :" + isSuccess); - } - } - break; - case STOP_CODEC: - LogUtil.info(TAG, "stop decode"); - if (muxer != null) { - muxer.stop(); - muxer.release(); - muxer = null; - } - if (decoder.stop() && decoder.release()) { - isOpen = false; - } - break; - default: - break; - } - } - } - - private void initDecoder(Format fmt, Surface surface) { - LogUtil.info(TAG, " init decoder"); - decoder = Codec.createDecoder(); - decoder.setVideoSurface(surface); - decoder.setCodecFormat(fmt); - decoder.registerCodecListener( - new Codec.ICodecListener() { - @Override - public void onReadBuffer(ByteBuffer byteBuffer, BufferInfo bufferInfo, int tag) { - LogUtil.info(TAG, "decode onReadBuffer is called "); - if (callback != null) { - callback.onGetcodecBuffer(byteBuffer, bufferInfo); - } - if (isSaveFile) { - boolean isSuccess = muxer.writeBuffer(trackIndex, byteBuffer, bufferInfo); - LogUtil.info(TAG, " 文件decodec写入,result is :" + isSuccess); - } - } - - @Override - public void onError(int tag, int tag1, int tag2) { - LogUtil.info(TAG, "decode onError is called"); - } - }); - } - - private void initMuxer(Format fmt, String filePath) { - decodeFile = new File(filePath); - muxer = new Muxer(decodeFile.getPath(), Muxer.MediaFileFormat.FORMAT_MPEG4); - trackIndex = muxer.appendTrack(fmt); - muxer.start(); - } - - /** - * 设置解码监听回调 - * - * @param listener listener - */ - public void setDecodeListener(CodecListener listener) { - callback = listener; - } - - /** - * 启动解码器 - */ - public void openDecoder() { - if (!isOpen) { - if (decoder.start()) { - isOpen = true; - } - } - } - - /** - * 开始解码 - * - * @param buffer buffer - */ - public void startDecode(byte[] buffer) { - if (isOpen) { - InnerEvent innerEvent = InnerEvent.get(WRITE_BUFFER, buffer.length, buffer); - decoderHandler.sendEvent(innerEvent, 0, EventHandler.Priority.IMMEDIATE); - } - } - - /** - * 停止解码 - */ - public void stopDecode() { - if (isOpen) { - decoderHandler.sendEvent(STOP_CODEC); - } - } - - /** - * 解码器是否启动 - * - * @return isOpen - */ - public boolean isOpen() { - return isOpen; - } - - /** - * Builder - * - * @since 2020-03-16 - */ - public static class Builder { - private Format format; - private String filePath; - private Surface surface; - - /** - * constructor of Builder - */ - public Builder() { - } - - /** - * setSurface of Builder - * - * @param surface surface - * @return builder - */ - public Builder setSurface(Surface surface) { - this.surface = surface; - return this; - } - - /** - * setFormat of Builder - * - * @param format format - * @return builder - */ - public Builder setFormat(Format format) { - this.format = format; - return this; - } - - /** - * setSaveFilePath of Builder - * - * @param path path - * @return builder - */ - public Builder setSaveFilePath(String path) { - this.filePath = path; - return this; - } - - /** - * create of create - * - * @return CodecDecoder - */ - public CodecDecoder create() { - return new CodecDecoder(this); - } - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/codec/CodecEncoder.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/codec/CodecEncoder.java deleted file mode 100644 index 23c773851901e156d32e29d6130487811d459032..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/codec/CodecEncoder.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.codec; - -import com.huawei.codecdemo.codec.api.CodecListener; -import com.huawei.codecdemo.utils.LogUtil; - -import ohos.eventhandler.EventHandler; -import ohos.eventhandler.EventRunner; -import ohos.eventhandler.InnerEvent; -import ohos.media.codec.Codec; -import ohos.media.common.BufferInfo; -import ohos.media.common.Format; -import ohos.media.muxer.Muxer; - -import java.io.File; -import java.nio.ByteBuffer; -import java.util.Date; - -/** - * CodecEncoder - * - * @since 2021-04-09 - */ -public class CodecEncoder { - private static final String TAG = CodecEncoder.class.getSimpleName(); - private static final long NUMBER_LONG_100 = 100L; - private static final int NUMBER_INT_1000 = 1000; - private static final int WRITE_BUFFER = 1; - private static final int STOP_CODEC = 2; - private boolean isOpen = false; - private CodecListener codecListener; - private Codec encoder; - private EventHandler encoderHandler; - private Muxer muxer; - private File encodeFile; - private int trackIndex; - private boolean isSaveFile = false; - - private CodecEncoder(Builder builder) { - initEncoder(builder.format); - if (builder.filePath != null) { - isSaveFile = true; - initMuxer(builder.format, builder.filePath); - } - encoderHandler = new MyEventHandler(EventRunner.create(CodecEncoder.class.getSimpleName())); - } - - /** - * MyEventHandler - * - * @since 2021-04-12 - */ - private class MyEventHandler extends EventHandler { - MyEventHandler(EventRunner eventRunner) { - super(eventRunner); - } - - @Override - protected void processEvent(InnerEvent event) { - switch (event.eventId) { - case WRITE_BUFFER: - byte[] bytes = (byte[]) (event.object); - LogUtil.info(TAG, "start encode"); - if (isOpen) { - ByteBuffer byteBuffer = encoder.getAvailableBuffer(NUMBER_LONG_100); - if (byteBuffer != null) { - byteBuffer.clear(); - byteBuffer.put(bytes); - BufferInfo info = new BufferInfo(); - info.size = bytes.length; - info.offset = 0; - info.timeStamp = System.currentTimeMillis(); - boolean isSuccess = encoder.writeBuffer(byteBuffer, info); - LogUtil.info(TAG, "encode result is " + isSuccess); - } - } - break; - case STOP_CODEC: - LogUtil.info(TAG, "stop encode"); - if (muxer != null) { - muxer.stop(); - muxer.release(); - muxer = null; - } - if (encoder.stop() && encoder.release()) { - encoder = null; - isOpen = false; - } - break; - default: - break; - } - } - } - - private void initEncoder(Format fmt) { - LogUtil.info(TAG, "init encoder"); - encoder = Codec.createEncoder(); - encoder.setCodecFormat(fmt); - encoder.registerCodecListener( - new Codec.ICodecListener() { - @Override - public void onReadBuffer(ByteBuffer byteBuffer, BufferInfo bufferInfo, int tag) { - LogUtil.info(TAG, "encode onReadBuffer is called"); - if (codecListener != null) { - codecListener.onGetcodecBuffer(byteBuffer, bufferInfo); - } - if (isSaveFile) { - bufferInfo.timeStamp = new Date().getTime() * NUMBER_INT_1000; - boolean isSuccess = muxer.writeBuffer(trackIndex, byteBuffer, bufferInfo); - LogUtil.info(TAG, "muxer.writeBuffer " + bufferInfo.size + ", result: " + isSuccess); - } - } - - @Override - public void onError(int tag, int tag1, int tag2) { - LogUtil.info(TAG, "encode onError is called"); - } - }); - } - - private void initMuxer(Format fmt, String filePath) { - encodeFile = new File(filePath); - muxer = new Muxer(encodeFile.getPath(), Muxer.MediaFileFormat.FORMAT_MPEG4); - trackIndex = muxer.appendTrack(fmt); - muxer.start(); - } - - /** - * 设置编码监听回调 - * - * @param listener listener - */ - public void setEncodeListener(CodecListener listener) { - codecListener = listener; - } - - /** - * 启动编码器 - */ - public void openEncoder() { - if (!isOpen) { - if (encoder.start()) { - isOpen = true; - } - } - } - - /** - * 开始编码 - * - * @param bytes bytes - */ - public void startEncode(byte[] bytes) { - if (isOpen) { - InnerEvent innerEvent = InnerEvent.get(WRITE_BUFFER, 0, bytes); - encoderHandler.sendEvent(innerEvent, 0, EventHandler.Priority.IMMEDIATE); - } - } - - /** - * 停止编码 - */ - public void stopEncode() { - if (isOpen) { - encoderHandler.sendEvent(STOP_CODEC); - } - } - - /** - * 编码器是否启动 - * - * @return boolean isOpen - */ - public boolean isOpen() { - return isOpen; - } - - /** - * Builder - * - * @since 2020-03-16 - */ - public static class Builder { - private Format format; - private String filePath; - - /** - * constructor of Builder - */ - public Builder() { - } - - /** - * setFormat of Builder - * - * @param format format - * @return builder - */ - public Builder setFormat(Format format) { - this.format = format; - return this; - } - - /** - * setSaveFilePath of Builder - * - * @param path path - * @return builder - */ - public Builder setSaveFilePath(String path) { - this.filePath = filePath; - return this; - } - - /** - * create of Builder - * - * @return CodecEncoder - */ - public CodecEncoder create() { - return new CodecEncoder(this); - } - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/codec/api/CodecListener.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/codec/api/CodecListener.java deleted file mode 100644 index cc013d1d9ed2c28021b1fa43189b1398c48ea52b..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/codec/api/CodecListener.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.codec.api; - -import ohos.media.common.BufferInfo; - -import java.nio.ByteBuffer; - -/** - * CodecListener - * - * @since 2021-04-09 - */ -public interface CodecListener { - /** - * onGetcodecBuffer - * - * @param byteBuffer byteBuffer - * @param bufferInfo bufferInfo - */ - void onGetcodecBuffer(ByteBuffer byteBuffer, BufferInfo bufferInfo); -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/codec/constant/CodecConst.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/codec/constant/CodecConst.java deleted file mode 100644 index 1c96a4042c2283da8720344c80c125b160fe0087..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/codec/constant/CodecConst.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.codec.constant; - -/** - * CodecConst - * - * @since 2021-04-09 - */ -public class CodecConst { - /** - * recorder bit rate - */ - public static final int RECORDER_BIT_RATE = 10000000; - - /** - * recorder fps - */ - public static final int RECORDER_FPS = 30; - - /** - * recorder frame rate - */ - public static final int RECORDER_FRAME_RATE = 25; - - /** - * codec color model - */ - public static final int CODEC_COLOR_MODEL = 21; - - /** - * codec frame interval - */ - public static final int CODEC_FRAME_INTERVAL = 1; - - /** - * codec bitrate mode - */ - public static final int CODEC_BITRATE_MODE = 1; - - private CodecConst() { - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/manager/CodecPlayer.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/manager/CodecPlayer.java deleted file mode 100644 index 4a0b03a111b86734fb506029fee039edb28f6f60..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/manager/CodecPlayer.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.manager; - -import com.huawei.codecdemo.camera.CameraController; -import com.huawei.codecdemo.camera.api.CameraStateListener; -import com.huawei.codecdemo.codec.CodecDecoder; -import com.huawei.codecdemo.codec.CodecEncoder; -import com.huawei.codecdemo.codec.constant.CodecConst; -import com.huawei.codecdemo.media.constant.MediaConst; - -import ohos.agp.graphics.Surface; -import ohos.media.common.Format; - -/** - * CodecPlayer 编解码播放器 - * - * @since 2021-04-09 - */ -public class CodecPlayer implements CameraStateListener { - private CodecEncoder videoEncoder; - private CodecDecoder videoDecoder; - private Surface surface; - - /** - * CodecPlayer - * - * @param surface surface - */ - public CodecPlayer(Surface surface) { - this.surface = surface; - } - - @Override - public void onCameraConfigured(CameraController controller) { - Format fmt = new Format(); - fmt.putStringValue(Format.MIME, Format.VIDEO_AVC); - // yuv数据解码视频旋转了90度,解码宽高对换 - fmt.putIntValue(Format.WIDTH, controller.getResolution().height); - fmt.putIntValue(Format.HEIGHT, controller.getResolution().width); - fmt.putIntValue(Format.BIT_RATE, MediaConst.RECORDER_BIT_RATE); - fmt.putIntValue(Format.COLOR_MODEL, CodecConst.CODEC_COLOR_MODEL); - fmt.putIntValue(Format.FRAME_RATE, MediaConst.RECORDER_FRAME_RATE); - fmt.putIntValue(Format.FRAME_INTERVAL, CodecConst.CODEC_FRAME_INTERVAL); - fmt.putIntValue(Format.BITRATE_MODE, CodecConst.CODEC_BITRATE_MODE); - initEncoder(fmt); - initDecoder(fmt); - if(controller.isCapturing()){ - controller.capture(); - } - } - - private void initEncoder(Format fmt) { - videoEncoder = new CodecEncoder.Builder().setFormat(fmt).create(); - videoEncoder.setEncodeListener((byteBuffer, bufferInfo) -> { - byte[] buffers = new byte[bufferInfo.size]; - byteBuffer.clear(); - byteBuffer.get(buffers); - videoDecoder.startDecode(buffers); - }); - videoEncoder.openEncoder(); - } - - private void initDecoder(Format fmt) { - videoDecoder = new CodecDecoder.Builder().setFormat(fmt).setSurface(surface).create(); - videoDecoder.openDecoder(); - } - - @Override - public void onGetFrameResult(byte[] frame) { - if (videoEncoder.isOpen()) { - videoEncoder.startEncode(frame); - } - } - - @Override - public void onCameraReleased() { - stop(); - } - - /** - * 停止播放 - */ - public void stop() { - if (videoEncoder != null) { - videoEncoder.stopEncode(); - } - if (videoDecoder != null) { - videoDecoder.stopDecode(); - } - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/media/VideoRecorder.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/media/VideoRecorder.java deleted file mode 100644 index d8e0bf404e68c50483d2967a6f766023e931380a..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/media/VideoRecorder.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.media; - -import com.huawei.codecdemo.media.constant.MediaConst; -import com.huawei.codecdemo.media.constant.MediaStatu; -import com.huawei.codecdemo.utils.ScreenUtils; - -import ohos.agp.graphics.Surface; -import ohos.app.Context; -import ohos.eventhandler.EventHandler; -import ohos.eventhandler.EventRunner; -import ohos.media.common.AudioProperty; -import ohos.media.common.Source; -import ohos.media.common.StorageProperty; -import ohos.media.common.VideoProperty; -import ohos.media.image.common.Size; -import ohos.media.recorder.Recorder; - -import java.util.Optional; - -/** - * VideoRecorder 视频收录器 - * - * @since 2021-04-09 - */ -public class VideoRecorder { - private Recorder recorder; - private EventHandler videoRecorderHandler; - private MediaStatu recordStatu = MediaStatu.IDEL; - private VideoProperty.Builder videoPropertyBuilder; - private AudioProperty.Builder audioPropertyBuilder; - private StorageProperty.Builder storagePropertyBuilder; - - private VideoRecorder(Builder builder) { - videoRecorderHandler = new EventHandler(EventRunner.create(VideoRecorder.class.getSimpleName())); - videoPropertyBuilder = new VideoProperty.Builder(); - audioPropertyBuilder = new AudioProperty.Builder(); - storagePropertyBuilder = new StorageProperty.Builder(); - recorder = new Recorder(); - init(builder); - } - - private void init(Builder builder) { - initVideoProperty(builder); - initAudioProperty(); - initStorageProperty(builder); - initRecorder(); - } - - private void initVideoProperty(Builder builder) { - videoPropertyBuilder.setRecorderDegrees(builder.degrees); - videoPropertyBuilder.setRecorderFps(builder.fps); - videoPropertyBuilder.setRecorderHeight(Math.min(builder.resolution.width, builder.resolution.height)); - videoPropertyBuilder.setRecorderWidth(Math.max(builder.resolution.width, builder.resolution.height)); - videoPropertyBuilder.setRecorderVideoEncoder(Recorder.VideoEncoder.H264); - videoPropertyBuilder.setRecorderRate(builder.frameRate); - videoPropertyBuilder.setRecorderBitRate(builder.bitRate); - } - - private void initAudioProperty() { - audioPropertyBuilder.setRecorderAudioEncoder(Recorder.AudioEncoder.AAC); - } - - private void initStorageProperty(Builder builder) { - storagePropertyBuilder.setRecorderPath(builder.savefilePath); - } - - /** - * 初始化录像器 - */ - private void initRecorder() { - Source source = new Source(); - source.setRecorderAudioSource(Recorder.AudioSource.MIC); - source.setRecorderVideoSource(Recorder.VideoSource.SURFACE); - recorder.setSource(source); - recorder.setOutputFormat(Recorder.OutputFormat.MPEG_4); - recorder.setStorageProperty(storagePropertyBuilder.build()); - recorder.setAudioProperty(audioPropertyBuilder.build()); - recorder.setVideoProperty(videoPropertyBuilder.build()); - } - - /** - * 录像器准备 - */ - public void prepare() { - if (recordStatu == MediaStatu.IDEL) { - if (recorder.prepare()) { - recordStatu = MediaStatu.PREPARED; - } - } - } - - /** - * 录像器启动 - */ - public void start() { - if (recordStatu != MediaStatu.IDEL && recordStatu != MediaStatu.START) { - videoRecorderHandler.postTask(() -> { - if (recorder.start()) { - recordStatu = MediaStatu.START; - } - }); - } - } - - /** - * pause - */ - public void pause() { - if (recordStatu == MediaStatu.START) { - if (recorder.pause()) { - recordStatu = MediaStatu.PAUSE; - } - } - } - - /** - * resume - */ - public void resume() { - if (recordStatu == MediaStatu.PAUSE) { - if (recorder.resume()) { - recordStatu = MediaStatu.START; - } - } - } - - /** - * stop - */ - public void stop() { - if (recordStatu != MediaStatu.IDEL) { - videoRecorderHandler.postTask(() -> { - if (recorder.stop()) { - recordStatu = MediaStatu.STOP; - } - }); - } - } - - /** - * reset - * - * @param builder builder - */ - public void reset(Builder builder) { - if (recorder.reset()) { - recordStatu = MediaStatu.IDEL; - } - init(builder); - prepare(); - } - - /** - * release - */ - public void release() { - if (recorder.release()) { - recordStatu = MediaStatu.IDEL; - } - } - - /** - * 获取视频收录器状态 - * - * @return MediaStatu MediaStatu - */ - public MediaStatu getStatu() { - return recordStatu; - } - - /** - * 获取视频收录器surface - * - * @return Surface - */ - public Optional getRecordSurface() { - if (recorder != null) { - return Optional.of(recorder.getVideoSurface()); - } - return Optional.empty(); - } - - /** - * 获取视频收录器监听回调 - * - * @param listener IRecorderListener - */ - public void setVideoRecorderListener(Recorder.IRecorderListener listener) { - if (recorder != null) { - recorder.registerRecorderListener(listener); - } - } - - /** - * Builder - * - * @since 2020-12-04 - */ - public static class Builder { - private Context context; - private String savefilePath; - private Size resolution; - private int degrees; - private int fps = MediaConst.RECORDER_FPS; - private int frameRate = MediaConst.RECORDER_FRAME_RATE; - private int bitRate = MediaConst.RECORDER_BIT_RATE; - - /** - * constructor of Builder - * - * @param context context - */ - public Builder(Context context) { - this.context = context; - resolution = new Size(ScreenUtils.getScreenWidth(context), ScreenUtils.getScreenHeight(context)); - } - - /** - * setSaveFilePath of Builder - * - * @param filePath filePath - * @return builder - */ - public Builder setSaveFilePath(String filePath) { - this.savefilePath = filePath; - return this; - } - - /** - * setStartMillisecond of Builder - * - * @param resolution resolution - * @return builder - */ - public Builder setResolution(Size resolution) { - this.resolution = resolution; - return this; - } - - /** - * setDegree of Builder - * - * @param degrees degrees - * @return Builder - */ - public Builder setDegrees(int degrees) { - this.degrees = degrees; - return this; - } - - /** - * setFps of Builder - * - * @param fps fps - * @return Builder - */ - public Builder setFps(int fps) { - this.fps = fps; - return this; - } - - /** - * setFrameRate of Builder - * - * @param frameRate frameRate - * @return Builder - */ - public Builder setFrameRate(int frameRate) { - this.frameRate = frameRate; - return this; - } - - /** - * setBitRate of Builder - * - * @param bitRate bitRate - * @return Builder - */ - public Builder setBitRate(int bitRate) { - this.bitRate = bitRate; - return this; - } - - /** - * create of Builder - * - * @return VideoRecorder - */ - public VideoRecorder create() { - return new VideoRecorder(this); - } - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/media/api/AudioRecordListener.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/media/api/AudioRecordListener.java deleted file mode 100644 index 93533120c3916afe04b905c01a6a8d31ecddd7d2..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/media/api/AudioRecordListener.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.media.api; - -/** - * AudioRecordListener - * - * @since 2021-04-09 - */ -public interface AudioRecordListener { - /** - * onGetRecordBuffer - * - * @param buffer buffer - * @param length length - */ - void onGetRecordBuffer(byte[] buffer, int length); -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/media/constant/MediaConst.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/media/constant/MediaConst.java deleted file mode 100644 index 4af02f383254eee71e4e9d7f41b6372846a3b479..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/media/constant/MediaConst.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.media.constant; - -/** - * MediaConst - * - * @since 2021-04-09 - */ -public class MediaConst { - /** - * VOICE FILE PREFIX - */ - public static final String VOICE_FILE_MUSIC = "MUSIC_"; - - /** - * VOICE FILE TYPE - */ - public static final String VOICE_FILE_TYPE_MP3 = ".mp3"; - - /** - * recorder fps - */ - public static final int RECORDER_FPS = 30; - - /** - * recorder bit rate - */ - public static final int RECORDER_BIT_RATE = 10000000; - - /** - * recorder frame rate - */ - public static final int RECORDER_FRAME_RATE = 25; - - /** - * BUFFERSIZE - */ - public static final int BUFFERSIZE = 1024; - - /** - * SAMPLE RATE - */ - public static final int SAMPLE_RATE = 44100; - - private MediaConst() { - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/media/constant/MediaStatu.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/media/constant/MediaStatu.java deleted file mode 100644 index e9c24e46f37aa5fb826c3b5be61087a1c0dd5368..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/media/constant/MediaStatu.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.media.constant; - -/** - * MediaStatu - * - * @since 2021-04-09 - */ -public enum MediaStatu { - /** - * idel - * - */ - IDEL, - /** - * preparing - * - */ - PREPARED, - /** - * start - * - */ - START, - /** - * pause - * - */ - PAUSE, - /** - * stop - * - */ - STOP -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/slice/CodecAbilitySlice.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/slice/CodecAbilitySlice.java deleted file mode 100644 index ea93c30823bf88034ebe8f84b3276a8ded201eba..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/slice/CodecAbilitySlice.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.slice; - -import com.huawei.codecdemo.ResourceTable; -import com.huawei.codecdemo.camera.api.CameraListener; -import com.huawei.codecdemo.camera.constant.CameraType; -import com.huawei.codecdemo.camera.constant.CaptureMode; -import com.huawei.codecdemo.camera.view.CameraView; -import com.huawei.codecdemo.camera.view.CaptureButton; -import com.huawei.codecdemo.manager.CodecPlayer; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.agp.components.Image; -import ohos.agp.components.Switch; -import ohos.agp.components.surfaceprovider.SurfaceProvider; -import ohos.agp.graphics.SurfaceOps; -import ohos.app.dispatcher.task.TaskPriority; - -import java.util.Optional; - -/** - * CodecAbilitySlice - * - * @since 2021-04-09 - */ -public class CodecAbilitySlice extends AbilitySlice { - private static final int NUMBER_INT_1000 = 1000; - private CameraListener cameraController; - private CodecPlayer codecPlayer; - private CaptureButton captureButton; - private Image cameraSwitchButton; - private Switch mirrorSwitch; - - @Override - protected void onStart(Intent intent) { - super.onStart(intent); - super.setUIContent(ResourceTable.Layout_ability_codec); - initView(); - initListener(); - } - - private void initView() { - if (findComponentById(ResourceTable.Id_button_capture) instanceof CaptureButton) { - captureButton = (CaptureButton) findComponentById(ResourceTable.Id_button_capture); - } - if (findComponentById(ResourceTable.Id_image_camera_switch) instanceof Image) { - cameraSwitchButton = (Image) findComponentById(ResourceTable.Id_image_camera_switch); - } - if (findComponentById(ResourceTable.Id_mirror_switch) instanceof Switch) { - mirrorSwitch = (Switch) findComponentById(ResourceTable.Id_mirror_switch); - } - if (findComponentById(ResourceTable.Id_cameraview) instanceof CameraView) { - CameraView cameraView = (CameraView) findComponentById(ResourceTable.Id_cameraview); - cameraController = cameraView.getController(); - cameraController.setMode(CaptureMode.PUSH_FLOW); - } - if (findComponentById(ResourceTable.Id_remote_player) instanceof SurfaceProvider) { - SurfaceProvider remoteSurfaceView = (SurfaceProvider) findComponentById(ResourceTable.Id_remote_player); - Optional optional = remoteSurfaceView.getSurfaceOps(); - optional.ifPresent(surfaceOps -> surfaceOps.addCallback( - new SurfaceOps.Callback() { - @Override - public void surfaceCreated(SurfaceOps surfaceOps) { - codecPlayer = new CodecPlayer(surfaceOps.getSurface()); - cameraController.setCameraListener(codecPlayer); - } - - @Override - public void surfaceChanged( - SurfaceOps surfaceOps, int tag, int width, int height) { - } - - @Override - public void surfaceDestroyed(SurfaceOps surfaceOps) { - } - })); - } - } - - private void initListener() { - if (mirrorSwitch != null) { - mirrorSwitch.setCheckedStateChangedListener((absButton, isMirror) -> - cameraController.setMirrorEffect(isMirror)); - } - if (cameraSwitchButton != null) { - cameraSwitchButton.setClickedListener(component -> { - codecPlayer.stop(); - cameraController.switchCamera(cameraController.isFrontCamera() ? CameraType.BACK : CameraType.FRONT); - }); - } - if (captureButton != null) { - captureButton.setClickedListener(component -> { - captureToggle(); - }); - } - } - - private void captureToggle() { - if (cameraController.isCapturing()) { - cameraController.stopCapture(); - codecPlayer.stop(); - } else { - cameraController.capture(); - } - } - - @Override - protected void onActive() { - super.onActive(); - } - - @Override - protected void onForeground(Intent intent) { - super.onForeground(intent); - } - - @Override - protected void onStop() { - super.onStop(); - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/slice/MainAbilitySlice.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/slice/MainAbilitySlice.java deleted file mode 100644 index f0cad2df9dfea44c834ca1d7b99632a60b865760..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/slice/MainAbilitySlice.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.slice; - -import com.huawei.codecdemo.CodecAbility; -import com.huawei.codecdemo.ResourceTable; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.aafwk.content.Operation; -import ohos.agp.components.Button; - -/** - * MainAbilitySlice - * - * @since 2021-04-09 - */ -public class MainAbilitySlice extends AbilitySlice { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setUIContent(ResourceTable.Layout_ability_main); - initView(); - } - - private void initView() { - if (findComponentById(ResourceTable.Id_live_button) instanceof Button) { - Button liveButton = (Button) findComponentById(ResourceTable.Id_live_button); - liveButton.setClickedListener(component -> { - Intent intent = new Intent(); - Operation operation = - new Intent.OperationBuilder() - .withBundleName(getBundleName()) - .withAbilityName(CodecAbility.class.getName()) - .build(); - intent.setOperation(operation); - startAbility(intent); - }); - } - } - - @Override - public void onActive() { - super.onActive(); - } - - @Override - public void onForeground(Intent intent) { - super.onForeground(intent); - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/utils/LogUtil.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/utils/LogUtil.java deleted file mode 100644 index a7a713b8dfc02e5bed7c17e43428c655bfd892c2..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/utils/LogUtil.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.utils; - -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; - -/** - * LogUtil - * - * @since 2021-04-09 - */ -public class LogUtil { - private static final String TAG_LOG = "LogUtil"; - - private static final HiLogLabel LABEL_LOG = new HiLogLabel(0, 0, LogUtil.TAG_LOG); - - private static final String LOG_FORMAT = "%{public}s: %{public}s"; - - private LogUtil() { - } - - /** - * Print info log - * - * @param tag log tag - * @param msg log message - */ - public static void info(String tag, String msg) { - HiLog.info(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print error log - * - * @param tag log tag - * @param msg log message - */ - public static void error(String tag, String msg) { - HiLog.error(LABEL_LOG, LOG_FORMAT, tag, msg); - } -} diff --git a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/utils/ScreenUtils.java b/CodecDemo/entry/src/main/java/com/huawei/codecdemo/utils/ScreenUtils.java deleted file mode 100644 index 4510909d38c1f39830864b9f7132e1e1584013a8..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/java/com/huawei/codecdemo/utils/ScreenUtils.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codecdemo.utils; - -import ohos.agp.utils.Point; -import ohos.agp.window.service.Display; -import ohos.agp.window.service.DisplayManager; -import ohos.app.Context; - -import java.util.Optional; - -/** - * ScreenUtils - * - * @since 2021-04-09 - */ -public class ScreenUtils { - private ScreenUtils() { - } - - /** - * 获取屏幕高的分辨率 - * - * @param context 上下文 - * @return int height - */ - public static int getScreenHeight(Context context) { - DisplayManager displayManager = DisplayManager.getInstance(); - Optional optDisplay = displayManager.getDefaultDisplay(context); - Point point = new Point(0, 0); - if (!optDisplay.isPresent()) { - return (int) point.position[1]; - } else { - Display display = optDisplay.get(); - display.getSize(point); - return (int) point.position[1]; - } - } - - /** - * 获取屏幕宽的分辨率 - * - * @param context 上下文 - * @return int width - */ - public static int getScreenWidth(Context context) { - DisplayManager displayManager = DisplayManager.getInstance(); - Optional optDisplay = displayManager.getDefaultDisplay(context); - Point point = new Point(0, 0); - if (!optDisplay.isPresent()) { - return (int) point.position[0]; - } else { - Display display = optDisplay.get(); - display.getSize(point); - return (int) point.position[0]; - } - } -} diff --git a/CodecDemo/entry/src/main/resources/base/element/color.json b/CodecDemo/entry/src/main/resources/base/element/color.json deleted file mode 100644 index 1489f326ee11f99ce995219a546eb9eed2f5081f..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "color": [ - { - "name": "red", - "value": "#FF0000" - }, - { - "name": "blue", - "value": "#0000FF" - }, - { - "name": "dark_grey", - "value": "#282828" - }, - { - "name": "white", - "value": "#ffffff" - } - ] -} \ No newline at end of file diff --git a/CodecDemo/entry/src/main/resources/base/element/string.json b/CodecDemo/entry/src/main/resources/base/element/string.json deleted file mode 100644 index b21401a2356c20a704e59511635955cadd7b3f28..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "CodecDemo" - }, - { - "name": "app_entry", - "value": "entry" - }, - { - "name": "mainability_description", - "value": "Java_Phone_Empty Feature Ability" - }, - { - "name": "codecability_description", - "value": "Java_Phone_Empty Feature Ability" - } - ] -} \ No newline at end of file diff --git a/CodecDemo/entry/src/main/resources/base/graphic/button_normal_ability_main.xml b/CodecDemo/entry/src/main/resources/base/graphic/button_normal_ability_main.xml deleted file mode 100644 index c0c0a3df480fa387a452b9c40ca191cc918a3fc0..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/resources/base/graphic/button_normal_ability_main.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/CodecDemo/entry/src/main/resources/base/graphic/button_pressed_ability_main.xml b/CodecDemo/entry/src/main/resources/base/graphic/button_pressed_ability_main.xml deleted file mode 100644 index 59c0141c2b5665c2d1d883022209208eb9290e3b..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/resources/base/graphic/button_pressed_ability_main.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/CodecDemo/entry/src/main/resources/base/graphic/gray_thumb.xml b/CodecDemo/entry/src/main/resources/base/graphic/gray_thumb.xml deleted file mode 100644 index d417a8323687bfb6403316072e2ac50b0a0befcd..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/resources/base/graphic/gray_thumb.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/CodecDemo/entry/src/main/resources/base/graphic/gray_track.xml b/CodecDemo/entry/src/main/resources/base/graphic/gray_track.xml deleted file mode 100644 index 2235f61227ed99cbe9dd13b183d8d3eb257c2ec2..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/resources/base/graphic/gray_track.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CodecDemo/entry/src/main/resources/base/graphic/green_thumb.xml b/CodecDemo/entry/src/main/resources/base/graphic/green_thumb.xml deleted file mode 100644 index f1d6074ab039aefb1826442ccf765b9963e8f12a..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/resources/base/graphic/green_thumb.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/CodecDemo/entry/src/main/resources/base/graphic/green_track.xml b/CodecDemo/entry/src/main/resources/base/graphic/green_track.xml deleted file mode 100644 index 4854f4e01f75d959d381e8ccbd739932a8f31473..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/resources/base/graphic/green_track.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CodecDemo/entry/src/main/resources/base/graphic/selector_ability_main.xml b/CodecDemo/entry/src/main/resources/base/graphic/selector_ability_main.xml deleted file mode 100644 index 603ed1fbca321ba08d2f00aa83089b9cfc79ea1f..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/resources/base/graphic/selector_ability_main.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/CodecDemo/entry/src/main/resources/base/graphic/shape_take_picture_bac.xml b/CodecDemo/entry/src/main/resources/base/graphic/shape_take_picture_bac.xml deleted file mode 100644 index f6491596a43fd37056c5821126ff25f73968b110..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/resources/base/graphic/shape_take_picture_bac.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CodecDemo/entry/src/main/resources/base/graphic/thumb.xml b/CodecDemo/entry/src/main/resources/base/graphic/thumb.xml deleted file mode 100644 index 1c42512863fc7196a8f326be27b340bac03784f1..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/resources/base/graphic/thumb.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/CodecDemo/entry/src/main/resources/base/graphic/track.xml b/CodecDemo/entry/src/main/resources/base/graphic/track.xml deleted file mode 100644 index ecb569ed0ad2ca43aafd7a7157301ee3e8d29829..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/resources/base/graphic/track.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/CodecDemo/entry/src/main/resources/base/layout/ability_codec.xml b/CodecDemo/entry/src/main/resources/base/layout/ability_codec.xml deleted file mode 100644 index 647b6117182cf4c1a36219318f10531d616b9c23..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/resources/base/layout/ability_codec.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/CodecDemo/entry/src/main/resources/base/layout/ability_main.xml b/CodecDemo/entry/src/main/resources/base/layout/ability_main.xml deleted file mode 100644 index 91845f2509b702fd7f94a89a9cfc8dc9fa77e832..0000000000000000000000000000000000000000 --- a/CodecDemo/entry/src/main/resources/base/layout/ability_main.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - -
-
- AlertDialog -
-
- -
-
-
- - -
-
- ConfirmDialog -
-
- - -
-
-
- - -
- - loading... -
-
- - -
-
- PromptDialog -
- - -
- - -
-
-
- - -
- Downloading... -
- -
- Image {{ percent / 10 }} of 10 -
-
- - \ No newline at end of file diff --git a/DialogDemo/entry/src/main/js/default/pages/index/index.js b/DialogDemo/entry/src/main/js/default/pages/index/index.js deleted file mode 100644 index 07c361cd3e933ac0e5fc0deba71c76f4deda29a7..0000000000000000000000000000000000000000 --- a/DialogDemo/entry/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import prompt from '@system.prompt'; - -export default { - data: { - percent: 0, - interval: '' - }, - showAlert() { - this.$element('alertDialog').show(); - }, - showConfirm() { - this.$element('confirmDialog').show(); - }, - showLoading() { - const options = { - duration: 800, - easing: 'linear', - iterations: 'Infinity' - }; - const frames = [ - { - transform: { - rotate: '0deg' - } - }, - { - transform: { - rotate: '360deg' - } - } - ]; - this.animation = this.$element('loading-img').animate(frames, options); - this.$element('loadingDialog').show(); - this.animation.play(); - }, - showPrompt() { - this.$element('promptDialog').show(); - }, - showProgress() { - const that = this; - that.percent = 0; - this.$element('progressDialog').show(); - this.interval = setInterval(function() { - that.percent += 10; - if (that.percent >= 100) { - clearInterval(that.interval); - } - }, 500); - }, - confirmClick(id) { - this.$element(id).close(); - prompt.showToast({ - message: 'confirm clicked' - }); - }, - cancelClick(id) { - this.$element(id).close(); - prompt.showToast({ - message: 'cancel clicked' - }); - }, - onCancel(){ - clearInterval(this.interval); - } -}; diff --git a/DialogDemo/entry/src/main/resources/base/media/icon.png b/DialogDemo/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/DialogDemo/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/DialogDemo/entry/src/ohosTest/java/com/huawei/codelab/ExampleOhosTest.java b/DialogDemo/entry/src/ohosTest/java/com/huawei/codelab/ExampleOhosTest.java deleted file mode 100644 index 526e3ebd3b369b4607dc1cd5b10a32170a95d4df..0000000000000000000000000000000000000000 --- a/DialogDemo/entry/src/ohosTest/java/com/huawei/codelab/ExampleOhosTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.huawei.codelab; - -import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class ExampleOhosTest { - @Test - public void testBundleName() { - final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName(); - assertEquals("com.huawei.cook", actualBundleName); - } -} \ No newline at end of file diff --git a/DialogDemo/entry/src/ohosTest/js/default/app.js b/DialogDemo/entry/src/ohosTest/js/default/app.js deleted file mode 100644 index 55b67e96deb821033f71d30b6fff05efdeb0d901..0000000000000000000000000000000000000000 --- a/DialogDemo/entry/src/ohosTest/js/default/app.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - onCreate() { - console.info('TestApplication onCreate'); - }, - onDestroy() { - console.info('TestApplication onDestroy'); - } -}; diff --git a/DialogDemo/entry/src/ohosTest/js/default/pages/index/index.css b/DialogDemo/entry/src/ohosTest/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/DialogDemo/entry/src/ohosTest/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/DialogDemo/entry/src/ohosTest/js/default/pages/index/index.hml b/DialogDemo/entry/src/ohosTest/js/default/pages/index/index.hml deleted file mode 100644 index f64b040a5ae394dbaa5e185e1ecd4f4556b92184..0000000000000000000000000000000000000000 --- a/DialogDemo/entry/src/ohosTest/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{ $t('strings.hello') }} {{ title }} - -
diff --git a/DialogDemo/entry/src/ohosTest/js/default/pages/index/index.js b/DialogDemo/entry/src/ohosTest/js/default/pages/index/index.js deleted file mode 100644 index 8be2df2479a8da755ed800ad70d2b6247e21b8a2..0000000000000000000000000000000000000000 --- a/DialogDemo/entry/src/ohosTest/js/default/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -import file from '@system.file' -import app from '@system.app' -import device from '@system.device' -import router from '@system.router' -import {Core, Constant, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - const reportExtend = new ReportExtend(file) - const instrumentLog = new InstrumentLog({ - 'id': 'report', - 'version': '1.0.3' - }) - core.addService('expect', expectExtend) - core.addService('report', reportExtend) - core.addService('report', instrumentLog) - core.init() - core.subscribeEvent('spec', instrumentLog) - core.subscribeEvent('suite', instrumentLog) - core.subscribeEvent('task', instrumentLog) - - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} \ No newline at end of file diff --git a/DialogDemo/entry/src/ohosTest/js/test/ExampleJsunit.test.js b/DialogDemo/entry/src/ohosTest/js/test/ExampleJsunit.test.js deleted file mode 100644 index b6d74caed96ddede98edd1bc9292f6568cd1cfd1..0000000000000000000000000000000000000000 --- a/DialogDemo/entry/src/ohosTest/js/test/ExampleJsunit.test.js +++ /dev/null @@ -1,10 +0,0 @@ -import app from '@system.app' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -describe('appInfoTest', function () { - it('app_info_test_001', 0, function () { - var info = app.getInfo() - expect(info.versionName).assertEqual('1.0') - expect(info.versionCode).assertEqual('3') - }) -}) \ No newline at end of file diff --git a/DialogDemo/entry/src/ohosTest/js/test/List.test.js b/DialogDemo/entry/src/ohosTest/js/test/List.test.js deleted file mode 100644 index 305eb5bb254cd4802afaffebe68fca2f9436159f..0000000000000000000000000000000000000000 --- a/DialogDemo/entry/src/ohosTest/js/test/List.test.js +++ /dev/null @@ -1 +0,0 @@ -require('./ExampleJsunit.test.js') \ No newline at end of file diff --git a/DialogDemo/entry/src/ohosTest/resources/base/element/string.json b/DialogDemo/entry/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index a684103ee4a87317cc17dd96b98fc3f6f644249f..0000000000000000000000000000000000000000 --- a/DialogDemo/entry/src/ohosTest/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "DialogDemo" - }, - { - "name": "mainability_description", - "value": "hap sample empty page" - } - ] -} diff --git a/DialogDemo/entry/src/ohosTest/resources/base/media/icon.png b/DialogDemo/entry/src/ohosTest/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/DialogDemo/entry/src/ohosTest/resources/base/media/icon.png and /dev/null differ diff --git a/DialogDemo/gradle/wrapper/gradle-wrapper.jar b/DialogDemo/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 490fda8577df6c95960ba7077c43220e5bb2c0d9..0000000000000000000000000000000000000000 Binary files a/DialogDemo/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/DialogDemo/gradle/wrapper/gradle-wrapper.properties b/DialogDemo/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index f59159e865d4b59feb1b8c44b001f62fc5d58df4..0000000000000000000000000000000000000000 --- a/DialogDemo/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/DistributeDatabaseDraw-master/LICENSE b/DistributeDatabaseDraw-master/LICENSE deleted file mode 100644 index 0d157f823e33378716f6abc657afe78e9b147793..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - Copyright (c) 2021 Huawei Device Co., Ltd. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -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/DistributeDatabaseDraw-master/README-NOTES.md b/DistributeDatabaseDraw-master/README-NOTES.md deleted file mode 100644 index ea23a13e3d4407d06cba3aa7155a23e5081b50b4..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/README-NOTES.md +++ /dev/null @@ -1,2 +0,0 @@ -1.0.0 -1.Initial version \ No newline at end of file diff --git a/DistributeDatabaseDraw-master/README.md b/DistributeDatabaseDraw-master/README.md deleted file mode 100644 index ae0c7f3db088260bed9a1c5213f6c100f4abcfcf..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# DistributeDatabaseDraw -简介 -• 多设备实时同步笔迹,也可撤回笔迹。 -• 它旨在帮助开发人员快速了解HarmonyOS应用程序开发,多屏协作交互和HarmonyOS分布式数据库和分布式设备启动与连接的经验。 -• 从项目创建、代码编写到编译、构造、部署和操作。 - -安装要求 -• 安装DevEco Studio -• 设置DevEco Studio开发环境。DevEco Studio开发环境需要连接到网络,以确保该正常使用。可以根据以下两种情况配置开发环境: - 1.如果您可以直接访问Internet,则只需下载HarmonyOS SDK - 2.如果网络无法直接访问Internet,则可以通过代理服务器进行访问 -• 生成密钥并申请证书 - -用户指南 -• 下载此项目 -• 打开HUAWEI DevEco Studio,单击File> Open选择此ComponentCodelab -• 单击Build> Build App(s)/Hap(s)>Build Debug Hap(s)以编译hap软件包 -• 单击Run> Run 'entry'以运行hap包 - -注意 -• 您可以选择在模拟器或真机上运行hap软件包。 -• 如果在真机上运行它,则需要在项目的File> Project Structure> Modules> Signing Configs中配置签名和证书信息。 - -许可 -请参阅LICENSE文件以获得更多信息。 - -What is it? -•Synchronize handwriting on multiple devices in real time or retrieve handwriting. -•It is designed to help developers quickly understand the experience of HarmonyOS application development, multi-screen collaborative interaction, and the startup and connection of HarmonyOS distributed databases and distributed devices.. -•From project creation, code writing, to compilation, construction, deployment and operation. - -Installation requirements -• Install DevEco Studio -• Set up the DevEco Studio development environment.The DevEco Studio development environment needs to depend on the network environment. It needs to be connected to the network to ensure the normal use of the tool.The development environment can be configured according to the following two situations - 1.If you can directly access the Internet, just download the HarmonyOS SDK - 2.If the network cannot access the Internet directly, it can be accessed through a proxy server -• Generate secret key and apply for certificate - -User guide -• Download this Project -• Open HUAWEI DevEco Studio, click File> Open> Then select and open this Project -• Click Build> Build App(s)/Hap(s)>Build Debug Hap(s) to compile the hap package -• Click Run> Run 'entry' to run the hap package - -Note -• You can choose to run the hap package on the simulator or the phone. -• If you run it on the phone, you need to configure the signature and certificate information in the project's File> Project Structure> Modules> Signing Configs. - -Licensing -Please see LICENSE for more info. - diff --git a/DistributeDatabaseDraw-master/build.gradle b/DistributeDatabaseDraw-master/build.gradle deleted file mode 100644 index bbb5d8b3bebfa3a7c406747c636f6dc51ab06748..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -apply plugin: 'com.huawei.ohos.app' - -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 5 - } -} - -buildscript { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } - dependencies { - classpath 'com.huawei.ohos:hap:2.4.2.5' - classpath 'com.huawei.ohos:decctest:1.0.0.6' - } -} - -allprojects { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } -} diff --git a/DistributeDatabaseDraw-master/entry/build.gradle b/DistributeDatabaseDraw-master/entry/build.gradle deleted file mode 100644 index 2b23a857051050a033db405463b5bca172d3f2d5..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/build.gradle +++ /dev/null @@ -1,26 +0,0 @@ -apply plugin: 'com.huawei.ohos.hap' -apply plugin: 'com.huawei.ohos.decctest' -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 5 - } - buildTypes { - release { - proguardOpt { - proguardEnabled false - rulesFiles 'proguard-rules.pro' - } - } - } - -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - testImplementation 'junit:junit:4.13' - ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' -} -decc { - supportType = ['html', 'xml'] -} diff --git a/DistributeDatabaseDraw-master/entry/libs/gson-2.8.0.jar b/DistributeDatabaseDraw-master/entry/libs/gson-2.8.0.jar deleted file mode 100644 index 1235f63816c5d04586f7a14e531f9c3c09ccf205..0000000000000000000000000000000000000000 Binary files a/DistributeDatabaseDraw-master/entry/libs/gson-2.8.0.jar and /dev/null differ diff --git a/DistributeDatabaseDraw-master/entry/src/main/config.json b/DistributeDatabaseDraw-master/entry/src/main/config.json deleted file mode 100644 index f027328fab74c1b97bb4ce7731a6cd9dd39e9912..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/config.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "app": { - "bundleName": "com.huawei.codelab", - "vendor": "huawei", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.huawei.codelab", - "name": ".MyApplication", - "deviceType": [ - "phone" - ], - "metaData": { - "customizeData": [ - { - "name": "hwc-theme", - "value": "androidhwext:style/Theme.Emui.NoTitleBar", - "extra": "" - } - ] - }, - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry" - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "orientation": "unspecified", - "name": "com.huawei.codelab.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard" - } - ], - "reqPermissions": [ - { - "reason": "多设备协同", - "name": "ohos.permission.DISTRIBUTED_DATASYNC", - "usedScene": { - "ability": [ - "MainAbility" - ], - "when": "always" - } - }, - { - "name": "ohos.permission.DISTRIBUTED_DATASYNC " - }, - { - "name": "ohos.permission.DISTRIBUTED_DEVICE_STATE_CHANGE" - }, - { - "name": "ohos.permission.GET_DISTRIBUTED_DEVICE_INFO" - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO" - } - ] - } -} \ No newline at end of file diff --git a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/MyApplication.java b/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/MyApplication.java deleted file mode 100644 index 71be9ff74776c2eba1461abd0cfcbb84ace64a20..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/MyApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab; - -import ohos.aafwk.ability.AbilityPackage; - -/** - * MyApplication - * - * @since 2021-04-06 - */ -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/bean/DeviceData.java b/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/bean/DeviceData.java deleted file mode 100644 index 677cca055e1718ef59a9ee63645ca4cffce37a2c..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/bean/DeviceData.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.bean; - -import ohos.distributedschedule.interwork.DeviceInfo; - -/** - * DeviceData - * - * @since 2021-04-06 - */ -public class DeviceData { - private boolean isChecked; - private DeviceInfo deviceInfo; - - /** - * device information - * - * @param isChecked isChecked - * @param deviceInfo deviceInfo - */ - public DeviceData(boolean isChecked, DeviceInfo deviceInfo) { - this.isChecked = isChecked; - this.deviceInfo = deviceInfo; - } - - public DeviceInfo getDeviceInfo() { - return deviceInfo; - } - - public void setDeviceInfo(DeviceInfo deviceInfo) { - this.deviceInfo = deviceInfo; - } - - public boolean isChecked() { - return isChecked; - } - - public void setChecked(boolean checked) { - isChecked = checked; - } -} diff --git a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/bean/MyPoint.java b/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/bean/MyPoint.java deleted file mode 100644 index 43985e3996d917b388070984310c52437ace3f5a..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/bean/MyPoint.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.bean; - -import ohos.agp.utils.Color; - -/** - * point entity - * - * @since 2021-04-06 - */ -public class MyPoint extends ohos.agp.utils.Point { - private float positionX; - private float positionY; - private boolean isLastPoint = false; - private Color paintColor; - - /** - * constructor - * - * @param positionX x - * @param positionY y - */ - public MyPoint(float positionX, float positionY) { - super(); - this.positionX = positionX; - this.positionY = positionY; - } - - public float getPositionX() { - return positionX; - } - - public float getPositionY() { - return positionY; - } - - public boolean isLastPoint() { - return isLastPoint; - } - - public void setLastPoint(boolean lastPoint) { - isLastPoint = lastPoint; - } - - public Color getPaintColor() { - return paintColor; - } - - public void setPaintColor(Color paintColor) { - this.paintColor = paintColor; - } -} diff --git a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/component/DeviceSelectDialog.java b/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/component/DeviceSelectDialog.java deleted file mode 100644 index 425b331b1135a688f73facf06d2a3289e430d48b..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/component/DeviceSelectDialog.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.component; - -import com.huawei.codelab.ResourceTable; -import com.huawei.codelab.bean.DeviceData; -import com.huawei.codelab.component.listcomponent.CommentViewHolder; -import com.huawei.codelab.component.listcomponent.ListComponentAdapter; - -import ohos.agp.components.Component; -import ohos.agp.components.LayoutScatter; -import ohos.agp.components.ListContainer; -import ohos.agp.components.Text; -import ohos.agp.utils.LayoutAlignment; -import ohos.agp.window.dialog.CommonDialog; -import ohos.app.Context; -import ohos.distributedschedule.interwork.DeviceInfo; -import ohos.distributedschedule.interwork.DeviceManager; - -import java.util.ArrayList; -import java.util.List; - -import static ohos.agp.components.ComponentContainer.LayoutConfig.MATCH_CONTENT; -import static ohos.agp.components.ComponentContainer.LayoutConfig.MATCH_PARENT; - -/** - * DeviceSelectDialog - * - * @since 2021-04-06 - */ -public class DeviceSelectDialog extends CommonDialog { - private static final int CORNER_RADIUS = 10; - private ListContainer listContainer; - private Context context; - private OnclickListener onclickListener; - private List deviceList = new ArrayList<>(); - private List checkedDeviceIds = new ArrayList<>(); - private ListComponentAdapter listComponentAdapter; - private Text operateConfirm; - private Text operateCancel; - - /** - * Interfaces for setting the OK button and canceling clicks - */ - public interface OnclickListener { - /** - * Used for interface callback. - * - * @param deviceIds deviceIds - */ - void onConfirmClick(List deviceIds); - } - - /** - * setListener - * - * @param context context - */ - public DeviceSelectDialog(Context context) { - super(context); - this.context = context; - } - - /** - * setListener - * - * @param listener listener - */ - public void setListener(OnclickListener listener) { - onclickListener = listener; - } - - @Override - protected void onCreate() { - super.onCreate(); - initView(); - setAdapter(); - } - - private void initView() { - Component rootView = LayoutScatter.getInstance(context) - .parse(ResourceTable.Layout_dialog_layout_device, null, false); - if (rootView.findComponentById(ResourceTable.Id_list_container_device) instanceof ListContainer) { - listContainer = (ListContainer) rootView.findComponentById(ResourceTable.Id_list_container_device); - } - if (rootView.findComponentById(ResourceTable.Id_operate_yes) instanceof Text) { - operateConfirm = (Text) rootView.findComponentById(ResourceTable.Id_operate_yes); - } - if (rootView.findComponentById(ResourceTable.Id_operate_no) instanceof Text) { - operateCancel = (Text) rootView.findComponentById(ResourceTable.Id_operate_no); - } - setSize(MATCH_PARENT, MATCH_CONTENT); - setAlignment(LayoutAlignment.BOTTOM); - setCornerRadius(CORNER_RADIUS); - setAutoClosable(true); - setContentCustomComponent(rootView); - setTransparent(true); - componentBonding(); - } - - private void componentBonding() { - operateConfirm.setClickedListener(component -> { - if (onclickListener != null) { - checkedDeviceIds.clear(); - cirDevice(); - } - }); - operateCancel.setClickedListener(component -> { - hide(); - }); - } - - private void cirDevice() { - for (DeviceData deviceData : deviceList) { - if (deviceData.isChecked()) { - checkedDeviceIds.add(deviceData.getDeviceInfo().getDeviceId()); - } - } - onclickListener.onConfirmClick(checkedDeviceIds); - } - - private void setAdapter() { - List deviceInfoList = DeviceManager.getDeviceList(DeviceInfo.FLAG_GET_ONLINE_DEVICE); - deviceList.clear(); - for (DeviceInfo deviceInfo : deviceInfoList) { - deviceList.add(new DeviceData(false, deviceInfo)); - } - listContainer.setItemProvider(listComponentAdapter = - new ListComponentAdapter(context, deviceList, ResourceTable.Layout_dialog_device_item) { - @Override - public void onBindViewHolder(CommentViewHolder commonViewHolder, DeviceData item, int position) { - commonViewHolder.getTextView(ResourceTable.Id_item_desc) - .setText(item.getDeviceInfo().getDeviceName()); - switch (item.getDeviceInfo().getDeviceType()) { - case SMART_PHONE: - commonViewHolder.getImageView(ResourceTable.Id_item_type) - .setPixelMap(ResourceTable.Media_dv_phone); - break; - case SMART_PAD: - commonViewHolder.getImageView(ResourceTable.Id_item_type) - .setPixelMap(ResourceTable.Media_dv_pad); - break; - case SMART_WATCH: - commonViewHolder.getImageView(ResourceTable.Id_item_type) - .setPixelMap(ResourceTable.Media_dv_watch); - break; - default: - break; - } - commonViewHolder.getImageView(ResourceTable.Id_item_check).setPixelMap(item.isChecked() - ? ResourceTable.Media_checked_point : ResourceTable.Media_uncheck_point); - } - - @Override - public void onItemClick(Component component, DeviceData item, int position) { - super.onItemClick(component, item, position); - deviceList.get(position).setChecked(!item.isChecked()); - listComponentAdapter.notifyDataChanged(); - } - }); - } -} diff --git a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/component/DrawPoint.java b/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/component/DrawPoint.java deleted file mode 100644 index 698d03186c6fbdc5df94f619e763afc29cc93fa2..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/component/DrawPoint.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.component; - -import com.huawei.codelab.bean.MyPoint; - -import ohos.agp.components.Component; -import ohos.agp.render.Canvas; -import ohos.agp.render.Paint; -import ohos.agp.utils.Color; -import ohos.agp.utils.Point; -import ohos.app.Context; -import ohos.eventhandler.EventHandler; -import ohos.eventhandler.EventRunner; -import ohos.eventhandler.InnerEvent; -import ohos.multimodalinput.event.TouchEvent; - -import java.util.ArrayList; -import java.util.List; -import java.util.Timer; -import java.util.TimerTask; - -/** - * Drawl - * - * @since 2021-04-06 - */ -public class DrawPoint extends Component implements Component.DrawTask { - private static final String TAG = "DrawPoint"; - private static final int STROKE_WIDTH = 15; - private static final int TIME = 200; - private static final int ITEM_HEIGHT = 200; - private static final int EVENT_MSG_STORE = 0x1000002; - private List points = new ArrayList<>(); - private Paint paint; - private OnDrawCallBack callBack; - private Color[] paintColors = new Color[]{Color.RED, Color.BLUE, Color.BLACK}; - private Timer timer = null; - private TimerTask timerTask = null; - - private EventHandler handler = new EventHandler(EventRunner.current()) { - @Override - protected void processEvent(InnerEvent event) { - switch (event.eventId) { - case EVENT_MSG_STORE: - callBack.callBack(points); - break; - default: - break; - } - } - }; - - public List getPoints() { - return points; - } - - /** - * SelectResult - * - * @since 2020-12-03 - */ - public interface OnDrawCallBack { - /** - * touchListener - * - * @param points points - */ - void callBack(List points); - } - - /** - * Drawl constructor - * - * @param context context - * @param colorIndex colorIndex - */ - public DrawPoint(Context context, int colorIndex) { - super(context); - init(colorIndex); - } - - /** - * setPoints - * - * @param points points - */ - public void setDrawParams(List points) { - this.points = points; - invalidate(); - } - - /** - * setOnDrawBack - * - * @param callBack callBack - */ - public void setOnDrawBack(OnDrawCallBack callBack) { - this.callBack = callBack; - } - - private void init(int colorIndex) { - paint = new Paint(); - paint.setAntiAlias(true); - paint.setStyle(Paint.Style.STROKE_STYLE); - paint.setStrokeWidth(STROKE_WIDTH); - addDrawTask(this); - Color color = getRandomColor(colorIndex); - - setTouchEventListener((component, touchEvent) -> { - scheduledTask(); - int crtX = (int) touchEvent.getPointerPosition(touchEvent.getIndex()).getX(); - int crtY = (int) touchEvent.getPointerPosition(touchEvent.getIndex()).getY() - ITEM_HEIGHT; - - MyPoint point = new MyPoint(crtX, crtY); - point.setPaintColor(color); - - switch (touchEvent.getAction()) { - case TouchEvent.POINT_MOVE: - points.add(point); - break; - case TouchEvent.PRIMARY_POINT_UP: - points.add(point); - point.setLastPoint(true); - callBack.callBack(points); - onTimerFinish(); - break; - default: - break; - } - invalidate(); - return true; - }); - } - - /** - * scheduled task start - */ - public void scheduledTask() { - if (timer == null && timerTask == null) { - timer = new Timer(); - timerTask = new TimerTask() { - @Override - public void run() { - handler.sendEvent(EVENT_MSG_STORE); - } - }; - timer.schedule(timerTask, 0, TIME); - } - } - - /** - * Canceling a Scheduled Task - */ - public void onTimerFinish() { - timer.cancel(); - timer = null; - timerTask = null; - } - - @Override - public void onDraw(Component component, Canvas canvas) { - draw(points, canvas); - } - - private void draw(List points, Canvas canvas) { - if (points == null || points.size() <= 1) { - return; - } - Point first = null; - Point last = null; - for (MyPoint myPoint : points) { - paint.setColor(myPoint.getPaintColor()); - float finalX = myPoint.getPositionX(); - float finalY = myPoint.getPositionY(); - Point finalPoint = new Point(finalX, finalY); - if (myPoint.isLastPoint()) { - first = null; - last = null; - continue; - } - if (first == null) { - first = finalPoint; - } else { - if (last != null) { - first = last; - } - last = finalPoint; - canvas.drawLine(first, last, paint); - } - } - } - - private Color getRandomColor(int index) { - return index > paintColors.length - 1 ? paintColors[0] : paintColors[index]; - } -} \ No newline at end of file diff --git a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/component/listcomponent/CommentViewHolder.java b/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/component/listcomponent/CommentViewHolder.java deleted file mode 100644 index 749e7a7381c9a8249246252abe32f266fe24b60c..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/component/listcomponent/CommentViewHolder.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.component.listcomponent; - -import ohos.agp.components.Component; -import ohos.agp.components.Image; -import ohos.agp.components.LayoutScatter; -import ohos.agp.components.Text; -import ohos.app.Context; - -import java.util.HashMap; -import java.util.Map; - -/** - * CommentViewHolder - * - * @since 2021-04-06 - */ -public class CommentViewHolder { - Component convertView; - private Map mViews = new HashMap<>(); - - // Avoiding Multiple Static Classes Using Singleton Mode - static CommentViewHolder getCommentViewHolder(Context context, Component convertView, int resource) { - if (convertView == null) { - Component creatConvertView = LayoutScatter.getInstance(context).parse(resource, null, false); - return new CommentViewHolder(creatConvertView); - } else { - return (CommentViewHolder) convertView.getTag(); - } - } - - private CommentViewHolder(Component convertView) { - this.convertView = convertView; - convertView.setTag(this); - } - - /** - * Obtain the corresponding control from the collection based on the resource ID of the control in the XML file - * - * @param resId int - * @param generic - * @return view - */ - public T getView(int resId) { - Component view = mViews.get(resId); - if (view == null) { - view = convertView.findComponentById(resId); - mViews.put(resId, view); - } - return (T) view; - } - - /** - * Specify the type of view based on the generic - * - * @param resId int - * @param type Class - * @param generic - * @return view - */ - private T getView(int resId, Class type) { - Component view = mViews.get(resId); - if (view == null) { - view = convertView.findComponentById(resId); - mViews.put(resId, view); - } - return (T) view; - } - - /** - * Two common views, which are provided for external systems - * - * @param resId int - * @return Text - */ - public Text getTextView(int resId) { - return getView(resId, Text.class); - } - - /** - * getImageView - * - * @param resId int - * @return Image - */ - public Image getImageView(int resId) { - return getView(resId, Image.class); - } -} diff --git a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/component/listcomponent/ListComponentAdapter.java b/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/component/listcomponent/ListComponentAdapter.java deleted file mode 100644 index a48bf7f857e5de436e96a5dacb0ea254954b2986..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/component/listcomponent/ListComponentAdapter.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.component.listcomponent; - -import ohos.agp.components.BaseItemProvider; -import ohos.agp.components.Component; -import ohos.agp.components.ComponentContainer; -import ohos.app.Context; - -import java.util.List; - -/** - * ListComponentAdapter - * - * @since 2021-04-06 - */ -public abstract class ListComponentAdapter extends BaseItemProvider { - private Context mContext; - private List mListBean; - private int mXmlId; - - protected ListComponentAdapter(Context context, List list, int xmlId) { - this.mContext = context; - this.mListBean = list; - this.mXmlId = xmlId; - } - - /** - * onBindViewHolder - * - * @param commonViewHolder CommentViewHolder - * @param item T - * @param position int - */ - public abstract void onBindViewHolder(CommentViewHolder commonViewHolder, T item, int position); - - @Override - public int getCount() { - return mListBean.size(); - } - - @Override - public T getItem(int var1) { - return mListBean.get(var1); - } - - @Override - public long getItemId(int var2) { - return var2; - } - - @Override - public Component getComponent(int var1, Component component, ComponentContainer componentContainer) { - CommentViewHolder commentViewHolder = CommentViewHolder.getCommentViewHolder(mContext, component, mXmlId); - T var2 = mListBean.get(var1); - onBindViewHolder(commentViewHolder, var2, var1); - commentViewHolder.convertView.setClickedListener(component1 -> onItemClick(component, var2, var1)); - return commentViewHolder.convertView; - } - - /** - * onItemClick - * - * @param component Component - * @param item item - * @param position int - */ - public void onItemClick(Component component, T item, int position) { - } -} diff --git a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/slice/MainAbilitySlice.java b/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/slice/MainAbilitySlice.java deleted file mode 100644 index bc4af81d7698771d51b076358c486bf726f598ef..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/slice/MainAbilitySlice.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.slice; - -import java.util.List; - -import com.huawei.codelab.MainAbility; -import com.huawei.codelab.ResourceTable; -import com.huawei.codelab.bean.MyPoint; -import com.huawei.codelab.component.DeviceSelectDialog; -import com.huawei.codelab.component.DrawPoint; -import com.huawei.codelab.util.GsonUtil; -import com.huawei.codelab.util.LogUtils; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.aafwk.content.Operation; -import ohos.agp.components.Button; -import ohos.agp.components.DependentLayout; -import ohos.agp.components.Image; -import ohos.agp.components.Text; -import ohos.agp.components.Component; -import ohos.bundle.IBundleManager; -import ohos.data.distributed.common.ChangeNotification; -import ohos.data.distributed.common.Entry; -import ohos.data.distributed.common.KvManager; -import ohos.data.distributed.common.KvManagerConfig; -import ohos.data.distributed.common.KvManagerFactory; -import ohos.data.distributed.common.KvStoreObserver; -import ohos.data.distributed.common.KvStoreType; -import ohos.data.distributed.common.Options; -import ohos.data.distributed.common.SubscribeType; -import ohos.data.distributed.common.SyncMode; -import ohos.data.distributed.user.SingleKvStore; - -import static ohos.agp.components.ComponentContainer.LayoutConfig.MATCH_PARENT; -import static ohos.security.SystemPermission.DISTRIBUTED_DATASYNC; - -/** - * MainAbilitySlice - * - * @since 2021-04-06 - */ -public class MainAbilitySlice extends AbilitySlice { - private static final String TAG = MainAbilitySlice.class.getName(); - private static final String STORE_ID = "testApp"; - private static final int PERMISSION_CODE = 20201203; - private static final int DELAY_TIME = 10; - private DependentLayout canvas; - private Image transform; - private KvManager kvManager; - private SingleKvStore singleKvStore; - private Text title; - private DrawPoint drawl; - private Button back; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setUIContent(ResourceTable.Layout_ability_main); - findComponentById(); - requestPermission(); - initDatabase(); - initDraw(intent); - initView(intent); - } - - private void initView(Intent intent) { - boolean isLocal = !intent.getBooleanParam("isFormLocal", false); - title.setText(isLocal ? "本地端" : "远程端"); - transform.setVisibility(isLocal ? Component.VISIBLE : Component.INVISIBLE); - } - - private void requestPermission() { - if (verifySelfPermission(DISTRIBUTED_DATASYNC) != IBundleManager.PERMISSION_GRANTED) { - if (canRequestPermission(DISTRIBUTED_DATASYNC)) { - requestPermissionsFromUser(new String[]{DISTRIBUTED_DATASYNC}, PERMISSION_CODE); - } - } - } - - private void findComponentById() { - if (findComponentById(ResourceTable.Id_canvas) instanceof DependentLayout) { - canvas = (DependentLayout) findComponentById(ResourceTable.Id_canvas); - } - if (findComponentById(ResourceTable.Id_transform) instanceof Image) { - transform = (Image) findComponentById(ResourceTable.Id_transform); - } - if (findComponentById(ResourceTable.Id_title) instanceof Text) { - title = (Text) findComponentById(ResourceTable.Id_title); - } - if (findComponentById(ResourceTable.Id_back) instanceof Button) { - back = (Button) findComponentById(ResourceTable.Id_back); - } - transform.setClickedListener(component -> { - DeviceSelectDialog dialog = new DeviceSelectDialog(MainAbilitySlice.this); - dialog.setListener(deviceIds -> { - if (deviceIds != null && !deviceIds.isEmpty()) { - startRemoteFas(deviceIds); - singleKvStore.sync(deviceIds, SyncMode.PUSH_ONLY); - } - dialog.hide(); - }); - dialog.show(); - }); - } - - /** - * Initialize artboards - * - * @param intent Intent - */ - private void initDraw(Intent intent) { - int colorIndex = intent.getIntParam("colorIndex", 0); - drawl = new DrawPoint(this, colorIndex); - drawl.setWidth(MATCH_PARENT); - drawl.setWidth(MATCH_PARENT); - canvas.addComponent(drawl); - drawl.setOnDrawBack(points -> { - if (points != null && points.size() > 1) { - String pointsString = GsonUtil.objectToString(points); - LogUtils.info(TAG, "pointsString::" + pointsString); - if (singleKvStore != null) { - singleKvStore.putString("points", pointsString); - } - } - }); - back.setClickedListener(component -> { - List points = drawl.getPoints(); - if (points == null || points.size() <= 1) { - return; - } - points.remove(points.size() - 1); - for (int i = points.size() - 1; i >= 0; i--) { - if (points.get(i).isLastPoint()) { - break; - } - points.remove(i); - } - drawl.setDrawParams(points); - String pointsString = GsonUtil.objectToString(points); - if (singleKvStore != null) { - singleKvStore.putString("points", pointsString); - } - }); - } - - class KvStoreObserverClient implements KvStoreObserver { - @Override - public void onChange(ChangeNotification notification) { - List insertEntries = notification.getInsertEntries(); - List updateEntries = notification.getUpdateEntries(); - List deleteEntries = notification.getDeleteEntries(); - LogUtils.info(TAG, "data changed......"); - for (Entry entry : updateEntries) { - if ("points".equals(entry.getKey())) { - List remotePoints = GsonUtil.jsonToList(entry.getValue().getString(), MyPoint.class); - LogUtils.info(TAG, "Entry entry : insertEntries......"); - getUITaskDispatcher().delayDispatch(() -> drawl.setDrawParams(remotePoints), DELAY_TIME); - } - } - } - } - - private void initDatabase() { - // Creating Distributed Database Management Objects - KvManagerConfig config = new KvManagerConfig(this); - kvManager = KvManagerFactory.getInstance().createKvManager(config); - // Creating a Distributed Database - Options options = new Options(); - options.setCreateIfMissing(true).setEncrypt(false).setKvStoreType(KvStoreType.SINGLE_VERSION); - singleKvStore = kvManager.getKvStore(options, STORE_ID); - // Subscribe to distributed data changes - KvStoreObserver kvStoreObserverClient = new KvStoreObserverClient(); - singleKvStore.subscribe(SubscribeType.SUBSCRIBE_TYPE_ALL, kvStoreObserverClient); - } - - /** - * Starting Multiple Remote Fas - * - * @param deviceIds deviceIds - */ - private void startRemoteFas(List deviceIds) { - Intent[] intents = new Intent[deviceIds.size()]; - for (int i = 0; i < deviceIds.size(); i++) { - Intent intent = new Intent(); - intent.setParam("isFormLocal", true); - intent.setParam("colorIndex", i + 1); - Operation operation = new Intent.OperationBuilder() - .withDeviceId(deviceIds.get(i)) - .withBundleName(getBundleName()) - .withAbilityName(MainAbility.class.getName()) - .withFlags(Intent.FLAG_ABILITYSLICE_MULTI_DEVICE) - .build(); - intent.setOperation(operation); - intents[i] = intent; - } - startAbilities(intents); - } - - @Override - protected void onStop() { - super.onStop(); - kvManager.closeKvStore(singleKvStore); - } -} diff --git a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/util/GsonUtil.java b/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/util/GsonUtil.java deleted file mode 100644 index e0dfb8f33854c2168fdda72ccd1ab9757b723bc9..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/util/GsonUtil.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.util; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import com.google.gson.reflect.TypeToken; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * GsonUtil - * - * @since 2021-04-06 - */ -public class GsonUtil { - private static Gson gson = null; - - static { - gson = new Gson(); - } - - public GsonUtil() { - } - - /** - * Converts an object into a JSON character string - * - * @param object Object - * @return jsonString - */ - public static String objectToString(Object object) { - String jsonString = null; - if (gson != null) { - jsonString = gson.toJson(object); - } - return jsonString; - } - - /** - * Converting gsonString to Generic Beans - * - * @param jsonString jsonString - * @param cls Class - * @return t - */ - public static T jsonToBean(String jsonString, Class cls) { - T var1 = null; - if (gson != null) { - var1 = gson.fromJson(jsonString, cls); - } - return var1; - } - - /** - * Converting to List to Solve Generic Problems - * - * @param json json - * @param cls cls - * @param generic - * @return list - */ - public static List jsonToList(String json, Class cls) { - List list = new ArrayList(); - JsonArray array = new JsonParser().parse(json).getAsJsonArray(); - for (final JsonElement elem : array) { - list.add(gson.fromJson(elem, cls)); - } - return list; - } - - /** - * Convert to a list with a map - * - * @param gsonString String - * @return list List - */ - public static List> jsonToListMaps(String gsonString) { - List> list = null; - if (gson != null) { - list = gson.fromJson(gsonString, - new TypeToken>>() { - }.getType()); - } - return list; - } - - /** - * Converted to map - * - * @param gsonString String - * @return map Map - */ - public static Map jsonToMaps(String gsonString) { - Map map = null; - if (gson != null) { - map = gson.fromJson(gsonString, new TypeToken>() { - }.getType()); - } - return map; - } -} \ No newline at end of file diff --git a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/util/LogUtils.java b/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/util/LogUtils.java deleted file mode 100644 index a218b626e39dbf6655efa1fd347da2eb6f46088a..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/util/LogUtils.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.util; - -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; - -/** - * LogUtils - * - * @since 2021-04-06 - */ -public class LogUtils { - private static final String TAG_LOG = "LogUtil"; - - private static final int DOMAIN_ID = 0xD000F00; - - private static final HiLogLabel LABEL_LOG = new HiLogLabel(0, 0, LogUtils.TAG_LOG); - - private static final String LOG_FORMAT = "%{public}s: %{public}s"; - - private LogUtils() { - } - - /** - * Print debug log - * - * @param tag log tag - * @param msg log message - */ - public static void debug(String tag, String msg) { - HiLog.debug(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print info log - * - * @param tag log tag - * @param msg log message - */ - public static void info(String tag, String msg) { - HiLog.info(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print warn log - * - * @param tag log tag - * @param msg log message - */ - public static void warn(String tag, String msg) { - HiLog.warn(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print error log - * - * @param tag log tag - * @param msg log message - */ - public static void error(String tag, String msg) { - HiLog.error(LABEL_LOG, LOG_FORMAT, tag, msg); - } -} diff --git a/DistributeDatabaseDraw-master/entry/src/main/resources/base/element/string.json b/DistributeDatabaseDraw-master/entry/src/main/resources/base/element/string.json deleted file mode 100644 index afb7ca1da70a612e812b501eaf7bade1574b91f5..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "DistributeDatabaseDraw" - }, - { - "name": "mainability_description", - "value": "Java_Phone_Empty Feature Ability" - }, - { - "name": "HelloWorld", - "value": "Hello World" - } - ] -} \ No newline at end of file diff --git a/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/background_ability_main.xml b/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/background_ability_main.xml deleted file mode 100644 index 90a82183b4b7d43c4a010873bfc5015701a7e061..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/background_ability_main.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - \ No newline at end of file diff --git a/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/background_card.xml b/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/background_card.xml deleted file mode 100644 index 0cafd64b478b33e400a867b81a40a5cdb9133612..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/background_card.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/background_white_radius_10.xml b/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/background_white_radius_10.xml deleted file mode 100644 index 9b066afd7028cd5ec087f34ce5471d42beb8f0aa..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/background_white_radius_10.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/button_normal.xml b/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/button_normal.xml deleted file mode 100644 index b3d4d5802e2f150b351628157eb419e8945a89f5..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/button_normal.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/button_pressed.xml b/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/button_pressed.xml deleted file mode 100644 index 17a2860029202444fb835ba02065fb9abf393354..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/button_pressed.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/button_selector.xml b/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/button_selector.xml deleted file mode 100644 index 11569697730deab0478cdbdaf832cd828636de9d..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/resources/base/graphic/button_selector.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - \ No newline at end of file diff --git a/DistributeDatabaseDraw-master/entry/src/main/resources/base/layout/ability_main.xml b/DistributeDatabaseDraw-master/entry/src/main/resources/base/layout/ability_main.xml deleted file mode 100644 index 53612d65d166ff5887b7f4ac92584a295a05a5d4..0000000000000000000000000000000000000000 --- a/DistributeDatabaseDraw-master/entry/src/main/resources/base/layout/ability_main.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/EducationSystem/entry/src/main/resources/base/layout/ability_picture.xml b/EducationSystem/entry/src/main/resources/base/layout/ability_picture.xml deleted file mode 100644 index f4df888d5c41c36c2cec7ed562c5cd80fb965692..0000000000000000000000000000000000000000 --- a/EducationSystem/entry/src/main/resources/base/layout/ability_picture.xml +++ /dev/null @@ -1,186 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/EducationSystem/entry/src/main/resources/base/layout/dialog_select_device.xml b/EducationSystem/entry/src/main/resources/base/layout/dialog_select_device.xml deleted file mode 100644 index 1857f58580555412143d50b2ace9ad36c6e7d317..0000000000000000000000000000000000000000 --- a/EducationSystem/entry/src/main/resources/base/layout/dialog_select_device.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/EducationSystem/entry/src/main/resources/base/layout/item_device_list.xml b/EducationSystem/entry/src/main/resources/base/layout/item_device_list.xml deleted file mode 100644 index 2677b9548ec6882d5c407516aabda69b4a017910..0000000000000000000000000000000000000000 --- a/EducationSystem/entry/src/main/resources/base/layout/item_device_list.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/EducationSystem/entry/src/main/resources/base/layout/math_draw.xml b/EducationSystem/entry/src/main/resources/base/layout/math_draw.xml deleted file mode 100644 index 4e9d1c266595f3f62c62431f58fb96f3f6080bc9..0000000000000000000000000000000000000000 --- a/EducationSystem/entry/src/main/resources/base/layout/math_draw.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/EducationSystem/entry/src/main/resources/base/layout/math_game.xml b/EducationSystem/entry/src/main/resources/base/layout/math_game.xml deleted file mode 100644 index 7e2a252460a136293ccf6e5edb5d1445dcaa971c..0000000000000000000000000000000000000000 --- a/EducationSystem/entry/src/main/resources/base/layout/math_game.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/EducationSystem/entry/src/main/resources/base/media/device.png b/EducationSystem/entry/src/main/resources/base/media/device.png deleted file mode 100644 index 5100a32ade3589466166e57b1f6f0944c321294e..0000000000000000000000000000000000000000 Binary files a/EducationSystem/entry/src/main/resources/base/media/device.png and /dev/null differ diff --git a/EducationSystem/entry/src/main/resources/base/media/icon.png b/EducationSystem/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/EducationSystem/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/EducationSystem/entry/src/main/resources/base/media/picture.jpg b/EducationSystem/entry/src/main/resources/base/media/picture.jpg deleted file mode 100644 index 4a06044f4f1fe2f10d9769f51625cb3d2f68d833..0000000000000000000000000000000000000000 Binary files a/EducationSystem/entry/src/main/resources/base/media/picture.jpg and /dev/null differ diff --git a/EducationSystem/entry/src/main/resources/base/media/picture_01.png b/EducationSystem/entry/src/main/resources/base/media/picture_01.png deleted file mode 100644 index 5c01205b0a5be8cf564a9569baf69449eea7a378..0000000000000000000000000000000000000000 Binary files a/EducationSystem/entry/src/main/resources/base/media/picture_01.png and /dev/null differ diff --git a/EducationSystem/entry/src/main/resources/base/media/picture_02.png b/EducationSystem/entry/src/main/resources/base/media/picture_02.png deleted file mode 100644 index f9d75f08c87a7538f66baba6468eb421db3fc485..0000000000000000000000000000000000000000 Binary files a/EducationSystem/entry/src/main/resources/base/media/picture_02.png and /dev/null differ diff --git a/EducationSystem/entry/src/main/resources/base/media/picture_03.png b/EducationSystem/entry/src/main/resources/base/media/picture_03.png deleted file mode 100644 index 6a176e662bdeeadc4bb83462d52b0f6983c40f54..0000000000000000000000000000000000000000 Binary files a/EducationSystem/entry/src/main/resources/base/media/picture_03.png and /dev/null differ diff --git a/EducationSystem/entry/src/main/resources/base/media/picture_04.png b/EducationSystem/entry/src/main/resources/base/media/picture_04.png deleted file mode 100644 index 959f764fa712c162a3bfecb3ce48e88523404668..0000000000000000000000000000000000000000 Binary files a/EducationSystem/entry/src/main/resources/base/media/picture_04.png and /dev/null differ diff --git a/EducationSystem/entry/src/main/resources/base/media/picture_05.png b/EducationSystem/entry/src/main/resources/base/media/picture_05.png deleted file mode 100644 index aee1f9bcb4d0eeca8cb6f5b8ae6d217eaaa034a7..0000000000000000000000000000000000000000 Binary files a/EducationSystem/entry/src/main/resources/base/media/picture_05.png and /dev/null differ diff --git a/EducationSystem/entry/src/main/resources/base/media/picture_06.png b/EducationSystem/entry/src/main/resources/base/media/picture_06.png deleted file mode 100644 index 3c54b2336a5c8c7a2d4d7f2ffde4623561a105d6..0000000000000000000000000000000000000000 Binary files a/EducationSystem/entry/src/main/resources/base/media/picture_06.png and /dev/null differ diff --git a/EducationSystem/entry/src/main/resources/base/media/picture_07.png b/EducationSystem/entry/src/main/resources/base/media/picture_07.png deleted file mode 100644 index a2b03f8832ae7c01cdab0818f0e34435ce3c76ca..0000000000000000000000000000000000000000 Binary files a/EducationSystem/entry/src/main/resources/base/media/picture_07.png and /dev/null differ diff --git a/EducationSystem/entry/src/main/resources/base/media/picture_08.png b/EducationSystem/entry/src/main/resources/base/media/picture_08.png deleted file mode 100644 index 180c1aedda3a5dae43319d1001db0f40466dd255..0000000000000000000000000000000000000000 Binary files a/EducationSystem/entry/src/main/resources/base/media/picture_08.png and /dev/null differ diff --git a/EducationSystem/entry/src/main/resources/base/media/picture_09.png b/EducationSystem/entry/src/main/resources/base/media/picture_09.png deleted file mode 100644 index aa99620777e299d8dd62c7a6f2b44e5f2ae3a618..0000000000000000000000000000000000000000 Binary files a/EducationSystem/entry/src/main/resources/base/media/picture_09.png and /dev/null differ diff --git a/EducationSystem/entry/src/test/java/com/huawei/codelab/ExampleTest.java b/EducationSystem/entry/src/test/java/com/huawei/codelab/ExampleTest.java deleted file mode 100644 index 325c8beecee33310f8b9197bbd9653c26fed979a..0000000000000000000000000000000000000000 --- a/EducationSystem/entry/src/test/java/com/huawei/codelab/ExampleTest.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.huawei.codelab; - -import org.junit.Test; - -public class ExampleTest { - @Test - public void onStart() { - } -} diff --git a/EducationSystem/gradle/wrapper/gradle-wrapper.jar b/EducationSystem/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f6b961fd5a86aa5fbfe90f707c3138408be7c718..0000000000000000000000000000000000000000 Binary files a/EducationSystem/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/EducationSystem/gradle/wrapper/gradle-wrapper.properties b/EducationSystem/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index f59159e865d4b59feb1b8c44b001f62fc5d58df4..0000000000000000000000000000000000000000 --- a/EducationSystem/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/EducationSystem/settings.gradle b/EducationSystem/settings.gradle deleted file mode 100644 index 4773db73233a570c2d0c01a22e75321acfbf7a07..0000000000000000000000000000000000000000 --- a/EducationSystem/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':entry' diff --git a/HarmonyOSNewsClient/LICENSE b/HarmonyOSNewsClient/LICENSE deleted file mode 100644 index 386f8b9374099acb177755d48a47adbe1ab99f4f..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/LICENSE +++ /dev/null @@ -1,99 +0,0 @@ - Copyright (c) 2021 Huawei Device Co., Ltd. - - Licensed under the Apache License,Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - We use Google's open-source Gson.jar. The details are as follows: - - ### License - - Gson is released under the [Apache 2.0 license](LICENSE). - - Copyright 2008 Google Inc. - - 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/HarmonyOSNewsClient/README.md b/HarmonyOSNewsClient/README.md deleted file mode 100644 index 42aa433f8ef122599f694db74f1929477d6c9823..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# HarmonyOSNewsClient -简介 -• HarmonyOS新闻客户端是一个简单的新闻应用程序。在这里,我们想向开发人员展示一些常见的控件和组件。此外,我们还展现了HarmonyOS的跨设备迁移能力,您可以无缝地将FA传输到局域网上的其他设备,以完成新闻共享。 - -安装要求 -• 安装DevEco Studio -• 设置DevEco Studio开发环境。DevEco Studio开发环境需要连接到网络,以确保该正常使用。可以根据以下两种情况配置开发环境: - 1.如果您可以直接访问Internet,则只需下载HarmonyOS SDK - 2.如果网络无法直接访问Internet,则可以通过代理服务器进行访问 -• 生成密钥并申请证书 - -用户指南 -• 下载此项目 -• 打开HUAWEI DevEco Studio,单击File> Open选择此ComponentCodelab -• 单击Build> Build App(s)/Hap(s)>Build Debug Hap(s)以编译hap软件包 -• 单击Run> Run 'entry'以运行hap包 - -注意 -• 您可以选择在模拟器或真机上运行hap软件包。 -• 如果在真机上运行它,则需要在项目的File> Project Structure> Modules> Signing Configs中配置签名和证书信息。 - -许可 -请参阅LICENSE文件以获得更多信息。 - -What is it? -The HarmonyOS news client is a simple news application. Here,we want to show developers some common controls and components of the HarmonyOS. In addition, -we also demonstrate the cross-device migration function.You can seamlessly transfer your FA to other devices on the local area network (LAN) to complete news sharing. -This example code is complete and you can learn from the beginning with us. - -Installation requirements -• Install DevEco Studio -• Set up the DevEco Studio development environment.The DevEco Studio development environment needs to depend on the network environment. It needs to be connected to the network to ensure the normal use of the tool.The development environment can be configured according to the following two situations - 1.If you can directly access the Internet, just download the HarmonyOS SDK - 2.If the network cannot access the Internet directly, it can be accessed through a proxy server -• Generate secret key and apply for certificate - -User guide -• Download this Project -• Open HUAWEI DevEco Studio, click File> Open> Then select and open this Project -• Click Build> Build App(s)/Hap(s)>Build Debug Hap(s) to compile the hap package -• Click Run> Run 'entry' to run the hap package - -Note -• You can choose to run the hap package on the simulator or the phone. -• If you run it on the phone, you need to configure the signature and certificate information in the project's File> Project Structure> Modules> Signing Configs. - -Licensing -Please see LICENSE for more info. \ No newline at end of file diff --git a/HarmonyOSNewsClient/RELEASE-NOTES.md b/HarmonyOSNewsClient/RELEASE-NOTES.md deleted file mode 100644 index ea23a13e3d4407d06cba3aa7155a23e5081b50b4..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/RELEASE-NOTES.md +++ /dev/null @@ -1,2 +0,0 @@ -1.0.0 -1.Initial version \ No newline at end of file diff --git a/HarmonyOSNewsClient/build.gradle b/HarmonyOSNewsClient/build.gradle deleted file mode 100644 index cee07328749cf41637db2e71b7fbf43f6bde41e4..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -apply plugin: 'com.huawei.ohos.app' - -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 4 - } -} - -buildscript { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } - dependencies { - classpath 'com.huawei.ohos:hap:2.4.2.7' - classpath 'com.huawei.ohos:decctest:1.0.0.7' - } -} - -allprojects { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } -} diff --git a/HarmonyOSNewsClient/entry/build.gradle b/HarmonyOSNewsClient/entry/build.gradle deleted file mode 100644 index dfc2d5b34a68f375924a5cfb98a102d1fe4068eb..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/build.gradle +++ /dev/null @@ -1,28 +0,0 @@ -apply plugin: 'com.huawei.ohos.hap' -apply plugin: 'com.huawei.ohos.decctest' -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 4 - } - buildTypes { - release { - proguardOpt { - proguardEnabled false - rulesFiles 'proguard-rules.pro' - } - } - } - -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' - implementation 'com.google.code.gson:gson:2.8.6' - testImplementation 'junit:junit:4.13' -} - -decc { - supportType = ['html', 'xml'] -} diff --git a/HarmonyOSNewsClient/entry/entry.iml b/HarmonyOSNewsClient/entry/entry.iml deleted file mode 100644 index 1195bcf115d99b7b11599c4f15157dd5863d2317..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/entry.iml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/HarmonyOSNewsClient/entry/src/main/config.json b/HarmonyOSNewsClient/entry/src/main/config.json deleted file mode 100644 index bb4fa20a7aa5211f6a3741767f033ccefeeca305..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/config.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "app": { - "bundleName": "com.huawei.codelab", - "vendor": "huawei", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.huawei.codelab", - "name": ".NewsDemo", - "reqCapabilities": [ - "video_support" - ], - "deviceType": [ - "phone", - "tv" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": false - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home", - "action.detail" - ] - } - ], - "orientation": "portrait", - "formsEnabled": false, - "name": "com.huawei.codelab.NewsAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard" - }, - { - "visible": true, - "name": "com.huawei.codelab.SharedService", - "type": "service" - } - ], - "reqPermissions": [ - { - "reason": "", - "name": "ohos.permission.servicebus.ACCESS_SERVICE" - }, - { - "name": "ohos.permission.DISTRIBUTED_DATASYNC" - }, - { - "name": "ohos.permission.DISTRIBUTED_DEVICE_STATE_CHANGE" - }, - { - "name": "ohos.permission.GET_DISTRIBUTED_DEVICE_INFO" - }, - { - "name": "ohos.permission.SYSTEM_FLOAT_WINDOW" - }, - { - "name": "ohos.permission.INTERNET" - }, - { - "name": "ohos.permission.R" - } - ] - } -} \ No newline at end of file diff --git a/HarmonyOSNewsClient/entry/src/main/idl/com/huawei/newsdemo/INewsDemoIDL.idl b/HarmonyOSNewsClient/entry/src/main/idl/com/huawei/newsdemo/INewsDemoIDL.idl deleted file mode 100644 index 725405b0c17062a046095cb279dc1a06abdf1e8f..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/idl/com/huawei/newsdemo/INewsDemoIDL.idl +++ /dev/null @@ -1,10 +0,0 @@ -// INewsDemoIDL.idl - -// Declare any non-default types here with sequenceable or interface statements - -interface com.huawei.codelab.INewsDemoIDL { - /* - * Demo service method use some parameters - */ - void tranShare([in]String title ,[in]String reads,[in]String likes,[in]String content,[in]String image); -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/NewsAbility.java b/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/NewsAbility.java deleted file mode 100644 index e870a1ff947d1720d5031331376a177f274f9763..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/NewsAbility.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab; - -import com.huawei.codelab.slice.NewsDetailAbilitySlice; -import com.huawei.codelab.slice.NewsListAbilitySlice; - -import ohos.aafwk.ability.Ability; -import ohos.aafwk.content.Intent; -import ohos.bundle.IBundleManager; - -/** - * News ability - * - * @since 2020-12-04 - */ -public class NewsAbility extends Ability { - private static final String PERMISSION_DATASYNC = "ohos.permission.DISTRIBUTED_DATASYNC"; - private static final int MY_PERMISSION_REQUEST_CODE = 1; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setMainRoute(NewsListAbilitySlice.class.getName()); - addActionRoute("action.detail", NewsDetailAbilitySlice.class.getName()); - - if (verifySelfPermission(PERMISSION_DATASYNC) != IBundleManager.PERMISSION_GRANTED) { - if (canRequestPermission(PERMISSION_DATASYNC)) { - requestPermissionsFromUser(new String[] {PERMISSION_DATASYNC}, MY_PERMISSION_REQUEST_CODE); - } - } - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/NewsDemo.java b/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/NewsDemo.java deleted file mode 100644 index c7352454b58cb4b716d269b06082298110bc6102..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/NewsDemo.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab; - -import ohos.aafwk.ability.AbilityPackage; - -/** - * News demo - * - * @since 2020-12-04 - */ -public class NewsDemo extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/SharedService.java b/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/SharedService.java deleted file mode 100644 index 6850bf489007f3e32f45f443025ac4e306aab0f5..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/SharedService.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab; - -import com.huawei.codelab.slice.NewsDetailAbilitySlice; - -import manager.NewsDemoIDLStub; -import ohos.aafwk.ability.Ability; -import ohos.aafwk.content.Intent; -import ohos.aafwk.content.Operation; -import ohos.rpc.IRemoteObject; - -/** - * Shared Service - * - * @since 2020-12-04 - */ -public class SharedService extends Ability { - private static final String DESCRIPTOR = "com.huawei.codelab.idl.INewsDemoIDL"; - - @Override - protected void onStart(Intent intent) { - super.onStart(intent); - } - - @Override - protected IRemoteObject onConnect(Intent intent) { - return new MyBinder(DESCRIPTOR); - } - - /** - * MyBinder - * - * @since 2020-12-04 - */ - private class MyBinder extends NewsDemoIDLStub { - MyBinder(String descriptor) { - super(descriptor); - } - - @Override - public void tranShare(String title, String reads, String likes, String content, String image) { - Intent intent = new Intent(); - Operation operation = - new Intent.OperationBuilder() - .withBundleName(getBundleName()) - .withAbilityName(NewsAbility.class.getName()) - .withAction("action.detail") - .build(); - intent.setOperation(operation); - intent.setParam(NewsDetailAbilitySlice.INTENT_TITLE, title); - intent.setParam(NewsDetailAbilitySlice.INTENT_READ, reads); - intent.setParam(NewsDetailAbilitySlice.INTENT_LIKE, likes); - intent.setParam(NewsDetailAbilitySlice.INTENT_CONTENT, content); - intent.setParam(NewsDetailAbilitySlice.INTENT_IMAGE, image); - startAbility(intent); - } - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/bean/NewsInfo.java b/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/bean/NewsInfo.java deleted file mode 100644 index 905c0e86b90b2e5a3c1586ad7b3daccf373b3d89..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/bean/NewsInfo.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.bean; - -/** - * News information - * - * @since 2020-12-04 - */ -public class NewsInfo { - private String title; - - private String type; - - private String imgUrl; - - private String reads; - - private String likes; - - private String content; - - public String getImgUrl() { - return imgUrl; - } - - public String getReads() { - return reads; - } - - public void setReads(String reads) { - this.reads = reads; - } - - public String getLikes() { - return likes; - } - - public void setLikes(String likes) { - this.likes = likes; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getType() { - return type; - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/bean/NewsType.java b/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/bean/NewsType.java deleted file mode 100644 index e0d633fdd8b85f128ddc9c0416878d952e77a827..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/bean/NewsType.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.bean; - -/** - * News information - * - * @since 2020-12-04 - */ -public class NewsType { - private String name; - - public String getName() { - return name; - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/provider/DevicesListProvider.java b/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/provider/DevicesListProvider.java deleted file mode 100644 index 72fd924255760286e817602a87776109b0cb3ec0..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/provider/DevicesListProvider.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.provider; - -import com.huawei.codelab.ResourceTable; - -import ohos.agp.components.BaseItemProvider; -import ohos.agp.components.Component; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.LayoutScatter; -import ohos.agp.components.Text; -import ohos.app.Context; -import ohos.distributedschedule.interwork.DeviceInfo; - -import java.util.List; - -/** - * Device list adapter - * - * @since 2020-12-04 - */ -public class DevicesListProvider extends BaseItemProvider { - private List deviceInfoList; - private Context context; - - /** - * constructor function - * - * @param listBasicInfo list info - * @param context context - * @since 2020-12-04 - */ - public DevicesListProvider(List listBasicInfo, Context context) { - this.deviceInfoList = listBasicInfo; - this.context = context; - } - - @Override - public int getCount() { - return deviceInfoList == null ? 0 : deviceInfoList.size(); - } - - @Override - public Object getItem(int position) { - return deviceInfoList.get(position); - } - - @Override - public long getItemId(int position) { - return position; - } - - @Override - public Component getComponent(int position, Component component, ComponentContainer componentContainer) { - ViewHolder viewHolder; - Component temp = component; - if (temp == null) { - temp = LayoutScatter.getInstance(context).parse(ResourceTable.Layout_device_list_item, null, false); - viewHolder = new ViewHolder(); - viewHolder.devicesName = (Text) temp.findComponentById(ResourceTable.Id_item_child_textview); - temp.setTag(viewHolder); - } else { - viewHolder = (ViewHolder) temp.getTag(); - } - viewHolder.devicesName.setText(deviceInfoList.get(position).getDeviceName()); - return temp; - } - - /** - * ViewHolder which has devicesName - * - * @since 2020-12-04 - */ - private static class ViewHolder { - private Text devicesName; - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/provider/NewsListProvider.java b/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/provider/NewsListProvider.java deleted file mode 100644 index 61d492b878c287eaa4969c846b16ec6c49c0f5e8..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/provider/NewsListProvider.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.provider; - -import com.huawei.codelab.ResourceTable; -import com.huawei.codelab.bean.NewsInfo; -import com.huawei.codelab.utils.CommonUtils; - -import ohos.agp.components.BaseItemProvider; -import ohos.agp.components.Component; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.Image; -import ohos.agp.components.LayoutScatter; -import ohos.agp.components.Text; -import ohos.app.Context; - -import java.util.List; - -/** - * News list adapter - * - * @since 2020-12-04 - */ -public class NewsListProvider extends BaseItemProvider { - private List newsInfoList; - private Context context; - - /** - * constructor function - * - * @param listBasicInfo list info - * @param context context - * @since 2020-12-04 - */ - public NewsListProvider(List listBasicInfo, Context context) { - this.newsInfoList = listBasicInfo; - this.context = context; - } - - @Override - public int getCount() { - return newsInfoList == null ? 0 : newsInfoList.size(); - } - - @Override - public Object getItem(int position) { - return newsInfoList.get(position); - } - - @Override - public long getItemId(int position) { - return position; - } - - @Override - public Component getComponent(int position, Component component, ComponentContainer componentContainer) { - ViewHolder viewHolder; - Component temp = component; - if (temp == null) { - temp = LayoutScatter.getInstance(context).parse(ResourceTable.Layout_item_news_layout, null, false); - viewHolder = new ViewHolder(); - viewHolder.title = (Text) temp.findComponentById(ResourceTable.Id_item_news_title); - viewHolder.image = (Image) temp.findComponentById(ResourceTable.Id_item_news_image); - temp.setTag(viewHolder); - } else { - viewHolder = (ViewHolder) temp.getTag(); - } - viewHolder.title.setText(newsInfoList.get(position).getTitle()); - viewHolder.image.setPixelMap(CommonUtils.getPixelMapFromPath(context, newsInfoList.get(position).getImgUrl())); - return temp; - } - - /** - * ViewHolder which has title and image - * - * @since 2020-12-04 - */ - private static class ViewHolder { - Text title; - Image image; - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/provider/NewsTypeProvider.java b/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/provider/NewsTypeProvider.java deleted file mode 100644 index f320b73fcd5502f18f194504b6aa6f7da0f79be6..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/provider/NewsTypeProvider.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.provider; - -import com.huawei.codelab.ResourceTable; -import com.huawei.codelab.bean.NewsType; - -import ohos.agp.components.BaseItemProvider; -import ohos.agp.components.Component; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.LayoutScatter; -import ohos.agp.components.Text; -import ohos.app.Context; - -import java.util.List; - -/** - * News type list adapter - * - * @since 2020-12-04 - */ -public class NewsTypeProvider extends BaseItemProvider { - private List newsTypeList; - private Context context; - - /** - * constructor function - * - * @param listBasicInfo list info - * @param context context - * @since 2020-12-04 - */ - public NewsTypeProvider(List listBasicInfo, Context context) { - this.newsTypeList = listBasicInfo; - this.context = context; - } - - @Override - public int getCount() { - return newsTypeList == null ? 0 : newsTypeList.size(); - } - - @Override - public Object getItem(int position) { - return newsTypeList.get(position); - } - - @Override - public long getItemId(int position) { - return position; - } - - @Override - public Component getComponent(int position, Component component, ComponentContainer componentContainer) { - ViewHolder viewHolder; - Component temp = component; - if (temp == null) { - temp = - LayoutScatter.getInstance(context).parse(ResourceTable.Layout_item_news_type_layout, null, false); - viewHolder = new ViewHolder(); - viewHolder.title = (Text) temp.findComponentById(ResourceTable.Id_news_type_text); - temp.setTag(viewHolder); - } else { - viewHolder = (ViewHolder) temp.getTag(); - } - viewHolder.title.setText(newsTypeList.get(position).getName()); - return temp; - } - - /** - * ViewHolder which has title - * - * @since 2020-12-04 - */ - private static class ViewHolder { - Text title; - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/slice/NewsDetailAbilitySlice.java b/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/slice/NewsDetailAbilitySlice.java deleted file mode 100644 index fb7af21b049c0ac25df460cf58ba0a541248977c..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/slice/NewsDetailAbilitySlice.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.slice; - -import com.huawei.codelab.ResourceTable; -import com.huawei.codelab.SharedService; -import com.huawei.codelab.provider.DevicesListProvider; -import com.huawei.codelab.utils.CommonUtils; -import com.huawei.codelab.utils.DialogUtils; -import com.huawei.codelab.utils.LogUtils; - -import manager.INewsDemoIDL; -import manager.NewsDemoIDLStub; -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.ability.IAbilityConnection; -import ohos.aafwk.content.Intent; -import ohos.aafwk.content.Operation; -import ohos.agp.components.DependentLayout; -import ohos.agp.components.Image; -import ohos.agp.components.ListContainer; -import ohos.agp.components.Text; -import ohos.agp.components.TextField; -import ohos.agp.window.dialog.CommonDialog; -import ohos.bundle.ElementName; -import ohos.distributedschedule.interwork.DeviceInfo; -import ohos.distributedschedule.interwork.DeviceManager; -import ohos.rpc.IRemoteObject; -import ohos.rpc.RemoteException; - -import java.util.ArrayList; -import java.util.List; - -/** - * News detail slice - * - * @since 2020-12-04 - */ -public class NewsDetailAbilitySlice extends AbilitySlice { - public static final String INTENT_TITLE = "intent_title"; - public static final String INTENT_READ = "intent_read"; - public static final String INTENT_LIKE = "intent_like"; - public static final String INTENT_CONTENT = "intent_content"; - public static final String INTENT_IMAGE = "intent_image"; - private static final String TAG = "NewsDetailAbilitySlice"; - private static final int WAIT_TIME = 30000; - private static final int DIALOG_SIZE_WIDTH = 900; - private static final int DIALOG_SIZE_HEIGHT = 800; - private DependentLayout parentLayout; - private TextField commentFocus; - private Image iconShared; - private CommonDialog dialog; - private List devices = new ArrayList<>(); - private String reads; - private String likes; - private String title; - private String content; - private String image; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setUIContent(ResourceTable.Layout_news_detail_layout); - reads = intent.getStringParam(INTENT_READ); - likes = intent.getStringParam(INTENT_LIKE); - title = intent.getStringParam(INTENT_TITLE); - content = intent.getStringParam(INTENT_CONTENT); - image = intent.getStringParam(INTENT_IMAGE); - initView(); - initListener(); - } - - private void initView() { - parentLayout = (DependentLayout) findComponentById(ResourceTable.Id_parent_layout); - commentFocus = (TextField) findComponentById(ResourceTable.Id_text_file); - iconShared = (Image) findComponentById(ResourceTable.Id_button4); - Text newsRead = (Text) findComponentById(ResourceTable.Id_read_num); - Text newsLike = (Text) findComponentById(ResourceTable.Id_like_num); - Text newsTitle = (Text) findComponentById(ResourceTable.Id_title_text); - Text newsContent = (Text) findComponentById(ResourceTable.Id_title_content); - Image newsImage = (Image) findComponentById(ResourceTable.Id_image_content); - newsRead.setText("reads: " + reads); - newsLike.setText("likes: " + likes); - newsTitle.setText("Original title: " + title); - newsContent.setText(content); - newsImage.setPixelMap(CommonUtils.getPixelMapFromPath(this, image)); - } - - private void initListener() { - parentLayout.setTouchEventListener( - (component, touchEvent) -> { - if (commentFocus.hasFocus()) { - commentFocus.clearFocus(); - } - return true; - }); - iconShared.setClickedListener( - component -> { - initDevices(); - showDeviceList(); - }); - } - - private void initDevices() { - if (devices.size() > 0) { - devices.clear(); - } - List deviceInfos = - DeviceManager.getDeviceList(DeviceInfo.FLAG_GET_ONLINE_DEVICE); - devices.addAll(deviceInfos); - } - - private void showDeviceList() { - dialog = new CommonDialog(NewsDetailAbilitySlice.this); - dialog.setAutoClosable(true); - dialog.setTitleText("Harmony devices"); - dialog.setSize(DIALOG_SIZE_WIDTH, DIALOG_SIZE_HEIGHT); - ListContainer devicesListContainer = new ListContainer(getContext()); - DevicesListProvider devicesListProvider = new DevicesListProvider(devices, this); - devicesListContainer.setItemProvider(devicesListProvider); - devicesListContainer.setItemClickedListener( - (listContainer, component, position, id) -> { - dialog.destroy(); - startAbilityFA(devices.get(position).getDeviceId()); - }); - devicesListProvider.notifyDataChanged(); - dialog.setContentCustomComponent(devicesListContainer); - dialog.show(); - } - - private void startAbilityFA(String devicesId) { - Intent intent = new Intent(); - Operation operation = - new Intent.OperationBuilder() - .withDeviceId(devicesId) - .withBundleName(getBundleName()) - .withAbilityName(SharedService.class.getName()) - .withFlags(Intent.FLAG_ABILITYSLICE_MULTI_DEVICE) - .build(); - intent.setOperation(operation); - boolean connectFlag = - connectAbility( - intent, - new IAbilityConnection() { - @Override - public void onAbilityConnectDone( - ElementName elementName, IRemoteObject remoteObject, int i) { - INewsDemoIDL sharedManager = NewsDemoIDLStub.asInterface(remoteObject); - try { - sharedManager.tranShare(title, reads, likes, content, image); - } catch (RemoteException e) { - LogUtils.info(TAG, "connect successful,but have remote exception"); - } - } - - @Override - public void onAbilityDisconnectDone(ElementName elementName, int i) { - disconnectAbility(this); - } - }); - DialogUtils.toast( - this, connectFlag ? "Sharing succeeded!" : "Sharing failed. Please try again later.", WAIT_TIME); - } - - @Override - public void onActive() { - super.onActive(); - } - - @Override - public void onForeground(Intent intent) { - super.onForeground(intent); - } - - @Override - protected void onStop() { - super.onStop(); - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/slice/NewsListAbilitySlice.java b/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/slice/NewsListAbilitySlice.java deleted file mode 100644 index 8f459d10170a38b65c3731e095f717ba6496dae6..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/slice/NewsListAbilitySlice.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.slice; - -import com.huawei.codelab.NewsAbility; -import com.huawei.codelab.ResourceTable; -import com.huawei.codelab.bean.NewsInfo; -import com.huawei.codelab.bean.NewsType; -import com.huawei.codelab.provider.NewsListProvider; -import com.huawei.codelab.provider.NewsTypeProvider; -import com.huawei.codelab.utils.CommonUtils; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.aafwk.content.Operation; -import ohos.agp.components.ListContainer; -import ohos.agp.components.Text; -import ohos.agp.utils.Color; - -import java.util.ArrayList; -import java.util.List; - -/** - * News list slice - * - * @since 2020-12-04 - */ -public class NewsListAbilitySlice extends AbilitySlice { - private static final float FOCUS_TEXT_SIZE = 1.2f; - private static final float UNFOCUSED_TEXT_SIZE = 1.0f; - private Text selectText; - - private ListContainer newsListContainer; - private ListContainer selectorListContainer; - private List totalNewsDataList; - private List newsDataList; - - private NewsTypeProvider newsTypeProvider; - private NewsListProvider newsListProvider; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setUIContent(ResourceTable.Layout_news_list_layout); - initView(); - initData(); - initListener(); - selectorListContainer.setItemProvider(newsTypeProvider); - newsListContainer.setItemProvider(newsListProvider); - newsTypeProvider.notifyDataChanged(); - newsListProvider.notifyDataChanged(); - } - - private void initView() { - selectorListContainer = (ListContainer) findComponentById(ResourceTable.Id_selector_list); - newsListContainer = (ListContainer) findComponentById(ResourceTable.Id_news_container); - } - - private void initData() { - Gson gson = new Gson(); - List newsTypeList = - gson.fromJson( - CommonUtils.getStringFromJsonPath(this, "entry/resources/rawfile/news_type_datas.json"), - new TypeToken>() { }.getType()); - totalNewsDataList = - gson.fromJson( - CommonUtils.getStringFromJsonPath(this, "entry/resources/rawfile/news_datas.json"), - new TypeToken>() { }.getType()); - newsDataList = new ArrayList<>(); - newsDataList.addAll(totalNewsDataList); - newsTypeProvider = new NewsTypeProvider(newsTypeList, this); - newsListProvider = new NewsListProvider(newsDataList, this); - } - - /** - * init listener of news type and news detail - */ - private void initListener() { - selectorListContainer.setItemClickedListener( - (listContainer, component, position, id) -> { - setCategorizationFocus(false); - selectText = (Text) component.findComponentById(ResourceTable.Id_news_type_text); - setCategorizationFocus(true); - newsDataList.clear(); - for (NewsInfo mTotalNewsData : totalNewsDataList) { - if (selectText.getText().equals(mTotalNewsData.getType()) || position == 0) { - newsDataList.add(mTotalNewsData); - } - } - updateListView(); - }); - newsListContainer.setItemClickedListener( - (listContainer, component, position, id) -> { - Intent intent = new Intent(); - Operation operation = - new Intent.OperationBuilder() - .withBundleName(getBundleName()) - .withAbilityName(NewsAbility.class.getName()) - .withAction("action.detail") - .build(); - intent.setOperation(operation); - intent.setParam(NewsDetailAbilitySlice.INTENT_TITLE, newsDataList.get(position).getTitle()); - intent.setParam(NewsDetailAbilitySlice.INTENT_READ, newsDataList.get(position).getReads()); - intent.setParam(NewsDetailAbilitySlice.INTENT_LIKE, newsDataList.get(position).getLikes()); - intent.setParam(NewsDetailAbilitySlice.INTENT_CONTENT, newsDataList.get(position).getContent()); - intent.setParam(NewsDetailAbilitySlice.INTENT_IMAGE, newsDataList.get(position).getImgUrl()); - startAbility(intent); - }); - } - - private void setCategorizationFocus(boolean isFocus) { - if (selectText == null) { - return; - } - if (isFocus) { - selectText.setTextColor( - new Color(CommonUtils.getColor(NewsListAbilitySlice.this, ResourceTable.Color_news_type_text_on))); - selectText.setScaleX(FOCUS_TEXT_SIZE); - selectText.setScaleY(FOCUS_TEXT_SIZE); - } else { - selectText.setTextColor( - new Color(CommonUtils.getColor(NewsListAbilitySlice.this, ResourceTable.Color_news_type_text_off))); - selectText.setScaleX(UNFOCUSED_TEXT_SIZE); - selectText.setScaleY(UNFOCUSED_TEXT_SIZE); - } - } - - private void updateListView() { - newsListProvider.notifyDataChanged(); - newsListContainer.invalidate(); - newsListContainer.scrollToCenter(0); - } - - @Override - public void onActive() { - super.onActive(); - } - - @Override - public void onForeground(Intent intent) { - super.onForeground(intent); - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/utils/CommonUtils.java b/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/utils/CommonUtils.java deleted file mode 100644 index 5d3524d83407c61ddc26f6f1f13de1e94db84c52..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/utils/CommonUtils.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.utils; - -import ohos.app.Context; -import ohos.global.resource.NotExistException; -import ohos.global.resource.Resource; -import ohos.global.resource.WrongTypeException; -import ohos.media.image.ImageSource; -import ohos.media.image.PixelMap; -import ohos.media.image.common.PixelFormat; -import ohos.media.image.common.Rect; -import ohos.media.image.common.Size; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.Optional; - -/** - * Common utils - * - * @since 2020-12-04 - */ -public class CommonUtils { - private static final String TAG = "Common Utils"; - private static final String ERROR_MESSAGE = "some error happened"; - private static final int GET_COLOR_STATE_FAILED = -1; - private static final int JSON_READ_ERROR = -1; - - private CommonUtils() { - } - - /** - * Get color method - * - * @param context context resourceID res id - * @param resourceId res id - * @return color - * @since 2020-12-04 - */ - public static int getColor(Context context, int resourceId) { - try { - return context.getResourceManager().getElement(resourceId).getColor(); - } catch (IOException | NotExistException | WrongTypeException e) { - LogUtils.info(TAG, "some exception happened"); - } - return GET_COLOR_STATE_FAILED; - } - - /** - * Obtains a bitmap object based on the resource path. - * - * @param context context - * @param path path - * @return pixelMap - */ - public static PixelMap getPixelMapFromPath(Context context, String path) { - InputStream drawableInputStream = null; - try { - drawableInputStream = context.getResourceManager().getRawFileEntry(path).openRawFile(); - ImageSource.SourceOptions sourceOptions = new ImageSource.SourceOptions(); - sourceOptions.formatHint = "image/png"; - ImageSource imageSource = ImageSource.create(drawableInputStream, sourceOptions); - ImageSource.DecodingOptions decodingOptions = new ImageSource.DecodingOptions(); - decodingOptions.desiredSize = new Size(0, 0); - decodingOptions.desiredRegion = new Rect(0, 0, 0, 0); - decodingOptions.desiredPixelFormat = PixelFormat.ARGB_8888; - return imageSource.createPixelmap(decodingOptions); - } catch (IOException e) { - LogUtils.info(TAG, ERROR_MESSAGE); - } finally { - try { - if (drawableInputStream != null) { - drawableInputStream.close(); - } - } catch (IOException e) { - LogUtils.error(TAG, ERROR_MESSAGE); - } - } - return null; - } - - /** - * Obtains a List based on the resource path. - * - * @param context context - * @param jsonPath path - * @return jsonString - */ - public static String getStringFromJsonPath(Context context, String jsonPath) { - Resource datasResource; - try { - datasResource = context.getResourceManager().getRawFileEntry(jsonPath).openRawFile(); - byte[] buffers = new byte[datasResource.available()]; - if (datasResource.read(buffers) != JSON_READ_ERROR) { - return new String(buffers, StandardCharsets.UTF_8); - } - } catch (IOException e) { - LogUtils.error(TAG, ERROR_MESSAGE); - } - return Optional.of(jsonPath).toString(); - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/utils/DialogUtils.java b/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/utils/DialogUtils.java deleted file mode 100644 index add83572b6cb75dd5e6491805b0c041481683e3a..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/utils/DialogUtils.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.utils; - -import ohos.agp.colors.RgbColor; -import ohos.agp.components.DependentLayout; -import ohos.agp.components.Text; -import ohos.agp.components.element.ShapeElement; -import ohos.agp.utils.Color; -import ohos.agp.window.dialog.ToastDialog; -import ohos.app.Context; - -/** - * Dialog util - * - * @since 2020-12-04 - */ -public class DialogUtils { - private static final int TEXT_SIZE = 40; - private static final int TEXT_PADDING = 20; - private static final int TEXT_HEIGHT = 100; - private static final int TEXT_CORNER = 20; - private static final int TEXT_OFFSETY = 200; - private static final int TEXT_ALPHA = 120; - - private DialogUtils() { - } - - /** - * Toast Method - * - * @param context context - * @param text Pop-up toast content - * @param ms Toast display time, in ms. - */ - public static void toast(Context context, String text, int ms) { - DependentLayout layout = new DependentLayout(context); - layout.setWidth(ScreenUtils.getScreenWidth(context)); - layout.setHeight(TEXT_HEIGHT); - Text textView = new Text(context); - ShapeElement background = new ShapeElement(); - background.setCornerRadius(TEXT_CORNER); - background.setRgbColor(new RgbColor(0, 0, 0, TEXT_ALPHA)); - textView.setBackground(background); - DependentLayout.LayoutConfig config = - new DependentLayout.LayoutConfig( - DependentLayout.LayoutConfig.MATCH_CONTENT, DependentLayout.LayoutConfig.MATCH_CONTENT); - config.addRule(DependentLayout.LayoutConfig.HORIZONTAL_CENTER); - textView.setLayoutConfig(config); - textView.setPadding(TEXT_PADDING, TEXT_PADDING, TEXT_PADDING, TEXT_PADDING); - textView.setMaxTextLines(1); - textView.setTextSize(TEXT_SIZE); - textView.setMaxTextWidth(ScreenUtils.getScreenWidth(context)); - textView.setTextColor(Color.WHITE); - textView.setText(text); - layout.addComponent(textView); - ToastDialog toastDialog = new ToastDialog(context); - toastDialog.setContentCustomComponent(layout); - toastDialog.setTransparent(true); - toastDialog.setOffset(0, TEXT_OFFSETY); - toastDialog.setSize(ScreenUtils.getScreenWidth(context), TEXT_HEIGHT); - toastDialog.setDuration(ms); - toastDialog.show(); - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/utils/LogUtils.java b/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/utils/LogUtils.java deleted file mode 100644 index 21b893004bee9d426446e04b4b5b9b346efaafce..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/utils/LogUtils.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.utils; - -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; - -/** - * Log Util - * - * @since 2020-12-04 - */ -public class LogUtils { - private static final String TAG_LOG = "LogUtil"; - - private static final HiLogLabel LABEL_LOG = new HiLogLabel(0, 0, LogUtils.TAG_LOG); - - private static final String LOG_FORMAT = "%{public}s: %{public}s"; - - private LogUtils() { - } - - /** - * Print info log - * - * @param tag log tag - * @param msg log message - */ - public static void info(String tag, String msg) { - HiLog.info(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print info log - * - * @param tag log tag - * @param msg log message - */ - public static void error(String tag, String msg) { - HiLog.info(LABEL_LOG, LOG_FORMAT, tag, msg); - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/utils/ScreenUtils.java b/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/utils/ScreenUtils.java deleted file mode 100644 index 3030bf7ed206d75dfaad8fc65caa0cfb4779cbd1..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/com/huawei/codelab/utils/ScreenUtils.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.codelab.utils; - -import ohos.agp.utils.Point; -import ohos.agp.window.service.Display; -import ohos.agp.window.service.DisplayManager; -import ohos.app.Context; - -import java.util.Optional; - -/** - * Screen Util - * - * @since 2020-12-04 - */ -class ScreenUtils { - private ScreenUtils() { } - - /** - * get Screen Width Method - * - * @param context context - * @return screen width - */ - static int getScreenWidth(Context context) { - DisplayManager displayManager = DisplayManager.getInstance(); - Optional optDisplay = displayManager.getDefaultDisplay(context); - Point point = new Point(0, 0); - if (!optDisplay.isPresent()) { - return (int) point.position[0]; - } else { - Display display = optDisplay.get(); - display.getSize(point); - return (int) point.position[0]; - } - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/manager/INewsDemoIDL.java b/HarmonyOSNewsClient/entry/src/main/java/manager/INewsDemoIDL.java deleted file mode 100644 index 736893cc141f058ade3f9ce5e714b33cce325a9b..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/manager/INewsDemoIDL.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package manager; - -import ohos.rpc.IRemoteBroker; -import ohos.rpc.RemoteException; - -/** - * News Demo IDL - */ -public interface INewsDemoIDL extends IRemoteBroker { - void tranShare( - /* [in] */ String title, - /* [in] */ String reads, - /* [in] */ String likes, - /* [in] */ String content, - /* [in] */ String image) - throws RemoteException; -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/manager/NewsDemoIDLProxy.java b/HarmonyOSNewsClient/entry/src/main/java/manager/NewsDemoIDLProxy.java deleted file mode 100644 index 6faa4bf8e9cd34c21538930faade285a67f5bbba..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/manager/NewsDemoIDLProxy.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - package manager; - -import ohos.rpc.IRemoteObject; -import ohos.rpc.MessageOption; -import ohos.rpc.MessageParcel; -import ohos.rpc.RemoteException; - -public class NewsDemoIDLProxy implements INewsDemoIDL { - private static final String DESCRIPTOR = "com.huawei.codelab.INewsDemoIDL"; - - private static final int COMMAND_TRAN_SHARE = IRemoteObject.MIN_TRANSACTION_ID; - - private final IRemoteObject remote; - - NewsDemoIDLProxy( - /* [in] */ IRemoteObject remote) { - this.remote = remote; - } - - @Override - public IRemoteObject asObject() { - return remote; - } - - @Override - public void tranShare( - /* [in] */ String title, - /* [in] */ String reads, - /* [in] */ String likes, - /* [in] */ String content, - /* [in] */ String image) - throws RemoteException { - MessageParcel data = MessageParcel.obtain(); - MessageParcel reply = MessageParcel.obtain(); - MessageOption option = new MessageOption(MessageOption.TF_SYNC); - - data.writeInterfaceToken(DESCRIPTOR); - data.writeString(title); - data.writeString(reads); - data.writeString(likes); - data.writeString(content); - data.writeString(image); - - try { - remote.sendRequest(COMMAND_TRAN_SHARE, data, reply, option); - reply.readException(); - } finally { - data.reclaim(); - reply.reclaim(); - } - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/java/manager/NewsDemoIDLStub.java b/HarmonyOSNewsClient/entry/src/main/java/manager/NewsDemoIDLStub.java deleted file mode 100644 index ed643868e0a587bdb603c778da527dc9c3bfa340..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/java/manager/NewsDemoIDLStub.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package manager; - -import ohos.rpc.*; - -public abstract class NewsDemoIDLStub extends RemoteObject implements INewsDemoIDL { - private static final String DESCRIPTOR = "com.huawei.codelab.INewsDemoIDL"; - - private static final int COMMAND_TRAN_SHARE = IRemoteObject.MIN_TRANSACTION_ID; - - public NewsDemoIDLStub( - /* [in] */ String descriptor) { - super(descriptor); - } - - @Override - public IRemoteObject asObject() { - return this; - } - - public static INewsDemoIDL asInterface(IRemoteObject object) { - if (object == null) { - return null; - } - - INewsDemoIDL result = null; - IRemoteBroker broker = object.queryLocalInterface(DESCRIPTOR); - if (broker != null) { - if (broker instanceof INewsDemoIDL) { - result = (INewsDemoIDL) broker; - } - } else { - result = new NewsDemoIDLProxy(object); - } - - return result; - } - - @Override - public boolean onRemoteRequest( - /* [in] */ int code, - /* [in] */ MessageParcel data, - /* [out] */ MessageParcel reply, - /* [in] */ MessageOption option) - throws RemoteException { - String token = data.readInterfaceToken(); - if (!DESCRIPTOR.equals(token)) { - return false; - } - if (code == COMMAND_TRAN_SHARE) { - String title = data.readString(); - String reads = data.readString(); - String likes = data.readString(); - String content = data.readString(); - String image = data.readString(); - tranShare(title, reads, likes, content, image); - reply.writeNoException(); - return true; - } - return super.onRemoteRequest(code, data, reply, option); - } -} diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/element/colors.json b/HarmonyOSNewsClient/entry/src/main/resources/base/element/colors.json deleted file mode 100644 index 2ee40bdd48dd9e9add158d97f9efcea24ce975f8..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/resources/base/element/colors.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "color": [ - { - "name": "news_type_text_off", - "value": "#55000000" - }, - { - "name": "news_type_text_on", - "value": "#afaafa" - }, - { - "name": "white", - "value": "#ffffff" - }, - { - "name": "half_transparent", - "value": "#55000000" - } - ] -} \ No newline at end of file diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/element/string.json b/HarmonyOSNewsClient/entry/src/main/resources/base/element/string.json deleted file mode 100644 index ac1a8264ec70561c846bdc64a5d7a7d902cdf086..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "NewsDemo" - }, - { - "name": "mainability_description", - "value": "hap sample empty page" - }, - { - "name": "serviceability_description", - "value": "hap sample empty service" - }, - { - "name": "news_text", - "value": "There are also smaller base stations, as large as the palm of your hand. Actually, there are many micro base stations, especially in urban areas and indoor areas. In the future, in the 5G era, more micro base stations will be installed everywhere, almost everywhere. You'd be asking, if there are so many base stations around, will it affect the human body? My answer is - no. In fact, contrary to the traditional perception, the more base stations, the less the radiation. Do you think, in winter, in a house of people, a large power heater is better, or a few small power heaters? Small base stations and low power are good for everyone. If only a large BTS is used, the distance between the BTS and the BTS is large and the BTS is far away from the BTS, and the BTS has no signal. There are also smaller base stations, as large as the palm of your hand. Actually, there are many micro base stations, especially in urban areas and indoor areas. In the future, in the 5G era, more micro base stations will be installed everywhere, almost everywhere. You'd be asking, if there are so many base stations around, will it affect the human body? My answer is - no. In fact, contrary to the traditional perception, the more base stations, the less the radiation. Do you think, in winter, in a house of people, a large power heater is better, or a few small power heaters? Small base stations and low power are good for everyone. If only a large BTS is used, the distance between the BTS and the BTS is large and the BTS is far away from the BTS, and the BTS has no signal. There are also smaller base stations, as large as the palm of your hand. Actually, there are many micro base stations, especially in urban areas and indoor areas. In the future, in the 5G era, more micro base stations will be installed everywhere, almost everywhere. You'd be asking, if there are so many base stations around, will it affect the human body? My answer is - no. In fact, contrary to the traditional perception, the more base stations, the less the radiation. Do you think, in winter, in a house of people, a large power heater is better, or a few small power heaters? Small base stations and low power are good for everyone. If only a large BTS is used, the distance between the BTS and the BTS is large and the BTS is far away from the BTS, and the BTS has no signal." - } - ] -} - - diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/graphic/corner_bg_comment.xml b/HarmonyOSNewsClient/entry/src/main/resources/base/graphic/corner_bg_comment.xml deleted file mode 100644 index 46d5f906e06bfaec1928b3e93341c48f3c0296a5..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/resources/base/graphic/corner_bg_comment.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/layout/device_list_item.xml b/HarmonyOSNewsClient/entry/src/main/resources/base/layout/device_list_item.xml deleted file mode 100644 index 93fd91cd2404a8bdebccaf2ac6662a8674af4e98..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/resources/base/layout/device_list_item.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/layout/item_news_layout.xml b/HarmonyOSNewsClient/entry/src/main/resources/base/layout/item_news_layout.xml deleted file mode 100644 index 551a963b79de53bc0c723e2003478f8fc99ff176..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/resources/base/layout/item_news_layout.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/layout/item_news_type_layout.xml b/HarmonyOSNewsClient/entry/src/main/resources/base/layout/item_news_type_layout.xml deleted file mode 100644 index e5c7801bb83b63f6d7b4253662fefbaed33fb4b6..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/resources/base/layout/item_news_type_layout.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - \ No newline at end of file diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/layout/news_detail_layout.xml b/HarmonyOSNewsClient/entry/src/main/resources/base/layout/news_detail_layout.xml deleted file mode 100644 index 63a79803f892a8cd5ef78e04c7968042f15b9056..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/resources/base/layout/news_detail_layout.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/layout/news_list_layout.xml b/HarmonyOSNewsClient/entry/src/main/resources/base/layout/news_list_layout.xml deleted file mode 100644 index 07a6b054a3126829a120ba2a69ce6e6b4ea70661..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/resources/base/layout/news_list_layout.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/collect_icon.png b/HarmonyOSNewsClient/entry/src/main/resources/base/media/collect_icon.png deleted file mode 100644 index 4b8235df45956d419edca3905813c65c153df6fe..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/collect_icon.png and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/huawei.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/huawei.jpg deleted file mode 100644 index 879e6df4a2a73737491eff4cf092d82468e4c58a..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/huawei.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/icon.png b/HarmonyOSNewsClient/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/like_icon.png b/HarmonyOSNewsClient/entry/src/main/resources/base/media/like_icon.png deleted file mode 100644 index 06d52687a3484057ebb411e3d87a7805c1aad31c..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/like_icon.png and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/message_icon.png b/HarmonyOSNewsClient/entry/src/main/resources/base/media/message_icon.png deleted file mode 100644 index 9272e6e1de35808e9f2a2b5461e28d71b58f8931..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/message_icon.png and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image1.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image1.jpg deleted file mode 100644 index bfe2ae5849d6b022c2eab195f0fc0c04721db285..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image1.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image10.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image10.jpg deleted file mode 100644 index 781936afc0354e0f22d1b77339968927c29ffb36..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image10.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image11.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image11.jpg deleted file mode 100644 index f2862e308f284c5cc87d06c5316d5edec86028f3..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image11.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image12.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image12.jpg deleted file mode 100644 index 0425178705c4e56888d7df2b308efdfcd7ac8640..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image12.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image13.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image13.jpg deleted file mode 100644 index b349d81e1dce2d2a553baaf26a5b7fde58d8beac..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image13.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image14.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image14.jpg deleted file mode 100644 index e3d1ca269b529e890a3e154ac081e93487f5743b..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image14.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image15.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image15.jpg deleted file mode 100644 index 54775977a85c165759a22b8c8e956ecc59603ff8..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image15.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image16.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image16.jpg deleted file mode 100644 index 17780bfc6f7f014b1920fa5159cb1a4699a5de49..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image16.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image17.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image17.jpg deleted file mode 100644 index a34dcd88e1507fd07d509fcffe024dfe7a59ab39..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image17.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image18.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image18.jpg deleted file mode 100644 index ad79353b9bcfb2cd5b05ef6296f29e3ac826d3ca..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image18.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image19.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image19.jpg deleted file mode 100644 index 5e8c9267e9632b829492f6d93bfebfcb9c0dc114..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image19.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image2.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image2.jpg deleted file mode 100644 index 2322f158e6a108b8a4f2bbcb20204bd7974c12d9..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image2.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image3.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image3.jpg deleted file mode 100644 index 6da8be18ed043a9fc815689e7482e9fe04969f1a..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image3.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image4.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image4.jpg deleted file mode 100644 index 78bfe6f367b9534e1236725b50a2b98934a76827..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image4.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image5.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image5.jpg deleted file mode 100644 index bda3780f9779e2169cea6b3cd0aae77bc6e6cc95..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image5.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image6.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image6.jpg deleted file mode 100644 index 60ebfaa4bd05ca32c40b99f247a9d2998d85dd69..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image6.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image7.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image7.jpg deleted file mode 100644 index bfc4fb58e7a5ca3062dc775721f9106d333adaec..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image7.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image8.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image8.jpg deleted file mode 100644 index e58a289f7d136043766f33f168a87af367c370f3..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image8.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image9.jpg b/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image9.jpg deleted file mode 100644 index e7de107a86d8a741fa4112c3df79c60a1ac086e5..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/news_image9.jpg and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/search.png b/HarmonyOSNewsClient/entry/src/main/resources/base/media/search.png deleted file mode 100644 index 837c207e538e7ac03af8e3ce24509da0f8c7fdf9..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/search.png and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/base/media/share_icon.png b/HarmonyOSNewsClient/entry/src/main/resources/base/media/share_icon.png deleted file mode 100644 index d7b19a4a7d6c96d8aeac1062cf7a7c05be127f8b..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/entry/src/main/resources/base/media/share_icon.png and /dev/null differ diff --git a/HarmonyOSNewsClient/entry/src/main/resources/rawfile/news_datas.json b/HarmonyOSNewsClient/entry/src/main/resources/rawfile/news_datas.json deleted file mode 100644 index c640ecf6344c727e7e57562442585e68a26e7952..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/resources/rawfile/news_datas.json +++ /dev/null @@ -1,154 +0,0 @@ -[ - { - "title": "Best Enterprise Wi-Fi Network Award of the Wireless Broadband Alliance 2020", - "type": "Health", - "imgUrl": "entry/resources/base/media/news_image1.jpg", - "reads": "54", - "likes": "81", - "content": "Recently, at the Wireless Broadband Alliance (WBA), an international industry organization, Huawei's AirEngine Wi-Fi 6 Solution Helps Factory Digital Transformation WBA 2020 Wi-Fi Industry Best Enterprise Wi-Fi Network Award. This is the first time that a Chinese Wi-Fi 6 vendor has won this award, which reflects the full recognition of Huawei AirEngine Wi-Fi 6 by global enterprise users." - }, - { - "title": "Latest technology and industry weather vane", - "type": "Health", - "imgUrl": "entry/resources/base/media/news_image2.jpg", - "reads": "100", - "likes": "354", - "content": "With the large-scale commercial use of new technologies such as 5G, IoT, cloud computing, and AI, industry digital transformation has entered deep water. In addition, the sudden epidemic and carbon-neutral targets accelerate the transformation of society towards intelligence. When energy technologies are combined with power electronics and digital technologies, what direction will site energy develop?" - }, - { - "title": "Openness and Cooperation Facilitate Industry Upgrade", - "type": "Finance", - "imgUrl": "entry/resources/base/media/news_image3.jpg", - "reads": "74", - "likes": "91", - "content": "Under the background of new infrastructure construction, digital transformation will face great pressure in power consumption. According to analysis data, it is estimated that the number of communication sites will increase to 70 million by 2025, and the annual power consumption will exceed 660 billion kWh. The data center will increase to 24 million racks, and the annual power consumption will exceed 950 billion kWh. In pan-industrial scenarios, the annual power consumption of rail transportation and industrial manufacturing alone will exceed 16 trillion kWh There are 40 billion smart terminals, and the annual power consumption will reach 210 billion kWh. The 40 billion mobile terminals under the 21 billion kWh power are driven by the transformation of social media and digital life." - }, - { - "title": "High-voltage super-fast charging is an inevitable trend", - "type": "Finance", - "imgUrl": "entry/resources/base/media/news_image4.jpg", - "reads": "44", - "likes": "82", - "content": "Consumers have a lot of doubts about buying electric cars, compared to fuel cars. Wang Chao pointed out that among the factors affecting the purchase of electric vehicles, charging problems account for 80 percent, with a small number of charging piles (currently, the ratio of piles is 3.2:1) and a long charging time being the first to bear the brunt. As a result, many players in the charging infrastructure sector are looking for a break. To alleviate consumers' pain points of poor charging experience, we need to improve the pile ratio and shorten the charging time to meet consumers' requirements for fast charging." - }, - { - "title": "Huawei Releases the New Trend of Modular Power Supply, Facilitating Industry Upgrade Through Open Cooperation", - "type": "Technology", - "imgUrl": "entry/resources/base/media/news_image5.jpg", - "reads": "73", - "likes": "888", - "content": "Under the background of new infrastructure construction, digital transformation will face great pressure in power consumption. According to analysis data, it is estimated that the number of communication sites will increase to 70 million by 2025, and the annual power consumption will exceed 660 billion kWh. The data center will increase to 24 million racks, and the annual power consumption will exceed 950 billion kWh. In pan-industrial scenarios, the annual power consumption of rail transportation and industrial manufacturing alone will exceed 16 trillion kWh. There are 40 billion smart terminals, and the annual power consumption will reach 210 billion kWh. The 40 billion mobile terminals under the 21 billion kWh power are driven by the transformation of social media and digital life." - }, - { - "title": "Ten Future Trends of Digital Energy", - "type": "Technology", - "imgUrl": "entry/resources/base/media/news_image6.jpg", - "reads": "100", - "likes": "354", - "content": "Energy digitalization is an inevitable trend. Innovative integration of digital and energy technologies enables end-to-end visual, manageable, and controllable intelligent management of energy infrastructure, improving energy efficiency.\nGreen power will benefit thousands of industries and households in the future. Green power, represented by PV, will become the main energy source. The era of price-effective PV is coming, and the integration of distributed power generation and solar storage will become an inevitable trend. Green Power will also help the ICT industry reduce its carbon footprint. In the future, we will build a \"zero-carbon network\" and \"zero-carbon\" data center. In addition, Huawei proposed the trend of full-link efficiency for the first time and implemented global optimization in terms of architecture and system." - }, - { - "title": "Ascend Helps Industry, Learning, and Research Promote AI Industry Development in the National AI Contest", - "type": "Sport", - "imgUrl": "entry/resources/base/media/news_image7.jpg", - "reads": "123", - "likes": "911", - "content": "The holding of the National AI Contest further fulfilled the requirements of the Ministry of Science and Technology and the Ministry of Industry and Information Technology for Shenzhen to build the national new-generation AI innovation and development trial zone and the AI innovation and application pilot zone. It also promoted the integration and development of innovation elements such as industry, academia, capital, and talent, create an AI innovation atmosphere. Huawei has co-hosted two National AI Competitions in a row, aiming to promote technological progress, industrial upgrade, economic transformation, and social progress, and jointly promote the implementation of AI technologies. This is the most practical point for Huawei and the National AI Competition." - }, - { - "title": "Enterprise data centers are moving towards autonomous driving network", - "type": "Sport", - "imgUrl": "entry/resources/base/media/news_image8.jpg", - "reads": "754", - "likes": "149", - "content": "More than 90% of enterprises say that fully autonomous driving data center network is their goal to achieve business agility, flexibility, and cost-effectiveness. This is a key research result in the data center network Autonomous Driving Index Report released by Huawei and IDC. Autonomous driving data center network helps enterprises restructure network architectures and operation models and enhance business resilience and continuity. In addition, regardless of the current level of data center network automation, IDC offers some guidance on how enterprises can move forward and move towards full automation." - }, - { - "title": "One optical fiber lights up a green smart room", - "type": "Internet", - "imgUrl": "entry/resources/base/media/news_image9.jpg", - "reads": "631", - "likes": "714", - "content": "At the 2020 China Real Estate Development Summit held in Guangzhou, Jin Yuzhi, President of Huawei's Transmission and Access Product Line, delivered a keynote speech entitled \"One Fiber Lights Green Smart Rooms\" to discuss the convergence development trend of optical networks and real estate industries, proposes that optical fibers are the standard configuration of F5G smart real estate, and shares seven reasons for choosing Fiber to the Room (FTTR) all-optical home networking, we call on industry partners to work together to build an F5G real gigabit all-optical room ecosystem." - }, - { - "title": "BWS2020: Accelerate Network Autonomy and Enable Agile Business", - "type": "Internet", - "imgUrl": "entry/resources/base/media/news_image10.jpg", - "reads": "53", - "likes": "824", - "content": "Currently, millions of enterprises embrace changes and accelerate their cloudification. SaaS traffic surges. Enterprise cloudification and multi-cloud collaboration become the new focus of cloud-network synergy . To address this challenge, Guo Dazheng, president of Huawei's data communications field, said: \"In cloud-network scenarios, iMaster NCE implements network as a service to help carriers provide cloud-network integration services and meet enterprise cloud access requirements.\" In 5G transport scenarios, improve the automation capability of the entire process of planning, construction, maintenance, and optimization to meet the requirements of large-scale 5G network construction and cloud network cost reduction and efficiency improvement." - }, - { - "title": "Trust technology, embrace openness, and share the world prosperity brought by technology", - "type": "Game", - "imgUrl": "entry/resources/base/media/news_image11.jpg", - "reads": "1500", - "likes": "3542", - "content": "Huawei successfully held the TrustInTech 2020 online summit today. Ryan Ding, Executive Director of Huawei, President of the Carrier BG, and Jim Rogers, a senior Wall Street investor, GSMA Chief Marketing Officer Stephanie Lynch-Habib and other ICT industry experts and economists from around the world attended the summit. The summit pointed out that ICT has become a digital foundation for economic development and people's livelihood. In an era of accelerated commercial use of 5G, the world needs to embrace openness and cooperation to eliminate unnecessary resistance and fears about new technologies and transnational cooperation, thereby sharing the world prosperity brought by technology." - }, - { - "title": "Intelligent Twins Won the Leading Technology Achievement Award at the 7th World Internet Conference", - "type": "Game", - "imgUrl": "entry/resources/base/media/news_image12.jpg", - "reads": "7451", - "likes": "9511", - "content": "Today, the Leading Technology Award was unveiled at the 7th World Internet Conference. As the industry's first systematic technical reference architecture for government and enterprise intelligence upgrade, intelligent virtual appliances have been recognized by experts and judges and won the Leading Scientific Achievement Award for their exploration and practice in various industries. This is the fifth time Huawei has won this award since 2016. The World Internet Leading Science and Technology Award showcases the latest technologies in the global ICT field and focuses on the best practices of innovative technologies in the fields of science and technology fight against epidemics, recovery of work, and promotion of digital economic development and cooperation." - }, - { - "title": "4G/5G FWA, New Engine for Revenue Growth", - "type": "Health", - "imgUrl": "entry/resources/base/media/news_image13.jpg", - "reads": "445", - "likes": "872", - "content": "The reason why FWA is growing so fast is that it provides new opportunities for carriers in the consumer market. For example, a Philippine operator used 4G FWA to rapidly develop home broadband users. According to its third quarter financial report, the operator has successfully developed 2.78 million new users this year, accounting for 80% of the total broadband users. The percentage of broadband revenue increased from 12.3% in 2017 to 17.9%. With the development of wireless technologies, 5G FWA can provide gigabit home access experience similar to that of optical fibers, meeting services such as 4K/8K HD video and AR/VR interactive experience." - }, - { - "title": "Down! CPI released in November! These things are cheap", - "type": "Finance", - "imgUrl": "entry/resources/base/media/news_image14.jpg", - "reads": "734", - "likes": "8788", - "content": "Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap.Down! CPI released in November! These things are cheap." - }, - { - "title": "Comedy movie \"Big Red Envelope\" is set to celebrate the New Year", - "type": "Technology", - "imgUrl": "entry/resources/base/media/news_image15.jpg", - "reads": "1010", - "likes": "3534", - "content": "Comedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New YearComedy movie \"Big Red Envelope\" is set to celebrate the New Year" - }, - { - "title": "Three living things are smart", - "type": "Sport", - "imgUrl": "entry/resources/base/media/news_image16.jpg", - "reads": "1243", - "likes": "9141", - "content": "Lifan said at the press conference: \"Retrospective on the journey, we have always adhered to the spirit of initiative, innovation and science. Build core capabilities in terms of networks, technologies, and platforms, and deliver excellent services, technologies, and quality. Internal maintenance, optimization, and sharing are in place. Carriers, equipment vendors, and partners are working together to build an end-to-end network capability and win-win ecosystem to provide users with the best 5G experience and services.\"" - }, - { - "title": "Maximizing the Value of Wireless Networks and Ushering in the Golden Decade of 5G", - "type": "Internet", - "imgUrl": "entry/resources/base/media/news_image17.jpg", - "reads": "7574", - "likes": "1439", - "content": "The 5G industry is developing faster than the previous standards. Currently, there are more than 100 5G commercial networks around the world, and the price of entry-level 5G mobile phones has fallen to CNY1,000, which has led to the rapid growth of 5G users worldwide. Thanks to this, leading operators have enjoyed the data dividend brought by 5G. The multi-dimensional package design and 5G message and 5G new communication services are upgraded to increase the ARPU of 5G users to different degrees.\nTo promote the further development of 5G networks and encourage more users to choose and prefer 5G networks, operators need to build 5G top-quality networks for individual users to achieve full-scenario coverage in densely populated urban areas, suburban areas, and indoor areas, allowing mobile phone users to access 5G services anytime, anywhere. In addition, 5G connection experience is optimized to ensure consistent user experience." - }, - { - "title": "Technology Helps Art, Leads a New Era", - "type": "Game", - "imgUrl": "entry/resources/base/media/news_image18.jpg", - "reads": "6311", - "likes": "7114", - "content": "Zhang Wenlin spoke highly of the \"Dance Storm\". He believes that since the second season's premiere, the show has brought the contestants' exquisite dance moves, the wonderful host of Mr Ho Kung, the excellent comments of the judges' tutors, and the exquisite design of the staff to the audience, dedicate a beautiful visual feast! To help achieve fantastic visual effects, Hunan Radio and TV set up a joint team with Huawei to develop a spatio-temporal condensation system for Dance Storm 2. The system supports AI algorithms such as intelligent fast focusing, butterfly shooting, zoom-in, and multi-focus, with the help of the video 3.0+ platform of device-cloud synergy, the program team has made several industry-leading achievements, such as the three-dimensional storm moment with fantastic visual changes, free-view Dance Storm program with interactive control and rotation, and dance Storm with 360-degree panoramic view. VR programs." - }, - { - "title": "Open Intelligent Twin Ecosystem Is the Key to All-Scenario Intelligence", - "type": "Health", - "imgUrl": "entry/resources/base/media/news_image19.jpg", - "reads": "6341", - "likes": "7164", - "content": "Intelligent upgrade will build core competitiveness in various industries. Huawei works with partners to integrate 5G, cloud, AI, intelligent edge, and industry applications to form an integrated intelligent system and create industry-leading smart experience. In the transportation industry, the abolition of highway toll stations at the provincial boundary enables fast and insensitive traffic, greatly improving traffic efficiency and reducing logistics transportation costs. Intelligent cameras are deployed on highway portals to collect vehicle traffic data 24 hours a day and send the data to the cloud in real time over the high-speed network for real-time charging. In addition, AI models trained on the cloud can be pushed to the edge so that cameras can have capabilities such as license plate recognition and vehicle feature extraction, and the capabilities can be continuously evolved. For example, in extreme weather conditions such as rain and snow, one-click upgrade can be performed on the cloud." - } -] diff --git a/HarmonyOSNewsClient/entry/src/main/resources/rawfile/news_type_datas.json b/HarmonyOSNewsClient/entry/src/main/resources/rawfile/news_type_datas.json deleted file mode 100644 index 8c131e8c361b2b084700a62730c8d028220d63a3..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/entry/src/main/resources/rawfile/news_type_datas.json +++ /dev/null @@ -1,25 +0,0 @@ -[ - { - "name": "All" - }, - { - "name": "Health" - }, - { - "name": "Finance" - }, - { - "name": "Technology" - }, - { - "name": "Sport" - }, - { - "name": "Internet" - }, - { - "name": "Game" - } -] - - diff --git a/HarmonyOSNewsClient/gradle/wrapper/gradle-wrapper.jar b/HarmonyOSNewsClient/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f6b961fd5a86aa5fbfe90f707c3138408be7c718..0000000000000000000000000000000000000000 Binary files a/HarmonyOSNewsClient/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/HarmonyOSNewsClient/gradle/wrapper/gradle-wrapper.properties b/HarmonyOSNewsClient/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index f59159e865d4b59feb1b8c44b001f62fc5d58df4..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/HarmonyOSNewsClient/settings.gradle b/HarmonyOSNewsClient/settings.gradle deleted file mode 100644 index 4773db73233a570c2d0c01a22e75321acfbf7a07..0000000000000000000000000000000000000000 --- a/HarmonyOSNewsClient/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':entry' diff --git a/DialogDemo/build.gradle b/ImageJsDemo/build.gradle similarity index 80% rename from DialogDemo/build.gradle rename to ImageJsDemo/build.gradle index 053b598314427762ef9ed02bced2d2b234093d42..9cf74c205fc884ae2c6796ce2298ecbe3f40672d 100644 --- a/DialogDemo/build.gradle +++ b/ImageJsDemo/build.gradle @@ -3,10 +3,7 @@ apply plugin: 'com.huawei.ohos.app' //For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 4 - } + compileSdkVersion 6 } buildscript { @@ -19,8 +16,8 @@ buildscript { } } dependencies { - classpath 'com.huawei.ohos:hap:2.4.5.0' - classpath 'com.huawei.ohos:decctest:1.2.4.1' + classpath 'com.huawei.ohos:hap:2.4.5.5' + classpath 'com.huawei.ohos:decctest:1.2.5.1' } } diff --git a/ClickableImageJsDemo/entry/.gitignore b/ImageJsDemo/entry/.gitignore similarity index 33% rename from ClickableImageJsDemo/entry/.gitignore rename to ImageJsDemo/entry/.gitignore index 796b96d1c402326528b4ba3c12ee9d92d0e212e9..7d5b7a94f4dcf381f03ff21f28f8a2494b58023f 100644 --- a/ClickableImageJsDemo/entry/.gitignore +++ b/ImageJsDemo/entry/.gitignore @@ -1 +1,2 @@ /build +/node_modules diff --git a/ClickableImageJsDemo/entry/build.gradle b/ImageJsDemo/entry/build.gradle similarity index 72% rename from ClickableImageJsDemo/entry/build.gradle rename to ImageJsDemo/entry/build.gradle index f4104e638c0aaf4eb3d1d8c37046528472db9722..cccb71cae91018743841ab76aeb19c595f4ed847 100644 --- a/ClickableImageJsDemo/entry/build.gradle +++ b/ImageJsDemo/entry/build.gradle @@ -1,10 +1,9 @@ apply plugin: 'com.huawei.ohos.hap' -apply plugin: 'com.huawei.ohos.decctest' //For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 ohos { - compileSdkVersion 5 + compileSdkVersion 6 defaultConfig { - compatibleSdkVersion 5 + compatibleSdkVersion 6 } buildTypes { release { @@ -15,13 +14,10 @@ ohos { } } + supportSystem "standard" } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) testImplementation 'junit:junit:4.13' - ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.200' -} -decc { - supportType = ['html', 'xml'] } diff --git a/DialogDemo/entry/package.json b/ImageJsDemo/entry/package.json similarity index 100% rename from DialogDemo/entry/package.json rename to ImageJsDemo/entry/package.json diff --git a/DialogDemo/entry/proguard-rules.pro b/ImageJsDemo/entry/proguard-rules.pro similarity index 100% rename from DialogDemo/entry/proguard-rules.pro rename to ImageJsDemo/entry/proguard-rules.pro diff --git a/InputApplication/entry/src/main/config.json b/ImageJsDemo/entry/src/main/config.json similarity index 76% rename from InputApplication/entry/src/main/config.json rename to ImageJsDemo/entry/src/main/config.json index 251d271536fa4d876b012355a68b2d0d4ba9ba13..de7878a02f417d2ede74d3cbffd4c1a636cef05d 100644 --- a/InputApplication/entry/src/main/config.json +++ b/ImageJsDemo/entry/src/main/config.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.huawei.cookbook", + "bundleName": "com.huawei.imagejsdemo", "vendor": "huawei", "version": { "code": 1000000, @@ -9,9 +9,9 @@ }, "deviceConfig": {}, "module": { - "package": "com.huawei.cookbook", + "package": "com.huawei.imagejsdemo", "name": ".MyApplication", - "mainAbility": "com.huawei.cookbook.MainAbility", + "mainAbility": "com.huawei.imagejsdemo.MainAbility", "deviceType": [ "phone" ], @@ -33,9 +33,11 @@ ] } ], - "name": "com.huawei.cookbook.MainAbility", + "orientation": "unspecified", + "name": "com.huawei.imagejsdemo.MainAbility", "icon": "$media:icon", "description": "$string:mainability_description", + "formsEnabled": false, "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" @@ -49,7 +51,7 @@ "name": "default", "window": { "designWidth": 720, - "autoDesignWidth": true + "autoDesignWidth": false } } ] diff --git a/ShoppingJs/entry/src/ohosTest/js/default/app.js b/ImageJsDemo/entry/src/main/js/default/app.js similarity index 42% rename from ShoppingJs/entry/src/ohosTest/js/default/app.js rename to ImageJsDemo/entry/src/main/js/default/app.js index d8dfc5237086ae1af0e29ab1a8b1fd40f13a9b7a..6d060ffe5682c19fc83e2274a9e62cbc40a655f8 100644 --- a/ShoppingJs/entry/src/ohosTest/js/default/app.js +++ b/ImageJsDemo/entry/src/main/js/default/app.js @@ -1,6 +1,8 @@ export default { onCreate() { + console.info("Application onCreate"); }, onDestroy() { + console.info("Application onDestroy"); } }; diff --git a/ImageJsDemo/entry/src/main/js/default/common/images/shanghai.jpg b/ImageJsDemo/entry/src/main/js/default/common/images/shanghai.jpg new file mode 100644 index 0000000000000000000000000000000000000000..34398556be62536f7c9490ccd0ab7e39f81f2896 Binary files /dev/null and b/ImageJsDemo/entry/src/main/js/default/common/images/shanghai.jpg differ diff --git a/AnimationDemo/entry/src/ohosTest/js/default/i18n/en-US.json b/ImageJsDemo/entry/src/main/js/default/i18n/en-US.json similarity index 40% rename from AnimationDemo/entry/src/ohosTest/js/default/i18n/en-US.json rename to ImageJsDemo/entry/src/main/js/default/i18n/en-US.json index 55561b83737c3c31d082fbfa11e5fc987a351104..08e34eac912bf2651eefc20e26aa479b5e4e7ec2 100644 --- a/AnimationDemo/entry/src/ohosTest/js/default/i18n/en-US.json +++ b/ImageJsDemo/entry/src/main/js/default/i18n/en-US.json @@ -1,7 +1,10 @@ { "strings": { "hello": "Hello", - "world": "World" + "world": "World", + "page": "Second Page", + "next": "Next Page", + "back": "Back" }, "Files": { } diff --git a/DialogDemo/entry/src/ohosTest/js/default/i18n/zh-CN.json b/ImageJsDemo/entry/src/main/js/default/i18n/zh-CN.json similarity index 40% rename from DialogDemo/entry/src/ohosTest/js/default/i18n/zh-CN.json rename to ImageJsDemo/entry/src/main/js/default/i18n/zh-CN.json index cce1af06761a42add0cac1a0567aa3237eda8cb4..3dd53b3a8b808aec9396fa663cb00ef22ba61e0a 100644 --- a/DialogDemo/entry/src/ohosTest/js/default/i18n/zh-CN.json +++ b/ImageJsDemo/entry/src/main/js/default/i18n/zh-CN.json @@ -1,7 +1,10 @@ { "strings": { "hello": "您好", - "world": "世界" + "world": "世界", + "page": "第二页", + "next": "下一页", + "back": "返回" }, "Files": { } diff --git a/ImageJsDemo/entry/src/main/js/default/pages/index/index.css b/ImageJsDemo/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..824ce5bb8e4dfd41378ece37d7e78050cd5d0a5b --- /dev/null +++ b/ImageJsDemo/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,45 @@ +.container { + justify-content: flex-start; + left: 0px; + top: 0px; + width: 100%; + height: 100%; + flex-direction: column; +} + +.title { + font-size: 30px; + text-align: center; + width: 200px; + height: 100px; + justify-content: center; + align-items: center; +} +.title-div{ + width: 100%; + height: 100px; + align-items: center; + justify-content: center; +} +.button-div{ + justify-content: center; + height: 100px; +} +.button{ + margin: 10px; + font-size: 22px; + background-color: #e9e9e9; + text-color: black; + width: 180px; + text-align: center; + height: 120px; +} +.image-div{ + width: 100%; + justify-content: center; + margin-top: 100px; +} +.image{ + width: 576px; + height: 432px; +} \ No newline at end of file diff --git a/ImageJsDemo/entry/src/main/js/default/pages/index/index.hml b/ImageJsDemo/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..5b76f7400c024bcc3fcd801ab0ab6440f8f675c5 --- /dev/null +++ b/ImageJsDemo/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,19 @@ +
+
+ + {{title}} + +
+
+ + + + +
+
+ + + + +
+
diff --git a/ImageJsDemo/entry/src/main/js/default/pages/index/index.js b/ImageJsDemo/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..772d252af64eebf47f35327cfea885fc4593f39a --- /dev/null +++ b/ImageJsDemo/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,86 @@ +// @ts-nocheck +export default { + data: { + title: "图像开发", + imageUrl: "/common/images/shanghai.jpg", + isRevolve: true, + isCut: false, + isScale: false, + isMirror: false, + scaleState: false, + degrees: 0, + xDegrees: 0, + yDegrees: 0, + rotateIndex: 0, + width: 576, + height: 488, + clipArray:[0, 0, 0, 0] + }, + // 旋转 + imageRotate() { + if (!this.isRevolve) { + this.isRevolve = true + this.isCut = false + this.isScale = false + this.isMirror = false + this.rotateIndex = 0 + } + if (this.rotateIndex <3) { + this.rotateIndex++ + } else{ + this.rotateIndex = 0 + } + this.degrees = this.rotateIndex * 90 + }, + // 剪裁 + imageCut() { + if (!this.isCut) { + this.isRevolve = false + this.isCut = true + this.isScale = false + this.isMirror = false + + } + if (this.clipArray[2] === 0) { + // 值指的是 top, right, bottom, left 四个点 + this.clipArray = [0, 0, this.height/2,0] + } else { + this.clipArray = [0, 0, 0, 0] + } + }, + // 缩放 + imageScale() { + if (!this.isScale) { + this.isRevolve = false + this.isCut = false + this.isScale = true + this.isMirror = false + if (this.width === 576) { + this.width = this.width/2 + this.height = this.height/2 + } + } else { + if (this.width === 576) { + this.width = this.width/2 + this.height = this.height/2 + } else { + this.width = this.width*2 + this.height = this.height*2 + } + } + }, + imageMirror() { + if (!this.isMirror) { + this.isRevolve = false + this.isCut = false + this.isScale = false + this.isMirror = true + this.yDegrees = 0 + } + if (this.yDegrees === 0) { + this.yDegrees = 180 + } else{ + this.yDegrees = 0 + } + } +} \ No newline at end of file diff --git a/ToolbarApplication/entry/src/main/resources/base/element/string.json b/ImageJsDemo/entry/src/main/resources/base/element/string.json similarity index 100% rename from ToolbarApplication/entry/src/main/resources/base/element/string.json rename to ImageJsDemo/entry/src/main/resources/base/element/string.json diff --git a/AudioDemo/entry/src/main/resources/base/media/icon.png b/ImageJsDemo/entry/src/main/resources/base/media/icon.png similarity index 100% rename from AudioDemo/entry/src/main/resources/base/media/icon.png rename to ImageJsDemo/entry/src/main/resources/base/media/icon.png diff --git a/ClickableImageJsDemo/gradle/wrapper/gradle-wrapper.jar b/ImageJsDemo/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from ClickableImageJsDemo/gradle/wrapper/gradle-wrapper.jar rename to ImageJsDemo/gradle/wrapper/gradle-wrapper.jar diff --git a/ClickableImageJsDemo/gradle/wrapper/gradle-wrapper.properties b/ImageJsDemo/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from ClickableImageJsDemo/gradle/wrapper/gradle-wrapper.properties rename to ImageJsDemo/gradle/wrapper/gradle-wrapper.properties diff --git a/ClickableImageJsDemo/settings.gradle b/ImageJsDemo/settings.gradle similarity index 100% rename from ClickableImageJsDemo/settings.gradle rename to ImageJsDemo/settings.gradle diff --git a/InputApplication/LICENSE b/InputApplication/LICENSE deleted file mode 100644 index 7c357dc828cf7d8c783f10ed6bb1bac8a1e903c1..0000000000000000000000000000000000000000 --- a/InputApplication/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - Copyright (c) 2021 Huawei Device Co., Ltd. - - Licensed under the Apache License,Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -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/InputApplication/README.md b/InputApplication/README.md deleted file mode 100644 index fe65630d1bcd0def9dbc94b07ea98302c4b6237c..0000000000000000000000000000000000000000 --- a/InputApplication/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# InputApplication -简介 -• 此Demo使用JS UI中的input组件,实现输入框和表单提交。您可以在input输入框输入内容,长按input输入框对输入内容进行翻译、分享、查找等操作,点击提交按钮时对必填项进行校验。 - -安装要求 -• 安装DevEco Studio -• 设置DevEco Studio开发环境。DevEco Studio开发环境需要连接到网络,以确保该正常使用。可以根据以下两种情况配置开发环境: - 1.如果您可以直接访问Internet,则只需下载HarmonyOS SDK - 2.如果网络无法直接访问Internet,则可以通过代理服务器进行访问 -• 生成密钥并申请证书 - -用户指南 -• 下载此项目 -• 打开HUAWEI DevEco Studio,单击File> Open选择此ComponentCodelab -• 单击Build> Build App(s)/Hap(s)>Build Debug Hap(s)以编译hap软件包 -• 单击Run> Run 'entry'以运行hap包 - -注意 -• 您可以选择在模拟器或真机上运行hap软件包。 -• 如果在真机上运行它,则需要在项目的File> Project Structure> Modules> Signing Configs中配置签名和证书信息。 - -许可 -请参阅LICENSE文件以获得更多信息。 - -What is it? -This demo uses the input text box to submit forms. You can enter content in the input text box, touch and hold the input text box to translate, share, and search the content, and verify mandatory fields when you click Submit. - -Installation requirements -• Install DevEco Studio -• Set up the DevEco Studio development environment.The DevEco Studio development environment needs to depend on the network environment. It needs to be connected to the network to ensure the normal use of the tool.The development environment can be configured according to the following two situations - 1.If you can directly access the Internet, just download the HarmonyOS SDK - 2.If the network cannot access the Internet directly, it can be accessed through a proxy server -• Generate secret key and apply for certificate - -User guide -• Download this Project -• Open HUAWEI DevEco Studio, click File> Open> Then select and open this Project -• Click Build> Build App(s)/Hap(s)>Build Debug Hap(s) to compile the hap package -• Click Run> Run 'entry' to run the hap package - -Note -• You can choose to run the hap package on the simulator or the phone. -• If you run it on the phone, you need to configure the signature and certificate information in the project's File> Project Structure> Modules> Signing Configs. - -Licensing -Please see LICENSE for more info. \ No newline at end of file diff --git a/InputApplication/RELEASE-NOTES.MD b/InputApplication/RELEASE-NOTES.MD deleted file mode 100644 index 9087a1482627f316280b762b6c5adc73c0d438d1..0000000000000000000000000000000000000000 --- a/InputApplication/RELEASE-NOTES.MD +++ /dev/null @@ -1 +0,0 @@ -1.0.0.1 Initial version \ No newline at end of file diff --git a/InputApplication/entry/.gitignore b/InputApplication/entry/.gitignore deleted file mode 100644 index 796b96d1c402326528b4ba3c12ee9d92d0e212e9..0000000000000000000000000000000000000000 --- a/InputApplication/entry/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/InputApplication/entry/src/main/java/com/huawei/cookbook/MainAbility.java b/InputApplication/entry/src/main/java/com/huawei/cookbook/MainAbility.java deleted file mode 100644 index b6b069e2d058d44a4e69c0fc994d18f79b16d0b1..0000000000000000000000000000000000000000 --- a/InputApplication/entry/src/main/java/com/huawei/cookbook/MainAbility.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook; - -import ohos.aafwk.content.Intent; -import ohos.ace.ability.AceAbility; - -/** - * mainAbility - * - * @since 2021-08-01 - * - */ -public class MainAbility extends AceAbility { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - } - - @Override - public void onStop() { - super.onStop(); - } -} diff --git a/InputApplication/entry/src/main/java/com/huawei/cookbook/MyApplication.java b/InputApplication/entry/src/main/java/com/huawei/cookbook/MyApplication.java deleted file mode 100644 index 6cedbab02ce50255c20556435d2e2360659ff817..0000000000000000000000000000000000000000 --- a/InputApplication/entry/src/main/java/com/huawei/cookbook/MyApplication.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook; - -import ohos.aafwk.ability.AbilityPackage; - -/** - * myApplication - * - * @since 2021-08-01 - * - */ -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/InputApplication/entry/src/main/js/default/common/images/require.png b/InputApplication/entry/src/main/js/default/common/images/require.png deleted file mode 100644 index d0860084482180c79e480fcfa151202bf26fdafa..0000000000000000000000000000000000000000 Binary files a/InputApplication/entry/src/main/js/default/common/images/require.png and /dev/null differ diff --git a/InputApplication/entry/src/main/js/default/i18n/en-US.json b/InputApplication/entry/src/main/js/default/i18n/en-US.json deleted file mode 100644 index e63c70d978a3a53be988388c87182f81785e170c..0000000000000000000000000000000000000000 --- a/InputApplication/entry/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } -} \ No newline at end of file diff --git a/InputApplication/entry/src/main/js/default/i18n/zh-CN.json b/InputApplication/entry/src/main/js/default/i18n/zh-CN.json deleted file mode 100644 index de6ee5748322f44942c1b003319d8e66c837675f..0000000000000000000000000000000000000000 --- a/InputApplication/entry/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } -} \ No newline at end of file diff --git a/InputApplication/entry/src/main/js/default/pages/index/index.css b/InputApplication/entry/src/main/js/default/pages/index/index.css deleted file mode 100644 index 1d520a325772bb26cbaa955ced46a85b0ecb313a..0000000000000000000000000000000000000000 --- a/InputApplication/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,45 +0,0 @@ -.container { - flex-direction: column; - align-items: center; -} -.input-form { - width: 100%; - justify-content: center; - margin-top: 10px; - margin-bottom: 10px; -} -.form-text { - font-size: 20px; -} -.row { - width: 98%; - margin-top: 5px; - flex-direction: row; -} -.label { - font-size: 13px; - width: 120px; - text-align: right; -} -.input-block { - width: 100%; -} -.input { - width: 90%; - font-size: 12px; -} -.password-tip { - font-size: 10px; -} -.sex { - font-size: 10px; - margin-right: 10px; -} -.favorite { - font-size: 10px; -} -.button { - margin-top: 70px; - width: 150px; - background-color: #17A98E; -} diff --git a/InputApplication/entry/src/main/js/default/pages/index/index.hml b/InputApplication/entry/src/main/js/default/pages/index/index.hml deleted file mode 100644 index e5f93d40025a2065d7416dd1ab8faf36c55f028d..0000000000000000000000000000000000000000 --- a/InputApplication/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,66 +0,0 @@ -
-
- input 表单 -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- - - 女 - -
-
-
- -
- - 游泳 - - 健身 - - 足球 - - 篮球 -
-
- - - -
diff --git a/InputApplication/entry/src/main/js/default/pages/index/index.js b/InputApplication/entry/src/main/js/default/pages/index/index.js deleted file mode 100644 index ac2cc80a022dbc13046eacf4f233d7b38ef9823c..0000000000000000000000000000000000000000 --- a/InputApplication/entry/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,81 +0,0 @@ -import prompt from '@system.prompt'; - -export default { - data: { - require: '/common/images/require.png', - username: '', - password: '', - password2: '', - email: '', - date: '', - height: '', - favorite: [], - list: [{icon: '/common/images/require.png', content: '选项0'}, - {icon: '/common/images/require.png', content: '选项1'}] - }, - // 文本框内容发生变化 - change(e) { - const idName = e.target.id; - if (idName === 'username') { - this.username = e.value; - } else if (idName === 'password') { - this.password = e.value; - } else if (idName === 'password2') { - this.password2 = e.value; - } else if (idName === 'email') { - this.email = e.value; - } else if (idName === 'date') { - this.date = e.value; - } else if (idName === 'height') { - this.height = e.value; - } - }, - // 复选框修改 - checkboxOnChange(e) { - const value = e.target.attr.value; - if (e.checked) { - this.favorite.push(value); - } else { - this.favorite.splice(this.favorite.findIndex(e => e === value), 1); - } - }, - // 提交 - buttonClick() { - if (this.username === '') { - this.showPrompt('用户名不能为空'); - } else if (this.password === '') { - this.showPrompt('密码不能为空'); - } else if (this.password !== '' && this.password !== this.password2) { - this.showPrompt('两次密码输入不一致'); - } else if (this.email === '') { - this.showPrompt('邮箱不能为空'); - } else if (this.favorite.length === 0) { - this.showPrompt('请至少选择一个爱好'); - } else { - this.showPrompt('提交成功'); - } - }, - // 弹框 - showPrompt(msg) { - prompt.showToast({ - message: msg, - duration: 3000 - }); - }, - // 进行文本选择操作后文本选择弹窗会出现翻译按钮 - translate(e) { - this.showPrompt(e.value); - }, - // 进行文本选择操作后文本选择弹窗会出现分享按钮 - share(e) { - this.showPrompt(e.value); - }, - // 进行文本选择操作后文本选择弹窗会出现查找按钮 - search(e) { - this.showPrompt(e.value); - }, - // 用户在文本选择操作后,点击菜单项后触发该回调 - optionselect(e) { - this.showPrompt('选项' + e.index + ': ' + e.value); - } -}; diff --git a/InputApplication/entry/src/main/resources/base/media/icon.png b/InputApplication/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/InputApplication/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/InputApplication/entry/src/ohosTest/java/com/huawei/cookbook/ExampleOhosTest.java b/InputApplication/entry/src/ohosTest/java/com/huawei/cookbook/ExampleOhosTest.java deleted file mode 100644 index bf27899ae844b18c931cc6c9841267cbdb2c717c..0000000000000000000000000000000000000000 --- a/InputApplication/entry/src/ohosTest/java/com/huawei/cookbook/ExampleOhosTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.huawei.cookbook; - -import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class ExampleOhosTest { - @Test - public void testBundleName() { - final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName(); - assertEquals("com.huawei.cookbook", actualBundleName); - } -} \ No newline at end of file diff --git a/InputApplication/entry/src/ohosTest/js/default/app.js b/InputApplication/entry/src/ohosTest/js/default/app.js deleted file mode 100644 index 55b67e96deb821033f71d30b6fff05efdeb0d901..0000000000000000000000000000000000000000 --- a/InputApplication/entry/src/ohosTest/js/default/app.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - onCreate() { - console.info('TestApplication onCreate'); - }, - onDestroy() { - console.info('TestApplication onDestroy'); - } -}; diff --git a/InputApplication/entry/src/ohosTest/js/default/pages/index/index.css b/InputApplication/entry/src/ohosTest/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/InputApplication/entry/src/ohosTest/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/InputApplication/entry/src/ohosTest/js/default/pages/index/index.hml b/InputApplication/entry/src/ohosTest/js/default/pages/index/index.hml deleted file mode 100644 index f64b040a5ae394dbaa5e185e1ecd4f4556b92184..0000000000000000000000000000000000000000 --- a/InputApplication/entry/src/ohosTest/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{ $t('strings.hello') }} {{ title }} - -
diff --git a/InputApplication/entry/src/ohosTest/js/default/pages/index/index.js b/InputApplication/entry/src/ohosTest/js/default/pages/index/index.js deleted file mode 100644 index 8be2df2479a8da755ed800ad70d2b6247e21b8a2..0000000000000000000000000000000000000000 --- a/InputApplication/entry/src/ohosTest/js/default/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -import file from '@system.file' -import app from '@system.app' -import device from '@system.device' -import router from '@system.router' -import {Core, Constant, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - const reportExtend = new ReportExtend(file) - const instrumentLog = new InstrumentLog({ - 'id': 'report', - 'version': '1.0.3' - }) - core.addService('expect', expectExtend) - core.addService('report', reportExtend) - core.addService('report', instrumentLog) - core.init() - core.subscribeEvent('spec', instrumentLog) - core.subscribeEvent('suite', instrumentLog) - core.subscribeEvent('task', instrumentLog) - - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} \ No newline at end of file diff --git a/InputApplication/entry/src/ohosTest/js/test/ExampleJsunit.test.js b/InputApplication/entry/src/ohosTest/js/test/ExampleJsunit.test.js deleted file mode 100644 index b6d74caed96ddede98edd1bc9292f6568cd1cfd1..0000000000000000000000000000000000000000 --- a/InputApplication/entry/src/ohosTest/js/test/ExampleJsunit.test.js +++ /dev/null @@ -1,10 +0,0 @@ -import app from '@system.app' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -describe('appInfoTest', function () { - it('app_info_test_001', 0, function () { - var info = app.getInfo() - expect(info.versionName).assertEqual('1.0') - expect(info.versionCode).assertEqual('3') - }) -}) \ No newline at end of file diff --git a/InputApplication/entry/src/ohosTest/js/test/List.test.js b/InputApplication/entry/src/ohosTest/js/test/List.test.js deleted file mode 100644 index 305eb5bb254cd4802afaffebe68fca2f9436159f..0000000000000000000000000000000000000000 --- a/InputApplication/entry/src/ohosTest/js/test/List.test.js +++ /dev/null @@ -1 +0,0 @@ -require('./ExampleJsunit.test.js') \ No newline at end of file diff --git a/InputApplication/entry/src/ohosTest/resources/base/element/string.json b/InputApplication/entry/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index c1891e5a373ef700608709ec454185ecfd769efc..0000000000000000000000000000000000000000 --- a/InputApplication/entry/src/ohosTest/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "InputApplication" - }, - { - "name": "mainability_description", - "value": "hap sample empty page" - } - ] -} diff --git a/InputApplication/entry/src/ohosTest/resources/base/media/icon.png b/InputApplication/entry/src/ohosTest/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/InputApplication/entry/src/ohosTest/resources/base/media/icon.png and /dev/null differ diff --git a/InputApplication/gradle/wrapper/gradle-wrapper.jar b/InputApplication/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 490fda8577df6c95960ba7077c43220e5bb2c0d9..0000000000000000000000000000000000000000 Binary files a/InputApplication/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/InputApplication/gradle/wrapper/gradle-wrapper.properties b/InputApplication/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index f59159e865d4b59feb1b8c44b001f62fc5d58df4..0000000000000000000000000000000000000000 --- a/InputApplication/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/InputApplication/settings.gradle b/InputApplication/settings.gradle deleted file mode 100644 index 4773db73233a570c2d0c01a22e75321acfbf7a07..0000000000000000000000000000000000000000 --- a/InputApplication/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':entry' diff --git a/JSPlaygroundDemo/LICENSE b/JSPlaygroundDemo/LICENSE deleted file mode 100644 index eb44b24a0ff113ed4b008408a3406f792bde2adb..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - Copyright (c) 2021 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/JSPlaygroundDemo/README.md b/JSPlaygroundDemo/README.md deleted file mode 100644 index a5c4b2d0d5aacbfd8efef4a0540d57ffb4afc162..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/README.md +++ /dev/null @@ -1,26 +0,0 @@ -JSPlaygroundDemo - -简介 -•在本文中,CodeLab使用JavaScript演示来完成TODOLIST案例。 -•它旨在帮助开发人员快速了解HarmonyOS应用一次部署的经验,以进行多设备部署。 -•从项目创建、代码编写到编译、构造、部署和运行。 - -安装要求 -• 安装DevEco Studio和Node.js -• 设置DevEco Studio开发环境。 DevEco Studio开发环境需要连接到网络,以确保该正常使用。可以根据以下两种情况配置开发环境: - 1.如果您可以直接访问Internet,则只需下载HarmonyOS SDK - 2.如果网络无法直接访问Internet,则可以通过代理服务器进行访问 -• 生成密钥并申请证书 - -用户指南 -• 下载此项目 -• 打开HUAWEI DevEco Studio,单击File> Open选择此ComponentCodelab -• 单击Build> Build App(s)/Hap(s)>Build Debug Hap(s)以编译hap软件包 -• 单击Run> Run 'entry'以运行hap包 - -注意 -• 您可以选择在模拟器或真机上运行hap软件包。 -• 如果在真机上运行它,则需要在项目的File> Project Structure> Modules> Signing Configs中配置签名和证书信息。 - -许可 -请参阅LICENSE文件以获得更多信息。 \ No newline at end of file diff --git a/JSPlaygroundDemo/RELEASE-NOTES.md b/JSPlaygroundDemo/RELEASE-NOTES.md deleted file mode 100644 index ea23a13e3d4407d06cba3aa7155a23e5081b50b4..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/RELEASE-NOTES.md +++ /dev/null @@ -1,2 +0,0 @@ -1.0.0 -1.Initial version \ No newline at end of file diff --git a/JSPlaygroundDemo/build.gradle b/JSPlaygroundDemo/build.gradle deleted file mode 100644 index e9e63cdb6b680367be281cc449df35b6967df3e6..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -apply plugin: 'com.huawei.ohos.app' - -ohos { - compileSdkVersion 6 - defaultConfig { - compatibleSdkVersion 5 - } -} - -buildscript { - repositories { - maven { - url 'https://mirrors.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } - dependencies { - classpath 'com.huawei.ohos:hap:2.4.5.0' - } -} - -allprojects { - repositories { - maven { - url 'https://mirrors.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } -} diff --git a/JSPlaygroundDemo/entry/build.gradle b/JSPlaygroundDemo/entry/build.gradle deleted file mode 100644 index 8fddbf68c1c25c69287c505bb708b821af27734b..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/entry/build.gradle +++ /dev/null @@ -1,13 +0,0 @@ -apply plugin: 'com.huawei.ohos.hap' -ohos { - compileSdkVersion 6 - defaultConfig { - compatibleSdkVersion 5 - } - -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - testCompile 'junit:junit:4.12' -} diff --git a/JSPlaygroundDemo/entry/src/main/config.json b/JSPlaygroundDemo/entry/src/main/config.json deleted file mode 100644 index 8c99aa566ccb8256bf2c7d06a35ebfa8f79a96d4..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/entry/src/main/config.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "app": { - "bundleName": "com.example.jsdemo", - "vendor": "example", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.example.jsdemo", - "name": ".MyApplication", - "deviceType": [ - "phone", - "tv", - "wearable" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree":false - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "com.example.jsdemo.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } -} \ No newline at end of file diff --git a/JSPlaygroundDemo/entry/src/main/java/com/example/jsdemo/MainAbility.java b/JSPlaygroundDemo/entry/src/main/java/com/example/jsdemo/MainAbility.java deleted file mode 100644 index 55479a3e5c291aa566ce34710e8440d4a9f281a9..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/entry/src/main/java/com/example/jsdemo/MainAbility.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.jsdemo; - -import ohos.ace.ability.AceAbility; -import ohos.aafwk.content.Intent; - -/** - * MainAbility - * - * @since 2021-03-26 - */ -public class MainAbility extends AceAbility { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - } - - @Override - public void onStop() { - super.onStop(); - } -} diff --git a/JSPlaygroundDemo/entry/src/main/java/com/example/jsdemo/MyApplication.java b/JSPlaygroundDemo/entry/src/main/java/com/example/jsdemo/MyApplication.java deleted file mode 100644 index 679762fc81764ffc9c60c4b1c5f96bc7c05c8993..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/entry/src/main/java/com/example/jsdemo/MyApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.jsdemo; - -import ohos.aafwk.ability.AbilityPackage; - -/** - * MyApplication - * - * @since 2021-03-26 - */ -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/JSPlaygroundDemo/entry/src/main/js/default/common/checkbutton.png b/JSPlaygroundDemo/entry/src/main/js/default/common/checkbutton.png deleted file mode 100644 index b4bc3d10a7a159af55cb2f8c2140be73b685f5e3..0000000000000000000000000000000000000000 Binary files a/JSPlaygroundDemo/entry/src/main/js/default/common/checkbutton.png and /dev/null differ diff --git a/JSPlaygroundDemo/entry/src/main/js/default/common/delete.png b/JSPlaygroundDemo/entry/src/main/js/default/common/delete.png deleted file mode 100644 index c8a749c50a249e958a50fba36ee7ae390a908b5e..0000000000000000000000000000000000000000 Binary files a/JSPlaygroundDemo/entry/src/main/js/default/common/delete.png and /dev/null differ diff --git a/JSPlaygroundDemo/entry/src/main/js/default/common/done.png b/JSPlaygroundDemo/entry/src/main/js/default/common/done.png deleted file mode 100644 index bfd44b664b5c75cde229536fd5b8b889af80180b..0000000000000000000000000000000000000000 Binary files a/JSPlaygroundDemo/entry/src/main/js/default/common/done.png and /dev/null differ diff --git a/JSPlaygroundDemo/entry/src/main/js/default/i18n/en-US.json b/JSPlaygroundDemo/entry/src/main/js/default/i18n/en-US.json deleted file mode 100644 index e63c70d978a3a53be988388c87182f81785e170c..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/entry/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } -} \ No newline at end of file diff --git a/JSPlaygroundDemo/entry/src/main/js/default/i18n/zh-CN.json b/JSPlaygroundDemo/entry/src/main/js/default/i18n/zh-CN.json deleted file mode 100644 index de6ee5748322f44942c1b003319d8e66c837675f..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/entry/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } -} \ No newline at end of file diff --git a/JSPlaygroundDemo/entry/src/main/js/default/pages/index/index.css b/JSPlaygroundDemo/entry/src/main/js/default/pages/index/index.css deleted file mode 100644 index 5ecf01b8a2255c40d3998acd81467fd00bf21428..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -.container { - flex-direction: column; - background-color: black; -} - -.title { - font-weight: 600; - color: #ccc; - background-color: black; -} - -.tag-list { - width: 100%; -} - -.todo-list-item { - width: 100%; -} - -.todo-item { - height: 120px; - width: 100%; - border-radius: 5px; - align-items: center; -} - -.flex-row { - flex-direction: row; - align-items: center; -} - -.todo-name-mark { - width: 100%; - height: 100%; - align-items: center; -} - -.todo-name { - font-size: 32px; - color: white; - height: 100px; - margin-right: 5px; - max-lines: 1; - text-overflow: ellipsis; -} - -.text-default { - color: white; -} - -.text-gray { - color: gray; -} - -.todo-mark { - width: 18px; - height: 30%; - margin-left: 16px; - border-radius: 50px; - background-color: lightslategrey; -} - -.todo-time { - font-size: 32px; - width: 100%; - height: 100%; - text-align: left; - color: gray; - margin-top:2px; -} - -.urgent { - background-color: firebrick; -} - -.senior { - background-color: gold; -} - -.middle { - background-color: mediumaquamarine; -} - -.low { - background-color: #0D9FFB; -} - -.hide { - display: none; -} - -.show { - display: flex; -} - -.todo-image { - width: 50px; - height: 50%; - object-fit: contain; - margin-left: 10px; - margin-top: 3px; -} - -.todo-text-wrapper { - height: 100%; - flex-grow: 1; - margin: 0px 32px; - flex-direction: column; -} - -@media (device-type: tv) { - .todo-item { - height: 50px; - } - - .todo-name { - font-size: 18px; - } - - .todo-time { - font-size: 16px; - } - - .todo-mark { - width: 10px; - height: 10px; - } -} - -@media (device-type: phone) { - .title { - font-size: 42px; - margin-top: 36px; - margin-bottom: 36px; - margin-left: 24px; - } -} - -@media (device-type: wearable) { - .title { - font-size: 52px; - height: 20%; - text-align: center; - } - - .todo-list-item { - padding-left: 100px; - padding-right: 50px; - } -} \ No newline at end of file diff --git a/JSPlaygroundDemo/entry/src/main/js/default/pages/index/index.hml b/JSPlaygroundDemo/entry/src/main/js/default/pages/index/index.hml deleted file mode 100644 index 3ac34a3dc63bdc2947965ce0160cdcac9d0f057c..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,29 +0,0 @@ - - -
- - -
- -
-
- {{$item.event}} - -
- {{$item.time}} -
-
-
-
-
diff --git a/JSPlaygroundDemo/entry/src/main/js/default/pages/index/index.js b/JSPlaygroundDemo/entry/src/main/js/default/pages/index/index.js deleted file mode 100644 index 13a877cd062239830f87fa91906a05a65c674296..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/entry/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import device from '@system.device'; - -const BUTTON_STATE_IMAGE = ['/common/checkbutton.png', '/common/done.png']; -const TAG_STATE = ['show', 'hide']; -const TEXT_COLOR = ['text-default', 'text-gray']; -const EVENT_LEVEL = ['urgent', 'senior', 'middle', 'low']; - -export default { - data: { - title: "", - eventList: [ - "拿快递", - "购买礼物", - "约会/安排", - "回复邮件", - "运动健身", - "足球比赛", - "看书学习"], - initialIndex: 0, - taskList: [] - }, - onInit() { - this.$set('taskList', []); - }, - onShow() { - for (let index = 0; index < this.eventList.length; index++) { - const element = {}; - element.id = 'id-' + index; - element.event = this.eventList[index]; - element.time = this.getRandomTime(); - let completeState = this.getRandom(100) % 2; - element.checkBtn = BUTTON_STATE_IMAGE[completeState]; - element.color = TEXT_COLOR[completeState]; - element.showTag = TAG_STATE[completeState]; - element.tag = EVENT_LEVEL[this.getRandom(EVENT_LEVEL.length)]; - this.taskList.push(element); - } - - const _this = this; - device.getInfo({ - success: function (data) { - if (data.deviceType && data.deviceType === 'wearable') { - _this.initialIndex = 2; - } - }, - }); - }, - completeEvent(e) { - for (let i of this.taskList) { - if (i.id == e) { - if (i.checkBtn == "/common/done.png") { - i.checkBtn = "/common/checkbutton.png"; - i.showTag = 'show'; - i.color = 'text-default'; - i.completeState = false; - } else { - i.checkBtn = "/common/done.png"; - i.showTag = 'hide'; - i.color = 'text-gray'; - i.completeState = true; - } - return; - } - } - }, - getRandomTime() { - let hour = this.getRandom(24); - let minute = this.getRandom(60); - if (minute < 10) { - minute = '0' + minute; - } - return hour + ':' + minute; - }, - getRandom(range) { - let num = Math.random(); - num = num * range; - num = Math.floor(num); - return num; - } -} diff --git a/JSPlaygroundDemo/entry/src/main/resources/base/element/string.json b/JSPlaygroundDemo/entry/src/main/resources/base/element/string.json deleted file mode 100644 index 55aa37a18ee2a7ef32639ea7766a56994a05c088..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsDemo" - }, - { - "name": "mainability_description", - "value": "JS_Phone_Empty Feature Ability" - } - ] -} \ No newline at end of file diff --git a/JSPlaygroundDemo/entry/src/main/resources/base/media/icon.png b/JSPlaygroundDemo/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/JSPlaygroundDemo/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/JSPlaygroundDemo/gradle/wrapper/gradle-wrapper.jar b/JSPlaygroundDemo/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 490fda8577df6c95960ba7077c43220e5bb2c0d9..0000000000000000000000000000000000000000 Binary files a/JSPlaygroundDemo/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/JSPlaygroundDemo/gradle/wrapper/gradle-wrapper.properties b/JSPlaygroundDemo/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index f59159e865d4b59feb1b8c44b001f62fc5d58df4..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/JSPlaygroundDemo/settings.gradle b/JSPlaygroundDemo/settings.gradle deleted file mode 100644 index 4773db73233a570c2d0c01a22e75321acfbf7a07..0000000000000000000000000000000000000000 --- a/JSPlaygroundDemo/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':entry' diff --git a/LICENSE b/LICENSE deleted file mode 100644 index a38914186d603631042206da87dee078b294a4c6..0000000000000000000000000000000000000000 --- a/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - Copyright (c) 2021 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/MetaDataBindingDemo/LICENSE.txt b/MetaDataBindingDemo/LICENSE.txt deleted file mode 100644 index 906f55094d4b8848ad929c257de46511c61e5e58..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/LICENSE.txt +++ /dev/null @@ -1,257 +0,0 @@ - Copyright (c) 2021 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. - -OPEN SOURCE SOFTWARE NOTICE -Please note we provide an open source software notice along with this product and/or this product firmware (in the following just “this product”). The open source software licenses are granted by the respective right holders. And the open source licenses prevail all other license information with regard to the respective open source software contained in the product, including but not limited to End User Software Licensing Agreement. This notice is provided on behalf of Huawei Technologies Co. Ltd. and any of its local subsidiaries which may have provided this product to you in your local country. - -Warranty Disclaimer -THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. - -Copyright Notice and License Texts - -Software 1: fastjson 1.2.73 -Copyright notice: -Copyright 1999-2020 Alibaba Group Holding 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 the following link. - - 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. - -Software 2: javapoet 1.13.0 -Copyright notice: -Copyright 2015 Square, Inc. - -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. - -License: Apache 2.0 license - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - 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: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) 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 - - (d) 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 - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 1999-2019 Alibaba Group Holding 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. - diff --git a/MetaDataBindingDemo/README.md b/MetaDataBindingDemo/README.md deleted file mode 100644 index 03229579401fbc3a452db9626bf9235393d6041b..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# 元数据绑定框架使用Demo - -## 简介: - -元数据绑定框架是基于HarmonyOS SDK开发的一套提供UI和数据源分离能力的框架。通过使用元数据绑定框架,HarmonyOS开发者无需像往常一样开发繁琐和重复的UI和数据源绑定的代码。 - -在本项目中,您将会使用元数据绑定框架提供的能力,模仿闹钟设置场景,实现单个闹钟和闹钟列表,本项目还使用了框架的可拓展能力,实现自定义UI组件和自定义数据源的绑定。 - -本demo包括四个功能的演示, 演示内容和代码路径如下: -* 单个闹钟和数据源绑定 - > alarm/single_alarm -* 列表场景下的数据绑定 - > alarm/list_alarm -* 自定义UI控件属性和数据的绑定 - > custom_operator -* 使用自定义数据源的绑定 - > notes_example - -四个功能的入口在 MainAbilitySlice.java中实现。 - -## 许可: -请参阅LICENSE文件以获得更多信息。 - diff --git a/MetaDataBindingDemo/RELEASE-NOTES.md b/MetaDataBindingDemo/RELEASE-NOTES.md deleted file mode 100644 index ea23a13e3d4407d06cba3aa7155a23e5081b50b4..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/RELEASE-NOTES.md +++ /dev/null @@ -1,2 +0,0 @@ -1.0.0 -1.Initial version \ No newline at end of file diff --git a/MetaDataBindingDemo/build.gradle b/MetaDataBindingDemo/build.gradle deleted file mode 100644 index 91af1ca64995ab365fbf9f4d6b6c9a5f816d163f..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -apply plugin: 'com.huawei.ohos.app' - -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 4 - } -} - -buildscript { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } - dependencies { - classpath 'com.huawei.ohos:hap:2.4.4.2' - } -} - -allprojects { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/.gitignore b/MetaDataBindingDemo/entry/.gitignore deleted file mode 100644 index 796b96d1c402326528b4ba3c12ee9d92d0e212e9..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/MetaDataBindingDemo/entry/build.gradle b/MetaDataBindingDemo/entry/build.gradle deleted file mode 100644 index 04a05c9c02cf5a69bf4e9f552fc8bc578ee7951f..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/build.gradle +++ /dev/null @@ -1,26 +0,0 @@ -apply plugin: 'com.huawei.ohos.hap' - -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 4 - } - buildTypes { - release { - proguardOpt { - proguardEnabled false - rulesFiles 'proguard-rules.pro' - } - } - } - compileOptions { - annotationEnabled true - } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - implementation 'com.huawei.middleplatform:ohos-metadata-annotation:1.0.0.0' - implementation 'com.huawei.middleplatform:ohos-metadata-binding:1.0.0.0' - annotationProcessor 'com.huawei.middleplatform:ohos-metadata-processor:1.0.0.0' -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/proguard-rules.pro b/MetaDataBindingDemo/entry/proguard-rules.pro deleted file mode 100644 index f7666e47561d514b2a76d5a7dfbb43ede86da92a..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/proguard-rules.pro +++ /dev/null @@ -1 +0,0 @@ -# config module specific ProGuard rules here. \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/config.json b/MetaDataBindingDemo/entry/src/main/config.json deleted file mode 100644 index 1c25f6db36159ac6736875372609d22abb231b8a..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/config.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "app": { - "bundleName": "com.huawei.metadatabindingdemo", - "vendor": "huawei", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.huawei.metadatabindingdemo", - "name": ".MyApplication", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": true - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": ".MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "type": "page", - "label": "$string:label", - "launchType": "standard" - }, - { - "name": "com.huawei.metadatabindingdemo.alarm.db.AlarmsDataAbility", - "icon": "$media:icon", - "description": "$string:clockdataability_description", - "type": "data", - "uri": "dataability://com.huawei.metadatabindingdemo.db.AlarmsDataAbility", - "visible": true - }, - { - "name": "com.huawei.metadatabindingdemo.custom_data_source.db.NotesDataAbility", - "icon": "$media:icon", - "type": "data", - "uri": "dataability://com.huawei.metadatabindingdemo.db.NotesDataAbility", - "visible": true - } - ] - } -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/MainAbility.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/MainAbility.java deleted file mode 100644 index b5298e2e4161f08ec2ea987016d8425728b0363a..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/MainAbility.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo; - -import ohos.aafwk.ability.Ability; -import ohos.aafwk.content.Intent; - -/** - * Sample list ability - * - * @since 2021-05-15 - */ -public class MainAbility extends Ability { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setMainRoute(MainAbilitySlice.class.getName()); - } -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/MainAbilitySlice.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/MainAbilitySlice.java deleted file mode 100644 index ed0106282820d2503cfc8203faed390d381d9159..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/MainAbilitySlice.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo; - -import com.huawei.metadatabindingdemo.alarm.list_ui.AlarmListSlice; -import com.huawei.metadatabindingdemo.alarm.simple_ui.SingleAlarmSlice; -import com.huawei.metadatabindingdemo.custom_data_source.NotesSlice; -import com.huawei.metadatabindingdemo.custom_ui.CustomOperatorSlice; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.agp.components.Button; - -/** - * Samples list ability slice, displays 4 buttons as entrance for 4 samples. - * - * @since 2021-05-15 - */ -public class MainAbilitySlice extends AbilitySlice { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setUIContent(ResourceTable.Layout_main_ability_slice); - - // click and go to the Alarm List sample - Button listAlarmButton = (Button) findComponentById(ResourceTable.Id_list_alarm_button); - listAlarmButton.setClickedListener(component -> present(new AlarmListSlice(), new Intent())); - - // click and go to the Single Alarm Setting sample - Button singleAlarmButton = (Button) findComponentById(ResourceTable.Id_single_alarm_button); - singleAlarmButton.setClickedListener(component -> present(new SingleAlarmSlice(), new Intent())); - - // click and go to the Customized components and ui-attributes binding sample - Button customOperatorButton = (Button) findComponentById(ResourceTable.Id_custom_operator_button); - customOperatorButton.setClickedListener(component -> present(new CustomOperatorSlice(), new Intent())); - - // click and go to the Customized datasource binding sample - Button notesButton = (Button) findComponentById(ResourceTable.Id_notes_button); - notesButton.setClickedListener(component -> present(new NotesSlice(), new Intent())); - } - - @Override - public void onActive() { - super.onActive(); - } - - @Override - public void onForeground(Intent intent) { - super.onForeground(intent); - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/MyApplication.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/MyApplication.java deleted file mode 100644 index e697fae4d2e9af2cece9a93b2c934374f424f2b7..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/MyApplication.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo; - -import ohos.aafwk.ability.AbilityPackage; -import ohos.app.Context; -import ohos.mp.metadata.annotation.MetaDataApplication; -import ohos.mp.metadata.binding.MetaDataFramework; - -/** - * The entrance of this application. the {@link MetaDataApplication} annotation must be tagged on the Application class - * if the application wants to use MetaDataBinding framework. - * - * @since 2021-05-15 - */ -@MetaDataApplication(requireData = true, exportData = false) -public class MyApplication extends AbilityPackage { - private static Context context; - - @Override - public void onInitialize() { - super.onInitialize(); - context = this.getContext(); - // innit MetaDataFramework with the application context - MetaDataFramework.init(this); - } - - /** - * get application context - * - * @return context - */ - public static Context getApplication() { - return context; - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/MyLog.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/MyLog.java deleted file mode 100644 index b84ea06d07d12b691d366be33e018ea08a6d5612..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/MyLog.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo; - -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; - -/** - * This is a util HiLog Wrapper class. Supplies info and error log print. - * - * @since 2021-05-15 - */ -public class MyLog { - private static final String TAG_LOG = "MyLog"; - - private static final String MY_TAG = "MyTag"; - - private static final HiLogLabel LABEL_LOG = new HiLogLabel(0, 0, TAG_LOG); - - private static final String LOG_FORMAT = "%{public}s: %{public}s"; - - /** - * Print info log - * - * @param msg log message - */ - public static void info(String msg) { - HiLog.info(LABEL_LOG, LOG_FORMAT, MY_TAG, msg); - } - - /** - * Print error log - * - * @param msg log message - */ - public static void error(String msg) { - HiLog.error(LABEL_LOG, LOG_FORMAT, MY_TAG, msg); - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/db/Alarm.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/db/Alarm.java deleted file mode 100644 index 666fedeae5497ec39d49412651be19963abf316b..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/db/Alarm.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.alarm.db; - -import ohos.data.orm.OrmObject; -import ohos.data.orm.annotation.Entity; -import ohos.data.orm.annotation.PrimaryKey; -import ohos.data.rdb.ValuesBucket; - -/** - * This class indicates an Alarm table structure of alarm database. - * - * @since 2021-05-15 - */ -@Entity(tableName = "alarms") -public class Alarm extends OrmObject { - @PrimaryKey(autoGenerate = true) - private Integer id; - private int hour; - private int minutes; - private int daysofweek; - private int enabled; - private String message; - - /** - * get alarm id - * - * @return alarm id - */ - public Integer getId() { - return id; - } - - /** - * set alarm id - * - * @param id alarm id - */ - public void setId(Integer id) { - this.id = id; - } - - public int getHour() { - return hour; - } - - public void setHour(int hour) { - this.hour = hour; - } - - public int getMinutes() { - return minutes; - } - - public void setMinutes(int minutes) { - this.minutes = minutes; - } - - public int getDaysofweek() { - return daysofweek; - } - - public void setDaysofweek(int daysofweek) { - this.daysofweek = daysofweek; - } - - public int getEnabled() { - return enabled; - } - - public void setEnabled(int enabled) { - this.enabled = enabled; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - void setAttribute(String attribute, Object value) { - switch (attribute) { - case "hour": - setHour((Integer) value); - break; - case "minutes": - setMinutes((Integer) value); - break; - case "daysofweek": - setDaysofweek((Integer) value); - break; - case "enabled": - setEnabled((Integer) value); - break; - case "message": - setMessage((String) value); - break; - default: - } - } - - /** - * convert values bucket to alarm - * - * @param valuesBucket values bucket - * @return alarm - */ - public Alarm fromValues(ValuesBucket valuesBucket) { - hour = valuesBucket.getInteger("hour"); - minutes = valuesBucket.getInteger("minutes"); - daysofweek = valuesBucket.getInteger("daysofweek"); - enabled = valuesBucket.getInteger("enabled"); - message = valuesBucket.getString("message"); - return this; - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/db/AlarmOrmDatabase.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/db/AlarmOrmDatabase.java deleted file mode 100644 index 2426bcf73a13c604712dd4f220faf4671c22b15b..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/db/AlarmOrmDatabase.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.alarm.db; - -import com.huawei.metadatabindingdemo.custom_data_source.db.Note; - -import ohos.data.orm.OrmDatabase; -import ohos.data.orm.annotation.Database; - -/** - * An ORM Database - * - * @since 2021-05-15 - */ -@Database(entities = {Alarm.class, Note.class}, version = 1) -public abstract class AlarmOrmDatabase extends OrmDatabase { - /** - * Configuring this Database's name. - */ - public static final String DATABASE_NAME = "AlarmOrmDatabase.db"; - - /** - * Configuring this Database's alias. - */ - public static final String DATABASE_NAME_ALIAS = "AlarmOrmDatabase"; -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/db/AlarmsDataAbility.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/db/AlarmsDataAbility.java deleted file mode 100644 index a4efe1c152fff9b69ca13301248a96b8bec9b9bf..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/db/AlarmsDataAbility.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.alarm.db; - -import ohos.aafwk.ability.Ability; -import ohos.aafwk.ability.DataAbilityHelper; -import ohos.aafwk.content.Intent; -import ohos.data.DatabaseHelper; -import ohos.data.dataability.DataAbilityPredicates; -import ohos.data.dataability.DataAbilityUtils; -import ohos.data.orm.OrmContext; -import ohos.data.orm.OrmPredicates; -import ohos.data.rdb.ValuesBucket; -import ohos.data.resultset.ResultSet; -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; -import ohos.utils.PacMap; -import ohos.utils.net.Uri; - -import java.io.FileDescriptor; - -/** - * Clock data ability. - * In this case, no self-defined permissions has set. Developers can connect this data ability directly. - * See config.json. - * For every data source changes operation, the operation should notify users the change, otherwise Metadata will not - * know the change. - * - * @since 2021-05-15 - */ -public class AlarmsDataAbility extends Ability { - /** - * data ability uri - */ - public static final Uri CLOCK_URI = Uri.parse( - "dataability:///com.huawei.metadatabindingdemo.db.AlarmsDataAbility"); - private static final HiLogLabel LABEL_LOG = new HiLogLabel(3, 0xD001100, "Demo"); - private static final int ERR_CODE = -1; - private static final String ROW_ID = "id"; - - private OrmContext ormContext = null; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - HiLog.info(LABEL_LOG, "AlarmsDataAbility onStart"); - DatabaseHelper manager = new DatabaseHelper(this); - ormContext = manager.getOrmContext( - AlarmOrmDatabase.DATABASE_NAME_ALIAS, - AlarmOrmDatabase.DATABASE_NAME, - AlarmOrmDatabase.class); - } - - @Override - public ResultSet query(Uri uri, String[] columns, DataAbilityPredicates predicates) { - if (uri.equals(CLOCK_URI)) { - OrmPredicates ormPredicates = DataAbilityUtils.createOrmPredicates(predicates, Alarm.class); - return ormContext.query(ormPredicates, columns); - } - return null; - } - - @Override - public int insert(Uri uri, ValuesBucket value) { - Alarm alarm = new Alarm(); - if (ormContext.insert(alarm.fromValues(value))) { - ormContext.flush(); - DataAbilityHelper.creator(this, uri).notifyChange(uri); - return (int) alarm.getRowId(); - } - return ERR_CODE; - } - - @Override - public int delete(Uri uri, DataAbilityPredicates predicates) { - // delete is not used in this example. - return 0; - } - - @Override - public int update(Uri uri, ValuesBucket value, DataAbilityPredicates predicates) { - OrmPredicates ormPredicates; - if (predicates == null) { - Integer id = value.getInteger(ROW_ID); - if (id == null) { - return ERR_CODE; - } - value.delete(ROW_ID); - ormPredicates = new OrmPredicates(Alarm.class).equalTo(ROW_ID, id); - } else { - ormPredicates = DataAbilityUtils.createOrmPredicates(predicates, Alarm.class); - } - int rst = ormContext.update(ormPredicates, value); - DataAbilityHelper.creator(getContext(), uri).notifyChange(uri); - return rst; - } - - @Override - public FileDescriptor openFile(Uri uri, String mode) { - return null; - } - - @Override - public String[] getFileTypes(Uri uri, String mimeTypeFilter) { - return new String[0]; - } - - @Override - public PacMap call(String method, String arg, PacMap extras) { - return null; - } - - @Override - public String getType(Uri uri) { - return null; - } - - @Override - protected void onStop() { - super.onStop(); - if (ormContext != null) { - ormContext.close(); - } - } -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/db/AlarmsOperation.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/db/AlarmsOperation.java deleted file mode 100644 index 814dd4926608a6e0c807ab96d36fd4f5968a88d5..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/db/AlarmsOperation.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.alarm.db; - -import com.huawei.metadatabindingdemo.MyLog; -import com.huawei.metadatabindingdemo.metadatabinding.AlarmlistsliceMetaDataBinding; - -import ohos.aafwk.ability.DataAbilityHelper; -import ohos.aafwk.ability.DataAbilityRemoteException; -import ohos.app.Context; -import ohos.data.rdb.ValuesBucket; -import ohos.data.resultset.ResultSet; -import ohos.mp.metadata.binding.databinding.MetaDataBinding; -import ohos.mp.metadata.binding.databinding.MetaDataRequestInfo; -import ohos.mp.metadata.binding.metadata.MetaData; - -/** - * this class wraps alarm database CURD operations. - * - * @since 2021-05-15 - */ -public class AlarmsOperation { - private static int idx = 0; - private static int count = 0; - private static final int DEFAULT_HOUR = 12; - private static final int DEFAULT_MINUTES = 12; - private static final int DEFAULT_DAYS_OF_WEEK = 12; - private static final int DEFAULT_ENABLE = 1; - private static final int HOURS = 24; - private static final int MINUTES = 60; - private static final int ENABLES = 2; - private static final int DAYS_OF_WEEK = 128; - - private static final String COL_HOUR = "hour"; - private static final String COL_MINUTE = "minutes"; - private static final String COL_ENABLE = "enabled"; - private static final String COL_DAYS = "daysofweek"; - private static final String COL_MSG = "message"; - - private AlarmsOperation() { } - - /** - * insert alarm data - * - * @param context context - */ - public static void insert(Context context) { - try { - int time = Math.abs((int) System.currentTimeMillis()); - ValuesBucket bucket = new ValuesBucket(); - bucket.putInteger(COL_HOUR, time % HOURS); - bucket.putInteger(COL_MINUTE, time % MINUTES); - bucket.putInteger(COL_ENABLE, time % ENABLES); - bucket.putInteger(COL_DAYS, time % DAYS_OF_WEEK); - bucket.putString(COL_MSG, "Clock" + idx++); - DataAbilityHelper.creator(context).insert(AlarmsDataAbility.CLOCK_URI, bucket); - } catch (DataAbilityRemoteException ex) { - MyLog.error("Insert Clock Data Failed: DataAbility Remote Exception"); - } - } - - /** - * Create a metadata by binding request information and add into datasource. - * - * @param binding meta data binding - */ - public static void insertAnAlarm(MetaDataBinding binding) { - MetaDataRequestInfo.RequestItem requestItem = binding.getRequestInfo().getRequestItem("ClockMetaData"); - - MetaData metaData = AlarmlistsliceMetaDataBinding.createMetaData(requestItem); - metaData.put(COL_HOUR, DEFAULT_HOUR); - metaData.put(COL_MINUTE, DEFAULT_MINUTES); - metaData.put(COL_DAYS, DEFAULT_DAYS_OF_WEEK); - metaData.put(COL_ENABLE, DEFAULT_ENABLE); - metaData.put(COL_MSG, "count" + count); - - binding.addMetaData(metaData, requestItem); - count++; - } - - /** - * Getting the first alarm record of the database. - * - * @param context app context, an ability or slice will be fine. - * @return An alarm instance of the first alarm record in database, or null is the database has no records. - */ - public static Alarm queryFirst(Context context) { - DataAbilityHelper helper = DataAbilityHelper.creator(context); - ResultSet resultSet = null; - try { - resultSet = helper.query( - AlarmsDataAbility.CLOCK_URI, - new String[]{COL_HOUR, COL_MINUTE, COL_DAYS, COL_ENABLE, COL_MSG}, - null); - } catch (DataAbilityRemoteException e) { - MyLog.error("AlarmsOperation query Exception"); - } - Alarm alarm = null; - if (resultSet != null) { - boolean hasData = resultSet.goToFirstRow(); - if (!hasData) { - return null; - } - // get the first alarm record, resultSet now pointing to the first row. - alarm = getQueryResults(resultSet); - } - return alarm; - } - - private static Alarm getQueryResults(ResultSet resultSet) { - Alarm alarm = new Alarm(); - for (String column : resultSet.getAllColumnNames()) { - int index = resultSet.getColumnIndexForName(column); - alarm.setAttribute(column, getFromColumn(resultSet, index)); - } - return alarm; - } - - private static Object getFromColumn(ResultSet resultSet, int index) { - ResultSet.ColumnType type = resultSet.getColumnTypeForIndex(index); - switch (type) { - case TYPE_INTEGER: - return resultSet.getInt(index); - case TYPE_FLOAT: - return resultSet.getDouble(index); - case TYPE_STRING: - return resultSet.getString(index); - case TYPE_BLOB: - case TYPE_NULL: - default: - return null; - } - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/list_ui/AlarmEditSlice.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/list_ui/AlarmEditSlice.java deleted file mode 100644 index 0b448ce334643f0d77c0e858975d6a289cdc62e3..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/list_ui/AlarmEditSlice.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.alarm.list_ui; - -import com.huawei.metadatabindingdemo.ResourceTable; -import com.huawei.metadatabindingdemo.metadatabinding.AlarmdetailMetaDataBinding; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.agp.components.Component; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.DependentLayout; -import ohos.agp.components.TimePicker; -import ohos.agp.components.element.ShapeElement; -import ohos.mp.metadata.binding.metadata.MetaData; - -/** - * Alarm Edition slice. - * This slice doesn't request a datasource to bind, it binds with an exist Metadata, the 'clockMeta'. - * This metadata is passed in from AlarmListSlice, indicates a list item's content. - * - * @since 2021-05-15 - */ -public class AlarmEditSlice extends AbilitySlice { - private static final int CORNER_RADIUS = 12; - MetaData clockMeta; - AlarmdetailMetaDataBinding metaBinding; - - /** - * Constructor - * - * @param clockMeta MetaData - */ - public AlarmEditSlice(MetaData clockMeta) { - this.clockMeta = clockMeta; - } - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - - metaBinding = AlarmdetailMetaDataBinding.createBinding(this, clockMeta); - Component comp = metaBinding.getLayoutComponent(); - DependentLayout dependentLayout = (DependentLayout) comp.findComponentById(ResourceTable - .Id_title_area_back_icon_hot_area); - dependentLayout.setClickedListener(component -> { - this.terminate(); - clockMeta.rollback(); - }); - - comp.findComponentById(ResourceTable.Id_save).setClickedListener(component -> { - clockMeta.commit(); - clockMeta.stash(); - this.terminate(); - }); - - TimePicker timePicker = (TimePicker) comp.findComponentById(ResourceTable.Id_time_picker); - timePicker.set24Hour(false); - timePicker.showSecond(false); - - Component nameComponent = comp.findComponentById(ResourceTable.Id_name_edit); - ShapeElement shapeElement = (ShapeElement) nameComponent.getBackgroundElement(); - // only one item in category, set all corner radius and bottom margin 12vp - shapeElement.setCornerRadiiArray(new float[]{CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS, - CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS}); - nameComponent.setBackground(shapeElement); - clockMeta.stash(); - setUIContent((ComponentContainer) comp); - } - - @Override - protected void onStop() { - super.onStop(); - clockMeta.rollback(); - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/list_ui/AlarmListProvider.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/list_ui/AlarmListProvider.java deleted file mode 100644 index 7cfcb9f2f026198ecf9478938b9027c6ac1932a8..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/list_ui/AlarmListProvider.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.alarm.list_ui; - -import ohos.agp.components.BaseItemProvider; -import ohos.agp.components.Component; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.ListContainer; -import ohos.app.Context; - -import java.util.List; - -/** - * Alarm list item provider. - * You can create different styles of items easily by implement the AlarmRow interface. AlarmListProvider - * will calculate the alarm index of each position and add the item created by AlarmRow interface into list - * container. AlarmRowItemBase interface use to declare different styles of items in AlarmRow. - * - * @since 2021-05-15 - */ -public class AlarmListProvider extends BaseItemProvider implements ListContainer.ItemClickedListener { - private static final int ERROR_CATEGORY_INDEX = -1; - - private final Context mContext; - private List alarmList; - - /** - * AlarmRow list item provider constructor - * - * @param context Context - */ - public AlarmListProvider(Context context) { - mContext = context; - } - - /** - * Initialization of this list provider's data. - * - * @param alarmList initializing data - */ - public void initData(List alarmList) { - this.alarmList = alarmList; - } - - /** - * add alarm list and notify - * - * @param alarmList alarm list - */ - public void addItems(List alarmList) { - this.alarmList.addAll(alarmList); - mContext.getUITaskDispatcher().asyncDispatch(this::notifyDataChanged); - } - - @Override - public int getCount() { - int count = 0; - for (AlarmRow alarm : alarmList) { - count++; - } - return count; - } - - @Override - public Object getItem(int position) { - return alarmList.get(position); - } - - @Override - public long getItemId(int position) { - return position; - } - - private int getAlarmRowIndex(int position) { - if (position < 0 || position >= getCount()) { - return ERROR_CATEGORY_INDEX; - } - - int alarmIndex = 0; - int alarmStartPosition = 0; - for (AlarmRow alarm : alarmList) { - if (position - alarmStartPosition < 1) { - return alarmIndex; - } - alarmStartPosition++; - alarmIndex++; - } - - return ERROR_CATEGORY_INDEX; - } - - @Override - public Component getComponent(int position, Component component, ComponentContainer componentContainer) { - int alarmIndex = getAlarmRowIndex(position); - - if (alarmIndex == ERROR_CATEGORY_INDEX) { - return null; - } - - AlarmRow alarm = alarmList.get(alarmIndex); - if (component == null) { - Component newComponent = alarm.createComponent(); - alarm.bindComponent(newComponent); - return newComponent; - } else { - alarm.bindComponent(component); - return component; - } - } - - private void onClickAlarmRowItem(int position) { - int alarmIdx = getAlarmRowIndex(position); - AlarmRow alarm = alarmList.get(alarmIdx); - alarm.onClick(); - } - - @Override - public void onItemClicked(ListContainer listContainer, Component component, int position, long id) { - onClickAlarmRowItem(position); - } -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/list_ui/AlarmListSlice.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/list_ui/AlarmListSlice.java deleted file mode 100644 index 78b59c6972cd9e5f1f35aff1fe0ce24273b4ab0e..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/list_ui/AlarmListSlice.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.alarm.list_ui; - -import com.huawei.metadatabindingdemo.ResourceTable; -import com.huawei.metadatabindingdemo.alarm.db.AlarmsOperation; -import com.huawei.metadatabindingdemo.metadatabinding.AlarmlistsliceMetaDataBinding; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.agp.components.Component; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.DependentLayout; -import ohos.agp.components.LayoutScatter; -import ohos.agp.components.ListContainer; -import ohos.mp.metadata.binding.databinding.DataSourceConnectionException; -import ohos.mp.metadata.binding.databinding.IMetaDataObserver; -import ohos.mp.metadata.binding.databinding.MetaDataBinding; -import ohos.mp.metadata.binding.databinding.MetaDataRequestInfo; -import ohos.mp.metadata.binding.metadata.MetaData; - -import java.util.ArrayList; -import java.util.List; - -/** - * A Slice Ability displays a clock list. It implements {@link IMetaDataObserver} that handles MetaData changes. - * - * @see IMetaDataObserver - * @since 2021-05-15 - */ -public class AlarmListSlice extends AbilitySlice implements IMetaDataObserver { - MetaDataBinding binding = null; - ListContainer listContainer; - AlarmListProvider itemProvider; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - createComponent(); - } - - private void createComponent() { - // making binding request - MetaDataRequestInfo request = new MetaDataRequestInfo.Builder() - .setRequestSource("ClockMetaData", - "dataability:///com.huawei.metadatabindingdemo.db.AlarmsDataAbility") - .setSyncRequest("ClockMetaData", false) - .build(); - Component mainComponent; - try { - // request binding - binding = AlarmlistsliceMetaDataBinding.requestBinding(this, request, this); - // get binding layout component - mainComponent = binding.getLayoutComponent(); - } catch (DataSourceConnectionException e) { - mainComponent = LayoutScatter.getInstance(this) - .parse(ResourceTable.Layout_default_error, null, false); - } - setUIContent((ComponentContainer) mainComponent); - - // initialize the list container and item provider - listContainer = (ListContainer) mainComponent.findComponentById(ResourceTable.Id_list_view); - itemProvider = new AlarmListProvider(this); - listContainer.setItemClickedListener(itemProvider); - - // insert an alarm list item. - mainComponent.findComponentById(ResourceTable.Id_title_area_add_icon) - .setClickedListener(component -> { - AlarmsOperation.insertAnAlarm(binding); - }); - - DependentLayout dependentLayout = (DependentLayout) mainComponent.findComponentById( - ResourceTable.Id_title_area_back_icon_hot_area); - dependentLayout.setClickedListener(component -> this.terminate()); - } - - @Override - public void onActive() { - super.onActive(); - } - - @Override - public void onForeground(Intent intent) { - super.onForeground(intent); - } - - @Override - public void onDataLoad(List metaDatas, MetaDataRequestInfo.RequestItem requestItem) { - if (metaDatas == null || requestItem == null) { - return; - } - // add loaded metadatas to ListContainer. - if (listContainer != null) { - itemProvider.initData(createAlarms(this, metaDatas)); - listContainer.setItemProvider(itemProvider); - } - } - - @Override - public void onDataChange(List addedMetaData, List updatedMetaData, - List deletedMetaData, MetaDataRequestInfo.RequestItem requestItem) { - // in this case we only handle the added metadatas. - if (addedMetaData == null) { - return; - } - // add added metadatas to ListContainer. - itemProvider.addItems(createAlarms(this, addedMetaData)); - } - - /** - * Init alarms data - * - * @param context ability slice - * @param dataList clock row mete data list - * @return category list - */ - private List createAlarms(AbilitySlice context, List dataList) { - List list = new ArrayList<>(); - for (MetaData metaData : dataList) { - AlarmRow item = new AlarmRow(context, metaData); - list.add(item); - } - return list; - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/list_ui/AlarmRow.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/list_ui/AlarmRow.java deleted file mode 100644 index fd2ca2a282999e1d7e0f33734e6014d2a5e89c88..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/list_ui/AlarmRow.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.alarm.list_ui; - -import com.huawei.metadatabindingdemo.alarm.metadata.ClockRowMetaData; -import com.huawei.metadatabindingdemo.metadatabinding.AlarmrowMetaDataBinding; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.agp.components.Component; -import ohos.mp.metadata.binding.metadata.MetaData; - -/** - * A row item of Alarm ListContainer. For the item layout, see: src/main/resources/base/layout/alarm_row.xml. - * - * @since 2021-05-15 - */ -public class AlarmRow { - private final AbilitySlice context; - private final ClockRowMetaData clockMeta; - - /** - * AlarmRow constructor - * - * @param context Context - * @param clockMeta MetaData - */ - public AlarmRow(AbilitySlice context, MetaData clockMeta) { - this.context = context; - this.clockMeta = (ClockRowMetaData) clockMeta; - } - - /** - * create AlarmRow component. - * - * @return a AlarmRow component - */ - public Component createComponent() { - // bind the metadata with the Alarm row item component. - AlarmrowMetaDataBinding metaBinding = AlarmrowMetaDataBinding.createBinding(context, clockMeta); - Component comp = metaBinding.getLayoutComponent(); - comp.setTag(metaBinding); - return comp; - } - - /** - * bind clockMetaData with component. - * - * @param component a AlarmRow Component - */ - public void bindComponent(Component component) { - AlarmrowMetaDataBinding metaBinding = (AlarmrowMetaDataBinding) component.getTag(); - metaBinding.reBinding(component, clockMeta); - } - - /** - * go to AlarmEditSlice slice. - */ - public void onClick() { - context.present(new AlarmEditSlice(clockMeta), new Intent()); - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/metadata/ClockRowMetaData.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/metadata/ClockRowMetaData.java deleted file mode 100644 index ba29462d64e8a1f79987182c89e822192dd81b12..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/metadata/ClockRowMetaData.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.alarm.metadata; - -import ohos.mp.metadata.binding.metadata.DataAbilityMetaData; - -/** - * This MetaData indicates a row of alarm dataset, wraps the information of an alarm. - * This class is used in Single Alarm demo and Alarm List demo. - * For the MetaData content see: src/main/resources/rawfile/jsonschema/alarm_schema.json. - * - * @since 2021-05-15 - */ -public class ClockRowMetaData extends DataAbilityMetaData { - private static final int BINARY_CODE_2 = 2; - private static final int HOUR_6 = 6; - private static final int HOUR_11 = 11; - private static final int HOUR_13 = 13; - private static final int HOUR_14 = 14; - private static final int HOUR_18 = 18; - private static final int HOUR_23 = 23; - String[] DATE = new String[]{"Mon.", "Tue.", "Wed.", "Thu.", " Fri.", "Sat.", "Sun."}; - - /** - * create string message - * - * @param message origin message - * @param daysofweek days of week - * @return message - */ - public String toMessage(String message, int daysofweek) { - StringBuilder res = new StringBuilder(); - int idx = 0; - int dayOfWeek = daysofweek; - while (dayOfWeek > 0) { - if ((dayOfWeek % BINARY_CODE_2) != 0) { - res.append(DATE[idx]).append(" "); - } - dayOfWeek /= BINARY_CODE_2; - idx++; - } - return message + ", " + res; - } - - /** - * convert hour to time zone - * - * @param hour hour - * @return time zone - */ - public String getTimeZone(int hour) { - if (hour >= HOUR_6 && hour < HOUR_11) { - return "Morning"; - } - if (hour >= HOUR_11 && hour <= HOUR_13) { - return "Midday"; - } - if (hour >= HOUR_14 && hour < HOUR_18) { - return "Afternoon"; - } - if (hour >= HOUR_18 && hour < HOUR_23) { - return "Evening"; - } - return "Early Morning"; - } -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/simple_ui/SingleAlarmSlice.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/simple_ui/SingleAlarmSlice.java deleted file mode 100644 index 339ef4bb00e13422551270348643a66b34e30722..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/alarm/simple_ui/SingleAlarmSlice.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.alarm.simple_ui; - -import com.huawei.metadatabindingdemo.ResourceTable; -import com.huawei.metadatabindingdemo.alarm.db.Alarm; -import com.huawei.metadatabindingdemo.alarm.db.AlarmsOperation; -import com.huawei.metadatabindingdemo.alarm.metadata.ClockRowMetaData; -import com.huawei.metadatabindingdemo.metadatabinding.SinglealarmMetaDataBinding; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.agp.components.Component; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.DependentLayout; -import ohos.agp.components.LayoutScatter; -import ohos.agp.components.TimePicker; -import ohos.mp.metadata.binding.databinding.DataSourceConnectionException; -import ohos.mp.metadata.binding.databinding.MetaDataBinding; -import ohos.mp.metadata.binding.databinding.MetaDataRequestInfo; - -/** - * This AbilitySlice displays an alarm setting page. - * - * @since 2021-05-15 - */ -public class SingleAlarmSlice extends AbilitySlice { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - createComponent(); - } - - private void createComponent() { - // in this case, if no records exists in database, we create one. - Alarm alarm = AlarmsOperation.queryFirst(this); - if (alarm == null) { - AlarmsOperation.insert(this); - } - // making binding request. - MetaDataRequestInfo request = new MetaDataRequestInfo.Builder() - .setMetaDataClass("ClockMetaData", ClockRowMetaData.class) - .setSyncRequest("ClockMetaData", true) - .build(); - MetaDataBinding binding; - Component mainComponent; - try { - // request binding. - binding = SinglealarmMetaDataBinding.requestBinding(this, request, null); - // getting binding layout component. - mainComponent = binding.getLayoutComponent(); - } catch (DataSourceConnectionException e) { - mainComponent = LayoutScatter.getInstance(this) - .parse(ResourceTable.Layout_default_error, null, false); - } - setUIContent((ComponentContainer) mainComponent); - - TimePicker timePicker = (TimePicker) mainComponent.findComponentById(ResourceTable.Id_time_picker); - if (timePicker == null) { - return; - } - timePicker.set24Hour(false); - timePicker.showSecond(false); - DependentLayout dependentLayout = (DependentLayout) mainComponent.findComponentById(ResourceTable - .Id_title_area_back_icon_hot_area); - dependentLayout.setClickedListener(component -> this.terminate()); - } - - @Override - public void onActive() { - super.onActive(); - } - - @Override - public void onForeground(Intent intent) { - super.onForeground(intent); - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/NoteListProvider.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/NoteListProvider.java deleted file mode 100644 index e32b1f24182da96d13f54c02c93fa0265f640a1a..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/NoteListProvider.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.custom_data_source; - -import ohos.agp.components.BaseItemProvider; -import ohos.agp.components.Component; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.ListContainer; -import ohos.app.Context; - -import java.util.List; - -/** - * Note list item provider. - * You can create different styles of items easily by implement the NoteRow interface. AlarmListProvider - * will calculate the category index of each position and add the item created by NoteRow interface into list - * container. NoteRowItemBase interface use to declare different styles of items in NoteRow. - * - * @since 2021-05-15 - */ -public class NoteListProvider extends BaseItemProvider implements ListContainer.ItemClickedListener { - private static final int ERROR_CATEGORY_INDEX = -1; - - private final Context mContext; - private List notesList; - - /** - * NoteRow list item provider constructor - * - * @param context Context - */ - public NoteListProvider(Context context) { - mContext = context; - } - - /** - * Initialization of this list provider's data. - * - * @param notesList initializing data - */ - public void initData(List notesList) { - this.notesList = notesList; - } - - /** - * add category list and notify - * - * @param notesList category list - */ - public void addItems(List notesList) { - this.notesList.addAll(notesList); - mContext.getUITaskDispatcher().asyncDispatch(this::notifyDataChanged); - } - - @Override - public int getCount() { - int count = 0; - for (NoteRow note : notesList) { - count++; - } - return count; - } - - @Override - public Object getItem(int position) { - return notesList.get(position); - } - - @Override - public long getItemId(int position) { - return position; - } - - private int getNoteRowIndex(int position) { - if (position < 0 || position >= getCount()) { - return ERROR_CATEGORY_INDEX; - } - - int idx = 0; - int startPosition = 0; - for (NoteRow note : notesList) { - if (position - startPosition < 1) { - return idx; - } - startPosition++; - idx++; - } - - return ERROR_CATEGORY_INDEX; - } - - @Override - public Component getComponent(int position, Component component, ComponentContainer componentContainer) { - int idx = getNoteRowIndex(position); - - if (idx == ERROR_CATEGORY_INDEX) { - return null; - } - - NoteRow note = notesList.get(idx); - if (component == null) { - Component newComponent = note.createComponent(); - note.bindComponent(newComponent); - return newComponent; - } else { - note.bindComponent(component); - return component; - } - } - - private void onClickNoteRowItem(int position) { - int categoryIdx = getNoteRowIndex(position); - NoteRow noteRow = notesList.get(categoryIdx); - noteRow.onClick(); - } - - @Override - public void onItemClicked(ListContainer listContainer, Component component, int position, long id) { - onClickNoteRowItem(position); - } -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/NoteRow.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/NoteRow.java deleted file mode 100644 index df796420388d973abb30d6ef02821a8dfaa7e3df..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/NoteRow.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.custom_data_source; - -import com.huawei.metadatabindingdemo.custom_data_source.metadata.NoteMetaData; -import com.huawei.metadatabindingdemo.metadatabinding.NoterowMetaDataBinding; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.agp.components.Component; -import ohos.mp.metadata.binding.metadata.MetaData; - -/** - * A row item of Alarm ListContainer. For the item layout, see: src/main/resources/base/layout/note_row.xml. - * - * @since 2021-05-15 - */ -public class NoteRow { - private final AbilitySlice context; - private final NoteMetaData noteMetaData; - - /** - * NoteRow constructor - * - * @param context Context - * @param noteMetaData MetaData - */ - public NoteRow(AbilitySlice context, MetaData noteMetaData) { - this.context = context; - this.noteMetaData = (NoteMetaData) noteMetaData; - } - - /** - * create NoteRow component. - * - * @return a NoteRow component - */ - public Component createComponent() { - NoterowMetaDataBinding metaBinding = NoterowMetaDataBinding.createBinding(context, noteMetaData); - Component comp = metaBinding.getLayoutComponent(); - comp.setTag(metaBinding); - return comp; - } - - /** - * bind noteMetaData with component. - * - * @param component a NoteRow Component - */ - public void bindComponent(Component component) { - NoterowMetaDataBinding metaBinding = (NoterowMetaDataBinding) component.getTag(); - metaBinding.reBinding(component, noteMetaData); - } - - /** - * do nothing. - */ - public void onClick() { - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/NotesSlice.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/NotesSlice.java deleted file mode 100644 index 87cd6eae9bde096d028ad691e6c1d728dc26cac9..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/NotesSlice.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.custom_data_source; - -import com.huawei.metadatabindingdemo.ResourceTable; -import com.huawei.metadatabindingdemo.custom_data_source.db.Note; -import com.huawei.metadatabindingdemo.custom_data_source.db.NotesOperation; -import com.huawei.metadatabindingdemo.metadatabinding.NotessliceMetaDataBinding; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.agp.components.Component; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.DependentLayout; -import ohos.agp.components.LayoutScatter; -import ohos.agp.components.ListContainer; -import ohos.mp.metadata.binding.databinding.DataSourceConnectionException; -import ohos.mp.metadata.binding.databinding.IMetaDataObserver; -import ohos.mp.metadata.binding.databinding.MetaDataBinding; -import ohos.mp.metadata.binding.databinding.MetaDataRequestInfo; -import ohos.mp.metadata.binding.metadata.MetaData; - -import java.util.ArrayList; -import java.util.List; - -/** - * A Slice Ability displays a note list. It implements {@link IMetaDataObserver} that handles MetaData changes. - * - * @see IMetaDataObserver - * @since 2021-05-15 - */ -public class NotesSlice extends AbilitySlice implements IMetaDataObserver { - private static final int DB_SIZE = 8; - private static final int TIME_DEFAULT = 1621047451; - private static final int UNIT_TIME_1000 = 1000; - private ListContainer listContainer; - private NoteListProvider notesProvider; - private List metaDatas; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - List notes = NotesOperation.getInstance().queryAll(); - // init database, add some data first to show this foundation. - if (notes.size() < DB_SIZE) { - for (int i = 0; i < DB_SIZE; i++) { - NotesOperation.getInstance().insert("Node" + i, (int) (System.currentTimeMillis() / UNIT_TIME_1000)); - } - NotesOperation.getInstance().insert("old Node", TIME_DEFAULT); - } - createComponent(); - } - - private void createComponent() { - MetaDataRequestInfo request = new MetaDataRequestInfo.Builder() - .setRequestSource("NoteMetaData", - "datahandler:///com.huawei.metadatabindingdemo.custom_data_source.handler.MyDataHandler") - .setSyncRequest("NoteMetaData", true) - .build(); - MetaDataBinding binding; - Component mainComponent; - try { - binding = NotessliceMetaDataBinding.requestBinding(this, request, this); - mainComponent = binding.getLayoutComponent(); - } catch (DataSourceConnectionException e) { - mainComponent = LayoutScatter.getInstance(this) - .parse(ResourceTable.Layout_default_error, null, false); - setUIContent((ComponentContainer) mainComponent); - return; - } - setUIContent((ComponentContainer) mainComponent); - - notesProvider = new NoteListProvider(this); - listContainer = (ListContainer) findComponentById(ResourceTable.Id_note_list); - notesProvider.initData(createNotes(this, metaDatas)); - listContainer.setItemProvider(notesProvider); - - DependentLayout dependentLayout = (DependentLayout) findComponentById( - ResourceTable.Id_title_area_back_icon_hot_area); - dependentLayout.setClickedListener(component -> this.terminate()); - } - - @Override - public void onDataLoad(List metaData, MetaDataRequestInfo.RequestItem requestItem) { - if (metaData == null || requestItem == null) { - return; - } - metaDatas = metaData; - } - - @Override - public void onDataChange(List addedMetaData, List updatedMetaData, - List deletedMetaData, MetaDataRequestInfo.RequestItem requestItem) { - if (addedMetaData == null) { - return; - } - notesProvider.addItems(createNotes(this, addedMetaData)); - } - - /** - * Init notes data - * - * @param context ability slice - * @param dataList clock row mete data list - * @return category list - */ - private List createNotes(AbilitySlice context, List dataList) { - List list = new ArrayList<>(); - if (dataList == null || dataList.isEmpty()) { - return list; - } - for (MetaData metaData : dataList) { - NoteRow item = new NoteRow(context, metaData); - list.add(item); - } - return list; - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/db/Note.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/db/Note.java deleted file mode 100644 index 1e5a152718f75b64e28afd0f6d57816087f91d76..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/db/Note.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.custom_data_source.db; - -import ohos.data.orm.OrmObject; -import ohos.data.orm.annotation.Entity; -import ohos.data.orm.annotation.PrimaryKey; - -/** - * This class indicates a Note table structure of alarm database. - * - * @since 2021-05-15 - */ -@Entity(tableName = "notes") -public class Note extends OrmObject { - @PrimaryKey(autoGenerate = true) - private Integer id; - private String content; - private int time; - - /** - * Constructor - */ - public Note() { - } - - /** - * Set Note 'content' and 'time' attributes' value. - * - * @param attribute attribute's name - * @param value attribute's value - */ - public void setAttribute(String attribute, Object value) { - switch (attribute) { - case "content": - setContent((String) value); - break; - case "time": - setTime((Integer) value); - break; - default: - } - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public int getTime() { - return time; - } - - public void setTime(int time) { - this.time = time; - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/db/NotesDataAbility.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/db/NotesDataAbility.java deleted file mode 100644 index a1cfa735585b29bf178108810d355c7a088fbc40..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/db/NotesDataAbility.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.custom_data_source.db; - -import com.huawei.metadatabindingdemo.alarm.db.AlarmOrmDatabase; - -import ohos.aafwk.ability.Ability; -import ohos.aafwk.ability.DataAbilityHelper; -import ohos.aafwk.content.Intent; -import ohos.data.DatabaseHelper; -import ohos.data.dataability.DataAbilityPredicates; -import ohos.data.dataability.DataAbilityUtils; -import ohos.data.orm.OrmContext; -import ohos.data.orm.OrmPredicates; -import ohos.data.rdb.ValuesBucket; -import ohos.data.resultset.ResultSet; -import ohos.utils.PacMap; -import ohos.utils.net.Uri; - -import java.io.FileDescriptor; - -/** - * Note data ability. - * This case reuse Alarm ORM Database, we can also change it to RDB Database, shared preference files as we want. - * Just remember that whenever the data source is changed, notify users. - * - * @since 2021-05-15 - */ -public class NotesDataAbility extends Ability { - /** - * clock uri - */ - public static final Uri NOTE_URI = Uri.parse( - "dataability:///com.huawei.metadatabindingdemo.db.NotesDataAbility/alarm"); - private static final int ERR_CODE = -1; - private OrmContext ormContext = null; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - DatabaseHelper manager = new DatabaseHelper(this); - // reuse Alarm Database. see Alarm Demo. - ormContext = manager.getOrmContext( - AlarmOrmDatabase.DATABASE_NAME_ALIAS, - AlarmOrmDatabase.DATABASE_NAME, - AlarmOrmDatabase.class); - } - - @Override - public ResultSet query(Uri uri, String[] columns, DataAbilityPredicates predicates) { - if (ormContext == null) { - return null; - } - OrmPredicates ormPredicates = DataAbilityUtils.createOrmPredicates(predicates, Note.class); - return ormContext.query(ormPredicates, columns); - } - - @Override - public int insert(Uri uri, ValuesBucket value) { - if (ormContext == null) { - return ERR_CODE; - } - // create a note object - Note note = new Note(); - note.setContent(value.getString("content")); - note.setTime(value.getInteger("time")); - // insert the note object to database - boolean isSuccessful = ormContext.insert(note); - if (!isSuccessful) { - return ERR_CODE; - } - isSuccessful = ormContext.flush(); - if (!isSuccessful) { - return ERR_CODE; - } - DataAbilityHelper.creator(this, uri).notifyChange(uri); - return Math.toIntExact(note.getRowId()); - } - - @Override - public int delete(Uri uri, DataAbilityPredicates predicates) { - if (ormContext == null) { - return ERR_CODE; - } - OrmPredicates ormPredicates = DataAbilityUtils.createOrmPredicates(predicates, Note.class); - int value = ormContext.delete(ormPredicates); - DataAbilityHelper.creator(this, uri).notifyChange(uri); - return value; - } - - @Override - public int update(Uri uri, ValuesBucket value, DataAbilityPredicates predicates) { - if (ormContext == null) { - return ERR_CODE; - } - OrmPredicates ormPredicates = DataAbilityUtils.createOrmPredicates(predicates, Note.class); - int index = ormContext.update(ormPredicates, value); - DataAbilityHelper.creator(this, uri).notifyChange(uri); - return index; - } - - @Override - public FileDescriptor openFile(Uri uri, String mode) { - return null; - } - - @Override - public String[] getFileTypes(Uri uri, String mimeTypeFilter) { - return new String[0]; - } - - @Override - public PacMap call(String method, String arg, PacMap extras) { - return null; - } - - @Override - public String getType(Uri uri) { - return null; - } - - @Override - protected void onStop() { - super.onStop(); - if (ormContext != null) { - ormContext.close(); - } - } -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/db/NotesOperation.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/db/NotesOperation.java deleted file mode 100644 index 705e259fdd7624168cf3182ae4fc8fc65b39a884..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/db/NotesOperation.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.custom_data_source.db; - -import com.huawei.metadatabindingdemo.MyApplication; -import com.huawei.metadatabindingdemo.MyLog; - -import ohos.aafwk.ability.DataAbilityHelper; -import ohos.aafwk.ability.DataAbilityRemoteException; -import ohos.data.dataability.DataAbilityPredicates; -import ohos.data.rdb.ValuesBucket; -import ohos.data.resultset.ResultSet; -import ohos.utils.net.Uri; - -import java.util.ArrayList; -import java.util.List; - -/** - * Note data Operation, wrapping datasource CURD operations for 'note-list' example.. - * - * @since 2021-05-15 - */ -public class NotesOperation { - private static final int ERR_CODE = -1; - private final DataAbilityHelper helper; - private final Uri USER_URI; - - private NotesOperation() { - helper = DataAbilityHelper.creator(MyApplication.getApplication()); - USER_URI = NotesDataAbility.NOTE_URI; - } - - private static class SingleNotesOperation { - private static final NotesOperation INSTANCE = new NotesOperation(); - } - - /** - * Obtaining a Singleton Instance - * - * @return NotesOperation object - */ - public static NotesOperation getInstance() { - return SingleNotesOperation.INSTANCE; - } - - /** - * Querying All Data - * - * @return A List of {@link Note}s - */ - public List queryAll() { - return query(null); - } - - /** - * Insert Note Data - * - * @param content Indicates a Note contents. - * @param time Indicates a Note created time in seconds. - * @return Note index - */ - public int insert(String content, int time) { - ValuesBucket valuesBucket = new ValuesBucket(); - valuesBucket.putString("content", content); - valuesBucket.putInteger("time", time); - - int result; - try { - result = helper.insert(USER_URI, valuesBucket); - } catch (DataAbilityRemoteException e) { - result = ERR_CODE; - } - return result; - } - - private List query(DataAbilityPredicates predicates) { - ResultSet resultSet = null; - try { - resultSet = helper.query(USER_URI, new String[]{"content", "time"}, predicates); - } catch (DataAbilityRemoteException e) { - MyLog.error("NotesOperation data query exception"); - } - List notes = new ArrayList<>(); - if (resultSet != null) { - // Processing result - boolean hasData = resultSet.goToFirstRow(); - if (!hasData) { - return notes; - } - do { - // Process the records in the ResultSet. - notes.add(getQueryResults(resultSet)); - } - while (resultSet.goToNextRow()); - } - return notes; - } - - private Note getQueryResults(ResultSet resultSet) { - Note note = new Note(); - for (String column : resultSet.getAllColumnNames()) { - int index = resultSet.getColumnIndexForName(column); - note.setAttribute(column, getFromColumn(resultSet, index)); - } - return note; - } - - private Object getFromColumn(ResultSet resultSet, int index) { - ResultSet.ColumnType type = resultSet.getColumnTypeForIndex(index); - switch (type) { - case TYPE_INTEGER: - return resultSet.getInt(index); - case TYPE_FLOAT: - return resultSet.getDouble(index); - case TYPE_STRING: - return resultSet.getString(index); - case TYPE_BLOB: - case TYPE_NULL: - default: - return null; - } - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/handler/MyDataHandler.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/handler/MyDataHandler.java deleted file mode 100644 index c43f5c8adb5bdeed5080a6fe3f8c0873f9b11a25..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/handler/MyDataHandler.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.custom_data_source.handler; - -import com.huawei.metadatabindingdemo.MyLog; -import com.huawei.metadatabindingdemo.custom_data_source.db.NotesDataAbility; - -import ohos.aafwk.ability.DataAbilityHelper; -import ohos.aafwk.ability.DataAbilityRemoteException; -import ohos.app.Context; -import ohos.data.rdb.ValuesBucket; -import ohos.data.resultset.ResultSet; -import ohos.mp.metadata.binding.MetaDataFramework; -import ohos.mp.metadata.binding.dao.CustomDao; -import ohos.mp.metadata.binding.databinding.MetaDataRequestInfo; -import ohos.mp.metadata.binding.metadata.MetaData; -import ohos.utils.PacMap; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class supplies Customized Data Source binding. You can encapsulate any datasource types through this class. - * - * @since 2021-05-15 - */ -public class MyDataHandler implements CustomDao.ICustomMetaDataHandler { - private DataAbilityHelper mDbHelper = null; - private MetaDataRequestInfo.RequestItem mReqItem = null; - - @Override - public boolean onConnect(CustomDao dao) { - Context mCtx = MetaDataFramework.appContext; - this.mDbHelper = DataAbilityHelper.creator(mCtx); - this.mReqItem = dao.getRequestItem(); - return true; - } - - @Override - public List onQuery(CustomDao dao, boolean isSync, String[] properties, PacMap predicates) { - ArrayList list = new ArrayList<>(); - try { - ResultSet resultSet = mDbHelper.query(NotesDataAbility.NOTE_URI, null, null); - if (resultSet != null) { - boolean hasData = resultSet.goToFirstRow(); - if (!hasData) { - return list; - } - do { - list.add(getQueryResults(resultSet)); - } - while (resultSet.goToNextRow()); - } - } catch (DataAbilityRemoteException e) { - MyLog.error("ohosTest: SimpleHandler onQuery error"); - } - return list; - } - - private MetaData getQueryResults(ResultSet resultSet) { - MetaData metaData = MetaDataFramework.createMetaData(mReqItem); - for (String column : resultSet.getAllColumnNames()) { - int index = resultSet.getColumnIndexForName(column); - assert metaData != null; - metaData.put(column, getFromColumn(resultSet, index)); - } - return metaData; - } - - private Object getFromColumn(ResultSet resultSet, int index) { - ResultSet.ColumnType type = resultSet.getColumnTypeForIndex(index); - switch (type) { - case TYPE_INTEGER: - return resultSet.getInt(index); - case TYPE_FLOAT: - return resultSet.getDouble(index); - case TYPE_STRING: - return resultSet.getString(index); - case TYPE_BLOB: - case TYPE_NULL: - default: - return null; - } - } - - @Override - public void onAdd(MetaData metaData) { - } - - @Override - public void onDelete(MetaData metaData) { - } - - @Override - public void onChange(MetaData metaData, String key, Object value) { - MyLog.info("ohosTest: MyDataHandler----onchange" + key + "-" + value); - ValuesBucket vb = new ValuesBucket(); - vb.putString(key, (String) value); - try { - mDbHelper.update(NotesDataAbility.NOTE_URI, vb, null); - } catch (DataAbilityRemoteException e) { - MyLog.error("ohosTest: SimpleHandler onChange error"); - } - } - - @Override - public void onFlush(MetaData metaData) { - } - - @Override - public void onDisconnect(CustomDao dao) { - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/metadata/NoteMetaData.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/metadata/NoteMetaData.java deleted file mode 100644 index 9692824a4cbd25095460f4400981415a57b635eb..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_data_source/metadata/NoteMetaData.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.custom_data_source.metadata; - -import com.huawei.metadatabindingdemo.MyLog; - -import ohos.mp.metadata.binding.metadata.MetaData; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * This MetaData indicates a row of note dataset, wraps the information of a note. - * This class is used in Note List binding demo. - * For the MetaData content see: src/main/resources/rawfile/jsonschema/note_schema.json. - * - * @since 2021-05-15 - */ -public class NoteMetaData extends MetaData { - private static final int UNIT_1000 = 1000; - private static final long UNIT_1000_LONG = 1000L; - private static final int UNIT_60 = 60; - - /** - * Conversion Format - * - * @param createTime Note create time - * @return Note create time show format - */ - public String getTime(int createTime) { - long nowTime = System.currentTimeMillis(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - String sd = sdf.format(new Date(nowTime)); - Date date = null; - try { - date = sdf.parse(sd); - } catch (ParseException e) { - MyLog.error("NoteMetaData getTime exception"); - } - assert date != null; - int todayTime = (int) (date.getTime() / UNIT_1000); - int howLongPass = (int) (nowTime / UNIT_1000 - createTime); - if (howLongPass < UNIT_60) { - return "Just now"; - } else if (howLongPass < UNIT_60 * UNIT_60) { - return (howLongPass / UNIT_60) + " minutes ago"; - } else if (createTime > todayTime) { - SimpleDateFormat sdf1 = new SimpleDateFormat("a hh:mm"); - long createTimeL = createTime * UNIT_1000_LONG; - return sdf1.format(createTimeL); - } else { - SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); - long createTimeL = createTime * UNIT_1000_LONG; - return sdf2.format(createTimeL); - } - } -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/CustomOperatorSlice.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/CustomOperatorSlice.java deleted file mode 100644 index 458ea6af9d8130b610bbefdfb93a2c1b2f84095f..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/CustomOperatorSlice.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.custom_ui; - -import com.huawei.metadatabindingdemo.ResourceTable; -import com.huawei.metadatabindingdemo.custom_ui.metadata.CustomMetaData; -import com.huawei.metadatabindingdemo.metadatabinding.CustomoperatorMetaDataBinding; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.agp.components.Component; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.DependentLayout; -import ohos.mp.metadata.binding.databinding.MetaDataBinding; - -/** - * Custom Operator Ability Slice - * - * @since 2021-05-15 - */ -public class CustomOperatorSlice extends AbilitySlice { - CustomMetaData metaData; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - createComponent(); - } - - private void createComponent() { - metaData = new CustomMetaData(); - metaData.setPrimaryKey("id"); - metaData.setName("MetaData"); - metaData.put("bool_attr", false); - MetaDataBinding binding; - Component mainComponent; - binding = CustomoperatorMetaDataBinding.createBinding(this, metaData); - mainComponent = binding.getLayoutComponent(); - setUIContent((ComponentContainer) mainComponent); - - DependentLayout dependentLayout = (DependentLayout) mainComponent.findComponentById(ResourceTable - .Id_title_area_back_icon_hot_area); - dependentLayout.setClickedListener(component -> this.terminate()); - } - - @Override - public void onActive() { - super.onActive(); - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/component/MyRadioButton.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/component/MyRadioButton.java deleted file mode 100644 index cd2c0ceb489b916f4d40e8700d960b95d12338e2..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/component/MyRadioButton.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.custom_ui.component; - -import ohos.agp.components.AttrSet; -import ohos.agp.components.RadioButton; -import ohos.app.Context; - -/** - * A radio button, this one is not adopted by fwk - * - * @since 2021-05-15 - */ -public class MyRadioButton extends RadioButton { - /** - * default constructor - * - * @param context context - */ - public MyRadioButton(Context context) { - super(context); - } - - /** - * mast be overload here - * - * @param context context - * @param attrSet attrset from xml - */ - public MyRadioButton(Context context, AttrSet attrSet) { - super(context, attrSet); - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/component/MySquare.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/component/MySquare.java deleted file mode 100644 index 40abca0d8c209f38ff84ff54f764f0a88b100d67..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/component/MySquare.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.custom_ui.component; - -import ohos.agp.components.AttrSet; -import ohos.agp.components.Component; -import ohos.agp.render.Canvas; -import ohos.agp.render.Paint; -import ohos.agp.utils.Color; -import ohos.app.Context; - -/** - * This is a self defined component. This component will display a wheel. - * - * @since 2021-05-15 - */ -public class MySquare extends Component implements Component.EstimateSizeListener, Component.DrawTask { - private static final float CIRCLE_STROKE_WIDTH = 100f; - - /** - * circle is green or not - */ - private boolean isGreen = false; - - private Paint rectPaint; - - /** - * default constructor - * - * @param context context - */ - public MySquare(Context context) { - super(context); - init(); - } - - /** - * must be overloaded - * - * @param context context - * @param attrSet attrset from xml - */ - public MySquare(Context context, AttrSet attrSet) { - super(context, attrSet); - init(); - } - - private void init() { - setEstimateSizeListener(this); - initPaint(); - addDrawTask(this); - } - - private void initPaint() { - rectPaint = new Paint(); - rectPaint.setColor(Color.BLUE); - rectPaint.setStrokeWidth(CIRCLE_STROKE_WIDTH); - rectPaint.setStyle(Paint.Style.STROKE_STYLE); - } - - /** - * draw component - * - * @param component component - * @param canvas canvas - */ - @Override - public void onDraw(Component component, Canvas canvas) { - int height = getHeight(); - int width = getWidth(); - int left = getPaddingLeft(); - int top = getPaddingTop(); - canvas.drawRect(left, top, left + width, top + height, rectPaint); - } - - /** - * Measuring this component' size. - * - * @param widthEstimateConfig config width:wq:wq - * - * @param heightEstimateConfig config height - * @return boolean true. - */ - @Override - public boolean onEstimateSize(int widthEstimateConfig, int heightEstimateConfig) { - int width = EstimateSpec.getSize(widthEstimateConfig); - int height = EstimateSpec.getSize(heightEstimateConfig); - setEstimatedSize( - EstimateSpec.getChildSizeWithMode(width, width, EstimateSpec.NOT_EXCEED), - EstimateSpec.getChildSizeWithMode(height, height, EstimateSpec.NOT_EXCEED)); - return true; - } - - /** - * set Circle color - * - * @param isGreen boolean, green or not - */ - public void setColor(boolean isGreen) { - this.isGreen = isGreen; - if (isGreen) { - rectPaint.setColor(Color.GREEN); - invalidate(); - } else { - rectPaint.setColor(Color.YELLOW); - invalidate(); - } - } -} diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/operator/Custom1Operator.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/operator/Custom1Operator.java deleted file mode 100644 index 996722718b3b4bb8cbaaa5d33f1c351c19f8bca8..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/operator/Custom1Operator.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.custom_ui.operator; - -import com.huawei.metadatabindingdemo.custom_ui.component.MySquare; - -import ohos.agp.components.Component; -import ohos.mp.metadata.annotation.BindingComponent; -import ohos.mp.metadata.annotation.BindingTag; -import ohos.mp.metadata.binding.uioperate.Operator; - -/** - * This class creates two {@link Operator}s for {@link MySquare} component. - * Operator is an abstract conception of 'operation' that do some operation with the binding value, - * normally setting component's attributes. - * - * @since 2021-05-15 - */ -@BindingComponent(component = - "com.huawei.metadatabindingdemo.custom_ui.component.MySquare") -public class Custom1Operator { - /** - * When the binding MetaData changing, we hope this operator is used to do setColor operation of - * the MySquare. - */ - @BindingTag(attr = "enabled2", type = "java.lang.Boolean") - public static Operator SetColorOperator = new Operator() { - @Override - public void operate(Component component, Boolean value) { - ((MySquare) component).setColor(value); - } - }; -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/operator/Custom2Operator.java b/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/operator/Custom2Operator.java deleted file mode 100644 index c2aa22777b48b9c6b7f56b80d7b15b17016467ee..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/operator/Custom2Operator.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.metadatabindingdemo.custom_ui.operator; - -import com.huawei.metadatabindingdemo.custom_ui.component.MyRadioButton; - -import ohos.agp.components.Component; -import ohos.agp.utils.Color; -import ohos.mp.metadata.annotation.BindingComponent; -import ohos.mp.metadata.annotation.BindingTag; -import ohos.mp.metadata.binding.uioperate.Operator; - -/** - * This class creates two {@link Operator}s for {@link MyRadioButton} component. - * Operator is an abstract conception of 'operation' that do some operation according to the binding value, - * normally setting component's attributes. - * - * @since 2021-05-15 - */ -@BindingComponent(component = - "com.huawei.metadatabindingdemo.custom_ui.component.MyRadioButton") -public class Custom2Operator { - /** - * When the binding MetaData changing, we hope this operator is used to do setTextColorOn operation of - * the MyRadioButton. - */ - @BindingTag(attr = "text_color_on2", type = "ohos.agp.utils.Color") - public static Operator SetOnColor = new Operator() { - @Override - public void operate(Component component, Color value) { - ((MyRadioButton)component).setTextColorOn(value); - } - }; - - /** - * When the binding MetaData changing, f, we hope this operator is used to do setTextColorOff operation of - * the MyRadioButton. - */ - @BindingTag(attr = "text_color_off2", type = "ohos.agp.utils.Color") - public static Operator SetOffColor = new Operator() { - @Override - public void operate(Component component, Color value) { - ((MyRadioButton)component).setTextColorOff(value); - } - }; -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/resources/base/element/color.json b/MetaDataBindingDemo/entry/src/main/resources/base/element/color.json deleted file mode 100644 index 618b4d935f13ea6be1e0014227f8557bc1451b0b..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "color": [ - { - "name": "colorPrimary", - "value": "#E6000000" - }, - { - "name": "colorSecondary", - "value": "#99000000" - }, - { - "name": "colorAppbarTitle", - "value": "#000000" - }, - { - "name": "colorAppbarBg", - "value": "#ffffff" - }, - { - "name": "colorAppbarSubBg", - "value": "#ffffff" - }, - { - "name": "textColorPrimary", - "value": "#E6000000" - }, - { - "name": "textColorSecondary", - "value": "#99000000" - }, - { - "name": "colorCardViewBg", - "value": "#ffffff" - }, - { - "name": "colorAppBackground", - "value": "#f1f3f5" - }, - { - "name": "colorSearchBarBackground", - "value": "#0C000000" - }, - { - "name": "colorListDivider", - "value": "#33000000" - } - ] -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/resources/base/element/float.json b/MetaDataBindingDemo/entry/src/main/resources/base/element/float.json deleted file mode 100644 index 00ba5235f43c7351469ea434cb61a1b064e52429..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/resources/base/element/float.json +++ /dev/null @@ -1,140 +0,0 @@ -{ - "float": [ - { - "name": "titleTextSize", - "value": "24fp" - }, - { - "name": "singleCardViewHeight", - "value": "80vp" - }, - { - "name": "singleCardViewLeftMargin", - "value": "12vp" - }, - { - "name": "singleCardViewTextHeight", - "value": "48vp" - }, - { - "name": "singleCardViewRightMargin", - "value": "12vp" - }, - { - "name": "textSizeBody1", - "value": "16fp" - }, - { - "name": "textSizeBody2", - "value": "14fp" - }, - { - "name": "titleTextLeftPadding", - "value": "4vp" - }, - { - "name": "singleCardViewRightIconHeight", - "value": "48vp" - }, - { - "name": "singleCardViewRightTextHeight", - "value": "48vp" - }, - { - "name": "singleCardViewRightTextRightMargin", - "value": "4vp" - }, - { - "name": "titlePartHeight", - "value": "56vp" - }, - { - "name": "titlePartIconHotAreaHeight", - "value": "48vp" - }, - { - "name": "titlePartIconHotAreaWidth", - "value": "48vp" - }, - { - "name": "titlePartIconHotAreaLeftMargin", - "value": "12vp" - }, - { - "name": "titlePartIconHotAreaRightMargin", - "value": "12vp" - }, - { - "name": "titlePartIconHeight", - "value": "24vp" - }, - { - "name": "titlePartIconWidth", - "value": "24vp" - }, - { - "name": "listDividerHeight", - "value": "1vp" - }, - { - "name": "listContainerTopPadding", - "value": "12vp" - }, - { - "name": "listContainerBottomPadding", - "value": "14vp" - }, - { - "name": "doubleLineItemLeftIconHeight", - "value": "24vp" - }, - { - "name": "doubleLineItemLeftIconWidth", - "value": "24vp" - }, - { - "name": "doubleLineItemLeftIconLeftMargin", - "value": "12vp" - }, - { - "name": "doubleLineItemLeftIconRightMargin", - "value": "16vp" - }, - { - "name": "doubleLineItemMainTextHeight", - "value": "24vp" - }, - { - "name": "doubleLineItemMainTextTopMargin", - "value": "8vp" - }, - { - "name": "doubleLineItemMainTextBottomMargin", - "value": "1vp" - }, - { - "name": "doubleLineItemSubTextHeight", - "value": "24vp" - }, - { - "name": "doubleLineItemSubTextBottomMargin", - "value": "8vp" - }, - { - "name": "doubleLineItemSubTextTopMargin", - "value": "1vp" - }, - { - "name": "doubleLineItemRightIconHotAreaRightMargin", - "value": "6vp" - }, - { - "name": "doubleLineItemRightIconHotAreaHeight", - "value": "48vp" - }, - { - "name": "doubleLineItemRightIconHotAreaWidth", - "value": "48vp" - } - ] -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/resources/base/element/string.json b/MetaDataBindingDemo/entry/src/main/resources/base/element/string.json deleted file mode 100644 index 389181ca06193606f8c9d1d5d16c7cb1df202c3f..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "MvvmDataBaseClock" - }, - { - "name": "mainability_description", - "value": "Java_Phone_Settings Feature Ability" - }, - { - "name": "label", - "value": "MetaDatabindingDemo" - }, - { - "name": "settings_list_title", - "value": "Title" - }, - { - "name": "clockdataability_description", - "value": "hap sample empty provider" - }, - { - "name": "metadata_service", - "value": "MetaDataFrameworkService" - }, - { - "name": "def_permission_description", - "value": "heiheihei" - } - ] -} \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/background_ability_main.xml b/MetaDataBindingDemo/entry/src/main/resources/base/graphic/background_ability_main.xml deleted file mode 100644 index a002c2353e78af3a15235e00738328ff566bc085..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/background_ability_main.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/background_note.xml b/MetaDataBindingDemo/entry/src/main/resources/base/graphic/background_note.xml deleted file mode 100644 index 893490d3e5c842592aaaf7ea706412905bb567a0..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/background_note.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/background_select_button.xml b/MetaDataBindingDemo/entry/src/main/resources/base/graphic/background_select_button.xml deleted file mode 100644 index d9956e1c32f653914fe8dfee486bac3d25f7c540..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/background_select_button.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/background_text_field.xml b/MetaDataBindingDemo/entry/src/main/resources/base/graphic/background_text_field.xml deleted file mode 100644 index 928c13023997f7d3312489806e55862c638c5067..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/background_text_field.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_add.xml b/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_add.xml deleted file mode 100644 index e9dfdb614efafe83ed3723e953e801cac17848a7..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_add.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - diff --git a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_back.xml b/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_back.xml deleted file mode 100644 index 72eadb2087f4347544f0d8467ce785452855c993..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_back.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - diff --git a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_more.xml b/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_more.xml deleted file mode 100644 index 392bd97bb89fa1b1f895522beaf3b0e9f68c691b..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_more.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - diff --git a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_right_grey.xml b/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_right_grey.xml deleted file mode 100644 index 9ed26a84b79352058321c2b696b80473ce0a68f4..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_right_grey.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - diff --git a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_star.xml b/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_star.xml deleted file mode 100644 index 1bd831b40ca07a129fddb3b1d7b37ad58338323e..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_star.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - diff --git a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_switch_disable.xml b/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_switch_disable.xml deleted file mode 100644 index be8efdbf1178c7e32beb81d22042f0b3e6d2baf1..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_switch_disable.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - diff --git a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_switch_enable.xml b/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_switch_enable.xml deleted file mode 100644 index 0934abc9a294099c1b8165efa96badc86ab56933..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/resources/base/graphic/icon_switch_enable.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - diff --git a/MetaDataBindingDemo/entry/src/main/resources/base/layout/alarm_detail.xml b/MetaDataBindingDemo/entry/src/main/resources/base/layout/alarm_detail.xml deleted file mode 100644 index 024f5511b55d04f2b013ce7e6b833aa61d7b18d1..0000000000000000000000000000000000000000 --- a/MetaDataBindingDemo/entry/src/main/resources/base/layout/alarm_detail.xml +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ShoppingJs/entry/src/main/resources/base/element/string.json b/ShoppingJs/entry/src/main/resources/base/element/string.json deleted file mode 100644 index b9890866dd98f1a62e1aa31b087829a8573cc9d3..0000000000000000000000000000000000000000 --- a/ShoppingJs/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "codelab" - }, - { - "name": "mainability_description", - "value": "JS_Phone_Empty Feature Ability" - } - ] -} \ No newline at end of file diff --git a/ShoppingJs/entry/src/main/resources/base/media/icon.png b/ShoppingJs/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index 2e24ee37e7ea2d1b35599b838f2a01ee97c1dfb0..0000000000000000000000000000000000000000 Binary files a/ShoppingJs/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/ShoppingJs/entry/src/ohosTest/config.json b/ShoppingJs/entry/src/ohosTest/config.json deleted file mode 100644 index f33f058d051a9fd7605b0cc92668f52e2646ef42..0000000000000000000000000000000000000000 --- a/ShoppingJs/entry/src/ohosTest/config.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "app": { - "bundleName": "com.huawei.codelab", - "vendor": "huawei", - "version": { - "code": 1, - "name": "1.0" - }, - "apiVersion": { - "compatible": 3, - "target": 4, - "releaseType": "Beta1" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.huawei.codelab", - "name": "testModule", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry_test", - "moduleType": "feature" - }, - "abilities": [ - { - "name": "decc.testkit.runner.JsEntryAbility", - "description": "Test Entry Ability", - "icon": "$media:icon", - "label": "TestAbility", - "launchType": "standard", - "orientation": "landscape", - "visible": true, - "type": "page" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 750, - "autoDesignWidth": false - } - } - ] - } -} \ No newline at end of file diff --git a/ShoppingJs/entry/src/ohosTest/js/default/common/logo.png b/ShoppingJs/entry/src/ohosTest/js/default/common/logo.png deleted file mode 100644 index 8ff99801a568aba384af790d7af48f83d9cf1603..0000000000000000000000000000000000000000 Binary files a/ShoppingJs/entry/src/ohosTest/js/default/common/logo.png and /dev/null differ diff --git a/ShoppingJs/entry/src/ohosTest/js/default/i18n/en-US.json b/ShoppingJs/entry/src/ohosTest/js/default/i18n/en-US.json deleted file mode 100644 index 55561b83737c3c31d082fbfa11e5fc987a351104..0000000000000000000000000000000000000000 --- a/ShoppingJs/entry/src/ohosTest/js/default/i18n/en-US.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - }, - "Files": { - } -} \ No newline at end of file diff --git a/ShoppingJs/entry/src/ohosTest/js/default/i18n/zh-CN.json b/ShoppingJs/entry/src/ohosTest/js/default/i18n/zh-CN.json deleted file mode 100644 index cce1af06761a42add0cac1a0567aa3237eda8cb4..0000000000000000000000000000000000000000 --- a/ShoppingJs/entry/src/ohosTest/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - }, - "Files": { - } -} \ No newline at end of file diff --git a/ShoppingJs/entry/src/ohosTest/js/default/pages/index/index.css b/ShoppingJs/entry/src/ohosTest/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/ShoppingJs/entry/src/ohosTest/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/ShoppingJs/entry/src/ohosTest/js/default/pages/index/index.hml b/ShoppingJs/entry/src/ohosTest/js/default/pages/index/index.hml deleted file mode 100644 index 1c26cf73deab18390844a53a103458b10ed11e93..0000000000000000000000000000000000000000 --- a/ShoppingJs/entry/src/ohosTest/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{ $t('strings.hello') }} {{title}} - -
diff --git a/ShoppingJs/entry/src/ohosTest/js/default/pages/index/index.js b/ShoppingJs/entry/src/ohosTest/js/default/pages/index/index.js deleted file mode 100644 index 8e45a632a42592c80d81362b27d42976e5e00b51..0000000000000000000000000000000000000000 --- a/ShoppingJs/entry/src/ohosTest/js/default/pages/index/index.js +++ /dev/null @@ -1,40 +0,0 @@ -import file from '@system.file' -import app from '@system.app' -import device from '@system.device' -import router from '@system.router' - -import {Core, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - const reportExtend = new ReportExtend(file) - const instrumentLog = new InstrumentLog({ - 'id': 'report' - }) - core.addService('expect', expectExtend) - core.addService('report', reportExtend) - core.addService('report', instrumentLog) - core.init() - core.subscribeEvent('spec', instrumentLog) - core.subscribeEvent('suite', instrumentLog) - core.subscribeEvent('task', instrumentLog) - - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} \ No newline at end of file diff --git a/ShoppingJs/entry/src/ohosTest/js/test/ExampleJsunit.test.js b/ShoppingJs/entry/src/ohosTest/js/test/ExampleJsunit.test.js deleted file mode 100644 index 79c59740af9424a45643da52bcf4c963d831852c..0000000000000000000000000000000000000000 --- a/ShoppingJs/entry/src/ohosTest/js/test/ExampleJsunit.test.js +++ /dev/null @@ -1,11 +0,0 @@ -import app from '@system.app' - -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -describe('appInfoTest', function () { - it('app_info_test_001', 0, function () { - var info = app.getInfo() - expect(info.versionName).assertEqual('1.0') - expect(info.versionCode).assertEqual('3') - }) -}) \ No newline at end of file diff --git a/ShoppingJs/entry/src/ohosTest/js/test/List.test.js b/ShoppingJs/entry/src/ohosTest/js/test/List.test.js deleted file mode 100644 index 305eb5bb254cd4802afaffebe68fca2f9436159f..0000000000000000000000000000000000000000 --- a/ShoppingJs/entry/src/ohosTest/js/test/List.test.js +++ /dev/null @@ -1 +0,0 @@ -require('./ExampleJsunit.test.js') \ No newline at end of file diff --git a/ShoppingJs/entry/src/ohosTest/resources/base/element/string.json b/ShoppingJs/entry/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index 40be19fe0d5538f04c7fc10f65c183585828b0cd..0000000000000000000000000000000000000000 --- a/ShoppingJs/entry/src/ohosTest/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "codelab" - }, - { - "name": "mainability_description", - "value": "hap sample empty page" - } - ] -} diff --git a/ShoppingJs/entry/src/ohosTest/resources/base/media/icon.png b/ShoppingJs/entry/src/ohosTest/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/ShoppingJs/entry/src/ohosTest/resources/base/media/icon.png and /dev/null differ diff --git a/ShoppingJs/gradle/wrapper/gradle-wrapper.jar b/ShoppingJs/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 490fda8577df6c95960ba7077c43220e5bb2c0d9..0000000000000000000000000000000000000000 Binary files a/ShoppingJs/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/ShoppingJs/gradle/wrapper/gradle-wrapper.properties b/ShoppingJs/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index bf127d05e72e6d10a23778bd97ee29ac8c849bba..0000000000000000000000000000000000000000 --- a/ShoppingJs/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists \ No newline at end of file diff --git a/ShoppingJs/settings.gradle b/ShoppingJs/settings.gradle deleted file mode 100644 index 4773db73233a570c2d0c01a22e75321acfbf7a07..0000000000000000000000000000000000000000 --- a/ShoppingJs/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':entry' diff --git a/ShoppingOpenHarmony/README.md b/ShoppingOpenHarmony/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f058162b4805336900d3d029c2fde205d330d66a --- /dev/null +++ b/ShoppingOpenHarmony/README.md @@ -0,0 +1,11 @@ +# ShoppingOpenHarmony + +ShoppingOpenHarmony + +本篇Codelab是在HarmonyOS JS组件购物车应用的代码基础上,对OpenHarmony开发板进行的适配。 + +我们将教会大家如何将一个HarmonyOS应用适配、部署到OpenHarmony开发板上。 + +案例最终效果如下图所示: + +![](screenshots/device/ShoppingDemo.PNG) \ No newline at end of file diff --git a/ToolbarApplication/build.gradle b/ShoppingOpenHarmony/build.gradle similarity index 86% rename from ToolbarApplication/build.gradle rename to ShoppingOpenHarmony/build.gradle index 446fc5b42cf8013148be318ba66aae0480fdbc1b..fa230b707f071d544736902167fda519b343d087 100644 --- a/ToolbarApplication/build.gradle +++ b/ShoppingOpenHarmony/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.huawei.ohos.app' //For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 ohos { - compileSdkVersion 5 + compileSdkVersion 6 } buildscript { @@ -16,8 +16,8 @@ buildscript { } } dependencies { - classpath 'com.huawei.ohos:hap:2.4.5.3' - classpath 'com.huawei.ohos:decctest:1.2.4.1' + classpath 'com.huawei.ohos:hap:3.0.1.5' + classpath 'com.huawei.ohos:decctest:3.0.1.1' } } diff --git a/CodecDemo/entry/.gitignore b/ShoppingOpenHarmony/entry/.gitignore similarity index 33% rename from CodecDemo/entry/.gitignore rename to ShoppingOpenHarmony/entry/.gitignore index 796b96d1c402326528b4ba3c12ee9d92d0e212e9..7d5b7a94f4dcf381f03ff21f28f8a2494b58023f 100644 --- a/CodecDemo/entry/.gitignore +++ b/ShoppingOpenHarmony/entry/.gitignore @@ -1 +1,2 @@ /build +/node_modules diff --git a/ToolbarApplication/entry/build.gradle b/ShoppingOpenHarmony/entry/build.gradle similarity index 72% rename from ToolbarApplication/entry/build.gradle rename to ShoppingOpenHarmony/entry/build.gradle index 4ff8bc645e758cc5dacdcfe1bfb22a1d5348e736..6c2dca308825d3d38937c45c03918e1628bbfb75 100644 --- a/ToolbarApplication/entry/build.gradle +++ b/ShoppingOpenHarmony/entry/build.gradle @@ -1,10 +1,9 @@ apply plugin: 'com.huawei.ohos.hap' -apply plugin: 'com.huawei.ohos.decctest' //For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 ohos { - compileSdkVersion 5 + compileSdkVersion 6 defaultConfig { - compatibleSdkVersion 4 + compatibleSdkVersion 6 } buildTypes { release { @@ -15,13 +14,10 @@ ohos { } } + supportSystem "standard" } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) testImplementation 'junit:junit:4.13' - ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.200' -} -decc { - supportType = ['html','xml'] } diff --git a/InputApplication/entry/package.json b/ShoppingOpenHarmony/entry/package.json similarity index 100% rename from InputApplication/entry/package.json rename to ShoppingOpenHarmony/entry/package.json diff --git a/DistributeDatabaseDraw-master/entry/proguard-rules.pro b/ShoppingOpenHarmony/entry/proguard-rules.pro similarity index 100% rename from DistributeDatabaseDraw-master/entry/proguard-rules.pro rename to ShoppingOpenHarmony/entry/proguard-rules.pro diff --git a/ShoppingJs/entry/src/main/config.json b/ShoppingOpenHarmony/entry/src/main/config.json similarity index 77% rename from ShoppingJs/entry/src/main/config.json rename to ShoppingOpenHarmony/entry/src/main/config.json index 4dec19554784119cfd404814fdfcc642ad1d0187..0e2472a094b872f4b6429fafd174e12977584236 100644 --- a/ShoppingJs/entry/src/main/config.json +++ b/ShoppingOpenHarmony/entry/src/main/config.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.huawei.codelab", + "bundleName": "com.huawei.shopping", "vendor": "huawei", "version": { "code": 1000000, @@ -9,9 +9,9 @@ }, "deviceConfig": {}, "module": { - "package": "com.huawei.codelab", + "package": "com.huawei.shopping", "name": ".MyApplication", - "mainAbility": "com.huawei.codelab.MainAbility", + "mainAbility": "com.huawei.shopping.MainAbility", "deviceType": [ "phone" ], @@ -33,10 +33,13 @@ ] } ], - "name": "com.huawei.codelab.MainAbility", + "orientation": "unspecified", + "visible": true, + "name": "com.huawei.shopping.MainAbility", "icon": "$media:icon", "description": "$string:mainability_description", - "label": "$string:app_name", + "formsEnabled": false, + "label": "$string:shoppingDemo", "type": "page", "launchType": "standard" } diff --git a/InputApplication/entry/src/main/js/default/app.js b/ShoppingOpenHarmony/entry/src/main/js/default/app.js similarity index 40% rename from InputApplication/entry/src/main/js/default/app.js rename to ShoppingOpenHarmony/entry/src/main/js/default/app.js index aedcefe0054c6e16c40491f4d1abc20a4dc1c6ef..6d060ffe5682c19fc83e2274a9e62cbc40a655f8 100644 --- a/InputApplication/entry/src/main/js/default/app.js +++ b/ShoppingOpenHarmony/entry/src/main/js/default/app.js @@ -1,8 +1,8 @@ export default { onCreate() { - console.info('AceApplication onCreate'); + console.info("Application onCreate"); }, onDestroy() { - console.info('AceApplication onDestroy'); + console.info("Application onDestroy"); } }; diff --git a/ShoppingJs/entry/src/main/js/default/common/background.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/background.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/background.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/background.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/computer1.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer1.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/computer1.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer1.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/computer10.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer10.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/computer10.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer10.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/computer11.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer11.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/computer11.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer11.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/computer12.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer12.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/computer12.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer12.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/computer13.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer13.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/computer13.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer13.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/computer14.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer14.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/computer14.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer14.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/computer2.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer2.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/computer2.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer2.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/computer3.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer3.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/computer3.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer3.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/computer4.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer4.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/computer4.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer4.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/computer5.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer5.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/computer5.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer5.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/computer6.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer6.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/computer6.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer6.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/computer7.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer7.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/computer7.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer7.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/computer8.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer8.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/computer8.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer8.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/computer9.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer9.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/computer9.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/computer9.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/icon-buy.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/icon-buy.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/icon-buy.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/icon-buy.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/icon-close.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/icon-close.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/icon-close.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/icon-close.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/icon-pinn.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/icon-pinn.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/icon-pinn.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/icon-pinn.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/icon-promotion.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/icon-promotion.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/icon-promotion.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/icon-promotion.png diff --git a/ShoppingJs/entry/src/main/js/default/common/computer/icon-return1.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/computer/icon-return1.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/computer/icon-return1.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/computer/icon-return1.png diff --git a/ShoppingJs/entry/src/main/js/default/common/detail/icon-more.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/detail/icon-more.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/detail/icon-more.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/detail/icon-more.png diff --git a/ShoppingJs/entry/src/main/js/default/common/detail/icon-return.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/detail/icon-return.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/detail/icon-return.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/detail/icon-return.png diff --git a/ShoppingJs/entry/src/main/js/default/common/detail/icon-share.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/detail/icon-share.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/detail/icon-share.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/detail/icon-share.png diff --git a/ShoppingJs/entry/src/main/js/default/common/nav/icon-buy.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-buy.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/nav/icon-buy.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-buy.png diff --git a/ShoppingJs/entry/src/main/js/default/common/nav/icon-home.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-home.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/nav/icon-home.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-home.png diff --git a/ShoppingJs/entry/src/main/js/default/common/nav/icon-menu-buy.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-menu-buy.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/nav/icon-menu-buy.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-menu-buy.png diff --git a/ShoppingJs/entry/src/main/js/default/common/nav/icon-menu-release.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-menu-release.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/nav/icon-menu-release.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-menu-release.png diff --git a/ShoppingJs/entry/src/main/js/default/common/nav/icon-menu-sell.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-menu-sell.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/nav/icon-menu-sell.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-menu-sell.png diff --git a/ShoppingJs/entry/src/main/js/default/common/nav/icon-message-select.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-message-select.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/nav/icon-message-select.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-message-select.png diff --git a/ShoppingJs/entry/src/main/js/default/common/nav/icon-message.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-message.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/nav/icon-message.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-message.png diff --git a/ShoppingJs/entry/src/main/js/default/common/nav/icon-my-select.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-my-select.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/nav/icon-my-select.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-my-select.png diff --git a/ShoppingJs/entry/src/main/js/default/common/nav/icon-shopping-cart-select.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-shopping-cart-select.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/nav/icon-shopping-cart-select.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-shopping-cart-select.png diff --git a/ShoppingJs/entry/src/main/js/default/common/nav/icon-shopping-cart.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-shopping-cart.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/nav/icon-shopping-cart.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-shopping-cart.png diff --git a/ShoppingJs/entry/src/main/js/default/common/nav/icon-user.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-user.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/nav/icon-user.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/nav/icon-user.png diff --git a/ShoppingJs/entry/src/main/js/default/common/nav/iocn-my.png b/ShoppingOpenHarmony/entry/src/main/js/default/common/nav/iocn-my.png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/nav/iocn-my.png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/nav/iocn-my.png diff --git a/ShoppingJs/entry/src/main/js/default/common/picture/HW (1).png b/ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (1).png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/picture/HW (1).png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (1).png diff --git a/ShoppingJs/entry/src/main/js/default/common/picture/HW (10).png b/ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (10).png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/picture/HW (10).png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (10).png diff --git a/ShoppingJs/entry/src/main/js/default/common/picture/HW (11).png b/ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (11).png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/picture/HW (11).png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (11).png diff --git a/ShoppingJs/entry/src/main/js/default/common/picture/HW (12).png b/ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (12).png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/picture/HW (12).png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (12).png diff --git a/ShoppingJs/entry/src/main/js/default/common/picture/HW (13).png b/ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (13).png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/picture/HW (13).png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (13).png diff --git a/ShoppingJs/entry/src/main/js/default/common/picture/HW (14).png b/ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (14).png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/picture/HW (14).png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (14).png diff --git a/ShoppingJs/entry/src/main/js/default/common/picture/HW (15).png b/ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (15).png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/picture/HW (15).png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (15).png diff --git a/ShoppingJs/entry/src/main/js/default/common/picture/HW (2).png b/ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (2).png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/picture/HW (2).png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (2).png diff --git a/ShoppingJs/entry/src/main/js/default/common/picture/HW (3).png b/ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (3).png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/picture/HW (3).png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (3).png diff --git a/ShoppingJs/entry/src/main/js/default/common/picture/HW (4).png b/ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (4).png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/picture/HW (4).png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (4).png diff --git a/ShoppingJs/entry/src/main/js/default/common/picture/HW (5).png b/ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (5).png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/picture/HW (5).png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (5).png diff --git a/ShoppingJs/entry/src/main/js/default/common/picture/HW (6).png b/ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (6).png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/picture/HW (6).png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (6).png diff --git a/ShoppingJs/entry/src/main/js/default/common/picture/HW (7).png b/ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (7).png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/picture/HW (7).png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (7).png diff --git a/ShoppingJs/entry/src/main/js/default/common/picture/HW (8).png b/ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (8).png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/picture/HW (8).png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (8).png diff --git a/ShoppingJs/entry/src/main/js/default/common/picture/HW (9).png b/ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (9).png similarity index 100% rename from ShoppingJs/entry/src/main/js/default/common/picture/HW (9).png rename to ShoppingOpenHarmony/entry/src/main/js/default/common/picture/HW (9).png diff --git a/InputApplication/entry/src/ohosTest/js/default/i18n/en-US.json b/ShoppingOpenHarmony/entry/src/main/js/default/i18n/en-US.json similarity index 40% rename from InputApplication/entry/src/ohosTest/js/default/i18n/en-US.json rename to ShoppingOpenHarmony/entry/src/main/js/default/i18n/en-US.json index 55561b83737c3c31d082fbfa11e5fc987a351104..08e34eac912bf2651eefc20e26aa479b5e4e7ec2 100644 --- a/InputApplication/entry/src/ohosTest/js/default/i18n/en-US.json +++ b/ShoppingOpenHarmony/entry/src/main/js/default/i18n/en-US.json @@ -1,7 +1,10 @@ { "strings": { "hello": "Hello", - "world": "World" + "world": "World", + "page": "Second Page", + "next": "Next Page", + "back": "Back" }, "Files": { } diff --git a/AnimationDemo/entry/src/ohosTest/js/default/i18n/zh-CN.json b/ShoppingOpenHarmony/entry/src/main/js/default/i18n/zh-CN.json similarity index 40% rename from AnimationDemo/entry/src/ohosTest/js/default/i18n/zh-CN.json rename to ShoppingOpenHarmony/entry/src/main/js/default/i18n/zh-CN.json index cce1af06761a42add0cac1a0567aa3237eda8cb4..3dd53b3a8b808aec9396fa663cb00ef22ba61e0a 100644 --- a/AnimationDemo/entry/src/ohosTest/js/default/i18n/zh-CN.json +++ b/ShoppingOpenHarmony/entry/src/main/js/default/i18n/zh-CN.json @@ -1,7 +1,10 @@ { "strings": { "hello": "您好", - "world": "世界" + "world": "世界", + "page": "第二页", + "next": "下一页", + "back": "返回" }, "Files": { } diff --git a/ShoppingJs/entry/src/main/js/default/pages/homepage/homepage.css b/ShoppingOpenHarmony/entry/src/main/js/default/pages/homepage/homepage.css similarity index 89% rename from ShoppingJs/entry/src/main/js/default/pages/homepage/homepage.css rename to ShoppingOpenHarmony/entry/src/main/js/default/pages/homepage/homepage.css index 449a1ca238538ec5a9b77b004504a02e6370ad15..2ddc9d8e549aeaee52441c2959e55ee9746bc35a 100644 --- a/ShoppingJs/entry/src/main/js/default/pages/homepage/homepage.css +++ b/ShoppingOpenHarmony/entry/src/main/js/default/pages/homepage/homepage.css @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + .container { flex-direction: column; align-items: center; @@ -116,13 +131,11 @@ .container-more-div { display: flex; - flex-flow: row wrap; justify-content: space-around; font-weight: 700; } .container-more-div:after { - content: ""; width: 100px; } diff --git a/ShoppingJs/entry/src/main/js/default/pages/homepage/homepage.hml b/ShoppingOpenHarmony/entry/src/main/js/default/pages/homepage/homepage.hml similarity index 91% rename from ShoppingJs/entry/src/main/js/default/pages/homepage/homepage.hml rename to ShoppingOpenHarmony/entry/src/main/js/default/pages/homepage/homepage.hml index afcb779e24e2439b92ef0e20e50a08ce5ca09d2f..3b79c2b8199cda44a38d175e7efd5d238c196215 100644 --- a/ShoppingJs/entry/src/main/js/default/pages/homepage/homepage.hml +++ b/ShoppingOpenHarmony/entry/src/main/js/default/pages/homepage/homepage.hml @@ -1,3 +1,18 @@ + +
-
+
diff --git a/ShoppingJs/entry/src/main/js/default/pages/homepage/homepage.js b/ShoppingOpenHarmony/entry/src/main/js/default/pages/homepage/homepage.js similarity index 96% rename from ShoppingJs/entry/src/main/js/default/pages/homepage/homepage.js rename to ShoppingOpenHarmony/entry/src/main/js/default/pages/homepage/homepage.js index 402e36b2461a37197fa6299a22710a41262d3fa8..ce21b57b79fca3b31fd745f76830c3724b2f8e95 100644 --- a/ShoppingJs/entry/src/main/js/default/pages/homepage/homepage.js +++ b/ShoppingOpenHarmony/entry/src/main/js/default/pages/homepage/homepage.js @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import router from '@system.router'; import prompt from '@system.prompt'; diff --git a/ShoppingJs/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.css b/ShoppingOpenHarmony/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.css similarity index 89% rename from ShoppingJs/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.css rename to ShoppingOpenHarmony/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.css index 2a709e44c1f1ba0c7debf7ed0c0ad07829d3f528..138a60978da5994fe05c77294438694000dc101c 100644 --- a/ShoppingJs/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.css +++ b/ShoppingOpenHarmony/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.css @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + .container { display: flex; flex-direction: column; diff --git a/ShoppingJs/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.hml b/ShoppingOpenHarmony/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.hml similarity index 93% rename from ShoppingJs/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.hml rename to ShoppingOpenHarmony/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.hml index adc33058ba0d124ea538a87c13db537c10e93c56..76e983c16ad640469eee2e86fefd11a4e1124964 100644 --- a/ShoppingJs/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.hml +++ b/ShoppingOpenHarmony/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.hml @@ -1,3 +1,18 @@ + +
diff --git a/ShoppingJs/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.js b/ShoppingOpenHarmony/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.js similarity index 92% rename from ShoppingJs/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.js rename to ShoppingOpenHarmony/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.js index a08de1c5d589c49d59760d9970cee7a668ec2213..bb7a09947513d24455651f223663d7edd7718fcb 100644 --- a/ShoppingJs/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.js +++ b/ShoppingOpenHarmony/entry/src/main/js/default/pages/shoppingDetailsPage/shoppingDetailsPage.js @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import router from '@system.router'; import prompt from '@system.prompt'; import app from '@system.app'; diff --git a/ClickableImageJsDemo/entry/src/main/java/com/huawei/codelab/MyApplication.java b/ShoppingOpenHarmony/entry/src/main/js/default/pages/viewsChart/viewsChart.css similarity index 65% rename from ClickableImageJsDemo/entry/src/main/java/com/huawei/codelab/MyApplication.java rename to ShoppingOpenHarmony/entry/src/main/js/default/pages/viewsChart/viewsChart.css index ebaef9f3399415fb04f2c88763e10206dce016e3..89cc11d7bd3890c704289a325bea9218c019e5fd 100644 --- a/ClickableImageJsDemo/entry/src/main/java/com/huawei/codelab/MyApplication.java +++ b/ShoppingOpenHarmony/entry/src/main/js/default/pages/viewsChart/viewsChart.css @@ -13,18 +13,28 @@ * limitations under the License. */ -package com.huawei.codelab; +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} -import ohos.aafwk.ability.AbilityPackage; +.chart-region { + height: 400px; + width: 700px; +} -/*** - * 应用 - * - * @since 2021-07-22 - */ -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } +.chart-background { + object-fit: fill; +} + +.chart-data { + width: 700px; + height: 600px; +} + +.button-sty { + margin-top: 10px; + width: 300px; + height: 80px; } diff --git a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/MainAbility.java b/ShoppingOpenHarmony/entry/src/main/js/default/pages/viewsChart/viewsChart.hml similarity index 56% rename from DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/MainAbility.java rename to ShoppingOpenHarmony/entry/src/main/js/default/pages/viewsChart/viewsChart.hml index ad60fb09e18ad684110c3b0eb27eeee2ed64e509..668bdd014f47691f1d35ea701e68c6c0050bec1b 100644 --- a/DistributeDatabaseDraw-master/entry/src/main/java/com/huawei/codelab/MainAbility.java +++ b/ShoppingOpenHarmony/entry/src/main/js/default/pages/viewsChart/viewsChart.hml @@ -1,4 +1,4 @@ -/* + -package com.huawei.codelab; - -import com.huawei.codelab.slice.MainAbilitySlice; - -import ohos.aafwk.ability.Ability; -import ohos.aafwk.content.Intent; - -/** - * MainAbility - * - * @since 2021-04-06 - */ -public class MainAbility extends Ability { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setMainRoute(MainAbilitySlice.class.getName()); - } -} +
+ + + + + + + + +
\ No newline at end of file diff --git a/ShoppingJs/entry/src/main/js/default/pages/viewsChart/viewsChart.js b/ShoppingOpenHarmony/entry/src/main/js/default/pages/viewsChart/viewsChart.js similarity index 75% rename from ShoppingJs/entry/src/main/js/default/pages/viewsChart/viewsChart.js rename to ShoppingOpenHarmony/entry/src/main/js/default/pages/viewsChart/viewsChart.js index 57a1565c97a52d562fdbdcec5bad8a480d17c034..7dfb453447ce72e8a13a47dfe1d81d3f69f2e6c5 100644 --- a/ShoppingJs/entry/src/main/js/default/pages/viewsChart/viewsChart.js +++ b/ShoppingOpenHarmony/entry/src/main/js/default/pages/viewsChart/viewsChart.js @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + export default { data: { temp: 0, diff --git a/ClickableImageJsDemo/entry/src/main/resources/base/element/string.json b/ShoppingOpenHarmony/entry/src/main/resources/base/element/string.json similarity index 63% rename from ClickableImageJsDemo/entry/src/main/resources/base/element/string.json rename to ShoppingOpenHarmony/entry/src/main/resources/base/element/string.json index 0e974a99c5a20d3482090c686f02e0e0995c192c..b7375991268c78ab9c8a3454d142ea62fc3db390 100644 --- a/ClickableImageJsDemo/entry/src/main/resources/base/element/string.json +++ b/ShoppingOpenHarmony/entry/src/main/resources/base/element/string.json @@ -1,8 +1,8 @@ { "string": [ { - "name": "entry_MainAbility", - "value": "ClickableJsImage" + "name": "shoppingDemo", + "value": "购物商场" }, { "name": "mainability_description", diff --git a/ClickableImageJsDemo/entry/src/main/resources/base/media/icon.png b/ShoppingOpenHarmony/entry/src/main/resources/base/media/icon.png similarity index 100% rename from ClickableImageJsDemo/entry/src/main/resources/base/media/icon.png rename to ShoppingOpenHarmony/entry/src/main/resources/base/media/icon.png diff --git a/ShoppingOpenHarmony/screenshots/device/ShoppingDemo.PNG b/ShoppingOpenHarmony/screenshots/device/ShoppingDemo.PNG new file mode 100644 index 0000000000000000000000000000000000000000..fdb989df1d7ee3e113c21665f926e3361f299455 Binary files /dev/null and b/ShoppingOpenHarmony/screenshots/device/ShoppingDemo.PNG differ diff --git a/ClockFACardDemo/settings.gradle b/ShoppingOpenHarmony/settings.gradle similarity index 100% rename from ClockFACardDemo/settings.gradle rename to ShoppingOpenHarmony/settings.gradle diff --git a/SimpleVideoCodelab/LICENSE b/SimpleVideoCodelab/LICENSE deleted file mode 100644 index b36a10d589119cb8557ff572ca3f5b0aab970604..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - Copyright (c) 2021 Huawei Device Co., Ltd. - - Licensed under the Apache License,Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -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 diff --git a/SimpleVideoCodelab/README.md b/SimpleVideoCodelab/README.md deleted file mode 100644 index 76dc737f8c62dbeaa9ee5bed5b2ec73465c3b4ba..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# SimpleVideoCodelab -简介 -• 此Demo用于简单地使用视频播放器。您可以方便、快捷地接入并实现视频播放,然后可以对播放内容的一些相关操作。 - -安装要求 -• 安装DevEco Studio -• 设置DevEco Studio开发环境。DevEco Studio开发环境需要连接到网络,以确保该正常使用。可以根据以下两种情况配置开发环境: - 1.如果您可以直接访问Internet,则只需下载HarmonyOS SDK - 2.如果网络无法直接访问Internet,则可以通过代理服务器进行访问 -• 生成密钥并申请证书 - -用户指南 -• 下载此项目 -• 打开HUAWEI DevEco Studio,单击File> Open选择此项目 -• 单击Build> Build App(s)/Hap(s)>Build Debug Hap(s)以编译hap软件包 -• 单击Run> Run 'entry'以运行hap包 - -注意 -• 您可以选择在模拟器或真机上运行hap软件包。 -• 如果在真机上运行它,则需要在项目的File> Project Structure> Modules> Signing Configs中配置签名和证书信息。 - -许可 -请参阅LICENSE文件以获得更多信息。 - -What is it? -This demo is used to simply use a video player. You can access and play videos conveniently and quickly, and then perform operations on the content to be played. - -Installation requirements -• Install DevEco Studio -• Set up the DevEco Studio development environment.The DevEco Studio development environment needs to depend on the network environment. It needs to be connected to the network to ensure the normal use of the tool.The development environment can be configured according to the following two situations - 1.If you can directly access the Internet, just download the HarmonyOS SDK - 2.If the network cannot access the Internet directly, it can be accessed through a proxy server -• Generate secret key and apply for certificate - -User guide -• Download this Project -• Open HUAWEI DevEco Studio, click File> Open> Then select and open this Project -• Click Build> Build App(s)/Hap(s)>Build Debug Hap(s) to compile the hap package -• Click Run> Run 'entry' to run the hap package - -Note -• You can choose to run the hap package on the simulator or the phone. -• If you run it on the phone, you need to configure the signature and certificate information in the project's File> Project Structure> Modules> Signing Configs. - -Licensing -Please see LICENSE for more info. \ No newline at end of file diff --git a/SimpleVideoCodelab/RELEASE-NOTES.md b/SimpleVideoCodelab/RELEASE-NOTES.md deleted file mode 100644 index ea23a13e3d4407d06cba3aa7155a23e5081b50b4..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/RELEASE-NOTES.md +++ /dev/null @@ -1,2 +0,0 @@ -1.0.0 -1.Initial version \ No newline at end of file diff --git a/SimpleVideoCodelab/build.gradle b/SimpleVideoCodelab/build.gradle deleted file mode 100644 index 0cdb1590ae7440ce7a35f6a3f6d2e970542c718e..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -apply plugin: 'com.huawei.ohos.app' - -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 4 - } -} - -buildscript { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } - dependencies { - classpath 'com.huawei.ohos:hap:2.4.2.7' - classpath 'com.huawei.ohos:decctest:1.0.0.7' - } -} - -allprojects { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } -} \ No newline at end of file diff --git a/SimpleVideoCodelab/entry/build.gradle b/SimpleVideoCodelab/entry/build.gradle deleted file mode 100644 index 3de012e16603dcf2842c83db5963598cb4b98ccf..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/build.gradle +++ /dev/null @@ -1,25 +0,0 @@ -apply plugin: 'com.huawei.ohos.hap' -apply plugin: 'com.huawei.ohos.decctest' -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 4 - } - buildTypes { - release { - proguardOpt { - proguardEnabled false - rulesFiles 'proguard-rules.pro' - } - } - } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - testImplementation 'junit:junit:4.13' - ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' -} -decc { - supportType = ['html', 'xml'] -} diff --git a/SimpleVideoCodelab/entry/entry.iml b/SimpleVideoCodelab/entry/entry.iml deleted file mode 100644 index bed000050ec3cb21894d02610549c9ff78d33c95..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/entry.iml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/SimpleVideoCodelab/entry/src/main/config.json b/SimpleVideoCodelab/entry/src/main/config.json deleted file mode 100644 index 40854c6471b475ed5429862dfd6bfd4f8c8cca83..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/config.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "app": { - "bundleName": "com.huawei.cookbook", - "vendor": "huawei", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "package": "ohos.codelabs.video", - "name": ".MainAbility", - "reqCapabilities": [ - "video_support" - ], - "deviceType": [ - "default" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": false - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "orientation": "unspecified", - "configChanges": [ - "orientation" - ], - "formsEnabled": true, - "name": ".MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard" - } - ], - "reqPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } -} \ No newline at end of file diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/MainAbility.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/MainAbility.java deleted file mode 100644 index c61a290d32028919a8e59663785629fb15baca85..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/MainAbility.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video; - -import ohos.aafwk.ability.Ability; -import ohos.aafwk.content.Intent; -import ohos.codelabs.video.slice.SimplePlayerAbilitySlice; - -/** - * the main page - * - * @since 2021-04-04 - * - */ -public class MainAbility extends Ability { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setMainRoute(SimplePlayerAbilitySlice.class.getName()); - } -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/HmPlayer.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/HmPlayer.java deleted file mode 100644 index ce05ab2ec2b51b74a0e79ec86451259a366031dd..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/HmPlayer.java +++ /dev/null @@ -1,507 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player; - -import ohos.agp.graphics.Surface; -import ohos.app.Context; -import ohos.app.dispatcher.task.TaskPriority; -import ohos.codelabs.video.player.api.ImplLifecycle; -import ohos.codelabs.video.player.api.ImplPlayer; -import ohos.codelabs.video.player.api.ScreenChangeListener; -import ohos.codelabs.video.player.api.StatuChangeListener; -import ohos.codelabs.video.player.constant.Constants; -import ohos.codelabs.video.player.constant.PlayerStatu; -import ohos.codelabs.video.player.factory.SourceFactory; -import ohos.codelabs.video.player.manager.HmPlayerLifecycle; -import ohos.codelabs.video.util.LogUtil; -import ohos.media.common.Source; -import ohos.media.player.Player; - -import java.util.ArrayList; -import java.util.List; - -/** - * Hm player - * - * @since 2021-04-04 - */ -public class HmPlayer implements ImplPlayer { - private static final String TAG = HmPlayer.class.getSimpleName(); - private static final int MICRO_MILLI_RATE = 1000; - private Player mPlayer; - private Surface surface; - private HmPlayerLifecycle mLifecycle; - private Builder mBuilder; - private PlayerStatu mStatu = PlayerStatu.IDEL; - private float currentVolume = 1; - private double videoScale = Constants.NUMBER_NEGATIVE_1; - private boolean isGestureOpen; - - private List statuChangeCallbacks = new ArrayList<>(0); - private List screenChangeCallbacks = new ArrayList<>(0); - - /** - * constructor of HmPlayer - * - * @param builder builder - */ - private HmPlayer(Builder builder) { - mBuilder = builder; - mLifecycle = new HmPlayerLifecycle(this); - } - - private void initBasePlayer() { - mPlayer = new Player(mBuilder.mContext); - Source source = new SourceFactory(mBuilder.mContext, mBuilder.filePath).getSource(); - mPlayer.setSource(source); - mPlayer.setPlayerCallback(new HmPlayerCallback()); - } - - /** - * HmPlayer Callback - * - * @since 2020-12-04 - */ - private class HmPlayerCallback implements Player.IPlayerCallback { - @Override - public void onPrepared() { - LogUtil.info(TAG, "onPrepared is called "); - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.PREPARED; - callback.statuCallback(PlayerStatu.PREPARED); - } - } - - @Override - public void onMessage(int info, int i1) { - LogUtil.info(TAG, "onMessage info is " + info + ",i1 is" + i1); - if (i1 == 0) { - switch (info) { - case Player.PLAYER_INFO_VIDEO_RENDERING_START: - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.PLAY; - callback.statuCallback(PlayerStatu.PLAY); - } - if (mBuilder.isPause) { - pause(); - } - break; - case Player.PLAYER_INFO_BUFFERING_START: - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.BUFFERING; - callback.statuCallback(PlayerStatu.BUFFERING); - } - break; - case Player.PLAYER_INFO_BUFFERING_END: - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.PLAY; - callback.statuCallback(PlayerStatu.PLAY); - } - break; - default: - break; - } - } - } - - @Override - public void onError(int type, int extra) { - LogUtil.info(TAG, "onError is called ,i is " + type + ",i1 is " + extra); - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.ERROR; - callback.statuCallback(PlayerStatu.ERROR); - } - release(); - } - - @Override - public void onResolutionChanged(int videoX, int videoY) { - LogUtil.info(TAG, "onResolutionChanged videoX is " + videoX + ",videoY is " + videoY); - if (!mBuilder.isStretch && videoX != 0 && videoY != 0) { - videoScale = (double) videoX / videoY; - } - } - - @Override - public void onPlayBackComplete() { - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.COMPLETE; - callback.statuCallback(PlayerStatu.COMPLETE); - } - } - - @Override - public void onRewindToComplete() { - resume(); - } - - @Override - public void onBufferingChange(int value) { - } - - @Override - public void onNewTimedMetaData(Player.MediaTimedMetaData mediaTimedMetaData) { - LogUtil.info(TAG, "onNewTimedMetaData is called"); - } - - @Override - public void onMediaTimeIncontinuity(Player.MediaTimeInfo mediaTimeInfo) { - LogUtil.info(TAG, "onMediaTimeIncontinuity is called"); - for (Player.StreamInfo streanInfo : mPlayer.getStreamInfo()) { - int streamType = streanInfo.getStreamType(); - if (streamType == Player.StreamInfo.MEDIA_STREAM_TYPE_AUDIO && mStatu == PlayerStatu.PREPARED) { - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.PLAY; - callback.statuCallback(PlayerStatu.PLAY); - } - if (mBuilder.isPause) { - pause(); - } - } - } - } - } - - /** - * start time consuming operation - */ - private void start() { - if (mPlayer != null) { - mBuilder.mContext.getGlobalTaskDispatcher(TaskPriority.DEFAULT).asyncDispatch(() -> { - if (surface != null) { - mPlayer.setVideoSurface(surface); - } else { - LogUtil.error(TAG, "The surface has not been initialized."); - } - mPlayer.prepare(); - if (mBuilder.startMillisecond > 0) { - int microsecond = mBuilder.startMillisecond * MICRO_MILLI_RATE; - mPlayer.rewindTo(microsecond); - } - mPlayer.play(); - }); - } - } - - @Override - public ImplLifecycle getLifecycle() { - return mLifecycle; - } - - @Override - public void addSurface(Surface videoSurface) { - this.surface = videoSurface; - } - - @Override - public void addPlayerStatuCallback(StatuChangeListener callback) { - if (callback != null) { - statuChangeCallbacks.add(callback); - } - } - - @Override - public void removePlayerStatuCallback(StatuChangeListener callback) { - statuChangeCallbacks.remove(callback); - } - - @Override - public void addPlayerViewCallback(ScreenChangeListener callback) { - if (callback != null) { - screenChangeCallbacks.add(callback); - } - } - - @Override - public void removePlayerViewCallback(ScreenChangeListener callback) { - screenChangeCallbacks.remove(callback); - } - - @Override - public Builder getBuilder() { - return mBuilder; - } - - @Override - public PlayerStatu getPlayerStatu() { - return mStatu; - } - - @Override - public void resizeScreen(int width, int height) { - for (ScreenChangeListener screenChangeCallback : screenChangeCallbacks) { - screenChangeCallback.screenCallback(width, height); - } - } - - @Override - public void openGesture(boolean isOpen) { - isGestureOpen = isOpen; - } - - @Override - public boolean isGestureOpen() { - return isPlaying() && isGestureOpen; - } - - @Override - public void play() { - if (mPlayer != null) { - mPlayer.reset(); - } - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.PREPARING; - callback.statuCallback(PlayerStatu.PREPARING); - } - initBasePlayer(); - start(); - } - - @Override - public void replay() { - if (isPlaying()) { - rewindTo(0); - } else { - reload(mBuilder.filePath, 0); - } - } - - @Override - public void reload(String filepath, int startMillisecond) { - mBuilder.filePath = filepath; - mBuilder.startMillisecond = startMillisecond; - play(); - } - - @Override - public void stop() { - if (mPlayer == null) { - return; - } - mPlayer.stop(); - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.STOP; - callback.statuCallback(PlayerStatu.STOP); - } - } - - @Override - public void release() { - if (mPlayer == null) { - return; - } - if (mStatu != PlayerStatu.IDEL) { - videoScale = Constants.NUMBER_NEGATIVE_1; - mPlayer.release(); - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.IDEL; - callback.statuCallback(PlayerStatu.IDEL); - } - } - } - - @Override - public void resume() { - if (mPlayer == null) { - return; - } - if (mStatu != PlayerStatu.IDEL) { - if (!isPlaying()) { - mPlayer.play(); - } - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.PLAY; - callback.statuCallback(PlayerStatu.PLAY); - } - } - } - - @Override - public void pause() { - if (mPlayer == null) { - return; - } - if (isPlaying()) { - mPlayer.pause(); - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.PAUSE; - callback.statuCallback(PlayerStatu.PAUSE); - } - } - } - - @Override - public int getCurrentPosition() { - if (mPlayer == null) { - return 0; - } - return mPlayer.getCurrentTime(); - } - - @Override - public int getDuration() { - if (mPlayer == null) { - return 0; - } - return mPlayer.getDuration(); - } - - @Override - public float getVolume() { - return currentVolume; - } - - @Override - public void setVolume(float volume) { - if (mPlayer != null) { - if (mPlayer.setVolume(volume)) { - currentVolume = volume; - } - } - } - - @Override - public void setPlaySpeed(float speed) { - if (mPlayer == null) { - return; - } - if (mStatu != PlayerStatu.IDEL) { - mPlayer.setPlaybackSpeed(speed); - } - } - - @Override - public double getVideoScale() { - return videoScale; - } - - @Override - public boolean isPlaying() { - if (mPlayer != null) { - return mPlayer.isNowPlaying(); - } - return false; - } - - @Override - public void rewindTo(int startMicrosecond) { - if (mPlayer == null) { - return; - } - if (mStatu != PlayerStatu.IDEL) { - for (StatuChangeListener callback : statuChangeCallbacks) { - mStatu = PlayerStatu.BUFFERING; - callback.statuCallback(PlayerStatu.BUFFERING); - } - mPlayer.rewindTo(startMicrosecond * MICRO_MILLI_RATE); - } - } - - /** - * Builder - * - * @since 2020-12-04 - */ - public static class Builder { - private Context mContext; - private String filePath; - private int startMillisecond; - private boolean isStretch; - private boolean isPause; - - /** - * constructor of Builder - * - * @param context context - */ - public Builder(Context context) { - mContext = context; - filePath = ""; - startMillisecond = 0; - } - - /** - * setFilePath of Builder - * - * @param filePath filePath - * @return builder - */ - public Builder setFilePath(String filePath) { - this.filePath = filePath; - return this; - } - - /** - * getFilePath of Builder - * - * @return filePath - */ - public String getFilePath() { - return filePath; - } - - /** - * setStartMillisecond of Builder - * - * @param startMillisecond startMillisecond - * @return builder - */ - public Builder setStartMillisecond(int startMillisecond) { - this.startMillisecond = startMillisecond; - return this; - } - - /** - * getStartMillisecond of Builder - * - * @return startMillisecond - */ - public int getStartMillisecond() { - return startMillisecond; - } - - /** - * setStretch of Builder - * - * @param isS isStretch - * @return Builder - */ - public Builder setStretch(boolean isS) { - this.isStretch = isS; - return this; - } - - /** - * setPause of Builder - * - * @param isP isPause - * @return Builder - */ - public Builder setPause(boolean isP) { - this.isPause = isP; - return this; - } - - /** - * create of Builder - * - * @return IPlayer - */ - public ImplPlayer create() { - return new HmPlayer(this); - } - } -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/api/ImplLifecycle.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/api/ImplLifecycle.java deleted file mode 100644 index 2bdc603fc29a5cd5d8803e1d5da9140f31d5ed6c..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/api/ImplLifecycle.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.api; - -/** - * ImplLifecycle - * - * @since 2021-04-09 - * - */ -public interface ImplLifecycle { - /** - * onStart - * - */ - void onStart(); - - /** - * onForeground - * - */ - void onForeground(); - - /** - * onBackground - * - */ - void onBackground(); - - /** - * onStop - * - */ - void onStop(); -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/api/ImplPlayModule.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/api/ImplPlayModule.java deleted file mode 100644 index d183ea67e5dfe7c605fe78316e1cabf7caf53674..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/api/ImplPlayModule.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.api; - -/** - * IPlayModuler - * - * @since 2021-04-09 - * - */ -public interface ImplPlayModule { - /** - * bind - * - * @param player player - */ - void bind(ImplPlayer player); - - /** - * unbind - * - */ - void unbind(); -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/api/ImplPlayer.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/api/ImplPlayer.java deleted file mode 100644 index 06c5d49cd64d6d48b15e992fc47dc82dc84c8334..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/api/ImplPlayer.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.api; - -import ohos.agp.graphics.Surface; -import ohos.codelabs.video.player.HmPlayer; -import ohos.codelabs.video.player.constant.PlayerStatu; - -/** - * IPlayer interface - * - * @since 2021-04-04 - */ -public interface ImplPlayer { - /** - * addSurface - * - * @param surface surface - */ - void addSurface(Surface surface); - - /** - * addPlayerStatuCallback - * - * @param callback callback - */ - void addPlayerStatuCallback(StatuChangeListener callback); - - /** - * removePlayerStatuCallback - * - * @param callback callback - */ - void removePlayerStatuCallback(StatuChangeListener callback); - - /** - * addPlayerViewCallback - * - * @param callback callback - */ - void addPlayerViewCallback(ScreenChangeListener callback); - - /** - * removePlayerViewCallback - * - * @param callback callback - */ - void removePlayerViewCallback(ScreenChangeListener callback); - - /** - * play - */ - void play(); - - /** - * replay - */ - void replay(); - - /** - * reload - * - * @param filepath filepath - * @param startMillisecond startMillisecond - */ - void reload(String filepath, int startMillisecond); - - /** - * resume - */ - void resume(); - - /** - * pause - */ - void pause(); - - /** - * getCurrentPosition - * - * @return current position - */ - int getCurrentPosition(); - - /** - * getDuration - * - * @return duration - */ - int getDuration(); - - /** - * getVolume - * - * @return float - */ - float getVolume(); - - /** - * set play volume - * - * @param volume 0~1 - */ - void setVolume(float volume); - - /** - * set play speed - * - * @param speed 0~12 - */ - void setPlaySpeed(float speed); - - /** - * getVideoScale - * - * @return double - */ - double getVideoScale(); - - /** - * rewindTo - * - * @param startMicrosecond startMicrosecond(ms) - */ - void rewindTo(int startMicrosecond); - - /** - * isPlaying - * - * @return isPlaying - */ - boolean isPlaying(); - - /** - * stop - */ - void stop(); - - /** - * release - */ - void release(); - - /** - * getLifecycle - * - * @return ImplLifecycle - */ - ImplLifecycle getLifecycle(); - - /** - * getBuilder - * - * @return Builder - */ - HmPlayer.Builder getBuilder(); - - /** - * getPlayerStatu - * - * @return PlayerStatu - */ - PlayerStatu getPlayerStatu(); - - /** - * resizeScreen - * - * @param width width - * @param height height - */ - void resizeScreen(int width, int height); - - /** - * openGesture - * - * @param isOpen isOpen - */ - void openGesture(boolean isOpen); - - /** - * openGesture - * - * @return isGestureOpen - */ - boolean isGestureOpen(); -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/api/ScreenChangeListener.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/api/ScreenChangeListener.java deleted file mode 100644 index 7bd722b0e56ec7a0588e0c4d7802eeb6f4d7044b..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/api/ScreenChangeListener.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.api; - -/** - * ScreenChangeListener interface - * - * @since 2021-04-04 - * - */ -public interface ScreenChangeListener { - /** - * screenCallback - * - * @param width width - * @param height height - */ - void screenCallback(int width, int height); -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/api/StatuChangeListener.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/api/StatuChangeListener.java deleted file mode 100644 index 28052869c8f2084dc2127d86e9da8962270154a1..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/api/StatuChangeListener.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.api; - -import ohos.codelabs.video.player.constant.PlayerStatu; - -/** - * StatuChangeListener interface - * - * @since 2021-04-04 - * - */ -public interface StatuChangeListener { - /** - * statuCallback - * - * @param statu statu - */ - void statuCallback(PlayerStatu statu); -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/constant/Constants.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/constant/Constants.java deleted file mode 100644 index 134c82644170b4040656fe662ae508c4fa187069..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/constant/Constants.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.constant; - -/** - * Constants - * - * @since 2021-04-04 - */ -public class Constants { - /** - * -1 - */ - public static final int NUMBER_NEGATIVE_1 = -1; - /** - * 2 - */ - public static final int NUMBER_2 = 2; - /** - * 2.0 - */ - public static final float NUMBER_FLOAT_2 = 2f; - /** - * 10 - */ - public static final int NUMBER_10 = 10; - /** - * 25 - */ - public static final int NUMBER_25 = 25; - /** - * 36 - */ - public static final int NUMBER_36 = 36; - /** - * 40 - */ - public static final int NUMBER_40 = 40; - /** - * 100 - */ - public static final int NUMBER_100 = 100; - /** - * 300 - */ - public static final int NUMBER_300 = 300; - /** - * 150 - */ - public static final int NUMBER_150 = 150; - /** - * 1000 - */ - public static final int NUMBER_1000 = 1000; - /** - * running - */ - public static final int PLAYER_PROGRESS_RUNNING = 0; - /** - * hide - */ - public static final int PLAYER_CONTROLLER_HIDE = 1; - /** - * hide - */ - public static final int PLAYER_CONTROLLER_SHOW = 2; - /** - * 100 - */ - public static final int ONE_HUNDRED_PERCENT = 100; - /** - * rewind step - */ - public static final int REWIND_STEP = 5000; - /** - * volume step - */ - public static final int VOLUME_STEP = 5; - /** - * INTENT STARTTIME PARAM - */ - public static final String INTENT_STARTTIME_PARAM = "intetn_starttime_param"; - /** - * INTENT PLAYURL PARAM - */ - public static final String INTENT_PLAYURL_PARAM = "intetn_playurl_param"; - /** - * INTENT PLAYSTATU PARAM - */ - public static final String INTENT_PLAYSTATU_PARAM = "intetn_playstatu_param"; - /** - * INTENT LANDSCREEN REQUEST CODE - */ - public static final int INTENT_LANDSCREEN_REQUEST_CODE = 1001; - - private Constants() { - } -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/constant/GestureConst.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/constant/GestureConst.java deleted file mode 100644 index 8f775aa56e23c4a8fb07bd92e535cba6d10f8c9b..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/constant/GestureConst.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.constant; - -/** - * GestureConst - * - * @since 2021-04-04 - */ -public class GestureConst { - private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500; - - private static final int TOUCH_SLOP = 64; - - private static final int TAP_TIMEOUT = 100; - - private static final int DOUBLE_TAP_TIMEOUT = 300; - - private static final int DOUBLE_TAP_MIN_TIME = 40; - - private static final int DOUBLE_TAP_SLOP = 100; - - private static final int MINIMUM_FLING_VELOCITY = 50; - - private static final int MAXIMUM_FLING_VELOCITY = 8000; - - private static final int DOUBLE_TAP_TOUCH_SLOP = TOUCH_SLOP; - - private static final float AMBIGUOUS_GESTURE_MULTIPLIER = 2f; - - private GestureConst() { - } - - /** - * getDoubleTapTimeout - * - * @return int - */ - public static int getDoubleTapTimeout() { - return DOUBLE_TAP_TIMEOUT; - } - - /** - * getDoubleTapMinTime - * - * @return int - */ - public static int getDoubleTapMinTime() { - return DOUBLE_TAP_MIN_TIME; - } - - /** - * getTouchSlop - * - * @return int - */ - public static int getTouchSlop() { - return TOUCH_SLOP; - } - - /** - * getLongPressTimeout - * - * @return int - */ - public static int getLongPressTimeout() { - return DEFAULT_LONG_PRESS_TIMEOUT; - } - - /** - * getTapTimeout - * - * @return int - */ - public static int getTapTimeout() { - return TAP_TIMEOUT; - } - - /** - * getDoubleTapSlop - * - * @return int - */ - public static int getDoubleTapSlop() { - return DOUBLE_TAP_SLOP; - } - - /** - * getMinimumFlingVelocity - * - * @return int - */ - public static int getMinimumFlingVelocity() { - return MINIMUM_FLING_VELOCITY; - } - - /** - * getMaximumFlingVelocity - * - * @return int - */ - public static int getMaximumFlingVelocity() { - return MAXIMUM_FLING_VELOCITY; - } - - /** - * getScaledTouchSlop - * - * @return int - */ - public static int getScaledTouchSlop() { - return TOUCH_SLOP; - } - - /** - * getScaledDoubleTapTouchSlop - * - * @return int - */ - public static int getScaledDoubleTapTouchSlop() { - return DOUBLE_TAP_TOUCH_SLOP; - } - - /** - * getScaledDoubleTapSlop - * - * @return int - */ - public static int getScaledDoubleTapSlop() { - return DOUBLE_TAP_SLOP; - } - - /** - * getScaledMinimumFlingVelocity - * - * @return int - */ - public static int getScaledMinimumFlingVelocity() { - return MINIMUM_FLING_VELOCITY; - } - - /** - * getScaledMaximumFlingVelocity - * - * @return int - */ - public static int getScaledMaximumFlingVelocity() { - return MAXIMUM_FLING_VELOCITY; - } - - /** - * getAmbiguousGestureMultiplier - * - * @return int - */ - public static float getAmbiguousGestureMultiplier() { - return AMBIGUOUS_GESTURE_MULTIPLIER; - } -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/constant/PlayerStatu.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/constant/PlayerStatu.java deleted file mode 100644 index c78c6575ef1a08d9930da573640a82d07f561972..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/constant/PlayerStatu.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.constant; - -/** - * PlayerStatu enum - * - * @since 2021-04-04 - * - */ -public enum PlayerStatu { - /** - * idel - * - */ - IDEL, - /** - * preparing - * - */ - PREPARING, - /** - * prepared - * - */ - PREPARED, - /** - * play - * - */ - PLAY, - /** - * pause - * - */ - PAUSE, - /** - * stop - * - */ - STOP, - /** - * complete - * - */ - COMPLETE, - /** - * error - * - */ - ERROR, - /** - * buffering - * - */ - BUFFERING -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/factory/SourceFactory.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/factory/SourceFactory.java deleted file mode 100644 index d4358528af2029a29fab28d2454e24ca694c5bb9..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/factory/SourceFactory.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.factory; - -import ohos.app.Context; -import ohos.codelabs.video.util.LogUtil; -import ohos.global.resource.RawFileDescriptor; -import ohos.media.common.Source; - -import java.io.File; -import java.io.FileDescriptor; -import java.io.FileInputStream; -import java.io.IOException; - -/** - * SourceFactory - * - * @since 2021-04-04 - * - */ -public class SourceFactory { - private static final String TAG = "SourceFactory"; - private static final String NET_HTTP_MATCH = "http"; - private static final String NET_RTMP_MATCH = "rtmp"; - private static final String NET_RTSP_MATCH = "rtsp"; - private static final String STORAGE_MATCH = "/storage/"; - - private Source mPlayerSource; - - /** - * constructor of SourceFactory - * - * @param context context - * @param path path - */ - public SourceFactory(Context context, String path) { - try { - initSourceType(context, path); - } catch (IOException e) { - LogUtil.error(TAG, "Audio resource is unavailable: "); - } - } - - private void initSourceType(Context context, String path) throws IOException { - if (context == null || path == null) { - return; - } - if (path.substring(0, NET_HTTP_MATCH.length()).equalsIgnoreCase(NET_HTTP_MATCH) - || path.substring(0, NET_RTMP_MATCH.length()).equalsIgnoreCase(NET_RTMP_MATCH) - || path.substring(0, NET_RTSP_MATCH.length()).equalsIgnoreCase(NET_RTSP_MATCH)) { - mPlayerSource = new Source(path); - } else if (path.startsWith(STORAGE_MATCH)) { - File file = new File(path); - if (file.exists()) { - FileInputStream fileInputStream = new FileInputStream(file); - FileDescriptor fileDescriptor = fileInputStream.getFD(); - mPlayerSource = new Source(fileDescriptor); - } - } else { - RawFileDescriptor fd = context.getResourceManager().getRawFileEntry(path).openRawFileDescriptor(); - mPlayerSource = new Source(fd.getFileDescriptor(), fd.getStartPosition(), fd.getFileSize()); - } - } - - /** - * getSource - * - * @return Source Source - */ - public Source getSource() { - return mPlayerSource; - } -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/manager/GestureDetector.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/manager/GestureDetector.java deleted file mode 100644 index 089c4dd5fad9aa9e9e6fcb1d03a07e7b0c676250..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/manager/GestureDetector.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.manager; - -import ohos.agp.components.VelocityDetector; -import ohos.codelabs.video.player.constant.Constants; -import ohos.codelabs.video.player.constant.GestureConst; -import ohos.multimodalinput.event.TouchEvent; - -/** - * GestureDetector - * - * @since 2021-04-09 - */ -public class GestureDetector { - /** - * MOVING_HORIZONTAL - */ - public static final int MOVING_HORIZONTAL = 0; - /** - * MOVING_VERTICAL - */ - public static final int MOVING_VERTICAL = 1; - private int currentMoveType; - - /** - * OnGestureListener - * - * @since 2021-04-09 - */ - public interface OnGestureListener { - /** - * 开始滚动时回调 - * - * @param windowX 手指移动时x位置 - * @param windowY 手指移动时y位置 - * @return is deliver - */ - boolean onTouchBegin(float windowX, float windowY); - - /** - * 发生滚动时回调 - * - * @param direction 移动方向 0:横向 1:纵向 - * @param windowX 手指移动时x位置 - * @param windowY 手指移动时y位置 - * @param distance 移动距离 - * @return is deliver - */ - boolean onTouchMoving(int direction, float windowX, float windowY, float distance); - - /** - * 结束滚动时回调 - * - * @param direction 移动方向 0:横向 1:纵向 - * @return is deliver - */ - boolean onTouchCancel(int direction); - } - - private final OnGestureListener mListener; - - private float mLastFocusX; - private float mLastFocusY; - private float mDownFocusX; - private float mDownFocusY; - - private VelocityDetector mVelocityTracker; - - /** - * GestureDetector - * - * @param listener listener - */ - public GestureDetector(OnGestureListener listener) { - mListener = listener; - } - - /** - * onTouchEvent - * - * @param ev ev - * @return boolean - */ - public boolean onTouchEvent(TouchEvent ev) { - final int action = ev.getAction(); - addVelocityDetector(ev); - float[] points = getFocusPoint(ev); - final float focusX = points[0]; - final float focusY = points[1]; - boolean isHandled = true; - switch (action) { - case TouchEvent.OTHER_POINT_DOWN: - case TouchEvent.PRIMARY_POINT_DOWN: - currentMoveType = Constants.NUMBER_NEGATIVE_1; - mDownFocusX = 0; - mDownFocusY = 0; - mListener.onTouchBegin(focusX, focusY); - break; - case TouchEvent.POINT_MOVE: - if (mDownFocusX == 0 || mDownFocusY == 0) { - mDownFocusX = focusX; - mDownFocusY = focusY; - mLastFocusX = focusX; - mLastFocusY = focusY; - } - final int deltaX = (int) (focusX - mDownFocusX); - final int deltaY = (int) (focusY - mDownFocusY); - int distanceX = Math.abs(deltaX); - int distanceY = Math.abs(deltaY); - if (distanceX > GestureConst.getScaledTouchSlop() || distanceY > GestureConst.getScaledTouchSlop()) { - if (distanceX >= distanceY) { - currentMoveType = MOVING_HORIZONTAL; - float scrollX = mLastFocusX - focusX; - isHandled = mListener.onTouchMoving(MOVING_HORIZONTAL, focusX, focusY, scrollX); - } else { - currentMoveType = MOVING_VERTICAL; - float scrollY = mLastFocusY - focusY; - isHandled = mListener.onTouchMoving(MOVING_VERTICAL, focusX, focusY, scrollY); - } - mLastFocusX = focusX; - mLastFocusY = focusY; - } - break; - case TouchEvent.PRIMARY_POINT_UP: - case TouchEvent.OTHER_POINT_UP: - case TouchEvent.CANCEL: - isHandled = mListener.onTouchCancel(currentMoveType); - break; - default: - break; - } - return isHandled; - } - - private void addVelocityDetector(TouchEvent ev) { - if (mVelocityTracker == null) { - mVelocityTracker = VelocityDetector.obtainInstance(); - } - mVelocityTracker.addEvent(ev); - } - - private float[] getFocusPoint(TouchEvent ev) { - final boolean isPointerUp = ev.getAction() == TouchEvent.OTHER_POINT_UP; - final int skipIndex = isPointerUp ? ev.getIndex() : Constants.NUMBER_NEGATIVE_1; - float sumX = 0; - float sumY = 0; - final int count = ev.getPointerCount(); - for (int i = 0; i < count; i++) { - if (skipIndex == i) { - continue; - } - sumX += ev.getPointerPosition(i).getX(); - sumY += ev.getPointerPosition(i).getY(); - } - final int div = isPointerUp ? count - 1 : count; - float focusX = sumX / div; - float focusY = sumY / div; - return new float[]{focusX, focusY}; - } -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/manager/HmPlayerLifecycle.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/manager/HmPlayerLifecycle.java deleted file mode 100644 index aac0922ce16d03b2f32934cc685ff23e806f60bf..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/manager/HmPlayerLifecycle.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.manager; - -import ohos.codelabs.video.player.api.ImplLifecycle; -import ohos.codelabs.video.player.api.ImplPlayer; -import ohos.codelabs.video.player.constant.PlayerStatu; - -/** - * HmPlayerLifecycle - * - * @since 2021-04-09 - * - */ -public class HmPlayerLifecycle implements ImplLifecycle { - private static final String TAG = HmPlayerLifecycle.class.getSimpleName(); - private ImplPlayer mPlayer; - - /** - * HmPlayerLifecycle - * - * @param player player - */ - public HmPlayerLifecycle(ImplPlayer player) { - mPlayer = player; - } - - @Override - public void onStart() { - } - - @Override - public void onForeground() { - String url = mPlayer.getBuilder().getFilePath(); - int startMillisecond = mPlayer.getBuilder().getStartMillisecond(); - mPlayer.reload(url, startMillisecond); - } - - @Override - public void onBackground() { - mPlayer.getBuilder().setPause(mPlayer.getPlayerStatu() == PlayerStatu.PAUSE); - mPlayer.getBuilder().setStartMillisecond(mPlayer.getCurrentPosition()); - mPlayer.release(); - } - - @Override - public void onStop() { - mPlayer.release(); - } -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/util/CommonUtils.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/util/CommonUtils.java deleted file mode 100644 index d3b72f7fcfa8e82b873bc5a9c5c0ee36769b3343..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/util/CommonUtils.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.util; - -import ohos.app.Context; -import ohos.codelabs.video.player.constant.Constants; -import ohos.codelabs.video.util.LogUtil; -import ohos.global.resource.NotExistException; -import ohos.global.resource.WrongTypeException; - -import java.io.IOException; - -/** - * Common util - * - * @since 2021-04-04 - */ -public class CommonUtils { - private static final String TAG = CommonUtils.class.getSimpleName(); - - private CommonUtils() { - } - - /** - * 通过资源ID获取颜色 - * - * @param context comtext - * @param resourceId id - * @return int - */ - public static int getColor(Context context, int resourceId) { - try { - return context.getResourceManager().getElement(resourceId).getColor(); - } catch (IOException | NotExistException | WrongTypeException e) { - LogUtil.error(TAG, e.getMessage()); - } - return Constants.NUMBER_NEGATIVE_1; - } -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/util/DateUtils.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/util/DateUtils.java deleted file mode 100644 index 491c1ed67ffa5ae5634265feb01710c5838f0793..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/util/DateUtils.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.util; - -import java.util.Locale; - -/** - * Date util - * - * @since 2021-04-04 - */ -public class DateUtils { - private static final int ONE_SECONDS_MS = 1000; - private static final int ONE_MINS_MINUTES = 60; - private static final int NUMBER = 16; - private static final String TIME_FORMAT = "%02d"; - private static final String SEMICOLON = ":"; - - private DateUtils() { - } - - /** - * conversion of msToString - * - * @param ms ms - * @return string - */ - public static String msToString(int ms) { - StringBuilder sb = new StringBuilder(NUMBER); - int seconds = ms / ONE_SECONDS_MS; - int minutes = seconds / ONE_MINS_MINUTES; - if (minutes > ONE_MINS_MINUTES) { - sb.append(String.format(Locale.ENGLISH, TIME_FORMAT, minutes / ONE_MINS_MINUTES)); - sb.append(SEMICOLON); - sb.append(String.format(Locale.ENGLISH, TIME_FORMAT, minutes % ONE_MINS_MINUTES)); - sb.append(SEMICOLON); - } else { - sb.append("00:"); - sb.append(String.format(Locale.ENGLISH, TIME_FORMAT, minutes)); - sb.append(SEMICOLON); - } - - if (seconds > minutes * ONE_MINS_MINUTES) { - sb.append(String.format(Locale.ENGLISH, TIME_FORMAT, seconds - minutes * ONE_MINS_MINUTES)); - } else { - sb.append("00"); - } - return sb.toString(); - } -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/view/PlayerGestureView.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/view/PlayerGestureView.java deleted file mode 100644 index 10f5ce954487e2d01482e05b5ec7a1a94a910f3d..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/view/PlayerGestureView.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.view; - -import ohos.agp.colors.RgbColor; -import ohos.agp.components.AttrSet; -import ohos.agp.components.DirectionalLayout; -import ohos.agp.components.Image; -import ohos.agp.components.Text; -import ohos.agp.components.element.ShapeElement; -import ohos.agp.utils.Color; -import ohos.agp.utils.LayoutAlignment; -import ohos.app.Context; -import ohos.codelabs.video.ResourceTable; -import ohos.codelabs.video.player.api.ImplPlayModule; -import ohos.codelabs.video.player.api.ImplPlayer; -import ohos.codelabs.video.player.constant.Constants; -import ohos.codelabs.video.player.constant.PlayerStatu; -import ohos.codelabs.video.player.manager.GestureDetector; -import ohos.codelabs.video.player.util.CommonUtils; -import ohos.codelabs.video.player.util.DateUtils; - -/** - * PlayerGestureView - * - * @since 2021-04-04 - */ -public class PlayerGestureView extends DirectionalLayout implements ImplPlayModule, GestureDetector.OnGestureListener { - private static final int MOVING_TYPE_INIT = -1; - private static final int VOLUME_TYPE = 0; - private static final int PROGRESS_DOWN_TYPE = 1; - private static final int PROGRESS_UP_TYPE = 2; - private static final int LIGHT_BRIGHT_TYPE = 3; - private ImplPlayer player; - private int currentPercent; - private int currentMoveType; - private int beginPosition; - - private Image gestureImage; - private Text gestureText; - - /** - * constructor of PlayerGestureView - * - * @param context context - */ - public PlayerGestureView(Context context) { - this(context, null); - } - - /** - * constructor of PlayerGestureView - * - * @param context context - * @param attrSet attSet - */ - public PlayerGestureView(Context context, AttrSet attrSet) { - this(context, attrSet, null); - } - - /** - * constructor of PlayerGestureView - * - * @param context context - * @param attrSet attSet - * @param styleName styleName - */ - public PlayerGestureView(Context context, AttrSet attrSet, String styleName) { - super(context, attrSet, styleName); - initView(); - hide(); - } - - private void initView() { - ShapeElement shapeElement = new ShapeElement(); - shapeElement.setRgbColor( - RgbColor.fromArgbInt(CommonUtils.getColor(mContext, ResourceTable.Color_half_transparent))); - shapeElement.setCornerRadius(Constants.NUMBER_25); - setOrientation(DirectionalLayout.VERTICAL); - setAlignment(LayoutAlignment.HORIZONTAL_CENTER); - setBackground(shapeElement); - gestureImage = new Image(mContext); - gestureImage.setWidth(Constants.NUMBER_150); - gestureImage.setHeight(Constants.NUMBER_150); - gestureImage.setScaleMode(Image.ScaleMode.STRETCH); - gestureImage.setMarginsTopAndBottom(Constants.NUMBER_40, Constants.NUMBER_10); - gestureText = new Text(mContext); - gestureText.setTextSize(Constants.NUMBER_36); - gestureText.setTextColor(new Color(CommonUtils.getColor(mContext, ResourceTable.Color_white))); - gestureText.setMarginsTopAndBottom(Constants.NUMBER_10, Constants.NUMBER_40); - addComponent(gestureImage); - addComponent(gestureText); - } - - private void show(int type, String content) { - int gestureImg = ResourceTable.Media_ic_horns; - switch (type) { - case VOLUME_TYPE: - gestureImg = ResourceTable.Media_ic_horns; - break; - case PROGRESS_DOWN_TYPE: - gestureImg = ResourceTable.Media_ic_backward; - break; - case PROGRESS_UP_TYPE: - gestureImg = ResourceTable.Media_ic_forward; - break; - case LIGHT_BRIGHT_TYPE: - gestureImg = ResourceTable.Media_ic_bright; - break; - default: - break; - } - gestureImage.setPixelMap(gestureImg); - gestureText.setText(content); - if (getVisibility() != VISIBLE) { - setVisibility(VISIBLE); - } - } - - private void hide() { - if (getVisibility() == VISIBLE) { - setVisibility(HIDE); - } - } - - @Override - public void bind(ImplPlayer implPlayer) { - this.player = implPlayer; - this.player.addPlayerStatuCallback(statu -> { - mContext.getUITaskDispatcher().asyncDispatch(() -> { - if (statu == PlayerStatu.STOP || statu == PlayerStatu.COMPLETE) { - hide(); - } - }); - }); - } - - @Override - public void unbind() { - } - - @Override - public boolean onTouchBegin(float focusX, float focusY) { - if (player != null) { - currentPercent = 0; - currentMoveType = MOVING_TYPE_INIT; - beginPosition = player.getCurrentPosition(); - } - return true; - } - - @Override - public boolean onTouchMoving(int direction, float focusX, float focusY, float distance) { - if (currentMoveType == MOVING_TYPE_INIT) { - currentMoveType = direction; - } - if (currentMoveType == direction && player != null) { - if (currentMoveType == GestureDetector.MOVING_HORIZONTAL) { - currentPercent += distance < 0 ? Constants.NUMBER_1000 : -Constants.NUMBER_1000; - int type = currentPercent < 0 - ? PlayerGestureView.PROGRESS_DOWN_TYPE : PlayerGestureView.PROGRESS_UP_TYPE; - int value = Math.abs(currentPercent); - String content = (currentPercent < 0 ? "- " : "+ ") + DateUtils.msToString(value); - show(type, content); - } else if (currentMoveType == GestureDetector.MOVING_VERTICAL) { - int interval = getHeight() / Constants.NUMBER_2; - if (focusX <= getWidth() / Constants.NUMBER_FLOAT_2) { - show(PlayerGestureView.LIGHT_BRIGHT_TYPE, "100%"); - } else { - float volume = player.getVolume() + distance / interval; - volume = (volume < 0) ? 0 : Math.min(volume, 1); - show(PlayerGestureView.VOLUME_TYPE, (int) (volume * Constants.NUMBER_100) + "%"); - player.setVolume(volume); - } - } else { - return false; - } - } - return true; - } - - @Override - public boolean onTouchCancel(int direction) { - if (currentMoveType == GestureDetector.MOVING_HORIZONTAL && player != null) { - player.rewindTo(beginPosition + currentPercent); - } - hide(); - return true; - } -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/view/PlayerLoading.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/view/PlayerLoading.java deleted file mode 100644 index e6c65a4b5aaded8b68412f31e44073bde2709c88..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/view/PlayerLoading.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.view; - -import ohos.agp.animation.AnimatorProperty; -import ohos.agp.components.AttrSet; -import ohos.agp.components.Component; -import ohos.agp.components.Component.TouchEventListener; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.Image; -import ohos.agp.components.LayoutScatter; -import ohos.app.Context; -import ohos.codelabs.video.ResourceTable; -import ohos.codelabs.video.player.api.ImplPlayModule; -import ohos.codelabs.video.player.api.ImplPlayer; -import ohos.multimodalinput.event.TouchEvent; - -/** - * PlayerLoading - * - * @since 2021-04-04 - */ -public class PlayerLoading extends ComponentContainer implements ImplPlayModule, TouchEventListener { - private static final int HALF_NUMBER = 2; - private static final int ANIM_ROTATE = 360; - private static final int ANIM_DURATION = 2000; - private static final int ANIM_LOOPED_COUNT = -1; - private ImplPlayer mPlayer; - private Image mLoading; - private AnimatorProperty mLoadingAnim; - - /** - * constructor of PlayerLoading - * - * @param context context - */ - public PlayerLoading(Context context) { - this(context, null); - } - - /** - * constructor of PlayerLoading - * - * @param context context - * @param attrSet attSet - */ - public PlayerLoading(Context context, AttrSet attrSet) { - this(context, attrSet, null); - } - - /** - * constructor of PlayerLoading - * - * @param context context - * @param attrSet attSet - * @param styleName styleName - */ - public PlayerLoading(Context context, AttrSet attrSet, String styleName) { - super(context, attrSet, styleName); - initView(context); - } - - private void initView(Context context) { - Component loadingContainer = - LayoutScatter.getInstance(context).parse(ResourceTable.Layout_player_loading_layout, null, false); - if (loadingContainer.findComponentById(ResourceTable.Id_image_loading) instanceof Image) { - mLoading = (Image) loadingContainer.findComponentById(ResourceTable.Id_image_loading); - initAnim(); - } - addComponent(loadingContainer); - hide(); - setTouchEventListener(this); - } - - private void initAnim() { - int with = mLoading.getWidth() / HALF_NUMBER; - int height = mLoading.getHeight() / HALF_NUMBER; - mLoading.setPivotX(with); - mLoading.setPivotY(height); - mLoadingAnim = mLoading.createAnimatorProperty(); - mLoadingAnim.rotate(ANIM_ROTATE).setDuration(ANIM_DURATION).setLoopedCount(ANIM_LOOPED_COUNT); - } - - private void initListener() { - mPlayer.addPlayerStatuCallback(statu -> mContext.getUITaskDispatcher().asyncDispatch(() -> { - switch (statu) { - case PREPARING: - case BUFFERING: - show(); - break; - case PLAY: - hide(); - break; - default: - break; - } - })); - } - - /** - * show of PlayerLoading - */ - public void show() { - if (mLoadingAnim.isPaused()) { - mLoadingAnim.resume(); - } else { - mLoadingAnim.start(); - } - setVisibility(VISIBLE); - } - - /** - * hide of PlayerLoading - */ - public void hide() { - setVisibility(INVISIBLE); - mLoadingAnim.pause(); - } - - @Override - public void bind(ImplPlayer player) { - mPlayer = player; - initListener(); - } - - @Override - public void unbind() { - mLoadingAnim.release(); - } - - @Override - public boolean onTouchEvent(Component component, TouchEvent touchEvent) { - return true; - } -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/view/PlayerView.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/view/PlayerView.java deleted file mode 100644 index 7095b350a79bf3bd3286cea7fedde7af311a72ae..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/view/PlayerView.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.view; - -import ohos.agp.components.Attr; -import ohos.agp.components.AttrSet; -import ohos.agp.components.Component; -import ohos.agp.components.Component.LayoutRefreshedListener; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.DependentLayout; -import ohos.agp.components.surfaceprovider.SurfaceProvider; -import ohos.agp.graphics.Surface; -import ohos.agp.graphics.SurfaceOps; -import ohos.agp.window.service.WindowManager; -import ohos.app.Context; -import ohos.codelabs.video.player.api.ImplPlayModule; -import ohos.codelabs.video.player.api.ImplPlayer; -import ohos.codelabs.video.player.constant.Constants; -import ohos.codelabs.video.player.manager.GestureDetector; - -import java.util.Optional; - -/** - * PlayerView - * - * @since 2021-04-04 - */ -public class PlayerView extends DependentLayout implements ImplPlayModule, LayoutRefreshedListener { - private ImplPlayer player; - private SurfaceProvider surfaceView; - private Surface surface; - private PlayerGestureView gestureView; - private GestureDetector gestureDetector; - private boolean isTopPlay; - private int viewWidth; - private int viewHeight; - - /** - * constructor of PlayerView - * - * @param context context - */ - public PlayerView(Context context) { - this(context, null); - } - - /** - * constructor of PlayerView - * - * @param context context - * @param attrSet attSet - */ - public PlayerView(Context context, AttrSet attrSet) { - this(context, attrSet, null); - } - - /** - * constructor of PlayerView - * - * @param context context - * @param attrSet attSet - * @param styleName styleName - */ - public PlayerView(Context context, AttrSet attrSet, String styleName) { - super(context, attrSet, styleName); - WindowManager.getInstance().getTopWindow().get().setTransparent(true); // 不设置窗体透明会挡住播放内容,除非设置pinToZTop为true - if (attrSet != null) { - Optional optIsTopPlay = attrSet.getAttr("top_play"); - optIsTopPlay.ifPresent(attr -> isTopPlay = "true".equals(attr.getStringValue())); - } - initView(); - initListener(); - setLayoutRefreshedListener(this); - } - - private void initView() { - surfaceView = new SurfaceProvider(mContext); - DependentLayout.LayoutConfig layoutConfig = new DependentLayout.LayoutConfig(); - layoutConfig.addRule(DependentLayout.LayoutConfig.CENTER_IN_PARENT); - surfaceView.setLayoutConfig(layoutConfig); - surfaceView.pinToZTop(isTopPlay); - addComponent(surfaceView); - addGestureView(); - } - - private void addGestureView() { - gestureView = new PlayerGestureView(mContext); - DependentLayout.LayoutConfig config = - new DependentLayout.LayoutConfig(Constants.NUMBER_300, ComponentContainer.LayoutConfig.MATCH_CONTENT); - config.addRule(DependentLayout.LayoutConfig.CENTER_IN_PARENT); - gestureView.setLayoutConfig(config); - addComponent(gestureView); - } - - private void initListener() { - gestureDetector = new GestureDetector(gestureView); - surfaceView.setTouchEventListener((component, touchEvent) -> - canGesture() && gestureDetector.onTouchEvent(touchEvent)); - surfaceView.getSurfaceOps().ifPresent(surfaceOps -> surfaceOps.addCallback(new SurfaceOps.Callback() { - @Override - public void surfaceCreated(SurfaceOps surfaceOps) { - surface = surfaceOps.getSurface(); - if (player != null) { - player.addSurface(surface); - } - } - - @Override - public void surfaceChanged(SurfaceOps surfaceOps, int info, int width, int height) { - } - - @Override - public void surfaceDestroyed(SurfaceOps surfaceOps) { - } - })); - } - - private boolean canGesture() { - return gestureDetector != null - && player != null - && player.isGestureOpen(); - } - - private void updateVideoSize(double videoScale) { - if (videoScale > 1) { - surfaceView.setWidth(viewWidth); - surfaceView.setHeight((int) Math.min(viewWidth / videoScale, viewHeight)); - } else { - surfaceView.setHeight(viewHeight); - surfaceView.setWidth((int) Math.min(viewHeight * videoScale, viewWidth)); - } - } - - @Override - public void bind(ImplPlayer implPlayer) { - this.player = implPlayer; - gestureView.bind(player); - this.player.addPlayerViewCallback((width, height) -> mContext.getUITaskDispatcher().asyncDispatch(() -> { - if (width > 0) { - setWidth(width); - } - if (height > 0) { - setHeight(height); - } - })); - } - - @Override - public void unbind() { - surfaceView.removeFromWindow(); - surfaceView = null; - surface = null; - } - - @Override - public void onRefreshed(Component component) { - int newWidth = component.getWidth(); - int newHeight = component.getHeight(); - double videoScale = player.getVideoScale(); - if (videoScale != Constants.NUMBER_NEGATIVE_1 && (newWidth != viewWidth || newHeight != viewHeight)) { - viewWidth = newWidth; - viewHeight = newHeight; - mContext.getUITaskDispatcher().asyncDispatch(() -> updateVideoSize(videoScale)); - } - } -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/view/SimplePlayerController.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/view/SimplePlayerController.java deleted file mode 100644 index 29a7d2bfc50f3a48f79f2f93331cf3f43a8874c3..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/player/view/SimplePlayerController.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.player.view; - -import ohos.agp.colors.RgbColor; -import ohos.agp.components.AttrSet; -import ohos.agp.components.Component; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.DependentLayout; -import ohos.agp.components.DirectionalLayout; -import ohos.agp.components.Image; -import ohos.agp.components.LayoutScatter; -import ohos.agp.components.Slider; -import ohos.agp.components.Text; -import ohos.agp.components.element.ShapeElement; -import ohos.app.Context; -import ohos.codelabs.video.ResourceTable; -import ohos.codelabs.video.player.api.ImplPlayModule; -import ohos.codelabs.video.player.api.ImplPlayer; -import ohos.codelabs.video.player.api.StatuChangeListener; -import ohos.codelabs.video.player.constant.Constants; -import ohos.codelabs.video.player.constant.PlayerStatu; -import ohos.codelabs.video.player.util.DateUtils; -import ohos.eventhandler.EventHandler; -import ohos.eventhandler.EventRunner; -import ohos.eventhandler.InnerEvent; - -/** - * PlayerController - * - * @since 2021-04-04 - */ -public class SimplePlayerController extends ComponentContainer implements ImplPlayModule { - private static final int THUMB_RED = 255; - private static final int THUMB_GREEN = 255; - private static final int THUMB_BLUE = 240; - private static final int THUMB_WIDTH = 40; - private static final int THUMB_HEIGHT = 40; - private static final int THUMB_RADIUS = 20; - private static final int CONTROLLER_HIDE_DLEY_TIME = 5000; - private static final int PROGRESS_RUNNING_TIME = 1000; - private boolean mIsDragMode = false; - private ImplPlayer mPlayer; - private DependentLayout topLayout; - private DirectionalLayout bottomLayout; - private Image mBack; - private Image mPlayToogle; - private Image mForward; - private Image mBackward; - private Slider mProgressBar; - private Text mCurrentTime; - private Text mTotleTime; - private ControllerHandler mHandler; - private StatuChangeListener mStatuChangeListener = new StatuChangeListener() { - @Override - public void statuCallback(PlayerStatu statu) { - mContext.getUITaskDispatcher().asyncDispatch(() -> { - switch (statu) { - case PREPARING: - mPlayToogle.setClickable(false); - mProgressBar.setEnabled(false); - mProgressBar.setProgressValue(0); - break; - case PREPARED: - mProgressBar.setMaxValue(mPlayer.getDuration()); - mTotleTime.setText(DateUtils.msToString(mPlayer.getDuration())); - break; - case PLAY: - showController(false); - mPlayToogle.setPixelMap(ResourceTable.Media_ic_music_stop); - mPlayToogle.setClickable(true); - mProgressBar.setEnabled(true); - break; - case PAUSE: - mPlayToogle.setPixelMap(ResourceTable.Media_ic_music_play); - break; - case STOP: - case COMPLETE: - mPlayToogle.setPixelMap(ResourceTable.Media_ic_update); - mProgressBar.setEnabled(false); - break; - default: - break; - } - }); - } - }; - - /** - * constructor of SimplePlayerController - * - * @param context context - */ - public SimplePlayerController(Context context) { - this(context, null); - } - - /** - * constructor of SimplePlayerController - * - * @param context context - * @param attrSet attSet - */ - public SimplePlayerController(Context context, AttrSet attrSet) { - this(context, attrSet, null); - } - - /** - * constructor of SimplePlayerController - * - * @param context context - * @param attrSet attSet - * @param styleName styleName - */ - public SimplePlayerController(Context context, AttrSet attrSet, String styleName) { - super(context, attrSet, styleName); - createHandler(); - initView(); - initListener(); - } - - private void createHandler() { - EventRunner runner = EventRunner.create(true); - if (runner == null) { - return; - } - mHandler = new ControllerHandler(runner); - } - - private void initView() { - Component playerController = - LayoutScatter.getInstance(mContext) - .parse(ResourceTable.Layout_simple_player_controller_layout, null, false); - addComponent(playerController); - if (playerController.findComponentById(ResourceTable.Id_controller_top_layout) instanceof DependentLayout) { - topLayout = (DependentLayout) playerController.findComponentById(ResourceTable.Id_controller_top_layout); - } - if (playerController.findComponentById(ResourceTable.Id_controller_bottom_layout) - instanceof DirectionalLayout) { - bottomLayout = (DirectionalLayout) playerController - .findComponentById(ResourceTable.Id_controller_bottom_layout); - } - if (playerController.findComponentById(ResourceTable.Id_back) instanceof Image) { - mBack = (Image) playerController.findComponentById(ResourceTable.Id_back); - } - if (playerController.findComponentById(ResourceTable.Id_play_controller) instanceof Image) { - mPlayToogle = (Image) playerController.findComponentById(ResourceTable.Id_play_controller); - } - if (playerController.findComponentById(ResourceTable.Id_play_forward) instanceof Image) { - mForward = (Image) playerController.findComponentById(ResourceTable.Id_play_forward); - } - if (playerController.findComponentById(ResourceTable.Id_play_backward) instanceof Image) { - mBackward = (Image) playerController.findComponentById(ResourceTable.Id_play_backward); - } - if (playerController.findComponentById(ResourceTable.Id_progress) instanceof Slider) { - mProgressBar = (Slider) playerController.findComponentById(ResourceTable.Id_progress); - } - ShapeElement shapeElement = new ShapeElement(); - shapeElement.setRgbColor(new RgbColor(THUMB_RED, THUMB_GREEN, THUMB_BLUE)); - shapeElement.setBounds(0, 0, THUMB_WIDTH, THUMB_HEIGHT); - shapeElement.setCornerRadius(THUMB_RADIUS); - mProgressBar.setThumbElement(shapeElement); - if (playerController.findComponentById(ResourceTable.Id_current_time) instanceof Text) { - mCurrentTime = (Text) playerController.findComponentById(ResourceTable.Id_current_time); - } - if (playerController.findComponentById(ResourceTable.Id_end_time) instanceof Text) { - mTotleTime = (Text) playerController.findComponentById(ResourceTable.Id_end_time); - } - } - - private void initListener() { - topLayout.setTouchEventListener((component, touchEvent) -> true); - bottomLayout.setTouchEventListener((component, touchEvent) -> true); - mBack.setClickedListener(component -> mContext.terminateAbility()); - } - - private void initPlayListener() { - mPlayer.addPlayerStatuCallback(mStatuChangeListener); - mPlayToogle.setClickedListener(component -> { - if (mPlayer.isPlaying()) { - mPlayer.pause(); - } else { - if (mPlayer.getPlayerStatu() == PlayerStatu.STOP) { - mPlayer.replay(); - } else { - mPlayer.resume(); - } - } - }); - mForward.setClickedListener(component -> - mPlayer.rewindTo(getBasicTransTime(mPlayer.getCurrentPosition()) + Constants.REWIND_STEP)); - mBackward.setClickedListener(component -> - mPlayer.rewindTo(getBasicTransTime(mPlayer.getCurrentPosition()) - Constants.REWIND_STEP)); - mProgressBar.setValueChangedListener( - new Slider.ValueChangedListener() { - @Override - public void onProgressUpdated(Slider slider, int value, boolean isB) { - mContext.getUITaskDispatcher().asyncDispatch(() -> - mCurrentTime.setText(DateUtils.msToString(value))); - } - - @Override - public void onTouchStart(Slider slider) { - mIsDragMode = true; - mHandler.removeEvent(Constants.PLAYER_PROGRESS_RUNNING, EventHandler.Priority.IMMEDIATE); - } - - @Override - public void onTouchEnd(Slider slider) { - mIsDragMode = false; - if (slider.getProgress() == mPlayer.getDuration()) { - mPlayer.stop(); - } else { - mPlayer.rewindTo(getBasicTransTime(slider.getProgress())); - } - } - }); - } - - private int getBasicTransTime(int currentTime) { - return currentTime / PROGRESS_RUNNING_TIME * PROGRESS_RUNNING_TIME; - } - - /** - * showController of PlayerController - * - * @param isAutoHide isAutoHide - */ - public void showController(boolean isAutoHide) { - mHandler.sendEvent(Constants.PLAYER_CONTROLLER_SHOW, EventHandler.Priority.HIGH); - if (isAutoHide) { - hideController(CONTROLLER_HIDE_DLEY_TIME); - } else { - mHandler.removeEvent(Constants.PLAYER_CONTROLLER_HIDE); - } - } - - /** - * hideController of PlayerController - * - * @param delay delay - */ - public void hideController(int delay) { - mHandler.removeEvent(Constants.PLAYER_CONTROLLER_HIDE); - mHandler.sendEvent(Constants.PLAYER_CONTROLLER_HIDE, delay, EventHandler.Priority.HIGH); - } - - @Override - public void bind(ImplPlayer player) { - mPlayer = player; - initPlayListener(); - } - - @Override - public void unbind() { - mHandler.removeAllEvent(); - mHandler = null; - } - - /** - * ControllerHandler - * - * @author chenweiquan - * @since 2020-12-04 - */ - private class ControllerHandler extends EventHandler { - private int currentPosition; - - private ControllerHandler(EventRunner runner) { - super(runner); - } - - @Override - public void processEvent(InnerEvent event) { - super.processEvent(event); - if (event == null) { - return; - } - switch (event.eventId) { - case Constants.PLAYER_PROGRESS_RUNNING: - if (mPlayer != null && mPlayer.isPlaying() && !mIsDragMode) { - currentPosition = mPlayer.getCurrentPosition(); - while (currentPosition < PROGRESS_RUNNING_TIME) { - currentPosition = mPlayer.getCurrentPosition(); - } - mContext.getUITaskDispatcher().asyncDispatch(() -> { - mProgressBar.setProgressValue(currentPosition); - mCurrentTime.setText(DateUtils.msToString(currentPosition)); - }); - mHandler.sendEvent( - Constants.PLAYER_PROGRESS_RUNNING, PROGRESS_RUNNING_TIME, Priority.HIGH); - } - break; - case Constants.PLAYER_CONTROLLER_HIDE: - mContext.getUITaskDispatcher().asyncDispatch(() -> setVisibility(INVISIBLE)); - mHandler.removeEvent(Constants.PLAYER_PROGRESS_RUNNING); - break; - case Constants.PLAYER_CONTROLLER_SHOW: - mHandler.removeEvent(Constants.PLAYER_PROGRESS_RUNNING); - mHandler.sendEvent(Constants.PLAYER_PROGRESS_RUNNING, Priority.IMMEDIATE); - mContext.getUITaskDispatcher().asyncDispatch(() -> { - if (getVisibility() != VISIBLE) { - setVisibility(VISIBLE); - } - }); - break; - default: - break; - } - } - } -} \ No newline at end of file diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/slice/SimplePlayerAbilitySlice.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/slice/SimplePlayerAbilitySlice.java deleted file mode 100644 index a639460e477db178ffd66937ee3bc3fc7e8d6494..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/slice/SimplePlayerAbilitySlice.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.slice; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.agp.components.DependentLayout; -import ohos.app.dispatcher.task.TaskPriority; -import ohos.bundle.AbilityInfo; -import ohos.codelabs.video.ResourceTable; -import ohos.codelabs.video.player.HmPlayer; -import ohos.codelabs.video.player.api.ImplPlayer; -import ohos.codelabs.video.player.constant.Constants; -import ohos.codelabs.video.player.view.PlayerLoading; -import ohos.codelabs.video.player.view.PlayerView; -import ohos.codelabs.video.player.view.SimplePlayerController; -import ohos.codelabs.video.util.LogUtil; -import ohos.codelabs.video.util.ScreenUtils; - -/** - * SimplePlayerAbilitySlice - * - * @since 2021-04-04 - */ -public class SimplePlayerAbilitySlice extends AbilitySlice { - private static final String TAG = SimplePlayerAbilitySlice.class.getSimpleName(); - private ImplPlayer player; - private DependentLayout parentLayout; - private PlayerView playerView; - private PlayerLoading loadingView; - private SimplePlayerController controllerView; - private String url = "entry/resources/base/media/gubeishuizhen.mp4"; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setUIContent(ResourceTable.Layout_simple_video_play_layout); - player = new HmPlayer.Builder(this).setFilePath(url).create(); - player.getLifecycle().onStart(); - initComponent(); - } - - private void initComponent() { - if (findComponentById(ResourceTable.Id_parent) instanceof DependentLayout) { - parentLayout = (DependentLayout) findComponentById(ResourceTable.Id_parent); - } - if (findComponentById(ResourceTable.Id_player_view) instanceof PlayerView) { - playerView = (PlayerView) findComponentById(ResourceTable.Id_player_view); - } - if (findComponentById(ResourceTable.Id_loading_view) instanceof PlayerLoading) { - loadingView = (PlayerLoading) findComponentById(ResourceTable.Id_loading_view); - } - if (findComponentById(ResourceTable.Id_controller_view) instanceof SimplePlayerController) { - controllerView = (SimplePlayerController) findComponentById(ResourceTable.Id_controller_view); - } - playerView.bind(player); - loadingView.bind(player); - controllerView.bind(player); - } - - @Override - protected void onOrientationChanged(AbilityInfo.DisplayOrientation displayOrientation) { - super.onOrientationChanged(displayOrientation); - int screenWidth = ScreenUtils.getScreenWidth(this); - parentLayout.setWidth(screenWidth); - player.openGesture(displayOrientation == AbilityInfo.DisplayOrientation.LANDSCAPE); - } - - @Override - public void onActive() { - super.onActive(); - getGlobalTaskDispatcher(TaskPriority.DEFAULT).delayDispatch(() -> player.play(), Constants.NUMBER_1000); - } - - @Override - public void onForeground(Intent intent) { - player.getLifecycle().onForeground(); - super.onForeground(intent); - } - - @Override - protected void onBackground() { - LogUtil.info(TAG, "onBackground is called"); - player.getLifecycle().onBackground(); - super.onBackground(); - } - - @Override - protected void onStop() { - LogUtil.info(TAG, "onStop is called"); - loadingView.unbind(); - controllerView.unbind(); - playerView.unbind(); - player.getLifecycle().onStop(); - super.onStop(); - } -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/util/LogUtil.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/util/LogUtil.java deleted file mode 100644 index 7ed5dfff3045708c63876e70e478fe34b0314976..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/util/LogUtil.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.util; - -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; - -/** - * Log util - * - * @since 2021-04-04 - */ -public class LogUtil { - private static final String TAG_LOG = "LogUtil"; - - private static final HiLogLabel LABEL_LOG = new HiLogLabel(0, 0, LogUtil.TAG_LOG); - - private static final String LOG_FORMAT = "%{public}s: %{public}s"; - - private LogUtil() { - } - - /** - * Print debug log - * - * @param tag log tag - * @param msg log message - */ - public static void debug(String tag, String msg) { - HiLog.debug(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print info log - * - * @param tag log tag - * @param msg log message - */ - public static void info(String tag, String msg) { - HiLog.info(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print error log - * - * @param tag log tag - * @param msg log message - */ - public static void error(String tag, String msg) { - HiLog.error(LABEL_LOG, LOG_FORMAT, tag, msg); - } -} diff --git a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/util/ScreenUtils.java b/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/util/ScreenUtils.java deleted file mode 100644 index 57d74942bf7bb0051fdcf9af665392e36700df62..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/java/ohos/codelabs/video/util/ScreenUtils.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ohos.codelabs.video.util; - -import ohos.agp.utils.Point; -import ohos.agp.window.service.Display; -import ohos.agp.window.service.DisplayManager; -import ohos.app.Context; -import ohos.global.configuration.DeviceCapability; - -import java.util.Optional; - -/** - * Screen util - * - * @since 2021-04-04 - */ -public class ScreenUtils { - private ScreenUtils() { - } - - /** - * getScreenHeight - * - * @param context context - * @return Screen Height - */ - public static int getScreenHeight(Context context) { - DisplayManager displayManager = DisplayManager.getInstance(); - Optional optDisplay = displayManager.getDefaultDisplay(context); - Point point = new Point(0, 0); - if (!optDisplay.isPresent()) { - return (int) point.position[1]; - } else { - Display display = optDisplay.get(); - display.getSize(point); - return (int) point.position[1]; - } - } - - /** - * getScreenWidth - * - * @param context context - * @return Screen Width - */ - public static int getScreenWidth(Context context) { - DisplayManager displayManager = DisplayManager.getInstance(); - Optional optDisplay = displayManager.getDefaultDisplay(context); - Point point = new Point(0, 0); - if (!optDisplay.isPresent()) { - return (int) point.position[0]; - } else { - Display display = optDisplay.get(); - display.getSize(point); - return (int) point.position[0]; - } - } - - /** - * dp2px - * - * @param context context - * @param size size - * @return int - */ - public static int dp2px(Context context, int size) { - int density = context.getResourceManager().getDeviceCapability().screenDensity / DeviceCapability.SCREEN_MDPI; - return size * density; - } - - /** - * px2dip - * - * @param context context - * @param size size - * @return int - */ - public static int px2dip(Context context, int size) { - int density = context.getResourceManager().getDeviceCapability().screenDensity / DeviceCapability.SCREEN_MDPI; - return size / density; - } -} diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/element/colors.json b/SimpleVideoCodelab/entry/src/main/resources/base/element/colors.json deleted file mode 100644 index 2ee40bdd48dd9e9add158d97f9efcea24ce975f8..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/resources/base/element/colors.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "color": [ - { - "name": "news_type_text_off", - "value": "#55000000" - }, - { - "name": "news_type_text_on", - "value": "#afaafa" - }, - { - "name": "white", - "value": "#ffffff" - }, - { - "name": "half_transparent", - "value": "#55000000" - } - ] -} \ No newline at end of file diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/element/string.json b/SimpleVideoCodelab/entry/src/main/resources/base/element/string.json deleted file mode 100644 index 80dc28cacfebf2757525f7574a186850fd3451cf..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "video" - }, - { - "name": "mainability_description", - "value": "hap sample empty page" - }, - { - "name": "videodetailabilityslice_description", - "value": "hap sample empty service" - } - ] -} \ No newline at end of file diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/layout/player_loading_layout.xml b/SimpleVideoCodelab/entry/src/main/resources/base/layout/player_loading_layout.xml deleted file mode 100644 index 498983f3b231656b23c998c91707e1882e589155..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/resources/base/layout/player_loading_layout.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/layout/simple_player_controller_layout.xml b/SimpleVideoCodelab/entry/src/main/resources/base/layout/simple_player_controller_layout.xml deleted file mode 100644 index 1d33a35b764ef501a149a3e03003532362f13376..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/resources/base/layout/simple_player_controller_layout.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/layout/simple_video_play_layout.xml b/SimpleVideoCodelab/entry/src/main/resources/base/layout/simple_video_play_layout.xml deleted file mode 100644 index 069f9aa57d63d67f33794eb1053f76235b6bee20..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/entry/src/main/resources/base/layout/simple_video_play_layout.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/media/gubeishuizhen.mp4 b/SimpleVideoCodelab/entry/src/main/resources/base/media/gubeishuizhen.mp4 deleted file mode 100644 index e34d0d9f9dcbc724142de146a3537d756a21e267..0000000000000000000000000000000000000000 Binary files a/SimpleVideoCodelab/entry/src/main/resources/base/media/gubeishuizhen.mp4 and /dev/null differ diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_back.png b/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_back.png deleted file mode 100644 index 392306cdb9171897c6ca7fec1216b6fa7099c2d0..0000000000000000000000000000000000000000 Binary files a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_back.png and /dev/null differ diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_backward.png b/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_backward.png deleted file mode 100644 index 2696217ec5156e83b88adf46d87d4c5bfd328075..0000000000000000000000000000000000000000 Binary files a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_backward.png and /dev/null differ diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_bright.png b/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_bright.png deleted file mode 100644 index e1ea29d98fa6edc34951519a4cccaf03ad2ffcc5..0000000000000000000000000000000000000000 Binary files a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_bright.png and /dev/null differ diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_forward.png b/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_forward.png deleted file mode 100644 index b52b99f1c209870d3c4a9b083b767eac2209bec8..0000000000000000000000000000000000000000 Binary files a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_forward.png and /dev/null differ diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_horns.png b/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_horns.png deleted file mode 100644 index ee0de06494813d36e55aeb9a557bffdd3e755432..0000000000000000000000000000000000000000 Binary files a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_horns.png and /dev/null differ diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_loading.png b/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_loading.png deleted file mode 100644 index a3c061f5b4753fbd669792b8992dc0cfb9122d19..0000000000000000000000000000000000000000 Binary files a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_loading.png and /dev/null differ diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_music_play.png b/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_music_play.png deleted file mode 100644 index 818369b1f29c3451ff7616ba3ca12c8fc2c2cfe4..0000000000000000000000000000000000000000 Binary files a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_music_play.png and /dev/null differ diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_music_stop.png b/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_music_stop.png deleted file mode 100644 index 211e4757a0aa24bc9256fca076d7d998b60e10dd..0000000000000000000000000000000000000000 Binary files a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_music_stop.png and /dev/null differ diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_tv.png b/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_tv.png deleted file mode 100644 index 5374896a7f2c49f59b8e4445dda96790e3033e59..0000000000000000000000000000000000000000 Binary files a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_tv.png and /dev/null differ diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_update.png b/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_update.png deleted file mode 100644 index 1b63a318d863b5b236da9c83f616334b702dde82..0000000000000000000000000000000000000000 Binary files a/SimpleVideoCodelab/entry/src/main/resources/base/media/ic_update.png and /dev/null differ diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/media/icon.png b/SimpleVideoCodelab/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index 837f49939adc60074c347d70fa4184953a7ac8cc..0000000000000000000000000000000000000000 Binary files a/SimpleVideoCodelab/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/SimpleVideoCodelab/entry/src/main/resources/base/media/preview_corner.png b/SimpleVideoCodelab/entry/src/main/resources/base/media/preview_corner.png deleted file mode 100644 index aa3bc86b67505800164dc1f93d79ed451e42cfdd..0000000000000000000000000000000000000000 Binary files a/SimpleVideoCodelab/entry/src/main/resources/base/media/preview_corner.png and /dev/null differ diff --git a/SimpleVideoCodelab/gradle/wrapper/gradle-wrapper.jar b/SimpleVideoCodelab/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f6b961fd5a86aa5fbfe90f707c3138408be7c718..0000000000000000000000000000000000000000 Binary files a/SimpleVideoCodelab/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/SimpleVideoCodelab/gradle/wrapper/gradle-wrapper.properties b/SimpleVideoCodelab/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index bf127d05e72e6d10a23778bd97ee29ac8c849bba..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists \ No newline at end of file diff --git a/SimpleVideoCodelab/settings.gradle b/SimpleVideoCodelab/settings.gradle deleted file mode 100644 index 4773db73233a570c2d0c01a22e75321acfbf7a07..0000000000000000000000000000000000000000 --- a/SimpleVideoCodelab/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':entry' diff --git a/InputApplication/build.gradle b/SliderApplication/build.gradle similarity index 80% rename from InputApplication/build.gradle rename to SliderApplication/build.gradle index ffb7d0b2406a4957aad77fd38996e79c00dccab6..9cf74c205fc884ae2c6796ce2298ecbe3f40672d 100644 --- a/InputApplication/build.gradle +++ b/SliderApplication/build.gradle @@ -3,10 +3,7 @@ apply plugin: 'com.huawei.ohos.app' //For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 5 - } + compileSdkVersion 6 } buildscript { @@ -19,8 +16,8 @@ buildscript { } } dependencies { - classpath 'com.huawei.ohos:hap:2.4.5.0' - classpath 'com.huawei.ohos:decctest:1.2.4.1' + classpath 'com.huawei.ohos:hap:2.4.5.5' + classpath 'com.huawei.ohos:decctest:1.2.5.1' } } diff --git a/DistributeDatabaseDraw-master/entry/.gitignore b/SliderApplication/entry/.gitignore similarity index 33% rename from DistributeDatabaseDraw-master/entry/.gitignore rename to SliderApplication/entry/.gitignore index 796b96d1c402326528b4ba3c12ee9d92d0e212e9..7d5b7a94f4dcf381f03ff21f28f8a2494b58023f 100644 --- a/DistributeDatabaseDraw-master/entry/.gitignore +++ b/SliderApplication/entry/.gitignore @@ -1 +1,2 @@ /build +/node_modules diff --git a/DialogDemo/entry/build.gradle b/SliderApplication/entry/build.gradle similarity index 72% rename from DialogDemo/entry/build.gradle rename to SliderApplication/entry/build.gradle index 6618a979327905114e1a5efa61aca8805144d664..cccb71cae91018743841ab76aeb19c595f4ed847 100644 --- a/DialogDemo/entry/build.gradle +++ b/SliderApplication/entry/build.gradle @@ -1,10 +1,9 @@ apply plugin: 'com.huawei.ohos.hap' -apply plugin: 'com.huawei.ohos.decctest' //For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 ohos { - compileSdkVersion 5 + compileSdkVersion 6 defaultConfig { - compatibleSdkVersion 4 + compatibleSdkVersion 6 } buildTypes { release { @@ -14,13 +13,11 @@ ohos { } } } + + supportSystem "standard" } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) testImplementation 'junit:junit:4.13' - ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.200' -} -decc { - supportType = ['html', 'xml'] } diff --git a/ShoppingJs/entry/package.json b/SliderApplication/entry/package.json similarity index 100% rename from ShoppingJs/entry/package.json rename to SliderApplication/entry/package.json diff --git a/DistributedMapDemo/tinymap/proguard-rules.pro b/SliderApplication/entry/proguard-rules.pro similarity index 100% rename from DistributedMapDemo/tinymap/proguard-rules.pro rename to SliderApplication/entry/proguard-rules.pro diff --git a/ToolbarApplication/entry/src/main/config.json b/SliderApplication/entry/src/main/config.json similarity index 79% rename from ToolbarApplication/entry/src/main/config.json rename to SliderApplication/entry/src/main/config.json index 251d271536fa4d876b012355a68b2d0d4ba9ba13..ca42a324bbcfb3af649bcc9770deeaf300c88950 100644 --- a/ToolbarApplication/entry/src/main/config.json +++ b/SliderApplication/entry/src/main/config.json @@ -9,9 +9,9 @@ }, "deviceConfig": {}, "module": { - "package": "com.huawei.cookbook", + "package": "com.huawei.sliderapplication", "name": ".MyApplication", - "mainAbility": "com.huawei.cookbook.MainAbility", + "mainAbility": "com.huawei.sliderapplication.MainAbility", "deviceType": [ "phone" ], @@ -33,9 +33,11 @@ ] } ], - "name": "com.huawei.cookbook.MainAbility", + "orientation": "unspecified", + "name": "com.huawei.sliderapplication.MainAbility", "icon": "$media:icon", "description": "$string:mainability_description", + "formsEnabled": false, "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" @@ -49,7 +51,7 @@ "name": "default", "window": { "designWidth": 720, - "autoDesignWidth": true + "autoDesignWidth": false } } ] diff --git a/ClickableImageJsDemo/entry/src/main/js/default/app.js b/SliderApplication/entry/src/main/js/default/app.js similarity index 40% rename from ClickableImageJsDemo/entry/src/main/js/default/app.js rename to SliderApplication/entry/src/main/js/default/app.js index aedcefe0054c6e16c40491f4d1abc20a4dc1c6ef..6d060ffe5682c19fc83e2274a9e62cbc40a655f8 100644 --- a/ClickableImageJsDemo/entry/src/main/js/default/app.js +++ b/SliderApplication/entry/src/main/js/default/app.js @@ -1,8 +1,8 @@ export default { onCreate() { - console.info('AceApplication onCreate'); + console.info("Application onCreate"); }, onDestroy() { - console.info('AceApplication onDestroy'); + console.info("Application onDestroy"); } }; diff --git a/InputApplication/entry/src/main/js/default/common/images/Wallpaper.png b/SliderApplication/entry/src/main/js/default/common/images/Wallpaper.png similarity index 100% rename from InputApplication/entry/src/main/js/default/common/images/Wallpaper.png rename to SliderApplication/entry/src/main/js/default/common/images/Wallpaper.png diff --git a/InputApplication/entry/src/main/js/default/common/images/bg-tv.jpg b/SliderApplication/entry/src/main/js/default/common/images/bg-tv.jpg similarity index 100% rename from InputApplication/entry/src/main/js/default/common/images/bg-tv.jpg rename to SliderApplication/entry/src/main/js/default/common/images/bg-tv.jpg diff --git a/SliderApplication/entry/src/main/js/default/common/images/windmill.png b/SliderApplication/entry/src/main/js/default/common/images/windmill.png new file mode 100644 index 0000000000000000000000000000000000000000..e15bda0300116d97dcdc730cee92b86457666777 Binary files /dev/null and b/SliderApplication/entry/src/main/js/default/common/images/windmill.png differ diff --git a/ClickableImageJsDemo/entry/src/ohosTest/js/default/i18n/en-US.json b/SliderApplication/entry/src/main/js/default/i18n/en-US.json similarity index 40% rename from ClickableImageJsDemo/entry/src/ohosTest/js/default/i18n/en-US.json rename to SliderApplication/entry/src/main/js/default/i18n/en-US.json index 55561b83737c3c31d082fbfa11e5fc987a351104..08e34eac912bf2651eefc20e26aa479b5e4e7ec2 100644 --- a/ClickableImageJsDemo/entry/src/ohosTest/js/default/i18n/en-US.json +++ b/SliderApplication/entry/src/main/js/default/i18n/en-US.json @@ -1,7 +1,10 @@ { "strings": { "hello": "Hello", - "world": "World" + "world": "World", + "page": "Second Page", + "next": "Next Page", + "back": "Back" }, "Files": { } diff --git a/InputApplication/entry/src/ohosTest/js/default/i18n/zh-CN.json b/SliderApplication/entry/src/main/js/default/i18n/zh-CN.json similarity index 40% rename from InputApplication/entry/src/ohosTest/js/default/i18n/zh-CN.json rename to SliderApplication/entry/src/main/js/default/i18n/zh-CN.json index cce1af06761a42add0cac1a0567aa3237eda8cb4..3dd53b3a8b808aec9396fa663cb00ef22ba61e0a 100644 --- a/InputApplication/entry/src/ohosTest/js/default/i18n/zh-CN.json +++ b/SliderApplication/entry/src/main/js/default/i18n/zh-CN.json @@ -1,7 +1,10 @@ { "strings": { "hello": "您好", - "world": "世界" + "world": "世界", + "page": "第二页", + "next": "下一页", + "back": "返回" }, "Files": { } diff --git a/SliderApplication/entry/src/main/js/default/pages/index/index.css b/SliderApplication/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..29c0dd95d61bb8644fd61a2e5fa10640332bf8a0 --- /dev/null +++ b/SliderApplication/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,44 @@ +/* 页面整体纵向布局 */ +.container { + flex-direction: column; +} +/* 图片区域布局 */ +.image-block { + height: 50%; + justify-content: center; + align-items: center; +} +/* 图片布局 */ +image { + width: 100px; + height: 100px; + animation-name: Go; + animation-iteration-count: infinite; + animation-timing-function: linear; +} +/* 图片旋转角度:0到360° */ +@keyframes Go +{ + from { + transform:rotate(0deg); + } + to { + transform:rotate(360deg); + } +} +/* 进度条区域布局 */ +.slider-block { + height: 50%; + justify-content: center; + align-items: center; + flex-direction: column; +} +/* 进度条布局 */ +slider { + margin-bottom: 20px; +} +/* 文字布局 */ +text { + margin-bottom: 10px; + font-size: 20px; +} diff --git a/SliderApplication/entry/src/main/js/default/pages/index/index.hml b/SliderApplication/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..439b7602de6c3fea01e12967d9d1e27099a7e9ad --- /dev/null +++ b/SliderApplication/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,15 @@ +
+
+ +
+
+ + 速度:{{speed}} + + + + 缩放比例:{{imageSize}} + + +
+
diff --git a/SliderApplication/entry/src/main/js/default/pages/index/index.js b/SliderApplication/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..84e13d6ba9e6771871bd6fd34d927bd64a4d473f --- /dev/null +++ b/SliderApplication/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,29 @@ +export default { + data: { + imgUrl: '/common/images/windmill.png', + animationDuration: '5000ms', + animationDurationNum: 5000, + speed: 50, + minSpeed: 0, + maxSpeed: 100, + imageSize: 1, + size: 50, + minSize: 0, + maxSize: 100 + }, + // 改变转速 + changeValue(e) { + if (e.mode === 'end' || e.mode === 'click') { + this.speed = e.value; + this.animationDurationNum = 10000 - e.value * 95; + this.animationDuration = this.animationDurationNum + 'ms'; + } + }, + // 改变大小 + changeSize(e) { + if (e.mode === 'end' || e.mode === 'click') { + this.size = e.value; + this.imageSize = this.size / 50 < 0.1 ? 0.1 : this.size / 50; + } + } +}; diff --git a/VideoApplication/entry/src/main/resources/base/element/string.json b/SliderApplication/entry/src/main/resources/base/element/string.json similarity index 100% rename from VideoApplication/entry/src/main/resources/base/element/string.json rename to SliderApplication/entry/src/main/resources/base/element/string.json diff --git a/ClickableImageJsDemo/entry/src/ohosTest/resources/base/media/icon.png b/SliderApplication/entry/src/main/resources/base/media/icon.png similarity index 100% rename from ClickableImageJsDemo/entry/src/ohosTest/resources/base/media/icon.png rename to SliderApplication/entry/src/main/resources/base/media/icon.png diff --git a/ClockFACardDemo/gradle/wrapper/gradle-wrapper.jar b/SliderApplication/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from ClockFACardDemo/gradle/wrapper/gradle-wrapper.jar rename to SliderApplication/gradle/wrapper/gradle-wrapper.jar diff --git a/ClockFACardDemo/gradle/wrapper/gradle-wrapper.properties b/SliderApplication/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from ClockFACardDemo/gradle/wrapper/gradle-wrapper.properties rename to SliderApplication/gradle/wrapper/gradle-wrapper.properties diff --git a/CodecDemo/settings.gradle b/SliderApplication/settings.gradle similarity index 100% rename from CodecDemo/settings.gradle rename to SliderApplication/settings.gradle diff --git a/StepsCard/LICENSE b/StepsCard/LICENSE deleted file mode 100644 index 80576ef141485b36eea4aebf25af97020bc2de44..0000000000000000000000000000000000000000 --- a/StepsCard/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - Copyright (c) 2021 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/StepsCard/README.md b/StepsCard/README.md deleted file mode 100644 index 1961de4c89d9e0958c77e339ac81a061fc26c10e..0000000000000000000000000000000000000000 --- a/StepsCard/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# StepsCard - -简介 • 本cookbook旨在使开发人员了解HarmonyOS中JS卡片的开发,包含卡片的创建、更新、删除功能,以文字的方式展了现用户当日行走的步数及路程,以进度条的方式展现了用户完成目标步数的进度,以线形图的方式展现了用户近四天的行走的步数统计,并实现了随着用户行走而更新卡片数据的效果。 - -安装要求 -• 安装DevEco Studio -• 设置DevEco Studio开发环境。DevEco Studio开发环境需要连接到网络,以确保该正常使用。可以根据以下两种情况配置开发环境: - 1.如果您可以直接访问Internet,则只需下载HarmonyOS SDK - 2.如果网络无法直接访问Internet,则可以通过代理服务器进行访问 -• 生成密钥并申请证书 - -用户指南 -• 下载此项目 -• 打开HUAWEI DevEco Studio,单击File> Open选择此StepsCard -• 单击Build> Build App(s)/Hap(s)>Build Debug Hap(s)以编译hap软件包 -• 单击Run> Run 'entry'以运行hap包 - -注意 -• 您可以选择在模拟器或真机上运行hap软件包。 -• 如果在真机上运行它,则需要在项目的File> Project Structure> Modules> Signing Configs中配置签名和证书信息。 -• 由于目前暂无办法保证卡片服务不被系统销毁,需要通过手机管家> 应用启动管理> 计步器服务卡片> 点击右侧滑块> 选择开启“允许后台活动”开启后台运行权限,如需要也可开启“运行自启动”。 - - -许可 -请参阅LICENSE文件以获得更多信息。 - -What is it? -This cookbook is designed to enable developers to understand the development of JS cards in HarmonyOS, including card creation, update, and deletion functions. It displays the number of steps and distances that users have walked on the day in text mode, and displays the progress of users completing the target steps in a progress bar. A line chart is used to display the step count statistics of the user in the last four days, and the card data is updated as the user walks. - -Installation requirements -• Install DevEco Studio -• Set up the DevEco Studio development environment.The DevEco Studio development environment needs to depend on the network environment. It needs to be connected to the network to ensure the normal use of the tool.The development environment can be configured according to the following two situations - 1.If you can directly access the Internet, just download the HarmonyOS SDK - 2.If the network cannot access the Internet directly, it can be accessed through a proxy server -• Generate secret key and apply for certificate - -User guide -• Download this Project -• Open HUAWEI DevEco Studio, click File> Open> Then select and open this Project -• Click Build> Build App(s)/Hap(s)>Build Debug Hap(s) to compile the hap package -• Click Run> Run 'entry' to run the hap package - -Note -• You can choose to run the hap package on the simulator or the phone. -• If you run it on the phone, you need to configure the signature and certificate information in the project's File> Project Structure> Modules> Signing Configs. -• Currently, there is no way to ensure that the card service will not be destroyed by the system. Go to Phone Manager > App Startup Management > Pedometer Service Card, touch the slider on the right, and select Enable Background Activities to enable the background running permission. You can also enable Auto Start if necessary. - -Licensing -Please see LICENSE for more info. \ No newline at end of file diff --git a/StepsCard/RELEASE-NOTES.md b/StepsCard/RELEASE-NOTES.md deleted file mode 100644 index ea23a13e3d4407d06cba3aa7155a23e5081b50b4..0000000000000000000000000000000000000000 --- a/StepsCard/RELEASE-NOTES.md +++ /dev/null @@ -1,2 +0,0 @@ -1.0.0 -1.Initial version \ No newline at end of file diff --git a/StepsCard/build.gradle b/StepsCard/build.gradle deleted file mode 100644 index 6e426123b4f051013e17a938fd2bff6eafd9ae36..0000000000000000000000000000000000000000 --- a/StepsCard/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.huawei.ohos.app' - -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 5 - } -} -buildscript { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } - dependencies { - classpath 'com.huawei.ohos:hap:2.4.5.0' - classpath 'com.huawei.ohos:decctest:1.2.4.1' - } - - - allprojects { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } - } -} \ No newline at end of file diff --git a/StepsCard/entry/.gitignore b/StepsCard/entry/.gitignore deleted file mode 100644 index 796b96d1c402326528b4ba3c12ee9d92d0e212e9..0000000000000000000000000000000000000000 --- a/StepsCard/entry/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/StepsCard/entry/build.gradle b/StepsCard/entry/build.gradle deleted file mode 100644 index 64596112d3e93a506e16d16852bf4e5735b60a7e..0000000000000000000000000000000000000000 --- a/StepsCard/entry/build.gradle +++ /dev/null @@ -1,26 +0,0 @@ -apply plugin: 'com.huawei.ohos.hap' -apply plugin: 'com.huawei.ohos.decctest' -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 5 - } - buildTypes { - release { - proguardOpt { - proguardEnabled false - rulesFiles 'proguard-rules.pro' - } - } - } - compileOptions { annotationEnabled true } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - testCompile 'junit:junit:4.13' - ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' -} -decc { - supportType = ['html', 'xml'] -} diff --git a/StepsCard/entry/src/main/config.json b/StepsCard/entry/src/main/config.json deleted file mode 100644 index 0b31d1d6040071ebde450b5b80fe780f1209231f..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/config.json +++ /dev/null @@ -1,153 +0,0 @@ -{ - "app": { - "bundleName": "com.huawei.cookbook", - "vendor": "huawei", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": { - "default": { - "keepAlive": true - } - }, - "module": { - "package": "com.huawei.cookbook", - "name": ".MyApplication", - "mainAbility": "com.huawei.cookbook.MainAbility", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": false - }, - "reqPermissions": [ - { - "name": "ohos.permission.ACTIVITY_MOTION", - "reason": "get step count", - "usedScene": { - "ability": [ - ".MainAbility", - ".StepSensorService" - ], - "when": "always" - } - }, - { - "name": "ohos.permission.KEEP_BACKGROUND_RUNNING", - "reason": "keep service ability backgroud running", - "usedScene": { - "ability": [ - ".StepSensorService" - ], - "when": "always" - } - } - ], - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "orientation": "unspecified", - "name": "com.huawei.cookbook.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard", - "formsEnabled": true, - "visible": true - }, - { - "name": "com.huawei.cookbook.StepSensorService", - "icon": "$media:icon", - "description": "$string:stepsensorservice_description", - "type": "service", - "visible": true, - "backgroundModes": [ - "dataTransfer", - "location" - ] - }, - { - "orientation": "unspecified", - "name": "com.huawei.cookbook.StepFormAbility", - "icon": "$media:icon", - "description": "$string:stepformability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard", - "visible": true, - "formsEnabled": true, - "forms": [ - { - "jsComponentName": "card2X2", - "isDefault": true, - "scheduledUpdateTime": "10:30", - "defaultDimension": "2*2", - "name": "card2X2", - "description": "This is a step service widget", - "colorMode": "auto", - "type": "JS", - "supportDimensions": [ - "2*2" - ], - "updateEnabled": true, - "updateDuration": 1 - }, - { - "jsComponentName": "card2X4", - "isDefault": false, - "scheduledUpdateTime": "10:30", - "defaultDimension": "2*4", - "name": "card2X4", - "description": "This is a step service widget", - "colorMode": "auto", - "type": "JS", - "supportDimensions": [ - "2*4" - ], - "updateEnabled": true, - "updateDuration": 1 - } - ] - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "card2X2", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "type": "form" - }, - { - "pages": [ - "pages/index/index" - ], - "name": "card2X4", - "window": { - "designWidth": 720, - "autoDesignWidth": true - }, - "type": "form" - } - ] - } -} \ No newline at end of file diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/MainAbility.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/MainAbility.java deleted file mode 100644 index a52fd708b137d0093e4c95a2338069957e9b5390..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/MainAbility.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook; - -import com.huawei.cookbook.slice.MainAbilitySlice; -import com.huawei.cookbook.utils.PermissionBridge; - -import ohos.aafwk.ability.Ability; -import ohos.aafwk.content.Intent; -import ohos.bundle.IBundleManager; -import ohos.security.SystemPermission; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -/** - * MainAbility - */ -public class MainAbility extends Ability { - /** - * permission handler granted - */ - private static final int EVENT_PERMISSION_GRANTED = 0x0000023; - - /** - * permission handler denied - */ - private static final int EVENT_PERMISSION_DENIED = 0x0000024; - private static final int PERMISSION_REQUEST_CODE = 0; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setMainRoute(MainAbilitySlice.class.getName()); - requestPermission(); - } - - // 向用户申请相关权限的授权 - private void requestPermission() { - String[] permissions = { - // 计步器权限 - SystemPermission.ACTIVITY_MOTION - }; - List permissionFiltereds = Arrays.stream(permissions) - .filter(permission -> verifySelfPermission(permission) != IBundleManager.PERMISSION_GRANTED) - .collect(Collectors.toList()); - if (permissionFiltereds.isEmpty()) { - PermissionBridge.getHandler().sendEvent(EVENT_PERMISSION_GRANTED); - return; - } - // 向用户申请相关权限的授权 - requestPermissionsFromUser(permissionFiltereds.toArray(new String[permissionFiltereds.size()]), - PERMISSION_REQUEST_CODE); - } - - @Override - public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions, int[] grantResults) { - if (permissions == null || permissions.length == 0 || grantResults == null || grantResults.length == 0) { - return; - } - for (int grantResult : grantResults) { - if (grantResult != IBundleManager.PERMISSION_GRANTED) { - PermissionBridge.getHandler().sendEvent(EVENT_PERMISSION_DENIED); - terminateAbility(); - return; - } - } - PermissionBridge.getHandler().sendEvent(EVENT_PERMISSION_GRANTED); - } -} \ No newline at end of file diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/MyApplication.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/MyApplication.java deleted file mode 100644 index aa0b392778678cba23371d003255bb05c1d64931..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/MyApplication.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook; - -import ohos.aafwk.ability.AbilityPackage; - -/** - * MyApplication - */ -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/StepFormAbility.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/StepFormAbility.java deleted file mode 100644 index 6d2c062dc2b11470c35583ff2f3308ee87c9cba8..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/StepFormAbility.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook; - -import com.huawei.cookbook.database.Form; -import com.huawei.cookbook.database.FormDatabase; -import com.huawei.cookbook.database.SensorData; -import com.huawei.cookbook.slice.StepFormAbilitySlice; -import com.huawei.cookbook.utils.ChartDataUtils; -import com.huawei.cookbook.utils.DatabaseUtils; -import com.huawei.cookbook.utils.DateUtils; -import com.huawei.cookbook.utils.LogUtils; - -import ohos.aafwk.ability.Ability; -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.ability.FormBindingData; -import ohos.aafwk.ability.FormException; -import ohos.aafwk.ability.ProviderFormInfo; -import ohos.aafwk.content.Intent; -import ohos.data.DatabaseHelper; -import ohos.data.orm.OrmContext; -import ohos.utils.zson.ZSONObject; - -/** - * StepFormAbility - */ -public class StepFormAbility extends Ability { - private static final String TAG = StepFormAbility.class.getSimpleName(); - private static final String EMPTY_STRING = ""; - private static final int INVALID_FORM_ID = -1; - private static final int DEFAULT_DIMENSION_2X2 = 2; - private DatabaseHelper helper = new DatabaseHelper(this); - private OrmContext connect; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setMainRoute(StepFormAbilitySlice.class.getName()); - connect = helper.getOrmContext("FormDatabase", "FormDatabase.db", FormDatabase.class); - } - - @Override - protected ProviderFormInfo onCreateForm(Intent intent) { - ProviderFormInfo providerFormInfo = new ProviderFormInfo(); - if (intent == null) { - return providerFormInfo; - } - // 获取卡片id - long formId = INVALID_FORM_ID; - if (intent.hasParameter(AbilitySlice.PARAM_FORM_IDENTITY_KEY)) { - formId = intent.getLongParam(AbilitySlice.PARAM_FORM_IDENTITY_KEY, INVALID_FORM_ID); - } - // 获取卡片名称 - String formName = EMPTY_STRING; - if (intent.hasParameter(AbilitySlice.PARAM_FORM_NAME_KEY)) { - formName = intent.getStringParam(AbilitySlice.PARAM_FORM_NAME_KEY); - } - // 获取卡片规格 - int dimension = DEFAULT_DIMENSION_2X2; - if (intent.hasParameter(AbilitySlice.PARAM_FORM_DIMENSION_KEY)) { - dimension = intent.getIntParam(AbilitySlice.PARAM_FORM_DIMENSION_KEY, DEFAULT_DIMENSION_2X2); - } - connect = helper.getOrmContext("FormDatabase", "FormDatabase.db", FormDatabase.class); - // 存储卡片信息 - Form form = new Form(formId, formName, dimension); - DatabaseUtils.insertForm(form, connect); - // 获取当天的步数 - SensorData sensorData = DatabaseUtils.getSensorData(connect, DateUtils.getDate(0)); - String stepValue = ""; - if (sensorData != null) { - stepValue = sensorData.getStepsValue() + ""; - } else { - stepValue = "0"; - } - // 获取卡片页面需要的数据 - ZSONObject zsonObject = ChartDataUtils.getZsonObject(stepValue, dimension, connect); - providerFormInfo.setJsBindingData(new FormBindingData(zsonObject)); - return providerFormInfo; - } - - @Override - protected void onUpdateForm(long formId) { - LogUtils.info(TAG, "onUpdateForm()"); - super.onUpdateForm(formId); - ZSONObject zsonObject = new ZSONObject(); - zsonObject.put(EMPTY_STRING, EMPTY_STRING); - try { - updateForm(formId, new FormBindingData(zsonObject)); - } catch (FormException e) { - LogUtils.error(TAG, e.getMessage()); - } - } - - @Override - protected void onDeleteForm(long formId) { - LogUtils.info(TAG, "onDeleteForm():formId=" + formId); - super.onDeleteForm(formId); - // 删除数据库中的卡片信息 - DatabaseUtils.deleteFormData(formId, connect); - } -} diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/StepSensorService.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/StepSensorService.java deleted file mode 100644 index 78a679e7cb375974f4561eaa5235ca8ef3c51c72..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/StepSensorService.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook; - -import com.huawei.cookbook.database.Form; -import com.huawei.cookbook.database.FormDatabase; -import com.huawei.cookbook.database.SensorData; -import com.huawei.cookbook.slice.MainAbilitySlice; -import com.huawei.cookbook.utils.ChartDataUtils; -import com.huawei.cookbook.utils.DatabaseUtils; -import com.huawei.cookbook.utils.DateUtils; -import com.huawei.cookbook.utils.LogUtils; - -import ohos.aafwk.ability.Ability; -import ohos.aafwk.ability.FormBindingData; -import ohos.aafwk.ability.FormException; -import ohos.aafwk.content.Intent; -import ohos.data.DatabaseHelper; -import ohos.data.orm.OrmContext; -import ohos.data.orm.OrmPredicates; -import ohos.event.notification.NotificationRequest; -import ohos.eventhandler.EventHandler; -import ohos.eventhandler.EventRunner; -import ohos.eventhandler.InnerEvent; -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; -import ohos.sensor.agent.CategoryMotionAgent; -import ohos.sensor.bean.CategoryMotion; -import ohos.sensor.data.CategoryMotionData; -import ohos.sensor.listener.ICategoryMotionDataCallback; -import ohos.utils.zson.ZSONObject; - -import java.util.List; - -/** - * StepSensorService 计步器传感器service - */ -public class StepSensorService extends Ability { - private static final HiLogLabel LABEL_LOG = new HiLogLabel(3, 0xD001100, "Demo"); - private static final long INTERVAL = 3000000000L; - private static final int NOTICE_ID = 1005; - private CategoryMotionAgent categoryMotionAgent = new CategoryMotionAgent(); - private ICategoryMotionDataCallback categoryMotionDataCallback; - private CategoryMotion categoryMotion; - private StepSensorService.MyEventHandler myHandler; - private DatabaseHelper helper = new DatabaseHelper(this); - private OrmContext connect; - - @Override - public void onStart(Intent intent) { - HiLog.info(LABEL_LOG, "StepSensorService::onStart"); - super.onStart(intent); - connect = helper.getOrmContext("FormDatabase", "FormDatabase.db", FormDatabase.class); - myHandler = new MyEventHandler(EventRunner.getMainEventRunner()); - categoryMotionDataCallback = new ICategoryMotionDataCallback() { - @Override - public void onSensorDataModified(CategoryMotionData categoryMotionData) { - float[] values = categoryMotionData.getValues(); - handleSensorData(values[0]); - // 设置前台service通知 - notice(); - } - - @Override - public void onAccuracyDataModified(CategoryMotion category, int accuracy) { - } - - @Override - public void onCommandCompleted(CategoryMotion category) { - } - }; - categoryMotion = categoryMotionAgent.getSingleSensor(CategoryMotion.SENSOR_TYPE_PEDOMETER); - if (categoryMotion != null) { - categoryMotionAgent.setSensorDataCallback(categoryMotionDataCallback, categoryMotion, INTERVAL); - } - } - - // 前台service - private void notice() { - // 创建通知 - NotificationRequest request = new NotificationRequest(NOTICE_ID); - request.setAlertOneTime(true); - NotificationRequest.NotificationNormalContent content = new NotificationRequest.NotificationNormalContent(); - SensorData sensorData = DatabaseUtils.getSensorData(connect, DateUtils.getDate(0)); - int stepValue = 0; - if (sensorData != null) { - stepValue = sensorData.getStepsValue(); - } - content.setText("今天走了" + stepValue + "步"); - NotificationRequest.NotificationContent notificationContent - = new NotificationRequest.NotificationContent(content); - request.setContent(notificationContent); - // 绑定通知 - keepBackgroundRunning(NOTICE_ID, request); - } - - /** - * handle sensor data - * - * @param value step count - */ - private void handleSensorData(float value) { - SensorData realSensorData = - DatabaseUtils.getRealSensorData(value, connect, - DateUtils.getDate(0), DateUtils.getDate(1)); - float stepsValue = realSensorData.getStepsValue(); - String stringValue = String.valueOf((int) stepsValue); - myHandler.postTask(new Runnable() { - @Override - public void run() { - // 存储数据 - DatabaseUtils.insertValues(stepsValue, value, connect); - // 更新页面 - MainAbilitySlice.updatePage(stringValue); - // 更新卡片 - updateForms(stringValue); - } - }); - } - - /** - * update form - * - * @param value 步数值 - */ - private void updateForms(String value) { - OrmPredicates ormPredicates = new OrmPredicates(Form.class); - List forms = connect.query(ormPredicates); - if (forms.size() <= 0) { - return; - } - for (Form form : forms) { - ZSONObject result = ChartDataUtils.getZsonObject(value, form.getDimension(), connect); - try { - updateForm(form.getFormId(), new FormBindingData(result)); - } catch (FormException e) { - connect.delete(form); - LogUtils.error("updateForms", "formid not exit"); - } - } - } - - @Override - public void onBackground() { - super.onBackground(); - HiLog.info(LABEL_LOG, "StepSensorService::onBackground"); - } - - @Override - public void onStop() { - super.onStop(); - categoryMotionAgent.releaseSensorDataCallback(categoryMotionDataCallback); - HiLog.info(LABEL_LOG, "StepSensorService::onStop"); - } - - @Override - public void onCommand(Intent intent, boolean isRestart, int startId) { - } - - @Override - public void onDisconnect(Intent intent) { - } - - /** - * MyEventHandler 用于线程间的通信 - */ - class MyEventHandler extends EventHandler { - MyEventHandler(EventRunner runner) throws IllegalArgumentException { - super(runner); - } - - @Override - protected void processEvent(InnerEvent event) { - super.processEvent(event); - } - } - - @Override - public void onMemoryLevel(int level) { - HiLog.info(LABEL_LOG, "StepSensorService::level::" + level); - super.onMemoryLevel(level); - } -} \ No newline at end of file diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/cardentity/ChartPoint.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/cardentity/ChartPoint.java deleted file mode 100644 index 448756c2dc2387166e20b4fc5ed26ae3e5c1e368..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/cardentity/ChartPoint.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook.cardentity; - -/** - * 表的点 - */ -public class ChartPoint { - // 步数 - private int value; - - // 点的样式 - private PointStyle pointStyle; - - // 点的描述 - private String description; - - // 描述的位置 - private String textLocation; - - // 字体颜色 - private String textColor; - - public int getValue() { - return value; - } - - public void setValue(int value) { - this.value = value; - } - - public PointStyle getPointStyle() { - return pointStyle; - } - - public void setPointStyle(PointStyle pointStyle) { - this.pointStyle = pointStyle; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getTextLocation() { - return textLocation; - } - - public void setTextLocation(String textLocation) { - this.textLocation = textLocation; - } - - public String getTextColor() { - return textColor; - } - - public void setTextColor(String textColor) { - this.textColor = textColor; - } - - /** - * 描述显示位置 - */ - public enum TextLocation { - /** - * 底部 - */ - bottom, - /** - * 不显示 - */ - none, - /** - * 顶部 - */ - top - } -} diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/cardentity/ChartValues.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/cardentity/ChartValues.java deleted file mode 100644 index e47aa70c649e8d112b6c78cec95c614f73b04cf6..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/cardentity/ChartValues.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook.cardentity; - -import java.util.List; - -/** - * 表单数据 - */ -public class ChartValues { - // 填充颜色 - private String fillColor; - - // 线条颜色 - private String strokeColor; - - // 设置是否显示填充渐变颜色 - private boolean gradient; - - // 设置绘制线型图中的点集 - private List data; - - public String getStrokeColor() { - return strokeColor; - } - - public void setStrokeColor(String strokeColor) { - this.strokeColor = strokeColor; - } - - public String getFillColor() { - return fillColor; - } - - public void setFillColor(String fillColor) { - this.fillColor = fillColor; - } - - public boolean getGradient() { - return gradient; - } - - public void setGradient(boolean gradient) { - this.gradient = gradient; - } - - public List getData() { - return data; - } - - public void setData(List data) { - this.data = data; - } -} diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/cardentity/PointStyle.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/cardentity/PointStyle.java deleted file mode 100644 index 836f5bc0dcb1809964ebddb8ca92182c0a97bd3a..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/cardentity/PointStyle.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook.cardentity; - -/** - * chart表 点的样式 - */ -public class PointStyle { - // 点的形状 - private String shape; - - // 填充颜色 - private String fillColor; - - // 边框颜色 - private String strokeColor; - - // 高亮点的大小 - private int size; - - public String getStrokeColor() { - return strokeColor; - } - - public void setStrokeColor(String strokeColor) { - this.strokeColor = strokeColor; - } - - public String getShape() { - return shape; - } - - public void setShape(String shape) { - this.shape = shape; - } - - public int getSize() { - return size; - } - - public void setSize(int size) { - this.size = size; - } - - public String getFillColor() { - return fillColor; - } - - public void setFillColor(String fillColor) { - this.fillColor = fillColor; - } - - /** - * 点的形状 - */ - public enum PointShape { - /** - * 圆形 - */ - CIRCLE, - /** - * 方形 - */ - SQUARE, - /** - * 三角形 - */ - TRIANGLE - } -} diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/database/Form.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/database/Form.java deleted file mode 100644 index c89006057f15ac5fa49162f48b4d42a1abbec873..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/database/Form.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook.database; - -import ohos.data.orm.OrmObject; -import ohos.data.orm.annotation.Entity; -import ohos.data.orm.annotation.PrimaryKey; - -/** - * 卡片表 - */ -@Entity(tableName = "form") -public class Form extends OrmObject { - @PrimaryKey() - // 卡片id - private Long formId; - - // 卡片名称 - private String formName; - - // 卡片规格 - private int dimension; - - /** - * 有参构造 - * - * @param formId 卡片id - * @param formName 卡片名 - * @param dimension 卡片规格 - */ - public Form(Long formId, String formName, int dimension) { - this.formId = formId; - this.formName = formName; - this.dimension = dimension; - } - - /** - * 无参构造 - */ - public Form() { - super(); - } - - public int getDimension() { - return dimension; - } - - public void setDimension(int dimension) { - this.dimension = dimension; - } - - public Long getFormId() { - return formId; - } - - public void setFormId(Long formId) { - this.formId = formId; - } - - public String getFormName() { - return formName; - } - - public void setFormName(String formName) { - this.formName = formName; - } -} diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/database/FormDatabase.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/database/FormDatabase.java deleted file mode 100644 index 02936af347a0f7c0fc2d6aec812d948294da90f2..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/database/FormDatabase.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook.database; - -import ohos.data.orm.OrmDatabase; -import ohos.data.orm.annotation.Database; - -/** - * 卡片数据库 - */ -@Database(entities = {Form.class, SensorData.class}, version = 1) -public abstract class FormDatabase extends OrmDatabase { -} diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/database/SensorData.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/database/SensorData.java deleted file mode 100644 index 59ef5de08c151cca26d8867868c62d912ca151b8..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/database/SensorData.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook.database; - -import ohos.data.orm.OrmObject; -import ohos.data.orm.annotation.Entity; -import ohos.data.orm.annotation.PrimaryKey; - -/** - * Sensor Data Storage Table - */ -@Entity(tableName = "sensorData") -public class SensorData extends OrmObject { - @PrimaryKey() - // date yyyyMMdd - private String date; - - // stepsValue - private int stepsValue; - - // 实际步数 - private int realValue; - - public SensorData() { - } - - /** - * parametric construction - * - * @param date date - * @param stepsValue stepsValue - * @param realValue real stepsValue - */ - public SensorData(String date, int stepsValue, int realValue) { - this.date = date; - this.stepsValue = stepsValue; - this.realValue = realValue; - } - - public String getDate() { - return date; - } - - public void setDate(String date) { - this.date = date; - } - - public int getStepsValue() { - return stepsValue; - } - - public void setStepsValue(int stepsValue) { - this.stepsValue = stepsValue; - } - - public int getRealValue() { - return realValue; - } - - public void setRealValue(int realValue) { - this.realValue = realValue; - } -} diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/slice/MainAbilitySlice.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/slice/MainAbilitySlice.java deleted file mode 100644 index 8b5f63fb7c20b958788a37aea042798ed323f39b..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/slice/MainAbilitySlice.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.huawei.cookbook.slice; - -import com.huawei.cookbook.ResourceTable; -import com.huawei.cookbook.StepSensorService; -import com.huawei.cookbook.database.FormDatabase; -import com.huawei.cookbook.database.SensorData; -import com.huawei.cookbook.utils.DatabaseUtils; -import com.huawei.cookbook.utils.DateUtils; -import com.huawei.cookbook.utils.PermissionBridge; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.aafwk.content.Operation; -import ohos.agp.components.ProgressBar; -import ohos.agp.components.Text; -import ohos.agp.window.dialog.ToastDialog; -import ohos.app.Context; -import ohos.data.DatabaseHelper; -import ohos.data.orm.OrmContext; - -/** - * MainAbilitySlice - */ -public class MainAbilitySlice extends AbilitySlice implements PermissionBridge.OnPermissionStateListener { - private static ChangeUi cs; - private Text step; - private ProgressBar progressBar; - private int value; - private DatabaseHelper helper = new DatabaseHelper(this); - private OrmContext connect; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setUIContent(ResourceTable.Layout_form_router_page); - new PermissionBridge().setOnPermissionStateListener(this); - intComponet(); - cs = new ChangeUi(); - } - - private void intComponet() { - step = (Text) findComponentById(ResourceTable.Id_step); - connect = helper.getOrmContext("FormDatabase", "FormDatabase.db", FormDatabase.class); - SensorData sensorData = DatabaseUtils.getSensorData(connect, DateUtils.getDate(0)); - if (sensorData != null) { - value = sensorData.getStepsValue(); - } - step.setText(value + ""); - progressBar = (ProgressBar) findComponentById(ResourceTable.Id_progressBar); - progressBar.setProgressValue(value); - } - - @Override - public void onActive() { - super.onActive(); - } - - @Override - public void onForeground(Intent intent) { - super.onForeground(intent); - } - - @Override - public void onPermissionGranted() { - Intent intentService = new Intent(); - Operation operation = new Intent.OperationBuilder() - .withDeviceId("") - .withBundleName(getBundleName()) - .withAbilityName(StepSensorService.class.getName()) - .build(); - intentService.setOperation(operation); - startAbility(intentService); - } - - private void showTips(Context context, String message) { - getUITaskDispatcher().asyncDispatch(() -> { - ToastDialog toastDialog = new ToastDialog(context); - toastDialog.setAutoClosable(false); - toastDialog.setContentText(message); - toastDialog.show(); - }); - } - - @Override - public void onPermissionDenied() { - showTips(MainAbilitySlice.this, "=======No permission"); - } - - /** - * 修改页面 - * - * @param value 传感器传过来的数据 - */ - public static void updatePage(String value) { - cs.updatePage(value); - } - - /** - * 修改页面 - */ - private class ChangeUi { - /** - * 修改页面数据 - * - * @param sensorValue 传感器传过来的数据 - */ - public void updatePage(String sensorValue) { - step.setText(sensorValue); - progressBar.setProgressValue(Integer.parseInt(sensorValue)); - } - } -} diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/slice/StepFormAbilitySlice.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/slice/StepFormAbilitySlice.java deleted file mode 100644 index f696e90ad6cc364bdc330c5b34e991723291c6f0..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/slice/StepFormAbilitySlice.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook.slice; - -import com.huawei.cookbook.ResourceTable; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; - -/** - * 计步器卡片Slice - */ -public class StepFormAbilitySlice extends AbilitySlice { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setUIContent(ResourceTable.Layout_ability_step_form); - } - - @Override - public void onActive() { - super.onActive(); - } - - @Override - public void onForeground(Intent intent) { - super.onForeground(intent); - } -} diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/utils/ChartDataUtils.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/utils/ChartDataUtils.java deleted file mode 100644 index 91286cb7e60d09cbff9d24e32b6f83655e9fab97..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/utils/ChartDataUtils.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook.utils; - -import com.huawei.cookbook.cardentity.ChartPoint; -import com.huawei.cookbook.cardentity.ChartValues; -import com.huawei.cookbook.cardentity.PointStyle; - -import ohos.data.orm.OrmContext; -import ohos.utils.zson.ZSONObject; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -/** - * chart date utls - */ -public class ChartDataUtils { - private static final String BLUE_COLOR = "#0D9FFB"; - private static final String WHITE_COLOR = "#FFFFFF"; - private static final String GREEN_COLOR = "#41BA41"; - private static final String GRAY_COLOR = "#CDCACA"; - private static final String ORANGE_COLOR = "#FF9C28"; - private static final int PAGE_WIDTH = 360; - private static final int IMG_WIDTH = 28; - private static final double CARD_WIDTH_PERCENT = 0.6; - private static final int DIMENSION_2X4 = 3; - private static final String SHOW = "flex"; - private static final String HIDE = "none"; - private static final int TARGET_STEPS = 1000; - private static final int PROGRESS_PERCENT = 100; - private static final int POINT_SIZE = 5; - private static final int PERCENT_100 = 100; - private static final double METER_PER_STEP = 0.6; - - /** - * hide constructor - * - */ - private ChartDataUtils() { - } - - /** - * get chart potin data list - * - * @param connect database connection - * @return chart potin data list - */ - public static List getChartPoints(OrmContext connect) { - return DatabaseUtils.getLastFourDaysValue(connect); - } - - /** - * get chart datasets - * - * @param value value - * @param connect database connection - * @return chart value - */ - public static ChartValues getChartValues(String value, OrmContext connect) { - ChartValues chartValues = new ChartValues(); - // 设置填充色颜色 - chartValues.setFillColor(GRAY_COLOR); - // 设置线的颜色 - chartValues.setStrokeColor(GRAY_COLOR); - chartValues.setGradient(true); - // 获取点的集合 - // 获取前三天的点的集合 - List chartPoints = ChartDataUtils.getChartPoints(connect); - ChartPoint noewChartPoint = ChartDataUtils.getChartPoint(Integer.parseInt(value)); - // 加入今天的步数点 - chartPoints.add(noewChartPoint); - chartValues.setData(chartPoints); - return chartValues; - } - - /** - * get chart point - * - * @param value value - * @return point data - */ - public static ChartPoint getChartPoint(int value) { - ChartPoint chartPoint = new ChartPoint(); - // 点的数值,超过1000只显示1000的高度 - chartPoint.setValue(value >= TARGET_STEPS ? TARGET_STEPS : value); - // 点的描述 - chartPoint.setDescription(value + ""); - // 点的描述显示位置,此处设置为点的上面 - chartPoint.setTextLocation(ChartPoint.TextLocation.top.toString()); - // 设置描述字体的颜色 - chartPoint.setTextColor(GRAY_COLOR); - PointStyle pointStyle = new PointStyle(); - // 设置点的大小 - pointStyle.setSize(POINT_SIZE); - // 设置点的颜色 - pointStyle.setFillColor(ORANGE_COLOR); - // 设置点的外框颜色 - pointStyle.setStrokeColor(ORANGE_COLOR); - // 设置点的样式,此处设置为圆形 - pointStyle.setShape(PointStyle.PointShape.CIRCLE.toString() - .toLowerCase(Locale.ROOT)); - chartPoint.setPointStyle(pointStyle); - return chartPoint; - } - - /** - * get data for js page - * - * @param value step count - * @param dimension form dimension - * @param connect database connection - * @return data for js page - */ - public static ZSONObject getZsonObject(String value, int dimension, OrmContext connect) { - ZSONObject result = new ZSONObject(); - int round = 0; - if (Double.parseDouble(value) >= TARGET_STEPS) { - round = PERCENT_100; - } else { - round = (int) Math.round(Double.parseDouble(value) / TARGET_STEPS * PROGRESS_PERCENT); - } - result.put("percent", round); - result.put("steps", value); - if (dimension == DIMENSION_2X4) { - // 组装chartdatasets - List datasets = new ArrayList<>(1); - // 获取点集数据 - ChartValues chartValues = ChartDataUtils.getChartValues(value, connect); - datasets.add(chartValues); - // chart图表数据 - result.put("datasets", datasets); - // 里程 - result.put("mileage", Math.round(Integer.parseInt(value) * METER_PER_STEP)); - } - return result; - } -} diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/utils/DatabaseUtils.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/utils/DatabaseUtils.java deleted file mode 100644 index deb50669165434ecc6c5fe134e0c3cf924bd2a0a..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/utils/DatabaseUtils.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook.utils; - -import com.huawei.cookbook.cardentity.ChartPoint; -import com.huawei.cookbook.database.Form; -import com.huawei.cookbook.database.SensorData; - -import ohos.data.orm.OrmContext; -import ohos.data.orm.OrmPredicates; - -import java.util.ArrayList; -import java.util.List; - -/** - * 卡片数据库操作 - */ -public class DatabaseUtils { - private static final int SHOW_DAYS = 3; - private static final String DATA_FILED_DATE = "date"; - - private DatabaseUtils() { - } - - /** - * 删除数据 - * - * @param formId 卡片id - * @param connect 数据连接 - */ - public static void deleteFormData(long formId, OrmContext connect) { - OrmPredicates where = connect.where(Form.class); - where.equalTo("formId", formId); - List forms = connect.query(where); - if (!forms.isEmpty()) { - connect.delete(forms.get(0)); - connect.flush(); - } - } - - /** - * 新增卡片信息 - * - * @param form 卡片对象 - * @param connect 数据连接 - */ - public static void insertForm(Form form, OrmContext connect) { - connect.insert(form); - connect.flush(); - } - - /** - * 插入步数到数据库 - * - * @param value 数据 - * @param connect 数据连接 - * @param realValue 真实传感器数据 - */ - public static void insertValues(float value, float realValue, OrmContext connect) { - String now = DateUtils.getDate(0); - SensorData sensorData = new SensorData(now, (int) value, (int) realValue); - // 查询今天是否有数据 - SensorData todayData = getSensorData(connect, now); - boolean isInsert = false; - if (todayData == null) { - isInsert = connect.insert(sensorData); - } else { - todayData.setStepsValue(sensorData.getStepsValue()); - isInsert = connect.update(todayData); - } - if (isInsert) { - connect.flush(); - } - } - - /** - * 获取真实的当天步数 - * - * @param value 步数 - * @param connect 数据库连接 - * @param now 今天日期 - * @param yestday 昨天日期 - * @return 数据 - */ - public static SensorData getRealSensorData(float value, OrmContext connect, String now, String yestday) { - OrmPredicates ormPredicates = new OrmPredicates(SensorData.class); - ormPredicates.equalTo(DATA_FILED_DATE, yestday); - SensorData yesterdayData = getSensorData(connect, yestday); - SensorData todayData = getSensorData(connect, now); - SensorData sensorData = null; - if (yesterdayData != null) { - if (todayData != null) { - sensorData = new SensorData(now, (int) (value - todayData.getRealValue()), (int) value); - } else { - sensorData = new SensorData(now, (int) (value - yesterdayData.getRealValue()), (int) value); - } - } else { - if (todayData != null) { - sensorData = new SensorData(now, (int) (value - todayData.getRealValue()), (int) value); - } else { - sensorData = new SensorData(now, 0, (int) value); - } - } - return sensorData; - } - - /** - * 获取真实的当天步数 - * - * @param connect 数据库连接 - * @param date 日期 - * @return 数据 - */ - public static SensorData getSensorData(OrmContext connect, String date) { - OrmPredicates ormPredicates = new OrmPredicates(SensorData.class); - ormPredicates.equalTo(DATA_FILED_DATE, date); - List datas = connect.query(ormPredicates); - SensorData sensorData = null; - if (datas.size() > 0) { - sensorData = datas.get(0); - } - return sensorData; - } - - /** - * 获取前三天的数据 - * - * @param connect 数据连接 - * @return 数据 - */ - public static List getLastFourDaysValue(OrmContext connect) { - List results = new ArrayList<>(SHOW_DAYS); - OrmPredicates ormPredicates = connect.where(SensorData.class); - for (int i = SHOW_DAYS; i > 0; i--) { - ormPredicates.clear(); - ormPredicates.equalTo(DATA_FILED_DATE, DateUtils.getDate(i)); - List datas = connect.query(ormPredicates); - if (datas.size() == 0) { - results.add(ChartDataUtils.getChartPoint(0)); - } else { - results.add(ChartDataUtils.getChartPoint(datas.get(0).getStepsValue())); - } - } - return results; - } -} diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/utils/DateUtils.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/utils/DateUtils.java deleted file mode 100644 index 6217e23441cc2ee1d6a375e4348ea8cc39db68f8..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/utils/DateUtils.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook.utils; - -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; - -/** - * 日期计算 - */ -public class DateUtils { - private DateUtils() { - } - - /** - * 获取日期 - * - * @param days 前几天 - * @return 返回年月日格式的日期 - */ - public static String getDate(int days) { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); - Calendar calendar = Calendar.getInstance(); - calendar.add(Calendar.DATE, -days); - String formatDate = simpleDateFormat.format(calendar.getTime()); - return formatDate; - } - - /** - * 获取指定格式的日期字符串 - * - * @param format 格式 - * @param date 日期 - * @return 指定格式的日期字符串 - */ - public static String getDateString(String format, Date date) { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format); - return simpleDateFormat.format(date); - } -} diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/utils/LogUtils.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/utils/LogUtils.java deleted file mode 100644 index 59492e9a8eb506c25bcea070f2e74fe10dc8ecd3..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/utils/LogUtils.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook.utils; - -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; - -/** - * LogUtils - */ -public class LogUtils { - private static final String TAG_LOG = "LogUtil"; - - private static final HiLogLabel LABEL_LOG = new HiLogLabel(0, 0, LogUtils.TAG_LOG); - - private static final String LOG_FORMAT = "%{public}s: %{public}s"; - - private LogUtils() { - } - - /** - * Print debug log - * - * @param tag log tag - * @param msg log message - */ - public static void debug(String tag, String msg) { - HiLog.debug(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print info log - * - * @param tag log tag - * @param msg log message - */ - public static void info(String tag, String msg) { - HiLog.info(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print warn log - * - * @param tag log tag - * @param msg log message - */ - public static void warn(String tag, String msg) { - HiLog.warn(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print error log - * - * @param tag log tag - * @param msg log message - */ - public static void error(String tag, String msg) { - HiLog.error(LABEL_LOG, LOG_FORMAT, tag, msg); - } -} diff --git a/StepsCard/entry/src/main/java/com/huawei/cookbook/utils/PermissionBridge.java b/StepsCard/entry/src/main/java/com/huawei/cookbook/utils/PermissionBridge.java deleted file mode 100644 index 43164414b4d01b17c5d2d406e922d459468ed0c0..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/java/com/huawei/cookbook/utils/PermissionBridge.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook.utils; - -import ohos.eventhandler.EventHandler; -import ohos.eventhandler.EventRunner; -import ohos.eventhandler.InnerEvent; - -/** - * PermissionBridge - */ -public class PermissionBridge { - /** - * permission handler granted - */ - public static final int EVENT_PERMISSION_GRANTED = 0x0000023; - - /** - * permission handler denied - */ - public static final int EVENT_PERMISSION_DENIED = 0x0000024; - - private static final String TAG = PermissionBridge.class.getSimpleName(); - - private static OnPermissionStateListener onPermissionStateListener; - - private static EventHandler handler = new EventHandler(EventRunner.current()) { - @Override - protected void processEvent(InnerEvent event) { - switch (event.eventId) { - case EVENT_PERMISSION_GRANTED: - onPermissionStateListener.onPermissionGranted(); - break; - case EVENT_PERMISSION_DENIED: - onPermissionStateListener.onPermissionDenied(); - break; - default: - LogUtils.info(TAG, "EventHandler Undefined Event"); - break; - } - } - }; - - /** - * setOnPermissionStateListener - * - * @param permissionStateListener OnPermissionStateListener - */ - public void setOnPermissionStateListener(OnPermissionStateListener permissionStateListener) { - onPermissionStateListener = permissionStateListener; - } - - /** - * OnPermissionStateListener - */ - public interface OnPermissionStateListener { - /** - * 当授权时 - */ - void onPermissionGranted(); - - /** - * 当拒绝授权时触发 - */ - void onPermissionDenied(); - } - - /** - * getHandler - * - * @return EventHandler - */ - public static EventHandler getHandler() { - return handler; - } -} diff --git a/StepsCard/entry/src/main/js/card2X2/common/backgroud.jpg b/StepsCard/entry/src/main/js/card2X2/common/backgroud.jpg deleted file mode 100644 index 967a4a4e08f114d8fc06fd9da64ea4ee6dc8da24..0000000000000000000000000000000000000000 Binary files a/StepsCard/entry/src/main/js/card2X2/common/backgroud.jpg and /dev/null differ diff --git a/StepsCard/entry/src/main/js/card2X2/pages/index/index.css b/StepsCard/entry/src/main/js/card2X2/pages/index/index.css deleted file mode 100644 index ee57e5ddb8e52645b4d3133a0ccb5e0c339e4f18..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/js/card2X2/pages/index/index.css +++ /dev/null @@ -1,52 +0,0 @@ -.card_root_layout { - width: 100%; - height: 100%; - position: relative; -} - -.div_basic_container { - background-image: url('common/backgroud.jpg'); - background-size: 100% 100%; - background-repeat: no-repeat; - position: absolute; - top: 0px; - left: 0px; - flex-direction: row; - width: 100%; - height: 100%; -} - -.div_progress { - color: #9C5A3C; - background-color: #A0C0BD; - stroke-width: 7px; - z-index: 0; - margin: 10%; - position: absolute; -} - -.title_container { - align-items: center; - flex-direction: column; - align-content: center; - justify-content: center; - width: 100%; - height: 100%; - z-index: 1; - position: absolute; -} - -.item_title {/* width: 154px;*/ - font-weight: bold; - color: #F3F6F5; - font-size: 16px; -} - -.item_content {/* width: 154px;*/ - color: #F3F6F5; - font-size: 12px; - margin-top: 2px; - -} - - diff --git a/StepsCard/entry/src/main/js/card2X2/pages/index/index.hml b/StepsCard/entry/src/main/js/card2X2/pages/index/index.hml deleted file mode 100644 index c5fa51de0e0a5394411a69a4b3719c340e2562d9..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/js/card2X2/pages/index/index.hml +++ /dev/null @@ -1,15 +0,0 @@ -
-
- - - -
- 今天一共走了 - - {{steps}} - - 步 - -
-
-
\ No newline at end of file diff --git a/StepsCard/entry/src/main/js/card2X2/pages/index/index.json b/StepsCard/entry/src/main/js/card2X2/pages/index/index.json deleted file mode 100644 index 2130bb7ff14a6fd536e2bf1d584a8cefe4682647..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/js/card2X2/pages/index/index.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "data": { - "percent": 0, - "steps": 0 - }, - "actions": { - "routerEvent": { - "action": "router", - "bundleName": "com.huawei.cookbook", - "abilityName": "com.huawei.cookbook.MainAbility", - "params": { - "message":"steps" - } - } - } -} - - - diff --git a/StepsCard/entry/src/main/js/card2X4/common/backgroundImg1.JPG b/StepsCard/entry/src/main/js/card2X4/common/backgroundImg1.JPG deleted file mode 100644 index 6c07dcb793c0c642adfe00e6f13c9212bfce2f0b..0000000000000000000000000000000000000000 Binary files a/StepsCard/entry/src/main/js/card2X4/common/backgroundImg1.JPG and /dev/null differ diff --git a/StepsCard/entry/src/main/js/card2X4/common/step2.png b/StepsCard/entry/src/main/js/card2X4/common/step2.png deleted file mode 100644 index c9db7fe48a3a622ac7b77e8a25649ff21b2ee1e9..0000000000000000000000000000000000000000 Binary files a/StepsCard/entry/src/main/js/card2X4/common/step2.png and /dev/null differ diff --git a/StepsCard/entry/src/main/js/card2X4/pages/index/index.css b/StepsCard/entry/src/main/js/card2X4/pages/index/index.css deleted file mode 100644 index 59de6256bf027ad60029032ec7047ad5361c6296..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/js/card2X4/pages/index/index.css +++ /dev/null @@ -1,112 +0,0 @@ -.card_root_layout { - width: 100%; - height: 100%; - position: relative; -} - -.div_basic_container { - background-image: url('common/backgroundImg1.JPG'); - background-size: 100% 100%; - background-repeat: no-repeat; - position: absolute; - top: 0px; - left: 0px; - flex-direction: row; - width: 100%; - height: 100%; -} - -.left_items { - width: 40%; - height: 100%; - align-content: flex-start; - flex-direction: column; - position: absolute; - left: 20; -} - -.left_items_top { - width: 100%; - height: 30%; - flex-direction: row; - align-content: flex-start; - position: relative; - top: 5; -} - -.left_items_center { - width: 100%; - height: 30%; - flex-direction: row; - top: 10px; - position: relative; -} - -.left_items_bootom { - width: 100%; - height: 30%; - flex-direction: row; - position: absolute; - bottom: 5; - top: 10px; - position: relative; -} - -.right_items { - align-content: flex-start; - width: 50%; - height: 100%; - position: absolute; - right: 20px; -} - -#stepImg { - align-content: center; - margin-top: 10px; - width: 30px; - height: 30px; -} - -#chart { - font-size: 10px; - lineColor: #7CFC00; -} - -.chartArea { - justify-content: flex-end; - width: 100%; - height: 50%; - position: absolute; - bottom: 10px; -} - -.text { - font-size: 20px; - color: #CDCACA; -} - -.progress { - width: 100%; - height: 40%; - flex-direction: row; - margin-top: 18px; - align-content: flex-start; -} - -.progressDiv { - flex-direction: row; -} - -#progress { - position: absolute; - width: 80%; - stroke-width: 20px; - background-color: #CDCACA; - color: #324846; - margin-top: 2px; -} - -.progressText { - flex-direction: row; - width: 50px; -} \ No newline at end of file diff --git a/StepsCard/entry/src/main/js/card2X4/pages/index/index.hml b/StepsCard/entry/src/main/js/card2X4/pages/index/index.hml deleted file mode 100644 index 9e731a4be1023036991010ccb499cc2cde519cde..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/js/card2X4/pages/index/index.hml +++ /dev/null @@ -1,39 +0,0 @@ -
-
- -
-
- 今天走了 - -
-
- {{ mileage }} - -
-
- {{ steps }} - -
-
- - -
- -
- -
- {{percent}} - % -
-
- - -
-
- -
- -
-
-
-
\ No newline at end of file diff --git a/StepsCard/entry/src/main/js/card2X4/pages/index/index.json b/StepsCard/entry/src/main/js/card2X4/pages/index/index.json deleted file mode 100644 index ccd236da2708362f322628224bafd37aa8fde331..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/js/card2X4/pages/index/index.json +++ /dev/null @@ -1,85 +0,0 @@ - { - "data": { - "datasets": [ - { - "strokeColor": "#CDCACA", - "fillColor": "#CDCACA", - "data": [ - { - "value": 0, - "description": "0", - "textLocation": "top", - "textColor": "#CDCACA", - "pointStyle": { - "shape": "circle", - "size": 5, - "fillColor": "#FF9C28", - "strokeColor": "#FF9C28" - } - }, - { - "value": 0, - "description": "0", - "textLocation": "top", - "textColor": "#CDCACA", - "pointStyle": { - "shape": "circle", - "size": 5, - "fillColor": "#FF9C28", - "strokeColor": "#FF9C28" - } - }, - { - "value": 0, - "description": "0", - "textLocation": "top", - "textColor": "#CDCACA", - "pointStyle": { - "shape": "circle", - "size": 5, - "fillColor": "#FF9C28", - "strokeColor": "#FF9C28" - } - }, - { - "value": 0, - "description": "0", - "textLocation": "top", - "textColor": "#CDCACA", - "pointStyle": { - "shape": "circle", - "size": 5, - "fillColor": "#FF9C28", - "strokeColor": "#FF9C28" - } - } - ], - "gradient": true - } - ], - "options": { - "xAxis": { - "min": 0, - "max": 3, - "display": false, - "axisTick": 4 - }, - "yAxis": { - "min": 0, - "max": 1000 - } - }, - "steps": 0, - "percent": 0, - "mileage": 0 - }, - - "actions": { - "routerEvent": { - "action": "router", - "bundleName": "com.huawei.cookbook", - "abilityName": "com.huawei.cookbook.MainAbility" - } - } -} - diff --git a/StepsCard/entry/src/main/resources/base/element/string.json b/StepsCard/entry/src/main/resources/base/element/string.json deleted file mode 100644 index dfa769a5d118ac0d2dac9a2119cc8ecaddb84574..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "计步器服务卡片" - }, - { - "name": "mainability_description", - "value": "Java_Phone_Empty Feature Ability" - }, - { - "name": "HelloWorld", - "value": "Hello World" - }, - { - "name": "stepsensorservice_description", - "value": "hap sample empty service" - }, - { - "name": "stepformability_description", - "value": "Java_Phone_Empty Feature Ability" - } - ] -} \ No newline at end of file diff --git a/StepsCard/entry/src/main/resources/base/graphic/background_ability_main.xml b/StepsCard/entry/src/main/resources/base/graphic/background_ability_main.xml deleted file mode 100644 index c0c0a3df480fa387a452b9c40ca191cc918a3fc0..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/resources/base/graphic/background_ability_main.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/StepsCard/entry/src/main/resources/base/graphic/background_ability_step_form.xml b/StepsCard/entry/src/main/resources/base/graphic/background_ability_step_form.xml deleted file mode 100644 index a002c2353e78af3a15235e00738328ff566bc085..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/resources/base/graphic/background_ability_step_form.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/StepsCard/entry/src/main/resources/base/layout/ability_step_form.xml b/StepsCard/entry/src/main/resources/base/layout/ability_step_form.xml deleted file mode 100644 index 546b5fd8986d5fcac4807ac11c69760c7dc2490f..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/resources/base/layout/ability_step_form.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/StepsCard/entry/src/main/resources/base/layout/form_router_page.xml b/StepsCard/entry/src/main/resources/base/layout/form_router_page.xml deleted file mode 100644 index 5fb2d21ca61876239b7e6d2b12403be7b0abdb72..0000000000000000000000000000000000000000 --- a/StepsCard/entry/src/main/resources/base/layout/form_router_page.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/StepsCard/entry/src/main/resources/base/media/form_image_with_info_steps_card_default_image_2.png b/StepsCard/entry/src/main/resources/base/media/form_image_with_info_steps_card_default_image_2.png deleted file mode 100644 index 64d3f425041c3dc993e82b45f1f5e7c56804db70..0000000000000000000000000000000000000000 Binary files a/StepsCard/entry/src/main/resources/base/media/form_image_with_info_steps_card_default_image_2.png and /dev/null differ diff --git a/StepsCard/entry/src/main/resources/base/media/icon.png b/StepsCard/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/StepsCard/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/StepsCard/gradle/wrapper/gradle-wrapper.jar b/StepsCard/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 490fda8577df6c95960ba7077c43220e5bb2c0d9..0000000000000000000000000000000000000000 Binary files a/StepsCard/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/StepsCard/gradle/wrapper/gradle-wrapper.properties b/StepsCard/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index f59159e865d4b59feb1b8c44b001f62fc5d58df4..0000000000000000000000000000000000000000 --- a/StepsCard/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/StepsCard/settings.gradle b/StepsCard/settings.gradle deleted file mode 100644 index 4773db73233a570c2d0c01a22e75321acfbf7a07..0000000000000000000000000000000000000000 --- a/StepsCard/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':entry' diff --git a/SwitchApplication/LICENSE b/SwitchApplication/LICENSE deleted file mode 100644 index 7c357dc828cf7d8c783f10ed6bb1bac8a1e903c1..0000000000000000000000000000000000000000 --- a/SwitchApplication/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - Copyright (c) 2021 Huawei Device Co., Ltd. - - Licensed under the Apache License,Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -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/SwitchApplication/README.md b/SwitchApplication/README.md deleted file mode 100644 index 1c83d50b49f4c933f1e07b043d572a73d68826a3..0000000000000000000000000000000000000000 --- a/SwitchApplication/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# SwitchApplication -简介 -• 此Demo使用了JS UI中的switch、chart组件。 您可以通过切换switch开关设置chart图表数据静态或动态显示。 - -安装要求 -• 安装DevEco Studio -• 设置DevEco Studio开发环境。DevEco Studio开发环境需要连接到网络,以确保该正常使用。可以根据以下两种情况配置开发环境: - 1.如果您可以直接访问Internet,则只需下载HarmonyOS SDK - 2.如果网络无法直接访问Internet,则可以通过代理服务器进行访问 -• 生成密钥并申请证书 - -用户指南 -• 下载此项目 -• 打开HUAWEI DevEco Studio,单击File> Open选择此ComponentCodelab -• 单击Build> Build App(s)/Hap(s)>Build Debug Hap(s)以编译hap软件包 -• 单击Run> Run 'entry'以运行hap包 - -注意 -• 您可以选择在模拟器或真机上运行hap软件包。 -• 如果在真机上运行它,则需要在项目的File> Project Structure> Modules> Signing Configs中配置签名和证书信息。 - -许可 -请参阅LICENSE文件以获得更多信息。 - -What is it? -This demo uses the switch and chart components of the JS UI. You can set the static or dynamic display of chart data by switching the switch. - -Installation requirements -• Install DevEco Studio -• Set up the DevEco Studio development environment.The DevEco Studio development environment needs to depend on the network environment. It needs to be connected to the network to ensure the normal use of the tool.The development environment can be configured according to the following two situations - 1.If you can directly access the Internet, just download the HarmonyOS SDK - 2.If the network cannot access the Internet directly, it can be accessed through a proxy server -• Generate secret key and apply for certificate - -User guide -• Download this Project -• Open HUAWEI DevEco Studio, click File> Open> Then select and open this Project -• Click Build> Build App(s)/Hap(s)>Build Debug Hap(s) to compile the hap package -• Click Run> Run 'entry' to run the hap package - -Note -• You can choose to run the hap package on the simulator or the phone. -• If you run it on the phone, you need to configure the signature and certificate information in the project's File> Project Structure> Modules> Signing Configs. - -Licensing -Please see LICENSE for more info. \ No newline at end of file diff --git a/SwitchApplication/RELEASE-NOTES.MD b/SwitchApplication/RELEASE-NOTES.MD deleted file mode 100644 index 9087a1482627f316280b762b6c5adc73c0d438d1..0000000000000000000000000000000000000000 --- a/SwitchApplication/RELEASE-NOTES.MD +++ /dev/null @@ -1 +0,0 @@ -1.0.0.1 Initial version \ No newline at end of file diff --git a/SwitchApplication/build.gradle b/SwitchApplication/build.gradle index 2ac7b7a5b5ab94280b3b09df2a8326d0c65ac8d3..9cf74c205fc884ae2c6796ce2298ecbe3f40672d 100644 --- a/SwitchApplication/build.gradle +++ b/SwitchApplication/build.gradle @@ -1,13 +1,11 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. apply plugin: 'com.huawei.ohos.app' +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 5 - } + compileSdkVersion 6 } - + buildscript { repositories { maven { @@ -16,11 +14,10 @@ buildscript { maven { url 'https://developer.huawei.com/repo/' } - jcenter() } dependencies { - classpath 'com.huawei.ohos:hap:2.4.5.0' - classpath 'com.huawei.ohos:decctest:1.2.4.1' + classpath 'com.huawei.ohos:hap:2.4.5.5' + classpath 'com.huawei.ohos:decctest:1.2.5.1' } } @@ -32,6 +29,5 @@ allprojects { maven { url 'https://developer.huawei.com/repo/' } - jcenter() } } diff --git a/SwitchApplication/entry/.gitignore b/SwitchApplication/entry/.gitignore index 796b96d1c402326528b4ba3c12ee9d92d0e212e9..7d5b7a94f4dcf381f03ff21f28f8a2494b58023f 100644 --- a/SwitchApplication/entry/.gitignore +++ b/SwitchApplication/entry/.gitignore @@ -1 +1,2 @@ /build +/node_modules diff --git a/SwitchApplication/entry/build.gradle b/SwitchApplication/entry/build.gradle index 1a3d6e2c2f8b9b19915a8cac2589093936210086..cccb71cae91018743841ab76aeb19c595f4ed847 100644 --- a/SwitchApplication/entry/build.gradle +++ b/SwitchApplication/entry/build.gradle @@ -1,9 +1,9 @@ apply plugin: 'com.huawei.ohos.hap' -apply plugin: 'com.huawei.ohos.decctest' +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 ohos { - compileSdkVersion 5 + compileSdkVersion 6 defaultConfig { - compatibleSdkVersion 5 + compatibleSdkVersion 6 } buildTypes { release { @@ -13,16 +13,11 @@ ohos { } } } - compileOptions { annotationEnabled true } + + supportSystem "standard" } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - implementation 'android.arch.persistence.room:runtime:1.1.1' - testCompile 'junit:junit:4.12' - - -} -decc { - supportType = ['html', 'xml'] + testImplementation 'junit:junit:4.13' } diff --git a/SwitchApplication/entry/src/main/config.json b/SwitchApplication/entry/src/main/config.json index 251d271536fa4d876b012355a68b2d0d4ba9ba13..94b41b26eaff5875a65d1ad96095333b0356918d 100644 --- a/SwitchApplication/entry/src/main/config.json +++ b/SwitchApplication/entry/src/main/config.json @@ -9,9 +9,9 @@ }, "deviceConfig": {}, "module": { - "package": "com.huawei.cookbook", + "package": "com.huawei.switchapplication", "name": ".MyApplication", - "mainAbility": "com.huawei.cookbook.MainAbility", + "mainAbility": "com.huawei.switchapplication.MainAbility", "deviceType": [ "phone" ], @@ -33,9 +33,11 @@ ] } ], - "name": "com.huawei.cookbook.MainAbility", + "orientation": "unspecified", + "name": "com.huawei.switchapplication.MainAbility", "icon": "$media:icon", "description": "$string:mainability_description", + "formsEnabled": false, "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" @@ -49,7 +51,7 @@ "name": "default", "window": { "designWidth": 720, - "autoDesignWidth": true + "autoDesignWidth": false } } ] diff --git a/SwitchApplication/entry/src/main/java/com/huawei/cookbook/MainAbility.java b/SwitchApplication/entry/src/main/java/com/huawei/cookbook/MainAbility.java deleted file mode 100644 index b6b069e2d058d44a4e69c0fc994d18f79b16d0b1..0000000000000000000000000000000000000000 --- a/SwitchApplication/entry/src/main/java/com/huawei/cookbook/MainAbility.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook; - -import ohos.aafwk.content.Intent; -import ohos.ace.ability.AceAbility; - -/** - * mainAbility - * - * @since 2021-08-01 - * - */ -public class MainAbility extends AceAbility { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - } - - @Override - public void onStop() { - super.onStop(); - } -} diff --git a/SwitchApplication/entry/src/main/java/com/huawei/cookbook/MyApplication.java b/SwitchApplication/entry/src/main/java/com/huawei/cookbook/MyApplication.java deleted file mode 100644 index 6cedbab02ce50255c20556435d2e2360659ff817..0000000000000000000000000000000000000000 --- a/SwitchApplication/entry/src/main/java/com/huawei/cookbook/MyApplication.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook; - -import ohos.aafwk.ability.AbilityPackage; - -/** - * myApplication - * - * @since 2021-08-01 - * - */ -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/SwitchApplication/entry/src/main/js/default/app.js b/SwitchApplication/entry/src/main/js/default/app.js index aedcefe0054c6e16c40491f4d1abc20a4dc1c6ef..6d060ffe5682c19fc83e2274a9e62cbc40a655f8 100644 --- a/SwitchApplication/entry/src/main/js/default/app.js +++ b/SwitchApplication/entry/src/main/js/default/app.js @@ -1,8 +1,8 @@ export default { onCreate() { - console.info('AceApplication onCreate'); + console.info("Application onCreate"); }, onDestroy() { - console.info('AceApplication onDestroy'); + console.info("Application onDestroy"); } }; diff --git a/SwitchApplication/entry/src/main/js/default/i18n/en-US.json b/SwitchApplication/entry/src/main/js/default/i18n/en-US.json index e63c70d978a3a53be988388c87182f81785e170c..08e34eac912bf2651eefc20e26aa479b5e4e7ec2 100644 --- a/SwitchApplication/entry/src/main/js/default/i18n/en-US.json +++ b/SwitchApplication/entry/src/main/js/default/i18n/en-US.json @@ -1,6 +1,11 @@ { "strings": { "hello": "Hello", - "world": "World" + "world": "World", + "page": "Second Page", + "next": "Next Page", + "back": "Back" + }, + "Files": { } } \ No newline at end of file diff --git a/SwitchApplication/entry/src/main/js/default/i18n/zh-CN.json b/SwitchApplication/entry/src/main/js/default/i18n/zh-CN.json index de6ee5748322f44942c1b003319d8e66c837675f..3dd53b3a8b808aec9396fa663cb00ef22ba61e0a 100644 --- a/SwitchApplication/entry/src/main/js/default/i18n/zh-CN.json +++ b/SwitchApplication/entry/src/main/js/default/i18n/zh-CN.json @@ -1,6 +1,11 @@ { "strings": { "hello": "您好", - "world": "世界" + "world": "世界", + "page": "第二页", + "next": "下一页", + "back": "返回" + }, + "Files": { } } \ No newline at end of file diff --git a/SwitchApplication/entry/src/main/resources/base/element/string.json b/SwitchApplication/entry/src/main/resources/base/element/string.json index 406aa4f927f77e4a0cc5527d74ac1f649604c723..0bae6bd40f7360d5d818998221b199d3ec0f69c0 100644 --- a/SwitchApplication/entry/src/main/resources/base/element/string.json +++ b/SwitchApplication/entry/src/main/resources/base/element/string.json @@ -2,7 +2,7 @@ "string": [ { "name": "entry_MainAbility", - "value": "switch_chart" + "value": "entry_MainAbility" }, { "name": "mainability_description", diff --git a/SwitchApplication/entry/src/ohosTest/java/com/huawei/cookbook/ExampleOhosTest.java b/SwitchApplication/entry/src/ohosTest/java/com/huawei/cookbook/ExampleOhosTest.java deleted file mode 100644 index bf27899ae844b18c931cc6c9841267cbdb2c717c..0000000000000000000000000000000000000000 --- a/SwitchApplication/entry/src/ohosTest/java/com/huawei/cookbook/ExampleOhosTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.huawei.cookbook; - -import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class ExampleOhosTest { - @Test - public void testBundleName() { - final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName(); - assertEquals("com.huawei.cookbook", actualBundleName); - } -} \ No newline at end of file diff --git a/SwitchApplication/entry/src/ohosTest/js/default/app.js b/SwitchApplication/entry/src/ohosTest/js/default/app.js deleted file mode 100644 index 55b67e96deb821033f71d30b6fff05efdeb0d901..0000000000000000000000000000000000000000 --- a/SwitchApplication/entry/src/ohosTest/js/default/app.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - onCreate() { - console.info('TestApplication onCreate'); - }, - onDestroy() { - console.info('TestApplication onDestroy'); - } -}; diff --git a/SwitchApplication/entry/src/ohosTest/js/default/i18n/en-US.json b/SwitchApplication/entry/src/ohosTest/js/default/i18n/en-US.json deleted file mode 100644 index 55561b83737c3c31d082fbfa11e5fc987a351104..0000000000000000000000000000000000000000 --- a/SwitchApplication/entry/src/ohosTest/js/default/i18n/en-US.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - }, - "Files": { - } -} \ No newline at end of file diff --git a/SwitchApplication/entry/src/ohosTest/js/default/i18n/zh-CN.json b/SwitchApplication/entry/src/ohosTest/js/default/i18n/zh-CN.json deleted file mode 100644 index cce1af06761a42add0cac1a0567aa3237eda8cb4..0000000000000000000000000000000000000000 --- a/SwitchApplication/entry/src/ohosTest/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - }, - "Files": { - } -} \ No newline at end of file diff --git a/SwitchApplication/entry/src/ohosTest/js/default/pages/index/index.css b/SwitchApplication/entry/src/ohosTest/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/SwitchApplication/entry/src/ohosTest/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/SwitchApplication/entry/src/ohosTest/js/default/pages/index/index.hml b/SwitchApplication/entry/src/ohosTest/js/default/pages/index/index.hml deleted file mode 100644 index f64b040a5ae394dbaa5e185e1ecd4f4556b92184..0000000000000000000000000000000000000000 --- a/SwitchApplication/entry/src/ohosTest/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{ $t('strings.hello') }} {{ title }} - -
diff --git a/SwitchApplication/entry/src/ohosTest/js/default/pages/index/index.js b/SwitchApplication/entry/src/ohosTest/js/default/pages/index/index.js deleted file mode 100644 index 8be2df2479a8da755ed800ad70d2b6247e21b8a2..0000000000000000000000000000000000000000 --- a/SwitchApplication/entry/src/ohosTest/js/default/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -import file from '@system.file' -import app from '@system.app' -import device from '@system.device' -import router from '@system.router' -import {Core, Constant, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - const reportExtend = new ReportExtend(file) - const instrumentLog = new InstrumentLog({ - 'id': 'report', - 'version': '1.0.3' - }) - core.addService('expect', expectExtend) - core.addService('report', reportExtend) - core.addService('report', instrumentLog) - core.init() - core.subscribeEvent('spec', instrumentLog) - core.subscribeEvent('suite', instrumentLog) - core.subscribeEvent('task', instrumentLog) - - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} \ No newline at end of file diff --git a/SwitchApplication/entry/src/ohosTest/js/test/ExampleJsunit.test.js b/SwitchApplication/entry/src/ohosTest/js/test/ExampleJsunit.test.js deleted file mode 100644 index b6d74caed96ddede98edd1bc9292f6568cd1cfd1..0000000000000000000000000000000000000000 --- a/SwitchApplication/entry/src/ohosTest/js/test/ExampleJsunit.test.js +++ /dev/null @@ -1,10 +0,0 @@ -import app from '@system.app' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -describe('appInfoTest', function () { - it('app_info_test_001', 0, function () { - var info = app.getInfo() - expect(info.versionName).assertEqual('1.0') - expect(info.versionCode).assertEqual('3') - }) -}) \ No newline at end of file diff --git a/SwitchApplication/entry/src/ohosTest/js/test/List.test.js b/SwitchApplication/entry/src/ohosTest/js/test/List.test.js deleted file mode 100644 index 305eb5bb254cd4802afaffebe68fca2f9436159f..0000000000000000000000000000000000000000 --- a/SwitchApplication/entry/src/ohosTest/js/test/List.test.js +++ /dev/null @@ -1 +0,0 @@ -require('./ExampleJsunit.test.js') \ No newline at end of file diff --git a/SwitchApplication/entry/src/ohosTest/resources/base/element/string.json b/SwitchApplication/entry/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index c6ec5946072aa9bd22153c957e88f8bd9d1f824d..0000000000000000000000000000000000000000 --- a/SwitchApplication/entry/src/ohosTest/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "SwitchApplication" - }, - { - "name": "mainability_description", - "value": "hap sample empty page" - } - ] -} diff --git a/SwitchApplication/entry/src/ohosTest/resources/base/media/icon.png b/SwitchApplication/entry/src/ohosTest/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/SwitchApplication/entry/src/ohosTest/resources/base/media/icon.png and /dev/null differ diff --git a/ToolbarApplication/LICENSE b/ToolbarApplication/LICENSE deleted file mode 100644 index 7c357dc828cf7d8c783f10ed6bb1bac8a1e903c1..0000000000000000000000000000000000000000 --- a/ToolbarApplication/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - Copyright (c) 2021 Huawei Device Co., Ltd. - - Licensed under the Apache License,Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -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/ToolbarApplication/README.md b/ToolbarApplication/README.md deleted file mode 100644 index 0952b16168d032b5df74142f50001fbf647fe713..0000000000000000000000000000000000000000 --- a/ToolbarApplication/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# ToolbarApplication -简介 -• 此Demo使用JS UI中的toolbar组件以及toolbar-item组件,实现一个面板切换的效果,用户可以利用toolbar 组件切换不同的页面。 - -安装要求 -• 安装DevEco Studio -• 设置DevEco Studio开发环境。DevEco Studio开发环境需要连接到网络,以确保该正常使用。可以根据以下两种情况配置开发环境: - 1.如果您可以直接访问Internet,则只需下载HarmonyOS SDK - 2.如果网络无法直接访问Internet,则可以通过代理服务器进行访问 -• 生成密钥并申请证书 - -用户指南 -• 下载此项目 -• 打开HUAWEI DevEco Studio,单击File> Open选择此ComponentCodelab -• 单击Build> Build App(s)/Hap(s)>Build Debug Hap(s)以编译hap软件包 -• 单击Run> Run 'entry'以运行hap包 - -注意 -• 您可以选择在模拟器或真机上运行hap软件包。 -• 如果在真机上运行它,则需要在项目的File> Project Structure> Modules> Signing Configs中配置签名和证书信息。 - -许可 -请参阅LICENSE文件以获得更多信息。 - -What is it? -This demo uses the toolbar and toolbar-item components in the JS UI to implement a panel switchover effect. Users can use the toolbar component to switch between different pages. - -Installation requirements -• Install DevEco Studio -• Set up the DevEco Studio development environment.The DevEco Studio development environment needs to depend on the network environment. It needs to be connected to the network to ensure the normal use of the tool.The development environment can be configured according to the following two situations - 1.If you can directly access the Internet, just download the HarmonyOS SDK - 2.If the network cannot access the Internet directly, it can be accessed through a proxy server -• Generate secret key and apply for certificate - -User guide -• Download this Project -• Open HUAWEI DevEco Studio, click File> Open> Then select and open this Project -• Click Build> Build App(s)/Hap(s)>Build Debug Hap(s) to compile the hap package -• Click Run> Run 'entry' to run the hap package - -Note -• You can choose to run the hap package on the simulator or the phone. -• If you run it on the phone, you need to configure the signature and certificate information in the project's File> Project Structure> Modules> Signing Configs. - -Licensing -Please see LICENSE for more info. \ No newline at end of file diff --git a/ToolbarApplication/RELEASE-NOTES.MD b/ToolbarApplication/RELEASE-NOTES.MD deleted file mode 100644 index 9087a1482627f316280b762b6c5adc73c0d438d1..0000000000000000000000000000000000000000 --- a/ToolbarApplication/RELEASE-NOTES.MD +++ /dev/null @@ -1 +0,0 @@ -1.0.0.1 Initial version \ No newline at end of file diff --git a/ToolbarApplication/entry/proguard-rules.pro b/ToolbarApplication/entry/proguard-rules.pro deleted file mode 100644 index f7666e47561d514b2a76d5a7dfbb43ede86da92a..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/proguard-rules.pro +++ /dev/null @@ -1 +0,0 @@ -# config module specific ProGuard rules here. \ No newline at end of file diff --git a/ToolbarApplication/entry/src/main/java/com/huawei/cookbook/MainAbility.java b/ToolbarApplication/entry/src/main/java/com/huawei/cookbook/MainAbility.java deleted file mode 100644 index 3234f850f728adc5dd5c36c2b154c589c6169181..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/java/com/huawei/cookbook/MainAbility.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook; - -import ohos.ace.ability.AceAbility; -import ohos.aafwk.content.Intent; - -public class MainAbility extends AceAbility { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - } - - @Override - public void onStop() { - super.onStop(); - } -} diff --git a/ToolbarApplication/entry/src/main/java/com/huawei/cookbook/MyApplication.java b/ToolbarApplication/entry/src/main/java/com/huawei/cookbook/MyApplication.java deleted file mode 100644 index 895a036f1ce5aa807c5fbe71fd9fcb37243b26cb..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/java/com/huawei/cookbook/MyApplication.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook; - -import ohos.aafwk.ability.AbilityPackage; - -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/ToolbarApplication/entry/src/main/js/default/app.js b/ToolbarApplication/entry/src/main/js/default/app.js deleted file mode 100644 index aedcefe0054c6e16c40491f4d1abc20a4dc1c6ef..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/js/default/app.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } -}; diff --git a/ToolbarApplication/entry/src/main/js/default/common/Icon/1.png b/ToolbarApplication/entry/src/main/js/default/common/Icon/1.png deleted file mode 100644 index af131260fce2a790f4d4f255927ab17968d39bd9..0000000000000000000000000000000000000000 Binary files a/ToolbarApplication/entry/src/main/js/default/common/Icon/1.png and /dev/null differ diff --git a/ToolbarApplication/entry/src/main/js/default/common/Icon/2.png b/ToolbarApplication/entry/src/main/js/default/common/Icon/2.png deleted file mode 100644 index 95bb6c80baf02f32036632ea4538b94be4abc75c..0000000000000000000000000000000000000000 Binary files a/ToolbarApplication/entry/src/main/js/default/common/Icon/2.png and /dev/null differ diff --git a/ToolbarApplication/entry/src/main/js/default/common/Icon/3.png b/ToolbarApplication/entry/src/main/js/default/common/Icon/3.png deleted file mode 100644 index 0455e3c3326288bd79c70b69849ad615bd33a40a..0000000000000000000000000000000000000000 Binary files a/ToolbarApplication/entry/src/main/js/default/common/Icon/3.png and /dev/null differ diff --git a/ToolbarApplication/entry/src/main/js/default/common/Icon/4.png b/ToolbarApplication/entry/src/main/js/default/common/Icon/4.png deleted file mode 100644 index 23dfcd370d7492b1c1094edce418dcf04a0987c9..0000000000000000000000000000000000000000 Binary files a/ToolbarApplication/entry/src/main/js/default/common/Icon/4.png and /dev/null differ diff --git a/ToolbarApplication/entry/src/main/js/default/common/Icon/5.png b/ToolbarApplication/entry/src/main/js/default/common/Icon/5.png deleted file mode 100644 index 9b4724a87460d5655d6dfe4579664906b5be301a..0000000000000000000000000000000000000000 Binary files a/ToolbarApplication/entry/src/main/js/default/common/Icon/5.png and /dev/null differ diff --git a/ToolbarApplication/entry/src/main/js/default/common/fifth/second.hml b/ToolbarApplication/entry/src/main/js/default/common/fifth/second.hml deleted file mode 100644 index 3819903ee503d30fa34f969e5dd400a6f484f880..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/js/default/common/fifth/second.hml +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/ToolbarApplication/entry/src/main/js/default/common/first/second.css b/ToolbarApplication/entry/src/main/js/default/common/first/second.css deleted file mode 100644 index ce4a2184b50f8339f6b31ae524ad77e22a1cd531..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/js/default/common/first/second.css +++ /dev/null @@ -1,10 +0,0 @@ -.container { - display: flex; - justify-content: center; - align-items: center; - left: 0px; - top: 0px; - width: 100%; - height: 100%; -} - diff --git a/ToolbarApplication/entry/src/main/js/default/common/first/second.hml b/ToolbarApplication/entry/src/main/js/default/common/first/second.hml deleted file mode 100644 index 035844a221f086dc5ba66a6d5f221038929912bb..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/js/default/common/first/second.hml +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/ToolbarApplication/entry/src/main/js/default/common/fourth/second.css b/ToolbarApplication/entry/src/main/js/default/common/fourth/second.css deleted file mode 100644 index f85382f907c76c849c10d29168468c6a6165ecb0..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/js/default/common/fourth/second.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - display: flex; - justify-content: center; - align-items: center; - left: 0px; - top: 0px; - width: 100%; - height: 100%; -} diff --git a/ToolbarApplication/entry/src/main/js/default/common/fourth/second.hml b/ToolbarApplication/entry/src/main/js/default/common/fourth/second.hml deleted file mode 100644 index 813d121f847d2cc37f20dc4cadcb28cbfba553f3..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/js/default/common/fourth/second.hml +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/ToolbarApplication/entry/src/main/js/default/common/images/Wallpaper.png b/ToolbarApplication/entry/src/main/js/default/common/images/Wallpaper.png deleted file mode 100644 index 60d4841a80eb20c63de74306cb7f8350d6a85c48..0000000000000000000000000000000000000000 Binary files a/ToolbarApplication/entry/src/main/js/default/common/images/Wallpaper.png and /dev/null differ diff --git a/ToolbarApplication/entry/src/main/js/default/common/images/bg-tv.jpg b/ToolbarApplication/entry/src/main/js/default/common/images/bg-tv.jpg deleted file mode 100644 index 86fc07358eea5c1474bc833fca07c6d4d8698a89..0000000000000000000000000000000000000000 Binary files a/ToolbarApplication/entry/src/main/js/default/common/images/bg-tv.jpg and /dev/null differ diff --git a/ToolbarApplication/entry/src/main/js/default/common/images/fc-1.png b/ToolbarApplication/entry/src/main/js/default/common/images/fc-1.png deleted file mode 100644 index 1e0f64b29be14c709973346ab29614b3f593e787..0000000000000000000000000000000000000000 Binary files a/ToolbarApplication/entry/src/main/js/default/common/images/fc-1.png and /dev/null differ diff --git a/ToolbarApplication/entry/src/main/js/default/common/images/fc-2.png b/ToolbarApplication/entry/src/main/js/default/common/images/fc-2.png deleted file mode 100644 index d0027a28c7cefcee11dc58a5f30849983e4ccec9..0000000000000000000000000000000000000000 Binary files a/ToolbarApplication/entry/src/main/js/default/common/images/fc-2.png and /dev/null differ diff --git a/ToolbarApplication/entry/src/main/js/default/common/images/fc-3.png b/ToolbarApplication/entry/src/main/js/default/common/images/fc-3.png deleted file mode 100644 index 7a169f54a2a7007cee68810a176773ec1aee40e5..0000000000000000000000000000000000000000 Binary files a/ToolbarApplication/entry/src/main/js/default/common/images/fc-3.png and /dev/null differ diff --git a/ToolbarApplication/entry/src/main/js/default/common/images/fc-4.png b/ToolbarApplication/entry/src/main/js/default/common/images/fc-4.png deleted file mode 100644 index aedabe2df4293176914f378075f41194edab24cc..0000000000000000000000000000000000000000 Binary files a/ToolbarApplication/entry/src/main/js/default/common/images/fc-4.png and /dev/null differ diff --git a/ToolbarApplication/entry/src/main/js/default/common/images/fc-5.png b/ToolbarApplication/entry/src/main/js/default/common/images/fc-5.png deleted file mode 100644 index 55bc94f213c2da8c203cff05176bc0ff25d73b82..0000000000000000000000000000000000000000 Binary files a/ToolbarApplication/entry/src/main/js/default/common/images/fc-5.png and /dev/null differ diff --git a/ToolbarApplication/entry/src/main/js/default/common/second/second.css b/ToolbarApplication/entry/src/main/js/default/common/second/second.css deleted file mode 100644 index ce4a2184b50f8339f6b31ae524ad77e22a1cd531..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/js/default/common/second/second.css +++ /dev/null @@ -1,10 +0,0 @@ -.container { - display: flex; - justify-content: center; - align-items: center; - left: 0px; - top: 0px; - width: 100%; - height: 100%; -} - diff --git a/ToolbarApplication/entry/src/main/js/default/common/second/second.hml b/ToolbarApplication/entry/src/main/js/default/common/second/second.hml deleted file mode 100644 index 6a3251c413c728aea861491b73b99245d024b763..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/js/default/common/second/second.hml +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/ToolbarApplication/entry/src/main/js/default/common/third/second.css b/ToolbarApplication/entry/src/main/js/default/common/third/second.css deleted file mode 100644 index ce4a2184b50f8339f6b31ae524ad77e22a1cd531..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/js/default/common/third/second.css +++ /dev/null @@ -1,10 +0,0 @@ -.container { - display: flex; - justify-content: center; - align-items: center; - left: 0px; - top: 0px; - width: 100%; - height: 100%; -} - diff --git a/ToolbarApplication/entry/src/main/js/default/common/third/second.hml b/ToolbarApplication/entry/src/main/js/default/common/third/second.hml deleted file mode 100644 index 4cebe8f79d96609423791557424dbed7ca61277b..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/js/default/common/third/second.hml +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/ToolbarApplication/entry/src/main/js/default/i18n/en-US.json b/ToolbarApplication/entry/src/main/js/default/i18n/en-US.json deleted file mode 100644 index e63c70d978a3a53be988388c87182f81785e170c..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } -} \ No newline at end of file diff --git a/ToolbarApplication/entry/src/main/js/default/i18n/zh-CN.json b/ToolbarApplication/entry/src/main/js/default/i18n/zh-CN.json deleted file mode 100644 index de6ee5748322f44942c1b003319d8e66c837675f..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } -} \ No newline at end of file diff --git a/ToolbarApplication/entry/src/main/js/default/pages/index/index.css b/ToolbarApplication/entry/src/main/js/default/pages/index/index.css deleted file mode 100644 index a5d4f67341b67500f41229650ba71968f614cef9..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,5 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} diff --git a/ToolbarApplication/entry/src/main/js/default/pages/index/index.hml b/ToolbarApplication/entry/src/main/js/default/pages/index/index.hml deleted file mode 100644 index f7cd4c6d2e1e019a3d5c2743e1d839d617fe43c0..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -
- - - - - - - - - - - - - - - - - -
diff --git a/ToolbarApplication/entry/src/main/js/default/pages/index/index.js b/ToolbarApplication/entry/src/main/js/default/pages/index/index.js deleted file mode 100644 index 0223f7c483580deb2b142797fe9de3ba9d081afa..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,92 +0,0 @@ -export default { - data: { - fontWeight0: 'bolder', - fontWeight1: null, - fontWeight2: null, - fontWeight3: null, - fontWeight4: null, - display1: 'flex', - display2: 'none', - display3: 'none', - display4: 'none', - display5: 'none', - imgGr: 'common/Icon/1.png', - imgDu: 'common/Icon/2.png', - imgGu: 'common/Icon/3.png', - imgWz: 'common/Icon/4.png', - imgXx: 'common/Icon/5.png' - }, - change(e) { - if (e.currentTarget.attr.value === 'Option 1') { - this.function1(); - } else if (e.currentTarget.attr.value === 'Option 2') { - this.function2(); - } else if (e.currentTarget.attr.value === 'Option 3') { - this.function3(); - } else if (e.currentTarget.attr.value === 'Option 4') { - this.function4(); - } else if (e.currentTarget.attr.value === 'Option 5') { - this.function5(); - } - }, - function1() { - this.fontWeight0 = 'bolder'; - this.fontWeight1 = 'normal'; - this.fontWeight2 = 'normal'; - this.fontWeight3 = 'normal'; - this.fontWeight4 = 'normal'; - this.display1 = 'flex'; - this.display2 = 'none'; - this.display3 = 'none'; - this.display4 = 'none'; - this.display5 = 'none'; - }, - function2() { - this.fontWeight0 = 'normal'; - this.fontWeight1 = 'bolder'; - this.fontWeight2 = 'normal'; - this.fontWeight3 = 'normal'; - this.fontWeight4 = 'normal'; - this.display1 = 'none'; - this.display2 = 'flex'; - this.display3 = 'none'; - this.display4 = 'none'; - this.display5 = 'none'; - }, - function3() { - this.fontWeight0 = 'normal'; - this.fontWeight1 = 'normal'; - this.fontWeight2 = 'bolder'; - this.fontWeight3 = 'normal'; - this.fontWeight4 = 'normal'; - this.display1 = 'none'; - this.display2 = 'none'; - this.display3 = 'flex'; - this.display4 = 'none'; - this.display5 = 'none'; - }, - function4() { - this.fontWeight0 = 'normal'; - this.fontWeight1 = 'normal'; - this.fontWeight2 = 'normal'; - this.fontWeight3 = 'bolder'; - this.fontWeight4 = 'normal'; - this.display1 = 'none'; - this.display2 = 'none'; - this.display3 = 'none'; - this.display4 = 'flex'; - this.display5 = 'none'; - }, - function5() { - this.fontWeight0 = 'normal'; - this.fontWeight1 = 'normal'; - this.fontWeight2 = 'normal'; - this.fontWeight3 = 'normal'; - this.fontWeight4 = 'bolder'; - this.display1 = 'none'; - this.display2 = 'none'; - this.display3 = 'none'; - this.display4 = 'none'; - this.display5 = 'flex'; - } -}; diff --git a/ToolbarApplication/entry/src/main/resources/base/media/icon.png b/ToolbarApplication/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/ToolbarApplication/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/ToolbarApplication/entry/src/ohosTest/java/com/huawei/cookbook/ExampleOhosTest.java b/ToolbarApplication/entry/src/ohosTest/java/com/huawei/cookbook/ExampleOhosTest.java deleted file mode 100644 index bf27899ae844b18c931cc6c9841267cbdb2c717c..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/ohosTest/java/com/huawei/cookbook/ExampleOhosTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.huawei.cookbook; - -import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class ExampleOhosTest { - @Test - public void testBundleName() { - final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName(); - assertEquals("com.huawei.cookbook", actualBundleName); - } -} \ No newline at end of file diff --git a/ToolbarApplication/entry/src/ohosTest/js/default/app.js b/ToolbarApplication/entry/src/ohosTest/js/default/app.js deleted file mode 100644 index 55b67e96deb821033f71d30b6fff05efdeb0d901..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/ohosTest/js/default/app.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - onCreate() { - console.info('TestApplication onCreate'); - }, - onDestroy() { - console.info('TestApplication onDestroy'); - } -}; diff --git a/ToolbarApplication/entry/src/ohosTest/js/default/i18n/en-US.json b/ToolbarApplication/entry/src/ohosTest/js/default/i18n/en-US.json deleted file mode 100644 index 55561b83737c3c31d082fbfa11e5fc987a351104..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/ohosTest/js/default/i18n/en-US.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - }, - "Files": { - } -} \ No newline at end of file diff --git a/ToolbarApplication/entry/src/ohosTest/js/default/i18n/zh-CN.json b/ToolbarApplication/entry/src/ohosTest/js/default/i18n/zh-CN.json deleted file mode 100644 index cce1af06761a42add0cac1a0567aa3237eda8cb4..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/ohosTest/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - }, - "Files": { - } -} \ No newline at end of file diff --git a/ToolbarApplication/entry/src/ohosTest/js/default/pages/index/index.css b/ToolbarApplication/entry/src/ohosTest/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/ohosTest/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/ToolbarApplication/entry/src/ohosTest/js/default/pages/index/index.hml b/ToolbarApplication/entry/src/ohosTest/js/default/pages/index/index.hml deleted file mode 100644 index f64b040a5ae394dbaa5e185e1ecd4f4556b92184..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/ohosTest/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{ $t('strings.hello') }} {{ title }} - -
diff --git a/ToolbarApplication/entry/src/ohosTest/js/default/pages/index/index.js b/ToolbarApplication/entry/src/ohosTest/js/default/pages/index/index.js deleted file mode 100644 index 8be2df2479a8da755ed800ad70d2b6247e21b8a2..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/ohosTest/js/default/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -import file from '@system.file' -import app from '@system.app' -import device from '@system.device' -import router from '@system.router' -import {Core, Constant, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - const reportExtend = new ReportExtend(file) - const instrumentLog = new InstrumentLog({ - 'id': 'report', - 'version': '1.0.3' - }) - core.addService('expect', expectExtend) - core.addService('report', reportExtend) - core.addService('report', instrumentLog) - core.init() - core.subscribeEvent('spec', instrumentLog) - core.subscribeEvent('suite', instrumentLog) - core.subscribeEvent('task', instrumentLog) - - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} \ No newline at end of file diff --git a/ToolbarApplication/entry/src/ohosTest/js/test/ExampleJsunit.test.js b/ToolbarApplication/entry/src/ohosTest/js/test/ExampleJsunit.test.js deleted file mode 100644 index b6d74caed96ddede98edd1bc9292f6568cd1cfd1..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/ohosTest/js/test/ExampleJsunit.test.js +++ /dev/null @@ -1,10 +0,0 @@ -import app from '@system.app' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -describe('appInfoTest', function () { - it('app_info_test_001', 0, function () { - var info = app.getInfo() - expect(info.versionName).assertEqual('1.0') - expect(info.versionCode).assertEqual('3') - }) -}) \ No newline at end of file diff --git a/ToolbarApplication/entry/src/ohosTest/js/test/List.test.js b/ToolbarApplication/entry/src/ohosTest/js/test/List.test.js deleted file mode 100644 index 305eb5bb254cd4802afaffebe68fca2f9436159f..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/ohosTest/js/test/List.test.js +++ /dev/null @@ -1 +0,0 @@ -require('./ExampleJsunit.test.js') \ No newline at end of file diff --git a/ToolbarApplication/entry/src/ohosTest/resources/base/element/string.json b/ToolbarApplication/entry/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index 2daf0c5f30d2d462b8b82adcad6478688864e68b..0000000000000000000000000000000000000000 --- a/ToolbarApplication/entry/src/ohosTest/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "ToolbarApplication" - }, - { - "name": "mainability_description", - "value": "hap sample empty page" - } - ] -} diff --git a/ToolbarApplication/entry/src/ohosTest/resources/base/media/icon.png b/ToolbarApplication/entry/src/ohosTest/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/ToolbarApplication/entry/src/ohosTest/resources/base/media/icon.png and /dev/null differ diff --git a/ToolbarApplication/gradle/wrapper/gradle-wrapper.jar b/ToolbarApplication/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 490fda8577df6c95960ba7077c43220e5bb2c0d9..0000000000000000000000000000000000000000 Binary files a/ToolbarApplication/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/ToolbarApplication/gradle/wrapper/gradle-wrapper.properties b/ToolbarApplication/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index f59159e865d4b59feb1b8c44b001f62fc5d58df4..0000000000000000000000000000000000000000 --- a/ToolbarApplication/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/ToolbarApplication/settings.gradle b/ToolbarApplication/settings.gradle deleted file mode 100644 index 4773db73233a570c2d0c01a22e75321acfbf7a07..0000000000000000000000000000000000000000 --- a/ToolbarApplication/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':entry' diff --git a/VideoApplication/LICENSE b/VideoApplication/LICENSE deleted file mode 100644 index 7c357dc828cf7d8c783f10ed6bb1bac8a1e903c1..0000000000000000000000000000000000000000 --- a/VideoApplication/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - Copyright (c) 2021 Huawei Device Co., Ltd. - - Licensed under the Apache License,Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -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/VideoApplication/README.md b/VideoApplication/README.md deleted file mode 100644 index 32ede2abaf1a267ef80586612cbc44ea0b85834c..0000000000000000000000000000000000000000 --- a/VideoApplication/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# VideoApplication -简介 -• 此Demo使用JS UI中的video组件,实现视频播放。您可以通过video自带的控制栏进行暂停、播放、全屏、退出全屏操作。 - -安装要求 -• 安装DevEco Studio -• 设置DevEco Studio开发环境。DevEco Studio开发环境需要连接到网络,以确保该正常使用。可以根据以下两种情况配置开发环境: - 1.如果您可以直接访问Internet,则只需下载HarmonyOS SDK - 2.如果网络无法直接访问Internet,则可以通过代理服务器进行访问 -• 生成密钥并申请证书 - -用户指南 -• 下载此项目 -• 打开HUAWEI DevEco Studio,单击File> Open选择此ComponentCodelab -• 单击Build> Build App(s)/Hap(s)>Build Debug Hap(s)以编译hap软件包 -• 单击Run> Run 'entry'以运行hap包 - -注意 -• 您可以选择在模拟器或真机上运行hap软件包。 -• 如果在真机上运行它,则需要在项目的File> Project Structure> Modules> Signing Configs中配置签名和证书信息。 - -许可 -请参阅LICENSE文件以获得更多信息。 - -What is it? -This demo uses the video component of the JS UI to play videos. You can use the video control bar to pause, play, full screen, or exit full screen. - -Installation requirements -• Install DevEco Studio -• Set up the DevEco Studio development environment.The DevEco Studio development environment needs to depend on the network environment. It needs to be connected to the network to ensure the normal use of the tool.The development environment can be configured according to the following two situations - 1.If you can directly access the Internet, just download the HarmonyOS SDK - 2.If the network cannot access the Internet directly, it can be accessed through a proxy server -• Generate secret key and apply for certificate - -User guide -• Download this Project -• Open HUAWEI DevEco Studio, click File> Open> Then select and open this Project -• Click Build> Build App(s)/Hap(s)>Build Debug Hap(s) to compile the hap package -• Click Run> Run 'entry' to run the hap package - -Note -• You can choose to run the hap package on the simulator or the phone. -• If you run it on the phone, you need to configure the signature and certificate information in the project's File> Project Structure> Modules> Signing Configs. - -Licensing -Please see LICENSE for more info. \ No newline at end of file diff --git a/VideoApplication/RELEASE-NOTES.MD b/VideoApplication/RELEASE-NOTES.MD deleted file mode 100644 index 9087a1482627f316280b762b6c5adc73c0d438d1..0000000000000000000000000000000000000000 --- a/VideoApplication/RELEASE-NOTES.MD +++ /dev/null @@ -1 +0,0 @@ -1.0.0.1 Initial version \ No newline at end of file diff --git a/VideoApplication/build.gradle b/VideoApplication/build.gradle deleted file mode 100644 index bf3ca7268bbf5e0ff118207bf08b5fbfdad7011a..0000000000000000000000000000000000000000 --- a/VideoApplication/build.gradle +++ /dev/null @@ -1,38 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -apply plugin: 'com.huawei.ohos.app' - -//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#ZH-CN_TOPIC_0000001154985555__section1112183053510 -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 5 - } -} - -buildscript { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } - dependencies { - classpath 'com.huawei.ohos:hap:2.4.5.0' - classpath 'com.huawei.ohos:decctest:1.2.4.1' - } -} - -allprojects { - repositories { - maven { - url 'https://repo.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } -} diff --git a/VideoApplication/entry/.gitignore b/VideoApplication/entry/.gitignore deleted file mode 100644 index 796b96d1c402326528b4ba3c12ee9d92d0e212e9..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/VideoApplication/entry/build.gradle b/VideoApplication/entry/build.gradle deleted file mode 100644 index 438b0a24d493cdae21758ec071799f2a8888240a..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/build.gradle +++ /dev/null @@ -1,26 +0,0 @@ -apply plugin: 'com.huawei.ohos.hap' -apply plugin: 'com.huawei.ohos.decctest' -//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#ZH-CN_TOPIC_0000001154985555__section1112183053510 -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 5 - } - buildTypes { - release { - proguardOpt { - proguardEnabled false - rulesFiles 'proguard-rules.pro' - } - } - } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - testImplementation 'junit:junit:4.13' - ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' -} -decc { - supportType = ['html','xml'] -} diff --git a/VideoApplication/entry/package.json b/VideoApplication/entry/package.json deleted file mode 100644 index 0967ef424bce6791893e9a57bb952f80fd536e93..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/package.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/VideoApplication/entry/proguard-rules.pro b/VideoApplication/entry/proguard-rules.pro deleted file mode 100644 index f7666e47561d514b2a76d5a7dfbb43ede86da92a..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/proguard-rules.pro +++ /dev/null @@ -1 +0,0 @@ -# config module specific ProGuard rules here. \ No newline at end of file diff --git a/VideoApplication/entry/src/main/config.json b/VideoApplication/entry/src/main/config.json deleted file mode 100644 index 251d271536fa4d876b012355a68b2d0d4ba9ba13..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/main/config.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "app": { - "bundleName": "com.huawei.cookbook", - "vendor": "huawei", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.huawei.cookbook", - "name": ".MyApplication", - "mainAbility": "com.huawei.cookbook.MainAbility", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": false - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "com.huawei.cookbook.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:entry_MainAbility", - "type": "page", - "launchType": "standard" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": true - } - } - ] - } -} \ No newline at end of file diff --git a/VideoApplication/entry/src/main/java/com/huawei/cookbook/MainAbility.java b/VideoApplication/entry/src/main/java/com/huawei/cookbook/MainAbility.java deleted file mode 100644 index b6b069e2d058d44a4e69c0fc994d18f79b16d0b1..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/main/java/com/huawei/cookbook/MainAbility.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook; - -import ohos.aafwk.content.Intent; -import ohos.ace.ability.AceAbility; - -/** - * mainAbility - * - * @since 2021-08-01 - * - */ -public class MainAbility extends AceAbility { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - } - - @Override - public void onStop() { - super.onStop(); - } -} diff --git a/VideoApplication/entry/src/main/java/com/huawei/cookbook/MyApplication.java b/VideoApplication/entry/src/main/java/com/huawei/cookbook/MyApplication.java deleted file mode 100644 index 6cedbab02ce50255c20556435d2e2360659ff817..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/main/java/com/huawei/cookbook/MyApplication.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.cookbook; - -import ohos.aafwk.ability.AbilityPackage; - -/** - * myApplication - * - * @since 2021-08-01 - * - */ -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/VideoApplication/entry/src/main/js/default/app.js b/VideoApplication/entry/src/main/js/default/app.js deleted file mode 100644 index aedcefe0054c6e16c40491f4d1abc20a4dc1c6ef..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/main/js/default/app.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } -}; diff --git a/VideoApplication/entry/src/main/js/default/common/images/Wallpaper.png b/VideoApplication/entry/src/main/js/default/common/images/Wallpaper.png deleted file mode 100644 index 60d4841a80eb20c63de74306cb7f8350d6a85c48..0000000000000000000000000000000000000000 Binary files a/VideoApplication/entry/src/main/js/default/common/images/Wallpaper.png and /dev/null differ diff --git a/VideoApplication/entry/src/main/js/default/common/images/back.png b/VideoApplication/entry/src/main/js/default/common/images/back.png deleted file mode 100644 index 7db2c3d84b2f3427534051b16bfa2e63f501e006..0000000000000000000000000000000000000000 Binary files a/VideoApplication/entry/src/main/js/default/common/images/back.png and /dev/null differ diff --git a/VideoApplication/entry/src/main/js/default/common/images/bg-tv.jpg b/VideoApplication/entry/src/main/js/default/common/images/bg-tv.jpg deleted file mode 100644 index 86fc07358eea5c1474bc833fca07c6d4d8698a89..0000000000000000000000000000000000000000 Binary files a/VideoApplication/entry/src/main/js/default/common/images/bg-tv.jpg and /dev/null differ diff --git a/VideoApplication/entry/src/main/js/default/common/images/next.png b/VideoApplication/entry/src/main/js/default/common/images/next.png deleted file mode 100644 index 0a87bdb015cb61d3b886f896281a8cdf02b4199d..0000000000000000000000000000000000000000 Binary files a/VideoApplication/entry/src/main/js/default/common/images/next.png and /dev/null differ diff --git a/VideoApplication/entry/src/main/js/default/common/images/pause.png b/VideoApplication/entry/src/main/js/default/common/images/pause.png deleted file mode 100644 index e0c8960767affcfad53f0dba39dd1e8e18c93827..0000000000000000000000000000000000000000 Binary files a/VideoApplication/entry/src/main/js/default/common/images/pause.png and /dev/null differ diff --git a/VideoApplication/entry/src/main/js/default/common/images/screenPause.png b/VideoApplication/entry/src/main/js/default/common/images/screenPause.png deleted file mode 100644 index 913f71d16c74a5601bad6fd9241104fbd1e1870b..0000000000000000000000000000000000000000 Binary files a/VideoApplication/entry/src/main/js/default/common/images/screenPause.png and /dev/null differ diff --git a/VideoApplication/entry/src/main/js/default/common/video/1.mp4 b/VideoApplication/entry/src/main/js/default/common/video/1.mp4 deleted file mode 100644 index 592abe4f4551198d5c4c25e346f66e523b21cd18..0000000000000000000000000000000000000000 Binary files a/VideoApplication/entry/src/main/js/default/common/video/1.mp4 and /dev/null differ diff --git a/VideoApplication/entry/src/main/js/default/common/video/2.mp4 b/VideoApplication/entry/src/main/js/default/common/video/2.mp4 deleted file mode 100644 index 8ad9ba799eba39018fb8a9c015e35b92d396092c..0000000000000000000000000000000000000000 Binary files a/VideoApplication/entry/src/main/js/default/common/video/2.mp4 and /dev/null differ diff --git a/VideoApplication/entry/src/main/js/default/i18n/en-US.json b/VideoApplication/entry/src/main/js/default/i18n/en-US.json deleted file mode 100644 index e63c70d978a3a53be988388c87182f81785e170c..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } -} \ No newline at end of file diff --git a/VideoApplication/entry/src/main/js/default/i18n/zh-CN.json b/VideoApplication/entry/src/main/js/default/i18n/zh-CN.json deleted file mode 100644 index de6ee5748322f44942c1b003319d8e66c837675f..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } -} \ No newline at end of file diff --git a/VideoApplication/entry/src/main/js/default/pages/index/index.css b/VideoApplication/entry/src/main/js/default/pages/index/index.css deleted file mode 100644 index b3571dd8a9688d36d92ea15b8c27841dd0fe3800..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,43 +0,0 @@ -.container { - flex-direction: column; - background-color: lightgray; -} -.video-block { - width: 100%; - aspect-ratio: 1.78; - justify-content: center; - align-items: center; -} -video { - width: 100%; - height: 100%; -} -.dialog-main { - width: 98%; -} -.dialog-div { - flex-direction: column; - align-items: center; -} -.inner-txt { - width: 98%; - margin-top: 20px; - flex-direction: column; - align-items: center; - justify-content: space-around; -} -.txt { - font-size: 20px; -} -.inner-btn { - width: 98%; - justify-content: space-around; - align-items: center; - margin-top: 20px; - margin-bottom: 20px; -} - -#timeDialog .dialog-div .inner-txt { - margin-top: 20px; - margin-bottom: 20px; -} \ No newline at end of file diff --git a/VideoApplication/entry/src/main/js/default/pages/index/index.hml b/VideoApplication/entry/src/main/js/default/pages/index/index.hml deleted file mode 100644 index b13ead85e98f7390b0bf262e2a45faa1326a6fdd..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,36 +0,0 @@ -
-
- -
- - - -
-
- 视频播放完成,是否重新播放? -
-
- - -
-
-
-
diff --git a/VideoApplication/entry/src/main/js/default/pages/index/index.js b/VideoApplication/entry/src/main/js/default/pages/index/index.js deleted file mode 100644 index f024ba08b1e64b93d9f2b4a0731f59a01239d7fb..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,79 +0,0 @@ -import prompt from '@system.prompt'; - -export default { - data: { - autoplay: false, // 是否自动播放 - videoId: 'video', // 播放器id - url: '/common/video/1.mp4', // 视频地址 - posterUrl: '/common/images/bg-tv.jpg', // 视频预览的海报路径 - controlShow: true, // 是否显示控制栏 - loop: true, // 是否循环播放 - startTime: 10, // 播放开始时间 - speed: 0.2, // 播放速度 - isfullscreenchange: false // 是否全屏 - }, - // 视频准备完成时触发该事件 - prepared(e) { - this.showPrompt('视频时长:' + e.duration + '秒'); - }, - // 视频开始播放 - start() { - this.showPrompt('视频开始播放'); - }, - // 视频暂停播放 - pause() { - this.showPrompt('视频暂停播放'); - }, - // 视频播放完成 - finish() { - this.$element('confirmDialog').show(); - }, - // 拖动进度条调用 - seeked(e) { - this.showPrompt('设置播放进度:' + e.currenttime + '秒'); - }, - // 播放进度变化调用 - timeupdate(e) { - - }, - // 自带组件进入全屏和退出全屏 - fullscreenchange(e) { - if (e.fullscreen === 1) { - this.isfullscreenchange = true; - } else { - this.isfullscreenchange = false; - } - }, - // 长按屏幕视频进入和退出全屏调用 - longPressFullscreenchange() { - if (this.isfullscreenchange) { // 全屏 - this.$element('video').exitFullscreen(); - this.isfullscreenchange = false; - } else { // 非全屏 - this.$element('video').requestFullscreen({ screenOrientation: 'default' }); - this.isfullscreenchange = true; - } - }, - - // dialog确定 - confirm() { - this.$element('video').start(); - this.$element('confirmDialog').close(); - }, - // dialog取消 - cancel() { - this.$element('confirmDialog').close(); - }, - // 弹框 - showPrompt(msg) { - prompt.showToast({ - message: msg, - duration: 1000 - }); - }, - // 点击视频 - hideControls() { - this.controlShow = !this.controlShow; - } - -}; diff --git a/VideoApplication/entry/src/main/resources/base/media/icon.png b/VideoApplication/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/VideoApplication/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/VideoApplication/entry/src/ohosTest/js/default/app.js b/VideoApplication/entry/src/ohosTest/js/default/app.js deleted file mode 100644 index 55b67e96deb821033f71d30b6fff05efdeb0d901..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/ohosTest/js/default/app.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - onCreate() { - console.info('TestApplication onCreate'); - }, - onDestroy() { - console.info('TestApplication onDestroy'); - } -}; diff --git a/VideoApplication/entry/src/ohosTest/js/default/i18n/en-US.json b/VideoApplication/entry/src/ohosTest/js/default/i18n/en-US.json deleted file mode 100644 index 55561b83737c3c31d082fbfa11e5fc987a351104..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/ohosTest/js/default/i18n/en-US.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - }, - "Files": { - } -} \ No newline at end of file diff --git a/VideoApplication/entry/src/ohosTest/js/default/i18n/zh-CN.json b/VideoApplication/entry/src/ohosTest/js/default/i18n/zh-CN.json deleted file mode 100644 index cce1af06761a42add0cac1a0567aa3237eda8cb4..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/ohosTest/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - }, - "Files": { - } -} \ No newline at end of file diff --git a/VideoApplication/entry/src/ohosTest/js/default/pages/index/index.css b/VideoApplication/entry/src/ohosTest/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/ohosTest/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/VideoApplication/entry/src/ohosTest/js/default/pages/index/index.hml b/VideoApplication/entry/src/ohosTest/js/default/pages/index/index.hml deleted file mode 100644 index f64b040a5ae394dbaa5e185e1ecd4f4556b92184..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/ohosTest/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{ $t('strings.hello') }} {{ title }} - -
diff --git a/VideoApplication/entry/src/ohosTest/js/default/pages/index/index.js b/VideoApplication/entry/src/ohosTest/js/default/pages/index/index.js deleted file mode 100644 index 6b01273d356c91ea7126d96f5ecf438dada94f8c..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/ohosTest/js/default/pages/index/index.js +++ /dev/null @@ -1,40 +0,0 @@ -import file from '@system.file' -import app from '@system.app' -import device from '@system.device' -import router from '@system.router' -import {Core, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - const reportExtend = new ReportExtend(file) - const instrumentLog = new InstrumentLog({ - 'id': 'report' - }) - core.addService('expect', expectExtend) - core.addService('report', reportExtend) - core.addService('report', instrumentLog) - core.init() - core.subscribeEvent('spec', instrumentLog) - core.subscribeEvent('suite', instrumentLog) - core.subscribeEvent('task', instrumentLog) - - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} \ No newline at end of file diff --git a/VideoApplication/entry/src/ohosTest/js/test/ExampleJsunit.test.js b/VideoApplication/entry/src/ohosTest/js/test/ExampleJsunit.test.js deleted file mode 100644 index b6d74caed96ddede98edd1bc9292f6568cd1cfd1..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/ohosTest/js/test/ExampleJsunit.test.js +++ /dev/null @@ -1,10 +0,0 @@ -import app from '@system.app' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -describe('appInfoTest', function () { - it('app_info_test_001', 0, function () { - var info = app.getInfo() - expect(info.versionName).assertEqual('1.0') - expect(info.versionCode).assertEqual('3') - }) -}) \ No newline at end of file diff --git a/VideoApplication/entry/src/ohosTest/js/test/List.test.js b/VideoApplication/entry/src/ohosTest/js/test/List.test.js deleted file mode 100644 index 305eb5bb254cd4802afaffebe68fca2f9436159f..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/ohosTest/js/test/List.test.js +++ /dev/null @@ -1 +0,0 @@ -require('./ExampleJsunit.test.js') \ No newline at end of file diff --git a/VideoApplication/entry/src/ohosTest/resources/base/element/string.json b/VideoApplication/entry/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index c2d93fd94907e1b6f4dd01671f6b87d0f99f8330..0000000000000000000000000000000000000000 --- a/VideoApplication/entry/src/ohosTest/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "VideoApplication" - }, - { - "name": "mainability_description", - "value": "hap sample empty page" - } - ] -} diff --git a/VideoApplication/entry/src/ohosTest/resources/base/media/icon.png b/VideoApplication/entry/src/ohosTest/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/VideoApplication/entry/src/ohosTest/resources/base/media/icon.png and /dev/null differ diff --git a/VideoApplication/gradle/wrapper/gradle-wrapper.jar b/VideoApplication/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 490fda8577df6c95960ba7077c43220e5bb2c0d9..0000000000000000000000000000000000000000 Binary files a/VideoApplication/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/VideoApplication/gradle/wrapper/gradle-wrapper.properties b/VideoApplication/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index f59159e865d4b59feb1b8c44b001f62fc5d58df4..0000000000000000000000000000000000000000 --- a/VideoApplication/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/VideoApplication/settings.gradle b/VideoApplication/settings.gradle deleted file mode 100644 index 4773db73233a570c2d0c01a22e75321acfbf7a07..0000000000000000000000000000000000000000 --- a/VideoApplication/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':entry' diff --git a/VideoOpenHarmony/README.md b/VideoOpenHarmony/README.md new file mode 100644 index 0000000000000000000000000000000000000000..924ae2138f7dcd886eb99777ce92cd5f1115ad7d --- /dev/null +++ b/VideoOpenHarmony/README.md @@ -0,0 +1,12 @@ +# VideoOpenHarmony + +VideoOpenHarmony + +我们最终会构建一个单机版本的视频播放器(JS版本)。应用包含两级页面,分别是主页面和播放页面,两个页面都展示了丰富的JS UI组件,本篇Codelab我们将会一起完成这个客户端,其中包括: +1.首页顶部swiper轮播图的使用 +2.首页底部list图片列表的使用 +3.播放页面video播放控件的使用 + +本案例可以部署到OpenHarmony的开发环境上,部署效果如下图所示: + +![](screenshots/device/videoPlayer.png) \ No newline at end of file diff --git a/ComposeLargeWatermelon/build.gradle b/VideoOpenHarmony/build.gradle similarity index 67% rename from ComposeLargeWatermelon/build.gradle rename to VideoOpenHarmony/build.gradle index d8fe7a13e8bde5b291230d78a2ac38445be91216..fa230b707f071d544736902167fda519b343d087 100644 --- a/ComposeLargeWatermelon/build.gradle +++ b/VideoOpenHarmony/build.gradle @@ -1,13 +1,11 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. apply plugin: 'com.huawei.ohos.app' +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 ohos { - compileSdkVersion 4 - defaultConfig { - compatibleSdkVersion 3 - } + compileSdkVersion 6 } - + buildscript { repositories { maven { @@ -16,11 +14,10 @@ buildscript { maven { url 'http://mirrors.tools.huawei.com/maven/' } - jcenter() } dependencies { - classpath 'com.huawei.ohos:hap:2.4.2.2' - classpath 'com.huawei.ohos:decctest:1.0.0.6' + classpath 'com.huawei.ohos:hap:3.0.1.5' + classpath 'com.huawei.ohos:decctest:3.0.1.1' } } @@ -32,6 +29,5 @@ allprojects { maven { url 'http://mirrors.tools.huawei.com/maven/' } - jcenter() } } diff --git a/DistributedHealthDemoWatch/entry/.gitignore b/VideoOpenHarmony/entry/.gitignore similarity index 33% rename from DistributedHealthDemoWatch/entry/.gitignore rename to VideoOpenHarmony/entry/.gitignore index 796b96d1c402326528b4ba3c12ee9d92d0e212e9..7d5b7a94f4dcf381f03ff21f28f8a2494b58023f 100644 --- a/DistributedHealthDemoWatch/entry/.gitignore +++ b/VideoOpenHarmony/entry/.gitignore @@ -1 +1,2 @@ /build +/node_modules diff --git a/VideoOpenHarmony/entry/build.gradle b/VideoOpenHarmony/entry/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..6c2dca308825d3d38937c45c03918e1628bbfb75 --- /dev/null +++ b/VideoOpenHarmony/entry/build.gradle @@ -0,0 +1,23 @@ +apply plugin: 'com.huawei.ohos.hap' +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 6 + defaultConfig { + compatibleSdkVersion 6 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } + + supportSystem "standard" +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) + testImplementation 'junit:junit:4.13' +} diff --git a/ToolbarApplication/entry/package.json b/VideoOpenHarmony/entry/package.json similarity index 100% rename from ToolbarApplication/entry/package.json rename to VideoOpenHarmony/entry/package.json diff --git a/InputApplication/entry/proguard-rules.pro b/VideoOpenHarmony/entry/proguard-rules.pro similarity index 100% rename from InputApplication/entry/proguard-rules.pro rename to VideoOpenHarmony/entry/proguard-rules.pro diff --git a/DialogDemo/entry/src/main/config.json b/VideoOpenHarmony/entry/src/main/config.json similarity index 71% rename from DialogDemo/entry/src/main/config.json rename to VideoOpenHarmony/entry/src/main/config.json index c4d317ab40c8281696e270e3d855551360eb4755..787d04a51c18ac67f41c39b2e9eebe8d23a4d788 100644 --- a/DialogDemo/entry/src/main/config.json +++ b/VideoOpenHarmony/entry/src/main/config.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.huawei.codelab", + "bundleName": "com.huawei.video", "vendor": "huawei", "version": { "code": 1000000, @@ -9,9 +9,9 @@ }, "deviceConfig": {}, "module": { - "package": "com.huawei.codelab", + "package": "com.huawei.video", "name": ".MyApplication", - "mainAbility": "com.huawei.codelab.MainAbility", + "mainAbility": "com.huawei.video.MainAbility", "deviceType": [ "phone" ], @@ -33,10 +33,13 @@ ] } ], - "name": "com.huawei.codelab.MainAbility", + "orientation": "unspecified", + "visible": true, + "name": "com.huawei.video.MainAbility", "icon": "$media:icon", "description": "$string:mainability_description", - "label": "$string:entry_MainAbility", + "formsEnabled": false, + "label": "$string:VideoDemo", "type": "page", "launchType": "standard" } @@ -44,7 +47,8 @@ "js": [ { "pages": [ - "pages/index/index" + "pages/index/index", + "pages/videopage/videopage" ], "name": "default", "window": { diff --git a/VideoOpenHarmony/entry/src/main/js/default/app.js b/VideoOpenHarmony/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..6d060ffe5682c19fc83e2274a9e62cbc40a655f8 --- /dev/null +++ b/VideoOpenHarmony/entry/src/main/js/default/app.js @@ -0,0 +1,8 @@ +export default { + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } +}; diff --git a/DistributedVideoCodelab/entry/src/main/resources/base/media/gubeishuizhen.mp4 b/VideoOpenHarmony/entry/src/main/js/default/common/TestVideo.mp4 similarity index 100% rename from DistributedVideoCodelab/entry/src/main/resources/base/media/gubeishuizhen.mp4 rename to VideoOpenHarmony/entry/src/main/js/default/common/TestVideo.mp4 diff --git a/DistributedVideoCodelab/entry/src/main/resources/base/media/ic_next.png b/VideoOpenHarmony/entry/src/main/js/default/common/images/ic_next.png similarity index 100% rename from DistributedVideoCodelab/entry/src/main/resources/base/media/ic_next.png rename to VideoOpenHarmony/entry/src/main/js/default/common/images/ic_next.png diff --git a/DistributedVideoCodelab/entry/src/main/resources/base/media/ic_tv.png b/VideoOpenHarmony/entry/src/main/js/default/common/images/ic_tv.png similarity index 100% rename from DistributedVideoCodelab/entry/src/main/resources/base/media/ic_tv.png rename to VideoOpenHarmony/entry/src/main/js/default/common/images/ic_tv.png diff --git a/ClockFACardDemo/entry/src/main/resources/base/media/icon.png b/VideoOpenHarmony/entry/src/main/js/default/common/images/icon.png similarity index 100% rename from ClockFACardDemo/entry/src/main/resources/base/media/icon.png rename to VideoOpenHarmony/entry/src/main/js/default/common/images/icon.png diff --git a/DistributedVideoCodelab/entry/src/main/resources/base/media/video_ad0.jpg b/VideoOpenHarmony/entry/src/main/js/default/common/images/video_ad0.jpg similarity index 100% rename from DistributedVideoCodelab/entry/src/main/resources/base/media/video_ad0.jpg rename to VideoOpenHarmony/entry/src/main/js/default/common/images/video_ad0.jpg diff --git a/DistributedVideoCodelab/entry/src/main/resources/base/media/video_ad1.jpg b/VideoOpenHarmony/entry/src/main/js/default/common/images/video_ad1.jpg similarity index 100% rename from DistributedVideoCodelab/entry/src/main/resources/base/media/video_ad1.jpg rename to VideoOpenHarmony/entry/src/main/js/default/common/images/video_ad1.jpg diff --git a/DistributedVideoCodelab/entry/src/main/resources/base/media/video_ad2.jpg b/VideoOpenHarmony/entry/src/main/js/default/common/images/video_ad2.jpg similarity index 100% rename from DistributedVideoCodelab/entry/src/main/resources/base/media/video_ad2.jpg rename to VideoOpenHarmony/entry/src/main/js/default/common/images/video_ad2.jpg diff --git a/DistributedVideoCodelab/entry/src/main/resources/base/media/video_ad3.jpg b/VideoOpenHarmony/entry/src/main/js/default/common/images/video_ad3.jpg similarity index 100% rename from DistributedVideoCodelab/entry/src/main/resources/base/media/video_ad3.jpg rename to VideoOpenHarmony/entry/src/main/js/default/common/images/video_ad3.jpg diff --git a/DistributedVideoCodelab/entry/src/main/resources/base/media/video_list0.jpg b/VideoOpenHarmony/entry/src/main/js/default/common/images/video_list0.jpg similarity index 100% rename from DistributedVideoCodelab/entry/src/main/resources/base/media/video_list0.jpg rename to VideoOpenHarmony/entry/src/main/js/default/common/images/video_list0.jpg diff --git a/DistributedVideoCodelab/entry/src/main/resources/base/media/video_list1.jpg b/VideoOpenHarmony/entry/src/main/js/default/common/images/video_list1.jpg similarity index 100% rename from DistributedVideoCodelab/entry/src/main/resources/base/media/video_list1.jpg rename to VideoOpenHarmony/entry/src/main/js/default/common/images/video_list1.jpg diff --git a/DistributedVideoCodelab/entry/src/main/resources/base/media/video_list2.jpg b/VideoOpenHarmony/entry/src/main/js/default/common/images/video_list2.jpg similarity index 100% rename from DistributedVideoCodelab/entry/src/main/resources/base/media/video_list2.jpg rename to VideoOpenHarmony/entry/src/main/js/default/common/images/video_list2.jpg diff --git a/VideoOpenHarmony/entry/src/main/js/default/i18n/en-US.json b/VideoOpenHarmony/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..08e34eac912bf2651eefc20e26aa479b5e4e7ec2 --- /dev/null +++ b/VideoOpenHarmony/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,11 @@ +{ + "strings": { + "hello": "Hello", + "world": "World", + "page": "Second Page", + "next": "Next Page", + "back": "Back" + }, + "Files": { + } +} \ No newline at end of file diff --git a/VideoOpenHarmony/entry/src/main/js/default/i18n/zh-CN.json b/VideoOpenHarmony/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..3dd53b3a8b808aec9396fa663cb00ef22ba61e0a --- /dev/null +++ b/VideoOpenHarmony/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,11 @@ +{ + "strings": { + "hello": "您好", + "world": "世界", + "page": "第二页", + "next": "下一页", + "back": "返回" + }, + "Files": { + } +} \ No newline at end of file diff --git a/DialogDemo/entry/src/main/js/default/pages/index/index.css b/VideoOpenHarmony/entry/src/main/js/default/pages/index/index.css similarity index 37% rename from DialogDemo/entry/src/main/js/default/pages/index/index.css rename to VideoOpenHarmony/entry/src/main/js/default/pages/index/index.css index 3bd3534d2acc27b21397653bae0e507bbdd861d3..96d365417ac7ab79b26bec63bcf874f8b7483fe6 100644 --- a/DialogDemo/entry/src/main/js/default/pages/index/index.css +++ b/VideoOpenHarmony/entry/src/main/js/default/pages/index/index.css @@ -1,10 +1,10 @@ /* * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); + * 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 + * 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, @@ -13,71 +13,68 @@ * limitations under the License. */ -.doc-page { - height: 100%; +.container { flex-direction: column; - background-color: #E3f8F9; - justify-content: center; - align-items: center; -} - -.btn-div { width: 100%; - flex-direction: column; - align-items: center; - justify-content: center; -} - -.btn { - background-color: #17A98E; - margin-top: 15px; - width: 80%; - font-weight: bold; + height: 100%; } -.btn-text { - color: #000000; - font-weight: bold; - font-size: 39px; +.swiper { + flex-direction: row; + align-content: center; + align-items: center; + margin-left: 30px; + margin-right: 30px; + width: 100%; + height: 250px; + background-color: black; + indicator-color: gray; + indicator-selected-color: white; + indicator-size: 20px; + indicator-bottom: 10px; + indicator-right: 10px; + margin-top: 30px; } -.dialog-main { - width: 80%; - margin-bottom: 40%; +.swiper_img { + width: 100%; + height: 360px; + object-fit: fill; } -.dialog-div { - flex-direction: column; - align-items: center; -} +.list_head { + margin-top: 40px; + flex-direction: row; + height: 50px; + width: 100%; -.inner-txt { - height: 120px; - flex-direction: column; - align-items: center; - justify-content: space-around; } -.inner-btn { - height: 80px; - justify-content: center; - align-items: center; +.title { + width: 200px; + font-size: 32px; + margin-left: 30px; } -.alert-inner-txt { - height: 120px; - flex-direction: column; - align-items: center; - justify-content: space-around; +.next_img { + width: 50px; + object-fit: scale-down; } -.alert-inner-btn { - height: 80px; - justify-content: space-around; +.list { + flex-direction: row; + align-content: center; align-items: center; + margin-left: 30px; + margin-right: 30px; + margin-top: 20px; + width: 100%; + height: 180px; } -.alert-dialog { - width: 80%; - margin-bottom: 40%; -} +.list_img { + margin-right: 20px; + width: 600px; + height: 360px; + object-fit: fill; +} \ No newline at end of file diff --git a/VideoOpenHarmony/entry/src/main/js/default/pages/index/index.hml b/VideoOpenHarmony/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..85b89884c9a8ec59d863d8ea8fe06540e668de16 --- /dev/null +++ b/VideoOpenHarmony/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,39 @@ + + +
+ + + + + + +
+ Coming soon + +
+ + + + + + + + + + + +
diff --git a/JSPlaygroundDemo/entry/src/main/js/default/app.js b/VideoOpenHarmony/entry/src/main/js/default/pages/index/index.js similarity index 81% rename from JSPlaygroundDemo/entry/src/main/js/default/app.js rename to VideoOpenHarmony/entry/src/main/js/default/pages/index/index.js index 8e47afff13e928a74fdcc01a108e4422404b9ac9..1e63fd7bed173a516d6a47dae9819a22c2781310 100644 --- a/JSPlaygroundDemo/entry/src/main/js/default/app.js +++ b/VideoOpenHarmony/entry/src/main/js/default/pages/index/index.js @@ -13,11 +13,13 @@ * limitations under the License. */ +import router from '@system.router'; + export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); + playVideo() { + router.push({ + uri: 'pages/videopage/videopage' + }); } -}; +} + diff --git a/DistributeDatabaseDraw-master/entry/src/test/java/com/huawei/codelab/ExampleTest.java b/VideoOpenHarmony/entry/src/main/js/default/pages/videopage/videopage.css similarity index 73% rename from DistributeDatabaseDraw-master/entry/src/test/java/com/huawei/codelab/ExampleTest.java rename to VideoOpenHarmony/entry/src/main/js/default/pages/videopage/videopage.css index f97080bdf675c463d5c162b712afee99d3522df2..1fa6d8321534687aec6bdd630cb733db2f3cc63e 100644 --- a/DistributeDatabaseDraw-master/entry/src/test/java/com/huawei/codelab/ExampleTest.java +++ b/VideoOpenHarmony/entry/src/main/js/default/pages/videopage/videopage.css @@ -13,20 +13,20 @@ * limitations under the License. */ -package com.huawei.codelab; +.container { + flex-direction: column; + align-items: center; +} -import org.junit.Test; +.title { + font-size: 20px; + color: #000000; + opacity: 0.9; + height: 10%; + width: 100%; +} -/** - * ExampleTest - * - * @since 2021-4-6 - */ -public class ExampleTest { - /** - * onStart - */ - @Test - public void onStart() { - } +#videoId { + height: 90%; + width: 100%; } diff --git a/VideoOpenHarmony/entry/src/main/js/default/pages/videopage/videopage.hml b/VideoOpenHarmony/entry/src/main/js/default/pages/videopage/videopage.hml new file mode 100644 index 0000000000000000000000000000000000000000..bacdc839754ceebeedd138d8d9ac50aed61a7273 --- /dev/null +++ b/VideoOpenHarmony/entry/src/main/js/default/pages/videopage/videopage.hml @@ -0,0 +1,28 @@ + + +
+
+ 视频准备播放中,如未自动播放,请点击下侧播放按键 +
+ + +
diff --git a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/metadata/CustomMetaData.java b/VideoOpenHarmony/entry/src/main/js/default/pages/videopage/videopage.js similarity index 30% rename from MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/metadata/CustomMetaData.java rename to VideoOpenHarmony/entry/src/main/js/default/pages/videopage/videopage.js index 00453f606d81b8d8baefdc0b97ad07e961958cb4..e55f86a67cd96945b6def764cbdd9a60d5ed5972 100644 --- a/MetaDataBindingDemo/entry/src/main/java/com/huawei/metadatabindingdemo/custom_ui/metadata/CustomMetaData.java +++ b/VideoOpenHarmony/entry/src/main/js/default/pages/videopage/videopage.js @@ -13,42 +13,59 @@ * limitations under the License. */ -package com.huawei.metadatabindingdemo.custom_ui.metadata; +import prompt from '@system.prompt'; -import ohos.agp.utils.Color; -import ohos.mp.metadata.binding.metadata.DataAbilityMetaData; - -/** - * metadata wrapper. Using dataability as data source, so this one extends {@link DataAbilityMetaData}. - * - * @since 2021-05-15 - */ -public class CustomMetaData extends DataAbilityMetaData { - /** - * self defined transfer function to transfer boolean metadata to Color - * - * @param bol boolean - * @return color false-BLUE or true-BLACK - */ - public Color getColorOn(boolean bol) { - if (bol) { - return Color.BLACK; +export default { + data: { + event: '', + seekingtime: '', + timeupdatetime: '', + seekedtime: '', + isStart: true, + isfullscreenchange: false, + duration: '', + }, + preparedCallback: function (e) { + this.event = '视频连接成功'; + this.duration = e.duration; + }, + startCallback: function () { + this.event = '视频开始播放'; + }, + pauseCallback: function () { + this.event = '视频暂停播放'; + }, + finishCallback: function () { + this.event = '视频播放结束'; + }, + errorCallback: function () { + this.event = '视频播放错误'; + }, + seekingCallback: function (e) { + this.seekingtime = e.currenttime; + }, + timeupdateCallback: function (e) { + this.timeupdatetime = e.currenttime; + }, + change_start_pause: function () { + if (this.isStart) { + this.$element('videoId').pause(); + this.isStart = false; } else { - return Color.BLUE; + this.$element('videoId').start(); + this.isStart = true; } - } + }, + start:async function() { + let actionData = { + }; + let target = { + bundleName: "com.huawei.video", + abilityName: "com.huawei.video.MainAbility", + data: actionData + }; - /** - * self defined transfer function to transfer boolean metadata to Color - * - * @param bol boolean - * @return color true-BLUE or false-BLACK - */ - public Color getColorOff(boolean bol) { - if (bol) { - return Color.BLUE; - } else { - return Color.BLACK; - } + let result = await FeatureAbility.startAbility(target); + let ret = JSON.parse(result); } } \ No newline at end of file diff --git a/InputApplication/entry/src/main/resources/base/element/string.json b/VideoOpenHarmony/entry/src/main/resources/base/element/string.json similarity index 67% rename from InputApplication/entry/src/main/resources/base/element/string.json rename to VideoOpenHarmony/entry/src/main/resources/base/element/string.json index 68809f0676300522d28cb2200701ac02ecec1ce3..3ffc637e57a110d1a2e91e8ffc9d62e79eeeab27 100644 --- a/InputApplication/entry/src/main/resources/base/element/string.json +++ b/VideoOpenHarmony/entry/src/main/resources/base/element/string.json @@ -1,8 +1,8 @@ { "string": [ { - "name": "entry_MainAbility", - "value": "input" + "name": "VideoDemo", + "value": "视频播放" }, { "name": "mainability_description", diff --git a/CodecDemo/entry/src/main/resources/base/media/icon.png b/VideoOpenHarmony/entry/src/main/resources/base/media/icon.png similarity index 100% rename from CodecDemo/entry/src/main/resources/base/media/icon.png rename to VideoOpenHarmony/entry/src/main/resources/base/media/icon.png diff --git a/RemoteInputDemo/entry/src/main/resources/base/media/gubeishuizhen.mp4 b/VideoOpenHarmony/screenshots/device/videoPlayer.png similarity index 41% rename from RemoteInputDemo/entry/src/main/resources/base/media/gubeishuizhen.mp4 rename to VideoOpenHarmony/screenshots/device/videoPlayer.png index e34d0d9f9dcbc724142de146a3537d756a21e267..c23a0018e300e2335f3205ea87d55835119ff6ed 100644 Binary files a/RemoteInputDemo/entry/src/main/resources/base/media/gubeishuizhen.mp4 and b/VideoOpenHarmony/screenshots/device/videoPlayer.png differ diff --git a/DialogDemo/settings.gradle b/VideoOpenHarmony/settings.gradle similarity index 100% rename from DialogDemo/settings.gradle rename to VideoOpenHarmony/settings.gradle diff --git a/VoiceCamera/LICENSE b/VoiceCamera/LICENSE deleted file mode 100644 index b36a10d589119cb8557ff572ca3f5b0aab970604..0000000000000000000000000000000000000000 --- a/VoiceCamera/LICENSE +++ /dev/null @@ -1,78 +0,0 @@ - Copyright (c) 2021 Huawei Device Co., Ltd. - - Licensed under the Apache License,Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -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 diff --git a/VoiceCamera/README.md b/VoiceCamera/README.md deleted file mode 100644 index 9f7a28a71590b2457aefbfded4e679e0946327be..0000000000000000000000000000000000000000 --- a/VoiceCamera/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# Distributed Voice Camera -简介 -• 在此demo中,使用HarmonyOS分布式文件系统和AI语音识别功能开发了一个分布式语音摄像头。使用此相机应用程序,同一分布式网络下的不同设备可以实时看到主设备拍摄的照片。这有效解决了对方拍照时需要来回跑过手机的痛点,此外,主设备还支持语音控制摄像头功能,让您可以从远处控制摄像头。 - -安装要求 -• 安装DevEco Studio -• 设置DevEco Studio开发环境。DevEco Studio开发环境需要连接到网络,以确保该正常使用。可以根据以下两种情况配置开发环境: - 1.如果您可以直接访问Internet,则只需下载HarmonyOS SDK - 2.如果网络无法直接访问Internet,则可以通过代理服务器进行访问 -• 生成密钥并申请证书 - -用户指南 -• 下载此项目 -• 打开HUAWEI DevEco Studio,单击File> Open选择此ComponentCodelab -• 单击Build> Build App(s)/Hap(s)>Build Debug Hap(s)以编译hap软件包 -• 单击Run> Run 'entry'以运行hap包 - -注意 -• 您可以选择在模拟器或真机上运行hap软件包。 -• 如果在真机上运行它,则需要在项目的File> Project Structure> Modules> Signing Configs中配置签名和证书信息。 - -许可 -请参阅LICENSE文件以获得更多信息。 - -What is it? -• In this article, Codelab uses the HarmonyOS distributed file system and AI voice recognition function to develop a distributed voice camera.Using this camera application, different devices under the same distributed network can see the photos taken by the main device in real time.This effectively solves the pain point of the need to run back and forth to pass the mobile phone when taking pictures of each other.In addition, the main device also supports a voice-controlled camera function, allowing you to control the camera from a distance. - -Installation requirements -• Install DevEco Studio -• Set up the DevEco Studio development environment.The DevEco Studio development environment needs to depend on the network environment. It needs to be connected to the network to ensure the normal use of the tool.The development environment can be configured according to the following two situations - 1.If you can directly access the Internet, just download the HarmonyOS SDK - 2.If the network cannot access the Internet directly, it can be accessed through a proxy server -• Generate secret key and apply for certificate - -User guide -• Download this Project -• Open HUAWEI DevEco Studio, click File> Open> Then select and open this Project -• Click Build> Build App(s)/Hap(s)>Build Debug Hap(s) to compile the hap package -• Click Run> Run 'entry' to run the hap package - -Note -• You can choose to run the hap package on the simulator or the phone. -• If you run it on the phone, you need to configure the signature and certificate information in the project's File> Project Structure> Modules> Signing Configs. - -Licensing -Please see LICENSE for more info. diff --git a/VoiceCamera/RELEASE-NOTES.md b/VoiceCamera/RELEASE-NOTES.md deleted file mode 100644 index ea23a13e3d4407d06cba3aa7155a23e5081b50b4..0000000000000000000000000000000000000000 --- a/VoiceCamera/RELEASE-NOTES.md +++ /dev/null @@ -1,2 +0,0 @@ -1.0.0 -1.Initial version \ No newline at end of file diff --git a/VoiceCamera/build.gradle b/VoiceCamera/build.gradle deleted file mode 100644 index 5e813edf5571fea3031c66316d196c0a506b8341..0000000000000000000000000000000000000000 --- a/VoiceCamera/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -apply plugin: 'com.huawei.ohos.app' - -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 4 - } -} - -buildscript { - repositories { - maven { - url 'https://mirrors.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } - dependencies { - classpath 'com.huawei.ohos:hap:2.4.2.7' - classpath 'com.huawei.ohos:decctest:1.0.0.7' - } -} - -allprojects { - repositories { - maven { - url 'https://mirrors.huaweicloud.com/repository/maven/' - } - maven { - url 'https://developer.huawei.com/repo/' - } - jcenter() - } -} diff --git a/VoiceCamera/entry/.gitignore b/VoiceCamera/entry/.gitignore deleted file mode 100644 index 796b96d1c402326528b4ba3c12ee9d92d0e212e9..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/VoiceCamera/entry/build.gradle b/VoiceCamera/entry/build.gradle deleted file mode 100644 index c8bca38989ca28241dc2ff0a32bd8a71ff6dc822..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/build.gradle +++ /dev/null @@ -1,13 +0,0 @@ -apply plugin: 'com.huawei.ohos.hap' -ohos { - compileSdkVersion 5 - defaultConfig { - compatibleSdkVersion 4 - } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - testCompile'junit:junit:4.12' - implementation('com.alibaba:fastjson:1.2.4') -} \ No newline at end of file diff --git a/VoiceCamera/entry/src/main/config.json b/VoiceCamera/entry/src/main/config.json deleted file mode 100644 index d52ceb69b9e9763bfac0b3f2c502db7f735f0e88..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/config.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "app": { - "bundleName": "com.huawei.camerademo", - "vendor": "huawei", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "package": "com.huawei.camerademo", - "name": ".MyApplication", - "mainAbility": "com.huawei.camerademo.MainAbility", - "deviceType": [ - "phone" - ], - "metaData": { - "customizeData": [ - { - "name": "hwc-theme", - "value": "androidhwext:style/Theme.Emui.NoTitleBar", - "extra": "" - } - ] - }, - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": false - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "orientation": "portrait", - "name": "com.huawei.camerademo.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard" - }, - { - "orientation": "portrait", - "name": "com.huawei.camerademo.ImageAbility", - "icon": "$media:icon", - "description": "$string:imageability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard" - } - ], - "reqPermissions": [ - { - "name": "ohos.permission.CAMERA" - }, - { - "name": "ohos.permission.WRITE_USER_STORAGE" - }, - { - "name": "ohos.permission.MICROPHONE" - }, - { - "name": "ohos.permission.READ_USER_STORAGE" - }, - { - "name": "ohos.permission.DISTRIBUTED_DATASYNC" - }, - { - "name": "ohos.permission.DISTRIBUTED_DEVICE_STATE_CHANGE" - }, - { - "name": "ohos.permission.GET_DISTRIBUTED_DEVICE_INFO" - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO" - }, - { - "name": "ohos.permission.ACCESS_SERVICE" - } - ] - } -} \ No newline at end of file diff --git a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/ImageAbility.java b/VoiceCamera/entry/src/main/java/com/huawei/camerademo/ImageAbility.java deleted file mode 100644 index 397e81296d6bb6e38dd6cd9ddbe4474f6b8b8c11..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/ImageAbility.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.camerademo; - -import com.huawei.camerademo.slice.ImageAbilitySlice; - -import ohos.aafwk.ability.Ability; -import ohos.aafwk.content.Intent; - -/** - * ImageAbility - * - * @since 2021-03-08 - */ -public class ImageAbility extends Ability { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setMainRoute(ImageAbilitySlice.class.getName()); - } -} diff --git a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/MainAbility.java b/VoiceCamera/entry/src/main/java/com/huawei/camerademo/MainAbility.java deleted file mode 100644 index 1d8081f46aabaf0c376bf502294b81b8863e710a..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/MainAbility.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.camerademo; - -import static com.huawei.camerademo.utils.PermissionBridge.EVENT_PERMISSION_DENIED; -import static com.huawei.camerademo.utils.PermissionBridge.EVENT_PERMISSION_GRANTED; -import static ohos.bundle.IBundleManager.PERMISSION_GRANTED; - -import com.huawei.camerademo.slice.MainAbilitySlice; -import com.huawei.camerademo.utils.PermissionBridge; - -import ohos.aafwk.ability.Ability; -import ohos.aafwk.content.Intent; -import ohos.agp.utils.Color; -import ohos.security.SystemPermission; - -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -/** - * MainAbility - * - * @since 2021-03-08 - */ -public class MainAbility extends Ability { - private static final int PERMISSION_REQUEST_CODE = 1; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setMainRoute(MainAbilitySlice.class.getName()); - requestCameraPermission(); - getWindow().setStatusBarColor(Color.BLACK.getValue()); - } - - private void requestCameraPermission() { - List permissions = - new LinkedList( - Arrays.asList( - SystemPermission.WRITE_USER_STORAGE, - SystemPermission.READ_USER_STORAGE, - SystemPermission.CAMERA, - SystemPermission.DISTRIBUTED_DATASYNC, - SystemPermission.MICROPHONE)); - permissions.removeIf( - permission -> - verifySelfPermission(permission) == PERMISSION_GRANTED || !canRequestPermission(permission)); - - if (!permissions.isEmpty()) { - requestPermissionsFromUser(permissions.toArray(new String[permissions.size()]), PERMISSION_REQUEST_CODE); - } else { - PermissionBridge.getHandler().sendEvent(EVENT_PERMISSION_GRANTED); - } - } - - @Override - public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions, int[] grantResults) { - if (requestCode != PERMISSION_REQUEST_CODE) { - return; - } - for (int grantResult : grantResults) { - if (grantResult != PERMISSION_GRANTED) { - PermissionBridge.getHandler().sendEvent(EVENT_PERMISSION_DENIED); - terminateAbility(); - return; - } - } - PermissionBridge.getHandler().sendEvent(EVENT_PERMISSION_GRANTED); - } -} diff --git a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/MyApplication.java b/VoiceCamera/entry/src/main/java/com/huawei/camerademo/MyApplication.java deleted file mode 100644 index e107bd242b60eeb104647709ed4559648d881fd7..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/MyApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.camerademo; - -import ohos.aafwk.ability.AbilityPackage; - -/** - * MyApplication - * - * @since 2021-03-08 - */ -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/listener/MyAsrListener.java b/VoiceCamera/entry/src/main/java/com/huawei/camerademo/listener/MyAsrListener.java deleted file mode 100644 index fe2b649a98f8341b6fc3b027e29d53bd5159320f..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/listener/MyAsrListener.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.camerademo.listener; - -import ohos.ai.asr.AsrListener; -import ohos.utils.PacMap; - -/** - * MyAsrListener - * - * @since 2021-03-08 - */ -public class MyAsrListener implements AsrListener { - @Override - public void onInit(PacMap pacMap) { - } - - @Override - public void onBeginningOfSpeech() { - } - - @Override - public void onRmsChanged(float var1) { - } - - @Override - public void onBufferReceived(byte[] bytes) { - } - - @Override - public void onEndOfSpeech() { - } - - @Override - public void onError(int var1) { - } - - @Override - public void onResults(PacMap pacMap) { - } - - @Override - public void onIntermediateResults(PacMap pacMap) { - } - - @Override - public void onEnd() { - } - - @Override - public void onEvent(int var1, PacMap pacMap) { - } - - @Override - public void onAudioStart() { - } - - @Override - public void onAudioEnd() { - } -} diff --git a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/slice/ImageAbilitySlice.java b/VoiceCamera/entry/src/main/java/com/huawei/camerademo/slice/ImageAbilitySlice.java deleted file mode 100644 index 5b4eeab8bd67b09a5e3343ce1eb04fbdbadb334c..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/slice/ImageAbilitySlice.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.camerademo.slice; - -import static com.huawei.camerademo.utils.CameraUtil.CAMERA_IMAGE_FILE_PATH; - -import com.huawei.camerademo.ResourceTable; -import com.huawei.camerademo.utils.CameraUtil; -import com.huawei.camerademo.utils.DistributeFileUtil; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.agp.components.Image; -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; -import ohos.media.image.PixelMap; - -/** - * ImageAbilitySlice - * - * @since 2021-03-08 - */ -public class ImageAbilitySlice extends AbilitySlice { - static final HiLogLabel TAG = new HiLogLabel(HiLog.LOG_APP, 0x00201, ImageAbilitySlice.class.getName()); - private Image image; - - @Override - public void onStart(Intent intent) { - super.onStart(intent); - super.setUIContent(ResourceTable.Layout_ability_image); - initView(intent); - } - - private void initView(Intent intent) { - HiLog.info(TAG, "initView"); - if (findComponentById(ResourceTable.Id_image) instanceof Image) { - image = (Image) findComponentById(ResourceTable.Id_image); - } - if (intent.getStringParam(CAMERA_IMAGE_FILE_PATH) != null - && !intent.getStringParam(CAMERA_IMAGE_FILE_PATH).isEmpty()) { - setImage(intent.getStringParam(CAMERA_IMAGE_FILE_PATH)); - } else { - setDisImage(intent); - } - } - - /** - * read image form distribute - * - * @param intent intent - */ - private void setDisImage(Intent intent) { - String filePath = intent.getStringParam("filePath"); - if (filePath != null && !filePath.isEmpty()) { - image.setPixelMap(DistributeFileUtil.readToDistributedDir(this, filePath)); - } - } - - private void setImage(String picPath) { - if (picPath != null && !picPath.isEmpty()) { - PixelMap pixelMap = CameraUtil.getPixelMap(null, picPath, 1); - image.setPixelMap(pixelMap); - } - } -} diff --git a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/slice/MainAbilitySlice.java b/VoiceCamera/entry/src/main/java/com/huawei/camerademo/slice/MainAbilitySlice.java deleted file mode 100644 index 2cc2e141408394dffd6106b823fc04352d7b243e..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/slice/MainAbilitySlice.java +++ /dev/null @@ -1,545 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.camerademo.slice; - -import static com.huawei.camerademo.utils.CameraUtil.CAMERA_IMAGE_FILE_PATH; -import static ohos.media.camera.device.Camera.FrameConfigType.FRAME_CONFIG_PICTURE; -import static ohos.media.camera.device.Camera.FrameConfigType.FRAME_CONFIG_PREVIEW; - -import com.huawei.camerademo.ImageAbility; -import com.huawei.camerademo.ResourceTable; -import com.huawei.camerademo.listener.MyAsrListener; -import com.huawei.camerademo.utils.CameraUtil; -import com.huawei.camerademo.utils.DistributeFileUtil; -import com.huawei.camerademo.utils.MyDrawTask; -import com.huawei.camerademo.utils.PermissionBridge; - -import com.alibaba.fastjson.JSONObject; - -import ohos.aafwk.ability.AbilitySlice; -import ohos.aafwk.content.Intent; -import ohos.aafwk.content.Operation; -import ohos.agp.components.Component; -import ohos.agp.components.ComponentContainer; -import ohos.agp.components.DirectionalLayout; -import ohos.agp.components.Image; -import ohos.agp.components.surfaceprovider.SurfaceProvider; -import ohos.agp.graphics.Surface; -import ohos.agp.graphics.SurfaceOps; -import ohos.ai.asr.AsrClient; -import ohos.ai.asr.AsrIntent; -import ohos.ai.asr.AsrListener; -import ohos.ai.asr.util.AsrResultKey; -import ohos.app.Environment; -import ohos.app.dispatcher.TaskDispatcher; -import ohos.eventhandler.EventHandler; -import ohos.eventhandler.EventRunner; -import ohos.eventhandler.InnerEvent; -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; -import ohos.media.audio.AudioCapturer; -import ohos.media.audio.AudioCapturerInfo; -import ohos.media.audio.AudioStreamInfo; -import ohos.media.camera.CameraKit; -import ohos.media.camera.device.Camera; -import ohos.media.camera.device.CameraConfig; -import ohos.media.camera.device.CameraStateCallback; -import ohos.media.camera.device.FrameConfig; -import ohos.media.image.ImageReceiver; -import ohos.media.image.common.ImageFormat; -import ohos.utils.PacMap; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -/** - * MainAbilitySlice - * - * @since 2021-03-08 - */ -public class MainAbilitySlice extends AbilitySlice implements PermissionBridge.OnPermissionStateListener { - private static final HiLogLabel TAG = new HiLogLabel(3, 0xD001100, "MainAbilitySlice"); - - private static final int EVENT_IMAGESAVING_PROMTING = 0x0000024; - - private static final int POOL_SIZE = 3; - private static final int ALIVE_TIME = 3; - private static final int CAPACITY = 6; - private static final int SLEEP_TIME = 200; - private static final int BYTES_LENGTH = 1280; - private static final int VAD_END_WAIT_MS = 2000; - private static final int VAD_FRONT_WAIT_MS = 4800; - private static final int SAMPLE_RATE = 16000; - private static final int TIMEOUT_DURATION = 20000; - - private static final int SCREEN_WIDTH = 1080; - - private static final int SCREEN_HEIGHT = 2340; - - private static final int IMAGE_RCV_CAPACITY = 9; - - private static final String IMG_FILE_PREFIX = "IMG_"; - - private static final String IMG_FILE_TYPE = ".png"; - - private static final Map COMMAND_MAP = new HashMap<>(); - - private static AsrClient asrClient; - - static { - COMMAND_MAP.put("拍照", true); - COMMAND_MAP.put("茄子", true); - } - - private EventHandler handler = new EventHandler(EventRunner.current()) { - @Override - protected void processEvent(InnerEvent event) { - switch (event.eventId) { - case EVENT_IMAGESAVING_PROMTING: - HiLog.info(TAG, "EVENT_IMAGESAVING_PROMTING"); - MyDrawTask drawTask = new MyDrawTask(smallImage); - smallImage.addDrawTask(drawTask); - drawTask.putPixelMap(CameraUtil.getPixelMap(bytes, "", 1)); - smallImage.setEnabled(true); - break; - default: - break; - } - } - }; - - private Surface previewSurface; - - private SurfaceProvider surfaceProvider; - - private boolean isCameraRear; - - private Camera cameraDevice; - - private EventHandler creamEventHandler; - - private ImageReceiver imageReceiver; - - private Image takePictureImage; - - private Image switchCameraImage; - - private File targetFile; - - private Image smallImage; - - private byte[] bytes; - - private boolean isRecord = false; - - private ThreadPoolExecutor poolExecutor; - - private AudioCapturer audioCapturer; - - private boolean recognizeOver; - - private String fileName; - - @Override - public void onStart(Intent intent) { - HiLog.info(TAG, "onStart"); - super.onStart(intent); - super.setUIContent(ResourceTable.Layout_ability_main); - new PermissionBridge().setOnPermissionStateListener(this); - } - - private void initSurface() { - surfaceProvider = new SurfaceProvider(this); - DirectionalLayout.LayoutConfig params = - new DirectionalLayout.LayoutConfig( - ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT); - - surfaceProvider.setLayoutConfig(params); - surfaceProvider.pinToZTop(true); - - surfaceProvider.getSurfaceOps().get().addCallback(new SurfaceCallBack()); - Component surfaceContainer = findComponentById(ResourceTable.Id_surface_container); - if (surfaceContainer instanceof ComponentContainer) { - ((ComponentContainer) surfaceContainer).addComponent(surfaceProvider); - } - } - - private void initControlComponents() { - if (findComponentById(ResourceTable.Id_tack_picture_btn) instanceof Image) { - takePictureImage = (Image) findComponentById(ResourceTable.Id_tack_picture_btn); - } - takePictureImage.setClickedListener(this::takePicture); - - if (findComponentById(ResourceTable.Id_switch_camera_btn) instanceof Image) { - switchCameraImage = (Image) findComponentById(ResourceTable.Id_switch_camera_btn); - MyDrawTask drawTask = new MyDrawTask(switchCameraImage); - switchCameraImage.addDrawTask(drawTask); - } - switchCameraImage.setClickedListener(component -> switchClicked()); - - if (findComponentById(ResourceTable.Id_small_pic) instanceof Image) { - smallImage = (Image) findComponentById(ResourceTable.Id_small_pic); - } - smallImage.setClickedListener(component -> showBigPic()); - } - - private void openAudio() { - HiLog.info(TAG, "openAudio"); - - if (!isRecord) { - asrClient.startListening(setStartIntent()); - isRecord = true; - poolExecutor.submit(new AudioCaptureRunnable()); - } - } - - private void takePicture(Component component) { - HiLog.info(TAG, "takePicture"); - if (!takePictureImage.isEnabled()) { - HiLog.info(TAG, "takePicture return"); - return; - } - if (cameraDevice == null || imageReceiver == null) { - return; - } - FrameConfig.Builder framePictureConfigBuilder = cameraDevice.getFrameConfigBuilder(FRAME_CONFIG_PICTURE); - framePictureConfigBuilder.addSurface(imageReceiver.getRecevingSurface()); - FrameConfig pictureFrameConfig = framePictureConfigBuilder.build(); - cameraDevice.triggerSingleCapture(pictureFrameConfig); - } - - private void switchClicked() { - if (!takePictureImage.isEnabled()) { - return; - } - takePictureImage.setEnabled(false); - isCameraRear = !isCameraRear; - CameraUtil.setIsCameraRear(isCameraRear); - openCamera(); - } - - private void openCamera() { - imageReceiver = ImageReceiver.create(SCREEN_WIDTH, SCREEN_HEIGHT, ImageFormat.JPEG, IMAGE_RCV_CAPACITY); - imageReceiver.setImageArrivalListener(this::saveImage); - - CameraKit cameraKit = CameraKit.getInstance(getApplicationContext()); - String[] cameraList = cameraKit.getCameraIds(); - String cameraId = cameraList.length > 1 && isCameraRear ? cameraList[1] : cameraList[0]; - CameraStateCallbackImpl cameraStateCallback = new CameraStateCallbackImpl(); - cameraKit.createCamera(cameraId, cameraStateCallback, creamEventHandler); - } - - private void saveImage(ImageReceiver receiver) { - fileName = IMG_FILE_PREFIX + System.currentTimeMillis() + IMG_FILE_TYPE; - targetFile = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), fileName); - try { - HiLog.info(TAG, "filePath is " + targetFile.getCanonicalPath()); - } catch (IOException e) { - HiLog.error(TAG, "filePath is error"); - } - - ohos.media.image.Image image = receiver.readNextImage(); - if (image == null) { - return; - } - ohos.media.image.Image.Component component = image.getComponent(ImageFormat.ComponentType.JPEG); - bytes = new byte[component.remaining()]; - component.read(bytes); - try (FileOutputStream output = new FileOutputStream(targetFile)) { - output.write(bytes); - output.flush(); - handler.sendEvent(EVENT_IMAGESAVING_PROMTING); - DistributeFileUtil.copyPicToDistributedDir(MainAbilitySlice.this, targetFile, fileName); - } catch (IOException e) { - HiLog.info(TAG, "IOException, Save image failed"); - } - } - - private void releaseCamera() { - if (cameraDevice != null) { - cameraDevice.release(); - cameraDevice = null; - } - - if (imageReceiver != null) { - imageReceiver.release(); - imageReceiver = null; - } - - if (creamEventHandler != null) { - creamEventHandler.removeAllEvent(); - creamEventHandler = null; - } - } - - @Override - protected void onStop() { - super.onStop(); - releaseCamera(); - } - - @Override - public void onPermissionGranted() { - getWindow().setTransparent(true); - initSurface(); - initAudioCapturer(); - initControlComponents(); - initAsrClient(); - creamEventHandler = new EventHandler(EventRunner.create("CameraBackground")); - } - - private void initAudioCapturer() { - poolExecutor = - new ThreadPoolExecutor( - POOL_SIZE, - POOL_SIZE, - ALIVE_TIME, - TimeUnit.SECONDS, - new LinkedBlockingQueue<>(CAPACITY), - new ThreadPoolExecutor.DiscardOldestPolicy()); - - AudioStreamInfo audioStreamInfo = - new AudioStreamInfo.Builder() - .encodingFormat(AudioStreamInfo.EncodingFormat.ENCODING_PCM_16BIT) - .channelMask(AudioStreamInfo.ChannelMask.CHANNEL_IN_MONO) - .sampleRate(SAMPLE_RATE) - .build(); - - AudioCapturerInfo audioCapturerInfo = new AudioCapturerInfo.Builder().audioStreamInfo(audioStreamInfo).build(); - - audioCapturer = new AudioCapturer(audioCapturerInfo); - } - - private boolean recognizeWords(String result) { - JSONObject jsonObject = JSONObject.parseObject(result); - JSONObject resultObject = new JSONObject(); - if (jsonObject.getJSONArray("result").get(0) instanceof JSONObject) { - resultObject = (JSONObject) jsonObject.getJSONArray("result").get(0); - } - String resultWord = resultObject.getString("ori_word").replace(" ", ""); - boolean command = COMMAND_MAP.getOrDefault(resultWord, false); - HiLog.info(TAG, "======" + resultWord + "===" + command); - return command; - } - - private void initListener() { - AsrListener asrListener = new MyAsrListener() { - @Override - public void onInit(PacMap params) { - super.onInit(params); - openAudio(); - HiLog.info(TAG, "======onInit======"); - } - - @Override - public void onError(int error) { - super.onError(error); - HiLog.info(TAG, "======error:" + error); - } - - @Override - public void onIntermediateResults(PacMap pacMap) { - super.onIntermediateResults(pacMap); - HiLog.info(TAG, "======onIntermediateResults:"); - String result = pacMap.getString(AsrResultKey.RESULTS_INTERMEDIATE); - boolean recognizeResult = recognizeWords(result); - - if (recognizeResult && !recognizeOver) { - recognizeOver = true; - takePicture(new Component(getContext())); - asrClient.stopListening(); - } - } - - @Override - public void onResults(PacMap results) { - super.onResults(results); - HiLog.info(TAG, "======onResults:"); - - recognizeOver = false; - asrClient.startListening(setStartIntent()); - } - - @Override - public void onEnd() { - super.onEnd(); - HiLog.info(TAG, "======onEnd:"); - recognizeOver = false; - asrClient.stopListening(); - asrClient.startListening(setStartIntent()); - } - }; - - // Initializes asr. - if (asrClient != null) { - asrClient.init(setInitIntent(), asrListener); - } - } - - private void initAsrClient() { - asrClient = AsrClient.createAsrClient(this).orElse(null); - TaskDispatcher taskDispatcher = getAbility().getMainTaskDispatcher(); - taskDispatcher.asyncDispatch( - new Runnable() { - @Override - public void run() { - initListener(); - } - }); - } - - @Override - public void onPermissionDenied() { - } - - /** - * CameraStateCallbackImpl - * - * @since 2021-03-08 - */ - class CameraStateCallbackImpl extends CameraStateCallback { - CameraStateCallbackImpl() { - } - - @Override - public void onCreated(Camera camera) { - previewSurface = surfaceProvider.getSurfaceOps().get().getSurface(); - if (previewSurface == null) { - HiLog.info(TAG, "create camera filed, preview surface is null"); - return; - } - - try { - Thread.sleep(SLEEP_TIME); - } catch (InterruptedException exception) { - HiLog.info(TAG, "Waiting to be interrupted"); - } - - CameraConfig.Builder cameraConfigBuilder = camera.getCameraConfigBuilder(); - cameraConfigBuilder.addSurface(previewSurface); - cameraConfigBuilder.addSurface(imageReceiver.getRecevingSurface()); - camera.configure(cameraConfigBuilder.build()); - cameraDevice = camera; - - enableImageGroup(); - } - - @Override - public void onConfigured(Camera camera) { - FrameConfig.Builder framePreviewConfigBuilder = camera.getFrameConfigBuilder(FRAME_CONFIG_PREVIEW); - framePreviewConfigBuilder.addSurface(previewSurface); - try { - // 启动循环帧捕获 - camera.triggerLoopingCapture(framePreviewConfigBuilder.build()); - } catch (IllegalArgumentException e) { - HiLog.error(TAG, "Argument Exception"); - } catch (IllegalStateException e) { - HiLog.error(TAG, "State Exception"); - } - } - - private void enableImageGroup() { - takePictureImage.setEnabled(true); - switchCameraImage.setEnabled(true); - } - } - - /** - * SurfaceCallBack - * - * @since 2021-03-08 - */ - class SurfaceCallBack implements SurfaceOps.Callback { - @Override - public void surfaceCreated(SurfaceOps callbackSurfaceOps) { - if (callbackSurfaceOps != null) { - callbackSurfaceOps.setFixedSize(surfaceProvider.getHeight(), surfaceProvider.getWidth()); - } - openCamera(); - } - - @Override - public void surfaceChanged(SurfaceOps callbackSurfaceOps, int format, int width, int height) { - } - - @Override - public void surfaceDestroyed(SurfaceOps callbackSurfaceOps) { - } - } - - /** - * showBigPic - */ - private void showBigPic() { - Intent intent = new Intent(); - Operation operation = - new Intent.OperationBuilder() - .withBundleName(getBundleName()) - .withAbilityName(ImageAbility.class.getName()) - .build(); - intent.setOperation(operation); - if (targetFile != null) { - try { - intent.setParam(CAMERA_IMAGE_FILE_PATH, targetFile.getCanonicalPath()); - } catch (IOException e) { - HiLog.error(TAG, "filePath is error"); - } - } - startAbility(intent); - } - - private AsrIntent setInitIntent() { - AsrIntent initIntent = new AsrIntent(); - initIntent.setAudioSourceType(AsrIntent.AsrAudioSrcType.ASR_SRC_TYPE_PCM); - initIntent.setEngineType(AsrIntent.AsrEngineType.ASR_ENGINE_TYPE_LOCAL); - return initIntent; - } - - private AsrIntent setStartIntent() { - AsrIntent asrIntent = new AsrIntent(); - asrIntent.setVadEndWaitMs(VAD_END_WAIT_MS); - asrIntent.setVadFrontWaitMs(VAD_FRONT_WAIT_MS); - asrIntent.setTimeoutThresholdMs(TIMEOUT_DURATION); - return asrIntent; - } - - /** - * Obtains PCM audio streams and sends them to the ASR engine during recording. - * - * @since 2021-03-08 - */ - private class AudioCaptureRunnable implements Runnable { - @Override - public void run() { - byte[] buffers = new byte[BYTES_LENGTH]; - audioCapturer.start(); - while (isRecord) { - int ret = audioCapturer.read(buffers, 0, BYTES_LENGTH); - if (ret <= 0) { - HiLog.error(TAG, "======Error read data"); - } else { - asrClient.writePcm(buffers, BYTES_LENGTH); - } - } - } - } -} diff --git a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/utils/CameraUtil.java b/VoiceCamera/entry/src/main/java/com/huawei/camerademo/utils/CameraUtil.java deleted file mode 100644 index a82c531bad2e587d51848dd0fa95bd469ea496d4..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/utils/CameraUtil.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.camerademo.utils; - -import ohos.media.image.ImageSource; -import ohos.media.image.PixelMap; -import ohos.media.image.common.PixelFormat; -import ohos.media.image.common.Size; - -/** - * CameraUtil - * - * @since 2021-03-08 - */ -public class CameraUtil { - /** - * camera image file path - */ - public static final String CAMERA_IMAGE_FILE_PATH = "camera_image_file_path"; - - /** - * is camera rear - */ - private static boolean isCameraRear = false; - - private static final int DEGREES_90 = 90; - private static final int DEGREES_270 = 270; - - private CameraUtil() { - } - - /** - * Obtains the PixelMap of an image. - * - * @param imageBytes Image byte stream - * @param imagePath Image path - * @param rotateCount angle of rotation - * @return PixelMap - */ - public static PixelMap getPixelMap(byte[] imageBytes, String imagePath, int rotateCount) { - ImageSource.SourceOptions sourceOptions = new ImageSource.SourceOptions(); - sourceOptions.formatHint = "image/png"; - ImageSource imageSource = null; - if (imagePath != null && !imagePath.isEmpty()) { - imageSource = ImageSource.create(imagePath, sourceOptions); - } else if (imageBytes != null) { - imageSource = ImageSource.create(imageBytes, sourceOptions); - } else { - return null; - } - ImageSource.DecodingOptions decodingOpts = new ImageSource.DecodingOptions(); - decodingOpts.desiredSize = new Size(0, 0); - decodingOpts.rotateDegrees = (isCameraRear ? DEGREES_270 : DEGREES_90) * rotateCount; - decodingOpts.desiredPixelFormat = PixelFormat.ARGB_8888; - return imageSource.createPixelmap(decodingOpts); - } - - public static void setIsCameraRear(boolean isCameraRear) { - CameraUtil.isCameraRear = isCameraRear; - } -} diff --git a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/utils/DistributeFileUtil.java b/VoiceCamera/entry/src/main/java/com/huawei/camerademo/utils/DistributeFileUtil.java deleted file mode 100644 index a5986a34798da05fc0fdcb2518d883e2406886ac..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/utils/DistributeFileUtil.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.camerademo.utils; - -import com.huawei.camerademo.ImageAbility; - -import ohos.aafwk.content.Intent; -import ohos.aafwk.content.Operation; -import ohos.agp.window.dialog.ToastDialog; -import ohos.app.Context; -import ohos.distributedschedule.interwork.DeviceInfo; -import ohos.distributedschedule.interwork.DeviceManager; -import ohos.media.image.ImageSource; -import ohos.media.image.PixelMap; -import ohos.media.image.SourceDataMalformedException; -import ohos.media.image.common.PixelFormat; -import ohos.media.image.common.Rect; -import ohos.media.image.common.Size; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; - -/** - * DistributeFileUtil - * - * @since 2021-03-08 - */ -public class DistributeFileUtil { - private static final String TAG = DistributeFileUtil.class.getSimpleName(); - private static final int CACHE_SIZE = 1024; - private static final int IO_END_LEN = -1; - private static final int DEGREES_90 = 90; - - private static File getDisFile(Context context, String fileName) { - File distributedDir = context.getDistributedDir(); - File distributedFile; - if (distributedDir == null) { - showTip(context, "分布式文件服务异常,目录为空!"); - return null; - } else { - distributedFile = new File(distributedDir, fileName); - } - return distributedFile; - } - - /** - * Copying Images to the Distributed File Service Address - * - * @param context context - * @param sourceFile file - * @param fileName filename - * @throws IOException Signals that an I/O exception of some sort has occurred - */ - public static void copyPicToDistributedDir(Context context, File sourceFile, String fileName) { - InputStream in = null; - OutputStream out = null; - File disPath = getDisFile(context, fileName); - if (disPath == null) { - return; - } - try { - in = new FileInputStream(sourceFile); - out = new FileOutputStream(disPath); - byte[] buffer = new byte[CACHE_SIZE]; - int len; - while ((len = in.read(buffer)) != IO_END_LEN) { - out.write(buffer, 0, len); - } - - // 拷贝成功,启动远程FA - startRemoteFas(context, disPath.getCanonicalPath()); - } catch (IOException e) { - LogUtil.error(TAG, "copy error occur while copy"); - showTip(context, "分布式文件服务异常,拷贝异常!"); - } finally { - try { - if (in != null) { - in.close(); - } - } catch (IOException e) { - LogUtil.error(TAG, "io close exception"); - } - try { - if (out != null) { - out.close(); - } - } catch (IOException e) { - LogUtil.error(TAG, "io close exception"); - } - } - } - - /** - * Reads the distributed file service address image. - * - * @param context context - * @param filePath filePath - * @return Provides images in forms of pixel matrices - * @throws SourceDataMalformedException Provides the exception for unsupported image format - */ - public static PixelMap readToDistributedDir(Context context, String filePath) { - File disPath = new File(filePath); - if (disPath == null) { - return null; - } - try { - ImageSource.SourceOptions srcOpts = new ImageSource.SourceOptions(); - ImageSource imageSource = ImageSource.create(disPath, srcOpts); - if (imageSource != null) { - LogUtil.info(TAG, "imageSource != null ok ok ok"); - showTip(context, "imageSource != null ok ok ok"); - ImageSource.DecodingOptions decodingOpts = new ImageSource.DecodingOptions(); - decodingOpts.desiredSize = new Size(0, 0); - decodingOpts.desiredRegion = new Rect(0, 0, 0, 0); - decodingOpts.desiredPixelFormat = PixelFormat.ARGB_8888; - decodingOpts.rotateDegrees = DEGREES_90; - return imageSource.createPixelmap(decodingOpts); - } else { - showTip(context, "imageSource == null error error error"); - } - } catch (SourceDataMalformedException e) { - LogUtil.error(TAG, "readToDistributedDir SourceDataMalformedException "); - } - - return null; - } - - /** - * Deleting a Distributed File Service Address - * - * @param context context - * @param fileName fileName - */ - private void deleteDistributedDir(Context context, String fileName) { - File disPath = getDisFile(context, fileName); - if (disPath != null && disPath.exists() && disPath.isFile()) { - boolean result = disPath.delete(); - showTip(context, "delete :" + (result ? "success" : "fail")); - } else { - showTip(context, "No pictures exists in the distributedDir"); - } - } - - private static void showTip(Context context, String msg) { - context.getUITaskDispatcher() - .delayDispatch( - new Runnable() { - @Override - public void run() { - ToastDialog toastDialog = new ToastDialog(context); - toastDialog.setAutoClosable(false); - toastDialog.setContentText(msg); - toastDialog.show(); - } - }, - 0); - } - - /** - * Start Remote - * - * @param context context - * @param filePath filePath - */ - private static void startRemoteFas(Context context, String filePath) { - List deviceInfos = - DeviceManager.getDeviceList(ohos.distributedschedule.interwork.DeviceInfo.FLAG_GET_ONLINE_DEVICE); - if (deviceInfos == null || deviceInfos.size() < 1) { - return; - } - Intent[] intents = new Intent[deviceInfos.size()]; - for (int i = 0; i < deviceInfos.size(); i++) { - Intent intent = new Intent(); - intent.setParam("filePath", filePath); - Operation operation = - new Intent.OperationBuilder() - .withDeviceId(deviceInfos.get(i).getDeviceId()) - .withBundleName(context.getBundleName()) - .withAbilityName(ImageAbility.class.getName()) - .withFlags(Intent.FLAG_ABILITYSLICE_MULTI_DEVICE) - .build(); - intent.setOperation(operation); - intents[i] = intent; - } - context.startAbilities(intents); - } -} diff --git a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/utils/LogUtil.java b/VoiceCamera/entry/src/main/java/com/huawei/camerademo/utils/LogUtil.java deleted file mode 100644 index 87e1dece895dccf3c7fa338b350d50daf9e20387..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/utils/LogUtil.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.camerademo.utils; - -import ohos.hiviewdfx.HiLog; -import ohos.hiviewdfx.HiLogLabel; - -/** - * Log Util - * - * @since 2021-03-08 - */ -public class LogUtil { - private static final String TAG_LOG = "LogUtil"; - - private static final HiLogLabel LABEL_LOG = new HiLogLabel(0, 0, LogUtil.TAG_LOG); - - private static final String LOG_FORMAT = "%{public}s: %{public}s"; - - private LogUtil() { - } - - /** - * Print info log - * - * @param tag log tag - * @param msg log message - */ - public static void info(String tag, String msg) { - HiLog.info(LABEL_LOG, LOG_FORMAT, tag, msg); - } - - /** - * Print info log - * - * @param tag log tag - * @param msg log message - */ - public static void error(String tag, String msg) { - HiLog.info(LABEL_LOG, LOG_FORMAT, tag, msg); - } -} diff --git a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/utils/MyDrawTask.java b/VoiceCamera/entry/src/main/java/com/huawei/camerademo/utils/MyDrawTask.java deleted file mode 100644 index 5a33c6018ae66f20989ef6b73714a5d655e35c3a..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/utils/MyDrawTask.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.camerademo.utils; - -import ohos.agp.components.Component; -import ohos.agp.render.Canvas; -import ohos.agp.render.Paint; -import ohos.agp.render.PixelMapHolder; -import ohos.agp.utils.Color; -import ohos.agp.utils.RectFloat; -import ohos.media.image.PixelMap; - -/** - * MyDrawTask - * - * @since 2021-03-08 - */ -public class MyDrawTask implements Component.DrawTask { - private static final int HALF = 2; - private static final int STROKE_WIDTH = 3; - private static final int MAX_SIZE = 66; - private Component component; - private PixelMap pixelMap; - private RectFloat rectSrc; - - /** - * MyDrawTask - * - * @param component component - */ - public MyDrawTask(Component component) { - this.component = component; - } - - /** - * putPixelMap - * - * @param pm Provides images in forms of pixel matrices - */ - public void putPixelMap(PixelMap pm) { - if (pm != null) { - pixelMap = pm; - int halfWidth = pixelMap.getImageInfo().size.width / HALF; - int halfHeight = pixelMap.getImageInfo().size.height / HALF; - int center = Math.min(halfWidth, halfHeight); - rectSrc = new RectFloat(halfWidth - center, halfHeight - center, halfWidth + center, halfHeight + center); - component.invalidate(); - } - } - - @Override - public void onDraw(Component component1, Canvas canvas) { - int halfWidth = component.getWidth() / HALF; - int halfHeight = component.getHeight() / HALF; - int center = Math.min(halfWidth, halfHeight); - if (center > MAX_SIZE) { - center = MAX_SIZE; - } - - int radius = center - STROKE_WIDTH / HALF; - if (pixelMap != null) { - canvas.drawPixelMapHolderCircleShape(new PixelMapHolder(pixelMap), rectSrc, halfWidth, halfHeight, radius); - } - - Paint roundPaint = new Paint(); - roundPaint.setAntiAlias(true); - roundPaint.setStyle(Paint.Style.STROKE_STYLE); - roundPaint.setStrokeWidth(STROKE_WIDTH); - roundPaint.setStrokeCap(Paint.StrokeCap.ROUND_CAP); - roundPaint.setColor(Color.WHITE); - canvas.drawCircle(halfWidth, halfHeight, radius, roundPaint); - } -} diff --git a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/utils/PermissionBridge.java b/VoiceCamera/entry/src/main/java/com/huawei/camerademo/utils/PermissionBridge.java deleted file mode 100644 index d7ab3e11666549e9dadd8bdc750b422eea9fb9a9..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/java/com/huawei/camerademo/utils/PermissionBridge.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License,Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.huawei.camerademo.utils; - -import ohos.eventhandler.EventHandler; -import ohos.eventhandler.EventRunner; -import ohos.eventhandler.InnerEvent; - -/** - * PermissionBridge - * - * @since 2021-03-08 - */ -public class PermissionBridge { - /** - * permission handler granted - */ - public static final int EVENT_PERMISSION_GRANTED = 0x0000023; - - /** - * permission handler denied - */ - public static final int EVENT_PERMISSION_DENIED = 0x0000024; - - private static final String TAG = PermissionBridge.class.getSimpleName(); - - private static OnPermissionStateListener onPermissionStateListener; - - private static EventHandler handler = new EventHandler(EventRunner.current()) { - @Override - protected void processEvent(InnerEvent event) { - switch (event.eventId) { - case EVENT_PERMISSION_GRANTED: - onPermissionStateListener.onPermissionGranted(); - break; - case EVENT_PERMISSION_DENIED: - onPermissionStateListener.onPermissionDenied(); - break; - default: - LogUtil.info(TAG, "EventHandler Undefined Event"); - break; - } - } - }; - - /** - * setOnPermissionStateListener - * - * @param permissionStateListener OnPermissionStateListener - */ - public void setOnPermissionStateListener(OnPermissionStateListener permissionStateListener) { - onPermissionStateListener = permissionStateListener; - } - - /** - * OnPermissionStateListener - * - * @since 2021-03-08 - */ - public interface OnPermissionStateListener { - /** - * onPermissionGranted - */ - void onPermissionGranted(); - - /** - * onPermissionDenied - */ - void onPermissionDenied(); - } - - /** - * getHandler - * - * @return EventHandler - */ - public static EventHandler getHandler() { - return handler; - } -} diff --git a/VoiceCamera/entry/src/main/resources/base/element/string.json b/VoiceCamera/entry/src/main/resources/base/element/string.json deleted file mode 100644 index dfddb7cb95e8574b5465c387791067ce033ba968..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "CameraDemo" - }, - { - "name": "mainability_description", - "value": "Java_Phone_Empty Feature Ability" - }, - { - "name": "imageability_description", - "value": "Java_Tv_Empty Feature Ability" - } - ] -} \ No newline at end of file diff --git a/VoiceCamera/entry/src/main/resources/base/graphic/background_ability_image.xml b/VoiceCamera/entry/src/main/resources/base/graphic/background_ability_image.xml deleted file mode 100644 index 868abb74e480648af79bff82ff5404a75f16becd..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/resources/base/graphic/background_ability_image.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/VoiceCamera/entry/src/main/resources/base/graphic/background_ability_main.xml b/VoiceCamera/entry/src/main/resources/base/graphic/background_ability_main.xml deleted file mode 100644 index c0c0a3df480fa387a452b9c40ca191cc918a3fc0..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/resources/base/graphic/background_ability_main.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/VoiceCamera/entry/src/main/resources/base/graphic/background_button.xml b/VoiceCamera/entry/src/main/resources/base/graphic/background_button.xml deleted file mode 100644 index 11da97deb17db54751326798a1a4b48f6e24cd24..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/resources/base/graphic/background_button.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/VoiceCamera/entry/src/main/resources/base/layout/ability_image.xml b/VoiceCamera/entry/src/main/resources/base/layout/ability_image.xml deleted file mode 100644 index b01305456577419763d74dd401ae49445b0df5dd..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/resources/base/layout/ability_image.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/VoiceCamera/entry/src/main/resources/base/layout/ability_main.xml b/VoiceCamera/entry/src/main/resources/base/layout/ability_main.xml deleted file mode 100644 index 0a9012cec0330bc1dbc2b52a4fe2ede5d976960f..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/main/resources/base/layout/ability_main.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/VoiceCamera/entry/src/main/resources/base/media/bg_image.png b/VoiceCamera/entry/src/main/resources/base/media/bg_image.png deleted file mode 100644 index 7c028464ed3f2d6ff75fb33b81eaf0ed00c75e87..0000000000000000000000000000000000000000 Binary files a/VoiceCamera/entry/src/main/resources/base/media/bg_image.png and /dev/null differ diff --git a/VoiceCamera/entry/src/main/resources/base/media/ic_camera_back.png b/VoiceCamera/entry/src/main/resources/base/media/ic_camera_back.png deleted file mode 100644 index 85453cfd5c185dc0f0d9898ae06c8d779d4b2bd2..0000000000000000000000000000000000000000 Binary files a/VoiceCamera/entry/src/main/resources/base/media/ic_camera_back.png and /dev/null differ diff --git a/VoiceCamera/entry/src/main/resources/base/media/ic_camera_foot.png b/VoiceCamera/entry/src/main/resources/base/media/ic_camera_foot.png deleted file mode 100644 index 47a0eaf8f1860e0966ff426c0f14320178651024..0000000000000000000000000000000000000000 Binary files a/VoiceCamera/entry/src/main/resources/base/media/ic_camera_foot.png and /dev/null differ diff --git a/VoiceCamera/entry/src/main/resources/base/media/ic_camera_head.png b/VoiceCamera/entry/src/main/resources/base/media/ic_camera_head.png deleted file mode 100644 index 063c47d64be1db57c7b128dd65d18c72fe6c0e56..0000000000000000000000000000000000000000 Binary files a/VoiceCamera/entry/src/main/resources/base/media/ic_camera_head.png and /dev/null differ diff --git a/VoiceCamera/entry/src/main/resources/base/media/ic_camera_photo.png b/VoiceCamera/entry/src/main/resources/base/media/ic_camera_photo.png deleted file mode 100644 index cf6e9e8b7cc9023f2bfb6ce10bb5c0d95625d6d5..0000000000000000000000000000000000000000 Binary files a/VoiceCamera/entry/src/main/resources/base/media/ic_camera_photo.png and /dev/null differ diff --git a/VoiceCamera/entry/src/main/resources/base/media/ic_camera_switch.png b/VoiceCamera/entry/src/main/resources/base/media/ic_camera_switch.png deleted file mode 100644 index 92eff2321b1e2ff15bef1b4016b582d9fbb8a74d..0000000000000000000000000000000000000000 Binary files a/VoiceCamera/entry/src/main/resources/base/media/ic_camera_switch.png and /dev/null differ diff --git a/VoiceCamera/entry/src/main/resources/base/media/ic_camera_thumbnail.png b/VoiceCamera/entry/src/main/resources/base/media/ic_camera_thumbnail.png deleted file mode 100644 index 0d7a9c3c29ca4fc7b683c3ac9c77c1f45bbaf44d..0000000000000000000000000000000000000000 Binary files a/VoiceCamera/entry/src/main/resources/base/media/ic_camera_thumbnail.png and /dev/null differ diff --git a/VoiceCamera/entry/src/main/resources/base/media/ic_image_foot.png b/VoiceCamera/entry/src/main/resources/base/media/ic_image_foot.png deleted file mode 100644 index 57d2c54ed0f94fed6c8b844d638642b42249fb3e..0000000000000000000000000000000000000000 Binary files a/VoiceCamera/entry/src/main/resources/base/media/ic_image_foot.png and /dev/null differ diff --git a/VoiceCamera/entry/src/main/resources/base/media/ic_image_left.png b/VoiceCamera/entry/src/main/resources/base/media/ic_image_left.png deleted file mode 100644 index 3392dec285b862ff560c8176151773a8fc767e08..0000000000000000000000000000000000000000 Binary files a/VoiceCamera/entry/src/main/resources/base/media/ic_image_left.png and /dev/null differ diff --git a/VoiceCamera/entry/src/main/resources/base/media/ic_image_right.png b/VoiceCamera/entry/src/main/resources/base/media/ic_image_right.png deleted file mode 100644 index 950381b0938adcdcf3295f05fb15c53175cfcd8d..0000000000000000000000000000000000000000 Binary files a/VoiceCamera/entry/src/main/resources/base/media/ic_image_right.png and /dev/null differ diff --git a/VoiceCamera/entry/src/main/resources/base/media/icon.png b/VoiceCamera/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/VoiceCamera/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/VoiceCamera/entry/src/test/java/com/huawei/camerademo/ExampleTest.java b/VoiceCamera/entry/src/test/java/com/huawei/camerademo/ExampleTest.java deleted file mode 100644 index 0832d47fb007d6fefd10470e5ba454e2c13d2185..0000000000000000000000000000000000000000 --- a/VoiceCamera/entry/src/test/java/com/huawei/camerademo/ExampleTest.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.huawei.camerademo; - -import org.junit.Test; - -public class ExampleTest { - @Test - public void onStart() { - } -} diff --git a/VoiceCamera/gradle/wrapper/gradle-wrapper.jar b/VoiceCamera/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 490fda8577df6c95960ba7077c43220e5bb2c0d9..0000000000000000000000000000000000000000 Binary files a/VoiceCamera/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/VoiceCamera/gradle/wrapper/gradle-wrapper.properties b/VoiceCamera/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index f59159e865d4b59feb1b8c44b001f62fc5d58df4..0000000000000000000000000000000000000000 --- a/VoiceCamera/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/VoiceCamera/settings.gradle b/VoiceCamera/settings.gradle deleted file mode 100644 index 4773db73233a570c2d0c01a22e75321acfbf7a07..0000000000000000000000000000000000000000 --- a/VoiceCamera/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':entry' diff --git a/local.properties b/local.properties deleted file mode 100644 index 2b1f3304d8169ec4f4602359b5e97bcf0d27cf71..0000000000000000000000000000000000000000 --- a/local.properties +++ /dev/null @@ -1,14 +0,0 @@ -## This file is automatically generated by DevEco Studio. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must *NOT* be checked into Version Control Systems, -# as it contains information specific to your local configuration. -# -# Location of the SDK. This is only used by Gradle. -# For customization when using a Version Control System, please read the -# header note. -#Wed Aug 04 20:12:59 CST 2021 -native.dir=C\:\\Users\\pc\\AppData\\Local\\Huawei\\Sdk\\native\\2.1.1.18 -nodejs.dir=F\:\\Program Files\\nodejs -npm.dir=F\:\\Program Files\\Huawei\\DevEco Studio 2.2.0.200\\tools\\nodejs -hwsdk.dir=C\:\\Users\\pc\\AppData\\Local\\Huawei\\Sdk