From 23ece690bb5b8e13bcec1f6ede63eb8bf9b22531 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Wed, 22 Oct 2025 12:14:57 +0800 Subject: [PATCH] =?utf8?q?272=EF=BC=9A=E5=8E=8B=E5=8A=9B=E7=95=8C=E9=9D=A2?= =?utf8?q?=E6=B7=BB=E5=8A=A0=E5=8E=8B=E5=8A=9B=E7=BB=93=E6=9E=9C=E9=A1=B5?= =?utf8?q?=E9=9D=A2=EF=BC=8C=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91=E4=BC=98?= =?utf8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../stress/include/stressTestFailView.h | 53 ++--- .../stress/include/stressTestMainView.h | 4 +- .../nativeui/stress/include/stressTestModel.h | 36 ++- .../stress/include/stressTestPresenter.h | 5 +- .../stress/include/stressTestResultView.h | 31 +++ .../stress/include/stressTestStandbyView.h | 4 +- .../stress/include/stressTestUIConfig.h | 25 ++ .../stress/include/stressTestingView.h | 9 +- .../stress/src/stressTestFailView.cpp | 95 ++++++-- .../stress/src/stressTestMainView.cpp | 27 ++- .../nativeui/stress/src/stressTestModel.cpp | 76 ++++++ .../stress/src/stressTestPresenter.cpp | 39 +++- .../stress/src/stressTestResultView.cpp | 219 ++++++++++++++++++ .../stress/src/stressTestStandbyView.cpp | 53 ++++- .../nativeui/stress/src/stressTestingView.cpp | 4 +- 15 files changed, 592 insertions(+), 88 deletions(-) create mode 100644 code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestUIConfig.h diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestFailView.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestFailView.h index e123fa821..c9bc8a3c4 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestFailView.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestFailView.h @@ -9,34 +9,35 @@ namespace OHOS { - static constexpr const char *STRESS_TEST_FAIL_VIEW_ID = "STRESS_TEST_FAIL_VIEW_ID";//压力测试失败视图ID - static constexpr const char *STOP_TEST_BUTTON_ID = "STOP_TEST_BUTTON_ID";//停止检测按钮ID - static constexpr const char *RETRY_TEST_BUTTON_ID = "RETRY_TEST_BUTTON_ID";//重试检测按钮ID - static constexpr const char *STOP_BUTTON_ID = "STOP_BUTTON_ID";//停止按钮ID - static constexpr const char *RETRY_BUTTON_ID = "RETRY_BUTTON_ID";//重试按钮ID + static constexpr const char *STRESS_TEST_FAIL_VIEW_ID = "STRESS_TEST_FAIL_VIEW_ID"; // 压力测试失败视图ID + static constexpr const char *STOP_TEST_BUTTON_ID = "STOP_TEST_BUTTON_ID"; // 停止检测按钮ID + static constexpr const char *RETRY_TEST_BUTTON_ID = "RETRY_TEST_BUTTON_ID"; // 重试检测按钮ID + static constexpr const char *STOP_BUTTON_ID = "STOP_BUTTON_ID"; // 停止按钮ID + static constexpr const char *RETRY_BUTTON_ID = "RETRY_BUTTON_ID"; // 重试按钮ID class StressTestFailView { - public: - StressTestFailView(); - ~StressTestFailView(); - void ClearAll(void); - UIViewGroup *CreateStressTestFailView(void); - private: - UIViewGroup * CreateStressTestFailView1(void); - UIViewGroup * CreateStressTestFailView2(void); - UIViewGroup *group{nullptr}; - UILabelExt *titleLabel{nullptr}; - UIImageView *imageView{nullptr}; - UIScrollView *scrollView{nullptr}; - //错误1相关组件 - UILabelExt *error1DescriptionLabel{nullptr}; - UILabelButtonExt *stopTestButton{nullptr};//停止检测 - UILabelButtonExt *retryTestButton{nullptr};//重试检测 - //错误2相关组件 - UILabelExt *error2DescriptionLabel{nullptr}; - UILabelButtonExt *stopButton{nullptr};//停止 - UILabelButtonExt *retryButton{nullptr};//重试 - }; + public: + StressTestFailView(); + ~StressTestFailView(); + void ClearAll(void); + UIViewGroup *CreateStressTestFailView(void); + + private: + UIViewGroup *CreateStressTestFailView1(void); + UIViewGroup *CreateStressTestFailView2(void); + UIViewGroup *group{nullptr}; + UILabelExt *titleLabel{nullptr}; + UIImageView *imageView{nullptr}; + UIScrollView *scrollView{nullptr}; + // 错误1相关组件 + UILabelExt *error1DescriptionLabel{nullptr}; + UILabelButtonExt *stopTestButton{nullptr}; // 停止检测 + UILabelButtonExt *retryTestButton{nullptr}; // 重试检测 + // 错误2相关组件 + UILabelExt *error2DescriptionLabel{nullptr}; + UILabelButtonExt *stopButton{nullptr}; // 停止 + UILabelButtonExt *retryButton{nullptr}; // 重试 + }; } #endif // STRESS_TEST_FAIL_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestMainView.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestMainView.h index b3509154c..0b9f9ad5d 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestMainView.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestMainView.h @@ -7,6 +7,7 @@ #include "stress/include/stressTestStandbyView.h" #include "stress/include/stressTestingView.h" #include "stress/include/stressTestFailView.h" +#include "stress/include/stressTestResultView.h" namespace OHOS { typedef enum @@ -34,10 +35,11 @@ namespace OHOS bool ChangeStressTestResultView(int16_t thisView); bool ChangeStressTestFailView(int16_t thisView); void OnStart() override; + private: StressTestStandbyView *standbyView{nullptr}; StressTestingView *stressTestingView{nullptr}; - // StressTestResultView stressTestResultView{nullptr}; + StressTestResultView *stressTestResultView{nullptr}; StressTestFailView *stressTestFailView{nullptr}; private: diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestModel.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestModel.h index 66448e722..cdb0a2037 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestModel.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestModel.h @@ -2,31 +2,49 @@ #define STRESS_TEST_MODEL_H #include +#include "string" +#include "iostream" namespace OHOS { - enum FailType :uint8_t - { - FAIL_TYPE_INVALID_DATA = 0,//数据无效 - FAIL_TYPE_NOT_WORN ,//未佩戴 - FAIL_TYPE_OTHER,//其他错误 - }; - class StressTestModel { public: + enum FailType : uint8_t + { + FAIL_TYPE_INVALID_DATA = 0, // 数据无效 + FAIL_TYPE_NOT_WORN, // 未佩戴 + FAIL_TYPE_OTHER, // 其他错误 + }; + enum ResultType : uint8_t + { + RESULT_TYPE_OVERLOAD = 0, // 压力过载 + RESULT_TYPE_WARNING, // 注意压力 + RESULT_TYPE_NORMAL, // 状态正常 + RESULT_TYPE_EXCELLENT, // 状态优秀 + RESULT_TYPE_OTHER, // 其他错误 + }; + static StressTestModel &GetInstance(void); uint8_t GetCurrentView(void); void SetCurrentView(uint8_t view); uint8_t GetCurrentFailType(void); void SetCurrentFailType(uint8_t failType); - + uint8_t GetCurrentResultType(void); + void SetCurrentResultType(uint8_t resultType); + void SetCurrentResultValue(uint16_t value); + uint16_t GetCurrentResultValue(void); + std::string GetCurrentResultValueStr(void); + void HandleResultValue(uint16_t value); + private: StressTestModel(); ~StressTestModel(); StressTestModel(const StressTestModel &) = delete; StressTestModel &operator=(const StressTestModel &) = delete; uint8_t currentView{0}; - uint8_t currentFailType{FAIL_TYPE_NOT_WORN};//当前错误类型 + uint8_t currentFailType{FAIL_TYPE_NOT_WORN}; // 当前错误类型 + uint8_t currentResultType{RESULT_TYPE_EXCELLENT}; // 当前结果类型 + uint16_t currentResultValue{30}; // 当前压力测试结果值 }; } diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestPresenter.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestPresenter.h index fa0175781..84e259548 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestPresenter.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestPresenter.h @@ -5,7 +5,8 @@ #include "stress/include/stressTestMainView.h" #include "key/include/KeyInputListener.h" #include "wearable_log.h" - +#include "stress/include/stressTestUIConfig.h" +#include "iostream" namespace OHOS { class StressTestMainView; @@ -23,6 +24,8 @@ namespace OHOS void OnResume() override; uint8_t GetCurrentFailType(void); + uint8_t GetCurrentResultType(void); + std::string GetCurrentResultValueStr(void); private: bool OnClick(UIView &view, const ClickEvent &event) override; diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestResultView.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestResultView.h index e69de29bb..bced61182 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestResultView.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestResultView.h @@ -0,0 +1,31 @@ +#ifndef STRESS_TEST_RESULT_VIEW_H +#define STRESS_TEST_RESULT_VIEW_H + +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_scroll_view.h" + +namespace OHOS +{ + static constexpr const char *STRESS_TEST_RESULT_VIEW_ID = "STRESS_TEST_RESULT_VIEW_ID"; // 压力测试结果视图ID + class StressTestResultView + { + public: + StressTestResultView(); + ~StressTestResultView(); + void ClearAll(void); + UIViewGroup *CreateStressTestResultView(void); + void UpdateStressTestResultView(void); + + private: + UIViewGroup *group{nullptr}; + UIScrollView *scrollView{nullptr}; + UILabelExt *titleLabel{nullptr}; + UILabelExt *ValueNamesLabel{nullptr}; + UILabelExt *descriptionLabel{nullptr}; + UIImageView *backgroundImageView{nullptr}; // 压力测试背景图片 + UIImageView *resultImageView{nullptr}; // 压力测试结果图片 + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestStandbyView.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestStandbyView.h index c86a44623..b999cdeac 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestStandbyView.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestStandbyView.h @@ -16,7 +16,9 @@ namespace OHOS ~StressTestStandbyView(); void ClearAll(void); - UIViewGroup * CreateStressTestStandbyView(void); + UIViewGroup *CreateStressTestStandbyView(void); + void UpdateStressTestStandbyView(void); + private: UIViewGroup *group{nullptr}; UILabelExt *titleLabel{nullptr}; diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestUIConfig.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestUIConfig.h new file mode 100644 index 000000000..4b68a1a8e --- /dev/null +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestUIConfig.h @@ -0,0 +1,25 @@ +#ifndef STRESS_TEST_UI_CONFIG_H +#define STRESS_TEST_UI_CONFIG_H + +namespace OHOS +{ + // 压力测试结果视图背景图片: + // 压力过载 + static constexpr const char *STRESS_TEST_RESULT_VIEW_BACKGROUND_IMAGE_1 = "/user/res/stress/stress_test_result_view_background_1.bin"; + // 注意压力 + static constexpr const char *STRESS_TEST_RESULT_VIEW_BACKGROUND_IMAGE_2 = "/user/res/stress/stress_test_result_view_background_2.bin"; + // 状态正常 + static constexpr const char *STRESS_TEST_RESULT_VIEW_BACKGROUND_IMAGE_3 = "/user/res/stress/stress_test_result_view_background_3.bin"; + // 状态优秀 + static constexpr const char *STRESS_TEST_RESULT_VIEW_BACKGROUND_IMAGE_4 = "/user/res/stress/stress_test_result_view_background_4.bin"; + // 压力测试结果视图结果图片: + // 压力过载 + static constexpr const char *STRESS_TEST_RESULT_VIEW_RESULT_IMAGE_1 = "/user/res/stress/stress_test_result_view_result_1.bin"; + // 注意压力 + static constexpr const char *STRESS_TEST_RESULT_VIEW_RESULT_IMAGE_2 = "/user/res/stress/stress_test_result_view_result_2.bin"; + // 状态正常 + static constexpr const char *STRESS_TEST_RESULT_VIEW_RESULT_IMAGE_3 = "/user/res/stress/stress_test_result_view_result_3.bin"; + // 状态优秀 + static constexpr const char *STRESS_TEST_RESULT_VIEW_RESULT_IMAGE_4 = "/user/res/stress/stress_test_result_view_result_4.bin"; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestingView.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestingView.h index cdb2a8803..130030c83 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestingView.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestingView.h @@ -7,15 +7,16 @@ #include "components/ui_label_button_ext.h" namespace OHOS { - static constexpr const char *STRESSTESTINGVIEW_ID = "STRESSTESTINGVIEW_ID"; - static constexpr const char *CANCEL_BUTTON_ID = "CANCEL_BUTTON_ID"; - class StressTestingView + static constexpr const char *STRESSTESTINGVIEW_ID = "STRESSTESTINGVIEW_ID"; // 压力测试中视图ID + static constexpr const char *CANCEL_BUTTON_ID = "CANCEL_BUTTON_ID"; // 取消按钮ID + class StressTestingView { public: StressTestingView(); ~StressTestingView(); void ClearAll(void); - UIViewGroup * CreateStressTestingView(void); + UIViewGroup *CreateStressTestingView(void); + private: UIViewGroup *group{nullptr}; UILabelExt *titleLabel{nullptr}; diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestFailView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestFailView.cpp index ced9dbeb5..9380e8430 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestFailView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestFailView.cpp @@ -3,7 +3,6 @@ #include "stress/include/stressTestModel.h" #include "UiConfig.h" - namespace OHOS { StressTestFailView::StressTestFailView() @@ -20,6 +19,58 @@ namespace OHOS void StressTestFailView::ClearAll(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestFailView::ClearAll"); + if (group != nullptr) + { + group->RemoveAll(); + delete group; + group = nullptr; + } + if (scrollView != nullptr) + { + scrollView->RemoveAll(); + delete scrollView; + scrollView = nullptr; + } + if (titleLabel != nullptr) + { + delete titleLabel; + titleLabel = nullptr; + } + if (imageView != nullptr) + { + delete imageView; + imageView = nullptr; + } + if (error1DescriptionLabel != nullptr) + { + delete error1DescriptionLabel; + error1DescriptionLabel = nullptr; + } + if (retryTestButton != nullptr) + { + delete retryTestButton; + retryTestButton = nullptr; + } + if (stopTestButton != nullptr) + { + delete stopTestButton; + stopTestButton = nullptr; + } + if (error2DescriptionLabel != nullptr) + { + delete error2DescriptionLabel; + error2DescriptionLabel = nullptr; + } + if (retryButton != nullptr) + { + delete retryButton; + retryButton = nullptr; + } + if (stopButton != nullptr) + { + delete stopButton; + stopButton = nullptr; + } } UIViewGroup *StressTestFailView::CreateStressTestFailView1(void) @@ -39,7 +90,7 @@ namespace OHOS group->SetDraggable(true); group->SetOnDragListener((UIView::OnDragListener *)OHOS::StressTestPresenter::GetInstance()); } - if(scrollView == nullptr) + if (scrollView == nullptr) { scrollView = new UIScrollView(); if (scrollView == nullptr) @@ -50,8 +101,8 @@ namespace OHOS scrollView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); scrollView->SetTouchable(true); scrollView->SetDraggable(true); - scrollView->SetScrollBlankSize(60,UIAbstractScroll::Direction::BOTTOM); - scrollView->SetScrollBlankSize(60,UIAbstractScroll::Direction::TOP); + scrollView->SetScrollBlankSize(60, UIAbstractScroll::Direction::BOTTOM); + scrollView->SetScrollBlankSize(60, UIAbstractScroll::Direction::TOP); group->Add(scrollView); } if (titleLabel == nullptr) @@ -62,7 +113,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel new fail!!"); return nullptr; } - titleLabel->SetPosition(83, 50,300,35); + titleLabel->SetPosition(83, 50, 300, 35); titleLabel->SetText("检测不到结果"); titleLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); titleLabel->SetStyle(STYLE_TEXT_FONT, 30); @@ -72,7 +123,7 @@ namespace OHOS titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); scrollView->Add(titleLabel); } - if(imageView == nullptr) + if (imageView == nullptr) { imageView = new UIImageView(); if (imageView == nullptr) @@ -84,7 +135,7 @@ namespace OHOS imageView->SetSrc(PNG_ATTENTION_IMAGE); scrollView->Add(imageView); } - if(error1DescriptionLabel == nullptr) + if (error1DescriptionLabel == nullptr) { error1DescriptionLabel = new UILabelExt(); if (error1DescriptionLabel == nullptr) @@ -102,7 +153,7 @@ namespace OHOS error1DescriptionLabel->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); scrollView->Add(error1DescriptionLabel); } - if(retryTestButton == nullptr) + if (retryTestButton == nullptr) { retryTestButton = new UILabelButtonExt(); if (retryTestButton == nullptr) @@ -110,7 +161,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "retryTestButton new fail!!"); return nullptr; } - retryTestButton->SetPosition(118, 334,230,80); + retryTestButton->SetPosition(118, 334, 230, 80); retryTestButton->SetText("重试检测"); retryTestButton->SetAlign(TEXT_ALIGNMENT_CENTER); retryTestButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); @@ -120,9 +171,8 @@ namespace OHOS retryTestButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); retryTestButton->SetOnClickListener((UIView::OnClickListener *)OHOS::StressTestPresenter::GetInstance()); scrollView->Add(retryTestButton); - } - if(stopTestButton == nullptr) + if (stopTestButton == nullptr) { stopTestButton = new UILabelButtonExt(); if (stopTestButton == nullptr) @@ -130,7 +180,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stopTestButton new fail!!"); return nullptr; } - stopTestButton->SetPosition(118, 434,230,80); + stopTestButton->SetPosition(118, 434, 230, 80); stopTestButton->SetText("停止检测"); stopTestButton->SetAlign(TEXT_ALIGNMENT_CENTER); stopTestButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); @@ -162,7 +212,7 @@ namespace OHOS group->SetDraggable(true); group->SetOnDragListener((UIView::OnDragListener *)OHOS::StressTestPresenter::GetInstance()); } - if(scrollView == nullptr) + if (scrollView == nullptr) { scrollView = new UIScrollView(); if (scrollView == nullptr) @@ -183,7 +233,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel new fail!!"); return nullptr; } - titleLabel->SetPosition(83, 50,300,35); + titleLabel->SetPosition(83, 50, 300, 35); titleLabel->SetText("检测不到结果"); titleLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); titleLabel->SetStyle(STYLE_TEXT_FONT, 30); @@ -193,7 +243,7 @@ namespace OHOS titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); scrollView->Add(titleLabel); } - if(imageView == nullptr) + if (imageView == nullptr) { imageView = new UIImageView(); if (imageView == nullptr) @@ -205,7 +255,7 @@ namespace OHOS imageView->SetSrc(PNG_ATTENTION_IMAGE); scrollView->Add(imageView); } - if(error1DescriptionLabel == nullptr) + if (error1DescriptionLabel == nullptr) { error1DescriptionLabel = new UILabelExt(); if (error1DescriptionLabel == nullptr) @@ -223,7 +273,7 @@ namespace OHOS error1DescriptionLabel->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff)); scrollView->Add(error1DescriptionLabel); } - if(retryButton == nullptr) + if (retryButton == nullptr) { retryButton = new UILabelButtonExt(); if (retryButton == nullptr) @@ -231,7 +281,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "retryButton new fail!!"); return nullptr; } - retryButton->SetPosition(238, 300,170,90); + retryButton->SetPosition(238, 300, 170, 90); retryButton->SetText("重测"); retryButton->SetAlign(TEXT_ALIGNMENT_CENTER); retryButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); @@ -241,9 +291,8 @@ namespace OHOS retryButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); retryButton->SetOnClickListener((UIView::OnClickListener *)OHOS::StressTestPresenter::GetInstance()); scrollView->Add(retryButton); - } - if(stopButton == nullptr) + if (stopButton == nullptr) { stopButton = new UILabelButtonExt(); if (stopButton == nullptr) @@ -251,7 +300,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stopButton new fail!!"); return nullptr; } - stopButton->SetPosition(58, 300,170,90); + stopButton->SetPosition(58, 300, 170, 90); stopButton->SetText("停止"); stopButton->SetAlign(TEXT_ALIGNMENT_CENTER); stopButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); @@ -269,11 +318,11 @@ namespace OHOS UIViewGroup *StressTestFailView::CreateStressTestFailView(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestFailView::CreateStressTestFailView"); - if (StressTestPresenter::GetInstance()->GetCurrentFailType() == FAIL_TYPE_NOT_WORN) + if (StressTestPresenter::GetInstance()->GetCurrentFailType() == StressTestModel::FAIL_TYPE_NOT_WORN) { return CreateStressTestFailView1(); } - else if (StressTestPresenter::GetInstance()->GetCurrentFailType() == FAIL_TYPE_INVALID_DATA) + else if (StressTestPresenter::GetInstance()->GetCurrentFailType() == StressTestModel::FAIL_TYPE_INVALID_DATA) { return CreateStressTestFailView2(); } diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestMainView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestMainView.cpp index c3bf1309c..c34b4eb37 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestMainView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestMainView.cpp @@ -2,7 +2,6 @@ #include "stress/include/stressTestPresenter.h" #include "stress/include/stressTestModel.h" - namespace OHOS { @@ -47,6 +46,11 @@ namespace OHOS delete stressTestFailView; stressTestFailView = nullptr; } + if (stressTestResultView != nullptr) + { + delete stressTestResultView; + stressTestResultView = nullptr; + } for (int i = 0; i < MAX_STRESSTESTMAINVIEW; i++) { if (group[i] != nullptr) @@ -58,7 +62,7 @@ namespace OHOS void StressTestMainView::OnStart() { - ChangeView(MAX_STRESSTESTMAINVIEW, STRESSTESTIDLEVIEW); + ChangeView(MAX_STRESSTESTMAINVIEW, STRESSTESTRESULTVIEW); } bool StressTestMainView::ChangeStressTestIdleView(int16_t thisView) @@ -75,6 +79,10 @@ namespace OHOS group[thisView] = standbyView->CreateStressTestStandbyView(); AddViewToRootContainer(group[thisView]); } + if (standbyView != nullptr) + { + standbyView->UpdateStressTestStandbyView(); + } return true; } @@ -97,6 +105,21 @@ namespace OHOS bool StressTestMainView::ChangeStressTestResultView(int16_t thisView) { + if (group[thisView] == nullptr) + { + stressTestResultView = new StressTestResultView(); + if (stressTestResultView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestMainView:: new stressTestResultView fail", thisView); + return false; + } + group[thisView] = stressTestResultView->CreateStressTestResultView(); + AddViewToRootContainer(group[thisView]); + } + if (stressTestResultView != nullptr) + { + stressTestResultView->UpdateStressTestResultView(); + } return true; } diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestModel.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestModel.cpp index 262a698b4..4e6052203 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestModel.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestModel.cpp @@ -21,6 +21,7 @@ namespace OHOS currentView = view; } + // 获取当前压力测试失败类型 uint8_t StressTestModel::GetCurrentFailType(void) { return currentFailType; @@ -30,4 +31,79 @@ namespace OHOS { currentFailType = failType; } + + // 获取当前压力测试结果类型 + uint8_t StressTestModel::GetCurrentResultType(void) + { + return currentResultType; + } + + void StressTestModel::SetCurrentResultType(uint8_t resultType) + { + currentResultType = resultType; + } + + void StressTestModel::SetCurrentResultValue(uint16_t value) + { + currentResultValue = value; + } + + // 获取当前压力测试结果值 + uint16_t StressTestModel::GetCurrentResultValue(void) + { + return currentResultValue; + } + + std::string StressTestModel::GetCurrentResultValueStr(void) + { + uint8_t resultType = GetCurrentResultType(); + std::string resultValueStr = std::to_string(GetCurrentResultValue()) + "ms"; + std::string resultStr; + switch (resultType) + { + case RESULT_TYPE_OVERLOAD: + resultStr = std::string("压力过载 ") + resultValueStr; + break; + case RESULT_TYPE_WARNING: + resultStr = std::string("注意压力 ") + resultValueStr; + break; + case RESULT_TYPE_NORMAL: + resultStr = std::string("状态正常 ") + resultValueStr; + break; + case RESULT_TYPE_EXCELLENT: + resultStr = std::string("状态优秀 ") + resultValueStr; + break; + default: + break; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestModel::GetCurrentResultValueStr: %s", resultStr.c_str()); + return resultStr; + } + + void StressTestModel::HandleResultValue(uint16_t value) + { + currentResultValue = value; + if (value >= 71 ) //压力过载 + { + currentResultType = RESULT_TYPE_OVERLOAD; + } + else if (value >= 51 && value < 71) //注意压力 + { + currentResultType = RESULT_TYPE_WARNING; + } + else if (value >= 31 && value < 51) //状态正常 + { + currentResultType = RESULT_TYPE_NORMAL; + } + else if (value >= 0 && value < 31) //状态优秀 + { + currentResultType = RESULT_TYPE_EXCELLENT; + } + else + { + currentResultType = RESULT_TYPE_OTHER; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestModel::HandleResultValue: %d", currentResultType); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestModel::HandleResultValue: %dms", currentResultValue); + } } diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestPresenter.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestPresenter.cpp index 6325d2c15..9af94fb3e 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestPresenter.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestPresenter.cpp @@ -13,8 +13,7 @@ namespace OHOS { REGIST_MENU_PRO(VIEW_STRESS_TEST, StressTestMainView, StressTestPresenter, - PNG_APPLIST_MUSIC_IMAGE_BIG, PNG_APPLIST_MUSIC_IMAGE,PNG_APPLIST_MUSIC_IMAGE, "stress", STR_MUSIC); - + PNG_APPLIST_MUSIC_IMAGE_BIG, PNG_APPLIST_MUSIC_IMAGE, PNG_APPLIST_MUSIC_IMAGE, "stress", STR_MUSIC); // 当前Presenter属性实例化的内存指针 static StressTestPresenter *g_pStressTestPresenter = nullptr; @@ -46,34 +45,38 @@ namespace OHOS RootView::GetInstance()->SetOnKeyActListener(this); } - bool StressTestPresenter::OnClick(UIView &view, const ClickEvent &event) { UNUSED(event); - if (view.GetViewId() == START_TEST_BUTTON_ID) + if (view.GetViewId() == START_TEST_BUTTON_ID) // 点击开始测试按钮 { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestPresenter::OnClick start test"); view_->ChangeView(StressTestModel::GetInstance().GetCurrentView(), STRESSTESTVIEW); } - else if(view.GetViewId() == CANCEL_BUTTON_ID) + else if (view.GetViewId() == CANCEL_BUTTON_ID) // 点击取消按钮 { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestPresenter::OnClick cancel test"); + view_->ChangeView(StressTestModel::GetInstance().GetCurrentView(), STRESSTESTIDLEVIEW); } - else if(view.GetViewId() == STOP_TEST_BUTTON_ID) + else if (view.GetViewId() == STOP_TEST_BUTTON_ID) // 点击停止测试按钮 { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestPresenter::OnClick stop test"); + view_->ChangeView(StressTestModel::GetInstance().GetCurrentView(), STRESSTESTIDLEVIEW); } - else if(view.GetViewId() == RETRY_TEST_BUTTON_ID) + else if (view.GetViewId() == RETRY_TEST_BUTTON_ID) // 点击重新测试按钮 { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestPresenter::OnClick retry test"); + view_->ChangeView(StressTestModel::GetInstance().GetCurrentView(), STRESSTESTVIEW); } - else if(view.GetViewId() == STOP_BUTTON_ID) + else if (view.GetViewId() == STOP_BUTTON_ID) // 点击停止按钮 { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestPresenter::OnClick stop"); + view_->ChangeView(StressTestModel::GetInstance().GetCurrentView(), STRESSTESTIDLEVIEW); } - else if(view.GetViewId() == RETRY_BUTTON_ID) + else if (view.GetViewId() == RETRY_BUTTON_ID) // 点击重新开始按钮 { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestPresenter::OnClick retry"); + view_->ChangeView(StressTestModel::GetInstance().GetCurrentView(), STRESSTESTVIEW); } return true; } @@ -99,9 +102,13 @@ namespace OHOS { NativeAbility::GetInstance().Back(); } - else if(view.GetViewId() == STRESSTESTINGVIEW_ID) + else if (view.GetViewId() == STRESSTESTINGVIEW_ID) + { + view_->ChangeView(StressTestModel::GetInstance().GetCurrentView(), STRESSTESTIDLEVIEW); + } + else if (view.GetViewId() == STRESS_TEST_RESULT_VIEW_ID) { - view_->ChangeView(StressTestModel::GetInstance().GetCurrentView(), STRESSTESTIDLEVIEW); + view_->ChangeView(StressTestModel::GetInstance().GetCurrentView(), STRESSTESTIDLEVIEW); } } return true; @@ -125,4 +132,14 @@ namespace OHOS { return StressTestModel::GetInstance().GetCurrentFailType(); } + + uint8_t StressTestPresenter::GetCurrentResultType(void) + { + return StressTestModel::GetInstance().GetCurrentResultType(); + } + + std::string StressTestPresenter::GetCurrentResultValueStr(void) + { + return StressTestModel::GetInstance().GetCurrentResultValueStr(); + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestResultView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestResultView.cpp index e69de29bb..1a1717b8c 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestResultView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestResultView.cpp @@ -0,0 +1,219 @@ +#include "stress/include/stressTestResultView.h" +#include "stress/include/stressTestPresenter.h" +#include "stress/include/stressTestModel.h" + +namespace OHOS +{ + StressTestResultView::StressTestResultView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestResultView::StressTestResultView"); + } + + StressTestResultView::~StressTestResultView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestResultView::~StressTestResultView"); + ClearAll(); + } + + void StressTestResultView::ClearAll(void) + { + if (group != nullptr) + { + group->RemoveAll(); + delete group; + group = nullptr; + } + if (scrollView != nullptr) + { + scrollView->RemoveAll(); + delete scrollView; + scrollView = nullptr; + } + if (backgroundImageView != nullptr) + { + delete backgroundImageView; + backgroundImageView = nullptr; + } + if (resultImageView != nullptr) + { + delete resultImageView; + resultImageView = nullptr; + } + if (titleLabel != nullptr) + { + delete titleLabel; + titleLabel = nullptr; + } + if (ValueNamesLabel != nullptr) + { + delete ValueNamesLabel; + ValueNamesLabel = nullptr; + } + if (descriptionLabel != nullptr) + { + delete descriptionLabel; + descriptionLabel = nullptr; + } + } + + void StressTestResultView::UpdateStressTestResultView(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestResultView::UpdateStressTestResultView"); + if (backgroundImageView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestResultView::UpdateStressTestResultView backgroundImageView is nullptr"); + return; + } + if (resultImageView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestResultView::UpdateStressTestResultView resultImageView is nullptr"); + return; + } + if (ValueNamesLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestResultView::UpdateStressTestResultView ValueNamesLabel is nullptr"); + return; + } + std::string resultValueStr = StressTestPresenter::GetInstance()->GetCurrentResultValueStr(); + ValueNamesLabel->SetText(resultValueStr.c_str()); + uint8_t resultType = StressTestPresenter::GetInstance()->GetCurrentResultType(); + if (resultType == StressTestModel::RESULT_TYPE_OVERLOAD) + { + resultImageView->SetSrc(STRESS_TEST_RESULT_VIEW_RESULT_IMAGE_1); + backgroundImageView->SetSrc(STRESS_TEST_RESULT_VIEW_BACKGROUND_IMAGE_1); + descriptionLabel->SetText("当前压力过高,建议暂停工作,进行呼吸训练或冥想"); + ValueNamesLabel->SetTextColor(Color::GetColorFromRGBA(0xfd, 0x52, 0x13, 0xff)); + } + else if (resultType == StressTestModel::RESULT_TYPE_WARNING) + { + resultImageView->SetSrc(STRESS_TEST_RESULT_VIEW_RESULT_IMAGE_2); + backgroundImageView->SetSrc(STRESS_TEST_RESULT_VIEW_BACKGROUND_IMAGE_2); + descriptionLabel->SetText("存在轻微压力,建议试试1分钟深呼吸或远眺"); + ValueNamesLabel->SetTextColor(Color::GetColorFromRGBA(0xff, 0x8e, 0x1a, 0xff)); + + } + else if (resultType == StressTestModel::RESULT_TYPE_NORMAL) + { + resultImageView->SetSrc(STRESS_TEST_RESULT_VIEW_RESULT_IMAGE_3); + backgroundImageView->SetSrc(STRESS_TEST_RESULT_VIEW_BACKGROUND_IMAGE_3); + descriptionLabel->SetText("压力在健康范围,建议继续保持规律作息,状态良好"); + ValueNamesLabel->SetTextColor(Color::GetColorFromRGBA(0x0f, 0xaf, 0xff, 0xff)); + } + else if (resultType == StressTestModel::RESULT_TYPE_EXCELLENT) + { + resultImageView->SetSrc(STRESS_TEST_RESULT_VIEW_RESULT_IMAGE_4); + descriptionLabel->SetText("当前压力极低,建议保持当前状态,享受放松时刻"); + backgroundImageView->SetSrc(STRESS_TEST_RESULT_VIEW_BACKGROUND_IMAGE_4); + ValueNamesLabel->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xce, 0x4c, 0xff)); + } + } + + UIViewGroup *StressTestResultView::CreateStressTestResultView(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestResultView::CreateStressTestResultView"); + if (group == nullptr) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestResultView::CreateStressTestResultView new group fail"); + return nullptr; + } + group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + group->SetViewId(STRESS_TEST_RESULT_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 (backgroundImageView == nullptr) + { + backgroundImageView = new UIImageView(); + if (backgroundImageView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestResultView::CreateStressTestResultView new backgroundImageView fail"); + return nullptr; + } + backgroundImageView->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + scrollView->Add(backgroundImageView); + } + if (resultImageView == nullptr) + { + resultImageView = new UIImageView(); + if (resultImageView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestResultView::CreateStressTestResultView new resultImageView fail"); + return nullptr; + } + resultImageView->SetPosition(158, 103, 160, 140); + scrollView->Add(resultImageView); + } + if (titleLabel == nullptr) + { + titleLabel = new UILabelExt(); + if (titleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestResultView::CreateStressTestResultView 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); + scrollView->Add(titleLabel); + } + if (ValueNamesLabel == nullptr) + { + ValueNamesLabel = new UILabelExt(); + if (ValueNamesLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestResultView::CreateStressTestResultView new ValueNamesLabel fail"); + return nullptr; + } + ValueNamesLabel->SetPosition(53, 261, 360, 35); + ValueNamesLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + ValueNamesLabel->SetStyle(STYLE_TEXT_FONT, 30); + ValueNamesLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + ValueNamesLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + ValueNamesLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + ValueNamesLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollView->Add(ValueNamesLabel); + } + if (descriptionLabel == nullptr) + { + descriptionLabel = new UILabelExt(); + if (descriptionLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestResultView::CreateStressTestResultView new descriptionLabel fail"); + return nullptr; + } + descriptionLabel->SetPosition(53, 315, 360, 70); + descriptionLabel->SetText("压力在健康范围,建议继续保持规律作息,状态良好"); + descriptionLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + descriptionLabel->SetStyle(STYLE_TEXT_FONT, 30); + descriptionLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + descriptionLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + descriptionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollView->Add(descriptionLabel); + } + + return group; + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestStandbyView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestStandbyView.cpp index bab0a7433..7780ba4a9 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestStandbyView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestStandbyView.cpp @@ -1,5 +1,6 @@ #include "stress/include/stressTestStandbyView.h" #include "stress/include/stressTestPresenter.h" +#include "stress/include/stressTestModel.h" namespace OHOS { @@ -10,8 +11,8 @@ namespace OHOS StressTestStandbyView::~StressTestStandbyView() { - ClearAll(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestStandbyView::~StressTestStandbyView"); + ClearAll(); } void StressTestStandbyView::ClearAll(void) @@ -44,7 +45,45 @@ namespace OHOS } } - UIViewGroup * StressTestStandbyView::CreateStressTestStandbyView(void) + void StressTestStandbyView::UpdateStressTestStandbyView(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestStandbyView::UpdateStressTestStandbyView"); + if (descriptionLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestStandbyView::UpdateStressTestStandbyView descriptionLabel is nullptr"); + return; + } + if (imageView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestStandbyView::UpdateStressTestStandbyView imageView is nullptr"); + return; + } + std::string resultValueStr = StressTestPresenter::GetInstance()->GetCurrentResultValueStr(); + descriptionLabel->SetText(resultValueStr.c_str()); + uint8_t resultType = StressTestPresenter::GetInstance()->GetCurrentResultType(); + if (resultType == StressTestModel::RESULT_TYPE_OVERLOAD) + { + imageView->SetSrc(STRESS_TEST_RESULT_VIEW_RESULT_IMAGE_1); + descriptionLabel->SetTextColor(Color::GetColorFromRGBA(0xfd, 0x52, 0x13, 0xff)); + } + else if (resultType == StressTestModel::RESULT_TYPE_WARNING) + { + imageView->SetSrc(STRESS_TEST_RESULT_VIEW_RESULT_IMAGE_2); + descriptionLabel->SetTextColor(Color::GetColorFromRGBA(0xff, 0x8e, 0x1a, 0xff)); + } + else if (resultType == StressTestModel::RESULT_TYPE_NORMAL) + { + imageView->SetSrc(STRESS_TEST_RESULT_VIEW_RESULT_IMAGE_3); + descriptionLabel->SetTextColor(Color::GetColorFromRGBA(0x0f, 0xaf, 0xff, 0xff)); + } + else if (resultType == StressTestModel::RESULT_TYPE_EXCELLENT) + { + imageView->SetSrc(STRESS_TEST_RESULT_VIEW_RESULT_IMAGE_4); + descriptionLabel->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xce, 0x4c, 0xff)); + } + } + + UIViewGroup *StressTestStandbyView::CreateStressTestStandbyView(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestStandbyView::CreateStressTestStandbyView"); if (group == nullptr) @@ -69,7 +108,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel new fail!!"); return nullptr; } - titleLabel->SetPosition(83, 50,300,35); + titleLabel->SetPosition(83, 50, 300, 35); titleLabel->SetText("压力"); titleLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); titleLabel->SetStyle(STYLE_TEXT_FONT, 30); @@ -87,8 +126,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imageView new fail!!"); return nullptr; } - imageView->SetPosition(158, 103,160,140); - imageView->SetSrc("/user/res/stress/STRESS_TEST_STANDBY.bin"); + imageView->SetPosition(158, 103, 160, 140); group->Add(imageView); } if (descriptionLabel == nullptr) @@ -99,8 +137,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "descriptionLabel new fail!!"); return nullptr; } - descriptionLabel->SetPosition(53, 261,360,35); - descriptionLabel->SetText("状态正常 35ms"); + descriptionLabel->SetPosition(53, 261, 360, 35); descriptionLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); descriptionLabel->SetTextColor(Color::GetColorFromRGBA(0x0f, 0xaf, 0xff, 0xff)); descriptionLabel->SetStyle(STYLE_TEXT_FONT, 30); @@ -118,7 +155,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startTestButton new fail!!"); return nullptr; } - startTestButton->SetPosition(93, 330,280,90); + startTestButton->SetPosition(93, 330, 280, 90); startTestButton->SetText("检测"); startTestButton->SetAlign(TEXT_ALIGNMENT_CENTER); startTestButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestingView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestingView.cpp index 161967142..894a40072 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestingView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestingView.cpp @@ -58,7 +58,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestingView::CreateStressTestingView new titleLabel fail!!"); return nullptr; } - titleLabel->SetPosition(83, 50,300,35); + titleLabel->SetPosition(83, 50, 300, 35); titleLabel->SetText("压力"); titleLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); titleLabel->SetStyle(STYLE_TEXT_FONT, 30); @@ -76,7 +76,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StressTestingView::CreateStressTestingView new cancelButton fail!!"); return nullptr; } - cancelButton->SetPosition(93, 330,280,90); + cancelButton->SetPosition(93, 330, 280, 90); cancelButton->SetText("取消检测"); cancelButton->SetAlign(TEXT_ALIGNMENT_CENTER); cancelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); -- 2.17.1