| /* |
| * Copyright (C) 2009 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License |
| */ |
| |
| package android.provider; |
| |
| import android.accounts.Account; |
| import android.content.ContentProviderClient; |
| import android.content.ContentProviderOperation; |
| import android.content.ContentResolver; |
| import android.content.ContentUris; |
| import android.content.Context; |
| import android.content.Intent; |
| import android.content.res.Resources; |
| import android.database.Cursor; |
| import android.graphics.BitmapFactory; |
| import android.net.Uri; |
| import android.os.RemoteException; |
| import android.provider.ContactsContract.CommonDataKinds.GroupMembership; |
| import android.text.TextUtils; |
| |
| import java.io.ByteArrayInputStream; |
| import java.io.InputStream; |
| |
| /** |
| * The contract between the contacts provider and applications. Contains definitions |
| * for the supported URIs and columns. |
| * |
| * @hide |
| */ |
| public final class ContactsContract { |
| /** The authority for the contacts provider */ |
| public static final String AUTHORITY = "com.android.contacts"; |
| /** A content:// style uri to the authority for the contacts provider */ |
| public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); |
| |
| public interface SyncStateColumns extends SyncStateContract.Columns { |
| } |
| |
| public static final class SyncState { |
| /** |
| * This utility class cannot be instantiated |
| */ |
| private SyncState() {} |
| |
| public static final String CONTENT_DIRECTORY = |
| SyncStateContract.Constants.CONTENT_DIRECTORY; |
| |
| /** |
| * The content:// style URI for this table |
| */ |
| public static final Uri CONTENT_URI = |
| Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY); |
| |
| /** |
| * @see android.provider.SyncStateContract.Helpers#get |
| */ |
| public static byte[] get(ContentProviderClient provider, Account account) |
| throws RemoteException { |
| return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| } |
| |
| /** |
| * @see android.provider.SyncStateContract.Helpers#set |
| */ |
| public static void set(ContentProviderClient provider, Account account, byte[] data) |
| throws RemoteException { |
| SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| } |
| |
| /** |
| * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| */ |
| public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| } |
| } |
| |
| /** |
| * Generic columns for use by sync adapters. The specific functions of |
| * these columns are private to the sync adapter. Other clients of the API |
| * should not attempt to either read or write this column. |
| */ |
| private interface BaseSyncColumns { |
| |
| /** Generic column for use by sync adapters. */ |
| public static final String SYNC1 = "sync1"; |
| /** Generic column for use by sync adapters. */ |
| public static final String SYNC2 = "sync2"; |
| /** Generic column for use by sync adapters. */ |
| public static final String SYNC3 = "sync3"; |
| /** Generic column for use by sync adapters. */ |
| public static final String SYNC4 = "sync4"; |
| } |
| |
| /** |
| * Columns that appear when each row of a table belongs to a specific |
| * account, including sync information that an account may need. |
| */ |
| private interface SyncColumns extends BaseSyncColumns { |
| /** |
| * The name of the account instance to which this row belongs. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String ACCOUNT_NAME = "account_name"; |
| |
| /** |
| * The type of account to which this row belongs, which when paired with |
| * {@link #ACCOUNT_NAME} identifies a specific account. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String ACCOUNT_TYPE = "account_type"; |
| |
| /** |
| * String that uniquely identifies this row to its source account. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String SOURCE_ID = "sourceid"; |
| |
| /** |
| * Version number that is updated whenever this row or its related data |
| * changes. |
| * <P>Type: INTEGER</P> |
| */ |
| public static final String VERSION = "version"; |
| |
| /** |
| * Flag indicating that {@link #VERSION} has changed, and this row needs |
| * to be synchronized by its owning account. |
| * <P>Type: INTEGER (boolean)</P> |
| */ |
| public static final String DIRTY = "dirty"; |
| } |
| |
| public interface ContactOptionsColumns { |
| /** |
| * The number of times a person has been contacted |
| * <P>Type: INTEGER</P> |
| */ |
| public static final String TIMES_CONTACTED = "times_contacted"; |
| |
| /** |
| * The last time a person was contacted. |
| * <P>Type: INTEGER</P> |
| */ |
| public static final String LAST_TIME_CONTACTED = "last_time_contacted"; |
| |
| /** |
| * Is the contact starred? |
| * <P>Type: INTEGER (boolean)</P> |
| */ |
| public static final String STARRED = "starred"; |
| |
| /** |
| * A custom ringtone associated with a person. Not always present. |
| * <P>Type: TEXT (URI to the ringtone)</P> |
| */ |
| public static final String CUSTOM_RINGTONE = "custom_ringtone"; |
| |
| /** |
| * Whether the person should always be sent to voicemail. Not always |
| * present. |
| * <P>Type: INTEGER (0 for false, 1 for true)</P> |
| */ |
| public static final String SEND_TO_VOICEMAIL = "send_to_voicemail"; |
| } |
| |
| private interface ContactsColumns { |
| /** |
| * The display name for the contact. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String DISPLAY_NAME = "display_name"; |
| |
| /** |
| * Reference to the row in the data table holding the photo. |
| * <P>Type: INTEGER REFERENCES data(_id)</P> |
| */ |
| public static final String PHOTO_ID = "photo_id"; |
| |
| /** |
| * Lookup value that reflects the {@link Groups#GROUP_VISIBLE} state of |
| * any {@link GroupMembership} for this contact. |
| */ |
| public static final String IN_VISIBLE_GROUP = "in_visible_group"; |
| |
| /** |
| * Contact presence status. See {@link android.provider.Im.CommonPresenceColumns} |
| * for individual status definitions. |
| */ |
| public static final String PRESENCE_STATUS = Presence.PRESENCE_STATUS; |
| |
| /** |
| * An indicator of whether this contact has at least one phone number. "1" if there is |
| * at least one phone number, "0" otherwise. |
| * <P>Type: INTEGER</P> |
| */ |
| public static final String HAS_PHONE_NUMBER = "has_phone_number"; |
| } |
| |
| /** |
| * Constants for the contacts table, which contains a record per group |
| * of raw contact representing the same person. |
| */ |
| public static class Contacts implements BaseColumns, ContactsColumns, |
| ContactOptionsColumns { |
| /** |
| * This utility class cannot be instantiated |
| */ |
| private Contacts() {} |
| |
| /** |
| * The content:// style URI for this table |
| */ |
| public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts"); |
| |
| /** |
| * The content:// style URI for this table joined with useful data from |
| * {@link Data}. |
| */ |
| public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| "contacts_summary"); |
| |
| /** |
| * The content:// style URI used for "type-to-filter" functionality on the |
| * {@link #CONTENT_SUMMARY_URI} URI. The filter string will be used to match |
| * various parts of the contact name. The filter argument should be passed |
| * as an additional path segment after this URI. |
| */ |
| public static final Uri CONTENT_SUMMARY_FILTER_URI = Uri.withAppendedPath( |
| CONTENT_SUMMARY_URI, "filter"); |
| |
| /** |
| * The content:// style URI for this table joined with useful data from |
| * {@link Data}, filtered to include only starred contacts |
| * and the most frequently contacted contacts. |
| */ |
| public static final Uri CONTENT_SUMMARY_STREQUENT_URI = Uri.withAppendedPath( |
| CONTENT_SUMMARY_URI, "strequent"); |
| |
| /** |
| * The content:// style URI used for "type-to-filter" functionality on the |
| * {@link #CONTENT_SUMMARY_STREQUENT_URI} URI. The filter string will be used to match |
| * various parts of the contact name. The filter argument should be passed |
| * as an additional path segment after this URI. |
| */ |
| public static final Uri CONTENT_SUMMARY_STREQUENT_FILTER_URI = Uri.withAppendedPath( |
| CONTENT_SUMMARY_STREQUENT_URI, "filter"); |
| |
| public static final Uri CONTENT_SUMMARY_GROUP_URI = Uri.withAppendedPath( |
| CONTENT_SUMMARY_URI, "group"); |
| /** |
| * The MIME type of {@link #CONTENT_URI} providing a directory of |
| * people. |
| */ |
| public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact"; |
| |
| /** |
| * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| * person. |
| */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact"; |
| |
| /** |
| * A sub-directory of a single contact that contains all of the constituent raw contact |
| * {@link Data} rows. |
| */ |
| public static final class Data implements BaseColumns, DataColumns { |
| /** |
| * no public constructor since this is a utility class |
| */ |
| private Data() {} |
| |
| /** |
| * The directory twig for this sub-table |
| */ |
| public static final String CONTENT_DIRECTORY = "data"; |
| } |
| |
| /** |
| * A sub-directory of a single contact aggregate that contains all aggregation suggestions |
| * (other contacts). The aggregation suggestions are computed based on approximate |
| * data matches with this contact. |
| */ |
| public static final class AggregationSuggestions implements BaseColumns, ContactsColumns { |
| /** |
| * No public constructor since this is a utility class |
| */ |
| private AggregationSuggestions() {} |
| |
| /** |
| * The directory twig for this sub-table |
| */ |
| public static final String CONTENT_DIRECTORY = "suggestions"; |
| } |
| |
| /** |
| * Returns a URI that can be used to retrieve the contact's default photo. |
| * |
| * @param contactUri the contact whose photo should be used |
| */ |
| public static Uri getPhotoUri(ContentResolver cr, Uri contactUri) { |
| |
| // TODO remove try/catch block as soon as eclair-dev is merged in eclair |
| try { |
| long photoId = -1; |
| Cursor cursor = cr.query(contactUri, new String[] {Contacts.PHOTO_ID}, |
| null, null, null); |
| try { |
| if (!cursor.moveToNext()) { |
| return null; |
| } |
| |
| if (cursor.isNull(0)) { |
| return null; |
| } |
| |
| photoId = cursor.getLong(0); |
| } finally { |
| cursor.close(); |
| } |
| |
| return ContentUris.withAppendedId(ContactsContract.Data.CONTENT_URI, photoId); |
| } catch (Exception e) { |
| return null; |
| } |
| } |
| |
| /** |
| * Opens an InputStream for the person's default photo and returns the |
| * photo as a Bitmap stream. |
| * |
| * @param contactUri the contact whose photo should be used |
| */ |
| public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) { |
| Uri photoUri = getPhotoUri(cr, contactUri); |
| if (photoUri == null) { |
| return null; |
| } |
| Cursor cursor = cr.query(photoUri, |
| new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null); |
| try { |
| if (!cursor.moveToNext()) { |
| return null; |
| } |
| byte[] data = cursor.getBlob(0); |
| if (data == null) { |
| return null; |
| } |
| return new ByteArrayInputStream(data); |
| } finally { |
| cursor.close(); |
| } |
| } |
| } |
| |
| private interface RawContactsColumns { |
| /** |
| * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} that this |
| * data belongs to. |
| * <P>Type: INTEGER</P> |
| */ |
| public static final String CONTACT_ID = "contact_id"; |
| |
| /** |
| * Flag indicating that this {@link RawContacts} entry and its children has |
| * been restricted to specific platform apps. |
| * <P>Type: INTEGER (boolean)</P> |
| * |
| * @hide until finalized in future platform release |
| */ |
| public static final String IS_RESTRICTED = "is_restricted"; |
| |
| /** |
| * The aggregation mode for this contact. |
| * <P>Type: INTEGER</P> |
| */ |
| public static final String AGGREGATION_MODE = "aggregation_mode"; |
| |
| /** |
| * The "deleted" flag: "0" by default, "1" if the row has been marked |
| * for deletion. When {@link android.content.ContentResolver#delete} is |
| * called on a raw contact, it is marked for deletion and removed from its |
| * aggregate contact. The sync adaptor deletes the raw contact on the server and |
| * then calls ContactResolver.delete once more, this time passing the |
| * {@link RawContacts#DELETE_PERMANENTLY} query parameter to finalize the data removal. |
| * <P>Type: INTEGER</P> |
| */ |
| public static final String DELETED = "deleted"; |
| } |
| |
| /** |
| * Constants for the raw_contacts table, which contains the base contact |
| * information per sync source. Sync adapters and contact management apps |
| * are the primary consumers of this API. |
| */ |
| public static final class RawContacts implements BaseColumns, RawContactsColumns, |
| ContactOptionsColumns, SyncColumns { |
| /** |
| * This utility class cannot be instantiated |
| */ |
| private RawContacts() { |
| } |
| |
| /** |
| * The content:// style URI for this table |
| */ |
| public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts"); |
| |
| /** |
| * The content:// style URL for filtering people by email address. The |
| * filter argument should be passed as an additional path segment after |
| * this URI. |
| * |
| * @hide |
| */ |
| @Deprecated |
| public static final Uri CONTENT_FILTER_EMAIL_URI = |
| Uri.withAppendedPath(CONTENT_URI, "filter_email"); |
| |
| /** |
| * The MIME type of {@link #CONTENT_URI} providing a directory of |
| * people. |
| */ |
| public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact"; |
| |
| /** |
| * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| * person. |
| */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact"; |
| |
| /** |
| * Query parameter that can be passed with the {@link #CONTENT_URI} URI |
| * to the {@link android.content.ContentResolver#delete} method to |
| * indicate that the raw contact can be deleted physically, rather than |
| * merely marked as deleted. |
| */ |
| public static final String DELETE_PERMANENTLY = "delete_permanently"; |
| |
| /** |
| * Aggregation mode: aggregate asynchronously. |
| */ |
| public static final int AGGREGATION_MODE_DEFAULT = 0; |
| |
| /** |
| * Aggregation mode: aggregate at the time the raw contact is inserted/updated. |
| */ |
| public static final int AGGREGATION_MODE_IMMEDITATE = 1; |
| |
| /** |
| * Aggregation mode: never aggregate this raw contact (note that the raw contact will not |
| * have a corresponding Aggregate and therefore will not be included in Aggregates |
| * query results.) |
| */ |
| public static final int AGGREGATION_MODE_DISABLED = 2; |
| |
| /** |
| * A sub-directory of a single raw contact that contains all of their {@link Data} rows. |
| * To access this directory append |
| */ |
| public static final class Data implements BaseColumns, DataColumns { |
| /** |
| * no public constructor since this is a utility class |
| */ |
| private Data() { |
| } |
| |
| /** |
| * The directory twig for this sub-table |
| */ |
| public static final String CONTENT_DIRECTORY = "data"; |
| } |
| } |
| |
| private interface DataColumns { |
| /** |
| * The package name to use when creating {@link Resources} objects for |
| * this data row. This value is only designed for use when building user |
| * interfaces, and should not be used to infer the owner. |
| */ |
| public static final String RES_PACKAGE = "res_package"; |
| |
| /** |
| * The MIME type of the item represented by this row. |
| */ |
| public static final String MIMETYPE = "mimetype"; |
| |
| /** |
| * A reference to the {@link RawContacts#_ID} |
| * that this data belongs to. |
| */ |
| public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| |
| /** |
| * Whether this is the primary entry of its kind for the raw contact it belongs to |
| * <P>Type: INTEGER (if set, non-0 means true)</P> |
| */ |
| public static final String IS_PRIMARY = "is_primary"; |
| |
| /** |
| * Whether this is the primary entry of its kind for the aggregate |
| * contact it belongs to. Any data record that is "super primary" must |
| * also be "primary". |
| * <P>Type: INTEGER (if set, non-0 means true)</P> |
| */ |
| public static final String IS_SUPER_PRIMARY = "is_super_primary"; |
| |
| /** |
| * The version of this data record. This is a read-only value. The data column is |
| * guaranteed to not change without the version going up. This value is monotonically |
| * increasing. |
| * <P>Type: INTEGER</P> |
| */ |
| public static final String DATA_VERSION = "data_version"; |
| |
| /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| public static final String DATA1 = "data1"; |
| /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| public static final String DATA2 = "data2"; |
| /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| public static final String DATA3 = "data3"; |
| /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| public static final String DATA4 = "data4"; |
| /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| public static final String DATA5 = "data5"; |
| /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| public static final String DATA6 = "data6"; |
| /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| public static final String DATA7 = "data7"; |
| /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| public static final String DATA8 = "data8"; |
| /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| public static final String DATA9 = "data9"; |
| /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| public static final String DATA10 = "data10"; |
| /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| public static final String DATA11 = "data11"; |
| /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| public static final String DATA12 = "data12"; |
| /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| public static final String DATA13 = "data13"; |
| /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| public static final String DATA14 = "data14"; |
| /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| public static final String DATA15 = "data15"; |
| |
| /** Generic column for use by sync adapters. */ |
| public static final String SYNC1 = "data_sync1"; |
| /** Generic column for use by sync adapters. */ |
| public static final String SYNC2 = "data_sync2"; |
| /** Generic column for use by sync adapters. */ |
| public static final String SYNC3 = "data_sync3"; |
| /** Generic column for use by sync adapters. */ |
| public static final String SYNC4 = "data_sync4"; |
| |
| /** |
| * An optional insert, update or delete URI parameter that determines if |
| * the corresponding raw contact should be marked as dirty. The default |
| * value is true. |
| */ |
| public static final String MARK_AS_DIRTY = "mark_as_dirty"; |
| } |
| |
| /** |
| * Constants for the data table, which contains data points tied to a raw contact. |
| * For example, a phone number or email address. Each row in this table contains a type |
| * definition and some generic columns. Each data type can define the meaning for each of |
| * the generic columns. |
| */ |
| public static final class Data implements BaseColumns, DataColumns { |
| /** |
| * This utility class cannot be instantiated |
| */ |
| private Data() {} |
| |
| /** |
| * The content:// style URI for this table |
| */ |
| public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); |
| |
| /** |
| * The MIME type of {@link #CONTENT_URI} providing a directory of data. |
| */ |
| public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; |
| } |
| |
| private interface PhoneLookupColumns { |
| /** |
| * The phone number as the user entered it. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String NUMBER = "number"; |
| |
| /** |
| * The type of phone number, for example Home or Work. |
| * <P>Type: INTEGER</P> |
| */ |
| public static final String TYPE = "type"; |
| |
| /** |
| * The user defined label for the phone number. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String LABEL = "label"; |
| } |
| |
| /** |
| * A table that represents the result of looking up a phone number, for |
| * example for caller ID. To perform a lookup you must append the number you |
| * want to find to {@link #CONTENT_FILTER_URI}. |
| */ |
| public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, |
| ContactsColumns, ContactOptionsColumns { |
| /** |
| * This utility class cannot be instantiated |
| */ |
| private PhoneLookup() {} |
| |
| /** |
| * The content:// style URI for this table. Append the phone number you want to lookup |
| * to this URI and query it to perform a lookup. For example: |
| * |
| * {@code |
| * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, phoneNumber); |
| * } |
| */ |
| public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| "phone_lookup"); |
| } |
| |
| /** |
| * Additional data mixed in with {@link Im.CommonPresenceColumns} to link |
| * back to specific {@link ContactsContract.Contacts#_ID} entries. |
| */ |
| private interface PresenceColumns { |
| |
| /** |
| * The unique ID for a row. |
| * <P>Type: INTEGER (long)</P> |
| */ |
| public static final String _ID = "presence_id"; |
| |
| /** |
| * Reference to the {@link RawContacts#_ID} this presence references. |
| * <P>Type: INTEGER</P> |
| */ |
| public static final String RAW_CONTACT_ID = "presence_raw_contact_id"; |
| |
| /** |
| * Reference to the {@link Data#_ID} entry that owns this presence. |
| * <P>Type: INTEGER</P> |
| */ |
| public static final String DATA_ID = "presence_data_id"; |
| |
| /** |
| * The IM service the presence is coming from. Formatted using either |
| * {@link CommonDataKinds.Im#encodePredefinedImProtocol(int)} or |
| * {@link CommonDataKinds.Im#encodeCustomImProtocol(String)}. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String IM_PROTOCOL = "im_protocol"; |
| |
| /** |
| * The IM handle the presence item is for. The handle is scoped to the |
| * {@link #IM_PROTOCOL}. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String IM_HANDLE = "im_handle"; |
| |
| /** |
| * The IM account for the local user that the presence data came from. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String IM_ACCOUNT = "im_account"; |
| } |
| |
| public static final class Presence implements PresenceColumns, Im.CommonPresenceColumns { |
| /** |
| * This utility class cannot be instantiated |
| */ |
| private Presence() { |
| } |
| |
| /** |
| * The content:// style URI for this table |
| */ |
| public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "presence"); |
| |
| /** |
| * Gets the resource ID for the proper presence icon. |
| * |
| * @param status the status to get the icon for |
| * @return the resource ID for the proper presence icon |
| */ |
| public static final int getPresenceIconResourceId(int status) { |
| switch (status) { |
| case AVAILABLE: |
| return android.R.drawable.presence_online; |
| case IDLE: |
| case AWAY: |
| return android.R.drawable.presence_away; |
| case DO_NOT_DISTURB: |
| return android.R.drawable.presence_busy; |
| case INVISIBLE: |
| return android.R.drawable.presence_invisible; |
| case OFFLINE: |
| default: |
| return android.R.drawable.presence_offline; |
| } |
| } |
| |
| /** |
| * Returns the precedence of the status code the higher number being the higher precedence. |
| * |
| * @param status The status code. |
| * @return An integer representing the precedence, 0 being the lowest. |
| */ |
| public static final int getPresencePrecedence(int status) { |
| // Keep this function here incase we want to enforce a different precedence than the |
| // natural order of the status constants. |
| return status; |
| } |
| |
| /** |
| * The MIME type of {@link #CONTENT_URI} providing a directory of |
| * presence details. |
| */ |
| public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-presence"; |
| |
| /** |
| * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| * presence detail. |
| */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-presence"; |
| } |
| |
| /** |
| * Container for definitions of common data types stored in the {@link Data} table. |
| */ |
| public static final class CommonDataKinds { |
| /** |
| * The {@link Data#RES_PACKAGE} value for common data that should be |
| * shown using a default style. |
| */ |
| public static final String PACKAGE_COMMON = "common"; |
| |
| /** |
| * Columns common across the specific types. |
| */ |
| private interface BaseCommonColumns { |
| /** |
| * The package name to use when creating {@link Resources} objects for |
| * this data row. This value is only designed for use when building user |
| * interfaces, and should not be used to infer the owner. |
| */ |
| public static final String RES_PACKAGE = "res_package"; |
| |
| /** |
| * The MIME type of the item represented by this row. |
| */ |
| public static final String MIMETYPE = "mimetype"; |
| |
| /** |
| * The {@link RawContacts#_ID} that this data belongs to. |
| */ |
| public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| } |
| |
| /** |
| * The base types that all "Typed" data kinds support. |
| */ |
| public interface BaseTypes { |
| |
| /** |
| * A custom type. The custom label should be supplied by user. |
| */ |
| public static int TYPE_CUSTOM = 0; |
| } |
| |
| /** |
| * Columns common across the specific types. |
| */ |
| private interface CommonColumns extends BaseTypes{ |
| /** |
| * The type of data, for example Home or Work. |
| * <P>Type: INTEGER</P> |
| */ |
| public static final String TYPE = "data1"; |
| |
| /** |
| * The data for the contact method. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String DATA = "data2"; |
| |
| /** |
| * The user defined label for the the contact method. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String LABEL = "data3"; |
| } |
| |
| /** |
| * Parts of the name. |
| */ |
| public static final class StructuredName implements BaseCommonColumns { |
| private StructuredName() {} |
| |
| /** MIME type used when storing this in data table. */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; |
| |
| /** |
| * The given name for the contact. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String GIVEN_NAME = "data1"; |
| |
| /** |
| * The family name for the contact. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String FAMILY_NAME = "data2"; |
| |
| /** |
| * The contact's honorific prefix, e.g. "Sir" |
| * <P>Type: TEXT</P> |
| */ |
| public static final String PREFIX = "data3"; |
| |
| /** |
| * The contact's middle name |
| * <P>Type: TEXT</P> |
| */ |
| public static final String MIDDLE_NAME = "data4"; |
| |
| /** |
| * The contact's honorific suffix, e.g. "Jr" |
| */ |
| public static final String SUFFIX = "data5"; |
| |
| /** |
| * The phonetic version of the given name for the contact. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String PHONETIC_GIVEN_NAME = "data6"; |
| |
| /** |
| * The phonetic version of the additional name for the contact. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String PHONETIC_MIDDLE_NAME = "data7"; |
| |
| /** |
| * The phonetic version of the family name for the contact. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String PHONETIC_FAMILY_NAME = "data8"; |
| |
| /** |
| * The name that should be used to display the contact. |
| * <i>Unstructured component of the name should be consistent with |
| * its structured representation.</i> |
| * <p> |
| * Type: TEXT |
| */ |
| public static final String DISPLAY_NAME = "data9"; |
| } |
| |
| /** |
| * A nickname. |
| */ |
| public static final class Nickname implements CommonColumns, BaseCommonColumns { |
| private Nickname() {} |
| |
| /** MIME type used when storing this in data table. */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; |
| |
| public static final int TYPE_DEFAULT = 1; |
| public static final int TYPE_OTHER_NAME = 2; |
| public static final int TYPE_MAINDEN_NAME = 3; |
| public static final int TYPE_SHORT_NAME = 4; |
| public static final int TYPE_INITIALS = 5; |
| |
| /** |
| * The name itself |
| */ |
| public static final String NAME = DATA; |
| } |
| |
| /** |
| * Common data definition for telephone numbers. |
| */ |
| public static final class Phone implements BaseCommonColumns, CommonColumns { |
| private Phone() {} |
| |
| /** MIME type used when storing this in data table. */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone"; |
| |
| /** |
| * The MIME type of {@link #CONTENT_URI} providing a directory of |
| * phones. |
| */ |
| public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone"; |
| |
| /** |
| * The content:// style URI for all data records of the |
| * {@link Phone#CONTENT_ITEM_TYPE} MIME type, combined with the |
| * associated raw contact and aggregate contact data. |
| */ |
| public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| "phones"); |
| |
| /** |
| * The content:// style URI for filtering data records of the |
| * {@link Phone#CONTENT_ITEM_TYPE} MIME type, combined with the |
| * associated raw contact and aggregate contact data. The filter argument should |
| * be passed as an additional path segment after this URI. |
| */ |
| public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| "filter"); |
| |
| public static final int TYPE_HOME = 1; |
| public static final int TYPE_MOBILE = 2; |
| public static final int TYPE_WORK = 3; |
| public static final int TYPE_FAX_WORK = 4; |
| public static final int TYPE_FAX_HOME = 5; |
| public static final int TYPE_PAGER = 6; |
| public static final int TYPE_OTHER = 7; |
| public static final int TYPE_CALLBACK = 8; |
| public static final int TYPE_CAR = 9; |
| public static final int TYPE_COMPANY_MAIN = 10; |
| public static final int TYPE_ISDN = 11; |
| public static final int TYPE_MAIN = 12; |
| public static final int TYPE_OTHER_FAX = 13; |
| public static final int TYPE_RADIO = 14; |
| public static final int TYPE_TELEX = 15; |
| public static final int TYPE_TTY_TDD = 16; |
| public static final int TYPE_WORK_MOBILE = 17; |
| public static final int TYPE_WORK_PAGER = 18; |
| public static final int TYPE_ASSISTANT = 19; |
| |
| /** |
| * The phone number as the user entered it. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String NUMBER = DATA; |
| |
| public static final CharSequence getDisplayLabel(Context context, int type, |
| CharSequence label, CharSequence[] labelArray) { |
| CharSequence display = ""; |
| |
| if (type != Phone.TYPE_CUSTOM) { |
| CharSequence[] labels = labelArray != null? labelArray |
| : context.getResources().getTextArray( |
| com.android.internal.R.array.phoneTypes); |
| try { |
| display = labels[type - 1]; |
| } catch (ArrayIndexOutOfBoundsException e) { |
| display = labels[Phone.TYPE_CUSTOM]; |
| } |
| } else { |
| if (!TextUtils.isEmpty(label)) { |
| display = label; |
| } |
| } |
| return display; |
| } |
| |
| public static final CharSequence getDisplayLabel(Context context, int type, |
| CharSequence label) { |
| return getDisplayLabel(context, type, label, null); |
| } |
| } |
| |
| /** |
| * Common data definition for email addresses. |
| */ |
| public static final class Email implements BaseCommonColumns, CommonColumns { |
| private Email() {} |
| |
| /** MIME type used when storing this in data table. */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email"; |
| |
| /** |
| * The content:// style URI for all data records of the |
| * {@link Email#CONTENT_ITEM_TYPE} MIME type, combined with the |
| * associated raw contact and aggregate contact data. |
| */ |
| public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| "emails"); |
| |
| /** |
| * The content:// style URL for filtering data rows by email address. The |
| * filter argument should be passed as an additional path segment after |
| * this URI. |
| */ |
| public static final Uri CONTENT_FILTER_EMAIL_URI = Uri.withAppendedPath(CONTENT_URI, |
| "filter"); |
| |
| public static final int TYPE_HOME = 1; |
| public static final int TYPE_WORK = 2; |
| public static final int TYPE_OTHER = 3; |
| |
| /** |
| * The display name for the email address |
| * <P>Type: TEXT</P> |
| */ |
| public static final String DISPLAY_NAME = "data4"; |
| } |
| |
| /** |
| * Common data definition for postal addresses. |
| */ |
| public static final class StructuredPostal implements BaseCommonColumns, CommonColumns { |
| private StructuredPostal() { |
| } |
| |
| /** MIME type used when storing this in data table. */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/postal-address"; |
| |
| /** |
| * The MIME type of {@link #CONTENT_URI} providing a directory of |
| * postal addresses. |
| */ |
| public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address"; |
| |
| /** |
| * The content:// style URI for all data records of the |
| * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. |
| */ |
| public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| "postals"); |
| |
| public static final int TYPE_HOME = 1; |
| public static final int TYPE_WORK = 2; |
| public static final int TYPE_OTHER = 3; |
| |
| /** |
| * The full, unstructured postal address. <i>This field must be |
| * consistent with any structured data.</i> |
| * <p> |
| * Type: TEXT |
| */ |
| public static final String FORMATTED_ADDRESS = DATA; |
| |
| /** |
| * The agent who actually receives the mail. Used in work addresses. |
| * Also for 'in care of' or 'c/o'. |
| * <p> |
| * Type: TEXT |
| * @deprecated since this isn't supported by gd:structuredPostalAddress |
| */ |
| @Deprecated |
| public static final String AGENT = "data4"; |
| |
| /** |
| * Used in places where houses or buildings have names (and not |
| * necessarily numbers), eg. "The Pillars". |
| * <p> |
| * Type: TEXT |
| * @deprecated since this isn't supported by gd:structuredPostalAddress |
| */ |
| @Deprecated |
| public static final String HOUSENAME = "data5"; |
| |
| /** |
| * Can be street, avenue, road, etc. This element also includes the |
| * house number and room/apartment/flat/floor number. |
| * <p> |
| * Type: TEXT |
| */ |
| public static final String STREET = "data6"; |
| |
| /** |
| * Covers actual P.O. boxes, drawers, locked bags, etc. This is |
| * usually but not always mutually exclusive with street. |
| * <p> |
| * Type: TEXT |
| */ |
| public static final String POBOX = "data7"; |
| |
| /** |
| * This is used to disambiguate a street address when a city |
| * contains more than one street with the same name, or to specify a |
| * small place whose mail is routed through a larger postal town. In |
| * China it could be a county or a minor city. |
| * <p> |
| * Type: TEXT |
| */ |
| public static final String NEIGHBORHOOD = "data8"; |
| |
| /** |
| * Can be city, village, town, borough, etc. This is the postal town |
| * and not necessarily the place of residence or place of business. |
| * <p> |
| * Type: TEXT |
| */ |
| public static final String CITY = "data9"; |
| |
| /** |
| * Handles administrative districts such as U.S. or U.K. counties |
| * that are not used for mail addressing purposes. Subregion is not |
| * intended for delivery addresses. |
| * <p> |
| * Type: TEXT |
| * @deprecated since this isn't supported by gd:structuredPostalAddress |
| */ |
| @Deprecated |
| public static final String SUBREGION = "data10"; |
| |
| /** |
| * A state, province, county (in Ireland), Land (in Germany), |
| * departement (in France), etc. |
| * <p> |
| * Type: TEXT |
| */ |
| public static final String REGION = "data11"; |
| |
| /** |
| * Postal code. Usually country-wide, but sometimes specific to the |
| * city (e.g. "2" in "Dublin 2, Ireland" addresses). |
| * <p> |
| * Type: TEXT |
| */ |
| public static final String POSTCODE = "data12"; |
| |
| /** |
| * The name or code of the country. |
| * <p> |
| * Type: TEXT |
| */ |
| public static final String COUNTRY = "data13"; |
| } |
| |
| /** |
| * Common data definition for IM addresses. |
| */ |
| public static final class Im implements BaseCommonColumns, CommonColumns { |
| private Im() {} |
| |
| /** MIME type used when storing this in data table. */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; |
| |
| public static final int TYPE_HOME = 1; |
| public static final int TYPE_WORK = 2; |
| public static final int TYPE_OTHER = 3; |
| |
| public static final String PROTOCOL = "data5"; |
| |
| public static final String CUSTOM_PROTOCOL = "data6"; |
| |
| /** |
| * The predefined IM protocol types. The protocol can either be non-present, one |
| * of these types, or a free-form string. These cases are encoded in the PROTOCOL |
| * column as: |
| * <ul> |
| * <li>null</li> |
| * <li>pre:<an integer, one of the protocols below></li> |
| * <li>custom:<a string></li> |
| * </ul> |
| */ |
| public static final int PROTOCOL_CUSTOM = -1; |
| public static final int PROTOCOL_AIM = 0; |
| public static final int PROTOCOL_MSN = 1; |
| public static final int PROTOCOL_YAHOO = 2; |
| public static final int PROTOCOL_SKYPE = 3; |
| public static final int PROTOCOL_QQ = 4; |
| public static final int PROTOCOL_GOOGLE_TALK = 5; |
| public static final int PROTOCOL_ICQ = 6; |
| public static final int PROTOCOL_JABBER = 7; |
| public static final int PROTOCOL_NETMEETING = 8; |
| } |
| |
| /** |
| * Common data definition for organizations. |
| */ |
| public static final class Organization implements BaseCommonColumns, CommonColumns { |
| private Organization() {} |
| |
| /** MIME type used when storing this in data table. */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; |
| |
| public static final int TYPE_WORK = 1; |
| public static final int TYPE_OTHER = 2; |
| |
| /** |
| * The company as the user entered it. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String COMPANY = DATA; |
| |
| /** |
| * The position title at this company as the user entered it. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String TITLE = "data4"; |
| |
| /** |
| * The department at this company as the user entered it. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String DEPARTMENT = "data5"; |
| |
| /** |
| * The job description at this company as the user entered it. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String JOB_DESCRIPTION = "data6"; |
| |
| /** |
| * The symbol of this company as the user entered it. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String SYMBOL = "data7"; |
| |
| /** |
| * The phonetic name of this company as the user entered it. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String PHONETIC_NAME = "data8"; |
| } |
| |
| /** |
| * Common data definition for miscellaneous information. |
| */ |
| public static final class Miscellaneous implements BaseCommonColumns { |
| private Miscellaneous() {} |
| |
| /** MIME type used when storing this in data table. */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/misc"; |
| |
| /** |
| * The birthday as the user entered it. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String BIRTHDAY = "data1"; |
| |
| /** |
| * The nickname as the user entered it. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String NICKNAME = "data2"; |
| } |
| |
| /** |
| * Common data definition for relations. |
| */ |
| public static final class Relation implements BaseCommonColumns, CommonColumns { |
| private Relation() {} |
| |
| /** MIME type used when storing this in data table. */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; |
| |
| public static final int TYPE_ASSISTANT = 1; |
| public static final int TYPE_BROTHER = 2; |
| public static final int TYPE_CHILD = 3; |
| public static final int TYPE_DOMESTIC_PARTNER = 4; |
| public static final int TYPE_FATHER = 5; |
| public static final int TYPE_FRIEND = 6; |
| public static final int TYPE_MANAGER = 7; |
| public static final int TYPE_MOTHER = 8; |
| public static final int TYPE_PARENT = 9; |
| public static final int TYPE_PARTNER = 10; |
| public static final int TYPE_REFERRED_BY = 11; |
| public static final int TYPE_RELATIVE = 12; |
| public static final int TYPE_SISTER = 13; |
| public static final int TYPE_SPOUSE = 14; |
| |
| /** |
| * The name of the relative as the user entered it. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String NAME = DATA; |
| } |
| |
| /** |
| * Common data definition for events. |
| */ |
| public static final class Event implements BaseCommonColumns, CommonColumns { |
| private Event() {} |
| |
| /** MIME type used when storing this in data table. */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/event"; |
| |
| public static final int TYPE_ANNIVERSARY = 1; |
| public static final int TYPE_OTHER = 2; |
| |
| /** |
| * The event start date as the user entered it. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String START_DATE = DATA; |
| } |
| |
| /** |
| * Photo of the contact. |
| */ |
| public static final class Photo implements BaseCommonColumns { |
| private Photo() {} |
| |
| /** MIME type used when storing this in data table. */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; |
| |
| /** |
| * Thumbnail photo of the raw contact. This is the raw bytes of an image |
| * that could be inflated using {@link BitmapFactory}. |
| * <p> |
| * Type: BLOB |
| */ |
| public static final String PHOTO = "data1"; |
| } |
| |
| /** |
| * Notes about the contact. |
| */ |
| public static final class Note implements BaseCommonColumns { |
| private Note() {} |
| |
| /** MIME type used when storing this in data table. */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; |
| |
| /** |
| * The note text. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String NOTE = "data1"; |
| } |
| |
| /** |
| * Group Membership. |
| */ |
| 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. Exactly one of |
| * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row. |
| * <P>Type: INTEGER</P> |
| */ |
| public static final String GROUP_ROW_ID = "data1"; |
| |
| /** |
| * The sourceid of the group that this group membership refers to. Exactly one of |
| * this or {@link #GROUP_ROW_ID} must be set when inserting a row. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String GROUP_SOURCE_ID = "group_sourceid"; |
| } |
| |
| /** |
| * Website related to the contact. |
| */ |
| public static final class Website implements BaseCommonColumns, CommonColumns { |
| private Website() {} |
| |
| /** MIME type used when storing this in data table. */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; |
| |
| public static final int TYPE_HOMEPAGE = 1; |
| public static final int TYPE_BLOG = 2; |
| public static final int TYPE_PROFILE = 3; |
| public static final int TYPE_HOME = 4; |
| public static final int TYPE_WORK = 5; |
| public static final int TYPE_FTP = 6; |
| public static final int TYPE_OTHER = 7; |
| |
| /** |
| * The website URL string. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String URL = "data1"; |
| } |
| } |
| |
| // TODO: make this private before unhiding |
| public interface GroupsColumns { |
| /** |
| * The display title of this group. |
| * <p> |
| * Type: TEXT |
| */ |
| public static final String TITLE = "title"; |
| |
| /** |
| * The package name to use when creating {@link Resources} objects for |
| * this group. This value is only designed for use when building user |
| * interfaces, and should not be used to infer the owner. |
| */ |
| public static final String RES_PACKAGE = "res_package"; |
| |
| /** |
| * The display title of this group to load as a resource from |
| * {@link #RES_PACKAGE}, which may be localized. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String TITLE_RES = "title_res"; |
| |
| /** |
| * Notes about the group. |
| * <p> |
| * Type: TEXT |
| */ |
| public static final String NOTES = "notes"; |
| |
| /** |
| * The ID of this group if it is a System Group, i.e. a group that has a special meaning |
| * to the sync adapter, null otherwise. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String SYSTEM_ID = "system_id"; |
| |
| /** |
| * The total number of {@link Contacts} that have |
| * {@link GroupMembership} in this group. Read-only value that is only |
| * present when querying {@link Groups#CONTENT_SUMMARY_URI}. |
| * <p> |
| * Type: INTEGER |
| */ |
| public static final String SUMMARY_COUNT = "summ_count"; |
| |
| /** |
| * The total number of {@link Contacts} that have both |
| * {@link GroupMembership} in this group, and also have phone numbers. |
| * Read-only value that is only present when querying |
| * {@link Groups#CONTENT_SUMMARY_URI}. |
| * <p> |
| * Type: INTEGER |
| */ |
| public static final String SUMMARY_WITH_PHONES = "summ_phones"; |
| |
| /** |
| * Flag indicating if the contacts belonging to this group should be |
| * visible in any user interface. |
| * <p> |
| * Type: INTEGER (boolean) |
| */ |
| public static final String GROUP_VISIBLE = "group_visible"; |
| |
| /** |
| * The "deleted" flag: "0" by default, "1" if the row has been marked |
| * for deletion. When {@link android.content.ContentResolver#delete} is |
| * called on a raw contact, it is marked for deletion and removed from its |
| * aggregate contact. The sync adaptor deletes the raw contact on the server and |
| * then calls ContactResolver.delete once more, this time passing the |
| * {@link RawContacts#DELETE_PERMANENTLY} query parameter to finalize the data removal. |
| * <P>Type: INTEGER</P> |
| */ |
| public static final String DELETED = "deleted"; |
| |
| /** |
| * Whether this group should be synced if the SYNC_EVERYTHING settings |
| * is false for this group's account. |
| * <p> |
| * Type: INTEGER (boolean) |
| */ |
| public static final String SHOULD_SYNC = "should_sync"; |
| } |
| |
| /** |
| * Constants for the groups table. |
| */ |
| public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { |
| /** |
| * This utility class cannot be instantiated |
| */ |
| private Groups() { |
| } |
| |
| /** |
| * The content:// style URI for this table |
| */ |
| public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); |
| |
| /** |
| * The content:// style URI for this table joined with details data from |
| * {@link Data}. |
| */ |
| public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| "groups_summary"); |
| |
| /** |
| * The MIME type of a directory of groups. |
| */ |
| public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; |
| |
| /** |
| * The MIME type of a single group. |
| */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; |
| |
| /** |
| * Query parameter that can be passed with the {@link #CONTENT_URI} URI |
| * to the {@link android.content.ContentResolver#delete} method to |
| * indicate that the raw contact can be deleted physically, rather than |
| * merely marked as deleted. |
| */ |
| public static final String DELETE_PERMANENTLY = "delete_permanently"; |
| |
| /** |
| * An optional update or insert URI parameter that determines if the |
| * group should be marked as dirty. The default value is true. |
| */ |
| public static final String MARK_AS_DIRTY = "mark_as_dirty"; |
| } |
| |
| /** |
| * Constants for the contact aggregation exceptions table, which contains |
| * aggregation rules overriding those used by automatic aggregation. This type only |
| * supports query and update. Neither insert nor delete are supported. |
| */ |
| public static final class AggregationExceptions implements BaseColumns { |
| /** |
| * 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 MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception |
| */ |
| public static final String CONTENT_ITEM_TYPE = |
| "vnd.android.cursor.item/aggregation_exception"; |
| |
| /** |
| * The type of exception: {@link #TYPE_KEEP_IN}, {@link #TYPE_KEEP_OUT} or |
| * {@link #TYPE_AUTOMATIC}. |
| * |
| * <P>Type: INTEGER</P> |
| */ |
| public static final String TYPE = "type"; |
| |
| /** |
| * Allows the provider to automatically decide whether the aggregate |
| * contact should include a particular raw contact or not. |
| */ |
| public static final int TYPE_AUTOMATIC = 0; |
| |
| /** |
| * Makes sure that the specified raw contact is included in the |
| * specified aggregate contact. |
| */ |
| public static final int TYPE_KEEP_IN = 1; |
| |
| /** |
| * Makes sure that the specified raw contact is NOT included in the |
| * specified aggregate contact. |
| */ |
| public static final int TYPE_KEEP_OUT = 2; |
| |
| /** |
| * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} of the |
| * aggregate contact that the rule applies to. |
| */ |
| public static final String CONTACT_ID = "contact_id"; |
| |
| /** |
| * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to. |
| */ |
| public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| } |
| |
| private interface SettingsColumns { |
| /** |
| * The name of the account instance to which this row belongs. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String ACCOUNT_NAME = "account_name"; |
| |
| /** |
| * The type of account to which this row belongs, which when paired with |
| * {@link #ACCOUNT_NAME} identifies a specific account. |
| * <P>Type: TEXT</P> |
| */ |
| public static final String ACCOUNT_TYPE = "account_type"; |
| |
| /** |
| * Setting to indicate how this source handles {@link #SHOULD_SYNC} and |
| * {@link Groups#SHOULD_SYNC} flags. This mode should be one of |
| * {@link Settings#SYNC_MODE_EVERYTHING}, |
| * {@link Settings#SYNC_MODE_UNGROUPED}, or |
| * {@link Settings#SYNC_MODE_UNSUPPORTED}. |
| * <p> |
| * Type: INTEGER |
| */ |
| public static final String SHOULD_SYNC_MODE = "should_sync_mode"; |
| |
| /** |
| * When modes is {@link Settings#SYNC_MODE_EVERYTHING}, this flag |
| * overrides any children {@link Groups#SHOULD_SYNC} when set. When mode |
| * is {@link Settings#SYNC_MODE_UNGROUPED}, this flag indicates the |
| * syncing behavior for contacts not belonging to any group. |
| * <p> |
| * Type: INTEGER (boolean) |
| */ |
| public static final String SHOULD_SYNC = "should_sync"; |
| |
| /** |
| * Flag indicating if contacts without any {@link GroupMembership} |
| * entries should be visible in any user interface. |
| * <p> |
| * Type: INTEGER (boolean) |
| */ |
| public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; |
| } |
| |
| /** |
| * Contacts-specific settings for various {@link Account}. |
| */ |
| public static final class Settings implements BaseColumns, SettingsColumns { |
| /** |
| * This utility class cannot be instantiated |
| */ |
| private Settings() { |
| } |
| |
| /** |
| * The content:// style URI for this table |
| */ |
| public static final Uri CONTENT_URI = |
| Uri.withAppendedPath(AUTHORITY_URI, "settings"); |
| |
| /** |
| * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| * settings. |
| */ |
| public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; |
| |
| /** |
| * The MIME-type of {@link #CONTENT_URI} providing a single setting. |
| */ |
| public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; |
| |
| /** |
| * Mode for {@link #SHOULD_SYNC_MODE} that indicates this data source |
| * doesn't support per-group {@link Groups#SHOULD_SYNC} flags. |
| */ |
| public static final int SYNC_MODE_UNSUPPORTED = 0; |
| |
| /** |
| * Mode for {@link #SHOULD_SYNC_MODE} that indicates this data source |
| * fully supports per-group {@link Groups#SHOULD_SYNC} flags and assumes |
| * that {@link #SHOULD_SYNC} refers to contacts without any |
| * {@link GroupMembership}. |
| */ |
| public static final int SYNC_MODE_UNGROUPED = 1; |
| |
| /** |
| * Mode for {@link #SHOULD_SYNC_MODE} that indicates this data source |
| * fully supports per-group {@link Groups#SHOULD_SYNC} flags but assumes |
| * that {@link #SHOULD_SYNC} overrides per-group flags when set. |
| */ |
| public static final int SYNC_MODE_EVERYTHING = 2; |
| } |
| |
| /** |
| * Contains helper classes used to create or manage {@link android.content.Intent Intents} |
| * that involve contacts. |
| */ |
| public static final class Intents { |
| /** |
| * This is the intent that is fired when a search suggestion is clicked on. |
| */ |
| public static final String SEARCH_SUGGESTION_CLICKED = |
| "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; |
| |
| /** |
| * This is the intent that is fired when a search suggestion for dialing a number |
| * is clicked on. |
| */ |
| public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = |
| "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; |
| |
| /** |
| * This is the intent that is fired when a search suggestion for creating a contact |
| * is clicked on. |
| */ |
| public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = |
| "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; |
| |
| /** |
| * Starts an Activity that lets the user pick a contact to attach an image to. |
| * After picking the contact it launches the image cropper in face detection mode. |
| */ |
| public static final String ATTACH_IMAGE = |
| "com.android.contacts.action.ATTACH_IMAGE"; |
| |
| /** |
| * Takes as input a data URI with a mailto: or tel: scheme. If a single |
| * contact exists with the given data it will be shown. If no contact |
| * exists, a dialog will ask the user if they want to create a new |
| * contact with the provided details filled in. If multiple contacts |
| * share the data the user will be prompted to pick which contact they |
| * want to view. |
| * <p> |
| * For <code>mailto:</code> URIs, the scheme specific portion must be a |
| * raw email address, such as one built using |
| * {@link Uri#fromParts(String, String, String)}. |
| * <p> |
| * For <code>tel:</code> URIs, the scheme specific portion is compared |
| * to existing numbers using the standard caller ID lookup algorithm. |
| * The number must be properly encoded, for example using |
| * {@link Uri#fromParts(String, String, String)}. |
| * <p> |
| * Any extras from the {@link Insert} class will be passed along to the |
| * create activity if there are no contacts to show. |
| * <p> |
| * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip |
| * prompting the user when the contact doesn't exist. |
| */ |
| public static final String SHOW_OR_CREATE_CONTACT = |
| "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; |
| |
| /** |
| * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new |
| * contact if no matching contact found. Otherwise, default behavior is |
| * to prompt user with dialog before creating. |
| * <p> |
| * Type: BOOLEAN |
| */ |
| public static final String EXTRA_FORCE_CREATE = |
| "com.android.contacts.action.FORCE_CREATE"; |
| |
| /** |
| * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact |
| * description to be shown when prompting user about creating a new |
| * contact. |
| * <p> |
| * Type: STRING |
| */ |
| public static final String EXTRA_CREATE_DESCRIPTION = |
| "com.android.contacts.action.CREATE_DESCRIPTION"; |
| |
| /** |
| * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| * dialog location using screen coordinates. When not specified, the |
| * dialog will be centered. |
| */ |
| public static final String EXTRA_TARGET_RECT = "target_rect"; |
| |
| /** |
| * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| * desired dialog style, usually a variation on size. One of |
| * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. |
| */ |
| public static final String EXTRA_MODE = "mode"; |
| |
| /** |
| * Value for {@link #EXTRA_MODE} to show a small-sized dialog. |
| */ |
| public static final int MODE_SMALL = 1; |
| |
| /** |
| * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. |
| */ |
| public static final int MODE_MEDIUM = 2; |
| |
| /** |
| * Value for {@link #EXTRA_MODE} to show a large-sized dialog. |
| */ |
| public static final int MODE_LARGE = 3; |
| |
| /** |
| * Intents related to the Contacts app UI. |
| */ |
| public static final class UI { |
| /** |
| * The action for the default contacts list tab. |
| */ |
| public static final String LIST_DEFAULT = |
| "com.android.contacts.action.LIST_DEFAULT"; |
| |
| /** |
| * The action for the contacts list tab. |
| */ |
| public static final String LIST_GROUP_ACTION = |
| "com.android.contacts.action.LIST_GROUP"; |
| |
| /** |
| * When in LIST_GROUP_ACTION mode, this is the group to display. |
| */ |
| public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP"; |
| |
| /** |
| * The action for the all contacts list tab. |
| */ |
| public static final String LIST_ALL_CONTACTS_ACTION = |
| "com.android.contacts.action.LIST_ALL_CONTACTS"; |
| |
| /** |
| * The action for the contacts with phone numbers list tab. |
| */ |
| public static final String LIST_CONTACTS_WITH_PHONES_ACTION = |
| "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES"; |
| |
| /** |
| * The action for the starred contacts list tab. |
| */ |
| public static final String LIST_STARRED_ACTION = |
| "com.android.contacts.action.LIST_STARRED"; |
| |
| /** |
| * The action for the frequent contacts list tab. |
| */ |
| public static final String LIST_FREQUENT_ACTION = |
| "com.android.contacts.action.LIST_FREQUENT"; |
| |
| /** |
| * The action for the "strequent" contacts list tab. It first lists the starred |
| * contacts in alphabetical order and then the frequent contacts in descending |
| * order of the number of times they have been contacted. |
| */ |
| public static final String LIST_STREQUENT_ACTION = |
| "com.android.contacts.action.LIST_STREQUENT"; |
| |
| /** |
| * A key for to be used as an intent extra to set the activity |
| * title to a custom String value. |
| */ |
| public static final String TITLE_EXTRA_KEY = |
| "com.android.contacts.extra.TITLE_EXTRA"; |
| |
| /** |
| * Activity Action: Display a filtered list of contacts |
| * <p> |
| * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for |
| * filtering |
| * <p> |
| * Output: Nothing. |
| */ |
| public static final String FILTER_CONTACTS_ACTION = |
| "com.android.contacts.action.FILTER_CONTACTS"; |
| |
| /** |
| * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION} |
| * intents to supply the text on which to filter. |
| */ |
| public static final String FILTER_TEXT_EXTRA_KEY = |
| "com.android.contacts.extra.FILTER_TEXT"; |
| } |
| |
| /** |
| * Convenience class that contains string constants used |
| * to create contact {@link android.content.Intent Intents}. |
| */ |
| public static final class Insert { |
| /** The action code to use when adding a contact */ |
| public static final String ACTION = Intent.ACTION_INSERT; |
| |
| /** |
| * If present, forces a bypass of quick insert mode. |
| */ |
| public static final String FULL_MODE = "full_mode"; |
| |
| /** |
| * The extra field for the contact name. |
| * <P>Type: String</P> |
| */ |
| public static final String NAME = "name"; |
| |
| // TODO add structured name values here. |
| |
| /** |
| * The extra field for the contact phonetic name. |
| * <P>Type: String</P> |
| */ |
| public static final String PHONETIC_NAME = "phonetic_name"; |
| |
| /** |
| * The extra field for the contact company. |
| * <P>Type: String</P> |
| */ |
| public static final String COMPANY = "company"; |
| |
| /** |
| * The extra field for the contact job title. |
| * <P>Type: String</P> |
| */ |
| public static final String JOB_TITLE = "job_title"; |
| |
| /** |
| * The extra field for the contact notes. |
| * <P>Type: String</P> |
| */ |
| public static final String NOTES = "notes"; |
| |
| /** |
| * The extra field for the contact phone number. |
| * <P>Type: String</P> |
| */ |
| public static final String PHONE = "phone"; |
| |
| /** |
| * The extra field for the contact phone number type. |
| * <P>Type: Either an integer value from |
| * {@link android.provider.Contacts.PhonesColumns PhonesColumns}, |
| * or a string specifying a custom label.</P> |
| */ |
| public static final String PHONE_TYPE = "phone_type"; |
| |
| /** |
| * The extra field for the phone isprimary flag. |
| * <P>Type: boolean</P> |
| */ |
| public static final String PHONE_ISPRIMARY = "phone_isprimary"; |
| |
| /** |
| * The extra field for an optional second contact phone number. |
| * <P>Type: String</P> |
| */ |
| public static final String SECONDARY_PHONE = "secondary_phone"; |
| |
| /** |
| * The extra field for an optional second contact phone number type. |
| * <P>Type: Either an integer value from |
| * {@link android.provider.Contacts.PhonesColumns PhonesColumns}, |
| * or a string specifying a custom label.</P> |
| */ |
| public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; |
| |
| /** |
| * The extra field for an optional third contact phone number. |
| * <P>Type: String</P> |
| */ |
| public static final String TERTIARY_PHONE = "tertiary_phone"; |
| |
| /** |
| * The extra field for an optional third contact phone number type. |
| * <P>Type: Either an integer value from |
| * {@link android.provider.Contacts.PhonesColumns PhonesColumns}, |
| * or a string specifying a custom label.</P> |
| */ |
| public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; |
| |
| /** |
| * The extra field for the contact email address. |
| * <P>Type: String</P> |
| */ |
| public static final String EMAIL = "email"; |
| |
| /** |
| * The extra field for the contact email type. |
| * <P>Type: Either an integer value from |
| * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} |
| * or a string specifying a custom label.</P> |
| */ |
| public static final String EMAIL_TYPE = "email_type"; |
| |
| /** |
| * The extra field for the email isprimary flag. |
| * <P>Type: boolean</P> |
| */ |
| public static final String EMAIL_ISPRIMARY = "email_isprimary"; |
| |
| /** |
| * The extra field for an optional second contact email address. |
| * <P>Type: String</P> |
| */ |
| public static final String SECONDARY_EMAIL = "secondary_email"; |
| |
| /** |
| * The extra field for an optional second contact email type. |
| * <P>Type: Either an integer value from |
| * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} |
| * or a string specifying a custom label.</P> |
| */ |
| public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; |
| |
| /** |
| * The extra field for an optional third contact email address. |
| * <P>Type: String</P> |
| */ |
| public static final String TERTIARY_EMAIL = "tertiary_email"; |
| |
| /** |
| * The extra field for an optional third contact email type. |
| * <P>Type: Either an integer value from |
| * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} |
| * or a string specifying a custom label.</P> |
| */ |
| public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; |
| |
| /** |
| * The extra field for the contact postal address. |
| * <P>Type: String</P> |
| */ |
| public static final String POSTAL = "postal"; |
| |
| /** |
| * The extra field for the contact postal address type. |
| * <P>Type: Either an integer value from |
| * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} |
| * or a string specifying a custom label.</P> |
| */ |
| public static final String POSTAL_TYPE = "postal_type"; |
| |
| /** |
| * The extra field for the postal isprimary flag. |
| * <P>Type: boolean</P> |
| */ |
| public static final String POSTAL_ISPRIMARY = "postal_isprimary"; |
| |
| /** |
| * The extra field for an IM handle. |
| * <P>Type: String</P> |
| */ |
| public static final String IM_HANDLE = "im_handle"; |
| |
| /** |
| * The extra field for the IM protocol |
| * <P>Type: the result of {@link CommonDataKinds.Im#encodePredefinedImProtocol(int)} |
| * or {@link CommonDataKinds.Im#encodeCustomImProtocol(String)}.</P> |
| */ |
| public static final String IM_PROTOCOL = "im_protocol"; |
| |
| /** |
| * The extra field for the IM isprimary flag. |
| * <P>Type: boolean</P> |
| */ |
| public static final String IM_ISPRIMARY = "im_isprimary"; |
| } |
| } |
| |
| } |