mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-10 05:59:08 -07:00
Add start menu to mass storage
This commit is contained in:
@@ -55,12 +55,16 @@ MassStorageApp* mass_storage_app_alloc(char* arg) {
|
||||
MassStorageAppViewWork,
|
||||
mass_storage_get_view(app->mass_storage_view));
|
||||
|
||||
app->submenu = submenu_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, MassStorageAppViewSubmenu, submenu_get_view(app->submenu));
|
||||
|
||||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
if(storage_file_exists(app->fs_api, furi_string_get_cstr(app->file_path))) {
|
||||
scene_manager_next_scene(app->scene_manager, MassStorageSceneWork);
|
||||
} else {
|
||||
scene_manager_next_scene(app->scene_manager, MassStorageSceneFileSelect);
|
||||
scene_manager_next_scene(app->scene_manager, MassStorageSceneStart);
|
||||
}
|
||||
|
||||
return app;
|
||||
@@ -72,6 +76,8 @@ void mass_storage_app_free(MassStorageApp* app) {
|
||||
// Views
|
||||
view_dispatcher_remove_view(app->view_dispatcher, MassStorageAppViewWork);
|
||||
mass_storage_free(app->mass_storage_view);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, MassStorageAppViewSubmenu);
|
||||
submenu_free(app->submenu);
|
||||
|
||||
// View dispatcher
|
||||
view_dispatcher_free(app->view_dispatcher);
|
||||
|
||||
@@ -8,11 +8,10 @@
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/scene_manager.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <dialogs/dialogs.h>
|
||||
#include <notification/notification_messages.h>
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
#include <gui/modules/widget.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <storage/storage.h>
|
||||
#include "views/mass_storage_view.h"
|
||||
|
||||
@@ -27,6 +26,7 @@ struct MassStorageApp {
|
||||
NotificationApp* notifications;
|
||||
DialogsApp* dialogs;
|
||||
Widget* widget;
|
||||
Submenu* submenu;
|
||||
|
||||
FuriString* file_path;
|
||||
File* file;
|
||||
@@ -39,4 +39,5 @@ struct MassStorageApp {
|
||||
typedef enum {
|
||||
MassStorageAppViewError,
|
||||
MassStorageAppViewWork,
|
||||
MassStorageAppViewSubmenu,
|
||||
} MassStorageAppView;
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
ADD_SCENE(mass_storage, start, Start)
|
||||
ADD_SCENE(mass_storage, file_select, FileSelect)
|
||||
ADD_SCENE(mass_storage, work, Work)
|
||||
|
||||
@@ -23,18 +23,15 @@ void mass_storage_scene_file_select_on_enter(void* context) {
|
||||
scene_manager_next_scene(mass_storage->scene_manager, MassStorageSceneWork);
|
||||
} else {
|
||||
scene_manager_previous_scene(mass_storage->scene_manager);
|
||||
view_dispatcher_stop(mass_storage->view_dispatcher);
|
||||
}
|
||||
}
|
||||
|
||||
bool mass_storage_scene_file_select_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
UNUSED(event);
|
||||
// MassStorageApp* mass_storage = context;
|
||||
return false;
|
||||
}
|
||||
|
||||
void mass_storage_scene_file_select_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
// MassStorageApp* mass_storage = context;
|
||||
}
|
||||
|
||||
38
applications/external/mass_storage/scenes/mass_storage_scene_start.c
vendored
Normal file
38
applications/external/mass_storage/scenes/mass_storage_scene_start.c
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "../mass_storage_app_i.h"
|
||||
|
||||
static void mass_storage_scene_start_submenu_callback(void* context, uint32_t index) {
|
||||
MassStorageApp* app = context;
|
||||
scene_manager_next_scene(app->scene_manager, index);
|
||||
}
|
||||
|
||||
void mass_storage_scene_start_on_enter(void* context) {
|
||||
MassStorageApp* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Emulate Image",
|
||||
MassStorageSceneFileSelect,
|
||||
mass_storage_scene_start_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_set_header(submenu, "USB Mass Storage");
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, MassStorageAppViewSubmenu);
|
||||
}
|
||||
|
||||
bool mass_storage_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void mass_storage_scene_start_on_exit(void* context) {
|
||||
MassStorageApp* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
Reference in New Issue
Block a user