mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 02:39:05 +01:00
Initialise Bluetooth state when view model is created.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.briarproject.briar.android.navdrawer;
|
||||
|
||||
import android.app.Application;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -99,6 +100,7 @@ public class PluginViewModel extends AndroidViewModel implements EventListener {
|
||||
torPluginState.setValue(getTransportState(TorConstants.ID));
|
||||
wifiPluginState.setValue(getTransportState(LanTcpConstants.ID));
|
||||
btPluginState.setValue(getTransportState(BluetoothConstants.ID));
|
||||
initialiseBluetoothState();
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
@@ -173,6 +175,12 @@ public class PluginViewModel extends AndroidViewModel implements EventListener {
|
||||
mergeSettings(s, id.getString());
|
||||
}
|
||||
|
||||
private void initialiseBluetoothState() {
|
||||
BluetoothAdapter bt = BluetoothAdapter.getDefaultAdapter();
|
||||
if (bt == null) bluetoothTurnedOn.setValue(false);
|
||||
else bluetoothTurnedOn.setValue(bt.getState() == STATE_ON);
|
||||
}
|
||||
|
||||
private void loadSettings() {
|
||||
dbExecutor.execute(() -> {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user