summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2016-10-25 11:21:38 -0700
committerSteve Kondik <steve@cyngn.com>2016-10-25 11:21:38 -0700
commit51290b64aec766c261d36cd14644faa69e60872f (patch)
tree6a0c333f52258f4fe55062c8a275566081a60062
parentfe2b8c363c0c79f151419df197afad1dfe318718 (diff)
parente140d79a2a9e023710c0a880027cd8944f8b2485 (diff)
downloadandroid_frameworks_opt_chips-cm-14.1_prerebase.tar.gz
android_frameworks_opt_chips-cm-14.1_prerebase.tar.bz2
android_frameworks_opt_chips-cm-14.1_prerebase.zip
Merge tag 'android-7.1.0_r4' of https://android.googlesource.com/platform/frameworks/opt/chips into 71cm-14.1_prerebase
Android 7.1.0 release 4
-rw-r--r--res/values-my-rMM/strings.xml2
-rw-r--r--src/com/android/ex/chips/RecipientEditTextView.java25
-rw-r--r--src/com/android/ex/chips/RecipientEntry.java21
3 files changed, 33 insertions, 15 deletions
diff --git a/res/values-my-rMM/strings.xml b/res/values-my-rMM/strings.xml
index 52d6ab6..1bfd7c7 100644
--- a/res/values-my-rMM/strings.xml
+++ b/res/values-my-rMM/strings.xml
@@ -24,6 +24,6 @@
<string name="accessbility_suggestion_dropdown_closed" msgid="5545766162855459747">"အကြံပြုချက်များ မရှိပါ"</string>
<string name="dropdown_delete_button_desc" msgid="8506791557733906887">"လက်ခံသူများ မှ<xliff:g id="CONTACT">%s</xliff:g> အားဖယ်ရှားရန်"</string>
<string name="chips_action_copy" msgid="1929144660075507103">"ကူးယူရန်"</string>
- <string name="chips_action_cancel" msgid="6077877438943543501">"မလုပ်တော့ပါ"</string>
+ <string name="chips_action_cancel" msgid="6077877438943543501">"မလုပ်တော့"</string>
<string name="chips_permission_text" msgid="1978301259208877495">"အဆက်အသွယ်အကြံပြုချက်များကို ခွင့်ပြုမည်"</string>
</resources>
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index ab9a804..3f3dab2 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -831,8 +831,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);
@@ -842,7 +843,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
@@ -891,6 +892,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;
}
@@ -1558,18 +1560,17 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
private boolean commitChip(int start, int end, Editable editable) {
int position = positionOfFirstEntryWithTypePerson();
if (position != -1 && enoughToFilter()
- && end == getSelectionEnd() && !isPhoneQuery()) {
+ && end == getSelectionEnd() && !isPhoneQuery()
+ && !isValidEmailAddress(editable.toString().substring(start, end).trim())) {
// let's choose the selected or first entry if only the input text is NOT an email
// address so we won't try to replace the user's potentially correct but
// new/unencountered email input
- if (!isValidEmailAddress(editable.toString().substring(start, end).trim())) {
- final int selectedPosition = getListSelection();
- if (selectedPosition == -1 || !isEntryAtPositionTypePerson(selectedPosition)) {
- // Nothing is selected or selected item is not type person; use the first item
- submitItemAtPosition(position);
- } else {
- submitItemAtPosition(selectedPosition);
- }
+ final int selectedPosition = getListSelection();
+ if (selectedPosition == -1 || !isEntryAtPositionTypePerson(selectedPosition)) {
+ // Nothing is selected or selected item is not type person; use the first item
+ submitItemAtPosition(position);
+ } else {
+ submitItemAtPosition(selectedPosition);
}
dismissDropDown();
return true;
diff --git a/src/com/android/ex/chips/RecipientEntry.java b/src/com/android/ex/chips/RecipientEntry.java
index 974ffb5..c312771 100644
--- a/src/com/android/ex/chips/RecipientEntry.java
+++ b/src/com/android/ex/chips/RecipientEntry.java
@@ -81,6 +81,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;
/**
@@ -99,9 +101,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;
@@ -112,6 +123,7 @@ public class RecipientEntry {
mDirectoryId = directoryId;
mDataId = dataId;
mPhotoThumbnailUri = photoThumbnailUri;
+ mShouldDisplayIcon = shouldDisplayIcon;
mPhotoBytes = null;
mIsValid = isValid;
mLookupKey = lookupKey;
@@ -290,6 +302,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;