diff --git a/UI/AtomicLayout/entry/src/main/js/default/common/common.css b/UI/AtomicLayout/entry/src/main/js/default/common/common.css new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/UI/RefreshContainer/entry/src/main/js/default/pages/index/index.hml b/UI/RefreshContainer/entry/src/main/js/default/pages/index/index.hml index 9c9ba0e6ee2c57c8dfb2a728c289688f2fecba6f..058c0e1f05beab1da5bee40ddd7019f03e9fad85 100644 --- a/UI/RefreshContainer/entry/src/main/js/default/pages/index/index.hml +++ b/UI/RefreshContainer/entry/src/main/js/default/pages/index/index.hml @@ -16,7 +16,7 @@
- + {{ $item.title }} diff --git a/UI/Toolbar/README_zh.md b/UI/Toolbar/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..f1cc4e95477229d094bc14fed7ad83e3508ba79d --- /dev/null +++ b/UI/Toolbar/README_zh.md @@ -0,0 +1,13 @@ +# 工具栏 + +### 简介 + +工具栏放在界面底部,可展示针对当前界面的各种操作,子组件表示工具栏上的一个操作选项,必须为其设置图片与文字。本示例使用工具栏实现了对小说阅读界面的模拟。 + +### 使用说明 + +本示例主界面为列表目录,点击列表条目,跳转到对应章节内容,点击内容可呼出工具栏,可通过工具栏中的操作选项来更改页面属性或章节跳转。 + +### 约束与限制 + +本示例仅支持在标准系统上使用。 \ No newline at end of file diff --git a/UI/Toolbar/build.gradle b/UI/Toolbar/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..ad33f7c014a76f9b635c1e497c19e278f2aef9da --- /dev/null +++ b/UI/Toolbar/build.gradle @@ -0,0 +1,36 @@ +// 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 6 + } +} + +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.3-RC' + } +} + +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/UI/Toolbar/entry/build.gradle b/UI/Toolbar/entry/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..6b6a606b1b3e2af76d27a6fa8ad069e92ddbed68 --- /dev/null +++ b/UI/Toolbar/entry/build.gradle @@ -0,0 +1,17 @@ +apply plugin: 'com.huawei.ohos.hap' + +ohos { + compileSdkVersion 6 + defaultConfig { + compatibleSdkVersion 6 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } + supportSystem "standard" +} diff --git a/UI/Toolbar/entry/src/main/config.json b/UI/Toolbar/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..a256150b8b83ec3332a4e0d043076d1bc144e63b --- /dev/null +++ b/UI/Toolbar/entry/src/main/config.json @@ -0,0 +1,57 @@ +{ + "app": { + "bundleName": "ohos.samples.toolbar", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.samples.toolbar", + "name": ".MainAbility", + "mainAbility": "ohos.samples.toolbar.MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "ohos.samples.toolbar.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index", + "pages/toolbar/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": true + } + } + ] + } +} \ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/js/default/app.js b/UI/Toolbar/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..8e47afff13e928a74fdcc01a108e4422404b9ac9 --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/app.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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'); + } +}; diff --git a/UI/Toolbar/entry/src/main/js/default/common/images/bright.png b/UI/Toolbar/entry/src/main/js/default/common/images/bright.png new file mode 100644 index 0000000000000000000000000000000000000000..b72177f2fa256f5171e7cbec0b8aad40dcf68c5f Binary files /dev/null and b/UI/Toolbar/entry/src/main/js/default/common/images/bright.png differ diff --git a/UI/Toolbar/entry/src/main/js/default/common/images/dark.png b/UI/Toolbar/entry/src/main/js/default/common/images/dark.png new file mode 100644 index 0000000000000000000000000000000000000000..1a8e4d4cebb9b1161df2d596de5c1d9f1b036947 Binary files /dev/null and b/UI/Toolbar/entry/src/main/js/default/common/images/dark.png differ diff --git a/UI/Toolbar/entry/src/main/js/default/common/images/directory.png b/UI/Toolbar/entry/src/main/js/default/common/images/directory.png new file mode 100644 index 0000000000000000000000000000000000000000..c730b81668b073ce2560c042d85aa81e624f75dd Binary files /dev/null and b/UI/Toolbar/entry/src/main/js/default/common/images/directory.png differ diff --git a/UI/Toolbar/entry/src/main/js/default/common/images/next.png b/UI/Toolbar/entry/src/main/js/default/common/images/next.png new file mode 100644 index 0000000000000000000000000000000000000000..bfebc6fc5d445371169d555b6c8bfaafcbbac078 Binary files /dev/null and b/UI/Toolbar/entry/src/main/js/default/common/images/next.png differ diff --git a/UI/Toolbar/entry/src/main/js/default/common/images/previous.png b/UI/Toolbar/entry/src/main/js/default/common/images/previous.png new file mode 100644 index 0000000000000000000000000000000000000000..352237ef60beb4aadffaceb73280f8d790b7f9c4 Binary files /dev/null and b/UI/Toolbar/entry/src/main/js/default/common/images/previous.png differ diff --git a/UI/Toolbar/entry/src/main/js/default/i18n/en-US.json b/UI/Toolbar/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..d5f2f0c547a3de0c0ed73a166d4d827e5e6bba94 --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,14 @@ +{ + "strings": { + "directory": "directory", + "the": "The ", + "chapter": " chapter", + "context": "context", + "previous": "previous", + "next": "next", + "bright": "bright", + "dark": "dark", + "first": "The current chapter is the final chapter", + "last": "The current chapter is the first chapter" + } +} \ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/js/default/i18n/zh-CN.json b/UI/Toolbar/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..e72e8927eee26425ae0b452825a10736c89a9e55 --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,14 @@ +{ + "strings": { + "directory": "目录", + "the": "第", + "chapter": "章", + "context": "内容", + "previous": "上一章", + "next": "下一章", + "bright": "亮色", + "dark": "暗色", + "first": "当前章节为第一章", + "last": "当前章节为最后一章" + } +} \ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/js/default/pages/index/index.css b/UI/Toolbar/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2cef16bb3dfab69401e3498d1980f42e92dbac21 --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +.container { + flex-direction: column; + align-items: center; + background-color: #ABDAFF; +} + +.title { + margin-top: 20px; + margin-bottom: 20px; + font-size: 30px; +} + +.item { + height: 60px; + background-color: #FAFAFA; + margin-top: 2px; +} + +.list { + flex-direction:column; + justify-content:center; + align-items:center +} + +.text { + margin-left: 10px; + font-size: 24px; +} \ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/js/default/pages/index/index.hml b/UI/Toolbar/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..9ed3d2251fab6dd9e8d1201eb5bd8ff717ae7c7e --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,24 @@ + + +
+ {{$t('strings.directory')}} + + + {{$item.title}} + + +
\ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/js/default/pages/index/index.js b/UI/Toolbar/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..54257760ca86a3f3e082694266a5b5ef6cfb1d36 --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import router from '@system.router'; +export default { + data: { + list: [] + }, + onInit() { + for(var i = 1; i <= 15; i++) { + var item = { uri: "pages/toolbar/index", + title: this.$t('strings.the') + i + this.$t('strings.chapter'), id: i } + this.list.push(item); + } + }, + jumpPage(id, uri) { + var cardId = this.$element(id).attr.id + router.push({ + uri: uri, + params : { ref : cardId } + }); + } +} diff --git a/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.css b/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.css new file mode 100644 index 0000000000000000000000000000000000000000..f17a967cab145a8bd2fbdb2ac8c1d38c511b1829 --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.css @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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; + justify-content: center; +} + +.list { + height: 85%; + width: 100%; + flex-direction: column; + align-items: center; + justify-content: center; +} + +.title { + position: absolute; + top: 15px; + left: 10px; + font-size: 30px; +} + +.text { + font-size: 24px; +} + +.toolbar { + width: 100%; + position: absolute; + bottom: 0px; + opacity: 0.6; +} + diff --git a/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.hml b/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..a1b7a2776d91cab0428b92b7f1053caf20a207fd --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.hml @@ -0,0 +1,27 @@ + + +
+ {{ title }} +
+ {{$t('strings.context')}} +
+ + + + + + +
\ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.js b/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.js new file mode 100644 index 0000000000000000000000000000000000000000..96c61878e82a2418211e5c633b72d42fedf8e04e --- /dev/null +++ b/UI/Toolbar/entry/src/main/js/default/pages/toolbar/index.js @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import prompt from '@system.prompt'; +import router from '@system.router' + +export default { + data: { + container_background: "white", + list_background: "white", + hidden: "hidden", + title: "", + num: 0, + isState: true, + isHidden: false + }, + onInit() { + this.num = this.ref + this.flash(this.num) + }, + flash(a) { + this.title = this.$t('strings.the') + JSON.stringify(a) + this.$t('strings.chapter') + }, + show() { + if(this.isHidden){ + this.hidden = "hidden" + this.isHidden = false + } else { + this.hidden = "visible" + this.isHidden = true + } + }, + jumpBack() { + router.push({ + uri: "pages/index/index" + }) + }, + black() { + if (this.isState) { + this.isState = false + this.container_background = "#999999" + this.list_background = "#999999" + } else { + this.isState = true + this.container_background = "white" + this.list_background = "white" + } + }, + change(x) { + if(this.num == 1 && x == "previous") { + prompt.showToast({message: this.$t('strings.first')}) + } else if(x == "previous") { + this.flash(--this.num) + } else if(this.num == 15 && x == "next") { + prompt.showToast({message: this.$t('strings.last')}) + } else if(x == "next") { + this.flash(++this.num) + } + } +} \ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/resources/base/element/string.json b/UI/Toolbar/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a4898df1c20d9896e4cc7f9d8e5bab9c5577eb59 --- /dev/null +++ b/UI/Toolbar/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "Toolbar" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/resources/base/media/icon.png b/UI/Toolbar/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/UI/Toolbar/entry/src/main/resources/base/media/icon.png differ diff --git a/UI/Toolbar/entry/src/main/resources/en/element/string.json b/UI/Toolbar/entry/src/main/resources/en/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..66e02a40851f577356389edbf6f98ecb728d5d6b --- /dev/null +++ b/UI/Toolbar/entry/src/main/resources/en/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Toobar" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/UI/Toolbar/entry/src/main/resources/zh/element/string.json b/UI/Toolbar/entry/src/main/resources/zh/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..94f68c95752d5982bdacd719329b26d486a04240 --- /dev/null +++ b/UI/Toolbar/entry/src/main/resources/zh/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "工具栏" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/UI/Toolbar/screenshots/device/bright.png b/UI/Toolbar/screenshots/device/bright.png new file mode 100644 index 0000000000000000000000000000000000000000..8fdae3863332908c87b4ab1d66cd83a05724e630 Binary files /dev/null and b/UI/Toolbar/screenshots/device/bright.png differ diff --git a/UI/Toolbar/screenshots/device/dark.png b/UI/Toolbar/screenshots/device/dark.png new file mode 100644 index 0000000000000000000000000000000000000000..404dc8cf72087f8419758c62762c359eb16f1ca8 Binary files /dev/null and b/UI/Toolbar/screenshots/device/dark.png differ diff --git a/UI/Toolbar/screenshots/device/directory.png b/UI/Toolbar/screenshots/device/directory.png new file mode 100644 index 0000000000000000000000000000000000000000..41c988081fdb8ff76dcaa8fe36b4709b4de8daa0 Binary files /dev/null and b/UI/Toolbar/screenshots/device/directory.png differ diff --git a/UI/Toolbar/screenshots/device/toolbar.png b/UI/Toolbar/screenshots/device/toolbar.png new file mode 100644 index 0000000000000000000000000000000000000000..490a41a9eae8e765f2c7646dbad1b56a62159f10 Binary files /dev/null and b/UI/Toolbar/screenshots/device/toolbar.png differ diff --git a/UI/Toolbar/settings.gradle b/UI/Toolbar/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..4773db73233a570c2d0c01a22e75321acfbf7a07 --- /dev/null +++ b/UI/Toolbar/settings.gradle @@ -0,0 +1 @@ +include ':entry' diff --git a/UI/chart/entry/src/main/js/default/common/common.css b/UI/chart/entry/src/main/js/default/common/common.css new file mode 100644 index 0000000000000000000000000000000000000000..d7ebf4fc67eddf49e151b8f843d089be856bbb94 --- /dev/null +++ b/UI/chart/entry/src/main/js/default/common/common.css @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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; + justify-content: center; + align-items: center; +} diff --git a/common/HelloWorld/entry/src/main/java/ohos/samples/helloworld/MainAbility.java b/common/HelloWorld/entry/src/main/java/ohos/samples/helloworld/MainAbility.java index 17853279e4fca961b38e569a21558784ff3f28ea..3eba1ebb59cd1917e70e5dc696806ed82b63e119 100644 --- a/common/HelloWorld/entry/src/main/java/ohos/samples/helloworld/MainAbility.java +++ b/common/HelloWorld/entry/src/main/java/ohos/samples/helloworld/MainAbility.java @@ -15,12 +15,9 @@ package ohos.samples.helloworld; -import ohos.samples.helloworld.slice.MainAbilitySlice; - import ohos.aafwk.ability.Ability; import ohos.aafwk.content.Intent; -import ohos.bundle.IBundleManager; -import ohos.security.SystemPermission; +import ohos.samples.helloworld.slice.MainAbilitySlice; /** * MainAbility diff --git a/common/HelloWorld/entry/src/main/resources/base/element/string.json b/common/HelloWorld/entry/src/main/resources/base/element/string.json index b20b073a59cac0d1d07a5590c9d82be4faf10146..076d188e41aff662abcf05f93c28ed4ea3aa90cb 100644 --- a/common/HelloWorld/entry/src/main/resources/base/element/string.json +++ b/common/HelloWorld/entry/src/main/resources/base/element/string.json @@ -11,6 +11,14 @@ { "name": "secondability_description", "value": "hap sample empty provider" + }, + { + "name": "hello", + "value": "Hello World" + }, + { + "name": "next", + "value": "Next" } ] } \ No newline at end of file diff --git a/common/HelloWorld/entry/src/main/resources/base/layout/main_ability_slice.xml b/common/HelloWorld/entry/src/main/resources/base/layout/main_ability_slice.xml index 8996c838cb9d0422c1166d9b86918963fe645c04..6aa2d1931f590b00449a86f7a317ac07607a7c12 100644 --- a/common/HelloWorld/entry/src/main/resources/base/layout/main_ability_slice.xml +++ b/common/HelloWorld/entry/src/main/resources/base/layout/main_ability_slice.xml @@ -22,7 +22,7 @@ ohos:id="$+id:text" ohos:width="match_content" ohos:height="match_content" - ohos:text="Hello World" + ohos:text="$string:hello" ohos:text_color="#000000" ohos:text_size="32fp" ohos:center_in_parent="true"/> @@ -30,7 +30,7 @@ ohos:id="$+id:button" ohos:width="match_content" ohos:height="match_content" - ohos:text="Next" + ohos:text="$string:next" ohos:text_size="19fp" ohos:text_color="#FFFFFF" ohos:background_element="$graphic:background_button" diff --git a/common/Resources/entry/src/main/java/ohos/samples/resource/slice/MainAbilitySlice.java b/common/Resources/entry/src/main/java/ohos/samples/resource/slice/MainAbilitySlice.java index 66972b2ff5359230bd4d5c23c5a87a13afd5c922..f092c437be39fc9d996ed6192e61b30516ec334f 100644 --- a/common/Resources/entry/src/main/java/ohos/samples/resource/slice/MainAbilitySlice.java +++ b/common/Resources/entry/src/main/java/ohos/samples/resource/slice/MainAbilitySlice.java @@ -29,6 +29,7 @@ import ohos.hiviewdfx.HiLogLabel; import ohos.samples.resource.ResourceTable; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Arrays; /** @@ -41,8 +42,6 @@ public class MainAbilitySlice extends AbilitySlice { private static final String RAW_FILE = "entry/resources/rawfile/text.txt"; - private Component btnResource; - private Text resourcesText; @Override @@ -53,7 +52,7 @@ public class MainAbilitySlice extends AbilitySlice { } private void initComponents() { - btnResource = findComponentById(ResourceTable.Id_btn_resource); + Component btnResource = findComponentById(ResourceTable.Id_btn_resource); resourcesText = (Text) findComponentById(ResourceTable.Id_resourece_text); btnResource.setClickedListener(component -> getResources()); } @@ -88,7 +87,7 @@ public class MainAbilitySlice extends AbilitySlice { byte[] bytes = new byte[resource.available()]; String appends = null; while ((resource.read(bytes)) != -1) { - appends = (builder.append(new String(bytes, "UTF-8"))).toString(); + appends = (builder.append(new String(bytes, StandardCharsets.UTF_8))).toString(); } HiLog.info(LABEL_LOG, "%{public}s", appends); resourcesText.setText( diff --git a/common/Resources/entry/src/main/resources/base/element/string.json b/common/Resources/entry/src/main/resources/base/element/string.json index 3d8d81882d949dce7b53ee8e1af0b640fc80f8df..b72fdd96ab5e9ecdb31927c0ff34c4fbe9e83c80 100644 --- a/common/Resources/entry/src/main/resources/base/element/string.json +++ b/common/Resources/entry/src/main/resources/base/element/string.json @@ -11,6 +11,10 @@ { "name": "select_timezone_text", "value": "Resource file display" + }, + { + "name": "getResources", + "value": "getResources" } ] } \ No newline at end of file diff --git a/common/Resources/entry/src/main/resources/base/layout/main_ability_slice.xml b/common/Resources/entry/src/main/resources/base/layout/main_ability_slice.xml index fd6628c572ab045ce734d83ecc0456a0fcd01b3f..87ed92d0b426c70dce6bea914f6aa1422cce2e37 100644 --- a/common/Resources/entry/src/main/resources/base/layout/main_ability_slice.xml +++ b/common/Resources/entry/src/main/resources/base/layout/main_ability_slice.xml @@ -24,7 +24,7 @@ ohos:text_size="30fp" ohos:width="match_parent" ohos:height="match_content" - ohos:text="getResources" + ohos:text="$string:getResources" ohos:text_color="#ffffff" ohos:background_element="#000fff"/> diff --git a/common/Timer/entry/src/main/java/ohos/timer/slice/MainAbilitySlice.java b/common/Timer/entry/src/main/java/ohos/timer/slice/MainAbilitySlice.java index 5912a426b5e15fd6524c2d0f6d322abc77257e8d..95e51d0c9df0b4cad03846da807b53520a6c2a54 100644 --- a/common/Timer/entry/src/main/java/ohos/timer/slice/MainAbilitySlice.java +++ b/common/Timer/entry/src/main/java/ohos/timer/slice/MainAbilitySlice.java @@ -24,7 +24,6 @@ import ohos.timer.utils.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.DirectionalLayout; import ohos.agp.components.InputAttribute; @@ -265,9 +264,6 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL private boolean isNumeric(String str) { Pattern pattern = Pattern.compile("[0-9]*"); Matcher isNum = pattern.matcher(str); - if (!isNum.matches()) { - return false; - } - return true; + return isNum.matches(); } } diff --git a/common/Timer/entry/src/main/java/ohos/timer/timerpluginutils/CountDownUtil.java b/common/Timer/entry/src/main/java/ohos/timer/timerpluginutils/CountDownUtil.java index 3b1b50caf7a79c9c889c5ae093e64ef979b79b3c..ac8691879bda3a571701a8f85261830dbccfacda 100644 --- a/common/Timer/entry/src/main/java/ohos/timer/timerpluginutils/CountDownUtil.java +++ b/common/Timer/entry/src/main/java/ohos/timer/timerpluginutils/CountDownUtil.java @@ -23,11 +23,11 @@ import ohos.timer.utils.LogUtil; public class CountDownUtil { private static final String TAG = CountDownUtil.class.getSimpleName(); - private long millisInFuture; + private final long millisInFuture; - private CountDownCallback countDownCallback; + private final CountDownCallback countDownCallback; - private CountDownTimer countDownTimer; + private final CountDownTimer countDownTimer; private boolean isCancel; diff --git a/common/Timer/entry/src/main/java/ohos/timer/timerpluginutils/TimerPlugin.java b/common/Timer/entry/src/main/java/ohos/timer/timerpluginutils/TimerPlugin.java index e9ee6040cca1012ad35af624ee779a2c2bfdbcbd..ecf1eed7b7b192a07d7940d6742030c8ab3ba4e1 100644 --- a/common/Timer/entry/src/main/java/ohos/timer/timerpluginutils/TimerPlugin.java +++ b/common/Timer/entry/src/main/java/ohos/timer/timerpluginutils/TimerPlugin.java @@ -15,32 +15,24 @@ package ohos.timer.timerpluginutils; -import static ohos.miscservices.timeutility.Timer.ABILITY_TYPE_COMMON_EVENT; -import static ohos.miscservices.timeutility.Timer.TIMER_TYPE_EXACT; -import static ohos.miscservices.timeutility.Timer.TIMER_TYPE_WAKEUP; - -import ohos.timer.interfaces.TimerEventListener; -import ohos.timer.slice.MainAbilitySlice; -import ohos.timer.utils.Constant; -import ohos.timer.utils.LogUtil; - import ohos.aafwk.content.Intent; -import ohos.agp.window.dialog.ToastDialog; -import ohos.event.commonevent.CommonEventData; -import ohos.event.commonevent.CommonEventManager; - -import ohos.event.commonevent.CommonEventSubscribeInfo; -import ohos.event.commonevent.CommonEventSubscriber; -import ohos.event.commonevent.MatchingSkills; +import ohos.aafwk.content.Operation; +import ohos.event.commonevent.*; import ohos.eventhandler.EventHandler; import ohos.eventhandler.EventRunner; import ohos.eventhandler.InnerEvent; import ohos.miscservices.timeutility.Time; import ohos.miscservices.timeutility.Timer; import ohos.rpc.RemoteException; +import ohos.timer.interfaces.TimerEventListener; +import ohos.timer.slice.MainAbilitySlice; +import ohos.timer.utils.Constant; +import ohos.timer.utils.LogUtil; import java.util.Locale; +import static ohos.miscservices.timeutility.Timer.*; + /** * TimerPlugin implements CountDownUtil.CountDownCallback */ @@ -55,7 +47,7 @@ public class TimerPlugin implements CountDownUtil.CountDownCallback { private long timeLeftInMilSec = 0L; - private MainAbilitySlice mainSliceContext; + private final MainAbilitySlice mainSliceContext; private TimerEventListener timerEventListener; @@ -67,7 +59,7 @@ public class TimerPlugin implements CountDownUtil.CountDownCallback { mainSliceContext = sliceContext; } - private EventHandler handler = new EventHandler(EventRunner.current()) { + private final EventHandler handler = new EventHandler(EventRunner.current()) { @Override protected void processEvent(InnerEvent event) { if (event.eventId == EVENT_CODE) { @@ -118,7 +110,8 @@ public class TimerPlugin implements CountDownUtil.CountDownCallback { } Intent intent = new Intent(); - intent.setAction(Constant.REPEAT_TIMER_EVENT); + Operation operation = new Intent.OperationBuilder().withBundleName(Constant.REPEAT_TIMER_EVENT).build(); + intent.setOperation(operation); Timer.TimerIntent timerIntent = new Timer.TimerIntent(intent, ABILITY_TYPE_COMMON_EVENT); repeatTimer = Timer.RepeatTimer.getTimer(mainSliceContext, timerIntent); @@ -166,9 +159,7 @@ public class TimerPlugin implements CountDownUtil.CountDownCallback { } private void startOneShortTimer() { - Timer.OneShotTimer oneShotTimer = Timer.OneShotTimer.getTimer(mainSliceContext, () -> { - timerEventListener.notifyTimerCompleted(); - }); + Timer.OneShotTimer oneShotTimer = Timer.OneShotTimer.getTimer(mainSliceContext, () -> timerEventListener.notifyTimerCompleted()); oneShotTimer.start(TIMER_TYPE_WAKEUP, Time.getCurrentTime() + millisInFuture); } diff --git a/common/Timer/entry/src/main/resources/base/element/string.json b/common/Timer/entry/src/main/resources/base/element/string.json index f3029c9cfe3712855a7087f20a9238be7c4502cc..2538b607ebf5b4bd58602d3a14a04e7e36b5f34a 100644 --- a/common/Timer/entry/src/main/resources/base/element/string.json +++ b/common/Timer/entry/src/main/resources/base/element/string.json @@ -43,6 +43,18 @@ { "name": "mainability_description", "value": "hap sample empty page" + }, + { + "name": "timer", + "value": "Timer" + }, + { + "name": "repeat", + "value": "Repeat Timer" + }, + { + "name": "sans", + "value": "sans-serif-medium" } ] } \ No newline at end of file diff --git a/common/Timer/entry/src/main/resources/base/layout/main_ability_slice.xml b/common/Timer/entry/src/main/resources/base/layout/main_ability_slice.xml index 0bd144aafb68708b894cb068cccaad58cdebcea6..01228210b772e0ab893b69366991d98ce6063d44 100644 --- a/common/Timer/entry/src/main/resources/base/layout/main_ability_slice.xml +++ b/common/Timer/entry/src/main/resources/base/layout/main_ability_slice.xml @@ -37,7 +37,7 @@ ohos:width="match_content" ohos:layout_alignment="center" ohos:alignment="center" - ohos:orientation="hoziontal"> + ohos:orientation="horizontal"> + ohos:orientation="horizontal"> + ohos:orientation="horizontal"> + ohos:orientation="horizontal">