Service data refactored (#109)
This commit is contained in:
committed by
GitHub
parent
c6f1cd6098
commit
36bb25deba
@@ -60,7 +60,7 @@ static void onShow(TT_UNUSED AppContext& app, lv_obj_t* parent) {
|
||||
}
|
||||
|
||||
static void onStart(AppContext& app) {
|
||||
auto data = std::shared_ptr<Data>(new Data());
|
||||
auto data = std::make_shared<Data>();
|
||||
app.setData(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "lvgl/Toolbar.h"
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <memory>
|
||||
|
||||
namespace tt::app::files {
|
||||
|
||||
@@ -120,11 +121,11 @@ static void viewFile(const char* path, const char* filename) {
|
||||
TT_LOG_I(TAG, "Clicked %s", filepath);
|
||||
|
||||
if (isSupportedImageFile(filename)) {
|
||||
auto bundle = std::shared_ptr<Bundle>(new Bundle());
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
bundle->putString(IMAGE_VIEWER_FILE_ARGUMENT, processed_filepath);
|
||||
service::loader::startApp("ImageViewer", false, bundle);
|
||||
} else if (isSupportedTextFile(filename)) {
|
||||
auto bundle = std::shared_ptr<Bundle>(new Bundle());
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
if (get_platform() == PlatformEsp) {
|
||||
bundle->putString(TEXT_VIEWER_FILE_ARGUMENT, processed_filepath);
|
||||
} else {
|
||||
@@ -217,7 +218,7 @@ static void onShow(AppContext& app, lv_obj_t* parent) {
|
||||
}
|
||||
|
||||
static void onStart(AppContext& app) {
|
||||
auto data = std::shared_ptr<Data>(new Data());
|
||||
auto data = std::make_shared<Data>();
|
||||
// PC platform is bound to current work directory because of the LVGL file system mapping
|
||||
if (get_platform() == PlatformSimulator) {
|
||||
char cwd[PATH_MAX];
|
||||
|
||||
@@ -21,11 +21,11 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
void lock() {
|
||||
void lock() const {
|
||||
tt_check(mutex.acquire(1000) == TtStatusOk);
|
||||
}
|
||||
|
||||
void unlock() {
|
||||
void unlock() const {
|
||||
tt_check(mutex.release() == TtStatusOk);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
void startTask();
|
||||
void stopTask();
|
||||
bool shouldInterruptTask() { return interruptTask; };
|
||||
bool shouldInterruptTask() const { return interruptTask; };
|
||||
|
||||
void updatePinStates();
|
||||
void updatePinWidgets();
|
||||
@@ -210,7 +210,7 @@ static void onHide(AppContext& app) {
|
||||
}
|
||||
|
||||
static void onStart(AppContext& app) {
|
||||
auto gpio = std::shared_ptr<Gpio>(new Gpio());
|
||||
auto gpio = std::make_shared<Gpio>();
|
||||
app.setData(gpio);
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ static void onHide(AppContext& app) {
|
||||
}
|
||||
|
||||
static void onStart(AppContext& app) {
|
||||
auto data = std::shared_ptr<Data>(new Data());
|
||||
auto data = std::make_shared<Data>();
|
||||
app.setData(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ static void onHide(TT_UNUSED AppContext& app) {
|
||||
}
|
||||
|
||||
static void onStart(AppContext& app) {
|
||||
auto data = std::shared_ptr<Data>(new Data());
|
||||
auto data = std::shared_ptr<Data>();
|
||||
app.setData(data);
|
||||
data->power = getConfiguration()->hardware->power;
|
||||
assert(data->power != nullptr); // The Power app only shows up on supported devices
|
||||
|
||||
@@ -50,7 +50,7 @@ static void onListItemSelected(lv_event_t* e) {
|
||||
size_t index = (size_t)(e->user_data);
|
||||
TT_LOG_I(TAG, "Selected item at index %d", index);
|
||||
tt::app::AppContext* app = service::loader::getCurrentApp();
|
||||
auto bundle = std::shared_ptr<Bundle>(new Bundle());
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
setResultIndex(bundle, (int32_t)index);
|
||||
app->setResult(app::ResultOk, bundle);
|
||||
service::loader::stopApp();
|
||||
@@ -82,7 +82,7 @@ static void onShow(AppContext& app, lv_obj_t* parent) {
|
||||
app.setResult(ResultError);
|
||||
service::loader::stopApp();
|
||||
} else if (items.size() == 1) {
|
||||
auto result_bundle = std::shared_ptr<Bundle>(new Bundle());
|
||||
auto result_bundle = std::make_shared<Bundle>();
|
||||
setResultIndex(result_bundle, 0);
|
||||
app.setResult(ResultOk, result_bundle);
|
||||
service::loader::stopApp();
|
||||
|
||||
@@ -24,7 +24,7 @@ const AppContext* _Nullable optWifiApSettingsApp() {
|
||||
}
|
||||
|
||||
void start(const std::string& ssid) {
|
||||
auto bundle = std::shared_ptr<Bundle>(new Bundle());
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
bundle->putString("ssid", ssid);
|
||||
service::loader::startApp(manifest.id, false, bundle);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ static void onHide(AppContext& app) {
|
||||
}
|
||||
|
||||
static void onStart(AppContext& app) {
|
||||
auto wifi = std::shared_ptr<WifiConnect>(new WifiConnect());
|
||||
auto wifi = std::make_shared<WifiConnect>();
|
||||
app.setData(wifi);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ static void onConnect(const char* ssid) {
|
||||
service::wifi::connect(&settings, false);
|
||||
} else {
|
||||
TT_LOG_I(TAG, "Starting connection dialog");
|
||||
auto bundle = std::shared_ptr<Bundle>(new Bundle());
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
bundle->putString(WIFI_CONNECT_PARAM_SSID, ssid);
|
||||
bundle->putString(WIFI_CONNECT_PARAM_PASSWORD, "");
|
||||
service::loader::startApp("WifiConnect", false, bundle);
|
||||
@@ -145,7 +145,7 @@ void WifiManage::onHide(TT_UNUSED AppContext& app) {
|
||||
// region Manifest methods
|
||||
|
||||
static void onStart(AppContext& app) {
|
||||
auto wifi = std::shared_ptr<WifiManage>(new WifiManage());
|
||||
auto wifi = std::make_shared<WifiManage>();
|
||||
app.setData(wifi);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user