From be55f82fab324c08d5a80958cae27f2b5f079d2e Mon Sep 17 00:00:00 2001 From: Shamali P Date: Tue, 16 Jan 2024 15:07:19 +0000 Subject: [PATCH] Fix issue that widget picker is only half of screen in foldable. Apply the extra top padding only if device is in portrait and aspect ratio is beyond 1.5 to keep the original intent of avoiding showing a single pane widget picker in super elongated form. In b/214215594, a top padding was applied for w720, but in fold, it ended up showing the picker only half way up. So, changed it to consider aspect ratio. In b/315055849 the tablet portrait will use full width two pane picker, and then, it will also not need this extra top padding. In that change, we will use the flag to guard applying this extra padding. See screen/cast/NTYwMjU1MzY4NDI5NTY4MHw3NDIxYzU0Mi1lNg Test: WidgetPickerImageTest and Manual (screencast above) Bug: 317013493 Flag: N/A Change-Id: I90e0c416f0f05460960983588edf0068d99cd1a6 --- src/com/android/launcher3/DeviceProfile.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 834ba043c5..e9545c859b 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -81,6 +81,9 @@ public class DeviceProfile { private static final float MIN_FOLDER_TEXT_SIZE_SP = 16f; private static final float MIN_WIDGET_PADDING_DP = 6f; + // 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; + public static final PointF DEFAULT_SCALE = new PointF(1.0f, 1.0f); public static final ViewScaleProvider DEFAULT_PROVIDER = itemInfo -> DEFAULT_SCALE; public static final Consumer DEFAULT_DIMENSION_PROVIDER = dp -> { @@ -414,8 +417,14 @@ 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 - + res.getDimensionPixelSize(R.dimen.bottom_sheet_extra_top_padding) + + (applyExtraTopPadding ? res.getDimensionPixelSize( + R.dimen.bottom_sheet_extra_top_padding) : 0) + (isTablet ? 0 : edgeMarginPx); // phones need edgeMarginPx additional padding bottomSheetOpenDuration = res.getInteger(R.integer.config_bottomSheetOpenDuration); bottomSheetCloseDuration = res.getInteger(R.integer.config_bottomSheetCloseDuration);