summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--carousel/Android.mk3
-rw-r--r--chips/res/values-sw/strings.xml2
-rw-r--r--chips/src/com/android/ex/chips/BaseRecipientAdapter.java41
-rw-r--r--chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java24
-rw-r--r--chips/src/com/android/ex/chips/RecipientEditTextView.java42
-rw-r--r--common/Android.mk3
-rw-r--r--common/AndroidManifest.xml2
-rw-r--r--common/build.gradle36
-rw-r--r--common/java/com/android/common/widget/CompositeCursorAdapter.java8
9 files changed, 119 insertions, 42 deletions
diff --git a/carousel/Android.mk b/carousel/Android.mk
index 403773a..1f2592f 100644
--- a/carousel/Android.mk
+++ b/carousel/Android.mk
@@ -25,6 +25,3 @@ LOCAL_SRC_FILES := \
$(call all-renderscript-files-under, java)
include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# Include this library in the build server's output directory
-$(call dist-for-goals, droidcore, $(LOCAL_BUILT_MODULE):android-common-carousel.jar)
diff --git a/chips/res/values-sw/strings.xml b/chips/res/values-sw/strings.xml
index 8734bc5..edea133 100644
--- a/chips/res/values-sw/strings.xml
+++ b/chips/res/values-sw/strings.xml
@@ -19,5 +19,5 @@
<string name="more_string" msgid="8495478259330621990">"+<xliff:g id="COUNT">%1$s</xliff:g>"</string>
<string name="copy_email" msgid="7869435992461603532">"Nakili anwani ya barua pepe"</string>
<string name="copy_number" msgid="530057841276106843">"Nakili namba ya simu"</string>
- <string name="done" msgid="2356320650733788862">"Leta"</string>
+ <string name="done" msgid="2356320650733788862">"Inayofuata"</string>
</resources>
diff --git a/chips/src/com/android/ex/chips/BaseRecipientAdapter.java b/chips/src/com/android/ex/chips/BaseRecipientAdapter.java
index 0230c86..8b4317b 100644
--- a/chips/src/com/android/ex/chips/BaseRecipientAdapter.java
+++ b/chips/src/com/android/ex/chips/BaseRecipientAdapter.java
@@ -140,7 +140,7 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter
}
/** Used to temporarily hold results in Cursor objects. */
- private static class TemporaryEntry {
+ protected static class TemporaryEntry {
public final String displayName;
public final String destination;
public final int destinationType;
@@ -150,6 +150,25 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter
public final String thumbnailUriString;
public final int displayNameSource;
+ public TemporaryEntry(
+ String displayName,
+ String destination,
+ int destinationType,
+ String destinationLabel,
+ long contactId,
+ long dataId,
+ String thumbnailUriString,
+ int displayNameSource) {
+ this.displayName = displayName;
+ this.destination = destination;
+ this.destinationType = destinationType;
+ this.destinationLabel = destinationLabel;
+ this.contactId = contactId;
+ this.dataId = dataId;
+ this.thumbnailUriString = thumbnailUriString;
+ this.displayNameSource = displayNameSource;
+ }
+
public TemporaryEntry(Cursor cursor) {
this.displayName = cursor.getString(Queries.Query.NAME);
this.destination = cursor.getString(Queries.Query.DESTINATION);
@@ -322,7 +341,7 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter
/**
* An asynchronous filter that performs search in a particular directory.
*/
- private final class DirectoryFilter extends Filter {
+ protected class DirectoryFilter extends Filter {
private final DirectorySearchParams mParams;
private int mLimit;
@@ -536,6 +555,10 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter
}
}
+ public Context getContext() {
+ return mContext;
+ }
+
public int getQueryType() {
return mQueryType;
}
@@ -554,6 +577,16 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter
return new DefaultFilter();
}
+ /**
+ * An extesion to {@link RecipientAlternatesAdapter#getMatchingRecipients} that allows
+ * additional sources of contacts to be considered as matching recipients.
+ * @param addresses A set of addresses to be matched
+ * @return A list of matches or null if none found
+ */
+ public Map<String, RecipientEntry> getMatchingRecipients(Set<String> addresses) {
+ return null;
+ }
+
public static List<DirectorySearchParams> setupOtherDirectories(Context context,
Cursor directoryCursor, Account account) {
final PackageManager packageManager = context.getPackageManager();
@@ -612,7 +645,7 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter
* Starts search in other directories using {@link Filter}. Results will be handled in
* {@link DirectoryFilter}.
*/
- private void startSearchOtherDirectories(
+ protected void startSearchOtherDirectories(
CharSequence constraint, List<DirectorySearchParams> paramsList, int limit) {
final int count = paramsList.size();
// Note: skipping the default partition (index 0), which has already been loaded
@@ -729,7 +762,7 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter
mTempEntries = null;
}
- private List<RecipientEntry> getEntries() {
+ protected List<RecipientEntry> getEntries() {
return mTempEntries != null ? mTempEntries : mEntries;
}
diff --git a/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java b/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java
index ef34379..f64c166 100644
--- a/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java
+++ b/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java
@@ -73,9 +73,9 @@ public class RecipientAlternatesAdapter extends CursorAdapter {
public void matchesNotFound(Set<String> unfoundAddresses);
}
- public static void getMatchingRecipients(Context context, ArrayList<String> inAddresses,
- Account account, RecipientMatchCallback callback) {
- getMatchingRecipients(context, inAddresses, QUERY_TYPE_EMAIL, account, callback);
+ public static void getMatchingRecipients(Context context, BaseRecipientAdapter adapter,
+ ArrayList<String> inAddresses, Account account, RecipientMatchCallback callback) {
+ getMatchingRecipients(context, adapter, inAddresses, QUERY_TYPE_EMAIL, account, callback);
}
/**
@@ -88,8 +88,9 @@ public class RecipientAlternatesAdapter extends CursorAdapter {
* @param callback RecipientMatchCallback called when a match or matches are found.
* @return HashMap<String,RecipientEntry>
*/
- public static void getMatchingRecipients(Context context, ArrayList<String> inAddresses,
- int addressType, Account account, RecipientMatchCallback callback) {
+ public static void getMatchingRecipients(Context context, BaseRecipientAdapter adapter,
+ ArrayList<String> inAddresses, int addressType, Account account,
+ RecipientMatchCallback callback) {
Queries.Query query;
if (addressType == QUERY_TYPE_EMAIL) {
query = Queries.EMAIL;
@@ -197,6 +198,19 @@ public class RecipientAlternatesAdapter extends CursorAdapter {
}
}
+ // If no matches found in contact provider or the directories, try the extension
+ // matcher.
+ // todo (aalbert): This whole method needs to be in the adapter?
+ if (adapter != null) {
+ final Map<String, RecipientEntry> entries =
+ adapter.getMatchingRecipients(matchesNotFound);
+ if (entries != null && entries.size() > 0) {
+ callback.matchesFound(entries);
+ for (final String address : entries.keySet()) {
+ matchesNotFound.remove(address);
+ }
+ }
+ }
callback.matchesNotFound(matchesNotFound);
}
diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java
index fefd273..e300354 100644
--- a/chips/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java
@@ -17,18 +17,6 @@
package com.android.ex.chips;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-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;
-
import android.app.Dialog;
import android.content.ClipData;
import android.content.ClipDescription;
@@ -100,6 +88,18 @@ import com.android.ex.chips.recipientchip.DrawableRecipientChip;
import com.android.ex.chips.recipientchip.InvisibleRecipientChip;
import com.android.ex.chips.recipientchip.VisibleRecipientChip;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+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;
+
/**
* RecipientEditTextView is an auto complete text view for use with applications
* that use the new Chips UI for addressing a message to recipients.
@@ -2506,7 +2506,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
}
}
final BaseRecipientAdapter adapter = (BaseRecipientAdapter) getAdapter();
- RecipientAlternatesAdapter.getMatchingRecipients(getContext(), addresses,
+ RecipientAlternatesAdapter.getMatchingRecipients(getContext(), adapter, addresses,
adapter.getAccount(), new RecipientMatchCallback() {
@Override
public void matchesFound(Map<String, RecipientEntry> entries) {
@@ -2633,7 +2633,8 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
addresses.add(createAddressText(chip.getEntry()));
}
}
- RecipientAlternatesAdapter.getMatchingRecipients(getContext(), addresses,
+ final BaseRecipientAdapter adapter = (BaseRecipientAdapter) getAdapter();
+ RecipientAlternatesAdapter.getMatchingRecipients(getContext(), adapter, addresses,
((BaseRecipientAdapter) getAdapter()).getAccount(),
new RecipientMatchCallback() {
@@ -2644,21 +2645,14 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
.getContactId())
&& getSpannable().getSpanStart(temp) != -1) {
// Replace this.
- RecipientEntry entry = createValidatedEntry(entries
+ final RecipientEntry entry = createValidatedEntry(entries
.get(tokenizeAddress(temp.getEntry().getDestination())
.toLowerCase()));
- // If we don't have a validated contact
- // match, just use the
- // entry as it existed before.
- if (entry == null && !isPhoneQuery()) {
- entry = temp.getEntry();
- }
- final RecipientEntry tempEntry = entry;
- if (tempEntry != null) {
+ if (entry != null) {
mHandler.post(new Runnable() {
@Override
public void run() {
- replaceChip(temp, tempEntry);
+ replaceChip(temp, entry);
}
});
}
diff --git a/common/Android.mk b/common/Android.mk
index ed7c479..65a22fe 100644
--- a/common/Android.mk
+++ b/common/Android.mk
@@ -25,9 +25,6 @@ LOCAL_SRC_FILES := \
$(call all-logtags-files-under, java)
include $(BUILD_STATIC_JAVA_LIBRARY)
-# Include this library in the build server's output directory
-$(call dist-for-goals, droidcore, $(LOCAL_BUILT_MODULE):android-common.jar)
-
# Build the test package
# we can't build the test for apps only build, because android.test.runner is not unbundled yet.
ifeq ($(TARGET_BUILD_APPS),)
diff --git a/common/AndroidManifest.xml b/common/AndroidManifest.xml
new file mode 100644
index 0000000..91f5f51
--- /dev/null
+++ b/common/AndroidManifest.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest package="com.android.common"/> \ No newline at end of file
diff --git a/common/build.gradle b/common/build.gradle
new file mode 100644
index 0000000..d2612c5
--- /dev/null
+++ b/common/build.gradle
@@ -0,0 +1,36 @@
+apply plugin: 'android-library'
+
+buildDir = "$project.rootBuildDir/android-$project.name"
+
+android {
+ compileSdkVersion 17
+ buildToolsVersion = 17
+
+ logtags {
+ srcDirs = ['java']
+ genDir = "$buildDir/source/generated"
+ }
+
+ sourceSets {
+ main {
+ manifest {
+ srcFile "AndroidManifest.xml"
+ }
+ java {
+ srcDirs = [
+ 'java',
+ "$buildDir/source/generated"
+ ]
+ }
+ resources.srcDirs = ['src']
+ aidl.srcDirs = ['src']
+ renderscript.srcDirs = ['src']
+ res.srcDirs = ['res']
+ assets.srcDirs = ['assets']
+ }
+ }
+}
+
+android.libraryVariants.each { variant ->
+ variant.packageLibrary.baseName = "android-common"
+} \ No newline at end of file
diff --git a/common/java/com/android/common/widget/CompositeCursorAdapter.java b/common/java/com/android/common/widget/CompositeCursorAdapter.java
index d6064e1..605eb82 100644
--- a/common/java/com/android/common/widget/CompositeCursorAdapter.java
+++ b/common/java/com/android/common/widget/CompositeCursorAdapter.java
@@ -309,10 +309,14 @@ public abstract class CompositeCursorAdapter extends BaseAdapter {
int end = start + mPartitions[i].count;
if (position >= start && position < end) {
int offset = position - start;
- if (mPartitions[i].hasHeader && offset == 0) {
+ if (mPartitions[i].hasHeader) {
+ offset--;
+ }
+ if (offset == -1) {
return IGNORE_ITEM_VIEW_TYPE;
+ } else {
+ return getItemViewType(i, offset);
}
- return getItemViewType(i, position);
}
start = end;
}