From: 罗正yun <1732036298@qq.com> Date: Sat, 6 Jan 2024 03:32:48 +0000 (+0800) Subject: 完善音乐来源视图: X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=37ef32a486c52a369b6954cf00b6a6bef0b92f71;p=mirrors%2FFD230.git 完善音乐来源视图: 完成功能: 点击音乐来源视图中的radiobutton可在音乐播放器主界面显示播放模式. 如,点击手机音乐,主播放器视图音乐来源标签(MusciSourceLabel)内容被设置为"手机音乐", 音乐列表将被隐藏,音乐来源标签上方PhoneMusicConnectStatusLabel(手机音乐连接状态标签)设置为显示。 点击本地音乐radiobutton亦是如此。 待完善功能: 从音乐播放器界面跳转至其他界面,若刚刚为手机音乐模式,则在其他界面返回至音乐播放器界面乐来源标签(MusciSourceLabel)被还原成本地音乐 与逻辑相悖,需要保存点击手机音乐radiobutton状态。 --- diff --git a/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersPresenter.h index 52f1237e7..c98141297 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersPresenter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersPresenter.h @@ -235,6 +235,10 @@ public: void OnClickConnFailBack(void); void OnClickFailBack(void); void SetTitleSetText(const char *text); + void SetMusicSourceSetText(const char *text); + void SetPhoneMusicConnectStatusSetText(const char *text); + void SetPhoneMusicConnectStatusLabelIsVisible(bool status); + void SetMusicListButtonIsVisible(bool status); void SetPlaybackProgress(int64_t value); void SetPlayerState(bool value); void PlayerbackReset(void); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersView.h b/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersView.h index 314fb2c6a..14583b141 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/player/include/PlayersView.h @@ -47,6 +47,12 @@ public: void ShowUpListView(void); void TitleSetText(const char *text); void PlayerModelButtonSetSrc(uint32_t playMode); + void CreateMusicSourceLabel(void); + void MusicSourceLabelSetText(const char *text); + void CreatePhoneMusicConnectStatusLabel(void); + void PhoneMusicConnectStatusLabelSetText(const char *text); + void PhoneMusicConnectStatusLabelIsSetVisible(bool status); + void MusicListButtonIsSetVisible(bool status); int16_t GetVolumeRank(void); void SetVolumeRank(int16_t value); void SetVolumeAddOne(void); @@ -55,7 +61,10 @@ public: UIButton *GetOptionsButton(void); UIButton *GetPreButton(void); UIButton *GetNextButton(void); + UIButton *GetMusicListButton(void); UILabel *GetTitleLabel(void); + UILabel *GetMusicSourceLabel(void); + UILabel *GetPhoneMusicConnectStatusLabel(void); UICheckBox *GetPlayerButton(void); UIImageView *GetSoundButton(void); UIImageView *GetPlayerModelButton(void); @@ -109,6 +118,8 @@ private: UILabel *musicListTitle{nullptr}; //歌单列表名 int16_t volumeSet{0}; //声音值的大小设置 PlayerListDelSongView *p_PlayerListDelSongView{nullptr}; + UILabel *MusciSourceLabel{nullptr}; //音乐来源标签 + UILabel *PhoneMusicConnectStatusLabel{nullptr};//手机音乐连接状态标签 UIScrollView *DelSongView{nullptr}; UIList *list{nullptr}; JumpView *jumpView{nullptr}; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/player/src/BluetoothView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/player/src/BluetoothView.cpp index d03e9e494..abd642798 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/player/src/BluetoothView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/player/src/BluetoothView.cpp @@ -125,14 +125,37 @@ public: UNUSED(event); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothOnClickListener OnClick"); BluetoothView *bluetoothView = BluetoothView::GetInstance(); + PlayersPresenter *playersPresenter = PlayersPresenter::GetInstance(); if (bluetoothView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bluetoothView is nullptr"); return false; } if (view_ == (UIView *)bluetoothView->GetWatchButton()) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "watchButton OnClick");//手表音乐 + playersPresenter->SetPhoneMusicConnectStatusLabelIsVisible(false); + playersPresenter->SetMusicListButtonIsVisible(true); + playersPresenter->SetMusicSourceSetText("本地音乐"); } else if (view_ == (UIView *)bluetoothView->GetPhoneButton()) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "phoneButton OnClick");//手机音乐 + playersPresenter->SetPhoneMusicConnectStatusLabelIsVisible(true); + playersPresenter->SetMusicListButtonIsVisible(false); + /* -------------------------------------------------------------------------- */ + // 以后会用 + // std::string phonemusic_connect_status_text = ""; + // if(获取连接状态。。。) + // { + // 获取成功。。。 + // phonemusic_connect_status_text = "已连接"; + // } + // else + // { + // 获取失败。。。 + // phonemusic_connect_status_text = "未连接"; + // } + // playersPresenter->SetPhoneMusicConnectStatusSetText(phonemusic_connect_status_text.c_str()); + /* -------------------------------------------------------------------------- */ + playersPresenter->SetPhoneMusicConnectStatusSetText("未连接"); + playersPresenter->SetMusicSourceSetText("手机音乐");//还有小bug,切换到其他界面时标签内容为“手机音乐”,会被还原成本地音乐 } else if (view_ == (UIView *)bluetoothView->GetSettingButton()) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "settingButton OnClick"); JumpView *jumpView = JumpView::GetInstance(); @@ -257,7 +280,7 @@ int BluetoothView::LoadLabel(void) return BLUETOOTH_ERROR; } } - phoneLabel->SetPosition(STEP_LABEL_X, STEP_LABEL_Y2, TEXT_WIDTH, TEXT_HEIGHT); + phoneLabel->SetPosition(STEP_LABEL_X, STEP_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); phoneLabel->SetText("手机音乐"); phoneLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_THIRTY_SIZE); /* -------------------------------------------------------------------------- */ @@ -268,8 +291,8 @@ int BluetoothView::LoadLabel(void) return BLUETOOTH_ERROR; } } - watchLabel->SetPosition(STEP_LABEL_X, STEP_LABEL_Y, TEXT_WIDTH, TEXT_HEIGHT); - watchLabel->SetText("手表音乐"); + watchLabel->SetPosition(STEP_LABEL_X, STEP_LABEL_Y2, TEXT_WIDTH, TEXT_HEIGHT); + watchLabel->SetText("本地音乐"); watchLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_THIRTY_SIZE); /* -------------------------------------------------------------------------- */ if (bluetoothLabel == nullptr) { @@ -320,6 +343,7 @@ int BluetoothView::LoadRadioButton(void) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "listener2 new fail"); return BLUETOOTH_ERROR; } + watchButton->SetState(UICheckBox::SELECTED); watchButton->SetPosition(BUTTON_X, BUTTON_Y2, WIDTH, HEIGHT); watchButton->SetImages(PNG_CHECKBOX_ON_IMAGE,PNG_CHECKBOX_OFF_IMAGE); watchButton->SetOnClickListener(listener2); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersPresenter.cpp index 98190380e..6940a6dbc 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersPresenter.cpp @@ -1358,6 +1358,70 @@ void PlayersPresenter::SetTitleSetText(const char *text) playersView->TitleSetText(text); } +/// @brief 设置音乐来源标签内容 +/// @param text 文本内容 +void PlayersPresenter::SetMusicSourceSetText(const char *text) +{ + PlayersView *playersView = PlayersView::GetInstance(); + if (playersView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetMusicSourceSetText playersView GetInstance fail"); + return; + } + if (playersView->GetMusicSourceLabel() == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetMusicSourceSetText MusciSourceLabel nullptr"); + return; + } + playersView->MusicSourceLabelSetText(text); +} + +/// @brief 设置手机音乐连接状态文本内容 +/// @param text 文本内容 +void PlayersPresenter::SetPhoneMusicConnectStatusSetText(const char *text) +{ + PlayersView *playersView = PlayersView::GetInstance(); + if (playersView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPhoneMusicConnectStatusSetText playersView GetInstance fail"); + return; + } + if (playersView->GetPhoneMusicConnectStatusLabel() == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPhoneMusicConnectStatusSetText PhoneMusicConnectStatusLabel nullptr"); + return; + } + playersView->PhoneMusicConnectStatusLabelSetText(text); +} + +/// @brief 设置手机音乐连接状态标签是否可见 +/// @param status true 可见 false 阴藏 +void PlayersPresenter::SetPhoneMusicConnectStatusLabelIsVisible(bool status) +{ + PlayersView *playersView = PlayersView::GetInstance(); + if (playersView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPhoneMusicConnectStatusLabelIsVisible playersView GetInstance fail"); + return; + } + if (playersView->GetPhoneMusicConnectStatusLabel() == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPhoneMusicConnectStatusLabelIsVisible PhoneMusicConnectStatusLabel nullptr"); + return; + } + playersView->PhoneMusicConnectStatusLabelIsSetVisible(status); +} + +/// @brief 设置音乐列表按钮是否可见 +/// @param status true 可见 false 阴藏 +void PlayersPresenter::SetMusicListButtonIsVisible(bool status) +{ + PlayersView *playersView = PlayersView::GetInstance(); + if (playersView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetMusicListButtonIsVisible playersView GetInstance fail"); + return; + } + if (playersView->GetMusicListButton() == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetMusicListButtonIsVisible music_list_button nullptr"); + return; + } + playersView->MusicListButtonIsSetVisible(status); +} + void PlayersPresenter::SetPlaybackProgress(int64_t value) { PlayersView *playersView = PlayersView::GetInstance(); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp index dd0f38659..7f49600db 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/player/src/PlayersView.cpp @@ -59,6 +59,18 @@ PlayersView::~PlayersView() delete backGround; delete titleLabel; delete subTitleLabel; + delete MusciSourceLabel; + MusciSourceLabel = nullptr; + if(music_list_button != nullptr) + { + delete music_list_button; + music_list_button = nullptr; + } + if(PhoneMusicConnectStatusLabel != nullptr) + { + delete PhoneMusicConnectStatusLabel; + PhoneMusicConnectStatusLabel = nullptr; + } backGround = nullptr; titleLabel = nullptr; subTitleLabel = nullptr; @@ -124,11 +136,29 @@ UIButton *PlayersView::GetNextButton(void) return nextButton; } +//获取音乐列表按钮 +UIButton *PlayersView::GetMusicListButton(void) +{ + return music_list_button; +} + UILabel *PlayersView::GetTitleLabel(void) { return titleLabel; } +//获取音乐来源标签 +UILabel *PlayersView::GetMusicSourceLabel(void) +{ + return MusciSourceLabel; +} + +//获手机音乐连接状态标签 +UILabel *PlayersView::GetPhoneMusicConnectStatusLabel(void) +{ + return PhoneMusicConnectStatusLabel; +} + UICheckBox *PlayersView::GetPlayerButton(void) { return playerButton; @@ -677,6 +707,80 @@ bool PlayersView::OnDragEvent(const DragEvent& event) return false; } +/// @brief 创建音乐来源标签 +/// @param +void PlayersView::CreateMusicSourceLabel(void) +{ + if (MusciSourceLabel == nullptr) { + MusciSourceLabel = new UILabel(); + if (MusciSourceLabel == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MusciSourceLabel new fail"); + return; + } + } + MusciSourceLabel->SetPosition(163, 90, 140, 41); + MusciSourceLabel->SetText("本地音乐"); + MusciSourceLabel->SetStyle(STYLE_TEXT_FONT, 35); + MusciSourceLabel->SetStyle(STYLE_LINE_HEIGHT, 41); + MusciSourceLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + MusciSourceLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + MusciSourceLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); + Add(MusciSourceLabel); +} + +/// @brief 设置音乐来源标签内容 +/// @param text 文本内容 +void PlayersView::MusicSourceLabelSetText(const char *text) +{ + MusciSourceLabel->SetText(text); + MusciSourceLabel->Invalidate(); +} + +/// @brief 创建手机音乐连接状态标签 +/// @param +void PlayersView::CreatePhoneMusicConnectStatusLabel(void) +{ + if (PhoneMusicConnectStatusLabel == nullptr) { + PhoneMusicConnectStatusLabel = new UILabel(); + if (PhoneMusicConnectStatusLabel == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneMusicConnectStatusLabel new fail"); + return; + } + } + PhoneMusicConnectStatusLabel->SetPosition(188, 40, 90, 35); + PhoneMusicConnectStatusLabel->SetText("未连接"); + PhoneMusicConnectStatusLabel->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + PhoneMusicConnectStatusLabel->SetStyle(STYLE_TEXT_FONT, 30); + PhoneMusicConnectStatusLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + PhoneMusicConnectStatusLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + PhoneMusicConnectStatusLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + PhoneMusicConnectStatusLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + PhoneMusicConnectStatusLabel->SetVisible(false); + Add(PhoneMusicConnectStatusLabel); +} + +/// @brief 设置手机音乐连接状态标签内容 +/// @param text 文本内容 +void PlayersView::PhoneMusicConnectStatusLabelSetText(const char *text) +{ + PhoneMusicConnectStatusLabel->SetText(text); + PhoneMusicConnectStatusLabel->Invalidate(); +} + +/// @brief 设置手机连接状态标签是否可见 +/// @param status +void PlayersView::PhoneMusicConnectStatusLabelIsSetVisible(bool status) +{ + PhoneMusicConnectStatusLabel->SetVisible(status); +} + +/// @brief 设置音乐列表按钮是否可见 +/// @param status +void PlayersView::MusicListButtonIsSetVisible(bool status) +{ + music_list_button->SetVisible(status); +} + //初始化音乐播放器主视图 bool PlayersView::InitView(void) { @@ -688,6 +792,8 @@ bool PlayersView::InitView(void) } //CreatePlayerMusicName(); + CreatePhoneMusicConnectStatusLabel(); + CreateMusicSourceLabel(); // changeView CreateJumpView(); // OnClick