From: Caisking <3449750381@qq.com> Date: Tue, 16 Apr 2024 02:24:28 +0000 (+0800) Subject: 修改主界面上拉界面UI;删除视频表盘panda;优化训练结束以及弹窗UI;搭建训练结束数据处理 X-Git-Tag: release_V1.2.70_20241020_135402~1175^2~9 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=df4ad274a7f18969b2b0d3b6306d8cd30ccfe4b0;p=mirrors%2FFD230.git 修改主界面上拉界面UI;删除视频表盘panda;优化训练结束以及弹窗UI;搭建训练结束数据处理 --- diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index a7852c0ff..6be43b08a 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -404,7 +404,7 @@ namespace OHOS RebootModel::GetInstance()->RegisterLongPressEvents(); // 开机检测充电状态 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Power is %d", get_charge_stat()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get_charge_stat is %d", get_charge_stat()); if (get_charge_stat()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Power is Charging!"); diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp index 023b24356..544068e63 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp @@ -113,6 +113,8 @@ extern "C" heartInfo->rest = preheart; heartInfo->maxValue = preheart; heartInfo->minValue = preheart; + /* + 暂时屏蔽主界面动态曲线 heartInfo->value[index_].x = index_; heartInfo->value[index_].y = preheart; index_++; @@ -121,6 +123,7 @@ extern "C" index_ = 0; } HeartModel::GetInstance()->SetIndex(index_); + */ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRateData = %d %d", heartInfo->index, preheart); OHOS::HeartModel::GetInstance()->HeartRatePros(heartInfo); free(heartInfo); @@ -600,7 +603,7 @@ namespace OHOS SetCheckTime(data->timestamp); HealthService::GetInstance()->UpdateHeartRateData(*data); // 更新卡片心率值 - //SetHeartRatePerSec(heart); + // SetHeartRatePerSec(heart); } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp index a9f13b534..75433d027 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp @@ -257,16 +257,6 @@ namespace OHOS { MessageLable = new UILabel(); } - MessageLable->SetPosition(173, 52, 120, 35); - MessageLable->Resize(120, 35); - MessageLable->SetStyle(STYLE_TEXT_FONT, 30); - MessageLable->SetStyle(STYLE_LINE_HEIGHT, 36); - MessageLable->SetText("信息通知"); - MessageLable->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); - MessageLable->SetStyle(STYLE_TEXT_COLOR, Color::White().full); - MessageLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - messageView->Add(MessageLable); - /* -------------------------------------------------------------------------- */ messageView->SetViewId("messageView"); messageView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); messageView->PreLoad(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageCardView.h b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageCardView.h index 1472a3b31..0e6d066ff 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageCardView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageCardView.h @@ -6,7 +6,11 @@ #include "components/ui_card_page.h" #include "wearable_log.h" #include "message/include/MessageView.h" - +#include "components/ui_label_button_ext.h" +#include "components/ui_image_animator.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_label_ext.h" namespace OHOS { class MessageCardView : public UICardPage @@ -22,6 +26,11 @@ namespace OHOS void ClearAll(void); MessageView *messageview{nullptr}; bool viewiInitStatus{false}; + + UIImageView *imageline{nullptr}; + UIImageView *imagemeage{nullptr}; + UILabelExt *labeltitle{nullptr}; + UILabelExt *labelmeage{nullptr}; }; } #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp index 79a23575b..ff1790150 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp @@ -1,9 +1,19 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-04-16 09:37:52 + * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageCardView.cpp + */ #include "message/include/MessageCardView.h" #include "wearable_log.h" namespace OHOS { + + static constexpr char *lineimagePath = "/user/res/message/Line 1.bin"; + static constexpr char *messageimagePath = "/user/res/message//message.bin"; + MessageCardView::MessageCardView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageCardView::MessageCardView()"); @@ -32,6 +42,8 @@ namespace OHOS bool MessageCardView::InitView(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ::InitView()"); + +#if 0 messageview = new MessageView(); if (messageview == nullptr) { @@ -52,6 +64,78 @@ namespace OHOS Add(messageview); messageview->GetList()->RefreshList(); // 刷新列表 //messageview->GetList()->SetElastic(true); +#endif + // Add ImageView to App + if (imageline == nullptr) + { + imageline = new UIImageView(); + } + imageline->SetPosition(193, 30); // widget's left position and top position + imageline->Resize(100, 100); // widget's width and height + imageline->SetViewId("image1"); // Set style + imageline->SetSrc(lineimagePath); + + // Add to rootView + Add(imageline); + imageline->SetVisible(true); + + // Add Label to App + if (labeltitle == nullptr) + { + labeltitle = new UILabelExt(); + } + labeltitle->SetPosition(83, 50); // widget's left position and top position + labeltitle->Resize(300, 35); // widget's width and height + labeltitle->SetViewId("label1"); // Set style + labeltitle->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + labeltitle->SetText("通知"); + labeltitle->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + labeltitle->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + labeltitle->SetRollSpeed(0); + labeltitle->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + Add(labeltitle); + labeltitle->SetVisible(true); + + // Add Label to App + if (labelmeage == nullptr) + { + labelmeage = new UILabelExt(); + } + labelmeage->SetPosition(53, 276); // widget's left position and top position + labelmeage->Resize(360, 35); // widget's width and height + labelmeage->SetViewId("label2"); // Set style + labelmeage->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + labelmeage->SetText("暂无内容"); + labelmeage->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + labelmeage->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + labelmeage->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + labelmeage->SetRollSpeed(0); + labelmeage->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + Add(labelmeage); + labelmeage->SetVisible(true); + + // Add ImageView to App + if (imagemeage == nullptr) + { + imagemeage = new UIImageView(); + } + imagemeage->SetPosition(183, 156); // widget's left position and top position + imagemeage->Resize(100, 100); // widget's width and height + imagemeage->SetViewId("image2"); // Set style + imagemeage->SetSrc(messageimagePath); + + // Add to rootView + Add(imagemeage); + imagemeage->SetVisible(true); + return true; } @@ -66,7 +150,6 @@ namespace OHOS void MessageCardView::UnLoad(void) { - } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/screensetting/src/ScreenModels.cpp b/code/sdk/application/wearable/fd230app/nativeui/screensetting/src/ScreenModels.cpp index 4af3b5fed..7c3d94fe8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/screensetting/src/ScreenModels.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/screensetting/src/ScreenModels.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-04-16 09:56:05 + * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/screensetting/src/ScreenModels.cpp + */ /* * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. * Description: ScreenModels @@ -76,6 +82,6 @@ namespace OHOS LoadAppMultiImages(HEART_IAMGES, HEART_HEARTRATECOOR, HEART_HEARTRATE_TOP); LoadAppMultiImages(BLOOD_IAMGES, BLOODOXYGEN_BACKGOUND, BLOODOXYGEN_BACKGOUND); LoadAppMultiImages(TRAINING_IAMGES, TRAINING_BOUTTONGROUND, TRAINING_WALKING_BIG); - LoadAppMultiImages(MESSAGE_IAMGES, MESSAGE_MESSAGE, MESSAGE_WECHAT); + // LoadAppMultiImages(MESSAGE_IAMGES, MESSAGE_MESSAGE, MESSAGE_WECHAT); } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h index 3c4d29248..40669e4aa 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-04-16 09:27:11 + * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h + */ #ifndef _TraingEnddata_VIEW_H #define _TraingEnddata_VIEW_H @@ -42,12 +48,10 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - + void PreLoad(void); - // 通过函数改变 - void SetLabel(); - void SetButton(); + void InitData(); private: UIView::OnDragListener *draglistener{nullptr}; @@ -55,29 +59,30 @@ namespace OHOS TraingEnddataView &operator=(TraingEnddataView &&) = delete; UIViewGroup *container_ = nullptr; - UIScrollView *scrollView1_ = nullptr; + UIScrollView *scrollView_ = nullptr; + + UILabelExt *labeltype = nullptr; + UILabelExt *labelsport = nullptr; + UILabelExt *labelutime = nullptr; + UILabelExt *labelutag = nullptr; + UILabelExt *labelumile = nullptr; + UILabelExt *labeluheart = nullptr; + UILabelExt *labelustrong = nullptr; + UILabelExt *labelnote = nullptr; + UILabelExt *labelduration = nullptr; - UILabelExt *label1_ = nullptr; - UILabelExt *label2_ = nullptr; - UILabelExt *label3_ = nullptr; - UILabelExt *label4_ = nullptr; - UILabelExt *label5_ = nullptr; - UILabelExt *label6_ = nullptr; - UILabelExt *label7_ = nullptr; - UILabelExt *label8_ = nullptr; - UILabelExt *label9_ = nullptr; - UILabelExt *label10_ = nullptr; - UILabelExt *label11_ = nullptr; - UILabelExt *label12_ = nullptr; - UILabelExt *label13_ = nullptr; - UILabelExt *label14_ = nullptr; - UILabelExt *label15_ = nullptr; + UILabelExt *labeltag = nullptr; + UILabelExt *labeltime = nullptr; + UILabelExt *labelmile = nullptr; + UILabelExt *labelheart = nullptr; + UILabelExt *labelstrong = nullptr; + UILabelExt *label16_ = nullptr; UILabelExt *label17_ = nullptr; UILabelExt *label18_ = nullptr; UILabelExt *label19_ = nullptr; - UIButton *button1_ = nullptr; + UIButton *buttonexit = nullptr; UIImageView *image1_ = nullptr; UIImageView *image2_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h index 8da6adffc..b50ef792c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h @@ -43,6 +43,10 @@ #include #include +#define GILROY_REGULAR_FONT "./font_library/gilroy-regular-3.ttf" +#define GILROY_BOLD_FONT "./font_library/gilroy-bold-4.ttf" +#define GILROY_MEDIUM_FONT "./font_library/gilroy-medium-2.ttf" + struct QuickTraining { OHOS::UIResourceTextId training1_Text; @@ -138,7 +142,7 @@ namespace OHOS Pause, Continue }; - // 运动类型 + // 运动项目 enum class ExerciseClass { NORMAL = 0, @@ -148,6 +152,18 @@ namespace OHOS FITNESS_PEDOMETER, FREE_TRAINING, }; + // 运动类型 + enum class Exercisetype + { + FITNESS = 0, + DANCE, + LEISURE, + BALL, + WATER, + ICE, + EXTREME, + OTHER + }; struct SportData { uint64 starttime; // 开始时间时间戳 @@ -157,7 +173,7 @@ namespace OHOS int duration; // 训练时长 int steps; // 训练步数 int distance; // 训练距离 - int intensity; // 训练强度 + int intensity; // 训练强度 (0:较低强度 1:中等强度 2:高等强度 3:超高强度) int avgheart; // 训练平均心率 UIResourceTextId sportId; // 训练Id }; @@ -183,6 +199,10 @@ namespace OHOS /*定时器 */ std::string DisplayMotionDuration(); + /*设置运动类型*/ + void SetSportType(Exercisetype type); + /*获取运动类型*/ + Exercisetype GetSporType(); /*设置运动项目*/ void SetSportEvent(UIResourceTextId id); /*获取运动项目*/ @@ -203,6 +223,10 @@ namespace OHOS void SetTimestamp(); /*解析时间戳*/ std::string AnalysisTimestamp(uint64_t timestamp); + /*获取运动总时长*/ + uint32_t GetTrainingTime(); + /*平均心率计算*/ + int CalculateAverageHeartRate(int newHeartRate); private: TraingModel(const TraingModel &) = delete; @@ -210,8 +234,11 @@ namespace OHOS std::string motionDuration; // 训练时长 UIResourceTextId sportId_ = STR_EXTREME_SPORTS; // 训练项目 + Exercisetype sporttype_ = Exercisetype::FITNESS; // 训练类型 ExerciseState sportstate_ = ExerciseState::General; // 训练状态 - /*std::unique_ptr sportdata;*/ // 使用 std::unique_ptr 管理 SportData 对象 + int totalHeartRate = 0; + int countHeartRate = 0; + /*std::unique_ptr sportdata;*/ // 使用 std::unique_ptr 管理 SportData 对象 }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp index ac076655c..1d4394fb9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp @@ -44,103 +44,84 @@ namespace OHOS } // Add ScrollView to App - if (scrollView1_ == nullptr) + if (scrollView_ == nullptr) { - scrollView1_ = new UIScrollView(); + scrollView_ = new UIScrollView(); } - scrollView1_->SetPosition(0, 0); // widget's left position and top position - scrollView1_->Resize(466, 466); // widget's width and height - scrollView1_->SetViewId("scrollView1"); // Set style - scrollView1_->SetReboundSize(100); - scrollView1_->SetScrollBlankSize(35); - scrollView1_->SetHorizontalScrollState(false); - // Add to rootView - container_->Add(scrollView1_); - scrollView1_->SetVisible(true); - - // 初始化Image - // TraingModel::GetInstance()->InitImageView(image1_, 200, 131, 80, 48, "image1", BUBBLE_IMAGE); - // TraingModel::GetInstance()->InitImageView(image2_, 230, 183, 20, 20, "image2", PIONT_BUBBLE_IMAGE); - // TraingModel::GetInstance()->InitImageView(image3_, 96, 118, 271, 233, "image3", PATH_IMAGE); - // TraingModel::GetInstance()->InitImageView(image4_, 212, 402, 40, 40, "image4", INCO_UP_40_IMAGE); - TraingModel::GetInstance()->InitImageView(image5_, 80, 470 - 338, 54, 80, "image5", WALKING_54_IMAGE); - TraingModel::GetInstance()->InitImageView(image6_, 97, 552 - 338, 80, 20, "image6", LINE_IMAGE); - TraingModel::GetInstance()->InitImageView(image8_, 97, 682 - 338, 80, 20, "image6", LINE_IMAGE); - TraingModel::GetInstance()->InitImageView(image9_, 97, 812 - 338, 80, 20, "image6", LINE_IMAGE); - TraingModel::GetInstance()->InitImageView(image10_, 97, 942 - 338, 80, 20, "image6", LINE_IMAGE); - TraingModel::GetInstance()->InitImageView(image11_, 97, 1072 - 338, 80, 20, "image6", LINE_IMAGE); - - // scrollView1_->Add(image3_); - scrollView1_->Add(image6_); - scrollView1_->Add(image8_); - scrollView1_->Add(image9_); - scrollView1_->Add(image10_); - scrollView1_->Add(image11_); - // scrollView1_->Add(image1_); - // scrollView1_->Add(image2_); - // scrollView1_->Add(image4_); - scrollView1_->Add(image5_); - - // 初始化button - TraingModel::GetInstance()->InitButton(button1_, 42, 1319 - 338, 380, 100, BUTTONBACK); - button1_->SetOnClickListener(static_cast(TraingEnddataPresenter::GetInstance())); - scrollView1_->Add(button1_); + scrollView_->SetPosition(0, 0); // widget's left position and top position + scrollView_->Resize(466, 466); // widget's width and height + scrollView_->SetViewId("scrollView1"); // Set style + scrollView_->SetReboundSize(100); + scrollView_->SetScrollBlankSize(35); + scrollView_->SetHorizontalScrollState(false); + container_->Add(scrollView_); + scrollView_->SetVisible(true); + + // 初始化image + TraingModel::GetInstance()->InitImageView(image5_, 80, 132, 54, 80, "image5", WALKING_54_IMAGE); + TraingModel::GetInstance()->InitImageView(image6_, 97, 214, 80, 20, "image6", LINE_IMAGE); + TraingModel::GetInstance()->InitImageView(image8_, 97, 344, 80, 20, "image8", LINE_IMAGE); + TraingModel::GetInstance()->InitImageView(image9_, 97, 474, 80, 20, "image9", LINE_IMAGE); + TraingModel::GetInstance()->InitImageView(image10_, 97, 604, 80, 20, "image10", LINE_IMAGE); + TraingModel::GetInstance()->InitImageView(image11_, 97, 734, 80, 20, "image11", LINE_IMAGE); + scrollView_->Add(image6_); + scrollView_->Add(image8_); + scrollView_->Add(image9_); + scrollView_->Add(image10_); + scrollView_->Add(image11_); + scrollView_->Add(image5_); // 初始化Lable - TraingModel::GetInstance()->InitLabel(label1_, 188, 52, 90, 35, "label1", "健身类", DEFAULT_VECTOR_FONT_FILENAME, 30); - // TraingModel::GetInstance()->InitLabel(label2_, 220, 140, 60, 40, "label2", "达标", DEFAULT_VECTOR_FONT_FILENAME, 20); - // TraingModel::GetInstance()->InitLabel(label3_, 114, 252, 60, 40, "label3", "终", DEFAULT_VECTOR_FONT_FILENAME, 20); - // TraingModel::GetInstance()->InitLabel(label4_, 172, 284, 60, 40, "label4", "èµ·", DEFAULT_VECTOR_FONT_FILENAME, 20); - // TraingModel::GetInstance()->InitLabel(label5_, 155, 372, 60, 40, "label5", "距离:8.3KM", DEFAULT_VECTOR_FONT_FILENAME, 30); - TraingModel::GetInstance()->InitLabel(label6_, 146, 478 - 338, 60, 40, "label6", "健走", DEFAULT_VECTOR_FONT_FILENAME, 30); - TraingModel::GetInstance()->InitLabel(label7_, 146, 517 - 338, 60, 40, "label7", "13:00:22-15:00:12", DEFAULT_VECTOR_FONT_FILENAME, 28); - - TraingModel::GetInstance()->InitLabel(label8_, 146, 590 - 338, 60, 40, "label8", "目标完成度", DEFAULT_VECTOR_FONT_FILENAME, 26); - TraingModel::GetInstance()->InitLabel(label9_, 146, 720 - 338, 60, 40, "label9", "训练时长", DEFAULT_VECTOR_FONT_FILENAME, 26); - TraingModel::GetInstance()->InitLabel(label10_, 146, 850 - 338, 60, 40, "label10", "距离(ç±³)", DEFAULT_VECTOR_FONT_FILENAME, 26); - TraingModel::GetInstance()->InitLabel(label11_, 146, 980 - 338, 60, 40, "label11", "平均心率(次/分)", DEFAULT_VECTOR_FONT_FILENAME, 26); - TraingModel::GetInstance()->InitLabel(label12_, 146, 1110 - 338, 60, 40, "label2", "训练强度", DEFAULT_VECTOR_FONT_FILENAME, 26); - TraingModel::GetInstance()->InitLabel(label18_, 155, 1232 - 338, 60, 40, "label8", "更多数据请前往手机\nAPP“小希爱玩”查看", DEFAULT_VECTOR_FONT_FILENAME, 26); - - label7_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); - label8_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); - label9_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); - label10_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); - label11_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); - label12_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); - label18_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); - - TraingModel::GetInstance()->InitLabel(label13_, 146, 626 - 338, 60, 40, "label18", "226%", DEFAULT_VECTOR_FONT_FILENAME, 40); - label13_->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); - TraingModel::GetInstance()->InitLabel(label14_, 146, 756 - 338, 60, 40, "label14", "05:45:46", DEFAULT_VECTOR_FONT_FILENAME, 40); - label14_->SetTextColor(Color::GetColorFromRGBA(0xff, 0x8a, 0x36, 0xff)); - TraingModel::GetInstance()->InitLabel(label15_, 146, 886 - 338, 60, 40, "label15", "8,301", DEFAULT_VECTOR_FONT_FILENAME, 40); - label15_->SetTextColor(Color::GetColorFromRGBA(0x36, 0x4a, 0xff, 0xff)); - TraingModel::GetInstance()->InitLabel(label16_, 146, 1016 - 338, 60, 40, "label16", "144", DEFAULT_VECTOR_FONT_FILENAME, 40); - label16_->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); - TraingModel::GetInstance()->InitLabel(label17_, 146, 1146 - 338, 60, 40, "label17", "中等强度", DEFAULT_VECTOR_FONT_FILENAME, 40); - label17_->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); - TraingModel::GetInstance()->InitLabel(label19_, 201, 1348 - 338, 60, 40, "label19", "关闭", DEFAULT_VECTOR_FONT_FILENAME, 31); - - scrollView1_->Add(label1_); - // scrollView1_->Add(label2_); - // scrollView1_->Add(label3_); - // scrollView1_->Add(label4_); - // scrollView1_->Add(label5_); - scrollView1_->Add(label6_); - scrollView1_->Add(label7_); - scrollView1_->Add(label8_); - scrollView1_->Add(label9_); - scrollView1_->Add(label10_); - scrollView1_->Add(label11_); - scrollView1_->Add(label12_); - scrollView1_->Add(label13_); - scrollView1_->Add(label14_); - scrollView1_->Add(label15_); - scrollView1_->Add(label16_); - scrollView1_->Add(label17_); - scrollView1_->Add(label18_); - scrollView1_->Add(label19_); + // 初始化标签 + TraingModel::GetInstance()->InitLabel(labeltype, 188, 52, 90, 35, "label1", "健身类", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabel(labelsport, 147, 140, 240, 35, "label6", "健走", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabel(labelduration, 146, 179, 240, 40, "label7", "13:00:22-15:00:12", DEFAULT_VECTOR_FONT_FILENAME, 28); + TraingModel::GetInstance()->InitLabel(labelutag, 146, 252, 240, 40, "label8", "目标完成度", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabel(labelutime, 146, 382, 240, 40, "label9", "训练时长", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabel(labelumile, 146, 512, 240, 40, "label10", "距离(ç±³)", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabel(labeluheart, 146, 642, 240, 40, "label11", "平均心率(次/分)", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabel(labelustrong, 146, 772, 240, 40, "label2", "训练强度", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabel(labelnote, 80, 894, 300, 40, "label8", "更多数据请前往手机APP查看", DEFAULT_VECTOR_FONT_FILENAME, 30); + + // 设置文本颜色 + labelduration->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); + labelutag->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); + labelutime->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); + labelumile->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); + labeluheart->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); + labelustrong->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); + labelnote->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); + + TraingModel::GetInstance()->InitLabel(labeltag, 146, 292, 240, 60, "label18", "230%", DEFAULT_VECTOR_FONT_FILENAME, 40); + labeltag->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); + TraingModel::GetInstance()->InitLabel(labeltime, 146, 418, 240, 60, "label14", "05:45:46", DEFAULT_VECTOR_FONT_FILENAME, 40); + labeltime->SetTextColor(Color::GetColorFromRGBA(0xff, 0x8a, 0x36, 0xff)); + TraingModel::GetInstance()->InitLabel(labelmile, 146, 548, 240, 60, "label15", "8,301", DEFAULT_VECTOR_FONT_FILENAME, 40); + labelmile->SetTextColor(Color::GetColorFromRGBA(0x36, 0x4a, 0xff, 0xff)); + TraingModel::GetInstance()->InitLabel(labelheart, 146, 678, 240, 60, "label16", "144", DEFAULT_VECTOR_FONT_FILENAME, 40); + labelheart->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + TraingModel::GetInstance()->InitLabel(labelstrong, 146, 808, 240, 60, "label17", "中等强度", DEFAULT_VECTOR_FONT_FILENAME, 30); + labelstrong->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); + + scrollView_->Add(labeltype); + scrollView_->Add(labelsport); + scrollView_->Add(labeltime); + scrollView_->Add(labelutag); + scrollView_->Add(labelutime); + scrollView_->Add(labelumile); + scrollView_->Add(labeluheart); + scrollView_->Add(labelustrong); + scrollView_->Add(labeltag); + scrollView_->Add(labelduration); + scrollView_->Add(labelmile); + scrollView_->Add(labelheart); + scrollView_->Add(labelstrong); + scrollView_->Add(labelnote); + + // 初始化button + TraingModel::GetInstance()->InitButton(buttonexit, 42, 1319 - 338, 380, 100, BUTTONBACK); + buttonexit->SetOnClickListener(static_cast(TraingEnddataPresenter::GetInstance())); + scrollView_->Add(buttonexit); // Add ImageView to App if (image7_ == nullptr) @@ -151,7 +132,7 @@ namespace OHOS image7_->Resize(100, 100); // widget's width and height image7_->SetViewId("image7"); // Set style // Add to rootView - scrollView1_->Add(image7_); + scrollView_->Add(image7_); image7_->SetVisible(true); } @@ -182,6 +163,11 @@ namespace OHOS viewiInitStatus = true; } } + + void TraingEnddataView::InitData() + { + } + void TraingEnddataView::OnStart() { container_ = new UIViewGroup(); @@ -228,4 +214,5 @@ namespace OHOS RootView::GetInstance()->RemoveAll(); return; } + } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp index 8b71a235f..b22017bdd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-15 11:46:23 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-04-15 15:09:35 + * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp + */ #include "traing/include/TraingModel.h" #include "wearable_log.h" #include @@ -140,8 +146,7 @@ namespace OHOS TraingModel ::~TraingModel() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::~TraingModel()"); - // 取消订阅 - TraingUnsubscribeTopic(TOPIC_EVENT_ACTIVITY_UPDATE); + TraingUnsubscribeTopic(TOPIC_EVENT_ACTIVITY_UPDATE); // 取消订阅 } TraingModel *TraingModel::GetInstance(void) { @@ -151,10 +156,8 @@ namespace OHOS void TraingModel ::Init() { - // 进行消息订阅 - TraingSubscribeTopic(TOPIC_EVENT_ACTIVITY_UPDATE); + TraingSubscribeTopic(TOPIC_EVENT_ACTIVITY_UPDATE); // 进行消息订阅 } - /* -------------------------------------------------------------------------- */ /*** * @description: @@ -354,6 +357,14 @@ namespace OHOS } /* -------------------------------------------------------------------------- */ + /*设置运动类型*/ + void TraingModel::SetSportType(Exercisetype type) + { + } + /*获取运动类型*/ + Exercisetype TraingModel::GetSporType() + { + } /*设置运动Id*/ void TraingModel::SetSportEvent(UIResourceTextId id) { @@ -448,6 +459,11 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SetTimestamp [%d %lu]", currentState, time); } + // 获取训练时长时间戳 + uint32_t TraingModel::GetTrainingTime() + { + return g_motionTimes; + } /*解析时间戳 返回例如:13:00:22*/ std::string TraingModel::AnalysisTimestamp(uint64_t timestamp) { @@ -462,6 +478,15 @@ namespace OHOS return ss.str(); } + /*处理平均心率*/ + int TraingModel::CalculateAverageHeartRate(int newHeartRate) + { + totalHeartRate += newHeartRate; // 累加心率值 + countHeartRate++; // 记录心率值的个数 + + int averageHeartRate = totalHeartRate / countHeartRate; // 计算平均心率 + return averageHeartRate; + } /* -------------------------------------------------------------------------- */ #if TIMER /* 时间显示 */ @@ -646,7 +671,7 @@ namespace OHOS { uint64_t time; uapi_get_timestampe_ms(&time); - uint32_t timeday = time / 1000 / 60 / 60 / 12; + uint32_t timeday = time / 1000 / 60 / 60 / 24; char file_path[128] = {0}; sprintf(file_path, "%s%d.bin", TRAINING_PATH, timeday); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s", file_path); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinView.cpp index c9ced84e5..908a263ee 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinView.cpp @@ -119,14 +119,14 @@ namespace OHOS } // 初始化Lable - TraingModel::GetInstance()->InitLabel(label1_, 155, 52, 195, 35, "label1", "目标已达成", DEFAULT_VECTOR_FONT_FILENAME, 35); + TraingModel::GetInstance()->InitLabel(label1_, 83, 50, 300, 35, "label1", "目标已达成", DEFAULT_VECTOR_FONT_FILENAME, 35); container_->Add(label1_); - TraingModel::GetInstance()->InitLabel(label2_, 108, 215, 146, 35, "label2", "10,000", DEFAULT_VECTOR_FONT_FILENAME, 80); + TraingModel::GetInstance()->InitLabel(label2_, 70, 215, 326, 97, "label2", "10,000", DEFAULT_VECTOR_FONT_FILENAME, 80); label2_->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); container_->Add(label2_); - TraingModel::GetInstance()->InitLabel(label3_, 132, 307, 146, 35, "label3", "完成目标", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabel(label3_, 73, 307, 200, 35, "label3", "完成目标", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label3_); - TraingModel::GetInstance()->InitLabel(label4_, 280, 307, 146, 35, "label3", "100%", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabel(label4_, 193, 307, 160, 35, "label3", "100%", DEFAULT_VECTOR_FONT_FILENAME, 30); label4_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); container_->Add(label4_); diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/dial/panda.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/dial/panda.bin deleted file mode 100644 index 5eed8e9a6..000000000 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/dial/panda.bin and /dev/null differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/Message.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/Message.bin deleted file mode 100644 index 3959e6841..000000000 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/Message.bin and /dev/null differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/message/Line 1.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/message/Line 1.bin new file mode 100644 index 000000000..96332ba8e Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/message/Line 1.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/message/message.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/message/message.bin new file mode 100644 index 000000000..7bc9bc605 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/message/message.bin differ