diff --git a/applications/main/xtreme_app/scenes/xtreme_app_scene_interface_lockscreen.c b/applications/main/xtreme_app/scenes/xtreme_app_scene_interface_lockscreen.c index 4a7b60aac..670feb186 100644 --- a/applications/main/xtreme_app/scenes/xtreme_app_scene_interface_lockscreen.c +++ b/applications/main/xtreme_app/scenes/xtreme_app_scene_interface_lockscreen.c @@ -41,6 +41,14 @@ static void app->save_settings = true; } +static void xtreme_app_scene_interface_lockscreen_lockscreen_poweroff_changed(VariableItem* item) { + XtremeApp* app = variable_item_get_context(item); + bool value = variable_item_get_current_value_index(item); + variable_item_set_current_value_text(item, value ? "ON" : "OFF"); + xtreme_settings.lockscreen_poweroff = value; + app->save_settings = true; +} + static void xtreme_app_scene_interface_lockscreen_lockscreen_time_changed(VariableItem* item) { XtremeApp* app = variable_item_get_context(item); bool value = variable_item_get_current_value_index(item); @@ -124,6 +132,15 @@ void xtreme_app_scene_interface_lockscreen_on_enter(void* context) { variable_item_set_current_value_text( item, xtreme_settings.allow_locked_rpc_commands ? "ON" : "OFF"); + item = variable_item_list_add( + var_item_list, + "Allow Poweroff", + 2, + xtreme_app_scene_interface_lockscreen_lockscreen_poweroff_changed, + app); + variable_item_set_current_value_index(item, xtreme_settings.lockscreen_poweroff); + variable_item_set_current_value_text(item, xtreme_settings.lockscreen_poweroff ? "ON" : "OFF"); + item = variable_item_list_add( var_item_list, "Show Time", diff --git a/applications/services/desktop/scenes/desktop_scene_locked.c b/applications/services/desktop/scenes/desktop_scene_locked.c index 513359f7e..79275dbd4 100644 --- a/applications/services/desktop/scenes/desktop_scene_locked.c +++ b/applications/services/desktop/scenes/desktop_scene_locked.c @@ -13,6 +13,7 @@ #include "../views/desktop_view_locked.h" #include "desktop_scene.h" #include "desktop_scene_i.h" +#include #define TAG "DesktopSrv" @@ -84,7 +85,9 @@ bool desktop_scene_locked_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { case DesktopLockedEventOpenPowerOff: { - loader_start(desktop->loader, "Power", "off", NULL); + if(xtreme_settings.lockscreen_poweroff) { + loader_start(desktop->loader, "Power", "off", NULL); + } consumed = true; break; } diff --git a/lib/xtreme/settings.c b/lib/xtreme/settings.c index b4d5b652e..978494318 100644 --- a/lib/xtreme/settings.c +++ b/lib/xtreme/settings.c @@ -15,6 +15,7 @@ XtremeSettings xtreme_settings = { .lock_on_boot = false, // OFF .bad_pins_format = false, // OFF .allow_locked_rpc_commands = false, // OFF + .lockscreen_poweroff = true, // ON .lockscreen_time = true, // ON .lockscreen_seconds = false, // OFF .lockscreen_date = true, // ON @@ -89,6 +90,10 @@ void XTREME_SETTINGS_LOAD() { x->lock_on_boot = b; } flipper_format_rewind(file); + if(flipper_format_read_bool(file, "lockscreen_poweroff", &b, 1)) { + x->lockscreen_poweroff = b; + } + flipper_format_rewind(file); if(flipper_format_read_bool(file, "lockscreen_time", &b, 1)) { x->lockscreen_time = b; } @@ -216,6 +221,7 @@ void XTREME_SETTINGS_SAVE() { flipper_format_write_bool( file, "allow_locked_rpc_commands", &x->allow_locked_rpc_commands, 1); flipper_format_write_bool(file, "lock_on_boot", &x->lock_on_boot, 1); + flipper_format_write_bool(file, "lockscreen_poweroff", &x->lockscreen_poweroff, 1); flipper_format_write_bool(file, "lockscreen_time", &x->lockscreen_time, 1); flipper_format_write_bool(file, "lockscreen_seconds", &x->lockscreen_seconds, 1); flipper_format_write_bool(file, "lockscreen_date", &x->lockscreen_date, 1); diff --git a/lib/xtreme/xtreme.h b/lib/xtreme/xtreme.h index f8b0e8761..b1b64ce9e 100644 --- a/lib/xtreme/xtreme.h +++ b/lib/xtreme/xtreme.h @@ -62,6 +62,7 @@ typedef struct { bool lock_on_boot; bool bad_pins_format; bool allow_locked_rpc_commands; + bool lockscreen_poweroff; bool lockscreen_time; bool lockscreen_seconds; bool lockscreen_date;