--- /dev/null
+#ifndef THUNDERBIRD_ADJUST_VIEW_H_
+#define THUNDERBIRD_ADJUST_VIEW_H_
+
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "components/ui_label_ext.h"
+
+namespace OHOS
+{
+ class ThunderBirdAdjustView
+ {
+ public:
+ ThunderBirdAdjustView();
+ virtual ~ThunderBirdAdjustView();
+ static ThunderBirdAdjustView *GetInstance(void);
+ UIViewGroup *ThunderBirdAdjustViewInit(void);
+ void ClearAll(void);
+
+ private:
+ UIViewGroup *group{nullptr};
+ UILabelExt *titleLabel{nullptr};
+ };
+}
+
+#endif
+
--- /dev/null
+#ifndef THUNDERBIRD_DIALOGUE_VIEW_H_
+#define THUNDERBIRD_DIALOGUE_VIEW_H_
+
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "components/ui_label_ext.h"
+
+namespace OHOS
+{
+ class ThunderBirdDialogueView
+ {
+ public:
+ ThunderBirdDialogueView();
+ virtual ~ThunderBirdDialogueView();
+ static ThunderBirdDialogueView *GetInstance(void);
+ UIViewGroup *ThunderBirdDialogueViewInit(void);
+ void ClearAll(void);
+
+ private:
+ UIViewGroup *group{nullptr};
+ UILabelExt *titleLabel{nullptr};
+ };
+}
+
+#endif
+
--- /dev/null
+#ifndef THUNDERBIRD_GUIDE_VIEW_H_
+#define THUNDERBIRD_GUIDE_VIEW_H_
+
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "components/ui_label_ext.h"
+
+namespace OHOS
+{
+ class ThunderBirdGuideView
+ {
+ public:
+ ThunderBirdGuideView();
+ virtual ~ThunderBirdGuideView();
+ static ThunderBirdGuideView *GetInstance(void);
+ UIViewGroup *ThunderBirdGuideViewInit(void);
+ void ClearAll(void);
+
+ private:
+ UIViewGroup *group{nullptr};
+ UILabelExt *titleLabel{nullptr};
+ };
+}
+
+#endif
+
--- /dev/null
+#ifndef THUNDERBIRD_LULLABY_VIEW_H_
+#define THUNDERBIRD_LULLABY_VIEW_H_
+
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "components/ui_label_ext.h"
+
+namespace OHOS
+{
+ class ThunderBirdLullabyView
+ {
+ public:
+ ThunderBirdLullabyView();
+ virtual ~ThunderBirdLullabyView();
+ static ThunderBirdLullabyView *GetInstance(void);
+ UIViewGroup *ThunderBirdLullabyViewInit(void);
+ void ClearAll(void);
+
+ private:
+ UIViewGroup *group{nullptr};
+ UILabelExt *titleLabel{nullptr};
+ };
+}
+
+#endif
+
--- /dev/null
+
+
+#ifndef BP_MAIN_VIEW_H
+#define BP_MAIN_VIEW_H
+
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "thunderbird/include/ThunderBirdView.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/ThunderBirdOtaView.h"
+#include "thunderbird/include/ThunderBirdGuideView.h"
+#include "thunderbird/include/ThunderBirdLullabyView.h"
+#include "thunderbird/include/ThunderBirdDialogueView.h"
+#include "thunderbird/include/ThunderBirdReminderView.h"
+#include "thunderbird/include/ThunderBirdAdjustView.h"
+namespace OHOS
+{
+ static constexpr const char *DROPDOWN_NOSIGNAL_IMAGE = "/user/res/dropdown/DROPDOWN_NOSIGNAL.bin";
+
+ typedef enum : uint8_t
+ {
+ THUNDERBIRDMENUVIEW = 0, // 主界面
+ THUNDERBIRD_OTAVIEW,
+ THUNDERBIRD_GUIDEVIEW,
+ THUNDERBIRD_LULLABYVIEW,
+ THUNDERBIRD_DIALOGUEVIEW,
+ THUNDERBIRD_REMINDERVIEW,
+ THUNDERBIRD_ADJUSTVIEW,
+ MAXVIEW
+ } BPVIEWID;
+
+ class ThunderBirdPresenter;
+ class ThunderBirdMainView : public View<ThunderBirdPresenter>
+ {
+ public:
+ ThunderBirdMainView();
+ virtual ~ThunderBirdMainView();
+ static ThunderBirdMainView *GetInstance(void);
+ void OnStart() override;
+
+ bool ChangeThunderBirdView(int16_t);
+ bool ChangeThunderBirdOtaView(int16_t);
+ bool ChangeThunderBirdGuideView(int16_t);
+ bool ChangeThunderBirdLullabyView(int16_t);
+ 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 UpdateBatteryProcess();
+ void updateSignalDisplay();
+ void UpdateSignalBarDisplay(int signalBars, bool state);
+ int CalculateSignalBars(int signalStrength);
+ void UpdateTimeText(const char *time);
+ void Initback();
+ void InitBaseData();
+
+ 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};
+
+ UIImageView *curFace{nullptr};
+ DialVideoView *videoPlayer_ = nullptr;
+ UILiteSurfaceView *surfaceView_ = nullptr;
+ MediaVideoPlay *video_ = nullptr;
+ MediaVideoPlay *videoPlay_ = nullptr;
+ ColorType colorKey_;
+
+ UIViewGroup *group1{nullptr};
+ UILabelExt *timeLabel{nullptr};
+ UIImageView *showSignalStrength[4]{nullptr}; // 信号强度
+ UIImageView *NoSignal{nullptr}; // 无信号
+ UIImageView *batteryimage{nullptr}; // 电池图片
+ UILabel *batteryLabel{nullptr}; // 电池电量
+ UIBoxProgress *progress{nullptr}; // 电池进度条
+ UIImageView *chargeBatteryicon{nullptr}; // 充电图标
+ bool isChargeBatteryIconVisible{false}; // 充电图标是否可见
+ };
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef THUNDERBIRD_OTA_VIEW_H_
+#define THUNDERBIRD_OTA_VIEW_H_
+
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "components/ui_label_ext.h"
+
+namespace OHOS
+{
+ class ThunderBirdOtaView
+ {
+ public:
+ ThunderBirdOtaView();
+ virtual ~ThunderBirdOtaView();
+ static ThunderBirdOtaView *GetInstance(void);
+ UIViewGroup *ThunderBirdOtaViewInit(void);
+ void ClearAll(void);
+
+ private:
+ UIViewGroup *group{nullptr};
+ UILabelExt *titleLabel{nullptr};
+ };
+}
+
+#endif
+
#ifndef THUNDERBIRD_PRESENTER_H
#define THUNDERBIRD_PRESENTER_H
-#include "thunderbird/include/ThunderBirdView.h"
+#include "thunderbird/include/ThunderBirdMainView.h"
#include "key/include/KeyInputListener.h"
#include "Presenter.h"
#include "View.h"
namespace OHOS
{
- class ThunderBirdView;
- class ThunderBirdPresenter : public Presenter<ThunderBirdView>,
+ class ThunderBirdMainView;
+ class ThunderBirdPresenter : public Presenter<ThunderBirdMainView>,
public UIView::OnClickListener,
public RootView::OnKeyActListener,
public UIView::OnDragListener
--- /dev/null
+#ifndef THUNDERBIRD_REMINDER_VIEW_H_
+#define THUNDERBIRD_REMINDER_VIEW_H_
+
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "components/ui_label_ext.h"
+
+namespace OHOS
+{
+ class ThunderBirdReminderView
+ {
+ public:
+ ThunderBirdReminderView();
+ virtual ~ThunderBirdReminderView();
+ static ThunderBirdReminderView *GetInstance(void);
+ UIViewGroup *ThunderBirdReminderViewInit(void);
+ void ClearAll(void);
+
+ private:
+ UIViewGroup *group{nullptr};
+ UILabelExt *titleLabel{nullptr};
+ };
+}
+
+#endif
+
#include "View.h"
#include "components/ui_scroll_view.h"
-#include "video_play_wrapper.h"
-#include "/home/maomao/FD230/FD230_650/FD230/code/sdk/application/wearable/nativeapp/nativeui/include/main/dial/DialVideoView.h"
-#include "animator/animator_manager.h"
#include "components/ui_view_group.h"
-#include "components/ui_image_animator.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
namespace OHOS
{
- class ThunderBirdPresenter;
- class ThunderBirdView : public View<ThunderBirdPresenter>
+ class ThunderBirdView
{
public:
ThunderBirdView();
virtual ~ThunderBirdView();
static ThunderBirdView *GetInstance(void);
-
- void OnStart() override;
+ UIViewGroup *ThunderBirdViewInit(void);
+
+ void InitBlackGround();
+ void InitText();
+ void ClearAll(void);
private:
- UIScrollView *ScrollView_{nullptr};
- UIScrollView * ThunderBirdViewInit(void);
- void ClearAll(void);
- UIImageView *curFace{nullptr};
- DialVideoView *videoPlayer_ = nullptr;
- UILiteSurfaceView *surfaceView_ = nullptr;
- MediaVideoPlay *video_ = nullptr;
- MediaVideoPlay *videoPlay_ = nullptr;
- ColorType colorKey_;
+ UIViewGroup *group{nullptr};
+
+
+ UIImageView *ground{nullptr};
+
+ UILabelExt *TextLabel{nullptr};
+ UILabelExt *RemindLabel{nullptr};
+ UIImageView *Remindground{nullptr};
#define SCREEN_WIDTH (Screen::GetInstance().GetWidth())
#define SCREEN_HEIGHT (Screen::GetInstance().GetHeight())
--- /dev/null
+#include "thunderbird/include/ThunderBirdAdjustView.h"
+#include "wearable_log.h"
+
+namespace OHOS
+{
+ static ThunderBirdAdjustView *g_pThunderBirdAdjustView{nullptr};
+
+ ThunderBirdAdjustView::ThunderBirdAdjustView()
+ {
+ g_pThunderBirdAdjustView = this;
+ }
+
+ ThunderBirdAdjustView::~ThunderBirdAdjustView()
+ {
+ g_pThunderBirdAdjustView = nullptr;
+ ClearAll();
+ }
+
+ ThunderBirdAdjustView *ThunderBirdAdjustView::GetInstance(void)
+ {
+ return g_pThunderBirdAdjustView;
+ }
+
+ void ThunderBirdAdjustView::ClearAll(void)
+ {
+ if (group != nullptr)
+ {
+ group->RemoveAll();
+ delete group;
+ group = nullptr;
+ }
+ if (titleLabel != nullptr)
+ {
+ delete titleLabel;
+ titleLabel = nullptr;
+ }
+ }
+
+ UIViewGroup *ThunderBirdAdjustView::ThunderBirdAdjustViewInit(void)
+ {
+ group = new UIViewGroup();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdAdjustView::group null!");
+ return nullptr;
+ }
+ group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+
+ titleLabel = new UILabelExt();
+ if (titleLabel != nullptr)
+ {
+ titleLabel->SetPosition(20, 20, 300, 40);
+ titleLabel->SetText("调节界面");
+ group->Add(titleLabel);
+ }
+
+ return group;
+ }
+}
+
+
--- /dev/null
+#include "thunderbird/include/ThunderBirdDialogueView.h"
+#include "wearable_log.h"
+
+namespace OHOS
+{
+ static ThunderBirdDialogueView *g_pThunderBirdDialogueView{nullptr};
+
+ ThunderBirdDialogueView::ThunderBirdDialogueView()
+ {
+ g_pThunderBirdDialogueView = this;
+ }
+
+ ThunderBirdDialogueView::~ThunderBirdDialogueView()
+ {
+ g_pThunderBirdDialogueView = nullptr;
+ ClearAll();
+ }
+
+ ThunderBirdDialogueView *ThunderBirdDialogueView::GetInstance(void)
+ {
+ return g_pThunderBirdDialogueView;
+ }
+
+ void ThunderBirdDialogueView::ClearAll(void)
+ {
+ if (group != nullptr)
+ {
+ group->RemoveAll();
+ delete group;
+ group = nullptr;
+ }
+ if (titleLabel != nullptr)
+ {
+ delete titleLabel;
+ titleLabel = nullptr;
+ }
+ }
+
+ UIViewGroup *ThunderBirdDialogueView::ThunderBirdDialogueViewInit(void)
+ {
+ group = new UIViewGroup();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdDialogueView::group null!");
+ return nullptr;
+ }
+ group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+
+ titleLabel = new UILabelExt();
+ if (titleLabel != nullptr)
+ {
+ titleLabel->SetPosition(20, 20, 300, 40);
+ titleLabel->SetText("对话界面");
+ group->Add(titleLabel);
+ }
+
+ return group;
+ }
+}
+
+
--- /dev/null
+#include "thunderbird/include/ThunderBirdGuideView.h"
+#include "wearable_log.h"
+
+namespace OHOS
+{
+ static ThunderBirdGuideView *g_pThunderBirdGuideView{nullptr};
+
+ ThunderBirdGuideView::ThunderBirdGuideView()
+ {
+ g_pThunderBirdGuideView = this;
+ }
+
+ ThunderBirdGuideView::~ThunderBirdGuideView()
+ {
+ g_pThunderBirdGuideView = nullptr;
+ ClearAll();
+ }
+
+ ThunderBirdGuideView *ThunderBirdGuideView::GetInstance(void)
+ {
+ return g_pThunderBirdGuideView;
+ }
+
+ void ThunderBirdGuideView::ClearAll(void)
+ {
+ if (group != nullptr)
+ {
+ group->RemoveAll();
+ delete group;
+ group = nullptr;
+ }
+ if (titleLabel != nullptr)
+ {
+ delete titleLabel;
+ titleLabel = nullptr;
+ }
+ }
+
+ UIViewGroup *ThunderBirdGuideView::ThunderBirdGuideViewInit(void)
+ {
+ group = new UIViewGroup();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdGuideView::group null!");
+ return nullptr;
+ }
+ group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+
+ titleLabel = new UILabelExt();
+ if (titleLabel != nullptr)
+ {
+ titleLabel->SetPosition(20, 20, 300, 40);
+ titleLabel->SetText("新手引导");
+ group->Add(titleLabel);
+ }
+
+ return group;
+ }
+}
+
+
--- /dev/null
+#include "thunderbird/include/ThunderBirdLullabyView.h"
+#include "wearable_log.h"
+
+namespace OHOS
+{
+ static ThunderBirdLullabyView *g_pThunderBirdLullabyView{nullptr};
+
+ ThunderBirdLullabyView::ThunderBirdLullabyView()
+ {
+ g_pThunderBirdLullabyView = this;
+ }
+
+ ThunderBirdLullabyView::~ThunderBirdLullabyView()
+ {
+ g_pThunderBirdLullabyView = nullptr;
+ ClearAll();
+ }
+
+ ThunderBirdLullabyView *ThunderBirdLullabyView::GetInstance(void)
+ {
+ return g_pThunderBirdLullabyView;
+ }
+
+ void ThunderBirdLullabyView::ClearAll(void)
+ {
+ if (group != nullptr)
+ {
+ group->RemoveAll();
+ delete group;
+ group = nullptr;
+ }
+ if (titleLabel != nullptr)
+ {
+ delete titleLabel;
+ titleLabel = nullptr;
+ }
+ }
+
+ UIViewGroup *ThunderBirdLullabyView::ThunderBirdLullabyViewInit(void)
+ {
+ group = new UIViewGroup();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView::group null!");
+ return nullptr;
+ }
+ group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+
+ titleLabel = new UILabelExt();
+ if (titleLabel != nullptr)
+ {
+ titleLabel->SetPosition(20, 20, 300, 40);
+ titleLabel->SetText("哄睡界面");
+ group->Add(titleLabel);
+ }
+
+ return group;
+ }
+}
+
+
--- /dev/null
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-31 14:36:25
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodpressure/src/ThunderBirdMainView.cpp
+ */
+
+#include "common/image_cache_manager.h"
+#include "ui_resource_image.h"
+#include <ui_scroll_view.h>
+#include "components/ui_button.h"
+#include "MainViewSample.h"
+#include "components/ui_view_group.h"
+
+#include "UiConfig.h"
+#include "uicomponents/UIComponents.h"
+#include "MainPresenterSample.h"
+#include "thunderbird/include/ThunderBirdMainView.h"
+
+#include "wearable_log.h"
+
+#include "screennotify/include/ui_screennotify.h"
+#include "custom_utils.h"
+#include <unistd.h>
+#include <sys/stat.h>
+#include "battery_hal.h"
+#include "battery_service.h"
+#include "custom_runtime.h"
+namespace OHOS
+{
+ static constexpr int16_t VIDEO_WIDTH = 466;
+ static constexpr int16_t VIDEO_HEIGHT = 466;
+ static constexpr int16_t STRIDE_ALIGNMENT_VALUE = 128;
+ static constexpr int16_t JPEG_WIDTH_BYTE_ALIGNMENT = 128;
+ static constexpr int16_t JPEG_HEIGHT_BYTE_ALIGNMENT = 16;
+ static constexpr int16_t BUFFER_QUEUE_SIZE = 2;
+ static constexpr int16_t JPEG_HEIGHT_DIVISOR = 2;
+
+ 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)
+ {
+ if (g_videoPlay == nullptr)
+ {
+ return;
+ }
+
+ bool temp = g_videoPlay->isPlayed_;
+ if (status == SCREEN_STATUS_OFF && g_videoPlay->isPlayed_)
+ {
+ g_videoPlay->PauseVideoPlay();
+ }
+ else if (status == SCREEN_STATUS_ON)
+ {
+ if (g_lastPlayed && g_videoPlay->isPause_)
+ {
+ g_videoPlay->ResumeVideoPlay();
+ }
+ }
+ g_lastPlayed = temp;
+ }
+ static ThunderBirdMainView *g_pThunderBirdMainView{nullptr};
+
+ ThunderBirdMainView::ThunderBirdMainView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::ThunderBirdMainView");
+ g_pThunderBirdMainView = this;
+ ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 打开屏幕常亮
+ ThunderBirdModel::GetInstance()->StartTimer();
+ }
+
+ ThunderBirdMainView::~ThunderBirdMainView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::~ThunderBirdMainView");
+ DeInit();
+ if (ScrollView_ != nullptr)
+ {
+ ScrollView_->RemoveAll();
+ delete ScrollView_;
+ ScrollView_ = nullptr;
+ }
+ g_pThunderBirdMainView = nullptr;
+ ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 关闭屏幕常亮
+ ThunderBirdModel::GetInstance()->StopTimer();
+ }
+
+ ThunderBirdMainView *ThunderBirdMainView::GetInstance()
+ {
+ return g_pThunderBirdMainView;
+ }
+
+ 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)
+ {
+ delete g_pThunderBirdAdjustView;
+ g_pThunderBirdAdjustView = nullptr;
+ }
+ // 先停止视频播放
+ if (videoPlay_ != nullptr)
+ {
+ if (videoPlay_->isPlayed_)
+ {
+ videoPlay_->PauseVideoPlay();
+ }
+ if (videoPlay_->isEntered_)
+ {
+ videoPlay_->StopVideoPlay();
+ }
+ delete videoPlay_;
+ videoPlay_ = nullptr;
+ }
+ // 清理全局变量
+ g_videoPlay = nullptr;
+ g_lastPlayed = false;
+
+ // 注销屏幕状态通知
+ deregisterNotifyScreenStatus(ScreenStatusNotify);
+
+ if (curFace != nullptr)
+ {
+ delete curFace;
+ curFace = nullptr;
+ }
+
+ if (surfaceView_ != nullptr)
+ {
+ delete surfaceView_;
+ surfaceView_ = nullptr;
+ }
+
+ // 清理顶部状态UI group1 及其子控件
+ if (group1 != nullptr)
+ {
+ if (timeLabel != nullptr)
+ {
+ delete timeLabel;
+ timeLabel = nullptr;
+ }
+ for (int i = 0; i < 4; i++)
+ {
+ if (showSignalStrength[i] != nullptr)
+ {
+ delete showSignalStrength[i];
+ showSignalStrength[i] = nullptr;
+ }
+ }
+ if (NoSignal != nullptr)
+ {
+ delete NoSignal;
+ NoSignal = nullptr;
+ }
+ if (batteryimage != nullptr)
+ {
+ delete batteryimage;
+ batteryimage = nullptr;
+ }
+ if (batteryLabel != nullptr)
+ {
+ delete batteryLabel;
+ batteryLabel = nullptr;
+ }
+ if (progress != nullptr)
+ {
+ delete progress;
+ progress = nullptr;
+ }
+ if (chargeBatteryicon != nullptr)
+ {
+ delete chargeBatteryicon;
+ chargeBatteryicon = nullptr;
+ }
+ group1->RemoveAll();
+ delete group1;
+ group1 = nullptr;
+ }
+
+ // 清理其他成员变量
+ video_ = nullptr;
+ videoPlayer_ = nullptr;
+
+ // 置空所有分组索引,避免悬空指针
+ for (int i = 0; i < MAXVIEW; i++)
+ {
+ group[i] = nullptr;
+ }
+ }
+
+ void ThunderBirdMainView::OnStart()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::OnStart");
+ View<ThunderBirdPresenter>::OnStart();
+ GetRootContainer()->SetTouchable(true);
+ GetRootContainer()->SetDraggable(true);
+ if (nullptr == ScrollView_)
+ {
+ ScrollView_ = new UIScrollView();
+ if (nullptr == ScrollView_)
+ return;
+
+ ScrollView_->SetScrollBlankSize(35);
+ ScrollView_->SetReboundSize(50);
+ ScrollView_->SetPosition(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ // ScrollView_->SetViewId();
+ ScrollView_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
+ ScrollView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+ ScrollView_->SetOnDragListener(presenter_);
+ ScrollView_->SetTouchable(true);
+ ScrollView_->SetDraggable(true);
+ AddViewToRootContainer(ScrollView_);
+ RootView::GetInstance()->SetOnKeyActListener(presenter_);
+ ChangeView(MAXVIEW, THUNDERBIRDMENUVIEW);
+
+ Initback();
+ InitBaseData();
+ // 增加按键监听
+ RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::ThunderBirdPresenter::GetInstance();
+ RootView::GetInstance()->SetOnKeyActListener(keyactListener);
+ }
+ }
+
+ bool ThunderBirdMainView::ChangeThunderBirdView(int16_t thisView)
+ {
+ // 检查视图是否已初始化
+ if (group[thisView] == nullptr)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodPressureView::ChangeUnderInitialCalibrationView");
+ g_pThunderBirdView = new ThunderBirdView();
+ if (g_pThunderBirdView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodPressureView:: new scrollView[%d] fail", thisView);
+ return false;
+ }
+ // 初始化视图并添加到视图组
+ group[thisView] = g_pThunderBirdView->ThunderBirdViewInit();
+ ScrollView_->Add(group[thisView]);
+ }
+ return true;
+ }
+
+ bool ThunderBirdMainView::ChangeThunderBirdOtaView(int16_t thisView)
+ {
+ if (group[thisView] == nullptr)
+ {
+ g_pThunderBirdOtaView = new ThunderBirdOtaView();
+ if (g_pThunderBirdOtaView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdOtaView new fail %d", thisView);
+ return false;
+ }
+ group[thisView] = g_pThunderBirdOtaView->ThunderBirdOtaViewInit();
+ ScrollView_->Add(group[thisView]);
+ }
+ return true;
+ }
+
+ bool ThunderBirdMainView::ChangeThunderBirdGuideView(int16_t thisView)
+ {
+ if (group[thisView] == nullptr)
+ {
+ g_pThunderBirdGuideView = new ThunderBirdGuideView();
+ if (g_pThunderBirdGuideView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdGuideView new fail %d", thisView);
+ return false;
+ }
+ group[thisView] = g_pThunderBirdGuideView->ThunderBirdGuideViewInit();
+ ScrollView_->Add(group[thisView]);
+ }
+ return true;
+ }
+
+ bool ThunderBirdMainView::ChangeThunderBirdLullabyView(int16_t thisView)
+ {
+ if (group[thisView] == nullptr)
+ {
+ g_pThunderBirdLullabyView = new ThunderBirdLullabyView();
+ if (g_pThunderBirdLullabyView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView new fail %d", thisView);
+ return false;
+ }
+ group[thisView] = g_pThunderBirdLullabyView->ThunderBirdLullabyViewInit();
+ ScrollView_->Add(group[thisView]);
+ }
+ return true;
+ }
+
+ bool ThunderBirdMainView::ChangeThunderBirdDialogueView(int16_t thisView)
+ {
+ if (group[thisView] == nullptr)
+ {
+ g_pThunderBirdDialogueView = new ThunderBirdDialogueView();
+ if (g_pThunderBirdDialogueView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdDialogueView new fail %d", thisView);
+ return false;
+ }
+ group[thisView] = g_pThunderBirdDialogueView->ThunderBirdDialogueViewInit();
+ ScrollView_->Add(group[thisView]);
+ }
+ return true;
+ }
+
+ bool ThunderBirdMainView::ChangeThunderBirdReminderView(int16_t thisView)
+ {
+ if (group[thisView] == nullptr)
+ {
+ g_pThunderBirdReminderView = new ThunderBirdReminderView();
+ if (g_pThunderBirdReminderView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdReminderView new fail %d", thisView);
+ return false;
+ }
+ group[thisView] = g_pThunderBirdReminderView->ThunderBirdReminderViewInit();
+ ScrollView_->Add(group[thisView]);
+ }
+ return true;
+ }
+
+ bool ThunderBirdMainView::ChangeThunderBirdAdjustView(int16_t thisView)
+ {
+ if (group[thisView] == nullptr)
+ {
+ g_pThunderBirdAdjustView = new ThunderBirdAdjustView();
+ if (g_pThunderBirdAdjustView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdAdjustView new fail %d", thisView);
+ return false;
+ }
+ group[thisView] = g_pThunderBirdAdjustView->ThunderBirdAdjustViewInit();
+ ScrollView_->Add(group[thisView]);
+ }
+ return true;
+ }
+
+ /**
+ * 视图映射结构体 - 将视图ID映射到对应的视图切换函数
+ */
+ struct TBViewMapper
+ {
+ const int16_t viewId; // 视图ID
+ bool (ThunderBirdMainView::*func)(int16_t); // 对应的视图切换函数指针
+ };
+
+ static const TBViewMapper ViewMapper[] = {
+ {THUNDERBIRDMENUVIEW, &ThunderBirdMainView::ChangeThunderBirdView},
+ {THUNDERBIRD_OTAVIEW, &ThunderBirdMainView::ChangeThunderBirdOtaView},
+ {THUNDERBIRD_GUIDEVIEW, &ThunderBirdMainView::ChangeThunderBirdGuideView},
+ {THUNDERBIRD_LULLABYVIEW, &ThunderBirdMainView::ChangeThunderBirdLullabyView},
+ {THUNDERBIRD_DIALOGUEVIEW, &ThunderBirdMainView::ChangeThunderBirdDialogueView},
+ {THUNDERBIRD_REMINDERVIEW, &ThunderBirdMainView::ChangeThunderBirdReminderView},
+ {THUNDERBIRD_ADJUSTVIEW, &ThunderBirdMainView::ChangeThunderBirdAdjustView},
+ };
+
+ bool ThunderBirdMainView::ClickFunc(int16_t interface)
+ {
+ int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]);
+
+ for (int i = 0; i < funcSize; i++)
+ {
+ if (interface == ViewMapper[i].viewId)
+ {
+ bool jug = (this->*(ViewMapper[i].func))(interface);
+ if (jug == false)
+ {
+ return false;
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ void ThunderBirdMainView::ChangeView(int16_t hideView, int16_t showView)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::ChangeView");
+ if (hideView > MAXVIEW)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView:: SystemViewId Overstep ones bounds");
+ return;
+ }
+ if (hideView != MAXVIEW)
+ {
+ if (group[hideView] == nullptr)
+ {
+ return;
+ }
+ group[hideView]->SetVisible(false);
+ }
+ ClickFunc(showView);
+ group[showView]->SetVisible(true);
+ ScrollView_->Invalidate();
+ }
+
+ void ThunderBirdMainView::Initback()
+ {
+ curFace = new UIImageView();
+ if (curFace == nullptr)
+ {
+ return;
+ }
+ curFace->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ curFace->SetSrc("/user/res/ThunderBird/hair.bin");
+
+ surfaceView_ = new UILiteSurfaceView();
+ if (surfaceView_ == nullptr)
+ {
+ GRAPHIC_LOGE("surfaceView is nullptr\n");
+ return;
+ }
+ colorKey_.full = 0xff202020;
+ surfaceView_->SetViewId("sur");
+ surfaceView_->SetPosition(0, 0, VIDEO_WIDTH, VIDEO_HEIGHT);
+ surfaceView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+ surfaceView_->SetSurfaceColorkey(colorKey_);
+
+ Surface *surface = surfaceView_->GetSurface();
+ surface->SetStrideAlignment(STRIDE_ALIGNMENT_VALUE);
+ surface->SetWidthAndHeight(VIDEO_WIDTH, VIDEO_HEIGHT);
+ surface->SetQueueSize(BUFFER_QUEUE_SIZE);
+ surface->SetFormat(PIXEL_FMT_YCBCR_420_SP);
+
+ // jpeg decoder output buffer size calculation formula
+ int32_t ySize = ALIGN_BYTE(VIDEO_WIDTH, JPEG_WIDTH_BYTE_ALIGNMENT) * VIDEO_HEIGHT;
+ int32_t uvSize = ALIGN_BYTE(VIDEO_WIDTH, JPEG_WIDTH_BYTE_ALIGNMENT) *
+ ALIGN_BYTE(VIDEO_HEIGHT, JPEG_HEIGHT_BYTE_ALIGNMENT) / JPEG_HEIGHT_DIVISOR;
+ int32_t bufferSize = ySize + uvSize;
+ surface->SetSize(bufferSize);
+ if (videoPlay_ == nullptr)
+ {
+ std::string uri("/user/video/thunderbird.mp4");
+ videoPlay_ = new MediaVideoPlay(surface, nullptr, uri, false);
+ if (videoPlay_ == nullptr)
+ {
+ GRAPHIC_LOGE("videoPlay_ is nullptr\n");
+ return;
+ }
+ g_videoPlay = videoPlay_;
+ registerNotifyScreenStatus(ScreenStatusNotify);
+ }
+ if (videoPlay_->isExited_ || !videoPlay_->isEntered_)
+ {
+ videoPlay_->StartVideoPlay();
+ }
+
+ ScrollView_->Add(surfaceView_);
+ ScrollView_->Add(curFace);
+ }
+ void ThunderBirdMainView::InitBaseData()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::InitBaseData");
+ if (group1 == nullptr)
+ {
+ group1 = new UIViewGroup();
+ if (group1 == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group1 new fail");
+ return;
+ }
+ }
+ group1->SetPosition(80, 30, 302, 40);
+ group1->SetStyle(STYLE_BACKGROUND_OPA, 0);
+
+ InitLabel(timeLabel, 0, (group1->GetHeight() - 38), 175, 38, "titleLable", "08:52", DEFAULT_VECTOR_FONT_FILENAME, 32);
+ timeLabel->SetText(ThunderBirdModel::GetInstance()->GetCurrentTimeStr().c_str()); // 每秒变化
+ group1->Add(timeLabel);
+ /* -------------------------------- NoSignal -------------------------------- */
+ if (NoSignal == nullptr)
+ {
+ NoSignal = new UIImageView();
+ if (NoSignal == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NoSignal new fail");
+ return;
+ }
+ }
+ NoSignal->SetPosition(148, (group1->GetHeight() - 38) / 2, 36, 38);
+ NoSignal->SetAutoEnable(false);
+ NoSignal->SetResizeMode(UIImageView::CENTER);
+ NoSignal->SetSrc(DROPDOWN_NOSIGNAL_IMAGE);
+ NoSignal->SetVisible(false);
+ group1->Add(NoSignal);
+ /* -------------------------------------------------------------------------- */
+ // 定义一个结构体,用于存储 ImageView 的信息
+ struct ImageViewInfo
+ {
+ int posX;
+ int posY;
+ int width;
+ int height;
+ };
+ // 待添加的 ImageView 信息列表
+ std::vector<ImageViewInfo> imageViewList = {
+ {148, 28, 6, 6},
+ {158, 20, 6, 14},
+ {168, 12, 6, 22},
+ {178, 4, 6, 30},
+ };
+
+ // 循环添加 ImageView 到相应的容器中
+ for (int i = 0; i < 4; i++)
+ {
+ if (showSignalStrength[i] == nullptr)
+ {
+ showSignalStrength[i] = new UIImageView();
+ if (showSignalStrength[i] == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showSignalStrength[%d] new fail", i);
+ return;
+ }
+ }
+ showSignalStrength[i]->SetPosition(imageViewList[i].posX, imageViewList[i].posY, imageViewList[i].width, imageViewList[i].height);
+ showSignalStrength[i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ showSignalStrength[i]->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ showSignalStrength[i]->SetStyle(STYLE_BORDER_RADIUS, 10);
+ group1->Add(showSignalStrength[i]);
+ showSignalStrength[i]->SetVisible(true);
+ }
+ /* ----------------------------------- 电池 ----------------------------------- */
+ batteryimage = new UIImageView();
+ if (batteryimage == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryimage new fail");
+ return;
+ }
+ batteryimage->SetPosition(178 + 20, (group1->GetHeight() - 30) / 2, 48, 30);
+ std::string batteryimagesPath = "/user/res/Battery/Battery_White.bin";
+ batteryimage->SetSrc(batteryimagesPath.c_str());
+ group1->Add(batteryimage);
+ /* -------------------------------------------------------------------------- */
+ progress = new UIBoxProgress();
+ if (progress == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "progress new fail");
+ return;
+ }
+ progress->SetPosition(batteryimage->GetX() + 7, batteryimage->GetY() + 6, 30, 18);
+ progress->SetValidWidth(30);
+ progress->SetValidHeight(18);
+ progress->SetRange(100, 0);
+ progress->SetStyle(STYLE_BORDER_RADIUS, 3);
+ progress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x00);
+ progress->SetBackgroundStyle(STYLE_TEXT_COLOR, 0xff000000);
+ progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ progress->SetForegroundStyle(STYLE_TEXT_COLOR, 0xff000000);
+ 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);
+ batteryLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT);
+ group1->Add(batteryLabel);
+ /* ----------------------------------充电图标-------------------------------------- */
+ chargeBatteryicon = new UIImageView();
+ if (!chargeBatteryicon)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "chargeBatteryicon creation failed");
+ return;
+ }
+ chargeBatteryicon->SetPosition(batteryLabel->GetX() + 10, batteryimage->GetY() + 2, 17, 22);
+ chargeBatteryicon->SetSrc("/user/res/Battery/Icon.bin");
+ chargeBatteryicon->SetAutoEnable(false);
+ chargeBatteryicon->SetResizeMode(UIImageView::CONTAIN);
+ chargeBatteryicon->SetVisible(false);
+ group1->Add(chargeBatteryicon);
+ /* -------------------------------------------------------------------------- */
+ ScrollView_->Add(group1);
+ /* -------------------------------------------------------------------------- */
+ updateSignalDisplay();
+ /* -------------------------------------------------------------------------- */
+ UpdateBatteryProcess();
+ }
+ void ThunderBirdMainView::UpdateTimeText(const char *time)
+ {
+ timeLabel->SetText(time); // 每秒变化
+ }
+
+ void ThunderBirdMainView::updateSignalDisplay()
+ {
+ int sim = uapi_dev_runtime_get_cat1_simstat();
+ int cat1_powerOn = uapi_dev_runtime_get_cat1_powerstat();
+ int signal = uapi_dev_runtime_get_cat1_signal();
+ int network_on = uapi_dev_runtime_get_cat1_networkstat();
+ int cat1_network_type = uapi_dev_runtime_get_cat1_networtype();
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sim = %d", sim);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cat1_powerOn = %d", cat1_powerOn);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "signal = %d", signal);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "network_on = %d", network_on);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cat1_network_type = %d", cat1_network_type);
+
+ const int SIGNAL_NO_SIGNAL = 99;
+
+ if (sim == 0 || cat1_powerOn == 0)
+ {
+ if (NoSignal != nullptr)
+ {
+ NoSignal->SetVisible(true);
+ }
+ UpdateSignalBarDisplay(CalculateSignalBars(signal), false);
+ }
+ else if (cat1_powerOn == 1 && sim == 1)
+ {
+ if (signal == SIGNAL_NO_SIGNAL) // 计算信号强度
+ {
+ // 无信号UI显示
+ if (NoSignal != nullptr)
+ {
+ NoSignal->SetVisible(true);
+ }
+ UpdateSignalBarDisplay(CalculateSignalBars(signal), false);
+ }
+ else
+ {
+ if (NoSignal != nullptr)
+ {
+ NoSignal->SetVisible(false);
+ }
+ UpdateSignalBarDisplay(CalculateSignalBars(signal), true);
+ }
+ }
+ }
+ void ThunderBirdMainView::UpdateSignalBarDisplay(int signalBars, bool state)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdView::UpdateSignalBarDisplay");
+ for (int i = 0; i < 4; i++)
+ {
+ showSignalStrength[i]->SetStyle(STYLE_BACKGROUND_COLOR, (i < signalBars) ? COLOR_SIGNAL_ON : COLOR_SIGNAL_OFF);
+ showSignalStrength[i]->Invalidate();
+ showSignalStrength[i]->SetVisible(state);
+ }
+ }
+ int ThunderBirdMainView::CalculateSignalBars(int signalStrength)
+ {
+ if (signalStrength >= 1 && signalStrength <= 8) // 0信号
+ {
+ return 0;
+ }
+ else if (signalStrength >= 9 && signalStrength <= 16) // 1格信号,信号很弱偶尔可以接打电话,很容易失败
+ {
+ return 1;
+ }
+ else if (signalStrength >= 17 && signalStrength <= 21) // 2格信号,信号一般
+ {
+ return 2;
+ }
+ else if (signalStrength >= 22 && signalStrength <= 26) // 3格信号,信号较强
+ {
+ return 3;
+ }
+ else if (signalStrength >= 27 && signalStrength <= 31) // 4格信号,信号很强
+ {
+ return 4;
+ }
+ else
+ {
+ return 99; // Invalid signal strength
+ }
+ }
+ void ThunderBirdMainView::UpdateBatteryProcess()
+ {
+ float voltage = 0.0F;
+ uint8_t value = 0;
+#ifdef SUPPORT_BATTERY_SERVICE
+ value = battery_get_voltage(&voltage);
+#endif
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "battery_get_voltage = %d", value);
+ batteryLabel->SetText(std::to_string(static_cast<int>(value)).c_str()); // 电量
+ progress->SetValue(value);
+
+ if (!chargeBatteryicon || !progress)
+ {
+ return;
+ }
+
+ bool isCharging = false;
+#ifdef SUPPORT_BATTERY_SERVICE
+ isCharging = get_charge_stat(); // 获取充电状态
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "isCharging = %d", isCharging);
+#endif
+
+ if (isCharging)
+ {
+ if (!isChargeBatteryIconVisible)
+ {
+ batteryLabel->SetX(progress->GetX() + 1); // 电量
+ batteryLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full); // 充电电量为白色
+ chargeBatteryicon->SetVisible(true); // 充电图标
+ isChargeBatteryIconVisible = true;
+ }
+ progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); // 充电状态为绿色
+ return;
+ }
+ else
+ {
+ if (value <= 20) // 低电量
+ {
+ if (isChargeBatteryIconVisible)
+ {
+ batteryLabel->SetX(progress->GetX() + 8); // 回到原来位置
+ batteryLabel->SetStyle(STYLE_TEXT_COLOR, Color::Black().full); // 不充电电量为黑色
+ chargeBatteryicon->SetVisible(false); // 充电图标
+ isChargeBatteryIconVisible = false;
+ }
+
+ progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Red().full); // 低电状态为红色
+ }
+ else // 非低电量
+ {
+ if (isChargeBatteryIconVisible)
+ {
+ batteryLabel->SetX(progress->GetX() + 8); // 回到原来位置
+ batteryLabel->SetStyle(STYLE_TEXT_COLOR, Color::Black().full); // 不充电电量为黑色
+ chargeBatteryicon->SetVisible(false); // 充电图标
+ isChargeBatteryIconVisible = false;
+ }
+
+ progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::White().full); // 非充电状态为白色
+ }
+ return;
+ }
+ }
+}
--- /dev/null
+/***
+ * @Date: 2024-06-22 18:08:25
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-06-24 11:30:12
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThunderBirdModel.cpp
+ */
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-06-07 09:21:47
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-11-05 14:49:01
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/ThunderBirdModel.cpp
+ */
+
+#include "thunderbird/include/ThunderBirdModel.h"
+#include "thunderbird/include/ThunderBirdView.h"
+#include "thunderbird/include/ThunderBirdMainView.h"
+#include "wearable_log.h"
+#include <sys/time.h>
+#include <service/graphic_service.h>
+#include "wearable_log.h"
+#include "custom_utils.h"
+#include <string.h>
+namespace OHOS
+{
+ ThunderBirdModel::ThunderBirdModel() {}
+ ThunderBirdModel::~ThunderBirdModel() {}
+
+ ThunderBirdModel *ThunderBirdModel::GetInstance()
+ {
+ static ThunderBirdModel instance;
+ return &instance;
+ }
+ // 获取当前时间戳字符串
+ std::string ThunderBirdModel::GetCurrentTimeStr()
+ {
+ uint32_t timeStamp = 0;
+ if (uapi_get_timestampe_ss(&timeStamp) != ERRCODE_SUCC)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp");
+ return "----/--/-- \n --/--";
+ }
+ // 将时间戳转换为 time_t 类型
+ time_t rawtime = static_cast<time_t>(timeStamp);
+ struct tm *timeinfo = localtime(&rawtime);
+
+ if (timeinfo == NULL)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to convert time");
+ return "----/--/-- \n --/--";
+ }
+
+ // 格式化时间为字符串 (HH:MM:SS format)
+ char buffer[20]; // 格式: HH:MM:SS
+ std::strftime(buffer, sizeof(buffer), "%H:%M", timeinfo);
+ return std::string(buffer);
+ }
+ void ThunderBirdModel::timer_callback_proc()
+ {
+ ThunderBirdMainView *view = ThunderBirdMainView::GetInstance();
+ if (view)
+ {
+ view->UpdateTimeText(GetCurrentTimeStr().c_str());
+ }
+ }
+
+ static osTimerId_t g_timer = nullptr;
+ /*定时器到期时的处理*/
+ static void TimerCallbackProc(uint8_t data)
+ {
+ // 倒计时
+ ThunderBirdModel::GetInstance()->timer_callback_proc();
+ ThunderBirdMainView::GetInstance()->updateSignalDisplay();
+ ThunderBirdMainView::GetInstance()->UpdateBatteryProcess();
+ }
+ /*
+ * @brief 回调函数
+ */
+ static void TimerCallback(uint8_t data)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TimerCallback %d", data);
+ GraphicService::GetInstance()->PostGraphicEvent(
+ std::bind(TimerCallbackProc, data));
+ }
+
+ /*
+ * @brief 开启定时器函数
+ * @param interval 时间间隔,单位ms
+ */
+ void ThunderBirdModel::StartTimer(uint32_t interval)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartTimer");
+ /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回
+ * ------------------------- */
+ if (g_timer != nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer already exists!!");
+ return;
+ }
+
+ /* --------------------------------- 2.创建定时器
+ * -------------------------------- */
+ g_timer = osTimerNew((osTimerFunc_t)TimerCallback, osTimerPeriodic,
+ nullptr, nullptr);
+ // 检查定时器创建是否成功
+ if (g_timer == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer create failed!!");
+ return;
+ }
+
+ /* ----------------------------- 3.将毫秒转换为系统时钟节拍数
+ * ---------------------------- */
+ /* --------------------------------- 4.启动定时器
+ * -------------------------------- */
+ osStatus_t ret = osTimerStart(g_timer, interval);
+ /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为
+ * nullptr -------------------- */
+ if (ret != osOK)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+ "osTimerDelete failed, ret = %lx!!", ret);
+ if (g_timer != nullptr)
+ {
+ ret = osTimerDelete(g_timer);
+ }
+ g_timer = nullptr;
+ return;
+ }
+ }
+ /*
+ * @brief 停止定时器
+ */
+ void ThunderBirdModel::StopTimer(void)
+ {
+ // 检查定时器是否存在
+ if (g_timer != nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::BP_StopTimer");
+ osTimerStop(g_timer);
+ // 删除定时器并置为 nullptr
+ osStatus_t ret = osTimerDelete(g_timer);
+ if (ret != osOK)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+ "osTimerDelete failed, ret = %lx!!", ret);
+ }
+ g_timer = nullptr;
+ }
+ }
+
+}
--- /dev/null
+#include "thunderbird/include/ThunderBirdOtaView.h"
+#include "wearable_log.h"
+
+namespace OHOS
+{
+ static ThunderBirdOtaView *g_pThunderBirdOtaView{nullptr};
+
+ ThunderBirdOtaView::ThunderBirdOtaView()
+ {
+ g_pThunderBirdOtaView = this;
+ }
+
+ ThunderBirdOtaView::~ThunderBirdOtaView()
+ {
+ g_pThunderBirdOtaView = nullptr;
+ ClearAll();
+ }
+
+ ThunderBirdOtaView *ThunderBirdOtaView::GetInstance(void)
+ {
+ return g_pThunderBirdOtaView;
+ }
+
+ void ThunderBirdOtaView::ClearAll(void)
+ {
+ if (group != nullptr)
+ {
+ group->RemoveAll();
+ delete group;
+ group = nullptr;
+ }
+ if (titleLabel != nullptr)
+ {
+ delete titleLabel;
+ titleLabel = nullptr;
+ }
+ }
+
+ UIViewGroup *ThunderBirdOtaView::ThunderBirdOtaViewInit(void)
+ {
+ group = new UIViewGroup();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdOtaView::group null!");
+ return nullptr;
+ }
+ group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+
+ titleLabel = new UILabelExt();
+ if (titleLabel != nullptr)
+ {
+ titleLabel->SetPosition(20, 20, 300, 40);
+ titleLabel->SetText("OTA 升级");
+ group->Add(titleLabel);
+ }
+
+ return group;
+ }
+}
+
+
namespace OHOS
{
- REGIST_MENU_PRO(VIEW_THUNDER_BIRD, ThunderBirdView, ThunderBirdPresenter,
+ REGIST_MENU_PRO(VIEW_THUNDER_BIRD, ThunderBirdMainView, ThunderBirdPresenter,
PNG_APPLIST_MESSAGE_IMAGE_BIG, PNG_APPLIST_MESSAGE_IMAGE,PNG_APPLIST_MESSAGE_IMAGE, "消息通知", STR_MESSAGE_NOTIFICATION);
// 当前Presenter属性实例化的内存指针
void ThunderBirdPresenter::OnStart()
{
- Presenter<ThunderBirdView>::OnStart();
+ Presenter<ThunderBirdMainView>::OnStart();
}
--- /dev/null
+#include "thunderbird/include/ThunderBirdReminderView.h"
+#include "wearable_log.h"
+
+namespace OHOS
+{
+ static ThunderBirdReminderView *g_pThunderBirdReminderView{nullptr};
+
+ ThunderBirdReminderView::ThunderBirdReminderView()
+ {
+ g_pThunderBirdReminderView = this;
+ }
+
+ ThunderBirdReminderView::~ThunderBirdReminderView()
+ {
+ g_pThunderBirdReminderView = nullptr;
+ ClearAll();
+ }
+
+ ThunderBirdReminderView *ThunderBirdReminderView::GetInstance(void)
+ {
+ return g_pThunderBirdReminderView;
+ }
+
+ void ThunderBirdReminderView::ClearAll(void)
+ {
+ if (group != nullptr)
+ {
+ group->RemoveAll();
+ delete group;
+ group = nullptr;
+ }
+ if (titleLabel != nullptr)
+ {
+ delete titleLabel;
+ titleLabel = nullptr;
+ }
+ }
+
+ UIViewGroup *ThunderBirdReminderView::ThunderBirdReminderViewInit(void)
+ {
+ group = new UIViewGroup();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdReminderView::group null!");
+ return nullptr;
+ }
+ group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+
+ titleLabel = new UILabelExt();
+ if (titleLabel != nullptr)
+ {
+ titleLabel->SetPosition(20, 20, 300, 40);
+ titleLabel->SetText("提醒界面");
+ group->Add(titleLabel);
+ }
+
+ return group;
+ }
+}
+
+
#include "thunderbird/include/ThunderBirdView.h"
+#include "thunderbird/include/ThunderBirdModel.h"
#include "thunderbird/include/ThunderBirdPresenter.h"
#include "wearable_log.h"
#include "NativeAbility.h"
#include "securec.h"
#include "common/low_power_manager.h"
#include "common/image_cache_manager.h"
-#include "screennotify/include/ui_screennotify.h"
-#include "custom_utils.h"
+#include "uicomponents/UIComponents.h"
+
namespace OHOS
{
- static constexpr int16_t VIDEO_WIDTH = 466;
- static constexpr int16_t VIDEO_HEIGHT = 466;
- static constexpr int16_t STRIDE_ALIGNMENT_VALUE = 128;
- static constexpr int16_t JPEG_WIDTH_BYTE_ALIGNMENT = 128;
- static constexpr int16_t JPEG_HEIGHT_BYTE_ALIGNMENT = 16;
- static constexpr int16_t BUFFER_QUEUE_SIZE = 2;
- static constexpr int16_t JPEG_HEIGHT_DIVISOR = 2;
static ThunderBirdView *g_pThunderBirdView{nullptr};
- static MediaVideoPlay *g_videoPlay = nullptr;
- static bool g_lastPlayed = false;
- static void ScreenStatusNotify(ScreenStatus status)
- {
- if (g_videoPlay == nullptr)
- {
- return;
- }
-
- bool temp = g_videoPlay->isPlayed_;
- if (status == SCREEN_STATUS_OFF && g_videoPlay->isPlayed_)
- {
- g_videoPlay->PauseVideoPlay();
- }
- else if (status == SCREEN_STATUS_ON)
- {
- if (g_lastPlayed && g_videoPlay->isPause_)
- {
- g_videoPlay->ResumeVideoPlay();
- }
- }
- g_lastPlayed = temp;
- }
-
ThunderBirdView::ThunderBirdView()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdView::ThunderBirdView");
g_pThunderBirdView = this;
+
}
ThunderBirdView::~ThunderBirdView()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdView::~ThunderBirdView");
g_pThunderBirdView = nullptr;
- ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON);//关闭屏幕常亮
ClearAll();
RootView::GetInstance()->ClearOnKeyActListener();
}
return g_pThunderBirdView;
}
- void ThunderBirdView::OnStart()
+ void ThunderBirdView::ClearAll(void)
{
- View<ThunderBirdPresenter>::OnStart();
- GetRootContainer()->SetTouchable(true);
- GetRootContainer()->SetDraggable(true);
- ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);//打开屏幕常亮
+
+ // 清理UI组件
+ if (group != nullptr)
+ {
+ group->RemoveAll();
+ delete group;
+ group = nullptr;
+ }
+ }
- ScrollView_ = ThunderBirdViewInit();
+ UIViewGroup *ThunderBirdView::ThunderBirdViewInit(void)
+ {
+ group = new UIViewGroup();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmPopUpView::group null!");
+ return nullptr;
+ }
+ group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
- AddViewToRootContainer(ScrollView_);
+ // InitBlackGround();
+ InitText();
- RootView::GetInstance()->SetOnKeyActListener(presenter_);
+ return group;
}
- void ThunderBirdView::ClearAll(void)
+ void ThunderBirdView::InitBlackGround()
{
- g_videoPlay = nullptr;
- deregisterNotifyScreenStatus(ScreenStatusNotify);
- videoPlay_->ResumeVideoPlay();
- if (nullptr != ScrollView_)
+ ground = new UIImageView();
+ if (ground == nullptr)
{
- ScrollView_->RemoveAll();
- if (curFace != nullptr)
- {
- delete curFace;
- curFace = nullptr;
- }
- if (surfaceView_ != nullptr)
- {
- delete surfaceView_;
- surfaceView_ = nullptr;
- }
- if (videoPlay_ != nullptr)
- {
- delete videoPlay_;
- videoPlay_ = nullptr;
- }
- delete ScrollView_;
- ScrollView_ = nullptr;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ground new fail");
+ return;
}
+ ground->SetStyle(STYLE_BACKGROUND_COLOR, 0x8D000000);
+ ground->SetStyle(STYLE_BACKGROUND_OPA, 0x8D);
+ // ground->SetStyle(STYLE_BORDER_RADIUS, 200);
+ ground->SetPosition(0, 0, 466, 466);
+ // ground->SetStyle(STYLE_BORDER_COLOR, Color::Gray().full);
+ group->Add(ground);
}
-
- UIScrollView *ThunderBirdView::ThunderBirdViewInit(void)
+ void ThunderBirdView::InitText()
{
- if (nullptr == ScrollView_)
+ Remindground = new UIImageView();
+ if (Remindground == nullptr)
{
- ScrollView_ = new UIScrollView();
- if (nullptr == ScrollView_)
- return nullptr;
-
- ScrollView_->SetScrollBlankSize(35);
- ScrollView_->SetReboundSize(50);
- ScrollView_->SetPosition(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
- // ScrollView_->SetViewId();
- ScrollView_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
- ScrollView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
- ScrollView_->SetOnDragListener(presenter_);
- ScrollView_->SetTouchable(true);
- ScrollView_->SetDraggable(false);
-
- curFace = new UIImageView();
- if (curFace == nullptr)
- {
- return nullptr;
- }
- curFace->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
- curFace->SetSrc("/user/res/ThunderBird/hair.bin");
-
- surfaceView_ = new UILiteSurfaceView();
- if (surfaceView_ == nullptr)
- {
- GRAPHIC_LOGE("surfaceView is nullptr\n");
- return nullptr;
- }
- colorKey_.full = 0xff202020;
- surfaceView_->SetViewId("sur");
- surfaceView_->SetPosition(0, 0, VIDEO_WIDTH, VIDEO_HEIGHT);
- surfaceView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
- surfaceView_->SetSurfaceColorkey(colorKey_);
-
- Surface *surface = surfaceView_->GetSurface();
- surface->SetStrideAlignment(STRIDE_ALIGNMENT_VALUE);
- surface->SetWidthAndHeight(VIDEO_WIDTH, VIDEO_HEIGHT);
- surface->SetQueueSize(BUFFER_QUEUE_SIZE);
- surface->SetFormat(PIXEL_FMT_YCBCR_420_SP);
-
- // jpeg decoder output buffer size calculation formula
- int32_t ySize = ALIGN_BYTE(VIDEO_WIDTH, JPEG_WIDTH_BYTE_ALIGNMENT) * VIDEO_HEIGHT;
- int32_t uvSize = ALIGN_BYTE(VIDEO_WIDTH, JPEG_WIDTH_BYTE_ALIGNMENT) *
- ALIGN_BYTE(VIDEO_HEIGHT, JPEG_HEIGHT_BYTE_ALIGNMENT) / JPEG_HEIGHT_DIVISOR;
- int32_t bufferSize = ySize + uvSize;
- surface->SetSize(bufferSize);
- if (videoPlay_ == nullptr)
- {
- std::string uri("/user/video/thunderbird.mp4");
- videoPlay_ = new MediaVideoPlay(surface, nullptr, uri, false);
- if (videoPlay_ == nullptr)
- {
- GRAPHIC_LOGE("videoPlay_ is nullptr\n");
- return nullptr;
- }
- g_videoPlay = videoPlay_;
- registerNotifyScreenStatus(ScreenStatusNotify);
- }
- if (videoPlay_->isExited_ || !videoPlay_->isEntered_)
- {
- videoPlay_->StartVideoPlay();
- }
-
- ScrollView_->Add(surfaceView_);
- ScrollView_->Add(curFace);
-
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Remindground new fail");
+ return;
}
- return ScrollView_;
+ Remindground->SetStyle(STYLE_BACKGROUND_COLOR, 0x8D101010);
+ Remindground->SetStyle(STYLE_BACKGROUND_OPA, 0x8D);
+ Remindground->SetStyle(STYLE_BORDER_RADIUS, 200);
+ Remindground->SetPosition(130, 201, 320, 46);
+ Remindground->SetStyle(STYLE_BORDER_COLOR, Color::Gray().full);
+ // group->Add(Remindground);
+
+ InitLabel(TextLabel, 100, 104, 300, 48, "TextLabel", "08:52", DEFAULT_VECTOR_FONT_FILENAME, 38);
+ TextLabel->SetText("Hey, 我是毛毛~");
+ TextLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT);
+ group->Add(TextLabel);
+
+ InitLabel(RemindLabel, 135, 198, 300, 40, "TextLabel", "08:52", DEFAULT_VECTOR_FONT_FILENAME, 30);
+ RemindLabel->SetText("按 下一页");
+ TextLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT);
+ // group->Add(RemindLabel);
}
-}
-
+}
\ No newline at end of file