mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-16 04:24:45 -07:00
Xfw custom app manager actually save and load list
This commit is contained in:
@@ -18,6 +18,19 @@ static bool xtreme_app_back_event_callback(void* 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_apps_paths);
|
||||
for(uint i = 0; i < CharList_size(app->mainmenu_apps_paths); i++) {
|
||||
stream_write_format(stream, "%s\n", *CharList_get(app->mainmenu_apps_paths, i));
|
||||
}
|
||||
}
|
||||
file_stream_close(stream);
|
||||
stream_free(stream);
|
||||
}
|
||||
|
||||
if(app->save_subghz) {
|
||||
furi_hal_subghz_set_extend_settings(app->subghz_extend, app->subghz_bypass);
|
||||
}
|
||||
@@ -192,6 +205,20 @@ XtremeApp* xtreme_app_alloc() {
|
||||
|
||||
CharList_init(app->mainmenu_apps_names);
|
||||
CharList_init(app->mainmenu_apps_paths);
|
||||
Stream* stream = file_stream_alloc(storage);
|
||||
FuriString* line = furi_string_alloc();
|
||||
if(file_stream_open(stream, XTREME_APPS_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
while(stream_read_line(stream, line)) {
|
||||
furi_string_replace_all(line, "\r", "");
|
||||
furi_string_replace_all(line, "\n", "");
|
||||
CharList_push_back(app->mainmenu_apps_paths, strdup(furi_string_get_cstr(line)));
|
||||
fap_loader_load_name_and_icon(line, storage, NULL, line);
|
||||
CharList_push_back(app->mainmenu_apps_names, strdup(furi_string_get_cstr(line)));
|
||||
}
|
||||
}
|
||||
furi_string_free(line);
|
||||
file_stream_close(stream);
|
||||
stream_free(stream);
|
||||
|
||||
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||
FrequencyList_init(app->subghz_static_frequencies);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <gui/modules/text_input.h>
|
||||
#include <gui/modules/popup.h>
|
||||
#include <lib/toolbox/value_index.h>
|
||||
#include <toolbox/stream/file_stream.h>
|
||||
#include <namechangersrv/namechangersrv.h>
|
||||
#include "scenes/xtreme_app_scene.h"
|
||||
#include "dolphin/helpers/dolphin_state.h"
|
||||
|
||||
@@ -20,6 +20,8 @@ extern "C" {
|
||||
#define XTREME_SETTINGS_PATH EXT_PATH(XTREME_SETTINGS_FILE_NAME)
|
||||
#define XTREME_SETTINGS_MAGIC (0x69)
|
||||
|
||||
#define XTREME_APPS_PATH EXT_PATH(XTREME_APPS_FILE_NAME)
|
||||
|
||||
// Some settings function backwards (logically) in
|
||||
// order to fit the default value we want
|
||||
// (values will default to 0 / false)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#define XTREME_SETTINGS_FILE_NAME ".xtreme.settings"
|
||||
#define XTREME_APPS_FILE_NAME ".xtreme_apps.txt"
|
||||
|
||||
Reference in New Issue
Block a user