From 5fbb0cccad866fe73e9deb51204293c48e7f8edb Mon Sep 17 00:00:00 2001 From: Shamali P Date: Tue, 6 Feb 2024 23:05:35 +0000 Subject: [PATCH] Use derived padding instead of static 300dp for large portrait displays In tablet, portrait mode, a padding of 300dp was applied to make it less elongated, but that doesn't scale well across different devices. So, we use 1/6th of height as the additional padding. This fixes the existing logic. Bug: 318410881 Bug: 315055849 Flag: N/A Test: Screenshot update in cl chain. Change-Id: Ia9cfe481131f086b66f625069cbf9a7c0343c2c9 --- res/values-sw720dp-land/dimens.xml | 3 --- res/values-sw720dp/dimens.xml | 3 --- res/values/dimens.xml | 1 - src/com/android/launcher3/DeviceProfile.java | 21 +++++++++++--------- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml index 4d0ac383d3..dd58ceeafb 100644 --- a/res/values-sw720dp-land/dimens.xml +++ b/res/values-sw720dp-land/dimens.xml @@ -32,7 +32,4 @@ 49dp 24dp - - - 0dp diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml index 2b0382d2c4..3c79588258 100644 --- a/res/values-sw720dp/dimens.xml +++ b/res/values-sw720dp/dimens.xml @@ -38,9 +38,6 @@ 30dp - - 300dp - 24dp diff --git a/res/values/dimens.xml b/res/values/dimens.xml index c18700028f..618996140c 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -454,7 +454,6 @@ 8dp - 0dp 36dp 32dp 4dp diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 563dfe2f20..4afa8e0623 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -416,15 +416,18 @@ public class DeviceProfile { gridVisualizationPaddingY = res.getDimensionPixelSize( R.dimen.grid_visualization_vertical_cell_spacing); - // Tablet portrait mode uses a single pane widget picker and extra padding may be applied on - // top to avoid making it look too elongated. - final boolean applyExtraTopPadding = isTablet - && !isLandscape - && (aspectRatio > MIN_ASPECT_RATIO_FOR_EXTRA_TOP_PADDING); - bottomSheetTopPadding = mInsets.top // statusbar height - + (applyExtraTopPadding ? res.getDimensionPixelSize( - R.dimen.bottom_sheet_extra_top_padding) : 0) - + (isTablet ? 0 : edgeMarginPx); // phones need edgeMarginPx additional padding + { + // In large screens, in portrait mode, a bottom sheet can appear too elongated, so, we + // apply additional padding. + final boolean applyExtraTopPadding = isTablet + && !isLandscape + && (aspectRatio > MIN_ASPECT_RATIO_FOR_EXTRA_TOP_PADDING); + final int derivedTopPadding = heightPx / 6; + bottomSheetTopPadding = mInsets.top // statusbar height + + (applyExtraTopPadding ? derivedTopPadding : 0) + + (isTablet ? 0 : edgeMarginPx); // phones need edgeMarginPx additional padding + } + bottomSheetOpenDuration = res.getInteger(R.integer.config_bottomSheetOpenDuration); bottomSheetCloseDuration = res.getInteger(R.integer.config_bottomSheetCloseDuration); if (isTablet) {