Merge pull request #338 from Willy-JL/autolock-with-pin

Autolock with pin code
This commit is contained in:
MX 2023-02-17 03:40:15 +03:00 committed by GitHub
commit faac423772
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 1 deletions

View File

@ -62,6 +62,9 @@ static bool desktop_custom_event_callback(void* context, uint32_t event) {
return true;
case DesktopGlobalAutoLock:
if(!loader_is_locked(desktop->loader)) {
if(desktop->settings.auto_lock_with_pin && desktop->settings.pin_code.length > 0) {
desktop_pin_lock(&desktop->settings);
}
desktop_lock(desktop);
}
return true;

View File

@ -8,7 +8,7 @@
#include <toolbox/saved_struct.h>
#include <storage/storage.h>
#define DESKTOP_SETTINGS_VER (6)
#define DESKTOP_SETTINGS_VER (7)
#define DESKTOP_SETTINGS_PATH INT_PATH(DESKTOP_SETTINGS_FILE_NAME)
#define DESKTOP_SETTINGS_MAGIC (0x17)
@ -63,4 +63,5 @@ typedef struct {
uint32_t auto_lock_delay_ms;
uint8_t displayBatteryPercentage;
uint8_t dummy_mode;
bool auto_lock_with_pin;
} DesktopSettings;

View File

@ -60,6 +60,14 @@ static void desktop_settings_scene_start_auto_lock_delay_changed(VariableItem* i
app->settings.auto_lock_delay_ms = auto_lock_delay_value[index];
}
static void desktop_settings_scene_start_auto_lock_pin_changed(VariableItem* item) {
DesktopSettingsApp* app = variable_item_get_context(item);
uint8_t value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
app->settings.auto_lock_with_pin = value;
}
void desktop_settings_scene_start_on_enter(void* context) {
DesktopSettingsApp* app = context;
VariableItemList* variable_item_list = app->variable_item_list;
@ -87,6 +95,16 @@ void desktop_settings_scene_start_on_enter(void* context) {
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, auto_lock_delay_text[value_index]);
item = variable_item_list_add(
variable_item_list,
"Auto Lock Pin",
2,
desktop_settings_scene_start_auto_lock_pin_changed,
app);
variable_item_set_current_value_index(item, app->settings.auto_lock_with_pin);
variable_item_set_current_value_text(item, app->settings.auto_lock_with_pin ? "ON" : "OFF");
item = variable_item_list_add(
variable_item_list,
"Battery View",