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:
@@ -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(
|
||||||
|
|||||||
@@ -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) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user