Merge "Fixes wrong measurements on QS animation"
This commit is contained in:
committed by
Android (Google) Code Review
commit
fa66c22c20
@@ -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>
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user