From bfcfe82f17250cb47c524213cab7facfa47bc223 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Sat, 26 Mar 2016 20:45:07 +0100 Subject: [PATCH] Improve pairing activity: #254 - add hint about rebooting phone - request enabling bluetooth --- .../gadgetbridge/activities/DiscoveryActivity.java | 10 +++++++++- app/src/main/res/values/strings.xml | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java index 5b0d5549..81a5a2f6 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java @@ -249,7 +249,13 @@ public class DiscoveryActivity extends Activity implements AdapterView.OnItemCli private void bluetoothStateChanged(int oldState, int newState) { discoveryFinished(); - startButton.setEnabled(newState == BluetoothAdapter.STATE_ON); + if (newState == BluetoothAdapter.STATE_ON) { + this.adapter = BluetoothAdapter.getDefaultAdapter(); + startButton.setEnabled(true); + } else { + this.adapter = null; + startButton.setEnabled(false); + } } private void discoveryFinished() { @@ -286,6 +292,8 @@ public class DiscoveryActivity extends Activity implements AdapterView.OnItemCli BluetoothAdapter adapter = bluetoothService.getAdapter(); if (!adapter.isEnabled()) { LOG.warn("Bluetooth not enabled"); + Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); + startActivity(enableBtIntent); this.adapter = null; return false; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5978634e..25a6f77e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -116,7 +116,7 @@ No valid user data given, using dummy user data for now. When your Mi Band vibrates and blinks, tap it a few times in a row. Install - Make your device discoverable. Currently connected devices will likely not be discovered. + Make your device discoverable. Currently connected devices will likely not be discovered. If your device does not show up after two minutes, try again after rebooting your mobile device. Note: Device Image Name/Alias