Various tweaks to launcher

- Removing hotdog for shadow bg protection
- Adding bg protection for customization tray
- Restoring holographic outlines for all apps
- Small bug fixes

Change-Id: I58d81bb490f78c76fcaf46122febc3c1aace854e
diff --git a/res/drawable-hdpi/focused_application_background.9.png b/res/drawable-hdpi/focused_application_background.9.png
index ac67b06..01c83c3 100644
--- a/res/drawable-hdpi/focused_application_background.9.png
+++ b/res/drawable-hdpi/focused_application_background.9.png
Binary files differ
diff --git a/res/drawable-hdpi/pressed_application_background.9.png b/res/drawable-hdpi/pressed_application_background.9.png
index fdb064a..c7d0bd4 100644
--- a/res/drawable-hdpi/pressed_application_background.9.png
+++ b/res/drawable-hdpi/pressed_application_background.9.png
Binary files differ
diff --git a/res/drawable-mdpi/focused_application_background.9.png b/res/drawable-mdpi/focused_application_background.9.png
index 259f122..341a80b 100644
--- a/res/drawable-mdpi/focused_application_background.9.png
+++ b/res/drawable-mdpi/focused_application_background.9.png
Binary files differ
diff --git a/res/drawable-mdpi/pressed_application_background.9.png b/res/drawable-mdpi/pressed_application_background.9.png
index 754af48..4b00eec 100644
--- a/res/drawable-mdpi/pressed_application_background.9.png
+++ b/res/drawable-mdpi/pressed_application_background.9.png
Binary files differ
diff --git a/res/layout-xlarge-land/launcher.xml b/res/layout-xlarge-land/launcher.xml
index 7b66d7c..e421e07 100644
--- a/res/layout-xlarge-land/launcher.xml
+++ b/res/layout-xlarge-land/launcher.xml
@@ -161,7 +161,7 @@
     </RelativeLayout>
 
     <TabHost
-        android:id="@android:id/tabhost"
+        android:id="@+id/customization_drawer"
         android:layout_width="match_parent"
         android:layout_height="480dp"
         android:layout_gravity="bottom">
diff --git a/res/layout-xlarge-port/launcher.xml b/res/layout-xlarge-port/launcher.xml
index c5691b8..d9839da 100644
--- a/res/layout-xlarge-port/launcher.xml
+++ b/res/layout-xlarge-port/launcher.xml
@@ -174,7 +174,7 @@
     </RelativeLayout>
 
     <TabHost
-        android:id="@android:id/tabhost"
+        android:id="@+id/customization_drawer"
         android:layout_width="match_parent"
         android:layout_height="800dp"
         android:layout_gravity="bottom">
diff --git a/res/layout-xlarge/all_apps_paged_view_application.xml b/res/layout-xlarge/all_apps_paged_view_application.xml
index a080bcec..e5f07bf 100644
--- a/res/layout-xlarge/all_apps_paged_view_application.xml
+++ b/res/layout-xlarge/all_apps_paged_view_application.xml
@@ -20,8 +20,6 @@
 
     launcher:blurColor="#FF6B8CF0"
     launcher:outlineColor="#FF8CD2FF"
-    launcher:checkedBlurColor="#FFBBE83C"
-    launcher:checkedOutlineColor="#FF8CD2FF"
 
     android:id="@+id/application_icon"
     android:layout_width="match_parent"
diff --git a/res/layout-xlarge/customize_paged_view_item.xml b/res/layout-xlarge/customize_paged_view_item.xml
index 35e06c3..b2e5f08 100644
--- a/res/layout-xlarge/customize_paged_view_item.xml
+++ b/res/layout-xlarge/customize_paged_view_item.xml
@@ -20,8 +20,6 @@
 
     launcher:blurColor="#FF6B8CF0"
     launcher:outlineColor="#FF8CD2FF"
-    launcher:checkedBlurColor="#FFBBE83C"
-    launcher:checkedOutlineColor="#FF8CD2FF"
 
     android:id="@+id/customize_icon"
     android:layout_width="match_parent"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 3373869..5e6a2ab 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -68,10 +68,6 @@
         <attr name="blurColor" format="color" />
         <!-- The outline color of the holographic outline -->
         <attr name="outlineColor" format="color" />
-        <!-- The checked blur color of the holographic outline -->
-        <attr name="checkedBlurColor" format="color" />
-        <!-- The checked outline color of the holographic outline -->
-        <attr name="checkedOutlineColor" format="color" />
     </declare-styleable>
 
     <!-- PagedViewWidget specific attributes. These attributes are used to
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java
index 855f261..995877b 100644
--- a/src/com/android/launcher2/BubbleTextView.java
+++ b/src/com/android/launcher2/BubbleTextView.java
@@ -36,6 +36,11 @@
  */
 public class BubbleTextView extends CacheableTextView {
     static final float CORNER_RADIUS = 4.0f;
+    static final float SHADOW_LARGE_RADIUS = 4.0f;
+    static final float SHADOW_SMALL_RADIUS = 1.75f;
+    static final float SHADOW_Y_OFFSET = 2.0f;
+    static final int SHADOW_LARGE_COLOUR = 0xCC000000;
+    static final int SHADOW_SMALL_COLOUR = 0xBB000000;
     static final float PADDING_H = 8.0f;
     static final float PADDING_V = 3.0f;
 
@@ -83,11 +88,17 @@
         mPaddingV = PADDING_V * scale;
     }
 
-    protected int getVerticalPadding() {
+    protected int getCacheTopPadding() {
         return (int) PADDING_V;
     }
-    protected int getHorizontalPadding() {
-        return (int) PADDING_H;
+    protected int getCacheBottomPadding() {
+        return (int) (PADDING_V + SHADOW_LARGE_RADIUS + SHADOW_Y_OFFSET);
+    }
+    protected int getCacheLeftPadding() {
+        return (int) (PADDING_H + SHADOW_LARGE_RADIUS);
+    }
+    protected int getCacheRightPadding() {
+        return (int) (PADDING_H + SHADOW_LARGE_RADIUS);
     }
 
     public void applyFromShortcutInfo(ShortcutInfo info, IconCache iconCache) {
@@ -126,41 +137,34 @@
 
     @Override
     public void draw(Canvas canvas) {
-        final Drawable background = mBackground;
-        if (background != null) {
-            final int scrollX = mScrollX;
-            final int scrollY = mScrollY;
+        if (isBuildingCache()) {
+            // We enhance the shadow by drawing the shadow twice
+            this.setShadowLayer(SHADOW_LARGE_RADIUS, 0.0f, SHADOW_Y_OFFSET, SHADOW_LARGE_COLOUR);
+            super.draw(canvas);
+            this.setShadowLayer(SHADOW_SMALL_RADIUS, 0.0f, 0.0f, SHADOW_SMALL_COLOUR);
+            super.draw(canvas);
+        } else {
+            final Drawable background = mBackground;
+            if (background != null) {
+                final int scrollX = mScrollX;
+                final int scrollY = mScrollY;
 
-            if (mBackgroundSizeChanged) {
-                background.setBounds(0, 0,  mRight - mLeft, mBottom - mTop);
-                mBackgroundSizeChanged = false;
+                if (mBackgroundSizeChanged) {
+                    background.setBounds(0, 0,  mRight - mLeft, mBottom - mTop);
+                    mBackgroundSizeChanged = false;
+                }
+
+                if ((scrollX | scrollY) == 0) {
+                    background.draw(canvas);
+                } else {
+                    canvas.translate(scrollX, scrollY);
+                    background.draw(canvas);
+                    canvas.translate(-scrollX, -scrollY);
+                }
             }
 
-            if ((scrollX | scrollY) == 0) {
-                background.draw(canvas);
-            } else {
-                canvas.translate(scrollX, scrollY);
-                background.draw(canvas);
-                canvas.translate(-scrollX, -scrollY);
-            }
+            super.draw(canvas);
         }
-
-        // Draw the hotdog bubble
-        final Layout layout = getLayout();
-        if (layout != null) {
-            final int offset = getExtendedPaddingTop();
-            final int paddingLeft = getPaddingLeft();
-            final int paddingRight = getPaddingRight();
-            final float left = layout.getLineLeft(0) + paddingLeft;
-            final float right = Math.min(layout.getLineRight(0) + paddingRight,
-                    left + getWidth() - paddingLeft - paddingRight);
-            mRect.set(left - mPaddingH, offset + (int) layout.getLineTop(0) - mPaddingV,
-                    right + mPaddingH, offset + (int) layout.getLineBottom(0) + mPaddingV);
-
-            canvas.drawRoundRect(mRect, mCornerRadius, mCornerRadius, mPaint);
-        }
-
-        super.draw(canvas);
     }
 
     @Override
diff --git a/src/com/android/launcher2/CacheableTextView.java b/src/com/android/launcher2/CacheableTextView.java
index 873cd4e..da2f302 100644
--- a/src/com/android/launcher2/CacheableTextView.java
+++ b/src/com/android/launcher2/CacheableTextView.java
@@ -20,8 +20,8 @@
 import android.graphics.Bitmap;
 import android.graphics.Bitmap.Config;
 import android.graphics.Canvas;
+import android.graphics.Color;
 import android.graphics.Paint;
-import android.graphics.Rect;
 import android.text.Layout;
 import android.util.AttributeSet;
 import android.widget.TextView;
@@ -60,10 +60,16 @@
         super(context, attrs, defStyle);
     }
 
-    protected int getVerticalPadding() {
+    protected int getCacheTopPadding() {
         return 0;
     }
-    protected int getHorizontalPadding() {
+    protected int getCacheLeftPadding() {
+        return 0;
+    }
+    protected int getCacheRightPadding() {
+        return 0;
+    }
+    protected int getCacheBottomPadding() {
         return 0;
     }
 
@@ -84,21 +90,21 @@
         final int top = getExtendedPaddingTop();
         final float prevAlpha = getAlpha();
 
-        int vPadding = getVerticalPadding();
-        int hPadding = getHorizontalPadding();
-
-        mTextCacheLeft = layout.getLineLeft(0) - hPadding;
-        mTextCacheTop = top + layout.getLineTop(0) - mPaddingV - vPadding;
+        mTextCacheLeft = layout.getLineLeft(0) - getCacheLeftPadding();
+        mTextCacheTop = top + layout.getLineTop(0) - mPaddingV - getCacheTopPadding();
 
         mRectLeft = mScrollX + getLeft();
         mRectTop = 0;
         mTextCacheScrollX = mScrollX;
 
         final float textCacheRight =
-            Math.min(left + layout.getLineRight(0) + mPaddingH, mScrollX + mRight - mLeft) + hPadding;
-        final float textCacheBottom = top + layout.getLineBottom(0) + mPaddingV + vPadding;
+            Math.min(left + layout.getLineRight(0) + mPaddingH, mScrollX + mRight - mLeft) +
+            getCacheRightPadding();
+        final float textCacheBottom = top + layout.getLineBottom(0) + mPaddingV +
+            getCacheBottomPadding();
+        final float xCharWidth = getPaint().measureText("x");
 
-        int width = (int) (textCacheRight - mTextCacheLeft);
+        int width = (int) (textCacheRight - mTextCacheLeft + (2 * xCharWidth));
         int height = (int) (textCacheBottom - mTextCacheTop);
 
         if (width != 0 && height != 0) {
@@ -150,6 +156,10 @@
         super.draw(canvas);
     }
 
+    protected boolean isBuildingCache() {
+        return mIsBuildingCache;
+    }
+
     @Override
     protected boolean onSetAlpha(int alpha) {
         if (mPrevAlpha != alpha) {
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index fd0ef51..daaf4be 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -139,6 +139,7 @@
         // A ViewGroup usually does not draw, but CellLayout needs to draw a rectangle to show
         // the user where a dragged item will land when dropped.
         setWillNotDraw(false);
+        setClipChildren(false);
 
         TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CellLayout, defStyle, 0);
 
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 0cb0e13..455b130 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -294,7 +294,7 @@
         checkForLocaleChange();
         setWallpaperDimension();
         setContentView(R.layout.launcher);
-        mHomeCustomizationDrawer = (TabHost) findViewById(com.android.internal.R.id.tabhost);
+        mHomeCustomizationDrawer = (TabHost) findViewById(R.id.customization_drawer);
         if (mHomeCustomizationDrawer != null) {
             mHomeCustomizationDrawer.setup();
 
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index 884884e..d91daf9 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -52,7 +52,7 @@
     private Object mIconCacheKey;
     private PagedViewIconCache mIconCache;
 
-    private int mAlpha;
+    private int mAlpha = 255;
     private int mHolographicAlpha;
 
     private boolean mIsChecked;
@@ -64,8 +64,6 @@
     // Highlight colors
     private int mHoloBlurColor;
     private int mHoloOutlineColor;
-    private int mCheckedBlurColor;
-    private int mCheckedOutlineColor;
 
     private static final HandlerThread sWorkerThread = new HandlerThread("pagedviewicon-helper");
     static {
@@ -110,11 +108,8 @@
         super(context, attrs, defStyle);
 
         TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedViewIcon, defStyle, 0);
-	mAlpha = 255;
         mHoloBlurColor = a.getColor(R.styleable.PagedViewIcon_blurColor, 0);
         mHoloOutlineColor = a.getColor(R.styleable.PagedViewIcon_outlineColor, 0);
-        mCheckedBlurColor = a.getColor(R.styleable.PagedViewIcon_checkedBlurColor, 0);
-        mCheckedOutlineColor = a.getColor(R.styleable.PagedViewIcon_checkedOutlineColor, 0);
         a.recycle();
 
         if (sHolographicOutlineHelper == null) {
@@ -126,14 +121,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 applyFromApplicationInfo(ApplicationInfo info, PagedViewIconCache cache,
@@ -248,7 +241,7 @@
             if (mCheckedAlphaAnimator != null) {
                 mCheckedAlphaAnimator.cancel();
             }
-            mCheckedAlphaAnimator = ObjectAnimator.ofFloat(this, "alpha", alpha);
+            mCheckedAlphaAnimator = ObjectAnimator.ofFloat(this, "alpha", getAlpha(), alpha);
             mCheckedAlphaAnimator.setDuration(duration);
             mCheckedAlphaAnimator.start();
 
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 705453d..06893e2 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -62,6 +62,7 @@
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.animation.DecelerateInterpolator;
+import android.widget.TabHost;
 import android.widget.TextView;
 import android.widget.Toast;
 
@@ -117,6 +118,11 @@
     private float mOverScrollMaxBackgroundAlpha = 0.0f;
     private int mOverScrollPageIndex = -1;
 
+    private View mCustomizationDrawer;
+    private View mCustomizationDrawerContent;
+    private int[] mCustomizationDrawerPos = new int[2];
+    private float[] mCustomizationDrawerTransformedPos = new float[2];
+
     private final WallpaperManager mWallpaperManager;
 
     private int mDefaultPage;
@@ -754,6 +760,21 @@
             mBackground.setBounds(mScrollX, 0, mScrollX + getMeasuredWidth(), getMeasuredHeight());
             mBackground.draw(canvas);
             if (mDrawCustomizeTrayBackground) {
+                // Find out where to offset the gradient for the customization tray content
+                mCustomizationDrawer.getLocationOnScreen(mCustomizationDrawerPos);
+                final Matrix m = mCustomizationDrawer.getMatrix();
+                mCustomizationDrawerTransformedPos[0] = 0.0f;
+                mCustomizationDrawerTransformedPos[1] = mCustomizationDrawerContent.getTop();
+                m.mapPoints(mCustomizationDrawerTransformedPos);
+
+                // Draw the bg gradient
+                final int  offset = (int) (mCustomizationDrawerPos[1] +
+                        mCustomizationDrawerTransformedPos[1]);
+                mBackground.setBounds(mScrollX, offset, mScrollX + getMeasuredWidth(),
+                        offset + getMeasuredHeight());
+                mBackground.draw(canvas);
+
+                // Draw the bg glow
                 mCustomizeTrayBackground.setAlpha(alpha);
                 mCustomizeTrayBackground.setBounds(mScrollX, 0, mScrollX + getMeasuredWidth(),
                         getMeasuredHeight());
@@ -2216,6 +2237,10 @@
     void setLauncher(Launcher launcher) {
         mLauncher = launcher;
         mSpringLoadedDragControllger = new SpringLoadedDragController(mLauncher);
+
+        mCustomizationDrawer = mLauncher.findViewById(R.id.customization_drawer);
+        mCustomizationDrawerContent =
+            mCustomizationDrawer.findViewById(com.android.internal.R.id.tabcontent);
     }
 
     public void setDragController(DragController dragController) {