kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
Fix #55 - warn user if they have location disabled
rodzic
3cf7d97dcf
commit
03af1f1de7
|
@ -14,6 +14,7 @@ import android.companion.CompanionDeviceManager
|
|||
import android.content.*
|
||||
import android.hardware.usb.UsbDevice
|
||||
import android.hardware.usb.UsbManager
|
||||
import android.location.LocationManager
|
||||
import android.os.Bundle
|
||||
import android.os.ParcelUuid
|
||||
import android.view.LayoutInflater
|
||||
|
@ -751,6 +752,15 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
|||
scanModel.stopScan()
|
||||
}
|
||||
|
||||
/**
|
||||
* Has the user _turned on_ the system setting for current location access.
|
||||
*/
|
||||
private fun isLocationEnabled(): Boolean {
|
||||
val locManager =
|
||||
requireContext().getSystemService(Context.LOCATION_SERVICE) as LocationManager
|
||||
return locManager.isLocationEnabled
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (!hasCompanionDeviceApi)
|
||||
|
@ -758,12 +768,21 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
|||
|
||||
// Keep reminding user BLE is still off
|
||||
val hasUSB = activity?.let { SerialInterface.findDrivers(it).isNotEmpty() } ?: true
|
||||
if (scanModel.bluetoothAdapter?.isEnabled != true && !hasUSB) {
|
||||
if (!hasUSB) {
|
||||
// Warn user if BLE is disabled
|
||||
if (scanModel.bluetoothAdapter?.isEnabled != true) {
|
||||
Toast.makeText(
|
||||
requireContext(),
|
||||
R.string.error_bluetooth,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
} else if (!isLocationEnabled()) {
|
||||
Toast.makeText(
|
||||
requireContext(),
|
||||
getString(R.string.location_disabled_warning),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,4 +69,5 @@
|
|||
<string name="modem_config_very_long">Very long range (but slow)</string>
|
||||
<string name="modem_config_unrecognized">UNRECOGNIZED</string>
|
||||
<string name="meshtastic_service_notifications">Meshtastic Service Notifications</string>
|
||||
<string name="location_disabled_warning">You must turn on location services in Android Settings</string>
|
||||
</resources>
|
||||
|
|
Ładowanie…
Reference in New Issue