From 1ffaf8c28e4106b3113df16df811eec8c8df1fbc Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Thu, 9 Apr 2020 11:13:07 -0700 Subject: [PATCH] Fix calculation of empty spaces We should not add spaces when columns are filled successfully. Bug: 152628601 Test: manual Change-Id: I2b86e440847e8de9ddabb43fca0d1f7083ffff12 --- .../android/systemui/controls/ui/ControlsUiControllerImpl.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt index 02c6ff68450ed..934a69508d683 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt @@ -429,7 +429,8 @@ class ControlsUiControllerImpl @Inject constructor ( } // add spacers if necessary to keep control size consistent - var spacersToAdd = maxColumns - (selectedStructure.controls.size % maxColumns) + val mod = selectedStructure.controls.size % maxColumns + var spacersToAdd = if (mod == 0) 0 else maxColumns - mod while (spacersToAdd > 0) { lastRow.addView(Space(context), LinearLayout.LayoutParams(0, 0, 1f)) spacersToAdd--