Skip to content

Add Material You dynamic color and fix system bar icon contrast#481

Open
ElCruncharino wants to merge 2 commits into
LivingWithHippos:masterfrom
ElCruncharino:feat/material-you-theming
Open

Add Material You dynamic color and fix system bar icon contrast#481
ElCruncharino wants to merge 2 commits into
LivingWithHippos:masterfrom
ElCruncharino:feat/material-you-theming

Conversation

@ElCruncharino

Copy link
Copy Markdown
Contributor

Adds a wallpaper-based Material You option to the theme picker on Android 12+, using Material
Components' own DynamicColors API, which overlays the device's wallpaper-derived palette on top
of the app's existing Material 3 theme structure.

Also fixes the actual bug reported in #315: status and navigation bar icon color was set once,
statically, per day/night mode, assuming every theme gets darker at night. None of the 9
existing themes actually have night-specific colors, so the assumption doesn't hold, and the
mismatch between the static assumption and each theme's real colors could make system icons
invisible in either mode depending on which theme was active, not just the reporter's. Icon
color is now computed from the actual applied colorPrimary/colorSurface luminance after each
theme (static or dynamic) is applied, so it stays legible regardless of theme or day/night mode.

While in there, rebuilt the theme picker itself as a bottom sheet instead of a plain alert
dialog with a custom view. The old dialog's RecyclerView height didn't resolve reliably against
the alert dialog's own ambiguous sizing, silently clipping the list short of whatever fit by
coincidence, cutting off the last couple of themes together with Material You without any
indication there was more below. Each theme row now also shows a check mark for the active one
instead of a separate label that could overlap the list at larger font scales.

This branch is stacked on #476 (apply theme changes instantly), since the picker's instant
recreate-on-select behavior comes from there. Once #476 merges the diff here will shrink to just
this PR's changes.

Closes #315

Picking a new theme now recreates the current activity right away.
Since the app has two activities (MainActivity and SettingsActivity),
ThemingCallback also checks on every activity resume whether the saved
theme differs from what that activity was created with, and recreates
it too, so MainActivity picks up the change as soon as you back out of
Settings instead of needing a full app restart.

Removes the now-inaccurate "restart to apply" summary and string.
…LivingWithHippos#315)

Adds a wallpaper-based Material You option to the theme picker on
Android 12+, using Material Components' own DynamicColors API, which
overlays the device's wallpaper-derived palette on top of the app's
existing Material 3 theme structure.

Also fixes the actual bug reported in LivingWithHippos#315: status and navigation bar
icon color was set once, statically, per day/night mode, assuming
every theme gets darker at night. None of the 9 existing themes
actually have night-specific colors, so the assumption doesn't hold,
and the mismatch between the static assumption and each theme's real
colors could make system icons invisible in either mode depending on
which theme was active, not just the reporter's. Icon color is now
computed from the actual applied colorPrimary/colorSurface luminance
after each theme (static or dynamic) is applied, so it stays legible
regardless of theme or day/night mode.

While in there, rebuilt the theme picker itself as a bottom sheet
instead of a plain alert dialog with a custom view. The old dialog's
RecyclerView height didn't resolve reliably against the alert dialog's
own ambiguous sizing, silently clipping the list short of whatever fit
by coincidence, cutting off the last couple of themes together with
Material You without any indication there was more below. Each theme
row now also shows a check mark for the active one instead of a
separate label that could overlap the list at larger font scales.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] Dynamic themes

1 participant