kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
Shows prompt when Bluetooth is off and trying to add device
When trying to add a Meshtastic device, the app will check if bluetooth is turned on, if it isn't then it will display a message.pull/469/head
rodzic
db1218c46a
commit
e4b2649807
|
@ -1,5 +1,6 @@
|
|||
package com.geeksville.mesh.ui
|
||||
|
||||
import android.bluetooth.BluetoothAdapter
|
||||
import android.bluetooth.BluetoothDevice
|
||||
import android.companion.CompanionDeviceManager
|
||||
import android.content.*
|
||||
|
@ -475,6 +476,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
|||
if (!myActivity.hasScanPermission()) {
|
||||
myActivity.requestScanPermission()
|
||||
} else {
|
||||
checkBTEnabled()
|
||||
if (!scanModel.hasCompanionDeviceApi) checkLocationEnabled()
|
||||
scanLeDevice()
|
||||
}
|
||||
|
@ -501,6 +503,18 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
|||
}
|
||||
}
|
||||
|
||||
private fun checkBTEnabled(
|
||||
warningReason: String = getString(R.string.requires_bluetooth)
|
||||
) {
|
||||
|
||||
var btAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
|
||||
if (!(btAdapter.isEnabled())) {
|
||||
warn("We need bluetooth")
|
||||
showSnackbar(warningReason)
|
||||
}
|
||||
}
|
||||
|
||||
private val updateProgressFilter = IntentFilter(SoftwareUpdateService.ACTION_UPDATE_PROGRESS)
|
||||
|
||||
private val updateProgressReceiver: BroadcastReceiver = object : BroadcastReceiver() {
|
||||
|
|
Ładowanie…
Reference in New Issue