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
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 withorientationparameter for ourDictionaryDefinitionActivityconstructor.src/activities/reader/DictionarySuggestionsActivity.cpp— Suggestions list UI withUITheme-aware layout, sub-activity management for definition display.
Modified Files (9)
src/util/Dictionary.h— AddedgetStemVariants(),findSimilar()(public) andeditDistance()(private) declarations.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().src/activities/reader/DictionaryDefinitionActivity.h— Added optionalonDonecallback parameter and member. Enables "Done" button to exit all the way back to the reader.src/activities/reader/DictionaryDefinitionActivity.cpp— Split Confirm handler: callsonDone()if set, elseonBack(). Button hint shows "Done" when callback provided. Preserved all HTML parsing, styled rendering, side button hints.src/activities/reader/DictionaryWordSelectActivity.h— Changed base class toActivityWithSubactivity. ReplacedonLookupcallback withnextPageFirstWordstring. AddedpendingBackFromDef/pendingExitToReaderstate.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()usingnextPageFirstWord - 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 andPageForward/PageBacksupport
- En-dash/em-dash splitting in
src/activities/reader/LookedUpWordsActivity.h— ReplacedonSelectWordwithonDonecallback. AddedreaderFontId,orientation,pendingBackFromDef/pendingExitToReader,getPageItems().src/activities/reader/LookedUpWordsActivity.cpp— Major rewrite:- Reverse-chronological word display
- Inline cascading lookup flow (same as word select)
UITheme-aware layout withGUI.drawHeader()/GUI.drawList()onNextRelease/onPreviousRelease/onNextContinuous/onPreviousContinuousnavigation- Sub-activity management for definition/suggestions
- Preserved delete confirmation mode
src/activities/reader/EpubReaderActivity.cpp— Simplified LOOKUP handler (removedonLookupcallback, addednextPageFirstWordextraction). Simplified LOOKED_UP_WORDS handler (removed inline lookup, passesreaderFontIdandorientation). Removed unusedLookupHistory.hinclude.
Cleanup
- Removed unused
DictionaryDefinitionActivity.hinclude fromEpubReaderActivity.h - Removed unused
util/LookupHistory.hinclude fromEpubReaderActivity.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 inDictionaryWordSelectActivity PageForward/PageBackbutton support in word selectionDELETE_DICT_CACHEmenu item andcacheExists()/deleteCache()stardictCmp/asciiCaseCmpfor 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