修改声音与震动视图
author罗正yun <1732036298@qq.com>
Mon, 29 Jan 2024 10:29:14 +0000 (18:29 +0800)
committer罗正yun <1732036298@qq.com>
Mon, 29 Jan 2024 10:29:14 +0000 (18:29 +0800)
12 files changed:
code/sdk/application/wearable/fd230app/CMakeLists.txt
code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumeView.h
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp
code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SoundAndVibration/CALL_VOLUME.bin [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/CALL_VOLUME.bin with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SoundAndVibration/MEDIA_VOLUME.bin [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/MEDIA_VOLUME.bin with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SoundAndVibration/SYSTEM_VOLUME.bin [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SYSTEM_VOLUME.bin with 100% similarity]

index bdadde9..d709cfd 100644 (file)
@@ -236,7 +236,8 @@ set(SOURCES
 
     #声音与震动
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp 
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationView.cpp      
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp      
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SystemVolumePresenter.cpp           
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SystemVolumeView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/CallVolumePresenter.cpp           
index 8f3f0b2..23b21e0 100644 (file)
@@ -284,9 +284,7 @@ namespace OHOS
     static constexpr const char *PNG_SYSTEM_CHECK_OFF_IMAGE = APP_RES_PATH "/SYSTEM_CheckOff.bin";              // 叉
     static constexpr const char *PNG_TOGGLEBUTTON_OFF_IMAGE = APP_RES_PATH "/TOGGLEBUTTON_OFF.bin";             // togglebuttton未选中图片
     static constexpr const char *PNG_TOGGLEBUTTON_ON_IMAGE = APP_RES_PATH "/TOGGLEBUTTON_ON.bin";               // togglebuttton选中图片
-    static constexpr const char *PNG_SYSTEM_VOLUME_IMAGE = APP_RES_PATH "/SYSTEM_VOLUME.bin";                   // 系统音量
-    static constexpr const char *PNG_CALL_VOLUME_IMAGE = APP_RES_PATH "/CALL_VOLUME.bin";                       // 通话音量
-    static constexpr const char *PNG_MEDIA_VOLUME_IMAGE = APP_RES_PATH "/MEDIA_VOLUME.bin";                     // 媒体音量
+    
     static constexpr const char *PNG_ORANGE_ATTENTION_VECTOR_IMAGE = APP_RES_PATH "/OrangeAttentionVector.bin"; // 橘黄色感叹号图标
     static constexpr const char *PNG_ANIMATOR1_IMAGE = APP_RES_PATH "/Record/animator1.bin";
     static constexpr const char *PNG_ANIMATOR2_IMAGE = APP_RES_PATH "/Record/animator2.bin";
index cc4d90a..1897a02 100644 (file)
@@ -3,8 +3,6 @@
 \r
 #include "BaseView.h"\r
 #include "View.h"\r
-\r
-#include "components/ui_view_group.h"\r
 #include "components/ui_scroll_view.h"\r
 #include "components/ui_label.h"\r
 #include "components/ui_button.h"\r
 #include "components/ui_toggle_button.h"\r
 namespace OHOS\r
 {\r
-    static const char * SYSTEM_VOLUME_BUTTON = "SystemVolumeButton"; //系统音量\r
-    static const char * CALL_VOLUME_BUTTON   = "CallVolumeButton";   //通话音量\r
-    static const char * MEDIAVOLUMEBUTTON    = "MediaVolumeButton";  //媒体音量\r
-    static const char * VIBRATION_REMINDER_TOGGLEBUTTON = "VibrationReminderToggleButton";//震动提醒\r
-    static const char * SILENT_MODEL_TOGGLEBUTTON = "SilentModeToggleButton"; //静音模式\r
+    /* ----------------------------------- 图片 ----------------------------------- */\r
+    static constexpr const char *PNG_SYSTEM_VOLUME_IMAGE = "/user/res/SoundAndVibration/SYSTEM_VOLUME.bin"; // 系统音量图片\r
+    static constexpr const char *PNG_CALL_VOLUME_IMAGE = "/user/res/SoundAndVibration/CALL_VOLUME.bin";     // 通话音量图片\r
+    static constexpr const char *PNG_MEDIA_VOLUME_IMAGE = "/user/res/SoundAndVibration/MEDIA_VOLUME.bin";   // 媒体音量图片\r
+    /* ---------------------------------- 组件ID ---------------------------------- */\r
+    static const char *SYSTEM_VOLUME_BUTTON = "SystemVolumeButton";                       // 系统音量按钮ID\r
+    static const char *CALL_VOLUME_BUTTON = "CallVolumeButton";                           // 通话音量按钮ID\r
+    static const char *MEDIAVOLUMEBUTTON = "MediaVolumeButton";                           // 媒体音量按钮ID\r
+    static const char *VIBRATION_REMINDER_TOGGLEBUTTON = "VibrationReminderToggleButton"; // 震动提醒\r
+    static const char *SILENT_MODEL_TOGGLEBUTTON = "SilentModeToggleButton";              // 静音模式\r
     class SoundAndVibrationPresenter;\r
     class SoundAndVibrationView : public View<SoundAndVibrationPresenter>\r
     {\r
 \r
     public:\r
+        struct ImageConfig\r
+        {\r
+            int x;\r
+            int y;\r
+            int w;\r
+            int 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 ButtonConfig\r
+        {\r
+            int x;\r
+            int y;\r
+            int w;\r
+            int h;\r
+            const char *ViewId;\r
+            const char *ImageSrc;\r
+        };\r
         SoundAndVibrationView();\r
         virtual ~SoundAndVibrationView();\r
         static SoundAndVibrationView *GetInstance(void);\r
@@ -33,25 +64,28 @@ namespace OHOS
 \r
     private:\r
         void InitView(void);\r
-        void DeInit(void);\r
+        void ClearAll(void);\r
+        bool SetUpSoundAndVibrationScrollView(void);\r
+        bool SetUpTitle(void);\r
+        UIButton *SetUpButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener);\r
+        UIImageView *SetUpImageVIew(ImageConfig &imageconfig);\r
+        UILabel *SetUpLabel(LabelConfig &labelConfig);\r
 \r
     private:\r
-        UIViewGroup *container_ = nullptr;\r
         UIScrollView *SoundAndVibrationScrollView = nullptr;\r
-        UILabel *SoundAndVibrationLabel = nullptr;\r
+        UILabel *Title = nullptr;\r
         UIButton *SystemVolumeButton = nullptr;\r
         UIButton *CallVolumeButton = nullptr;\r
-        UIImageView *image1 = nullptr;\r
-        UIImageView *image2 = nullptr;\r
-        UIImageView *SilentModeImage = nullptr;\r
-        UILabel *SilentModeLabe_ = nullptr;\r
-        UIToggleButton * VibrationReminderToggleButton = nullptr;\r
-        UILabel *SilentModeLabel = nullptr;\r
-        UIImageView *VibrationReminderImage = nullptr;\r
-        UIToggleButton *SilentModeToggleButton = nullptr;\r
-        UILabel *VibrationReminderLabel = nullptr;\r
         UIButton *MediaVolumeButton = nullptr;\r
+        UIImageView *Background[2]{nullptr};       // 放组件的背景\r
+        UILabel *VibrationReminderLabel = nullptr; // 震动提醒\r
+        UILabel *SilentModeLabel = nullptr;        // 静音模式\r
+        UILabel *SilentModeLabel_ = nullptr;       // 系统音量不受影响\r
+        UIToggleButton *VibrationReminderToggleButton = nullptr;\r
+        UIToggleButton *SilentModeToggleButton = nullptr;\r
+\r
+        bool initViewStatus{false};\r
     };\r
 } // namespace OHOS\r
 \r
-#endif
\ No newline at end of file
+#endif\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h
new file mode 100644 (file)
index 0000000..9c6803d
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef SOUND_AND_VIBRATION_VOLUME_SETTING_H
+#define SOUND_AND_VIBRATION_VOLUME_SETTING_H
+
+#include "BaseView.h"
+#include "View.h"
+#include "components/ui_view_group.h"
+#include "components/ui_slider.h"
+#include "components/ui_image_view.h"
+
+/*
+    声音与震动的声音设置视图
+*/
+
+namespace OHOS
+{
+#define VOLUME_MIN 0
+#define VOLUME_MAX 100
+#define VOLUME_PROGRESS "progress"
+
+    class SoundAndVibrationVolumeSettingView 
+    {
+    public:
+        SoundAndVibrationVolumeSettingView();
+        ~SoundAndVibrationVolumeSettingView();
+        static SoundAndVibrationVolumeSettingView *GetInstance(void);
+        UIViewGroup * SetUpVolumeProcess(void);
+        void ClearAll(void);
+    private:
+        UIViewGroup *group{nullptr};
+        UISlider *VolumeProcess{nullptr};
+        UIImageView *VolumeVetor{nullptr};
+        bool initViewStatus{false};
+    };
+
+}
+#endif
\ No newline at end of file
index aa5ba64..b45eade 100644 (file)
@@ -3,10 +3,8 @@
 \r
 #include "BaseView.h"\r
 #include "View.h"\r
-\r
 #include "components/ui_view_group.h"\r
-#include "components/ui_slider.h"\r
-#include "components/ui_image_view.h"\r
+#include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h"\r
 namespace OHOS\r
 {\r
     static const char *SYSTEM_VOLUME_SLIDER = "SystemVolumeSlider";\r
@@ -25,15 +23,11 @@ namespace OHOS
         void OnTearDownView() override;\r
         void OnStop() override;\r
 \r
-    private:\r
-        UIView::OnDragListener *draglistener{nullptr};\r
-        UIView::OnClickListener *sliderClick{nullptr};\r
-        UIView::OnDragListener *sliderDrag{nullptr};\r
-        void InitView(void);\r
+        UIViewGroup * SystemVolumeViewInit(void);\r
 \r
-        UIViewGroup *container_ = nullptr;\r
-        UISlider *SystemVolumeslider = nullptr;\r
-        UIImageView *SystemVolumeimageicon = nullptr;\r
+    private:\r
+        UIViewGroup *group{nullptr};\r
+        SoundAndVibrationVolumeSettingView *p_SoundAndVibrationVolumeSettingView{nullptr};\r
     };\r
 } // namespace OHOS\r
 \r
index f897635..c9df18b 100644 (file)
@@ -1,10 +1,6 @@
-#include "common/image_cache_manager.h"\r
-#include "UiConfig.h"\r
-#include "ui_resource_image.h"\r
-\r
 #include "soundandvibration/include/SoundAndVibrationView.h"\r
 #include "soundandvibration/include/SoundAndVibrationPresenter.h"\r
-\r
+#include "wearable_log.h"\r
 /*\r
 按优先级分为\r
 1.系统音量\r
@@ -26,371 +22,310 @@ namespace OHOS
 \r
     SoundAndVibrationView::SoundAndVibrationView()\r
     {\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SoundAndVibrationView");\r
         g_pSoundAndVibrationView = this;\r
     }\r
 \r
     SoundAndVibrationView::~SoundAndVibrationView()\r
     {\r
-        DeInit();\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::~SoundAndVibrationView");\r
+        ClearAll();\r
         g_pSoundAndVibrationView = nullptr;\r
     }\r
 \r
     SoundAndVibrationView *SoundAndVibrationView::GetInstance()\r
     {\r
-\r
         return g_pSoundAndVibrationView;\r
     }\r
-    void SoundAndVibrationView::InitView(void)\r
+\r
+    void SoundAndVibrationView::ClearAll()\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 *>(SoundAndVibrationPresenter::GetInstance());\r
-            if (draglistener == nullptr)\r
+            SoundAndVibrationScrollView->RemoveAll();\r
+            delete Title;\r
+            Title = nullptr;\r
+            delete SystemVolumeButton;\r
+            SystemVolumeButton = nullptr;\r
+            delete CallVolumeButton;\r
+            CallVolumeButton = nullptr;\r
+            delete MediaVolumeButton;\r
+            MediaVolumeButton = nullptr;\r
+            for (int i = 0; i < 2; i++)\r
             {\r
-                return;\r
+                delete Background[i];\r
+                Background[i] = nullptr;\r
             }\r
-            container_->SetOnDragListener(draglistener);\r
-            container_->SetTouchable(true);\r
-            container_->SetDraggable(true);\r
+            delete VibrationReminderLabel;\r
+            VibrationReminderLabel = nullptr;\r
+            delete SilentModeLabel;\r
+            SilentModeLabel = nullptr;\r
+            delete SilentModeLabel_;\r
+            SilentModeLabel_ = nullptr;\r
+            delete VibrationReminderToggleButton;\r
+            VibrationReminderToggleButton = nullptr;\r
+            delete SilentModeToggleButton;\r
+            SilentModeToggleButton = nullptr;\r
+            delete SoundAndVibrationScrollView;\r
+            SoundAndVibrationScrollView = nullptr;\r
         }\r
-        /***********************************************************************************************************/\r
-        // Add ScrollView to App\r
+    }\r
+\r
+    bool SoundAndVibrationView::SetUpSoundAndVibrationScrollView(void)\r
+    {\r
+        SoundAndVibrationScrollView = new UIScrollView();\r
         if (SoundAndVibrationScrollView == nullptr)\r
         {\r
-            SoundAndVibrationScrollView = new UIScrollView();\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new SoundAndVibrationScrollView fail!");\r
+            return false;\r
         }\r
-        SoundAndVibrationScrollView->SetPosition(0, 0);                     \r
-        SoundAndVibrationScrollView->Resize(466, 466);                      \r
-        SoundAndVibrationScrollView->SetViewId("SoundAndVibrationScrollView");\r
+        SoundAndVibrationScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
         SoundAndVibrationScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        // Add to rootView\r
-        container_->Add(SoundAndVibrationScrollView);\r
-        SoundAndVibrationScrollView->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add Label to App\r
-        if (SoundAndVibrationLabel == nullptr)\r
+        SoundAndVibrationScrollView->SetScrollBlankSize(35);\r
+        SoundAndVibrationScrollView->SetReboundSize(50);\r
+        SoundAndVibrationScrollView->SetDirection(1);\r
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(SoundAndVibrationPresenter::GetInstance());\r
+        if (draglistener == nullptr)\r
         {\r
-            SoundAndVibrationLabel = new UILabel();\r
+            return false;\r
         }\r
-        SoundAndVibrationLabel->SetPosition(158, 52); \r
-        SoundAndVibrationLabel->Resize(200, 60);     \r
-        SoundAndVibrationLabel->SetViewId("SoundAndVibrationLabel");\r
-        SoundAndVibrationLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
-        SoundAndVibrationLabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-        // Set additional property\r
-        SoundAndVibrationLabel->SetText("声音与震动");\r
-        SoundAndVibrationLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        SoundAndVibrationLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        SoundAndVibrationLabel->SetRollSpeed(6);\r
-        SoundAndVibrationLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-        // Add to scrollView\r
-        SoundAndVibrationScrollView->Add(SoundAndVibrationLabel);\r
-        SoundAndVibrationLabel->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add SystemVolumeButton to App\r
-        if (SystemVolumeButton == nullptr)\r
-        {\r
-            SystemVolumeButton = new UIButton();\r
-        }\r
-        SystemVolumeButton->SetPosition(43, 120); \r
-        SystemVolumeButton->Resize(380, 100);     \r
-        SystemVolumeButton->SetViewId(SYSTEM_VOLUME_BUTTON);\r
-        SystemVolumeButton->SetStyle(STYLE_BORDER_RADIUS, 50);\r
-        // Set additional property\r
-        SystemVolumeButton->SetImageSrc(PNG_SYSTEM_VOLUME_IMAGE, nullptr);\r
-        SystemVolumeButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-        SystemVolumeButton->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED);\r
+        SoundAndVibrationScrollView->SetOnDragListener(draglistener);\r
+        SoundAndVibrationScrollView->SetTouchable(true);\r
+        SoundAndVibrationScrollView->SetDraggable(true);\r
 \r
-        // Add the CallBack about events\r
-        UIView::OnClickListener *SystemVolumeButtonClick = static_cast<UIView::OnClickListener *>(SoundAndVibrationPresenter::GetInstance());\r
-        SystemVolumeButton->SetOnClickListener(SystemVolumeButtonClick);\r
-        // Add to scrollView1\r
-        SoundAndVibrationScrollView->Add(SystemVolumeButton);\r
-        SystemVolumeButton->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add CallVolumeButton to App\r
-        if (CallVolumeButton == nullptr)\r
-        {\r
-            CallVolumeButton = new UIButton();\r
-        }\r
-        CallVolumeButton->SetPosition(43, 240); \r
-        CallVolumeButton->Resize(380, 100);     \r
-        CallVolumeButton->SetViewId(CALL_VOLUME_BUTTON); \r
-        CallVolumeButton->SetStyle(STYLE_BORDER_RADIUS, 50);\r
-        CallVolumeButton->SetImageSrc(PNG_CALL_VOLUME_IMAGE, nullptr);\r
-        CallVolumeButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-        CallVolumeButton->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED);\r
-        // Add the CallBack about events\r
-        UIView::OnClickListener *CallVolumeButtonClick = static_cast<UIView::OnClickListener *>(SoundAndVibrationPresenter::GetInstance());\r
-        CallVolumeButton->SetOnClickListener(CallVolumeButtonClick);\r
-        // Add to SoundAndVibrationScrollView\r
-        SoundAndVibrationScrollView->Add(CallVolumeButton);\r
-        CallVolumeButton->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add MediaVolumeButton to App\r
-        if (MediaVolumeButton == nullptr)\r
+        return true;\r
+    }\r
+\r
+    // 设置标题\r
+    bool SoundAndVibrationView::SetUpTitle(void)\r
+    {\r
+        Title = new UILabel();\r
+        if (Title == nullptr)\r
         {\r
-            MediaVolumeButton = new UIButton();\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new Title fail!");\r
+            return false;\r
         }\r
-        MediaVolumeButton->SetPosition(43, 360); \r
-        MediaVolumeButton->Resize(380, 100);     \r
-        MediaVolumeButton->SetViewId(MEDIAVOLUMEBUTTON);\r
+        Title->SetPosition(158, 52);\r
+        Title->SetStyle(STYLE_TEXT_FONT, 30);\r
+        Title->SetStyle(STYLE_LINE_HEIGHT, 35);\r
+        Title->SetText("声音与震动");\r
+        Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+        Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+        Title->SetRollSpeed(6);\r
+        Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
 \r
-        MediaVolumeButton->SetImageSrc(PNG_MEDIA_VOLUME_IMAGE, nullptr);\r
-        MediaVolumeButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+        return true;\r
+    }\r
 \r
-        // Add the CallBack about events\r
-        UIView::OnClickListener *MediaVolumeButtonClick = static_cast<UIView::OnClickListener *>(SoundAndVibrationPresenter::GetInstance());\r
-        MediaVolumeButton->SetOnClickListener(MediaVolumeButtonClick);\r
-        // Add to scrollView1\r
-        SoundAndVibrationScrollView->Add(MediaVolumeButton);\r
-        MediaVolumeButton->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        if (VibrationReminderImage == nullptr)\r
-        {\r
-            VibrationReminderImage = new UIImageView();\r
-        }\r
-        VibrationReminderImage->SetPosition(43, 480); \r
-        VibrationReminderImage->Resize(100, 100);     \r
-        VibrationReminderImage->SetViewId("VibrationReminderImage");  \r
-        VibrationReminderImage->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-        VibrationReminderImage->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        VibrationReminderImage->SetStyle(STYLE_BORDER_RADIUS, 50);\r
-        VibrationReminderImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE);\r
-        SoundAndVibrationScrollView->Add(VibrationReminderImage);\r
-        VibrationReminderImage->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add Label to App\r
-        if (VibrationReminderLabel == nullptr)\r
-        {\r
-            VibrationReminderLabel = new UILabel();\r
-        }\r
-        VibrationReminderLabel->SetPosition(90, 513); // widget's left position and top position\r
-        VibrationReminderLabel->Resize(120, 35);      // widget's width and height\r
-        VibrationReminderLabel->SetViewId("VibrationReminderLabel");  // Set style\r
-        VibrationReminderLabel->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-        VibrationReminderLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        VibrationReminderLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
-        VibrationReminderLabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-        // Set additional property\r
-        VibrationReminderLabel->SetText("震动提醒");\r
-        VibrationReminderLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        VibrationReminderLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        VibrationReminderLabel->SetRollSpeed(6);\r
-        VibrationReminderLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-        // Add to SoundAndVibrationScrollView\r
-        SoundAndVibrationScrollView->Add(VibrationReminderLabel);\r
-        VibrationReminderLabel->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add ToggleButton to App\r
-        if (VibrationReminderToggleButton == nullptr)\r
-        {\r
-            VibrationReminderToggleButton = new UIToggleButton();\r
-        }\r
-        VibrationReminderToggleButton->SetPosition(298, 505);      \r
-        VibrationReminderToggleButton->Resize(100, 50);            \r
-        VibrationReminderToggleButton->SetViewId(VIBRATION_REMINDER_TOGGLEBUTTON);\r
-        VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
-        VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-        VibrationReminderToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE,PNG_TOGGLEBUTTON_OFF_IMAGE);\r
-        // Add the CallBack about events\r
-        UIView::OnClickListener *VibrationReminderToggleButtonClick = static_cast<UIView::OnClickListener *>(SoundAndVibrationPresenter::GetInstance());\r
-        VibrationReminderToggleButton->SetOnClickListener(VibrationReminderToggleButtonClick);\r
-        // Add to SoundAndVibrationScrollView\r
-        SoundAndVibrationScrollView->Add(VibrationReminderToggleButton);\r
-        VibrationReminderToggleButton->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add ImageView to App\r
-        if (SilentModeImage == nullptr)\r
-        {\r
-            SilentModeImage = new UIImageView();\r
-        }\r
-        SilentModeImage->SetPosition(43, 600); \r
-        SilentModeImage->Resize(380, 100);     \r
-        SilentModeImage->SetViewId("SilentModeImage");\r
-        SilentModeImage->SetStyle(STYLE_BORDER_RADIUS, 50);\r
-        SilentModeImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE);\r
-        // Add to scrollView1\r
-        SoundAndVibrationScrollView->Add(SilentModeImage);\r
-        SilentModeImage->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        if (SilentModeLabel == nullptr)\r
-        {\r
-            SilentModeLabel = new UILabel();\r
-        }\r
-        SilentModeLabel->SetPosition(90, 620); \r
-        SilentModeLabel->Resize(120, 35);      \r
-        SilentModeLabel->SetViewId("SilentModeLabel");\r
-        SilentModeLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
-        SilentModeLabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-        // Set additional property\r
-        SilentModeLabel->SetText("静音模式");\r
-        SilentModeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        SilentModeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        SilentModeLabel->SetRollSpeed(6);\r
-        SilentModeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-        // Add to SoundAndVibrationScrollView\r
-        SoundAndVibrationScrollView->Add(SilentModeLabel);\r
-        SilentModeLabel->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        if (SilentModeLabe_ == nullptr)\r
-        {\r
-            SilentModeLabe_ = new UILabel();\r
-        }\r
-        SilentModeLabe_->SetPosition(90, 657); \r
-        SilentModeLabe_->Resize(160, 23);      \r
-        SilentModeLabe_->SetViewId("label9");\r
-        SilentModeLabe_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-        SilentModeLabe_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        SilentModeLabe_->SetStyle(STYLE_TEXT_FONT, 20);\r
-        SilentModeLabe_->SetStyle(STYLE_LINE_HEIGHT, 23);\r
-        // Set additional property\r
-        SilentModeLabe_->SetText("系统音量不受影响");\r
-        SilentModeLabe_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        SilentModeLabe_->SetTextColor(Color::GetColorFromRGBA(0xfd, 0xfd, 0xfd, 0x7f));\r
-        SilentModeLabe_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        SilentModeLabe_->SetRollSpeed(6);\r
-        SilentModeLabe_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
-        // Add to SoundAndVibrationScrollView\r
-        SoundAndVibrationScrollView->Add(SilentModeLabe_);\r
-        SilentModeLabe_->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add SilentModeToggleButton to App\r
-        if (SilentModeToggleButton == nullptr)\r
-        {\r
-            SilentModeToggleButton = new UIToggleButton();\r
-        }\r
-        SilentModeToggleButton->SetPosition(298, 625);     \r
-        SilentModeToggleButton->Resize(100, 50);             \r
-        SilentModeToggleButton->SetViewId(SILENT_MODEL_TOGGLEBUTTON);\r
-        SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
-        SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-        SilentModeToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE,PNG_TOGGLEBUTTON_OFF_IMAGE);\r
-        UIView::OnClickListener *SilentModeToggleButtonClick = static_cast<UIView::OnClickListener *>(SoundAndVibrationPresenter::GetInstance());\r
-        SilentModeToggleButton->SetOnClickListener(SilentModeToggleButtonClick);\r
-        // Add to scrollView1\r
-        SoundAndVibrationScrollView->Add(SilentModeToggleButton);\r
-        SilentModeToggleButton->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add ImageView to App\r
-        if (image1 == nullptr)\r
+    /// @brief 设置按钮\r
+    /// @param button\r
+    /// @return true 设置成功,false 失败\r
+    UIButton *SoundAndVibrationView::SetUpButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener)\r
+    {\r
+        UIButton *button = new UIButton();\r
+        if (button == nullptr)\r
         {\r
-            image1 = new UIImageView();\r
+            return nullptr;\r
         }\r
-        image1->SetPosition(183, 18); \r
-        image1->Resize(100, 100);     \r
-        image1->SetViewId("image1");  \r
+        button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h);\r
+        button->SetViewId(buttonconfig.ViewId);\r
+        button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc);\r
+        button->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
+        button->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+        button->SetOnClickListener(clickListener);\r
+        return button;\r
+    }\r
 \r
-        SoundAndVibrationScrollView->Add(image1);\r
-        image1->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add ImageView to App\r
-        if (image2 == nullptr)\r
+    // 设置图片\r
+    UIImageView *SoundAndVibrationView::SetUpImageVIew(ImageConfig &imageconfig)\r
+    {\r
+        UIImageView *Image = new UIImageView();\r
+        if (Image == nullptr)\r
         {\r
-            image2 = new UIImageView();\r
+            return nullptr;\r
         }\r
-        image2->SetPosition(183, 668);\r
-        image2->Resize(100, 100);      \r
-        image2->SetViewId("image2");   \r
-\r
-        SoundAndVibrationScrollView->Add(image2);\r
-        image2->SetVisible(true);\r
+        Image->SetPosition(imageconfig.x, imageconfig.y, imageconfig.w, imageconfig.h);\r
+        Image->SetSrc(imageconfig.ImageSrc);\r
+        return Image;\r
     }\r
 \r
-    void SoundAndVibrationView::DeInit()\r
+    // 设置标签\r
+    UILabel *SoundAndVibrationView::SetUpLabel(LabelConfig &labelConfig)\r
     {\r
-        if (container_ != nullptr)\r
-        {\r
-            container_->RemoveAll();\r
-            delete container_;\r
-            container_ = nullptr;\r
-        }\r
-        if (SoundAndVibrationScrollView != nullptr)\r
-        {\r
-            delete SoundAndVibrationScrollView;\r
-            SoundAndVibrationScrollView = nullptr;\r
-        }\r
-        if (SoundAndVibrationLabel != nullptr)\r
+        UILabel *label = new UILabel();\r
+        if (label == nullptr)\r
         {\r
-            delete SoundAndVibrationLabel;\r
-            SoundAndVibrationLabel = nullptr;\r
+            return nullptr;\r
         }\r
-        if (SystemVolumeButton != nullptr)\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
+    void SoundAndVibrationView::InitView(void)\r
+    {\r
+        if (SetUpSoundAndVibrationScrollView() == false)\r
         {\r
-            delete SystemVolumeButton;\r
-            SystemVolumeButton = nullptr;\r
+            return;\r
         }\r
-        if (CallVolumeButton != nullptr)\r
+        if (SetUpTitle() == false)\r
         {\r
-            delete CallVolumeButton;\r
-            CallVolumeButton = nullptr;\r
+            return;\r
         }\r
-        if (image1 != nullptr)\r
+        UIView::OnClickListener *ButtonClick = static_cast<UIView::OnClickListener *>(SoundAndVibrationPresenter::GetInstance());\r
+        /* --------------------------- SystemVolumeButton --------------------------- */\r
+        ButtonConfig buttonconfig = {\r
+            .x = 43,\r
+            .y = 120,\r
+            .w = 380,\r
+            .h = 100,\r
+            .ViewId = SYSTEM_VOLUME_BUTTON,\r
+            .ImageSrc = PNG_SYSTEM_VOLUME_IMAGE,\r
+        };\r
+        SystemVolumeButton = SetUpButton(buttonconfig, ButtonClick);\r
+        if (SystemVolumeButton == nullptr)\r
         {\r
-            delete image1;\r
-            image1 = nullptr;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetTheButton: SystemVolumeButton is nullptr!");\r
+            return;\r
         }\r
-        if (image2 != nullptr)\r
+        /* ---------------------------- CallVolumeButton ---------------------------- */\r
+        buttonconfig.y = 240;\r
+        buttonconfig.ViewId = CALL_VOLUME_BUTTON;\r
+        buttonconfig.ImageSrc = PNG_CALL_VOLUME_IMAGE;\r
+        CallVolumeButton = SetUpButton(buttonconfig, ButtonClick);\r
+        if (SystemVolumeButton == nullptr)\r
         {\r
-            delete image2;\r
-            image2 = nullptr;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetTheButton: CallVolumeButton is nullptr!");\r
+            return;\r
         }\r
-        if (SilentModeImage != nullptr)\r
+        /* ---------------------------- MediaVolumeButton --------------------------- */\r
+        buttonconfig.y = 360;\r
+        buttonconfig.ViewId = MEDIAVOLUMEBUTTON;\r
+        buttonconfig.ImageSrc = PNG_MEDIA_VOLUME_IMAGE;\r
+        MediaVolumeButton = SetUpButton(buttonconfig, ButtonClick);\r
+        if (SystemVolumeButton == nullptr)\r
         {\r
-            delete SilentModeImage;\r
-            SilentModeImage = nullptr;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetTheButton: MediaVolumeButton is nullptr!");\r
+            return;\r
         }\r
-        if (SilentModeLabe_ != nullptr)\r
+        /* ------------------------------- Background ------------------------------- */\r
+        ImageConfig imageconfig = {\r
+            .x = 43,\r
+            .y = 480,\r
+            .w = 380,\r
+            .h = 100,\r
+            .ImageSrc = "/user/res/SETTING_BACKGROUND.bin",\r
+        };\r
+        Background[0] = SetUpImageVIew(imageconfig);\r
+        if (Background[0] == nullptr)\r
         {\r
-            delete SilentModeLabe_;\r
-            SilentModeLabe_ = nullptr;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Background[0] new fail!");\r
+            return;\r
         }\r
-        if (VibrationReminderToggleButton != nullptr)\r
+        imageconfig.y = 600;\r
+        Background[1] = SetUpImageVIew(imageconfig);\r
+        if (Background[1] == nullptr)\r
         {\r
-            delete VibrationReminderToggleButton;\r
-            VibrationReminderToggleButton = nullptr;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Background[1] new fail!");\r
+            return;\r
         }\r
-        if (SilentModeLabel != nullptr)\r
+        /* ------------------------- VibrationReminderLabel ------------------------- */\r
+        LabelConfig labelConfig = {\r
+            .left = 90,\r
+            .top = 513,\r
+            .width = 120,\r
+            .height = 35,\r
+            .fontSize = 30,\r
+            .lineHeigh = 35,\r
+            .text = "震动提醒",\r
+            .lineBreakMode = UILabel::LINE_BREAK_ADAPT,\r
+        };\r
+        VibrationReminderLabel = SetUpLabel(labelConfig);\r
+        if (VibrationReminderLabel == nullptr)\r
         {\r
-            delete SilentModeLabel;\r
-            SilentModeLabel = nullptr;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::VibrationReminderLabel is nullptr!");\r
+            return;\r
         }\r
-        if (VibrationReminderImage != nullptr)\r
+        /* ----------------------------- SilentModeLabel ---------------------------- */\r
+        labelConfig.top = 620;\r
+        labelConfig.text = "静音模式";\r
+        SilentModeLabel = SetUpLabel(labelConfig);\r
+        if (SilentModeLabel == nullptr)\r
         {\r
-            delete VibrationReminderImage;\r
-            VibrationReminderImage = nullptr;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeLabel is nullptr!");\r
+            return;\r
         }\r
-        if (SilentModeToggleButton != nullptr)\r
+        /* ---------------------------- SilentModeLabel_ ---------------------------- */\r
+        labelConfig.top = 657;\r
+        labelConfig.text = "系统音量不受影响";\r
+        labelConfig.fontSize = 20;\r
+        labelConfig.lineHeigh = 23;\r
+        SilentModeLabel_ = SetUpLabel(labelConfig);\r
+        if (SilentModeLabel_ == nullptr)\r
         {\r
-            delete SilentModeToggleButton;\r
-            SilentModeToggleButton = nullptr;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeLabel_ is nullptr!");\r
+            return;\r
         }\r
-        if (VibrationReminderLabel != nullptr)\r
+        SilentModeLabel_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+        SilentModeLabel_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
+        SilentModeLabel_->SetTextColor(Color::GetColorFromRGBA(0xfd, 0xfd, 0xfd, 0x7f));\r
+        /* ---------------------- VibrationReminderToggleButton --------------------- */\r
+        VibrationReminderToggleButton = new UIToggleButton();\r
+        if (VibrationReminderToggleButton == nullptr)\r
         {\r
-            delete VibrationReminderLabel;\r
-            VibrationReminderLabel = nullptr;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::VibrationReminderToggleButton new  fail!");\r
+            return;\r
         }\r
-        if (MediaVolumeButton != nullptr)\r
+        VibrationReminderToggleButton->SetPosition(298, 505, 100, 50);\r
+        VibrationReminderToggleButton->SetViewId(VIBRATION_REMINDER_TOGGLEBUTTON);\r
+        VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+        VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+        const char *ToggleButtonSelect = "/user/res/TOGGLEBUTTON_ON.bin";\r
+        const char *ToggleButtonUnSelect = "/user/res/TOGGLEBUTTON_OFF.bin";\r
+        VibrationReminderToggleButton->SetImages(ToggleButtonSelect, ToggleButtonUnSelect);\r
+        VibrationReminderToggleButton->SetOnClickListener(ButtonClick);\r
+        /* ------------------------- SilentModeToggleButton ------------------------- */\r
+        SilentModeToggleButton = new UIToggleButton();\r
+        if (SilentModeToggleButton == nullptr)\r
         {\r
-            delete MediaVolumeButton;\r
-            MediaVolumeButton = nullptr;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeToggleButton new  fail!");\r
+            return;\r
         }\r
+        SilentModeToggleButton->SetPosition(298, 625, 100, 50);\r
+        SilentModeToggleButton->SetViewId(SILENT_MODEL_TOGGLEBUTTON);\r
+        SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+        SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+        SilentModeToggleButton->SetImages(ToggleButtonSelect, ToggleButtonUnSelect);\r
+        SilentModeToggleButton->SetOnClickListener(ButtonClick);\r
+\r
+        initViewStatus = true;\r
     }\r
 \r
     void SoundAndVibrationView::OnStart()\r
     {\r
         View<SoundAndVibrationPresenter>::OnStart();\r
         InitView();\r
-        RootView::GetInstance()->Add(container_);\r
     }\r
 \r
     void SoundAndVibrationView::OnSetUpView()\r
     {\r
-\r
         View<SoundAndVibrationPresenter>::OnSetUpView();\r
+        SoundAndVibrationScrollView->Add(Title);\r
+        SoundAndVibrationScrollView->Add(SystemVolumeButton);\r
+        SoundAndVibrationScrollView->Add(CallVolumeButton);\r
+        SoundAndVibrationScrollView->Add(MediaVolumeButton);\r
+        SoundAndVibrationScrollView->Add(Background[0]);\r
+        SoundAndVibrationScrollView->Add(Background[1]);\r
+        SoundAndVibrationScrollView->Add(VibrationReminderLabel);\r
+        SoundAndVibrationScrollView->Add(SilentModeLabel);\r
+        SoundAndVibrationScrollView->Add(SilentModeLabel_);\r
+        SoundAndVibrationScrollView->Add(VibrationReminderToggleButton);\r
+        SoundAndVibrationScrollView->Add(SilentModeToggleButton);\r
+        RootView::GetInstance()->Add(SoundAndVibrationScrollView);\r
         Draw();\r
     }\r
 \r
@@ -408,4 +343,4 @@ namespace OHOS
         RootView::GetInstance()->RemoveAll();\r
         return;\r
     }\r
-}
\ No newline at end of file
+}\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp
new file mode 100644 (file)
index 0000000..4f65e77
--- /dev/null
@@ -0,0 +1,106 @@
+#include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h"
+#include "wearable_log.h"
+
+namespace OHOS
+{
+    static SoundAndVibrationVolumeSettingView *g_pSoundAndVibrationVolumeSettingView{nullptr};
+
+    SoundAndVibrationVolumeSettingView::SoundAndVibrationVolumeSettingView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::SoundAndVibrationVolumeSettingView");
+
+        g_pSoundAndVibrationVolumeSettingView = this;
+    }
+
+    SoundAndVibrationVolumeSettingView::~SoundAndVibrationVolumeSettingView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::~SoundAndVibrationVolumeSettingView");
+        ClearAll();
+        g_pSoundAndVibrationVolumeSettingView = nullptr;
+    }
+
+    SoundAndVibrationVolumeSettingView *SoundAndVibrationVolumeSettingView::GetInstance(void)
+    {
+        return g_pSoundAndVibrationVolumeSettingView;
+    }
+
+    void SoundAndVibrationVolumeSettingView::ClearAll(void)
+    {
+        if (initViewStatus == true)
+        {
+            group->RemoveAll();
+            delete VolumeProcess;
+            VolumeProcess = nullptr;
+            delete VolumeVetor;
+            VolumeVetor = nullptr;
+            delete group;
+            group = nullptr;
+        }
+    }
+
+    UIViewGroup *SoundAndVibrationVolumeSettingView::SetUpVolumeProcess(void)
+    {
+        group = new UIViewGroup();
+        if (group == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::group new fail");
+            return nullptr;
+        }
+        group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+        group->SetDraggable(true);
+        group->SetTouchable(true);
+        /* ------------------------------ VolumeProcess ----------------------------- */
+        VolumeProcess = new UISlider();
+        if (VolumeProcess == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VolumeProcess new fail");
+            return nullptr;
+        }
+        VolumeProcess->SetSliderColor(Color::Gray(), Color::Silver());
+        VolumeProcess->SetPosition(167, 77, 130, 310);
+        VolumeProcess->SetDirection(UISlider::Direction::DIR_BOTTOM_TO_TOP);
+        VolumeProcess->SetViewId(VOLUME_PROGRESS);
+        VolumeProcess->SetRange(VOLUME_MAX, VOLUME_MIN);
+
+        VolumeProcess->SetStyle(STYLE_BORDER_RADIUS, 100);
+        VolumeProcess->SetBackgroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND);
+        VolumeProcess->SetForegroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND);
+        VolumeProcess->SetSliderColor(Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
+        VolumeProcess->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff);
+        VolumeProcess->SetKnobStyle(StyleDefault::GetSliderKnobStyle());
+        /* ------------------------------- VolumeVetor ------------------------------ */
+        VolumeVetor = new UIImageView();
+        if (VolumeVetor == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VolumeVetor new fail");
+            return nullptr;
+        }
+        VolumeVetor->SetPosition(213, 213, 40, 40);
+        const char *image = "/user/res/VolumeControlVector.bin";
+        VolumeVetor->SetSrc(image);
+
+        // if (listener == nullptr)
+        // {
+        //     listener = new VolumeSliderEventListener();
+        //     if (listener == nullptr)
+        //     {
+        //         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "listener new fail");
+        //         return false;
+        //     }
+        // }
+        // progress->SetSliderEventListener(listener);
+        // progress->SetOnClickListener(listener);
+        // progress->SetOnDragListener(listener);
+        // progress->SetKnobStyle(StyleDefault::GetSliderKnobStyle());
+        // UIView::OnDragListener *volDragListener = (UIView::OnDragListener *)OHOS::VolumeSliderEventListener::GetInstance();
+        // SetViewId(VOLUME_VIEW);
+        // SetOnDragListener(volDragListener);
+        // SetDraggable(true);
+        // SetTouchable(true);
+        group->Add(VolumeProcess);
+        group->Add(VolumeVetor);
+        initViewStatus = true;
+        return group;
+    }
+
+}
\ No newline at end of file
index a781c47..0a94a4c 100644 (file)
@@ -1,7 +1,6 @@
 #include "soundandvibration/include/SystemVolumeView.h"\r
 #include "soundandvibration/include/SystemVolumePresenter.h"\r
-#include "UiConfig.h"\r
-\r
+#include "wearable_log.h"\r
 /*\r
 系统音量:\r
 通话,提醒,查找手表的音量\r
@@ -19,22 +18,8 @@ namespace OHOS
 \r
     SystemVolumeView::~SystemVolumeView()\r
     {\r
-        g_pSystemVolumeView = nullptr;\r
-        if (container_ != nullptr)\r
-        {\r
-            delete container_;\r
-            container_ = nullptr;\r
-        }\r
-        if (SystemVolumeslider != nullptr)\r
-        {\r
-            delete SystemVolumeslider;\r
-            SystemVolumeslider = nullptr;\r
-        }\r
-        if (SystemVolumeimageicon != nullptr)\r
-        {\r
-            delete SystemVolumeimageicon;\r
-            SystemVolumeimageicon = nullptr;\r
-        }\r
+        delete p_SoundAndVibrationVolumeSettingView;\r
+        p_SoundAndVibrationVolumeSettingView = nullptr;\r
     }\r
 \r
     SystemVolumeView *SystemVolumeView::GetInstance()\r
@@ -42,71 +27,34 @@ namespace OHOS
 \r
         return g_pSystemVolumeView;\r
     }\r
-    void SystemVolumeView::InitView(void)\r
+    UIViewGroup *SystemVolumeView::SystemVolumeViewInit(void)\r
     {\r
-        if (container_ == nullptr)\r
-        {\r
-            container_ = new UIViewGroup();\r
-            container_->SetPosition(0, 0, 466, 466);\r
-            container_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-            container_->SetStyle(STYLE_BACKGROUND_COLOR, 0x000000);\r
-        }\r
-        draglistener = static_cast<UIView::OnDragListener *>(SystemVolumePresenter::GetInstance());\r
-        container_->SetOnDragListener(draglistener);\r
-        container_->SetTouchable(true);\r
-        container_->SetDraggable(true);\r
-        /********************************************************************************************************/\r
-        if (SystemVolumeslider == nullptr)\r
+        p_SoundAndVibrationVolumeSettingView = new SoundAndVibrationVolumeSettingView();\r
+        if (p_SoundAndVibrationVolumeSettingView == nullptr)\r
         {\r
-            SystemVolumeslider = new UISlider();\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!");\r
+            return nullptr;\r
         }\r
-        SystemVolumeslider->SetPosition(167, 77);\r
-        SystemVolumeslider->Resize(130, 310);\r
-        SystemVolumeslider->SetViewId(SYSTEM_VOLUME_SLIDER);\r
-        SystemVolumeslider->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
-        SystemVolumeslider->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        SystemVolumeslider->SetStyle(STYLE_BORDER_OPA, 0x19);\r
-        SystemVolumeslider->SetStyle(STYLE_BORDER_RADIUS, 100);\r
-        SystemVolumeslider->SetDirection(UISlider::Direction::DIR_BOTTOM_TO_TOP);\r
-        SystemVolumeslider->SetValue(50);\r
-        SystemVolumeslider->SetSliderColor(Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));\r
-        SystemVolumeslider->SetKnobStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
-        SystemVolumeslider->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        SystemVolumeslider->SetBackgroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND); // 圆帽式\r
-        SystemVolumeslider->SetForegroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND); // 设置进度条的前景样式。圆帽式\r
-        SystemVolumeslider->SetStyle(STYLE_BORDER_COLOR, Color::Black().full);\r
-        SystemVolumeslider->SetStyle(STYLE_BORDER_WIDTH,2);\r
-        sliderClick = static_cast<UIView::OnClickListener *>(SystemVolumePresenter::GetInstance()); // 用来处理之后点击slider的点击事件\r
-        SystemVolumeslider->SetOnClickListener(sliderClick);\r
-        sliderDrag = static_cast<UIView::OnDragListener *>(SystemVolumePresenter::GetInstance()); // 用来处理之后拖动slider的拖动事件\r
-        SystemVolumeslider->SetOnDragListener(sliderDrag);\r
-        container_->Add(SystemVolumeslider);\r
-        SystemVolumeslider->SetVisible(true);\r
-        /********************************************************************************************************/\r
-        if (SystemVolumeimageicon == nullptr)\r
+        group = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess();\r
+        if (group == nullptr)\r
         {\r
-            SystemVolumeimageicon = new UIImageView();\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::group is nullptr!");\r
+            return nullptr;\r
         }\r
-        SystemVolumeimageicon->SetPosition(213, 213);              // widget's left position and top position\r
-        SystemVolumeimageicon->Resize(100, 100);                   // widget's width and height\r
-        SystemVolumeimageicon->SetViewId("SystemVolumeimageicon"); // Set style\r
-        SystemVolumeimageicon->SetStyle(STYLE_BORDER_COLOR, 0xffAAAAAA);\r
-        SystemVolumeimageicon->SetSrc(PNG_VOLUME_CONTROL_VECTOR);\r
 \r
-        container_->Add(SystemVolumeimageicon);\r
-        SystemVolumeimageicon->SetVisible(true);\r
+        return group;\r
     }\r
 \r
     void SystemVolumeView::OnStart()\r
     {\r
         View<SystemVolumePresenter>::OnStart();\r
-        InitView();\r
-        RootView::GetInstance()->Add(container_);\r
+        SystemVolumeViewInit();\r
     }\r
 \r
     void SystemVolumeView::OnSetUpView()\r
     {\r
         View<SystemVolumePresenter>::OnSetUpView();\r
+        RootView::GetInstance()->Add(group);\r
         Draw();\r
     }\r
 \r
index 6e126ac..ac9f3f4 100644 (file)
@@ -53,6 +53,8 @@ namespace OHOS
             SystemLanguageButton = nullptr;\r
             delete FactoryResetButton;\r
             FactoryResetButton = nullptr;\r
+            delete SystemScrollView[SYSTEMVIEW];\r
+            SystemScrollView[SYSTEMVIEW] = nullptr;\r
         }\r
     }\r
 \r