Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd4eb2da authored by Michael Mikhail's avatar Michael Mikhail
Browse files

Update measurement input when width or height of UMO is higher

Flag: com.android.systemui.qs_ui_refactor_compose_fragment
Bug: 404815434
Test: checked UI with logging.
Change-Id: I7a9455e989f84de6d26780fd352a0cc383a70da7
parent ce154082
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@ import com.android.systemui.keyboard.shortcut.ui.composable.ProvideShortcutHelpe
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.lifecycle.setSnapshotBinding
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.media.controls.ui.controller.MediaViewLogger
import com.android.systemui.media.controls.ui.view.MediaHost
import com.android.systemui.plugins.qs.QS
import com.android.systemui.plugins.qs.QSContainerController
@@ -146,6 +147,7 @@ import com.android.systemui.qs.ui.composable.QuickSettingsShade.systemGestureExc
import com.android.systemui.qs.ui.composable.QuickSettingsTheme
import com.android.systemui.res.R
import com.android.systemui.util.LifecycleFragment
import com.android.systemui.util.animation.MeasurementInput
import com.android.systemui.util.animation.UniqueObjectHostView
import com.android.systemui.util.asIndenting
import com.android.systemui.util.children
@@ -174,6 +176,7 @@ constructor(
    @QSFragmentComposeClippingTableLog private val qsClippingTableLogBuffer: TableLogBuffer,
    private val dumpManager: DumpManager,
    @Background private val backgroundDispatcher: CoroutineDispatcher,
    private val mediaLogger: MediaViewLogger,
) : LifecycleFragment(), QS, Dumpable {

    private val scrollListener = MutableStateFlow<QS.ScrollListener?>(null)
@@ -715,6 +718,7 @@ constructor(
                                // (b/383085298)
                                modifier = Modifier.requiredHeightIn(max = Dp.Infinity),
                                mediaHost = viewModel.qqsMediaHost,
                                mediaLogger = mediaLogger,
                            )
                        }
                    }
@@ -869,6 +873,7 @@ constructor(
                                if (viewModel.qsMediaVisible) {
                                    MediaObject(
                                        mediaHost = viewModel.qsMediaHost,
                                        mediaLogger = mediaLogger,
                                        update = { translationY = viewModel.qsMediaTranslationY },
                                    )
                                }
@@ -1342,6 +1347,7 @@ private fun Modifier.gesturesDisabled(disabled: Boolean) =
private fun MediaObject(
    mediaHost: MediaHost,
    modifier: Modifier = Modifier,
    mediaLogger: MediaViewLogger,
    update: UniqueObjectHostView.() -> Unit = {},
) {
    Box {
@@ -1361,11 +1367,17 @@ private fun MediaObject(
                // Update layout params if host view bounds are higher than its child.
                val height = mediaHost.hostView.height
                val width = mediaHost.hostView.width
                var measure = false
                mediaHost.hostView.children.forEach { child ->
                    if (child is FrameLayout && (height > child.height || width > child.width)) {
                        measure = true
                        child.layoutParams = FrameLayout.LayoutParams(width, height)
                    }
                }
                if (measure) {
                    mediaHost.hostView.measurementManager.onMeasure(MeasurementInput(width, height))
                    mediaLogger.logMediaSize("update size in compose", width, height)
                }
            },
            onReset = {},
        )