diff --git a/applications/main/xtreme_app/scenes/xtreme_app_scene_start.c b/applications/main/xtreme_app/scenes/xtreme_app_scene_start.c index c6a776edc..9b3179a0e 100644 --- a/applications/main/xtreme_app/scenes/xtreme_app_scene_start.c +++ b/applications/main/xtreme_app/scenes/xtreme_app_scene_start.c @@ -47,6 +47,13 @@ bool xtreme_app_scene_start_on_event(void* context, SceneManagerEvent event) { case VarItemListIndexMisc: scene_manager_next_scene(app->scene_manager, XtremeAppSceneMisc); break; + case VarItemListIndexVersion: { + if(storage_common_copy(furi_record_open(RECORD_STORAGE), EXT_PATH("dolphin/xfwfirstboot.bin"), EXT_PATH(".slideshow"))) { + app->show_slideshow = true; + xtreme_app_apply(app); + } + break; + } default: break; } diff --git a/applications/main/xtreme_app/xtreme_app.c b/applications/main/xtreme_app/xtreme_app.c index 68d017d40..6ae904d77 100644 --- a/applications/main/xtreme_app/xtreme_app.c +++ b/applications/main/xtreme_app/xtreme_app.c @@ -11,129 +11,140 @@ void callback_reboot(void* context) { power_reboot(PowerBootModeNormal); } +bool xtreme_app_apply(XtremeApp* app) { + Storage* storage = furi_record_open(RECORD_STORAGE); + + if(app->save_mainmenu_apps) { + Stream* stream = file_stream_alloc(storage); + if(file_stream_open(stream, XTREME_APPS_PATH, FSAM_READ_WRITE, FSOM_CREATE_ALWAYS)) { + CharList_it_t it; + CharList_it(it, app->mainmenu_app_paths); + for(uint i = 0; i < CharList_size(app->mainmenu_app_paths); i++) { + stream_write_format(stream, "%s\n", *CharList_get(app->mainmenu_app_paths, i)); + } + } + file_stream_close(stream); + stream_free(stream); + } + + if(app->save_subghz_frequencies) { + FlipperFormat* file = flipper_format_file_alloc(storage); + do { + FrequencyList_it_t it; + if(!flipper_format_file_open_always(file, EXT_PATH("subghz/assets/setting_user"))) + break; + + if(!flipper_format_write_header_cstr( + file, SUBGHZ_SETTING_FILE_TYPE, SUBGHZ_SETTING_FILE_VERSION)) + break; + + while(flipper_format_delete_key(file, "Add_standard_frequencies")) + ; + flipper_format_write_bool( + file, "Add_standard_frequencies", &app->subghz_use_defaults, 1); + + if(!flipper_format_rewind(file)) break; + while(flipper_format_delete_key(file, "Frequency")) + ; + FrequencyList_it(it, app->subghz_static_freqs); + for(uint i = 0; i < FrequencyList_size(app->subghz_static_freqs); i++) { + flipper_format_write_uint32( + file, "Frequency", FrequencyList_get(app->subghz_static_freqs, i), 1); + } + + if(!flipper_format_rewind(file)) break; + while(flipper_format_delete_key(file, "Hopper_frequency")) + ; + for(uint i = 0; i < FrequencyList_size(app->subghz_hopper_freqs); i++) { + flipper_format_write_uint32( + file, + "Hopper_frequency", + FrequencyList_get(app->subghz_hopper_freqs, i), + 1); + } + } while(false); + flipper_format_free(file); + } + + if(app->save_subghz) { + furi_hal_subghz_set_extend_settings(app->subghz_extend, app->subghz_bypass); + } + + if(app->save_name) { + if(strcmp(app->device_name, "") == 0) { + storage_simply_remove(storage, NAMECHANGER_PATH); + } else { + FlipperFormat* file = flipper_format_file_alloc(storage); + + do { + if(!flipper_format_file_open_always(file, NAMECHANGER_PATH)) break; + + if(!flipper_format_write_header_cstr(file, NAMECHANGER_HEADER, 1)) break; + + if(!flipper_format_write_comment_cstr( + file, + "Changing the value below will change your FlipperZero device name.")) + break; + if(!flipper_format_write_comment_cstr( + file, + "Note: This is limited to 8 characters using the following: a-z, A-Z, 0-9, and _")) + break; + if(!flipper_format_write_comment_cstr( + file, "It cannot contain any other characters.")) + break; + + if(!flipper_format_write_string_cstr(file, "Name", app->device_name)) break; + + } while(0); + + flipper_format_free(file); + } + } + + if(app->save_level) { + Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN); + int32_t xp = app->xp_level > 1 ? dolphin_get_levels()[app->xp_level - 2] : 0; + dolphin->state->data.icounter = xp + 1; + dolphin->state->dirty = true; + dolphin_state_save(dolphin->state); + furi_record_close(RECORD_DOLPHIN); + } + + if(app->save_backlight) { + rgb_backlight_save_settings(); + } + + if(app->save_settings) { + XTREME_SETTINGS_SAVE(); + } + + if(app->show_slideshow) { + callback_reboot(NULL); + } + + if(app->require_reboot) { + popup_set_header(app->popup, "Rebooting...", 64, 26, AlignCenter, AlignCenter); + popup_set_text(app->popup, "Applying changes...", 64, 40, AlignCenter, AlignCenter); + popup_set_callback(app->popup, callback_reboot); + popup_set_context(app->popup, app); + popup_set_timeout(app->popup, 1000); + popup_enable_timeout(app->popup); + view_dispatcher_switch_to_view(app->view_dispatcher, XtremeAppViewPopup); + return true; + } + + furi_record_close(RECORD_STORAGE); + return false; +} + static bool xtreme_app_back_event_callback(void* context) { furi_assert(context); XtremeApp* app = context; if(!scene_manager_has_previous_scene(app->scene_manager, XtremeAppSceneStart)) { - Storage* storage = furi_record_open(RECORD_STORAGE); - - if(app->save_mainmenu_apps) { - Stream* stream = file_stream_alloc(storage); - if(file_stream_open(stream, XTREME_APPS_PATH, FSAM_READ_WRITE, FSOM_CREATE_ALWAYS)) { - CharList_it_t it; - CharList_it(it, app->mainmenu_app_paths); - for(uint i = 0; i < CharList_size(app->mainmenu_app_paths); i++) { - stream_write_format(stream, "%s\n", *CharList_get(app->mainmenu_app_paths, i)); - } - } - file_stream_close(stream); - stream_free(stream); - } - - if(app->save_subghz_frequencies) { - FlipperFormat* file = flipper_format_file_alloc(storage); - do { - FrequencyList_it_t it; - if(!flipper_format_file_open_always(file, EXT_PATH("subghz/assets/setting_user"))) - break; - - if(!flipper_format_write_header_cstr( - file, SUBGHZ_SETTING_FILE_TYPE, SUBGHZ_SETTING_FILE_VERSION)) - break; - - while(flipper_format_delete_key(file, "Add_standard_frequencies")) - ; - flipper_format_write_bool( - file, "Add_standard_frequencies", &app->subghz_use_defaults, 1); - - if(!flipper_format_rewind(file)) break; - while(flipper_format_delete_key(file, "Frequency")) - ; - FrequencyList_it(it, app->subghz_static_freqs); - for(uint i = 0; i < FrequencyList_size(app->subghz_static_freqs); i++) { - flipper_format_write_uint32( - file, "Frequency", FrequencyList_get(app->subghz_static_freqs, i), 1); - } - - if(!flipper_format_rewind(file)) break; - while(flipper_format_delete_key(file, "Hopper_frequency")) - ; - for(uint i = 0; i < FrequencyList_size(app->subghz_hopper_freqs); i++) { - flipper_format_write_uint32( - file, - "Hopper_frequency", - FrequencyList_get(app->subghz_hopper_freqs, i), - 1); - } - } while(false); - flipper_format_free(file); - } - - if(app->save_subghz) { - furi_hal_subghz_set_extend_settings(app->subghz_extend, app->subghz_bypass); - } - - if(app->save_name) { - if(strcmp(app->device_name, "") == 0) { - storage_simply_remove(storage, NAMECHANGER_PATH); - } else { - FlipperFormat* file = flipper_format_file_alloc(storage); - - do { - if(!flipper_format_file_open_always(file, NAMECHANGER_PATH)) break; - - if(!flipper_format_write_header_cstr(file, NAMECHANGER_HEADER, 1)) break; - - if(!flipper_format_write_comment_cstr( - file, - "Changing the value below will change your FlipperZero device name.")) - break; - if(!flipper_format_write_comment_cstr( - file, - "Note: This is limited to 8 characters using the following: a-z, A-Z, 0-9, and _")) - break; - if(!flipper_format_write_comment_cstr( - file, "It cannot contain any other characters.")) - break; - - if(!flipper_format_write_string_cstr(file, "Name", app->device_name)) break; - - } while(0); - - flipper_format_free(file); - } - } - - if(app->save_level) { - Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN); - int32_t xp = app->xp_level > 1 ? dolphin_get_levels()[app->xp_level - 2] : 0; - dolphin->state->data.icounter = xp + 1; - dolphin->state->dirty = true; - dolphin_state_save(dolphin->state); - furi_record_close(RECORD_DOLPHIN); - } - - if(app->save_backlight) { - rgb_backlight_save_settings(); - } - - if(app->save_settings) { - XTREME_SETTINGS_SAVE(); - } - - if(app->require_reboot) { - popup_set_header(app->popup, "Rebooting...", 64, 26, AlignCenter, AlignCenter); - popup_set_text(app->popup, "Applying changes...", 64, 40, AlignCenter, AlignCenter); - popup_set_callback(app->popup, callback_reboot); - popup_set_context(app->popup, app); - popup_set_timeout(app->popup, 1000); - popup_enable_timeout(app->popup); - view_dispatcher_switch_to_view(app->view_dispatcher, XtremeAppViewPopup); + if(xtreme_app_apply(app)) { return true; } - - furi_record_close(RECORD_STORAGE); } return scene_manager_handle_back_event(app->scene_manager); diff --git a/applications/main/xtreme_app/xtreme_app.h b/applications/main/xtreme_app/xtreme_app.h index c8eab0150..759afd769 100644 --- a/applications/main/xtreme_app/xtreme_app.h +++ b/applications/main/xtreme_app/xtreme_app.h @@ -65,6 +65,7 @@ typedef struct { bool save_level; bool save_backlight; bool save_settings; + bool show_slideshow; bool require_reboot; } XtremeApp; @@ -73,3 +74,5 @@ typedef enum { XtremeAppViewTextInput, XtremeAppViewPopup, } XtremeAppView; + +bool xtreme_app_apply(XtremeApp* app); diff --git a/scripts/update.py b/scripts/update.py index d1c59c6b5..bf8c24e14 100755 --- a/scripts/update.py +++ b/scripts/update.py @@ -126,6 +126,14 @@ class Main(App): ) if self.args.resources: resources_basename = self.RESOURCE_FILE_NAME + SlideshowMain(no_exit=True)( + [ + "-i", + str(pathlib.Path(self.args.resources).parent / "slideshow/xfwfirstboot"), + "-o", + str(pathlib.Path(self.args.resources) / "dolphin/xfwfirstboot.bin"), + ] + ) if not self.package_resources( self.args.resources, join(self.args.directory, resources_basename) ):