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