Add run_with_default_app(), run files in right app

This commit is contained in:
Willy-JL
2023-08-10 01:44:33 +02:00
parent ea6966208b
commit 04f724a52c
3 changed files with 24 additions and 0 deletions

View File

@@ -19,6 +19,8 @@ void favorite_timeout_callback(void* _ctx);
void favorite_timeout_run(ViewDispatcher* view_dispatcher, SceneManager* scene_manager);
void run_with_default_app(const char* path);
#ifdef __cplusplus
}
#endif

View File

@@ -3,6 +3,7 @@
#include "../helpers/archive_apps.h"
#include "../helpers/archive_favorites.h"
#include "../helpers/archive_browser.h"
#include "../helpers/archive_helpers_ext.h"
#include "../views/archive_browser_view.h"
#include "archive/scenes/archive_scene.h"
@@ -116,6 +117,26 @@ static void
furi_record_close(RECORD_LOADER);
}
// Hijack existing archive code for default app choosing without needing archive running
void run_with_default_app(const char* path) {
// Kostily
FileInfo info;
Storage* storage = furi_record_open(RECORD_STORAGE);
bool is_dir = storage_common_stat(storage, path, &info) == FSE_OK &&
info.flags & FSF_DIRECTORY;
furi_record_close(RECORD_STORAGE);
// Velosipedy
ArchiveFile_t item;
ArchiveFile_t_init(&item);
furi_string_set(item.path, path);
archive_set_file_type(&item, path, is_dir, false);
// Bydlo kod go brrr
archive_run_in_app(NULL, &item, false);
ArchiveFile_t_clear(&item);
}
void archive_scene_browser_callback(ArchiveBrowserEvent event, void* context) {
ArchiveApp* archive = (ArchiveApp*)context;
view_dispatcher_send_custom_event(archive->view_dispatcher, event);