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

Commit c9d831d6 authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "Work on QS layouts"

parents d697463d 9d02a431
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -21,14 +21,6 @@
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <com.android.systemui.qs.QuickTileLayout
        android:id="@+id/quick_tile_layout"
        android:layout_width="match_parent"
        android:layout_height="@dimen/qs_quick_actions_height"
        android:orientation="horizontal"
        android:paddingStart="@dimen/qs_quick_actions_padding"
        android:paddingEnd="@dimen/qs_quick_actions_padding" />

    <view
        class="com.android.systemui.qs.PagedTileLayout$TilePage"
        android:id="@+id/tile_page"
+2 −0
Original line number Diff line number Diff line
@@ -38,4 +38,6 @@
         while the stack is not focused. -->
    <item name="recents_layout_unfocused_range_min" format="float" type="integer">-2</item>
    <item name="recents_layout_unfocused_range_max" format="float" type="integer">1.5</item>

    <integer name="quick_settings_num_columns">4</integer>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -18,4 +18,6 @@
    <!-- The maximum count of notifications on Keyguard. The rest will be collapsed in an overflow
         card. -->
    <integer name="keyguard_max_notification_count">3</integer>

    <integer name="quick_settings_num_columns">3</integer>
</resources>
+1 −3
Original line number Diff line number Diff line
@@ -134,9 +134,7 @@
    <dimen name="pull_span_min">25dp</dimen>

    <dimen name="qs_tile_height">88dp</dimen>
    <dimen name="qs_new_tile_height">100dp</dimen>
    <dimen name="qs_quick_actions_height">88dp</dimen>
    <dimen name="qs_quick_actions_padding">25dp</dimen>
    <dimen name="qs_tile_margin">16dp</dimen>
    <dimen name="qs_quick_tile_size">48dp</dimen>
    <dimen name="qs_quick_tile_padding">12dp</dimen>
    <dimen name="qs_date_anim_translation">44.5dp</dimen>
+31 −16
Original line number Diff line number Diff line
@@ -62,27 +62,32 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {

    @Override
    public int getOffsetTop(TileRecord tile) {
        return ((ViewGroup) tile.tileView.getParent()).getTop();
        return ((ViewGroup) tile.tileView.getParent()).getTop() + getTop();
    }

    @Override
    public void addTile(TileRecord tile) {
        mTiles.add(tile);
        distributeTiles();
        postDistributeTiles();
    }

    @Override
    public void removeTile(TileRecord tile) {
        if (mTiles.remove(tile)) {
            distributeTiles();
            postDistributeTiles();
        }
    }

    private void postDistributeTiles() {
        removeCallbacks(mDistribute);
        post(mDistribute);
    }

    private void distributeTiles() {
        if (DEBUG) Log.d(TAG, "Distributing tiles");
        final int NP = mPages.size();
        for (int i = 0; i < NP; i++) {
            mPages.get(i).clear();
            mPages.get(i).removeAllViews();
        }
        int index = 0;
        final int NT = mTiles.size();
@@ -107,10 +112,15 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
    }

    @Override
    public void updateResources() {
    public boolean updateResources() {
        boolean changed = false;
        for (int i = 0; i < mPages.size(); i++) {
            mPages.get(i).updateResources();
            changed |= mPages.get(i).updateResources();
        }
        if (changed) {
            distributeTiles();
        }
        return changed;
    }

    @Override
@@ -129,6 +139,13 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        setMeasuredDimension(getMeasuredWidth(), maxHeight + mPageIndicator.getMeasuredHeight());
    }

    private final Runnable mDistribute = new Runnable() {
        @Override
        public void run() {
            distributeTiles();
        }
    };

    public static class TilePage extends TileLayout {
        private int mMaxRows = 3;

@@ -137,19 +154,17 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
            updateResources();
        }

        public void setMaxRows(int maxRows) {
            mMaxRows = maxRows;
        }

        @Override
        protected int getCellHeight() {
            return mContext.getResources().getDimensionPixelSize(R.dimen.qs_new_tile_height);
        public boolean updateResources() {
            if (super.updateResources()) {
                mMaxRows = mColumns != 3 ? 2 : 3;
                return true;
            }
            return false;
        }

        private void clear() {
            if (DEBUG) Log.d(TAG, "Clearing page");
            removeAllViews();
            mRecords.clear();
        public void setMaxRows(int maxRows) {
            mMaxRows = maxRows;
        }

        public boolean isFull() {
Loading