蓝牙耳机界面优化修改
authorluozheng <1732036298@qq.com>
Sat, 17 Aug 2024 02:43:59 +0000 (10:43 +0800)
committerluozheng <1732036298@qq.com>
Sat, 17 Aug 2024 02:43:59 +0000 (10:43 +0800)
13 files changed:
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothDeviceListView.h
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothItemView.h
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothModel.h
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothPresenter.h
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/TipsConnFailMessageView.h
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothDeviceListView.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothEarListView.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothItemView.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothOptionsView.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/MainBluetoothView.cpp
code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp

index a2c076c..71eb905 100644 (file)
@@ -1,40 +1,41 @@
 /*\r
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
- * Description: BluetoothDeviceListView view 蓝牙耳机设备列表界面\r
- * Author:\r
- * Create: 2021-10-13\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-08-05 15:20:01\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-08-16 17:33:49\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothDeviceListView.h\r
  */\r
 #ifndef BLUETOOTH_DEVICE_LIST_VIEW_H\r
 #define BLUETOOTH_DEVICE_LIST_VIEW_H\r
 \r
 #include "components/ui_view_group.h"\r
-#include "components/ui_label.h"\r
 #include "components/ui_label_ext.h"\r
-#include "components/ui_label_button.h"\r
+#include "components/ui_label_button_ext.h"\r
 #include "components/ui_list.h"\r
 #include "BluetoothDeviceCaseListAdapter.h"\r
-\r
+#include "components/ui_scroll_view.h"\r
 namespace OHOS {\r
 class BluetoothDeviceCaseListAdapter;\r
+//已连接过的蓝牙设备列表视图\r
 class BluetoothDeviceListView {\r
 public:\r
     BluetoothDeviceListView();\r
     ~BluetoothDeviceListView();\r
     static BluetoothDeviceListView *GetInstance();\r
-    UIViewGroup *InitShowUpView(void);\r
+    UIViewGroup *CreateBluetoothDeviceListView(void);\r
     UIViewGroup *GetGroup(void);\r
     UIList *GetDeviceUIList(void);\r
-    void RefreshText(void);\r
+    void RefreshBluetoothDeviceListView(void);\r
 private:\r
     void InitList(void);\r
     void InItEmptyLabel();\r
     void InitNewEquipmentButton();\r
     UIViewGroup *group{nullptr};\r
     UIList *list{nullptr};\r
-    UILabel *titleLabel{nullptr};\r
-    UILabel *emptyLabel{nullptr};\r
+    UILabelExt *titleLabel{nullptr}; /*标题:蓝牙耳机*/\r
+    UILabelExt *emptyLabel{nullptr}; /*暂无已配对设备*/\r
     BluetoothDeviceCaseListAdapter *adapterText{nullptr};\r
-    UILabelButton *newEquipmentButton{nullptr};\r
+    UILabelButtonExt *newEquipmentButton{nullptr};\r
 };\r
 } // namespace OHOS\r
 #endif // BLUETOOTH_DEVICE_LIST_VIEW_H
\ No newline at end of file
index bfddc3f..9abf4da 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com\r
  * @Date: 2024-08-05 15:20:01\r
  * @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-08-15 14:19:01\r
+ * @LastEditTime: 2024-08-16 18:37:30\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothItemView.h\r
  */\r
 \r
@@ -29,16 +29,18 @@ public:
     void SetItemInfo(const BluetoothCaseInfo& itemInfo, bool isCaseList);\r
     BluetoothCaseInfo *GetItemInfo(void);\r
     void SetConnectionstatus(const BluetoothCaseInfo& infoData);\r
+    void SetViewOnClickListener(UIView::OnClickListener *listener);\r
     void SetUpChild();\r
     void ConnectAnimatorStart(void);\r
     void ConnectAnimatorStop(void);\r
     bool IsConnectAnimator(void);\r
 private:\r
     ImageAnimatorInfo connectImageInfo[BLUETOOTH_CONNECT_IMAGE_NUM];\r
-    UIImageView image;\r
     UIButton button;\r
     UILabel connectStateLabel;/*连接状态标签*/\r
-    UILabel namelabel;\r
+    UILabel namelabel;/*设备名*/\r
+    UIImageView lineImage;\r
+    UIImageView noteImage;\r
     UIImageAnimatorView connectionAnimator; /*连接动画*/\r
     BluetoothCaseInfo itemInfo_{};\r
     void BtConnectImageAnimator();\r
index 86ba575..50e695c 100644 (file)
@@ -101,7 +101,7 @@ private:
     bd_addr_t remoteConnectAddr{0};\r
     BluetoothItemView *selectItemView{nullptr};\r
     std::list<BluetoothCaseInfo> btScansDevicesList_{}; // É¨ÃèÉ豸¶ÓÁÐ\r
-    List<BluetoothCaseInfo> *btConnedDevicesList_{nullptr}; // ÒÑÅä¶ÔÉ豸¶ÓÁÐ\r
+    List<BluetoothCaseInfo> *btConnedDevicesList_{nullptr}; //已连接设备列表\r
     bool tagReconnectJump{0};\r
     int16_t curView{0};\r
     bool tagConnectView{true};\r
index c4ef734..1f2fa62 100644 (file)
@@ -1,7 +1,9 @@
 /*\r
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
- * Description: BluetoothPresenter view\r
- * Create: 2021-10-13\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-08-05 15:20:01\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-08-16 16:32:56\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothPresenter.h\r
  */\r
 \r
 #ifndef BLUETOOTH_PRESENTER_H\r
 #include "common/key_code.h"\r
 namespace OHOS {\r
 enum BluetoothPresenterNum : uint8_t {\r
-        BLUETOOTHEARPHONEVIEW = 0,\r
-        BLUETOOTHEARLISTVIEW,\r
-        BLUETOOTHDEVICELISTVIEW,\r
-        BLUETOOTHEOPTIONSVIEW,/*已连接的蓝牙耳机设备视图*/\r
+        BLUETOOTHEARPHONEVIEW = 0, // 搜索界面\r
+        BLUETOOTHEARLISTVIEW,   /*耳机列表界面*/\r
+        BLUETOOTHDEVICELISTVIEW,/*已连接过的蓝牙设备列表视图*/\r
+        BLUETOOTHEOPTIONSVIEW, /*查看已连接过的蓝牙耳机设备视图*/\r
         BLUETOOTHRECONNECTVIEW,/*蓝牙重新连接视图*/\r
-        TIPSSUCCMESSAGEVIEW,\r
-        TIPSCONNFAILMESSAGEVIEW,\r
-        TIPSFAILMESSAGEVIEW,\r
+        TIPSSUCCMESSAGEVIEW,/*连接成功的提示视图*/\r
+        TIPSCONNFAILMESSAGEVIEW,/*连接失败的提示*/\r
+        TIPSFAILMESSAGEVIEW,/*未搜索到蓝牙耳机界面*/\r
         BLUETOOTHEVIEW,\r
         BLUETOOTHEVIEW_MAX,\r
     };\r
index db68663..c389e8d 100644 (file)
@@ -1,9 +1,11 @@
 /*\r
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.\r
- * Description: TipsConnFailMessageView view\r
- * Author:\r
- * Create: 2021-10-13\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-08-05 15:20:01\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-08-16 16:24:39\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/TipsConnFailMessageView.h\r
  */\r
+\r
 #ifndef TIPS_CONN_FAIL_MESSAGE_VIEW_H\r
 #define TIPS_CONN_FAIL_MESSAGE_VIEW_H\r
 \r
@@ -15,6 +17,7 @@
 #include "bts_def.h"\r
 \r
 namespace OHOS {\r
+/*连接失败视图*/\r
 class TipsConnFailMessageView {\r
 public:\r
     TipsConnFailMessageView();\r
index f2950ec..0ed042c 100644 (file)
@@ -48,8 +48,11 @@ public:
     bool OnClick(UIView& view, const ClickEvent& event) override
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceOnClickListListener");
-        UNUSED(view);
         UNUSED(event);
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceOnClickListListener addr: %02x%02x%02x%02x%02x%02x",
+            bluetoothInfo_.addr[5], bluetoothInfo_.addr[4], bluetoothInfo_.addr[3], /* mac下标 0 1 2 3 4 5 */
+            bluetoothInfo_.addr[2], bluetoothInfo_.addr[1], bluetoothInfo_.addr[0]); /* mac下标 0 1 2 3 4 5 */
+        BluetoothModel::GetInstance()->SetTempMacValue(&bluetoothInfo_);
         /* 点击事件 */
         // 跳转可选页
         if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) {
@@ -66,20 +69,35 @@ public:
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceOnClick mainBluetoothView GetInstance fail");
                 return false;
             }
-            mainBluetoothView->ChangeView(BLUETOOTHDEVICELISTVIEW, BLUETOOTHEOPTIONSVIEW);
-        }
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceOnClickListListener addr: %02x%02x%02x%02x%02x%02x",
-            bluetoothInfo_.addr[5], bluetoothInfo_.addr[4], bluetoothInfo_.addr[3], /* mac下标 0 1 2 3 4 5 */
-            bluetoothInfo_.addr[2], bluetoothInfo_.addr[1], bluetoothInfo_.addr[0]); /* mac下标 0 1 2 3 4 5 */
-        BluetoothModel::GetInstance()->SetTempMacValue(&bluetoothInfo_);
-        // 用于查询连接状态
-        BluetoothOptionsView *bluetoothOptionsView = BluetoothOptionsView::GetInstance();
-        if (bluetoothOptionsView == nullptr) {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick bluetoothOptionsView new fail");
-            return false;
+            if(view.GetViewType() == UIViewType::UI_BUTTON)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UIViewType::UI_BUTTON,%s",reinterpret_cast<const char *>(bluetoothInfo_.deviceName));
+                // 判断是否正在连接
+                bd_addr_t *lastAddr = BluetoothModel::GetInstance()->GetLastConnedAddr();
+                bool ret = bt_is_acl_connected(lastAddr);
+                if (ret) {
+                    errcode_t retVal = gap_disconnect_remote_device(lastAddr);
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Disconnect LastDevice retVal =  %d", retVal);
+                } else {
+                    mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), BLUETOOTHRECONNECTVIEW);
+                    errcode_t retVal = BluetoothModel::GetInstance()->ConnectRemoteDevice(&addr);
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectRemoteDevice ret =  %d", retVal);
+                }
+            }
+            else if(view.GetViewType() == UIViewType::UI_IMAGE_VIEW) /*点击的是图片*/
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UIViewType::UI_IMAGE_VIEW");
+                mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), BLUETOOTHEOPTIONSVIEW);
+                BluetoothOptionsView *bluetoothOptionsView = BluetoothOptionsView::GetInstance();
+                if (bluetoothOptionsView == nullptr) {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick bluetoothOptionsView new fail");
+                    return false;
+                }
+                bluetoothOptionsView->SetCurrentAddr(addr);
+                bluetoothOptionsView->RefreshText();
+            }
         }
-        bluetoothOptionsView->SetCurrentAddr(addr);
-        bluetoothOptionsView->RefreshText();
+       
         return true;
     }
 
@@ -98,7 +116,7 @@ UIView *BluetoothDeviceCaseListAdapter::GetView(UIView *inView, int16_t index)
         return nullptr;
     }
     if ((index > bluetoothCaseList.Size() - 1) || (index < 0)) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceCaseListAdapter::GetView err");
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceCaseListAdapter::GetView err,%d,%d",index,bluetoothCaseList.Size());
         return nullptr;
     }
     ListNode<BluetoothCaseInfo>* node = bluetoothCaseList.Begin();
@@ -116,6 +134,7 @@ UIView *BluetoothDeviceCaseListAdapter::GetView(UIView *inView, int16_t index)
     } else {
         item = static_cast<BluetoothItemView *>(inView);
     }
+    item->SetViewIndex(index);
     item->SetItemInfo(itemData, false);
     item->SetConnectionstatus(itemData);
 
@@ -133,8 +152,8 @@ UIView *BluetoothDeviceCaseListAdapter::GetView(UIView *inView, int16_t index)
         node->data_.addr[2], node->data_.addr[3], node->data_.addr[4], node->data_.addr[5]); // 没有%s类型,不做返回判断
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "addrTmp %s", addrTmp);
 
-    item->SetViewIndex(index);
-    item->SetOnClickListener(listener);
+    // item->SetOnClickListener(listener);
+    item->SetViewOnClickListener(listener);
     return item;
 }
 } // namespace OHOS
\ No newline at end of file
index 94ef720..563f0bd 100644 (file)
 #include "PlayersPresenter.h"\r
 #include "BluetoothPresenter.h"\r
 #include "BluetoothModel.h"\r
-\r
-namespace OHOS {\r
-static BluetoothDeviceListView *g_pBluetoothDeviceListView{nullptr};\r
-\r
-BluetoothDeviceListView::BluetoothDeviceListView()\r
+#include "ui_resource_string.h"\r
+namespace OHOS\r
 {\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::BluetoothDeviceListView");\r
-    g_pBluetoothDeviceListView = this;\r
-}\r
+    static BluetoothDeviceListView *g_pBluetoothDeviceListView{nullptr};\r
 \r
-BluetoothDeviceListView::~BluetoothDeviceListView()\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::~BluetoothDeviceListView");\r
-    group->RemoveAll();\r
-    delete titleLabel;\r
-    titleLabel = nullptr;\r
-    delete adapterText;\r
-    adapterText = nullptr;\r
-    delete emptyLabel;\r
-    emptyLabel = nullptr;\r
-    delete list;\r
-    list = nullptr;\r
-    delete newEquipmentButton;\r
-    newEquipmentButton = nullptr;\r
-    delete group;\r
-    group = nullptr;\r
-    g_pBluetoothDeviceListView = nullptr;\r
-}\r
-\r
-BluetoothDeviceListView *BluetoothDeviceListView::GetInstance()\r
-{\r
-    return g_pBluetoothDeviceListView;\r
-}\r
+    BluetoothDeviceListView::BluetoothDeviceListView()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::BluetoothDeviceListView");\r
+        g_pBluetoothDeviceListView = this;\r
+    }\r
 \r
-void BluetoothDeviceListView::InitList()\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::InitList");\r
-    // list type\r
-    if (adapterText == nullptr) {\r
-        adapterText = new BluetoothDeviceCaseListAdapter();\r
-        if (adapterText == nullptr) {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView adapterText new fail");\r
-            return;\r
+    BluetoothDeviceListView::~BluetoothDeviceListView()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::~BluetoothDeviceListView");\r
+        if (group)\r
+        {\r
+            group->RemoveAll();\r
+            if (titleLabel)\r
+            {\r
+                delete titleLabel;\r
+                titleLabel = nullptr;\r
+            }\r
+            if (emptyLabel)\r
+            {\r
+                delete emptyLabel;\r
+                emptyLabel = nullptr;\r
+            }\r
+            if (adapterText)\r
+            {\r
+                delete adapterText;\r
+                adapterText = nullptr;\r
+            }\r
+            if (list)\r
+            {\r
+                delete list;\r
+                list = nullptr;\r
+            }\r
+            if (newEquipmentButton)\r
+            {\r
+                delete newEquipmentButton;\r
+                newEquipmentButton = nullptr;\r
+            }\r
+            delete group;\r
+            group = nullptr;\r
         }\r
+        g_pBluetoothDeviceListView = nullptr;\r
     }\r
-    if (list == nullptr) {\r
-        list = new UIList(UIList::VERTICAL);\r
-        if (list == nullptr) {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView list new fail");\r
-            return;\r
+\r
+    BluetoothDeviceListView *BluetoothDeviceListView::GetInstance()\r
+    {\r
+        return g_pBluetoothDeviceListView;\r
+    }\r
+\r
+    void BluetoothDeviceListView::InitList()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::InitList");\r
+        if (adapterText == nullptr)\r
+        {\r
+            adapterText = new BluetoothDeviceCaseListAdapter();\r
+            if (adapterText == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView adapterText new fail");\r
+                return;\r
+            }\r
         }\r
-        list->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);\r
-        list->SetPosition(36, 118, HORIZONTAL_RESOLUTION, 241); // 36:x 118:y 454:width 241:height\r
-        list->SetStartIndex(0); // 0 : list start index\r
-        list->SetAdapter(adapterText);\r
-        group->Add(list);\r
+        if (list == nullptr)\r
+        {\r
+            list = new UIList(UIList::VERTICAL);\r
+            if (list == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView list new fail");\r
+                return;\r
+            }\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "adapterText->GetCount = %d", adapterText->GetCount());\r
+            list->SetPosition(43, 120);\r
+            switch (adapterText->GetCount())\r
+            {\r
+            case 0:\r
+            case 1:\r
+                list->Resize(380, 100);\r
+                break;\r
+            default:\r
+                list->Resize(380, 230);\r
+                break;\r
+            }\r
+            list->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+            list->SetStyle(STYLE_BORDER_RADIUS, 50);\r
+            list->SetDragACCLevel(5);\r
+            list->SetSwipeACCLevel(800);\r
+            list->SetReboundSize(30);\r
+            list->SetScrollBlankSize(30);\r
+            list->SetAdapter(adapterText);\r
+        }\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::InitList end");\r
     }\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::InitList end");\r
-}\r
 \r
-void BluetoothDeviceListView::InItEmptyLabel() // 暂无已配对设备\r
-{\r
-    if (emptyLabel == nullptr) {\r
-        emptyLabel = new UILabel();\r
-        if (emptyLabel == nullptr) {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView emptyLabel new fail");\r
-            return;\r
+    void BluetoothDeviceListView::InItEmptyLabel()\r
+    {\r
+        if (emptyLabel == nullptr)\r
+        {\r
+            emptyLabel = new UILabelExt();\r
+            if (emptyLabel == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView emptyLabel new fail");\r
+                return;\r
+            }\r
         }\r
+        emptyLabel->SetPosition(83, 205, 300, 45);\r
+        emptyLabel->SetTextId(STR_NO_PAIRED_DEV); // 暂无已配对设备\r
+        emptyLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);\r
+        emptyLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);\r
+        emptyLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE);\r
+        emptyLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);\r
     }\r
-    emptyLabel->SetPosition(87, 205, 280, 45); // 87:x 205:y 280:width 45:height\r
-    emptyLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE);\r
-    emptyLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);\r
-    emptyLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER,\r
-        UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);\r
-    emptyLabel->SetText("暂无已配对设备");\r
-}\r
 \r
-UIViewGroup *BluetoothDeviceListView::GetGroup()\r
-{\r
-    return group;\r
-}\r
+    UIViewGroup *BluetoothDeviceListView::GetGroup()\r
+    {\r
+        return group;\r
+    }\r
 \r
-UIList *BluetoothDeviceListView::GetDeviceUIList()\r
-{\r
-    return list;\r
-}\r
+    /*获取蓝牙已连接设备列表*/\r
+    UIList *BluetoothDeviceListView::GetDeviceUIList()\r
+    {\r
+        return list;\r
+    }\r
 \r
-void BluetoothDeviceListView::InitNewEquipmentButton()\r
-{\r
-    if (newEquipmentButton == nullptr) {\r
-        newEquipmentButton = new UILabelButton();\r
-        if (newEquipmentButton == nullptr) {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView newEquipmentButton new fail");\r
+    void BluetoothDeviceListView::InitNewEquipmentButton()\r
+    {\r
+        if (newEquipmentButton == nullptr)\r
+        {\r
+            newEquipmentButton = new UILabelButtonExt();\r
+            if (newEquipmentButton == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView newEquipmentButton new fail");\r
+                return;\r
+            }\r
+        }\r
+        newEquipmentButton->SetPosition(0, 366, 466, 100);\r
+        newEquipmentButton->SetTextId(STR_BT_HEADSET_RESCAN); // 重新搜索\r
+        newEquipmentButton->SetViewId(BLUETOOTH_NEWEQUIPMENT_BUTTON);\r
+        newEquipmentButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
+        newEquipmentButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+        newEquipmentButton->SetImageSrc(PNG_466x100BUTTON_IMAGE, PNG_466x100BUTTON_IMAGE);\r
+        newEquipmentButton->SetTextColor(Color::GetColorFromRGBA(0x35, 0x49, 0xff, 0xff));\r
+        newEquipmentButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);\r
+        newEquipmentButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::PlayersPresenter::GetInstance();\r
+        UIView::OnClickListener *clickListener2 = (UIView::OnClickListener *)OHOS::BluetoothPresenter::GetInstance();\r
+        if ((clickListener == nullptr) && (clickListener2 == nullptr))\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail");\r
             return;\r
         }\r
+        if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS)\r
+        {\r
+            newEquipmentButton->SetOnClickListener(clickListener);\r
+        }\r
+        else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING)\r
+        {\r
+            newEquipmentButton->SetOnClickListener(clickListener2);\r
+        }\r
     }\r
-    newEquipmentButton->SetPosition(65, 359, 324, 101); // 65 : x, 359 : y, 324:width 101:height\r
-    newEquipmentButton->SetText("新设备");\r
-    UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::PlayersPresenter::GetInstance();\r
-    UIView::OnClickListener *clickListener2 = (UIView::OnClickListener *)OHOS::BluetoothPresenter::GetInstance();\r
-    if ((clickListener == nullptr) && (clickListener2 == nullptr)) {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance fail");\r
-        return;\r
-    }\r
-    if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) {\r
-        newEquipmentButton->SetOnClickListener(clickListener);\r
-        newEquipmentButton->SetTextColor(Color::Red());\r
-    } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) {\r
-        newEquipmentButton->SetOnClickListener(clickListener2);\r
-        newEquipmentButton->SetTextColor(Color::Blue());\r
-    }\r
-    newEquipmentButton->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE);\r
-    newEquipmentButton->SetViewId(BLUETOOTH_NEWEQUIPMENT_BUTTON);\r
-    newEquipmentButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE);\r
-}\r
 \r
-UIViewGroup *BluetoothDeviceListView::InitShowUpView()\r
-{\r
-    // 获取currentBdAddr db值 待开发\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView init");\r
-    if (group == nullptr) {\r
-        group = new UIViewGroup();\r
-        if (group == nullptr) {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail");\r
-            return nullptr;\r
+    UIViewGroup *BluetoothDeviceListView::CreateBluetoothDeviceListView()\r
+    {\r
+        // 获取currentBdAddr db值 待开发\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView init");\r
+        if (group == nullptr)\r
+        {\r
+            group = new UIViewGroup();\r
+            if (group == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail");\r
+                return nullptr;\r
+            }\r
         }\r
-    }\r
-    group->SetPosition(0, 0);\r
-    group->SetWidth(HORIZONTAL_RESOLUTION);\r
-    group->SetHeight(VERTICAL_RESOLUTION);\r
-    if (titleLabel == nullptr) {\r
-        titleLabel = new UILabel();\r
-        if (titleLabel == nullptr) {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView titleLabel new fail");\r
+        group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);\r
+        group->SetViewId(BLUETOOTH_DEVICE_LIST_VIEW);\r
+        group->SetDraggable(true);\r
+        group->SetTouchable(true);\r
+        UIView::OnDragListener *earDragListener = (UIView::OnDragListener *)OHOS::PlayerOnDragListener::GetInstance();\r
+        UIView::OnDragListener *earDragListener2 = (UIView::OnDragListener *)OHOS::BluetoothPresenter::GetInstance();\r
+        if ((earDragListener == nullptr) && (earDragListener2 == nullptr))\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "earDragListener GetInstance fail");\r
             return nullptr;\r
         }\r
-    }\r
-\r
-    titleLabel->SetPosition(135, 35, 183, 53); // 135:x 35:y 183:width 53:height\r
-    titleLabel->SetText("蓝牙耳机");\r
-    titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE);\r
-    titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);\r
-    titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER,\r
-        UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);\r
-    InitNewEquipmentButton();\r
-    InItEmptyLabel();\r
-    // 加载列表\r
-    InitList();\r
-    group->Add(newEquipmentButton);\r
-    group->Add(titleLabel);\r
-    group->Add(emptyLabel);\r
+        if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS)\r
+        {\r
+            group->SetOnDragListener(earDragListener);\r
+        }\r
+        else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING)\r
+        {\r
+            group->SetOnDragListener(earDragListener2);\r
+        }\r
+        /* ------------------------------- titleLabel ------------------------------- */\r
+        if (titleLabel == nullptr)\r
+        {\r
+            titleLabel = new UILabelExt();\r
+            if (titleLabel == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView titleLabel new fail");\r
+                return nullptr;\r
+            }\r
+        }\r
+        titleLabel->SetPosition(83, 50, 300, 35);\r
+        titleLabel->SetTextId(STR_BLUETOOTH_HEADPHONES);\r
+        titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);\r
+        titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);\r
+        InitList(); // 加载bt设备列表\r
+        InitNewEquipmentButton();\r
+        InItEmptyLabel();\r
+        /* -------------------------------------------------------------------------- */\r
+        group->Add(titleLabel);\r
+        group->Add(list);\r
+        group->Add(emptyLabel);\r
+        group->Add(newEquipmentButton);\r
 \r
-    UIView::OnDragListener *earDragListener = (UIView::OnDragListener *)OHOS::PlayerOnDragListener::GetInstance();\r
-    UIView::OnDragListener *earDragListener2 = (UIView::OnDragListener *)OHOS::BluetoothPresenter::GetInstance();\r
-    if ((earDragListener == nullptr) && (earDragListener2 == nullptr)) {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "earDragListener GetInstance fail");\r
-        return nullptr;\r
+        return group;\r
     }\r
-    if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) {\r
-        group->SetOnDragListener(earDragListener);\r
-    } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) {\r
-        group->SetOnDragListener(earDragListener2);\r
-    }\r
-    group->SetViewId(BLUETOOTH_DEVICE_LIST_VIEW);\r
-    group->SetDraggable(true);\r
-    group->SetTouchable(true);\r
-    return group;\r
-}\r
 \r
-void BluetoothDeviceListView::RefreshText(void)\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::RefreshText");\r
-    List<BluetoothCaseInfo> &bluetoothConnedList = BluetoothModel::GetInstance()->GetConnedDevicesCase();\r
-    bool ret = bluetoothConnedList.IsEmpty();\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::RefreshText bluetoothConnedList.IsEmpty ret = %d", ret);\r
-    if (ret) {\r
-        emptyLabel->SetVisible(true);\r
-    } else {\r
-        emptyLabel->SetVisible(false);\r
+    /*刷新已连接过的蓝牙设备列表视图*/\r
+    void BluetoothDeviceListView::RefreshBluetoothDeviceListView(void)\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::RefreshBluetoothDeviceListView");\r
+        List<BluetoothCaseInfo> &bluetoothConnedList = BluetoothModel::GetInstance()->GetConnedDevicesCase();\r
+        bool ret = bluetoothConnedList.IsEmpty();\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::RefreshBluetoothDeviceListView bluetoothConnedList.IsEmpty ret = %d", ret);\r
+        if (ret)\r
+        {\r
+            emptyLabel->SetVisible(true);\r
+            list->SetVisible(false);\r
+        }\r
+        else\r
+        {\r
+            emptyLabel->SetVisible(false);\r
+            list->SetVisible(true);\r
+            switch (BluetoothModel::GetInstance()->GetConnedDevicesCase().Size())\r
+            {\r
+            case 0:\r
+            case 1:\r
+                list->Resize(380, 100);\r
+                break;\r
+            default:\r
+                list->Resize(380, 230);\r
+                break;\r
+            }\r
+            list->Invalidate();\r
+        }\r
     }\r
-}\r
 \r
 }
\ No newline at end of file
index daf4cf8..231d364 100644 (file)
@@ -60,10 +60,14 @@ void BluetoothEarListView::InitList()
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView list new fail");\r
             return;\r
         }\r
-        list->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);\r
-        list->SetPosition(36, 118, HORIZONTAL_RESOLUTION, 241); // 36:x 118:y 454:width 241:height\r
-        list->SetStartIndex(0); // 0 : list start index\r
+        list->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+        list->SetPosition(43, 120, 380, 300); \r
+        list->SetStartIndex(0);\r
         list->SetAdapter(adapterText);\r
+        list->SetReboundSize(35);\r
+        list->SetStyle(STYLE_BORDER_RADIUS, 50);\r
+        list->EnableAutoAlign(true);\r
+        list->SetIntercept(true);\r
         group->Add(list);\r
     }\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::InitList end");\r
index 676c018..ce9b516 100644 (file)
@@ -8,16 +8,17 @@
 #include "BluetoothItemView.h"\r
 #include "wearable_log.h"\r
 #include "UiConfig.h"\r
-#include "common/image_cache_manager.h"\r
-\r
-namespace OHOS {\r
-constexpr uint16_t BUTTON_WIDTH = 351;\r
-constexpr uint16_t BUTTON_HEIGHT = 81;\r
-constexpr uint16_t IMAGE_WIDTH = 81;\r
-constexpr uint16_t IMAGE_HEIGHT = 81;\r
-constexpr uint16_t LABEL_HEIGHT = 81;\r
-constexpr uint16_t LABEL_WIDTH = 189;\r
-constexpr uint16_t BLELIST_BUTTON_HEIGHT = 81;\r
+#include "player/include/PlayersView.h"\r
+#include "ui_resource_image.h"\r
+namespace OHOS\r
+{\r
+    constexpr uint16_t BUTTON_WIDTH = 351;\r
+    constexpr uint16_t BUTTON_HEIGHT = 81;\r
+    constexpr uint16_t IMAGE_WIDTH = 81;\r
+    constexpr uint16_t IMAGE_HEIGHT = 81;\r
+    constexpr uint16_t LABEL_HEIGHT = 81;\r
+    constexpr uint16_t LABEL_WIDTH = 189;\r
+    constexpr uint16_t BLELIST_BUTTON_HEIGHT = 81;\r
 \r
 #define BLUETOOTH_CONNECT_DELAY 200\r
 #define BLUETOOTH_CONNECT_X 294\r
@@ -25,140 +26,187 @@ constexpr uint16_t BLELIST_BUTTON_HEIGHT = 81;
 #define BLUETOOTH_CONNECT_WIDTH 81\r
 #define BLUETOOTH_CONNECT_HEIGHT 81\r
 \r
-BluetoothItemView::BluetoothItemView()\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::BluetoothItemView");\r
-    SetPosition(53, 106, 375, 81); // 53:x 106:y 375:width 81:height\r
-    SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);\r
-    SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);\r
-    SetUpChild();\r
-    SetTouchable(true);\r
-\r
-    Add(&button);\r
-    Add(&connectStateLabel);\r
-    Add(&namelabel);\r
-    Add(&image);\r
-    Add(&connectionAnimator);\r
-}\r
+    BluetoothItemView::BluetoothItemView()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::BluetoothItemView");\r
+        SetPosition(40, 21, 380, 100);\r
+        SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+        SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+        SetUpChild();\r
+        SetTouchable(true);\r
+\r
+        Add(&button);\r
+        Add(&namelabel);\r
+        Add(&connectStateLabel);\r
+        Add(&lineImage);\r
+        Add(&noteImage);\r
+        Add(&connectionAnimator);\r
+    }\r
 \r
-BluetoothItemView::~BluetoothItemView()\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::~BluetoothItemView");\r
-    Remove(&connectStateLabel);\r
-    Remove(&button);\r
-    Remove(&namelabel);\r
-    Remove(&image);\r
-    Remove(&connectionAnimator);\r
-}\r
+    BluetoothItemView::~BluetoothItemView()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::~BluetoothItemView");\r
+        Remove(&button);\r
+        Remove(&namelabel);\r
+        Remove(&connectStateLabel);\r
+        Remove(&lineImage);\r
+        Remove(&noteImage);\r
+        Remove(&connectionAnimator);\r
+    }\r
 \r
-void BluetoothItemView::SetUpChild()\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetUpChild");\r
-    button.Resize(BUTTON_WIDTH, BUTTON_HEIGHT); // 351:Width\r
-    button.SetImageSrc(PNG_BT_LIST, PNG_BT_LIST); // 跳转图片\r
-    button.SetImagePosition(24, 0); // 24: lable x-coordinate\r
-\r
-    namelabel.SetPosition(105, 0); // 105:x 0:y\r
-    namelabel.Resize(LABEL_WIDTH, LABEL_HEIGHT);\r
-    namelabel.SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
-    namelabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 30: means font size\r
-    namelabel.SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);\r
-    namelabel.SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER,\r
-        UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);\r
-\r
-    image.SetPosition(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT); // 0:x 0:y\r
-    image.SetSrc(PNG_BLUETOOTHEAR);\r
-    BtConnectImageAnimator();\r
-}\r
+    void BluetoothItemView::SetUpChild()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetUpChild");\r
+        button.SetPosition(40, 0, 250, 80);\r
+        button.SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+        button.SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+        button.SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);\r
+\r
+        /*蓝牙设备名称*/\r
+        namelabel.SetPosition(40, 21, 250, 35);\r
+        namelabel.SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+        namelabel.SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+        namelabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        namelabel.SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);\r
+        namelabel.SetRollSpeed(100);\r
+        namelabel.SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_LEFT, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);\r
+\r
+        /*线*/\r
+        lineImage.SetPosition(35, 98, 310, 2);\r
+        lineImage.SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
+        lineImage.SetStyle(STYLE_BACKGROUND_OPA, 0x33);\r
+        lineImage.SetStyle(STYLE_BORDER_RADIUS, 100);\r
+\r
+        BtConnectImageAnimator();\r
+    }\r
 \r
-void BluetoothItemView::SetItemInfo(const BluetoothCaseInfo& itemInfo, bool isCaseList)\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetItemInfo");\r
-    itemInfo_ = itemInfo;\r
-    namelabel.SetText(reinterpret_cast<const char *>(itemInfo_.deviceName));\r
-    if (isCaseList) {\r
-        bool ret = BluetoothModel::GetInstance()->IsTagScanDeviceClicked();\r
-        if ((!IsConnectAnimator()) && (ret)) {\r
-            namelabel.SetStyle(STYLE_TEXT_COLOR, Color::Gray().full);\r
-            button.SetTouchable(false);\r
-            SetTouchable(false);\r
-        } else {\r
-            namelabel.SetStyle(STYLE_TEXT_COLOR, Color::White().full);\r
-            button.SetTouchable(true);\r
-            SetTouchable(true);\r
+    void BluetoothItemView::SetItemInfo(const BluetoothCaseInfo &itemInfo, bool isCaseList)\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetItemInfo");\r
+        itemInfo_ = itemInfo;\r
+        namelabel.SetText(reinterpret_cast<const char *>(itemInfo_.deviceName));\r
+        if (isCaseList)\r
+        {\r
+            bool ret = BluetoothModel::GetInstance()->IsTagScanDeviceClicked();\r
+            if ((!IsConnectAnimator()) && (ret))\r
+            {\r
+                button.SetTouchable(false);\r
+                SetTouchable(false);\r
+            }\r
+            else\r
+            {\r
+                button.SetTouchable(true);\r
+                SetTouchable(true);\r
+            }\r
+        }\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "index =  %d", GetViewIndex());\r
+        List<BluetoothCaseInfo> &bluetoothCaseList = BluetoothModel::GetInstance()->GetConnedDevicesCase();\r
+        if (GetViewIndex() == bluetoothCaseList.Size() - 1)\r
+        {\r
+            lineImage.SetVisible(false);\r
+        }\r
+        else\r
+        {\r
+            lineImage.SetVisible(true);\r
         }\r
     }\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "index =  %d", GetViewIndex());\r
-}\r
 \r
-BluetoothCaseInfo *BluetoothItemView::GetItemInfo(void)\r
-{\r
-    return &itemInfo_;\r
-}\r
+    BluetoothCaseInfo *BluetoothItemView::GetItemInfo(void)\r
+    {\r
+        return &itemInfo_;\r
+    }\r
 \r
-void BluetoothItemView::SetConnectionstatus(const BluetoothCaseInfo& infoData)\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetConnectionstatus");\r
-    connectStateLabel.SetPosition(105, 0); // 105:x 0:y\r
-    connectStateLabel.Resize(LABEL_WIDTH, LABEL_HEIGHT);\r
-    connectStateLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 30: means font size\r
-    connectStateLabel.SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);\r
-    connectStateLabel.SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER,\r
-                               UITextLanguageAlignment::TEXT_ALIGNMENT_BOTTOM);\r
-    bool aclConnected = bt_is_acl_connected((const bd_addr_t*)&infoData.addr);\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetConnectionstatus aclConnected %d", aclConnected);\r
-    if (aclConnected) {\r
-        connectStateLabel.SetText("已连接");\r
-    } else {\r
-        connectStateLabel.SetText("已断开");\r
+    /**/\r
+    void BluetoothItemView::SetConnectionstatus(const BluetoothCaseInfo &infoData)\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetConnectionstatus");\r
+        connectStateLabel.SetPosition(40, namelabel.GetY() + namelabel.GetHeight(), 250, 27);\r
+        connectStateLabel.SetStyle(STYLE_TEXT_FONT, 23);\r
+        connectStateLabel.SetStyle(STYLE_LINE_HEIGHT, 27);\r
+        connectStateLabel.SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_LEFT, UITextLanguageAlignment::TEXT_ALIGNMENT_BOTTOM);\r
+        connectStateLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 23);\r
+        /* -------------------------------- noteImage ------------------------------- */\r
+        noteImage.SetPosition(namelabel.GetX() + namelabel.GetWidth(), 0, 80, 80);\r
+        noteImage.SetAutoEnable(false);\r
+        noteImage.SetResizeMode(UIImageView::CENTER);\r
+        noteImage.SetTouchable(true);\r
+        if (!PlayersView::LoadPlayerImage(&noteImage, PLAYER_LOOK_CONNECTED_NOTE))\r
+        {\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "noteImage LoadPlayerImage fail");\r
+            return;\r
+        }\r
+        /* ------------------------------ 检查ACL链路是否连接。 ------------------------------ */\r
+        bool aclConnected = bt_is_acl_connected((const bd_addr_t *)&infoData.addr);\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetConnectionstatus aclConnected %d", aclConnected);\r
+        if (aclConnected)\r
+        {\r
+            connectStateLabel.SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));\r
+            connectStateLabel.SetText("已连接");\r
+        }\r
+        else\r
+        {\r
+            connectStateLabel.SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f));\r
+            connectStateLabel.SetText("已断开");\r
+        }\r
+        connectStateLabel.Invalidate();\r
     }\r
-    namelabel.SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER,\r
-                       UITextLanguageAlignment::TEXT_ALIGNMENT_TOP);\r
-    namelabel.Invalidate();\r
-}\r
 \r
-void BluetoothItemView::ConnectAnimatorStart(void)\r
-{\r
-    connectionAnimator.SetVisible(true);\r
-    connectionAnimator.Start();\r
-}\r
+    void BluetoothItemView::SetViewOnClickListener(UIView::OnClickListener *listener)\r
+    {\r
+        if (listener)\r
+        {\r
+            button.SetOnClickListener(listener);\r
+            noteImage.SetOnClickListener(listener);\r
+        }\r
+    }\r
 \r
-void BluetoothItemView::ConnectAnimatorStop(void)\r
-{\r
-    connectionAnimator.SetVisible(false);\r
-    connectionAnimator.Stop();\r
-}\r
+    /*动画开始*/\r
+    void BluetoothItemView::ConnectAnimatorStart(void)\r
+    {\r
+        connectionAnimator.SetVisible(true);\r
+        connectionAnimator.Start();\r
+    }\r
 \r
-bool BluetoothItemView::IsConnectAnimator(void)\r
-{\r
-    return connectionAnimator.IsVisible();\r
-}\r
+    /*动画停止*/\r
+    void BluetoothItemView::ConnectAnimatorStop(void)\r
+    {\r
+        connectionAnimator.SetVisible(false);\r
+        connectionAnimator.Stop();\r
+    }\r
 \r
-void BluetoothItemView::BtConnectImageAnimator()\r
-{\r
-    const char *connectImagePath[BLUETOOTH_CONNECT_IMAGE_NUM] = {\r
-        PNG_A019_088_IMAGE_PATH,\r
-        PNG_A019_089_IMAGE_PATH,\r
-        PNG_A019_090_IMAGE_PATH,\r
-        PNG_A019_091_IMAGE_PATH,\r
-        PNG_A019_092_IMAGE_PATH,\r
-        PNG_A019_093_IMAGE_PATH,\r
-        PNG_A019_094_IMAGE_PATH,\r
-        PNG_A019_095_IMAGE_PATH,\r
-    };\r
-\r
-    for (uint8_t i = 0; i < BLUETOOTH_CONNECT_IMAGE_NUM; i++) {\r
-        connectImageInfo[i].imageInfo =  ImageCacheManager::GetInstance().LoadSingleRes(connectImagePath[i]);\r
-        connectImageInfo[i].imageType = IMG_SRC_IMAGE_INFO;\r
-        connectImageInfo[i].pos.x = BLUETOOTH_CONNECT_X;\r
-        connectImageInfo[i].pos.y = BLUETOOTH_CONNECT_Y;\r
-        connectImageInfo[i].width = BLUETOOTH_CONNECT_WIDTH;\r
-        connectImageInfo[i].height = BLUETOOTH_CONNECT_HEIGHT;\r
+    /*连接动画是否可见*/\r
+    bool BluetoothItemView::IsConnectAnimator(void)\r
+    {\r
+        return connectionAnimator.IsVisible();\r
     }\r
 \r
-    connectionAnimator.SetImageAnimatorSrc(connectImageInfo, BLUETOOTH_CONNECT_IMAGE_NUM, BLUETOOTH_CONNECT_DELAY);\r
-    connectionAnimator.SetRepeat(true);\r
-    connectionAnimator.SetVisible(false);\r
-}\r
+    /*蓝牙连接动画*/\r
+    void BluetoothItemView::BtConnectImageAnimator()\r
+    {\r
+        const char *connectImagePath[BLUETOOTH_CONNECT_IMAGE_NUM] = {\r
+            PNG_A019_088_IMAGE_PATH,\r
+            PNG_A019_089_IMAGE_PATH,\r
+            PNG_A019_090_IMAGE_PATH,\r
+            PNG_A019_091_IMAGE_PATH,\r
+            PNG_A019_092_IMAGE_PATH,\r
+            PNG_A019_093_IMAGE_PATH,\r
+            PNG_A019_094_IMAGE_PATH,\r
+            PNG_A019_095_IMAGE_PATH,\r
+        };\r
+\r
+        for (uint8_t i = 0; i < BLUETOOTH_CONNECT_IMAGE_NUM; i++)\r
+        {\r
+            connectImageInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(connectImagePath[i]);\r
+            connectImageInfo[i].imageType = IMG_SRC_IMAGE_INFO;\r
+            connectImageInfo[i].pos.x = BLUETOOTH_CONNECT_X;\r
+            connectImageInfo[i].pos.y = BLUETOOTH_CONNECT_Y;\r
+            connectImageInfo[i].width = BLUETOOTH_CONNECT_WIDTH;\r
+            connectImageInfo[i].height = BLUETOOTH_CONNECT_HEIGHT;\r
+        }\r
+\r
+        connectionAnimator.SetImageAnimatorSrc(connectImageInfo, BLUETOOTH_CONNECT_IMAGE_NUM, BLUETOOTH_CONNECT_DELAY);\r
+        connectionAnimator.SetRepeat(true);\r
+        connectionAnimator.SetVisible(false);\r
+    }\r
 \r
 }\r
index 586115c..1f77b5c 100644 (file)
@@ -55,7 +55,7 @@ namespace OHOS {
 #define BT_SPP_TASK_PRI        20\r
 #define TEN                    10\r
 \r
-constexpr uint16_t BLUETOOTH_MAX_NUM = 20;\r
+constexpr uint16_t BLUETOOTH_MAX_NUM = 20; /*已连接设备列表的大小*/\r
 \r
 #define MEDIA_A2DP_SNK_INTERFACE 1\r
 osal_timer g_a2dp_stream_accept_timer = {nullptr, nullptr, 0, 0};\r
@@ -415,6 +415,7 @@ void BluetoothModel::AddConnedDevicesCase(BluetoothCaseInfo caseInfo)
     }\r
 }\r
 \r
+/*返回指向已连接设备列表的引用,以便其他部分的代码可以直接访问和操作这个列表*/\r
 List<BluetoothCaseInfo>& BluetoothModel::GetConnedDevicesCase()\r
 {\r
     return *btConnedDevicesList_;\r
@@ -489,11 +490,13 @@ bool BluetoothModel::GetTagReconnectJump(void)
     return tagReconnectJump;\r
 }\r
 \r
+/*设置当前哪个子视图是可见的*/\r
 void BluetoothModel::SetCurView(int16_t viewNum)\r
 {\r
     curView = viewNum;\r
 }\r
 \r
+/*获取当前哪个子视图是可见的*/\r
 int BluetoothModel::GetCurView(void)\r
 {\r
     return curView;\r
index 050556d..f4c0c12 100644 (file)
@@ -127,7 +127,6 @@ namespace OHOS
         pairState->SetStyle(STYLE_TEXT_FONT, 30);\r
         pairState->SetStyle(STYLE_LINE_HEIGHT, 35);\r
         pairState->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f));\r
-        caseInfo = BluetoothModel::GetInstance()->GetTempMacValue();\r
         pairState->SetTextId(STR_PAIRED);\r
         pairState->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);\r
         pairState->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
index 27846c3..0259db4 100644 (file)
@@ -113,6 +113,7 @@ void MainBluetoothView::OnStop()
     return;\r
 }\r
 \r
+/*跳转到已连接过的蓝牙设备列表视图*/\r
 bool MainBluetoothView::ChangeBluetoothDeviceListView(int16_t hideView, int16_t thisView)\r
 {\r
     UNUSED(hideView);\r
@@ -123,8 +124,7 @@ bool MainBluetoothView::ChangeBluetoothDeviceListView(int16_t hideView, int16_t
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothDeviceListView new fail");\r
             return false;\r
         }\r
-        // init view\r
-        UIViewGroup *group = bluetoothDeviceListView->InitShowUpView();\r
+        UIViewGroup *group = bluetoothDeviceListView->CreateBluetoothDeviceListView();\r
         if (group == nullptr) {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Device group nullptr fail");\r
             return false;\r
@@ -140,7 +140,7 @@ bool MainBluetoothView::ChangeBluetoothDeviceListView(int16_t hideView, int16_t
         }\r
         deviceList->RefreshList();\r
     }\r
-    bluetoothDeviceListView->RefreshText();\r
+    bluetoothDeviceListView->RefreshBluetoothDeviceListView();\r
     return true;\r
 }\r
 \r
@@ -316,6 +316,7 @@ bool MainBluetoothView::ChangeBluetoothReconnectView(int16_t hideView, int16_t t
     return true;\r
 }\r
 \r
+/*连接失败和蓝牙重连视图都跳转到已连接的蓝牙设备列表视图*/\r
 void MainBluetoothView::CorrespondingJump(int16_t hideView)\r
 {\r
     BluetoothModel *bluetoothModel = BluetoothModel::GetInstance();\r
@@ -323,17 +324,19 @@ void MainBluetoothView::CorrespondingJump(int16_t hideView)
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView bluetoothModel == nullptr");\r
             return;\r
         }\r
-    if (bluetoothModel->GetTagReconnectJump()) {\r
-        ChangeView(hideView, BLUETOOTHEOPTIONSVIEW);\r
-    } else {\r
-        std::list<BluetoothCaseInfo> &bluetoothScanList = BluetoothModel::GetInstance()->GetCase();\r
-        bool ret = bluetoothScanList.empty();\r
-        if (!ret) {\r
-            ChangeView(hideView, BLUETOOTHEARLISTVIEW);\r
-        } else {\r
-            ChangeView(hideView, BLUETOOTHEARPHONEVIEW);\r
-        }\r
-    }\r
+    ChangeView(hideView, BLUETOOTHDEVICELISTVIEW);/*查看已连接过的蓝牙耳机设备视图*/\r
+\r
+    // if (bluetoothModel->GetTagReconnectJump()) {\r
+    //     ChangeView(hideView, BLUETOOTHEOPTIONSVIEW);/*查看已连接过的蓝牙耳机设备视图*/\r
+    // } else {\r
+    //     std::list<BluetoothCaseInfo> &bluetoothScanList = BluetoothModel::GetInstance()->GetCase();\r
+    //     bool ret = bluetoothScanList.empty();\r
+    //     if (!ret) {\r
+    //         ChangeView(hideView, BLUETOOTHEARLISTVIEW);/*耳机列表界面*/\r
+    //     } else {\r
+    //         ChangeView(hideView, BLUETOOTHEARPHONEVIEW);/*搜索界面*/\r
+    //     }\r
+    // }\r
     return;\r
 }\r
 \r
@@ -413,9 +416,9 @@ void MainBluetoothView::DropView(UIView& view)
         ChangeSettingView();\r
     } else if (&view == container[BLUETOOTHRECONNECTVIEW]) {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[BLUETOOTHRECONNECTVIEW]");\r
-        CorrespondingJump(BLUETOOTHRECONNECTVIEW);\r
         BluetoothModel::GetInstance()->SetTagDisconnectView(false);\r
-        bluetoothReconnectView->BtReconnectStop();\r
+        bluetoothReconnectView->BtReconnectStop();/*先停止动画在视图跳转*/\r
+        CorrespondingJump(BLUETOOTHRECONNECTVIEW);\r
     }\r
 }\r
 \r
index 2190639..0eafd36 100644 (file)
@@ -207,7 +207,7 @@ bool JumpView::ChangeBluetoothDeviceListView(int16_t hideView, int16_t thisView)
             return false;\r
         }\r
         // init view\r
-        UIViewGroup *group = bluetoothDeviceListView->InitShowUpView();\r
+        UIViewGroup *group = bluetoothDeviceListView->CreateBluetoothDeviceListView();\r
         if (group == nullptr) {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Device group nullptr fail");\r
             return false;\r
@@ -228,7 +228,7 @@ bool JumpView::ChangeBluetoothDeviceListView(int16_t hideView, int16_t thisView)
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick bluetoothDeviceListView new fail");\r
         return false;\r
     }\r
-    bluetoothDeviceListView->RefreshText();\r
+    bluetoothDeviceListView->RefreshBluetoothDeviceListView();\r
     \r
     return true;\r
 }\r