Merge "ColorSchemeTransition now updates the ripple color" into tm-dev am: a776c95416 am: d13590e665

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17954103

Change-Id: Ic0dbe98ca82c988d59be50f56722f5e93b838e1b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-05-03 05:25:51 +00:00
committed by Automerger Merge Worker
3 changed files with 19 additions and 3 deletions

View File

@@ -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,

View File

@@ -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

View File

@@ -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)
}
}