From 2179d3c4fa2de5c58c445680e52efcea6950c0d6 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Sat, 10 Aug 2024 19:12:06 +0800 Subject: [PATCH] =?utf8?q?=E9=9F=B3=E4=B9=90=E8=A7=86=E5=9B=BE=E6=B7=BB?= =?utf8?q?=E5=8A=A0=E8=93=9D=E7=89=99=E6=9C=AA=E8=BF=9E=E6=8E=A5=E8=A7=86?= =?utf8?q?=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 1 + .../include/ui_resource_string.h | 3 +- .../include/MusicPlayerBluetoothDisConView.h | 56 ++++ .../player/include/MusicPlayerSourceView.h | 5 +- .../player/include/PlayersPresenter.h | 6 +- .../nativeui/player/include/PlayersView.h | 18 +- .../src/MusicPlayerBluetoothDisConView.cpp | 305 ++++++++++++++++++ .../player/src/MusicPlayerSourceView.cpp | 24 +- .../nativeui/player/src/PlayersPresenter.cpp | 4 +- .../nativeui/player/src/PlayersView.cpp | 71 ++-- .../fd230/fs/user/res/font/en.lang | Bin 10782 -> 10886 bytes .../fs/user/res/font/ui_resource_string.h | 3 +- .../fd230/fs/user/res/font/zh.lang | Bin 9711 -> 9819 bytes .../Language_xml/input_list_en.txt | 3 +- .../Language_xml/input_list_zh.txt | 3 +- .../Language_xml/language_en.xml | 1 + .../Language_xml/language_zh.xml | 1 + tools/language_tool/font/en.lang | Bin 10782 -> 10886 bytes tools/language_tool/font/ui_resource_string.h | 3 +- tools/language_tool/font/zh.lang | Bin 9711 -> 9819 bytes 20 files changed, 467 insertions(+), 40 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerBluetoothDisConView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerBluetoothDisConView.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 6dceb0181..fd9e95485 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -243,6 +243,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/VolumeSettingView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/VolumeSettingPresenter.cpp #音乐 + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/player/src/MusicPlayerBluetoothDisConView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/player/src/MusicPlayerSourceView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/player/src/PlayersView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/player/src/PlayersPresenter.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h index 333c7c9db..a501aad31 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h @@ -513,7 +513,8 @@ enum UIResourceTextId : uint16_t { STR_IFLYTEK_SPARK = 500, STR_DISTURBNOTE_OFF = 501, STR_4G_NOTE = 502, - STR_MAX_ID = 503, + STR_MUSIC_PLAYER_SOURCE_NOTE = 503, + STR_MAX_ID = 504, }; // UIResourceTextId enum FontLanguageId : uint8_t { diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerBluetoothDisConView.h b/code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerBluetoothDisConView.h new file mode 100644 index 000000000..b82f18b3e --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerBluetoothDisConView.h @@ -0,0 +1,56 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-08-10 16:23:34 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-08-10 17:42:47 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerBluetoothDisConView.h + */ +#ifndef MUSIC_PLAYER_BLUETOOTH_DISCON_VIEW_H +#define MUSIC_PLAYER_BLUETOOTH_DISCON_VIEW_H +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_button.h" + +namespace OHOS +{ + class MusicPlayerBluetoothDisConView : public UIView::OnClickListener + { + public: + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; + int16_t lineHeigh; + uint16_t textId; + uint8_t lineBreakMode; + }; + MusicPlayerBluetoothDisConView(); + ~MusicPlayerBluetoothDisConView(); + bool OnClick(UIView &view, const ClickEvent &event) override; + UIViewGroup *CreateMusicPlayerBluetoothDisConView(void); + + private: + UILabelExt *MusicPlayerBluetoothDisConViewLabelInit(LabelConfig &labelconfig); + bool CreateMusicPlayerBluetoothDisConViewLabel(void); + bool CreateMusicPlayerBluetoothDisConViewImage(void); + bool CreateMusicPlayerBluetoothDisConViewButton(void); + + void ClearAll(); + UIViewGroup *group{nullptr}; + UIScrollView *scrollView{nullptr}; + UILabelExt *titleLabel{nullptr}; // 标题 + UIImageView *bluetoothImage{nullptr}; + UIImageView *image66{nullptr}; + UIImageView *image99{nullptr}; + UILabelExt *noteLabel{nullptr}; + UIButton *OkButton{nullptr}; + UILabelExt *OkLabel{nullptr}; + UIView::OnDragListener *dragListener{nullptr}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerSourceView.h b/code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerSourceView.h index 3fd4fcaeb..1f3523165 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerSourceView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerSourceView.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-08 16:15:50 + * @LastEditTime: 2024-08-10 16:29:34 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/MusicPlayerSourceView.h */ @@ -53,7 +53,6 @@ namespace OHOS UIViewGroup *CreateMusicPlayerSourceView(void); void UpdateBluetoothHeadSetViewIsVisible(void); void UpdateBluetoothHeadsetConnectLabel(void); - UIViewGroup *group{nullptr}; private: UILabelButton *MusicPlayerSourceViewLabelButtonInit(ButtonConfig &buttonconfig); @@ -62,7 +61,7 @@ namespace OHOS bool CreateMusicPlayerSourceViewLabel(void); bool CreateMusicPlayerSourceViewImage(void); void ClearAll(); - + UIViewGroup *group{nullptr}; UIScrollView *scrollView{nullptr}; UILabelExt *titleLabel{nullptr}; // 标题 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 9bffa44d9..9e1a75c68 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-08-09 18:07:21 + * @LastEditTime: 2024-08-10 17:54:49 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersPresenter.h */ @@ -55,6 +55,8 @@ class VolumeSettingView; #define MUSIC_PLAYER_SOURCE_VIEW "MusicPlayerSourceView" //音乐来源视图的滑动监听 #define MUSIC_PLAYER_LIST_VIEW "MusicPlayerListView" //音乐列表的滑动监听 #define MUSIC_PLAYER_DELETE_VIEW "MusicPlayerDeleteView" //音乐删除视图的滑动监听 +#define MUSIC_PLAYER_DELETE_VIEW "MusicPlayerDeleteView" //音乐删除视图的滑动监听 +#define MUISC_PLAYER_BLUETOOTH_DISCONN_VIEW "MusicPlayerBluetoothDisConView" #define TIPS_SUCC_MESSAGE_VIEW "TipsSuccMessageView" #define TIPS_FAIL_MESSAGE_VIEW "TipsFailMessageView" #define TIPS_CONN_FAIL_MESSAGE_VIEW "TipsConnFailMessageView" @@ -234,7 +236,7 @@ public: void OnClickSuccBack(void); void OnClickConnFailBack(void); void OnClickFailBack(void); - void UpdatePlayerView(void); + void UpdatePlayerView(bool musicSourceType, bool phoneMusicConnectStatus); void SetPlaybackProgress(int64_t value); void SetPlayerState(bool value); void PlayerbackReset(void); 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 1062b1577..d2c4c4023 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-09 18:19:34 + * @LastEditTime: 2024-08-10 18:09:09 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h */ @@ -32,6 +32,7 @@ #include "common/image_cache_manager.h" #include "VolumeSettingView.h" #include "player/include/MusicPlayerSourceView.h" +#include "player/include/MusicPlayerBluetoothDisConView.h" namespace OHOS { #define PLAY_PROGRESS_MIN 0 @@ -58,6 +59,7 @@ namespace OHOS MUSIC_VOLUME_CONTROL_VIEW, // 音量调节视图 MUSIC_LIST_VIEW, // 音乐列表视图 MUSIC_DELETE_VIEW, // 音乐删除视图 + MUSIC_BLUETOOTH_DISCONN_VIEW, // 音乐蓝牙未连接视图 MUISC_CONNECTING, // 连接动画视图 MUISC_BLUETOOTH_HEADSET_LIST_VIEW, // 蓝牙耳机列表视图 MUSIC_CONNECTED_BLUETOOTH_HEADSET_VIEW, // 已连接的蓝牙耳机设备视图 @@ -94,7 +96,7 @@ namespace OHOS UICircleProgress *GetPlaybackProgress(void); UICheckBox::UICheckBoxState GetPlayerButtonState(void); - void UpdatePlayerView(void); + void UpdatePlayerView(bool musicSourceType, bool phoneMusicConnectStatus); VolumeSettingView *GetVolumeSettingView(); PlayerListDelSongView *GetPlayerListDelSongView(); @@ -106,6 +108,7 @@ namespace OHOS bool ChangeToVolumeControlView(int16_t thisView); bool ChangeToMusicListView(int16_t thisView); bool ChangeToMusicDeleteView(int16_t thisView); + bool ChangeToMusicBluetoothDisConnectView(int16_t thisView); private: UIButton *PlayerViewButtonInit(ButtonConfig &buttonconfig); @@ -134,13 +137,14 @@ namespace OHOS void PhoneMusicConnectStatusLabelIsSetVisible(bool status); void PhoneMusicConnectStatusLabelColor(bool state); void OptionsButtonSetImageStyle(ImageInfo *image); - void UpdateMusicPlayerModelButton(void); + void SetMusicPlayerButtonIsTouchable(bool musicSourceType, bool phoneMusicConnectStatus); private: - VolumeSettingView *volumeSettingView{nullptr}; // 声音设置 - MusicPlayerSourceView *musicPlayerSourceView{nullptr}; // 音乐来源 - PlayerListDelSongView *playerListDelSongView{nullptr}; // 音乐删除视图 - UIViewGroup *musicListGroupView{nullptr}; // 音乐列表视图 + VolumeSettingView *volumeSettingView{nullptr}; // 声音设置 + MusicPlayerSourceView *musicPlayerSourceView{nullptr}; // 音乐来源 + PlayerListDelSongView *playerListDelSongView{nullptr}; // 音乐删除视图 + UIViewGroup *musicListGroupView{nullptr}; // 音乐列表视图 + MusicPlayerBluetoothDisConView *musicPlayerBluetoothDisConView{nullptr}; // 蓝牙未连接视图 private: UIView::OnClickListener *clickListener{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 new file mode 100644 index 000000000..bf0b7bbc8 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerBluetoothDisConView.cpp @@ -0,0 +1,305 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-08-10 16:23:46 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-08-10 19:11:52 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerBluetoothDisConView.cpp + */ +#include "player/include/MusicPlayerBluetoothDisConView.h" +#include "wearable_log.h" +#include "ui_resource_string.h" +#include "player/include/PlayersPresenter.h" +#include "player/include/PlayersView.h" +#include "ui_resource_image.h" +namespace OHOS +{ + MusicPlayerBluetoothDisConView::MusicPlayerBluetoothDisConView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MusicPlayerBluetoothDisConView::MusicPlayerBluetoothDisConView"); + } + + MusicPlayerBluetoothDisConView::~MusicPlayerBluetoothDisConView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MusicPlayerBluetoothDisConView::~MusicPlayerBluetoothDisConView"); + ClearAll(); + } + + bool MusicPlayerBluetoothDisConView::OnClick(UIView &view, const ClickEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MusicPlayerBluetoothDisConView::OnClick"); + UILabelButton *button = dynamic_cast(&view); + if (!button) + { + return false; + } + PlayersView *playersView = PlayersView::GetInstance(); + if (!playersView) + { + return false; + } + if (button == OkButton) + { + playersView->ChangeView(PlayersView::MUSIC_BLUETOOTH_DISCONN_VIEW, PlayersView::MAIN_MUSICPLAYER_VIEW); + } + return true; + } + + void MusicPlayerBluetoothDisConView::ClearAll() + { + if (group != nullptr) + { + group->RemoveAll(); + if (scrollView != nullptr) + { + scrollView->RemoveAll(); + if (titleLabel != nullptr) + { + delete titleLabel; + titleLabel = nullptr; + } + if (bluetoothImage != nullptr) + { + delete bluetoothImage; + bluetoothImage = nullptr; + } + if (image66 != nullptr) + { + delete image66; + image66 = nullptr; + } + if (image99 != nullptr) + { + delete image99; + image99 = nullptr; + } + if (noteLabel != nullptr) + { + delete noteLabel; + noteLabel = nullptr; + } + delete scrollView; + scrollView = nullptr; + } + if (OkButton != nullptr) + { + delete OkButton; + OkButton = nullptr; + } + if (OkLabel != nullptr) + { + delete OkLabel; + OkLabel = nullptr; + } + delete group; + group = nullptr; + } + } + + UILabelExt *MusicPlayerBluetoothDisConView::MusicPlayerBluetoothDisConViewLabelInit(LabelConfig &labelconfig) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); + label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); + label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); + label->SetTextId(labelconfig.textId); + label->SetLineBreakMode(labelconfig.lineBreakMode); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(70); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); + return label; + } + + bool MusicPlayerBluetoothDisConView::CreateMusicPlayerBluetoothDisConViewLabel(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MusicPlayerBluetoothDisConView::CreateMusicPlayerBluetoothDisConViewLabel"); + LabelConfig labelConfig = { + .left = 83, + .top = 50, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_BLUETOOTH_DISCONNECTED, /*蓝牙未连接*/ + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + titleLabel = MusicPlayerBluetoothDisConViewLabelInit(labelConfig); + if (nullptr == titleLabel) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel new fail!!"); + return false; + } + scrollView->Add(titleLabel); + /* -------------------------------------------------------------------------- */ + labelConfig = { + .left = 53, + .top = 230, + .width = 360, + .height = 105, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_MUSIC_PLAYER_SOURCE_NOTE, /*请从手表端应用界面进入“音乐”-“音乐来源”,设置为“手机模式”后重试*/ + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + noteLabel = MusicPlayerBluetoothDisConViewLabelInit(labelConfig); + if (nullptr == noteLabel) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "noteLabel new fail!!"); + return false; + } + scrollView->Add(noteLabel); + /* -------------------------------------------------------------------------- */ + int16_t y = noteLabel->GetY() + noteLabel->GetTextHeight() + 30 + 33; + labelConfig = { + .left = 133, + .top = y, + .width = 200, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_KONW, /*知道了*/ + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + OkLabel = MusicPlayerBluetoothDisConViewLabelInit(labelConfig); + if (nullptr == OkLabel) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OkLabel new fail!!"); + return false; + } + scrollView->Add(OkLabel); + return true; + } + + bool MusicPlayerBluetoothDisConView::CreateMusicPlayerBluetoothDisConViewImage(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MusicPlayerBluetoothDisConView::CreateMusicPlayerBluetoothDisConViewImage"); + if (bluetoothImage == nullptr) + { + bluetoothImage = new UIImageView(); + if (bluetoothImage == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); + return false; + } + bluetoothImage->SetPosition(209, 120, 48, 80); + if (!PlayersView::LoadPlayerImage(bluetoothImage, PLAYER_BLUETOOTH_COLOR)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneImage LoadPlayerImage fail"); + return false; + } + } + scrollView->Add(bluetoothImage); + /* -------------------------------------------------------------------------- */ + if (image66 == nullptr) + { + image66 = new UIImageView(); + if (image66 == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); + return false; + } + image66->SetPosition(33, 200, 74, 52); + if (!PlayersView::LoadPlayerImage(image66, PLAYER_UP_66)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneImage LoadPlayerImage fail"); + return false; + } + } + scrollView->Add(image66); + if (image99 == nullptr) + { + image99 = new UIImageView(); + if (image99 == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); + return false; + } + image99->SetPosition(344, 296, 74, 52); + if (!PlayersView::LoadPlayerImage(image99, PLAYER_DOWM_66)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "phoneImage LoadPlayerImage fail"); + return false; + } + } + scrollView->Add(image99); + + return true; + } + + bool MusicPlayerBluetoothDisConView::CreateMusicPlayerBluetoothDisConViewButton(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MusicPlayerBluetoothDisConView::CreateMusicPlayerBluetoothDisConViewButton"); + if (OkButton == nullptr) + { + OkButton = new UIButton(); + if (OkButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OkButton new fail!!"); + return false; + } + } + OkButton->SetPosition(0, noteLabel->GetY() + noteLabel->GetTextHeight() + 30, 466, 100); + OkButton->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE); + OkButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff383838, UIButton::PRESSED); + OkButton->SetOnClickListener(this); + + scrollView->Add(OkButton); + + return true; + } + + UIViewGroup *MusicPlayerBluetoothDisConView::CreateMusicPlayerBluetoothDisConView(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MusicPlayerBluetoothDisConView::CreateMusicPlayerBluetoothDisConView"); + 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); + group->SetStyle(STYLE_BACKGROUND_OPA, 0); + group->SetTouchable(true); + group->SetDraggable(true); + group->SetIntercept(true); + group->SetViewId(MUISC_PLAYER_BLUETOOTH_DISCONN_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(35); + scrollView->SetReboundSize(35); + scrollView->SetDirection(UIScrollView::VERTICAL); + + if (!CreateMusicPlayerBluetoothDisConViewLabel() || !CreateMusicPlayerBluetoothDisConViewImage() || !CreateMusicPlayerBluetoothDisConViewButton()) + { + return nullptr; + } + + group->Add(scrollView); + return group; + } +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerSourceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerSourceView.cpp index 434c4aabd..5151ab568 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerSourceView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/MusicPlayerSourceView.cpp @@ -47,8 +47,15 @@ namespace OHOS { return false; } + PlayersView *playersView = PlayersView::GetInstance(); + if (!playersView) + { + return false; + } ImageInfo *image; - if (button == phoneLableButton) // 若点击的是手机音乐按钮 + bool phonebluetoothcon = SettingModel::GetInstance().GetPhoneConnectStatus(); // 获取手机连接状态 + bool a2dp = uapi_a2dp_snk_get_device_connect_state(); // 获取a2dp连接状态 + if (button == phoneLableButton) // 若点击的是手机音乐按钮 { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick phoneLableButton"); PlayersModel::GetInstance()->SetMusicSource(true); @@ -57,7 +64,18 @@ namespace OHOS // 1.a2dp未连接,向手机发起a2dp连接 // 如果蓝牙没连接直接是跳转到蓝牙连接失败视图,连接了就有一个主动去连手机的a2dp过程,5秒超市 - playersPresenter->UpdatePlayerView(); + playersPresenter->UpdatePlayerView(PlayersModel::GetInstance()->GetMusicSource(), phonebluetoothcon && a2dp); + + if (!phonebluetoothcon) + { + playersView->ChangeView(PlayersView::MUSIC_SOURCE_VIEW, PlayersView::MUSIC_BLUETOOTH_DISCONN_VIEW); + } + else if (phonebluetoothcon && !a2dp) + { + } + else if (phonebluetoothcon && a2dp) + { + } } else if (button == watchLableButton) // 若点击的是手表音乐按钮 { @@ -65,7 +83,7 @@ namespace OHOS PlayersModel::GetInstance()->SetMusicSource(false); UpdateBluetoothHeadSetViewIsVisible(); - playersPresenter->UpdatePlayerView(); + playersPresenter->UpdatePlayerView(PlayersModel::GetInstance()->GetMusicSource(), phonebluetoothcon && a2dp); } else if (button == bluetoothHeadsetLableButton) { 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 3452ab1cf..1aabce4b6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp @@ -1351,14 +1351,14 @@ bool PlayersPresenter::OnClick(UIView &view, const ClickEvent &event) return false; } -void PlayersPresenter::UpdatePlayerView(void) +void PlayersPresenter::UpdatePlayerView(bool musicSourceType, bool phoneMusicConnectStatus) { PlayersView *playersView = PlayersView::GetInstance(); if (playersView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playersView GetInstance fail"); return; } - playersView->UpdatePlayerView(); + playersView->UpdatePlayerView(musicSourceType,phoneMusicConnectStatus); } void PlayersPresenter::SetPlaybackProgress(int64_t value) 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 8a79d7114..d701a6748 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp @@ -424,6 +424,11 @@ namespace OHOS delete playerListDelSongView; playerListDelSongView = nullptr; } + if (musicPlayerBluetoothDisConView != nullptr) + { + delete musicPlayerBluetoothDisConView; + musicPlayerBluetoothDisConView = nullptr; + } for (int i = MAIN_MUSICPLAYER_VIEW; i < MUSICPLAYERJUMPVIEWID_MAX; i++) { @@ -745,28 +750,33 @@ namespace OHOS LoadPlayerButtonImage(playerModelButton, playMode); } - /*更新音乐播放模式按钮*/ - void PlayersView::UpdateMusicPlayerModelButton(void) + /// @brief 设置音乐播放按钮是否可点击 + /// @param musicSourceType 音乐来源类型 false:手表音乐 true 手机音乐 + /// @param phoneMusicConnectStatus 手机音乐连接状态 + void PlayersView::SetMusicPlayerButtonIsTouchable(bool musicSourceType, bool phoneMusicConnectStatus) { - if (PlayersModel::GetInstance()->GetMusicSource()) - { - playerModelButton->SetTouchable(false); - } - else - { - playerModelButton->SetTouchable(true); - } + // 1.如果为手机音乐且手机音乐已连接那么上一首,下一首,播放或暂停,声音等按钮设置为可点击. + // 2.如果不为手机音乐按钮就可点击 + /* -------------------------------------------------------------------------- */ + bool touchableState = (musicSourceType && phoneMusicConnectStatus) || !musicSourceType; + play_or_pause_Button->SetTouchable(touchableState); + preMusicButton->SetTouchable(touchableState); + nextMusicButton->SetTouchable(touchableState); + soundButton->SetTouchable(touchableState); + /* ------------------------- 如果音乐来源为手机音乐,播放顺序按钮就不可用 ------------------------- */ + playerModelButton->SetTouchable(!musicSourceType); + /* -------------------------------------------------------------------------- */ PreLoadPlayerModeImageRes(); } - void PlayersView::UpdatePlayerView(void) + void PlayersView::UpdatePlayerView(bool musicSourceType, bool phoneMusicConnectStatus) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UpdatePlayerView"); // 1.a2dp未连接,向手机发起a2dp连接 // 2. ImageInfo *image; - if (PlayersModel::GetInstance()->GetMusicSource()) + if (musicSourceType) { image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_PHONE_COLOR, PLAYER_IAMGES); if (!image) @@ -778,11 +788,8 @@ namespace OHOS OptionsButtonSetImageStyle(image); PhoneMusicConnectStatusLabelIsSetVisible(true); MusicListButtonIsSetVisible(false); - UpdateMusicPlayerModelButton(); - bool phonecon = SettingModel::GetInstance().GetPhoneConnectStatus(); // 获取手机连接状态 - bool a2dp = uapi_a2dp_snk_get_device_connect_state(); // 获取a2dp连接状态 - if (phonecon && a2dp) + if (phoneMusicConnectStatus) { PhoneMusicConnectStatusLabelSetText(STR_CONNECTED); /*已连接*/ MusicSourceLabelSetText(STR_MOBILE_MUSIC); // 手机音乐 @@ -794,6 +801,7 @@ namespace OHOS MusicSourceLabelSetText(STR_MOBILE_MUSIC); // 手机音乐 PhoneMusicConnectStatusLabelColor(false); } + SetMusicPlayerButtonIsTouchable(musicSourceType, phoneMusicConnectStatus); } else { @@ -807,7 +815,7 @@ namespace OHOS PhoneMusicConnectStatusLabelIsSetVisible(false); MusicListButtonIsSetVisible(true); MusicSourceLabelSetText(STR_WATCH_MUSIC); /*手表音乐*/ - UpdateMusicPlayerModelButton(); + SetMusicPlayerButtonIsTouchable(musicSourceType, phoneMusicConnectStatus); } } @@ -827,7 +835,9 @@ namespace OHOS return false; } /* -------------------------------------------------------------------------- */ - UpdatePlayerView(); + bool phonebluetoothcon = SettingModel::GetInstance().GetPhoneConnectStatus(); // 获取手机连接状态 + bool a2dp = uapi_a2dp_snk_get_device_connect_state(); // 获取a2dp连接状态 + UpdatePlayerView(PlayersModel::GetInstance()->GetMusicSource(), phonebluetoothcon && a2dp); /* -------------------------------------------------------------------------- */ PlayersListGroup::GetInstance()->SetUpListCase(); @@ -1072,6 +1082,7 @@ namespace OHOS {PlayersView::MUSIC_VOLUME_CONTROL_VIEW, &PlayersView::ChangeToVolumeControlView}, {PlayersView::MUSIC_LIST_VIEW, &PlayersView::ChangeToMusicListView}, {PlayersView::MUSIC_DELETE_VIEW, &PlayersView::ChangeToMusicDeleteView}, + {PlayersView::MUSIC_BLUETOOTH_DISCONN_VIEW, &PlayersView::ChangeToMusicBluetoothDisConnectView}, }; /*根据传入的 interface 值,在 ViewMapper 数组中查找匹配的 viewId*/ @@ -1232,4 +1243,28 @@ namespace OHOS } return true; } + + /*切换到蓝牙未连接视图*/ + bool PlayersView::ChangeToMusicBluetoothDisConnectView(int16_t thisView) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PlayersView::ChangeToMusicBluetoothDisConnectView"); + if (group[thisView] == nullptr) + { + musicPlayerBluetoothDisConView = new MusicPlayerBluetoothDisConView(); + if (musicPlayerBluetoothDisConView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new playerListDelSongView fail"); + return false; + } + UIViewGroup *groupview = musicPlayerBluetoothDisConView->CreateMusicPlayerBluetoothDisConView(); + if (groupview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new group[%d] fail", thisView); + return false; + } + group[thisView] = groupview; + Add(group[thisView]); + } + return true; + } } diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang index c67adb79f1f58394c3b83fc6337941e7ce3d3091..f2c9f8ae9e5bb6724139747f114ed88b967d39b0 100644 GIT binary patch delta 139 zcmbOi(iSSZ;*0vH)I0_h@MELsU3MlNrOhAM^^{Tqa#9nEQx#J4N>Ymyd`pWnlNEHK zbZ~xYQF5w6T2X$kLP^e#Sy4DHb diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h index 9443534a1..dc7dd217e 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h @@ -513,7 +513,8 @@ enum UIResourceTextId : uint16_t { STR_IFLYTEK_SPARK = 500, STR_DISTURBNOTE_OFF = 501, STR_4G_NOTE = 502, - STR_MAX_ID = 503, + STR_MUSIC_PLAYER_SOURCE_NOTE = 503, + STR_MAX_ID = 504, }; // UIResourceTextId enum FontLanguageId : uint8_t { diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang index 9c38b26e4f5388a1422aa844c53862e7433f6e30..558c19bfe069321ff66031a1f16a1cf602fa0d22 100644 GIT binary patch delta 141 zcmaFwecMMg?qynGRR#kJ__0y+E<5Aj#qZhWGG46T{$zLGv(D}p3s*c}z5eO0DbJ^@ zcs{k~<=jOt_RoIWy7W=QoR{-AKiN6qQNvtaIOo~irO$SOgx>Gzd9iNa^S$ey?AQgA d1se2h&aP)G7Czn650rg6q3>mT?~C + diff --git a/tools/language_tool/Language_xml/language_zh.xml b/tools/language_tool/Language_xml/language_zh.xml index 8bce54a5d..8171c7a32 100644 --- a/tools/language_tool/Language_xml/language_zh.xml +++ b/tools/language_tool/Language_xml/language_zh.xml @@ -502,4 +502,5 @@ + diff --git a/tools/language_tool/font/en.lang b/tools/language_tool/font/en.lang index c67adb79f1f58394c3b83fc6337941e7ce3d3091..f2c9f8ae9e5bb6724139747f114ed88b967d39b0 100644 GIT binary patch delta 139 zcmbOi(iSSZ;*0vH)I0_h@MELsU3MlNrOhAM^^{Tqa#9nEQx#J4N>Ymyd`pWnlNEHK zbZ~xYQF5w6T2X$kLP^e#Sy4DHb diff --git a/tools/language_tool/font/ui_resource_string.h b/tools/language_tool/font/ui_resource_string.h index 9443534a1..dc7dd217e 100644 --- a/tools/language_tool/font/ui_resource_string.h +++ b/tools/language_tool/font/ui_resource_string.h @@ -513,7 +513,8 @@ enum UIResourceTextId : uint16_t { STR_IFLYTEK_SPARK = 500, STR_DISTURBNOTE_OFF = 501, STR_4G_NOTE = 502, - STR_MAX_ID = 503, + STR_MUSIC_PLAYER_SOURCE_NOTE = 503, + STR_MAX_ID = 504, }; // UIResourceTextId enum FontLanguageId : uint8_t { diff --git a/tools/language_tool/font/zh.lang b/tools/language_tool/font/zh.lang index 9c38b26e4f5388a1422aa844c53862e7433f6e30..558c19bfe069321ff66031a1f16a1cf602fa0d22 100644 GIT binary patch delta 141 zcmaFwecMMg?qynGRR#kJ__0y+E<5Aj#qZhWGG46T{$zLGv(D}p3s*c}z5eO0DbJ^@ zcs{k~<=jOt_RoIWy7W=QoR{-AKiN6qQNvtaIOo~irO$SOgx>Gzd9iNa^S$ey?AQgA d1se2h&aP)G7Czn650rg6q3>mT?~C