diff --git a/res/values/dimens.xml b/res/values/dimens.xml index c18700028f..43970d3e5a 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -31,6 +31,7 @@ 0dp 76dp + 64dp 0dp @@ -47,6 +48,7 @@ 20dp 32dp 16dp + 32dp diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 563dfe2f20..a6ff6c1a89 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -83,6 +83,7 @@ public class DeviceProfile { // Minimum aspect ratio beyond which an extra top padding may be applied to a bottom sheet. private static final float MIN_ASPECT_RATIO_FOR_EXTRA_TOP_PADDING = 1.5f; + private static final float MAX_ASPECT_RATIO_FOR_ALTERNATE_EDIT_STATE = 1.5f; public static final PointF DEFAULT_SCALE = new PointF(1.0f, 1.0f); public static final ViewScaleProvider DEFAULT_PROVIDER = itemInfo -> DEFAULT_SCALE; @@ -500,8 +501,17 @@ public class DeviceProfile { } dropTargetBarSizePx = res.getDimensionPixelSize(R.dimen.dynamic_grid_drop_target_size); - dropTargetBarTopMarginPx = res.getDimensionPixelSize(R.dimen.drop_target_top_margin); - dropTargetBarBottomMarginPx = res.getDimensionPixelSize(R.dimen.drop_target_bottom_margin); + // Some foldable portrait modes are too wide in terms of aspect ratio so we need to tweak + // the dimensions for edit state. + final boolean shouldApplyWidePortraitDimens = isTablet + && !isLandscape + && aspectRatio < MAX_ASPECT_RATIO_FOR_ALTERNATE_EDIT_STATE; + dropTargetBarTopMarginPx = shouldApplyWidePortraitDimens + ? 0 + : res.getDimensionPixelSize(R.dimen.drop_target_top_margin); + dropTargetBarBottomMarginPx = shouldApplyWidePortraitDimens + ? res.getDimensionPixelSize(R.dimen.drop_target_bottom_margin_wide_portrait) + : res.getDimensionPixelSize(R.dimen.drop_target_bottom_margin); dropTargetDragPaddingPx = res.getDimensionPixelSize(R.dimen.drop_target_drag_padding); dropTargetTextSizePx = res.getDimensionPixelSize(R.dimen.drop_target_text_size); dropTargetHorizontalPaddingPx = res.getDimensionPixelSize( @@ -592,8 +602,9 @@ public class DeviceProfile { } } - springLoadedHotseatBarTopMarginPx = res.getDimensionPixelSize( - R.dimen.spring_loaded_hotseat_top_margin); + springLoadedHotseatBarTopMarginPx = shouldApplyWidePortraitDimens + ? res.getDimensionPixelSize(R.dimen.spring_loaded_hotseat_top_margin_wide_portrait) + : res.getDimensionPixelSize(R.dimen.spring_loaded_hotseat_top_margin); if (mIsResponsiveGrid) { updateHotseatSizes(mResponsiveWorkspaceCellSpec.getIconSize()); diff --git a/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait.txt b/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait.txt index 93ab6f29b4..3169f41b22 100644 --- a/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait.txt +++ b/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait.txt @@ -79,7 +79,7 @@ DeviceProfile: hotseatBarEndOffset: 0.0px (0.0dp) hotseatQsbSpace: 0.0px (0.0dp) hotseatQsbHeight: 0.0px (0.0dp) - springLoadedHotseatBarTopMarginPx: 171.0px (65.14286dp) + springLoadedHotseatBarTopMarginPx: 168.0px (64.0dp) getHotseatLayoutPadding(context).top: 0.0px (0.0dp) getHotseatLayoutPadding(context).bottom: 108.0px (41.142857dp) getHotseatLayoutPadding(context).left: 98.0px (37.333332dp) @@ -118,12 +118,12 @@ DeviceProfile: overviewPageSpacing: 0.0px (0.0dp) overviewRowSpacing: 0.0px (0.0dp) overviewGridSideMargin: 0.0px (0.0dp) - dropTargetBarTopMarginPx: 168.0px (64.0dp) + dropTargetBarTopMarginPx: 0.0px (0.0dp) dropTargetBarSizePx: 147.0px (56.0dp) - dropTargetBarBottomMarginPx: 42.0px (16.0dp) - getCellLayoutSpringLoadShrunkTop(): 490.0px (186.66667dp) - getCellLayoutSpringLoadShrunkBottom(): 1770.0px (674.2857dp) + dropTargetBarBottomMarginPx: 84.0px (32.0dp) + getCellLayoutSpringLoadShrunkTop(): 364.0px (138.66667dp) + getCellLayoutSpringLoadShrunkBottom(): 1773.0px (675.4286dp) workspaceSpringLoadedMinNextPageVisiblePx: 63.0px (24.0dp) - getWorkspaceSpringLoadScale(): 0.7437536px (0.2833347dp) + getWorkspaceSpringLoadScale(): 0.81871px (0.31188953dp) getCellLayoutHeight(): 1721.0px (655.619dp) getCellLayoutWidth(): 899.0px (342.4762dp) diff --git a/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait3Button.txt b/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait3Button.txt index ec9a10e6cc..9d3d7bc0d6 100644 --- a/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait3Button.txt +++ b/tests/assets/dumpTests/DeviceProfileDumpTest/twoPanelPortrait3Button.txt @@ -79,7 +79,7 @@ DeviceProfile: hotseatBarEndOffset: 0.0px (0.0dp) hotseatQsbSpace: 0.0px (0.0dp) hotseatQsbHeight: 0.0px (0.0dp) - springLoadedHotseatBarTopMarginPx: 171.0px (65.14286dp) + springLoadedHotseatBarTopMarginPx: 168.0px (64.0dp) getHotseatLayoutPadding(context).top: 0.0px (0.0dp) getHotseatLayoutPadding(context).bottom: 108.0px (41.142857dp) getHotseatLayoutPadding(context).left: 98.0px (37.333332dp) @@ -118,12 +118,12 @@ DeviceProfile: overviewPageSpacing: 0.0px (0.0dp) overviewRowSpacing: 0.0px (0.0dp) overviewGridSideMargin: 0.0px (0.0dp) - dropTargetBarTopMarginPx: 168.0px (64.0dp) + dropTargetBarTopMarginPx: 0.0px (0.0dp) dropTargetBarSizePx: 147.0px (56.0dp) - dropTargetBarBottomMarginPx: 42.0px (16.0dp) - getCellLayoutSpringLoadShrunkTop(): 490.0px (186.66667dp) - getCellLayoutSpringLoadShrunkBottom(): 1770.0px (674.2857dp) + dropTargetBarBottomMarginPx: 84.0px (32.0dp) + getCellLayoutSpringLoadShrunkTop(): 364.0px (138.66667dp) + getCellLayoutSpringLoadShrunkBottom(): 1773.0px (675.4286dp) workspaceSpringLoadedMinNextPageVisiblePx: 63.0px (24.0dp) - getWorkspaceSpringLoadScale(): 0.7437536px (0.2833347dp) + getWorkspaceSpringLoadScale(): 0.81871px (0.31188953dp) getCellLayoutHeight(): 1721.0px (655.619dp) getCellLayoutWidth(): 899.0px (342.4762dp)