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:
2
.idea/deploymentTargetSelector.xml
generated
2
.idea/deploymentTargetSelector.xml
generated
@@ -4,7 +4,7 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2025-08-16T15:24:03.539393207Z">
|
<DropdownSelection timestamp="2025-09-14T17:27:28.916146190Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=39151FDJG000HZ" />
|
<DeviceId pluginId="PhysicalDevice" identifier="serial=39151FDJG000HZ" />
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ import androidx.work.OneTimeWorkRequestBuilder
|
|||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
import app.klottr.data.AppDatabase
|
import app.klottr.data.AppDatabase
|
||||||
import app.klottr.data.NoteRepository
|
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.FoundOpenAction // Delat åtgärds-ADT
|
||||||
import app.klottr.nearby.NearbyEntryShared // Delad radmodell
|
import app.klottr.nearby.NearbyEntryShared // Delad radmodell
|
||||||
import app.klottr.nearby.buildNearbyEntries // Delad builder för “Närliggande”
|
import app.klottr.nearby.buildNearbyEntries // Delad builder för “Närliggande”
|
||||||
|
|||||||
@@ -113,7 +113,8 @@ kotlin {
|
|||||||
// commonMain by default and will correctly pull the Android artifacts of any KMP
|
// commonMain by default and will correctly pull the Android artifacts of any KMP
|
||||||
// dependencies declared in commonMain.
|
// dependencies declared in commonMain.
|
||||||
implementation(libs.ktor.client.okhttp)
|
implementation(libs.ktor.client.okhttp)
|
||||||
|
implementation("com.google.android.gms:play-services-location:21.3.0") // FusedLocation
|
||||||
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.9.0") // await() på Tasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ import kotlinx.coroutines.tasks.await
|
|||||||
|
|
||||||
/** Android-implementation som använder FusedLocationProvider. */
|
/** Android-implementation som använder FusedLocationProvider. */
|
||||||
object AndroidLocationProvider : LocationProvider {
|
object AndroidLocationProvider : LocationProvider {
|
||||||
|
|
||||||
/** Hämtar lastLocation och faller tillbaka till getCurrentLocation. */
|
/** Hämtar lastLocation och faller tillbaka till getCurrentLocation. */
|
||||||
suspend fun currentOrLastKnown(context: Context): GeoPoint? {
|
suspend fun currentOrLastKnown(context: Context): GeoPoint? {
|
||||||
val client = LocationServices.getFusedLocationProviderClient(context) // Använder befintligt GMS-bibliotek
|
val client = LocationServices.getFusedLocationProviderClient(context)
|
||||||
return try {
|
return try {
|
||||||
val last = client.lastLocation.await()
|
val last = client.lastLocation.await()
|
||||||
val loc = last ?: client.getCurrentLocation(Priority.PRIORITY_HIGH_ACCURACY, null).await()
|
val loc = last ?: client.getCurrentLocation(Priority.PRIORITY_HIGH_ACCURACY, null).await()
|
||||||
@@ -19,8 +20,6 @@ object AndroidLocationProvider : LocationProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun currentOrLastKnown(): GeoPoint? {
|
// Interface-override finns för framtida DI utan Context (används ej av :app idag).
|
||||||
// Ej använd i appen just nu (kräver Context), men finns för framtida DI.
|
override suspend fun currentOrLastKnown(): GeoPoint? = null
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package app.klottr.location
|
||||||
|
|
||||||
|
/** iOS-stub tills riktig plats läggs till. */
|
||||||
|
object IosLocationProvider : LocationProvider {
|
||||||
|
override suspend fun currentOrLastKnown(): GeoPoint? = null
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user