mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 07:18:35 -07:00
Temporarily backport app updates from apps repo
This commit is contained in:
@@ -84,28 +84,24 @@ MassStorageApp* mass_storage_app_alloc(char* arg) {
|
||||
MassStorageAppViewWork,
|
||||
mass_storage_get_view(app->mass_storage_view));
|
||||
|
||||
app->var_item_list = variable_item_list_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher,
|
||||
MassStorageAppViewVarItemList,
|
||||
variable_item_list_get_view(app->var_item_list));
|
||||
|
||||
app->submenu = submenu_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, MassStorageAppViewSubmenu, submenu_get_view(app->submenu));
|
||||
|
||||
app->text_input = text_input_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, MassStorageAppViewTextInput, text_input_get_view(app->text_input));
|
||||
|
||||
app->popup = popup_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, MassStorageAppViewPopup, popup_get_view(app->popup));
|
||||
|
||||
app->loading = loading_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, MassStorageAppViewLoading, loading_get_view(app->loading));
|
||||
|
||||
app->variable_item_list = variable_item_list_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher,
|
||||
MassStorageAppViewStart,
|
||||
variable_item_list_get_view(app->variable_item_list));
|
||||
|
||||
app->popup = popup_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, MassStorageAppViewPopup, popup_get_view(app->popup));
|
||||
|
||||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
scene_manager_set_scene_state(
|
||||
@@ -124,18 +120,16 @@ void mass_storage_app_free(MassStorageApp* app) {
|
||||
|
||||
// Views
|
||||
view_dispatcher_remove_view(app->view_dispatcher, MassStorageAppViewWork);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, MassStorageAppViewVarItemList);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, MassStorageAppViewSubmenu);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, MassStorageAppViewTextInput);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, MassStorageAppViewPopup);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, MassStorageAppViewStart);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, MassStorageAppViewLoading);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, MassStorageAppViewPopup);
|
||||
|
||||
mass_storage_free(app->mass_storage_view);
|
||||
variable_item_list_free(app->var_item_list);
|
||||
submenu_free(app->submenu);
|
||||
text_input_free(app->text_input);
|
||||
popup_free(app->popup);
|
||||
variable_item_list_free(app->variable_item_list);
|
||||
loading_free(app->loading);
|
||||
popup_free(app->popup);
|
||||
|
||||
// View dispatcher
|
||||
view_dispatcher_free(app->view_dispatcher);
|
||||
|
||||
@@ -8,15 +8,16 @@
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/scene_manager.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <dialogs/dialogs.h>
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <gui/modules/text_input.h>
|
||||
#include <gui/modules/popup.h>
|
||||
#include <gui/modules/loading.h>
|
||||
#include <gui/modules/popup.h>
|
||||
#include <storage/storage.h>
|
||||
#include "views/mass_storage_view.h"
|
||||
#include <mass_storage_icons.h>
|
||||
|
||||
#include <assets_icons.h>
|
||||
|
||||
#define MASS_STORAGE_APP_PATH_FOLDER STORAGE_APP_DATA_PATH_PREFIX
|
||||
@@ -28,11 +29,10 @@ struct MassStorageApp {
|
||||
Storage* fs_api;
|
||||
ViewDispatcher* view_dispatcher;
|
||||
SceneManager* scene_manager;
|
||||
DialogsApp* dialogs;
|
||||
VariableItemList* var_item_list;
|
||||
Submenu* submenu;
|
||||
TextInput* text_input;
|
||||
Popup* popup;
|
||||
DialogsApp* dialogs;
|
||||
TextInput* text_input;
|
||||
VariableItemList* variable_item_list;
|
||||
Loading* loading;
|
||||
|
||||
FuriString* file_path;
|
||||
@@ -50,12 +50,11 @@ struct MassStorageApp {
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
MassStorageAppViewVarItemList,
|
||||
MassStorageAppViewSubmenu,
|
||||
MassStorageAppViewStart,
|
||||
MassStorageAppViewTextInput,
|
||||
MassStorageAppViewPopup,
|
||||
MassStorageAppViewLoading,
|
||||
MassStorageAppViewWork,
|
||||
MassStorageAppViewLoading,
|
||||
MassStorageAppViewPopup,
|
||||
} MassStorageAppView;
|
||||
|
||||
enum MassStorageCustomEvent {
|
||||
|
||||
@@ -7,7 +7,7 @@ enum VarItemListIndex {
|
||||
VarItemListIndexCreateImage,
|
||||
};
|
||||
|
||||
void mass_storage_scene_create_image_var_item_list_callback(void* context, uint32_t index) {
|
||||
void mass_storage_scene_create_image_variable_item_list_callback(void* context, uint32_t index) {
|
||||
MassStorageApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
@@ -45,7 +45,7 @@ static void mass_storage_scene_create_image_image_size_changed(VariableItem* ite
|
||||
|
||||
void mass_storage_scene_create_image_on_enter(void* context) {
|
||||
MassStorageApp* app = context;
|
||||
VariableItemList* var_item_list = app->var_item_list;
|
||||
VariableItemList* variable_item_list = app->variable_item_list;
|
||||
VariableItem* item;
|
||||
|
||||
uint8_t size_count = COUNT_OF(image_sizes);
|
||||
@@ -61,7 +61,7 @@ void mass_storage_scene_create_image_on_enter(void* context) {
|
||||
app->create_image_size = CLAMP(7, size_count - 2, 0); // 7 = 128MB
|
||||
}
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
variable_item_list,
|
||||
"Image Size",
|
||||
size_count,
|
||||
mass_storage_scene_create_image_image_size_changed,
|
||||
@@ -69,21 +69,21 @@ void mass_storage_scene_create_image_on_enter(void* context) {
|
||||
variable_item_set_current_value_index(item, app->create_image_size);
|
||||
variable_item_set_current_value_text(item, image_sizes[app->create_image_size].name);
|
||||
|
||||
item = variable_item_list_add(var_item_list, "Image Name", 0, NULL, app);
|
||||
item = variable_item_list_add(variable_item_list, "Image Name", 0, NULL, app);
|
||||
variable_item_set_current_value_text(item, app->create_image_name);
|
||||
|
||||
variable_item_list_add(var_item_list, "Create Image", 0, NULL, app);
|
||||
variable_item_list_add(variable_item_list, "Create Image", 0, NULL, app);
|
||||
|
||||
variable_item_list_set_enter_callback(
|
||||
var_item_list, mass_storage_scene_create_image_var_item_list_callback, app);
|
||||
variable_item_list, mass_storage_scene_create_image_variable_item_list_callback, app);
|
||||
|
||||
variable_item_list_set_header(var_item_list, "Create Disk Image");
|
||||
variable_item_list_set_header(variable_item_list, "Create Disk Image");
|
||||
|
||||
variable_item_list_set_selected_item(
|
||||
var_item_list,
|
||||
variable_item_list,
|
||||
scene_manager_get_scene_state(app->scene_manager, MassStorageSceneCreateImage));
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, MassStorageAppViewVarItemList);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, MassStorageAppViewStart);
|
||||
}
|
||||
|
||||
static void popup_callback_ok(void* context) {
|
||||
@@ -96,7 +96,7 @@ static void popup_callback_ok(void* context) {
|
||||
|
||||
static void popup_callback_error(void* context) {
|
||||
MassStorageApp* app = context;
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, MassStorageAppViewVarItemList);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, MassStorageAppViewStart);
|
||||
}
|
||||
|
||||
bool mass_storage_scene_create_image_on_event(void* context, SceneManagerEvent event) {
|
||||
@@ -183,5 +183,5 @@ bool mass_storage_scene_create_image_on_event(void* context, SceneManagerEvent e
|
||||
|
||||
void mass_storage_scene_create_image_on_exit(void* context) {
|
||||
MassStorageApp* app = context;
|
||||
variable_item_list_reset(app->var_item_list);
|
||||
variable_item_list_reset(app->variable_item_list);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ void mass_storage_scene_file_select_on_enter(void* context) {
|
||||
bool mass_storage_scene_file_select_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
UNUSED(event);
|
||||
// MassStorageApp* mass_storage = context;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,49 +1,64 @@
|
||||
#include "../mass_storage_app_i.h"
|
||||
|
||||
static void mass_storage_scene_start_submenu_callback(void* context, uint32_t index) {
|
||||
enum VarItemListIndex {
|
||||
VarItemListIndexSelectDiskImage,
|
||||
VarItemListIndexCreateDiskImage,
|
||||
};
|
||||
|
||||
static void mass_storage_scene_start_variable_item_list_callback(void* context, uint32_t index) {
|
||||
MassStorageApp* app = context;
|
||||
scene_manager_set_scene_state(app->scene_manager, MassStorageSceneStart, index);
|
||||
scene_manager_next_scene(app->scene_manager, index);
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void mass_storage_scene_start_on_enter(void* context) {
|
||||
MassStorageApp* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
VariableItemList* variable_item_list = app->variable_item_list;
|
||||
VariableItem* item;
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Select Disk Image",
|
||||
MassStorageSceneFileSelect,
|
||||
mass_storage_scene_start_submenu_callback,
|
||||
app);
|
||||
variable_item_list_add(variable_item_list, "Select Disk Image", 0, NULL, app);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Create Disk Image",
|
||||
MassStorageSceneCreateImage,
|
||||
mass_storage_scene_start_submenu_callback,
|
||||
app);
|
||||
scene_manager_set_scene_state(app->scene_manager, MassStorageSceneCreateImage, 0);
|
||||
variable_item_list_add(variable_item_list, "Create Disk Image", 0, NULL, app);
|
||||
|
||||
submenu_set_header(submenu, "USB Mass Storage");
|
||||
submenu_set_selected_item(
|
||||
submenu, scene_manager_get_scene_state(app->scene_manager, MassStorageSceneStart));
|
||||
variable_item_list_set_enter_callback(
|
||||
variable_item_list, mass_storage_scene_create_image_variable_item_list_callback, app);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, MassStorageAppViewSubmenu);
|
||||
variable_item_list_set_header(variable_item_list, "USB Mass Storage");
|
||||
|
||||
variable_item_list_set_selected_item(
|
||||
variable_item_list,
|
||||
scene_manager_get_scene_state(app->scene_manager, MassStorageSceneStart));
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, MassStorageAppViewStart);
|
||||
}
|
||||
|
||||
bool mass_storage_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
UNUSED(event);
|
||||
MassStorageApp* app = context;
|
||||
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
scene_manager_set_scene_state(app->scene_manager, MassStorageSceneStart, event.event);
|
||||
consumed = true;
|
||||
switch(event.event) {
|
||||
case VarItemListIndexSelectDiskImage:
|
||||
scene_manager_next_scene(app->scene_manager, MassStorageSceneFileSelect);
|
||||
break;
|
||||
case VarItemListIndexCreateDiskImage:
|
||||
scene_manager_set_scene_state(app->scene_manager, MassStorageSceneCreateImage, 0);
|
||||
scene_manager_next_scene(app->scene_manager, MassStorageSceneCreateImage);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void mass_storage_scene_start_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
MassStorageApp* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
variable_item_list_reset(app->variable_item_list);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user