diff --git a/applications/settings/desktop_settings/desktop_settings_app.c b/applications/settings/desktop_settings/desktop_settings_app.c index 7eeb3fdde..53d5a9452 100644 --- a/applications/settings/desktop_settings/desktop_settings_app.c +++ b/applications/settings/desktop_settings/desktop_settings_app.c @@ -73,7 +73,6 @@ DesktopSettingsApp* desktop_settings_app_alloc(void) { DesktopSettingsApp* app = malloc(sizeof(DesktopSettingsApp)); app->gui = furi_record_open(RECORD_GUI); - app->desktop = furi_record_open(RECORD_DESKTOP); app->dialogs = furi_record_open(RECORD_DIALOGS); app->view_dispatcher = view_dispatcher_alloc(); app->scene_manager = scene_manager_alloc(&desktop_settings_scene_handlers, app); @@ -142,20 +141,21 @@ void desktop_settings_app_free(DesktopSettingsApp* app) { scene_manager_free(app->scene_manager); // Records furi_record_close(RECORD_DIALOGS); - furi_record_close(RECORD_DESKTOP); furi_record_close(RECORD_GUI); free(app); } extern int32_t desktop_settings_app(void* p) { - UNUSED(p); - DesktopSettingsApp* app = desktop_settings_app_alloc(); Desktop* desktop = furi_record_open(RECORD_DESKTOP); desktop_api_get_settings(desktop, &app->settings); - scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneStart); + if(p && (strcmp(p, DESKTOP_SETTINGS_RUN_PIN_SETUP_ARG) == 0)) { + scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinSetupHowto); + } else { + scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneStart); + } view_dispatcher_run(app->view_dispatcher); diff --git a/applications/settings/desktop_settings/desktop_settings_app.h b/applications/settings/desktop_settings/desktop_settings_app.h index da2a5a865..cc583802d 100644 --- a/applications/settings/desktop_settings/desktop_settings_app.h +++ b/applications/settings/desktop_settings/desktop_settings_app.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include "views/desktop_settings_view_pin_setup_howto.h" #include "views/desktop_settings_view_pin_setup_howto2.h" @@ -37,7 +37,7 @@ extern const char* EXTRA_KEYBINDS[]; extern const size_t EXTRA_KEYBINDS_COUNT; typedef struct { - Desktop* desktop; + DesktopSettings settings; Gui* gui; DialogsApp* dialogs; @@ -55,8 +55,6 @@ typedef struct { bool pincode_buffer_filled; uint32_t pin_menu_idx; - - bool save_settings; } DesktopSettingsApp; const char* desktop_settings_app_get_keybind(DesktopSettingsApp* app); diff --git a/applications/settings/desktop_settings/helpers/pin.c b/applications/settings/desktop_settings/helpers/pin.c deleted file mode 100644 index 2e2791971..000000000 --- a/applications/settings/desktop_settings/helpers/pin.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/applications/settings/desktop_settings/helpers/pin_code.c b/applications/settings/desktop_settings/helpers/pin_code.c new file mode 100644 index 000000000..13e986278 --- /dev/null +++ b/applications/settings/desktop_settings/helpers/pin_code.c @@ -0,0 +1,5 @@ +// Since settings app is external, it cannot access firmware functions +// For simple utils like this, easier to include C code in app too +// Instead of copying the file, can (ab)use preprocessor to copy source code here +#include +// Then, we still use the Header from original code as if nothing happened diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_menu.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_menu.c index 8f03d8180..e0c66cb28 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_menu.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_menu.c @@ -4,7 +4,6 @@ #include "../desktop_settings_app.h" #include "desktop_settings_scene.h" #include "desktop_settings_scene_i.h" -#include "desktop/helpers/pin.h" #define SCENE_EVENT_SET_PIN 0 #define SCENE_EVENT_CHANGE_PIN 1 diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_done.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_done.c index 0f145a64e..aa3d2214e 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_done.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_pin_setup_done.c @@ -49,8 +49,6 @@ bool desktop_settings_scene_pin_setup_done_on_event(void* context, SceneManagerE if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { case SCENE_EVENT_DONE: { - memcpy(&app->desktop->settings.pin_code, &app->pincode_buffer, sizeof(PinCode)); - app->save_settings = true; bool scene_found = false; scene_found = scene_manager_search_and_switch_to_previous_scene( app->scene_manager, DesktopSettingsAppScenePinMenu); diff --git a/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c b/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c index cc331e586..62ef77037 100644 --- a/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c +++ b/applications/settings/desktop_settings/scenes/desktop_settings_scene_start.c @@ -4,16 +4,16 @@ #include "../desktop_settings_app.h" #include "desktop_settings_scene.h" -enum VarItemListIndex { - VarItemListIndexKeybinds, - VarItemListIndexResetKeybinds, - VarItemListIndexPinSetup, - VarItemListIndexAutoLockTime, - VarItemListIndexAutoLockPin, -}; +typedef enum { + DesktopSettingsPinSetup = 0, + DesktopSettingsKeybindSetup, + DesktopSettingsResetKeybinds, + DesktopSettingsAutoLockDelay, + DesktopSettingsAutoLockPin, +} DesktopSettingsEntry; #define AUTO_LOCK_DELAY_COUNT 9 -const char* const auto_lock_delay_text[AUTO_LOCK_DELAY_COUNT] = { +static const char* const auto_lock_delay_text[AUTO_LOCK_DELAY_COUNT] = { "OFF", "10s", "15s", @@ -24,7 +24,7 @@ const char* const auto_lock_delay_text[AUTO_LOCK_DELAY_COUNT] = { "5min", "10min", }; -const uint32_t auto_lock_delay_value[AUTO_LOCK_DELAY_COUNT] = +static const uint32_t auto_lock_delay_value[AUTO_LOCK_DELAY_COUNT] = {0, 10000, 15000, 30000, 60000, 90000, 120000, 300000, 600000}; static void desktop_settings_scene_start_var_list_enter_callback(void* context, uint32_t index) { @@ -37,8 +37,7 @@ static void desktop_settings_scene_start_auto_lock_delay_changed(VariableItem* i uint8_t index = variable_item_get_current_value_index(item); variable_item_set_current_value_text(item, auto_lock_delay_text[index]); - app->desktop->settings.auto_lock_delay_ms = auto_lock_delay_value[index]; - app->save_settings = true; + app->settings.auto_lock_delay_ms = auto_lock_delay_value[index]; } static void desktop_settings_scene_start_auto_lock_pin_changed(VariableItem* item) { @@ -46,8 +45,7 @@ static void desktop_settings_scene_start_auto_lock_pin_changed(VariableItem* ite uint8_t value = variable_item_get_current_value_index(item); variable_item_set_current_value_text(item, value ? "ON" : "OFF"); - app->desktop->settings.auto_lock_with_pin = value; - app->save_settings = true; + app->settings.auto_lock_with_pin = value; } void desktop_settings_scene_start_on_enter(void* context) { @@ -57,12 +55,12 @@ void desktop_settings_scene_start_on_enter(void* context) { VariableItem* item; uint8_t value_index; + variable_item_list_add(variable_item_list, "PIN Setup", 1, NULL, NULL); + variable_item_list_add(variable_item_list, "Keybinds Setup", 1, NULL, NULL); variable_item_list_add(variable_item_list, "Reset Keybinds to Default", 1, NULL, NULL); - variable_item_list_add(variable_item_list, "PIN Setup", 1, NULL, NULL); - item = variable_item_list_add( variable_item_list, "Auto Lock Time", @@ -71,7 +69,7 @@ void desktop_settings_scene_start_on_enter(void* context) { app); value_index = value_index_uint32( - app->desktop->settings.auto_lock_delay_ms, auto_lock_delay_value, AUTO_LOCK_DELAY_COUNT); + app->settings.auto_lock_delay_ms, auto_lock_delay_value, AUTO_LOCK_DELAY_COUNT); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, auto_lock_delay_text[value_index]); @@ -82,9 +80,8 @@ void desktop_settings_scene_start_on_enter(void* context) { desktop_settings_scene_start_auto_lock_pin_changed, app); - variable_item_set_current_value_index(item, app->desktop->settings.auto_lock_with_pin); - variable_item_set_current_value_text( - item, app->desktop->settings.auto_lock_with_pin ? "ON" : "OFF"); + 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); @@ -98,23 +95,28 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case VarItemListIndexKeybinds: + case DesktopSettingsPinSetup: + scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinMenu); + break; + + case DesktopSettingsKeybindSetup: scene_manager_set_scene_state( app->scene_manager, DesktopSettingsAppSceneKeybindsType, 0); scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneKeybindsType); consumed = true; break; - case VarItemListIndexResetKeybinds: + + case DesktopSettingsResetKeybinds: scene_manager_set_scene_state( app->scene_manager, DesktopSettingsAppSceneKeybindsType, 0); scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneKeybindsReset); consumed = true; break; - case VarItemListIndexPinSetup: - scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinMenu); - consumed = true; + + default: break; } + consumed = true; } return consumed; } diff --git a/applications/settings/desktop_settings/views/desktop_view_pin_input.c b/applications/settings/desktop_settings/views/desktop_view_pin_input.c index 56ed98f53..5f6c74c68 100644 --- a/applications/settings/desktop_settings/views/desktop_view_pin_input.c +++ b/applications/settings/desktop_settings/views/desktop_view_pin_input.c @@ -1 +1,5 @@ +// Since settings app is external, it cannot access firmware functions +// For simple utils like this, easier to include C code in app too +// Instead of copying the file, can (ab)use preprocessor to copy source code here #include +// Then, we still use the Header from original code as if nothing happened diff --git a/applications/settings/power_settings_app/about.c b/applications/settings/power_settings_app/about.c index d33248c4f..964fc654f 100644 --- a/applications/settings/power_settings_app/about.c +++ b/applications/settings/power_settings_app/about.c @@ -1 +1,5 @@ +// Since settings app is external, it cannot access firmware functions +// For simple utils like this, easier to include C code in app too +// Instead of copying the file, can (ab)use preprocessor to copy source code here #include +// Then, we still use the Header from original code as if nothing happened