Klottr v0.2.4.1, lite bättre hantering av okänt klotter.

This commit is contained in:
2025-08-30 00:32:17 +02:00
parent 077f022eaf
commit f3a10435f7
2 changed files with 11 additions and 13 deletions

View File

@@ -47,7 +47,7 @@ android {
minSdk = 26 minSdk = 26
targetSdk = 35 targetSdk = 35
versionCode = 11 versionCode = 11
versionName = "0.2.4" versionName = "0.2.4.1"
// Byggtid i UTC (ISO 8601) genereras vid build-konfiguration // Byggtid i UTC (ISO 8601) genereras vid build-konfiguration
val buildTimeUtc = Instant.now().toString() val buildTimeUtc = Instant.now().toString()

View File

@@ -2053,10 +2053,6 @@ private fun KlotterDialog(
LaunchedEffect(id, lat, lon, label) { LaunchedEffect(id, lat, lon, label) {
loading = !prefilledFromCache loading = !prefilledFromCache
val baseLabel = label.trim()
val isKnown = baseLabel.isNotBlank() && baseLabel != "Okänt klotter"
app.klottr.util.AppLog.d { "KlotterDialog start id=$id isKnown=$isKnown label='${baseLabel.take(40)}'"}
// Hämta ev. färsk plats (fallback LastLocationStore) // Hämta ev. färsk plats (fallback LastLocationStore)
val my = LastLocationStore.lastKnownLocation val my = LastLocationStore.lastKnownLocation
val fused = GmsLocationServices.getFusedLocationProviderClient(context) val fused = GmsLocationServices.getFusedLocationProviderClient(context)
@@ -2074,14 +2070,16 @@ private fun KlotterDialog(
distanceMeters(qLat, qLon, lat, lon) <= Config.DEFAULT_KLOTTER_RADIUS_M.toDouble() distanceMeters(qLat, qLon, lat, lon) <= Config.DEFAULT_KLOTTER_RADIUS_M.toDouble()
} else false } else false
// Försök hämta detalj/bild om posten är känd (Hittat) ELLER vi är inom radien
val canAttempt = isKnown || withinRadius // Försök hämta detalj/bild om posten har besökts tidigare ELLER vi är inom radien
app.klottr.util.AppLog.d { "KlotterDialog canAttempt=$canAttempt withinRadius=$withinRadius"} val canAttempt = wasFoundBefore || withinRadius
app.klottr.util.AppLog.d { "KlotterDialog canAttempt=$canAttempt withinRadius=$withinRadius wasFoundBefore=$wasFoundBefore" }
if (canAttempt) { if (canAttempt) {
// get_note.php ska få: Hittat => NOTISENS coords, annars besökarens (fallback notisens) // get_note.php ska få: Besökt tidigare => NOTISENS coords, annars besökarens (fallback notisens)
val reqLat = if (isKnown) lat else (qLat ?: lat) val reqLat = if (wasFoundBefore) lat else (qLat ?: lat)
val reqLon = if (isKnown) lon else (qLon ?: lon) val reqLon = if (wasFoundBefore) lon else (qLon ?: lon)
val detail = withContext(Dispatchers.IO) { val detail = withContext(Dispatchers.IO) {
try { try {
@@ -2130,8 +2128,8 @@ private fun KlotterDialog(
} }
} }
} else { } else {
// Kunde inte få detalj – behåll ev. fallback (endast om ej känd och långt bort) // Kunde inte få detalj – behåll fallback (endast om aldrig funnen och utanför radie)
if (!isKnown && !withinRadius) { if (!wasFoundBefore && !withinRadius) {
titleText = "Okänt klotter" titleText = "Okänt klotter"
text = "Du måste vara inom ${Config.DEFAULT_KLOTTER_RADIUS_M}\u00A0m för att se det." text = "Du måste vara inom ${Config.DEFAULT_KLOTTER_RADIUS_M}\u00A0m för att se det."
} }