Cut volume dialog timeout in half for media.

Bug:15849635
Change-Id: I84078c62db082293fb0153e378055c0279989e3c
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java b/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java
index b6d6767..08216c4 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java
@@ -84,6 +84,7 @@
     private static final int MAX_VOLUME = 100;
     private static final int FREE_DELAY = 10000;
     private static final int TIMEOUT_DELAY = 3000;
+    private static final int TIMEOUT_DELAY_SHORT = 1500;
     private static final int TIMEOUT_DELAY_EXPANDED = 10000;
 
     private static final int MSG_VOLUME_CHANGED = 0;
@@ -113,6 +114,7 @@
     private boolean mRingIsSilent;
     private boolean mVoiceCapable;
     private boolean mZenModeCapable;
+    private boolean mZenPanelExpanded;
     private int mTimeoutDelay = TIMEOUT_DELAY;
 
     // True if we want to play tones on the system stream when the master stream is specified.
@@ -515,6 +517,7 @@
             mActiveStreamType = activeStreamType;
             active.group.setVisibility(View.VISIBLE);
             updateSlider(active);
+            updateTimeoutDelay();
             setZenPanelVisible(isNotificationOrRing(mActiveStreamType));
         }
     }
@@ -586,6 +589,11 @@
         mCallback = callback;
     }
 
+    private void updateTimeoutDelay() {
+        mTimeoutDelay = mActiveStreamType == AudioManager.STREAM_MUSIC ? TIMEOUT_DELAY_SHORT
+                : mZenPanelExpanded ? TIMEOUT_DELAY_EXPANDED : TIMEOUT_DELAY;
+    }
+
     private void setZenPanelVisible(boolean visible) {
         if (LOGD) Log.d(mTag, "setZenPanelVisible " + visible + " mZenPanel=" + mZenPanel);
         if (visible) {
@@ -607,7 +615,9 @@
 
                     @Override
                     public void onExpanded(boolean expanded) {
-                        mTimeoutDelay = expanded ? TIMEOUT_DELAY_EXPANDED : TIMEOUT_DELAY;
+                        if (mZenPanelExpanded == expanded) return;
+                        mZenPanelExpanded = expanded;
+                        updateTimeoutDelay();
                         resetTimeout();
                     }
                 });
@@ -618,8 +628,6 @@
             if (mZenPanel != null) {
                 mZenPanel.setVisibility(View.GONE);
             }
-            mTimeoutDelay = TIMEOUT_DELAY;
-            resetTimeout();
         }
     }