Merge "Remove rippleFill from RippleShader (last one)." into tm-qpr-dev am: b488504cf3
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21166601 Change-Id: I70f05223dc2de47670b8fcf37d5743f8613ab128 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -66,11 +66,28 @@ class RippleAnimation(private val config: RippleAnimationConfig) {
|
|||||||
fun isPlaying(): Boolean = animator.isRunning
|
fun isPlaying(): Boolean = animator.isRunning
|
||||||
|
|
||||||
private fun applyConfigToShader() {
|
private fun applyConfigToShader() {
|
||||||
rippleShader.setCenter(config.centerX, config.centerY)
|
with(rippleShader) {
|
||||||
rippleShader.setMaxSize(config.maxWidth, config.maxHeight)
|
setCenter(config.centerX, config.centerY)
|
||||||
rippleShader.rippleFill = config.shouldFillRipple
|
setMaxSize(config.maxWidth, config.maxHeight)
|
||||||
rippleShader.pixelDensity = config.pixelDensity
|
pixelDensity = config.pixelDensity
|
||||||
rippleShader.color = ColorUtils.setAlphaComponent(config.color, config.opacity)
|
color = ColorUtils.setAlphaComponent(config.color, config.opacity)
|
||||||
rippleShader.sparkleStrength = config.sparkleStrength
|
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,
|
val pixelDensity: Float = 1f,
|
||||||
var color: Int = Color.WHITE,
|
var color: Int = Color.WHITE,
|
||||||
val opacity: Int = RIPPLE_DEFAULT_ALPHA,
|
val opacity: Int = RIPPLE_DEFAULT_ALPHA,
|
||||||
val shouldFillRipple: Boolean = false,
|
|
||||||
val sparkleStrength: Float = RIPPLE_SPARKLE_STRENGTH,
|
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
|
val shouldDistort: Boolean = true
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -270,38 +270,6 @@ class RippleShader(rippleShape: RippleShape = RippleShape.CIRCLE) :
|
|||||||
var currentHeight: Float = 0f
|
var currentHeight: Float = 0f
|
||||||
private set
|
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. */
|
/** Parameters that are used to fade in/ out of the sparkle ring. */
|
||||||
val sparkleRingFadeParams =
|
val sparkleRingFadeParams =
|
||||||
FadeParams(
|
FadeParams(
|
||||||
@@ -324,12 +292,7 @@ class RippleShader(rippleShape: RippleShape = RippleShape.CIRCLE) :
|
|||||||
DEFAULT_FADE_OUT_END
|
DEFAULT_FADE_OUT_END
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/** Parameters that are used to fade in/ out of the center fill. */
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
val centerFillFadeParams =
|
val centerFillFadeParams =
|
||||||
FadeParams(
|
FadeParams(
|
||||||
DEFAULT_FADE_IN_START,
|
DEFAULT_FADE_IN_START,
|
||||||
|
|||||||
@@ -1136,8 +1136,10 @@ public class MediaControlPanel {
|
|||||||
/* pixelDensity= */ getContext().getResources().getDisplayMetrics().density,
|
/* pixelDensity= */ getContext().getResources().getDisplayMetrics().density,
|
||||||
mColorSchemeTransition.getAccentPrimary().getCurrentColor(),
|
mColorSchemeTransition.getAccentPrimary().getCurrentColor(),
|
||||||
/* opacity= */ 100,
|
/* opacity= */ 100,
|
||||||
/* shouldFillRipple= */ false,
|
|
||||||
/* sparkleStrength= */ 0f,
|
/* sparkleStrength= */ 0f,
|
||||||
|
/* baseRingFadeParams= */ null,
|
||||||
|
/* sparkleRingFadeParams= */ null,
|
||||||
|
/* centerFillFadeParams= */ null,
|
||||||
/* shouldDistort= */ false
|
/* shouldDistort= */ false
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -42,13 +42,35 @@ class RippleAnimationTest : SysuiTestCase() {
|
|||||||
pixelDensity = 2f,
|
pixelDensity = 2f,
|
||||||
color = Color.RED,
|
color = Color.RED,
|
||||||
opacity = 30,
|
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
|
sparkleStrength = 0.3f
|
||||||
)
|
)
|
||||||
val rippleAnimation = RippleAnimation(config)
|
val rippleAnimation = RippleAnimation(config)
|
||||||
|
|
||||||
with(rippleAnimation.rippleShader) {
|
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(pixelDensity).isEqualTo(config.pixelDensity)
|
||||||
assertThat(color).isEqualTo(ColorUtils.setAlphaComponent(config.color, config.opacity))
|
assertThat(color).isEqualTo(ColorUtils.setAlphaComponent(config.color, config.opacity))
|
||||||
assertThat(sparkleStrength).isEqualTo(config.sparkleStrength)
|
assertThat(sparkleStrength).isEqualTo(config.sparkleStrength)
|
||||||
|
|||||||
Reference in New Issue
Block a user