From 528af8245525d3c3608f3b1d9c2648601c5c4031 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Thu, 18 Apr 2024 12:45:56 +0000 Subject: [PATCH] Merge #46 into xts_origin from refs/changes/46/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/46/head: (4 commits squashed) - 添加抬腕亮屏功能 - Merge branch 'xts_origin' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into xts_origin - 修改声音与震动视图 - 修改天气视图:解决天气子地区显示错误问题 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/46 --- .../nativeui/config/include/ConfigModel.h | 15 +- .../nativeui/config/include/ConfigModelC.h | 6 +- .../nativeui/config/src/ConfigModel.cpp | 30 ++- .../include/DisplayBrightnessModel.h | 12 +- .../include/DisplayBrightnessPresenter.h | 4 +- .../src/DisplayBrightnessModel.cpp | 21 +- .../src/DisplayBrightnessPresent.cpp | 8 +- .../src/DisplayBrightnessView.cpp | 14 +- .../producttest/src/testluminance.cpp | 2 +- .../include/SoundAndVibrationPresenter.h | 25 +- .../include/SoundAndVibrationView.h | 47 ++-- .../src/SoundAndVibrationModel.cpp | 19 +- .../src/SoundAndVibrationPresenter.cpp | 83 ++----- .../src/SoundAndVibrationView.cpp | 220 +++++++----------- .../nativeui/weather/src/WeatherModel.cpp | 4 +- .../drivers/peripheral/utils/custom_utils.c | 1 + 16 files changed, 184 insertions(+), 327 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h index ddba642a2..bd01055d2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h @@ -105,14 +105,6 @@ namespace OHOS /* --------------------------------自定义封装 set与get方法 ------------------------------- */ - - bool GetRaiseToWake(void); - - unsigned GetScreenBrightnessValue(void); - - void SetScreenDuration(unsigned int value); - unsigned int GetScreenDuration(void); - bool GetClassicBlueToothState(void); void SetLanguage(int languageid); @@ -140,8 +132,15 @@ namespace OHOS void SetDnotdisturb(bool state); bool GetDnotdisturb(void); + /* ----------------------------- 屏幕与亮度相关set与get ----------------------------- */ void SetBrightness(int level); int GetBrightness(void); + + void SetScreenDuration(unsigned int value); + unsigned int GetScreenDuration(void); + + void SetRaiseToWake(bool value); + bool GetRaiseToWake(void); // -------------------------------------------------------------------------- */ private: configmodel_item configmodel_item_key_name[CONFIGMODEL_ITEM_MAX] = diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h index 9589a2997..dbabfb475 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h +++ b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-17 09:32:03 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-17 14:52:37 + * @LastEditTime: 2024-04-18 15:44:00 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h */ #ifndef _CONFIG_MODEL_C_H_ @@ -41,6 +41,10 @@ void initScreenBrightness(void); */ void initializeScreenDuration(void); +/* + * @brief 初始化抬腕亮屏 + */ +void initializeRaiseToWake(void); #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp index 87c02022b..5b6dd0460 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp @@ -488,14 +488,20 @@ namespace OHOS /* -------------------------------- set与get方法 ------------------------------- */ - bool ConfigModel::GetRaiseToWake(void) + /* + * @brief 设置抬腕亮屏是否开启 + */ + void ConfigModel::SetRaiseToWake(bool value) { - return get_configData_bool(CONFIGMODEL_ITEM_RAISE_TO_WAKE); + set_condigData_Bool(CONFIGMODEL_ITEM_RAISE_TO_WAKE,value); } - /// @brief 获取亮度值 - unsigned ConfigModel::GetScreenBrightnessValue(void) + + /* + * @brief 获取抬腕亮屏是否开启 + */ + bool ConfigModel::GetRaiseToWake(void) { - return get_configData_int(CONFIGMODEL_ITEM_SCREEN_BRIGHTNESS_VALUE) ; + return get_configData_bool(CONFIGMODEL_ITEM_RAISE_TO_WAKE); } /* @@ -750,6 +756,20 @@ void initializeScreenDuration(void) unsigned int time = OHOS::ConfigModel::GetInstance()->GetScreenDuration(); uapi_setScreenDuration(time); } + +void initializeRaiseToWake(void) +{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "initializeRaiseToWake"); + bool isOpen = OHOS::ConfigModel::GetInstance()->GetRaiseToWake(); + if(isOpen == true) + { + uapi_take_to_wake(1); + } + else + { + uapi_take_to_wake(2); + } +} #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessModel.h b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessModel.h index 015ef9dea..06c5865aa 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessModel.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-12 20:11:04 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-18 10:23:37 + * @LastEditTime: 2024-04-18 15:36:31 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessModel.h */ #ifndef DISPLAY_BRIGHTNESS_MODEL_H_ @@ -15,21 +15,17 @@ namespace OHOS { public: static DisplayBrightnessModel *GetInstance(void); - void SetRaiseToBrightnessCheckBoxButtonStatus(bool value); bool RaiseToBrightnessCheckBoxButtonStatusInit(void); bool ScreenDurationRadioButtonSlectStatusInit(void); bool SelectScreenDurationLabelInit(void); void SetScreenDurationTime(unsigned int time); unsigned int GetScreenDurationTime(void); + private: DisplayBrightnessModel(); - DisplayBrightnessModel(const DisplayBrightnessModel &); - DisplayBrightnessModel &operator=(const DisplayBrightnessModel &); + DisplayBrightnessModel(const DisplayBrightnessModel &) = delete; + DisplayBrightnessModel &operator=(const DisplayBrightnessModel &) = delete; virtual ~DisplayBrightnessModel(); - - private: - bool RaiseToBrightnessCheckBoxButtonState{false}; // 抬腕按钮状态 ,默认补选中 - unsigned int ScreenDurationTime{10000}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h index bf3a59fc4..445a202be 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-02-18 09:10:05 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-18 10:59:11 + * @LastEditTime: 2024-04-18 15:53:53 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h */ #ifndef _DISPLAY_BRIGHTNESS_PRESENTER_H @@ -15,6 +15,8 @@ namespace OHOS { + static constexpr uint8_t WRIST_RAISE_TO_WAKE_ENABLED = 1; + static constexpr uint8_t WRIST_RAISE_TO_WAKE_DISENABLED = 2; typedef enum { DISPLAYBRIGHTNESSVIEW = 0, // 屏幕与亮度视图(slice) diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp index f58cbcad8..6cf09d50b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp @@ -2,21 +2,19 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-12 20:11:04 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-18 10:55:38 + * @LastEditTime: 2024-04-18 15:34:22 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp */ #include "displaybrightness/include/DisplayBrightnessModel.h" #include "displaybrightness/include/DisplayBrightnessPresenter.h" #include "wearable_log.h" -#include "cat1_ctl.h" +#include "config/include/ConfigModel.h" namespace OHOS { DisplayBrightnessModel::DisplayBrightnessModel() { - ConfigModel *p_ConfigModel = ConfigModel::GetInstance(); - RaiseToBrightnessCheckBoxButtonState = p_ConfigModel->GetRaiseToWake(); } DisplayBrightnessModel::~DisplayBrightnessModel() {} @@ -27,16 +25,11 @@ namespace OHOS return &instance; } - /// @brief 设置抬腕亮屏按钮状态 - /// @param value true 开启 false 关闭 - void DisplayBrightnessModel::SetRaiseToBrightnessCheckBoxButtonStatus(bool value) - { - RaiseToBrightnessCheckBoxButtonState = value; - } + - /// @brief 显示与亮度及其子视图中的组件状态初始化 - /// @param value true 开启 false 关闭 - /// @return true 初始化成功 false 初始化失败 + /* + * @brief 抬腕亮屏按钮状态设置 + */ bool DisplayBrightnessModel::RaiseToBrightnessCheckBoxButtonStatusInit(void) { DisplayBrightnessPresenter *displayBrightnessPresent = DisplayBrightnessPresenter::GetInstance(); @@ -45,7 +38,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessViewAndSubViewComponentsStatusInit DisplayBrightnessPresenter GetInstance fail"); return false; } - displayBrightnessPresent->SetRaiseToBrightnessState(RaiseToBrightnessCheckBoxButtonState); // 抬腕按钮的状态 + displayBrightnessPresent->SetRaiseToBrightnessState(ConfigModel::GetInstance()->GetRaiseToWake()); // 抬腕按钮的状态 return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp index 442efe7b0..f9b378212 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 09:14:38 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-18 11:16:04 + * @LastEditTime: 2024-04-18 15:54:44 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp */ #include "AppViewIDs.h" @@ -19,6 +19,7 @@ #include #include "map" #include "iostream" +#include "config/include/ConfigModel.h" namespace OHOS { // 当前Presenter属性实例化的内存指针 @@ -55,7 +56,6 @@ namespace OHOS if (value != false) { displayBrightnessView->SetRaiseToBrightnessCheckBoxButtonState(UICheckBox::UICheckBoxState::SELECTED); - DisplayBrightnessModel::GetInstance()->SetRaiseToBrightnessCheckBoxButtonStatus(false); // 将Model层保存的状态清除 } } @@ -201,9 +201,13 @@ namespace OHOS { case UICheckBox::SELECTED: WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Raise to Wake switched on!"); + uapi_take_to_wake(WRIST_RAISE_TO_WAKE_ENABLED); + ConfigModel::GetInstance()->SetRaiseToWake(true); break; case UICheckBox::UNSELECTED: WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Raise to Wake switched off!"); + uapi_take_to_wake(WRIST_RAISE_TO_WAKE_DISENABLED); + ConfigModel::GetInstance()->SetRaiseToWake(false); break; default: break; diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp index 56872bf9e..35e43a755 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp @@ -60,18 +60,6 @@ namespace OHOS delete RaiseToBrightnessImage; RaiseToBrightnessImage = nullptr; - state = GetRaiseToBrightnessCheckBoxButtonState(); - if (state == UICheckBox::UICheckBoxState::SELECTED) - { - DisplayBrightnessModel::GetInstance()->SetRaiseToBrightnessCheckBoxButtonStatus(true); - ConfigModel::GetInstance()->set_condigData_Bool(ConfigModel::ConfigItem::CONFIGMODEL_ITEM_RAISE_TO_WAKE, true); - } - else - { - DisplayBrightnessModel::GetInstance()->SetRaiseToBrightnessCheckBoxButtonStatus(false); - ConfigModel::GetInstance()->set_condigData_Bool(ConfigModel::ConfigItem::CONFIGMODEL_ITEM_RAISE_TO_WAKE, false); - } - delete RaiseToBrightnessCheckBoxButton; RaiseToBrightnessCheckBoxButton = nullptr; @@ -462,7 +450,7 @@ namespace OHOS return true; } - // 3.切换到“亮屏时长”视图 + // 2.切换到“亮屏时长”视图 bool DisplayBrightnessView::ChangeScreenDurationView(int16_t thisView) { if (DisplayBrightnessScrollView[thisView] == nullptr) diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testluminance.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testluminance.cpp index ef0b87d9e..d4df051af 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testluminance.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testluminance.cpp @@ -94,7 +94,7 @@ namespace OHOS BrightnessControlViewSlider->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff); BrightnessControlViewSlider->SetDraggable(true); ConfigModel *p_ConfigModel = ConfigModel::GetInstance(); - unsigned int value = p_ConfigModel->GetScreenBrightnessValue(); + unsigned int value = p_ConfigModel->GetBrightness(); BrightnessControlViewSlider->SetValue(value); diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h index 8869a90a8..4440804e0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationPresenter.h @@ -2,39 +2,25 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-02-19 10:39:08 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-01 19:33:48 + * @LastEditTime: 2024-04-18 18:05:12 * @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 "KeyInputListener.h" #include "soundandvibration/include/SoundAndVibrationModel.h" namespace OHOS { - class SoundAndVibrationViewOnChangeListener : public UICheckBox::OnChangeListener - { - public: - SoundAndVibrationViewOnChangeListener(UIView *view) - { - view_ = view; - } - - ~SoundAndVibrationViewOnChangeListener() {} - - bool OnChange(UICheckBox::UICheckBoxState state) override; - - private: - UIView *view_{nullptr}; - }; class SoundAndVibrationView; class SoundAndVibrationPresenter : public Presenter, public UIView::OnClickListener, public RootView::OnKeyActListener, + public UICheckBox::OnChangeListener, public UIView::OnDragListener { public: @@ -47,7 +33,6 @@ namespace OHOS void OnStop() override; static SoundAndVibrationPresenter *GetInstance(); - void VibrationReminderToggleButtonStateSetting(bool value); void SilentModeToggleButtonStateSetting(bool value); private: @@ -56,9 +41,7 @@ namespace OHOS bool OnDrag(UIView &view, const DragEvent &event) override; bool OnDragEnd(UIView &view, const DragEvent &event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 - - private: - UIView *view_{nullptr}; + bool OnChange(UICheckBox::UICheckBoxState state) override; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h index d09295dd4..ad40dc3d4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h @@ -9,6 +9,7 @@ #include "components/ui_button.h" #include "components/ui_image_view.h" #include "components/ui_toggle_button.h" +#include "iostream" namespace OHOS { /* ----------------------------------- 图片 ----------------------------------- */ @@ -16,9 +17,9 @@ namespace OHOS static constexpr const char *PNG_CALL_VOLUME_IMAGE = "/user/res/SoundAndVibration/CALL_VOLUME.bin"; // 通话音量图片 static constexpr const char *PNG_MEDIA_VOLUME_IMAGE = "/user/res/SoundAndVibration/MEDIA_VOLUME.bin"; // 媒体音量图片 /* ---------------------------------- 组件ID ---------------------------------- */ - static const char *SYSTEM_VOLUME_BUTTON = "SystemVolumeButton"; // 系统音量按钮ID - static const char *CALL_VOLUME_BUTTON = "CallVolumeButton"; // 通话音量按钮ID - static const char *MEDIA_VOLUME_BUTTON = "MediaVolumeButton"; // 媒体音量按钮ID + static const char *SYSTEM_VOLUME_BUTTON = "SystemVolumeButton"; // 系统音量按钮ID + static const char *CALL_VOLUME_BUTTON = "CallVolumeButton"; // 通话音量按钮ID + static const char *VIBRATION_REMINDER_BUTTON = "VibrationReminderButton"; // 震动模式按钮ID class SoundAndVibrationPresenter; class SoundAndVibrationView : public View { @@ -40,7 +41,7 @@ namespace OHOS int16_t height; int16_t fontSize; // 字体大小 int16_t lineHeigh; // 行高 - const char *text; // 文本 + std::string text; // 文本 uint8_t lineBreakMode; // 断行模式。 }; struct ButtonConfig @@ -51,18 +52,14 @@ namespace OHOS int16_t h; const char *ViewId; int64_t BackgroundColorValue; // 按钮背景颜色值 - int64_t TriggeredBackgroundColorValue; // 点击按钮触发的背景颜色值 }; SoundAndVibrationView(); virtual ~SoundAndVibrationView(); static SoundAndVibrationView *GetInstance(void); - void SetVibrationReminderToggleButtonState(bool value); void SetSilentModeToggleButtonState(bool value); - bool GetVibrationReminderToggleButtonState(void); bool GetSilentModeToggleButtonState(void); - UIToggleButton * GetVibrationReminderToggleButton(); - UIToggleButton * GetSilentModeToggleButton(); + UIToggleButton *GetSilentModeToggleButton(); void OnStart() override; void OnSetUpView() override; @@ -74,7 +71,7 @@ namespace OHOS void ClearAll(void); UIButton *SetUpButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener); UIImageView *SetUpImageVIew(ImageConfig &imageconfig); - UILabel *SetUpLabel(LabelConfig &labelConfig); + UILabelExt *SetUpLabel(LabelConfig &labelConfig); bool InitSoundAndVibrationScrollView(void); bool InitSoundAndVibrationViewTitleLabel(void); bool InitSoundAndVibrationButtonView(void); @@ -85,23 +82,19 @@ namespace OHOS private: UIScrollView *SoundAndVibrationScrollView{nullptr}; - UILabel *Title{nullptr}; // 标题:“声音与震动” - UIButton *SystemVolumeButton{nullptr}; // 系统音量按钮 - UIButton *CallVolumeButton{nullptr}; // 通话音量按钮 - UIButton *MediaVolumeButton{nullptr}; // 媒体音量按钮 - UILabel *SystemVolumeLabel{nullptr}; // 系统音量标签 - UILabel *CallVolumeLabel{nullptr}; // 通话音量标签 - UILabel *MediaVolumeLabel{nullptr}; // 媒体音量标签 - UILabel *VibrationReminderLabel{nullptr}; // 震动提醒标签 - UILabel *SilentModeLabel{nullptr}; // 静音模式标签 - UILabel *reminder[4]{nullptr}; // 提示标签 - UIImageView *nextImageView[3]{nullptr}; // 箭头图片 - UIImageView *VibrationReminderImageView{nullptr}; // - UIImageView *SilentModeImageView{nullptr}; // - UIToggleButton *VibrationReminderToggleButton{nullptr}; // 震动提醒切换按钮 - UIToggleButton *SilentModeToggleButton{nullptr}; // 静音模式切换按钮 - UICheckBox::OnChangeListener *VibrationReminderToggleButtonChangeListener{nullptr}; - UICheckBox::OnChangeListener *SilentModeToggleButtonChangeListener{nullptr}; + UILabelExt *Title{nullptr}; // 标题:“声音与震动” + UIButton *SystemVolumeButton{nullptr}; // 系统音量按钮 + UIButton *CallVolumeButton{nullptr}; // 通话音量按钮 + UIButton *VibrationReminderButton{nullptr}; // 震动提醒按钮 + UILabelExt *SystemVolumeLabel{nullptr}; // 系统音量标签 + UILabelExt *CallVolumeLabel{nullptr}; // 通话音量标签 + UILabelExt *VibrationReminderLabel{nullptr}; // 震动提醒标签 + UILabelExt *SilentModeLabel{nullptr}; // 静音模式标签 + // UILabelExt *reminder[4]{nullptr}; // 提示标签 + UIImageView *nextImageView[3]{nullptr}; // 箭头图片 + UIImageView *VibrationReminderImageView{nullptr}; // + UIImageView *SilentModeImageView{nullptr}; // + UIToggleButton *SilentModeToggleButton{nullptr}; // 静音模式切换按钮 bool initViewStatus{false}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp index 98e123998..1513db2bd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-02-23 09:17:00 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-01 18:19:45 + * @LastEditTime: 2024-04-18 18:03:36 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationModel.cpp */ #include "soundandvibration/include/SoundAndVibrationModel.h" @@ -34,26 +34,11 @@ namespace OHOS VibrationReminderToggleButtonState = value; } - /// @brief “震动提醒”切换按钮状态初始化 - /// @param void - /// @return true 初始化成功 false 初始化失败 - bool SoundAndVibrationModel::VibrationReminderToggleButtonStatusInit(void) - { - SoundAndVibrationPresenter *p_SoundAndVibrationPresenter = SoundAndVibrationPresenter::GetInstance(); - if (p_SoundAndVibrationPresenter == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationReminderToggleButtonStatusInit SoundAndVibrationPresenter GetInstance fail!"); - return false; - } - p_SoundAndVibrationPresenter->VibrationReminderToggleButtonStateSetting(VibrationReminderToggleButtonState); - return true; - } - /// @brief 设置“静音模式”是否开启 /// @param value void SoundAndVibrationModel::SetSilentModeToggleButtonStatus(bool value) { - SilentModeToggleButtonState = value; + ConfigModel::GetInstance()->SetSilentMode(value); } /// @brief “静音模式”切换按钮状态初始化 diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp index 062f1e74a..020791821 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp @@ -2,13 +2,13 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-02-19 10:39:11 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-02 09:14:23 + * @LastEditTime: 2024-04-18 18:08:44 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp */ #include "AppViewIDs.h" #include "components/ui_label_ext.h" -#include"language/font/ui_resource_string.h" +#include "language/font/ui_resource_string.h" #include "NativeAbility.h" #include "graphic_math.h" #include "string.h" @@ -16,6 +16,7 @@ #include "common/key_code.h" #include "custom_utils.h" #include "config/include/ConfigModel.h" +#include namespace OHOS { @@ -41,22 +42,6 @@ namespace OHOS return g_pSoundAndVibrationPresenter; } - /// @brief "震动提醒"按钮状态设置 - /// @param value true 开启 false 关闭 - void SoundAndVibrationPresenter::VibrationReminderToggleButtonStateSetting(bool value) - { - SoundAndVibrationView *p_SoundAndVibrationView = SoundAndVibrationView::GetInstance(); - if (p_SoundAndVibrationView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationReminderToggleButtonStateSetting SoundAndVibrationView GetInstance fail!"); - return; - } - if (value != false) - { - p_SoundAndVibrationView->SetVibrationReminderToggleButtonState(true); - } - } - /// @brief "静音模式"按钮状态设置 /// @param value true 开启 false 关闭 void SoundAndVibrationPresenter::SilentModeToggleButtonStateSetting(bool value) @@ -108,7 +93,7 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationPresenter::OnDragEnd"); if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + NativeAbility::GetInstance().Back(); } return true; } @@ -122,77 +107,41 @@ namespace OHOS // 如果是power键,且是亮屏状态,按键释放就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + NativeAbility::GetInstance().Back(); } return true; } bool SoundAndVibrationPresenter::OnClick(UIView &view, const ClickEvent &event) { - - // 根据控件id查找是哪个控件触发了点击回调 UNUSED(event); if (strcmp(view.GetViewId(), SYSTEM_VOLUME_BUTTON) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); - return true; + NativeAbility::GetInstance().EnterSlice(VIEW_SYSTEM_VOLUME); } else if (strcmp(view.GetViewId(), CALL_VOLUME_BUTTON) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); - return true; + NativeAbility::GetInstance().EnterSlice(VIEW_SYSTEM_VOLUME); } - else if (strcmp(view.GetViewId(), MEDIA_VOLUME_BUTTON) == 0) + else if (strcmp(view.GetViewId(), VIBRATION_REMINDER_BUTTON) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); - return true; + NativeAbility::GetInstance().EnterSlice(VIEW_SYSTEM_VOLUME); } - return false; + return true; } - bool SoundAndVibrationViewOnChangeListener::OnChange(UICheckBox::UICheckBoxState state) + bool SoundAndVibrationPresenter::OnChange(UICheckBox::UICheckBoxState state) { - SoundAndVibrationView *p_SoundAndVibrationView = SoundAndVibrationView::GetInstance(); - if (p_SoundAndVibrationView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::GetInstance fail!"); - return false; - } - SoundAndVibrationModel* p_SoundAndVibrationModel = SoundAndVibrationModel::GetInstance(); - ConfigModel *p_ConfigModel = ConfigModel::GetInstance(); + SoundAndVibrationModel *p_SoundAndVibrationModel = SoundAndVibrationModel::GetInstance(); switch (state) { case UICheckBox::SELECTED: - if (p_SoundAndVibrationView->GetVibrationReminderToggleButton() == (UIView *)view_) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationReminder is enable!"); - p_SoundAndVibrationModel->SetVibrationReminderToggleButtonStaus(true); - p_ConfigModel->SetVibrationReminder(true); - return true; - } - else if (p_SoundAndVibrationView->GetSilentModeToggleButton() == (UIView *)view_) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SilentMode is enable!"); - p_SoundAndVibrationModel->SetSilentModeToggleButtonStatus(true); - p_ConfigModel->SetSilentMode(true); - return true; - } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SilentMode is enable!"); + p_SoundAndVibrationModel->SetSilentModeToggleButtonStatus(true); break; case UICheckBox::UNSELECTED: - if (p_SoundAndVibrationView->GetVibrationReminderToggleButton() == (UIView *)view_) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VibrationReminder is disable!"); - p_SoundAndVibrationModel->SetVibrationReminderToggleButtonStaus(false); - p_ConfigModel->SetVibrationReminder(false); - return true; - } - else if (p_SoundAndVibrationView->GetSilentModeToggleButton() == (UIView *)view_) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SilentMode is disable!"); - p_SoundAndVibrationModel->SetSilentModeToggleButtonStatus(false); - p_ConfigModel->SetSilentMode(false); - return true; - } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SilentMode is disable!"); + p_SoundAndVibrationModel->SetSilentModeToggleButtonStatus(false); break; default: break; diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp index 6d2a219b1..d9df73e63 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp @@ -54,8 +54,8 @@ namespace OHOS delete CallVolumeButton; CallVolumeButton = nullptr; - delete MediaVolumeButton; - MediaVolumeButton = nullptr; + delete VibrationReminderButton; + VibrationReminderButton = nullptr; delete SystemVolumeLabel; SystemVolumeLabel = nullptr; @@ -63,20 +63,17 @@ namespace OHOS delete CallVolumeLabel; CallVolumeLabel = nullptr; - delete MediaVolumeLabel; - MediaVolumeLabel = nullptr; - delete VibrationReminderLabel; VibrationReminderLabel = nullptr; delete SilentModeLabel; SilentModeLabel = nullptr; - for (int i = 0; i < 4; i++) - { - delete reminder[i]; - reminder[i] = nullptr; - } + // for (int i = 0; i < 4; i++) + // { + // delete reminder[i]; + // reminder[i] = nullptr; + // } for (int i = 0; i < 3; i++) { @@ -90,15 +87,6 @@ namespace OHOS delete SilentModeImageView; SilentModeImageView = nullptr; - delete VibrationReminderToggleButtonChangeListener; - VibrationReminderToggleButtonChangeListener = nullptr; - - delete SilentModeToggleButtonChangeListener; - SilentModeToggleButtonChangeListener = nullptr; - - delete VibrationReminderToggleButton; - VibrationReminderToggleButton = nullptr; - delete SilentModeToggleButton; SilentModeToggleButton = nullptr; @@ -120,7 +108,8 @@ namespace OHOS button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); button->SetViewId(buttonconfig.ViewId); button->SetStyle(STYLE_BACKGROUND_COLOR, buttonconfig.BackgroundColorValue); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, buttonconfig.TriggeredBackgroundColorValue, UIButton::PRESSED); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + button->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); button->SetOnClickListener(clickListener); return button; } @@ -139,9 +128,9 @@ namespace OHOS } // 设置标签 - UILabel *SoundAndVibrationView::SetUpLabel(LabelConfig &labelConfig) + UILabelExt *SoundAndVibrationView::SetUpLabel(LabelConfig &labelConfig) { - UILabel *label = new UILabel(); + UILabelExt *label = new UILabelExt(); if (label == nullptr) { return nullptr; @@ -149,9 +138,10 @@ namespace OHOS 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->SetText(labelConfig.text); // 内容 + label->SetText(labelConfig.text.c_str()); // 内容 label->SetLineBreakMode(labelConfig.lineBreakMode); // 断行模式。 - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + //label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(40); label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize); return label; } @@ -189,19 +179,19 @@ namespace OHOS /// @return true 初始化成功 false 初始化失败 bool SoundAndVibrationView::InitSoundAndVibrationViewTitleLabel(void) { - Title = new UILabel(); + Title = new UILabelExt(); if (Title == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new Title fail!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Title new fail!"); return false; } - Title->SetPosition(158, 52); + Title->SetPosition(93, 52, 280, 40); Title->SetStyle(STYLE_TEXT_FONT, 30); Title->SetStyle(STYLE_LINE_HEIGHT, 35); Title->SetText("声音与震动"); - Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - Title->SetRollSpeed(6); + Title->SetRollSpeed(40); Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); return true; @@ -230,8 +220,8 @@ namespace OHOS return false; } - /* ---------------------------- MediaVolumeButton --------------------------- */ - if (!SetUpButtonAndCheck(MEDIA_VOLUME_BUTTON, 43, 360, MediaVolumeButton, ButtonClick)) + /* ---------------------------- VibrationReminderButton --------------------------- */ + if (!SetUpButtonAndCheck(VIBRATION_REMINDER_BUTTON, 43, 360, VibrationReminderButton, ButtonClick)) { return false; } @@ -240,12 +230,6 @@ namespace OHOS } /// @brief 为指定的按钮设置属性并进行错误检查 - /// @param viewId - /// @param x - /// @param y - /// @param button - /// @param listener - /// @return true 设置成功 false 设置失败 bool SoundAndVibrationView::SetUpButtonAndCheck(const char *viewId, int x, int y, UIButton *&button, UIView::OnClickListener *listener) { ButtonConfig buttonconfig = { @@ -255,7 +239,6 @@ namespace OHOS .h = 100, .ViewId = viewId, .BackgroundColorValue = 0xff191919, - .TriggeredBackgroundColorValue = 0xff29b862, }; button = SetUpButton(buttonconfig, listener); @@ -267,11 +250,12 @@ namespace OHOS return true; } + /*初始化声音与震动视图图片*/ bool SoundAndVibrationView::InitSoundAndVibrationImageView() { ImageConfig imageconfig = { .x = 43, - .y = 480, + .y = 360, .w = 380, .h = 100, .ImageSrc = "/user/res/SETTING_BACKGROUND.bin", @@ -284,7 +268,7 @@ namespace OHOS return false; } - imageconfig.y = 600; + imageconfig.y = 480; SilentModeImageView = SetUpImageVIew(imageconfig); if (SilentModeImageView == nullptr) { @@ -313,16 +297,17 @@ namespace OHOS return true; } + /*初始化声音与震动视图标签*/ bool SoundAndVibrationView::InitSoundAndVibrationLabel(void) { LabelConfig labelConfig = { .left = 90, - .top = 140, - .width = 120, - .height = 35, + .top = 152, + .width = 250, + .height = 40, .fontSize = 30, .lineHeigh = 35, - .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, }; /* ---------------------------- SystemVolumeLabel --------------------------- */ labelConfig.text = "系统音量"; @@ -333,7 +318,7 @@ namespace OHOS return false; } /* ----------------------------- CallVolumeLabel ---------------------------- */ - labelConfig.top = 260; + labelConfig.top = 272; labelConfig.text = "通话音量"; CallVolumeLabel = SetUpLabel(labelConfig); if (CallVolumeLabel == nullptr) @@ -341,18 +326,9 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CallVolumeLabel is nullptr!"); return false; } - /* ---------------------------- MediaVolumeLabel ---------------------------- */ - labelConfig.top = 380; - labelConfig.text = "媒体音量"; - MediaVolumeLabel = SetUpLabel(labelConfig); - if (MediaVolumeLabel == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::MediaVolumeLabel is nullptr!"); - return false; - } - /* ------------------------- VibrationReminderLabel ------------------------- */ - labelConfig.top = 513; - labelConfig.text = "震动提醒"; + /* ---------------------------- VibrationReminderLabel ---------------------------- */ + labelConfig.top = 392; + labelConfig.text = "震动模式"; VibrationReminderLabel = SetUpLabel(labelConfig); if (VibrationReminderLabel == nullptr) { @@ -360,7 +336,7 @@ namespace OHOS return false; } /* ----------------------------- SilentModeLabel ---------------------------- */ - labelConfig.top = 620; + labelConfig.top = 512; labelConfig.text = "静音模式"; SilentModeLabel = SetUpLabel(labelConfig); if (SilentModeLabel == nullptr) @@ -369,62 +345,47 @@ namespace OHOS return false; } /* -------------------------------------------------------------------------- */ - typedef struct - { - int top; - char text[100]; - } LabelInfo; - - LabelInfo labelInfo[] = { - {177, "闹钟、提醒、查找手表"}, - {297, "手表通话"}, - {417, "音乐、录音、训练"}, - {657, "系统音量不受影响"}, - }; - for (int i = 0; i < (int)(sizeof(labelInfo) / sizeof(labelInfo[0])); i++) - { - LabelConfig labelConfig = { - .left = 90, - .top = labelInfo[i].top, - .width = 300, - .height = 35, - .fontSize = 20, - .lineHeigh = 23, - .text = labelInfo[i].text, - .lineBreakMode = UILabel::LINE_BREAK_ADAPT, - }; - - reminder[i] = SetUpLabel(labelConfig); - if (reminder[i] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::reminder[%d] is nullptr!", i); - return false; - } - - reminder[i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - reminder[i]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - reminder[i]->SetTextColor(Color::GetColorFromRGBA(0xfd, 0xfd, 0xfd, 0x7f)); - } + // typedef struct + // { + // int top; + // char text[100]; + // } LabelInfo; + + // LabelInfo labelInfo[] = { + // {177, "闹钟、提醒、查找手表"}, + // {297, "手表通话"}, + // {417, "音乐、录音、训练"}, + // {657, "系统音量不受影响"}, + // }; + // for (int i = 0; i < (int)(sizeof(labelInfo) / sizeof(labelInfo[0])); i++) + // { + // LabelConfig labelConfig = { + // .left = 90, + // .top = labelInfo[i].top, + // .width = 300, + // .height = 35, + // .fontSize = 20, + // .lineHeigh = 23, + // .text = labelInfo[i].text, + // .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + // }; + + // reminder[i] = SetUpLabel(labelConfig); + // if (reminder[i] == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::reminder[%d] is nullptr!", i); + // return false; + // } + + // reminder[i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + // reminder[i]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + // reminder[i]->SetTextColor(Color::GetColorFromRGBA(0xfd, 0xfd, 0xfd, 0x7f)); + // } return true; } bool SoundAndVibrationView::InitSoundAndVibrationToggleButton(void) { - /* ---------------------- VibrationReminderToggleButton --------------------- */ - VibrationReminderToggleButton = new UIToggleButton(); - if (VibrationReminderToggleButton == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::VibrationReminderToggleButton new fail!"); - return false; - } - VibrationReminderToggleButton->SetPosition(298, 505, 100, 50); - VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - const char *ToggleButtonSelect = "/user/res/TOGGLEBUTTON_ON.bin"; - const char *ToggleButtonUnSelect = "/user/res/TOGGLEBUTTON_OFF.bin"; - VibrationReminderToggleButton->SetImages(ToggleButtonSelect, ToggleButtonUnSelect); - VibrationReminderToggleButtonChangeListener = new SoundAndVibrationViewOnChangeListener(reinterpret_cast(VibrationReminderToggleButton)); - VibrationReminderToggleButton->SetOnChangeListener(VibrationReminderToggleButtonChangeListener); /* ------------------------- SilentModeToggleButton ------------------------- */ SilentModeToggleButton = new UIToggleButton(); if (SilentModeToggleButton == nullptr) @@ -432,22 +393,17 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeToggleButton new fail!"); return false; } - SilentModeToggleButton->SetPosition(298, 625, 100, 50); + SilentModeToggleButton->SetPosition(298, 505, 100, 50); SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + const char *ToggleButtonSelect = "/user/res/TOGGLEBUTTON_ON.bin"; + const char *ToggleButtonUnSelect = "/user/res/TOGGLEBUTTON_OFF.bin"; SilentModeToggleButton->SetImages(ToggleButtonSelect, ToggleButtonUnSelect); - SilentModeToggleButtonChangeListener = new SoundAndVibrationViewOnChangeListener(reinterpret_cast(SilentModeToggleButton)); + UICheckBox::OnChangeListener * SilentModeToggleButtonChangeListener = static_cast(SoundAndVibrationPresenter::GetInstance()); SilentModeToggleButton->SetOnChangeListener(SilentModeToggleButtonChangeListener); return true; } - /// @brief 获取"震动提醒"按钮开,关状态 - /// @param void - /// @return true 开 false 关 - bool SoundAndVibrationView::GetVibrationReminderToggleButtonState(void) - { - return VibrationReminderToggleButton->GetState(); - } /// @brief 获取"静音模式"按钮开,关状态 /// @param void @@ -457,12 +413,6 @@ namespace OHOS return SilentModeToggleButton->GetState(); } - /// @brief 设置"震动提醒"按钮开,关状态 - /// @param value - void SoundAndVibrationView::SetVibrationReminderToggleButtonState(bool value) - { - VibrationReminderToggleButton->SetState(value); - } /// @brief 设置"静音模式"按钮开,关状态 /// @param value @@ -471,11 +421,6 @@ namespace OHOS SilentModeToggleButton->SetState(value); } - /// @brief 获取"震动提醒"切换按钮 - UIToggleButton *SoundAndVibrationView::GetVibrationReminderToggleButton(void) - { - return VibrationReminderToggleButton; - } /// @brief 获取"静音模式"切换按钮 UIToggleButton *SoundAndVibrationView::GetSilentModeToggleButton(void) @@ -509,10 +454,6 @@ namespace OHOS { return; } - if (SoundAndVibrationModel::GetInstance()->VibrationReminderToggleButtonStatusInit() == false) - { - return; - } if (SoundAndVibrationModel::GetInstance()->SilentModeToggleButtonStatusInit() == false) { return; @@ -534,22 +475,21 @@ namespace OHOS SoundAndVibrationScrollView->Add(Title); SoundAndVibrationScrollView->Add(SystemVolumeButton); SoundAndVibrationScrollView->Add(CallVolumeButton); - SoundAndVibrationScrollView->Add(MediaVolumeButton); + SoundAndVibrationScrollView->Add(VibrationReminderButton); SoundAndVibrationScrollView->Add(VibrationReminderImageView); SoundAndVibrationScrollView->Add(SilentModeImageView); SoundAndVibrationScrollView->Add(SystemVolumeLabel); SoundAndVibrationScrollView->Add(CallVolumeLabel); - SoundAndVibrationScrollView->Add(MediaVolumeLabel); + SoundAndVibrationScrollView->Add(VibrationReminderLabel); SoundAndVibrationScrollView->Add(VibrationReminderLabel); SoundAndVibrationScrollView->Add(SilentModeLabel); - SoundAndVibrationScrollView->Add(reminder[0]); - SoundAndVibrationScrollView->Add(reminder[1]); - SoundAndVibrationScrollView->Add(reminder[2]); - SoundAndVibrationScrollView->Add(reminder[3]); + // SoundAndVibrationScrollView->Add(reminder[0]); + // SoundAndVibrationScrollView->Add(reminder[1]); + // SoundAndVibrationScrollView->Add(reminder[2]); + // SoundAndVibrationScrollView->Add(reminder[3]); SoundAndVibrationScrollView->Add(nextImageView[0]); SoundAndVibrationScrollView->Add(nextImageView[1]); SoundAndVibrationScrollView->Add(nextImageView[2]); - SoundAndVibrationScrollView->Add(VibrationReminderToggleButton); SoundAndVibrationScrollView->Add(SilentModeToggleButton); RootView::GetInstance()->Add(SoundAndVibrationScrollView); Draw(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp index daa9e5639..2fd144feb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-08 18:40:09 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-16 09:48:10 + * @LastEditTime: 2024-04-18 18:42:24 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp */ #include "weather/include/WeatherModel.h" @@ -164,7 +164,7 @@ namespace OHOS std::string WeatherModel::GetWeatherArea() { std::string city = Weather_data_t_address.city; - std::string subLocality = Weather_data_t_address.city; + std::string subLocality = Weather_data_t_address.subLocality; return (city + subLocality); } diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 30deed282..322bcc6e0 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -217,6 +217,7 @@ void startup_post_init_task(void) initScreenBrightness(); initializeScreenDuration(); + initializeRaiseToWake(); LOS_Msleep(5000); if ( poweron_cat1_on_bootup_flag() ) -- 2.17.1