From 9ffad071a9956ba2603475b060f271900a4d2e26 Mon Sep 17 00:00:00 2001 From: Brian Attwell Date: Wed, 21 Jan 2015 16:28:59 -0800 Subject: Unhide AggregationSuggestions.Builder Additional unbundling from ContactsContract. I'm going to remove all parameter types except name. None of them have been implemented since they were defined in ICS. Bug: 18777272 Change-Id: I5c4066d1e933cc4ab18df06809687ee2b7eac91c --- core/java/android/provider/ContactsContract.java | 70 ++++++++---------------- 1 file changed, 24 insertions(+), 46 deletions(-) (limited to 'core/java/android') diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java index 0666a24..d24e614 100644 --- a/core/java/android/provider/ContactsContract.java +++ b/core/java/android/provider/ContactsContract.java @@ -1792,52 +1792,26 @@ public final class ContactsContract { public static final String CONTENT_DIRECTORY = "suggestions"; /** - * Used with {@link Builder#addParameter} to specify what kind of data is - * supplied for the suggestion query. + * Used to specify what kind of data is supplied for the suggestion query. * * @hide */ public static final String PARAMETER_MATCH_NAME = "name"; /** - * Used with {@link Builder#addParameter} to specify what kind of data is - * supplied for the suggestion query. - * - * @hide - */ - public static final String PARAMETER_MATCH_EMAIL = "email"; - - /** - * Used with {@link Builder#addParameter} to specify what kind of data is - * supplied for the suggestion query. - * - * @hide - */ - public static final String PARAMETER_MATCH_PHONE = "phone"; - - /** - * Used with {@link Builder#addParameter} to specify what kind of data is - * supplied for the suggestion query. - * - * @hide - */ - public static final String PARAMETER_MATCH_NICKNAME = "nickname"; - - /** * A convenience builder for aggregation suggestion content URIs. - * - * TODO: change documentation for this class to use the builder. - * @hide */ public static final class Builder { private long mContactId; - private ArrayList mKinds = new ArrayList(); - private ArrayList mValues = new ArrayList(); + private final ArrayList mValues = new ArrayList(); private int mLimit; /** * Optional existing contact ID. If it is not provided, the search - * will be based exclusively on the values supplied with {@link #addParameter}. + * will be based exclusively on the values supplied with {@link #addNameParameter}. + * + * @param contactId contact to find aggregation suggestions for + * @return This Builder object to allow for chaining of calls to builder methods */ public Builder setContactId(long contactId) { this.mContactId = contactId; @@ -1845,28 +1819,31 @@ public final class ContactsContract { } /** - * A value that can be used when searching for an aggregation - * suggestion. + * Add a name to be used when searching for aggregation suggestions. * - * @param kind can be one of - * {@link AggregationSuggestions#PARAMETER_MATCH_NAME}, - * {@link AggregationSuggestions#PARAMETER_MATCH_EMAIL}, - * {@link AggregationSuggestions#PARAMETER_MATCH_NICKNAME}, - * {@link AggregationSuggestions#PARAMETER_MATCH_PHONE} + * @param name name to find aggregation suggestions for + * @return This Builder object to allow for chaining of calls to builder methods */ - public Builder addParameter(String kind, String value) { - if (!TextUtils.isEmpty(value)) { - mKinds.add(kind); - mValues.add(value); - } + public Builder addNameParameter(String name) { + mValues.add(name); return this; } + /** + * Sets the Maximum number of suggested aggregations that should be returned. + * @param limit The maximum number of suggested aggregations + * + * @return This Builder object to allow for chaining of calls to builder methods + */ public Builder setLimit(int limit) { mLimit = limit; return this; } + /** + * Combine all of the options that have been set and return a new {@link Uri} + * object for fetching aggregation suggestions. + */ public Uri build() { android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon(); builder.appendEncodedPath(String.valueOf(mContactId)); @@ -1875,9 +1852,10 @@ public final class ContactsContract { builder.appendQueryParameter("limit", String.valueOf(mLimit)); } - int count = mKinds.size(); + int count = mValues.size(); for (int i = 0; i < count; i++) { - builder.appendQueryParameter("query", mKinds.get(i) + ":" + mValues.get(i)); + builder.appendQueryParameter("query", PARAMETER_MATCH_NAME + + ":" + mValues.get(i)); } return builder.build(); -- cgit v1.1