Merge #871 into sdk602patch0626 from refs/changes/871/head 873/target/1
author罗正 <1732036298@qq.com>
Wed, 4 Sep 2024 14:00:40 +0000 (14:00 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Wed, 4 Sep 2024 14:00:40 +0000 (14:00 +0000)
蓝牙耳机基本修改完成

* refs/changes/871/head: (1 commits squashed)

  - 蓝牙耳机基本修改完成

Signed-off-by: 罗正 <1732036298@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/871
18 files changed:
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothEarListView.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/BluetoothOptionsView.h
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothPresenter.h
code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothReconnectView.h
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothCaseListAdapter.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/BluetoothEarPhoneView.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/BluetoothPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothReconnectView.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/MainBluetoothView.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/TipsConnFailMessageView.cpp
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/TipsSuccMessageView.cpp

index a42c631..06d6111 100644 (file)
@@ -10,7 +10,7 @@
 #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_image_animator.h"\r
 #include "components/ui_list.h"\r
 #include "BluetoothCaseListAdapter.h"\r
@@ -30,15 +30,18 @@ public:
     void SetNewEquipmentButtonRemove(void);\r
     void SetCancelConnedRequestButtonAdd(void);\r
     void SetCancelConnedRequestButtonRemove(void);\r
+    void RefreshBluetoothEarListView(void);\r
+    \r
 private:\r
     void InitList(void);\r
     void InitButten(UILabelButton **button, const char *text, const char* id);\r
+    void InitNewEquipmentButton();\r
     UIViewGroup *group{nullptr};\r
     UIList *list{nullptr};\r
-    UILabel *titleLabel{nullptr};\r
+    UILabelExt *titleLabel{nullptr};\r
     BluetoothCaseListAdapter *adapterText{nullptr};\r
-    UILabelButton *rescanButton{nullptr};\r
-    UILabelButton *cancelConnedRequestButton{nullptr};\r
+    UILabelButtonExt *rescanButton{nullptr};\r
+    UILabelButtonExt *cancelConnedRequestButton{nullptr};\r
 };\r
 } // namespace OHOS\r
 #endif // BLUETOOTH_EAR_LIST_VIEW_H
\ No newline at end of file
index 9abf4da..9ff78ba 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-16 18:37:30\r
+ * @LastEditTime: 2024-09-04 14:23:09\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothItemView.h\r
  */\r
 \r
@@ -29,6 +29,7 @@ public:
     void SetItemInfo(const BluetoothCaseInfo& itemInfo, bool isCaseList);\r
     BluetoothCaseInfo *GetItemInfo(void);\r
     void SetConnectionstatus(const BluetoothCaseInfo& infoData);\r
+    void SetPairingtatus();\r
     void SetViewOnClickListener(UIView::OnClickListener *listener);\r
     void SetUpChild();\r
     void ConnectAnimatorStart(void);\r
@@ -37,7 +38,7 @@ public:
 private:\r
     ImageAnimatorInfo connectImageInfo[BLUETOOTH_CONNECT_IMAGE_NUM];\r
     UIButton button;\r
-    UILabel connectStateLabel;/*连接状态标签*/\r
+    UILabelExt connectStateLabel;/*连接状态标签*/\r
     UILabel namelabel;/*设备名*/\r
     UIImageView lineImage;\r
     UIImageView noteImage;\r
index 9190e5a..1611290 100644 (file)
@@ -53,7 +53,6 @@ public:
     void Init();\r
     int GetBluetoothCalleridStatus(void);\r
     void SetBluetoothCalleridStatus(int16_t value);\r
-    // É¨ÃèÉ豸¶ÓÁгõʼ»¯\r
     std::list<BluetoothCaseInfo>& GetCase();\r
     void AddCase(BluetoothCaseInfo caseInfo);\r
     void SetScansCaseRssi(const bd_addr_t *bdAddr, int rssi);\r
@@ -110,7 +109,7 @@ private:
     bd_addr_t lastConnedAddr{};\r
     bd_addr_t remoteConnectAddr{0};\r
     BluetoothItemView *selectItemView{nullptr};\r
-    std::list<BluetoothCaseInfo> btScansDevicesList_{}; // É¨ÃèÉ豸¶ÓÁÐ\r
+    std::list<BluetoothCaseInfo> btScansDevicesList_{};     //蓝牙扫描设备列表\r
     List<BluetoothCaseInfo> *btConnedDevicesList_{nullptr}; //已连接设备列表\r
     bool tagReconnectJump{0};\r
     int16_t curView{0};\r
index 2f52947..3d42f8d 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 10:18:02\r
+ * @LastEditTime: 2024-09-04 18:20:24\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothOptionsView.h\r
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE\r
  */\r
@@ -18,7 +18,7 @@
 \r
 namespace OHOS\r
 {\r
-    // 已连接的蓝牙耳机设备视图\r
+    // 查看已连接的蓝牙耳机设备视图\r
     class BluetoothOptionsView\r
     {\r
     public:\r
index 1f2fa62..e6c7e10 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-16 16:32:56\r
+ * @LastEditTime: 2024-09-04 15:43:50\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothPresenter.h\r
  */\r
 \r
@@ -25,7 +25,7 @@
 namespace OHOS {\r
 enum BluetoothPresenterNum : uint8_t {\r
         BLUETOOTHEARPHONEVIEW = 0, // 搜索界面\r
-        BLUETOOTHEARLISTVIEW,   /*耳机列表界面*/\r
+        BLUETOOTHEARLISTVIEW,   /*扫描出的耳机列表界面*/\r
         BLUETOOTHDEVICELISTVIEW,/*已连接过的蓝牙设备列表视图*/\r
         BLUETOOTHEOPTIONSVIEW, /*查看已连接过的蓝牙耳机设备视图*/\r
         BLUETOOTHRECONNECTVIEW,/*蓝牙重新连接视图*/\r
index 52b26c2..e9683eb 100644 (file)
@@ -14,7 +14,7 @@
 #include "components/abstract_adapter.h"\r
 #include "components/ui_view_group.h"\r
 #include "bts_def.h"\r
-#define BLUETOOTH_RECONNECT_IMAGE_NUM 8\r
+#define BLUETOOTH_RECONNECT_IMAGE_NUM 60\r
 \r
 namespace OHOS {\r
 class BluetoothReconnectView {\r
@@ -28,14 +28,19 @@ public:
     bd_addr_t GetcurrentBdAddr(void);\r
     void RefreshBluetoothNameLabel();\r
 private:\r
-    ImageAnimatorInfo reconnetImageInfo[BLUETOOTH_RECONNECT_IMAGE_NUM];\r
+    // ImageAnimatorInfo reconnetImageInfo[BLUETOOTH_RECONNECT_IMAGE_NUM];\r
     void ShowUpTitleLabel(void);\r
+    void start_connect_timer();\r
+    void stop_connect_timer();\r
     UILabel *titleLabel{nullptr};\r
     UILabel *bluetoothNameLabel{nullptr};\r
-    UIImageAnimatorView *reconnectAnimator{nullptr};\r
+    // UIImageAnimatorView *reconnectAnimator{nullptr};\r
     UIViewGroup *group{nullptr};\r
     bd_addr_t currentBdAddr;\r
     void BtReconnectImageAnimator();\r
+    UIImageAnimatorView *reconnectAnimator{nullptr};\r
+    const ImageInfo **reconnectPathsArray{nullptr};\r
+    ImageAnimatorInfo reconnetImageInfo[BLUETOOTH_RECONNECT_IMAGE_NUM];\r
 };\r
 } // namespace OHOS\r
 #endif // BLUETOOTH_RECONNECT_VIEW_H
\ No newline at end of file
index 9bd3eac..a9003d3 100644 (file)
@@ -12,6 +12,7 @@
 #include "wearable_log.h"
 #include "UiConfig.h"
 #include "BluetoothModel.h"
+#include "bluetooth/include/MainBluetoothView.h"
 
 namespace OHOS {
 BluetoothCaseListAdapter::~BluetoothCaseListAdapter()
@@ -44,12 +45,12 @@ public:
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothOnClickListListener");
         UNUSED(event);
         BluetoothItemView *itemView = static_cast<BluetoothItemView *>(&view);
-        // 二次点击不做响应
-        bool ret = itemView->IsConnectAnimator();
-        if (ret) {
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Block secondary clicks");
-            return true;
-        }
+        // // 二次点击不做响应
+        // bool ret = itemView->IsConnectAnimator();
+        // if (ret) {
+        //     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Block secondary clicks");
+        //     return true;
+        // }
         BluetoothCaseInfo *bluetoothInfo_ = itemView->GetItemInfo();
         /* 点击事件 */
         BluetoothModel::GetInstance()->SetTempMacValue(bluetoothInfo_);
@@ -62,33 +63,39 @@ public:
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView bluetoothEarPhoneView == nullptr");
             return false;
         }
-        bluetoothEarPhoneView->BtAnimatorStop();
-        bluetoothEarPhoneView->StopBtDiscovery();
+        bluetoothEarPhoneView->BtAnimatorStop();//搜索动画停止
+        bluetoothEarPhoneView->StopBtDiscovery();//停止扫描
         BluetoothModel::GetInstance()->SetTagScanDeviceClicked(true);
-
-        // 刷新列表
-        BluetoothEarListView *bluetoothEarListView = BluetoothEarListView::GetInstance();
-        if (bluetoothEarListView == nullptr) {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClickCancelConnedRequestButton bluetoothEarListView nullptr");
+        MainBluetoothView *mainBluetoothView = MainBluetoothView::GetInstance();
+        if (mainBluetoothView == nullptr) {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceOnClick mainBluetoothView GetInstance fail");
             return false;
         }
-        if (bluetoothEarListView->GetScanUIList() == nullptr) {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClickCancelConnedRequestButton GetScanUIList nullptr");
-            return false;
-        }
-        bluetoothEarListView->GetScanUIList()->RefreshList();
-        bluetoothEarListView->SetNewEquipmentButtonRemove();
-        bluetoothEarListView->SetCancelConnedRequestButtonAdd();
-        RootView::GetInstance()->Invalidate();
+
+        // // 刷新列表
+        // BluetoothEarListView *bluetoothEarListView = BluetoothEarListView::GetInstance();
+        // if (bluetoothEarListView == nullptr) {
+        //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClickCancelConnedRequestButton bluetoothEarListView nullptr");
+        //     return false;
+        // }
+        // if (bluetoothEarListView->GetScanUIList() == nullptr) {
+        //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClickCancelConnedRequestButton GetScanUIList nullptr");
+        //     return false;
+        // }
+        // bluetoothEarListView->GetScanUIList()->RefreshList();
+        // // bluetoothEarListView->SetNewEquipmentButtonRemove();
+        // // bluetoothEarListView->SetCancelConnedRequestButtonAdd();
+        // RootView::GetInstance()->Invalidate();
 
         // 判断是否正在连接
         bd_addr_t *lastAddr = BluetoothModel::GetInstance()->GetLastConnedAddr();
-        ret = bt_is_acl_connected(lastAddr);
+        bool ret = bt_is_acl_connected(lastAddr);
         if (ret) {
             BluetoothModel::GetInstance()->SetTagConnectNew(true);
             errcode_t retVal = gap_disconnect_remote_device(lastAddr);
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Disconnect LastDevice retVal =  %d", retVal);
         } else {
+            mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), BLUETOOTHRECONNECTVIEW);
             errcode_t retVal = BluetoothModel::GetInstance()->ConnectRemoteDevice(&addr);
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectRemoteDevice ret =  %d", retVal);
         }
@@ -155,9 +162,10 @@ UIView *BluetoothCaseListAdapter::GetView(UIView *inView, int16_t index)
     (void)sprintf_s(addrTmp, sizeof(addrTmp), "%02x%02x%02x%02x%02x%02x", node->addr[0], node->addr[1],
         node->addr[2], node->addr[3], node->addr[4], node->addr[5]); // 没有%s类型,不做返回判断
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "addrTmp %s", addrTmp);
-    ClickAnimation(itemData, item);
+    // ClickAnimation(itemData, item);
     item->SetItemInfo(itemData, true);
     item->SetViewIndex(index);
+    item->SetPairingtatus();
     return item;
 }
 } // namespace OHOS
\ No newline at end of file
index 563f0bd..17a2a38 100644 (file)
@@ -84,23 +84,13 @@ namespace OHOS
                 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->SetPosition(43, 120, 380, 100);\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->SetScrollBlankSize(30);\r
             list->SetAdapter(adapterText);\r
         }\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView::InitList end");\r
@@ -123,6 +113,7 @@ namespace OHOS
         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
+        emptyLabel->SetVisible(false);\r
     }\r
 \r
     UIViewGroup *BluetoothDeviceListView::GetGroup()\r
@@ -147,12 +138,12 @@ namespace OHOS
                 return;\r
             }\r
         }\r
-        newEquipmentButton->SetPosition(0, 366, 466, 100);\r
+        newEquipmentButton->SetPosition(173, list->GetY() + list->GetHeight() + 20, 120, 40);\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->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
@@ -217,8 +208,12 @@ namespace OHOS
         }\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->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);\r
+        titleLabel->SetStyle(STYLE_TEXT_FONT,30);\r
+        titleLabel->SetStyle(STYLE_LINE_HEIGHT,35);\r
+        titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        titleLabel->SetRollSpeed(70);\r
         titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);\r
         InitList(); // 加载bt设备列表\r
         InitNewEquipmentButton();\r
@@ -236,29 +231,27 @@ namespace OHOS
     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
+        if (list && newEquipmentButton)\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
+                list->Resize(380, 0);\r
+                break;\r
             case 1:\r
                 list->Resize(380, 100);\r
                 break;\r
+            case 2:\r
+                list->Resize(380, 200);\r
+                break;\r
             default:\r
-                list->Resize(380, 230);\r
+                list->Resize(380, 300);\r
                 break;\r
             }\r
+            newEquipmentButton->SetY(list->GetY() + list->GetHeight() + 20);\r
+            list->RefreshList();\r
             list->Invalidate();\r
+            newEquipmentButton->Invalidate();\r
         }\r
     }\r
 \r
index 231d364..9122a94 100644 (file)
 #include "PlayersPresenter.h"\r
 #include "BluetoothPresenter.h"\r
 #include "SettingModel.h"\r
+#include "ui_resource_string.h"\r
 \r
-namespace OHOS {\r
-static BluetoothEarListView *g_pBluetoothEarListView{nullptr};\r
-\r
-BluetoothEarListView::BluetoothEarListView()\r
+namespace OHOS\r
 {\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::BluetoothEarListView");\r
-    g_pBluetoothEarListView = this;\r
-}\r
+    static BluetoothEarListView *g_pBluetoothEarListView{nullptr};\r
 \r
-BluetoothEarListView::~BluetoothEarListView()\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::~BluetoothEarListView");\r
-    group->RemoveAll();\r
-    delete titleLabel;\r
-    titleLabel = nullptr;\r
-    delete adapterText;\r
-    adapterText = nullptr;\r
-    delete list;\r
-    list = nullptr;\r
-    delete rescanButton;\r
-    rescanButton = nullptr;\r
-    delete group;\r
-    group = nullptr;\r
-    g_pBluetoothEarListView = nullptr;\r
-}\r
-\r
-BluetoothEarListView *BluetoothEarListView::GetInstance()\r
-{\r
-    return g_pBluetoothEarListView;\r
-}\r
+    BluetoothEarListView::BluetoothEarListView()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::BluetoothEarListView");\r
+        g_pBluetoothEarListView = this;\r
+    }\r
 \r
-void BluetoothEarListView::InitList()\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::InitList");\r
-    // list type\r
-    if (adapterText == nullptr) {\r
-        adapterText = new BluetoothCaseListAdapter();\r
-        if (adapterText == nullptr) {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView adapterText new fail");\r
-            return;\r
+    BluetoothEarListView::~BluetoothEarListView()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::~BluetoothEarListView");\r
+        if (group)\r
+        {\r
+            group->RemoveAll();\r
+            if (titleLabel)\r
+            {\r
+                delete titleLabel;\r
+                titleLabel = 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 (rescanButton)\r
+            {\r
+                delete rescanButton;\r
+                rescanButton = nullptr;\r
+            }\r
+            if (cancelConnedRequestButton)\r
+            {\r
+                delete cancelConnedRequestButton;\r
+                cancelConnedRequestButton = nullptr;\r
+            }\r
+            delete group;\r
+            group = nullptr;\r
         }\r
+        g_pBluetoothEarListView = nullptr;\r
     }\r
-    if (list == nullptr) {\r
-        list = new UIList(UIList::VERTICAL);\r
-        if (list == nullptr) {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView list new fail");\r
-            return;\r
+\r
+    BluetoothEarListView *BluetoothEarListView::GetInstance()\r
+    {\r
+        return g_pBluetoothEarListView;\r
+    }\r
+\r
+    void BluetoothEarListView::InitList()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::InitList");\r
+        // list type\r
+        if (adapterText == nullptr)\r
+        {\r
+            adapterText = new BluetoothCaseListAdapter();\r
+            if (adapterText == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView adapterText new fail");\r
+                return;\r
+            }\r
+        }\r
+        if (list == nullptr)\r
+        {\r
+            list = new UIList(UIList::VERTICAL);\r
+            if (list == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView list new fail");\r
+                return;\r
+            }\r
+            list->SetPosition(43, 120, 380, 300);\r
+            list->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+            list->SetStyle(STYLE_BORDER_RADIUS, 50);\r
+            list->SetStartIndex(0);\r
+            // list->EnableAutoAlign(true);\r
+            // list->SetIntercept(true);\r
+            list->SetDragACCLevel(5);\r
+            list->SetSwipeACCLevel(800);\r
+            list->SetReboundSize(30);\r
+            // list->SetScrollBlankSize(30);\r
+            list->SetAdapter(adapterText);\r
+            group->Add(list);\r
         }\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
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::InitList end");\r
     }\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::InitList end");\r
-}\r
 \r
-UIViewGroup *BluetoothEarListView::GetGroup()\r
-{\r
-    return group;\r
-}\r
+    UIViewGroup *BluetoothEarListView::GetGroup()\r
+    {\r
+        return group;\r
+    }\r
 \r
-UIList *BluetoothEarListView::GetScanUIList()\r
-{\r
-    return list;\r
-}\r
+    UIList *BluetoothEarListView::GetScanUIList()\r
+    {\r
+        return list;\r
+    }\r
 \r
-void BluetoothEarListView::SetTitleLabel(const char *text)\r
-{\r
-    titleLabel->SetText(text);\r
-}\r
+    void BluetoothEarListView::SetTitleLabel(const char *text)\r
+    {\r
+        // titleLabel->SetText(text);\r
+    }\r
 \r
-void BluetoothEarListView::SetNewEquipmentButtonAdd(void)\r
-{\r
-    group->Add(rescanButton);\r
-}\r
+    void BluetoothEarListView::SetNewEquipmentButtonAdd(void)\r
+    {\r
+        // group->Add(rescanButton);\r
+    }\r
 \r
-void BluetoothEarListView::SetNewEquipmentButtonRemove(void)\r
-{\r
-    group->Remove(rescanButton);\r
-}\r
+    void BluetoothEarListView::SetNewEquipmentButtonRemove(void)\r
+    {\r
+        // group->Remove(rescanButton);\r
+    }\r
 \r
-void BluetoothEarListView::SetCancelConnedRequestButtonAdd(void)\r
-{\r
-    group->Add(cancelConnedRequestButton);\r
-}\r
+    void BluetoothEarListView::SetCancelConnedRequestButtonAdd(void)\r
+    {\r
+        // group->Add(cancelConnedRequestButton);\r
+    }\r
 \r
-void BluetoothEarListView::SetCancelConnedRequestButtonRemove(void)\r
-{\r
-    group->Remove(cancelConnedRequestButton);\r
-}\r
+    void BluetoothEarListView::SetCancelConnedRequestButtonRemove(void)\r
+    {\r
+        // group->Remove(cancelConnedRequestButton);\r
+    }\r
 \r
-void BluetoothEarListView::InitButten(UILabelButton **button, const char *text, const char* id)\r
-{\r
-    if (*button == nullptr) {\r
-        *button = new UILabelButton();\r
-        if (*button == nullptr) {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::InitButten new fail");\r
+    void BluetoothEarListView::InitButten(UILabelButton **button, const char *text, const char *id)\r
+    {\r
+        if (*button == nullptr)\r
+        {\r
+            *button = new UILabelButton();\r
+            if (*button == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView::InitButten new fail");\r
+                return;\r
+            }\r
+        }\r
+        (*button)->SetPosition(65, 359, 324, 101); // 65 : x, 359 : y, 324:width 101:height\r
+        (*button)->SetText(text);\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, "BluetoothEarListView::InitButten button GetInstance fail");\r
             return;\r
         }\r
+        if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS)\r
+        {\r
+            (*button)->SetOnClickListener(clickListener);\r
+            (*button)->SetTextColor(Color::Red());\r
+        }\r
+        else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING)\r
+        {\r
+            (*button)->SetOnClickListener(clickListener2);\r
+            (*button)->SetTextColor(Color::Blue());\r
+        }\r
+        (*button)->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE);\r
+        (*button)->SetViewId(id);\r
+        (*button)->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE);\r
     }\r
-    (*button)->SetPosition(65, 359, 324, 101); // 65 : x, 359 : y, 324:width 101:height\r
-    (*button)->SetText(text);\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, "BluetoothEarListView::InitButten button GetInstance fail");\r
-        return;\r
-    }\r
-    if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) {\r
-        (*button)->SetOnClickListener(clickListener);\r
-        (*button)->SetTextColor(Color::Red());\r
-    } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) {\r
-        (*button)->SetOnClickListener(clickListener2);\r
-        (*button)->SetTextColor(Color::Blue());\r
-    }\r
-    (*button)->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE);\r
-    (*button)->SetViewId(id);\r
-    (*button)->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE);\r
-}\r
 \r
-UIViewGroup *BluetoothEarListView::InitShowUpView()\r
-{\r
-    // 获取currentBdAddr db值 待开发\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView 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
+    void BluetoothEarListView::InitNewEquipmentButton()\r
+    {\r
+        if (rescanButton == nullptr)\r
+        {\r
+            rescanButton = new UILabelButtonExt();\r
+            if (rescanButton == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothDeviceListView rescanButton new fail");\r
+                return;\r
+            }\r
+        }\r
+        rescanButton->SetPosition(173, list->GetY() + list->GetHeight() + 20, 120, 40);\r
+        rescanButton->SetTextId(STR_BT_HEADSET_RESCAN); // 重新搜索\r
+        rescanButton->SetViewId(BLUETOOTH_RESCAN_BUTTON);\r
+        rescanButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
+        rescanButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+        rescanButton->SetTextColor(Color::GetColorFromRGBA(0x35, 0x49, 0xff, 0xff));\r
+        rescanButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);\r
+        rescanButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        group->Add(rescanButton);\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
+            rescanButton->SetOnClickListener(clickListener);\r
+        }\r
+        else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING)\r
+        {\r
+            rescanButton->SetOnClickListener(clickListener2);\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, "BluetoothEarListView titleLabel new fail");\r
+\r
+    UIViewGroup *BluetoothEarListView::InitShowUpView()\r
+    {\r
+        // 获取currentBdAddr db值 待开发\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarListView 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
+        group->SetPosition(0, 0);\r
+        group->SetWidth(HORIZONTAL_RESOLUTION);\r
+        group->SetHeight(VERTICAL_RESOLUTION);\r
+        /* -------------------------------------------------------------------------- */\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->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);\r
+        titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);\r
+        titleLabel->SetStyle(STYLE_TEXT_FONT,30);\r
+        titleLabel->SetStyle(STYLE_LINE_HEIGHT,35);\r
+        titleLabel->SetRollSpeed(70);\r
+        titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);\r
+        titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        group->Add(titleLabel);\r
+        /* -------------------------------------------------------------------------- */\r
+        // 加载列表\r
+        InitList();\r
+        // 按钮初始化\r
+        // InitButten(&rescanButton, "重新扫描", BLUETOOTH_RESCAN_BUTTON);\r
+        // InitButten(&cancelConnedRequestButton, "取消", BLUETOOTH_CANCELCONNEDREQUEST_BUTTON);\r
+        InitNewEquipmentButton();\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
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "earDragListener GetInstance fail");\r
             return nullptr;\r
         }\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
+        group->SetViewId(BLUETOOTH_EARLIST_VIEW);\r
+        group->SetDraggable(true);\r
+        group->SetTouchable(true);\r
+        return group;\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
-    // 加载列表\r
-    InitList();\r
-    InitButten(&rescanButton, "重新扫描", BLUETOOTH_RESCAN_BUTTON);\r
-    InitButten(&cancelConnedRequestButton, "取消", BLUETOOTH_CANCELCONNEDREQUEST_BUTTON);\r
-    group->Add(titleLabel);\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
-    }\r
-    if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) {\r
-        group->SetOnDragListener(earDragListener);\r
-    } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) {\r
-        group->SetOnDragListener(earDragListener2);\r
+\r
+    // 刷新扫描出来的设备列表\r
+    void BluetoothEarListView::RefreshBluetoothEarListView(void)\r
+    {\r
+        if (list && rescanButton)\r
+        {\r
+            switch (BluetoothModel::GetInstance()->GetCase().size())//根据扫描出的设备数量,设置扫描列表的高度,使其高度自适应\r
+            {\r
+            case 0:\r
+                list->Resize(380, 0);\r
+                break;\r
+            case 1:\r
+                list->Resize(380, 100);\r
+                break;\r
+            case 2:\r
+                list->Resize(380, 200);\r
+                break;\r
+            default:\r
+                list->Resize(380, 300);\r
+                break;\r
+            }\r
+            rescanButton->SetY(list->GetY() + list->GetHeight() + 20);\r
+            list->RefreshList();\r
+            list->Invalidate();\r
+            rescanButton->Invalidate();\r
+        }\r
     }\r
-    group->SetViewId(BLUETOOTH_EARLIST_VIEW);\r
-    group->SetDraggable(true);\r
-    group->SetTouchable(true);\r
-    return group;\r
-}\r
 }
\ No newline at end of file
index 6f75591..7f5ae69 100644 (file)
@@ -16,6 +16,7 @@
 #include "graphic_service.h"\r
 #include "uicomponents/UIComponents.h"\r
 #include "uiservice/include/ui_service.h"\r
+#include <custom_utils.h>\r
 \r
 namespace OHOS\r
 {\r
@@ -162,6 +163,8 @@ namespace OHOS
             }\r
             g_stopScanHandle = nullptr;\r
         }\r
+        /* --------------------------------- 取消屏幕常亮 --------------------------------- */\r
+        ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON);\r
         /* -------------------------------------------------------------------------- */\r
         bool results = gap_br_cancel_discovery();\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CancelBtDiscovery results %d", results);\r
@@ -170,6 +173,7 @@ namespace OHOS
     // 结束扫描处理\r
     static void EndScanHandle(void)\r
     {\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EndScanHandle");\r
         if (BluetoothModel::GetInstance()->GetCase().size() == 0)\r
         {\r
             BluetoothEarPhoneView *bluetoothEarPhoneView = BluetoothEarPhoneView::GetInstance();\r
@@ -230,7 +234,7 @@ namespace OHOS
     {\r
         (void)data;\r
         CancelBrScanHandle();\r
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Bt scan end jumpView");\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Bt scan end jumpView");\r
         EndScanHandle();\r
     }\r
 \r
@@ -260,7 +264,9 @@ namespace OHOS
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable StartBtDiscovery results %d", results);\r
         }\r
         /* -------------------------------------------------------------------------- */\r
-        ScreenTurnOn(MS_SCAN_TIME);\r
+        // ScreenTurnOn(MS_SCAN_TIME);\r
+        /* --------------------------------- 设置屏幕为常亮 -------------------------------- */\r
+        ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);\r
         /* -------------------------------------------------------------------------- */\r
         /*开启定时器*/\r
         if (g_stopScanHandle != nullptr)\r
index ce9b516..69adb8a 100644 (file)
@@ -10,6 +10,7 @@
 #include "UiConfig.h"\r
 #include "player/include/PlayersView.h"\r
 #include "ui_resource_image.h"\r
+#include "ui_resource_string.h"\r
 namespace OHOS\r
 {\r
     constexpr uint16_t BUTTON_WIDTH = 351;\r
@@ -116,7 +117,7 @@ namespace OHOS
         return &itemInfo_;\r
     }\r
 \r
-    /**/\r
+    /*连接状态设置*/\r
     void BluetoothItemView::SetConnectionstatus(const BluetoothCaseInfo &infoData)\r
     {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetConnectionstatus");\r
@@ -141,16 +142,29 @@ namespace OHOS
         if (aclConnected)\r
         {\r
             connectStateLabel.SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));\r
-            connectStateLabel.SetText("已连接");\r
+            connectStateLabel.SetTextId(STR_CONNECTED); // 已连接\r
         }\r
         else\r
         {\r
             connectStateLabel.SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f));\r
-            connectStateLabel.SetText("已断开");\r
+            connectStateLabel.SetTextId(STR_DISCONNECTED); // 未连接\r
         }\r
+        connectStateLabel.ForceResetText();\r
         connectStateLabel.Invalidate();\r
     }\r
 \r
+    void BluetoothItemView::SetPairingtatus()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothItemView::SetPairingtatus");\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
+        connectStateLabel.SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f));\r
+        connectStateLabel.SetTextId(STR_NOT_PAIRED); // 未配对\r
+    }\r
+\r
     void BluetoothItemView::SetViewOnClickListener(UIView::OnClickListener *listener)\r
     {\r
         if (listener)\r
index 02e9bb0..e49ce8a 100644 (file)
@@ -49,6 +49,9 @@
 #include "Bluetooyhpabpserver.h"\r
 #include "bletest.h"\r
 #include "ConfigModelC.h"\r
+#include "uiservice/include/ui_service.h"\r
+#include "vibrator_service.h"\r
+#include "ConfigModel.h"\r
 namespace OHOS {\r
 \r
 #define BT_SPP_TASK_STACK_SIZE 2048\r
@@ -267,11 +270,13 @@ SetUpListCase();
 SetUpConnedDevicesList();\r
 }\r
 \r
+//清空这个扫描列表\r
 void BluetoothModel::SetCaseListClear()\r
 {\r
     btScansDevicesList_.clear();\r
 }\r
 \r
+//检查给定的蓝牙设备信息是否已经存在于这个列表中\r
 bool BluetoothModel::CheckExistScanList(BluetoothCaseInfo caseInfo)\r
 {\r
     std::list<BluetoothCaseInfo>::iterator node = btScansDevicesList_.begin();\r
@@ -290,16 +295,19 @@ bool BluetoothModel::CheckExistScanList(BluetoothCaseInfo caseInfo)
     return false;\r
 }\r
 \r
+//清空这个扫描列表\r
 void BluetoothModel::SetUpListCase()\r
 {\r
     SetCaseListClear();\r
 }\r
 \r
+//返回这个列表的引用\r
 std::list<BluetoothCaseInfo>& BluetoothModel::GetCase()\r
 {\r
     return btScansDevicesList_;\r
 }\r
 \r
+//向这个列表中添加蓝牙设备信息\r
 void BluetoothModel::AddCase(BluetoothCaseInfo caseInfo)\r
 {\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCase::caseInfo addr: %02x%02x%02x%02x%02x%02x",\r
@@ -312,7 +320,7 @@ void BluetoothModel::AddCase(BluetoothCaseInfo caseInfo)
         btScansDevicesList_.push_back(caseInfo);\r
     }\r
 }\r
-\r
+//设置设备的信号强度\r
 void BluetoothModel::SetScansCaseRssi(const bd_addr_t *bdAddr, int rssi)\r
 {\r
     for (auto it = btScansDevicesList_.begin(); it != btScansDevicesList_.end(); it++) {\r
@@ -334,12 +342,14 @@ bool CompBuletoothInfo(const BluetoothCaseInfo& a, const BluetoothCaseInfo& b)
     return false;\r
 }\r
 \r
+//按照信号强度进行排序\r
 void BluetoothModel::SortScansCaseRssi()\r
 {\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothModel::SortScansCaseRssi");\r
     btScansDevicesList_.sort(CompBuletoothInfo);\r
 }\r
 \r
+//重置设备名称\r
 void BluetoothModel::ResetScanDevicesCase(const BluetoothCaseInfo& caseInfo)\r
 {\r
     for (auto it = btScansDevicesList_.begin(); it != btScansDevicesList_.end(); it++) {\r
@@ -353,7 +363,7 @@ void BluetoothModel::ResetScanDevicesCase(const BluetoothCaseInfo& caseInfo)
     }\r
 }\r
 \r
-/* 已配对设备队列 */\r
+/* 清空已配对设备队列 */\r
 void BluetoothModel::SetConnedDevicesListClear()\r
 {\r
     btConnedDevicesList_->Clear();\r
@@ -526,18 +536,16 @@ bool BluetoothModel::IsTagDisconnectView(void)
     return tagDisconnectView;\r
 }\r
 \r
-void BluetoothModel::SetTagConnectNew(bool tag)\r
-{\r
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothModel::SetTagConnectNew:%d", tag);\r
-    tagConnectNew = tag;\r
-}\r
 \r
+\r
+//设置是否返回到已连接过的设备列表视图标志\r
 void BluetoothModel::SetTagReturnToDeviceListView(bool tag)\r
 {\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothModel::SetTagReturnToDeviceListView:%d", tag);\r
     tagReturnToDeviceListView = tag;\r
 }\r
 \r
+//是否返回到已连接过的设备列表视图\r
 bool BluetoothModel::IsTagReturnToDeviceListView(void)\r
 {\r
     return tagReturnToDeviceListView;\r
@@ -549,6 +557,13 @@ bool BluetoothModel::IsTagConnectNew(void)
     return tagConnectNew;\r
 }\r
 \r
+// 获取断开连接时是否需要马上连接新设备\r
+void BluetoothModel::SetTagConnectNew(bool tag)\r
+{\r
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothModel::SetTagConnectNew:%d", tag);\r
+    tagConnectNew = tag;\r
+}\r
+\r
 void BluetoothModel::SetTagScanDeviceClicked(bool tag)\r
 {\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothModel::SetTagScanDeviceClicked:%d", tag);\r
@@ -869,6 +884,7 @@ void HandleBeforeChangeView()
     }\r
 }\r
 \r
+//处理蓝牙耳机连接成功操作\r
 static void ACLConnectionSuss(const bd_addr_t &bdAddr)\r
 {\r
     // 判断是否已退出蓝牙模块(无需跳转)\r
@@ -894,7 +910,7 @@ static void ACLConnectionSuss(const bd_addr_t &bdAddr)
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainBluetoothView GetInstance fail");\r
             return;\r
         }\r
-        mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), TIPSSUCCMESSAGEVIEW);\r
+        mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), TIPSSUCCMESSAGEVIEW);//跳转到连接成功视图\r
     }\r
     TipsSuccMessageView *tipsSuccMessageView = TipsSuccMessageView::GetInstance();\r
     if (tipsSuccMessageView == nullptr) {\r
@@ -902,8 +918,16 @@ static void ACLConnectionSuss(const bd_addr_t &bdAddr)
         return;\r
     }\r
     tipsSuccMessageView->RefreshNameLabel(bdAddr);\r
+    /* -------------------------------------------------------------------------- */\r
+    if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))\r
+    {\r
+        ui_api_vibrate_once_func();\r
+    }\r
+    ScreenTurnOn(5*1000);\r
+    /* -------------------------------------------------------------------------- */\r
 }\r
 \r
+//处理蓝牙耳机连接失败操作\r
 static void ACLConnectionFail(const bd_addr_t &bdAddr)\r
 {\r
     // 判断是否已退出蓝牙模块(无需跳转)\r
@@ -939,8 +963,16 @@ static void ACLConnectionFail(const bd_addr_t &bdAddr)
         return;\r
     }\r
     tipsConnFailMessageView->RefreshNameLabel(bdAddr);\r
+    /* -------------------------------------------------------------------------- */\r
+    if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))\r
+    {\r
+        ui_api_vibrate_once_func();\r
+    }\r
+    ScreenTurnOn(5*1000);\r
+    /* -------------------------------------------------------------------------- */\r
 }\r
 \r
+//处理断开蓝牙耳机连接\r
 static void DisconnectedHandle()\r
 {\r
     BluetoothModel::GetInstance()->SetTagDisconnectView(false);\r
@@ -955,12 +987,12 @@ static void DisconnectedHandle()
         return;\r
     }\r
     deviceList->RefreshList();\r
-    BluetoothOptionsView *bluetoothOptionsView = BluetoothOptionsView::GetInstance();\r
-    if (bluetoothOptionsView == nullptr) {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AclStateChangedCallback bluetoothOptionsView  == nullptr");\r
-        return;\r
-    }\r
-    bluetoothOptionsView->RefreshText();\r
+    // BluetoothOptionsView *bluetoothOptionsView = BluetoothOptionsView::GetInstance();\r
+    // if (bluetoothOptionsView == nullptr) {\r
+    //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AclStateChangedCallback bluetoothOptionsView  == nullptr");\r
+    //     return;\r
+    // }\r
+    // bluetoothOptionsView->RefreshText();\r
 }\r
 \r
 void BluetoothModel::BtGapAclStateChangedHandle(gap_acl_state_t state, unsigned int reason, const bd_addr_t &bdAddr)\r
index f4c0c12..c11059f 100644 (file)
@@ -94,6 +94,9 @@ namespace OHOS
         titleLabel->SetTextId(STR_BLUETOOTH_HEADPHONES); /*蓝牙耳机*/\r
         titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);\r
         titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+        titleLabel->SetStyle(STYLE_TEXT_FONT,30);\r
+        titleLabel->SetStyle(STYLE_LINE_HEIGHT,35);\r
+        titleLabel->SetRollSpeed(70);\r
         titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
         /* --------------------------- EarPhoneDeviceName --------------------------- */\r
         if (EarPhoneDeviceName == nullptr)\r
index 878c2e2..9d6b02e 100644 (file)
@@ -70,6 +70,7 @@ void BluetoothPresenter::ClickNewEquipmentButton(void)
     view_->ChangeView(BLUETOOTHDEVICELISTVIEW, BLUETOOTHEARPHONEVIEW);\r
 }\r
 \r
+//点击取消连接按钮\r
 void BluetoothPresenter::ClickCancelConnedRequestButton(void)\r
 {\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothPresenter::OnClick BLUETOOTH_CANCELCONNEDREQUEST_BUTTON");\r
@@ -106,6 +107,7 @@ void BluetoothPresenter::ClickCancelConnedRequestButton(void)
     RootView::GetInstance()->Invalidate();\r
 }\r
 \r
+//点击取消配对\r
 void BluetoothPresenter::ClickUnpairButton(void)\r
 {\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothPresenter::OnClick BLUETOOTH_UNPAIR_BUTTON");\r
@@ -200,21 +202,21 @@ bool BluetoothPresenter::OnClick(UIView &view, const ClickEvent &event)
 {\r
     UNUSED(event);\r
     if (strcmp(view.GetViewId(), BLUETOOTH_RESCAN_BUTTON) == 0) {\r
-        ClickRescanButton();\r
+        ClickRescanButton();//扫描出的耳机列表界面中的[重新扫描按钮]被点击\r
     } else if (strcmp(view.GetViewId(), BLUETOOTH_NEWEQUIPMENT_BUTTON) == 0) {\r
-        ClickNewEquipmentButton();\r
+        ClickNewEquipmentButton();//已连接设备列表界面中的[重新扫描按钮]被点击\r
     } else if (strcmp(view.GetViewId(), BLUETOOTH_CANCELCONNEDREQUEST_BUTTON) == 0) {\r
         ClickCancelConnedRequestButton();\r
     } else if (strcmp(view.GetViewId(), BLUETOOTH_UNPAIR_BUTTON) == 0) {\r
-        ClickUnpairButton();\r
+        ClickUnpairButton();//查看已连接的蓝牙耳机设备界面的[取消配对按]钮被点击\r
     } else if (strcmp(view.GetViewId(), BLUETOOTH_OPTIONONE_BUTTON) == 0) {\r
         ClickOptionsOneButton();\r
     } else if (strcmp(view.GetViewId(), BLUETOOTH_SUCC_BACK_BUTTON) == 0) {\r
-        ClickSuccBackButton();\r
+        ClickSuccBackButton();//点击连接成功的确定按钮\r
     } else if (strcmp(view.GetViewId(), BLUETOOTH_FAIL_BACK_BUTTON) == 0) {\r
-        ClickFailBackButton();\r
+        ClickFailBackButton(); //点击重新搜索按钮\r
     } else if (strcmp(view.GetViewId(), BLUETOOTH_CONN_FAIL_BACK_BUTTON) == 0) {\r
-        ClickConnfailBackButton();\r
+        ClickConnfailBackButton();//连接失败的重试按钮\r
     }\r
     return true;\r
 }\r
index ad23342..779a1ab 100644 (file)
 #include "PlayersPresenter.h"\r
 #include "BluetoothPresenter.h"\r
 #include "common/image_cache_manager.h"\r
-\r
+#include "uicomponents/UIComponents.h"\r
+#include <custom_utils.h>\r
+#include "graphic_service.h"\r
+#include <ui_service.h>\r
 namespace OHOS {\r
 static BluetoothReconnectView *g_pBluetoothReconnectView{nullptr};\r
-#define BLUETOOTH_IMAGE_X 175\r
-#define BLUETOOTH_IMAGE_Y 125\r
-#define BLUETOOTH_IMAGE_WIDTH 104\r
-#define BLUETOOTH_IMAGE_HEIGHT 104\r
-#define BLUETOOTH_DELAY 200\r
-\r
+#define BLUETOOTH_IMAGE_X 183\r
+#define BLUETOOTH_IMAGE_Y 153\r
+#define BLUETOOTH_IMAGE_WIDTH 100\r
+#define BLUETOOTH_IMAGE_HEIGHT 120\r
+#define BLUETOOTH_DELAY 50\r
+static constexpr const char *reconnectImagePaths = "/user/res/connect/";\r
+osTimerId_t g_stopConnectHandle = nullptr;\r
+static constexpr uint64_t MS_CONN_TIME = 15000;\r
 BluetoothReconnectView::BluetoothReconnectView()\r
 {\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothReconnectView::BluetoothReconnectView");\r
@@ -29,22 +34,29 @@ BluetoothReconnectView::BluetoothReconnectView()
 BluetoothReconnectView::~BluetoothReconnectView()\r
 {\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothReconnectView::~BluetoothReconnectView");\r
-    group->RemoveAll();\r
-    delete titleLabel;\r
-    titleLabel = nullptr;\r
-    delete bluetoothNameLabel;\r
-    bluetoothNameLabel = nullptr;\r
-    delete reconnectAnimator;\r
-    reconnectAnimator = nullptr;\r
-    delete group;\r
-    group = nullptr;\r
+    if(group){\r
+        group->RemoveAll();\r
+        if(titleLabel){\r
+            delete titleLabel;\r
+            titleLabel = nullptr;\r
+        }\r
+        if(bluetoothNameLabel){\r
+            delete bluetoothNameLabel;\r
+            bluetoothNameLabel = nullptr;\r
+        }\r
+        if(reconnectAnimator){\r
+            delete reconnectAnimator;\r
+            reconnectAnimator = nullptr;\r
+            FreeImageInfoArray(reconnectPathsArray, reconnectImagePaths, BLUETOOTH_RECONNECT_IMAGE_NUM);\r
+        }\r
+        delete group;\r
+        group = nullptr;\r
+    }\r
+    stop_connect_timer();\r
     g_pBluetoothReconnectView = nullptr;\r
 }\r
 \r
-bd_addr_t BluetoothReconnectView::GetcurrentBdAddr(void)\r
-{\r
-    return currentBdAddr;\r
-}\r
+\r
 \r
 BluetoothReconnectView *BluetoothReconnectView::GetInstance()\r
 {\r
@@ -65,6 +77,7 @@ void BluetoothReconnectView::ShowUpTitleLabel()
         titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_FORTY_SIZE);\r
         titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);\r
         titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);\r
+        titleLabel->SetVisible(false);\r
         group->Add(titleLabel);\r
     }\r
     if (bluetoothNameLabel == nullptr) {\r
@@ -80,20 +93,11 @@ void BluetoothReconnectView::ShowUpTitleLabel()
         bluetoothNameLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_THIRTY_SIZE);\r
         bluetoothNameLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE);\r
         bluetoothNameLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);\r
+        bluetoothNameLabel->SetVisible(false);\r
         group->Add(bluetoothNameLabel);\r
     }\r
 }\r
 \r
-void BluetoothReconnectView::BtReconnectStart(void)\r
-{\r
-    reconnectAnimator->Start();\r
-}\r
-\r
-void BluetoothReconnectView::BtReconnectStop(void)\r
-{\r
-    reconnectAnimator->Stop();\r
-}\r
-\r
 UIViewGroup *BluetoothReconnectView::InitShowUpView()\r
 {\r
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothReconnectView init");\r
@@ -115,10 +119,11 @@ UIViewGroup *BluetoothReconnectView::InitShowUpView()
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "reDragListener GetInstance fail");\r
         return nullptr;\r
     }\r
+    /* ------------------------------ 连接过程动画不能右滑退出 ------------------------------ */\r
     if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) {\r
-        group->SetOnDragListener(reDragListener);\r
+        // group->SetOnDragListener(reDragListener);\r
     } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) {\r
-        group->SetOnDragListener(reDragListener2);\r
+        // group->SetOnDragListener(reDragListener2);\r
     }\r
     group->SetViewId(BLUETOOTH_RECONNECT_VIEW);\r
     group->SetDraggable(true);\r
@@ -140,6 +145,7 @@ void BluetoothReconnectView::RefreshBluetoothNameLabel()
 \r
 void BluetoothReconnectView::BtReconnectImageAnimator()\r
 {\r
+#if 0\r
     const char *reconnectImagePath[BLUETOOTH_RECONNECT_IMAGE_NUM] = {\r
         PNG_A019_080_IMAGE_PATH,\r
         PNG_A019_081_IMAGE_PATH,\r
@@ -169,6 +175,130 @@ void BluetoothReconnectView::BtReconnectImageAnimator()
         reconnectAnimator->SetRepeat(true);\r
         group->Add(reconnectAnimator);\r
     }\r
+#endif\r
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BtScanImageAnimator init");\r
+    reconnectPathsArray = CreateImageInfoArray(reconnectImagePaths, BLUETOOTH_RECONNECT_IMAGE_NUM);\r
+    if (reconnectAnimator == nullptr)\r
+    {\r
+        reconnectAnimator = new UIImageAnimatorView();\r
+        if (reconnectAnimator == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "reconnectAnimator new fail");\r
+            return;\r
+        }\r
+        for (uint8_t i = 0; i < BLUETOOTH_RECONNECT_IMAGE_NUM; i++)\r
+        {\r
+            reconnetImageInfo[i].imageInfo = (reconnectPathsArray[i]);\r
+            reconnetImageInfo[i].imageType = IMG_SRC_IMAGE_INFO;\r
+            reconnetImageInfo[i].pos.x = BLUETOOTH_IMAGE_X;\r
+            reconnetImageInfo[i].pos.y = BLUETOOTH_IMAGE_Y;\r
+            reconnetImageInfo[i].width = BLUETOOTH_IMAGE_WIDTH;\r
+            reconnetImageInfo[i].height = BLUETOOTH_IMAGE_HEIGHT;\r
+        }\r
+        reconnectAnimator->SetPosition(BLUETOOTH_IMAGE_X, BLUETOOTH_IMAGE_Y, BLUETOOTH_IMAGE_WIDTH, BLUETOOTH_IMAGE_HEIGHT);\r
+        reconnectAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
+        reconnectAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
+        reconnectAnimator->SetImageAnimatorSrc(reconnetImageInfo, BLUETOOTH_RECONNECT_IMAGE_NUM, BLUETOOTH_DELAY);\r
+        reconnectAnimator->SetRepeat(true);\r
+        reconnectAnimator->SetSizeFixed(true);\r
+        group->Add(reconnectAnimator);\r
+    }\r
 }\r
 \r
+bd_addr_t BluetoothReconnectView::GetcurrentBdAddr(void)\r
+{\r
+    return currentBdAddr;\r
+}\r
+\r
+void BluetoothReconnectView::BtReconnectStart(void)\r
+{\r
+    // ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); //动画启动,常亮屏\r
+    ScreenTurnOn(20*1000);\r
+    reconnectAnimator->Start();\r
+    start_connect_timer();\r
+}\r
+\r
+void BluetoothReconnectView::BtReconnectStop(void)\r
+{\r
+    /* ---------------------------------- 取消定时器 --------------------------------- */\r
+    // ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON);//动画停止,取消常亮屏\r
+    reconnectAnimator->Stop();\r
+    stop_connect_timer();\r
+}\r
+\r
+// 定时器回调函数\r
+static void ConnectTimerCallbackProc(int data)\r
+{\r
+    (void)data;\r
+    \r
+    MainBluetoothView *mainBluetoothView = MainBluetoothView::GetInstance();\r
+    if (mainBluetoothView == nullptr) {\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainBluetoothView GetInstance fail");\r
+        return;\r
+    }\r
+    mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), TIPSCONNFAILMESSAGEVIEW);\r
+\r
+    TipsConnFailMessageView *tipsConnFailMessageView = TipsConnFailMessageView::GetInstance();\r
+    if (tipsConnFailMessageView == nullptr) {\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ACLConnectionFail tipsConnFailMessageView GetInstance fail");\r
+        return;\r
+    }\r
+    BluetoothCaseInfo *bluetoothInfo_= BluetoothModel::GetInstance()->GetTempMacValue();\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "device name = %s",bluetoothInfo_->deviceName);\r
+    bd_addr_t addr;\r
+    (void)memcpy_s(addr.addr, BD_ADDR_LEN, bluetoothInfo_->addr, BD_ADDR_LEN);\r
+    tipsConnFailMessageView->RefreshNameLabel(addr);\r
+}\r
+\r
+static void ConnectTimerCallback(int data)\r
+{\r
+    GraphicService::GetInstance()->PostGraphicEvent(std::bind(ConnectTimerCallbackProc, data));\r
+}\r
+//开启第一个重连动画的定时器\r
+void BluetoothReconnectView::start_connect_timer()\r
+{\r
+    /*开启定时器*/\r
+    if (g_stopConnectHandle != nullptr)\r
+    {\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable g_stopConnectHandle != nullptr");\r
+        return;\r
+    }\r
+    g_stopConnectHandle = osTimerNew((osTimerFunc_t)ConnectTimerCallback, osTimerPeriodic, nullptr, nullptr);\r
+    if (g_stopConnectHandle == nullptr)\r
+    {\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable osTimerNew failed!!");\r
+        return;\r
+    }\r
+    uint32 tick = osMs2Tick(MS_CONN_TIME);\r
+    osStatus_t retTimer = osTimerStart(g_stopConnectHandle, tick);\r
+    if (retTimer != osOK)\r
+    {\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable osTimerStart failed, ret = %lx!!", retTimer);\r
+        if (g_stopConnectHandle != nullptr)\r
+        {\r
+            retTimer = osTimerDelete(g_stopConnectHandle);\r
+            if (retTimer != osOK)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView::BtEnable osTimerDelete  ret = %lx!!", retTimer);\r
+                return;\r
+            }\r
+            g_stopConnectHandle = nullptr;\r
+        }\r
+        return;\r
+    }\r
+}\r
+//停止定时器\r
+void BluetoothReconnectView::stop_connect_timer()\r
+{\r
+    if (g_stopConnectHandle != nullptr)\r
+    {\r
+        osStatus_t ret = osTimerDelete(g_stopConnectHandle);\r
+        if (ret != osOK)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScanTimerCallback osTimerDelete failed, ret = %lx!!", ret);\r
+            return;\r
+        }\r
+        g_stopConnectHandle = nullptr;\r
+    }\r
+}\r
 }
\ No newline at end of file
index 0013ba6..aa79652 100644 (file)
@@ -131,16 +131,19 @@ bool MainBluetoothView::ChangeBluetoothDeviceListView(int16_t hideView, int16_t
         }\r
         container[thisView] = group;\r
         RootView::GetInstance()->Add(container[thisView]);\r
-    } else {\r
-        // 刷新列表\r
-        UIList *deviceList = bluetoothDeviceListView->GetDeviceUIList();\r
-        if (deviceList == nullptr) {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick deviceList nullptr");\r
-            return false;\r
-        }\r
-        deviceList->RefreshList();\r
+    } \r
+    // else {\r
+    //     // 刷新列表\r
+    //     UIList *deviceList = bluetoothDeviceListView->GetDeviceUIList();\r
+    //     if (deviceList == nullptr) {\r
+    //         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick deviceList nullptr");\r
+    //         return false;\r
+    //     }\r
+    //     deviceList->RefreshList();\r
+    // }\r
+    if(bluetoothDeviceListView) {\r
+        bluetoothDeviceListView->RefreshBluetoothDeviceListView();\r
     }\r
-    bluetoothDeviceListView->RefreshBluetoothDeviceListView();\r
     return true;\r
 }\r
 \r
@@ -194,6 +197,7 @@ bool MainBluetoothView::ChangeTipsConnFailMessageView(int16_t hideView, int16_t
     return true;\r
 }\r
 \r
+//连接成功界面\r
 bool MainBluetoothView::ChangeTipsSuccMessageView(int16_t hideView, int16_t thisView)\r
 {\r
     UNUSED(hideView);\r
@@ -216,6 +220,7 @@ bool MainBluetoothView::ChangeTipsSuccMessageView(int16_t hideView, int16_t this
     return true;\r
 }\r
 \r
+//搜索界面\r
 bool MainBluetoothView::ChangeBluetoothEarPhoneView(int16_t hideView, int16_t thisView)\r
 {\r
     UNUSED(hideView);\r
@@ -241,6 +246,7 @@ bool MainBluetoothView::ChangeBluetoothEarPhoneView(int16_t hideView, int16_t th
     return true;\r
 }\r
 \r
+//扫描出来的设备列表界面\r
 bool MainBluetoothView::ChangeBluetoothEarListView(int16_t hideView, int16_t thisView)\r
 {\r
     if (container[thisView] == nullptr) {\r
@@ -257,16 +263,20 @@ bool MainBluetoothView::ChangeBluetoothEarListView(int16_t hideView, int16_t thi
         }\r
         container[thisView] = group;\r
         RootView::GetInstance()->Add(container[thisView]);\r
-    } else {\r
-        // 刷新列表\r
-        UIList *scanList = bluetoothEarListView->GetScanUIList();\r
-        if (scanList == nullptr) {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick scanList nullptr");\r
-            return false;\r
-        }\r
-        scanList->RefreshList();\r
+    } \r
+    // else {\r
+    //     // 刷新列表\r
+    //     UIList *scanList = bluetoothEarListView->GetScanUIList();\r
+    //     if (scanList == nullptr) {\r
+    //         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick scanList nullptr");\r
+    //         return false;\r
+    //     }\r
+    //     scanList->RefreshList();\r
+    // }\r
+    // ResetEarListView(hideView);\r
+    if(bluetoothEarListView) {\r
+        bluetoothEarListView->RefreshBluetoothEarListView();\r
     }\r
-    ResetEarListView(hideView);\r
     return true;\r
 }\r
 \r
@@ -292,6 +302,7 @@ bool MainBluetoothView::ChangeBluetoothOptionsView(int16_t hideView, int16_t thi
     return true;\r
 }\r
 \r
+//重新连接界面\r
 bool MainBluetoothView::ChangeBluetoothReconnectView(int16_t hideView, int16_t thisView)\r
 {\r
     UNUSED(hideView);\r
@@ -332,7 +343,7 @@ void MainBluetoothView::CorrespondingJump(int16_t hideView)
     //     std::list<BluetoothCaseInfo> &bluetoothScanList = BluetoothModel::GetInstance()->GetCase();\r
     //     bool ret = bluetoothScanList.empty();\r
     //     if (!ret) {\r
-    //         ChangeView(hideView, BLUETOOTHEARLISTVIEW);/*耳机列表界面*/\r
+    //         ChangeView(hideView, BLUETOOTHEARLISTVIEW);/*扫描出的耳机列表界面*/\r
     //     } else {\r
     //         ChangeView(hideView, BLUETOOTHEARPHONEVIEW);/*搜索界面*/\r
     //     }\r
@@ -359,9 +370,9 @@ void MainBluetoothView::DropEarPhoneView()
     bluetoothEarPhoneView->StopBtDiscovery();\r
     bool ret = BluetoothModel::GetInstance()->IsTagReturnToDeviceListView();\r
     if (ret) {\r
-        ChangeView(BLUETOOTHEARPHONEVIEW, BLUETOOTHDEVICELISTVIEW);\r
+        ChangeView(BLUETOOTHEARPHONEVIEW, BLUETOOTHDEVICELISTVIEW);//返回到已连接的设备列表界面\r
     } else {\r
-        ChangeSettingView();\r
+        ChangeSettingView(); //退出蓝牙耳机界面\r
     }\r
 }\r
 \r
@@ -393,32 +404,33 @@ void MainBluetoothView::DropEarListView()
 \r
 void MainBluetoothView::DropView(UIView& view)\r
 {\r
-    if (&view == container[BLUETOOTHEARPHONEVIEW]) {\r
+    if (&view == container[BLUETOOTHEARPHONEVIEW]) { \r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[BLUETOOTHEARPHONEVIEW]");\r
-        DropEarPhoneView();\r
+        DropEarPhoneView();//搜索界面右滑退出操作\r
     } else if (&view == container[BLUETOOTHEOPTIONSVIEW]) {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[BLUETOOTHEOPTIONSVIEW]");\r
-        ChangeView(BLUETOOTHEOPTIONSVIEW, BLUETOOTHDEVICELISTVIEW);\r
+        ChangeView(BLUETOOTHEOPTIONSVIEW, BLUETOOTHDEVICELISTVIEW);//查看已连接过的蓝牙耳机设备视图->已连接过的蓝牙耳机设备视图\r
     } else if (&view == container[TIPSCONNFAILMESSAGEVIEW]) {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[TIPSCONNFAILMESSAGEVIEW]");\r
-        CorrespondingJump(TIPSCONNFAILMESSAGEVIEW);\r
+        ChangeView(TIPSCONNFAILMESSAGEVIEW, BLUETOOTHDEVICELISTVIEW);/*连接失败的提示视图 ->已连接过的蓝牙耳机设备视图*/\r
     } else if (&view == container[TIPSSUCCMESSAGEVIEW]) {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[TIPSSUCCMESSAGEVIEW]");\r
-        ChangeView(TIPSSUCCMESSAGEVIEW, BLUETOOTHDEVICELISTVIEW);\r
+        ChangeView(TIPSSUCCMESSAGEVIEW, BLUETOOTHDEVICELISTVIEW);//连接成功的提示视图->已连接过的蓝牙设备列表视图\r
     } else if (&view == container[TIPSFAILMESSAGEVIEW]) {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[TIPSFAILMESSAGEVIEW]");\r
-        ChangeView(TIPSFAILMESSAGEVIEW, BLUETOOTHEARPHONEVIEW);\r
+        // ChangeView(TIPSFAILMESSAGEVIEW, BLUETOOTHEARPHONEVIEW);//未搜索到蓝牙耳机界面->搜索界面\r
+        ChangeSettingView();//未搜索到蓝牙耳机界面->退出蓝牙耳机界面\r
     } else if (&view == container[BLUETOOTHEARLISTVIEW]) {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[BLUETOOTHEARLISTVIEW]");\r
         DropEarListView();\r
     } else if (&view == container[BLUETOOTHDEVICELISTVIEW]) {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[BLUETOOTHDEVICELISTVIEW]");\r
-        ChangeSettingView();\r
+        ChangeSettingView();//已连接过的蓝牙设备列表视图 -> 退出蓝牙耳机界面\r
     } else if (&view == container[BLUETOOTHRECONNECTVIEW]) {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::DropView::container[BLUETOOTHRECONNECTVIEW]");\r
         BluetoothModel::GetInstance()->SetTagDisconnectView(false);\r
-        bluetoothReconnectView->BtReconnectStop();/*先停止动画在视图跳转*/\r
         CorrespondingJump(BLUETOOTHRECONNECTVIEW);\r
+        bluetoothReconnectView->BtReconnectStop();/*停止动画*/\r
     }\r
 }\r
 \r
index 552f968..7053406 100644 (file)
@@ -184,6 +184,7 @@ UIViewGroup *TipsConnFailMessageView::ShowUpViewInit(void)
     return group;\r
 }\r
 \r
+//刷新设备名称\r
 void TipsConnFailMessageView::RefreshNameLabel(const bd_addr_t &bdAddr)\r
 {\r
     BluetoothCaseInfo caseInfo;\r
index 9bab50f..b551ed3 100644 (file)
@@ -144,6 +144,7 @@ UIViewGroup *TipsSuccMessageView::ShowUpViewInit(void)
     return group;\r
 }\r
 \r
+//刷新设备名称\r
 void TipsSuccMessageView::RefreshNameLabel(const bd_addr_t &bdAddr)\r
 {\r
     BluetoothCaseInfo caseInfo;\r