mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-14 10:48:35 -07:00
Add desktop auto lock with pin setting
This commit is contained in:
@@ -56,7 +56,7 @@ static bool desktop_custom_event_callback(void* context, uint32_t event) {
|
||||
return true;
|
||||
case DesktopGlobalAutoLock:
|
||||
if(!loader_is_locked(desktop->loader)) {
|
||||
if(desktop->settings.pin_code.length > 0) {
|
||||
if(desktop->settings.auto_lock_with_pin && desktop->settings.pin_code.length > 0) {
|
||||
desktop_pin_lock(&desktop->settings);
|
||||
}
|
||||
desktop_lock(desktop);
|
||||
|
||||
@@ -54,4 +54,5 @@ typedef struct {
|
||||
PinCode pin_code;
|
||||
uint8_t is_locked;
|
||||
uint32_t auto_lock_delay_ms;
|
||||
bool auto_lock_with_pin;
|
||||
} DesktopSettings;
|
||||
|
||||
@@ -39,6 +39,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;
|
||||
@@ -66,6 +74,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");
|
||||
|
||||
variable_item_list_set_enter_callback(
|
||||
variable_item_list, desktop_settings_scene_start_var_list_enter_callback, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewVarItemList);
|
||||
|
||||
Reference in New Issue
Block a user