mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-09 05:49:09 -07:00
Merge branch 'dev' of https://github.com/claracrazy/flipper-xtreme into dev
This commit is contained in:
@@ -4,6 +4,7 @@ ADD_SCENE(xtreme_app, interface_graphics, InterfaceGraphics)
|
||||
ADD_SCENE(xtreme_app, interface_mainmenu, InterfaceMainmenu)
|
||||
ADD_SCENE(xtreme_app, interface_mainmenu_add, InterfaceMainmenuAdd)
|
||||
ADD_SCENE(xtreme_app, interface_mainmenu_add_main, InterfaceMainmenuAddMain)
|
||||
ADD_SCENE(xtreme_app, interface_mainmenu_reset, InterfaceMainmenuReset)
|
||||
ADD_SCENE(xtreme_app, interface_lockscreen, InterfaceLockscreen)
|
||||
ADD_SCENE(xtreme_app, interface_statusbar, InterfaceStatusbar)
|
||||
ADD_SCENE(xtreme_app, interface_filebrowser, InterfaceFilebrowser)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
enum VarItemListIndex {
|
||||
VarItemListIndexMenuStyle,
|
||||
VarItemListIndexResetMenu,
|
||||
VarItemListIndexMenuApp,
|
||||
VarItemListIndexAddApp,
|
||||
VarItemListIndexMoveApp,
|
||||
@@ -26,6 +27,9 @@ static void xtreme_app_scene_interface_mainmenu_menu_app_changed(VariableItem* i
|
||||
app->mainmenu_app_index = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(
|
||||
item, *CharList_get(app->mainmenu_app_labels, app->mainmenu_app_index));
|
||||
char label[13];
|
||||
snprintf(label, 13, "Menu App %u", 1 + app->mainmenu_app_index);
|
||||
variable_item_set_item_label(item, label);
|
||||
}
|
||||
|
||||
static void xtreme_app_scene_interface_mainmenu_move_app_changed(VariableItem* item) {
|
||||
@@ -62,15 +66,21 @@ void xtreme_app_scene_interface_mainmenu_on_enter(void* context) {
|
||||
variable_item_set_current_value_text(
|
||||
item, xtreme_settings->wii_menu ? "Wii Grid" : "App List");
|
||||
|
||||
variable_item_list_add(var_item_list, "Reset Menu", 0, NULL, app);
|
||||
|
||||
size_t count = CharList_size(app->mainmenu_app_labels);
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
"Menu App",
|
||||
CharList_size(app->mainmenu_app_labels),
|
||||
count,
|
||||
xtreme_app_scene_interface_mainmenu_menu_app_changed,
|
||||
app);
|
||||
if(CharList_size(app->mainmenu_app_labels)) {
|
||||
if(count) {
|
||||
app->mainmenu_app_index =
|
||||
CLAMP(app->mainmenu_app_index, CharList_size(app->mainmenu_app_labels) - 1, 0U);
|
||||
CLAMP(app->mainmenu_app_index, count - 1, 0U);
|
||||
char label[13];
|
||||
snprintf(label, 13, "Menu App %u", 1 + app->mainmenu_app_index);
|
||||
variable_item_set_item_label(item, label);
|
||||
variable_item_set_current_value_text(
|
||||
item, *CharList_get(app->mainmenu_app_labels, app->mainmenu_app_index));
|
||||
} else {
|
||||
@@ -85,6 +95,7 @@ void xtreme_app_scene_interface_mainmenu_on_enter(void* context) {
|
||||
var_item_list, "Move App", 3, xtreme_app_scene_interface_mainmenu_move_app_changed, app);
|
||||
variable_item_set_current_value_text(item, "");
|
||||
variable_item_set_current_value_index(item, 1);
|
||||
variable_item_set_locked(item, count < 2, "Can't move\nwith less\nthan 2 apps!");
|
||||
|
||||
variable_item_list_add(var_item_list, "Remove App", 0, NULL, app);
|
||||
|
||||
@@ -107,6 +118,9 @@ bool xtreme_app_scene_interface_mainmenu_on_event(void* context, SceneManagerEve
|
||||
app->scene_manager, XtremeAppSceneInterfaceMainmenu, event.event);
|
||||
consumed = true;
|
||||
switch(event.event) {
|
||||
case VarItemListIndexResetMenu:
|
||||
scene_manager_next_scene(app->scene_manager, XtremeAppSceneInterfaceMainmenuReset);
|
||||
break;
|
||||
case VarItemListIndexRemoveApp:
|
||||
if(!CharList_size(app->mainmenu_app_labels)) break;
|
||||
if(!CharList_size(app->mainmenu_app_exes)) break;
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "../xtreme_app.h"
|
||||
|
||||
static void
|
||||
xtreme_app_scene_interface_mainmenu_reset_dialog_callback(DialogExResult result, void* context) {
|
||||
XtremeApp* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
|
||||
void xtreme_app_scene_interface_mainmenu_reset_on_enter(void* context) {
|
||||
XtremeApp* app = context;
|
||||
DialogEx* dialog_ex = app->dialog_ex;
|
||||
|
||||
dialog_ex_set_header(dialog_ex, "Reset Menu Apps?", 64, 10, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_text(dialog_ex, "Your edits will be lost!", 64, 32, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_left_button_text(dialog_ex, "Cancel");
|
||||
dialog_ex_set_right_button_text(dialog_ex, "Reset");
|
||||
|
||||
dialog_ex_set_context(dialog_ex, app);
|
||||
dialog_ex_set_result_callback(
|
||||
dialog_ex, xtreme_app_scene_interface_mainmenu_reset_dialog_callback);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, XtremeAppViewDialogEx);
|
||||
}
|
||||
|
||||
bool xtreme_app_scene_interface_mainmenu_reset_on_event(void* context, SceneManagerEvent event) {
|
||||
XtremeApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
switch(event.event) {
|
||||
case DialogExResultRight:
|
||||
storage_common_remove(furi_record_open(RECORD_STORAGE), XTREME_MENU_PATH);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
app->save_mainmenu_apps = false;
|
||||
app->require_reboot = true;
|
||||
xtreme_app_apply(app);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void xtreme_app_scene_interface_mainmenu_reset_on_exit(void* context) {
|
||||
XtremeApp* app = context;
|
||||
DialogEx* dialog_ex = app->dialog_ex;
|
||||
|
||||
dialog_ex_reset(dialog_ex);
|
||||
}
|
||||
@@ -196,6 +196,10 @@ XtremeApp* xtreme_app_alloc() {
|
||||
app->popup = popup_alloc();
|
||||
view_dispatcher_add_view(app->view_dispatcher, XtremeAppViewPopup, popup_get_view(app->popup));
|
||||
|
||||
app->dialog_ex = dialog_ex_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, XtremeAppViewDialogEx, dialog_ex_get_view(app->dialog_ex));
|
||||
|
||||
// Settings init
|
||||
|
||||
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
|
||||
@@ -315,6 +319,8 @@ void xtreme_app_free(XtremeApp* app) {
|
||||
text_input_free(app->text_input);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, XtremeAppViewPopup);
|
||||
popup_free(app->popup);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, XtremeAppViewDialogEx);
|
||||
dialog_ex_free(app->dialog_ex);
|
||||
|
||||
// View Dispatcher and Scene Manager
|
||||
view_dispatcher_free(app->view_dispatcher);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/scene_manager.h>
|
||||
#include <dialogs/dialogs.h>
|
||||
#include <gui/modules/dialog_ex.h>
|
||||
#include <assets_icons.h>
|
||||
#include <applications.h>
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
@@ -42,6 +43,7 @@ typedef struct {
|
||||
Submenu* submenu;
|
||||
TextInput* text_input;
|
||||
Popup* popup;
|
||||
DialogEx* dialog_ex;
|
||||
|
||||
CharList_t asset_pack_names;
|
||||
uint8_t asset_pack_index;
|
||||
@@ -78,6 +80,7 @@ typedef enum {
|
||||
XtremeAppViewSubmenu,
|
||||
XtremeAppViewTextInput,
|
||||
XtremeAppViewPopup,
|
||||
XtremeAppViewDialogEx,
|
||||
} XtremeAppView;
|
||||
|
||||
bool xtreme_app_apply(XtremeApp* app);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
struct VariableItem {
|
||||
const char* label;
|
||||
FuriString* label;
|
||||
uint8_t current_value_index;
|
||||
FuriString* current_value_text;
|
||||
uint8_t values_count;
|
||||
@@ -81,9 +81,9 @@ static void variable_item_list_draw_callback(Canvas* canvas, void* _model) {
|
||||
|
||||
if(item->current_value_index == 0 && furi_string_empty(item->current_value_text)) {
|
||||
// Only left text, no right text
|
||||
canvas_draw_str(canvas, 6, item_text_y, item->label);
|
||||
canvas_draw_str(canvas, 6, item_text_y, furi_string_get_cstr(item->label));
|
||||
} else {
|
||||
elements_scrollable_text_line_str(
|
||||
elements_scrollable_text_line_centered(
|
||||
canvas, 6, item_text_y, 66, item->label, scroll_counter, false, false);
|
||||
}
|
||||
|
||||
@@ -420,6 +420,7 @@ void variable_item_list_free(VariableItemList* variable_item_list) {
|
||||
VariableItemArray_it_t it;
|
||||
for(VariableItemArray_it(it, model->items); !VariableItemArray_end_p(it);
|
||||
VariableItemArray_next(it)) {
|
||||
furi_string_free(VariableItemArray_ref(it)->label);
|
||||
furi_string_free(VariableItemArray_ref(it)->current_value_text);
|
||||
furi_string_free(VariableItemArray_ref(it)->locked_message);
|
||||
}
|
||||
@@ -444,6 +445,7 @@ void variable_item_list_reset(VariableItemList* variable_item_list) {
|
||||
VariableItemArray_it_t it;
|
||||
for(VariableItemArray_it(it, model->items); !VariableItemArray_end_p(it);
|
||||
VariableItemArray_next(it)) {
|
||||
furi_string_free(VariableItemArray_ref(it)->label);
|
||||
furi_string_free(VariableItemArray_ref(it)->current_value_text);
|
||||
furi_string_free(VariableItemArray_ref(it)->locked_message);
|
||||
}
|
||||
@@ -472,7 +474,7 @@ VariableItem* variable_item_list_add(
|
||||
VariableItemListModel * model,
|
||||
{
|
||||
item = VariableItemArray_push_new(model->items);
|
||||
item->label = label;
|
||||
item->label = furi_string_alloc_set(label);
|
||||
item->values_count = values_count;
|
||||
item->change_callback = change_callback;
|
||||
item->context = context;
|
||||
@@ -510,6 +512,10 @@ void variable_item_set_values_count(VariableItem* item, uint8_t values_count) {
|
||||
item->values_count = values_count;
|
||||
}
|
||||
|
||||
void variable_item_set_item_label(VariableItem* item, const char* label) {
|
||||
furi_string_set(item->label, label);
|
||||
}
|
||||
|
||||
void variable_item_set_current_value_text(VariableItem* item, const char* current_value_text) {
|
||||
furi_string_set(item->current_value_text, current_value_text);
|
||||
}
|
||||
|
||||
@@ -88,6 +88,13 @@ void variable_item_set_current_value_index(VariableItem* item, uint8_t current_v
|
||||
*/
|
||||
void variable_item_set_values_count(VariableItem* item, uint8_t values_count);
|
||||
|
||||
/** Set number of values for item
|
||||
*
|
||||
* @param item VariableItem* instance
|
||||
* @param label The new label text
|
||||
*/
|
||||
void variable_item_set_item_label(VariableItem* item, const char* label);
|
||||
|
||||
/** Set item current selected text
|
||||
*
|
||||
* @param item VariableItem* instance
|
||||
|
||||
@@ -3135,6 +3135,7 @@ Function,+,variable_item_list_set_enter_callback,void,"VariableItemList*, Variab
|
||||
Function,+,variable_item_list_set_selected_item,void,"VariableItemList*, uint8_t"
|
||||
Function,+,variable_item_set_current_value_index,void,"VariableItem*, uint8_t"
|
||||
Function,+,variable_item_set_current_value_text,void,"VariableItem*, const char*"
|
||||
Function,+,variable_item_set_item_label,void,"VariableItem*, const char*"
|
||||
Function,+,variable_item_set_locked,void,"VariableItem*, _Bool, const char*"
|
||||
Function,+,variable_item_set_values_count,void,"VariableItem*, uint8_t"
|
||||
Function,-,vasiprintf,int,"char**, const char*, __gnuc_va_list"
|
||||
|
||||
|
Reference in New Issue
Block a user