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
3.5 KiB
3.5 KiB
Placeholder Cover Generation for Books Without Covers
Task
Implement placeholder cover BMP generation for books that have no embedded cover image (or have covers in unsupported formats). Previously, these books showed empty rectangles on the home screen and fell back to the default sleep screen.
Root Cause
Cover generation failed silently in three cases:
- EPUB: No
coverItemHrefin metadata, or cover is non-JPG format (PNG/SVG/GIF) - TXT: No matching image file on the SD card
- XTC: First-page render failure (rare)
When generateCoverBmp() returned false, no BMP was created, and no fallback was attempted.
Changes Made
New Files
lib/PlaceholderCover/PlaceholderCoverGenerator.h- Header for the placeholder generatorlib/PlaceholderCover/PlaceholderCoverGenerator.cpp- Implementation: allocates a 1-bit pixel buffer, renders title/author text using EpdFont glyph data (ported from GfxRenderer::renderChar), writes a 1-bit BMP file with word-wrapped centered text, border, and separator line
Modified Files
src/activities/reader/EpubReaderActivity.cpp- Added placeholder fallback aftergenerateCoverBmp()andgenerateThumbBmp()fail during first-open prerendersrc/activities/reader/TxtReaderActivity.cpp- Added placeholder fallback, added thumbnail generation (previously TXT had none), now passes thumb path to RECENT_BOOKS.addBook() instead of empty stringsrc/activities/reader/XtcReaderActivity.cpp- Added placeholder fallback after cover/thumb generation fail (rare case)src/activities/boot_sleep/SleepActivity.cpp- Added placeholder generation before falling back to default sleep screen (handles books opened before this feature was added)lib/Txt/Txt.h- AddedgetThumbBmpPath()andgetThumbBmpPath(int height)methodslib/Txt/Txt.cpp- Implemented the new thumb path methods
Architecture
- Option B approach: shared
PlaceholderCoverGeneratorutility called from reader activities - Generator is independent of
GfxRenderer(no display framebuffer dependency) - Includes Ubuntu 10 Regular and Ubuntu 12 Bold font data directly for self-contained rendering
- Memory: 48KB for full cover (480x800), 4-12KB for thumbnails; allocated and freed per call
Flash Impact
- Before: 96.4% flash usage (6,317,250 bytes)
- After: 97.3% flash usage (6,374,546 bytes)
- Delta: ~57KB (mostly from duplicate font bitmap data included in the generator)
Layout Revision (traditional book cover style)
- Border: moved inward with proportional edge padding (~10px at full size) and thickened to ~5px, keeping it visible within the device bezel
- Title: 2x integer-scaled Ubuntu 12 Bold (effectively ~24pt) for full-size covers, positioned in the top 2/3 zone, max 5 lines
- Author: positioned in the bottom 1/3 zone, max 3 lines with word wrapping
- Book icon: 48x48 1-bit bitmap (generated by
scripts/generate_book_icon.py), displayed at 2x for full covers, 1x for medium thumbnails, omitted for small thumbnails - Separator line between title and author zones
- All dimensions scale proportionally for thumbnails
Follow-up Items
- Books opened before this feature was added won't get home screen thumbnails until re-opened (SleepActivity handles the sleep cover case by generating on demand)
- Font data duplication adds ~57KB flash; could be reduced by exposing shared font references instead of including headers directly
- Preview scripts in
scripts/can regenerate the icon and layout previews:generate_book_icon.py,preview_placeholder_cover.py