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

Commit 9d02a431 authored by Jason Monk's avatar Jason Monk
Browse files

Work on QS layouts

Better layouts, less work, more columns... sometimes.

Also fix some bugs.

Bug: 26705136

Change-Id: Ia368791259a1a91522a3efb70729919da79e37ea
parent 751766a5
Loading
Loading
Loading
Loading
+0 −8
Original line number Original line Diff line number Diff line
@@ -21,14 +21,6 @@
    android:layout_height="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    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
    <view
        class="com.android.systemui.qs.PagedTileLayout$TilePage"
        class="com.android.systemui.qs.PagedTileLayout$TilePage"
        android:id="@+id/tile_page"
        android:id="@+id/tile_page"
+2 −0
Original line number Original line Diff line number Diff line
@@ -38,4 +38,6 @@
         while the stack is not focused. -->
         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_min" format="float" type="integer">-2</item>
    <item name="recents_layout_unfocused_range_max" format="float" type="integer">1.5</item>
    <item name="recents_layout_unfocused_range_max" format="float" type="integer">1.5</item>

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

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


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


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


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


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


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

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


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


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


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

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


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


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

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


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


        public boolean isFull() {
        public boolean isFull() {
Loading