Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f24d1b6 authored by Alex Florescu's avatar Alex Florescu
Browse files

Configure power menu grid

Fixes: 216769732
Test: manual
Change-Id: I6c6df7032a9ef08ba6886021534eca255ed31edd
parent 30d45531
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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>
+3 −0
Original line number Diff line number Diff line
@@ -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>
+4 −0
Original line number Diff line number Diff line
@@ -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>
+6 −11
Original line number Diff line number Diff line
@@ -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);