From: Caisking <3449750381@qq.com> Date: Fri, 12 Apr 2024 12:37:40 +0000 (+0800) Subject: 修复训练结束弹窗bug X-Git-Tag: release_V1.2.70_20241020_135402~1203 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=6a1d365eaa47ccbeed50527a3d8f19054ad3b74e;p=mirrors%2FFD230.git 修复训练结束弹窗bug --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp index e64c1f0a5..4145204b1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp @@ -29,7 +29,6 @@ namespace OHOS {VIEW_COMPASS, PNG_APPLIST_COMPASS_IMAGE, PNG_APPLIST_COMPASS_IMAGE, "指南针", nullptr}, {VIEW_BLOODOXY, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_SPO2_IMAGE, "血氧饱和度", nullptr}, {VIEW_HEART, PNG_APPLIST_HEART_IMAGE, PNG_APPLIST_HEART_IMAGE, "心率检测", nullptr}, - {VIEW_INDOORWALK, PNG_APPLIST_WALK_IMAGE, PNG_APPLIST_WALK_IMAGE, "室内步行", nullptr}, {VIEW_WEATHER, PNG_APPLIST_WEATHER_IMAGE, PNG_APPLIST_WEATHER_IMAGE, "天气", nullptr}, {VIEW_TRAINING, PNG_APPLIST_TRAINING_IMAGE, PNG_APPLIST_TRAINING_IMAGE, "体能训练", nullptr}, {VIEW_TRAINING_RECORD, PNG_APPLIST_TRAINING_RECORD_IMAGE, PNG_APPLIST_TRAINING_RECORD_IMAGE, "训练记录", nullptr}, @@ -51,6 +50,7 @@ namespace OHOS {VIEW_OFFLINEVOICE, PNG_APPLIST_VOCASSIST_IMAGE, PNG_APPLIST_VOCASSIST_IMAGE, "语音助手", nullptr}, {VIEW_UISAMPLE, PNG_APPLIST_UI_SAMPLE_IMAGE, PNG_APPLIST_UI_SAMPLE_IMAGE, "示例", nullptr}, {VIEW_MESSAGE, PNG_APPLIST_CALLER_IMAGE, PNG_APPLIST_CALLER_IMAGE, "信息通知", nullptr}, + {VIEW_INDOORWALK, PNG_APPLIST_WALK_IMAGE, PNG_APPLIST_WALK_IMAGE, "室内步行", nullptr}, #endif }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h index 04f33d048..94d410510 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h @@ -149,10 +149,16 @@ namespace OHOS }; struct SportData { - int calories; // 训练卡路里 - int duration; // 训练时长 - int steps; // 训练步数 - int distance; // 训练距离 + uint32 starttime; // 开始时间时间戳 + uint32 endtime; // 结束时间时间戳 + int goaldegree; // 目标完成度 + int calories; // 训练卡路里 + int duration; // 训练时长 + int steps; // 训练步数 + int distance; // 训练距离 + int intensity; // 训练强度 + int avgheart; // 训练平均心率 + UIResourceTextId sportId; // 训练Id }; class TraingModel @@ -169,15 +175,11 @@ namespace OHOS bool InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); bool InitButtonExt(UILabelButtonExt *&button, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, int fontSize); bool InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); - + void InitList(); void SetQuickTraining(QuickTraining *quickTraining); QuickTraining *GetQuickTraining() const; - /*屏幕管理*/ - void SetSteadyOn(); - void SetSteadyOff(); - /*定时器 */ std::string DisplayMotionDuration(); /*设置运动项目*/ @@ -204,9 +206,6 @@ namespace OHOS std::string motionDuration; // 训练时长 UIResourceTextId sportId_ = STR_EXTREME_SPORTS; // 训练项目 ExerciseState sportstate_ = ExerciseState::General; // 训练状态 - - const power_display_svr_api_t *display_api = power_display_svr_get_api(); - uint32_t display_time; }; } 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 dadbdcac9..8890dc464 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -411,14 +411,7 @@ namespace OHOS // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::InitImageView is succeed"); return true; } - void TraingModel::SetSteadyOn() - { - display_api->set_screen_set_keepon_timeout(-1); - } - void TraingModel::SetSteadyOff() - { - display_api->set_screen_set_keepon_timeout(0); - } + /* -------------------------------------------------------------------------- */ /*设置运动Id*/ void TraingModel::SetSportEvent(UIResourceTextId id) 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 3ceee1fb6..bc893f975 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 @@ -74,6 +74,7 @@ namespace OHOS void SetEndViewStatus(bool status); void ShowEndView(); + void RefreshEndView(); UIView *GetTraingCrad(); int GetCurrentPage(); 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 f8c437867..e9366d6cb 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 @@ -187,7 +187,7 @@ namespace OHOS TrainingDetailView::GetInstance()->GetStepLabel()->SetText(stepsStr.c_str()); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ControlSensor--Calories: %s, Distance: %s, Steps: %s", calorieStr.c_str(), distanceStr.c_str(), stepsStr.c_str()); - + // 释放sportdata内存 } /*刷新time和data*/ @@ -236,6 +236,7 @@ namespace OHOS ControlSensor(ExerciseState::Pause); // 弹窗显示是否结束 TraingCardView::GetInstance()->SetEndViewStatus(true); + TraingCardView::GetInstance()->RefreshEndView(); } // 退出按键 if (strcmp(view.GetViewId(), BUTTONEXIT) == 0) 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 c306aafa8..8857a4119 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 @@ -235,7 +235,7 @@ namespace OHOS /*结束弹窗界面*/ void TraingCardView::ShowEndView() { - momentumFlag = false; // 标志位还原 + // momentumFlag = false; // 标志位还原 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowEndView"); endView = new UIScrollView(); if (endView == nullptr) @@ -248,23 +248,9 @@ namespace OHOS endView->SetReboundSize(50); endView->SetDirection(1); - // 获取训练卡路里判断运动量 - int caldata = TraingModel::GetInstance()->GetCal(); - if (caldata >= 10) - { - momentumFlag = true; - } - // 初始化Lable - if (momentumFlag) - { - TraingModel::GetInstance()->InitLabel(endtitle, 83, 50, 300, 35, "label1", "结束运动", DEFAULT_VECTOR_FONT_FILENAME, 30); - TraingModel::GetInstance()->InitLabel(notelabel, 56, 187, 360, 40, "label2", "是否结束本次运动", DEFAULT_VECTOR_FONT_FILENAME, 30); - } - else - { - TraingModel::GetInstance()->InitLabel(endtitle, 83, 50, 300, 35, "label1", "注意", DEFAULT_VECTOR_FONT_FILENAME, 30); - TraingModel::GetInstance()->InitLabel(notelabel, 56, 167, 360, 80, "label2", "当前运动量过少,无法记录 是否结束运动", DEFAULT_VECTOR_FONT_FILENAME, 30); - } + TraingModel::GetInstance()->InitLabel(endtitle, 83, 50, 300, 35, "label1", "注意", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabel(notelabel, 56, 167, 360, 80, "label2", "当前运动量过少,无法记录 是否结束运动", DEFAULT_VECTOR_FONT_FILENAME, 30); + endView->Add(endtitle); endView->Add(notelabel); @@ -299,7 +285,28 @@ namespace OHOS endView->SetVisible(status); return; } - + /*获取运动量结束弹窗界面刷新*/ + void TraingCardView::RefreshEndView() + { + // 获取训练卡路里判断运动量 + int caldata = TraingModel::GetInstance()->GetCal(); + if (caldata >= 1) + { + momentumFlag = true; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "momentumFlag %d", momentumFlag); + if (momentumFlag) + { + // 正常结束 + endtitle->SetTextId(STR_END_MOVEMENT); + notelabel->SetTextId(STR_END_THIS_MOVEMENT); + } + else + { + endtitle->SetTextId(STR_LOOK_OUT); + notelabel->SetTextId(STR_INSUFFICIENT_EXERCISE_AMOUNT); + } + } /*获取卡片View单例*/ UIView *TraingCardView::GetTraingCrad() {