mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-11-30 23:30:32 +01:00
The car's Settings keeps what you'd change in the car; speech, the browser's start page and experimental features are set on the phone
This commit is contained in:
1 parent
623a8dc438
commit
8593e59b30
1 file changed
+2
-84
@@ -74,11 +74,7 @@ fun CarSettingsScreen() {
|
||||
val theme by CarSettings.appTheme.collectAsState()
|
||||
val uiTheme by CarSettings.uiTheme.collectAsState()
|
||||
val darkStyle by CarSettings.darkStyle.collectAsState()
|
||||
val experimentalFeatures by CarSettings.experimentalFeaturesEnabled.collectAsState()
|
||||
val carSensors by CarSettings.carSensorsEnabled.collectAsState()
|
||||
val adaptiveVideo by CarSettings.adaptiveVideoEnabled.collectAsState()
|
||||
val clusterVideo by CarSettings.clusterVideoEnabled.collectAsState()
|
||||
val systemSpeech by CarSettings.systemSpeech.collectAsState()
|
||||
val display by CarEnvironment.display.collectAsState()
|
||||
val vehicle by CarEnvironment.vehicle.collectAsState()
|
||||
val context = LocalContext.current
|
||||
@@ -230,9 +226,6 @@ fun CarSettingsScreen() {
|
||||
if (speakDirections) item {
|
||||
SwitchRow(stringResource(R.string.car_directions_over_music), stringResource(R.string.car_directions_over_music_note), directionsOverMusic) { CarSettings.setDirectionsOverMusic(it) }
|
||||
}
|
||||
item {
|
||||
SwitchRow(stringResource(R.string.car_phone_speech), stringResource(R.string.carset_phone_speech_note), systemSpeech) { CarSettings.setSystemSpeech(it) }
|
||||
}
|
||||
}
|
||||
3 -> {
|
||||
item { Group(stringResource(R.string.car_group_warnings)) }
|
||||
@@ -244,20 +237,12 @@ fun CarSettingsScreen() {
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
// Set-up settings (speech, the browser's start page, experimental features)
|
||||
// stay on the phone: they're set once, parked, not glanced at while driving.
|
||||
item { Group(stringResource(R.string.car_group_more)) }
|
||||
item { WebPageSetting() }
|
||||
item {
|
||||
SwitchRow(stringResource(R.string.car_cluster_video), stringResource(R.string.car_cluster_video_note), clusterVideo) { CarSettings.setClusterVideoEnabled(it) }
|
||||
}
|
||||
item {
|
||||
SwitchRow(stringResource(R.string.car_experimental), stringResource(R.string.car_experimental_note), experimentalFeatures) { CarSettings.setExperimentalFeaturesEnabled(it) }
|
||||
}
|
||||
if (experimentalFeatures) item {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
SubGroup(stringResource(R.string.carset_experimental_heading))
|
||||
ExperimentalFeaturesList(carSensors, adaptiveVideo)
|
||||
}
|
||||
}
|
||||
item {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
SwitchRow(
|
||||
@@ -412,30 +397,6 @@ private fun <T> ChoiceButtons(options: List<Pair<T, String>>, selected: T, onSel
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Individually-switched experimental features, shown once the driver has opted into
|
||||
* experimental features as a whole. Each is its own row - a title, what it does, and a switch -
|
||||
* so the list reads fine whether there's one entry or several.
|
||||
*/
|
||||
@Composable
|
||||
private fun ExperimentalFeaturesList(carSensors: Boolean, adaptiveVideo: Boolean) {
|
||||
Column(
|
||||
Modifier.fillMaxWidth(),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp),
|
||||
) {
|
||||
SwitchRow(
|
||||
title = stringResource(R.string.car_vehicle_data),
|
||||
description = stringResource(R.string.carset_vehicle_data_note),
|
||||
checked = carSensors,
|
||||
) { CarSettings.setCarSensorsEnabled(it) }
|
||||
SwitchRow(
|
||||
title = stringResource(R.string.car_adaptive_video),
|
||||
description = stringResource(R.string.carset_adaptive_note),
|
||||
checked = adaptiveVideo,
|
||||
) { CarSettings.setAdaptiveVideoEnabled(it) }
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SwitchRow(
|
||||
title: String,
|
||||
@@ -470,49 +431,6 @@ private fun SwitchRow(
|
||||
}
|
||||
}
|
||||
|
||||
/** The URL (or raw HTML) the Browser app shows. Edited with [CarKeyboard] - no phone in hand needed. */
|
||||
@Composable
|
||||
private fun WebPageSetting() {
|
||||
val context = LocalContext.current
|
||||
var editing by remember { mutableStateOf(false) }
|
||||
var url by remember { mutableStateOf(AppSettings.startupUrl(context)) }
|
||||
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text(stringResource(R.string.web_page), style = MaterialTheme.typography.titleMedium, color = MaterialTheme.colorScheme.primary)
|
||||
Surface(
|
||||
onClick = { editing = !editing },
|
||||
shape = MaterialTheme.shapes.large,
|
||||
color = MaterialTheme.colorScheme.surfaceContainerHigh,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
Text(
|
||||
url.ifEmpty { stringResource(R.string.carset_web_default) },
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
color = if (url.isEmpty()) MaterialTheme.colorScheme.onSurfaceVariant else MaterialTheme.colorScheme.onSurface,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
|
||||
)
|
||||
}
|
||||
Text(
|
||||
stringResource(R.string.carset_web_note),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
if (editing) {
|
||||
CarKeyboard(
|
||||
url,
|
||||
onTextChange = {
|
||||
url = it
|
||||
AppSettings.setStartupUrl(context, it)
|
||||
},
|
||||
onSubmit = { editing = false },
|
||||
onDismiss = { editing = false },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Info(label: String, value: String) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
|
||||
|
||||
Reference in new issue
Block a user