about: fix inconsistent tinting
This commit is contained in:
@@ -548,9 +548,14 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||||||
*/
|
*/
|
||||||
private class StyledDrawable(
|
private class StyledDrawable(
|
||||||
context: Context,
|
context: Context,
|
||||||
private val inner: Drawable,
|
inner: Drawable,
|
||||||
@Px val iconSize: Int?,
|
@Px val iconSize: Int?,
|
||||||
) : Drawable() {
|
) : Drawable() {
|
||||||
|
// Never tint a shared drawable instance. These icons are also used elsewhere (e.g. the
|
||||||
|
// About screen), and tinting without mutation can leak the modified tint state across
|
||||||
|
// views in inconsistent ways depending on drawable caching/inflation order.
|
||||||
|
private val inner: Drawable = (inner.constantState?.newDrawable() ?: inner).mutate()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Re-tint the drawable to use the analogous "on surface" color for
|
// Re-tint the drawable to use the analogous "on surface" color for
|
||||||
// StyledImageView.
|
// StyledImageView.
|
||||||
|
|||||||
Reference in New Issue
Block a user