Fix issue with grouped task rects being calculated slightly off

- This was causing bleed through between split tasks and perhaps
  some rounded corners to be calculated incorrectly
- Also reset the translation after it is adjusted for dismissing
  in case the dismiss gesture is canceled.  This doesn't fix the
  issue with bleed through between the task views (to be fixed
  separately), but makes sure it isn't permanently set on the task

Bug: 206739664
Test: Split tasks, swipe up and check the bounds

Change-Id: I34430e958ca7a75f48621bc27a281e93fdf97179
This commit is contained in:
Winson Chung 2021-11-17 08:09:49 +00:00
parent b797ca77b2
commit 9304879387
3 changed files with 17 additions and 18 deletions

View File

@ -3014,6 +3014,10 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
@SuppressWarnings("WrongCall") @SuppressWarnings("WrongCall")
private void onEnd(boolean success) { private void onEnd(boolean success) {
// Reset task translations as they may have updated via animations in
// createTaskDismissAnimation
resetTaskVisuals();
if (success) { if (success) {
if (shouldRemoveTask) { if (shouldRemoveTask) {
if (dismissedTaskView.getTask() != null) { if (dismissedTaskView.getTask() != null) {
@ -3030,10 +3034,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
} }
} }
// Reset task translations as they may have updated via animations in
// createTaskDismissAnimation
resetTaskVisuals();
int pageToSnapTo = mCurrentPage; int pageToSnapTo = mCurrentPage;
mCurrentPageScrollDiff = 0; mCurrentPageScrollDiff = 0;
int taskViewIdToSnapTo = -1; int taskViewIdToSnapTo = -1;

View File

@ -451,24 +451,19 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect, public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect,
StagedSplitBounds splitInfo, int desiredStagePosition) { StagedSplitBounds splitInfo, int desiredStagePosition) {
boolean isLandscape = dp.isLandscape; boolean isLandscape = dp.isLandscape;
float verticalDividerDiff = splitInfo.visualDividerBounds.height() / 2f;
float horizontalDividerDiff = splitInfo.visualDividerBounds.width() / 2f;
float diff;
if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) { if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) {
if (isLandscape) { if (isLandscape) {
diff = outRect.width() * (1f - splitInfo.leftTaskPercent) + horizontalDividerDiff; outRect.right = outRect.left + (int) (outRect.width() * splitInfo.leftTaskPercent);
outRect.right -= diff;
} else { } else {
diff = outRect.height() * (1f - splitInfo.topTaskPercent) + verticalDividerDiff; outRect.bottom = outRect.top + (int) (outRect.height() * splitInfo.topTaskPercent);
outRect.bottom -= diff;
} }
} else { } else {
if (isLandscape) { if (isLandscape) {
diff = outRect.width() * splitInfo.leftTaskPercent + horizontalDividerDiff; outRect.left += (int) (outRect.width() *
outRect.left += diff; (splitInfo.leftTaskPercent + splitInfo.dividerWidthPercent));
} else { } else {
diff = outRect.height() * splitInfo.topTaskPercent + verticalDividerDiff; outRect.top += (int) (outRect.height() *
outRect.top += diff; (splitInfo.topTaskPercent + splitInfo.dividerHeightPercent));
} }
} }
} }
@ -479,9 +474,9 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
StagedSplitBounds splitBoundsConfig, DeviceProfile dp) { StagedSplitBounds splitBoundsConfig, DeviceProfile dp) {
int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx; int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
int totalThumbnailHeight = parentHeight - spaceAboveSnapshot; int totalThumbnailHeight = parentHeight - spaceAboveSnapshot;
int dividerBar = (splitBoundsConfig.appsStackedVertically ? int dividerBar = splitBoundsConfig.appsStackedVertically
splitBoundsConfig.visualDividerBounds.height() : ? (int) (splitBoundsConfig.dividerHeightPercent * parentHeight)
splitBoundsConfig.visualDividerBounds.width()); : (int) (splitBoundsConfig.dividerWidthPercent * parentWidth);
int primarySnapshotHeight; int primarySnapshotHeight;
int primarySnapshotWidth; int primarySnapshotWidth;
int secondarySnapshotHeight; int secondarySnapshotHeight;

View File

@ -99,6 +99,8 @@ public final class SplitConfigurationOptions {
// This class is orientation-agnostic, so we compute both for later use // This class is orientation-agnostic, so we compute both for later use
public final float topTaskPercent; public final float topTaskPercent;
public final float leftTaskPercent; public final float leftTaskPercent;
public final float dividerWidthPercent;
public final float dividerHeightPercent;
/** /**
* If {@code true}, that means at the time of creation of this object, the * If {@code true}, that means at the time of creation of this object, the
* split-screened apps were vertically stacked. This is useful in scenarios like * split-screened apps were vertically stacked. This is useful in scenarios like
@ -130,6 +132,8 @@ public final class SplitConfigurationOptions {
leftTaskPercent = this.leftTopBounds.width() / (float) rightBottomBounds.right; leftTaskPercent = this.leftTopBounds.width() / (float) rightBottomBounds.right;
topTaskPercent = this.leftTopBounds.height() / (float) rightBottomBounds.bottom; topTaskPercent = this.leftTopBounds.height() / (float) rightBottomBounds.bottom;
dividerWidthPercent = visualDividerBounds.width() / (float) rightBottomBounds.right;
dividerHeightPercent = visualDividerBounds.height() / (float) rightBottomBounds.bottom;
} }
} }