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

Commit 64918d3e authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Revert "Remove DepartingAnimationTarget from BackMotionEvent"

Revert submission 32129017-remove_departing_motion

Reason for revert: b/402422333

Reverted changes: /q/submissionid:32129017-remove_departing_motion

Change-Id: I72a11a2e99f7ffa591b3b17d60e2e86416997844
parent b951f512
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.window;

import android.annotation.FloatRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
import android.view.RemoteAnimationTarget;
@@ -38,6 +39,8 @@ public final class BackMotionEvent implements Parcelable {

    @BackEvent.SwipeEdge
    private final int mSwipeEdge;
    @Nullable
    private final RemoteAnimationTarget mDepartingAnimationTarget;

    /**
     * Creates a new {@link BackMotionEvent} instance.
@@ -50,6 +53,8 @@ public final class BackMotionEvent implements Parcelable {
     * @param progress Value between 0 and 1 on how far along the back gesture is.
     * @param triggerBack Indicates whether the back arrow is in the triggered state or not
     * @param swipeEdge Indicates which edge the swipe starts from.
     * @param departingAnimationTarget The remote animation target of the departing
     *                                 application window.
     */
    public BackMotionEvent(
            float touchX,
@@ -57,13 +62,15 @@ public final class BackMotionEvent implements Parcelable {
            long frameTimeMillis,
            float progress,
            boolean triggerBack,
            @BackEvent.SwipeEdge int swipeEdge) {
            @BackEvent.SwipeEdge int swipeEdge,
            @Nullable RemoteAnimationTarget departingAnimationTarget) {
        mTouchX = touchX;
        mTouchY = touchY;
        mFrameTimeMillis = frameTimeMillis;
        mProgress = progress;
        mTriggerBack = triggerBack;
        mSwipeEdge = swipeEdge;
        mDepartingAnimationTarget = departingAnimationTarget;
    }

    private BackMotionEvent(@NonNull Parcel in) {
@@ -72,6 +79,7 @@ public final class BackMotionEvent implements Parcelable {
        mProgress = in.readFloat();
        mTriggerBack = in.readBoolean();
        mSwipeEdge = in.readInt();
        mDepartingAnimationTarget = in.readTypedObject(RemoteAnimationTarget.CREATOR);
        mFrameTimeMillis = in.readLong();
    }

@@ -100,6 +108,7 @@ public final class BackMotionEvent implements Parcelable {
        dest.writeFloat(mProgress);
        dest.writeBoolean(mTriggerBack);
        dest.writeInt(mSwipeEdge);
        dest.writeTypedObject(mDepartingAnimationTarget, flags);
        dest.writeLong(mFrameTimeMillis);
    }

@@ -151,6 +160,16 @@ public final class BackMotionEvent implements Parcelable {
        return mFrameTimeMillis;
    }

    /**
     * Returns the {@link RemoteAnimationTarget} of the top departing application window,
     * or {@code null} if the top window should not be moved for the current type of back
     * destination.
     */
    @Nullable
    public RemoteAnimationTarget getDepartingAnimationTarget() {
        return mDepartingAnimationTarget;
    }

    @Override
    public String toString() {
        return "BackMotionEvent{"
@@ -160,6 +179,7 @@ public final class BackMotionEvent implements Parcelable {
                + ", mProgress=" + mProgress
                + ", mTriggerBack=" + mTriggerBack
                + ", mSwipeEdge=" + mSwipeEdge
                + ", mDepartingAnimationTarget=" + mDepartingAnimationTarget
                + "}";
    }
}
+6 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.FloatRange;
import android.os.SystemProperties;
import android.util.MathUtils;
import android.view.MotionEvent;
import android.view.RemoteAnimationTarget;

import java.io.PrintWriter;

@@ -146,14 +147,15 @@ public class BackTouchTracker {
    }

    /** Creates a start {@link BackMotionEvent}. */
    public BackMotionEvent createStartEvent() {
    public BackMotionEvent createStartEvent(RemoteAnimationTarget target) {
        return new BackMotionEvent(
                /* touchX = */ mInitTouchX,
                /* touchY = */ mInitTouchY,
                /* frameTimeMillis = */ 0,
                /* progress = */ 0,
                /* triggerBack = */ mTriggerBack,
                /* swipeEdge = */ mSwipeEdge);
                /* swipeEdge = */ mSwipeEdge,
                /* departingAnimationTarget = */ target);
    }

    /** Creates a progress {@link BackMotionEvent}. */
@@ -237,7 +239,8 @@ public class BackTouchTracker {
                /* frameTimeMillis = */ 0,
                /* progress = */ progress,
                /* triggerBack = */ mTriggerBack,
                /* swipeEdge = */ mSwipeEdge);
                /* swipeEdge = */ mSwipeEdge,
                /* departingAnimationTarget = */ null);
    }

    /** Sets the thresholds for computing progress. */
+4 −2
Original line number Diff line number Diff line
@@ -270,7 +270,8 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
                }
                mIOnBackInvokedCallback.onBackStarted(
                        new BackMotionEvent(backEvent.getTouchX(), backEvent.getTouchY(), frameTime,
                                backEvent.getProgress(), false, backEvent.getSwipeEdge()));
                                backEvent.getProgress(), false, backEvent.getSwipeEdge(),
                                null));
            } catch (RemoteException e) {
                Log.e(TAG, "Exception when invoking forwarded callback. e: ", e);
            }
@@ -285,7 +286,8 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
                }
                mIOnBackInvokedCallback.onBackProgressed(
                        new BackMotionEvent(backEvent.getTouchX(), backEvent.getTouchY(), frameTime,
                                backEvent.getProgress(), false, backEvent.getSwipeEdge()));
                                backEvent.getProgress(), false, backEvent.getSwipeEdge(),
                                null));
            } catch (RemoteException e) {
                Log.e(TAG, "Exception when invoking forwarded callback. e: ", e);
            }
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ class BackTouchTrackerTest {
    fun generatesProgress_onStart() {
        val linearTracker = linearTouchTracker()
        linearTracker.setGestureStartLocation(INITIAL_X_LEFT_EDGE, 0f, BackEvent.EDGE_LEFT)
        val event = linearTracker.createStartEvent()
        val event = linearTracker.createStartEvent(null)
        assertEquals(0f, event.progress, 0f)
    }

+2 −1
Original line number Diff line number Diff line
@@ -689,7 +689,8 @@ public class WindowOnBackInvokedDispatcherTest {
                /* frameTimeMillis = */ 0,
                /* progress = */ progress,
                /* triggerBack = */ false,
                /* swipeEdge = */ BackEvent.EDGE_LEFT);
                /* swipeEdge = */ BackEvent.EDGE_LEFT,
                /* departingAnimationTarget = */ null);
    }

    private void verifyImeCallackRegistrations() throws RemoteException {
Loading