mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-11 06:09:08 -07:00
Merge branch 'Flipper-XFW:dev' into dev
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
App(
|
||||
appid="lightmeter",
|
||||
name="Lightmeter",
|
||||
name="[BH1750] Lightmeter",
|
||||
apptype=FlipperAppType.EXTERNAL,
|
||||
entry_point="lightmeter_app",
|
||||
requires=[
|
||||
|
||||
@@ -17,7 +17,7 @@ static void xtreme_app_scene_interface_graphics_asset_pack_changed(VariableItem*
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(
|
||||
item, index == 0 ? "SFW" : *CharList_get(app->asset_pack_names, index - 1));
|
||||
item, index == 0 ? "Default" : *CharList_get(app->asset_pack_names, index - 1));
|
||||
strlcpy(
|
||||
XTREME_SETTINGS()->asset_pack,
|
||||
index == 0 ? "" : *CharList_get(app->asset_pack_names, index - 1),
|
||||
|
||||
@@ -14,11 +14,15 @@ void xtreme_app_scene_interface_mainmenu_var_item_list_callback(void* context, u
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
static void xtreme_app_scene_interface_mainmenu_wii_menu_changed(VariableItem* item) {
|
||||
const char* const menu_style_names[MenuStyleCount] = {
|
||||
"List",
|
||||
"Wii",
|
||||
};
|
||||
static void xtreme_app_scene_interface_mainmenu_menu_style_changed(VariableItem* item) {
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
bool value = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(item, value ? "Wii Grid" : "App List");
|
||||
XTREME_SETTINGS()->wii_menu = value;
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(item, menu_style_names[index]);
|
||||
XTREME_SETTINGS()->menu_style = index;
|
||||
app->save_settings = true;
|
||||
}
|
||||
|
||||
@@ -62,10 +66,13 @@ void xtreme_app_scene_interface_mainmenu_on_enter(void* context) {
|
||||
VariableItem* item;
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list, "Menu Style", 2, xtreme_app_scene_interface_mainmenu_wii_menu_changed, app);
|
||||
variable_item_set_current_value_index(item, xtreme_settings->wii_menu);
|
||||
variable_item_set_current_value_text(
|
||||
item, xtreme_settings->wii_menu ? "Wii Grid" : "App List");
|
||||
var_item_list,
|
||||
"Menu Style",
|
||||
MenuStyleCount,
|
||||
xtreme_app_scene_interface_mainmenu_menu_style_changed,
|
||||
app);
|
||||
variable_item_set_current_value_index(item, xtreme_settings->menu_style);
|
||||
variable_item_set_current_value_text(item, menu_style_names[xtreme_settings->menu_style]);
|
||||
|
||||
variable_item_list_add(var_item_list, "Reset Menu", 0, NULL, app);
|
||||
|
||||
|
||||
@@ -215,12 +215,10 @@ XtremeApp* xtreme_app_alloc() {
|
||||
if(info.flags & FSF_DIRECTORY) {
|
||||
char* copy = strdup(name);
|
||||
size_t idx = 0;
|
||||
if(strcmp(copy, "NSFW") != 0) {
|
||||
for(; idx < CharList_size(app->asset_pack_names); idx++) {
|
||||
char* comp = *CharList_get(app->asset_pack_names, idx);
|
||||
if(strcasecmp(copy, comp) < 0 && strcmp(comp, "NSFW") != 0) {
|
||||
break;
|
||||
}
|
||||
for(; idx < CharList_size(app->asset_pack_names); idx++) {
|
||||
char* comp = *CharList_get(app->asset_pack_names, idx);
|
||||
if(strcasecmp(copy, comp) < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
CharList_push_at(app->asset_pack_names, idx, copy);
|
||||
|
||||
@@ -489,6 +489,8 @@ void desktop_run_keybind(Desktop* instance, InputType _type, InputKey _key) {
|
||||
view_dispatcher_send_custom_event(instance->view_dispatcher, DesktopMainEventLockKeypad);
|
||||
} else if(!strncmp(keybind, "Lock with PIN", MAX_KEYBIND_LENGTH)) {
|
||||
view_dispatcher_send_custom_event(instance->view_dispatcher, DesktopMainEventLockWithPin);
|
||||
} else if(!strncmp(keybind, "Wipe Device", MAX_KEYBIND_LENGTH)) {
|
||||
loader_start_detached_with_gui_error(instance->loader, "Storage", "wipe");
|
||||
} else {
|
||||
loader_start_detached_with_gui_error(instance->loader, keybind, NULL);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
|
||||
if(items_count) {
|
||||
MenuItem* item;
|
||||
size_t shift_position;
|
||||
if(XTREME_SETTINGS()->wii_menu) {
|
||||
switch(XTREME_SETTINGS()->menu_style) {
|
||||
case MenuStyleWii: {
|
||||
FuriString* name = furi_string_alloc();
|
||||
if(items_count > 6 && position >= 4) {
|
||||
if(position >= items_count - 2 + (items_count % 2)) {
|
||||
@@ -102,7 +103,9 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
|
||||
}
|
||||
}
|
||||
furi_string_free(name);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
case MenuStyleList: {
|
||||
// First line
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
shift_position = (0 + position + items_count - 1) % items_count;
|
||||
@@ -149,6 +152,10 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {
|
||||
// Frame and scrollbar
|
||||
elements_frame(canvas, 0, 21, 128 - 5, 21);
|
||||
elements_scrollbar(canvas, position, items_count);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
canvas_draw_str(canvas, 2, 32, "Empty");
|
||||
@@ -354,19 +361,24 @@ static void menu_process_up(Menu* menu) {
|
||||
icon_animation_stop(item->icon);
|
||||
}
|
||||
|
||||
if(XTREME_SETTINGS()->wii_menu) {
|
||||
switch(XTREME_SETTINGS()->menu_style) {
|
||||
case MenuStyleWii:
|
||||
if(model->position % 2 || (model->position == count - 1 && count % 2)) {
|
||||
model->position--;
|
||||
} else {
|
||||
model->position++;
|
||||
}
|
||||
model->scroll_counter = 0;
|
||||
} else {
|
||||
break;
|
||||
case MenuStyleList:
|
||||
if(model->position > 0) {
|
||||
model->position--;
|
||||
} else {
|
||||
model->position = count - 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
item = MenuItemArray_get(model->items, model->position);
|
||||
@@ -388,19 +400,24 @@ static void menu_process_down(Menu* menu) {
|
||||
icon_animation_stop(item->icon);
|
||||
}
|
||||
|
||||
if(XTREME_SETTINGS()->wii_menu) {
|
||||
switch(XTREME_SETTINGS()->menu_style) {
|
||||
case MenuStyleWii:
|
||||
if(model->position % 2 || (model->position == count - 1 && count % 2)) {
|
||||
model->position--;
|
||||
} else {
|
||||
model->position++;
|
||||
}
|
||||
model->scroll_counter = 0;
|
||||
} else {
|
||||
break;
|
||||
case MenuStyleList:
|
||||
if(model->position < count - 1) {
|
||||
model->position++;
|
||||
} else {
|
||||
model->position = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
item = MenuItemArray_get(model->items, model->position);
|
||||
@@ -412,27 +429,33 @@ static void menu_process_down(Menu* menu) {
|
||||
}
|
||||
|
||||
static void menu_process_left(Menu* menu) {
|
||||
if(!XTREME_SETTINGS()->wii_menu) return;
|
||||
if(XTREME_SETTINGS()->menu_style == MenuStyleList) return;
|
||||
with_view_model(
|
||||
menu->view,
|
||||
MenuModel * model,
|
||||
{
|
||||
size_t count = MenuItemArray_size(model->items);
|
||||
MenuItem* item = MenuItemArray_get(model->items, model->position);
|
||||
if(item && item->icon) {
|
||||
icon_animation_stop(item->icon);
|
||||
}
|
||||
|
||||
size_t count = MenuItemArray_size(model->items);
|
||||
if(model->position < 2) {
|
||||
if(count % 2) {
|
||||
model->position = count - 1;
|
||||
switch(XTREME_SETTINGS()->menu_style) {
|
||||
case MenuStyleWii:
|
||||
if(model->position < 2) {
|
||||
if(count % 2) {
|
||||
model->position = count - 1;
|
||||
} else {
|
||||
model->position = count - 2 + model->position % 2;
|
||||
}
|
||||
} else {
|
||||
model->position = count - 2 + model->position % 2;
|
||||
model->position -= 2;
|
||||
}
|
||||
} else {
|
||||
model->position -= 2;
|
||||
model->scroll_counter = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
model->scroll_counter = 0;
|
||||
|
||||
item = MenuItemArray_get(model->items, model->position);
|
||||
if(item && item->icon) {
|
||||
@@ -443,32 +466,38 @@ static void menu_process_left(Menu* menu) {
|
||||
}
|
||||
|
||||
static void menu_process_right(Menu* menu) {
|
||||
if(!XTREME_SETTINGS()->wii_menu) return;
|
||||
if(XTREME_SETTINGS()->menu_style == MenuStyleList) return;
|
||||
with_view_model(
|
||||
menu->view,
|
||||
MenuModel * model,
|
||||
{
|
||||
size_t count = MenuItemArray_size(model->items);
|
||||
MenuItem* item = MenuItemArray_get(model->items, model->position);
|
||||
if(item && item->icon) {
|
||||
icon_animation_stop(item->icon);
|
||||
}
|
||||
|
||||
size_t count = MenuItemArray_size(model->items);
|
||||
if(count % 2) {
|
||||
if(model->position == count - 1) {
|
||||
model->position = 0;
|
||||
} else if(model->position == count - 2) {
|
||||
model->position = count - 1;
|
||||
switch(XTREME_SETTINGS()->menu_style) {
|
||||
case MenuStyleWii:
|
||||
if(count % 2) {
|
||||
if(model->position == count - 1) {
|
||||
model->position = 0;
|
||||
} else if(model->position == count - 2) {
|
||||
model->position = count - 1;
|
||||
} else {
|
||||
model->position += 2;
|
||||
}
|
||||
} else {
|
||||
model->position += 2;
|
||||
if(model->position >= count) {
|
||||
model->position = model->position % 2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
model->position += 2;
|
||||
if(model->position >= count) {
|
||||
model->position = model->position % 2;
|
||||
}
|
||||
model->scroll_counter = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
model->scroll_counter = 0;
|
||||
|
||||
item = MenuItemArray_get(model->items, model->position);
|
||||
if(item && item->icon) {
|
||||
|
||||
@@ -15,6 +15,7 @@ const char* EXTRA_KEYBINDS[] = {
|
||||
"Lock Keypad",
|
||||
"Lock with PIN",
|
||||
"Passport",
|
||||
"Wipe Device",
|
||||
};
|
||||
const size_t EXTRA_KEYBINDS_COUNT = COUNT_OF(EXTRA_KEYBINDS);
|
||||
|
||||
|
||||
@@ -7,3 +7,4 @@ ADD_SCENE(storage_settings, sd_info, SDInfo)
|
||||
ADD_SCENE(storage_settings, internal_info, InternalInfo)
|
||||
ADD_SCENE(storage_settings, benchmark, Benchmark)
|
||||
ADD_SCENE(storage_settings, factory_reset, FactoryReset)
|
||||
ADD_SCENE(storage_settings, wipe_device, WipeDevice)
|
||||
@@ -44,6 +44,7 @@ bool storage_settings_scene_format_confirm_on_event(void* context, SceneManagerE
|
||||
consumed = scene_manager_previous_scene(app->scene_manager);
|
||||
break;
|
||||
case DialogExResultRight:
|
||||
scene_manager_set_scene_state(app->scene_manager, StorageSettingsFormatting, false);
|
||||
scene_manager_next_scene(app->scene_manager, StorageSettingsFormatting);
|
||||
consumed = true;
|
||||
break;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "../storage_settings.h"
|
||||
#include <power/power_service/power.h>
|
||||
|
||||
static const NotificationMessage message_green_165 = {
|
||||
.type = NotificationMessageTypeLedGreen,
|
||||
@@ -47,8 +48,12 @@ void storage_settings_scene_formatting_on_enter(void* context) {
|
||||
dialog_ex_set_text(
|
||||
dialog_ex, storage_error_get_desc(error), 64, 32, AlignCenter, AlignCenter);
|
||||
} else {
|
||||
dialog_ex_set_icon(dialog_ex, 72, 17, &I_DolphinCommon_56x48);
|
||||
dialog_ex_set_header(dialog_ex, "Format\ncomplete!", 14, 15, AlignLeft, AlignTop);
|
||||
if(scene_manager_get_scene_state(app->scene_manager, StorageSettingsFormatting)) {
|
||||
power_reboot(PowerBootModeNormal);
|
||||
} else {
|
||||
dialog_ex_set_icon(dialog_ex, 72, 17, &I_DolphinCommon_56x48);
|
||||
dialog_ex_set_header(dialog_ex, "Format\ncomplete!", 14, 15, AlignLeft, AlignTop);
|
||||
}
|
||||
}
|
||||
dialog_ex_set_center_button_text(dialog_ex, "OK");
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ enum StorageSettingsStartSubmenuIndex {
|
||||
StorageSettingsStartSubmenuIndexUnmount,
|
||||
StorageSettingsStartSubmenuIndexFormat,
|
||||
StorageSettingsStartSubmenuIndexBenchy,
|
||||
StorageSettingsStartSubmenuIndexFactoryReset
|
||||
StorageSettingsStartSubmenuIndexFactoryReset,
|
||||
StorageSettingsStartSubmenuIndexWipeDevice,
|
||||
};
|
||||
|
||||
static void storage_settings_scene_start_submenu_callback(void* context, uint32_t index) {
|
||||
@@ -55,6 +56,12 @@ void storage_settings_scene_start_on_enter(void* context) {
|
||||
StorageSettingsStartSubmenuIndexFactoryReset,
|
||||
storage_settings_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Wipe Device",
|
||||
StorageSettingsStartSubmenuIndexWipeDevice,
|
||||
storage_settings_scene_start_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_set_selected_item(
|
||||
submenu, scene_manager_get_scene_state(app->scene_manager, StorageSettingsStart));
|
||||
@@ -108,6 +115,14 @@ bool storage_settings_scene_start_on_event(void* context, SceneManagerEvent even
|
||||
scene_manager_next_scene(app->scene_manager, StorageSettingsFactoryReset);
|
||||
consumed = true;
|
||||
break;
|
||||
case StorageSettingsStartSubmenuIndexWipeDevice:
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager,
|
||||
StorageSettingsStart,
|
||||
StorageSettingsStartSubmenuIndexWipeDevice);
|
||||
scene_manager_next_scene(app->scene_manager, StorageSettingsWipeDevice);
|
||||
consumed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
#include "../storage_settings.h"
|
||||
#include <furi_hal.h>
|
||||
|
||||
#define STORAGE_SETTINGS_SCENE_WIPE_DEVICE_CONFIRM_COUNT 5
|
||||
|
||||
static void
|
||||
storage_settings_scene_wipe_device_dialog_callback(DialogExResult result, void* context) {
|
||||
StorageSettings* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
|
||||
void storage_settings_scene_wipe_device_on_enter(void* context) {
|
||||
StorageSettings* app = context;
|
||||
DialogEx* dialog_ex = app->dialog_ex;
|
||||
|
||||
dialog_ex_set_context(dialog_ex, app);
|
||||
dialog_ex_set_result_callback(dialog_ex, storage_settings_scene_wipe_device_dialog_callback);
|
||||
|
||||
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 full Wipe", 64, 10, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_text(
|
||||
dialog_ex,
|
||||
"Everything will be erased\r\nData and settings will be lost!",
|
||||
64,
|
||||
32,
|
||||
AlignCenter,
|
||||
AlignCenter);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, StorageSettingsViewDialogEx);
|
||||
}
|
||||
|
||||
bool storage_settings_scene_wipe_device_on_event(void* context, SceneManagerEvent event) {
|
||||
StorageSettings* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
uint32_t counter =
|
||||
scene_manager_get_scene_state(app->scene_manager, StorageSettingsWipeDevice);
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
switch(event.event) {
|
||||
case DialogExResultLeft:
|
||||
scene_manager_set_scene_state(app->scene_manager, StorageSettingsWipeDevice, 0);
|
||||
consumed = scene_manager_previous_scene(app->scene_manager);
|
||||
if(!consumed) {
|
||||
view_dispatcher_stop(app->view_dispatcher);
|
||||
}
|
||||
break;
|
||||
case DialogExResultRight:
|
||||
counter++;
|
||||
if(counter < STORAGE_SETTINGS_SCENE_WIPE_DEVICE_CONFIRM_COUNT) {
|
||||
furi_string_printf(
|
||||
app->text_string,
|
||||
"%ld presses left",
|
||||
STORAGE_SETTINGS_SCENE_WIPE_DEVICE_CONFIRM_COUNT - counter);
|
||||
dialog_ex_set_text(
|
||||
app->dialog_ex,
|
||||
furi_string_get_cstr(app->text_string),
|
||||
64,
|
||||
32,
|
||||
AlignCenter,
|
||||
AlignCenter);
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, StorageSettingsWipeDevice, counter);
|
||||
} else {
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagFactoryReset);
|
||||
scene_manager_set_scene_state(app->scene_manager, StorageSettingsFormatting, true);
|
||||
scene_manager_next_scene(app->scene_manager, StorageSettingsFormatting);
|
||||
}
|
||||
|
||||
consumed = true;
|
||||
break;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void storage_settings_scene_wipe_device_on_exit(void* context) {
|
||||
StorageSettings* app = context;
|
||||
DialogEx* dialog_ex = app->dialog_ex;
|
||||
|
||||
dialog_ex_reset(dialog_ex);
|
||||
|
||||
furi_string_reset(app->text_string);
|
||||
}
|
||||
@@ -41,8 +41,6 @@ static StorageSettings* storage_settings_alloc() {
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, StorageSettingsViewDialogEx, dialog_ex_get_view(app->dialog_ex));
|
||||
|
||||
scene_manager_next_scene(app->scene_manager, StorageSettingsStart);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -65,10 +63,15 @@ static void storage_settings_free(StorageSettings* app) {
|
||||
free(app);
|
||||
}
|
||||
|
||||
int32_t storage_settings_app(void* p) {
|
||||
UNUSED(p);
|
||||
int32_t storage_settings_app(char* p) {
|
||||
StorageSettings* app = storage_settings_alloc();
|
||||
|
||||
if(p && strlen(p) && strcmp(p, "wipe") == 0) {
|
||||
scene_manager_next_scene(app->scene_manager, StorageSettingsWipeDevice);
|
||||
} else {
|
||||
scene_manager_next_scene(app->scene_manager, StorageSettingsStart);
|
||||
}
|
||||
|
||||
view_dispatcher_run(app->view_dispatcher);
|
||||
|
||||
storage_settings_free(app);
|
||||
|
||||
Reference in New Issue
Block a user