From 57587be9be7ce46fb9be81fce74843e21b94548c Mon Sep 17 00:00:00 2001 From: leekleak <142348248+leekleak@users.noreply.github.com> Date: Mon, 10 Feb 2025 21:07:12 +0200 Subject: [PATCH] refill api url when left empty (#1267) --- .../preferences/search/LocationSearchSettings.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/preferences/src/main/java/de/mm20/launcher2/preferences/search/LocationSearchSettings.kt b/core/preferences/src/main/java/de/mm20/launcher2/preferences/search/LocationSearchSettings.kt index 331c99bc..277afca7 100644 --- a/core/preferences/src/main/java/de/mm20/launcher2/preferences/search/LocationSearchSettings.kt +++ b/core/preferences/src/main/java/de/mm20/launcher2/preferences/search/LocationSearchSettings.kt @@ -74,7 +74,9 @@ class LocationSearchSettings internal constructor( fun setOverpassUrl(overpassUrl: String?) { var url = overpassUrl - if (url != null) { + if (url.isNullOrBlank()) { + url = DefaultOverpassUrl + } else { if (!url.startsWith("http://") && !url.startsWith("https://")) { url = "https://$url" } @@ -95,7 +97,9 @@ class LocationSearchSettings internal constructor( fun setTileServer(tileServer: String?) { var url = tileServer - if (url != null) { + if (url.isNullOrBlank()) { + url = DefaultTileServerUrl + } else { if (!url.startsWith("http://") && !url.startsWith("https://")) { url = "https://$url" } @@ -136,8 +140,8 @@ class LocationSearchSettings internal constructor( } companion object { - const val DefaultTileServerUrl = "https://tile.openstreetmap.org" - const val DefaultOverpassUrl = "https://overpass-api.de/" + const val DefaultTileServerUrl = "https://tile.openstreetmap.org/\${z}/\${x}/\${y}.png" + const val DefaultOverpassUrl = "https://overpass-api.de" } }