Don't use textpaint for drawing icons

When drawing icons we set various shaders and
attributes to convert sq icon to circle. These
attributes are applied directly on the TextPaint
and are never reset. As a result, we see tiny fonts.

b/16700424

Change-Id: I9ffd07d64fa5c3dee6a5b312195e54559a73413d
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index aa330bd..cda8f58 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -171,6 +171,8 @@
     private static final int IMAGE_SPAN_ALIGNMENT_BASELINE = 1;
 
 
+    private Paint mWorkPaint = new Paint();
+
     private boolean mDisableDelete;
 
     private Tokenizer mTokenizer;
@@ -643,7 +645,7 @@
                 mChipBackgroundPressed, getResources().getColor(R.color.chip_background_selected));
 
         if (bitmapContainer.loadIcon) {
-            loadAvatarIcon(contact, bitmapContainer, paint);
+            loadAvatarIcon(contact, bitmapContainer);
         }
 
         return bitmapContainer.bitmap;
@@ -661,7 +663,7 @@
                 getChipBackground(contact), getDefaultChipBackgroundColor(contact));
 
         if (bitmapContainer.loadIcon) {
-            loadAvatarIcon(contact, bitmapContainer, paint);
+            loadAvatarIcon(contact, bitmapContainer);
         }
         return bitmapContainer.bitmap;
     }
@@ -735,12 +737,12 @@
     /**
      * Helper function that draws the loaded icon bitmap into the chips bitmap
      */
-    private void drawIcon(ChipBitmapContainer bitMapResult, Bitmap icon, Paint paint) {
+    private void drawIcon(ChipBitmapContainer bitMapResult, Bitmap icon) {
         final Canvas canvas = new Canvas(bitMapResult.bitmap);
         final RectF src = new RectF(0, 0, icon.getWidth(), icon.getHeight());
         final RectF dst = new RectF(bitMapResult.left, bitMapResult.top, bitMapResult.right,
                 bitMapResult.bottom);
-        drawIconOnCanvas(icon, canvas, paint, src, dst);
+        drawIconOnCanvas(icon, canvas, src, dst);
     }
 
     /**
@@ -761,7 +763,7 @@
      * draw an icon for this recipient.
      */
     private void loadAvatarIcon(final RecipientEntry contact,
-            final ChipBitmapContainer bitmapContainer, final Paint paint) {
+            final ChipBitmapContainer bitmapContainer) {
         // Don't draw photos for recipients that have been typed in OR generated on the fly.
         long contactId = contact.getContactId();
         boolean drawPhotos = isPhoneQuery() ?
@@ -798,7 +800,7 @@
                     }
 
                     private void tryDrawAndInvalidate(Bitmap icon) {
-                        drawIcon(bitmapContainer, icon, paint);
+                        drawIcon(bitmapContainer, icon);
                         // The caller might originated from a background task. However, if the
                         // background task has already completed, the view might be already drawn
                         // on the UI but the callback would happen on the background thread.
@@ -819,7 +821,7 @@
             } else {
                 final Bitmap icon = BitmapFactory.decodeByteArray(origPhotoBytes, 0,
                         origPhotoBytes.length);
-                drawIcon(bitmapContainer, icon, paint);
+                drawIcon(bitmapContainer, icon);
             }
         }
     }
@@ -848,7 +850,7 @@
      * Draws the icon onto the canvas given the source rectangle of the bitmap and the destination
      * rectangle of the canvas.
      */
-    protected void drawIconOnCanvas(Bitmap icon, Canvas canvas, Paint paint, RectF src, RectF dst) {
+    protected void drawIconOnCanvas(Bitmap icon, Canvas canvas, RectF src, RectF dst) {
         final Matrix matrix = new Matrix();
 
         // Draw bitmap through shader first.
@@ -859,23 +861,23 @@
         matrix.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
 
         shader.setLocalMatrix(matrix);
-        paint.reset();
-        paint.setShader(shader);
-        paint.setAntiAlias(true);
-        paint.setFilterBitmap(true);
-        paint.setDither(true);
-        canvas.drawCircle(dst.centerX(), dst.centerY(), dst.width() / 2f, paint);
+        mWorkPaint.reset();
+        mWorkPaint.setShader(shader);
+        mWorkPaint.setAntiAlias(true);
+        mWorkPaint.setFilterBitmap(true);
+        mWorkPaint.setDither(true);
+        canvas.drawCircle(dst.centerX(), dst.centerY(), dst.width() / 2f, mWorkPaint);
 
         // Then draw the border.
         final float borderWidth = 1f;
-        paint.reset();
-        paint.setColor(Color.TRANSPARENT);
-        paint.setStyle(Style.STROKE);
-        paint.setStrokeWidth(borderWidth);
-        paint.setAntiAlias(true);
-        canvas.drawCircle(dst.centerX(), dst.centerY(), dst.width() / 2f - borderWidth / 2, paint);
+        mWorkPaint.reset();
+        mWorkPaint.setColor(Color.TRANSPARENT);
+        mWorkPaint.setStyle(Style.STROKE);
+        mWorkPaint.setStrokeWidth(borderWidth);
+        mWorkPaint.setAntiAlias(true);
+        canvas.drawCircle(dst.centerX(), dst.centerY(), dst.width() / 2f - borderWidth / 2, mWorkPaint);
 
-        paint.reset();
+        mWorkPaint.reset();
     }
 
     private DrawableRecipientChip constructChipSpan(RecipientEntry contact, boolean pressed) {