Loading core/java/android/window/BackMotionEvent.java +21 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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. Loading @@ -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, Loading @@ -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) { Loading @@ -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(); } Loading Loading @@ -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); } Loading Loading @@ -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{" Loading @@ -160,6 +179,7 @@ public final class BackMotionEvent implements Parcelable { + ", mProgress=" + mProgress + ", mTriggerBack=" + mTriggerBack + ", mSwipeEdge=" + mSwipeEdge + ", mDepartingAnimationTarget=" + mDepartingAnimationTarget + "}"; } } core/java/android/window/BackTouchTracker.java +6 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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}. */ Loading Loading @@ -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. */ Loading core/java/android/window/ImeOnBackInvokedDispatcher.java +4 −2 Original line number Diff line number Diff line Loading @@ -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); } Loading @@ -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); } Loading core/tests/coretests/src/android/window/BackTouchTrackerTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -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) } Loading core/tests/coretests/src/android/window/WindowOnBackInvokedDispatcherTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -695,7 +695,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 Loading
core/java/android/window/BackMotionEvent.java +21 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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. Loading @@ -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, Loading @@ -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) { Loading @@ -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(); } Loading Loading @@ -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); } Loading Loading @@ -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{" Loading @@ -160,6 +179,7 @@ public final class BackMotionEvent implements Parcelable { + ", mProgress=" + mProgress + ", mTriggerBack=" + mTriggerBack + ", mSwipeEdge=" + mSwipeEdge + ", mDepartingAnimationTarget=" + mDepartingAnimationTarget + "}"; } }
core/java/android/window/BackTouchTracker.java +6 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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}. */ Loading Loading @@ -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. */ Loading
core/java/android/window/ImeOnBackInvokedDispatcher.java +4 −2 Original line number Diff line number Diff line Loading @@ -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); } Loading @@ -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); } Loading
core/tests/coretests/src/android/window/BackTouchTrackerTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -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) } Loading
core/tests/coretests/src/android/window/WindowOnBackInvokedDispatcherTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -695,7 +695,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