From 7258c9f77cc14c806aaf0bd397a0521a73c6ed04 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Sat, 20 Jul 2024 08:21:17 +0000 Subject: [PATCH] Merge #561 into sdk602patch0626 from refs/changes/561/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/561/head: (5 commits squashed) - 添加滑动关机和重启功能: 恢复出厂设置未加 目前是长按才是滑动关机和重启 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 滑动关机和重启添加恢复出厂设置功能 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 滑动关机和重启界面多国语言修改 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/561 --- .../wearable/fd230app/CMakeLists.txt | 6 + .../nativelauncher/include/AppViewIDs.h | 1 + .../nativelauncher/include/NativeLauncher.h | 1 + .../include/ui_resource_string.h | 34 +- .../nativelauncher/src/NativeLauncher.cpp | 18 +- .../language/Language_xml/input_list_en.txt | 4 +- .../language/Language_xml/input_list_zh.txt | 4 +- .../language/Language_xml/language_en.xml | 2 + .../language/Language_xml/language_zh.xml | 2 + .../fd230app/nativeui/language/font/en.lang | Bin 9944 -> 9986 bytes .../language/font/ui_resource_string.h | 4 +- .../fd230app/nativeui/language/font/zh.lang | Bin 9029 -> 9069 bytes .../include/FactoryResetView.h | 46 ++ .../include/RebootAndShutdownModel.h | 27 + .../include/RebootAndShutdownPresenter.h | 53 ++ .../include/RebootAndShutdownView.h | 102 ++++ .../include/ShutDownImageAnimatorView.h | 45 ++ .../src/FactoryResetView.cpp | 187 +++++++ .../src/RebootAndShutdownModel.cpp | 24 + .../src/RebootAndShutdownPresenter.cpp | 210 +++++++ .../src/RebootAndShutdownView.cpp | 529 ++++++++++++++++++ .../src/ShutDownImageAnimatorView.cpp | 126 +++++ .../include/ShutDownAnimatorView.h | 12 +- .../rebootdevice/src/RebootDeviceView.cpp | 2 +- .../nativeui/rebootdevice/src/RebootModel.cpp | 4 +- .../nativeui/rebootdevice/src/RebootView.cpp | 4 +- .../rebootdevice/src/ShutDownAnimatorView.cpp | 7 + .../rebootdevice/src/ShutdownDeviceView.cpp | 2 +- .../system/src/SystemFactoryResetView.cpp | 23 +- .../nativeui/system/src/SystemView.cpp | 3 +- .../fd230/fs/user/res/font/en.lang | Bin 9944 -> 9986 bytes .../fs/user/res/font/ui_resource_string.h | 4 +- .../fd230/fs/user/res/font/zh.lang | Bin 9029 -> 9069 bytes .../fs/user/res/settings/SETTTING_REBOOT.bin | 4 +- .../user/res/settings/SETTTING_SHUTDOWN.bin | 4 +- 35 files changed, 1445 insertions(+), 49 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/FactoryResetView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/ShutDownImageAnimatorView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/FactoryResetView.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 6b8033223..d7829cc96 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -402,6 +402,12 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aimodels/src/AiModelsView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aimodels/src/AiModelsPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rebootandshutdown/src/FactoryResetView.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 457c5a651..0551fae31 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -66,6 +66,7 @@ typedef enum : uint16_t VIEW_THEME_STYLE, // 主题样式 VIEW_AI_VOICE, // AI Voice(人工智能语音) VIEW_AI_MODELS, // AI模型选择界面 + VIEW_REBOOTANDSHUTDOWN, //(滑动关机和重启带恢复出厂设置) VIEW_RECORD, /* ----------------------------------------------------------------------------- */ VIEW_DIAL, // 切换表盘 diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index dd4724c36..212e3ee39 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -63,6 +63,7 @@ namespace OHOS void InitThemeStyleSlice(void); void InitAiVoiceSlice(void); void InitAiModelsSlice(void); + void InitRebootAndShutdownSlice(void); /* --------------------------------界面------------------------------------ */ void InitRotateSlice(void); void InitBloodSlice(void); diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h index d7d2106ad..9c6e32b5d 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h @@ -1,15 +1,15 @@ -/* -* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved. -* Description: language -* Author: Graphic develop team -* Create: 2021-07-06 -*/ - -#ifndef UI_RESOURCE_STRING_H -#define UI_RESOURCE_STRING_H -#include -namespace OHOS { -enum UIResourceTextId : uint16_t { +/* +* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved. +* Description: language +* Author: Graphic develop team +* Create: 2021-07-06 +*/ + +#ifndef UI_RESOURCE_STRING_H +#define UI_RESOURCE_STRING_H +#include +namespace OHOS { +enum UIResourceTextId : uint16_t { STR_EXERCISE_OUTDOORWALKING = 0, STR_EXERCISE_OUTDOORRUNNING = 1, STR_EXERCISE_OUTDOORBIKING = 2, @@ -485,12 +485,14 @@ enum UIResourceTextId : uint16_t { STR_AIMODES_WENXINYIYAN = 472, STR_AIMODES_KIMI = 473, STR_AIMODES_CHATGPT = 474, - STR_MAX_ID = 475, + STR_SLIDE_TO_SHUTDOWN = 475, + STR_SLIDE_TO_REBOOT = 476, + STR_MAX_ID = 477, }; // UIResourceTextId - -enum FontLanguageId : uint8_t { - LANGUAGE_ID_ZH, + +enum FontLanguageId : uint8_t { LANGUAGE_ID_EN, + LANGUAGE_ID_ZH, LANGUAGE_ID_MAX }; // UITextLanguageTextId } diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 31606ce8f..2da956644 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -200,6 +200,9 @@ #include "aimodels/include/AiModelsPresenter.h" #include "aimodels/include/AiModelsView.h" + +#include "rebootandshutdown/include/RebootAndShutdownPresenter.h" +#include "rebootandshutdown/include/RebootAndShutdownView.h" /* -------------------------------------------------------------------------- */ #include "traing/include/TraingView.h" #include "traing/include/TraingPresenter.h" @@ -294,7 +297,8 @@ namespace OHOS {VIEW_RESPIRATORY_TRAINING, &NativeLauncher::InitRespiratoryTrainingSlice}, // 呼吸训练界面 {VIEW_THEME_STYLE, &NativeLauncher::InitThemeStyleSlice}, // 主题样式界面 {VIEW_AI_VOICE, &NativeLauncher::InitAiVoiceSlice}, // Ai Voice(人工智能语音) - {VIEW_AI_MODELS, &NativeLauncher::InitAiModelsSlice}, // Ai Models(Ai模型选择界面) + {VIEW_AI_MODELS, &NativeLauncher::InitAiModelsSlice}, // Ai Models(Ai模型选择界面) + {VIEW_REBOOTANDSHUTDOWN, &NativeLauncher::InitRebootAndShutdownSlice}, // 滑动关机和重启带恢复出厂设置 // {VIEW_SECONDARY_FUNCTION, &NativeLauncher::InitSecondaryFunction}, // {VIEW_FAST_TRAINING, &NativeLauncher::InitFastTrainingSlice}, @@ -1293,6 +1297,18 @@ namespace OHOS } NativeAbility::GetInstance().AddSliceProxy(VIEW_AI_MODELS, AiModels); } + + /*滑动关机和重启带恢复出厂设置*/ + void NativeLauncher::InitRebootAndShutdownSlice(void) + { + SliceProxy *rebootandshutdown = new AbilitySliceProxy; + if (rebootandshutdown == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootandshutdown"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_REBOOTANDSHUTDOWN, rebootandshutdown); + } /* -------------------------------------------------------------------------- */ void NativeLauncher::InitSetCardSlice(void) diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt index bd842a677..969dd6934 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt @@ -472,4 +472,6 @@ STR_CONTINUE_CHAT$Continue the conversation STR_AIMODELS_DOUBAO$Cici STR_AIMODES_WENXINYIYAN$ERNIE Bot STR_AIMODES_KIMI$Kimi -STR_AIMODES_CHATGPT$ChatGPT \ No newline at end of file +STR_AIMODES_CHATGPT$ChatGPT +STR_SLIDE_TO_SHUTDOWN$Slide to shutdown +STR_SLIDE_TO_REBOOT$Slide to reboot \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt index 407425a50..099b258a6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt @@ -472,4 +472,6 @@ STR_CONTINUE_CHAT$继续对话 STR_AIMODELS_DOUBAO$豆包 STR_AIMODES_WENXINYIYAN$文心一言 STR_AIMODES_KIMI$Kimi -STR_AIMODES_CHATGPT$ChatGPT \ No newline at end of file +STR_AIMODES_CHATGPT$ChatGPT +STR_SLIDE_TO_SHUTDOWN$滑动关机 >> +STR_SLIDE_TO_REBOOT$滑动重启 >> \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml index be26e19d4..08bd8e479 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml @@ -474,4 +474,6 @@ + + diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml index 0ea317fce..8bb63aa69 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml @@ -474,4 +474,6 @@ + + diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang b/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang index a242fedb92864bf92dfa4b3af58531aa2f36695a..0cc6eea44aea6e3bd46fe1e537a999ab37b9ebdd 100644 GIT binary patch delta 76 zcmccN+vF$O;=8XuHID%W+}$Xe%g!1m&%ltext={zUMV;yGbL4_BwwL8qqHO?zdVlt NE>e`5l%HS1000nz754xD delta 35 fcmZqjyWuOU&~@J;HID%W+}h diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h b/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h index ede429db9..69218bc92 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h +++ b/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h @@ -485,7 +485,9 @@ enum UIResourceTextId : uint16_t { STR_AIMODES_WENXINYIYAN = 472, STR_AIMODES_KIMI = 473, STR_AIMODES_CHATGPT = 474, - STR_MAX_ID = 475, + STR_SLIDE_TO_SHUTDOWN = 475, + STR_SLIDE_TO_REBOOT = 476, + STR_MAX_ID = 477, }; // UIResourceTextId enum FontLanguageId : uint8_t { diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang b/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang index 053d7e382fe277213dc47b21569c419423f5bb8b..d06ff68f305dbf3b93f4728efb32c4b46f3f78c0 100644 GIT binary patch delta 74 zcmX@=_SQ{w$3cF!stg7caCf6_tJ@IMRil?ocpUv5&U}whw O;lFI}eL7)1hz|gi799@& delta 35 fcmaFscGOLDi+0u0stg7caC@U@F8k&#_QTQux48*x diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/FactoryResetView.h b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/FactoryResetView.h new file mode 100644 index 000000000..d6199e585 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/FactoryResetView.h @@ -0,0 +1,46 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-07-20 14:12:16 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-20 14:54:48 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/FactoryResetVIew.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ + +#ifndef FACTORY_RESET_VIEW_H +#define FACTORY_RESET_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +namespace OHOS +{ + static constexpr const char *FACTORY_RESET_GROUPVIEW = "FactoryResetGroupView"; + static constexpr const char *FACTORY_RESET_BUTTON_CHECK_ON = "FactoryResetButtonCheckOn"; /*确认恢复出厂设置*/ + static constexpr const char *FACTORY_RESET_BUTTON_CHECK_OFF = "FactoryResetButtonCheckOff"; /*取消*/ + class FactoryResetView + { + + public: + FactoryResetView(); + virtual ~FactoryResetView(); + static FactoryResetView *GetInstance(void); + + UIViewGroup *FactoryResetViewInit(void); + void ClearAll(void); + + private: + UIViewGroup *group{nullptr}; + UILabelExt *Title{nullptr}; + UIImageView *FactoryResetImage{nullptr}; + UILabelExt *FactoryResetNote{nullptr}; + UIButton *FactoryResetButtonCheckOn{nullptr}; // 重置确认 + UIButton *FactoryResetButtonCheckOff{nullptr}; // 重置否定 + bool initViewStatus{false}; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h new file mode 100644 index 000000000..3e1f0480e --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h @@ -0,0 +1,27 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-07-18 14:55:21 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-18 14:56:47 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h + */ + +#ifndef REBOOT_AND_SHUTDOWN_H +#define REBOOT_AND_SHUTDOWN_H + +namespace OHOS +{ + class RebootAndShutdownModel + { + public: + static RebootAndShutdownModel &GetInstance(void); + + private: + RebootAndShutdownModel(); + ~RebootAndShutdownModel(); + RebootAndShutdownModel(const RebootAndShutdownModel &) = delete; + RebootAndShutdownModel &operator=(const RebootAndShutdownModel &) = delete; + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h new file mode 100644 index 000000000..b62307505 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h @@ -0,0 +1,53 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-07-18 14:26:31 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-20 11:15:27 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h + */ + +#ifndef REBOOT_AND_SHUTDOWN_PRESENTER_H +#define REBOOT_AND_SHUTDOWN_PRESENTER_H + +#include "Presenter.h" +#include "View.h" +#include "components/ui_slider.h" +#include "components/ui_image_animator.h" + +namespace OHOS +{ + class RebootAndShutdownView; + class RebootAndShutdownModel; + class RebootAndShutdownPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener, + public UISlider::UISliderEventListener, + public UIImageAnimatorView::AnimatorStopListener, + public RootView::OnKeyActListener + { + public: + RebootAndShutdownPresenter(); + virtual ~RebootAndShutdownPresenter(); + static RebootAndShutdownPresenter *GetInstance(); + + void OnStart() override; + void OnResume() override; + void OnPause() override; + void OnStop() override; + + 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; + void OnAnimatorStop(UIView &view) override; + void OnChange(int32_t value) override; + void OnRelease(int32_t value) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + + RebootAndShutdownModel *model; + bool X_DRAG_FLAG{false}; + bool isShutDownOperation{false}; + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownView.h b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownView.h new file mode 100644 index 000000000..548ea4e79 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownView.h @@ -0,0 +1,102 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-07-18 14:25:53 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-20 14:56:42 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownView.h + */ +#ifndef REBOOT_AND_SHUTDOWN_VIEW_H +#define REBOOT_AND_SHUTDOWN_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label_ext.h" +#include "components/ui_slider.h" +#include "components/ui_view_group.h" +#include "rebootandshutdown/include/ShutDownImageAnimatorView.h" +#include "rebootandshutdown/include/FactoryResetView.h" +namespace OHOS +{ + typedef enum : uint8_t + { + REBOOTANDSHUTDOWN = 0, + SHUTDOWNANIMATOR, /*关机动画view*/ + FACTORYRESET, /*恢复出厂设置view*/ + REBOOTANDSHUTDOWN_MAX, + } REBOOTANDSHUTDOWNVIEWID; + + static constexpr const char *SHUTDOWN_SLIDER_VIEWID = "shutdown_slider_viewid"; + static constexpr const char *REBOOT_SLIDER_VIEWID = "reboot_slider_viewid"; + static constexpr const char *FACTORYRESET_LABEL_VIEWID = "factoryreset_label_viewid"; + static constexpr const char *REBOOT_AND_SHUTDOWN_GROUPVIEW = "reboot_and_shutdown_groupview"; + + class RebootAndShutdownPresenter; + class RebootAndShutdownView : public View + { + + public: + RebootAndShutdownView(); + ~RebootAndShutdownView(); + static RebootAndShutdownView *GetInstance(void); + UISlider *GetShutdownSlider(void); + UISlider *GetRebootSlider(void); + + bool ChangeToRebootAndShutdownView(int16_t thisView); + bool ChangeToShutDownAnimatorView(int16_t thisView); + bool ChangeToFactoryResetView(int16_t thisView); + void ChangeView(int16_t hideView, int16_t showView); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + 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; + }; + + private: + bool CheckViewParam(int16_t hideView, int16_t showView); + bool ClickFunc(int16_t interface); + + ShutDownImageAnimatorView *shutDownImageAnimatorView{nullptr}; + FactoryResetView *factoryResetView{nullptr}; + + private: + UILabelExt *RebootAndShutdownLabelInit(LabelConfig &labelconfig); + + bool CreateRebootAndShutdownLabel(void); + bool CreateRebootAndShutdownSlider(void); + bool CreateRebootAndShutdownScrollView(void); + bool CreateRebootAndShutdownGroupView(void); + void CreateRebootAndShutdownView(void); + void ClearAll(void); + + UIViewGroup *rebootAndShutdownGroupView[REBOOTANDSHUTDOWN_MAX]{nullptr}; + + UILabelExt *title{nullptr}; + UILabelExt *factoryResetLabel{nullptr}; /*恢复出厂设置*/ + + /*关机*/ + UILabelExt *shutdownLabel{nullptr}; + UISlider *shutdownSlider{nullptr}; + UIScrollView *shutdownScrollView{nullptr}; + + /*重启*/ + UILabelExt *rebootLabel{nullptr}; + UISlider *rebootSlider{nullptr}; + UIScrollView *rebootScrollView{nullptr}; + + bool viewInitStatus{false}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/ShutDownImageAnimatorView.h b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/ShutDownImageAnimatorView.h new file mode 100644 index 000000000..a779a771c --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/ShutDownImageAnimatorView.h @@ -0,0 +1,45 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-07-20 11:05:46 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-20 15:11:40 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/ShutDownImageAnimatorView.h + */ + +#ifndef __SHUTDOWN_IMAGE_ANIMATOR_VIEW_H__ +#define __SHUTDOWN_IMAGE_ANIMATOR_VIEW_H__ + +#include "components/ui_view_group.h" +#include "components/ui_image_animator.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 const char *ShutDownPaths = "/user/res/RebootAndShutDown/ShutDown/"; // 关机图片路径 + + class ShutDownImageAnimatorView + { + public: + ShutDownImageAnimatorView(); + ~ShutDownImageAnimatorView(); + static ShutDownImageAnimatorView *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[SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 关机图像的信息 + const char **ShutDownPathsArray{nullptr}; // 关机图片路径数组 + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/FactoryResetView.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/FactoryResetView.cpp new file mode 100644 index 000000000..b09d102cb --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/FactoryResetView.cpp @@ -0,0 +1,187 @@ +#include "rebootandshutdown/include/FactoryResetView.h" +#include "rebootandshutdown/include/RebootAndShutdownPresenter.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "ui_resource_string.h" + +namespace OHOS +{ + + static FactoryResetView *g_pFactoryResetView{nullptr}; + + FactoryResetView::FactoryResetView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::FactoryResetView"); + g_pFactoryResetView = this; + } + + FactoryResetView::~FactoryResetView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::~FactoryResetView"); + ClearAll(); + g_pFactoryResetView = nullptr; + } + + FactoryResetView *FactoryResetView::GetInstance() + { + return g_pFactoryResetView; + } + + void FactoryResetView::ClearAll() + { + if (initViewStatus == true) + { + group->RemoveAll(); + + if (Title != nullptr) + { + delete Title; + Title = nullptr; + } + + if (FactoryResetImage != nullptr) + { + delete FactoryResetImage; + FactoryResetImage = nullptr; + } + + if (FactoryResetNote != nullptr) + { + delete FactoryResetNote; + FactoryResetNote = nullptr; + } + + if (FactoryResetButtonCheckOn != nullptr) + { + delete FactoryResetButtonCheckOn; + FactoryResetButtonCheckOn = nullptr; + } + if (FactoryResetButtonCheckOff != nullptr) + { + delete FactoryResetButtonCheckOff; + FactoryResetButtonCheckOff = nullptr; + } + + delete group; + group = nullptr; + } + } + + UIViewGroup *FactoryResetView::FactoryResetViewInit(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FactoryResetView::FactoryResetViewInit"); + if (group == nullptr) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::new group fail!"); + return nullptr; + } + group->SetViewId(FACTORY_RESET_GROUPVIEW); + group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + group->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + group->SetStyle(STYLE_BORDER_RADIUS, 100); + group->SetTouchable(true); + group->SetDraggable(true); + UIView::OnDragListener *dragListener = static_cast(RebootAndShutdownPresenter::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::GetInstance fail!!"); + return nullptr; + } + group->SetOnDragListener(dragListener); + /* ---------------------------------- Title --------------------------------- */ + Title = new UILabelExt(); + if (Title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::new Title fail!"); + return nullptr; + } + Title->SetPosition(83, 50, 300, 35); + Title->SetStyle(STYLE_TEXT_FONT, 30); + Title->SetStyle(STYLE_LINE_HEIGHT, 35); + Title->SetTextId(STR_FACTORY_RESET); /*恢复出厂*/ + Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + Title->SetRollSpeed(70); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ---------------------------- FactoryResetImage --------------------------- */ + FactoryResetImage = new UIImageView(); + if (FactoryResetImage == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::new FactoryResetImage fail!"); + return nullptr; + } + FactoryResetImage->SetPosition(193, 120); + FactoryResetImage->SetSrc(PNG_ATTENTION_IMAGE); + /* ---------------------------- FactoryResetNote ---------------------------- */ + FactoryResetNote = new UILabelExt(); + if (FactoryResetNote == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::new FactoryResetNote fail!"); + return nullptr; + } + FactoryResetNote->SetPosition(53, 228, 360, 70); + FactoryResetNote->SetStyle(STYLE_TEXT_FONT, 30); + FactoryResetNote->SetStyle(STYLE_LINE_HEIGHT, 35); + FactoryResetNote->SetTextId(STR_RESET_CONFIRM_NOTE); /*该操作会清空并重置手表数据,是否确认继续?*/ + FactoryResetNote->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + FactoryResetNote->SetTextColor(Color::GetColorFromRGBA(0xff, 0x8a, 0x36, 0xff)); + FactoryResetNote->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + FactoryResetNote->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ----------------------- FactoryResetButtonCheckOff ----------------------- */ + FactoryResetButtonCheckOff = new UIButton(); + if (FactoryResetButtonCheckOff == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::new FactoryResetButtonCheckOff fail!"); + return nullptr; + } + FactoryResetButtonCheckOff->SetPosition(97, 320, 130, 130); + FactoryResetButtonCheckOff->SetViewId(FACTORY_RESET_BUTTON_CHECK_OFF); + FactoryResetButtonCheckOff->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + FactoryResetButtonCheckOff->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + FactoryResetButtonCheckOff->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + FactoryResetButtonCheckOff->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + FactoryResetButtonCheckOff->SetImageSrc(PNG_SYSTEM_CHECK_OFF_IMAGE, PNG_SYSTEM_CHECK_OFF_IMAGE); + UIView::OnClickListener *FactoryResetButtonCheckOffClick = static_cast(RebootAndShutdownPresenter::GetInstance()); + if (FactoryResetButtonCheckOffClick == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::RebootAndShutdownPresenter::GetInstance fail!!"); + return nullptr; + } + FactoryResetButtonCheckOff->SetOnClickListener(FactoryResetButtonCheckOffClick); + /* ------------------------ FactoryResetButtonCheckOn ----------------------- */ + FactoryResetButtonCheckOn = new UIButton(); + if (FactoryResetButtonCheckOn == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::new FactoryResetButtonCheckOn fail!"); + return nullptr; + } + FactoryResetButtonCheckOn->SetPosition(240, 320, 130, 130); + FactoryResetButtonCheckOn->SetViewId(FACTORY_RESET_BUTTON_CHECK_ON); + FactoryResetButtonCheckOn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + FactoryResetButtonCheckOn->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + FactoryResetButtonCheckOn->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + FactoryResetButtonCheckOn->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + FactoryResetButtonCheckOn->SetImageSrc(PNG_SYSTEM_CHECK_ON_IMAGE, PNG_SYSTEM_CHECK_ON_IMAGE); + UIView::OnClickListener *FactoryResetButtonCheckOnClick = static_cast(RebootAndShutdownPresenter::GetInstance()); + if (FactoryResetButtonCheckOnClick == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::RebootAndShutdownPresenter::GetInstance fail!!"); + return nullptr; + } + FactoryResetButtonCheckOn->SetOnClickListener(FactoryResetButtonCheckOnClick); + + /* ----------------------------- Add to scroView ---------------------------- */ + group->Add(Title); + group->Add(FactoryResetImage); + group->Add(FactoryResetNote); + group->Add(FactoryResetButtonCheckOff); + group->Add(FactoryResetButtonCheckOn); + + initViewStatus = true; + } + return group; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp new file mode 100644 index 000000000..2e9fbbe99 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp @@ -0,0 +1,24 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-07-18 14:55:27 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-18 14:56:16 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp + */ + +#include "rebootandshutdown/include/RebootAndShutdownModel.h" +#include "wearable_log.h" + +namespace OHOS +{ + RebootAndShutdownModel::RebootAndShutdownModel() {} + + RebootAndShutdownModel::~RebootAndShutdownModel() {} + + RebootAndShutdownModel &RebootAndShutdownModel::GetInstance() + { + static RebootAndShutdownModel instance; + return instance; + } + +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp new file mode 100644 index 000000000..a1f107518 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp @@ -0,0 +1,210 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-20 15:11:17 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-20 14:56:16 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/RebootAndShutdownPresenter.cpp + */ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "common/key_code.h" +#include +#include "UiConfig.h" +#include "rebootandshutdown/include/RebootAndShutdownPresenter.h" +#include "rebootandshutdown/include/RebootAndShutdownView.h" +#include "rebootandshutdown/include/RebootAndShutdownModel.h" + +namespace OHOS +{ + + static constexpr const int SLIDER_VALUE_MAX = 88; + static constexpr const int SLIDER_VALUE_MIN = 12; + // 当前Presenter属性实例化的内存指针 + static RebootAndShutdownPresenter *g_pRebootAndShutdownPresenter = nullptr; + + RebootAndShutdownPresenter::RebootAndShutdownPresenter() + { + model = &RebootAndShutdownModel::GetInstance(); + g_pRebootAndShutdownPresenter = this; + } + + RebootAndShutdownPresenter::~RebootAndShutdownPresenter() + { + g_pRebootAndShutdownPresenter = nullptr; + } + + RebootAndShutdownPresenter *RebootAndShutdownPresenter::GetInstance() + { + return g_pRebootAndShutdownPresenter; + } + + // 启动时执行的逻辑 + void RebootAndShutdownPresenter::OnStart() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnStart"); + Presenter::OnStart(); + } + + // 页面已经展示后的调用逻辑 + void RebootAndShutdownPresenter::OnResume(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnResume"); + Presenter::OnResume(); + if (view_ == nullptr) + { + return; + } + } + + // 页面准备切换到后台前执行的逻辑 + void RebootAndShutdownPresenter::OnPause(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnPause"); + Presenter::OnPause(); + } + + // 页面完全置于后台时的逻辑。 + void RebootAndShutdownPresenter::OnStop(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnStop"); + Presenter::OnStop(); + } + + bool RebootAndShutdownPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnClick"); + if (strcmp(view.GetViewId(), FACTORYRESET_LABEL_VIEWID) == 0) // 进入出厂设置界面 + { + RebootAndShutdownView::GetInstance()->ChangeView(REBOOTANDSHUTDOWN, FACTORYRESET); + 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); + } + return true; + } + + bool RebootAndShutdownPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + RebootAndShutdownPresenter::X_DRAG_FLAG = true; + } + return true; + } + + bool RebootAndShutdownPresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnDragEnd"); + UISlider *slider = dynamic_cast(&view); + if (slider != nullptr) + { + if (slider == view_->GetRebootSlider() || slider == view_->GetShutdownSlider()) + { + return true; + } + } + else + { + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && RebootAndShutdownPresenter::X_DRAG_FLAG) + { + if (strcmp(view.GetViewId(), REBOOT_AND_SHUTDOWN_GROUPVIEW) == 0) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + } + else if (strcmp(view.GetViewId(), FACTORY_RESET_GROUPVIEW) == 0) + { + RebootAndShutdownView::GetInstance()->ChangeView(FACTORYRESET, REBOOTANDSHUTDOWN); + } + RebootAndShutdownPresenter::X_DRAG_FLAG = false; + return true; + } + } + return false; + } + + void RebootAndShutdownPresenter::OnAnimatorStop(UIView &view) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnAnimatorStop"); + if (isShutDownOperation == true) + { + uapi_poweroff_device(); // 关机 + } + else + { + uapi_reboot_device(); // 重启 + } + } + + void RebootAndShutdownPresenter::OnChange(int32_t value) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnChange"); + } + + void RebootAndShutdownPresenter::OnRelease(int32_t value) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnRelease,value = %d", value); + auto shutdownSlider = view_->GetShutdownSlider(); + auto rebootSlider = view_->GetRebootSlider(); + + if (shutdownSlider->GetValue() < SLIDER_VALUE_MAX) + { + shutdownSlider->SetValue(SLIDER_VALUE_MIN); + } + else + { + shutdownSlider->SetValue(SLIDER_VALUE_MAX); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "关机!!"); + + RebootAndShutdownView::GetInstance()->ChangeView(REBOOTANDSHUTDOWN, SHUTDOWNANIMATOR); + + start_shutdown_or_reboot(); + shutdown_reboot_prejobs(); + + ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start(); + + isShutDownOperation = true; + } + + if (rebootSlider->GetValue() < SLIDER_VALUE_MAX) + { + rebootSlider->SetValue(SLIDER_VALUE_MIN); + } + else + { + rebootSlider->SetValue(SLIDER_VALUE_MAX); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "重启!!"); + RebootAndShutdownView::GetInstance()->ChangeView(REBOOTANDSHUTDOWN, SHUTDOWNANIMATOR); + start_shutdown_or_reboot(); + shutdown_reboot_prejobs(); + + ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start(); + + isShutDownOperation = false; + } + } + + bool RebootAndShutdownPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnKeyAct"); + uint16_t keyID = event.GetKeyId(); + uint16_t keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp new file mode 100644 index 000000000..19caa9591 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp @@ -0,0 +1,529 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-07-18 14:26:08 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-20 15:09:36 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp + */ + +#include "rebootandshutdown/include/RebootAndShutdownPresenter.h" +#include "rebootandshutdown/include/RebootAndShutdownView.h" +#include "wearable_log.h" +#include "ui_resource_string.h" +#include "UiConfig.h" +namespace OHOS +{ + + static RebootAndShutdownView *g_pRebootAndShutdownView{nullptr}; + + RebootAndShutdownView::RebootAndShutdownView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::RebootAndShutdownView"); + g_pRebootAndShutdownView = this; + } + + RebootAndShutdownView::~RebootAndShutdownView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::~RebootAndShutdownView"); + g_pRebootAndShutdownView = nullptr; + } + + RebootAndShutdownView *RebootAndShutdownView::GetInstance() + { + return g_pRebootAndShutdownView; + } + + /*获取关机滑动条*/ + UISlider *RebootAndShutdownView::GetShutdownSlider(void) + { + return shutdownSlider; + } + + /*获取重启滑动条*/ + UISlider *RebootAndShutdownView::GetRebootSlider(void) + { + return rebootSlider; + } + + void RebootAndShutdownView::ClearAll(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::ClearAll"); + if (viewInitStatus) + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + + if (rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] != nullptr) + { + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->RemoveAll(); + if (title != nullptr) + { + delete title; + title = nullptr; + } + if (factoryResetLabel != nullptr) + { + delete factoryResetLabel; + factoryResetLabel = nullptr; + } + if (shutdownScrollView != nullptr) + { + shutdownScrollView->RemoveAll(); + + if (shutdownLabel != nullptr) + { + delete shutdownLabel; + shutdownLabel = nullptr; + } + + if (shutdownSlider != nullptr) + { + delete shutdownSlider; + shutdownSlider = nullptr; + } + + delete shutdownScrollView; + shutdownScrollView = nullptr; + } + if (rebootScrollView != nullptr) + { + rebootScrollView->RemoveAll(); + + if (rebootSlider != nullptr) + { + delete rebootSlider; + rebootSlider = nullptr; + } + + if (rebootLabel != nullptr) + { + delete rebootLabel; + rebootLabel = nullptr; + } + + delete rebootScrollView; + rebootScrollView = nullptr; + } + delete rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]; + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] = nullptr; + } + + if (shutDownImageAnimatorView != nullptr) + { + delete shutDownImageAnimatorView; + shutDownImageAnimatorView = nullptr; + } + + if (factoryResetView != nullptr) + { + delete factoryResetView; + factoryResetView = nullptr; + } + } + } + + UILabelExt *RebootAndShutdownView::RebootAndShutdownLabelInit(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_CENTER); + label->SetRollSpeed(70); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); + return label; + } + + bool RebootAndShutdownView::CreateRebootAndShutdownLabel(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CreateRebootAndShutdownLabel"); + LabelConfig labelConfig = { + .left = 83, + .top = 50, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_SHUTDOWN_AND_RESTART, /*关机和重启*/ + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + title = RebootAndShutdownLabelInit(labelConfig); + if (title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "title new fail!"); + return false; + } + /* -------------------------------------------------------------------------- */ + labelConfig = { + .left = 110, + .top = 33, + .width = 240, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_SLIDE_TO_SHUTDOWN, /*滑动关机 >>*/ + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + shutdownLabel = RebootAndShutdownLabelInit(labelConfig); + if (shutdownLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutdownLabel new fail!"); + return false; + } + shutdownLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + /* -------------------------------------------------------------------------- */ + labelConfig.textId = STR_SLIDE_TO_REBOOT; /*滑动重启 >>*/ + rebootLabel = RebootAndShutdownLabelInit(labelConfig); + if (rebootLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootLabel new fail!"); + return false; + } + rebootLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + /* -------------------------------------------------------------------------- */ + labelConfig = { + .left = 83, + .top = 370, + .width = 300, + .height = 70, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_FACTORY_RESET, /*恢复出厂*/ + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + factoryResetLabel = RebootAndShutdownLabelInit(labelConfig); + if (factoryResetLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "factoryResetLabel new fail!"); + return false; + } + factoryResetLabel->SetViewId(FACTORYRESET_LABEL_VIEWID); + factoryResetLabel->SetTouchable(true); + factoryResetLabel->SetTextColor(Color::GetColorFromRGBA(0x35, 0x49, 0xff, 0xff)); + factoryResetLabel->SetStyle(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP); + factoryResetLabel->SetOnClickListener(presenter_); + + return true; + } + + bool RebootAndShutdownView::CreateRebootAndShutdownSlider(void) + { + if (shutdownSlider == nullptr) + { + shutdownSlider = new UISlider(); + if (shutdownSlider == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutdownSlider new fail!"); + return false; + } + shutdownSlider->SetPosition(10, 10, 360, 80); + shutdownSlider->SetViewId(REBOOT_SLIDER_VIEWID); + shutdownSlider->SetStyle(STYLE_BORDER_RADIUS, 100); + shutdownSlider->SetRange(100, 0); + shutdownSlider->SetValidWidth(360); + shutdownSlider->SetValidHeight(80); + shutdownSlider->SetSliderColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff), Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff)); + shutdownSlider->SetKnobWidth(80); + shutdownSlider->SetKnobStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + shutdownSlider->SetKnobRadius(100); + shutdownSlider->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x00); + // shutdownSlider->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff); + shutdownSlider->SetKnobImage(PNG_SETTINGS_SETTTING_SHUTDOWN); + shutdownSlider->SetValue(12); + shutdownSlider->SetCapType(CapType::CAP_ROUND); + } + /* -------------------------------------------------------------------------- */ + if (rebootSlider == nullptr) + { + rebootSlider = new UISlider(); + if (rebootSlider == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootSlider new fail!"); + return false; + } + rebootSlider->SetPosition(10, 10, 360, 80); + rebootSlider->SetViewId(REBOOT_SLIDER_VIEWID); + rebootSlider->SetStyle(STYLE_BORDER_RADIUS, 100); + rebootSlider->SetRange(100, 0); + rebootSlider->SetValidWidth(360); + rebootSlider->SetValidHeight(80); + rebootSlider->SetSliderColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff), Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff)); + rebootSlider->SetKnobWidth(80); + rebootSlider->SetKnobStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + rebootSlider->SetKnobRadius(100); + rebootSlider->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x00); + // rebootSlider->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff); + rebootSlider->SetKnobImage(PNG_SETTINGS_SETTTING_REBOOT); + rebootSlider->SetValue(12); + rebootSlider->SetCapType(CapType::CAP_ROUND); + } + shutdownSlider->SetOnDragListener(presenter_); + shutdownSlider->SetSliderEventListener(presenter_); + + rebootSlider->SetOnDragListener(presenter_); + rebootSlider->SetSliderEventListener(presenter_); + + return true; + } + + bool RebootAndShutdownView::CreateRebootAndShutdownScrollView(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CreateRebootAndShutdownScrollView"); + if (shutdownScrollView == nullptr) + { + shutdownScrollView = new UIScrollView(); + if (shutdownScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutdownScrollView new fail!"); + return false; + } + shutdownScrollView->SetPosition(43, 120, 380, 100); + shutdownScrollView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + shutdownScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + shutdownScrollView->SetStyle(STYLE_BORDER_RADIUS, 100); + shutdownScrollView->SetTouchable(true); + shutdownScrollView->SetDraggable(true); + shutdownScrollView->SetIntercept(true); + } + + /* -------------------------------------------------------------------------- */ + if (rebootScrollView == nullptr) + { + rebootScrollView = new UIScrollView(); + if (rebootScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootScrollView new fail!"); + return false; + } + rebootScrollView->SetPosition(43, 240, 380, 100); + rebootScrollView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + rebootScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + rebootScrollView->SetStyle(STYLE_BORDER_RADIUS, 100); + rebootScrollView->SetTouchable(true); + rebootScrollView->SetDraggable(true); + rebootScrollView->SetIntercept(true); + } + + return true; + } + + bool RebootAndShutdownView::CreateRebootAndShutdownGroupView(void) + { + if (rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] == nullptr) + { + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] = new UIViewGroup(); + if (rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] is new fail!!"); + return false; + } + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->SetPosition(0, 0, 466, 466); + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->SetViewId(REBOOT_AND_SHUTDOWN_GROUPVIEW); + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->SetStyle(STYLE_BACKGROUND_OPA, 0); + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->SetTouchable(true); + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->SetDraggable(true); + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->SetOnDragListener(presenter_); + } + + return true; + } + + void RebootAndShutdownView::CreateRebootAndShutdownView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CreateRebootAndShutdownView"); + if (!CreateRebootAndShutdownGroupView() || !CreateRebootAndShutdownScrollView() || + !CreateRebootAndShutdownLabel() || !CreateRebootAndShutdownSlider()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CreateRebootAndShutdownView fail!"); + return; + } + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(title); + shutdownScrollView->Add(shutdownLabel); + shutdownScrollView->Add(shutdownSlider); + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(shutdownScrollView); + + rebootScrollView->Add(rebootLabel); + rebootScrollView->Add(rebootSlider); + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(rebootScrollView); + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(factoryResetLabel); + + container_->Add(rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]); + } + + void RebootAndShutdownView::OnStart() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::OnStart"); + View::OnStart(); + SetContainerView(new UIViewGroup()); + if (GetContainer() == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!"); + return; + } + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetTouchable(true); + container_->SetDraggable(true); + + if (!viewInitStatus) + { + CreateRebootAndShutdownView(); + viewInitStatus = true; + } + + RootView::GetInstance()->SetOnKeyActListener(presenter_); + return; + } + void RebootAndShutdownView::OnSetUpView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::OnSetUpView"); + View::OnSetUpView(); + Draw(); + return; + } + + void RebootAndShutdownView::OnTearDownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::OnTearDownView"); + View::OnTearDownView(); + return; + } + + void RebootAndShutdownView::OnStop() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::OnStop"); + View::OnStop(); + RootView::GetInstance()->ClearOnKeyActListener(); + ClearAll(); + return; + } + + bool RebootAndShutdownView::ChangeToRebootAndShutdownView(int16_t thisView) + { + if (rebootAndShutdownGroupView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::ChangeToRebootAndShutdownView"); + container_->Add(rebootAndShutdownGroupView[thisView]); + } + return true; + } + + bool RebootAndShutdownView::ChangeToShutDownAnimatorView(int16_t thisView) + { + if (rebootAndShutdownGroupView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::ChangeToShutDownAnimatorView"); + shutDownImageAnimatorView = new ShutDownImageAnimatorView(); + if (shutDownImageAnimatorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutDownImageAnimatorView new fail"); + return false; + } + UIViewGroup *group = shutDownImageAnimatorView->ShutDownAnimatorViewInit(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); + return false; + } + rebootAndShutdownGroupView[thisView] = group; + container_->Add(rebootAndShutdownGroupView[thisView]); + } + return true; + } + + bool RebootAndShutdownView::ChangeToFactoryResetView(int16_t thisView) + { + if (rebootAndShutdownGroupView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::ChangeToFactoryResetView"); + factoryResetView = new FactoryResetView(); + if (factoryResetView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "factoryResetView new fail"); + return false; + } + UIViewGroup *group = factoryResetView->FactoryResetViewInit(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); + return false; + } + rebootAndShutdownGroupView[thisView] = group; + container_->Add(rebootAndShutdownGroupView[thisView]); + } + + return true; + } + + struct RebootAndShutdownViewMapper + { + const int16_t viewId; + bool (RebootAndShutdownView::*func)(int16_t thisView); + }; + + static const RebootAndShutdownViewMapper ViewMapper[] = { + {REBOOTANDSHUTDOWN, &RebootAndShutdownView::ChangeToRebootAndShutdownView}, + {FACTORYRESET, &RebootAndShutdownView::ChangeToFactoryResetView}, + {SHUTDOWNANIMATOR, &RebootAndShutdownView::ChangeToShutDownAnimatorView}, + }; + + bool RebootAndShutdownView::ClickFunc(int16_t interface) + { + int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]); + for (int i = 0; i < funcSize; i++) + { + if (interface == ViewMapper[i].viewId) + { + bool jug = (this->*(ViewMapper[i].func))(interface); + if (jug == false) + { + return false; + } + return true; + } + } + return false; + } + + bool RebootAndShutdownView::CheckViewParam(int16_t hideView, int16_t showView) + { + if (showView < 0 || showView >= REBOOTANDSHUTDOWN_MAX) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "REBOOTANDSHUTDOWN_MAX::CheckViewParam showView err."); + return false; + } + + if (hideView < 0 || hideView > REBOOTANDSHUTDOWN_MAX) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "REBOOTANDSHUTDOWN_MAX::CheckViewParam hideView err."); + return false; + } + + return true; + } + + void RebootAndShutdownView::ChangeView(int16_t hideView, int16_t showView) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::ChangeView %d, %d", hideView, showView); + + if (!CheckViewParam(hideView, showView)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CheckViewParam failed."); + return; + } + + rebootAndShutdownGroupView[hideView]->SetVisible(false); + ClickFunc(showView); + rebootAndShutdownGroupView[showView]->SetVisible(true); + Draw(); + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp new file mode 100644 index 000000000..f993fafb3 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp @@ -0,0 +1,126 @@ +#include "rebootandshutdown/include/ShutDownImageAnimatorView.h" +#include "rebootandshutdown/include/RebootAndShutdownPresenter.h" +#include "wearable_log.h" +namespace OHOS +{ + + static ShutDownImageAnimatorView *g_pShutDownAnimatorView = nullptr; + ShutDownImageAnimatorView::ShutDownImageAnimatorView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownImageAnimatorView::ShutDownImageAnimatorView"); + g_pShutDownAnimatorView = this; + } + ShutDownImageAnimatorView::~ShutDownImageAnimatorView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownImageAnimatorView::~ShutDownImageAnimatorView"); + ClearAll(); + g_pShutDownAnimatorView = nullptr; + } + ShutDownImageAnimatorView *ShutDownImageAnimatorView::GetInstance() + { + return g_pShutDownAnimatorView; + } + + const char **ShutDownImageAnimatorView::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 ShutDownImageAnimatorView::FreeImagePathsArray(const char **imagePaths, const int numImages) + { + for (int i = 0; i < numImages; i++) + { + delete imagePaths[i]; + imagePaths[i] = nullptr; + } + } + + void ShutDownImageAnimatorView::ClearAll(void) + { + if (group != nullptr) + { + group->RemoveAll(); + if (shutDownImageAnimatorView != nullptr) + { + delete shutDownImageAnimatorView; + shutDownImageAnimatorView = nullptr; + } + FreeImagePathsArray(ShutDownPathsArray, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + delete group; + group = nullptr; + } + } + + UIImageAnimatorView *ShutDownImageAnimatorView::GeShutDownImageAnimatorView(void) + { + return shutDownImageAnimatorView; + } + + bool ShutDownImageAnimatorView::ShowUpShutDownAnimatorView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShutDownImageAnimatorView::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(RebootAndShutdownPresenter::GetInstance()); + if (stoplistener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create stoplistener!!"); + return false; + } + shutDownImageAnimatorView->SetAnimatorStopListener(stoplistener); + } + + return true; + } + + UIViewGroup *ShutDownImageAnimatorView::ShutDownAnimatorViewInit(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShutDownImageAnimatorView::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/include/ShutDownAnimatorView.h b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/ShutDownAnimatorView.h index 0dadf249d..3db74e6f9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/ShutDownAnimatorView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/ShutDownAnimatorView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-20 16:37:13 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-09 10:53:24 + * @LastEditTime: 2024-07-20 11:34:59 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/ShutDownAnimatorView.h */ @@ -14,13 +14,7 @@ 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/"; //关机图片路径 + class ShutDownAnimatorView { public: @@ -37,7 +31,7 @@ namespace OHOS void FreeImagePathsArray(const char **imagePaths, const int numImages); UIViewGroup *group{nullptr}; UIImageAnimatorView *ShutDownImageAnimatorView{nullptr}; // 关机动画 - ImageAnimatorInfo ShutDownImageInfo[SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 关机图像的信息 + ImageAnimatorInfo ShutDownImageInfo[30]; // 关机图像的信息 const char **ShutDownPathsArray{nullptr}; // 关机图片路径数组 }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootDeviceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootDeviceView.cpp index 97775804b..69751cab5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootDeviceView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootDeviceView.cpp @@ -65,7 +65,7 @@ bool RebootDeviceView::ShowUpRebootDeviceView() } rebootDeviceButton->SetPosition(172, 147, 110, 110); // 172:x 147:y 110:width 110:height rebootDeviceButton->SetImageSrc(PNG_SETTINGS_SETTTING_REBOOT, PNG_SETTINGS_SETTTING_REBOOT); - rebootDeviceButton->SetImagePosition(36, 36); + rebootDeviceButton->SetImagePosition(16, 16); rebootDeviceButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); rebootDeviceButton->SetViewId(REBOOTDEVICE_BUTTON); UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp index 874da317a..b24f0ba03 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-28 11:50:42 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-18 11:35:15 + * @LastEditTime: 2024-07-19 17:21:38 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp */ @@ -74,7 +74,7 @@ namespace OHOS } // 切换到关机/重启卡片 - NativeAbility::GetInstance().EnterSlice(VIEW_SHUTDOWN_OR_REBOOT); + NativeAbility::GetInstance().EnterSlice(VIEW_REBOOTANDSHUTDOWN); } /*注册电源键的长按事件*/ diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootView.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootView.cpp index f32328935..9b3afd211 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootView.cpp @@ -141,7 +141,7 @@ namespace OHOS } rebootButton->SetPosition(69, 147, 110, 110); // 69:x 147:y 110:width 110:height rebootButton->SetImageSrc(PNG_SETTINGS_SETTTING_REBOOT, PNG_SETTINGS_SETTTING_REBOOT); - rebootButton->SetImagePosition(36, 36); + rebootButton->SetImagePosition(16, 16); rebootButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); rebootButton->SetViewId(REBOOT_BUTTON); UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance(); @@ -183,7 +183,7 @@ namespace OHOS } shutdownButton->SetPosition(275, 147, 110, 110); // 275:x 147:y 110:width 110:height shutdownButton->SetImageSrc(PNG_SETTINGS_SETTTING_SHUTDOWN, PNG_SETTINGS_SETTTING_SHUTDOWN); - shutdownButton->SetImagePosition(36, 36); + shutdownButton->SetImagePosition(16, 16); shutdownButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36); shutdownButton->SetViewId(SHUTDOWN_BUTTON); UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutDownAnimatorView.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutDownAnimatorView.cpp index 953902f82..96f26b9a0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutDownAnimatorView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutDownAnimatorView.cpp @@ -4,6 +4,13 @@ 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() diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutdownDeviceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutdownDeviceView.cpp index 775d5ecf0..1fc6cda00 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutdownDeviceView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutdownDeviceView.cpp @@ -65,7 +65,7 @@ bool ShutdownDeviceView::ShowUpShutdownDeviceView() } shutdownDeviceButton->SetPosition(172, 147, 110, 110); // 172:x 147:y 110:width 110:height shutdownDeviceButton->SetImageSrc(PNG_SETTINGS_SETTTING_SHUTDOWN, PNG_SETTINGS_SETTTING_SHUTDOWN); - shutdownDeviceButton->SetImagePosition(36, 36); + shutdownDeviceButton->SetImagePosition(16, 16); shutdownDeviceButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36); shutdownDeviceButton->SetViewId(SHUTDOWNDEVICE_BUTTON); UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::RebootPresenter::GetInstance(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemFactoryResetView.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemFactoryResetView.cpp index c9ae12673..249133539 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemFactoryResetView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemFactoryResetView.cpp @@ -32,22 +32,22 @@ namespace OHOS if (initViewStatus == true) { scrollView->RemoveAll(); - + delete Title; - Title =nullptr; + Title = nullptr; delete FactoryResetImage; FactoryResetImage = nullptr; delete FactoryResetNote; FactoryResetNote = nullptr; - + delete FactoryResetButtonCheckOn; FactoryResetButtonCheckOn = nullptr; - + delete FactoryResetButtonCheckOff; FactoryResetButtonCheckOff = nullptr; - + delete scrollView; scrollView = nullptr; } @@ -63,7 +63,14 @@ namespace OHOS } scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - scrollView->SetStyle(STYLE_BORDER_RADIUS, 1294); + scrollView->SetStyle(STYLE_BORDER_RADIUS, 100); + UIView::OnDragListener *dragListener = static_cast(SystemPresenter::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemPresenter::GetInstance fail!!"); + return nullptr; + } + scrollView->SetOnDragListener(dragListener); /* ---------------------------------- Title --------------------------------- */ Title = new UILabelExt(); if (Title == nullptr) @@ -95,10 +102,10 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::new FactoryResetNote fail!"); return nullptr; } - FactoryResetNote->SetPosition(53, 228,360,70); + FactoryResetNote->SetPosition(53, 228, 360, 70); FactoryResetNote->SetStyle(STYLE_TEXT_FONT, 30); FactoryResetNote->SetStyle(STYLE_LINE_HEIGHT, 35); - //FactoryResetNote->SetText("该操作会清空并重置手表数据,是否确认继续?"); + // FactoryResetNote->SetText("该操作会清空并重置手表数据,是否确认继续?"); FactoryResetNote->SetTextId(STR_RESET_CONFIRM_NOTE); FactoryResetNote->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); FactoryResetNote->SetTextColor(Color::GetColorFromRGBA(0xff, 0x8a, 0x36, 0xff)); diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp index 81235e0eb..6bdf28783 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp @@ -181,7 +181,8 @@ namespace OHOS Title->SetStyle(STYLE_LINE_HEIGHT, 35); // Title->SetText("系统"); Title->SetTextId(STR_SYSTEM); - Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + Title->SetRollSpeed(70); Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); // Title->SetRollSpeed(6); Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang index a242fedb92864bf92dfa4b3af58531aa2f36695a..0cc6eea44aea6e3bd46fe1e537a999ab37b9ebdd 100644 GIT binary patch delta 76 zcmccN+vF$O;=8XuHID%W+}$Xe%g!1m&%ltext={zUMV;yGbL4_BwwL8qqHO?zdVlt NE>e`5l%HS1000nz754xD delta 35 fcmZqjyWuOU&~@J;HID%W+}h diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h index ede429db9..69218bc92 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h @@ -485,7 +485,9 @@ enum UIResourceTextId : uint16_t { STR_AIMODES_WENXINYIYAN = 472, STR_AIMODES_KIMI = 473, STR_AIMODES_CHATGPT = 474, - STR_MAX_ID = 475, + STR_SLIDE_TO_SHUTDOWN = 475, + STR_SLIDE_TO_REBOOT = 476, + STR_MAX_ID = 477, }; // UIResourceTextId enum FontLanguageId : uint8_t { diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang index 053d7e382fe277213dc47b21569c419423f5bb8b..d06ff68f305dbf3b93f4728efb32c4b46f3f78c0 100644 GIT binary patch delta 74 zcmX@=_SQ{w$3cF!stg7caCf6_tJ@IMRil?ocpUv5&U}whw O;lFI}eL7)1hz|gi799@& delta 35 fcmaFscGOLDi+0u0stg7caC@U@F8k&#_QTQux48*x diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/settings/SETTTING_REBOOT.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/settings/SETTTING_REBOOT.bin index de1a6473a..38ccdc9e9 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/settings/SETTTING_REBOOT.bin +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/settings/SETTTING_REBOOT.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8d8251031e42202a3917fa015c5a5c5837a2700993649af939847b79ef695205 -size 1144 +oid sha256:94e2a8c1bad2a01632f8feebcbdc71bd4de2947fa9b606f9adcea469ab118a28 +size 4504 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/settings/SETTTING_SHUTDOWN.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/settings/SETTTING_SHUTDOWN.bin index 87e284364..b25e53155 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/settings/SETTTING_SHUTDOWN.bin +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/settings/SETTTING_SHUTDOWN.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0cf041e325baf899b2bb7d95f1ff05bfb764333f10e49e38e6bcf0be9fa0d1b2 -size 1144 +oid sha256:66dad3548d7036af3d8b9c4a28b8effec69a257ec6ef64edb1e08b0f6509cf48 +size 4504 -- 2.17.1