From e96b427d4b0e7a0603784d2cf7fc281e3eceb96d Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 11 Jul 2024 20:13:25 +0800 Subject: [PATCH] =?utf8?q?power=20=E9=80=82=E9=85=8D=E5=88=87=E6=8D=A2?= =?utf8?q?=E5=88=B0=E6=98=BE=E7=A4=BA=E4=B8=8E=E6=96=B9=E5=BC=8FSlice?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/applist/src/ApplistView.cpp | 1 + .../nativeui/rebootdevice/src/RebootModel.cpp | 33 ++++++++++++++++++- .../themestyle/include/ThemeStyleModel.h | 3 +- .../themestyle/src/ThemeStyleModel.cpp | 20 ++++++++++- 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp index b3a13c922..f31f8f816 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp @@ -219,6 +219,7 @@ void ApplistView::OnStop() FootballStyleOnStop(); } else if (style == AppListStyle::HEXAGONS_STYLE) { HexagonsStyleOnStop(); + RootView::GetInstance()->ClearOnKeyActListener(); } else { ListStyleOnStop(); RootView::GetInstance()->ClearOnKeyActListener(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp index bc113aa6e..e74aa0bd6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-28 11:50:42 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-11 14:41:49 + * @LastEditTime: 2024-07-11 19:35:30 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp */ @@ -14,6 +14,8 @@ #include #include "power_display_service.h" #include "aimodels/include/AiModelsModel.h" +#include "themestyle/include/ThemeStyleModel.h" + namespace OHOS { RebootModel::RebootModel() {} @@ -92,6 +94,29 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandlePowerKeyDoubleClick"); // Handle PowerKey DoubleClick logic here + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + if (!display_api) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr"); + return; + } + + if (display_api->get_screen_state() == SCREEN_ON) + { + // ThemeStyleModel &themeStyleModel = ThemeStyleModel::GetInstance(); + // ThemeStyle style = themeStyleModel.GetAppListDisplayStyle(); + // themeStyleModel.SwitchApplistStyleOnPowerClick(); // 切换样式 + // uint16_t sliceId = NativeAbility::GetInstance().GetCurSliceId(); + // if (sliceId == VIEW_APPLIST) + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM); + // } + NativeAbility::GetInstance().EnterSlice(VIEW_THEME_STYLE); + } + else + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Screen is not on, skipping applist style change"); + } } /*注册电源键的双击事件*/ @@ -99,6 +124,12 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootModel::RegisterPowerKeyDoubleClickEvent"); // Register PowerKey DoubleClick event here + int32_t ret = uapi_button_register_event_cb(HandlePowerKeyDoubleClick, BUTTON_PWR_CLICKUP_2); + if (ret != ERRCODE_SUCC) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register FuncKey Click Event error, ret = %d", ret); + return false; + } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleModel.h b/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleModel.h index 9368b8b6a..24581446c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleModel.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-14 09:40:13 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-06 16:43:47 + * @LastEditTime: 2024-07-11 17:17:52 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleModel.h */ #ifndef SET_THEMESTYLE_MODEL_H @@ -52,6 +52,7 @@ namespace OHOS static ThemeStyleModel &GetInstance(void); ThemeStyle GetAppListDisplayStyle(void); void SetAppListDisplayStyle(ThemeStyle style); + void SwitchApplistStyleOnPowerClick(void); private: ThemeStyleModel(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleModel.cpp index c3f2406db..db0801ce3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleModel.cpp @@ -8,7 +8,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-07 09:21:47 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-06 16:43:52 + * @LastEditTime: 2024-07-11 17:52:54 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/ThemeStyleModel.cpp */ @@ -83,4 +83,22 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetAppListDisplayStyle fail!!"); } } + + /*通过power建切换applist的样式*/ + void ThemeStyleModel::SwitchApplistStyleOnPowerClick(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThemeStyleModel::SwitchApplistStyleOnPowerClick"); + uint16_t style = GetAppListDisplayStyle(); + style += 1; + if (style == FOOTBALL_STYLE) + { + style += 1; + } + if (style >= MAX_THEME_STYLE) + { + style = APPLIST_STYLE; + } + SetAppListDisplayStyle(static_cast(style)); + return; + } } -- 2.17.1