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

Shows a prompt when Bluetooth is off and trying to add a device
pull/475/head
Andre K 2022-08-30 17:26:36 -03:00 zatwierdzone przez GitHub
commit c1d854dc84
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 11 dodań i 0 usunięć

Wyświetl plik

@ -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() {