Merge pull request #82 from jpirnay/feat-globalbookmarks

feat: Add global bookmarks screen
This commit is contained in:
jpirnay
2026-04-15 10:52:04 +02:00
committed by GitHub
21 changed files with 782 additions and 74 deletions
@@ -9,6 +9,7 @@
#include "CrossPointSettings.h"
#include "CrossPointState.h"
#include "GlobalBookmarkIndex.h"
#include "MappedInputManager.h"
#include "ReaderUtils.h"
#include "RecentBooksStore.h"
@@ -99,6 +100,7 @@ void TxtReaderActivity::onEnter() {
}
txt->setupCacheDir();
applyPendingBookmarkJump();
// Load bookmarks for this file
bookmarkStore.load(txt->getCachePath());
@@ -119,6 +121,9 @@ void TxtReaderActivity::onExit() {
// Save bookmarks before exit
bookmarkStore.save();
if (txt) {
GLOBAL_BOOKMARKS.syncFromStore(bookmarkStore, txt->getPath(), txt->getCachePath(), txt->getTitle(), true);
}
// Reset orientation back to portrait for the rest of the UI
renderer.setOrientation(GfxRenderer::Orientation::Portrait);
@@ -428,6 +433,34 @@ void TxtReaderActivity::saveProgress() const {
}
}
void TxtReaderActivity::applyPendingBookmarkJump() {
auto& jump = APP_STATE.pendingBookmarkJump;
if (!jump.active || !txt || jump.bookPath != txt->getPath()) {
return;
}
LOG_DBG("TRS", "Applying pending bookmark jump: page=%u", jump.pageNumber);
bool persisted = false;
FsFile f;
if (Storage.openFileForWrite("TRS", txt->getCachePath() + "/progress.bin", f)) {
uint8_t data[6] = {0};
data[0] = jump.pageNumber & 0xFF;
data[1] = (jump.pageNumber >> 8) & 0xFF;
// Offset bytes stay 0: loadProgress reads only the page, and the lazy
// initializeReader() rebuilds the page index on first render anyway.
if (f.write(data, 6) == 6) {
persisted = f.close();
} else {
f.close();
}
}
if (persisted) {
jump.clear();
APP_STATE.saveToFile();
}
}
void TxtReaderActivity::loadProgress() {
FsFile f;
if (Storage.openFileForRead("TRS", txt->getCachePath() + "/progress.bin", f)) {