#include "secondaryfunction/include/SecondaryFunctionView.h"\r
#include "secondaryfunction/include/SecondaryFunctionPresenter.h"\r
-\r
-#include "UiConfig.h"\r
+#include "common/image_cache_manager.h"\r
namespace OHOS\r
{\r
\r
\r
SecondaryFunctionView::SecondaryFunctionView()\r
{\r
-\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SecondaryFunctionView::SecondaryFunctionView");\r
g_pSecondaryFunctionView = this;\r
}\r
\r
SecondaryFunctionView::~SecondaryFunctionView()\r
{\r
- DeInitView();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SecondaryFunctionView::~SecondaryFunctionView");\r
+ ClearAll();\r
g_pSecondaryFunctionView = nullptr;\r
}\r
\r
SecondaryFunctionView *SecondaryFunctionView::GetInstance()\r
{\r
-\r
return g_pSecondaryFunctionView;\r
}\r
\r
- void SecondaryFunctionView::InitView(void)\r
+ void SecondaryFunctionView::ClearAll(void)\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 *>(SecondaryFunctionPresenter::GetInstance());\r
- if (draglistener == nullptr)\r
+ SecondaryFunctionScrollView->RemoveAll();\r
+\r
+ delete SecondaryFunctionScrollTitleLabel;\r
+ SecondaryFunctionScrollTitleLabel = nullptr;\r
+\r
+ delete QuickAccessLabel;\r
+ QuickAccessLabel = nullptr;\r
+\r
+ delete FastTrainingLabel;\r
+ FastTrainingLabel = nullptr;\r
+\r
+ delete QuickAccessButton;\r
+ QuickAccessButton = nullptr;\r
+\r
+ delete FastTrainingButton;\r
+ FastTrainingButton = nullptr;\r
+\r
+ for (int i = 0; i < 2; i++)\r
{\r
- return;\r
+ delete Image[i];\r
+ Image[i] = nullptr;\r
}\r
- container_->SetOnDragListener(draglistener);\r
- container_->SetTouchable(true);\r
- container_->SetDraggable(true);\r
- }\r
- // Add Label to App\r
- if (label1_ == nullptr)\r
- {\r
- label1_ = new UILabel();\r
+\r
+ delete SecondaryFunctionScrollView;\r
+ SecondaryFunctionScrollView = nullptr;\r
}\r
- label1_->SetPosition(172, 52);\r
- label1_->SetStyle(STYLE_TEXT_FONT, 30);\r
- label1_->SetStyle(STYLE_LINE_HEIGHT, 35);\r
- label1_->SetText("辅助功能");\r
- label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
- container_->Add(label1_);\r
- label1_->SetVisible(true);\r
-\r
- // Add Button to App\r
- if (SECONDARY_FUNCTION_BUTTON1 == nullptr)\r
+ }\r
+\r
+ // 设置图片\r
+ UIImageView *SecondaryFunctionView::SetUpImageView(ImageConfig &imageconfig)\r
+ {\r
+ UIImageView *Image = new UIImageView();\r
+ if (Image == nullptr)\r
{\r
- SECONDARY_FUNCTION_BUTTON1 = new UIButton();\r
+ return nullptr;\r
}\r
- SECONDARY_FUNCTION_BUTTON1->SetPosition(43, 120);\r
- SECONDARY_FUNCTION_BUTTON1->Resize(380, 100);\r
- SECONDARY_FUNCTION_BUTTON1->SetViewId(SECONDARY_FUNCTION_BUTTON1ID);\r
- SECONDARY_FUNCTION_BUTTON1->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
- SECONDARY_FUNCTION_BUTTON1->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
- SECONDARY_FUNCTION_BUTTON1->SetStyle(STYLE_BORDER_OPA, 0x00);\r
- SECONDARY_FUNCTION_BUTTON1->SetStyle(STYLE_BORDER_COLOR, 0xffffffff);\r
- SECONDARY_FUNCTION_BUTTON1->SetImageSrc(PNG_SETTING_BACKGROUND_IMAGE, nullptr);\r
- SECONDARY_FUNCTION_BUTTON1->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffafafa, UIButton::PRESSED);\r
- SECONDARY_FUNCTION_BUTTON1->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);\r
- SECONDARY_FUNCTION_BUTTON1->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
- SECONDARY_FUNCTION_BUTTON1->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED);\r
- // Add the CallBack about events\r
- UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(SecondaryFunctionPresenter::GetInstance());\r
- SECONDARY_FUNCTION_BUTTON1->SetOnClickListener(button1Click);\r
- // Add to rootView\r
- container_->Add(SECONDARY_FUNCTION_BUTTON1);\r
- SECONDARY_FUNCTION_BUTTON1->SetVisible(true);\r
-\r
- // Add Label to App\r
- if (label2_ == nullptr)\r
+ Image->SetPosition(imageconfig.x, imageconfig.y, imageconfig.w, imageconfig.h);\r
+ Image->SetSrc(imageconfig.ImageSrc);\r
+ return Image;\r
+ }\r
+\r
+ // 设置标签\r
+ UILabel *SecondaryFunctionView::SetUpLabel(LabelConfig &labelconfig)\r
+ {\r
+ UILabel *label = new UILabel();\r
+ if (label == nullptr)\r
{\r
- label2_ = new UILabel();\r
+ return nullptr;\r
}\r
- label2_->SetPosition(90, 153);\r
- label2_->SetStyle(STYLE_TEXT_FONT, 30);\r
- label2_->SetStyle(STYLE_LINE_HEIGHT, 35);\r
- // Set additional property\r
- label2_->SetText("快速访问");\r
- label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- label2_->SetRollSpeed(0);\r
- label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
- // Add to rootView\r
- container_->Add(label2_);\r
- label2_->SetVisible(true);\r
-\r
- // Add ImageView to App\r
- if (image3_ == 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
+\r
+ bool SecondaryFunctionView::SecondaryFunctionScrollViewInit(void)\r
+ {\r
+ SecondaryFunctionScrollView = new UIScrollView();\r
+ if (SecondaryFunctionScrollView == nullptr)\r
{\r
- image3_ = new UIImageView();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView::SecondaryFunctionScrollView new fail!");\r
+ return false;\r
}\r
- image3_->SetPosition(369, 157);\r
- image3_->SetSrc(PNG_SETTING_NEXT_IMAGE);\r
- // Add to rootView\r
- container_->Add(image3_);\r
- image3_->SetVisible(true);\r
-\r
- // Add Button to App\r
- if (SECONDARY_FUNCTION_BUTTON2 == nullptr)\r
+ SecondaryFunctionScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+ UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(SecondaryFunctionPresenter::GetInstance());\r
+ if (draglistener == nullptr)\r
{\r
- SECONDARY_FUNCTION_BUTTON2 = new UIButton();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView::draglistener can not be nullptr!");\r
+ return false;\r
}\r
- SECONDARY_FUNCTION_BUTTON2->SetPosition(43, 240);\r
- SECONDARY_FUNCTION_BUTTON2->Resize(380, 100);\r
- SECONDARY_FUNCTION_BUTTON2->SetViewId(SECONDARY_FUNCTION_BUTTON2ID);\r
- SECONDARY_FUNCTION_BUTTON2->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
- SECONDARY_FUNCTION_BUTTON2->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
- SECONDARY_FUNCTION_BUTTON2->SetStyle(STYLE_BORDER_OPA, 0x00);\r
- SECONDARY_FUNCTION_BUTTON2->SetStyle(STYLE_BORDER_COLOR, 0xffffffff);\r
- SECONDARY_FUNCTION_BUTTON2->SetImageSrc(PNG_SETTING_BACKGROUND_IMAGE, nullptr);\r
- SECONDARY_FUNCTION_BUTTON2->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
- SECONDARY_FUNCTION_BUTTON2->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED);\r
- // Add the CallBack about events\r
- UIView::OnClickListener *button2Click = static_cast<UIView::OnClickListener *>(SecondaryFunctionPresenter::GetInstance());\r
- SECONDARY_FUNCTION_BUTTON2->SetOnClickListener(button2Click);\r
- // Add to rootView\r
- container_->Add(SECONDARY_FUNCTION_BUTTON2);\r
- SECONDARY_FUNCTION_BUTTON2->SetVisible(true);\r
- // Add Label to App\r
- if (label4_ == nullptr)\r
+ SecondaryFunctionScrollView->SetOnDragListener(draglistener);\r
+ SecondaryFunctionScrollView->SetTouchable(true);\r
+ SecondaryFunctionScrollView->SetDraggable(true);\r
+ return true;\r
+ }\r
+\r
+ bool SecondaryFunctionView::SecondaryFunctionScrollButtonInit(void)\r
+ {\r
+ QuickAccessButton = new UIButton();\r
+ if (QuickAccessButton == nullptr)\r
{\r
- label4_ = new UILabel();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::QuickAccessButton new fail!");\r
+ return false;\r
}\r
- label4_->SetPosition(90, 273);\r
- label4_->SetStyle(STYLE_TEXT_FONT, 30);\r
- label4_->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-\r
- // Set additional property\r
- label4_->SetText("快速训练");\r
- label4_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
- label4_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
- label4_->SetRollSpeed(0);\r
- label4_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
- // Add to rootView\r
- container_->Add(label4_);\r
- label4_->SetVisible(true);\r
-\r
- // Add ImageView to App\r
- if (image4_ == nullptr)\r
+ QuickAccessButton->SetPosition(43, 120, 380, 100);\r
+ QuickAccessButton->SetViewId(SECONDARY_FUNCTION_QUICK_ACCESS_BUTTON);\r
+ QuickAccessButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+ QuickAccessButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff4fc34c, UIButton::PRESSED);\r
+ QuickAccessButton->SetStyleForState(STYLE_BORDER_COLOR, 0xffffffff, UIButton::PRESSED);\r
+ QuickAccessButton->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED);\r
+\r
+ FastTrainingButton = new UIButton();\r
+ if (FastTrainingButton == nullptr)\r
{\r
- image4_ = new UIImageView();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ClassicBlueToothView::FastTrainingButton new fail!");\r
+ return false;\r
}\r
- image4_->SetPosition(369, 277);\r
- image4_->SetSrc(PNG_SETTING_NEXT_IMAGE);\r
- // Add to rootView\r
- container_->Add(image4_);\r
- image4_->SetVisible(true);\r
+ FastTrainingButton->SetPosition(43, 240, 380, 100);\r
+ FastTrainingButton->SetViewId(SECONDARY_FUNCTION_FAST_TRAINING_BUTTON);\r
+ FastTrainingButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+ FastTrainingButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff4fc34c, UIButton::PRESSED);\r
+ FastTrainingButton->SetStyleForState(STYLE_BORDER_COLOR, 0xffffffff, UIButton::PRESSED);\r
+ FastTrainingButton->SetStyleForState(STYLE_BORDER_OPA, 0x00, UIButton::PRESSED);\r
+\r
+ UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(SecondaryFunctionPresenter::GetInstance());\r
+ QuickAccessButton->SetOnClickListener(clickListener);\r
+ FastTrainingButton->SetOnClickListener(clickListener);\r
+\r
+ return true;\r
}\r
- void SecondaryFunctionView::DeInitView(void)\r
+\r
+ bool SecondaryFunctionView::SecondaryFunctionScrollLabelInit(void)\r
{\r
- if (container_ != nullptr)\r
+ // 创建ScreenDurationTitleLabel\r
+ LabelConfig labelconfig = {\r
+ .left = 173,\r
+ .top = 52,\r
+ .width = 120,\r
+ .height = 35,\r
+ .fontSize = 30,\r
+ .lineHeigh = 35,\r
+ .text = "辅助功能",\r
+ .lineBreakMode = UILabel::LINE_BREAK_ADAPT,\r
+ };\r
+\r
+ SecondaryFunctionScrollTitleLabel = SetUpLabel(labelconfig);\r
+ if (nullptr == SecondaryFunctionScrollTitleLabel)\r
{\r
- container_->RemoveAll();\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView::SecondaryFunctionScrollTitleLabel is nullptr!");\r
+ return false;\r
}\r
- if (label1_ != nullptr)\r
+\r
+ labelconfig.left = 90;\r
+ labelconfig.top = 153;\r
+ labelconfig.text = "快速访问";\r
+ QuickAccessLabel = SetUpLabel(labelconfig);\r
+ if (nullptr == SecondaryFunctionScrollTitleLabel)\r
{\r
- delete label1_;\r
- label1_ = nullptr;\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView::QuickAccessLabel is nullptr!");\r
+ return false;\r
}\r
- if (SECONDARY_FUNCTION_BUTTON1 != nullptr)\r
+\r
+ labelconfig.top = 273;\r
+ labelconfig.text = "快速训练";\r
+ FastTrainingLabel = SetUpLabel(labelconfig);\r
+ if (nullptr == SecondaryFunctionScrollTitleLabel)\r
{\r
- delete SECONDARY_FUNCTION_BUTTON1;\r
- SECONDARY_FUNCTION_BUTTON1 = nullptr;\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView::FastTrainingLabel is nullptr!");\r
+ return false;\r
}\r
- if (image3_ != nullptr)\r
+\r
+ return true;\r
+ }\r
+\r
+ bool SecondaryFunctionView::SecondaryFunctionScrollImageInit(void)\r
+ {\r
+ ImageConfig imageconfig = {\r
+ .x = 369,\r
+ .y = 157,\r
+ .w = 14,\r
+ .h = 26,\r
+ .ImageSrc = "/user/res/SETTING_NEXT.bin",\r
+ };\r
+\r
+ for (int i = 0; i < 2; i++)\r
{\r
- delete image3_;\r
- image3_ = nullptr;\r
+ imageconfig.y = 157 + (i * 120);\r
+ Image[i] = SetUpImageView(imageconfig);\r
+ if (Image[i] == nullptr)\r
+ {\r
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView::Image[%d] is nullptr!", i);\r
+ return false;\r
+ }\r
}\r
- if (label2_ != nullptr)\r
+ return true;\r
+ }\r
+\r
+ // 辅助功能视图初始化\r
+ void SecondaryFunctionView::SecondaryFunctionViewInit(void)\r
+ {\r
+ if (!SecondaryFunctionScrollViewInit())\r
{\r
- delete label2_;\r
- label2_ = nullptr;\r
+ return;\r
}\r
- if (SECONDARY_FUNCTION_BUTTON2 != nullptr)\r
+\r
+ if (!SecondaryFunctionScrollLabelInit())\r
{\r
- delete SECONDARY_FUNCTION_BUTTON2;\r
- SECONDARY_FUNCTION_BUTTON2 = nullptr;\r
+ return;\r
}\r
- if (image4_ != nullptr)\r
+\r
+ if (!SecondaryFunctionScrollButtonInit())\r
{\r
- delete image4_;\r
- image4_ = nullptr;\r
+ return;\r
}\r
- if (label4_ != nullptr)\r
+\r
+ if (!SecondaryFunctionScrollImageInit())\r
{\r
- delete label4_;\r
- label4_ = nullptr;\r
+ return;\r
}\r
- delete container_;\r
- container_ = nullptr;\r
+ initViewStatus = true;\r
}\r
\r
void SecondaryFunctionView::OnStart()\r
{\r
View<SecondaryFunctionPresenter>::OnStart();\r
- InitView();\r
- RootView::GetInstance()->Add(container_);\r
+ SecondaryFunctionViewInit();\r
}\r
\r
void SecondaryFunctionView::OnSetUpView()\r
{\r
-\r
View<SecondaryFunctionPresenter>::OnSetUpView();\r
+ SecondaryFunctionScrollView->Add(SecondaryFunctionScrollTitleLabel);\r
+ SecondaryFunctionScrollView->Add(QuickAccessButton);\r
+ SecondaryFunctionScrollView->Add(FastTrainingButton);\r
+ SecondaryFunctionScrollView->Add(QuickAccessLabel);\r
+ SecondaryFunctionScrollView->Add(FastTrainingLabel);\r
+ SecondaryFunctionScrollView->Add(Image[0]);\r
+ SecondaryFunctionScrollView->Add(Image[1]);\r
+ RootView::GetInstance()->Add(SecondaryFunctionScrollView);\r
Draw();\r
}\r
\r