#include "View.h"
#include "components/ui_view_group.h"
#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
namespace OHOS
{
static ThunderBirdGuideView *GetInstance(void);
UIViewGroup *ThunderBirdGuideViewInit(void);
void ClearAll(void);
+ void Show(int16_t showView);
+
+ enum : int16_t {
+ THUNDERBIRD_GUIDEVIEW_1 = 0,
+ THUNDERBIRD_GUIDEVIEW_2,
+ THUNDERBIRD_GUIDEVIEW_3,
+ };
private:
UIViewGroup *group{nullptr};
UILabelExt *titleLabel{nullptr};
+ UILabelExt *TextLabel{nullptr};
+ UIImageView *RemindGround{nullptr};
+ UILabelExt *RemindLabel{nullptr};
+ UIImageView *RemindIcon{nullptr};
};
}
#include "View.h"
#include "components/ui_view_group.h"
#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
namespace OHOS
{
static ThunderBirdLullabyView *GetInstance(void);
UIViewGroup *ThunderBirdLullabyViewInit(void);
void ClearAll(void);
+ void Show(int16_t showView);
+
+ enum : int16_t {
+ THUNDERBIRD_LULLABYVIEW_1 = 0,
+ THUNDERBIRD_LULLABYVIEW_2,
+ THUNDERBIRD_LULLABYVIEW_3,
+ THUNDERBIRD_LULLABYVIEW_4,
+ THUNDERBIRD_LULLABYVIEW_5,
+ };
private:
UIViewGroup *group{nullptr};
UILabelExt *titleLabel{nullptr};
+ UILabelExt *TextLabel{nullptr};
+ UILabelExt *RemindLabel{nullptr};
+ UIImageView *RemindIcon{nullptr};
+ UIImageView *RemindIcon2{nullptr};
+ UIImageView *BackGround{nullptr};
};
}
#include "View.h"
#include "components/ui_view_group.h"
-#include "thunderbird/include/ThunderBirdView.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
#include "video_play_wrapper.h"
#include "main/include/dial/DialVideoView.h"
#include "animator/animator_manager.h"
#include "components/ui_box_progress.h"
#include "components/ui_image_animator.h"
-#include "thunderbird/include/ThunderBirdView.h"
#include "thunderbird/include/ThunderBirdModel.h"
#include "thunderbird/include/ThunderBirdPresenter.h"
+// 各子界面头文件
+#include "thunderbird/include/ThunderBirdView.h"
#include "thunderbird/include/ThunderBirdOtaView.h"
#include "thunderbird/include/ThunderBirdGuideView.h"
#include "thunderbird/include/ThunderBirdLullabyView.h"
static ThunderBirdMainView *GetInstance(void);
void OnStart() override;
+ // 视图切换(按组显示/隐藏)
bool ChangeThunderBirdView(int16_t);
bool ChangeThunderBirdOtaView(int16_t);
bool ChangeThunderBirdGuideView(int16_t);
bool ChangeThunderBirdDialogueView(int16_t);
bool ChangeThunderBirdReminderView(int16_t);
bool ChangeThunderBirdAdjustView(int16_t);
-
bool ClickFunc(int16_t interface);
- void ChangeView(int16_t hideView, int16_t showView);
+ void ChangeView(int16_t hideView, int16_t showView, int16_t subView = -1);
+
+ int16_t GetCurrentView() const;
+ int16_t GetCurrentSubView() const;
void UpdateBatteryProcess();
void updateSignalDisplay();
void UpdateTimeText(const char *time);
void Initback();
void InitBaseData();
+ void InitCommonPageComponents();
+ void HideCommonPageComponents();
+ bool SwitchVideo(const char *uri);
- private:
- ThunderBirdView *g_pThunderBirdView{nullptr};
- ThunderBirdOtaView *g_pThunderBirdOtaView{nullptr};
- ThunderBirdGuideView *g_pThunderBirdGuideView{nullptr};
- ThunderBirdLullabyView *g_pThunderBirdLullabyView{nullptr};
- ThunderBirdDialogueView *g_pThunderBirdDialogueView{nullptr};
- ThunderBirdReminderView *g_pThunderBirdReminderView{nullptr};
- ThunderBirdAdjustView *g_pThunderBirdAdjustView{nullptr};
private:
void DeInit();
+ // 旧多视图分组容器
UIViewGroup *group[MAXVIEW]{nullptr};
UIScrollView *ScrollView_{nullptr};
+ // 页面聚合容器:承载所有子界面,切换仅做显示/隐藏
+ UIViewGroup *pagesGroup{nullptr};
+ int16_t currentView_{THUNDERBIRD_GUIDEVIEW};
+ int16_t currentSubView_{0};
UIImageView *curFace{nullptr};
DialVideoView *videoPlayer_ = nullptr;
UIBoxProgress *progress{nullptr}; // 电池进度条
UIImageView *chargeBatteryicon{nullptr}; // 充电图标
bool isChargeBatteryIconVisible{false}; // 充电图标是否可见
+
+ // Ota(进度/文本)
+ UIBoxProgress *otaProgress{nullptr};
+
+ // 各子界面对象指针
+ ThunderBirdView *g_pThunderBirdView{nullptr};
+ ThunderBirdOtaView *g_pThunderBirdOtaView{nullptr};
+ ThunderBirdGuideView *g_pThunderBirdGuideView{nullptr};
+ ThunderBirdLullabyView *g_pThunderBirdLullabyView{nullptr};
+ ThunderBirdDialogueView *g_pThunderBirdDialogueView{nullptr};
+ ThunderBirdReminderView *g_pThunderBirdReminderView{nullptr};
+ ThunderBirdAdjustView *g_pThunderBirdAdjustView{nullptr};
+
+#define SCREEN_WIDTH (Screen::GetInstance().GetWidth())
+#define SCREEN_HEIGHT (Screen::GetInstance().GetHeight())
};
}
delete group;
group = nullptr;
}
- if (titleLabel != nullptr)
- {
- delete titleLabel;
- titleLabel = nullptr;
- }
+ if (titleLabel != nullptr) { delete titleLabel; titleLabel = nullptr; }
+ if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; }
+ if (RemindGround != nullptr) { delete RemindGround; RemindGround = nullptr; }
+ if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; }
}
UIViewGroup *ThunderBirdGuideView::ThunderBirdGuideViewInit(void)
}
group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
- titleLabel = new UILabelExt();
- if (titleLabel != nullptr)
+ // 公共控件
+ TextLabel = new UILabelExt();
+ if (TextLabel)
+ {
+ TextLabel->SetPosition(0, 104, 466, 48);
+ TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 34);
+ TextLabel->SetVisible(false);
+ group->Add(TextLabel);
+ }
+ RemindGround = new UIImageView();
+ if (RemindGround)
+ {
+ RemindGround->SetPosition(140, 175, 180, 48);
+ RemindGround->SetStyle(STYLE_BACKGROUND_COLOR, 0xff95847b);
+ RemindGround->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ RemindGround->SetStyle(STYLE_BORDER_RADIUS, 80);
+ RemindGround->SetVisible(false);
+ group->Add(RemindGround);
+ }
+ RemindLabel = new UILabelExt();
+ if (RemindLabel)
+ {
+ RemindLabel->SetPosition(0, 180, 466, 40);
+ RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28);
+ RemindLabel->SetVisible(false);
+ group->Add(RemindLabel);
+ }
+ RemindIcon = new UIImageView();
+ if (RemindIcon)
{
- titleLabel->SetPosition(20, 20, 300, 40);
- titleLabel->SetText("新手引导");
- group->Add(titleLabel);
+ RemindIcon->SetPosition(280, 320, 30, 30);
+ RemindIcon->SetVisible(false);
+ group->Add(RemindIcon);
}
return group;
}
+
+ void ThunderBirdGuideView::Show(int16_t showView)
+ {
+ if (group == nullptr) { return; }
+ if (TextLabel) { TextLabel->SetVisible(false); }
+ if (RemindGround) { RemindGround->SetVisible(false); }
+ if (RemindLabel) { RemindLabel->SetVisible(false); }
+ if (RemindIcon) { RemindIcon->SetVisible(false); }
+
+ switch (showView)
+ {
+ case THUNDERBIRD_GUIDEVIEW_1:
+ {
+ if (TextLabel)
+ {
+ TextLabel->SetPosition(0, 104, 466, 48);
+ TextLabel->SetText("Hey, 我是毛毛~");
+ TextLabel->SetVisible(true);
+ }
+ if(RemindGround)
+ {
+ RemindGround->SetVisible(true);
+ }
+ if (RemindLabel)
+ {
+ RemindLabel->SetText("按 下一页");
+ RemindLabel->SetVisible(true);
+ }
+ if(RemindIcon)
+ {
+ RemindIcon->SetPosition(180, 175, 30, 30);
+ RemindIcon->SetSrc("/user/res/volumeup.bin");
+ RemindIcon->SetVisible(true);
+ }
+
+ break;
+ }
+ case THUNDERBIRD_GUIDEVIEW_2:
+ {
+ if (TextLabel)
+ {
+ TextLabel->SetPosition(0, 104, 466, 48);
+ TextLabel->SetText("我可以和你聊天,哄你睡觉");
+ TextLabel->SetVisible(true);
+ }
+ if(RemindGround)
+ {
+ RemindGround->SetVisible(true);
+ }
+ if (RemindLabel)
+ {
+ RemindLabel->SetText("按 下一页");
+ RemindLabel->SetVisible(true);
+ }
+ if(RemindIcon)
+ {
+ RemindIcon->SetPosition(180, 175, 30, 30);
+ RemindIcon->SetSrc("/user/res/volumeup.bin");
+ RemindIcon->SetVisible(true);
+ }
+ break;
+ }
+ case THUNDERBIRD_GUIDEVIEW_3:
+ {
+ if (TextLabel)
+ {
+ TextLabel->SetPosition(0, 104, 466, 48);
+ TextLabel->SetText("换角色、挑声音、哄睡...扫码尽享受");
+ TextLabel->SetVisible(true);
+ }
+ if(RemindGround)
+ {
+ RemindGround->SetVisible(true);
+ }
+ if (RemindLabel)
+ {
+ RemindLabel->SetText("按 跳过");
+ RemindLabel->SetVisible(true);
+ }
+ if(RemindIcon)
+ {
+ RemindIcon->SetPosition(180, 175, 30, 30);
+ RemindIcon->SetSrc("/user/res/volumeup.bin");
+ RemindIcon->SetVisible(true);
+ }
+ // 黑色背景与二维码需要补充
+ break;
+ }
+ default:
+ break;
+ }
+ }
}
delete group;
group = nullptr;
}
- if (titleLabel != nullptr)
- {
- delete titleLabel;
- titleLabel = nullptr;
- }
+ if (titleLabel != nullptr) { delete titleLabel; titleLabel = nullptr; }
+ if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; }
+ if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; }
+ if (RemindIcon != nullptr) { delete RemindIcon; RemindIcon = nullptr; }
+ if (RemindIcon2 != nullptr) { delete RemindIcon2; RemindIcon2 = nullptr; }
+ if (BackGround != nullptr) { delete BackGround; BackGround = nullptr; }
}
UIViewGroup *ThunderBirdLullabyView::ThunderBirdLullabyViewInit(void)
}
group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
- titleLabel = new UILabelExt();
- if (titleLabel != nullptr)
+ // 公共控件
+ TextLabel = new UILabelExt();
+ if (TextLabel)
+ {
+ TextLabel->SetPosition(0, 104, 466, 48);
+ TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 34);
+ TextLabel->SetVisible(false);
+ group->Add(TextLabel);
+ }
+ RemindLabel = new UILabelExt();
+ if (RemindLabel)
{
- titleLabel->SetPosition(20, 20, 300, 40);
- titleLabel->SetText("哄睡界面");
- group->Add(titleLabel);
+ RemindLabel->SetPosition(0, 180, 466, 40);
+ RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28);
+ RemindLabel->SetVisible(false);
+ group->Add(RemindLabel);
+ }
+ RemindIcon = new UIImageView();
+ if (RemindIcon)
+ {
+ RemindIcon->SetAutoEnable(false);
+ RemindIcon->SetVisible(false);
+ group->Add(RemindIcon);
+ }
+ RemindIcon2 = new UIImageView();
+ if (RemindIcon2)
+ {
+ RemindIcon2->SetAutoEnable(false);
+ RemindIcon2->SetVisible(false);
+ group->Add(RemindIcon2);
+ }
+ BackGround = new UIImageView();//有待解决
+ if (BackGround)
+ {
+ BackGround->SetPosition(0, 0, 300, 300);
+ BackGround->SetStyle(STYLE_BACKGROUND_COLOR, 0x66191919);
+ BackGround->SetStyle(STYLE_BACKGROUND_OPA, 0x66);
+ BackGround->SetVisible(false);
+ group->Add(BackGround);
}
return group;
}
+
+ void ThunderBirdLullabyView::Show(int16_t showView)
+ {
+ if (group == nullptr) { return; }
+ if (BackGround) { BackGround->SetVisible(false); }
+ if (TextLabel) { TextLabel->SetVisible(false); TextLabel->SetY(104); }
+ if (RemindLabel) { RemindLabel->SetVisible(false); RemindLabel->SetY(180); }
+ if (RemindIcon) { RemindIcon->SetVisible(false); }
+ if (RemindIcon2) { RemindIcon2->SetVisible(false); }
+
+ switch (showView)
+ {
+ case THUNDERBIRD_LULLABYVIEW_1:
+ {
+ if (TextLabel)
+ {
+ TextLabel->SetText("按 说“哄我睡觉”");
+ TextLabel->SetVisible(true);
+ }
+ if(RemindIcon)
+ {
+ RemindIcon->SetVisible(true);
+ }
+ break;
+ }
+ case THUNDERBIRD_LULLABYVIEW_2:
+ {
+ if (TextLabel)
+ {
+ TextLabel->SetText("是否开启哄睡模式");
+ TextLabel->SetY(160);
+ TextLabel->SetVisible(true);
+ }
+ if (RemindLabel)
+ {
+ RemindLabel->SetText("按 取消 按 确认");
+ RemindLabel->SetVisible(true);
+ }
+ break;
+ }
+ case THUNDERBIRD_LULLABYVIEW_3:
+ {
+ if (TextLabel)
+ {
+ TextLabel->SetText(" 告诉我想听的故事");
+ TextLabel->SetY(160);
+ TextLabel->SetVisible(true);
+ }
+ if (RemindLabel)
+ {
+ RemindLabel->SetText("按 取消 按 确认");
+ RemindLabel->SetVisible(true);
+ }
+ break;
+ }
+ case THUNDERBIRD_LULLABYVIEW_4:
+ {
+ if (TextLabel)
+ {
+ TextLabel->SetText("从前有座山");
+ TextLabel->SetVisible(true);
+ }
+ if(RemindLabel)
+ {
+ RemindLabel->SetText("按 下一页");
+ RemindLabel->SetVisible(true);
+ }
+ break;
+ }
+ case THUNDERBIRD_LULLABYVIEW_5:
+ {
+ if (TextLabel)
+ {
+ TextLabel->SetText("是否退出哄睡模式");
+ TextLabel->SetY(160);
+ TextLabel->SetVisible(true);
+ }
+ if(RemindLabel)
+ {
+ RemindLabel->SetY(320);
+ RemindLabel->SetText("按 取消 按 确认");
+ RemindLabel->SetVisible(true);
+ }
+ if(RemindIcon)
+ {
+ RemindIcon->SetPosition(130, 320, 30, 30);
+ RemindIcon->SetSrc("/user/res/volumedown.bin");
+ RemindIcon->SetVisible(true);
+ }
+ if(RemindIcon2)
+ {
+ RemindIcon2->SetPosition(280, 320, 30, 30);
+ RemindIcon2->SetSrc("/user/res/volumeup.bin");
+ RemindIcon2->SetVisible(true);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
}
static const int64_t COLOR_SIGNAL_ON = 0xffffffff;
static const int64_t COLOR_SIGNAL_OFF = 0xff383838;
- static ThunderBirdView *g_pThunderBirdView{nullptr};
-
static MediaVideoPlay *g_videoPlay = nullptr;
static bool g_lastPlayed = false;
static void ScreenStatusNotify(ScreenStatus status)
void ThunderBirdMainView::DeInit()
{
- if (g_pThunderBirdView)
- {
- delete g_pThunderBirdView;
- g_pThunderBirdView = nullptr;
- }
- if (g_pThunderBirdOtaView)
- {
- delete g_pThunderBirdOtaView;
- g_pThunderBirdOtaView = nullptr;
- }
- if (g_pThunderBirdGuideView)
- {
- delete g_pThunderBirdGuideView;
- g_pThunderBirdGuideView = nullptr;
- }
- if (g_pThunderBirdLullabyView)
- {
- delete g_pThunderBirdLullabyView;
- g_pThunderBirdLullabyView = nullptr;
- }
- if (g_pThunderBirdDialogueView)
- {
- delete g_pThunderBirdDialogueView;
- g_pThunderBirdDialogueView = nullptr;
- }
- if (g_pThunderBirdReminderView)
- {
- delete g_pThunderBirdReminderView;
- g_pThunderBirdReminderView = nullptr;
- }
- if (g_pThunderBirdAdjustView)
+ // 释放各子界面对象
+ if (g_pThunderBirdView) { delete g_pThunderBirdView; g_pThunderBirdView = nullptr; }
+ if (g_pThunderBirdOtaView) { delete g_pThunderBirdOtaView; g_pThunderBirdOtaView = nullptr; }
+ if (g_pThunderBirdGuideView) { delete g_pThunderBirdGuideView; g_pThunderBirdGuideView = nullptr; }
+ if (g_pThunderBirdLullabyView) { delete g_pThunderBirdLullabyView; g_pThunderBirdLullabyView = nullptr; }
+ if (g_pThunderBirdDialogueView) { delete g_pThunderBirdDialogueView; g_pThunderBirdDialogueView = nullptr; }
+ if (g_pThunderBirdReminderView) { delete g_pThunderBirdReminderView; g_pThunderBirdReminderView = nullptr; }
+ if (g_pThunderBirdAdjustView) { delete g_pThunderBirdAdjustView; g_pThunderBirdAdjustView = nullptr; }
+
+ // 置空所有分组索引,避免悬空指针
+ for (int i = 0; i < MAXVIEW; i++)
{
- delete g_pThunderBirdAdjustView;
- g_pThunderBirdAdjustView = nullptr;
+ group[i] = nullptr;
}
+
+ // 不再持有旧 View 实例,全部使用聚合组件
// 先停止视频播放
if (videoPlay_ != nullptr)
{
// 清理其他成员变量
video_ = nullptr;
videoPlayer_ = nullptr;
-
- // 置空所有分组索引,避免悬空指针
- for (int i = 0; i < MAXVIEW; i++)
- {
- group[i] = nullptr;
- }
}
void ThunderBirdMainView::OnStart()
ScrollView_->SetDraggable(true);
AddViewToRootContainer(ScrollView_);
RootView::GetInstance()->SetOnKeyActListener(presenter_);
- ChangeView(MAXVIEW, THUNDERBIRDMENUVIEW);
+
Initback();
+ // 顶部状态栏
InitBaseData();
+ // 默认显示主界面
+ ChangeView(MAXVIEW, THUNDERBIRD_GUIDEVIEW,0);
// 增加按键监听
RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::ThunderBirdPresenter::GetInstance();
RootView::GetInstance()->SetOnKeyActListener(keyactListener);
}
}
+ bool ThunderBirdMainView::SwitchVideo(const char *uri)
+ {
+ if (uri == nullptr || surfaceView_ == nullptr) {
+ return false;
+ }
+ // 停止并销毁旧播放器
+ if (videoPlay_ != nullptr)
+ {
+ if (videoPlay_->isPlayed_) {
+ videoPlay_->PauseVideoPlay();
+ }
+ if (videoPlay_->isEntered_) {
+ videoPlay_->StopVideoPlay();
+ }
+ delete videoPlay_;
+ videoPlay_ = nullptr;
+ }
+
+ Surface *surface = surfaceView_->GetSurface();
+ if (surface == nullptr) {
+ return false;
+ }
+
+ // 创建新播放器并启动
+ videoPlay_ = new MediaVideoPlay(surface, nullptr, std::string(uri), false);
+ if (videoPlay_ == nullptr) {
+ return false;
+ }
+ g_videoPlay = videoPlay_;
+ int32_t ret = videoPlay_->StartVideoPlay();
+ return (ret == 0);
+ }
bool ThunderBirdMainView::ChangeThunderBirdView(int16_t thisView)
{
// 检查视图是否已初始化
return false;
}
- void ThunderBirdMainView::ChangeView(int16_t hideView, int16_t showView)
+ void ThunderBirdMainView::ChangeView(int16_t hideView, int16_t showView, int16_t subView)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdMainView::ChangeView");
if (hideView > MAXVIEW)
}
ClickFunc(showView);
group[showView]->SetVisible(true);
+ group[showView]->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+ // 进入大界面后,根据 subView 跳转到其子界面
+ if (subView != -1)
+ {
+ switch (showView)
+ {
+ case THUNDERBIRD_GUIDEVIEW:
+ if (g_pThunderBirdGuideView)
+ {
+ g_pThunderBirdGuideView->Show(subView);
+ }
+ break;
+ case THUNDERBIRD_LULLABYVIEW:
+ if (g_pThunderBirdLullabyView)
+ {
+ g_pThunderBirdLullabyView->Show(subView);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ currentView_ = showView;//更新当前视图
+ currentSubView_ = subView;//更新当前子视图
ScrollView_->Invalidate();
+
+ }
+
+ int16_t ThunderBirdMainView::GetCurrentView() const
+ {
+ return currentView_;
+ }
+ int16_t ThunderBirdMainView::GetCurrentSubView() const
+ {
+ return currentSubView_;
}
void ThunderBirdMainView::Initback()
return;
}
}
- group1->SetPosition(80, 30, 302, 40);
+ group1->SetPosition(70, 40, 350, 40);
group1->SetStyle(STYLE_BACKGROUND_OPA, 0);
InitLabel(timeLabel, 0, (group1->GetHeight() - 38), 175, 38, "titleLable", "08:52", DEFAULT_VECTOR_FONT_FILENAME, 32);
return;
}
}
- NoSignal->SetPosition(148, (group1->GetHeight() - 38) / 2, 36, 38);
+ NoSignal->SetPosition(140, (group1->GetHeight() - 38) / 2, 36, 38);
NoSignal->SetAutoEnable(false);
NoSignal->SetResizeMode(UIImageView::CENTER);
NoSignal->SetSrc(DROPDOWN_NOSIGNAL_IMAGE);
};
// 待添加的 ImageView 信息列表
std::vector<ImageViewInfo> imageViewList = {
- {148, 28, 6, 6},
- {158, 20, 6, 14},
- {168, 12, 6, 22},
- {178, 4, 6, 30},
+ {140, 28, 6, 6},
+ {150, 20, 6, 14},
+ {160, 12, 6, 22},
+ {170, 4, 6, 30},
};
// 循环添加 ImageView 到相应的容器中
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryimage new fail");
return;
}
- batteryimage->SetPosition(178 + 20, (group1->GetHeight() - 30) / 2, 48, 30);
+ batteryimage->SetPosition(170 + 20, (group1->GetHeight() - 30) / 2, 48, 30);
std::string batteryimagesPath = "/user/res/Battery_White.bin";
batteryimage->SetSrc(batteryimagesPath.c_str());
group1->Add(batteryimage);
progress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45A5FF);
group1->Add(progress);
/* -----------------------------------电量--------------------------------------- */
- InitUILabel(batteryLabel, progress->GetX() + 8, batteryimage->GetY() + 6, 30, 22, "titleLable", "100", DEFAULT_VECTOR_FONT_FILENAME, 15);
- batteryLabel->SetStyle(STYLE_TEXT_COLOR, 0xff000000);
+ InitUILabel(batteryLabel, batteryimage->GetX() + 58, (group1->GetHeight() - 28) / 2, 30, 28, "titleLable", "100", DEFAULT_VECTOR_FONT_FILENAME, 25);
+ batteryLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full);
batteryLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT);
group1->Add(batteryLabel);
/* ----------------------------------充电图标-------------------------------------- */
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "chargeBatteryicon creation failed");
return;
}
- chargeBatteryicon->SetPosition(batteryLabel->GetX() + 10, batteryimage->GetY() + 2, 17, 22);
+ chargeBatteryicon->SetPosition(progress->GetX() + 6, batteryimage->GetY() + 2, 17, 26);
chargeBatteryicon->SetSrc("/user/res/Icon.bin");
chargeBatteryicon->SetAutoEnable(false);
chargeBatteryicon->SetResizeMode(UIImageView::CONTAIN);
value = battery_get_voltage(&voltage);
#endif
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "battery_get_voltage = %d", value);
- batteryLabel->SetText(std::to_string(static_cast<int>(value)).c_str()); // 电量
+ batteryLabel->SetText((std::to_string(static_cast<int>(value))+"%").c_str()); // 电量
progress->SetValue(value);
if (!chargeBatteryicon || !progress)
{
if (!isChargeBatteryIconVisible)
{
- batteryLabel->SetX(progress->GetX() + 1); // 电量
- batteryLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full); // 充电电量为白色
chargeBatteryicon->SetVisible(true); // 充电图标
isChargeBatteryIconVisible = true;
}
{
if (isChargeBatteryIconVisible)
{
- batteryLabel->SetX(progress->GetX() + 8); // 回到原来位置
- batteryLabel->SetStyle(STYLE_TEXT_COLOR, Color::Black().full); // 不充电电量为黑色
chargeBatteryicon->SetVisible(false); // 充电图标
isChargeBatteryIconVisible = false;
}
{
if (isChargeBatteryIconVisible)
{
- batteryLabel->SetX(progress->GetX() + 8); // 回到原来位置
- batteryLabel->SetStyle(STYLE_TEXT_COLOR, Color::Black().full); // 不充电电量为黑色
chargeBatteryicon->SetVisible(false); // 充电图标
isChargeBatteryIconVisible = false;
}
// 如果是power键就返回上一级
if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
{
- NativeAbility::GetInstance().Back();
+ int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView();
+ int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView();
+ if(currentView == THUNDERBIRD_GUIDEVIEW)
+ {
+ if(currentSubView == 0)
+ {
+ ThunderBirdMainView::GetInstance()->ChangeView(currentView,THUNDERBIRD_GUIDEVIEW,1);
+ }
+ else if(currentSubView == 1)
+ {
+ ThunderBirdMainView::GetInstance()->ChangeView(currentView,THUNDERBIRD_GUIDEVIEW,2);
+ }
+ else if(currentSubView == 2)
+ {
+ ThunderBirdMainView::GetInstance()->ChangeView(currentView,THUNDERBIRD_LULLABYVIEW,0);
+ }
+ }
+ else if(currentView == THUNDERBIRD_LULLABYVIEW)
+ {
+ if(currentSubView == 0)
+ {
+ ThunderBirdMainView::GetInstance()->ChangeView(currentView,THUNDERBIRD_LULLABYVIEW,1);
+ }
+ else if(currentSubView == 1)
+ {
+ ThunderBirdMainView::GetInstance()->ChangeView(currentView,THUNDERBIRD_LULLABYVIEW,2);
+ }
+ else if(currentSubView == 2)
+ {
+ ThunderBirdMainView::GetInstance()->ChangeView(currentView,THUNDERBIRD_LULLABYVIEW,3);
+ }
+ else if(currentSubView == 3)
+ {
+ ThunderBirdMainView::GetInstance()->ChangeView(currentView,THUNDERBIRD_LULLABYVIEW,4);
+ }
+ }
+ //NativeAbility::GetInstance().Back();
+ }
+ if(keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_FUNC) && keyState == 1 && uapi_get_screen_state() == 0)
+ {
+ ThunderBirdMainView::GetInstance()->SwitchVideo("/user/video/46x46_shocked.mp4");
}
return true;
}