Merge develop into main (#343)
- Refactor `AppManifest`: add new fields and rename existing ones - Parse and validate the manifest from an app that is being installed. - Remove deprecated `scoped()` from `Lock` - Create `Tactility/Paths.h` - App loading at boot now properly parses the manifest files of external apps - Properly lock both source and destination locations during app install - Remove LVGL path variants from `AppPaths` and `ServicePaths` - Removed `xPath` base classes for apps and services. There's now `AppPaths` and `ServicePaths`. - Renamed app and service paths: "data" and "system" paths are now "user data" and "assets"
This commit is contained in:
committed by
GitHub
parent
a4d15b2a1e
commit
bab3eb19bc
@@ -1,6 +1,8 @@
|
||||
#include <Tactility/app/App.h>
|
||||
#include "Tactility/Paths.h"
|
||||
|
||||
#include <Tactility/app/App.h>
|
||||
#include <Tactility/app/AppManifestParsing.h>
|
||||
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/app/AppRegistration.h>
|
||||
#include <Tactility/file/File.h>
|
||||
@@ -103,130 +105,105 @@ static bool untar(const std::string& tarPath, const std::string& destinationPath
|
||||
return success;
|
||||
}
|
||||
|
||||
bool findFirstMountedSdCardPath(std::string& path) {
|
||||
// const auto sdcards = hal::findDevices<hal::sdcard::SdCardDevice>(hal::Device::Type::SdCard);
|
||||
bool is_set = false;
|
||||
hal::findDevices<hal::sdcard::SdCardDevice>(hal::Device::Type::SdCard, [&is_set, &path](const auto& device) {
|
||||
if (device->isMounted()) {
|
||||
path = device->getMountPath();
|
||||
is_set = true;
|
||||
return false; // stop iterating
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return is_set;
|
||||
}
|
||||
|
||||
std::string getTempPath() {
|
||||
std::string root_path;
|
||||
if (!findFirstMountedSdCardPath(root_path)) {
|
||||
root_path = file::MOUNT_POINT_DATA;
|
||||
void cleanupInstallDirectory(const std::string& path) {
|
||||
const auto lock = file::getLock(path);
|
||||
lock->lock();
|
||||
if (!file::deleteRecursively(path)) {
|
||||
TT_LOG_W(TAG, "Failed to delete existing installation at %s", path.c_str());
|
||||
}
|
||||
return root_path + "/tmp";
|
||||
}
|
||||
|
||||
std::string getInstallPath() {
|
||||
std::string root_path;
|
||||
if (!findFirstMountedSdCardPath(root_path)) {
|
||||
root_path = file::MOUNT_POINT_DATA;
|
||||
}
|
||||
return root_path + "/apps";
|
||||
lock->unlock();
|
||||
}
|
||||
|
||||
bool install(const std::string& path) {
|
||||
// TODO: Make better: lock for each path type properly (source vs target)
|
||||
|
||||
// We lock and unlock frequently because SPI SD card devices share
|
||||
// the lock with the display. We don't want to lock the display for very long.
|
||||
|
||||
auto app_parent_path = getInstallPath();
|
||||
auto app_parent_path = getAppInstallPath();
|
||||
TT_LOG_I(TAG, "Installing app %s to %s", path.c_str(), app_parent_path.c_str());
|
||||
|
||||
auto lock = file::getLock(app_parent_path)->asScopedLock();
|
||||
auto target_path_lock = file::getLock(app_parent_path)->asScopedLock();
|
||||
|
||||
lock.lock();
|
||||
target_path_lock.lock();
|
||||
auto filename = file::getLastPathSegment(path);
|
||||
const std::string app_target_path = std::format("{}/{}", app_parent_path, filename);
|
||||
if (file::isDirectory(app_target_path) && !file::deleteRecursively(app_target_path)) {
|
||||
TT_LOG_W(TAG, "Failed to delete %s", app_target_path.c_str());
|
||||
}
|
||||
lock.unlock();
|
||||
target_path_lock.unlock();
|
||||
|
||||
lock.lock();
|
||||
target_path_lock.lock();
|
||||
if (!file::findOrCreateDirectory(app_target_path, 0777)) {
|
||||
TT_LOG_I(TAG, "Failed to create directory %s", app_target_path.c_str());
|
||||
return false;
|
||||
}
|
||||
lock.unlock();
|
||||
target_path_lock.unlock();
|
||||
|
||||
lock.lock();
|
||||
auto source_path_lock = file::getLock(path)->asScopedLock();
|
||||
target_path_lock.lock();
|
||||
source_path_lock.lock();
|
||||
TT_LOG_I(TAG, "Extracting app from %s to %s", path.c_str(), app_target_path.c_str());
|
||||
if (!untar(path, app_target_path)) {
|
||||
TT_LOG_E(TAG, "Failed to extract");
|
||||
return false;
|
||||
}
|
||||
lock.unlock();
|
||||
source_path_lock.unlock();
|
||||
target_path_lock.unlock();
|
||||
|
||||
lock.lock();
|
||||
target_path_lock.lock();
|
||||
auto manifest_path = app_target_path + "/manifest.properties";
|
||||
if (!file::isFile(manifest_path)) {
|
||||
TT_LOG_E(TAG, "Manifest not found at %s", manifest_path.c_str());
|
||||
cleanupInstallDirectory(app_target_path);
|
||||
return false;
|
||||
}
|
||||
lock.unlock();
|
||||
target_path_lock.unlock();
|
||||
|
||||
lock.lock();
|
||||
target_path_lock.lock();
|
||||
std::map<std::string, std::string> properties;
|
||||
if (!file::loadPropertiesFile(manifest_path, properties)) {
|
||||
TT_LOG_E(TAG, "Failed to load manifest at %s", manifest_path.c_str());
|
||||
cleanupInstallDirectory(app_target_path);
|
||||
return false;
|
||||
}
|
||||
lock.unlock();
|
||||
target_path_lock.unlock();
|
||||
|
||||
auto app_id_iterator = properties.find("[app]id");
|
||||
if (app_id_iterator == properties.end()) {
|
||||
TT_LOG_E(TAG, "Failed to find app id in manifest");
|
||||
AppManifest manifest;
|
||||
if (!parseManifest(properties, manifest)) {
|
||||
TT_LOG_W(TAG, "Invalid manifest");
|
||||
cleanupInstallDirectory(app_target_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto app_name_entry = properties.find("[app]name");
|
||||
if (app_name_entry == properties.end()) {
|
||||
TT_LOG_E(TAG, "Failed to find app name in manifest");
|
||||
return false;
|
||||
}
|
||||
|
||||
lock.lock();
|
||||
const std::string renamed_target_path = std::format("{}/{}", app_parent_path, app_id_iterator->second);
|
||||
target_path_lock.lock();
|
||||
const std::string renamed_target_path = std::format("{}/{}", app_parent_path, manifest.appId);
|
||||
if (file::isDirectory(renamed_target_path)) {
|
||||
if (!file::deleteRecursively(renamed_target_path)) {
|
||||
TT_LOG_W(TAG, "Failed to delete existing installation at %s", renamed_target_path.c_str());
|
||||
cleanupInstallDirectory(app_target_path);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
lock.unlock();
|
||||
target_path_lock.unlock();
|
||||
|
||||
lock.lock();
|
||||
target_path_lock.lock();
|
||||
if (rename(app_target_path.c_str(), renamed_target_path.c_str()) != 0) {
|
||||
TT_LOG_E(TAG, "Failed to rename %s to %s", app_target_path.c_str(), app_id_iterator->second.c_str());
|
||||
TT_LOG_E(TAG, "Failed to rename \"%s\" to \"%s\"", app_target_path.c_str(), manifest.appId.c_str());
|
||||
cleanupInstallDirectory(app_target_path);
|
||||
return false;
|
||||
}
|
||||
lock.unlock();
|
||||
target_path_lock.unlock();
|
||||
|
||||
addApp({
|
||||
.id = app_id_iterator->second,
|
||||
.name = app_name_entry->second,
|
||||
.category = Category::User,
|
||||
.location = Location::external(renamed_target_path)
|
||||
});
|
||||
manifest.appLocation = Location::external(renamed_target_path);
|
||||
|
||||
addApp(manifest);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool uninstall(const std::string& appId) {
|
||||
TT_LOG_I(TAG, "Uninstalling app %s", appId.c_str());
|
||||
auto app_path = getInstallPath() + "/" + appId;
|
||||
return file::withLock<bool>(app_path, [&app_path, &appId]() {
|
||||
auto app_path = getAppInstallPath(appId);
|
||||
return file::withLock<bool>(app_path, [&app_path, &appId] {
|
||||
if (!file::isDirectory(app_path)) {
|
||||
TT_LOG_E(TAG, "App %s not found at ", app_path.c_str());
|
||||
return false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Tactility/app/AppInstance.h"
|
||||
#include "Tactility/app/AppInstancePaths.h"
|
||||
#include <Tactility/app/AppInstance.h>
|
||||
#include <Tactility/app/AppPaths.h>
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
@@ -49,9 +49,9 @@ std::shared_ptr<const Bundle> AppInstance::getParameters() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::unique_ptr<Paths> AppInstance::getPaths() const {
|
||||
std::unique_ptr<AppPaths> AppInstance::getPaths() const {
|
||||
assert(manifest != nullptr);
|
||||
return std::make_unique<AppInstancePaths>(*manifest);
|
||||
return std::make_unique<AppPaths>(*manifest);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
#include "Tactility/app/AppInstancePaths.h"
|
||||
|
||||
#include <Tactility/MountPoints.h>
|
||||
|
||||
#define LVGL_PATH_PREFIX std::string("A:/")
|
||||
#ifdef ESP_PLATFORM
|
||||
#define PARTITION_PREFIX std::string("/")
|
||||
#else
|
||||
#define PARTITION_PREFIX std::string("")
|
||||
#endif
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
std::string AppInstancePaths::getDataDirectory() const {
|
||||
return PARTITION_PREFIX + file::DATA_PARTITION_NAME + "/app/" + manifest.id;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getDataDirectoryLvgl() const {
|
||||
return LVGL_PATH_PREFIX + file::DATA_PARTITION_NAME + "/app/" + manifest.id;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getDataPath(const std::string& childPath) const {
|
||||
assert(!childPath.starts_with('/'));
|
||||
return PARTITION_PREFIX + file::DATA_PARTITION_NAME + "/app/" + manifest.id + '/' + childPath;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getDataPathLvgl(const std::string& childPath) const {
|
||||
assert(!childPath.starts_with('/'));
|
||||
return LVGL_PATH_PREFIX + file::DATA_PARTITION_NAME + "/app/" + manifest.id + '/' + childPath;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getSystemDirectory() const {
|
||||
return PARTITION_PREFIX + file::SYSTEM_PARTITION_NAME + "/app/" + manifest.id;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getSystemDirectoryLvgl() const {
|
||||
return LVGL_PATH_PREFIX + file::SYSTEM_PARTITION_NAME + "/app/" + manifest.id;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getSystemPath(const std::string& childPath) const {
|
||||
assert(!childPath.starts_with('/'));
|
||||
return PARTITION_PREFIX + file::SYSTEM_PARTITION_NAME + "/app/" + manifest.id + '/' + childPath;
|
||||
}
|
||||
|
||||
std::string AppInstancePaths::getSystemPathLvgl(const std::string& childPath) const {
|
||||
return LVGL_PATH_PREFIX + file::SYSTEM_PARTITION_NAME + "/app/" + manifest.id + '/' + childPath;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
#include <Tactility/app/AppManifestParsing.h>
|
||||
|
||||
#include <regex>
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
constexpr auto* TAG = "App";
|
||||
|
||||
static bool validateString(const std::string& value, const std::function<bool(const char)>& isValidChar) {
|
||||
for (const auto& c : value) {
|
||||
if (!isValidChar(c)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool getValueFromManifest(const std::map<std::string, std::string>& map, const std::string& key, std::string& output) {
|
||||
const auto iterator = map.find(key);
|
||||
if (iterator == map.end()) {
|
||||
TT_LOG_E(TAG, "Failed to find %s in manifest", key.c_str());
|
||||
return false;
|
||||
}
|
||||
output = iterator->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isValidId(const std::string& id) {
|
||||
return id.size() >= 5 && validateString(id, [](const char c) {
|
||||
return std::isalnum(c) != 0 || c == '.';
|
||||
});
|
||||
}
|
||||
|
||||
static bool isValidManifestVersion(const std::string& version) {
|
||||
return version.size() > 0 && validateString(version, [](const char c) {
|
||||
return std::isalnum(c) != 0 || c == '.';
|
||||
});
|
||||
}
|
||||
|
||||
static bool isValidAppVersionName(const std::string& version) {
|
||||
return version.size() > 0 && validateString(version, [](const char c) {
|
||||
return std::isalnum(c) != 0 || c == '.' || c == '-' || c == '_';
|
||||
});
|
||||
}
|
||||
|
||||
static bool isValidAppVersionCode(const std::string& version) {
|
||||
return version.size() > 0 && validateString(version, [](const char c) {
|
||||
return std::isdigit(c) != 0;
|
||||
});
|
||||
}
|
||||
|
||||
static bool isValidName(const std::string& name) {
|
||||
return name.size() >= 2 && validateString(name, [](const char c) {
|
||||
return std::isalnum(c) != 0 || c == ' ' || c == '-';
|
||||
});
|
||||
}
|
||||
|
||||
bool parseManifest(const std::map<std::string, std::string>& map, AppManifest& manifest) {
|
||||
TT_LOG_I(TAG, "Parsing manifest");
|
||||
|
||||
// [manifest]
|
||||
|
||||
if (!getValueFromManifest(map, "[manifest]version", manifest.manifestVersion)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isValidManifestVersion(manifest.manifestVersion)) {
|
||||
TT_LOG_E(TAG, "Invalid version");
|
||||
return false;
|
||||
}
|
||||
|
||||
// [app]
|
||||
|
||||
if (!getValueFromManifest(map, "[app]id", manifest.appId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isValidId(manifest.appId)) {
|
||||
TT_LOG_E(TAG, "Invalid app id");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getValueFromManifest(map, "[app]name", manifest.appName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isValidName(manifest.appName)) {
|
||||
TT_LOG_I(TAG, "Invalid app name");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getValueFromManifest(map, "[app]versionName", manifest.appVersionName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isValidAppVersionName(manifest.appVersionName)) {
|
||||
TT_LOG_E(TAG, "Invalid app version name");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string version_code_string;
|
||||
if (!getValueFromManifest(map, "[app]versionCode", version_code_string)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isValidAppVersionCode(version_code_string)) {
|
||||
TT_LOG_E(TAG, "Invalid app version code");
|
||||
return false;
|
||||
}
|
||||
|
||||
manifest.appVersionCode = std::stoull(version_code_string);
|
||||
|
||||
// [target]
|
||||
|
||||
if (!getValueFromManifest(map, "[target]sdk", manifest.targetSdk)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getValueFromManifest(map, "[target]platforms", manifest.targetPlatforms)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Defaults
|
||||
|
||||
manifest.appCategory = Category::User;
|
||||
manifest.appLocation = Location::external("");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#include <Tactility/app/AppPaths.h>
|
||||
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/file/File.h>
|
||||
|
||||
#include <format>
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
constexpr auto PARTITION_PREFIX = std::string("/");
|
||||
#else
|
||||
constexpr auto PARTITION_PREFIX = std::string("");
|
||||
#endif
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
std::string AppPaths::getUserDataPath() const {
|
||||
if (manifest.appLocation.isInternal()) {
|
||||
return std::format("{}{}/user/app/{}", PARTITION_PREFIX, file::DATA_PARTITION_NAME, manifest.appId);
|
||||
} else {
|
||||
return std::format("{}/user/app/{}", file::getFirstPathSegment(manifest.appLocation.getPath()), manifest.appId);
|
||||
}
|
||||
}
|
||||
|
||||
std::string AppPaths::getUserDataPath(const std::string& childPath) const {
|
||||
assert(!childPath.starts_with('/'));
|
||||
return std::format("{}/{}", getUserDataPath(), childPath);
|
||||
}
|
||||
|
||||
|
||||
std::string AppPaths::getAssetsDirectory() const {
|
||||
if (manifest.appLocation.isInternal()) {
|
||||
return std::format("{}{}/app/{}/assets", PARTITION_PREFIX, file::SYSTEM_PARTITION_NAME, manifest.appId);
|
||||
} else {
|
||||
return std::format("{}/assets", manifest.appLocation.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
std::string AppPaths::getAssetsPath(const std::string& childPath) const {
|
||||
assert(!childPath.starts_with('/'));
|
||||
return std::format("{}/{}", getAssetsDirectory(), childPath);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,15 +16,15 @@ static AppManifestMap app_manifest_map;
|
||||
static Mutex hash_mutex(Mutex::Type::Normal);
|
||||
|
||||
void addApp(const AppManifest& manifest) {
|
||||
TT_LOG_I(TAG, "Registering manifest %s", manifest.id.c_str());
|
||||
TT_LOG_I(TAG, "Registering manifest %s", manifest.appId.c_str());
|
||||
|
||||
hash_mutex.lock();
|
||||
|
||||
if (app_manifest_map.contains(manifest.id)) {
|
||||
TT_LOG_W(TAG, "Overwriting existing manifest for %s", manifest.id.c_str());
|
||||
if (app_manifest_map.contains(manifest.appId)) {
|
||||
TT_LOG_W(TAG, "Overwriting existing manifest for %s", manifest.appId.c_str());
|
||||
}
|
||||
|
||||
app_manifest_map[manifest.id] = std::make_shared<AppManifest>(manifest);
|
||||
app_manifest_map[manifest.appId] = std::make_shared<AppManifest>(manifest);
|
||||
|
||||
hash_mutex.unlock();
|
||||
}
|
||||
|
||||
@@ -223,8 +223,8 @@ void setElfAppParameters(
|
||||
std::shared_ptr<App> createElfApp(const std::shared_ptr<AppManifest>& manifest) {
|
||||
TT_LOG_I(TAG, "createElfApp");
|
||||
assert(manifest != nullptr);
|
||||
assert(manifest->location.isExternal());
|
||||
return std::make_shared<ElfApp>(manifest->location.getPath());
|
||||
assert(manifest->appLocation.isExternal());
|
||||
return std::make_shared<ElfApp>(manifest->appLocation.getPath());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -172,16 +172,16 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "AddGps",
|
||||
.name = "Add GPS",
|
||||
.icon = LV_SYMBOL_GPS,
|
||||
.category = Category::System,
|
||||
.flags = AppManifest::Flags::Hidden,
|
||||
.appId = "AddGps",
|
||||
.appName = "Add GPS",
|
||||
.appIcon = LV_SYMBOL_GPS,
|
||||
.appCategory = Category::System,
|
||||
.appFlags = AppManifest::Flags::Hidden,
|
||||
.createApp = create<AddGpsApp>
|
||||
};
|
||||
|
||||
void start() {
|
||||
app::start(manifest.id);
|
||||
app::start(manifest.appId);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -28,7 +28,7 @@ LaunchId start(const std::string& title, const std::string& message, const std::
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_TITLE, title);
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_MESSAGE, message);
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_BUTTON_LABELS, items_joined);
|
||||
return service::loader::startApp(manifest.id, bundle);
|
||||
return service::loader::startApp(manifest.appId, bundle);
|
||||
}
|
||||
|
||||
LaunchId start(const std::string& title, const std::string& message) {
|
||||
@@ -36,7 +36,7 @@ LaunchId start(const std::string& title, const std::string& message) {
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_TITLE, title);
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_MESSAGE, message);
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_BUTTON_LABELS, "OK");
|
||||
return service::loader::startApp(manifest.id, bundle);
|
||||
return service::loader::startApp(manifest.appId, bundle);
|
||||
}
|
||||
|
||||
int32_t getResultIndex(const Bundle& bundle) {
|
||||
@@ -126,10 +126,10 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "AlertDialog",
|
||||
.name = "Alert Dialog",
|
||||
.category = Category::System,
|
||||
.flags = AppManifest::Flags::Hidden,
|
||||
.appId = "AlertDialog",
|
||||
.appName = "Alert Dialog",
|
||||
.appCategory = Category::System,
|
||||
.appFlags = AppManifest::Flags::Hidden,
|
||||
.createApp = create<AlertDialogApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -13,12 +13,12 @@ class AppListApp : public App {
|
||||
|
||||
static void onAppPressed(lv_event_t* e) {
|
||||
const auto* manifest = static_cast<const AppManifest*>(lv_event_get_user_data(e));
|
||||
service::loader::startApp(manifest->id);
|
||||
service::loader::startApp(manifest->appId);
|
||||
}
|
||||
|
||||
static void createAppWidget(const std::shared_ptr<AppManifest>& manifest, lv_obj_t* list) {
|
||||
const void* icon = !manifest->icon.empty() ? manifest->icon.c_str() : TT_ASSETS_APP_ICON_FALLBACK;
|
||||
lv_obj_t* btn = lv_list_add_button(list, icon, manifest->name.c_str());
|
||||
const void* icon = !manifest->appIcon.empty() ? manifest->appIcon.c_str() : TT_ASSETS_APP_ICON_FALLBACK;
|
||||
lv_obj_t* btn = lv_list_add_button(list, icon, manifest->appName.c_str());
|
||||
lv_obj_add_event_cb(btn, &onAppPressed, LV_EVENT_SHORT_CLICKED, manifest.get());
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ public:
|
||||
std::ranges::sort(manifests, SortAppManifestByName);
|
||||
|
||||
for (const auto& manifest: manifests) {
|
||||
bool is_valid_category = (manifest->category == Category::User) || (manifest->category == Category::System);
|
||||
bool is_visible = (manifest->flags & AppManifest::Flags::Hidden) == 0u;
|
||||
bool is_valid_category = (manifest->appCategory == Category::User) || (manifest->appCategory == Category::System);
|
||||
bool is_visible = (manifest->appFlags & AppManifest::Flags::Hidden) == 0u;
|
||||
if (is_valid_category && is_visible) {
|
||||
createAppWidget(manifest, list);
|
||||
}
|
||||
@@ -50,10 +50,10 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "AppList",
|
||||
.name = "Apps",
|
||||
.category = Category::System,
|
||||
.flags = AppManifest::Flags::Hidden,
|
||||
.appId = "AppList",
|
||||
.appName = "Apps",
|
||||
.appCategory = Category::System,
|
||||
.appFlags = AppManifest::Flags::Hidden,
|
||||
.createApp = create<AppListApp>,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <Tactility/TactilityPrivate.h>
|
||||
#include <Tactility/app/AppContext.h>
|
||||
#include <Tactility/app/AppPaths.h>
|
||||
#include <Tactility/CpuAffinity.h>
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
#include <Tactility/hal/usb/Usb.h>
|
||||
@@ -163,21 +164,21 @@ public:
|
||||
const char* logo;
|
||||
// TODO: Replace with automatic asset buckets like on Android
|
||||
if (getSmallestDimension() < 150) { // e.g. Cardputer
|
||||
logo = hal::usb::isUsbBootMode() ? "assets/logo_usb.png" : "assets/logo_small.png";
|
||||
logo = hal::usb::isUsbBootMode() ? "logo_usb.png" : "logo_small.png";
|
||||
} else {
|
||||
logo = hal::usb::isUsbBootMode() ? "assets/logo_usb.png" : "assets/logo.png";
|
||||
logo = hal::usb::isUsbBootMode() ? "logo_usb.png" : "logo.png";
|
||||
}
|
||||
const auto logo_path = paths->getSystemPathLvgl(logo);
|
||||
const auto logo_path = "A:" + paths->getAssetsPath(logo);
|
||||
TT_LOG_I(TAG, "%s", logo_path.c_str());
|
||||
lv_image_set_src(image, logo_path.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "Boot",
|
||||
.name = "Boot",
|
||||
.category = Category::System,
|
||||
.flags = AppManifest::Flags::HideStatusBar | AppManifest::Flags::Hidden,
|
||||
.appId = "Boot",
|
||||
.appName = "Boot",
|
||||
.appCategory = Category::System,
|
||||
.appFlags = AppManifest::Flags::HideStatusBar | AppManifest::Flags::Hidden,
|
||||
.createApp = create<BootApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -224,9 +224,9 @@ class CalculatorApp : public App {
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "Calculator",
|
||||
.name = "Calculator",
|
||||
.icon = TT_ASSETS_APP_ICON_CALCULATOR,
|
||||
.appId = "Calculator",
|
||||
.appName = "Calculator",
|
||||
.appIcon = TT_ASSETS_APP_ICON_CALCULATOR,
|
||||
.createApp = create<CalculatorApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -136,9 +136,9 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "Chat",
|
||||
.name = "Chat",
|
||||
.icon = TT_ASSETS_APP_ICON_CHAT,
|
||||
.appId = "Chat",
|
||||
.appName = "Chat",
|
||||
.appIcon = TT_ASSETS_APP_ICON_CHAT,
|
||||
.createApp = create<ChatApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -122,15 +122,15 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "CrashDiagnostics",
|
||||
.name = "Crash Diagnostics",
|
||||
.category = Category::System,
|
||||
.flags = AppManifest::Flags::Hidden,
|
||||
.appId = "CrashDiagnostics",
|
||||
.appName = "Crash Diagnostics",
|
||||
.appCategory = Category::System,
|
||||
.appFlags = AppManifest::Flags::Hidden,
|
||||
.createApp = create<CrashDiagnosticsApp>
|
||||
};
|
||||
|
||||
void start() {
|
||||
service::loader::startApp(manifest.id);
|
||||
service::loader::startApp(manifest.appId);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -160,14 +160,14 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "Development",
|
||||
.name = "Development",
|
||||
.category = Category::Settings,
|
||||
.appId = "Development",
|
||||
.appName = "Development",
|
||||
.appCategory = Category::Settings,
|
||||
.createApp = create<DevelopmentApp>
|
||||
};
|
||||
|
||||
void start() {
|
||||
app::start(manifest.id);
|
||||
app::start(manifest.appId);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -164,10 +164,10 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "Display",
|
||||
.name = "Display",
|
||||
.icon = TT_ASSETS_APP_ICON_DISPLAY_SETTINGS,
|
||||
.category = Category::Settings,
|
||||
.appId = "Display",
|
||||
.appName = "Display",
|
||||
.appIcon = TT_ASSETS_APP_ICON_DISPLAY_SETTINGS,
|
||||
.appCategory = Category::Settings,
|
||||
.createApp = create<DisplayApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -33,16 +33,16 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "Files",
|
||||
.name = "Files",
|
||||
.icon = TT_ASSETS_APP_ICON_FILES,
|
||||
.category = Category::System,
|
||||
.flags = AppManifest::Flags::Hidden,
|
||||
.appId = "Files",
|
||||
.appName = "Files",
|
||||
.appIcon = TT_ASSETS_APP_ICON_FILES,
|
||||
.appCategory = Category::System,
|
||||
.appFlags = AppManifest::Flags::Hidden,
|
||||
.createApp = create<FilesApp>
|
||||
};
|
||||
|
||||
void start() {
|
||||
service::loader::startApp(manifest.id);
|
||||
service::loader::startApp(manifest.appId);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -56,24 +56,24 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "FileSelection",
|
||||
.name = "File Selection",
|
||||
.icon = TT_ASSETS_APP_ICON_FILES,
|
||||
.category = Category::System,
|
||||
.flags = AppManifest::Flags::Hidden,
|
||||
.appId = "FileSelection",
|
||||
.appName = "File Selection",
|
||||
.appIcon = TT_ASSETS_APP_ICON_FILES,
|
||||
.appCategory = Category::System,
|
||||
.appFlags = AppManifest::Flags::Hidden,
|
||||
.createApp = create<FileSelection>
|
||||
};
|
||||
|
||||
LaunchId startForExistingFile() {
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
setMode(*bundle, Mode::Existing);
|
||||
return service::loader::startApp(manifest.id, bundle);
|
||||
return service::loader::startApp(manifest.appId, bundle);
|
||||
}
|
||||
|
||||
LaunchId startForExistingOrNewFile() {
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
setMode(*bundle, Mode::ExistingOrNew);
|
||||
return service::loader::startApp(manifest.id, bundle);
|
||||
return service::loader::startApp(manifest.appId, bundle);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -188,10 +188,10 @@ void GpioApp::onHide(AppContext& app) {
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "Gpio",
|
||||
.name = "GPIO",
|
||||
.icon = TT_ASSETS_APP_ICON_GPIO,
|
||||
.category = Category::System,
|
||||
.appId = "Gpio",
|
||||
.appName = "GPIO",
|
||||
.appIcon = TT_ASSETS_APP_ICON_GPIO,
|
||||
.appCategory = Category::System,
|
||||
.createApp = create<GpioApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ class GpsSettingsApp final : public App {
|
||||
}
|
||||
|
||||
void onAddGps() {
|
||||
app::start(addgps::manifest.id);
|
||||
app::start(addgps::manifest.appId);
|
||||
}
|
||||
|
||||
void startReceivingUpdates() {
|
||||
@@ -344,15 +344,15 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "GpsSettings",
|
||||
.name = "GPS",
|
||||
.icon = LV_SYMBOL_GPS,
|
||||
.category = Category::Settings,
|
||||
.appId = "GpsSettings",
|
||||
.appName = "GPS",
|
||||
.appIcon = LV_SYMBOL_GPS,
|
||||
.appCategory = Category::Settings,
|
||||
.createApp = create<GpsSettingsApp>
|
||||
};
|
||||
|
||||
void start() {
|
||||
app::start(manifest.id);
|
||||
app::start(manifest.appId);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
/** Returns the app data if the app is active. Note that this could clash if the same app is started twice and a background thread is slow. */
|
||||
std::shared_ptr<I2cScannerApp> _Nullable optApp() {
|
||||
auto appContext = getCurrentAppContext();
|
||||
if (appContext != nullptr && appContext->getManifest().id == manifest.id) {
|
||||
if (appContext != nullptr && appContext->getManifest().appId == manifest.appId) {
|
||||
return std::static_pointer_cast<I2cScannerApp>(appContext->getApp());
|
||||
} else {
|
||||
return nullptr;
|
||||
@@ -403,15 +403,15 @@ void I2cScannerApp::onScanTimerFinished() {
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "I2cScanner",
|
||||
.name = "I2C Scanner",
|
||||
.icon = TT_ASSETS_APP_ICON_I2C_SETTINGS,
|
||||
.category = Category::System,
|
||||
.appId = "I2cScanner",
|
||||
.appName = "I2C Scanner",
|
||||
.appIcon = TT_ASSETS_APP_ICON_I2C_SETTINGS,
|
||||
.appCategory = Category::System,
|
||||
.createApp = create<I2cScannerApp>
|
||||
};
|
||||
|
||||
void start() {
|
||||
service::loader::startApp(manifest.id);
|
||||
service::loader::startApp(manifest.appId);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -93,10 +93,10 @@ class I2cSettingsApp : public App {
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "I2cSettings",
|
||||
.name = "I2C",
|
||||
.icon = TT_ASSETS_APP_ICON_I2C_SETTINGS,
|
||||
.category = Category::Settings,
|
||||
.appId = "I2cSettings",
|
||||
.appName = "I2C",
|
||||
.appIcon = TT_ASSETS_APP_ICON_I2C_SETTINGS,
|
||||
.appCategory = Category::Settings,
|
||||
.createApp = create<I2cSettingsApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -60,17 +60,17 @@ class ImageViewerApp : public App {
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "ImageViewer",
|
||||
.name = "Image Viewer",
|
||||
.category = Category::System,
|
||||
.flags = AppManifest::Flags::Hidden,
|
||||
.appId = "ImageViewer",
|
||||
.appName = "Image Viewer",
|
||||
.appCategory = Category::System,
|
||||
.appFlags = AppManifest::Flags::Hidden,
|
||||
.createApp = create<ImageViewerApp>
|
||||
};
|
||||
|
||||
void start(const std::string& file) {
|
||||
auto parameters = std::make_shared<Bundle>();
|
||||
parameters->putString(IMAGE_VIEWER_FILE_ARGUMENT, file);
|
||||
service::loader::startApp(manifest.id, parameters);
|
||||
service::loader::startApp(manifest.appId, parameters);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -26,7 +26,7 @@ void start(const std::string& title, const std::string& message, const std::stri
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_TITLE, title);
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_MESSAGE, message);
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_PREFILLED, prefilled);
|
||||
service::loader::startApp(manifest.id, bundle);
|
||||
service::loader::startApp(manifest.appId, bundle);
|
||||
}
|
||||
|
||||
std::string getResult(const Bundle& bundle) {
|
||||
@@ -118,10 +118,10 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "InputDialog",
|
||||
.name = "Input Dialog",
|
||||
.category = Category::System,
|
||||
.flags = AppManifest::Flags::Hidden,
|
||||
.appId = "InputDialog",
|
||||
.appName = "Input Dialog",
|
||||
.appCategory = Category::System,
|
||||
.appFlags = AppManifest::Flags::Hidden,
|
||||
.createApp = create<InputDialogApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <Tactility/Tactility.h>
|
||||
|
||||
#include <Tactility/app/AppContext.h>
|
||||
#include <Tactility/app/AppPaths.h>
|
||||
#include <Tactility/app/AppRegistration.h>
|
||||
#include <Tactility/hal/power/PowerDevice.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
@@ -112,9 +113,9 @@ public:
|
||||
const int32_t margin = is_landscape_display ? std::min<int32_t>(available_width / 16, button_size) : 0;
|
||||
|
||||
const auto paths = app.getPaths();
|
||||
const auto apps_icon_path = paths->getSystemPathLvgl("assets/icon_apps.png");
|
||||
const auto files_icon_path = paths->getSystemPathLvgl("assets/icon_files.png");
|
||||
const auto settings_icon_path = paths->getSystemPathLvgl("assets/icon_settings.png");
|
||||
const auto apps_icon_path = "A:" + paths->getAssetsPath("icon_apps.png");
|
||||
const auto files_icon_path = "A:" + paths->getAssetsPath("icon_files.png");
|
||||
const auto settings_icon_path = "A:" + paths->getAssetsPath("icon_settings.png");
|
||||
|
||||
createAppButton(buttons_wrapper, ui_scale, apps_icon_path.c_str(), "AppList", margin);
|
||||
createAppButton(buttons_wrapper, ui_scale, files_icon_path.c_str(), "Files", margin);
|
||||
@@ -136,14 +137,15 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "Launcher",
|
||||
.name = "Launcher",
|
||||
.category = Category::System,
|
||||
.appId = "Launcher",
|
||||
.appName = "Launcher",
|
||||
.appCategory = Category::System,
|
||||
.appFlags = AppManifest::Flags::Hidden,
|
||||
.createApp = create<LauncherApp>
|
||||
};
|
||||
|
||||
void start() {
|
||||
service::loader::startApp(manifest.id);
|
||||
service::loader::startApp(manifest.appId);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -162,15 +162,15 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "LocaleSettings",
|
||||
.name = "Region & Language",
|
||||
.icon = TT_ASSETS_APP_ICON_TIME_DATE_SETTINGS,
|
||||
.category = Category::Settings,
|
||||
.appId = "LocaleSettings",
|
||||
.appName = "Region & Language",
|
||||
.appIcon = TT_ASSETS_APP_ICON_TIME_DATE_SETTINGS,
|
||||
.appCategory = Category::Settings,
|
||||
.createApp = create<LocaleSettingsApp>
|
||||
};
|
||||
|
||||
void start() {
|
||||
service::loader::startApp(manifest.id);
|
||||
service::loader::startApp(manifest.appId);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -120,10 +120,10 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "Log",
|
||||
.name = "Log",
|
||||
.icon = LV_SYMBOL_LIST,
|
||||
.category = Category::System,
|
||||
.appId = "Log",
|
||||
.appName = "Log",
|
||||
.appIcon = LV_SYMBOL_LIST,
|
||||
.appCategory = Category::System,
|
||||
.createApp = create<LogApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -207,15 +207,15 @@ class NotesApp : public App {
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "Notes",
|
||||
.name = "Notes",
|
||||
.icon = TT_ASSETS_APP_ICON_NOTES,
|
||||
.appId = "Notes",
|
||||
.appName = "Notes",
|
||||
.appIcon = TT_ASSETS_APP_ICON_NOTES,
|
||||
.createApp = create<NotesApp>
|
||||
};
|
||||
|
||||
void start(const std::string& filePath) {
|
||||
auto parameters = std::make_shared<Bundle>();
|
||||
parameters->putString(NOTES_FILE_ARGUMENT, filePath);
|
||||
service::loader::startApp(manifest.id, parameters);
|
||||
service::loader::startApp(manifest.appId, parameters);
|
||||
}
|
||||
} // namespace tt::app::notes
|
||||
@@ -22,7 +22,7 @@ class PowerApp;
|
||||
/** Returns the app data if the app is active. Note that this could clash if the same app is started twice and a background thread is slow. */
|
||||
std::shared_ptr<PowerApp> _Nullable optApp() {
|
||||
auto appContext = getCurrentAppContext();
|
||||
if (appContext != nullptr && appContext->getManifest().id == manifest.id) {
|
||||
if (appContext != nullptr && appContext->getManifest().appId == manifest.appId) {
|
||||
return std::static_pointer_cast<PowerApp>(appContext->getApp());
|
||||
} else {
|
||||
return nullptr;
|
||||
@@ -189,10 +189,10 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "Power",
|
||||
.name = "Power",
|
||||
.icon = TT_ASSETS_APP_ICON_POWER_SETTINGS,
|
||||
.category = Category::Settings,
|
||||
.appId = "Power",
|
||||
.appName = "Power",
|
||||
.appIcon = TT_ASSETS_APP_ICON_POWER_SETTINGS,
|
||||
.appCategory = Category::Settings,
|
||||
.createApp = create<PowerApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
/** Returns the app data if the app is active. Note that this could clash if the same app is started twice and a background thread is slow. */
|
||||
std::shared_ptr<ScreenshotApp> _Nullable optApp() {
|
||||
auto appContext = getCurrentAppContext();
|
||||
if (appContext != nullptr && appContext->getManifest().id == manifest.id) {
|
||||
if (appContext != nullptr && appContext->getManifest().appId == manifest.appId) {
|
||||
return std::static_pointer_cast<ScreenshotApp>(appContext->getApp());
|
||||
} else {
|
||||
return nullptr;
|
||||
@@ -278,10 +278,10 @@ void ScreenshotApp::onShow(AppContext& appContext, lv_obj_t* parent) {
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "Screenshot",
|
||||
.name = "Screenshot",
|
||||
.icon = LV_SYMBOL_IMAGE,
|
||||
.category = Category::System,
|
||||
.appId = "Screenshot",
|
||||
.appName = "Screenshot",
|
||||
.appIcon = LV_SYMBOL_IMAGE,
|
||||
.appCategory = Category::System,
|
||||
.createApp = create<ScreenshotApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ void start(const std::string& title, const std::vector<std::string>& items) {
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_TITLE, title);
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_ITEMS, items_joined);
|
||||
service::loader::startApp(manifest.id, bundle);
|
||||
service::loader::startApp(manifest.appId, bundle);
|
||||
}
|
||||
|
||||
int32_t getResultIndex(const Bundle& bundle) {
|
||||
@@ -112,10 +112,10 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "SelectionDialog",
|
||||
.name = "Selection Dialog",
|
||||
.category = Category::System,
|
||||
.flags = AppManifest::Flags::Hidden,
|
||||
.appId = "SelectionDialog",
|
||||
.appName = "Selection Dialog",
|
||||
.appCategory = Category::System,
|
||||
.appFlags = AppManifest::Flags::Hidden,
|
||||
.createApp = create<SelectionDialogApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -85,10 +85,10 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "SerialConsole",
|
||||
.name = "Serial Console",
|
||||
.icon = LV_SYMBOL_LIST,
|
||||
.category = Category::System,
|
||||
.appId = "SerialConsole",
|
||||
.appName = "Serial Console",
|
||||
.appIcon = LV_SYMBOL_LIST,
|
||||
.appCategory = Category::System,
|
||||
.createApp = create<SerialConsoleApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -12,14 +12,14 @@ namespace tt::app::settings {
|
||||
|
||||
static void onAppPressed(lv_event_t* e) {
|
||||
const auto* manifest = static_cast<const AppManifest*>(lv_event_get_user_data(e));
|
||||
service::loader::startApp(manifest->id);
|
||||
service::loader::startApp(manifest->appId);
|
||||
}
|
||||
|
||||
static void createWidget(const std::shared_ptr<AppManifest>& manifest, void* parent) {
|
||||
tt_check(parent);
|
||||
auto* list = (lv_obj_t*)parent;
|
||||
const void* icon = !manifest->icon.empty() ? manifest->icon.c_str() : TT_ASSETS_APP_ICON_FALLBACK;
|
||||
auto* btn = lv_list_add_button(list, icon, manifest->name.c_str());
|
||||
const void* icon = !manifest->appIcon.empty() ? manifest->appIcon.c_str() : TT_ASSETS_APP_ICON_FALLBACK;
|
||||
auto* btn = lv_list_add_button(list, icon, manifest->appName.c_str());
|
||||
lv_obj_add_event_cb(btn, &onAppPressed, LV_EVENT_SHORT_CLICKED, (void*)manifest.get());
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class SettingsApp : public App {
|
||||
auto manifests = getApps();
|
||||
std::sort(manifests.begin(), manifests.end(), SortAppManifestByName);
|
||||
for (const auto& manifest: manifests) {
|
||||
if (manifest->category == Category::Settings) {
|
||||
if (manifest->appCategory == Category::Settings) {
|
||||
createWidget(manifest, list);
|
||||
}
|
||||
}
|
||||
@@ -46,11 +46,11 @@ class SettingsApp : public App {
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "Settings",
|
||||
.name = "Settings",
|
||||
.icon = TT_ASSETS_APP_ICON_SETTINGS,
|
||||
.category = Category::System,
|
||||
.flags = AppManifest::Flags::Hidden,
|
||||
.appId = "Settings",
|
||||
.appName = "Settings",
|
||||
.appIcon = TT_ASSETS_APP_ICON_SETTINGS,
|
||||
.appCategory = Category::System,
|
||||
.appFlags = AppManifest::Flags::Hidden,
|
||||
.createApp = create<SettingsApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -292,10 +292,10 @@ class SystemInfoApp final : public App {
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "SystemInfo",
|
||||
.name = "System Info",
|
||||
.icon = TT_ASSETS_APP_ICON_SYSTEM_INFO,
|
||||
.category = Category::System,
|
||||
.appId = "SystemInfo",
|
||||
.appName = "System Info",
|
||||
.appIcon = TT_ASSETS_APP_ICON_SYSTEM_INFO,
|
||||
.appCategory = Category::System,
|
||||
.createApp = create<SystemInfoApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -57,15 +57,15 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "TimeDateSettings",
|
||||
.name = "Time & Date",
|
||||
.icon = TT_ASSETS_APP_ICON_TIME_DATE_SETTINGS,
|
||||
.category = Category::Settings,
|
||||
.appId = "TimeDateSettings",
|
||||
.appName = "Time & Date",
|
||||
.appIcon = TT_ASSETS_APP_ICON_TIME_DATE_SETTINGS,
|
||||
.appCategory = Category::Settings,
|
||||
.createApp = create<TimeDateSettingsApp>
|
||||
};
|
||||
|
||||
void start() {
|
||||
service::loader::startApp(manifest.id);
|
||||
service::loader::startApp(manifest.appId);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <Tactility/app/AppContext.h>
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/app/AppPaths.h>
|
||||
#include <Tactility/app/timezone/TimeZone.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
@@ -200,7 +201,7 @@ public:
|
||||
lv_obj_set_style_image_recolor_opa(icon, 255, 0);
|
||||
lv_obj_set_style_image_recolor(icon, lv_theme_get_color_primary(parent), 0);
|
||||
|
||||
std::string icon_path = app.getPaths()->getSystemPathLvgl("search.png");
|
||||
std::string icon_path = "A:" + app.getPaths()->getAssetsPath("search.png");
|
||||
lv_image_set_src(icon, icon_path.c_str());
|
||||
lv_obj_set_style_image_recolor(icon, lv_theme_get_color_primary(parent), 0);
|
||||
|
||||
@@ -226,15 +227,15 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "TimeZone",
|
||||
.name = "Select timezone",
|
||||
.category = Category::System,
|
||||
.flags = AppManifest::Flags::Hidden,
|
||||
.appId = "TimeZone",
|
||||
.appName = "Select timezone",
|
||||
.appCategory = Category::System,
|
||||
.appFlags = AppManifest::Flags::Hidden,
|
||||
.createApp = create<TimeZoneApp>
|
||||
};
|
||||
|
||||
void start() {
|
||||
service::loader::startApp(manifest.id);
|
||||
service::loader::startApp(manifest.appId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ class UsbSettingsApp : public App {
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "UsbSettings",
|
||||
.name = "USB",
|
||||
.icon = LV_SYMBOL_USB,
|
||||
.category = Category::Settings,
|
||||
.appId = "UsbSettings",
|
||||
.appName = "USB",
|
||||
.appIcon = LV_SYMBOL_USB,
|
||||
.appCategory = Category::Settings,
|
||||
.createApp = create<UsbSettingsApp>
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ extern const AppManifest manifest;
|
||||
void start(const std::string& ssid) {
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
bundle->putString("ssid", ssid);
|
||||
app::start(manifest.id, bundle);
|
||||
app::start(manifest.appId, bundle);
|
||||
}
|
||||
|
||||
class WifiApSettings : public App {
|
||||
@@ -241,11 +241,11 @@ public:
|
||||
};
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "WifiApSettings",
|
||||
.name = "Wi-Fi AP Settings",
|
||||
.icon = LV_SYMBOL_WIFI,
|
||||
.category = Category::System,
|
||||
.flags = AppManifest::Flags::Hidden,
|
||||
.appId = "WifiApSettings",
|
||||
.appName = "Wi-Fi AP Settings",
|
||||
.appIcon = LV_SYMBOL_WIFI,
|
||||
.appCategory = Category::System,
|
||||
.appFlags = AppManifest::Flags::Hidden,
|
||||
.createApp = create<WifiApSettings>
|
||||
};
|
||||
|
||||
|
||||
@@ -94,11 +94,11 @@ void WifiConnect::onHide(TT_UNUSED AppContext& app) {
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "WifiConnect",
|
||||
.name = "Wi-Fi Connect",
|
||||
.icon = LV_SYMBOL_WIFI,
|
||||
.category = Category::System,
|
||||
.flags = AppManifest::Flags::Hidden,
|
||||
.appId = "WifiConnect",
|
||||
.appName = "Wi-Fi Connect",
|
||||
.appIcon = LV_SYMBOL_WIFI,
|
||||
.appCategory = Category::System,
|
||||
.appFlags = AppManifest::Flags::Hidden,
|
||||
.createApp = create<WifiConnect>
|
||||
};
|
||||
|
||||
@@ -106,7 +106,7 @@ void start(const std::string& ssid, const std::string& password) {
|
||||
auto parameters = std::make_shared<Bundle>();
|
||||
parameters->putString(WIFI_CONNECT_PARAM_SSID, ssid);
|
||||
parameters->putString(WIFI_CONNECT_PARAM_PASSWORD, password);
|
||||
service::loader::startApp(manifest.id, parameters);
|
||||
service::loader::startApp(manifest.appId, parameters);
|
||||
}
|
||||
|
||||
bool optSsidParameter(const std::shared_ptr<const Bundle>& bundle, std::string& ssid) {
|
||||
|
||||
@@ -133,15 +133,15 @@ void WifiManage::onHide(TT_UNUSED AppContext& app) {
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "WifiManage",
|
||||
.name = "Wi-Fi",
|
||||
.icon = LV_SYMBOL_WIFI,
|
||||
.category = Category::Settings,
|
||||
.appId = "WifiManage",
|
||||
.appName = "Wi-Fi",
|
||||
.appIcon = LV_SYMBOL_WIFI,
|
||||
.appCategory = Category::Settings,
|
||||
.createApp = create<WifiManage>
|
||||
};
|
||||
|
||||
void start() {
|
||||
service::loader::startApp(manifest.id);
|
||||
service::loader::startApp(manifest.appId);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user