diff --git a/UI/JsTimer/README_zh.md b/UI/JsTimer/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..9fafa9c686f833e7579d9138dccb1e47c3d7e8e1 --- /dev/null +++ b/UI/JsTimer/README_zh.md @@ -0,0 +1,16 @@ +# 定时器与系统时间设置 + +### 简介 + +本示例通过 systemTime 接口来实现设置系统时间,通过 setTimeout() 等函数来设置定时器。 + +### 使用说明 + +点击时间框,选择时间日期,点击相应按钮来设置系统时间; + +点击倒计时框,选择定时器的时长,点击按钮来启动定时器,若想中途放弃定时任务,点击取消按钮。 + +### 约束与限制 + +本示例仅支持在标准系统上运行。 + diff --git a/UI/JsTimer/build.gradle b/UI/JsTimer/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..1b3e0fec17de0c99cac160a912d7914d4b49214d --- /dev/null +++ b/UI/JsTimer/build.gradle @@ -0,0 +1,33 @@ +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/' + } + } + 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/' + } + } +} \ No newline at end of file diff --git a/UI/JsTimer/entry/build.gradle b/UI/JsTimer/entry/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..bdd062a7561aa5eb7aff41d19322ee21d13a72a5 --- /dev/null +++ b/UI/JsTimer/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" +} \ No newline at end of file diff --git a/UI/JsTimer/entry/src/main/config.json b/UI/JsTimer/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..7f7c9265ff98ada04e38fef5e0dcb69282351bed --- /dev/null +++ b/UI/JsTimer/entry/src/main/config.json @@ -0,0 +1,57 @@ +{ + "app": { + "bundleName": "ohos.samples.jstimer", + "vendor": "samples", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.samples.jstimer", + "name": ".MyApplication", + "mainAbility": "ohos.samples.jstimer.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.jstimer.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/UI/JsTimer/entry/src/main/js/default/app.js b/UI/JsTimer/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..d7e076f8bc1c94876554011c7dc9cef4385e1593 --- /dev/null +++ b/UI/JsTimer/entry/src/main/js/default/app.js @@ -0,0 +1,24 @@ +'@file function' +/* + * 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/JsTimer/entry/src/main/js/default/i18n/en-US.json b/UI/JsTimer/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..f3a4507be4004695d2ddd89d0c4c712277ebe103 --- /dev/null +++ b/UI/JsTimer/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,12 @@ +{ + "strings": { + "time-text": "time", + "countdown": "countdown", + "setTimer": "set timer", + "success": "start the time", + "failure": "cancel setting timer", + "setSystemTime": "set system time", + "setup": "set up the success", + "shutdown": "end of the timing" + } +} \ No newline at end of file diff --git a/UI/JsTimer/entry/src/main/js/default/i18n/zh-CN.json b/UI/JsTimer/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..eae462447449fc0e815b869d88a8adddad6a61f7 --- /dev/null +++ b/UI/JsTimer/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,12 @@ +{ + "strings": { + "time-text": "时间", + "countdown": "倒计时", + "setTimer": "设置定时器", + "success": "开始计时", + "failure": "取消定时器", + "setSystemTime": "设置系统时间", + "setup": "设置成功", + "shutdown": "计时结束" + } +} \ No newline at end of file diff --git a/UI/JsTimer/entry/src/main/js/default/pages/index/index.css b/UI/JsTimer/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..f1e4221778765cff445ebcb72ccbcb569266bdd6 --- /dev/null +++ b/UI/JsTimer/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,52 @@ +/* + * 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 { + width: 100%; + height: 100%; + flex-direction: column; + justify-content: center; + align-items: center; +} + +.picker { + width: 200px; + height: 30px; + font-size: 16px; + margin-left: 20px; + text-align: center; + border-width: 1px; + border-style: solid; + border-color: #000; +} + +.text { + height: 30px; + font-size: 16px; +} + +.picker-text { + width: 100%; + height: 50px; + align-items: center; + justify-content: center; +} + +.btn { + width: 60%; + height: 48px; + font-size: 16px; + margin-top: 20px; +} \ No newline at end of file diff --git a/UI/JsTimer/entry/src/main/js/default/pages/index/index.hml b/UI/JsTimer/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..34c2c01deee4b59d3a4907fc6d18db1e989ec8e6 --- /dev/null +++ b/UI/JsTimer/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,30 @@ + + +