From 095141ad075a18628c27531f8c1b0119bae99cb7 Mon Sep 17 00:00:00 2001 From: Jim Havrilla <6568964+jimhavrilla@users.noreply.github.com> Date: Mon, 16 Nov 2026 20:30:18 -0500 Subject: [PATCH] Show cable and wireless as a list ordered by priority Each link gets a number, an arrow to move it, and its own switch, in place of a separate Try first row. Co-Authored-By: Claude Opus 5.5 --- .../gearslip/ui/SettingsScreen.kt | 84 +++++++++++-------- gearslip/src/main/res/values/strings.xml | 14 ++-- 2 files changed, 57 insertions(+), 41 deletions(-) diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/ui/SettingsScreen.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/ui/SettingsScreen.kt index 04be6ea..d5887d3 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/ui/SettingsScreen.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/ui/SettingsScreen.kt @@ -281,8 +281,8 @@ private fun ConnectionSection() { } /** - * Cable and wireless, each switchable on its own, and which one Gearslip tries first when the - * car offers both. Wireless auto-connect off keeps Gearslip from fighting the car's Bluetooth. + * Cable and wireless as a short list in the order Gearslip tries them: arrows move a link up or + * down, and each has its own switch. Wireless off keeps Gearslip from fighting the car's Bluetooth. */ @Composable private fun ConnectionOrderRows() { @@ -290,44 +290,62 @@ private fun ConnectionOrderRows() { var cable by remember { mutableStateOf(AppSettings.cableEnabled(context)) } var wireless by remember { mutableStateOf(AppSettings.wirelessAutoConnect(context)) } var order by remember { mutableStateOf(AppSettings.connectionOrder(context)) } - SettingsRow( - stringResource(R.string.settings_cable), - Modifier.toggleable(cable, role = Role.Switch) { - cable = it - AppSettings.setCableEnabled(context, it) - }, - subtitle = stringResource(if (cable) R.string.settings_cable_on else R.string.settings_cable_off), - icon = Icons.Filled.Settings, - trailing = { Switch(checked = cable, onCheckedChange = null) }, + val links = if (order == AppSettings.ConnectionOrder.CABLE_FIRST) listOf(true, false) else listOf(false, true) + fun swap() { + order = if (order == AppSettings.ConnectionOrder.CABLE_FIRST) AppSettings.ConnectionOrder.WIRELESS_FIRST + else AppSettings.ConnectionOrder.CABLE_FIRST + AppSettings.setConnectionOrder(context, order) + } + Text( + stringResource(R.string.settings_order_hint), + style = MaterialTheme.typography.bodyMedium, + color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = 12.dp, bottom = 4.dp), ) - SettingsRow( - stringResource(R.string.settings_wireless_auto), - Modifier.toggleable(wireless, role = Role.Switch) { - wireless = it - AppSettings.setWirelessAutoConnect(context, it) - }, - subtitle = stringResource(if (wireless) R.string.settings_wireless_auto_on else R.string.settings_wireless_auto_off), - icon = Icons.Filled.Refresh, - trailing = { Switch(checked = wireless, onCheckedChange = null) }, - ) - // An order only matters when both can start. - if (cable && wireless) { - val cableFirst = order == AppSettings.ConnectionOrder.CABLE_FIRST + links.forEachIndexed { index, isCable -> + val on = if (isCable) cable else wireless SettingsRow( - stringResource(R.string.settings_order), - Modifier.clickable { - order = if (cableFirst) AppSettings.ConnectionOrder.WIRELESS_FIRST else AppSettings.ConnectionOrder.CABLE_FIRST - AppSettings.setConnectionOrder(context, order) + stringResource(if (isCable) R.string.settings_cable else R.string.settings_wireless_auto), + Modifier.toggleable(on, role = Role.Switch) { + if (isCable) { + cable = it + AppSettings.setCableEnabled(context, it) + } else { + wireless = it + AppSettings.setWirelessAutoConnect(context, it) + } }, - subtitle = stringResource(if (cableFirst) R.string.settings_order_cable else R.string.settings_order_wireless), - icon = Icons.Filled.KeyboardArrowUp, - trailing = { + subtitle = stringResource( + when { + isCable && on -> R.string.settings_cable_on + isCable -> R.string.settings_cable_off + on -> R.string.settings_wireless_auto_on + else -> R.string.settings_wireless_auto_off + }, + ), + leading = { Text( - stringResource(if (cableFirst) R.string.settings_order_cable_short else R.string.settings_order_wireless_short), - color = MaterialTheme.colorScheme.primary, + "${index + 1}", + style = MaterialTheme.typography.titleLarge, fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold, + color = if (on) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant, ) }, + trailing = { + androidx.compose.foundation.layout.Row(verticalAlignment = androidx.compose.ui.Alignment.CenterVertically) { + // With two links, moving either one swaps them. + if (index > 0) { + IconButton(onClick = ::swap) { + Icon(Icons.Filled.KeyboardArrowUp, contentDescription = stringResource(R.string.settings_order_up)) + } + } else { + IconButton(onClick = ::swap) { + Icon(Icons.Filled.KeyboardArrowDown, contentDescription = stringResource(R.string.settings_order_down)) + } + } + Switch(checked = on, onCheckedChange = null) + } + }, ) } } diff --git a/gearslip/src/main/res/values/strings.xml b/gearslip/src/main/res/values/strings.xml index a4470f3..bdb7f4b 100644 --- a/gearslip/src/main/res/values/strings.xml +++ b/gearslip/src/main/res/values/strings.xml @@ -424,16 +424,14 @@ No car on the cable Plug the phone into the car\'s USB port with a data cable, then try again. Connect over cable - Gearslip answers the car\'s USB connection + When the phone is plugged into the car Off: the cable only charges, or Android Auto takes it - Connect wirelessly on its own - Starts when a car you\'ve connected to comes up on Bluetooth + Connect wirelessly + On its own, when a car you\'ve used comes up on Bluetooth Off: the car\'s Bluetooth is left alone until you tap Connect wirelessly - Try first - Cable. Gearslip waits a few seconds for one before going wireless. - Wireless. A cable plugged in later doesn\'t take over, but steps in if wireless fails. - Cable - Wireless + Gearslip tries these in order. Use the arrows to choose which comes first. + Move up + Move down Voice: live words