From 50c70ff731be3c40e21a4b3b2f057ac4ae57cbea Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=A2=81=E6=B8=85=E6=A2=A6?= <3449750381@qq.com> Date: Tue, 24 Sep 2024 10:42:37 +0000 Subject: [PATCH] Merge #1007 into sdk602patch0626 from refs/changes/1007/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 袁清梦 * refs/changes/1007/head: (12 commits squashed) - 修改心率曲线图Y轴数字 - #144 手表,心率测量开始测量的时候显示的心率值太大,需要优化开始显示的心率值 - #678 心率初始出值不稳定,偏差太大。 - #560 运动,徒步运动设置目标1KM,实际放桌子上未动,提示我目标达成 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - #446 运动界面,上下滑,下界面是覆盖式的,优化为U6那种滑动式界面 - #667 运动结束界面,数据不完整,数据内容不丰富,没有设置目标也会显示目标完成度 - #700 运动时间显示花屏,显示逻辑不对(两台测试样机都有) - #687 省电模式-有长按不起反应现象 - #819 手表,表盘步数显示-31441,实际步数99631 - 修改表盘距离数据为uint32_t - #448 运动结束训练记录滑动会遮挡,并且运动结束会显示训练历史记录 Signed-off-by: Caisking <3449750381@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1007 --- .../wearable/fd230app/CMakeLists.txt | 1 + .../nativeui/activity/src/ActivityModel.cpp | 3 +- .../main/include/MainPresenterSample.h | 187 +-- .../main/include/dial/DialModelDistance.h | 2 +- .../main/include/dial/DialModelSteps.h | 4 +- .../main/src/dial/DialModelDistance.cpp | 17 +- .../nativeui/main/src/dial/DialModelSteps.cpp | 12 +- .../saveele/include/SaveBatPresenter.h | 2 + .../nativeui/saveele/src/SaveBatPresenter.cpp | 40 +- .../traing/include/TraingEnddataView.h | 161 +-- .../nativeui/traing/src/TraingEnddataView.cpp | 1052 +++++++++-------- .../nativeui/traing/src/TraingModel.cpp | 6 +- .../include/TraingCardPresenter.h | 116 +- .../training_card/include/TraingCardView.h | 8 +- .../training_card/include/TraingDataAllView.h | 75 ++ .../training_card/include/TrainingDataView.h | 78 +- .../include/TrainingDetailView.h | 58 +- .../training_card/src/TraingCardPresenter.cpp | 800 +++++++------ .../training_card/src/TraingCardView.cpp | 999 ++++++++-------- .../training_card/src/TraingDataAllView.cpp | 169 +++ .../training_card/src/TrainingDataView.cpp | 352 +++--- .../training_card/src/TrainingDetailView.cpp | 281 ++--- .../traingrecord/src/TraingRecordView.cpp | 11 +- 23 files changed, 2390 insertions(+), 2044 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingDataAllView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingDataAllView.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 849754813..7372ec01f 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -612,6 +612,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_card/src/TrainingControlView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_card/src/TrainingDataView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_card/src/TrainingDetailView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_card/src/TraingDataAllView.cpp #训练记录 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traingrecord/src/TraingRecordView.cpp diff --git a/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityModel.cpp index f053aac11..4b7ea8439 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityModel.cpp @@ -124,7 +124,8 @@ static void Notify(void *args, const Topic topic, Request* request) return; } // 计步数据累加 - uint32 counter =0;// OHOS::ActivityModel::GetInstance()->GetStepCounter(); + uint32_t counter = + 0; // OHOS::ActivityModel::GetInstance()->GetStepCounter(); counter = *(uint32_t *)request->data; set_step_data(counter); counter = get_step_data();//*(uint32_t *)request->data; diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h index 3837b511d..2fcb1eaad 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h @@ -3,114 +3,127 @@ * @Date: 2024-03-01 15:10:34 * @LastEditors: luozheng 1732036298@qq.com * @LastEditTime: 2024-09-03 17:53:43 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h + * @FilePath: + * /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h */ #ifndef MAIN_PRESENTER_SAMPLE_H #define MAIN_PRESENTER_SAMPLE_H -#include "Presenter.h" -#include "ModelListenerSample.h" -#include "components/root_view.h" +#include "HeartRateView.h" #include "KeyInputListener.h" -#include "drag_event.h" -#include "MainViewSample.h" +#include "MainCompassPresenter.h" +#include "MainCompassView.h" #include "MainModel.h" +#include "MainViewSample.h" +#include "ModelListenerSample.h" +#include "PlayersView.h" +#include "Presenter.h" +#include "components/root_view.h" #include "components/ui_swipe_view.h" #include "components/ui_view.h" -#include "MainCompassView.h" -#include "MainCompassPresenter.h" -#include "PlayersView.h" -#include "HeartRateView.h" +#include "drag_event.h" #include "swipe_effect/zoom_effect.h" -namespace OHOS -{ - static constexpr const char *MAIN_CLICK_WEATHER = "mainclickweather"; - static constexpr const char *MAIN_CLICK_ACTIVITY = "mainclickactivity"; - static constexpr const char *MAIN_CLICK_MESSAGE = "mainclickmessage"; - static constexpr const char *MAIN_CLICK_HEARTRATE = "mainclickheartrate"; - static constexpr const char *MAIN_CLICK_BLOOD = "mainclickblood"; // 血氧检测 - static constexpr const char *MAIN_CLICK_SETCARD = "mainclicksetcard"; // 设置卡片 +namespace OHOS { +static constexpr const char *MAIN_CLICK_WEATHER = "mainclickweather"; +static constexpr const char *MAIN_CLICK_ACTIVITY = "mainclickactivity"; +static constexpr const char *MAIN_CLICK_MESSAGE = "mainclickmessage"; +static constexpr const char *MAIN_CLICK_HEARTRATE = "mainclickheartrate"; +static constexpr const char *MAIN_CLICK_BLOOD = "mainclickblood"; // 血氧检测 +static constexpr const char *MAIN_CLICK_SETCARD = + "mainclicksetcard"; // 设置卡片 - static constexpr const char *DROPDOWN_CLICK_DONOTDISTURB = "dropdownclickdonotdisturb"; - static constexpr const char *DROPDOWN_CLICK_BRIGHTENSCREEN = "dropdownclickbrightscreen"; +static constexpr const char *DROPDOWN_CLICK_DONOTDISTURB = + "dropdownclickdonotdisturb"; +static constexpr const char *DROPDOWN_CLICK_BRIGHTENSCREEN = + "dropdownclickbrightscreen"; - static constexpr const char *DROPDOWN_CLICK_SETTING = "dropdownclicksetting"; // 设置 - static constexpr const char *DROPDOWN_CLICK_BLUETOOTH = "dropdownclickbluetooth"; // 蓝牙 - static constexpr const char *DROPDOWN_CLICK_DNOTDISTURB = "dropdownclickdnotdisturb"; // 勿扰 - static constexpr const char *DROPDOWN_CLICK_SAVEELE = "dropdownclicksaveele"; // 省电 - static constexpr const char *DROPDOWN_CLICK_FINDMYPHONE = "dropdownclickfindmyphone"; // 找手机 +static constexpr const char *DROPDOWN_CLICK_SETTING = + "dropdownclicksetting"; // 设置 +static constexpr const char *DROPDOWN_CLICK_BLUETOOTH = + "dropdownclickbluetooth"; // 蓝牙 +static constexpr const char *DROPDOWN_CLICK_DNOTDISTURB = + "dropdownclickdnotdisturb"; // 勿扰 +static constexpr const char *DROPDOWN_CLICK_SAVEELE = + "dropdownclicksaveele"; // 省电 +static constexpr const char *DROPDOWN_CLICK_FINDMYPHONE = + "dropdownclickfindmyphone"; // 找手机 - static constexpr const char *CONNECTEDSTATUSBACKGROUNDBUTTON = "connectedstatusbackgroundbutton"; // 连接状态按钮 - static constexpr const char *CONNECTEDSTATUSVIEWCLOSEBUTTON = "connectedstatusviewclosebutton"; // 连接状态视图的关闭按钮 +static constexpr const char *CONNECTEDSTATUSBACKGROUNDBUTTON = + "connectedstatusbackgroundbutton"; // 连接状态按钮 +static constexpr const char *CONNECTEDSTATUSVIEWCLOSEBUTTON = + "connectedstatusviewclosebutton"; // 连接状态视图的关闭按钮 - constexpr uint16_t VERTICAL_STATUS = 1; - constexpr uint16_t HORIZONTAL_STATUS = 0; +constexpr uint16_t VERTICAL_STATUS = 1; +constexpr uint16_t HORIZONTAL_STATUS = 0; - class MainViewSample; - class MainPresenterSample : public Presenter, public ModelListenerSample, public UIView::OnClickListener, public UIView::OnDragListener, public UISwipeView::OnSwipeListener, public UIView::OnLongPressListener, public UISwipeView, public CompassPresenter - { - public: - MainPresenterSample(); - ~MainPresenterSample() override; - static MainPresenterSample *GetInstance(void); +class MainViewSample; +class MainPresenterSample : public Presenter, + public ModelListenerSample, + public UIView::OnClickListener, + public UIView::OnDragListener, + public UISwipeView::OnSwipeListener, + public UIView::OnLongPressListener, + public UISwipeView, + public CompassPresenter { +public: + MainPresenterSample(); + ~MainPresenterSample() override; + static MainPresenterSample *GetInstance(void); - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - void Notify() override; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - bool OnLongPress(UIView &view, const LongPressEvent &event) override; - void OnSwipe(UISwipeView &view) override; - void SetPage(int8_t id); - void SetTaskPeroid(CardId cardId); - void setCallback(ZoomEffect *callback) - { - callback_ = callback; - } + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + void Notify() override; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnLongPress(UIView &view, const LongPressEvent &event) override; + void OnSwipe(UISwipeView &view) override; + void SetPage(int8_t id); + void SetTaskPeroid(CardId cardId); + void setCallback(ZoomEffect *callback) { callback_ = callback; } - void InitCardSettings(void); - uint8_t GetCardSettingCount(void); - CardId *GetCardSettings(void); - void InitDialSettings(void); - DialSetting &GetDialSetting(); - void UpdataTime(); - uint32_t GetWeekStr(char *p_week); - void UpdataBaseData(); - void PullUpDown_StartTimer(uint32_t interval); - void PullUpDown_StopTimer(void); - static uint8_t g_PullUpDownTimes; + void InitCardSettings(void); + uint8_t GetCardSettingCount(void); + CardId *GetCardSettings(void); + void InitDialSettings(void); + DialSetting &GetDialSetting(); + void UpdataTime(); + uint32_t GetWeekStr(char *p_week); + void UpdataBaseData(); + void PullUpDown_StartTimer(uint32_t interval); + void PullUpDown_StopTimer(void); + static uint8_t g_PullUpDownTimes; - void get_memcheck(); + void get_memcheck(); - bool IsFromSetCardView(void) const; - void SetFromSetCardView(bool isFrom); - uint8_t GetFromCardId(void); + bool IsFromSetCardView(void) const; + void SetFromSetCardView(bool isFrom); + uint8_t GetFromCardId(void); - private: - void LogCardTransition(CardId previous, CardId current); - void ResetSleepCardView(); - void ResetWeatherCardView(); - void ResetgoalCardView(); - void StartHeartRateDetection(); - void UpdateWatchFace(); - void UpdateWeather(); - void Updategoal(); - void ProcessDataNotify(void); - void SetCircleProgress(void); - void SetCompassRotate(void); - KeyInputListener *keyActListener_{nullptr}; - ZoomEffect *callback_{nullptr}; - uint8_t state_ = UICheckBox::UICheckBoxState::MAX_STATUS_NUM; - int64_t playerCurrentTime_{0}; - int64_t playerMusicDuration_{0}; - int64_t playerProgressValue_{0}; - bool isCompassSensorOpened_{false}; - CardId previousCardId{WATCH_FACE}; - }; +private: + void LogCardTransition(CardId previous, CardId current); + void ResetSleepCardView(); + void ResetWeatherCardView(); + void ResetgoalCardView(); + void StartHeartRateDetection(); + void UpdateWatchFace(); + void UpdateWeather(); + void Updategoal(); + void ProcessDataNotify(void); + void SetCircleProgress(void); + void SetCompassRotate(void); + KeyInputListener *keyActListener_{nullptr}; + ZoomEffect *callback_{nullptr}; + uint8_t state_ = UICheckBox::UICheckBoxState::MAX_STATUS_NUM; + int64_t playerCurrentTime_{0}; + int64_t playerMusicDuration_{0}; + int64_t playerProgressValue_{0}; + bool isCompassSensorOpened_{false}; + CardId previousCardId{WATCH_FACE}; +}; } #endif // MAIN_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelDistance.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelDistance.h index 4a7500a52..1498d820f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelDistance.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelDistance.h @@ -29,7 +29,7 @@ namespace OHOS return &instance; } bool GetDialFloatData(DialDataType &type, float &out) override; - void UpdateDistance(int16_t Distance); + void UpdateDistance(uint32_t Distance); int GetDistanceData(void); private: diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelSteps.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelSteps.h index e721c60d8..b68863777 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelSteps.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelSteps.h @@ -21,9 +21,9 @@ public: return &instance; } bool GetDialFloatData(DialDataType& type, float& out) override; - void UpdateSteps(int16_t steps); + void UpdateSteps(uint32_t steps); -private: + private: float steps_ = 0; // 11520.0: default step value as reference }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelDistance.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelDistance.cpp index 38f246631..07a12ed5b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelDistance.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelDistance.cpp @@ -17,15 +17,14 @@ namespace OHOS return true; } - void DialModelDistance::UpdateDistance(int16_t distance) - { - // 将距离从米(m)转换为公里(km)并保留一位小数 - distance_ = static_cast(distance) / 1000.0f; // distance 米 + void DialModelDistance::UpdateDistance(uint32_t distance) { + // 将距离从米(m)转换为公里(km)并保留一位小数 + distance_ = static_cast(distance) / 1000.0f; // distance 米 - if (onChangeListener_ != nullptr) - { - // 通知改变监听器更新距离数据 - onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_DISTANCE, distance_); - } + if (onChangeListener_ != nullptr) { + // 通知改变监听器更新距离数据 + onChangeListener_->OnDialFloatDataUpdate( + DialDataType::DATA_TYPE_DISTANCE, distance_); + } } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelSteps.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelSteps.cpp index b21f8cc92..4fd12b98a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelSteps.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelSteps.cpp @@ -18,11 +18,11 @@ bool DialModelSteps::GetDialFloatData(DialDataType& type, float& out) return true; } -void DialModelSteps::UpdateSteps(int16_t steps) -{ - steps_ = static_cast(steps); - if(onChangeListener_ != nullptr) { - onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_STEPS, steps_); - } +void DialModelSteps::UpdateSteps(uint32_t steps) { + steps_ = static_cast(steps); + if (onChangeListener_ != nullptr) { + onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_STEPS, + steps_); + } } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveBatPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveBatPresenter.h index 5d60a82f4..d731685c8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveBatPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/saveele/include/SaveBatPresenter.h @@ -53,6 +53,8 @@ namespace OHOS uint64_t startTime{0}; int count = 3; // 初始计数 int progressValue = 0; // 初始进度值 + uint16_t drag_x = 0; + uint16_t drag_y = 0; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveBatPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveBatPresenter.cpp index 092c6580a..4856ddfd1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveBatPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveBatPresenter.cpp @@ -1,24 +1,3 @@ -/*** - * @Date: 2024-04-15 10:55:58 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-08-20 16:29:53 - * @FilePath: - * /FD230/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveBatPresenter.cpp - */ -/*** - * @Date: 2024-04-15 10:55:58 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-08-20 16:28:11 - * @FilePath: - * /FD230/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveBatPresenter.cpp - */ -/*** - * @Date: 2024-04-15 10:55:58 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-08-17 15:08:53 - * @FilePath: - * /FD230/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveBatPresenter.cpp - */ #include "AppViewIDs.h" #include "KeyInputListener.h" @@ -59,7 +38,21 @@ SaveBatPresenter *SaveBatPresenter::GetInstance() { return g_pSaveBatPresenter; } -void SaveBatPresenter::OnStart() { Presenter::OnStart(); } +/* + void enable_drag(uint8_t direction, uint8_t enable); + void set_drag_limit(uint8_t direction, uint16_t limit); + uint16_t get_drag_limit(uint8_t direction); +*/ +void SaveBatPresenter::OnStart() { + Presenter::OnStart(); + // 1.获取原drag + drag_x = get_drag_limit(0); + drag_y = get_drag_limit(1); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "drag_x:%d,drag_y:%d", drag_x, drag_y); + // 2.设置drag + enable_drag(0, 0); + enable_drag(1, 0); +} void SaveBatPresenter::OnPause(void) { Presenter::OnPause(); } @@ -68,6 +61,9 @@ void SaveBatPresenter::OnResume(void) { Presenter::OnResume(); } void SaveBatPresenter::OnStop(void) { SaveEleModel::GetInstance()->SetViewState(false); Presenter::OnStop(); + ///回退darg设置 + enable_drag(0, 1); + enable_drag(1, 1); } bool SaveBatPresenter::OnPress(UIView &view, const PressEvent &event) { 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 be75218f1..2ed83144d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h @@ -2,116 +2,121 @@ * @Date: 2024-04-15 10:55:58 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-04-25 10:32:38 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h + * @FilePath: + * /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h */ /*** * @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 + * @FilePath: + * /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h */ #ifndef _TraingEnddata_VIEW_H #define _TraingEnddata_VIEW_H #include "BaseView.h" #include "View.h" -#include -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_ext.h" -#include "components/ui_image_view.h" +#include "components/icon_adapter.h" #include "components/ui_button.h" +#include "components/ui_card_page.h" +#include "components/ui_chart.h" #include "components/ui_image_animator.h" +#include "components/ui_image_view.h" +#include "components/ui_label.h" #include "components/ui_label_button_ext.h" -#include "components/ui_chart.h" +#include "components/ui_label_ext.h" #include "components/ui_list.h" -#include "components/icon_adapter.h" -#include "wearable_log.h" +#include "components/ui_view_group.h" #include "ohos_types.h" -#include "components/ui_card_page.h" +#include "wearable_log.h" +#include +#include "TraingEnddataPresenter.h" +#include "traing/Training_UiConfig.h" #include "traing/include/TraingModel.h" #include "uicomponents/UIComponents.h" -#include "traing/Training_UiConfig.h" -#include "TraingEnddataPresenter.h" -namespace OHOS -{ +namespace OHOS { #define BUTTONBACK "button1" - class TraingEnddataPresenter; - class TraingEnddataView : public View - { +class TraingEnddataPresenter; +class TraingEnddataView : public View { - public: - TraingEnddataView(); - virtual ~TraingEnddataView(); - static TraingEnddataView *GetInstance(void); +public: + TraingEnddataView(); + virtual ~TraingEnddataView(); + static TraingEnddataView *GetInstance(void); - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - void InitView(); - void DeInit(); + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void InitView(); + void DeInit(); - void PreLoad(void); + void PreLoad(void); - void InitData(void); - void InitializeImageViews(void); - void InitializeLabels(void); - void SetLabelsTextColor(const std::vector &labels, OHOS::ColorType color); - void AddLabelsToScrollView(const std::vector &labels); - void InitializeExitControls(void); + void InitData(void); + void InitializeImageViews(void); + void InitializeLabels(void); + void SetLabelsTextColor(const std::vector &labels, + OHOS::ColorType color); + void AddLabelsToScrollView(const std::vector &labels); + void InitializeExitControls(void); - void BonusdataView(); - void ExitView(); + void BonusdataView(); + void ExitView(); - private: - UIView::OnDragListener *draglistener{nullptr}; - TraingEnddataView(TraingEnddataView &&) = delete; - TraingEnddataView &operator=(TraingEnddataView &&) = delete; +private: + UIView::OnDragListener *draglistener{nullptr}; + TraingEnddataView(TraingEnddataView &&) = delete; + TraingEnddataView &operator=(TraingEnddataView &&) = delete; - UIViewGroup *container_ = nullptr; - UIScrollView *scrollView_ = nullptr; + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView_ = nullptr; - UILabelExt *labelutime = nullptr; // u训练时间 - UILabelExt *labelutag = nullptr; // u训练完成度 - UILabelExt *labelumile = nullptr; // u训练距离 - UILabelExt *labeluheart = nullptr; // u训练平均心率 - UILabelExt *labelustrong = nullptr; // u训练强度 - UILabelExt *labelusteps = nullptr; // u训练步数 - UILabelExt *labeluavpace = nullptr; // u训练平均配速 - UILabelExt *labelufreq = nullptr; // u训练步频 - UILabelExt *labelustride = nullptr; // u训练步幅 + UILabelExt *labelutime = nullptr; // u训练时间 + UILabelExt *labelutag = nullptr; // u训练完成度 + UILabelExt *labelumile = nullptr; // u训练距离 + UILabelExt *labeluheart = nullptr; // u训练平均心率 + UILabelExt *labelustrong = nullptr; // u训练强度 + UILabelExt *labelusteps = nullptr; // u训练步数 + UILabelExt *labeluavpace = nullptr; // u训练平均配速 + UILabelExt *labelufreq = nullptr; // u训练步频 + UILabelExt *labelustride = nullptr; // u训练步幅 + UILabelExt *labelucalorie = nullptr; // u训练卡路里 - UILabelExt *labeltype = nullptr; // 训练类型 - UILabelExt *labelsport = nullptr; // 训练项 - UILabelExt *labelduration = nullptr; // 训练时间 - UILabelExt *labeltag = nullptr; // 训练目标完成度 - UILabelExt *labeltime = nullptr; // 训练时长 - UILabelExt *labelmile = nullptr; // 训练距离 - UILabelExt *labelheart = nullptr; // 训练平均心率 - UILabelExt *labelstrong = nullptr; // 训练强度 - UILabelExt *labelsteps = nullptr; // 训练步数 - UILabelExt *labelavpace = nullptr; // 训练平均配速 - UILabelExt *labelfreq = nullptr; // 训练步频 - UILabelExt *labelstride = nullptr; // 训练步幅 + UILabelExt *labeltype = nullptr; // 训练类型 + UILabelExt *labelsport = nullptr; // 训练项 + UILabelExt *labelduration = nullptr; // 训练时间 + UILabelExt *labeltag = nullptr; // 训练目标完成度 + UILabelExt *labeltime = nullptr; // 训练时长 + UILabelExt *labelmile = nullptr; // 训练距离 + UILabelExt *labelheart = nullptr; // 训练平均心率 + UILabelExt *labelstrong = nullptr; // 训练强度 + UILabelExt *labelsteps = nullptr; // 训练步数 + UILabelExt *labelavpace = nullptr; // 训练平均配速 + UILabelExt *labelfreq = nullptr; // 训练步频 + UILabelExt *labelstride = nullptr; // 训练步幅 + UILabelExt *labelcalories = nullptr; // 训练卡路里 - UILabelExt *exitLabel = nullptr; // APP提醒 - UILabelButtonExt *exitButton = nullptr; // 返回按键 + UILabelExt *exitLabel = nullptr; // APP提醒 + UILabelButtonExt *exitButton = nullptr; // 返回按键 - UIImageView *imageIcon = nullptr; - UIImageView *imageLine2 = nullptr; - UIImageView *imageLine3 = nullptr; - UIImageView *imageLine4 = nullptr; - UIImageView *imageLine5 = nullptr; - UIImageView *imageLine6 = nullptr; - UIImageView *imageLine7 = nullptr; - UIImageView *imageLine8 = nullptr; - UIImageView *imageLine9 = nullptr; - UIImageView *imageLine10 = nullptr; + UIImageView *imageIcon = nullptr; + UIImageView *imageLine2 = nullptr; + UIImageView *imageLine3 = nullptr; + UIImageView *imageLine4 = nullptr; + UIImageView *imageLine5 = nullptr; + UIImageView *imageLine6 = nullptr; + UIImageView *imageLine7 = nullptr; + UIImageView *imageLine8 = nullptr; + UIImageView *imageLine9 = nullptr; + UIImageView *imageLine10 = nullptr; + UIImageView *imageLine11 = nullptr; + UIImageView *imageLine12 = nullptr; - bool viewiInitStatus{false}; - }; + bool viewiInitStatus{false}; +}; } // namespace OHOS #endif // TraingEnddata_PRESENTER_H 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 ded48ee29..a8abf78bb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp @@ -1,524 +1,626 @@ #include "traing/include/TraingEnddataView.h" -#include "common/image_cache_manager.h" -#include "components/ui_label_ext.h" -#include "ui_resource_string.h" #include "UiConfig.h" -#include "ui_resource_image.h" -#include +#include "common/image_cache_manager.h" #include "components/ui_button.h" +#include "components/ui_label_ext.h" +#include "traing/Training_UiConfig.h" #include "traing/include/TraingModel.h" +#include "ui_resource_image.h" +#include "ui_resource_string.h" #include "uicomponents/UIComponents.h" -#include "traing/Training_UiConfig.h" -#include // 包含数学函数库,用于四舍五入 -#include // 包含字符串处理库,用于使用 std::to_string +#include // 包含数学函数库,用于四舍五入 +#include +#include // 用于 std::ostringstream +#include // 包含字符串处理库,用于使用 std::to_string +#include /*测试打印函数*/ -#define PRINT_LINE_INFO() WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "File: %s, Line: %d\r\n", __FILE__, __LINE__) -#define PRINT_FUNCTION_LINE() WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Function: %s, Line: %d\r\n", __FUNCTION__, __LINE__) - +#define PRINT_LINE_INFO() \ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "File: %s, Line: %d\r\n", __FILE__, \ + __LINE__) +#define PRINT_FUNCTION_LINE() \ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Function: %s, Line: %d\r\n", \ + __FUNCTION__, __LINE__) + +/* + 普通运动: + 时长,平均心率,训练强度,卡路里,目标完成度 + 算法支持运动: + 时长,平均心率,训练强度,卡路里, + 距离,步数,平均配速,步幅,步频,目标完成度 +*/ #define UI_UPDATA 0 -namespace OHOS -{ +namespace OHOS { - static const int startY_Unit = 252; - static const int startY_Value = 292; - static const int labelHeight = 40; - static const int labelInterval = 130; - ColorType textColor = Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f); +static const int startY_Unit = 252; +static const int startY_Value = 292; +static const int labelHeight = 40; +static const int labelInterval = 130; +ColorType textColor = Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f); - static const int initialY = 132; - static const int lineHeight = 130; - static const int iconHeight = 80; - static const int verticalOffset = 2; - static const int baseY = 214; +static const int initialY = 132; +static const int lineHeight = 130; +static const int iconHeight = 80; +static const int verticalOffset = 2; +static const int baseY = 214; - static TraingEnddataView *g_pTraingEnddataView{nullptr}; +static TraingEnddataView *g_pTraingEnddataView{nullptr}; - TraingEnddataView::TraingEnddataView() - { - g_pTraingEnddataView = this; - } +TraingEnddataView::TraingEnddataView() { g_pTraingEnddataView = this; } - TraingEnddataView::~TraingEnddataView() - { - // DeInit(); - UIViewGroup *tmpGroup = dynamic_cast(container_); - UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); +TraingEnddataView::~TraingEnddataView() { + // DeInit(); + scrollView_->RemoveAll(); - g_pTraingEnddataView = nullptr; - } + UIViewGroup *tmpGroup = dynamic_cast(container_); + UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); - TraingEnddataView *TraingEnddataView::GetInstance() - { + g_pTraingEnddataView = nullptr; +} - return g_pTraingEnddataView; - } +TraingEnddataView *TraingEnddataView::GetInstance() { - // 初始化图像 - void TraingEnddataView ::InitializeImageViews() - { - // 初始化主图标 - InitImageView(imageIcon, 80, initialY, 54, iconHeight, "image", WALKING_54_IMAGE); - - InitImageView(imageLine2, 97, baseY, 80, 20, "image2", LINE_IMAGE); // imageLine2 - InitImageView(imageLine3, 97, baseY + lineHeight, 80, 20, "image3", LINE_IMAGE); // imageLine3 - InitImageView(imageLine4, 97, baseY + 2 * lineHeight, 80, 20, "image4", LINE_IMAGE); // imageLine4 - InitImageView(imageLine5, 97, baseY + 3 * lineHeight, 80, 20, "image5", LINE_IMAGE); // imageLine5 - scrollView_->Add(imageLine2); - scrollView_->Add(imageLine3); - scrollView_->Add(imageLine4); - scrollView_->Add(imageLine5); - scrollView_->Add(imageIcon); - -#if UI_UPDATA - InitImageView(imageLine6, 97, baseY + 4 * lineHeight, 80, 20, "image6", LINE_IMAGE); // imageLine6 - InitImageView(imageLine7, 97, baseY + 5 * lineHeight, 80, 20, "image7", LINE_IMAGE); // imageLine7 - scrollView_->Add(imageLine6); - scrollView_->Add(imageLine7); -#endif - } - void TraingEnddataView ::InitializeLabels(void) - { - /*title and sport*/ - InitRollLabel(labeltype, 83, 50, 300, 35, "label1", STR_EXERCISE_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(labelsport, 147, 140, 240, 35, "label6", "健走", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(labelduration, 146, 179, 240, 40, "label7", "13:00:22-15:00:12", DEFAULT_VECTOR_FONT_FILENAME, 28); - - // 初始化单位Label - InitRollLabel(labelutag, 146, startY_Unit + labelInterval * 0, 240, 40, "label8", STR_GOAL_ACCOMPLISHMENT_DEGREE, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitRollLabel(labelutime, 146, startY_Unit + labelInterval * 1, 240, 40, "label9", STR_TRAINING_DURATION, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitRollLabel(labeluheart, 146, startY_Unit + labelInterval * 2, 240, 40, "label11", STR_MEAN_HEART_RATE_MIN, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitRollLabel(labelustrong, 146, startY_Unit + labelInterval * 3, 240, 40, "label2", STR_TRAINING_INTENSITY, DEFAULT_VECTOR_FONT_FILENAME, 30); - - // 设置文本颜色 - labelduration->SetTextColor(textColor); - labelutag->SetTextColor(textColor); - labelutime->SetTextColor(textColor); - labeluheart->SetTextColor(textColor); - labelustrong->SetTextColor(textColor); - - // 初始化值 - InitLabel(labeltag, 146, startY_Value + 0 * labelInterval, 240, 60, "label18", "--", DEFAULT_VECTOR_FONT_FILENAME, 40); - labeltag->SetTextColor(Color::Green()); - InitLabel(labeltime, 146, startY_Value + 1 * labelInterval, 240, 60, "label14", "00:00:00", DEFAULT_VECTOR_FONT_FILENAME, 40); - labeltime->SetTextColor(Color::Red()); - InitLabel(labelheart, 146, startY_Value + 2 * labelInterval, 240, 60, "label16", "--", DEFAULT_VECTOR_FONT_FILENAME, 40); - labelheart->SetTextColor(Color::Yellow()); - InitLabel(labelstrong, 146, startY_Value + 3 * labelInterval, 240, 60, "label17", "中等强度", DEFAULT_VECTOR_FONT_FILENAME, 30); - labelstrong->SetTextColor(Color::Red()); - - scrollView_->Add(labeltype); - scrollView_->Add(labelsport); - scrollView_->Add(labeltime); - scrollView_->Add(labelutag); - scrollView_->Add(labelutime); - scrollView_->Add(labeluheart); - scrollView_->Add(labelustrong); - - scrollView_->Add(labeltag); - scrollView_->Add(labelduration); - scrollView_->Add(labelheart); - scrollView_->Add(labelstrong); - -#if UI_UPDATA - InitRollLabel(labelumile, 146, startY_Unit + labelInterval * 2, 240, 40, "label10", STR_RANGE_MILE, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitRollLabel(labelusteps, 146, startY_Unit + labelInterval * 4, 240, 40, "label12", STR_STEP_NUMBER, DEFAULT_VECTOR_FONT_FILENAME, 30); - labelumile->SetTextColor(textColor); - labelusteps->SetTextColor(textColor); - - InitLabel(labelmile, 146, startY_Value + 2 * labelInterval, 240, 60, "label15", "8,301", DEFAULT_VECTOR_FONT_FILENAME, 40); - labelmile->SetTextColor(Color::Blue()); - InitLabel(labelsteps, 146, startY_Value + 4 * labelInterval, 240, 60, "label16", "5000", DEFAULT_VECTOR_FONT_FILENAME, 40); - labelsteps->SetTextColor(Color::Green()); - - scrollView_->Add(labelumile); - scrollView_->Add(labelusteps); - scrollView_->Add(labelmile); - scrollView_->Add(labelsteps); -#endif - } - /* InitView:初始化界面*/ - void TraingEnddataView ::InitView() - { + return g_pTraingEnddataView; +} + +// 初始化图像 +void TraingEnddataView ::InitializeImageViews() { + // 初始化主图标 + InitImageView(imageIcon, 80, initialY, 54, iconHeight, "image", + WALKING_54_IMAGE); + + InitImageView(imageLine2, 97, baseY, 80, 20, "image2", + LINE_IMAGE); // imageLine2 + InitImageView(imageLine3, 97, baseY + lineHeight, 80, 20, "image3", + LINE_IMAGE); // imageLine3 + InitImageView(imageLine4, 97, baseY + 2 * lineHeight, 80, 20, "image4", + LINE_IMAGE); // imageLine4 + InitImageView(imageLine5, 97, baseY + 3 * lineHeight, 80, 20, "image5", + LINE_IMAGE); // imageLine5 + + bool isincludeTag = TraingModel::GetInstance()->GetSportTag(); + if (isincludeTag) { + InitImageView(imageLine6, 97, baseY + 4 * lineHeight, 80, 20, "image7", + LINE_IMAGE); + scrollView_->Add(imageLine6); + } + + scrollView_->Add(imageLine2); + scrollView_->Add(imageLine3); + scrollView_->Add(imageLine4); + scrollView_->Add(imageLine5); + + scrollView_->Add(imageIcon); +} +/* + InitView:初始化界面 + + 普通运动: + 时长,平均心率,训练强度,卡路里,目标完成度 + 算法支持运动: + 时长,平均心率,训练强度,卡路里,目标完成度 + 距离,步数,平均配速,步幅,步频, + + 蓝色:距离、平均配速 + 黄色:训练时长 + 橙色:平均心率、训练强度 + 绿色:步数,步幅,步频,平均配速,卡路里,目标完成度 +*/ +void TraingEnddataView ::InitializeLabels() { + + /*title and sport*/ + InitRollLabel(labeltype, 83, 50, 300, 35, "label1", STR_EXERCISE_LIST, + DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(labelsport, 147, 140, 240, 35, "label6", "健走", + DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(labelduration, 146, 179, 240, 40, "label7", "13:00:22-15:00:12", + DEFAULT_VECTOR_FONT_FILENAME, 28); + // 初始化Label + //时长 + InitRollLabel(labelutime, 146, startY_Unit + labelInterval * 0, 240, 40, + "label8", STR_TRAINING_DURATION, DEFAULT_VECTOR_FONT_FILENAME, + 30); + InitLabel(labeltime, 146, startY_Value + 0 * labelInterval, 240, 60, + "label14", "00:00:00", DEFAULT_VECTOR_FONT_FILENAME, 40); + labeltime->SetTextColor(Color::Yellow()); + //平均心率 + InitRollLabel(labeluheart, 146, startY_Unit + labelInterval * 1, 240, 40, + "label9", STR_MEAN_HEART_RATE_MIN, DEFAULT_VECTOR_FONT_FILENAME, + 30); + InitLabel(labelheart, 146, startY_Value + 1 * labelInterval, 240, 60, + "label16", "--", DEFAULT_VECTOR_FONT_FILENAME, 40); + labelheart->SetTextColor(Color::Orange()); + // 训练强度 + InitRollLabel(labelustrong, 146, startY_Unit + labelInterval * 2, 240, 40, + "label11", STR_TRAINING_INTENSITY, DEFAULT_VECTOR_FONT_FILENAME, + 30); + InitLabel(labelstrong, 146, startY_Value + 2 * labelInterval, 240, 60, + "label17", "中等强度", DEFAULT_VECTOR_FONT_FILENAME, 30); + labelstrong->SetTextColor(Color::Orange()); + //卡路里 + InitRollLabel(labelucalorie, 146, startY_Unit + labelInterval * 3, 240, 40, + "label2", STR_CALORIE_SETTING, DEFAULT_VECTOR_FONT_FILENAME, + 30); + InitLabel(labelcalories, 146, startY_Value + 3 * labelInterval, 240, 60, + "label15", "--", DEFAULT_VECTOR_FONT_FILENAME, 40); + labelcalories->SetTextColor(Color::Green()); + + //目标完成度 + bool isincludeTag = TraingModel::GetInstance()->GetSportTag(); + if (isincludeTag) { + InitRollLabel(labelutag, 146, startY_Unit + labelInterval * 4, 240, 40, + "label10", STR_GOAL_ACCOMPLISHMENT_DEGREE, + DEFAULT_VECTOR_FONT_FILENAME, 30); + labelutag->SetTextColor(textColor); + InitLabel(labeltag, 146, startY_Value + 4 * labelInterval, 240, 60, + "label18", "--", DEFAULT_VECTOR_FONT_FILENAME, 40); + labeltag->SetTextColor(Color::Green()); + scrollView_->Add(labelutag); + scrollView_->Add(labeltag); + } + + // 设置文本颜色 + labelduration->SetTextColor(textColor); + labelutime->SetTextColor(textColor); + labeluheart->SetTextColor(textColor); + labelustrong->SetTextColor(textColor); + labelucalorie->SetTextColor(textColor); + + scrollView_->Add(labeltype); + scrollView_->Add(labelsport); + scrollView_->Add(labeltime); + + scrollView_->Add(labelutime); + scrollView_->Add(labeluheart); + scrollView_->Add(labelustrong); + scrollView_->Add(labelucalorie); + + scrollView_->Add(labelduration); + scrollView_->Add(labelheart); + scrollView_->Add(labelstrong); + scrollView_->Add(labelcalories); +} +// 增加额外配置 +void TraingEnddataView::BonusdataView() { + if (!TraingModel::GetInstance()->GetIsSpecial()) + return; + + bool isincludeTag = TraingModel::GetInstance()->GetSportTag(); + int tagflge = isincludeTag ? 1 : 0; + + // 初始化线条 + + InitImageView(imageLine8, 97, baseY + (4 + tagflge) * lineHeight, 80, 20, + "image8", LINE_IMAGE); // imageLine8 + InitImageView(imageLine9, 97, baseY + (5 + tagflge) * lineHeight, 80, 20, + "image9", LINE_IMAGE); // imageLine9 + InitImageView(imageLine10, 97, baseY + (6 + tagflge) * lineHeight, 80, 20, + "image10", LINE_IMAGE); // imageLine10 + InitImageView(imageLine11, 97, baseY + (7 + tagflge) * lineHeight, 80, 20, + "image11", LINE_IMAGE); + InitImageView(imageLine12, 97, baseY + (8 + tagflge) * lineHeight, 80, 20, + "image7", LINE_IMAGE); + + scrollView_->Add(imageLine8); + scrollView_->Add(imageLine9); + scrollView_->Add(imageLine10); + scrollView_->Add(imageLine11); + scrollView_->Add(imageLine12); + + // 初始化标签 + // 距离 + InitRollLabel(labelumile, 146, startY_Unit + labelInterval * (4 + tagflge), + 240, 40, "label10", STR_RANGE_MILE, + DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(labelmile, 146, startY_Value + (4 + tagflge) * labelInterval, 240, + 60, "label15", "--", DEFAULT_VECTOR_FONT_FILENAME, 40); + labelumile->SetTextColor(textColor); + labelmile->SetTextColor(Color::Blue()); + + // 步数 + InitRollLabel(labelusteps, 146, startY_Unit + labelInterval * (5 + tagflge), + 240, 40, "label12", STR_STEP_NUMBER, + DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(labelsteps, 146, startY_Value + (5 + tagflge) * labelInterval, 240, + 60, "label17", "--", DEFAULT_VECTOR_FONT_FILENAME, 40); + labelusteps->SetTextColor(textColor); + labelsteps->SetTextColor(Color::Green()); + + // 平均配速 + InitRollLabel(labeluavpace, 146, startY_Unit + labelInterval * (6 + tagflge), + 240, 40, "label2", STR_AVG_PACE, DEFAULT_VECTOR_FONT_FILENAME, + 30); + InitLabel(labelavpace, 146, startY_Value + (6 + tagflge) * labelInterval, 240, + 60, "label17", "--", DEFAULT_VECTOR_FONT_FILENAME, 40); + labeluavpace->SetTextColor(textColor); + labelavpace->SetTextColor(Color::Green()); + + // 步幅 + InitRollLabel(labelustride, 146, startY_Unit + labelInterval * (7 + tagflge), + 240, 40, "label2", STR_STEP_LENGTH, + DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(labelstride, 146, startY_Value + (7 + tagflge) * labelInterval, 240, + 60, "label17", "77", DEFAULT_VECTOR_FONT_FILENAME, 40); + labelustride->SetTextColor(textColor); + labelstride->SetTextColor(Color::Green()); + + // 步频 + InitRollLabel(labelufreq, 146, startY_Unit + labelInterval * (8 + tagflge), + 240, 40, "label2", STR_STEP_FREQUENCY, + DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(labelfreq, 146, startY_Value + (8 + tagflge) * labelInterval, 240, + 60, "label17", "154", DEFAULT_VECTOR_FONT_FILENAME, 40); + labelufreq->SetTextColor(textColor); + labelfreq->SetTextColor(Color::Green()); + + scrollView_->Add(labelumile); + scrollView_->Add(labelmile); + scrollView_->Add(labelusteps); + scrollView_->Add(labelsteps); + scrollView_->Add(labeluavpace); + scrollView_->Add(labelavpace); + scrollView_->Add(labelustride); + scrollView_->Add(labelstride); + scrollView_->Add(labelufreq); + scrollView_->Add(labelfreq); +} +// 配置退出相关位置 +void TraingEnddataView::ExitView() { + + bool isincludeTag = TraingModel::GetInstance()->GetSportTag(); + int tagflge = isincludeTag ? 1 : 0; + + if (TraingModel::GetInstance()->GetIsSpecial()) { + // 初始化退出(最后 要根据前方配置设置位置) + // 是否为特殊运动 + // 是否包含目标 + InitRollLabel(exitLabel, 80, + (startY_Value + labelInterval * (8 + tagflge) + 100), 300, 40, + "label8", STR_MORE_APP, DEFAULT_VECTOR_FONT_FILENAME, 30); + InitButtonExt(exitButton, 42, + (startY_Value + labelInterval * (8 + tagflge) + 160), 380, + 100, BUTTONBACK, STR_CLOSE, 30); + } else { + InitRollLabel(exitLabel, 80, + (startY_Value + labelInterval * (3 + tagflge) + 100), 300, 40, + "label8", STR_MORE_APP, DEFAULT_VECTOR_FONT_FILENAME, 30); + InitButtonExt(exitButton, 42, + (startY_Value + labelInterval * (3 + tagflge) + 160), 380, + 100, BUTTONBACK, STR_CLOSE, 30); + } + exitLabel->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); + scrollView_->Add(exitLabel); + exitButton->SetOnClickListener(presenter_); + scrollView_->Add(exitButton); +} +void TraingEnddataView ::InitView() { - scrollView_ = new UIScrollView(); + scrollView_ = new UIScrollView(); - scrollView_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - scrollView_->SetScrollBlankSize(50); - // scrollView_->SetReboundSize(35); - scrollView_->SetHorizontalScrollState(false); - scrollView_->RequestFocus(); - scrollView_->SetRotateFactor(1.0); - scrollView_->SetMaxScrollDistance(1000); - scrollView_->SetDragACCLevel(5); - scrollView_->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ - scrollView_->SetTouchable(true); - scrollView_->SetDraggable(true); + scrollView_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), + Screen::GetInstance().GetHeight()); + scrollView_->SetScrollBlankSize(100); + scrollView_->SetReboundSize(50); + scrollView_->SetHorizontalScrollState(false); + scrollView_->RequestFocus(); + scrollView_->SetRotateFactor(1.0); + scrollView_->SetMaxScrollDistance(1000); + scrollView_->SetDragACCLevel(5); + scrollView_->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + scrollView_->SetTouchable(true); + scrollView_->SetDraggable(true); - /*初始化线条*/ - InitializeImageViews(); + /*初始化线条*/ + InitializeImageViews(); - /*初始化label*/ - InitializeLabels(); + /*初始化label*/ + InitializeLabels(); - BonusdataView(); // 配置额外数据 + BonusdataView(); // 配置额外数据 - ExitView(); // 配置退出组件 + ExitView(); // 配置退出组件 - container_->Add(scrollView_); - } - // 增加额外配置 - void TraingEnddataView::BonusdataView() + container_->Add(scrollView_); +} + +/* DeInit:删除组件 */ +void TraingEnddataView::DeInit() { + scrollView_->RemoveAll(); + + /*单位label*/ + delete labelutime; + labelutime = nullptr; + delete labelutag; + labelutag = nullptr; + delete labelusteps; + labelusteps = nullptr; + delete labelumile; + labelumile = nullptr; + delete labeluheart; + labeluheart = nullptr; + delete labelustrong; + labelustrong = nullptr; + delete labeluavpace; + labeluavpace = nullptr; + delete labelufreq; + labelufreq = nullptr; + delete labelustride; + labelustride = nullptr; + + /*值label*/ + delete labeltype; + labeltype = nullptr; + delete labelsport; + labelsport = nullptr; + delete labelduration; + labelduration = nullptr; + delete labeltag; + labeltag = nullptr; + delete labeltime; + labeltime = nullptr; + delete labelmile; + labelmile = nullptr; + delete labelheart; + labelheart = nullptr; + delete labelstrong; + labelstrong = nullptr; + delete labelsteps; + labelsteps = nullptr; + delete labelavpace; + labelavpace = nullptr; + delete labelfreq; + labelfreq = nullptr; + delete labelstride; + labelstride = nullptr; + + /*图片label*/ + delete imageIcon; + imageIcon = nullptr; + delete imageLine2; + imageLine2 = nullptr; + delete imageLine3; + imageLine3 = nullptr; + delete imageLine4; + imageLine4 = nullptr; + delete imageLine5; + imageLine5 = nullptr; + delete imageLine6; + imageLine6 = nullptr; + delete imageLine8; + imageLine8 = nullptr; + delete imageLine9; + imageLine9 = nullptr; + delete imageLine10; + imageLine10 = nullptr; + + /*退出相关*/ + delete exitButton; + exitButton = nullptr; + delete exitLabel; + exitLabel = nullptr; + + delete scrollView_; + scrollView_ = nullptr; +} + +void TraingEnddataView::PreLoad(void) { + if (!viewiInitStatus) { + InitView(); + viewiInitStatus = true; + } +} + +void TraingEnddataView::InitData() { + SportData *enddata = TraingModel::GetInstance()->GetSportdata(); + + if (enddata == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Enddata is nullptr. Exiting InitData()...\r\n"); + return; + } + + // 训练图标Icon + std::string imageStr = + TraingModel::GetInstance()->GetSportType(enddata->sportType); + if (!imageStr.empty()) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "imageIcon %s\r\n", + imageStr.c_str()); + if (imageIcon) // 检查 imageIcon 是否为空 { - if (!TraingModel::GetInstance()->GetIsSpecial()) - return; -#if UI_UPDATA - /*线条*/ - InitImageView(imageLine8, 97, baseY + 6 * lineHeight, 80, 20, "image8", LINE_IMAGE); // imageLine8 - InitImageView(imageLine9, 97, baseY + 7 * lineHeight, 80, 20, "image9", LINE_IMAGE); // imageLine9 - InitImageView(imageLine10, 97, baseY + 8 * lineHeight, 80, 20, "image10", LINE_IMAGE); // imageLine10 - scrollView_->Add(imageLine8); - scrollView_->Add(imageLine9); - scrollView_->Add(imageLine10); - /*label*/ - InitRollLabel(labeluavpace, 146, startY_Unit + labelInterval * 6, 240, 40, "label2", STR_AVG_PACE, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitRollLabel(labelufreq, 146, startY_Unit + labelInterval * 7, 240, 40, "label2", STR_STEP_FREQUENCY, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitRollLabel(labelustride, 146, startY_Unit + labelInterval * 8, 240, 40, "label2", STR_STEP_LENGTH, DEFAULT_VECTOR_FONT_FILENAME, 30); - labeluavpace->SetTextColor(textColor); - labelufreq->SetTextColor(textColor); - labelustride->SetTextColor(textColor); - scrollView_->Add(labeluavpace); - scrollView_->Add(labelufreq); - scrollView_->Add(labelustride); - - InitLabel(labelavpace, 146, startY_Value + 6 * labelInterval, 240, 60, "label17", "5.45", DEFAULT_VECTOR_FONT_FILENAME, 40); - labelavpace->SetTextColor(Color::Blue()); - InitLabel(labelfreq, 146, startY_Value + 7 * labelInterval, 240, 60, "label17", "154", DEFAULT_VECTOR_FONT_FILENAME, 40); - labelfreq->SetTextColor(Color::Green()); - InitLabel(labelstride, 146, startY_Value + 8 * labelInterval, 240, 60, "label17", "77", DEFAULT_VECTOR_FONT_FILENAME, 40); - labelstride->SetTextColor(Color::Green()); - scrollView_->Add(labelavpace); - scrollView_->Add(labelfreq); - scrollView_->Add(labelstride); -#else - InitRollLabel(labelumile, 146, startY_Unit + labelInterval * 4, 240, 40, "label10", STR_RANGE_MILE, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitRollLabel(labelusteps, 146, startY_Unit + labelInterval * 5, 240, 40, "label12", STR_STEP_NUMBER, DEFAULT_VECTOR_FONT_FILENAME, 30); - labelumile->SetTextColor(textColor); - labelusteps->SetTextColor(textColor); - - InitLabel(labelmile, 146, startY_Value + 4 * labelInterval, 240, 60, "label15", "8,301", DEFAULT_VECTOR_FONT_FILENAME, 40); - labelmile->SetTextColor(Color::Blue()); - InitLabel(labelsteps, 146, startY_Value + 5 * labelInterval, 240, 60, "label16", "5000", DEFAULT_VECTOR_FONT_FILENAME, 40); - labelsteps->SetTextColor(Color::Green()); - - scrollView_->Add(labelumile); - scrollView_->Add(labelusteps); - scrollView_->Add(labelmile); - scrollView_->Add(labelsteps); - - InitImageView(imageLine6, 97, baseY + 4 * lineHeight, 80, 20, "image6", LINE_IMAGE); // imageLine6 - InitImageView(imageLine7, 97, baseY + 5 * lineHeight, 80, 20, "image7", LINE_IMAGE); // imageLine7 - scrollView_->Add(imageLine6); - scrollView_->Add(imageLine7); -#endif + imageIcon->SetSrc(imageStr.c_str()); } - // 配置退出相关位置 - void TraingEnddataView::ExitView() + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Failed to get image string. Skipping imageIcon update.\r\n"); + } + + // 训练类 + UIResourceTextId typeId = + TraingModel::GetInstance()->GetSportTypeId(enddata->sportType); + if (labeltype) // 检查 labeltype 是否为空 + { + labeltype->SetTextId(typeId); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Sport Type ID set: %d\r\n", + typeId); // 打印运动类型ID + } + + // 运动项目 + if (labelsport) // 检查 labelsport 是否为空 + { + labelsport->SetTextId(enddata->sportId); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Sport ID set: %d\r\n", + enddata->sportId); // 打印运动项目ID + } + + // 运动开始结束时间 + std::string startTimeStr = enddata->start_time; + std::string endTimeStr = enddata->end_time; + std::string durationStr = startTimeStr + "-" + endTimeStr; + if (labelduration) // 检查 labelduration 是否为空 + { + labelduration->SetText(durationStr.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Duration set: %s\r\n", + durationStr.c_str()); // 打印运动时间段 + } + + // 运动目标 + if (enddata->goaldegree) { + std::string tagStr = std::to_string(enddata->goaldegree) + "%"; + if (labeltag) // 检查 labeltag 是否为空 { - if (TraingModel::GetInstance()->GetIsSpecial()) - { - // 初始化退出(最后 要根据前方配置设置位置) - InitRollLabel(exitLabel, 80, 1033, 300, 40, "label8", STR_MORE_APP, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitButtonExt(exitButton, 42, 1083, 380, 100, BUTTONBACK, STR_CLOSE, 30); - } - else - { - InitRollLabel(exitLabel, 80, 773, 300, 40, "label8", STR_MORE_APP, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitButtonExt(exitButton, 42, 823, 380, 100, BUTTONBACK, STR_CLOSE, 30); - } - exitLabel->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); - scrollView_->Add(exitLabel); - exitButton->SetOnClickListener(presenter_); - scrollView_->Add(exitButton); + labeltag->SetText(tagStr.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Goal degree set: %s\r\n", + tagStr.c_str()); // 打印运动目标 } - /* DeInit:删除组件 */ - void TraingEnddataView::DeInit() + } else { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, + "Enddata tag is null. Skipping labeltag update.\r\n"); + } + + // 运动时长 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Duration of the sport: %d\r\n", + enddata->duration); + std::string timeStr = TraingModel::GetInstance()->GetTrainingTime(); + if (labeltime) // 检查 labeltime 是否为空 + { + labeltime->SetText(timeStr.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Training time set: %s\r\n", + timeStr.c_str()); // 打印训练时间 + } + + // 运动距离 + std::string mileStr = std::to_string(enddata->distance); + if (labelmile) // 检查 labelmile 是否为空 + { + labelmile->SetText(mileStr.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Distance set: %s\r\n", + mileStr.c_str()); // 打印运动距离 + } + + // 平均心率 + std::string heartStr = std::to_string(enddata->avgheart); + if (labelheart) // 检查 labelheart 是否为空 + { + labelheart->SetText(heartStr.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Average heart rate set: %s\r\n", + heartStr.c_str()); // 打印平均心率 + } + + // 步数 + std::string stepStr = std::to_string(enddata->steps); + if (labelsteps) // 检查 labelsteps 是否为空 + { + labelsteps->SetText(stepStr.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Steps set: %s\r\n", + stepStr.c_str()); // 打印步数 + } + + // 训练强度 + UIResourceTextId intensityid = TraingModel::GetInstance()->GetIntensity(); + if (labelstrong) // 检查 labelstrong 是否为空 + { + labelstrong->SetTextId(intensityid); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Intensity ID set: %d\r\n", + intensityid); // 打印训练强度ID + } + //卡路里 + std::string calStr = std::to_string(enddata->calories); + if (labelcalories) // 检查 labelcal 是否为空 + { + labelcalories->SetText(calStr.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Calories set: %s\r\n", + calStr.c_str()); // 打印卡路里 + } + + //特殊配置 + if (TraingModel::GetInstance()->GetIsSpecial()) { + // 平均配速 + // 需要计算一下 是秒 需要显示 分钟''秒'' + int totalSeconds = enddata->apc; // 总秒数 + int minutes = totalSeconds / 60; // 计算分钟 + int seconds = totalSeconds % 60; // 计算剩余秒数 + // 格式化为字符串 + std::ostringstream oss; + oss << minutes << "'" << seconds << "\""; // 生成 "X'Y\"" 格式的字符串 + std::string avpaceStr = oss.str(); // 得到字符串 + if (labelavpace) // 检查标签是否为空 { - scrollView_->RemoveAll(); - - /*单位label*/ - delete labelutime; - labelutime = nullptr; - delete labelutag; - labelutag = nullptr; - delete labelusteps; - labelusteps = nullptr; - delete labelumile; - labelumile = nullptr; - delete labeluheart; - labeluheart = nullptr; - delete labelustrong; - labelustrong = nullptr; - delete labeluavpace; - labeluavpace = nullptr; - delete labelufreq; - labelufreq = nullptr; - delete labelustride; - labelustride = nullptr; - - /*值label*/ - delete labeltype; - labeltype = nullptr; - delete labelsport; - labelsport = nullptr; - delete labelduration; - labelduration = nullptr; - delete labeltag; - labeltag = nullptr; - delete labeltime; - labeltime = nullptr; - delete labelmile; - labelmile = nullptr; - delete labelheart; - labelheart = nullptr; - delete labelstrong; - labelstrong = nullptr; - delete labelsteps; - labelsteps = nullptr; - delete labelavpace; - labelavpace = nullptr; - delete labelfreq; - labelfreq = nullptr; - delete labelstride; - labelstride = nullptr; - - /*图片label*/ - delete imageIcon; - imageIcon = nullptr; - delete imageLine2; - imageLine2 = nullptr; - delete imageLine3; - imageLine3 = nullptr; - delete imageLine4; - imageLine4 = nullptr; - delete imageLine5; - imageLine5 = nullptr; - delete imageLine6; - imageLine6 = nullptr; - delete imageLine8; - imageLine8 = nullptr; - delete imageLine9; - imageLine9 = nullptr; - delete imageLine10; - imageLine10 = nullptr; - - /*退出相关*/ - delete exitButton; - exitButton = nullptr; - delete exitLabel; - exitLabel = nullptr; - - delete scrollView_; - scrollView_ = nullptr; + labelavpace->SetText(avpaceStr.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Average pace set: %s\r\n", + avpaceStr.c_str()); // 打印平均配速 } - void TraingEnddataView::PreLoad(void) + // 步频 + std::string freqStr = std::to_string(enddata->cdc); + if (labelfreq) // 检查 labelfreq 是否为空 { - if (!viewiInitStatus) - { - InitView(); - viewiInitStatus = true; - } + labelfreq->SetText(freqStr.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Cadence set: %s\r\n", + freqStr.c_str()); // 打印步频 } - void TraingEnddataView::InitData() + // 步幅 + std::string strideStr = std::to_string(enddata->std); + if (labelstride) // 检查 labelstride 是否为空 { - SportData *enddata = TraingModel::GetInstance()->GetSportdata(); - - if (enddata == nullptr) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Enddata is nullptr. Exiting InitData()...\r\n"); - return; - } - - // 训练图标Icon - std::string imageStr = TraingModel::GetInstance()->GetSportType(enddata->sportType); - if (!imageStr.empty()) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "imageIcon %s\r\n", imageStr.c_str()); - if (imageIcon) // 检查 imageIcon 是否为空 - { - imageIcon->SetSrc(imageStr.c_str()); - } - } - else - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Failed to get image string. Skipping imageIcon update.\r\n"); - } - - // 训练类 - UIResourceTextId typeId = TraingModel::GetInstance()->GetSportTypeId(enddata->sportType); - if (labeltype) // 检查 labeltype 是否为空 - { - labeltype->SetTextId(typeId); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Sport Type ID set: %d\r\n", typeId); // 打印运动类型ID - } - - // 运动项目 - if (labelsport) // 检查 labelsport 是否为空 - { - labelsport->SetTextId(enddata->sportId); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Sport ID set: %d\r\n", enddata->sportId); // 打印运动项目ID - } - - // 运动开始结束时间 - std::string startTimeStr = enddata->start_time; - std::string endTimeStr = enddata->end_time; - std::string durationStr = startTimeStr + "-" + endTimeStr; - if (labelduration) // 检查 labelduration 是否为空 - { - labelduration->SetText(durationStr.c_str()); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Duration set: %s\r\n", durationStr.c_str()); // 打印运动时间段 - } - - // 运动目标 - if (enddata->goaldegree) - { - std::string tagStr = std::to_string(enddata->goaldegree) + "%"; - if (labeltag) // 检查 labeltag 是否为空 - { - labeltag->SetText(tagStr.c_str()); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Goal degree set: %s\r\n", tagStr.c_str()); // 打印运动目标 - } - } - else - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Enddata tag is null. Skipping labeltag update.\r\n"); - } - - // 运动时长 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Duration of the sport: %d\r\n", enddata->duration); - std::string timeStr = TraingModel::GetInstance()->GetTrainingTime(); - if (labeltime) // 检查 labeltime 是否为空 - { - labeltime->SetText(timeStr.c_str()); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Training time set: %s\r\n", timeStr.c_str()); // 打印训练时间 - } - - // 运动距离 - std::string mileStr = std::to_string(enddata->distance); - if (labelmile) // 检查 labelmile 是否为空 - { - labelmile->SetText(mileStr.c_str()); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Distance set: %s\r\n", mileStr.c_str()); // 打印运动距离 - } - - // 平均心率 - std::string heartStr = std::to_string(enddata->avgheart); - if (labelheart) // 检查 labelheart 是否为空 - { - labelheart->SetText(heartStr.c_str()); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Average heart rate set: %s\r\n", heartStr.c_str()); // 打印平均心率 - } - - // 步数 - std::string stepStr = std::to_string(enddata->steps); - if (labelsteps) // 检查 labelsteps 是否为空 - { - labelsteps->SetText(stepStr.c_str()); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Steps set: %s\r\n", stepStr.c_str()); // 打印步数 - } - - // 训练强度 - UIResourceTextId intensityid = TraingModel::GetInstance()->GetIntensity(); - if (labelstrong) // 检查 labelstrong 是否为空 - { - labelstrong->SetTextId(intensityid); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Intensity ID set: %d\r\n", intensityid); // 打印训练强度ID - } - - if (TraingModel::GetInstance()->GetIsSpecial()) - { - // 平均配速 - std::string avpaceStr = std::to_string(enddata->apc); - if (labelavpace) // 检查 labelavpace 是否为空 - { - labelavpace->SetText(avpaceStr.c_str()); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Average pace set: %s\r\n", avpaceStr.c_str()); // 打印平均配速 - } - - // 步频 - std::string freqStr = std::to_string(enddata->cdc); - if (labelfreq) // 检查 labelfreq 是否为空 - { - labelfreq->SetText(freqStr.c_str()); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Cadence set: %s\r\n", freqStr.c_str()); // 打印步频 - } - - // 步幅 - std::string strideStr = std::to_string(enddata->std); - if (labelstride) // 检查 labelstride 是否为空 - { - labelstride->SetText(strideStr.c_str()); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Stride length set: %s\r\n", strideStr.c_str()); // 打印步幅 - } - } - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingEnddataView data initialization complete.\r\n"); + labelstride->SetText(strideStr.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Stride length set: %s\r\n", + strideStr.c_str()); // 打印步幅 } - // 设置按键监听 - static void SetKeyActListener() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener"); - // 增加按键监听 - RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::TraingEnddataPresenter::GetInstance(); - RootView::GetInstance()->SetOnKeyActListener(keyactListener); - } - void TraingEnddataView::OnStart() - { - View::OnStart(); + } - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "TraingEnddataView data initialization complete.\r\n"); +} +// 设置按键监听 +static void SetKeyActListener() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetKeyActListener"); + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = + (RootView::OnKeyActListener *)OHOS::TraingEnddataPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); +} +void TraingEnddataView::OnStart() { + View::OnStart(); - PreLoad(); - InitData(); // 刷新数据 + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), + Screen::GetInstance().GetHeight()); - SetContainerView(container_); + PreLoad(); + InitData(); // 刷新数据 - container_->SetDraggable(true); - container_->SetTouchable(true); - container_->SetOnDragListener(presenter_); + SetContainerView(container_); - SetKeyActListener(); - } + container_->SetDraggable(true); + container_->SetTouchable(true); + container_->SetOnDragListener(presenter_); - void TraingEnddataView::OnSetUpView() - { + SetKeyActListener(); +} - View::OnSetUpView(); - Draw(); - } +void TraingEnddataView::OnSetUpView() { - void TraingEnddataView::OnTearDownView() - { - View::OnTearDownView(); - return; - } + View::OnSetUpView(); + Draw(); +} - void TraingEnddataView::OnStop() - { - View::OnStop(); - RootView::GetInstance()->ClearOnKeyActListener(); - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - return; - } +void TraingEnddataView::OnTearDownView() { + View::OnTearDownView(); + return; +} +void TraingEnddataView::OnStop() { + View::OnStop(); + RootView::GetInstance()->ClearOnKeyActListener(); + if (container_ != nullptr) { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + return; } + +} // namespace OHOS 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 8a819753c..982df613c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -1334,7 +1334,8 @@ namespace OHOS /* 定时器回调函数 */ void TraingTimerCallback() { - g_motionTimes++; + g_motionTimes++; +#if 0 TraingCardPresenter *gTraingCardPresenter = TraingCardPresenter::GetInstance(); if (gTraingCardPresenter == nullptr) { @@ -1342,7 +1343,8 @@ namespace OHOS return; } gTraingCardPresenter->ModifiesTime(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingTimerCallback\r\n"); +#endif + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingTimerCallback\r\n"); } /* 开启定时器 */ 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 7e52f6804..b939924a4 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 @@ -1,87 +1,75 @@ -/*** - * @Date: 2024-04-15 10:55:58 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-08-24 15:18:42 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h - */ -/*** - * @Date: 2024-04-15 10:55:58 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-08-19 10:55:50 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h - */ -/*** - * @Author: Caisking 3449750381@qq.com - * @Date: 2024-03-19 17:37:18 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-03-26 16:54:22 - * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h - * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE - */ #ifndef _TraingCard_PRESENTER_H #define _TraingCard_PRESENTER_H +#include "ModelListenerSample.h" #include "Presenter.h" #include "TraingCardView.h" #include "traing/training_card/include/TrainingControlView.h" #include "traing/training_card/include/TrainingDataView.h" #include "traing/training_card/include/TrainingDetailView.h" -#include "ModelListenerSample.h" -#include "cywee_service.h" +#include "bletest.h" +#include "components/root_view.h" +#include "components/ui_swipe_view.h" +#include "components/ui_view.h" + #include "cywee_hal.h" +#include "cywee_service.h" #include "traing/include/TraingModel.h" #include "uicomponents/UIComponents.h" -#include "bletest.h" -namespace OHOS -{ - class TraingCardView; - class TrainingControlView; - class TrainingDataView; - class TrainingDetailView; - class TraingModel; - class TraingCardPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener, - public ModelListenerSample - { - public: - TraingCardPresenter(); - virtual ~TraingCardPresenter(); - static TraingCardPresenter *GetInstance(); +namespace OHOS { +class TraingCardView; +class TrainingControlView; +class TrainingDataView; +class TrainingDetailView; +class TraingModel; +class TraingCardPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener, + public UISwipeView::OnSwipeListener, + public ModelListenerSample { +public: + TraingCardPresenter(); + virtual ~TraingCardPresenter() override; + static TraingCardPresenter *GetInstance(void); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + // void OnTickEvent() override; + void Notify() override; - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - // void OnTickEvent() override; - void Notify() override; + bool OpenSensor(ExerciseClass type); + bool ControlSensor(ExerciseState state); - bool OpenSensor(ExerciseClass type); - bool ControlSensor(ExerciseState state); + void ModifiesTime(); + void RefreshData(SportData *sportdata); // 更新数据 - void ModifiesTime(); - void RefreshData(SportData *sportdata); // 更新数据 + void UpdateTimeOfControl(); + void UpdateTimeOfData(); + void UpdateDataView(); - /*蓝牙开启运动*/ - bool send_sport_cmd(training_ble *cmd); + /*蓝牙开启运动*/ + bool send_sport_cmd(training_ble *cmd); - /*控制*/ - void handleStartState(); - void handleEndState(); - void handlePauseState(); - void handleContinueState(); + /*控制*/ + void handleStartState(); + void handleEndState(); + void handlePauseState(); + void handleContinueState(); - private: - // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - int tag_ = 0; - bool opensensorstuats{false}; - // bool OnDragEnd(UIView& view, const DragEvent& event) override; - }; +private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + void OnSwipe(UISwipeView &view) override; + int tag_ = 0; + bool opensensorstuats{false}; + // bool OnDragEnd(UIView& view, const DragEvent& event) override; +}; } // namespace OHOS #endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardView.h index 704b05912..38126469a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardView.h @@ -35,6 +35,7 @@ #include "traing/training_card/include/TraingCardPresenter.h" #include "PlayersView.h" +#include "traing/training_card/include/TraingDataAllView.h" #include "traing/training_card/include/TrainingControlView.h" #include "traing/training_card/include/TrainingDataView.h" #include "traing/training_card/include/TrainingDetailView.h" @@ -80,6 +81,7 @@ namespace OHOS UICardPage *InitControlPage(void); UICardPage *InitDataPage(void); UICardPage *InitMusicPage(void); + UICardPage *InitDetailPage(void); void InitView(); @@ -106,10 +108,10 @@ namespace OHOS UIScrollView *endView{nullptr}; UIScrollView *getView{nullptr}; UIScrollView *heartView{nullptr}; - TrainingControlView *ControlView{nullptr}; // 控制卡片 - TrainingDataView *DataVIew{nullptr}; // 数据卡片 + TrainingControlView *controlview_{nullptr}; // 控制卡片 + TraingDataAllView *dataallview_{nullptr}; // 数据卡片 TrainingDetailView *DetailView{nullptr}; // 详细数据卡片 - PlayersView *MusicView{nullptr}; // 音乐卡片 + PlayersView *musicview_{nullptr}; // 音乐卡片 /*结束弹窗*/ UILabelExt *endtitle{nullptr}; // 结束弹窗title diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingDataAllView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingDataAllView.h new file mode 100644 index 000000000..ee8312d06 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingDataAllView.h @@ -0,0 +1,75 @@ +/*** + * @Date: 2024-06-25 10:41:08 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-09-02 09:22:33 + * @FilePath: + * /FD230/code/sdk/application/wearable/fd230app/nativeui/TraingDataAll/include/TraingDataAllView.h + */ + +#ifndef TRAING_DATA_ALL__VIEW_H +#define TRAING_DATA_ALL__VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_swipe_view.h" +#include "traing/training_card/include/TraingCardPresenter.h" +#include "traing/training_card/include/TrainingDataView.h" +#include "traing/training_card/include/TrainingDetailView.h" + +#include "components/ui_card_page.h" +namespace OHOS { + +typedef enum { + TRAING_DATA_ALL_MAIN_VIEW = 0, // Heart rate time data chart + TRAING_DATA_ALL_DETAIL_VIEW, // Detailed view + TRAING_DATA_ALL_MAX_VIEW, +} TraingDataAllPageId; + +#define TRAING_DATA_ALL_VIEW "TraingDataAllView" + +class TraingCardPresenter; +class TrainingDataView; +class TrainingDetailView; + +class TraingDataAllView : public UICardPage { +public: + TraingDataAllView(); + virtual ~TraingDataAllView(); + + static TraingDataAllView *GetInstance(void); + + UISwipeView *TraingDataAllViewInit(void); + void ClearAll(void); + + AppGroupView *TraingDataPageInit(void); + AppGroupView *TraingDetailPageInit(void); + + TrainingDataView *GetTrainingDataView(void); + TrainingDetailView *GetTrainingDetailView(void); + + UISwipeView *GetTraingDataAllPageView(void); + void ChangeView(int16_t hideView, int16_t showView); + + void InitPage(void); + + void PreLoad(void) override; + void UnLoad(void) override; + bool InitView(void); + +private: + TrainingDataView *trainingDataView{nullptr}; + TrainingDetailView *trainingDetailView{nullptr}; + TraingDataAllView *trainingDataAllView{nullptr}; + UISwipeView *traingDataAllPageView{nullptr}; + + int16_t maxPage = TRAING_DATA_ALL_MAX_VIEW; + UISwipeView *TraingDataAllSwipeViewList{nullptr}; + AppGroupView *recordCard[TRAING_DATA_ALL_MAX_VIEW]{nullptr}; + + AppGroupView *CreatePage(uint8_t pageId); + bool viewiInitStatus{false}; +}; + +} // namespace OHOS + +#endif // TRAING_DATA_ALL__VIEW_H \ No newline at end of file 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 82dd76e5d..593c89835 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 @@ -22,12 +22,13 @@ #include "components/icon_adapter.h" #include "components/ui_circle_progress.h" -#include "wearable_log.h" -#include "ohos_types.h" +#include "AppGroupView.h" #include "components/ui_card_page.h" +#include "ohos_types.h" +#include "traing/Training_UiConfig.h" #include "traing/include/TraingModel.h" #include "uicomponents/UIComponents.h" -#include "traing/Training_UiConfig.h" +#include "wearable_log.h" #include "traing/include/TraingModel.h" #include "uicomponents/UIComponents.h" @@ -39,51 +40,48 @@ namespace OHOS { #define BUTTONNOTE "button1" - class TrainingDataView : public UICardPage - { - public: - TrainingDataView(); - virtual ~TrainingDataView(); - static TrainingDataView *GetInstance(void); - - void InitView(); - void DeInit(); +class TrainingDataView : public AppGroupView { +public: + TrainingDataView(); + virtual ~TrainingDataView(); + static TrainingDataView *GetInstance(void); + bool InitPage(void); + virtual bool InitView(void *caller) override; + void DeInit(); - void PreLoad(void) override; - void UnLoad(void) override; - UILabelExt *GetTimeLabel(); - UILabelExt *GetHeartLabel(); - UICircleProgress*GetProgress(); + UILabelExt *GetTimeLabel(); + UILabelExt *GetHeartLabel(); + UICircleProgress *GetProgress(); - void UpdataTime(); + void UpdataTime(); - private: - UIView::OnDragListener *draglistener{nullptr}; - TrainingDataView(TrainingDataView &&) = delete; - TrainingDataView &operator=(TrainingDataView &&) = delete; +private: + UIView::OnDragListener *draglistener{nullptr}; + TrainingDataView(TrainingDataView &&) = delete; + TrainingDataView &operator=(TrainingDataView &&) = delete; - UIViewGroup *container_ = nullptr; + UIViewGroup *container_ = nullptr; - UILabelExt *curtimelabel = nullptr; // 当前时间 - UILabelExt *sportlabel = nullptr; // 运动项目名称 - UILabelExt *timerlabel = nullptr; // 计时 - UILabelExt *heartlabel = nullptr; // 运动实时心率 - UILabelExt *ubpmlabel = nullptr; // 运动强度 + UILabelExt *curtimelabel = nullptr; // 当前时间 + UILabelExt *sportlabel = nullptr; // 运动项目名称 + UILabelExt *timerlabel = nullptr; // 计时 + UILabelExt *heartlabel = nullptr; // 运动实时心率 + UILabelExt *ubpmlabel = nullptr; // 运动强度 - UIImageView *image_progress = nullptr; - UIImageView *image_heart = nullptr; - UIImageView *image_lowIntensity = nullptr; // 低等强度 - UIImageView *image_mediumIntensity = nullptr; // 中等强度 - UIImageView *image_highIntensity = nullptr; // 高等强度 - UIImageView *image_superHighIntensity = nullptr; // 超高等强度 + UIImageView *image_progress = nullptr; + UIImageView *image_heart = nullptr; + UIImageView *image_lowIntensity = nullptr; // 低等强度 + UIImageView *image_mediumIntensity = nullptr; // 中等强度 + UIImageView *image_highIntensity = nullptr; // 高等强度 + UIImageView *image_superHighIntensity = nullptr; // 超高等强度 - UICircleProgress *circleProgress = nullptr; + UICircleProgress *circleProgress = nullptr; - UIImageView *image_iconup = nullptr; - UIImageView *image_iconpoint = nullptr; + UIImageView *image_iconup = nullptr; + UIImageView *image_iconpoint = nullptr; - UIButton *buttonNote = nullptr; // 注意事项按键 - bool viewiInitStatus{false}; - }; + UIButton *buttonNote = nullptr; // 注意事项按键 + bool viewiInitStatus{false}; +}; } // namespace OHOS #endif // TraingData_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDetailView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDetailView.h index 84566bf99..7f32c43a7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDetailView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDetailView.h @@ -36,44 +36,42 @@ namespace OHOS { - class TrainingDetailView : public UICardPage - { - public: - TrainingDetailView(); - virtual ~TrainingDetailView(); - static TrainingDetailView *GetInstance(void); +class TrainingDetailView : public AppGroupView { +public: + TrainingDetailView(); + virtual ~TrainingDetailView(); + static TrainingDetailView *GetInstance(void); - void InitView(); - void DeInit(); + void DeInit(); - void PreLoad(void) override; - void UnLoad(void) override; + bool InitPage(void); + virtual bool InitView(void *caller) override; - UILabelExt *GetMileLabel(); - UILabelExt *GetStepLabel(); - UILabelExt *GetCalorieLabel(); - UILabelButtonExt *Get_Intensity_Button(); + UILabelExt *GetMileLabel(); + UILabelExt *GetStepLabel(); + UILabelExt *GetCalorieLabel(); + UILabelButtonExt *Get_Intensity_Button(); - private: - UIView::OnDragListener *draglistener{nullptr}; - TrainingDetailView(TrainingDetailView &&) = delete; - TrainingDetailView &operator=(TrainingDetailView &&) = delete; +private: + UIView::OnDragListener *draglistener{nullptr}; + TrainingDetailView(TrainingDetailView &&) = delete; + TrainingDetailView &operator=(TrainingDetailView &&) = delete; - UIViewGroup *container_ = nullptr; + UIViewGroup *container_ = nullptr; - UILabelButtonExt *intensity_button{nullptr}; + UILabelButtonExt *intensity_button{nullptr}; - UILabelExt *u_milelabel = nullptr; - UILabelExt *u_stepslabel = nullptr; - UILabelExt *u_calorielabel = nullptr; - UILabelExt *milelabel = nullptr; - UILabelExt *steplabel = nullptr; - UILabelExt *calorielabel = nullptr; + UILabelExt *u_milelabel = nullptr; + UILabelExt *u_stepslabel = nullptr; + UILabelExt *u_calorielabel = nullptr; + UILabelExt *milelabel = nullptr; + UILabelExt *steplabel = nullptr; + UILabelExt *calorielabel = nullptr; - UIImageView *progress_image = nullptr; - UIImageView *lineimage2_ = nullptr; + UIImageView *progress_image = nullptr; + UIImageView *lineimage2_ = nullptr; - bool viewiInitStatus{false}; - }; + bool viewiInitStatus{false}; +}; } // namespace OHOS #endif // TraingDetail_PRESENTER_H 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 16488879a..9d1ea290c 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 @@ -2,34 +2,36 @@ * @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 + * @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 * @LastEditTime: 2024-04-26 10:25:05 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp + * @FilePath: + * /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp */ #include "AppViewIDs.h" +#include "NativeAbility.h" #include "components/ui_label_ext.h" #include "ui_resource_string.h" -#include "NativeAbility.h" -#include -#include -#include +#include "ConfigModel.h" +#include "custom_utils.h" +#include "graphic_service.h" +#include "traing/include/TraingModel.h" #include "traing/training_card/include/TraingCardPresenter.h" #include "traing/training_card/include/TrainingControlView.h" -#include "traing/include/TraingModel.h" #include "uicomponents/UIComponents.h" -#include "ConfigModel.h" -#include "custom_utils.h" #include "vibrator_service.h" +#include #include +#include #include +#include #include -#include "graphic_service.h" extern "C" void do_cywee_service_check_msg(int cmd, int data[]); @@ -38,196 +40,214 @@ extern "C" void do_cywee_service_check_msg(int cmd, int data[]); #define DEFAULT_DASH "--" #define DATATEST 0 -extern "C" -{ - void InitTimer(); - void DisableTimer(); - void PauseTimer(); - void ResumeTimer(); +extern "C" { +void InitTimer(); +void DisableTimer(); +void PauseTimer(); +void ResumeTimer(); } -namespace OHOS -{ - // 当前Presenter属性实例化的内存指针 - static TraingCardPresenter *g_pTraingCardPresenter = nullptr; +namespace OHOS { +// 当前Presenter属性实例化的内存指针 +static TraingCardPresenter *g_pTraingCardPresenter = nullptr; - TraingCardPresenter::TraingCardPresenter() - { - g_pTraingCardPresenter = this; - } +TraingCardPresenter::TraingCardPresenter() { g_pTraingCardPresenter = this; } - TraingCardPresenter::~TraingCardPresenter() - { - // tag_ = 0; - g_pTraingCardPresenter = nullptr; - } - - TraingCardPresenter *TraingCardPresenter::GetInstance() - { - static TraingCardPresenter instance; - return &instance; - } +TraingCardPresenter::~TraingCardPresenter() { + // tag_ = 0; + g_pTraingCardPresenter = nullptr; +} - void TraingCardPresenter::OnStart() - { - Presenter::OnStart(); - // ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 长亮屏 - } +TraingCardPresenter *TraingCardPresenter::GetInstance() { + static TraingCardPresenter instance; + return &instance; +} - void TraingCardPresenter::OnPause(void) - { +void TraingCardPresenter::OnStart() { + Presenter::OnStart(); + // ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 长亮屏 +} - Presenter::OnPause(); - } +void TraingCardPresenter::OnPause(void) { - void TraingCardPresenter::OnResume(void) - { + Presenter::OnPause(); +} - Presenter::OnResume(); - } +void TraingCardPresenter::OnResume(void) { - void TraingCardPresenter::OnStop(void) - { + Presenter::OnResume(); +} - Presenter::OnStop(); - // ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 长亮屏 - } +void TraingCardPresenter::OnStop(void) { - bool TraingCardPresenter::OnDrag(UIView &view, const DragEvent &event) - { - UNUSED(view); - return true; - } + Presenter::OnStop(); + // ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 长亮屏 +} - // 计时器更新timer - void TraingCardPresenter::ModifiesTime() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ModifiesTime begin"); - std ::string TimeStr = TraingModel::GetInstance()->DisplayMotionDuration(); +bool TraingCardPresenter::OnDrag(UIView &view, const DragEvent &event) { + UNUSED(view); + return true; +} - /*灭屏状态不刷新UI*/ - if (uapi_get_screen_state() == 1) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_get_screen_state is off"); - return; - } +// 计时器更新timer +void TraingCardPresenter::ModifiesTime() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ModifiesTime begin"); + std ::string TimeStr = TraingModel::GetInstance()->DisplayMotionDuration(); + + /*灭屏状态不刷新UI*/ + if (uapi_get_screen_state() == 1) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_get_screen_state is off"); + return; + } + + if (TimeStr.empty()) { + WEARABLE_LOGE( + WEARABLE_LOG_MODULE_APP, + "TraingModel::GetInstance()->DisplayMotionDuration() nullptr"); + return; + } + if (TrainingControlView::GetInstance()->GetTimeLabel() != nullptr) { + TrainingControlView::GetInstance()->GetTimeLabel()->SetText( + TimeStr.c_str()); + } + if (TrainingDataView::GetInstance()->GetTimeLabel() != nullptr) { + TrainingDataView::GetInstance()->GetTimeLabel()->SetText(TimeStr.c_str()); + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ModifiesTime end"); +} - if (TimeStr.empty()) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::GetInstance()->DisplayMotionDuration() nullptr"); - return; - } - if (TrainingControlView::GetInstance()->GetTimeLabel() != nullptr) - { - TrainingControlView::GetInstance()->GetTimeLabel()->SetText(TimeStr.c_str()); - } - if (TrainingDataView::GetInstance()->GetTimeLabel() != nullptr) - { - TrainingDataView::GetInstance()->GetTimeLabel()->SetText(TimeStr.c_str()); - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ModifiesTime end"); - } +//计时器 +void TraingCardPresenter::UpdateTimeOfControl() { + std ::string TimeStr = TraingModel::GetInstance()->DisplayMotionDuration(); + if (TimeStr.empty()) { + WEARABLE_LOGE( + WEARABLE_LOG_MODULE_APP, + "TraingModel::GetInstance()->DisplayMotionDuration() nullptr"); + return; + } + if (TrainingControlView::GetInstance()->GetTimeLabel() != nullptr) { + TrainingControlView::GetInstance()->GetTimeLabel()->SetText( + TimeStr.c_str()); + } +} +void TraingCardPresenter::UpdateTimeOfData() { + std ::string TimeStr = TraingModel::GetInstance()->DisplayMotionDuration(); + if (TimeStr.empty()) { + WEARABLE_LOGE( + WEARABLE_LOG_MODULE_APP, + "TraingModel::GetInstance()->DisplayMotionDuration() nullptr"); + return; + } + if (TrainingDataView::GetInstance()->GetTimeLabel() != nullptr) { + TrainingDataView::GetInstance()->GetTimeLabel()->SetText(TimeStr.c_str()); + } +} - /* --------------------------------- cywee库操作 -------------------------------- */ - /*开启cywee*/ - bool TraingCardPresenter::OpenSensor(ExerciseClass type) - { - // 防止重复开启 - if (opensensorstuats) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OpenSensor is opening!!"); - return false; - } - // 根据不同的运动项目进行不同的运动 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardPresenter::OpenSensor!!"); - switch (type) - { - case ExerciseClass::NORMAL: - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NORMAL_MODE, NULL); - break; - case ExerciseClass::TREADMILL: - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_TREADMILL_MODE, NULL); - break; - case ExerciseClass::OUTDOOR: - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OUTDOOR_RUNNING_MODE, NULL); - break; - case ExerciseClass::INDOOR: - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_INDOOR_RUNNING_MODE, NULL); - break; - case ExerciseClass::FITNESS_PEDOMETER: - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_FITNESS_PEDOMETER_MODE, NULL); - break; - case ExerciseClass::FREE_TRAINING: - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_FREE_TRAINING_MODE, NULL); - break; - default: - break; - } - opensensorstuats = true; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OpenSensor--%d!!", type); - return true; - } +/* --------------------------------- cywee库操作 + * -------------------------------- */ +/*开启cywee*/ +bool TraingCardPresenter::OpenSensor(ExerciseClass type) { + // 防止重复开启 + if (opensensorstuats) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OpenSensor is opening!!"); + return false; + } + // 根据不同的运动项目进行不同的运动 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardPresenter::OpenSensor!!"); + switch (type) { + case ExerciseClass::NORMAL: + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NORMAL_MODE, NULL); + break; + case ExerciseClass::TREADMILL: + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_TREADMILL_MODE, NULL); + break; + case ExerciseClass::OUTDOOR: + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OUTDOOR_RUNNING_MODE, NULL); + break; + case ExerciseClass::INDOOR: + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_INDOOR_RUNNING_MODE, NULL); + break; + case ExerciseClass::FITNESS_PEDOMETER: + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_FITNESS_PEDOMETER_MODE, NULL); + break; + case ExerciseClass::FREE_TRAINING: + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_FREE_TRAINING_MODE, NULL); + break; + default: + break; + } + opensensorstuats = true; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OpenSensor--%d!!", type); + return true; +} - /*控制cywee*/ - bool TraingCardPresenter::ControlSensor(ExerciseState state) - { - switch (state) - { - case ExerciseState::End: - // 退出进入普通模式 - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NORMAL_MODE, NULL); - opensensorstuats = false; // 恢复标志位 - DisableTimer(); // 关闭计时器 - break; - case ExerciseState::Pause: - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_PAUSE, 0); - break; - case ExerciseState::Continue: - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_RESUME, 0); - break; - default: - break; - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ControlSensor[%d]!!", state); - return true; - } +/*控制cywee*/ +bool TraingCardPresenter::ControlSensor(ExerciseState state) { + switch (state) { + case ExerciseState::End: + // 退出进入普通模式 + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NORMAL_MODE, NULL); + opensensorstuats = false; // 恢复标志位 + DisableTimer(); // 关闭计时器 + break; + case ExerciseState::Pause: + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_PAUSE, 0); + break; + case ExerciseState::Continue: + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_RESUME, 0); + break; + default: + break; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ControlSensor[%d]!!", state); + return true; +} - void TraingCardPresenter::RefreshData(SportData *sportdata) - { - if (sportdata == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportdata is null"); - return; - } - std::string distanceStr; - if (sportdata->distance != 0) - { - double distance_km = sportdata->distance / 1000.0; // 转换为公里并保留两位小数 - std::stringstream ss; - ss << std::fixed << std::setprecision(2) << distance_km; - distanceStr = ss.str(); - } - else - { - distanceStr = DEFAULT_DASH; - } - - std::string heartStr = (sportdata->heart != 0) ? std::to_string(sportdata->heart) : DEFAULT_DASH; - std::string stepsStr = (sportdata->steps != 0) ? std::to_string(sportdata->steps) : DEFAULT_DASH; - std::string calorieStr = (sportdata->calories != 0) ? std::to_string(sportdata->calories) : DEFAULT_DASH; - // 训练强度刷新 - UIResourceTextId intensityid = TraingModel::GetInstance()->GetIntensity(); - // 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_LOGD(WEARABLE_LOG_MODULE_APP, "[Calories: %s, Distance: %s, Steps: %s Intensityid: %d]", calorieStr.c_str(), distanceStr.c_str(), stepsStr.c_str(), intensityid); - // 释放sportdata内存 - } +void TraingCardPresenter::RefreshData(SportData *sportdata) { + if (sportdata == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportdata is null"); + return; + } + std::string distanceStr; + if (sportdata->distance != 0) { + double distance_km = + sportdata->distance / 1000.0; // 转换为公里并保留两位小数 + std::stringstream ss; + ss << std::fixed << std::setprecision(2) << distance_km; + distanceStr = ss.str(); + } else { + distanceStr = DEFAULT_DASH; + } + + std::string heartStr = + (sportdata->heart != 0) ? std::to_string(sportdata->heart) : DEFAULT_DASH; + std::string stepsStr = + (sportdata->steps != 0) ? std::to_string(sportdata->steps) : DEFAULT_DASH; + std::string calorieStr = (sportdata->calories != 0) + ? std::to_string(sportdata->calories) + : DEFAULT_DASH; + // 训练强度刷新 + UIResourceTextId intensityid = TraingModel::GetInstance()->GetIntensity(); + // 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_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() @@ -242,210 +262,236 @@ namespace OHOS } #endif #if 1 - void TraingCardPresenter::Notify(void) - { - // 未开启训练 直接退出 - if (TraingModel::GetInstance()->GetSportState() == ExerciseState::General) - return; +void TraingCardPresenter::Notify(void) { + // 如果未开启训练,直接退出 + if (TraingModel::GetInstance()->GetSportState() == ExerciseState::General) { + return; + } + + Control_Card cardId = static_cast(view_->GetCurrentPage()); + + switch (cardId) { + case Control_Card::CONTROL: { + UpdateTimeOfControl(); // 更新控制界面的时间 + break; + } + case Control_Card::DATA: { + UpdateDataView(); // 更新训练数据视图 + break; + } + default: + break; // 其他情况不处理 + } +} - // 刷新训练数据界面 现实时间 - GraphicService::GetInstance()->PostGraphicEvent(std::bind(&TrainingDataView::UpdataTime, TrainingDataView::GetInstance())); +void TraingCardPresenter::UpdateDataView() { + // 刷新计时 + UpdateTimeOfData(); - // 刷新训练数据界面 心率 卡路里 距离 步数 训练强度 目标完成度 - SportData *sportdata = TraingModel::GetInstance()->GetSportdata(); - GraphicService::GetInstance()->PostGraphicEvent(std::bind(&TraingCardPresenter::RefreshData, TraingCardPresenter::GetInstance(), sportdata)); - } + // 刷新训练数据视图,显示当前时间 + GraphicService::GetInstance()->PostGraphicEvent(std::bind( + &TrainingDataView::UpdataTime, TrainingDataView::GetInstance())); + + // 刷新训练数据:心率、卡路里、距离、步数、训练强度、目标完成度 + SportData *sportdata = TraingModel::GetInstance()->GetSportdata(); + RefreshData(sportdata); +} #endif - /* --------------------------------- 点击事件处理 --------------------------------- */ - bool TraingCardPresenter::OnClick(UIView &view, const ClickEvent &event) - { - const std::string viewId = view.GetViewId(); - - // 定义点击事件映射 - static const std::unordered_map> actionMap = { - // 暂停按键 - {BUTTONSTOP, [&]() - { - auto currentState = TraingModel::GetInstance()->GetSportState(); - if (currentState == ExerciseState::Continue || currentState == ExerciseState::Start) - { - handlePauseState(); - } - else if (currentState == ExerciseState::Pause) - { - handleContinueState(); - } - }}, - // 结束按键 - {BUTTONEND, [&]() - { - ControlSensor(ExerciseState::Pause); - TraingCardView::GetInstance()->SetPopupViewStatus(EndPopup, true); - TraingCardView::GetInstance()->RefreshEndView(); - }}, - // 确定结束 - {BUTTONEXIT, [&]() - { - handleEndState(); - }}, - // 返回 - {BUTTONBACK, [&]() - { - ControlSensor(ExerciseState::Continue); - TraingCardView::GetInstance()->SetPopupViewStatus(EndPopup, false); - }}, - // 确定达到目标 - {BUTTONWINOK, [&]() - { - TraingCardView::GetInstance()->SetPopupViewStatus(GetTagPopup, false); - TraingCardView::GetInstance()->GetAnimator()->Stop(); - }}, - // 确定心率提醒 - {BUTTONNOTE, [&]() - { - TraingCardView::GetInstance()->SetPopupViewStatus(HeartPopup, false); - }}, - }; - - // 查找并执行对应的操作 - auto it = actionMap.find(viewId); - if (it != actionMap.end()) - { - it->second(); // 执行操作 - return true; - } - - return false; // 没有匹配的操作 +/* --------------------------------- 点击事件处理 + * --------------------------------- */ +bool TraingCardPresenter::OnClick(UIView &view, const ClickEvent &event) { + const std::string viewId = view.GetViewId(); + + // 定义点击事件映射 + static const std::unordered_map> + actionMap = { + // 暂停按键 + {BUTTONSTOP, + [&]() { + auto currentState = TraingModel::GetInstance()->GetSportState(); + if (currentState == ExerciseState::Continue || + currentState == ExerciseState::Start) { + handlePauseState(); + } else if (currentState == ExerciseState::Pause) { + handleContinueState(); + } + }}, + // 结束按键 + {BUTTONEND, + [&]() { + ControlSensor(ExerciseState::Pause); + TraingCardView::GetInstance()->SetPopupViewStatus(EndPopup, true); + TraingCardView::GetInstance()->RefreshEndView(); + }}, + // 确定结束 + {BUTTONEXIT, [&]() { handleEndState(); }}, + // 返回 + {BUTTONBACK, + [&]() { + ControlSensor(ExerciseState::Continue); + TraingCardView::GetInstance()->SetPopupViewStatus(EndPopup, false); + }}, + // 确定达到目标 + {BUTTONWINOK, + [&]() { + TraingCardView::GetInstance()->SetPopupViewStatus(GetTagPopup, + false); + TraingCardView::GetInstance()->GetAnimator()->Stop(); + }}, + // 确定心率提醒 + {BUTTONNOTE, + [&]() { + TraingCardView::GetInstance()->SetPopupViewStatus(HeartPopup, + false); + }}, + }; + + // 查找并执行对应的操作 + auto it = actionMap.find(viewId); + if (it != actionMap.end()) { + it->second(); // 执行操作 + return true; + } + + return false; // 没有匹配的操作 +} +void TraingCardPresenter::OnSwipe(UISwipeView &view) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TempPresenter::OnSwipe "); + UNUSED(view); + return; +} +/* -------------------------------- 协议发起运动处理 + * -------------------------------- */ +bool TraingCardPresenter::send_sport_cmd(training_ble *cmd) { + if (cmd == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid sport command"); + return false; + } + + switch (cmd->controlmd) { + case SETGOAL: + if (TraingModel::GetInstance()->GetSportState() == ExerciseState::General) { + // 设置目标:在非运动情况下设置 [单指令,执行后退出] + TraingModel::GetInstance()->SetSportTag( + static_cast(cmd->sportTagType), cmd->sportTag); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetSportTag is succeed!\r\n"); + return true; } - - /* -------------------------------- 协议发起运动处理 -------------------------------- */ - bool TraingCardPresenter::send_sport_cmd(training_ble *cmd) - { - if (cmd == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Invalid sport command"); - return false; - } - - switch (cmd->controlmd) - { - case SETGOAL: - if (TraingModel::GetInstance()->GetSportState() == ExerciseState::General) - { - // 设置目标:在非运动情况下设置 [单指令,执行后退出] - TraingModel::GetInstance()->SetSportTag(static_cast(cmd->sportTagType), cmd->sportTag); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetSportTag is succeed!\r\n"); - return true; - } - break; - - case SENDDATA: - TraingModel::GetInstance()->SendLiveData(); // 发送实时数据 [单指令,执行后退出] - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SendLiveData is succeed!\r\n"); - return true; - default: - break; - } - - if (TraingCardView::GetInstance() == nullptr) - { - uapi_set_screen_on_api(); // 亮屏 - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCRAD); - // 设置目标类型和项目有且只有一次 - switch (cmd->sportType) - { - case 0: - TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORWALKING); - OpenSensor(ExerciseClass::OUTDOOR); - break; - case 1: - TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORRUNNING); - OpenSensor(ExerciseClass::OUTDOOR); - break; - case 2: - TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORBIKING); - OpenSensor(ExerciseClass::FREE_TRAINING); - break; - default: - break; - } - } - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "cmd->sportType[%d],cmd->controlmd[%d],cmd->sportTagType[%d],cmd->sportTag[%d]\r\n", cmd->sportType, cmd->controlmd, cmd->sportTagType, cmd->sportTag); - - ExerciseState cmdState = static_cast(cmd->controlmd); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ExerciseState::End [%d]\r\n", cmdState); - - switch (cmdState) - { - case ExerciseState::End: - handleEndState(); - break; - case ExerciseState::Pause: - handlePauseState(); - break; - case ExerciseState::Continue: - handleContinueState(); - break; - case ExerciseState::Start: - handleStartState(); - break; - default: - break; - } - - return true; + break; + + case SENDDATA: + TraingModel::GetInstance() + ->SendLiveData(); // 发送实时数据 [单指令,执行后退出] + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SendLiveData is succeed!\r\n"); + return true; + default: + break; + } + + if (TraingCardView::GetInstance() == nullptr) { + uapi_set_screen_on_api(); // 亮屏 + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCRAD); + // 设置目标类型和项目有且只有一次 + switch (cmd->sportType) { + case 0: + TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORWALKING); + OpenSensor(ExerciseClass::OUTDOOR); + break; + case 1: + TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORRUNNING); + OpenSensor(ExerciseClass::OUTDOOR); + break; + case 2: + TraingModel::GetInstance()->SetSportEvent(STR_EXERCISE_OUTDOORBIKING); + OpenSensor(ExerciseClass::FREE_TRAINING); + break; + default: + break; } + } + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, + "cmd->sportType[%d],cmd->controlmd[%d],cmd->sportTagType[%d]," + "cmd->sportTag[%d]\r\n", + cmd->sportType, cmd->controlmd, cmd->sportTagType, + cmd->sportTag); + + ExerciseState cmdState = static_cast(cmd->controlmd); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ExerciseState::End [%d]\r\n", + cmdState); + + switch (cmdState) { + case ExerciseState::End: + handleEndState(); + break; + case ExerciseState::Pause: + handlePauseState(); + break; + case ExerciseState::Continue: + handleContinueState(); + break; + case ExerciseState::Start: + handleStartState(); + break; + default: + break; + } + + return true; +} - /*训练结束*/ - void TraingCardPresenter::handleEndState() - { - TraingModel::GetInstance()->SetSportState(ExerciseState::End); - ControlSensor(ExerciseState::End); +/*训练结束*/ +void TraingCardPresenter::handleEndState() { + TraingModel::GetInstance()->SetSportState(ExerciseState::End); + ControlSensor(ExerciseState::End); #if DATATEST - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDDATA); - return; + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDDATA); + return; #endif - // 是否达到训练目标 - if (TraingModel::GetInstance()->GetMomentum()) - { - // 进入训练详情 - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDDATA); - NativeAbility::GetInstance().ClearSliceIdStack(); // 清空所有SLiceId栈元素 - } - else - { - // 进入训练记录 - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING_RECORD); - NativeAbility::GetInstance().ClearSliceIdStack(); // 清空所有SLiceId栈元素 - } - } - - /*训练暂停*/ - void TraingCardPresenter::handlePauseState() - { - TrainingControlView::GetInstance()->GetLabel()->SetTextId(STR_RESUME); - TrainingControlView::GetInstance()->GetButton()->SetImageSrc(SPORT_CONTINUE_IMAGE, SPORT_CONTINUE_IMAGE); - TraingModel::GetInstance()->SetSportState(ExerciseState::Pause); - PauseTimer(); - ControlSensor(ExerciseState::Pause); + // 是否达到训练目标 + if (TraingModel::GetInstance()->GetMomentum()) { + // 进入训练详情 + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDDATA); + NativeAbility::GetInstance().ClearSliceIdStack(); // 清空所有SLiceId栈元素 + } else { + // 进入训练记录 + // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING_RECORD); + if (TraingModel::GetInstance()->GetEntryType() == APPLIST_ENTER) + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING, + TransitionType::TRANSITION_ZOOM); + else { + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN, + TransitionType::TRANSITION_ZOOM); + NativeAbility::GetInstance().ClearSliceIdStack(); // 清空所有SLiceId栈元素 } + NativeAbility::GetInstance().ClearSliceIdStack(); // 清空所有SLiceId栈元素 + } +} - /*训练继续*/ - void TraingCardPresenter::handleContinueState() - { - TrainingControlView::GetInstance()->GetLabel()->SetTextId(STR_PAUSE); - TrainingControlView::GetInstance()->GetButton()->SetImageSrc(SPORT_PAUSE_IMAGE, SPORT_PAUSE_IMAGE); - TraingModel::GetInstance()->SetSportState(ExerciseState::Continue); - ResumeTimer(); - ControlSensor(ExerciseState::Continue); - } +/*训练暂停*/ +void TraingCardPresenter::handlePauseState() { + TrainingControlView::GetInstance()->GetLabel()->SetTextId(STR_RESUME); + TrainingControlView::GetInstance()->GetButton()->SetImageSrc( + SPORT_CONTINUE_IMAGE, SPORT_CONTINUE_IMAGE); + TraingModel::GetInstance()->SetSportState(ExerciseState::Pause); + PauseTimer(); + ControlSensor(ExerciseState::Pause); +} - /*训练开始*/ - void TraingCardPresenter::handleStartState() - { - ControlSensor(ExerciseState::Start); - TraingModel::GetInstance()->SetSportOpenWay(true); - } +/*训练继续*/ +void TraingCardPresenter::handleContinueState() { + TrainingControlView::GetInstance()->GetLabel()->SetTextId(STR_PAUSE); + TrainingControlView::GetInstance()->GetButton()->SetImageSrc( + SPORT_PAUSE_IMAGE, SPORT_PAUSE_IMAGE); + TraingModel::GetInstance()->SetSportState(ExerciseState::Continue); + ResumeTimer(); + ControlSensor(ExerciseState::Continue); +} +/*训练开始*/ +void TraingCardPresenter::handleStartState() { + ControlSensor(ExerciseState::Start); + TraingModel::GetInstance()->SetSportOpenWay(true); } + +} // namespace OHOS 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 860980b7a..29a583e35 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 @@ -1,12 +1,12 @@ #include "traing/training_card/include/TraingCardView.h" +#include "UiConfig.h" #include "common/image_cache_manager.h" +#include "components/ui_button.h" #include "components/ui_label_ext.h" -#include "ui_resource_string.h" -#include "UiConfig.h" #include "ui_resource_image.h" +#include "ui_resource_string.h" #include -#include "components/ui_button.h" #include "common/screen.h" #include "components/ui_digital_clock.h" @@ -14,525 +14,504 @@ #include "components/ui_label_ext.h" #include "font/ui_font.h" -#include "traing/include/TraingModel.h" -#include "uicomponents/UIComponents.h" #include "ConfigModel.h" #include "custom_utils.h" +#include "traing/include/TraingModel.h" +#include "uicomponents/UIComponents.h" -extern "C" -{ - void InitTimer(); - void DisableTimer(); +extern "C" { +void InitTimer(); +void DisableTimer(); } -namespace OHOS -{ +namespace OHOS { #ifdef __cplusplus - extern "C" - { +extern "C" { #endif -#include "pm_veto.h" #include "pm.h" - /*移除睡眠否决投票*/ - void uapi_remove_sport_vote(void) - { - uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART); - if (cnt == 1) - { - uapi_pm_remove_sleep_veto(PM_ID_HEART); - } - else - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, "Sport SERVICE MCU has delete pm_id_Sport vote"); - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_MAIN_SERVICE, "Sport SERVICE MCU SLEEP SUCCESS"); - } - - /*添加睡眠否决投票*/ - void uapi_add_sport_vote(void) - { - uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART); - if (cnt == 0) - { - uapi_pm_add_sleep_veto(PM_ID_HEART); - } - else - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, "Sport SERVICE MCU has got pm_id_Sport vote"); - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_MAIN_SERVICE, "Sport SERVICE MCU WAKEUP SUCCESS"); - } +#include "pm_veto.h" +/*移除睡眠否决投票*/ +void uapi_remove_sport_vote(void) { + uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART); + if (cnt == 1) { + uapi_pm_remove_sleep_veto(PM_ID_HEART); + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, + "Sport SERVICE MCU has delete pm_id_Sport vote"); + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MAIN_SERVICE, + "Sport SERVICE MCU SLEEP SUCCESS"); +} + +/*添加睡眠否决投票*/ +void uapi_add_sport_vote(void) { + uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART); + if (cnt == 0) { + uapi_pm_add_sleep_veto(PM_ID_HEART); + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, + "Sport SERVICE MCU has got pm_id_Sport vote"); + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MAIN_SERVICE, + "Sport SERVICE MCU WAKEUP SUCCESS"); +} #ifdef __cplusplus - } +} #endif - static const uint16_t LABEL_FONT_SIZE = 200; - static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6; - static const uint32_t CARD_PAGE_COLOR = 0xffd0d0d0; - - static TraingCardView *g_pTraingCardView{nullptr}; - - TraingCardView::TraingCardView() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView::TraingCardView"); - InitTimer(); // 开启计时器 - TraingModel::GetInstance()->SetSportState(ExerciseState::Start); // 设置运动状态为开始 - TraingModel::GetInstance()->SetTimestamp(); - uapi_add_sport_vote(); // 保护进程 - g_pTraingCardView = this; - } - - TraingCardView::~TraingCardView() - { - imageAnimator->Stop(); - FreeImageInfoArray(winimageInfos, winbasePath.c_str(), 94); - ReleaseImageAnimatorSource(winimageAnimatorInfo, 94); - DeInit(); - - g_pTraingCardView = nullptr; - DisableTimer(); // 关闭计时器 - TraingModel::GetInstance()->SetTimestamp(); - uapi_remove_sport_vote(); // 移除 - } - - TraingCardView *TraingCardView::GetInstance() - { - return g_pTraingCardView; - } - - /* InitView:初始化界面*/ - void TraingCardView ::InitView() - { - UISwipeView::OnSwipeListener *listener = nullptr; - - if (swipe_ == nullptr) - { - swipe_ = new UICrossView(); - swipe_->SetPosition(0, 0, 466, 466); - swipe_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } - - InitControlPage(); - InitDataPage(); - InitMusicPage(); - InitDetailPage(); - - swipe_->HorAdd(ControlView); - swipe_->HorAdd(DataVIew); - swipe_->HorAdd(MusicView); - - ShowEndView(); - ShowGetTagView(); - ShowHeartView(); - // swipe_->HorAdd(DetailView); - - swipe_->VerAdd(DetailView, UICrossView::VPage::DOWN_PAGE); - swipe_->SetHorCurrentPage(Control_Card::DATA); // 设置进入索引 [数据] - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView::InitPage over"); - } - - /* DeInit:删除组件 */ - void TraingCardView::DeInit() - { - swipe_->RemoveAll(); - - /*界面*/ - ControlView->RemoveAll(); - DataVIew->RemoveAll(); - DetailView->RemoveAll(); - MusicView->RemoveAll(); - endView->RemoveAll(); - getView->RemoveAll(); - heartView->RemoveAll(); - - /*标签*/ - delete endtitle; - endtitle = nullptr; - delete notelabel; - notelabel = nullptr; - delete endnotelabel; - endnotelabel = nullptr; - delete endnote; - endnote = 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; - /*图片*/ - delete heartiamge; - heartiamge = nullptr; - - /*按键*/ - delete exit; - exit = nullptr; - delete back; - back = nullptr; - delete buttonok_; - buttonok_ = nullptr; - delete buttonnote_; - buttonnote_ = nullptr; - - /*动画*/ - 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) - { - ControlView = new TrainingControlView(); - ControlView->PreLoad(); - if (ControlView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ControlView new fail"); - return nullptr; - } - return ControlView; - } - UICardPage *TraingCardView::InitDataPage(void) - { - DataVIew = new TrainingDataView(); - DataVIew->PreLoad(); - if (DataVIew == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DataVIew new fail"); - return nullptr; - } - return DataVIew; - } - UICardPage *TraingCardView::InitMusicPage(void) - { - MusicView = new PlayersView(); - MusicView->PreLoad(); - if (MusicView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MusicView new fail"); - return nullptr; - } - return MusicView; - } - UICardPage *TraingCardView::InitDetailPage() - { - DetailView = new TrainingDetailView(); - DetailView->PreLoad(); - DetailView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - DetailView->SetStyle(STYLE_BORDER_RADIUS, 466); // 设置为圆形 - if (DetailView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DetailView new fail"); - return nullptr; - } - return DetailView; - } - void TraingCardView::PreLoad(void) - { - if (!viewiInitStatus) - { - InitView(); - viewiInitStatus = true; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView PreLoad"); - } - void TraingCardView::OnStart() - { - swipe_ = new UICrossView(); - if (swipe_ == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "swipe_ new fail"); - return; - } - swipe_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - // 创建 draglistener 实例并设置为拖动监听器 - UIView::OnDragListener *draglistener = static_cast(TraingCardPresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - swipe_->SetOnDragListener(draglistener); - swipe_->SetTouchable(true); - swipe_->SetDraggable(true); - swipe_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR); - swipe_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - // swipe_->EnableScreenCap(true); - PreLoad(); - SetContainerView(swipe_); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "swipe_ new ok"); - } - /*设置弹窗状态*/ - void TraingCardView::SetPopupViewStatus(PopupType type, bool status) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", type); - UIView *popupView = nullptr; - if (type == EndPopup) - { - popupView = endView; - } - else if (type == GetTagPopup) - { - popupView = getView; - } - else if (type == HeartPopup) - { - popupView = heartView; - } - - if (popupView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PopupView is NULL"); - return; - } - - UIView *cardview = TraingCardView::GetInstance()->GetTraingCrad(); - if (cardview != nullptr) - { - cardview->SetVisible(!status); - } - - popupView->SetVisible(status); - } - /*结束弹窗界面*/ - void TraingCardView::ShowEndView() - { - // momentumFlag = false; // 标志位还原 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowEndView"); - endView = new UIScrollView(); - if (endView == nullptr) - { - return; - } - endView->SetPosition(0, 0); - endView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - endView->SetScrollBlankSize(20); - endView->SetReboundSize(50); - endView->SetDirection(1); - - InitRollLabel(endtitle, 83, 50, 300, 35, "label1", STR_LOOK_OUT, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitRollLabel(notelabel, 56, 167, 360, 80, "label2", STR_INSUFFICIENT_EXERCISE_AMOUNT, DEFAULT_VECTOR_FONT_FILENAME, 30); - /*隐藏是否结束运动title*/ - InitRollLabel(endnote, 56, 207, 360, 80, "label3", STR_END_THIS_MOVEMENT, DEFAULT_VECTOR_FONT_FILENAME, 30); - endnote->SetVisible(false); - - endView->Add(endnote); - endView->Add(endtitle); - endView->Add(notelabel); - - InitButton(exit, 111, 299, 100, 100, BUTTONBACK); - exit->SetOnClickListener(static_cast(TraingCardPresenter::GetInstance())); - exit->SetImageSrc(NO_IMAGE, NO_IMAGE); - InitButton(back, 256, 299, 100, 100, BUTTONEXIT); - back->SetOnClickListener(static_cast(TraingCardPresenter::GetInstance())); - back->SetImageSrc(YES_IMAGE, YES_IMAGE); - endView->Add(exit); - endView->Add(back); - RootView::GetInstance()->Add(endView); - endView->SetDraggable(false); - endView->SetTouchable(true); - endView->SetVisible(false); // 界面隐藏 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowEndView end"); - } - /*目标达成界面*/ - void TraingCardView::ShowGetTagView() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowGetTagView"); - getView = new UIScrollView(); - if (getView == nullptr) - { - return; - } - getView->SetPosition(0, 0); - getView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - getView->SetScrollBlankSize(20); - getView->SetReboundSize(50); - getView->SetDirection(1); - - // 初始化Lable - InitRollLabel(labeltitle, 83, 50, 300, 35, "label1", STR_GOAL_ACHIEVED, DEFAULT_VECTOR_FONT_FILENAME, 35); - getView->Add(labeltitle); - InitRollLabel(labelgettag, 103, 307, 200, 35, "label3", STR_ACCOMPLISH_GOAL, DEFAULT_VECTOR_FONT_FILENAME, 30); - getView->Add(labelgettag); - InitLabel(labelpre, 233, 307, 160, 35, "label3", "100%", DEFAULT_VECTOR_FONT_FILENAME, 30); - getView->Add(labelpre); - - // 初始化按键 - InitButtonExt(buttonok_, 0, 366, 466, 100, BUTTONWINOK, STR_OK, 30); - buttonok_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE); - buttonok_->SetOnClickListener(static_cast(TraingCardPresenter::GetInstance())); - getView->Add(buttonok_); - - InitImageAnimator(); - RootView::GetInstance()->Add(getView); - getView->SetDraggable(false); - getView->SetTouchable(true); - getView->SetVisible(false); // 界面隐藏 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowGetTagView end"); - } - /*最高心率提醒弹窗*/ - void TraingCardView::ShowHeartView() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowHeartView"); - heartView = new UIScrollView(); - if (heartView == nullptr) - { - return; - } - heartView->SetPosition(0, 0); - heartView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - heartView->SetScrollBlankSize(20); - heartView->SetReboundSize(50); - heartView->SetDirection(1); - - // 初始化Lable - InitRollLabel(hearttitle, 83, 50, 300, 35, "label1", STR_HEARTTITLE, DEFAULT_VECTOR_FONT_FILENAME, 35); - heartView->Add(hearttitle); - - int maxheart = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_TRAINING_HEART_MAX); - std::string heartStr = "当前心率高于" + std::to_string(maxheart) + "次/分钟"; - InitLabel(labelnote, 53, 269, 360, 35, "label3", heartStr.c_str(), DEFAULT_VECTOR_FONT_FILENAME, 30); - heartView->Add(labelnote); - - InitImageView(heartiamge, 193, 149, 80, 80, "note", WARNING_IMAGE); - heartView->Add(heartiamge); - - // 初始化按键 - InitButtonExt(buttonnote_, 0, 366, 466, 100, BUTTONNOTE, STR_OK, 30); - buttonnote_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE); - buttonnote_->SetOnClickListener(static_cast(TraingCardPresenter::GetInstance())); - heartView->Add(buttonnote_); - - RootView::GetInstance()->Add(heartView); - heartView->SetDraggable(false); - heartView->SetTouchable(true); - heartView->SetVisible(false); // 界面隐藏 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowHeartView end"); - } - /*获取运动量结束弹窗界面刷新*/ - bool TraingCardView::RefreshEndView() - { - // 获取训练卡路里判断运动量 - momentumFlag = TraingModel::GetInstance()->GetMomentum(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "momentumFlag %d", momentumFlag); - - if (momentumFlag) - { - // 正常结束 - endnote->SetVisible(false); - endtitle->SetTextId(STR_END_MOVEMENT); - notelabel->SetTextId(STR_END_THIS_MOVEMENT); - } - else - { - endtitle->SetTextId(STR_LOOK_OUT); - notelabel->SetTextId(STR_INSUFFICIENT_EXERCISE_AMOUNT); - endnote->SetVisible(true); - } - return momentumFlag; - } - /*初始化动画以及Taglabel*/ - void TraingCardView::InitImageAnimator() - { - int tag = TraingModel::GetInstance()->GetSportTag(); - ExerciseTag tagType = TraingModel::GetInstance()->GetSportTagtype(); - std::string tagString = std::to_string(tag); - switch (tagType) - { - case ExerciseTag::Duration: - { - int hours = tag / 60; - int minutes = tag % 60; - int seconds = 0; - // 将小时、分钟、秒转换为字符串,并在小于10时补零 - std::string hoursStr = (hours < 10) ? "0" + std::to_string(hours) : std::to_string(hours); - std::string minutesStr = (minutes < 10) ? "0" + std::to_string(minutes) : std::to_string(minutes); - std::string secondsStr = (seconds < 10) ? "0" + std::to_string(seconds) : std::to_string(seconds); - tagString = hoursStr + ":" + minutesStr + ":" + secondsStr; - break; - } - case ExerciseTag::Calories: - { - tagString = tagString + "kcal"; - break; - } - case ExerciseTag::Distance: - { - tagString = tagString + "km"; - break; - } - case ExerciseTag::Steps: - break; - default: - break; - } - 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); - - // 初始化图片数组以及动画 - winimageInfos = CreateImageInfoArray(winbasePath.c_str(), 94); - InitImageAnimatorSource(imageAnimator, winimageAnimatorInfo, winimageInfos, 94, 173, 100, 120, 120, "imageAnimator1", 10); - getView->Add(imageAnimator); - } - - /*获取卡片View单例*/ - UICrossView *TraingCardView::GetTraingCrad() - { - return swipe_; - } - void TraingCardView::OnSetUpView() - { - View::OnSetUpView(); - Draw(); - } - - void TraingCardView::OnTearDownView() - { - View::OnTearDownView(); - return; - } - - void TraingCardView::OnStop() - { - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; - } - - int TraingCardView::GetCurrentPage() - { - return swipe_->GetCurrentPageId(0); // 获取水平页面 - } - UIImageAnimatorView *TraingCardView::GetAnimator() - { - return imageAnimator; - } +static const uint16_t LABEL_FONT_SIZE = 200; +static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6; +static const uint32_t CARD_PAGE_COLOR = 0xffd0d0d0; + +static TraingCardView *g_pTraingCardView{nullptr}; + +TraingCardView::TraingCardView() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView::TraingCardView"); + InitTimer(); // 开启计时器 + TraingModel::GetInstance()->SetSportState( + ExerciseState::Start); // 设置运动状态为开始 + TraingModel::GetInstance()->SetTimestamp(); + uapi_add_sport_vote(); // 保护进程 + g_pTraingCardView = this; +} + +TraingCardView::~TraingCardView() { + imageAnimator->Stop(); + FreeImageInfoArray(winimageInfos, winbasePath.c_str(), 94); + ReleaseImageAnimatorSource(winimageAnimatorInfo, 94); + DeInit(); + + g_pTraingCardView = nullptr; + DisableTimer(); // 关闭计时器 + TraingModel::GetInstance()->SetTimestamp(); + uapi_remove_sport_vote(); // 移除 +} + +TraingCardView *TraingCardView::GetInstance() { return g_pTraingCardView; } + +/* InitView:初始化界面*/ +void TraingCardView ::InitView() { + + if (swipe_ == nullptr) { + swipe_ = new UICrossView(); + swipe_->SetPosition(0, 0, 466, 466); + swipe_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + InitControlPage(); + InitDataPage(); + InitMusicPage(); + InitDetailPage(); + + swipe_->HorAdd(controlview_); + swipe_->HorAdd(dataallview_); + swipe_->HorAdd(musicview_); + + ShowEndView(); + ShowGetTagView(); + ShowHeartView(); + + // swipe_->HorAdd(DetailView); + swipe_->VerAdd(DetailView, UICrossView::VPage::DOWN_PAGE); + + swipe_->SetHorCurrentPage(Control_Card::DATA); // 设置进入索引 [数据] + + UISwipeView::OnSwipeListener *onSwipeListener = + static_cast( + OHOS::TraingCardPresenter::GetInstance()); + if (onSwipeListener == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "onSwipeListener is null"); + return; + } + swipe_->SetOnSwipeListener(onSwipeListener); + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView::InitPage over"); +} + +/* DeInit:删除组件 */ +void TraingCardView::DeInit() { + swipe_->RemoveAll(); + + /*界面*/ + controlview_->RemoveAll(); + dataallview_->RemoveAll(); + // DetailView->RemoveAll(); + musicview_->RemoveAll(); + endView->RemoveAll(); + getView->RemoveAll(); + heartView->RemoveAll(); + + /*标签*/ + delete endtitle; + endtitle = nullptr; + delete notelabel; + notelabel = nullptr; + delete endnotelabel; + endnotelabel = nullptr; + delete endnote; + endnote = 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; + /*图片*/ + delete heartiamge; + heartiamge = nullptr; + + /*按键*/ + delete exit; + exit = nullptr; + delete back; + back = nullptr; + delete buttonok_; + buttonok_ = nullptr; + delete buttonnote_; + buttonnote_ = nullptr; + + /*动画*/ + delete imageAnimator; + imageAnimator = nullptr; + + /*卡片*/ + delete controlview_; + controlview_ = nullptr; + delete dataallview_; + dataallview_ = 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) { + controlview_ = new TrainingControlView(); + // controlview_->PreLoad(); + if (controlview_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "controlview_ new fail"); + return nullptr; + } + return controlview_; +} +UICardPage *TraingCardView::InitDataPage(void) { + dataallview_ = new TraingDataAllView(); + // dataallview_->PreLoad(); + if (dataallview_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dataallview_ new fail"); + return nullptr; + } + return dataallview_; +} +UICardPage *TraingCardView::InitMusicPage(void) { + musicview_ = new PlayersView(); + // musicview_->PreLoad(); + if (musicview_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "musicview_ new fail"); + return nullptr; + } + return musicview_; +} +UICardPage *TraingCardView::InitDetailPage() { + DetailView = new TrainingDetailView(); + // DetailView->PreLoad(); + DetailView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), + Screen::GetInstance().GetHeight()); + DetailView->SetStyle(STYLE_BORDER_RADIUS, 466); // 设置为圆形 + if (DetailView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DetailView new fail"); + return nullptr; + } + return DetailView; +} +void TraingCardView::PreLoad(void) { + if (!viewiInitStatus) { + InitView(); + viewiInitStatus = true; + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView PreLoad"); +} +void TraingCardView::OnStart() { + View::OnStart(); + + swipe_ = new UICrossView(); + if (swipe_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "swipe_ new fail"); + return; + } + UIView::OnDragListener *listener = + static_cast(TraingCardPresenter::GetInstance()); + if (listener == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "AlarmSetWeekView:: new alarmDragListener fail"); + return; + } + swipe_->SetOnDragListener(listener); + + PreLoad(); + swipe_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), + Screen::GetInstance().GetHeight()); + swipe_->SetTouchable(true); + swipe_->SetDraggable(true); + swipe_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR); + swipe_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + swipe_->EnableScreenCap(true); + swipe_->SetAnimatorTime(50); + + SetContainerView(swipe_); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "swipe_ new ok"); +} +/*设置弹窗状态*/ +void TraingCardView::SetPopupViewStatus(PopupType type, bool status) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", type); + UIView *popupView = nullptr; + if (type == EndPopup) { + popupView = endView; + } else if (type == GetTagPopup) { + popupView = getView; + } else if (type == HeartPopup) { + popupView = heartView; + } + + if (popupView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PopupView is NULL"); + return; + } + + UIView *cardview = TraingCardView::GetInstance()->GetTraingCrad(); + if (cardview != nullptr) { + cardview->SetVisible(!status); + } + + popupView->SetVisible(status); +} +/*结束弹窗界面*/ +void TraingCardView::ShowEndView() { + // momentumFlag = false; // 标志位还原 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowEndView"); + endView = new UIScrollView(); + if (endView == nullptr) { + return; + } + endView->SetPosition(0, 0); + endView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); + endView->SetScrollBlankSize(20); + endView->SetReboundSize(50); + endView->SetDirection(1); + + InitRollLabel(endtitle, 83, 50, 300, 35, "label1", STR_LOOK_OUT, + DEFAULT_VECTOR_FONT_FILENAME, 30); + InitRollLabel(notelabel, 56, 167, 360, 80, "label2", + STR_INSUFFICIENT_EXERCISE_AMOUNT, DEFAULT_VECTOR_FONT_FILENAME, + 30); + /*隐藏是否结束运动title*/ + InitRollLabel(endnote, 56, 207, 360, 80, "label3", STR_END_THIS_MOVEMENT, + DEFAULT_VECTOR_FONT_FILENAME, 30); + endnote->SetVisible(false); + + endView->Add(endnote); + endView->Add(endtitle); + endView->Add(notelabel); + + InitButton(exit, 111, 299, 100, 100, BUTTONBACK); + exit->SetOnClickListener(static_cast( + TraingCardPresenter::GetInstance())); + exit->SetImageSrc(NO_IMAGE, NO_IMAGE); + InitButton(back, 256, 299, 100, 100, BUTTONEXIT); + back->SetOnClickListener(static_cast( + TraingCardPresenter::GetInstance())); + back->SetImageSrc(YES_IMAGE, YES_IMAGE); + endView->Add(exit); + endView->Add(back); + RootView::GetInstance()->Add(endView); + endView->SetDraggable(false); + endView->SetTouchable(true); + endView->SetVisible(false); // 界面隐藏 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowEndView end"); +} +/*目标达成界面*/ +void TraingCardView::ShowGetTagView() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowGetTagView"); + getView = new UIScrollView(); + if (getView == nullptr) { + return; + } + getView->SetPosition(0, 0); + getView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); + getView->SetScrollBlankSize(20); + getView->SetReboundSize(50); + getView->SetDirection(1); + + // 初始化Lable + InitRollLabel(labeltitle, 83, 50, 300, 35, "label1", STR_GOAL_ACHIEVED, + DEFAULT_VECTOR_FONT_FILENAME, 35); + getView->Add(labeltitle); + InitRollLabel(labelgettag, 103, 307, 200, 35, "label3", STR_ACCOMPLISH_GOAL, + DEFAULT_VECTOR_FONT_FILENAME, 30); + getView->Add(labelgettag); + InitLabel(labelpre, 233, 307, 160, 35, "label3", "100%", + DEFAULT_VECTOR_FONT_FILENAME, 30); + getView->Add(labelpre); + + // 初始化按键 + InitButtonExt(buttonok_, 0, 366, 466, 100, BUTTONWINOK, STR_OK, 30); + buttonok_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE); + buttonok_->SetOnClickListener(static_cast( + TraingCardPresenter::GetInstance())); + getView->Add(buttonok_); + + InitImageAnimator(); + RootView::GetInstance()->Add(getView); + getView->SetDraggable(false); + getView->SetTouchable(true); + getView->SetVisible(false); // 界面隐藏 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowGetTagView end"); +} +/*最高心率提醒弹窗*/ +void TraingCardView::ShowHeartView() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowHeartView"); + heartView = new UIScrollView(); + if (heartView == nullptr) { + return; + } + heartView->SetPosition(0, 0); + heartView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); + heartView->SetScrollBlankSize(20); + heartView->SetReboundSize(50); + heartView->SetDirection(1); + + // 初始化Lable + InitRollLabel(hearttitle, 83, 50, 300, 35, "label1", STR_HEARTTITLE, + DEFAULT_VECTOR_FONT_FILENAME, 35); + heartView->Add(hearttitle); + + int maxheart = ConfigModel::GetInstance()->get_configData_int( + ConfigModel::CONFIGMODEL_ITEM_TRAINING_HEART_MAX); + std::string heartStr = "当前心率高于" + std::to_string(maxheart) + "次/分钟"; + InitLabel(labelnote, 53, 269, 360, 35, "label3", heartStr.c_str(), + DEFAULT_VECTOR_FONT_FILENAME, 30); + heartView->Add(labelnote); + + InitImageView(heartiamge, 193, 149, 80, 80, "note", WARNING_IMAGE); + heartView->Add(heartiamge); + + // 初始化按键 + InitButtonExt(buttonnote_, 0, 366, 466, 100, BUTTONNOTE, STR_OK, 30); + buttonnote_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE); + buttonnote_->SetOnClickListener(static_cast( + TraingCardPresenter::GetInstance())); + heartView->Add(buttonnote_); + + RootView::GetInstance()->Add(heartView); + heartView->SetDraggable(false); + heartView->SetTouchable(true); + heartView->SetVisible(false); // 界面隐藏 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowHeartView end"); +} +/*获取运动量结束弹窗界面刷新*/ +bool TraingCardView::RefreshEndView() { + // 获取训练卡路里判断运动量 + momentumFlag = TraingModel::GetInstance()->GetMomentum(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "momentumFlag %d", momentumFlag); + + if (momentumFlag) { + // 正常结束 + endnote->SetVisible(false); + endtitle->SetTextId(STR_END_MOVEMENT); + notelabel->SetTextId(STR_END_THIS_MOVEMENT); + } else { + endtitle->SetTextId(STR_LOOK_OUT); + notelabel->SetTextId(STR_INSUFFICIENT_EXERCISE_AMOUNT); + endnote->SetVisible(true); + } + return momentumFlag; +} +/*初始化动画以及Taglabel*/ +void TraingCardView::InitImageAnimator() { + int tag = TraingModel::GetInstance()->GetSportTag(); + ExerciseTag tagType = TraingModel::GetInstance()->GetSportTagtype(); + std::string tagString = std::to_string(tag); + switch (tagType) { + case ExerciseTag::Duration: { + int hours = tag / 60; + int minutes = tag % 60; + int seconds = 0; + // 将小时、分钟、秒转换为字符串,并在小于10时补零 + std::string hoursStr = + (hours < 10) ? "0" + std::to_string(hours) : std::to_string(hours); + std::string minutesStr = (minutes < 10) ? "0" + std::to_string(minutes) + : std::to_string(minutes); + std::string secondsStr = (seconds < 10) ? "0" + std::to_string(seconds) + : std::to_string(seconds); + tagString = hoursStr + ":" + minutesStr + ":" + secondsStr; + break; + } + case ExerciseTag::Calories: { + tagString = tagString + "kcal"; + break; + } + case ExerciseTag::Distance: { + tagString = tagString + "km"; + break; + } + case ExerciseTag::Steps: + break; + default: + break; + } + 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); + + // 初始化图片数组以及动画 + winimageInfos = CreateImageInfoArray(winbasePath.c_str(), 94); + InitImageAnimatorSource(imageAnimator, winimageAnimatorInfo, winimageInfos, + 94, 173, 100, 120, 120, "imageAnimator1", 10); + getView->Add(imageAnimator); +} + +/*获取卡片View单例*/ +UICrossView *TraingCardView::GetTraingCrad() { return swipe_; } +void TraingCardView::OnSetUpView() { + View::OnSetUpView(); + Draw(); +} + +void TraingCardView::OnTearDownView() { + View::OnTearDownView(); + return; +} + +void TraingCardView::OnStop() { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; +} + +int TraingCardView::GetCurrentPage() { + return swipe_->GetCurrentPageId(0); // 获取水平页面 } +UIImageAnimatorView *TraingCardView::GetAnimator() { return imageAnimator; } +} // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingDataAllView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingDataAllView.cpp new file mode 100644 index 000000000..1579cf2dd --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingDataAllView.cpp @@ -0,0 +1,169 @@ +#include "traing/include/TraingModel.h" +#include "traing/training_card/include/TrainingControlView.h" +#include "traing/training_card/include/TrainingDataView.h" +#include "traing/training_card/include/TrainingDetailView.h" +#include "wearable_log.h" + +namespace OHOS { + +static TraingDataAllView *g_pTraingDataAllView{nullptr}; + +TraingDataAllView::TraingDataAllView() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, + "TraingDataAllView::TraingDataAllView"); + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + g_pTraingDataAllView = this; +} + +TraingDataAllView::~TraingDataAllView() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, + "TraingDataAllView::~TraingDataAllView"); + ClearAll(); + g_pTraingDataAllView = nullptr; +} + +TraingDataAllView *TraingDataAllView::GetInstance(void) { + return g_pTraingDataAllView; +} + +void TraingDataAllView::ClearAll(void) { + for (int32_t i = 0; i < maxPage; i++) { + recordCard[i] = nullptr; + } + + if (TraingDataAllSwipeViewList) { + TraingDataAllSwipeViewList->RemoveAll(); + delete TraingDataAllSwipeViewList; + TraingDataAllSwipeViewList = nullptr; + } + + delete trainingDataView; + trainingDataView = nullptr; + + delete trainingDetailView; + trainingDetailView = nullptr; +} + +UISwipeView *TraingDataAllView::TraingDataAllViewInit(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "TraingDataAllView::TraingDataAllViewInit"); + + TraingDataAllSwipeViewList = new UISwipeView(UISwipeView::VERTICAL); + if (!TraingDataAllSwipeViewList) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Failed to create TraingDataAllSwipeViewList"); + return nullptr; + } + + TraingDataAllSwipeViewList->SetStyle(STYLE_BACKGROUND_COLOR, + Color::Black().full); + TraingDataAllSwipeViewList->SetPosition(0, 0, HORIZONTAL_RESOLUTION, + VERTICAL_RESOLUTION); + TraingDataAllSwipeViewList->SetDraggable(true); + TraingDataAllSwipeViewList->SetTouchable(true); + + for (uint16_t i = 0; i < maxPage; i++) { + recordCard[i] = CreatePage(i); + if (!recordCard[i]) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recordCard[%d] is nullptr", i); + return nullptr; + } + recordCard[i]->InitView(this); + TraingDataAllSwipeViewList->Add(recordCard[i]); + } + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingDataAllView InitPage complete"); + return TraingDataAllSwipeViewList; +} + +UISwipeView *TraingDataAllView::GetTraingDataAllPageView() { + return TraingDataAllViewInit(); +} + +TrainingDataView *TraingDataAllView::GetTrainingDataView(void) { + return trainingDataView; +} + +TrainingDetailView *TraingDataAllView::GetTrainingDetailView(void) { + return trainingDetailView; +} + +AppGroupView *TraingDataAllView::TraingDataPageInit(void) { + trainingDataView = new TrainingDataView(); + if (!trainingDataView) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to create TrainingDataView"); + return nullptr; + } + return trainingDataView; +} + +AppGroupView *TraingDataAllView::TraingDetailPageInit(void) { + trainingDetailView = new TrainingDetailView(); + if (!trainingDetailView) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Failed to create TrainingDetailView"); + return nullptr; + } + return trainingDetailView; +} + +struct TraingDataAllViewMapper { + const int16_t viewId; + AppGroupView *(TraingDataAllView::*func)(void); +}; + +static const TraingDataAllViewMapper g_pageMapper[] = { + {TRAING_DATA_ALL_MAIN_VIEW, &TraingDataAllView::TraingDataPageInit}, + {TRAING_DATA_ALL_DETAIL_VIEW, &TraingDataAllView::TraingDetailPageInit}, +}; + +AppGroupView *TraingDataAllView::CreatePage(uint8_t TraingDataAllPageId) { + for (const auto &mapper : g_pageMapper) { + if (mapper.viewId == TraingDataAllPageId) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Creating page for TraingDataAllPageId: %d", + TraingDataAllPageId); + return (this->*(mapper.func))(); + } + } + return nullptr; +} + +bool TraingDataAllView::InitView(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Initializing TraingDataAllView"); + + if (!trainingDataAllView) { + trainingDataAllView = new TraingDataAllView(); + if (!trainingDataAllView) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Failed to create TraingDataAllView"); + return false; + } + } + + traingDataAllPageView = dynamic_cast( + trainingDataAllView->GetTraingDataAllPageView()); + if (!traingDataAllPageView) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "GetTraingDataAllPageView returned nullptr"); + return false; + } + traingDataAllPageView->SetDraggable(true); + traingDataAllPageView->SetTouchable(true); + Add(traingDataAllPageView); + + return true; +} + +void TraingDataAllView::PreLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Preloading TraingDataAllView"); + if (!viewiInitStatus && InitView()) { + viewiInitStatus = true; + } +} + +void TraingDataAllView::UnLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Unloading TraingDataAllView"); +} + +} // namespace OHOS \ No newline at end of file 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 f8a919421..d91ce2294 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 @@ -2,95 +2,98 @@ * @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 + * @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" -#include "common/image_cache_manager.h" -#include "components/ui_label_ext.h" -#include "ui_resource_string.h" #include "UiConfig.h" -#include "ui_resource_image.h" -#include +#include "common/image_cache_manager.h" #include "components/ui_button.h" +#include "components/ui_label_ext.h" +#include "traing/Training_UiConfig.h" #include "traing/include/TraingModel.h" +#include "ui_resource_image.h" +#include "ui_resource_string.h" #include "uicomponents/UIComponents.h" -#include "traing/Training_UiConfig.h" +#include + +namespace OHOS { -namespace OHOS -{ - - static TrainingDataView *g_pTrainingDataView{nullptr}; - - TrainingDataView::TrainingDataView() - { - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - g_pTrainingDataView = this; - } - - TrainingDataView::~TrainingDataView() - { - RemoveAll(); - DeInit(); - g_pTrainingDataView = nullptr; - } - - TrainingDataView *TrainingDataView::GetInstance() - { - return g_pTrainingDataView; - } - - /* InitView:初始化界面*/ - void TrainingDataView ::InitView() - { - // 初始化Image - InitImageView(image_progress, 13, 13, 440, 386, "image1", PROGRESS_IMAGE); - InitImageView(image_heart, 88, 295, 50, 50, "image2", SPORT_HEARTRATE_IMAGE); - InitImageView(image_iconup, 225, 396, 16, 10, "image4", INCO_UP_IMAGE); - InitImageView(image_iconpoint, 193, 421, 80, 20, "image5", DATA_POINT_IMAGE); - Add(image_progress); - 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, 0xff4fC34C); - 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); - sportlabel->SetTextColor(Color::Gray()); - - InitLabel(curtimelabel, 155, 60, 150, 50, "label1", "23:54", DEFAULT_VECTOR_FONT_FILENAME, 40); - - InitLabel(timerlabel, 0, 163, 466, 150, "label3", "00:00:00", DEFAULT_VECTOR_FONT_FILENAME, 80); - InitLabel(heartlabel, 85, 284, 230, 80, "label4", "--", DEFAULT_VECTOR_FONT_FILENAME, 60); - InitLabel(ubpmlabel, 218, 284, 230, 80, "label5", "bpm", DEFAULT_VECTOR_FONT_FILENAME, 60); - ubpmlabel->SetTextColor(Color::Gray()); - Add(curtimelabel); - Add(sportlabel); - Add(timerlabel); - Add(heartlabel); - Add(ubpmlabel); +static TrainingDataView *g_pTrainingDataView{nullptr}; + +TrainingDataView::TrainingDataView() { + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + g_pTrainingDataView = this; +} + +TrainingDataView::~TrainingDataView() { + RemoveAll(); + DeInit(); + g_pTrainingDataView = nullptr; +} + +TrainingDataView *TrainingDataView::GetInstance() { + return g_pTrainingDataView; +} + +/* InitView:初始化界面*/ +bool TrainingDataView ::InitPage() { + // 初始化Image + InitImageView(image_progress, 13, 13, 440, 386, "image1", PROGRESS_IMAGE); + InitImageView(image_heart, 88, 295, 50, 50, "image2", SPORT_HEARTRATE_IMAGE); + InitImageView(image_iconup, 225, 396, 16, 10, "image4", INCO_UP_IMAGE); + InitImageView(image_iconpoint, 193, 421, 80, 20, "image5", DATA_POINT_IMAGE); + Add(image_progress); + 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, 0xff4fC34C); + 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); + sportlabel->SetTextColor(Color::Gray()); + + InitLabel(curtimelabel, 155, 60, 150, 50, "label1", "23:54", + DEFAULT_VECTOR_FONT_FILENAME, 40); + + InitLabel(timerlabel, 0, 163, 466, 150, "label3", "00:00:00", + DEFAULT_VECTOR_FONT_FILENAME, 80); + InitLabel(heartlabel, 85, 284, 230, 80, "label4", "--", + DEFAULT_VECTOR_FONT_FILENAME, 60); + InitLabel(ubpmlabel, 218, 284, 230, 80, "label5", "bpm", + DEFAULT_VECTOR_FONT_FILENAME, 60); + ubpmlabel->SetTextColor(Color::Gray()); + Add(curtimelabel); + Add(sportlabel); + Add(timerlabel); + Add(heartlabel); + Add(ubpmlabel); + + return true; #if 0 // 初始化Button @@ -100,108 +103,91 @@ namespace OHOS buttonNote->SetOnClickListener(static_cast(TraingCardPresenter::GetInstance())); Add(buttonNote); #endif - // 增加上拉卡片 - SetCoverable(true); - } - - /* DeInit:删除组件 */ - void TrainingDataView::DeInit() - { - RemoveAll(); - if (curtimelabel != nullptr) - { - curtimelabel = nullptr; - } - if (sportlabel != nullptr) - { - delete sportlabel; - sportlabel = nullptr; - } - if (timerlabel != nullptr) - { - delete timerlabel; - timerlabel = nullptr; - } - if (heartlabel != nullptr) - { - delete heartlabel; - heartlabel = nullptr; - } - if (ubpmlabel != nullptr) - { - delete ubpmlabel; - ubpmlabel = nullptr; - } - // 删除button - if (buttonNote != nullptr) - { - delete buttonNote; - buttonNote = nullptr; - } - - // 删除Image - if (image_lowIntensity != nullptr) - { - delete image_lowIntensity; - image_lowIntensity = nullptr; - } - if (image_iconup != nullptr) - { - delete image_iconup; - image_iconup = nullptr; - } - if (image_iconpoint != nullptr) - { - delete image_iconpoint; - image_iconpoint = nullptr; - } - if (circleProgress != nullptr) - { - delete circleProgress; - circleProgress = nullptr; - } - } - - void TrainingDataView::PreLoad(void) - { - if (!viewiInitStatus) - { - InitView(); - viewiInitStatus = true; - } - } - - void TrainingDataView::UnLoad(void) {} - UILabelExt *TrainingDataView::GetTimeLabel() - { - return timerlabel; - } - UILabelExt *TrainingDataView::GetHeartLabel() - { - return heartlabel; - } - UICircleProgress *TrainingDataView::GetProgress() - { - return circleProgress; - } - /*更新当前时间*/ - void TrainingDataView::UpdataTime() - { - if (curtimelabel == nullptr) // 防止刷新空组件 - return; - - // 获取当前时间 - struct tm pTM; - time_t seconds; - time(&seconds); - localtime_r(&seconds, &pTM); - - // 解析时间 - int hour = pTM.tm_hour; - int minute = pTM.tm_min; - - // 将时间和日期转换为字符串 - std::string stringtime = (hour < 10 ? "0" : "") + std::to_string(hour) + ":" + (minute < 10 ? "0" : "") + std::to_string(minute); - curtimelabel->SetText(stringtime.c_str()); - } + // 增加上拉卡片 + // SetCoverable(true); +} + +/* DeInit:删除组件 */ +void TrainingDataView::DeInit() { + RemoveAll(); + if (curtimelabel != nullptr) { + curtimelabel = nullptr; + } + if (sportlabel != nullptr) { + delete sportlabel; + sportlabel = nullptr; + } + if (timerlabel != nullptr) { + delete timerlabel; + timerlabel = nullptr; + } + if (heartlabel != nullptr) { + delete heartlabel; + heartlabel = nullptr; + } + if (ubpmlabel != nullptr) { + delete ubpmlabel; + ubpmlabel = nullptr; + } + // 删除button + if (buttonNote != nullptr) { + delete buttonNote; + buttonNote = nullptr; + } + + // 删除Image + if (image_lowIntensity != nullptr) { + delete image_lowIntensity; + image_lowIntensity = nullptr; + } + if (image_iconup != nullptr) { + delete image_iconup; + image_iconup = nullptr; + } + if (image_iconpoint != nullptr) { + delete image_iconpoint; + image_iconpoint = nullptr; + } + if (circleProgress != nullptr) { + delete circleProgress; + circleProgress = nullptr; + } +} + +UILabelExt *TrainingDataView::GetTimeLabel() { return timerlabel; } +UILabelExt *TrainingDataView::GetHeartLabel() { return heartlabel; } +UICircleProgress *TrainingDataView::GetProgress() { return circleProgress; } +/*更新当前时间*/ +void TrainingDataView::UpdataTime() { + if (curtimelabel == nullptr) // 防止刷新空组件 + return; + + // 获取当前时间 + struct tm pTM; + time_t seconds; + time(&seconds); + localtime_r(&seconds, &pTM); + + // 解析时间 + int hour = pTM.tm_hour; + int minute = pTM.tm_min; + + // 将时间和日期转换为字符串 + std::string stringtime = (hour < 10 ? "0" : "") + std::to_string(hour) + ":" + + (minute < 10 ? "0" : "") + std::to_string(minute); + curtimelabel->SetText(stringtime.c_str()); +} + +bool TrainingDataView::InitView(void *caller) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingDataView InitView %p", + caller); + if (InitPage() == false) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingDataView::InitPage fail"); + return false; + } + SetDraggable(true); + SetTouchable(true); + // SleepDataRefresh(); + return true; } +} // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDetailView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDetailView.cpp index a4518a683..cc77a9012 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDetailView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDetailView.cpp @@ -2,164 +2,145 @@ #include "traing/training_card/include/TrainingDetailView.h" #include "traing/training_card/include/TraingCardView.h" -#include "common/image_cache_manager.h" -#include "components/ui_label_ext.h" -#include "ui_resource_string.h" #include "UiConfig.h" -#include "ui_resource_image.h" -#include +#include "common/image_cache_manager.h" #include "components/ui_button.h" +#include "components/ui_label_ext.h" +#include "traing/Training_UiConfig.h" #include "traing/include/TraingModel.h" +#include "ui_resource_image.h" +#include "ui_resource_string.h" #include "uicomponents/UIComponents.h" -#include "traing/Training_UiConfig.h" - -namespace OHOS -{ - - static TrainingDetailView *g_pTrainingDetailView{nullptr}; - - TrainingDetailView::TrainingDetailView() - { - SetPosition(0, 0, 466, 466); - // SetStyle(STYLE_BACKGROUND_OPA, 0); - // SetStyle(STYLE_BORDER_RADIUS, 466); - g_pTrainingDetailView = this; - } - TrainingDetailView::~TrainingDetailView() - { - RemoveAll(); - DeInit(); - g_pTrainingDetailView = nullptr; - } - - TrainingDetailView *TrainingDetailView::GetInstance() - { - return g_pTrainingDetailView; - } - - /* InitView:初始化界面*/ - void TrainingDetailView ::InitView() - { - // 初始化Image - - InitImageView(progress_image, 0, 0, 100, 100, "image5", COLOR_PROGRESS_IMAGE); - // InitImageView(lineimage2_, 225, 190, 0, 0, "image", LINE_2_IMAGE); - if (lineimage2_ == nullptr) - { - lineimage2_ = new UIImageView(); - } - lineimage2_->SetPosition(232, 191); - lineimage2_->Resize(2, 82); - lineimage2_->SetViewId("image2"); - lineimage2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff333333); - lineimage2_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - lineimage2_->SetVisible(true); - - Add(progress_image); - Add(lineimage2_); - - // 初始化Lable - InitLabelExt(u_milelabel, 16, 234, 220, 35, "label2", STR_RANGE_SETTING, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabelExt(u_stepslabel, 73, 362, 320, 35, "label3", STR_STEP_NUMBER, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabelExt(u_calorielabel, 225, 235, 230, 35, "label4", STR_CALORIE_SETTING, DEFAULT_VECTOR_FONT_FILENAME, 30); - u_milelabel->SetTextColor(Color::Gray()); - u_stepslabel->SetTextColor(Color::Gray()); - u_calorielabel->SetTextColor(Color::Gray()); - - InitLabel(milelabel, 17, 160, 200, 80, "label6", "13.21", DEFAULT_VECTOR_FONT_FILENAME, 65); - InitLabel(calorielabel, 230, 160, 200, 80, "label7", "28312", DEFAULT_VECTOR_FONT_FILENAME, 65); - InitLabel(steplabel, 133, 285, 200, 80, "label8", "210.03", DEFAULT_VECTOR_FONT_FILENAME, 65); - Add(u_milelabel); - Add(u_stepslabel); - Add(u_calorielabel); - Add(milelabel); - Add(steplabel); - Add(calorielabel); +#include - InitButtonExt(intensity_button, 103, 70, 260, 80, "button", STR_LOWER_STRENGTH, 30); - Add(intensity_button); +namespace OHOS { - SetTouchable(true); - // SetIntercept(true); - } - /* DeInit:删除组件 */ - void TrainingDetailView::DeInit() - { - RemoveAll(); - if (u_milelabel != nullptr) - { - delete u_milelabel; - u_milelabel = nullptr; - } - if (u_stepslabel != nullptr) - { - delete u_stepslabel; - u_stepslabel = nullptr; - } - if (u_calorielabel != nullptr) - { - delete u_calorielabel; - u_calorielabel = nullptr; - } - if (milelabel != nullptr) - { - delete milelabel; - milelabel = nullptr; - } - if (steplabel != nullptr) - { - delete steplabel; - steplabel = nullptr; - } - if (calorielabel != nullptr) - { - delete calorielabel; - calorielabel = nullptr; - } +static TrainingDetailView *g_pTrainingDetailView{nullptr}; - if (progress_image != nullptr) - { - delete progress_image; - progress_image = nullptr; - } - if (lineimage2_ != nullptr) - { - delete lineimage2_; - lineimage2_ = nullptr; - } - if (intensity_button != nullptr) - { - delete intensity_button; - intensity_button = nullptr; - } - } +TrainingDetailView::TrainingDetailView() { + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + // SetStyle(STYLE_BACKGROUND_OPA, 0); + // SetStyle(STYLE_BORDER_RADIUS, 466); + g_pTrainingDetailView = this; +} +TrainingDetailView::~TrainingDetailView() { + RemoveAll(); + DeInit(); + g_pTrainingDetailView = nullptr; +} - void TrainingDetailView::PreLoad(void) - { - if (!viewiInitStatus) - { - InitView(); - viewiInitStatus = true; - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingDetailView"); - } +TrainingDetailView *TrainingDetailView::GetInstance() { + return g_pTrainingDetailView; +} - void TrainingDetailView::UnLoad(void) {} +/* InitView:初始化界面*/ +bool TrainingDetailView ::InitPage() { + // 初始化Image + InitImageView(progress_image, 0, 0, 100, 100, "image5", COLOR_PROGRESS_IMAGE); + // InitImageView(lineimage2_, 225, 190, 0, 0, "image", LINE_2_IMAGE); + if (lineimage2_ == nullptr) { + lineimage2_ = new UIImageView(); + } + lineimage2_->SetPosition(232, 191); + lineimage2_->Resize(2, 82); + lineimage2_->SetViewId("image2"); + lineimage2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff333333); + lineimage2_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + lineimage2_->SetVisible(true); + + Add(progress_image); + Add(lineimage2_); + + // 初始化Lable + InitLabelExt(u_milelabel, 16, 234, 220, 35, "label2", STR_RANGE_SETTING, + DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabelExt(u_stepslabel, 73, 362, 320, 35, "label3", STR_STEP_NUMBER, + DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabelExt(u_calorielabel, 225, 235, 230, 35, "label4", STR_CALORIE_SETTING, + DEFAULT_VECTOR_FONT_FILENAME, 30); + u_milelabel->SetTextColor(Color::Gray()); + u_stepslabel->SetTextColor(Color::Gray()); + u_calorielabel->SetTextColor(Color::Gray()); + + InitLabel(milelabel, 17, 160, 200, 80, "label6", "13.21", + DEFAULT_VECTOR_FONT_FILENAME, 65); + InitLabel(calorielabel, 230, 160, 200, 80, "label7", "28312", + DEFAULT_VECTOR_FONT_FILENAME, 65); + InitLabel(steplabel, 133, 285, 200, 80, "label8", "210.03", + DEFAULT_VECTOR_FONT_FILENAME, 65); + Add(u_milelabel); + Add(u_stepslabel); + Add(u_calorielabel); + Add(milelabel); + Add(steplabel); + Add(calorielabel); + + InitButtonExt(intensity_button, 103, 70, 260, 80, "button", + STR_LOWER_STRENGTH, 30); + Add(intensity_button); + + SetTouchable(true); + + return true; +} +/* DeInit:删除组件 */ +void TrainingDetailView::DeInit() { + RemoveAll(); + if (u_milelabel != nullptr) { + delete u_milelabel; + u_milelabel = nullptr; + } + if (u_stepslabel != nullptr) { + delete u_stepslabel; + u_stepslabel = nullptr; + } + if (u_calorielabel != nullptr) { + delete u_calorielabel; + u_calorielabel = nullptr; + } + if (milelabel != nullptr) { + delete milelabel; + milelabel = nullptr; + } + if (steplabel != nullptr) { + delete steplabel; + steplabel = nullptr; + } + if (calorielabel != nullptr) { + delete calorielabel; + calorielabel = nullptr; + } + + if (progress_image != nullptr) { + delete progress_image; + progress_image = nullptr; + } + if (lineimage2_ != nullptr) { + delete lineimage2_; + lineimage2_ = nullptr; + } + if (intensity_button != nullptr) { + delete intensity_button; + intensity_button = nullptr; + } +} - UILabelExt *TrainingDetailView::GetMileLabel() - { - return milelabel; - } - UILabelExt *TrainingDetailView::GetStepLabel() - { - return steplabel; - } - UILabelExt *TrainingDetailView::GetCalorieLabel() - { - return calorielabel; - } - UILabelButtonExt *TrainingDetailView::Get_Intensity_Button() - { - return intensity_button; - } +bool TrainingDetailView::InitView(void *caller) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingDetailView InitView %p", + caller); + if (InitPage() == false) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingDetailView::InitPage fail"); + return false; + } + SetDraggable(true); + SetTouchable(true); + // SleepDataRefresh(); + return true; +} +UILabelExt *TrainingDetailView::GetMileLabel() { return milelabel; } +UILabelExt *TrainingDetailView::GetStepLabel() { return steplabel; } +UILabelExt *TrainingDetailView::GetCalorieLabel() { return calorielabel; } +UILabelButtonExt *TrainingDetailView::Get_Intensity_Button() { + return intensity_button; } +} // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp index 97bdacdf7..a459d5e4c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp @@ -29,11 +29,14 @@ namespace OHOS TraingRecordView::~TraingRecordView() { - // DeInit(); - UIViewGroup *tmpGroup = dynamic_cast(container_); - UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + // DeInit() + lackView->RemoveAll(); + recordView->RemoveAll(); - g_pTraingRecordView = nullptr; + UIViewGroup *tmpGroup = dynamic_cast(container_); + UIViewGroup::RemoveAndDeleteAllRecursively(tmpGroup); + + g_pTraingRecordView = nullptr; } TraingRecordView *TraingRecordView::GetInstance() -- 2.17.1