diff --git a/applications/main/xtreme_app/scenes/xtreme_app_scene_mainmenu.c b/applications/main/xtreme_app/scenes/xtreme_app_scene_mainmenu.c index 01f3afb06..a085fb0ea 100644 --- a/applications/main/xtreme_app/scenes/xtreme_app_scene_mainmenu.c +++ b/applications/main/xtreme_app/scenes/xtreme_app_scene_mainmenu.c @@ -16,7 +16,7 @@ void xtreme_app_scene_mainmenu_var_item_list_callback( static void xtreme_app_scene_mainmenu_app_changed(VariableItem* item) { XtremeApp* app = variable_item_get_context(item); app->mainmenu_app_index = variable_item_get_current_value_index(item); - variable_item_set_current_value_text(item, *CharList_get(app->mainmenu_apps, app->mainmenu_app_index)); + variable_item_set_current_value_text(item, *CharList_get(app->mainmenu_apps_names, app->mainmenu_app_index)); } void xtreme_app_scene_mainmenu_on_enter(void* context) { @@ -27,13 +27,13 @@ void xtreme_app_scene_mainmenu_on_enter(void* context) { item = variable_item_list_add( var_item_list, "App", - CharList_size(app->mainmenu_apps), + CharList_size(app->mainmenu_apps_names), xtreme_app_scene_mainmenu_app_changed, app); app->mainmenu_app_index = 0; variable_item_set_current_value_index(item, app->mainmenu_app_index); - if(CharList_size(app->mainmenu_apps)) { - variable_item_set_current_value_text(item, *CharList_get(app->mainmenu_apps, app->mainmenu_app_index)); + if(CharList_size(app->mainmenu_apps_names)) { + variable_item_set_current_value_text(item, *CharList_get(app->mainmenu_apps_names, app->mainmenu_app_index)); } else { variable_item_set_current_value_text(item, "None"); } @@ -63,19 +63,12 @@ bool xtreme_app_scene_mainmenu_on_event(void* context, SceneManagerEvent event) consumed = true; switch(event.event) { case VarItemListIndexRemoveApp: - if(!CharList_size(app->mainmenu_apps)) break; - char* value = - *CharList_get(app->mainmenu_apps, app->mainmenu_app_index); - CharList_it_t it; - CharList_it(it, app->mainmenu_apps); - while(!CharList_end_p(it)) { - if(strcmp(*CharList_ref(it), value) == 0) { - CharList_remove(app->mainmenu_apps, it); - } else { - CharList_next(it); - } - } + if(!CharList_size(app->mainmenu_apps_names)) break; + if(!CharList_size(app->mainmenu_apps_paths)) break; + CharList_remove_v(app->mainmenu_apps_names, app->mainmenu_app_index, app->mainmenu_app_index + 1); + CharList_remove_v(app->mainmenu_apps_paths, app->mainmenu_app_index, app->mainmenu_app_index + 1); app->save_mainmenu_apps = true; + app->require_reboot = true; scene_manager_previous_scene(app->scene_manager); scene_manager_next_scene(app->scene_manager, XtremeAppSceneMainmenu); break; diff --git a/applications/main/xtreme_app/scenes/xtreme_app_scene_mainmenu_add.c b/applications/main/xtreme_app/scenes/xtreme_app_scene_mainmenu_add.c index 7865a84a0..af8733e97 100644 --- a/applications/main/xtreme_app/scenes/xtreme_app_scene_mainmenu_add.c +++ b/applications/main/xtreme_app/scenes/xtreme_app_scene_mainmenu_add.c @@ -10,22 +10,15 @@ static bool xtreme_app_scene_mainmenu_add_file_browser_callback( uint8_t** icon_ptr, FuriString* item_name) { UNUSED(context); -// #ifndef APP_FAP_LOADER -// Storage* storage = furi_record_open(RECORD_STORAGE); -// bool success = fap_loader_load_name_and_icon(file_path, storage, icon_ptr, item_name); -// furi_record_close(RECORD_STORAGE); -// #else - UNUSED(file_path); - UNUSED(icon_ptr); - UNUSED(item_name); - bool success = false; -// #endif + Storage* storage = furi_record_open(RECORD_STORAGE); + bool success = fap_loader_load_name_and_icon(file_path, storage, icon_ptr, item_name); + furi_record_close(RECORD_STORAGE); return success; } void xtreme_app_scene_mainmenu_add_on_enter(void* context) { XtremeApp* app = context; - FuriString* file_path = furi_string_alloc_set_str(EXT_PATH("apps")); + FuriString* string = furi_string_alloc_set_str(EXT_PATH("apps")); const DialogsFileBrowserOptions browser_options = { .extension = ".fap", @@ -36,12 +29,17 @@ void xtreme_app_scene_mainmenu_add_on_enter(void* context) { .base_path = EXT_PATH("apps"), }; - if(dialog_file_browser_show(app->dialogs, file_path, file_path, &browser_options)) { - CharList_push_back(app->mainmenu_apps, strdup(furi_string_get_cstr(file_path))); + if(dialog_file_browser_show(app->dialogs, string, string, &browser_options)) { + CharList_push_back(app->mainmenu_apps_paths, strdup(furi_string_get_cstr(string))); + Storage* storage = furi_record_open(RECORD_STORAGE); + fap_loader_load_name_and_icon(string, storage, NULL, string); + furi_record_close(RECORD_STORAGE); + CharList_push_back(app->mainmenu_apps_names, strdup(furi_string_get_cstr(string))); app->save_mainmenu_apps = true; + app->require_reboot = true; } - furi_string_free(file_path); + furi_string_free(string); view_dispatcher_send_custom_event(app->view_dispatcher, FileBrowserResultOk); } diff --git a/applications/main/xtreme_app/xtreme_app.c b/applications/main/xtreme_app/xtreme_app.c index dadb0fd43..6c639fcbc 100644 --- a/applications/main/xtreme_app/xtreme_app.c +++ b/applications/main/xtreme_app/xtreme_app.c @@ -158,44 +158,9 @@ XtremeApp* xtreme_app_alloc() { XtremeSettings* xtreme_settings = XTREME_SETTINGS(); - Storage* storage = furi_record_open(RECORD_STORAGE); - FlipperFormat* file = flipper_format_file_alloc(storage); - FrequencyList_init(app->subghz_static_frequencies); - FrequencyList_init(app->subghz_hopper_frequencies); - app->subghz_use_defaults = true; - do { - uint32_t temp; - if(!flipper_format_file_open_existing(file, EXT_PATH("subghz/assets/setting_user"))) break; - - flipper_format_read_bool(file, "Add_standard_frequencies", &app->subghz_use_defaults, 1); - - if(!flipper_format_rewind(file)) break; - while(flipper_format_read_uint32(file, "Frequency", &temp, 1)) { - if(furi_hal_subghz_is_frequency_valid(temp)) { - FrequencyList_push_back(app->subghz_static_frequencies, temp); - } - } - - if(!flipper_format_rewind(file)) break; - while(flipper_format_read_uint32(file, "Hopper_frequency", &temp, 1)) { - if(furi_hal_subghz_is_frequency_valid(temp)) { - FrequencyList_push_back(app->subghz_hopper_frequencies, temp); - } - } - } while(false); - flipper_format_free(file); - - furi_hal_subghz_get_extend_settings(&app->subghz_extend, &app->subghz_bypass); - - Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN); - DolphinStats stats = dolphin_stats(dolphin); - app->dolphin_level = stats.level; - furi_record_close(RECORD_DOLPHIN); - - strlcpy(app->device_name, furi_hal_version_get_name_ptr(), NAMECHANGER_TEXT_STORE_SIZE); - app->asset_pack = 0; CharList_init(app->asset_packs); + Storage* storage = furi_record_open(RECORD_STORAGE); File* folder = storage_file_alloc(storage); FileInfo info; char* name = malloc(MAX_PACK_NAME_LEN); @@ -224,8 +189,46 @@ XtremeApp* xtreme_app_alloc() { } free(name); storage_file_free(folder); + + CharList_init(app->mainmenu_apps_names); + CharList_init(app->mainmenu_apps_paths); + + FlipperFormat* file = flipper_format_file_alloc(storage); + FrequencyList_init(app->subghz_static_frequencies); + FrequencyList_init(app->subghz_hopper_frequencies); + app->subghz_use_defaults = true; + do { + uint32_t temp; + if(!flipper_format_file_open_existing(file, EXT_PATH("subghz/assets/setting_user"))) break; + + flipper_format_read_bool(file, "Add_standard_frequencies", &app->subghz_use_defaults, 1); + + if(!flipper_format_rewind(file)) break; + while(flipper_format_read_uint32(file, "Frequency", &temp, 1)) { + if(furi_hal_subghz_is_frequency_valid(temp)) { + FrequencyList_push_back(app->subghz_static_frequencies, temp); + } + } + + if(!flipper_format_rewind(file)) break; + while(flipper_format_read_uint32(file, "Hopper_frequency", &temp, 1)) { + if(furi_hal_subghz_is_frequency_valid(temp)) { + FrequencyList_push_back(app->subghz_hopper_frequencies, temp); + } + } + } while(false); + flipper_format_free(file); furi_record_close(RECORD_STORAGE); + furi_hal_subghz_get_extend_settings(&app->subghz_extend, &app->subghz_bypass); + + Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN); + DolphinStats stats = dolphin_stats(dolphin); + app->dolphin_level = stats.level; + furi_record_close(RECORD_DOLPHIN); + + strlcpy(app->device_name, furi_hal_version_get_name_ptr(), NAMECHANGER_TEXT_STORE_SIZE); + app->version_tag = furi_string_alloc_printf("%s %s", version_get_version(NULL), version_get_builddate(NULL)); @@ -249,14 +252,22 @@ void xtreme_app_free(XtremeApp* app) { // Settings deinit - FrequencyList_clear(app->subghz_static_frequencies); - FrequencyList_clear(app->subghz_hopper_frequencies); - CharList_it_t it; for(CharList_it(it, app->asset_packs); !CharList_end_p(it); CharList_next(it)) { free(*CharList_cref(it)); } CharList_clear(app->asset_packs); + for(CharList_it(it, app->mainmenu_apps_names); !CharList_end_p(it); CharList_next(it)) { + free(*CharList_cref(it)); + } + CharList_clear(app->mainmenu_apps_names); + for(CharList_it(it, app->mainmenu_apps_paths); !CharList_end_p(it); CharList_next(it)) { + free(*CharList_cref(it)); + } + CharList_clear(app->mainmenu_apps_paths); + + FrequencyList_clear(app->subghz_static_frequencies); + FrequencyList_clear(app->subghz_hopper_frequencies); furi_string_free(app->version_tag); diff --git a/applications/main/xtreme_app/xtreme_app.h b/applications/main/xtreme_app/xtreme_app.h index 4f6c6ee4c..ddb7c3879 100644 --- a/applications/main/xtreme_app/xtreme_app.h +++ b/applications/main/xtreme_app/xtreme_app.h @@ -18,6 +18,7 @@ #include "dolphin/dolphin_i.h" #include #include +#include #include #include "xtreme/settings.h" #include "xtreme/assets.h" @@ -36,7 +37,8 @@ typedef struct { Popup* popup; uint asset_pack; CharList_t asset_packs; - CharList_t mainmenu_apps; + CharList_t mainmenu_apps_names; + CharList_t mainmenu_apps_paths; uint8_t mainmenu_app_index; bool subghz_use_defaults; FrequencyList_t subghz_static_frequencies;