diff --git a/application/entry/src/main/ets/pages/DHardwareUI.ets b/application/entry/src/main/ets/pages/DHardwareUI.ets index acbe50caa87486b0b264d7c05d8c06879436a035..99b47202ab6e198fb9f60efce713dc167b34e098 100644 --- a/application/entry/src/main/ets/pages/DHardwareUI.ets +++ b/application/entry/src/main/ets/pages/DHardwareUI.ets @@ -25,13 +25,11 @@ PersistentStorage.persistProp('sign', ''); @Component struct DHardwareUI { @State deviceName: string = ''; - @State deviceType: string = ''; @State DHTypeName: string = ''; @State bgcImg: PixelMap | null = null; @StorageLink('type') stoLink_type: number = 0; @StorageLink('srcNetworkId') stoLink_srcNetworkId: string = ''; @StorageLink('deviceName') stoLink_deviceName: string = ''; - @StorageLink('deviceType') stoLink_deviceType: string = ''; @StorageLink('sign') sign: string = ''; @StorageLink('camera') camera: number = 999; @StorageLink('mic') mic: number = 999; @@ -64,7 +62,6 @@ struct DHardwareUI { } } - this.deviceType = this.convertDeviceTypeToChStr(this.stoLink_deviceType); AppStorage.setAndLink('description', this.description); console.info(TAG + 'aboutToAppear : this.description : ' + this.description); @@ -72,11 +69,35 @@ struct DHardwareUI { console.info(TAG + 'aboutToAppear : this.description.srcNetworkId : ' + this.description.srcNetworkId); if (this.stoLink_type == 1024) { - this.DHTypeName = '麦克风'; - console.info(TAG + 'aboutToAppear : this.DHTypeName : ' + this.DHTypeName); + try { + this.context.resourceManager.getStringValue($r('app.string.DHTypeName_Mic').id, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + this.DHTypeName = value; + console.info(TAG + 'aboutToAppear : this.DHTypeName : ' + this.DHTypeName); + } + }); + } catch (error) { + let code = (error as BusinessError).code; + let message = (error as BusinessError).message; + console.error(`callback getStringValue failed, error code: ${code}, message: ${message}.`); + } } else { - this.DHTypeName = '相机'; - console.info(TAG + 'aboutToAppear : this.DHTypeName : ' + this.DHTypeName); + try { + this.context.resourceManager.getStringValue($r('app.string.DHTypeName_Camera').id, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + this.DHTypeName = value; + console.info(TAG + 'aboutToAppear : this.DHTypeName : ' + this.DHTypeName); + } + }); + } catch (error) { + let code = (error as BusinessError).code; + let message = (error as BusinessError).message; + console.error(`callback getStringValue failed, error code: ${code}, message: ${message}.`); + } } } @@ -90,55 +111,6 @@ struct DHardwareUI { } } - //转换对端可信设备列表的设备类型为中文字符 - convertDeviceTypeToChStr(deviceType: string): string { - console.log(TAG + 'convertDeviceTypeToChStr', deviceType); - switch (deviceType) { - case 'camera': { - return '相机'; - } - case 'audio': { - return '音频'; - } - case 'pc': { - return '笔记本电脑'; - } - case 'phone': { - return '手机'; - } - case 'pad': { - return '平板'; - } - case 'watch': { - return '手表'; - } - case 'car': { - return '车机'; - } - case 'tv': { - return '电视'; - } - case 'display': { - return '显示屏'; - } - case '2in1': { - return '2in1'; - } - case 'default': { - return '手机'; - } - case 'tablet': { - return '平板'; - } - case 'wearable': { - return '可穿戴电子设备'; - } - default: { - return ''; - } - } - } - changePauseOrResumeStatus() { this.isPause = !this.isPause; console.log(TAG + "changePauseOrResumeStatus - this.isPause" + JSON.stringify(this.isPause)) @@ -192,7 +164,6 @@ struct DHardwareUI { onBackPress() { console.info(TAG + 'onBackPress'); - this.sign = 'onBackPress'; } @@ -220,14 +191,14 @@ struct DHardwareUI { .height(54) .backgroundColor("rgba(0,0,0,0.15)") - Text(CommonConstants.CONNECTED_TO + this.stoLink_deviceName + CommonConstants.CONJUNCTS + this.deviceType) + Text($r('app.string.connected_to',this.stoLink_deviceName)) .fontSize(18) .fontWeight(FontWeight.Medium) .fontColor("#FFFFFF") .margin({ left: 0, top: 16, right: 0 }) .textAlign(TextAlign.Center) - Text(CommonConstants.STOP_DEVICE + this.DHTypeName) + Text($r('app.string.stop_device',this.DHTypeName)) .fontSize(16) .fontWeight(FontWeight.Regular) .fontColor("#99FFFFFF") diff --git a/application/entry/src/main/module.json b/application/entry/src/main/module.json index 5dd40fabecd0a2ea1ecf7446039a7a59961cc6dd..e6f633f26ae1050f9412c43c943fc3dd0df3cb83 100644 --- a/application/entry/src/main/module.json +++ b/application/entry/src/main/module.json @@ -6,7 +6,9 @@ "mainElement": "EntryAbility", "deviceTypes": [ "default", - "tablet" + "tablet", + "2in1", + "wearable" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/application/entry/src/main/module.json5 b/application/entry/src/main/module.json5 index 99f9a497ebdff3e78eec6c65ded8a7868a16c382..fc87ba564a76799dccd5fce296c3fa205882344f 100644 --- a/application/entry/src/main/module.json5 +++ b/application/entry/src/main/module.json5 @@ -21,7 +21,9 @@ "mainElement": "EntryAbility", "deviceTypes": [ "default", - "tablet" + "tablet", + "2in1", + "wearable" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/application/entry/src/main/resources/base/element/string.json b/application/entry/src/main/resources/base/element/string.json index 5f6fd38588a10b10028328cb0a3245edc649de06..fe1394a2b01c7133b6a9a10d2930d3972ba34374 100644 --- a/application/entry/src/main/resources/base/element/string.json +++ b/application/entry/src/main/resources/base/element/string.json @@ -14,15 +14,11 @@ }, { "name": "connected_to", - "value": "connected to" - }, - { - "name": "conjuncts", - "value": "'s" + "value": "Connected to %1$s" }, { "name": "stop_device", - "value": "You can disconnect to stop using this device's" + "value": "Disconnect to stop using this device's %1$s." }, { "name": "pause", @@ -30,67 +26,19 @@ }, { "name": "continue", - "value": "Continue" - }, - { - "name": "camera", - "value": "Camera" - }, - { - "name": "audio", - "value": "Audio" - }, - { - "name": "pc", - "value": "PC" - }, - { - "name": "phone", - "value": "Phone" - }, - { - "name": "pad", - "value": "Pad" - }, - { - "name": "watch", - "value": "Watch" - }, - { - "name": "car", - "value": "Car" - }, - { - "name": "tv", - "value": "TV" - }, - { - "name": "display", - "value": "Display" - }, - { - "name": "2in1", - "value": "2in1" - }, - { - "name": "default", - "value": "Phone" - }, - { - "name": "tablet", - "value": "Tablet" + "value": "Resume" }, { - "name": "wearable", - "value": "Wearable" + "name": "DHTypeName_Camera", + "value": "camera" }, { - "name": "microphone", - "value": "Mic" + "name": "DHTypeName_Mic", + "value": "microphone" }, { "name": "disconnect", - "value": "disconnect" + "value": "Disconnect" } ] } \ No newline at end of file diff --git a/application/entry/src/main/resources/en_US/element/string.json b/application/entry/src/main/resources/en_US/element/string.json index 5b59823db8af21c1954fdec10fc06bbaa82d577c..fe1394a2b01c7133b6a9a10d2930d3972ba34374 100644 --- a/application/entry/src/main/resources/en_US/element/string.json +++ b/application/entry/src/main/resources/en_US/element/string.json @@ -10,19 +10,15 @@ }, { "name": "EntryAbility_label", - "value": "PrivacyView" + "value": "DHardwareUI" }, { "name": "connected_to", - "value": "connected to" - }, - { - "name": "conjuncts", - "value": "'s" + "value": "Connected to %1$s" }, { "name": "stop_device", - "value": "You can disconnect to stop using this device's" + "value": "Disconnect to stop using this device's %1$s." }, { "name": "pause", @@ -30,67 +26,19 @@ }, { "name": "continue", - "value": "Continue" - }, - { - "name": "camera", - "value": "Camera" - }, - { - "name": "audio", - "value": "Audio" - }, - { - "name": "pc", - "value": "PC" - }, - { - "name": "phone", - "value": "Phone" - }, - { - "name": "pad", - "value": "Pad" - }, - { - "name": "watch", - "value": "Watch" - }, - { - "name": "car", - "value": "Car" - }, - { - "name": "tv", - "value": "TV" - }, - { - "name": "display", - "value": "Display" - }, - { - "name": "2in1", - "value": "2in1" - }, - { - "name": "default", - "value": "Phone" - }, - { - "name": "tablet", - "value": "Tablet" + "value": "Resume" }, { - "name": "wearable", - "value": "Wearable" + "name": "DHTypeName_Camera", + "value": "camera" }, { - "name": "microphone", - "value": "Mic" + "name": "DHTypeName_Mic", + "value": "microphone" }, { "name": "disconnect", - "value": "disconnect" + "value": "Disconnect" } ] } \ No newline at end of file diff --git a/application/entry/src/main/resources/zh_CN/element/string.json b/application/entry/src/main/resources/zh_CN/element/string.json index 9c846ba8ad7dedf1b88d5df6ecbde7a0b3dec56d..bbc31c1d7c6f79c7d0442cf5f4fd733e64fad9fb 100644 --- a/application/entry/src/main/resources/zh_CN/element/string.json +++ b/application/entry/src/main/resources/zh_CN/element/string.json @@ -14,15 +14,11 @@ }, { "name": "connected_to", - "value": "已连接到" - }, - { - "name": "conjuncts", - "value": "的" + "value": "已连接至%1$s" }, { "name": "stop_device", - "value": "你可以断开连接以停止使用此设备的" + "value": "您可以断开连接以停止使用此设备的%1$s" }, { "name": "pause", @@ -33,59 +29,11 @@ "value": "继续" }, { - "name": "camera", + "name": "DHTypeName_Camera", "value": "相机" }, { - "name": "audio", - "value": "音频" - }, - { - "name": "pc", - "value": "笔记本电脑" - }, - { - "name": "phone", - "value": "手机" - }, - { - "name": "pad", - "value": "平板" - }, - { - "name": "watch", - "value": "手表" - }, - { - "name": "car", - "value": "车机" - }, - { - "name": "tv", - "value": "电视" - }, - { - "name": "display", - "value": "显示器" - }, - { - "name": "2in1", - "value": "2in1" - }, - { - "name": "default", - "value": "手机" - }, - { - "name": "tablet", - "value": "平板" - }, - { - "name": "wearable", - "value": "可穿戴电子设备" - }, - { - "name": "microphone", + "name": "DHTypeName_Mic", "value": "麦克风" }, {