summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/ColorSchemeTransition.kt17
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/MediaColorSchemes.kt3
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/media/ColorSchemeTransitionTest.kt2
3 files changed, 19 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/media/ColorSchemeTransition.kt b/packages/SystemUI/src/com/android/systemui/media/ColorSchemeTransition.kt
index a6b4f1d2a9d0..f93ce377938b 100644
--- a/packages/SystemUI/src/com/android/systemui/media/ColorSchemeTransition.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/ColorSchemeTransition.kt
@@ -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,
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaColorSchemes.kt b/packages/SystemUI/src/com/android/systemui/media/MediaColorSchemes.kt
index 5e767b0458b9..208766d7f5e6 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaColorSchemes.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaColorSchemes.kt
@@ -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
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/ColorSchemeTransitionTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/ColorSchemeTransitionTest.kt
index 65d501442d87..5463977ec9ae 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/ColorSchemeTransitionTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/ColorSchemeTransitionTest.kt
@@ -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)
}
}