summaryrefslogtreecommitdiffstats
path: root/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java
diff options
context:
space:
mode:
authorScott Kennedy <skennedy@google.com>2013-02-15 18:22:05 -0800
committerScott Kennedy <skennedy@google.com>2013-02-19 10:04:03 -0800
commit2727f969d0ce46cdd16cd77e1dc21f3a636217d2 (patch)
tree588ed5d0ec5e90f4650bc2e17a2a7e542cf9f77f /chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java
parent7b1c6d7dea5f4e3fcb3eb4f137b2e510b394ea79 (diff)
downloadandroid_frameworks_ex-2727f969d0ce46cdd16cd77e1dc21f3a636217d2.tar.gz
android_frameworks_ex-2727f969d0ce46cdd16cd77e1dc21f3a636217d2.tar.bz2
android_frameworks_ex-2727f969d0ce46cdd16cd77e1dc21f3a636217d2.zip
Ensure all addresses turn into chips
If an address wasn't properly resolved, it was left as text. This change processes all unresolved addresses into chips. Bug: 8201904 Change-Id: Iae7718d97c7c1167bdc464ef372b171743524712
Diffstat (limited to 'chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java')
-rw-r--r--chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java23
1 files changed, 21 insertions, 2 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) {