From 32af64ccdc97f63ccb4c6e43878534b0686e7973 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Fri, 29 Apr 2022 11:45:54 -0400 Subject: [PATCH] Manually set mLastTileBottom when not laying out We want to use the correct bottom when using squishiness. As we cannot override `setLeftTopRightBottom` in QSTileViewImpl, we manually set it using the correct scale. Test: manual Fixes: 225405454 Change-Id: I9e6905a68fcb076842bb189bc75396067b6dfaa2 --- .../SystemUI/src/com/android/systemui/qs/TileLayout.java | 8 +++++++- .../com/android/systemui/qs/tileimpl/QSTileViewImpl.kt | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java index 9ef90ecf50a73..311ee56477de0 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java +++ b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java @@ -17,6 +17,7 @@ import com.android.systemui.R; import com.android.systemui.qs.QSPanel.QSTileLayout; import com.android.systemui.qs.QSPanelControllerBase.TileRecord; import com.android.systemui.qs.tileimpl.HeightOverrideable; +import com.android.systemui.qs.tileimpl.QSTileViewImplKt; import java.util.ArrayList; @@ -242,7 +243,12 @@ public class TileLayout extends ViewGroup implements QSTileLayout { record.tileView.setLeftTopRightBottom(left, top, right, bottom); } record.tileView.setPosition(i); - mLastTileBottom = bottom; + if (forLayout) { + mLastTileBottom = record.tileView.getBottom(); + } else { + float scale = QSTileViewImplKt.constrainSquishiness(mSquishinessFraction); + mLastTileBottom = top + (int) (record.tileView.getMeasuredHeight() * scale); + } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt index 72dad0608a3a0..59164dea9c454 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt @@ -262,7 +262,7 @@ open class QSTileViewImpl @JvmOverloads constructor( } // Limit how much we affect the height, so we don't have rounding artifacts when the tile // is too short. - val constrainedSquishiness = 0.1f + squishinessFraction * 0.9f + val constrainedSquishiness = constrainSquishiness(squishinessFraction) bottom = top + (actualHeight * constrainedSquishiness).toInt() scrollY = (actualHeight - height) / 2 } @@ -678,6 +678,10 @@ internal object SubtitleArrayMapping { } } +fun constrainSquishiness(squish: Float): Float { + return 0.1f + squish * 0.9f +} + private fun colorValuesHolder(name: String, vararg values: Int): PropertyValuesHolder { return PropertyValuesHolder.ofInt(name, *values).apply { setEvaluator(ArgbEvaluator.getInstance())