diff options
author | Winson Chung <winsonc@google.com> | 2012-09-11 17:10:43 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-11 17:10:43 -0700 |
commit | 709c542b6758d2e40ed15ab8aa2a2dc0e52a342d (patch) | |
tree | 4539fdb6805271619f826afc9bb21e384967b935 /packages | |
parent | 73e0d75c9d3869a39635e55461349b3f5dd75604 (diff) | |
parent | 6072b00b6291b3c8e816fa7bd837c2cbba2f055b (diff) | |
download | frameworks_base-709c542b6758d2e40ed15ab8aa2a2dc0e52a342d.zip frameworks_base-709c542b6758d2e40ed15ab8aa2a2dc0e52a342d.tar.gz frameworks_base-709c542b6758d2e40ed15ab8aa2a2dc0e52a342d.tar.bz2 |
Merge "Fixing crash in emulator due to missing bluetooth." into jb-mr1-dev
Diffstat (limited to 'packages')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java | 39 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java | 3 |
2 files changed, 23 insertions, 19 deletions
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 7056e03..1c3cb2e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java @@ -167,10 +167,9 @@ class QuickSettings { startSettingsActivity(intent); } private void startSettingsActivity(Intent intent) { - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); mBar.collapseAllPanels(true); mContext.startActivity(intent); - } private void addUserTiles(ViewGroup parent, LayoutInflater inflater) { @@ -310,23 +309,25 @@ class QuickSettings { parent.addView(airplaneTile); // Bluetooth - QuickSettingsTileView bluetoothTile = (QuickSettingsTileView) - inflater.inflate(R.layout.quick_settings_tile, parent, false); - bluetoothTile.setContent(R.layout.quick_settings_tile_bluetooth, inflater); - bluetoothTile.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - startSettingsActivity(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS); - } - }); - mModel.addBluetoothTile(bluetoothTile, new QuickSettingsModel.RefreshCallback() { - @Override - public void refreshView(QuickSettingsTileView view, State state) { - TextView tv = (TextView) view.findViewById(R.id.bluetooth_textview); - tv.setCompoundDrawablesRelativeWithIntrinsicBounds(0, state.iconId, 0, 0); - } - }); - parent.addView(bluetoothTile); + if (mModel.deviceSupportsBluetooth()) { + QuickSettingsTileView bluetoothTile = (QuickSettingsTileView) + inflater.inflate(R.layout.quick_settings_tile, parent, false); + bluetoothTile.setContent(R.layout.quick_settings_tile_bluetooth, inflater); + bluetoothTile.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startSettingsActivity(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS); + } + }); + mModel.addBluetoothTile(bluetoothTile, new QuickSettingsModel.RefreshCallback() { + @Override + public void refreshView(QuickSettingsTileView view, State state) { + TextView tv = (TextView) view.findViewById(R.id.bluetooth_textview); + tv.setCompoundDrawablesRelativeWithIntrinsicBounds(0, state.iconId, 0, 0); + } + }); + parent.addView(bluetoothTile); + } // Brightness QuickSettingsTileView brightnessTile = (QuickSettingsTileView) 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 2318921..aa40f3c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java @@ -258,6 +258,9 @@ class QuickSettingsModel implements BluetoothStateChangeCallback, final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); onBluetoothStateChange(adapter.isEnabled()); } + boolean deviceSupportsBluetooth() { + return (BluetoothAdapter.getDefaultAdapter() != null); + } // BluetoothController callback @Override public void onBluetoothStateChange(boolean on) { |