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

Commit ac4c063e authored by ztenghui's avatar ztenghui
Browse files

Don't show the background when pressed and focus

According to the spec, the foreground will cover the whole area at
the end of expansion, and do not show the background.

In bounded case, the ripple exit should start from the current value.

b/63635160

Test: demo app, calculator and settings
Change-Id: I64d8b941e2b28ea11165d29de3e6ef77d5ee78f5
parent 5cfb3d7e
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -268,7 +268,7 @@ public class RippleDrawable extends LayerDrawable {

        setRippleActive(focused || (enabled && pressed));

        setBackgroundActive(hovered || focused || (enabled && pressed), focused || hovered);
        setBackgroundActive(hovered, hovered);

        return changed;
    }
@@ -694,7 +694,9 @@ public class RippleDrawable extends LayerDrawable {
        // have a mask or content and the ripple bounds if we're projecting.
        final Rect bounds = getDirtyBounds();
        final int saveCount = canvas.save(Canvas.CLIP_SAVE_FLAG);
        if (isBounded()) {
            canvas.clipRect(bounds);
        }

        drawContent(canvas);
        drawBackgroundAndRipples(canvas);
+6 −33
Original line number Diff line number Diff line
@@ -80,9 +80,6 @@ class RippleForeground extends RippleComponent {
    private float mTweenX = 0;
    private float mTweenY = 0;

    /** Whether this ripple is bounded. */
    private boolean mIsBounded;

    /** Whether this ripple has finished its exit animation. */
    private boolean mHasFinishedExit;

@@ -90,7 +87,6 @@ class RippleForeground extends RippleComponent {
            boolean isBounded, boolean forceSoftware) {
        super(owner, bounds, forceSoftware);

        mIsBounded = isBounded;
        mStartingX = startingX;
        mStartingY = startingY;

@@ -210,31 +206,15 @@ class RippleForeground extends RippleComponent {
        return (int) (1000 * mOpacity / WAVE_OPACITY_DECAY_VELOCITY + 0.5f);
    }

    /**
     * Compute target values that are dependent on bounding.
     */
    private void computeBoundedTargetValues() {
        mTargetX = (mClampedStartingX - mBounds.exactCenterX()) * .7f;
        mTargetY = (mClampedStartingY - mBounds.exactCenterY()) * .7f;
        mTargetRadius = mBoundedRadius;
    }

    @Override
    protected Animator createSoftwareExit() {
        final int radiusDuration;
        final int originDuration;
        final int opacityDuration;
        if (mIsBounded) {
            computeBoundedTargetValues();

            radiusDuration = BOUNDED_RADIUS_EXIT_DURATION;
            originDuration = BOUNDED_ORIGIN_EXIT_DURATION;
            opacityDuration = BOUNDED_OPACITY_EXIT_DURATION;
        } else {
        radiusDuration = getRadiusExitDuration();
        originDuration = radiusDuration;
        opacityDuration = getOpacityExitDuration();
        }

        final ObjectAnimator tweenRadius = ObjectAnimator.ofFloat(this, TWEEN_RADIUS, 1);
        tweenRadius.setAutoCancel(true);
@@ -263,17 +243,10 @@ class RippleForeground extends RippleComponent {
        final int radiusDuration;
        final int originDuration;
        final int opacityDuration;
        if (mIsBounded) {
            computeBoundedTargetValues();

            radiusDuration = BOUNDED_RADIUS_EXIT_DURATION;
            originDuration = BOUNDED_ORIGIN_EXIT_DURATION;
            opacityDuration = BOUNDED_OPACITY_EXIT_DURATION;
        } else {
        radiusDuration = getRadiusExitDuration();
        originDuration = radiusDuration;
        opacityDuration = getOpacityExitDuration();
        }

        final float startX = getCurrentX();
        final float startY = getCurrentY();