Skip to content

Commit

Permalink
Fix header visibility of remainder of apps
Browse files Browse the repository at this point in the history
  • Loading branch information
KenVanHoeylandt committed Jan 14, 2025
1 parent 6355048 commit bffdc47
Show file tree
Hide file tree
Showing 28 changed files with 138 additions and 74 deletions.
File renamed without changes.
34 changes: 34 additions & 0 deletions Tactility/Private/app/files/FilesPrivate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once

#include "./View.h"
#include "./State.h"

#include "app/AppManifest.h"

#include <lvgl.h>
#include <dirent.h>
#include <memory>

namespace tt::app::files {

class Files {
std::unique_ptr<View> view;
std::shared_ptr<State> state;

public:
Files() {
state = std::make_shared<State>();
view = std::make_unique<View>(state);
}

void onShow(lv_obj_t* parent) {
view->init(parent);
}

void onResult(Result result, const Bundle& bundle) {
view->onResult(result, bundle);
}
};


} // namespace
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "State.h"
#include "./State.h"

#include "app/AppManifest.h"
#include <lvgl.h>
#include <memory>
Expand Down
37 changes: 37 additions & 0 deletions Tactility/Private/app/i2cscanner/I2cScannerPrivate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once

#include <TactilityCore.h>
#include <Mutex.h>
#include <Thread.h>
#include "lvgl.h"
#include "hal/i2c/I2c.h"
#include "Timer.h"
#include <memory>

namespace tt::app::i2cscanner {

#define TAG "i2cscanner"

enum ScanState {
ScanStateInitial,
ScanStateScanning,
ScanStateStopped
};

struct Data {
// Core
Mutex mutex = Mutex(Mutex::TypeRecursive);
std::unique_ptr<Timer> scanTimer = nullptr;
// State
ScanState scanState;
i2c_port_t port = I2C_NUM_0;
std::vector<uint8_t> scannedAddresses;
// Widgets
lv_obj_t* scanButtonLabelWidget = nullptr;
lv_obj_t* portDropdownWidget = nullptr;
lv_obj_t* scanListWidget = nullptr;
};

void onScanTimerFinished(std::shared_ptr<Data> data);

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "I2cScanner.h"
#include "./I2cScannerPrivate.h"
#include <memory>

namespace tt::app::i2cscanner {
Expand Down
6 changes: 3 additions & 3 deletions Tactility/Source/app/crashdiagnostics/CrashDiagnostics.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifdef ESP_TARGET

#include "app/crashdiagnostics/QrHelpers.h"
#include "app/crashdiagnostics/QrUrl.h"
#include "app/launcher/Launcher.h"
#include "lvgl.h"
#include "lvgl/Statusbar.h"
#include "app/launcher/Launcher.h"
#include "qrcode.h"
#include "QrHelpers.h"
#include "QrUrl.h"
#include "service/loader/Loader.h"

#define TAG "crash_diagnostics"
Expand Down
3 changes: 1 addition & 2 deletions Tactility/Source/app/crashdiagnostics/QrHelpers.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "app/crashdiagnostics/QrHelpers.h"
#include <cstdint>
#include <cassert>
#include "QrHelpers.h"

/**
* Maps QR version (starting at a fictitious 0) to the usable byte size for L(ow) CRC checking QR.
Expand Down
2 changes: 1 addition & 1 deletion Tactility/Source/app/crashdiagnostics/QrUrl.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifdef ESP_TARGET

#include "QrUrl.h"
#include "app/crashdiagnostics/QrUrl.h"

#include "kernel/PanicHandler.h"
#include "Log.h"
Expand Down
3 changes: 2 additions & 1 deletion Tactility/Source/app/files/FileUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "FileUtils.h"
#include "app/files/FileUtils.h"

#include "TactilityCore.h"
#include <cstring>
#include <StringUtils.h>
Expand Down
8 changes: 7 additions & 1 deletion Tactility/Source/app/files/Files.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "Files.h"
#include "app/files/FilesPrivate.h"

#include "app/AppContext.h"
#include "Assets.h"
#include "service/loader/Loader.h"

#include <memory>

Expand Down Expand Up @@ -37,4 +39,8 @@ extern const AppManifest manifest = {
.onResult = onResult
};

void start() {
service::loader::startApp(manifest.id);
}

} // namespace
20 changes: 1 addition & 19 deletions Tactility/Source/app/files/Files.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,6 @@

namespace tt::app::files {

class Files {
std::unique_ptr<View> view;
std::shared_ptr<State> state;

public:
Files() {
state = std::make_shared<State>();
view = std::make_unique<View>(state);
}

void onShow(lv_obj_t* parent) {
view->init(parent);
}

void onResult(Result result, const Bundle& bundle) {
view->onResult(result, bundle);
}
};

void start();

} // namespace
5 changes: 3 additions & 2 deletions Tactility/Source/app/files/State.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "State.h"
#include "app/files/State.h"
#include "app/files/FileUtils.h"

#include "kernel/Kernel.h"
#include "Log.h"
#include "FileUtils.h"
#include "Partitions.h"
#include "hal/SdCard.h"

Expand Down
15 changes: 6 additions & 9 deletions Tactility/Source/app/files/View.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include "app/files/FileUtils.h"
#include "app/files/View.h"

#include "app/alertdialog/AlertDialog.h"
#include "app/imageviewer/ImageViewer.h"
#include "app/inputdialog/InputDialog.h"
Expand All @@ -6,9 +9,7 @@
#include "lvgl/Toolbar.h"
#include "lvgl/LvglSync.h"
#include "service/loader/Loader.h"
#include "FileUtils.h"
#include "Tactility.h"
#include "View.h"
#include "StringUtils.h"
#include <cstring>
#include <unistd.h>
Expand Down Expand Up @@ -83,18 +84,14 @@ void View::viewFile(const std::string& path, const std::string& filename) {
app::startElfApp(processed_filepath);
#endif
} else if (isSupportedImageFile(filename)) {
auto bundle = std::make_shared<Bundle>();
bundle->putString(IMAGE_VIEWER_FILE_ARGUMENT, processed_filepath);
service::loader::startApp("ImageViewer", bundle);
app::imageviewer::start(processed_filepath);
} else if (isSupportedTextFile(filename)) {
auto bundle = std::make_shared<Bundle>();
if (kernel::getPlatform() == kernel::PlatformEsp) {
bundle->putString(TEXT_VIEWER_FILE_ARGUMENT, processed_filepath);
app::textviewer::start(processed_filepath);
} else {
// Remove forward slash, because we need a relative path
bundle->putString(TEXT_VIEWER_FILE_ARGUMENT, processed_filepath.substr(1));
app::textviewer::start(processed_filepath.substr(1));
}
service::loader::startApp("TextViewer", bundle);
} else {
TT_LOG_W(TAG, "opening files of this type is not supported");
}
Expand Down
2 changes: 1 addition & 1 deletion Tactility/Source/app/i2cscanner/I2cHelpers.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "I2cHelpers.h"
#include "app/i2cscanner/I2cHelpers.h"
#include "Tactility.h"
#include "StringUtils.h"
#include <iomanip>
Expand Down
12 changes: 8 additions & 4 deletions Tactility/Source/app/i2cscanner/I2cScanner.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "I2cScanner.h"
#include "I2cScannerThread.h"
#include "I2cHelpers.h"
#include "app/i2cscanner/I2cScannerPrivate.h"
#include "app/i2cscanner/I2cScannerThread.h"
#include "app/i2cscanner/I2cHelpers.h"

#include "Assets.h"
#include "Tactility.h"
Expand Down Expand Up @@ -50,7 +50,7 @@ static void onSelectBus(lv_event_t* event) {
TT_LOG_I(TAG, "Selected %ld", selected);
}

static void onPressScan(lv_event_t* event) {
static void onPressScan(TT_UNUSED lv_event_t* event) {
auto data = optData();
if (data != nullptr) {
if (data->scanState == ScanStateScanning) {
Expand Down Expand Up @@ -191,4 +191,8 @@ extern const AppManifest manifest = {
.onHide = onHide
};

void start() {
service::loader::startApp(manifest.id);
}

} // namespace
24 changes: 1 addition & 23 deletions Tactility/Source/app/i2cscanner/I2cScanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,6 @@

namespace tt::app::i2cscanner {

#define TAG "i2cscanner"

enum ScanState {
ScanStateInitial,
ScanStateScanning,
ScanStateStopped
};

struct Data {
// Core
Mutex mutex = Mutex(Mutex::TypeRecursive);
std::unique_ptr<Timer> scanTimer = nullptr;
// State
ScanState scanState;
i2c_port_t port = I2C_NUM_0;
std::vector<uint8_t> scannedAddresses;
// Widgets
lv_obj_t* scanButtonLabelWidget = nullptr;
lv_obj_t* portDropdownWidget = nullptr;
lv_obj_t* scanListWidget = nullptr;
};

void onScanTimerFinished(std::shared_ptr<Data> data);
void start();

}
2 changes: 1 addition & 1 deletion Tactility/Source/app/i2cscanner/I2cScannerThread.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "I2cScannerThread.h"
#include "app/i2cscanner/I2cScannerThread.h"
#include "lvgl.h"
#include "service/loader/Loader.h"

Expand Down
9 changes: 8 additions & 1 deletion Tactility/Source/app/imageviewer/ImageViewer.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#include <TactilityCore.h>
#include "ImageViewer.h"
#include "lvgl.h"
#include "lvgl/Style.h"
#include "lvgl/Toolbar.h"
#include "StringUtils.h"
#include "service/loader/Loader.h"

namespace tt::app::imageviewer {

extern const AppManifest manifest;

#define TAG "image_viewer"
#define IMAGE_VIEWER_FILE_ARGUMENT "file"

static void onShow(AppContext& app, lv_obj_t* parent) {
auto wrapper = lv_obj_create(parent);
Expand Down Expand Up @@ -57,4 +58,10 @@ extern const AppManifest manifest = {
.onShow = onShow
};

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);
}

} // namespace
6 changes: 5 additions & 1 deletion Tactility/Source/app/imageviewer/ImageViewer.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#pragma once

#define IMAGE_VIEWER_FILE_ARGUMENT "file"
namespace tt::app::imageviewer {

void start(const std::string& file);

};
2 changes: 1 addition & 1 deletion Tactility/Source/app/screenshot/Screenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#if TT_FEATURE_SCREENSHOT_ENABLED

#include "ScreenshotUi.h"
#include "app/screenshot/ScreenshotUi.h"
#include <memory>

namespace tt::app::screenshot {
Expand Down
2 changes: 1 addition & 1 deletion Tactility/Source/app/screenshot/ScreenshotUi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#if TT_FEATURE_SCREENSHOT_ENABLED

#include "ScreenshotUi.h"
#include "app/screenshot/ScreenshotUi.h"

#include "TactilityCore.h"
#include "hal/SdCard.h"
Expand Down
9 changes: 9 additions & 0 deletions Tactility/Source/app/textviewer/TextViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
#include "lvgl/LabelUtils.h"
#include "lvgl/Style.h"
#include "lvgl/Toolbar.h"
#include "service/loader/Loader.h"

#define TAG "text_viewer"
#define TEXT_VIEWER_FILE_ARGUMENT "file"

namespace tt::app::textviewer {

Expand Down Expand Up @@ -45,4 +47,11 @@ extern const AppManifest manifest = {
.onShow = onShow
};

void start(const std::string& file) {
auto parameters = std::make_shared<Bundle>();
parameters->putString(TEXT_VIEWER_FILE_ARGUMENT, file);
service::loader::startApp(manifest.id, parameters);
}


} // namespace
6 changes: 5 additions & 1 deletion Tactility/Source/app/textviewer/TextViewer.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#pragma once

#define TEXT_VIEWER_FILE_ARGUMENT "file"
namespace tt::app::textviewer {

void start(const std::string&file);

}

0 comments on commit bffdc47

Please sign in to comment.