From cd00192aacb9b3af62a0f40f6de0cd4641ca9101 Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Fri, 2 Aug 2024 17:57:29 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E8=AE=AD=E7=BB=83=E7=9B=AE?= =?utf8?q?=E6=A0=87=E8=BF=9B=E5=BA=A6=E6=9D=A1=20=E8=AE=AD=E7=BB=83?= =?utf8?q?=E5=BC=BA=E5=BA=A6=E5=90=8C=E6=AD=A5=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../include/TraingCardPresenter.h | 3 +- .../training_card/include/TrainingDataView.h | 11 + .../training_card/src/TraingCardPresenter.cpp | 31 ++- .../training_card/src/TraingCardView.cpp | 215 +++++++----------- .../training_card/src/TrainingDataView.cpp | 40 +++- 5 files changed, 154 insertions(+), 146 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h index 62b343714..705ddec8e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h @@ -44,7 +44,8 @@ namespace OHOS void OnPause() override; void OnResume() override; void OnStop() override; - virtual void Notify() override; + // void OnTickEvent() override; + void Notify() override; bool OpenSensor(ExerciseClass type); bool ControlSensor(ExerciseState state); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDataView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDataView.h index 9265a1eca..82dd76e5d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDataView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDataView.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-02 09:56:04 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDataView.h + */ #ifndef _TrainingData_VIEW_H #define _TrainingData_VIEW_H @@ -14,6 +20,8 @@ #include "components/ui_chart.h" #include "components/ui_list.h" #include "components/icon_adapter.h" +#include "components/ui_circle_progress.h" + #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" @@ -45,6 +53,7 @@ namespace OHOS void UnLoad(void) override; UILabelExt *GetTimeLabel(); UILabelExt *GetHeartLabel(); + UICircleProgress*GetProgress(); void UpdataTime(); @@ -68,6 +77,8 @@ namespace OHOS UIImageView *image_highIntensity = nullptr; // 高等强度 UIImageView *image_superHighIntensity = nullptr; // 超高等强度 + UICircleProgress *circleProgress = nullptr; + UIImageView *image_iconup = nullptr; UIImageView *image_iconpoint = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp index a1c11e640..bb78a55c2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-07-06 16:27:31 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-02 10:21:14 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp + */ /*** * @Date: 2024-04-26 09:23:18 * @LastEditors: Caisking 3449750381@qq.com @@ -94,7 +100,7 @@ namespace OHOS // 计时器更新timer void TraingCardPresenter::ModifiesTime() { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesTime begin"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ModifiesTime begin"); std ::string TimeStr = TraingModel::GetInstance()->DisplayMotionDuration(); /*灭屏状态不刷新UI*/ @@ -117,7 +123,7 @@ namespace OHOS { TrainingDataView::GetInstance()->GetTimeLabel()->SetText(TimeStr.c_str()); } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ModifiesTime end"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ModifiesTime end"); } /* --------------------------------- cywee库操作 -------------------------------- */ @@ -210,16 +216,32 @@ namespace OHOS std::string calorieStr = (sportdata->calories != 0) ? std::to_string(sportdata->calories) : DEFAULT_DASH; // 训练强度刷新 UIResourceTextId intensityid = TraingModel::GetInstance()->GetIntensity(); - TrainingDetailView::GetInstance()->Get_Intensity_Button()->SetFontId(intensityid); + // printf("intensityid %d \r\n", intensityid); + TrainingDetailView::GetInstance()->Get_Intensity_Button()->SetTextId(intensityid); + TrainingDataView::GetInstance()->GetProgress()->SetValue(sportdata->goaldegree); // 目标完成度 TrainingDataView::GetInstance()->GetHeartLabel()->SetText(heartStr.c_str()); // 心率 TrainingDetailView::GetInstance()->GetCalorieLabel()->SetText(calorieStr.c_str()); // 卡路里 TrainingDetailView::GetInstance()->GetMileLabel()->SetText(distanceStr.c_str()); // 距离 TrainingDetailView::GetInstance()->GetStepLabel()->SetText(stepsStr.c_str()); // 步数 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[Calories: %s, Distance: %s, Steps: %s Intensityid: %d]", calorieStr.c_str(), distanceStr.c_str(), stepsStr.c_str(), intensityid); + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[Calories: %s, Distance: %s, Steps: %s Intensityid: %d]", calorieStr.c_str(), distanceStr.c_str(), stepsStr.c_str(), intensityid); // 释放sportdata内存 } +#if 0 /*刷新 time 和 data */ + void TraingCardPresenter::OnTickEvent() + { + // 未开启训练 直接退出 + if (TraingModel::GetInstance()->GetSportState() == ExerciseState::General) + return; + // 刷新训练数据界面 时间 + TrainingDataView::GetInstance()->UpdataTime(); + // 刷新训练数据界面 心率 卡路里 距离 步数 训练强度 目标完成度 + RefreshData(); + } +#endif +#if 1 void TraingCardPresenter::Notify(void) { // 未开启训练 直接退出 @@ -230,6 +252,7 @@ namespace OHOS // 刷新训练数据界面 心率 卡路里 距离 步数 训练强度 目标完成度 RefreshData(); } +#endif /* --------------------------------- 点击事件处理 --------------------------------- */ bool TraingCardPresenter::OnClick(UIView &view, const ClickEvent &event) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardView.cpp index 82a37f2b9..fa9f8acdd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardView.cpp @@ -47,7 +47,7 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, "Sport SERVICE MCU has delete pm_id_Sport vote"); } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, "Sport SERVICE MCU SLEEP SUCCESS"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MAIN_SERVICE, "Sport SERVICE MCU SLEEP SUCCESS"); } /*添加睡眠否决投票*/ @@ -62,7 +62,7 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, "Sport SERVICE MCU has got pm_id_Sport vote"); } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, "Sport SERVICE MCU WAKEUP SUCCESS"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MAIN_SERVICE, "Sport SERVICE MCU WAKEUP SUCCESS"); } #ifdef __cplusplus @@ -77,7 +77,7 @@ namespace OHOS TraingCardView::TraingCardView() { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingCardView::TraingCardView"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView::TraingCardView"); InitTimer(); // 开启计时器 TraingModel::GetInstance()->SetSportState(ExerciseState::Start); // 设置运动状态为开始 TraingModel::GetInstance()->SetTimestamp(); @@ -126,145 +126,82 @@ namespace OHOS // swipe_->HorAdd(DetailView); swipe_->VerAdd(DetailView, UICrossView::VPage::DOWN_PAGE); - swipe_->SetHorCurrentPage(Control_Card::DATA);//设置进入索引 [数据] + swipe_->SetHorCurrentPage(Control_Card::DATA); // 设置进入索引 [数据] - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingCardView::InitPage over"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView::InitPage over"); } /* DeInit:删除组件 */ void TraingCardView::DeInit() { swipe_->RemoveAll(); + /*界面*/ - if (ControlView != nullptr) - { - ControlView->RemoveAll(); - delete ControlView; - ControlView = nullptr; - } - if (DataVIew != nullptr) - { - DataVIew->RemoveAll(); - delete DataVIew; - DataVIew = nullptr; - } - if (DetailView != nullptr) - { - DetailView->RemoveAll(); - delete DetailView; - DetailView = nullptr; - } - if (MusicView != nullptr) - { - MusicView->RemoveAll(); - delete MusicView; - MusicView = nullptr; - } - if (endView != nullptr) - { - endView->RemoveAll(); - delete endView; - endView = nullptr; - } - if (getView != nullptr) - { - getView->RemoveAll(); - delete getView; - getView = nullptr; - } - if (heartView != nullptr) - { - heartView->RemoveAll(); - delete heartView; - heartView = nullptr; - } + ControlView->RemoveAll(); + DataVIew->RemoveAll(); + DetailView->RemoveAll(); + MusicView->RemoveAll(); + endView->RemoveAll(); + getView->RemoveAll(); + heartView->RemoveAll(); /*标签*/ - if (endtitle != nullptr) - { - delete endtitle; - endtitle = nullptr; - } - if (notelabel != nullptr) - { - delete notelabel; - notelabel = nullptr; - } - if (endnotelabel != nullptr) - { - delete endnotelabel; - endnotelabel = nullptr; - } - if (labeltitle != nullptr) - { - delete labeltitle; - labeltitle = nullptr; - } - if (labeltag != nullptr) - { - delete labeltag; - labeltag = nullptr; - } - if (labelgettag != nullptr) - { - delete labelgettag; - labelgettag = nullptr; - } - if (labelpre != nullptr) - { - delete labelpre; - labelpre = nullptr; - } - if (hearttitle != nullptr) - { - delete hearttitle; - hearttitle = nullptr; - } - if (labelnote != nullptr) - { - delete labelnote; - labelnote = nullptr; - } + delete endtitle; + endtitle = nullptr; + delete notelabel; + notelabel = nullptr; + delete endnotelabel; + endnotelabel = nullptr; + delete labeltitle; + labeltitle = nullptr; + delete labeltag; + labeltag = nullptr; + delete labelgettag; + labelgettag = nullptr; + delete labelpre; + labelpre = nullptr; + delete hearttitle; + hearttitle = nullptr; + delete labelnote; + labelnote = nullptr; /*图片*/ - if (heartiamge != nullptr) - { - delete heartiamge; - heartiamge = nullptr; - } + delete heartiamge; + heartiamge = nullptr; + /*按键*/ - if (exit != nullptr) - { - delete exit; - exit = nullptr; - } - if (back != nullptr) - { - delete back; - back = nullptr; - } - if (buttonok_ != nullptr) - { - delete buttonok_; - buttonok_ = nullptr; - } - if (buttonnote_ != nullptr) - { - delete buttonnote_; - buttonnote_ = nullptr; - } - /*动画*/ - if (imageAnimator != nullptr) - { - imageAnimator->Stop(); - delete imageAnimator; - imageAnimator = nullptr; - } + delete exit; + exit = nullptr; + delete back; + back = nullptr; + delete buttonok_; + buttonok_ = nullptr; + delete buttonnote_; + buttonnote_ = nullptr; - if (swipe_ != nullptr) - { - delete swipe_; - swipe_ = nullptr; - } + /*动画*/ + imageAnimator->Stop(); + delete imageAnimator; + imageAnimator = nullptr; + + /*卡片*/ + delete ControlView; + ControlView = nullptr; + delete DataVIew; + DataVIew = nullptr; + delete DetailView; + DetailView = nullptr; + delete swipe_; + delete MusicView; + MusicView = nullptr; + /*弹窗*/ + delete endView; + endView = nullptr; + delete getView; + getView = nullptr; + delete heartView; + heartView = nullptr; + + swipe_ = nullptr; } UICardPage *TraingCardView::InitControlPage(void) { @@ -318,7 +255,7 @@ namespace OHOS InitView(); viewiInitStatus = true; } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingCardView PreLoad"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView PreLoad"); } void TraingCardView::OnStart() { @@ -348,7 +285,7 @@ namespace OHOS /*设置弹窗状态*/ void TraingCardView::SetPopupViewStatus(PopupType type, bool status) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", type); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", type); UIView *popupView = nullptr; if (type == EndPopup) { @@ -381,7 +318,7 @@ namespace OHOS void TraingCardView::ShowEndView() { // momentumFlag = false; // 标志位还原 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowEndView"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowEndView"); endView = new UIScrollView(); if (endView == nullptr) { @@ -411,12 +348,12 @@ namespace OHOS endView->SetDraggable(false); endView->SetTouchable(true); endView->SetVisible(false); // 界面隐藏 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowEndView end"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowEndView end"); } /*目标达成界面*/ void TraingCardView::ShowGetTagView() { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowGetTagView"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowGetTagView"); getView = new UIScrollView(); if (getView == nullptr) { @@ -447,12 +384,12 @@ namespace OHOS getView->SetDraggable(false); getView->SetTouchable(true); getView->SetVisible(false); // 界面隐藏 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowGetTagView end"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowGetTagView end"); } /*最高心率提醒弹窗*/ void TraingCardView::ShowHeartView() { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowHeartView"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowHeartView"); heartView = new UIScrollView(); if (heartView == nullptr) { @@ -486,14 +423,14 @@ namespace OHOS heartView->SetDraggable(false); heartView->SetTouchable(true); heartView->SetVisible(false); // 界面隐藏 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowHeartView end"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowHeartView end"); } /*获取运动量结束弹窗界面刷新*/ bool TraingCardView::RefreshEndView() { // 获取训练卡路里判断运动量 momentumFlag = TraingModel::GetInstance()->GetMomentum(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "momentumFlag %d", momentumFlag); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "momentumFlag %d", momentumFlag); if (momentumFlag) { @@ -543,7 +480,7 @@ namespace OHOS default: break; } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"tag[%d]-tagType[%d]-tagString[%s]\r\n", tag, tagType, tagString.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "tag[%d]-tagType[%d]-tagString[%s]\r\n", tag, tagType, tagString.c_str()); InitLabel(labeltag, 70, 215, 326, 97, "label2", tagString.c_str(), DEFAULT_VECTOR_FONT_FILENAME, 80); labeltag->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); getView->Add(labeltag); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDataView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDataView.cpp index 77987e073..002bc7501 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDataView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDataView.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-02 09:35:58 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDataView.cpp + */ #include "traing/training_card/include/TrainingDataView.h" #include "traing/training_card/include/TraingCardView.h" @@ -48,6 +54,27 @@ namespace OHOS Add(image_heart); Add(image_iconup); Add(image_iconpoint); + + // 初始化进度条 + circleProgress = new UICircleProgress(); + circleProgress->SetPosition(0, 0); + circleProgress->Resize(466, 466); + circleProgress->SetViewId("circleProgress"); + circleProgress->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + circleProgress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + circleProgress->SetBackgroundStyle(STYLE_LINE_WIDTH, 12); + circleProgress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff2195F6); + circleProgress->SetForegroundStyle(STYLE_BORDER_COLOR, 0xff000000); + circleProgress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45A5FF); + circleProgress->SetForegroundStyle(STYLE_LINE_WIDTH, 10); + circleProgress->SetCenterPosition(235, 235); + circleProgress->SetRadius(215); + circleProgress->SetStartAngle(215); + circleProgress->SetEndAngle(505); + circleProgress->SetCapType(CAP_ROUND); + circleProgress->SetValue(0); + Add(circleProgress); + // 初始化Lable UIResourceTextId sport_id = TraingModel::GetInstance()->GetSportEvent(); InitLabelExt(sportlabel, 83, 120, 300, 35, "label2", sport_id, DEFAULT_VECTOR_FONT_FILENAME, 30); @@ -55,7 +82,7 @@ namespace OHOS InitLabel(curtimelabel, 155, 60, 150, 50, "label1", "23:54", DEFAULT_VECTOR_FONT_FILENAME, 40); - InitLabel(timerlabel, 40, 163, 400, 140, "label3", "00:00:00", GILROY_BOLD_FONT, 80); + InitLabel(timerlabel, 0, 163, 466, 150, "label3", "00:00:00", GILROY_BOLD_FONT, 80); InitLabel(heartlabel, 85, 284, 230, 80, "label4", "144", GILROY_BOLD_FONT, 60); InitLabel(ubpmlabel, 218, 284, 230, 80, "label5", "bpm", DEFAULT_VECTOR_FONT_FILENAME, 60); ubpmlabel->SetTextColor(Color::Gray()); @@ -64,6 +91,7 @@ namespace OHOS Add(timerlabel); Add(heartlabel); Add(ubpmlabel); + #if 0 // 初始化Button InitButton(buttonNote, 275, 350, 26, 26, BUTTONNOTE); @@ -127,6 +155,11 @@ namespace OHOS delete image_iconpoint; image_iconpoint = nullptr; } + if (circleProgress != nullptr) + { + delete circleProgress; + circleProgress = nullptr; + } } void TrainingDataView::PreLoad(void) @@ -139,7 +172,6 @@ namespace OHOS } void TrainingDataView::UnLoad(void) {} - UILabelExt *TrainingDataView::GetTimeLabel() { return timerlabel; @@ -148,6 +180,10 @@ namespace OHOS { return heartlabel; } + UICircleProgress *TrainingDataView::GetProgress() + { + return circleProgress; + } /*更新当前时间*/ void TrainingDataView::UpdataTime() { -- 2.17.1