From 4ba517381828e4b61d46878e8154624301e28205 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Wed, 10 Oct 2018 12:52:35 -0400 Subject: [PATCH] DO NOT MERGE Fixes clipping on PagedTileLayout Manually cherry-picked from ag/5161962 and ag/5213435 Defines left and right bounds for clipping the pages of PagedTileLayout with the same width as the padding in PagedTileLayout.TilePage. Test: manual && atest Change-Id: I5023d5a20749ad239036c316e035e31bed013cff Fixes: 117096186 --- .../SystemUI/res/layout/qs_paged_tile_layout.xml | 2 +- .../com/android/systemui/qs/PagedTileLayout.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/res/layout/qs_paged_tile_layout.xml b/packages/SystemUI/res/layout/qs_paged_tile_layout.xml index e96a09baa9dbb..d1818447a7987 100644 --- a/packages/SystemUI/res/layout/qs_paged_tile_layout.xml +++ b/packages/SystemUI/res/layout/qs_paged_tile_layout.xml @@ -19,7 +19,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - android:clipChildren="false" + android:clipChildren="true" android:clipToPadding="false" 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 ab822696d3826..7955d3af22ae8 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.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.util.AttributeSet; @@ -57,6 +58,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { private AnimatorSet mBounceAnimatorSet; private int mAnimatingToPage = -1; private float mLastExpansion; + private int mHorizontalClipBounds; public PagedTileLayout(Context context, AttributeSet attrs) { super(context, attrs); @@ -243,6 +245,8 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { public boolean updateResources() { // Update bottom padding, useful for removing extra space once the panel page indicator is // hidden. + mHorizontalClipBounds = getContext().getResources().getDimensionPixelSize( + R.dimen.notification_side_paddings); setPadding(0, 0, 0, getContext().getResources().getDimensionPixelSize( R.dimen.qs_paged_tile_layout_padding_bottom)); @@ -273,6 +277,15 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { setMeasuredDimension(getMeasuredWidth(), maxHeight + getPaddingBottom()); } + @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(mHorizontalClipBounds, 0, + r - l - mHorizontalClipBounds, b - t); + setClipBounds(clipBounds); + } + + private final Runnable mDistribute = new Runnable() { @Override public void run() {