mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 14:47:37 +03:00
style: apply clang-format
This commit is contained in:
parent
f611cc9615
commit
f3ec7b8800
@ -1,33 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "../Activity.h"
|
||||
#include "../../extension/AppLoader.h"
|
||||
#include <GfxRenderer.h>
|
||||
#include <MappedInputManager.h>
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
#include "../../extension/AppLoader.h"
|
||||
#include "../Activity.h"
|
||||
|
||||
class AppsActivity : public Activity {
|
||||
public:
|
||||
using ExitCallback = std::function<void()>;
|
||||
|
||||
|
||||
AppsActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, ExitCallback exitCallback);
|
||||
|
||||
|
||||
void onEnter() override;
|
||||
void onExit() override;
|
||||
void loop() override;
|
||||
|
||||
|
||||
private:
|
||||
GfxRenderer& renderer_;
|
||||
MappedInputManager& mappedInput_;
|
||||
ExitCallback exitCallback_;
|
||||
|
||||
|
||||
std::vector<CrossPoint::AppInfo> appList_;
|
||||
int selectedIndex_;
|
||||
bool needsUpdate_;
|
||||
bool isFlashing_;
|
||||
int flashProgress_;
|
||||
|
||||
|
||||
void scanApps();
|
||||
void launchApp();
|
||||
void render();
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
#include <EpdFontFamily.h>
|
||||
#include <GfxRenderer.h>
|
||||
#include <builtinFonts/all.h>
|
||||
|
||||
#include <esp_attr.h>
|
||||
#include <esp_ota_ops.h>
|
||||
#include <esp_system.h>
|
||||
@ -17,7 +16,7 @@ namespace {
|
||||
EpdFont ui12RegularFont(&ubuntu_12_regular);
|
||||
EpdFont ui12BoldFont(&ubuntu_12_bold);
|
||||
EpdFontFamily ui12FontFamily(&ui12RegularFont, &ui12BoldFont);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
HelloWorldActivity::HelloWorldActivity(HalDisplay& display, HalGPIO& input)
|
||||
: display_(display), input_(input), needsUpdate_(true) {}
|
||||
|
||||
@ -6,16 +6,16 @@
|
||||
class HelloWorldActivity {
|
||||
public:
|
||||
HelloWorldActivity(HalDisplay& display, HalGPIO& input);
|
||||
|
||||
|
||||
void onEnter();
|
||||
void loop();
|
||||
void onExit();
|
||||
|
||||
|
||||
private:
|
||||
HalDisplay& display_;
|
||||
HalGPIO& input_;
|
||||
bool needsUpdate_;
|
||||
|
||||
|
||||
void render();
|
||||
void returnToLauncher();
|
||||
};
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
#include "AppLoader.h"
|
||||
|
||||
#include <memory>
|
||||
#include <esp_ota_ops.h>
|
||||
#include <esp_partition.h>
|
||||
#include <esp_system.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Battery.h"
|
||||
|
||||
namespace CrossPoint {
|
||||
@ -85,8 +86,8 @@ AppManifest AppLoader::parseManifest(const String& path) {
|
||||
}
|
||||
|
||||
if (fileSize > MAX_MANIFEST_SIZE) {
|
||||
Serial.printf("[%lu] [AppLoader] Manifest file too large (%u bytes, max %u): %s\n",
|
||||
millis(), fileSize, MAX_MANIFEST_SIZE, path.c_str());
|
||||
Serial.printf("[%lu] [AppLoader] Manifest file too large (%u bytes, max %u): %s\n", millis(), fileSize,
|
||||
MAX_MANIFEST_SIZE, path.c_str());
|
||||
file.close();
|
||||
return manifest;
|
||||
}
|
||||
@ -97,8 +98,8 @@ AppManifest AppLoader::parseManifest(const String& path) {
|
||||
file.close();
|
||||
|
||||
if (bytesRead != fileSize) {
|
||||
Serial.printf("[%lu] [AppLoader] Failed to read complete manifest file (read %u of %u bytes): %s\n",
|
||||
millis(), bytesRead, fileSize, path.c_str());
|
||||
Serial.printf("[%lu] [AppLoader] Failed to read complete manifest file (read %u of %u bytes): %s\n", millis(),
|
||||
bytesRead, fileSize, path.c_str());
|
||||
return manifest;
|
||||
}
|
||||
|
||||
@ -113,8 +114,7 @@ AppManifest AppLoader::parseManifest(const String& path) {
|
||||
const DeserializationError error = deserializeJson(doc, json);
|
||||
|
||||
if (error) {
|
||||
Serial.printf("[%lu] [AppLoader] JSON parse error in %s: %s\n",
|
||||
millis(), path.c_str(), error.c_str());
|
||||
Serial.printf("[%lu] [AppLoader] JSON parse error in %s: %s\n", millis(), path.c_str(), error.c_str());
|
||||
return manifest;
|
||||
}
|
||||
|
||||
@ -307,8 +307,6 @@ String AppLoader::buildManifestPath(const String& appDir) const {
|
||||
return path;
|
||||
}
|
||||
|
||||
bool AppLoader::isSDReady() const {
|
||||
return SdMan.ready();
|
||||
}
|
||||
bool AppLoader::isSDReady() const { return SdMan.ready(); }
|
||||
|
||||
}
|
||||
} // namespace CrossPoint
|
||||
|
||||
@ -1,24 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <WString.h>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <SDCardManager.h>
|
||||
#include <WString.h>
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
namespace CrossPoint {
|
||||
|
||||
/**
|
||||
* @brief App manifest data structure
|
||||
*
|
||||
*
|
||||
* Contains the metadata parsed from app.json files
|
||||
*/
|
||||
struct AppManifest {
|
||||
String name; ///< Display name of the app
|
||||
String version; ///< Version string (e.g., "1.0.0")
|
||||
String description; ///< Brief description of the app
|
||||
String author; ///< Author/creator name
|
||||
String minFirmware; ///< Minimum firmware version required
|
||||
String name; ///< Display name of the app
|
||||
String version; ///< Version string (e.g., "1.0.0")
|
||||
String description; ///< Brief description of the app
|
||||
String author; ///< Author/creator name
|
||||
String minFirmware; ///< Minimum firmware version required
|
||||
|
||||
AppManifest() = default;
|
||||
AppManifest(const String& n, const String& v, const String& d, const String& a, const String& f)
|
||||
@ -27,7 +28,7 @@ struct AppManifest {
|
||||
|
||||
/**
|
||||
* @brief Complete app information including manifest and path
|
||||
*
|
||||
*
|
||||
* Combines the parsed manifest with file system path information
|
||||
*/
|
||||
struct AppInfo {
|
||||
@ -40,10 +41,10 @@ struct AppInfo {
|
||||
|
||||
/**
|
||||
* @brief Utility class for loading and managing apps from SD card
|
||||
*
|
||||
*
|
||||
* Handles scanning for app manifests in the /.crosspoint/apps directory,
|
||||
* parsing JSON manifests, and providing access to app information.
|
||||
*
|
||||
*
|
||||
* Usage:
|
||||
* AppLoader loader;
|
||||
* std::vector<AppInfo> apps = loader.scanApps();
|
||||
@ -60,21 +61,21 @@ class AppLoader {
|
||||
|
||||
/**
|
||||
* @brief Scan for apps in the /.crosspoint/apps directory
|
||||
*
|
||||
*
|
||||
* Searches for subdirectories under /.crosspoint/apps and attempts to
|
||||
* parse app.json files in each directory. Invalid or missing manifests
|
||||
* are skipped gracefully.
|
||||
*
|
||||
*
|
||||
* @return Vector of AppInfo objects for all valid apps found
|
||||
*/
|
||||
std::vector<AppInfo> scanApps();
|
||||
|
||||
/**
|
||||
* @brief Parse an app.json manifest file
|
||||
*
|
||||
*
|
||||
* Reads and parses a JSON manifest file, extracting the required fields.
|
||||
* Logs errors for malformed JSON but does not throw exceptions.
|
||||
*
|
||||
*
|
||||
* @param path Full path to the app.json file
|
||||
* @return AppManifest object with parsed data (empty on failure)
|
||||
*/
|
||||
@ -107,7 +108,7 @@ class AppLoader {
|
||||
|
||||
/**
|
||||
* @brief Helper to build manifest file path from app directory path
|
||||
*
|
||||
*
|
||||
* @param appDir Path to the app directory
|
||||
* @return Full path to the app.json file
|
||||
*/
|
||||
@ -115,7 +116,7 @@ class AppLoader {
|
||||
|
||||
/**
|
||||
* @brief Check if SD card is ready
|
||||
*
|
||||
*
|
||||
* @return true if SD card is initialized and ready
|
||||
*/
|
||||
bool isSDReady() const;
|
||||
|
||||
@ -15,9 +15,9 @@
|
||||
#include "KOReaderCredentialStore.h"
|
||||
#include "MappedInputManager.h"
|
||||
#include "RecentBooksStore.h"
|
||||
#include "activities/apps/AppsActivity.h"
|
||||
#include "activities/boot_sleep/BootActivity.h"
|
||||
#include "activities/boot_sleep/SleepActivity.h"
|
||||
#include "activities/apps/AppsActivity.h"
|
||||
#include "activities/browser/OpdsBookBrowserActivity.h"
|
||||
#include "activities/home/HomeActivity.h"
|
||||
#include "activities/home/MyLibraryActivity.h"
|
||||
|
||||
@ -9,9 +9,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "html/AppsPageHtml.generated.h"
|
||||
#include "html/FilesPageHtml.generated.h"
|
||||
#include "html/HomePageHtml.generated.h"
|
||||
#include "html/AppsPageHtml.generated.h"
|
||||
#include "util/StringUtils.h"
|
||||
|
||||
namespace {
|
||||
@ -525,8 +525,8 @@ static bool isValidAppId(const String& appId) {
|
||||
}
|
||||
for (size_t i = 0; i < appId.length(); i++) {
|
||||
const char c = appId.charAt(i);
|
||||
const bool ok = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '.' ||
|
||||
c == '_' || c == '-';
|
||||
const bool ok =
|
||||
(c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '.' || c == '_' || c == '-';
|
||||
if (!ok) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user