1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-20 07:21:40 +02:00

fixed to show correct icon if direct connection failed

This commit is contained in:
OliE
2018-04-25 16:28:36 +02:00
parent 0447fc2c31
commit 8beeca596d

View File

@@ -449,12 +449,14 @@ public class MainActivity extends BaseAppCompatActivity
BluetoothPreferences.PREFERENCE_KEY_BLUETOOTH_HW_ADDRESS, "");
if (!BluetoothAdapter.checkBluetoothAddress(hwAddress)) {
setBluetoothStatusIcon(R.drawable.ic_bluetooth_connection_lost);
Toast.makeText(getApplicationContext(), R.string.info_bluetooth_no_device_set, Toast.LENGTH_SHORT).show();
return;
}
BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(BLUETOOTH_SERVICE);
if (!bluetoothManager.getAdapter().isEnabled()) {
setBluetoothStatusIcon(R.drawable.ic_bluetooth_connection_lost);
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, ENABLE_BLUETOOTH_REQUEST);
return;
@@ -464,6 +466,7 @@ public class MainActivity extends BaseAppCompatActivity
setBluetoothStatusIcon(R.drawable.ic_bluetooth_searching);
if (!openScale.connectToBluetoothDevice(deviceName, hwAddress, callbackBtHandler)) {
setBluetoothStatusIcon(R.drawable.ic_bluetooth_connection_lost);
Toast.makeText(getApplicationContext(), deviceName + " " + getResources().getString(R.string.label_bt_device_no_support), Toast.LENGTH_SHORT).show();
}
}