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

Commit 326b69ef authored by Fabián Kozynski's avatar Fabián Kozynski
Browse files

Fix height of QQS so it's wrap content

In order to make QQS in Flexiglass wrap content, we need two things:

* Pass the correct height to the MovableContent. As QSContainerImpl
  reports QS height as the measured height, instead pass the individual
  heights (QQS, QS) to the adapter so they can be used in the `layout`
  modifier.
* Make ShadeScene higher (zIndex) than QuickSettingsScene. This makes
  sense since things like the scrim are visually on top.

Test: manual, open Customizer, change display size (scroll), landscape.
Fixes: 324090413
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT

Change-Id: Iaab56d9b05e1523a696922197ca23112dd5b30c6
parent ca4a84d4
Loading
Loading
Loading
Loading
+22 −15
Original line number Diff line number Diff line
@@ -18,21 +18,21 @@ package com.android.systemui.qs.ui.composable

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.layout
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import com.android.compose.animation.scene.ElementKey
import com.android.compose.animation.scene.MovableElementScenePicker
import com.android.compose.animation.scene.SceneScope
import com.android.compose.animation.scene.TransitionState
import com.android.compose.modifiers.thenIf
import com.android.compose.theme.colorAttr
import com.android.systemui.qs.ui.adapter.QSSceneAdapter
import com.android.systemui.qs.ui.adapter.QSSceneAdapter.State.Companion.Collapsing
@@ -44,9 +44,16 @@ import com.android.systemui.scene.ui.composable.QuickSettings as QuickSettingsSc
import com.android.systemui.scene.ui.composable.Shade

object QuickSettings {
    private val SCENES =
        setOf(
            QuickSettingsSceneKey,
            Shade,
        )

    object Elements {
        // TODO RENAME
        val Content = ElementKey("QuickSettingsContent")
        val Content =
            ElementKey("QuickSettingsContent", scenePicker = MovableElementScenePicker(SCENES))
        val CollapsedGrid = ElementKey("QuickSettingsCollapsedGrid")
        val FooterActions = ElementKey("QuickSettingsFooterActions")
    }
@@ -86,14 +93,22 @@ private fun SceneScope.stateForQuickSettingsContent(): QSSceneAdapter.State {
 */
@Composable
fun SceneScope.QuickSettings(
    modifier: Modifier = Modifier,
    qsSceneAdapter: QSSceneAdapter,
    heightProvider: () -> Int,
    modifier: Modifier = Modifier,
) {
    val contentState = stateForQuickSettingsContent()

    MovableElement(
        key = QuickSettings.Elements.Content,
        modifier = modifier.fillMaxWidth().defaultMinSize(minHeight = 300.dp)
        modifier =
            modifier.fillMaxWidth().layout { measurable, constraints ->
                val placeable = measurable.measure(constraints)
                // Use the height of the correct view based on the scene it is being composed in
                val height = heightProvider()

                layout(placeable.width, height) { placeable.placeRelative(0, 0) }
            }
    ) {
        content { QuickSettingsContent(qsSceneAdapter = qsSceneAdapter, contentState) }
    }
@@ -118,15 +133,7 @@ private fun QuickSettingsContent(
        qsView?.let { view ->
            Box(
                modifier =
                    modifier
                        .fillMaxWidth()
                        .then(
                            if (isCustomizing) {
                                Modifier.fillMaxHeight()
                            } else {
                                Modifier.wrapContentHeight()
                            }
                        )
                    modifier.fillMaxWidth().thenIf(isCustomizing) { Modifier.fillMaxHeight() }
            ) {
                AndroidView(
                    modifier = Modifier.fillMaxWidth().background(colorAttr(R.attr.underSurface)),
+2 −1
Original line number Diff line number Diff line
@@ -213,8 +213,9 @@ private fun SceneScope.QuickSettingsScene(
                    Spacer(modifier = Modifier.height(16.dp))
                    // This view has its own horizontal padding
                    QuickSettings(
                        modifier = Modifier.sysuiResTag("expanded_qs_scroll_view"),
                        viewModel.qsSceneAdapter,
                        { viewModel.qsSceneAdapter.qsHeight },
                        modifier = Modifier.sysuiResTag("expanded_qs_scroll_view"),
                    )
                }
            }
+1 −1
Original line number Diff line number Diff line
@@ -189,8 +189,8 @@ private fun SceneScope.ShadeScene(
                                    )
                            )
                            QuickSettings(
                                modifier = Modifier.height(130.dp),
                                viewModel.qsSceneAdapter,
                                { viewModel.qsSceneAdapter.qqsHeight },
                            )

                            if (viewModel.isMediaVisible()) {
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ class QuickSettingsSceneViewModelTest : SysuiTestCase() {
    private val sceneInteractor by lazy { kosmos.sceneInteractor }
    private val mobileIconsInteractor = FakeMobileIconsInteractor(FakeMobileMappingsProxy(), mock())
    private val flags = FakeFeatureFlagsClassic().also { it.set(Flags.NEW_NETWORK_SLICE_UI, false) }
    private val qsFlexiglassAdapter = FakeQSSceneAdapter { mock() }
    private val qsFlexiglassAdapter = FakeQSSceneAdapter({ mock() })
    private val footerActionsViewModel = mock<FooterActionsViewModel>()
    private val footerActionsViewModelFactory =
        mock<FooterActionsViewModel.Factory> {
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ class ShadeSceneViewModelTest : SysuiTestCase() {
            scope = testScope.backgroundScope,
        )

    private val qsFlexiglassAdapter = FakeQSSceneAdapter { mock() }
    private val qsFlexiglassAdapter = FakeQSSceneAdapter({ mock() })

    private lateinit var shadeHeaderViewModel: ShadeHeaderViewModel

Loading