material-components-android
material-components-android copied to clipboard
[Color] Expose more powerful dynamic color extraction
Is your feature request related to a problem? Please describe. I want to implement dynamic coloring in part of my app, but MDC currently provides color extraction functionality that is extremely limited:
- It uses theming overrides that only work on Android 12+
- None of the colors are exposed, which makes it impossible to use outside of a self-contained fragment or activity unless you do some extremely messy Context workarounds
- You seemingly cannot switch/animate between different palettes at runtime, making it useless for i.e music apps whose cover art regularly changes while it's being used.
Describe the solution you'd like Update dynamic color extraction to be:
- Backwards-compatible with pre-Android 12 versions, assuming that an existing Material3-compliant theme is already provided to harmonize with
- Able to return a general Theming object that allows the colors to be easily applied or accessed.
Describe alternatives you've considered Using unmaintained third-party libraries like MonetCompat that are largely proofs-of-concept that likely don't align with the current palette extraction/color harmonization that the M3 spec recommends.
For example, material-color-utilities has a color extractor implementation right here: https://github.com/material-foundation/material-color-utilities/tree/main/typescript. It's in typescript, but this seems like precedent to also make a Java/Kotlin implementation as well.
Wait, the typescript dynamic color implementation is literally 400 lines of code and has tests. This is mostly a simple conversion task that GPT could do (if rights weren't a problem) and then just compared with the tests. Might make an implementation in my app and contribute it back.