From b03f60d4bd7e9f8e383728275d8eb0ba7fdf08ea Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 7 Jun 2024 10:58:35 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E4=BD=BF=E7=94=A8=E6=8C=89?= =?utf8?q?=E9=94=AE=E8=B7=B3=E8=BD=ACSlice=E4=B8=8D=E8=B5=B7=E4=BD=9C?= =?utf8?q?=E7=94=A8=E9=97=AE=E9=A2=98,=E5=A6=82=E6=9E=9Capplist=E4=B8=BA?= =?utf8?q?=E5=85=B6=E4=BB=96=E9=A3=8E=E6=A0=BC=E5=BD=A2=E5=BC=8F=E5=A6=82?= =?utf8?q?=E8=9C=82=E7=AA=9D=EF=BC=8C=E6=8C=89=E9=94=AE=E8=B7=B3=E8=BD=AC?= =?utf8?q?=E8=BF=94=E5=9B=9E=E9=9C=80=E8=A6=81=E6=A0=B9=E6=8D=AE=E5=85=B6?= =?utf8?q?=E9=A3=8E=E6=A0=BC=E6=89=8D=E8=83=BD=E8=B7=B3=E8=BD=AC=20eg?= =?utf8?q?=EF=BC=9ANativeAbility::GetInstance().Back(TransitionType::TRANS?= =?utf8?q?ITION=5FBACK=5FTO=5FHEXAGONS);?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/BrightnessLevelPresenter.cpp | 8 ++----- .../compass/src/MainCompassPresenter.cpp | 21 +++++++++++-------- .../countdown/src/MainCountDownPresenter.cpp | 5 ++--- .../src/DisplayBrightnessPresent.cpp | 4 +--- .../flashlight/src/FlashlightPresenter.cpp | 8 +++---- .../language/src/LanguageSwitchPresenter.cpp | 3 +-- .../slip/cat1Service/cat1_server.cpp | 2 +- .../drivers/peripheral/utils/custom_utils.c | 9 +++----- .../drivers/peripheral/utils/custom_utils.h | 5 +---- 9 files changed, 26 insertions(+), 39 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/brightnesslevel/src/BrightnessLevelPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/brightnesslevel/src/BrightnessLevelPresenter.cpp index bebd55ade..ce294d44c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/brightnesslevel/src/BrightnessLevelPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/brightnesslevel/src/BrightnessLevelPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-16 14:36:45 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-16 20:31:07 + * @LastEditTime: 2024-06-07 10:40:39 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/brightnesslevel/src/BrightnessLevelPresenter.cpp */ #include "brightnesslevel/include/BrightnessLevelPresenter.h" @@ -69,9 +69,7 @@ namespace OHOS UNUSED(view); if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - // NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); + NativeAbility::GetInstance().Back(); } return true; } @@ -85,8 +83,6 @@ namespace OHOS // 如果是power键,且是亮屏状态,按键释放就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - // NativeAbility::GetInstance().ChangeSlice(preSlice); NativeAbility::GetInstance().Back(); } return true; 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 78e9ec4f3..bf87159f4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/compass/src/MainCompassPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/compass/src/MainCompassPresenter.cpp @@ -1,9 +1,12 @@ /* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: MainCompassPresenter.cpp - * Author: - * Create: 2021-12-21 + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-14 15:02:03 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-07 10:33:16 + * @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 */ + #include "CompassView.h" #include "MainCompassPresenter.h" #include "MainCompassView.h" @@ -52,7 +55,7 @@ namespace OHOS UNUSED(view); if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + NativeAbility::GetInstance().Back(); } return true; } @@ -63,12 +66,12 @@ namespace OHOS bool MainCompassPresenter::OnKeyAct(UIView &view, const KeyEvent &event) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCompassPresenter::OnKeyAct"); - uint16 keyID = event.GetKeyId(); + uint16_t keyID = event.GetKeyId(); + uint16_t keyState = event.GetState(); // 如果是power键就返回上一级 - if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); + NativeAbility::GetInstance().Back(); } return true; } 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 1f086046b..fcacd8701 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp @@ -71,7 +71,7 @@ namespace OHOS { if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && strcmp(view.GetViewId(), MAINCOUNTDOWNVIEW) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + NativeAbility::GetInstance().Back(); } else if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && strcmp(view.GetViewId(), COUNTDOWN_TIMECONFIG_VIEW) == 0) { @@ -183,8 +183,7 @@ namespace OHOS // 如果是power键就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); + NativeAbility::GetInstance().Back(); } return true; } 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 60f0dc2bc..c796fd717 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 09:14:38 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-05-06 11:06:27 + * @LastEditTime: 2024-06-07 10:38:25 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp */ #include "AppViewIDs.h" @@ -156,7 +156,6 @@ namespace OHOS // 根据控件id查找是哪个控件触发了点击回调 if (strcmp(view.GetViewId(), BRINGHTNESSCONTROLBUTTON_VIEW) == 0) { - // NativeAbility::GetInstance().ChangeSlice(VIEW_BRIGHTNESSLEVEL); NativeAbility::GetInstance().EnterSlice(VIEW_BRIGHTNESSLEVEL); return true; } @@ -186,7 +185,6 @@ namespace OHOS } else if (strcmp(view.GetViewId(), DISPLAY_BRIGHTNESS_VIEW) == 0) { - // NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); NativeAbility::GetInstance().Back(); return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/flashlight/src/FlashlightPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/flashlight/src/FlashlightPresenter.cpp index b52a73444..a6cb95766 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/flashlight/src/FlashlightPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/flashlight/src/FlashlightPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-10 17:32:38 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-10 21:30:01 + * @LastEditTime: 2024-06-07 10:37:20 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/flashligh/src/FlashlightPresenter.cpp */ @@ -66,8 +66,7 @@ namespace OHOS UNUSED(view); if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); + NativeAbility::GetInstance().Back(); } return true; } @@ -91,8 +90,7 @@ namespace OHOS // 如果是power键就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); + NativeAbility::GetInstance().Back(); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/src/LanguageSwitchPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/language/src/LanguageSwitchPresenter.cpp index f92a2dea0..e5b02a894 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/src/LanguageSwitchPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/language/src/LanguageSwitchPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-28 14:17:43 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-05-07 10:02:26 + * @LastEditTime: 2024-06-07 10:36:33 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/LanguageSwitchPresenter.cpp */ #include "AppViewIDs.h" @@ -81,7 +81,6 @@ namespace OHOS UNUSED(view); if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); NativeAbility::GetInstance().Back(); } return true; diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp index 4371d2bb3..05f691cf8 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp @@ -876,7 +876,7 @@ static void time_sync_func(void) cat1_gettime(); #endif - if (uapi_get_screen_state() == 1) + if (uapi_get_screen_state() == 0) { cat1_getsignal(); }else{ diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 1d11fb7aa..8406939de 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -886,19 +886,16 @@ void uapi_setScreenDuration(int32_t time) display_api->set_screen_auto_off_timeout(time); } -/* - * @brief 获取屏幕状态 - * return 1 screen on , 0 screen off -*/ +/*获取屏幕状态: return 0 screen on , 1 screen off*/ int32_t uapi_get_screen_state(void) { const power_display_svr_api_t *display_api = power_display_svr_get_api(); screen_state_t state = display_api->get_screen_state(); // printf("uapi_get_screen_state = %s . \r\n", state==SCREEN_ON?"on":"off"); if( state == SCREEN_ON){ - return 1; - }else{ return 0; + }else{ + return 1; } } diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index 5bd5c3b68..7af5cc4de 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -81,10 +81,7 @@ void ScreenAlwaysOnCtr(uint8_t turnOnFlag); void uapi_setScreenBrightness(int value); void uapi_setScreenDuration(int32_t time); -/* - * @brief 获取屏幕状态 - * return 1 screen on , 0 screen off -*/ + int32_t uapi_get_screen_state(void); void uapi_systemVolumeSet(int16_t sounding); -- 2.17.1