Make BackEvent#getTouchX and BackEvent#getTouchY floats.
Bug: 228533817
Test: Try swipe back to home on Flag Flipper (with Predictive Back
Animation toggle enabled in Flipper) and make sure animation looks good.
Try in both landscape and portrait mode.
Change-Id: If2165827a0f66f8e0bd8f78483577c3ac4c9f213
diff --git a/core/java/android/window/BackEvent.java b/core/java/android/window/BackEvent.java
index 14985c9..1024e2e 100644
--- a/core/java/android/window/BackEvent.java
+++ b/core/java/android/window/BackEvent.java
@@ -46,8 +46,8 @@
@Retention(RetentionPolicy.SOURCE)
public @interface SwipeEdge{}
- private final int mTouchX;
- private final int mTouchY;
+ private final float mTouchX;
+ private final float mTouchY;
private final float mProgress;
@SwipeEdge
@@ -58,14 +58,14 @@
/**
* Creates a new {@link BackEvent} instance.
*
- * @param touchX Absolute X location of the touch point.
- * @param touchY Absolute Y location of the touch point.
+ * @param touchX Absolute X location of the touch point of this event.
+ * @param touchY Absolute Y location of the touch point of this event.
* @param progress Value between 0 and 1 on how far along the back gesture is.
* @param swipeEdge Indicates which edge the swipe starts from.
* @param departingAnimationTarget The remote animation target of the departing application
* window.
*/
- public BackEvent(int touchX, int touchY, float progress, @SwipeEdge int swipeEdge,
+ public BackEvent(float touchX, float touchY, float progress, @SwipeEdge int swipeEdge,
@Nullable RemoteAnimationTarget departingAnimationTarget) {
mTouchX = touchX;
mTouchY = touchY;
@@ -75,8 +75,8 @@
}
private BackEvent(@NonNull Parcel in) {
- mTouchX = in.readInt();
- mTouchY = in.readInt();
+ mTouchX = in.readFloat();
+ mTouchY = in.readFloat();
mProgress = in.readFloat();
mSwipeEdge = in.readInt();
mDepartingAnimationTarget = in.readTypedObject(RemoteAnimationTarget.CREATOR);
@@ -101,8 +101,8 @@
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
- dest.writeInt(mTouchX);
- dest.writeInt(mTouchY);
+ dest.writeFloat(mTouchX);
+ dest.writeFloat(mTouchY);
dest.writeFloat(mProgress);
dest.writeInt(mSwipeEdge);
dest.writeTypedObject(mDepartingAnimationTarget, flags);
@@ -118,14 +118,14 @@
/**
* Returns the absolute X location of the touch point.
*/
- public int getTouchX() {
+ public float getTouchX() {
return mTouchX;
}
/**
* Returns the absolute Y location of the touch point.
*/
- public int getTouchY() {
+ public float getTouchY() {
return mTouchY;
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java
index 42ac195..cfd0624 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java
@@ -301,7 +301,8 @@
int backType = mBackNavigationInfo.getType();
RemoteAnimationTarget animationTarget = mBackNavigationInfo.getDepartingAnimationTarget();
- BackEvent backEvent = new BackEvent(0, 0, progress, swipeEdge, animationTarget);
+ BackEvent backEvent = new BackEvent(
+ event.getX(), event.getY(), progress, swipeEdge, animationTarget);
IOnBackInvokedCallback targetCallback = null;
if (shouldDispatchToLauncher(backType)) {
targetCallback = mBackToLauncherCallback;