mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-12-01 15:40:32 +01:00
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:
1 parent
962c083fe6
commit
095141ad07
2 files changed
+57
-41
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)) }
|
||||||
SettingsRow(
|
val links = if (order == AppSettings.ConnectionOrder.CABLE_FIRST) listOf(true, false) else listOf(false, true)
|
||||||
stringResource(R.string.settings_cable),
|
fun swap() {
|
||||||
Modifier.toggleable(cable, role = Role.Switch) {
|
order = if (order == AppSettings.ConnectionOrder.CABLE_FIRST) AppSettings.ConnectionOrder.WIRELESS_FIRST
|
||||||
cable = it
|
else AppSettings.ConnectionOrder.CABLE_FIRST
|
||||||
AppSettings.setCableEnabled(context, it)
|
AppSettings.setConnectionOrder(context, order)
|
||||||
},
|
}
|
||||||
subtitle = stringResource(if (cable) R.string.settings_cable_on else R.string.settings_cable_off),
|
Text(
|
||||||
icon = Icons.Filled.Settings,
|
stringResource(R.string.settings_order_hint),
|
||||||
trailing = { Switch(checked = cable, onCheckedChange = null) },
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = 12.dp, bottom = 4.dp),
|
||||||
)
|
)
|
||||||
SettingsRow(
|
links.forEachIndexed { index, isCable ->
|
||||||
stringResource(R.string.settings_wireless_auto),
|
val on = if (isCable) cable else wireless
|
||||||
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
|
|
||||||
SettingsRow(
|
SettingsRow(
|
||||||
stringResource(R.string.settings_order),
|
stringResource(if (isCable) R.string.settings_cable else R.string.settings_wireless_auto),
|
||||||
Modifier.clickable {
|
Modifier.toggleable(on, role = Role.Switch) {
|
||||||
order = if (cableFirst) AppSettings.ConnectionOrder.WIRELESS_FIRST else AppSettings.ConnectionOrder.CABLE_FIRST
|
if (isCable) {
|
||||||
AppSettings.setConnectionOrder(context, order)
|
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),
|
subtitle = stringResource(
|
||||||
icon = Icons.Filled.KeyboardArrowUp,
|
when {
|
||||||
trailing = {
|
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(
|
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)
|
||||||
|
}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in new issue
Block a user