Merge "Make BackEvent#getTouchX and BackEvent#getTouchY floats." into tm-dev

This commit is contained in:
TreeHugger Robot
2022-04-16 01:51:10 +00:00
committed by Android (Google) Code Review
2 changed files with 13 additions and 12 deletions

View File

@@ -46,8 +46,8 @@ public class BackEvent implements Parcelable {
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface SwipeEdge{} public @interface SwipeEdge{}
private final int mTouchX; private final float mTouchX;
private final int mTouchY; private final float mTouchY;
private final float mProgress; private final float mProgress;
@SwipeEdge @SwipeEdge
@@ -58,14 +58,14 @@ public class BackEvent implements Parcelable {
/** /**
* Creates a new {@link BackEvent} instance. * Creates a new {@link BackEvent} instance.
* *
* @param touchX Absolute X 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. * @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 progress Value between 0 and 1 on how far along the back gesture is.
* @param swipeEdge Indicates which edge the swipe starts from. * @param swipeEdge Indicates which edge the swipe starts from.
* @param departingAnimationTarget The remote animation target of the departing application * @param departingAnimationTarget The remote animation target of the departing application
* window. * 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) { @Nullable RemoteAnimationTarget departingAnimationTarget) {
mTouchX = touchX; mTouchX = touchX;
mTouchY = touchY; mTouchY = touchY;
@@ -75,8 +75,8 @@ public class BackEvent implements Parcelable {
} }
private BackEvent(@NonNull Parcel in) { private BackEvent(@NonNull Parcel in) {
mTouchX = in.readInt(); mTouchX = in.readFloat();
mTouchY = in.readInt(); mTouchY = in.readFloat();
mProgress = in.readFloat(); mProgress = in.readFloat();
mSwipeEdge = in.readInt(); mSwipeEdge = in.readInt();
mDepartingAnimationTarget = in.readTypedObject(RemoteAnimationTarget.CREATOR); mDepartingAnimationTarget = in.readTypedObject(RemoteAnimationTarget.CREATOR);
@@ -101,8 +101,8 @@ public class BackEvent implements Parcelable {
@Override @Override
public void writeToParcel(@NonNull Parcel dest, int flags) { public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeInt(mTouchX); dest.writeFloat(mTouchX);
dest.writeInt(mTouchY); dest.writeFloat(mTouchY);
dest.writeFloat(mProgress); dest.writeFloat(mProgress);
dest.writeInt(mSwipeEdge); dest.writeInt(mSwipeEdge);
dest.writeTypedObject(mDepartingAnimationTarget, flags); dest.writeTypedObject(mDepartingAnimationTarget, flags);
@@ -118,14 +118,14 @@ public class BackEvent implements Parcelable {
/** /**
* Returns the absolute X location of the touch point. * Returns the absolute X location of the touch point.
*/ */
public int getTouchX() { public float getTouchX() {
return mTouchX; return mTouchX;
} }
/** /**
* Returns the absolute Y location of the touch point. * Returns the absolute Y location of the touch point.
*/ */
public int getTouchY() { public float getTouchY() {
return mTouchY; return mTouchY;
} }

View File

@@ -301,7 +301,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
int backType = mBackNavigationInfo.getType(); int backType = mBackNavigationInfo.getType();
RemoteAnimationTarget animationTarget = mBackNavigationInfo.getDepartingAnimationTarget(); 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; IOnBackInvokedCallback targetCallback = null;
if (shouldDispatchToLauncher(backType)) { if (shouldDispatchToLauncher(backType)) {
targetCallback = mBackToLauncherCallback; targetCallback = mBackToLauncherCallback;