Support not displaying an icon in chips am: a233af88e3
am: abbbd82940

Change-Id: I325ae245388a3916d202a79eb47989ed4f2d5795
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index da9ef27..966325b 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -796,8 +796,9 @@
         // on the sides.
         int height = (int) mChipHeight;
         // Since the icon is a square, it's width is equal to the maximum height it can be inside
-        // the chip. Don't include iconWidth for invalid contacts.
-        int iconWidth = contact.isValid() ?
+        // the chip. Don't include iconWidth for invalid contacts and when not displaying photos.
+        boolean displayIcon = contact.isValid() && contact.shouldDisplayIcon();
+        int iconWidth = displayIcon ?
                 height - backgroundPadding.top - backgroundPadding.bottom : 0;
         float[] widths = new float[1];
         paint.getTextWidths(" ", widths);
@@ -807,7 +808,7 @@
         int textWidth = (int) paint.measureText(ellipsizedText, 0, ellipsizedText.length());
 
         // Chip start padding is the same as the end padding if there is no contact image.
-        final int startPadding = contact.isValid() ? mChipTextStartPadding : mChipTextEndPadding;
+        final int startPadding = displayIcon ? mChipTextStartPadding : mChipTextEndPadding;
         // Make sure there is a minimum chip width so the user can ALWAYS
         // tap a chip without difficulty.
         int width = Math.max(iconWidth * 2, textWidth + startPadding + mChipTextEndPadding
@@ -855,6 +856,7 @@
         result.top = backgroundPadding.top;
         result.right = iconX + iconWidth;
         result.bottom = height - backgroundPadding.bottom;
+        result.loadIcon = displayIcon;
 
         return result;
     }
diff --git a/src/com/android/ex/chips/RecipientEntry.java b/src/com/android/ex/chips/RecipientEntry.java
index 5610918..a8c8c02 100644
--- a/src/com/android/ex/chips/RecipientEntry.java
+++ b/src/com/android/ex/chips/RecipientEntry.java
@@ -76,6 +76,8 @@
     private final long mDataId;
 
     private final Uri mPhotoThumbnailUri;
+    /** Configures showing the icon in the chip */
+    private final boolean mShouldDisplayIcon;
 
     private boolean mIsValid;
     /**
@@ -94,9 +96,18 @@
     private final String[] mPermissions;
 
     protected RecipientEntry(int entryType, String displayName, String destination,
+        int destinationType, String destinationLabel, long contactId, Long directoryId,
+        long dataId, Uri photoThumbnailUri, boolean isFirstLevel, boolean isValid,
+        String lookupKey, String[] permissions) {
+        this(entryType, displayName, destination, destinationType,
+            destinationLabel, contactId, directoryId, dataId, photoThumbnailUri,
+            true /* shouldDisplayIcon */, isFirstLevel, isValid, lookupKey, permissions);
+    }
+
+    protected RecipientEntry(int entryType, String displayName, String destination,
             int destinationType, String destinationLabel, long contactId, Long directoryId,
-            long dataId, Uri photoThumbnailUri, boolean isFirstLevel, boolean isValid,
-            String lookupKey, String[] permissions) {
+            long dataId, Uri photoThumbnailUri, boolean shouldDisplayIcon,
+            boolean isFirstLevel, boolean isValid, String lookupKey, String[] permissions) {
         mEntryType = entryType;
         mIsFirstLevel = isFirstLevel;
         mDisplayName = displayName;
@@ -107,6 +118,7 @@
         mDirectoryId = directoryId;
         mDataId = dataId;
         mPhotoThumbnailUri = photoThumbnailUri;
+        mShouldDisplayIcon = shouldDisplayIcon;
         mPhotoBytes = null;
         mIsValid = isValid;
         mLookupKey = lookupKey;
@@ -272,6 +284,11 @@
         return mPhotoThumbnailUri;
     }
 
+    /** Indicates whether the icon in the chip is displayed or not. */
+    public boolean shouldDisplayIcon() {
+        return mShouldDisplayIcon;
+    }
+
     /** This can be called outside main Looper thread. */
     public synchronized void setPhotoBytes(byte[] photoBytes) {
         mPhotoBytes = photoBytes;