From 200445a479204c771ae46d18fe553bd4dfd19163 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 29 Aug 2024 17:56:58 +0800 Subject: [PATCH] =?utf8?q?=E6=B5=B7=E6=80=9D=E5=8E=9F=E6=9C=AC=E5=85=B3?= =?utf8?q?=E6=9C=BA=E5=92=8C=E9=87=8D=E5=90=AF=E7=95=8C=E9=9D=A2=E5=88=A0?= =?utf8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 7 - .../nativelauncher/include/AppViewIDs.h | 3 +- .../nativelauncher/src/NativeLauncher.cpp | 16 - .../nativeui/key/src/KeyInputListener.cpp | 1 - .../rebootdevice/include/RebootDeviceView.h | 32 -- .../rebootdevice/include/RebootModel.h | 44 -- .../rebootdevice/include/RebootPresenter.h | 68 --- .../rebootdevice/include/RebootView.h | 67 --- .../include/ShutDownAnimatorView.h | 38 -- .../rebootdevice/include/ShutdownDeviceView.h | 30 - .../rebootdevice/src/RebootDeviceView.cpp | 115 ---- .../nativeui/rebootdevice/src/RebootModel.cpp | 326 ----------- .../rebootdevice/src/RebootPresenter.cpp | 164 ------ .../nativeui/rebootdevice/src/RebootView.cpp | 520 ------------------ .../rebootdevice/src/ShutDownAnimatorView.cpp | 131 ----- .../rebootdevice/src/ShutdownDeviceView.cpp | 118 ---- .../settings/src/SettingPresenter.cpp | 3 +- 17 files changed, 2 insertions(+), 1681 deletions(-) delete mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootDeviceView.h delete mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootModel.h delete mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootPresenter.h delete mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootView.h delete mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/ShutDownAnimatorView.h delete mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/ShutdownDeviceView.h delete mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootDeviceView.cpp delete mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp delete mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootPresenter.cpp delete mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootView.cpp delete mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutDownAnimatorView.cpp delete mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutdownDeviceView.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 91746ab4d..c6f79f888 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -19,7 +19,6 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodoxygen/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetooth/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/indoorwalk/include - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rebootdevice/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/activity/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heartrate/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/callerlog/include @@ -232,12 +231,6 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/connectnewphone/src/ConnectSelectView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/connectnewphone/src/ConnectOpenView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/connectnewphone/src/ConnectPhonePresenter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rebootdevice/src/RebootView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rebootdevice/src/RebootPresenter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rebootdevice/src/RebootModel.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rebootdevice/src/RebootDeviceView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rebootdevice/src/ShutdownDeviceView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rebootdevice/src/ShutDownAnimatorView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/callerlog/src/CallerLogView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/callerlog/src/CallerLogPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/callerlog/src/CallerLogModel.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index 3f7710b22..8ba8419dc 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -64,8 +64,7 @@ typedef enum : uint16_t VIEW_THEME_STYLE, // 主题样式 VIEW_AI_VOICE, // AI Voice(人工智能语音) VIEW_AI_MODELS, // AI模型选择界面 - VIEW_SHUTDOWN_OR_REBOOT, // 关机或重启界面 - VIEW_REBOOTANDSHUTDOWN, //(滑动关机和重启带恢复出厂设置) + VIEW_REBOOTANDSHUTDOWN, //(关机或重启界面) VIEW_RECORD, VIEW_MUSIC_PLAYER, // 音乐播放器 /* -------------------------------------------------------------------------- */ diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index f88f405fa..27ce088dc 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -55,8 +55,6 @@ #include "TempPresenter.h" #include "IndoorWalkPresenter.h" #include "IndoorWalkView.h" -#include "rebootdevice/include/RebootView.h" -#include "rebootdevice/include/RebootPresenter.h" #include "UISampleView.h" #include "UISamplePresenter.h" @@ -312,7 +310,6 @@ namespace OHOS {VIEW_COMPASS, &NativeLauncher::InitCompassSlice}, {VIEW_CONNECT_PHONE, &NativeLauncher::InitConnectPhoneSlice}, {VIEW_INDOORWALK, &NativeLauncher::InitIndoorWalkSlice}, - {VIEW_SHUTDOWN_OR_REBOOT, &NativeLauncher::InitRebootSlice}, {VIEW_WEATHER, &NativeLauncher::InitWeatherSlice}, // 天气 {VIEW_GOAL, &NativeLauncher::InitGoalSlice}, // 每日目标 {VIEW_SYSTEM, &NativeLauncher::InitSystemSlice}, // 系统实例化地址 @@ -443,7 +440,6 @@ namespace OHOS {VIEW_CONNECT_PHONE, "ConnectPhoneView"}, //{VIEW_PHONE, "phoneview"}, {VIEW_INDOORWALK, "IndoorWalkView"}, - // {VIEW_SHUTDOWN_OR_REBOOT, "RebootView"}, {VIEW_TEST, "testView"}}; NativeLauncher::NativeLauncher() {} @@ -597,18 +593,6 @@ namespace OHOS NativeAbility::GetInstance().AddSliceProxy(VIEW_INDOORWALK, indoorWalkView); } - void NativeLauncher::InitRebootSlice(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::RebootView"); - SliceProxy *rebootView = new AbilitySliceProxy; - if (rebootView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootView is nullptr"); - return; - } - NativeAbility::GetInstance().AddSliceProxy(VIEW_SHUTDOWN_OR_REBOOT, rebootView); - } - void NativeLauncher::InitConnectPhoneSlice(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::ConnectPhoneView"); diff --git a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp index 2ab687bc1..555e280f4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp @@ -64,7 +64,6 @@ namespace OHOS if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { // 电源按键 // 切换到关机/重启卡片 - // NativeAbility::GetInstance().ChangeSlice(VIEW_SHUTDOWN_OR_REBOOT); } else if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_FUNC)) { // 功能按键 diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootDeviceView.h b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootDeviceView.h deleted file mode 100644 index dffd6fdc3..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootDeviceView.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * @Author: luozheng 1732036298@qq.com - * @Date: 2024-01-29 15:37:44 - * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-03-20 10:52:37 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootDeviceView.h - */ -#ifndef REBOOTDEVICE_VIEW_H -#define REBOOTDEVICE_VIEW_H - -#include "View.h" -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_ext.h" -#include "components/ui_button.h" - -namespace OHOS { -class RebootDeviceView { -public: - RebootDeviceView(); - ~RebootDeviceView(); - static RebootDeviceView *GetInstance(); - UIViewGroup *InitShowUpView(void); - -private: - bool ShowUpRebootDeviceView(void); - UILabel *rebootDeviceLabel{nullptr}; //重启标签 - UIButton *rebootDeviceButton{nullptr}; //重启按钮 - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // REBOOTDEVICE_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootModel.h b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootModel.h deleted file mode 100644 index 7f6f5331c..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootModel.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * @Author: luozheng 1732036298@qq.com - * @Date: 2024-06-12 11:44:04 - * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-12 10:23:32 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootModel.h - * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%A - */ - -#ifndef REBOOT_MODEL_H -#define REBOOT_MODEL_H - -#include "BaseView.h" - -namespace OHOS { -enum RebootModelView : uint8_t { - REBOOT, - REBOOTDEVICE, - SHUTDOWNDEVICE, -}; - - -class RebootModel { -public: - ~RebootModel(); - static RebootModel *GetInstance(void); - int16_t GetSelectView(void); - void SetSelectViewId(int16_t value); - bool GetExitsView(void); - void SetExitsView(bool value); - bool RegisterPowerKeyLongPressEvent(void); - bool RegisterPowerKeyDoubleClickEvent(void); - bool RegisterFuncKeyPressEvent(void); - bool RegisterFuncKeyLongPressEvent(void); - bool RegisterFuncKeyClickEvent(void); - bool RegisterFuncKeyDoubleClickEvent(void); - void RegisterAllKeyEvents(void); -private: - RebootModel(); - int16_t selectView{0}; - bool exitsView{false}; -}; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootPresenter.h deleted file mode 100644 index 5dc40d364..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootPresenter.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * @Author: luozheng 1732036298@qq.com - * @Date: 2024-01-29 15:37:44 - * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-03-21 09:48:06 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootPresenter.h - * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE - */ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Reboot Presenter - * Create: 2022-04-28 - */ - -#ifndef REBOOT_PRESENTER_H -#define REBOOT_PRESENTER_H - -#include "Presenter.h" -#include "NativeLauncher.h" -#include "NativeAbility.h" -#include "BaseView.h" -#include "components/ui_image_animator.h" -#include "KeyInputListener.h" -namespace OHOS -{ - enum RebootPresenterNum : uint8_t - { - REBOOTVIEW = 0, - REBOOTDEVICEVIEW, - SHUTDOWNDEVICEVIEW, - SHUTDOWNANIMATORVIEW, // 关机动画视图 - REBOOT_MAX, - }; - -#define REBOOT_BUTTON "rebootButton" -#define SHUTDOWN_BUTTON "shutdownButton" -#define REBOOTDEVICE_BUTTON "rebootDeviceButton" -#define SHUTDOWNDEVICE_BUTTON "shutdownDeviceButton" - -#define REBOOT_VIEW "rebootView" -#define REBOOTDEVICE_VIEW "rebootDeviceView" -#define SHUTDOWNDEVICE_VIEW "shutdownDeviceView" - - class RebootView; - class RebootPresenter : public Presenter, - public UIView::OnClickListener, - public UIImageAnimatorView::AnimatorStopListener, - public RootView::OnKeyActListener, - public UIView::OnDragListener - { - public: - RebootPresenter(); - ~RebootPresenter(); - static RebootPresenter *GetInstance(); - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - virtual void OnAnimatorStop(UIView &view) override; - bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 - - private: - bool isShutDownOperation{false}; // 是否是关机操作 - }; -} // namespace OHOS -#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootView.h b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootView.h deleted file mode 100644 index c8ce0f42c..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootView.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * @Author: luozheng 1732036298@qq.com - * @Date: 2024-01-29 15:37:44 - * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-03-20 20:01:01 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootView.h - */ - -#ifndef REBOOT_VIEW_H -#define REBOOT_VIEW_H - -#include "View.h" -#include "ShutdownDeviceView.h" -#include "RebootDeviceView.h" -#include "rebootdevice/include/ShutDownAnimatorView.h" -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_ext.h" -#include "components/ui_button.h" -#include "components/ui_image_animator.h" -#include "ConfigModel.h" -#include "rebootandshutdown/include/FactoryResetView.h" -namespace OHOS { -constexpr int16_t NUM_REBOOT_CONTAINER = 4; - -class RebootPresenter; -class RebootView : public View { -public: - RebootView(); - ~RebootView(); - static RebootView *GetInstance(); - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - UIViewGroup *InitShowUpView(void); - void ChangeView(int16_t hideView, int16_t showView); - void FactoryResetGroupVisible(bool data); - -private: - bool ChangeRebootView(int16_t hideView, int16_t thisView); - bool ChangeRebootDeviceView(int16_t hideView, int16_t thisView); - bool ChangeShutdownDeviceView(int16_t hideView, int16_t thisView); - bool ChangeShutDownAnimatorView(int16_t hideView, int16_t thisView); - bool CheckViewParam(int16_t hideView, int16_t showView); - bool ShowUpRebootView(void); - bool ShowUpShutdownView(void); - bool factoryResetLabelInit(void); - bool factoryResetViewInit(void); - UILabelExt *rebootLabel{nullptr}; - UIButton *rebootButton{nullptr}; - UILabelExt *shutdownLabel{nullptr}; - UILabelExt *factoryResetLabel{nullptr}; - - UIButton *shutdownButton{nullptr}; - FactoryResetView *factoryResetView{nullptr}; - UIViewGroup *group{nullptr}; - RebootDeviceView *rebootDeviceView{nullptr}; - ShutdownDeviceView *shutdownDeviceView{nullptr}; - ShutDownAnimatorView*shutDownAnimatorView{nullptr}; - UIViewGroup *container[NUM_REBOOT_CONTAINER]{nullptr}; - UIViewGroup *FactoryResetGroup{nullptr}; - typedef bool (RebootView::*PreprosssChangeView)(int16_t hideView, int16_t thisView); - PreprosssChangeView preProcessView[NUM_REBOOT_CONTAINER]; -}; -} // namespace OHOS -#endif // REBOOT_VIEW_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/ShutDownAnimatorView.h b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/ShutDownAnimatorView.h deleted file mode 100644 index 3db74e6f9..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/ShutDownAnimatorView.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * @Author: luozheng 1732036298@qq.com - * @Date: 2024-03-20 16:37:13 - * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-20 11:34:59 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/ShutDownAnimatorView.h - */ - -#ifndef SHUTDOWN_ANIMATOR_VIEW_H -#define SHUTDOWN_ANIMATOR_VIEW_H - -#include "components/ui_view_group.h" -#include "components/ui_image_animator.h" - -namespace OHOS -{ - - class ShutDownAnimatorView - { - public: - ShutDownAnimatorView(); - ~ShutDownAnimatorView(); - static ShutDownAnimatorView *GetInstance(); - UIViewGroup *ShutDownAnimatorViewInit(void); - UIImageAnimatorView *GeShutDownImageAnimatorView(void); - - private: - void ClearAll(void); - bool ShowUpShutDownAnimatorView(); - const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages); - void FreeImagePathsArray(const char **imagePaths, const int numImages); - UIViewGroup *group{nullptr}; - UIImageAnimatorView *ShutDownImageAnimatorView{nullptr}; // 关机动画 - ImageAnimatorInfo ShutDownImageInfo[30]; // 关机图像的信息 - const char **ShutDownPathsArray{nullptr}; // 关机图片路径数组 - }; -} -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/ShutdownDeviceView.h b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/ShutdownDeviceView.h deleted file mode 100644 index 8fb6a2eaa..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/ShutdownDeviceView.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: ShutdownDevice View - * Create: 2022-04-28 - */ -#ifndef SHUTDOWNDEVICE_VIEW_H -#define SHUTDOWNDEVICE_VIEW_H - -#include "View.h" -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_ext.h" -#include "components/ui_button.h" - -namespace OHOS { -class ShutdownDeviceView { -public: - ShutdownDeviceView(); - ~ShutdownDeviceView(); - static ShutdownDeviceView *GetInstance(); - UIViewGroup *InitShowUpView(void); - -private: - bool ShowUpShutdownDeviceView(void); - UILabelExt *shutdownDeviceLabel{nullptr}; //关机标签 - UIButton *shutdownDeviceButton{nullptr}; //关机按钮 - UIViewGroup *group{nullptr}; -}; -} // namespace OHOS -#endif // SHUTDOWNDEVICE_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootDeviceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootDeviceView.cpp deleted file mode 100644 index 9e0be6819..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootDeviceView.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: RebootDevice View - * Create: 2022-04-28 - */ - -#include "rebootdevice/include/RebootDeviceView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "RebootPresenter.h" - -namespace OHOS { -static RebootDeviceView *g_pRebootDeviceView{nullptr}; -RebootDeviceView::RebootDeviceView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootDeviceView::RebootDeviceView"); - g_pRebootDeviceView = this; -} - -RebootDeviceView::~RebootDeviceView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootDeviceView::~RebootDeviceView"); - if (group != nullptr) { - group->RemoveAll(); - } - delete rebootDeviceLabel; - rebootDeviceLabel = nullptr; - delete rebootDeviceButton; - rebootDeviceButton = nullptr; - delete group; - group = nullptr; - g_pRebootDeviceView = nullptr; -} - -RebootDeviceView *RebootDeviceView::GetInstance() -{ - return g_pRebootDeviceView; -} - -/* - * @brief 显示重启设备视图 -*/ -bool RebootDeviceView::ShowUpRebootDeviceView() -{ - if (rebootDeviceLabel == nullptr) { - rebootDeviceLabel = new UILabel(); - if (rebootDeviceLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpRebootDeviceView rebootDeviceLabel new fail"); - return false; - } - } - rebootDeviceLabel->SetPosition(152, 272, 150, 45); // 152:x 272:y 150:width 45:height - rebootDeviceLabel->SetText("SOS"); - rebootDeviceLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35:font data - rebootDeviceLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - rebootDeviceLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - - if (rebootDeviceButton == nullptr) { - rebootDeviceButton = new UIButton(); - if (rebootDeviceButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpRebootDeviceView rebootDeviceButton new fail"); - return false; - } - } - rebootDeviceButton->SetPosition(172, 147, 100, 100); // 172:x 147:y 110:width 110:height - rebootDeviceButton->SetImageSrc(PNG_SETTINGS_SETTTING_SOS, PNG_SETTINGS_SETTTING_SOS); - rebootDeviceButton->SetImagePosition(0, 0); - rebootDeviceButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); - rebootDeviceButton->SetViewId(REBOOTDEVICE_BUTTON); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance nullptr"); - return false; - } - rebootDeviceButton->SetOnClickListener(clickListener); - return true; -} - -/* - * @brief 初始化重启视图 -*/ -UIViewGroup *RebootDeviceView::InitShowUpView(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootDeviceView::InitShowUpView"); - bool ret; - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); // 0:x; 0:y - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - ret = ShowUpRebootDeviceView(); - if (!ret) { - return nullptr; - } - group->Add(rebootDeviceLabel); - group->Add(rebootDeviceButton); - - UIView::OnDragListener *rebootDeviceDragListener = (UIView::OnDragListener *)OHOS::RebootPresenter::GetInstance(); - if (rebootDeviceDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootDeviceDragListener GetInstance fail"); - return nullptr; - } - group->SetOnDragListener(rebootDeviceDragListener); - group->SetViewId(REBOOTDEVICE_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp deleted file mode 100644 index 143fe0232..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp +++ /dev/null @@ -1,326 +0,0 @@ -/* - * @Author: luozheng 1732036298@qq.com - * @Date: 2024-03-28 11:50:42 - * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-19 17:21:38 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp - */ - -#include "rebootdevice/include/RebootModel.h" -#include "wearable_log.h" -#include "NativeAbility.h" -#include "errcode.h" -#include -#include -#include "power_display_service.h" -#include "aimodels/include/AiModelsModel.h" -#include "themestyle/include/ThemeStyleModel.h" -#include "ui_service.h" -extern "C" uint8_t uapi_dev_runtime_get_lock_status(void); -namespace OHOS -{ - RebootModel::RebootModel() {} - - RebootModel::~RebootModel() {} - - RebootModel *RebootModel::GetInstance(void) - { - static RebootModel instance; - return &instance; - } - - int16_t RebootModel::GetSelectView(void) - { - return selectView; - } - - void RebootModel::SetSelectViewId(int16_t value) - { - selectView = value; - } - - bool RebootModel::GetExitsView(void) - { - return exitsView; - } - - void RebootModel::SetExitsView(bool value) - { - exitsView = value; - } - -#ifdef __cplusplus - extern "C" - { -#endif - -#include "input_app.h" -#ifdef __cplusplus - } -#endif - - static void HandlePowerKeyLongPress(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandlePowerKeyLongPress"); - const power_display_svr_api_t *display_api = power_display_svr_get_api(); - if (!display_api) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr"); - return; - } - - if (display_api->get_screen_state() != SCREEN_ON) - { - display_api->turn_on_screen(); - } - - // 切换到关机/重启卡片 - NativeAbility::GetInstance().EnterSlice(VIEW_SHUTDOWN_OR_REBOOT); - } - - /*注册电源键的长按事件*/ - bool RebootModel::RegisterPowerKeyLongPressEvent(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootModel::RegisterPowerKeyLongPressEvent"); - int32_t ret = uapi_button_register_event_cb(HandlePowerKeyLongPress, BUTTON_PWR_LONGPRESS_3S); - if (ret != ERRCODE_SUCC) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register PowerKey LongPress Event error, ret = %d", ret); - return false; - } - return true; - } - - static void HandlePowerKeyDoubleClick(void) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandlePowerKeyDoubleClick"); - // Handle PowerKey DoubleClick logic here - const power_display_svr_api_t *display_api = power_display_svr_get_api(); - if (!display_api) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr"); - return; - } - - if (display_api->get_screen_state() == SCREEN_ON) - { - uint16_t cursliceId = NativeAbility::GetInstance().GetCurSliceId(); - if (cursliceId == VIEW_APPLIST) - { - ThemeStyleModel &themeStyleModel = ThemeStyleModel::GetInstance(); - ThemeStyle style = themeStyleModel.GetAppListDisplayStyle(); - themeStyleModel.SetPreApplistStyle(style); - themeStyleModel.SetTheSameSliceChangeFlag(true); - themeStyleModel.SwitchApplistStyleOnPowerClick(); // 切换样式 - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - } - } - else - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Screen is not on, skipping applist style change"); - } - } - - /*注册电源键的双击事件*/ - bool RebootModel::RegisterPowerKeyDoubleClickEvent(void) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootModel::RegisterPowerKeyDoubleClickEvent"); - // Register PowerKey DoubleClick event here - int32_t ret = uapi_button_register_event_cb(HandlePowerKeyDoubleClick, BUTTON_PWR_CLICKUP_2); - if (ret != ERRCODE_SUCC) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register PowerKey DoubleClick Event error, ret = %d", ret); - return false; - } - return true; - } - - static void HandFuncKeyOnPress(void) - { - const power_display_svr_api_t *display_api = power_display_svr_get_api(); - if (!display_api) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr"); - return; - } - if (display_api->get_screen_state() == SCREEN_OFF) /*处于灭屏状态才亮屏*/ - { - display_api->turn_on_screen(); - } - else - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Screen is on not to turn_on_screen"); - } - return; - } - - /*注册功能键的按下事件*/ - bool RebootModel::RegisterFuncKeyPressEvent(void) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootModel::RegisterFuncKeyPressEvent"); - // Register FuncKey Press event here - int32_t ret = uapi_button_register_event_cb(HandFuncKeyOnPress, BUTTON1_PRESS); - if (ret != ERRCODE_SUCC) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register FuncKey Press Event error, ret = %d", ret); - return false; - } - return true; - } - - static void HandFuncKeyOnLongPress(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandFuncKeyOnLongPress"); - const power_display_svr_api_t *display_api = power_display_svr_get_api(); - if (!display_api) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr"); - return; - } - - if (display_api->get_screen_state() == SCREEN_ON) - { - uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId(); - /*处于主界面 或者密码锁界面*/ - if (curSliceId == VIEW_MAIN || curSliceId == VIEW_CODED_LOCK) - { - /*被锁*/ - if (uapi_dev_runtime_get_lock_status()) - { - NativeAbility::GetInstance().EnterSlice(VIEW_CODED_LOCK); - return; - } - } - - if (curSliceId == VIEW_AI_VOICE) // 如果当前已在ai语音界面不做切换 - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VIEW_AI_VOICE is not switched"); - return; - } - // 全局切换到Ai语音界面 - NativeAbility::GetInstance().EnterSlice(VIEW_AI_VOICE); - } - else - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Screen is not on, skipping AI voice change"); - } - } - - /*注册功能键的长按(2s)事件*/ - bool RebootModel::RegisterFuncKeyLongPressEvent(void) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootModel::RegisterFuncKeyLongPressEvent"); - int32_t ret = uapi_button_register_event_cb(HandFuncKeyOnLongPress, BUTTON1_LONGPRESS_2S); - if (ret != ERRCODE_SUCC) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register FuncKey LongPress Event error, ret = %d", ret); - return false; - } - return true; - } - - static void HandleFuncKeyOnClick(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandleFuncKeyOnClick"); - - const power_display_svr_api_t *display_api = power_display_svr_get_api(); - if (!display_api) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr"); - return; - } - - if (display_api->get_screen_state() == SCREEN_ON) - { - uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId(); - /*处于主界面 或者密码锁界面*/ - if (curSliceId == VIEW_MAIN || curSliceId == VIEW_CODED_LOCK) - { - /*被锁*/ - if (uapi_dev_runtime_get_lock_status()) - { - NativeAbility::GetInstance().EnterSlice(VIEW_CODED_LOCK); - return; - } - } - - AiModelsModel &aiModelsModel = AiModelsModel::GetInstance(); - if (!aiModelsModel.ChangeAiModel()) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to change AI model"); - } - } - else - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Screen is not on, skipping AI model change"); - } - } - - /*注册功能键的单击事件*/ - bool RebootModel::RegisterFuncKeyClickEvent(void) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootModel::RegisterFuncKeyClickEvent"); - int32_t ret = uapi_button_register_event_cb(HandleFuncKeyOnClick, BUTTON1_CLICKUP); - if (ret != ERRCODE_SUCC) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register FuncKey Click Event error, ret = %d", ret); - return false; - } - return true; - } - - static void HandleFuncKeyDoubleClick(void) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleFuncKeyDoubleClick"); - const power_display_svr_api_t *display_api = power_display_svr_get_api(); - if (!display_api) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr"); - return; - } - if (display_api->get_screen_state() == SCREEN_ON) - { - uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId(); - /*处于主界面 或者密码锁界面*/ - if (curSliceId == VIEW_MAIN || curSliceId == VIEW_CODED_LOCK) - { - /*被锁*/ - if (uapi_dev_runtime_get_lock_status()) - { - NativeAbility::GetInstance().EnterSlice(VIEW_CODED_LOCK); - return; - } - } - - // 切换到显示方式界面 - NativeAbility::GetInstance().EnterSlice(VIEW_AI_MODELS); - } - else - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Screen is not on, skipping Slice change"); - } - } - - /*注册功能键双击事件*/ - bool RebootModel::RegisterFuncKeyDoubleClickEvent(void) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootModel::RegisterFuncKeyDoubleClickEvent"); - int32_t ret = uapi_button_register_event_cb(HandleFuncKeyDoubleClick, BUTTON1_CLICKUP_2); - if (ret != ERRCODE_SUCC) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register FuncKey DoubleClick Event error, ret = %d", ret); - return false; - } - return true; - } - - void RebootModel::RegisterAllKeyEvents(void) - { - RegisterPowerKeyDoubleClickEvent(); - RegisterPowerKeyLongPressEvent(); - RegisterFuncKeyPressEvent(); - RegisterFuncKeyLongPressEvent(); - RegisterFuncKeyClickEvent(); - RegisterFuncKeyDoubleClickEvent(); - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootPresenter.cpp deleted file mode 100644 index 8ecbdc09b..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootPresenter.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * @Author: luozheng 1732036298@qq.com - * @Date: 2024-02-21 19:06:02 - * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-25 09:21:08 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootPresenter.cpp - */ -#include "rebootdevice/include/RebootPresenter.h" -#include "rebootdevice/include/RebootView.h" -#include "rebootdevice/include/RebootModel.h" -#include "drag_event.h" -#include "wearable_log.h" -#include "custom_utils.h" -#include "components/ui_image_animator.h" -#include "common/key_code.h" -#include "dial_sos_c.h" -//#include "rebootandshutdown/include/FactoryResetVIew.h" - -namespace OHOS -{ - static RebootPresenter *g_pRebootPresenter = nullptr; - - RebootPresenter::RebootPresenter() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter::RebootPresenter"); - g_pRebootPresenter = this; - } - - RebootPresenter::~RebootPresenter() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter::~RebootPresenter"); - g_pRebootPresenter = nullptr; - } - - RebootPresenter *RebootPresenter::GetInstance() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter GetInstance"); - return g_pRebootPresenter; - } - - void RebootPresenter::OnStart() - { - Presenter::OnStart(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter::On Start "); - uapi_setScreenDuration(10 * 1000); - } - - void RebootPresenter::OnPause(void) {} - - void RebootPresenter::OnResume(void) {} - - void RebootPresenter::OnStop(void) {} - - bool RebootPresenter::OnClick(UIView &view, const ClickEvent &event) - { - UNUSED(event); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnClick OnClick"); - if (strcmp(view.GetViewId(), REBOOT_BUTTON) == 0) - { - RebootView::GetInstance()->ChangeView(REBOOTVIEW, REBOOTDEVICEVIEW); - } - else if (strcmp(view.GetViewId(), SHUTDOWN_BUTTON) == 0) - { - RebootView::GetInstance()->ChangeView(REBOOTVIEW, SHUTDOWNDEVICEVIEW); - } - else if (strcmp(view.GetViewId(), REBOOTDEVICE_BUTTON) == 0) - { - // 重启 - // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "REBOOTDEVICE_BUTTON OnClick"); - // RebootView::GetInstance()->ChangeView(REBOOTDEVICEVIEW, SHUTDOWNANIMATORVIEW); - // start_shutdown_or_reboot(); - // shutdown_reboot_prejobs(); - - // ShutDownAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start(); - // isShutDownOperation = false; - start_SOS_phone_dail(); - } - else if (strcmp(view.GetViewId(), SHUTDOWNDEVICE_BUTTON) == 0) - { - // 关机 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SHUTDOWNDEVICE_BUTTON OnClick"); - // GetPMSDefaultInterface()->ShutDownDevice(NULL, NULL); - RebootView::GetInstance()->ChangeView(SHUTDOWNDEVICEVIEW, SHUTDOWNANIMATORVIEW); - start_shutdown_or_reboot(); - shutdown_reboot_prejobs(); - - ShutDownAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start(); - isShutDownOperation = true; - } - else if (strcmp(view.GetViewId(), "FACTORYRESET_LABEL_VIEWID") == 0) // 进入出厂设置界面 - { - // RebootAndShutdownView::GetInstance()->ChangeView(REBOOTANDSHUTDOWN, FACTORYRESET); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FACTORYRESET_LABEL_VIEWID"); - RebootView::GetInstance()-> FactoryResetGroupVisible(true); - return true; - } - else if (strcmp(view.GetViewId(), "FACTORY_RESET_BUTTON_CHECK_ON") == 0) // 恢复出厂设置确认 - { - do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_RESTORE_FACTORY_SETTING, NULL, 0); - return true; - } - else if (strcmp(view.GetViewId(), "FACTORY_RESET_BUTTON_CHECK_OFF") == 0) // 恢复出厂设置取消 - { - // RebootAndShutdownView::GetInstance()->ChangeView(FACTORYRESET, REBOOTANDSHUTDOWN); - RebootView::GetInstance()-> FactoryResetGroupVisible(false); - } - return true; - } - - bool RebootPresenter::OnDrag(UIView &view, const DragEvent &event) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootPresenter::OnDrag"); - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) - { - if (strcmp(view.GetViewId(), REBOOT_VIEW) == 0) - { - // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - // NativeAbility::GetInstance().ChangeSlice(preSlice); - NativeAbility::GetInstance().Back(); - } - else if (strcmp(view.GetViewId(), REBOOTDEVICE_VIEW) == 0) - { - RebootView::GetInstance()->ChangeView(REBOOTDEVICEVIEW, REBOOTVIEW); - } - else if (strcmp(view.GetViewId(), SHUTDOWNDEVICE_VIEW) == 0) - { - RebootView::GetInstance()->ChangeView(SHUTDOWNDEVICEVIEW, REBOOTVIEW); - } - else if (strcmp(view.GetViewId(), "FACTORY_RESET_GROUPVIEW") == 0) - RebootView::GetInstance()-> FactoryResetGroupVisible(false); - } - return true; - } - - void RebootPresenter::OnAnimatorStop(UIView &view) - { - UNUSED(view); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootPresenter::OnAnimatorStop"); - if (isShutDownOperation == true) - { - uapi_poweroff_device(); // 关机 - } - else - { - uapi_reboot_device(); // 重启 - } - } - - bool RebootPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 - { - UNUSED(view); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnKeyAct"); - uint16 keyID = event.GetKeyId(); - uint16 keyState = event.GetState(); - // 如果是power键,且是亮屏状态,按键释放就返回上一级 - if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) - { - // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - // NativeAbility::GetInstance().ChangeSlice(preSlice); - NativeAbility::GetInstance().Back(); - } - return true; - } -} diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootView.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootView.cpp deleted file mode 100644 index b44405b14..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootView.cpp +++ /dev/null @@ -1,520 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Reboot View - * Create: 2022-04-28 - */ - -#include "rebootdevice/include/RebootView.h" -#include "rebootdevice/include/RebootModel.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "RebootPresenter.h" -#include "ui_resource_string.h" - - -static constexpr int16_t BOOT_IMAGE_ANIMATOR_VIEW_X = 0; -static constexpr int16_t BOOT_IMAGE_ANIMATOR_VIEW_Y = 0; -static constexpr int16_t BOOT_IMAGE_ANIMATOR_VIEW_W = 466; -static constexpr int16_t BOOT_IMAGE_ANIMATOR_VIEW_H = 466; -static constexpr int16_t BOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 24; // 图片帧数 -static constexpr int16_t BOOT_IMAGE_ANIMATOR_TIME = 100; // 图片更新间隔 - -static constexpr char *BootPaths = ""; - -namespace OHOS -{ - static RebootView *g_pRebootView{nullptr}; - RebootView::RebootView() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::RebootView"); - preProcessView[REBOOTVIEW] = &RebootView::ChangeRebootView; - preProcessView[REBOOTDEVICEVIEW] = &RebootView::ChangeRebootDeviceView; - preProcessView[SHUTDOWNDEVICEVIEW] = &RebootView::ChangeShutdownDeviceView; - preProcessView[SHUTDOWNANIMATORVIEW] = &RebootView::ChangeShutDownAnimatorView; - g_pRebootView = this; - } - - RebootView::~RebootView() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~RebootView"); - if (group != nullptr) - { - group->RemoveAll(); - } - delete rebootLabel; - rebootLabel = nullptr; - delete rebootButton; - rebootButton = nullptr; - delete shutdownLabel; - shutdownLabel = nullptr; - delete shutdownButton; - shutdownButton = nullptr; - - if(factoryResetView) - { - delete factoryResetView; - factoryResetView = nullptr; - } - - if(FactoryResetGroup) - { - delete FactoryResetGroup; - FactoryResetGroup = nullptr; - } - - if(factoryResetLabel) - { - delete factoryResetLabel; - factoryResetLabel = nullptr; - } - - delete group; - group = nullptr; - g_pRebootView = nullptr; - } - - RebootView *RebootView::GetInstance() - { - return g_pRebootView; - } - - void RebootView::OnStart() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~OnStart"); - View::OnStart(); - BaseView::RootView(Color::Black().full); - // if (RebootModel::GetInstance()->GetSelectView() == REBOOT) - // { - // ChangeView(REBOOT_MAX, REBOOTVIEW); - // } - // else if (RebootModel::GetInstance()->GetSelectView() == REBOOTDEVICE) - // { - // ChangeView(REBOOT_MAX, REBOOTDEVICEVIEW); - // RebootModel::GetInstance()->SetSelectViewId(REBOOT); - // } - // else if (RebootModel::GetInstance()->GetSelectView() == SHUTDOWNDEVICE) - // { - // ChangeView(REBOOT_MAX, SHUTDOWNDEVICEVIEW); - // RebootModel::GetInstance()->SetSelectViewId(REBOOT); - // } - ChangeView(REBOOT_MAX, REBOOTVIEW); - RootView::GetInstance()->Invalidate(); - return; - } - - void RebootView::OnSetUpView() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~OnSetUpView"); - View::OnSetUpView(); - RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::RebootPresenter::GetInstance(); - RootView::GetInstance()->SetOnKeyActListener(keyactListener); - Draw(); - } - - void RebootView::OnTearDownView() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~OnTearDownView"); - View::OnTearDownView(); - return; - } - - void RebootView::OnStop() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::~OnStop"); - View::OnStop(); - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - RootView::GetInstance()->ClearOnKeyActListener(); - RootView::GetInstance()->RemoveAll(); - return; - } - //李代桃僵一手 不改函数名了,变为SOS - bool RebootView::ShowUpRebootView() - { - if (rebootLabel == nullptr) - { - rebootLabel = new UILabelExt(); - if (rebootLabel == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpRebootView rebootLabel new fail"); - return false; - } - } - rebootLabel->SetPosition(223, 272, 200, 45); // 49:x 272:y 150:width 45:height - rebootLabel->SetText("SOS"); - rebootLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - rebootLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35:font data - rebootLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - rebootLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - - if (rebootButton == nullptr) - { - rebootButton = new UIButton(); - if (rebootButton == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpRebootView rebootButton new fail"); - return false; - } - } - rebootButton->SetPosition(273, 160, 100, 100); // 69:x 147:y 110:width 110:height - rebootButton->SetImageSrc(PNG_SETTINGS_SETTTING_SOS, PNG_SETTINGS_SETTTING_SOS); - rebootButton->SetImagePosition(0, 0); - rebootButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); - rebootButton->SetViewId(REBOOT_BUTTON); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance(); - if (clickListener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance nullptr"); - return false; - } - rebootButton->SetOnClickListener(clickListener); - return true; - } - - bool RebootView::factoryResetLabelInit(void) - { - - factoryResetLabel = new UILabelExt(); - if (factoryResetLabel == nullptr) - { - return false; - } - factoryResetLabel->SetPosition(83, 370, 300,70); - factoryResetLabel->SetStyle(STYLE_TEXT_FONT, 30); - factoryResetLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - factoryResetLabel->SetTextId(STR_FACTORY_RESET); - factoryResetLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); - factoryResetLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - factoryResetLabel->SetRollSpeed(70); - factoryResetLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - factoryResetLabel->SetViewId("FACTORYRESET_LABEL_VIEWID"); - factoryResetLabel->SetTouchable(true); - factoryResetLabel->SetTextColor(Color::GetColorFromRGBA(0x35, 0x49, 0xff, 0xff)); - factoryResetLabel->SetVisible(true); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance(); - if (clickListener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance nullptr"); - return false; - } - factoryResetLabel->SetOnClickListener(clickListener); - if(factoryResetLabel) - return true; - else - return false; - } - - void RebootView::FactoryResetGroupVisible(bool data) - { - - FactoryResetGroup->SetVisible(data); - RootView::GetInstance()->Invalidate(); - - - } - - bool RebootView::factoryResetViewInit(void) - { - factoryResetView = new FactoryResetView(); - if (factoryResetView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "factoryResetView new fail"); - return false; - } - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance(); - if (clickListener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance nullptr"); - return false; - } - - UIView::OnDragListener *rebootDragListener = (UIView::OnDragListener *)OHOS::RebootPresenter::GetInstance(); - if (clickListener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance nullptr"); - return false; - } - - FactoryResetGroup = factoryResetView->FactoryResetViewInit(clickListener,rebootDragListener); - if(FactoryResetGroup) - { - return true; - } - else - { - return false; - } - - } - - bool RebootView::ShowUpShutdownView() - { - if (shutdownLabel == nullptr) - { - shutdownLabel = new UILabelExt(); - if (shutdownLabel == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpShutdownView shutdownLabel new fail"); - return false; - } - } - shutdownLabel->SetPosition(43, 272, 200, 45); // 255:x 272:y 150:width 45:height43 - shutdownLabel->SetText("关机"); - shutdownLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - shutdownLabel->SetTextId(STR_SHUTDOWN); - shutdownLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35:font data - shutdownLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - shutdownLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - - if (shutdownButton == nullptr) - { - shutdownButton = new UIButton(); - if (shutdownButton == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpShutdownView shutdownButton new fail"); - return false; - } - } - shutdownButton->SetPosition(93, 160, 100, 100); // 275:x 147:y 110:width 110:height93 - shutdownButton->SetImageSrc(PNG_SETTINGS_SETTTING_SHUTDOWN_1, PNG_SETTINGS_SETTTING_SHUTDOWN_1); - shutdownButton->SetImagePosition(0, 0); - shutdownButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36); - shutdownButton->SetViewId(SHUTDOWN_BUTTON); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance(); - if (clickListener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance nullptr"); - return false; - } - shutdownButton->SetOnClickListener(clickListener); - return true; - } - - /* - * @brief 初始化开关机视图 - */ - UIViewGroup *RebootView::InitShowUpView(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::InitShowUpView"); - bool ret; - if (group == nullptr) - { - group = new UIViewGroup(); - if (group == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); // 0:x; 0:y - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - ret = ShowUpRebootView(); - if (ret == false) - { - return nullptr; - } - group->Add(rebootLabel); - group->Add(rebootButton); - - ret = ShowUpShutdownView(); - if (ret == false) - { - return nullptr; - } - group->Add(shutdownLabel); - group->Add(shutdownButton); - - ret=factoryResetLabelInit(); - if(false==ret) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "factoryResetLabelInit fail"); - return nullptr; - } - group->Add(factoryResetLabel); - - - ret=factoryResetViewInit(); - if(false==ret) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "factoryResetViewInit fail"); - return nullptr; - } - group->Add(FactoryResetGroup); - - - UIView::OnDragListener *rebootDragListener = (UIView::OnDragListener *)OHOS::RebootPresenter::GetInstance(); - if (rebootDragListener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootDragListener GetInstance fail"); - return nullptr; - } - group->SetOnDragListener(rebootDragListener); - group->SetViewId(REBOOT_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; - } - - /* - * @brief 切换到重启和开关机视图 - */ - bool RebootView::ChangeRebootView(int16_t hideView, int16_t thisView) - { - UNUSED(hideView); - if (container[thisView] == nullptr) - { - UIViewGroup *viewGroup = InitShowUpView(); - if (viewGroup == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "viewGroup nullptr fail"); - return false; - } - container[thisView] = viewGroup; - RootView::GetInstance()->Add(container[thisView]); - } - return true; - } - - /* - * @brief 切换到重启设备视图 - */ - bool RebootView::ChangeRebootDeviceView(int16_t hideView, int16_t thisView) - { - UNUSED(hideView); - if (container[thisView] == nullptr) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeRebootDeviceView"); - rebootDeviceView = new RebootDeviceView(); - if (rebootDeviceView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootDeviceView new fail"); - return false; - } - // init view - UIViewGroup *viewGroup = rebootDeviceView->InitShowUpView(); - if (viewGroup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "viewGroup nullptr fail"); - return false; - } - container[thisView] = viewGroup; - RootView::GetInstance()->Add(container[thisView]); - } - return true; - } - - /* - * @brief 切换到开启设备视图 - */ - bool RebootView::ChangeShutdownDeviceView(int16_t hideView, int16_t thisView) - { - UNUSED(hideView); - if (container[thisView] == nullptr) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeShutdownDeviceView"); - shutdownDeviceView = new ShutdownDeviceView(); - if (shutdownDeviceView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutdownDeviceView new fail"); - return false; - } - // init view - UIViewGroup *viewGroup = shutdownDeviceView->InitShowUpView(); - if (viewGroup == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "viewGroup nullptr fail"); - return false; - } - container[thisView] = viewGroup; - RootView::GetInstance()->Add(container[thisView]); - } - return true; - } - - /* - * @brief 切换到关机动画视图 - */ - bool RebootView::ChangeShutDownAnimatorView(int16_t hideView, int16_t thisView) - { - UNUSED(hideView); - if (container[thisView] == nullptr) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ChangeShutdownDeviceView"); - shutDownAnimatorView = new ShutDownAnimatorView(); - if (shutDownAnimatorView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutDownAnimatorView new fail"); - return false; - } - UIViewGroup *group = shutDownAnimatorView->ShutDownAnimatorViewInit(); - if (group == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); - return false; - } - container[thisView] = group; - RootView::GetInstance()->Add(container[thisView]); - } - return true; - } - - /* - * @brief 用于检查传递给 ChangeView 方法的视图索引参数是否有效 - */ - bool RebootView::CheckViewParam(int16_t hideView, int16_t showView) - { - if (showView < 0 || showView >= REBOOT_MAX) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::CheckViewParam showView err."); - return false; - } - - if (hideView < 0 || hideView > REBOOT_MAX) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::CheckViewParam hideView err."); - return false; - } - - return true; - } - - /* - * @brief 执行视图切换逻辑 - */ - void RebootView::ChangeView(int16_t hideView, int16_t showView) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView::ChangeView %d, %d", hideView, showView); - - if (!CheckViewParam(hideView, showView)) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::CheckViewParam failed."); - return; - } - - PreprosssChangeView tmpPreProcessView = preProcessView[showView]; - - if (!(this->*tmpPreProcessView)(hideView, showView)) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootView::ChangeView %d %dfailed", showView, hideView); - return; - } - if (hideView != REBOOT_MAX) - { - if (container[hideView] == nullptr) - { - return; - } - container[hideView]->SetVisible(false); - } - container[showView]->SetVisible(true); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootView:: ChangeView end!!!%d", showView); - RootView::GetInstance()->Invalidate(); - } - -} diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutDownAnimatorView.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutDownAnimatorView.cpp deleted file mode 100644 index 96f26b9a0..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutDownAnimatorView.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include "rebootdevice/include/ShutDownAnimatorView.h" -#include "wearable_log.h" -#include "rebootdevice/include/RebootPresenter.h" -namespace OHOS -{ - - static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_X = 0; - static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y = 0; - static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_W = 466; - static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_H = 466; - static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 30; // 图片帧数 - static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_TIME = 150; // 图片更新间隔 - static constexpr char *ShutDownPaths = "/user/res/RebootAndShutDown/ShutDown/"; //关机图片路径 - static ShutDownAnimatorView *g_pShutDownAnimatorView = nullptr; - - ShutDownAnimatorView::ShutDownAnimatorView() - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownAnimatorView::ShutDownAnimatorView"); - g_pShutDownAnimatorView = this; - } - ShutDownAnimatorView::~ShutDownAnimatorView() - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownAnimatorView::~ShutDownAnimatorView"); - ClearAll(); - g_pShutDownAnimatorView = nullptr; - } - ShutDownAnimatorView *ShutDownAnimatorView::GetInstance() - { - return g_pShutDownAnimatorView; - } - - const char **ShutDownAnimatorView::CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages) - { - const char **imagePaths = new const char *[numImages]; - char buffer[256]; - for (int i = 0; i < numImages; i++) - { - snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension); - imagePaths[i] = strdup(buffer); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]); - } - return imagePaths; - } - - void ShutDownAnimatorView::FreeImagePathsArray(const char **imagePaths, const int numImages) - { - for (int i = 0; i < numImages; i++) - { - delete imagePaths[i]; - imagePaths[i] = nullptr; - } - } - - void ShutDownAnimatorView::ClearAll(void) - { - group->RemoveAll(); - if (ShutDownImageAnimatorView != nullptr) - { - delete ShutDownImageAnimatorView; - ShutDownImageAnimatorView = nullptr; - } - FreeImagePathsArray(ShutDownPathsArray, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); - delete group; - group = nullptr; - } - - UIImageAnimatorView *ShutDownAnimatorView::GeShutDownImageAnimatorView(void) - { - return ShutDownImageAnimatorView; - } - - bool ShutDownAnimatorView::ShowUpShutDownAnimatorView() - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownAnimatorView::ShowUpShutDownAnimatorView"); - ShutDownPathsArray = CreateImagePathsArray(ShutDownPaths, "bin", SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); - - if (ShutDownImageAnimatorView == nullptr) - { - ShutDownImageAnimatorView = new UIImageAnimatorView(); - if (ShutDownImageAnimatorView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView new ShutDownImageAnimatorView fail"); - return false; - } - for (uint8_t i = 0; i < SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++) - { - ShutDownImageInfo[i].imagePath = (ShutDownPathsArray[i]); - ShutDownImageInfo[i].imageType = IMG_SRC_FILE_PATH; - ShutDownImageInfo[i].pos.x = SHUTDOWN_IMAGE_ANIMATOR_VIEW_X; - ShutDownImageInfo[i].pos.y = SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y; - ShutDownImageInfo[i].width = SHUTDOWN_IMAGE_ANIMATOR_VIEW_W; - ShutDownImageInfo[i].height = SHUTDOWN_IMAGE_ANIMATOR_VIEW_H; - } - ShutDownImageAnimatorView->SetPosition(SHUTDOWN_IMAGE_ANIMATOR_VIEW_X, SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y, SHUTDOWN_IMAGE_ANIMATOR_VIEW_W, SHUTDOWN_IMAGE_ANIMATOR_VIEW_H); - ShutDownImageAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - ShutDownImageAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - ShutDownImageAnimatorView->SetImageAnimatorSrc(ShutDownImageInfo, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, 100); - ShutDownImageAnimatorView->SetRepeat(false); - ShutDownImageAnimatorView->SetRepeatTimes(1); - UIImageAnimatorView::AnimatorStopListener *stoplistener = static_cast(RebootPresenter::GetInstance()); - if (stoplistener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create stoplistener!!"); - return false; - } - ShutDownImageAnimatorView->SetAnimatorStopListener(stoplistener); - } - - return true; - } - - UIViewGroup *ShutDownAnimatorView::ShutDownAnimatorViewInit(void) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShutDownAnimatorView::InitShowUpView"); - bool ret; - group = new UIViewGroup(); - if (group == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - ret = ShowUpShutDownAnimatorView(); - if (ret == false) - { - return nullptr; - } - group->Add(ShutDownImageAnimatorView); - return group; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutdownDeviceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutdownDeviceView.cpp deleted file mode 100644 index 08d924bcb..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutdownDeviceView.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: ShutdownDevice View - * Create: 2022-04-28 - */ - -#include "rebootdevice/include/ShutdownDeviceView.h" -#include "wearable_log.h" -#include "UiConfig.h" -#include "rebootdevice/include/RebootPresenter.h" -#include "ui_resource_string.h" - -namespace OHOS { -static ShutdownDeviceView *g_pShutdownDeviceView{nullptr}; -ShutdownDeviceView::ShutdownDeviceView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShutdownDeviceView::ShutdownDeviceView"); - g_pShutdownDeviceView = this; -} - -ShutdownDeviceView::~ShutdownDeviceView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShutdownDeviceView::~ShutdownDeviceView"); - if (group != nullptr) { - group->RemoveAll(); - } - delete shutdownDeviceLabel; - shutdownDeviceLabel = nullptr; - delete shutdownDeviceButton; - shutdownDeviceButton = nullptr; - delete group; - group = nullptr; - g_pShutdownDeviceView = nullptr; -} - -ShutdownDeviceView *ShutdownDeviceView::GetInstance() -{ - return g_pShutdownDeviceView; -} - -/* - * @brief 显示关闭设备视图 -*/ -bool ShutdownDeviceView::ShowUpShutdownDeviceView() -{ - if (shutdownDeviceLabel == nullptr) { - shutdownDeviceLabel = new UILabelExt(); - if (shutdownDeviceLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpShutdownDeviceView shutdownDeviceLabel new fail"); - return false; - } - } - shutdownDeviceLabel->SetPosition(152, 272, 150, 45); // 152:x 272:y 150:width 45:height - shutdownDeviceLabel->SetText("关机"); - shutdownDeviceLabel->SetTextId(STR_SHUTDOWN); - shutdownDeviceLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 35:font data - shutdownDeviceLabel->SetStyle(STYLE_BACKGROUND_COLOR, OPA_OPAQUE); - shutdownDeviceLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, - UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - - if (shutdownDeviceButton == nullptr) { - shutdownDeviceButton = new UIButton(); - if (shutdownDeviceButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowUpShutdownDeviceView shutdownDeviceButton new fail"); - return false; - } - } - shutdownDeviceButton->SetPosition(172, 147, 100, 100); // 172:x 147:y 110:width 110:height - shutdownDeviceButton->SetImageSrc(PNG_SETTINGS_SETTTING_SHUTDOWN_1, PNG_SETTINGS_SETTTING_SHUTDOWN_1); - shutdownDeviceButton->SetImagePosition(0, 0); - shutdownDeviceButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36); - shutdownDeviceButton->SetViewId(SHUTDOWNDEVICE_BUTTON); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clickListener GetInstance nullptr"); - return false; - } - shutdownDeviceButton->SetOnClickListener(clickListener); - return true; -} - -/* - * @brief 关机视图初始化 - * @return 初始化成功,返回关机视图,反之返回nullptr -*/ -UIViewGroup *ShutdownDeviceView::InitShowUpView(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShutdownDeviceView::InitShowUpView"); - bool ret; - if (group == nullptr) { - group = new UIViewGroup(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail"); - return nullptr; - } - group->SetPosition(0, 0); // 0:x; 0:y - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - } - - ret = ShowUpShutdownDeviceView(); - if (!ret) { - return nullptr; - } - group->Add(shutdownDeviceLabel); - group->Add(shutdownDeviceButton); - UIView::OnDragListener *rebootDragListener = (UIView::OnDragListener *)OHOS::RebootPresenter::GetInstance(); - if (rebootDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootDragListener GetInstance fail"); - return nullptr; - } - group->SetOnDragListener(rebootDragListener); - group->SetViewId(SHUTDOWNDEVICE_VIEW); - group->SetDraggable(true); - group->SetTouchable(true); - return group; -} -} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp index 2b4f7db0a..dffffffb2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-12 11:44:04 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-15 14:28:46 + * @LastEditTime: 2024-08-29 17:49:05 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp */ /* @@ -15,7 +15,6 @@ #include "settings/include/SettingView.h" #include "settings/include/SettingModel.h" #include "settings/include/SettingPresenter.h" -#include "RebootModel.h" #include "common/key_code.h" #include namespace OHOS -- 2.17.1