From 56dafa8fc3f38d855ed5642f75d3652e053a1f46 Mon Sep 17 00:00:00 2001 From: Hawk <28853569+WebF1yin@users.noreply.github.com> Date: Sun, 22 Nov 2026 22:42:55 -0800 Subject: [PATCH 1/2] On a short car screen, the player beside the map shows the cover behind its controls The car UI now knows when the car's screen is short: under 420 dp tall inside its margins, as a single-DIN unit's is (369 dp on a SOOEMAKA). Most head units' screens are 480 dp or more, and nothing changes on them. The player beside the map put the cover above the title, seek bar and transport, so on a short screen the cover had room for a sliver. There, the cover now fills the card, darkened toward the bottom, with the controls over it in light colours. Tapping it opens the media screen, as before. Co-Authored-By: Claude Opus 5.5 --- .../gearslip/car/CarHomeScreen.kt | 76 ++++++++++++++++++- .../app/seb3thehacker/gearslip/car/CarUi.kt | 14 +++- 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarHomeScreen.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarHomeScreen.kt index b60ee0d..899ba57 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarHomeScreen.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarHomeScreen.kt @@ -132,7 +132,11 @@ fun CarHome() { top = CARD_GAP, bottom = LocalNavBarInset.current + CARD_GAP, ) - if (shown.value == SidePanel.LYRICS) SideLyrics(now, card) else DockedPlayer(now, card) + when { + shown.value == SidePanel.LYRICS -> SideLyrics(now, card) + LocalShortScreen.current -> CoverPlayer(now, card) + else -> DockedPlayer(now, card) + } } } } @@ -291,6 +295,76 @@ private fun DockedPlayer(now: NowPlaying, modifier: Modifier) { } } +/** + * The player beside the map on a short screen, where a cover above the controls had room for only + * a sliver: the cover fills the card, darkened toward the bottom, with the title, seek bar and + * transport over it. Tapping the cover opens the full media screen, as on the tall player. + */ +@Composable +private fun CoverPlayer(now: NowPlaying, modifier: Modifier, shape: androidx.compose.ui.graphics.Shape = CARD_SHAPE) { + val navigator = LocalCarNavigator.current + val media = CarServices.media + val art = rememberArt(now) + val scheme = MaterialTheme.colorScheme + // Light text and buttons over the darkened cover, whatever the theme; the theme's own without one. + val over = when { + art == null || scheme.surface.luminance() < 0.5f -> scheme + else -> androidx.compose.material3.dynamicDarkColorScheme(LocalContext.current) + } + Surface(modifier = modifier.gsPanelShadow(shape), shape = shape, color = scheme.surfaceContainer) { + Box(Modifier.fillMaxSize().clickable { navigator.media() }) { + // A new song's cover fades in over the old one instead of cutting to it. + androidx.compose.animation.Crossfade(art, animationSpec = tween(350), label = "cover") { shown -> + if (shown != null) { + Box(Modifier.fillMaxSize()) { + Image(shown.asImageBitmap(), null, Modifier.fillMaxSize(), contentScale = ContentScale.Crop) + Box( + Modifier.fillMaxSize().background( + androidx.compose.ui.graphics.Brush.verticalGradient( + 0f to Color.Black.copy(alpha = 0.2f), + 0.4f to Color.Black.copy(alpha = 0.45f), + 1f to Color.Black.copy(alpha = 0.78f), + ), + ), + ) + } + } else { + AlbumGlow(null, Modifier.fillMaxSize()) + } + } + MaterialTheme(colorScheme = over) { + Column( + Modifier.fillMaxSize().padding(12.dp), + verticalArrangement = Arrangement.Bottom, + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Text( + now.title, style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold, + color = over.onSurface, maxLines = 1, overflow = TextOverflow.Ellipsis, + ) + Text( + now.artist, style = MaterialTheme.typography.bodyMedium, color = over.onSurfaceVariant, + maxLines = 1, overflow = TextOverflow.Ellipsis, + ) + if (now.durationMs > 0) { + PlayerProgress( + now, media, Modifier.fillMaxWidth().padding(vertical = 2.dp), + timeStyle = MaterialTheme.typography.labelLarge, + ) + } else { + Spacer(Modifier.height(10.dp)) + } + BoxWithConstraints(Modifier.fillMaxWidth()) { + // As on the tall player: two skips, play at 1.25 times a skip, and two gaps. + val skip = ((maxWidth - 40.dp) / 3.25f).coerceIn(36.dp, 48.dp) + TransportRow(now, media, skip = skip, modifier = Modifier.fillMaxWidth()) + } + } + } + } + } +} + /** * Lyrics alone beside the map, big enough to read at a glance. The header is slim, since the * player goes back to the nav bar meanwhile and names the song there. Its note button swaps the diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarUi.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarUi.kt index aeb9f80..c599301 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarUi.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarUi.kt @@ -262,7 +262,8 @@ fun CarUi() { val homeInset = if (barShown) NAV_BAR_HEIGHT else 0.dp // Only the screen that asked: going Home or anywhere else ends it. val fullscreen = CarFullscreen.active && screen != CarScreen.Home - Box(Modifier.fillMaxSize().padding(pad)) { + BoxWithConstraints(Modifier.fillMaxSize().padding(pad)) { + CompositionLocalProvider(LocalShortScreen provides (maxHeight < SHORT_SCREEN_HEIGHT)) { Column(Modifier.fillMaxSize()) { if (!safetyWarningSeen) { CarSafetyWizard(onDone = CarSettings::markSafetyWarningSeen) @@ -389,6 +390,7 @@ fun CarUi() { AppMenu(navigator, rememberRunningApps()) if (safetyWarningSeen) CarWhatsNew() } + } } } } @@ -397,6 +399,16 @@ fun CarUi() { internal val NAV_BAR_HEIGHT = 56.dp +/** + * Whether the car's screen is short: under [SHORT_SCREEN_HEIGHT] tall inside the car's margins, as a + * single-DIN unit's is. Screens laid out for the usual height switch to a compact layout of their + * own on it; on any taller screen nothing changes. + */ +internal val LocalShortScreen = androidx.compose.runtime.compositionLocalOf { false } + +/** A SOOEMAKA single-DIN unit's screen is 369 dp tall; most head units' are 480 dp or more. */ +internal val SHORT_SCREEN_HEIGHT = 420.dp + /** * How much of the bottom of Home the floating nav bar covers right now: its height while it shows, * zero while it's hidden or when it has a row of its own. From 49f5db59a7109ca91c0e76b8fcdf6213f114643e Mon Sep 17 00:00:00 2001 From: Hawk <28853569+WebF1yin@users.noreply.github.com> Date: Sun, 22 Nov 2026 22:45:10 -0800 Subject: [PATCH 2/2] On a short car screen, the media screen fits its tabs to the height: controls beside the cover, a grid to browse, and slimmer queue rows On a SOOEMAKA's 369 dp screen the Now playing tab had no room for the cover, the browse list showed three rows, and Up next showed under three. On a short screen (see LocalShortScreen), every tab now takes the screen's width rather than its height: - Now playing: the title, seek bar and buttons on the left, with the transport and like, shuffle and repeat in one row, and the cover as tall as the page on the right. - Browse: every entry is a button with a small cover, as many across as fit, under the app's headings. In a folder, the way back up and the folder's name sit in the screen's header instead of a row of their own. - Up next: slimmer rows, so four or five show. Taller screens keep their layouts. Co-Authored-By: Claude Opus 5.5 --- .../seb3thehacker/gearslip/car/MediaBrowse.kt | 120 ++++++++++++++---- .../seb3thehacker/gearslip/car/MediaScreen.kt | 54 +++++++- 2 files changed, 145 insertions(+), 29 deletions(-) diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/MediaBrowse.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/MediaBrowse.kt index 4878c30..2047e93 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/MediaBrowse.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/MediaBrowse.kt @@ -85,20 +85,9 @@ internal fun BrowsePanel(browse: app.seb3thehacker.gearslip.media.BrowseState, m // At the library root there's no trail and nowhere to go up to, so there's nothing this // row could say that the app's name in the top-left corner hasn't already - showing it // again here (as "Browse", or as the app's own name) was just the same label twice. - if (media.canGoUp || browse.trail.isNotEmpty()) { - Row(Modifier.padding(bottom = 12.dp), verticalAlignment = Alignment.CenterVertically) { - if (media.canGoUp) { - GsIconButton(Icons.Filled.ArrowBack, stringResource(R.string.media_up), media::up, size = 44.dp, shape = CircleShape) - Spacer(Modifier.width(14.dp)) - } - browse.trail.lastOrNull()?.let { - Text( - it, - style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.Bold, - maxLines = 1, overflow = TextOverflow.Ellipsis, - ) - } - } + // A short screen has it in the media screen's own header instead. + if (!LocalShortScreen.current && (media.canGoUp || browse.trail.isNotEmpty())) { + BrowseUp(browse, media, Modifier.padding(bottom = 12.dp)) } when { browse.loading -> Notice(stringResource(R.string.media_loading), null) @@ -113,6 +102,24 @@ internal fun BrowsePanel(browse: app.seb3thehacker.gearslip.media.BrowseState, m } } +/** The way back up out of a folder, and the folder's name. */ +@Composable +internal fun BrowseUp(browse: app.seb3thehacker.gearslip.media.BrowseState, media: CarMedia, modifier: Modifier = Modifier) { + Row(modifier, verticalAlignment = Alignment.CenterVertically) { + if (media.canGoUp) { + GsIconButton(Icons.Filled.ArrowBack, stringResource(R.string.media_up), media::up, size = 44.dp, shape = CircleShape) + Spacer(Modifier.width(14.dp)) + } + browse.trail.lastOrNull()?.let { + Text( + it, + style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.Bold, + maxLines = 1, overflow = TextOverflow.Ellipsis, + ) + } + } +} + /** * A list laid out the way the app asked: under its section headings, covers where it asked for a * grid and rows everywhere else. A grid section among others is a shelf that scrolls sideways; a @@ -123,6 +130,10 @@ private fun BrowseList(entries: List, media: CarMedia) { // A list's keys must be unique, and some apps list the same item twice (Music Assistant's // playlists, issue #90): the repeat would do the same thing anyway, so it's dropped. val sections = remember(entries) { browseSections(entries.distinctBy { it.id }) } + if (LocalShortScreen.current) { + BrowseGrid(sections, media) + return + } BoxWithConstraints(Modifier.fillMaxSize()) { val onlyGrid = sections.size == 1 && sections[0].grid && sections[0].heading == null val columns = ((maxWidth + SHELF_GAP) / (SHELF_COVER + SHELF_GAP)).toInt().coerceAtLeast(2) @@ -162,6 +173,67 @@ private fun BrowseList(entries: List, media: CarMedia) { } } +/** + * The browse list for a short screen, where a list showed three rows and a shelf of covers one: + * every entry is a button with a small cover, as many across as fit, under the app's headings. + */ +@Composable +private fun BrowseGrid(sections: List, media: CarMedia) { + androidx.compose.foundation.lazy.grid.LazyVerticalGrid( + columns = androidx.compose.foundation.lazy.grid.GridCells.Adaptive(GRID_BUTTON_WIDTH), + modifier = Modifier.fillMaxSize(), + contentPadding = PaddingValues(bottom = 8.dp), + horizontalArrangement = Arrangement.spacedBy(8.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), + ) { + sections.forEachIndexed { i, section -> + val heading = section.heading + if (heading != null && sections.getOrNull(i - 1)?.heading != heading) { + item(key = "heading $i", span = { androidx.compose.foundation.lazy.grid.GridItemSpan(maxLineSpan) }) { + Text( + heading, + style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold, + maxLines = 1, overflow = TextOverflow.Ellipsis, + modifier = Modifier.padding(top = if (i == 0) 0.dp else 4.dp), + ) + } + } + items(section.entries.size, key = { section.entries[it].id }) { EntryButton(section.entries[it], media) } + } + } +} + +/** One entry as a button in [BrowseGrid]: its cover, its name, and play for a folder that plays. */ +@Composable +private fun EntryButton(entry: MediaEntry, media: CarMedia) { + val context = LocalContext.current + val icon by produceState(entry.iconBitmap, entry.iconUri) { + value = entry.iconBitmap ?: MediaArt.load(context, entry.iconUri) + } + Surface( + onClick = { media.select(entry) }, + shape = MaterialTheme.shapes.large, + color = MaterialTheme.colorScheme.surfaceContainer, + modifier = Modifier.fillMaxWidth(), + ) { + Row(Modifier.padding(6.dp), verticalAlignment = Alignment.CenterVertically) { + RowArt(icon, if (entry.browsable) MediaIcons.Folder else MediaIcons.MusicNote, size = 44.dp) + Column(Modifier.weight(1f).padding(horizontal = 10.dp)) { + Text(entry.title, style = MaterialTheme.typography.titleSmall, maxLines = 1, overflow = TextOverflow.Ellipsis) + if (entry.subtitle.isNotEmpty()) { + Text(entry.subtitle, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis) + } + } + if (entry.browsable && entry.playable) { + GsIconButton(Icons.Filled.PlayArrow, stringResource(R.string.media_play), { media.playAll(entry) }, size = 40.dp) + } + } + } +} + +/** The narrowest a button in [BrowseGrid] gets before it gives up a column. */ +private val GRID_BUTTON_WIDTH = 220.dp + private val SHELF_COVER = 132.dp private val SHELF_GAP = 14.dp @@ -243,7 +315,7 @@ internal fun QueuePanel(queue: List, now: NowPlaying, media: CarMedi LazyColumn( Modifier.fillMaxSize(), contentPadding = PaddingValues(bottom = 8.dp), - verticalArrangement = Arrangement.spacedBy(8.dp), + verticalArrangement = Arrangement.spacedBy(if (LocalShortScreen.current) 4.dp else 8.dp), ) { items(upNext.distinctBy { it.queueId }, key = { it.queueId }) { track -> QueueRow(track, media) } } @@ -257,18 +329,20 @@ private fun QueueRow(track: QueueTrack, media: CarMedia) { val icon by produceState(track.iconBitmap, track.iconUri) { value = track.iconBitmap ?: MediaArt.load(context, track.iconUri) } + // A short screen showed two and a half rows; slimmer ones show four or five. + val short = LocalShortScreen.current Surface( onClick = { media.playQueueItem(track) }, shape = MaterialTheme.shapes.large, color = MaterialTheme.colorScheme.surfaceContainer, modifier = Modifier.fillMaxWidth(), ) { - Row(Modifier.padding(8.dp), verticalAlignment = Alignment.CenterVertically) { - RowArt(icon, MediaIcons.MusicNote) - Column(Modifier.weight(1f).padding(horizontal = 14.dp)) { - Text(track.title, style = MaterialTheme.typography.titleMedium, maxLines = 1, overflow = TextOverflow.Ellipsis) + Row(Modifier.padding(if (short) 4.dp else 8.dp), verticalAlignment = Alignment.CenterVertically) { + RowArt(icon, MediaIcons.MusicNote, size = if (short) 40.dp else 56.dp) + Column(Modifier.weight(1f).padding(horizontal = if (short) 10.dp else 14.dp)) { + Text(track.title, style = if (short) MaterialTheme.typography.titleSmall else MaterialTheme.typography.titleMedium, maxLines = 1, overflow = TextOverflow.Ellipsis) if (track.subtitle.isNotEmpty()) { - Text(track.subtitle, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis) + Text(track.subtitle, style = if (short) MaterialTheme.typography.bodySmall else MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis) } } Icon(Icons.Filled.PlayArrow, stringResource(R.string.media_play), tint = MaterialTheme.colorScheme.onSurfaceVariant) @@ -306,13 +380,13 @@ internal fun EntryRow(entry: MediaEntry, media: CarMedia, onClick: () -> Unit = /** A row's artwork, or a folder or note in its place when the app sends none. */ @Composable -private fun RowArt(icon: android.graphics.Bitmap?, fallback: ImageVector) { +private fun RowArt(icon: android.graphics.Bitmap?, fallback: ImageVector, size: androidx.compose.ui.unit.Dp = 56.dp) { Box( - Modifier.size(56.dp).clip(RoundedCornerShape(12.dp)).background(MaterialTheme.colorScheme.surfaceContainerHigh), + Modifier.size(size).clip(RoundedCornerShape(size * 12 / 56)).background(MaterialTheme.colorScheme.surfaceContainerHigh), contentAlignment = Alignment.Center, ) { if (icon != null) Image(icon.asImageBitmap(), null, Modifier.fillMaxSize(), contentScale = ContentScale.Crop) - else Icon(fallback, null, tint = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.size(30.dp)) + else Icon(fallback, null, tint = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.size(size * 30 / 56)) } } diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/MediaScreen.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/MediaScreen.kt index ae6610f..42f1585 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/MediaScreen.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/MediaScreen.kt @@ -199,17 +199,23 @@ fun MediaScreen(app: MediaApp, onExit: () -> Unit) { } BoxWithConstraints(Modifier.fillMaxSize().padding(start = 16.dp, end = 16.dp, top = 10.dp)) { - // A small screen, or a big one at Extra large size, has no room for two columns: the - // app and the tabs share one bar, and a list takes the whole width. The nav bar keeps - // the controls, so nothing is lost. - if (maxWidth < NARROW_WIDTH || maxHeight - barInset < NARROW_HEIGHT) { + // A small or short screen, or a big one at Extra large size, has no room for two + // columns: the app and the tabs share one bar, and a list takes the whole width. The + // nav bar keeps the controls, so nothing is lost. + if (LocalShortScreen.current || maxWidth < NARROW_WIDTH || maxHeight - barInset < NARROW_HEIGHT) { Column(Modifier.fillMaxSize(), verticalArrangement = Arrangement.spacedBy(8.dp)) { Row( Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(12.dp), verticalAlignment = Alignment.CenterVertically, ) { - AppIdentity(app, onExit, Modifier.widthIn(max = 180.dp)) + // On a short screen, a folder's way back up takes the app's place here + // rather than a row of its own over the list. + if (LocalShortScreen.current && tab == Tab.BROWSE && (media.canGoUp || browse.trail.isNotEmpty())) { + BrowseUp(browse, media, Modifier.widthIn(max = 280.dp)) + } else { + AppIdentity(app, onExit, Modifier.widthIn(max = 180.dp)) + } Row( Modifier.weight(1f).horizontalScroll(rememberScrollState()), horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.End), @@ -644,7 +650,14 @@ internal fun Notice(title: String, detail: String?, action: Pair U internal fun NowPlayingPage(now: NowPlaying, media: CarMedia, modifier: Modifier, padded: Boolean = true) { BoxWithConstraints(if (padded) modifier.padding(horizontal = 24.dp, vertical = 8.dp) else modifier) { val art = rememberArt(now) - if (maxWidth >= 520.dp && maxHeight >= 260.dp) { + if (LocalShortScreen.current) { + // A short screen: the controls on the driver's side, the cover as tall as the page beside them. + val cover = minOf(maxHeight, maxWidth * 0.4f) + Row(Modifier.fillMaxSize(), horizontalArrangement = Arrangement.spacedBy(20.dp)) { + ShortControls(now, media, Modifier.weight(1f).fillMaxHeight()) + CoverArt(art, Modifier.width(cover).fillMaxHeight()) + } + } else if (maxWidth >= 520.dp && maxHeight >= 260.dp) { val artWidth = minOf(maxHeight, (maxWidth - 24.dp) * 0.4f) Row(Modifier.fillMaxSize(), horizontalArrangement = Arrangement.spacedBy(24.dp)) { CoverArt(art, Modifier.width(artWidth).fillMaxHeight()) @@ -777,6 +790,35 @@ private fun NowPlayingControls(now: NowPlaying, media: CarMedia, modifier: Modif } } +/** + * [NowPlayingControls] for a short screen, which has width to spare but little height: the title + * and seek bar, then the transport and like, shuffle and repeat side by side in one row. + */ +@Composable +private fun ShortControls(now: NowPlaying, media: CarMedia, modifier: Modifier) { + Column(modifier, verticalArrangement = Arrangement.spacedBy(6.dp, Alignment.CenterVertically)) { + // The title gives up its height first and scrolls, so the controls never leave the screen. + Column(Modifier.weight(1f, fill = false).verticalScroll(rememberScrollState())) { + Text( + now.title.ifEmpty { stringResource(R.string.media_nothing_playing) }, + style = MaterialTheme.typography.headlineSmall, fontWeight = FontWeight.Bold, + maxLines = 2, overflow = TextOverflow.Ellipsis, + ) + Text( + listOf(now.artist, now.album).filter { it.isNotEmpty() }.joinToString(" ยท "), + style = MaterialTheme.typography.titleMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, + maxLines = 1, overflow = TextOverflow.Ellipsis, + ) + now.error?.let { Text(it, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.error, maxLines = 2) } + } + PlayerProgress(now, media, Modifier.fillMaxWidth(), timeStyle = MaterialTheme.typography.titleMedium) + Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) { + TransportRow(now, media, skip = 48.dp, modifier = Modifier.weight(1f)) + PlayModeRow(now, media, size = 44.dp, modifier = Modifier.weight(1f), maxOther = 2) + } + } +} + /** Below these, the media app drops to one column: see [MediaScreen]. */ private val NARROW_WIDTH = 600.dp private val NARROW_HEIGHT = 300.dp