This commit is contained in:
Konstantin Vukolov 2026-01-22 17:55:38 +03:00
parent 3ce11f14ce
commit e32394fc81
7 changed files with 41 additions and 12 deletions

View File

@ -45,6 +45,7 @@ bool CrossPointSettings::saveToFile() const {
serialization::writePod(outputFile, screenMargin); serialization::writePod(outputFile, screenMargin);
serialization::writePod(outputFile, sleepScreenCoverMode); serialization::writePod(outputFile, sleepScreenCoverMode);
serialization::writeString(outputFile, std::string(opdsServerUrl)); serialization::writeString(outputFile, std::string(opdsServerUrl));
serialization::writeString(outputFile, std::string(opdsPath));
serialization::writePod(outputFile, textAntiAliasing); serialization::writePod(outputFile, textAntiAliasing);
serialization::writePod(outputFile, hideBatteryPercentage); serialization::writePod(outputFile, hideBatteryPercentage);
serialization::writePod(outputFile, longPressChapterSkip); serialization::writePod(outputFile, longPressChapterSkip);
@ -112,6 +113,14 @@ bool CrossPointSettings::loadFromFile() {
opdsServerUrl[sizeof(opdsServerUrl) - 1] = '\0'; opdsServerUrl[sizeof(opdsServerUrl) - 1] = '\0';
} }
if (++settingsRead >= fileSettingsCount) break; if (++settingsRead >= fileSettingsCount) break;
{
std::string urlPath;
serialization::readString(inputFile, urlPath);
strncpy(opdsPath, urlPath.c_str(), sizeof(opdsPath) - 1);
opdsPath[sizeof(opdsPath) - 1] = '\0';
}
if (++settingsRead >= fileSettingsCount) break;
serialization::readPod(inputFile, textAntiAliasing); serialization::readPod(inputFile, textAntiAliasing);
if (++settingsRead >= fileSettingsCount) break; if (++settingsRead >= fileSettingsCount) break;
serialization::readPod(inputFile, hideBatteryPercentage); serialization::readPod(inputFile, hideBatteryPercentage);

View File

@ -90,6 +90,7 @@ class CrossPointSettings {
uint8_t screenMargin = 5; uint8_t screenMargin = 5;
// OPDS browser settings // OPDS browser settings
char opdsServerUrl[128] = ""; char opdsServerUrl[128] = "";
char opdsPath[128] = "";
// Hide battery percentage // Hide battery percentage
uint8_t hideBatteryPercentage = HIDE_NEVER; uint8_t hideBatteryPercentage = HIDE_NEVER;
// Long-press chapter skip on side buttons // Long-press chapter skip on side buttons

View File

@ -18,7 +18,7 @@
namespace { namespace {
constexpr int PAGE_ITEMS = 23; constexpr int PAGE_ITEMS = 23;
constexpr int SKIP_PAGE_MS = 700; constexpr int SKIP_PAGE_MS = 700;
constexpr char OPDS_ROOT_PATH[] = "opds"; // No leading slash - relative to server URL constexpr char DEFAULT_OPDS_ROOT_PATH[] = "opds"; // No leading slash - relative to server URL
} // namespace } // namespace
void OpdsBookBrowserActivity::taskTrampoline(void* param) { void OpdsBookBrowserActivity::taskTrampoline(void* param) {
@ -33,7 +33,7 @@ void OpdsBookBrowserActivity::onEnter() {
state = BrowserState::CHECK_WIFI; state = BrowserState::CHECK_WIFI;
entries.clear(); entries.clear();
navigationHistory.clear(); navigationHistory.clear();
currentPath = OPDS_ROOT_PATH; currentPath = strcmp(SETTINGS.opdsPath, "") ? SETTINGS.opdsPath : DEFAULT_OPDS_ROOT_PATH;
selectorIndex = 0; selectorIndex = 0;
errorMessage.clear(); errorMessage.clear();
statusMessage = "Checking WiFi..."; statusMessage = "Checking WiFi...";
@ -172,7 +172,7 @@ void OpdsBookBrowserActivity::render() const {
const auto pageWidth = renderer.getScreenWidth(); const auto pageWidth = renderer.getScreenWidth();
const auto pageHeight = renderer.getScreenHeight(); const auto pageHeight = renderer.getScreenHeight();
renderer.drawCenteredText(UI_12_FONT_ID, 15, "Calibre Library", true, EpdFontFamily::BOLD); renderer.drawCenteredText(UI_12_FONT_ID, 15, "Remote", true, EpdFontFamily::BOLD);
if (state == BrowserState::CHECK_WIFI) { if (state == BrowserState::CHECK_WIFI) {
renderer.drawCenteredText(UI_10_FONT_ID, pageHeight / 2, statusMessage.c_str()); renderer.drawCenteredText(UI_10_FONT_ID, pageHeight / 2, statusMessage.c_str());

View File

@ -503,7 +503,7 @@ void HomeActivity::render() {
std::vector<const char*> menuItems = {"My Library", "File Transfer", "Settings"}; std::vector<const char*> menuItems = {"My Library", "File Transfer", "Settings"};
if (hasOpdsUrl) { if (hasOpdsUrl) {
// Insert Calibre Library after My Library // Insert Calibre Library after My Library
menuItems.insert(menuItems.begin() + 1, "Calibre Library"); menuItems.insert(menuItems.begin() + 1, "Remote Library");
} }
const int menuTileWidth = pageWidth - 2 * margin; const int menuTileWidth = pageWidth - 2 * margin;

View File

@ -13,8 +13,8 @@
#include "fontIds.h" #include "fontIds.h"
namespace { namespace {
constexpr int MENU_ITEMS = 2; constexpr int MENU_ITEMS = 3;
const char* menuNames[MENU_ITEMS] = {"Calibre Web URL", "Connect as Wireless Device"}; const char* menuNames[MENU_ITEMS] = {"Server URL", "OPDS Path", "Connect as Wireless Device"};
} // namespace } // namespace
void CalibreSettingsActivity::taskTrampoline(void* param) { void CalibreSettingsActivity::taskTrampoline(void* param) {
@ -80,10 +80,10 @@ void CalibreSettingsActivity::handleSelection() {
xSemaphoreTake(renderingMutex, portMAX_DELAY); xSemaphoreTake(renderingMutex, portMAX_DELAY);
if (selectedIndex == 0) { if (selectedIndex == 0) {
// Calibre Web URL // Server URL
exitActivity(); exitActivity();
enterNewActivity(new KeyboardEntryActivity( enterNewActivity(new KeyboardEntryActivity(
renderer, mappedInput, "Calibre Web URL", SETTINGS.opdsServerUrl, 10, renderer, mappedInput, "Server URL", SETTINGS.opdsServerUrl, 10,
127, // maxLength 127, // maxLength
false, // not password false, // not password
[this](const std::string& url) { [this](const std::string& url) {
@ -97,7 +97,26 @@ void CalibreSettingsActivity::handleSelection() {
exitActivity(); exitActivity();
updateRequired = true; updateRequired = true;
})); }));
} else if (selectedIndex == 1) { } else if (selectedIndex == 1) {
// OPDS Path
exitActivity();
enterNewActivity(new KeyboardEntryActivity(
renderer, mappedInput, "OPDS Path", SETTINGS.opdsPath, 10,
127, // maxLength
false, // not password
[this](const std::string& url) {
strncpy(SETTINGS.opdsPath, url.c_str(), sizeof(SETTINGS.opdsServerUrl) - 1);
SETTINGS.opdsPath[sizeof(SETTINGS.opdsPath) - 1] = '\0';
SETTINGS.saveToFile();
exitActivity();
updateRequired = true;
},
[this]() {
exitActivity();
updateRequired = true;
}));
} else if (selectedIndex == 2) {
// Wireless Device - launch the activity (handles WiFi connection internally) // Wireless Device - launch the activity (handles WiFi connection internally)
exitActivity(); exitActivity();
if (WiFi.status() != WL_CONNECTED) { if (WiFi.status() != WL_CONNECTED) {
@ -141,7 +160,7 @@ void CalibreSettingsActivity::render() {
const auto pageWidth = renderer.getScreenWidth(); const auto pageWidth = renderer.getScreenWidth();
// Draw header // Draw header
renderer.drawCenteredText(UI_12_FONT_ID, 15, "Calibre", true, EpdFontFamily::BOLD); renderer.drawCenteredText(UI_12_FONT_ID, 15, "Remote Library", true, EpdFontFamily::BOLD);
// Draw selection highlight // Draw selection highlight
renderer.fillRect(0, 60 + selectedIndex * 30 - 2, pageWidth - 1, 30); renderer.fillRect(0, 60 + selectedIndex * 30 - 2, pageWidth - 1, 30);

View File

@ -103,7 +103,7 @@ void CategorySettingsActivity::toggleCurrentSetting() {
updateRequired = true; updateRequired = true;
})); }));
xSemaphoreGive(renderingMutex); xSemaphoreGive(renderingMutex);
} else if (strcmp(setting.name, "Calibre Settings") == 0) { } else if (strcmp(setting.name, "Remote Library") == 0) {
xSemaphoreTake(renderingMutex, portMAX_DELAY); xSemaphoreTake(renderingMutex, portMAX_DELAY);
exitActivity(); exitActivity();
enterNewActivity(new CalibreSettingsActivity(renderer, mappedInput, [this] { enterNewActivity(new CalibreSettingsActivity(renderer, mappedInput, [this] {

View File

@ -48,7 +48,7 @@ constexpr int systemSettingsCount = 5;
const SettingInfo systemSettings[systemSettingsCount] = { const SettingInfo systemSettings[systemSettingsCount] = {
SettingInfo::Enum("Time to Sleep", &CrossPointSettings::sleepTimeout, SettingInfo::Enum("Time to Sleep", &CrossPointSettings::sleepTimeout,
{"1 min", "5 min", "10 min", "15 min", "30 min"}), {"1 min", "5 min", "10 min", "15 min", "30 min"}),
SettingInfo::Action("KOReader Sync"), SettingInfo::Action("Calibre Settings"), SettingInfo::Action("Clear Cache"), SettingInfo::Action("KOReader Sync"), SettingInfo::Action("Remote Library"), SettingInfo::Action("Clear Cache"),
SettingInfo::Action("Check for updates")}; SettingInfo::Action("Check for updates")};
} // namespace } // namespace