mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-27 15:22:29 +03:00
[FL-3797] Settings menu refactoring (#3632)
* Settings menu refactoring * Update F18 api * Wording changes * Update certification icon * Desktop: optimize settings save routine, fix navigation lag * Gui: add submenu position getter. Desktop: proper menu index preservation. * Gui: proper index getter for submenu. Desktop: cleaner settings navigation. Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
a86aeface5
commit
e3f95a326b
@ -121,7 +121,8 @@ void elements_multiline_text_aligned(
|
||||
/** Draw multiline text
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x, y top left corner coordinates
|
||||
* @param x top left corner coordinates
|
||||
* @param y top left corner coordinates
|
||||
* @param text string (possible multiline)
|
||||
*/
|
||||
void elements_multiline_text(Canvas* canvas, int32_t x, int32_t y, const char* text);
|
||||
@ -129,7 +130,8 @@ void elements_multiline_text(Canvas* canvas, int32_t x, int32_t y, const char* t
|
||||
/** Draw framed multiline text
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x, y top left corner coordinates
|
||||
* @param x top left corner coordinates
|
||||
* @param y top left corner coordinates
|
||||
* @param text string (possible multiline)
|
||||
*/
|
||||
void elements_multiline_text_framed(Canvas* canvas, int32_t x, int32_t y, const char* text);
|
||||
@ -137,8 +139,10 @@ void elements_multiline_text_framed(Canvas* canvas, int32_t x, int32_t y, const
|
||||
/** Draw slightly rounded frame
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x, y top left corner coordinates
|
||||
* @param width, height size of frame
|
||||
* @param x top left corner coordinates
|
||||
* @param y top left corner coordinates
|
||||
* @param width width of frame
|
||||
* @param height height of frame
|
||||
*/
|
||||
void elements_slightly_rounded_frame(
|
||||
Canvas* canvas,
|
||||
@ -150,8 +154,10 @@ void elements_slightly_rounded_frame(
|
||||
/** Draw slightly rounded box
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x, y top left corner coordinates
|
||||
* @param width, height size of box
|
||||
* @param x top left corner coordinates
|
||||
* @param y top left corner coordinates
|
||||
* @param width height of box
|
||||
* @param height height of box
|
||||
*/
|
||||
void elements_slightly_rounded_box(
|
||||
Canvas* canvas,
|
||||
@ -163,8 +169,10 @@ void elements_slightly_rounded_box(
|
||||
/** Draw bold rounded frame
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x, y top left corner coordinates
|
||||
* @param width, height size of frame
|
||||
* @param x top left corner coordinates
|
||||
* @param y top left corner coordinates
|
||||
* @param width width of frame
|
||||
* @param height height of frame
|
||||
*/
|
||||
void elements_bold_rounded_frame(Canvas* canvas, int32_t x, int32_t y, size_t width, size_t height);
|
||||
|
||||
|
@ -215,6 +215,26 @@ void submenu_add_item(
|
||||
true);
|
||||
}
|
||||
|
||||
void submenu_change_item_label(Submenu* submenu, uint32_t index, const char* label) {
|
||||
furi_check(submenu);
|
||||
furi_check(label);
|
||||
|
||||
with_view_model(
|
||||
submenu->view,
|
||||
SubmenuModel * model,
|
||||
{
|
||||
SubmenuItemArray_it_t it;
|
||||
for(SubmenuItemArray_it(it, model->items); !SubmenuItemArray_end_p(it);
|
||||
SubmenuItemArray_next(it)) {
|
||||
if(index == SubmenuItemArray_cref(it)->index) {
|
||||
furi_string_set_str(SubmenuItemArray_cref(it)->label, label);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
void submenu_reset(Submenu* submenu) {
|
||||
furi_check(submenu);
|
||||
|
||||
@ -230,6 +250,25 @@ void submenu_reset(Submenu* submenu) {
|
||||
true);
|
||||
}
|
||||
|
||||
uint32_t submenu_get_selected_item(Submenu* submenu) {
|
||||
furi_check(submenu);
|
||||
|
||||
uint32_t selected_item_index = 0;
|
||||
|
||||
with_view_model(
|
||||
submenu->view,
|
||||
SubmenuModel * model,
|
||||
{
|
||||
if(model->position < SubmenuItemArray_size(model->items)) {
|
||||
const SubmenuItem* item = SubmenuItemArray_cget(model->items, model->position);
|
||||
selected_item_index = item->index;
|
||||
}
|
||||
},
|
||||
false);
|
||||
|
||||
return selected_item_index;
|
||||
}
|
||||
|
||||
void submenu_set_selected_item(Submenu* submenu, uint32_t index) {
|
||||
furi_check(submenu);
|
||||
with_view_model(
|
||||
|
@ -53,16 +53,32 @@ void submenu_add_item(
|
||||
SubmenuItemCallback callback,
|
||||
void* callback_context);
|
||||
|
||||
/** Change label of an existing item
|
||||
*
|
||||
* @param submenu Submenu instance
|
||||
* @param index The index of the item
|
||||
* @param label The new label
|
||||
*/
|
||||
void submenu_change_item_label(Submenu* submenu, uint32_t index, const char* label);
|
||||
|
||||
/** Remove all items from submenu
|
||||
*
|
||||
* @param submenu Submenu instance
|
||||
*/
|
||||
void submenu_reset(Submenu* submenu);
|
||||
|
||||
/** Set submenu item selector
|
||||
/** Get submenu selected item index
|
||||
*
|
||||
* @param submenu Submenu instance
|
||||
* @param index The index
|
||||
*
|
||||
* @return Index of the selected item
|
||||
*/
|
||||
uint32_t submenu_get_selected_item(Submenu* submenu);
|
||||
|
||||
/** Set submenu selected item by index
|
||||
*
|
||||
* @param submenu Submenu instance
|
||||
* @param index The index of the selected item
|
||||
*/
|
||||
void submenu_set_selected_item(Submenu* submenu, uint32_t index);
|
||||
|
||||
|
@ -41,7 +41,7 @@ static DialogMessageButton about_screen_product(DialogsApp* dialogs, DialogMessa
|
||||
static DialogMessageButton about_screen_address(DialogsApp* dialogs, DialogMessage* message) {
|
||||
DialogMessageButton result;
|
||||
|
||||
const char* screen_text = "Flipper Devices Inc\n"
|
||||
const char* screen_text = "Flipper Devices Inc.\n"
|
||||
"Suite B #551, 2803\n"
|
||||
"Philadelphia Pike, Claymont\n"
|
||||
"DE, USA 19703\n";
|
||||
@ -56,7 +56,7 @@ static DialogMessageButton about_screen_compliance(DialogsApp* dialogs, DialogMe
|
||||
DialogMessageButton result;
|
||||
|
||||
const char* screen_text = "For all compliance\n"
|
||||
"certificates please visit:\n"
|
||||
"certificates, please visit:\n"
|
||||
"www.flipp.dev/compliance";
|
||||
|
||||
dialog_message_set_text(message, screen_text, 0, 0, AlignLeft, AlignTop);
|
||||
@ -97,7 +97,7 @@ static DialogMessageButton about_screen_cert_china_0(DialogsApp* dialogs, Dialog
|
||||
static DialogMessageButton about_screen_cert_china_1(DialogsApp* dialogs, DialogMessage* message) {
|
||||
DialogMessageButton result;
|
||||
|
||||
dialog_message_set_icon(message, &I_CertificationChina1_122x47, 3, 3);
|
||||
dialog_message_set_icon(message, &I_CertificationChina1_124x47, 3, 3);
|
||||
dialog_message_set_text(
|
||||
message, furi_hal_version_get_srrc_id(), 55, 11, AlignLeft, AlignBottom);
|
||||
result = dialog_message_show(dialogs, message);
|
||||
@ -227,9 +227,11 @@ int32_t about_settings_app(void* p) {
|
||||
|
||||
while(1) {
|
||||
if(screen_index >= COUNT_OF(about_screens) - 1) {
|
||||
dialog_message_set_buttons(message, "Back", NULL, NULL);
|
||||
dialog_message_set_buttons(message, "Prev.", NULL, NULL);
|
||||
} else if(screen_index == 0) {
|
||||
dialog_message_set_buttons(message, NULL, NULL, "Next");
|
||||
} else {
|
||||
dialog_message_set_buttons(message, "Back", NULL, "Next");
|
||||
dialog_message_set_buttons(message, "Prev.", NULL, "Next");
|
||||
}
|
||||
|
||||
screen_result = about_screens[screen_index](dialogs, message);
|
||||
|
@ -10,10 +10,10 @@ void bt_settings_scene_forget_dev_confirm_dialog_callback(DialogExResult result,
|
||||
void bt_settings_scene_forget_dev_confirm_on_enter(void* context) {
|
||||
BtSettingsApp* app = context;
|
||||
DialogEx* dialog = app->dialog;
|
||||
dialog_ex_set_header(dialog, "Unpair All Devices?", 64, 3, AlignCenter, AlignTop);
|
||||
dialog_ex_set_header(dialog, "Unpair All Devices?", 64, 0, AlignCenter, AlignTop);
|
||||
dialog_ex_set_text(
|
||||
dialog, "All previous pairings\nwill be lost!", 64, 22, AlignCenter, AlignTop);
|
||||
dialog_ex_set_left_button_text(dialog, "Back");
|
||||
dialog, "All previous pairings\nwill be lost!", 64, 14, AlignCenter, AlignTop);
|
||||
dialog_ex_set_left_button_text(dialog, "Cancel");
|
||||
dialog_ex_set_right_button_text(dialog, "Unpair");
|
||||
dialog_ex_set_context(dialog, app);
|
||||
dialog_ex_set_result_callback(dialog, bt_settings_scene_forget_dev_confirm_dialog_callback);
|
||||
|
@ -53,7 +53,7 @@ void bt_settings_scene_start_on_enter(void* context) {
|
||||
variable_item_set_current_value_index(item, BtSettingOff);
|
||||
variable_item_set_current_value_text(item, bt_settings_text[BtSettingOff]);
|
||||
}
|
||||
variable_item_list_add(var_item_list, "Forget All Paired Devices", 1, NULL, NULL);
|
||||
variable_item_list_add(var_item_list, "Unpair All Devices", 1, NULL, NULL);
|
||||
variable_item_list_set_enter_callback(
|
||||
var_item_list, bt_settings_scene_start_var_list_enter_callback, app);
|
||||
} else {
|
||||
|
@ -92,6 +92,7 @@ void desktop_settings_app_free(DesktopSettingsApp* app) {
|
||||
extern int32_t desktop_settings_app(void* p) {
|
||||
DesktopSettingsApp* app = desktop_settings_app_alloc();
|
||||
DESKTOP_SETTINGS_LOAD(&app->settings);
|
||||
|
||||
if(p && (strcmp(p, DESKTOP_SETTINGS_RUN_PIN_SETUP_ARG) == 0)) {
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinSetupHowto);
|
||||
} else {
|
||||
@ -99,6 +100,9 @@ extern int32_t desktop_settings_app(void* p) {
|
||||
}
|
||||
|
||||
view_dispatcher_run(app->view_dispatcher);
|
||||
|
||||
DESKTOP_SETTINGS_SAVE(&app->settings);
|
||||
desktop_settings_app_free(app);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -40,5 +40,7 @@ typedef struct {
|
||||
PinCode pincode_buffer;
|
||||
bool pincode_buffer_filled;
|
||||
|
||||
uint8_t menu_idx;
|
||||
uint32_t pin_menu_idx;
|
||||
uint32_t quick_apps_menu_idx;
|
||||
uint32_t quick_apps_direction_menu_idx;
|
||||
} DesktopSettingsApp;
|
||||
|
@ -9,3 +9,6 @@ ADD_SCENE(desktop_settings, pin_setup, PinSetup)
|
||||
ADD_SCENE(desktop_settings, pin_setup_howto, PinSetupHowto)
|
||||
ADD_SCENE(desktop_settings, pin_setup_howto2, PinSetupHowto2)
|
||||
ADD_SCENE(desktop_settings, pin_setup_done, PinSetupDone)
|
||||
|
||||
ADD_SCENE(desktop_settings, quick_apps_menu, QuickAppsMenu)
|
||||
ADD_SCENE(desktop_settings, quick_apps_direction_menu, QuickAppsDirectionMenu)
|
@ -9,11 +9,17 @@
|
||||
#define APPS_COUNT (FLIPPER_APPS_COUNT + FLIPPER_EXTERNAL_APPS_COUNT)
|
||||
|
||||
#define DEFAULT_INDEX (0)
|
||||
#define EXTERNAL_BROWSER_NAME ("Apps Menu (Default)")
|
||||
#define PASSPORT_NAME ("Passport (Default)")
|
||||
#define EXTERNAL_BROWSER_NAME ("( ) Apps Menu (Default)")
|
||||
#define EXTERNAL_BROWSER_NAME_SELECTED ("(*) Apps Menu (Default)")
|
||||
#define PASSPORT_NAME ("( ) Passport (Default)")
|
||||
#define PASSPORT_NAME_SELECTED ("(*) Passport (Default)")
|
||||
|
||||
#define SELECTED_PREFIX ("(*) ")
|
||||
#define NOT_SELECTED_PREFIX ("( ) ")
|
||||
|
||||
#define EXTERNAL_APPLICATION_INDEX (1)
|
||||
#define EXTERNAL_APPLICATION_NAME ("[Select App]")
|
||||
#define EXTERNAL_APPLICATION_NAME ("( ) [Select App]")
|
||||
#define EXTERNAL_APPLICATION_NAME_SELECTED ("(*) [Select App]")
|
||||
|
||||
#define PRESELECTED_SPECIAL 0xffffffff
|
||||
|
||||
@ -61,7 +67,6 @@ void desktop_settings_scene_favorite_on_enter(void* context) {
|
||||
scene_manager_get_scene_state(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
uint32_t pre_select_item = PRESELECTED_SPECIAL;
|
||||
FavoriteApp* curr_favorite_app = NULL;
|
||||
bool is_dummy_app = false;
|
||||
bool default_passport = false;
|
||||
|
||||
if((favorite_id & SCENE_STATE_SET_DUMMY_APP) == 0) {
|
||||
@ -74,7 +79,6 @@ void desktop_settings_scene_favorite_on_enter(void* context) {
|
||||
favorite_id &= ~(SCENE_STATE_SET_DUMMY_APP);
|
||||
furi_assert(favorite_id < DummyAppNumber);
|
||||
curr_favorite_app = &app->settings.dummy_apps[favorite_id];
|
||||
is_dummy_app = true;
|
||||
default_passport = true;
|
||||
}
|
||||
|
||||
@ -94,29 +98,76 @@ void desktop_settings_scene_favorite_on_enter(void* context) {
|
||||
desktop_settings_scene_favorite_submenu_callback,
|
||||
app);
|
||||
|
||||
if(!is_dummy_app) {
|
||||
for(size_t i = 0; i < APPS_COUNT; i++) {
|
||||
const char* name = favorite_fap_get_app_name(i);
|
||||
FuriString* full_name = furi_string_alloc();
|
||||
|
||||
submenu_add_item(
|
||||
submenu, name, i + 2, 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);
|
||||
|
||||
// Select favorite item in submenu
|
||||
if(!strcmp(name, curr_favorite_app->name_or_path)) {
|
||||
pre_select_item = i + 2;
|
||||
}
|
||||
// Add the prefix
|
||||
furi_string_reset(full_name);
|
||||
if(!strcmp(name, curr_favorite_app->name_or_path)) {
|
||||
furi_string_set_str(full_name, SELECTED_PREFIX);
|
||||
} else {
|
||||
furi_string_set_str(full_name, NOT_SELECTED_PREFIX);
|
||||
}
|
||||
furi_string_cat_str(full_name, name);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
furi_string_get_cstr(full_name),
|
||||
i + 2,
|
||||
desktop_settings_scene_favorite_submenu_callback,
|
||||
app);
|
||||
|
||||
// Select favorite item in submenu
|
||||
if(!strcmp(name, curr_favorite_app->name_or_path)) {
|
||||
pre_select_item = i + 2;
|
||||
}
|
||||
}
|
||||
|
||||
if(pre_select_item == PRESELECTED_SPECIAL) {
|
||||
if(curr_favorite_app->name_or_path[0] == '\0') {
|
||||
pre_select_item = DEFAULT_INDEX;
|
||||
submenu_change_item_label(
|
||||
submenu,
|
||||
DEFAULT_INDEX,
|
||||
default_passport ? (PASSPORT_NAME_SELECTED) : (EXTERNAL_BROWSER_NAME_SELECTED));
|
||||
} else {
|
||||
pre_select_item = EXTERNAL_APPLICATION_INDEX;
|
||||
submenu_change_item_label(
|
||||
submenu, EXTERNAL_APPLICATION_INDEX, EXTERNAL_APPLICATION_NAME_SELECTED);
|
||||
}
|
||||
}
|
||||
|
||||
submenu_set_header(submenu, is_dummy_app ? ("Dummy Mode App") : ("Favorite App"));
|
||||
switch(favorite_id) {
|
||||
case SCENE_STATE_SET_FAVORITE_APP | FavoriteAppLeftShort:
|
||||
submenu_set_header(submenu, "Left - Short");
|
||||
break;
|
||||
case SCENE_STATE_SET_FAVORITE_APP | FavoriteAppLeftLong:
|
||||
submenu_set_header(submenu, "Left - Long");
|
||||
break;
|
||||
case SCENE_STATE_SET_FAVORITE_APP | FavoriteAppRightShort:
|
||||
submenu_set_header(submenu, "Right - Short");
|
||||
break;
|
||||
case SCENE_STATE_SET_FAVORITE_APP | FavoriteAppRightLong:
|
||||
submenu_set_header(submenu, "Right - Long");
|
||||
break;
|
||||
case SCENE_STATE_SET_DUMMY_APP | DummyAppLeft:
|
||||
submenu_set_header(submenu, "Left");
|
||||
break;
|
||||
case SCENE_STATE_SET_DUMMY_APP | DummyAppRight:
|
||||
submenu_set_header(submenu, "Right");
|
||||
break;
|
||||
case SCENE_STATE_SET_DUMMY_APP | DummyAppDown:
|
||||
submenu_set_header(submenu, "Down");
|
||||
break;
|
||||
case SCENE_STATE_SET_DUMMY_APP | DummyAppOk:
|
||||
submenu_set_header(submenu, "Middle");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
submenu_set_selected_item(submenu, pre_select_item); // If set during loop, visual glitch.
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewMenu);
|
||||
@ -177,6 +228,8 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
};
|
||||
consumed = true;
|
||||
|
||||
DESKTOP_SETTINGS_SAVE(&app->settings);
|
||||
}
|
||||
|
||||
furi_string_free(temp_path);
|
||||
@ -185,6 +238,5 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e
|
||||
|
||||
void desktop_settings_scene_favorite_on_exit(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
DESKTOP_SETTINGS_SAVE(&app->settings);
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ void desktop_settings_scene_pin_menu_on_enter(void* context) {
|
||||
}
|
||||
|
||||
submenu_set_header(app->submenu, "PIN Code Settings");
|
||||
submenu_set_selected_item(app->submenu, app->menu_idx);
|
||||
submenu_set_selected_item(app->submenu, app->pin_menu_idx);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewMenu);
|
||||
}
|
||||
|
||||
@ -76,11 +76,16 @@ bool desktop_settings_scene_pin_menu_on_event(void* context, SceneManagerEvent e
|
||||
consumed = true;
|
||||
break;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
submenu_set_selected_item(app->submenu, 0);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void desktop_settings_scene_pin_menu_on_exit(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
|
||||
app->pin_menu_idx = submenu_get_selected_item(app->submenu);
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
|
@ -97,6 +97,7 @@ bool desktop_settings_scene_pin_setup_on_event(void* context, SceneManagerEvent
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ void desktop_settings_scene_pin_setup_done_on_enter(void* context) {
|
||||
DESKTOP_SETTINGS_SAVE(&app->settings);
|
||||
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
|
||||
notification_message(notification, &sequence_single_vibro);
|
||||
notification_message(notification, &sequence_blink_green_10);
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
|
||||
desktop_view_pin_input_set_context(app->pin_input_view, app);
|
||||
|
@ -0,0 +1,187 @@
|
||||
#include <gui/scene_manager.h>
|
||||
#include <applications.h>
|
||||
|
||||
#include "../desktop_settings_app.h"
|
||||
#include "desktop_settings_scene.h"
|
||||
#include "desktop_settings_scene_i.h"
|
||||
|
||||
enum QuickAppsSubmenuIndex {
|
||||
QuickAppsSubmenuIndexFavoriteLeftClick,
|
||||
QuickAppsSubmenuIndexFavoriteRightClick,
|
||||
QuickAppsSubmenuIndexFavoriteLeftHold,
|
||||
QuickAppsSubmenuIndexFavoriteRightHold,
|
||||
QuickAppsSubmenuIndexDummyLeftClick,
|
||||
QuickAppsSubmenuIndexDummyRightClick,
|
||||
QuickAppsSubmenuIndexDummyDownClick,
|
||||
QuickAppsSubmenuIndexDummyMiddleClick,
|
||||
};
|
||||
|
||||
static void desktop_settings_scene_quick_apps_direction_menu_submenu_callback(
|
||||
void* context,
|
||||
uint32_t index) {
|
||||
DesktopSettingsApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void desktop_settings_scene_quick_apps_direction_menu_on_enter(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
submenu_reset(submenu);
|
||||
|
||||
uint32_t favorite_id = scene_manager_get_scene_state(
|
||||
app->scene_manager, DesktopSettingsAppSceneQuickAppsDirectionMenu);
|
||||
|
||||
if(favorite_id == SCENE_STATE_SET_FAVORITE_APP) {
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Left - Click",
|
||||
QuickAppsSubmenuIndexFavoriteLeftClick,
|
||||
desktop_settings_scene_quick_apps_direction_menu_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Right - Click",
|
||||
QuickAppsSubmenuIndexFavoriteRightClick,
|
||||
desktop_settings_scene_quick_apps_direction_menu_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Left - Hold",
|
||||
QuickAppsSubmenuIndexFavoriteLeftHold,
|
||||
desktop_settings_scene_quick_apps_direction_menu_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Right - Hold",
|
||||
QuickAppsSubmenuIndexFavoriteRightHold,
|
||||
desktop_settings_scene_quick_apps_direction_menu_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_set_header(app->submenu, "Default Mode");
|
||||
} else {
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Left - Click",
|
||||
QuickAppsSubmenuIndexDummyLeftClick,
|
||||
desktop_settings_scene_quick_apps_direction_menu_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Right - Click",
|
||||
QuickAppsSubmenuIndexDummyRightClick,
|
||||
desktop_settings_scene_quick_apps_direction_menu_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Down - Click",
|
||||
QuickAppsSubmenuIndexDummyDownClick,
|
||||
desktop_settings_scene_quick_apps_direction_menu_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Middle - Click",
|
||||
QuickAppsSubmenuIndexDummyMiddleClick,
|
||||
desktop_settings_scene_quick_apps_direction_menu_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_set_header(app->submenu, "Dummy Mode");
|
||||
}
|
||||
|
||||
submenu_set_selected_item(app->submenu, app->quick_apps_direction_menu_idx);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewMenu);
|
||||
}
|
||||
|
||||
bool desktop_settings_scene_quick_apps_direction_menu_on_event(
|
||||
void* context,
|
||||
SceneManagerEvent event) {
|
||||
DesktopSettingsApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
switch(event.event) {
|
||||
case QuickAppsSubmenuIndexFavoriteLeftClick:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_FAVORITE_APP | FavoriteAppLeftShort);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
consumed = true;
|
||||
break;
|
||||
case QuickAppsSubmenuIndexFavoriteRightClick:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_FAVORITE_APP | FavoriteAppRightShort);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
consumed = true;
|
||||
break;
|
||||
case QuickAppsSubmenuIndexFavoriteLeftHold:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_FAVORITE_APP | FavoriteAppLeftLong);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
consumed = true;
|
||||
break;
|
||||
case QuickAppsSubmenuIndexFavoriteRightHold:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_FAVORITE_APP | FavoriteAppRightLong);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
consumed = true;
|
||||
break;
|
||||
case QuickAppsSubmenuIndexDummyLeftClick:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppLeft);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
consumed = true;
|
||||
break;
|
||||
case QuickAppsSubmenuIndexDummyRightClick:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppRight);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
consumed = true;
|
||||
break;
|
||||
case QuickAppsSubmenuIndexDummyDownClick:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppDown);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
consumed = true;
|
||||
break;
|
||||
case QuickAppsSubmenuIndexDummyMiddleClick:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppOk);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
consumed = true;
|
||||
break;
|
||||
default:
|
||||
consumed = true;
|
||||
break;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
submenu_set_selected_item(app->submenu, 0);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void desktop_settings_scene_quick_apps_direction_menu_on_exit(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
app->quick_apps_direction_menu_idx = submenu_get_selected_item(app->submenu);
|
||||
submenu_reset(app->submenu);
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
#include <gui/scene_manager.h>
|
||||
#include <applications.h>
|
||||
|
||||
#include "../desktop_settings_app.h"
|
||||
#include "desktop_settings_scene.h"
|
||||
#include "desktop_settings_scene_i.h"
|
||||
|
||||
#define SCENE_EVENT_SET_DEFAULT (0U)
|
||||
#define SCENE_EVENT_SET_DUMMY (1U)
|
||||
|
||||
static void
|
||||
desktop_settings_scene_quick_apps_menu_submenu_callback(void* context, uint32_t index) {
|
||||
DesktopSettingsApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void desktop_settings_scene_quick_apps_menu_on_enter(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
submenu_reset(submenu);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Default Mode",
|
||||
SCENE_EVENT_SET_DEFAULT,
|
||||
desktop_settings_scene_quick_apps_menu_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Dummy Mode",
|
||||
SCENE_EVENT_SET_DUMMY,
|
||||
desktop_settings_scene_quick_apps_menu_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_set_header(app->submenu, "Set Quick Access Apps");
|
||||
submenu_set_selected_item(app->submenu, app->quick_apps_menu_idx);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewMenu);
|
||||
}
|
||||
|
||||
bool desktop_settings_scene_quick_apps_menu_on_event(void* context, SceneManagerEvent event) {
|
||||
DesktopSettingsApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
switch(event.event) {
|
||||
case SCENE_EVENT_SET_DEFAULT:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneQuickAppsDirectionMenu,
|
||||
SCENE_STATE_SET_FAVORITE_APP);
|
||||
scene_manager_next_scene(
|
||||
app->scene_manager, DesktopSettingsAppSceneQuickAppsDirectionMenu);
|
||||
consumed = true;
|
||||
break;
|
||||
case SCENE_EVENT_SET_DUMMY:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneQuickAppsDirectionMenu,
|
||||
SCENE_STATE_SET_DUMMY_APP);
|
||||
scene_manager_next_scene(
|
||||
app->scene_manager, DesktopSettingsAppSceneQuickAppsDirectionMenu);
|
||||
consumed = true;
|
||||
break;
|
||||
default:
|
||||
consumed = true;
|
||||
break;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
submenu_set_selected_item(app->submenu, 0);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void desktop_settings_scene_quick_apps_menu_on_exit(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
app->quick_apps_menu_idx = submenu_get_selected_item(app->submenu);
|
||||
submenu_reset(app->submenu);
|
||||
}
|
@ -9,14 +9,7 @@ typedef enum {
|
||||
DesktopSettingsPinSetup = 0,
|
||||
DesktopSettingsAutoLockDelay,
|
||||
DesktopSettingsClockDisplay,
|
||||
DesktopSettingsFavoriteLeftShort,
|
||||
DesktopSettingsFavoriteLeftLong,
|
||||
DesktopSettingsFavoriteRightShort,
|
||||
DesktopSettingsFavoriteRightLong,
|
||||
DesktopSettingsDummyLeft,
|
||||
DesktopSettingsDummyRight,
|
||||
DesktopSettingsDummyDown,
|
||||
DesktopSettingsDummyOk,
|
||||
DesktopSettingsFavoriteApps,
|
||||
} DesktopSettingsEntry;
|
||||
|
||||
#define AUTO_LOCK_DELAY_COUNT 6
|
||||
@ -93,15 +86,7 @@ void desktop_settings_scene_start_on_enter(void* context) {
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, clock_enable_text[value_index]);
|
||||
|
||||
variable_item_list_add(variable_item_list, "Favorite App - Left Short", 1, NULL, NULL);
|
||||
variable_item_list_add(variable_item_list, "Favorite App - Left Long", 1, NULL, NULL);
|
||||
variable_item_list_add(variable_item_list, "Favorite App - Right Short", 1, NULL, NULL);
|
||||
variable_item_list_add(variable_item_list, "Favorite App - Right Long", 1, NULL, NULL);
|
||||
|
||||
variable_item_list_add(variable_item_list, "Dummy Mode App - Left", 1, NULL, NULL);
|
||||
variable_item_list_add(variable_item_list, "Dummy Mode App - Right", 1, NULL, NULL);
|
||||
variable_item_list_add(variable_item_list, "Dummy Mode App - Down", 1, NULL, NULL);
|
||||
variable_item_list_add(variable_item_list, "Dummy Mode App - Ok", 1, NULL, NULL);
|
||||
variable_item_list_add(variable_item_list, "Set Quick Access Apps", 1, NULL, NULL);
|
||||
|
||||
variable_item_list_set_enter_callback(
|
||||
variable_item_list, desktop_settings_scene_start_var_list_enter_callback, app);
|
||||
@ -119,62 +104,8 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinMenu);
|
||||
break;
|
||||
|
||||
case DesktopSettingsFavoriteLeftShort:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_FAVORITE_APP | FavoriteAppLeftShort);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
break;
|
||||
case DesktopSettingsFavoriteLeftLong:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_FAVORITE_APP | FavoriteAppLeftLong);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
break;
|
||||
case DesktopSettingsFavoriteRightShort:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_FAVORITE_APP | FavoriteAppRightShort);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
break;
|
||||
case DesktopSettingsFavoriteRightLong:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_FAVORITE_APP | FavoriteAppRightLong);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
break;
|
||||
|
||||
case DesktopSettingsDummyLeft:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppLeft);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
break;
|
||||
case DesktopSettingsDummyRight:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppRight);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
break;
|
||||
case DesktopSettingsDummyDown:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppDown);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
break;
|
||||
case DesktopSettingsDummyOk:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
DesktopSettingsAppSceneFavorite,
|
||||
SCENE_STATE_SET_DUMMY_APP | DummyAppOk);
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneFavorite);
|
||||
case DesktopSettingsFavoriteApps:
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneQuickAppsMenu);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -188,5 +119,4 @@ bool desktop_settings_scene_start_on_event(void* context, SceneManagerEvent even
|
||||
void desktop_settings_scene_start_on_exit(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
variable_item_list_reset(app->variable_item_list);
|
||||
DESKTOP_SETTINGS_SAVE(&app->settings);
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ static void desktop_settings_view_pin_setup_howto2_draw(Canvas* canvas, void* mo
|
||||
elements_multiline_text_aligned(
|
||||
canvas,
|
||||
64,
|
||||
24,
|
||||
AlignCenter,
|
||||
0,
|
||||
AlignCenter,
|
||||
AlignTop,
|
||||
"Forgotten PIN can only be\n"
|
||||
"reset with entire device.\n"
|
||||
"Read docs How to reset PIN.");
|
||||
|
@ -30,3 +30,5 @@ typedef enum {
|
||||
PowerSettingsAppViewSubmenu,
|
||||
PowerSettingsAppViewDialog,
|
||||
} PowerSettingsAppView;
|
||||
|
||||
typedef enum { RebootTypeDFU, RebootTypeNormal } RebootType;
|
||||
|
@ -1,4 +1,5 @@
|
||||
ADD_SCENE(power_settings, start, Start)
|
||||
ADD_SCENE(power_settings, battery_info, BatteryInfo)
|
||||
ADD_SCENE(power_settings, reboot, Reboot)
|
||||
ADD_SCENE(power_settings, reboot_confirm, RebootConfirm)
|
||||
ADD_SCENE(power_settings, power_off, PowerOff)
|
||||
|
@ -10,12 +10,12 @@ void power_settings_scene_power_off_on_enter(void* context) {
|
||||
PowerSettingsApp* app = context;
|
||||
DialogEx* dialog = app->dialog;
|
||||
|
||||
dialog_ex_set_header(dialog, "Turn OFF Device?", 64, 2, AlignCenter, AlignTop);
|
||||
dialog_ex_set_header(dialog, "Turn Off Device?", 64, 0, AlignCenter, AlignTop);
|
||||
dialog_ex_set_text(
|
||||
dialog, " I will be\nwaiting for\n you here...", 78, 16, AlignLeft, AlignTop);
|
||||
dialog_ex_set_icon(dialog, 21, 13, &I_Cry_dolph_55x52);
|
||||
dialog_ex_set_left_button_text(dialog, "Back");
|
||||
dialog_ex_set_right_button_text(dialog, "OFF");
|
||||
dialog, " I will be\nwaiting for\n you here...", 78, 14, AlignLeft, AlignTop);
|
||||
dialog_ex_set_icon(dialog, 14, 10, &I_dolph_cry_49x54);
|
||||
dialog_ex_set_left_button_text(dialog, "Cancel");
|
||||
dialog_ex_set_right_button_text(dialog, "Power Off");
|
||||
dialog_ex_set_result_callback(dialog, power_settings_scene_power_off_dialog_callback);
|
||||
dialog_ex_set_context(dialog, app);
|
||||
|
||||
|
@ -24,7 +24,7 @@ void power_settings_scene_reboot_on_enter(void* context) {
|
||||
app);
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Flipper OS",
|
||||
"Reboot Flipper",
|
||||
PowerSettingsRebootSubmenuIndexOs,
|
||||
power_settings_scene_reboot_submenu_callback,
|
||||
app);
|
||||
@ -33,14 +33,18 @@ void power_settings_scene_reboot_on_enter(void* context) {
|
||||
}
|
||||
|
||||
bool power_settings_scene_reboot_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
PowerSettingsApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == PowerSettingsRebootSubmenuIndexDfu) {
|
||||
power_reboot(PowerBootModeDfu);
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, PowerSettingsAppSceneRebootConfirm, RebootTypeDFU);
|
||||
scene_manager_next_scene(app->scene_manager, PowerSettingsAppSceneRebootConfirm);
|
||||
} else if(event.event == PowerSettingsRebootSubmenuIndexOs) {
|
||||
power_reboot(PowerBootModeNormal);
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, PowerSettingsAppSceneRebootConfirm, RebootTypeNormal);
|
||||
scene_manager_next_scene(app->scene_manager, PowerSettingsAppSceneRebootConfirm);
|
||||
}
|
||||
consumed = true;
|
||||
}
|
||||
|
@ -0,0 +1,66 @@
|
||||
#include "../power_settings_app.h"
|
||||
|
||||
void power_settings_scene_reboot_confirm_dialog_callback(DialogExResult result, void* context) {
|
||||
furi_assert(context);
|
||||
PowerSettingsApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
|
||||
void power_settings_scene_reboot_confirm_on_enter(void* context) {
|
||||
PowerSettingsApp* app = context;
|
||||
DialogEx* dialog = app->dialog;
|
||||
|
||||
RebootType reboot_type =
|
||||
scene_manager_get_scene_state(app->scene_manager, PowerSettingsAppSceneRebootConfirm);
|
||||
|
||||
if(reboot_type == RebootTypeDFU) {
|
||||
dialog_ex_set_header(dialog, "Reboot to DFU Mode?", 64, 0, AlignCenter, AlignTop);
|
||||
dialog_ex_set_text(
|
||||
dialog,
|
||||
"Needed for device maintenance\nor firmware upgrades",
|
||||
64,
|
||||
14,
|
||||
AlignCenter,
|
||||
AlignTop);
|
||||
} else if(reboot_type == RebootTypeNormal) {
|
||||
dialog_ex_set_header(dialog, "Reboot Flipper?", 64, 0, AlignCenter, AlignTop);
|
||||
dialog_ex_set_text(
|
||||
dialog, "May help with some firmware\n issues", 64, 14, AlignCenter, AlignTop);
|
||||
} else {
|
||||
furi_crash("Invalid reboot type");
|
||||
}
|
||||
|
||||
dialog_ex_set_left_button_text(dialog, "Cancel");
|
||||
dialog_ex_set_right_button_text(dialog, "Reboot");
|
||||
|
||||
dialog_ex_set_result_callback(dialog, power_settings_scene_reboot_confirm_dialog_callback);
|
||||
dialog_ex_set_context(dialog, app);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, PowerSettingsAppViewDialog);
|
||||
}
|
||||
|
||||
bool power_settings_scene_reboot_confirm_on_event(void* context, SceneManagerEvent event) {
|
||||
PowerSettingsApp* app = context;
|
||||
bool consumed = false;
|
||||
RebootType reboot_type =
|
||||
scene_manager_get_scene_state(app->scene_manager, PowerSettingsAppSceneRebootConfirm);
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == DialogExResultLeft) {
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
} else if(event.event == DialogExResultRight) {
|
||||
if(reboot_type == RebootTypeDFU) {
|
||||
power_reboot(PowerBootModeDfu);
|
||||
} else {
|
||||
power_reboot(PowerBootModeNormal);
|
||||
}
|
||||
}
|
||||
consumed = true;
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void power_settings_scene_reboot_confirm_on_exit(void* context) {
|
||||
PowerSettingsApp* app = context;
|
||||
dialog_ex_reset(app->dialog);
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
#include "../storage_settings.h"
|
||||
#include <furi_hal.h>
|
||||
#include <notification/notification.h>
|
||||
#include <notification/notification_messages.h>
|
||||
|
||||
#define BENCH_DATA_SIZE 4096
|
||||
#define BENCH_COUNT 6
|
||||
@ -86,7 +88,8 @@ static void storage_settings_scene_benchmark(StorageSettings* app) {
|
||||
uint32_t bench_w_speed[BENCH_COUNT] = {0, 0, 0, 0, 0, 0};
|
||||
uint32_t bench_r_speed[BENCH_COUNT] = {0, 0, 0, 0, 0, 0};
|
||||
|
||||
dialog_ex_set_header(dialog_ex, "Benchmarking...", 64, 32, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_header(dialog_ex, "Benchmarking...", 74, 32, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_icon(dialog_ex, 12, 20, &I_LoadingHourglass_24x24);
|
||||
for(size_t i = 0; i < BENCH_COUNT; i++) {
|
||||
if(!storage_settings_scene_bench_write(
|
||||
app->fs_api, bench_size[i], bench_data, &bench_w_speed[i]))
|
||||
@ -95,6 +98,7 @@ static void storage_settings_scene_benchmark(StorageSettings* app) {
|
||||
if(i > 0) furi_string_cat_printf(app->text_string, "\n");
|
||||
furi_string_cat_printf(app->text_string, "%ub : W %luK ", bench_size[i], bench_w_speed[i]);
|
||||
dialog_ex_set_header(dialog_ex, NULL, 0, 0, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_icon(dialog_ex, 0, 0, NULL);
|
||||
dialog_ex_set_text(
|
||||
dialog_ex, furi_string_get_cstr(app->text_string), 0, 32, AlignLeft, AlignCenter);
|
||||
|
||||
@ -110,6 +114,12 @@ static void storage_settings_scene_benchmark(StorageSettings* app) {
|
||||
dialog_ex, furi_string_get_cstr(app->text_string), 0, 32, AlignLeft, AlignCenter);
|
||||
}
|
||||
|
||||
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
|
||||
notification_message(notification, &sequence_single_vibro);
|
||||
notification_message(notification, &sequence_set_green_255);
|
||||
notification_message(notification, &sequence_success);
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
|
||||
free(bench_data);
|
||||
}
|
||||
|
||||
@ -146,11 +156,17 @@ bool storage_settings_scene_benchmark_on_event(void* context, SceneManagerEvent
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
switch(event.event) {
|
||||
case DialogExResultCenter:
|
||||
consumed = scene_manager_previous_scene(app->scene_manager);
|
||||
consumed = scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, StorageSettingsStart);
|
||||
break;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeBack && sd_status != FSE_OK) {
|
||||
consumed = true;
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
if(sd_status == FSE_OK) {
|
||||
consumed = scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, StorageSettingsStart);
|
||||
} else {
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
@ -160,6 +176,10 @@ void storage_settings_scene_benchmark_on_exit(void* context) {
|
||||
StorageSettings* app = context;
|
||||
DialogEx* dialog_ex = app->dialog_ex;
|
||||
|
||||
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
|
||||
notification_message(notification, &sequence_reset_green);
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
|
||||
dialog_ex_reset(dialog_ex);
|
||||
|
||||
furi_string_reset(app->text_string);
|
||||
|
@ -0,0 +1,70 @@
|
||||
#include "../storage_settings.h"
|
||||
|
||||
static void
|
||||
storage_settings_scene_benchmark_confirm_dialog_callback(DialogExResult result, void* context) {
|
||||
StorageSettings* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
|
||||
void storage_settings_scene_benchmark_confirm_on_enter(void* context) {
|
||||
StorageSettings* app = context;
|
||||
DialogEx* dialog_ex = app->dialog_ex;
|
||||
|
||||
FS_Error sd_status = storage_sd_status(app->fs_api);
|
||||
|
||||
if(sd_status == FSE_NOT_READY) {
|
||||
dialog_ex_set_icon(dialog_ex, 83, 22, &I_WarningDolphinFlip_45x42);
|
||||
dialog_ex_set_header(dialog_ex, "SD Card Not Mounted", 64, 3, AlignCenter, AlignTop);
|
||||
dialog_ex_set_text(
|
||||
dialog_ex, "Try to reinsert\nor format SD\ncard.", 3, 19, AlignLeft, AlignTop);
|
||||
dialog_ex_set_center_button_text(dialog_ex, "Ok");
|
||||
} else {
|
||||
dialog_ex_set_header(dialog_ex, "Benchmark SD Card?", 64, 0, AlignCenter, AlignTop);
|
||||
dialog_ex_set_text(
|
||||
dialog_ex,
|
||||
"SD will be tested in SPI\nmode. Learn more:\nr.flipper.net/sd_test",
|
||||
0,
|
||||
12,
|
||||
AlignLeft,
|
||||
AlignTop);
|
||||
dialog_ex_set_icon(dialog_ex, 103, 12, &I_qr_benchmark_25x25);
|
||||
dialog_ex_set_left_button_text(dialog_ex, "Cancel");
|
||||
dialog_ex_set_right_button_text(dialog_ex, "Benchmark");
|
||||
}
|
||||
|
||||
dialog_ex_set_context(dialog_ex, app);
|
||||
dialog_ex_set_result_callback(
|
||||
dialog_ex, storage_settings_scene_benchmark_confirm_dialog_callback);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, StorageSettingsViewDialogEx);
|
||||
}
|
||||
|
||||
bool storage_settings_scene_benchmark_confirm_on_event(void* context, SceneManagerEvent event) {
|
||||
StorageSettings* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
switch(event.event) {
|
||||
case DialogExResultLeft:
|
||||
case DialogExResultCenter:
|
||||
consumed = scene_manager_previous_scene(app->scene_manager);
|
||||
break;
|
||||
case DialogExResultRight:
|
||||
scene_manager_next_scene(app->scene_manager, StorageSettingsBenchmark);
|
||||
consumed = true;
|
||||
break;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void storage_settings_scene_benchmark_confirm_on_exit(void* context) {
|
||||
StorageSettings* app = context;
|
||||
DialogEx* dialog_ex = app->dialog_ex;
|
||||
|
||||
dialog_ex_reset(dialog_ex);
|
||||
}
|
@ -5,5 +5,6 @@ ADD_SCENE(storage_settings, format_confirm, FormatConfirm)
|
||||
ADD_SCENE(storage_settings, formatting, Formatting)
|
||||
ADD_SCENE(storage_settings, sd_info, SDInfo)
|
||||
ADD_SCENE(storage_settings, internal_info, InternalInfo)
|
||||
ADD_SCENE(storage_settings, benchmark_confirm, BenchmarkConfirm)
|
||||
ADD_SCENE(storage_settings, benchmark, Benchmark)
|
||||
ADD_SCENE(storage_settings, factory_reset, FactoryReset)
|
||||
|
@ -21,14 +21,14 @@ void storage_settings_scene_factory_reset_on_enter(void* context) {
|
||||
dialog_ex_set_left_button_text(dialog_ex, "Cancel");
|
||||
dialog_ex_set_right_button_text(dialog_ex, "Erase");
|
||||
|
||||
dialog_ex_set_header(dialog_ex, "Confirm Factory Reset", 64, 10, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_header(dialog_ex, "Confirm Factory Reset?", 64, 0, AlignCenter, AlignTop);
|
||||
dialog_ex_set_text(
|
||||
dialog_ex,
|
||||
"Internal storage will be erased\r\nData and settings will be lost!",
|
||||
"Internal storage will be erased\ndata and settings will be lost!",
|
||||
64,
|
||||
32,
|
||||
14,
|
||||
AlignCenter,
|
||||
AlignCenter);
|
||||
AlignTop);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, StorageSettingsViewDialogEx);
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ void storage_settings_scene_format_confirm_on_enter(void* context) {
|
||||
dialog_ex, "Try to reinsert\nor format SD\ncard.", 3, 19, AlignLeft, AlignTop);
|
||||
dialog_ex_set_center_button_text(dialog_ex, "Ok");
|
||||
} else {
|
||||
dialog_ex_set_header(dialog_ex, "Format SD Card?", 64, 10, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_text(dialog_ex, "All data will be lost!", 64, 32, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_header(dialog_ex, "Format SD Card?", 64, 0, AlignCenter, AlignTop);
|
||||
dialog_ex_set_text(dialog_ex, "All data will be lost!", 64, 12, AlignCenter, AlignTop);
|
||||
dialog_ex_set_left_button_text(dialog_ex, "Cancel");
|
||||
dialog_ex_set_right_button_text(dialog_ex, "Format");
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "../storage_settings.h"
|
||||
#include <notification/notification.h>
|
||||
#include <notification/notification_messages.h>
|
||||
|
||||
static const NotificationMessage message_green_165 = {
|
||||
.type = NotificationMessageTypeLedGreen,
|
||||
@ -31,7 +33,8 @@ void storage_settings_scene_formatting_on_enter(void* context) {
|
||||
FS_Error error;
|
||||
DialogEx* dialog_ex = app->dialog_ex;
|
||||
|
||||
dialog_ex_set_header(dialog_ex, "Formatting...", 64, 32, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_header(dialog_ex, "Formatting...", 70, 32, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_icon(dialog_ex, 15, 20, &I_LoadingHourglass_24x24);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, StorageSettingsViewDialogEx);
|
||||
|
||||
notification_message_block(app->notification, &sequence_set_formatting_leds);
|
||||
@ -44,11 +47,17 @@ void storage_settings_scene_formatting_on_enter(void* context) {
|
||||
|
||||
if(error != FSE_OK) {
|
||||
dialog_ex_set_header(dialog_ex, "Cannot Format SD Card", 64, 10, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_icon(dialog_ex, 0, 0, NULL);
|
||||
dialog_ex_set_text(
|
||||
dialog_ex, storage_error_get_desc(error), 64, 32, AlignCenter, AlignCenter);
|
||||
} else {
|
||||
dialog_ex_set_icon(dialog_ex, 83, 22, &I_WarningDolphinFlip_45x42);
|
||||
dialog_ex_set_header(dialog_ex, "Format\ncomplete!", 14, 15, AlignLeft, AlignTop);
|
||||
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
|
||||
notification_message(notification, &sequence_single_vibro);
|
||||
notification_message(notification, &sequence_set_green_255);
|
||||
notification_message(notification, &sequence_success);
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
}
|
||||
dialog_ex_set_center_button_text(dialog_ex, "OK");
|
||||
}
|
||||
@ -75,5 +84,9 @@ void storage_settings_scene_formatting_on_exit(void* context) {
|
||||
StorageSettings* app = context;
|
||||
DialogEx* dialog_ex = app->dialog_ex;
|
||||
|
||||
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
|
||||
notification_message(notification, &sequence_reset_green);
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
|
||||
dialog_ex_reset(dialog_ex);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ void storage_settings_scene_internal_info_on_enter(void* context) {
|
||||
} else {
|
||||
furi_string_printf(
|
||||
app->text_string,
|
||||
"Label: %s\nType: LittleFS\n%lu KiB total\n%lu KiB free",
|
||||
"Name: %s\nType: LittleFS\nTotal: %lu KiB\nFree: %lu KiB",
|
||||
furi_hal_version_get_name_ptr() ? furi_hal_version_get_name_ptr() : "Unknown",
|
||||
(uint32_t)(total_space / 1024),
|
||||
(uint32_t)(free_space / 1024));
|
||||
|
@ -27,12 +27,31 @@ void storage_settings_scene_sd_info_on_enter(void* context) {
|
||||
} else {
|
||||
furi_string_printf(
|
||||
app->text_string,
|
||||
"Label: %s\nType: %s\n%lu KiB total\n%lu KiB free\n"
|
||||
"%02X%s %s v%i.%i\nSN:%04lX %02i/%i",
|
||||
"Label: %s\nType: %s\n",
|
||||
sd_info.label,
|
||||
sd_api_get_fs_type_text(sd_info.fs_type),
|
||||
sd_info.kb_total,
|
||||
sd_info.kb_free,
|
||||
sd_api_get_fs_type_text(sd_info.fs_type));
|
||||
|
||||
if(sd_info.kb_total < 1024) {
|
||||
furi_string_cat_printf(app->text_string, "Total: %lu KiB\n", sd_info.kb_total);
|
||||
} else if(sd_info.kb_total < 1024 * 1024) {
|
||||
furi_string_cat_printf(app->text_string, "Total: %lu MiB\n", sd_info.kb_total / 1024);
|
||||
} else {
|
||||
furi_string_cat_printf(
|
||||
app->text_string, "Total: %lu GiB\n", sd_info.kb_total / (1024 * 1024));
|
||||
}
|
||||
|
||||
if(sd_info.kb_free < 1024) {
|
||||
furi_string_cat_printf(app->text_string, "Free: %lu KiB\n", sd_info.kb_free);
|
||||
} else if(sd_info.kb_free < 1024 * 1024) {
|
||||
furi_string_cat_printf(app->text_string, "Free: %lu MiB\n", sd_info.kb_free / 1024);
|
||||
} else {
|
||||
furi_string_cat_printf(
|
||||
app->text_string, "Free: %lu GiB\n", sd_info.kb_free / (1024 * 1024));
|
||||
}
|
||||
|
||||
furi_string_cat_printf(
|
||||
app->text_string,
|
||||
"%02X%s %s v%i.%i\nSN:%04lX %02i/%i",
|
||||
sd_info.manufacturer_id,
|
||||
sd_info.oem_id,
|
||||
sd_info.product_name,
|
||||
@ -41,6 +60,7 @@ void storage_settings_scene_sd_info_on_enter(void* context) {
|
||||
sd_info.product_serial_number,
|
||||
sd_info.manufacturing_month,
|
||||
sd_info.manufacturing_year);
|
||||
|
||||
dialog_ex_set_text(
|
||||
dialog_ex, furi_string_get_cstr(app->text_string), 4, 1, AlignLeft, AlignTop);
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ bool storage_settings_scene_start_on_event(void* context, SceneManagerEvent even
|
||||
case StorageSettingsStartSubmenuIndexBenchy:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, StorageSettingsStart, StorageSettingsStartSubmenuIndexBenchy);
|
||||
scene_manager_next_scene(app->scene_manager, StorageSettingsBenchmark);
|
||||
scene_manager_next_scene(app->scene_manager, StorageSettingsBenchmarkConfirm);
|
||||
consumed = true;
|
||||
break;
|
||||
case StorageSettingsStartSubmenuIndexFactoryReset:
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.1 KiB |
BIN
assets/icons/About/CertificationChina1_124x47.png
Normal file
BIN
assets/icons/About/CertificationChina1_124x47.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 429 B |
Binary file not shown.
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.6 KiB |
BIN
assets/icons/Settings/dolph_cry_49x54.png
Normal file
BIN
assets/icons/Settings/dolph_cry_49x54.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 973 B |
BIN
assets/icons/Settings/qr_benchmark_25x25.png
Normal file
BIN
assets/icons/Settings/qr_benchmark_25x25.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 395 B |
@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,61.2,,
|
||||
Version,+,61.3,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
Header,+,applications/services/cli/cli_vcp.h,,
|
||||
@ -2554,7 +2554,9 @@ Function,-,strxfrm,size_t,"char*, const char*, size_t"
|
||||
Function,-,strxfrm_l,size_t,"char*, const char*, size_t, locale_t"
|
||||
Function,+,submenu_add_item,void,"Submenu*, const char*, uint32_t, SubmenuItemCallback, void*"
|
||||
Function,+,submenu_alloc,Submenu*,
|
||||
Function,+,submenu_change_item_label,void,"Submenu*, uint32_t, const char*"
|
||||
Function,+,submenu_free,void,Submenu*
|
||||
Function,+,submenu_get_selected_item,uint32_t,Submenu*
|
||||
Function,+,submenu_get_view,View*,Submenu*
|
||||
Function,+,submenu_reset,void,Submenu*
|
||||
Function,+,submenu_set_header,void,"Submenu*, const char*"
|
||||
|
|
@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,61.2,,
|
||||
Version,+,61.3,,
|
||||
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
@ -3351,7 +3351,9 @@ Function,+,subghz_worker_start,void,SubGhzWorker*
|
||||
Function,+,subghz_worker_stop,void,SubGhzWorker*
|
||||
Function,+,submenu_add_item,void,"Submenu*, const char*, uint32_t, SubmenuItemCallback, void*"
|
||||
Function,+,submenu_alloc,Submenu*,
|
||||
Function,+,submenu_change_item_label,void,"Submenu*, uint32_t, const char*"
|
||||
Function,+,submenu_free,void,Submenu*
|
||||
Function,+,submenu_get_selected_item,uint32_t,Submenu*
|
||||
Function,+,submenu_get_view,View*,Submenu*
|
||||
Function,+,submenu_reset,void,Submenu*
|
||||
Function,+,submenu_set_header,void,"Submenu*, const char*"
|
||||
|
|
Loading…
Reference in New Issue
Block a user