summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEkin Oguz <ekinoguz@google.com>2016-06-22 17:17:39 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-06-22 17:17:39 +0000
commit84dcfd8d3313779adc8a2b4f8e69de1f6a91d683 (patch)
treee812106d0f2f6c8aa6e1dd5e7534d772248dd23d
parentfea2a5b25f09cd5340951c042b7aef9bb11db8a2 (diff)
parent1a68eb2ed0497378aa39080e3ba54ddf5eff7214 (diff)
downloadchips-84dcfd8d3313779adc8a2b4f8e69de1f6a91d683.tar.gz
Add a function to get recipients under more span.nougat-dev
am: 1a68eb2ed0 Change-Id: I617462a3e9bda280d59425c393f6ff77d4d5520b
-rw-r--r--src/com/android/ex/chips/RecipientEditTextView.java44
1 files changed, 30 insertions, 14 deletions
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index a27449a..f7c6781 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -192,7 +192,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
// VisibleForTesting
ArrayList<DrawableRecipientChip> mTemporaryRecipients;
- private ArrayList<DrawableRecipientChip> mRemovedSpans;
+ private ArrayList<DrawableRecipientChip> mHiddenSpans;
// Chip copy fields.
private GestureDetector mGestureDetector;
@@ -477,6 +477,22 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
return results;
}
+ /**
+ * @return The list of {@link RecipientEntry}s that have been selected by the user and also
+ * hidden due to {@link #mMoreChip} span.
+ */
+ public List<RecipientEntry> getAllRecipients() {
+ List<RecipientEntry> results = getSelectedRecipients();
+
+ if (mHiddenSpans != null) {
+ for (DrawableRecipientChip chip : mHiddenSpans) {
+ results.add(chip.getEntry());
+ }
+ }
+
+ return results;
+ }
+
@Override
public void onSelectionChanged(int start, int end) {
// When selection changes, see if it is inside the chips area.
@@ -2205,12 +2221,12 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
int numRecipients = recipients.length;
int overage = numRecipients - CHIP_LIMIT;
MoreImageSpan moreSpan = createMoreSpan(overage);
- mRemovedSpans = new ArrayList<DrawableRecipientChip>();
+ mHiddenSpans = new ArrayList<DrawableRecipientChip>();
int totalReplaceStart = 0;
int totalReplaceEnd = 0;
Editable text = getText();
for (int i = numRecipients - overage; i < recipients.length; i++) {
- mRemovedSpans.add(recipients[i]);
+ mHiddenSpans.add(recipients[i]);
if (i == numRecipients - overage) {
totalReplaceStart = spannable.getSpanStart(recipients[i]);
}
@@ -2249,9 +2265,9 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
Spannable span = getSpannable();
span.removeSpan(mMoreChip);
mMoreChip = null;
- // Re-add the spans that were removed.
- if (mRemovedSpans != null && mRemovedSpans.size() > 0) {
- // Recreate each removed span.
+ // Re-add the spans that were hidden.
+ if (mHiddenSpans != null && mHiddenSpans.size() > 0) {
+ // Recreate each hidden span.
DrawableRecipientChip[] recipients = getSortedRecipients();
// Start the search for tokens after the last currently visible
// chip.
@@ -2260,13 +2276,13 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
}
int end = span.getSpanEnd(recipients[recipients.length - 1]);
Editable editable = getText();
- for (DrawableRecipientChip chip : mRemovedSpans) {
+ for (DrawableRecipientChip chip : mHiddenSpans) {
int chipStart;
int chipEnd;
String token;
// Need to find the location of the chip, again.
token = (String) chip.getOriginalText();
- // As we find the matching recipient for the remove spans,
+ // As we find the matching recipient for the hidden spans,
// reduce the size of the string we need to search.
// That way, if there are duplicates, we always find the correct
// recipient.
@@ -2278,7 +2294,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
- mRemovedSpans.clear();
+ mHiddenSpans.clear();
}
}
}
@@ -2527,7 +2543,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
}
private boolean chipsPending() {
- return mPendingChipsCount > 0 || (mRemovedSpans != null && mRemovedSpans.size() > 0);
+ return mPendingChipsCount > 0 || (mHiddenSpans != null && mHiddenSpans.size() > 0);
}
@Override
@@ -2828,8 +2844,8 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
new ArrayList<DrawableRecipientChip>();
final DrawableRecipientChip[] existingChips = getSortedRecipients();
Collections.addAll(originalRecipients, existingChips);
- if (mRemovedSpans != null) {
- originalRecipients.addAll(mRemovedSpans);
+ if (mHiddenSpans != null) {
+ originalRecipients.addAll(mHiddenSpans);
}
final List<DrawableRecipientChip> replacements =
@@ -2859,8 +2875,8 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
new ArrayList<DrawableRecipientChip>();
DrawableRecipientChip[] existingChips = getSortedRecipients();
Collections.addAll(recipients, existingChips);
- if (mRemovedSpans != null) {
- recipients.addAll(mRemovedSpans);
+ if (mHiddenSpans != null) {
+ recipients.addAll(mHiddenSpans);
}
ArrayList<String> addresses = new ArrayList<String>();
for (DrawableRecipientChip chip : recipients) {