am 3edcf5ee: Merge "make bluetooth iconography consistent with other quicksettings icons." into jb-mr1-dev
* commit '3edcf5ee908d4e96030dabbd673fbb457c400607': make bluetooth iconography consistent with other quicksettings icons.
|
After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.7 KiB |
@@ -20,6 +20,7 @@ import android.app.ActivityManagerNative;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -81,6 +82,7 @@ class QuickSettings {
|
|||||||
private DisplayManager mDisplayManager;
|
private DisplayManager mDisplayManager;
|
||||||
private WifiDisplayStatus mWifiDisplayStatus;
|
private WifiDisplayStatus mWifiDisplayStatus;
|
||||||
private PhoneStatusBar mStatusBarService;
|
private PhoneStatusBar mStatusBarService;
|
||||||
|
private QuickSettingsModel.BluetoothState mBluetoothState;
|
||||||
|
|
||||||
private BrightnessController mBrightnessController;
|
private BrightnessController mBrightnessController;
|
||||||
private BluetoothController mBluetoothController;
|
private BluetoothController mBluetoothController;
|
||||||
@@ -115,6 +117,7 @@ class QuickSettings {
|
|||||||
mContainerView = container;
|
mContainerView = container;
|
||||||
mModel = new QuickSettingsModel(context);
|
mModel = new QuickSettingsModel(context);
|
||||||
mWifiDisplayStatus = new WifiDisplayStatus();
|
mWifiDisplayStatus = new WifiDisplayStatus();
|
||||||
|
mBluetoothState = new QuickSettingsModel.BluetoothState();
|
||||||
mHandler = new Handler();
|
mHandler = new Handler();
|
||||||
|
|
||||||
Resources r = mContext.getResources();
|
Resources r = mContext.getResources();
|
||||||
@@ -128,6 +131,7 @@ class QuickSettings {
|
|||||||
|
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(DisplayManager.ACTION_WIFI_DISPLAY_STATUS_CHANGED);
|
filter.addAction(DisplayManager.ACTION_WIFI_DISPLAY_STATUS_CHANGED);
|
||||||
|
filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
|
||||||
mContext.registerReceiver(mReceiver, filter);
|
mContext.registerReceiver(mReceiver, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -739,6 +743,10 @@ class QuickSettings {
|
|||||||
mModel.onWifiDisplayStateChanged(mWifiDisplayStatus);
|
mModel.onWifiDisplayStateChanged(mWifiDisplayStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void applyBluetoothStatus() {
|
||||||
|
mModel.onBluetoothStateChange(mBluetoothState);
|
||||||
|
}
|
||||||
|
|
||||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
@@ -748,6 +756,12 @@ class QuickSettings {
|
|||||||
mWifiDisplayStatus = status;
|
mWifiDisplayStatus = status;
|
||||||
applyWifiDisplayStatus();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ class QuickSettingsModel implements BluetoothStateChangeCallback,
|
|||||||
static class BrightnessState extends State {
|
static class BrightnessState extends State {
|
||||||
boolean autoBrightness;
|
boolean autoBrightness;
|
||||||
}
|
}
|
||||||
|
public static class BluetoothState extends State {
|
||||||
|
boolean connected = false;
|
||||||
|
}
|
||||||
|
|
||||||
/** The callback to update a given tile. */
|
/** The callback to update a given tile. */
|
||||||
interface RefreshCallback {
|
interface RefreshCallback {
|
||||||
@@ -173,7 +176,7 @@ class QuickSettingsModel implements BluetoothStateChangeCallback,
|
|||||||
|
|
||||||
private QuickSettingsTileView mBluetoothTile;
|
private QuickSettingsTileView mBluetoothTile;
|
||||||
private RefreshCallback mBluetoothCallback;
|
private RefreshCallback mBluetoothCallback;
|
||||||
private State mBluetoothState = new State();
|
private BluetoothState mBluetoothState = new BluetoothState();
|
||||||
|
|
||||||
private QuickSettingsTileView mBatteryTile;
|
private QuickSettingsTileView mBatteryTile;
|
||||||
private RefreshCallback mBatteryCallback;
|
private RefreshCallback mBatteryCallback;
|
||||||
@@ -398,7 +401,10 @@ class QuickSettingsModel implements BluetoothStateChangeCallback,
|
|||||||
mBluetoothCallback = cb;
|
mBluetoothCallback = cb;
|
||||||
|
|
||||||
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
onBluetoothStateChange(adapter.isEnabled());
|
mBluetoothState.enabled = adapter.isEnabled();
|
||||||
|
mBluetoothState.connected =
|
||||||
|
(adapter.getConnectionState() == BluetoothAdapter.STATE_CONNECTED);
|
||||||
|
onBluetoothStateChange(mBluetoothState);
|
||||||
}
|
}
|
||||||
boolean deviceSupportsBluetooth() {
|
boolean deviceSupportsBluetooth() {
|
||||||
return (BluetoothAdapter.getDefaultAdapter() != null);
|
return (BluetoothAdapter.getDefaultAdapter() != null);
|
||||||
@@ -406,11 +412,20 @@ class QuickSettingsModel implements BluetoothStateChangeCallback,
|
|||||||
// BluetoothController callback
|
// BluetoothController callback
|
||||||
@Override
|
@Override
|
||||||
public void onBluetoothStateChange(boolean on) {
|
public void onBluetoothStateChange(boolean on) {
|
||||||
|
mBluetoothState.enabled = on;
|
||||||
|
onBluetoothStateChange(mBluetoothState);
|
||||||
|
}
|
||||||
|
public void onBluetoothStateChange(BluetoothState bluetoothStateIn) {
|
||||||
// TODO: If view is in awaiting state, disable
|
// TODO: If view is in awaiting state, disable
|
||||||
Resources r = mContext.getResources();
|
Resources r = mContext.getResources();
|
||||||
mBluetoothState.enabled = on;
|
mBluetoothState.enabled = bluetoothStateIn.enabled;
|
||||||
if (on) {
|
mBluetoothState.connected = bluetoothStateIn.connected;
|
||||||
mBluetoothState.iconId = R.drawable.ic_qs_bluetooth_on;
|
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);
|
mBluetoothState.label = r.getString(R.string.quick_settings_bluetooth_label);
|
||||||
} else {
|
} else {
|
||||||
mBluetoothState.iconId = R.drawable.ic_qs_bluetooth_off;
|
mBluetoothState.iconId = R.drawable.ic_qs_bluetooth_off;
|
||||||
@@ -632,5 +647,4 @@ class QuickSettingsModel implements BluetoothStateChangeCallback,
|
|||||||
onNextAlarmChanged();
|
onNextAlarmChanged();
|
||||||
onBugreportChanged();
|
onBugreportChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||