From: luozheng <1732036298@qq.com> Date: Wed, 21 Feb 2024 11:09:56 +0000 (+0800) Subject: 声音与震动视图修改删除带文字图片 X-Git-Tag: release_V1.2.70_20241020_135402~1298^2~18^2 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.js?a=commitdiff_plain;h=153c0deb6703a67dbaf64ac3c8f375ff183b048b;p=mirrors%2FFD230.git 声音与震动视图修改删除带文字图片 --- 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 1c7580dcd..c7228dd68 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp @@ -119,7 +119,7 @@ namespace OHOS DisplayBrightnessTitleLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); DisplayBrightnessTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); DisplayBrightnessTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - DisplayBrightnessTitleLabel->SetText("显示与亮度"); + DisplayBrightnessTitleLabel->SetText("屏幕与亮度"); DisplayBrightnessTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); DisplayBrightnessTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); DisplayBrightnessTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); 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 1897a02d7..9100117e1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h @@ -17,7 +17,7 @@ namespace OHOS /* ---------------------------------- 组件ID ---------------------------------- */ static const char *SYSTEM_VOLUME_BUTTON = "SystemVolumeButton"; // 系统音量按钮ID static const char *CALL_VOLUME_BUTTON = "CallVolumeButton"; // 通话音量按钮ID - static const char *MEDIAVOLUMEBUTTON = "MediaVolumeButton"; // 媒体音量按钮ID + static const char *MEDIA_VOLUME_BUTTON = "MediaVolumeButton"; // 媒体音量按钮ID static const char *VIBRATION_REMINDER_TOGGLEBUTTON = "VibrationReminderToggleButton"; // 震动提醒 static const char *SILENT_MODEL_TOGGLEBUTTON = "SilentModeToggleButton"; // 静音模式 class SoundAndVibrationPresenter; @@ -27,10 +27,10 @@ namespace OHOS public: struct ImageConfig { - int x; - int y; - int w; - int h; + int16_t x; + int16_t y; + int16_t w; + int16_t h; const char *ImageSrc; }; struct LabelConfig @@ -46,12 +46,13 @@ namespace OHOS }; struct ButtonConfig { - int x; - int y; - int w; - int h; + int16_t x; + int16_t y; + int16_t w; + int16_t h; const char *ViewId; - const char *ImageSrc; + int64_t BackgroundColorValue; // 按钮背景颜色值 + int64_t TriggeredBackgroundColorValue; // 点击按钮触发的背景颜色值 }; SoundAndVibrationView(); virtual ~SoundAndVibrationView(); @@ -65,25 +66,34 @@ namespace OHOS private: void InitView(void); void ClearAll(void); - bool SetUpSoundAndVibrationScrollView(void); - bool SetUpTitle(void); UIButton *SetUpButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener); UIImageView *SetUpImageVIew(ImageConfig &imageconfig); UILabel *SetUpLabel(LabelConfig &labelConfig); + bool InitSoundAndVibrationScrollView(void); + bool InitSoundAndVibrationViewTitleLabel(void); + bool InitSoundAndVibrationButtonView(void); + bool SetUpButtonAndCheck(const char *viewId, int x, int y, UIButton *&button, UIView::OnClickListener *listener); + bool InitSoundAndVibrationImageView(void); + bool InitSoundAndVibrationLabel(void); + bool InitSoundAndVibrationToggleButton(void); private: - UIScrollView *SoundAndVibrationScrollView = nullptr; - UILabel *Title = nullptr; - UIButton *SystemVolumeButton = nullptr; - UIButton *CallVolumeButton = nullptr; - UIButton *MediaVolumeButton = nullptr; - UIImageView *Background[2]{nullptr}; // 放组件的背景 - UILabel *VibrationReminderLabel = nullptr; // 震动提醒 - UILabel *SilentModeLabel = nullptr; // 静音模式 - UILabel *SilentModeLabel_ = nullptr; // 系统音量不受影响 - UIToggleButton *VibrationReminderToggleButton = nullptr; - UIToggleButton *SilentModeToggleButton = nullptr; - + 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}; // 静音模式切换按钮 bool initViewStatus{false}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h index 9c6803d5f..7aa75ea4f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h @@ -3,7 +3,7 @@ #include "BaseView.h" #include "View.h" -#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" #include "components/ui_slider.h" #include "components/ui_image_view.h" @@ -23,10 +23,10 @@ namespace OHOS SoundAndVibrationVolumeSettingView(); ~SoundAndVibrationVolumeSettingView(); static SoundAndVibrationVolumeSettingView *GetInstance(void); - UIViewGroup * SetUpVolumeProcess(void); + UIScrollView * SetUpVolumeProcess(void); void ClearAll(void); private: - UIViewGroup *group{nullptr}; + UIScrollView *ScrollView{nullptr}; UISlider *VolumeProcess{nullptr}; UIImageView *VolumeVetor{nullptr}; bool initViewStatus{false}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumeView.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumeView.h index b45eadebd..af359213e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumeView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumeView.h @@ -3,7 +3,7 @@ #include "BaseView.h" #include "View.h" -#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" #include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h" namespace OHOS { @@ -23,10 +23,10 @@ namespace OHOS void OnTearDownView() override; void OnStop() override; - UIViewGroup * SystemVolumeViewInit(void); + UIScrollView * SystemVolumeViewInit(void); private: - UIViewGroup *group{nullptr}; + UIScrollView *SystemVolumeScrollView{nullptr}; SoundAndVibrationVolumeSettingView *p_SoundAndVibrationVolumeSettingView{nullptr}; }; } // namespace OHOS 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 6eacd8b40..df4df048d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp @@ -68,7 +68,7 @@ namespace OHOS{ { NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); return true; - }else if(strcmp(view.GetViewId(), MEDIAVOLUMEBUTTON) == 0) + }else if(strcmp(view.GetViewId(), MEDIA_VOLUME_BUTTON) == 0) { NativeAbility::GetInstance().ChangeSlice(VIEW_SYSTEM_VOLUME); return true; 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 c9df18bc2..0c8da83ef 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp @@ -47,76 +47,57 @@ namespace OHOS Title = nullptr; delete SystemVolumeButton; SystemVolumeButton = nullptr; + delete CallVolumeButton; CallVolumeButton = nullptr; + delete MediaVolumeButton; MediaVolumeButton = nullptr; - for (int i = 0; i < 2; i++) - { - delete Background[i]; - Background[i] = nullptr; - } + + delete SystemVolumeLabel; + SystemVolumeLabel = nullptr; + + delete CallVolumeLabel; + CallVolumeLabel = nullptr; + + delete MediaVolumeLabel; + MediaVolumeLabel = nullptr; + delete VibrationReminderLabel; VibrationReminderLabel = nullptr; + delete SilentModeLabel; SilentModeLabel = nullptr; - delete SilentModeLabel_; - SilentModeLabel_ = nullptr; + + for (int i = 0; i < 4; i++) + { + delete reminder[i]; + reminder[i] = nullptr; + } + + for (int i = 0; i < 3; i++) + { + delete nextImageView[i]; + nextImageView[i] = nullptr; + } + + delete VibrationReminderImageView; + VibrationReminderImageView = nullptr; + + delete SilentModeImageView; + SilentModeImageView; + delete VibrationReminderToggleButton; VibrationReminderToggleButton = nullptr; + delete SilentModeToggleButton; SilentModeToggleButton = nullptr; + delete SoundAndVibrationScrollView; SoundAndVibrationScrollView = nullptr; } } - bool SoundAndVibrationView::SetUpSoundAndVibrationScrollView(void) - { - SoundAndVibrationScrollView = new UIScrollView(); - if (SoundAndVibrationScrollView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new SoundAndVibrationScrollView fail!"); - return false; - } - SoundAndVibrationScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - SoundAndVibrationScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - SoundAndVibrationScrollView->SetScrollBlankSize(35); - SoundAndVibrationScrollView->SetReboundSize(50); - SoundAndVibrationScrollView->SetDirection(1); - UIView::OnDragListener *draglistener = static_cast(SoundAndVibrationPresenter::GetInstance()); - if (draglistener == nullptr) - { - return false; - } - SoundAndVibrationScrollView->SetOnDragListener(draglistener); - SoundAndVibrationScrollView->SetTouchable(true); - SoundAndVibrationScrollView->SetDraggable(true); - - return true; - } - - // 设置标题 - bool SoundAndVibrationView::SetUpTitle(void) - { - Title = new UILabel(); - if (Title == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new Title fail!"); - return false; - } - Title->SetPosition(158, 52); - Title->SetStyle(STYLE_TEXT_FONT, 30); - Title->SetStyle(STYLE_LINE_HEIGHT, 35); - Title->SetText("声音与震动"); - Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - Title->SetRollSpeed(6); - Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - return true; - } - /// @brief 设置按钮 /// @param button /// @return true 设置成功,false 失败 @@ -129,9 +110,8 @@ namespace OHOS } button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); button->SetViewId(buttonconfig.ViewId); - button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc); - button->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - button->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button->SetStyle(STYLE_BACKGROUND_COLOR, buttonconfig.BackgroundColorValue); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, buttonconfig.TriggeredBackgroundColorValue, UIButton::PRESSED); button->SetOnClickListener(clickListener); return button; } @@ -166,53 +146,120 @@ namespace OHOS label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize); return label; } - void SoundAndVibrationView::InitView(void) + + /// @brief 声音与震动视图"scrollView"视图初始化 + /// @param void + /// @return true 初始化成功 false 初始化失败 + bool SoundAndVibrationView::InitSoundAndVibrationScrollView(void) { - if (SetUpSoundAndVibrationScrollView() == false) + SoundAndVibrationScrollView = new UIScrollView(); + if (SoundAndVibrationScrollView == nullptr) { - return; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new SoundAndVibrationScrollView fail!"); + return false; } - if (SetUpTitle() == false) + SoundAndVibrationScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + SoundAndVibrationScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SoundAndVibrationScrollView->SetScrollBlankSize(35); + SoundAndVibrationScrollView->SetReboundSize(50); + SoundAndVibrationScrollView->SetDirection(1); + UIView::OnDragListener *draglistener = static_cast(SoundAndVibrationPresenter::GetInstance()); + if (draglistener == nullptr) { - return; + return false; } + SoundAndVibrationScrollView->SetOnDragListener(draglistener); + SoundAndVibrationScrollView->SetTouchable(true); + SoundAndVibrationScrollView->SetDraggable(true); + + return true; + } + + /// @brief 声音与震动视图"标题"标签初始化 + /// @param void + /// @return true 初始化成功 false 初始化失败 + bool SoundAndVibrationView::InitSoundAndVibrationViewTitleLabel(void) + { + Title = new UILabel(); + if (Title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new Title fail!"); + return false; + } + Title->SetPosition(158, 52); + Title->SetStyle(STYLE_TEXT_FONT, 30); + Title->SetStyle(STYLE_LINE_HEIGHT, 35); + Title->SetText("声音与震动"); + Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetRollSpeed(6); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + return true; + } + + /// @brief 声音与震动视图"按钮"初始化 + /// @param void + /// @return true 初始化成功 false 初始化失败 + bool SoundAndVibrationView::InitSoundAndVibrationButtonView(void) + { UIView::OnClickListener *ButtonClick = static_cast(SoundAndVibrationPresenter::GetInstance()); + if (ButtonClick == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationPresenter::GetInstance() fail!"); + return false; + } /* --------------------------- SystemVolumeButton --------------------------- */ - ButtonConfig buttonconfig = { - .x = 43, - .y = 120, - .w = 380, - .h = 100, - .ViewId = SYSTEM_VOLUME_BUTTON, - .ImageSrc = PNG_SYSTEM_VOLUME_IMAGE, - }; - SystemVolumeButton = SetUpButton(buttonconfig, ButtonClick); - if (SystemVolumeButton == nullptr) + if (!SetUpButtonAndCheck(SYSTEM_VOLUME_BUTTON, 43, 120, SystemVolumeButton, ButtonClick)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetTheButton: SystemVolumeButton is nullptr!"); - return; + return false; } + /* ---------------------------- CallVolumeButton ---------------------------- */ - buttonconfig.y = 240; - buttonconfig.ViewId = CALL_VOLUME_BUTTON; - buttonconfig.ImageSrc = PNG_CALL_VOLUME_IMAGE; - CallVolumeButton = SetUpButton(buttonconfig, ButtonClick); - if (SystemVolumeButton == nullptr) + if (!SetUpButtonAndCheck(CALL_VOLUME_BUTTON, 43, 240, CallVolumeButton, ButtonClick)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetTheButton: CallVolumeButton is nullptr!"); - return; + return false; } + /* ---------------------------- MediaVolumeButton --------------------------- */ - buttonconfig.y = 360; - buttonconfig.ViewId = MEDIAVOLUMEBUTTON; - buttonconfig.ImageSrc = PNG_MEDIA_VOLUME_IMAGE; - MediaVolumeButton = SetUpButton(buttonconfig, ButtonClick); - if (SystemVolumeButton == nullptr) + if (!SetUpButtonAndCheck(MEDIA_VOLUME_BUTTON, 43, 360, MediaVolumeButton, ButtonClick)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetTheButton: MediaVolumeButton is nullptr!"); - return; + return false; } - /* ------------------------------- Background ------------------------------- */ + + return true; + } + + /// @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 = { + .x = x, + .y = y, + .w = 380, + .h = 100, + .ViewId = viewId, + .BackgroundColorValue = 0xff191919, + .TriggeredBackgroundColorValue = 0xff29b862, + }; + + button = SetUpButton(buttonconfig, listener); + if (button == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetUpButtonAndCheck: Button is nullptr!"); + return false; + } + return true; + } + + bool SoundAndVibrationView::InitSoundAndVibrationImageView() + { ImageConfig imageconfig = { .x = 43, .y = 480, @@ -220,35 +267,88 @@ namespace OHOS .h = 100, .ImageSrc = "/user/res/SETTING_BACKGROUND.bin", }; - Background[0] = SetUpImageVIew(imageconfig); - if (Background[0] == nullptr) + + VibrationReminderImageView = SetUpImageVIew(imageconfig); + if (VibrationReminderImageView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Background[0] new fail!"); - return; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::VibrationReminderImageView is nullptr!"); + return false; } + imageconfig.y = 600; - Background[1] = SetUpImageVIew(imageconfig); - if (Background[1] == nullptr) + SilentModeImageView = SetUpImageVIew(imageconfig); + if (SilentModeImageView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Background[1] new fail!"); - return; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeImageView is nullptr!"); + return false; } - /* ------------------------- VibrationReminderLabel ------------------------- */ + + imageconfig = { + .x = 369, + .w = 14, + .h = 26, + .ImageSrc = "/user/res/SETTING_NEXT.bin", + }; + + for (int i = 0; i < 3; i++) + { + imageconfig.y = 157 + 120 * i; + nextImageView[i] = SetUpImageVIew(imageconfig); + if (nextImageView[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView:: nextImageView[%d] is nullptr!", i); + return false; + } + } + + return true; + } + + bool SoundAndVibrationView::InitSoundAndVibrationLabel(void) + { LabelConfig labelConfig = { .left = 90, - .top = 513, + .top = 140, .width = 120, .height = 35, .fontSize = 30, .lineHeigh = 35, - .text = "震动提醒", .lineBreakMode = UILabel::LINE_BREAK_ADAPT, }; + /* ---------------------------- SystemVolumeLabel --------------------------- */ + labelConfig.text = "系统音量"; + SystemVolumeLabel = SetUpLabel(labelConfig); + if (SystemVolumeLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SystemVolumeLabel is nullptr!"); + return false; + } + /* ----------------------------- CallVolumeLabel ---------------------------- */ + labelConfig.top = 260; + labelConfig.text = "通话音量"; + CallVolumeLabel = SetUpLabel(labelConfig); + if (CallVolumeLabel == nullptr) + { + 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 = SetUpLabel(labelConfig); if (VibrationReminderLabel == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::VibrationReminderLabel is nullptr!"); - return; + return false; } /* ----------------------------- SilentModeLabel ---------------------------- */ labelConfig.top = 620; @@ -257,28 +357,57 @@ namespace OHOS if (SilentModeLabel == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeLabel is nullptr!"); - return; + return false; } - /* ---------------------------- SilentModeLabel_ ---------------------------- */ - labelConfig.top = 657; - labelConfig.text = "系统音量不受影响"; - labelConfig.fontSize = 20; - labelConfig.lineHeigh = 23; - SilentModeLabel_ = SetUpLabel(labelConfig); - if (SilentModeLabel_ == nullptr) + /* -------------------------------------------------------------------------- */ + typedef struct { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeLabel_ is nullptr!"); - return; + int top; + char text[100]; + } LabelInfo; + + LabelInfo labelInfo[] = { + {177, "闹钟、提醒、查找手表"}, + {297, "手表通话"}, + {417, "音乐、录音、训练"}, + {657, "系统音量不受影响"}, + }; + for (int i = 0; i < 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)); } - SilentModeLabel_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - SilentModeLabel_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - SilentModeLabel_->SetTextColor(Color::GetColorFromRGBA(0xfd, 0xfd, 0xfd, 0x7f)); + return true; + } + + bool SoundAndVibrationView::InitSoundAndVibrationToggleButton(void) + { + UIView::OnClickListener *ButtonClick = static_cast(SoundAndVibrationPresenter::GetInstance()); /* ---------------------- VibrationReminderToggleButton --------------------- */ VibrationReminderToggleButton = new UIToggleButton(); if (VibrationReminderToggleButton == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::VibrationReminderToggleButton new fail!"); - return; + return false; } VibrationReminderToggleButton->SetPosition(298, 505, 100, 50); VibrationReminderToggleButton->SetViewId(VIBRATION_REMINDER_TOGGLEBUTTON); @@ -293,7 +422,7 @@ namespace OHOS if (SilentModeToggleButton == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeToggleButton new fail!"); - return; + return false; } SilentModeToggleButton->SetPosition(298, 625, 100, 50); SilentModeToggleButton->SetViewId(SILENT_MODEL_TOGGLEBUTTON); @@ -301,7 +430,35 @@ namespace OHOS SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); SilentModeToggleButton->SetImages(ToggleButtonSelect, ToggleButtonUnSelect); SilentModeToggleButton->SetOnClickListener(ButtonClick); + return true; + } + void SoundAndVibrationView::InitView(void) + { + if (InitSoundAndVibrationScrollView() == false) + { + return; + } + if (InitSoundAndVibrationViewTitleLabel() == false) + { + return; + } + if (InitSoundAndVibrationButtonView() == false) + { + return; + } + if (InitSoundAndVibrationImageView() == false) + { + return; + } + if (InitSoundAndVibrationToggleButton() == false) + { + return; + } + if (InitSoundAndVibrationLabel() == false) + { + return; + } initViewStatus = true; } @@ -318,11 +475,20 @@ namespace OHOS SoundAndVibrationScrollView->Add(SystemVolumeButton); SoundAndVibrationScrollView->Add(CallVolumeButton); SoundAndVibrationScrollView->Add(MediaVolumeButton); - SoundAndVibrationScrollView->Add(Background[0]); - SoundAndVibrationScrollView->Add(Background[1]); + SoundAndVibrationScrollView->Add(VibrationReminderImageView); + SoundAndVibrationScrollView->Add(SilentModeImageView); + SoundAndVibrationScrollView->Add(SystemVolumeLabel); + SoundAndVibrationScrollView->Add(CallVolumeLabel); + SoundAndVibrationScrollView->Add(MediaVolumeLabel); SoundAndVibrationScrollView->Add(VibrationReminderLabel); SoundAndVibrationScrollView->Add(SilentModeLabel); - SoundAndVibrationScrollView->Add(SilentModeLabel_); + 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); diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp index 4f65e773c..dc16bb2ef 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp @@ -1,4 +1,6 @@ #include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h" +#include "soundandvibration/include/SoundAndVibrationPresenter.h" +#include "soundandvibration/include/SystemVolumePresenter.h" #include "wearable_log.h" namespace OHOS @@ -28,27 +30,34 @@ namespace OHOS { if (initViewStatus == true) { - group->RemoveAll(); + ScrollView->RemoveAll(); delete VolumeProcess; VolumeProcess = nullptr; delete VolumeVetor; VolumeVetor = nullptr; - delete group; - group = nullptr; + delete ScrollView; + ScrollView = nullptr; } } - UIViewGroup *SoundAndVibrationVolumeSettingView::SetUpVolumeProcess(void) + UIScrollView *SoundAndVibrationVolumeSettingView::SetUpVolumeProcess(void) { - group = new UIViewGroup(); - if (group == nullptr) + ScrollView = new UIScrollView(); + if (ScrollView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::group new fail"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::ScrollView new fail"); return nullptr; } - group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - group->SetDraggable(true); - group->SetTouchable(true); + ScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + UIView::OnDragListener *volumeDragListener = (UIView::OnDragListener *)OHOS::SystemVolumePresenter::GetInstance(); + if (volumeDragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumePresenter GetInstance fail"); + return nullptr; + } + ScrollView->SetOnDragListener(volumeDragListener); + ScrollView->SetDraggable(true); + ScrollView->SetTouchable(true); /* ------------------------------ VolumeProcess ----------------------------- */ VolumeProcess = new UISlider(); if (VolumeProcess == nullptr) @@ -92,15 +101,12 @@ namespace OHOS // progress->SetOnClickListener(listener); // progress->SetOnDragListener(listener); // progress->SetKnobStyle(StyleDefault::GetSliderKnobStyle()); - // UIView::OnDragListener *volDragListener = (UIView::OnDragListener *)OHOS::VolumeSliderEventListener::GetInstance(); + // // SetViewId(VOLUME_VIEW); - // SetOnDragListener(volDragListener); - // SetDraggable(true); - // SetTouchable(true); - group->Add(VolumeProcess); - group->Add(VolumeVetor); + ScrollView->Add(VolumeProcess); + ScrollView->Add(VolumeVetor); initViewStatus = true; - return group; + return ScrollView; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp index 0a94a4c1b..2ff1653f3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp @@ -27,7 +27,7 @@ namespace OHOS return g_pSystemVolumeView; } - UIViewGroup *SystemVolumeView::SystemVolumeViewInit(void) + UIScrollView *SystemVolumeView::SystemVolumeViewInit(void) { p_SoundAndVibrationVolumeSettingView = new SoundAndVibrationVolumeSettingView(); if (p_SoundAndVibrationVolumeSettingView == nullptr) @@ -35,14 +35,14 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!"); return nullptr; } - group = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess(); - if (group == nullptr) + SystemVolumeScrollView = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess(); + if (SystemVolumeScrollView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::group is nullptr!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::SystemVolumeScrollView is nullptr!"); return nullptr; } - return group; + return SystemVolumeScrollView; } void SystemVolumeView::OnStart() @@ -54,7 +54,7 @@ namespace OHOS void SystemVolumeView::OnSetUpView() { View::OnSetUpView(); - RootView::GetInstance()->Add(group); + RootView::GetInstance()->Add(SystemVolumeScrollView); Draw(); } diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/CALL_VOLUME.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/CALL_VOLUME.bin deleted file mode 100644 index cb2c53a07..000000000 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/CALL_VOLUME.bin and /dev/null differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/MEDIA_VOLUME.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/MEDIA_VOLUME.bin deleted file mode 100644 index 16f64f013..000000000 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/MEDIA_VOLUME.bin and /dev/null differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/SYSTEM_VOLUME.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/SYSTEM_VOLUME.bin deleted file mode 100644 index 95333ff29..000000000 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/SoundAndVibration/SYSTEM_VOLUME.bin and /dev/null differ