From 876efc4b26152f3f48d6a195ceafc5bf4e36a34f Mon Sep 17 00:00:00 2001 From: Hawkwood Glazier Date: Wed, 23 Nov 2022 17:04:48 +0000 Subject: [PATCH] Ensure final height of UMO transition is the hostView's height Since the targetHost should be measured correctly, and it sets the child view's size when it is added (either by remeasuring or by directly setting it), setting it again to the target bounds is unnessecary and potentially buggy. Additionally, when we obtain a view state, we always obtain it at an expansion of 1f. This prevents any squishiness from being applied when remeasuring. Test: Manual Bug: 232528163 Change-Id: I0a4e6c457663dfe376ad7754f6d151f47d3aeaf3 --- .../media/controls/ui/MediaHierarchyManager.kt | 13 ++----------- .../media/controls/ui/MediaViewController.kt | 4 +++- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt index cbb670ebf02d5..ca45e4f1d02e4 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt @@ -1043,18 +1043,9 @@ constructor( rootOverlay!!.add(mediaFrame) } else { val targetHost = getHost(newLocation)!!.hostView - // When adding back to the host, let's make sure to reset the bounds. - // Usually adding the view will trigger a layout that does this automatically, - // but we sometimes suppress this. + // This will either do a full layout pass and remeasure, or it will bypass + // that and directly set the mediaFrame's bounds within the premeasured host. targetHost.addView(mediaFrame) - val left = targetHost.paddingLeft - val top = targetHost.paddingTop - mediaFrame.setLeftTopRightBottom( - left, - top, - left + currentBounds.width(), - top + currentBounds.height() - ) if (mediaFrame.childCount > 0) { val child = mediaFrame.getChildAt(0) diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt index 4bf3031c02b4b..4feb9844cb8b8 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaViewController.kt @@ -420,7 +420,9 @@ constructor( */ fun getMeasurementsForState(hostState: MediaHostState): MeasurementOutput? = traceSection("MediaViewController#getMeasurementsForState") { - val viewState = obtainViewState(hostState) ?: return null + // measurements should never factor in the squish fraction + val viewState = + obtainViewState(hostState.copy().also { it.squishFraction = 1.0f }) ?: return null measurement.measuredWidth = viewState.width measurement.measuredHeight = viewState.height return measurement