mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-03-14 20:08:32 -04:00
use LocationListenerCompat
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user