diff --git a/display/entry/build.gradle b/display/entry/build.gradle index f83acd76..60fc1dd8 100644 --- a/display/entry/build.gradle +++ b/display/entry/build.gradle @@ -14,11 +14,11 @@ */ 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 6 + compileSdkVersion 8 defaultConfig { - compatibleSdkVersion 6 + compatibleSdkVersion 7 } buildTypes { release { @@ -28,14 +28,9 @@ ohos { } } } - } 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'] + testImplementation 'junit:junit:4.13.1' } diff --git a/display/entry/src/main/config.json b/display/entry/src/main/config.json index 946df5f4..b73d3a31 100644 --- a/display/entry/src/main/config.json +++ b/display/entry/src/main/config.json @@ -11,12 +11,10 @@ "module": { "package": "com.ohos.devicemanagerui", "name": ".MyApplication", - "mainAbility": "com.ohos.devicemanagerui.MainAbility", + "mainAbility": ".MainAbility", + "srcPath": "", "deviceType": [ - "phone", - "tablet", - "tv", - "wearable" + "phone" ], "distro": { "deliveryWithInstall": true, @@ -36,10 +34,14 @@ ] } ], + "orientation": "unspecified", "visible": true, - "name": "com.ohos.devicemanagerui.MainAbility", + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "js", "icon": "$media:icon", - "description": "$string:mainability_description", + "description": "$string:description_mainability", + "formsEnabled": false, "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" @@ -48,12 +50,13 @@ "js": [ { "pages": [ - "pages/index/index" + "pages/index/index", + "pages/second/second" ], - "name": "default", + "name": ".MainAbility", "window": { "designWidth": 720, - "autoDesignWidth": true + "autoDesignWidth": false } } ] diff --git a/display/entry/src/main/js/MainAbility/app.js b/display/entry/src/main/js/MainAbility/app.js new file mode 100644 index 00000000..4aa26e97 --- /dev/null +++ b/display/entry/src/main/js/MainAbility/app.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 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("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } +}; diff --git a/display/entry/src/main/js/MainAbility/i18n/en-US.json b/display/entry/src/main/js/MainAbility/i18n/en-US.json new file mode 100644 index 00000000..328519b8 --- /dev/null +++ b/display/entry/src/main/js/MainAbility/i18n/en-US.json @@ -0,0 +1,22 @@ +{ + "strings": { + "pinCodeConnection": "Pin connection", + "enterThePinCode": "Please enter the displayed pin code", + "delete": "Del", + "off": "Off", + + "toConnectToThisComputer": " connection", + "resourceAccess": "Resource access", + "cancel": "Cancel", + "parenthesesLeft": "(", + "parenthesesRight": ")", + "allow": "Allow", + + "applyAuth": "Allow open apply auth?", + "from": "From ", + + "enterDisplayPinCode": "Please enter the displayed pin code" + }, + "Files": { + } +} \ No newline at end of file diff --git a/display/entry/src/main/js/MainAbility/i18n/zh-CN.json b/display/entry/src/main/js/MainAbility/i18n/zh-CN.json new file mode 100644 index 00000000..254f9c12 --- /dev/null +++ b/display/entry/src/main/js/MainAbility/i18n/zh-CN.json @@ -0,0 +1,22 @@ +{ + "strings": { + "pinCodeConnection": "PIN码连接", + "enterThePinCode": "请输入PIN码", + "delete": "删除", + "off": "关闭", + + "toConnectToThisComputer": "想要连接本机", + "resourceAccess": "用于资源访问", + "cancel": "取消", + "parenthesesLeft": "(", + "parenthesesRight": ")", + "allow": "允许", + + "applyAuth": "是否允许连接?", + "from": "来自", + + "enterDisplayPinCode": "请在主控端输入连接码进行验证" + }, + "Files": { + } +} \ No newline at end of file diff --git a/display/entry/src/main/js/MainAbility/pages/index/index.css b/display/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 00000000..56a0c2ee --- /dev/null +++ b/display/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2022 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; + opacity: 0.8; + width: 100%; + background-color: azure; +} + +.container > div { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.main-pin { + flex-direction: column; + justify-content: center; + align-items: center; + opacity: 0.8; + width: 100%; + padding: 3% 0; + background-color: azure; +} +.main-pin > .pin-numb { + flex-direction: row; + justify-content: space-around; + align-items: center; + padding: 0 0px 3% 0px; +} +.main-pin > .pin-numb > .pin-numb-item { + font-size: 30px; + height: 14%; + margin: 0 5px; + padding-bottom: 2%; + font-weight: 800; + width: 30px; + border-bottom-width: 2px; + border-bottom-color: darkgray; + text-align: center; +} + +.main-pin > .input { + flex-direction: row; + justify-content: space-around; + align-items: center; + padding: 2%; +} + +.main-pin > .input > .numb { + text-color: black; + padding: 2%; + flex-shrink: 0; + margin: 0 5px; + flex-basis: 72px; + background-color: white; + border: 1px; +} + +.join-auth { + padding-top: 10%; +} +.join-auth-image > image { + height: 50%; +} +.join-authorize { + padding-top: 4%; +} +.join-pin { + padding: 4% 0; +} +.join-pin > .pin { + font-size: 50px; + height: 31%; + font-weight: bolder; + color: #000000; +} + +.join-auth > .title, +.join-auth-image > .title, +.join-authorize > .title { + font-size: 18px; + height: 28%; + font-weight: 800; + color: #000000; +} +.join-auth > .title { + height: 14%; +} +.join-auth-image > .title { + height: 9%; +} +.join-pin > .title { + font-size: 28px; + height: 20%; + font-weight: 800; +} +.main-pin > .title { + font-size: 30px; + height: 14%; + font-weight: bolder; +} + +.join-auth > .title-tip, +.join-auth-image > .title-tip, +.main-pin > .title-tip, +.join-authorize > .title-tip { + font-size: 15px; + height: 14%; + color: #5A5A5A; +} +.join-auth > .title-tip { + height: 14%; +} +.join-auth-image > .title-tip { + height: 8%; +} +.join-auth-image > .title-tip > image { + width: 30px; + height: 10%; + margin: 5px 10px 0 0; +} +.join-pin > .title-tip { + font-size: 20px; + height: 17%; + font-weight: 600; +} +.main-pin > .title-tip { + font-size: 18px; + height: 10%; + font-weight: 800; +} + +.join-auth > .dialog-foot, +.join-auth-image > .dialog-foot, +.join-authorize > .dialog-foot { + flex-direction: row; + justify-content: center; + align-items: center; + justify-content: space-around; + margin: 28% 20px 10% 20px; +} +.join-authorize > .dialog-foot { + margin: 35% 20px 10% 20px; +} +.join-auth-image > .dialog-foot { + margin: 3% 20px; +} +.join-pin > .dialog-foot { + margin: 3% 20px; +} + +.join-auth .button-cancel, +.join-auth-image .button-cancel, +.join-authorize .button-cancel { + width: 160px; + height: 12%; +} +.join-pin .button-cancel { + width: 100%; + font-size: 26px; + height: 17%; +} + +.join-auth .button-ok, +.join-auth-image .button-ok, +.join-authorize .button-ok { + width: 150px; + height: 12%; +} + +/* css of wifi page*/ +.join-wifi-container, +.main-wifi { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.input-container { + flex-direction: column; + justify-content: center; + align-items: center; + height: 50%; + width: 100%; + padding: 2% 15% 2% 15%; +} + +.keyboard-container { + flex-direction: column; + justify-content: center; + align-items: center; + height: 50%; + width: 100%; + padding: 1%; +} + +.input-title { + height: 15%; + font-size: 16px; + font-weight: bold; +} + +.input-area { + border: 1px solid darkgrey; + border-radius: 5px; + width: 100%; + height: 25%; + margin-top: 5%; +} + +.button-area { + flex-direction: row; + justify-content: space-around; + align-items: center; + height: 25%; + margin-top: 5%; + width: 80%; +} + +.input-label { + width: 20%; + font-size: 14px; + text-align: center; +} + +.input-text { + width: 60%; + font-size: 14px; + text-align: start; + padding-start: 5%; + max-lines: 1; +} + +.input-divider { + color: darkgrey; +} + +.button-row { + flex-direction: row; + justify-content: center; + height: 23%; + width: 100%; + margin: 1% 0; +} + +.wifi-button { + height: 100%; + font-size: 14px; +} + +.keyboard-button { + width: 9%; + margin: 0 1%; + height: 100%; + border: 1px solid darkgrey; + border-radius: 3px; + font-size: 12px; + text-align: center; +} + +.join-wifi-text { + width: 80%; + font-size: 16px; + text-align: center; + height: 33%; +} + diff --git a/display/entry/src/main/js/MainAbility/pages/index/index.hml b/display/entry/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 00000000..fc25d7c0 --- /dev/null +++ b/display/entry/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,149 @@ + + +
+
+ {{ $t('strings.pinCodeConnection') }} + {{ $t('strings.enterThePinCode') }} +
+ {{pin[0]}} + {{pin[1]}} + {{pin[2]}} + {{pin[3]}} + {{pin[4]}} + {{pin[5]}} +
+
+ + + + +
+
+ + + + +
+
+ + + + +
+
+
+ {{statusInfo.deviceName}}{{ $t('strings.toConnectToThisComputer') }} + {{ $t( 'strings.resourceAccess' ) }} +
+ + +
+
+ +
+ {{ statusInfo.appName }} + {{ $t('strings.applyAuth') }} + {{ $t('strings.from') }}{{statusInfo.deviceName}} +
+ + +
+
+ +
+
+ 请输入网络信息 +
+ SSID: + + {{wifiInfo.wifiSsid}} +
+
+ Key: + + {{wifiInfo.wifiPassword}} +
+
+ + +
+
+
+
+ {{ item }} + Del +
+
+ {{ item }} + Aa +
+
+ {{ item }} +
+
+ {{ item }} +
+
+
+ +
+ {{wifiInfo.wifiSsid}} + 配网成功 + 配网失败 + +
+ +
+ +
+ + {{ statusInfo.appName }} +
+ {{ $t('strings.applyAuth') }} + {{ $t('strings.from') }}{{statusInfo.deviceName}} +
+ + +
+
+
+ {{ $t('strings.pinCodeConnection') }} + {{ $t('strings.enterDisplayPinCode') }} + {{statusInfo.pinCode.split('').join(' ')}} +
+ +
+
+ +
diff --git a/display/entry/src/main/js/MainAbility/pages/index/index.js b/display/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 00000000..c10c5475 --- /dev/null +++ b/display/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,523 @@ +/* + * Copyright (c) 2022 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 deviceManager from '@ohos.distributedHardware.deviceManager'; +function uint8ArrayToBase64(array) { + array = new Uint8Array(array); + let table = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' + ,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2' + ,'3','4','5','6','7','8','9','+','/'], + base64Str = '', length = array.byteLength, i = 0; + for(i = 0; length - i >= 3; i += 3) { + let num1 = array[i], num2 = array[i + 1], num3 = array[i + 2]; + base64Str += table[num1 >>> 2] + table[((num1 & 0b11) << 4) | (num2 >>> 4)] + table[((num2 & 0b1111) << 2) | + (num3 >>> 6)] + table[num3 & 0b111111]; + } + const lastByte = length - i; + if(lastByte === 1) { + const lastNum1 = array[i]; + base64Str += table[lastNum1 >>> 2] + table[((lastNum1 & 0b11) << 4)] + '=='; + } else if(lastByte === 2){ + const lastNum1 = array[i]; + const lastNum2 = array[i + 1]; + base64Str += table[lastNum1 >>> 2] + table[((lastNum1 & 0b11) << 4) | (lastNum2 >>> 4)] + table[(lastNum2 & + 0b1111) << 2] + '='; + } + return 'data:image/png;base64,' + base64Str; +} +const TAG = "DeviceManagerUI:"; + +const AUTH_TYPE_PIN = 1 +const AUTH_TYPE_WIFI = 2 + +const LOWER_CASE_KEYS = { + line1 : ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'], + line2 : ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'], + line3 : [',', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', '.'], + line4 : [';', '*', 'z', 'x', 'c', 'v', 'b', 'n', 'm', '-', '_'], +} +const UPPER_CASE_KEYS = { + line1 : ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'], + line2 : ['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P'], + line3 : [',', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', '.'], + line4 : [';', '*', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '-', '_'], +} + +const CURRENT_FOCUS_SSID = 0 +const CURRENT_FOCUS_KEY = 1 + +const USER_WIFI_CANCEL_CODE = 5 + +const ACTIVE_COLOR = '#fff' +const INACTIVE_COLOR = '#ddd' + +const WIFI_CONFIGURE_SUCCESS = 0 +const WIFI_CONFIGURE_FAILED = 1 +const WIFI_CONFIGURE_DOING = 2 +const WIFI_CONFIGURE_DEFAULT = -1 + +let dmClass; + +export default { + data: { + // showType: ['main-pin','join-authorize','join-auth','join-auth-image','join-pin'] + status: "", + // showInfo + statusInfo: { + deviceName: "AppName", + appName: 'PackageName', + appIcon: null, + appThumbnail: null, + pinCode: '', + pinToken: '' + }, + // join: join-authorize timing + timeRemaining: 0, + // input pinCode + pin: ['','','','','',''], + // input pinCode next number + pinNumb: 0, + wifiInfo: { + wifiSsid: '', + wifiPassword: '' + }, + keyboardItem : LOWER_CASE_KEYS, + isSSidFocus : false, + isKeyFocus : false, + currentSsidColor : INACTIVE_COLOR, + currentKeyColor : INACTIVE_COLOR, + configureResult : WIFI_CONFIGURE_DEFAULT + }, + + log(m) { + console.info(TAG + m); + }, + + onDestroy() { + this.log("onDestroy") + if (dmClass != null) { + dmClass.off('dmFaCallback'); + dmClass.off('deviceStateChange'); + dmClass.off('serviceDie'); + dmClass.release(); + dmClass = null + } + }, + + onShow() { + if (dmClass) { + this.log('deviceManager exist') + this.initStatue() + } else { + this.log('createDeviceManager') + deviceManager.createDeviceManager('com.ohos.devicemanagerui', (err, dm) => { + this.log("createDeviceManager err:" + JSON.stringify(err) + ' --success:' + JSON.stringify(dm)) + if (err) return; + dmClass = dm; + dmClass.on('dmFaCallback', () => { + this.log("dmFaCallback executed, dialog closed") + router.back() + }) + this.initStatue() + }); + } + }, + + onHide() { + this.log('onHide') + this.timeRemaining = 0 + }, + + /** + * Get authentication param + */ + initStatue() { + this.log('initStatue') + const data = dmClass.getFaParam(); + this.log('getFaParam:' + JSON.stringify(data)) + // const data = dmClas icationParam:' + JSON.stringify(data)) + // Authentication type, 1 for pin code. + if(data&&!data.FaType){ + return; + } + if (data && data.FaType == 1) { + this.log('initStatue:data.FaType == 1' ) + let authParam = data.authParam + this.log('initStatue authParam: ' +authParam ) + this.statusInfo = { + deviceName: authParam.extraInfo.PackageName, + appName: authParam.extraInfo.appName, + appIcon: uint8ArrayToBase64(authParam.appIcon), + appThumbnail: uint8ArrayToBase64(authParam.appThumbnail), + pinCode: authParam.extraInfo.pinCode + '', + pinToken: authParam.extraInfo.pinToken + } + this.log('initStatue statusInfo: ' +this.statusInfo ) + // direction: 1(main)/0(join) + if (authParam.extraInfo.direction == 1) { + this.log('initStatue statusInfo: authParam.extraInfo.direction == 1') + this.mainPin() + } else if (authParam.appIcon) { + this.log('initStatue statusInfo:authParam.appIcon == 1') + this.joinAuthImage() + } else if (authParam.extraInfo.business == 0) { + // business: 0(FA流转)/1(资源访问) + this.log('initStatue statusInfo:authParam.extraInfo.business == 0') + this.joinAuth() + } else { + this.log('initStatue join') + this.joinAuthorize() + } + } + this.log('initStatue wifi start') + if (data && data.FaType == AUTH_TYPE_WIFI && data.ConWifiParam == WIFI_CONFIGURE_DOING) { + this.log("show main wifi page") + this.mainWifi() + } + + if (data && data.FaType == AUTH_TYPE_WIFI && data.ConWifiParam != WIFI_CONFIGURE_DOING) { + this.log("show join wifi page") + let wifiParam = data.conWifiParam + this.wifiInfo.wifiSsid = wifiParam.wifiSsid; + this.configureResult = wifiParam.configureResult + this.joinWifi() + } + }, + + /** + * Set user Operation from devicemanager Fa, this interface can only used by devicemanager Fa. + * + * @param operateAction User Operation Actions. + * ACTION_ALLOW_AUTH = 0, allow authentication + * ACTION_CANCEL_AUTH = 1, cancel authentication + * ACTION_AUTH_CONFIRM_TIMEOUT = 2, user operation timeout for authentication confirm + * ACTION_CANCEL_PINCODE_DISPLAY = 3, cancel pinCode display + * ACTION_CANCEL_PINCODE_INPUT = 4, cancel pinCode input + */ + setUserOperation(operation) { + this.log('setUserOperation: ' + operation) + if (dmClass != null) { + var data = dmClass.setUserOperation(operation); + this.log('setUserOperation result: ' + JSON.stringify(data)) + } else { + this.log('deviceManagerObject not exit') + } + }, + + /** + * verify auth info, such as pin code. + * @param pinCode + * @return + */ + verifyAuthInfo(pinCode) { + this.log('verifyAuthInfo: ' + pinCode) + if (dmClass != null) { + dmClass.verifyAuthInfo({ + "authType": 1, + "token": this.statusInfo.pinToken, + "extraInfo": { + "pinCode": +pinCode + } + }, (err, data) => { + if (err) { + this.log("verifyAuthInfo err:" + JSON.stringify(err)) + } + this.log("verifyAuthInfo result:" + JSON.stringify(data)) + router.back() + }); + } else { + this.log('deviceManagerObject not exit') + } + }, + + /** + * Input pinCode at the main control terminal + */ + mainPin() { + this.status = 'main-pin' + this.log("mainPin") + }, + + /** + * Enter a number with the keyboard + * @param s + * @return + */ + mainInputPin(s) { + this.log('mainInputPin input: ' + s + '-' + this.pin) + if (this.pinNumb == 6) return + if (this.pinNumb < 6) { + this.pin[this.pinNumb] = + ++this.pinNumb + this.pin = [...this.pin] + } + this.log('mainInputPin pin: ' + this.pin + '-' + this.pin.join('')) + if (this.pinNumb == 6) { + // input end + this.log('mainInputPin end: ' + this.pin + '-' + this.pin.join('')) + this.verifyAuthInfo(this.pin.join('')) + router.back() + } + this.log("mainInputPin") + }, + + /** + * Keyboard delete number + */ + mainInputPinBack() { + if (this.pinNumb > 0) { + --this.pinNumb + this.pin[this.pinNumb] = '' + this.pin = [...this.pin] + } + this.log("mainInputPinBack") + }, + + /** + * Cancel pinCode input + */ + mainInputPinCancel() { + this.setUserOperation(4) + router.back() + this.log("mainInputPinCancel") + }, + + /** + * Main end wifiInfo input Page display + */ + mainWifi() { + this.status = 'main-wifi' + this.log(" this.status = 'main-wifi'") + }, + + /** + * Join end presents wifi configure result + */ + joinWifi() { + this.status = 'join-wifi' + this.log(" this.status = 'join-wifi'") + }, + + /** + * Cancel current operation + */ + mainWifiCancel() { + this.log(' mainWifiCancel') + this.setUserOperation(USER_WIFI_CANCEL_CODE) + router.back() + }, + + /** + * main end wifi ssid and pwd confirm + */ + mainWifiConfirm() { + this.log(' mainWifiConfirm') + dmClass.configureWifiInfo(this.wifiInfo, (err, data) => { + this.log('configureWifiInfo callback err = ' + err) + this.log('mainWifiConfirm + wifiSsid = ' + this.wifiInfo.wifiSsid) + }) + router.back(); + }, + + /** + * Cancel result dialog + */ + joinWifiCancel() { + this.log("joinWifiCancel") + router.back() + }, + + /** + * Join end authorization, business(FA流转)/1(资源访问): 0 + */ + joinAuthorize() { + this.status = 'join-authorize' + this.timing(60, 'join-authorize', () => { + this.setUserOperation(2) + router.back() + }) + }, + + /** + * Join end authorization, business(FA流转)/1(资源访问): 1 + */ + joinAuth() { + this.log("joinAuth") + this.status = 'join-auth' + this.timing(60, 'join-auth', () => { + this.setUserOperation(2) + router.back() + }) + }, + + /** + * Join end authorization, business(FA流转)/1(资源访问): 1, show application icon + */ + joinAuthImage() { + this.log("joinAuthImage") + this.status = 'join-auth-image' + this.timing(60, 'join-auth-image', () => { + this.setUserOperation(2) + router.back() + }) + }, + + /** + * Display pinCode at join end + */ + joinPin() { + this.status = 'join-pin' + }, + + /** + * Cancel authorization + */ + joinAuthorizeCancel() { + this.setUserOperation(1) + router.back() + }, + + /** + * Confirm authorization + */ + joinAuthorizeOk() { + this.setUserOperation(0) + this.joinPin() + }, + + /** + * Cancel authorization + */ + joinAuthCancel() { + this.setUserOperation(1) + router.back() + }, + + /** + * Confirm authorization + */ + joinAuthOk() { + this.setUserOperation(0) + this.joinPin() + }, + + /** + * Cancel authorization + */ + joinAuthImageCancel() { + this.setUserOperation(1) + router.back() + }, + + /** + * Confirm authorization + */ + joinAuthImageOk() { + this.setUserOperation(0) + this.joinPin() + }, + + /** + * Cancel authorization + */ + joinPinCancel() { + this.setUserOperation(3) + router.back() + }, + + /** + * Pure function countdown + * @param numb second + * @param status + * @param callback + * @return + */ + timing(numb, status, callback) { + this.log("timing") + this.timeRemaining = numb + const next = () => { + if (status != this.status) return + --this.timeRemaining + if (this.timeRemaining > 0) { + setTimeout(next, 1000) + } else { + callback() + } + } + next() + }, + + /** + * Change keyboard focus in wifi page + * @param currentArea - area that user clicked + */ + changeFocus(currentArea) { + this.log("changeFocus" ) + if (currentArea == CURRENT_FOCUS_SSID) { + this.isSSidFocus = true + this.currentSsidColor = ACTIVE_COLOR + + this.isKeyFocus = false + this.currentKeyColor = INACTIVE_COLOR + } + if (currentArea == CURRENT_FOCUS_KEY) { + this.isSSidFocus = false + this.currentSsidColor = INACTIVE_COLOR + + this.isKeyFocus = true + this.currentKeyColor = ACTIVE_COLOR + } + }, + + /** + * Change input case to upper case or lower case + */ + changeCase() { + this.log("changeCase" ) + if (this.keyboardItem == LOWER_CASE_KEYS) { + this.keyboardItem = UPPER_CASE_KEYS; + } else { + this.keyboardItem = LOWER_CASE_KEYS; + } + }, + + /** + * Add char to the selected input area + * @param itemChar - the char in the button that user clicked + */ + inputChar(itemChar) { + this.log("inputChar :"+itemChar) + if (this.isSSidFocus == true) { + this.ssidString = this.ssidString + itemChar + } + if (this.isKeyFocus == true) { + this.keyString = this.keyString + itemChar + } + }, + + /** + * Remove the first char of the selected input area + */ + deleteChar() { + this.log("deleteChar") + if (this.isSSidFocus == true && this.ssidString.length > 0) { + this.ssidString = this.ssidString.substring(0, this.ssidString.length - 1) + } + if (this.isKeyFocus == true && this.keyString.length > 0) { + this.keyString = this.keyString.substring(0, this.keyString.length - 1) + } + }, +} diff --git a/display/entry/src/main/resources/base/element/string.json b/display/entry/src/main/resources/base/element/string.json index 0bae6bd4..a1f1955b 100644 --- a/display/entry/src/main/resources/base/element/string.json +++ b/display/entry/src/main/resources/base/element/string.json @@ -2,10 +2,10 @@ "string": [ { "name": "entry_MainAbility", - "value": "entry_MainAbility" + "value": "DeviceManagerUI" }, { - "name": "mainability_description", + "name": "description_mainability", "value": "JS_Empty Ability" } ]