feat: Implement bookmark functionality for epub reader
Replace bookmark stubs with full add/remove/navigate implementation: - BookmarkStore: per-book binary persistence on SD card with v2 format supporting text snippets (backward-compatible with v1) - Visual bookmark ribbon indicator drawn on bookmarked pages via fillPolygon - Reader menu dynamically shows Add/Remove Bookmark based on current page state - Bookmark selection activity with chapter name, first sentence snippet, and page number display; long-press to delete with confirmation - Go to Bookmark falls back to Table of Contents when no bookmarks exist - Smart snippet extraction: skips partial sentences (lowercase first word) to capture the first full sentence on the page - Label truncation reserves space for page suffix so it's never cut off - Half refresh forced on menu exit to clear popup/menu artifacts Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,6 +16,7 @@ class EpubReaderMenuActivity final : public ActivityWithSubactivity {
|
||||
// Menu actions available from the reader menu.
|
||||
enum class MenuAction {
|
||||
ADD_BOOKMARK,
|
||||
REMOVE_BOOKMARK,
|
||||
LOOKUP,
|
||||
LOOKED_UP_WORDS,
|
||||
ROTATE_SCREEN,
|
||||
@@ -31,10 +32,11 @@ class EpubReaderMenuActivity final : public ActivityWithSubactivity {
|
||||
explicit EpubReaderMenuActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::string& title,
|
||||
const int currentPage, const int totalPages, const int bookProgressPercent,
|
||||
const uint8_t currentOrientation, const bool hasDictionary,
|
||||
const bool isBookmarked,
|
||||
const std::function<void(uint8_t)>& onBack,
|
||||
const std::function<void(MenuAction)>& onAction)
|
||||
: ActivityWithSubactivity("EpubReaderMenu", renderer, mappedInput),
|
||||
menuItems(buildMenuItems(hasDictionary)),
|
||||
menuItems(buildMenuItems(hasDictionary, isBookmarked)),
|
||||
title(title),
|
||||
pendingOrientation(currentOrientation),
|
||||
currentPage(currentPage),
|
||||
@@ -70,9 +72,13 @@ class EpubReaderMenuActivity final : public ActivityWithSubactivity {
|
||||
const std::function<void(uint8_t)> onBack;
|
||||
const std::function<void(MenuAction)> onAction;
|
||||
|
||||
static std::vector<MenuItem> buildMenuItems(bool hasDictionary) {
|
||||
static std::vector<MenuItem> buildMenuItems(bool hasDictionary, bool isBookmarked) {
|
||||
std::vector<MenuItem> items;
|
||||
items.push_back({MenuAction::ADD_BOOKMARK, "Add Bookmark"});
|
||||
if (isBookmarked) {
|
||||
items.push_back({MenuAction::REMOVE_BOOKMARK, "Remove Bookmark"});
|
||||
} else {
|
||||
items.push_back({MenuAction::ADD_BOOKMARK, "Add Bookmark"});
|
||||
}
|
||||
if (hasDictionary) {
|
||||
items.push_back({MenuAction::LOOKUP, "Lookup Word"});
|
||||
items.push_back({MenuAction::LOOKED_UP_WORDS, "Lookup Word History"});
|
||||
|
||||
Reference in New Issue
Block a user