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

Commit 5481b649 authored by Jay Aliomer's avatar Jay Aliomer Committed by Automerger Merge Worker
Browse files

Merge "Fix ripple radius calculation" into sc-dev am: 2903ad55

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

Change-Id: I6a039661dcbcc023c8a258bcef86d6f9909b91d4
parents fba4fae3 2903ad55
Loading
Loading
Loading
Loading
+4 −8
Original line number Original line Diff line number Diff line
@@ -184,7 +184,6 @@ public class RippleDrawable extends LayerDrawable {
    private PorterDuffColorFilter mMaskColorFilter;
    private PorterDuffColorFilter mMaskColorFilter;
    private PorterDuffColorFilter mFocusColorFilter;
    private PorterDuffColorFilter mFocusColorFilter;
    private boolean mHasValidMask;
    private boolean mHasValidMask;
    private int mComputedRadius = -1;


    /** The current ripple. May be actively animating or pending entry. */
    /** The current ripple. May be actively animating or pending entry. */
    private RippleForeground mRipple;
    private RippleForeground mRipple;
@@ -390,8 +389,6 @@ public class RippleDrawable extends LayerDrawable {
        if (mRipple != null) {
        if (mRipple != null) {
            mRipple.onBoundsChange();
            mRipple.onBoundsChange();
        }
        }

        mComputedRadius = Math.round(computeRadius());
        invalidateSelf();
        invalidateSelf();
    }
    }


@@ -750,7 +747,7 @@ public class RippleDrawable extends LayerDrawable {
        if (mBackground != null) {
        if (mBackground != null) {
            mBackground.onHotspotBoundsChanged();
            mBackground.onHotspotBoundsChanged();
        }
        }
        float newRadius = Math.round(computeRadius());
        float newRadius = Math.round(getComputedRadius());
        for (int i = 0; i < mRunningAnimations.size(); i++) {
        for (int i = 0; i < mRunningAnimations.size(); i++) {
            RippleAnimationSession s = mRunningAnimations.get(i);
            RippleAnimationSession s = mRunningAnimations.get(i);
            s.setRadius(newRadius);
            s.setRadius(newRadius);
@@ -939,14 +936,13 @@ public class RippleDrawable extends LayerDrawable {
    }
    }


    private float computeRadius() {
    private float computeRadius() {
        Rect b = getDirtyBounds();
        final float halfWidth = mHotspotBounds.width() / 2.0f;
        float radius = (float) Math.sqrt(b.width() * b.width() + b.height() * b.height()) / 2;
        final float halfHeight = mHotspotBounds.height() / 2.0f;
        return radius;
        return (float) Math.sqrt(halfWidth * halfWidth + halfHeight * halfHeight);
    }
    }


    private int getComputedRadius() {
    private int getComputedRadius() {
        if (mState.mMaxRadius >= 0) return mState.mMaxRadius;
        if (mState.mMaxRadius >= 0) return mState.mMaxRadius;
        if (mComputedRadius >= 0) return mComputedRadius;
        return (int) computeRadius();
        return (int) computeRadius();
    }
    }