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

Commit 6237fe8c authored by Jiaming Cheng's avatar Jiaming Cheng
Browse files

[QSDetailedView] Set min/max height for the details view

Use min-height of 300dp and max-height of 600dp
    - if the details content height is between 300~600, use the
    details content's height
    - if the details content height is smaller than 300, use 300
    - if the details content height is larger than 600, use 600.
    Also in the case the content should be scrollable.

Bug:407104102
Flag: com.android.systemui.qs_tile_detailed_view
Test: Only change the details size. Existing unit tests still pass.
Change-Id: I72693678c3d0406780af80e5a2f011be0efa02e7
parent 963ae7cd
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
package com.android.systemui.bluetooth.qsdialog

import android.view.LayoutInflater
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
@@ -27,7 +27,7 @@ import com.android.systemui.res.R
@Composable
fun BluetoothDetailsContent(detailsContentViewModel: BluetoothDetailsContentViewModel) {
    AndroidView(
        modifier = Modifier.fillMaxSize(),
        modifier = Modifier.fillMaxWidth(),
        factory = { context ->
            // Inflate with the existing dialog xml layout
            val view =
+25 −22
Original line number Diff line number Diff line
@@ -20,11 +20,13 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Settings
@@ -74,33 +76,32 @@ fun TileDetails(modifier: Modifier = Modifier, detailsViewModel: DetailsViewMode
        modifier =
            modifier
                .fillMaxWidth()
                // The height of the details view is TBD.
                .fillMaxHeight()
                .heightIn(
                    min = TileDetailsDefaults.DetailsMinHeight,
                    max = TileDetailsDefaults.DetailsMaxHeight,
                )
                .background(color = colors.onPrimary)
    ) {
        CompositionLocalProvider(
            value = LocalContentColor provides MaterialTheme.colorScheme.onSurfaceVariant
        ) {
            Row(
                modifier = Modifier
                    .fillMaxWidth()
                modifier =
                    Modifier.fillMaxWidth()
                        .padding(
                            start = TileDetailsDefaults.TitleRowStart,
                            top = TileDetailsDefaults.TitleRowTop,
                            end = TileDetailsDefaults.TitleRowEnd,
                        bottom = TileDetailsDefaults.TitleRowBottom
                            bottom = TileDetailsDefaults.TitleRowBottom,
                        ),
                horizontalArrangement = Arrangement.SpaceBetween,
                verticalAlignment = Alignment.CenterVertically,
            ) {
                IconButton(
                    onClick = { detailsViewModel.closeDetailedView() },
                    colors = IconButtonDefaults.iconButtonColors(
                        contentColor = colors.onSurface
                    ),
                    colors = IconButtonDefaults.iconButtonColors(contentColor = colors.onSurface),
                    modifier =
                        Modifier
                            .align(Alignment.CenterVertically)
                        Modifier.align(Alignment.CenterVertically)
                            .height(TileDetailsDefaults.IconHeight)
                            .width(TileDetailsDefaults.IconWidth)
                            .padding(start = TileDetailsDefaults.IconPadding),
@@ -120,12 +121,9 @@ fun TileDetails(modifier: Modifier = Modifier, detailsViewModel: DetailsViewMode
                )
                IconButton(
                    onClick = { tileDetailedViewModel.clickOnSettingsButton() },
                    colors = IconButtonDefaults.iconButtonColors(
                        contentColor = colors.onSurface
                    ),
                    colors = IconButtonDefaults.iconButtonColors(contentColor = colors.onSurface),
                    modifier =
                        Modifier
                            .align(Alignment.CenterVertically)
                        Modifier.align(Alignment.CenterVertically)
                            .height(TileDetailsDefaults.IconHeight)
                            .width(TileDetailsDefaults.IconWidth)
                            .padding(end = TileDetailsDefaults.IconPadding),
@@ -145,9 +143,12 @@ fun TileDetails(modifier: Modifier = Modifier, detailsViewModel: DetailsViewMode
                color = colors.onSurfaceVariant,
            )
        }

        Column(modifier = Modifier.fillMaxWidth().verticalScroll(rememberScrollState())) {
            MapTileDetailsContent(tileDetailedViewModel)
        }
    }
}

@Composable
private fun MapTileDetailsContent(tileDetailsViewModel: TileDetailsViewModel) {
@@ -169,4 +170,6 @@ private object TileDetailsDefaults {
    val TitleRowTop = 22.dp
    val TitleRowEnd = 20.dp
    val TitleRowBottom = 8.dp
    val DetailsMaxHeight = 600.dp
    val DetailsMinHeight = 300.dp
}
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
package com.android.systemui.qs.tiles.dialog

import android.view.LayoutInflater
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
@@ -29,7 +29,7 @@ fun InternetDetailsContent(viewModel: InternetDetailsViewModel) {
    val coroutineScope = rememberCoroutineScope()

    AndroidView(
        modifier = Modifier.fillMaxSize(),
        modifier = Modifier.fillMaxWidth(),
        factory = { context ->
            // Inflate with the existing dialog xml layout and bind it with the manager
            val view =
+1 −2
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.qs.tiles.dialog

import android.view.LayoutInflater
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
@@ -35,7 +34,7 @@ fun ScreenRecordDetailsContent(viewModel: ScreenRecordDetailsViewModel) {
    }

    AndroidView(
        modifier = Modifier.fillMaxWidth().fillMaxHeight(),
        modifier = Modifier.fillMaxWidth(),
        factory = { context ->
            // Inflate with the existing dialog xml layout
            val view = LayoutInflater.from(context).inflate(R.layout.screen_share_dialog, null)