Refactor app launching (#174)
- Refactor the way apps work: Instead of a C interface, they are now C++ classes. The main reasoning is that attaching data to an app was cumbersome. Having different implementations for different kinds of apps was cumbersome too. (3 or 4 layers of manifest nesting for the TactilityC project) - External apps are still written in C, but they get a createData/destroyData in their manifest, so: - External apps now have their own manifest. - All functions in the original AppManifest are removed and replaced by a single `createApp` function - External apps now automatically register (each app individually!) when they run the first time. As a side-effect they become visible in the `AppList` app! - Adapted all apps for the new interface. - Adapted all internal logic for these changes (Gui, ViewPort, Loader, AppContext, AppInstance, etc.) - Rewrote parts of Loader to use std::shared_ptr to make the code much safer. - Added a refcount check for the `AppInstance` and `App` at the end of their lifecycle. Show warning if refcount is too high.
This commit is contained in:
committed by
GitHub
parent
2bbd44a8b5
commit
c3bcf93698
@@ -8,12 +8,15 @@
|
||||
#include "app/ElfApp.h"
|
||||
#include "lvgl/Toolbar.h"
|
||||
#include "lvgl/LvglSync.h"
|
||||
#include "service/loader/Loader.h"
|
||||
#include "Tactility.h"
|
||||
#include "StringUtils.h"
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "service/loader/Loader.h"
|
||||
#endif
|
||||
|
||||
#define TAG "files_app"
|
||||
|
||||
namespace tt::app::files {
|
||||
@@ -81,7 +84,9 @@ void View::viewFile(const std::string& path, const std::string& filename) {
|
||||
|
||||
if (isSupportedExecutableFile(filename)) {
|
||||
#ifdef ESP_PLATFORM
|
||||
app::startElfApp(processed_filepath);
|
||||
app::registerElfApp(processed_filepath);
|
||||
auto app_id = app::getElfAppId(processed_filepath);
|
||||
service::loader::startApp(app_id);
|
||||
#endif
|
||||
} else if (isSupportedImageFile(filename)) {
|
||||
app::imageviewer::start(processed_filepath);
|
||||
@@ -282,8 +287,8 @@ void View::onNavigate() {
|
||||
}
|
||||
}
|
||||
|
||||
void View::onResult(Result result, const Bundle& bundle) {
|
||||
if (result != ResultOk) {
|
||||
void View::onResult(Result result, std::unique_ptr<Bundle> bundle) {
|
||||
if (result != Result::Ok || bundle == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -292,7 +297,7 @@ void View::onResult(Result result, const Bundle& bundle) {
|
||||
|
||||
switch (state->getPendingAction()) {
|
||||
case State::ActionDelete: {
|
||||
if (alertdialog::getResultIndex(bundle) == 0) {
|
||||
if (alertdialog::getResultIndex(*bundle) == 0) {
|
||||
int delete_count = (int)remove(filepath.c_str());
|
||||
if (delete_count > 0) {
|
||||
TT_LOG_I(TAG, "Deleted %d items", delete_count);
|
||||
@@ -305,7 +310,7 @@ void View::onResult(Result result, const Bundle& bundle) {
|
||||
break;
|
||||
}
|
||||
case State::ActionRename: {
|
||||
auto new_name = app::inputdialog::getResult(bundle);
|
||||
auto new_name = app::inputdialog::getResult(*bundle);
|
||||
if (!new_name.empty() && new_name != state->getSelectedChildEntry()) {
|
||||
std::string rename_to = getChildPath(state->getCurrentPath(), new_name);
|
||||
if (rename(filepath.c_str(), rename_to.c_str())) {
|
||||
|
||||
Reference in New Issue
Block a user