From: luozheng <1732036298@qq.com> Date: Thu, 13 Jun 2024 12:12:16 +0000 (+0800) Subject: 注册双击按键事件,目前双击function键会跳转到显示方式界面 X-Git-Tag: release_V1.2.70_20241020_135402~1004 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=df945741fcebf88926167604aef078f9469958ed;p=mirrors%2FFD230.git 注册双击按键事件,目前双击function键会跳转到显示方式界面 --- diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index d412038d0..fe802689e 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -406,8 +406,8 @@ namespace OHOS // 初始化默认首页 ScreenModels::GetInstance()->PreLoadAppimages(); // NativeAbility::GetInstance().SetDefaultSliceId(VIEW_MAIN); - // 注册长按重启或关机事件 - RebootModel::GetInstance()->RegisterLongPressEvents(); + // 注册按键事件 + RebootModel::GetInstance()->RegisterKeyEvents(); // 开机检测充电状态 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get_charge_stat is %d", get_charge_stat()); diff --git a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp index 8ea443029..4d71687bc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp @@ -179,15 +179,15 @@ void KeyInputListener::CallVolumeDipSwitchControl(VolumeChangeStatus status) if (mcu_pms_is_screen_on()) { PressAlarmNotify(); // 当前为闹钟通知页面时,先处理闹钟再切换页面 - if (SecondaryFunctionModel::GetInstance()->GetHeartRateOrBloodOxygenQuickAccessSwitch() == true) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM); - } - else - { - // 之后需要将VIEW_APPLIST改成心率的SliceID - NativeAbility::GetInstance().ChangeSlice(VIEW_BLOODOXY, TransitionType::TRANSITION_ZOOM); - } + // if (SecondaryFunctionModel::GetInstance()->GetHeartRateOrBloodOxygenQuickAccessSwitch() == true) + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM); + // } + // else + // { + // // 之后需要将VIEW_APPLIST改成心率的SliceID + // NativeAbility::GetInstance().ChangeSlice(VIEW_BLOODOXY, TransitionType::TRANSITION_ZOOM); + // } } } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootModel.h b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootModel.h index 915652f34..90c7ecdc6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootModel.h @@ -1,7 +1,10 @@ /* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Reboot Model - * Create: 2022-04-28 + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-12 11:44:04 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-13 19:09:49 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootModel.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%A */ #ifndef REBOOT_MODEL_H @@ -26,6 +29,8 @@ public: bool GetExitsView(void); void SetExitsView(bool value); bool RegisterLongPressEvents(void); + bool RegisterDoubleClickEvents(void); + void RegisterKeyEvents(void); private: RebootModel(); int16_t selectView{0}; 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 d1d09ecc9..73ecf58c8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp @@ -1,7 +1,9 @@ /* - * Copyright (c) CompanyNameMagicTag 2022-2022. All rights reserved. - * Description: Reboot Model - * Create: 2022-04-28 + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-28 11:50:42 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-13 19:52:52 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp */ #include "rebootdevice/include/RebootModel.h" @@ -64,7 +66,7 @@ namespace OHOS { display_api->turn_on_screen(); } - //切换到关机/重启卡片 + // 切换到关机/重启卡片 NativeAbility::GetInstance().ChangeSlice(VIEW_SHUTDOWN_OR_REBOOT); return; @@ -85,4 +87,44 @@ namespace OHOS } return true; } + + /* + * @brief 双击事件回调函数 + */ + static void OnKeyDoubleClick_Callback(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnKeyDoubleClick_Callback"); + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + if (display_api->get_screen_state() == SCREEN_ON) + { + // 切换到主题样式界面 + NativeAbility::GetInstance().EnterSlice(VIEW_SET_DESKTOP); + //NativeAbility::GetInstance().ChangeSlice(VIEW_SET_DESKTOP); + } + + return; + } + + /* + * @brief 注册双击事件 + * @return 注册成功返回true,反之返回false + */ + bool RebootModel::RegisterDoubleClickEvents(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootModel::RegisterDoubleClickEvents"); + int32_t ret = uapi_button_register_event_cb(OnKeyDoubleClick_Callback, BUTTON1_CLICKUP_2); + if (ret != ERRCODE_SUCC) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register DoubleClick Events err,ret = %d", ret); + return false; + } + return true; + } + + // 注册按键事件 + void RebootModel::RegisterKeyEvents(void) + { + RegisterLongPressEvents(); + RegisterDoubleClickEvents(); + } } \ No newline at end of file