ColorSchemeTransition now updates the ripple color
Fixes: 230329043 Test: Manual & atest ColorSchemeTransitionTest Change-Id: I94c297f17b1bf2d49117a63abb7f0f96d392b31f
This commit is contained in:
@@ -22,6 +22,7 @@ import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.graphics.drawable.RippleDrawable
|
||||
import com.android.internal.R
|
||||
import com.android.internal.annotations.VisibleForTesting
|
||||
import com.android.settingslib.Utils
|
||||
@@ -38,7 +39,7 @@ interface ColorTransition {
|
||||
|
||||
/** A generic implementation of [ColorTransition] so that we can define a factory method. */
|
||||
open class GenericColorTransition(
|
||||
private val applyTheme: (ColorScheme?) -> Unit
|
||||
private val applyTheme: (ColorScheme?) -> Unit
|
||||
) : ColorTransition {
|
||||
override fun updateColorScheme(scheme: ColorScheme?) = applyTheme(scheme)
|
||||
}
|
||||
@@ -130,8 +131,19 @@ class ColorSchemeTransition internal constructor(
|
||||
) { accentPrimary ->
|
||||
val accentColorList = ColorStateList.valueOf(accentPrimary)
|
||||
mediaViewHolder.actionPlayPause.backgroundTintList = accentColorList
|
||||
mediaViewHolder.seamlessButton.backgroundTintList = accentColorList
|
||||
mediaViewHolder.gutsViewHolder.setAccentPrimaryColor(accentPrimary)
|
||||
mediaViewHolder.seamlessButton.backgroundTintList = accentColorList
|
||||
}
|
||||
|
||||
val accentSecondary = animatingColorTransitionFactory(
|
||||
loadDefaultColor(R.attr.textColorPrimary),
|
||||
::accentSecondaryFromScheme
|
||||
) { accentSecondary ->
|
||||
val colorList = ColorStateList.valueOf(accentSecondary)
|
||||
(mediaViewHolder.seamlessButton.background as? RippleDrawable)?.let {
|
||||
it.setColor(colorList)
|
||||
it.effectColor = colorList
|
||||
}
|
||||
}
|
||||
|
||||
val textPrimary = animatingColorTransitionFactory(
|
||||
@@ -203,6 +215,7 @@ class ColorSchemeTransition internal constructor(
|
||||
val colorTransitions = arrayOf(
|
||||
surfaceColor,
|
||||
accentPrimary,
|
||||
accentSecondary,
|
||||
textPrimary,
|
||||
textPrimaryInverse,
|
||||
textSecondary,
|
||||
|
||||
@@ -24,6 +24,9 @@ internal fun surfaceFromScheme(scheme: ColorScheme) = scheme.accent2[9] // A2-80
|
||||
/** Returns the primary accent color for media controls based on the scheme. */
|
||||
internal fun accentPrimaryFromScheme(scheme: ColorScheme) = scheme.accent1[2] // A1-100
|
||||
|
||||
/** Returns the secondary accent color for media controls based on the scheme. */
|
||||
internal fun accentSecondaryFromScheme(scheme: ColorScheme) = scheme.accent1[3] // A1-200
|
||||
|
||||
/** Returns the primary text color for media controls based on the scheme. */
|
||||
internal fun textPrimaryFromScheme(scheme: ColorScheme) = scheme.neutral1[1] // N1-50
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ class ColorSchemeTransitionTest : SysuiTestCase() {
|
||||
@Test
|
||||
fun testColorSchemeTransition_update() {
|
||||
colorSchemeTransition.updateColorScheme(colorScheme)
|
||||
verify(mockAnimatingTransition, times(6)).updateColorScheme(colorScheme)
|
||||
verify(mockAnimatingTransition, times(7)).updateColorScheme(colorScheme)
|
||||
verify(mockGenericTransition).updateColorScheme(colorScheme)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user