Skip to content

feat(theme): backport wallpaper color extraction to API < 31 - #1219

Merged
rukamori merged 6 commits into
rukamori:devfrom
sang765:backport-wallpaper-color-api-31
Aug 27, 2026
Merged

feat(theme): backport wallpaper color extraction to API < 31#1219
rukamori merged 6 commits into
rukamori:devfrom
sang765:backport-wallpaper-color-api-31

Conversation

@sang765

@sang765 sang765 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Uses WallpaperManager to extract the device wallpaper bitmap and derive a seed color via the existing Palette-based extractThemeColor(). On API below 31 this seed color feeds into MaterialKolor to produce a full M3 ColorScheme, giving Material You-style wallpaper-adaptive theming on older devices where the system dynamic color API is unavailable.

Changes

  • Theme.kt: added extractWallpaperThemeColor(context) function that gets the wallpaper drawable, converts to bitmap, and calls the existing extractThemeColor() Palette extraction
  • MainActivity.kt: when no song is playing and dynamic theme is enabled, uses wallpaper color as seed on API below 31 (falls back to customThemeColor if extraction fails)

Behavior

Scenario API below 31 API 31+
Song playing Album art color (unchanged) Album art color (unchanged)
No song, dynamic theme ON Wallpaper color - new System dynamic color (unchanged)
No song, dynamic theme OFF Custom palette/color (unchanged) Custom palette/color (unchanged)

Notes

  • No new dependencies - reuses existing androidx.palette:palette-ktx and com.materialkolor:material-kolor
  • WallpaperManager.getDrawable() requires no runtime permissions on API 24+
  • Safely falls back to customThemeColor on any extraction failure
  • minSdk = 26 ensures WallpaperManager.getDrawable() (API 24) is always available

Use WallpaperManager to extract the device wallpaper bitmap and derive
a seed color via the existing Palette-based extractThemeColor(). On
API < 31 this seed color feeds into MaterialKolor to produce a full
M3 ColorScheme, giving Material You-style wallpaper-adaptive theming
on older devices where the system dynamic color API is unavailable.
@sang765
sang765 force-pushed the backport-wallpaper-color-api-31 branch from 92704b8 to 82a546e Compare August 24, 2026 15:21
On API below 31, the random theme on startup toggle was visible even
when dynamic theme was enabled (since wallpaper color now serves as
the seed). Hide it unconditionally when dynamic theme is on — it has
no effect in that mode anyway.
When dynamic theme is enabled on devices below API 31, show a
"Wallpaper color permission" entry that opens the app settings
page. This lets users grant READ_EXTERNAL_STORAGE on OEM devices
that restrict wallpaper access beyond the standard API.
…ails

Track wallpaper color extraction result via WallpaperExtractionFailedKey
in DataStore. The permission entry now only appears when dynamic theme
is enabled on API below 31 AND the wallpaper extraction actually failed,
instead of showing unconditionally.
@sang765
sang765 marked this pull request as ready for review August 25, 2026 10:01
@rukamori
rukamori merged commit eb55a19 into rukamori:dev Aug 27, 2026
1 check passed
sang765 added a commit to sang765/AT that referenced this pull request Aug 28, 2026
…i#1219)

Co-authored-by: morieeattonkatsu <107134739+rukamori@users.noreply.github.com>
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.

2 participants