From: luozheng <1732036298@qq.com> Date: Thu, 14 Mar 2024 03:50:23 +0000 (+0800) Subject: 声音与震动视图的系统音量已经可以调节系统 X-Git-Tag: release_V1.2.70_20241020_135402~1274^2~8^2~11 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=d21a5956be66786f91e3be0ddf1245e1e3bfb13b;p=mirrors%2FFD230.git 声音与震动视图的系统音量已经可以调节系统 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumeView.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumeView.h index 4a72e8f11..b05764327 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumeView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumeView.h @@ -24,11 +24,14 @@ namespace OHOS void OnTearDownView() override; void OnStop() override; - UIScrollView * SystemVolumeViewInit(void); + UIScrollView *SystemVolumeViewInit(void); + void ClearAll(); private: UIScrollView *SystemVolumeScrollView{nullptr}; SoundAndVibrationVolumeSettingView *p_SoundAndVibrationVolumeSettingView{nullptr}; + UIView::OnDragListener *volumeDragListener{nullptr}; + bool initViewStatus{false}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumePresenter.cpp index 31d1ee375..cd2beb8f6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumePresenter.cpp @@ -56,9 +56,9 @@ namespace OHOS bool SystemVolumePresenter::OnDrag(UIView &view, const DragEvent &event) { - + UNUSED(view); if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && - (event.GetDeltaX() > 30) && (event.GetDeltaX() > (3 * MATH_ABS(event.GetDeltaY())))) + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) { // NativeAbility::GetInstance().ChangeSlice(VIEW_SOUND_VIBRATION); uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); @@ -69,13 +69,8 @@ namespace OHOS bool SystemVolumePresenter::OnClick(UIView &view, const ClickEvent &event) { - - // 根据控件id查找是哪个控件触发了点击回调 - // if (strcmp(view.GetViewId(), 控件ID) == 0) - // if(strcmp(view.GetViewId(), BRIGHTNESS_CONTROL_SLIDER)) - // { - - // } + UNUSED(view); + UNUSED(event); return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp index 2ff1653f3..2e9f089ac 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp @@ -1,6 +1,7 @@ #include "soundandvibration/include/SystemVolumeView.h" #include "soundandvibration/include/SystemVolumePresenter.h" #include "wearable_log.h" +#include /* 系统音量: 通话,提醒,查找手表的音量 @@ -13,20 +14,34 @@ namespace OHOS SystemVolumeView::SystemVolumeView() { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::SystemVolumeView"); g_pSystemVolumeView = this; } SystemVolumeView::~SystemVolumeView() { - delete p_SoundAndVibrationVolumeSettingView; - p_SoundAndVibrationVolumeSettingView = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::~SystemVolumeView"); + ClearAll(); + g_pSystemVolumeView = nullptr; } SystemVolumeView *SystemVolumeView::GetInstance() { - return g_pSystemVolumeView; } + + void SystemVolumeView::ClearAll() + { + if (initViewStatus == true) + { + delete volumeDragListener; + volumeDragListener = nullptr; + + delete p_SoundAndVibrationVolumeSettingView; + p_SoundAndVibrationVolumeSettingView = nullptr; + } + } + UIScrollView *SystemVolumeView::SystemVolumeViewInit(void) { p_SoundAndVibrationVolumeSettingView = new SoundAndVibrationVolumeSettingView(); @@ -42,6 +57,22 @@ namespace OHOS return nullptr; } + volumeDragListener = static_cast(SystemVolumePresenter::GetInstance()); + if (volumeDragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RecordingPresenter GetInstance fail"); + return nullptr; + } + SystemVolumeScrollView->SetOnDragListener(volumeDragListener); + if (SystemVolumeScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess fail!!"); + return nullptr; + } + + p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC)); + + initViewStatus = true; return SystemVolumeScrollView; }