Updating long-press effect dimensions after re-layouts.
When the device rotates, the long-press effect properties that control
the effect need to be updated to align with the latest dimensions of the
tile. This is accomplished by updating the height and width of the
properties after a re-layout.
Test: atest SystemUITests:QSTileViewImplTest
Test: manual: open the quick settings panel -> rotate the device ->
long-press on a tile that is long-clickable -> verify that the
animation starts from the tile's current dimensions. Repeat on the
quick-quick settings panel
Flag: ACONFIG quick_settings_visual_haptics_longpress TEAMFOOD
Bug: 340663904
Change-Id: I447ee0300593de65f978c397348a552312862c40
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 4fd0df4..598cbc3 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
@@ -330,6 +330,21 @@
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
super.onLayout(changed, l, t, r, b)
updateHeight()
+ maybeUpdateLongPressEffectDimensions()
+ }
+
+ private fun maybeUpdateLongPressEffectDimensions() {
+ if (!isLongClickable || longPressEffect == null) return
+
+ val actualHeight = if (heightOverride != HeightOverrideable.NO_OVERRIDE) {
+ heightOverride
+ } else {
+ measuredHeight
+ }
+ initialLongPressProperties?.height = actualHeight.toFloat()
+ initialLongPressProperties?.width = measuredWidth.toFloat()
+ finalLongPressProperties?.height = LONG_PRESS_EFFECT_HEIGHT_SCALE * actualHeight
+ finalLongPressProperties?.width = LONG_PRESS_EFFECT_WIDTH_SCALE * measuredWidth
}
private fun updateHeight() {