mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 12:42:30 +04:00
Desktop favorites: Return none and add lock in dummy
This commit is contained in:
@@ -65,8 +65,8 @@ static bool one_shot_view_input(InputEvent* event, void* context) {
|
|||||||
if(!consumed) {
|
if(!consumed) {
|
||||||
if(event->key == InputKeyRight) {
|
if(event->key == InputKeyRight) {
|
||||||
/* Right button reserved for animation activation, so consume */
|
/* Right button reserved for animation activation, so consume */
|
||||||
consumed = true;
|
|
||||||
if(event->type == InputTypeShort) {
|
if(event->type == InputTypeShort) {
|
||||||
|
consumed = true;
|
||||||
if(view->interact_callback) {
|
if(view->interact_callback) {
|
||||||
view->interact_callback(view->interact_callback_context);
|
view->interact_callback(view->interact_callback_context);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,11 +61,19 @@ static void
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static inline bool desktop_scene_main_check_none(const char* str) {
|
||||||
|
return (str[1] == '\0' && str[0] == '?');
|
||||||
|
}
|
||||||
|
|
||||||
static void desktop_scene_main_open_app_or_profile(Desktop* desktop, FavoriteApp* application) {
|
static void desktop_scene_main_open_app_or_profile(Desktop* desktop, FavoriteApp* application) {
|
||||||
bool load_ok = false;
|
bool load_ok = false;
|
||||||
if(strlen(application->name_or_path) > 0) {
|
if(strlen(application->name_or_path) > 0) {
|
||||||
if(loader_start(desktop->loader, application->name_or_path, NULL, NULL) ==
|
if(desktop_scene_main_check_none(application->name_or_path)) {
|
||||||
LoaderStatusOk) {
|
// skip loading
|
||||||
|
load_ok = true;
|
||||||
|
} else if(
|
||||||
|
loader_start(desktop->loader, application->name_or_path, NULL, NULL) ==
|
||||||
|
LoaderStatusOk) {
|
||||||
load_ok = true;
|
load_ok = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,7 +84,9 @@ static void desktop_scene_main_open_app_or_profile(Desktop* desktop, FavoriteApp
|
|||||||
|
|
||||||
static void desktop_scene_main_start_favorite(Desktop* desktop, FavoriteApp* application) {
|
static void desktop_scene_main_start_favorite(Desktop* desktop, FavoriteApp* application) {
|
||||||
if(strlen(application->name_or_path) > 0) {
|
if(strlen(application->name_or_path) > 0) {
|
||||||
loader_start_with_gui_error(desktop->loader, application->name_or_path, NULL);
|
if(!desktop_scene_main_check_none(application->name_or_path)) {
|
||||||
|
loader_start_with_gui_error(desktop->loader, application->name_or_path, NULL);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
loader_start(desktop->loader, LOADER_APPLICATIONS_NAME, NULL, NULL);
|
loader_start(desktop->loader, LOADER_APPLICATIONS_NAME, NULL, NULL);
|
||||||
}
|
}
|
||||||
@@ -207,8 +217,14 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
|
|||||||
desktop, &desktop->settings.dummy_apps[DummyAppOk]);
|
desktop, &desktop->settings.dummy_apps[DummyAppOk]);
|
||||||
break;
|
break;
|
||||||
case DesktopDummyEventOpenUpLong:
|
case DesktopDummyEventOpenUpLong:
|
||||||
desktop_scene_main_open_app_or_profile(
|
if(!desktop_scene_main_check_none(
|
||||||
desktop, &desktop->settings.dummy_apps[DummyAppUpLong]);
|
desktop->settings.dummy_apps[DummyAppUpLong].name_or_path)) {
|
||||||
|
desktop_scene_main_open_app_or_profile(
|
||||||
|
desktop, &desktop->settings.dummy_apps[DummyAppUpLong]);
|
||||||
|
} else {
|
||||||
|
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 0);
|
||||||
|
desktop_lock(desktop);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DesktopDummyEventOpenDownLong:
|
case DesktopDummyEventOpenDownLong:
|
||||||
desktop_scene_main_open_app_or_profile(
|
desktop_scene_main_open_app_or_profile(
|
||||||
|
|||||||
@@ -12,9 +12,15 @@
|
|||||||
#define EXTERNAL_BROWSER_NAME ("Apps Menu (Default)")
|
#define EXTERNAL_BROWSER_NAME ("Apps Menu (Default)")
|
||||||
#define PASSPORT_NAME ("Passport (Default)")
|
#define PASSPORT_NAME ("Passport (Default)")
|
||||||
|
|
||||||
#define EXTERNAL_APPLICATION_INDEX (1)
|
#define NONE_APPLICATION_INDEX (1)
|
||||||
|
#define NONE_APPLICATION_NAME "None (disable)"
|
||||||
|
#define LOCK_APPLICATION_NAME "Lock Flipper"
|
||||||
|
|
||||||
|
#define EXTERNAL_APPLICATION_INDEX (2)
|
||||||
#define EXTERNAL_APPLICATION_NAME ("[Select App]")
|
#define EXTERNAL_APPLICATION_NAME ("[Select App]")
|
||||||
|
|
||||||
|
#define MAIN_LIST_APPLICATION_OFFSET (3)
|
||||||
|
|
||||||
#define PRESELECTED_SPECIAL 0xffffffff
|
#define PRESELECTED_SPECIAL 0xffffffff
|
||||||
|
|
||||||
static const char* favorite_fap_get_app_name(size_t i) {
|
static const char* favorite_fap_get_app_name(size_t i) {
|
||||||
@@ -63,6 +69,7 @@ void desktop_settings_scene_favorite_on_enter(void* context) {
|
|||||||
FavoriteApp* curr_favorite_app = NULL;
|
FavoriteApp* curr_favorite_app = NULL;
|
||||||
bool is_dummy_app = false;
|
bool is_dummy_app = false;
|
||||||
bool default_passport = false;
|
bool default_passport = false;
|
||||||
|
bool lock_if_none = false;
|
||||||
|
|
||||||
if((favorite_id & SCENE_STATE_SET_DUMMY_APP) == 0) {
|
if((favorite_id & SCENE_STATE_SET_DUMMY_APP) == 0) {
|
||||||
furi_assert(favorite_id < FavoriteAppNumber);
|
furi_assert(favorite_id < FavoriteAppNumber);
|
||||||
@@ -76,6 +83,9 @@ void desktop_settings_scene_favorite_on_enter(void* context) {
|
|||||||
curr_favorite_app = &app->settings.dummy_apps[favorite_id];
|
curr_favorite_app = &app->settings.dummy_apps[favorite_id];
|
||||||
is_dummy_app = true;
|
is_dummy_app = true;
|
||||||
default_passport = true;
|
default_passport = true;
|
||||||
|
if(favorite_id == DummyAppUpLong) {
|
||||||
|
lock_if_none = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special case: Application browser
|
// Special case: Application browser
|
||||||
@@ -86,6 +96,14 @@ void desktop_settings_scene_favorite_on_enter(void* context) {
|
|||||||
desktop_settings_scene_favorite_submenu_callback,
|
desktop_settings_scene_favorite_submenu_callback,
|
||||||
app);
|
app);
|
||||||
|
|
||||||
|
// Special case: None (disable) or Lock Flipper
|
||||||
|
submenu_add_item(
|
||||||
|
submenu,
|
||||||
|
lock_if_none ? (LOCK_APPLICATION_NAME) : (NONE_APPLICATION_NAME),
|
||||||
|
NONE_APPLICATION_INDEX,
|
||||||
|
desktop_settings_scene_favorite_submenu_callback,
|
||||||
|
app);
|
||||||
|
|
||||||
// Special case: Specific application
|
// Special case: Specific application
|
||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
submenu,
|
submenu,
|
||||||
@@ -99,11 +117,15 @@ void desktop_settings_scene_favorite_on_enter(void* context) {
|
|||||||
const char* name = favorite_fap_get_app_name(i);
|
const char* name = favorite_fap_get_app_name(i);
|
||||||
|
|
||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
submenu, name, i + 2, desktop_settings_scene_favorite_submenu_callback, app);
|
submenu,
|
||||||
|
name,
|
||||||
|
i + MAIN_LIST_APPLICATION_OFFSET,
|
||||||
|
desktop_settings_scene_favorite_submenu_callback,
|
||||||
|
app);
|
||||||
|
|
||||||
// Select favorite item in submenu
|
// Select favorite item in submenu
|
||||||
if(!strcmp(name, curr_favorite_app->name_or_path)) {
|
if(!strcmp(name, curr_favorite_app->name_or_path)) {
|
||||||
pre_select_item = i + 2;
|
pre_select_item = i + MAIN_LIST_APPLICATION_OFFSET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,6 +133,10 @@ void desktop_settings_scene_favorite_on_enter(void* context) {
|
|||||||
if(pre_select_item == PRESELECTED_SPECIAL) {
|
if(pre_select_item == PRESELECTED_SPECIAL) {
|
||||||
if(curr_favorite_app->name_or_path[0] == '\0') {
|
if(curr_favorite_app->name_or_path[0] == '\0') {
|
||||||
pre_select_item = DEFAULT_INDEX;
|
pre_select_item = DEFAULT_INDEX;
|
||||||
|
} else if(
|
||||||
|
(curr_favorite_app->name_or_path[1] == '\0') &&
|
||||||
|
(curr_favorite_app->name_or_path[0] == '?')) {
|
||||||
|
pre_select_item = NONE_APPLICATION_INDEX;
|
||||||
} else {
|
} else {
|
||||||
pre_select_item = EXTERNAL_APPLICATION_INDEX;
|
pre_select_item = EXTERNAL_APPLICATION_INDEX;
|
||||||
}
|
}
|
||||||
@@ -143,6 +169,10 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e
|
|||||||
if(event.event == DEFAULT_INDEX) {
|
if(event.event == DEFAULT_INDEX) {
|
||||||
curr_favorite_app->name_or_path[0] = '\0';
|
curr_favorite_app->name_or_path[0] = '\0';
|
||||||
consumed = true;
|
consumed = true;
|
||||||
|
} else if(event.event == NONE_APPLICATION_INDEX) {
|
||||||
|
curr_favorite_app->name_or_path[0] = '?';
|
||||||
|
curr_favorite_app->name_or_path[1] = '\0';
|
||||||
|
consumed = true;
|
||||||
} else if(event.event == EXTERNAL_APPLICATION_INDEX) {
|
} else if(event.event == EXTERNAL_APPLICATION_INDEX) {
|
||||||
const DialogsFileBrowserOptions browser_options = {
|
const DialogsFileBrowserOptions browser_options = {
|
||||||
.extension = ".fap",
|
.extension = ".fap",
|
||||||
@@ -168,7 +198,7 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e
|
|||||||
consumed = true;
|
consumed = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size_t app_index = event.event - 2;
|
size_t app_index = event.event - MAIN_LIST_APPLICATION_OFFSET;
|
||||||
const char* name = favorite_fap_get_app_name(app_index);
|
const char* name = favorite_fap_get_app_name(app_index);
|
||||||
if(name) strncpy(curr_favorite_app->name_or_path, name, MAX_APP_LENGTH);
|
if(name) strncpy(curr_favorite_app->name_or_path, name, MAX_APP_LENGTH);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user