From: Caisking Date: Tue, 1 Jul 2025 09:36:03 +0000 (+0800) Subject: 运动卡片控制界面增加gps状态标签 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=a75c10e7f56ba10173079e528a9c337d734af6bd;p=mirrors%2FFD230.git 运动卡片控制界面增加gps状态标签 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingControlView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingControlView.h index bfe13d96f..d0358c15d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingControlView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingControlView.h @@ -47,6 +47,7 @@ namespace OHOS UIButton *GetButton(); UILabelExt *GetTimeLabel(); + UILabelExt *GetGpsStatusLabel(); private: UIView::OnDragListener *draglistener{nullptr}; @@ -62,6 +63,8 @@ namespace OHOS UIImageView *imagepoint = nullptr; + UILabelExt *gpsstatus = nullptr; + void ClearAll(void); }; } 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 f7ac60cf6..230ce9ddd 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 @@ -101,9 +101,7 @@ void TraingCardPresenter::ModifiesTime() { } if (TimeStr.empty()) { - WEARABLE_LOGE( - WEARABLE_LOG_MODULE_APP, - "TraingModel::GetInstance()->DisplayMotionDuration() nullptr"); + WEARABLE_LOGE( WEARABLE_LOG_MODULE_APP,"TraingModel::GetInstance()->DisplayMotionDuration() nullptr"); return; } if (TrainingControlView::GetInstance()->GetTimeLabel() != nullptr) { @@ -129,6 +127,19 @@ void TraingCardPresenter::UpdateTimeOfControl() { TrainingControlView::GetInstance()->GetTimeLabel()->SetText( TimeStr.c_str()); } + if(TrainingControlView::GetInstance()->GetGpsStatusLabel() != nullptr) { + //获取GPS状态 + bool gpsStatus = TraingModel::GetInstance()->GetGPSConnectState(); + std::string gpsStatusStr; + if (gpsStatus) { + gpsStatusStr = "GPS定位成功"; + TrainingControlView::GetInstance()->GetGpsStatusLabel()->SetTextColor(Color::Green()); + } else { + gpsStatusStr = "GPS未定位成功"; + TrainingControlView::GetInstance()->GetGpsStatusLabel()->SetTextColor(Color::Red()); + } + TrainingControlView::GetInstance()->GetGpsStatusLabel()->SetText(gpsStatusStr.c_str()); + } } void TraingCardPresenter::UpdateTimeOfData() { std ::string TimeStr = TraingModel::GetInstance()->DisplayMotionDuration(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingControlView.cpp index 1ca79f226..5a1353315 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingControlView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingControlView.cpp @@ -74,11 +74,16 @@ void TrainingControlView::InitView() { labelstop->SetTextId(STR_PAUSE); } + InitLabel(gpsstatus, 83, 365, 300, 35, "label1", "gps:定位中...", + DEFAULT_VECTOR_FONT_FILENAME, 30); + gpsstatus->SetTextColor(Color::Red()); + // 添加到视图中 Add(labeltitle); Add(labeltimer); Add(labelend); Add(labelstop); + Add(gpsstatus); // 初始化 Image InitImageView(imagepoint, 193, 421, 80, 20, "image1", CONTROL_POINT_IMAGE); @@ -108,6 +113,10 @@ void TrainingControlView::DeInit() { delete labelstop; labelstop = nullptr; } + if(gpsstatus != nullptr) { + delete gpsstatus; + gpsstatus = nullptr; + } // 删除Button if (buttonEnd != nullptr) { @@ -136,4 +145,5 @@ void TrainingControlView::PreLoad(void) { void TrainingControlView::UnLoad(void) {} UILabelExt *TrainingControlView::GetTimeLabel() { return labeltimer; } +UILabelExt *TrainingControlView::GetGpsStatusLabel() { return gpsstatus; } } // namespace OHOS