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

Commit c0e05e4f authored by Yein Jo's avatar Yein Jo Committed by Automerger Merge Worker
Browse files

Merge "Consolidate default values for Ripple shader in one place." into...

Merge "Consolidate default values for Ripple shader in one place." into udc-dev am: da825bf6 am: 39769eb9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22679651



Change-Id: I315be0a6c6524054e652a6188a19dc341d6eb928
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 2880dac1 39769eb9
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -19,17 +19,11 @@ data class RippleAnimationConfig(
    val maxHeight: Float = 0f,
    val pixelDensity: Float = 1f,
    var color: Int = Color.WHITE,
    val opacity: Int = RIPPLE_DEFAULT_ALPHA,
    val sparkleStrength: Float = RIPPLE_SPARKLE_STRENGTH,
    val opacity: Int = RippleShader.RIPPLE_DEFAULT_ALPHA,
    val sparkleStrength: Float = RippleShader.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 {
        const val RIPPLE_SPARKLE_STRENGTH: Float = 0.3f
        const val RIPPLE_DEFAULT_COLOR: Int = 0xffffffff.toInt()
        const val RIPPLE_DEFAULT_ALPHA: Int = 115 // full opacity is 255.
    }
}
)
+4 −0
Original line number Diff line number Diff line
@@ -60,6 +60,10 @@ class RippleShader(rippleShape: RippleShape = RippleShape.CIRCLE) :
        const val DEFAULT_CENTER_FILL_FADE_OUT_START = 0f
        const val DEFAULT_CENTER_FILL_FADE_OUT_END = 0.6f

        const val RIPPLE_SPARKLE_STRENGTH: Float = 0.3f
        const val RIPPLE_DEFAULT_COLOR: Int = 0xffffffff.toInt()
        const val RIPPLE_DEFAULT_ALPHA: Int = 115 // full opacity is 255.

        private const val SHADER_UNIFORMS =
            """
            uniform vec2 in_center;
+3 −3
Original line number Diff line number Diff line
@@ -72,9 +72,9 @@ open class RippleView(context: Context?, attrs: AttributeSet?) : View(context, a
        this.rippleShape = rippleShape
        rippleShader = RippleShader(rippleShape)

        rippleShader.color = RippleAnimationConfig.RIPPLE_DEFAULT_COLOR
        rippleShader.color = RippleShader.RIPPLE_DEFAULT_COLOR
        rippleShader.rawProgress = 0f
        rippleShader.sparkleStrength = RippleAnimationConfig.RIPPLE_SPARKLE_STRENGTH
        rippleShader.sparkleStrength = RippleShader.RIPPLE_SPARKLE_STRENGTH
        rippleShader.pixelDensity = resources.displayMetrics.density

        ripplePaint.shader = rippleShader
@@ -209,7 +209,7 @@ open class RippleView(context: Context?, attrs: AttributeSet?) : View(context, a
     *
     * The alpha value of the color will be applied to the ripple. The alpha range is [0-255].
     */
    fun setColor(color: Int, alpha: Int = RippleAnimationConfig.RIPPLE_DEFAULT_ALPHA) {
    fun setColor(color: Int, alpha: Int = RippleShader.RIPPLE_DEFAULT_ALPHA) {
        rippleShader.color = ColorUtils.setAlphaComponent(color, alpha)
    }

+1 −2
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import com.android.settingslib.Utils;
import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.shared.recents.utilities.Utilities;
import com.android.systemui.surfaceeffects.ripple.RippleAnimationConfig;
import com.android.systemui.surfaceeffects.ripple.RippleShader;
import com.android.systemui.surfaceeffects.ripple.RippleShader.RippleShape;
import com.android.systemui.surfaceeffects.ripple.RippleView;
@@ -177,7 +176,7 @@ final class WirelessChargingLayout extends FrameLayout {
            mRippleView.setBlur(6.5f, 2.5f);
        } else {
            mRippleView.setDuration(CIRCLE_RIPPLE_ANIMATION_DURATION);
            mRippleView.setColor(color, RippleAnimationConfig.RIPPLE_DEFAULT_ALPHA);
            mRippleView.setColor(color, RippleShader.RIPPLE_DEFAULT_ALPHA);
        }

        OnAttachStateChangeListener listener = new OnAttachStateChangeListener() {