From 24cf1971bbf895bc48b9d3c7dcbb36b551dcddcb Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 23 Feb 2024 15:22:30 +0800 Subject: [PATCH] =?utf8?q?=E5=A3=B0=E9=9F=B3=E4=B8=8E=E9=9C=87=E5=8A=A8?= =?utf8?q?=E8=A7=86=E5=9B=BE=E5=88=87=E6=8D=A2=E6=8C=89=E9=92=AE=E4=BC=98?= =?utf8?q?=E5=8C=96=E5=88=A9=E7=94=A8Model=E4=BF=9D=E5=AD=98=E5=BC=80?= =?utf8?q?=E5=90=AF=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 1 + .../include/SoundAndVibrationModel.h | 28 +++ .../include/SoundAndVibrationPresenter.h | 54 ++++-- .../include/SoundAndVibrationView.h | 11 +- .../src/SoundAndVibrationModel.cpp | 61 ++++++ .../src/SoundAndVibrationPresenter.cpp | 173 +++++++++++++----- .../src/SoundAndVibrationView.cpp | 84 ++++++++- 7 files changed, 340 insertions(+), 72 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationModel.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index b32070297..648b2b5bd 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -261,6 +261,7 @@ 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/SoundAndVibrationModel.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 diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationModel.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationModel.h new file mode 100644 index 000000000..341f2d00c --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationModel.h @@ -0,0 +1,28 @@ +#ifndef SOUND_AND_VIBRATION_MODEL_H +#define SOUND_AND_VIBRATION_MODEL_H + +namespace OHOS +{ + class SoundAndVibrationModel + { + public: + static SoundAndVibrationModel *GetInstance(void); + + void SetVibrationReminderToggleButtonStaus(bool value); + bool VibrationReminderToggleButtonStatusInit(void); + void SetSilentModeToggleButtonStatus(bool value); + bool SilentModeToggleButtonStatusInit(void); + + private: + SoundAndVibrationModel(); + SoundAndVibrationModel(const SoundAndVibrationModel &); + SoundAndVibrationModel &operator=(const SoundAndVibrationModel &); + virtual ~SoundAndVibrationModel(); + + private: + bool VibrationReminderToggleButtonState{false}; // “震动提醒”切换按钮状态 + bool SilentModeToggleButtonState{false}; // “静音模式”切换按钮状态 + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h index b8931cddb..d8438752b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h @@ -3,34 +3,50 @@ #include "Presenter.h" #include "SoundAndVibrationView.h" - + namespace OHOS { + class SoundAndVibrationViewOnChangeListener : public UICheckBox::OnChangeListener + { + public: + SoundAndVibrationViewOnChangeListener(UIView *view) + { + view_ = view; + } + + ~SoundAndVibrationViewOnChangeListener() {} + + bool OnChange(UICheckBox::UICheckBoxState state) override; + + private: + UIView *view_{nullptr}; + }; + class SoundAndVibrationView; - class SoundAndVibrationPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener + public UIView::OnClickListener, + public UIView::OnDragListener { public: SoundAndVibrationPresenter(); virtual ~SoundAndVibrationPresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static SoundAndVibrationPresenter *GetInstance(); - - private: - //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - }; -} //namespace OHOS - + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + static SoundAndVibrationPresenter *GetInstance(); + void VibrationReminderToggleButtonStateSetting(bool value); + void SilentModeToggleButtonStateSetting(bool value); + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; + private: + UIView *view_{nullptr}; + }; +} // namespace OHOS #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h index 9100117e1..e218b3ef5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h @@ -18,8 +18,6 @@ namespace OHOS static const char *SYSTEM_VOLUME_BUTTON = "SystemVolumeButton"; // 系统音量按钮ID static const char *CALL_VOLUME_BUTTON = "CallVolumeButton"; // 通话音量按钮ID static const char *MEDIA_VOLUME_BUTTON = "MediaVolumeButton"; // 媒体音量按钮ID - static const char *VIBRATION_REMINDER_TOGGLEBUTTON = "VibrationReminderToggleButton"; // 震动提醒 - static const char *SILENT_MODEL_TOGGLEBUTTON = "SilentModeToggleButton"; // 静音模式 class SoundAndVibrationPresenter; class SoundAndVibrationView : public View { @@ -58,6 +56,13 @@ namespace OHOS virtual ~SoundAndVibrationView(); static SoundAndVibrationView *GetInstance(void); + void SetVibrationReminderToggleButtonState(bool value); + void SetSilentModeToggleButtonState(bool value); + bool GetVibrationReminderToggleButtonState(void); + bool GetSilentModeToggleButtonState(void); + UIToggleButton * GetVibrationReminderToggleButton(); + UIToggleButton * GetSilentModeToggleButton(); + void OnStart() override; void OnSetUpView() override; void OnTearDownView() override; @@ -94,6 +99,8 @@ namespace OHOS UIImageView *SilentModeImageView{nullptr}; // UIToggleButton *VibrationReminderToggleButton{nullptr}; // 震动提醒切换按钮 UIToggleButton *SilentModeToggleButton{nullptr}; // 静音模式切换按钮 + UICheckBox::OnChangeListener *VibrationReminderToggleButtonChangeListener{nullptr}; + UICheckBox::OnChangeListener *SilentModeToggleButtonChangeListener{nullptr}; bool initViewStatus{false}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp new file mode 100644 index 000000000..328c2d5fc --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp @@ -0,0 +1,61 @@ +#include "soundandvibration/include/SoundAndVibrationModel.h" +#include "soundandvibration/include/SoundAndVibrationPresenter.h" +#include "wearable_log.h" +namespace OHOS +{ + + SoundAndVibrationModel::SoundAndVibrationModel() {} + + SoundAndVibrationModel::~SoundAndVibrationModel() {} + + SoundAndVibrationModel *SoundAndVibrationModel::GetInstance(void) + { + static SoundAndVibrationModel instance; + return &instance; + } + + /// @brief 设置“震动提醒”是否开启 + /// @param value + void SoundAndVibrationModel::SetVibrationReminderToggleButtonStaus(bool value) + { + VibrationReminderToggleButtonState = value; + } + + /// @brief “震动提醒”切换按钮状态初始化 + /// @param void + /// @return true 初始化成功 false 初始化失败 + bool SoundAndVibrationModel::VibrationReminderToggleButtonStatusInit(void) + { + SoundAndVibrationPresenter *p_SoundAndVibrationPresenter = SoundAndVibrationPresenter::GetInstance(); + if (p_SoundAndVibrationPresenter == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationReminderToggleButtonStatusInit SoundAndVibrationPresenter GetInstance fail!"); + return false; + } + p_SoundAndVibrationPresenter->VibrationReminderToggleButtonStateSetting(VibrationReminderToggleButtonState); + return true; + } + + /// @brief 设置“静音模式”是否开启 + /// @param value + void SoundAndVibrationModel::SetSilentModeToggleButtonStatus(bool value) + { + SilentModeToggleButtonState = value; + } + + /// @brief “静音模式”切换按钮状态初始化 + /// @param void + /// @return true 初始化成功 false 初始化失败 + bool SoundAndVibrationModel::SilentModeToggleButtonStatusInit(void) + { + SoundAndVibrationPresenter *p_SoundAndVibrationPresenter = SoundAndVibrationPresenter::GetInstance(); + if (p_SoundAndVibrationPresenter == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SilentModeToggleButtonStatusInit SoundAndVibrationPresenter GetInstance fail!"); + return false; + } + p_SoundAndVibrationPresenter->SilentModeToggleButtonStateSetting(SilentModeToggleButtonState); + return true; + } + +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp index df4df048d..684e274fd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp @@ -3,60 +3,106 @@ #include "graphic_math.h" #include "string.h" #include "soundandvibration/include/SoundAndVibrationPresenter.h" - -namespace OHOS{ - - //当前Presenter属性实例化的内存指针 - static SoundAndVibrationPresenter *g_pSoundAndVibrationPresenter = nullptr; - - SoundAndVibrationPresenter::SoundAndVibrationPresenter(){ - +#include "soundandvibration/include/SoundAndVibrationModel.h" +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static SoundAndVibrationPresenter *g_pSoundAndVibrationPresenter = nullptr; + + SoundAndVibrationPresenter::SoundAndVibrationPresenter() + { + g_pSoundAndVibrationPresenter = this; } - - SoundAndVibrationPresenter::~SoundAndVibrationPresenter(){ - + + SoundAndVibrationPresenter::~SoundAndVibrationPresenter() + { + g_pSoundAndVibrationPresenter = nullptr; } - - SoundAndVibrationPresenter *SoundAndVibrationPresenter::GetInstance(){ - + + SoundAndVibrationPresenter *SoundAndVibrationPresenter::GetInstance() + { + return g_pSoundAndVibrationPresenter; } - - void SoundAndVibrationPresenter::OnStart(){ - - Presenter::OnStart(); + + /// @brief "震动提醒"按钮状态设置 + /// @param value true 开启 false 关闭 + void SoundAndVibrationPresenter::VibrationReminderToggleButtonStateSetting(bool value) + { + SoundAndVibrationView *p_SoundAndVibrationView = SoundAndVibrationView::GetInstance(); + if (p_SoundAndVibrationView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationReminderToggleButtonStateSetting SoundAndVibrationView GetInstance fail!"); + return; + } + if (value != false) + { + p_SoundAndVibrationView->SetVibrationReminderToggleButtonState(true); + SoundAndVibrationModel::GetInstance()->SetVibrationReminderToggleButtonStaus(false); // 将Model层保存的状态清除 + } + } + + /// @brief "静音模式"按钮状态设置 + /// @param value true 开启 false 关闭 + void SoundAndVibrationPresenter::SilentModeToggleButtonStateSetting(bool value) + { + SoundAndVibrationView *p_SoundAndVibrationView = SoundAndVibrationView::GetInstance(); + if (p_SoundAndVibrationView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SilentModeToggleButtonStateSetting SoundAndVibrationView GetInstance fail!"); + return; + } + if (value != false) + { + p_SoundAndVibrationView->SetSilentModeToggleButtonState(true); + SoundAndVibrationModel::GetInstance()->SetSilentModeToggleButtonStatus(false); // 将Model层保存的状态清除 + } } - - void SoundAndVibrationPresenter::OnPause(void){ - + + void SoundAndVibrationPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SoundAndVibrationPresenter::OnPause(void) + { + Presenter::OnPause(); } - - void SoundAndVibrationPresenter::OnResume(void){ - + + void SoundAndVibrationPresenter::OnResume(void) + { + Presenter::OnResume(); } - - void SoundAndVibrationPresenter::OnStop(void){ - - Presenter::OnStop(); + + void SoundAndVibrationPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool SoundAndVibrationPresenter::OnDrag(UIView &view, const DragEvent &event) + { + return true; } - - bool SoundAndVibrationPresenter::OnDrag(UIView &view, const DragEvent &event){ - - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && - (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + + bool SoundAndVibrationPresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); - return true; } - return false; + return true; } - - bool SoundAndVibrationPresenter::OnClick(UIView &view, const ClickEvent &event){ - + + bool SoundAndVibrationPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 UNUSED(event); if (strcmp(view.GetViewId(), SYSTEM_VOLUME_BUTTON) == 0) @@ -64,23 +110,62 @@ namespace OHOS{ NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); return true; } - else if(strcmp(view.GetViewId(), CALL_VOLUME_BUTTON) == 0) + else if (strcmp(view.GetViewId(), CALL_VOLUME_BUTTON) == 0) { NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); return true; - }else if(strcmp(view.GetViewId(), MEDIA_VOLUME_BUTTON) == 0) + } + else if (strcmp(view.GetViewId(), MEDIA_VOLUME_BUTTON) == 0) { NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); return true; } - else if(strcmp(view.GetViewId(), VIBRATION_REMINDER_TOGGLEBUTTON) == 0) + return false; + } + + bool SoundAndVibrationViewOnChangeListener::OnChange(UICheckBox::UICheckBoxState state) + { + SoundAndVibrationView *p_SoundAndVibrationView = SoundAndVibrationView::GetInstance(); + if (p_SoundAndVibrationView == nullptr) { - return true; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::GetInstance fail!"); + return false; } - else if(strcmp(view.GetViewId(), SILENT_MODEL_TOGGLEBUTTON) == 0) + + switch (state) { - return true; + case UICheckBox::SELECTED: + if (p_SoundAndVibrationView->GetVibrationReminderToggleButton() == (UIView *)view_) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationReminder is enable!"); + + return true; + } + else if (p_SoundAndVibrationView->GetSilentModeToggleButton() == (UIView *)view_) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SilentMode is enable!"); + + return true; + } + break; + case UICheckBox::UNSELECTED: + if (p_SoundAndVibrationView->GetVibrationReminderToggleButton() == (UIView *)view_) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationReminder is disable!"); + + return true; + } + else if (p_SoundAndVibrationView->GetSilentModeToggleButton() == (UIView *)view_) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SilentMode is disable!"); + + return true; + } + break; + default: + break; } return false; } + } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp index 0c8da83ef..bbbd6c549 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp @@ -1,5 +1,6 @@ #include "soundandvibration/include/SoundAndVibrationView.h" #include "soundandvibration/include/SoundAndVibrationPresenter.h" +#include "soundandvibration/include/SoundAndVibrationModel.h" #include "wearable_log.h" /* 按优先级分为 @@ -43,8 +44,22 @@ namespace OHOS if (initViewStatus == true) { SoundAndVibrationScrollView->RemoveAll(); + + bool state = GetVibrationReminderToggleButtonState(); + if (state == true) + { + SoundAndVibrationModel::GetInstance()->SetVibrationReminderToggleButtonStaus(true); + } + state = GetSilentModeToggleButtonState(); + + if (state == true) + { + SoundAndVibrationModel::GetInstance()->SetSilentModeToggleButtonStatus(true); + } + delete Title; Title = nullptr; + delete SystemVolumeButton; SystemVolumeButton = nullptr; @@ -85,7 +100,13 @@ namespace OHOS VibrationReminderImageView = nullptr; delete SilentModeImageView; - SilentModeImageView; + SilentModeImageView = nullptr; + + delete VibrationReminderToggleButtonChangeListener; + VibrationReminderToggleButtonChangeListener = nullptr; + + delete SilentModeToggleButtonChangeListener; + SilentModeToggleButtonChangeListener = nullptr; delete VibrationReminderToggleButton; VibrationReminderToggleButton = nullptr; @@ -372,7 +393,7 @@ namespace OHOS {417, "音乐、录音、训练"}, {657, "系统音量不受影响"}, }; - for (int i = 0; i < sizeof(labelInfo) / sizeof(labelInfo[0]); i++) + for (int i = 0; i < (int)(sizeof(labelInfo) / sizeof(labelInfo[0])); i++) { LabelConfig labelConfig = { .left = 90, @@ -401,7 +422,6 @@ namespace OHOS bool SoundAndVibrationView::InitSoundAndVibrationToggleButton(void) { - UIView::OnClickListener *ButtonClick = static_cast(SoundAndVibrationPresenter::GetInstance()); /* ---------------------- VibrationReminderToggleButton --------------------- */ VibrationReminderToggleButton = new UIToggleButton(); if (VibrationReminderToggleButton == nullptr) @@ -410,13 +430,13 @@ namespace OHOS return false; } VibrationReminderToggleButton->SetPosition(298, 505, 100, 50); - VibrationReminderToggleButton->SetViewId(VIBRATION_REMINDER_TOGGLEBUTTON); VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); const char *ToggleButtonSelect = "/user/res/TOGGLEBUTTON_ON.bin"; const char *ToggleButtonUnSelect = "/user/res/TOGGLEBUTTON_OFF.bin"; VibrationReminderToggleButton->SetImages(ToggleButtonSelect, ToggleButtonUnSelect); - VibrationReminderToggleButton->SetOnClickListener(ButtonClick); + VibrationReminderToggleButtonChangeListener = new SoundAndVibrationViewOnChangeListener(reinterpret_cast(VibrationReminderToggleButton)); + VibrationReminderToggleButton->SetOnChangeListener(VibrationReminderToggleButtonChangeListener); /* ------------------------- SilentModeToggleButton ------------------------- */ SilentModeToggleButton = new UIToggleButton(); if (SilentModeToggleButton == nullptr) @@ -425,14 +445,56 @@ namespace OHOS return false; } SilentModeToggleButton->SetPosition(298, 625, 100, 50); - SilentModeToggleButton->SetViewId(SILENT_MODEL_TOGGLEBUTTON); SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); SilentModeToggleButton->SetImages(ToggleButtonSelect, ToggleButtonUnSelect); - SilentModeToggleButton->SetOnClickListener(ButtonClick); + SilentModeToggleButtonChangeListener = new SoundAndVibrationViewOnChangeListener(reinterpret_cast(SilentModeToggleButton)); + SilentModeToggleButton->SetOnChangeListener(SilentModeToggleButtonChangeListener); return true; } + /// @brief 获取"震动提醒"按钮开,关状态 + /// @param void + /// @return true 开 false 关 + bool SoundAndVibrationView::GetVibrationReminderToggleButtonState(void) + { + return VibrationReminderToggleButton->GetState(); + } + + /// @brief 获取"静音模式"按钮开,关状态 + /// @param void + /// @return true 开 false 关 + bool SoundAndVibrationView::GetSilentModeToggleButtonState(void) + { + return SilentModeToggleButton->GetState(); + } + + /// @brief 设置"震动提醒"按钮开,关状态 + /// @param value + void SoundAndVibrationView::SetVibrationReminderToggleButtonState(bool value) + { + VibrationReminderToggleButton->SetState(value); + } + + /// @brief 设置"静音模式"按钮开,关状态 + /// @param value + void SoundAndVibrationView::SetSilentModeToggleButtonState(bool value) + { + SilentModeToggleButton->SetState(value); + } + + /// @brief 获取"震动提醒"切换按钮 + UIToggleButton *SoundAndVibrationView::GetVibrationReminderToggleButton(void) + { + return VibrationReminderToggleButton; + } + + /// @brief 获取"静音模式"切换按钮 + UIToggleButton *SoundAndVibrationView::GetSilentModeToggleButton(void) + { + return SilentModeToggleButton; + } + void SoundAndVibrationView::InitView(void) { if (InitSoundAndVibrationScrollView() == false) @@ -459,6 +521,14 @@ namespace OHOS { return; } + if (SoundAndVibrationModel::GetInstance()->VibrationReminderToggleButtonStatusInit() == false) + { + return; + } + if (SoundAndVibrationModel::GetInstance()->SilentModeToggleButtonStatusInit() == false) + { + return; + } initViewStatus = true; } -- 2.17.1