From: luozheng <1732036298@qq.com> Date: Wed, 14 Aug 2024 10:33:05 +0000 (+0800) Subject: 蓝牙耳机界面中“蓝牙耳机设备未找到视图”优化修改。 X-Git-Tag: release_V1.2.70_20241020_135402~638^2~5^2~18 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=04730f786854533a6b8e2b6577b7c3f760da4677;p=mirrors%2FFD230.git 蓝牙耳机界面中“蓝牙耳机设备未找到视图”优化修改。 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/TipsFailMessageView.h b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/TipsFailMessageView.h index b99dba6a8..000cc6b42 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/TipsFailMessageView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/TipsFailMessageView.h @@ -1,31 +1,42 @@ /* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: TipsFailMessageView 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-14 17:36:25 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/TipsFailMessageView.h */ + #ifndef TIPS_FAIL_MESSAGE_VIEW_H #define TIPS_FAIL_MESSAGE_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_image_view.h" -namespace OHOS { -class TipsFailMessageView { -public: - TipsFailMessageView(); - ~TipsFailMessageView(); - static TipsFailMessageView *GetInstance(); - UIViewGroup *ShowUpViewInit(void); -private: - int ShowUpButtonBack(void); - UILabel *titleLabel{nullptr}; - UILabelButton *backButton{nullptr}; - UIImageView *tipImg{nullptr}; - UIViewGroup *group{nullptr}; -}; +namespace OHOS +{ + /*蓝牙设备搜索不到视图*/ + class TipsFailMessageView + { + public: + TipsFailMessageView(); + ~TipsFailMessageView(); + static TipsFailMessageView *GetInstance(); + UIViewGroup *CreateTipsFailMessageView(void); + + private: + bool CreateTipsFailMessageLabelView(void); + bool CreateTipsFailMessageLabelButton(void); + bool CreateTipsFailMessageImageView(void); + + int ShowUpButtonBack(void); + UIViewGroup *group{nullptr}; + UILabelExt *titleLabel{nullptr}; /*标题:蓝牙耳机 */ + UIImageView *btIconImage{nullptr}; /*灰色的蓝牙图标*/ + UILabelExt *btHeadsetNotFoundLabel{nullptr}; /*当前搜索不到耳机蓝牙设备*/ + UILabelButtonExt *rescanButton{nullptr}; /*重新搜索按钮*/ + }; } // namespace OHOS #endif // TIPS_FAIL_MESSAGE_VIEW_H \ 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 3c6aa8cac..3c641a141 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/MainBluetoothView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/MainBluetoothView.cpp @@ -155,7 +155,7 @@ bool MainBluetoothView::ChangeTipsFailMessageView(int16_t hideView, int16_t this return false; } // init view - UIViewGroup *group = tipsFailMessageView->ShowUpViewInit(); + UIViewGroup *group = tipsFailMessageView->CreateTipsFailMessageView(); if (group == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); return false; diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/TipsFailMessageView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/TipsFailMessageView.cpp index 4d732b85d..56222c913 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/TipsFailMessageView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/TipsFailMessageView.cpp @@ -8,120 +8,205 @@ #include "BluetoothModel.h" #include "wearable_log.h" #include "UiConfig.h" -#include "PlayersPresenter.h" -#include "BluetoothPresenter.h" +#include "player/include/PlayersPresenter.h" +#include "player/include/PlayersView.h" +#include "bluetooth/include/BluetoothPresenter.h" +#include "ui_resource_string.h" +#include "ui_resource_image.h" -namespace OHOS { -static TipsFailMessageView *g_pFailMessageView{nullptr}; -TipsFailMessageView::TipsFailMessageView() +namespace OHOS { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView::TipsFailMessageView"); - g_pFailMessageView = this; -} + static TipsFailMessageView *g_pFailMessageView{nullptr}; + TipsFailMessageView::TipsFailMessageView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView::TipsFailMessageView"); + g_pFailMessageView = this; + } -TipsFailMessageView::~TipsFailMessageView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView::~TipsFailMessageView"); - group->RemoveAll(); - delete titleLabel; - titleLabel = nullptr; - delete backButton; - backButton = nullptr; - delete group; - group = nullptr; - delete tipImg; - tipImg = nullptr; - g_pFailMessageView = nullptr; -} + TipsFailMessageView::~TipsFailMessageView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView::~TipsFailMessageView"); + if (group != nullptr) + { + group->RemoveAll(); + if (titleLabel) + { + delete titleLabel; + titleLabel = nullptr; + } + if (btIconImage) + { + delete btIconImage; + btIconImage = nullptr; + ImageCacheManager::GetInstance().UnloadOneInMultiRes(PLAYER_BLUETOOTH_GRAY, PLAYER_IAMGES); + } + if (btHeadsetNotFoundLabel) + { + delete btHeadsetNotFoundLabel; + btHeadsetNotFoundLabel = nullptr; + } + if (rescanButton) + { + delete rescanButton; + rescanButton = nullptr; + } + delete group; + group = nullptr; + } + g_pFailMessageView = nullptr; + } -TipsFailMessageView *TipsFailMessageView::GetInstance() -{ - return g_pFailMessageView; -} + TipsFailMessageView *TipsFailMessageView::GetInstance() + { + return g_pFailMessageView; + } -int TipsFailMessageView::ShowUpButtonBack() -{ - if (backButton == nullptr) { - backButton = new UILabelButton(); - if (backButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView backButton new fail"); - return OHOS_FAILURE; + bool TipsFailMessageView::CreateTipsFailMessageLabelView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView::CreateTipsFailMessageLabelView"); + /* ------------------------------- titleLabel ------------------------------- */ + if (titleLabel == nullptr) + { + titleLabel = new UILabelExt(); + if (titleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel new fail"); + return false; + } } - 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 OHOS_FAILURE; + titleLabel->SetPosition(83, 50, 300, 35); + titleLabel->SetStyle(STYLE_TEXT_FONT, 30); + titleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + titleLabel->SetTextId(STR_BLUETOOTH_HEADPHONES); /*蓝牙耳机*/ + titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ------------------------- btHeadsetNotFoundLabel ------------------------- */ + if (btHeadsetNotFoundLabel == nullptr) + { + btHeadsetNotFoundLabel = new UILabelExt(); + if (btHeadsetNotFoundLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel new fail"); + return false; + } } - backButton->SetPosition(65, 359, 324, 101); // 65:x, 359:y, 324:width 101:height - backButton->SetText("重试"); - backButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40:font data - backButton->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE); - backButton->SetViewId(BLUETOOTH_FAIL_BACK_BUTTON); - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - backButton->SetTextColor(Color::Red()); - backButton->SetOnClickListener(clickListener); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - backButton->SetTextColor(Color::Blue()); - backButton->SetOnClickListener(clickListener2); + btHeadsetNotFoundLabel->SetPosition(53, 305, 360, 30); + btHeadsetNotFoundLabel->SetStyle(STYLE_TEXT_FONT, 26); + btHeadsetNotFoundLabel->SetStyle(STYLE_LINE_HEIGHT, 30); + btHeadsetNotFoundLabel->SetTextId(STR_BT_HEADSET_NOFOND); /*当前搜索不到耳机蓝牙设备*/ + btHeadsetNotFoundLabel->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + btHeadsetNotFoundLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + btHeadsetNotFoundLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + btHeadsetNotFoundLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + + return true; + } + + bool TipsFailMessageView::CreateTipsFailMessageImageView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView::CreateTipsFailMessageImageView"); + if (btIconImage == nullptr) + { + btIconImage = new UIImageView(); + if (btIconImage == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); + return false; + } + btIconImage->SetPosition(163, 126, 140, 140); + btIconImage->SetAutoEnable(false); + btIconImage->SetResizeMode(UIImageView::CENTER); + if (!PlayersView::LoadPlayerImage(btIconImage, PLAYER_BLUETOOTH_GRAY)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneImage LoadPlayerImage fail"); + return false; + } } - group->Add(backButton); + return true; } - if (tipImg == nullptr) { - tipImg = new UIImageView(); - if (tipImg == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView tipImg new fail"); - return OHOS_FAILURE; + + bool TipsFailMessageView::CreateTipsFailMessageLabelButton() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView::CreateTipsFailMessageLabelButton"); + if (rescanButton == nullptr) + { + rescanButton = new UILabelButtonExt(); + if (rescanButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView rescanButton new fail"); + return false; + } + 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 false; + } + rescanButton->SetPosition(73, 350, 320, 100); + rescanButton->SetTextId(STR_BT_HEADSET_RESCAN); /*重新搜索*/ + rescanButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + rescanButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + rescanButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + rescanButton->SetViewId(BLUETOOTH_FAIL_BACK_BUTTON); + rescanButton->SetTextColor(Color::GetColorFromRGBA(0x35, 0x49, 0xff, 0xff)); + rescanButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) + { + rescanButton->SetOnClickListener(clickListener); + } + else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) + { + rescanButton->SetOnClickListener(clickListener2); + } } - tipImg->SetPosition(181, 111, 90, 90); // 181:x 111:y 90:width 90:height - tipImg->SetSrc(PNG_GANTAN); - group->Add(tipImg); + return true; } - return OHOS_SUCCESS; -} -UIViewGroup *TipsFailMessageView::ShowUpViewInit(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView::ShowUpViewInit"); - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); + UIViewGroup *TipsFailMessageView::CreateTipsFailMessageView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView::CreateTipsFailMessageView"); + if (group == nullptr) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); + return nullptr; + } + group->SetPosition(0, 0, 466, 466); + } + UIView::OnDragListener *tipsDragListener = (UIView::OnDragListener *)OHOS::PlayerOnDragListener::GetInstance(); + UIView::OnDragListener *tipsDragListener2 = (UIView::OnDragListener *)OHOS::BluetoothPresenter::GetInstance(); + if ((tipsDragListener == nullptr) && (tipsDragListener2 == nullptr)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "tipsDragListener GetInstance 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, "TipsFailMessageView titleLabel new fail"); + if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) + { + group->SetOnDragListener(tipsDragListener); + } + else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) + { + group->SetOnDragListener(tipsDragListener2); + } + group->SetViewId(TIPS_FAIL_MESSAGE_VIEW); + group->SetDraggable(true); + group->SetTouchable(true); + /* -------------------------------------------------------------------------- */ + if (!CreateTipsFailMessageLabelView() || !CreateTipsFailMessageImageView() || !CreateTipsFailMessageLabelButton()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TipsFailMessageView::CreateTipsFailMessageView fail!!"); return nullptr; } - titleLabel->SetPosition(0, 234, HORIZONTAL_RESOLUTION, 45); // 0:x 234:y 454:width 45:height - titleLabel->SetText("未发现蓝牙耳机"); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); // 40:font data - titleLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - titleLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); + /* ----------------------------------- Add ---------------------------------- */ group->Add(titleLabel); + group->Add(btIconImage); + group->Add(btHeadsetNotFoundLabel); + group->Add(rescanButton); + /* -------------------------------------------------------------------------- */ + return group; } - ShowUpButtonBack(); - UIView::OnDragListener *tipsDragListener = (UIView::OnDragListener *)OHOS::PlayerOnDragListener::GetInstance(); - UIView::OnDragListener *tipsDragListener2 = (UIView::OnDragListener *)OHOS::BluetoothPresenter::GetInstance(); - if ((tipsDragListener == nullptr) && (tipsDragListener2 == nullptr)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "tipsDragListener GetInstance fail"); - return nullptr; - } - if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERPLAYERS) { - group->SetOnDragListener(tipsDragListener); - } else if (BluetoothModel::GetInstance()->GetBluetoothCalleridStatus() == CALLERSETTING) { - group->SetOnDragListener(tipsDragListener2); - } - group->SetViewId(TIPS_FAIL_MESSAGE_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h index 28bf93cf8..d8b5f973a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-05 15:20:03 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-13 16:11:48 + * @LastEditTime: 2024-08-14 11:26:39 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h */ @@ -100,6 +100,7 @@ namespace OHOS void UpdatePlayerView(bool musicSourceType, bool phoneMusicConnectStatus); void UpdateMusicListStatus(void); + void OnClickBackKeyToMainMusicPlayerView(void); VolumeSettingView *GetVolumeSettingView(); PlayerListDelSongView *GetPlayerListDelSongView(); @@ -113,6 +114,7 @@ namespace OHOS bool ChangeToMusicDeleteView(int16_t thisView); bool ChangeToMusicBluetoothDisConnectView(int16_t thisView); bool ChangeToMusicBluetoothConnectFailedView(int16_t thisView); + bool ChangeToMusicConnectingView(int16_t thisView); private: UIButton *PlayerViewButtonInit(ButtonConfig &buttonconfig); 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 b6ddbeae1..32fbe7540 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp @@ -338,7 +338,7 @@ bool JumpView::ChangeTipsFailMessageView(int16_t hideView, int16_t thisView) return false; } // init view - UIViewGroup *group = tipsFailMessageView->ShowUpViewInit(); + UIViewGroup *group = tipsFailMessageView->CreateTipsFailMessageView(); if (group == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); return false; diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp index 443ba94d3..6cde8c3ad 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp @@ -882,6 +882,34 @@ namespace OHOS } } + /*点击返回键回到音乐主视图*/ + void PlayersView::OnClickBackKeyToMainMusicPlayerView(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PlayersView::OnClickBackKeyToMainMusicPlayerView"); + int index = 0; + for (int i = MAIN_MUSICPLAYER_VIEW; i < MUSICPLAYERJUMPVIEWID_MAX; i++) + { + if (group[i] != nullptr) + { + if (group[index]->IsVisible() == true) + { + index = i; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group[%d] IsVisible ", index); + break; + } + } + else + { + continue; + } + } + if (index == MAIN_MUSICPLAYER_VIEW) /*如果是音乐主视图是可见的不做ChangeView*/ + { + return; + } + ChangeView(index, MAIN_MUSICPLAYER_VIEW); + } + /*刷新播放器界面的组件状态*/ void PlayersView::UpdatePlayerView(bool musicSourceType, bool phoneMusicConnectStatus) { @@ -1407,4 +1435,28 @@ namespace OHOS } return true; } + + /*切换到蓝牙未连接视图*/ + bool PlayersView::ChangeToMusicConnectingView(int16_t thisView) + { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PlayersView::ChangeToMusicBluetoothConnectFailedView"); + // if (group[thisView] == nullptr) + // { + // musicPlayerBTConnectFailedView = new MusicPlayerBTConnectFailedView(); + // if (musicPlayerBTConnectFailedView == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new playerListDelSongView fail"); + // return false; + // } + // UIViewGroup *groupview = musicPlayerBTConnectFailedView->CreateMusicPlayerBTConnectFailedView(); + // if (groupview == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new group[%d] fail", thisView); + // return false; + // } + // group[thisView] = groupview; + // Add(group[thisView]); + // } + return true; + } }