Repository navigation
feat(android): add "System" reading-theme option - #395
Conversation
Android half of #349, mirroring iOS's ConcreteReadingTheme split (#374) so the compiler enforces resolving SYSTEM before it reaches anything that needs a concrete color. ## Changes - ReadingTheme/AppReadingTheme both gain a SYSTEM case. - New core:ui ConcreteReadingTheme (DARK/LIGHT/SEPIA) + ReadingTheme.resolved( systemInDarkTheme) — the single place the SYSTEM→Dark/Light policy lives. Sepia is never a resolution target, same call as iOS. - Every exhaustive `when (ReadingTheme)` #370 flagged as a landmine now takes ConcreteReadingTheme instead, resolved at the nearest @composable call site via isSystemInDarkTheme(): LibravaultTheme's color-scheme selection, mermaidThemeName, and both toEpubPreferences()/toVaultEpubPreferences() helpers (EpubReaderScreen, VaultEpubReaderScreen). LaunchedEffect keys include the resolved theme (not just the raw enum) so a live OS appearance change re-applies while SYSTEM is selected, matching the "updates live" acceptance criterion for both the reader chrome and Mermaid diagrams. - MainActivity maps the new AppReadingTheme.SYSTEM case through. - Both settings sheets (ReaderSettingsSheet, VaultReaderSettingsSheet) and SettingsScreen already iterate ReadingTheme/AppReadingTheme.entries generically, so the 4th "System" chip needed no changes there. - Default stays DARK for both app-wide and per-session settings, matching the iOS decision (#374) — System is an available choice, not the default. Per-session settings still reset to DARK each reader open, same pre-existing (out-of-scope) gap #374 found on iOS. ## Bug found while wiring this up LibravaultTheme's old color-scheme `when` only special-cased SEPIA and otherwise fell straight through to the ambient `darkTheme` (system) value — an explicit DARK or LIGHT pick was silently overridden by whatever the system's own light/dark setting happened to be. Resolving readingTheme against darkTheme up front (required to support SYSTEM at all) fixes this as a side effect: DARK/LIGHT/SEPIA now always win regardless of the system setting, and SYSTEM is the only case that still follows it. Covered by two new regression tests in LibravaultThemeTest. ## Tests - ReadingThemeResolutionTest (new): resolved() logic, all four cases. - LibravaultThemeTest: SYSTEM follows system light/dark + the DARK/LIGHT- wins-over-ambient-system regression above. - MermaidThemeTest: updated to ConcreteReadingTheme's 3 cases. - ReaderViewModelTest / VaultReaderViewModelTest: onThemeChanged(SYSTEM) round-trips through UI state. - SettingsViewModelTest: onReadingThemeChanged(SYSTEM) persists. - VaultReaderSettingsSheetUiTest: System renders as a 4th chip and can be selected. - UserPreferencesRepositoryTest's existing `AppReadingTheme.values()` loop covers SYSTEM's persistence round-trip with no changes needed. All new/changed tests mutation-checked (deliberately broke resolved()'s SYSTEM branch and LibravaultTheme's pre-fix logic; both caught by the new tests, then reverted). Closes #370 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
This PR was opened outside the automated pipeline (author isn't |
📱 iOS Build Status: PASSED✅ iOS Simulator Build & Unit Tests - success iOS UI tests run in a separate, informational job and are not reflected above — check "iOS UI Tests (informational)" for those. |
QA verification — PR #395 vs issue #370Verified against Acceptance criteria (issue #370)
Bug fix found + verified as a real regression guardThe PR also fixes a latent bug it found while wiring SYSTEM: With Test run (real, not trusted from PR body)Ran directly in the worktree ( BUILD SUCCESSFUL. Checked all 43 generated JUnit XML result files across these 5 modules directly: 0 failures, 0 errors across all suites (not just the new tests — this covers the full existing suites too, so no regressions surfaced). Spot-checked the new/changed suites individually:
Regressions / related-area check
Conventions (AGENTS.md)
No blockers found. No QA verdict: PASS |
QA verification — PR #395 vs issue #370Scope: Android "System" reading-theme option ( Acceptance criteria
What I ran
Mutation check (independent of the PR's own claimed mutation testing)Manually reverted Regression / convention check
No gaps found against the issue's acceptance criteria or this repo's testing conventions. QA verdict: PASS |
Principal review — PR #395Verdict: auto-merge ( Risk classification sanity checkRe-ran Verified, not just read
Minor nit (non-blocking)
No CONFIRMED-severity findings, so no issue filed. |
Summary
Android half of #349, tracked as #370 (iOS half — #371 — already merged via #374/#390). Adds a
SYSTEMcase that follows the OS-level light/dark appearance setting, mirroring iOS'sReadingTheme/ConcreteReadingThemesplit (#374) so the compiler enforces resolvingSYSTEMbefore it reaches anything that needs a concrete color.Approach
ReadingTheme(core:ui) andAppReadingTheme(core:domain) both gain aSYSTEMcase.ConcreteReadingTheme(DARK/LIGHT/SEPIA) +ReadingTheme.resolved(systemInDarkTheme: Boolean)— the single place the System→Dark/Light policy lives. Sepia is never a resolution target (not one of the OS's two choices), same call as iOS.when (ReadingTheme)this issue's scope note flagged as a landmine now takesConcreteReadingThemeinstead, resolved at the nearest@Composablecall site viaisSystemInDarkTheme():LibravaultTheme's color-scheme selectionmermaidThemeName(Mermaid diagram theming)toEpubPreferences()/toVaultEpubPreferences()(EpubReaderScreen,VaultEpubReaderScreen)LaunchedEffectkeys include the resolved theme (not just the raw enum) at all three of those call sites, so a live OS appearance change re-applies while System is selected — the "updates live" acceptance criterion, for both the reader chrome and Mermaid diagrams.MainActivitymaps the newAppReadingTheme.SYSTEMcase through toReadingTheme.SYSTEM.ReaderSettingsSheet,VaultReaderSettingsSheet) andSettingsScreenalready iterate.entriesgenerically, so the 4th "System" chip needed no changes there.Bug found while wiring this up
LibravaultTheme's old color-schemewhenonly special-casedSEPIAand otherwise fell straight through to the ambientdarkTheme(system) value — an explicitDARKorLIGHTpick had no actual effect; only the system's own light/dark setting mattered. ResolvingreadingThemeagainstdarkThemeup front (required to supportSYSTEMat all) fixes this as a side effect:DARK/LIGHT/SEPIAnow always win regardless of the system setting, andSYSTEMis the only case that still follows it. Two new regression tests inLibravaultThemeTestcover this directly (explicit Dark winning over an ambient-light system, and explicit Light winning over an ambient-dark system).Tests
ReadingThemeResolutionTest(new):resolved()logic, all fourReadingThemecases.LibravaultThemeTest: System follows system light/dark, plus the two bug-fix regression tests above.MermaidThemeTest: updated toConcreteReadingTheme's 3 cases.ReaderViewModelTest/VaultReaderViewModelTest:onThemeChanged(SYSTEM)round-trips through UI state.SettingsViewModelTest:onReadingThemeChanged(SYSTEM)persists.VaultReaderSettingsSheetUiTest: System renders as a 4th chip and can be shown selected.UserPreferencesRepositoryTest's existingAppReadingTheme.values()loop already covers System's persistence round-trip with no changes needed (additive enum value, no migration).All new/changed logic was mutation-checked locally (deliberately broke
resolved()'s SYSTEM branch and revertedLibravaultTheme's fix back to the old buggy form; both were caught by the new tests, then reverted back).Ran
:core:ui,:core:domain,:feature:reader,:feature:vault,:feature:settingsunit tests locally — all green.Not touched, deliberately
ThemeScreenshotTest) — deliberately kept to 3 images per that file's own doc; System is covered by non-screenshot tests instead. Screenshot baselines are also a sensitive path per.github/agent-policy.yml.feature:reader'sReaderSettingsSheet— no such file existed before this PR (unlikefeature:vault'sVaultReaderSettingsSheetUiTest, extended here); the underlying.entries.forEachmechanism is identical and already covered on the vault side plus the resolution-logic tests.Closes #370
🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com