summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandeep Siddhartha <sansid@google.com>2016-07-29 18:38:10 -0700
committerSandeep Siddhartha <sansid@google.com>2016-07-31 12:19:21 -0700
commita233af88e381e4a8caf917176974aeb0aa259c19 (patch)
treee816d76cf0ed8f3237a668e63d4c6f4a76ff8c47
parent238ff9497310493b926476e862128900d6e71200 (diff)
downloadchips-a233af88e381e4a8caf917176974aeb0aa259c19.tar.gz
Support not displaying an icon in chips
Change-Id: Ia570791e3b01cef1e0758c6d4ae5a91ccc694eaf BUG: 28095750
-rw-r--r--src/com/android/ex/chips/RecipientEditTextView.java8
-rw-r--r--src/com/android/ex/chips/RecipientEntry.java21
2 files changed, 24 insertions, 5 deletions
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index 0099ff1..fd817db 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -797,8 +797,9 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
// 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);
@@ -808,7 +809,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
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
@@ -857,6 +858,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
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 78895e2..dc08dd7 100644
--- a/src/com/android/ex/chips/RecipientEntry.java
+++ b/src/com/android/ex/chips/RecipientEntry.java
@@ -76,6 +76,8 @@ public class RecipientEntry {
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 @@ public class RecipientEntry {
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 @@ public class RecipientEntry {
mDirectoryId = directoryId;
mDataId = dataId;
mPhotoThumbnailUri = photoThumbnailUri;
+ mShouldDisplayIcon = shouldDisplayIcon;
mPhotoBytes = null;
mIsValid = isValid;
mLookupKey = lookupKey;
@@ -263,6 +275,11 @@ public class RecipientEntry {
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;