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

Commit 904148de authored by Jiaming Cheng's avatar Jiaming Cheng
Browse files

[QSDetailedView] Fix the cast list in the details scrollable column

Previously, the Android view was measured to a 0 height view,
preventing the content from being displayed.

Bug: 378513588
Flag: com.android.systemui.qs_tile_detailed_view
Test: Only fix the UI. Existing unit tests still pass.
Change-Id: I41d005244cd41d74b6421aff98415466aaea778b
parent 71572aa7
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -17,10 +17,14 @@
package com.android.systemui.qs.tiles.dialog

import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.ListView
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@@ -28,12 +32,15 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import com.android.compose.ui.graphics.painter.rememberDrawablePainter
import com.android.internal.R
import com.android.internal.app.MediaRouteChooserContentManager
import com.android.internal.app.MediaRouteControllerContentManager

private val MAX_CAST_LIST_HEIGHT = 5000.dp

@Composable
fun CastDetailsContent(castDetailsViewModel: CastDetailsViewModel) {
    if (castDetailsViewModel.shouldShowChooserDialog()) {
@@ -65,7 +72,12 @@ fun CastDetailsContent(castDetailsViewModel: CastDetailsViewModel) {
@Composable
fun CastChooserView(contentManager: MediaRouteChooserContentManager) {
    AndroidView(
        modifier = Modifier.fillMaxWidth().testTag(CastDetailsViewModel.CHOOSER_VIEW_TEST_TAG),
        // Use heightIn on this AndroidView to ensure it measures to a non-zero height that works
        // within the scrollable area in the `TileDetails`.
        modifier =
            Modifier.fillMaxWidth()
                .heightIn(max = MAX_CAST_LIST_HEIGHT)
                .testTag(CastDetailsViewModel.CHOOSER_VIEW_TEST_TAG),
        factory = { context ->
            // Inflate with the existing dialog xml layout
            val view =
@@ -73,6 +85,13 @@ fun CastChooserView(contentManager: MediaRouteChooserContentManager) {
            contentManager.bindViews(view)
            contentManager.onAttachedToWindow()

            val listView = view.findViewById<ListView>(R.id.media_route_list)
            (listView.layoutParams as? LinearLayout.LayoutParams)?.apply {
                weight = 0.0f
                height = ViewGroup.LayoutParams.WRAP_CONTENT
                listView.layoutParams = this
            }

            view
        },
        onRelease = { contentManager.onDetachedFromWindow() },