--- /dev/null
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-01-29 16:24:23\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-06-19 18:58:47\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/CallVolumePresenter.h\r
+ */\r
+#ifndef CALL_VOLUME_PRESENTER_H\r
+#define CALL_VOLUME_PRESENTER_H\r
+\r
+#include "Presenter.h"\r
+#include "CallVolumeView.h"\r
+\r
+namespace OHOS\r
+{\r
+ typedef enum : uint8_t\r
+ {\r
+ VOLUMEREDUCE = 0, // 声音降低\r
+ VOLUMEADD = 1, // 声音增加\r
+ OTHER = 2, // 其他\r
+ } VolumeStatusChange;\r
+\r
+ /*\r
+ * @brief 声音进度条的事件监听类\r
+ */\r
+ class VoumeProcessSliderEventListener : public UISlider::UISliderEventListener,\r
+ public UIView::OnClickListener,\r
+ public UIView::OnDragListener\r
+ {\r
+ public:\r
+ VoumeProcessSliderEventListener();\r
+ ~VoumeProcessSliderEventListener();\r
+ static VoumeProcessSliderEventListener *GetInstance(void);\r
+ void ChangeVolumeValue(uint8_t status, uint8_t value);\r
+ void LocalVolumeSet(int16_t sounding);\r
+ void OnChange(int32_t value) override;\r
+ void OnRelease(int32_t value) override;\r
+ bool OnClick(UIView &view, const ClickEvent &event) override;\r
+ bool OnDrag(UIView &view, const DragEvent &event) override;\r
+\r
+ private:\r
+ int32_t VolumeValue; // 声音值\r
+ };\r
+\r
+ class CallVolumeView;\r
+ class CallVolumePresenter : public Presenter<CallVolumeView>,\r
+ public UIView::OnClickListener,\r
+ public RootView::OnKeyActListener,\r
+ public UIView::OnDragListener\r
+ {\r
+ public:\r
+ CallVolumePresenter();\r
+ virtual ~CallVolumePresenter();\r
+\r
+ void OnStart() override;\r
+ void OnPause() override;\r
+ void OnResume() override;\r
+ void OnStop() override;\r
+\r
+ static CallVolumePresenter *GetInstance();\r
+\r
+ private:\r
+ // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
+ bool OnClick(UIView &view, const ClickEvent &event) override;\r
+ bool OnDrag(UIView &view, const DragEvent &event) override;\r
+ bool OnDragEnd(UIView &view, const DragEvent &event);\r
+ bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件\r
+ bool X_DRAG_FLAG{false};\r
+ };\r
+} // namespace OHOS\r
+\r
+#endif
\ No newline at end of file
--- /dev/null
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-01-29 15:37:44\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2025-02-24 18:04:04\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/CallVolumeView.h\r
+ */\r
+#ifndef CALL_VOLUME_VIEW_H\r
+#define CALL_VOLUME_VIEW_H\r
+\r
+\r
+#include "View.h"\r
+#include "components/ui_scroll_view.h"\r
+#include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h"\r
+namespace OHOS\r
+{\r
+\r
+ class SoundAndVibrationVolumeSettingView;\r
+ class CallVolumePresenter;\r
+ class CallVolumeView : public View<CallVolumePresenter>\r
+ {\r
+\r
+ public:\r
+ CallVolumeView();\r
+ virtual ~CallVolumeView();\r
+ static CallVolumeView *GetInstance(void);\r
+ bool UpdateCallVolumeSliderValue(void);\r
+\r
+ void OnStart() override;\r
+\r
+ private:\r
+ void ClearAll();\r
+ UIScrollView *CallVolumeViewInit(void);\r
+ UIScrollView *CallVolumeScrollView{nullptr};\r
+ SoundAndVibrationVolumeSettingView *p_SoundAndVibrationVolumeSettingView{nullptr};\r
+ bool initViewStatus{false};\r
+ };\r
+} // namespace OHOS\r
+\r
+#endif
\ No newline at end of file
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-02-23 09:17:12
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-06-19 17:40:28
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationModel.h
+ */
+#ifndef SOUND_AND_VIBRATION_MODEL_H
+#define SOUND_AND_VIBRATION_MODEL_H
+
+namespace OHOS
+{
+ class SoundAndVibrationModel
+ {
+ public:
+ static SoundAndVibrationModel *GetInstance(void);
+ bool UpdateSystemVolume(void);
+ bool UpdateCallVolume(void);
+ bool UpdateVibrationModePickerSelectIndex(void);
+ bool UpdateSilentModeSwitch(void);
+ void SetVibrationReminderToggleButtonStaus(int value);
+ int GetVibrationReminderToggleButtonStaus();
+ void SetSilentModeToggleButtonStatus(bool value);
+ bool GetSilentModeToggleButtonStatus(void);
+
+ private:
+ SoundAndVibrationModel();
+ SoundAndVibrationModel(const SoundAndVibrationModel &);
+ SoundAndVibrationModel &operator=(const SoundAndVibrationModel &);
+ virtual ~SoundAndVibrationModel();
+ };
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-02-19 10:39:08\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-06-19 14:37:36\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h\r
+ */\r
+#ifndef SOUND_AND_VIBRATION_PRESENTER_H\r
+#define SOUND_AND_VIBRATION_PRESENTER_H\r
+\r
+#include "Presenter.h"\r
+#include "View.h"\r
+#include "SoundAndVibrationView.h"\r
+#include "soundandvibration/include/SoundAndVibrationModel.h"\r
+\r
+namespace OHOS\r
+{\r
+\r
+ class SoundAndVibrationView;\r
+ class SoundAndVibrationPresenter : public Presenter<SoundAndVibrationView>,\r
+ public UIView::OnClickListener,\r
+ public RootView::OnKeyActListener,\r
+ public UICheckBox::OnChangeListener,\r
+ public UIView::OnRotateListener,\r
+ public UIView::OnDragListener\r
+ {\r
+ public:\r
+ SoundAndVibrationPresenter();\r
+ virtual ~SoundAndVibrationPresenter();\r
+\r
+ void OnStart() override;\r
+ void OnPause() override;\r
+ void OnResume() override;\r
+ void OnStop() override;\r
+\r
+ static SoundAndVibrationPresenter *GetInstance();\r
+\r
+ private:\r
+ // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
+ bool OnClick(UIView &view, const ClickEvent &event) override;\r
+ bool OnDrag(UIView &view, const DragEvent &event) override;\r
+ bool OnDragEnd(UIView &view, const DragEvent &event) override;\r
+ bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件\r
+ bool OnChange(UICheckBox::UICheckBoxState state) override;\r
+ bool OnRotate(UIView& view, const RotateEvent& event);\r
+ bool OnRotateEnd(UIView& view, const RotateEvent& event);\r
+ bool X_DRAG_FLAG{false};\r
+ };\r
+} // namespace OHOS\r
+\r
+#endif
\ No newline at end of file
--- /dev/null
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-04-19 21:03:26\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2025-02-24 17:15:54\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h\r
+ */\r
+#ifndef SOUND_AND_VIBRATION_VIEW_H\r
+#define SOUND_AND_VIBRATION_VIEW_H\r
+\r
+\r
+#include "View.h"\r
+#include "components/ui_scroll_view.h"\r
+#include "components/ui_label_ext.h"\r
+#include "components/ui_label_button_ext.h"\r
+#include "components/ui_toggle_button.h"\r
+#include "iostream"\r
+#include "soundandvibration/include/VibrationModeView.h"\r
+\r
+namespace OHOS\r
+{\r
+ /* ---------------------------------- 组件ID ---------------------------------- */\r
+ static constexpr const char *SYSTEM_VOLUME_BUTTON = "SystemVolumeButton"; // 系统音量按钮ID\r
+ static constexpr const char *CALL_VOLUME_BUTTON = "CallVolumeButton"; // 通话音量按钮ID\r
+ static constexpr const char *VIBRATION_REMINDER_BUTTON = "VibrationReminderButton"; // 震动模式按钮ID\r
+ static constexpr const char *SILENT_MODE_BUTTON = "SilentModeButton"; // 静音模式按钮ID\r
+ typedef enum\r
+ {\r
+ SOUNDANDVIBRATIONVIEW = 0, // 声音与震动\r
+ VIBRATIONMODEVIEW, // 震动模式\r
+ MAX_SOUNDANDVIBRATIONVIEWID,\r
+ } SOUNDANDVIBRATIONVIEWID;\r
+\r
+ class SoundAndVibrationPresenter;\r
+ class SoundAndVibrationView : public View<SoundAndVibrationPresenter>\r
+ {\r
+\r
+ public:\r
+ struct ButtonConfig\r
+ {\r
+ int16_t x;\r
+ int16_t y;\r
+ int16_t w;\r
+ int16_t h;\r
+ const char *ViewId;\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
+\r
+ void OnStart() override;\r
+\r
+ private:\r
+ VibrationModeView *vibrationModeView{nullptr};\r
+\r
+ private:\r
+ 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
+ bool InitSoundAndVibrationToggleButton(void);\r
+\r
+ private:\r
+ UIScrollView *SoundAndVibrationScrollView[MAX_SOUNDANDVIBRATIONVIEWID]{nullptr};\r
+ UILabelExt *Title{nullptr}; // 标题:“声音与震动”\r
+ // UILabelButtonExt *SystemVolumeButton{nullptr}; // 系统音量按钮\r
+ // 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
+ UILabelButtonExt *buttonPointers[4]{nullptr};\r
+ UILabelExt *labelPointers[4]{nullptr};\r
+ UIToggleButton *SilentModeToggleButton{nullptr}; // 静音模式切换按钮\r
+ bool initViewStatus{false};\r
+ UIImageView *temp{nullptr};\r
+ };\r
+} // namespace OHOS\r
+\r
+#endif\r
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-19 18:59:49
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-09-14 18:28:53
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h
+ */
+#ifndef SOUND_AND_VIBRATION_VOLUME_SETTINGC_H
+#define SOUND_AND_VIBRATION_VOLUME_SETTINGC_H
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C"
+{
+#endif
+#endif
+#include <stdint.h>
+#include <stdbool.h>
+
+ void SystemVolumeSet(int32_t sounding);
+ int SystemVolumeGet(void);
+ void CallVolumeSet(int32_t sounding);
+ int CallVolumeGet(void);
+ // void VibationModeSet(int value);
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif
+#endif
+#endif
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-19 10:08:21
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @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
+#define SOUND_AND_VIBRATION_VOLUME_SETTING_PRESENTER_H
+#include <cstdint>
+#include "components/ui_slider.h"
+#include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h"
+#include "map"
+#include "memory"
+namespace OHOS
+{
+ typedef enum : uint8_t
+ {
+ VOLUMEREDUCE = 0, // 声音降低
+ VOLUMEADD = 1, // 声音增加
+ OTHER = 2, // 其他
+ } VolumeStatusChange;
+
+ // 步骤 1: 定义策略接口.定义一个策略接口,所有的声音调整策略都需要实现这个接口
+ class SoundAndVibrationVolumeSettingView;
+ class VolumeChangeStrategy
+ {
+ public:
+ virtual void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, int32_t value) = 0;
+ virtual ~VolumeChangeStrategy() = default;
+ };
+
+ /*
+ * @brief 声音进度条的事件监听类
+ */
+ class VoumeProcessSliderEventListener : public UISlider::UISliderEventListener,
+ public UIView::OnClickListener,
+ public UIView::OnDragListener,
+ public UIView::OnRotateListener
+ {
+ public:
+ VoumeProcessSliderEventListener();
+ ~VoumeProcessSliderEventListener();
+ static VoumeProcessSliderEventListener *GetInstance(void);
+ void FindAndApplyStrategy(uint8_t status, int32_t value);
+ void ChangeVolumeValue(uint8_t status, int32_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 OnRotate(UIView& view, const RotateEvent& event);
+ bool OnRotateEnd(UIView& view, const RotateEvent& event);
+
+ private:
+ std::map<int32_t, std::shared_ptr<VolumeChangeStrategy>> strategyMap;
+ bool isOnClickSlider{true};
+ bool isDragSlider{false};
+ bool isRotateSlider{false};
+ };
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-01-29 15:41:49
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-04-19 15:22:04
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h
+ */
+#ifndef SOUND_AND_VIBRATION_VOLUME_SETTING_H
+#define SOUND_AND_VIBRATION_VOLUME_SETTING_H
+
+
+#include "View.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_slider.h"
+#include "components/ui_image_view.h"
+
+/*
+ 声音与震动的声音设置视图
+*/
+
+namespace OHOS
+{
+#define VOLUME_MIN 0
+#define VOLUME_MAX 100
+#define VOLUME_PROGRESS "progress"
+
+#define SYSTEM_VOLUME 0
+#define CALL_VOLUME 1
+
+ class VoumeProcessSliderEventListener;
+ class SoundAndVibrationVolumeSettingView
+ {
+ public:
+ SoundAndVibrationVolumeSettingView(uint8_t VolumeType);
+ ~SoundAndVibrationVolumeSettingView();
+ static SoundAndVibrationVolumeSettingView *GetInstance(void);
+ UIScrollView *SetUpVolumeProcess(void);
+ void ClearAll(void);
+ UISlider *GetVolumeProcess(void);
+ int GetVolumeType(void);
+ int CurrentVolumeValue{0};
+
+ private:
+ UIScrollView *ScrollView{nullptr};
+ UISlider *VolumeProcess{nullptr};
+ UIImageView *VolumeVetor{nullptr};
+ VoumeProcessSliderEventListener *listener = nullptr;
+ uint8_t m_VolumeType;
+ bool initViewStatus{false};
+ };
+
+}
+#endif
\ No newline at end of file
--- /dev/null
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-01-29 16:24:30\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-06-19 17:04:30\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumePresenter.h\r
+ */\r
+#ifndef SYSTEM_VOLUME_PRESENTER_H\r
+#define SYSTEM_VOLUME_PRESENTER_H\r
+\r
+#include "Presenter.h"\r
+#include "View.h"\r
+#include "SystemVolumeView.h"\r
+#include "wearable_log.h"\r
+namespace OHOS\r
+{\r
+ \r
+\r
+ class SystemVolumeView;\r
+ class SystemVolumePresenter : public Presenter<SystemVolumeView>,\r
+ public UIView::OnClickListener,\r
+ public RootView::OnKeyActListener,\r
+ public UIView::OnDragListener\r
+ {\r
+ public:\r
+ SystemVolumePresenter();\r
+ virtual ~SystemVolumePresenter();\r
+\r
+ void OnStart() override;\r
+ void OnPause() override;\r
+ void OnResume() override;\r
+ void OnStop() override;\r
+\r
+ static SystemVolumePresenter *GetInstance();\r
+\r
+ private:\r
+ bool OnClick(UIView &view, const ClickEvent &event) override;\r
+ bool OnDrag(UIView &view, const DragEvent &event) override;\r
+ bool OnDragEnd(UIView &view, const DragEvent &event);\r
+ bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件\r
+ bool X_DRAG_FLAG{false};\r
+ };\r
+} // namespace OHOS\r
+\r
+#endif
\ No newline at end of file
--- /dev/null
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-01-29 15:37:44\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2025-02-24 17:25:58\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumeView.h\r
+ */\r
+#ifndef SYSTEM_VOLUME_VIEW_H\r
+#define SYSTEM_VOLUME_VIEW_H\r
+\r
+\r
+#include "View.h"\r
+#include "components/ui_scroll_view.h"\r
+#include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h"\r
+namespace OHOS\r
+{\r
+\r
+ class SoundAndVibrationVolumeSettingView;\r
+ class SystemVolumePresenter;\r
+ class SystemVolumeView : public View<SystemVolumePresenter>\r
+ {\r
+\r
+ public:\r
+ SystemVolumeView();\r
+ virtual ~SystemVolumeView();\r
+ static SystemVolumeView *GetInstance(void);\r
+ bool UpdateSystemVolumeSliderValue(void);\r
+\r
+ void OnStart() override;\r
+\r
+ private:\r
+ void ClearAll();\r
+ UIScrollView *SystemVolumeViewInit(void);\r
+ UIScrollView *SystemVolumeScrollView{nullptr};\r
+ SoundAndVibrationVolumeSettingView *p_SoundAndVibrationVolumeSettingView{nullptr};\r
+ bool initViewStatus{false};\r
+ };\r
+} // namespace OHOS\r
+\r
+#endif
\ No newline at end of file
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-22 14:35:10
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-06-19 15:18:07
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/VibrationModeView.h
+ */
+#ifndef VIBRATION_MODE_H
+#define VIBRATION_MODE_H
+
+#include "components/ui_scroll_view.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_picker.h"
+#include "components/ui_label_button_ext.h"
+
+namespace OHOS
+{
+ static constexpr const char *VIBRATION_MODE_VIEWID = "VibrationModeViewId";
+ class VibrationModeView
+ {
+ public:
+ VibrationModeView();
+ ~VibrationModeView();
+ static VibrationModeView *GetInstance();
+ UIScrollView *VibrationModeViewInit(void);
+ UIScrollView *GetVibrationModeScrollView(void);
+ UILabelButtonExt *GetVibrationModeLabelButton(void);
+ UIPicker *GetVibrationModePicker(void);
+ bool UpdatePickerSelectIndex(void);
+
+ private:
+ void ClearAll();
+ UIScrollView *scrollView{nullptr};
+ UILabelExt *Title = nullptr;
+ UIPicker *VibrationModePicker = nullptr;
+ UILabelButtonExt *VibrationModeLabelButton = nullptr;
+ };
+
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-03-30 09:14:38\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-06-19 18:58:32\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumePresenter.cpp\r
+ */\r
+#include "AppViewIDs.h"\r
+#include "components/ui_label_ext.h"\r
+#include "ui_resource_string.h"\r
+#include "NativeAbility.h"\r
+#include "graphic_math.h"\r
+#include "soundandvibration/include/CallVolumePresenter.h"\r
+#include "common/key_code.h"\r
+#include "custom_utils.h"\r
+#include <ohos_types.h>\r
+#include <UiConfig.h>\r
+#include "NativeRegisterManager.h"\r
+// 系统音量\r
+namespace OHOS\r
+{\r
+ REGIST_SLICE(VIEW_CALL_VOLUME, CallVolumeView, CallVolumePresenter);\r
+ // 当前Presenter属性实例化的内存指针\r
+ static CallVolumePresenter *g_pCallVolumePresenter = nullptr;\r
+\r
+ CallVolumePresenter::CallVolumePresenter()\r
+ {\r
+\r
+ g_pCallVolumePresenter = this;\r
+ }\r
+\r
+ CallVolumePresenter::~CallVolumePresenter()\r
+ {\r
+\r
+ g_pCallVolumePresenter = nullptr;\r
+ }\r
+\r
+ CallVolumePresenter *CallVolumePresenter::GetInstance()\r
+ {\r
+\r
+ return g_pCallVolumePresenter;\r
+ }\r
+\r
+ void CallVolumePresenter::OnStart()\r
+ {\r
+\r
+ }\r
+\r
+ void CallVolumePresenter::OnPause(void)\r
+ {\r
+\r
+ Presenter<CallVolumeView>::OnPause();\r
+ }\r
+\r
+ void CallVolumePresenter::OnResume(void)\r
+ {\r
+\r
+ Presenter<CallVolumeView>::OnResume();\r
+ }\r
+\r
+ void CallVolumePresenter::OnStop(void)\r
+ {\r
+\r
+ }\r
+\r
+ bool CallVolumePresenter::OnDrag(UIView &view, const DragEvent &event)\r
+ {\r
+ UNUSED(view);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumePresenter::OnDrag");\r
+ if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动\r
+ {\r
+ CallVolumePresenter::X_DRAG_FLAG = true;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ bool CallVolumePresenter::OnDragEnd(UIView &view, const DragEvent &event)\r
+ {\r
+ UNUSED(view);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumePresenter::OnDragEnd");\r
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && CallVolumePresenter::X_DRAG_FLAG)\r
+ {\r
+ NativeAbility::GetInstance().Back();\r
+ CallVolumePresenter::X_DRAG_FLAG = false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ bool CallVolumePresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件\r
+ {\r
+ UNUSED(view);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumePresenter::OnKeyAct");\r
+ uint16 keyID = event.GetKeyId();\r
+ uint16 keyState = event.GetState();\r
+ // 如果是power键,且是亮屏状态,按键释放就返回上一级\r
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)\r
+ {\r
+ NativeAbility::GetInstance().Back();\r
+ }\r
+ return true;\r
+ }\r
+\r
+ bool CallVolumePresenter::OnClick(UIView &view, const ClickEvent &event)\r
+ {\r
+ UNUSED(view);\r
+ UNUSED(event);\r
+ return true;\r
+ }\r
+\r
+}\r
--- /dev/null
+#include "soundandvibration/include/CallVolumeView.h"\r
+#include "soundandvibration/include/CallVolumePresenter.h"\r
+#include "wearable_log.h"\r
+#include <audio_manager.h>\r
+#include "phoneservice/include/PhoneAudio.h"\r
+#include "phoneservice/include/PhoneService.h"\r
+#include "ConfigModel.h"\r
+#include <custom_utils.h>\r
+namespace OHOS\r
+{\r
+\r
+ static CallVolumeView *g_pCallVolumeView{nullptr};\r
+\r
+ CallVolumeView::CallVolumeView()\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumeView::CallVolumeView");\r
+ g_pCallVolumeView = this;\r
+ }\r
+\r
+ CallVolumeView::~CallVolumeView()\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumeView::~CallVolumeView");\r
+ ClearAll();\r
+ g_pCallVolumeView = nullptr;\r
+ }\r
+\r
+ CallVolumeView *CallVolumeView::GetInstance()\r
+ {\r
+ return g_pCallVolumeView;\r
+ }\r
+\r
+ void CallVolumeView::ClearAll()\r
+ {\r
+ if (initViewStatus == true)\r
+ {\r
+ {\r
+ CallVolumeScrollView = nullptr;\r
+ }\r
+ delete p_SoundAndVibrationVolumeSettingView;\r
+ p_SoundAndVibrationVolumeSettingView = nullptr;\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumeView::ClearAll end!!");\r
+ }\r
+ }\r
+\r
+ UIScrollView *CallVolumeView::CallVolumeViewInit(void)\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumeView::CallVolumeViewInit");\r
+ if (p_SoundAndVibrationVolumeSettingView == nullptr)\r
+ {\r
+ p_SoundAndVibrationVolumeSettingView = new SoundAndVibrationVolumeSettingView(CALL_VOLUME);\r
+ if (p_SoundAndVibrationVolumeSettingView == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!");\r
+ return nullptr;\r
+ }\r
+ }\r
+ if (CallVolumeScrollView == nullptr)\r
+ {\r
+ CallVolumeScrollView = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess();\r
+ if (CallVolumeScrollView == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::CallVolumeScrollView is nullptr!");\r
+ return nullptr;\r
+ }\r
+ }\r
+\r
+ return CallVolumeScrollView;\r
+ }\r
+\r
+ void CallVolumeView::OnStart()\r
+ {\r
+ GetRootContainer()->SetTouchable(true);\r
+ GetRootContainer()->SetDraggable(true);\r
+ GetRootContainer()->SetOnDragListener(presenter_);\r
+\r
+ if (!initViewStatus)\r
+ {\r
+ CallVolumeViewInit();\r
+ initViewStatus = true;\r
+ }\r
+ UpdateCallVolumeSliderValue();\r
+ AddViewToRootContainer(CallVolumeScrollView);\r
+\r
+ return;\r
+ }\r
+\r
+ // 更新通话音量条的值\r
+ bool CallVolumeView::UpdateCallVolumeSliderValue(void)\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumeView::UpdateCallVolumeSliderValue");\r
+ if (p_SoundAndVibrationVolumeSettingView == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!");\r
+ return false;\r
+ }\r
+ int callVolume = uapi_callVolumeGet();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolume = %d", callVolume);\r
+ p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(callVolume);\r
+\r
+ return true;\r
+ }\r
+}\r
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-02-23 09:17:00
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-09-18 19:34:06
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp
+ */
+#include "soundandvibration/include/SoundAndVibrationModel.h"
+#include "soundandvibration/include/SoundAndVibrationPresenter.h"
+#include "soundandvibration/include/VibrationModeView.h"
+#include "soundandvibration/include/SystemVolumeView.h"
+#include "soundandvibration/include/CallVolumeView.h"
+#include "wearable_log.h"
+#include "ConfigModel.h"
+#include "player/include/PlayersView.h"
+namespace OHOS
+{
+
+ SoundAndVibrationModel::SoundAndVibrationModel() {}
+
+ SoundAndVibrationModel::~SoundAndVibrationModel() {}
+
+ SoundAndVibrationModel *SoundAndVibrationModel::GetInstance(void)
+ {
+ static SoundAndVibrationModel instance;
+ return &instance;
+ }
+
+ // 更新系统音量条的值
+ bool SoundAndVibrationModel::UpdateSystemVolume(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationModel::UpdateSystemVolume");
+ if (SystemVolumeView::GetInstance())
+ {
+ SystemVolumeView::GetInstance()->UpdateSystemVolumeSliderValue();
+ }
+
+ //同步显示音乐的声音进度条
+ if(PlayersView::GetInstance())
+ {
+ #ifdef FD230_650
+ PlayersView::GetInstance()->UpdateVolumeValue();
+ #endif
+ }
+ return true;
+ }
+
+ // 更新通话音量条的值
+ bool SoundAndVibrationModel::UpdateCallVolume(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationModel::UpdateCallVolume");
+ CallVolumeView *p_CallVolumeView = CallVolumeView::GetInstance();
+ if (p_CallVolumeView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::GetInstance fail!!");
+ return false;
+ }
+ p_CallVolumeView->UpdateCallVolumeSliderValue();
+
+ return true;
+ }
+
+ // 更新震动模式选择器的选定项的索引
+ bool SoundAndVibrationModel::UpdateVibrationModePickerSelectIndex(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationModel::UpdateVibrationModePickerSelectIndex");
+ VibrationModeView *p_VibrationModeView = VibrationModeView::GetInstance();
+ if (p_VibrationModeView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationModeView::GetInstance fail!!");
+ return false;
+ }
+ p_VibrationModeView->UpdatePickerSelectIndex();
+
+ return true;
+ }
+
+ // 更新静音模式开关状态
+ bool SoundAndVibrationModel::UpdateSilentModeSwitch(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationModel::UpdateSilentModeSwitch");
+ SoundAndVibrationView *p_SoundAndVibrationView = SoundAndVibrationView::GetInstance();
+ if (p_SoundAndVibrationView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::GetInstance fail!!");
+ return false;
+ }
+ p_SoundAndVibrationView->UpdateSilentModeSwitchStatus();
+ return true;
+ }
+
+ /// @brief 设置“震动模式”强度
+ /// @param value
+ void SoundAndVibrationModel::SetVibrationReminderToggleButtonStaus(int value)
+ {
+ ConfigModel::GetInstance()->SetVibrationReminder(value);
+ }
+
+ // 获取震动强度
+ int SoundAndVibrationModel::GetVibrationReminderToggleButtonStaus()
+ {
+ return ConfigModel::GetInstance()->GetVibrationReminder();
+ }
+
+ /// @brief 设置“静音模式”是否开启
+ /// @param value
+ void SoundAndVibrationModel::SetSilentModeToggleButtonStatus(bool value)
+ {
+ ConfigModel::GetInstance()->SetSilentMode(value);
+ }
+
+ /// @brief 获取“静音模式”是否开启
+ bool SoundAndVibrationModel::GetSilentModeToggleButtonStatus(void)
+ {
+ return ConfigModel::GetInstance()->GetSilentMode();
+ }
+
+}
--- /dev/null
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-02-19 10:39:11\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-11-05 14:42:21\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp\r
+ */\r
+\r
+#include "AppViewIDs.h"\r
+#include "components/ui_label_ext.h"\r
+#include "ui_resource_string.h"\r
+#include "NativeAbility.h"\r
+#include "graphic_math.h"\r
+#include "string.h"\r
+#include "soundandvibration/include/SoundAndVibrationPresenter.h"\r
+#include "common/key_code.h"\r
+#include "custom_utils.h"\r
+#include "ConfigModel.h"\r
+#include <ohos_types.h>\r
+#include "soundandvibration/include/SoundAndVibrationVolumeSettingC.h"\r
+#include "UiConfig.h"\r
+#include "vibrator_service.h"\r
+#include "NativeRegisterManager.h"\r
+\r
+namespace OHOS\r
+{\r
+ REGIST_SLICE(VIEW_SOUND_VIBRATION, SoundAndVibrationView, SoundAndVibrationPresenter);\r
+ // 当前Presenter属性实例化的内存指针\r
+ static SoundAndVibrationPresenter *g_pSoundAndVibrationPresenter = nullptr;\r
+\r
+ SoundAndVibrationPresenter::SoundAndVibrationPresenter()\r
+ {\r
+ g_pSoundAndVibrationPresenter = this;\r
+ }\r
+\r
+ SoundAndVibrationPresenter::~SoundAndVibrationPresenter()\r
+ {\r
+ g_pSoundAndVibrationPresenter = nullptr;\r
+ }\r
+\r
+ SoundAndVibrationPresenter *SoundAndVibrationPresenter::GetInstance()\r
+ {\r
+ return g_pSoundAndVibrationPresenter;\r
+ }\r
+\r
+ void SoundAndVibrationPresenter::OnStart()\r
+ {\r
+ }\r
+\r
+ void SoundAndVibrationPresenter::OnPause(void)\r
+ {\r
+ Presenter<SoundAndVibrationView>::OnPause();\r
+ }\r
+\r
+ void SoundAndVibrationPresenter::OnResume(void)\r
+ {\r
+ Presenter<SoundAndVibrationView>::OnResume();\r
+ if (view_ == nullptr)\r
+ {\r
+ return;\r
+ }\r
+ }\r
+\r
+ void SoundAndVibrationPresenter::OnStop(void)\r
+ {\r
+ }\r
+\r
+ bool SoundAndVibrationPresenter::OnDrag(UIView &view, const DragEvent &event)\r
+ {\r
+ UNUSED(view);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RespiratoryTrainingPresenter::OnDrag");\r
+ if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动\r
+ {\r
+ SoundAndVibrationPresenter::X_DRAG_FLAG = true;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ bool SoundAndVibrationPresenter::OnDragEnd(UIView &view, const DragEvent &event)\r
+ {\r
+ UNUSED(view);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationPresenter::OnDragEnd");\r
+ std::string viewId = view.GetViewId();\r
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && SoundAndVibrationPresenter::X_DRAG_FLAG)\r
+ {\r
+ if (viewId == VIBRATION_MODE_VIEWID) // 如果在震动提醒子视图\r
+ {\r
+ view_->GetVibrationModeView()->UpdatePickerSelectIndex();\r
+ SoundAndVibrationView::GetInstance()->ChangeView(VIBRATIONMODEVIEW, SOUNDANDVIBRATIONVIEW);\r
+ }\r
+ else\r
+ {\r
+ NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);\r
+ }\r
+ SoundAndVibrationPresenter::X_DRAG_FLAG = false;\r
+ }\r
+\r
+ return true;\r
+ }\r
+\r
+ bool SoundAndVibrationPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件\r
+ {\r
+ UNUSED(view);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationPresenter::OnKeyAct");\r
+ uint16 keyID = event.GetKeyId();\r
+ uint16 keyState = event.GetState();\r
+ // 如果是power键,且是亮屏状态,按键释放就返回上一级\r
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)\r
+ {\r
+ NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);\r
+ }\r
+ return true;\r
+ }\r
+\r
+ bool SoundAndVibrationPresenter::OnClick(UIView &view, const ClickEvent &event)\r
+ {\r
+ UNUSED(event);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationPresenter::OnKeyAct");\r
+ if (strcmp(view.GetViewId(), SYSTEM_VOLUME_BUTTON) == 0)\r
+ {\r
+ NativeAbility::GetInstance().EnterSlice(VIEW_SYSTEM_VOLUME);\r
+ }\r
+ else if (strcmp(view.GetViewId(), CALL_VOLUME_BUTTON) == 0)\r
+ {\r
+ NativeAbility::GetInstance().EnterSlice(VIEW_CALL_VOLUME);\r
+ }\r
+ else if (strcmp(view.GetViewId(), VIBRATION_REMINDER_BUTTON) == 0)\r
+ {\r
+ view_->ChangeView(SOUNDANDVIBRATIONVIEW, VIBRATIONMODEVIEW);\r
+ }\r
+ else if ((view_->GetVibrationModeView() != nullptr) && (&view == view_->GetVibrationModeView()->GetVibrationModeLabelButton()))\r
+ {\r
+ int VibrationMode = view_->GetVibrationModeView()->GetVibrationModePicker()->GetSelected();\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VibrationMode = %d", VibrationMode);\r
+ SoundAndVibrationModel::GetInstance()->SetVibrationReminderToggleButtonStaus(VibrationMode);\r
+ // uapi_vibrationModeSet(VibrationMode);\r
+ ui_api_vibrate_once_func();\r
+ view_->ChangeView(VIBRATIONMODEVIEW, SOUNDANDVIBRATIONVIEW);\r
+ }\r
+ return true;\r
+ }\r
+\r
+ bool SoundAndVibrationPresenter::OnChange(UICheckBox::UICheckBoxState state)\r
+ {\r
+ SoundAndVibrationModel *p_SoundAndVibrationModel = SoundAndVibrationModel::GetInstance();\r
+ switch (state)\r
+ {\r
+ case UICheckBox::SELECTED:\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SilentMode is enable!");\r
+ p_SoundAndVibrationModel->SetSilentModeToggleButtonStatus(true);\r
+ break;\r
+ case UICheckBox::UNSELECTED:\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SilentMode is disable!");\r
+ p_SoundAndVibrationModel->SetSilentModeToggleButtonStatus(false);\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ bool SoundAndVibrationPresenter::OnRotate(UIView &view, const RotateEvent &event)\r
+ {\r
+ UNUSED(view);\r
+ UNUSED(event);\r
+ return true;\r
+ }\r
+\r
+ bool SoundAndVibrationPresenter::OnRotateEnd(UIView &view, const RotateEvent &event)\r
+ {\r
+ UNUSED(view);\r
+ UNUSED(event);\r
+ return true;\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-02-19 10:39:14\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2025-02-24 17:16:40\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp\r
+ */\r
+#include "soundandvibration/include/SoundAndVibrationView.h"\r
+#include "soundandvibration/include/SoundAndVibrationPresenter.h"\r
+#include "soundandvibration/include/SoundAndVibrationModel.h"\r
+#include "wearable_log.h"\r
+#include "ui_resource_string.h"\r
+#include <UiConfig.h>\r
+/*\r
+按优先级分为\r
+1.系统音量\r
+2通话音量\r
+3.媒体音量\r
+\r
+震动提醒\r
+开/关\r
+\r
+静音模式\r
+系统音量不受影响\r
+\r
+*/\r
+\r
+namespace OHOS\r
+{\r
+\r
+ static SoundAndVibrationView *g_pSoundAndVibrationView{nullptr};\r
+\r
+ SoundAndVibrationView::SoundAndVibrationView()\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SoundAndVibrationView");\r
+ g_pSoundAndVibrationView = this;\r
+ }\r
+\r
+ SoundAndVibrationView::~SoundAndVibrationView()\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::~SoundAndVibrationView");\r
+ ClearAll();\r
+ g_pSoundAndVibrationView = nullptr;\r
+ }\r
+\r
+ SoundAndVibrationView *SoundAndVibrationView::GetInstance()\r
+ {\r
+ return g_pSoundAndVibrationView;\r
+ }\r
+\r
+ void SoundAndVibrationView::ClearAll()\r
+ {\r
+ if (initViewStatus == true)\r
+ {\r
+\r
+ if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] != nullptr)\r
+ {\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->RemoveAll();\r
+ if (Title != nullptr)\r
+ {\r
+ delete Title;\r
+ Title = nullptr;\r
+ }\r
+ for (int i = 0; i < 4; i++)\r
+ {\r
+ if (buttonPointers[i] != nullptr)\r
+ {\r
+ delete buttonPointers[i];\r
+ buttonPointers[i] = nullptr;\r
+ }\r
+ if (labelPointers[i] != nullptr)\r
+ {\r
+ delete labelPointers[i];\r
+ labelPointers[i] = nullptr;\r
+ }\r
+ }\r
+ if (SilentModeToggleButton != nullptr)\r
+ {\r
+ delete SilentModeToggleButton;\r
+ SilentModeToggleButton = nullptr;\r
+ }\r
+ if (temp != nullptr)\r
+ {\r
+ delete temp;\r
+ temp = nullptr;\r
+ }\r
+ delete SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW];\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = nullptr;\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::ClearAll end!!");\r
+ }\r
+ }\r
+ if (vibrationModeView != nullptr)\r
+ {\r
+ delete vibrationModeView;\r
+ vibrationModeView = nullptr;\r
+ }\r
+ for (int i = SOUNDANDVIBRATIONVIEW; i < MAX_SOUNDANDVIBRATIONVIEWID; i++)\r
+ {\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = nullptr;\r
+ }\r
+ }\r
+\r
+ /// @brief 声音与震动视图"scrollView"视图初始化\r
+ /// @param void\r
+ /// @return true 初始化成功 false 初始化失败\r
+ bool SoundAndVibrationView::InitSoundAndVibrationScrollView(void)\r
+ {\r
+ if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] == nullptr)\r
+ {\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = new UIScrollView();\r
+ if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new SoundAndVibrationScrollView[%d] fail!", SOUNDANDVIBRATIONVIEW);\r
+ return false;\r
+ }\r
+ }\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetThrowDrag(true);\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetTouchable(true);\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetDraggable(true);\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetScrollBlankSize(30);\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetReboundSize(30);\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetDirection(1);\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetMaxScrollDistance(1000); // 设置手指抬起屏幕后的最大滚动距离。\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetSwipeACCLevel(200); /*设置手指抬起屏幕后的补偿距离。*/\r
+ FocusManager::GetInstance()->RequestFocus(SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]);\r
+ FocusManager::GetInstance()->RequestFocusByDirection(FOCUS_DIRECTION_UP);\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetRotateFactor(1.0);\r
+ AddViewToRootContainer(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(23);\r
+ label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);\r
+ return label;\r
+ }\r
+\r
+ /// @brief 声音与震动视图"标题"标签初始化\r
+ /// @param void\r
+ /// @return true 初始化成功 false 初始化失败\r
+ bool SoundAndVibrationView::InitSoundAndVibrationViewTitleLabel(void)\r
+ {\r
+ if (Title == nullptr)\r
+ {\r
+ Title = new UILabelExt();\r
+ if (Title == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Title new fail!");\r
+ return false;\r
+ }\r
+ }\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_OSCILLATION);\r
+ Title->SetRollSpeed(23);\r
+ Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(Title);\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
+ if (labelPointers[i] == nullptr)\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
+ }\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(labelPointers[i]);\r
+ }\r
+ return true;\r
+ }\r
+\r
+ /// @brief 设置按钮\r
+ /// @param button\r
+ /// @return true 设置成功,false 失败\r
+ UILabelButtonExt *SoundAndVibrationView::SetUpButton_Ext(ButtonConfig &buttonconfig, bool nextImgVisible)\r
+ {\r
+ UILabelButtonExt *labelButton = new UILabelButtonExt();\r
+ if (labelButton == nullptr)\r
+ {\r
+ return nullptr;\r
+ }\r
+ labelButton->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h);\r
+ labelButton->SetViewId(buttonconfig.ViewId);\r
+ labelButton->SetOnClickListener(presenter_);\r
+ labelButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+ if (nextImgVisible)\r
+ {\r
+ 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->SetStyleForState(STYLE_BACKGROUND_COLOR, nextImgVisible ? 0xff000000 : 0xff191919, UIButton::PRESSED);\r
+\r
+ return labelButton;\r
+ }\r
+ /// @brief 声音与震动视图"按钮"初始化\r
+ /// @param void\r
+ /// @return true 初始化成功 false 初始化失败\r
+ bool SoundAndVibrationView::InitSoundAndVibrationButtonView(void)\r
+ {\r
+ struct ButtonSetup\r
+ {\r
+ int y;\r
+ const char *viewId;\r
+ bool clickEffect;\r
+ };\r
+\r
+ ButtonSetup buttonSetups[] = {\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
+ for (int i = 0; i < sizeof(buttonSetups) / sizeof(buttonSetups[0]); ++i)\r
+ {\r
+ ButtonConfig buttonconfig = {\r
+ .x = 43,\r
+ .y = buttonSetups[i].y,\r
+ .w = 380,\r
+ .h = 100,\r
+ .ViewId = buttonSetups[i].viewId,\r
+ };\r
+ if (buttonPointers[i] == nullptr)\r
+ {\r
+ buttonPointers[i] = SetUpButton_Ext(buttonconfig, buttonSetups[i].clickEffect);\r
+ if (buttonPointers[i] == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Button[%d] new fail!", i);\r
+ return false;\r
+ }\r
+ }\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(buttonPointers[i]);\r
+ }\r
+\r
+ return true;\r
+ }\r
+\r
+ bool SoundAndVibrationView::InitSoundAndVibrationToggleButton(void)\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::InitSoundAndVibrationToggleButton");\r
+ if (SilentModeToggleButton == nullptr)\r
+ {\r
+ SilentModeToggleButton = new UIToggleButton();\r
+ if (SilentModeToggleButton == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeToggleButton new fail!");\r
+ return false;\r
+ }\r
+ }\r
+ SilentModeToggleButton->SetPosition(298, 505, 100, 50);\r
+ SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+ SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+ SilentModeToggleButton->SetState(SoundAndVibrationModel::GetInstance()->GetSilentModeToggleButtonStatus());\r
+ SilentModeToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE);\r
+ SilentModeToggleButton->SetOnChangeListener(presenter_);\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(SilentModeToggleButton);\r
+\r
+ return true;\r
+ }\r
+\r
+ void SoundAndVibrationView::CreateSoundAndVibrationView(void)\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CreateSoundAndVibrationView");\r
+ if (!InitSoundAndVibrationScrollView() || !InitSoundAndVibrationButtonView() ||\r
+ !InitSoundAndVibrationViewTitleLabel() || !InitSoundAndVibrationToggleButton())\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CreateSoundAndVibrationView fail!!");\r
+ return;\r
+ }\r
+ /* ------------------- 该组件的使用是为了解决不能单独设置滚动视图底部空白大小问题,用一个不可见组件占位置 ------------------ */\r
+ /* ---------------------------- 因为使用SetScrollBlankSize设置大小后下拉后无法恢复到原位置,有向下偏移 --------------------------- */\r
+ if (temp == nullptr)\r
+ {\r
+ temp = new UIImageView();\r
+ if (temp == nullptr)\r
+ {\r
+ return;\r
+ }\r
+ temp->SetPosition(43, 480 + 120, 380, 40);\r
+ temp->SetVisible(false);\r
+ SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(temp);\r
+ }\r
+ initViewStatus = true;\r
+ }\r
+\r
+ void SoundAndVibrationView::OnStart()\r
+ {\r
+ GetRootContainer()->SetTouchable(true);\r
+ GetRootContainer()->SetDraggable(true);\r
+ GetRootContainer()->SetOnDragListener(presenter_);\r
+\r
+ if (!initViewStatus)\r
+ {\r
+ CreateSoundAndVibrationView();\r
+ }\r
+ }\r
+\r
+ // 声音与震动界面\r
+ bool SoundAndVibrationView::ChangeSoundAndVibrationView(int16_t thisView)\r
+ {\r
+ if (SoundAndVibrationScrollView[thisView] == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::ChangeSoundAndVibrationView");\r
+ AddViewToRootContainer(SoundAndVibrationScrollView[thisView]);\r
+ }\r
+ return true;\r
+ }\r
+\r
+ // 震动模式界面\r
+ bool SoundAndVibrationView::ChangeVibrationModeView(int16_t thisView)\r
+ {\r
+ if (SoundAndVibrationScrollView[thisView] == nullptr)\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::ChangeVibrationModeView");\r
+ if (vibrationModeView == nullptr)\r
+ {\r
+ vibrationModeView = new VibrationModeView();\r
+ if (vibrationModeView == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView:: new scrollView[%d] fail", thisView);\r
+ return false;\r
+ }\r
+ }\r
+ SoundAndVibrationScrollView[thisView] = vibrationModeView->VibrationModeViewInit();\r
+ AddViewToRootContainer(SoundAndVibrationScrollView[thisView]);\r
+ }\r
+ return true;\r
+ }\r
+\r
+ struct SoundAndVibrationViewMapper\r
+ {\r
+ const int16_t viewId;\r
+ bool (SoundAndVibrationView::*func)(int16_t thisView);\r
+ };\r
+\r
+ static const SoundAndVibrationViewMapper ViewMapper[] = {\r
+ {SOUNDANDVIBRATIONVIEW, &SoundAndVibrationView::ChangeSoundAndVibrationView},\r
+ {VIBRATIONMODEVIEW, &SoundAndVibrationView::ChangeVibrationModeView},\r
+ };\r
+\r
+ bool SoundAndVibrationView::ClickFunc(int16_t interface)\r
+ {\r
+ int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]);\r
+ for (int i = 0; i < funcSize; i++)\r
+ {\r
+ if (interface == ViewMapper[i].viewId)\r
+ {\r
+ bool jug = (this->*(ViewMapper[i].func))(interface);\r
+ if (jug == false)\r
+ {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+ }\r
+ 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 (!CheckViewParam(hideView, showView))\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CheckViewParam failed.");\r
+ return;\r
+ }\r
+ SoundAndVibrationScrollView[hideView]->SetVisible(false);\r
+ ClickFunc(showView);\r
+ SoundAndVibrationScrollView[showView]->SetVisible(true);\r
+ Draw();\r
+ }\r
+ /* -------------------------------------------------------------------------- */\r
+\r
+ VibrationModeView *SoundAndVibrationView::GetVibrationModeView(void)\r
+ {\r
+ return vibrationModeView;\r
+ }\r
+\r
+ // 更新静音模式开关状态\r
+ bool SoundAndVibrationView::UpdateSilentModeSwitchStatus(void)\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::UpdateSilentModeSwitchStatus");\r
+ if (SilentModeToggleButton == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeToggleButton is nullptr!!");\r
+ return false;\r
+ }\r
+ SilentModeToggleButton->SetState(SoundAndVibrationModel::GetInstance()->GetSilentModeToggleButtonStatus());\r
+ SilentModeToggleButton->Invalidate();\r
+\r
+ return true;\r
+ }\r
+}\r
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-19 10:08:31
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-12-23 15:53:23
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp
+ */
+#include "soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h"
+#include "soundandvibration/include/SoundAndVibrationVolumeSettingC.h"
+#include "wearable_log.h"
+#include <audio_manager.h>
+#include <custom_utils.h>
+#include "phoneservice/include/PhoneAudio.h"
+#include "phoneservice/include/PhoneService.h"
+#include "../../../../../../middleware/services/media/foundation/audiomanager/frameworks/audioservice/include/audio_service.h"
+#include "vibrator_service.h"
+#include "ConfigModel.h"
+#include <custom_runtime.h>
+
+namespace OHOS
+{
+
+ static constexpr int16_t VOLUMEVALUE_CHANGE = 10;
+ // 步骤 2: 实现具体的策略
+ class LowerVolumeStrategy : public VolumeChangeStrategy
+ {
+ public:
+ void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, int32_t value) override
+ {
+ uint16_t newVolumeValue = slider->GetValue() - VOLUMEVALUE_CHANGE;
+ if (newVolumeValue < VOLUME_MIN)
+ {
+ newVolumeValue = VOLUME_MIN;
+ }
+ if (view->GetVolumeType() == SYSTEM_VOLUME)
+ {
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_SYSTEM_VOLUME, (void *)(&value), sizeof(value));
+ }
+ else if (view->GetVolumeType() == CALL_VOLUME)
+ {
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_CALL_VOLUME, (void *)(&value), sizeof(value));
+ }
+ slider->SetValue(newVolumeValue);
+ }
+ };
+
+ class ElevateVolumeStrategy : public VolumeChangeStrategy
+ {
+ public:
+ void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, int32_t value) override
+ {
+ uint16_t newVolumeValue = slider->GetValue() + VOLUMEVALUE_CHANGE;
+ if (newVolumeValue > VOLUME_MAX)
+ {
+ newVolumeValue = VOLUME_MAX;
+ }
+ if (view->GetVolumeType() == SYSTEM_VOLUME)
+ {
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_SYSTEM_VOLUME, (void *)(&value), sizeof(value));
+ }
+ else if (view->GetVolumeType() == CALL_VOLUME)
+ {
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_CALL_VOLUME, (void *)(&value), sizeof(value));
+ }
+ slider->SetValue(newVolumeValue);
+ }
+ };
+
+ class DragVolumeStrategy : public VolumeChangeStrategy
+ {
+ public:
+ void ApplyChange(SoundAndVibrationVolumeSettingView *view, UISlider *slider, int32_t value) override
+ {
+ if (view->GetVolumeType() == SYSTEM_VOLUME)
+ {
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_SYSTEM_VOLUME, (void *)(&value), sizeof(value));
+ }
+ else if (view->GetVolumeType() == CALL_VOLUME)
+ {
+
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CHANGE_CALL_VOLUME, (void *)(&value), sizeof(value));
+ }
+ slider->SetValue(value);
+ }
+ };
+
+ /* --------------------- VoumeProcessSliderEventListener -------------------- */
+ static VoumeProcessSliderEventListener *g_pVoumeProcessSliderEventListener{nullptr};
+ VoumeProcessSliderEventListener::VoumeProcessSliderEventListener()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::VoumeProcessSliderEventListener");
+ // 步骤 3: 创建一个映射表将状态映射到策略
+ strategyMap[VOLUMEREDUCE] = std::make_shared<LowerVolumeStrategy>();
+ strategyMap[VOLUMEADD] = std::make_shared<ElevateVolumeStrategy>();
+ strategyMap[OTHER] = std::make_shared<DragVolumeStrategy>();
+ g_pVoumeProcessSliderEventListener = this;
+ }
+
+ VoumeProcessSliderEventListener::~VoumeProcessSliderEventListener()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::~VoumeProcessSliderEventListener");
+ g_pVoumeProcessSliderEventListener = nullptr;
+ }
+
+ VoumeProcessSliderEventListener *VoumeProcessSliderEventListener::GetInstance(void)
+ {
+ return g_pVoumeProcessSliderEventListener;
+ }
+
+ void VoumeProcessSliderEventListener::FindAndApplyStrategy(uint8_t status, int32_t value)
+ {
+ auto it = strategyMap.find(status);
+ if (it != strategyMap.end())
+ {
+ SoundAndVibrationVolumeSettingView *view = SoundAndVibrationVolumeSettingView::GetInstance();
+ UISlider *slider = view ? view->GetVolumeProcess() : nullptr;
+ if (view && slider)
+ {
+ it->second->ApplyChange(view, slider, value);
+ }
+ }
+ }
+
+ void VoumeProcessSliderEventListener::ChangeVolumeValue(uint8_t status, int32_t value)
+ {
+ FindAndApplyStrategy(status, value);
+ }
+
+ // 滑块变化事件处理
+ void VoumeProcessSliderEventListener::OnChange(int32_t value)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnChange %d", 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);
+ }
+
+ // 滑块点击事件处理
+ bool VoumeProcessSliderEventListener::OnClick(UIView &view, const ClickEvent &event)
+ {
+ UNUSED(event);
+ 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);
+ 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::OnRotate(UIView &view, const RotateEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VoumeProcessSliderEventListener::OnRotate,%d",event.GetRotate());
+ 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;
+ }
+ 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
+extern "C"
+{
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+ extern void custom_VibratorFunc_int(int vibratorType);
+ /*
+ * @brief 系统音量设置
+ */
+ void SystemVolumeSet(int32_t sounding)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeSet %d", sounding);
+ Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, sounding); // 系统音量设置
+ Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_NOTIFICATION_SYSTEM, sounding); // 查找手表,闹钟,倒计时铃声也受系统音量控制
+ Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_RING, sounding); //来电铃声
+ }
+
+ int SystemVolumeGet(void)
+ {
+ return Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_MUSIC);
+ }
+
+ /*
+ * @brief 通话音量设置
+ */
+ void CallVolumeSet(int32_t sounding)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeSet %d", sounding);
+ // Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO, sounding); // 通话音量设置
+ // Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_VOICE_CALL_VOLTE, sounding); // 通话音量设置
+ #ifdef FD230_650
+ set_speaker_volume(sounding,AUDIO_STREAM_VOICE_CALL_BT_SCO);
+ set_speaker_volume(sounding,AUDIO_STREAM_VOICE_CALL_VOLTE);
+ #endif
+ }
+
+ int CallVolumeGet(void)
+ {
+ // return Audio::AudioManager::GetInstance().GetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO);
+ return GetCallCurrVolume();
+ }
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
\ No newline at end of file
--- /dev/null
+#include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h"
+#include "soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h"
+#include "wearable_log.h"
+#include "ConfigModel.h"
+
+namespace OHOS
+{
+
+ static constexpr const char *VOLUMECONTROLVECTORIMAGEPATH = "/user/res/VolumeControlVector.bin";
+ static SoundAndVibrationVolumeSettingView *g_pSoundAndVibrationVolumeSettingView{nullptr};
+
+ SoundAndVibrationVolumeSettingView::SoundAndVibrationVolumeSettingView(uint8_t VolumeType)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::SoundAndVibrationVolumeSettingView,VolumeType = %d", VolumeType);
+ m_VolumeType = VolumeType;
+ g_pSoundAndVibrationVolumeSettingView = this;
+ }
+
+ SoundAndVibrationVolumeSettingView::~SoundAndVibrationVolumeSettingView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::~SoundAndVibrationVolumeSettingView");
+ ClearAll();
+ g_pSoundAndVibrationVolumeSettingView = nullptr;
+ }
+
+ SoundAndVibrationVolumeSettingView *SoundAndVibrationVolumeSettingView::GetInstance(void)
+ {
+ return g_pSoundAndVibrationVolumeSettingView;
+ }
+
+ void SoundAndVibrationVolumeSettingView::ClearAll(void)
+ {
+ if (initViewStatus == true)
+ {
+ 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;
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::ClearAll end!!");
+ }
+ }
+ }
+
+ /*
+ * @brief 获取声音进度条
+ */
+ UISlider *SoundAndVibrationVolumeSettingView::GetVolumeProcess(void)
+ {
+ return VolumeProcess;
+ }
+
+ /*
+ * @brief 获取声音类型
+ * @return 返回 0 系统音量,返回 1 通话音量
+ */
+ int SoundAndVibrationVolumeSettingView::GetVolumeType(void)
+ {
+ return m_VolumeType;
+ }
+
+ UIScrollView *SoundAndVibrationVolumeSettingView::SetUpVolumeProcess(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::SetUpVolumeProcess");
+ if (ScrollView == nullptr)
+ {
+ ScrollView = new UIScrollView();
+ if (ScrollView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::ScrollView new fail");
+ return nullptr;
+ }
+ }
+ ScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+ ScrollView->SetDraggable(true);
+ ScrollView->SetTouchable(true);
+ /* ------------------------------ VolumeProcess ----------------------------- */
+ if (VolumeProcess == nullptr)
+ {
+ VolumeProcess = new UISlider();
+ if (VolumeProcess == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VolumeProcess new fail");
+ return nullptr;
+ }
+ }
+ VolumeProcess->SetSliderColor(Color::Gray(), Color::Silver());
+ VolumeProcess->SetPosition(167, 77, 130, 310);
+ VolumeProcess->SetDirection(UISlider::Direction::DIR_BOTTOM_TO_TOP);
+ VolumeProcess->SetViewId(VOLUME_PROGRESS);
+ VolumeProcess->SetRange(VOLUME_MAX, VOLUME_MIN);
+
+ VolumeProcess->SetStyle(STYLE_BORDER_RADIUS, 100);
+ VolumeProcess->SetBackgroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND);
+ VolumeProcess->SetForegroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND);
+ 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 ------------------------------ */
+ if (VolumeVetor == nullptr)
+ {
+ VolumeVetor = new UIImageView();
+ if (VolumeVetor == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VolumeVetor new fail");
+ return nullptr;
+ }
+ }
+ VolumeVetor->SetPosition(213, 213, 40, 40);
+ VolumeVetor->SetSrc(VOLUMECONTROLVECTORIMAGEPATH);
+
+ if (listener == nullptr)
+ {
+ listener = new VoumeProcessSliderEventListener();
+ if (listener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Listener new fail!");
+ return nullptr;
+ }
+ }
+ VolumeProcess->SetSliderEventListener(listener);
+ VolumeProcess->SetOnClickListener(listener);
+ VolumeProcess->SetOnDragListener(listener);
+ VolumeProcess->SetOnRotateListener(listener);
+
+ ScrollView->Add(VolumeProcess);
+ ScrollView->Add(VolumeVetor);
+ initViewStatus = true;
+
+ return ScrollView;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-03-30 09:14:38\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-06-19 18:58:05\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumePresenter.cpp\r
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE\r
+ */\r
+#include "AppViewIDs.h"\r
+#include "components/ui_label_ext.h"\r
+#include "ui_resource_string.h"\r
+#include "NativeAbility.h"\r
+#include "graphic_math.h"\r
+#include "string.h"\r
+#include "soundandvibration/include/SystemVolumePresenter.h"\r
+\r
+#include "common/key_code.h"\r
+#include "custom_utils.h"\r
+#include <ohos_types.h>\r
+#include <UiConfig.h>\r
+#include "NativeRegisterManager.h"\r
+// 系统音量\r
+namespace OHOS\r
+{\r
+ REGIST_SLICE(VIEW_SYSTEM_VOLUME, SystemVolumeView, SystemVolumePresenter);\r
+ // 当前Presenter属性实例化的内存指针\r
+ static SystemVolumePresenter *g_pSystemVolumePresenter = nullptr;\r
+\r
+ SystemVolumePresenter::SystemVolumePresenter()\r
+ {\r
+\r
+ g_pSystemVolumePresenter = this;\r
+ }\r
+\r
+ SystemVolumePresenter::~SystemVolumePresenter()\r
+ {\r
+\r
+ g_pSystemVolumePresenter = nullptr;\r
+ }\r
+\r
+ SystemVolumePresenter *SystemVolumePresenter::GetInstance()\r
+ {\r
+\r
+ return g_pSystemVolumePresenter;\r
+ }\r
+\r
+ void SystemVolumePresenter::OnStart()\r
+ {\r
+\r
+ }\r
+\r
+ void SystemVolumePresenter::OnPause(void)\r
+ {\r
+\r
+ Presenter<SystemVolumeView>::OnPause();\r
+ }\r
+\r
+ void SystemVolumePresenter::OnResume(void)\r
+ {\r
+\r
+ Presenter<SystemVolumeView>::OnResume();\r
+ }\r
+\r
+ void SystemVolumePresenter::OnStop(void)\r
+ {\r
+\r
+ }\r
+\r
+ bool SystemVolumePresenter::OnDrag(UIView &view, const DragEvent &event)\r
+ {\r
+ UNUSED(view);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumePresenter::OnDrag");\r
+ if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动\r
+ {\r
+ SystemVolumePresenter::X_DRAG_FLAG = true;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ bool SystemVolumePresenter::OnDragEnd(UIView &view, const DragEvent &event)\r
+ {\r
+ UNUSED(view);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumePresenter::OnDragEnd");\r
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && SystemVolumePresenter::X_DRAG_FLAG)\r
+ {\r
+ NativeAbility::GetInstance().Back();\r
+ SystemVolumePresenter::X_DRAG_FLAG = false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ bool SystemVolumePresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件\r
+ {\r
+ UNUSED(view);\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumePresenter::OnKeyAct");\r
+ uint16 keyID = event.GetKeyId();\r
+ uint16 keyState = event.GetState();\r
+ // 如果是power键,且是亮屏状态,按键释放就返回上一级\r
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)\r
+ {\r
+ NativeAbility::GetInstance().Back();\r
+ }\r
+ return true;\r
+ }\r
+\r
+ bool SystemVolumePresenter::OnClick(UIView &view, const ClickEvent &event)\r
+ {\r
+ UNUSED(view);\r
+ UNUSED(event);\r
+ return true;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-06-12 11:44:04\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2025-02-24 17:26:02\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp\r
+ */\r
+#include "soundandvibration/include/SystemVolumeView.h"\r
+#include "soundandvibration/include/SystemVolumePresenter.h"\r
+#include "wearable_log.h"\r
+#include <audio_manager.h>\r
+#include "ConfigModel.h"\r
+#include <custom_utils.h>\r
+/*\r
+系统音量:\r
+通话,提醒,查找手表的音量\r
+*/\r
+\r
+namespace OHOS\r
+{\r
+\r
+ static SystemVolumeView *g_pSystemVolumeView{nullptr};\r
+\r
+ SystemVolumeView::SystemVolumeView()\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::SystemVolumeView");\r
+ g_pSystemVolumeView = this;\r
+ }\r
+\r
+ SystemVolumeView::~SystemVolumeView()\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::~SystemVolumeView");\r
+ ClearAll();\r
+ g_pSystemVolumeView = nullptr;\r
+ }\r
+\r
+ SystemVolumeView *SystemVolumeView::GetInstance()\r
+ {\r
+ return g_pSystemVolumeView;\r
+ }\r
+\r
+ void SystemVolumeView::ClearAll()\r
+ {\r
+ if (initViewStatus == true)\r
+ {\r
+ if (SystemVolumeScrollView != nullptr)\r
+ {\r
+ SystemVolumeScrollView = nullptr;\r
+ }\r
+ delete p_SoundAndVibrationVolumeSettingView;\r
+ p_SoundAndVibrationVolumeSettingView = nullptr;\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::ClearAll end!!");\r
+ }\r
+ }\r
+\r
+ UIScrollView *SystemVolumeView::SystemVolumeViewInit(void)\r
+ {\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::SystemVolumeViewInit");\r
+ if (p_SoundAndVibrationVolumeSettingView == nullptr)\r
+ {\r
+ p_SoundAndVibrationVolumeSettingView = new SoundAndVibrationVolumeSettingView(SYSTEM_VOLUME);\r
+ if (p_SoundAndVibrationVolumeSettingView == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!");\r
+ return nullptr;\r
+ }\r
+ }\r
+ if (SystemVolumeScrollView == nullptr)\r
+ {\r
+ SystemVolumeScrollView = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess();\r
+ if (SystemVolumeScrollView == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::SystemVolumeScrollView is nullptr!");\r
+ return nullptr;\r
+ }\r
+ }\r
+\r
+ return SystemVolumeScrollView;\r
+ }\r
+\r
+ void SystemVolumeView::OnStart()\r
+ {\r
+ GetRootContainer()->SetTouchable(true);\r
+ GetRootContainer()->SetDraggable(true);\r
+ GetRootContainer()->SetOnDragListener(presenter_);\r
+\r
+ if (!initViewStatus)\r
+ {\r
+ SystemVolumeViewInit();\r
+ initViewStatus = true;\r
+ }\r
+ UpdateSystemVolumeSliderValue();\r
+ AddViewToRootContainer(SystemVolumeScrollView);\r
+\r
+ return;\r
+ }\r
+\r
+ // 更新系统音量条的值\r
+ bool SystemVolumeView::UpdateSystemVolumeSliderValue(void)\r
+ {\r
+ if (p_SoundAndVibrationVolumeSettingView == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!");\r
+ return false;\r
+ }\r
+ int SystemVolume = uapi_systemVolumeGet();\r
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolume = %d", SystemVolume);\r
+ p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(SystemVolume);\r
+\r
+ return true;\r
+ }\r
+}\r
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-22 14:35:22
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2025-02-25 15:09:34
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/VibrationModeView.cpp
+ */
+#include "soundandvibration/include/VibrationModeView.h"
+#include "soundandvibration/include/SoundAndVibrationPresenter.h"
+#include "wearable_log.h"
+#include "ConfigModel.h"
+#include "ui_resource_string.h"
+#include <UiConfig.h>
+namespace OHOS
+{
+
+ static constexpr const float ROTATEFACTOR = 1.0;
+
+ static VibrationModeView *g_pVibrationModeView{nullptr};
+
+ VibrationModeView::VibrationModeView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VibrationModeView::VibrationModeView");
+ g_pVibrationModeView = this;
+ }
+
+ VibrationModeView::~VibrationModeView()
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VibrationModeView::~VibrationModeView");
+ ClearAll();
+ g_pVibrationModeView = nullptr;
+ }
+
+ VibrationModeView *VibrationModeView::GetInstance()
+ {
+ return g_pVibrationModeView;
+ }
+
+ void VibrationModeView::ClearAll()
+ {
+ if (scrollView != nullptr)
+ {
+ scrollView->RemoveAll();
+
+ if (Title != nullptr)
+ {
+ delete Title;
+ Title = nullptr;
+ }
+
+ if (VibrationModePicker != nullptr)
+ {
+ delete VibrationModePicker;
+ VibrationModePicker = nullptr;
+ }
+
+ if (VibrationModeLabelButton != nullptr)
+ {
+ delete VibrationModeLabelButton;
+ VibrationModeLabelButton = nullptr;
+ }
+
+ delete scrollView;
+ scrollView = nullptr;
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VibrationModeView::ClearAll end!!");
+ }
+ }
+
+ UIScrollView *VibrationModeView::VibrationModeViewInit(void)
+ {
+ if (scrollView == nullptr)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VibrationModeView::VibrationModeViewInit");
+ scrollView = new UIScrollView();
+ if (scrollView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationModeView::scrollView is nullptr!");
+ return nullptr;
+ }
+ scrollView->SetPosition(0, 0, 466, 466);
+ scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0);
+ scrollView->SetViewId(VIBRATION_MODE_VIEWID);
+ UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(SoundAndVibrationPresenter::GetInstance());
+ if (dragListener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationPresenter::GetInstance() fail!!");
+ return nullptr;
+ }
+ scrollView->SetOnDragListener(dragListener);
+ /* -------------------------------------------------------------------------- */
+ if (Title == nullptr)
+ {
+ Title = new UILabelExt();
+ if (Title == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationModeView::Title is nullptr!");
+ return nullptr;
+ }
+ }
+ 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_OSCILLATION);
+ Title->SetRollSpeed(23);
+ Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ scrollView->Add(Title);
+ /* -------------------------------------------------------------------------- */
+ if (VibrationModePicker == nullptr)
+ {
+ VibrationModePicker = new UIPicker();
+ if (VibrationModePicker == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationModeView::VibrationModePicker is nullptr!");
+ return nullptr;
+ }
+ }
+ VibrationModePicker->SetPosition(43, 110, 380, 240);
+ VibrationModePicker->SetViewId("VibrationModePicker");
+ VibrationModePicker->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ VibrationModePicker->SetItemHeight(80);
+ VibrationModePicker->SetLoopState(true);
+ VibrationModePicker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 设置普通文本大小
+ VibrationModePicker->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, 35); // 设置高光文本大小
+ VibrationModePicker->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff), Color::GetColorFromRGBA(0x4F, 0xC3, 0x4C, 0xff));
+ /* -------------------------------------------------------------------------- */
+ UIView::OnRotateListener *RotateListener = static_cast<UIView::OnRotateListener *>(SoundAndVibrationPresenter::GetInstance());
+ VibrationModePicker->SetOnRotateListener(RotateListener);
+ // 增加表冠控制
+ VibrationModePicker->SetRotateFactor(ROTATEFACTOR);
+ VibrationModePicker->RequestFocus();
+ /* -------------------------------------------------------------------------- */
+ const char *translations[][4] = {
+ "无", "弱", "中", "强", // 中文
+ "None", "Weak", "Medium", "Strong", // 英语
+ "なし", "弱い", "中間", "強い", // 日语
+ "없음", "약한", "중간", "강한", // 韩语
+ "Ninguno", "Débil", "Medio", "Fuerte", // 西班牙语
+ "ничего", "слабый", "средний", "сильный", // 俄语
+ "nic", "słaby", "średni", "jak", // 克罗地亚语
+ "keiner", "schwach", "mittel", "stark", // 德语
+ "Nenhum", "Fraco", "Médio", "Forte", // 葡萄牙语
+ "aucun", "faible", "moyen", "fort", // 法语
+ "geen", "zwak", "gemiddeld", "sterk", // 荷兰语
+ "nessuno", "debole", "medio", "forte", // 意大利语
+ "nic", "slabý", "střední", "silný", // 捷克语
+ "κανένας", "αδύναμος", "μέτριος", "ισχυρός", // 希腊语
+ "कोई नहीं", "कमजोर", "मध्यम", "मजबूत", // 印地语
+ "tidak ada", "lemah", "sedang", "kuat", // 印尼语
+ "tidak ada", "lemah", "sedang", "kuat", // 马来语
+ "brak", "słaby", "średni", "silny", // 波兰语
+ "ไม่มี", "อ่อนแอ", "กลาง", "แข็งแกร่ง", // 泰语
+ "không", "yếu", "trung bình", "mạnh", // 越南语
+ "ei mitään", "heikko", "keskiverto", "vahva", // 芬兰语
+ "nimic", "slab", "mediu", "puternic", // 罗马尼亚语
+ "hiçbiri", "zayıf", "orta", "güçlü", // 土耳其语
+ "هیچ", "ضعیف", "متوسط", "قوی", // 波斯语
+ "لا شيء", "ضعيف", "متوسط", "قوي", // 阿拉伯语
+ "אֵין", "חַלָשׁ", "בֵּינוֹנִי", "חָזָק", // 希伯来语
+ "нічого", "слабкий", "середній", "сильний", // 乌克兰语
+ "ingen", "svag", "medium", "stark", // 瑞典语
+ "hech", "kam", "o'rtacha", "kuchli", // 乌兹别克语
+ "heç biri", "zəif", "orta", "güclü" // 阿塞拜疆语
+ };
+ int languageid = ConfigModel::GetInstance()->GetLanguage();
+ VibrationModePicker->SetValues(translations[languageid], 4);
+ VibrationModePicker->SetSelected(ConfigModel::GetInstance()->GetVibrationReminder());
+ scrollView->Add(VibrationModePicker);
+ /* -------------------------------------------------------------------------- */
+ if (VibrationModeLabelButton == nullptr)
+ {
+ VibrationModeLabelButton = new UILabelButtonExt();
+ if (VibrationModeLabelButton == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationModeView::VibrationModeLabelButton is nullptr!");
+ return nullptr;
+ }
+ }
+ VibrationModeLabelButton->SetPosition(0, 366, 466, 100);
+ VibrationModeLabelButton->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE);
+ VibrationModeLabelButton->SetTextId(STR_OK); // 确定
+ VibrationModeLabelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ VibrationModeLabelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED);
+ VibrationModeLabelButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+ VibrationModeLabelButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+ UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(SoundAndVibrationPresenter::GetInstance());
+ VibrationModeLabelButton->SetOnClickListener(clickListener);
+ scrollView->Add(VibrationModeLabelButton);
+ }
+ return scrollView;
+ }
+
+ UIScrollView *VibrationModeView::GetVibrationModeScrollView(void)
+ {
+ return scrollView;
+ }
+
+ UILabelButtonExt *VibrationModeView::GetVibrationModeLabelButton(void)
+ {
+ return VibrationModeLabelButton;
+ }
+
+ UIPicker *VibrationModeView::GetVibrationModePicker(void)
+ {
+ return VibrationModePicker;
+ }
+
+ // 更新震动模式选择器的选定项的索引
+ bool VibrationModeView::UpdatePickerSelectIndex(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VibrationModeView::UpdatePickerSelectIndex");
+ if (VibrationModePicker == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationModeView::VibrationModePicker is nullptr!");
+ return false;
+ }
+ VibrationModePicker->SetSelected(ConfigModel::GetInstance()->GetVibrationReminder());
+ VibrationModePicker->Invalidate();
+
+ return true;
+ }
+}
\ No newline at end of file
#include "custom_utils.h"
+#include "record/include/RecordingModelC.h"
#ifdef FD230_650
#include "BluetoothModelC.h"
#include "PhoneServiceC.h"
#include "safemodemanager/include/SafeModeManagerModelC.h"
#include "sleep/include/SleepModelC.h"
#include "player/include/PlayersModelC.h"
-#include "record/include/RecordingModelC.h"
#include "system/include/SystemLogModelC.h"
#else
void custom_setUpListCase(void){}
bool canSyncMusic(uint32_t songSize){return true;}
bool stopPhonePlayingMusic(void){return true;}
-void CheckRecordingSpaceOutC(void){}
#ifdef __cplusplus
}
#endif