UILabelExt *RemindLabel{nullptr};
UIImageView *RemindIcon{nullptr};
UIImageView *RemindIcon2{nullptr};
+ UIImageView *RemindIcon1{nullptr};
};
}
UIViewGroup *group{nullptr};
UIImageView *background{nullptr};
UILabelExt *TextLabel{nullptr};
+ UILabelExt *LittleTextLabel{nullptr};
UILabelExt *RemindLabel{nullptr};
UIImageView *RemindIcon{nullptr};
+ UIImageView *RemindIcon1{nullptr};
};
}
void ClearAll();
UIViewGroup* CreateIndependentStatusBar(); // 创建独立的状态栏
+ // 各个子界面的UI创建方法
+ UIViewGroup* CreateOtaNormalView(); // 创建正常升级界面
+ UIViewGroup* CreateOtaUpdatingView(); // 创建更新中界面
+
int16_t currentView_;
UIViewGroup *group[MAX_OTA_VIEW]{nullptr};
UIScrollView *ScrollView_{nullptr};
+ UIImageView *backgroundImageView{nullptr}; // 最底层背景图片
UIViewGroup *group1{nullptr};
UILabelExt *timeLabel{nullptr};
}
// 创建背景
- background = new UIImageView();
- if (background) {
- background->SetAutoEnable(false);
- background->SetPosition(0, 0, 360, 360);
- background->SetResizeMode(UIImageView::COVER);
- background->SetSrc("/user/res/yellowbg.bin");
- group->Add(background);
- }
+ // 背景图已移至OtaView.cpp作为最底层背景
+
// 创建文本标签
TextLabel = new UILabelExt();
group->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
}
- // 创建背景
- background = new UIImageView();
- if (background) {
- background->SetAutoEnable(false);
- background->SetPosition(0, 0, 360, 360);
- background->SetResizeMode(UIImageView::COVER);
- background->SetSrc("/user/res/yellowbg.bin");
- group->Add(background);
- }
+ // 背景图已移至OtaView.cpp作为最底层背景
// 创建文本标签
TextLabel = new UILabelExt();
if (TextLabel) {
- TextLabel->SetPosition(90, 102, 180, 42);
+ TextLabel->SetPosition(127, 122, 150, 42);
TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24);
TextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff);
// 创建小文本标签
LittleTextLabel = new UILabelExt();
if (LittleTextLabel) {
- LittleTextLabel->SetPosition(60, 162, 240, 28);
- LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 18);
- LittleTextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffcccccc);
- LittleTextLabel->SetText("更新过程中出现错误");
+ LittleTextLabel->SetPosition(70, 184, 220, 28);
+ LittleTextLabel->SetText("请检查网络和电量后重试");
LittleTextLabel->SetVisible(true);
group->Add(LittleTextLabel);
}
RemindIcon->SetVisible(true);
group->Add(RemindIcon);
}
+ if (RemindIcon1)
+ {
+ RemindIcon1->SetPosition(83, 124, 36, 36);
+ RemindIcon1->SetSrc("/user/res/warning.bin");
+ RemindIcon1->SetVisible(true);
+ group->Add(RemindIcon1);
+ }
// 创建第二个提示图标
RemindIcon2 = new UIImageView();
group = nullptr;
}
- if (background) { delete background; background = nullptr; }
+ // background已移至OtaView.cpp,无需在此清理
if (TextLabel) { delete TextLabel; TextLabel = nullptr; }
if (LittleTextLabel) { delete LittleTextLabel; LittleTextLabel = nullptr; }
- if (TextLabel) { delete TextLabel; TextLabel = nullptr; }
if (RemindLabel) { delete RemindLabel; RemindLabel = nullptr; }
if (RemindIcon) { delete RemindIcon; RemindIcon = nullptr; }
if (RemindIcon2) { delete RemindIcon2; RemindIcon2 = nullptr; }
+ if (RemindIcon1) { delete RemindIcon1; RemindIcon1 = nullptr; }
}
}
}
// 创建背景
- background = new UIImageView();
- if (background) {
- background->SetAutoEnable(false);
- background->SetPosition(0, 0, 360, 360);
- background->SetResizeMode(UIImageView::COVER);
- background->SetSrc("/user/res/yellowbg.bin");
- group->Add(background);
- }
+ // 背景图已移至OtaView.cpp作为最底层背景
+
// 创建文本标签
TextLabel = new UILabelExt();
}
// 创建背景
- background = new UIImageView();
- if (background) {
- background->SetAutoEnable(false);
- background->SetPosition(0, 0, 360, 360);
- background->SetResizeMode(UIImageView::COVER);
- background->SetSrc("/user/res/yellowbg.bin");
- group->Add(background);
- }
+ // 背景图已移至OtaView.cpp作为最底层背景
+
// 创建文本标签
TextLabel = new UILabelExt();
// 检查内存是否足够(至少100MB)
// TODO: 实现实际的内存检查
// int freeMemory = get_free_memory();
+ const char* memoryInfo = get_system_memory_info();
+ printf("memoryInfo: %s\r\n", memoryInfo);
int freeMemory = 200; // 暂时返回200MB可用内存
return (freeMemory >= 100);
}
}
// 创建背景
- background = new UIImageView();
- if (background) {
- background->SetAutoEnable(false);
- background->SetPosition(0, 0, 360, 360);
- background->SetResizeMode(UIImageView::COVER);
- background->SetSrc("/user/res/yellowbg.bin");
- group->Add(background);
- }
+ // 背景图已移至OtaView.cpp作为最底层背景
+
// 创建文本标签
TextLabel = new UILabelExt();
}
// 创建背景
- background = new UIImageView();
- if (background) {
- background->SetAutoEnable(false);
- background->SetPosition(0, 0, 360, 360);
- background->SetResizeMode(UIImageView::COVER);
- background->SetSrc("/user/res/yellowbg.bin");
- group->Add(background);
- }
+ // 背景图已移至OtaView.cpp作为最底层背景
+
// 创建文本标签
TextLabel = new UILabelExt();
}
// 创建背景
- background = new UIImageView();
- if (background) {
- background->SetAutoEnable(false);
- background->SetPosition(0, 0, 360, 360);
- background->SetResizeMode(UIImageView::COVER);
- background->SetSrc("/user/res/yellowbg.bin");
- group->Add(background);
- }
+ // 背景图已移至OtaView.cpp作为最底层背景
+
// 创建文本标签
TextLabel = new UILabelExt();
group->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
}
- // 创建背景
- background = new UIImageView();
- if (background) {
- background->SetAutoEnable(false);
- background->SetPosition(0, 0, 360, 360);
- background->SetResizeMode(UIImageView::COVER);
- background->SetSrc("/user/res/yellowbg.bin");
- group->Add(background);
- }
+ // 背景图已移至OtaView.cpp作为最底层背景
// 创建文本标签
TextLabel = new UILabelExt();
if (TextLabel) {
}
// 显式删除所有UI组件
- if (background) {
- delete background;
- background = nullptr;
- }
+ // background已移至OtaView.cpp,无需在此清理
if (TextLabel) {
delete TextLabel;
TextLabel = nullptr;
group->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
}
- // 创建背景
- background = new UIImageView();
- if (background) {
- background->SetAutoEnable(false);
- background->SetPosition(0, 0, 360, 360);
- background->SetResizeMode(UIImageView::COVER);
- background->SetSrc("/user/res/yellowbg.bin");
- group->Add(background);
- }
+ // 背景图已移至OtaView.cpp作为最底层背景
// 创建文本标签
TextLabel = new UILabelExt();
group = nullptr;
}
- if (background) { delete background; background = nullptr; }
+ // background已移至OtaView.cpp,无需在此清理
if (TextLabel) { delete TextLabel; TextLabel = nullptr; }
if (LittleTextLabel) { delete LittleTextLabel; LittleTextLabel = nullptr; }
if (TextLabel) { delete TextLabel; TextLabel = nullptr; }
else if (currentView == OtaView::OTA_VIEW_NIGHT_UPDATE) {
//夜间升级
//夜间升级操作
-
OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_NIGHT_UPDATE, OtaView::OTA_VIEW_NIGHT_UPDATE_SUCCESS);
}
- else if (currentView == OtaView::OTA_VIEW_NIGHT_UPDATE_SUCCESS) {
+ else if (currentView == OtaView::OTA_VIEW_NIGHT_UPDATE_SUCCESS || currentView == OtaView::OTA_VIEW_UPDATE_SUCCESS) {
//夜间升级成功
NativeAbility::GetInstance().SwitchSlice(VIEW_THUNDER_BIRD);
}
+ //倒计时界面确认,开始升级,定时器停止,进入升级中界面
+ else if (currentView == OtaView::OTA_VIEW_COUNTDOWN) {
+ do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_DOWNLOAD, NULL, 0);
+ OtaModel::GetInstance()->StopCountdownTimer();
+ OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_COUNTDOWN, OtaView::OTA_VIEW_UPDATING);
+ }
+ //升级失败界面重试
+ else if (currentView == OtaView::OTA_VIEW_UPDATE_FAILED) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "升级失败界面重试");
+ OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_UPDATE_FAILED, OtaView::OTA_VIEW_COUNTDOWN);
+ }
break;
case static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_VENDOR_DOWN)://VENDOR_DOWN键
if (currentView == OtaView::OTA_VIEW_NORMAL) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "普通升级界面跳转升级中");
-
OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_NORMAL, OtaView::OTA_VIEW_NIGHT_UPDATE);
}
else if (currentView == OtaView::OTA_VIEW_UPDATE_NOW) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "强制升级界面跳转升级中");
-
OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_UPDATE_NOW, OtaView::OTA_VIEW_NIGHT_UPDATE);
}
- else if (currentView == OtaView::OTA_VIEW_NIGHT_UPDATE) {
+ else if (currentView == OtaView::OTA_VIEW_NIGHT_UPDATE_SUCCESS || currentView == OtaView::OTA_VIEW_NIGHT_UPDATE || currentView == OtaView::OTA_VIEW_COUNTDOWN) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "夜间升级界面跳转普通升级");
NativeAbility::GetInstance().SwitchSlice(VIEW_THUNDER_BIRD);
}
-
+ else if (currentView == OtaView::OTA_VIEW_NETWORK_ERROR || currentView == OtaView::OTA_VIEW_LOW_BATTERY || currentView == OtaView::OTA_VIEW_MEMORY_ERROR ||currentView == OtaView::OTA_VIEW_UPDATE_FAILED) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "网络异常、电量不足、内存不足界面跳转普通升级");
+ NativeAbility::GetInstance().SwitchSlice(VIEW_THUNDER_BIRD);
+ }
break;
}
}
// 创建背景
- background = new UIImageView();
- if (background) {
- background->SetAutoEnable(false);
- background->SetPosition(0, 0, 360, 360);
- background->SetResizeMode(UIImageView::COVER);
- background->SetSrc("/user/res/yellowbg.bin");
- group->Add(background);
- }
+ // 背景图已移至OtaView.cpp作为最底层背景
+
// 创建文本标签
TextLabel = new UILabelExt();
if (TextLabel) {
- TextLabel->SetPosition(90, 102, 180, 84);
+ TextLabel->SetPosition(127, 122, 164, 42);
TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24);
TextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff);
- TextLabel->SetText("设定成功!\n记得充好电哦");
TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ TextLabel->SetText("更新成功");
TextLabel->SetVisible(true);
group->Add(TextLabel);
}
+ if (LittleTextLabel)
+ {
+ LittleTextLabel->SetPosition(80, 184, 220, 28);
+ LittleTextLabel->SetText("你的设备已是最新版本");
+ LittleTextLabel->SetVisible(true);
+ group->Add(LittleTextLabel);
+ }
// 创建提示标签
RemindLabel = new UILabelExt();
RemindLabel->SetVisible(true);
group->Add(RemindLabel);
}
-
- // 创建提示图标
- RemindIcon = new UIImageView();
- if (RemindIcon) {
- RemindIcon->SetAutoEnable(false);
+ if (RemindIcon)
+ {
RemindIcon->SetPosition(160, 277, 22, 22);
- RemindIcon->SetResizeMode(UIImageView::CONTAIN);
- RemindIcon->SetSrc("/user/res/volume_down.bin");
+ RemindIcon->SetSrc("/user/res/volume_up.bin");
RemindIcon->SetVisible(true);
group->Add(RemindIcon);
}
-
+ if (RemindIcon1)
+ {
+ RemindIcon1->SetPosition(98, 124, 36, 36);
+ RemindIcon1->SetSrc("/user/res/completed.bin");
+ RemindIcon1->SetVisible(true);
+ group->Add(RemindIcon1);
+ }
return group;
}
group = nullptr;
}
- if (background) { delete background; background = nullptr; }
+ // background已移至OtaView.cpp,无需在此清理
if (TextLabel) { delete TextLabel; TextLabel = nullptr; }
+ if (LittleTextLabel) { delete LittleTextLabel; LittleTextLabel = nullptr; }
if (RemindLabel) { delete RemindLabel; RemindLabel = nullptr; }
if (RemindIcon) { delete RemindIcon; RemindIcon = nullptr; }
+ if (RemindIcon1) { delete RemindIcon1; RemindIcon1 = nullptr; }
}
}
}
// 创建背景
- background = new UIImageView();
- if (background) {
- background->SetAutoEnable(false);
- background->SetPosition(0, 0, 360, 360);
- background->SetResizeMode(UIImageView::COVER);
- background->SetSrc("/user/res/yellowbg.bin");
- group->Add(background);
- }
+ // 背景图已移至OtaView.cpp作为最底层背景
+
// 创建文本标签
TextLabel = new UILabelExt();
group = nullptr;
}
- if (background) { delete background; background = nullptr; }
+ // background已移至OtaView.cpp,无需在此清理
if (TextLabel) { delete TextLabel; TextLabel = nullptr; }
if (LittleTextLabel) { delete LittleTextLabel; LittleTextLabel = nullptr; }
if (TextLabel) { delete TextLabel; TextLabel = nullptr; }
group->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
}
- // 创建背景
- background = new UIImageView();
- if (background) {
- background->SetAutoEnable(false);
- background->SetResizeMode(UIImageView::CONTAIN);
- background->SetPosition(0, 0, 360, 360);
- background->SetResizeMode(UIImageView::COVER);
- background->SetSrc("/user/res/yellowbg.bin");
- group->Add(background);
- }
+ // 背景图已移至OtaView.cpp作为最底层背景
// 创建标题标签
titleLabel = new UILabelExt();
if (titleLabel) {
+ titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
titleLabel->SetPosition(90, 108, 180, 82);
titleLabel->SetText("更新中\n请勿关闭设备");
titleLabel->SetVisible(true);
group->Add(titleLabel);
}
-
// 创建进度条
progressBar = new UIBoxProgress();
if (progressBar) {
- progressBar->SetPosition(80, 150, 200, 20);
- progressBar->SetValidWidth(200);
- progressBar->SetValidHeight(20);
+ progressBar->SetPosition(56, 279, 248, 4);
progressBar->SetRange(100, 0);
- progressBar->SetStyle(STYLE_BORDER_RADIUS, 10);
- progressBar->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xff333333);
- progressBar->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff45A5FF);
+ progressBar->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0xff);
+ progressBar->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xffb4a9a0);
+ progressBar->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ progressBar->SetForegroundStyle(STYLE_TEXT_COLOR, 0xff000000);
+ progressBar->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45A5FF);
progressBar->SetValue(0);
group->Add(progressBar);
}
// 创建进度百分比标签
LittleTextLabel = new UILabelExt();
if (LittleTextLabel) {
- LittleTextLabel->SetPosition(56, 180, 44, 28);
+ LittleTextLabel->SetPosition(56, 243, 44, 28);
LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 18);
LittleTextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff);
group = nullptr;
}
- if (background) { delete background; background = nullptr; }
+ // background已移至OtaView.cpp,无需在此清理
if (titleLabel) { delete titleLabel; titleLabel = nullptr; }
if (LittleTextLabel) { delete LittleTextLabel; LittleTextLabel = nullptr; }
if (RemindLabel) { delete RemindLabel; RemindLabel = nullptr; }
AddViewToRootContainer(ScrollView_);
}
+ // 创建最底层背景图片
+ backgroundImageView = new UIImageView();
+ if (backgroundImageView) {
+ backgroundImageView->SetAutoEnable(false);
+ backgroundImageView->SetPosition(0, 0, 360, 360);
+ backgroundImageView->SetResizeMode(UIImageView::COVER);
+ backgroundImageView->SetSrc("/user/res/yellowbg.bin");
+ ScrollView_->Add(backgroundImageView);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Background image added to ScrollView");
+ }
+
int otaStatus = ThunderBirdModel::GetInstance()->GetOtaStatus();
if(otaStatus == OTA_UI_STATUS_OPTIONAL_START)//选择升级
{
group[hideView]->SetVisible(false);
}
ClickFunc(showView);
+ group[showView]->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
group[showView]->SetVisible(true);
+
ScrollView_->Invalidate();
}
void OtaView::ClearAll()
{
- // 清理所有视图组
+ // 清理所有视图组 - 先从ScrollView中移除,然后让各个view对象自己清理
for (int i = 0; i < MAX_OTA_VIEW; i++) {
if (group[i]) {
- group[i]->RemoveAll();
- delete group[i];
+ // 先从ScrollView中移除
+ if (ScrollView_) {
+ ScrollView_->Remove(group[i]);
+ }
+ // 不在这里删除group[i],让各个view对象自己清理
group[i] = nullptr;
}
}
+ // 清理状态栏相关视图
+ if (group1) {
+ // 先从ScrollView中移除
+ if (ScrollView_) {
+ ScrollView_->Remove(group1);
+ }
+ // 清理状态栏子视图
+ if (timeLabel) {
+ group1->Remove(timeLabel);
+ delete timeLabel;
+ timeLabel = nullptr;
+ }
+ if (NoSignal) {
+ group1->Remove(NoSignal);
+ delete NoSignal;
+ NoSignal = nullptr;
+ }
+ for (int i = 0; i < 4; i++) {
+ if (showSignalStrength[i]) {
+ group1->Remove(showSignalStrength[i]);
+ delete showSignalStrength[i];
+ showSignalStrength[i] = nullptr;
+ }
+ }
+ if (batteryimage) {
+ group1->Remove(batteryimage);
+ delete batteryimage;
+ batteryimage = nullptr;
+ }
+ if (progress) {
+ group1->Remove(progress);
+ delete progress;
+ progress = nullptr;
+ }
+ if (batteryLabel) {
+ group1->Remove(batteryLabel);
+ delete batteryLabel;
+ batteryLabel = nullptr;
+ }
+ if (chargeBatteryicon) {
+ group1->Remove(chargeBatteryicon);
+ delete chargeBatteryicon;
+ chargeBatteryicon = nullptr;
+ }
+ // 最后删除group1
+ group1->RemoveAll();
+ delete group1;
+ group1 = nullptr;
+ }
+
+ // 清理背景图片
+ if (backgroundImageView) {
+ if (ScrollView_) {
+ ScrollView_->Remove(backgroundImageView);
+ }
+ delete backgroundImageView;
+ backgroundImageView = nullptr;
+ }
+
// 清理滚动视图
if (ScrollView_) {
ScrollView_->RemoveAll();
ScrollView_ = nullptr;
}
- // Clean up all view pointers
+ // Clean up all view pointers - these will clean up their own UI components
if (g_pOtaNormalView) {
delete g_pOtaNormalView;
g_pOtaNormalView = nullptr;
delete g_pOtaNightUpdateSuccessView;
g_pOtaNightUpdateSuccessView = nullptr;
}
-
-
}
// 更新电池进度条
progress->SetValue(batteryLevel);
+ // 根据充电状态和电量设置进度条颜色
+
+ if (isCharging) {
+ // 充电时显示绿色
+ progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); // 绿色
+ } else if (batteryLevel <= 20) {
+ // 电量低于20%显示红色
+ progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Red().full); // 红色
+ } else {
+ // 正常状态显示蓝色
+ progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); // 蓝色
+ }
+
// 更新充电图标显示
chargeBatteryicon->SetVisible(isCharging);
}