Take margin insets into account when setting position
Previously we computed insets for task menu position
whenever a Task was told that orientation had changed.
This missed a path for the TaskMenuView's onScrollChanged()
listener, which also calls set position and wasn't taking
the insets into account.
Moved the inset into setPosition() directly so it's caught
on all code paths.
Also noticed 2 bugs where
* We were calling updateChildTaskOrientation() twice, it
already happens in the call to updateOrientationHandler()
* We were directly modifying insets from the activity's
drag layer instead of copying those insets to another rect
and then modifying (this is no longer an issue since we
are not touching those insets at all anymore)
Bug: 192400086
Test: Rotated w/ task menu open for fake and real
landscape. Nothing seems broken.
Note real landscape hides the menu whereas fake one
shows it (which was behavior before this change)
Change-Id: I613dac9519220f49285655ef11a1f72e4a6d31bd
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 710a9ab..1b1066a 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1665,7 +1665,6 @@
pa.addListener(AnimatorListeners.forSuccessCallback(() -> {
setLayoutRotation(newRotation, mOrientationState.getDisplayRotation());
mActivity.getDragLayer().recreateControllers();
- updateChildTaskOrientations();
setRecentsChangedOrientation(false).start();
}));
pa.start();
diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
index c97225e..d663635 100644
--- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
@@ -59,6 +59,7 @@
private static final int REVEAL_OPEN_DURATION = 150;
private static final int REVEAL_CLOSE_DURATION = 100;
+ private final float mTaskInsetMargin;
private BaseDraggingActivity mActivity;
private TextView mTaskName;
@@ -75,6 +76,7 @@
mActivity = BaseDraggingActivity.fromContext(context);
setClipToOutline(true);
+ mTaskInsetMargin = getResources().getDimension(R.dimen.task_card_margin);
}
@Override
@@ -124,8 +126,13 @@
private void setPosition(float x, float y, int overscrollShift) {
PagedOrientationHandler pagedOrientationHandler = mTaskView.getPagedOrientationHandler();
+ // Inset due to margin
+ PointF additionalInset = pagedOrientationHandler
+ .getAdditionalInsetForTaskMenu(mTaskInsetMargin);
int taskTopMargin = mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
- float adjustedY = y + taskTopMargin;
+
+ float adjustedY = y + taskTopMargin - additionalInset.y;
+ float adjustedX = x - additionalInset.x;
// Changing pivot to make computations easier
// NOTE: Changing the pivots means the rotated view gets rotated about the new pivots set,
// which would render the X and Y position set here incorrect
@@ -137,7 +144,8 @@
setPivotY(0);
}
setRotation(pagedOrientationHandler.getDegreesRotated());
- setX(pagedOrientationHandler.getTaskMenuX(x, mTaskView.getThumbnail(), overscrollShift));
+ setX(pagedOrientationHandler.getTaskMenuX(adjustedX,
+ mTaskView.getThumbnail(), overscrollShift));
setY(pagedOrientationHandler.getTaskMenuY(
adjustedY, mTaskView.getThumbnail(), overscrollShift));
}
@@ -228,8 +236,7 @@
private void orientAroundTaskView(TaskView taskView) {
PagedOrientationHandler orientationHandler = taskView.getPagedOrientationHandler();
measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
- float taskInsetMargin = getResources().getDimension(R.dimen.task_card_margin);
- orientationHandler.setTaskMenuAroundTaskView(this, taskInsetMargin);
+ orientationHandler.setTaskMenuAroundTaskView(this, mTaskInsetMargin);
mActivity.getDragLayer().getDescendantRectRelativeToSelf(taskView, sTempRect);
Rect insets = mActivity.getDragLayer().getInsets();
BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams();
@@ -243,9 +250,6 @@
setScaleY(taskView.getScaleY());
orientationHandler.setTaskOptionsMenuLayoutOrientation(
mActivity.getDeviceProfile(), mOptionLayout);
- PointF additionalInset = orientationHandler.getAdditionalInsetForTaskMenu(taskInsetMargin);
- insets.left += additionalInset.x;
- insets.top += additionalInset.y;
setPosition(sTempRect.left - insets.left, sTempRect.top - insets.top, 0);
}