Merge #561 into sdk602patch0626 from refs/changes/561/head 563/target/2 565/target/1
author罗正 <1732036298@qq.com>
Sat, 20 Jul 2024 08:21:17 +0000 (08:21 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Sat, 20 Jul 2024 08:21:17 +0000 (08:21 +0000)
Code review from 罗正

* refs/changes/561/head: (5 commits squashed)

  - 添加滑动关机和重启功能:
    恢复出厂设置未加
    目前是长按才是滑动关机和重启

  - Merge branch &#39;sdk602patch0626&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626

  - 滑动关机和重启添加恢复出厂设置功能

  - Merge branch &#39;sdk602patch0626&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626

  - 滑动关机和重启界面多国语言修改

Signed-off-by: 罗正 <1732036298@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/561
35 files changed:
code/sdk/application/wearable/fd230app/CMakeLists.txt
code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h
code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h
code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h
code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp
code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt
code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt
code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml
code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml
code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang
code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h
code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/FactoryResetView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/ShutDownImageAnimatorView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/FactoryResetView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/ShutDownAnimatorView.h
code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootDeviceView.cpp
code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp
code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootView.cpp
code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutDownAnimatorView.cpp
code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/ShutdownDeviceView.cpp
code/sdk/application/wearable/fd230app/nativeui/system/src/SystemFactoryResetView.cpp
code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/settings/SETTTING_REBOOT.bin
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/settings/SETTTING_SHUTDOWN.bin

index 6b80332..d7829cc 100644 (file)
@@ -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
index 457c5a6..0551fae 100644 (file)
@@ -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,           // 切换表盘
index dd4724c..212e3ee 100644 (file)
@@ -63,6 +63,7 @@ namespace OHOS
         void InitThemeStyleSlice(void);
         void InitAiVoiceSlice(void);
         void InitAiModelsSlice(void);
+        void InitRebootAndShutdownSlice(void);
         /* --------------------------------界面------------------------------------ */
         void InitRotateSlice(void);
         void InitBloodSlice(void);
index d7d2106..9c6e32b 100644 (file)
@@ -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 <cstdint>
-namespace OHOS {
-enum UIResourceTextId : uint16_t {
+/*\r
+* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved.\r
+* Description: language\r
+* Author: Graphic develop team\r
+* Create: 2021-07-06\r
+*/\r
+\r
+#ifndef UI_RESOURCE_STRING_H\r
+#define UI_RESOURCE_STRING_H\r
+#include <cstdint>\r
+namespace OHOS {\r
+enum UIResourceTextId : uint16_t {\r
     STR_EXERCISE_OUTDOORWALKING = 0,\r
     STR_EXERCISE_OUTDOORRUNNING = 1,\r
     STR_EXERCISE_OUTDOORBIKING = 2,\r
@@ -485,12 +485,14 @@ enum UIResourceTextId : uint16_t {
     STR_AIMODES_WENXINYIYAN = 472,\r
     STR_AIMODES_KIMI = 473,\r
     STR_AIMODES_CHATGPT = 474,\r
-    STR_MAX_ID = 475,\r
+    STR_SLIDE_TO_SHUTDOWN = 475,\r
+    STR_SLIDE_TO_REBOOT = 476,\r
+    STR_MAX_ID = 477,\r
 }; // UIResourceTextId\r
-
-enum FontLanguageId : uint8_t {
-    LANGUAGE_ID_ZH,\r
+\r
+enum FontLanguageId : uint8_t {\r
     LANGUAGE_ID_EN,\r
+    LANGUAGE_ID_ZH,\r
     LANGUAGE_ID_MAX\r
 }; // UITextLanguageTextId\r
 }\r
index 31606ce..2da9566 100644 (file)
 
 #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<RebootAndShutdownView, RebootAndShutdownPresenter>;
+        if (rebootandshutdown == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootandshutdown");
+            return;
+        }
+        NativeAbility::GetInstance().AddSliceProxy(VIEW_REBOOTANDSHUTDOWN, rebootandshutdown);
+    }
     /* -------------------------------------------------------------------------- */
 
     void NativeLauncher::InitSetCardSlice(void)
index bd842a6..969dd69 100644 (file)
@@ -472,4 +472,6 @@ STR_CONTINUE_CHAT$Continue the conversation
 STR_AIMODELS_DOUBAO$Cici\r
 STR_AIMODES_WENXINYIYAN$ERNIE Bot\r
 STR_AIMODES_KIMI$Kimi\r
-STR_AIMODES_CHATGPT$ChatGPT
\ No newline at end of file
+STR_AIMODES_CHATGPT$ChatGPT\r
+STR_SLIDE_TO_SHUTDOWN$Slide to shutdown\r
+STR_SLIDE_TO_REBOOT$Slide to reboot
\ No newline at end of file
index 407425a..099b258 100644 (file)
@@ -472,4 +472,6 @@ STR_CONTINUE_CHAT$继续对话
 STR_AIMODELS_DOUBAO$豆包\r
 STR_AIMODES_WENXINYIYAN$文心一言\r
 STR_AIMODES_KIMI$Kimi\r
-STR_AIMODES_CHATGPT$ChatGPT
\ No newline at end of file
+STR_AIMODES_CHATGPT$ChatGPT\r
+STR_SLIDE_TO_SHUTDOWN$滑动关机 >>\r
+STR_SLIDE_TO_REBOOT$滑动重启 >>
\ No newline at end of file
index be26e19..08bd8e4 100644 (file)
        <lanstr id="STR_AIMODES_WENXINYIYAN" value="ERNIE Bot"/>
        <lanstr id="STR_AIMODES_KIMI" value="Kimi"/>
        <lanstr id="STR_AIMODES_CHATGPT" value="ChatGPT"/>
+       <lanstr id="STR_SLIDE_TO_SHUTDOWN" value="Slide to shutdown"/>
+       <lanstr id="STR_SLIDE_TO_REBOOT" value="Slide to reboot"/>
 </language>
index 0ea317f..8bb63aa 100644 (file)
        <lanstr id="STR_AIMODES_WENXINYIYAN" value="文心一言"/>
        <lanstr id="STR_AIMODES_KIMI" value="Kimi"/>
        <lanstr id="STR_AIMODES_CHATGPT" value="ChatGPT"/>
+       <lanstr id="STR_SLIDE_TO_SHUTDOWN" value="滑动关机 &gt;&gt;"/>
+       <lanstr id="STR_SLIDE_TO_REBOOT" value="滑动重启 &gt;&gt;"/>
 </language>
index a242fed..0cc6eea 100644 (file)
Binary files a/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang and b/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang differ
index ede429d..69218bc 100644 (file)
@@ -485,7 +485,9 @@ enum UIResourceTextId : uint16_t {
     STR_AIMODES_WENXINYIYAN = 472,\r
     STR_AIMODES_KIMI = 473,\r
     STR_AIMODES_CHATGPT = 474,\r
-    STR_MAX_ID = 475,\r
+    STR_SLIDE_TO_SHUTDOWN = 475,\r
+    STR_SLIDE_TO_REBOOT = 476,\r
+    STR_MAX_ID = 477,\r
 }; // UIResourceTextId\r
 
 enum FontLanguageId : uint8_t {
index 053d7e3..d06ff68 100644 (file)
Binary files a/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang and b/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang differ
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 (file)
index 0000000..d6199e5
--- /dev/null
@@ -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 (file)
index 0000000..3e1f048
--- /dev/null
@@ -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 (file)
index 0000000..b623075
--- /dev/null
@@ -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<RebootAndShutdownView>,
+                                       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 (file)
index 0000000..548ea4e
--- /dev/null
@@ -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<RebootAndShutdownPresenter>
+    {
+
+    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 (file)
index 0000000..a779a77
--- /dev/null
@@ -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 (file)
index 0000000..b09d102
--- /dev/null
@@ -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<UIView::OnDragListener *>(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<UIView::OnClickListener *>(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<UIView::OnClickListener *>(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 (file)
index 0000000..2e9fbbe
--- /dev/null
@@ -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 (file)
index 0000000..a1f1075
--- /dev/null
@@ -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 <custom_utils.h>
+#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<RebootAndShutdownView>::OnStart();
+    }
+
+    // 页面已经展示后的调用逻辑
+    void RebootAndShutdownPresenter::OnResume(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnResume");
+        Presenter<RebootAndShutdownView>::OnResume();
+        if (view_ == nullptr)
+        {
+            return;
+        }
+    }
+
+    // 页面准备切换到后台前执行的逻辑
+    void RebootAndShutdownPresenter::OnPause(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnPause");
+        Presenter<RebootAndShutdownView>::OnPause();
+    }
+
+    // 页面完全置于后台时的逻辑。
+    void RebootAndShutdownPresenter::OnStop(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnStop");
+        Presenter<RebootAndShutdownView>::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<UISlider *>(&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<uint16_t>(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 (file)
index 0000000..19caa95
--- /dev/null
@@ -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<RebootAndShutdownPresenter>::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<RebootAndShutdownPresenter>::OnSetUpView();
+        Draw();
+        return;
+    }
+
+    void RebootAndShutdownView::OnTearDownView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::OnTearDownView");
+        View<RebootAndShutdownPresenter>::OnTearDownView();
+        return;
+    }
+
+    void RebootAndShutdownView::OnStop()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::OnStop");
+        View<RebootAndShutdownPresenter>::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 (file)
index 0000000..f993faf
--- /dev/null
@@ -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<UIImageAnimatorView::AnimatorStopListener *>(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
index 0dadf24..3db74e6 100644 (file)
@@ -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
  */
 
 
 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};                                     // 关机图片路径数组
     };
 }
index 9777580..69751ca 100644 (file)
@@ -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();
index 874da31..b24f0ba 100644 (file)
@@ -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);
     }
 
     /*注册电源键的长按事件*/
index f323289..9b3afd2 100644 (file)
@@ -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();
index 953902f..96f26b9 100644 (file)
@@ -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()
index 775d5ec..1fc6cda 100644 (file)
@@ -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();
index c9ae126..2491335 100644 (file)
@@ -32,22 +32,22 @@ namespace OHOS
         if (initViewStatus == true)\r
         {\r
             scrollView->RemoveAll();\r
-            \r
+\r
             delete Title;\r
-            Title =nullptr;\r
+            Title = nullptr;\r
 \r
             delete FactoryResetImage;\r
             FactoryResetImage = nullptr;\r
 \r
             delete FactoryResetNote;\r
             FactoryResetNote = nullptr;\r
-            \r
+\r
             delete FactoryResetButtonCheckOn;\r
             FactoryResetButtonCheckOn = nullptr;\r
-            \r
+\r
             delete FactoryResetButtonCheckOff;\r
             FactoryResetButtonCheckOff = nullptr;\r
-            \r
+\r
             delete scrollView;\r
             scrollView = nullptr;\r
         }\r
@@ -63,7 +63,14 @@ namespace OHOS
         }\r
         scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
         scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        scrollView->SetStyle(STYLE_BORDER_RADIUS, 1294);\r
+        scrollView->SetStyle(STYLE_BORDER_RADIUS, 100);\r
+        UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(SystemPresenter::GetInstance());\r
+        if (dragListener == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemPresenter::GetInstance fail!!");\r
+            return nullptr;\r
+        }\r
+        scrollView->SetOnDragListener(dragListener);\r
         /* ---------------------------------- Title --------------------------------- */\r
         Title = new UILabelExt();\r
         if (Title == nullptr)\r
@@ -95,10 +102,10 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::new FactoryResetNote fail!");\r
             return nullptr;\r
         }\r
-        FactoryResetNote->SetPosition(53, 228,360,70); \r
+        FactoryResetNote->SetPosition(53, 228, 360, 70);\r
         FactoryResetNote->SetStyle(STYLE_TEXT_FONT, 30);\r
         FactoryResetNote->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-        //FactoryResetNote->SetText("该操作会清空并重置手表数据,是否确认继续?");\r
+        // FactoryResetNote->SetText("该操作会清空并重置手表数据,是否确认继续?");\r
         FactoryResetNote->SetTextId(STR_RESET_CONFIRM_NOTE);\r
         FactoryResetNote->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);\r
         FactoryResetNote->SetTextColor(Color::GetColorFromRGBA(0xff, 0x8a, 0x36, 0xff));\r
index 81235e0..6bdf287 100644 (file)
@@ -181,7 +181,8 @@ namespace OHOS
         Title->SetStyle(STYLE_LINE_HEIGHT, 35);\r
         // Title->SetText("系统");\r
         Title->SetTextId(STR_SYSTEM);\r
-        Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
+        Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);\r
+        Title->SetRollSpeed(70);\r
         Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
         // Title->SetRollSpeed(6);\r
         Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
index a242fed..0cc6eea 100644 (file)
Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang differ
index ede429d..69218bc 100644 (file)
@@ -485,7 +485,9 @@ enum UIResourceTextId : uint16_t {
     STR_AIMODES_WENXINYIYAN = 472,\r
     STR_AIMODES_KIMI = 473,\r
     STR_AIMODES_CHATGPT = 474,\r
-    STR_MAX_ID = 475,\r
+    STR_SLIDE_TO_SHUTDOWN = 475,\r
+    STR_SLIDE_TO_REBOOT = 476,\r
+    STR_MAX_ID = 477,\r
 }; // UIResourceTextId\r
 
 enum FontLanguageId : uint8_t {
index 053d7e3..d06ff68 100644 (file)
Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang differ