Loading packages/SystemUI/src/com/android/systemui/media/controls/ui/animation/ColorSchemeTransition.kt +69 −23 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.graphics.drawable.RippleDrawable import com.android.internal.R import com.android.internal.annotations.VisibleForTesting import com.android.settingslib.Utils import com.android.systemui.Flags import com.android.systemui.media.controls.ui.view.MediaViewHolder import com.android.systemui.monet.ColorScheme import com.android.systemui.surfaceeffects.loadingeffect.LoadingEffect Loading @@ -51,7 +52,7 @@ interface ColorTransition { open class AnimatingColorTransition( private val defaultColor: Int, private val extractColor: (ColorScheme) -> Int, private val applyColor: (Int) -> Unit private val applyColor: (Int) -> Unit, ) : AnimatorUpdateListener, ColorTransition { private val argbEvaluator = ArgbEvaluator() Loading Loading @@ -105,35 +106,52 @@ internal constructor( private val mediaViewHolder: MediaViewHolder, private val multiRippleController: MultiRippleController, private val turbulenceNoiseController: TurbulenceNoiseController, animatingColorTransitionFactory: AnimatingColorTransitionFactory animatingColorTransitionFactory: AnimatingColorTransitionFactory, ) { constructor( context: Context, mediaViewHolder: MediaViewHolder, multiRippleController: MultiRippleController, turbulenceNoiseController: TurbulenceNoiseController turbulenceNoiseController: TurbulenceNoiseController, ) : this( context, mediaViewHolder, multiRippleController, turbulenceNoiseController, ::AnimatingColorTransition ::AnimatingColorTransition, ) var loadingEffect: LoadingEffect? = null val bgColor = context.getColor(com.google.android.material.R.color.material_dynamic_neutral20) val bgColor = if (Flags.mediaControlsUiUpdate()) { context.getColor(R.color.materialColorOnSurface) } else { context.getColor(com.google.android.material.R.color.material_dynamic_neutral20) } val textColor = context.getColor(R.color.materialColorInverseOnSurface) val buttonBgColor = context.getColor(R.color.materialColorPrimary) val insideButtonColor = context.getColor(R.color.materialColorOnPrimary) val surfaceColor = animatingColorTransitionFactory(bgColor, ::surfaceFromScheme) { surfaceColor -> val colorList = ColorStateList.valueOf(surfaceColor) mediaViewHolder.seamlessIcon.imageTintList = colorList mediaViewHolder.seamlessText.setTextColor(surfaceColor) mediaViewHolder.albumView.backgroundTintList = colorList mediaViewHolder.gutsViewHolder.setSurfaceColor(surfaceColor) if (Flags.mediaControlsUiUpdate()) return@animatingColorTransitionFactory mediaViewHolder.seamlessIcon.imageTintList = colorList mediaViewHolder.seamlessText.setTextColor(surfaceColor) } val accentPrimary = animatingColorTransitionFactory( loadDefaultColor(R.attr.textColorPrimary), ::accentPrimaryFromScheme if (Flags.mediaControlsUiUpdate()) { buttonBgColor } else { loadDefaultColor(R.attr.textColorPrimary) }, ::accentPrimaryFromScheme, ) { accentPrimary -> val accentColorList = ColorStateList.valueOf(accentPrimary) mediaViewHolder.actionPlayPause.backgroundTintList = accentColorList Loading @@ -145,8 +163,12 @@ internal constructor( val accentSecondary = animatingColorTransitionFactory( loadDefaultColor(R.attr.textColorPrimary), ::accentSecondaryFromScheme if (Flags.mediaControlsUiUpdate()) { buttonBgColor } else { loadDefaultColor(R.attr.textColorPrimary) }, ::accentSecondaryFromScheme, ) { accentSecondary -> val colorList = ColorStateList.valueOf(accentSecondary) (mediaViewHolder.seamlessButton.background as? RippleDrawable)?.let { Loading @@ -157,7 +179,11 @@ internal constructor( val colorSeamless = animatingColorTransitionFactory( loadDefaultColor(R.attr.textColorPrimary), if (Flags.mediaControlsUiUpdate()) { buttonBgColor } else { loadDefaultColor(R.attr.textColorPrimary) }, { colorScheme: ColorScheme -> // A1-100 dark in dark theme, A1-200 in light theme if ( Loading @@ -170,13 +196,17 @@ internal constructor( { seamlessColor: Int -> val accentColorList = ColorStateList.valueOf(seamlessColor) mediaViewHolder.seamlessButton.backgroundTintList = accentColorList } }, ) val textPrimary = animatingColorTransitionFactory( loadDefaultColor(R.attr.textColorPrimary), ::textPrimaryFromScheme if (Flags.mediaControlsUiUpdate()) { textColor } else { loadDefaultColor(R.attr.textColorPrimary) }, ::textPrimaryFromScheme, ) { textPrimary -> mediaViewHolder.titleText.setTextColor(textPrimary) val textColorList = ColorStateList.valueOf(textPrimary) Loading @@ -192,25 +222,41 @@ internal constructor( val textPrimaryInverse = animatingColorTransitionFactory( loadDefaultColor(R.attr.textColorPrimaryInverse), ::textPrimaryInverseFromScheme if (Flags.mediaControlsUiUpdate()) { insideButtonColor } else { loadDefaultColor(R.attr.textColorPrimaryInverse) }, ::textPrimaryInverseFromScheme, ) { textPrimaryInverse -> mediaViewHolder.actionPlayPause.imageTintList = ColorStateList.valueOf(textPrimaryInverse) val colorList = ColorStateList.valueOf(textPrimaryInverse) mediaViewHolder.actionPlayPause.imageTintList = colorList if (!Flags.mediaControlsUiUpdate()) return@animatingColorTransitionFactory mediaViewHolder.seamlessIcon.imageTintList = colorList mediaViewHolder.seamlessText.setTextColor(textPrimaryInverse) } val textSecondary = animatingColorTransitionFactory( loadDefaultColor(R.attr.textColorSecondary), ::textSecondaryFromScheme if (Flags.mediaControlsUiUpdate()) { textColor } else { loadDefaultColor(R.attr.textColorSecondary) }, ::textSecondaryFromScheme, ) { textSecondary -> mediaViewHolder.artistText.setTextColor(textSecondary) } val textTertiary = animatingColorTransitionFactory( loadDefaultColor(R.attr.textColorTertiary), ::textTertiaryFromScheme if (Flags.mediaControlsUiUpdate()) { textColor } else { loadDefaultColor(R.attr.textColorTertiary) }, ::textTertiaryFromScheme, ) { textTertiary -> mediaViewHolder.seekBar.progressBackgroundTintList = ColorStateList.valueOf(textTertiary) Loading Loading
packages/SystemUI/src/com/android/systemui/media/controls/ui/animation/ColorSchemeTransition.kt +69 −23 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.graphics.drawable.RippleDrawable import com.android.internal.R import com.android.internal.annotations.VisibleForTesting import com.android.settingslib.Utils import com.android.systemui.Flags import com.android.systemui.media.controls.ui.view.MediaViewHolder import com.android.systemui.monet.ColorScheme import com.android.systemui.surfaceeffects.loadingeffect.LoadingEffect Loading @@ -51,7 +52,7 @@ interface ColorTransition { open class AnimatingColorTransition( private val defaultColor: Int, private val extractColor: (ColorScheme) -> Int, private val applyColor: (Int) -> Unit private val applyColor: (Int) -> Unit, ) : AnimatorUpdateListener, ColorTransition { private val argbEvaluator = ArgbEvaluator() Loading Loading @@ -105,35 +106,52 @@ internal constructor( private val mediaViewHolder: MediaViewHolder, private val multiRippleController: MultiRippleController, private val turbulenceNoiseController: TurbulenceNoiseController, animatingColorTransitionFactory: AnimatingColorTransitionFactory animatingColorTransitionFactory: AnimatingColorTransitionFactory, ) { constructor( context: Context, mediaViewHolder: MediaViewHolder, multiRippleController: MultiRippleController, turbulenceNoiseController: TurbulenceNoiseController turbulenceNoiseController: TurbulenceNoiseController, ) : this( context, mediaViewHolder, multiRippleController, turbulenceNoiseController, ::AnimatingColorTransition ::AnimatingColorTransition, ) var loadingEffect: LoadingEffect? = null val bgColor = context.getColor(com.google.android.material.R.color.material_dynamic_neutral20) val bgColor = if (Flags.mediaControlsUiUpdate()) { context.getColor(R.color.materialColorOnSurface) } else { context.getColor(com.google.android.material.R.color.material_dynamic_neutral20) } val textColor = context.getColor(R.color.materialColorInverseOnSurface) val buttonBgColor = context.getColor(R.color.materialColorPrimary) val insideButtonColor = context.getColor(R.color.materialColorOnPrimary) val surfaceColor = animatingColorTransitionFactory(bgColor, ::surfaceFromScheme) { surfaceColor -> val colorList = ColorStateList.valueOf(surfaceColor) mediaViewHolder.seamlessIcon.imageTintList = colorList mediaViewHolder.seamlessText.setTextColor(surfaceColor) mediaViewHolder.albumView.backgroundTintList = colorList mediaViewHolder.gutsViewHolder.setSurfaceColor(surfaceColor) if (Flags.mediaControlsUiUpdate()) return@animatingColorTransitionFactory mediaViewHolder.seamlessIcon.imageTintList = colorList mediaViewHolder.seamlessText.setTextColor(surfaceColor) } val accentPrimary = animatingColorTransitionFactory( loadDefaultColor(R.attr.textColorPrimary), ::accentPrimaryFromScheme if (Flags.mediaControlsUiUpdate()) { buttonBgColor } else { loadDefaultColor(R.attr.textColorPrimary) }, ::accentPrimaryFromScheme, ) { accentPrimary -> val accentColorList = ColorStateList.valueOf(accentPrimary) mediaViewHolder.actionPlayPause.backgroundTintList = accentColorList Loading @@ -145,8 +163,12 @@ internal constructor( val accentSecondary = animatingColorTransitionFactory( loadDefaultColor(R.attr.textColorPrimary), ::accentSecondaryFromScheme if (Flags.mediaControlsUiUpdate()) { buttonBgColor } else { loadDefaultColor(R.attr.textColorPrimary) }, ::accentSecondaryFromScheme, ) { accentSecondary -> val colorList = ColorStateList.valueOf(accentSecondary) (mediaViewHolder.seamlessButton.background as? RippleDrawable)?.let { Loading @@ -157,7 +179,11 @@ internal constructor( val colorSeamless = animatingColorTransitionFactory( loadDefaultColor(R.attr.textColorPrimary), if (Flags.mediaControlsUiUpdate()) { buttonBgColor } else { loadDefaultColor(R.attr.textColorPrimary) }, { colorScheme: ColorScheme -> // A1-100 dark in dark theme, A1-200 in light theme if ( Loading @@ -170,13 +196,17 @@ internal constructor( { seamlessColor: Int -> val accentColorList = ColorStateList.valueOf(seamlessColor) mediaViewHolder.seamlessButton.backgroundTintList = accentColorList } }, ) val textPrimary = animatingColorTransitionFactory( loadDefaultColor(R.attr.textColorPrimary), ::textPrimaryFromScheme if (Flags.mediaControlsUiUpdate()) { textColor } else { loadDefaultColor(R.attr.textColorPrimary) }, ::textPrimaryFromScheme, ) { textPrimary -> mediaViewHolder.titleText.setTextColor(textPrimary) val textColorList = ColorStateList.valueOf(textPrimary) Loading @@ -192,25 +222,41 @@ internal constructor( val textPrimaryInverse = animatingColorTransitionFactory( loadDefaultColor(R.attr.textColorPrimaryInverse), ::textPrimaryInverseFromScheme if (Flags.mediaControlsUiUpdate()) { insideButtonColor } else { loadDefaultColor(R.attr.textColorPrimaryInverse) }, ::textPrimaryInverseFromScheme, ) { textPrimaryInverse -> mediaViewHolder.actionPlayPause.imageTintList = ColorStateList.valueOf(textPrimaryInverse) val colorList = ColorStateList.valueOf(textPrimaryInverse) mediaViewHolder.actionPlayPause.imageTintList = colorList if (!Flags.mediaControlsUiUpdate()) return@animatingColorTransitionFactory mediaViewHolder.seamlessIcon.imageTintList = colorList mediaViewHolder.seamlessText.setTextColor(textPrimaryInverse) } val textSecondary = animatingColorTransitionFactory( loadDefaultColor(R.attr.textColorSecondary), ::textSecondaryFromScheme if (Flags.mediaControlsUiUpdate()) { textColor } else { loadDefaultColor(R.attr.textColorSecondary) }, ::textSecondaryFromScheme, ) { textSecondary -> mediaViewHolder.artistText.setTextColor(textSecondary) } val textTertiary = animatingColorTransitionFactory( loadDefaultColor(R.attr.textColorTertiary), ::textTertiaryFromScheme if (Flags.mediaControlsUiUpdate()) { textColor } else { loadDefaultColor(R.attr.textColorTertiary) }, ::textTertiaryFromScheme, ) { textTertiary -> mediaViewHolder.seekBar.progressBackgroundTintList = ColorStateList.valueOf(textTertiary) Loading