From 27b2190cd66f33b4d0ee3531c3fd0d4eba4919cd Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Mon, 1 Nov 2021 20:35:33 -0700 Subject: [PATCH] Only call layout during layout pass In other cases, let's just adjust the bounds, otherwise we'll conflict with the measuring pass, causing the width to be 0 after screen rotations. Test: manual Fixes: 204497727 Change-Id: I759f084577814ff1a4372f1d90cd05ce73604950 --- .../android/systemui/qs/QSSquishinessController.kt | 10 +++++----- .../src/com/android/systemui/qs/TileLayout.java | 12 ++++++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSSquishinessController.kt b/packages/SystemUI/src/com/android/systemui/qs/QSSquishinessController.kt index 6de837008d916..4854600994aa2 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSSquishinessController.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/QSSquishinessController.kt @@ -34,7 +34,11 @@ class QSSquishinessController @Inject constructor( * Change the height of all tiles and repositions their siblings. */ private fun updateSquishiness() { - // Start by updating the height of all tiles + // Update tile positions in the layout + val tileLayout = quickQSPanelController.tileLayout as TileLayout + tileLayout.setSquishinessFraction(squishiness) + + // Adjust their heights as well for (tile in qsTileHost.tiles) { val tileView = quickQSPanelController.getTileView(tile) (tileView as? HeightOverrideable)?.let { @@ -42,10 +46,6 @@ class QSSquishinessController @Inject constructor( } } - // Update tile positions in the layout - val tileLayout = quickQSPanelController.tileLayout as TileLayout - tileLayout.setSquishinessFraction(squishiness) - // Calculate how much we should move the footer val tileHeightOffset = tileLayout.height - tileLayout.tilesHeight val footerTopMargin = (qqsFooterActionsView.layoutParams as ViewGroup.MarginLayoutParams) diff --git a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java index ee5d5ffb961cf..58c05089b0625 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java +++ b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java @@ -212,7 +212,7 @@ public class TileLayout extends ViewGroup implements QSTileLayout { return mMaxCellHeight; } - private void layoutTileRecords(int numRecords) { + private void layoutTileRecords(int numRecords, boolean forLayout) { final boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL; int row = 0; int column = 0; @@ -232,14 +232,18 @@ public class TileLayout extends ViewGroup implements QSTileLayout { final int left = getColumnStart(isRtl ? mColumns - column - 1 : column); final int right = left + mCellWidth; final int bottom = top + record.tileView.getMeasuredHeight(); - record.tileView.layout(left, top, right, bottom); + if (forLayout) { + record.tileView.layout(left, top, right, bottom); + } else { + record.tileView.setLeftTopRightBottom(left, top, right, bottom); + } mLastTileBottom = bottom; } } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { - layoutTileRecords(mRecords.size()); + layoutTileRecords(mRecords.size(), true /* forLayout */); } protected int getRowTop(int row) { @@ -280,6 +284,6 @@ public class TileLayout extends ViewGroup implements QSTileLayout { return; } mSquishinessFraction = squishinessFraction; - layoutTileRecords(mRecords.size()); + layoutTileRecords(mRecords.size(), false /* forLayout */); } }