Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75ae9ea2 authored by Yein Jo's avatar Yein Jo Committed by Android (Google) Code Review
Browse files

Merge "Migrate to RippleShader#FadeParams to deprecate rippleFill." into tm-qpr-dev

parents 1d6561cb 38f6333d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
+0 −9
Original line number Diff line number Diff line
@@ -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
+28 −2
Original line number Diff line number Diff line
@@ -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