Handle return value when Bluetooth is enabled
am: 77ad3c2531
* commit '77ad3c2531c00c7b654162be826e93abb5e4dc75':
Handle return value when Bluetooth is enabled
Change-Id: I5db74292d85d6a8795b2b25afd3c89c3731bd533
This commit is contained in:
@@ -24,6 +24,7 @@ import android.content.IntentFilter;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.util.Log;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -189,7 +190,16 @@ public final class BluetoothEnabler implements SwitchBar.OnSwitchChangeListener
|
|||||||
MetricsLogger.action(mContext, MetricsEvent.ACTION_BLUETOOTH_TOGGLE, isChecked);
|
MetricsLogger.action(mContext, MetricsEvent.ACTION_BLUETOOTH_TOGGLE, isChecked);
|
||||||
|
|
||||||
if (mLocalAdapter != null) {
|
if (mLocalAdapter != null) {
|
||||||
mLocalAdapter.setBluetoothEnabled(isChecked);
|
boolean status = mLocalAdapter.setBluetoothEnabled(isChecked);
|
||||||
|
// If we cannot toggle it ON then reset the UI assets:
|
||||||
|
// a) The switch should be OFF but it should still be togglable (enabled = True)
|
||||||
|
// b) The switch bar should have OFF text.
|
||||||
|
if (isChecked && !status) {
|
||||||
|
switchView.setChecked(false);
|
||||||
|
mSwitch.setEnabled(true);
|
||||||
|
mSwitchBar.setTextViewLabel(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mSwitch.setEnabled(false);
|
mSwitch.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user