mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 13:19:52 +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;
|
package org.briarproject.briar.android.navdrawer;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -99,6 +100,7 @@ public class PluginViewModel extends AndroidViewModel implements EventListener {
|
|||||||
torPluginState.setValue(getTransportState(TorConstants.ID));
|
torPluginState.setValue(getTransportState(TorConstants.ID));
|
||||||
wifiPluginState.setValue(getTransportState(LanTcpConstants.ID));
|
wifiPluginState.setValue(getTransportState(LanTcpConstants.ID));
|
||||||
btPluginState.setValue(getTransportState(BluetoothConstants.ID));
|
btPluginState.setValue(getTransportState(BluetoothConstants.ID));
|
||||||
|
initialiseBluetoothState();
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +175,12 @@ public class PluginViewModel extends AndroidViewModel implements EventListener {
|
|||||||
mergeSettings(s, id.getString());
|
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() {
|
private void loadSettings() {
|
||||||
dbExecutor.execute(() -> {
|
dbExecutor.execute(() -> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user