From fd89f9c1c74fefb2033f01008e06a62eb9e52e7e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Fri, 27 Sep 2024 08:05:53 +0000 Subject: [PATCH] Merge #1033 into sdk602patch0626 from refs/changes/1033/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/1033/head: (2 commits squashed) - 1.解决slider和scrollview旋转编码器一直震动问题 2.解决slider旋转编码器方向是反的问题 3.slider添加旋转结束监听,结束后震动一次(受设置中震动强度影响) - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1033 --- .../include/BrightnessControlView.h | 6 ++++-- .../displaybrightness/src/BrightnessControlView.cpp | 9 +++++++++ .../nativeui/main/src/VolumeSettingPresenter.cpp | 2 ++ .../SoundAndVibrationVolumeSettingPresenter.h | 3 ++- .../src/SoundAndVibrationVolumeSettingPresenter.cpp | 13 ++++++++++--- .../ui/frameworks/components/ui_scroll_view.cpp | 4 ++-- .../uikit/ui/frameworks/components/ui_slider.cpp | 8 +++++--- 7 files changed, 34 insertions(+), 11 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/BrightnessControlView.h b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/BrightnessControlView.h index f03208a62..711250aa1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/BrightnessControlView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/BrightnessControlView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-01-29 15:37:44 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-18 14:52:47 + * @LastEditTime: 2024-09-27 15:07:34 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/BrightnessControlView.h */ #ifndef BRIGHTNESS_CONTROL_VIEW_H @@ -33,7 +33,8 @@ namespace OHOS static const char *BRIGHTNESS_CONTROL_SLIDER = "BrightnessControlViewSlider"; class BrightnessSliderEventListener : public UISlider::UISliderEventListener, public UIView::OnClickListener, - public UIView::OnDragListener + public UIView::OnDragListener, + public UIView::OnRotateListener { public: BrightnessSliderEventListener(); @@ -44,6 +45,7 @@ namespace OHOS 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> strategyMap; diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlView.cpp index 35515fff9..1ae94dd3b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlView.cpp @@ -6,6 +6,7 @@ #include "ConfigModel.h" #include "map" #include "iostream" +#include "vibrator_service.h" namespace OHOS { static BrightnessControlView *g_pBrightnessControlView{nullptr}; @@ -99,6 +100,7 @@ namespace OHOS BrightnessControlViewSlider->SetSliderEventListener(rawPointer); BrightnessControlViewSlider->SetOnClickListener(rawPointer); BrightnessControlViewSlider->SetOnDragListener(rawPointer); + BrightnessControlViewSlider->SetOnRotateListener(rawPointer); BrightnessControlViewSlider->SetKnobStyle(StyleDefault::GetSliderKnobStyle()); return true; } @@ -291,4 +293,11 @@ namespace OHOS UNUSED(view); return true; } + + bool BrightnessSliderEventListener::OnRotateEnd(UIView& view, const RotateEvent& event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnRotateEnd %d", value); + ui_api_vibrate_once_func();//受设置中震动强度控制 + return true; + } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp index 89b71bcc3..6353de17b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingPresenter.cpp @@ -19,6 +19,7 @@ #include "BluetoothHeadsetEvent.h" #include "bts_avrcp_controller.h" #include "ConfigModel.h" +#include "vibrator_service.h" namespace OHOS { @@ -173,6 +174,7 @@ bool VolumeSliderEventListener::OnRotateEnd(UIView& view, const RotateEvent& eve if (slider == progress) { ChangeVolume(VOLUMEDRAG); + ui_api_vibrate_once_func();//受设置中震动强度控制 } } return true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h index 954a2b737..76d63fa78 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-19 10:08:21 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-06 14:11:01 + * @LastEditTime: 2024-09-27 14:16:52 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h */ #ifndef SOUND_AND_VIBRATION_VOLUME_SETTING_PRESENTER_H @@ -48,6 +48,7 @@ namespace OHOS void OnRelease(int32_t value) override; bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnRotate(UIView& view, const RotateEvent& event); bool OnRotateEnd(UIView& view, const RotateEvent& event); private: diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp index eda49f13e..863643b50 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-19 10:08:31 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-14 18:27:21 + * @LastEditTime: 2024-09-27 15:08:56 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp */ #include "soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h" @@ -15,6 +15,7 @@ #include "../../../../../../middleware/services/media/foundation/audiomanager/frameworks/audioservice/include/audio_service.h" #include "vibrator_service.h" #include "ConfigModel.h" +#include namespace OHOS { @@ -181,9 +182,9 @@ namespace OHOS } // 滑块旋转结束事件处理 - bool VoumeProcessSliderEventListener::OnRotateEnd(UIView &view, const RotateEvent &event) + bool VoumeProcessSliderEventListener::OnRotate(UIView &view, const RotateEvent &event) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::OnRotateEnd"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::OnRotate,%d",event.GetRotate()); UISlider *slider = dynamic_cast(&view); SoundAndVibrationVolumeSettingView *soundAndVibrationVolumeSettingView = SoundAndVibrationVolumeSettingView::GetInstance(); if (slider != nullptr && soundAndVibrationVolumeSettingView != nullptr) @@ -200,6 +201,12 @@ namespace OHOS } return true; } + bool VoumeProcessSliderEventListener::OnRotateEnd(UIView& view, const RotateEvent& event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::OnRotateEnd,%d",event.GetRotate()); + ui_api_vibrate_once_func();//受设置中震动强度控制 + return true; + } } #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_scroll_view.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_scroll_view.cpp index ebfa86a75..1735310cd 100755 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_scroll_view.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_scroll_view.cpp @@ -139,14 +139,14 @@ bool UIScrollView::OnRotateEvent(const RotateEvent& event) uint16_t vibrationCnt = rotateLen / DEFAULT_SCROLL_VIEW_VIBRATION_LEN; for (uint16_t i = 0; i < vibrationCnt; i++) { GRAPHIC_LOGI("UIScrollView::OnRotateEvent calls TYPE_ONE vibrator"); - vibratorFunc(VibratorType::VIBRATOR_TYPE_ONE); + // vibratorFunc(VibratorType::VIBRATOR_TYPE_ONE); } lastVibratorRotateLen_ = totalRotateLen_; } } if (vibratorFunc != nullptr && (!lastIsEdge && isEdge)) { GRAPHIC_LOGI("UIScrollView::OnRotateEvent calls TYPE_THREE vibrator"); - vibratorFunc(VibratorType::VIBRATOR_TYPE_THREE); + // vibratorFunc(VibratorType::VIBRATOR_TYPE_THREE); } #endif return UIView::OnRotateEvent(event); diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_slider.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_slider.cpp index 98c572016..7833ee857 100755 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_slider.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_slider.cpp @@ -363,7 +363,9 @@ bool UISlider::OnDragEndEvent(const DragEvent& event) bool UISlider::OnRotateEvent(const RotateEvent& event) { int32_t realRotation = 0; - cachedRotation_ += event.GetRotate() * rotateFactor_; + int16_t invertedRotate = -event.GetRotate();//对旋转量取反 + cachedRotation_ += invertedRotate * rotateFactor_; + // cachedRotation_ += event.GetRotate() * rotateFactor_; realRotation = static_cast(cachedRotation_); if (realRotation == 0) { return UIView::OnRotateEvent(event); @@ -381,12 +383,12 @@ bool UISlider::OnRotateEvent(const RotateEvent& event) if (vibratorFunc != nullptr && lastValue != curValue_) { if (curValue_ == rangeMin_ || curValue_ == rangeMax_) { GRAPHIC_LOGI("UISlider::OnRotateEvent calls TYPE_THREE vibrator"); - vibratorFunc(VibratorType::VIBRATOR_TYPE_THREE); + // vibratorFunc(VibratorType::VIBRATOR_TYPE_THREE); } else { int32_t changedValue = MATH_ABS(curValue_ - lastValue); for (int32_t i = 0; i < changedValue; i++) { GRAPHIC_LOGI("UISlider::OnRotateEvent calls TYPE_TWO vibrator"); - vibratorFunc(VibratorType::VIBRATOR_TYPE_TWO); + // vibratorFunc(VibratorType::VIBRATOR_TYPE_TWO); } } } -- 2.17.1