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

Commit 1cffc196 authored by Vladislav Kaznacheev's avatar Vladislav Kaznacheev Committed by Android (Google) Code Review
Browse files

Merge "Animate drag shadow when the drag is cancelled"

parents ccec4f6d ce2aef9f
Loading
Loading
Loading
Loading
+23 −4
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.ScaleAnimation;
import android.view.animation.Transformation;
import android.view.animation.TranslateAnimation;
import com.android.server.input.InputApplicationHandle;
@@ -324,6 +325,13 @@ class DragState {
        cleanUpDragLw();
    }

    void cancelDragLw() {
        if (mAnimation != null) {
            return;
        }
        mAnimation = createCancelAnimationLocked();
        mService.scheduleAnimationLocked();
    }

    private void cleanUpDragLw() {
        broadcastDragEndedLw();
@@ -525,11 +533,11 @@ class DragState {
            return false;
        }

        mTransformation.getMatrix().postTranslate(
                mCurrentX - mThumbOffsetX, mCurrentY - mThumbOffsetY);
        final float tmpFloats[] = mService.mTmpFloats;
        mTransformation.getMatrix().getValues(tmpFloats);
        mSurfaceControl.setPosition(
                tmpFloats[Matrix.MTRANS_X] - mThumbOffsetX,
                tmpFloats[Matrix.MTRANS_Y] - mThumbOffsetY);
        mSurfaceControl.setPosition(tmpFloats[Matrix.MTRANS_X], tmpFloats[Matrix.MTRANS_Y]);
        mSurfaceControl.setAlpha(mTransformation.getAlpha());
        mSurfaceControl.setMatrix(tmpFloats[Matrix.MSCALE_X], tmpFloats[Matrix.MSKEW_Y],
                tmpFloats[Matrix.MSKEW_X], tmpFloats[Matrix.MSCALE_Y]);
@@ -539,7 +547,7 @@ class DragState {
    private Animation createReturnAnimationLocked() {
        final AnimationSet set = new AnimationSet(false);
        set.addAnimation(new TranslateAnimation(
                mCurrentX, mOriginalX, mCurrentY, mOriginalY));
                0, mOriginalX - mCurrentX, 0, mOriginalY - mCurrentY));
        set.addAnimation(new AlphaAnimation(mOriginalAlpha, mOriginalAlpha / 2));
        set.setDuration(ANIMATION_DURATION_MS);
        set.setInterpolator(mCubicEaseOutInterpolator);
@@ -547,4 +555,15 @@ class DragState {
        set.start();  // Will start on the first call to getTransformation.
        return set;
    }

    private Animation createCancelAnimationLocked() {
        final AnimationSet set = new AnimationSet(false);
        set.addAnimation(new ScaleAnimation(1, 0, 1, 0, mThumbOffsetX, mThumbOffsetY));
        set.addAnimation(new AlphaAnimation(mOriginalAlpha, 0));
        set.setDuration(ANIMATION_DURATION_MS);
        set.setInterpolator(mCubicEaseOutInterpolator);
        set.initialize(0, 0, 0, 0);
        set.start();  // Will start on the first call to getTransformation.
        return set;
    }
}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -420,7 +420,7 @@ final class Session extends IWindowSession.Stub
                }

                mService.mDragState.mDragResult = false;
                mService.mDragState.endDragLw();
                mService.mDragState.cancelDragLw();
            } finally {
                Binder.restoreCallingIdentity(ident);
            }