Implement nice motion for collapsing panel while QS open

Also remove the delay for actions which close the panel. Delaying is
no longer necessary as you still see the touch feedback when the
panel is closed.

Change-Id: I0dffae6998fc41b1590cb182667323f40be3a7d5
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 7d5d99d..2c5ece6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -289,7 +289,7 @@
                     }
                     mJustPeeked = false;
                 }
-                if (!mJustPeeked && (!waitForTouchSlop || mTracking)) {
+                if (!mJustPeeked && (!waitForTouchSlop || mTracking) && !isTrackingBlocked()) {
                     setExpandedHeightInternal(newHeight);
                 }
 
@@ -475,7 +475,8 @@
 
             // Make it shorter if we run a canned animation
             if (vel == 0) {
-                animator.setDuration((long) (animator.getDuration() / 1.75f));
+                animator.setDuration((long)
+                        (animator.getDuration() * getCannedFlingDurationFactor()));
             }
         }
         animator.addListener(new AnimatorListenerAdapter() {
@@ -546,9 +547,12 @@
         float currentMaxPanelHeight = getMaxPanelHeight();
 
         // If the user isn't actively poking us, let's update the height
-        if (!mTracking && mHeightAnimator == null
-                && mExpandedHeight > 0 && currentMaxPanelHeight != mExpandedHeight
-                && !mPeekPending && mPeekAnimator == null) {
+        if ((!mTracking || isTrackingBlocked())
+                && mHeightAnimator == null
+                && mExpandedHeight > 0
+                && currentMaxPanelHeight != mExpandedHeight
+                && !mPeekPending
+                && mPeekAnimator == null) {
             setExpandedHeight(currentMaxPanelHeight);
         }
     }
@@ -576,6 +580,12 @@
         notifyBarPanelExpansionChanged();
     }
 
+    /**
+     * @return true if the panel tracking should be temporarily blocked; this is used when a
+     *         conflicting gesture (opening QS) is happening
+     */
+    protected abstract boolean isTrackingBlocked();
+
     protected abstract void setOverExpansion(float overExpansion, boolean isPixels);
 
     protected abstract void onHeightUpdated(float expandedHeight);
@@ -866,4 +876,6 @@
     public abstract void resetViews();
 
     protected abstract float getPeekHeight();
+
+    protected abstract float getCannedFlingDurationFactor();
 }