ContactsContract.java revision 0050ee36398c3ab6e5f1ee0038609aff8cf4f0e9
1/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16
17package android.provider;
18
19import android.accounts.Account;
20import android.content.ContentProviderClient;
21import android.content.ContentProviderOperation;
22import android.content.ContentResolver;
23import android.content.ContentUris;
24import android.content.Context;
25import android.content.Intent;
26import android.content.res.Resources;
27import android.database.Cursor;
28import android.graphics.BitmapFactory;
29import android.graphics.Rect;
30import android.net.Uri;
31import android.os.RemoteException;
32import android.text.TextUtils;
33import android.util.Pair;
34import android.view.View;
35
36import java.io.ByteArrayInputStream;
37import java.io.InputStream;
38
39/**
40 * The contract between the contacts provider and applications. Contains definitions
41 * for the supported URIs and columns.
42 *
43 * @hide pending API council approval
44 */
45public final class ContactsContract {
46    /** The authority for the contacts provider */
47    public static final String AUTHORITY = "com.android.contacts";
48    /** A content:// style uri to the authority for the contacts provider */
49    public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
50
51    /**
52     * An optional insert, update or delete URI parameter that allows the caller
53     * to specify that it is a sync adapter. The default value is false. If true
54     * the dirty flag is not automatically set and the "syncToNetwork" parameter
55     * is set to false when calling
56     * {@link ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}.
57     */
58    public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
59
60    public interface SyncStateColumns extends SyncStateContract.Columns {
61    }
62
63    public static final class SyncState {
64        /**
65         * This utility class cannot be instantiated
66         */
67        private SyncState() {}
68
69        public static final String CONTENT_DIRECTORY =
70                SyncStateContract.Constants.CONTENT_DIRECTORY;
71
72        /**
73         * The content:// style URI for this table
74         */
75        public static final Uri CONTENT_URI =
76                Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY);
77
78        /**
79         * @see android.provider.SyncStateContract.Helpers#get
80         */
81        public static byte[] get(ContentProviderClient provider, Account account)
82                throws RemoteException {
83            return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
84        }
85
86        /**
87         * @see android.provider.SyncStateContract.Helpers#get
88         */
89        public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
90                throws RemoteException {
91            return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
92        }
93
94        /**
95         * @see android.provider.SyncStateContract.Helpers#set
96         */
97        public static void set(ContentProviderClient provider, Account account, byte[] data)
98                throws RemoteException {
99            SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
100        }
101
102        /**
103         * @see android.provider.SyncStateContract.Helpers#newSetOperation
104         */
105        public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
106            return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
107        }
108    }
109
110    /**
111     * Generic columns for use by sync adapters. The specific functions of
112     * these columns are private to the sync adapter. Other clients of the API
113     * should not attempt to either read or write this column.
114     */
115    private interface BaseSyncColumns {
116
117        /** Generic column for use by sync adapters. */
118        public static final String SYNC1 = "sync1";
119        /** Generic column for use by sync adapters. */
120        public static final String SYNC2 = "sync2";
121        /** Generic column for use by sync adapters. */
122        public static final String SYNC3 = "sync3";
123        /** Generic column for use by sync adapters. */
124        public static final String SYNC4 = "sync4";
125    }
126
127    /**
128     * Columns that appear when each row of a table belongs to a specific
129     * account, including sync information that an account may need.
130     */
131    private interface SyncColumns extends BaseSyncColumns {
132        /**
133         * The name of the account instance to which this row belongs.
134         * <P>Type: TEXT</P>
135         */
136        public static final String ACCOUNT_NAME = "account_name";
137
138        /**
139         * The type of account to which this row belongs, which when paired with
140         * {@link #ACCOUNT_NAME} identifies a specific account.
141         * <P>Type: TEXT</P>
142         */
143        public static final String ACCOUNT_TYPE = "account_type";
144
145        /**
146         * String that uniquely identifies this row to its source account.
147         * <P>Type: TEXT</P>
148         */
149        public static final String SOURCE_ID = "sourceid";
150
151        /**
152         * Version number that is updated whenever this row or its related data
153         * changes.
154         * <P>Type: INTEGER</P>
155         */
156        public static final String VERSION = "version";
157
158        /**
159         * Flag indicating that {@link #VERSION} has changed, and this row needs
160         * to be synchronized by its owning account.
161         * <P>Type: INTEGER (boolean)</P>
162         */
163        public static final String DIRTY = "dirty";
164    }
165
166    public interface ContactOptionsColumns {
167        /**
168         * The number of times a person has been contacted
169         * <P>Type: INTEGER</P>
170         */
171        public static final String TIMES_CONTACTED = "times_contacted";
172
173        /**
174         * The last time a person was contacted.
175         * <P>Type: INTEGER</P>
176         */
177        public static final String LAST_TIME_CONTACTED = "last_time_contacted";
178
179        /**
180         * Is the contact starred?
181         * <P>Type: INTEGER (boolean)</P>
182         */
183        public static final String STARRED = "starred";
184
185        /**
186         * A custom ringtone associated with a person. Not always present.
187         * <P>Type: TEXT (URI to the ringtone)</P>
188         */
189        public static final String CUSTOM_RINGTONE = "custom_ringtone";
190
191        /**
192         * Whether the person should always be sent to voicemail. Not always
193         * present.
194         * <P>Type: INTEGER (0 for false, 1 for true)</P>
195         */
196        public static final String SEND_TO_VOICEMAIL = "send_to_voicemail";
197    }
198
199    private interface ContactsColumns {
200        /**
201         * The display name for the contact.
202         * <P>Type: TEXT</P>
203         */
204        public static final String DISPLAY_NAME = "display_name";
205
206        /**
207         * Reference to the row in the data table holding the photo.
208         * <P>Type: INTEGER REFERENCES data(_id)</P>
209         */
210        public static final String PHOTO_ID = "photo_id";
211
212        /**
213         * Lookup value that reflects the {@link Groups#GROUP_VISIBLE} state of
214         * any {@link CommonDataKinds.GroupMembership} for this contact.
215         */
216        public static final String IN_VISIBLE_GROUP = "in_visible_group";
217
218        /**
219         * Contact presence status.  See {@link android.provider.Im.CommonPresenceColumns}
220         * for individual status definitions.  This column is only returned if explicitly
221         * requested in the query projection.
222         * <p>Type: NUMBER</p>
223         */
224        public static final String PRESENCE_STATUS = Presence.PRESENCE_STATUS;
225
226        /**
227         * Contact presence custom status. This column is only returned if explicitly
228         * requested in the query projection.
229         * <p>Type: TEXT</p>
230         */
231        public static final String PRESENCE_CUSTOM_STATUS = Presence.PRESENCE_CUSTOM_STATUS;
232
233        /**
234         * An indicator of whether this contact has at least one phone number. "1" if there is
235         * at least one phone number, "0" otherwise.
236         * <P>Type: INTEGER</P>
237         */
238        public static final String HAS_PHONE_NUMBER = "has_phone_number";
239
240        /**
241         * An opaque value that contains hints on how to find the contact if
242         * its row id changed as a result of a sync or aggregation.
243         */
244        public static final String LOOKUP_KEY = "lookup";
245    }
246
247    /**
248     * Constants for the contacts table, which contains a record per group
249     * of raw contact representing the same person.
250     */
251    public static class Contacts implements BaseColumns, ContactsColumns,
252            ContactOptionsColumns {
253        /**
254         * This utility class cannot be instantiated
255         */
256        private Contacts()  {}
257
258        /**
259         * The content:// style URI for this table
260         */
261        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
262
263        /**
264         * A content:// style URI for this table that should be used to create
265         * shortcuts or otherwise create long-term links to contacts. This URI
266         * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}.
267         * It can optionally also have a "/" and last known contact ID appended after
268         * that. This "complete" format is an important optimization and is highly recommended.
269         * <p>
270         * As long as the contact's row ID remains the same, this URI is
271         * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes
272         * as a result of a sync or aggregation, this URI will look up the
273         * contact using indirect information (sync IDs or constituent raw
274         * contacts).
275         * <p>
276         * Lookup key should be appended unencoded - it is stored in the encoded
277         * form, ready for use in a URI.
278         */
279        public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
280                "lookup");
281
282        /**
283         * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the
284         * requested {@link Contacts} entry.
285         *
286         * @param contactUri A {@link #CONTENT_URI} row, or an existing
287         *            {@link #CONTENT_LOOKUP_URI} to attempt refreshing.
288         */
289        public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) {
290            final Cursor c = resolver.query(contactUri, new String[] {
291                    Contacts.LOOKUP_KEY, Contacts._ID
292            }, null, null, null);
293            if (c == null) {
294                return null;
295            }
296
297            try {
298                if (c.moveToFirst()) {
299                    final String lookupKey = c.getString(0);
300                    final long contactId = c.getLong(1);
301                    return getLookupUri(contactId, lookupKey);
302                }
303            } finally {
304                c.close();
305            }
306            return null;
307        }
308
309        /**
310         * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the
311         * given {@link Contacts#_ID} and {@link Contacts#LOOKUP_KEY}.
312         */
313        public static Uri getLookupUri(long contactId, String lookupKey) {
314            return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI,
315                    lookupKey), contactId);
316        }
317
318        /**
319         * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI.
320         * <p>
321         * Returns null if the contact cannot be found.
322         */
323        public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) {
324            if (lookupUri == null) {
325                return null;
326            }
327
328            Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null);
329            if (c == null) {
330                return null;
331            }
332
333            try {
334                if (c.moveToFirst()) {
335                    long contactId = c.getLong(0);
336                    return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
337                }
338            } finally {
339                c.close();
340            }
341            return null;
342        }
343
344        /**
345         * The content:// style URI used for "type-to-filter" functionality on the
346         * {@link #CONTENT_URI} URI. The filter string will be used to match
347         * various parts of the contact name. The filter argument should be passed
348         * as an additional path segment after this URI.
349         */
350        public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
351                CONTENT_URI, "filter");
352
353        /**
354         * The content:// style URI for this table joined with useful data from
355         * {@link Data}, filtered to include only starred contacts
356         * and the most frequently contacted contacts.
357         */
358        public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath(
359                CONTENT_URI, "strequent");
360
361        /**
362         * The content:// style URI used for "type-to-filter" functionality on the
363         * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match
364         * various parts of the contact name. The filter argument should be passed
365         * as an additional path segment after this URI.
366         */
367        public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath(
368                CONTENT_STREQUENT_URI, "filter");
369
370        public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath(
371                CONTENT_URI, "group");
372
373        /**
374         * The MIME type of {@link #CONTENT_URI} providing a directory of
375         * people.
376         */
377        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
378
379        /**
380         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
381         * person.
382         */
383        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
384
385        /**
386         * A sub-directory of a single contact that contains all of the constituent raw contact
387         * {@link Data} rows.
388         */
389        public static final class Data implements BaseColumns, DataColumns {
390            /**
391             * no public constructor since this is a utility class
392             */
393            private Data() {}
394
395            /**
396             * The directory twig for this sub-table
397             */
398            public static final String CONTENT_DIRECTORY = "data";
399        }
400
401        /**
402         * A sub-directory of a single contact aggregate that contains all aggregation suggestions
403         * (other contacts).  The aggregation suggestions are computed based on approximate
404         * data matches with this contact.
405         */
406        public static final class AggregationSuggestions implements BaseColumns, ContactsColumns {
407            /**
408             * No public constructor since this is a utility class
409             */
410            private AggregationSuggestions() {}
411
412            /**
413             * The directory twig for this sub-table
414             */
415            public static final String CONTENT_DIRECTORY = "suggestions";
416        }
417
418        /**
419         * A sub-directory of a single contact that contains the contact's primary photo.
420         */
421        public static final class Photo implements BaseColumns, DataColumns {
422            /**
423             * no public constructor since this is a utility class
424             */
425            private Photo() {}
426
427            /**
428             * The directory twig for this sub-table
429             */
430            public static final String CONTENT_DIRECTORY = "photo";
431        }
432
433        /**
434         * Opens an InputStream for the person's default photo and returns the
435         * photo as a Bitmap stream.
436         *
437         * @param contactUri the contact whose photo should be used
438         */
439        public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
440            Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY);
441            if (photoUri == null) {
442                return null;
443            }
444            Cursor cursor = cr.query(photoUri,
445                    new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null);
446            try {
447                if (cursor == null || !cursor.moveToNext()) {
448                    return null;
449                }
450                byte[] data = cursor.getBlob(0);
451                if (data == null) {
452                    return null;
453                }
454                return new ByteArrayInputStream(data);
455            } finally {
456                if (cursor != null) {
457                    cursor.close();
458                }
459            }
460        }
461    }
462
463    private interface RawContactsColumns {
464        /**
465         * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} that this
466         * data belongs to.
467         * <P>Type: INTEGER</P>
468         */
469        public static final String CONTACT_ID = "contact_id";
470
471        /**
472         * Flag indicating that this {@link RawContacts} entry and its children has
473         * been restricted to specific platform apps.
474         * <P>Type: INTEGER (boolean)</P>
475         *
476         * @hide until finalized in future platform release
477         */
478        public static final String IS_RESTRICTED = "is_restricted";
479
480        /**
481         * The aggregation mode for this contact.
482         * <P>Type: INTEGER</P>
483         */
484        public static final String AGGREGATION_MODE = "aggregation_mode";
485
486        /**
487         * The "deleted" flag: "0" by default, "1" if the row has been marked
488         * for deletion. When {@link android.content.ContentResolver#delete} is
489         * called on a raw contact, it is marked for deletion and removed from its
490         * aggregate contact. The sync adaptor deletes the raw contact on the server and
491         * then calls ContactResolver.delete once more, this time passing the
492         * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
493         * the data removal.
494         * <P>Type: INTEGER</P>
495         */
496        public static final String DELETED = "deleted";
497    }
498
499    /**
500     * Constants for the raw_contacts table, which contains the base contact
501     * information per sync source. Sync adapters and contact management apps
502     * are the primary consumers of this API.
503     */
504    public static final class RawContacts implements BaseColumns, RawContactsColumns,
505            ContactOptionsColumns, SyncColumns  {
506        /**
507         * This utility class cannot be instantiated
508         */
509        private RawContacts() {
510        }
511
512        /**
513         * The content:// style URI for this table
514         */
515        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
516
517        /**
518         * The MIME type of {@link #CONTENT_URI} providing a directory of
519         * people.
520         */
521        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
522
523        /**
524         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
525         * person.
526         */
527        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
528
529        /**
530         * Aggregation mode: aggregate asynchronously.
531         */
532        public static final int AGGREGATION_MODE_DEFAULT = 0;
533
534        /**
535         * Aggregation mode: aggregate at the time the raw contact is inserted/updated.
536         */
537        public static final int AGGREGATION_MODE_IMMEDIATE = 1;
538
539        /**
540         * If {@link #AGGREGATION_MODE} is {@link #AGGREGATION_MODE_SUSPENDED}, changes
541         * to the raw contact do not cause its aggregation to be revisited. Note that changing
542         * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to
543         * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass. Any subsequent
544         * change to the raw contact's data will.
545         */
546        public static final int AGGREGATION_MODE_SUSPENDED = 2;
547
548        /**
549         * Aggregation mode: never aggregate this raw contact (note that the raw contact will not
550         * have a corresponding Aggregate and therefore will not be included in Aggregates
551         * query results.)
552         */
553        public static final int AGGREGATION_MODE_DISABLED = 3;
554
555        /**
556         * Build a {@link Contacts#CONTENT_LOOKUP_URI} style {@link Uri} for the
557         * parent {@link Contacts} entry of the given {@link RawContacts} entry.
558         */
559        public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) {
560            // TODO: use a lighter query by joining rawcontacts with contacts in provider
561            final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY);
562            final Cursor cursor = resolver.query(dataUri, new String[] {
563                    RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
564            }, null, null, null);
565
566            Uri lookupUri = null;
567            try {
568                if (cursor != null && cursor.moveToFirst()) {
569                    final long contactId = cursor.getLong(0);
570                    final String lookupKey = cursor.getString(1);
571                    return Contacts.getLookupUri(contactId, lookupKey);
572                }
573            } finally {
574                if (cursor != null) cursor.close();
575            }
576            return lookupUri;
577        }
578
579        /**
580         * A sub-directory of a single raw contact that contains all of their {@link Data} rows.
581         * To access this directory append {@link Data#CONTENT_DIRECTORY} to the contact URI.
582         */
583        public static final class Data implements BaseColumns, DataColumns {
584            /**
585             * no public constructor since this is a utility class
586             */
587            private Data() {
588            }
589
590            /**
591             * The directory twig for this sub-table
592             */
593            public static final String CONTENT_DIRECTORY = "data";
594        }
595    }
596
597    private interface DataColumns {
598        /**
599         * The package name to use when creating {@link Resources} objects for
600         * this data row. This value is only designed for use when building user
601         * interfaces, and should not be used to infer the owner.
602         */
603        public static final String RES_PACKAGE = "res_package";
604
605        /**
606         * The MIME type of the item represented by this row.
607         */
608        public static final String MIMETYPE = "mimetype";
609
610        /**
611         * A reference to the {@link RawContacts#_ID}
612         * that this data belongs to.
613         */
614        public static final String RAW_CONTACT_ID = "raw_contact_id";
615
616        /**
617         * Whether this is the primary entry of its kind for the raw contact it belongs to
618         * <P>Type: INTEGER (if set, non-0 means true)</P>
619         */
620        public static final String IS_PRIMARY = "is_primary";
621
622        /**
623         * Whether this is the primary entry of its kind for the aggregate
624         * contact it belongs to. Any data record that is "super primary" must
625         * also be "primary".
626         * <P>Type: INTEGER (if set, non-0 means true)</P>
627         */
628        public static final String IS_SUPER_PRIMARY = "is_super_primary";
629
630        /**
631         * The version of this data record. This is a read-only value. The data column is
632         * guaranteed to not change without the version going up. This value is monotonically
633         * increasing.
634         * <P>Type: INTEGER</P>
635         */
636        public static final String DATA_VERSION = "data_version";
637
638        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
639        public static final String DATA1 = "data1";
640        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
641        public static final String DATA2 = "data2";
642        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
643        public static final String DATA3 = "data3";
644        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
645        public static final String DATA4 = "data4";
646        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
647        public static final String DATA5 = "data5";
648        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
649        public static final String DATA6 = "data6";
650        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
651        public static final String DATA7 = "data7";
652        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
653        public static final String DATA8 = "data8";
654        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
655        public static final String DATA9 = "data9";
656        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
657        public static final String DATA10 = "data10";
658        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
659        public static final String DATA11 = "data11";
660        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
661        public static final String DATA12 = "data12";
662        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
663        public static final String DATA13 = "data13";
664        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
665        public static final String DATA14 = "data14";
666        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
667        public static final String DATA15 = "data15";
668
669        /** Generic column for use by sync adapters. */
670        public static final String SYNC1 = "data_sync1";
671        /** Generic column for use by sync adapters. */
672        public static final String SYNC2 = "data_sync2";
673        /** Generic column for use by sync adapters. */
674        public static final String SYNC3 = "data_sync3";
675        /** Generic column for use by sync adapters. */
676        public static final String SYNC4 = "data_sync4";
677    }
678
679    /**
680     * Constants for the data table, which contains data points tied to a raw contact.
681     * For example, a phone number or email address. Each row in this table contains a type
682     * definition and some generic columns. Each data type can define the meaning for each of
683     * the generic columns.
684     */
685    public static final class Data implements BaseColumns, DataColumns {
686        /**
687         * This utility class cannot be instantiated
688         */
689        private Data() {}
690
691        /**
692         * The content:// style URI for this table
693         */
694        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
695
696        /**
697         * The content:// style URI for this table joined with {@link Presence}
698         * data where applicable.
699         *
700         * @hide
701         */
702        public static final Uri CONTENT_WITH_PRESENCE_URI = Uri.withAppendedPath(AUTHORITY_URI,
703                "data_with_presence");
704
705        /**
706         * The MIME type of {@link #CONTENT_URI} providing a directory of data.
707         */
708        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
709
710        /**
711         * Build a {@link Contacts#CONTENT_LOOKUP_URI} style {@link Uri} for the
712         * parent {@link Contacts} entry of the given {@link Data} entry.
713         */
714        public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) {
715            final Cursor cursor = resolver.query(dataUri, new String[] {
716                    RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
717            }, null, null, null);
718
719            Uri lookupUri = null;
720            try {
721                if (cursor != null && cursor.moveToFirst()) {
722                    final long contactId = cursor.getLong(0);
723                    final String lookupKey = cursor.getString(1);
724                    return Contacts.getLookupUri(contactId, lookupKey);
725                }
726            } finally {
727                if (cursor != null) cursor.close();
728            }
729            return lookupUri;
730        }
731    }
732
733    private interface PhoneLookupColumns {
734        /**
735         * The phone number as the user entered it.
736         * <P>Type: TEXT</P>
737         */
738        public static final String NUMBER = "number";
739
740        /**
741         * The type of phone number, for example Home or Work.
742         * <P>Type: INTEGER</P>
743         */
744        public static final String TYPE = "type";
745
746        /**
747         * The user defined label for the phone number.
748         * <P>Type: TEXT</P>
749         */
750        public static final String LABEL = "label";
751    }
752
753    /**
754     * A table that represents the result of looking up a phone number, for
755     * example for caller ID. To perform a lookup you must append the number you
756     * want to find to {@link #CONTENT_FILTER_URI}.
757     */
758    public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
759            ContactsColumns, ContactOptionsColumns {
760        /**
761         * This utility class cannot be instantiated
762         */
763        private PhoneLookup() {}
764
765        /**
766         * The content:// style URI for this table. Append the phone number you want to lookup
767         * to this URI and query it to perform a lookup. For example:
768         *
769         * {@code
770         * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, phoneNumber);
771         * }
772         */
773        public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
774                "phone_lookup");
775    }
776
777    /**
778     * Additional data mixed in with {@link Im.CommonPresenceColumns} to link
779     * back to specific {@link ContactsContract.Contacts#_ID} entries.
780     */
781    private interface PresenceColumns {
782
783        /**
784         * The unique ID for a row.
785         * <P>Type: INTEGER (long)</P>
786         */
787        public static final String _ID = "presence_id";
788
789        /**
790         * Reference to the {@link Data#_ID} entry that owns this presence.
791         * <P>Type: INTEGER</P>
792         */
793        public static final String DATA_ID = "presence_data_id";
794
795        /**
796         * <p>Type: NUMBER</p>
797         */
798        public static final String PROTOCOL = "protocol";
799
800        /**
801         * Name of the custom protocol.  Should be supplied along with the {@link #PROTOCOL} value
802         * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.  Should be null or
803         * omitted if {@link #PROTOCOL} value is not
804         * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.
805         *
806         * <p>Type: NUMBER</p>
807         */
808        public static final String CUSTOM_PROTOCOL = "custom_protocol";
809
810        /**
811         * The IM handle the presence item is for. The handle is scoped to
812         * {@link #PROTOCOL}.
813         * <P>Type: TEXT</P>
814         */
815        public static final String IM_HANDLE = "im_handle";
816
817        /**
818         * The IM account for the local user that the presence data came from.
819         * <P>Type: TEXT</P>
820         */
821        public static final String IM_ACCOUNT = "im_account";
822    }
823
824    public static final class Presence implements PresenceColumns, Im.CommonPresenceColumns {
825        /**
826         * This utility class cannot be instantiated
827         */
828        private Presence() {
829        }
830
831        /**
832         * The content:// style URI for this table
833         */
834        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "presence");
835
836        /**
837         * Gets the resource ID for the proper presence icon.
838         *
839         * @param status the status to get the icon for
840         * @return the resource ID for the proper presence icon
841         */
842        public static final int getPresenceIconResourceId(int status) {
843            switch (status) {
844                case AVAILABLE:
845                    return android.R.drawable.presence_online;
846                case IDLE:
847                case AWAY:
848                    return android.R.drawable.presence_away;
849                case DO_NOT_DISTURB:
850                    return android.R.drawable.presence_busy;
851                case INVISIBLE:
852                    return android.R.drawable.presence_invisible;
853                case OFFLINE:
854                default:
855                    return android.R.drawable.presence_offline;
856            }
857        }
858
859        /**
860         * Returns the precedence of the status code the higher number being the higher precedence.
861         *
862         * @param status The status code.
863         * @return An integer representing the precedence, 0 being the lowest.
864         */
865        public static final int getPresencePrecedence(int status) {
866            // Keep this function here incase we want to enforce a different precedence than the
867            // natural order of the status constants.
868            return status;
869        }
870
871        /**
872         * The MIME type of {@link #CONTENT_URI} providing a directory of
873         * presence details.
874         */
875        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-presence";
876
877        /**
878         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
879         * presence detail.
880         */
881        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-presence";
882    }
883
884    /**
885     * Container for definitions of common data types stored in the {@link Data} table.
886     */
887    public static final class CommonDataKinds {
888        /**
889         * The {@link Data#RES_PACKAGE} value for common data that should be
890         * shown using a default style.
891         */
892        public static final String PACKAGE_COMMON = "common";
893
894        /**
895         * Columns common across the specific types.
896         */
897        private interface BaseCommonColumns {
898            /**
899             * The package name to use when creating {@link Resources} objects for
900             * this data row. This value is only designed for use when building user
901             * interfaces, and should not be used to infer the owner.
902             */
903            public static final String RES_PACKAGE = "res_package";
904
905            /**
906             * The MIME type of the item represented by this row.
907             */
908            public static final String MIMETYPE = "mimetype";
909
910            /**
911             * The {@link RawContacts#_ID} that this data belongs to.
912             */
913            public static final String RAW_CONTACT_ID = "raw_contact_id";
914        }
915
916        /**
917         * The base types that all "Typed" data kinds support.
918         */
919        public interface BaseTypes {
920
921            /**
922             * A custom type. The custom label should be supplied by user.
923             */
924            public static int TYPE_CUSTOM = 0;
925        }
926
927        /**
928         * Columns common across the specific types.
929         */
930        private interface CommonColumns extends BaseTypes{
931            /**
932             * The type of data, for example Home or Work.
933             * <P>Type: INTEGER</P>
934             */
935            public static final String TYPE = "data1";
936
937            /**
938             * The data for the contact method.
939             * <P>Type: TEXT</P>
940             */
941            public static final String DATA = "data2";
942
943            /**
944             * The user defined label for the the contact method.
945             * <P>Type: TEXT</P>
946             */
947            public static final String LABEL = "data3";
948        }
949
950        /**
951         * Parts of the name.
952         */
953        public static final class StructuredName implements BaseCommonColumns {
954            private StructuredName() {}
955
956            /** MIME type used when storing this in data table. */
957            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
958
959            /**
960             * The given name for the contact.
961             * <P>Type: TEXT</P>
962             */
963            public static final String GIVEN_NAME = "data1";
964
965            /**
966             * The family name for the contact.
967             * <P>Type: TEXT</P>
968             */
969            public static final String FAMILY_NAME = "data2";
970
971            /**
972             * The contact's honorific prefix, e.g. "Sir"
973             * <P>Type: TEXT</P>
974             */
975            public static final String PREFIX = "data3";
976
977            /**
978             * The contact's middle name
979             * <P>Type: TEXT</P>
980             */
981            public static final String MIDDLE_NAME = "data4";
982
983            /**
984             * The contact's honorific suffix, e.g. "Jr"
985             */
986            public static final String SUFFIX = "data5";
987
988            /**
989             * The phonetic version of the given name for the contact.
990             * <P>Type: TEXT</P>
991             */
992            public static final String PHONETIC_GIVEN_NAME = "data6";
993
994            /**
995             * The phonetic version of the additional name for the contact.
996             * <P>Type: TEXT</P>
997             */
998            public static final String PHONETIC_MIDDLE_NAME = "data7";
999
1000            /**
1001             * The phonetic version of the family name for the contact.
1002             * <P>Type: TEXT</P>
1003             */
1004            public static final String PHONETIC_FAMILY_NAME = "data8";
1005
1006            /**
1007             * The name that should be used to display the contact.
1008             * <i>Unstructured component of the name should be consistent with
1009             * its structured representation.</i>
1010             * <p>
1011             * Type: TEXT
1012             */
1013            public static final String DISPLAY_NAME = "data9";
1014        }
1015
1016        /**
1017         * A nickname.
1018         */
1019        public static final class Nickname implements CommonColumns, BaseCommonColumns {
1020            private Nickname() {}
1021
1022            /** MIME type used when storing this in data table. */
1023            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
1024
1025            public static final int TYPE_DEFAULT = 1;
1026            public static final int TYPE_OTHER_NAME = 2;
1027            public static final int TYPE_MAINDEN_NAME = 3;
1028            public static final int TYPE_SHORT_NAME = 4;
1029            public static final int TYPE_INITIALS = 5;
1030
1031            /**
1032             * The name itself
1033             */
1034            public static final String NAME = DATA;
1035        }
1036
1037        /**
1038         * Common data definition for telephone numbers.
1039         */
1040        public static final class Phone implements BaseCommonColumns, CommonColumns {
1041            private Phone() {}
1042
1043            /** MIME type used when storing this in data table. */
1044            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
1045
1046            /**
1047             * The MIME type of {@link #CONTENT_URI} providing a directory of
1048             * phones.
1049             */
1050            public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
1051
1052            /**
1053             * The content:// style URI for all data records of the
1054             * {@link Phone#CONTENT_ITEM_TYPE} MIME type, combined with the
1055             * associated raw contact and aggregate contact data.
1056             */
1057            public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1058                    "phones");
1059
1060            /**
1061             * The content:// style URL for phone lookup using a filter. The filter returns
1062             * records of MIME type {@link Phone#CONTENT_ITEM_TYPE}. The filter is applied
1063             * to display names as well as phone numbers. The filter argument should be passed
1064             * as an additional path segment after this URI.
1065             */
1066            public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
1067                    "filter");
1068
1069            public static final int TYPE_HOME = 1;
1070            public static final int TYPE_MOBILE = 2;
1071            public static final int TYPE_WORK = 3;
1072            public static final int TYPE_FAX_WORK = 4;
1073            public static final int TYPE_FAX_HOME = 5;
1074            public static final int TYPE_PAGER = 6;
1075            public static final int TYPE_OTHER = 7;
1076            public static final int TYPE_CALLBACK = 8;
1077            public static final int TYPE_CAR = 9;
1078            public static final int TYPE_COMPANY_MAIN = 10;
1079            public static final int TYPE_ISDN = 11;
1080            public static final int TYPE_MAIN = 12;
1081            public static final int TYPE_OTHER_FAX = 13;
1082            public static final int TYPE_RADIO = 14;
1083            public static final int TYPE_TELEX = 15;
1084            public static final int TYPE_TTY_TDD = 16;
1085            public static final int TYPE_WORK_MOBILE = 17;
1086            public static final int TYPE_WORK_PAGER = 18;
1087            public static final int TYPE_ASSISTANT = 19;
1088            public static final int TYPE_MMS = 20;
1089
1090            /**
1091             * The phone number as the user entered it.
1092             * <P>Type: TEXT</P>
1093             */
1094            public static final String NUMBER = DATA;
1095
1096            public static final CharSequence getDisplayLabel(Context context, int type,
1097                    CharSequence label, CharSequence[] labelArray) {
1098                CharSequence display = "";
1099
1100                if (type != Phone.TYPE_CUSTOM) {
1101                    CharSequence[] labels = labelArray != null? labelArray
1102                            : context.getResources().getTextArray(
1103                                    com.android.internal.R.array.phoneTypes);
1104                    try {
1105                        display = labels[type - 1];
1106                    } catch (ArrayIndexOutOfBoundsException e) {
1107                        display = labels[Phone.TYPE_CUSTOM];
1108                    }
1109                } else {
1110                    if (!TextUtils.isEmpty(label)) {
1111                        display = label;
1112                    }
1113                }
1114                return display;
1115            }
1116
1117            public static final CharSequence getDisplayLabel(Context context, int type,
1118                    CharSequence label) {
1119                return getDisplayLabel(context, type, label, null);
1120            }
1121        }
1122
1123        /**
1124         * Common data definition for email addresses.
1125         */
1126        public static final class Email implements BaseCommonColumns, CommonColumns {
1127            private Email() {}
1128
1129            /** MIME type used when storing this in data table. */
1130            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2";
1131
1132            /**
1133             * The content:// style URI for all data records of the
1134             * {@link Email#CONTENT_ITEM_TYPE} MIME type, combined with the
1135             * associated raw contact and aggregate contact data.
1136             */
1137            public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1138                    "emails");
1139
1140            /**
1141             * The content:// style URL for looking up data rows by email address. The
1142             * lookup argument, an email address, should be passed as an additional path segment
1143             * after this URI.
1144             */
1145            public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
1146                    "lookup");
1147
1148            @Deprecated
1149            public static final Uri CONTENT_FILTER_EMAIL_URI = CONTENT_LOOKUP_URI;
1150
1151            /**
1152             * The content:// style URL for email lookup using a filter. The filter returns
1153             * records of MIME type {@link Email#CONTENT_ITEM_TYPE}. The filter is applied
1154             * to display names as well as email addresses. The filter argument should be passed
1155             * as an additional path segment after this URI.
1156             */
1157            public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
1158                    "filter");
1159
1160            public static final int TYPE_HOME = 1;
1161            public static final int TYPE_WORK = 2;
1162            public static final int TYPE_OTHER = 3;
1163            public static final int TYPE_MOBILE = 4;
1164
1165            /**
1166             * The display name for the email address
1167             * <P>Type: TEXT</P>
1168             */
1169            public static final String DISPLAY_NAME = "data4";
1170        }
1171
1172        /**
1173         * Common data definition for postal addresses.
1174         */
1175        public static final class StructuredPostal implements BaseCommonColumns, CommonColumns {
1176            private StructuredPostal() {
1177            }
1178
1179            /** MIME type used when storing this in data table. */
1180            public static final String CONTENT_ITEM_TYPE =
1181                    "vnd.android.cursor.item/postal-address_v2";
1182
1183            /**
1184             * The MIME type of {@link #CONTENT_URI} providing a directory of
1185             * postal addresses.
1186             */
1187            public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2";
1188
1189            /**
1190             * The content:// style URI for all data records of the
1191             * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
1192             */
1193            public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1194                    "postals");
1195
1196            public static final int TYPE_HOME = 1;
1197            public static final int TYPE_WORK = 2;
1198            public static final int TYPE_OTHER = 3;
1199
1200            /**
1201             * The full, unstructured postal address. <i>This field must be
1202             * consistent with any structured data.</i>
1203             * <p>
1204             * Type: TEXT
1205             */
1206            public static final String FORMATTED_ADDRESS = DATA;
1207
1208            /**
1209             * Can be street, avenue, road, etc. This element also includes the
1210             * house number and room/apartment/flat/floor number.
1211             * <p>
1212             * Type: TEXT
1213             */
1214            public static final String STREET = "data6";
1215
1216            /**
1217             * Covers actual P.O. boxes, drawers, locked bags, etc. This is
1218             * usually but not always mutually exclusive with street.
1219             * <p>
1220             * Type: TEXT
1221             */
1222            public static final String POBOX = "data7";
1223
1224            /**
1225             * This is used to disambiguate a street address when a city
1226             * contains more than one street with the same name, or to specify a
1227             * small place whose mail is routed through a larger postal town. In
1228             * China it could be a county or a minor city.
1229             * <p>
1230             * Type: TEXT
1231             */
1232            public static final String NEIGHBORHOOD = "data8";
1233
1234            /**
1235             * Can be city, village, town, borough, etc. This is the postal town
1236             * and not necessarily the place of residence or place of business.
1237             * <p>
1238             * Type: TEXT
1239             */
1240            public static final String CITY = "data9";
1241
1242            /**
1243             * A state, province, county (in Ireland), Land (in Germany),
1244             * departement (in France), etc.
1245             * <p>
1246             * Type: TEXT
1247             */
1248            public static final String REGION = "data11";
1249
1250            /**
1251             * Postal code. Usually country-wide, but sometimes specific to the
1252             * city (e.g. "2" in "Dublin 2, Ireland" addresses).
1253             * <p>
1254             * Type: TEXT
1255             */
1256            public static final String POSTCODE = "data12";
1257
1258            /**
1259             * The name or code of the country.
1260             * <p>
1261             * Type: TEXT
1262             */
1263            public static final String COUNTRY = "data13";
1264        }
1265
1266        /**
1267         * Common data definition for IM addresses.
1268         */
1269        public static final class Im implements BaseCommonColumns, CommonColumns {
1270            private Im() {}
1271
1272            /** MIME type used when storing this in data table. */
1273            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
1274
1275            public static final int TYPE_HOME = 1;
1276            public static final int TYPE_WORK = 2;
1277            public static final int TYPE_OTHER = 3;
1278
1279            /**
1280             * This column should be populated with one of the defined
1281             * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this
1282             * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL}
1283             * should contain the name of the custom protocol.
1284             */
1285            public static final String PROTOCOL = "data5";
1286
1287            public static final String CUSTOM_PROTOCOL = "data6";
1288
1289            /*
1290             * The predefined IM protocol types.
1291             */
1292            public static final int PROTOCOL_CUSTOM = -1;
1293            public static final int PROTOCOL_AIM = 0;
1294            public static final int PROTOCOL_MSN = 1;
1295            public static final int PROTOCOL_YAHOO = 2;
1296            public static final int PROTOCOL_SKYPE = 3;
1297            public static final int PROTOCOL_QQ = 4;
1298            public static final int PROTOCOL_GOOGLE_TALK = 5;
1299            public static final int PROTOCOL_ICQ = 6;
1300            public static final int PROTOCOL_JABBER = 7;
1301            public static final int PROTOCOL_NETMEETING = 8;
1302        }
1303
1304        /**
1305         * Common data definition for organizations.
1306         */
1307        public static final class Organization implements BaseCommonColumns, CommonColumns {
1308            private Organization() {}
1309
1310            /** MIME type used when storing this in data table. */
1311            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
1312
1313            public static final int TYPE_WORK = 1;
1314            public static final int TYPE_OTHER = 2;
1315
1316            /**
1317             * The company as the user entered it.
1318             * <P>Type: TEXT</P>
1319             */
1320            public static final String COMPANY = DATA;
1321
1322            /**
1323             * The position title at this company as the user entered it.
1324             * <P>Type: TEXT</P>
1325             */
1326            public static final String TITLE = "data4";
1327
1328            /**
1329             * The department at this company as the user entered it.
1330             * <P>Type: TEXT</P>
1331             */
1332            public static final String DEPARTMENT = "data5";
1333
1334            /**
1335             * The job description at this company as the user entered it.
1336             * <P>Type: TEXT</P>
1337             */
1338            public static final String JOB_DESCRIPTION = "data6";
1339
1340            /**
1341             * The symbol of this company as the user entered it.
1342             * <P>Type: TEXT</P>
1343             */
1344            public static final String SYMBOL = "data7";
1345
1346            /**
1347             * The phonetic name of this company as the user entered it.
1348             * <P>Type: TEXT</P>
1349             */
1350            public static final String PHONETIC_NAME = "data8";
1351        }
1352
1353        /**
1354         * Common data definition for miscellaneous information.
1355         */
1356        public static final class Miscellaneous implements BaseCommonColumns {
1357            private Miscellaneous() {}
1358
1359            /** MIME type used when storing this in data table. */
1360            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/misc";
1361
1362            /**
1363             * The birthday as the user entered it.
1364             * <P>Type: TEXT</P>
1365             */
1366            public static final String BIRTHDAY = "data1";
1367
1368            /**
1369             * The nickname as the user entered it.
1370             * <P>Type: TEXT</P>
1371             */
1372            public static final String NICKNAME = "data2";
1373        }
1374
1375        /**
1376         * Common data definition for relations.
1377         */
1378        public static final class Relation implements BaseCommonColumns, CommonColumns {
1379            private Relation() {}
1380
1381            /** MIME type used when storing this in data table. */
1382            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
1383
1384            public static final int TYPE_ASSISTANT = 1;
1385            public static final int TYPE_BROTHER = 2;
1386            public static final int TYPE_CHILD = 3;
1387            public static final int TYPE_DOMESTIC_PARTNER = 4;
1388            public static final int TYPE_FATHER = 5;
1389            public static final int TYPE_FRIEND = 6;
1390            public static final int TYPE_MANAGER = 7;
1391            public static final int TYPE_MOTHER = 8;
1392            public static final int TYPE_PARENT = 9;
1393            public static final int TYPE_PARTNER = 10;
1394            public static final int TYPE_REFERRED_BY = 11;
1395            public static final int TYPE_RELATIVE = 12;
1396            public static final int TYPE_SISTER = 13;
1397            public static final int TYPE_SPOUSE = 14;
1398
1399            /**
1400             * The name of the relative as the user entered it.
1401             * <P>Type: TEXT</P>
1402             */
1403            public static final String NAME = DATA;
1404        }
1405
1406        /**
1407         * Common data definition for events.
1408         */
1409        public static final class Event implements BaseCommonColumns, CommonColumns {
1410            private Event() {}
1411
1412            /** MIME type used when storing this in data table. */
1413            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/event";
1414
1415            public static final int TYPE_ANNIVERSARY = 1;
1416            public static final int TYPE_OTHER = 2;
1417
1418            /**
1419             * The event start date as the user entered it.
1420             * <P>Type: TEXT</P>
1421             */
1422            public static final String START_DATE = DATA;
1423        }
1424
1425        /**
1426         * Photo of the contact.
1427         */
1428        public static final class Photo implements BaseCommonColumns {
1429            private Photo() {}
1430
1431            /** MIME type used when storing this in data table. */
1432            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
1433
1434            /**
1435             * Thumbnail photo of the raw contact. This is the raw bytes of an image
1436             * that could be inflated using {@link BitmapFactory}.
1437             * <p>
1438             * Type: BLOB
1439             */
1440            public static final String PHOTO = "data1";
1441        }
1442
1443        /**
1444         * Notes about the contact.
1445         */
1446        public static final class Note implements BaseCommonColumns {
1447            private Note() {}
1448
1449            /** MIME type used when storing this in data table. */
1450            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
1451
1452            /**
1453             * The note text.
1454             * <P>Type: TEXT</P>
1455             */
1456            public static final String NOTE = "data1";
1457        }
1458
1459        /**
1460         * Group Membership.
1461         */
1462        public static final class GroupMembership implements BaseCommonColumns {
1463            private GroupMembership() {}
1464
1465            /** MIME type used when storing this in data table. */
1466            public static final String CONTENT_ITEM_TYPE =
1467                    "vnd.android.cursor.item/group_membership";
1468
1469            /**
1470             * The row id of the group that this group membership refers to. Exactly one of
1471             * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
1472             * <P>Type: INTEGER</P>
1473             */
1474            public static final String GROUP_ROW_ID = "data1";
1475
1476            /**
1477             * The sourceid of the group that this group membership refers to.  Exactly one of
1478             * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
1479             * <P>Type: TEXT</P>
1480             */
1481            public static final String GROUP_SOURCE_ID = "group_sourceid";
1482        }
1483
1484        /**
1485         * Website related to the contact.
1486         */
1487        public static final class Website implements BaseCommonColumns, CommonColumns {
1488            private Website() {}
1489
1490            /** MIME type used when storing this in data table. */
1491            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
1492
1493            public static final int TYPE_HOMEPAGE = 1;
1494            public static final int TYPE_BLOG = 2;
1495            public static final int TYPE_PROFILE = 3;
1496            public static final int TYPE_HOME = 4;
1497            public static final int TYPE_WORK = 5;
1498            public static final int TYPE_FTP = 6;
1499            public static final int TYPE_OTHER = 7;
1500
1501            /**
1502             * The website URL string.
1503             * <P>Type: TEXT</P>
1504             */
1505            public static final String URL = "data1";
1506        }
1507    }
1508
1509    // TODO: make this private before unhiding
1510    public interface GroupsColumns {
1511        /**
1512         * The display title of this group.
1513         * <p>
1514         * Type: TEXT
1515         */
1516        public static final String TITLE = "title";
1517
1518        /**
1519         * The package name to use when creating {@link Resources} objects for
1520         * this group. This value is only designed for use when building user
1521         * interfaces, and should not be used to infer the owner.
1522         */
1523        public static final String RES_PACKAGE = "res_package";
1524
1525        /**
1526         * The display title of this group to load as a resource from
1527         * {@link #RES_PACKAGE}, which may be localized.
1528         * <P>Type: TEXT</P>
1529         */
1530        public static final String TITLE_RES = "title_res";
1531
1532        /**
1533         * Notes about the group.
1534         * <p>
1535         * Type: TEXT
1536         */
1537        public static final String NOTES = "notes";
1538
1539        /**
1540         * The ID of this group if it is a System Group, i.e. a group that has a special meaning
1541         * to the sync adapter, null otherwise.
1542         * <P>Type: TEXT</P>
1543         */
1544        public static final String SYSTEM_ID = "system_id";
1545
1546        /**
1547         * The total number of {@link Contacts} that have
1548         * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only
1549         * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
1550         * <p>
1551         * Type: INTEGER
1552         */
1553        public static final String SUMMARY_COUNT = "summ_count";
1554
1555        /**
1556         * The total number of {@link Contacts} that have both
1557         * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers.
1558         * Read-only value that is only present when querying
1559         * {@link Groups#CONTENT_SUMMARY_URI}.
1560         * <p>
1561         * Type: INTEGER
1562         */
1563        public static final String SUMMARY_WITH_PHONES = "summ_phones";
1564
1565        /**
1566         * Flag indicating if the contacts belonging to this group should be
1567         * visible in any user interface.
1568         * <p>
1569         * Type: INTEGER (boolean)
1570         */
1571        public static final String GROUP_VISIBLE = "group_visible";
1572
1573        /**
1574         * The "deleted" flag: "0" by default, "1" if the row has been marked
1575         * for deletion. When {@link android.content.ContentResolver#delete} is
1576         * called on a raw contact, it is marked for deletion and removed from its
1577         * aggregate contact. The sync adaptor deletes the raw contact on the server and
1578         * then calls ContactResolver.delete once more, this time setting the the
1579         * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
1580         * the data removal.
1581         * <P>Type: INTEGER</P>
1582         */
1583        public static final String DELETED = "deleted";
1584
1585        /**
1586         * Whether this group should be synced if the SYNC_EVERYTHING settings
1587         * is false for this group's account.
1588         * <p>
1589         * Type: INTEGER (boolean)
1590         */
1591        public static final String SHOULD_SYNC = "should_sync";
1592    }
1593
1594    /**
1595     * Constants for the groups table.
1596     */
1597    public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
1598        /**
1599         * This utility class cannot be instantiated
1600         */
1601        private Groups() {
1602        }
1603
1604        /**
1605         * The content:// style URI for this table
1606         */
1607        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
1608
1609        /**
1610         * The content:// style URI for this table joined with details data from
1611         * {@link Data}.
1612         */
1613        public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
1614                "groups_summary");
1615
1616        /**
1617         * The MIME type of a directory of groups.
1618         */
1619        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
1620
1621        /**
1622         * The MIME type of a single group.
1623         */
1624        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
1625    }
1626
1627    /**
1628     * Constants for the contact aggregation exceptions table, which contains
1629     * aggregation rules overriding those used by automatic aggregation.  This type only
1630     * supports query and update. Neither insert nor delete are supported.
1631     */
1632    public static final class AggregationExceptions implements BaseColumns {
1633        /**
1634         * This utility class cannot be instantiated
1635         */
1636        private AggregationExceptions() {}
1637
1638        /**
1639         * The content:// style URI for this table
1640         */
1641        public static final Uri CONTENT_URI =
1642                Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
1643
1644        /**
1645         * The MIME type of {@link #CONTENT_URI} providing a directory of data.
1646         */
1647        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
1648
1649        /**
1650         * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
1651         */
1652        public static final String CONTENT_ITEM_TYPE =
1653                "vnd.android.cursor.item/aggregation_exception";
1654
1655        /**
1656         * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or
1657         * {@link #TYPE_AUTOMATIC}.
1658         *
1659         * <P>Type: INTEGER</P>
1660         */
1661        public static final String TYPE = "type";
1662
1663        /**
1664         * Allows the provider to automatically decide whether the specified raw contacts should
1665         * be included in the same aggregate contact or not.
1666         */
1667        public static final int TYPE_AUTOMATIC = 0;
1668
1669        /**
1670         * Makes sure that the specified raw contacts are included in the same
1671         * aggregate contact.
1672         */
1673        public static final int TYPE_KEEP_TOGETHER = 1;
1674
1675        @Deprecated
1676        public static final int TYPE_KEEP_IN = 1;
1677
1678        /**
1679         * Makes sure that the specified raw contacts are NOT included in the same
1680         * aggregate contact.
1681         */
1682        public static final int TYPE_KEEP_SEPARATE = 2;
1683
1684        @Deprecated
1685        public static final int TYPE_KEEP_OUT = 2;
1686
1687        @Deprecated
1688        public static final String CONTACT_ID = "contact_id";
1689
1690        @Deprecated
1691        public static final String RAW_CONTACT_ID = "raw_contact_id";
1692
1693        /**
1694         * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
1695         */
1696        public static final String RAW_CONTACT_ID1 = "raw_contact_id1";
1697
1698        /**
1699         * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule
1700         * applies to.
1701         */
1702        public static final String RAW_CONTACT_ID2 = "raw_contact_id2";
1703    }
1704
1705    private interface SettingsColumns {
1706        /**
1707         * The name of the account instance to which this row belongs.
1708         * <P>Type: TEXT</P>
1709         */
1710        public static final String ACCOUNT_NAME = "account_name";
1711
1712        /**
1713         * The type of account to which this row belongs, which when paired with
1714         * {@link #ACCOUNT_NAME} identifies a specific account.
1715         * <P>Type: TEXT</P>
1716         */
1717        public static final String ACCOUNT_TYPE = "account_type";
1718
1719        /**
1720         * Depending on the mode defined by the sync-adapter, this flag controls
1721         * the top-level sync behavior for this data source.
1722         * <p>
1723         * Type: INTEGER (boolean)
1724         */
1725        public static final String SHOULD_SYNC = "should_sync";
1726
1727        /**
1728         * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership}
1729         * entries should be visible in any user interface.
1730         * <p>
1731         * Type: INTEGER (boolean)
1732         */
1733        public static final String UNGROUPED_VISIBLE = "ungrouped_visible";
1734
1735        /**
1736         * Read-only flag indicating if this {@link #SHOULD_SYNC} or any
1737         * {@link Groups#SHOULD_SYNC} under this account have been marked as
1738         * unsynced.
1739         */
1740        public static final String ANY_UNSYNCED = "any_unsynced";
1741
1742        /**
1743         * Read-only count of {@link Contacts} from a specific source that have
1744         * no {@link CommonDataKinds.GroupMembership} entries.
1745         * <p>
1746         * Type: INTEGER
1747         */
1748        public static final String UNGROUPED_COUNT = "summ_count";
1749
1750        /**
1751         * Read-only count of {@link Contacts} from a specific source that have
1752         * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers.
1753         * <p>
1754         * Type: INTEGER
1755         */
1756        public static final String UNGROUPED_WITH_PHONES = "summ_phones";
1757    }
1758
1759    /**
1760     * Contacts-specific settings for various {@link Account}.
1761     */
1762    public static final class Settings implements SettingsColumns {
1763        /**
1764         * This utility class cannot be instantiated
1765         */
1766        private Settings() {
1767        }
1768
1769        /**
1770         * The content:// style URI for this table
1771         */
1772        public static final Uri CONTENT_URI =
1773                Uri.withAppendedPath(AUTHORITY_URI, "settings");
1774
1775        /**
1776         * The MIME-type of {@link #CONTENT_URI} providing a directory of
1777         * settings.
1778         */
1779        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting";
1780
1781        /**
1782         * The MIME-type of {@link #CONTENT_URI} providing a single setting.
1783         */
1784        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
1785    }
1786
1787    /**
1788     * Helper methods to display FastTrack dialogs that allow users to pivot on
1789     * a specific {@link Contacts} entry.
1790     */
1791    public static final class FastTrack {
1792        /**
1793         * Action used to trigger person pivot dialog.
1794         * @hide
1795         */
1796        public static final String ACTION_FAST_TRACK =
1797                "com.android.contacts.action.FAST_TRACK";
1798
1799        /**
1800         * Extra used to specify pivot dialog location in screen coordinates.
1801         * @hide
1802         */
1803        public static final String EXTRA_TARGET_RECT = "target_rect";
1804
1805        /**
1806         * Extra used to specify size of pivot dialog.
1807         * @hide
1808         */
1809        public static final String EXTRA_MODE = "mode";
1810
1811        /**
1812         * Extra used to indicate a list of specific MIME-types to exclude and
1813         * not display. Stored as a {@link String} array.
1814         * @hide
1815         */
1816        public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
1817
1818        /**
1819         * Small FastTrack mode, usually presented with minimal actions.
1820         */
1821        public static final int MODE_SMALL = 1;
1822
1823        /**
1824         * Medium FastTrack mode, includes actions and light summary describing
1825         * the {@link Contacts} entry being shown. This may include social
1826         * status and presence details.
1827         */
1828        public static final int MODE_MEDIUM = 2;
1829
1830        /**
1831         * Large FastTrack mode, includes actions and larger, card-like summary
1832         * of the {@link Contacts} entry being shown. This may include detailed
1833         * information, such as a photo.
1834         */
1835        public static final int MODE_LARGE = 3;
1836
1837        /**
1838         * Trigger a dialog that lists the various methods of interacting with
1839         * the requested {@link Contacts} entry. This may be based on available
1840         * {@link Data} rows under that contact, and may also include social
1841         * status and presence details.
1842         *
1843         * @param context The parent {@link Context} that may be used as the
1844         *            parent for this dialog.
1845         * @param target Specific {@link View} from your layout that this dialog
1846         *            should be centered around. In particular, if the dialog
1847         *            has a "callout" arrow, it will be pointed and centered
1848         *            around this {@link View}.
1849         * @param lookupUri A {@link Contacts#CONTENT_LOOKUP_URI} style
1850         *            {@link Uri} that describes a specific contact to feature
1851         *            in this dialog.
1852         * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
1853         *            {@link #MODE_LARGE}, indicating the desired dialog size,
1854         *            when supported.
1855         * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
1856         *            to exclude when showing this dialog. For example, when
1857         *            already viewing the contact details card, this can be used
1858         *            to omit the details entry from the dialog.
1859         */
1860        public static void showFastTrack(Context context, View target, Uri lookupUri, int mode,
1861                String[] excludeMimes) {
1862            // Find location and bounds of target view
1863            final int[] location = new int[2];
1864            target.getLocationOnScreen(location);
1865
1866            final Rect rect = new Rect();
1867            rect.left = location[0];
1868            rect.top = location[1];
1869            rect.right = rect.left + target.getWidth();
1870            rect.bottom = rect.top + target.getHeight();
1871
1872            // Trigger with obtained rectangle
1873            showFastTrack(context, rect, lookupUri, mode, excludeMimes);
1874        }
1875
1876        /**
1877         * Trigger a dialog that lists the various methods of interacting with
1878         * the requested {@link Contacts} entry. This may be based on available
1879         * {@link Data} rows under that contact, and may also include social
1880         * status and presence details.
1881         *
1882         * @param context The parent {@link Context} that may be used as the
1883         *            parent for this dialog.
1884         * @param target Specific {@link Rect} that this dialog should be
1885         *            centered around, in screen coordinates. In particular, if
1886         *            the dialog has a "callout" arrow, it will be pointed and
1887         *            centered around this {@link Rect}.
1888         * @param lookupUri A {@link Contacts#CONTENT_LOOKUP_URI} style
1889         *            {@link Uri} that describes a specific contact to feature
1890         *            in this dialog.
1891         * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
1892         *            {@link #MODE_LARGE}, indicating the desired dialog size,
1893         *            when supported.
1894         * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
1895         *            to exclude when showing this dialog. For example, when
1896         *            already viewing the contact details card, this can be used
1897         *            to omit the details entry from the dialog.
1898         */
1899        public static void showFastTrack(Context context, Rect target, Uri lookupUri, int mode,
1900                String[] excludeMimes) {
1901            // Launch pivot dialog through intent for now
1902            final Intent intent = new Intent(ACTION_FAST_TRACK);
1903            intent.setData(lookupUri);
1904            intent.putExtra(EXTRA_TARGET_RECT, target);
1905            intent.putExtra(EXTRA_MODE, mode);
1906            intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes);
1907            context.startActivity(intent);
1908        }
1909    }
1910
1911    /**
1912     * Contains helper classes used to create or manage {@link android.content.Intent Intents}
1913     * that involve contacts.
1914     */
1915    public static final class Intents {
1916        /**
1917         * This is the intent that is fired when a search suggestion is clicked on.
1918         */
1919        public static final String SEARCH_SUGGESTION_CLICKED =
1920                "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
1921
1922        /**
1923         * This is the intent that is fired when a search suggestion for dialing a number
1924         * is clicked on.
1925         */
1926        public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
1927                "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
1928
1929        /**
1930         * This is the intent that is fired when a search suggestion for creating a contact
1931         * is clicked on.
1932         */
1933        public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
1934                "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
1935
1936        /**
1937         * Starts an Activity that lets the user pick a contact to attach an image to.
1938         * After picking the contact it launches the image cropper in face detection mode.
1939         */
1940        public static final String ATTACH_IMAGE =
1941                "com.android.contacts.action.ATTACH_IMAGE";
1942
1943        /**
1944         * Takes as input a data URI with a mailto: or tel: scheme. If a single
1945         * contact exists with the given data it will be shown. If no contact
1946         * exists, a dialog will ask the user if they want to create a new
1947         * contact with the provided details filled in. If multiple contacts
1948         * share the data the user will be prompted to pick which contact they
1949         * want to view.
1950         * <p>
1951         * For <code>mailto:</code> URIs, the scheme specific portion must be a
1952         * raw email address, such as one built using
1953         * {@link Uri#fromParts(String, String, String)}.
1954         * <p>
1955         * For <code>tel:</code> URIs, the scheme specific portion is compared
1956         * to existing numbers using the standard caller ID lookup algorithm.
1957         * The number must be properly encoded, for example using
1958         * {@link Uri#fromParts(String, String, String)}.
1959         * <p>
1960         * Any extras from the {@link Insert} class will be passed along to the
1961         * create activity if there are no contacts to show.
1962         * <p>
1963         * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
1964         * prompting the user when the contact doesn't exist.
1965         */
1966        public static final String SHOW_OR_CREATE_CONTACT =
1967                "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
1968
1969        /**
1970         * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
1971         * contact if no matching contact found. Otherwise, default behavior is
1972         * to prompt user with dialog before creating.
1973         * <p>
1974         * Type: BOOLEAN
1975         */
1976        public static final String EXTRA_FORCE_CREATE =
1977                "com.android.contacts.action.FORCE_CREATE";
1978
1979        /**
1980         * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
1981         * description to be shown when prompting user about creating a new
1982         * contact.
1983         * <p>
1984         * Type: STRING
1985         */
1986        public static final String EXTRA_CREATE_DESCRIPTION =
1987            "com.android.contacts.action.CREATE_DESCRIPTION";
1988
1989        /**
1990         * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
1991         * dialog location using screen coordinates. When not specified, the
1992         * dialog will be centered.
1993         */
1994        @Deprecated
1995        public static final String EXTRA_TARGET_RECT = "target_rect";
1996
1997        /**
1998         * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
1999         * desired dialog style, usually a variation on size. One of
2000         * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
2001         */
2002        @Deprecated
2003        public static final String EXTRA_MODE = "mode";
2004
2005        /**
2006         * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
2007         */
2008        @Deprecated
2009        public static final int MODE_SMALL = 1;
2010
2011        /**
2012         * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
2013         */
2014        @Deprecated
2015        public static final int MODE_MEDIUM = 2;
2016
2017        /**
2018         * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
2019         */
2020        @Deprecated
2021        public static final int MODE_LARGE = 3;
2022
2023        /**
2024         * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate
2025         * a list of specific MIME-types to exclude and not display. Stored as a
2026         * {@link String} array.
2027         */
2028        @Deprecated
2029        public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
2030
2031        /**
2032         * Intents related to the Contacts app UI.
2033         */
2034        public static final class UI {
2035            /**
2036             * The action for the default contacts list tab.
2037             */
2038            public static final String LIST_DEFAULT =
2039                    "com.android.contacts.action.LIST_DEFAULT";
2040
2041            /**
2042             * The action for the contacts list tab.
2043             */
2044            public static final String LIST_GROUP_ACTION =
2045                    "com.android.contacts.action.LIST_GROUP";
2046
2047            /**
2048             * When in LIST_GROUP_ACTION mode, this is the group to display.
2049             */
2050            public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP";
2051
2052            /**
2053             * The action for the all contacts list tab.
2054             */
2055            public static final String LIST_ALL_CONTACTS_ACTION =
2056                    "com.android.contacts.action.LIST_ALL_CONTACTS";
2057
2058            /**
2059             * The action for the contacts with phone numbers list tab.
2060             */
2061            public static final String LIST_CONTACTS_WITH_PHONES_ACTION =
2062                    "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES";
2063
2064            /**
2065             * The action for the starred contacts list tab.
2066             */
2067            public static final String LIST_STARRED_ACTION =
2068                    "com.android.contacts.action.LIST_STARRED";
2069
2070            /**
2071             * The action for the frequent contacts list tab.
2072             */
2073            public static final String LIST_FREQUENT_ACTION =
2074                    "com.android.contacts.action.LIST_FREQUENT";
2075
2076            /**
2077             * The action for the "strequent" contacts list tab. It first lists the starred
2078             * contacts in alphabetical order and then the frequent contacts in descending
2079             * order of the number of times they have been contacted.
2080             */
2081            public static final String LIST_STREQUENT_ACTION =
2082                    "com.android.contacts.action.LIST_STREQUENT";
2083
2084            /**
2085             * A key for to be used as an intent extra to set the activity
2086             * title to a custom String value.
2087             */
2088            public static final String TITLE_EXTRA_KEY =
2089                "com.android.contacts.extra.TITLE_EXTRA";
2090
2091            /**
2092             * Activity Action: Display a filtered list of contacts
2093             * <p>
2094             * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for
2095             * filtering
2096             * <p>
2097             * Output: Nothing.
2098             */
2099            public static final String FILTER_CONTACTS_ACTION =
2100                "com.android.contacts.action.FILTER_CONTACTS";
2101
2102            /**
2103             * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION}
2104             * intents to supply the text on which to filter.
2105             */
2106            public static final String FILTER_TEXT_EXTRA_KEY =
2107                "com.android.contacts.extra.FILTER_TEXT";
2108        }
2109
2110        /**
2111         * Convenience class that contains string constants used
2112         * to create contact {@link android.content.Intent Intents}.
2113         */
2114        public static final class Insert {
2115            /** The action code to use when adding a contact */
2116            public static final String ACTION = Intent.ACTION_INSERT;
2117
2118            /**
2119             * If present, forces a bypass of quick insert mode.
2120             */
2121            public static final String FULL_MODE = "full_mode";
2122
2123            /**
2124             * The extra field for the contact name.
2125             * <P>Type: String</P>
2126             */
2127            public static final String NAME = "name";
2128
2129            // TODO add structured name values here.
2130
2131            /**
2132             * The extra field for the contact phonetic name.
2133             * <P>Type: String</P>
2134             */
2135            public static final String PHONETIC_NAME = "phonetic_name";
2136
2137            /**
2138             * The extra field for the contact company.
2139             * <P>Type: String</P>
2140             */
2141            public static final String COMPANY = "company";
2142
2143            /**
2144             * The extra field for the contact job title.
2145             * <P>Type: String</P>
2146             */
2147            public static final String JOB_TITLE = "job_title";
2148
2149            /**
2150             * The extra field for the contact notes.
2151             * <P>Type: String</P>
2152             */
2153            public static final String NOTES = "notes";
2154
2155            /**
2156             * The extra field for the contact phone number.
2157             * <P>Type: String</P>
2158             */
2159            public static final String PHONE = "phone";
2160
2161            /**
2162             * The extra field for the contact phone number type.
2163             * <P>Type: Either an integer value from
2164             * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
2165             *  or a string specifying a custom label.</P>
2166             */
2167            public static final String PHONE_TYPE = "phone_type";
2168
2169            /**
2170             * The extra field for the phone isprimary flag.
2171             * <P>Type: boolean</P>
2172             */
2173            public static final String PHONE_ISPRIMARY = "phone_isprimary";
2174
2175            /**
2176             * The extra field for an optional second contact phone number.
2177             * <P>Type: String</P>
2178             */
2179            public static final String SECONDARY_PHONE = "secondary_phone";
2180
2181            /**
2182             * The extra field for an optional second contact phone number type.
2183             * <P>Type: Either an integer value from
2184             * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
2185             *  or a string specifying a custom label.</P>
2186             */
2187            public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
2188
2189            /**
2190             * The extra field for an optional third contact phone number.
2191             * <P>Type: String</P>
2192             */
2193            public static final String TERTIARY_PHONE = "tertiary_phone";
2194
2195            /**
2196             * The extra field for an optional third contact phone number type.
2197             * <P>Type: Either an integer value from
2198             * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
2199             *  or a string specifying a custom label.</P>
2200             */
2201            public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
2202
2203            /**
2204             * The extra field for the contact email address.
2205             * <P>Type: String</P>
2206             */
2207            public static final String EMAIL = "email";
2208
2209            /**
2210             * The extra field for the contact email type.
2211             * <P>Type: Either an integer value from
2212             * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2213             *  or a string specifying a custom label.</P>
2214             */
2215            public static final String EMAIL_TYPE = "email_type";
2216
2217            /**
2218             * The extra field for the email isprimary flag.
2219             * <P>Type: boolean</P>
2220             */
2221            public static final String EMAIL_ISPRIMARY = "email_isprimary";
2222
2223            /**
2224             * The extra field for an optional second contact email address.
2225             * <P>Type: String</P>
2226             */
2227            public static final String SECONDARY_EMAIL = "secondary_email";
2228
2229            /**
2230             * The extra field for an optional second contact email type.
2231             * <P>Type: Either an integer value from
2232             * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2233             *  or a string specifying a custom label.</P>
2234             */
2235            public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
2236
2237            /**
2238             * The extra field for an optional third contact email address.
2239             * <P>Type: String</P>
2240             */
2241            public static final String TERTIARY_EMAIL = "tertiary_email";
2242
2243            /**
2244             * The extra field for an optional third contact email type.
2245             * <P>Type: Either an integer value from
2246             * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2247             *  or a string specifying a custom label.</P>
2248             */
2249            public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
2250
2251            /**
2252             * The extra field for the contact postal address.
2253             * <P>Type: String</P>
2254             */
2255            public static final String POSTAL = "postal";
2256
2257            /**
2258             * The extra field for the contact postal address type.
2259             * <P>Type: Either an integer value from
2260             * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2261             *  or a string specifying a custom label.</P>
2262             */
2263            public static final String POSTAL_TYPE = "postal_type";
2264
2265            /**
2266             * The extra field for the postal isprimary flag.
2267             * <P>Type: boolean</P>
2268             */
2269            public static final String POSTAL_ISPRIMARY = "postal_isprimary";
2270
2271            /**
2272             * The extra field for an IM handle.
2273             * <P>Type: String</P>
2274             */
2275            public static final String IM_HANDLE = "im_handle";
2276
2277            /**
2278             * The extra field for the IM protocol
2279             * <P>Type: the result of {@link CommonDataKinds.Im#encodePredefinedImProtocol(int)}
2280             * or {@link CommonDataKinds.Im#encodeCustomImProtocol(String)}.</P>
2281             */
2282            public static final String IM_PROTOCOL = "im_protocol";
2283
2284            /**
2285             * The extra field for the IM isprimary flag.
2286             * <P>Type: boolean</P>
2287             */
2288            public static final String IM_ISPRIMARY = "im_isprimary";
2289        }
2290    }
2291
2292}
2293