shared(location): move AndroidLocationProvider to shared/androidMain; add play-services-location and coroutines-play-services deps; add iOS stub

app(main): update imports and keep using centralized provider for startup, auto-scans, and “Nearby” flow
This commit is contained in:
2025-09-14 19:33:00 +02:00
parent 5eb96a0ff1
commit dac05a23d4
5 changed files with 14 additions and 8 deletions

View File

@@ -108,7 +108,7 @@ import androidx.work.OneTimeWorkRequestBuilder
import androidx.work.WorkManager
import app.klottr.data.AppDatabase
import app.klottr.data.NoteRepository
import app.klottr.location.AndroidLocationProvider // Använd vår provider
import app.klottr.location.AndroidLocationProvider
import app.klottr.nearby.FoundOpenAction // Delat åtgärds-ADT
import app.klottr.nearby.NearbyEntryShared // Delad radmodell
import app.klottr.nearby.buildNearbyEntries // Delad builder för “Närliggande”

View File

@@ -1,26 +0,0 @@
package app.klottr.location
import android.content.Context
import com.google.android.gms.location.LocationServices
import com.google.android.gms.location.Priority
import kotlinx.coroutines.tasks.await
/** Android-implementation som använder FusedLocationProvider. */
object AndroidLocationProvider : LocationProvider {
/** Hämtar lastLocation och faller tillbaka till getCurrentLocation. */
suspend fun currentOrLastKnown(context: Context): GeoPoint? {
val client = LocationServices.getFusedLocationProviderClient(context) // Använder befintligt GMS-bibliotek
return try {
val last = client.lastLocation.await()
val loc = last ?: client.getCurrentLocation(Priority.PRIORITY_HIGH_ACCURACY, null).await()
loc?.let { GeoPoint(it.latitude, it.longitude) }
} catch (_: Exception) {
null
}
}
override suspend fun currentOrLastKnown(): GeoPoint? {
// Ej använd i appen just nu (kräver Context), men finns för framtida DI.
return null
}
}