Loader: good looking error messages (#2873)

* Loader: special error for unknown external app
* Loader: update special error
* Loader: beautify GUI errors, remove redundant logs
* Loader: fix gui error vertical position
* Desktop settings: add external menu apps
* Desktop: smaller settings struct and fix incorrect behavior with ext apps

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
Sergey Gavrilov
2023-07-13 16:02:59 +04:00
committed by GitHub
co-authored by Aleksandr Kutuzov
parent b55d97f827
commit 8dc1edac18
5 changed files with 68 additions and 43 deletions
@@ -5,11 +5,26 @@
#include <storage/storage.h>
#include <dialogs/dialogs.h>
#define APPS_COUNT (FLIPPER_APPS_COUNT + FLIPPER_EXTERNAL_APPS_COUNT)
#define EXTERNAL_BROWSER_NAME ("Applications")
#define EXTERNAL_BROWSER_INDEX (FLIPPER_APPS_COUNT + 1)
#define EXTERNAL_BROWSER_INDEX (APPS_COUNT + 1)
#define EXTERNAL_APPLICATION_NAME ("[External Application]")
#define EXTERNAL_APPLICATION_INDEX (FLIPPER_APPS_COUNT + 2)
#define EXTERNAL_APPLICATION_INDEX (APPS_COUNT + 2)
#define PRESELECTED_SPECIAL 0xffffffff
static const char* favorite_fap_get_app_name(size_t i) {
const char* name;
if(i < FLIPPER_APPS_COUNT) {
name = FLIPPER_APPS[i].name;
} else {
name = FLIPPER_EXTERNAL_APPS[i - FLIPPER_APPS_COUNT].name;
}
return name;
}
static bool favorite_fap_selector_item_callback(
FuriString* file_path,
@@ -42,21 +57,17 @@ void desktop_settings_scene_favorite_on_enter(void* context) {
uint32_t primary_favorite =
scene_manager_get_scene_state(app->scene_manager, DesktopSettingsAppSceneFavorite);
uint32_t pre_select_item = 0;
uint32_t pre_select_item = PRESELECTED_SPECIAL;
FavoriteApp* curr_favorite_app = primary_favorite ? &app->settings.favorite_primary :
&app->settings.favorite_secondary;
for(size_t i = 0; i < FLIPPER_APPS_COUNT; i++) {
submenu_add_item(
submenu,
FLIPPER_APPS[i].name,
i,
desktop_settings_scene_favorite_submenu_callback,
app);
for(size_t i = 0; i < APPS_COUNT; i++) {
const char* name = favorite_fap_get_app_name(i);
submenu_add_item(submenu, name, i, desktop_settings_scene_favorite_submenu_callback, app);
// Select favorite item in submenu
if(!curr_favorite_app->is_external &&
!strcmp(FLIPPER_APPS[i].name, curr_favorite_app->name_or_path)) {
if(!strcmp(name, curr_favorite_app->name_or_path)) {
pre_select_item = i;
}
}
@@ -77,7 +88,7 @@ void desktop_settings_scene_favorite_on_enter(void* context) {
desktop_settings_scene_favorite_submenu_callback,
app);
if(curr_favorite_app->is_external) {
if(pre_select_item == PRESELECTED_SPECIAL) {
if(curr_favorite_app->name_or_path[0] == '\0') {
pre_select_item = EXTERNAL_BROWSER_INDEX;
} else {
@@ -104,7 +115,6 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == EXTERNAL_BROWSER_INDEX) {
curr_favorite_app->is_external = true;
curr_favorite_app->name_or_path[0] = '\0';
consumed = true;
} else if(event.event == EXTERNAL_APPLICATION_INDEX) {
@@ -125,7 +135,6 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e
if(dialog_file_browser_show(app->dialogs, temp_path, temp_path, &browser_options)) {
submenu_reset(app->submenu); // Prevent menu from being shown when we exiting scene
curr_favorite_app->is_external = true;
strncpy(
curr_favorite_app->name_or_path,
furi_string_get_cstr(temp_path),
@@ -133,9 +142,8 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e
consumed = true;
}
} else {
curr_favorite_app->is_external = false;
strncpy(
curr_favorite_app->name_or_path, FLIPPER_APPS[event.event].name, MAX_APP_LENGTH);
const char* name = favorite_fap_get_app_name(event.event);
if(name) strncpy(curr_favorite_app->name_or_path, name, MAX_APP_LENGTH);
consumed = true;
}
if(consumed) {