mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-03 04:49:59 -07:00
Merge branch 'dev' of https://github.com/flipperdevices/flipperzero-firmware into xfw-dev
This commit is contained in:
@@ -7,9 +7,12 @@
|
||||
#include <gui/view_holder.h>
|
||||
#include <gui/modules/loading.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <lib/toolbox/path.h>
|
||||
|
||||
#define TAG "LoaderApplications"
|
||||
|
||||
#define JS_RUNNER_APP "JS Runner"
|
||||
|
||||
struct LoaderApplications {
|
||||
FuriThread* thread;
|
||||
void (*closed_cb)(void*);
|
||||
@@ -36,7 +39,7 @@ void loader_applications_free(LoaderApplications* loader_applications) {
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
FuriString* fap_path;
|
||||
FuriString* file_path;
|
||||
DialogsApp* dialogs;
|
||||
Storage* storage;
|
||||
Loader* loader;
|
||||
@@ -48,7 +51,7 @@ typedef struct {
|
||||
|
||||
static LoaderApplicationsApp* loader_applications_app_alloc() {
|
||||
LoaderApplicationsApp* app = malloc(sizeof(LoaderApplicationsApp)); //-V799
|
||||
app->fap_path = furi_string_alloc_set(EXT_PATH("apps"));
|
||||
app->file_path = furi_string_alloc_set(EXT_PATH("apps"));
|
||||
app->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||
app->storage = furi_record_open(RECORD_STORAGE);
|
||||
app->loader = furi_record_open(RECORD_LOADER);
|
||||
@@ -73,7 +76,7 @@ static void loader_applications_app_free(LoaderApplicationsApp* app) {
|
||||
furi_record_close(RECORD_LOADER);
|
||||
furi_record_close(RECORD_DIALOGS);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
furi_string_free(app->fap_path);
|
||||
furi_string_free(app->file_path);
|
||||
free(app);
|
||||
}
|
||||
|
||||
@@ -84,13 +87,19 @@ static bool loader_applications_item_callback(
|
||||
FuriString* item_name) {
|
||||
LoaderApplicationsApp* loader_applications_app = context;
|
||||
furi_assert(loader_applications_app);
|
||||
return flipper_application_load_name_and_icon(
|
||||
path, loader_applications_app->storage, icon_ptr, item_name);
|
||||
if(furi_string_end_with(path, ".fap")) {
|
||||
return flipper_application_load_name_and_icon(
|
||||
path, loader_applications_app->storage, icon_ptr, item_name);
|
||||
} else {
|
||||
path_extract_filename(path, item_name, false);
|
||||
memcpy(*icon_ptr, icon_get_data(&I_js_script_10px), FAP_MANIFEST_MAX_ICON_SIZE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static bool loader_applications_select_app(LoaderApplicationsApp* loader_applications_app) {
|
||||
const DialogsFileBrowserOptions browser_options = {
|
||||
.extension = ".fap",
|
||||
.extension = ".fap|.js",
|
||||
.skip_assets = true,
|
||||
.icon = &I_unknown_10px,
|
||||
.hide_ext = true,
|
||||
@@ -101,8 +110,8 @@ static bool loader_applications_select_app(LoaderApplicationsApp* loader_applica
|
||||
|
||||
return dialog_file_browser_show(
|
||||
loader_applications_app->dialogs,
|
||||
loader_applications_app->fap_path,
|
||||
loader_applications_app->fap_path,
|
||||
loader_applications_app->file_path,
|
||||
loader_applications_app->file_path,
|
||||
&browser_options);
|
||||
}
|
||||
|
||||
@@ -117,11 +126,10 @@ static void loader_pubsub_callback(const void* message, void* context) {
|
||||
}
|
||||
}
|
||||
|
||||
static void loader_applications_start_app(LoaderApplicationsApp* app) {
|
||||
const char* name = furi_string_get_cstr(app->fap_path);
|
||||
|
||||
if(!furi_string_start_with_str(app->fap_path, EXT_PATH("apps/Games/")) &&
|
||||
!furi_string_start_with_str(app->fap_path, EXT_PATH("apps/Media/"))) {
|
||||
static void
|
||||
loader_applications_start_app(LoaderApplicationsApp* app, const char* name, const char* args) {
|
||||
if(!furi_string_start_with_str(app->file_path, EXT_PATH("apps/Games/")) &&
|
||||
!furi_string_start_with_str(app->file_path, EXT_PATH("apps/Media/"))) {
|
||||
dolphin_deed(DolphinDeedPluginInternalStart);
|
||||
}
|
||||
|
||||
@@ -130,7 +138,7 @@ static void loader_applications_start_app(LoaderApplicationsApp* app) {
|
||||
FuriPubSubSubscription* subscription =
|
||||
furi_pubsub_subscribe(loader_get_pubsub(app->loader), loader_pubsub_callback, thread_id);
|
||||
|
||||
LoaderStatus status = loader_start_with_gui_error(app->loader, name, NULL);
|
||||
LoaderStatus status = loader_start_with_gui_error(app->loader, name, args);
|
||||
|
||||
if(status == LoaderStatusOk) {
|
||||
furi_thread_flags_wait(APPLICATION_STOP_EVENT, FuriFlagWaitAny, FuriWaitForever);
|
||||
@@ -147,7 +155,12 @@ static int32_t loader_applications_thread(void* p) {
|
||||
view_holder_start(app->view_holder);
|
||||
|
||||
while(loader_applications_select_app(app)) {
|
||||
loader_applications_start_app(app);
|
||||
if(!furi_string_end_with(app->file_path, ".js")) {
|
||||
loader_applications_start_app(app, furi_string_get_cstr(app->file_path), NULL);
|
||||
} else {
|
||||
loader_applications_start_app(
|
||||
app, JS_RUNNER_APP, furi_string_get_cstr(app->file_path));
|
||||
}
|
||||
}
|
||||
|
||||
// stop loading animation
|
||||
|
||||
Reference in New Issue
Block a user