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

Commit 63098f4d authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Pass densityDpi into RippleComponent, store as densityScale"

parents 7790fda9 bd5294bc
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.animation.Animator;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.DisplayMetrics;
import android.view.DisplayListCanvas;
import android.view.RenderNodeAnimator;

@@ -50,7 +51,7 @@ abstract class RippleComponent {
    protected float mTargetRadius;

    /** Screen density used to adjust pixel-based constants. */
    protected float mDensity;
    protected float mDensityScale;

    /**
     * If set, force all ripple animations to not run on RenderThread, even if it would be
@@ -71,7 +72,7 @@ abstract class RippleComponent {
        }
    }

    public final void setup(float maxRadius, float density) {
    public final void setup(float maxRadius, int densityDpi) {
        if (maxRadius >= 0) {
            mHasMaxRadius = true;
            mTargetRadius = maxRadius;
@@ -79,7 +80,7 @@ abstract class RippleComponent {
            mTargetRadius = getTargetRadius(mBounds);
        }

        mDensity = density;
        mDensityScale = densityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE;

        onTargetRadiusChanged(mTargetRadius);
    }
+2 −3
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ public class RippleDrawable extends LayerDrawable {
    private Paint mRipplePaint;

    /** Target density of the display into which ripples are drawn. */
    private float mDensity = 1.0f;
    private int mDensity;

    /** Whether bounds are being overridden. */
    private boolean mOverrideBounds;
@@ -544,8 +544,7 @@ public class RippleDrawable extends LayerDrawable {
            mBackground = new RippleBackground(this, mHotspotBounds, mForceSoftware);
        }

        final float densityScale = mState.mDensity * DisplayMetrics.DENSITY_DEFAULT_SCALE;
        mBackground.setup(mState.mMaxRadius, densityScale);
        mBackground.setup(mState.mMaxRadius, mDensity);
        mBackground.enter(focused);
    }

+2 −2
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ class RippleForeground extends RippleComponent {
        }

        final int duration = (int)
                (1000 * Math.sqrt(mTargetRadius / WAVE_TOUCH_DOWN_ACCELERATION * mDensity) + 0.5);
                (1000 * Math.sqrt(mTargetRadius / WAVE_TOUCH_DOWN_ACCELERATION * mDensityScale) + 0.5);

        final ObjectAnimator tweenRadius = ObjectAnimator.ofFloat(this, TWEEN_RADIUS, 1);
        tweenRadius.setAutoCancel(true);
@@ -204,7 +204,7 @@ class RippleForeground extends RippleComponent {
    private int getRadiusExitDuration() {
        final float remainingRadius = mTargetRadius - getCurrentRadius();
        return (int) (1000 * Math.sqrt(remainingRadius / (WAVE_TOUCH_UP_ACCELERATION
                + WAVE_TOUCH_DOWN_ACCELERATION) * mDensity) + 0.5);
                + WAVE_TOUCH_DOWN_ACCELERATION) * mDensityScale) + 0.5);
    }

    private float getCurrentRadius() {