音乐蓝牙连接失败视图优化修改:视图中添加蓝牙耳机名称
authorluozheng <1732036298@qq.com>
Tue, 3 Sep 2024 12:38:52 +0000 (20:38 +0800)
committerluozheng <1732036298@qq.com>
Tue, 3 Sep 2024 12:38:52 +0000 (20:38 +0800)
code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerBTConnectFailedView.h
code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerBTConnectFailedView.cpp

index 9615c6d..ad3e92a 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-08-12 11:31:35
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-12 17:08:31
+ * @LastEditTime: 2024-09-03 20:13:24
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerBTConnectFailedView.cpp
  */
 #ifndef MUSIC_PLAYER_BTCONNECTFAILED_VIEW_H
@@ -25,17 +25,19 @@ namespace OHOS
         bool CreateMusicPlayerBTConnectFailedViewLabel();
         bool CreateMusicPlayerBTConnectFailedViewButton();
         void ClearAll();
+        void get_bt_name(void);
         UIViewGroup *group{nullptr};
         UIScrollView *scrollView{nullptr};
         UILabelExt *titleLabel{nullptr}; // 标题
         UILabelExt *IPoneLabel{nullptr};
-        UILabelExt *AndroidLabel{nullptr}; 
+        UILabelExt *AndroidLabel{nullptr};
         UILabelExt *BTNoteLabel1{nullptr};
         UILabelExt *BTNoteLabel2{nullptr};
         UILabelExt *BTNoteLabel3{nullptr};
         UILabelExt *CloseLabel{nullptr};
         UIButton *CloseButton{nullptr};
         UIView::OnDragListener *dragListener{nullptr};
+        uint8_t ble_name[30]{0};
     };
 
 }
index e889d66..625281a 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-08-12 11:31:43
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-12 17:19:23
+ * @LastEditTime: 2024-09-03 20:31:31
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerBTConnectFailedView.cpp
  */
 #include "player/include/MusicPlayerBTConnectFailedView.h"
@@ -10,7 +10,8 @@
 #include "player/include/PlayersView.h"
 #include "wearable_log.h"
 #include "ui_resource_string.h"
-
+#include <custom_utils.h>
+#include "uicomponents/UIComponents.h"
 namespace OHOS
 {
     static constexpr const char *CLOSEBUTTON_VIEWID = "CLOSEButton";
@@ -164,6 +165,7 @@ namespace OHOS
         BTNoteLabel2->SetStyle(STYLE_TEXT_FONT, 30);
         BTNoteLabel2->SetStyle(STYLE_LINE_HEIGHT, 35);
         BTNoteLabel2->SetTextId(STR_ENABLE_BLUETOOTH_CALL_NOTE_IPHONE);
+        UpdateLabel(BTNoteLabel2, (char *)ble_name, STR_ENABLE_BLUETOOTH_CALL_NOTE_IPHONE);
         BTNoteLabel2->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
         BTNoteLabel2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
         /* ------------------------------- AndroidLabel ------------------------------- */
@@ -179,7 +181,7 @@ namespace OHOS
         AndroidLabel->SetPosition(53, BTNoteLabel2->GetY() + BTNoteLabel2->GetTextHeight() + 40, 360, 35);
         AndroidLabel->SetStyle(STYLE_TEXT_FONT, 30);
         AndroidLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
-        AndroidLabel->SetTextId(STR_IPHONE);
+        AndroidLabel->SetTextId(STR_ANDROID);
         AndroidLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
         AndroidLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
         /* ------------------------------ BTNoteLabel3 ------------------------------ */
@@ -196,6 +198,7 @@ namespace OHOS
         BTNoteLabel3->SetStyle(STYLE_TEXT_FONT, 30);
         BTNoteLabel3->SetStyle(STYLE_LINE_HEIGHT, 35);
         BTNoteLabel3->SetTextId(STR_ENABLE_BLUETOOTH_CALL_NOTE_ANDROID);
+        UpdateLabel(BTNoteLabel3, (char *)ble_name, STR_ENABLE_BLUETOOTH_CALL_NOTE_ANDROID);
         BTNoteLabel3->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
         BTNoteLabel3->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
         /* ------------------------------- CloseLabel ------------------------------- */
@@ -285,6 +288,9 @@ namespace OHOS
         scrollView->SetMaxScrollDistance(1000);
         scrollView->SetDirection(UIScrollView::VERTICAL);
 
+        /* --------------------------------- 获取蓝牙名称 --------------------------------- */
+        get_bt_name();
+        /* -------------------------------------------------------------------------- */
         if (!CreateMusicPlayerBTConnectFailedViewLabel() || !CreateMusicPlayerBTConnectFailedViewButton())
         {
             return nullptr;
@@ -302,4 +308,9 @@ namespace OHOS
         return group;
     }
 
+    void MusicPlayerBTConnectFailedView::get_bt_name(void)
+    {
+        uint32_t ble_name_len = sizeof(ble_name);
+        uapi_get_nv_btname(ble_name, &ble_name_len);
+    }
 }
\ No newline at end of file