声音与震动Slice优化:
authorluozheng <1732036298@qq.com>
Wed, 24 Jul 2024 09:57:31 +0000 (17:57 +0800)
committerluozheng <1732036298@qq.com>
Wed, 24 Jul 2024 09:57:31 +0000 (17:57 +0800)
1.解决如果是点击设置音量退出Slice未将音量值保存的问题
2.优化了如果是拖拽设置致使多次调用OnChange,实际上我们只要我们手指离开屏幕最后设置的值。

code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumeView.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/VibrationModeView.cpp

index 19caa95..f7cea52 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-07-18 14:26:08
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-20 15:09:36
+ * @LastEditTime: 2024-07-24 17:35:57
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp
  */
 
@@ -498,13 +498,13 @@ namespace OHOS
     {
         if (showView < 0 || showView >= REBOOTANDSHUTDOWN_MAX)
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "REBOOTANDSHUTDOWN_MAX::CheckViewParam showView err.");
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CheckViewParam showView err.");
             return false;
         }
 
         if (hideView < 0 || hideView > REBOOTANDSHUTDOWN_MAX)
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "REBOOTANDSHUTDOWN_MAX::CheckViewParam hideView err.");
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CheckViewParam hideView err.");
             return false;
         }
 
index b8c021b..44ec1d1 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com\r
  * @Date: 2024-04-19 21:03:26\r
  * @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-06-19 17:44:40\r
+ * @LastEditTime: 2024-07-24 17:33:52\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h\r
  */\r
 #ifndef SOUND_AND_VIBRATION_VIEW_H\r
@@ -43,15 +43,26 @@ namespace OHOS
             int16_t w;\r
             int16_t h;\r
             const char *ViewId;\r
-            // std::string Text;\r
             int16_t TextId;\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
+            int16_t textId;\r
+            uint8_t lineBreakMode;\r
+        };\r
         SoundAndVibrationView();\r
         virtual ~SoundAndVibrationView();\r
         static SoundAndVibrationView *GetInstance(void);\r
         bool ChangeSoundAndVibrationView(int16_t thisView);\r
         bool ChangeVibrationModeView(int16_t thisView);\r
         bool ClickFunc(int16_t interface);\r
+        bool CheckViewParam(int16_t hideView, int16_t showView);\r
         void ChangeView(int16_t hideView, int16_t showView);\r
         VibrationModeView *GetVibrationModeView(void);\r
         bool UpdateSilentModeSwitchStatus(void);\r
@@ -68,6 +79,7 @@ namespace OHOS
         void CreateSoundAndVibrationView(void);\r
         void ClearAll(void);\r
         UILabelButtonExt *SetUpButton_Ext(ButtonConfig &buttonconfig, bool nextImgVisible);\r
+        UILabelExt *SetUpLabel_Ext(LabelConfig &labelConfig);\r
         bool InitSoundAndVibrationScrollView(void);\r
         bool InitSoundAndVibrationViewTitleLabel(void);\r
         bool InitSoundAndVibrationButtonView(void);\r
@@ -80,7 +92,12 @@ namespace OHOS
         UILabelButtonExt *CallVolumeButton{nullptr};        // 通话音量按钮\r
         UILabelButtonExt *VibrationReminderButton{nullptr}; // 震动提醒按钮\r
         UILabelButtonExt *SilentModeButton{nullptr};        // 静音模式按钮\r
+        UILabelExt *SystemVolumeLabel{nullptr};             // 系统音量标签\r
+        UILabelExt *CallVolumeLabel{nullptr};               // 通话音量标签\r
+        UILabelExt *VibrationReminderLabel{nullptr};        // 震动提醒标签\r
+        UILabelExt *SilentModeLabel{nullptr};               // 静音模式标签\r
         UIToggleButton *SilentModeToggleButton{nullptr};    // 静音模式切换按钮\r
+        bool initViewStatus{false};\r
     };\r
 } // namespace OHOS\r
 \r
index 30eb50f..f3f398e 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-04-19 10:08:21
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-04-19 19:01:46
+ * @LastEditTime: 2024-07-24 16:35:52
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h
  */
 #ifndef SOUND_AND_VIBRATION_VOLUME_SETTING_PRESENTER_H
@@ -35,20 +35,26 @@ namespace OHOS
      */
     class VoumeProcessSliderEventListener : public UISlider::UISliderEventListener,
                                             public UIView::OnClickListener,
-                                            public UIView::OnDragListener
+                                            public UIView::OnDragListener,
+                                            public UIView::OnRotateListener
     {
     public:
         VoumeProcessSliderEventListener();
         ~VoumeProcessSliderEventListener();
         static VoumeProcessSliderEventListener *GetInstance(void);
+        void FindAndApplyStrategy(uint8_t status, uint8_t value);
         void ChangeVolumeValue(uint8_t status, uint8_t value);
         void OnChange(int32_t value) override;
         void OnRelease(int32_t value) override;
         bool OnClick(UIView &view, const ClickEvent &event) override;
         bool OnDrag(UIView &view, const DragEvent &event) override;
+        bool OnRotateEnd(UIView& view, const RotateEvent& event);
 
     private:
         std::map<uint8_t, std::shared_ptr<VolumeChangeStrategy>> strategyMap;
+        bool isOnClickSlider{true};
+        bool isDragSlider{false};
+        bool isRotateSlider{false};
     };
 }
 
index bc93bc8..d05d2ed 100644 (file)
@@ -67,6 +67,11 @@ namespace OHOS
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumeView::OnStart");\r
         View<CallVolumePresenter>::OnStart();\r
         SetContainerView(new UIViewGroup());\r
+        if (GetContainer() == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!");\r
+            return;\r
+        }\r
         container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
         container_->SetTouchable(true);\r
         container_->SetDraggable(true);\r
index 251303e..54c3c6d 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com\r
  * @Date: 2024-02-19 10:39:14\r
  * @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-06-20 18:03:01\r
+ * @LastEditTime: 2024-07-24 17:48:13\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp\r
  */\r
 #include "soundandvibration/include/SoundAndVibrationView.h"\r
@@ -56,30 +56,45 @@ namespace OHOS
             container_ = nullptr;\r
         }\r
 \r
-        if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] != nullptr)\r
+        if (initViewStatus)\r
         {\r
-            SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->RemoveAll();\r
+            if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] != nullptr)\r
+            {\r
+                SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->RemoveAll();\r
+\r
+                delete Title;\r
+                Title = nullptr;\r
+\r
+                delete SystemVolumeButton;\r
+                SystemVolumeButton = nullptr;\r
 \r
-            delete Title;\r
-            Title = nullptr;\r
+                delete CallVolumeButton;\r
+                CallVolumeButton = nullptr;\r
 \r
-            delete SystemVolumeButton;\r
-            SystemVolumeButton = nullptr;\r
+                delete VibrationReminderButton;\r
+                VibrationReminderButton = nullptr;\r
 \r
-            delete CallVolumeButton;\r
-            CallVolumeButton = nullptr;\r
+                delete SilentModeButton;\r
+                SilentModeButton = nullptr;\r
 \r
-            delete VibrationReminderButton;\r
-            VibrationReminderButton = nullptr;\r
+                delete SilentModeToggleButton;\r
+                SilentModeToggleButton = nullptr;\r
 \r
-            delete SilentModeButton;\r
-            SilentModeButton = nullptr;\r
+                delete SystemVolumeLabel;\r
+                SystemVolumeLabel = nullptr;\r
 \r
-            delete SilentModeToggleButton;\r
-            SilentModeToggleButton = nullptr;\r
+                delete CallVolumeLabel;\r
+                CallVolumeLabel = nullptr;\r
 \r
-            delete SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW];\r
-            SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = nullptr;\r
+                delete VibrationReminderLabel;\r
+                VibrationReminderLabel = nullptr;\r
+\r
+                delete SilentModeLabel;\r
+                SilentModeLabel = nullptr;\r
+\r
+                delete SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW];\r
+                SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = nullptr;\r
+            }\r
         }\r
 \r
         if (vibrationModeView != nullptr)\r
@@ -109,11 +124,31 @@ namespace OHOS
         SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetThrowDrag(true);\r
         SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetTouchable(true);\r
         SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetDraggable(true);\r
+        SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->RequestFocus();\r
+        SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetRotateFactor(2.0);\r
         container_->Add(SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]);\r
 \r
         return true;\r
     }\r
 \r
+    UILabelExt *SoundAndVibrationView::SetUpLabel_Ext(LabelConfig &labelconfig)\r
+    {\r
+        UILabelExt *label = new UILabelExt();\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->SetTextId(labelconfig.textId);\r
+        label->SetLineBreakMode(labelconfig.lineBreakMode);\r
+        label->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);\r
+        label->SetRollSpeed(70);\r
+        label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);\r
+        return label;\r
+    }\r
+\r
     /// @brief 声音与震动视图"标题"标签初始化\r
     /// @param  void\r
     /// @return true 初始化成功 false 初始化失败\r
@@ -125,15 +160,49 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Title new fail!");\r
             return false;\r
         }\r
-        Title->SetPosition(83, 52, 300, 35);\r
+        Title->SetPosition(83, 50, 300, 35);\r
         Title->SetStyle(STYLE_TEXT_FONT, 30);\r
         Title->SetStyle(STYLE_LINE_HEIGHT, 35);\r
         Title->SetTextId(STR_SOUND_AND_VIBRATION); // 声音与震动\r
-        Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
+        Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);\r
+        Title->SetRollSpeed(70);\r
         Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
         Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
         SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(Title);\r
-\r
+        /* -------------------------------------------------------------------------- */\r
+        LabelConfig labelConfig;\r
+        struct LabelSetup\r
+        {\r
+            int16_t y;\r
+            const int16_t textId;\r
+        };\r
+        LabelSetup labelSetups[] = {\r
+            {152, STR_SYSTEM_VOLUME},\r
+            {272, STR_CALL_VOLUME},\r
+            {392, STR_VIBRATION_MODE},\r
+            {512, STR_SILENT_MODE},\r
+        };\r
+        UILabelExt *labelPointers[] = {SystemVolumeLabel, CallVolumeLabel, VibrationReminderLabel, SilentModeLabel};\r
+        for (int i = 0; i < sizeof(labelSetups) / sizeof(labelSetups[0]); ++i)\r
+        {\r
+            labelConfig = {\r
+                .left = 90,\r
+                .top = labelSetups[i].y,\r
+                .width = 240,\r
+                .height = 35,\r
+                .fontSize = 30,\r
+                .lineHeigh = 35,\r
+                .textId = labelSetups[i].textId,\r
+                .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,\r
+            };\r
+            labelPointers[i] = SetUpLabel_Ext(labelConfig);\r
+            if (labelPointers[i] == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::labelPointers[%d] new fail!", i);\r
+                return false;\r
+            }\r
+            SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(labelPointers[i]);\r
+        }\r
         return true;\r
     }\r
 \r
@@ -156,12 +225,12 @@ namespace OHOS
             labelButton->SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE);\r
             labelButton->SetImagePosition(326, 37);\r
         }\r
-        labelButton->SetTextId(buttonconfig.TextId);\r
-        labelButton->SetAlign(TEXT_ALIGNMENT_LEFT);\r
-        labelButton->SetLabelPosition(47, 0);\r
-        labelButton->SetStyle(STYLE_TEXT_FONT, 30);\r
-        labelButton->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-        labelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        // labelButton->SetTextId(buttonconfig.TextId);\r
+        // labelButton->SetAlign(TEXT_ALIGNMENT_LEFT);\r
+        // labelButton->SetLabelPosition(47, 0);\r
+        // labelButton->SetStyle(STYLE_TEXT_FONT, 30);\r
+        // labelButton->SetStyle(STYLE_LINE_HEIGHT, 35);\r
+        // labelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
         labelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, nextImgVisible ? 0xff000000 : 0xff191919, UIButton::PRESSED);\r
 \r
         return labelButton;\r
@@ -175,15 +244,15 @@ namespace OHOS
         {\r
             int y;\r
             const char *viewId;\r
-            const int16_t textId;\r
             bool clickEffect;\r
         };\r
 \r
         ButtonSetup buttonSetups[] = {\r
-            {120, SYSTEM_VOLUME_BUTTON, STR_SYSTEM_VOLUME, true},\r
-            {240, CALL_VOLUME_BUTTON, STR_CALL_VOLUME, true},\r
-            {360, VIBRATION_REMINDER_BUTTON, STR_VIBRATION_MODE, true},\r
-            {480, SILENT_MODE_BUTTON, STR_SILENT_MODE, false}};\r
+            {120, SYSTEM_VOLUME_BUTTON, true},\r
+            {240, CALL_VOLUME_BUTTON, true},\r
+            {360, VIBRATION_REMINDER_BUTTON, true},\r
+            {480, SILENT_MODE_BUTTON, false},\r
+        };\r
 \r
         UILabelButtonExt *buttonPointers[] = {SystemVolumeButton, CallVolumeButton, VibrationReminderButton, SilentModeButton};\r
 \r
@@ -195,7 +264,7 @@ namespace OHOS
                 .w = 380,\r
                 .h = 100,\r
                 .ViewId = buttonSetups[i].viewId,\r
-                .TextId = buttonSetups[i].textId};\r
+            };\r
             buttonPointers[i] = SetUpButton_Ext(buttonconfig, buttonSetups[i].clickEffect);\r
             if (buttonPointers[i] == nullptr)\r
             {\r
@@ -231,12 +300,13 @@ namespace OHOS
     void SoundAndVibrationView::CreateSoundAndVibrationView(void)\r
     {\r
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CreateSoundAndVibrationView");\r
-        if (!InitSoundAndVibrationScrollView() || !InitSoundAndVibrationViewTitleLabel() ||\r
-            !InitSoundAndVibrationButtonView() || !InitSoundAndVibrationToggleButton())\r
+        if (!InitSoundAndVibrationScrollView() || !InitSoundAndVibrationButtonView() ||\r
+            !InitSoundAndVibrationViewTitleLabel() || !InitSoundAndVibrationToggleButton())\r
         {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CreateSoundAndVibrationView fail!!");\r
             return;\r
         }\r
+        initViewStatus = true;\r
     }\r
 \r
     void SoundAndVibrationView::OnStart()\r
@@ -244,12 +314,20 @@ namespace OHOS
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::OnStart");\r
         View<SoundAndVibrationPresenter>::OnStart();\r
         SetContainerView(new UIViewGroup());\r
+        if (GetContainer() == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!");\r
+            return;\r
+        }\r
         container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
         container_->SetOnDragListener(presenter_);\r
         container_->SetTouchable(true);\r
         container_->SetDraggable(true);\r
 \r
-        CreateSoundAndVibrationView();\r
+        if (!initViewStatus)\r
+        {\r
+            CreateSoundAndVibrationView();\r
+        }\r
         RootView::GetInstance()->SetOnKeyActListener(presenter_);\r
     }\r
 \r
@@ -334,11 +412,29 @@ namespace OHOS
         return false;\r
     }\r
 \r
+    /*检查传入的两个视图参数 hideView 和 showView 的有效性。*/\r
+    bool SoundAndVibrationView::CheckViewParam(int16_t hideView, int16_t showView)\r
+    {\r
+        if (showView < 0 || showView >= MAX_SOUNDANDVIBRATIONVIEWID)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CheckViewParam showView err.");\r
+            return false;\r
+        }\r
+\r
+        if (hideView < 0 || hideView > MAX_SOUNDANDVIBRATIONVIEWID)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CheckViewParam hideView err.");\r
+            return false;\r
+        }\r
+\r
+        return true;\r
+    }\r
+\r
     void SoundAndVibrationView::ChangeView(int16_t hideView, int16_t showView)\r
     {\r
-        if (hideView > MAX_SOUNDANDVIBRATIONVIEWID)\r
+        if (!CheckViewParam(hideView, showView))\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " Overstep ones bounds");\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CheckViewParam failed.");\r
             return;\r
         }\r
         SoundAndVibrationScrollView[hideView]->SetVisible(false);\r
@@ -353,7 +449,7 @@ namespace OHOS
         return vibrationModeView;\r
     }\r
 \r
-    //更新静音模式开关状态\r
+    // 更新静音模式开关状态\r
     bool SoundAndVibrationView::UpdateSilentModeSwitchStatus(void)\r
     {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::UpdateSilentModeSwitchStatus");\r
index bfd70a1..3363612 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-04-19 10:08:31
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-04-22 20:26:10
+ * @LastEditTime: 2024-07-24 16:37:37
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp
  */
 #include "soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h"
@@ -87,7 +87,7 @@ namespace OHOS
     static VoumeProcessSliderEventListener *g_pVoumeProcessSliderEventListener{nullptr};
     VoumeProcessSliderEventListener::VoumeProcessSliderEventListener()
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::VoumeProcessSliderEventListener");
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::VoumeProcessSliderEventListener");
         // 步骤 3: 创建一个映射表将状态映射到策略
         strategyMap[VOLUMEREDUCE] = std::make_shared<LowerVolumeStrategy>();
         strategyMap[VOLUMEADD] = std::make_shared<ElevateVolumeStrategy>();
@@ -97,7 +97,7 @@ namespace OHOS
 
     VoumeProcessSliderEventListener::~VoumeProcessSliderEventListener()
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::~VoumeProcessSliderEventListener");
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::~VoumeProcessSliderEventListener");
         g_pVoumeProcessSliderEventListener = nullptr;
     }
 
@@ -106,7 +106,7 @@ namespace OHOS
         return g_pVoumeProcessSliderEventListener;
     }
 
-    void VoumeProcessSliderEventListener::ChangeVolumeValue(uint8_t status, uint8_t value)
+    void VoumeProcessSliderEventListener::FindAndApplyStrategy(uint8_t status, uint8_t value)
     {
         auto it = strategyMap.find(status);
         if (it != strategyMap.end())
@@ -120,38 +120,97 @@ namespace OHOS
         }
     }
 
+    void VoumeProcessSliderEventListener::ChangeVolumeValue(uint8_t status, uint8_t value)
+    {
+        FindAndApplyStrategy(status, value);
+
+        SoundAndVibrationVolumeSettingView *view = SoundAndVibrationVolumeSettingView::GetInstance();
+        if (view)
+        {
+            if (view->GetVolumeType() == SYSTEM_VOLUME)
+            {
+                ConfigModel::GetInstance()->SetSystemVolume(value);
+            }
+            else if (view->GetVolumeType() == CALL_VOLUME)
+            {
+                ConfigModel::GetInstance()->SetCallVolume(value);
+            }
+        }
+    }
+
+    // 滑块变化事件处理
     void VoumeProcessSliderEventListener::OnChange(int32_t value)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnChange %d", value);
-        ChangeVolumeValue(OTHER, value);
+        if (isOnClickSlider && !isDragSlider && !isRotateSlider)
+        {
+            ChangeVolumeValue(OTHER, value);
+        }
     }
 
+    // 滑块释放事件处理
     void VoumeProcessSliderEventListener::OnRelease(int32_t value)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnRelease %d", value);
         ChangeVolumeValue(OTHER, value);
-
-        if ( SoundAndVibrationVolumeSettingView::GetInstance()->GetVolumeType() == SYSTEM_VOLUME)
-        {
-            ConfigModel::GetInstance()->SetSystemVolume(value);
-        }
-        else if (SoundAndVibrationVolumeSettingView::GetInstance()->GetVolumeType() == CALL_VOLUME)
-        {
-            ConfigModel::GetInstance()->SetCallVolume(value);
-        }
     }
 
+    // 滑块点击事件处理
     bool VoumeProcessSliderEventListener::OnClick(UIView &view, const ClickEvent &event)
     {
         UNUSED(event);
-        UNUSED(view);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::OnClick");
+        UISlider *slider = dynamic_cast<UISlider *>(&view);
+        SoundAndVibrationVolumeSettingView *soundAndVibrationVolumeSettingView = SoundAndVibrationVolumeSettingView::GetInstance();
+        if (slider != nullptr && soundAndVibrationVolumeSettingView != nullptr)
+        {
+            if (slider == soundAndVibrationVolumeSettingView->GetVolumeProcess())
+            {
+                isOnClickSlider = true;
+                isDragSlider = false;
+                isRotateSlider = false;
+            }
+        }
         return true;
     }
 
+    // 滑块拖动事件处理
     bool VoumeProcessSliderEventListener::OnDrag(UIView &view, const DragEvent &event)
     {
         UNUSED(event);
-        UNUSED(view);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::OnDrag");
+        UISlider *slider = dynamic_cast<UISlider *>(&view);
+        SoundAndVibrationVolumeSettingView *soundAndVibrationVolumeSettingView = SoundAndVibrationVolumeSettingView::GetInstance();
+        if (slider != nullptr && soundAndVibrationVolumeSettingView != nullptr)
+        {
+            if (slider == soundAndVibrationVolumeSettingView->GetVolumeProcess())
+            {
+                isOnClickSlider = false;
+                isDragSlider = true;
+                isRotateSlider = false;
+            }
+        }
+        return true;
+    }
+
+    // 滑块旋转结束事件处理
+    bool VoumeProcessSliderEventListener::OnRotateEnd(UIView &view, const RotateEvent &event)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::OnRotateEnd");
+        UISlider *slider = dynamic_cast<UISlider *>(&view);
+        SoundAndVibrationVolumeSettingView *soundAndVibrationVolumeSettingView = SoundAndVibrationVolumeSettingView::GetInstance();
+        if (slider != nullptr && soundAndVibrationVolumeSettingView != nullptr)
+        {
+            if (slider == soundAndVibrationVolumeSettingView->GetVolumeProcess())
+            {
+                isDragSlider = false;
+                isOnClickSlider = false;
+                isRotateSlider = true;
+
+                int value = slider->GetValue();
+                ChangeVolumeValue(OTHER, value);
+            }
+        }
         return true;
     }
 }
index eea2125..f4254f4 100644 (file)
@@ -11,14 +11,14 @@ namespace OHOS
 
     SoundAndVibrationVolumeSettingView::SoundAndVibrationVolumeSettingView(uint8_t VolumeType)
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::SoundAndVibrationVolumeSettingView,VolumeType = %d", VolumeType);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::SoundAndVibrationVolumeSettingView,VolumeType = %d", VolumeType);
         m_VolumeType = VolumeType;
         g_pSoundAndVibrationVolumeSettingView = this;
     }
 
     SoundAndVibrationVolumeSettingView::~SoundAndVibrationVolumeSettingView()
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::~SoundAndVibrationVolumeSettingView");
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::~SoundAndVibrationVolumeSettingView");
         ClearAll();
         g_pSoundAndVibrationVolumeSettingView = nullptr;
     }
@@ -32,19 +32,27 @@ namespace OHOS
     {
         if (initViewStatus == true)
         {
-            ScrollView->RemoveAll();
-
-            delete VolumeProcess;
-            VolumeProcess = nullptr;
-
-            delete VolumeVetor;
-            VolumeVetor = nullptr;
-
-            delete listener;
-            listener = nullptr;
-
-            delete ScrollView;
-            ScrollView = nullptr;
+            if (ScrollView != nullptr)
+            {
+                ScrollView->RemoveAll();
+                if (VolumeProcess != nullptr)
+                {
+                    delete VolumeProcess;
+                    VolumeProcess = nullptr;
+                }
+                if (VolumeVetor != nullptr)
+                {
+                    delete VolumeVetor;
+                    VolumeVetor = nullptr;
+                }
+                if (listener != nullptr)
+                {
+                    delete listener;
+                    listener = nullptr;
+                }
+                delete ScrollView;
+                ScrollView = nullptr;
+            }
         }
     }
 
@@ -96,6 +104,8 @@ namespace OHOS
         VolumeProcess->SetSliderColor(Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
         VolumeProcess->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff);
         VolumeProcess->SetKnobStyle(StyleDefault::GetSliderKnobStyle());
+        VolumeProcess->RequestFocus();
+        VolumeProcess->SetRotateFactor(1.0);
         /* ------------------------------- VolumeVetor ------------------------------ */
         VolumeVetor = new UIImageView();
         if (VolumeVetor == nullptr)
@@ -118,12 +128,12 @@ namespace OHOS
         VolumeProcess->SetSliderEventListener(listener);
         VolumeProcess->SetOnClickListener(listener);
         VolumeProcess->SetOnDragListener(listener);
-        VolumeProcess->SetKnobStyle(StyleDefault::GetSliderKnobStyle());
+        VolumeProcess->SetOnRotateListener(listener);
 
         ScrollView->Add(VolumeProcess);
         ScrollView->Add(VolumeVetor);
         initViewStatus = true;
-        
+
         return ScrollView;
     }
 
index 8b4a567..30db852 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com\r
  * @Date: 2024-06-12 11:44:04\r
  * @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-06-19 18:21:36\r
+ * @LastEditTime: 2024-07-23 16:58:58\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp\r
  */\r
 #include "soundandvibration/include/SystemVolumeView.h"\r
@@ -77,6 +77,11 @@ namespace OHOS
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::OnStart");\r
         View<SystemVolumePresenter>::OnStart();\r
         SetContainerView(new UIViewGroup());\r
+        if (GetContainer() == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!");\r
+            return;\r
+        }\r
         container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
         container_->SetTouchable(true);\r
         container_->SetDraggable(true);\r
index b5512d6..4cbd6c2 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-04-22 14:35:22
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-19 15:31:31
+ * @LastEditTime: 2024-07-24 17:49:58
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/VibrationModeView.cpp
  */
 #include "soundandvibration/include/VibrationModeView.h"
@@ -14,7 +14,7 @@
 namespace OHOS
 {
 
-    static constexpr uint8_t ROTATEFACTOR = 2;
+    static constexpr const float ROTATEFACTOR = 1.0;
 
     static VibrationModeView *g_pVibrationModeView{nullptr};
 
@@ -94,11 +94,12 @@ namespace OHOS
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationModeView::Title is nullptr!");
                 return nullptr;
             }
-            Title->SetPosition(93, 52, 280, 40);
+            Title->SetPosition(93, 50, 280, 40);
             Title->SetStyle(STYLE_TEXT_FONT, 30);
             Title->SetStyle(STYLE_LINE_HEIGHT, 35);
             Title->SetTextId(STR_VIBRATION_MODE); // 震动模式
-            Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
+            Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+            Title->SetRollSpeed(70);
             Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
             Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
             scrollView->Add(Title);