Simplified getting the BluetoothAdapter.

This commit is contained in:
Dennis Guse
2020-08-04 16:54:30 +02:00
parent 9e553cc900
commit cf45a8079c
5 changed files with 18 additions and 49 deletions
@@ -137,7 +137,7 @@ public class SettingsActivity extends AppCompatActivity implements ChooseActivit
private void updateBluetooth() {
// Disable Bluetooth preference if device does not have Bluetooth
BluetoothLeSensorPreference bluetoothPreference = findPreference(getString(R.string.settings_sensor_bluetooth_heart_rate_key));
bluetoothPreference.setVisible(BluetoothUtils.hasBluetooth(TAG));
bluetoothPreference.setVisible(BluetoothUtils.hasBluetooth(getContext()));
}
private void updateUnits() {
@@ -136,7 +136,7 @@ public abstract class BluetoothLeSensorPreference extends DialogPreference {
UUID sensorUUID = (UUID) getArguments().getSerializable(ARG_BLUETOOTH_UUID);
Log.i(TAG, "UUID: " + sensorUUID);
BluetoothAdapter bluetoothAdapter = BluetoothUtils.getDefaultBluetoothAdapter(TAG);
BluetoothAdapter bluetoothAdapter = BluetoothUtils.getAdapter(getContext());
if (bluetoothAdapter == null || !bluetoothAdapter.isEnabled()) {
Log.w(TAG, "Bluetooth adapter is present or not enabled.");
Toast.makeText(getContext(), R.string.bluetooth_disabled, Toast.LENGTH_SHORT).show();