From 0d4ffcc2347cce260c3909fb30fdb1267e95935a Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Sat, 30 Aug 2025 11:44:38 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E9=9B=B7=E9=B8=9F=E9=80=BB?= =?utf8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../include/ThunderBirdGuideView.h | 12 ++ .../include/ThunderBirdLullabyView.h | 15 ++ .../thunderbird/include/ThunderBirdMainView.h | 44 +++-- .../thunderbird/src/ThunderBirdGuideView.cpp | 140 ++++++++++++++-- .../src/ThunderBirdLullabyView.cpp | 157 ++++++++++++++++-- .../thunderbird/src/ThunderBirdMainView.cpp | 156 ++++++++++------- .../thunderbird/src/ThunderBirdPresenter.cpp | 42 ++++- 7 files changed, 473 insertions(+), 93 deletions(-) diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h index 014cf2bbf..eaa15ecfe 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/include/ThunderBirdGuideView.h @@ -4,6 +4,7 @@ #include "View.h" #include "components/ui_view_group.h" #include "components/ui_label_ext.h" +#include "components/ui_image_view.h" namespace OHOS { @@ -15,10 +16,21 @@ namespace OHOS static ThunderBirdGuideView *GetInstance(void); UIViewGroup *ThunderBirdGuideViewInit(void); void ClearAll(void); + void Show(int16_t showView); + + enum : int16_t { + THUNDERBIRD_GUIDEVIEW_1 = 0, + THUNDERBIRD_GUIDEVIEW_2, + THUNDERBIRD_GUIDEVIEW_3, + }; private: UIViewGroup *group{nullptr}; UILabelExt *titleLabel{nullptr}; + UILabelExt *TextLabel{nullptr}; + UIImageView *RemindGround{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindIcon{nullptr}; }; } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/include/ThunderBirdLullabyView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/include/ThunderBirdLullabyView.h index e37e384ae..14a632b7b 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/include/ThunderBirdLullabyView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/include/ThunderBirdLullabyView.h @@ -4,6 +4,7 @@ #include "View.h" #include "components/ui_view_group.h" #include "components/ui_label_ext.h" +#include "components/ui_image_view.h" namespace OHOS { @@ -15,10 +16,24 @@ namespace OHOS static ThunderBirdLullabyView *GetInstance(void); UIViewGroup *ThunderBirdLullabyViewInit(void); void ClearAll(void); + void Show(int16_t showView); + + enum : int16_t { + THUNDERBIRD_LULLABYVIEW_1 = 0, + THUNDERBIRD_LULLABYVIEW_2, + THUNDERBIRD_LULLABYVIEW_3, + THUNDERBIRD_LULLABYVIEW_4, + THUNDERBIRD_LULLABYVIEW_5, + }; private: UIViewGroup *group{nullptr}; UILabelExt *titleLabel{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon2{nullptr}; + UIImageView *BackGround{nullptr}; }; } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h index b9e41994e..c9c52ac4e 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h @@ -5,15 +5,17 @@ #include "View.h" #include "components/ui_view_group.h" -#include "thunderbird/include/ThunderBirdView.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" #include "video_play_wrapper.h" #include "main/include/dial/DialVideoView.h" #include "animator/animator_manager.h" #include "components/ui_box_progress.h" #include "components/ui_image_animator.h" -#include "thunderbird/include/ThunderBirdView.h" #include "thunderbird/include/ThunderBirdModel.h" #include "thunderbird/include/ThunderBirdPresenter.h" +// 各子界面头文件 +#include "thunderbird/include/ThunderBirdView.h" #include "thunderbird/include/ThunderBirdOtaView.h" #include "thunderbird/include/ThunderBirdGuideView.h" #include "thunderbird/include/ThunderBirdLullabyView.h" @@ -45,6 +47,7 @@ namespace OHOS static ThunderBirdMainView *GetInstance(void); void OnStart() override; + // 视图切换(按组显示/隐藏) bool ChangeThunderBirdView(int16_t); bool ChangeThunderBirdOtaView(int16_t); bool ChangeThunderBirdGuideView(int16_t); @@ -52,9 +55,11 @@ namespace OHOS bool ChangeThunderBirdDialogueView(int16_t); bool ChangeThunderBirdReminderView(int16_t); bool ChangeThunderBirdAdjustView(int16_t); - bool ClickFunc(int16_t interface); - void ChangeView(int16_t hideView, int16_t showView); + void ChangeView(int16_t hideView, int16_t showView, int16_t subView = -1); + + int16_t GetCurrentView() const; + int16_t GetCurrentSubView() const; void UpdateBatteryProcess(); void updateSignalDisplay(); @@ -63,20 +68,20 @@ namespace OHOS void UpdateTimeText(const char *time); void Initback(); void InitBaseData(); + void InitCommonPageComponents(); + void HideCommonPageComponents(); + bool SwitchVideo(const char *uri); - private: - ThunderBirdView *g_pThunderBirdView{nullptr}; - ThunderBirdOtaView *g_pThunderBirdOtaView{nullptr}; - ThunderBirdGuideView *g_pThunderBirdGuideView{nullptr}; - ThunderBirdLullabyView *g_pThunderBirdLullabyView{nullptr}; - ThunderBirdDialogueView *g_pThunderBirdDialogueView{nullptr}; - ThunderBirdReminderView *g_pThunderBirdReminderView{nullptr}; - ThunderBirdAdjustView *g_pThunderBirdAdjustView{nullptr}; private: void DeInit(); + // 旧多视图分组容器 UIViewGroup *group[MAXVIEW]{nullptr}; UIScrollView *ScrollView_{nullptr}; + // 页面聚合容器:承载所有子界面,切换仅做显示/隐藏 + UIViewGroup *pagesGroup{nullptr}; + int16_t currentView_{THUNDERBIRD_GUIDEVIEW}; + int16_t currentSubView_{0}; UIImageView *curFace{nullptr}; DialVideoView *videoPlayer_ = nullptr; @@ -94,6 +99,21 @@ namespace OHOS UIBoxProgress *progress{nullptr}; // 电池进度条 UIImageView *chargeBatteryicon{nullptr}; // 充电图标 bool isChargeBatteryIconVisible{false}; // 充电图标是否可见 + + // Ota(进度/文本) + UIBoxProgress *otaProgress{nullptr}; + + // 各子界面对象指针 + ThunderBirdView *g_pThunderBirdView{nullptr}; + ThunderBirdOtaView *g_pThunderBirdOtaView{nullptr}; + ThunderBirdGuideView *g_pThunderBirdGuideView{nullptr}; + ThunderBirdLullabyView *g_pThunderBirdLullabyView{nullptr}; + ThunderBirdDialogueView *g_pThunderBirdDialogueView{nullptr}; + ThunderBirdReminderView *g_pThunderBirdReminderView{nullptr}; + ThunderBirdAdjustView *g_pThunderBirdAdjustView{nullptr}; + +#define SCREEN_WIDTH (Screen::GetInstance().GetWidth()) +#define SCREEN_HEIGHT (Screen::GetInstance().GetHeight()) }; } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp index f58c3478a..06108f5a6 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp @@ -29,11 +29,10 @@ namespace OHOS delete group; group = nullptr; } - if (titleLabel != nullptr) - { - delete titleLabel; - titleLabel = nullptr; - } + if (titleLabel != nullptr) { delete titleLabel; titleLabel = nullptr; } + if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; } + if (RemindGround != nullptr) { delete RemindGround; RemindGround = nullptr; } + if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; } } UIViewGroup *ThunderBirdGuideView::ThunderBirdGuideViewInit(void) @@ -46,16 +45,137 @@ namespace OHOS } group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - titleLabel = new UILabelExt(); - if (titleLabel != nullptr) + // 公共控件 + TextLabel = new UILabelExt(); + if (TextLabel) + { + TextLabel->SetPosition(0, 104, 466, 48); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 34); + TextLabel->SetVisible(false); + group->Add(TextLabel); + } + RemindGround = new UIImageView(); + if (RemindGround) + { + RemindGround->SetPosition(140, 175, 180, 48); + RemindGround->SetStyle(STYLE_BACKGROUND_COLOR, 0xff95847b); + RemindGround->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + RemindGround->SetStyle(STYLE_BORDER_RADIUS, 80); + RemindGround->SetVisible(false); + group->Add(RemindGround); + } + RemindLabel = new UILabelExt(); + if (RemindLabel) + { + RemindLabel->SetPosition(0, 180, 466, 40); + RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28); + RemindLabel->SetVisible(false); + group->Add(RemindLabel); + } + RemindIcon = new UIImageView(); + if (RemindIcon) { - titleLabel->SetPosition(20, 20, 300, 40); - titleLabel->SetText("新手引导"); - group->Add(titleLabel); + RemindIcon->SetPosition(280, 320, 30, 30); + RemindIcon->SetVisible(false); + group->Add(RemindIcon); } return group; } + + void ThunderBirdGuideView::Show(int16_t showView) + { + if (group == nullptr) { return; } + if (TextLabel) { TextLabel->SetVisible(false); } + if (RemindGround) { RemindGround->SetVisible(false); } + if (RemindLabel) { RemindLabel->SetVisible(false); } + if (RemindIcon) { RemindIcon->SetVisible(false); } + + switch (showView) + { + case THUNDERBIRD_GUIDEVIEW_1: + { + if (TextLabel) + { + TextLabel->SetPosition(0, 104, 466, 48); + TextLabel->SetText("Hey, 我是毛毛~"); + TextLabel->SetVisible(true); + } + if(RemindGround) + { + RemindGround->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetText("按 下一页"); + RemindLabel->SetVisible(true); + } + if(RemindIcon) + { + RemindIcon->SetPosition(180, 175, 30, 30); + RemindIcon->SetSrc("/user/res/volumeup.bin"); + RemindIcon->SetVisible(true); + } + + break; + } + case THUNDERBIRD_GUIDEVIEW_2: + { + if (TextLabel) + { + TextLabel->SetPosition(0, 104, 466, 48); + TextLabel->SetText("我可以和你聊天,哄你睡觉"); + TextLabel->SetVisible(true); + } + if(RemindGround) + { + RemindGround->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetText("按 下一页"); + RemindLabel->SetVisible(true); + } + if(RemindIcon) + { + RemindIcon->SetPosition(180, 175, 30, 30); + RemindIcon->SetSrc("/user/res/volumeup.bin"); + RemindIcon->SetVisible(true); + } + break; + } + case THUNDERBIRD_GUIDEVIEW_3: + { + if (TextLabel) + { + TextLabel->SetPosition(0, 104, 466, 48); + TextLabel->SetText("换角色、挑声音、哄睡...扫码尽享受"); + TextLabel->SetVisible(true); + } + if(RemindGround) + { + RemindGround->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetText("按 跳过"); + RemindLabel->SetVisible(true); + } + if(RemindIcon) + { + RemindIcon->SetPosition(180, 175, 30, 30); + RemindIcon->SetSrc("/user/res/volumeup.bin"); + RemindIcon->SetVisible(true); + } + // 黑色背景与二维码需要补充 + break; + } + default: + break; + } + } } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp index ca405fed1..51ee91cdc 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdLullabyView.cpp @@ -29,11 +29,12 @@ namespace OHOS delete group; group = nullptr; } - if (titleLabel != nullptr) - { - delete titleLabel; - titleLabel = nullptr; - } + if (titleLabel != nullptr) { delete titleLabel; titleLabel = nullptr; } + if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; } + if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; } + if (RemindIcon != nullptr) { delete RemindIcon; RemindIcon = nullptr; } + if (RemindIcon2 != nullptr) { delete RemindIcon2; RemindIcon2 = nullptr; } + if (BackGround != nullptr) { delete BackGround; BackGround = nullptr; } } UIViewGroup *ThunderBirdLullabyView::ThunderBirdLullabyViewInit(void) @@ -46,16 +47,152 @@ namespace OHOS } group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - titleLabel = new UILabelExt(); - if (titleLabel != nullptr) + // 公共控件 + TextLabel = new UILabelExt(); + if (TextLabel) + { + TextLabel->SetPosition(0, 104, 466, 48); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 34); + TextLabel->SetVisible(false); + group->Add(TextLabel); + } + RemindLabel = new UILabelExt(); + if (RemindLabel) { - titleLabel->SetPosition(20, 20, 300, 40); - titleLabel->SetText("哄睡界面"); - group->Add(titleLabel); + RemindLabel->SetPosition(0, 180, 466, 40); + RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28); + RemindLabel->SetVisible(false); + group->Add(RemindLabel); + } + RemindIcon = new UIImageView(); + if (RemindIcon) + { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetVisible(false); + group->Add(RemindIcon); + } + RemindIcon2 = new UIImageView(); + if (RemindIcon2) + { + RemindIcon2->SetAutoEnable(false); + RemindIcon2->SetVisible(false); + group->Add(RemindIcon2); + } + BackGround = new UIImageView();//有待解决 + if (BackGround) + { + BackGround->SetPosition(0, 0, 300, 300); + BackGround->SetStyle(STYLE_BACKGROUND_COLOR, 0x66191919); + BackGround->SetStyle(STYLE_BACKGROUND_OPA, 0x66); + BackGround->SetVisible(false); + group->Add(BackGround); } return group; } + + void ThunderBirdLullabyView::Show(int16_t showView) + { + if (group == nullptr) { return; } + if (BackGround) { BackGround->SetVisible(false); } + if (TextLabel) { TextLabel->SetVisible(false); TextLabel->SetY(104); } + if (RemindLabel) { RemindLabel->SetVisible(false); RemindLabel->SetY(180); } + if (RemindIcon) { RemindIcon->SetVisible(false); } + if (RemindIcon2) { RemindIcon2->SetVisible(false); } + + switch (showView) + { + case THUNDERBIRD_LULLABYVIEW_1: + { + if (TextLabel) + { + TextLabel->SetText("按 说“哄我睡觉”"); + TextLabel->SetVisible(true); + } + if(RemindIcon) + { + RemindIcon->SetVisible(true); + } + break; + } + case THUNDERBIRD_LULLABYVIEW_2: + { + if (TextLabel) + { + TextLabel->SetText("是否开启哄睡模式"); + TextLabel->SetY(160); + TextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetText("按 取消 按 确认"); + RemindLabel->SetVisible(true); + } + break; + } + case THUNDERBIRD_LULLABYVIEW_3: + { + if (TextLabel) + { + TextLabel->SetText(" 告诉我想听的故事"); + TextLabel->SetY(160); + TextLabel->SetVisible(true); + } + if (RemindLabel) + { + RemindLabel->SetText("按 取消 按 确认"); + RemindLabel->SetVisible(true); + } + break; + } + case THUNDERBIRD_LULLABYVIEW_4: + { + if (TextLabel) + { + TextLabel->SetText("从前有座山"); + TextLabel->SetVisible(true); + } + if(RemindLabel) + { + RemindLabel->SetText("按 下一页"); + RemindLabel->SetVisible(true); + } + break; + } + case THUNDERBIRD_LULLABYVIEW_5: + { + if (TextLabel) + { + TextLabel->SetText("是否退出哄睡模式"); + TextLabel->SetY(160); + TextLabel->SetVisible(true); + } + if(RemindLabel) + { + RemindLabel->SetY(320); + RemindLabel->SetText("按 取消 按 确认"); + RemindLabel->SetVisible(true); + } + if(RemindIcon) + { + RemindIcon->SetPosition(130, 320, 30, 30); + RemindIcon->SetSrc("/user/res/volumedown.bin"); + RemindIcon->SetVisible(true); + } + if(RemindIcon2) + { + RemindIcon2->SetPosition(280, 320, 30, 30); + RemindIcon2->SetSrc("/user/res/volumeup.bin"); + RemindIcon2->SetVisible(true); + } + break; + } + default: + break; + } + } } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp index 16a79e0cd..65d426147 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp @@ -39,8 +39,6 @@ namespace OHOS static const int64_t COLOR_SIGNAL_ON = 0xffffffff; static const int64_t COLOR_SIGNAL_OFF = 0xff383838; - static ThunderBirdView *g_pThunderBirdView{nullptr}; - static MediaVideoPlay *g_videoPlay = nullptr; static bool g_lastPlayed = false; static void ScreenStatusNotify(ScreenStatus status) @@ -96,41 +94,22 @@ namespace OHOS void ThunderBirdMainView::DeInit() { - if (g_pThunderBirdView) - { - delete g_pThunderBirdView; - g_pThunderBirdView = nullptr; - } - if (g_pThunderBirdOtaView) - { - delete g_pThunderBirdOtaView; - g_pThunderBirdOtaView = nullptr; - } - if (g_pThunderBirdGuideView) - { - delete g_pThunderBirdGuideView; - g_pThunderBirdGuideView = nullptr; - } - if (g_pThunderBirdLullabyView) - { - delete g_pThunderBirdLullabyView; - g_pThunderBirdLullabyView = nullptr; - } - if (g_pThunderBirdDialogueView) - { - delete g_pThunderBirdDialogueView; - g_pThunderBirdDialogueView = nullptr; - } - if (g_pThunderBirdReminderView) - { - delete g_pThunderBirdReminderView; - g_pThunderBirdReminderView = nullptr; - } - if (g_pThunderBirdAdjustView) + // 释放各子界面对象 + if (g_pThunderBirdView) { delete g_pThunderBirdView; g_pThunderBirdView = nullptr; } + if (g_pThunderBirdOtaView) { delete g_pThunderBirdOtaView; g_pThunderBirdOtaView = nullptr; } + if (g_pThunderBirdGuideView) { delete g_pThunderBirdGuideView; g_pThunderBirdGuideView = nullptr; } + if (g_pThunderBirdLullabyView) { delete g_pThunderBirdLullabyView; g_pThunderBirdLullabyView = nullptr; } + if (g_pThunderBirdDialogueView) { delete g_pThunderBirdDialogueView; g_pThunderBirdDialogueView = nullptr; } + if (g_pThunderBirdReminderView) { delete g_pThunderBirdReminderView; g_pThunderBirdReminderView = nullptr; } + if (g_pThunderBirdAdjustView) { delete g_pThunderBirdAdjustView; g_pThunderBirdAdjustView = nullptr; } + + // 置空所有分组索引,避免悬空指针 + for (int i = 0; i < MAXVIEW; i++) { - delete g_pThunderBirdAdjustView; - g_pThunderBirdAdjustView = nullptr; + group[i] = nullptr; } + + // 不再持有旧 View 实例,全部使用聚合组件 // 先停止视频播放 if (videoPlay_ != nullptr) { @@ -213,12 +192,6 @@ namespace OHOS // 清理其他成员变量 video_ = nullptr; videoPlayer_ = nullptr; - - // 置空所有分组索引,避免悬空指针 - for (int i = 0; i < MAXVIEW; i++) - { - group[i] = nullptr; - } } void ThunderBirdMainView::OnStart() @@ -244,16 +217,51 @@ namespace OHOS ScrollView_->SetDraggable(true); AddViewToRootContainer(ScrollView_); RootView::GetInstance()->SetOnKeyActListener(presenter_); - ChangeView(MAXVIEW, THUNDERBIRDMENUVIEW); + Initback(); + // 顶部状态栏 InitBaseData(); + // 默认显示主界面 + ChangeView(MAXVIEW, THUNDERBIRD_GUIDEVIEW,0); // 增加按键监听 RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::ThunderBirdPresenter::GetInstance(); RootView::GetInstance()->SetOnKeyActListener(keyactListener); } } + bool ThunderBirdMainView::SwitchVideo(const char *uri) + { + if (uri == nullptr || surfaceView_ == nullptr) { + return false; + } + // 停止并销毁旧播放器 + if (videoPlay_ != nullptr) + { + if (videoPlay_->isPlayed_) { + videoPlay_->PauseVideoPlay(); + } + if (videoPlay_->isEntered_) { + videoPlay_->StopVideoPlay(); + } + delete videoPlay_; + videoPlay_ = nullptr; + } + + Surface *surface = surfaceView_->GetSurface(); + if (surface == nullptr) { + return false; + } + + // 创建新播放器并启动 + videoPlay_ = new MediaVideoPlay(surface, nullptr, std::string(uri), false); + if (videoPlay_ == nullptr) { + return false; + } + g_videoPlay = videoPlay_; + int32_t ret = videoPlay_->StartVideoPlay(); + return (ret == 0); + } bool ThunderBirdMainView::ChangeThunderBirdView(int16_t thisView) { // 检查视图是否已初始化 @@ -407,7 +415,7 @@ namespace OHOS return false; } - void ThunderBirdMainView::ChangeView(int16_t hideView, int16_t showView) + void ThunderBirdMainView::ChangeView(int16_t hideView, int16_t showView, int16_t subView) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::ChangeView"); if (hideView > MAXVIEW) @@ -425,7 +433,41 @@ namespace OHOS } ClickFunc(showView); group[showView]->SetVisible(true); + group[showView]->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + // 进入大界面后,根据 subView 跳转到其子界面 + if (subView != -1) + { + switch (showView) + { + case THUNDERBIRD_GUIDEVIEW: + if (g_pThunderBirdGuideView) + { + g_pThunderBirdGuideView->Show(subView); + } + break; + case THUNDERBIRD_LULLABYVIEW: + if (g_pThunderBirdLullabyView) + { + g_pThunderBirdLullabyView->Show(subView); + } + break; + default: + break; + } + } + currentView_ = showView;//更新当前视图 + currentSubView_ = subView;//更新当前子视图 ScrollView_->Invalidate(); + + } + + int16_t ThunderBirdMainView::GetCurrentView() const + { + return currentView_; + } + int16_t ThunderBirdMainView::GetCurrentSubView() const + { + return currentSubView_; } void ThunderBirdMainView::Initback() @@ -494,7 +536,7 @@ namespace OHOS return; } } - group1->SetPosition(80, 30, 302, 40); + group1->SetPosition(70, 40, 350, 40); group1->SetStyle(STYLE_BACKGROUND_OPA, 0); InitLabel(timeLabel, 0, (group1->GetHeight() - 38), 175, 38, "titleLable", "08:52", DEFAULT_VECTOR_FONT_FILENAME, 32); @@ -510,7 +552,7 @@ namespace OHOS return; } } - NoSignal->SetPosition(148, (group1->GetHeight() - 38) / 2, 36, 38); + NoSignal->SetPosition(140, (group1->GetHeight() - 38) / 2, 36, 38); NoSignal->SetAutoEnable(false); NoSignal->SetResizeMode(UIImageView::CENTER); NoSignal->SetSrc(DROPDOWN_NOSIGNAL_IMAGE); @@ -527,10 +569,10 @@ namespace OHOS }; // 待添加的 ImageView 信息列表 std::vector imageViewList = { - {148, 28, 6, 6}, - {158, 20, 6, 14}, - {168, 12, 6, 22}, - {178, 4, 6, 30}, + {140, 28, 6, 6}, + {150, 20, 6, 14}, + {160, 12, 6, 22}, + {170, 4, 6, 30}, }; // 循环添加 ImageView 到相应的容器中 @@ -559,7 +601,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryimage new fail"); return; } - batteryimage->SetPosition(178 + 20, (group1->GetHeight() - 30) / 2, 48, 30); + batteryimage->SetPosition(170 + 20, (group1->GetHeight() - 30) / 2, 48, 30); std::string batteryimagesPath = "/user/res/Battery_White.bin"; batteryimage->SetSrc(batteryimagesPath.c_str()); group1->Add(batteryimage); @@ -582,8 +624,8 @@ namespace OHOS progress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45A5FF); group1->Add(progress); /* -----------------------------------电量--------------------------------------- */ - InitUILabel(batteryLabel, progress->GetX() + 8, batteryimage->GetY() + 6, 30, 22, "titleLable", "100", DEFAULT_VECTOR_FONT_FILENAME, 15); - batteryLabel->SetStyle(STYLE_TEXT_COLOR, 0xff000000); + InitUILabel(batteryLabel, batteryimage->GetX() + 58, (group1->GetHeight() - 28) / 2, 30, 28, "titleLable", "100", DEFAULT_VECTOR_FONT_FILENAME, 25); + batteryLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full); batteryLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT); group1->Add(batteryLabel); /* ----------------------------------充电图标-------------------------------------- */ @@ -593,7 +635,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "chargeBatteryicon creation failed"); return; } - chargeBatteryicon->SetPosition(batteryLabel->GetX() + 10, batteryimage->GetY() + 2, 17, 22); + chargeBatteryicon->SetPosition(progress->GetX() + 6, batteryimage->GetY() + 2, 17, 26); chargeBatteryicon->SetSrc("/user/res/Icon.bin"); chargeBatteryicon->SetAutoEnable(false); chargeBatteryicon->SetResizeMode(UIImageView::CONTAIN); @@ -700,7 +742,7 @@ namespace OHOS value = battery_get_voltage(&voltage); #endif WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "battery_get_voltage = %d", value); - batteryLabel->SetText(std::to_string(static_cast(value)).c_str()); // 电量 + batteryLabel->SetText((std::to_string(static_cast(value))+"%").c_str()); // 电量 progress->SetValue(value); if (!chargeBatteryicon || !progress) @@ -718,8 +760,6 @@ namespace OHOS { if (!isChargeBatteryIconVisible) { - batteryLabel->SetX(progress->GetX() + 1); // 电量 - batteryLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full); // 充电电量为白色 chargeBatteryicon->SetVisible(true); // 充电图标 isChargeBatteryIconVisible = true; } @@ -732,8 +772,6 @@ namespace OHOS { if (isChargeBatteryIconVisible) { - batteryLabel->SetX(progress->GetX() + 8); // 回到原来位置 - batteryLabel->SetStyle(STYLE_TEXT_COLOR, Color::Black().full); // 不充电电量为黑色 chargeBatteryicon->SetVisible(false); // 充电图标 isChargeBatteryIconVisible = false; } @@ -744,8 +782,6 @@ namespace OHOS { if (isChargeBatteryIconVisible) { - batteryLabel->SetX(progress->GetX() + 8); // 回到原来位置 - batteryLabel->SetStyle(STYLE_TEXT_COLOR, Color::Black().full); // 不充电电量为黑色 chargeBatteryicon->SetVisible(false); // 充电图标 isChargeBatteryIconVisible = false; } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp index db9cb1199..b440ba499 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp @@ -82,7 +82,47 @@ namespace OHOS // 如果是power键就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) { - NativeAbility::GetInstance().Back(); + int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView(); + int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView(); + if(currentView == THUNDERBIRD_GUIDEVIEW) + { + if(currentSubView == 0) + { + ThunderBirdMainView::GetInstance()->ChangeView(currentView,THUNDERBIRD_GUIDEVIEW,1); + } + else if(currentSubView == 1) + { + ThunderBirdMainView::GetInstance()->ChangeView(currentView,THUNDERBIRD_GUIDEVIEW,2); + } + else if(currentSubView == 2) + { + ThunderBirdMainView::GetInstance()->ChangeView(currentView,THUNDERBIRD_LULLABYVIEW,0); + } + } + else if(currentView == THUNDERBIRD_LULLABYVIEW) + { + if(currentSubView == 0) + { + ThunderBirdMainView::GetInstance()->ChangeView(currentView,THUNDERBIRD_LULLABYVIEW,1); + } + else if(currentSubView == 1) + { + ThunderBirdMainView::GetInstance()->ChangeView(currentView,THUNDERBIRD_LULLABYVIEW,2); + } + else if(currentSubView == 2) + { + ThunderBirdMainView::GetInstance()->ChangeView(currentView,THUNDERBIRD_LULLABYVIEW,3); + } + else if(currentSubView == 3) + { + ThunderBirdMainView::GetInstance()->ChangeView(currentView,THUNDERBIRD_LULLABYVIEW,4); + } + } + //NativeAbility::GetInstance().Back(); + } + if(keyID == static_cast(ZliteKeyCode::ZLITE_KEY_FUNC) && keyState == 1 && uapi_get_screen_state() == 0) + { + ThunderBirdMainView::GetInstance()->SwitchVideo("/user/video/46x46_shocked.mp4"); } return true; } -- 2.17.1