fix: several bookmarks UX improvments (#2372)
## Summary This PR enhances the EPUB reader's bookmark system with two complementary improvements: a per-page bookmark indicator icon and toggle behavior on the existing long-press action. --- ### What Changed **Bookmark Toggle (was: add-only)** The long-press Confirm action now toggles bookmarks rather than always adding. `addBookmark()` checks whether a bookmark with the same xpath already exists in the in-memory cache: - If found → removes it and shows "Bookmark removed." - If not found → adds it and shows "Bookmark added." A new `STR_BOOKMARK_REMOVED` translation string was added to support the removal message. **Bookmark Icon Indicator** A `BookmarkIcon` is now drawn at the top-right corner of the page whenever the current page has a bookmark. `updateBookmarkFlag()` is called at render time to determine whether the current page is bookmarked. **In-Memory Bookmark Cache** Bookmarks are now loaded into `cachedBookmarks` on `onEnter()` rather than being re-read from disk on every toggle. All subsequent add/remove operations work against this cache and flush to disk, avoiding redundant file reads on each bookmark action. **Faster bookmarks list** Previously, calculating "page X/Y" for each entry required decompressing the entire spine item. We now persist `si`/`pc`/`pp` (spine index, page count, and page progress) in the bookmark JSON when saving, and restore them when loading. This avoids the expensive `toCrossPoint()` loop in `onEnter()`, significantly reducing the cost of initializing the bookmarks list. --- ### Files Changed - `EpubReaderActivity.cpp` — `addBookmark()` toggle logic, `updateBookmarkFlag()` (new), icon rendering in `renderContents()`, cache initialization in `onEnter()` - `EpubReaderActivity.h` — new fields: `currentPageBookmarked`, `bookmarkRemoved`, `cachedBookmarks`; new method declaration `updateBookmarkFlag()` --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**< PARTIALLY >**_ --------- Co-authored-by: Julia Nguyen <julia@uxj.io>
This commit is contained in:
co-authored by
Julia Nguyen
parent
362dcb2a65
commit
1db1442319
@@ -192,6 +192,7 @@ STR_HOME: "« Home"
|
||||
STR_SELECT: "Seleziona"
|
||||
STR_SELECTED: "Selezionato"
|
||||
STR_TOGGLE: "Cambia"
|
||||
STR_TOGGLE_BOOKMARK: "Attiva/disattiva segnalibro"
|
||||
STR_CONFIRM: "Conferma"
|
||||
STR_CANCEL: "Annulla"
|
||||
STR_CONNECT: "Connetti"
|
||||
@@ -357,9 +358,9 @@ STR_FIRMWARE_WRITE_FAILED: "Aggiornamento firmware non riuscito"
|
||||
STR_FIRMWARE_UPDATE_DO_NOT_POWER_OFF: "Non spegnere il dispositivo!"
|
||||
STR_RECOVERY_MODE: "Modalità ripristino"
|
||||
STR_RECOVERY_MODE_HINT: "Metti firmware.bin nella scheda SD e selezionalo"
|
||||
STR_BOOKMARK_INSTRUCTIONS: "Tieni premuto Conferma nel lettore per creare un segnalibro"
|
||||
STR_BOOKMARKS: "Segnalibri"
|
||||
STR_BOOKMARK_ADDED: "Segnalibro aggiunto"
|
||||
STR_BOOKMARK_REMOVED: "Segnalibro rimosso"
|
||||
STR_CONFIRM_DELETE_BOOKMARK: "Eliminare questo segnalibro?"
|
||||
STR_CLOCK_SYNC_NO_WIFI_HINT: "Connettiti prima al Wi-Fi e poi riprova"
|
||||
STR_CLOCK_SYNC_OK: "Orologio sincronizzato"
|
||||
@@ -374,10 +375,10 @@ STR_CLOCK_SYNCING: "Sincronizzazione con il server NTP..."
|
||||
STR_CLOCK_SYNC_FAIL: "Sincronizzazione non riuscita"
|
||||
STR_CLOCK_SYNC_NOW: "Sincronizza l'orologio adesso"
|
||||
STR_CLOCK_SYNC_NO_WIFI: "Wi-Fi non connesso"
|
||||
STR_HOLD_CONFIRM_TO_DELETE: "Tieni premuto Conferma per cancellare"
|
||||
STR_HOLD_OPEN_TO_DELETE: "Tieni premuto Apri per eliminare"
|
||||
STR_NEXT_FIELD: "Succ."
|
||||
STR_CURRENT_TIME: "Ora attuale: "
|
||||
STR_DISABLED: "Disattivato"
|
||||
STR_BOOKMARK_OPTION: "Segnalibro"
|
||||
STR_KOSYNC: "KOSync"
|
||||
STR_PWR_BTN_FOOTNOTE_BACK: "Rientro rapido dalle note"
|
||||
STR_PWR_BTN_FOOTNOTE_BACK: "Rientro rapido dalle note"
|
||||
|
||||
Reference in New Issue
Block a user