From cbb1ec8a4ab8bd71a5794c9ad963411519add263 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Mon, 17 Aug 2020 16:03:07 -0400 Subject: [PATCH] Fix padding in management activities Remove the inherent margin of the controls tiles and exclusively use the item decorator. As we are only assigning margin to the top (to prevent extra margin at the bottom) of each group, we double the top margin. Fixes: 164171322 Test: manual Change-Id: Id337471f3ac81855940da598b4396257ed829311 --- packages/SystemUI/res/values/dimens.xml | 2 +- .../systemui/controls/management/ControlAdapter.kt | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 5984d8d3322e8..0d40a9fa26d48 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1371,7 +1371,7 @@ 2dp 32dp - 2dp + @dimen/control_base_item_margin 15 32dp diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlAdapter.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlAdapter.kt index c683a87d6282b..31830b94e8e4a 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlAdapter.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlAdapter.kt @@ -72,8 +72,13 @@ class ControlAdapter( TYPE_CONTROL -> { ControlHolder( layoutInflater.inflate(R.layout.controls_base_item, parent, false).apply { - layoutParams.apply { + (layoutParams as ViewGroup.MarginLayoutParams).apply { width = ViewGroup.LayoutParams.MATCH_PARENT + // Reset margins as they will be set through the decoration + topMargin = 0 + bottomMargin = 0 + leftMargin = 0 + rightMargin = 0 } elevation = this@ControlAdapter.elevation background = parent.context.getDrawable( @@ -386,7 +391,7 @@ class MarginItemDecorator( val type = parent.adapter?.getItemViewType(position) if (type == ControlAdapter.TYPE_CONTROL) { outRect.apply { - top = topMargin + top = topMargin * 2 // Use double margin, as we are not setting bottom left = sideMargins right = sideMargins bottom = 0