use LocationListenerCompat

pull/483/head
andrekir 2022-09-12 18:20:36 -03:00
rodzic fd0c8ef9b8
commit d9d46236dc
2 zmienionych plików z 8 dodań i 10 usunięć

Wyświetl plik

@ -3,8 +3,8 @@ package com.geeksville.mesh.repository.location
import android.annotation.SuppressLint
import android.content.Context
import android.location.Location
import android.location.LocationListener
import android.location.LocationManager
import androidx.core.location.LocationListenerCompat
import com.geeksville.mesh.android.GeeksvilleApplication
import com.geeksville.mesh.android.Logging
import com.geeksville.mesh.android.hasBackgroundPermission
@ -38,15 +38,9 @@ class SharedLocationManager constructor(
@SuppressLint("MissingPermission")
private val _locationUpdates = callbackFlow {
val locationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager
val callback = object: LocationListener {
override fun onLocationChanged(location: Location) {
// info("New location: $location")
trySend(location)
}
override fun onProviderDisabled(provider: String) {
close()
}
val callback = LocationListenerCompat { location ->
// info("New location: $location")
trySend(location)
}
if (!context.hasBackgroundPermission()) close()

Wyświetl plik

@ -605,5 +605,9 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
// Warn user if BLE device is selected but BLE disabled
if (scanModel.selectedBluetooth) checkBTEnabled()
// Warn user if provide location is selected but location disabled
if (binding.provideLocationCheckbox.isChecked)
checkLocationEnabled(getString(R.string.location_disabled))
}
}