diff --git a/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleShader.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleShader.kt index c764d536609b5..74bc9105c4f3c 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleShader.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleShader.kt @@ -87,7 +87,7 @@ class RippleShader(rippleShape: RippleShape = RippleShape.CIRCLE) : * (1.-sparkleRing) * in_fadeSparkle; float rippleInsideAlpha = (1.-inside) * in_fadeFill; - float rippleRingAlpha = (1.-sparkleRing) * in_fadeRing * in_sparkle_strength; + float rippleRingAlpha = (1.-sparkleRing) * in_fadeRing; float rippleAlpha = max(rippleInsideAlpha, rippleRingAlpha) * in_color.a; vec4 ripple = vec4(in_color.rgb, 1.0) * rippleAlpha; return mix(ripple, vec4(sparkle), sparkle * in_sparkle_strength); diff --git a/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleView.kt b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleView.kt index bc4796aff042b..3c9328c82b832 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleView.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/surfaceeffects/ripple/RippleView.kt @@ -117,15 +117,6 @@ open class RippleView(context: Context?, attrs: AttributeSet?) : View(context, a rippleShader.color = ColorUtils.setAlphaComponent(color, alpha) } - /** - * Set whether the ripple should remain filled as the ripple expands. - * - * See [RippleShader.rippleFill]. - */ - fun setRippleFill(rippleFill: Boolean) { - rippleShader.rippleFill = rippleFill - } - /** Set the intensity of the sparkles. */ fun setSparkleStrength(strength: Float) { rippleShader.sparkleStrength = strength diff --git a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/ReceiverChipRippleView.kt b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/ReceiverChipRippleView.kt index f1acae8e26854..997370b597643 100644 --- a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/ReceiverChipRippleView.kt +++ b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/ReceiverChipRippleView.kt @@ -34,7 +34,7 @@ class ReceiverChipRippleView(context: Context?, attrs: AttributeSet?) : RippleVi init { setupShader(RippleShader.RippleShape.CIRCLE) - setRippleFill(true) + setupRippleFadeParams() setSparkleStrength(0f) isStarted = false } @@ -72,7 +72,7 @@ class ReceiverChipRippleView(context: Context?, attrs: AttributeSet?) : RippleVi animator.removeAllUpdateListeners() // Only show the outline as ripple expands and disappears when animation ends. - setRippleFill(false) + removeRippleFill() val startingPercentage = calculateStartingPercentage(newHeight) animator.duration = EXPAND_TO_FULL_DURATION @@ -103,6 +103,32 @@ class ReceiverChipRippleView(context: Context?, attrs: AttributeSet?) : RippleVi return 1 - remainingPercentage } + private fun setupRippleFadeParams() { + with(rippleShader) { + // No fade out for the base ring. + baseRingFadeParams.fadeOutStart = 1f + baseRingFadeParams.fadeOutEnd = 1f + + // No fade in and outs for the center fill, as we always draw it. + centerFillFadeParams.fadeInStart = 0f + centerFillFadeParams.fadeInEnd = 0f + centerFillFadeParams.fadeOutStart = 1f + centerFillFadeParams.fadeOutEnd = 1f + } + } + + private fun removeRippleFill() { + with(rippleShader) { + baseRingFadeParams.fadeOutStart = RippleShader.DEFAULT_BASE_RING_FADE_OUT_START + baseRingFadeParams.fadeOutEnd = RippleShader.DEFAULT_FADE_OUT_END + + centerFillFadeParams.fadeInStart = RippleShader.DEFAULT_FADE_IN_START + centerFillFadeParams.fadeInEnd = RippleShader.DEFAULT_CENTER_FILL_FADE_IN_END + centerFillFadeParams.fadeOutStart = RippleShader.DEFAULT_CENTER_FILL_FADE_OUT_START + centerFillFadeParams.fadeOutEnd = RippleShader.DEFAULT_CENTER_FILL_FADE_OUT_END + } + } + companion object { const val DEFAULT_DURATION = 333L const val EXPAND_TO_FULL_DURATION = 1000L