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

Commit 25daa65e authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Ice8f0efb,Ia2fa29f9 into main

* changes:
  Fix paddings and play/pause button size
  Update compose player fonts and guts colors
parents 7a0f4f24 52a23a08
Loading
Loading
Loading
Loading
+33 −25
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButtonDefaults
import androidx.compose.material3.MaterialTheme
@@ -121,6 +122,7 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.util.fastCoerceIn
import androidx.compose.ui.util.fastForEachIndexed
import androidx.compose.ui.util.fastRoundToInt
@@ -537,12 +539,10 @@ private fun ContentScope.CardForegroundContent(
                modifier =
                    Modifier.align(Alignment.TopEnd)
                        // Output switcher chip must be limited to at most 40% of the maximum
                        // width
                        // of the card.
                        // width of the card.
                        //
                        // This saves the maximum possible width of the card so it can be
                        // referred
                        // to by child custom layout code below.
                        // referred to by child custom layout code below.
                        //
                        // The assumption is that the row can be as wide as the entire card.
                        .layout { measurable, constraints ->
@@ -612,7 +612,7 @@ private fun ContentScope.CardForegroundContent(
            // Second row.
            Row(
                verticalAlignment = Alignment.CenterVertically,
                modifier = Modifier.padding(start = 16.dp, top = 16.dp, end = 16.dp),
                modifier = Modifier.padding(start = 16.dp, end = 16.dp),
            ) {
                Metadata(
                    title = viewModel.title,
@@ -621,19 +621,17 @@ private fun ContentScope.CardForegroundContent(
                    modifier = Modifier.weight(1f).padding(end = 8.dp),
                )

                val playPauseSize = DpSize(width = 48.dp, height = 48.dp)
                if (viewModel.actionButtonLayout == MediaCardActionButtonLayout.WithPlayPause) {
                    AnimatedVisibility(visible = viewModel.playPauseAction != null) {
                        PlayPauseAction(
                            viewModel = viewModel.playPauseAction,
                            buttonSize = playPauseSize,
                            buttonColor = colorScheme.primary,
                            iconColor = colorScheme.onPrimary,
                            buttonCornerRadius = { isPlaying -> if (isPlaying) 16.dp else 48.dp },
                        )
                    }
                } else {
                    Spacer(Modifier.size(playPauseSize))
                    Spacer(Modifier.size(width = 0.dp, height = 48.dp))
                }
            }

@@ -642,8 +640,7 @@ private fun ContentScope.CardForegroundContent(
                Row(
                    horizontalArrangement = Arrangement.spacedBy(8.dp),
                    verticalAlignment = Alignment.CenterVertically,
                    modifier =
                        Modifier.padding(start = 16.dp, top = 24.dp, end = 16.dp, bottom = 16.dp),
                    modifier = Modifier.padding(top = 8.dp, bottom = 8.dp),
                ) {
                    Navigation(
                        viewModel = viewModel.navigation,
@@ -669,7 +666,7 @@ private fun ContentScope.CardForegroundContent(
            // Bottom row.
            Row(
                verticalAlignment = Alignment.CenterVertically,
                modifier = Modifier.padding(start = 16.dp, top = 36.dp, end = 16.dp, bottom = 16.dp),
                modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 16.dp),
            ) {
                Metadata(
                    title = viewModel.title,
@@ -703,19 +700,17 @@ private fun ContentScope.CardForegroundContent(
                    }
                }

                val playPauseSize = DpSize(width = 48.dp, height = 48.dp)
                if (viewModel.actionButtonLayout == MediaCardActionButtonLayout.WithPlayPause) {
                    AnimatedVisibility(visible = viewModel.playPauseAction != null) {
                        PlayPauseAction(
                            viewModel = viewModel.playPauseAction,
                            buttonSize = playPauseSize,
                            buttonColor = colorScheme.primary,
                            iconColor = colorScheme.onPrimary,
                            buttonCornerRadius = { isPlaying -> if (isPlaying) 16.dp else 48.dp },
                        )
                    }
                } else {
                    Spacer(Modifier.size(playPauseSize))
                    Spacer(Modifier.size(width = 0.dp, height = 48.dp))
                }
            }
        }
@@ -777,7 +772,6 @@ private fun ContentScope.CompactCardForeground(
        AnimatedVisibility(visible = viewModel.playPauseAction != null) {
            PlayPauseAction(
                viewModel = viewModel.playPauseAction,
                buttonSize = DpSize(width = 72.dp, height = 48.dp),
                buttonColor = MaterialTheme.colorScheme.primaryContainer,
                iconColor = MaterialTheme.colorScheme.onPrimaryContainer,
                buttonCornerRadius = { isPlaying -> if (isPlaying) 16.dp else 24.dp },
@@ -1107,6 +1101,7 @@ private fun CardGuts(
                Modifier.align(Alignment.TopEnd).padding(top = 16.dp, end = 16.dp).clickable {
                    viewModel.settingsButton.onClick()
                },
            tint = Color.White,
        )

        //  Content.
@@ -1114,11 +1109,16 @@ private fun CardGuts(
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.spacedBy(16.dp),
            modifier =
                Modifier.align(Alignment.BottomCenter)
                Modifier.align(Alignment.Center)
                    .fillMaxWidth()
                    .padding(start = 16.dp, end = 32.dp, bottom = 40.dp),
                    .padding(start = 16.dp, end = 32.dp, top = 16.dp),
        ) {
            Text(text = viewModel.text, color = Color.White)
            Text(
                text = viewModel.text,
                color = Color.White,
                style = MaterialTheme.typography.labelMedium,
                fontSize = 14.sp,
            )

            Row(
                horizontalArrangement = Arrangement.spacedBy(8.dp),
@@ -1127,20 +1127,27 @@ private fun CardGuts(
                PlatformButton(
                    onClick = viewModel.primaryAction.onClick,
                    modifier = Modifier.sysuiResTag(MediaRes.HIDE_BTN),
                    colors = ButtonDefaults.buttonColors(containerColor = Color.White),
                    colors = ButtonDefaults.buttonColors(containerColor = colorScheme.primary),
                ) {
                    Text(
                        text = checkNotNull(viewModel.primaryAction.text),
                        color = colorScheme.onPrimary,
                        style = MaterialTheme.typography.labelMedium,
                        fontSize = 14.sp,
                    )
                }

                viewModel.secondaryAction?.let { button ->
                    PlatformOutlinedButton(
                        onClick = button.onClick,
                        border = BorderStroke(width = 1.dp, color = Color.White),
                        border = BorderStroke(width = 1.dp, color = colorScheme.primary),
                    ) {
                        Text(text = checkNotNull(button.text), color = Color.White)
                        Text(
                            text = checkNotNull(button.text),
                            color = Color.White,
                            style = MaterialTheme.typography.labelMedium,
                            fontSize = 14.sp,
                        )
                    }
                }
            }
@@ -1149,6 +1156,7 @@ private fun CardGuts(
}

/** Renders the metadata labels of a track. */
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Composable
private fun ContentScope.Metadata(
    title: String,
@@ -1165,7 +1173,7 @@ private fun ContentScope.Metadata(
                Text(
                    text = title,
                    modifier = Modifier.sysuiResTag(MediaRes.TITLE),
                    style = MaterialTheme.typography.bodyLarge,
                    style = MaterialTheme.typography.titleMediumEmphasized,
                    color = color,
                    maxLines = 1,
                    overflow = TextOverflow.Ellipsis,
@@ -1207,7 +1215,7 @@ private fun DeviceChip(
                color = Color.Transparent,
                shape = RoundedCornerShape(12.dp),
            ),
        modifier = modifier.padding(top = 16.dp, bottom = 8.dp),
        modifier = modifier.padding(top = 16.dp, bottom = 0.dp),
        useModifierBasedImplementation = true,
    ) {
        Box(
@@ -1251,7 +1259,7 @@ private fun DeviceChip(
                    rememberLastNonNull(viewModel.text)?.let {
                        Text(
                            text = it,
                            style = MaterialTheme.typography.bodySmall,
                            style = MaterialTheme.typography.labelMedium,
                            color = style.contentColor,
                            maxLines = 1,
                            overflow = TextOverflow.Ellipsis,
@@ -1268,7 +1276,6 @@ private fun DeviceChip(
@Composable
private fun ContentScope.PlayPauseAction(
    viewModel: MediaPlayPauseActionViewModel?,
    buttonSize: DpSize,
    buttonColor: Color,
    iconColor: Color,
    buttonCornerRadius: (isPlaying: Boolean) -> Dp,
@@ -1276,6 +1283,7 @@ private fun ContentScope.PlayPauseAction(
) {
    if (viewModel == null) return

    val buttonSize = DpSize(width = 72.dp, height = 48.dp)
    val cornerRadius: Dp by
        animateDpAsState(
            targetValue = buttonCornerRadius(viewModel.state != MediaSessionState.Paused),