[FL-1308] Add API for starting applications with arguments (#486)

* app-loader: add API for starting applications with arguments
* app-loader: add check if application is running
* archive: rework starting app with app-loader API

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
gornekich
2021-05-26 19:23:25 +03:00
committed by GitHub
parent 1cfb16d9a7
commit 63e9207c44
4 changed files with 83 additions and 30 deletions

View File

@@ -290,21 +290,11 @@ static void archive_close_file_menu(ArchiveApp* archive) {
view_commit_model(archive->view_archive_main, true);
}
static void
archive_open_app(ArchiveApp* archive, const FlipperApplication* flipper_app, void* arg) {
static void archive_open_app(ArchiveApp* archive, const char* app_name, const char* args) {
furi_assert(archive);
furi_assert(flipper_app);
furi_assert(flipper_app->app);
furi_assert(flipper_app->name);
furi_assert(app_name);
if(arg) {
// pass path to app?
}
furi_thread_set_name(archive->app_thread, flipper_app->name);
furi_thread_set_stack_size(archive->app_thread, flipper_app->stack_size);
furi_thread_set_callback(archive->app_thread, flipper_app->app);
furi_thread_start(archive->app_thread);
app_loader_start(app_name, args);
}
static void archive_delete_file(ArchiveApp* archive, string_t name) {
@@ -339,7 +329,8 @@ static void archive_file_menu_callback(ArchiveApp* archive) {
switch(model->menu_idx) {
case 0:
if((selected->type != ArchiveFileTypeFolder && selected->type != ArchiveFileTypeUnknown)) {
archive_open_app(archive, &FLIPPER_APPS[selected->type], NULL);
archive_open_app(
archive, flipper_app_name[selected->type], string_get_cstr(selected->name));
}
break;
case 1:

View File

@@ -6,6 +6,7 @@
#include <gui/gui_i.h>
#include <gui/view_dispatcher.h>
#include <gui/modules/text_input.h>
#include <app-loader/app-loader.h>
#include <m-string.h>
#include <m-array.h>
@@ -33,6 +34,14 @@ typedef enum {
ArchiveTabTotal,
} ArchiveTabEnum;
static const char* flipper_app_name[] = {
[ArchiveFileTypeIButton] = "iButton",
[ArchiveFileTypeNFC] = "NFC",
[ArchiveFileTypeSubOne] = "Sub-1 GHz",
[ArchiveFileTypeLFRFID] = "125 kHz RFID",
[ArchiveFileTypeIrda] = "Infrared",
};
static const char* known_ext[] = {
[ArchiveFileTypeIButton] = ".ibtn",
[ArchiveFileTypeNFC] = ".nfc",