QRcode 添加版本号,title改为设别名
authorluozheng <1732036298@qq.com>
Sat, 20 Jul 2024 09:06:55 +0000 (17:06 +0800)
committerluozheng <1732036298@qq.com>
Sat, 20 Jul 2024 09:06:55 +0000 (17:06 +0800)
code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodeView.cpp

index 2985642..02f0000 100644 (file)
@@ -3,6 +3,8 @@
 #include "wearable_log.h"
 #include "custom_utils.h"
 #include "language/font/ui_resource_string.h"
+#include "iostream"
+#include "string"
 namespace OHOS
 {
 
@@ -17,7 +19,6 @@ namespace OHOS
     WatchQRCodeView::~WatchQRCodeView()
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::~WatchQRCodeView");
-        ClearAll();
         g_pWatchQRCodePresenter = nullptr;
     }
 
@@ -58,6 +59,13 @@ namespace OHOS
         }
     }
 
+    extern "C"
+    {
+#include "build_version.h"
+
+        const char *get_version_string(void);
+    }
+
     bool WatchQRCodeView::WatchQRCodeInitViewGroup(void)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeInitViewGroup");
@@ -91,7 +99,7 @@ namespace OHOS
             return false;
         }
         Watch_QR_Code_View->SetPosition(93, 100, 280, 280);
-        Watch_QR_Code_View->SetECCLevel(QrCode::Ecc::LOW);/*QR 码的 ECC(Error Correction Code ,错误纠正码)级别表示二维码的纠错能力或容错率*/
+        Watch_QR_Code_View->SetECCLevel(QrCode::Ecc::LOW); /*QR 码的 ECC(Error Correction Code ,错误纠正码)级别表示二维码的纠错能力或容错率*/
         Watch_QR_Code_View->SetAutoEnable(false);
         Watch_QR_Code_View->SetResizeMode(UIImageView::ImageResizeMode::CENTER);
         std::string str = WatchQRCodePresenter::GetInstance()->WatchQRCodeGetQRCodeStr();
@@ -112,7 +120,11 @@ namespace OHOS
         TitleLabel->SetPosition(83, 50, 300, 35);
         TitleLabel->SetStyle(STYLE_TEXT_FONT, 30);
         TitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
-        TitleLabel->SetTextId(STR_SCANNING_BINDING);
+        uint8_t ble_name[30] = {0};
+        uint32_t ble_name_len = sizeof(ble_name);
+        errcode_t ret = uapi_get_nv_btname(ble_name, &ble_name_len);
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get btname %s ,ret 0x%X\n", ble_name, ret);
+        TitleLabel->SetText((char *)ble_name);
         TitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
         TitleLabel->SetRollSpeed(70);
         TitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
@@ -125,12 +137,9 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::DeviceNameLabel new label fail");
             return false;
         }
-
-        uint8_t ble_name[30] = {0};
-        uint32_t ble_name_len = sizeof(ble_name);
-        errcode_t ret = uapi_get_nv_btname(ble_name, &ble_name_len);
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get btname %s ,ret 0x%X\n", ble_name, ret);
-        DeviceNameLabel->SetText((char *)ble_name);
+        std::string temp = get_version_string();
+        std::string version_string = "V" + temp;
+        DeviceNameLabel->SetText(version_string.c_str());
         DeviceNameLabel->SetPosition(83, 402, 300, 35);
         DeviceNameLabel->SetStyle(STYLE_TEXT_FONT, 30);
         DeviceNameLabel->SetStyle(STYLE_LINE_HEIGHT, 35);