Fixing issue with customize page holographic previews not showing.

- Adding temporary workaround for bad holographic default widget previews.

Change-Id: I261045beac3791111f928511435e17e320f2d4a7
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 856507d..8483f95 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -595,20 +595,14 @@
             int rightScreen = 0;
             while (x <= mScrollX) {
                 leftScreen++;
-                x += pageWidth + mPageSpacing;
-                // replace above line with this if you don't assume all pages have same width as 0th
-                // page:
-                // x += getScaledMeasuredWidth(getChildAt(leftScreen));
+                x += getScaledMeasuredWidth(getChildAt(leftScreen)) + mPageSpacing;
             }
             rightScreen = leftScreen;
-            while (x < mScrollX + screenWidth) {
+            while (x < mScrollX + screenWidth && rightScreen < pageCount) {
                 rightScreen++;
-                x += pageWidth + mPageSpacing;
-                // replace above line with this if you don't assume all pages have same width as 0th
-                // page:
-                //if (rightScreen < pageCount) {
-                //    x += getScaledMeasuredWidth(getChildAt(rightScreen));
-                //}
+                if (rightScreen < pageCount) {
+                    x += getScaledMeasuredWidth(getChildAt(rightScreen)) + mPageSpacing;
+                }
             }
             rightScreen = Math.min(getChildCount() - 1, rightScreen);
 
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java
index 89ed0ec..5f5844f 100644
--- a/src/com/android/launcher2/PagedViewWidget.java
+++ b/src/com/android/launcher2/PagedViewWidget.java
@@ -25,6 +25,8 @@
 import android.graphics.Canvas;
 import android.graphics.Color;
 import android.graphics.Paint;
+import android.graphics.PorterDuffXfermode;
+import android.graphics.PorterDuff.Mode;
 import android.graphics.drawable.Drawable;
 import android.os.Handler;
 import android.os.HandlerThread;
@@ -78,6 +80,8 @@
             widget.mPreview.setAlpha(255);
             widget.mPreview.draw(widget.mHolographicOutlineCanvas);
             widget.mPreview.setAlpha(prevAlpha);
+            // Temporary workaround to make the default widget outlines visible
+            widget.mHolographicOutlineCanvas.drawColor(Color.argb(156, 0, 0, 0), Mode.SRC_OVER);
             widget.mHolographicOutlineCanvas.restore();
 
             sHolographicOutlineHelper.applyThickExpensiveOutlineWithBlur(outline,
@@ -120,14 +124,12 @@
     }
 
     private void queueHolographicOutlineCreation() {
-        /* Temporarily disabling holographic outline creation.
         // Generate the outline in the background
         if (mHolographicOutline == null) {
             Message m = sWorker.obtainMessage(MESSAGE_CREATE_HOLOGRAPHIC_OUTLINE);
             m.obj = this;
             sWorker.sendMessage(m);
         }
-        */
     }
 
     public void applyFromAppWidgetProviderInfo(AppWidgetProviderInfo info,