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
This commit is contained in:
Shamali P
2024-02-06 23:05:35 +00:00
parent 933a05a2be
commit 5fbb0cccad
4 changed files with 12 additions and 16 deletions

View File

@@ -32,7 +32,4 @@
<!-- Widget picker--> <!-- Widget picker-->
<dimen name="widget_list_horizontal_margin">49dp</dimen> <dimen name="widget_list_horizontal_margin">49dp</dimen>
<dimen name="widget_list_horizontal_margin_two_pane">24dp</dimen> <dimen name="widget_list_horizontal_margin_two_pane">24dp</dimen>
<!-- Bottom sheet-->
<dimen name="bottom_sheet_extra_top_padding">0dp</dimen>
</resources> </resources>

View File

@@ -38,9 +38,6 @@
<!-- Widget picker--> <!-- Widget picker-->
<dimen name="widget_list_horizontal_margin">30dp</dimen> <dimen name="widget_list_horizontal_margin">30dp</dimen>
<!-- Bottom sheet-->
<dimen name="bottom_sheet_extra_top_padding">300dp</dimen>
<!-- Folder spaces --> <!-- Folder spaces -->
<dimen name="folder_footer_horiz_padding">24dp</dimen> <dimen name="folder_footer_horiz_padding">24dp</dimen>
</resources> </resources>

View File

@@ -454,7 +454,6 @@
<dimen name="padded_rounded_button_padding">8dp</dimen> <dimen name="padded_rounded_button_padding">8dp</dimen>
<!-- Bottom sheet related parameters --> <!-- Bottom sheet related parameters -->
<dimen name="bottom_sheet_extra_top_padding">0dp</dimen>
<dimen name="bottom_sheet_handle_area_height">36dp</dimen> <dimen name="bottom_sheet_handle_area_height">36dp</dimen>
<dimen name="bottom_sheet_handle_width">32dp</dimen> <dimen name="bottom_sheet_handle_width">32dp</dimen>
<dimen name="bottom_sheet_handle_height">4dp</dimen> <dimen name="bottom_sheet_handle_height">4dp</dimen>

View File

@@ -416,15 +416,18 @@ public class DeviceProfile {
gridVisualizationPaddingY = res.getDimensionPixelSize( gridVisualizationPaddingY = res.getDimensionPixelSize(
R.dimen.grid_visualization_vertical_cell_spacing); 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. // In large screens, in portrait mode, a bottom sheet can appear too elongated, so, we
final boolean applyExtraTopPadding = isTablet // apply additional padding.
&& !isLandscape final boolean applyExtraTopPadding = isTablet
&& (aspectRatio > MIN_ASPECT_RATIO_FOR_EXTRA_TOP_PADDING); && !isLandscape
bottomSheetTopPadding = mInsets.top // statusbar height && (aspectRatio > MIN_ASPECT_RATIO_FOR_EXTRA_TOP_PADDING);
+ (applyExtraTopPadding ? res.getDimensionPixelSize( final int derivedTopPadding = heightPx / 6;
R.dimen.bottom_sheet_extra_top_padding) : 0) bottomSheetTopPadding = mInsets.top // statusbar height
+ (isTablet ? 0 : edgeMarginPx); // phones need edgeMarginPx additional padding + (applyExtraTopPadding ? derivedTopPadding : 0)
+ (isTablet ? 0 : edgeMarginPx); // phones need edgeMarginPx additional padding
}
bottomSheetOpenDuration = res.getInteger(R.integer.config_bottomSheetOpenDuration); bottomSheetOpenDuration = res.getInteger(R.integer.config_bottomSheetOpenDuration);
bottomSheetCloseDuration = res.getInteger(R.integer.config_bottomSheetCloseDuration); bottomSheetCloseDuration = res.getInteger(R.integer.config_bottomSheetCloseDuration);
if (isTablet) { if (isTablet) {