Implemented LaunchId and FileSelection, updated Notes (#281)
- Implemented `LaunchId` to keep track of the apps that are started - Implemented `FileSelection` app to select existing and/or new files. - Moved some re-usable file functionality to `tt::file::` - Renamed `Files` app to `FileBrowser` - Updated `Notes` app to use new `FileSelection` functionality, and cleaned it up a bit. - General code cleanliness improvements
This commit is contained in:
committed by
GitHub
parent
74eb830870
commit
2691dbb014
@@ -16,9 +16,9 @@ namespace tt::app {
|
||||
class AppContext;
|
||||
enum class Result;
|
||||
|
||||
class App {
|
||||
typedef unsigned int LaunchId;
|
||||
|
||||
private:
|
||||
class App {
|
||||
|
||||
Mutex mutex;
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
virtual void onDestroy(AppContext& appContext) {}
|
||||
virtual void onShow(AppContext& appContext, lv_obj_t* parent) {}
|
||||
virtual void onHide(AppContext& appContext) {}
|
||||
virtual void onResult(AppContext& appContext, Result result, std::unique_ptr<Bundle> _Nullable resultData) {}
|
||||
virtual void onResult(AppContext& appContext, LaunchId launchId, Result result, std::unique_ptr<Bundle> _Nullable resultData) {}
|
||||
|
||||
Mutex& getMutex() { return mutex; }
|
||||
|
||||
@@ -83,15 +83,15 @@ std::shared_ptr<App> create() { return std::shared_ptr<T>(new T); }
|
||||
* @param[in] id application name or id
|
||||
* @param[in] parameters optional parameters to pass onto the application
|
||||
*/
|
||||
void start(const std::string& id, std::shared_ptr<const Bundle> _Nullable parameters = nullptr);
|
||||
LaunchId start(const std::string& id, std::shared_ptr<const Bundle> _Nullable parameters = nullptr);
|
||||
|
||||
/** @brief Stop the currently showing app. Show the previous app if any app was still running. */
|
||||
void stop();
|
||||
|
||||
/** @return the currently running app context (it is only ever null before the splash screen is shown) */
|
||||
std::shared_ptr<app::AppContext> _Nullable getCurrentAppContext();
|
||||
std::shared_ptr<AppContext> _Nullable getCurrentAppContext();
|
||||
|
||||
/** @return the currently running app (it is only ever null before the splash screen is shown) */
|
||||
std::shared_ptr<app::App> _Nullable getCurrentApp();
|
||||
std::shared_ptr<App> _Nullable getCurrentApp();
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ typedef void (*OnCreate)(void* appContext, void* _Nullable data);
|
||||
typedef void (*OnDestroy)(void* appContext, void* _Nullable data);
|
||||
typedef void (*OnShow)(void* appContext, void* _Nullable data, lv_obj_t* parent);
|
||||
typedef void (*OnHide)(void* appContext, void* _Nullable data);
|
||||
typedef void (*OnResult)(void* appContext, void* _Nullable data, Result result, Bundle* resultData);
|
||||
typedef void (*OnResult)(void* appContext, void* _Nullable data, LaunchId launchId, Result result, Bundle* resultData);
|
||||
|
||||
void setElfAppManifest(
|
||||
const char* name,
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace tt::app::filebrowser {
|
||||
|
||||
void start();
|
||||
|
||||
} // namespace
|
||||
@@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/files/View.h"
|
||||
#include "app/files/State.h"
|
||||
#include "app/AppManifest.h"
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <dirent.h>
|
||||
#include <memory>
|
||||
|
||||
namespace tt::app::files {
|
||||
|
||||
void start();
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
namespace tt::app::fileselection {
|
||||
|
||||
/**
|
||||
* Show a file selection dialog that allows the user to select an existing file.
|
||||
* This app returns the absolute file path as a result.
|
||||
*/
|
||||
LaunchId startForExistingFile();
|
||||
|
||||
/**
|
||||
* Show a file selection dialog that allows the user to select a new or existing file.
|
||||
* This app returns the absolute file path as a result.
|
||||
*/
|
||||
LaunchId startForExistingOrNewFile();
|
||||
|
||||
/**
|
||||
* @param bundle the result bundle of an app
|
||||
* @return the path from the bundle, or empty string if none is present
|
||||
*/
|
||||
std::string getResultPath(const Bundle& bundle);
|
||||
|
||||
} // namespace
|
||||
@@ -53,7 +53,7 @@ std::shared_ptr<SdCardDevice> _Nullable find(const std::string& path);
|
||||
* Always calls the function, but doesn't lock if the path is not an SD card path.
|
||||
*/
|
||||
template<typename ReturnType>
|
||||
inline ReturnType withSdCardLock(const std::string& path, std::function<ReturnType()> fn) {
|
||||
ReturnType withSdCardLock(const std::string& path, std::function<ReturnType()> fn) {
|
||||
auto sdcard = find(path);
|
||||
if (sdcard != nullptr) {
|
||||
auto scoped_lockable = sdcard->getLock().asScopedLock();
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <Tactility/Bundle.h>
|
||||
#include <Tactility/PubSub.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -30,7 +29,7 @@ struct LoaderEvent {
|
||||
* @param[in] id application name or id
|
||||
* @param[in] parameters optional parameters to pass onto the application
|
||||
*/
|
||||
void startApp(const std::string& id, std::shared_ptr<const Bundle> _Nullable parameters = nullptr);
|
||||
app::LaunchId startApp(const std::string& id, std::shared_ptr<const Bundle> _Nullable parameters = nullptr);
|
||||
|
||||
/** @brief Stop the currently showing app. Show the previous app if any app was still running. */
|
||||
void stopApp();
|
||||
|
||||
Reference in New Issue
Block a user