diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_bluetooth_not_connected.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_bluetooth_not_connected.png new file mode 100644 index 0000000000000..8fb71ba74901c Binary files /dev/null and b/packages/SystemUI/res/drawable-hdpi/ic_qs_bluetooth_not_connected.png differ diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_bluetooth_off.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_bluetooth_off.png index 7c6ca7534d817..ac76535945684 100644 Binary files a/packages/SystemUI/res/drawable-hdpi/ic_qs_bluetooth_off.png and b/packages/SystemUI/res/drawable-hdpi/ic_qs_bluetooth_off.png differ diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_bluetooth_on.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_bluetooth_on.png index ff0ba07cde09b..090d235d7911c 100644 Binary files a/packages/SystemUI/res/drawable-hdpi/ic_qs_bluetooth_on.png and b/packages/SystemUI/res/drawable-hdpi/ic_qs_bluetooth_on.png differ diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_bluetooth_not_connected.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_bluetooth_not_connected.png new file mode 100644 index 0000000000000..d0ce4f6fdddf3 Binary files /dev/null and b/packages/SystemUI/res/drawable-mdpi/ic_qs_bluetooth_not_connected.png differ diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_bluetooth_off.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_bluetooth_off.png index 61eff946df08e..2116449fb52c0 100644 Binary files a/packages/SystemUI/res/drawable-mdpi/ic_qs_bluetooth_off.png and b/packages/SystemUI/res/drawable-mdpi/ic_qs_bluetooth_off.png differ diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_bluetooth_on.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_bluetooth_on.png index b480a80bc638d..1cc6e62f20291 100644 Binary files a/packages/SystemUI/res/drawable-mdpi/ic_qs_bluetooth_on.png and b/packages/SystemUI/res/drawable-mdpi/ic_qs_bluetooth_on.png differ diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_bluetooth_not_connected.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_bluetooth_not_connected.png new file mode 100644 index 0000000000000..e312f8e9e7d10 Binary files /dev/null and b/packages/SystemUI/res/drawable-xhdpi/ic_qs_bluetooth_not_connected.png differ diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_bluetooth_off.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_bluetooth_off.png index b4d9175a7a764..44cd31b347cd3 100644 Binary files a/packages/SystemUI/res/drawable-xhdpi/ic_qs_bluetooth_off.png and b/packages/SystemUI/res/drawable-xhdpi/ic_qs_bluetooth_off.png differ diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_bluetooth_on.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_bluetooth_on.png index 598d9676cb6bd..62a518a9ecafd 100644 Binary files a/packages/SystemUI/res/drawable-xhdpi/ic_qs_bluetooth_on.png and b/packages/SystemUI/res/drawable-xhdpi/ic_qs_bluetooth_on.png differ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java index c31e138a621f2..4ef35aace041f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java @@ -20,6 +20,7 @@ import android.app.ActivityManagerNative; import android.app.AlertDialog; import android.app.Dialog; import android.app.PendingIntent; +import android.bluetooth.BluetoothAdapter; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -81,6 +82,7 @@ class QuickSettings { private DisplayManager mDisplayManager; private WifiDisplayStatus mWifiDisplayStatus; private PhoneStatusBar mStatusBarService; + private QuickSettingsModel.BluetoothState mBluetoothState; private BrightnessController mBrightnessController; private BluetoothController mBluetoothController; @@ -115,6 +117,7 @@ class QuickSettings { mContainerView = container; mModel = new QuickSettingsModel(context); mWifiDisplayStatus = new WifiDisplayStatus(); + mBluetoothState = new QuickSettingsModel.BluetoothState(); mHandler = new Handler(); Resources r = mContext.getResources(); @@ -128,6 +131,7 @@ class QuickSettings { IntentFilter filter = new IntentFilter(); filter.addAction(DisplayManager.ACTION_WIFI_DISPLAY_STATUS_CHANGED); + filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); mContext.registerReceiver(mReceiver, filter); } @@ -739,6 +743,10 @@ class QuickSettings { mModel.onWifiDisplayStateChanged(mWifiDisplayStatus); } + private void applyBluetoothStatus() { + mModel.onBluetoothStateChange(mBluetoothState); + } + private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { @@ -748,6 +756,12 @@ class QuickSettings { mWifiDisplayStatus = status; applyWifiDisplayStatus(); } + if (intent.getAction().equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) { + int status = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, + BluetoothAdapter.STATE_DISCONNECTED); + mBluetoothState.connected = (status == BluetoothAdapter.STATE_CONNECTED); + applyBluetoothStatus(); + } } }; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java index 6b9a321081861..4b2fee44d2a6f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java @@ -77,6 +77,9 @@ class QuickSettingsModel implements BluetoothStateChangeCallback, static class BrightnessState extends State { boolean autoBrightness; } + public static class BluetoothState extends State { + boolean connected = false; + } /** The callback to update a given tile. */ interface RefreshCallback { @@ -173,7 +176,7 @@ class QuickSettingsModel implements BluetoothStateChangeCallback, private QuickSettingsTileView mBluetoothTile; private RefreshCallback mBluetoothCallback; - private State mBluetoothState = new State(); + private BluetoothState mBluetoothState = new BluetoothState(); private QuickSettingsTileView mBatteryTile; private RefreshCallback mBatteryCallback; @@ -398,7 +401,10 @@ class QuickSettingsModel implements BluetoothStateChangeCallback, mBluetoothCallback = cb; final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); - onBluetoothStateChange(adapter.isEnabled()); + mBluetoothState.enabled = adapter.isEnabled(); + mBluetoothState.connected = + (adapter.getConnectionState() == BluetoothAdapter.STATE_CONNECTED); + onBluetoothStateChange(mBluetoothState); } boolean deviceSupportsBluetooth() { return (BluetoothAdapter.getDefaultAdapter() != null); @@ -406,11 +412,20 @@ class QuickSettingsModel implements BluetoothStateChangeCallback, // BluetoothController callback @Override public void onBluetoothStateChange(boolean on) { + mBluetoothState.enabled = on; + onBluetoothStateChange(mBluetoothState); + } + public void onBluetoothStateChange(BluetoothState bluetoothStateIn) { // TODO: If view is in awaiting state, disable Resources r = mContext.getResources(); - mBluetoothState.enabled = on; - if (on) { - mBluetoothState.iconId = R.drawable.ic_qs_bluetooth_on; + mBluetoothState.enabled = bluetoothStateIn.enabled; + mBluetoothState.connected = bluetoothStateIn.connected; + if (mBluetoothState.enabled) { + if (mBluetoothState.connected) { + mBluetoothState.iconId = R.drawable.ic_qs_bluetooth_on; + } else { + mBluetoothState.iconId = R.drawable.ic_qs_bluetooth_not_connected; + } mBluetoothState.label = r.getString(R.string.quick_settings_bluetooth_label); } else { mBluetoothState.iconId = R.drawable.ic_qs_bluetooth_off; @@ -632,5 +647,4 @@ class QuickSettingsModel implements BluetoothStateChangeCallback, onNextAlarmChanged(); onBugreportChanged(); } - }