From d5a4e2e4e243f2228a0f4cc07e2daf2af9c002b5 Mon Sep 17 00:00:00 2001 From: Ahmed Fakhry Date: Fri, 6 Sep 2024 03:17:05 +0000 Subject: [PATCH] Fix broken Splitscreen in Overview on orientation change in foldables We should make sure that only either `topMargin` or a Y translation is used at a time on an Overview snapshot view to avoid seeing the snapshot shifted down by an unexpected amount. Detailed explanation can be found here: https://b.corp.google.com/issues/347143158#comment16 Fixes: 347143158 Test: Manually by following the steps described in the above comment and verifying the bug no longer repros. Flag: EXEMPT bugfix Change-Id: I699b0ccd9630c10d973fc28abb1228359184929b --- .../orientation/PortraitPagedViewHandler.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java index eeacee1cf6..96b686c708 100644 --- a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java +++ b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java @@ -535,6 +535,18 @@ public class PortraitPagedViewHandler extends DefaultPagedViewHandler implements int parentWidth, int parentHeight, SplitBounds splitBoundsConfig, DeviceProfile dp, boolean isRtl) { int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx; + + FrameLayout.LayoutParams primaryParams = + (FrameLayout.LayoutParams) primarySnapshot.getLayoutParams(); + FrameLayout.LayoutParams secondaryParams = + (FrameLayout.LayoutParams) secondarySnapshot.getLayoutParams(); + + // Reset margin and translations that aren't used in this method, but are used in other + // `RecentsPagedOrientationHandler` variants. + secondaryParams.topMargin = 0; + primaryParams.topMargin = spaceAboveSnapshot; + primarySnapshot.setTranslationY(0); + int totalThumbnailHeight = parentHeight - spaceAboveSnapshot; float dividerScale = splitBoundsConfig.appsStackedVertically ? splitBoundsConfig.dividerHeightPercent @@ -552,24 +564,14 @@ public class PortraitPagedViewHandler extends DefaultPagedViewHandler implements secondarySnapshot.setTranslationX(translationX); primarySnapshot.setTranslationX(0); } - secondarySnapshot.setTranslationY(spaceAboveSnapshot); - // Reset unused translations - primarySnapshot.setTranslationY(0); + secondarySnapshot.setTranslationY(spaceAboveSnapshot); } else { float finalDividerHeight = Math.round(totalThumbnailHeight * dividerScale); float translationY = taskViewSizes.first.y + spaceAboveSnapshot + finalDividerHeight; secondarySnapshot.setTranslationY(translationY); - FrameLayout.LayoutParams primaryParams = - (FrameLayout.LayoutParams) primarySnapshot.getLayoutParams(); - FrameLayout.LayoutParams secondaryParams = - (FrameLayout.LayoutParams) secondarySnapshot.getLayoutParams(); - secondaryParams.topMargin = 0; - primaryParams.topMargin = spaceAboveSnapshot; - - // Reset unused translations - primarySnapshot.setTranslationY(0); + // Reset unused translations. secondarySnapshot.setTranslationX(0); primarySnapshot.setTranslationX(0); }