Merge "make bluetooth iconography consistent with other quicksettings icons." into jb-mr1-dev

This commit is contained in:
Chris Wren
2012-10-03 09:19:11 -07:00
committed by Android (Google) Code Review
11 changed files with 34 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -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();
}
}
};
}

View File

@@ -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();
}
}