Remove rippleFill from RippleShader (last one).
Bug: 265326983 Test: Manual with adb commands, MediaControlPanelTest, RippleAnimationTest Change-Id: I19f5055af17b71b7c7b7a02f636c568ecad41179
This commit is contained in:
@@ -66,11 +66,28 @@ class RippleAnimation(private val config: RippleAnimationConfig) {
|
||||
fun isPlaying(): Boolean = animator.isRunning
|
||||
|
||||
private fun applyConfigToShader() {
|
||||
rippleShader.setCenter(config.centerX, config.centerY)
|
||||
rippleShader.setMaxSize(config.maxWidth, config.maxHeight)
|
||||
rippleShader.rippleFill = config.shouldFillRipple
|
||||
rippleShader.pixelDensity = config.pixelDensity
|
||||
rippleShader.color = ColorUtils.setAlphaComponent(config.color, config.opacity)
|
||||
rippleShader.sparkleStrength = config.sparkleStrength
|
||||
with(rippleShader) {
|
||||
setCenter(config.centerX, config.centerY)
|
||||
setMaxSize(config.maxWidth, config.maxHeight)
|
||||
pixelDensity = config.pixelDensity
|
||||
color = ColorUtils.setAlphaComponent(config.color, config.opacity)
|
||||
sparkleStrength = config.sparkleStrength
|
||||
|
||||
assignFadeParams(baseRingFadeParams, config.baseRingFadeParams)
|
||||
assignFadeParams(sparkleRingFadeParams, config.sparkleRingFadeParams)
|
||||
assignFadeParams(centerFillFadeParams, config.centerFillFadeParams)
|
||||
}
|
||||
}
|
||||
|
||||
private fun assignFadeParams(
|
||||
destFadeParams: RippleShader.FadeParams,
|
||||
srcFadeParams: RippleShader.FadeParams?
|
||||
) {
|
||||
srcFadeParams?.let {
|
||||
destFadeParams.fadeInStart = it.fadeInStart
|
||||
destFadeParams.fadeInEnd = it.fadeInEnd
|
||||
destFadeParams.fadeOutStart = it.fadeOutStart
|
||||
destFadeParams.fadeOutEnd = it.fadeOutEnd
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,11 @@ data class RippleAnimationConfig(
|
||||
val pixelDensity: Float = 1f,
|
||||
var color: Int = Color.WHITE,
|
||||
val opacity: Int = RIPPLE_DEFAULT_ALPHA,
|
||||
val shouldFillRipple: Boolean = false,
|
||||
val sparkleStrength: Float = RIPPLE_SPARKLE_STRENGTH,
|
||||
// Null means it uses default fade parameter values.
|
||||
val baseRingFadeParams: RippleShader.FadeParams? = null,
|
||||
val sparkleRingFadeParams: RippleShader.FadeParams? = null,
|
||||
val centerFillFadeParams: RippleShader.FadeParams? = null,
|
||||
val shouldDistort: Boolean = true
|
||||
) {
|
||||
companion object {
|
||||
|
||||
@@ -270,38 +270,6 @@ class RippleShader(rippleShape: RippleShape = RippleShape.CIRCLE) :
|
||||
var currentHeight: Float = 0f
|
||||
private set
|
||||
|
||||
/**
|
||||
* True if the ripple should stayed filled in as it expands to give a filled-in circle effect.
|
||||
* False for a ring effect.
|
||||
*
|
||||
* <p>You must reset fade params after changing this.
|
||||
*
|
||||
* TODO(b/265326983): Remove this and only expose fade params.
|
||||
*/
|
||||
var rippleFill: Boolean = false
|
||||
set(value) {
|
||||
if (value) {
|
||||
baseRingFadeParams.fadeOutStart = 1f
|
||||
baseRingFadeParams.fadeOutEnd = 1f
|
||||
|
||||
centerFillFadeParams.fadeInStart = 0f
|
||||
centerFillFadeParams.fadeInEnd = 0f
|
||||
centerFillFadeParams.fadeOutStart = 1f
|
||||
centerFillFadeParams.fadeOutEnd = 1f
|
||||
} else {
|
||||
// Set back to the original fade parameters.
|
||||
// Ideally this should be set by the client as they know the initial value.
|
||||
baseRingFadeParams.fadeOutStart = DEFAULT_BASE_RING_FADE_OUT_START
|
||||
baseRingFadeParams.fadeOutEnd = DEFAULT_FADE_OUT_END
|
||||
|
||||
centerFillFadeParams.fadeInStart = DEFAULT_FADE_IN_START
|
||||
centerFillFadeParams.fadeInEnd = DEFAULT_CENTER_FILL_FADE_IN_END
|
||||
centerFillFadeParams.fadeOutStart = DEFAULT_CENTER_FILL_FADE_OUT_START
|
||||
centerFillFadeParams.fadeOutEnd = DEFAULT_CENTER_FILL_FADE_OUT_END
|
||||
}
|
||||
field = value
|
||||
}
|
||||
|
||||
/** Parameters that are used to fade in/ out of the sparkle ring. */
|
||||
val sparkleRingFadeParams =
|
||||
FadeParams(
|
||||
@@ -324,12 +292,7 @@ class RippleShader(rippleShape: RippleShape = RippleShape.CIRCLE) :
|
||||
DEFAULT_FADE_OUT_END
|
||||
)
|
||||
|
||||
/**
|
||||
* Parameters that are used to fade in/ out of the center fill.
|
||||
*
|
||||
* <p>Note that if [rippleFill] is set to true, those will be ignored and the center fill will
|
||||
* be always full alpha.
|
||||
*/
|
||||
/** Parameters that are used to fade in/ out of the center fill. */
|
||||
val centerFillFadeParams =
|
||||
FadeParams(
|
||||
DEFAULT_FADE_IN_START,
|
||||
|
||||
@@ -1136,8 +1136,10 @@ public class MediaControlPanel {
|
||||
/* pixelDensity= */ getContext().getResources().getDisplayMetrics().density,
|
||||
mColorSchemeTransition.getAccentPrimary().getCurrentColor(),
|
||||
/* opacity= */ 100,
|
||||
/* shouldFillRipple= */ false,
|
||||
/* sparkleStrength= */ 0f,
|
||||
/* baseRingFadeParams= */ null,
|
||||
/* sparkleRingFadeParams= */ null,
|
||||
/* centerFillFadeParams= */ null,
|
||||
/* shouldDistort= */ false
|
||||
)
|
||||
);
|
||||
|
||||
@@ -42,13 +42,35 @@ class RippleAnimationTest : SysuiTestCase() {
|
||||
pixelDensity = 2f,
|
||||
color = Color.RED,
|
||||
opacity = 30,
|
||||
shouldFillRipple = true,
|
||||
baseRingFadeParams =
|
||||
RippleShader.FadeParams(
|
||||
fadeInStart = 0f,
|
||||
fadeInEnd = 0.3f,
|
||||
fadeOutStart = 0.5f,
|
||||
fadeOutEnd = 1f
|
||||
),
|
||||
sparkleRingFadeParams =
|
||||
RippleShader.FadeParams(
|
||||
fadeInStart = 0.1f,
|
||||
fadeInEnd = 0.2f,
|
||||
fadeOutStart = 0.7f,
|
||||
fadeOutEnd = 0.9f
|
||||
),
|
||||
centerFillFadeParams =
|
||||
RippleShader.FadeParams(
|
||||
fadeInStart = 0f,
|
||||
fadeInEnd = 0.1f,
|
||||
fadeOutStart = 0.2f,
|
||||
fadeOutEnd = 0.3f
|
||||
),
|
||||
sparkleStrength = 0.3f
|
||||
)
|
||||
val rippleAnimation = RippleAnimation(config)
|
||||
|
||||
with(rippleAnimation.rippleShader) {
|
||||
assertThat(rippleFill).isEqualTo(config.shouldFillRipple)
|
||||
assertThat(baseRingFadeParams).isEqualTo(config.baseRingFadeParams)
|
||||
assertThat(sparkleRingFadeParams).isEqualTo(config.sparkleRingFadeParams)
|
||||
assertThat(centerFillFadeParams).isEqualTo(config.centerFillFadeParams)
|
||||
assertThat(pixelDensity).isEqualTo(config.pixelDensity)
|
||||
assertThat(color).isEqualTo(ColorUtils.setAlphaComponent(config.color, config.opacity))
|
||||
assertThat(sparkleStrength).isEqualTo(config.sparkleStrength)
|
||||
|
||||
Reference in New Issue
Block a user