From: luozheng <1732036298@qq.com> Date: Wed, 18 Jun 2025 06:43:51 +0000 (+0800) Subject: ECGslice提交,子界面待添加 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=4cf0133a301f7978a957a04ede53b1e80a1f893b;p=mirrors%2FFD230.git ECGslice提交,子界面待添加 --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 2e8fe8b78..797f3ff07 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -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 diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index 210e90cd7..1154017f7 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -136,6 +136,7 @@ namespace OHOS void InittestSlice(void); void InitBloodPressureCheckSlice(void); + void InitECGSlice(void); private: void InitAllNativeSlices(void); diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h index 8368d219d..1a0221e76 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h @@ -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"; // 打电话 diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index a7905dde6..e2b84944d 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -114,6 +114,9 @@ /*血压检测*/ #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; + 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 index 000000000..9c5cc60e8 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgModel.h @@ -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 index 000000000..93188d755 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgPresenter.h @@ -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, + 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 index 000000000..39114c7c5 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgView.h @@ -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 + { + + 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 index 000000000..1fc5a0e8f --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgModel.cpp @@ -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 index 000000000..04585d873 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgPresenter.cpp @@ -0,0 +1,107 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "common/key_code.h" +#include +#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::OnStart(); + } + + // 页面已经展示后的调用逻辑 + void EcgPresenter::OnResume(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnResume"); + Presenter::OnResume(); + if (view_ == nullptr) + { + return; + } + } + + // 页面准备切换到后台前执行的逻辑 + void EcgPresenter::OnPause(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnPause"); + Presenter::OnPause(); + } + + // 页面完全置于后台时的逻辑。 + void EcgPresenter::OnStop(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnStop"); + Presenter::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(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 index 000000000..25c4a370e --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgView.cpp @@ -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::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::OnSetUpView(); + Draw(); + return; + } + + void EcgView::OnTearDownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgView::OnTearDownView"); + View::OnTearDownView(); + return; + } + + void EcgView::OnStop() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgView::OnStop"); + View::OnStop(); + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + RootView::GetInstance()->ClearOnKeyActListener(); + return; + } +} \ No newline at end of file