From 8e4bade2b448b7c4be324a6e9cb79d18a056323d Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Mon, 5 Oct 2026 00:52:43 -0400 Subject: [PATCH] Desktop page: fit the desktop card and the emulator tiles on a small phone On a 640dp-wide screen the Japanese "Install & open desktop" button left the card's title a character a line, and three tiles a row left the emulators' names as an ellipsis in every language. The button now goes under the title when the card is under 640dp, and the grid shows two tiles a row under 720dp. --- .../droiddeck/launcher/ui/FrontEndContent.kt | 73 +++++++++++-------- 1 file changed, 44 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt index 9454a7c2a..26751674e 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndContent.kt @@ -419,7 +419,6 @@ private fun Content( private fun DesktopCard(s: FrontEndState, a: FrontEndActions) { val colors = MaterialTheme.colorScheme val pal = LocalPalette.current - val narrow = LocalNarrowPane.current val actions: @Composable () -> Unit = { Actions { // Enabled without a runtime or the desktop: the session's loading screen installs them first. @@ -428,25 +427,33 @@ private fun DesktopCard(s: FrontEndState, a: FrontEndActions) { BusyChip(s) } } - Column( - verticalArrangement = Arrangement.spacedBy(14.dp), - modifier = Modifier.fillMaxWidth().clip(Shape16).background(colors.surface).border(1.dp, pal.line, Shape16).padding(16.dp), - ) { - Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(14.dp)) { - Box( - contentAlignment = Alignment.Center, - modifier = Modifier.size(52.dp).clip(Shape14).background(colors.surfaceVariant).border(1.dp, pal.line2, Shape14), - ) { Icon(Icons.Outlined.DesktopWindows, contentDescription = null, tint = colors.onBackground, modifier = Modifier.size(26.dp)) } - Column(modifier = Modifier.weight(1f)) { - Text(stringResource(R.string.content_linux_desktop), fontSize = 18.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground) - Text(stringResource(R.string.content_linux_desktop_hint), fontSize = 14.sp, color = colors.onSurfaceVariant, maxLines = 2, overflow = TextOverflow.Ellipsis) + // The button goes under the title unless the card is wide enough for both side by side: in some + // languages its label alone takes half a small phone's pane. + BoxWithConstraints(Modifier.fillMaxWidth()) { + val narrow = LocalNarrowPane.current || maxWidth < DesktopCardInlineWidth + Column( + verticalArrangement = Arrangement.spacedBy(14.dp), + modifier = Modifier.fillMaxWidth().clip(Shape16).background(colors.surface).border(1.dp, pal.line, Shape16).padding(16.dp), + ) { + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(14.dp)) { + Box( + contentAlignment = Alignment.Center, + modifier = Modifier.size(52.dp).clip(Shape14).background(colors.surfaceVariant).border(1.dp, pal.line2, Shape14), + ) { Icon(Icons.Outlined.DesktopWindows, contentDescription = null, tint = colors.onBackground, modifier = Modifier.size(26.dp)) } + Column(modifier = Modifier.weight(1f)) { + Text(stringResource(R.string.content_linux_desktop), fontSize = 18.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground) + Text(stringResource(R.string.content_linux_desktop_hint), fontSize = 14.sp, color = colors.onSurfaceVariant, maxLines = 2, overflow = TextOverflow.Ellipsis) + } + if (!narrow) actions() } - if (!narrow) actions() + if (narrow) actions() } - if (narrow) actions() } } +/** How wide the desktop card must be to keep its button beside the title. */ +private val DesktopCardInlineWidth = 640.dp + /** What the Desktop page's grids hold: emulators, the user's own apps, and Add at the end. */ private sealed class GridItem(val key: String) { class Emu(val e: Library.Emulator) : GridItem("emu:${e.id}") @@ -454,25 +461,33 @@ private sealed class GridItem(val key: String) { data object Add : GridItem("add") } -/** Wide tiles - three across, or a list on a narrow page. */ +/** Wide tiles - three across, two on a small phone, or a list on a narrow page. */ @Composable private fun LauncherGrid(items: List, first: Boolean, onSelect: (String) -> Unit, onAdd: () -> Unit = {}) { - val columns = if (LocalNarrowPane.current) 1 else 3 - Column(verticalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().padding(top = 4.dp, bottom = 8.dp)) { - items.chunked(columns).forEachIndexed { r, row -> - Row(horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().height(IntrinsicSize.Min)) { - row.forEachIndexed { i, item -> - key(item.key) { - val m = Modifier.weight(1f).fillMaxHeight() - val isFirst = first && r == 0 && i == 0 - when (item) { - is GridItem.Emu -> EmulatorTile(item.e, m, isFirst) { onSelect(item.key) } - is GridItem.User -> UserAppTile(item.app, m, isFirst) { onSelect(item.key) } - GridItem.Add -> AddTile(m, isFirst, onAdd) + BoxWithConstraints(Modifier.fillMaxWidth()) { + // A tile holds an icon, a name and an Install button: one much under 230dp wide leaves the + // name no room at all. + val columns = when { + LocalNarrowPane.current -> 1 + maxWidth < 720.dp -> 2 + else -> 3 + } + Column(verticalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().padding(top = 4.dp, bottom = 8.dp)) { + items.chunked(columns).forEachIndexed { r, row -> + Row(horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().height(IntrinsicSize.Min)) { + row.forEachIndexed { i, item -> + key(item.key) { + val m = Modifier.weight(1f).fillMaxHeight() + val isFirst = first && r == 0 && i == 0 + when (item) { + is GridItem.Emu -> EmulatorTile(item.e, m, isFirst) { onSelect(item.key) } + is GridItem.User -> UserAppTile(item.app, m, isFirst) { onSelect(item.key) } + GridItem.Add -> AddTile(m, isFirst, onAdd) + } } } + repeat(columns - row.size) { Spacer(Modifier.weight(1f)) } } - repeat(columns - row.size) { Spacer(Modifier.weight(1f)) } } } }