声音与震动视图修改删除带文字图片
authorluozheng <1732036298@qq.com>
Wed, 21 Feb 2024 11:09:56 +0000 (19:09 +0800)
committerluozheng <1732036298@qq.com>
Wed, 21 Feb 2024 11:09:56 +0000 (19:09 +0800)
code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumeView.h
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/CALL_VOLUME.bin [deleted file]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/MEDIA_VOLUME.bin [deleted file]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/SYSTEM_VOLUME.bin [deleted file]

index 1c7580d..c7228dd 100644 (file)
@@ -119,7 +119,7 @@ namespace OHOS
         DisplayBrightnessTitleLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
         DisplayBrightnessTitleLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
         DisplayBrightnessTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-        DisplayBrightnessTitleLabel->SetText("显示与亮度");\r
+        DisplayBrightnessTitleLabel->SetText("屏幕与亮度");\r
         DisplayBrightnessTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
         DisplayBrightnessTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
         DisplayBrightnessTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
index 1897a02..9100117 100644 (file)
@@ -17,7 +17,7 @@ namespace OHOS
     /* ---------------------------------- 组件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 *MEDIA_VOLUME_BUTTON = "MediaVolumeButton";                         // 媒体音量按钮ID\r
     static const char *VIBRATION_REMINDER_TOGGLEBUTTON = "VibrationReminderToggleButton"; // 震动提醒\r
     static const char *SILENT_MODEL_TOGGLEBUTTON = "SilentModeToggleButton";              // 静音模式\r
     class SoundAndVibrationPresenter;\r
@@ -27,10 +27,10 @@ namespace OHOS
     public:\r
         struct ImageConfig\r
         {\r
-            int x;\r
-            int y;\r
-            int w;\r
-            int h;\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
@@ -46,12 +46,13 @@ namespace OHOS
         };\r
         struct ButtonConfig\r
         {\r
-            int x;\r
-            int y;\r
-            int w;\r
-            int h;\r
+            int16_t x;\r
+            int16_t y;\r
+            int16_t w;\r
+            int16_t h;\r
             const char *ViewId;\r
-            const char *ImageSrc;\r
+            int64_t BackgroundColorValue;          // 按钮背景颜色值\r
+            int64_t TriggeredBackgroundColorValue; // 点击按钮触发的背景颜色值\r
         };\r
         SoundAndVibrationView();\r
         virtual ~SoundAndVibrationView();\r
@@ -65,25 +66,34 @@ namespace OHOS
     private:\r
         void InitView(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
+        bool InitSoundAndVibrationScrollView(void);\r
+        bool InitSoundAndVibrationViewTitleLabel(void);\r
+        bool InitSoundAndVibrationButtonView(void);\r
+        bool SetUpButtonAndCheck(const char *viewId, int x, int y, UIButton *&button, UIView::OnClickListener *listener);\r
+        bool InitSoundAndVibrationImageView(void);\r
+        bool InitSoundAndVibrationLabel(void);\r
+        bool InitSoundAndVibrationToggleButton(void);\r
 \r
     private:\r
-        UIScrollView *SoundAndVibrationScrollView = nullptr;\r
-        UILabel *Title = nullptr;\r
-        UIButton *SystemVolumeButton = nullptr;\r
-        UIButton *CallVolumeButton = 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
+        UIScrollView *SoundAndVibrationScrollView{nullptr};\r
+        UILabel *Title{nullptr};                                // 标题:“声音与震动”\r
+        UIButton *SystemVolumeButton{nullptr};                  // 系统音量按钮\r
+        UIButton *CallVolumeButton{nullptr};                    // 通话音量按钮\r
+        UIButton *MediaVolumeButton{nullptr};                   // 媒体音量按钮\r
+        UILabel *SystemVolumeLabel{nullptr};                    // 系统音量标签\r
+        UILabel *CallVolumeLabel{nullptr};                      // 通话音量标签\r
+        UILabel *MediaVolumeLabel{nullptr};                     // 媒体音量标签\r
+        UILabel *VibrationReminderLabel{nullptr};               // 震动提醒标签\r
+        UILabel *SilentModeLabel{nullptr};                      // 静音模式标签\r
+        UILabel *reminder[4]{nullptr};                          // 提示标签\r
+        UIImageView *nextImageView[3]{nullptr};                 // 箭头图片\r
+        UIImageView *VibrationReminderImageView{nullptr};       //\r
+        UIImageView *SilentModeImageView{nullptr};              //\r
+        UIToggleButton *VibrationReminderToggleButton{nullptr}; // 震动提醒切换按钮\r
+        UIToggleButton *SilentModeToggleButton{nullptr};        // 静音模式切换按钮\r
         bool initViewStatus{false};\r
     };\r
 } // namespace OHOS\r
index 9c6803d..7aa75ea 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "BaseView.h"
 #include "View.h"
-#include "components/ui_view_group.h"
+#include "components/ui_scroll_view.h"
 #include "components/ui_slider.h"
 #include "components/ui_image_view.h"
 
@@ -23,10 +23,10 @@ namespace OHOS
         SoundAndVibrationVolumeSettingView();
         ~SoundAndVibrationVolumeSettingView();
         static SoundAndVibrationVolumeSettingView *GetInstance(void);
-        UIViewGroup * SetUpVolumeProcess(void);
+        UIScrollView * SetUpVolumeProcess(void);
         void ClearAll(void);
     private:
-        UIViewGroup *group{nullptr};
+        UIScrollView *ScrollView{nullptr};
         UISlider *VolumeProcess{nullptr};
         UIImageView *VolumeVetor{nullptr};
         bool initViewStatus{false};
index b45eade..af35921 100644 (file)
@@ -3,7 +3,7 @@
 \r
 #include "BaseView.h"\r
 #include "View.h"\r
-#include "components/ui_view_group.h"\r
+#include "components/ui_scroll_view.h"\r
 #include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h"\r
 namespace OHOS\r
 {\r
@@ -23,10 +23,10 @@ namespace OHOS
         void OnTearDownView() override;\r
         void OnStop() override;\r
 \r
-        UIViewGroup * SystemVolumeViewInit(void);\r
+        UIScrollView * SystemVolumeViewInit(void);\r
 \r
     private:\r
-        UIViewGroup *group{nullptr};\r
+        UIScrollView *SystemVolumeScrollView{nullptr};\r
         SoundAndVibrationVolumeSettingView *p_SoundAndVibrationVolumeSettingView{nullptr};\r
     };\r
 } // namespace OHOS\r
index 6eacd8b..df4df04 100644 (file)
@@ -68,7 +68,7 @@ namespace OHOS{
         {\r
             NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME);\r
             return true;\r
-        }else if(strcmp(view.GetViewId(), MEDIAVOLUMEBUTTON) == 0)\r
+        }else if(strcmp(view.GetViewId(), MEDIA_VOLUME_BUTTON) == 0)\r
         {\r
             NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME);\r
             return true;\r
index c9df18b..0c8da83 100644 (file)
@@ -47,76 +47,57 @@ namespace OHOS
             Title = nullptr;\r
             delete SystemVolumeButton;\r
             SystemVolumeButton = nullptr;\r
+\r
             delete CallVolumeButton;\r
             CallVolumeButton = nullptr;\r
+\r
             delete MediaVolumeButton;\r
             MediaVolumeButton = nullptr;\r
-            for (int i = 0; i < 2; i++)\r
-            {\r
-                delete Background[i];\r
-                Background[i] = nullptr;\r
-            }\r
+\r
+            delete SystemVolumeLabel;\r
+            SystemVolumeLabel = nullptr;\r
+\r
+            delete CallVolumeLabel;\r
+            CallVolumeLabel = nullptr;\r
+\r
+            delete MediaVolumeLabel;\r
+            MediaVolumeLabel = nullptr;\r
+\r
             delete VibrationReminderLabel;\r
             VibrationReminderLabel = nullptr;\r
+\r
             delete SilentModeLabel;\r
             SilentModeLabel = nullptr;\r
-            delete SilentModeLabel_;\r
-            SilentModeLabel_ = nullptr;\r
+\r
+            for (int i = 0; i < 4; i++)\r
+            {\r
+                delete reminder[i];\r
+                reminder[i] = nullptr;\r
+            }\r
+\r
+            for (int i = 0; i < 3; i++)\r
+            {\r
+                delete nextImageView[i];\r
+                nextImageView[i] = nullptr;\r
+            }\r
+\r
+            delete VibrationReminderImageView;\r
+            VibrationReminderImageView = nullptr;\r
+\r
+            delete SilentModeImageView;\r
+            SilentModeImageView;\r
+\r
             delete VibrationReminderToggleButton;\r
             VibrationReminderToggleButton = nullptr;\r
+\r
             delete SilentModeToggleButton;\r
             SilentModeToggleButton = nullptr;\r
+\r
             delete SoundAndVibrationScrollView;\r
             SoundAndVibrationScrollView = nullptr;\r
         }\r
     }\r
 \r
-    bool SoundAndVibrationView::SetUpSoundAndVibrationScrollView(void)\r
-    {\r
-        SoundAndVibrationScrollView = new UIScrollView();\r
-        if (SoundAndVibrationScrollView == nullptr)\r
-        {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new SoundAndVibrationScrollView fail!");\r
-            return false;\r
-        }\r
-        SoundAndVibrationScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
-        SoundAndVibrationScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\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
-            return false;\r
-        }\r
-        SoundAndVibrationScrollView->SetOnDragListener(draglistener);\r
-        SoundAndVibrationScrollView->SetTouchable(true);\r
-        SoundAndVibrationScrollView->SetDraggable(true);\r
-\r
-        return true;\r
-    }\r
-\r
-    // 设置标题\r
-    bool SoundAndVibrationView::SetUpTitle(void)\r
-    {\r
-        Title = new UILabel();\r
-        if (Title == nullptr)\r
-        {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new Title fail!");\r
-            return false;\r
-        }\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
-        return true;\r
-    }\r
-\r
     /// @brief 设置按钮\r
     /// @param button\r
     /// @return true 设置成功,false 失败\r
@@ -129,9 +110,8 @@ namespace OHOS
         }\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->SetStyle(STYLE_BACKGROUND_COLOR, buttonconfig.BackgroundColorValue);\r
+        button->SetStyleForState(STYLE_BACKGROUND_COLOR, buttonconfig.TriggeredBackgroundColorValue, UIButton::PRESSED);\r
         button->SetOnClickListener(clickListener);\r
         return button;\r
     }\r
@@ -166,53 +146,120 @@ namespace OHOS
         label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize);\r
         return label;\r
     }\r
-    void SoundAndVibrationView::InitView(void)\r
+\r
+    /// @brief 声音与震动视图"scrollView"视图初始化\r
+    /// @param void\r
+    /// @return true 初始化成功 false 初始化失败\r
+    bool SoundAndVibrationView::InitSoundAndVibrationScrollView(void)\r
     {\r
-        if (SetUpSoundAndVibrationScrollView() == false)\r
+        SoundAndVibrationScrollView = new UIScrollView();\r
+        if (SoundAndVibrationScrollView == nullptr)\r
         {\r
-            return;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new SoundAndVibrationScrollView fail!");\r
+            return false;\r
         }\r
-        if (SetUpTitle() == false)\r
+        SoundAndVibrationScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+        SoundAndVibrationScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\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
-            return;\r
+            return false;\r
         }\r
+        SoundAndVibrationScrollView->SetOnDragListener(draglistener);\r
+        SoundAndVibrationScrollView->SetTouchable(true);\r
+        SoundAndVibrationScrollView->SetDraggable(true);\r
+\r
+        return true;\r
+    }\r
+\r
+    /// @brief 声音与震动视图"标题"标签初始化\r
+    /// @param  void\r
+    /// @return true 初始化成功 false 初始化失败\r
+    bool SoundAndVibrationView::InitSoundAndVibrationViewTitleLabel(void)\r
+    {\r
+        Title = new UILabel();\r
+        if (Title == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new Title fail!");\r
+            return false;\r
+        }\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
+        return true;\r
+    }\r
+\r
+    /// @brief 声音与震动视图"按钮"初始化\r
+    /// @param  void\r
+    /// @return true 初始化成功 false 初始化失败\r
+    bool SoundAndVibrationView::InitSoundAndVibrationButtonView(void)\r
+    {\r
         UIView::OnClickListener *ButtonClick = static_cast<UIView::OnClickListener *>(SoundAndVibrationPresenter::GetInstance());\r
+        if (ButtonClick == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationPresenter::GetInstance() fail!");\r
+            return false;\r
+        }\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
+        if (!SetUpButtonAndCheck(SYSTEM_VOLUME_BUTTON, 43, 120, SystemVolumeButton, ButtonClick))\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetTheButton: SystemVolumeButton is nullptr!");\r
-            return;\r
+            return false;\r
         }\r
+\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
+        if (!SetUpButtonAndCheck(CALL_VOLUME_BUTTON, 43, 240, CallVolumeButton, ButtonClick))\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetTheButton: CallVolumeButton is nullptr!");\r
-            return;\r
+            return false;\r
         }\r
+\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
+        if (!SetUpButtonAndCheck(MEDIA_VOLUME_BUTTON, 43, 360, MediaVolumeButton, ButtonClick))\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetTheButton: MediaVolumeButton is nullptr!");\r
-            return;\r
+            return false;\r
         }\r
-        /* ------------------------------- Background ------------------------------- */\r
+\r
+        return true;\r
+    }\r
+\r
+    /// @brief 为指定的按钮设置属性并进行错误检查\r
+    /// @param viewId\r
+    /// @param x\r
+    /// @param y\r
+    /// @param button\r
+    /// @param listener\r
+    /// @return true 设置成功 false 设置失败\r
+    bool SoundAndVibrationView::SetUpButtonAndCheck(const char *viewId, int x, int y, UIButton *&button, UIView::OnClickListener *listener)\r
+    {\r
+        ButtonConfig buttonconfig = {\r
+            .x = x,\r
+            .y = y,\r
+            .w = 380,\r
+            .h = 100,\r
+            .ViewId = viewId,\r
+            .BackgroundColorValue = 0xff191919,\r
+            .TriggeredBackgroundColorValue = 0xff29b862,\r
+        };\r
+\r
+        button = SetUpButton(buttonconfig, listener);\r
+        if (button == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetUpButtonAndCheck: Button is nullptr!");\r
+            return false;\r
+        }\r
+        return true;\r
+    }\r
+\r
+    bool SoundAndVibrationView::InitSoundAndVibrationImageView()\r
+    {\r
         ImageConfig imageconfig = {\r
             .x = 43,\r
             .y = 480,\r
@@ -220,35 +267,88 @@ namespace OHOS
             .h = 100,\r
             .ImageSrc = "/user/res/SETTING_BACKGROUND.bin",\r
         };\r
-        Background[0] = SetUpImageVIew(imageconfig);\r
-        if (Background[0] == nullptr)\r
+\r
+        VibrationReminderImageView = SetUpImageVIew(imageconfig);\r
+        if (VibrationReminderImageView == nullptr)\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Background[0] new fail!");\r
-            return;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::VibrationReminderImageView is nullptr!");\r
+            return false;\r
         }\r
+\r
         imageconfig.y = 600;\r
-        Background[1] = SetUpImageVIew(imageconfig);\r
-        if (Background[1] == nullptr)\r
+        SilentModeImageView = SetUpImageVIew(imageconfig);\r
+        if (SilentModeImageView == nullptr)\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Background[1] new fail!");\r
-            return;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeImageView is nullptr!");\r
+            return false;\r
         }\r
-        /* ------------------------- VibrationReminderLabel ------------------------- */\r
+\r
+        imageconfig = {\r
+            .x = 369,\r
+            .w = 14,\r
+            .h = 26,\r
+            .ImageSrc = "/user/res/SETTING_NEXT.bin",\r
+        };\r
+\r
+        for (int i = 0; i < 3; i++)\r
+        {\r
+            imageconfig.y = 157 + 120 * i;\r
+            nextImageView[i] = SetUpImageVIew(imageconfig);\r
+            if (nextImageView[i] == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView:: nextImageView[%d] is nullptr!", i);\r
+                return false;\r
+            }\r
+        }\r
+\r
+        return true;\r
+    }\r
+\r
+    bool SoundAndVibrationView::InitSoundAndVibrationLabel(void)\r
+    {\r
         LabelConfig labelConfig = {\r
             .left = 90,\r
-            .top = 513,\r
+            .top = 140,\r
             .width = 120,\r
             .height = 35,\r
             .fontSize = 30,\r
             .lineHeigh = 35,\r
-            .text = "震动提醒",\r
             .lineBreakMode = UILabel::LINE_BREAK_ADAPT,\r
         };\r
+        /* ---------------------------- SystemVolumeLabel --------------------------- */\r
+        labelConfig.text = "系统音量";\r
+        SystemVolumeLabel = SetUpLabel(labelConfig);\r
+        if (SystemVolumeLabel == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SystemVolumeLabel is nullptr!");\r
+            return false;\r
+        }\r
+        /* ----------------------------- CallVolumeLabel ---------------------------- */\r
+        labelConfig.top = 260;\r
+        labelConfig.text = "通话音量";\r
+        CallVolumeLabel = SetUpLabel(labelConfig);\r
+        if (CallVolumeLabel == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CallVolumeLabel is nullptr!");\r
+            return false;\r
+        }\r
+        /* ---------------------------- MediaVolumeLabel ---------------------------- */\r
+        labelConfig.top = 380;\r
+        labelConfig.text = "媒体音量";\r
+        MediaVolumeLabel = SetUpLabel(labelConfig);\r
+        if (MediaVolumeLabel == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::MediaVolumeLabel is nullptr!");\r
+            return false;\r
+        }\r
+        /* ------------------------- VibrationReminderLabel ------------------------- */\r
+        labelConfig.top = 513;\r
+        labelConfig.text = "震动提醒";\r
         VibrationReminderLabel = SetUpLabel(labelConfig);\r
         if (VibrationReminderLabel == nullptr)\r
         {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::VibrationReminderLabel is nullptr!");\r
-            return;\r
+            return false;\r
         }\r
         /* ----------------------------- SilentModeLabel ---------------------------- */\r
         labelConfig.top = 620;\r
@@ -257,28 +357,57 @@ namespace OHOS
         if (SilentModeLabel == nullptr)\r
         {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeLabel is nullptr!");\r
-            return;\r
+            return false;\r
         }\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
+        typedef struct\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeLabel_ is nullptr!");\r
-            return;\r
+            int top;\r
+            char text[100];\r
+        } LabelInfo;\r
+\r
+        LabelInfo labelInfo[] = {\r
+            {177, "闹钟、提醒、查找手表"},\r
+            {297, "手表通话"},\r
+            {417, "音乐、录音、训练"},\r
+            {657, "系统音量不受影响"},\r
+        };\r
+        for (int i = 0; i < sizeof(labelInfo) / sizeof(labelInfo[0]); i++)\r
+        {\r
+            LabelConfig labelConfig = {\r
+                .left = 90,\r
+                .top = labelInfo[i].top,\r
+                .width = 300,\r
+                .height = 35,\r
+                .fontSize = 20,\r
+                .lineHeigh = 23,\r
+                .text = labelInfo[i].text,\r
+                .lineBreakMode = UILabel::LINE_BREAK_ADAPT,\r
+            };\r
+\r
+            reminder[i] = SetUpLabel(labelConfig);\r
+            if (reminder[i] == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::reminder[%d] is nullptr!", i);\r
+                return false;\r
+            }\r
+\r
+            reminder[i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+            reminder[i]->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
+            reminder[i]->SetTextColor(Color::GetColorFromRGBA(0xfd, 0xfd, 0xfd, 0x7f));\r
         }\r
-        SilentModeLabel_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-        SilentModeLabel_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        SilentModeLabel_->SetTextColor(Color::GetColorFromRGBA(0xfd, 0xfd, 0xfd, 0x7f));\r
+        return true;\r
+    }\r
+\r
+    bool SoundAndVibrationView::InitSoundAndVibrationToggleButton(void)\r
+    {\r
+        UIView::OnClickListener *ButtonClick = static_cast<UIView::OnClickListener *>(SoundAndVibrationPresenter::GetInstance());\r
         /* ---------------------- VibrationReminderToggleButton --------------------- */\r
         VibrationReminderToggleButton = new UIToggleButton();\r
         if (VibrationReminderToggleButton == nullptr)\r
         {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::VibrationReminderToggleButton new  fail!");\r
-            return;\r
+            return false;\r
         }\r
         VibrationReminderToggleButton->SetPosition(298, 505, 100, 50);\r
         VibrationReminderToggleButton->SetViewId(VIBRATION_REMINDER_TOGGLEBUTTON);\r
@@ -293,7 +422,7 @@ namespace OHOS
         if (SilentModeToggleButton == nullptr)\r
         {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeToggleButton new  fail!");\r
-            return;\r
+            return false;\r
         }\r
         SilentModeToggleButton->SetPosition(298, 625, 100, 50);\r
         SilentModeToggleButton->SetViewId(SILENT_MODEL_TOGGLEBUTTON);\r
@@ -301,7 +430,35 @@ namespace OHOS
         SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
         SilentModeToggleButton->SetImages(ToggleButtonSelect, ToggleButtonUnSelect);\r
         SilentModeToggleButton->SetOnClickListener(ButtonClick);\r
+        return true;\r
+    }\r
 \r
+    void SoundAndVibrationView::InitView(void)\r
+    {\r
+        if (InitSoundAndVibrationScrollView() == false)\r
+        {\r
+            return;\r
+        }\r
+        if (InitSoundAndVibrationViewTitleLabel() == false)\r
+        {\r
+            return;\r
+        }\r
+        if (InitSoundAndVibrationButtonView() == false)\r
+        {\r
+            return;\r
+        }\r
+        if (InitSoundAndVibrationImageView() == false)\r
+        {\r
+            return;\r
+        }\r
+        if (InitSoundAndVibrationToggleButton() == false)\r
+        {\r
+            return;\r
+        }\r
+        if (InitSoundAndVibrationLabel() == false)\r
+        {\r
+            return;\r
+        }\r
         initViewStatus = true;\r
     }\r
 \r
@@ -318,11 +475,20 @@ namespace OHOS
         SoundAndVibrationScrollView->Add(SystemVolumeButton);\r
         SoundAndVibrationScrollView->Add(CallVolumeButton);\r
         SoundAndVibrationScrollView->Add(MediaVolumeButton);\r
-        SoundAndVibrationScrollView->Add(Background[0]);\r
-        SoundAndVibrationScrollView->Add(Background[1]);\r
+        SoundAndVibrationScrollView->Add(VibrationReminderImageView);\r
+        SoundAndVibrationScrollView->Add(SilentModeImageView);\r
+        SoundAndVibrationScrollView->Add(SystemVolumeLabel);\r
+        SoundAndVibrationScrollView->Add(CallVolumeLabel);\r
+        SoundAndVibrationScrollView->Add(MediaVolumeLabel);\r
         SoundAndVibrationScrollView->Add(VibrationReminderLabel);\r
         SoundAndVibrationScrollView->Add(SilentModeLabel);\r
-        SoundAndVibrationScrollView->Add(SilentModeLabel_);\r
+        SoundAndVibrationScrollView->Add(reminder[0]);\r
+        SoundAndVibrationScrollView->Add(reminder[1]);\r
+        SoundAndVibrationScrollView->Add(reminder[2]);\r
+        SoundAndVibrationScrollView->Add(reminder[3]);\r
+        SoundAndVibrationScrollView->Add(nextImageView[0]);\r
+        SoundAndVibrationScrollView->Add(nextImageView[1]);\r
+        SoundAndVibrationScrollView->Add(nextImageView[2]);\r
         SoundAndVibrationScrollView->Add(VibrationReminderToggleButton);\r
         SoundAndVibrationScrollView->Add(SilentModeToggleButton);\r
         RootView::GetInstance()->Add(SoundAndVibrationScrollView);\r
index 4f65e77..dc16bb2 100644 (file)
@@ -1,4 +1,6 @@
 #include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h"
+#include "soundandvibration/include/SoundAndVibrationPresenter.h"
+#include "soundandvibration/include/SystemVolumePresenter.h"
 #include "wearable_log.h"
 
 namespace OHOS
@@ -28,27 +30,34 @@ namespace OHOS
     {
         if (initViewStatus == true)
         {
-            group->RemoveAll();
+            ScrollView->RemoveAll();
             delete VolumeProcess;
             VolumeProcess = nullptr;
             delete VolumeVetor;
             VolumeVetor = nullptr;
-            delete group;
-            group = nullptr;
+            delete ScrollView;
+            ScrollView = nullptr;
         }
     }
 
-    UIViewGroup *SoundAndVibrationVolumeSettingView::SetUpVolumeProcess(void)
+    UIScrollView *SoundAndVibrationVolumeSettingView::SetUpVolumeProcess(void)
     {
-        group = new UIViewGroup();
-        if (group == nullptr)
+        ScrollView = new UIScrollView();
+        if (ScrollView == nullptr)
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::group new fail");
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::ScrollView new fail");
             return nullptr;
         }
-        group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
-        group->SetDraggable(true);
-        group->SetTouchable(true);
+        ScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+        UIView::OnDragListener *volumeDragListener = (UIView::OnDragListener *)OHOS::SystemVolumePresenter::GetInstance();
+        if (volumeDragListener == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumePresenter GetInstance fail");
+            return nullptr;
+        }
+        ScrollView->SetOnDragListener(volumeDragListener);
+        ScrollView->SetDraggable(true);
+        ScrollView->SetTouchable(true);
         /* ------------------------------ VolumeProcess ----------------------------- */
         VolumeProcess = new UISlider();
         if (VolumeProcess == nullptr)
@@ -92,15 +101,12 @@ namespace OHOS
         // 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);
+        ScrollView->Add(VolumeProcess);
+        ScrollView->Add(VolumeVetor);
         initViewStatus = true;
-        return group;
+        return ScrollView;
     }
 
 }
\ No newline at end of file
index 0a94a4c..2ff1653 100644 (file)
@@ -27,7 +27,7 @@ namespace OHOS
 \r
         return g_pSystemVolumeView;\r
     }\r
-    UIViewGroup *SystemVolumeView::SystemVolumeViewInit(void)\r
+    UIScrollView *SystemVolumeView::SystemVolumeViewInit(void)\r
     {\r
         p_SoundAndVibrationVolumeSettingView = new SoundAndVibrationVolumeSettingView();\r
         if (p_SoundAndVibrationVolumeSettingView == nullptr)\r
@@ -35,14 +35,14 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!");\r
             return nullptr;\r
         }\r
-        group = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess();\r
-        if (group == nullptr)\r
+        SystemVolumeScrollView = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess();\r
+        if (SystemVolumeScrollView == nullptr)\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::group is nullptr!");\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::SystemVolumeScrollView is nullptr!");\r
             return nullptr;\r
         }\r
 \r
-        return group;\r
+        return SystemVolumeScrollView;\r
     }\r
 \r
     void SystemVolumeView::OnStart()\r
@@ -54,7 +54,7 @@ namespace OHOS
     void SystemVolumeView::OnSetUpView()\r
     {\r
         View<SystemVolumePresenter>::OnSetUpView();\r
-        RootView::GetInstance()->Add(group);\r
+        RootView::GetInstance()->Add(SystemVolumeScrollView);\r
         Draw();\r
     }\r
 \r
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/CALL_VOLUME.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/CALL_VOLUME.bin
deleted file mode 100644 (file)
index cb2c53a..0000000
Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/CALL_VOLUME.bin and /dev/null differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/MEDIA_VOLUME.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/MEDIA_VOLUME.bin
deleted file mode 100644 (file)
index 16f64f0..0000000
Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/MEDIA_VOLUME.bin and /dev/null differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/SYSTEM_VOLUME.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/SYSTEM_VOLUME.bin
deleted file mode 100644 (file)
index 95333ff..0000000
Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/SYSTEM_VOLUME.bin and /dev/null differ