diff --git a/quickstep/src/com/android/quickstep/OrientationRectF.java b/quickstep/src/com/android/quickstep/OrientationRectF.java index 59a202cf76..aa01b05b47 100644 --- a/quickstep/src/com/android/quickstep/OrientationRectF.java +++ b/quickstep/src/com/android/quickstep/OrientationRectF.java @@ -66,7 +66,7 @@ public class OrientationRectF extends RectF { return applyTransform(event, deltaRotation(mRotation, currentRotation), forceTransform); } - private boolean applyTransform(MotionEvent event, int deltaRotation, boolean forceTransform) { + public boolean applyTransform(MotionEvent event, int deltaRotation, boolean forceTransform) { mTmpMatrix.reset(); postDisplayRotation(deltaRotation, mHeight, mWidth, mTmpMatrix); if (forceTransform) { diff --git a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java index ecff4f1a45..d2d3ba3ef4 100644 --- a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java +++ b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java @@ -22,6 +22,7 @@ import static android.view.MotionEvent.ACTION_MOVE; import static android.view.MotionEvent.ACTION_POINTER_DOWN; import static android.view.MotionEvent.ACTION_UP; +import static com.android.launcher3.states.RotationHelper.deltaRotation; import android.content.res.Resources; import android.graphics.Point; import android.graphics.RectF; @@ -358,7 +359,18 @@ class OrientationTouchTransformer { if (mLastRectTouched == null) { return; } - mLastRectTouched.applyTransformFromRotation(event, mCurrentDisplay.rotation, true); + if (TaskAnimationManager.ENABLE_SHELL_TRANSITIONS) { + if (event.getSurfaceRotation() != mActiveTouchRotation) { + // With Shell transitions, we should rotated to the orientation at the start + // of the gesture not the current display rotation which will happen early + mLastRectTouched.applyTransform(event, + deltaRotation(event.getSurfaceRotation(), mActiveTouchRotation), + true); + } + } else { + mLastRectTouched.applyTransformFromRotation(event, mCurrentDisplay.rotation, + true); + } break; } case ACTION_CANCEL: @@ -366,7 +378,18 @@ class OrientationTouchTransformer { if (mLastRectTouched == null) { return; } - mLastRectTouched.applyTransformFromRotation(event, mCurrentDisplay.rotation, true); + if (TaskAnimationManager.ENABLE_SHELL_TRANSITIONS) { + if (event.getSurfaceRotation() != mActiveTouchRotation) { + // With Shell transitions, we should rotated to the orientation at the start + // of the gesture not the current display rotation which will happen early + mLastRectTouched.applyTransform(event, + deltaRotation(event.getSurfaceRotation(), mActiveTouchRotation), + true); + } + } else { + mLastRectTouched.applyTransformFromRotation(event, mCurrentDisplay.rotation, + true); + } mLastRectTouched = null; break; } diff --git a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java index b031c4744b..a12a670d86 100644 --- a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java +++ b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java @@ -117,8 +117,8 @@ public class RemoteTargetGluer { secondaryTaskTarget = targets.findTask(splitIds[1]); mStagedSplitBounds = new StagedSplitBounds( - primaryTaskTarget.screenSpaceBounds, - secondaryTaskTarget.screenSpaceBounds, splitIds[0], splitIds[1]); + primaryTaskTarget.startScreenSpaceBounds, + secondaryTaskTarget.startScreenSpaceBounds, splitIds[0], splitIds[1]); mRemoteTargetHandles[0].mTransformParams.setTargetSet( createRemoteAnimationTargetsForTarget(primaryTaskTarget, targets)); mRemoteTargetHandles[0].mTaskViewSimulator.setPreview(primaryTaskTarget, diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java index 8ccab71f63..ae8e45ae32 100644 --- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java +++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java @@ -52,6 +52,7 @@ import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.SettingsCache; import com.android.quickstep.BaseActivityInterface; import com.android.quickstep.SystemUiProxy; +import com.android.quickstep.TaskAnimationManager; import com.android.quickstep.views.TaskView; import java.lang.annotation.Retention; @@ -340,6 +341,11 @@ public class RecentsOrientedState implements @SurfaceRotation public int getDisplayRotation() { + if (TaskAnimationManager.ENABLE_SHELL_TRANSITIONS) { + // When shell transitions are enabled, both the display and activity rotations should + // be the same once the gesture starts + return mRecentsActivityRotation; + } return mDisplayRotation; } diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index f676091607..f66a6dee04 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -44,6 +44,7 @@ import com.android.launcher3.util.SplitConfigurationOptions.StagedSplitBounds; import com.android.launcher3.util.TraceHelper; import com.android.quickstep.AnimatedFloat; import com.android.quickstep.BaseActivityInterface; +import com.android.quickstep.TaskAnimationManager; import com.android.quickstep.views.TaskThumbnailView.PreviewPositionHelper; import com.android.quickstep.views.TaskView.FullscreenDrawParams; import com.android.systemui.shared.recents.model.ThumbnailData; @@ -170,7 +171,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { * Sets the targets which the simulator will control */ public void setPreview(RemoteAnimationTargetCompat runningTarget) { - setPreviewBounds(runningTarget.screenSpaceBounds, runningTarget.contentInsets); + setPreviewBounds(runningTarget.startScreenSpaceBounds, runningTarget.contentInsets); } /** @@ -304,7 +305,13 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { mOrientationStateId = mOrientationState.getStateId(); getFullScreenScale(); - mThumbnailData.rotation = mOrientationState.getDisplayRotation(); + if (TaskAnimationManager.ENABLE_SHELL_TRANSITIONS) { + // With shell transitions, the display is rotated early so we need to actually use + // the rotation when the gesture starts + mThumbnailData.rotation = mOrientationState.getTouchRotation(); + } else { + mThumbnailData.rotation = mOrientationState.getDisplayRotation(); + } // mIsRecentsRtl is the inverse of TaskView RTL. boolean isRtlEnabled = !mIsRecentsRtl;