From: 罗正yun <1732036298@qq.com> Date: Mon, 29 Jan 2024 10:29:14 +0000 (+0800) Subject: 修改声音与震动视图 X-Git-Tag: release_V1.2.70_20241020_135402~1319^2 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=b752354909fc4f4d17f87905d5dca197c212ebbe;p=mirrors%2FFD230.git 修改声音与震动视图 --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index bdadde925..d709cfd9d 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -236,7 +236,8 @@ set(SOURCES #声音与震动 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SystemVolumePresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SystemVolumeView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/CallVolumePresenter.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h index 8f3f0b2b7..23b21e0d8 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h @@ -284,9 +284,7 @@ namespace OHOS static constexpr const char *PNG_SYSTEM_CHECK_OFF_IMAGE = APP_RES_PATH "/SYSTEM_CheckOff.bin"; // 叉 static constexpr const char *PNG_TOGGLEBUTTON_OFF_IMAGE = APP_RES_PATH "/TOGGLEBUTTON_OFF.bin"; // togglebuttton未选中图片 static constexpr const char *PNG_TOGGLEBUTTON_ON_IMAGE = APP_RES_PATH "/TOGGLEBUTTON_ON.bin"; // togglebuttton选中图片 - static constexpr const char *PNG_SYSTEM_VOLUME_IMAGE = APP_RES_PATH "/SYSTEM_VOLUME.bin"; // 系统音量 - static constexpr const char *PNG_CALL_VOLUME_IMAGE = APP_RES_PATH "/CALL_VOLUME.bin"; // 通话音量 - static constexpr const char *PNG_MEDIA_VOLUME_IMAGE = APP_RES_PATH "/MEDIA_VOLUME.bin"; // 媒体音量 + static constexpr const char *PNG_ORANGE_ATTENTION_VECTOR_IMAGE = APP_RES_PATH "/OrangeAttentionVector.bin"; // 橘黄色感叹号图标 static constexpr const char *PNG_ANIMATOR1_IMAGE = APP_RES_PATH "/Record/animator1.bin"; static constexpr const char *PNG_ANIMATOR2_IMAGE = APP_RES_PATH "/Record/animator2.bin"; 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 cc4d90ac4..1897a02d7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h @@ -3,8 +3,6 @@ #include "BaseView.h" #include "View.h" - -#include "components/ui_view_group.h" #include "components/ui_scroll_view.h" #include "components/ui_label.h" #include "components/ui_button.h" @@ -12,16 +10,49 @@ #include "components/ui_toggle_button.h" namespace OHOS { - static const char * SYSTEM_VOLUME_BUTTON = "SystemVolumeButton"; //系统音量 - static const char * CALL_VOLUME_BUTTON = "CallVolumeButton"; //通话音量 - static const char * MEDIAVOLUMEBUTTON = "MediaVolumeButton"; //媒体音量 - static const char * VIBRATION_REMINDER_TOGGLEBUTTON = "VibrationReminderToggleButton";//震动提醒 - static const char * SILENT_MODEL_TOGGLEBUTTON = "SilentModeToggleButton"; //静音模式 + /* ----------------------------------- 图片 ----------------------------------- */ + static constexpr const char *PNG_SYSTEM_VOLUME_IMAGE = "/user/res/SoundAndVibration/SYSTEM_VOLUME.bin"; // 系统音量图片 + 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 *MEDIAVOLUMEBUTTON = "MediaVolumeButton"; // 媒体音量按钮ID + static const char *VIBRATION_REMINDER_TOGGLEBUTTON = "VibrationReminderToggleButton"; // 震动提醒 + static const char *SILENT_MODEL_TOGGLEBUTTON = "SilentModeToggleButton"; // 静音模式 class SoundAndVibrationPresenter; class SoundAndVibrationView : public View { public: + struct ImageConfig + { + int x; + int y; + int w; + int h; + const char *ImageSrc; + }; + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; // 字体大小 + int16_t lineHeigh; // 行高 + const char *text; // 文本 + uint8_t lineBreakMode; // 断行模式。 + }; + struct ButtonConfig + { + int x; + int y; + int w; + int h; + const char *ViewId; + const char *ImageSrc; + }; SoundAndVibrationView(); virtual ~SoundAndVibrationView(); static SoundAndVibrationView *GetInstance(void); @@ -33,25 +64,28 @@ namespace OHOS private: void InitView(void); - void DeInit(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); private: - UIViewGroup *container_ = nullptr; UIScrollView *SoundAndVibrationScrollView = nullptr; - UILabel *SoundAndVibrationLabel = nullptr; + UILabel *Title = nullptr; UIButton *SystemVolumeButton = nullptr; UIButton *CallVolumeButton = nullptr; - UIImageView *image1 = nullptr; - UIImageView *image2 = nullptr; - UIImageView *SilentModeImage = nullptr; - UILabel *SilentModeLabe_ = nullptr; - UIToggleButton * VibrationReminderToggleButton = nullptr; - UILabel *SilentModeLabel = nullptr; - UIImageView *VibrationReminderImage = nullptr; - UIToggleButton *SilentModeToggleButton = nullptr; - UILabel *VibrationReminderLabel = nullptr; UIButton *MediaVolumeButton = nullptr; + UIImageView *Background[2]{nullptr}; // 放组件的背景 + UILabel *VibrationReminderLabel = nullptr; // 震动提醒 + UILabel *SilentModeLabel = nullptr; // 静音模式 + UILabel *SilentModeLabel_ = nullptr; // 系统音量不受影响 + UIToggleButton *VibrationReminderToggleButton = nullptr; + UIToggleButton *SilentModeToggleButton = nullptr; + + bool initViewStatus{false}; }; } // namespace OHOS -#endif \ No newline at end of file +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h new file mode 100644 index 000000000..9c6803d5f --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationVolumeSettingView.h @@ -0,0 +1,36 @@ +#ifndef SOUND_AND_VIBRATION_VOLUME_SETTING_H +#define SOUND_AND_VIBRATION_VOLUME_SETTING_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.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" + + class SoundAndVibrationVolumeSettingView + { + public: + SoundAndVibrationVolumeSettingView(); + ~SoundAndVibrationVolumeSettingView(); + static SoundAndVibrationVolumeSettingView *GetInstance(void); + UIViewGroup * SetUpVolumeProcess(void); + void ClearAll(void); + private: + UIViewGroup *group{nullptr}; + UISlider *VolumeProcess{nullptr}; + UIImageView *VolumeVetor{nullptr}; + bool initViewStatus{false}; + }; + +} +#endif \ No newline at end of file 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 aa5ba647f..b45eadebd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumeView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SystemVolumeView.h @@ -3,10 +3,8 @@ #include "BaseView.h" #include "View.h" - #include "components/ui_view_group.h" -#include "components/ui_slider.h" -#include "components/ui_image_view.h" +#include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h" namespace OHOS { static const char *SYSTEM_VOLUME_SLIDER = "SystemVolumeSlider"; @@ -25,15 +23,11 @@ namespace OHOS void OnTearDownView() override; void OnStop() override; - private: - UIView::OnDragListener *draglistener{nullptr}; - UIView::OnClickListener *sliderClick{nullptr}; - UIView::OnDragListener *sliderDrag{nullptr}; - void InitView(void); + UIViewGroup * SystemVolumeViewInit(void); - UIViewGroup *container_ = nullptr; - UISlider *SystemVolumeslider = nullptr; - UIImageView *SystemVolumeimageicon = nullptr; + private: + UIViewGroup *group{nullptr}; + SoundAndVibrationVolumeSettingView *p_SoundAndVibrationVolumeSettingView{nullptr}; }; } // namespace OHOS 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 f897635e6..c9df18bc2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp @@ -1,10 +1,6 @@ -#include "common/image_cache_manager.h" -#include "UiConfig.h" -#include "ui_resource_image.h" - #include "soundandvibration/include/SoundAndVibrationView.h" #include "soundandvibration/include/SoundAndVibrationPresenter.h" - +#include "wearable_log.h" /* 按优先级分为 1.系统音量 @@ -26,371 +22,310 @@ namespace OHOS SoundAndVibrationView::SoundAndVibrationView() { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SoundAndVibrationView"); g_pSoundAndVibrationView = this; } SoundAndVibrationView::~SoundAndVibrationView() { - DeInit(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::~SoundAndVibrationView"); + ClearAll(); g_pSoundAndVibrationView = nullptr; } SoundAndVibrationView *SoundAndVibrationView::GetInstance() { - return g_pSoundAndVibrationView; } - void SoundAndVibrationView::InitView(void) + + void SoundAndVibrationView::ClearAll() { - if (container_ == nullptr) + if (initViewStatus == true) { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - UIView::OnDragListener *draglistener = static_cast(SoundAndVibrationPresenter::GetInstance()); - if (draglistener == nullptr) + SoundAndVibrationScrollView->RemoveAll(); + delete Title; + Title = nullptr; + delete SystemVolumeButton; + SystemVolumeButton = nullptr; + delete CallVolumeButton; + CallVolumeButton = nullptr; + delete MediaVolumeButton; + MediaVolumeButton = nullptr; + for (int i = 0; i < 2; i++) { - return; + delete Background[i]; + Background[i] = nullptr; } - container_->SetOnDragListener(draglistener); - container_->SetTouchable(true); - container_->SetDraggable(true); + delete VibrationReminderLabel; + VibrationReminderLabel = nullptr; + delete SilentModeLabel; + SilentModeLabel = nullptr; + delete SilentModeLabel_; + SilentModeLabel_ = nullptr; + delete VibrationReminderToggleButton; + VibrationReminderToggleButton = nullptr; + delete SilentModeToggleButton; + SilentModeToggleButton = nullptr; + delete SoundAndVibrationScrollView; + SoundAndVibrationScrollView = nullptr; } - /***********************************************************************************************************/ - // Add ScrollView to App + } + + bool SoundAndVibrationView::SetUpSoundAndVibrationScrollView(void) + { + SoundAndVibrationScrollView = new UIScrollView(); if (SoundAndVibrationScrollView == nullptr) { - SoundAndVibrationScrollView = new UIScrollView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new SoundAndVibrationScrollView fail!"); + return false; } - SoundAndVibrationScrollView->SetPosition(0, 0); - SoundAndVibrationScrollView->Resize(466, 466); - SoundAndVibrationScrollView->SetViewId("SoundAndVibrationScrollView"); + SoundAndVibrationScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); SoundAndVibrationScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - // Add to rootView - container_->Add(SoundAndVibrationScrollView); - SoundAndVibrationScrollView->SetVisible(true); - /***********************************************************************************************************/ - // Add Label to App - if (SoundAndVibrationLabel == nullptr) + SoundAndVibrationScrollView->SetScrollBlankSize(35); + SoundAndVibrationScrollView->SetReboundSize(50); + SoundAndVibrationScrollView->SetDirection(1); + UIView::OnDragListener *draglistener = static_cast(SoundAndVibrationPresenter::GetInstance()); + if (draglistener == nullptr) { - SoundAndVibrationLabel = new UILabel(); + return false; } - SoundAndVibrationLabel->SetPosition(158, 52); - SoundAndVibrationLabel->Resize(200, 60); - SoundAndVibrationLabel->SetViewId("SoundAndVibrationLabel"); - SoundAndVibrationLabel->SetStyle(STYLE_TEXT_FONT, 30); - SoundAndVibrationLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - // Set additional property - SoundAndVibrationLabel->SetText("声音与震动"); - SoundAndVibrationLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - SoundAndVibrationLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - SoundAndVibrationLabel->SetRollSpeed(6); - SoundAndVibrationLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - // Add to scrollView - SoundAndVibrationScrollView->Add(SoundAndVibrationLabel); - SoundAndVibrationLabel->SetVisible(true); - /***********************************************************************************************************/ - // Add SystemVolumeButton to App - if (SystemVolumeButton == nullptr) - { - SystemVolumeButton = new UIButton(); - } - SystemVolumeButton->SetPosition(43, 120); - SystemVolumeButton->Resize(380, 100); - SystemVolumeButton->SetViewId(SYSTEM_VOLUME_BUTTON); - SystemVolumeButton->SetStyle(STYLE_BORDER_RADIUS, 50); - // Set additional property - SystemVolumeButton->SetImageSrc(PNG_SYSTEM_VOLUME_IMAGE, nullptr); - SystemVolumeButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - SystemVolumeButton->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED); + SoundAndVibrationScrollView->SetOnDragListener(draglistener); + SoundAndVibrationScrollView->SetTouchable(true); + SoundAndVibrationScrollView->SetDraggable(true); - // Add the CallBack about events - UIView::OnClickListener *SystemVolumeButtonClick = static_cast(SoundAndVibrationPresenter::GetInstance()); - SystemVolumeButton->SetOnClickListener(SystemVolumeButtonClick); - // Add to scrollView1 - SoundAndVibrationScrollView->Add(SystemVolumeButton); - SystemVolumeButton->SetVisible(true); - /***********************************************************************************************************/ - // Add CallVolumeButton to App - if (CallVolumeButton == nullptr) - { - CallVolumeButton = new UIButton(); - } - CallVolumeButton->SetPosition(43, 240); - CallVolumeButton->Resize(380, 100); - CallVolumeButton->SetViewId(CALL_VOLUME_BUTTON); - CallVolumeButton->SetStyle(STYLE_BORDER_RADIUS, 50); - CallVolumeButton->SetImageSrc(PNG_CALL_VOLUME_IMAGE, nullptr); - CallVolumeButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - CallVolumeButton->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED); - // Add the CallBack about events - UIView::OnClickListener *CallVolumeButtonClick = static_cast(SoundAndVibrationPresenter::GetInstance()); - CallVolumeButton->SetOnClickListener(CallVolumeButtonClick); - // Add to SoundAndVibrationScrollView - SoundAndVibrationScrollView->Add(CallVolumeButton); - CallVolumeButton->SetVisible(true); - /***********************************************************************************************************/ - // Add MediaVolumeButton to App - if (MediaVolumeButton == nullptr) + return true; + } + + // 设置标题 + bool SoundAndVibrationView::SetUpTitle(void) + { + Title = new UILabel(); + if (Title == nullptr) { - MediaVolumeButton = new UIButton(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new Title fail!"); + return false; } - MediaVolumeButton->SetPosition(43, 360); - MediaVolumeButton->Resize(380, 100); - MediaVolumeButton->SetViewId(MEDIAVOLUMEBUTTON); + 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); - MediaVolumeButton->SetImageSrc(PNG_MEDIA_VOLUME_IMAGE, nullptr); - MediaVolumeButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + return true; + } - // Add the CallBack about events - UIView::OnClickListener *MediaVolumeButtonClick = static_cast(SoundAndVibrationPresenter::GetInstance()); - MediaVolumeButton->SetOnClickListener(MediaVolumeButtonClick); - // Add to scrollView1 - SoundAndVibrationScrollView->Add(MediaVolumeButton); - MediaVolumeButton->SetVisible(true); - /***********************************************************************************************************/ - if (VibrationReminderImage == nullptr) - { - VibrationReminderImage = new UIImageView(); - } - VibrationReminderImage->SetPosition(43, 480); - VibrationReminderImage->Resize(100, 100); - VibrationReminderImage->SetViewId("VibrationReminderImage"); - VibrationReminderImage->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - VibrationReminderImage->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - VibrationReminderImage->SetStyle(STYLE_BORDER_RADIUS, 50); - VibrationReminderImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); - SoundAndVibrationScrollView->Add(VibrationReminderImage); - VibrationReminderImage->SetVisible(true); - /***********************************************************************************************************/ - // Add Label to App - if (VibrationReminderLabel == nullptr) - { - VibrationReminderLabel = new UILabel(); - } - VibrationReminderLabel->SetPosition(90, 513); // widget's left position and top position - VibrationReminderLabel->Resize(120, 35); // widget's width and height - VibrationReminderLabel->SetViewId("VibrationReminderLabel"); // Set style - VibrationReminderLabel->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - VibrationReminderLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - VibrationReminderLabel->SetStyle(STYLE_TEXT_FONT, 30); - VibrationReminderLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - // Set additional property - VibrationReminderLabel->SetText("震动提醒"); - VibrationReminderLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - VibrationReminderLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - VibrationReminderLabel->SetRollSpeed(6); - VibrationReminderLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - // Add to SoundAndVibrationScrollView - SoundAndVibrationScrollView->Add(VibrationReminderLabel); - VibrationReminderLabel->SetVisible(true); - /***********************************************************************************************************/ - // Add ToggleButton to App - if (VibrationReminderToggleButton == nullptr) - { - VibrationReminderToggleButton = new UIToggleButton(); - } - VibrationReminderToggleButton->SetPosition(298, 505); - VibrationReminderToggleButton->Resize(100, 50); - VibrationReminderToggleButton->SetViewId(VIBRATION_REMINDER_TOGGLEBUTTON); - VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - VibrationReminderToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE,PNG_TOGGLEBUTTON_OFF_IMAGE); - // Add the CallBack about events - UIView::OnClickListener *VibrationReminderToggleButtonClick = static_cast(SoundAndVibrationPresenter::GetInstance()); - VibrationReminderToggleButton->SetOnClickListener(VibrationReminderToggleButtonClick); - // Add to SoundAndVibrationScrollView - SoundAndVibrationScrollView->Add(VibrationReminderToggleButton); - VibrationReminderToggleButton->SetVisible(true); - /***********************************************************************************************************/ - // Add ImageView to App - if (SilentModeImage == nullptr) - { - SilentModeImage = new UIImageView(); - } - SilentModeImage->SetPosition(43, 600); - SilentModeImage->Resize(380, 100); - SilentModeImage->SetViewId("SilentModeImage"); - SilentModeImage->SetStyle(STYLE_BORDER_RADIUS, 50); - SilentModeImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE); - // Add to scrollView1 - SoundAndVibrationScrollView->Add(SilentModeImage); - SilentModeImage->SetVisible(true); - /***********************************************************************************************************/ - if (SilentModeLabel == nullptr) - { - SilentModeLabel = new UILabel(); - } - SilentModeLabel->SetPosition(90, 620); - SilentModeLabel->Resize(120, 35); - SilentModeLabel->SetViewId("SilentModeLabel"); - SilentModeLabel->SetStyle(STYLE_TEXT_FONT, 30); - SilentModeLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - // Set additional property - SilentModeLabel->SetText("静音模式"); - SilentModeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - SilentModeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - SilentModeLabel->SetRollSpeed(6); - SilentModeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - // Add to SoundAndVibrationScrollView - SoundAndVibrationScrollView->Add(SilentModeLabel); - SilentModeLabel->SetVisible(true); - /***********************************************************************************************************/ - if (SilentModeLabe_ == nullptr) - { - SilentModeLabe_ = new UILabel(); - } - SilentModeLabe_->SetPosition(90, 657); - SilentModeLabe_->Resize(160, 23); - SilentModeLabe_->SetViewId("label9"); - SilentModeLabe_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - SilentModeLabe_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - SilentModeLabe_->SetStyle(STYLE_TEXT_FONT, 20); - SilentModeLabe_->SetStyle(STYLE_LINE_HEIGHT, 23); - // Set additional property - SilentModeLabe_->SetText("系统音量不受影响"); - SilentModeLabe_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - SilentModeLabe_->SetTextColor(Color::GetColorFromRGBA(0xfd, 0xfd, 0xfd, 0x7f)); - SilentModeLabe_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - SilentModeLabe_->SetRollSpeed(6); - SilentModeLabe_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); - // Add to SoundAndVibrationScrollView - SoundAndVibrationScrollView->Add(SilentModeLabe_); - SilentModeLabe_->SetVisible(true); - /***********************************************************************************************************/ - // Add SilentModeToggleButton to App - if (SilentModeToggleButton == nullptr) - { - SilentModeToggleButton = new UIToggleButton(); - } - SilentModeToggleButton->SetPosition(298, 625); - SilentModeToggleButton->Resize(100, 50); - SilentModeToggleButton->SetViewId(SILENT_MODEL_TOGGLEBUTTON); - SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - SilentModeToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE,PNG_TOGGLEBUTTON_OFF_IMAGE); - UIView::OnClickListener *SilentModeToggleButtonClick = static_cast(SoundAndVibrationPresenter::GetInstance()); - SilentModeToggleButton->SetOnClickListener(SilentModeToggleButtonClick); - // Add to scrollView1 - SoundAndVibrationScrollView->Add(SilentModeToggleButton); - SilentModeToggleButton->SetVisible(true); - /***********************************************************************************************************/ - // Add ImageView to App - if (image1 == nullptr) + /// @brief 设置按钮 + /// @param button + /// @return true 设置成功,false 失败 + UIButton *SoundAndVibrationView::SetUpButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener) + { + UIButton *button = new UIButton(); + if (button == nullptr) { - image1 = new UIImageView(); + return nullptr; } - image1->SetPosition(183, 18); - image1->Resize(100, 100); - image1->SetViewId("image1"); + 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->SetOnClickListener(clickListener); + return button; + } - SoundAndVibrationScrollView->Add(image1); - image1->SetVisible(true); - /***********************************************************************************************************/ - // Add ImageView to App - if (image2 == nullptr) + // 设置图片 + UIImageView *SoundAndVibrationView::SetUpImageVIew(ImageConfig &imageconfig) + { + UIImageView *Image = new UIImageView(); + if (Image == nullptr) { - image2 = new UIImageView(); + return nullptr; } - image2->SetPosition(183, 668); - image2->Resize(100, 100); - image2->SetViewId("image2"); - - SoundAndVibrationScrollView->Add(image2); - image2->SetVisible(true); + Image->SetPosition(imageconfig.x, imageconfig.y, imageconfig.w, imageconfig.h); + Image->SetSrc(imageconfig.ImageSrc); + return Image; } - void SoundAndVibrationView::DeInit() + // 设置标签 + UILabel *SoundAndVibrationView::SetUpLabel(LabelConfig &labelConfig) { - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - if (SoundAndVibrationScrollView != nullptr) - { - delete SoundAndVibrationScrollView; - SoundAndVibrationScrollView = nullptr; - } - if (SoundAndVibrationLabel != nullptr) + UILabel *label = new UILabel(); + if (label == nullptr) { - delete SoundAndVibrationLabel; - SoundAndVibrationLabel = nullptr; + return nullptr; } - if (SystemVolumeButton != 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->SetText(labelConfig.text); // 内容 + label->SetLineBreakMode(labelConfig.lineBreakMode); // 断行模式。 + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize); + return label; + } + void SoundAndVibrationView::InitView(void) + { + if (SetUpSoundAndVibrationScrollView() == false) { - delete SystemVolumeButton; - SystemVolumeButton = nullptr; + return; } - if (CallVolumeButton != nullptr) + if (SetUpTitle() == false) { - delete CallVolumeButton; - CallVolumeButton = nullptr; + return; } - if (image1 != nullptr) + UIView::OnClickListener *ButtonClick = static_cast(SoundAndVibrationPresenter::GetInstance()); + /* --------------------------- 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) { - delete image1; - image1 = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetTheButton: SystemVolumeButton is nullptr!"); + return; } - if (image2 != nullptr) + /* ---------------------------- CallVolumeButton ---------------------------- */ + buttonconfig.y = 240; + buttonconfig.ViewId = CALL_VOLUME_BUTTON; + buttonconfig.ImageSrc = PNG_CALL_VOLUME_IMAGE; + CallVolumeButton = SetUpButton(buttonconfig, ButtonClick); + if (SystemVolumeButton == nullptr) { - delete image2; - image2 = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetTheButton: CallVolumeButton is nullptr!"); + return; } - if (SilentModeImage != nullptr) + /* ---------------------------- MediaVolumeButton --------------------------- */ + buttonconfig.y = 360; + buttonconfig.ViewId = MEDIAVOLUMEBUTTON; + buttonconfig.ImageSrc = PNG_MEDIA_VOLUME_IMAGE; + MediaVolumeButton = SetUpButton(buttonconfig, ButtonClick); + if (SystemVolumeButton == nullptr) { - delete SilentModeImage; - SilentModeImage = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetTheButton: MediaVolumeButton is nullptr!"); + return; } - if (SilentModeLabe_ != nullptr) + /* ------------------------------- Background ------------------------------- */ + ImageConfig imageconfig = { + .x = 43, + .y = 480, + .w = 380, + .h = 100, + .ImageSrc = "/user/res/SETTING_BACKGROUND.bin", + }; + Background[0] = SetUpImageVIew(imageconfig); + if (Background[0] == nullptr) { - delete SilentModeLabe_; - SilentModeLabe_ = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Background[0] new fail!"); + return; } - if (VibrationReminderToggleButton != nullptr) + imageconfig.y = 600; + Background[1] = SetUpImageVIew(imageconfig); + if (Background[1] == nullptr) { - delete VibrationReminderToggleButton; - VibrationReminderToggleButton = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Background[1] new fail!"); + return; } - if (SilentModeLabel != nullptr) + /* ------------------------- VibrationReminderLabel ------------------------- */ + LabelConfig labelConfig = { + .left = 90, + .top = 513, + .width = 120, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "震动提醒", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + VibrationReminderLabel = SetUpLabel(labelConfig); + if (VibrationReminderLabel == nullptr) { - delete SilentModeLabel; - SilentModeLabel = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::VibrationReminderLabel is nullptr!"); + return; } - if (VibrationReminderImage != nullptr) + /* ----------------------------- SilentModeLabel ---------------------------- */ + labelConfig.top = 620; + labelConfig.text = "静音模式"; + SilentModeLabel = SetUpLabel(labelConfig); + if (SilentModeLabel == nullptr) { - delete VibrationReminderImage; - VibrationReminderImage = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeLabel is nullptr!"); + return; } - if (SilentModeToggleButton != nullptr) + /* ---------------------------- SilentModeLabel_ ---------------------------- */ + labelConfig.top = 657; + labelConfig.text = "系统音量不受影响"; + labelConfig.fontSize = 20; + labelConfig.lineHeigh = 23; + SilentModeLabel_ = SetUpLabel(labelConfig); + if (SilentModeLabel_ == nullptr) { - delete SilentModeToggleButton; - SilentModeToggleButton = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeLabel_ is nullptr!"); + return; } - if (VibrationReminderLabel != nullptr) + SilentModeLabel_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + SilentModeLabel_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SilentModeLabel_->SetTextColor(Color::GetColorFromRGBA(0xfd, 0xfd, 0xfd, 0x7f)); + /* ---------------------- VibrationReminderToggleButton --------------------- */ + VibrationReminderToggleButton = new UIToggleButton(); + if (VibrationReminderToggleButton == nullptr) { - delete VibrationReminderLabel; - VibrationReminderLabel = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::VibrationReminderToggleButton new fail!"); + return; } - if (MediaVolumeButton != nullptr) + VibrationReminderToggleButton->SetPosition(298, 505, 100, 50); + VibrationReminderToggleButton->SetViewId(VIBRATION_REMINDER_TOGGLEBUTTON); + VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + const char *ToggleButtonSelect = "/user/res/TOGGLEBUTTON_ON.bin"; + const char *ToggleButtonUnSelect = "/user/res/TOGGLEBUTTON_OFF.bin"; + VibrationReminderToggleButton->SetImages(ToggleButtonSelect, ToggleButtonUnSelect); + VibrationReminderToggleButton->SetOnClickListener(ButtonClick); + /* ------------------------- SilentModeToggleButton ------------------------- */ + SilentModeToggleButton = new UIToggleButton(); + if (SilentModeToggleButton == nullptr) { - delete MediaVolumeButton; - MediaVolumeButton = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeToggleButton new fail!"); + return; } + SilentModeToggleButton->SetPosition(298, 625, 100, 50); + SilentModeToggleButton->SetViewId(SILENT_MODEL_TOGGLEBUTTON); + SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + SilentModeToggleButton->SetImages(ToggleButtonSelect, ToggleButtonUnSelect); + SilentModeToggleButton->SetOnClickListener(ButtonClick); + + initViewStatus = true; } void SoundAndVibrationView::OnStart() { View::OnStart(); InitView(); - RootView::GetInstance()->Add(container_); } void SoundAndVibrationView::OnSetUpView() { - View::OnSetUpView(); + SoundAndVibrationScrollView->Add(Title); + SoundAndVibrationScrollView->Add(SystemVolumeButton); + SoundAndVibrationScrollView->Add(CallVolumeButton); + SoundAndVibrationScrollView->Add(MediaVolumeButton); + SoundAndVibrationScrollView->Add(Background[0]); + SoundAndVibrationScrollView->Add(Background[1]); + SoundAndVibrationScrollView->Add(VibrationReminderLabel); + SoundAndVibrationScrollView->Add(SilentModeLabel); + SoundAndVibrationScrollView->Add(SilentModeLabel_); + SoundAndVibrationScrollView->Add(VibrationReminderToggleButton); + SoundAndVibrationScrollView->Add(SilentModeToggleButton); + RootView::GetInstance()->Add(SoundAndVibrationScrollView); Draw(); } @@ -408,4 +343,4 @@ namespace OHOS RootView::GetInstance()->RemoveAll(); return; } -} \ No newline at end of file +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp new file mode 100644 index 000000000..4f65e773c --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingView.cpp @@ -0,0 +1,106 @@ +#include "soundandvibration/include/SoundAndVibrationVolumeSettingView.h" +#include "wearable_log.h" + +namespace OHOS +{ + static SoundAndVibrationVolumeSettingView *g_pSoundAndVibrationVolumeSettingView{nullptr}; + + SoundAndVibrationVolumeSettingView::SoundAndVibrationVolumeSettingView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::SoundAndVibrationVolumeSettingView"); + + g_pSoundAndVibrationVolumeSettingView = this; + } + + SoundAndVibrationVolumeSettingView::~SoundAndVibrationVolumeSettingView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::~SoundAndVibrationVolumeSettingView"); + ClearAll(); + g_pSoundAndVibrationVolumeSettingView = nullptr; + } + + SoundAndVibrationVolumeSettingView *SoundAndVibrationVolumeSettingView::GetInstance(void) + { + return g_pSoundAndVibrationVolumeSettingView; + } + + void SoundAndVibrationVolumeSettingView::ClearAll(void) + { + if (initViewStatus == true) + { + group->RemoveAll(); + delete VolumeProcess; + VolumeProcess = nullptr; + delete VolumeVetor; + VolumeVetor = nullptr; + delete group; + group = nullptr; + } + } + + UIViewGroup *SoundAndVibrationVolumeSettingView::SetUpVolumeProcess(void) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationVolumeSettingView::group new fail"); + return nullptr; + } + group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + group->SetDraggable(true); + group->SetTouchable(true); + /* ------------------------------ VolumeProcess ----------------------------- */ + 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()); + /* ------------------------------- VolumeVetor ------------------------------ */ + VolumeVetor = new UIImageView(); + if (VolumeVetor == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VolumeVetor new fail"); + return nullptr; + } + VolumeVetor->SetPosition(213, 213, 40, 40); + const char *image = "/user/res/VolumeControlVector.bin"; + VolumeVetor->SetSrc(image); + + // if (listener == nullptr) + // { + // listener = new VolumeSliderEventListener(); + // if (listener == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "listener new fail"); + // return false; + // } + // } + // progress->SetSliderEventListener(listener); + // 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); + initViewStatus = true; + return group; + } + +} \ 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 a781c47a8..0a94a4c1b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SystemVolumeView.cpp @@ -1,7 +1,6 @@ #include "soundandvibration/include/SystemVolumeView.h" #include "soundandvibration/include/SystemVolumePresenter.h" -#include "UiConfig.h" - +#include "wearable_log.h" /* 系统音量: 通话,提醒,查找手表的音量 @@ -19,22 +18,8 @@ namespace OHOS SystemVolumeView::~SystemVolumeView() { - g_pSystemVolumeView = nullptr; - if (container_ != nullptr) - { - delete container_; - container_ = nullptr; - } - if (SystemVolumeslider != nullptr) - { - delete SystemVolumeslider; - SystemVolumeslider = nullptr; - } - if (SystemVolumeimageicon != nullptr) - { - delete SystemVolumeimageicon; - SystemVolumeimageicon = nullptr; - } + delete p_SoundAndVibrationVolumeSettingView; + p_SoundAndVibrationVolumeSettingView = nullptr; } SystemVolumeView *SystemVolumeView::GetInstance() @@ -42,71 +27,34 @@ namespace OHOS return g_pSystemVolumeView; } - void SystemVolumeView::InitView(void) + UIViewGroup *SystemVolumeView::SystemVolumeViewInit(void) { - if (container_ == nullptr) - { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - container_->SetStyle(STYLE_BACKGROUND_COLOR, 0x000000); - } - draglistener = static_cast(SystemVolumePresenter::GetInstance()); - container_->SetOnDragListener(draglistener); - container_->SetTouchable(true); - container_->SetDraggable(true); - /********************************************************************************************************/ - if (SystemVolumeslider == nullptr) + p_SoundAndVibrationVolumeSettingView = new SoundAndVibrationVolumeSettingView(); + if (p_SoundAndVibrationVolumeSettingView == nullptr) { - SystemVolumeslider = new UISlider(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::p_SoundAndVibrationVolumeSettingView is nullptr!"); + return nullptr; } - SystemVolumeslider->SetPosition(167, 77); - SystemVolumeslider->Resize(130, 310); - SystemVolumeslider->SetViewId(SYSTEM_VOLUME_SLIDER); - SystemVolumeslider->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - SystemVolumeslider->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - SystemVolumeslider->SetStyle(STYLE_BORDER_OPA, 0x19); - SystemVolumeslider->SetStyle(STYLE_BORDER_RADIUS, 100); - SystemVolumeslider->SetDirection(UISlider::Direction::DIR_BOTTOM_TO_TOP); - SystemVolumeslider->SetValue(50); - SystemVolumeslider->SetSliderColor(Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff)); - SystemVolumeslider->SetKnobStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - SystemVolumeslider->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff); - SystemVolumeslider->SetBackgroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND); // 圆帽式 - SystemVolumeslider->SetForegroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND); // 设置进度条的前景样式。圆帽式 - SystemVolumeslider->SetStyle(STYLE_BORDER_COLOR, Color::Black().full); - SystemVolumeslider->SetStyle(STYLE_BORDER_WIDTH,2); - sliderClick = static_cast(SystemVolumePresenter::GetInstance()); // 用来处理之后点击slider的点击事件 - SystemVolumeslider->SetOnClickListener(sliderClick); - sliderDrag = static_cast(SystemVolumePresenter::GetInstance()); // 用来处理之后拖动slider的拖动事件 - SystemVolumeslider->SetOnDragListener(sliderDrag); - container_->Add(SystemVolumeslider); - SystemVolumeslider->SetVisible(true); - /********************************************************************************************************/ - if (SystemVolumeimageicon == nullptr) + group = p_SoundAndVibrationVolumeSettingView->SetUpVolumeProcess(); + if (group == nullptr) { - SystemVolumeimageicon = new UIImageView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemVolumeView::group is nullptr!"); + return nullptr; } - SystemVolumeimageicon->SetPosition(213, 213); // widget's left position and top position - SystemVolumeimageicon->Resize(100, 100); // widget's width and height - SystemVolumeimageicon->SetViewId("SystemVolumeimageicon"); // Set style - SystemVolumeimageicon->SetStyle(STYLE_BORDER_COLOR, 0xffAAAAAA); - SystemVolumeimageicon->SetSrc(PNG_VOLUME_CONTROL_VECTOR); - container_->Add(SystemVolumeimageicon); - SystemVolumeimageicon->SetVisible(true); + return group; } void SystemVolumeView::OnStart() { View::OnStart(); - InitView(); - RootView::GetInstance()->Add(container_); + SystemVolumeViewInit(); } void SystemVolumeView::OnSetUpView() { View::OnSetUpView(); + RootView::GetInstance()->Add(group); Draw(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp index 6e126acf1..ac9f3f43e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp @@ -53,6 +53,8 @@ namespace OHOS SystemLanguageButton = nullptr; delete FactoryResetButton; FactoryResetButton = nullptr; + delete SystemScrollView[SYSTEMVIEW]; + SystemScrollView[SYSTEMVIEW] = nullptr; } } diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/CALL_VOLUME.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SoundAndVibration/CALL_VOLUME.bin similarity index 100% rename from code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/CALL_VOLUME.bin rename to code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SoundAndVibration/CALL_VOLUME.bin diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/MEDIA_VOLUME.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SoundAndVibration/MEDIA_VOLUME.bin similarity index 100% rename from code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/MEDIA_VOLUME.bin rename to code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SoundAndVibration/MEDIA_VOLUME.bin diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SYSTEM_VOLUME.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SoundAndVibration/SYSTEM_VOLUME.bin similarity index 100% rename from code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SYSTEM_VOLUME.bin rename to code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/SoundAndVibration/SYSTEM_VOLUME.bin