From: xue <2144439972@qq.com> Date: Thu, 9 Oct 2025 06:59:30 +0000 (+0800) Subject: 优化表情下载成功失败逻辑 X-Git-Tag: V1.0.9_20251128_194606_LN~268^2~10 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=9b3b9f9c51a7bf63e7500d281096c5cdccabf015;p=mirrors%2FFD230.git 优化表情下载成功失败逻辑 --- diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/include/uiservice/ui_service.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/include/uiservice/ui_service.h index 97d2e735e..9c0d3ee62 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/include/uiservice/ui_service.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/include/uiservice/ui_service.h @@ -64,6 +64,7 @@ typedef enum { HAND_DOWNLOAD_FILE_NOTIFY, // 下载文件通知 HAND_DOWNLOAD_SUCCESS_NOTIFY, // 下载成功通知 HAND_DOWNLOAD_FAIL_NOTIFY, // 下载失败通知 + HAND_DOWNLOAD_PROGRESS_NOTIFY, // 下载进度通知 MAX_NUM_HANDLER, } UiServiceMsgId; diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaModel.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaModel.h index ddef5bb13..74e8d3834 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaModel.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaModel.h @@ -61,7 +61,10 @@ namespace OHOS bool HasNetwork() const; bool IsBatterySufficient() const; bool IsMemorySufficient() const; - + + void HandleDownloadSuccess(int type); + void HandleDownloadProgress(int progress); + void HandleDownloadFail(int type); private: OtaModel(); virtual ~OtaModel(); diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaSuccessView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaSuccessView.h index 5915a3565..143982ffd 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaSuccessView.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaSuccessView.h @@ -25,7 +25,8 @@ namespace OHOS static OtaSuccessView* GetInstance(); UIViewGroup* InitUI(); void ClearAll(); - + //表情屏保下载成功,显示下载成功 + void UpdateDownloadSuccess(std::string content); private: UIViewGroup *group{nullptr}; diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaDownloadView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaDownloadView.cpp index 8ecc83405..fa549fec9 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaDownloadView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaDownloadView.cpp @@ -45,36 +45,27 @@ namespace OHOS // 创建主标题 TextLabel = new UILabelExt(); if (TextLabel) { - TextLabel->SetPosition(127, 100, 164, 42); TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + TextLabel->SetPosition(90, 108, 180, 82); + TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); TextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - TextLabel->SetText("正在下载"); TextLabel->SetVisible(true); group->Add(TextLabel); } - // 创建状态标签 - StatusLabel = new UILabelExt(); - if (StatusLabel) { - StatusLabel->SetPosition(80, 150, 220, 28); - StatusLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - StatusLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); - StatusLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); - StatusLabel->SetText("准备下载..."); - StatusLabel->SetVisible(true); - group->Add(StatusLabel); - } // 创建进度条 ProgressBar = new UIBoxProgress(); if (ProgressBar) { - ProgressBar->SetPosition(80, 200, 200, 8); + ProgressBar->SetPosition(56, 279, 248, 4); ProgressBar->SetRange(100, 0); ProgressBar->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0xff); - ProgressBar->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xff333333); - ProgressBar->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff00ff00); + 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); ProgressBar->SetVisible(true); group->Add(ProgressBar); @@ -83,7 +74,7 @@ namespace OHOS // 创建进度文本 ProgressLabel = new UILabelExt(); if (ProgressLabel) { - ProgressLabel->SetPosition(80, 220, 200, 24); + ProgressLabel->SetPosition(56, 243, 44, 28); ProgressLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); ProgressLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 18); ProgressLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); @@ -91,17 +82,7 @@ namespace OHOS ProgressLabel->SetVisible(true); group->Add(ProgressLabel); } - // 创建提示标签 - RemindLabel = new UILabelExt(); - if (RemindLabel) { - RemindLabel->SetPosition(136, 300, 88, 25); - RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); - RemindLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); - RemindLabel->SetText("请稍候..."); - RemindLabel->SetVisible(true); - group->Add(RemindLabel); - } + return group; } @@ -115,10 +96,7 @@ namespace OHOS } if (TextLabel) { delete TextLabel; TextLabel = nullptr; } - if (StatusLabel) { delete StatusLabel; StatusLabel = nullptr; } if (ProgressLabel) { delete ProgressLabel; ProgressLabel = nullptr; } - if (RemindLabel) { delete RemindLabel; RemindLabel = nullptr; } - if (RemindIcon) { delete RemindIcon; RemindIcon = nullptr; } if (ProgressBar) { delete ProgressBar; ProgressBar = nullptr; } } @@ -159,19 +137,18 @@ namespace OHOS if (TextLabel) { switch (type) { - case 1: // 屏保下载 - TextLabel->SetText("下载屏保"); + case 0: // 屏保下载 + TextLabel->SetText("下载屏保中\n请勿关闭设备"); break; - case 2: // 表情下载 - TextLabel->SetText("下载表情"); + case 1: // 表情下载 + TextLabel->SetText("下载表情中\n请勿关闭设备"); break; default: - TextLabel->SetText("正在下载"); + TextLabel->SetText("正在下载\n请勿关闭设备"); break; } TextLabel->Invalidate(); } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaDownloadView::SetDownloadType: %d", type); } } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp index 8594df032..0d0819329 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp @@ -391,4 +391,41 @@ namespace OHOS return uapi_dev_runtime_get_cat1_signal(); } + + //下载成功通知 + void OtaModel::HandleDownloadSuccess(int type) + { + if(OtaDownloadView::GetInstance()) + { + OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_DOWNLOAD, OtaView::OTA_VIEW_UPDATE_SUCCESS); + if(type == 0) //表情切换 + { + OtaSuccessView::GetInstance()->UpdateDownloadSuccess("屏保下载成功"); + } + else if(type == 1) //屏保切换 + { + OtaSuccessView::GetInstance()->UpdateDownloadSuccess("表情下载成功"); + } + } + } + + //下载进度通知 + void OtaModel::HandleDownloadProgress(int progress) + { + if(OtaDownloadView::GetInstance()) + { + OtaDownloadView::GetInstance()->UpdateDownloadProgress(progress); + } + } + + //下载失败通知 + void OtaModel::HandleDownloadFail(int type) + { + if(OtaDownloadView::GetInstance()) + { + OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_DOWNLOAD, OtaView::OTA_VIEW_UPDATE_SUCCESS); + OtaDownloadView::GetInstance()->UpdateDownloadSuccess("下载失败"); + } + + } } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp index 6a5b15fb4..65660b79b 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp @@ -6,6 +6,7 @@ #include "ota/include/OtaPresenter.h" #include "ota/include/OtaView.h" #include "ota/include/OtaModel.h" +#include "thunderbird/include/ThunderBirdModel.h" #include "wearable_log.h" #include "ln_api.h" #include "custom_utils.h" @@ -140,6 +141,7 @@ namespace OHOS } else if (currentView == OtaView::OTA_VIEW_NIGHT_UPDATE_SUCCESS || currentView == OtaView::OTA_VIEW_UPDATE_SUCCESS) { //夜间升级成功 + ThunderBirdModel::GetInstance()->ResetOtaStatus(); NativeAbility::GetInstance().SwitchSlice(VIEW_THUNDER_BIRD); } //倒计时界面确认,开始升级,定时器停止,进入升级中界面 @@ -166,10 +168,12 @@ namespace OHOS } 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, "夜间升级界面跳转普通升级"); + ThunderBirdModel::GetInstance()->ResetOtaStatus(); 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, "网络异常、电量不足、内存不足界面跳转普通升级"); + ThunderBirdModel::GetInstance()->ResetOtaStatus(); NativeAbility::GetInstance().SwitchSlice(VIEW_THUNDER_BIRD); } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaSuccessView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaSuccessView.cpp index 55909abc5..72616976e 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaSuccessView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaSuccessView.cpp @@ -119,4 +119,11 @@ namespace OHOS if (RemindIcon1) { delete RemindIcon1; RemindIcon1 = nullptr; } } + void OtaSuccessView::UpdateDownloadSuccess(std::string content) + { + TextLabel->SetText(content.c_str()); + LittleTextLabel->SetVisible(false); + TextLabel->Invalidate(); + + } } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaView.cpp index 0f99c735d..24c083ef7 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaView.cpp @@ -94,7 +94,11 @@ namespace OHOS int downloadFileType = ThunderBirdModel::GetInstance()->GetDownloadFile(); if(downloadFileType != -1) { - ChangeView(MAX_OTA_VIEW, OTA_VIEW_NIGHT_UPDATE); + ChangeView(MAX_OTA_VIEW, OTA_VIEW_DOWNLOAD); + if(OtaDownloadView::GetInstance()) + { + OtaDownloadView::GetInstance()->SetDownloadType(downloadFileType); + } } } @@ -669,7 +673,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryLabel new fail"); return nullptr; } - batteryLabel->SetPosition(batteryimage->GetX() + 38, (group1->GetHeight() - 14) / 2, 30, 30); + batteryLabel->SetPosition(batteryimage->GetX() + 35, (group1->GetHeight() - 14) / 2, 30, 30); batteryLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 15); batteryLabel->SetText("100"); batteryLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full); @@ -769,7 +773,10 @@ namespace OHOS if (showSignalStrength[i] != nullptr) { // 根据信号强度显示对应的信号条 // 信号强度范围0-31,分为4个等级:0-7, 8-15, 16-23, 24-31 - bool showBar = (signalStrength >= (i + 1) * 8); + // 修改逻辑:第1条>=8, 第2条>=16, 第3条>=24, 第4条>=28 + int threshold = (i + 1) * 8; + if (i == 3) threshold = 28; // 第4条在28以上显示 + bool showBar = (signalStrength >= threshold); showSignalStrength[i]->SetVisible(hasSignal && showBar); } } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h index 1a3060f5c..ad007c076 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h @@ -49,6 +49,7 @@ namespace OHOS // OTA升级状态 void UpdateOtaStatus(int status); int GetOtaStatus(); + void ResetOtaStatus(); // 新手引导相关函数 enum class BindingStatus { BOUND = 0, // 已绑定 diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp index 2d14d2db8..3c7580137 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp @@ -316,6 +316,13 @@ return m_otaStatus; } + /*************************重置OTA升级状态*************************/ + void ThunderBirdModel::ResetOtaStatus() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::ResetOtaStatus: resetting OTA status to 0"); + m_otaStatus = 0; + } + // ==================== 恢复出厂设置相关函数 ==================== bool ThunderBirdModel::restore_factory_settings()