手表二维码界面修改添加了标题,修正了设备名的位置
authorluozheng <1732036298@qq.com>
Wed, 17 Jul 2024 09:14:06 +0000 (17:14 +0800)
committerluozheng <1732036298@qq.com>
Wed, 17 Jul 2024 09:14:06 +0000 (17:14 +0800)
code/sdk/application/wearable/fd230app/nativeui/watchQRcode/include/WatchQRCodeView.h
code/sdk/application/wearable/fd230app/nativeui/watchQRcode/src/WatchQRCodeView.cpp

index d2001cb..44843ea 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-06-12 11:44:04
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-07-17 16:21:55
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/watchQRcode/include/WatchQRCodeView.h
+ */
 #ifndef WATCH_QR_CODE_VIEW_H
 #define WATCH_QR_CODE_VIEW_H
 
@@ -29,7 +36,8 @@ namespace OHOS
         void ClearAll();
         UIViewGroup *WatchQRCodeGroupView{nullptr};
         UIQrcode *Watch_QR_Code_View{nullptr}; // 手表二维码
-        UILabel *DeviceNameLabel{nullptr};
+        UILabelExt *TitleLabel{nullptr};       /*标题*/
+        UILabel *DeviceNameLabel{nullptr};     /*蓝牙设备名称*/
     };
 
 }
index ed16bc2..2985642 100644 (file)
@@ -2,6 +2,7 @@
 #include "watchQRcode/include/WatchQRCodeView.h"
 #include "wearable_log.h"
 #include "custom_utils.h"
+#include "language/font/ui_resource_string.h"
 namespace OHOS
 {
 
@@ -31,20 +32,35 @@ namespace OHOS
         {
             WatchQRCodeGroupView->RemoveAll();
 
-            delete Watch_QR_Code_View;
-            Watch_QR_Code_View = nullptr;
-
-            delete DeviceNameLabel;
-            DeviceNameLabel = nullptr;
-
-            delete WatchQRCodeGroupView;
-            WatchQRCodeGroupView = nullptr;
+            if (TitleLabel != nullptr)
+            {
+                delete TitleLabel;
+                TitleLabel = nullptr;
+            }
+
+            if (Watch_QR_Code_View != nullptr)
+            {
+                delete Watch_QR_Code_View;
+                Watch_QR_Code_View = nullptr;
+            }
+
+            if (DeviceNameLabel != nullptr)
+            {
+                delete DeviceNameLabel;
+                DeviceNameLabel = nullptr;
+            }
+
+            if (WatchQRCodeGroupView != nullptr)
+            {
+                delete WatchQRCodeGroupView;
+                WatchQRCodeGroupView = nullptr;
+            }
         }
     }
 
     bool WatchQRCodeView::WatchQRCodeInitViewGroup(void)
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeInitViewGroup");
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeInitViewGroup");
         WatchQRCodeGroupView = new UIViewGroup();
         if (WatchQRCodeGroupView == nullptr)
         {
@@ -67,14 +83,15 @@ namespace OHOS
 
     bool WatchQRCodeView::WatchQRCodeInitQrcodeImage(void)
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeInitQrcodeImage");
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeInitQrcodeImage");
         Watch_QR_Code_View = new UIQrcode();
         if (Watch_QR_Code_View == nullptr)
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::Watch_QR_Code_View new fail!");
             return false;
         }
-        Watch_QR_Code_View->SetPosition(93, 110, 280, 280);
+        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->SetAutoEnable(false);
         Watch_QR_Code_View->SetResizeMode(UIImageView::ImageResizeMode::CENTER);
         std::string str = WatchQRCodePresenter::GetInstance()->WatchQRCodeGetQRCodeStr();
@@ -85,25 +102,41 @@ namespace OHOS
 
     bool WatchQRCodeView::WatchQRCodeInitLabel(void)
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeInitLabel");
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeInitLabel");
+        TitleLabel = new UILabelExt();
+        if (TitleLabel == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::TitleLabel new label fail");
+            return false;
+        }
+        TitleLabel->SetPosition(83, 50, 300, 35);
+        TitleLabel->SetStyle(STYLE_TEXT_FONT, 30);
+        TitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+        TitleLabel->SetTextId(STR_SCANNING_BINDING);
+        TitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+        TitleLabel->SetRollSpeed(70);
+        TitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+        TitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+        WatchQRCodeGroupView->Add(TitleLabel);
+        /* -------------------------------------------------------------------------- */
         DeviceNameLabel = new UILabel();
         if (DeviceNameLabel == nullptr)
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::DeviceNameLabel new label fail");
             return false;
         }
-        // DeviceNameLabel->SetText("KUMI_XXXX");
 
         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);
-        DeviceNameLabel->SetPosition(83, 412, 300, 35);
+        DeviceNameLabel->SetText((char *)ble_name);
+        DeviceNameLabel->SetPosition(83, 402, 300, 35);
         DeviceNameLabel->SetStyle(STYLE_TEXT_FONT, 30);
         DeviceNameLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
         DeviceNameLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
-        DeviceNameLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
+        DeviceNameLabel->SetRollSpeed(70);
+        DeviceNameLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
         DeviceNameLabel->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));
         DeviceNameLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
         WatchQRCodeGroupView->Add(DeviceNameLabel);
@@ -164,9 +197,9 @@ namespace OHOS
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::OnStop");
         View<WatchQRCodePresenter>::OnStop();
-
         RootView::GetInstance()->RemoveAll();
         RootView::GetInstance()->ClearOnKeyActListener();
+        ClearAll();
         return;
     }