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