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

Commit 3085e072 authored by Jonathon Axford's avatar Jonathon Axford Committed by Android (Google) Code Review
Browse files

Merge "Quick Settings rows and columns on small landscape lockscreen" into main

parents f1325adb 65fc77cc
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -70,6 +70,16 @@
    <!-- The number of rows in the QuickSettings -->
    <integer name="quick_settings_max_rows">4</integer>

    <!-- Override column number for quick settings.
    For now, this value has effect only when flag lockscreen.enable_landscape is enabled.
    TODO (b/293252410) - change this comment/resource when flag is enabled -->
    <integer name="small_land_lockscreen_quick_settings_num_columns">2</integer>

    <!-- Override row number for quick settings.
    For now, this value has effect only when flag lockscreen.enable_landscape is enabled.
    TODO (b/293252410) - change this comment/resource when flag is enabled -->
    <integer name="small_land_lockscreen_quick_settings_max_rows">2</integer>

    <!-- If the dp width of the available space is <= this value, potentially adjust the number
         of media recommendation items-->
    <integer name="default_qs_media_rec_width_dp">380</integer>
+19 −1
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.systemui.qs

import android.content.Context
import android.util.AttributeSet
import com.android.systemui.flags.Flags
import com.android.systemui.flags.ViewRefactorFlag
import com.android.systemui.res.R

open class SideLabelTileLayout(
@@ -25,9 +27,25 @@ open class SideLabelTileLayout(
    attrs: AttributeSet?
) : TileLayout(context, attrs) {

    private final val isSmallLandscapeLockscreenEnabled =
            ViewRefactorFlag(flag = Flags.LOCKSCREEN_ENABLE_LANDSCAPE).isEnabled

    override fun updateResources(): Boolean {
        return super.updateResources().also {
            mMaxAllowedRows = context.resources.getInteger(R.integer.quick_settings_max_rows)
            // TODO (b/293252410) remove condition here when flag is launched
            //  Instead update quick_settings_max_rows resource to be the same as
            //  small_land_lockscreen_quick_settings_max_rows whenever is_small_screen_landscape is
            //  true. Then, only use quick_settings_max_rows resource.
            val useSmallLandscapeLockscreenResources =
                    isSmallLandscapeLockscreenEnabled &&
                    mContext.resources.getBoolean(R.bool.is_small_screen_landscape)

            mMaxAllowedRows = if (useSmallLandscapeLockscreenResources) {
                context.resources.getInteger(
                        R.integer.small_land_lockscreen_quick_settings_max_rows)
                } else {
                    context.resources.getInteger(R.integer.quick_settings_max_rows)
                }
        }
    }

+23 −3
Original line number Diff line number Diff line
@@ -15,7 +15,9 @@ import androidx.annotation.Nullable;

import com.android.internal.logging.UiEventLogger;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.flags.ViewRefactorFlag;
import com.android.systemui.res.R;
import com.android.systemui.flags.Flags;
import com.android.systemui.qs.QSPanel.QSTileLayout;
import com.android.systemui.qs.QSPanelControllerBase.TileRecord;
import com.android.systemui.qs.tileimpl.HeightOverrideable;
@@ -51,8 +53,9 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
    protected int mResourceColumns;
    private float mSquishinessFraction = 1f;
    protected int mLastTileBottom;

    protected TextView mTempTextView;
    private final Boolean mIsSmallLandscapeLockscreenEnabled =
            new ViewRefactorFlag(Flags.LOCKSCREEN_ENABLE_LANDSCAPE).isEnabled();

    public TileLayout(Context context) {
        this(context, null);
@@ -127,12 +130,18 @@ public class TileLayout extends ViewGroup implements QSTileLayout {

    public boolean updateResources() {
        Resources res = getResources();
        mResourceColumns = Math.max(1, res.getInteger(R.integer.quick_settings_num_columns));
        int columns = useSmallLandscapeLockscreenResources()
                ? res.getInteger(R.integer.small_land_lockscreen_quick_settings_num_columns)
                : res.getInteger(R.integer.quick_settings_num_columns);
        mResourceColumns = Math.max(1, columns);
        mResourceCellHeight = res.getDimensionPixelSize(mResourceCellHeightResId);
        mCellMarginHorizontal = res.getDimensionPixelSize(R.dimen.qs_tile_margin_horizontal);
        mSidePadding = useSidePadding() ? mCellMarginHorizontal / 2 : 0;
        mCellMarginVertical= res.getDimensionPixelSize(R.dimen.qs_tile_margin_vertical);
        mMaxAllowedRows = Math.max(1, getResources().getInteger(R.integer.quick_settings_max_rows));
        int rows = useSmallLandscapeLockscreenResources()
                ? res.getInteger(R.integer.small_land_lockscreen_quick_settings_max_rows)
                : res.getInteger(R.integer.quick_settings_max_rows);
        mMaxAllowedRows = Math.max(1, rows);
        if (mLessRows) {
            mMaxAllowedRows = Math.max(mMinRows, mMaxAllowedRows - 1);
        }
@@ -146,6 +155,17 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
        return false;
    }

    // TODO (b/293252410) remove condition here when flag is launched
    //  Instead update quick_settings_num_columns and quick_settings_max_rows to be the same as
    //  the small_land_lockscreen_quick_settings_num_columns or
    //  small_land_lockscreen_quick_settings_max_rows respectively whenever
    //  is_small_screen_landscape is true.
    //  Then, only use quick_settings_num_columns and quick_settings_max_rows.
    private boolean useSmallLandscapeLockscreenResources() {
        return mIsSmallLandscapeLockscreenEnabled
                && mContext.getResources().getBoolean(R.bool.is_small_screen_landscape);
    }

    protected boolean useSidePadding() {
        return true;
    }
+26 −3
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ import androidx.recyclerview.widget.RecyclerView.ViewHolder;

import com.android.internal.logging.UiEventLogger;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.res.R;
import com.android.systemui.qs.QSEditEvent;
import com.android.systemui.qs.QSHost;
@@ -117,12 +119,14 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta

    private TextView mTempTextView;
    private int mMinTileViewHeight;
    private final boolean mIsSmallLandscapeLockscreenEnabled;

    @Inject
    public TileAdapter(
            @QSThemedContext Context context,
            QSHost qsHost,
            UiEventLogger uiEventLogger) {
            UiEventLogger uiEventLogger,
            FeatureFlags featureFlags) {
        mContext = context;
        mHost = qsHost;
        mUiEventLogger = uiEventLogger;
@@ -130,7 +134,12 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
        mDecoration = new TileItemDecoration(context);
        mMarginDecoration = new MarginTileDecoration();
        mMinNumTiles = context.getResources().getInteger(R.integer.quick_settings_min_num_tiles);
        mNumColumns = context.getResources().getInteger(NUM_COLUMNS_ID);
        mIsSmallLandscapeLockscreenEnabled =
                featureFlags.isEnabled(Flags.LOCKSCREEN_ENABLE_LANDSCAPE);
        mNumColumns = useSmallLandscapeLockscreenResources()
                ? context.getResources().getInteger(
                        R.integer.small_land_lockscreen_quick_settings_num_columns)
                : context.getResources().getInteger(NUM_COLUMNS_ID);
        mAccessibilityDelegate = new TileAdapterDelegate();
        mSizeLookup.setSpanIndexCacheEnabled(true);
        mTempTextView = new TextView(context);
@@ -153,7 +162,10 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
     * @return {@code true} if the number of columns changed, {@code false} otherwise
     */
    public boolean updateNumColumns() {
        int numColumns = mContext.getResources().getInteger(NUM_COLUMNS_ID);
        int numColumns = useSmallLandscapeLockscreenResources()
                ? mContext.getResources().getInteger(
                        R.integer.small_land_lockscreen_quick_settings_num_columns)
                : mContext.getResources().getInteger(NUM_COLUMNS_ID);
        if (numColumns != mNumColumns) {
            mNumColumns = numColumns;
            return true;
@@ -162,6 +174,17 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
        }
    }

    // TODO (b/293252410) remove condition here when flag is launched
    //  Instead update quick_settings_num_columns and quick_settings_max_rows to be the same as
    //  the small_land_lockscreen_quick_settings_num_columns or
    //  small_land_lockscreen_quick_settings_max_rows respectively whenever
    //  is_small_screen_landscape is true.
    //  Then, only use quick_settings_num_columns and quick_settings_max_rows.
    private boolean useSmallLandscapeLockscreenResources() {
        return mIsSmallLandscapeLockscreenEnabled
                && mContext.getResources().getBoolean(R.bool.is_small_screen_landscape);
    }

    public int getNumColumns() {
        return mNumColumns;
    }
+6 −1
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import androidx.test.filters.SmallTest;

import com.android.internal.logging.testing.UiEventLoggerFake;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.flags.FakeFeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.qs.QSHost;

import org.junit.Before;
@@ -46,10 +48,13 @@ public class TileAdapterTest extends SysuiTestCase {

    @Before
    public void setup() throws Exception {
        FakeFeatureFlags fakeFeatureFlags = new FakeFeatureFlags();
        fakeFeatureFlags.set(Flags.LOCKSCREEN_ENABLE_LANDSCAPE, false);

        MockitoAnnotations.initMocks(this);

        TestableLooper.get(this).runWithLooper(() -> mTileAdapter =
                new TileAdapter(mContext, mQSHost, new UiEventLoggerFake()));
                new TileAdapter(mContext, mQSHost, new UiEventLoggerFake(), fakeFeatureFlags));
    }

    @Test