+#include "stress/include/stressTestFailView.h"
+#include "stress/include/stressTestPresenter.h"
+#include "stress/include/stressTestModel.h"
+#include "UiConfig.h"
+
+
+namespace OHOS
+{
+ StressTestFailView::StressTestFailView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestFailView::StressTestFailView");
+ }
+
+ StressTestFailView::~StressTestFailView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestFailView::~StressTestFailView");
+ ClearAll();
+ }
+
+ void StressTestFailView::ClearAll(void)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestFailView::ClearAll");
+ }
+
+ UIViewGroup *StressTestFailView::CreateStressTestFailView1(void)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestFailView::CreateStressTestFailView1");
+ if (group == nullptr)
+ {
+ group = new UIViewGroup();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail!!");
+ return nullptr;
+ }
+ group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ group->SetViewId(STRESS_TEST_FAIL_VIEW_ID);
+ group->SetTouchable(true);
+ group->SetDraggable(true);
+ group->SetOnDragListener((UIView::OnDragListener *)OHOS::StressTestPresenter::GetInstance());
+ }
+ if(scrollView == nullptr)
+ {
+ scrollView = new UIScrollView();
+ if (scrollView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail!!");
+ return nullptr;
+ }
+ scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ scrollView->SetTouchable(true);
+ scrollView->SetDraggable(true);
+ group->Add(scrollView);
+ }
+ if (titleLabel == nullptr)
+ {
+ titleLabel = new UILabelExt();
+ if (titleLabel == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel new fail!!");
+ return nullptr;
+ }
+ titleLabel->SetPosition(83, 50,300,35);
+ titleLabel->SetText("检测不到结果");
+ titleLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ titleLabel->SetStyle(STYLE_TEXT_FONT, 30);
+ titleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+ titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+ titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ scrollView->Add(titleLabel);
+ }
+ if(imageView == nullptr)
+ {
+ imageView = new UIImageView();
+ if (imageView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imageView new fail!!");
+ return nullptr;
+ }
+ imageView->SetPosition(193, 111, 80, 80);
+ imageView->SetSrc(PNG_ATTENTION_IMAGE);
+ scrollView->Add(imageView);
+ }
+ if(error1DescriptionLabel == nullptr)
+ {
+ error1DescriptionLabel = new UILabelExt();
+ if (error1DescriptionLabel == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "error1DescriptionLabel new fail!!");
+ return nullptr;
+ }
+ error1DescriptionLabel->SetPosition(33, 208, 400, 105);
+ error1DescriptionLabel->SetText("请确认已带上手表,并保持静止,准备好后点击下方按钮进行重新检测");
+ error1DescriptionLabel->SetStyle(STYLE_TEXT_FONT, 30);
+ error1DescriptionLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+ error1DescriptionLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ error1DescriptionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ error1DescriptionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ error1DescriptionLabel->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff));
+ scrollView->Add(error1DescriptionLabel);
+ }
+ if(retryTestButton == nullptr)
+ {
+ retryTestButton = new UILabelButtonExt();
+ if (retryTestButton == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "retryTestButton new fail!!");
+ return nullptr;
+ }
+ retryTestButton->SetPosition(118, 334,230,80);
+ retryTestButton->SetText("重试检测");
+ retryTestButton->SetAlign(TEXT_ALIGNMENT_CENTER);
+ retryTestButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ retryTestButton->SetViewId(RETRY_TEST_BUTTON_ID);
+ retryTestButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff0d62ff);
+ retryTestButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
+ retryTestButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+ retryTestButton->SetOnClickListener((UIView::OnClickListener *)OHOS::StressTestPresenter::GetInstance());
+ scrollView->Add(retryTestButton);
+
+ }
+ if(stopTestButton == nullptr)
+ {
+ stopTestButton = new UILabelButtonExt();
+ if (stopTestButton == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stopTestButton new fail!!");
+ return nullptr;
+ }
+ stopTestButton->SetPosition(118, 434,230,80);
+ stopTestButton->SetText("停止检测");
+ stopTestButton->SetAlign(TEXT_ALIGNMENT_CENTER);
+ stopTestButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ stopTestButton->SetViewId(STOP_TEST_BUTTON_ID);
+ stopTestButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+ stopTestButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
+ stopTestButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+ stopTestButton->SetOnClickListener((UIView::OnClickListener *)OHOS::StressTestPresenter::GetInstance());
+ scrollView->Add(stopTestButton);
+ }
+
+ return group;
+ }
+
+ UIViewGroup *StressTestFailView::CreateStressTestFailView2(void)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestFailView::CreateStressTestFailView2");
+ if (group == nullptr)
+ {
+ group = new UIViewGroup();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail!!");
+ return nullptr;
+ }
+ group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ group->SetViewId(STRESS_TEST_FAIL_VIEW_ID);
+ group->SetTouchable(true);
+ group->SetDraggable(true);
+ group->SetOnDragListener((UIView::OnDragListener *)OHOS::StressTestPresenter::GetInstance());
+ }
+ if(scrollView == nullptr)
+ {
+ scrollView = new UIScrollView();
+ if (scrollView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView new fail!!");
+ return nullptr;
+ }
+ scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ scrollView->SetTouchable(true);
+ scrollView->SetDraggable(true);
+ group->Add(scrollView);
+ }
+ if (titleLabel == nullptr)
+ {
+ titleLabel = new UILabelExt();
+ if (titleLabel == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel new fail!!");
+ return nullptr;
+ }
+ titleLabel->SetPosition(83, 50,300,35);
+ titleLabel->SetText("检测不到结果");
+ titleLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ titleLabel->SetStyle(STYLE_TEXT_FONT, 30);
+ titleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+ titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+ titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ scrollView->Add(titleLabel);
+ }
+ if(imageView == nullptr)
+ {
+ imageView = new UIImageView();
+ if (imageView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imageView new fail!!");
+ return nullptr;
+ }
+ imageView->SetPosition(193, 111, 80, 80);
+ imageView->SetSrc(PNG_ATTENTION_IMAGE);
+ scrollView->Add(imageView);
+ }
+ if(error1DescriptionLabel == nullptr)
+ {
+ error1DescriptionLabel = new UILabelExt();
+ if (error1DescriptionLabel == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "error1DescriptionLabel new fail!!");
+ return nullptr;
+ }
+ error1DescriptionLabel->SetPosition(53, 230, 360, 70);
+ error1DescriptionLabel->SetText("请确认已带上手表,并保持静止");
+ error1DescriptionLabel->SetStyle(STYLE_TEXT_FONT, 30);
+ error1DescriptionLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+ error1DescriptionLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ error1DescriptionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ error1DescriptionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ error1DescriptionLabel->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff));
+ scrollView->Add(error1DescriptionLabel);
+ }
+ if(retryButton == nullptr)
+ {
+ retryButton = new UILabelButtonExt();
+ if (retryButton == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "retryButton new fail!!");
+ return nullptr;
+ }
+ retryButton->SetPosition(238, 328,170,90);
+ retryButton->SetText("重测");
+ retryButton->SetAlign(TEXT_ALIGNMENT_CENTER);
+ retryButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ retryButton->SetViewId(RETRY_BUTTON_ID);
+ retryButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff0d62ff);
+ retryButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
+ retryButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+ retryButton->SetOnClickListener((UIView::OnClickListener *)OHOS::StressTestPresenter::GetInstance());
+ scrollView->Add(retryButton);
+
+ }
+ if(stopButton == nullptr)
+ {
+ stopButton = new UILabelButtonExt();
+ if (stopButton == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stopButton new fail!!");
+ return nullptr;
+ }
+ stopButton->SetPosition(58, 328,170,90);
+ stopButton->SetText("停止");
+ stopButton->SetAlign(TEXT_ALIGNMENT_CENTER);
+ stopButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ stopButton->SetViewId(STOP_BUTTON_ID);
+ stopButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+ stopButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
+ stopButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+ stopButton->SetOnClickListener((UIView::OnClickListener *)OHOS::StressTestPresenter::GetInstance());
+ scrollView->Add(stopButton);
+ }
+
+ return group;
+ }
+
+ UIViewGroup *StressTestFailView::CreateStressTestFailView(void)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestFailView::CreateStressTestFailView");
+ if (StressTestPresenter::GetInstance()->GetCurrentFailType() == FAIL_TYPE_NOT_WORN)
+ {
+ return CreateStressTestFailView1();
+ }
+ else if (StressTestPresenter::GetInstance()->GetCurrentFailType() == FAIL_TYPE_INVALID_DATA)
+ {
+ return CreateStressTestFailView2();
+ }
+ return nullptr;
+ }
+}
\ No newline at end of file
+#include "stress/include/stressTestingView.h"
+#include "stress/include/stressTestPresenter.h"
+
+namespace OHOS
+{
+ StressTestingView::StressTestingView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestingView::StressTestingView");
+ }
+
+ StressTestingView::~StressTestingView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestingView::~StressTestingView");
+ ClearAll();
+ }
+
+ void StressTestingView::ClearAll(void)
+ {
+ if (group != nullptr)
+ {
+ group->RemoveAll();
+ delete group;
+ group = nullptr;
+ }
+ if (titleLabel != nullptr)
+ {
+ delete titleLabel;
+ titleLabel = nullptr;
+ }
+ if (cancelButton != nullptr)
+ {
+ delete cancelButton;
+ cancelButton = nullptr;
+ }
+ }
+
+ UIViewGroup *StressTestingView::CreateStressTestingView(void)
+ {
+ if (group == nullptr)
+ {
+ group = new UIViewGroup();
+ if (group == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestingView::CreateStressTestingView new group fail!!");
+ return nullptr;
+ }
+ group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ group->SetViewId(STRESSTESTINGVIEW_ID);
+ group->SetTouchable(true);
+ group->SetDraggable(true);
+ group->SetOnDragListener((UIView::OnDragListener *)OHOS::StressTestPresenter::GetInstance());
+ }
+ if (titleLabel == nullptr)
+ {
+ titleLabel = new UILabelExt();
+ if (titleLabel == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestingView::CreateStressTestingView new titleLabel fail!!");
+ return nullptr;
+ }
+ titleLabel->SetPosition(83, 50,300,35);
+ titleLabel->SetText("压力");
+ titleLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ titleLabel->SetStyle(STYLE_TEXT_FONT, 30);
+ titleLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+ titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+ titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ group->Add(titleLabel);
+ }
+ if (cancelButton == nullptr)
+ {
+ cancelButton = new UILabelButtonExt();
+ if (cancelButton == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestingView::CreateStressTestingView new cancelButton fail!!");
+ return nullptr;
+ }
+ cancelButton->SetPosition(93, 330,280,90);
+ cancelButton->SetText("取消检测");
+ cancelButton->SetAlign(TEXT_ALIGNMENT_CENTER);
+ cancelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ cancelButton->SetViewId(CANCEL_BUTTON_ID);
+ cancelButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff0d62ff);
+ cancelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
+ cancelButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+ cancelButton->SetOnClickListener((UIView::OnClickListener *)OHOS::StressTestPresenter::GetInstance());
+ group->Add(cancelButton);
+ }
+
+ return group;
+ }
+}
\ No newline at end of file