From d1a70eeb75721dddfd77172e702192303de6c0b4 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Tue, 7 Sep 2021 16:50:21 -0700 Subject: [PATCH] Slight polish for split screen gesture animation * Divider bar dimensions manually calculated since the leash that is provided has bounds larger than the space that is visually shown between the two split apps Bug: 181704764 Test: Swipe up on large and normal screen, w/ and w/o home rotation enabled Change-Id: I1fde053151d47c6ce3e11f16f8ae4a153d273871 --- .../android/quickstep/RemoteTargetGluer.java | 4 +-- .../touch/LandscapePagedViewHandler.java | 9 ++++--- .../touch/PortraitPagedViewHandler.java | 19 +++++++------- .../util/SplitConfigurationOptions.java | 26 +++++++++++-------- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java index 8a4a632f99..dc04016898 100644 --- a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java +++ b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java @@ -107,11 +107,9 @@ public class RemoteTargetGluer { primaryTaskTarget = targets.findTask(splitIds[0]); secondaryTaskTarget = targets.findTask(splitIds[1]); - RemoteAnimationTargetCompat dividerTarget = targets.getNonAppTargetOfType( - TYPE_DOCK_DIVIDER); mStagedSplitBounds = new SplitConfigurationOptions.StagedSplitBounds( primaryTaskTarget.screenSpaceBounds, - secondaryTaskTarget.screenSpaceBounds, dividerTarget.screenSpaceBounds); + secondaryTaskTarget.screenSpaceBounds); mRemoteTargetHandles[0].mTransformParams.setTargetSet( createRemoteAnimationTargetsForTarget(primaryTaskTarget, targets)); mRemoteTargetHandles[0].mTaskViewSimulator.setPreview(primaryTaskTarget, diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java index 8d330d4e1b..895ca08510 100644 --- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java @@ -388,11 +388,12 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler { public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect, SplitConfigurationOptions.StagedSplitBounds splitInfo, int desiredStagePosition) { float diff; + float horizontalDividerDiff = splitInfo.visualDividerBounds.width() / 2f; if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) { - diff = outRect.height() * (1f - splitInfo.leftTaskPercent); + diff = outRect.height() * (1f - splitInfo.leftTaskPercent) + horizontalDividerDiff; outRect.bottom -= diff; } else { - diff = outRect.height() * splitInfo.leftTaskPercent; + diff = outRect.height() * splitInfo.leftTaskPercent + horizontalDividerDiff; outRect.top += diff; } } @@ -402,7 +403,7 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler { SplitConfigurationOptions.StagedSplitBounds splitInfo, int desiredStagePosition) { if (desiredStagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) { // The preview set is for the bottom/right, inset by top/left task - splitOffset.x = splitInfo.leftTopBounds.width() + splitInfo.dividerBounds.width() / 2; + splitOffset.x = splitInfo.leftTopBounds.width() + splitInfo.visualDividerBounds.width(); } } @@ -413,7 +414,7 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler { int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx; int totalThumbnailHeight = taskParent.getHeight() - spaceAboveSnapshot; int totalThumbnailWidth = taskParent.getWidth(); - int dividerBar = splitBoundsConfig.dividerBounds.width() / 2; + int dividerBar = splitBoundsConfig.visualDividerBounds.width(); ViewGroup.LayoutParams primaryLp = mSnapshotView.getLayoutParams(); ViewGroup.LayoutParams secondaryLp = mSnapshotView2.getLayoutParams(); diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index 82846593dc..064d808756 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -474,21 +474,23 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect, SplitConfigurationOptions.StagedSplitBounds splitInfo, int desiredStagePosition) { 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 (isLandscape) { - diff = outRect.width() * (1f - splitInfo.leftTaskPercent); + diff = outRect.width() * (1f - splitInfo.leftTaskPercent) + horizontalDividerDiff; outRect.right -= diff; } else { - diff = outRect.height() * (1f - splitInfo.topTaskPercent); + diff = outRect.height() * (1f - splitInfo.topTaskPercent) + verticalDividerDiff; outRect.bottom -= diff; } } else { if (isLandscape) { - diff = outRect.width() * splitInfo.leftTaskPercent; + diff = outRect.width() * splitInfo.leftTaskPercent + horizontalDividerDiff; outRect.left += diff; } else { - diff = outRect.height() * splitInfo.topTaskPercent; + diff = outRect.height() * splitInfo.topTaskPercent + verticalDividerDiff; outRect.top += diff; } } @@ -500,10 +502,10 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { if (desiredStagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) { if (dp.isLandscape) { splitOffset.x = splitInfo.leftTopBounds.width() + - splitInfo.dividerBounds.width() / 2; + splitInfo.visualDividerBounds.width(); } else { splitOffset.y = splitInfo.leftTopBounds.height() + - splitInfo.dividerBounds.height() / 2; + splitInfo.visualDividerBounds.height(); } } } @@ -516,9 +518,8 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { int totalThumbnailHeight = taskParent.getHeight() - spaceAboveSnapshot; int totalThumbnailWidth = taskParent.getWidth(); int dividerBar = (dp.isLandscape ? - splitBoundsConfig.dividerBounds.width() : - splitBoundsConfig.dividerBounds.height()) - / 2; + splitBoundsConfig.visualDividerBounds.width() : + splitBoundsConfig.visualDividerBounds.height()); ViewGroup.LayoutParams primaryLp = mSnapshotView.getLayoutParams(); ViewGroup.LayoutParams secondaryLp = mSnapshotView2.getLayoutParams(); diff --git a/src/com/android/launcher3/util/SplitConfigurationOptions.java b/src/com/android/launcher3/util/SplitConfigurationOptions.java index 41693def5f..5093d85535 100644 --- a/src/com/android/launcher3/util/SplitConfigurationOptions.java +++ b/src/com/android/launcher3/util/SplitConfigurationOptions.java @@ -88,25 +88,29 @@ public final class SplitConfigurationOptions { public static class StagedSplitBounds { public final Rect leftTopBounds; public final Rect rightBottomBounds; - public final Rect dividerBounds; + /** This rect represents the actual gap between the two apps */ + public final Rect visualDividerBounds; // This class is orientation-agnostic, so we compute both for later use public final float topTaskPercent; public final float leftTaskPercent; - public StagedSplitBounds(Rect leftTopBounds, Rect rightBottomBounds, Rect dividerBounds) { + public StagedSplitBounds(Rect leftTopBounds, Rect rightBottomBounds) { this.leftTopBounds = leftTopBounds; this.rightBottomBounds = rightBottomBounds; - this.dividerBounds = dividerBounds; - float totalHeight = this.leftTopBounds.height() - + this.rightBottomBounds.height() - + this.dividerBounds.height(); - float totalWidth = this.leftTopBounds.width() - + this.rightBottomBounds.width() - + this.dividerBounds.width(); - leftTaskPercent = this.leftTopBounds.width() / totalWidth; - topTaskPercent = this.leftTopBounds.height() / totalHeight; + if (rightBottomBounds.top > leftTopBounds.top) { + // vertical apps, horizontal divider + this.visualDividerBounds = new Rect(leftTopBounds.left, leftTopBounds.bottom, + leftTopBounds.right, rightBottomBounds.top); + } else { + // horizontal apps, vertical divider + this.visualDividerBounds = new Rect(leftTopBounds.right, leftTopBounds.top, + rightBottomBounds.left, leftTopBounds.bottom); + } + + leftTaskPercent = this.leftTopBounds.width() / (float) rightBottomBounds.right; + topTaskPercent = this.leftTopBounds.height() / (float) rightBottomBounds.bottom; } }