From bf6f171f8495f83543455acbf2d139329e2ead09 Mon Sep 17 00:00:00 2001 From: Jeremy Sim Date: Mon, 14 Mar 2022 18:25:47 -0700 Subject: [PATCH] Fix issue with split thumbnails overflowing during rotation Fixes a set of issues in Overview where you could cause split thumbnails to overflow their contents into each other by rotating the phone in certain ways. The issue occurred because StagedSplitBounds objects have their height and width assigned differently depending on if they were created while the phone was in portrait or landscape. Fixed by adding a conditional check in PortraitPagedViewHandler#setSplitTaskSwipeRect and LandscapePagedViewHandler#setSplitTaskSwipeRect. Fixes: 218784856 Fixes: 218779313 Test: Manual on local devices Change-Id: I04b4f4344250da34616ab1744af22fa41b9aba9b (cherry picked from commit 1d6b7f2abf9b7af77b75d5e47e46233bdc106507) --- .../touch/LandscapePagedViewHandler.java | 15 +++++++++------ .../touch/PortraitPagedViewHandler.java | 17 +++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java index 2609e549a5..d0ac3c8017 100644 --- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java @@ -414,14 +414,17 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler { @Override public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect, StagedSplitBounds splitInfo, int desiredStagePosition) { - float diff; - float horizontalDividerDiff = splitInfo.visualDividerBounds.width() / 2f; + float topLeftTaskPercent = splitInfo.appsStackedVertically + ? splitInfo.topTaskPercent + : splitInfo.leftTaskPercent; + float dividerBarPercent = splitInfo.appsStackedVertically + ? splitInfo.dividerHeightPercent + : splitInfo.dividerWidthPercent; + if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) { - diff = outRect.height() * (1f - splitInfo.leftTaskPercent) + horizontalDividerDiff; - outRect.bottom -= diff; + outRect.bottom = outRect.top + (int) (outRect.height() * topLeftTaskPercent); } else { - diff = outRect.height() * splitInfo.leftTaskPercent + horizontalDividerDiff; - outRect.top += diff; + outRect.top += (int) (outRect.height() * (topLeftTaskPercent + dividerBarPercent)); } } diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index 2c9afd6506..0909e8e753 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -488,19 +488,24 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect, StagedSplitBounds splitInfo, int desiredStagePosition) { boolean isLandscape = dp.isLandscape; + float topLeftTaskPercent = splitInfo.appsStackedVertically + ? splitInfo.topTaskPercent + : splitInfo.leftTaskPercent; + float dividerBarPercent = splitInfo.appsStackedVertically + ? splitInfo.dividerHeightPercent + : splitInfo.dividerWidthPercent; + if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) { if (isLandscape) { - outRect.right = outRect.left + (int) (outRect.width() * splitInfo.leftTaskPercent); + outRect.right = outRect.left + (int) (outRect.width() * topLeftTaskPercent); } else { - outRect.bottom = outRect.top + (int) (outRect.height() * splitInfo.topTaskPercent); + outRect.bottom = outRect.top + (int) (outRect.height() * topLeftTaskPercent); } } else { if (isLandscape) { - outRect.left += (int) (outRect.width() * - (splitInfo.leftTaskPercent + splitInfo.dividerWidthPercent)); + outRect.left += (int) (outRect.width() * (topLeftTaskPercent + dividerBarPercent)); } else { - outRect.top += (int) (outRect.height() * - (splitInfo.topTaskPercent + splitInfo.dividerHeightPercent)); + outRect.top += (int) (outRect.height() * (topLeftTaskPercent + dividerBarPercent)); } } }