From 2794beffdc3e9b0d1113b7e7c9f9f86586cbd429 Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Tue, 24 Jun 2025 14:19:53 +0800 Subject: [PATCH] =?utf8?q?=E8=93=9D=E7=89=99=E6=88=96=E8=80=854G=E6=9C=AA?= =?utf8?q?=E8=BF=9E=E6=8E=A5slice?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 4 + .../nativelauncher/include/AppViewIDs.h | 2 + .../nativelauncher/include/NativeLauncher.h | 1 + .../nativelauncher/src/NativeLauncher.cpp | 17 ++++ .../include/UnconnectedPresenter.h | 35 +++++++ .../unconnected/include/UnconnectedView.h | 36 +++++++ .../unconnected/src/UnconnectedPresenter.cpp | 90 +++++++++++++++++ .../unconnected/src/UnconnectedView.cpp | 99 +++++++++++++++++++ 8 files changed, 284 insertions(+) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/unconnected/include/UnconnectedPresenter.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/unconnected/include/UnconnectedView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/unconnected/src/UnconnectedPresenter.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/unconnected/src/UnconnectedView.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 4b6a2adc1..1d6f51836 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -294,6 +294,10 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/fatiguelevel/src/FatigueFailView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/fatiguelevel/src/FatiguePresenter.cpp + #未连接 + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/unconnected/src/UnconnectedView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/unconnected/src/UnconnectedPresenter.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/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index 340058450..9c16e777d 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -103,6 +103,8 @@ typedef enum : uint16_t VIEW_ECG, //疲劳度 VIEW_FATIGUE, + //未连接 + VIEW_UNCONNECTED, //画布组件测试 VIEW_CANVAS_TEST, /* -------------------------------------------------------------------------- */ diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index ce35528d5..59a68487f 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -77,6 +77,7 @@ namespace OHOS void InitBloodPressureSlice(void); void InitStressSlice(void); void InitFatigueLevelSlice(void); + void InitUnconnectedSlice(void); void InitCheckAbnormalSlice(void); void InitCheckInvalidSlice(void); void InitHeartResultSlice(void); diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 2092d12e2..ef59c3426 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -124,6 +124,9 @@ /*疲劳度检测*/ #include "fatiguelevel/include/FatiguePresenter.h" #include "fatiguelevel/include/FatigueMainView.h" +/*未连接*/ +#include "unconnected/include/UnconnectedPresenter.h" +#include "unconnected/include/UnconnectedView.h" /*心率监测*/ #include "heartrate/include/HeartDetectionView.h" #include "heartrate/include/HeartDetectionPresenter.h" @@ -480,6 +483,8 @@ namespace OHOS {VIEW_PRESSURE, &NativeLauncher::InitStressSlice}, /*疲劳度监测*/ {VIEW_FATIGUE, &NativeLauncher::InitFatigueLevelSlice}, + /*未连接*/ + {VIEW_UNCONNECTED, &NativeLauncher::InitUnconnectedSlice}, /*心率检测*/ {VIEW_HEART_CHECK, &NativeLauncher::InitHeartCheckSlice}, {VIEW_HEART_RESULT, &NativeLauncher::InitHeartResultSlice}, @@ -1428,6 +1433,18 @@ namespace OHOS } NativeAbility::GetInstance().AddSliceProxy(VIEW_FATIGUE, fatigueView); } + // 未连接界面 + void NativeLauncher::InitUnconnectedSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitUnconnectedSlice"); + SliceProxy *unconnectedView = new AbilitySliceProxy; + if (unconnectedView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "unconnectedView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_UNCONNECTED, unconnectedView); + } // 心率监测界面 void NativeLauncher::InitHeartCheckSlice(void) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/unconnected/include/UnconnectedPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/unconnected/include/UnconnectedPresenter.h new file mode 100644 index 000000000..494bc22e9 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/unconnected/include/UnconnectedPresenter.h @@ -0,0 +1,35 @@ + +#ifndef UNCONNECTED_PRESENTER_H +#define UNCONNECTED_PRESENTER_H + +#include "Presenter.h" +#include "View.h" + +namespace OHOS +{ + class UnconnectedView; + class UnconnectedPresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UIView::OnDragListener + { + public: + UnconnectedPresenter(); + virtual ~UnconnectedPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static UnconnectedPresenter *GetInstance(); + + 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; // 增加按键事件 + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/unconnected/include/UnconnectedView.h b/code/sdk/application/wearable/fd230app/nativeui/unconnected/include/UnconnectedView.h new file mode 100644 index 000000000..c4426f10e --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/unconnected/include/UnconnectedView.h @@ -0,0 +1,36 @@ +#ifndef UNCONNECTED_VIEW_H_ +#define UNCONNECTED_VIEW_H_ + +#include "BaseView.h" +#include "View.h" +#include "ecg/include/EcgTestNeedAppOrNetworkView.h" +#include "components/ui_scroll_view.h" +namespace OHOS +{ + + class UnconnectedPresenter; + class UnconnectedView : public View + { + + public: + UnconnectedView(); + virtual ~UnconnectedView(); + static UnconnectedView *GetInstance(void); + EcgTestNeedAppOrNetworkView *GetcgTestNeedAppOrNetworkView(void) + { + return g_pEcgTestNeedAppOrNetworkView; + } + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void UnconnectedViewInit(void); + void ClearAll(void); + UIViewGroup *grouplView{nullptr}; + EcgTestNeedAppOrNetworkView *g_pEcgTestNeedAppOrNetworkView{nullptr}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/unconnected/src/UnconnectedPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/unconnected/src/UnconnectedPresenter.cpp new file mode 100644 index 000000000..8ccdddf5e --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/unconnected/src/UnconnectedPresenter.cpp @@ -0,0 +1,90 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-16 14:36:45 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-18 15:19:37 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/Unconnected/src/UnconnectedPresenter.cpp + */ +#include "unconnected/include/UnconnectedPresenter.h" +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "common/key_code.h" +#include +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static UnconnectedPresenter *g_pUnconnectedPresenter = nullptr; + + UnconnectedPresenter::UnconnectedPresenter() + { + g_pUnconnectedPresenter = this; + } + + UnconnectedPresenter::~UnconnectedPresenter() + { + g_pUnconnectedPresenter = nullptr; + } + + UnconnectedPresenter *UnconnectedPresenter::GetInstance() + { + return g_pUnconnectedPresenter; + } + + void UnconnectedPresenter::OnStart() + { + Presenter::OnStart(); + } + + void UnconnectedPresenter::OnPause(void) + { + Presenter::OnPause(); + } + + void UnconnectedPresenter::OnResume(void) + { + Presenter::OnResume(); + } + + void UnconnectedPresenter::OnStop(void) + { + Presenter::OnStop(); + } + + bool UnconnectedPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + return true; + } + + bool UnconnectedPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } + + bool UnconnectedPresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + UNUSED(view); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + } + return true; + } + + bool UnconnectedPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UnconnectedPresenter::OnKeyAct"); + unsigned short keyID = event.GetKeyId(); + unsigned short 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/unconnected/src/UnconnectedView.cpp b/code/sdk/application/wearable/fd230app/nativeui/unconnected/src/UnconnectedView.cpp new file mode 100644 index 000000000..344726eee --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/unconnected/src/UnconnectedView.cpp @@ -0,0 +1,99 @@ + +#include "unconnected/include/UnconnectedView.h" +#include "unconnected/include/UnconnectedPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + + static UnconnectedView *g_pUnconnectedView{nullptr}; + + UnconnectedView::UnconnectedView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UnconnectedView::UnconnectedView"); + g_pUnconnectedView = this; + } + + UnconnectedView::~UnconnectedView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UnconnectedView::~UnconnectedView"); + g_pUnconnectedView = nullptr; + } + + UnconnectedView *UnconnectedView::GetInstance() + { + return g_pUnconnectedView; + } + + void UnconnectedView::ClearAll(void) + { + if (g_pEcgTestNeedAppOrNetworkView != nullptr) + { + delete g_pEcgTestNeedAppOrNetworkView; + g_pEcgTestNeedAppOrNetworkView = nullptr; + + delete grouplView; + grouplView = nullptr; + } + } + + void UnconnectedView::UnconnectedViewInit(void) + { + g_pEcgTestNeedAppOrNetworkView = new EcgTestNeedAppOrNetworkView(); + if (g_pEcgTestNeedAppOrNetworkView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[UnconnectedView::UnconnectedViewInit] p_BrightnessControlView is nullptr!!"); + return; + } + grouplView = g_pEcgTestNeedAppOrNetworkView->EcgTestNeedAppOrNetworkInit(); + if (grouplView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[UnconnectedView::UnconnectedViewInit] scorllView == nullptr"); + return; + } + } + + void UnconnectedView::OnStart() + { + View::OnStart(); + SetContainerView(new UIViewGroup()); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetOnDragListener(presenter_); + container_->SetTouchable(true); + container_->SetDraggable(true); + + UnconnectedViewInit(); + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::UnconnectedPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); + } + + void UnconnectedView::OnSetUpView() + { + View::OnSetUpView(); + container_->Add(grouplView); + Draw(); + } + + void UnconnectedView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void UnconnectedView::OnStop() + { + + View::OnStop(); + if (container_ != nullptr) + { + ClearAll(); + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + RootView::GetInstance()->ClearOnKeyActListener(); + return; + } +} \ No newline at end of file -- 2.17.1