summaryrefslogtreecommitdiffstats
path: root/chips/src/com/android/ex
diff options
context:
space:
mode:
authorScott Kennedy <skennedy@google.com>2013-02-19 11:04:01 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2013-02-19 11:04:01 -0800
commit438972e5da3a847e0717b4d030cb579f53195b43 (patch)
tree2860239be98af7313a5fedb293798d35e82b5d13 /chips/src/com/android/ex
parent58d61cab309ff1b5a62bc699ddb41118dc70c337 (diff)
parent2727f969d0ce46cdd16cd77e1dc21f3a636217d2 (diff)
downloadandroid_frameworks_ex-438972e5da3a847e0717b4d030cb579f53195b43.tar.gz
android_frameworks_ex-438972e5da3a847e0717b4d030cb579f53195b43.tar.bz2
android_frameworks_ex-438972e5da3a847e0717b4d030cb579f53195b43.zip
am 2727f969: Ensure all addresses turn into chips
* commit '2727f969d0ce46cdd16cd77e1dc21f3a636217d2': Ensure all addresses turn into chips
Diffstat (limited to 'chips/src/com/android/ex')
-rw-r--r--chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java23
-rw-r--r--chips/src/com/android/ex/chips/RecipientEditTextView.java36
2 files changed, 54 insertions, 5 deletions
diff --git a/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java b/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java
index 00f1ff4..49e2d5c 100644
--- a/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java
+++ b/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java
@@ -41,6 +41,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* RecipientAlternatesAdapter backs the RecipientEditTextView for managing contacts
@@ -63,7 +65,11 @@ public class RecipientAlternatesAdapter extends CursorAdapter {
private Query mQuery;
public interface RecipientMatchCallback {
- public void matchesFound(HashMap<String, RecipientEntry> results);
+ public void matchesFound(Map<String, RecipientEntry> results);
+ /**
+ * Called with all addresses that could not be resolved to valid recipients.
+ */
+ public void matchesNotFound(Set<String> addresses);
}
public static void getMatchingRecipients(Context context, ArrayList<String> inAddresses,
@@ -126,6 +132,7 @@ public class RecipientAlternatesAdapter extends CursorAdapter {
}
// See if any entries did not resolve; if so, we need to check other
// directories
+ final Set<String> matchesNotFound = new HashSet<String>();
if (recipientEntries.size() < addresses.size()) {
final List<DirectorySearchParams> paramsList;
Cursor directoryCursor = context.getContentResolver().query(DirectoryListQuery.URI,
@@ -139,6 +146,9 @@ public class RecipientAlternatesAdapter extends CursorAdapter {
unresolvedAddresses.add(address);
}
}
+
+ matchesNotFound.addAll(unresolvedAddresses);
+
Cursor directoryContactsCursor = null;
for (String unresolvedAddress : unresolvedAddresses) {
for (int i = 0; i < paramsList.size(); i++) {
@@ -158,13 +168,22 @@ public class RecipientAlternatesAdapter extends CursorAdapter {
}
if (directoryContactsCursor != null) {
try {
- callback.matchesFound(processContactEntries(directoryContactsCursor));
+ final Map<String, RecipientEntry> entries =
+ processContactEntries(directoryContactsCursor);
+
+ for (final String address : entries.keySet()) {
+ matchesNotFound.remove(address);
+ }
+
+ callback.matchesFound(entries);
} finally {
directoryContactsCursor.close();
}
}
}
}
+
+ callback.matchesNotFound(matchesNotFound);
}
private static HashMap<String, RecipientEntry> processContactEntries(Cursor c) {
diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java
index 998cf8d..f349262 100644
--- a/chips/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java
@@ -86,9 +86,9 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -2450,7 +2450,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
new RecipientMatchCallback() {
@Override
- public void matchesFound(HashMap<String, RecipientEntry> entries) {
+ public void matchesFound(Map<String, RecipientEntry> entries) {
final ArrayList<RecipientChip> replacements =
new ArrayList<RecipientChip>();
for (final RecipientChip temp : originalRecipients) {
@@ -2469,6 +2469,10 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
replacements.add(null);
}
}
+ processReplacements(replacements);
+ }
+
+ private void processReplacements(final List<RecipientChip> replacements) {
if (replacements != null && replacements.size() > 0) {
mHandler.post(new Runnable() {
@Override
@@ -2518,6 +2522,28 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
});
}
}
+
+ @Override
+ public void matchesNotFound(final Set<String> addresses) {
+ final List<RecipientChip> replacements =
+ new ArrayList<RecipientChip>(addresses.size());
+
+ for (final RecipientChip temp : originalRecipients) {
+ if (RecipientEntry.isCreatedRecipient(temp.getEntry()
+ .getContactId())
+ && getSpannable().getSpanStart(temp) != -1) {
+ if (addresses.contains(temp.getEntry().getDestination())) {
+ replacements.add(createFreeChip(temp.getEntry()));
+ } else {
+ replacements.add(null);
+ }
+ } else {
+ replacements.add(null);
+ }
+ }
+
+ processReplacements(replacements);
+ }
});
return null;
}
@@ -2545,7 +2571,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
new RecipientMatchCallback() {
@Override
- public void matchesFound(HashMap<String, RecipientEntry> entries) {
+ public void matchesFound(Map<String, RecipientEntry> entries) {
for (final RecipientChip temp : originalRecipients) {
if (RecipientEntry.isCreatedRecipient(temp.getEntry()
.getContactId())
@@ -2573,6 +2599,10 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
}
}
+ @Override
+ public void matchesNotFound(final Set<String> addresses) {
+ // No action required
+ }
});
return null;
}