From 460b181a3bb31c96b342da80457f83b53d2facba Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 7 Jun 2024 20:43:50 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E6=8C=87=E5=8D=97=E9=92=88?= =?utf8?q?=EF=BC=8C=E5=80=92=E8=AE=A1=E6=97=B6=EF=BC=8C=E6=98=BE=E7=A4=BA?= =?utf8?q?=E4=B8=8E=E4=BA=AE=E5=BA=A6=E7=9A=84=E9=80=80=E5=87=BA=E9=80=BB?= =?utf8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../compass/include/MainCompassPresenter.h | 12 +++++--- .../compass/src/MainCompassPresenter.cpp | 21 +++++++++++--- .../include/MainCountDownPresenter.h | 3 +- .../countdown/src/MainCountDownPresenter.cpp | 27 ++++++++++++------ .../countdown/src/MainCountDownView.cpp | 1 + .../include/DisplayBrightnessPresenter.h | 3 +- .../src/DisplayBrightnessPresent.cpp | 28 ++++++++++++------- .../src/DisplayBrightnessView.cpp | 1 + 8 files changed, 67 insertions(+), 29 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/compass/include/MainCompassPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/compass/include/MainCompassPresenter.h index 8bc3c1d40..4123c1d5d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/compass/include/MainCompassPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/compass/include/MainCompassPresenter.h @@ -1,8 +1,10 @@ /* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: MainCompassPresenter.h - * Author: - * Create: 2021-12-21 + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-07 09:21:47 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-07 20:18:32 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/compass/include/MainCompassPresenter.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ #ifndef COMPASS_MAINPRESENTER_H #define COMPASS_MAINPRESENTER_H @@ -35,8 +37,10 @@ public: static MainCompassPresenter *GetInstance(void); bool OnDrag(UIView& view, const DragEvent& event) override; + bool OnDragEnd(UIView& view, const DragEvent& event) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 void Notify() override; + bool X_DRAG_FLAG{false}; }; } #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/compass/src/MainCompassPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/compass/src/MainCompassPresenter.cpp index bf87159f4..516365c85 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/compass/src/MainCompassPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/compass/src/MainCompassPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-14 15:02:03 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-07 10:33:16 + * @LastEditTime: 2024-06-07 20:23:18 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/compass/src/MainCompassPresenter.cpp * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -13,6 +13,7 @@ #include "wearable_log.h" #include "common/key_code.h" #include "custom_utils.h" +#include "UiConfig.h" namespace OHOS { static MainCompassPresenter *g_pMainView = nullptr; @@ -52,10 +53,22 @@ namespace OHOS */ bool MainCompassPresenter::OnDrag(UIView &view, const DragEvent &event) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCompassPresenter::OnDrag"); UNUSED(view); - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 { - NativeAbility::GetInstance().Back(); + MainCompassPresenter::X_DRAG_FLAG = true; + } + return true; + } + + bool MainCompassPresenter::OnDragEnd(UIView& view, const DragEvent& event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCompassPresenter::OnDragEnd"); + UNUSED(view); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && MainCompassPresenter::X_DRAG_FLAG) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); } return true; } @@ -71,7 +84,7 @@ bool MainCompassPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 如果是power键就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - NativeAbility::GetInstance().Back(); + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/MainCountDownPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/MainCountDownPresenter.h index dea71c490..d946e7b39 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/MainCountDownPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/MainCountDownPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-07 18:15:53 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-09 15:40:05 + * @LastEditTime: 2024-06-07 19:57:56 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/countdown/include/MainCountDownPresenter.h */ #ifndef MAIN_COUNTDOWN_PRESENTER_H @@ -55,6 +55,7 @@ namespace OHOS std::string countdowntime{0}; std::string ringtime{0}; + bool X_DRAG_FLAG{false}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp index fcacd8701..40ea1b5b7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp @@ -1,5 +1,6 @@ #include "AppViewIDs.h" #include "NativeAbility.h" +#include "UiConfig.h" #include "countdown/include/MainCountDownPresenter.h" #include "countdown/include/CountDownModel.h" #include "common/key_code.h" @@ -57,25 +58,33 @@ namespace OHOS { Presenter::OnStop(); ScreenAlwaysOnCtr(0); // 取消长亮屏 - } bool MainCountDownPresenter::OnDrag(UIView &view, const DragEvent &event) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCountDownPresenter::OnDrag"); UNUSED(view); - UNUSED(event); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + MainCountDownPresenter::X_DRAG_FLAG = true; + } return true; } bool MainCountDownPresenter::OnDragEnd(UIView &view, const DragEvent &event) { - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && strcmp(view.GetViewId(), MAINCOUNTDOWNVIEW) == 0) - { - NativeAbility::GetInstance().Back(); - } - else if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && strcmp(view.GetViewId(), COUNTDOWN_TIMECONFIG_VIEW) == 0) + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCountDownPresenter::OnDragEnd"); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && MainCountDownPresenter::X_DRAG_FLAG) { - MainCountDownView::GetInstance()->ChangeView(TIMECONFIG_COUNTDOWN, MAIN_COUNTDOWN); + if (strcmp(view.GetViewId(), MAINCOUNTDOWNVIEW) == 0) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + } + else if (strcmp(view.GetViewId(), COUNTDOWN_TIMECONFIG_VIEW) == 0) + { + MainCountDownView::GetInstance()->ChangeView(TIMECONFIG_COUNTDOWN, MAIN_COUNTDOWN); + } + MainCountDownPresenter::X_DRAG_FLAG = false; } return true; } @@ -183,7 +192,7 @@ namespace OHOS // 如果是power键就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - NativeAbility::GetInstance().Back(); + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownView.cpp index a70dd21e3..2680cbae7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownView.cpp @@ -383,6 +383,7 @@ namespace OHOS scrollView[MAIN_COUNTDOWN]->Add(COUNTDOWN_THIRTY_MINUTE_BUTTON); group->Add(scrollView[MAIN_COUNTDOWN]); RootView::GetInstance()->Add(group); + container_ = group; Draw(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h index 445a202be..1e070aebb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-02-18 09:10:05 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-18 15:53:53 + * @LastEditTime: 2024-06-07 19:25:27 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h */ #ifndef _DISPLAY_BRIGHTNESS_PRESENTER_H @@ -100,6 +100,7 @@ namespace OHOS bool OnDragEnd(UIView &view, const DragEvent &event) override; bool OnChange(UICheckBox::UICheckBoxState state) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + bool X_DRAG_FLAG{false}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp index c796fd717..21400b2e6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp @@ -2,10 +2,11 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 09:14:38 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-07 10:38:25 + * @LastEditTime: 2024-06-07 19:55:47 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp */ #include "AppViewIDs.h" +#include "UiConfig.h" #include "components/ui_label_ext.h" #include "language/font/ui_resource_string.h" #include "NativeAbility.h" @@ -152,32 +153,38 @@ namespace OHOS bool DisplayBrightnessPresenter::OnClick(UIView &view, const ClickEvent &event) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessPresenter::OnClick"); DisplayBrightnessView *p_DisplayBrightnessView = DisplayBrightnessView::GetInstance(); - // 根据控件id查找是哪个控件触发了点击回调 + if (p_DisplayBrightnessView == nullptr) + { + return false; + } if (strcmp(view.GetViewId(), BRINGHTNESSCONTROLBUTTON_VIEW) == 0) { NativeAbility::GetInstance().EnterSlice(VIEW_BRIGHTNESSLEVEL); - return true; } - if (strcmp(view.GetViewId(), SCREENDURATIONBUTTON_VIEWID) == 0) + else if (strcmp(view.GetViewId(), SCREENDURATIONBUTTON_VIEWID) == 0) { p_DisplayBrightnessView->ChangeView(DISPLAYBRIGHTNESSVIEW, SCREENDURATIONVIEW); // 切换到亮屏时长视图 - return true; } - return false; + return true; } bool DisplayBrightnessPresenter::OnDrag(UIView &view, const DragEvent &event) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessPresenter::OnDrag"); UNUSED(view); - UNUSED(event); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + DisplayBrightnessPresenter::X_DRAG_FLAG = true; + } return true; } bool DisplayBrightnessPresenter::OnDragEnd(UIView &view, const DragEvent &event) { DisplayBrightnessView *p_DisplayBrightnessView = DisplayBrightnessView::GetInstance(); - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && DisplayBrightnessPresenter::X_DRAG_FLAG) { if (strcmp(view.GetViewId(), SCREENDURATIONSCROLLVIEW) == 0) { @@ -185,9 +192,10 @@ namespace OHOS } else if (strcmp(view.GetViewId(), DISPLAY_BRIGHTNESS_VIEW) == 0) { - NativeAbility::GetInstance().Back(); - return true; + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + } + DisplayBrightnessPresenter::X_DRAG_FLAG = false; } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp index d205e179e..caaa16fc2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp @@ -553,6 +553,7 @@ namespace OHOS DisplayBrightnessScrollView[DISPLAYBRIGHTNESSVIEW]->Add(RaiseToBrightnessLabel); DisplayBrightnessScrollView[DISPLAYBRIGHTNESSVIEW]->Add(RaiseToBrightnessCheckBoxButton); RootView::GetInstance()->Add(DisplayBrightnessScrollView[DISPLAYBRIGHTNESSVIEW]); + container_ = DisplayBrightnessScrollView[DISPLAYBRIGHTNESSVIEW]; Draw(); } -- 2.17.1