From 58a22af103486a58b4f4b5bd8d59e7575066b34d Mon Sep 17 00:00:00 2001 From: Mugurell Date: Fri, 16 Oct 2020 20:08:18 +0300 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/15757 - Avoid the double spacing issues for grid items in tabs tray Items should have a 16dp all around padding. Have them have a 8dp padding that will add to 16 when placed together. Have the parent have another 8dp that will add to 16 for when items are placed to the edge of the available screen. --- .../java/org/mozilla/fenix/tabtray/TabTrayView.kt | 12 ++++++++++++ app/src/main/res/layout/component_tabstray.xml | 1 + 2 files changed, 13 insertions(+) diff --git a/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayView.kt b/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayView.kt index 87894865aa..66018c6d28 100644 --- a/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayView.kt +++ b/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayView.kt @@ -44,6 +44,7 @@ import mozilla.components.browser.state.state.TabSessionState import mozilla.components.browser.tabstray.TabViewHolder import mozilla.components.feature.syncedtabs.SyncedTabsFeature import mozilla.components.support.base.feature.ViewBoundFeatureWrapper +import mozilla.components.support.ktx.android.util.dpToPx import org.mozilla.fenix.R import org.mozilla.fenix.browser.InfoBanner import org.mozilla.fenix.components.metrics.Event @@ -399,6 +400,15 @@ class TabTrayView( } layoutManager = gridLayoutManager + + // Ensure items have the same all around padding - 16 dp. Avoid the double spacing issue. + // A 8dp padding is already set in xml, pad the parent with the remaining needed 8dp. + updateLayoutParams { + val padding = GRID_ITEM_PARENT_PADDING.dpToPx(resources.displayMetrics) + // Account for the already set bottom padding needed to accommodate the fab. + val bottomPadding = paddingBottom + padding + setPadding(padding, padding, padding, bottomPadding) + } } } @@ -702,6 +712,8 @@ class TabTrayView( private const val SELECTION_DELAY = 500 private const val NORMAL_HANDLE_PERCENT_WIDTH = 0.1F private const val COLUMN_WIDTH_DP = 180 + // The remaining padding offset needed to provide a 16dp column spacing between the grid items. + const val GRID_ITEM_PARENT_PADDING = 8 } } diff --git a/app/src/main/res/layout/component_tabstray.xml b/app/src/main/res/layout/component_tabstray.xml index 3d0ba0582a..7d8c1e32be 100644 --- a/app/src/main/res/layout/component_tabstray.xml +++ b/app/src/main/res/layout/component_tabstray.xml @@ -181,6 +181,7 @@ android:layout_height="0dp" android:clipToPadding="false" android:paddingBottom="140dp" + android:scrollbarStyle="outsideOverlay" android:scrollbars="vertical" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent"