Update status bar icon policy for volume + zen.
Only show vibrate in the volume slot, create a separate slot
for zen.
Bug:15831713
Change-Id: I9d23a2d370bc6f98be3bdc98c2990bbea6643ce7
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 7f8fe4d..f34fbc13 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -31,6 +31,7 @@
<item><xliff:g id="id">nfc</xliff:g></item>
<item><xliff:g id="id">tty</xliff:g></item>
<item><xliff:g id="id">speakerphone</xliff:g></item>
+ <item><xliff:g id="id">zen</xliff:g></item>
<item><xliff:g id="id">mute</xliff:g></item>
<item><xliff:g id="id">volume</xliff:g></item>
<item><xliff:g id="id">wifi</xliff:g></item>
diff --git a/packages/SystemUI/res/drawable/stat_sys_zen_none.xml b/packages/SystemUI/res/drawable/stat_sys_zen_none.xml
new file mode 100644
index 0000000..101e3c4
--- /dev/null
+++ b/packages/SystemUI/res/drawable/stat_sys_zen_none.xml
@@ -0,0 +1,28 @@
+<!--
+Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android" >
+ <size
+ android:width="19dp"
+ android:height="19dp"/>
+
+ <viewport
+ android:viewportWidth="48.0"
+ android:viewportHeight="48.0"/>
+
+ <path
+ android:fill="#FFFFFFFF"
+ android:pathData="M24.0,4.0C13.0,4.0 4.0,13.0 4.0,24.0c0.0,11.0 9.0,20.0 20.0,20.0c11.0,0.0 20.0,-9.0 20.0,-20.0C44.0,13.0 35.0,4.0 24.0,4.0zM24.0,40.0c-8.8,0.0 -16.0,-7.2 -16.0,-16.0c0.0,-3.7 1.3,-7.1 3.4,-9.8l22.4,22.4C31.1,38.7 27.7,40.0 24.0,40.0zM36.6,33.8L14.2,11.4C16.9,9.3 20.3,8.0 24.0,8.0c8.8,0.0 16.0,7.2 16.0,16.0C40.0,27.7 38.7,31.1 36.6,33.8z"/>
+</vector>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
index 186b618..fa8e1a6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
@@ -39,20 +39,18 @@
*/
public class PhoneStatusBarPolicy {
private static final String TAG = "PhoneStatusBarPolicy";
-
- // message codes for the handler
- private static final int EVENT_BATTERY_CLOSE = 4;
-
- private static final int AM_PM_STYLE_NORMAL = 0;
- private static final int AM_PM_STYLE_SMALL = 1;
- private static final int AM_PM_STYLE_GONE = 2;
-
- private static final int AM_PM_STYLE = AM_PM_STYLE_GONE;
-
- private static final int INET_CONDITION_THRESHOLD = 50;
+ private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private static final boolean SHOW_SYNC_ICON = false;
+ private static final String SLOT_SYNC_ACTIVE = "sync_active";
+ private static final String SLOT_BLUETOOTH = "bluetooth";
+ private static final String SLOT_TTY = "tty";
+ private static final String SLOT_ZEN = "zen";
+ private static final String SLOT_VOLUME = "volume";
+ private static final String SLOT_CDMA_ERI = "cdma_eri";
+ private static final String SLOT_ALARM_CLOCK = "alarm_clock";
+
private final Context mContext;
private final StatusBarManager mService;
private final Handler mHandler = new Handler();
@@ -61,24 +59,13 @@
// to get broadcasts that it *is* there.
IccCardConstants.State mSimState = IccCardConstants.State.READY;
- // ringer volume
+ private boolean mZenVisible;
private boolean mVolumeVisible;
- // zen mode
private int mZen;
- // bluetooth device status
private boolean mBluetoothEnabled = false;
- private int mLastWifiSignalLevel = -1;
- private boolean mIsWifiConnected = false;
-
- // state of inet connection - 0 not connected, 100 connected
- private int mInetCondition = 0;
-
- // sync state
- // If sync is active the SyncActive icon is displayed. If sync is not active but
- // sync is failing the SyncFailing icon is displayed. Otherwise neither are displayed.
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
@@ -95,7 +82,7 @@
updateBluetooth(intent);
}
else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) {
- updateVolume();
+ updateVolumeZen();
}
else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
updateSimState(intent);
@@ -122,12 +109,12 @@
mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
// TTY status
- mService.setIcon("tty", R.drawable.stat_sys_tty_mode, 0, null);
- mService.setIconVisibility("tty", false);
+ mService.setIcon(SLOT_TTY, R.drawable.stat_sys_tty_mode, 0, null);
+ mService.setIconVisibility(SLOT_TTY, false);
// Cdma Roaming Indicator, ERI
- mService.setIcon("cdma_eri", R.drawable.stat_sys_roaming_cdma_0, 0, null);
- mService.setIconVisibility("cdma_eri", false);
+ mService.setIcon(SLOT_CDMA_ERI, R.drawable.stat_sys_roaming_cdma_0, 0, null);
+ mService.setIconVisibility(SLOT_CDMA_ERI, false);
// bluetooth status
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
@@ -138,38 +125,42 @@
bluetoothIcon = R.drawable.stat_sys_data_bluetooth_connected;
}
}
- mService.setIcon("bluetooth", bluetoothIcon, 0, null);
- mService.setIconVisibility("bluetooth", mBluetoothEnabled);
+ mService.setIcon(SLOT_BLUETOOTH, bluetoothIcon, 0, null);
+ mService.setIconVisibility(SLOT_BLUETOOTH, mBluetoothEnabled);
// Alarm clock
- mService.setIcon("alarm_clock", R.drawable.stat_sys_alarm, 0, null);
- mService.setIconVisibility("alarm_clock", false);
+ mService.setIcon(SLOT_ALARM_CLOCK, R.drawable.stat_sys_alarm, 0, null);
+ mService.setIconVisibility(SLOT_ALARM_CLOCK, false);
// Sync state
- mService.setIcon("sync_active", R.drawable.stat_sys_sync, 0, null);
- mService.setIconVisibility("sync_active", false);
+ mService.setIcon(SLOT_SYNC_ACTIVE, R.drawable.stat_sys_sync, 0, null);
+ mService.setIconVisibility(SLOT_SYNC_ACTIVE, false);
// "sync_failing" is obsolete: b/1297963
+ // zen
+ mService.setIcon(SLOT_ZEN, R.drawable.stat_sys_zen_important, 0, null);
+ mService.setIconVisibility(SLOT_ZEN, false);
+
// volume
- mService.setIcon("volume", R.drawable.stat_sys_ringer_silent, 0, null);
- mService.setIconVisibility("volume", false);
- updateVolume();
+ mService.setIcon(SLOT_VOLUME, R.drawable.stat_sys_ringer_silent, 0, null);
+ mService.setIconVisibility(SLOT_VOLUME, false);
+ updateVolumeZen();
}
public void setZenMode(int zen) {
mZen = zen;
- updateVolume();
+ updateVolumeZen();
}
private final void updateAlarm(Intent intent) {
boolean alarmSet = intent.getBooleanExtra("alarmSet", false);
- mService.setIconVisibility("alarm_clock", alarmSet);
+ mService.setIconVisibility(SLOT_ALARM_CLOCK, alarmSet);
}
private final void updateSyncState(Intent intent) {
if (!SHOW_SYNC_ICON) return;
boolean isActive = intent.getBooleanExtra("active", false);
- mService.setIconVisibility("sync_active", isActive);
+ mService.setIconVisibility(SLOT_SYNC_ACTIVE, isActive);
}
private final void updateSimState(Intent intent) {
@@ -200,32 +191,48 @@
}
}
- private final void updateVolume() {
+ private final void updateVolumeZen() {
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
- final int ringerMode = audioManager.getRingerMode();
- int iconId = 0;
- String contentDescription = null;
- boolean visible = false;
- if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
- visible = true;
- iconId = R.drawable.stat_sys_ringer_silent;
- contentDescription = mContext.getString(R.string.accessibility_ringer_silent);
+
+ boolean zenVisible = false;
+ int zenIconId = 0;
+ String zenDescription = null;
+
+ boolean volumeVisible = false;
+ int volumeIconId = 0;
+ String volumeDescription = null;
+
+ if (mZen == Global.ZEN_MODE_NO_INTERRUPTIONS) {
+ zenVisible = true;
+ zenIconId = R.drawable.stat_sys_zen_none;
+ zenDescription = mContext.getString(R.string.zen_no_interruptions);
} else if (mZen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) {
- visible = true;
- iconId = R.drawable.stat_sys_zen_important;
- contentDescription = mContext.getString(R.string.zen_important_interruptions);
- } else if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
- visible = true;
- iconId = R.drawable.stat_sys_ringer_vibrate;
- contentDescription = mContext.getString(R.string.accessibility_ringer_vibrate);
+ zenVisible = true;
+ zenIconId = R.drawable.stat_sys_zen_important;
+ zenDescription = mContext.getString(R.string.zen_important_interruptions);
}
- if (visible) {
- mService.setIcon("volume", iconId, 0, contentDescription);
+ if (mZen != Global.ZEN_MODE_NO_INTERRUPTIONS &&
+ audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) {
+ volumeVisible = true;
+ volumeIconId = R.drawable.stat_sys_ringer_vibrate;
+ volumeDescription = mContext.getString(R.string.accessibility_ringer_vibrate);
}
- if (visible != mVolumeVisible) {
- mService.setIconVisibility("volume", visible);
- mVolumeVisible = visible;
+
+ if (zenVisible) {
+ mService.setIcon(SLOT_ZEN, zenIconId, 0, zenDescription);
+ }
+ if (zenVisible != mZenVisible) {
+ mService.setIconVisibility(SLOT_ZEN, zenVisible);
+ mZenVisible = zenVisible;
+ }
+
+ if (volumeVisible) {
+ mService.setIcon(SLOT_VOLUME, volumeIconId, 0, volumeDescription);
+ }
+ if (volumeVisible != mVolumeVisible) {
+ mService.setIconVisibility(SLOT_VOLUME, volumeVisible);
+ mVolumeVisible = volumeVisible;
}
}
@@ -250,26 +257,25 @@
return;
}
- mService.setIcon("bluetooth", iconId, 0, contentDescription);
- mService.setIconVisibility("bluetooth", mBluetoothEnabled);
+ mService.setIcon(SLOT_BLUETOOTH, iconId, 0, contentDescription);
+ mService.setIconVisibility(SLOT_BLUETOOTH, mBluetoothEnabled);
}
private final void updateTTY(Intent intent) {
- final String action = intent.getAction();
final boolean enabled = intent.getBooleanExtra(TtyIntent.TTY_ENABLED, false);
- if (false) Log.v(TAG, "updateTTY: enabled: " + enabled);
+ if (DEBUG) Log.v(TAG, "updateTTY: enabled: " + enabled);
if (enabled) {
// TTY is on
- if (false) Log.v(TAG, "updateTTY: set TTY on");
- mService.setIcon("tty", R.drawable.stat_sys_tty_mode, 0,
+ if (DEBUG) Log.v(TAG, "updateTTY: set TTY on");
+ mService.setIcon(SLOT_TTY, R.drawable.stat_sys_tty_mode, 0,
mContext.getString(R.string.accessibility_tty_enabled));
- mService.setIconVisibility("tty", true);
+ mService.setIconVisibility(SLOT_TTY, true);
} else {
// TTY is off
- if (false) Log.v(TAG, "updateTTY: set TTY off");
- mService.setIconVisibility("tty", false);
+ if (DEBUG) Log.v(TAG, "updateTTY: set TTY off");
+ mService.setIconVisibility(SLOT_TTY, false);
}
}
}