Merge pull request #469 from legendgroupv2/dev-app-bt-prompt

Shows a prompt when Bluetooth is off and trying to add a device
This commit is contained in:
Andre K
2022-08-30 17:26:36 -03:00
committed by GitHub

View File

@@ -1,5 +1,6 @@
package com.geeksville.mesh.ui
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothDevice
import android.companion.CompanionDeviceManager
import android.content.*
@@ -485,6 +486,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
if (!myActivity.hasScanPermission()) {
myActivity.requestScanPermission()
} else {
checkBTEnabled()
if (!scanModel.hasCompanionDeviceApi) checkLocationEnabled()
scanLeDevice()
}
@@ -511,6 +513,15 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
}
}
private fun checkBTEnabled(
warningReason: String = getString(R.string.requires_bluetooth)
) {
if (bluetoothViewModel.enabled.value == false) {
warn("We need bluetooth")
showSnackbar(warningReason)
}
}
private val updateProgressFilter = IntentFilter(SoftwareUpdateService.ACTION_UPDATE_PROGRESS)
private val updateProgressReceiver: BroadcastReceiver = object : BroadcastReceiver() {