From 52bd8c260e3798d64a65c64e65d2b122235d2cd6 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Mon, 8 Oct 2018 12:52:51 -0400 Subject: [PATCH] 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 --- .../res/layout/qs_paged_tile_layout.xml | 13 ------------ .../android/systemui/qs/PagedTileLayout.java | 21 +++++++++++++++++-- .../com/android/systemui/qs/TileLayout.java | 6 ++++-- 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 7083269714541..e44fbcfd122f5 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"> - - - - - - diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java index c398a4a68976c..76dfddb78c80f 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; @@ -275,6 +277,13 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { return changed; } + @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) { @@ -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 e884302af0753..1dd729d0624c0 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); } /**