Reader: Apply theme to post detail and improve preferences dialog#22723
Open
Reader: Apply theme to post detail and improve preferences dialog#22723
Conversation
Three issues prevented theme changes from being reflected in an already-open post: 1. SharedFlow event dropped: UpdatePostDetails was emitted via launch(bgDispatcher) but the collector was bound to the dialog's viewLifecycleOwner, which was already destroyed by onDismiss time. Fix: call postDetailViewModel directly from onDismiss(). 2. detach/reattach doesn't work with ViewPager2: FragmentStateAdapter manages its own fragments, so manual detach/attach was ignored. Fix: re-render WebView content and update native view colors in place. 3. Repository cache race: the save coroutine on ioDispatcher may not have executed by the time the fragment re-reads preferences. Fix: synchronously update the in-memory cache before the UI reads it. Also explicitly set header text colors from ThemeValues since the ContextThemeWrapper used at inflation time becomes stale, and update the activity status bar color on theme change. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The status bar area on API 35+ is transparent (edge-to-edge), so the visible color comes from the AppBarLayout and its CollapsingToolbarLayout content scrim drawn behind it. Update both when reading preferences theme changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update footer bar background color when reading preferences theme changes so the area behind the transparent navigation bar matches - Remove dead setWindowStatusBarColor call (no-op on SDK 35+) - Inline isDirty() into hasUnsavedChanges property Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of manually updating colors on each view (root, appBar, collapsingToolbar, footer, chips, header text) when reading preferences change, the ViewPager2 adapter now destroys and recreates the current fragment. The new fragment is inflated with a fresh ContextThemeWrapper so all views get correct theme colors automatically. Also removes the Experimental badge from the reading preferences screen and adds chip color support via ColorStateList. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove dead initNavigationBar() method, simplify ReaderExpandableTagsView and ReaderPostDetailHeaderView, and add setDialogWindowStatusBarColor() for dialog windows that aren't subject to edge-to-edge enforcement. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
On SDK 35+, Window.setStatusBarColor() is ignored because the status bar is always transparent. Enable edge-to-edge on the dialog window so the TopAppBar's background color shows through the status bar. Add navigationBarsPadding to the bottom preferences section. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of trying to set the status bar color (which is ignored on SDK 35+), hide the status and navigation bars on the dialog window to match the post detail screen behavior. This removes all status bar color management from the dialog. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The edge-to-edge setup was causing a gap at the top of the dialog where the activity's toolbar was visible. Just hiding the system bars is sufficient. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The BottomSheetDialog's internal container, coordinator, and bottom sheet views all have fitsSystemWindows=true, which adds top padding for the status bar. Clear fitsSystemWindows and padding on these views in onStart() so the dialog content fills the entire screen, matching the post detail screen's full-screen layout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The various approaches to fix the dialog's status bar color on SDK 35+ (setDialogWindowStatusBarColor, edge-to-edge, hiding system bars) did not work correctly. Revert to the original dialog state before those changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…discard UX Replace fullscreen bottom sheet with a non-fullscreen one to avoid SDK 35+ status bar color issues. X (close) discards changes, checkmark saves. Remove all status bar color management logic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove updateCache/updateCachedPreferences which became dead code after the ViewModel's syncCachedPreferences was removed. Also remove the nestedScroll modifier from the reading preferences screen since it is no longer a fullscreen draggable bottom sheet. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…s exist Move STATE_EXPANDED/skipCollapsed into setOnShowListener to avoid the scroll-up-then-down animation on open. Add hasUnsavedChanges StateFlow to conditionally show the save checkmark only when preferences differ from the original values. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The SlideDialogFragmentAnimation was designed for fullscreen dialogs and conflicts with the BottomSheetDialog's built-in entrance animation, causing the sheet to slide to the top of the screen then settle back down. Removing it lets the bottom sheet animate smoothly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace BottomSheetDialogFragment with DialogFragment to eliminate animation conflicts between the window-level slide animation and the BottomSheetBehavior entrance animation. Add rounded corners to the Compose content and use a Material dialog theme overlay. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
Generated by 🚫 Danger |
WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.kt
Fixed
Show fixed
Hide fixed
WordPress/src/main/java/org/wordpress/android/ui/reader/views/ReaderExpandableTagsView.kt
Fixed
Show fixed
Hide fixed
Contributor
|
|
Contributor
|
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #22723 +/- ##
==========================================
- Coverage 37.35% 37.35% -0.01%
==========================================
Files 2316 2316
Lines 123272 123264 -8
Branches 16712 16711 -1
==========================================
- Hits 46053 46046 -7
+ Misses 73520 73519 -1
Partials 3699 3699 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.





Description
This PR started with a simple task: ensure that after choosing a theme from the Reader Preferences, that theme is applied when returning to the post detail. Previously the theme wouldn't be applied until you returned to the post list and re-opened the post.
Unfortunately, the existing Reader Preferences screen suffered from a number of problems, mostly related to using a bottom sheet instead of a standard dialog, and was implemented very differently than the iOS version. So I chose to redo this screen as a standard dialog, similar to iOS, and add icons to the toolbar to save or discard changes (previously there was just an "X" icon).
This was a much bigger task than expected, but I think the end result is quite an improvement over the existing reader preferences.
Testing instructions
Theme applies to open post:
Save/discard behavior:
Landscape scrolling:
reader.mp4