Files
crosspoint-reader-mod/chat-summaries/2026-02-14_pr857-update-integration.md
cottongin dfbc931c14 mod: Phase 1 - bring forward mod-exclusive files with ActivityManager migration
Brings ~55 mod-exclusive files to the upstream-based mod/master-resync branch:

Activities (migrated to new ActivityManager pattern):
- Clock/Time: SetTimeActivity, SetTimezoneOffsetActivity, NtpSyncActivity
- Dictionary: DictionaryDefinitionActivity, DictionarySuggestionsActivity,
  DictionaryWordSelectActivity, LookedUpWordsActivity
- Bookmark: EpubReaderBookmarkSelectionActivity
- Book management: BookManageMenuActivity, EndOfBookMenuActivity
- OPDS: OpdsServerListActivity, OpdsSettingsActivity
- Utility: DirectoryPickerActivity, NumericStepperActivity

Utilities (unchanged):
- BookManager, BookSettings, BookmarkStore, BootNtpSync
- Dictionary, LookupHistory, TimeSync, OpdsServerStore

Libraries: PlaceholderCover, TableData, ChapterXPathIndexer
Scripts: inject_mod_version, generate_book_icon, preview_placeholder_cover
Docs: KOReader sync XPath mapping

Migration changes:
- ActivityWithSubactivity -> Activity base class
- Callback constructors -> finish()/setResult() pattern
- enterNewActivity() -> startActivityForResult()
- Activity::RenderLock&& -> RenderLock&&

These files won't compile yet - they reference mod settings and I18n
strings that will be added in subsequent phases.

Made-with: Cursor
2026-03-07 15:10:00 -05:00

4.8 KiB

PR #857 Full Feature Update Integration

Date: 2026-02-14

Task Description

Implemented the full feature update from PR #857 ("feat: Add dictionary word lookup feature") into our fork, following the detailed plan in pr_857_update_integration_190041ae.plan.md. This covered dictionary intelligence features (stemming, edit distance, fuzzy matching), the ActivityWithSubactivity refactor for inline definition display, en-dash/em-dash splitting, cross-page hyphenation, reverse-chronological lookup history, and a new "Did you mean?" suggestions activity.

Changes Made

New Files (2)

  • src/activities/reader/DictionarySuggestionsActivity.h — New "Did you mean?" activity header. Adapted from PR with orientation parameter for our DictionaryDefinitionActivity constructor.
  • src/activities/reader/DictionarySuggestionsActivity.cpp — Suggestions list UI with UITheme-aware layout, sub-activity management for definition display.

Modified Files (9)

  1. src/util/Dictionary.h — Added getStemVariants(), findSimilar() (public) and editDistance() (private) declarations.
  2. src/util/Dictionary.cpp — Added ~250 lines: morphological stemming (getStemVariants), Levenshtein distance (editDistance), and fuzzy index scan (findSimilar). Preserved fork's /.dictionary/ paths, stardictCmp/asciiCaseCmp, cacheExists()/deleteCache().
  3. src/activities/reader/DictionaryDefinitionActivity.h — Added optional onDone callback parameter and member. Enables "Done" button to exit all the way back to the reader.
  4. src/activities/reader/DictionaryDefinitionActivity.cpp — Split Confirm handler: calls onDone() if set, else onBack(). Button hint shows "Done" when callback provided. Preserved all HTML parsing, styled rendering, side button hints.
  5. src/activities/reader/DictionaryWordSelectActivity.h — Changed base class to ActivityWithSubactivity. Replaced onLookup callback with nextPageFirstWord string. Added pendingBackFromDef/pendingExitToReader state.
  6. src/activities/reader/DictionaryWordSelectActivity.cpp — Major update:
    • En-dash/em-dash splitting in extractWords() (splits on U+2013/U+2014)
    • Cross-page hyphenation in mergeHyphenatedWords() using nextPageFirstWord
    • Cascading lookup flow: exact → stem variants → similar suggestions → "Not found"
    • Sub-activity delegation in loop() for definition/suggestions screens
    • Preserved custom drawHints() with overlap detection and PageForward/PageBack support
  7. src/activities/reader/LookedUpWordsActivity.h — Replaced onSelectWord with onDone callback. Added readerFontId, orientation, pendingBackFromDef/pendingExitToReader, getPageItems().
  8. src/activities/reader/LookedUpWordsActivity.cpp — Major rewrite:
    • Reverse-chronological word display
    • Inline cascading lookup flow (same as word select)
    • UITheme-aware layout with GUI.drawHeader()/GUI.drawList()
    • onNextRelease/onPreviousRelease/onNextContinuous/onPreviousContinuous navigation
    • Sub-activity management for definition/suggestions
    • Preserved delete confirmation mode
  9. src/activities/reader/EpubReaderActivity.cpp — Simplified LOOKUP handler (removed onLookup callback, added nextPageFirstWord extraction). Simplified LOOKED_UP_WORDS handler (removed inline lookup, passes readerFontId and orientation). Removed unused LookupHistory.h include.

Cleanup

  • Removed unused DictionaryDefinitionActivity.h include from EpubReaderActivity.h
  • Removed unused util/LookupHistory.h include from EpubReaderActivity.cpp

Architectural Summary

Before: EpubReaderActivity orchestrated definition display via callbacks — word select and history both called back to the reader to create definition activities.

After: DictionaryWordSelectActivity and LookedUpWordsActivity manage their own sub-activity chains (definition, suggestions) using ActivityWithSubactivity. This enables the cascading lookup flow: exact match → stem variants → similar suggestions → "Not found".

What Was Preserved (Fork Advantages)

  • Full HTML parsing in DictionaryDefinitionActivity
  • Custom drawHints() with overlap detection in DictionaryWordSelectActivity
  • PageForward/PageBack button support in word selection
  • DELETE_DICT_CACHE menu item and cacheExists()/deleteCache()
  • stardictCmp/asciiCaseCmp for proper StarDict index comparison
  • /.dictionary/ path prefix

Follow-up Items

  • Test the full lookup flow on device (exact → stems → suggestions → not found)
  • Verify cross-page hyphenation with a book that has page-spanning hyphenated words
  • Verify en-dash/em-dash splitting with books using those characters
  • Confirm reverse-chronological history order is intuitive for users