mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-10 05:59:08 -07:00
Loader pick all menu apps from file
This commit is contained in:
@@ -24,7 +24,7 @@ static void xtreme_app_scene_interface_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_app_names, app->mainmenu_app_index));
|
||||
item, *CharList_get(app->mainmenu_app_labels, app->mainmenu_app_index));
|
||||
}
|
||||
|
||||
void xtreme_app_scene_interface_mainmenu_on_enter(void* context) {
|
||||
@@ -42,14 +42,14 @@ void xtreme_app_scene_interface_mainmenu_on_enter(void* context) {
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
"App",
|
||||
CharList_size(app->mainmenu_app_names),
|
||||
CharList_size(app->mainmenu_app_labels),
|
||||
xtreme_app_scene_interface_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_app_names)) {
|
||||
if(CharList_size(app->mainmenu_app_labels)) {
|
||||
variable_item_set_current_value_text(
|
||||
item, *CharList_get(app->mainmenu_app_names, app->mainmenu_app_index));
|
||||
item, *CharList_get(app->mainmenu_app_labels, app->mainmenu_app_index));
|
||||
} else {
|
||||
variable_item_set_current_value_text(item, "None");
|
||||
}
|
||||
@@ -78,12 +78,12 @@ bool xtreme_app_scene_interface_mainmenu_on_event(void* context, SceneManagerEve
|
||||
consumed = true;
|
||||
switch(event.event) {
|
||||
case VarItemListIndexRemoveApp:
|
||||
if(!CharList_size(app->mainmenu_app_names)) break;
|
||||
if(!CharList_size(app->mainmenu_app_paths)) break;
|
||||
if(!CharList_size(app->mainmenu_app_labels)) break;
|
||||
if(!CharList_size(app->mainmenu_app_exes)) break;
|
||||
CharList_remove_v(
|
||||
app->mainmenu_app_names, app->mainmenu_app_index, app->mainmenu_app_index + 1);
|
||||
app->mainmenu_app_labels, app->mainmenu_app_index, app->mainmenu_app_index + 1);
|
||||
CharList_remove_v(
|
||||
app->mainmenu_app_paths, app->mainmenu_app_index, app->mainmenu_app_index + 1);
|
||||
app->mainmenu_app_exes, 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);
|
||||
|
||||
@@ -30,11 +30,11 @@ void xtreme_app_scene_interface_mainmenu_add_on_enter(void* context) {
|
||||
};
|
||||
|
||||
if(dialog_file_browser_show(app->dialogs, string, string, &browser_options)) {
|
||||
CharList_push_back(app->mainmenu_app_paths, strdup(furi_string_get_cstr(string)));
|
||||
CharList_push_back(app->mainmenu_app_exes, strdup(furi_string_get_cstr(string)));
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
flipper_application_load_name_and_icon(string, storage, NULL, string);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
CharList_push_back(app->mainmenu_app_names, strdup(furi_string_get_cstr(string)));
|
||||
CharList_push_back(app->mainmenu_app_labels, strdup(furi_string_get_cstr(string)));
|
||||
app->save_mainmenu_apps = true;
|
||||
app->require_reboot = true;
|
||||
}
|
||||
|
||||
@@ -16,11 +16,12 @@ bool xtreme_app_apply(XtremeApp* app) {
|
||||
|
||||
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)) {
|
||||
if(file_stream_open(stream, XTREME_MENU_PATH, FSAM_READ_WRITE, FSOM_CREATE_ALWAYS)) {
|
||||
stream_write_format(stream, "MenuAppList Version %u\n", 0);
|
||||
CharList_it_t it;
|
||||
CharList_it(it, app->mainmenu_app_paths);
|
||||
for(size_t i = 0; i < CharList_size(app->mainmenu_app_paths); i++) {
|
||||
stream_write_format(stream, "%s\n", *CharList_get(app->mainmenu_app_paths, i));
|
||||
CharList_it(it, app->mainmenu_app_exes);
|
||||
for(size_t i = 0; i < CharList_size(app->mainmenu_app_exes); i++) {
|
||||
stream_write_format(stream, "%s\n", *CharList_get(app->mainmenu_app_exes, i));
|
||||
}
|
||||
}
|
||||
file_stream_close(stream);
|
||||
@@ -227,17 +228,18 @@ XtremeApp* xtreme_app_alloc() {
|
||||
free(name);
|
||||
storage_file_free(folder);
|
||||
|
||||
CharList_init(app->mainmenu_app_names);
|
||||
CharList_init(app->mainmenu_app_paths);
|
||||
CharList_init(app->mainmenu_app_labels);
|
||||
CharList_init(app->mainmenu_app_exes);
|
||||
Stream* stream = file_stream_alloc(storage);
|
||||
FuriString* line = furi_string_alloc();
|
||||
if(file_stream_open(stream, XTREME_APPS_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
if(file_stream_open(stream, XTREME_MENU_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
stream_read_line(stream, line);
|
||||
while(stream_read_line(stream, line)) {
|
||||
furi_string_replace_all(line, "\r", "");
|
||||
furi_string_replace_all(line, "\n", "");
|
||||
CharList_push_back(app->mainmenu_app_paths, strdup(furi_string_get_cstr(line)));
|
||||
CharList_push_back(app->mainmenu_app_exes, strdup(furi_string_get_cstr(line)));
|
||||
flipper_application_load_name_and_icon(line, storage, NULL, line);
|
||||
CharList_push_back(app->mainmenu_app_names, strdup(furi_string_get_cstr(line)));
|
||||
CharList_push_back(app->mainmenu_app_labels, strdup(furi_string_get_cstr(line)));
|
||||
}
|
||||
}
|
||||
furi_string_free(line);
|
||||
@@ -314,14 +316,14 @@ void xtreme_app_free(XtremeApp* app) {
|
||||
}
|
||||
CharList_clear(app->asset_pack_names);
|
||||
|
||||
for(CharList_it(it, app->mainmenu_app_names); !CharList_end_p(it); CharList_next(it)) {
|
||||
for(CharList_it(it, app->mainmenu_app_labels); !CharList_end_p(it); CharList_next(it)) {
|
||||
free(*CharList_cref(it));
|
||||
}
|
||||
CharList_clear(app->mainmenu_app_names);
|
||||
for(CharList_it(it, app->mainmenu_app_paths); !CharList_end_p(it); CharList_next(it)) {
|
||||
CharList_clear(app->mainmenu_app_labels);
|
||||
for(CharList_it(it, app->mainmenu_app_exes); !CharList_end_p(it); CharList_next(it)) {
|
||||
free(*CharList_cref(it));
|
||||
}
|
||||
CharList_clear(app->mainmenu_app_paths);
|
||||
CharList_clear(app->mainmenu_app_exes);
|
||||
|
||||
FrequencyList_clear(app->subghz_static_freqs);
|
||||
FrequencyList_clear(app->subghz_hopper_freqs);
|
||||
|
||||
@@ -42,8 +42,8 @@ typedef struct {
|
||||
|
||||
CharList_t asset_pack_names;
|
||||
uint8_t asset_pack_index;
|
||||
CharList_t mainmenu_app_names;
|
||||
CharList_t mainmenu_app_paths;
|
||||
CharList_t mainmenu_app_labels;
|
||||
CharList_t mainmenu_app_exes;
|
||||
uint8_t mainmenu_app_index;
|
||||
bool subghz_use_defaults;
|
||||
FrequencyList_t subghz_static_freqs;
|
||||
|
||||
Reference in New Issue
Block a user