From 39cd10f061425a165e06581bad674e62c5ee3b78 Mon Sep 17 00:00:00 2001 From: an4tur0r Date: Thu, 13 Oct 2022 16:54:13 +0300 Subject: [PATCH] lock device shortcut --- .../services/desktop/scenes/desktop_scene_main.c | 13 +++++++++++++ .../services/desktop/views/desktop_events.h | 1 + .../services/desktop/views/desktop_view_main.c | 2 ++ 3 files changed, 16 insertions(+) diff --git a/applications/services/desktop/scenes/desktop_scene_main.c b/applications/services/desktop/scenes/desktop_scene_main.c index 217725148..341ad1fb5 100644 --- a/applications/services/desktop/scenes/desktop_scene_main.c +++ b/applications/services/desktop/scenes/desktop_scene_main.c @@ -9,6 +9,7 @@ #include "../views/desktop_view_main.h" #include "desktop_scene.h" #include "desktop_scene_i.h" +#include "../helpers/pin_lock.h" #define TAG "DesktopSrv" @@ -96,6 +97,18 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) { consumed = true; break; + case DesktopMainEventLock: + if(desktop->settings.pin_code.length > 0) { + scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 1); + desktop_pin_lock(&desktop->settings); + desktop_lock(desktop); + } else { + scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 0); + desktop_lock(desktop); + } + consumed = true; + break; + case DesktopMainEventOpenArchive: #ifdef APP_ARCHIVE desktop_switch_to_app(desktop, &FLIPPER_ARCHIVE); diff --git a/applications/services/desktop/views/desktop_events.h b/applications/services/desktop/views/desktop_events.h index a7e610fff..37413da2e 100644 --- a/applications/services/desktop/views/desktop_events.h +++ b/applications/services/desktop/views/desktop_events.h @@ -9,6 +9,7 @@ typedef enum { DesktopMainEventOpenDebug, DesktopMainEventOpenPassport, DesktopMainEventOpenPowerOff, + DesktopMainEventLock, DesktopMainEventOpenGameMenu, diff --git a/applications/services/desktop/views/desktop_view_main.c b/applications/services/desktop/views/desktop_view_main.c index 354c3061c..f893566fd 100644 --- a/applications/services/desktop/views/desktop_view_main.c +++ b/applications/services/desktop/views/desktop_view_main.c @@ -67,6 +67,8 @@ bool desktop_main_input_callback(InputEvent* event, void* context) { main_view->callback(DesktopMainEventOpenDebug, main_view->context); } else if(event->key == InputKeyLeft) { main_view->callback(DesktopMainEventOpenFavoriteSecondary, main_view->context); + } else if(event->key == InputKeyUp) { + main_view->callback(DesktopMainEventLock, main_view->context); } } } else {