mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-15 04:19:26 -07:00
Xfw custom app manager improvements
This commit is contained in:
@@ -16,7 +16,7 @@ void xtreme_app_scene_mainmenu_var_item_list_callback(
|
|||||||
static void xtreme_app_scene_mainmenu_app_changed(VariableItem* item) {
|
static void xtreme_app_scene_mainmenu_app_changed(VariableItem* item) {
|
||||||
XtremeApp* app = variable_item_get_context(item);
|
XtremeApp* app = variable_item_get_context(item);
|
||||||
app->mainmenu_app_index = variable_item_get_current_value_index(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) {
|
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(
|
item = variable_item_list_add(
|
||||||
var_item_list,
|
var_item_list,
|
||||||
"App",
|
"App",
|
||||||
CharList_size(app->mainmenu_apps),
|
CharList_size(app->mainmenu_apps_names),
|
||||||
xtreme_app_scene_mainmenu_app_changed,
|
xtreme_app_scene_mainmenu_app_changed,
|
||||||
app);
|
app);
|
||||||
app->mainmenu_app_index = 0;
|
app->mainmenu_app_index = 0;
|
||||||
variable_item_set_current_value_index(item, app->mainmenu_app_index);
|
variable_item_set_current_value_index(item, app->mainmenu_app_index);
|
||||||
if(CharList_size(app->mainmenu_apps)) {
|
if(CharList_size(app->mainmenu_apps_names)) {
|
||||||
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));
|
||||||
} else {
|
} else {
|
||||||
variable_item_set_current_value_text(item, "None");
|
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;
|
consumed = true;
|
||||||
switch(event.event) {
|
switch(event.event) {
|
||||||
case VarItemListIndexRemoveApp:
|
case VarItemListIndexRemoveApp:
|
||||||
if(!CharList_size(app->mainmenu_apps)) break;
|
if(!CharList_size(app->mainmenu_apps_names)) break;
|
||||||
char* value =
|
if(!CharList_size(app->mainmenu_apps_paths)) break;
|
||||||
*CharList_get(app->mainmenu_apps, app->mainmenu_app_index);
|
CharList_remove_v(app->mainmenu_apps_names, app->mainmenu_app_index, app->mainmenu_app_index + 1);
|
||||||
CharList_it_t it;
|
CharList_remove_v(app->mainmenu_apps_paths, app->mainmenu_app_index, app->mainmenu_app_index + 1);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
app->save_mainmenu_apps = true;
|
app->save_mainmenu_apps = true;
|
||||||
|
app->require_reboot = true;
|
||||||
scene_manager_previous_scene(app->scene_manager);
|
scene_manager_previous_scene(app->scene_manager);
|
||||||
scene_manager_next_scene(app->scene_manager, XtremeAppSceneMainmenu);
|
scene_manager_next_scene(app->scene_manager, XtremeAppSceneMainmenu);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -10,22 +10,15 @@ static bool xtreme_app_scene_mainmenu_add_file_browser_callback(
|
|||||||
uint8_t** icon_ptr,
|
uint8_t** icon_ptr,
|
||||||
FuriString* item_name) {
|
FuriString* item_name) {
|
||||||
UNUSED(context);
|
UNUSED(context);
|
||||||
// #ifndef APP_FAP_LOADER
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||||
// Storage* storage = furi_record_open(RECORD_STORAGE);
|
bool success = fap_loader_load_name_and_icon(file_path, storage, icon_ptr, item_name);
|
||||||
// bool success = fap_loader_load_name_and_icon(file_path, storage, icon_ptr, item_name);
|
furi_record_close(RECORD_STORAGE);
|
||||||
// furi_record_close(RECORD_STORAGE);
|
|
||||||
// #else
|
|
||||||
UNUSED(file_path);
|
|
||||||
UNUSED(icon_ptr);
|
|
||||||
UNUSED(item_name);
|
|
||||||
bool success = false;
|
|
||||||
// #endif
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void xtreme_app_scene_mainmenu_add_on_enter(void* context) {
|
void xtreme_app_scene_mainmenu_add_on_enter(void* context) {
|
||||||
XtremeApp* app = 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 = {
|
const DialogsFileBrowserOptions browser_options = {
|
||||||
.extension = ".fap",
|
.extension = ".fap",
|
||||||
@@ -36,12 +29,17 @@ void xtreme_app_scene_mainmenu_add_on_enter(void* context) {
|
|||||||
.base_path = EXT_PATH("apps"),
|
.base_path = EXT_PATH("apps"),
|
||||||
};
|
};
|
||||||
|
|
||||||
if(dialog_file_browser_show(app->dialogs, file_path, file_path, &browser_options)) {
|
if(dialog_file_browser_show(app->dialogs, string, string, &browser_options)) {
|
||||||
CharList_push_back(app->mainmenu_apps, strdup(furi_string_get_cstr(file_path)));
|
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->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);
|
view_dispatcher_send_custom_event(app->view_dispatcher, FileBrowserResultOk);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,44 +158,9 @@ XtremeApp* xtreme_app_alloc() {
|
|||||||
|
|
||||||
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
|
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;
|
app->asset_pack = 0;
|
||||||
CharList_init(app->asset_packs);
|
CharList_init(app->asset_packs);
|
||||||
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||||
File* folder = storage_file_alloc(storage);
|
File* folder = storage_file_alloc(storage);
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
char* name = malloc(MAX_PACK_NAME_LEN);
|
char* name = malloc(MAX_PACK_NAME_LEN);
|
||||||
@@ -224,8 +189,46 @@ XtremeApp* xtreme_app_alloc() {
|
|||||||
}
|
}
|
||||||
free(name);
|
free(name);
|
||||||
storage_file_free(folder);
|
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_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 =
|
app->version_tag =
|
||||||
furi_string_alloc_printf("%s %s", version_get_version(NULL), version_get_builddate(NULL));
|
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
|
// Settings deinit
|
||||||
|
|
||||||
FrequencyList_clear(app->subghz_static_frequencies);
|
|
||||||
FrequencyList_clear(app->subghz_hopper_frequencies);
|
|
||||||
|
|
||||||
CharList_it_t it;
|
CharList_it_t it;
|
||||||
for(CharList_it(it, app->asset_packs); !CharList_end_p(it); CharList_next(it)) {
|
for(CharList_it(it, app->asset_packs); !CharList_end_p(it); CharList_next(it)) {
|
||||||
free(*CharList_cref(it));
|
free(*CharList_cref(it));
|
||||||
}
|
}
|
||||||
CharList_clear(app->asset_packs);
|
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);
|
furi_string_free(app->version_tag);
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "dolphin/dolphin_i.h"
|
#include "dolphin/dolphin_i.h"
|
||||||
#include <lib/flipper_format/flipper_format.h>
|
#include <lib/flipper_format/flipper_format.h>
|
||||||
#include <lib/subghz/subghz_setting.h>
|
#include <lib/subghz/subghz_setting.h>
|
||||||
|
#include <applications/main/fap_loader/fap_loader_app.h>
|
||||||
#include <m-array.h>
|
#include <m-array.h>
|
||||||
#include "xtreme/settings.h"
|
#include "xtreme/settings.h"
|
||||||
#include "xtreme/assets.h"
|
#include "xtreme/assets.h"
|
||||||
@@ -36,7 +37,8 @@ typedef struct {
|
|||||||
Popup* popup;
|
Popup* popup;
|
||||||
uint asset_pack;
|
uint asset_pack;
|
||||||
CharList_t asset_packs;
|
CharList_t asset_packs;
|
||||||
CharList_t mainmenu_apps;
|
CharList_t mainmenu_apps_names;
|
||||||
|
CharList_t mainmenu_apps_paths;
|
||||||
uint8_t mainmenu_app_index;
|
uint8_t mainmenu_app_index;
|
||||||
bool subghz_use_defaults;
|
bool subghz_use_defaults;
|
||||||
FrequencyList_t subghz_static_frequencies;
|
FrequencyList_t subghz_static_frequencies;
|
||||||
|
|||||||
Reference in New Issue
Block a user