power 适配切换到显示与方式Slice
authorluozheng <1732036298@qq.com>
Thu, 11 Jul 2024 12:13:25 +0000 (20:13 +0800)
committerluozheng <1732036298@qq.com>
Thu, 11 Jul 2024 12:13:25 +0000 (20:13 +0800)
code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp
code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp
code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleModel.h
code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleModel.cpp

index b3a13c9..f31f8f8 100644 (file)
@@ -219,6 +219,7 @@ void ApplistView::OnStop()
         FootballStyleOnStop();
     } else if (style == AppListStyle::HEXAGONS_STYLE) {
         HexagonsStyleOnStop();
+        RootView::GetInstance()->ClearOnKeyActListener();
     } else {
         ListStyleOnStop();
         RootView::GetInstance()->ClearOnKeyActListener();
index bc113aa..e74aa0b 100644 (file)
@@ -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 <AppViewIDs.h>
 #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;
     }
 
index 9368b8b..2458144 100644 (file)
@@ -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();
index c3f2406..db0801c 100644 (file)
@@ -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<ThemeStyle>(style));
+        return;
+    }
 }