Make photo and delete icons fit within the chip background.

Fixes bug:5289589 Chip thumbnail image should not extend outside the chip

Change-Id: I8191c52a531b47e45073a9a08b879051ec10af37
diff --git a/res/drawable-hdpi/chip_background_selected.9.png b/res/drawable-hdpi/chip_background_selected.9.png
index ef13a16..e05657f 100644
--- a/res/drawable-hdpi/chip_background_selected.9.png
+++ b/res/drawable-hdpi/chip_background_selected.9.png
Binary files differ
diff --git a/res/drawable-mdpi/chip_background_selected.9.png b/res/drawable-mdpi/chip_background_selected.9.png
index 33d8f86..308fa03 100644
--- a/res/drawable-mdpi/chip_background_selected.9.png
+++ b/res/drawable-mdpi/chip_background_selected.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/chip_background_selected.9.png b/res/drawable-xhdpi/chip_background_selected.9.png
index 7b846c4..abed86a 100644
--- a/res/drawable-xhdpi/chip_background_selected.9.png
+++ b/res/drawable-xhdpi/chip_background_selected.9.png
Binary files differ
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index 933c608..17a928f 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -382,7 +382,12 @@
             canvas.drawText(ellipsizedText, 0, ellipsizedText.length(), mChipPadding,
                     getTextYOffset((String) ellipsizedText, paint, height), paint);
             // Make the delete a square.
-            mChipDelete.setBounds(width - deleteWidth, 0, width, height);
+            Rect backgroundPadding = new Rect();
+            mChipBackgroundPressed.getPadding(backgroundPadding);
+            mChipDelete.setBounds(width - deleteWidth + backgroundPadding.left,
+                    0 + backgroundPadding.top,
+                    width - backgroundPadding.right,
+                    height - backgroundPadding.bottom);
             mChipDelete.draw(canvas);
         } else {
             Log.w(TAG, "Unable to draw a background for the chips as it was never set");
@@ -390,7 +395,6 @@
         return tmpBitmap;
     }
 
-
     /**
      * Get the background drawable for a RecipientChip.
      */
@@ -446,8 +450,13 @@
                 // Draw the photo on the left side.
                 Matrix matrix = new Matrix();
                 RectF src = new RectF(0, 0, photo.getWidth(), photo.getHeight());
-                RectF dst = new RectF(width - iconWidth, 0, width, height);
-                matrix.setRectToRect(src, dst, Matrix.ScaleToFit.CENTER);
+                Rect backgroundPadding = new Rect();
+                mChipBackground.getPadding(backgroundPadding);
+                RectF dst = new RectF(width - iconWidth + backgroundPadding.left,
+                        0 + backgroundPadding.top,
+                        width - backgroundPadding.right,
+                        height - backgroundPadding.bottom);
+                matrix.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
                 canvas.drawBitmap(photo, matrix, paint);
             } else {
                 // Don't leave any space for the icon. It isn't being drawn.