Caching icon labels to bitmaps for better performance

Change-Id: I78a3c116c1103b5b994a47f2cfcff18c0a9b31b8
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java
index f4a3d44..6039307 100644
--- a/src/com/android/launcher2/BubbleTextView.java
+++ b/src/com/android/launcher2/BubbleTextView.java
@@ -19,6 +19,7 @@
 import android.widget.TextView;
 import android.content.Context;
 import android.util.AttributeSet;
+import android.graphics.Bitmap;
 import android.graphics.Canvas;
 import android.graphics.Paint;
 import android.graphics.RectF;
@@ -32,7 +33,7 @@
  * because we want to make the bubble taller than the text and TextView's clip is
  * too aggressive.
  */
-public class BubbleTextView extends TextView {
+public class BubbleTextView extends CacheableTextView {
     static final float CORNER_RADIUS = 8.0f;
     static final float PADDING_H = 5.0f;
     static final float PADDING_V = 1.0f;
@@ -77,6 +78,18 @@
         mPaddingV = PADDING_V * scale;
     }
 
+    public void applyFromShortcutInfo(ShortcutInfo info, IconCache iconCache) {
+        Bitmap b = info.getIcon(iconCache);
+
+        setCompoundDrawablesWithIntrinsicBounds(null,
+                new FastBitmapDrawable(b),
+                null, null);
+        setText(info.title);
+        buildAndEnableCache();
+        setTag(info);
+
+    }
+
     @Override
     protected boolean setFrame(int left, int top, int right, int bottom) {
         if (mLeft != left || mRight != right || mTop != top || mBottom != bottom) {
@@ -129,7 +142,9 @@
                 top + layout.getLineTop(0) -  mPaddingV,
                 Math.min(left + layout.getLineRight(0) + mPaddingH, mScrollX + mRight - mLeft),
                 top + layout.getLineBottom(0) + mPaddingV);
-        canvas.drawRoundRect(rect, mCornerRadius, mCornerRadius, mPaint);
+        // TEMPORARILY DISABLE DRAWING ROUND RECT -- re-enable this when we tweak CacheableTextView
+        // to support padding so we can capture the "rounded" edges
+        //canvas.drawRoundRect(rect, mCornerRadius, mCornerRadius, mPaint);
 
         super.draw(canvas);
     }