ECGslice提交,子界面待添加
authorluozheng <1732036298@qq.com>
Wed, 18 Jun 2025 06:43:51 +0000 (14:43 +0800)
committerluozheng <1732036298@qq.com>
Wed, 18 Jun 2025 06:43:51 +0000 (14:43 +0800)
code/sdk/application/wearable/fd230app/CMakeLists.txt
code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h
code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h
code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp
code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgModel.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgView.cpp [new file with mode: 0644]

index 2e8fe8b..797f3ff 100644 (file)
@@ -236,6 +236,8 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPMainView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPMainPresenter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPModel.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPCalPosReqView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPLastCalibrationTimeView.cpp
 
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/detection/BPDetectionView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/detection/BPDetectionPresenter.cpp
@@ -246,8 +248,10 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/detection/BPDetectErrorView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/detection/BPDetectFailView.cpp 
 
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPCalPosReqView.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPLastCalibrationTimeView.cpp
+    # ECG
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgModel.cpp 
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgPresenter.cpp 
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgView.cpp 
 
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetooth/src/BluetoothDeviceListView.cpp
index 210e90c..1154017 100644 (file)
@@ -136,6 +136,7 @@ namespace OHOS
         void InittestSlice(void);
 
         void InitBloodPressureCheckSlice(void);
+        void InitECGSlice(void);
 
     private:
         void InitAllNativeSlices(void);
index 8368d21..1a0221e 100644 (file)
@@ -540,6 +540,7 @@ namespace OHOS
     static constexpr const char *PNG_APPLIST_ALARM_IMAGE = APP_LIST_PATH "/alarm.bin";              // 闹钟
     static constexpr const char *PNG_APPLIST_SPO2_IMAGE = APP_LIST_PATH "/booldoxygen.bin";         // 血氧
     static constexpr const char *PNG_APPLIST_BP_MESSURE_IMAGE = APP_LIST_PATH "/blood_pressure.bin";         // 血压测量
+    static constexpr const char *PNG_APPLIST_ECG_IMAGE = APP_LIST_PATH "/ecg.bin";                   // 心电(ECG)测量
     static constexpr const char *PNG_APPLIST_BP_IMAGE = APP_LIST_PATH "/bp_calibration.bin";         // 血压校准
     static constexpr const char *PNG_APPLIST_HEART_IMAGE = APP_LIST_PATH "/heart.bin";              // 心率
     static constexpr const char *PNG_APPLIST_SETTING_IMAGE = APP_LIST_PATH "/setting.bin";          // 设置
@@ -578,7 +579,8 @@ namespace OHOS
     static constexpr const char *PNG_APPLIST_ALARM_IMAGE_BIG = APP_LIST_PATH "/applist_big_icon/alarm.bin";              // 闹钟
     static constexpr const char *PNG_APPLIST_SPO2_IMAGE_BIG = APP_LIST_PATH "/applist_big_icon/booldoxygen.bin";         // 血氧
     static constexpr const char *PNG_APPLIST_BP_MESSURE_IMAGE_BIG = APP_LIST_PATH "/applist_big_icon/blood_pressure.bin";   // 血压测量
-    static constexpr const char *PNG_APPLIST_BP_IMAGE_BIG = APP_LIST_PATH "/applist_big_icon/bp_calibration.bin";   // 血压校准
+    static constexpr const char *PNG_APPLIST_BP_IMAGE_BIG = APP_LIST_PATH "/applist_big_icon/bp_calibration.bin";         // 血压校准
+    static constexpr const char *PNG_APPLIST_ECG_IMAGE_BIG = APP_LIST_PATH "/applist_big_icon/ecg.bin";                   // 心电(ECG)测量
     static constexpr const char *PNG_APPLIST_HEART_IMAGE_BIG = APP_LIST_PATH "/applist_big_icon/heart.bin";              // 心率
     static constexpr const char *PNG_APPLIST_SETTING_IMAGE_BIG = APP_LIST_PATH "/applist_big_icon/setting.bin";          // 设置
     static constexpr const char *PNG_APPLIST_CALLER_IMAGE_BIG = APP_LIST_PATH "/applist_big_icon/phone.bin";             // 打电话
index a7905dd..e2b8494 100644 (file)
 /*血压检测*/
 #include "bloodpressure/include/detection/BPDetectionPresenter.h"
 #include "bloodpressure/include/detection/BPDetectionView.h"
+/*ECG*/
+#include "ecg/include/EcgPresenter.h"
+#include "ecg/include/EcgView.h"
 /*心率监测*/
 #include "heartrate/include/HeartDetectionView.h"
 #include "heartrate/include/HeartDetectionPresenter.h"
@@ -455,6 +458,8 @@ namespace OHOS
         {VIEW_BLOOD_PRESSURE_CALIBRATION, &NativeLauncher::InitBloodPressureSlice},
         /*血压监测*/
         {VIEW_BLOOD_PRESSURE_CHECK, &NativeLauncher::InitBloodPressureCheckSlice},
+        /*ECG*/
+        {VIEW_ECG, &NativeLauncher::InitECGSlice},
         /*心率检测*/
         {VIEW_HEART_CHECK, &NativeLauncher::InitHeartCheckSlice},
         {VIEW_HEART_RESULT, &NativeLauncher::InitHeartResultSlice},
@@ -1355,6 +1360,17 @@ namespace OHOS
         }
         NativeAbility::GetInstance().AddSliceProxy(VIEW_BLOOD_PRESSURE_CHECK, bloodPressureCheckView);
     }
+    void NativeLauncher::InitECGSlice(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitECGSlice");
+        SliceProxy *ECGView = new AbilitySliceProxy<EcgView, EcgPresenter>;
+        if (ECGView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ECGView is nullptr");
+            return;
+        }
+        NativeAbility::GetInstance().AddSliceProxy(VIEW_ECG, ECGView);
+    }
     // 心率监测界面
     void NativeLauncher::InitHeartCheckSlice(void)
     {
diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgModel.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgModel.h
new file mode 100644 (file)
index 0000000..9c5cc60
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef ECG_MODEL_H
+#define ECG_MODEL_H
+
+namespace OHOS
+{
+    class EcgModel
+    {
+    public:
+        static EcgModel &GetInstance(void);
+
+    private:
+        EcgModel();
+        ~EcgModel();
+        EcgModel(const EcgModel &) = delete;
+        EcgModel &operator=(const EcgModel &) = delete;
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgPresenter.h
new file mode 100644 (file)
index 0000000..93188d7
--- /dev/null
@@ -0,0 +1,39 @@
+
+#ifndef ECG_PRESENTER_H
+#define ECG_PRESENTER_H
+
+#include "Presenter.h"
+#include "EcgView.h"
+
+namespace OHOS
+{
+    class EcgView;
+    class EcgModel;
+    class EcgPresenter : public Presenter<EcgView>,
+                             public UIView::OnClickListener,
+                             public UIView::OnDragListener,
+                             public RootView::OnKeyActListener
+    {
+    public:
+        EcgPresenter();
+        ~EcgPresenter();
+        static EcgPresenter *GetInstance();
+
+        void OnStart() override;
+        void OnResume() override;
+        void OnPause() override;
+        void OnStop() override;
+
+
+    private:
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+        bool OnDrag(UIView &view, const DragEvent &event) override;
+        bool OnDragEnd(UIView &view, const DragEvent &event) override;
+        bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
+
+        EcgModel *model;
+        bool X_DRAG_FLAG{false};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgView.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgView.h
new file mode 100644 (file)
index 0000000..39114c7
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef ECG_VIEW_H
+#define ECG_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+
+namespace OHOS
+{
+    class EcgPresenter;
+    class EcgView : public View<EcgPresenter>
+    {
+
+    public:
+        EcgView();
+        ~EcgView();
+        static EcgView *GetInstance(void);
+
+        void OnStart() override;
+        void OnSetUpView() override;
+        void OnTearDownView() override;
+        void OnStop() override;
+
+    private:
+        void CreateEcgView(void);
+        void ClearAll(void);
+
+        bool viewInitStatus{false};
+    };
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgModel.cpp
new file mode 100644 (file)
index 0000000..1fc5a0e
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-07-08 09:39:58
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-07-08 09:43:15
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aimodels/src/EcgModel.cpp
+ */
+
+#include "ecg/include/EcgModel.h"
+#include "wearable_log.h"
+
+namespace OHOS
+{
+    EcgModel::EcgModel() {}
+    EcgModel::~EcgModel() {}
+    EcgModel &EcgModel::GetInstance()
+    {
+        static EcgModel instance;
+        return instance;
+    }
+
+}
diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgPresenter.cpp
new file mode 100644 (file)
index 0000000..04585d8
--- /dev/null
@@ -0,0 +1,107 @@
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+#include "common/key_code.h"
+#include <custom_utils.h>
+#include "UiConfig.h"
+#include "ecg/include/EcgPresenter.h"
+#include "ecg/include/EcgView.h"
+#include "ecg/include/EcgModel.h"
+
+namespace OHOS
+{
+
+    // 当前Presenter属性实例化的内存指针
+    static EcgPresenter *g_pEcgPresenter = nullptr;
+
+    EcgPresenter::EcgPresenter()
+    {
+        model = &EcgModel::GetInstance();
+        g_pEcgPresenter = this;
+    }
+
+    EcgPresenter::~EcgPresenter()
+    {
+        g_pEcgPresenter = nullptr;
+    }
+
+    EcgPresenter *EcgPresenter::GetInstance()
+    {
+        return g_pEcgPresenter;
+    }
+
+    // 启动时执行的逻辑
+    void EcgPresenter::OnStart()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnStart");
+        Presenter<EcgView>::OnStart();
+    }
+
+    // 页面已经展示后的调用逻辑
+    void EcgPresenter::OnResume(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnResume");
+        Presenter<EcgView>::OnResume();
+        if (view_ == nullptr)
+        {
+            return;
+        }
+    }
+
+    // 页面准备切换到后台前执行的逻辑
+    void EcgPresenter::OnPause(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnPause");
+        Presenter<EcgView>::OnPause();
+    }
+
+    // 页面完全置于后台时的逻辑。
+    void EcgPresenter::OnStop(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnStop");
+        Presenter<EcgView>::OnStop();
+    }
+
+    bool EcgPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        UNUSED(event);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnClick");
+        return true;
+    }
+
+    bool EcgPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        UNUSED(view);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnDrag");
+        if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动
+        {
+            EcgPresenter::X_DRAG_FLAG = true;
+        }
+        return true;
+    }
+
+    bool EcgPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+        UNUSED(view);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnDragEnd");
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && EcgPresenter::X_DRAG_FLAG)
+        {
+            NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
+            EcgPresenter::X_DRAG_FLAG = false;
+        }
+        return true;
+    }
+
+    bool EcgPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件
+    {
+        UNUSED(view);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnKeyAct");
+        uint16_t keyID = event.GetKeyId();
+        uint16_t keyState = event.GetState();
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
+        {
+            NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
+        }
+        return true;
+    }
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgView.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgView.cpp
new file mode 100644 (file)
index 0000000..25c4a37
--- /dev/null
@@ -0,0 +1,89 @@
+#include "ecg/include/EcgPresenter.h"
+#include "ecg/include/EcgView.h"
+#include "wearable_log.h"
+
+namespace OHOS
+{
+
+    static EcgView *g_pEcgView{nullptr};
+    EcgView::EcgView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgView::EcgView");
+        g_pEcgView = this;
+    }
+
+    EcgView::~EcgView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgView::~EcgView");
+        ClearAll();
+        g_pEcgView = nullptr;
+    }
+
+    EcgView *EcgView::GetInstance()
+    {
+        return g_pEcgView;
+    }
+
+    void EcgView::ClearAll(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgView::ClearAll");
+    }
+
+    void EcgView::CreateEcgView(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgView::CreateEcgView");
+    }
+
+    void EcgView::OnStart()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgView::OnStart");
+        View<EcgPresenter>::OnStart();
+        SetContainerView(new UIViewGroup());
+        if (GetContainer() == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!");
+            return;
+        }
+        container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+        container_->SetOnDragListener(presenter_);
+        container_->SetTouchable(true);
+        container_->SetDraggable(true);
+
+        if (!viewInitStatus)
+        {
+            CreateEcgView();
+            viewInitStatus = true;
+        }
+
+        RootView::GetInstance()->SetOnKeyActListener(presenter_);
+        return;
+    }
+    void EcgView::OnSetUpView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgView::OnSetUpView");
+        View<EcgPresenter>::OnSetUpView();
+        Draw();
+        return;
+    }
+
+    void EcgView::OnTearDownView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgView::OnTearDownView");
+        View<EcgPresenter>::OnTearDownView();
+        return;
+    }
+
+    void EcgView::OnStop()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgView::OnStop");
+        View<EcgPresenter>::OnStop();
+        if (container_ != nullptr)
+        {
+            container_->RemoveAll();
+            delete container_;
+            container_ = nullptr;
+        }
+        RootView::GetInstance()->ClearOnKeyActListener();
+        return;
+    }
+}
\ No newline at end of file