ImageAnimatorInfo listenImageInfo[TB_LISTEN_ANIM_FRAMES];
const char **speakPathsArray{nullptr};
const char **listenPathsArray{nullptr};
+ void UpdateDialogueText(const char *text);
};
}
UIImageAnimatorView *listenAnimator{nullptr};
ImageAnimatorInfo listenImageInfo[TB_LISTEN_FRAMES];
const char **listenPathsArray{nullptr};
+ void UpdateLullabyText(const char *text);
};
}
{
if (TextLabel)
{
- TextLabel->SetText("保镖小姐 , 你来啦");
TextLabel->SetVisible(true);
}
if (TextLabel_Y)
+ {
+ TextLabel_Y->SetVisible(true);
+ }
+ if(ThunderBirdModel::IsTextEmpty() == true)
{
- TextLabel_Y->SetText("保镖小姐 , 你来啦");
- TextLabel_Y->SetVisible(true);
+ UpdateDialogueText("保镖小姐 , 你来啦");
+ }
+ else
+ {
+ UpdateDialogueText(ThunderBirdModel::GetInstance()->GetTextStr().c_str());
}
+
//动效图标
if (speakAnimator) { speakAnimator->SetVisible(true); speakAnimator->Start(); }
break;
break;
}
}
+ void ThunderBirdDialogueView::UpdateDialogueText(const char *text)
+ {
+ TextLabel->SetText(text);
+ TextLabel_Y->SetText(text);
+ }
}
if (TextLabel)
{
TextLabel->SetPosition(0, 64, 360, 42);
- TextLabel->SetText("从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?");
+ //TextLabel->SetText("从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?");
TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
TextLabel->SetRollSpeed(35);
TextLabel->SetVisible(true);
if (TextLabel_Y)
{
TextLabel_Y->SetPosition(2, 66, 360, 42);
- TextLabel_Y->SetText("从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?");
+ //TextLabel_Y->SetText("从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?");
TextLabel_Y->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
TextLabel_Y->SetRollSpeed(35);
TextLabel_Y->SetVisible(true);
}
+ ThunderBirdLullabyView::UpdateLullabyText(ThunderBirdModel::GetInstance()->GetTextStr().c_str());
if(RemindLabel)
{
std::string merged = left + "/" + right;
RemindLabel->SetText(merged.c_str());
}
+
+ void ThunderBirdLullabyView::UpdateLullabyText(const char *text)
+ {
+ TextLabel->SetText(text);
+ TextLabel_Y->SetText(text);
+ }
}
${ROOT_DIR}/zhihui/4g/cat1Service/include
${ROOT_DIR}/zhihui/4g/cat1Service/Service
${ROOT_DIR}/zhihui/ai/include/
- ${ROOT_DIR}/zhihui/leiniao/imsl_ln/ #暂时添加
+ ${ROOT_DIR}/zhihui/leiniao/imsl_ln
)
+++ /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"
-#include "components/ui_image_view.h"
-#include "components/ui_image_animator.h"
-#include "UiConfig.h"
-
-namespace OHOS
-{
- static constexpr int16_t TB_NET_ANIM_X = 38;
- static constexpr int16_t TB_NET_ANIM_Y = 149;
- static constexpr int16_t TB_NET_ANIM_W = 36;
- static constexpr int16_t TB_NET_ANIM_H = 36;
- static constexpr int16_t TB_NET_ANIM_FRAMES = 60;
- static constexpr int16_t TB_NET_ANIM_INTERVAL = 41;
- static constexpr const char *TB_NET_ANIM_PATH = "/user/res/animated_icon/net/";
-
- static const char *TB_NET_PATHS[TB_NET_ANIM_FRAMES] = {
- TB_NET_IMAGE_1,
- TB_NET_IMAGE_2,
- TB_NET_IMAGE_3,
- TB_NET_IMAGE_4,
- TB_NET_IMAGE_5,
- TB_NET_IMAGE_6,
- TB_NET_IMAGE_7,
- TB_NET_IMAGE_8,
- TB_NET_IMAGE_9,
- TB_NET_IMAGE_10,
- TB_NET_IMAGE_11,
- TB_NET_IMAGE_12,
- TB_NET_IMAGE_13,
- TB_NET_IMAGE_14,
- TB_NET_IMAGE_15,
- TB_NET_IMAGE_16,
- TB_NET_IMAGE_17,
- TB_NET_IMAGE_18,
- TB_NET_IMAGE_19,
- TB_NET_IMAGE_20,
- TB_NET_IMAGE_21,
- TB_NET_IMAGE_22,
- TB_NET_IMAGE_23,
- TB_NET_IMAGE_24,
- TB_NET_IMAGE_25,
- TB_NET_IMAGE_26,
- TB_NET_IMAGE_27,
- TB_NET_IMAGE_28,
- TB_NET_IMAGE_29,
- TB_NET_IMAGE_30,
- TB_NET_IMAGE_31,
- TB_NET_IMAGE_32,
- TB_NET_IMAGE_33,
- TB_NET_IMAGE_34,
- TB_NET_IMAGE_35,
- TB_NET_IMAGE_36,
- TB_NET_IMAGE_37,
- TB_NET_IMAGE_38,
- TB_NET_IMAGE_39,
- TB_NET_IMAGE_40,
- TB_NET_IMAGE_41,
- TB_NET_IMAGE_42,
- TB_NET_IMAGE_43,
- TB_NET_IMAGE_44,
- TB_NET_IMAGE_45,
- TB_NET_IMAGE_46,
- TB_NET_IMAGE_47,
- TB_NET_IMAGE_48,
- TB_NET_IMAGE_49,
- TB_NET_IMAGE_50,
- TB_NET_IMAGE_51,
- TB_NET_IMAGE_52,
- TB_NET_IMAGE_53,
- TB_NET_IMAGE_54,
- TB_NET_IMAGE_55,
- TB_NET_IMAGE_56,
- TB_NET_IMAGE_57,
- TB_NET_IMAGE_58,
- TB_NET_IMAGE_59,
- TB_NET_IMAGE_60,
- };
-
- class ThunderBirdAdjustView
- {
- public:
- ThunderBirdAdjustView();
- virtual ~ThunderBirdAdjustView();
- static ThunderBirdAdjustView *GetInstance(void);
- bool EnsureNetAnimator();
- UIViewGroup *ThunderBirdAdjustViewInit(void);
- void ClearAll(void);
- void Show(int16_t showView);
-
- enum : int16_t {
- THUNDERBIRD_ADJUSTVIEW_BIND_SUCCESS = 0, // 绑定成功
- THUNDERBIRD_ADJUSTVIEW_WARNING, // 异常警告
- THUNDERBIRD_ADJUSTVIEW_NETWORK_CONNECTING, // 网络连接中
- };
-
- private:
- UIViewGroup *group{nullptr};
- UILabelExt *TextLabel{nullptr};
- UIImageAnimatorView *netAnimator{nullptr};
- ImageAnimatorInfo netImageInfo[TB_NET_ANIM_FRAMES];
- const char **netPathsArray{nullptr};
- UILabelExt *RemindLabel{nullptr};
- UIImageView *BackGround{nullptr};
- UIImageView *RemindIcon{nullptr};
- UIImageView *RemindIcon2{nullptr};
- UIImageView *RemindIcon3{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"
-#include "components/ui_image_view.h"
-#include "components/ui_image_animator.h"
-#include "UiConfig.h"
-
-namespace OHOS
-{
- static constexpr int16_t TB_SPEAK_ANIM_X = 141;
- static constexpr int16_t TB_SPEAK_ANIM_Y = 112;
- static constexpr int16_t TB_SPEAK_ANIM_W = 78;
- static constexpr int16_t TB_SPEAK_ANIM_H = 24;
- static constexpr int16_t TB_SPEAK_ANIM_FRAMES = 25;
- static constexpr int16_t TB_SPEAK_ANIM_INTERVAL = 41;
- static constexpr const char *TB_SPEAK_ANIM_PATH = "/user/res/animated_icon/speak/";
-
- static constexpr int16_t TB_LISTEN_ANIM_X = 69;
- static constexpr int16_t TB_LISTEN_ANIM_Y = 65;
- static constexpr int16_t TB_LISTEN_ANIM_W = 36;
- static constexpr int16_t TB_LISTEN_ANIM_H = 36;
- static constexpr int16_t TB_LISTEN_ANIM_FRAMES = 61;
- static constexpr int16_t TB_LISTEN_ANIM_INTERVAL = 41;
- static constexpr const char *TB_LISTEN_ANIM_PATH = "/user/res/animated_icon/listen/";
-
- static const char *TB_SPEAK_PATHS[TB_SPEAK_ANIM_FRAMES] = {
- TB_SPEAK_IMAGE_1,
- TB_SPEAK_IMAGE_2,
- TB_SPEAK_IMAGE_3,
- TB_SPEAK_IMAGE_4,
- TB_SPEAK_IMAGE_5,
- TB_SPEAK_IMAGE_6,
- TB_SPEAK_IMAGE_7,
- TB_SPEAK_IMAGE_8,
- TB_SPEAK_IMAGE_9,
- TB_SPEAK_IMAGE_10,
- TB_SPEAK_IMAGE_11,
- TB_SPEAK_IMAGE_12,
- TB_SPEAK_IMAGE_13,
- TB_SPEAK_IMAGE_14,
- TB_SPEAK_IMAGE_15,
- TB_SPEAK_IMAGE_16,
- TB_SPEAK_IMAGE_17,
- TB_SPEAK_IMAGE_18,
- TB_SPEAK_IMAGE_19,
- TB_SPEAK_IMAGE_20,
- TB_SPEAK_IMAGE_21,
- TB_SPEAK_IMAGE_22,
- TB_SPEAK_IMAGE_23,
- TB_SPEAK_IMAGE_24,
- TB_SPEAK_IMAGE_25,
- };
- static const char *TB_LISTEN_PATHS[TB_LISTEN_ANIM_FRAMES] = {
- TB_LISTEN_IMAGE_1,
- TB_LISTEN_IMAGE_2,
- TB_LISTEN_IMAGE_3,
- TB_LISTEN_IMAGE_4,
- TB_LISTEN_IMAGE_5,
- TB_LISTEN_IMAGE_6,
- TB_LISTEN_IMAGE_7,
- TB_LISTEN_IMAGE_8,
- TB_LISTEN_IMAGE_9,
- TB_LISTEN_IMAGE_10,
- TB_LISTEN_IMAGE_11,
- TB_LISTEN_IMAGE_12,
- TB_LISTEN_IMAGE_13,
- TB_LISTEN_IMAGE_14,
- TB_LISTEN_IMAGE_15,
- TB_LISTEN_IMAGE_16,
- TB_LISTEN_IMAGE_17,
- TB_LISTEN_IMAGE_18,
- TB_LISTEN_IMAGE_19,
- TB_LISTEN_IMAGE_20,
- TB_LISTEN_IMAGE_21,
- TB_LISTEN_IMAGE_22,
- TB_LISTEN_IMAGE_23,
- TB_LISTEN_IMAGE_24,
- TB_LISTEN_IMAGE_25,
- TB_LISTEN_IMAGE_26,
- TB_LISTEN_IMAGE_27,
- TB_LISTEN_IMAGE_28,
- TB_LISTEN_IMAGE_29,
- TB_LISTEN_IMAGE_30,
- TB_LISTEN_IMAGE_31,
- TB_LISTEN_IMAGE_32,
- TB_LISTEN_IMAGE_33,
- TB_LISTEN_IMAGE_34,
- TB_LISTEN_IMAGE_35,
- TB_LISTEN_IMAGE_36,
- TB_LISTEN_IMAGE_37,
- TB_LISTEN_IMAGE_38,
- TB_LISTEN_IMAGE_39,
- TB_LISTEN_IMAGE_40,
- TB_LISTEN_IMAGE_41,
- TB_LISTEN_IMAGE_42,
- TB_LISTEN_IMAGE_43,
- TB_LISTEN_IMAGE_44,
- TB_LISTEN_IMAGE_45,
- TB_LISTEN_IMAGE_46,
- TB_LISTEN_IMAGE_47,
- TB_LISTEN_IMAGE_48,
- TB_LISTEN_IMAGE_49,
- TB_LISTEN_IMAGE_50,
- TB_LISTEN_IMAGE_51,
- TB_LISTEN_IMAGE_52,
- TB_LISTEN_IMAGE_53,
- TB_LISTEN_IMAGE_54,
- TB_LISTEN_IMAGE_55,
- TB_LISTEN_IMAGE_56,
- TB_LISTEN_IMAGE_57,
- TB_LISTEN_IMAGE_58,
- TB_LISTEN_IMAGE_59,
- TB_LISTEN_IMAGE_60,
- TB_LISTEN_IMAGE_61,
- };
-
- class ThunderBirdDialogueView
- {
- public:
- ThunderBirdDialogueView();
- virtual ~ThunderBirdDialogueView();
- static ThunderBirdDialogueView *GetInstance(void);
- UIViewGroup *ThunderBirdDialogueViewInit(void);
- bool EnsureSpeakAnimator();
- bool EnsureListenAnimator();
- void ClearAll(void);
- void Show(int16_t showView);
-
- enum : int16_t {
- THUNDERBIRD_DIALOGUEVIEW_SPEAKING = 0, // 说话中
- THUNDERBIRD_DIALOGUEVIEW_LISTENING, // 聆听中
- THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW, // 状态展示
- };
-
- private:
- UIViewGroup *group{nullptr};
- UILabelExt *TextLabel{nullptr};
- UILabelExt *TextLabel_Y{nullptr};
- UIImageAnimatorView *speakAnimator{nullptr};
- UIImageAnimatorView *listenAnimator{nullptr};
- ImageAnimatorInfo speakImageInfo[TB_SPEAK_ANIM_FRAMES];
- ImageAnimatorInfo listenImageInfo[TB_LISTEN_ANIM_FRAMES];
- const char **speakPathsArray{nullptr};
- const char **listenPathsArray{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"
-#include "components/ui_image_view.h"
-#include "components/ui_label_button.h"
-#include "components/ui_qrcode.h"
-
-namespace OHOS
-{
- class ThunderBirdGuideView
- {
- public:
- ThunderBirdGuideView();
- virtual ~ThunderBirdGuideView();
- 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 *TextLabel{nullptr};
- UILabelExt *TextLabel_Y{nullptr};
- UIQrcode *qrcode_{nullptr};
- UILabelButton *RemindButton{nullptr};
- UILabelExt *RemindLabel{nullptr};
- UIImageView *RemindGround{nullptr};
- UIImageView *RemindIcon{nullptr};
- UIImageView *RemindIcon2{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"
-#include "components/ui_image_view.h"
-#include "components/ui_image_animator.h"
-#include <cstdint>
-
-namespace OHOS
-{
- static constexpr int16_t TB_LISTEN_X = 38;
- static constexpr int16_t TB_LISTEN_Y = 151;
- static constexpr int16_t TB_LISTEN_W = 36;
- static constexpr int16_t TB_LISTEN_H = 36;
- static constexpr int16_t TB_LISTEN_FRAMES = 95;
- static constexpr int16_t TB_LISTEN_INTERVAL = 41;
- static constexpr const char *TB_LISTEN_PATH = "/user/res/animated_icon/listen/";
-
- class ThunderBirdLullabyView
- {
- public:
- ThunderBirdLullabyView();
- virtual ~ThunderBirdLullabyView();
- static ThunderBirdLullabyView *GetInstance(void);
- UIViewGroup *ThunderBirdLullabyViewInit(void);
- bool EnsureListenAnimator();
- void ClearAll(void);
- void Show(int16_t showView);
- void UpdateTimeText(uint32_t currentSeconds, uint32_t totalSeconds);
-
- enum : int16_t {
- THUNDERBIRD_LULLABYVIEW_1 = 0,
- THUNDERBIRD_LULLABYVIEW_2,
- THUNDERBIRD_LULLABYVIEW_3,
- THUNDERBIRD_LULLABYVIEW_4,
- THUNDERBIRD_LULLABYVIEW_5,
- };
-
- private:
- UIViewGroup *group{nullptr};
- UILabelExt *TextLabel{nullptr};
- UILabelExt *TextLabel_Y{nullptr};
- UILabelExt *RemindLabel{nullptr};
- UIImageView *RemindIcon{nullptr};
- UIImageView *RemindIcon2{nullptr};
- UIImageAnimatorView *listenAnimator{nullptr};
- ImageAnimatorInfo listenImageInfo[TB_LISTEN_FRAMES];
- const char **listenPathsArray{nullptr};
- };
-}
-
-#endif
-
+++ /dev/null
-
-
-#ifndef BP_MAIN_VIEW_H
-#define BP_MAIN_VIEW_H
-
-#include "View.h"
-#include "components/ui_view_group.h"
-#include "components/ui_label_ext.h"
-#include "components/ui_image_view.h"
-#include "video_play_wrapper.h"
-#include "main/dial/DialVideoView.h"
-#include "animator/animator_manager.h"
-#include "components/ui_box_progress.h"
-#include "components/ui_image_animator.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"
-#include "thunderbird/include/ThunderBirdShutdownView.h"
-#include "thunderbird/include/ThunderBirdShutdownTestView.h"
-namespace OHOS
-{
- static constexpr const char *DROPDOWN_NOSIGNAL_IMAGE = "/user/res/DROPDOWN_NOSIGNAL.bin";
-
- typedef enum : uint8_t
- {
- THUNDERBIRDMENUVIEW = 0, // 主界面
- THUNDERBIRD_OTAVIEW,
- THUNDERBIRD_GUIDEVIEW,
- THUNDERBIRD_LULLABYVIEW,
- THUNDERBIRD_DIALOGUEVIEW,
- THUNDERBIRD_REMINDERVIEW,
- THUNDERBIRD_ADJUSTVIEW,
- THUNDERBIRD_SHUTDOWNVIEW,
- THUNDERBIRD_SHUTDOWNTESTVIEW,
- 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 ChangeThunderBirdShutdownView(int16_t);
- bool ChangeThunderBirdShutdownTestView(int16_t);
- bool ClickFunc(int16_t interface);
- void ChangeView(int16_t hideView, int16_t showView, int16_t subView = -1);
- int16_t GetPrevViewId() const { return prevView_; }
- int16_t GetPrevSubViewId() const { return prevSubView_; }
-
- int16_t GetCurrentView() const;
- int16_t GetCurrentSubView() const;
-
-
- void UpdateBatteryProcess();
- void updateSignalDisplay();
- void UpdateSignalBarDisplay(int signalBars, bool state);
- int CalculateSignalBars(int signalStrength);
- void UpdateTimeText(const char *time);
- void Initback();
- UIViewGroup * InitBaseData();
- void InitCommonPageComponents();
- void HideCommonPageComponents();
- bool SwitchVideo(const char *uri);
- // 切换头发贴图
- void SwitchHair(const char *hairPath);
- // 关机前关闭视频与相关资源
- void CloseVideo();
- // 打开遮罩(部分视图需要)
- void OpenBackGround(void);
-
- MediaVideoPlay *video_ = nullptr;
- MediaVideoPlay *videoPlay_ = nullptr;
- UIImageView *batteryimage{nullptr}; // 电池图片
- UILabel *batteryLabel{nullptr}; // 电池电量
- UIBoxProgress *progress{nullptr}; // 电池进度条
- UIImageView *chargeBatteryicon{nullptr}; // 充电图标
- bool isChargeBatteryIconVisible{false}; // 充电图标是否可见
-
- int16_t Batteryvalue{0}; // 电池电量
-
- UIImageView *iconView{nullptr};
- UIImageView *backGroundView{nullptr};
-
-
- private:
- void DeInit();
- // 旧多视图分组容器
- UIViewGroup *group[MAXVIEW]{nullptr};
- UIScrollView *ScrollView_{nullptr};
- // 页面聚合容器:承载所有子界面,切换仅做显示/隐藏
- UIViewGroup *pagesGroup{nullptr};
- int16_t currentView_{THUNDERBIRD_GUIDEVIEW};
- int16_t currentSubView_{0};
- int16_t prevView_{THUNDERBIRDMENUVIEW};
- int16_t prevSubView_{0};
- // 网络状态变化标志(-1 未初始化,0 无网络,1 有网络)
- int8_t lastNetworkOnline_{-1};
- UIImageView *curFace{nullptr};
- DialVideoView *videoPlayer_ = nullptr;
- UILiteSurfaceView *surfaceView_ = nullptr;
-
- ColorType colorKey_;
-
- UIViewGroup *group1{nullptr};
- UILabelExt *timeLabel{nullptr};
- UIImageView *showSignalStrength[4]{nullptr}; // 信号强度
- UIImageView *NoSignal{nullptr}; // 无信号
-
-
- // Ota(进度/文本)
- UIBoxProgress *otaProgress{nullptr};
-
- // 电量提醒与充电状态一次性提示控制
- int16_t lastBatteryStage{-1}; // 3:>20, 2:(10,20], 1:(5,10], 0:<=5
- bool wasCharging{false};
- bool notifiedChargeFull{false};
-
- // 各子界面对象指针
- ThunderBirdOtaView *g_pThunderBirdOtaView{nullptr};
- ThunderBirdGuideView *g_pThunderBirdGuideView{nullptr};
- ThunderBirdLullabyView *g_pThunderBirdLullabyView{nullptr};
- ThunderBirdDialogueView *g_pThunderBirdDialogueView{nullptr};
- ThunderBirdReminderView *g_pThunderBirdReminderView{nullptr};
- ThunderBirdAdjustView *g_pThunderBirdAdjustView{nullptr};
- ThunderBirdShutdownView *g_pThunderBirdShutdownView{nullptr};
- ThunderBirdShutdownTestView *g_pThunderBirdShutdownTestView{nullptr};
-
-#define SCREEN_WIDTH 360
-#define SCREEN_HEIGHT 360
- };
-}
-
-#endif
\ No newline at end of file
+++ /dev/null
-#ifndef THUNDERBIRD_MODEL_H
-#define THUNDERBIRD_MODEL_H
-
-#include <cstdint>
-#include <map>
-#include <iostream>
-#include <unordered_map>
-#include <vector>
-#include <string>
-#include <fstream>
-#include <cstring>
-#include "AppViewIDs.h"
-#include "UiConfig.h"
-
-namespace OHOS
-{
- class ThunderBirdModel
- {
- public:
- static ThunderBirdModel *GetInstance(void);
- std::string GetCurrentTimeStr();
- void timer_callback_proc();
- void StopTimer(void);
- void StartTimer(uint32_t interval = 2 * 1000);//2秒
- void StartReminderHideTimer(uint32_t intervalMs = 1000);
- void StartOtaCountdown(uint32_t startVal);
- void StopOtaCountdown(void);
- void StartCountUpTimer(uint32_t targetSeconds);
- void StopCountUpTimer(void);
- int GetCountUpValue() const;
-
- // 新手引导相关函数
- enum class BindingStatus {
- BOUND = 0, // 已绑定
- NOT_BOUND = 1, // 未绑定
- NO_NETWORK = 2 // 没有网络
- };
- BindingStatus CheckBindingStatus();
-
- // 对话相关函数
- bool StartRecording();
- bool StopRecording();
- bool SendRecording();
- bool ReceiveAnswer();
- std::string GetConversationText();
- bool EndConversation();
-
- // 哄睡模式相关函数
- bool StartLullabyMode();
- bool StopLullabyMode();
- bool IsLullabyModeActive() const;
-
- // 提醒结构体定义
- struct ReminderData {
- uint32_t id; // 提醒ID
- uint32_t timestamp; // 时间戳
- char content[256]; // 提醒内容(最大255字符)
- bool isActive; // 是否激活
- uint32_t createTime; // 创建时间
-
- ReminderData() : id(0), timestamp(0), isActive(false), createTime(0) {
- memset(content, 0, sizeof(content));
- }
- };
-
- // 事项提醒相关函数
- bool AddReminder(const std::string& content, uint32_t timestamp);
- bool RemoveReminder(uint32_t reminderId);
- bool UpdateReminder(uint32_t reminderId, const std::string& content, uint32_t timestamp);
- std::vector<std::string> GetReminders();
-
- // 文件存储相关函数
- bool SaveRemindersToFile();
- bool LoadRemindersFromFile();
- std::string GetReminderFilePath() const;
- uint32_t GenerateReminderId();
-
- private:
- ThunderBirdModel();
- virtual ~ThunderBirdModel();
- ThunderBirdModel(const ThunderBirdModel &) = delete;
- ThunderBirdModel &operator=(const ThunderBirdModel &) = delete;
-
- // 提醒数据存储
- std::vector<ReminderData> m_reminders;
- uint32_t m_nextReminderId;
- };
-}
-
-#endif // THUNDERBIRD_MODEL_H
\ 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"
-#include "components/ui_image_view.h"
-#include "components/ui_box_progress.h"
-
-namespace OHOS
-{
- class ThunderBirdOtaView
- {
- public:
- ThunderBirdOtaView();
- virtual ~ThunderBirdOtaView();
- static ThunderBirdOtaView *GetInstance(void);
- UIViewGroup *ThunderBirdOtaViewInit(void);
- void ClearAll(void);
- void Show(int16_t showView);
- void UpdateCountdown(int value);
- void SetRemindProgress(int16_t value);
- enum : int16_t {
- THUNDERBIRD_OTAVIEW_NORMAL = 0, // OTA就绪
- THUNDERBIRD_OTAVIEW_OBVIOUS, // 有新功能
- THUNDERBIRD_OTAVIEW_UPDATE_NOW, // 需要立即更新
- THUNDERBIRD_OTAVIEW_UPDATING, // 更新中
- THUNDERBIRD_OTAVIEW_NIGHT_UPDATE, // 设置夜间更新
- THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS, // 设置夜间更新成功
- THUNDERBIRD_OTAVIEW_COUNTDOWN, // 更新倒计时
- THUNDERBIRD_OTAVIEW_LOW_BATTERY, // 电量不足
- THUNDERBIRD_OTAVIEW_NETWORK_ERROR, // 网络异常
- THUNDERBIRD_OTAVIEW_MEMORY_ERROR, // 内存不足
- THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS, // 更新成功
- THUNDERBIRD_OTAVIEW_UPDATE_FAILED, // 更新未完成
- };
-
- private:
- UIViewGroup *group{nullptr};
- UILabelExt *titleLabel{nullptr};
- UILabelExt *TextLabel{nullptr};
- UILabelExt *LittleTextLabel{nullptr};
- UILabelExt *LittleTextLabel_2{nullptr};
- UILabelExt *RemindLabel{nullptr};
- UIImageView *RemindIcon{nullptr};
- UIImageView *RemindIcon2{nullptr};
- UIImageView *RemindIcon3{nullptr};
- UIBoxProgress *VolumeProgress{nullptr};
- UIImageView *BackGround{nullptr};
- int16_t remindProgressValue_{0};
- };
-}
-
-#endif
-
+++ /dev/null
-
-#ifndef THUNDERBIRD_PRESENTER_H
-#define THUNDERBIRD_PRESENTER_H
-
-#include "thunderbird/include/ThunderBirdMainView.h"
-#include "key/include/KeyInputListener.h"
-#include "Presenter.h"
-#include "View.h"
-
-namespace OHOS
-{
- class ThunderBirdMainView;
- class ThunderBirdPresenter : public Presenter<ThunderBirdMainView>,
- public UIView::OnClickListener,
- public RootView::OnKeyActListener,
- public UIView::OnDragListener
- {
- public:
- ThunderBirdPresenter();
- virtual ~ThunderBirdPresenter();
-
- void OnStart() override;
- void OnResume() override;
-
- static ThunderBirdPresenter *GetInstance();
-
- // 发布事件函数
- void PublishEvent(uint16_t topic, uint8_t *data = nullptr, uint32_t size = 0);
-
- private:
- bool OnClick(UIView &view, const ClickEvent &event) override;
- bool OnDrag(UIView &view, const DragEvent &event) override;
- bool OnDragEnd(UIView &view, const DragEvent &event) override;
- bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
- bool X_DRAG_FLAG{false};
- };
-}
-
-#endif
\ No newline at end of file
+++ /dev/null
-// #ifndef THUNDERBIRD_RECORD_PRESENTER_H_
-// #define THUNDERBIRD_RECORD_PRESENTER_H_
-
-// #include "Presenter.h"
-// #include "View.h"
-// #include "thunderbird/include/ThunderBirdRecordView.h"
-// #include "thunderbird/include/ThunderBirdModel.h"
-// #include "click_event.h"
-// #include "drag_event.h"
-// #include "events/key_event.h"
-// #include "key/include/KeyInputListener.h"
-
-// namespace OHOS
-// {
-// class ThunderBirdRecordPresenter : public Presenter<ThunderBirdRecordView>,
-// public UIView::OnClickListener,
-// public UIView::OnDragListener
-// {
-// public:
-// ThunderBirdRecordPresenter();
-// virtual ~ThunderBirdRecordPresenter();
-// static ThunderBirdRecordPresenter *GetInstance(void);
-
-// private:
-// void HandleRecordButtonClick();
-// void HandleVolumeUpButtonClick();
-// void HandleVolumeDownButtonClick();
-
-// // 重写Presenter的虚函数
-// bool OnClick(UIView &view, const ClickEvent &event) override;
-// bool OnDrag(UIView &view, const DragEvent &event) override;
-// bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
-
-
-// };
-// }
-
-// #endif
+++ /dev/null
-// #ifndef THUNDERBIRD_RECORD_VIEW_H_
-// #define THUNDERBIRD_RECORD_VIEW_H_
-
-// #include "View.h"
-// #include "components/ui_view_group.h"
-// #include "components/ui_label_ext.h"
-// #include "components/ui_image_view.h"
-// #include "components/ui_label_button.h"
-// #include "thunderbird/include/ThunderBirdRecordPresenter.h"
-
-// namespace OHOS
-// {
-// class ThunderBirdRecordPresenter;
-// class ThunderBirdRecordView : public View<ThunderBirdRecordPresenter>
-// {
-// public:
-// ThunderBirdRecordView();
-// virtual ~ThunderBirdRecordView();
-// static ThunderBirdRecordView *GetInstance(void);
-// UIViewGroup *ThunderBirdRecordViewInit(void);
-// void ClearAll(void);
-// void Show(int16_t showView);
-
-// // 更新文本标签
-// void UpdateTextLabel(const char* text);
-// void UpdateVolumeText(int volume);
-
-// // 获取按键引用(供Presenter使用)
-// UILabelButton* GetRecordButton() { return RecordButton; }
-// UILabelButton* GetVolumeUpButton() { return VolumeUpButton; }
-// UILabelButton* GetVolumeDownButton() { return VolumeDownButton; }
-
-// // 获取状态
-// bool IsRecording() const { return isRecording; }
-// int GetCurrentVolume() const { return currentVolume; }
-
-// // 设置状态
-// void SetRecording(bool recording);
-// void SetVolume(int volume);
-
-// private:
-// UIViewGroup *group{nullptr};
-// UILabelExt *TextLabel{nullptr}; // 主文本标签
-// UILabelExt *VolumeLabel{nullptr}; // 音量显示标签
-// UILabelButton *RecordButton{nullptr}; // 录音按键
-// UILabelButton *VolumeUpButton{nullptr}; // 音量加按键
-// UILabelButton *VolumeDownButton{nullptr}; // 音量减按键
-// UIImageView *RecordIcon{nullptr}; // 录音图标
-
-// // 状态变量
-// bool isRecording{false};
-// int currentVolume{50}; // 音量范围 0-100
-// };
-// }
-
-// #endif
+++ /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"
-#include "components/ui_image_view.h"
-#include "components/ui_box_progress.h"
-#include "components/ui_label_button.h"
-
-namespace OHOS
-{
- class ThunderBirdReminderView
- {
- public:
- ThunderBirdReminderView();
- virtual ~ThunderBirdReminderView();
- static ThunderBirdReminderView *GetInstance(void);
- UIViewGroup *ThunderBirdReminderViewInit(void);
- void ClearAll(void);
- void Show(int16_t showView);
- void HideAll();
- // 音量/进度调节接口(用于 THUNDERBIRD_REMINDERVIEW_VOLUME)
- void AdjustRemindProgress(int16_t delta); // 正数增加,负数减少
- void SetRemindProgress(int16_t value);
-
- enum : int16_t {
- THUNDERBIRD_REMINDERVIEW_VOLUME = 0, // 音量调节
- THUNDERBIRD_REMINDERVIEW_TASK_REMINDER, // 事项提醒
- THUNDERBIRD_REMINDERVIEW_NETWORK_DISCONNECT, // 网络断开
- THUNDERBIRD_REMINDERVIEW_LOW_BATTERY, // 电量不足
- THUNDERBIRD_REMINDERVIEW_CHARGING, // 充电中
- THUNDERBIRD_REMINDERVIEW_CHARGE_COMPLETE, // 充电完成
- THUNDERBIRD_REMINDERVIEW_DIALOGUE_NOT_ENOUGH,//对话不足
- THUNDERBIRD_REMINDERVIEW_DIALOGUE_USE_UP, //对话用尽
- THUNDERBIRD_REMINDERVIEW_FLOW_NOT_ENOUGH, //流量不足
- THUNDERBIRD_REMINDERVIEW_FLOW_USE_UP, //流量用尽
- };
-
- private:
- UIViewGroup *group{nullptr};
- UILabelExt *TextLabel{nullptr};
- UILabelExt *RemindLabel{nullptr};
- UILabelButton *RemindButton{nullptr};
- UIImageView *RemindIcon{nullptr};
- UIImageView *RemindIcon2{nullptr};
-
- UIBoxProgress *VolumeProgress{nullptr};
-
- // 进度当前值(用于音量界面),0~100
- int16_t remindProgressValue_{50};
- };
-}
-
-#endif
-
+++ /dev/null
-#ifndef THUNDERBIRD_SHUTDOWN_TEST_VIEW_H
-#define THUNDERBIRD_SHUTDOWN_TEST_VIEW_H
-
-#include "components/ui_view_group.h"
-#include "components/ui_image_animator.h"
-
-namespace OHOS
-{
- static constexpr int16_t TB_SHUTDOWN_ANIM_X_TEST = 0;
- static constexpr int16_t TB_SHUTDOWN_ANIM_Y_TEST = 0;
- static constexpr int16_t TB_SHUTDOWN_ANIM_W_TEST = 360;
- static constexpr int16_t TB_SHUTDOWN_ANIM_H_TEST = 360;
- static constexpr int16_t TB_SHUTDOWN_ANIM_FRAMES_TEST = 86;
- static constexpr int16_t TB_SHUTDOWN_ANIM_INTERVAL_TEST = 41;
- static constexpr const char *TB_SHUTDOWN_ANIM_PATH_TEST = "/user/res/emoticon/naughty";
- class ThunderBirdShutdownTestView : public UIImageAnimatorView::AnimatorStopListener
- {
- public:
- ThunderBirdShutdownTestView();
- virtual ~ThunderBirdShutdownTestView();
-
- static ThunderBirdShutdownTestView *GetInstance();
-
- UIViewGroup *Init();
- UIImageAnimatorView *GetAnimator();
-
- void StartAnimation();
-
- private:
- void OnAnimatorStop(UIView &view) override;
- void ClearAll();
- bool EnsureAnimator();
-
- private:
- UIViewGroup *group{nullptr};
- UIImageAnimatorView *animator{nullptr};
- ImageAnimatorInfo imageInfos[TB_SHUTDOWN_ANIM_FRAMES_TEST];
- UIImageView *iconView{nullptr};
- const char **pathsArray{nullptr};
- };
-}
-
-#endif
-
-
+++ /dev/null
-#ifndef THUNDERBIRD_SHUTDOWN_VIEW_H
-#define THUNDERBIRD_SHUTDOWN_VIEW_H
-
-#include "components/ui_view_group.h"
-#include "components/ui_image_animator.h"
-
-namespace OHOS
-{
- static constexpr int16_t TB_SHUTDOWN_ANIM_X = 0;
- static constexpr int16_t TB_SHUTDOWN_ANIM_Y = 0;
- static constexpr int16_t TB_SHUTDOWN_ANIM_W = 360;
- static constexpr int16_t TB_SHUTDOWN_ANIM_H = 360;
- static constexpr int16_t TB_SHUTDOWN_ANIM_FRAMES = 95;
- static constexpr int16_t TB_SHUTDOWN_ANIM_INTERVAL = 41;
- static constexpr const char *TB_SHUTDOWN_ANIM_PATH = "/user/res/RebootAndShutDown/ShutDown/";
-
- class ThunderBirdShutdownView : public UIImageAnimatorView::AnimatorStopListener
- {
- public:
- ThunderBirdShutdownView();
- virtual ~ThunderBirdShutdownView();
-
- static ThunderBirdShutdownView *GetInstance();
-
- UIViewGroup *ThunderBirdShutdownViewInit();
- UIImageAnimatorView *GetAnimator();
-
- void StartShutdownAnimation();
-
- private:
- void OnAnimatorStop(UIView &view) override;
- void ClearAll();
- bool EnsureAnimator();
-
- private:
- UIViewGroup *group{nullptr};
- UIImageAnimatorView *shutdownAnimator{nullptr};
- ImageAnimatorInfo shutdownImageInfo[TB_SHUTDOWN_ANIM_FRAMES];
- const char **shutdownPathsArray{nullptr};
- };
-}
-
-#endif
-
-
+++ /dev/null
-#include "thunderbird/include/ThunderBirdAdjustView.h"
-#include "wearable_log.h"
-#include "common/image_cache_manager.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 (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 (RemindIcon3 != nullptr) { delete RemindIcon3; RemindIcon3 = nullptr; }
- if (netAnimator != nullptr) { delete netAnimator; netAnimator = nullptr; }
- if (BackGround != nullptr) { delete BackGround; BackGround = nullptr; }
- }
-
- bool ThunderBirdAdjustView::EnsureNetAnimator()
- {
- if (netAnimator == nullptr)
- {
- netPathsArray = TB_NET_PATHS;
- netAnimator = new UIImageAnimatorView();
- if (netAnimator == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdDialogueView new UIImageAnimatorView fail");
- return false;
- }
- netAnimator->SetAutoEnable(false);
- for (uint8_t i = 0; i < TB_NET_ANIM_FRAMES; i++)
- {
- netImageInfo[i].imagePath = (netPathsArray[i]);
- netImageInfo[i].imageType = IMG_SRC_FILE_PATH;
- netImageInfo[i].pos.x = TB_NET_ANIM_X;
- netImageInfo[i].pos.y = TB_NET_ANIM_Y;
- netImageInfo[i].width = TB_NET_ANIM_W;
- netImageInfo[i].height = TB_NET_ANIM_H;
- }
- netAnimator->SetPosition(TB_NET_ANIM_X, TB_NET_ANIM_Y, TB_NET_ANIM_W, TB_NET_ANIM_H);
- netAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
- netAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
- netAnimator->SetImageAnimatorSrc(netImageInfo, TB_NET_ANIM_FRAMES, TB_NET_ANIM_INTERVAL);
- netAnimator->SetRepeat(true);
- netAnimator->SetRepeatTimes(1);
- netAnimator->SetResizeMode(UIImageView::COVER);
- //netAnimator->SetAnimatorStopListener(this);
- }
- return true;
- }
-
- 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, 360, 360);
-
- // 公共控件
- BackGround = new UIImageView();
- if (BackGround)
- {
- BackGround->SetAutoEnable(false);
- BackGround->SetPosition(0, 0, 360, 360);
- BackGround->SetSrc("/user/res/yellowbg.bin");
- BackGround->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- BackGround->SetResizeMode(UIImageView::CONTAIN);
- BackGround->SetVisible(true);
- group->Add(BackGround);
- }
- if(!EnsureNetAnimator())
- {
- return nullptr;
- }
- group->Add(netAnimator);
- TextLabel = new UILabelExt();
- if (TextLabel)
- {
- TextLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT);
- TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- TextLabel->SetVisible(false);
- group->Add(TextLabel);
- }
- RemindIcon = new UIImageView();
- if (RemindIcon)
- {
- RemindIcon->SetAutoEnable(false);
- RemindIcon->SetVisible(false);
- RemindIcon->SetResizeMode(UIImageView::CONTAIN);
- group->Add(RemindIcon);
- }
- RemindIcon2 = new UIImageView();
- if (RemindIcon2)
- {
- RemindIcon2->SetAutoEnable(false);
- RemindIcon2->SetVisible(false);
- RemindIcon2->SetResizeMode(UIImageView::CONTAIN);
- group->Add(RemindIcon2);
- }
- RemindIcon3 = new UIImageView();
- if (RemindIcon3)
- {
- RemindIcon3->SetAutoEnable(false);
- RemindIcon3->SetVisible(false);
- RemindIcon3->SetResizeMode(UIImageView::CONTAIN);
- group->Add(RemindIcon3);
- }
- RemindLabel = new UILabelExt();
- if (RemindLabel)
- {
- RemindLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT);
- RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- RemindLabel->SetVisible(false);
- group->Add(RemindLabel);
- }
- return group;
- }
-
- void ThunderBirdAdjustView::Show(int16_t showView)
- {
- if (group == nullptr) { return; }
- if (TextLabel) { TextLabel->SetVisible(false);}
- if (RemindLabel) { RemindLabel->SetVisible(false);}
- if (RemindIcon) { RemindIcon->SetVisible(false); }
- if (RemindIcon2) { RemindIcon2->SetVisible(false); }
- if (RemindIcon3) { RemindIcon3->SetVisible(false); }
- if (netAnimator) { netAnimator->SetVisible(false); netAnimator->Stop(); }
- switch (showView)
- {
- case THUNDERBIRD_ADJUSTVIEW_BIND_SUCCESS:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(142, 148, 120, 42);
- TextLabel->SetText("绑定成功");
- TextLabel->SetVisible(true);
- }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(132, 284, 96, 28);
- RemindLabel->SetText("按 确认");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(98, 146, 36, 36);
- RemindIcon->SetSrc("/user/res/completed.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(158, 286, 24, 24);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_ADJUSTVIEW_WARNING:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(112, 148, 180, 42);
- TextLabel->SetText("网络连接失败");
- TextLabel->SetVisible(true);
- }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(80, 275, 200, 25);
- RemindLabel->SetText("按 退出 按 重试");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(68, 146, 36, 36);
- RemindIcon->SetSrc("/user/res/warning.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(105, 277, 22, 22);
- RemindIcon2->SetSrc("/user/res/volume_down.bin");
- RemindIcon2->SetVisible(true);
- }
- if (RemindIcon3)
- {
- RemindIcon3->SetPosition(211, 276, 22, 22);
- RemindIcon3->SetSrc("/user/res/volume_up.bin");
- RemindIcon3->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_ADJUSTVIEW_NETWORK_CONNECTING:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(82, 148, 240, 42);
- TextLabel->SetText("正在重新连接网络");
- TextLabel->SetVisible(true);
- }
- if (netAnimator) { netAnimator->SetVisible(true); netAnimator->Start(); }
- break;
- }
- default:
- break;
- }
- }
-}
-
-
+++ /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 (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; }
- if (TextLabel_Y != nullptr) { delete TextLabel_Y; TextLabel_Y = nullptr; }
-
- if (speakAnimator != nullptr) { delete speakAnimator; speakAnimator = nullptr; }
- if (listenAnimator != nullptr) { delete listenAnimator; listenAnimator = nullptr; }
- }
- bool ThunderBirdDialogueView::EnsureSpeakAnimator()
- {
- if (speakAnimator == nullptr)
- {
- speakPathsArray = TB_SPEAK_PATHS;
- speakAnimator = new UIImageAnimatorView();
- if (speakAnimator == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdDialogueView new UIImageAnimatorView fail");
- return false;
- }
- speakAnimator->SetAutoEnable(false);
- for (uint8_t i = 0; i < TB_SPEAK_ANIM_FRAMES; i++)
- {
- speakImageInfo[i].imagePath = (speakPathsArray[i]);
- speakImageInfo[i].imageType = IMG_SRC_FILE_PATH;
- speakImageInfo[i].pos.x = TB_SPEAK_ANIM_X;
- speakImageInfo[i].pos.y = TB_SPEAK_ANIM_Y;
- speakImageInfo[i].width = TB_SPEAK_ANIM_W;
- speakImageInfo[i].height = TB_SPEAK_ANIM_H;
- }
- speakAnimator->SetPosition(TB_SPEAK_ANIM_X, TB_SPEAK_ANIM_Y, TB_SPEAK_ANIM_W, TB_SPEAK_ANIM_H);
- speakAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
- speakAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
- speakAnimator->SetImageAnimatorSrc(speakImageInfo, TB_SPEAK_ANIM_FRAMES, TB_SPEAK_ANIM_INTERVAL);
- speakAnimator->SetRepeat(true);
- speakAnimator->SetRepeatTimes(1);
- speakAnimator->SetResizeMode(UIImageView::COVER);
- //speakAnimator->SetAnimatorStopListener(this);
- }
- return true;
- }
- bool ThunderBirdDialogueView::EnsureListenAnimator()
- {
- if (listenAnimator == nullptr)
- {
- listenPathsArray = TB_LISTEN_PATHS;
- listenAnimator = new UIImageAnimatorView();
- if (listenAnimator == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdDialogueView new UIImageAnimatorView fail");
- return false;
- }
- listenAnimator->SetAutoEnable(false);
- for (uint8_t i = 0; i < TB_LISTEN_ANIM_FRAMES; i++)
- {
- listenImageInfo[i].imagePath = (listenPathsArray[i]);
- listenImageInfo[i].imageType = IMG_SRC_FILE_PATH;
- listenImageInfo[i].pos.x = TB_LISTEN_ANIM_X;
- listenImageInfo[i].pos.y = TB_LISTEN_ANIM_Y;
- listenImageInfo[i].width = TB_LISTEN_ANIM_W;
- listenImageInfo[i].height = TB_LISTEN_ANIM_H;
- }
- listenAnimator->SetPosition(TB_LISTEN_ANIM_X, TB_LISTEN_ANIM_Y, TB_LISTEN_ANIM_W, TB_LISTEN_ANIM_H);
- listenAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
- listenAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
- listenAnimator->SetImageAnimatorSrc(listenImageInfo, TB_LISTEN_ANIM_FRAMES, TB_LISTEN_ANIM_INTERVAL);
- listenAnimator->SetRepeat(true);
- listenAnimator->SetRepeatTimes(1);
- listenAnimator->SetResizeMode(UIImageView::COVER);
- //listenAnimator->SetAnimatorStopListener(this);
- }
- return true;
- }
-
- 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, 360, 360);
-
- // 公共控件
- TextLabel_Y = new UILabelExt();
- if (TextLabel_Y)
- {
- TextLabel_Y->SetPosition(2, 66, 360, 42);
- TextLabel_Y->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- TextLabel_Y->SetStyle(STYLE_TEXT_COLOR, 0xff000000);
- TextLabel_Y->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- TextLabel_Y->SetVisible(false);
- group->Add(TextLabel_Y);
- }
- TextLabel = new UILabelExt();
- if (TextLabel)
- {
- TextLabel->SetPosition(0, 64, 360, 42);
- TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
- TextLabel->SetRollSpeed(35);
- TextLabel->SetVisible(false);
- group->Add(TextLabel);
- }
- if(!EnsureSpeakAnimator())
- {
- return nullptr;
- }
- if(!EnsureListenAnimator())
- {
- return nullptr;
- }
- group->Add(speakAnimator);
- group->Add(listenAnimator);
-
- return group;
- }
-
- void ThunderBirdDialogueView::Show(int16_t showView)
- {
- if (group == nullptr) { return; }
- if (TextLabel) { TextLabel->SetVisible(false);}
- if (TextLabel_Y) { TextLabel_Y->SetVisible(false);}
- if (speakAnimator) { speakAnimator->SetVisible(false); speakAnimator->Stop(); }
- if (listenAnimator) { listenAnimator->SetVisible(false); listenAnimator->Stop(); }
-
- switch (showView)
- {
- case THUNDERBIRD_DIALOGUEVIEW_SPEAKING:
- {
- if (TextLabel)
- {
- TextLabel->SetText("保镖小姐 , 你来啦");
- TextLabel->SetVisible(true);
- }
- if (TextLabel_Y)
- {
- TextLabel_Y->SetText("保镖小姐 , 你来啦");
- TextLabel_Y->SetVisible(true);
- }
- //动效图标
- if (speakAnimator) { speakAnimator->SetVisible(true); speakAnimator->Start(); }
- break;
- }
- case THUNDERBIRD_DIALOGUEVIEW_LISTENING:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(111, 64, 180, 42);
- TextLabel->SetText("超认真聆听中");
- TextLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT);
- TextLabel->SetVisible(true);
- }
- if (TextLabel_Y)
- {
- TextLabel_Y->SetPosition(113, 66, 180, 42);
- TextLabel_Y->SetText("超认真聆听中");
- TextLabel_Y->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT);
- TextLabel_Y->SetVisible(true);
- }
- //动效图标
- if (listenAnimator) { listenAnimator->SetVisible(true); listenAnimator->Start(); }
- break;
- }
- case THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(111, 64, 180, 42);
- TextLabel->SetText("发呆中...");
- TextLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT);
- TextLabel->SetVisible(true);
- }
- if (TextLabel_Y)
- {
- TextLabel_Y->SetPosition(113, 66, 180, 42);
- TextLabel_Y->SetText("发呆中...");
- TextLabel_Y->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT);
- TextLabel_Y->SetVisible(true);
- }
- break;
- }
- default:
- break;
- }
- }
-}
-
-
+++ /dev/null
-#include "thunderbird/include/ThunderBirdGuideView.h"
-#include "thunderbird/include/ThunderBirdMainView.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 (RemindButton != nullptr) { delete RemindButton; RemindButton = nullptr; }
- if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; }
- if (TextLabel_Y != nullptr) { delete TextLabel_Y; TextLabel_Y = nullptr; }
- if (qrcode_ != nullptr) { delete qrcode_; qrcode_ = nullptr; }
- if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; }
- if (RemindGround != nullptr) { delete RemindGround; RemindGround = nullptr; }
- if (RemindIcon != nullptr) { delete RemindIcon; RemindIcon = nullptr; }
- if (RemindIcon2 != nullptr) { delete RemindIcon2; RemindIcon2 = 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, 360, 360);
-
- // 公共控件
- TextLabel_Y = new UILabelExt();
- if (TextLabel_Y)
- {
- TextLabel_Y->SetPosition(0, 106, 360, 48);
- TextLabel_Y->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- TextLabel_Y->SetStyle(STYLE_TEXT_COLOR, 0xff000000);
- TextLabel_Y->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- TextLabel_Y->SetStyle(STYLE_LINE_SPACE, 10);
- TextLabel_Y->SetStyle(STYLE_LETTER_SPACE, 1);
- TextLabel_Y->SetVisible(false);
- group->Add(TextLabel_Y);
- }
- TextLabel = new UILabelExt();
- if (TextLabel)
- {
- TextLabel->SetPosition(0, 104, 360, 48);
- TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- TextLabel->SetStyle(STYLE_LINE_SPACE, 10);
- TextLabel->SetStyle(STYLE_LETTER_SPACE, 1);
-
- TextLabel->SetVisible(false);
- group->Add(TextLabel);
- }
- qrcode_ = new UIQrcode();
- if (qrcode_)
- {
- qrcode_->SetPosition(133, 169, 104, 104);
- qrcode_->SetQrcodeInfo("https://example.com/device/bind?deviceId=DEVICE_001");
- qrcode_->SetStyle(STYLE_PADDING_LEFT, 4);
- qrcode_->SetStyle(STYLE_PADDING_RIGHT, 4);
- qrcode_->SetStyle(STYLE_PADDING_TOP, 4);
- qrcode_->SetStyle(STYLE_PADDING_BOTTOM, 4);
- qrcode_->SetVisible(false);
- group->Add(qrcode_);
- }
-
- RemindButton = new UILabelButton();
- if (RemindButton)
- {
- RemindButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff635d58, UIButton::RELEASED);
- RemindButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff7c7773, UIButton::RELEASED);
- RemindButton->SetStyleForState(STYLE_BORDER_WIDTH, 2, UIButton::RELEASED);
- RemindButton->SetVisible(false);
- group->Add(RemindButton);
- }
- RemindGround = new UIImageView();
- if (RemindGround)
- {
- RemindGround->SetAutoEnable(false);
- RemindGround->SetPosition(128, 164, 94, 94);
- RemindGround->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- RemindGround->SetResizeMode(UIImageView::CONTAIN);
- RemindGround->SetVisible(false);
- group->Add(RemindGround);
- }
- RemindLabel = new UILabelExt();
- if (RemindLabel)
- {
- RemindLabel->SetPosition(0, 180, 360, 40);
- RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- RemindLabel->SetVisible(false);
- group->Add(RemindLabel);
- }
- RemindIcon = new UIImageView();
- if (RemindIcon)
- {
- RemindIcon->SetAutoEnable(false);
- RemindIcon->SetPosition(280, 320, 30, 30);
- RemindIcon->SetResizeMode(UIImageView::CONTAIN);
- RemindIcon->SetVisible(false);
- group->Add(RemindIcon);
- }
-
- RemindIcon2 = new UIImageView();
- if (RemindIcon2)
- {
- RemindIcon2->SetAutoEnable(false);
- RemindIcon2->SetVisible(false);
- group->Add(RemindIcon2);
- }
-
- return group;
- }
-
- void ThunderBirdGuideView::Show(int16_t showView)
- {
- if (group == nullptr) { return; }
- if (TextLabel) { TextLabel->SetVisible(false);TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);}
- if (TextLabel_Y) { TextLabel_Y->SetVisible(false); }
- if (qrcode_) { qrcode_->SetVisible(false); }
- if (RemindButton) { RemindButton->SetVisible(false); }
- if (RemindLabel) { RemindLabel->SetVisible(false); }
- if (RemindIcon) { RemindIcon->SetVisible(false); }
- if (RemindIcon2) { RemindIcon2->SetVisible(false); }
-
- switch (showView)
- {
- case THUNDERBIRD_GUIDEVIEW_1:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(0, 64, 360, 42);
- TextLabel->SetText("Hey, 我是Amby~");
- TextLabel->SetVisible(true);
- }
- if (TextLabel_Y)
- {
- TextLabel_Y->SetPosition(2, 66, 360, 42);
- TextLabel_Y->SetText("Hey, 我是Amby~");
- TextLabel_Y->SetVisible(true);
- }
- if (RemindButton)
- {
- RemindButton->SetPosition(106, 114, 148, 40);
- RemindButton->SetText("按 下一页");
- RemindButton->SetLabelPosition(2, 0);
- RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- RemindButton->SetVisible(true);
- }
- if(RemindIcon)
- {
- RemindIcon->SetPosition(152, 122, 24, 24);
- RemindIcon->SetSrc("/user/res/volume_up.bin");
- RemindIcon->SetVisible(true);
- }
-
- break;
- }
- case THUNDERBIRD_GUIDEVIEW_2:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(0, 64, 360, 42);
- TextLabel->SetText("我可以和你聊天,哄你睡觉");
- TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
- TextLabel->SetRollSpeed(35);
- TextLabel->SetVisible(true);
- }
- if (TextLabel_Y)
- {
- TextLabel_Y->SetPosition(2, 66, 360, 42);
- TextLabel_Y->SetText("我可以和你聊天,哄你睡觉");
- TextLabel_Y->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
- TextLabel_Y->SetRollSpeed(35);
- TextLabel_Y->SetVisible(true);
- }
- if (RemindButton)
- {
- RemindButton->SetPosition(106, 114, 148, 40);
- RemindButton->SetText("按 下一页");
- RemindButton->SetLabelPosition(2, 0);
- RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- RemindButton->SetVisible(true);
- }
- if(RemindIcon)
- {
- RemindIcon->SetPosition(152, 122, 24, 24);
- RemindIcon->SetSrc("/user/res/volume_up.bin");
- RemindIcon->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_GUIDEVIEW_3:
- {
- ThunderBirdMainView::GetInstance()->OpenBackGround();
- if (TextLabel)
- {
- TextLabel->SetPosition(60, 64, 250, 84);
- TextLabel->SetText("换角色、挑声音、\n哄睡...扫码尽享!");
- TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);//自动换行
- TextLabel->SetVisible(true);
- }
- if (qrcode_)
- {
- qrcode_->SetVisible(true);
- }
- if(RemindIcon)
- {
- RemindIcon->SetPosition(158, 296, 30, 30);
- RemindIcon->SetSrc("/user/res/volume_up.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindButton)
- {
- RemindButton->SetPosition(116, 288, 148, 40);
- RemindButton->SetText("按 跳过");
- RemindButton->SetLabelPosition(2, 0);
- RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- RemindButton->SetVisible(true);
- }
-
- break;
- }
- default:
- break;
- }
- }
-}
-
-
+++ /dev/null
-#include "thunderbird/include/ThunderBirdLullabyView.h"
-#include "thunderbird/include/ThunderBirdMainView.h"
-#include "wearable_log.h"
-#include <cstdio>
-#include <string>
-#include "UiConfig.h"
-
-namespace OHOS
-{
- static ThunderBirdLullabyView *g_pThunderBirdLullabyView{nullptr};
- static const char *TB_LULLABY_LISTEN_PATHS[TB_LISTEN_FRAMES] = {
- TB_LISTEN_IMAGE_1,
- TB_LISTEN_IMAGE_2,
- TB_LISTEN_IMAGE_3,
- TB_LISTEN_IMAGE_4,
- TB_LISTEN_IMAGE_5,
- TB_LISTEN_IMAGE_6,
- TB_LISTEN_IMAGE_7,
- TB_LISTEN_IMAGE_8,
- TB_LISTEN_IMAGE_9,
- TB_LISTEN_IMAGE_10,
- TB_LISTEN_IMAGE_11,
- TB_LISTEN_IMAGE_12,
- TB_LISTEN_IMAGE_13,
- TB_LISTEN_IMAGE_14,
- TB_LISTEN_IMAGE_15,
- TB_LISTEN_IMAGE_16,
- TB_LISTEN_IMAGE_17,
- TB_LISTEN_IMAGE_18,
- TB_LISTEN_IMAGE_19,
- TB_LISTEN_IMAGE_20,
- TB_LISTEN_IMAGE_21,
- TB_LISTEN_IMAGE_22,
- TB_LISTEN_IMAGE_23,
- TB_LISTEN_IMAGE_24,
- TB_LISTEN_IMAGE_25,
- TB_LISTEN_IMAGE_26,
- TB_LISTEN_IMAGE_27,
- TB_LISTEN_IMAGE_28,
- TB_LISTEN_IMAGE_29,
- TB_LISTEN_IMAGE_30,
- TB_LISTEN_IMAGE_31,
- TB_LISTEN_IMAGE_32,
- TB_LISTEN_IMAGE_33,
- TB_LISTEN_IMAGE_34,
- TB_LISTEN_IMAGE_35,
- TB_LISTEN_IMAGE_36,
- TB_LISTEN_IMAGE_37,
- TB_LISTEN_IMAGE_38,
- TB_LISTEN_IMAGE_39,
- TB_LISTEN_IMAGE_40,
- TB_LISTEN_IMAGE_41,
- TB_LISTEN_IMAGE_42,
- TB_LISTEN_IMAGE_43,
- TB_LISTEN_IMAGE_44,
- TB_LISTEN_IMAGE_45,
- TB_LISTEN_IMAGE_46,
- TB_LISTEN_IMAGE_47,
- TB_LISTEN_IMAGE_48,
- TB_LISTEN_IMAGE_49,
- TB_LISTEN_IMAGE_50,
- TB_LISTEN_IMAGE_51,
- TB_LISTEN_IMAGE_52,
- TB_LISTEN_IMAGE_53,
- TB_LISTEN_IMAGE_54,
- TB_LISTEN_IMAGE_55,
- TB_LISTEN_IMAGE_56,
- TB_LISTEN_IMAGE_57,
- TB_LISTEN_IMAGE_58,
- TB_LISTEN_IMAGE_59,
- TB_LISTEN_IMAGE_60,
- TB_LISTEN_IMAGE_61,
- TB_LISTEN_IMAGE_62,
- TB_LISTEN_IMAGE_63,
- TB_LISTEN_IMAGE_64,
- TB_LISTEN_IMAGE_65,
- TB_LISTEN_IMAGE_66,
- TB_LISTEN_IMAGE_67,
- TB_LISTEN_IMAGE_68,
- TB_LISTEN_IMAGE_69,
- TB_LISTEN_IMAGE_70,
- TB_LISTEN_IMAGE_71,
- TB_LISTEN_IMAGE_72,
- TB_LISTEN_IMAGE_73,
- TB_LISTEN_IMAGE_74,
- TB_LISTEN_IMAGE_75,
- TB_LISTEN_IMAGE_76,
- TB_LISTEN_IMAGE_77,
- TB_LISTEN_IMAGE_78,
- TB_LISTEN_IMAGE_79,
- TB_LISTEN_IMAGE_80,
- TB_LISTEN_IMAGE_81,
- TB_LISTEN_IMAGE_82,
- TB_LISTEN_IMAGE_83,
- TB_LISTEN_IMAGE_84,
- TB_LISTEN_IMAGE_85,
- TB_LISTEN_IMAGE_86,
- TB_LISTEN_IMAGE_87,
- TB_LISTEN_IMAGE_88,
- TB_LISTEN_IMAGE_89,
- TB_LISTEN_IMAGE_90,
- TB_LISTEN_IMAGE_91,
- TB_LISTEN_IMAGE_92,
- TB_LISTEN_IMAGE_93,
- TB_LISTEN_IMAGE_94,
- TB_LISTEN_IMAGE_95,
- };
-
- 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 (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; }
- if (TextLabel_Y != nullptr) { delete TextLabel_Y; TextLabel_Y = nullptr; }
- if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; }
- if (RemindIcon != nullptr) { delete RemindIcon; RemindIcon = nullptr; }
- if (RemindIcon2 != nullptr) { delete RemindIcon2; RemindIcon2 = nullptr; }
- if (listenAnimator != nullptr) { delete listenAnimator; listenAnimator = nullptr; }
- }
- bool ThunderBirdLullabyView::EnsureListenAnimator()
- {
- if (listenAnimator == nullptr)
- {
- listenPathsArray = TB_LULLABY_LISTEN_PATHS;
- listenAnimator = new UIImageAnimatorView();
- if (listenAnimator == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdLullabyView new UIImageAnimatorView fail");
- return false;
- }
- listenAnimator->SetAutoEnable(false);
- for (uint8_t i = 0; i < TB_LISTEN_FRAMES; i++)
- {
- listenImageInfo[i].imagePath = (listenPathsArray[i]);
- listenImageInfo[i].imageType = IMG_SRC_FILE_PATH;
- listenImageInfo[i].pos.x = TB_LISTEN_X;
- listenImageInfo[i].pos.y = TB_LISTEN_Y;
- listenImageInfo[i].width = TB_LISTEN_W;
- listenImageInfo[i].height = TB_LISTEN_H;
- }
- listenAnimator->SetPosition(TB_LISTEN_X, TB_LISTEN_Y, TB_LISTEN_W, TB_LISTEN_H);
- listenAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
- listenAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- listenAnimator->SetImageAnimatorSrc(listenImageInfo, TB_LISTEN_FRAMES, TB_LISTEN_INTERVAL);
- listenAnimator->SetRepeat(false);
- listenAnimator->SetRepeatTimes(1);
- listenAnimator->SetResizeMode(UIImageView::COVER);
- //listenAnimator->SetAnimatorStopListener(this);
- }
- return true;
- }
-
- 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, 360, 360);
-
- // 公共控件
- TextLabel_Y = new UILabelExt();
- if (TextLabel_Y)
- {
- TextLabel_Y->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- TextLabel_Y->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- TextLabel_Y->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
- TextLabel_Y->SetVisible(false);
- group->Add(TextLabel_Y);
- }
- TextLabel = new UILabelExt();
- if (TextLabel)
- {
- TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- TextLabel->SetVisible(false);
- group->Add(TextLabel);
- }
-
- RemindLabel = new UILabelExt();
- if (RemindLabel)
- {
- RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- RemindLabel->SetVisible(false);
- group->Add(RemindLabel);
- }
- RemindIcon = new UIImageView();
- if (RemindIcon)
- {
- RemindIcon->SetAutoEnable(false);
- RemindIcon->SetVisible(false);
- RemindIcon->SetResizeMode(UIImageView::CONTAIN);
- group->Add(RemindIcon);
- }
- RemindIcon2 = new UIImageView();
- if (RemindIcon2)
- {
- RemindIcon2->SetAutoEnable(false);
- RemindIcon2->SetVisible(false);
- RemindIcon2->SetResizeMode(UIImageView::CONTAIN);
- group->Add(RemindIcon2);
- }
- if(!EnsureListenAnimator())
- {
- return nullptr;
- }
- group->Add(listenAnimator);
-
- return group;
- }
-
- void ThunderBirdLullabyView::Show(int16_t showView)
- {
- ThunderBirdModel::GetInstance()->StopCountUpTimer();//每次进入哄睡界面都停止定时器
- if (group == nullptr) { return; }
- if (TextLabel) { TextLabel->SetVisible(false); TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); }
- if (TextLabel_Y) { TextLabel_Y->SetVisible(false); }
- if (RemindLabel) { RemindLabel->SetVisible(false);}
- if (RemindIcon) { RemindIcon->SetVisible(false); }
- if (RemindIcon2) { RemindIcon2->SetVisible(false); }
- if (listenAnimator) { listenAnimator->SetVisible(false); listenAnimator->Stop(); }
-
- switch (showView)
- {
- case THUNDERBIRD_LULLABYVIEW_1:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(43, 64, 280, 42);
- TextLabel->SetText("按 说「哄我睡觉」");
- TextLabel->SetVisible(true);
- }
- if (TextLabel_Y)
- {
- TextLabel_Y->SetPosition(45, 66, 280, 42);
- TextLabel_Y->SetText("按 说「哄我睡觉」");
- TextLabel_Y->SetVisible(true);
- }
- if(RemindIcon)
- {
- RemindIcon->SetPosition(75, 65, 36, 36);
- RemindIcon->SetSrc("/user/res/voice.bin");
- RemindIcon->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_LULLABYVIEW_2:
- {
- ThunderBirdMainView::GetInstance()->OpenBackGround();
- if (TextLabel)
- {
- TextLabel->SetPosition(60, 140, 240, 42);
- TextLabel->SetText("是否开启哄睡模式");
- TextLabel->SetVisible(true);
- }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(80, 275, 200, 25);
- RemindLabel->SetText("按 退出 按 确认");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(105, 276, 22, 22);
- RemindIcon->SetSrc("/user/res/volume_down.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(211, 276, 22, 22);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_LULLABYVIEW_3:
- {
- ThunderBirdMainView::GetInstance()->OpenBackGround();
- if (TextLabel)
- {
- TextLabel->SetPosition(82, 148, 240, 42);
- TextLabel->SetText("告诉我想听的故事");
- TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
- TextLabel->SetRollSpeed(35);
- TextLabel->SetVisible(true);
- }
- if (listenAnimator) { listenAnimator->SetVisible(true); listenAnimator->Start(); }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(80, 275, 200, 25);
- RemindLabel->SetText("按 退出 按 随机");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(105, 276, 22, 22);
- RemindIcon->SetSrc("/user/res/volume_down.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(211, 276, 22, 22);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_LULLABYVIEW_4:
- {
- ThunderBirdModel::GetInstance()->StartCountUpTimer(15 * 60);
- if (TextLabel)
- {
- TextLabel->SetPosition(0, 64, 360, 42);
- TextLabel->SetText("从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?");
- TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
- TextLabel->SetRollSpeed(35);
- TextLabel->SetVisible(true);
- }
- if (TextLabel_Y)
- {
- TextLabel_Y->SetPosition(2, 66, 360, 42);
- TextLabel_Y->SetText("从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?从前有座山,山里有座庙,庙里有个老和尚,老和尚给小和尚讲故事,讲什么呢?");
- TextLabel_Y->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
- TextLabel_Y->SetRollSpeed(35);
- TextLabel_Y->SetVisible(true);
- }
- if(RemindLabel)
- {
-
- RemindLabel->SetPosition(115, 114, 131, 28);
- RemindLabel->SetText("04:00/15:00");
- RemindLabel->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_LULLABYVIEW_5:
- {
- ThunderBirdMainView::GetInstance()->OpenBackGround();
- if (TextLabel)
- {
- TextLabel->SetPosition(60, 148, 240, 42);
- TextLabel->SetText("是否退出哄睡模式");
- TextLabel->SetVisible(true);
- }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(80, 275, 200, 25);
- RemindLabel->SetText("按 退出 按 确认");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(105, 276, 22, 22);
- RemindIcon->SetSrc("/user/res/volume_down.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(211, 276, 22, 22);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- break;
- }
- default:
- break;
- }
- }
- void ThunderBirdLullabyView::UpdateTimeText(uint32_t currentSeconds, uint32_t totalSeconds)
- {
- if (RemindLabel == nullptr) { return; }
- // 保护:避免除零或异常
- uint32_t safeTotal = (totalSeconds == 0) ? 1 : totalSeconds;
- // 取值范围保护:当前不能超过总时长
- if (currentSeconds > safeTotal) { currentSeconds = safeTotal; }
-
- // 格式化为 mm:ss/mm:ss
- auto formatToMMSS = [](uint32_t seconds) -> std::string {
- uint32_t minutes = seconds / 60;
- uint32_t secs = seconds % 60;
- char buf[8]; // mm:ss + \0
- std::snprintf(buf, sizeof(buf), "%02u:%02u", minutes, secs);
- return std::string(buf);
- };
-
- std::string left = formatToMMSS(currentSeconds);
- std::string right = formatToMMSS(safeTotal);
- std::string merged = left + "/" + right;
- RemindLabel->SetText(merged.c_str());
- }
-}
-
-
+++ /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 "thunderbird/include/ThunderBirdShutdownView.h"
-#include "thunderbird/include/ThunderBirdShutdownTestView.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"
-#include <service/graphic_service.h>
-#include "ln_api.h"
-namespace OHOS
-{
- static constexpr int16_t VIDEO_WIDTH = 360;
- static constexpr int16_t VIDEO_HEIGHT = 360;
- 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 MediaVideoPlay *g_videoPlay = nullptr;
- static bool g_lastPlayed = false;
-
- static ThunderBirdShutdownView *g_pThunderBirdShutdownView{nullptr};
- 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_LOGE(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_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 (g_pThunderBirdShutdownView)
- {
- delete g_pThunderBirdShutdownView;
- g_pThunderBirdShutdownView = nullptr;
- }
- if (g_pThunderBirdShutdownTestView)
- {
- delete g_pThunderBirdShutdownTestView;
- g_pThunderBirdShutdownTestView = nullptr;
- }
- if (g_pThunderBirdShutdownView)
- {
- delete g_pThunderBirdShutdownView;
- g_pThunderBirdShutdownView = nullptr;
- }
- // 置空所有分组索引,避免悬空指针
- for (int i = 0; i < MAXVIEW; i++)
- {
- group[i] = nullptr;
- }
-
- // 不再持有旧 View 实例,全部使用聚合组件
- // 先停止视频播放
- 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;
- }
- 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_);
-
- Initback(); // 最底层
-
- iconView = new UIImageView(); //(表情图片)需要遮罩时启用,预先增加在对应图层
- iconView->SetAutoEnable(false);
- iconView->SetPosition(0, 0, 360, 360);
- iconView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- iconView->SetResizeMode(UIImageView::COVER);
- iconView->SetSrc("/user/res/1.bin");
- iconView->SetVisible(false);
- ScrollView_->Add(iconView);
-
- backGroundView = new UIImageView(); //(黑色遮罩)需要遮罩时启用,预先增加在对应图层
- backGroundView->SetAutoEnable(false);
- backGroundView->SetPosition(0, 0, 360, 360);
- backGroundView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
- backGroundView->SetStyle(STYLE_BACKGROUND_OPA, 0xD0);
- backGroundView->SetVisible(false);
- ScrollView_->Add(backGroundView);
-
- // 默认显示主界面
- ChangeView(MAXVIEW, THUNDERBIRD_GUIDEVIEW, 0); // 文字显示图层
- //绑定设备提示 > 配置更新成功>OTA升级>其他(按触发时间先后提示)
- /*************************用户是否绑定*************************/
- // do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_GET_USER_ID, nullptr, 0);//获取用户是否绑定
- // if(uapi_ln_get_user_bind_status() == 0)//未绑定
- // {
- // ChangeView(MAXVIEW, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_1);
- // }
- // if(uapi_ln_get_user_bind_status() == 1)//已绑定
- // {
- // //ChangeView(MAXVIEW, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_2);进入对话界面
- // }
-
- // /*************************更新角色配置*************************/
- // do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_GET_CHARACTER, nullptr, 0);//获取角色配置
-
-
- // /*************************OTA升级*************************/
- // do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_GET_TASK, nullptr, 0);//获取是否需要OTA升级
- // if(uapi_ln_ota_get_update_type() == 1)//强制OTA升级
- // {
- // ChangeView(MAXVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW);
- // }
- // if(uapi_ln_ota_get_update_type() == 0)//可选OTA升级
- // {
- // ChangeView(MAXVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL);
- // }
-
- ScrollView_->Add(InitBaseData()); // 最上面状态栏
-
-
-
- // // 增加按键监听
- // 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);
- }
-
- void ThunderBirdMainView::CloseVideo() // 关闭表情接口
- {
- // 停止视频并释放播放器
- 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 (surfaceView_ != nullptr)
- {
- delete surfaceView_;
- surfaceView_ = nullptr;
- }
- if (curFace != nullptr)
- {
- delete curFace;
- curFace = nullptr;
- }
- }
-
- bool ThunderBirdMainView::ChangeThunderBirdOtaView(int16_t thisView) // 切换Ota界面接口
- {
- 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;
- }
- bool ThunderBirdMainView::ChangeThunderBirdShutdownView(int16_t thisView) // 切换关机界面接口
- {
- if (group[thisView] == nullptr)
- {
- g_pThunderBirdShutdownView = new ThunderBirdShutdownView();
- if (g_pThunderBirdShutdownView == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView new fail %d", thisView);
- return false;
- }
- group[thisView] = g_pThunderBirdShutdownView->ThunderBirdShutdownViewInit();
- ScrollView_->Add(group[thisView]);
- // 启动关机动动画
- g_pThunderBirdShutdownView->StartShutdownAnimation();
- }
- return true;
- }
- bool ThunderBirdMainView::ChangeThunderBirdShutdownTestView(int16_t thisView) // 切换关机测试界面接口
- {
- if (group[thisView] == nullptr)
- {
- g_pThunderBirdShutdownTestView = new ThunderBirdShutdownTestView();
- if (g_pThunderBirdShutdownTestView == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView new fail %d", thisView);
- return false;
- }
- group[thisView] = g_pThunderBirdShutdownTestView->Init();
- ScrollView_->Add(group[thisView]);
- g_pThunderBirdShutdownTestView->StartAnimation();
- }
- return true;
- }
-
- /**
- * 视图映射结构体 - 将视图ID映射到对应的视图切换函数
- */
- struct TBViewMapper
- {
- const int16_t viewId; // 视图ID
- bool (ThunderBirdMainView::*func)(int16_t); // 对应的视图切换函数指针
- };
-
- static const TBViewMapper ViewMapper[] = {
- {THUNDERBIRD_OTAVIEW, &ThunderBirdMainView::ChangeThunderBirdOtaView},
- {THUNDERBIRD_GUIDEVIEW, &ThunderBirdMainView::ChangeThunderBirdGuideView},
- {THUNDERBIRD_LULLABYVIEW, &ThunderBirdMainView::ChangeThunderBirdLullabyView},
- {THUNDERBIRD_DIALOGUEVIEW, &ThunderBirdMainView::ChangeThunderBirdDialogueView},
- {THUNDERBIRD_REMINDERVIEW, &ThunderBirdMainView::ChangeThunderBirdReminderView},
- {THUNDERBIRD_ADJUSTVIEW, &ThunderBirdMainView::ChangeThunderBirdAdjustView},
- {THUNDERBIRD_SHUTDOWNVIEW, &ThunderBirdMainView::ChangeThunderBirdShutdownView},
- {THUNDERBIRD_SHUTDOWNTESTVIEW, &ThunderBirdMainView::ChangeThunderBirdShutdownTestView},
- };
-
- 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, int16_t subView)
- {
- 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);
- }
- // 同用遮罩,部分界面在内部自行开启,其余界面关闭
- iconView->SetVisible(false);
- backGroundView->SetVisible(false);
- // 保存上一级视图信息
- prevView_ = currentView_;
- prevSubView_ = currentSubView_;
- ClickFunc(showView);
- group[showView]->SetVisible(true);
- group[showView]->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
- // 关键:把状态栏重新加到末尾,确保最上层
- if (group1)
- {
- ScrollView_->Remove(group1);
- ScrollView_->Add(group1);
- }
- // 进入大界面后,根据 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;
- case THUNDERBIRD_OTAVIEW:
- if (g_pThunderBirdOtaView)
- {
- g_pThunderBirdOtaView->Show(subView);
- }
- break;
- case THUNDERBIRD_DIALOGUEVIEW:
- if (g_pThunderBirdDialogueView)
- {
- g_pThunderBirdDialogueView->Show(subView);
- }
- break;
- case THUNDERBIRD_REMINDERVIEW:
- if (g_pThunderBirdReminderView)
- {
- g_pThunderBirdReminderView->Show(subView);
- }
- break;
- case THUNDERBIRD_ADJUSTVIEW:
- if (g_pThunderBirdAdjustView)
- {
- g_pThunderBirdAdjustView->Show(subView);
- }
- break;
- default:
- break;
- }
- }
- currentView_ = showView; // 更新当前视图
- currentSubView_ = subView; // 更新当前子视图
- ScrollView_->Invalidate();
- }
-
- void ThunderBirdMainView::OpenBackGround(void)//打开遮罩
- {
- iconView->SetVisible(true);
- backGroundView->SetVisible(true);
- }
-
- int16_t ThunderBirdMainView::GetCurrentView() const
- {
- return currentView_;
- }
- int16_t ThunderBirdMainView::GetCurrentSubView() const
- {
- return currentSubView_;
- }
-
- void ThunderBirdMainView::Initback()
- {
- curFace = new UIImageView();
- if (curFace == nullptr)
- {
- return;
- }
- curFace->SetAutoEnable(false);
- curFace->SetPosition(0, 0, 360, 360);
- curFace->SetResizeMode(UIImageView::COVER);
- curFace->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
- //curFace->SetStyle(STYLE_BACKGROUND_COLOR, 0xffe0c7c1);
- curFace->SetSrc("/user/res/501.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/Expression_0/Angry.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_)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::Initback videoPlay_->StartVideoPlay");
- videoPlay_->StartVideoPlay();
- }
-
- ScrollView_->Add(surfaceView_);
- ScrollView_->Add(curFace);
- }
-
- void ThunderBirdMainView::SwitchHair(const char *hairPath)
- {
- if (curFace == nullptr || hairPath == nullptr) {
- return;
- }
- curFace->SetSrc(hairPath);
- curFace->Invalidate();
- }
- UIViewGroup *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 nullptr;
- }
- }
- group1->SetPosition(90, 14, 175, 40);
- group1->SetStyle(STYLE_BACKGROUND_OPA, 0);
-
- timeLabel = new UILabelExt();
- if (timeLabel == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "timeLabel new fail");
- return nullptr;
- }
- timeLabel->SetPosition(0, 4, 60, 33);
- timeLabel->SetViewId("timeLabel");
- timeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24);
- timeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- timeLabel->SetVisible(true);
- 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 nullptr;
- }
- }
- NoSignal->SetAutoEnable(false);
- NoSignal->SetPosition(80, (group1->GetHeight() - 25) / 2, 25, 25);
- NoSignal->SetResizeMode(UIImageView::COVER);
- 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 = {
- {65, 28, 6, 6},
- {75, 20, 6, 14},
- {85, 12, 6, 22},
- {95, 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 nullptr;
- }
- }
- 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 nullptr;
- }
- batteryimage->SetAutoEnable(false);
- batteryimage->SetPosition(95 + 20, (group1->GetHeight() - 20) / 2, 32, 20);
- batteryimage->SetResizeMode(UIImageView::COVER);
- std::string batteryimagesPath = "/user/res/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 nullptr;
- }
- progress->SetPosition(batteryimage->GetX() + 5, batteryimage->GetY() + 4, 18, 12);
- progress->SetValidWidth(18);
- progress->SetValidHeight(12);
- 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);
- /* -----------------------------------电量--------------------------------------- */
- batteryLabel = new UILabel();
- if (batteryLabel == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryLabel new fail");
- return nullptr;
- }
- batteryLabel->SetPosition(batteryimage->GetX() + 38, (group1->GetHeight() - 14) / 2, 30, 30);
- batteryLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 15);
- batteryLabel->SetText("100");
- batteryLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full);
- 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 nullptr;
- }
- chargeBatteryicon->SetAutoEnable(false);
- chargeBatteryicon->SetPosition(progress->GetX() + 5, batteryimage->GetY() + 3, 9, 13);
- chargeBatteryicon->SetSrc("/user/res/Icon.bin");
- chargeBatteryicon->SetResizeMode(UIImageView::CONTAIN);
- chargeBatteryicon->SetVisible(false);
- group1->Add(chargeBatteryicon);
- /* -------------------------------------------------------------------------- */
- // ScrollView_->Add(group1);
- /* -------------------------------------------------------------------------- */
- updateSignalDisplay();
- /* -------------------------------------------------------------------------- */
- UpdateBatteryProcess();
- return group1;
- }
- 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);
- // 处理网络标志位(无网络)
- int8_t currentNet = 0;
- if (lastNetworkOnline_ == -1)
- {
- lastNetworkOnline_ = currentNet;
- }
- if (lastNetworkOnline_ == 1 && currentNet == 0)
- {
- if (currentView_ == THUNDERBIRD_DIALOGUEVIEW ||
- (currentView_ == THUNDERBIRD_LULLABYVIEW &&
- (currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1 ||
- currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4))) // 只有在对话界面还有哄睡界面才触发
- {
- // 从有网络到无网络:提示一次
- ThunderBirdModel::GetInstance()->StartReminderHideTimer(1000);
- ChangeThunderBirdReminderView(THUNDERBIRD_REMINDERVIEW);
- if (g_pThunderBirdReminderView)
- {
- g_pThunderBirdReminderView->Show(ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_NETWORK_DISCONNECT);
- }
-
- }
- }
- lastNetworkOnline_ = currentNet;
- }
- else if (cat1_powerOn == 1 && sim == 1)
- {
- if (signal == SIGNAL_NO_SIGNAL) // 计算信号强度
- {
- // 无信号UI显示
- if (NoSignal != nullptr)
- {
- NoSignal->SetVisible(true);
- }
- UpdateSignalBarDisplay(CalculateSignalBars(signal), false);
- // 从有网络到无网络:提示一次
- int8_t currentNet = 0;
- if (lastNetworkOnline_ == -1)
- {
- lastNetworkOnline_ = currentNet;
- }
- if (lastNetworkOnline_ == 1 && currentNet == 0)
- {
- if (currentView_ == THUNDERBIRD_DIALOGUEVIEW ||
- (currentView_ == THUNDERBIRD_LULLABYVIEW &&
- (currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1 ||
- currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4))) // 只有在对话界面还有哄睡界面才触发
- {
- ThunderBirdModel::GetInstance()->StartReminderHideTimer(1000);
- ChangeThunderBirdReminderView(THUNDERBIRD_REMINDERVIEW);
- if (g_pThunderBirdReminderView)
- {
- g_pThunderBirdReminderView->Show(ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_NETWORK_DISCONNECT);
- }
-
- }
- }
- lastNetworkOnline_ = currentNet;
- }
- else
- {
- if (NoSignal != nullptr)
- {
- NoSignal->SetVisible(false);
- }
- UpdateSignalBarDisplay(CalculateSignalBars(signal), true);
- lastNetworkOnline_ = 1;
- }
- }
- }
- 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;
- Batteryvalue = 0;
-#ifdef SUPPORT_BATTERY_SERVICE
- Batteryvalue = battery_get_voltage(&voltage);
-#endif
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "battery_get_voltage = %d", Batteryvalue);
- if (batteryLabel)
- {
- batteryLabel->SetText((std::to_string(static_cast<int>(Batteryvalue))).c_str()); // 电量
- }
- if (progress)
- {
- progress->SetValue(Batteryvalue);
- }
-
- 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)
- {
- chargeBatteryicon->SetVisible(true); // 充电图标
- isChargeBatteryIconVisible = true;
- }
- progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Green().full);
-
- if (!wasCharging)
- {
- // int16_t currentView = GetCurrentView();
- // int16_t currentSubView = GetCurrentSubView();
- if (currentView_ == THUNDERBIRD_DIALOGUEVIEW ||
- (currentView_ == THUNDERBIRD_LULLABYVIEW &&
- (currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1 ||
- currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4))) // 只有在对话界面还有哄睡界面才触发
- {
- // 首次进入充电状态,提醒一次,不走ChangeView
- ThunderBirdModel::GetInstance()->StartReminderHideTimer(1000);
- ChangeThunderBirdReminderView(THUNDERBIRD_REMINDERVIEW); // 不走ChangeView
- if (g_pThunderBirdReminderView)
- {
- g_pThunderBirdReminderView->Show(ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_CHARGING);
- }
-
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "currentView = %d, currentSubView = %d", currentView_, currentSubView_);
-
- }
-
- wasCharging = true;
- notifiedChargeFull = false;
- }
-
- if (Batteryvalue >= 100 && !notifiedChargeFull)
- {
- if (currentView_ == THUNDERBIRD_DIALOGUEVIEW ||
- (currentView_ == THUNDERBIRD_LULLABYVIEW &&
- (currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1 ||
- currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4))) // 只有在对话界面还有哄睡界面才触发
- {
- ThunderBirdModel::GetInstance()->StartReminderHideTimer(1000);
- ChangeThunderBirdReminderView(THUNDERBIRD_REMINDERVIEW); // 不走ChangeView
- if (g_pThunderBirdReminderView)
- {
- g_pThunderBirdReminderView->Show(ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_CHARGE_COMPLETE);
- }
- notifiedChargeFull = true;
-
- }
- }
- return;
- }
-
- // 非充电:重置充电相关一次性标记
- if (isChargeBatteryIconVisible)
- {
- chargeBatteryicon->SetVisible(false);
- isChargeBatteryIconVisible = false;
- }
- wasCharging = false;
- notifiedChargeFull = false;
-
- // 颜色显示
- if (Batteryvalue <= 20)
- {
- progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
- }
- else
- {
- progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::White().full);
- }
-
- // 电量阶段:3:>20, 2:(10,20], 1:(5,10], 0:<=5
- int16_t stage = 3;
- if (Batteryvalue == 5)
- stage = 0;
- else if (Batteryvalue == 10)
- stage = 1;
- else if (Batteryvalue == 20)
- stage = 2;
-
- // 阶段变更时提醒一次(从高到低跨阈值时触发)
- if (stage != lastBatteryStage)
- {
- if (stage < lastBatteryStage || lastBatteryStage == -1)
- {
- if (stage <= 2) // 仅在<=20%三个档位弹低电量提醒
- {
- if (currentView_ == THUNDERBIRD_DIALOGUEVIEW ||
- (currentView_ == THUNDERBIRD_LULLABYVIEW &&
- (currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1 ||
- currentSubView_ == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4))) // 只有在对话界面还有哄睡界面才触发
- {
- ThunderBirdModel::GetInstance()->StartReminderHideTimer(1000);
- ChangeThunderBirdReminderView(THUNDERBIRD_REMINDERVIEW); // 不走ChangeView
- if (g_pThunderBirdReminderView)
- {
- g_pThunderBirdReminderView->Show(ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_LOW_BATTERY);
- }
-
- }
- }
- }
- lastBatteryStage = stage;
- }
- 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/ThunderBirdReminderView.h"
-#include "thunderbird/include/ThunderBirdOtaView.h"
-#include "thunderbird/include/ThunderBirdLullabyView.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>
-#include <algorithm>
-#include <ctime>
-#include "custom_runtime.h"
-namespace OHOS
-{
- enum OTA_STATUS
- {
- OTA_STATUS_LOW_BATTERY = 0,
- OTA_STATUS_DOW,
- OTA_STATUS_UPDATING,
- OTA_STATUS_SUCCESS,
- };
- static bool g_isRecording = false;//是否正在录音
- ThunderBirdModel::ThunderBirdModel() : m_nextReminderId(1)
- {
- // 初始化时加载提醒数据
- // LoadRemindersFromFile();
- }
-
- ThunderBirdModel::~ThunderBirdModel()
- {
- // 析构时保存提醒数据
- // SaveRemindersToFile();
- }
-
- 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;
- }
- }
-
- /*----------------------提醒界面定时器----------------------------------*/
- static osTimerId_t g_reminderHideTimer = nullptr;
- static void ReminderHideTimerCallbackProc(uint8_t data)
- {
- (void)data;
- auto *reminder = ThunderBirdReminderView::GetInstance();
- if (reminder != nullptr)
- {
- reminder->HideAll();
- }
- int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView();
- int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView();
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "currentView = %d, currentSubView = %d", currentView, currentSubView);
- // 隐藏后切回之前的界面
- // auto *mainv = ThunderBirdReminderView::GetInstance();
- // if (mainv != nullptr)//判断条件需要修改
- // {
- // mainv->Show(-1);
- // }
- }
- static void ReminderHideTimerCallback(uint8_t data)
- {
- GraphicService::GetInstance()->PostGraphicEvent(std::bind(ReminderHideTimerCallbackProc, data));
- }
- void ThunderBirdModel::StartReminderHideTimer(uint32_t intervalMs)
- {
- if (g_reminderHideTimer != nullptr)
- {
- osTimerStop(g_reminderHideTimer);
- osStatus_t ret = osTimerDelete(g_reminderHideTimer);
- (void)ret;
- g_reminderHideTimer = nullptr;
- }
- g_reminderHideTimer = osTimerNew((osTimerFunc_t)ReminderHideTimerCallback, osTimerOnce, nullptr, nullptr);
- if (g_reminderHideTimer == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartReminderHideTimer new timer failed!!");
- return;
- }
- osStatus_t ret = osTimerStart(g_reminderHideTimer, intervalMs);
- if (ret != osOK)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartReminderHideTimer start failed, ret = %lx!!", ret);
- osTimerDelete(g_reminderHideTimer);
- g_reminderHideTimer = nullptr;
- }
- auto *reminder = ThunderBirdReminderView::GetInstance();//先隐藏全部提醒界面
- if (reminder != nullptr)
- {
- reminder->HideAll();
- }
- }
-
- // ---------------------- OTA 倒计时定时器(5 -> 1,每步1秒) ----------------------
- static osTimerId_t g_otaCountdownTimer = nullptr;
- static int g_otaCountdownValue = 0;
- static void OtaCountdownTimerProc(uint8_t data)
- {
- (void)data;
- if (g_otaCountdownValue < 1)
- {
- // 停止并删除
- if (g_otaCountdownTimer != nullptr)
- {
- osTimerStop(g_otaCountdownTimer);
- osTimerDelete(g_otaCountdownTimer);
- g_otaCountdownTimer = nullptr;
- }
- g_otaCountdownValue = 0;
- //自动跳转到开始OTA界面
- ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING);
- return;
-
-
- }
- g_otaCountdownValue -= 1;
- GraphicService::GetInstance()->PostGraphicEvent([](){
- if (ThunderBirdOtaView::GetInstance())
- {
- ThunderBirdOtaView::GetInstance()->UpdateCountdown(g_otaCountdownValue);
- }
- });
- }
- static void OtaCountdownTimerCb(uint8_t data)
- {
- OtaCountdownTimerProc(data);
- }
- void ThunderBirdModel::StartOtaCountdown(uint32_t startVal)
- {
- // 范围保护
- if (startVal < 1) { startVal = 1; }
- if (startVal > 5) { startVal = 5; }
- // 先停旧定时器
- if (g_otaCountdownTimer != nullptr)
- {
- osTimerStop(g_otaCountdownTimer);
- osTimerDelete(g_otaCountdownTimer);
- g_otaCountdownTimer = nullptr;
- }
- g_otaCountdownValue = (int)startVal;
- // 立即刷新一次当前值
- if (ThunderBirdOtaView::GetInstance())
- {
- ThunderBirdOtaView::GetInstance()->UpdateCountdown(g_otaCountdownValue);
- }
- // 创建1s周期定时器
- uint32_t oneSecond = 1000;
- g_otaCountdownTimer = osTimerNew((osTimerFunc_t)OtaCountdownTimerCb, osTimerPeriodic, nullptr, nullptr);
- if (g_otaCountdownTimer == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartOtaCountdown new timer failed!!");
- return;
- }
- osStatus_t ret = osTimerStart(g_otaCountdownTimer, oneSecond);
- if (ret != osOK)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartOtaCountdown start failed, ret = %lx!!", ret);
- osTimerDelete(g_otaCountdownTimer);
- g_otaCountdownTimer = nullptr;
- }
- }
- void ThunderBirdModel::StopOtaCountdown(void)
- {
- if (g_otaCountdownTimer != nullptr)
- {
- osTimerStop(g_otaCountdownTimer);
- osTimerDelete(g_otaCountdownTimer);
- g_otaCountdownTimer = nullptr;
- }
- g_otaCountdownValue = 0;
- }
-
-
- // ---------------------- 通用计时加一定时器(0 -> targetSeconds,每步1秒) ----------------------
- static osTimerId_t g_countUpTimer = nullptr;
- static int g_countUpTargetSeconds = 0;
- static int g_countUpValue = 0;
- static void CountUpTimerProc(uint8_t data)
- {
- (void)data;
- if (g_countUpValue >= g_countUpTargetSeconds)
- {
- if (g_countUpTimer != nullptr)
- {
- osTimerStop(g_countUpTimer);
- osTimerDelete(g_countUpTimer);
- g_countUpTimer = nullptr;
- }
- return;
- }
- g_countUpValue += 1;
- ThunderBirdLullabyView::GetInstance()->UpdateTimeText(g_countUpValue, g_countUpTargetSeconds);
- }
- static void CountUpTimerCb(uint8_t data)
- {
- CountUpTimerProc(data);
- }
- void ThunderBirdModel::StartCountUpTimer(uint32_t targetSeconds)
- {
- // 参数保护:至少为1秒
- if (targetSeconds < 1) { targetSeconds = 1; }
- // 停止旧定时器
- if (g_countUpTimer != nullptr)
- {
- osTimerStop(g_countUpTimer);
- osStatus_t ret = osTimerDelete(g_countUpTimer);
- (void)ret;
- g_countUpTimer = nullptr;
- }
- // 初始化
- g_countUpTargetSeconds = (int)targetSeconds;
- g_countUpValue = 0;
- // 创建1s周期定时器
- uint32_t oneSecond = 1000;
- g_countUpTimer = osTimerNew((osTimerFunc_t)CountUpTimerCb, osTimerPeriodic, nullptr, nullptr);
- if (g_countUpTimer == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartCountUpTimer new timer failed!!");
- return;
- }
- osStatus_t ret = osTimerStart(g_countUpTimer, oneSecond);
- if (ret != osOK)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartCountUpTimer start failed, ret = %lx!!", ret);
- osTimerDelete(g_countUpTimer);
- g_countUpTimer = nullptr;
- }
- }
- void ThunderBirdModel::StopCountUpTimer(void)
- {
- if (g_countUpTimer != nullptr)
- {
- osTimerStop(g_countUpTimer);
- osStatus_t ret = osTimerDelete(g_countUpTimer);
- if (ret != osOK)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StopCountUpTimer delete failed, ret = %lx!!", ret);
- }
- g_countUpTimer = nullptr;
- }
- }
- int ThunderBirdModel::GetCountUpValue() const
- {
- return g_countUpValue;
- }
-
- // ==================== 新手引导相关函数 ====================
- ThunderBirdModel::BindingStatus ThunderBirdModel::CheckBindingStatus()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::CheckBindingStatus");
-
- // TODO: 实现实际的绑定状态检查逻辑
- // 这里需要根据实际的网络状态和设备绑定状态来判断
- //if(uapi_dev_runtime_get_cat1_signal() == 99)
- // 模拟实现 - 实际应该检查网络连接和绑定状态
- // 返回未绑定状态作为默认值
- return BindingStatus::NOT_BOUND;
- }
-
- // ==================== 对话相关函数 ====================
- bool ThunderBirdModel::StartRecording()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartRecording");
-
- // TODO: 实现开始录音逻辑
- // 1. 初始化录音设备
- // 2. 开始录音
- // 3. 设置录音状态
- if(g_isRecording == true)
- {
- return false;
- }
- g_isRecording = true;//设置录音状态
- //std::string audioPath = uapi_ln_get_story_choose_audio_path();//故事选择的录音文件路径
- //audioPath = "/user/audio/test.pcm";//修改为实际的录音文件路径
- //const char *defaultArgs[6] = {"01", "pcm", "16000", "1", "16", audioPath.c_str()};
- //AudioCaptureSample(6, defaultArgs);
-
- return true; // 模拟成功
- }
-
- bool ThunderBirdModel::StopRecording()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StopRecording");
-
- // TODO: 实现停止录音逻辑
- // 1. 停止录音设备
- // 2. 保存录音文件
- // 3. 清理录音状态
- if(g_isRecording == false)
- {
- return false;
- }
- g_isRecording = false;//设置录音状态
- int32_t argc = 1;
- uint8_t *argv = (uint8_t *)"stop";
- //AudioCaptureSample(argc, (const char **)&argv);
-
- return true; // 模拟成功
- }
-
- bool ThunderBirdModel::SendRecording()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::SendRecording");
-
- // TODO: 实现发送录音逻辑
- // 1. 读取录音文件
- // 2. 通过网络发送到服务器
- // 3. 等待服务器响应
- //do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_SPEECH_CHAT_STREAM, NULL, 0);//开始对话
-
- return true; // 模拟成功
- }
-
- bool ThunderBirdModel::ReceiveAnswer()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::ReceiveAnswer");
-
- // TODO: 实现接收回答逻辑
- // 1. 监听服务器响应
- // 2. 解析回答数据
- // 3. 更新对话状态
- if(g_isRecording == false && 1/*服务器相应*/)
- {
-
- }
- return true; // 模拟成功
- }
-
- std::string ThunderBirdModel::GetConversationText()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::GetConversationText");
-
- // TODO: 实现获取对话文本逻辑
- // 1. 从缓存或存储中获取对话文本
- // 2. 格式化文本
- // 3. 返回文本内容
-
- return "模拟对话文本"; // 模拟返回
- }
-
- bool ThunderBirdModel::EndConversation()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::EndConversation");
-
- // TODO: 实现结束对话逻辑
- // 1. 清理对话状态
- // 2. 保存对话记录
- // 3. 释放相关资源
-
- return true; // 模拟成功
- }
-
- // ==================== 哄睡模式相关函数 ====================
- bool ThunderBirdModel::StartLullabyMode()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartLullabyMode");
-
- // TODO: 实现开始哄睡模式逻辑
- // 1. 初始化哄睡模式状态
- // 2. 开始播放哄睡音频
- // 3. 设置定时器
- // 4. 更新UI状态
-
- return true; // 模拟成功
- }
-
- bool ThunderBirdModel::StopLullabyMode()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StopLullabyMode");
-
- // TODO: 实现停止哄睡模式逻辑
- // 1. 停止播放哄睡音频
- // 2. 清理哄睡模式状态
- // 3. 停止相关定时器
- // 4. 更新UI状态
-
- return true; // 模拟成功
- }
-
- bool ThunderBirdModel::IsLullabyModeActive() const
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::IsLullabyModeActive");
-
- // TODO: 实现检查哄睡模式是否激活的逻辑
- // 1. 检查哄睡模式状态标志
- // 2. 检查音频播放状态
- // 3. 返回当前状态
-
- return false; // 模拟未激活
- }
-
- // ==================== 事项提醒相关函数 ====================
- bool ThunderBirdModel::AddReminder(const std::string& content, uint32_t timestamp)
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::AddReminder: %s, timestamp: %u",
- content.c_str(), timestamp);
-
- // 验证输入参数
- if (content.empty() || content.length() >= 255) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid reminder content");
- return false;
- }
-
- if (timestamp == 0) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid timestamp");
- return false;
- }
-
- // 创建提醒对象
- ReminderData reminder;
- reminder.id = GenerateReminderId();
- reminder.timestamp = timestamp;
- reminder.isActive = true;
- reminder.createTime = static_cast<uint32_t>(time(nullptr));
-
- // 复制内容(确保不超过255字符)
- strncpy(reminder.content, content.c_str(), sizeof(reminder.content) - 1);
- reminder.content[sizeof(reminder.content) - 1] = '\0';
-
- // 添加到列表
- m_reminders.push_back(reminder);
-
- // 保存到文件
- if (!SaveRemindersToFile()) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to save reminders to file");
- // 从列表中移除(回滚)
- m_reminders.pop_back();
- return false;
- }
-
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Added reminder with ID: %u", reminder.id);
- return true;
- }
-
- bool ThunderBirdModel::RemoveReminder(uint32_t reminderId)
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::RemoveReminder: %u", reminderId);
-
- // 查找提醒
- auto it = std::find_if(m_reminders.begin(), m_reminders.end(),
- [reminderId](const ReminderData& reminder) {
- return reminder.id == reminderId;
- });
-
- if (it == m_reminders.end()) {
- WEARABLE_LOGW(WEARABLE_LOG_MODULE_APP, "Reminder not found: %u", reminderId);
- return false;
- }
-
- // 从列表中删除
- m_reminders.erase(it);
-
- // 保存到文件
- if (!SaveRemindersToFile()) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to save reminders to file after removal");
- return false;
- }
-
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Removed reminder with ID: %u", reminderId);
- return true;
- }
-
- bool ThunderBirdModel::UpdateReminder(uint32_t reminderId, const std::string& content, uint32_t timestamp)
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::UpdateReminder: %u, %s, %u",
- reminderId, content.c_str(), timestamp);
-
- // 验证输入参数
- if (content.empty() || content.length() >= 255) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid reminder content");
- return false;
- }
-
- if (timestamp == 0) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid timestamp");
- return false;
- }
-
- // 查找提醒
- auto it = std::find_if(m_reminders.begin(), m_reminders.end(),
- [reminderId](const ReminderData& reminder) {
- return reminder.id == reminderId;
- });
-
- if (it == m_reminders.end()) {
- WEARABLE_LOGW(WEARABLE_LOG_MODULE_APP, "Reminder not found: %u", reminderId);
- return false;
- }
-
- // 更新提醒内容和时间
- it->timestamp = timestamp;
- strncpy(it->content, content.c_str(), sizeof(it->content) - 1);
- it->content[sizeof(it->content) - 1] = '\0';
-
- // 保存到文件
- if (!SaveRemindersToFile()) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to save reminders to file after update");
- return false;
- }
-
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Updated reminder with ID: %u", reminderId);
- return true;
- }
-
- std::vector<std::string> ThunderBirdModel::GetReminders()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::GetReminders");
-
- // TODO: 实现获取提醒列表逻辑
- // 1. 从存储系统读取所有提醒
- // 2. 按时间排序
- // 3. 格式化为字符串列表
- // 4. 返回提醒列表
-
- std::vector<std::string> reminders;
- for (const auto& reminder : m_reminders) {
- if (reminder.isActive) {
- char timeStr[32];
- time_t time = static_cast<time_t>(reminder.timestamp);
- struct tm* timeinfo = localtime(&time);
- if (timeinfo) {
- strftime(timeStr, sizeof(timeStr), "%Y-%m-%d %H:%M", timeinfo);
- std::string reminderStr = std::string(timeStr) + ": " + reminder.content;
- reminders.push_back(reminderStr);
- }
- }
- }
- return reminders;
- }
-
- // ==================== 文件存储相关函数 ====================
- std::string ThunderBirdModel::GetReminderFilePath() const
- {
- // 返回提醒数据文件的完整路径
- return "/user/reminders/reminder_data.bin";
- }
-
- uint32_t ThunderBirdModel::GenerateReminderId()
- {
- return m_nextReminderId++;
- }
-
- bool ThunderBirdModel::SaveRemindersToFile()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::SaveRemindersToFile");
-
- std::string filePath = GetReminderFilePath();
-
- // 创建目录(如果不存在)
- std::string dirPath = filePath.substr(0, filePath.find_last_of('/'));
- // TODO: 实现目录创建逻辑
-
- // 打开文件进行二进制写入
- std::ofstream file(filePath, std::ios::binary);
- if (!file.is_open()) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open file for writing: %s", filePath.c_str());
- return false;
- }
-
- // 写入提醒数量
- uint32_t count = static_cast<uint32_t>(m_reminders.size());
- file.write(reinterpret_cast<const char*>(&count), sizeof(count));
-
- // 写入每个提醒数据
- for (const auto& reminder : m_reminders) {
- file.write(reinterpret_cast<const char*>(&reminder), sizeof(ReminderData));
- }
-
- file.close();
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Saved %u reminders to file", count);
- return true;
- }
-
- bool ThunderBirdModel::LoadRemindersFromFile()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::LoadRemindersFromFile");
-
- std::string filePath = GetReminderFilePath();
-
- // 打开文件进行二进制读取
- std::ifstream file(filePath, std::ios::binary);
- if (!file.is_open()) {
- WEARABLE_LOGW(WEARABLE_LOG_MODULE_APP, "Reminder file not found: %s", filePath.c_str());
- return false; // 文件不存在不算错误
- }
-
- // 清空现有数据
- m_reminders.clear();
-
- // 读取提醒数量
- uint32_t count = 0;
- file.read(reinterpret_cast<char*>(&count), sizeof(count));
-
- if (count > 1000) { // 防止异常数据
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid reminder count: %u", count);
- return false;
- }
-
- // 读取每个提醒数据
- for (uint32_t i = 0; i < count; i++) {
- ReminderData reminder;
- file.read(reinterpret_cast<char*>(&reminder), sizeof(ReminderData));
-
- // 验证数据有效性
- if (reminder.id > 0 && reminder.timestamp > 0) {
- m_reminders.push_back(reminder);
- // 更新下一个ID
- if (reminder.id >= m_nextReminderId) {
- m_nextReminderId = reminder.id + 1;
- }
- }
- }
-
- file.close();
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Loaded %u reminders from file", static_cast<uint32_t>(m_reminders.size()));
- return true;
- }
-
-/*
- 1、新手引导
- 判断是否绑定 返回,0:绑定,1:未绑定;2:没有网络 使用枚举
- 2、对话
- 2.1 录音
- 开始录音接口
- 停止录音接口
- 2.2 发送录音接口
- 2.3 接收回答数据
- 2.4 对话文本获取接口
- 2.5 对话结束接口
- 3、哄睡模式
- 4、事项提醒
- */
-}
+++ /dev/null
-#include "thunderbird/include/ThunderBirdOtaView.h"
-#include "thunderbird/include/ThunderBirdModel.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; }
- if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; }
- if (LittleTextLabel != nullptr) { delete LittleTextLabel; LittleTextLabel = nullptr; }
- if (LittleTextLabel_2 != nullptr) { delete LittleTextLabel_2; LittleTextLabel_2 = 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 *ThunderBirdOtaView::ThunderBirdOtaViewInit(void)
- {
- group = new UIViewGroup();
- if (group == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdOtaView::group null!");
- return nullptr;
- }
- group->SetPosition(0, 0, 360, 360);
-
- BackGround = new UIImageView();
- if (BackGround)
- {
- BackGround->SetAutoEnable(false);
- BackGround->SetPosition(0, 0, 360, 360);
- BackGround->SetSrc("/user/res/yellowbg.bin");
- BackGround->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- BackGround->SetResizeMode(UIImageView::CONTAIN);
- BackGround->SetVisible(false);
- group->Add(BackGround);
- }
-
- // 公共控件
- TextLabel = new UILabelExt();
- if (TextLabel)
- {
- TextLabel->SetPosition(0, 104, 360, 48);
- TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- TextLabel->SetStyle(STYLE_LINE_SPACE, 10);
- //TextLabel->SetStyle(STYLE_LETTER_SPACE, 1);
- TextLabel->SetVisible(false);
- group->Add(TextLabel);
- }
- LittleTextLabel = new UILabelExt();
- if (LittleTextLabel)
- {
- LittleTextLabel->SetPosition(0, 180, 360, 40);
- LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- LittleTextLabel->SetVisible(false);
- group->Add(LittleTextLabel);
- }
- LittleTextLabel_2 = new UILabelExt();
- if (LittleTextLabel_2)
- {
- LittleTextLabel_2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- LittleTextLabel_2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- LittleTextLabel_2->SetVisible(false);
- group->Add(LittleTextLabel_2);
- }
- RemindLabel = new UILabelExt();
- if (RemindLabel)
- {
- RemindLabel->SetPosition(0, 180, 360, 40);
- RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- RemindLabel->SetVisible(false);
- group->Add(RemindLabel);
- }
- RemindIcon = new UIImageView();
- if (RemindIcon)
- {
- RemindIcon->SetAutoEnable(false);
- RemindIcon->SetVisible(false);
- RemindIcon->SetResizeMode(UIImageView::CONTAIN);
- group->Add(RemindIcon);
- }
- RemindIcon2 = new UIImageView();
- if (RemindIcon2)
- {
- RemindIcon2->SetAutoEnable(false);
- RemindIcon2->SetVisible(false);
- RemindIcon2->SetResizeMode(UIImageView::CONTAIN);
- group->Add(RemindIcon2);
- }
- RemindIcon3 = new UIImageView();
- if (RemindIcon3)
- {
- RemindIcon3->SetAutoEnable(false);
- RemindIcon3->SetVisible(false);
- RemindIcon3->SetResizeMode(UIImageView::CONTAIN);
- group->Add(RemindIcon3);
- }
- VolumeProgress = new UIBoxProgress();
- if (VolumeProgress)
- {
- VolumeProgress->SetPosition(56, 279, 248, 4);
- VolumeProgress->SetRange(100, 0);
- VolumeProgress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0xff);
- VolumeProgress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xffb4a9a0);
- VolumeProgress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
- VolumeProgress->SetForegroundStyle(STYLE_TEXT_COLOR, 0xff000000);
- VolumeProgress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45A5FF);
- group->Add(VolumeProgress);
- }
- return group;
- }
-
- void ThunderBirdOtaView::Show(int16_t showView)
- {
- if (group == nullptr) { return; }
- if (BackGround) { BackGround->SetVisible(true);}
- if (TextLabel) { TextLabel->SetVisible(false); }
- if (LittleTextLabel)
- {
- LittleTextLabel->SetVisible(false);
- TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
- LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- LittleTextLabel->SetRollSpeed(35);
- LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- }
- if (LittleTextLabel_2) { LittleTextLabel_2->SetVisible(false);}
- if (RemindLabel) { RemindLabel->SetVisible(false);}
- if (RemindIcon) { RemindIcon->SetVisible(false); }
- if (RemindIcon2) { RemindIcon2->SetVisible(false); }
- if (RemindIcon3) { RemindIcon3->SetVisible(false); }
- if (VolumeProgress) { VolumeProgress->SetVisible(false); }
- ThunderBirdModel::GetInstance()->StopOtaCountdown();
- switch (showView)
- {
- case THUNDERBIRD_OTAVIEW_NORMAL:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(45, 102, 270, 42);
- TextLabel->SetText("新的体验优化已就绪");
- TextLabel->SetVisible(true);
- }
- if (LittleTextLabel)
- {
- LittleTextLabel->SetText("全新功能已推出,现在Amby可以哄你睡觉");
- LittleTextLabel->SetPosition(0, 162, 360, 28);
- LittleTextLabel->SetVisible(true);
- }
- if (LittleTextLabel_2)
- {
- LittleTextLabel_2->SetPosition(94, 194, 172, 28);
- LittleTextLabel_2->SetText("更新预计需要5分钟");
- LittleTextLabel_2->SetVisible(true);
- }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(80, 275, 200, 25);
- RemindLabel->SetText("按 退出 按 更新");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(105, 276, 22, 22);
- RemindIcon->SetSrc("/user/res/volume_down.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(211, 276, 22, 22);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_OTAVIEW_OBVIOUS:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(66, 102, 240, 42);
- TextLabel->SetText("有新功能更新可用");
- TextLabel->SetVisible(true);
- }
- if (LittleTextLabel)
- {
- LittleTextLabel->SetText("全新功能已推出,现在Amby可以哄你睡觉");
- LittleTextLabel->SetPosition(0, 162, 360, 28);
- LittleTextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
- LittleTextLabel->SetVisible(true);
- }
- if (LittleTextLabel_2)
- {
- LittleTextLabel_2->SetText("更新预计需要5分钟");
- LittleTextLabel_2->SetPosition(94, 194, 172, 28);
- LittleTextLabel_2->SetVisible(true);
- }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(80, 275, 200, 25);
- RemindLabel->SetText("按 退出 按 更新");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(105, 276, 22, 22);
- RemindIcon->SetSrc("/user/res/volume_down.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(211, 276, 22, 22);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_OTAVIEW_UPDATE_NOW:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(90, 102, 180, 42);
- TextLabel->SetText("需要立即更新");
- TextLabel->SetVisible(true);
- }
- if (LittleTextLabel)
- {
- LittleTextLabel->SetText("为保障您的产品安全,部分功能将在更新后恢复使用");
- LittleTextLabel->SetPosition(60, 162, 240, 56);
- LittleTextLabel->SetVisible(true);
- }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(80, 275, 200, 25);
- RemindLabel->SetText("按 退出 按 更新");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(105, 276, 22, 22);
- RemindIcon->SetSrc("/user/res/volume_down.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(211, 276, 22, 22);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_OTAVIEW_NIGHT_UPDATE:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(45, 102, 270, 42);
- TextLabel->SetText("设置夜间更新");
- TextLabel->SetVisible(true);
- }
- if (LittleTextLabel)
- {
- LittleTextLabel->SetText("电量>50%,网络正常");
- LittleTextLabel->SetPosition(75, 162, 210, 28);
- LittleTextLabel->SetVisible(true);
- }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(80, 275, 200, 25);
- RemindLabel->SetText("按 退出 按 确认");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(105, 276, 22, 22);
- RemindIcon->SetSrc("/user/res/volume_down.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(211, 276, 22, 22);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(90, 102, 180, 84);
- TextLabel->SetText("设定成功!\n记得充好电哦");
- TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
- TextLabel->SetVisible(true);
- }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(136, 275, 88, 25);
- RemindLabel->SetText("按 确认");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(160, 277, 22, 22);
- RemindIcon->SetSrc("/user/res/volume_down.bin");
- RemindIcon->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_OTAVIEW_COUNTDOWN:
- {
- ThunderBirdModel::GetInstance()->StartOtaCountdown(5);
- if (TextLabel)
- {
- TextLabel->SetPosition(60, 102, 240, 42);
- TextLabel->SetText("设备更新即将开始");
- TextLabel->SetVisible(true);
- }
- if (LittleTextLabel)
- {
- LittleTextLabel->SetText("5");
- LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 48);
- LittleTextLabel->SetPosition(166, 172, 29, 67);
- LittleTextLabel->SetVisible(true);
- }
-
- if (RemindLabel)
- {
- RemindLabel->SetPosition(80, 275, 200, 25);
- RemindLabel->SetText("按 退出 按 确认");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(105, 276, 22, 22);
- RemindIcon->SetSrc("/user/res/volume_down.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(211, 276, 22, 22);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_OTAVIEW_LOW_BATTERY:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(82, 124, 240, 42);
- TextLabel->SetText("电量不足无法更新");
- TextLabel->SetVisible(true);
- }
- if (LittleTextLabel)
- {
- LittleTextLabel->SetText("请至少充至50%电量哦");
- LittleTextLabel->SetPosition(72, 186, 192, 25);
- LittleTextLabel->SetVisible(true);
- }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(136, 275, 88, 25);
- RemindLabel->SetText("按 退出");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(160, 277, 22, 22);
- RemindIcon->SetSrc("/user/res/volume_down.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(38, 124, 36, 36);
- RemindIcon2->SetSrc("/user/res/warning.bin");
- RemindIcon2->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_OTAVIEW_NETWORK_ERROR:
- {
- if (TextLabel)
- {
- TextLabel->SetText("网络连接异常");
- TextLabel->SetPosition(112, 124, 180, 42);
- TextLabel->SetVisible(true);
- }
- if (LittleTextLabel)
- {
- LittleTextLabel->SetText("请检查网络后重试");
- LittleTextLabel->SetPosition(100, 184, 160, 28);
- LittleTextLabel->SetVisible(true);
- }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(80, 275, 200, 25);
- RemindLabel->SetText("按 退出 按 重试");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(105, 276, 22, 22);
- RemindIcon->SetSrc("/user/res/volume_down.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(211, 276, 22, 22);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- if (RemindIcon3)
- {
- RemindIcon3->SetPosition(68, 124, 36, 36);
- RemindIcon3->SetSrc("/user/res/warning.bin");
- RemindIcon3->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_OTAVIEW_MEMORY_ERROR:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(82, 124, 240, 42);
- TextLabel->SetText("内存不足无法更新");
- TextLabel->SetVisible(true);
- }
- if (LittleTextLabel)
- {
- LittleTextLabel->SetText("请及时清理内存空间");
- LittleTextLabel->SetPosition(90, 184, 180, 28);
- LittleTextLabel->SetVisible(true);
- }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(80, 275, 200, 25);
- RemindLabel->SetText("按 退出 按 清理");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(105, 276, 22, 22);
- RemindIcon->SetSrc("/user/res/volume_down.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(211, 276, 22, 22);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- if (RemindIcon3)
- {
- RemindIcon3->SetPosition(38, 124, 36, 36);
- RemindIcon3->SetSrc("/user/res/warning.bin");
- RemindIcon3->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_OTAVIEW_UPDATING:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(90, 108, 180, 82);
- TextLabel->SetText("更新中\n请勿关闭设备");
- TextLabel->SetVisible(true);
- }
- if (VolumeProgress)
- {
- VolumeProgress->SetVisible(true);
- }
- if(LittleTextLabel)
- {
- LittleTextLabel->SetPosition(56, 243, 44, 28);
- LittleTextLabel->SetText((std::to_string(remindProgressValue_) + "%").c_str());
- LittleTextLabel->SetVisible(true);
- }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(170, 246, 150, 22);
- RemindLabel->SetText("更新还需5分钟");
- RemindLabel->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(127, 122, 164, 42);
- TextLabel->SetText("更新成功");
- TextLabel->SetVisible(true);
- }
- if (LittleTextLabel)
- {
- LittleTextLabel->SetPosition(80, 184, 220, 28);
- LittleTextLabel->SetText("你的设备已是最新版本");
- LittleTextLabel->SetVisible(true);
- }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(136, 275, 88, 25);
- RemindLabel->SetText("按 确认");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(160, 277, 22, 22);
- RemindIcon->SetSrc("/user/res/volume_up.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(98, 124, 36, 36);
- RemindIcon2->SetSrc("/user/res/completed.bin");
- RemindIcon2->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_OTAVIEW_UPDATE_FAILED:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(127, 122, 150, 42);
- TextLabel->SetText("更新未完成");
- TextLabel->SetVisible(true);
- }
- if (LittleTextLabel)
- {
- LittleTextLabel->SetPosition(70, 184, 220, 28);
- LittleTextLabel->SetText("请检查网络和电量后重试");
- LittleTextLabel->SetVisible(true);
- }
- if (RemindLabel)
- {
- RemindLabel->SetPosition(80, 275, 200, 25);
- RemindLabel->SetText("按 退出 按 重试");
- RemindLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(105, 276, 22, 22);
- RemindIcon->SetSrc("/user/res/volume_down.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(211, 276, 22, 22);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- if (RemindIcon3)
- {
- RemindIcon3->SetPosition(83, 124, 36, 36);
- RemindIcon3->SetSrc("/user/res/completed.bin");
- RemindIcon3->SetVisible(true);
- }
- break;
- }
- default:
- break;
- }
- }
-
- void ThunderBirdOtaView::UpdateCountdown(int value)//更新倒计时
- {
- if (LittleTextLabel == nullptr)
- {
- return;
- }
- if (value < 1) { value = 1; }
- if (value > 5) { value = 5; }
- LittleTextLabel->SetText(std::to_string(value).c_str());
- LittleTextLabel->Invalidate();
- }
-
- void ThunderBirdOtaView::SetRemindProgress(int16_t value)//更新进度
- {
- if (VolumeProgress == nullptr)
- {
- return;
- }
- int newVal = remindProgressValue_ + value;
- if (newVal < 0) { newVal = 0; }
- if (newVal > 100) { newVal = 100; }
- remindProgressValue_ = newVal;
- VolumeProgress->SetValue(remindProgressValue_);
- VolumeProgress->Invalidate();
- }
-}
-
-
+++ /dev/null
-/*
- * @Author: luozheng 1732036298@qq.com
- * @Date: 2024-04-16 14:36:45
- * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-18 15:19:37
- * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/ThunderBird/src/ThunderBirdPresenter.cpp
- */
-#include "thunderbird/include/ThunderBirdPresenter.h"
-#include "thunderbird/include/ThunderBirdGuideView.h"
-#include "thunderbird/include/ThunderBirdOtaView.h"
-#include "thunderbird/include/ThunderBirdLullabyView.h"
-#include "thunderbird/include/ThunderBirdDialogueView.h"
-#include "thunderbird/include/ThunderBirdReminderView.h"
-#include "thunderbird/include/ThunderBirdAdjustView.h"
-#include "AppViewIDs.h"
-#include "NativeAbility.h"
-#include "common/key_code.h"
-#include <custom_utils.h>
-#include "NativeRegisterManager.h"
-//#include "uicomponents/UIComponents.h"
-#include "broadcast_feature.h"
-#include "broadcast_service.h"
-#include "samgr_lite.h"
-#include "service_id_define.h"
-#include "dock/input_device.h"
-#include "custom_runtime.h"
-namespace OHOS
-{
- static int i=0;//版本临时变量
-
- REGIST_SLICE(VIEW_THUNDER_BIRD, ThunderBirdMainView, ThunderBirdPresenter);
-
- // 当前Presenter属性实例化的内存指针
- static ThunderBirdPresenter *g_pThunderBirdPresenter = nullptr;
-
- ThunderBirdPresenter::ThunderBirdPresenter()
- {
- NativeAbility::GetInstance().SetDefaultSliceId(VIEW_THUNDER_BIRD);
- g_pThunderBirdPresenter = this;
- }
-
- ThunderBirdPresenter::~ThunderBirdPresenter()
- {
- g_pThunderBirdPresenter = nullptr;
- }
-
- ThunderBirdPresenter *ThunderBirdPresenter::GetInstance()
- {
- return g_pThunderBirdPresenter;
- }
-
-
-
- void ThunderBirdPresenter::OnStart()
- {
- Presenter<ThunderBirdMainView>::OnStart();
- }
-
- void ThunderBirdPresenter::OnResume()
- {
- Presenter<ThunderBirdMainView>::OnResume();
- //统一抢回
- RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)ThunderBirdPresenter::GetInstance();
- RootView::GetInstance()->SetOnKeyActListener(keyactListener);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdPresenter::OnResume reset key listener");
- }
-
-
- bool ThunderBirdPresenter::OnDrag(UIView &view, const DragEvent &event)
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdPresenter::OnDrag");
- UNUSED(view);
- if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动
- {
- ThunderBirdPresenter::X_DRAG_FLAG = true;
- }
- return true;
- }
-
- bool ThunderBirdPresenter::OnDragEnd(UIView &view, const DragEvent &event)
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdPresenter::OnDragEnd");
- UNUSED(event);
- if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && ThunderBirdPresenter::X_DRAG_FLAG)
- {
- //NativeAbility::GetInstance().Back();
- ThunderBirdPresenter::X_DRAG_FLAG = false;
- }
- return true;
- }
-
- bool ThunderBirdPresenter::OnClick(UIView &view, const ClickEvent &event)
- {
- UNUSED(event);
-
-
- //NativeAbility::GetInstance().Back();
- return true;
- }
-
- // 增加按键事件
- bool ThunderBirdPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdPresenter::OnKeyAct");
- uint16_t keyID = event.GetKeyId();
- uint16_t keyState = event.GetState();
-
- // 刷新息屏计时:任意按键按下时重置屏幕熄灭倒计时
- if (keyState == InputDevice::STATE_PRESS) {
- uapi_set_screen_on_api();
- }
-
- // 长按关机键
- if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) &&
- keyState == InputDevice::STATE_LONG_PRESS)
- {
- NativeAbility::GetInstance().SwitchSlice(VIEW_REBOOT);
- return true;
- }
- /*************************power键*************************/
- if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
- {
- int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView();
- int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView();
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "currentView = %d, currentSubView = %d", currentView, currentSubView);
- i++;
- if(i == 1)
- {
- ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/Classic/blue.bin");
- }
- else if(i == 2)
- {
- ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/Classic/curly_hair.bin");
- }
- else if(i == 3)
- {
- ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/SidePartingShort/purple.bin");
- }
- else if(i == 4)
- {
- ThunderBirdMainView::GetInstance()->SwitchHair("/user/res/hair/Bangs/gold.bin");
- }
- else if(i == 5)
- {
- ThunderBirdMainView::GetInstance()->SwitchVideo("/user/video/Angry.mp4");
- }
- return true;
-
- }
- /*************************语音键*************************/
- if(keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_FUNC) && keyState == 1 && uapi_get_screen_state() == 0)
- {
- int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView();
- int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView();
-
- ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
-
-
- }
-
- // /*************************VENDOR_UP键*************************/
- // if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_VENDOR_UP) && uapi_get_screen_state() == 0)
- // {
- // static bool s_vendorUpPressed = false;
- // if (keyState == InputDevice::STATE_PRESS) {
- // if (s_vendorUpPressed) {
- // return true;
- // }
- // s_vendorUpPressed = true;
- // } else if (keyState == InputDevice::STATE_RELEASE) {
- // s_vendorUpPressed = false;
- // return true;
- // } else {
- // return true;
- // }
- // int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView();
- // int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView();
- // // 音量界面:FUNC 键 -10
- // if (currentView == THUNDERBIRD_DIALOGUEVIEW ||
- // (currentView == THUNDERBIRD_LULLABYVIEW &&
- // (currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1 ||
- // currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4))) //只有在对话界面还有哄睡界面才触发
- // {
- // ThunderBirdMainView::GetInstance()->ChangeThunderBirdReminderView(THUNDERBIRD_REMINDERVIEW);//不走ChangeView
- // if (ThunderBirdReminderView::GetInstance())
- // {
- // ThunderBirdModel::GetInstance()->StartReminderHideTimer(1000);
- // ThunderBirdReminderView::GetInstance()->Show(ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_VOLUME);
- // ThunderBirdReminderView::GetInstance()->AdjustRemindProgress(10);
-
- // }
- // return true;
- // }
- // // 引导界面导航
- // else if(currentView == THUNDERBIRD_GUIDEVIEW)
- // {
- // if(currentSubView == ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_1)
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_2);
- // }
- // else if(currentSubView == ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_2)
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_GUIDEVIEW, ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_3);
- // }
- // else if(currentSubView == ThunderBirdGuideView::THUNDERBIRD_GUIDEVIEW_3)
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL);
- // }
- // return true;
- // }
- // // 对话界面导航
- // else if(currentView == THUNDERBIRD_DIALOGUEVIEW)
- // {
- // if(currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING) // 说话中
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
- // }
- // else if(currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING) // 聆听中
- // {
-
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW);
- // }
- // else if(currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW) // 状态展示
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_VOLUME);
- // }
- // return true;
- // }
- // // OTA界面导航
- // else if(currentView == THUNDERBIRD_OTAVIEW)
- // {
- // if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL) // 有新功能
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_OBVIOUS);
- // }
- // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_OBVIOUS) // 需要立即更新
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW);
- // }
- // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW) // 设置夜间更新
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS);
- // }
-
- // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE) // 设置夜间更新
- // {
- // // if(uapi_get_battery_level() > 50)//获取电量
- // // {
- // // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS);
- // // }
- // // else
- // // {
- // // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_LOW_BATTERY);
- // // }
- // // if(uapi_get_network_state() == 1)//获取网络状态
- // // {
- // // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS);
- // // }
- // // else
- // // {
- // // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NETWORK_ERROR);
- // // }
- // // if(uapi_get_memory_state() == 1)//获取内存状态
- // // {
- // // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS);
- // // }
- // // else
- // // {
- // // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS);
- // // }
-
- // }
- // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS) // 更新倒计时
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_COUNTDOWN);
- // }
- // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_COUNTDOWN) // 更新倒计时
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING);
- // }
- // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING) // 更新中
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS);
- // }
- // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS) // 更新成功
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED);
- // }
- // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED) // 更新失败
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1);
- // }
- // return true;
- // }
- // // 哄睡界面导航
- // else if(currentView == THUNDERBIRD_LULLABYVIEW)
- // {
- // if(currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1)
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_2);
- // }
- // else if(currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_2)
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3);
- // }
- // else if(currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3)
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4);
- // }
- // else if(currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4)
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_5);
- // }
- // else if(currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_5)
- // {
- // // 返回主界面
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING);
- // }
- // return true;
- // }
- // // 提醒界面导航
- // else if(currentView == THUNDERBIRD_REMINDERVIEW)
- // {
- // if(currentSubView == ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_VOLUME) // 音量调节
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_TASK_REMINDER);
- // }
- // else if(currentSubView == ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_TASK_REMINDER) // 事项提醒
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_NETWORK_DISCONNECT);
- // }
- // else if(currentSubView == ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_NETWORK_DISCONNECT) // 网络断开
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_LOW_BATTERY);
- // }
- // else if(currentSubView == ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_LOW_BATTERY) // 电量不足
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_CHARGING);
- // }
- // else if(currentSubView == ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_CHARGING) // 充电中
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_REMINDERVIEW, ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_CHARGE_COMPLETE);
- // }
- // else if(currentSubView == ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_CHARGE_COMPLETE) // 充电完成
- // {
- // // 返回主界面
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_ADJUSTVIEW, ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_BIND_SUCCESS);
- // }
- // return true;
- // }
- // // 调节界面导航
- // else if(currentView == THUNDERBIRD_ADJUSTVIEW)
- // {
- // if(currentSubView == ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_BIND_SUCCESS) // 绑定成功
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_ADJUSTVIEW, ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_WARNING);
- // }
- // else if(currentSubView == ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_WARNING) // 异常警告
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_ADJUSTVIEW, ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_NETWORK_CONNECTING);
- // }
- // else if(currentSubView == ThunderBirdAdjustView::THUNDERBIRD_ADJUSTVIEW_NETWORK_CONNECTING) // 网络连接中
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_SHUTDOWNVIEW, 0);
- // //ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_SHUTDOWNTESTVIEW, -1);
- // }
- // return true;
- // }
- // return true;
- // }
- // /*************************VENDOR_DOWN键*************************/
- // if(keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_VENDOR_DOWN) && keyState == 1 && uapi_get_screen_state() == 0)
- // {
- // int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView();
- // int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView();
- // // 音量界面:FUNC 键 -10
- // if (currentView == THUNDERBIRD_DIALOGUEVIEW ||
- // (currentView == THUNDERBIRD_LULLABYVIEW &&
- // (currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1 ||
- // currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4))) //只有在对话界面还有哄睡界面才触发
- // {
- // ThunderBirdMainView::GetInstance()->ChangeThunderBirdReminderView(THUNDERBIRD_REMINDERVIEW);//不走ChangeView
- // if (ThunderBirdReminderView::GetInstance())
- // {
- // ThunderBirdModel::GetInstance()->StartReminderHideTimer(1000);
- // ThunderBirdReminderView::GetInstance()->Show(ThunderBirdReminderView::THUNDERBIRD_REMINDERVIEW_VOLUME);
- // ThunderBirdReminderView::GetInstance()->AdjustRemindProgress(-10);
-
- // }
- // return true;
- // }
- // if(currentView == THUNDERBIRD_OTAVIEW)
- // {
- // if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL || currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_OBVIOUS
- // ) // 可选升级退出进入是否设置夜间更新
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE);
- // }
- // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE) // 夜间更新退出返回原任务
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW);
- // }
- // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE) // 设置夜间更新成功
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS);
- // }
- // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS) // 更新倒计时
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_COUNTDOWN);
- // }
- // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_COUNTDOWN) // 电量不足
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_LOW_BATTERY);
- // }
- // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS) // 更新成功
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED);
- // }
- // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED) // 更新失败
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_1);
- // }
- // else if(currentSubView == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING) // 更新中
- // {
- // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS);
- // }
- // }
- // }
-
- return true;
- }
-}
-
+++ /dev/null
-// #include "thunderbird/include/ThunderBirdRecordPresenter.h"
-// #include "thunderbird/include/ThunderBirdRecordView.h"
-// #include "thunderbird/include/ThunderBirdModel.h"
-// #include "AppViewIDs.h"
-// #include "NativeAbility.h"
-// #include "wearable_log.h"
-// #include "click_event.h"
-// #include "drag_event.h"
-
-// namespace OHOS
-// {
-// static ThunderBirdRecordPresenter *g_pThunderBirdRecordPresenter{nullptr};
-
-// REGIST_SLICE(VIEW_THUNDER_RECORD, ThunderBirdRecordView, ThunderBirdRecordPresenter);
-
-// ThunderBirdRecordPresenter::ThunderBirdRecordPresenter()
-// {
-// g_pThunderBirdRecordPresenter = this;
-// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordPresenter::ThunderBirdRecordPresenter");
-// }
-
-// ThunderBirdRecordPresenter::~ThunderBirdRecordPresenter()
-// {
-// g_pThunderBirdRecordPresenter = nullptr;
-// }
-
-// ThunderBirdRecordPresenter *ThunderBirdRecordPresenter::GetInstance(void)
-// {
-// return g_pThunderBirdRecordPresenter;
-// }
-
-// bool ThunderBirdRecordPresenter::OnClick(UIView &view, const ClickEvent &event)
-// {
-// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordPresenter::OnClick");
-// (void)event;
-// const char* viewId = view.GetViewId();
-// if (viewId == nullptr) {
-// return false;
-// }
-// if (strcmp(viewId, "RECORD_BUTTON") == 0) {
-// HandleRecordButtonClick();
-// return true;
-// } else if (strcmp(viewId, "VOLUME_UP_BUTTON") == 0) {
-// HandleVolumeUpButtonClick();
-// return true;
-// } else if (strcmp(viewId, "VOLUME_DOWN_BUTTON") == 0) {
-// HandleVolumeDownButtonClick();
-// return true;
-// }
-// return false;
-// }
-
-// bool ThunderBirdRecordPresenter::OnDrag(UIView &view, const DragEvent &event)
-// {
-// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordPresenter::OnDrag");
-// (void)view;
-// (void)event;
-// return false;
-// }
-
-// void ThunderBirdRecordPresenter::HandleRecordButtonClick()
-// {
-// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandleRecordButtonClick");
-// ThunderBirdRecordView* view = ThunderBirdRecordView::GetInstance();
-// if (view == nullptr) {
-// return;
-// }
-// bool isRecording = view->IsRecording();
-// if (!isRecording)
-// {
-// ThunderBirdModel::GetInstance()->StartRecording();
-// view->SetRecording(true);
-// }
-// else
-// {
-// ThunderBirdModel::GetInstance()->StopRecording();
-// view->SetRecording(false);
-// }
-// }
-
-// void ThunderBirdRecordPresenter::HandleVolumeUpButtonClick()
-// {
-// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandleVolumeUpButtonClick");
-// ThunderBirdRecordView* view = ThunderBirdRecordView::GetInstance();
-// if (view == nullptr) {
-// return;
-// }
-// int currentVolume = view->GetCurrentVolume();
-// if (currentVolume < 100)
-// {
-// int newVolume = currentVolume + 10;
-// if (newVolume > 100) newVolume = 100;
-// view->SetVolume(newVolume);
-// }
-// }
-
-// void ThunderBirdRecordPresenter::HandleVolumeDownButtonClick()
-// {
-// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandleVolumeDownButtonClick");
-// ThunderBirdRecordView* view = ThunderBirdRecordView::GetInstance();
-// if (view == nullptr) {
-// return;
-// }
-// int currentVolume = view->GetCurrentVolume();
-// if (currentVolume > 0)
-// {
-// int newVolume = currentVolume - 10;
-// if (newVolume < 0) newVolume = 0;
-// view->SetVolume(newVolume);
-// }
-// }
-// }
+++ /dev/null
-// #include "thunderbird/include/ThunderBirdRecordView.h"
-// #include "thunderbird/include/ThunderBirdModel.h"
-// #include "thunderbird/include/ThunderBirdRecordPresenter.h"
-// #include "wearable_log.h"
-// #include <cstdio>
-
-// namespace OHOS
-// {
-// static ThunderBirdRecordView *g_pThunderBirdRecordView{nullptr};
-
-// ThunderBirdRecordView::ThunderBirdRecordView()
-// {
-// g_pThunderBirdRecordView = this;
-// currentVolume = 50; // 初始化音量为50
-// isRecording = false;
-// }
-
-// ThunderBirdRecordView::~ThunderBirdRecordView()
-// {
-// g_pThunderBirdRecordView = nullptr;
-// ClearAll();
-// }
-
-// ThunderBirdRecordView *ThunderBirdRecordView::GetInstance(void)
-// {
-// return g_pThunderBirdRecordView;
-// }
-
-// void ThunderBirdRecordView::ClearAll(void)
-// {
-// if (group != nullptr)
-// {
-// group->RemoveAll();
-// delete group;
-// group = nullptr;
-// }
-// if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; }
-// if (VolumeLabel != nullptr) { delete VolumeLabel; VolumeLabel = nullptr; }
-// if (RecordButton != nullptr) { delete RecordButton; RecordButton = nullptr; }
-// if (VolumeUpButton != nullptr) { delete VolumeUpButton; VolumeUpButton = nullptr; }
-// if (VolumeDownButton != nullptr) { delete VolumeDownButton; VolumeDownButton = nullptr; }
-// if (RecordIcon != nullptr) { delete RecordIcon; RecordIcon = nullptr; }
-// }
-
-// UIViewGroup *ThunderBirdRecordView::ThunderBirdRecordViewInit(void)
-// {
-// group = new UIViewGroup();
-// if (group == nullptr)
-// {
-// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordView::group null!");
-// return nullptr;
-// }
-
-// // 设置组的基本属性
-// group->SetPosition(0, 0, 240, 240);
-// group->SetStyle(STYLE_BACKGROUND_OPA, 0);
-
-// // 创建主文本标签
-// TextLabel = new UILabelExt();
-// if (TextLabel != nullptr)
-// {
-// TextLabel->SetPosition(20, 30, 200, 40);
-// TextLabel->SetText("录音控制面板");
-// TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 16);
-// TextLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full);
-// TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-// group->Add(TextLabel);
-// }
-
-// // 创建音量显示标签
-// VolumeLabel = new UILabelExt();
-// if (VolumeLabel != nullptr)
-// {
-// VolumeLabel->SetPosition(20, 80, 200, 30);
-// char volumeText[32];
-// snprintf(volumeText, sizeof(volumeText), "音量: %d%%", currentVolume);
-// VolumeLabel->SetText(volumeText);
-// VolumeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 14);
-// VolumeLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full);
-// VolumeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-// group->Add(VolumeLabel);
-// }
-
-// // 创建录音按键
-// RecordButton = new UILabelButton();
-// if (RecordButton != nullptr)
-// {
-// RecordButton->SetPosition(70, 130, 100, 40);
-// RecordButton->SetText("开始录音");
-// RecordButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 14);
-// RecordButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full);
-// RecordButton->SetStyle(STYLE_TEXT_COLOR, Color::White().full);
-// RecordButton->SetAlign(TEXT_ALIGNMENT_CENTER);
-
-// // 设置按键ID,供Presenter识别
-// RecordButton->SetViewId("RECORD_BUTTON");
-
-// group->Add(RecordButton);
-// }
-
-// // 创建音量加按键
-// VolumeUpButton = new UILabelButton();
-// if (VolumeUpButton != nullptr)
-// {
-// VolumeUpButton->SetPosition(20, 190, 60, 30);
-// VolumeUpButton->SetText("音量+");
-// VolumeUpButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 12);
-// VolumeUpButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full);
-// VolumeUpButton->SetStyle(STYLE_TEXT_COLOR, Color::White().full);
-// VolumeUpButton->SetAlign(TEXT_ALIGNMENT_CENTER);
-
-// // 设置按键ID,供Presenter识别
-// VolumeUpButton->SetViewId("VOLUME_UP_BUTTON");
-
-// group->Add(VolumeUpButton);
-// }
-
-// // 创建音量减按键
-// VolumeDownButton = new UILabelButton();
-// if (VolumeDownButton != nullptr)
-// {
-// VolumeDownButton->SetPosition(160, 190, 60, 30);
-// VolumeDownButton->SetText("音量-");
-// VolumeDownButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 12);
-// VolumeDownButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
-// VolumeDownButton->SetStyle(STYLE_TEXT_COLOR, Color::White().full);
-// VolumeDownButton->SetAlign(TEXT_ALIGNMENT_CENTER);
-
-// // 设置按键ID,供Presenter识别
-// VolumeDownButton->SetViewId("VOLUME_DOWN_BUTTON");
-
-// group->Add(VolumeDownButton);
-// }
-
-// // 创建录音图标
-// RecordIcon = new UIImageView();
-// if (RecordIcon != nullptr)
-// {
-// RecordIcon->SetPosition(100, 50, 40, 40);
-// // 这里可以设置录音图标,暂时使用背景色表示
-// RecordIcon->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full);
-// RecordIcon->SetVisible(false); // 初始隐藏
-// group->Add(RecordIcon);
-// }
-
-// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdRecordView init completed");
-// return group;
-// }
-
-// void ThunderBirdRecordView::Show(int16_t showView)
-// {
-// if (group != nullptr)
-// {
-// group->SetVisible(true);
-// }
-// }
-
-// void ThunderBirdRecordView::SetRecording(bool recording)
-// {
-// isRecording = recording;
-
-// if (RecordButton != nullptr)
-// {
-// if (recording)
-// {
-// RecordButton->SetText("停止录音");
-// RecordButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
-// }
-// else
-// {
-// RecordButton->SetText("开始录音");
-// RecordButton->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full);
-// }
-// }
-
-// if (RecordIcon != nullptr)
-// {
-// RecordIcon->SetVisible(recording);
-// }
-
-// if (recording)
-// {
-// UpdateTextLabel("正在录音...");
-// }
-// else
-// {
-// UpdateTextLabel("录音已停止");
-// }
-// }
-
-// void ThunderBirdRecordView::SetVolume(int volume)
-// {
-// if (volume >= 0 && volume <= 100)
-// {
-// currentVolume = volume;
-// UpdateVolumeText(currentVolume);
-// }
-// }
-
-// void ThunderBirdRecordView::UpdateTextLabel(const char* text)
-// {
-// if (TextLabel != nullptr && text != nullptr)
-// {
-// TextLabel->SetText(text);
-// }
-// }
-
-// void ThunderBirdRecordView::UpdateVolumeText(int volume)
-// {
-// if (VolumeLabel != nullptr)
-// {
-// char volumeText[32];
-// snprintf(volumeText, sizeof(volumeText), "音量: %d%%", volume);
-// VolumeLabel->SetText(volumeText);
-// }
-// }
-// }
+++ /dev/null
-#include "thunderbird/include/ThunderBirdReminderView.h"
-#include "wearable_log.h"
-#include "thunderbird/include/ThunderBirdMainView.h"
-#include "battery_hal.h"
-#include "battery_service.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 (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; }
- }
-
- 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, 360, 360);
- group->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
-
- // 公共控件
- TextLabel = new UILabelExt();
- if (TextLabel)
- {
- TextLabel->SetVisible(false);
- TextLabel->SetStyle(STYLE_LINE_SPACE, 10);
- TextLabel->SetStyle(STYLE_LETTER_SPACE, 1);
- group->Add(TextLabel);
- }
- if(RemindLabel)
- {
- RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- RemindLabel->SetVisible(false);
- group->Add(RemindLabel);
- }
- RemindButton = new UILabelButton();
- if (RemindButton)
- {
- RemindButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff635d58, UIButton::RELEASED);
- RemindButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff7c7773, UIButton::RELEASED);
- RemindButton->SetStyleForState(STYLE_BORDER_WIDTH, 2, UIButton::RELEASED);
- RemindButton->SetVisible(false);
- group->Add(RemindButton);
- }
- RemindIcon = new UIImageView();
- if (RemindIcon)
- {
- RemindIcon->SetAutoEnable(false);
- RemindIcon->SetVisible(false);
- RemindIcon->SetResizeMode(UIImageView::CONTAIN);
- group->Add(RemindIcon);
- }
- RemindIcon2 = new UIImageView();
- if (RemindIcon2)
- {
- RemindIcon2->SetAutoEnable(false);
- RemindIcon2->SetVisible(false);
- RemindIcon2->SetResizeMode(UIImageView::CONTAIN);
- group->Add(RemindIcon2);
- }
- VolumeProgress = new UIBoxProgress();
- if (VolumeProgress)
- {
- VolumeProgress->SetPosition(118, 132, 124, 4);
- VolumeProgress->SetRange(100, 0);
- VolumeProgress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0xff);
- VolumeProgress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xffb4a9a0);
- VolumeProgress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
- VolumeProgress->SetForegroundStyle(STYLE_TEXT_COLOR, 0xff000000);
- VolumeProgress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45A5FF);
- group->Add(VolumeProgress);
- }
- return group;
- }
-
- void ThunderBirdReminderView::Show(int16_t showView)
- {
- if (group == nullptr) { return; }
- if (TextLabel) { TextLabel->SetVisible(false); TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);}
- if (RemindLabel) { RemindLabel->SetVisible(false); }
- if (RemindButton) { RemindButton->SetVisible(false); }
- if (RemindIcon) { RemindIcon->SetVisible(false); RemindIcon->SetStyle(STYLE_BACKGROUND_OPA, 0x00);}
- if (RemindIcon2) { RemindIcon2->SetVisible(false); }
- if (VolumeProgress) { VolumeProgress->SetVisible(false); }
-
-
- switch (showView)
- {
- case THUNDERBIRD_REMINDERVIEW_VOLUME:
- {
- if (RemindButton)
- {
- RemindButton->SetPosition(102, 114, 156, 40);
- RemindButton->SetText("");
- RemindButton->SetVisible(true);
- }
- if (VolumeProgress)
- {
- VolumeProgress->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_REMINDERVIEW_TASK_REMINDER:
- {
- if (TextLabel)
- {
- TextLabel->SetPosition(99, 64, 261, 42);
- TextLabel->SetText("11点了该睡觉了");
- TextLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT);
- TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
- TextLabel->SetRollSpeed(35);
- TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- TextLabel->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(57, 64, 36, 36);
- RemindIcon->SetSrc("/user/res/notification.bin");
- RemindIcon->SetVisible(true);
- }
- if (RemindButton)
- {
- RemindButton->SetPosition(102, 114, 168, 40);
- RemindButton->SetText("按 关闭通知");
- RemindButton->SetLabelPosition(4, 2);
- RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- RemindButton->SetVisible(true);
- }
- if (RemindIcon2)
- {
- RemindIcon2->SetPosition(144, 122, 24, 24);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_REMINDERVIEW_NETWORK_DISCONNECT:
- {
- if (RemindButton)
- {
- RemindButton->SetPosition(99, 114, 185, 59);
- RemindButton->SetText("网络已断开");
- RemindButton->SetLabelPosition(69, 0);
- RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- RemindButton->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(115, 120, 47, 47);
- RemindIcon->SetSrc("/user/res/no_network.bin");
- RemindIcon->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_REMINDERVIEW_LOW_BATTERY:
- {
- if (RemindButton)
- {
- RemindButton->SetPosition(87, 114, 185, 40);
- RemindButton->SetText("电量不足20%");
- RemindButton->SetLabelPosition(40, 0);
- RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- RemindButton->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(103, 122, 23, 23);
- RemindIcon->SetSrc("/user/res/low_battery.bin");
- RemindIcon->SetVisible(true);
- }
- if(RemindLabel)
- {
- if (ThunderBirdMainView::GetInstance()->Batteryvalue <= 20 && ThunderBirdMainView::GetInstance()->Batteryvalue > 10)
- {
- RemindButton->SetText("电量不足20%");
- }
- else if (ThunderBirdMainView::GetInstance()->Batteryvalue <= 10 && ThunderBirdMainView::GetInstance()->Batteryvalue > 5)
- {
- RemindButton->SetText("电量不足10%");
- }
- else if (ThunderBirdMainView::GetInstance()->Batteryvalue <= 5)
- {
- RemindButton->SetText("电量不足5%");
- }
- }
-
- break;
- }
- case THUNDERBIRD_REMINDERVIEW_CHARGING:
- {
- if (RemindButton)
- {
- RemindButton->SetPosition(119, 116, 121, 40);
- RemindButton->SetText("充电中");
- RemindButton->SetLabelPosition(40, 0);
- RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- RemindButton->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(135, 124, 23, 23);
- RemindIcon->SetSrc("/user/res/charging.bin");
- RemindIcon->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_REMINDERVIEW_CHARGE_COMPLETE:
- {
- if (RemindButton)
- {
- RemindButton->SetPosition(109, 116, 141, 40);
- RemindButton->SetText("充电完成");
- RemindButton->SetLabelPosition(40, 0);
- RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- RemindButton->SetVisible(true);
- }
- if (RemindIcon)
- {
- RemindIcon->SetPosition(125, 124, 23, 23);
- RemindIcon->SetSrc("/user/res/charged.bin");
- RemindIcon->SetVisible(true);
- }
-
- break;
- }
- case THUNDERBIRD_REMINDERVIEW_DIALOGUE_NOT_ENOUGH:
- {
- ThunderBirdMainView::GetInstance()->OpenBackGround();
- if(TextLabel)
- {
- TextLabel->SetPosition(57, 69, 246, 84);
- TextLabel->SetText("对话额度不足20轮可扫码续充");
- TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
- TextLabel->SetVisible(true);
- }
- if(RemindIcon)
- {
- RemindIcon->SetPosition(133, 169, 94, 94);
- RemindIcon->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
- RemindIcon->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- //RemindIcon->SetSrc("/user/res/volume_up.bin");
- RemindIcon->SetVisible(true);
- }
- if(RemindLabel)
- {
- RemindLabel->SetPosition(132, 296, 96, 28);
- RemindLabel->SetText("按 确认");
- RemindLabel->SetVisible(true);
- }
- if(RemindIcon2)
- {
- RemindIcon2->SetPosition(156, 294, 24, 24);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_REMINDERVIEW_DIALOGUE_USE_UP:
- {
- ThunderBirdMainView::GetInstance()->OpenBackGround();
- if(TextLabel)
- {
- TextLabel->SetPosition(47, 64, 266, 84);
- TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
- TextLabel->SetText("啊哦,对话轮数已用完,扫码续上吧");
- TextLabel->SetVisible(true);
- }
- if(RemindIcon)
- {
- RemindIcon->SetPosition(133, 169, 94, 94);
- RemindIcon->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
- RemindIcon->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- //RemindIcon->SetSrc("/user/res/volume_up.bin");
- RemindIcon->SetVisible(true);
- }
- if(RemindLabel)
- {
- RemindLabel->SetPosition(132, 296, 96, 28);
- RemindLabel->SetText("按 确认");
- RemindLabel->SetVisible(true);
- }
- if(RemindIcon2)
- {
- RemindIcon2->SetPosition(158, 298, 24, 24);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_REMINDERVIEW_FLOW_NOT_ENOUGH:
- {
- ThunderBirdMainView::GetInstance()->OpenBackGround();
- if(TextLabel)
- {
- TextLabel->SetPosition(47, 64, 266, 84);
- TextLabel->SetText("流量不足100M了哦扫码可重置流量");
- TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
- TextLabel->SetVisible(true);
- }
- if(RemindIcon)
- {
- RemindIcon->SetPosition(133, 169, 94, 94);
- RemindIcon->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
- RemindIcon->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- //RemindIcon->SetSrc("/user/res/volume_up.bin");
- RemindIcon->SetVisible(true);
- }
- if(RemindLabel)
- {
- RemindLabel->SetPosition(132, 296, 96, 28);
- RemindLabel->SetText("按 确认");
- RemindLabel->SetVisible(true);
- }
- if(RemindIcon2)
- {
- RemindIcon2->SetPosition(158, 298, 24, 24);
- RemindIcon2->SetSrc("/user/res/volume_up.bin");
- RemindIcon2->SetVisible(true);
- }
- break;
- }
- case THUNDERBIRD_REMINDERVIEW_FLOW_USE_UP:
- {
- if(TextLabel)
- {
- TextLabel->SetPosition(91, 64, 180, 42);
- TextLabel->SetText("流量用完了哦");
- TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- TextLabel->SetVisible(true);
- }
- if (RemindButton)
- {
- RemindButton->SetPosition(64, 114, 232, 40);
- RemindButton->SetText("可在小程序上续费使用");
- RemindButton->SetLabelPosition(46, 6);
- RemindButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
- RemindButton->SetVisible(true);
- }
- break;
- }
- default:
- break;
- }
- }
-
- void ThunderBirdReminderView::HideAll()
- {
- if (group == nullptr) { return; }
- if (RemindButton) { RemindButton->SetVisible(false); }
- if (TextLabel) { TextLabel->SetVisible(false); }
- if (RemindLabel) { RemindLabel->SetVisible(false); }
- if (RemindIcon) { RemindIcon->SetVisible(false); }
- if (RemindIcon2) { RemindIcon2->SetVisible(false); }
- if (VolumeProgress) { VolumeProgress->SetVisible(false); }
- group->Invalidate();
- }
-
- void ThunderBirdReminderView::SetRemindProgress(int16_t value)
- {
- if (VolumeProgress == nullptr)
- {
- return;
- }
- if (value < 0) { value = 0; }
- if (value > 100) { value = 100; }
- remindProgressValue_ = value;
- VolumeProgress->SetValue(remindProgressValue_);
- VolumeProgress->Invalidate();
- }
-
- void ThunderBirdReminderView::AdjustRemindProgress(int16_t delta)
- {
- if (VolumeProgress == nullptr)
- {
- return;
- }
- int16_t newVal = remindProgressValue_ + delta;
- SetRemindProgress(newVal);
- // 若当前处于音量界面,确保控件可见
- if (RemindButton) { RemindButton->SetVisible(true); }
- }
-
-}
-
-
+++ /dev/null
-#include "thunderbird/include/ThunderBirdShutdownTestView.h"
-//#include "uicomponents/UIComponents.h"
-#include "wearable_log.h"
-#include "custom_utils.h"
-#include "thunderbird/include/ThunderBirdMainView.h"
-#include "UiConfig.h"
-
-namespace OHOS
-{
- static ThunderBirdShutdownTestView *g_tbShutdownTestView{nullptr};
- static const char *TB_NAUGHTY_PATHS[TB_SHUTDOWN_ANIM_FRAMES_TEST] = {
-
- };
- ThunderBirdShutdownTestView::ThunderBirdShutdownTestView()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView::ThunderBirdShutdownTestView");
- if (ThunderBirdMainView::GetInstance())
- {
- // ThunderBirdMainView::GetInstance()->CloseVideo();
- ThunderBirdMainView::GetInstance()->videoPlay_->StopVideoPlay();
- }
- g_tbShutdownTestView = this;
- }
-
- ThunderBirdShutdownTestView::~ThunderBirdShutdownTestView()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView::~ThunderBirdShutdownTestView");
- ClearAll();
- g_tbShutdownTestView = nullptr;
- }
- ThunderBirdShutdownTestView *ThunderBirdShutdownTestView::GetInstance()
- {
- return g_tbShutdownTestView;
- }
-
- void ThunderBirdShutdownTestView::ClearAll()
- {
- if (group != nullptr)
- {
- group->RemoveAll();
- if (animator != nullptr)
- {
- delete animator;
- animator = nullptr;
- }
- //FreeImagePathsArray(pathsArray, TB_SHUTDOWN_ANIM_FRAMES_TEST);
- delete group;
- group = nullptr;
- }
- }
-
- bool ThunderBirdShutdownTestView::EnsureAnimator()
- {
- if (animator == nullptr)
- {
- pathsArray = TB_NAUGHTY_PATHS;
- animator = new UIImageAnimatorView();
- if (animator == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView new UIImageAnimatorView fail");
- return false;
- }
- animator->SetAutoEnable(false);
- for (uint8_t i = 0; i < TB_SHUTDOWN_ANIM_FRAMES_TEST; i++)
- {
- imageInfos[i].imagePath = (pathsArray[i]);
- imageInfos[i].imageType = IMG_SRC_FILE_PATH;
- imageInfos[i].pos.x = TB_SHUTDOWN_ANIM_X_TEST;
- imageInfos[i].pos.y = TB_SHUTDOWN_ANIM_Y_TEST;
- imageInfos[i].width = TB_SHUTDOWN_ANIM_W_TEST;
- imageInfos[i].height = TB_SHUTDOWN_ANIM_H_TEST;
- }
- animator->SetPosition(TB_SHUTDOWN_ANIM_X_TEST, TB_SHUTDOWN_ANIM_Y_TEST, TB_SHUTDOWN_ANIM_W_TEST, TB_SHUTDOWN_ANIM_H_TEST);
- animator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
- animator->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- animator->SetImageAnimatorSrc(imageInfos, TB_SHUTDOWN_ANIM_FRAMES_TEST, TB_SHUTDOWN_ANIM_INTERVAL_TEST);
- animator->SetRepeat(true);
- animator->SetRepeatTimes(1);
- animator->SetResizeMode(UIImageView::COVER);
- //animator->SetAnimatorStopListener(this);
- }
- return true;
- }
-
- UIViewGroup *ThunderBirdShutdownTestView::Init()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView::Init");
- group = new UIViewGroup();
- if (group == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView group new fail");
- return nullptr;
- }
- group->SetPosition(0, 0, 360, 360);
- if (!EnsureAnimator())
- {
- return nullptr;
- }
- group->Add(animator);
- iconView = new UIImageView();
- iconView->SetPosition(0, 0, 360, 360);
- iconView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
- iconView->SetStyle(STYLE_BACKGROUND_OPA, 0x66);
- iconView->SetVisible(false);
- group->Add(iconView);
- return group;
- }
-
- UIImageAnimatorView *ThunderBirdShutdownTestView::GetAnimator()
- {
- return animator;
- }
-
- void ThunderBirdShutdownTestView::StartAnimation()
- {
- if (!EnsureAnimator())
- {
- return;
- }
- animator->Start();
- }
-
- void ThunderBirdShutdownTestView::OnAnimatorStop(UIView &view)
- {
- UNUSED(view);
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownTestView::OnAnimatorStop");
- // No shutdown side effects in test view
- }
-}
-
-
+++ /dev/null
-#include "thunderbird/include/ThunderBirdShutdownView.h"
-//#include "uicomponents/UIComponents.h"
-#include "wearable_log.h"
-#include "custom_runtime.h"
-#include "custom_utils.h"
-//#include "uiservice/include/ui_service.h"
-#include "vibrator_service.h"
-#include "thunderbird/include/ThunderBirdMainView.h"
-#include "UiConfig.h"
-
-namespace OHOS
-{
- static ThunderBirdShutdownView *g_tbShutdownView{nullptr};
- static const char *TB_SHUTDOWN_PATHS[TB_SHUTDOWN_ANIM_FRAMES] = {
- TB_SHUTDOWN_IMAGE_1, TB_SHUTDOWN_IMAGE_2, TB_SHUTDOWN_IMAGE_3, TB_SHUTDOWN_IMAGE_4, TB_SHUTDOWN_IMAGE_5,
- TB_SHUTDOWN_IMAGE_6, TB_SHUTDOWN_IMAGE_7, TB_SHUTDOWN_IMAGE_8, TB_SHUTDOWN_IMAGE_9, TB_SHUTDOWN_IMAGE_10,
- TB_SHUTDOWN_IMAGE_11, TB_SHUTDOWN_IMAGE_12, TB_SHUTDOWN_IMAGE_13, TB_SHUTDOWN_IMAGE_14, TB_SHUTDOWN_IMAGE_15,
- TB_SHUTDOWN_IMAGE_16, TB_SHUTDOWN_IMAGE_17, TB_SHUTDOWN_IMAGE_18, TB_SHUTDOWN_IMAGE_19, TB_SHUTDOWN_IMAGE_20,
- TB_SHUTDOWN_IMAGE_21, TB_SHUTDOWN_IMAGE_22, TB_SHUTDOWN_IMAGE_23, TB_SHUTDOWN_IMAGE_24, TB_SHUTDOWN_IMAGE_25,
- TB_SHUTDOWN_IMAGE_26, TB_SHUTDOWN_IMAGE_27, TB_SHUTDOWN_IMAGE_28, TB_SHUTDOWN_IMAGE_29, TB_SHUTDOWN_IMAGE_30,
- TB_SHUTDOWN_IMAGE_31, TB_SHUTDOWN_IMAGE_32, TB_SHUTDOWN_IMAGE_33, TB_SHUTDOWN_IMAGE_34, TB_SHUTDOWN_IMAGE_35,
- TB_SHUTDOWN_IMAGE_36, TB_SHUTDOWN_IMAGE_37, TB_SHUTDOWN_IMAGE_38, TB_SHUTDOWN_IMAGE_39, TB_SHUTDOWN_IMAGE_40,
- TB_SHUTDOWN_IMAGE_41, TB_SHUTDOWN_IMAGE_42, TB_SHUTDOWN_IMAGE_43, TB_SHUTDOWN_IMAGE_44, TB_SHUTDOWN_IMAGE_45,
- TB_SHUTDOWN_IMAGE_46, TB_SHUTDOWN_IMAGE_47, TB_SHUTDOWN_IMAGE_48, TB_SHUTDOWN_IMAGE_49, TB_SHUTDOWN_IMAGE_50,
- TB_SHUTDOWN_IMAGE_51, TB_SHUTDOWN_IMAGE_52, TB_SHUTDOWN_IMAGE_53, TB_SHUTDOWN_IMAGE_54, TB_SHUTDOWN_IMAGE_55,
- TB_SHUTDOWN_IMAGE_56, TB_SHUTDOWN_IMAGE_57, TB_SHUTDOWN_IMAGE_58, TB_SHUTDOWN_IMAGE_59, TB_SHUTDOWN_IMAGE_60,
- TB_SHUTDOWN_IMAGE_61, TB_SHUTDOWN_IMAGE_62, TB_SHUTDOWN_IMAGE_63, TB_SHUTDOWN_IMAGE_64, TB_SHUTDOWN_IMAGE_65,
- TB_SHUTDOWN_IMAGE_66, TB_SHUTDOWN_IMAGE_67, TB_SHUTDOWN_IMAGE_68, TB_SHUTDOWN_IMAGE_69, TB_SHUTDOWN_IMAGE_70,
- TB_SHUTDOWN_IMAGE_71, TB_SHUTDOWN_IMAGE_72, TB_SHUTDOWN_IMAGE_73, TB_SHUTDOWN_IMAGE_74, TB_SHUTDOWN_IMAGE_75,
- TB_SHUTDOWN_IMAGE_76, TB_SHUTDOWN_IMAGE_77, TB_SHUTDOWN_IMAGE_78, TB_SHUTDOWN_IMAGE_79, TB_SHUTDOWN_IMAGE_80,
- TB_SHUTDOWN_IMAGE_81, TB_SHUTDOWN_IMAGE_82, TB_SHUTDOWN_IMAGE_83, TB_SHUTDOWN_IMAGE_84, TB_SHUTDOWN_IMAGE_85,
- TB_SHUTDOWN_IMAGE_86, TB_SHUTDOWN_IMAGE_87, TB_SHUTDOWN_IMAGE_88, TB_SHUTDOWN_IMAGE_89, TB_SHUTDOWN_IMAGE_90,
- TB_SHUTDOWN_IMAGE_91, TB_SHUTDOWN_IMAGE_92, TB_SHUTDOWN_IMAGE_93, TB_SHUTDOWN_IMAGE_94, TB_SHUTDOWN_IMAGE_95,
- };
-
- ThunderBirdShutdownView::ThunderBirdShutdownView()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView::ThunderBirdShutdownView");
- g_tbShutdownView = this;
- // 关机前释放 thunderbird 视频与相关资源
- if (ThunderBirdMainView::GetInstance())
- {
- // ThunderBirdMainView::GetInstance()->CloseVideo();
- ThunderBirdMainView::GetInstance()->videoPlay_->StopVideoPlay();
- }
- }
-
- ThunderBirdShutdownView::~ThunderBirdShutdownView()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView::~ThunderBirdShutdownView");
- ClearAll();
- g_tbShutdownView = nullptr;
- }
-
- ThunderBirdShutdownView *ThunderBirdShutdownView::GetInstance()
- {
- return g_tbShutdownView;
- }
-
- void ThunderBirdShutdownView::ClearAll()
- {
- if (group != nullptr)
- {
- group->RemoveAll();
- if (shutdownAnimator != nullptr)
- {
- delete shutdownAnimator;
- shutdownAnimator = nullptr;
- }
- //FreeImagePathsArray(shutdownPathsArray, TB_SHUTDOWN_ANIM_FRAMES);
- delete group;
- group = nullptr;
- }
- }
-
- void ThunderBirdShutdownView::OnAnimatorStop(UIView &view)
- {
- UNUSED(view);
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView::OnAnimatorStop");
- shutdown_reboot_prejobs(SHUTDOWN_TYPE);
- }
-
- bool ThunderBirdShutdownView::EnsureAnimator()
- {
- if (shutdownAnimator == nullptr)
- {
- shutdownPathsArray = TB_SHUTDOWN_PATHS;
- shutdownAnimator = new UIImageAnimatorView();
- if (shutdownAnimator == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView new UIImageAnimatorView fail");
- return false;
- }
- shutdownAnimator->SetAutoEnable(false);
- for (uint8_t i = 0; i < TB_SHUTDOWN_ANIM_FRAMES; i++)
- {
- shutdownImageInfo[i].imagePath = (shutdownPathsArray[i]);
- shutdownImageInfo[i].imageType = IMG_SRC_FILE_PATH;
- shutdownImageInfo[i].pos.x = TB_SHUTDOWN_ANIM_X;
- shutdownImageInfo[i].pos.y = TB_SHUTDOWN_ANIM_Y;
- shutdownImageInfo[i].width = TB_SHUTDOWN_ANIM_W;
- shutdownImageInfo[i].height = TB_SHUTDOWN_ANIM_H;
- }
- shutdownAnimator->SetPosition(TB_SHUTDOWN_ANIM_X, TB_SHUTDOWN_ANIM_Y, TB_SHUTDOWN_ANIM_W, TB_SHUTDOWN_ANIM_H);
- shutdownAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
- shutdownAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- shutdownAnimator->SetImageAnimatorSrc(shutdownImageInfo, TB_SHUTDOWN_ANIM_FRAMES, TB_SHUTDOWN_ANIM_INTERVAL);
- shutdownAnimator->SetRepeat(false);
- shutdownAnimator->SetRepeatTimes(1);
- shutdownAnimator->SetResizeMode(UIImageView::COVER);
- //shutdownAnimator->SetAnimatorStopListener(this);
- }
- return true;
- }
-
- UIViewGroup *ThunderBirdShutdownView::ThunderBirdShutdownViewInit()
- {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView::ThunderBirdShutdownViewInit");
- group = new UIViewGroup();
- if (group == nullptr)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdShutdownView group new fail");
- return nullptr;
- }
- group->SetPosition(0, 0, 360, 360);
- if (!EnsureAnimator())
- {
- return nullptr;
- }
- group->Add(shutdownAnimator);
- return group;
- }
-
- UIImageAnimatorView *ThunderBirdShutdownView::GetAnimator()
- {
- return shutdownAnimator;
- }
-
- void ThunderBirdShutdownView::StartShutdownAnimation()
- {
- if (!EnsureAnimator())
- {
- return;
- }
- shutdownAnimator->Start();
- uapi_dev_runtime_set_shutting_down_status(1);
- //ScreenOffEnable(false);
- uapi_set_screen_on_api();
- custom_VibratorFunc_int(0);
- }
-}
-
-