## New
- Read property files with `PropertiesFile`
- Support `boot.properties` so the user can specify the launcher app and an optional app to start after the launcher finishes. (see `BootProperties.cpp`)
- Create registry for CPU affinity and update code to make use of it
- `AppRegistration` and `ServiceRegistration` now also ensure that the `/data` directories always exist for all apps
- `Notes` is now the default app for opening text files. `TextViewer` is removed entirely. Created `tt::app:🎶:start(path)` function.
- WiFi settings moved from NVS to properties file.
- Specify `*.ap.properties` file on the SD card for automatic WiFi settings import on start-up.
- Added `file::getLock(path)` and `file::withLock(path, function)` to do safe file operations on SD cards
## Improvements
- Update TinyUSB to `1.7.6~1`
- Improved `Boot.cpp` code. General code quality fixes and some restructuring to improve readability.
- `tt::string` functionality improvements
- Rename `AppRegistry` to `AppRegistration`
- Rename `ServiceRegistry` to `ServiceRegistration`
- Cleanup in `Notes.cpp`
- `FileTest.cpp` fix for PC
- Created `TestFile` helper class for tests, which automatically deletes files after the test.
- Renamed `Partitions.h` to `MountPoints.h`
- Created `std::string getMountPoints()` function for easy re-use
- Other code quality improvements
- `SdCardDevice`'s `getState()` and `isMounted()` now have a timeout argument
## Fixes
- ELF loading now has a lock so to avoid a bug when 2 ELF apps are loaded in parallel
79 lines
2.1 KiB
C++
79 lines
2.1 KiB
C++
#include "Tactility/app/fileselection/FileSelectionPrivate.h"
|
|
#include "Tactility/app/fileselection/View.h"
|
|
#include "Tactility/app/fileselection/State.h"
|
|
#include "Tactility/app/AppContext.h"
|
|
|
|
#include <Tactility/Assets.h>
|
|
#include <Tactility/service/loader/Loader.h>
|
|
|
|
#include <memory>
|
|
|
|
namespace tt::app::fileselection {
|
|
|
|
constexpr auto* TAG = "FileSelection";
|
|
|
|
extern const AppManifest manifest;
|
|
|
|
std::string getResultPath(const Bundle& bundle) {
|
|
std::string result;
|
|
if (bundle.optString("path", result)) {
|
|
return result;
|
|
} else {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
Mode getMode(const Bundle& bundle) {
|
|
int32_t mode = static_cast<int32_t>(Mode::ExistingOrNew);
|
|
bundle.optInt32("mode", mode);
|
|
return static_cast<Mode>(mode);
|
|
}
|
|
|
|
void setMode(Bundle& bundle, Mode mode) {
|
|
auto mode_int = static_cast<int32_t>(mode);
|
|
bundle.putInt32("mode", mode_int);
|
|
}
|
|
|
|
class FileSelection : public App {
|
|
std::unique_ptr<View> view;
|
|
std::shared_ptr<State> state;
|
|
|
|
public:
|
|
FileSelection() {
|
|
state = std::make_shared<State>();
|
|
view = std::make_unique<View>(state, [this](const std::string& path) {
|
|
auto bundle = std::make_unique<Bundle>();
|
|
bundle->putString("path", path);
|
|
setResult(Result::Ok, std::move(bundle));
|
|
service::loader::stopApp();
|
|
});
|
|
}
|
|
|
|
void onShow(AppContext& appContext, lv_obj_t* parent) override {
|
|
auto mode = getMode(*appContext.getParameters());
|
|
view->init(parent, mode);
|
|
}
|
|
};
|
|
|
|
extern const AppManifest manifest = {
|
|
.id = "FileSelection",
|
|
.name = "File Selection",
|
|
.icon = TT_ASSETS_APP_ICON_FILES,
|
|
.type = Type::Hidden,
|
|
.createApp = create<FileSelection>
|
|
};
|
|
|
|
LaunchId startForExistingFile() {
|
|
auto bundle = std::make_shared<Bundle>();
|
|
setMode(*bundle, Mode::Existing);
|
|
return service::loader::startApp(manifest.id, bundle);
|
|
}
|
|
|
|
LaunchId startForExistingOrNewFile() {
|
|
auto bundle = std::make_shared<Bundle>();
|
|
setMode(*bundle, Mode::ExistingOrNew);
|
|
return service::loader::startApp(manifest.id, bundle);
|
|
}
|
|
|
|
} // namespace
|