From: luozheng <1732036298@qq.com> Date: Thu, 27 Mar 2025 02:06:41 +0000 (+0800) Subject: 声音与震动slice合并提交 X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~387 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=870197298a190f594baf712bcefd38b8e3d25342;p=mirrors%2FFD230.git 声音与震动slice合并提交 --- diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/CallVolumePresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/CallVolumePresenter.h new file mode 100644 index 000000000..e330b9e44 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/CallVolumePresenter.h @@ -0,0 +1,72 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-01-29 16:24:23 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-19 18:58:47 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/CallVolumePresenter.h + */ +#ifndef CALL_VOLUME_PRESENTER_H +#define CALL_VOLUME_PRESENTER_H + +#include "Presenter.h" +#include "CallVolumeView.h" + +namespace OHOS +{ + typedef enum : uint8_t + { + VOLUMEREDUCE = 0, // 声音降低 + VOLUMEADD = 1, // 声音增加 + OTHER = 2, // 其他 + } VolumeStatusChange; + + /* + * @brief 声音进度条的事件监听类 + */ + class VoumeProcessSliderEventListener : public UISlider::UISliderEventListener, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + VoumeProcessSliderEventListener(); + ~VoumeProcessSliderEventListener(); + static VoumeProcessSliderEventListener *GetInstance(void); + void ChangeVolumeValue(uint8_t status, uint8_t value); + void LocalVolumeSet(int16_t sounding); + 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; + + private: + int32_t VolumeValue; // 声音值 + }; + + class CallVolumeView; + class CallVolumePresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UIView::OnDragListener + { + public: + CallVolumePresenter(); + virtual ~CallVolumePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static CallVolumePresenter *GetInstance(); + + 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); + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + bool X_DRAG_FLAG{false}; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/CallVolumeView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/CallVolumeView.h new file mode 100644 index 000000000..8520b0220 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/CallVolumeView.h @@ -0,0 +1,40 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-01-29 15:37:44 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2025-02-24 18:04:04 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/CallVolumeView.h + */ +#ifndef CALL_VOLUME_VIEW_H +#define CALL_VOLUME_VIEW_H + + +#include "View.h" +#include "components/ui_scroll_view.h" +#include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h" +namespace OHOS +{ + + class SoundAndVibrationVolumeSettingView; + class CallVolumePresenter; + class CallVolumeView : public View + { + + public: + CallVolumeView(); + virtual ~CallVolumeView(); + static CallVolumeView *GetInstance(void); + bool UpdateCallVolumeSliderValue(void); + + void OnStart() override; + + private: + void ClearAll(); + UIScrollView *CallVolumeViewInit(void); + UIScrollView *CallVolumeScrollView{nullptr}; + SoundAndVibrationVolumeSettingView *p_SoundAndVibrationVolumeSettingView{nullptr}; + bool initViewStatus{false}; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationModel.h new file mode 100644 index 000000000..0e6985216 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationModel.h @@ -0,0 +1,34 @@ +/* + * @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 diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h new file mode 100644 index 000000000..19c6c8ac9 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h @@ -0,0 +1,51 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-02-19 10:39:08 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-19 14:37:36 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h + */ +#ifndef SOUND_AND_VIBRATION_PRESENTER_H +#define SOUND_AND_VIBRATION_PRESENTER_H + +#include "Presenter.h" +#include "View.h" +#include "SoundAndVibrationView.h" +#include "soundandvibration/include/SoundAndVibrationModel.h" + +namespace OHOS +{ + + class SoundAndVibrationView; + class SoundAndVibrationPresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UICheckBox::OnChangeListener, + public UIView::OnRotateListener, + 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; + bool OnDragEnd(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + bool OnChange(UICheckBox::UICheckBoxState state) override; + bool OnRotate(UIView& view, const RotateEvent& event); + bool OnRotateEnd(UIView& view, const RotateEvent& event); + bool X_DRAG_FLAG{false}; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationView.h new file mode 100644 index 000000000..7922a1c02 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationView.h @@ -0,0 +1,104 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-19 21:03:26 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2025-02-24 17:15:54 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h + */ +#ifndef SOUND_AND_VIBRATION_VIEW_H +#define SOUND_AND_VIBRATION_VIEW_H + + +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label_ext.h" +#include "components/ui_label_button_ext.h" +#include "components/ui_toggle_button.h" +#include "iostream" +#include "soundandvibration/include/VibrationModeView.h" + +namespace OHOS +{ + /* ---------------------------------- 组件ID ---------------------------------- */ + static constexpr const char *SYSTEM_VOLUME_BUTTON = "SystemVolumeButton"; // 系统音量按钮ID + static constexpr const char *CALL_VOLUME_BUTTON = "CallVolumeButton"; // 通话音量按钮ID + static constexpr const char *VIBRATION_REMINDER_BUTTON = "VibrationReminderButton"; // 震动模式按钮ID + static constexpr const char *SILENT_MODE_BUTTON = "SilentModeButton"; // 静音模式按钮ID + typedef enum + { + SOUNDANDVIBRATIONVIEW = 0, // 声音与震动 + VIBRATIONMODEVIEW, // 震动模式 + MAX_SOUNDANDVIBRATIONVIEWID, + } SOUNDANDVIBRATIONVIEWID; + + class SoundAndVibrationPresenter; + class SoundAndVibrationView : public View + { + + public: + struct ButtonConfig + { + int16_t x; + int16_t y; + int16_t w; + int16_t h; + const char *ViewId; + int16_t TextId; + }; + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; + int16_t lineHeigh; + int16_t textId; + uint8_t lineBreakMode; + }; + SoundAndVibrationView(); + virtual ~SoundAndVibrationView(); + static SoundAndVibrationView *GetInstance(void); + bool ChangeSoundAndVibrationView(int16_t thisView); + bool ChangeVibrationModeView(int16_t thisView); + bool ClickFunc(int16_t interface); + bool CheckViewParam(int16_t hideView, int16_t showView); + void ChangeView(int16_t hideView, int16_t showView); + VibrationModeView *GetVibrationModeView(void); + bool UpdateSilentModeSwitchStatus(void); + + void OnStart() override; + + private: + VibrationModeView *vibrationModeView{nullptr}; + + private: + void CreateSoundAndVibrationView(void); + void ClearAll(void); + UILabelButtonExt *SetUpButton_Ext(ButtonConfig &buttonconfig, bool nextImgVisible); + UILabelExt *SetUpLabel_Ext(LabelConfig &labelConfig); + bool InitSoundAndVibrationScrollView(void); + bool InitSoundAndVibrationViewTitleLabel(void); + bool InitSoundAndVibrationButtonView(void); + bool InitSoundAndVibrationToggleButton(void); + + private: + UIScrollView *SoundAndVibrationScrollView[MAX_SOUNDANDVIBRATIONVIEWID]{nullptr}; + UILabelExt *Title{nullptr}; // 标题:“声音与震动” + // UILabelButtonExt *SystemVolumeButton{nullptr}; // 系统音量按钮 + // UILabelButtonExt *CallVolumeButton{nullptr}; // 通话音量按钮 + // UILabelButtonExt *VibrationReminderButton{nullptr}; // 震动提醒按钮 + // UILabelButtonExt *SilentModeButton{nullptr}; // 静音模式按钮 + // UILabelExt *SystemVolumeLabel{nullptr}; // 系统音量标签 + // UILabelExt *CallVolumeLabel{nullptr}; // 通话音量标签 + // UILabelExt *VibrationReminderLabel{nullptr}; // 震动提醒标签 + // UILabelExt *SilentModeLabel{nullptr}; // 静音模式标签 + UILabelButtonExt *buttonPointers[4]{nullptr}; + UILabelExt *labelPointers[4]{nullptr}; + UIToggleButton *SilentModeToggleButton{nullptr}; // 静音模式切换按钮 + bool initViewStatus{false}; + UIImageView *temp{nullptr}; + }; +} // namespace OHOS + +#endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h new file mode 100644 index 000000000..18042a462 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingC.h @@ -0,0 +1,30 @@ +/* + * @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 +#include + + 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 diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h new file mode 100644 index 000000000..76d63fa78 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h @@ -0,0 +1,62 @@ +/* + * @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 +#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> strategyMap; + bool isOnClickSlider{true}; + bool isDragSlider{false}; + bool isRotateSlider{false}; + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h new file mode 100644 index 000000000..162df65a6 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h @@ -0,0 +1,53 @@ +/* + * @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 diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SystemVolumePresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SystemVolumePresenter.h new file mode 100644 index 000000000..40cda0855 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SystemVolumePresenter.h @@ -0,0 +1,45 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-01-29 16:24:30 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-19 17:04:30 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumePresenter.h + */ +#ifndef SYSTEM_VOLUME_PRESENTER_H +#define SYSTEM_VOLUME_PRESENTER_H + +#include "Presenter.h" +#include "View.h" +#include "SystemVolumeView.h" +#include "wearable_log.h" +namespace OHOS +{ + + + class SystemVolumeView; + class SystemVolumePresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UIView::OnDragListener + { + public: + SystemVolumePresenter(); + virtual ~SystemVolumePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SystemVolumePresenter *GetInstance(); + + private: + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event); + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + bool X_DRAG_FLAG{false}; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SystemVolumeView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SystemVolumeView.h new file mode 100644 index 000000000..e2cfeec0a --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/SystemVolumeView.h @@ -0,0 +1,40 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-01-29 15:37:44 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2025-02-24 17:25:58 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumeView.h + */ +#ifndef SYSTEM_VOLUME_VIEW_H +#define SYSTEM_VOLUME_VIEW_H + + +#include "View.h" +#include "components/ui_scroll_view.h" +#include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h" +namespace OHOS +{ + + class SoundAndVibrationVolumeSettingView; + class SystemVolumePresenter; + class SystemVolumeView : public View + { + + public: + SystemVolumeView(); + virtual ~SystemVolumeView(); + static SystemVolumeView *GetInstance(void); + bool UpdateSystemVolumeSliderValue(void); + + void OnStart() override; + + private: + void ClearAll(); + UIScrollView *SystemVolumeViewInit(void); + UIScrollView *SystemVolumeScrollView{nullptr}; + SoundAndVibrationVolumeSettingView *p_SoundAndVibrationVolumeSettingView{nullptr}; + bool initViewStatus{false}; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/VibrationModeView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/VibrationModeView.h new file mode 100644 index 000000000..d92b773f0 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/include/VibrationModeView.h @@ -0,0 +1,41 @@ +/* + * @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 diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/CallVolumePresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/CallVolumePresenter.cpp new file mode 100644 index 000000000..752bf9108 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/CallVolumePresenter.cpp @@ -0,0 +1,110 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-30 09:14:38 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-19 18:58:32 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/CallVolumePresenter.cpp + */ +#include "AppViewIDs.h" +#include "components/ui_label_ext.h" +#include "ui_resource_string.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "soundandvibration/include/CallVolumePresenter.h" +#include "common/key_code.h" +#include "custom_utils.h" +#include +#include +#include "NativeRegisterManager.h" +// 系统音量 +namespace OHOS +{ + REGIST_SLICE(VIEW_CALL_VOLUME, CallVolumeView, CallVolumePresenter); + // 当前Presenter属性实例化的内存指针 + static CallVolumePresenter *g_pCallVolumePresenter = nullptr; + + CallVolumePresenter::CallVolumePresenter() + { + + g_pCallVolumePresenter = this; + } + + CallVolumePresenter::~CallVolumePresenter() + { + + g_pCallVolumePresenter = nullptr; + } + + CallVolumePresenter *CallVolumePresenter::GetInstance() + { + + return g_pCallVolumePresenter; + } + + void CallVolumePresenter::OnStart() + { + + } + + void CallVolumePresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void CallVolumePresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void CallVolumePresenter::OnStop(void) + { + + } + + bool CallVolumePresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumePresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + CallVolumePresenter::X_DRAG_FLAG = true; + } + return true; + } + + bool CallVolumePresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumePresenter::OnDragEnd"); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && CallVolumePresenter::X_DRAG_FLAG) + { + NativeAbility::GetInstance().Back(); + CallVolumePresenter::X_DRAG_FLAG = false; + } + return true; + } + + bool CallVolumePresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumePresenter::OnKeyAct"); + uint16 keyID = event.GetKeyId(); + uint16 keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(); + } + return true; + } + + bool CallVolumePresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } + +} diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/CallVolumeView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/CallVolumeView.cpp new file mode 100644 index 000000000..cf6910abd --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/CallVolumeView.cpp @@ -0,0 +1,102 @@ +#include "soundandvibration/include/CallVolumeView.h" +#include "soundandvibration/include/CallVolumePresenter.h" +#include "wearable_log.h" +#include +#include "phoneservice/include/PhoneAudio.h" +#include "phoneservice/include/PhoneService.h" +#include "ConfigModel.h" +#include +namespace OHOS +{ + + static CallVolumeView *g_pCallVolumeView{nullptr}; + + CallVolumeView::CallVolumeView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumeView::CallVolumeView"); + g_pCallVolumeView = this; + } + + CallVolumeView::~CallVolumeView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumeView::~CallVolumeView"); + ClearAll(); + g_pCallVolumeView = nullptr; + } + + CallVolumeView *CallVolumeView::GetInstance() + { + return g_pCallVolumeView; + } + + void CallVolumeView::ClearAll() + { + if (initViewStatus == true) + { + { + CallVolumeScrollView = nullptr; + } + delete p_SoundAndVibrationVolumeSettingView; + p_SoundAndVibrationVolumeSettingView = nullptr; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumeView::ClearAll end!!"); + } + } + + UIScrollView *CallVolumeView::CallVolumeViewInit(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumeView::CallVolumeViewInit"); + if (p_SoundAndVibrationVolumeSettingView == nullptr) + { + p_SoundAndVibrationVolumeSettingView = new SoundAndVibrationVolumeSettingView(CALL_VOLUME); + if (p_SoundAndVibrationVolumeSettingView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!"); + return nullptr; + } + } + if (CallVolumeScrollView == nullptr) + { + CallVolumeScrollView = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess(); + if (CallVolumeScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::CallVolumeScrollView is nullptr!"); + return nullptr; + } + } + + return CallVolumeScrollView; + } + + void CallVolumeView::OnStart() + { + GetRootContainer()->SetTouchable(true); + GetRootContainer()->SetDraggable(true); + GetRootContainer()->SetOnDragListener(presenter_); + + if (!initViewStatus) + { + CallVolumeViewInit(); + initViewStatus = true; + } + UpdateCallVolumeSliderValue(); + AddViewToRootContainer(CallVolumeScrollView); + + return; + } + + // 更新通话音量条的值 + bool CallVolumeView::UpdateCallVolumeSliderValue(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallVolumeView::UpdateCallVolumeSliderValue"); + if (p_SoundAndVibrationVolumeSettingView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!"); + return false; + } + int callVolume = uapi_callVolumeGet(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolume = %d", callVolume); + p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(callVolume); + + return true; + } +} diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp new file mode 100644 index 000000000..fca259d3a --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp @@ -0,0 +1,118 @@ +/* + * @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(); + } + +} diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp new file mode 100644 index 000000000..9e5914e02 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp @@ -0,0 +1,175 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-02-19 10:39:11 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-11-05 14:42:21 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp + */ + +#include "AppViewIDs.h" +#include "components/ui_label_ext.h" +#include "ui_resource_string.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "soundandvibration/include/SoundAndVibrationPresenter.h" +#include "common/key_code.h" +#include "custom_utils.h" +#include "ConfigModel.h" +#include +#include "soundandvibration/include/SoundAndVibrationVolumeSettingC.h" +#include "UiConfig.h" +#include "vibrator_service.h" +#include "NativeRegisterManager.h" + +namespace OHOS +{ + REGIST_SLICE(VIEW_SOUND_VIBRATION, SoundAndVibrationView, SoundAndVibrationPresenter); + // 当前Presenter属性实例化的内存指针 + static SoundAndVibrationPresenter *g_pSoundAndVibrationPresenter = nullptr; + + SoundAndVibrationPresenter::SoundAndVibrationPresenter() + { + g_pSoundAndVibrationPresenter = this; + } + + SoundAndVibrationPresenter::~SoundAndVibrationPresenter() + { + g_pSoundAndVibrationPresenter = nullptr; + } + + SoundAndVibrationPresenter *SoundAndVibrationPresenter::GetInstance() + { + return g_pSoundAndVibrationPresenter; + } + + void SoundAndVibrationPresenter::OnStart() + { + } + + void SoundAndVibrationPresenter::OnPause(void) + { + Presenter::OnPause(); + } + + void SoundAndVibrationPresenter::OnResume(void) + { + Presenter::OnResume(); + if (view_ == nullptr) + { + return; + } + } + + void SoundAndVibrationPresenter::OnStop(void) + { + } + + bool SoundAndVibrationPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RespiratoryTrainingPresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + SoundAndVibrationPresenter::X_DRAG_FLAG = true; + } + return true; + } + + bool SoundAndVibrationPresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationPresenter::OnDragEnd"); + std::string viewId = view.GetViewId(); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && SoundAndVibrationPresenter::X_DRAG_FLAG) + { + if (viewId == VIBRATION_MODE_VIEWID) // 如果在震动提醒子视图 + { + view_->GetVibrationModeView()->UpdatePickerSelectIndex(); + SoundAndVibrationView::GetInstance()->ChangeView(VIBRATIONMODEVIEW, SOUNDANDVIBRATIONVIEW); + } + else + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + } + SoundAndVibrationPresenter::X_DRAG_FLAG = false; + } + + return true; + } + + bool SoundAndVibrationPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationPresenter::OnKeyAct"); + uint16 keyID = event.GetKeyId(); + uint16 keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + } + return true; + } + + bool SoundAndVibrationPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationPresenter::OnKeyAct"); + if (strcmp(view.GetViewId(), SYSTEM_VOLUME_BUTTON) == 0) + { + NativeAbility::GetInstance().EnterSlice(VIEW_SYSTEM_VOLUME); + } + else if (strcmp(view.GetViewId(), CALL_VOLUME_BUTTON) == 0) + { + NativeAbility::GetInstance().EnterSlice(VIEW_CALL_VOLUME); + } + else if (strcmp(view.GetViewId(), VIBRATION_REMINDER_BUTTON) == 0) + { + view_->ChangeView(SOUNDANDVIBRATIONVIEW, VIBRATIONMODEVIEW); + } + else if ((view_->GetVibrationModeView() != nullptr) && (&view == view_->GetVibrationModeView()->GetVibrationModeLabelButton())) + { + int VibrationMode = view_->GetVibrationModeView()->GetVibrationModePicker()->GetSelected(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "VibrationMode = %d", VibrationMode); + SoundAndVibrationModel::GetInstance()->SetVibrationReminderToggleButtonStaus(VibrationMode); + // uapi_vibrationModeSet(VibrationMode); + ui_api_vibrate_once_func(); + view_->ChangeView(VIBRATIONMODEVIEW, SOUNDANDVIBRATIONVIEW); + } + return true; + } + + bool SoundAndVibrationPresenter::OnChange(UICheckBox::UICheckBoxState state) + { + SoundAndVibrationModel *p_SoundAndVibrationModel = SoundAndVibrationModel::GetInstance(); + switch (state) + { + case UICheckBox::SELECTED: + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SilentMode is enable!"); + p_SoundAndVibrationModel->SetSilentModeToggleButtonStatus(true); + break; + case UICheckBox::UNSELECTED: + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SilentMode is disable!"); + p_SoundAndVibrationModel->SetSilentModeToggleButtonStatus(false); + break; + default: + break; + } + return true; + } + + bool SoundAndVibrationPresenter::OnRotate(UIView &view, const RotateEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } + + bool SoundAndVibrationPresenter::OnRotateEnd(UIView &view, const RotateEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationView.cpp new file mode 100644 index 000000000..e3b7621b3 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationView.cpp @@ -0,0 +1,462 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-02-19 10:39:14 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2025-02-24 17:16:40 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp + */ +#include "soundandvibration/include/SoundAndVibrationView.h" +#include "soundandvibration/include/SoundAndVibrationPresenter.h" +#include "soundandvibration/include/SoundAndVibrationModel.h" +#include "wearable_log.h" +#include "ui_resource_string.h" +#include +/* +按优先级分为 +1.系统音量 +2通话音量 +3.媒体音量 + +震动提醒 +开/关 + +静音模式 +系统音量不受影响 + +*/ + +namespace OHOS +{ + + static SoundAndVibrationView *g_pSoundAndVibrationView{nullptr}; + + SoundAndVibrationView::SoundAndVibrationView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SoundAndVibrationView"); + g_pSoundAndVibrationView = this; + } + + SoundAndVibrationView::~SoundAndVibrationView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::~SoundAndVibrationView"); + ClearAll(); + g_pSoundAndVibrationView = nullptr; + } + + SoundAndVibrationView *SoundAndVibrationView::GetInstance() + { + return g_pSoundAndVibrationView; + } + + void SoundAndVibrationView::ClearAll() + { + if (initViewStatus == true) + { + + if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] != nullptr) + { + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->RemoveAll(); + if (Title != nullptr) + { + delete Title; + Title = nullptr; + } + for (int i = 0; i < 4; i++) + { + if (buttonPointers[i] != nullptr) + { + delete buttonPointers[i]; + buttonPointers[i] = nullptr; + } + if (labelPointers[i] != nullptr) + { + delete labelPointers[i]; + labelPointers[i] = nullptr; + } + } + if (SilentModeToggleButton != nullptr) + { + delete SilentModeToggleButton; + SilentModeToggleButton = nullptr; + } + if (temp != nullptr) + { + delete temp; + temp = nullptr; + } + delete SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]; + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = nullptr; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::ClearAll end!!"); + } + } + if (vibrationModeView != nullptr) + { + delete vibrationModeView; + vibrationModeView = nullptr; + } + for (int i = SOUNDANDVIBRATIONVIEW; i < MAX_SOUNDANDVIBRATIONVIEWID; i++) + { + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = nullptr; + } + } + + /// @brief 声音与震动视图"scrollView"视图初始化 + /// @param void + /// @return true 初始化成功 false 初始化失败 + bool SoundAndVibrationView::InitSoundAndVibrationScrollView(void) + { + if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] == nullptr) + { + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = new UIScrollView(); + if (SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new SoundAndVibrationScrollView[%d] fail!", SOUNDANDVIBRATIONVIEW); + return false; + } + } + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetThrowDrag(true); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetTouchable(true); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetDraggable(true); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetScrollBlankSize(30); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetReboundSize(30); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetDirection(1); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetMaxScrollDistance(1000); // 设置手指抬起屏幕后的最大滚动距离。 + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetSwipeACCLevel(200); /*设置手指抬起屏幕后的补偿距离。*/ + FocusManager::GetInstance()->RequestFocus(SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]); + FocusManager::GetInstance()->RequestFocusByDirection(FOCUS_DIRECTION_UP); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetRotateFactor(1.0); + AddViewToRootContainer(SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]); + + return true; + } + + UILabelExt *SoundAndVibrationView::SetUpLabel_Ext(LabelConfig &labelconfig) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); + label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); + label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); + label->SetTextId(labelconfig.textId); + label->SetLineBreakMode(labelconfig.lineBreakMode); + label->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(23); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); + return label; + } + + /// @brief 声音与震动视图"标题"标签初始化 + /// @param void + /// @return true 初始化成功 false 初始化失败 + bool SoundAndVibrationView::InitSoundAndVibrationViewTitleLabel(void) + { + if (Title == nullptr) + { + Title = new UILabelExt(); + if (Title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Title new fail!"); + return false; + } + } + Title->SetPosition(83, 50, 300, 35); + Title->SetStyle(STYLE_TEXT_FONT, 30); + Title->SetStyle(STYLE_LINE_HEIGHT, 35); + Title->SetTextId(STR_SOUND_AND_VIBRATION); // 声音与震动 + Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + Title->SetRollSpeed(23); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(Title); + /* -------------------------------------------------------------------------- */ + LabelConfig labelConfig; + struct LabelSetup + { + int16_t y; + const int16_t textId; + }; + LabelSetup labelSetups[] = { + {152, STR_SYSTEM_VOLUME}, + {272, STR_CALL_VOLUME}, + {392, STR_VIBRATION_MODE}, + {512, STR_SILENT_MODE}, + }; + // UILabelExt *labelPointers[] = {SystemVolumeLabel, CallVolumeLabel, VibrationReminderLabel, SilentModeLabel}; + for (int i = 0; i < sizeof(labelSetups) / sizeof(labelSetups[0]); ++i) + { + labelConfig = { + .left = 90, + .top = labelSetups[i].y, + .width = 240, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = labelSetups[i].textId, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + if (labelPointers[i] == nullptr) + { + labelPointers[i] = SetUpLabel_Ext(labelConfig); + if (labelPointers[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::labelPointers[%d] new fail!", i); + return false; + } + } + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(labelPointers[i]); + } + return true; + } + + /// @brief 设置按钮 + /// @param button + /// @return true 设置成功,false 失败 + UILabelButtonExt *SoundAndVibrationView::SetUpButton_Ext(ButtonConfig &buttonconfig, bool nextImgVisible) + { + UILabelButtonExt *labelButton = new UILabelButtonExt(); + if (labelButton == nullptr) + { + return nullptr; + } + labelButton->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); + labelButton->SetViewId(buttonconfig.ViewId); + labelButton->SetOnClickListener(presenter_); + labelButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + if (nextImgVisible) + { + labelButton->SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE); + labelButton->SetImagePosition(326, 37); + } + // labelButton->SetTextId(buttonconfig.TextId); + // labelButton->SetAlign(TEXT_ALIGNMENT_LEFT); + // labelButton->SetLabelPosition(47, 0); + // labelButton->SetStyle(STYLE_TEXT_FONT, 30); + // labelButton->SetStyle(STYLE_LINE_HEIGHT, 35); + // labelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + labelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, nextImgVisible ? 0xff000000 : 0xff191919, UIButton::PRESSED); + + return labelButton; + } + /// @brief 声音与震动视图"按钮"初始化 + /// @param void + /// @return true 初始化成功 false 初始化失败 + bool SoundAndVibrationView::InitSoundAndVibrationButtonView(void) + { + struct ButtonSetup + { + int y; + const char *viewId; + bool clickEffect; + }; + + ButtonSetup buttonSetups[] = { + {120, SYSTEM_VOLUME_BUTTON, true}, + {240, CALL_VOLUME_BUTTON, true}, + {360, VIBRATION_REMINDER_BUTTON, true}, + {480, SILENT_MODE_BUTTON, false}, + }; + + // UILabelButtonExt *buttonPointers[] = {SystemVolumeButton, CallVolumeButton, VibrationReminderButton, SilentModeButton}; + + for (int i = 0; i < sizeof(buttonSetups) / sizeof(buttonSetups[0]); ++i) + { + ButtonConfig buttonconfig = { + .x = 43, + .y = buttonSetups[i].y, + .w = 380, + .h = 100, + .ViewId = buttonSetups[i].viewId, + }; + if (buttonPointers[i] == nullptr) + { + buttonPointers[i] = SetUpButton_Ext(buttonconfig, buttonSetups[i].clickEffect); + if (buttonPointers[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Button[%d] new fail!", i); + return false; + } + } + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(buttonPointers[i]); + } + + return true; + } + + bool SoundAndVibrationView::InitSoundAndVibrationToggleButton(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::InitSoundAndVibrationToggleButton"); + if (SilentModeToggleButton == nullptr) + { + SilentModeToggleButton = new UIToggleButton(); + if (SilentModeToggleButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeToggleButton new fail!"); + return false; + } + } + SilentModeToggleButton->SetPosition(298, 505, 100, 50); + SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + SilentModeToggleButton->SetState(SoundAndVibrationModel::GetInstance()->GetSilentModeToggleButtonStatus()); + SilentModeToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE); + SilentModeToggleButton->SetOnChangeListener(presenter_); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(SilentModeToggleButton); + + return true; + } + + void SoundAndVibrationView::CreateSoundAndVibrationView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CreateSoundAndVibrationView"); + if (!InitSoundAndVibrationScrollView() || !InitSoundAndVibrationButtonView() || + !InitSoundAndVibrationViewTitleLabel() || !InitSoundAndVibrationToggleButton()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CreateSoundAndVibrationView fail!!"); + return; + } + /* ------------------- 该组件的使用是为了解决不能单独设置滚动视图底部空白大小问题,用一个不可见组件占位置 ------------------ */ + /* ---------------------------- 因为使用SetScrollBlankSize设置大小后下拉后无法恢复到原位置,有向下偏移 --------------------------- */ + if (temp == nullptr) + { + temp = new UIImageView(); + if (temp == nullptr) + { + return; + } + temp->SetPosition(43, 480 + 120, 380, 40); + temp->SetVisible(false); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(temp); + } + initViewStatus = true; + } + + void SoundAndVibrationView::OnStart() + { + GetRootContainer()->SetTouchable(true); + GetRootContainer()->SetDraggable(true); + GetRootContainer()->SetOnDragListener(presenter_); + + if (!initViewStatus) + { + CreateSoundAndVibrationView(); + } + } + + // 声音与震动界面 + bool SoundAndVibrationView::ChangeSoundAndVibrationView(int16_t thisView) + { + if (SoundAndVibrationScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::ChangeSoundAndVibrationView"); + AddViewToRootContainer(SoundAndVibrationScrollView[thisView]); + } + return true; + } + + // 震动模式界面 + bool SoundAndVibrationView::ChangeVibrationModeView(int16_t thisView) + { + if (SoundAndVibrationScrollView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::ChangeVibrationModeView"); + if (vibrationModeView == nullptr) + { + vibrationModeView = new VibrationModeView(); + if (vibrationModeView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView:: new scrollView[%d] fail", thisView); + return false; + } + } + SoundAndVibrationScrollView[thisView] = vibrationModeView->VibrationModeViewInit(); + AddViewToRootContainer(SoundAndVibrationScrollView[thisView]); + } + return true; + } + + struct SoundAndVibrationViewMapper + { + const int16_t viewId; + bool (SoundAndVibrationView::*func)(int16_t thisView); + }; + + static const SoundAndVibrationViewMapper ViewMapper[] = { + {SOUNDANDVIBRATIONVIEW, &SoundAndVibrationView::ChangeSoundAndVibrationView}, + {VIBRATIONMODEVIEW, &SoundAndVibrationView::ChangeVibrationModeView}, + }; + + bool SoundAndVibrationView::ClickFunc(int16_t interface) + { + int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]); + for (int i = 0; i < funcSize; i++) + { + if (interface == ViewMapper[i].viewId) + { + bool jug = (this->*(ViewMapper[i].func))(interface); + if (jug == false) + { + return false; + } + return true; + } + } + return false; + } + + /*检查传入的两个视图参数 hideView 和 showView 的有效性。*/ + bool SoundAndVibrationView::CheckViewParam(int16_t hideView, int16_t showView) + { + if (showView < 0 || showView >= MAX_SOUNDANDVIBRATIONVIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CheckViewParam showView err."); + return false; + } + + if (hideView < 0 || hideView > MAX_SOUNDANDVIBRATIONVIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CheckViewParam hideView err."); + return false; + } + + return true; + } + + void SoundAndVibrationView::ChangeView(int16_t hideView, int16_t showView) + { + if (!CheckViewParam(hideView, showView)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CheckViewParam failed."); + return; + } + SoundAndVibrationScrollView[hideView]->SetVisible(false); + ClickFunc(showView); + SoundAndVibrationScrollView[showView]->SetVisible(true); + Draw(); + } + /* -------------------------------------------------------------------------- */ + + VibrationModeView *SoundAndVibrationView::GetVibrationModeView(void) + { + return vibrationModeView; + } + + // 更新静音模式开关状态 + bool SoundAndVibrationView::UpdateSilentModeSwitchStatus(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::UpdateSilentModeSwitchStatus"); + if (SilentModeToggleButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeToggleButton is nullptr!!"); + return false; + } + SilentModeToggleButton->SetState(SoundAndVibrationModel::GetInstance()->GetSilentModeToggleButtonStatus()); + SilentModeToggleButton->Invalidate(); + + return true; + } +} diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp new file mode 100644 index 000000000..4f0920280 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp @@ -0,0 +1,259 @@ +/* + * @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 +#include +#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 + +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(); + strategyMap[VOLUMEADD] = std::make_shared(); + strategyMap[OTHER] = std::make_shared(); + 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(&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(&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(&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 diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp new file mode 100644 index 000000000..ca30ca5cb --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp @@ -0,0 +1,150 @@ +#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 diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SystemVolumePresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SystemVolumePresenter.cpp new file mode 100644 index 000000000..dbceca14c --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SystemVolumePresenter.cpp @@ -0,0 +1,112 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-30 09:14:38 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-19 18:58:05 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumePresenter.cpp + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +#include "AppViewIDs.h" +#include "components/ui_label_ext.h" +#include "ui_resource_string.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "soundandvibration/include/SystemVolumePresenter.h" + +#include "common/key_code.h" +#include "custom_utils.h" +#include +#include +#include "NativeRegisterManager.h" +// 系统音量 +namespace OHOS +{ + REGIST_SLICE(VIEW_SYSTEM_VOLUME, SystemVolumeView, SystemVolumePresenter); + // 当前Presenter属性实例化的内存指针 + static SystemVolumePresenter *g_pSystemVolumePresenter = nullptr; + + SystemVolumePresenter::SystemVolumePresenter() + { + + g_pSystemVolumePresenter = this; + } + + SystemVolumePresenter::~SystemVolumePresenter() + { + + g_pSystemVolumePresenter = nullptr; + } + + SystemVolumePresenter *SystemVolumePresenter::GetInstance() + { + + return g_pSystemVolumePresenter; + } + + void SystemVolumePresenter::OnStart() + { + + } + + void SystemVolumePresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void SystemVolumePresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SystemVolumePresenter::OnStop(void) + { + + } + + bool SystemVolumePresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumePresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + SystemVolumePresenter::X_DRAG_FLAG = true; + } + return true; + } + + bool SystemVolumePresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumePresenter::OnDragEnd"); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && SystemVolumePresenter::X_DRAG_FLAG) + { + NativeAbility::GetInstance().Back(); + SystemVolumePresenter::X_DRAG_FLAG = false; + } + return true; + } + + bool SystemVolumePresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumePresenter::OnKeyAct"); + uint16 keyID = event.GetKeyId(); + uint16 keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(); + } + return true; + } + + bool SystemVolumePresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } +} diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SystemVolumeView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SystemVolumeView.cpp new file mode 100644 index 000000000..541b56616 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/SystemVolumeView.cpp @@ -0,0 +1,112 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-12 11:44:04 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2025-02-24 17:26:02 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp + */ +#include "soundandvibration/include/SystemVolumeView.h" +#include "soundandvibration/include/SystemVolumePresenter.h" +#include "wearable_log.h" +#include +#include "ConfigModel.h" +#include +/* +系统音量: +通话,提醒,查找手表的音量 +*/ + +namespace OHOS +{ + + static SystemVolumeView *g_pSystemVolumeView{nullptr}; + + SystemVolumeView::SystemVolumeView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::SystemVolumeView"); + g_pSystemVolumeView = this; + } + + SystemVolumeView::~SystemVolumeView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::~SystemVolumeView"); + ClearAll(); + g_pSystemVolumeView = nullptr; + } + + SystemVolumeView *SystemVolumeView::GetInstance() + { + return g_pSystemVolumeView; + } + + void SystemVolumeView::ClearAll() + { + if (initViewStatus == true) + { + if (SystemVolumeScrollView != nullptr) + { + SystemVolumeScrollView = nullptr; + } + delete p_SoundAndVibrationVolumeSettingView; + p_SoundAndVibrationVolumeSettingView = nullptr; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::ClearAll end!!"); + } + } + + UIScrollView *SystemVolumeView::SystemVolumeViewInit(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::SystemVolumeViewInit"); + if (p_SoundAndVibrationVolumeSettingView == nullptr) + { + p_SoundAndVibrationVolumeSettingView = new SoundAndVibrationVolumeSettingView(SYSTEM_VOLUME); + if (p_SoundAndVibrationVolumeSettingView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!"); + return nullptr; + } + } + if (SystemVolumeScrollView == nullptr) + { + SystemVolumeScrollView = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess(); + if (SystemVolumeScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::SystemVolumeScrollView is nullptr!"); + return nullptr; + } + } + + return SystemVolumeScrollView; + } + + void SystemVolumeView::OnStart() + { + GetRootContainer()->SetTouchable(true); + GetRootContainer()->SetDraggable(true); + GetRootContainer()->SetOnDragListener(presenter_); + + if (!initViewStatus) + { + SystemVolumeViewInit(); + initViewStatus = true; + } + UpdateSystemVolumeSliderValue(); + AddViewToRootContainer(SystemVolumeScrollView); + + return; + } + + // 更新系统音量条的值 + bool SystemVolumeView::UpdateSystemVolumeSliderValue(void) + { + if (p_SoundAndVibrationVolumeSettingView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!"); + return false; + } + int SystemVolume = uapi_systemVolumeGet(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemVolume = %d", SystemVolume); + p_SoundAndVibrationVolumeSettingView->GetVolumeProcess()->SetValue(SystemVolume); + + return true; + } +} diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/VibrationModeView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/VibrationModeView.cpp new file mode 100644 index 000000000..63000a79d --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/soundandvibration/src/VibrationModeView.cpp @@ -0,0 +1,223 @@ +/* + * @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 +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(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(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(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 diff --git a/code/sdk/zhihui/utils/custom_fileoperate_service.c b/code/sdk/zhihui/utils/custom_fileoperate_service.c index 16f8142f3..dfa485bf2 100644 --- a/code/sdk/zhihui/utils/custom_fileoperate_service.c +++ b/code/sdk/zhihui/utils/custom_fileoperate_service.c @@ -31,6 +31,7 @@ #include "custom_utils.h" +#include "record/include/RecordingModelC.h" #ifdef FD230_650 #include "BluetoothModelC.h" #include "PhoneServiceC.h" @@ -38,7 +39,6 @@ #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 @@ -75,7 +75,6 @@ void stopPlayingMusic(void){} void custom_setUpListCase(void){} bool canSyncMusic(uint32_t songSize){return true;} bool stopPhonePlayingMusic(void){return true;} -void CheckRecordingSpaceOutC(void){} #ifdef __cplusplus } #endif