Prevent Recents from doing a relayout

Don't relayout Recents when going from a
fullscreen app to Recents; set the proper flags
to do the layout underneath the status bar
diff --git a/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml b/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml
index b51b333..b06166d 100644
--- a/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml
+++ b/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml
@@ -41,7 +41,8 @@
             android:fadingEdge="horizontal"
             android:scrollbars="none"
             android:layout_gravity="right"
-            android:fadingEdgeLength="@dimen/status_bar_recents_scroll_fading_edge_length">
+            android:fadingEdgeLength="@dimen/status_bar_recents_scroll_fading_edge_length"
+            android:fitsSystemWindows="true">
 
             <LinearLayout android:id="@+id/recents_linear_layout"
                 android:layout_width="wrap_content"
diff --git a/packages/SystemUI/res/layout/status_bar_recent_panel.xml b/packages/SystemUI/res/layout/status_bar_recent_panel.xml
index 4bbe277..305aaf2 100644
--- a/packages/SystemUI/res/layout/status_bar_recent_panel.xml
+++ b/packages/SystemUI/res/layout/status_bar_recent_panel.xml
@@ -45,7 +45,8 @@
             android:fadingEdgeLength="@dimen/status_bar_recents_scroll_fading_edge_length"
             android:layout_gravity="bottom|start"
             android:clipToPadding="false"
-            android:clipChildren="false">
+            android:clipChildren="false"
+            android:fitsSystemWindows="true">
 
             <LinearLayout android:id="@+id/recents_linear_layout"
                 android:layout_width="match_parent"
diff --git a/packages/SystemUI/res/layout/system_bar_recent_panel.xml b/packages/SystemUI/res/layout/system_bar_recent_panel.xml
index aed8a8c..3d15d9b 100644
--- a/packages/SystemUI/res/layout/system_bar_recent_panel.xml
+++ b/packages/SystemUI/res/layout/system_bar_recent_panel.xml
@@ -49,7 +49,8 @@
             android:fadingEdgeLength="20dip"
             android:layout_gravity="bottom|start"
             android:clipToPadding="false"
-            android:clipChildren="false">
+            android:clipChildren="false"
+            android:fitsSystemWindows="true">
 
             <LinearLayout android:id="@+id/recents_linear_layout"
                 android:layout_width="wrap_content"
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java
index 676326a..c325937 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java
@@ -177,6 +177,7 @@
         setContentView(R.layout.status_bar_recent_panel);
         mRecentsPanel = (RecentsPanelView) findViewById(R.id.recents_root);
         mRecentsPanel.setOnTouchListener(new TouchOutsideListener(mRecentsPanel));
+        mRecentsPanel.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
 
         final RecentTasksLoader recentTasksLoader = RecentTasksLoader.getInstance(this);
         recentTasksLoader.setRecentsPanel(mRecentsPanel, mRecentsPanel);
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
index 3330301..217b7fd 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
@@ -256,7 +256,7 @@
             mPerformanceHelper.drawCallback(canvas,
                     left, right, top, bottom, mScrollX, mScrollY,
                     0, 0,
-                    getLeftFadingEdgeStrength(), getRightFadingEdgeStrength());
+                    getLeftFadingEdgeStrength(), getRightFadingEdgeStrength(), mPaddingTop);
         }
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsScrollViewPerformanceHelper.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsScrollViewPerformanceHelper.java
index 71cc1e4..f17766b 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsScrollViewPerformanceHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsScrollViewPerformanceHelper.java
@@ -38,6 +38,10 @@
     private int mFadingEdgeLength;
     private boolean mIsVertical;
     private boolean mSoftwareRendered = false;
+    private Paint mBlackPaint;
+    private Paint mFadePaint;
+    private Matrix mFadeMatrix;
+    private LinearGradient mFade;
 
     public static RecentsScrollViewPerformanceHelper create(Context context,
             AttributeSet attrs, View scrollView, boolean isVertical) {
@@ -81,18 +85,19 @@
     public void drawCallback(Canvas canvas,
             int left, int right, int top, int bottom, int scrollX, int scrollY,
             float topFadingEdgeStrength, float bottomFadingEdgeStrength,
-            float leftFadingEdgeStrength, float rightFadingEdgeStrength) {
+            float leftFadingEdgeStrength, float rightFadingEdgeStrength, int mPaddingTop) {
 
         if ((mSoftwareRendered && OPTIMIZE_SW_RENDERED_RECENTS)
                 || USE_DARK_FADE_IN_HW_ACCELERATED_MODE) {
-            Paint p = new Paint();
-            Matrix matrix = new Matrix();
-            // use use a height of 1, and then wack the matrix each time we
-            // actually use it.
-            Shader fade = new LinearGradient(0, 0, 0, 1, 0xCC000000, 0, Shader.TileMode.CLAMP);
-            // PULL OUT THIS CONSTANT
-
-            p.setShader(fade);
+            if (mFadePaint == null) {
+                mFadePaint = new Paint();
+                mFadeMatrix = new Matrix();
+                // use use a height of 1, and then wack the matrix each time we
+                // actually use it.
+                mFade = new LinearGradient(0, 0, 0, 1, 0xCC000000, 0, Shader.TileMode.CLAMP);
+                // PULL OUT THIS CONSTANT
+                mFadePaint.setShader(mFade);
+            }
 
             // draw the fade effect
             boolean drawTop = false;
@@ -134,34 +139,41 @@
             }
 
             if (drawTop) {
-                matrix.setScale(1, fadeHeight * topFadeStrength);
-                matrix.postTranslate(left, top);
-                fade.setLocalMatrix(matrix);
-                canvas.drawRect(left, top, right, top + length, p);
+                mFadeMatrix.setScale(1, fadeHeight * topFadeStrength);
+                mFadeMatrix.postTranslate(left, top);
+                mFade.setLocalMatrix(mFadeMatrix);
+                canvas.drawRect(left, top, right, top + length, mFadePaint);
+
+                if (mBlackPaint == null) {
+                    // Draw under the status bar at the top
+                    mBlackPaint = new Paint();
+                    mBlackPaint.setColor(0xFF000000);
+                }
+                canvas.drawRect(left, top - mPaddingTop, right, top, mBlackPaint);
             }
 
             if (drawBottom) {
-                matrix.setScale(1, fadeHeight * bottomFadeStrength);
-                matrix.postRotate(180);
-                matrix.postTranslate(left, bottom);
-                fade.setLocalMatrix(matrix);
-                canvas.drawRect(left, bottom - length, right, bottom, p);
+                mFadeMatrix.setScale(1, fadeHeight * bottomFadeStrength);
+                mFadeMatrix.postRotate(180);
+                mFadeMatrix.postTranslate(left, bottom);
+                mFade.setLocalMatrix(mFadeMatrix);
+                canvas.drawRect(left, bottom - length, right, bottom, mFadePaint);
             }
 
             if (drawLeft) {
-                matrix.setScale(1, fadeHeight * leftFadeStrength);
-                matrix.postRotate(-90);
-                matrix.postTranslate(left, top);
-                fade.setLocalMatrix(matrix);
-                canvas.drawRect(left, top, left + length, bottom, p);
+                mFadeMatrix.setScale(1, fadeHeight * leftFadeStrength);
+                mFadeMatrix.postRotate(-90);
+                mFadeMatrix.postTranslate(left, top);
+                mFade.setLocalMatrix(mFadeMatrix);
+                canvas.drawRect(left, top, left + length, bottom, mFadePaint);
             }
 
             if (drawRight) {
-                matrix.setScale(1, fadeHeight * rightFadeStrength);
-                matrix.postRotate(90);
-                matrix.postTranslate(right, top);
-                fade.setLocalMatrix(matrix);
-                canvas.drawRect(right - length, top, right, bottom, p);
+                mFadeMatrix.setScale(1, fadeHeight * rightFadeStrength);
+                mFadeMatrix.postRotate(90);
+                mFadeMatrix.postTranslate(right, top);
+                mFade.setLocalMatrix(mFadeMatrix);
+                canvas.drawRect(right - length, top, right, bottom, mFadePaint);
             }
         }
     }
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
index b3adbaf..403c643f 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
@@ -21,6 +21,7 @@
 import android.content.res.Configuration;
 import android.database.DataSetObserver;
 import android.graphics.Canvas;
+import android.graphics.Paint;
 import android.util.AttributeSet;
 import android.util.DisplayMetrics;
 import android.util.FloatMath;
@@ -68,7 +69,7 @@
     }
 
     private int scrollPositionOfMostRecent() {
-        return mLinearLayout.getHeight() - getHeight();
+        return mLinearLayout.getHeight() - getHeight() + mPaddingTop;
     }
 
     private void addToRecycledViews(View v) {
@@ -265,7 +266,7 @@
             mPerformanceHelper.drawCallback(canvas,
                     left, right, top, bottom, mScrollX, mScrollY,
                     getTopFadingEdgeStrength(), getBottomFadingEdgeStrength(),
-                    0, 0);
+                    0, 0, mPaddingTop);
         }
     }