diff --git a/applications/main/archive/helpers/archive_helpers_ext.h b/applications/main/archive/helpers/archive_helpers_ext.h index a46f7ec1e..cf5a9b64c 100644 --- a/applications/main/archive/helpers/archive_helpers_ext.h +++ b/applications/main/archive/helpers/archive_helpers_ext.h @@ -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 diff --git a/applications/main/archive/scenes/archive_scene_browser.c b/applications/main/archive/scenes/archive_scene_browser.c index 136983d94..52ae14ca6 100644 --- a/applications/main/archive/scenes/archive_scene_browser.c +++ b/applications/main/archive/scenes/archive_scene_browser.c @@ -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); diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index 55ce053c6..b4edd8624 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -2578,6 +2578,7 @@ Function,+,rpc_system_app_set_data_exchange_callback,void,"RpcAppSystem*, RpcApp Function,+,rpc_system_app_set_error_code,void,"RpcAppSystem*, uint32_t" Function,+,rpc_system_app_set_error_text,void,"RpcAppSystem*, const char*" Function,-,rpmatch,int,const char* +Function,-,run_with_default_app,void,const char* Function,+,saved_struct_get_payload_size,_Bool,"const char*, uint8_t, uint8_t, size_t*" Function,+,saved_struct_load,_Bool,"const char*, void*, size_t, uint8_t, uint8_t" Function,+,saved_struct_save,_Bool,"const char*, void*, size_t, uint8_t, uint8_t"