mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
BadKB ask to migrate badusb folder + show loading
This commit is contained in:
@@ -108,6 +108,17 @@ static void bad_kb_save_settings(BadKbApp* app) {
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
void bad_kb_app_show_loading_popup(BadKbApp* app, bool show) {
|
||||
if(show) {
|
||||
// Raise timer priority so that animations can play
|
||||
furi_timer_set_thread_priority(FuriTimerThreadPriorityElevated);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, BadKbAppViewLoading);
|
||||
} else {
|
||||
// Restore default timer priority
|
||||
furi_timer_set_thread_priority(FuriTimerThreadPriorityNormal);
|
||||
}
|
||||
}
|
||||
|
||||
BadKbApp* bad_kb_app_alloc(char* arg) {
|
||||
BadKbApp* app = malloc(sizeof(BadKbApp));
|
||||
|
||||
@@ -119,11 +130,6 @@ BadKbApp* bad_kb_app_alloc(char* arg) {
|
||||
furi_string_set(app->file_path, arg);
|
||||
}
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
storage_common_rename_safe(storage, EXT_PATH("badusb"), BAD_KB_APP_BASE_FOLDER);
|
||||
storage_simply_mkdir(storage, BAD_KB_APP_BASE_FOLDER);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
bad_kb_load_settings(app);
|
||||
|
||||
app->gui = furi_record_open(RECORD_GUI);
|
||||
@@ -184,6 +190,10 @@ BadKbApp* bad_kb_app_alloc(char* arg) {
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, BadKbAppViewByteInput, byte_input_get_view(app->byte_input));
|
||||
|
||||
app->loading = loading_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, BadKbAppViewLoading, loading_get_view(app->loading));
|
||||
|
||||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
app->conn_mode = BadKbConnModeNone;
|
||||
@@ -230,6 +240,10 @@ void bad_kb_app_free(BadKbApp* app) {
|
||||
view_dispatcher_remove_view(app->view_dispatcher, BadKbAppViewByteInput);
|
||||
byte_input_free(app->byte_input);
|
||||
|
||||
// Loading
|
||||
view_dispatcher_remove_view(app->view_dispatcher, BadKbAppViewLoading);
|
||||
loading_free(app->loading);
|
||||
|
||||
// View dispatcher
|
||||
view_dispatcher_free(app->view_dispatcher);
|
||||
scene_manager_free(app->scene_manager);
|
||||
|
||||
@@ -23,5 +23,8 @@ typedef enum {
|
||||
BadKbAppViewWork,
|
||||
BadKbAppViewVarItemList,
|
||||
BadKbAppViewByteInput,
|
||||
BadKbAppViewTextInput
|
||||
BadKbAppViewTextInput,
|
||||
BadKbAppViewLoading,
|
||||
} BadKbAppView;
|
||||
|
||||
void bad_kb_app_show_loading_popup(BadKbApp* app, bool show);
|
||||
|
||||
@@ -13,6 +13,7 @@ extern "C" {
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
#include <gui/modules/text_input.h>
|
||||
#include <gui/modules/byte_input.h>
|
||||
#include <gui/modules/loading.h>
|
||||
#include "../views/bad_kb_view.h"
|
||||
#include "../bad_kb_paths.h"
|
||||
|
||||
@@ -137,6 +138,7 @@ struct BadKbApp {
|
||||
VariableItemList* var_item_list;
|
||||
TextInput* text_input;
|
||||
ByteInput* byte_input;
|
||||
Loading* loading;
|
||||
char usb_name_buf[BAD_KB_USB_LEN];
|
||||
uint16_t usb_vidpid_buf[2];
|
||||
char bt_name_buf[BAD_KB_NAME_LEN];
|
||||
|
||||
@@ -6,6 +6,32 @@
|
||||
static bool bad_kb_file_select(BadKbApp* bad_kb) {
|
||||
furi_assert(bad_kb);
|
||||
|
||||
bad_kb_app_show_loading_popup(bad_kb, true);
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
if(storage_dir_exists(storage, EXT_PATH("badusb"))) {
|
||||
DialogMessage* message = dialog_message_alloc();
|
||||
dialog_message_set_header(message, "Migrate BadUSB?", 64, 0, AlignCenter, AlignTop);
|
||||
dialog_message_set_buttons(message, "No", NULL, "Yes");
|
||||
dialog_message_set_text(
|
||||
message,
|
||||
"A badusb folder was found!\n"
|
||||
"XFW uses the badkb folder.\n"
|
||||
"Want to transfer the files?",
|
||||
64,
|
||||
32,
|
||||
AlignCenter,
|
||||
AlignCenter);
|
||||
DialogMessageButton res = dialog_message_show(furi_record_open(RECORD_DIALOGS), message);
|
||||
dialog_message_free(message);
|
||||
furi_record_close(RECORD_DIALOGS);
|
||||
if(res == DialogMessageButtonRight) {
|
||||
storage_common_migrate(storage, EXT_PATH("badusb"), BAD_KB_APP_BASE_FOLDER);
|
||||
}
|
||||
}
|
||||
storage_simply_mkdir(storage, BAD_KB_APP_BASE_FOLDER);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
bad_kb_app_show_loading_popup(bad_kb, false);
|
||||
|
||||
DialogsFileBrowserOptions browser_options;
|
||||
dialog_file_browser_set_basic_options(
|
||||
&browser_options, BAD_KB_APP_SCRIPT_EXTENSION, &I_badkb_10px);
|
||||
|
||||
Reference in New Issue
Block a user