fix(location): remove disable option and add manual UI

- Add ConfigFlag.NO_DISABLE_KEY to locationSearchProvider config to prevent
  'Disable' (null) option which caused fallback to OSM.
- Add manual UI controls to BetterLocationRoot.kt for Location Search Provider
  and Google Maps API Key, as automatic UI generation was not present on this page.
- Add ConfigSelector and ConfigInput helpers to BetterLocationRoot.kt.
- Ensure API key input is hidden/masked in the UI list.
This commit is contained in:
daplugg23
2026-02-05 17:13:44 -06:00
parent a4de81aaf6
commit d485718245
2 changed files with 49 additions and 1 deletions

View File

@@ -234,6 +234,8 @@ class BetterLocationRoot : Routes.Route() {
val coordinatesProperty = remember { val coordinatesProperty = remember {
context.config.root.global.betterLocation.getPropertyPair("coordinates") context.config.root.global.betterLocation.getPropertyPair("coordinates")
} }
val providerProperty = remember { context.config.root.global.betterLocation.getPropertyPair("location_search_provider") }
val apiKeyProperty = remember { context.config.root.global.betterLocation.getPropertyPair("google_maps_api_key") }
val updateDispatcher = rememberAsyncUpdateDispatcher() val updateDispatcher = rememberAsyncUpdateDispatcher()
val savedCoordinates = rememberAsyncMutableStateList( val savedCoordinates = rememberAsyncMutableStateList(
@@ -245,6 +247,8 @@ class BetterLocationRoot : Routes.Route() {
var showMap by remember { mutableStateOf(false) } var showMap by remember { mutableStateOf(false) }
var addSavedCoordinateDialog by remember { mutableStateOf(false) } var addSavedCoordinateDialog by remember { mutableStateOf(false) }
var showTeleportDialog by remember { mutableStateOf(false) } var showTeleportDialog by remember { mutableStateOf(false) }
var showProviderDialog by remember { mutableStateOf(false) }
var showApiKeyDialog by remember { mutableStateOf(false) }
val marker = remember { mutableStateOf<Marker?>(null) } val marker = remember { mutableStateOf<Marker?>(null) }
val mapView = remember { mutableStateOf<MapView?>(null) } val mapView = remember { mutableStateOf<MapView?>(null) }
@@ -271,6 +275,17 @@ class BetterLocationRoot : Routes.Route() {
) )
} }
if (showProviderDialog) {
me.eternal.purrfectsnap.ui.util.Dialog(onDismissRequest = { showProviderDialog = false }) {
alertDialogs.UniqueSelectionDialog(providerProperty)
}
}
if (showApiKeyDialog) {
me.eternal.purrfectsnap.ui.util.Dialog(onDismissRequest = { showApiKeyDialog = false }) {
alertDialogs.KeyboardInputDialog(apiKeyProperty) { showApiKeyDialog = false }
}
}
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
@@ -401,6 +416,39 @@ class BetterLocationRoot : Routes.Route() {
) { ) {
context.config.root.global.betterLocation.suspendLocationUpdates.set(it) context.config.root.global.betterLocation.suspendLocationUpdates.set(it)
} }
@Composable
fun ConfigSelector(text: String, value: String, onClick: () -> Unit) {
Row(
modifier = Modifier
.fillMaxWidth()
.clickable(onClick = onClick)
.padding(horizontal = 16.dp, vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically
) {
Text(text = text)
Spacer(modifier = Modifier.weight(1f))
Text(text = value, color = PurrfectPalette.textSecondary, fontSize = 14.sp)
}
}
@Composable
fun ConfigInput(text: String, value: String, onClick: () -> Unit) {
ConfigSelector(text, if (value.isNotEmpty()) "********" else translation["options.empty"], onClick)
}
val currentProvider = context.config.root.global.betterLocation.locationSearchProvider.get()
ConfigSelector(
text = translation["properties.location_search_provider.name"],
value = context.translation["options.location_search_provider.$currentProvider"]
) { showProviderDialog = true }
if (currentProvider == "google_maps") {
ConfigInput(
text = translation["properties.google_maps_api_key.name"],
value = context.config.root.global.betterLocation.googleMapsApiKey.get()
) { showApiKeyDialog = true }
}
} }
item { item {
GlassPanel( GlassPanel(

View File

@@ -28,7 +28,7 @@ class Global : ConfigContainer() {
val spoofBatteryLevel = string("spoof_battery_level") { requireRestart(); inputCheck = { it.isEmpty() || it.toIntOrNull() in 0..100 } } val spoofBatteryLevel = string("spoof_battery_level") { requireRestart(); inputCheck = { it.isEmpty() || it.toIntOrNull() in 0..100 } }
val spoofHeadphones = boolean("spoof_headphones") { requireRestart() } val spoofHeadphones = boolean("spoof_headphones") { requireRestart() }
val showBatteryLevel = boolean("show_battery_level") { requireRestart() } val showBatteryLevel = boolean("show_battery_level") { requireRestart() }
val locationSearchProvider = unique("location_search_provider", "osm", "google_maps") val locationSearchProvider = unique("location_search_provider", "osm", "google_maps") { addFlags(ConfigFlag.NO_DISABLE_KEY) }
val googleMapsApiKey = string("google_maps_api_key") { addFlags(ConfigFlag.SENSITIVE) } val googleMapsApiKey = string("google_maps_api_key") { addFlags(ConfigFlag.SENSITIVE) }
} }