diff options
| author | 2018-10-08 12:52:51 -0400 | |
|---|---|---|
| committer | 2018-10-09 10:18:26 -0400 | |
| commit | 52bd8c260e3798d64a65c64e65d2b122235d2cd6 (patch) | |
| tree | b9e6d0042ed703ff4b9fa64e8387db5a16ab9ad4 | |
| parent | a4b1fe65470ea4c015207fa8b2016d95603e5931 (diff) | |
Fixes wrong measurements on QS animation
Clipping of PagedTileLayout is done independent of padding so no
measurement corrections are needed. Padding in TilePage fixed so
the pages are centered (they use all the width).
FrameLayout in qs_paged_tile_layout removed as not used.
Change-Id: If8cd95855ebcddf533e87b9203c4ee3d831bdf2c
Test: atest && visual
Fixes: 117452733
Bug: 117401270
Bug: 117096186
3 files changed, 23 insertions, 17 deletions
diff --git a/packages/SystemUI/res/layout/qs_paged_tile_layout.xml b/packages/SystemUI/res/layout/qs_paged_tile_layout.xml index 708326971454..e44fbcfd122f 100644 --- a/packages/SystemUI/res/layout/qs_paged_tile_layout.xml +++ b/packages/SystemUI/res/layout/qs_paged_tile_layout.xml @@ -21,18 +21,5 @@ android:layout_height="wrap_content" android:layout_weight="1" android:clipChildren="true" - android:clipToPadding="true" - android:paddingStart="@dimen/notification_side_paddings" - android:paddingEnd="@dimen/notification_side_paddings" android:paddingBottom="@dimen/qs_paged_tile_layout_padding_bottom"> - - - <FrameLayout - android:id="@+id/page_decor" - android:layout_width="wrap_content" - android:layout_height="48dp" - android:layout_gravity="bottom"> - - </FrameLayout> - </com.android.systemui.qs.PagedTileLayout> diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java index c398a4a68976..76dfddb78c80 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java +++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java @@ -8,6 +8,7 @@ import android.animation.PropertyValuesHolder; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; +import android.graphics.Rect; import android.os.Bundle; import android.util.AttributeSet; import android.util.Log; @@ -60,6 +61,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { private int mPageToRestore = -1; private int mLayoutOrientation; private int mLayoutDirection; + private int mHorizontalClipBound; public PagedTileLayout(Context context, AttributeSet attrs) { super(context, attrs); @@ -260,8 +262,8 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { // Update bottom padding, useful for removing extra space once the panel page indicator is // hidden. Resources res = getContext().getResources(); - final int sidePadding = res.getDimensionPixelSize(R.dimen.notification_side_paddings); - setPadding(sidePadding, 0, sidePadding, + mHorizontalClipBound = res.getDimensionPixelSize(R.dimen.notification_side_paddings); + setPadding(0, 0, 0, getContext().getResources().getDimensionPixelSize( R.dimen.qs_paged_tile_layout_padding_bottom)); boolean changed = false; @@ -276,6 +278,13 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { } @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + Rect clipBounds = new Rect(mHorizontalClipBound, 0, (r-l) - mHorizontalClipBound, b - t); + setClipBounds(clipBounds); + } + + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final int nTiles = mTiles.size(); @@ -412,6 +421,14 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { public int maxTiles() { return mColumns * mRows; } + + @Override + public boolean updateResources() { + final int sidePadding = getContext().getResources().getDimensionPixelSize( + R.dimen.notification_side_paddings); + setPadding(sidePadding, 0, sidePadding, 0); + return super.updateResources(); + } } private final PagerAdapter mAdapter = new PagerAdapter() { diff --git a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java index e884302af075..1dd729d0624c 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java +++ b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java @@ -104,11 +104,13 @@ public class TileLayout extends ViewGroup implements QSTileLayout { // container is measured. Any change in the tiles, should trigger a remeasure. final int numTiles = mRecords.size(); final int width = MeasureSpec.getSize(widthMeasureSpec); + final int availableWidth = width - getPaddingStart() - getPaddingEnd(); final int heightMode = MeasureSpec.getMode(heightMeasureSpec); if (heightMode == MeasureSpec.UNSPECIFIED) { mRows = (numTiles + mColumns - 1) / mColumns; } - mCellWidth = (width - mSidePadding * 2 - (mCellMarginHorizontal * mColumns)) / mColumns; + mCellWidth = + (availableWidth - mSidePadding * 2 - (mCellMarginHorizontal * mColumns)) / mColumns; // Measure each QS tile. View previousView = this; @@ -124,7 +126,7 @@ public class TileLayout extends ViewGroup implements QSTileLayout { (mRows != 0 ? (mCellMarginTop - mCellMarginVertical) : 0); if (height < 0) height = 0; - setMeasuredDimension(width, height); + setMeasuredDimension(width + getPaddingStart() + getPaddingEnd(), height); } /** |