Improved the logic for notification clipping

Views are now still clipped during animations
but just on the right size.

Change-Id: I25e7d6dd67c9fcdb3a2c743048f9e83c840d837e
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
index 2d96199..1e5dcf7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
@@ -41,6 +41,8 @@
     private boolean mActualHeightInitialized;
     private boolean mDark;
     private ArrayList<View> mMatchParentViews = new ArrayList<View>();
+    private int mClipTopOptimization;
+    private static Rect mClipRect = new Rect();
 
     public ExpandableView(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -141,6 +143,7 @@
     public void setActualHeight(int actualHeight, boolean notifyListeners) {
         mActualHeightInitialized = true;
         mActualHeight = actualHeight;
+        updateClipping();
         if (notifyListeners) {
             notifyHeightChanged();
         }
@@ -299,6 +302,26 @@
         outRect.top += getTranslationY() + getClipTopAmount();
     }
 
+    private void updateClipping() {
+        mClipRect.set(0, mClipTopOptimization, getWidth(), getActualHeight());
+        setClipBounds(mClipRect);
+    }
+
+    public int getClipTopOptimization() {
+        return mClipTopOptimization;
+    }
+
+    /**
+     * Set that the view will be clipped by a given amount from the top. Contrary to
+     * {@link #setClipTopAmount} this amount doesn't effect shadows and the background.
+     *
+     * @param clipTopOptimization the amount to clip from the top
+     */
+    public void setClipTopOptimization(int clipTopOptimization) {
+        mClipTopOptimization = clipTopOptimization;
+        updateClipping();
+    }
+
     /**
      * A listener notifying when {@link #getActualHeight} changes.
      */