Fixing boot stall.
Revert "-Added 3D effect to home screen scrolling"

This reverts commit 9415d87eda0cf28b8df1eccde39b0ca1646be3b9.

Change-Id: Ib8d6602f5d82884eb1f6cc44c0cc71cc563a3a59
diff --git a/src/com/android/launcher2/DimmableBubbleTextView.java b/src/com/android/launcher2/DimmableBubbleTextView.java
index cb3b8ef..66cc97a 100644
--- a/src/com/android/launcher2/DimmableBubbleTextView.java
+++ b/src/com/android/launcher2/DimmableBubbleTextView.java
@@ -21,17 +21,18 @@
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
+import android.graphics.Color;
 import android.graphics.Paint;
 import android.graphics.PorterDuff;
 import android.util.AttributeSet;
 
-public class DimmableBubbleTextView extends BubbleTextView implements Dimmable {
+public class DimmableBubbleTextView extends BubbleTextView {
     private  Paint mDimmedPaint = new Paint();
     private int mAlpha;
+    private int mDimmedAlpha;
     private Bitmap mDimmedView;
     private Canvas mDimmedViewCanvas;
     private boolean isDimmedViewUpdatePass;
-    private float mDimmableProgress;
 
     public DimmableBubbleTextView(Context context) {
         super(context);
@@ -48,12 +49,48 @@
         mDimmedPaint.setFilterBitmap(true);
     }
 
-    public void setDimmableProgress(float progress) {
-        mDimmableProgress = progress;
+    private static float cubic(float r) {
+        return (float) (Math.pow(r-1, 3) + 1);
     }
 
-    public float getDimmableProgress() {
-        return mDimmableProgress;
+    /**
+     * Returns the interpolated holographic highlight alpha for the effect we want when scrolling
+     * pages.
+     */
+    public static float highlightAlphaInterpolator(float r) {
+        final float pivot = 0.3f;
+        if (r < pivot) {
+            return Math.max(0.5f, 0.65f*cubic(r/pivot));
+        } else {
+            return Math.min(1.0f, 0.65f*cubic(1 - (r-pivot)/(1-pivot)));
+        }
+    }
+
+    /**
+     * Returns the interpolated view alpha for the effect we want when scrolling pages.
+     */
+    public static float viewAlphaInterpolator(float r) {
+        final float pivot = 0.6f;
+        if (r < pivot) {
+            return r/pivot;
+        } else {
+            return 1.0f;
+        }
+    }
+
+    @Override
+    public boolean onSetAlpha(int alpha) {
+        super.onSetAlpha(alpha);
+        return true;
+    }
+
+    @Override
+    public void setAlpha(float alpha) {
+        final float viewAlpha = viewAlphaInterpolator(alpha);
+        final float dimmedAlpha = highlightAlphaInterpolator(alpha);
+        mAlpha = (int) (viewAlpha * 255);
+        mDimmedAlpha = (int) (dimmedAlpha * 255);
+        super.setAlpha(viewAlpha);
     }
 
     @Override
@@ -87,11 +124,13 @@
             super.setAlpha(alpha);
             canvas.restore();
         } else {
-            super.onDraw(canvas);
+            if (mAlpha > 0) {
+                super.onDraw(canvas);
+            }
         }
 
-        if (mDimmedView != null && mDimmableProgress > 0) {
-            mDimmedPaint.setAlpha((int) (mDimmableProgress * 255));
+        if (mDimmedView != null && mDimmedAlpha > 0) {
+            mDimmedPaint.setAlpha(mDimmedAlpha);
             canvas.drawBitmap(mDimmedView, mScrollX, mScrollY, mDimmedPaint);
         }
     }