diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fdc0c4a --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +/entry/.preview +.cxx +/node_modules diff --git a/README.md b/README.md new file mode 100644 index 0000000..07ff56a --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# smart_watch_seven +watch 7 +This is a smart watch library +trial \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..f80876c --- /dev/null +++ b/build.gradle @@ -0,0 +1,33 @@ +// 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/en/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 6 +} + +buildscript { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + } + dependencies { + classpath 'com.huawei.ohos:hap:3.0.3.4' + classpath 'com.huawei.ohos:decctest:1.2.6.0' + } +} + +allprojects { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + } +} diff --git a/entry/.gitignore b/entry/.gitignore new file mode 100644 index 0000000..7d5b7a9 --- /dev/null +++ b/entry/.gitignore @@ -0,0 +1,2 @@ +/build +/node_modules diff --git a/entry/build.gradle b/entry/build.gradle new file mode 100644 index 0000000..2830ac3 --- /dev/null +++ b/entry/build.gradle @@ -0,0 +1,26 @@ +apply plugin: 'com.huawei.ohos.hap' +apply plugin: 'com.huawei.ohos.decctest' +//For instructions on signature configuration, see https://developer.harmonyos.com/en/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 6 + 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.1' + ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.200' +} +decc { + supportType = ['html','xml'] +} diff --git a/entry/package-lock.json b/entry/package-lock.json new file mode 100644 index 0000000..48e341a --- /dev/null +++ b/entry/package-lock.json @@ -0,0 +1,3 @@ +{ + "lockfileVersion": 1 +} diff --git a/entry/package.json b/entry/package.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/entry/package.json @@ -0,0 +1 @@ +{} diff --git a/entry/proguard-rules.pro b/entry/proguard-rules.pro new file mode 100644 index 0000000..f7666e4 --- /dev/null +++ b/entry/proguard-rules.pro @@ -0,0 +1 @@ +# config module specific ProGuard rules here. \ No newline at end of file diff --git a/entry/src/main/config.json b/entry/src/main/config.json new file mode 100644 index 0000000..cffaf47 --- /dev/null +++ b/entry/src/main/config.json @@ -0,0 +1,74 @@ +{ + "app": { + "bundleName": "com.example.smartwatchseven", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.smartwatchseven", + "name": ".MyApplication", + "mainAbility": "com.example.smartwatchseven.MainAbility", + "deviceType": [ + "phone", + "tablet", + "tv", + "wearable" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": "com.example.smartwatchseven.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 + } + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.ACTIVITY_MOTION", + "reason": "To count steps", + "usedScene": + { + "ability": [ + "com.example.smartwatchseven.MainAbility" + ], + "when": "always" + } + } + ] + } +} \ No newline at end of file diff --git a/entry/src/main/java/com/example/smartwatchseven/MainAbility.java b/entry/src/main/java/com/example/smartwatchseven/MainAbility.java new file mode 100644 index 0000000..beb7291 --- /dev/null +++ b/entry/src/main/java/com/example/smartwatchseven/MainAbility.java @@ -0,0 +1,16 @@ +package com.example.smartwatchseven; + +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/entry/src/main/java/com/example/smartwatchseven/MyApplication.java b/entry/src/main/java/com/example/smartwatchseven/MyApplication.java new file mode 100644 index 0000000..74fa96e --- /dev/null +++ b/entry/src/main/java/com/example/smartwatchseven/MyApplication.java @@ -0,0 +1,10 @@ +package com.example.smartwatchseven; + +import ohos.aafwk.ability.AbilityPackage; + +public class MyApplication extends AbilityPackage { + @Override + public void onInitialize() { + super.onInitialize(); + } +} diff --git a/entry/src/main/js/default/app.js b/entry/src/main/js/default/app.js new file mode 100644 index 0000000..aa35176 --- /dev/null +++ b/entry/src/main/js/default/app.js @@ -0,0 +1,23 @@ +import ability_featureAbility from '@ohos.ability.featureAbility' + +export default { + onCreate() { + console.info('AceApplication onCreate'); + //requestPermission() + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; + +//function requestPermission() { +// var context = ability_featureAbility.getContext(); +// let permissions = ["ohos.permission.ACTIVITY_MOTION"]; +// let requestCode = 123 +// context.requestPermissionsFromUser(permissions, requestCode) +// .then((data) => { +// console.info('Permission Granted') +// }).catch((error) => { +// console.error('Permission Denied') +// }) +//} diff --git a/entry/src/main/js/default/common/images/12,3,6,9_point.png b/entry/src/main/js/default/common/images/12,3,6,9_point.png new file mode 100644 index 0000000..3a9bf21 Binary files /dev/null and b/entry/src/main/js/default/common/images/12,3,6,9_point.png differ diff --git a/entry/src/main/js/default/common/images/Calories_icon.png b/entry/src/main/js/default/common/images/Calories_icon.png new file mode 100644 index 0000000..92e4dfe Binary files /dev/null and b/entry/src/main/js/default/common/images/Calories_icon.png differ diff --git a/entry/src/main/js/default/common/images/Hour_needle.png b/entry/src/main/js/default/common/images/Hour_needle.png new file mode 100644 index 0000000..de05118 Binary files /dev/null and b/entry/src/main/js/default/common/images/Hour_needle.png differ diff --git a/entry/src/main/js/default/common/images/Minutes_needle.png b/entry/src/main/js/default/common/images/Minutes_needle.png new file mode 100644 index 0000000..0737619 Binary files /dev/null and b/entry/src/main/js/default/common/images/Minutes_needle.png differ diff --git a/entry/src/main/js/default/common/images/MyApplication2.zip b/entry/src/main/js/default/common/images/MyApplication2.zip new file mode 100644 index 0000000..ac14c26 Binary files /dev/null and b/entry/src/main/js/default/common/images/MyApplication2.zip differ diff --git a/entry/src/main/js/default/common/images/Schedule_icon.png b/entry/src/main/js/default/common/images/Schedule_icon.png new file mode 100644 index 0000000..89b5af0 Binary files /dev/null and b/entry/src/main/js/default/common/images/Schedule_icon.png differ diff --git a/entry/src/main/js/default/common/images/Thunderstorm.png b/entry/src/main/js/default/common/images/Thunderstorm.png new file mode 100644 index 0000000..4e132ca Binary files /dev/null and b/entry/src/main/js/default/common/images/Thunderstorm.png differ diff --git a/entry/src/main/js/default/common/images/antique_midpoint.png b/entry/src/main/js/default/common/images/antique_midpoint.png new file mode 100644 index 0000000..0d7f444 Binary files /dev/null and b/entry/src/main/js/default/common/images/antique_midpoint.png differ diff --git a/entry/src/main/js/default/common/images/bg.png b/entry/src/main/js/default/common/images/bg.png new file mode 100644 index 0000000..c7d2528 Binary files /dev/null and b/entry/src/main/js/default/common/images/bg.png differ diff --git a/entry/src/main/js/default/common/images/bg_black.png b/entry/src/main/js/default/common/images/bg_black.png new file mode 100644 index 0000000..e4f42d7 Binary files /dev/null and b/entry/src/main/js/default/common/images/bg_black.png differ diff --git a/entry/src/main/js/default/common/images/cloudy.png b/entry/src/main/js/default/common/images/cloudy.png new file mode 100644 index 0000000..8ac53c9 Binary files /dev/null and b/entry/src/main/js/default/common/images/cloudy.png differ diff --git a/entry/src/main/js/default/common/images/lens effect.png b/entry/src/main/js/default/common/images/lens effect.png new file mode 100644 index 0000000..ca214d5 Binary files /dev/null and b/entry/src/main/js/default/common/images/lens effect.png differ diff --git a/entry/src/main/js/default/common/images/partly_sunny.png b/entry/src/main/js/default/common/images/partly_sunny.png new file mode 100644 index 0000000..1b774de Binary files /dev/null and b/entry/src/main/js/default/common/images/partly_sunny.png differ diff --git a/entry/src/main/js/default/common/images/rainy.png b/entry/src/main/js/default/common/images/rainy.png new file mode 100644 index 0000000..52e32a7 Binary files /dev/null and b/entry/src/main/js/default/common/images/rainy.png differ diff --git a/entry/src/main/js/default/common/images/seconds_needle.png b/entry/src/main/js/default/common/images/seconds_needle.png new file mode 100644 index 0000000..1393b38 Binary files /dev/null and b/entry/src/main/js/default/common/images/seconds_needle.png differ diff --git a/entry/src/main/js/default/common/images/sleeting.png b/entry/src/main/js/default/common/images/sleeting.png new file mode 100644 index 0000000..aa2eabe Binary files /dev/null and b/entry/src/main/js/default/common/images/sleeting.png differ diff --git a/entry/src/main/js/default/common/images/steps_icon.png b/entry/src/main/js/default/common/images/steps_icon.png new file mode 100644 index 0000000..d47acf2 Binary files /dev/null and b/entry/src/main/js/default/common/images/steps_icon.png differ diff --git a/entry/src/main/js/default/common/images/sun & rain.png b/entry/src/main/js/default/common/images/sun & rain.png new file mode 100644 index 0000000..6d4597b Binary files /dev/null and b/entry/src/main/js/default/common/images/sun & rain.png differ diff --git a/entry/src/main/js/default/common/images/sun & windy.png b/entry/src/main/js/default/common/images/sun & windy.png new file mode 100644 index 0000000..ded7b49 Binary files /dev/null and b/entry/src/main/js/default/common/images/sun & windy.png differ diff --git a/entry/src/main/js/default/common/images/sunny.png b/entry/src/main/js/default/common/images/sunny.png new file mode 100644 index 0000000..1d8aa50 Binary files /dev/null and b/entry/src/main/js/default/common/images/sunny.png differ diff --git a/entry/src/main/js/default/common/images/thunderstorm & rain.png b/entry/src/main/js/default/common/images/thunderstorm & rain.png new file mode 100644 index 0000000..39642a8 Binary files /dev/null and b/entry/src/main/js/default/common/images/thunderstorm & rain.png differ diff --git a/entry/src/main/js/default/common/images/windy.png b/entry/src/main/js/default/common/images/windy.png new file mode 100644 index 0000000..caf5dd6 Binary files /dev/null and b/entry/src/main/js/default/common/images/windy.png differ diff --git a/entry/src/main/js/default/common/poppins/CenturyGothic-Bold.TTF b/entry/src/main/js/default/common/poppins/CenturyGothic-Bold.TTF new file mode 100644 index 0000000..93faeb3 Binary files /dev/null and b/entry/src/main/js/default/common/poppins/CenturyGothic-Bold.TTF differ diff --git a/entry/src/main/js/default/common/poppins/Poppins-Regular.otf b/entry/src/main/js/default/common/poppins/Poppins-Regular.otf new file mode 100644 index 0000000..e5c4eee Binary files /dev/null and b/entry/src/main/js/default/common/poppins/Poppins-Regular.otf differ diff --git a/entry/src/main/js/default/common/poppins/Poppins-SemiBold.otf b/entry/src/main/js/default/common/poppins/Poppins-SemiBold.otf new file mode 100644 index 0000000..fcd0845 Binary files /dev/null and b/entry/src/main/js/default/common/poppins/Poppins-SemiBold.otf differ diff --git a/entry/src/main/js/default/i18n/en-US.json b/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000..e650f00 --- /dev/null +++ b/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,5 @@ +{ + "strings": { + "start_count": "Start Step Count" + } +} \ No newline at end of file diff --git a/entry/src/main/js/default/i18n/weather_api.json b/entry/src/main/js/default/i18n/weather_api.json new file mode 100644 index 0000000..21a8017 --- /dev/null +++ b/entry/src/main/js/default/i18n/weather_api.json @@ -0,0 +1,7 @@ +[ + { + "latitude": "28.4595", + "longitude": "77.0266", + "api_key": "55e15ebc8fdd929dd4c16583773384f3" + } +] diff --git a/entry/src/main/js/default/i18n/zh-CN.json b/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000..cce1af0 --- /dev/null +++ b/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/entry/src/main/js/default/pages/index/index.css b/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000..7ab22ea --- /dev/null +++ b/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,267 @@ +@font-face { + font-family: poppins-regular; + src: url('/common/poppins/Poppins-Regular.otf'); +} + +.centre { + border:2px solid green; + height: 20px; + width: 20px; + top: 105px; + left: 106px; + +} + +.second { + height: 85px; + width: 3px; + top: 125px; + left: 94.5px; + border-radius: 10px; + z-index: 1; +} + +.hour { + height: 50.08px; + width: 50.08px; + top: 69px; + left: 46px; + z-index: 1; +} + +.minute { + height: 48px; + width: 80px; + top: 70px; + left: 38px; + z-index: -1; +} + +.point { + height: 10px; + width: 9px; +} + +.point1 { + position: absolute; + top: 110px; + left: 0px; +} + +.point2 { + position: absolute; + top: 110px; + left: -200px; +} + +.point3 { + position: absolute; + top: 7px; + left: -100px; +} + +.point4 { + position: absolute; + top: 215px; + left: -101.5px; +} + +.calendar { + height: 20px; + width: 20px; + top: 155px; + left: -47px; +} + +.notification { + font-size: 6.5px; + font-family: poppins-regular; + colour: white; + height: 11px; + width: 86px; + top: 180px; + left: 85px; + position: absolute; + text-overflow: ellipsis; +} + +.weather { + height: 10.52px; + width: 13.46px; + top: 24.5px; + left: -70px; +} + +.weather_description { + font-size: 6.5px; + font-family: poppins-regular; + colour: white; + width: 23px; + height: 10px; + top: 25.5px; + left: -70px; + text-overflow: ellipsis; +} + +.date { + position: absolute; + font-size: 6.5px; + font-family: poppins-regular; + colour: white; + width: 57px; + height: 8px; + top: 40px; + left: 102px; + text-overflow: ellipsis; +} + +.background { + width: 230px; + height: 230px; + position: absolute; + z-index: -3; + top: 1px; + left: 1px; +} + +.bgblack { + width: 230px; + height: 230px; + position: absolute; + top: 1px; + left: 1px; + z-index: -2; +} + +.lens { + width: 230px; + height: 230px; + position: absolute; + z-index: -2; + top: 5px; + left: 0px; +} + +.container { + position: absolute; + height: 45px; + width: 45px; + top: 100px; + left: 40px; +} + +.calories_img { + position: absolute; + width: 10px; + height: 17px; + top: 103px; + left: 57px; +} + +.foots { + position: absolute; + width: 17px; + height: 20px; + top: 105px; + left: 169px; +} + +.calories { + position: absolute; + flex-direction: column; + height: 100%; + width: 100%; + align-items: center; + top: 95px; + left: -55px; +} + +.min_progress_calories { + width: 45px; + height: 45px; + background-color: #454545; + color: linear-gradient(#ff8c00, #ff4500); + stroke-width: 5px; +} + +.foot_steps { + position: absolute; + flex-direction: column; + height: 100%; + width: 100%; + align-items: center; + top: 97px; + left: 60px; +} + +.min_progress_footSteps { + width: 45px; + height: 45px; + background-color: #454545; + color: linear-gradient(#00ff7f, #0dbab1); + stroke-width: 5px; +} + +#value_container_calories { + position: absolute; + font-family: poppins-regular; + font-size: 6.5px; + top: 124px; + left: 54px; +} + +#value_container_footSteps { + position: absolute; + font-family: poppins-regular; + font-size: 6.5px; + top: 125px; + left: 170px; +} + +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.button { + background-color: #F2F2F2; + text-color: #0D81F2; + margin-top: 15px; +} + +.title { + font-size: 24px; + color: #000000; + opacity: 0.9; +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} + +@media screen and (device-type: wearable) { + .title { + font-size: 28px; + color: #FFFFFF; + } +} + +@media screen and (device-type: tv) { + .container {/* background-image: url("/common/images/Wallpaper.png");*/ + /* background-size: cover;*/ + /* background-repeat: no-repeat;*/ + /* background-position: center;*/ + + background-color: #242527; + } + + .title { + font-size: 100px; + color: #FFFFFF; + } +} \ No newline at end of file diff --git a/entry/src/main/js/default/pages/index/index.hml b/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000..e363989 --- /dev/null +++ b/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,84 @@ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ {{ notification }} +
+
+ + + + + + + + + + + + +
+
+ {{ weather_description }} +
+
+ {{ date_d }} {{ date_m }} | {{ date_w }} +
+
+ + + + +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ {{ min_progress_calories * 100 }} +
+
+ +
+
+ {{ min_progress_footSteps * 100 }} +
+ + + + + + + + + +
diff --git a/entry/src/main/js/default/pages/index/index.js b/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000..742c275 --- /dev/null +++ b/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,104 @@ +// @ts-nocheck +import ability_featureAbility from '@ohos.ability.featureAbility' +import sensor from '@system.sensor' +import fetch from '@system.fetch'; +import item from '../../i18n/weather_api.json'; + +export default { + data: { + // cloudy, windy, partly_sunny, rainy, sleeting, sun_n_rain, sun_n_windy, sunny, thunderstorm_n_rain, thunderstorm + weather: "", + weather_description:"", + notification:"Team Meeting 11am", + min_progress_calories:'50', + min_progress_footSteps:'65', + btnText: "", + mySteps: '', + sensorPermission: false + }, + fetchDate : function(){ + const date = new Date(); + this.date_d=(String(date.getDate())) + this.date_m=(String(date.getMonth()+1)) + const dayOfWeek = (date.getDay()) + const month=(date.getMonth()) + + var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; + this.date_w= days[dayOfWeek]; + + var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul','Aug','Sep','Oct','Nov','Dec']; + this.date_m= months[month]; + }, + fetchWeather: function () { + var dataw = JSON.stringify(item); + let weather_api_input = JSON.parse(dataw); + let data; + fetch.fetch({ + url: "https://api.openweathermap.org/data/2.5/weather?lat=" + weather_api_input[0].latitude + "&lon=" + weather_api_input[0].longitude + "&appid=" + weather_api_input[0].api_key, + responseType: "json", + method: 'GET', + success: function (resp) { + data = JSON.stringify(resp); + console.info('Weather data fetch success. Resp: ' + data); + }, + fail: function (data, code) { + console.log("fail data: " + JSON.stringify(data) + " fail code: " + code); + }, + complete: () => { + const { main } = data.weather[0]; + this.weather = main; + this.weather_description = main; + } + }) + }, + + fetchNotification: function () { + let data; + fetch.fetch({ + complete: () => { + this.notification=data.notification; + this.min_progress_calories=data.min_progress_calories; + this.min_progress_footSteps=data.min_progress_footSteps; + } + }) + }, + + onInit() { + this.fetchWeather(); + this.fetchNotification(); + this.fetchDate(); + this.btnText = this.$t('strings.start_count'); + }, + async startCounting() { + if (!this.sensorPermission) { + this.sensorPermission = await verifyPermissions() + } else { + subscribePedometerSensor(this) + } + } + } + +function verifyPermissions() { + var context = ability_featureAbility.getContext() + let permission = "ohos.permission.ACTIVITY_MOTION" + var result = new Promise((resolve, reject) => { + context.verifyPermission(permission) + .then((data) => { + resolve(true) + }).catch((error) => { + reject(false) + }) + }) + return result +} + +function subscribePedometerSensor(context) { + sensor.subscribeStepCounter({ + success: function(ret) { + context.mySteps = ret.steps.toString() + }, + fail: function(data, code) { + console.log('Subscription failed. Code: ' + code + '; Data: ' + data) + } + }) +} diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000..0bae6bd --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000..ce307a8 Binary files /dev/null and b/entry/src/main/resources/base/media/icon.png differ diff --git a/entry/src/ohosTest/java/com/example/smartwatchseven/ExampleOhosTest.java b/entry/src/ohosTest/java/com/example/smartwatchseven/ExampleOhosTest.java new file mode 100644 index 0000000..ce694d5 --- /dev/null +++ b/entry/src/ohosTest/java/com/example/smartwatchseven/ExampleOhosTest.java @@ -0,0 +1,14 @@ +package com.example.smartwatchseven; + +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.example.smartwatchseven", actualBundleName); + } +} \ No newline at end of file diff --git a/entry/src/ohosTest/js/default/app.js b/entry/src/ohosTest/js/default/app.js new file mode 100644 index 0000000..55b67e9 --- /dev/null +++ b/entry/src/ohosTest/js/default/app.js @@ -0,0 +1,8 @@ +export default { + onCreate() { + console.info('TestApplication onCreate'); + }, + onDestroy() { + console.info('TestApplication onDestroy'); + } +}; diff --git a/entry/src/ohosTest/js/default/i18n/en-US.json b/entry/src/ohosTest/js/default/i18n/en-US.json new file mode 100644 index 0000000..55561b8 --- /dev/null +++ b/entry/src/ohosTest/js/default/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/entry/src/ohosTest/js/default/i18n/zh-CN.json b/entry/src/ohosTest/js/default/i18n/zh-CN.json new file mode 100644 index 0000000..cce1af0 --- /dev/null +++ b/entry/src/ohosTest/js/default/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/entry/src/ohosTest/js/default/pages/index/index.css b/entry/src/ohosTest/js/default/pages/index/index.css new file mode 100644 index 0000000..4280f46 --- /dev/null +++ b/entry/src/ohosTest/js/default/pages/index/index.css @@ -0,0 +1,11 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.title { + font-size: 100px; +} diff --git a/entry/src/ohosTest/js/default/pages/index/index.hml b/entry/src/ohosTest/js/default/pages/index/index.hml new file mode 100644 index 0000000..f64b040 --- /dev/null +++ b/entry/src/ohosTest/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/entry/src/ohosTest/js/default/pages/index/index.js b/entry/src/ohosTest/js/default/pages/index/index.js new file mode 100644 index 0000000..8be2df2 --- /dev/null +++ b/entry/src/ohosTest/js/default/pages/index/index.js @@ -0,0 +1,41 @@ +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/entry/src/ohosTest/js/test/ExampleJsunit.test.js b/entry/src/ohosTest/js/test/ExampleJsunit.test.js new file mode 100644 index 0000000..b6d74ca --- /dev/null +++ b/entry/src/ohosTest/js/test/ExampleJsunit.test.js @@ -0,0 +1,10 @@ +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/entry/src/ohosTest/js/test/List.test.js b/entry/src/ohosTest/js/test/List.test.js new file mode 100644 index 0000000..305eb5b --- /dev/null +++ b/entry/src/ohosTest/js/test/List.test.js @@ -0,0 +1 @@ +require('./ExampleJsunit.test.js') \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/element/string.json b/entry/src/ohosTest/resources/base/element/string.json new file mode 100644 index 0000000..4388f58 --- /dev/null +++ b/entry/src/ohosTest/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MyApplication" + }, + { + "name": "mainability_description", + "value": "hap sample empty page" + } + ] +} diff --git a/entry/src/ohosTest/resources/base/media/icon.png b/entry/src/ohosTest/resources/base/media/icon.png new file mode 100644 index 0000000..ce307a8 Binary files /dev/null and b/entry/src/ohosTest/resources/base/media/icon.png differ diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..be49249 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,13 @@ +# Project-wide Gradle settings. +# IDE (e.g. DevEco Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# If the Chinese output is garbled, please configure the following parameter. +# This function is enabled by default when the DevEco Studio builds the hap/app,if you need disable gradle parallel,you should set org.gradle.parallel false. +# more information see https://docs.gradle.org/current/userguide/performance.html +# org.gradle.parallel=false +# org.gradle.jvmargs=-Dfile.encoding=GBK \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..490fda8 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..f59159e --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +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/gradlew b/gradlew new file mode 100644 index 0000000..2fe81a7 --- /dev/null +++ b/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# 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 +# +# https://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. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..62bd9b9 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,103 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/package.json b/package.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/package.json @@ -0,0 +1 @@ +{} diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..4773db7 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':entry'