- make it easier to add content values to the ContentProviderOperation
- add the group membership common kind as well as some IM utilities to the ContactsContract
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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,10 +438,55 @@ 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
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
private AggregationExceptions() {}
|
||||
|
||||
/**
|
||||
* The content:// style URI for this table
|
||||
* Constants for the contact aggregation exceptions table, which contains
|
||||
* aggregation rules overriding those used by automatic aggregation.
|
||||
*/
|
||||
public static final Uri CONTENT_URI =
|
||||
Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
|
||||
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 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";
|
||||
|
||||
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 the other
|
||||
* contact that the rule applies to.
|
||||
*/
|
||||
public static final String CONTACT_ID2 = "contact_id2";
|
||||
}
|
||||
|
||||
/**
|
||||
* The MIME type of {@link #CONTENT_URI} providing a directory of data.
|
||||
* Group Membership.
|
||||
*/
|
||||
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
|
||||
public static final class GroupMembership implements BaseCommonColumns {
|
||||
private GroupMembership() {}
|
||||
|
||||
/**
|
||||
* The type of exception: {@link #TYPE_NEVER_MATCH} or {@link #TYPE_ALWAYS_MATCH}.
|
||||
*
|
||||
* <P>Type: INTEGER</P>
|
||||
*/
|
||||
public static final String TYPE = "type";
|
||||
/** Mime-type used when storing this in data table. */
|
||||
public static final String CONTENT_ITEM_TYPE =
|
||||
"vnd.android.cursor.item/group_membership";
|
||||
|
||||
public static final int TYPE_NEVER_MATCH = 0;
|
||||
public static final int TYPE_ALWAYS_MATCH = 1;
|
||||
/**
|
||||
* 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";
|
||||
|
||||
/**
|
||||
* 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";
|
||||
/**
|
||||
* 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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user