fix: apply dynamic (Material You) colors to backgrounds, toggles, and status bar on API 31+#587
Open
mvanhorn wants to merge 1 commit into
Open
Conversation
… status bar on API 31+
Contributor
|
This PR builds correctly, here is the generated apk.
You must be logged in for the link to work. This is an automatic comment created by a Github Action based on a previous Github Action |
Owner
|
Thank you for the PR, much appreciated. As I mentioned in the other one, I'm currently out-of-programming for a bit, so it may take time until I can properly review this (feel free to ping me in a month if needed). This pr however only touches assets, so it may be faster (a bit concerned about the 88 lines to the style file though) |
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.
Summary
On Android 12+ with dynamic colors, backgrounds, switches, the status bar, and dialog surfaces now follow the wallpaper-derived palette instead of keeping stock colors. Text and icons already picked it up; this fills in the surfaces that did not.
Why this matters
You confirmed the report in #560 (One UI screenshots) and noted a special configuration for switches and backgrounds would probably be needed, with the constraint that no appcompat/Material dependency be added. This stays library-free: it wires the platform's own
@android:color/system_accent1_*/system_neutral1_*resources (API 31+) into the existingTheme.DeviceDefault*styles through resource-qualifier overlays, which the OEM skins populate from the dynamic-color engine.Changes
values-v31/styles.xmlredefines the existing theme styles with explicitcolorAccent,colorControlActivated,colorControlHighlight,colorBackground,windowBackground, andstatusBarColorentries; the v29 items (windowLightStatusBar,navigationBarColor) are carried over so nothing regresses.values-v31/colors.xml(day) and overridden invalues-night-v31/colors.xml(night).AndroidSettings.setThemealready applies these style IDs; resource resolution picks the v31 variants on Android 12+, so behavior below API 31 is untouched.Testing
Built and inspected resource resolution for the v31 qualifiers. Verified the style names and item sets mirror the base
values/styles.xmldefinitions so pre-31 devices resolve exactly the resources they resolve today.Fixes #560