Merge "Configure power menu grid"

This commit is contained in:
Alex Florescu
2022-02-11 15:58:40 +00:00
committed by Android (Google) Code Review
4 changed files with 19 additions and 11 deletions

View File

@@ -33,4 +33,10 @@
<!-- Max number of columns for power menu -->
<integer name="power_menu_max_columns">4</integer>
<!-- Max number of columns for power menu lite -->
<integer name="power_menu_lite_max_columns">4</integer>
<!-- Max number of rows for power menu lite -->
<integer name="power_menu_lite_max_rows">2</integer>
</resources>

View File

@@ -33,4 +33,7 @@
<!-- Notifications are sized to match the width of two (of 4) qs tiles in landscape. -->
<bool name="config_skinnyNotifsInLandscape">false</bool>
<integer name="power_menu_lite_max_columns">3</integer>
<integer name="power_menu_lite_max_rows">2</integer>
</resources>

View File

@@ -23,4 +23,8 @@
<!-- The number of columns in the QuickSettings -->
<integer name="quick_settings_num_columns">3</integer>
<integer name="power_menu_lite_max_columns">2</integer>
<integer name="power_menu_lite_max_rows">3</integer>
</resources>

View File

@@ -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);