From: luozheng <1732036298@qq.com> Date: Tue, 7 May 2024 09:23:43 +0000 (+0800) Subject: 添加系统更新Slice X-Git-Tag: release_V1.2.70_20241020_135402~1025^2~16^2~5 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=7462a7e7b9d5d835a76d983b9a09a2d0f4cf3b2c;p=mirrors%2FFD230.git 添加系统更新Slice --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index f914e30b9..149872fe2 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -363,6 +363,10 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/Systemupgrade.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/system/src/SystemFactoryResetView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemupdate/src/SystemUpdateModel.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemupdate/src/SystemUpdateView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/systemupdate/src/SystemUpdatePresenter.cpp + #声音与震动 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationView.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index 46c023433..c28ea6f07 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -61,6 +61,7 @@ typedef enum : uint16_t VIEW_BRIGHTNESSLEVEL, // 亮度调节 VIEW_NETWORKANDCALL, // 网络与通话 VIEW_MOTION_RECOGNITION, // 运动识别 + VIEW_SYSTEM_UPDATE, // 系统更新 /* ----------------------------------- 录音 ----------------------------------- */ VIEW_RECORD, /* ---------------------------------- 界面 ---------------------------------- */ diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index e9657b937..c4c0ebe19 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -57,6 +57,7 @@ namespace OHOS void InitBrightnessLevelSlice(void); void InitNetworkAndCallSlice(void); void InitMotionRecognitionSlice(void); + void InitSystemUpdateSlice(void); /* --------------------------------界面------------------------------------ */ void InitRotateSlice(void); void InitBloodSlice(void); diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 7c43bfb5a..f27b9c216 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -173,6 +173,9 @@ #include "motionrecognition/include/MotionRecognitionPresenter.h" #include "motionrecognition/include/MotionRecognitionView.h" + +#include "systemupdate/include/SystemUpdatePresenter.h" +#include "systemupdate/include/SystemUpdateView.h" /* -------------------------------------------------------------------------- */ #include "traing/include/TraingView.h" #include "traing/include/TraingPresenter.h" @@ -261,6 +264,7 @@ namespace OHOS {VIEW_DISPLAY_BRIGHTNESS, &NativeLauncher::InitDisplayBrightnessSlice}, // 显示与亮度的实例化地址 {VIEW_NETWORKANDCALL, &NativeLauncher::InitNetworkAndCallSlice}, // 网络与通话 {VIEW_MOTION_RECOGNITION, &NativeLauncher::InitMotionRecognitionSlice}, // 网络与通话 + {VIEW_SYSTEM_UPDATE, &NativeLauncher::InitSystemUpdateSlice}, // 系统更新界面 // {VIEW_SECONDARY_FUNCTION, &NativeLauncher::InitSecondaryFunction}, // {VIEW_FAST_TRAINING, &NativeLauncher::InitFastTrainingSlice}, @@ -1132,6 +1136,18 @@ namespace OHOS } NativeAbility::GetInstance().AddSliceProxy(VIEW_MOTION_RECOGNITION, motionrecognition); } + + /*系统更新*/ + void NativeLauncher::InitSystemUpdateSlice(void) + { + SliceProxy *systemupdate = new AbilitySliceProxy; + if (systemupdate == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "systemupdate"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SYSTEM_UPDATE, systemupdate); + } /* -------------------------------------------------------------------------- */ void NativeLauncher::InitSetDesktopSlice(void) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp index 96c45f3c3..8d5d0b4e1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp @@ -164,7 +164,8 @@ namespace OHOS } else if (strcmp(view.GetViewId(), SYSTEM_UPGRADE) == 0) // 点击进入系统升级视图 { - p_SystemView->ChangeView(SYSTEMVIEW, SYSTEMLUPGRADE); + //p_SystemView->ChangeView(SYSTEMVIEW, SYSTEMLUPGRADE); + NativeAbility::GetInstance().EnterSlice(VIEW_SYSTEM_UPDATE); return true; } else if (strcmp(view.GetViewId(), WATCH_QR_CODE) == 0) // 点击进入手表二维码视图 @@ -194,7 +195,7 @@ namespace OHOS } - if (strcmp(view.GetViewId(), SYSTEM_UPGRADE) == 0) //点击是否立即升级 + if (strcmp(view.GetViewId(), "UpdateNowButton") == 0) //点击是否立即升级 { SystemupgradeView::GetInstance()->statr_down_fwpkg(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp index 1558a10b8..af820470b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/Systemupgrade.cpp @@ -1000,7 +1000,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemUpgradeButtonExt new fail!"); } SystemUpgradeButton_->SetPosition(163, 400, 180, 80); - SystemUpgradeButton_->SetViewId(SYSTEM_UPGRADE); + SystemUpgradeButton_->SetViewId("UpdateNowButton"); SystemUpgradeButton_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); SystemUpgradeButton_->SetText("确认升级"); SystemUpgradeButton_->SetAlign(TEXT_ALIGNMENT_LEFT); diff --git a/code/sdk/application/wearable/fd230app/nativeui/systemupdate/include/SystemUpdateModel.h b/code/sdk/application/wearable/fd230app/nativeui/systemupdate/include/SystemUpdateModel.h new file mode 100644 index 000000000..82c7b6d94 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/systemupdate/include/SystemUpdateModel.h @@ -0,0 +1,28 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-05-07 11:26:14 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-05-07 16:31:17 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/systemupdate/include/SystemUpdateModel.h + */ + +#ifndef SYSTEM_UPDATE_MODEL_H +#define SYSTEM_UPDATE_MODEL_H + +namespace OHOS +{ + class SystemUpdateModel + { + public: + static SystemUpdateModel &GetInstance(void); + bool IsLatestVersion(void); + + private: + SystemUpdateModel(); + SystemUpdateModel(const SystemUpdateModel &) = delete; + SystemUpdateModel &operator=(const SystemUpdateModel &) = delete; + virtual ~SystemUpdateModel(); + }; +} + +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/systemupdate/include/SystemUpdatePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/systemupdate/include/SystemUpdatePresenter.h new file mode 100644 index 000000000..45ab33630 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/systemupdate/include/SystemUpdatePresenter.h @@ -0,0 +1,44 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-05-07 11:25:49 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-05-07 14:22:10 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/systemupdate/include/SystemUpdatePresenter.h + */ + +#ifndef SYSTEM_UPDATE_PRESENTER_H +#define SYSTEM_UPDATE_PRESENTER_H + +#include "Presenter.h" +#include "View.h" + +namespace OHOS +{ + class SystemUpdateView; + class SystemUpdatePresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UIView::OnDragListener + { + public: + SystemUpdatePresenter(); + virtual ~SystemUpdatePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SystemUpdatePresenter *GetInstance(); + + 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 diff --git a/code/sdk/application/wearable/fd230app/nativeui/systemupdate/include/SystemUpdateView.h b/code/sdk/application/wearable/fd230app/nativeui/systemupdate/include/SystemUpdateView.h new file mode 100644 index 000000000..bf1cc7d98 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/systemupdate/include/SystemUpdateView.h @@ -0,0 +1,67 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-05-07 11:25:27 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-05-07 16:13:06 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/systemupdate/include/SystemUpdateView.h + */ + +#ifndef SYSTEM_UPDATE_VIEW_H +#define SYSTEM_UPDATE_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +namespace OHOS +{ + class SystemUpdatePresenter; + class SystemUpdateView : public View + { + + public: + SystemUpdateView(); + virtual ~SystemUpdateView(); + static SystemUpdateView *GetInstance(void); + + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; // 字体大小 + int16_t lineHeigh; // 行高 + uint16_t textId; + uint8_t lineBreakMode; // 断行模式。 + }; + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + UIButton *GetUpdateNowButtton(void); + UIButton *GetTryAgainLaterButton(void); + + private: + bool SetSystemUpdateScrollView(void); + UILabelExt *InitLabel_Ext(LabelConfig &labelConfig); + void SystemUpdateViewInit(void); + void ClearAll(void); + + UIScrollView *SystemUpdateScrollView{nullptr}; + UILabelExt *Title{nullptr}; // 标题 + UIImageView *KUMILOGOImage{nullptr}; // KUMILogo图片 + UILabelExt *LatestVersionLabel{nullptr}; // 最新版本 + UILabelExt *VersionIdLabel{nullptr}; // 版本编号 + UILabelExt *UpdateNowLabel{nullptr}; // 立即升级标签 + UILabelExt *TryAgainLaterLabel{nullptr}; // 稍后再试标签 + UIButton *UpdateNowButtton{nullptr}; // 立即升级按钮 + UIButton *TryAgainLaterButton{nullptr}; // 稍后再试按钮 + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/systemupdate/src/SystemUpdateModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/systemupdate/src/SystemUpdateModel.cpp new file mode 100644 index 000000000..2ed512c65 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/systemupdate/src/SystemUpdateModel.cpp @@ -0,0 +1,35 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-05-07 11:26:25 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-05-07 16:32:26 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/systemupdate/src/SystemUpdateModel.cpp + */ +#include "systemupdate/include/SystemUpdateModel.h" +#include "wearable_log.h" + +namespace OHOS +{ + SystemUpdateModel::SystemUpdateModel() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemUpdateModel::SystemUpdateModel"); + } + + SystemUpdateModel::~SystemUpdateModel() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemUpdateModel::~SystemUpdateModel"); + } + + SystemUpdateModel &SystemUpdateModel::GetInstance() + { + static SystemUpdateModel instance; + return instance; + } + + //获取是否是最新版本 + bool SystemUpdateModel::IsLatestVersion(void) + { + return false; + } + +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/systemupdate/src/SystemUpdatePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/systemupdate/src/SystemUpdatePresenter.cpp new file mode 100644 index 000000000..bd5945988 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/systemupdate/src/SystemUpdatePresenter.cpp @@ -0,0 +1,117 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-05-07 11:26:06 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-05-07 17:14:36 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/systemupdate/src/SystemUpdatePresenter.cpp + */ + +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "systemupdate/include/SystemUpdatePresenter.h" +#include "systemupdate/include/SystemUpdateView.h" +#include "common/key_code.h" +#include +#include "UiConfig.h" +#include "wearable_log.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SystemUpdatePresenter *g_pSystemUpdatePresenter = nullptr; + + SystemUpdatePresenter::SystemUpdatePresenter() + { + g_pSystemUpdatePresenter = this; + } + + SystemUpdatePresenter::~SystemUpdatePresenter() + { + g_pSystemUpdatePresenter = nullptr; + } + + SystemUpdatePresenter *SystemUpdatePresenter::GetInstance() + { + return g_pSystemUpdatePresenter; + } + + void SystemUpdatePresenter::OnStart() + { + Presenter::OnStart(); + } + + void SystemUpdatePresenter::OnPause(void) + { + Presenter::OnPause(); + } + + void SystemUpdatePresenter::OnResume(void) + { + Presenter::OnResume(); + } + + void SystemUpdatePresenter::OnStop(void) + { + Presenter::OnStop(); + } + + bool SystemUpdatePresenter::OnClick(UIView &view, const ClickEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemUpdatePresenter::OnClick"); + SystemUpdateView *systemUpdateView = SystemUpdateView::GetInstance(); + if (systemUpdateView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::GetInstance fail!"); + return false; + } + + if (&view == systemUpdateView->GetUpdateNowButtton()) // 如果点击的是立即更新按钮 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetUpdateNowButtton"); + } + else if (&view == systemUpdateView->GetTryAgainLaterButton()) // 如果点击的是稍后再说按钮 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetTryAgainLaterButton"); + NativeAbility::GetInstance().Back(); + } + + return true; + } + + bool SystemUpdatePresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemUpdatePresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + SystemUpdatePresenter::X_DRAG_FLAG = true; + } + return true; + } + + bool SystemUpdatePresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemUpdatePresenter::OnDragEnd"); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && SystemUpdatePresenter::X_DRAG_FLAG) + { + NativeAbility::GetInstance().Back(); + } + return true; + } + + bool SystemUpdatePresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemUpdatePresenter::OnKeyAct"); + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/systemupdate/src/SystemUpdateView.cpp b/code/sdk/application/wearable/fd230app/nativeui/systemupdate/src/SystemUpdateView.cpp new file mode 100644 index 000000000..638f51a22 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/systemupdate/src/SystemUpdateView.cpp @@ -0,0 +1,320 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-05-07 11:25:58 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-05-07 17:15:10 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/systemupdate/src/SystemUpdateView.cpp + */ + +#include "systemupdate/include/SystemUpdatePresenter.h" +#include "systemupdate/include/SystemUpdateView.h" +#include "wearable_log.h" +#include "language/font/ui_resource_string.h" +#include "config/include/ConfigModel.h" +#include "systemupdate/include/SystemUpdateModel.h" + +namespace OHOS +{ + + static SystemUpdateView *g_pSystemUpdateView{nullptr}; + + SystemUpdateView::SystemUpdateView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::SystemUpdateView"); + g_pSystemUpdateView = this; + } + + SystemUpdateView::~SystemUpdateView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::~SystemUpdateView"); + ClearAll(); + g_pSystemUpdateView = nullptr; + } + + SystemUpdateView *SystemUpdateView::GetInstance() + { + return g_pSystemUpdateView; + } + + void SystemUpdateView::ClearAll(void) + { + if (SystemUpdateScrollView != nullptr) + { + SystemUpdateScrollView->RemoveAll(); + + delete Title; + Title = nullptr; + + delete KUMILOGOImage; + KUMILOGOImage = nullptr; + + delete LatestVersionLabel; + LatestVersionLabel = nullptr; + + delete VersionIdLabel; + VersionIdLabel = nullptr; + + delete UpdateNowLabel; + UpdateNowLabel = nullptr; + + delete TryAgainLaterLabel; + TryAgainLaterLabel = nullptr; + + delete UpdateNowButtton; + UpdateNowButtton = nullptr; + + delete TryAgainLaterButton; + TryAgainLaterButton = nullptr; + + delete SystemUpdateScrollView; + SystemUpdateScrollView = nullptr; + } + } + + UILabelExt *SystemUpdateView::InitLabel_Ext(LabelConfig &labelConfig) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelConfig.left, labelConfig.top, labelConfig.width, labelConfig.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, labelConfig.lineHeigh); // 字体行高 + label->SetTextId(labelConfig.textId); + label->SetLineBreakMode(labelConfig.lineBreakMode); // 断行模式。 + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize); + return label; + } + + bool SystemUpdateView::SetSystemUpdateScrollView(void) + { + SystemUpdateScrollView = new UIScrollView(); + if (SystemUpdateScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemUpdateScrollView new fail!"); + return false; + } + SystemUpdateScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + SystemUpdateScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SystemUpdateScrollView->SetStyle(STYLE_BORDER_RADIUS, 1294); + SystemUpdateScrollView->SetScrollBlankSize(35); + SystemUpdateScrollView->SetReboundSize(50); + SystemUpdateScrollView->SetDirection(1); + UIView::OnDragListener *draglistener = static_cast(SystemUpdatePresenter::GetInstance()); + if (draglistener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::draglistener can not be nullptr!"); + return false; + } + SystemUpdateScrollView->SetOnDragListener(draglistener); + SystemUpdateScrollView->SetTouchable(true); + SystemUpdateScrollView->SetDraggable(true); + + return true; + } + + void SystemUpdateView::SystemUpdateViewInit(void) + { + if (!SetSystemUpdateScrollView()) + { + return; + } + /* ---------------------------------- Title --------------------------------- */ + LabelConfig Config = { + .left = 83, + .top = 52, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + //.text = "系统", + .textId = STR_SYSTEM, + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + Title = InitLabel_Ext(Config); + if (Title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::Title new fail!"); + return; + } + /* ------------------------------ KUMILOGOImage ----------------------------- */ + KUMILOGOImage = new UIImageView(); + if (KUMILOGOImage == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::KUMILOGOImage new fail!"); + return; + } + KUMILOGOImage->SetPosition(117, 87, 230, 160); + const char *imagesPath = "/user/res/system/KUMILOGO.bin"; + KUMILOGOImage->SetSrc(imagesPath); + /* --------------------------- LatestVersionLabel --------------------------- */ + Config = { + .left = 33, + .top = 227, + .width = 400, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + //.text = "最新版本", + .textId = STR_LATEST_VERSION, + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + LatestVersionLabel = InitLabel_Ext(Config); + if (LatestVersionLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::LatestVersionLabel new fail!"); + return; + } + /* ----------------------------- VersionIdLabel ----------------------------- */ + VersionIdLabel = new UILabelExt(); + if (VersionIdLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::VersionIdLabel new fail!"); + return; + } + VersionIdLabel->SetPosition(33, 262, 400, 35); + VersionIdLabel->SetStyle(STYLE_TEXT_FONT, 30); + VersionIdLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + VersionIdLabel->SetText("OTA V4.0.0"); + VersionIdLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + VersionIdLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + VersionIdLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ----------------------------- UpdateNowLabel ----------------------------- */ + Config = { + .left = 113, + .top = 350, + .width = 240, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_LATEST_VERSION, + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + UpdateNowLabel = InitLabel_Ext(Config); + if (UpdateNowLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::UpdateNowLabel new fail!"); + return; + } + /* -------------------------------------------------------------------------- */ + Config = { + .left = 113, + .top = 477, + .width = 240, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_LATER, + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + TryAgainLaterLabel = InitLabel_Ext(Config); + if (TryAgainLaterLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::TryAgainLaterLabel new fail!"); + return; + } + /* ---------------------------- UpdateNowButtton ---------------------------- */ + UpdateNowButtton = new UIButton(); + if (UpdateNowButtton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::UpdateNowButtton new fail!"); + return; + } + UpdateNowButtton->SetPosition(63, 317, 340, 100); + UpdateNowButtton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); + UpdateNowButtton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + /* --------------------------- TryAgainLaterButton -------------------------- */ + TryAgainLaterButton = new UIButton(); + if (TryAgainLaterButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::TryAgainLaterButton new fail!"); + return; + } + TryAgainLaterButton->SetPosition(63, 427, 340, 100); + TryAgainLaterButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + TryAgainLaterButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + /* ----------------------------- OnClickListener ---------------------------- */ + UIView::OnClickListener *listener = static_cast(SystemUpdatePresenter::GetInstance()); + if (listener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemUpdateView::listener can not be nullptr!"); + return; + } + UpdateNowButtton->SetOnClickListener(listener); + TryAgainLaterButton->SetOnClickListener(listener); + + /* ----------------------------------- Add ---------------------------------- */ + SystemUpdateScrollView->Add(Title); + SystemUpdateScrollView->Add(KUMILOGOImage); + SystemUpdateScrollView->Add(LatestVersionLabel); + SystemUpdateScrollView->Add(VersionIdLabel); + SystemUpdateScrollView->Add(UpdateNowLabel); + SystemUpdateScrollView->Add(TryAgainLaterLabel); + SystemUpdateScrollView->Add(UpdateNowButtton); + SystemUpdateScrollView->Add(TryAgainLaterButton); + RootView::GetInstance()->Add(SystemUpdateScrollView); + } + + void SystemUpdateView::OnStart() + { + View::OnStart(); + + if (SystemUpdateModel::GetInstance().IsLatestVersion() == true) //如果是最新版本显示不需要更新界面 + { + + } + else + { + // 如果需要系统更新 + SystemUpdateViewInit(); + } + + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::SystemUpdatePresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); + } + + void SystemUpdateView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void SystemUpdateView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void SystemUpdateView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + RootView::GetInstance()->ClearOnKeyActListener(); + return; + } + + UIButton *SystemUpdateView::GetUpdateNowButtton(void) + { + if (UpdateNowButtton != nullptr) + { + return UpdateNowButtton; + } + return nullptr; + } + + UIButton *SystemUpdateView::GetTryAgainLaterButton(void) + { + if (TryAgainLaterButton != nullptr) + { + return TryAgainLaterButton; + } + return nullptr; + } +} \ No newline at end of file