diff --git a/packages/SystemUI/res/values-land/config.xml b/packages/SystemUI/res/values-land/config.xml
index 8c5006de577ee..062e33ce7e301 100644
--- a/packages/SystemUI/res/values-land/config.xml
+++ b/packages/SystemUI/res/values-land/config.xml
@@ -33,4 +33,10 @@
4
+
+
+ 4
+
+ 2
+
diff --git a/packages/SystemUI/res/values-sw600dp-land/config.xml b/packages/SystemUI/res/values-sw600dp-land/config.xml
index fe546f65bb136..588638f3dea5b 100644
--- a/packages/SystemUI/res/values-sw600dp-land/config.xml
+++ b/packages/SystemUI/res/values-sw600dp-land/config.xml
@@ -33,4 +33,7 @@
false
+ 3
+ 2
+
diff --git a/packages/SystemUI/res/values-sw600dp-port/config.xml b/packages/SystemUI/res/values-sw600dp-port/config.xml
index 3c6a81e7c617f..857e162d4f14b 100644
--- a/packages/SystemUI/res/values-sw600dp-port/config.xml
+++ b/packages/SystemUI/res/values-sw600dp-port/config.xml
@@ -23,4 +23,8 @@
3
+
+ 2
+ 3
+
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsLayoutLite.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsLayoutLite.java
index f1e5b0862ae03..42230aed15d5a 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsLayoutLite.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsLayoutLite.java
@@ -16,8 +16,6 @@
package com.android.systemui.globalactions;
-import static com.android.systemui.util.leak.RotationUtils.ROTATION_NONE;
-
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
@@ -33,15 +31,9 @@ import com.android.systemui.R;
* ConstraintLayout implementation of the button layout created by the global actions dialog.
*/
public class GlobalActionsLayoutLite extends GlobalActionsLayout {
- private final int mMaxColumns;
- private final int mMaxRows;
public GlobalActionsLayoutLite(Context context, AttributeSet attrs) {
super(context, attrs);
- mMaxColumns = getResources().getInteger(
- com.android.systemui.R.integer.power_menu_lite_max_columns);
- mMaxRows = getResources().getInteger(
- com.android.systemui.R.integer.power_menu_lite_max_rows);
setOnClickListener(v -> { }); // Prevent parent onClickListener from triggering
}
@@ -60,10 +52,13 @@ public class GlobalActionsLayoutLite extends GlobalActionsLayout {
@Override
public void onUpdateList() {
super.onUpdateList();
- int nElementsWrap = (getCurrentRotation() == ROTATION_NONE) ? mMaxColumns : mMaxRows;
+ int nElementsWrap = getResources().getInteger(
+ com.android.systemui.R.integer.power_menu_lite_max_columns);
int nChildren = getListView().getChildCount() - 1; // don't count flow element
- if (getCurrentRotation() != ROTATION_NONE && nChildren > mMaxRows) {
- // up to 4 elements can fit in a row in landscape, otherwise limit for balance
+
+ // Avoid having just one action on the last row if there are more than 2 columns because
+ // it looks unbalanced. Instead, bring the column size down to balance better.
+ if (nChildren == nElementsWrap + 1 && nElementsWrap > 2) {
nElementsWrap -= 1;
}
Flow flow = findViewById(R.id.list_flow);