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