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 <noreply@anthropic.com>
This commit is contained in:
Jim HavrillaandClaude Opus 5.5 committed 2026-11-16 20:30:18 -05:00
1 parent 962c083fe6
commit 095141ad07
2 files changed
+53 -37

No files matched your search

@@ -281,8 +281,8 @@ private fun ConnectionSection() {
} }
/** /**
* Cable and wireless, each switchable on its own, and which one Gearslip tries first when the * Cable and wireless as a short list in the order Gearslip tries them: arrows move a link up or
* car offers both. Wireless auto-connect off keeps Gearslip from fighting the car's Bluetooth. * down, and each has its own switch. Wireless off keeps Gearslip from fighting the car's Bluetooth.
*/ */
@Composable @Composable
private fun ConnectionOrderRows() { private fun ConnectionOrderRows() {
@@ -290,44 +290,62 @@ private fun ConnectionOrderRows() {
var cable by remember { mutableStateOf(AppSettings.cableEnabled(context)) } var cable by remember { mutableStateOf(AppSettings.cableEnabled(context)) }
var wireless by remember { mutableStateOf(AppSettings.wirelessAutoConnect(context)) } var wireless by remember { mutableStateOf(AppSettings.wirelessAutoConnect(context)) }
var order by remember { mutableStateOf(AppSettings.connectionOrder(context)) } var order by remember { mutableStateOf(AppSettings.connectionOrder(context)) }
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),
)
links.forEachIndexed { index, isCable ->
val on = if (isCable) cable else wireless
SettingsRow( SettingsRow(
stringResource(R.string.settings_cable), stringResource(if (isCable) R.string.settings_cable else R.string.settings_wireless_auto),
Modifier.toggleable(cable, role = Role.Switch) { Modifier.toggleable(on, role = Role.Switch) {
if (isCable) {
cable = it cable = it
AppSettings.setCableEnabled(context, it) AppSettings.setCableEnabled(context, it)
}, } else {
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) },
)
SettingsRow(
stringResource(R.string.settings_wireless_auto),
Modifier.toggleable(wireless, role = Role.Switch) {
wireless = it wireless = it
AppSettings.setWirelessAutoConnect(context, it) AppSettings.setWirelessAutoConnect(context, it)
}
}, },
subtitle = stringResource(if (wireless) R.string.settings_wireless_auto_on else R.string.settings_wireless_auto_off), subtitle = stringResource(
icon = Icons.Filled.Refresh, when {
trailing = { Switch(checked = wireless, onCheckedChange = null) }, isCable && on -> R.string.settings_cable_on
) isCable -> R.string.settings_cable_off
// An order only matters when both can start. on -> R.string.settings_wireless_auto_on
if (cable && wireless) { else -> R.string.settings_wireless_auto_off
val cableFirst = order == AppSettings.ConnectionOrder.CABLE_FIRST
SettingsRow(
stringResource(R.string.settings_order),
Modifier.clickable {
order = if (cableFirst) AppSettings.ConnectionOrder.WIRELESS_FIRST else AppSettings.ConnectionOrder.CABLE_FIRST
AppSettings.setConnectionOrder(context, order)
}, },
subtitle = stringResource(if (cableFirst) R.string.settings_order_cable else R.string.settings_order_wireless), ),
icon = Icons.Filled.KeyboardArrowUp, leading = {
trailing = {
Text( Text(
stringResource(if (cableFirst) R.string.settings_order_cable_short else R.string.settings_order_wireless_short), "${index + 1}",
color = MaterialTheme.colorScheme.primary, style = MaterialTheme.typography.titleLarge,
fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold, 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)
}
},
) )
} }
} }
+6 -8
View File
@@ -424,16 +424,14 @@
<string name="cable_none_title">No car on the cable</string> <string name="cable_none_title">No car on the cable</string>
<string name="cable_none_body">Plug the phone into the car\'s USB port with a data cable, then try again.</string> <string name="cable_none_body">Plug the phone into the car\'s USB port with a data cable, then try again.</string>
<string name="settings_cable">Connect over cable</string> <string name="settings_cable">Connect over cable</string>
<string name="settings_cable_on">Gearslip answers the car\'s USB connection</string> <string name="settings_cable_on">When the phone is plugged into the car</string>
<string name="settings_cable_off">Off: the cable only charges, or Android Auto takes it</string> <string name="settings_cable_off">Off: the cable only charges, or Android Auto takes it</string>
<string name="settings_wireless_auto">Connect wirelessly on its own</string> <string name="settings_wireless_auto">Connect wirelessly</string>
<string name="settings_wireless_auto_on">Starts when a car you\'ve connected to comes up on Bluetooth</string> <string name="settings_wireless_auto_on">On its own, when a car you\'ve used comes up on Bluetooth</string>
<string name="settings_wireless_auto_off">Off: the car\'s Bluetooth is left alone until you tap Connect wirelessly</string> <string name="settings_wireless_auto_off">Off: the car\'s Bluetooth is left alone until you tap Connect wirelessly</string>
<string name="settings_order">Try first</string> <string name="settings_order_hint">Gearslip tries these in order. Use the arrows to choose which comes first.</string>
<string name="settings_order_cable">Cable. Gearslip waits a few seconds for one before going wireless.</string> <string name="settings_order_up">Move up</string>
<string name="settings_order_wireless">Wireless. A cable plugged in later doesn\'t take over, but steps in if wireless fails.</string> <string name="settings_order_down">Move down</string>
<string name="settings_order_cable_short">Cable</string>
<string name="settings_order_wireless_short">Wireless</string>
<!-- Voice models --> <!-- Voice models -->
<string name="voice_live_title">Voice: live words</string> <string name="voice_live_title">Voice: live words</string>