增加运动GPSUI;增加gps提醒界面 1878/1 1878/head
authorCaisking <Casiking@zhihuishixun.com>
Sat, 21 Jun 2025 07:13:12 +0000 (15:13 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Sat, 21 Jun 2025 07:13:12 +0000 (15:13 +0800)
code/sdk/application/wearable/fd230app/CMakeLists.txt
code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h
code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h
code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_GPS/include/TraingGPSPresenter.h
code/sdk/application/wearable/fd230app/nativeui/traing/training_GPS/include/TraingGPSnoteView.h
code/sdk/application/wearable/fd230app/nativeui/traing/training_GPS/src/TraingGPSnotePresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_GPS/src/TraingGPSnoteView.cpp

index 95a35e9..7700ba0 100644 (file)
@@ -684,6 +684,8 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TrainingSetTimeView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TrainingSetMileView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TrainingSetStepView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_GPS/src/TraingGPSnoteView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_GPS/src/TraingGPSnotePresenter.cpp
     
     #主界面训练卡片
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_card/src/Training_CardView.cpp
index bcc445e..3400584 100644 (file)
@@ -113,6 +113,7 @@ typedef enum : uint16_t
     VIEW_TRAININGCRAD,    // 训练控制卡片
     VIEW_TRAININGENDDATA, // 训练结束详细数据
     VIEW_TRAINING_RECORD, // 训练记录
+    VIEW_TRAINING_GPSNOTE,// 训练GPS提醒
     /* ---------------------------------- 训练列表 ---------------------------------- */
     VIEW_TRAININGMORE,    // 更多训练
     VIEW_TRAININGLIMIT,   // 极限运动列表
index 0527c37..616ca23 100644 (file)
@@ -99,6 +99,7 @@ namespace OHOS
         void InitTraingSetSlice(void);
         void InitTraingCardSlice(void);
         void InitTraingEnddataSlice(void);
+        void InitTraingGPSNoteSlice(void);
 
         void InitTraingMoreSlice(void);    // 更多训练
         void InitTraingLimitSlice(void);   // 极限训练
index e7e4304..aad142d 100644 (file)
 #include "traing/include/TraingSetView.h"
 #include "traing/include/TraingEnddataPresenter.h"
 #include "traing/include/TraingEnddataView.h"
+#include "traing/training_GPS/include/TraingGPSnoteView.h"
+#include "traing/training_GPS/include/TraingGPSnotePresenter.h"
+
 /* ---------------------------------- 训练记录 ---------------------------------- */
 #include "traingrecord/include/TraingRecordView.h"
 #include "traingrecord/include/TraingRecordPresenter.h"
@@ -444,6 +447,7 @@ namespace OHOS
         {VIEW_TRAININGAQUATIC,
          &NativeLauncher::InitTraingAquaticSlice}, // 水上训练
         {VIEW_TRAININGOTHER, &NativeLauncher::InitTraingOtherSlice}, // 水上训练
+        {VIEW_TRAINING_GPSNOTE, &NativeLauncher::InitTraingGPSNoteSlice}, // 训练GPS提醒
         /* --------------------------------------------------------------------------
          */
         /*消息通知*/
@@ -1777,4 +1781,17 @@ namespace OHOS
         NativeAbility::GetInstance().AddSliceProxy(VIEW_CANVAS_TEST, t_View);
     }
 
+    /*GPSnote*/
+    void NativeLauncher::InitTraingGPSNoteSlice(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitGPSNote");
+        SliceProxy *t_View = new AbilitySliceProxy<TraingGPSnoteView, TraingGPSnotePresenter>;
+        if (nullptr == t_View)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "View is nullptr");
+            return;
+        }
+        NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAINING_GPSNOTE, t_View);
+    }
+
 }
index 581ea61..ce3aab9 100644 (file)
@@ -67,6 +67,13 @@ namespace OHOS
         UILabelExt *sporttitle_ = nullptr;
         UIButton *buttonGo_ = nullptr;
         UILabelButtonExt *buttonSet_ = nullptr;
+
+        /*心率与GPS*/
+        UIImageView *gps_image_ = nullptr;
+        UILabel *gps_label_ = nullptr;
+        UIImageView *heartrate_image_ = nullptr;
+        UILabel *heartrate_label_ = nullptr;
+
         bool viewiInitStatus{false};
     };
 } // namespace OHOS
index 8852455..a8a3e4c 100644 (file)
@@ -98,7 +98,7 @@ namespace OHOS
         if (strcmp(view.GetViewId(), BUTTONGO) == 0)\r
         {\r
             // 开始训练 ->不返回\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCRAD);\r
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING_GPSNOTE);\r
 \r
             // 获取运动项目\r
             ExerciseClass type = TraingModel::GetInstance()->GetSportId();\r
index 8f4bc3a..84ffe6d 100644 (file)
@@ -68,6 +68,16 @@ namespace OHOS
         buttonSet_->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingNomalPresenter::GetInstance()));
         container_->Add(buttonGo_);
         container_->Add(buttonSet_);
+
+        InitUILabel(heartrate_label_, -32, 230, 200, 60, "heartrate_label_", "--", DEFAULT_VECTOR_FONT_FILENAME, 35);
+        container_->Add(heartrate_label_);
+        InitUILabel(gps_label_, 295, 230, 200, 60, "label_time", "GPS", DEFAULT_VECTOR_FONT_FILENAME, 35);
+        container_->Add(gps_label_);
+        
+        InitImageView(gps_image_, 375, 193, 100, 100, "gps_image", GPS_1_IMAGE);
+        container_->Add(gps_image_);
+        InitImageView(heartrate_image_, 48, 193, 100, 100, "heartrate_image_", HEARTRATE_1_IMAGE);
+        container_->Add(heartrate_image_);
     }
     /* DeInit:删除组件*/
     void TraingNomalView::DeInit()
@@ -91,6 +101,26 @@ namespace OHOS
             delete buttonSet_;
             buttonSet_ = nullptr;
         }
+        if (heartrate_label_ != nullptr)
+        {
+            delete heartrate_label_;
+            heartrate_label_ = nullptr;
+        }
+        if(gps_label_ != nullptr)
+        {
+            delete gps_label_;
+            gps_label_ = nullptr;
+        }
+        if(gps_image_ != nullptr)
+        {
+            delete gps_image_;
+            gps_image_ = nullptr;
+        }
+        if(heartrate_image_ != nullptr)
+        {
+            delete heartrate_image_;
+            heartrate_image_ = nullptr;
+        }
     }
 
     void TraingNomalView::PreLoad(void)
index f6e1dfc..b0ea810 100644 (file)
@@ -8,7 +8,6 @@
 namespace OHOS
 {
     class TraingGPSView;
-
     class TraingGPSPresenter : public Presenter<TraingGPSView>,
                                  public UIView::OnClickListener,
                                  public UIView::OnDragListener
index eb282d7..736bfac 100644 (file)
@@ -4,68 +4,65 @@
 
 #include "BaseView.h"
 #include "View.h"
-#include <ui_scroll_view.h>
-#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.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 "traing/Training_UiConfig.h"
 #include "traing/include/TraingModel.h"
 #include "uicomponents/UIComponents.h"
-#include "traing/Training_UiConfig.h"
+#include "wearable_log.h"
+#include <ui_scroll_view.h>
 
 #include "TraingGPSnotePresenter.h"
-namespace OHOS
-{
+namespace OHOS {
 #define BUTTONBACK "button1"
 #define BUTTONGO "button2"
 
-    class TraingGPSnotePresenter;
-    class TraingGPSnoteView : public View<TraingGPSnotePresenter>
-    {
+class TraingGPSnotePresenter;
+class TraingGPSnoteView : public View<TraingGPSnotePresenter> {
+
+public:
+  TraingGPSnoteView();
+  virtual ~TraingGPSnoteView();
+  static TraingGPSnoteView *GetInstance(void);
+
+  void OnStart() override;
+  void OnSetUpView() override;
+  void OnTearDownView() override;
+  void OnStop() override;
+  void InitView();
+  void DeInit();
 
-    public:
-        TraingGPSnoteView();
-        virtual ~TraingGPSnoteView();
-        static TraingGPSnoteView *GetInstance(void);
+  void InitList();
+  void PreLoad(void);
 
-        void OnStart() override;
-        void OnSetUpView() override;
-        void OnTearDownView() override;
-        void OnStop() override;
-        void InitView();
-        void DeInit();
-       
-        void InitList();
-        void PreLoad(void);
+private:
+  UIView::OnDragListener *draglistener{nullptr};
+  TraingGPSnoteView(TraingGPSnoteView &&) = delete;
+  TraingGPSnoteView &operator=(TraingGPSnoteView &&) = delete;
 
-    private:
-        UIView::OnDragListener *draglistener{nullptr};
-        TraingGPSnoteView(TraingGPSnoteView &&) = delete;
-        TraingGPSnoteView &operator=(TraingGPSnoteView &&) = delete;
+  UIScrollView *scrollView1_ = nullptr;
 
-        UIViewGroup *container_ = nullptr;
-        UIScrollView *scrollView1_ = nullptr;
+  UILabelExt *label1_ = nullptr;
+  UILabelExt *label2_ = nullptr;
 
-        UILabelExt *label1_ = nullptr;
-        UILabelExt *label2_ = nullptr;
-        UILabelExt *label3_ = nullptr;
-        UILabelExt *label4_ = nullptr;
 
-        UIButton *button1_ = nullptr;
-        UIButton *button2_ = nullptr;
+  UILabelButtonExt *button_wait = nullptr;
+  UILabelButtonExt *button_go = nullptr;
 
-        UIImageView *image1_ = nullptr;
-        UIImageView *image2_ = nullptr;
-        bool viewiInitStatus{false};
-    };
+  UIImageView *image1_ = nullptr;
+  UIImageView *image2_ = nullptr;
+  bool viewiInitStatus{false};
+};
 } // namespace OHOS
 #endif // TraingGPSnote_PRESENTER_H
index 4aed46d..254c11c 100644 (file)
@@ -78,11 +78,11 @@ namespace OHOS
         // 根据控件id查找是哪个控件触发了点击回调
         if (strcmp(view.GetViewId(), BUTTONBACK) == 0)
         {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPSLACK);
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGNOMAL);
         }
         if (strcmp(view.GetViewId(), BUTTONGO) == 0)
         {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPSLOST);
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCRAD);
         }
         return true;
     }
index 755797a..825b14b 100644 (file)
@@ -11,7 +11,7 @@
 #include "traing/include/TraingModel.h"
 #include "uicomponents/UIComponents.h"
 #include "traing/Training_UiConfig.h"
-
+#include "ui_resource_image.h"
 namespace OHOS
 {
 
@@ -61,27 +61,29 @@ namespace OHOS
         scrollView1_->SetVisible(true);
 
         // 初始化Image
-        TraingModel::GetInstance()->InitImageView(image1_, 193, 111, 80, 80, "image1", WARNING_IMAGE);
+        InitImageView(image1_, 193, 111, 80, 80, "image1", WARNING_IMAGE);
         scrollView1_->Add(image1_);
 
         // 初始化button
-        TraingModel::GetInstance()->InitButton(button1_, 118, 334, 230, 80, BUTTONBACK);
-        button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c);
-        scrollView1_->Add(button1_);
+        InitButtonExt(button_wait, 118, 334, 230, 80, BUTTONBACK, STR_SET_TARGET, 30);
+        button_wait->SetText("继续等待");
+        button_wait->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c);
+        scrollView1_->Add(button_wait);
+        button_wait->SetOnClickListener(presenter_);
 
-        TraingModel::GetInstance()->InitButton(button2_, 118, 434, 230, 80, BUTTONGO);
-        scrollView1_->Add(button2_);
+        InitButtonExt(button_go, 118, 434, 230, 80, BUTTONGO, STR_SET_TARGET, 30);
+        button_go->SetText("直接开始");
+        scrollView1_->Add(button_go);
+        button_go->SetOnClickListener(presenter_);
 
         // 初始化Lable
-        TraingModel::GetInstance()->InitLabel(label1_, 160, 52, 90, 35, "label1", "GPS未准备", DEFAULT_VECTOR_FONT_FILENAME, 30);
-        TraingModel::GetInstance()->InitLabel(label2_, 33, 215, 60, 40, "label2", "GPS仍在定位,建议等待定位\n完成后再开始训练", DEFAULT_VECTOR_FONT_FILENAME, 30);
-        TraingModel::GetInstance()->InitLabel(label3_, 181, 357, 60, 40, "label3", "继续等待", DEFAULT_VECTOR_FONT_FILENAME, 30);
-        TraingModel::GetInstance()->InitLabel(label4_, 181, 457, 60, 40, "label4", "直接开始", DEFAULT_VECTOR_FONT_FILENAME, 30);
+       InitLabel(label1_, 133, 52, 200, 60, "label1", "GPS未准备", DEFAULT_VECTOR_FONT_FILENAME, 30);
+       InitLabel(label2_, 33, 215, 400, 90, "label2", "GPS仍在定位,建议等待定位 完成后再开始训练", DEFAULT_VECTOR_FONT_FILENAME, 30);
+
 
         scrollView1_->Add(label1_);
         scrollView1_->Add(label2_);
-        scrollView1_->Add(label3_);
-        scrollView1_->Add(label4_);
+
 
         // Add ImageView to App
         if (image2_ == nullptr)
@@ -99,19 +101,48 @@ namespace OHOS
     /* DeInit:删除组件 */
     void TraingGPSnoteView::DeInit()
     {
-        UIView *view = static_cast<UIViewGroup *>(container_)->GetChildrenHead();
-        while (view != nullptr)
+       if(container_ != nullptr)
+        {
+          container_->RemoveAll();
+        }
+        if (scrollView1_ != nullptr)
         {
-            UIView *tempView = view;
-            view = view->GetNextSibling();
-            if (tempView->GetParent())
+            scrollView1_->RemoveAll();
+            if (image1_ != nullptr)
+            {
+                delete image1_;
+                image1_ = nullptr;
+            }
+            if (button_wait != nullptr)
+            {
+                delete button_wait;
+                button_wait = nullptr;
+            }
+            if(button_go != nullptr)
             {
-                static_cast<UIViewGroup *>(tempView->GetParent())->Remove(tempView);
+                delete button_go;
+                button_go = nullptr;
             }
-            delete tempView;
+            if (label1_ != nullptr)
+            {
+                delete label1_;
+                label1_ = nullptr;
+            }
+            if (label2_ != nullptr)
+            {
+                delete label2_;
+                label2_ = nullptr;
+            }
+            if (image2_ != nullptr)
+            {
+                delete image2_;
+                image2_ = nullptr;
+            }
+
+            delete scrollView1_;
+            scrollView1_ = nullptr;
         }
-        delete container_;
-        container_ = nullptr;
+        
     }
 
     void TraingGPSnoteView::PreLoad(void)
@@ -145,7 +176,9 @@ namespace OHOS
         container_->SetDraggable(true);
 
         PreLoad();
-        RootView::GetInstance()->Add(container_);
+     
+        SetContainerView(container_);
+        // RootView::GetInstance()->SetOnKeyActListener(presenter_);
     }
 
     void TraingGPSnoteView::OnSetUpView()
@@ -165,6 +198,12 @@ namespace OHOS
     void TraingGPSnoteView::OnStop()
     {
         View<TraingGPSnotePresenter>::OnStop();
+        if (container_ != nullptr)
+        {
+            container_->RemoveAll();
+            delete container_;
+            container_ = nullptr;
+        }
         RootView::GetInstance()->RemoveAll();
         return;
     }