From 0b7d617af2616b221e4a5e1f796b481b2ff1cdce Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Thu, 8 Aug 2019 15:53:34 -0400 Subject: [PATCH] Prevent QSPanel from remeasuring Once QSPanel has been measured, do not measure it again in the pass from QSContainerImpl. This prevents measuring with a slightly bigger size (why?) that causes it to recalculate the number of rows (and the number of pages) of PagedTileLayout. In some cases, this was causing a different measure while scrolling for an instant, changing the number of pages and therefore sending the user to page 0 again. Fixes: 135136427 Test: manual, following configs: * landscape and portrait * 1, 2 and 3 pages * Security footer off and on with 1 and 2 lines Change-Id: I74e3ce68bd2d3a8b7af1c84d9d0164ce6a672ed1 --- .../com/android/systemui/qs/QSContainerImpl.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java b/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java index f0413cd6651bd..be8a8fd261508 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java @@ -111,13 +111,25 @@ public class QSContainerImpl extends FrameLayout { + mQSPanel.getMeasuredHeight() + getPaddingBottom(); super.onMeasure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)); - // QSCustomizer will always be the height of the screen, but do this after // other measuring to avoid changing the height of the QS. mQSCustomizer.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(getDisplayHeight(), MeasureSpec.EXACTLY)); } + + @Override + protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, + int parentHeightMeasureSpec, int heightUsed) { + // Do not measure QSPanel again when doing super.onMeasure. + // This prevents the pages in PagedTileLayout to be remeasured with a different (incorrect) + // size to the one used for determining the number of rows and then the number of pages. + if (child != mQSPanel) { + super.measureChildWithMargins(child, parentWidthMeasureSpec, widthUsed, + parentHeightMeasureSpec, heightUsed); + } + } + @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom);