Improve pairing activity: #254

- add hint about rebooting phone
- request enabling bluetooth
This commit is contained in:
cpfeiffer 2016-03-26 20:45:07 +01:00
parent 9d29e4db3f
commit bfcfe82f17
2 changed files with 10 additions and 2 deletions

View File

@ -249,7 +249,13 @@ public class DiscoveryActivity extends Activity implements AdapterView.OnItemCli
private void bluetoothStateChanged(int oldState, int newState) { private void bluetoothStateChanged(int oldState, int newState) {
discoveryFinished(); 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() { private void discoveryFinished() {
@ -286,6 +292,8 @@ public class DiscoveryActivity extends Activity implements AdapterView.OnItemCli
BluetoothAdapter adapter = bluetoothService.getAdapter(); BluetoothAdapter adapter = bluetoothService.getAdapter();
if (!adapter.isEnabled()) { if (!adapter.isEnabled()) {
LOG.warn("Bluetooth not enabled"); LOG.warn("Bluetooth not enabled");
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivity(enableBtIntent);
this.adapter = null; this.adapter = null;
return false; return false;
} }

View File

@ -116,7 +116,7 @@
<string name="miband_pairing_using_dummy_userdata">No valid user data given, using dummy user data for now.</string> <string name="miband_pairing_using_dummy_userdata">No valid user data given, using dummy user data for now.</string>
<string name="miband_pairing_tap_hint">When your Mi Band vibrates and blinks, tap it a few times in a row.</string> <string name="miband_pairing_tap_hint">When your Mi Band vibrates and blinks, tap it a few times in a row.</string>
<string name="appinstaller_install">Install</string> <string name="appinstaller_install">Install</string>
<string name="discovery_connected_devices_hint">Make your device discoverable. Currently connected devices will likely not be discovered.</string> <string name="discovery_connected_devices_hint">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.</string>
<string name="discovery_note">Note:</string> <string name="discovery_note">Note:</string>
<string name="candidate_item_device_image">Device Image</string> <string name="candidate_item_device_image">Device Image</string>
<string name="miband_prefs_alias">Name/Alias</string> <string name="miband_prefs_alias">Name/Alias</string>