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.3 KiB
3.3 KiB
Port PR #838 and PR #907 into fork
Task
Cherry-pick / manually port two upstream PRs into the fork:
- PR #907: Cover image outlines to improve legibility
- PR #838: Fallback logic for epub cover extraction
Changes Made
PR #907 (cover outlines) — src/components/themes/lyra/LyraTheme.cpp
- Always draw a rectangle outline around cover tiles before drawing the bitmap on top
- Removed
hasCoverflag — simplified logic so outline is always present, preventing low-contrast covers from blending into the background
PR #838 (cover fallback logic) — 3 files
lib/Epub/Epub.h
- Added declarations for 4 new methods:
generateInvalidFormatCoverBmp,generateInvalidFormatThumbBmp,isValidThumbnailBmp(static),getCoverCandidates(private) - Added doc comments on existing
generateCoverBmpandgenerateThumbBmp
lib/Epub/Epub.cpp
- Added
#include <HalDisplay.h>and#include <algorithm> generateCoverBmp: Added invalid BMP detection/retry, cover fallback candidate probing (getCoverCandidates), case-insensitive extension checking. Returnsfalseon failure (no internal X-pattern fallback) so callers control the fallback chaingenerateThumbBmp: Same changes asgenerateCoverBmp— invalid BMP detection, fallback probing, case-insensitive check. Returnsfalseon failure (no internal X-pattern fallback) so callers control the fallback chaingenerateInvalidFormatThumbBmp(new): Creates 1-bit BMP with X pattern as thumbnail markergenerateInvalidFormatCoverBmp(new): Creates 1-bit BMP with X pattern as cover marker, using display dimensionsisValidThumbnailBmp(new, static): Validates BMP by checking file size > 0 and 'BM' headergetCoverCandidates(new, private): Returns list of common cover filenames to probe
src/activities/home/HomeActivity.cpp
- Replaced
Storage.exists()check withEpub::isValidThumbnailBmp()to catch corrupt/empty thumbnails - Added epub.load retry logic (cache-only first, then full build)
- After successful thumbnail generation, update
RECENT_BOOKSwith the new thumb path - Thumbnail fallback chain: Real Cover → PlaceholderCoverGenerator → X-Pattern marker (epub only; xtc/other formats fall back to placeholder only)
Adaptations from upstream PR
- All
Serial.printfcalls converted toLOG_DBG/LOG_ERRmacros (fork convention) - No
#include <HardwareSerial.h>(not needed with Logging.h) - Retained fork's
bookMetadataCachenull-check guards - HomeActivity changes manually adapted to fork's
loadRecentCovers()structure (upstream has inline code in a different method) - Fork's
PlaceholderCoverGeneratoris the preferred fallback; X-pattern marker is last resort only
src/activities/boot_sleep/SleepActivity.cpp
- EPUB sleep screen cover now follows Real Cover → Placeholder → X-Pattern fallback chain
- Upgraded
Storage.exists()check toEpub::isValidThumbnailBmp()for the epub cover path
src/activities/reader/EpubReaderActivity.cpp
- Cover and thumbnail pre-rendering now follows Real Cover → Placeholder → X-Pattern fallback chain
- Upgraded all
Storage.exists()checks toEpub::isValidThumbnailBmp()for cover/thumb paths
Follow-up Items
- Build and test on device to verify cover generation pipeline works end-to-end