屏幕与亮度视图完善,但亮屏时长视图选择一个按钮,打印日志中则显示选择两个,目前不知道什么原因
authorluozheng <1732036298@qq.com>
Sun, 18 Feb 2024 10:40:39 +0000 (18:40 +0800)
committerluozheng <1732036298@qq.com>
Sun, 18 Feb 2024 10:40:39 +0000 (18:40 +0800)
15 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/src/NativeLauncher.cpp
code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/BrightnessControlPresenter.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h
code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessView.h
code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/ScreenDurationPresenter.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/ScreenDurationView.h
code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlPresenter.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlView.cpp
code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp
code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp
code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/ScreenDurationPresenter.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/ScreenDurationView.cpp

index ca08340..0302837 100644 (file)
@@ -261,7 +261,6 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/BrightnessControlView.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/ScreenDurationPresenter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/ScreenDurationView.cpp
 
     #辅助功能
index 1ac9929..df179b5 100644 (file)
@@ -50,7 +50,6 @@ typedef enum : uint16_t
     VIEW_CALL_VOLUME,             // 通话音量
     VIEW_MEDIA_VOLUME,            // 媒体音量
     VIEW_DISPLAY_BRIGHTNESS,      // 屏幕与亮度
-    VIEW_SCREEN_DURATION,         // 亮屏时长
     VIEW_SECONDARY_FUNCTION,      // 辅助功能
     VIEW_QUICK_ACCESS,            // 快速访问
     VIEW_FAST_TRAINING,           // 快速训练
index 67c76d3..b2133eb 100644 (file)
@@ -56,8 +56,7 @@ namespace OHOS
         void InitMediaVolumeSlice(void);
         void InitMessageSlice(void);
         /* -------------------------------------------------------------------------- */
-        void InitUIDisplayBrightnessSlice(void);
-        void InitScreenDurationSlice(void);
+        void InitDisplayBrightnessSlice(void);
         /* --------------------------------测试界面------------------------------------ */
         void InitDialSlice(void);
         void InitBloodSlice(void);
index 81cb8d6..42f668e 100644 (file)
@@ -80,8 +80,6 @@
 
 #include "displaybrightness/include/DisplayBrightnessPresenter.h"
 #include "displaybrightness/include/DisplayBrightnessView.h"
-#include "displaybrightness/include/ScreenDurationPresenter.h"
-#include "displaybrightness/include/ScreenDurationView.h"
 
 #include "message/include/MessageAdapter.h"
 #include "message/include/MessageView.h"
@@ -146,9 +144,7 @@ namespace OHOS
         {VIEW_SOUND_VIBRATION, &NativeLauncher::InitSoundAndVibrationSlice},          // 声音与震动实例化地址
         {VIEW_SYSTEM_VOLUME, &NativeLauncher::InitSystemVolumeSlice},                 // 系统音量
 
-        {VIEW_DISPLAY_BRIGHTNESS, &NativeLauncher::InitUIDisplayBrightnessSlice}, // 显示与亮度的实例化地址
-        {VIEW_SCREEN_DURATION, &NativeLauncher::InitScreenDurationSlice},         // 亮屏时长实例化地址
-
+        {VIEW_DISPLAY_BRIGHTNESS, &NativeLauncher::InitDisplayBrightnessSlice}, // 显示与亮度的实例化地址
         {VIEW_SECONDARY_FUNCTION, &NativeLauncher::InitSecondaryFunction},
         {VIEW_QUICK_ACCESS, &NativeLauncher::InitQuickAccessSlice}, // 快速访问实例化地址
         {VIEW_FAST_TRAINING, &NativeLauncher::InitFastTrainingSlice},
@@ -548,7 +544,7 @@ namespace OHOS
     }
 
     // DisplayBrightness的实例化
-    void NativeLauncher::InitUIDisplayBrightnessSlice(void)
+    void NativeLauncher::InitDisplayBrightnessSlice(void)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitUISampleSlice");
         SliceProxy *uidisplaybrightnessView = new AbilitySliceProxy<DisplayBrightnessView, DisplayBrightnessPresenter>;
@@ -560,15 +556,6 @@ namespace OHOS
         NativeAbility::GetInstance().AddSliceProxy(VIEW_DISPLAY_BRIGHTNESS, uidisplaybrightnessView);
     }
 
-    void NativeLauncher::InitScreenDurationSlice(void)
-    {
-        SliceProxy *ScreenDuration = new AbilitySliceProxy<ScreenDurationView, ScreenDurationPresenter>;
-        if (ScreenDuration == nullptr)
-        {
-            return;
-        }
-        NativeAbility::GetInstance().AddSliceProxy(VIEW_SCREEN_DURATION, ScreenDuration);
-    }
 
     void NativeLauncher::InitSecondaryFunction(void) // 辅助功能
     {
diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/BrightnessControlPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/BrightnessControlPresenter.h
deleted file mode 100644 (file)
index 33f35b3..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef BRIGHTNESS_CONTROL_PRESENTER_H\r
-#define BRIGHTNESS_CONTROL_PRESENTER_H\r
-\r
-\r
-#include "Presenter.h"\r
- \r
-#include "BrightnessControlView.h"\r
- \r
-namespace OHOS\r
-{\r
-    class BrightnessControlView;\r
-       \r
-    class BrightnessControlPresenter : public Presenter<BrightnessControlView>,\r
-                                 public UIView::OnClickListener,\r
-                                 public UIView::OnDragListener\r
-    {\r
-    public:\r
-        BrightnessControlPresenter();\r
-        virtual ~BrightnessControlPresenter();\r
- \r
-        void OnStart() override;  \r
-        void OnPause() override;  \r
-        void OnResume() override; \r
-        void OnStop() override;   \r
- \r
-        static BrightnessControlPresenter *GetInstance();     \r
- \r
-    private:\r
-        //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
-        bool OnClick(UIView &view, const ClickEvent &event) override; \r
-        bool OnDrag(UIView &view, const DragEvent &event) override;   \r
-    };\r
-} //namespace OHOS\r
-\r
-\r
-\r
-#endif
\ No newline at end of file
index fb924aa..8a60fdd 100644 (file)
@@ -18,6 +18,27 @@ namespace OHOS
     static const char *BRINGHTNESSCONTROLBUTTON_VIEW = "BRINGHTNESSCONTROLBUTTON";                 // 亮度调节按钮视图id\r
     static const char *SCREENDURATIONBUTTON_VIEWID = "SCREENDURATIONBUTTON";                       // 亮屏时长按钮视图id\r
     static const char *RAISETOBRIGHTNESSCHECKBOXBUTTON_VIEWID = "RAISETOBRIGHTNESSCHECKBOXBUTTON"; // 抬腕亮屏checkbox按钮视图id\r
+\r
+    static const char *SCREENDURATION_FIVESECONDS_VIEWID = "SCREENDURATION_FIVESECONDS";       // 5秒时长\r
+    static const char *SCREENDURATION_TENSECONDS_VIEWID = "SCREENDURATION_TENSECONDS";         // 10秒时长\r
+    static const char *SCREENDURATION_FIFTEENSECONDS_VIEWID = "SCREENDURATION_FIFTEENSECONDS"; // 15秒时长\r
+\r
+    class ScreenDurationRadiobuttonOnChangeListener : public UICheckBox::OnChangeListener\r
+    {\r
+    public:\r
+        ScreenDurationRadiobuttonOnChangeListener(){}\r
+        ~ScreenDurationRadiobuttonOnChangeListener() {}\r
+        bool isRadioButtonSelected(int index);\r
+        void SetRadioButton(UIRadioButton *radiobutton, int16_t i)\r
+        {\r
+            m_radiobutton[i] = radiobutton;\r
+        }\r
+        bool OnChange(UICheckBox::UICheckBoxState state) override;\r
+\r
+    private:\r
+        UIRadioButton *m_radiobutton[3]{nullptr};\r
+    };\r
+\r
     class DisplayBrightnessView;\r
     class DisplayBrightnessPresenter : public Presenter<DisplayBrightnessView>,\r
                                        public UIView::OnClickListener,\r
index 0f5160c..ab6470f 100644 (file)
@@ -8,8 +8,10 @@
 #include "components/ui_button.h"\r
 #include "components/ui_scroll_view.h"\r
 #include "components/ui_checkbox.h"\r
+#include "components/ui_radio_button.h"\r
 #include "DisplayBrightnessPresenter.h"\r
 #include "displaybrightness/include/BrightnessControlView.h"\r
+#include "displaybrightness/include/ScreenDurationView.h"\r
 namespace OHOS\r
 {\r
 \r
@@ -66,6 +68,7 @@ namespace OHOS
         bool ClickFunc(int16_t interface);\r
         void ChangeView(int16_t hideView, int16_t showView);\r
         UIScrollView *GetDisplayBrightnessScrollView(int16_t i);\r
+\r
     public:\r
         void OnStart() override;\r
         void OnSetUpView() override;\r
@@ -74,6 +77,7 @@ namespace OHOS
 \r
     private:\r
         BrightnessControlView *p_BrightnessControlView{nullptr}; // 亮度调节视图\r
+        ScreenDurationView *p_ScreenDurationView{nullptr};       // 亮屏时长视图\r
     private:\r
         bool SetUpScrollView(void);\r
         bool SetTheTitle(void);\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/ScreenDurationPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/ScreenDurationPresenter.h
deleted file mode 100644 (file)
index 6d028fa..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef SCREEN_DUATION_PRESENTER_H\r
-#define SCREEN_DUATION_PRESENTER_H\r
-\r
-#include "Presenter.h"\r
-\r
-#include "ScreenDurationView.h"\r
-#include "components/ui_checkbox.h"\r
-#include "components/ui_label.h"\r
-namespace OHOS\r
-{\r
-    class ScreenDurationView;\r
-\r
-    class ScreenDurationPresenter : public Presenter<ScreenDurationView>,\r
-                                    public UIView::OnClickListener,\r
-                                    public UIView::OnDragListener\r
-    {\r
-    public:\r
-        ScreenDurationPresenter();\r
-        virtual ~ScreenDurationPresenter();\r
-\r
-        void OnStart() override;\r
-        void OnPause() override;\r
-        void OnResume() override;\r
-        void OnStop() override;\r
-        static ScreenDurationPresenter *GetInstance();\r
-        void getcheckbox(UICheckBox *checkbox_5,UICheckBox *checkbox_10,UICheckBox *checkbox_15){\r
-            m_checkbox_5 = checkbox_5;\r
-            m_checkbox_10 = checkbox_10;\r
-            m_checkbox_15 = checkbox_15;\r
-        }\r
-        void UpdateCheckBoxState(UICheckBox &checkbox, bool isSelected);\r
-    private:\r
-        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
-        bool OnClick(UIView &view, const ClickEvent &event) override;\r
-        bool OnDrag(UIView &view, const DragEvent &event) override;\r
-\r
-    private:\r
-        UICheckBox *m_checkbox_5 = nullptr;\r
-        UICheckBox *m_checkbox_10 = nullptr;\r
-        UICheckBox *m_checkbox_15 = nullptr;\r
-    };\r
-} // namespace OHOS\r
-\r
-#endif
\ No newline at end of file
index 2b99b64..e26e899 100644 (file)
@@ -1,44 +1,67 @@
 #ifndef SCREEN_DUATION_VIEW_H\r
 #define SCREEN_DUATION_VIEW_H\r
-//屏幕时长\r
+// 屏幕时长\r
 #include "BaseView.h"\r
 #include "View.h"\r
-#include "components/ui_view_group.h"\r
 #include "components/ui_scroll_view.h"\r
 #include "components/ui_image_view.h"\r
 #include "components/ui_label.h"\r
-#include "components/ui_checkbox.h"\r
+#include "components/ui_radio_button.h"\r
 namespace OHOS\r
 {\r
-    static const char *SECOND5_CHECKBOX = "5secCheckbox";   // 5秒\r
-    static const char *SECOND10_CHECKBOX = "10secCheckbox"; // 10秒\r
-    static const char *SECOND15_CHECKBOX = "15secCheckbox"; // 15秒\r
-    class ScreenDurationPresenter;\r
-    class ScreenDurationView : public View<ScreenDurationPresenter>\r
+    class ScreenDurationView\r
     {\r
-\r
     public:\r
+        struct ImageConfig\r
+        {\r
+            int16_t x;\r
+            int16_t y;\r
+            int16_t w;\r
+            int16_t h;\r
+            const char *ImageSrc;\r
+        };\r
+        struct LabelConfig\r
+        {\r
+            int16_t left;\r
+            int16_t top;\r
+            int16_t width;\r
+            int16_t height;\r
+            int16_t fontSize;      // 字体大小\r
+            int16_t lineHeigh;     // 行高\r
+            const char *text;      // 文本\r
+            uint8_t lineBreakMode; // 断行模式。\r
+        };\r
+        struct RadioButtonConfig\r
+        {\r
+            int16_t x;\r
+            int16_t y;\r
+            int16_t w;\r
+            int16_t h;\r
+            const char *viewId;\r
+            const char *select;\r
+            const char *unselect;\r
+        };\r
         ScreenDurationView();\r
         virtual ~ScreenDurationView();\r
         static ScreenDurationView *GetInstance(void);\r
-\r
-        void OnStart() override;\r
-        void OnSetUpView() override;\r
-        void OnTearDownView() override;\r
-        void OnStop() override;\r
-\r
-    public:\r
-        UICheckBox *second5checkbox = nullptr;\r
-        UICheckBox *second10checkbox = nullptr;\r
-        UICheckBox *second15checkbox = nullptr;\r
-\r
-    private:\r
-        void InitView(void);\r
+        UIScrollView *ScreenDurationViewInit(void);\r
+        void ClearAll(void);\r
+        UIRadioButton *GetRadioButton(int16_t i);\r
 \r
     private:\r
-        UIViewGroup *container_ = nullptr;\r
+        UIImageView *SetUpImageView(ImageConfig &imageconfig);                 // 设置图片\r
+        UILabel *SetUpLabel(LabelConfig &labelconfig);                         // 设置标签\r
+        UIRadioButton *SetUpRadioButton(RadioButtonConfig &radiobuttonconfig); // 设置单选框\r
+        bool SetUpScrollView(void);\r
+        bool SetUpScreenDurationViewLabel(void);\r
+        bool SetUpScreenDurationViewImageView(void);\r
+        bool SetUpScreenDurationViewRadioButton(void);\r
         UIScrollView *ScreenDurationScrollView = nullptr;\r
-        UILabel *ScreenDurationLabel = nullptr;\r
+        UILabel *ScreenDurationTitleLabel = nullptr;          // 标题\r
+        UILabel *ScreenDurationLabel[3]{nullptr};             // 亮屏时长标签\r
+        UIImageView *BackGroundImage[3]{nullptr};             // 放置组件的背景\r
+        UIRadioButton *ScreenDurationRadioButton[3]{nullptr}; // 三个单选框\r
+        bool initViewStatus{false};\r
     };\r
 } // namespace OHOS\r
 \r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlPresenter.cpp
deleted file mode 100644 (file)
index c9ffc6f..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#include "AppViewIDs.h"\r
-#include "NativeAbility.h"\r
-#include "graphic_math.h"\r
-#include "string.h"\r
-#include "displaybrightness/include/BrightnessControlPresenter.h"\r
-\r
-namespace OHOS{\r
- \r
-    //当前Presenter属性实例化的内存指针\r
-    static BrightnessControlPresenter *g_pBrightnessControlPresenter = nullptr; \r
-    \r
-    BrightnessControlPresenter::BrightnessControlPresenter(){\r
-               \r
-        g_pBrightnessControlPresenter = this;\r
-    }\r
- \r
-    BrightnessControlPresenter::~BrightnessControlPresenter(){\r
-    \r
-        g_pBrightnessControlPresenter = nullptr;\r
-    }\r
- \r
-    BrightnessControlPresenter *BrightnessControlPresenter::GetInstance(){\r
-    \r
-        return g_pBrightnessControlPresenter;\r
-    }\r
- \r
-    void BrightnessControlPresenter::OnStart(){\r
-    \r
-        Presenter<BrightnessControlView>::OnStart(); \r
-    }\r
- \r
-    void BrightnessControlPresenter::OnPause(void){\r
-    \r
-        Presenter<BrightnessControlView>::OnPause();\r
-    }\r
- \r
-    void BrightnessControlPresenter::OnResume(void){\r
-    \r
-        Presenter<BrightnessControlView>::OnResume();\r
-    }\r
- \r
-    void BrightnessControlPresenter::OnStop(void){\r
-    \r
-        Presenter<BrightnessControlView>::OnStop(); \r
-    }\r
- \r
-    bool BrightnessControlPresenter::OnDrag(UIView &view, const DragEvent &event){\r
-    \r
-        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&\r
-            (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))\r
-        {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_DISPLAY_BRIGHTNESS);//跳转到显示与亮度view\r
-        }\r
-        if(strcmp(view.GetViewId(), BRIGHTNESS_CONTROL_SLIDER))\r
-        {\r
-            \r
-        }\r
-        return true;\r
-    }\r
- \r
-    bool BrightnessControlPresenter::OnClick(UIView &view, const ClickEvent &event){\r
-    \r
-        // 根据控件id查找是哪个控件触发了点击回调\r
-        // if (strcmp(view.GetViewId(), 控件ID) == 0)\r
-        if(strcmp(view.GetViewId(), BRIGHTNESS_CONTROL_SLIDER))\r
-        {\r
-            \r
-        }\r
-        return true;\r
-    }\r
-}\r
-\r
-\r
-\r
-\r
-\r
-\r
index 94aaa7f..1ef39dc 100644 (file)
@@ -94,7 +94,7 @@ namespace OHOS
             return false;\r
         }\r
         BrightnessControlViewImageIcon->SetPosition(213, 213, 40, 40);\r
-        const char *image = "/user/res/VolumeControlVector.bin";\r
+        const char *image = "/user/res/BringhtnessContuolVector.bin";\r
         BrightnessControlViewImageIcon->SetSrc(image);\r
         return true;\r
     }\r
index a372edc..5d4d149 100644 (file)
@@ -61,7 +61,7 @@ namespace OHOS
         }\r
         if (strcmp(view.GetViewId(), SCREENDURATIONBUTTON_VIEWID) == 0)\r
         {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_SCREEN_DURATION); // 亮屏时长\r
+            p_DisplayBrightnessView->ChangeView(DISPLAYBRIGHTNESSVIEW, SCREENDURATIONVIEW); // 切换到亮屏时长视图\r
             return true;\r
         }\r
         return false;\r
@@ -79,7 +79,8 @@ namespace OHOS
         {\r
             for (int i = 0; i < MAX_DISPLAYBRIGHTNESSVIEWID; i++)\r
             {\r
-                if (p_DisplayBrightnessView->GetDisplayBrightnessScrollView(i)->IsVisible() == true)\r
+                if (p_DisplayBrightnessView->GetDisplayBrightnessScrollView(i) != nullptr &&\r
+                    p_DisplayBrightnessView->GetDisplayBrightnessScrollView(i)->IsVisible() == true)\r
                 {\r
                     if (i == DISPLAYBRIGHTNESSVIEW)\r
                     {\r
@@ -112,4 +113,48 @@ namespace OHOS
         }\r
         return true;\r
     }\r
+\r
+    bool ScreenDurationRadiobuttonOnChangeListener::isRadioButtonSelected(int index)\r
+    {\r
+        if (m_radiobutton[index]->GetState() == UICheckBox::SELECTED)\r
+        {\r
+            return true;\r
+        }\r
+        return false;\r
+    }\r
+\r
+    bool ScreenDurationRadiobuttonOnChangeListener::OnChange(UICheckBox::UICheckBoxState state)\r
+    {\r
+        switch (state)\r
+        {\r
+        case UICheckBox::SELECTED:\r
+            for (int i = 0; i < 3; i++)\r
+            {\r
+                if (isRadioButtonSelected(i))\r
+                {\r
+                    switch (i)\r
+                    {\r
+                    case 0:\r
+                        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Switched to 5 seconds");\r
+                        break;\r
+                    case 1:\r
+                        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Switched to 10 seconds");\r
+                        break;\r
+                    case 2:\r
+                        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Switched to 15 seconds");\r
+                        break;\r
+                    default:\r
+                        break;\r
+                    }\r
+                }\r
+            }\r
+        case UICheckBox::UNSELECTED:\r
+            // Handle unselected state if needed\r
+            break;\r
+        default:\r
+            break;\r
+        }\r
+\r
+        return true;\r
+    }\r
 }
\ No newline at end of file
index a2f6d53..6abc77d 100644 (file)
@@ -397,6 +397,19 @@ namespace OHOS
     // 3.切换到“亮屏时长”视图\r
     bool DisplayBrightnessView::ChangeScreenDurationView(int16_t thisView)\r
     {\r
+        if (DisplayBrightnessScrollView[thisView] == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessView::ChangeScreenDurationView");\r
+            p_ScreenDurationView = new ScreenDurationView();\r
+            if (p_ScreenDurationView == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessView:: new scrollView[%d] fail", thisView);\r
+                return false;\r
+            }\r
+            DisplayBrightnessScrollView[thisView] = p_ScreenDurationView->ScreenDurationViewInit();\r
+            RootView::GetInstance()->Add(DisplayBrightnessScrollView[thisView]);\r
+        }\r
+        return true;\r
     }\r
 \r
     /* -------------------------------------------------------------------------- */\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/ScreenDurationPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/ScreenDurationPresenter.cpp
deleted file mode 100644 (file)
index d3442cf..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-#include "AppViewIDs.h"\r
-#include "NativeAbility.h"\r
-#include "graphic_math.h"\r
-#include "string.h"\r
-#include "displaybrightness/include/ScreenDurationPresenter.h"\r
-#include "components/ui_checkbox.h"\r
-namespace OHOS\r
-{\r
-\r
-    // 当前Presenter属性实例化的内存指针\r
-    static ScreenDurationPresenter *g_pScreenDurationPresenter = nullptr;\r
-\r
-    ScreenDurationPresenter::ScreenDurationPresenter()\r
-    {\r
-\r
-        g_pScreenDurationPresenter = this;\r
-    }\r
-\r
-    ScreenDurationPresenter::~ScreenDurationPresenter()\r
-    {\r
-\r
-        g_pScreenDurationPresenter = nullptr;\r
-    }\r
-\r
-    ScreenDurationPresenter *ScreenDurationPresenter::GetInstance()\r
-    {\r
-\r
-        return g_pScreenDurationPresenter;\r
-    }\r
-\r
-    \r
-\r
-    void ScreenDurationPresenter::OnStart()\r
-    {\r
-\r
-        Presenter<ScreenDurationView>::OnStart();\r
-    }\r
-\r
-    void ScreenDurationPresenter::OnPause(void)\r
-    {\r
-\r
-        Presenter<ScreenDurationView>::OnPause();\r
-    }\r
-\r
-    void ScreenDurationPresenter::OnResume(void)\r
-    {\r
-\r
-        Presenter<ScreenDurationView>::OnResume();\r
-    }\r
-\r
-    void ScreenDurationPresenter::OnStop(void)\r
-    {\r
-\r
-        Presenter<ScreenDurationView>::OnStop();\r
-    }\r
-\r
-    bool ScreenDurationPresenter::OnDrag(UIView &view, const DragEvent &event)\r
-    {\r
-\r
-        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&\r
-            (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))\r
-        {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_DISPLAY_BRIGHTNESS); // 跳转到显示与亮度view\r
-        }\r
-        return true;\r
-    }\r
-   \r
-   \r
-\r
-    bool ScreenDurationPresenter::OnClick(UIView &view, const ClickEvent &event)\r
-    {\r
-        // 根据控件id查找是哪个控件触发了点击回调\r
-        if (strcmp(view.GetViewId(), SECOND5_CHECKBOX) == 0)\r
-        {\r
-            m_checkbox_5->SetState(UICheckBox::SELECTED);\r
-            UpdateCheckBoxState(*m_checkbox_10, false);\r
-            UpdateCheckBoxState(*m_checkbox_15, false);\r
-            return true;\r
-        }\r
-        else if (strcmp(view.GetViewId(), SECOND10_CHECKBOX) == 0)\r
-        {\r
-            m_checkbox_10->SetState(UICheckBox::SELECTED);\r
-            UpdateCheckBoxState(*m_checkbox_5, false);\r
-            UpdateCheckBoxState(*m_checkbox_15, false);\r
-        }\r
-        else if (strcmp(view.GetViewId(), SECOND15_CHECKBOX) == 0)\r
-        {\r
-            m_checkbox_15->SetState(UICheckBox::SELECTED);\r
-            UpdateCheckBoxState(*m_checkbox_5, false);\r
-            UpdateCheckBoxState(*m_checkbox_10, false);\r
-        }\r
-        return false;\r
-    }\r
-    void ScreenDurationPresenter::UpdateCheckBoxState(UICheckBox &checkbox, bool isSelected)\r
-    {\r
-        checkbox.SetState(isSelected ? UICheckBox::SELECTED : UICheckBox::UNSELECTED);\r
-    }\r
-}
\ No newline at end of file
index dbebfbc..6631a54 100644 (file)
@@ -1,7 +1,6 @@
 #include "displaybrightness/include/ScreenDurationView.h"\r
-#include "displaybrightness/include/ScreenDurationPresenter.h"\r
-#include "UiConfig.h"\r
-\r
+#include "displaybrightness/include/DisplayBrightnessPresenter.h"\r
+#include "wearable_log.h"\r
 namespace OHOS\r
 {\r
 \r
@@ -9,19 +8,14 @@ namespace OHOS
 \r
     ScreenDurationView::ScreenDurationView()\r
     {\r
-\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScreenDurationView::ScreenDurationView");\r
         g_pScreenDurationView = this;\r
     }\r
 \r
     ScreenDurationView::~ScreenDurationView()\r
     {\r
-        container_->RemoveAll();\r
-        delete ScreenDurationScrollView;\r
-        ScreenDurationScrollView = nullptr;\r
-        delete ScreenDurationLabel;\r
-        ScreenDurationLabel = nullptr;\r
-        delete container_;\r
-        container_ = nullptr;\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScreenDurationView::~ScreenDurationView");\r
+        ClearAll();\r
         g_pScreenDurationView = nullptr;\r
     }\r
 \r
@@ -30,242 +24,248 @@ namespace OHOS
         return g_pScreenDurationView;\r
     }\r
 \r
-    void ScreenDurationView::InitView(void)\r
+    void ScreenDurationView::ClearAll(void)\r
     {\r
-        if (container_ == nullptr)\r
+        if (initViewStatus == true)\r
         {\r
-            container_ = new UIViewGroup();\r
-            container_->SetPosition(0, 0, 466, 466);\r
-            container_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
-            UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(ScreenDurationPresenter::GetInstance());\r
-            if (draglistener == nullptr)\r
+            ScreenDurationScrollView->RemoveAll();\r
+\r
+            delete ScreenDurationTitleLabel;\r
+            ScreenDurationTitleLabel = nullptr;\r
+\r
+            for (int i = 0; i < 3; i++)\r
             {\r
-                return;\r
+                delete ScreenDurationLabel[i];\r
+                ScreenDurationLabel[i] = nullptr;\r
+\r
+                delete BackGroundImage[i];\r
+                BackGroundImage[i] = nullptr;\r
+\r
+                delete ScreenDurationRadioButton[i];\r
+                ScreenDurationRadioButton[i] = nullptr;\r
             }\r
-            container_->SetOnDragListener(draglistener);\r
-            container_->SetTouchable(true);\r
-            container_->SetDraggable(true);\r
+\r
+            delete ScreenDurationScrollView;\r
+            ScreenDurationScrollView = nullptr;\r
         }\r
+    }\r
 \r
-        // Add ScrollView to App\r
-        if (ScreenDurationScrollView == nullptr)\r
+    UIRadioButton *ScreenDurationView::GetRadioButton(int16_t i)\r
+    {\r
+        if (ScreenDurationRadioButton[i] == nullptr)\r
         {\r
-            ScreenDurationScrollView = new UIScrollView();\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScreenDurationView::ScreenDurationRadioButton[%d] is nullptr!", i);\r
+            return nullptr;\r
         }\r
-        ScreenDurationScrollView->SetPosition(0, 0);\r
-        ScreenDurationScrollView->Resize(466, 466);\r
-        ScreenDurationScrollView->SetViewId("ScreenDurationScrollView");\r
-        ScreenDurationScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        container_->Add(ScreenDurationScrollView);\r
-        ScreenDurationScrollView->SetVisible(true);\r
+        return ScreenDurationRadioButton[i];\r
+    }\r
 \r
-        // Add Label to App\r
-        if (ScreenDurationLabel == nullptr)\r
+    // 设置图片\r
+    UIImageView *ScreenDurationView::SetUpImageView(ImageConfig &imageconfig)\r
+    {\r
+        UIImageView *Image = new UIImageView();\r
+        if (Image == nullptr)\r
         {\r
-            ScreenDurationLabel = new UILabel();\r
+            return nullptr;\r
         }\r
-        ScreenDurationLabel->SetPosition(173, 52);             // widget's left position and top position\r
-        ScreenDurationLabel->Resize(120, 35);                  // widget's width and height\r
-        ScreenDurationLabel->SetViewId("ScreenDurationLabel"); // Set style\r
-        ScreenDurationLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
-        ScreenDurationLabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-\r
-        // Set additional property\r
-        ScreenDurationLabel->SetText("亮屏时长");\r
-        ScreenDurationLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        ScreenDurationLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        ScreenDurationLabel->SetRollSpeed(0);\r
-        ScreenDurationLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-\r
-        // Add to scrollView1\r
-        ScreenDurationScrollView->Add(ScreenDurationLabel);\r
-        ScreenDurationLabel->SetVisible(true);\r
-        /********************************************************************************************************/\r
-        // Add ImageView to App\r
-        UIImageView *secImage5 = new UIImageView();\r
-        secImage5->SetPosition(39, 120);\r
-        secImage5->Resize(380, 100);\r
-        secImage5->SetViewId("5secImage");\r
-        secImage5->SetStyle(STYLE_BORDER_RADIUS, 50);\r
-        secImage5->SetSrc(PNG_SETTING_BACKGROUND_IMAGE);\r
-        ScreenDurationScrollView->Add(secImage5);\r
-        secImage5->SetVisible(true);\r
-        // Add Label to App\r
-        UILabel *secLabel5 = new UILabel();\r
-        secLabel5->SetPosition(99, 153);\r
-        secLabel5->Resize(48, 35);\r
-        secLabel5->SetViewId("5secLabel");\r
-        secLabel5->SetStyle(STYLE_TEXT_FONT, 30);\r
-        secLabel5->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        secLabel5->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-        secLabel5->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-\r
-        secLabel5->SetText("5秒");\r
-        secLabel5->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        secLabel5->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        secLabel5->SetRollSpeed(6);\r
-        secLabel5->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-\r
-        ScreenDurationScrollView->Add(secLabel5);\r
-        secLabel5->SetVisible(true);\r
-\r
-        // Add CheckBox to App\r
-        second5checkbox = new UICheckBox();\r
-        second5checkbox->SetPosition(300, 130);\r
-        second5checkbox->Resize(80, 80);\r
-        second5checkbox->SetViewId(SECOND5_CHECKBOX);\r
-        second5checkbox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-        second5checkbox->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        second5checkbox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE);\r
-       \r
-        ScreenDurationScrollView->Add(second5checkbox);\r
-        second5checkbox->SetVisible(true);\r
-        /********************************************************************************************************/\r
-        // Add ImageView to App\r
-        UIImageView *secImage10 = new UIImageView();\r
-        secImage10->SetPosition(39, 240);\r
-        secImage10->Resize(380, 100);\r
-        secImage10->SetViewId("10secImage");\r
-        secImage10->SetStyle(STYLE_BORDER_RADIUS, 50);\r
-        secImage10->SetSrc(PNG_SETTING_BACKGROUND_IMAGE);\r
-        ScreenDurationScrollView->Add(secImage10);\r
-        secImage10->SetVisible(true);\r
-\r
-        // Add Label to App\r
-        UILabel *secLabel10 = new UILabel();\r
-        secLabel10->SetPosition(99, 273);\r
-        secLabel10->Resize(65, 35);\r
-        secLabel10->SetViewId("10secLabel");\r
-        secLabel10->SetStyle(STYLE_TEXT_FONT, 30);\r
-        secLabel10->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        secLabel10->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-        secLabel10->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-\r
-        secLabel10->SetText("10秒");\r
-        secLabel10->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        secLabel10->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        secLabel10->SetRollSpeed(6);\r
-        secLabel10->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-\r
-        ScreenDurationScrollView->Add(secLabel10);\r
-        secLabel10->SetVisible(true);\r
-\r
-        // Add CheckBox to App\r
-        second10checkbox = new UICheckBox();\r
-        second10checkbox->SetPosition(300, 250);\r
-        second10checkbox->Resize(80, 80);\r
-        second10checkbox->SetViewId(SECOND10_CHECKBOX);\r
-        second10checkbox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-        second10checkbox->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        second10checkbox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE);\r
-       \r
-        ScreenDurationScrollView->Add(second10checkbox);\r
-        second10checkbox->SetVisible(true);\r
-        /********************************************************************************************************/\r
-        // Add ImageView to App\r
-        UIImageView *secImage15 = new UIImageView();\r
-        secImage15->SetPosition(39, 360);\r
-        secImage15->Resize(380, 100);\r
-        secImage15->SetViewId("15secImage");\r
-        secImage15->SetStyle(STYLE_BORDER_RADIUS, 50);\r
-        secImage15->SetSrc(PNG_SETTING_BACKGROUND_IMAGE);\r
-        ScreenDurationScrollView->Add(secImage15);\r
-        secImage15->SetVisible(true);\r
-\r
-        // Add Label to App\r
-        UILabel *secLabel15 = new UILabel();\r
-        secLabel15->SetPosition(99, 393);\r
-        secLabel15->Resize(65, 35);\r
-        secLabel15->SetViewId("15secLabel");\r
-        secLabel15->SetStyle(STYLE_TEXT_FONT, 30);\r
-        secLabel15->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        secLabel15->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-        secLabel15->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-\r
-        secLabel15->SetText("15秒");\r
-        secLabel15->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        secLabel15->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        secLabel15->SetRollSpeed(6);\r
-        secLabel15->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-\r
-        ScreenDurationScrollView->Add(secLabel15);\r
-        secLabel15->SetVisible(true);\r
-\r
-        // Add CheckBox to App\r
-        second15checkbox = new UICheckBox();\r
-        second15checkbox->SetPosition(300, 370);\r
-        second15checkbox->Resize(80, 80);\r
-        second15checkbox->SetViewId(SECOND15_CHECKBOX);\r
-        second15checkbox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-        second15checkbox->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        second15checkbox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE);\r
-       \r
-        ScreenDurationScrollView->Add(second15checkbox);\r
-        second15checkbox->SetVisible(true);\r
-        /********************************************************************************************************/\r
-        // AddLabelImageViewCheckbox(ScreenDurationScrollView, 99, 153, 48, 35, "5秒", "5secLabel",\r
-        //                           39, 120, 380, 100, "5secImage", PNG_SETTING_BACKGROUND_IMAGE,\r
-        //                           second5checkbox, 300, 130, 80, 80, SECOND5_CHECKBOX, PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE);\r
-        /*\r
-        AddLabelImageViewCheckbox(ScreenDurationScrollView, 99, 273, 65, 35, "10秒", "10secLabel",\r
-                                  39, 240, 380, 100, "10secImage", PNG_SETTING_BACKGROUND_IMAGE,\r
-                                  second10checkbox, 300, 250, 80, 80, SECOND10_CHECKBOX, PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE);\r
-       \r
-        AddLabelImageViewCheckbox(ScreenDurationScrollView, 99, 393, 65, 35, "15秒", "15secLabel",\r
-                                  39, 360, 380, 100, "15secImage", PNG_SETTING_BACKGROUND_IMAGE,\r
-                                  second15checkbox, 300, 370, 80, 80, SECOND15_CHECKBOX, PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE);\r
-        */\r
-        \r
-        /********************************************************************************************************/\r
-        UIImageView *image1_ = new UIImageView();\r
-\r
-        image1_->SetPosition(183, 440);\r
-        image1_->Resize(100, 100);\r
-        image1_->SetViewId("image1");\r
-        ScreenDurationScrollView->Add(image1_);\r
-        image1_->SetVisible(true);\r
-        /********************************************************************************************************/\r
-\r
-        UIImageView *image2_ = new UIImageView();\r
+        Image->SetPosition(imageconfig.x, imageconfig.y, imageconfig.w, imageconfig.h);\r
+        Image->SetSrc(imageconfig.ImageSrc);\r
+        return Image;\r
+    }\r
 \r
-        image2_->SetPosition(183, 19);\r
-        image2_->Resize(100, 100);\r
-        image2_->SetViewId("image2");\r
-        ScreenDurationScrollView->Add(image2_);\r
-        image2_->SetVisible(true);\r
+    // 设置标签\r
+    UILabel *ScreenDurationView::SetUpLabel(LabelConfig &labelconfig)\r
+    {\r
+        UILabel *label = new UILabel();\r
+        if (label == nullptr)\r
+        {\r
+            return nullptr;\r
+        }\r
+        label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); // 位置大小\r
+        label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize);                                       // 字体大小\r
+        label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh);                                    // 字体行高\r
+        label->SetText(labelconfig.text);                                                             // 内容\r
+        label->SetLineBreakMode(labelconfig.lineBreakMode);                                           // 断行模式。\r
+        label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+        label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);\r
+        return label;\r
+    }\r
 \r
-        ScreenDurationPresenter::GetInstance()->getcheckbox(second5checkbox,second10checkbox,second15checkbox);\r
-        UIView::OnClickListener *checkboxClick = static_cast<UIView::OnClickListener *>(ScreenDurationPresenter::GetInstance());\r
-        second5checkbox->SetOnClickListener(checkboxClick);\r
-        second10checkbox->SetOnClickListener(checkboxClick);\r
-        second15checkbox->SetOnClickListener(checkboxClick);\r
+    // 设置单选框\r
+    UIRadioButton *ScreenDurationView::SetUpRadioButton(RadioButtonConfig &radiobuttonconfig)\r
+    {\r
+        UIRadioButton *radiobutton = new UIRadioButton("ScreenDuration");\r
+        if (nullptr == radiobutton)\r
+        {\r
+            return nullptr;\r
+        }\r
+        radiobutton->SetPosition(radiobuttonconfig.x, radiobuttonconfig.y, radiobuttonconfig.w, radiobuttonconfig.h);\r
+        radiobutton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
+        radiobutton->SetImages(radiobuttonconfig.select, radiobuttonconfig.unselect);\r
+        return radiobutton;\r
     }\r
 \r
-    void ScreenDurationView::OnStart()\r
+    // 亮屏时长视图“scrollView”初始化\r
+    bool ScreenDurationView::SetUpScrollView(void)\r
     {\r
-        View<ScreenDurationPresenter>::OnStart();\r
-        InitView();\r
-        RootView::GetInstance()->Add(container_);\r
+        ScreenDurationScrollView = new UIScrollView();\r
+        if (ScreenDurationScrollView == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScreenDurationView::ScreenDurationScrollView new fail!");\r
+            return false;\r
+        }\r
+        ScreenDurationScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+        ScreenDurationScrollView->SetScrollBlankSize(35);\r
+        ScreenDurationScrollView->SetReboundSize(50);\r
+        ScreenDurationScrollView->SetDirection(1);\r
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(DisplayBrightnessPresenter::GetInstance());\r
+        if (draglistener == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScreenDurationView::draglistener can not be nullptr!");\r
+            return false;\r
+        }\r
+        ScreenDurationScrollView->SetOnDragListener(draglistener);\r
+        ScreenDurationScrollView->SetTouchable(true);\r
+        ScreenDurationScrollView->SetDraggable(true);\r
+        return true;\r
     }\r
 \r
-    void ScreenDurationView::OnSetUpView()\r
+    // 亮屏时长视图“图片”初始化\r
+    bool ScreenDurationView::SetUpScreenDurationViewImageView(void)\r
     {\r
-        View<ScreenDurationPresenter>::OnSetUpView();\r
-        Draw();\r
+        ImageConfig imageconfig = {\r
+            .x = 39,\r
+            .y = 120,\r
+            .w = 380,\r
+            .h = 100,\r
+            .ImageSrc = "/user/res/SETTING_BACKGROUND.bin",\r
+        };\r
+\r
+        for (int i = 0; i < 3; i++)\r
+        {\r
+            imageconfig.y = 120 + (i * 120);\r
+            BackGroundImage[i] = SetUpImageView(imageconfig);\r
+            if (BackGroundImage[i] == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScreenDurationView::BackGroundImage[%d] is nullptr!", i);\r
+                return false;\r
+            }\r
+        }\r
+        return true;\r
     }\r
 \r
-    void ScreenDurationView::OnTearDownView()\r
+    // 亮屏时长视图“标签”初始化\r
+    bool ScreenDurationView::SetUpScreenDurationViewLabel(void)\r
     {\r
+        // 创建ScreenDurationTitleLabel\r
+        LabelConfig labelconfig = {\r
+            .left = 173,\r
+            .top = 52,\r
+            .width = 120,\r
+            .height = 35,\r
+            .fontSize = 30,\r
+            .lineHeigh = 35,\r
+            .text = "亮屏时长",\r
+            .lineBreakMode = UILabel::LINE_BREAK_ADAPT,\r
+        };\r
+\r
+        ScreenDurationTitleLabel = SetUpLabel(labelconfig);\r
+        if (nullptr == ScreenDurationTitleLabel)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScreenDurationView::SetUpScreenDurationViewLabel is nullptr!");\r
+            return false;\r
+        }\r
+\r
+        // 创建ScreenDurationLabel\r
+        labelconfig = {\r
+            .left = 99,\r
+            .fontSize = 30,\r
+            .lineHeigh = 35,\r
+            .lineBreakMode = UILabel::LINE_BREAK_ADAPT,\r
+        };\r
+\r
+        const char *durations[] = {"5秒", "10秒", "15秒"};\r
+\r
+        for (int i = 0; i < 3; i++)\r
+        {\r
+            labelconfig.top = 153 + (i * 120);\r
+            labelconfig.text = durations[i];\r
+            ScreenDurationLabel[i] = SetUpLabel(labelconfig);\r
+            if (ScreenDurationLabel[i] == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScreenDurationView::ScreenDurationLabel[%d] is nullptr!", i);\r
+                return false;\r
+            }\r
+        }\r
 \r
-        View<ScreenDurationPresenter>::OnTearDownView();\r
-        return;\r
+        return true;\r
     }\r
 \r
-    void ScreenDurationView::OnStop()\r
+    // 亮屏时长视图“单选框”初始化\r
+    bool ScreenDurationView::SetUpScreenDurationViewRadioButton(void)\r
     {\r
+        RadioButtonConfig radiobuttonconfig = {\r
+            .x = 300,\r
+            .w = 80,\r
+            .h = 80,\r
+            .select = "/user/res/CHECKBOX_ON.bin",\r
+            .unselect = "/user/res/CHECKBOX_OFF.bin",\r
+        };\r
+\r
+        int y_positions[] = {130, 250, 370};\r
+        const char *viewID[] = {SCREENDURATION_FIVESECONDS_VIEWID, SCREENDURATION_TENSECONDS_VIEWID, SCREENDURATION_FIFTEENSECONDS_VIEWID};\r
+        ScreenDurationRadiobuttonOnChangeListener *p_ScreenDurationRadiobuttonOnChangeListener = new ScreenDurationRadiobuttonOnChangeListener();\r
+        UICheckBox::OnChangeListener *SimplifiedChineseRadioButtonChange = static_cast<UICheckBox::OnChangeListener *>(p_ScreenDurationRadiobuttonOnChangeListener);\r
+        for (int i = 0; i < 3; i++)\r
+        {\r
+            radiobuttonconfig.y = y_positions[i];\r
+            radiobuttonconfig.viewId = viewID[i];\r
+            ScreenDurationRadioButton[i] = SetUpRadioButton(radiobuttonconfig);\r
+            if (ScreenDurationRadioButton[i] == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScreenDurationView::ScreenDurationRadioButton[%d] is nullptr!", i);\r
+                return false;\r
+            }\r
+            p_ScreenDurationRadiobuttonOnChangeListener->SetRadioButton(ScreenDurationRadioButton[i],i);\r
+            ScreenDurationRadioButton[i]->SetOnChangeListener(SimplifiedChineseRadioButtonChange);\r
+        }\r
 \r
-        View<ScreenDurationPresenter>::OnStop();\r
-        RootView::GetInstance()->RemoveAll();\r
-        return;\r
+        return true;\r
+    }\r
+\r
+    // 亮屏时长视图初始化\r
+    UIScrollView *ScreenDurationView::ScreenDurationViewInit(void)\r
+    {\r
+        /* ------------------------ ScreenDurationScrollView ------------------------ */\r
+        if (!SetUpScrollView())\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScreenDurationView::ScreenDurationScrollView is nullptr!");\r
+            return nullptr;\r
+        }\r
+        /* ----------------------------- BackGroundImage[] ---------------------------- */\r
+        if (!SetUpScreenDurationViewImageView())\r
+        {\r
+            return nullptr;\r
+        }\r
+        /* -------------------------- ScreenDurationLabel[] ------------------------- */\r
+        if (!SetUpScreenDurationViewLabel())\r
+        {\r
+            return nullptr;\r
+        }\r
+        /* ----------------------- ScreenDurationRadioButton[] ---------------------- */\r
+        if (!SetUpScreenDurationViewRadioButton())\r
+        {\r
+            return nullptr;\r
+        }\r
+        /* ----------------------------------- Add ---------------------------------- */\r
+        ScreenDurationScrollView->Add(ScreenDurationTitleLabel);\r
+        for (int i = 0; i < 3; i++)\r
+        {\r
+            ScreenDurationScrollView->Add(BackGroundImage[i]);\r
+            ScreenDurationScrollView->Add(ScreenDurationLabel[i]);\r
+            ScreenDurationScrollView->Add(ScreenDurationRadioButton[i]);\r
+        }\r
+        initViewStatus = true;\r
+        return ScreenDurationScrollView;\r
     }\r
 }
\ No newline at end of file