-#include "common/image_cache_manager.h"\r
-#include "UiConfig.h"\r
-#include "ui_resource_image.h"\r
-\r
#include "soundandvibration/include/SoundAndVibrationView.h"\r
#include "soundandvibration/include/SoundAndVibrationPresenter.h"\r
-\r
+#include "wearable_log.h"\r
/*\r
按优先级分为\r
1.系统音量\r
\r
SoundAndVibrationView::SoundAndVibrationView()\r
{\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SoundAndVibrationView");\r
g_pSoundAndVibrationView = this;\r
}\r
\r
SoundAndVibrationView::~SoundAndVibrationView()\r
{\r
- DeInit();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::~SoundAndVibrationView");\r
+ ClearAll();\r
g_pSoundAndVibrationView = nullptr;\r
}\r
\r
SoundAndVibrationView *SoundAndVibrationView::GetInstance()\r
{\r
-\r
return g_pSoundAndVibrationView;\r
}\r
- void SoundAndVibrationView::InitView(void)\r
+\r
+ void SoundAndVibrationView::ClearAll()\r
{\r
- if (container_ == nullptr)\r
+ if (initViewStatus == true)\r
{\r
- container_ = new UIViewGroup();\r
- container_->SetPosition(0, 0, 466, 466);\r
- container_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
- UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(SoundAndVibrationPresenter::GetInstance());\r
- if (draglistener == nullptr)\r
+ SoundAndVibrationScrollView->RemoveAll();\r
+ delete Title;\r
+ Title = nullptr;\r
+ delete SystemVolumeButton;\r
+ SystemVolumeButton = nullptr;\r
+ delete CallVolumeButton;\r
+ CallVolumeButton = nullptr;\r
+ delete MediaVolumeButton;\r
+ MediaVolumeButton = nullptr;\r
+ for (int i = 0; i < 2; i++)\r
{\r
- return;\r
+ delete Background[i];\r
+ Background[i] = nullptr;\r
}\r
- container_->SetOnDragListener(draglistener);\r
- container_->SetTouchable(true);\r
- container_->SetDraggable(true);\r
+ delete VibrationReminderLabel;\r
+ VibrationReminderLabel = nullptr;\r
+ delete SilentModeLabel;\r
+ SilentModeLabel = nullptr;\r
+ delete SilentModeLabel_;\r
+ SilentModeLabel_ = nullptr;\r
+ delete VibrationReminderToggleButton;\r
+ VibrationReminderToggleButton = nullptr;\r
+ delete SilentModeToggleButton;\r
+ SilentModeToggleButton = nullptr;\r
+ delete SoundAndVibrationScrollView;\r
+ SoundAndVibrationScrollView = nullptr;\r
}\r
- /***********************************************************************************************************/\r
- // Add ScrollView to App\r
+ }\r
+\r
+ bool SoundAndVibrationView::SetUpSoundAndVibrationScrollView(void)\r
+ {\r
+ SoundAndVibrationScrollView = new UIScrollView();\r
if (SoundAndVibrationScrollView == nullptr)\r
{\r
- SoundAndVibrationScrollView = new UIScrollView();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new SoundAndVibrationScrollView fail!");\r
+ return false;\r
}\r
- SoundAndVibrationScrollView->SetPosition(0, 0); \r
- SoundAndVibrationScrollView->Resize(466, 466); \r
- SoundAndVibrationScrollView->SetViewId("SoundAndVibrationScrollView");\r
+ SoundAndVibrationScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
SoundAndVibrationScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
- // Add to rootView\r
- container_->Add(SoundAndVibrationScrollView);\r
- SoundAndVibrationScrollView->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add Label to App\r
- if (SoundAndVibrationLabel == nullptr)\r
+ SoundAndVibrationScrollView->SetScrollBlankSize(35);\r
+ SoundAndVibrationScrollView->SetReboundSize(50);\r
+ SoundAndVibrationScrollView->SetDirection(1);\r
+ UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(SoundAndVibrationPresenter::GetInstance());\r
+ if (draglistener == nullptr)\r
{\r
- SoundAndVibrationLabel = new UILabel();\r
+ return false;\r
}\r
- SoundAndVibrationLabel->SetPosition(158, 52); \r
- SoundAndVibrationLabel->Resize(200, 60); \r
- SoundAndVibrationLabel->SetViewId("SoundAndVibrationLabel");\r
- SoundAndVibrationLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
- SoundAndVibrationLabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
- // Set additional property\r
- SoundAndVibrationLabel->SetText("声音与震动");\r
- SoundAndVibrationLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- SoundAndVibrationLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- SoundAndVibrationLabel->SetRollSpeed(6);\r
- SoundAndVibrationLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
- // Add to scrollView\r
- SoundAndVibrationScrollView->Add(SoundAndVibrationLabel);\r
- SoundAndVibrationLabel->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add SystemVolumeButton to App\r
- if (SystemVolumeButton == nullptr)\r
- {\r
- SystemVolumeButton = new UIButton();\r
- }\r
- SystemVolumeButton->SetPosition(43, 120); \r
- SystemVolumeButton->Resize(380, 100); \r
- SystemVolumeButton->SetViewId(SYSTEM_VOLUME_BUTTON);\r
- SystemVolumeButton->SetStyle(STYLE_BORDER_RADIUS, 50);\r
- // Set additional property\r
- SystemVolumeButton->SetImageSrc(PNG_SYSTEM_VOLUME_IMAGE, nullptr);\r
- SystemVolumeButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
- SystemVolumeButton->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED);\r
+ SoundAndVibrationScrollView->SetOnDragListener(draglistener);\r
+ SoundAndVibrationScrollView->SetTouchable(true);\r
+ SoundAndVibrationScrollView->SetDraggable(true);\r
\r
- // Add the CallBack about events\r
- UIView::OnClickListener *SystemVolumeButtonClick = static_cast<UIView::OnClickListener *>(SoundAndVibrationPresenter::GetInstance());\r
- SystemVolumeButton->SetOnClickListener(SystemVolumeButtonClick);\r
- // Add to scrollView1\r
- SoundAndVibrationScrollView->Add(SystemVolumeButton);\r
- SystemVolumeButton->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add CallVolumeButton to App\r
- if (CallVolumeButton == nullptr)\r
- {\r
- CallVolumeButton = new UIButton();\r
- }\r
- CallVolumeButton->SetPosition(43, 240); \r
- CallVolumeButton->Resize(380, 100); \r
- CallVolumeButton->SetViewId(CALL_VOLUME_BUTTON); \r
- CallVolumeButton->SetStyle(STYLE_BORDER_RADIUS, 50);\r
- CallVolumeButton->SetImageSrc(PNG_CALL_VOLUME_IMAGE, nullptr);\r
- CallVolumeButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
- CallVolumeButton->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED);\r
- // Add the CallBack about events\r
- UIView::OnClickListener *CallVolumeButtonClick = static_cast<UIView::OnClickListener *>(SoundAndVibrationPresenter::GetInstance());\r
- CallVolumeButton->SetOnClickListener(CallVolumeButtonClick);\r
- // Add to SoundAndVibrationScrollView\r
- SoundAndVibrationScrollView->Add(CallVolumeButton);\r
- CallVolumeButton->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add MediaVolumeButton to App\r
- if (MediaVolumeButton == nullptr)\r
+ return true;\r
+ }\r
+\r
+ // 设置标题\r
+ bool SoundAndVibrationView::SetUpTitle(void)\r
+ {\r
+ Title = new UILabel();\r
+ if (Title == nullptr)\r
{\r
- MediaVolumeButton = new UIButton();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::new Title fail!");\r
+ return false;\r
}\r
- MediaVolumeButton->SetPosition(43, 360); \r
- MediaVolumeButton->Resize(380, 100); \r
- MediaVolumeButton->SetViewId(MEDIAVOLUMEBUTTON);\r
+ Title->SetPosition(158, 52);\r
+ Title->SetStyle(STYLE_TEXT_FONT, 30);\r
+ Title->SetStyle(STYLE_LINE_HEIGHT, 35);\r
+ Title->SetText("声音与震动");\r
+ Title->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+ Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ Title->SetRollSpeed(6);\r
+ Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
\r
- MediaVolumeButton->SetImageSrc(PNG_MEDIA_VOLUME_IMAGE, nullptr);\r
- MediaVolumeButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+ return true;\r
+ }\r
\r
- // Add the CallBack about events\r
- UIView::OnClickListener *MediaVolumeButtonClick = static_cast<UIView::OnClickListener *>(SoundAndVibrationPresenter::GetInstance());\r
- MediaVolumeButton->SetOnClickListener(MediaVolumeButtonClick);\r
- // Add to scrollView1\r
- SoundAndVibrationScrollView->Add(MediaVolumeButton);\r
- MediaVolumeButton->SetVisible(true);\r
- /***********************************************************************************************************/\r
- if (VibrationReminderImage == nullptr)\r
- {\r
- VibrationReminderImage = new UIImageView();\r
- }\r
- VibrationReminderImage->SetPosition(43, 480); \r
- VibrationReminderImage->Resize(100, 100); \r
- VibrationReminderImage->SetViewId("VibrationReminderImage"); \r
- VibrationReminderImage->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
- VibrationReminderImage->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
- VibrationReminderImage->SetStyle(STYLE_BORDER_RADIUS, 50);\r
- VibrationReminderImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE);\r
- SoundAndVibrationScrollView->Add(VibrationReminderImage);\r
- VibrationReminderImage->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add Label to App\r
- if (VibrationReminderLabel == nullptr)\r
- {\r
- VibrationReminderLabel = new UILabel();\r
- }\r
- VibrationReminderLabel->SetPosition(90, 513); // widget's left position and top position\r
- VibrationReminderLabel->Resize(120, 35); // widget's width and height\r
- VibrationReminderLabel->SetViewId("VibrationReminderLabel"); // Set style\r
- VibrationReminderLabel->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
- VibrationReminderLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
- VibrationReminderLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
- VibrationReminderLabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
- // Set additional property\r
- VibrationReminderLabel->SetText("震动提醒");\r
- VibrationReminderLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- VibrationReminderLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- VibrationReminderLabel->SetRollSpeed(6);\r
- VibrationReminderLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
- // Add to SoundAndVibrationScrollView\r
- SoundAndVibrationScrollView->Add(VibrationReminderLabel);\r
- VibrationReminderLabel->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add ToggleButton to App\r
- if (VibrationReminderToggleButton == nullptr)\r
- {\r
- VibrationReminderToggleButton = new UIToggleButton();\r
- }\r
- VibrationReminderToggleButton->SetPosition(298, 505); \r
- VibrationReminderToggleButton->Resize(100, 50); \r
- VibrationReminderToggleButton->SetViewId(VIBRATION_REMINDER_TOGGLEBUTTON);\r
- VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
- VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
- VibrationReminderToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE,PNG_TOGGLEBUTTON_OFF_IMAGE);\r
- // Add the CallBack about events\r
- UIView::OnClickListener *VibrationReminderToggleButtonClick = static_cast<UIView::OnClickListener *>(SoundAndVibrationPresenter::GetInstance());\r
- VibrationReminderToggleButton->SetOnClickListener(VibrationReminderToggleButtonClick);\r
- // Add to SoundAndVibrationScrollView\r
- SoundAndVibrationScrollView->Add(VibrationReminderToggleButton);\r
- VibrationReminderToggleButton->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add ImageView to App\r
- if (SilentModeImage == nullptr)\r
- {\r
- SilentModeImage = new UIImageView();\r
- }\r
- SilentModeImage->SetPosition(43, 600); \r
- SilentModeImage->Resize(380, 100); \r
- SilentModeImage->SetViewId("SilentModeImage");\r
- SilentModeImage->SetStyle(STYLE_BORDER_RADIUS, 50);\r
- SilentModeImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE);\r
- // Add to scrollView1\r
- SoundAndVibrationScrollView->Add(SilentModeImage);\r
- SilentModeImage->SetVisible(true);\r
- /***********************************************************************************************************/\r
- if (SilentModeLabel == nullptr)\r
- {\r
- SilentModeLabel = new UILabel();\r
- }\r
- SilentModeLabel->SetPosition(90, 620); \r
- SilentModeLabel->Resize(120, 35); \r
- SilentModeLabel->SetViewId("SilentModeLabel");\r
- SilentModeLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
- SilentModeLabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
- // Set additional property\r
- SilentModeLabel->SetText("静音模式");\r
- SilentModeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- SilentModeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- SilentModeLabel->SetRollSpeed(6);\r
- SilentModeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
- // Add to SoundAndVibrationScrollView\r
- SoundAndVibrationScrollView->Add(SilentModeLabel);\r
- SilentModeLabel->SetVisible(true);\r
- /***********************************************************************************************************/\r
- if (SilentModeLabe_ == nullptr)\r
- {\r
- SilentModeLabe_ = new UILabel();\r
- }\r
- SilentModeLabe_->SetPosition(90, 657); \r
- SilentModeLabe_->Resize(160, 23); \r
- SilentModeLabe_->SetViewId("label9");\r
- SilentModeLabe_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
- SilentModeLabe_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
- SilentModeLabe_->SetStyle(STYLE_TEXT_FONT, 20);\r
- SilentModeLabe_->SetStyle(STYLE_LINE_HEIGHT, 23);\r
- // Set additional property\r
- SilentModeLabe_->SetText("系统音量不受影响");\r
- SilentModeLabe_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- SilentModeLabe_->SetTextColor(Color::GetColorFromRGBA(0xfd, 0xfd, 0xfd, 0x7f));\r
- SilentModeLabe_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- SilentModeLabe_->SetRollSpeed(6);\r
- SilentModeLabe_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);\r
- // Add to SoundAndVibrationScrollView\r
- SoundAndVibrationScrollView->Add(SilentModeLabe_);\r
- SilentModeLabe_->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add SilentModeToggleButton to App\r
- if (SilentModeToggleButton == nullptr)\r
- {\r
- SilentModeToggleButton = new UIToggleButton();\r
- }\r
- SilentModeToggleButton->SetPosition(298, 625); \r
- SilentModeToggleButton->Resize(100, 50); \r
- SilentModeToggleButton->SetViewId(SILENT_MODEL_TOGGLEBUTTON);\r
- SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
- SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
- SilentModeToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE,PNG_TOGGLEBUTTON_OFF_IMAGE);\r
- UIView::OnClickListener *SilentModeToggleButtonClick = static_cast<UIView::OnClickListener *>(SoundAndVibrationPresenter::GetInstance());\r
- SilentModeToggleButton->SetOnClickListener(SilentModeToggleButtonClick);\r
- // Add to scrollView1\r
- SoundAndVibrationScrollView->Add(SilentModeToggleButton);\r
- SilentModeToggleButton->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add ImageView to App\r
- if (image1 == nullptr)\r
+ /// @brief 设置按钮\r
+ /// @param button\r
+ /// @return true 设置成功,false 失败\r
+ UIButton *SoundAndVibrationView::SetUpButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener)\r
+ {\r
+ UIButton *button = new UIButton();\r
+ if (button == nullptr)\r
{\r
- image1 = new UIImageView();\r
+ return nullptr;\r
}\r
- image1->SetPosition(183, 18); \r
- image1->Resize(100, 100); \r
- image1->SetViewId("image1"); \r
+ button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h);\r
+ button->SetViewId(buttonconfig.ViewId);\r
+ button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc);\r
+ button->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
+ button->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+ button->SetOnClickListener(clickListener);\r
+ return button;\r
+ }\r
\r
- SoundAndVibrationScrollView->Add(image1);\r
- image1->SetVisible(true);\r
- /***********************************************************************************************************/\r
- // Add ImageView to App\r
- if (image2 == nullptr)\r
+ // 设置图片\r
+ UIImageView *SoundAndVibrationView::SetUpImageVIew(ImageConfig &imageconfig)\r
+ {\r
+ UIImageView *Image = new UIImageView();\r
+ if (Image == nullptr)\r
{\r
- image2 = new UIImageView();\r
+ return nullptr;\r
}\r
- image2->SetPosition(183, 668);\r
- image2->Resize(100, 100); \r
- image2->SetViewId("image2"); \r
-\r
- SoundAndVibrationScrollView->Add(image2);\r
- image2->SetVisible(true);\r
+ Image->SetPosition(imageconfig.x, imageconfig.y, imageconfig.w, imageconfig.h);\r
+ Image->SetSrc(imageconfig.ImageSrc);\r
+ return Image;\r
}\r
\r
- void SoundAndVibrationView::DeInit()\r
+ // 设置标签\r
+ UILabel *SoundAndVibrationView::SetUpLabel(LabelConfig &labelConfig)\r
{\r
- if (container_ != nullptr)\r
- {\r
- container_->RemoveAll();\r
- delete container_;\r
- container_ = nullptr;\r
- }\r
- if (SoundAndVibrationScrollView != nullptr)\r
- {\r
- delete SoundAndVibrationScrollView;\r
- SoundAndVibrationScrollView = nullptr;\r
- }\r
- if (SoundAndVibrationLabel != nullptr)\r
+ UILabel *label = new UILabel();\r
+ if (label == nullptr)\r
{\r
- delete SoundAndVibrationLabel;\r
- SoundAndVibrationLabel = nullptr;\r
+ return nullptr;\r
}\r
- if (SystemVolumeButton != nullptr)\r
+ label->SetPosition(labelConfig.left, labelConfig.top, labelConfig.width, labelConfig.height); // 位置大小\r
+ label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize); // 字体大小\r
+ label->SetStyle(STYLE_LINE_HEIGHT, labelConfig.lineHeigh); // 字体行高\r
+ label->SetText(labelConfig.text); // 内容\r
+ label->SetLineBreakMode(labelConfig.lineBreakMode); // 断行模式。\r
+ label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+ label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize);\r
+ return label;\r
+ }\r
+ void SoundAndVibrationView::InitView(void)\r
+ {\r
+ if (SetUpSoundAndVibrationScrollView() == false)\r
{\r
- delete SystemVolumeButton;\r
- SystemVolumeButton = nullptr;\r
+ return;\r
}\r
- if (CallVolumeButton != nullptr)\r
+ if (SetUpTitle() == false)\r
{\r
- delete CallVolumeButton;\r
- CallVolumeButton = nullptr;\r
+ return;\r
}\r
- if (image1 != nullptr)\r
+ UIView::OnClickListener *ButtonClick = static_cast<UIView::OnClickListener *>(SoundAndVibrationPresenter::GetInstance());\r
+ /* --------------------------- SystemVolumeButton --------------------------- */\r
+ ButtonConfig buttonconfig = {\r
+ .x = 43,\r
+ .y = 120,\r
+ .w = 380,\r
+ .h = 100,\r
+ .ViewId = SYSTEM_VOLUME_BUTTON,\r
+ .ImageSrc = PNG_SYSTEM_VOLUME_IMAGE,\r
+ };\r
+ SystemVolumeButton = SetUpButton(buttonconfig, ButtonClick);\r
+ if (SystemVolumeButton == nullptr)\r
{\r
- delete image1;\r
- image1 = nullptr;\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetTheButton: SystemVolumeButton is nullptr!");\r
+ return;\r
}\r
- if (image2 != nullptr)\r
+ /* ---------------------------- CallVolumeButton ---------------------------- */\r
+ buttonconfig.y = 240;\r
+ buttonconfig.ViewId = CALL_VOLUME_BUTTON;\r
+ buttonconfig.ImageSrc = PNG_CALL_VOLUME_IMAGE;\r
+ CallVolumeButton = SetUpButton(buttonconfig, ButtonClick);\r
+ if (SystemVolumeButton == nullptr)\r
{\r
- delete image2;\r
- image2 = nullptr;\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetTheButton: CallVolumeButton is nullptr!");\r
+ return;\r
}\r
- if (SilentModeImage != nullptr)\r
+ /* ---------------------------- MediaVolumeButton --------------------------- */\r
+ buttonconfig.y = 360;\r
+ buttonconfig.ViewId = MEDIAVOLUMEBUTTON;\r
+ buttonconfig.ImageSrc = PNG_MEDIA_VOLUME_IMAGE;\r
+ MediaVolumeButton = SetUpButton(buttonconfig, ButtonClick);\r
+ if (SystemVolumeButton == nullptr)\r
{\r
- delete SilentModeImage;\r
- SilentModeImage = nullptr;\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SoundAndVibrationView::SetTheButton: MediaVolumeButton is nullptr!");\r
+ return;\r
}\r
- if (SilentModeLabe_ != nullptr)\r
+ /* ------------------------------- Background ------------------------------- */\r
+ ImageConfig imageconfig = {\r
+ .x = 43,\r
+ .y = 480,\r
+ .w = 380,\r
+ .h = 100,\r
+ .ImageSrc = "/user/res/SETTING_BACKGROUND.bin",\r
+ };\r
+ Background[0] = SetUpImageVIew(imageconfig);\r
+ if (Background[0] == nullptr)\r
{\r
- delete SilentModeLabe_;\r
- SilentModeLabe_ = nullptr;\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Background[0] new fail!");\r
+ return;\r
}\r
- if (VibrationReminderToggleButton != nullptr)\r
+ imageconfig.y = 600;\r
+ Background[1] = SetUpImageVIew(imageconfig);\r
+ if (Background[1] == nullptr)\r
{\r
- delete VibrationReminderToggleButton;\r
- VibrationReminderToggleButton = nullptr;\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Background[1] new fail!");\r
+ return;\r
}\r
- if (SilentModeLabel != nullptr)\r
+ /* ------------------------- VibrationReminderLabel ------------------------- */\r
+ LabelConfig labelConfig = {\r
+ .left = 90,\r
+ .top = 513,\r
+ .width = 120,\r
+ .height = 35,\r
+ .fontSize = 30,\r
+ .lineHeigh = 35,\r
+ .text = "震动提醒",\r
+ .lineBreakMode = UILabel::LINE_BREAK_ADAPT,\r
+ };\r
+ VibrationReminderLabel = SetUpLabel(labelConfig);\r
+ if (VibrationReminderLabel == nullptr)\r
{\r
- delete SilentModeLabel;\r
- SilentModeLabel = nullptr;\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::VibrationReminderLabel is nullptr!");\r
+ return;\r
}\r
- if (VibrationReminderImage != nullptr)\r
+ /* ----------------------------- SilentModeLabel ---------------------------- */\r
+ labelConfig.top = 620;\r
+ labelConfig.text = "静音模式";\r
+ SilentModeLabel = SetUpLabel(labelConfig);\r
+ if (SilentModeLabel == nullptr)\r
{\r
- delete VibrationReminderImage;\r
- VibrationReminderImage = nullptr;\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeLabel is nullptr!");\r
+ return;\r
}\r
- if (SilentModeToggleButton != nullptr)\r
+ /* ---------------------------- SilentModeLabel_ ---------------------------- */\r
+ labelConfig.top = 657;\r
+ labelConfig.text = "系统音量不受影响";\r
+ labelConfig.fontSize = 20;\r
+ labelConfig.lineHeigh = 23;\r
+ SilentModeLabel_ = SetUpLabel(labelConfig);\r
+ if (SilentModeLabel_ == nullptr)\r
{\r
- delete SilentModeToggleButton;\r
- SilentModeToggleButton = nullptr;\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeLabel_ is nullptr!");\r
+ return;\r
}\r
- if (VibrationReminderLabel != nullptr)\r
+ SilentModeLabel_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+ SilentModeLabel_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
+ SilentModeLabel_->SetTextColor(Color::GetColorFromRGBA(0xfd, 0xfd, 0xfd, 0x7f));\r
+ /* ---------------------- VibrationReminderToggleButton --------------------- */\r
+ VibrationReminderToggleButton = new UIToggleButton();\r
+ if (VibrationReminderToggleButton == nullptr)\r
{\r
- delete VibrationReminderLabel;\r
- VibrationReminderLabel = nullptr;\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::VibrationReminderToggleButton new fail!");\r
+ return;\r
}\r
- if (MediaVolumeButton != nullptr)\r
+ VibrationReminderToggleButton->SetPosition(298, 505, 100, 50);\r
+ VibrationReminderToggleButton->SetViewId(VIBRATION_REMINDER_TOGGLEBUTTON);\r
+ VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+ VibrationReminderToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+ const char *ToggleButtonSelect = "/user/res/TOGGLEBUTTON_ON.bin";\r
+ const char *ToggleButtonUnSelect = "/user/res/TOGGLEBUTTON_OFF.bin";\r
+ VibrationReminderToggleButton->SetImages(ToggleButtonSelect, ToggleButtonUnSelect);\r
+ VibrationReminderToggleButton->SetOnClickListener(ButtonClick);\r
+ /* ------------------------- SilentModeToggleButton ------------------------- */\r
+ SilentModeToggleButton = new UIToggleButton();\r
+ if (SilentModeToggleButton == nullptr)\r
{\r
- delete MediaVolumeButton;\r
- MediaVolumeButton = nullptr;\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SilentModeToggleButton new fail!");\r
+ return;\r
}\r
+ SilentModeToggleButton->SetPosition(298, 625, 100, 50);\r
+ SilentModeToggleButton->SetViewId(SILENT_MODEL_TOGGLEBUTTON);\r
+ SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+ SilentModeToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+ SilentModeToggleButton->SetImages(ToggleButtonSelect, ToggleButtonUnSelect);\r
+ SilentModeToggleButton->SetOnClickListener(ButtonClick);\r
+\r
+ initViewStatus = true;\r
}\r
\r
void SoundAndVibrationView::OnStart()\r
{\r
View<SoundAndVibrationPresenter>::OnStart();\r
InitView();\r
- RootView::GetInstance()->Add(container_);\r
}\r
\r
void SoundAndVibrationView::OnSetUpView()\r
{\r
-\r
View<SoundAndVibrationPresenter>::OnSetUpView();\r
+ SoundAndVibrationScrollView->Add(Title);\r
+ SoundAndVibrationScrollView->Add(SystemVolumeButton);\r
+ SoundAndVibrationScrollView->Add(CallVolumeButton);\r
+ SoundAndVibrationScrollView->Add(MediaVolumeButton);\r
+ SoundAndVibrationScrollView->Add(Background[0]);\r
+ SoundAndVibrationScrollView->Add(Background[1]);\r
+ SoundAndVibrationScrollView->Add(VibrationReminderLabel);\r
+ SoundAndVibrationScrollView->Add(SilentModeLabel);\r
+ SoundAndVibrationScrollView->Add(SilentModeLabel_);\r
+ SoundAndVibrationScrollView->Add(VibrationReminderToggleButton);\r
+ SoundAndVibrationScrollView->Add(SilentModeToggleButton);\r
+ RootView::GetInstance()->Add(SoundAndVibrationScrollView);\r
Draw();\r
}\r
\r
RootView::GetInstance()->RemoveAll();\r
return;\r
}\r
-}
\ No newline at end of file
+}\r