Merge "Migrate to RippleShader#FadeParams to deprecate rippleFill." into tm-qpr-dev
This commit is contained in:
@@ -87,7 +87,7 @@ class RippleShader(rippleShape: RippleShape = RippleShape.CIRCLE) :
|
|||||||
* (1.-sparkleRing) * in_fadeSparkle;
|
* (1.-sparkleRing) * in_fadeSparkle;
|
||||||
|
|
||||||
float rippleInsideAlpha = (1.-inside) * in_fadeFill;
|
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;
|
float rippleAlpha = max(rippleInsideAlpha, rippleRingAlpha) * in_color.a;
|
||||||
vec4 ripple = vec4(in_color.rgb, 1.0) * rippleAlpha;
|
vec4 ripple = vec4(in_color.rgb, 1.0) * rippleAlpha;
|
||||||
return mix(ripple, vec4(sparkle), sparkle * in_sparkle_strength);
|
return mix(ripple, vec4(sparkle), sparkle * in_sparkle_strength);
|
||||||
|
|||||||
@@ -117,15 +117,6 @@ open class RippleView(context: Context?, attrs: AttributeSet?) : View(context, a
|
|||||||
rippleShader.color = ColorUtils.setAlphaComponent(color, alpha)
|
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. */
|
/** Set the intensity of the sparkles. */
|
||||||
fun setSparkleStrength(strength: Float) {
|
fun setSparkleStrength(strength: Float) {
|
||||||
rippleShader.sparkleStrength = strength
|
rippleShader.sparkleStrength = strength
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class ReceiverChipRippleView(context: Context?, attrs: AttributeSet?) : RippleVi
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
setupShader(RippleShader.RippleShape.CIRCLE)
|
setupShader(RippleShader.RippleShape.CIRCLE)
|
||||||
setRippleFill(true)
|
setupRippleFadeParams()
|
||||||
setSparkleStrength(0f)
|
setSparkleStrength(0f)
|
||||||
isStarted = false
|
isStarted = false
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ class ReceiverChipRippleView(context: Context?, attrs: AttributeSet?) : RippleVi
|
|||||||
animator.removeAllUpdateListeners()
|
animator.removeAllUpdateListeners()
|
||||||
|
|
||||||
// Only show the outline as ripple expands and disappears when animation ends.
|
// Only show the outline as ripple expands and disappears when animation ends.
|
||||||
setRippleFill(false)
|
removeRippleFill()
|
||||||
|
|
||||||
val startingPercentage = calculateStartingPercentage(newHeight)
|
val startingPercentage = calculateStartingPercentage(newHeight)
|
||||||
animator.duration = EXPAND_TO_FULL_DURATION
|
animator.duration = EXPAND_TO_FULL_DURATION
|
||||||
@@ -103,6 +103,32 @@ class ReceiverChipRippleView(context: Context?, attrs: AttributeSet?) : RippleVi
|
|||||||
return 1 - remainingPercentage
|
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 {
|
companion object {
|
||||||
const val DEFAULT_DURATION = 333L
|
const val DEFAULT_DURATION = 333L
|
||||||
const val EXPAND_TO_FULL_DURATION = 1000L
|
const val EXPAND_TO_FULL_DURATION = 1000L
|
||||||
|
|||||||
Reference in New Issue
Block a user