mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 12:58:36 -07:00
Add run_with_default_app(), run files in right app
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user