From 0de85cd8f3100243ccc68350c2e47a2c51ee44ce Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Sat, 19 Oct 2024 15:52:07 +0800 Subject: [PATCH] =?utf8?q?=E5=9C=A8=E6=92=AD=E6=94=BE=E6=89=8B=E6=9C=BA?= =?utf8?q?=E9=9F=B3=E4=B9=90=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E5=A6=82?= =?utf8?q?=E6=9E=9C=E6=83=B3=E5=AF=B9=E6=9C=AC=E5=9C=B0=E9=9F=B3=E4=B9=90?= =?utf8?q?=E6=93=8D=E4=BD=9C=E8=BF=99=E6=97=B6=E5=BC=B9=E7=AA=97=E6=8F=90?= =?utf8?q?=E7=A4=BA=EF=BC=8C=E4=B8=8D=E8=83=BD=E5=AF=B9=E6=9C=AC=E5=9C=B0?= =?utf8?q?=E9=9F=B3=E4=B9=90=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 1 + .../player/include/MusicPlayerTipView.h | 36 ++++ .../player/include/PlayersPresenter.h | 4 +- .../nativeui/player/include/PlayersView.h | 6 +- .../src/MusicPlayerBTConnectFailedView.cpp | 7 +- .../src/MusicPlayerBluetoothDisConView.cpp | 12 +- .../player/src/MusicPlayerTipView.cpp | 202 ++++++++++++++++++ .../player/src/PlayersCaseListAdapter.cpp | 7 + .../nativeui/player/src/PlayersPresenter.cpp | 66 +++++- .../nativeui/player/src/PlayersView.cpp | 24 +++ 10 files changed, 352 insertions(+), 13 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerTipView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerTipView.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 313edede6..d3cbb6285 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -257,6 +257,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/player/src/PlayersCaseListAdapter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/player/src/PlayerListDelSongView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/player/src/PlayerListitemView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/player/src/MusicPlayerTipView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/activity/src/MainActivityView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/activity/src/ActivityWeekView.cpp diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerTipView.h b/code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerTipView.h new file mode 100644 index 000000000..eea1b9bb4 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerTipView.h @@ -0,0 +1,36 @@ +#ifndef __MUSIC_PLAYER_TIP_VIEW_H__ +#define __MUSIC_PLAYER_TIP_VIEW_H__ + +#include "components/ui_label_ext.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +namespace OHOS +{ + class MusicPlayerTipView : public UIView::OnClickListener + { + public: + MusicPlayerTipView(); + ~MusicPlayerTipView(); + static MusicPlayerTipView *GetInstance(void); + + UIViewGroup * CreateMusicPlayerTipView(void); + bool OnClick(UIView &view, const ClickEvent &event); + + + private: + void ClearAll(void); + UIViewGroup *group{nullptr}; + UIScrollView *scrollView{nullptr}; + UIImageView *image{nullptr}; + UILabelExt *noteLabel{nullptr}; + UILabelExt *OKLabel{nullptr}; + UIButton *OkButton{nullptr}; + UIView::OnDragListener *dragListener{nullptr}; + }; + +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersPresenter.h index b41ca0005..2e2267e45 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-05 15:20:03 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-24 15:01:01 + * @LastEditTime: 2024-10-19 14:33:19 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersPresenter.h */ @@ -58,6 +58,7 @@ class VolumeSettingView; #define MUSIC_PLAYER_DELETE_VIEW "MusicPlayerDeleteView" //音乐删除视图的滑动监听 #define MUISC_PLAYER_BLUETOOTH_DISCONN_VIEW "MusicPlayerBluetoothDisConView" //蓝牙未连接视图的滑动监听 #define MUISC_PLAYER_BLUETOOTH_CONNECTFAILED_VIEW "MusicPlayerBluetoothConncetFailedView" //蓝牙连接失败视图的滑动监听 +#define MUISC_PLAYER_TIP_VIEW "MusicPlayerTipView" //音乐播放器Tip视图的滑动监听 #define TIPS_SUCC_MESSAGE_VIEW "TipsSuccMessageView" #define TIPS_FAIL_MESSAGE_VIEW "TipsFailMessageView" #define TIPS_CONN_FAIL_MESSAGE_VIEW "TipsConnFailMessageView" @@ -176,6 +177,7 @@ private: void OnDragChangMusicPlayerDeleteView(const DragEvent& event); void OnDragChangMusicPlayerBTDisConnectView(const DragEvent& event); void OnDragChangMusicPlayerBTConnectFailedView(const DragEvent& event); + void OnDragChangMusicPlayerTipView(const DragEvent& event); void DropEarPhoneView(const DragEvent& event); void DropEarListView(const DragEvent& event); void CorrespondingJump(const DragEvent& event, int16_t hideView); 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 16ea701ba..3d2eba03f 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-09-18 19:13:53 + * @LastEditTime: 2024-10-19 14:38:21 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h */ @@ -35,6 +35,7 @@ #include "player/include/MusicPlayerBluetoothDisConView.h" #include "player/include/MusicPlayerBTConnectFailedView.h" #include "aivoice/include/AiVoiceConnectingView.h" +#include "player/include/MusicPlayerTipView.h" namespace OHOS { #define PLAY_PROGRESS_MIN 0 @@ -67,6 +68,7 @@ namespace OHOS MUISC_BLUETOOTH_HEADSET_LIST_VIEW, // 蓝牙耳机列表视图 MUSIC_CONNECTED_BLUETOOTH_HEADSET_VIEW, // 已连接的蓝牙耳机设备视图 MUSIC_PHONE_BLUETOOTH_CONNECT_FAIL_VIEW, // 与手机蓝牙连接失败视图 + MUSIC_PLAYER_TIP_VIEW, // 音乐播放器Tip视图 MUSICPLAYERJUMPVIEWID_MAX, }; PlayersView(); @@ -118,6 +120,7 @@ namespace OHOS bool ChangeToMusicBluetoothDisConnectView(int16_t thisView); bool ChangeToMusicBluetoothConnectFailedView(int16_t thisView); bool ChangeToMusicConnectingView(int16_t thisView); + bool ChangeToMusicPlayerTipView(int16_t thisView); private: UIButton *PlayerViewButtonInit(ButtonConfig &buttonconfig); @@ -156,6 +159,7 @@ namespace OHOS MusicPlayerBluetoothDisConView *musicPlayerBluetoothDisConView{nullptr}; // 蓝牙未连接视图 MusicPlayerBTConnectFailedView *musicPlayerBTConnectFailedView{nullptr}; // 蓝牙连接失败视图 AiVoiceConnectingView *musicPlayerConnectingView{nullptr}; // 连接动画 + MusicPlayerTipView * musicPlayerTipView{nullptr}; // 音乐播放器Tip视图 private: UIView::OnClickListener *clickListener{nullptr}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerBTConnectFailedView.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerBTConnectFailedView.cpp index 0142c6b7f..1129348d9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerBTConnectFailedView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerBTConnectFailedView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-12 11:31:43 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-12 11:15:50 + * @LastEditTime: 2024-10-19 11:51:53 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerBTConnectFailedView.cpp */ #include "player/include/MusicPlayerBTConnectFailedView.h" @@ -94,6 +94,11 @@ namespace OHOS delete scrollView; scrollView = nullptr; } + if (dragListener) + { + delete dragListener; + dragListener = nullptr; + } delete group; group = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerBluetoothDisConView.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerBluetoothDisConView.cpp index c7e9497e0..3bd84eb00 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerBluetoothDisConView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerBluetoothDisConView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-10 16:23:46 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-12 11:20:55 + * @LastEditTime: 2024-10-19 11:52:00 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerBluetoothDisConView.cpp */ #include "player/include/MusicPlayerBluetoothDisConView.h" @@ -38,9 +38,9 @@ namespace OHOS { playersView->ChangeView(PlayersView::MUSIC_BLUETOOTH_DISCONN_VIEW, PlayersView::MAIN_MUSICPLAYER_VIEW); } - else if(strcmp(view.GetViewId(), MUISC_PLAYER_BLUETOOTH_DISCONN_VIEW) == 0) + else if (strcmp(view.GetViewId(), MUISC_PLAYER_BLUETOOTH_DISCONN_VIEW) == 0) { - //跳转到蓝牙连接失败视图 + // 跳转到蓝牙连接失败视图 playersView->ChangeView(PlayersView::MUSIC_BLUETOOTH_DISCONN_VIEW, PlayersView::MUSIC_BT_CONNECTFAILED_VIEW); } return true; @@ -94,6 +94,12 @@ namespace OHOS scrollView = nullptr; } + if (dragListener) + { + delete dragListener; + dragListener = nullptr; + } + delete group; group = nullptr; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerTipView.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerTipView.cpp new file mode 100644 index 000000000..09255d973 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerTipView.cpp @@ -0,0 +1,202 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-10-19 11:27:19 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-10-19 15:35:34 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerTipView.cpp + */ +#include "player/include/MusicPlayerTipView.h" +#include "player/include/PlayersPresenter.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "ui_resource_string.h" +#include "iostream" +#include "string" +namespace OHOS +{ + + static constexpr const char *OKBUTTON = "okButton"; + static MusicPlayerTipView *g_pMusicPlayerTipView = nullptr; + MusicPlayerTipView::MusicPlayerTipView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MusicPlayerTipView::MusicPlayerTipView"); + g_pMusicPlayerTipView = this; + } + + MusicPlayerTipView::~MusicPlayerTipView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "~MusicPlayerTipView::MusicPlayerTipView"); + ClearAll(); + g_pMusicPlayerTipView = nullptr; + } + + MusicPlayerTipView *MusicPlayerTipView::GetInstance(void) + { + return g_pMusicPlayerTipView; + } + + void MusicPlayerTipView::ClearAll(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MusicPlayerTipView::ClearAll"); + if (group) + { + group->RemoveAll(); + if (scrollView) + { + scrollView->RemoveAll(); + + delete image; + image = nullptr; + + delete noteLabel; + noteLabel = nullptr; + + delete OKLabel; + OKLabel = nullptr; + + delete OkButton; + OkButton = nullptr; + + delete scrollView; + scrollView = nullptr; + } + delete dragListener; + dragListener = nullptr; + + delete group; + group = nullptr; + } + } + + bool MusicPlayerTipView::OnClick(UIView &view, const ClickEvent &event) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MusicPlayerTipView::OnClick"); + PlayersView *playersView = PlayersView::GetInstance(); + if (!playersView) + { + return false; + } + std::string viewId = view.GetViewId(); + if (viewId == OKBUTTON) + { + playersView->ChangeView(PlayersView::MUSIC_PLAYER_TIP_VIEW, PlayersView::MAIN_MUSICPLAYER_VIEW); + } + return true; + } + + UIViewGroup *MusicPlayerTipView::CreateMusicPlayerTipView() + { + if (group == nullptr) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); + return nullptr; + } + + group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + group->SetStyle(STYLE_BACKGROUND_OPA, 0); + group->SetTouchable(true); + group->SetDraggable(true); + group->SetIntercept(true); + group->SetViewId(MUISC_PLAYER_TIP_VIEW); + if (dragListener == nullptr) + { + dragListener = static_cast(new PlayerOnDragListener()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener new fail"); + return nullptr; + } + } + group->SetOnDragListener(dragListener); + /* -------------------------------------------------------------------------- */ + if (scrollView == nullptr) + { + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail"); + return nullptr; + } + } + scrollView->SetPosition(0, 0, 466, 466); + scrollView->SetScrollBlankSize(50); + scrollView->SetReboundSize(35); + scrollView->SetThrowDrag(true); + scrollView->SetMaxScrollDistance(1000); + scrollView->SetDirection(UIScrollView::VERTICAL); + scrollView->RequestFocus(); + scrollView->SetRotateFactor(1.0); + /* -------------------------------------------------------------------------- */ + if (image == nullptr) + { + image = new UIImageView(); + if (image == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "image new fail"); + return nullptr; + } + } + image->SetPosition(193, 120, 80, 80); + image->SetSrc(PNG_ATTENTION_IMAGE); + /* -------------------------------------------------------------------------- */ + if (noteLabel == nullptr) + { + noteLabel = new UILabelExt(); + if (noteLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "noteLabel new fail"); + return nullptr; + } + } + noteLabel->SetPosition(53, 230, 360, 35); + noteLabel->SetStyle(STYLE_TEXT_FONT, 30); + noteLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + noteLabel->SetText("手表正在播放手机音乐,不能对本地音乐进行操作。"); + noteLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + noteLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + noteLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + /* -------------------------------------------------------------------------- */ + if (OkButton == nullptr) + { + OkButton = new UIButton(); + if (OkButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OkButton new fail"); + return nullptr; + } + } + OkButton->SetPosition(0, noteLabel->GetY() + noteLabel->GetTextHeight() + 30, 466, 100); + OkButton->SetViewId(OKBUTTON); + OkButton->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE); + OkButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0x00, UIButton::PRESSED); + OkButton->SetOnClickListener(this); + /* -------------------------------------------------------------------------- */ + if (OKLabel == nullptr) + { + OKLabel = new UILabelExt(); + if (OKLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OKLabel new fail"); + return nullptr; + } + } + OKLabel->SetPosition(173, OkButton->GetY() + 33, 120, 35); + OKLabel->SetStyle(STYLE_TEXT_FONT, 30); + OKLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + OKLabel->SetTextId(STR_OK); // 知道了 + OKLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + OKLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + OKLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* -------------------------------------------------------------------------- */ + scrollView->Add(image); + scrollView->Add(noteLabel); + scrollView->Add(OkButton); + scrollView->Add(OKLabel); + group->Add(scrollView); + } + return group; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp index 3c176d895..88e70fef8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp @@ -47,6 +47,13 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "playersView null!"); return false; } + /* -------------------------------------------------------------------------- */ + if (PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && + PlayersModel::GetInstance()->get_a2dp_sink_connect_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已连接状态 + { + return false; + } + /* -------------------------------------------------------------------------- */ BtnOnListData(view); /* --------------------------- 若点击的是View类型是Button --------------------------- */ if (view.GetViewType() == UIViewType::UI_BUTTON) 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 7c005b015..1d4106c40 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp @@ -641,15 +641,21 @@ void ButtonOnClickListener::PlayerButtonOnClick() playersView->ChangeView(PlayersView::MAIN_MUSICPLAYER_VIEW,PlayersView::MUSIC_LIST_VIEW); return; } - else + else //若当前歌曲列表不为空且为本地音乐 { - if (state == UICheckBox::UICheckBoxState::SELECTED) { - /* start play */ - PlayersModel::GetInstance()->ConnectBtAndLocalPlay(connCtState, connTgState, playerState); - } else if (state == UICheckBox::UICheckBoxState::UNSELECTED) { - PlayersModel::GetInstance()->ConnectBtAndLocalPause(connCtState, connTgState); + if (PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && + PlayersModel::GetInstance()->get_a2dp_sink_connect_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已连接状态 + { + playersView->ChangeView(PlayersView::MAIN_MUSICPLAYER_VIEW, PlayersView::MUSIC_PLAYER_TIP_VIEW); // 跳转到提示界面 + } else { + if (state == UICheckBox::UICheckBoxState::SELECTED) { + /* start play */ + PlayersModel::GetInstance()->ConnectBtAndLocalPlay(connCtState, connTgState, playerState); + } else if (state == UICheckBox::UICheckBoxState::UNSELECTED) { + PlayersModel::GetInstance()->ConnectBtAndLocalPause(connCtState, connTgState); + } + PlayersModel::GetInstance()->SetCurrentIndex(PlayersModel::GetInstance()->GetCurrentIndex()); } - PlayersModel::GetInstance()->SetCurrentIndex(PlayersModel::GetInstance()->GetCurrentIndex()); } } else //手机音乐 @@ -689,6 +695,12 @@ void ButtonOnClickListener::NextButtonOnClick() WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PlayersView::GetInstance"); return; } + if (PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && + PlayersModel::GetInstance()->get_a2dp_sink_connect_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已连接状态 + { + playersView->ChangeView(PlayersView::MAIN_MUSICPLAYER_VIEW, PlayersView::MUSIC_PLAYER_TIP_VIEW); // 跳转到提示界面 + return; + } if (playersView->GetPlaybackProgress() != nullptr) { playersView->GetPlaybackProgress()->SetValue(0); // 0:进度0% playersView->GetPlaybackProgress()->Invalidate(); @@ -712,6 +724,12 @@ void ButtonOnClickListener::PreButtonOnClick() WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PlayersView::GetInstance"); return; } + if (PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && + PlayersModel::GetInstance()->get_a2dp_sink_connect_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已连接状态 + { + playersView->ChangeView(PlayersView::MAIN_MUSICPLAYER_VIEW, PlayersView::MUSIC_PLAYER_TIP_VIEW); // 跳转到提示界面 + return; + } if (playersView->GetPlaybackProgress() != nullptr) { playersView->GetPlaybackProgress()->SetValue(0); // 0:进度0% playersView->GetPlaybackProgress()->Invalidate(); @@ -728,6 +746,14 @@ void ButtonOnClickListener::SoundButtonOnClick() WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundButtonOnClick playersView nullptr err"); return; } + /* -------------------------------------------------------------------------- */ + if (PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && + PlayersModel::GetInstance()->get_a2dp_sink_connect_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已连接状态 + { + playersView->ChangeView(PlayersView::MAIN_MUSICPLAYER_VIEW, PlayersView::MUSIC_PLAYER_TIP_VIEW); // 跳转到提示界面 + return; + } + /* -------------------------------------------------------------------------- */ playersView->ChangeView(PlayersView::MAIN_MUSICPLAYER_VIEW, PlayersView::MUSIC_VOLUME_CONTROL_VIEW); VolumeSettingView *volumeSettingView = playersView->GetVolumeSettingView(); if(volumeSettingView == nullptr) @@ -791,6 +817,14 @@ void ButtonOnClickListener::PlayerModelButtonOnClick() WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PlayerModelButtonOnClick playersView nullptr err"); return; } + /* -------------------------------------------------------------------------- */ + if (PlayersModel::GetInstance()->get_avrcp_ct_or_tg_is_connected() && + PlayersModel::GetInstance()->get_a2dp_sink_connect_state()) //若ct或tg端是已连接状态且当前a2dp_sink是已连接状态 + { + playersView->ChangeView(PlayersView::MAIN_MUSICPLAYER_VIEW, PlayersView::MUSIC_PLAYER_TIP_VIEW); // 跳转到提示界面 + return; + } + /* -------------------------------------------------------------------------- */ switch (PlayersModel::GetInstance()->GetPlayerModel()) { case LOOP: playersView->PlayerModelButtonSetSrc(PLAYER_PLAYERSMODEL_LOOP); // 循环 @@ -1199,6 +1233,20 @@ void PlayerOnDragListener::OnDragChangMusicPlayerBTConnectFailedView(const DragE X_DRAG_FLAG = true; } } +// 从音乐提示视图回到音乐主视图 +void PlayerOnDragListener::OnDragChangMusicPlayerTipView(const DragEvent& event) +{ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnDragChangMusicPlayerTipView"); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && X_DRAG_FLAG) { + PlayersView *playersView = PlayersView::GetInstance(); + if (playersView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playersView GetInstance fail"); + return; + } + playersView->ChangeView(PlayersView::MUSIC_PLAYER_TIP_VIEW, PlayersView::MAIN_MUSICPLAYER_VIEW); + X_DRAG_FLAG = true; + } +} void PlayerOnDragListener::DropEarPhoneView(const DragEvent& event) { bool ret = BluetoothModel::GetInstance()->IsTagReturnToDeviceListView(); @@ -1296,6 +1344,10 @@ bool PlayerOnDragListener::OnDragEnd(UIView& view, const DragEvent& event) OnDragChangMusicPlayerBTConnectFailedView(event); return false; } + else if (strcmp(view.GetViewId(), MUISC_PLAYER_TIP_VIEW) == 0) { + OnDragChangMusicPlayerTipView(event); + return false; + } return true; } 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 912de71e8..19709e522 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp @@ -1274,6 +1274,7 @@ namespace OHOS {PlayersView::MUSIC_BLUETOOTH_DISCONN_VIEW, &PlayersView::ChangeToMusicBluetoothDisConnectView}, {PlayersView::MUSIC_BT_CONNECTFAILED_VIEW, &PlayersView::ChangeToMusicBluetoothConnectFailedView}, {PlayersView::MUISC_CONNECTING, &PlayersView::ChangeToMusicConnectingView}, + {PlayersView::MUSIC_PLAYER_TIP_VIEW, &PlayersView::ChangeToMusicPlayerTipView}, }; /*根据传入的 interface 值,在 ViewMapper 数组中查找匹配的 viewId*/ @@ -1536,4 +1537,27 @@ namespace OHOS PlayersModel::GetInstance()->PlayerMusic_StartTimer(); return true; } + + bool PlayersView::ChangeToMusicPlayerTipView(int16_t thisView) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PlayersView::ChangeToMusicPlayerTipView"); + if (group[thisView] == nullptr) + { + musicPlayerTipView = new MusicPlayerTipView(); + if (musicPlayerTipView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new playerListDelSongView fail"); + return false; + } + UIViewGroup *groupview = musicPlayerTipView->CreateMusicPlayerTipView(); + if (groupview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new group[%d] fail", thisView); + return false; + } + group[thisView] = groupview; + Add(group[thisView]); + } + return true; + } } -- 2.17.1