summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandeep Siddhartha <sansid@google.com>2016-07-31 22:09:23 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-07-31 22:09:23 +0000
commitabbbd829406392d14925f124e985058232403778 (patch)
treeb04af436a3996fecb061d539fd2e32391045a2f3
parent36677c72d16003d6bbafe31a532dcce03c15b60c (diff)
parenta233af88e381e4a8caf917176974aeb0aa259c19 (diff)
downloadchips-abbbd829406392d14925f124e985058232403778.tar.gz
Support not displaying an icon in chips
am: a233af88e3 Change-Id: I8aba69b3a641c009636c6e6797034eb86ac8b84c
-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 da9ef27..966325b 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -796,8 +796,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);
@@ -807,7 +808,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
@@ -855,6 +856,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 5610918..a8c8c02 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;
@@ -272,6 +284,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;