summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.xml15
-rw-r--r--core/java/android/content/ContentProviderOperation.java51
-rw-r--r--core/java/android/provider/ContactsContract.java118
3 files changed, 149 insertions, 35 deletions
diff --git a/api/current.xml b/api/current.xml
index b0be4d58b4f1..6fa5c3a29007 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -28851,6 +28851,21 @@
<parameter name="previousResult" type="int">
</parameter>
</method>
+<method name="withValue"
+ return="android.content.ContentProviderOperation.Builder"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="key" type="java.lang.String">
+</parameter>
+<parameter name="value" type="java.lang.Object">
+</parameter>
+</method>
<method name="withValueBackReference"
return="android.content.ContentProviderOperation.Builder"
abstract="false"
diff --git a/core/java/android/content/ContentProviderOperation.java b/core/java/android/content/ContentProviderOperation.java
index 07be017da54f..001af16ea293 100644
--- a/core/java/android/content/ContentProviderOperation.java
+++ b/core/java/android/content/ContentProviderOperation.java
@@ -20,6 +20,7 @@ import android.net.Uri;
import android.database.Cursor;
import android.os.Parcelable;
import android.os.Parcel;
+import android.os.Debug;
import java.util.Map;
import java.util.HashMap;
@@ -428,7 +429,8 @@ public class ContentProviderOperation implements Parcelable {
/**
* The ContentValues to use. This may be null. These values may be overwritten by
- * the corresponding value specified by {@link #withValueBackReferences(ContentValues)}.
+ * the corresponding value specified by {@link #withValueBackReference} or by
+ * future calls to {@link #withValues} or {@link #withValue}.
* This can only be used with builders of type insert or update.
* @return this builder, to allow for chaining.
*/
@@ -436,11 +438,56 @@ public class ContentProviderOperation implements Parcelable {
if (mType != TYPE_INSERT && mType != TYPE_UPDATE) {
throw new IllegalArgumentException("only inserts and updates can have values");
}
- mValues = values;
+ if (mValues == null) {
+ mValues = new ContentValues();
+ }
+ mValues.putAll(values);
return this;
}
/**
+ * A value to insert or update. This value may be overwritten by
+ * the corresponding value specified by {@link #withValueBackReference}.
+ * This can only be used with builders of type insert or update.
+ * @param key the name of this value
+ * @param value the value itself. the type must be acceptable for insertion by
+ * {@link ContentValues#put}
+ * @return this builder, to allow for chaining.
+ */
+ public Builder withValue(String key, Object value) {
+ if (mType != TYPE_INSERT && mType != TYPE_UPDATE) {
+ throw new IllegalArgumentException("only inserts and updates can have values");
+ }
+ if (mValues == null) {
+ mValues = new ContentValues();
+ }
+ if (value == null) {
+ mValues.putNull(key);
+ } else if (value instanceof String) {
+ mValues.put(key, (String) value);
+ } else if (value instanceof Byte) {
+ mValues.put(key, (Byte) value);
+ } else if (value instanceof Short) {
+ mValues.put(key, (Short) value);
+ } else if (value instanceof Integer) {
+ mValues.put(key, (Integer) value);
+ } else if (value instanceof Long) {
+ mValues.put(key, (Long) value);
+ } else if (value instanceof Float) {
+ mValues.put(key, (Float) value);
+ } else if (value instanceof Double) {
+ mValues.put(key, (Double) value);
+ } else if (value instanceof Boolean) {
+ mValues.put(key, (Boolean) value);
+ } else if (value instanceof byte[]) {
+ mValues.put(key, (byte[]) value);
+ } else {
+ throw new IllegalArgumentException("bad value type: " + value.getClass().getName());
+ }
+ return this;
+ }
+
+ /**
* The selection and arguments to use. An occurrence of '?' in the selection will be
* replaced with the corresponding occurence of the selection argument. Any of the
* selection arguments may be overwritten by a selection argument back reference as
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 60187d15d548..2bbf5f94f976 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -610,6 +610,31 @@ public final class ContactsContract {
public static final int PROTOCOL_GOOGLE_TALK = 5;
public static final int PROTOCOL_ICQ = 6;
public static final int PROTOCOL_JABBER = 7;
+
+ public static String encodePredefinedImProtocol(int protocol) {
+ return "pre:" + protocol;
+ }
+
+ public static String encodeCustomImProtocol(String protocolString) {
+ return "custom:" + protocolString;
+ }
+
+ public static Object decodeImProtocol(String encodedString) {
+ if (encodedString == null) {
+ return null;
+ }
+
+ if (encodedString.startsWith("pre:")) {
+ return Integer.parseInt(encodedString.substring(4));
+ }
+
+ if (encodedString.startsWith("custom:")) {
+ return encodedString.substring(7);
+ }
+
+ throw new IllegalArgumentException(
+ "the value is not a valid encoded protocol, " + encodedString);
+ }
}
/**
@@ -705,49 +730,76 @@ public final class ContactsContract {
*/
public static final String RINGTONE_URI = "data2";
}
- }
- /**
- * Constants for the contact aggregation exceptions table, which contains
- * aggregation rules overriding those used by automatic aggregation.
- */
- public static final class AggregationExceptions {
/**
- * This utility class cannot be instantiated
+ * Constants for the contact aggregation exceptions table, which contains
+ * aggregation rules overriding those used by automatic aggregation.
*/
- private AggregationExceptions() {}
+ public static final class AggregationExceptions {
+ /**
+ * This utility class cannot be instantiated
+ */
+ private AggregationExceptions() {}
- /**
- * The content:// style URI for this table
- */
- public static final Uri CONTENT_URI =
- Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
+ /**
+ * The content:// style URI for this table
+ */
+ public static final Uri CONTENT_URI =
+ Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
- /**
- * The MIME type of {@link #CONTENT_URI} providing a directory of data.
- */
- public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
+ /**
+ * The MIME type of {@link #CONTENT_URI} providing a directory of data.
+ */
+ public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
- /**
- * The type of exception: {@link #TYPE_NEVER_MATCH} or {@link #TYPE_ALWAYS_MATCH}.
- *
- * <P>Type: INTEGER</P>
- */
- public static final String TYPE = "type";
+ /**
+ * The type of exception: {@link #TYPE_NEVER_MATCH} or {@link #TYPE_ALWAYS_MATCH}.
+ *
+ * <P>Type: INTEGER</P>
+ */
+ public static final String TYPE = "type";
- public static final int TYPE_NEVER_MATCH = 0;
- public static final int TYPE_ALWAYS_MATCH = 1;
+ public static final int TYPE_NEVER_MATCH = 0;
+ public static final int TYPE_ALWAYS_MATCH = 1;
- /**
- * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} of one of
- * the contacts that the rule applies to.
- */
- public static final String CONTACT_ID1 = "contact_id1";
+ /**
+ * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} of one of
+ * the contacts that the rule applies to.
+ */
+ public static final String CONTACT_ID1 = "contact_id1";
+
+ /**
+ * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} of the other
+ * contact that the rule applies to.
+ */
+ public static final String CONTACT_ID2 = "contact_id2";
+ }
/**
- * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} of the other
- * contact that the rule applies to.
+ * Group Membership.
*/
- public static final String CONTACT_ID2 = "contact_id2";
+ public static final class GroupMembership implements BaseCommonColumns {
+ private GroupMembership() {}
+
+ /** Mime-type used when storing this in data table. */
+ public static final String CONTENT_ITEM_TYPE =
+ "vnd.android.cursor.item/group_membership";
+
+ /**
+ * The row id of the group that this group membership refers to. Either this or the
+ * GROUP_SOURCE_ID must be set. If they are both set then they must refer to the same
+ * group.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String GROUP_ROW_ID = "data1";
+
+ /**
+ * The source id of the group that this membership refers to. Either this or the
+ * GROUP_ROW_ID must be set. If they are both set then they must refer to the same
+ * group.
+ * <P>Type: STRING</P>
+ */
+ public static final String GROUP_SOURCE_ID = "data2";
+ }
}
}