ContactsContract.java revision 8851e163fc5bc17d139bf29cd2ec2f3926d342bc
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.content.Intent;
20import android.content.ContentProviderClient;
21import android.content.ContentProviderOperation;
22import android.content.res.Resources;
23import android.graphics.BitmapFactory;
24import android.net.Uri;
25import android.provider.ContactsContract.CommonDataKinds.GroupMembership;
26import android.accounts.Account;
27import android.os.RemoteException;
28
29/**
30 * The contract between the contacts provider and applications. Contains definitions
31 * for the supported URIs and columns.
32 *
33 * @hide
34 */
35public final class ContactsContract {
36    /** The authority for the contacts provider */
37    public static final String AUTHORITY = "com.android.contacts";
38    /** A content:// style uri to the authority for the contacts provider */
39    public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
40
41    public interface SyncStateColumns extends SyncStateContract.Columns {
42    }
43
44    public static final class SyncState {
45        /**
46         * This utility class cannot be instantiated
47         */
48        private SyncState() {}
49
50        public static final String CONTENT_DIRECTORY =
51                SyncStateContract.Constants.CONTENT_DIRECTORY;
52
53        /**
54         * The content:// style URI for this table
55         */
56        public static final Uri CONTENT_URI =
57                Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY);
58
59        /**
60         * @see android.provider.SyncStateContract.Helpers#get
61         */
62        public static byte[] get(ContentProviderClient provider, Account account)
63                throws RemoteException {
64            return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
65        }
66
67        /**
68         * @see android.provider.SyncStateContract.Helpers#set
69         */
70        public static void set(ContentProviderClient provider, Account account, byte[] data)
71                throws RemoteException {
72            SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
73        }
74
75        /**
76         * @see android.provider.SyncStateContract.Helpers#newSetOperation
77         */
78        public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
79            return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
80        }
81    }
82
83    /**
84     * Generic columns for use by sync adapters. The specific functions of
85     * these columns are private to the sync adapter. Other clients of the API
86     * should not attempt to either read or write this column.
87     */
88    private interface BaseSyncColumns {
89
90        /** Generic column for use by sync adapters. */
91        public static final String SYNC1 = "sync1";
92        /** Generic column for use by sync adapters. */
93        public static final String SYNC2 = "sync2";
94        /** Generic column for use by sync adapters. */
95        public static final String SYNC3 = "sync3";
96        /** Generic column for use by sync adapters. */
97        public static final String SYNC4 = "sync4";
98    }
99
100    /**
101     * Columns that appear when each row of a table belongs to a specific
102     * account, including sync information that an account may need.
103     */
104    private interface SyncColumns extends BaseSyncColumns {
105        /**
106         * The name of the account instance to which this row belongs.
107         * <P>Type: TEXT</P>
108         */
109        public static final String ACCOUNT_NAME = "account_name";
110
111        /**
112         * The type of account to which this row belongs, which when paired with
113         * {@link #ACCOUNT_NAME} identifies a specific account.
114         * <P>Type: TEXT</P>
115         */
116        public static final String ACCOUNT_TYPE = "account_type";
117
118        /**
119         * String that uniquely identifies this row to its source account.
120         * <P>Type: TEXT</P>
121         */
122        public static final String SOURCE_ID = "sourceid";
123
124        /**
125         * Version number that is updated whenever this row or its related data
126         * changes.
127         * <P>Type: INTEGER</P>
128         */
129        public static final String VERSION = "version";
130
131        /**
132         * Flag indicating that {@link #VERSION} has changed, and this row needs
133         * to be synchronized by its owning account.
134         * <P>Type: INTEGER (boolean)</P>
135         */
136        public static final String DIRTY = "dirty";
137    }
138
139    public interface ContactOptionsColumns {
140        /**
141         * The number of times a person has been contacted
142         * <P>Type: INTEGER</P>
143         */
144        public static final String TIMES_CONTACTED = "times_contacted";
145
146        /**
147         * The last time a person was contacted.
148         * <P>Type: INTEGER</P>
149         */
150        public static final String LAST_TIME_CONTACTED = "last_time_contacted";
151
152        /**
153         * Is the contact starred?
154         * <P>Type: INTEGER (boolean)</P>
155         */
156        public static final String STARRED = "starred";
157
158        /**
159         * A custom ringtone associated with a person. Not always present.
160         * <P>Type: TEXT (URI to the ringtone)</P>
161         */
162        public static final String CUSTOM_RINGTONE = "custom_ringtone";
163
164        /**
165         * Whether the person should always be sent to voicemail. Not always
166         * present.
167         * <P>Type: INTEGER (0 for false, 1 for true)</P>
168         */
169        public static final String SEND_TO_VOICEMAIL = "send_to_voicemail";
170    }
171
172    private interface ContactsColumns {
173        /**
174         * The display name for the contact.
175         * <P>Type: TEXT</P>
176         */
177        public static final String DISPLAY_NAME = "display_name";
178
179        /**
180         * Reference to the row in the data table holding the primary phone number.
181         * <P>Type: INTEGER REFERENCES data(_id)</P>
182         */
183        public static final String PRIMARY_PHONE_ID = "primary_phone_id";
184
185        /**
186         * Reference to the row in the data table holding the primary email address.
187         * <P>Type: INTEGER REFERENCES data(_id)</P>
188         */
189        public static final String PRIMARY_EMAIL_ID = "primary_email_id";
190
191        /**
192         * Reference to the row in the data table holding the photo.
193         * <P>Type: INTEGER REFERENCES data(_id)</P>
194         */
195        public static final String PHOTO_ID = "photo_id";
196
197        /**
198         * Lookup value that reflects the {@link Groups#GROUP_VISIBLE} state of
199         * any {@link GroupMembership} for this contact.
200         */
201        public static final String IN_VISIBLE_GROUP = "in_visible_group";
202
203        /**
204         * Contact presence status.  See {@link android.provider.Im.CommonPresenceColumns}
205         * for individual status definitions.
206         */
207        public static final String PRESENCE_STATUS = Presence.PRESENCE_STATUS;
208
209        /**
210         * The type of data, for example Home or Work.
211         * <P>Type: INTEGER</P>
212         */
213        public static final String PRIMARY_PHONE_TYPE = CommonDataKinds.Phone.TYPE;
214
215        /**
216         * The user defined label for the primary phone.
217         * <P>Type: TEXT</P>
218         */
219        public static final String PRIMARY_PHONE_LABEL = CommonDataKinds.Phone.LABEL;
220
221        /**
222         * The primary phone number.
223         * <P>Type: TEXT</P>
224         */
225        public static final String PRIMARY_PHONE_NUMBER = CommonDataKinds.Phone.NUMBER;
226    }
227
228    /**
229     * Constants for the contacts table, which contains a record per group
230     * of raw contact representing the same person.
231     */
232    public static class Contacts implements BaseColumns, ContactsColumns,
233            ContactOptionsColumns {
234        /**
235         * This utility class cannot be instantiated
236         */
237        private Contacts()  {}
238
239        /**
240         * The content:// style URI for this table
241         */
242        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
243
244        /**
245         * The content:// style URI for this table joined with useful data from
246         * {@link Data}.
247         */
248        public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
249                "contacts_summary");
250
251        /**
252         * The content:// style URI used for "type-to-filter" functionality on the
253         * {@link #CONTENT_SUMMARY_URI} URI. The filter string will be used to match
254         * various parts of the contact name. The filter argument should be passed
255         * as an additional path segment after this URI.
256         */
257        public static final Uri CONTENT_SUMMARY_FILTER_URI = Uri.withAppendedPath(
258                CONTENT_SUMMARY_URI, "filter");
259
260        /**
261         * The content:// style URI for this table joined with useful data from
262         * {@link Data}, filtered to include only starred contacts
263         * and the most frequently contacted contacts.
264         */
265        public static final Uri CONTENT_SUMMARY_STREQUENT_URI = Uri.withAppendedPath(
266                CONTENT_SUMMARY_URI, "strequent");
267
268        /**
269         * The content:// style URI used for "type-to-filter" functionality on the
270         * {@link #CONTENT_SUMMARY_STREQUENT_URI} URI. The filter string will be used to match
271         * various parts of the contact name. The filter argument should be passed
272         * as an additional path segment after this URI.
273         */
274        public static final Uri CONTENT_SUMMARY_STREQUENT_FILTER_URI = Uri.withAppendedPath(
275                CONTENT_SUMMARY_STREQUENT_URI, "filter");
276
277        public static final Uri CONTENT_SUMMARY_GROUP_URI = Uri.withAppendedPath(
278                CONTENT_SUMMARY_URI, "group");
279        /**
280         * The MIME type of {@link #CONTENT_URI} providing a directory of
281         * people.
282         */
283        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
284
285        /**
286         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
287         * person.
288         */
289        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
290
291        /**
292         * A sub-directory of a single contact that contains all of the constituent raw contact
293         * {@link Data} rows.
294         */
295        public static final class Data implements BaseColumns, DataColumns {
296            /**
297             * no public constructor since this is a utility class
298             */
299            private Data() {}
300
301            /**
302             * The directory twig for this sub-table
303             */
304            public static final String CONTENT_DIRECTORY = "data";
305        }
306
307        /**
308         * A sub-directory of a single contact aggregate that contains all aggregation suggestions
309         * (other contacts).  The aggregation suggestions are computed based on approximate
310         * data matches with this contact.
311         */
312        public static final class AggregationSuggestions implements BaseColumns, ContactsColumns {
313            /**
314             * No public constructor since this is a utility class
315             */
316            private AggregationSuggestions() {}
317
318            /**
319             * The directory twig for this sub-table
320             */
321            public static final String CONTENT_DIRECTORY = "suggestions";
322
323            /**
324             * An optional query parameter that can be supplied to limit the number of returned
325             * suggestions.
326             * <p>
327             * Type: INTEGER
328             *
329             * @deprecated Please use the "limit" parameter
330             */
331            @Deprecated
332            public static final String MAX_SUGGESTIONS = "max_suggestions";
333        }
334    }
335
336    private interface RawContactsColumns {
337        /**
338         * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} that this
339         * data belongs to.
340         * <P>Type: INTEGER</P>
341         */
342        public static final String CONTACT_ID = "contact_id";
343
344        /**
345         * Flag indicating that this {@link RawContacts} entry and its children has
346         * been restricted to specific platform apps.
347         * <P>Type: INTEGER (boolean)</P>
348         *
349         * @hide until finalized in future platform release
350         */
351        public static final String IS_RESTRICTED = "is_restricted";
352
353        /**
354         * The aggregation mode for this contact.
355         * <P>Type: INTEGER</P>
356         */
357        public static final String AGGREGATION_MODE = "aggregation_mode";
358
359        /**
360         * The "deleted" flag: "0" by default, "1" if the row has been marked
361         * for deletion. When {@link android.content.ContentResolver#delete} is
362         * called on a raw contact, it is marked for deletion and removed from its
363         * aggregate contact. The sync adaptor deletes the raw contact on the server and
364         * then calls ContactResolver.delete once more, this time passing the
365         * {@link RawContacts#DELETE_PERMANENTLY} query parameter to finalize the data removal.
366         * <P>Type: INTEGER</P>
367         */
368        public static final String DELETED = "deleted";
369    }
370
371    /**
372     * Constants for the raw_contacts table, which contains the base contact
373     * information per sync source. Sync adapters and contact management apps
374     * are the primary consumers of this API.
375     */
376    public static final class RawContacts implements BaseColumns, RawContactsColumns,
377            ContactOptionsColumns, SyncColumns  {
378        /**
379         * This utility class cannot be instantiated
380         */
381        private RawContacts() {
382        }
383
384        /**
385         * The content:// style URI for this table
386         */
387        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
388
389        /**
390         * The content:// style URL for filtering people by email address. The
391         * filter argument should be passed as an additional path segment after
392         * this URI.
393         *
394         * @hide
395         */
396        public static final Uri CONTENT_FILTER_EMAIL_URI =
397                Uri.withAppendedPath(CONTENT_URI, "filter_email");
398
399        /**
400         * The MIME type of {@link #CONTENT_URI} providing a directory of
401         * people.
402         */
403        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
404
405        /**
406         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
407         * person.
408         */
409        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
410
411        /**
412         * Query parameter that can be passed with the {@link #CONTENT_URI} URI
413         * to the {@link android.content.ContentResolver#delete} method to
414         * indicate that the raw contact can be deleted physically, rather than
415         * merely marked as deleted.
416         */
417        public static final String DELETE_PERMANENTLY = "delete_permanently";
418
419        /**
420         * Aggregation mode: aggregate asynchronously.
421         */
422        public static final int AGGREGATION_MODE_DEFAULT = 0;
423
424        /**
425         * Aggregation mode: aggregate at the time the raw contact is inserted/updated.
426         */
427        public static final int AGGREGATION_MODE_IMMEDITATE = 1;
428
429        /**
430         * Aggregation mode: never aggregate this raw contact (note that the raw contact will not
431         * have a corresponding Aggregate and therefore will not be included in Aggregates
432         * query results.)
433         */
434        public static final int AGGREGATION_MODE_DISABLED = 2;
435
436        /**
437         * A sub-directory of a single raw contact that contains all of their {@link Data} rows.
438         * To access this directory append
439         */
440        public static final class Data implements BaseColumns, DataColumns {
441            /**
442             * no public constructor since this is a utility class
443             */
444            private Data() {
445            }
446
447            /**
448             * The directory twig for this sub-table
449             */
450            public static final String CONTENT_DIRECTORY = "data";
451        }
452    }
453
454    private interface DataColumns {
455        /**
456         * The package name to use when creating {@link Resources} objects for
457         * this data row. This value is only designed for use when building user
458         * interfaces, and should not be used to infer the owner.
459         */
460        public static final String RES_PACKAGE = "res_package";
461
462        /**
463         * The MIME type of the item represented by this row.
464         */
465        public static final String MIMETYPE = "mimetype";
466
467        /**
468         * A reference to the {@link RawContacts#_ID}
469         * that this data belongs to.
470         */
471        public static final String RAW_CONTACT_ID = "raw_contact_id";
472
473        /**
474         * Whether this is the primary entry of its kind for the raw contact it belongs to
475         * <P>Type: INTEGER (if set, non-0 means true)</P>
476         */
477        public static final String IS_PRIMARY = "is_primary";
478
479        /**
480         * Whether this is the primary entry of its kind for the aggregate
481         * contact it belongs to. Any data record that is "super primary" must
482         * also be "primary".
483         * <P>Type: INTEGER (if set, non-0 means true)</P>
484         */
485        public static final String IS_SUPER_PRIMARY = "is_super_primary";
486
487        /**
488         * The version of this data record. This is a read-only value. The data column is
489         * guaranteed to not change without the version going up. This value is monotonically
490         * increasing.
491         * <P>Type: INTEGER</P>
492         */
493        public static final String DATA_VERSION = "data_version";
494
495        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
496        public static final String DATA1 = "data1";
497        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
498        public static final String DATA2 = "data2";
499        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
500        public static final String DATA3 = "data3";
501        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
502        public static final String DATA4 = "data4";
503        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
504        public static final String DATA5 = "data5";
505        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
506        public static final String DATA6 = "data6";
507        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
508        public static final String DATA7 = "data7";
509        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
510        public static final String DATA8 = "data8";
511        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
512        public static final String DATA9 = "data9";
513        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
514        public static final String DATA10 = "data10";
515        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
516        public static final String DATA11 = "data11";
517        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
518        public static final String DATA12 = "data12";
519        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
520        public static final String DATA13 = "data13";
521        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
522        public static final String DATA14 = "data14";
523        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
524        public static final String DATA15 = "data15";
525
526        /** Generic column for use by sync adapters. */
527        public static final String SYNC1 = "data_sync1";
528        /** Generic column for use by sync adapters. */
529        public static final String SYNC2 = "data_sync2";
530        /** Generic column for use by sync adapters. */
531        public static final String SYNC3 = "data_sync3";
532        /** Generic column for use by sync adapters. */
533        public static final String SYNC4 = "data_sync4";
534
535        /**
536         * An optional update or insert URI parameter that determines if the
537         * corresponding raw contact should be marked as dirty. The default
538         * value is true.
539         */
540        public static final String MARK_AS_DIRTY = "mark_as_dirty";
541    }
542
543    /**
544     * Constants for the data table, which contains data points tied to a raw contact.
545     * For example, a phone number or email address. Each row in this table contains a type
546     * definition and some generic columns. Each data type can define the meaning for each of
547     * the generic columns.
548     */
549    public static final class Data implements BaseColumns, DataColumns {
550        /**
551         * This utility class cannot be instantiated
552         */
553        private Data() {}
554
555        /**
556         * The content:// style URI for this table
557         */
558        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
559
560        /**
561         * The MIME type of {@link #CONTENT_URI} providing a directory of data.
562         */
563        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
564    }
565
566    /**
567     * A table that represents the result of looking up a phone number, for
568     * example for caller ID. The table joins that data row for the phone number
569     * with the raw contact that owns the number. To perform a lookup you must
570     * append the number you want to find to {@link #CONTENT_FILTER_URI}.
571     */
572    public static final class PhoneLookup implements BaseColumns, DataColumns, ContactsColumns {
573        /**
574         * This utility class cannot be instantiated
575         */
576        private PhoneLookup() {}
577
578        /**
579         * The content:// style URI for this table. Append the phone number you want to lookup
580         * to this URI and query it to perform a lookup. For example:
581         *
582         * {@code
583         * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, phoneNumber);
584         * }
585         */
586        public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
587                "phone_lookup");
588    }
589
590    /**
591     * Additional data mixed in with {@link Im.CommonPresenceColumns} to link
592     * back to specific {@link ContactsContract.Contacts#_ID} entries.
593     */
594    private interface PresenceColumns {
595
596        /**
597         * The unique ID for a row.
598         * <P>Type: INTEGER (long)</P>
599         */
600        public static final String _ID = "presence_id";
601
602        /**
603         * Reference to the {@link RawContacts#_ID} this presence references.
604         * <P>Type: INTEGER</P>
605         */
606        public static final String RAW_CONTACT_ID = "raw_contact_id";
607
608        /**
609         * Reference to the {@link Data#_ID} entry that owns this presence.
610         * <P>Type: INTEGER</P>
611         */
612        public static final String DATA_ID = "data_id";
613
614        /**
615         * The IM service the presence is coming from. Formatted using either
616         * {@link CommonDataKinds.Im#encodePredefinedImProtocol(int)} or
617         * {@link CommonDataKinds.Im#encodeCustomImProtocol(String)}.
618         * <P>Type: TEXT</P>
619         */
620        public static final String IM_PROTOCOL = "im_protocol";
621
622        /**
623         * The IM handle the presence item is for. The handle is scoped to the
624         * {@link #IM_PROTOCOL}.
625         * <P>Type: TEXT</P>
626         */
627        public static final String IM_HANDLE = "im_handle";
628
629        /**
630         * The IM account for the local user that the presence data came from.
631         * <P>Type: TEXT</P>
632         */
633        public static final String IM_ACCOUNT = "im_account";
634    }
635
636    public static final class Presence implements PresenceColumns, Im.CommonPresenceColumns {
637        /**
638         * This utility class cannot be instantiated
639         */
640        private Presence() {
641        }
642
643        /**
644         * The content:// style URI for this table
645         */
646        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "presence");
647
648        /**
649         * Gets the resource ID for the proper presence icon.
650         *
651         * @param status the status to get the icon for
652         * @return the resource ID for the proper presence icon
653         */
654        public static final int getPresenceIconResourceId(int status) {
655            switch (status) {
656                case AVAILABLE:
657                    return android.R.drawable.presence_online;
658                case IDLE:
659                case AWAY:
660                    return android.R.drawable.presence_away;
661                case DO_NOT_DISTURB:
662                    return android.R.drawable.presence_busy;
663                case INVISIBLE:
664                    return android.R.drawable.presence_invisible;
665                case OFFLINE:
666                default:
667                    return android.R.drawable.presence_offline;
668            }
669        }
670
671        /**
672         * Returns the precedence of the status code the higher number being the higher precedence.
673         *
674         * @param status The status code.
675         * @return An integer representing the precedence, 0 being the lowest.
676         */
677        public static final int getPresencePrecedence(int status) {
678            // Keep this function here incase we want to enforce a different precedence than the
679            // natural order of the status constants.
680            return status;
681        }
682
683        /**
684         * The MIME type of {@link #CONTENT_URI} providing a directory of
685         * presence details.
686         */
687        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-presence";
688
689        /**
690         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
691         * presence detail.
692         */
693        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-presence";
694    }
695
696    /**
697     * Container for definitions of common data types stored in the {@link Data} table.
698     */
699    public static final class CommonDataKinds {
700        /**
701         * The {@link Data#RES_PACKAGE} value for common data that should be
702         * shown using a default style.
703         */
704        public static final String PACKAGE_COMMON = "common";
705
706        /**
707         * Columns common across the specific types.
708         */
709        private interface BaseCommonColumns {
710            /**
711             * The package name to use when creating {@link Resources} objects for
712             * this data row. This value is only designed for use when building user
713             * interfaces, and should not be used to infer the owner.
714             */
715            public static final String RES_PACKAGE = "res_package";
716
717            /**
718             * The MIME type of the item represented by this row.
719             */
720            public static final String MIMETYPE = "mimetype";
721
722            /**
723             * The {@link RawContacts#_ID} that this data belongs to.
724             */
725            public static final String RAW_CONTACT_ID = "raw_contact_id";
726        }
727
728        /**
729         * The base types that all "Typed" data kinds support.
730         */
731        public interface BaseTypes {
732
733            /**
734             * A custom type. The custom label should be supplied by user.
735             */
736            public static int TYPE_CUSTOM = 0;
737        }
738
739        /**
740         * Columns common across the specific types.
741         */
742        private interface CommonColumns extends BaseTypes{
743            /**
744             * The type of data, for example Home or Work.
745             * <P>Type: INTEGER</P>
746             */
747            public static final String TYPE = "data1";
748
749            /**
750             * The data for the contact method.
751             * <P>Type: TEXT</P>
752             */
753            public static final String DATA = "data2";
754
755            /**
756             * The user defined label for the the contact method.
757             * <P>Type: TEXT</P>
758             */
759            public static final String LABEL = "data3";
760        }
761
762        /**
763         * Parts of the name.
764         */
765        public static final class StructuredName implements BaseCommonColumns {
766            private StructuredName() {}
767
768            /** MIME type used when storing this in data table. */
769            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
770
771            /**
772             * The given name for the contact.
773             * <P>Type: TEXT</P>
774             */
775            public static final String GIVEN_NAME = "data1";
776
777            /**
778             * The family name for the contact.
779             * <P>Type: TEXT</P>
780             */
781            public static final String FAMILY_NAME = "data2";
782
783            /**
784             * The contact's honorific prefix, e.g. "Sir"
785             * <P>Type: TEXT</P>
786             */
787            public static final String PREFIX = "data3";
788
789            /**
790             * The contact's middle name
791             * <P>Type: TEXT</P>
792             */
793            public static final String MIDDLE_NAME = "data4";
794
795            /**
796             * The contact's honorific suffix, e.g. "Jr"
797             */
798            public static final String SUFFIX = "data5";
799
800            /**
801             * The phonetic version of the given name for the contact.
802             * <P>Type: TEXT</P>
803             */
804            public static final String PHONETIC_GIVEN_NAME = "data6";
805
806            /**
807             * The phonetic version of the additional name for the contact.
808             * <P>Type: TEXT</P>
809             */
810            public static final String PHONETIC_MIDDLE_NAME = "data7";
811
812            /**
813             * The phonetic version of the family name for the contact.
814             * <P>Type: TEXT</P>
815             */
816            public static final String PHONETIC_FAMILY_NAME = "data8";
817
818            /**
819             * The name that should be used to display the contact.
820             * <P>Type: TEXT</P>
821             */
822            public static final String DISPLAY_NAME = "data9";
823        }
824
825        /**
826         * A nickname.
827         */
828        public static final class Nickname implements CommonColumns, BaseCommonColumns {
829            private Nickname() {}
830
831            /** MIME type used when storing this in data table. */
832            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
833
834            public static final int TYPE_DEFAULT = 1;
835            public static final int TYPE_OTHER_NAME = 2;
836            public static final int TYPE_MAINDEN_NAME = 3;
837            public static final int TYPE_SHORT_NAME = 4;
838            public static final int TYPE_INITIALS = 5;
839
840            /**
841             * The name itself
842             */
843            public static final String NAME = DATA;
844        }
845
846        /**
847         * Common data definition for telephone numbers.
848         */
849        public static final class Phone implements BaseCommonColumns, CommonColumns {
850            private Phone() {}
851
852            /** MIME type used when storing this in data table. */
853            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone";
854
855            /**
856             * The MIME type of {@link #CONTENT_URI} providing a directory of
857             * phones.
858             */
859            public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone";
860
861            /**
862             * The content:// style URI for all data records of the
863             * {@link Phone#CONTENT_ITEM_TYPE} MIME type, combined with the
864             * associated raw contact and aggregate contact data.
865             */
866            public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
867                    "phones");
868
869            /**
870             * The content:// style URI for filtering data records of the
871             * {@link Phone#CONTENT_ITEM_TYPE} MIME type, combined with the
872             * associated raw contact and aggregate contact data. The filter argument should
873             * be passed as an additional path segment after this URI.
874             */
875            public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
876                    "filter");
877
878            public static final int TYPE_HOME = 1;
879            public static final int TYPE_MOBILE = 2;
880            public static final int TYPE_WORK = 3;
881            public static final int TYPE_FAX_WORK = 4;
882            public static final int TYPE_FAX_HOME = 5;
883            public static final int TYPE_PAGER = 6;
884            public static final int TYPE_OTHER = 7;
885            public static final int TYPE_CALLBACK = 8;
886            public static final int TYPE_CAR = 9;
887            public static final int TYPE_COMPANY_MAIN = 10;
888            public static final int TYPE_ISDN = 11;
889            public static final int TYPE_MAIN = 12;
890            public static final int TYPE_OTHER_FAX = 13;
891            public static final int TYPE_RADIO = 14;
892            public static final int TYPE_TELEX = 15;
893            public static final int TYPE_TTY_TDD = 16;
894            public static final int TYPE_WORK_MOBILE = 17;
895            public static final int TYPE_WORK_PAGER = 18;
896            public static final int TYPE_ASSISTANT = 19;
897
898            /**
899             * The phone number as the user entered it.
900             * <P>Type: TEXT</P>
901             */
902            public static final String NUMBER = DATA;
903        }
904
905        /**
906         * Common data definition for email addresses.
907         */
908        public static final class Email implements BaseCommonColumns, CommonColumns {
909            private Email() {}
910
911            /** MIME type used when storing this in data table. */
912            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email";
913
914            public static final int TYPE_HOME = 1;
915            public static final int TYPE_WORK = 2;
916            public static final int TYPE_OTHER = 3;
917
918            /**
919             * The display name for the email address
920             * <P>Type: TEXT</P>
921             */
922            public static final String DISPLAY_NAME = "data4";
923        }
924
925        /**
926         * Common data definition for postal addresses.
927         */
928        public static final class StructuredPostal implements BaseCommonColumns, CommonColumns {
929            private StructuredPostal() {
930            }
931
932            /** MIME type used when storing this in data table. */
933            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/postal-address";
934
935            /**
936             * The MIME type of {@link #CONTENT_URI} providing a directory of
937             * postal addresses.
938             */
939            public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address";
940
941            /**
942             * The content:// style URI for all data records of the
943             * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
944             */
945            public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
946                    "postals");
947
948            public static final int TYPE_HOME = 1;
949            public static final int TYPE_WORK = 2;
950            public static final int TYPE_OTHER = 3;
951
952            /**
953             * The full, unstructured postal address.
954             * <p>
955             * Type: TEXT
956             */
957            public static final String FORMATTED_ADDRESS = DATA;
958
959            /**
960             * The agent who actually receives the mail. Used in work addresses.
961             * Also for 'in care of' or 'c/o'.
962             * <p>
963             * Type: TEXT
964             */
965            public static final String AGENT = "data4";
966
967            /**
968             * Used in places where houses or buildings have names (and not
969             * necessarily numbers), eg. "The Pillars".
970             * <p>
971             * Type: TEXT
972             */
973            public static final String HOUSENAME = "data5";
974
975            /**
976             * Can be street, avenue, road, etc. This element also includes the
977             * house number and room/apartment/flat/floor number.
978             * <p>
979             * Type: TEXT
980             */
981            public static final String STREET = "data6";
982
983            /**
984             * Covers actual P.O. boxes, drawers, locked bags, etc. This is
985             * usually but not always mutually exclusive with street.
986             * <p>
987             * Type: TEXT
988             */
989            public static final String POBOX = "data7";
990
991            /**
992             * This is used to disambiguate a street address when a city
993             * contains more than one street with the same name, or to specify a
994             * small place whose mail is routed through a larger postal town. In
995             * China it could be a county or a minor city.
996             * <p>
997             * Type: TEXT
998             */
999            public static final String NEIGHBORHOOD = "data8";
1000
1001            /**
1002             * Can be city, village, town, borough, etc. This is the postal town
1003             * and not necessarily the place of residence or place of business.
1004             * <p>
1005             * Type: TEXT
1006             */
1007            public static final String CITY = "data9";
1008
1009            /**
1010             * Handles administrative districts such as U.S. or U.K. counties
1011             * that are not used for mail addressing purposes. Subregion is not
1012             * intended for delivery addresses.
1013             * <p>
1014             * Type: TEXT
1015             */
1016            public static final String SUBREGION = "data10";
1017
1018            /**
1019             * A state, province, county (in Ireland), Land (in Germany),
1020             * departement (in France), etc.
1021             * <p>
1022             * Type: TEXT
1023             */
1024            public static final String REGION = "data11";
1025
1026            /**
1027             * Postal code. Usually country-wide, but sometimes specific to the
1028             * city (e.g. "2" in "Dublin 2, Ireland" addresses).
1029             * <p>
1030             * Type: TEXT
1031             */
1032            public static final String POSTCODE = "data12";
1033
1034            /**
1035             * The name or code of the country.
1036             * <p>
1037             * Type: TEXT
1038             */
1039            public static final String COUNTRY = "data13";
1040        }
1041
1042        /**
1043         * Common data definition for IM addresses.
1044         */
1045        public static final class Im implements BaseCommonColumns, CommonColumns {
1046            private Im() {}
1047
1048            /** MIME type used when storing this in data table. */
1049            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
1050
1051            public static final int TYPE_HOME = 1;
1052            public static final int TYPE_WORK = 2;
1053            public static final int TYPE_OTHER = 3;
1054
1055            public static final String PROTOCOL = "data5";
1056
1057            public static final String CUSTOM_PROTOCOL = "data6";
1058
1059            /**
1060             * The predefined IM protocol types. The protocol can either be non-present, one
1061             * of these types, or a free-form string. These cases are encoded in the PROTOCOL
1062             * column as:
1063             * <ul>
1064             * <li>null</li>
1065             * <li>pre:&lt;an integer, one of the protocols below&gt;</li>
1066             * <li>custom:&lt;a string&gt;</li>
1067             * </ul>
1068             */
1069            public static final int PROTOCOL_CUSTOM = -1;
1070            public static final int PROTOCOL_AIM = 0;
1071            public static final int PROTOCOL_MSN = 1;
1072            public static final int PROTOCOL_YAHOO = 2;
1073            public static final int PROTOCOL_SKYPE = 3;
1074            public static final int PROTOCOL_QQ = 4;
1075            public static final int PROTOCOL_GOOGLE_TALK = 5;
1076            public static final int PROTOCOL_ICQ = 6;
1077            public static final int PROTOCOL_JABBER = 7;
1078            public static final int PROTOCOL_NETMEETING = 8;
1079        }
1080
1081        /**
1082         * Common data definition for organizations.
1083         */
1084        public static final class Organization implements BaseCommonColumns, CommonColumns {
1085            private Organization() {}
1086
1087            /** MIME type used when storing this in data table. */
1088            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
1089
1090            public static final int TYPE_WORK = 1;
1091            public static final int TYPE_OTHER = 2;
1092
1093            /**
1094             * The company as the user entered it.
1095             * <P>Type: TEXT</P>
1096             */
1097            public static final String COMPANY = DATA;
1098
1099            /**
1100             * The position title at this company as the user entered it.
1101             * <P>Type: TEXT</P>
1102             */
1103            public static final String TITLE = "data4";
1104
1105            /**
1106             * The department at this company as the user entered it.
1107             * <P>Type: TEXT</P>
1108             */
1109            public static final String DEPARTMENT = "data5";
1110
1111            /**
1112             * The job description at this company as the user entered it.
1113             * <P>Type: TEXT</P>
1114             */
1115            public static final String JOB_DESCRIPTION = "data6";
1116
1117            /**
1118             * The symbol of this company as the user entered it.
1119             * <P>Type: TEXT</P>
1120             */
1121            public static final String SYMBOL = "data7";
1122
1123            /**
1124             * The phonetic name of this company as the user entered it.
1125             * <P>Type: TEXT</P>
1126             */
1127            public static final String PHONETIC_NAME = "data8";
1128        }
1129
1130        /**
1131         * Common data definition for miscellaneous information.
1132         */
1133        public static final class Miscellaneous implements BaseCommonColumns {
1134            private Miscellaneous() {}
1135
1136            /** MIME type used when storing this in data table. */
1137            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/misc";
1138
1139            /**
1140             * The birthday as the user entered it.
1141             * <P>Type: TEXT</P>
1142             */
1143            public static final String BIRTHDAY = "data1";
1144
1145            /**
1146             * The nickname as the user entered it.
1147             * <P>Type: TEXT</P>
1148             */
1149            public static final String NICKNAME = "data2";
1150        }
1151
1152        /**
1153         * Common data definition for relations.
1154         */
1155        public static final class Relation implements BaseCommonColumns, CommonColumns {
1156            private Relation() {}
1157
1158            /** MIME type used when storing this in data table. */
1159            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
1160
1161            public static final int TYPE_ASSISTANT = 1;
1162            public static final int TYPE_BROTHER = 2;
1163            public static final int TYPE_CHILD = 3;
1164            public static final int TYPE_DOMESTIC_PARTNER = 4;
1165            public static final int TYPE_FATHER = 5;
1166            public static final int TYPE_FRIEND = 6;
1167            public static final int TYPE_MANAGER = 7;
1168            public static final int TYPE_MOTHER = 8;
1169            public static final int TYPE_PARENT = 9;
1170            public static final int TYPE_PARTNER = 10;
1171            public static final int TYPE_REFERRED_BY = 11;
1172            public static final int TYPE_RELATIVE = 12;
1173            public static final int TYPE_SISTER = 13;
1174            public static final int TYPE_SPOUSE = 14;
1175
1176            /**
1177             * The name of the relative as the user entered it.
1178             * <P>Type: TEXT</P>
1179             */
1180            public static final String NAME = DATA;
1181        }
1182
1183        /**
1184         * Common data definition for events.
1185         */
1186        public static final class Event implements BaseCommonColumns, CommonColumns {
1187            private Event() {}
1188
1189            /** MIME type used when storing this in data table. */
1190            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/event";
1191
1192            public static final int TYPE_ANNIVERSARY = 1;
1193            public static final int TYPE_OTHER = 2;
1194
1195            /**
1196             * The event start date as the user entered it.
1197             * <P>Type: TEXT</P>
1198             */
1199            public static final String START_DATE = DATA;
1200        }
1201
1202        /**
1203         * Photo of the contact.
1204         */
1205        public static final class Photo implements BaseCommonColumns {
1206            private Photo() {}
1207
1208            /** MIME type used when storing this in data table. */
1209            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
1210
1211            /**
1212             * Thumbnail photo of the raw contact. This is the raw bytes of an image
1213             * that could be inflated using {@link BitmapFactory}.
1214             * <p>
1215             * Type: BLOB
1216             */
1217            public static final String PHOTO = "data1";
1218        }
1219
1220        /**
1221         * Notes about the contact.
1222         */
1223        public static final class Note implements BaseCommonColumns {
1224            private Note() {}
1225
1226            /** MIME type used when storing this in data table. */
1227            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
1228
1229            /**
1230             * The note text.
1231             * <P>Type: TEXT</P>
1232             */
1233            public static final String NOTE = "data1";
1234        }
1235
1236        /**
1237         * Group Membership.
1238         */
1239        public static final class GroupMembership implements BaseCommonColumns {
1240            private GroupMembership() {}
1241
1242            /** MIME type used when storing this in data table. */
1243            public static final String CONTENT_ITEM_TYPE =
1244                    "vnd.android.cursor.item/group_membership";
1245
1246            /**
1247             * The row id of the group that this group membership refers to. Exactly one of
1248             * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
1249             * <P>Type: INTEGER</P>
1250             */
1251            public static final String GROUP_ROW_ID = "data1";
1252
1253            /**
1254             * The sourceid of the group that this group membership refers to.  Exactly one of
1255             * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
1256             * <P>Type: TEXT</P>
1257             */
1258            public static final String GROUP_SOURCE_ID = "group_sourceid";
1259        }
1260
1261        /**
1262         * Website related to the contact.
1263         */
1264        public static final class Website implements BaseCommonColumns, CommonColumns {
1265            private Website() {}
1266
1267            /** MIME type used when storing this in data table. */
1268            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
1269
1270            public static final int TYPE_HOMEPAGE = 1;
1271            public static final int TYPE_BLOG = 2;
1272            public static final int TYPE_PROFILE = 3;
1273            public static final int TYPE_HOME = 4;
1274            public static final int TYPE_WORK = 5;
1275            public static final int TYPE_FTP = 6;
1276            public static final int TYPE_OTHER = 7;
1277
1278            /**
1279             * The website URL string.
1280             * <P>Type: TEXT</P>
1281             */
1282            public static final String URL = "data1";
1283        }
1284    }
1285
1286    public interface GroupsColumns {
1287        /**
1288         * The display title of this group.
1289         * <p>
1290         * Type: TEXT
1291         */
1292        public static final String TITLE = "title";
1293
1294        /**
1295         * The package name to use when creating {@link Resources} objects for
1296         * this group. This value is only designed for use when building user
1297         * interfaces, and should not be used to infer the owner.
1298         */
1299        public static final String RES_PACKAGE = "res_package";
1300
1301        /**
1302         * The display title of this group to load as a resource from
1303         * {@link #RES_PACKAGE}, which may be localized.
1304         * <P>Type: TEXT</P>
1305         */
1306        public static final String TITLE_RES = "title_res";
1307
1308        /**
1309         * Notes about the group.
1310         * <p>
1311         * Type: TEXT
1312         */
1313        public static final String NOTES = "notes";
1314
1315        /**
1316         * The ID of this group if it is a System Group, i.e. a group that has a special meaning
1317         * to the sync adapter, null otherwise.
1318         * <P>Type: TEXT</P>
1319         */
1320        public static final String SYSTEM_ID = "system_id";
1321
1322        /**
1323         * The total number of {@link Contacts} that have
1324         * {@link GroupMembership} in this group. Read-only value that is only
1325         * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
1326         * <p>
1327         * Type: INTEGER
1328         */
1329        public static final String SUMMARY_COUNT = "summ_count";
1330
1331        /**
1332         * The total number of {@link Contacts} that have both
1333         * {@link GroupMembership} in this group, and also have phone numbers.
1334         * Read-only value that is only present when querying
1335         * {@link Groups#CONTENT_SUMMARY_URI}.
1336         * <p>
1337         * Type: INTEGER
1338         */
1339        public static final String SUMMARY_WITH_PHONES = "summ_phones";
1340
1341        /**
1342         * Flag indicating if the contacts belonging to this group should be
1343         * visible in any user interface.
1344         * <p>
1345         * Type: INTEGER
1346         */
1347        public static final String GROUP_VISIBLE = "group_visible";
1348    }
1349
1350    /**
1351     * Constants for the groups table.
1352     */
1353    public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
1354        /**
1355         * This utility class cannot be instantiated
1356         */
1357        private Groups() {
1358        }
1359
1360        /**
1361         * The content:// style URI for this table
1362         */
1363        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
1364
1365        /**
1366         * The content:// style URI for this table joined with details data from
1367         * {@link Data}.
1368         */
1369        public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
1370                "groups_summary");
1371
1372        /**
1373         * The MIME type of a directory of groups.
1374         */
1375        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
1376
1377        /**
1378         * The MIME type of a single group.
1379         */
1380        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
1381    }
1382
1383    /**
1384     * Constants for the contact aggregation exceptions table, which contains
1385     * aggregation rules overriding those used by automatic aggregation.  This type only
1386     * supports query and update. Neither insert nor delete are supported.
1387     */
1388    public static final class AggregationExceptions implements BaseColumns {
1389        /**
1390         * This utility class cannot be instantiated
1391         */
1392        private AggregationExceptions() {}
1393
1394        /**
1395         * The content:// style URI for this table
1396         */
1397        public static final Uri CONTENT_URI =
1398                Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
1399
1400        /**
1401         * The MIME type of {@link #CONTENT_URI} providing a directory of data.
1402         */
1403        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
1404
1405        /**
1406         * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
1407         */
1408        public static final String CONTENT_ITEM_TYPE =
1409                "vnd.android.cursor.item/aggregation_exception";
1410
1411        /**
1412         * The type of exception: {@link #TYPE_KEEP_IN}, {@link #TYPE_KEEP_OUT} or
1413         * {@link #TYPE_AUTOMATIC}.
1414         *
1415         * <P>Type: INTEGER</P>
1416         */
1417        public static final String TYPE = "type";
1418
1419        /**
1420         * Allows the provider to automatically decide whether the aggregate
1421         * contact should include a particular raw contact or not.
1422         */
1423        public static final int TYPE_AUTOMATIC = 0;
1424
1425        /**
1426         * Makes sure that the specified raw contact is included in the
1427         * specified aggregate contact.
1428         */
1429        public static final int TYPE_KEEP_IN = 1;
1430
1431        /**
1432         * Makes sure that the specified raw contact is NOT included in the
1433         * specified aggregate contact.
1434         */
1435        public static final int TYPE_KEEP_OUT = 2;
1436
1437        /**
1438         * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} of the
1439         * aggregate contact that the rule applies to.
1440         */
1441        public static final String CONTACT_ID = "contact_id";
1442
1443        /**
1444         * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
1445         */
1446        public static final String RAW_CONTACT_ID = "raw_contact_id";
1447    }
1448
1449    /**
1450     * Contains helper classes used to create or manage {@link android.content.Intent Intents}
1451     * that involve contacts.
1452     */
1453    public static final class Intents {
1454        /**
1455         * This is the intent that is fired when a search suggestion is clicked on.
1456         */
1457        public static final String SEARCH_SUGGESTION_CLICKED =
1458                "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
1459
1460        /**
1461         * This is the intent that is fired when a search suggestion for dialing a number
1462         * is clicked on.
1463         */
1464        public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
1465                "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
1466
1467        /**
1468         * This is the intent that is fired when a search suggestion for creating a contact
1469         * is clicked on.
1470         */
1471        public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
1472                "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
1473
1474        /**
1475         * Starts an Activity that lets the user pick a contact to attach an image to.
1476         * After picking the contact it launches the image cropper in face detection mode.
1477         */
1478        public static final String ATTACH_IMAGE =
1479                "com.android.contacts.action.ATTACH_IMAGE";
1480
1481        /**
1482         * Takes as input a data URI with a mailto: or tel: scheme. If a single
1483         * contact exists with the given data it will be shown. If no contact
1484         * exists, a dialog will ask the user if they want to create a new
1485         * contact with the provided details filled in. If multiple contacts
1486         * share the data the user will be prompted to pick which contact they
1487         * want to view.
1488         * <p>
1489         * For <code>mailto:</code> URIs, the scheme specific portion must be a
1490         * raw email address, such as one built using
1491         * {@link Uri#fromParts(String, String, String)}.
1492         * <p>
1493         * For <code>tel:</code> URIs, the scheme specific portion is compared
1494         * to existing numbers using the standard caller ID lookup algorithm.
1495         * The number must be properly encoded, for example using
1496         * {@link Uri#fromParts(String, String, String)}.
1497         * <p>
1498         * Any extras from the {@link Insert} class will be passed along to the
1499         * create activity if there are no contacts to show.
1500         * <p>
1501         * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
1502         * prompting the user when the contact doesn't exist.
1503         */
1504        public static final String SHOW_OR_CREATE_CONTACT =
1505                "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
1506
1507        /**
1508         * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
1509         * contact if no matching contact found. Otherwise, default behavior is
1510         * to prompt user with dialog before creating.
1511         * <p>
1512         * Type: BOOLEAN
1513         */
1514        public static final String EXTRA_FORCE_CREATE =
1515                "com.android.contacts.action.FORCE_CREATE";
1516
1517        /**
1518         * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
1519         * description to be shown when prompting user about creating a new
1520         * contact.
1521         * <p>
1522         * Type: STRING
1523         */
1524        public static final String EXTRA_CREATE_DESCRIPTION =
1525            "com.android.contacts.action.CREATE_DESCRIPTION";
1526
1527        /**
1528         * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
1529         * dialog location using screen coordinates. When not specified, the
1530         * dialog will be centered.
1531         */
1532        public static final String EXTRA_TARGET_RECT = "target_rect";
1533
1534        /**
1535         * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
1536         * desired dialog style, usually a variation on size. One of
1537         * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
1538         */
1539        public static final String EXTRA_MODE = "mode";
1540
1541        /**
1542         * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
1543         */
1544        public static final int MODE_SMALL = 1;
1545
1546        /**
1547         * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
1548         */
1549        public static final int MODE_MEDIUM = 2;
1550
1551        /**
1552         * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
1553         */
1554        public static final int MODE_LARGE = 3;
1555
1556        /**
1557         * Intents related to the Contacts app UI.
1558         */
1559        public static final class UI {
1560            /**
1561             * The action for the default contacts list tab.
1562             */
1563            public static final String LIST_DEFAULT =
1564                    "com.android.contacts.action.LIST_DEFAULT";
1565
1566            /**
1567             * The action for the contacts list tab.
1568             */
1569            public static final String LIST_GROUP_ACTION =
1570                    "com.android.contacts.action.LIST_GROUP";
1571
1572            /**
1573             * When in LIST_GROUP_ACTION mode, this is the group to display.
1574             */
1575            public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP";
1576
1577            /**
1578             * The action for the all contacts list tab.
1579             */
1580            public static final String LIST_ALL_CONTACTS_ACTION =
1581                    "com.android.contacts.action.LIST_ALL_CONTACTS";
1582
1583            /**
1584             * The action for the contacts with phone numbers list tab.
1585             */
1586            public static final String LIST_CONTACTS_WITH_PHONES_ACTION =
1587                    "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES";
1588
1589            /**
1590             * The action for the starred contacts list tab.
1591             */
1592            public static final String LIST_STARRED_ACTION =
1593                    "com.android.contacts.action.LIST_STARRED";
1594
1595            /**
1596             * The action for the frequent contacts list tab.
1597             */
1598            public static final String LIST_FREQUENT_ACTION =
1599                    "com.android.contacts.action.LIST_FREQUENT";
1600
1601            /**
1602             * The action for the "strequent" contacts list tab. It first lists the starred
1603             * contacts in alphabetical order and then the frequent contacts in descending
1604             * order of the number of times they have been contacted.
1605             */
1606            public static final String LIST_STREQUENT_ACTION =
1607                    "com.android.contacts.action.LIST_STREQUENT";
1608
1609            /**
1610             * A key for to be used as an intent extra to set the activity
1611             * title to a custom String value.
1612             */
1613            public static final String TITLE_EXTRA_KEY =
1614                "com.android.contacts.extra.TITLE_EXTRA";
1615
1616            /**
1617             * Activity Action: Display a filtered list of contacts
1618             * <p>
1619             * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for
1620             * filtering
1621             * <p>
1622             * Output: Nothing.
1623             */
1624            public static final String FILTER_CONTACTS_ACTION =
1625                "com.android.contacts.action.FILTER_CONTACTS";
1626
1627            /**
1628             * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION}
1629             * intents to supply the text on which to filter.
1630             */
1631            public static final String FILTER_TEXT_EXTRA_KEY =
1632                "com.android.contacts.extra.FILTER_TEXT";
1633        }
1634
1635        /**
1636         * Convenience class that contains string constants used
1637         * to create contact {@link android.content.Intent Intents}.
1638         */
1639        public static final class Insert {
1640            /** The action code to use when adding a contact */
1641            public static final String ACTION = Intent.ACTION_INSERT;
1642
1643            /**
1644             * If present, forces a bypass of quick insert mode.
1645             */
1646            public static final String FULL_MODE = "full_mode";
1647
1648            /**
1649             * The extra field for the contact name.
1650             * <P>Type: String</P>
1651             */
1652            public static final String NAME = "name";
1653
1654            // TODO add structured name values here.
1655
1656            /**
1657             * The extra field for the contact phonetic name.
1658             * <P>Type: String</P>
1659             */
1660            public static final String PHONETIC_NAME = "phonetic_name";
1661
1662            /**
1663             * The extra field for the contact company.
1664             * <P>Type: String</P>
1665             */
1666            public static final String COMPANY = "company";
1667
1668            /**
1669             * The extra field for the contact job title.
1670             * <P>Type: String</P>
1671             */
1672            public static final String JOB_TITLE = "job_title";
1673
1674            /**
1675             * The extra field for the contact notes.
1676             * <P>Type: String</P>
1677             */
1678            public static final String NOTES = "notes";
1679
1680            /**
1681             * The extra field for the contact phone number.
1682             * <P>Type: String</P>
1683             */
1684            public static final String PHONE = "phone";
1685
1686            /**
1687             * The extra field for the contact phone number type.
1688             * <P>Type: Either an integer value from
1689             * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
1690             *  or a string specifying a custom label.</P>
1691             */
1692            public static final String PHONE_TYPE = "phone_type";
1693
1694            /**
1695             * The extra field for the phone isprimary flag.
1696             * <P>Type: boolean</P>
1697             */
1698            public static final String PHONE_ISPRIMARY = "phone_isprimary";
1699
1700            /**
1701             * The extra field for an optional second contact phone number.
1702             * <P>Type: String</P>
1703             */
1704            public static final String SECONDARY_PHONE = "secondary_phone";
1705
1706            /**
1707             * The extra field for an optional second contact phone number type.
1708             * <P>Type: Either an integer value from
1709             * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
1710             *  or a string specifying a custom label.</P>
1711             */
1712            public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
1713
1714            /**
1715             * The extra field for an optional third contact phone number.
1716             * <P>Type: String</P>
1717             */
1718            public static final String TERTIARY_PHONE = "tertiary_phone";
1719
1720            /**
1721             * The extra field for an optional third contact phone number type.
1722             * <P>Type: Either an integer value from
1723             * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
1724             *  or a string specifying a custom label.</P>
1725             */
1726            public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
1727
1728            /**
1729             * The extra field for the contact email address.
1730             * <P>Type: String</P>
1731             */
1732            public static final String EMAIL = "email";
1733
1734            /**
1735             * The extra field for the contact email type.
1736             * <P>Type: Either an integer value from
1737             * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
1738             *  or a string specifying a custom label.</P>
1739             */
1740            public static final String EMAIL_TYPE = "email_type";
1741
1742            /**
1743             * The extra field for the email isprimary flag.
1744             * <P>Type: boolean</P>
1745             */
1746            public static final String EMAIL_ISPRIMARY = "email_isprimary";
1747
1748            /**
1749             * The extra field for an optional second contact email address.
1750             * <P>Type: String</P>
1751             */
1752            public static final String SECONDARY_EMAIL = "secondary_email";
1753
1754            /**
1755             * The extra field for an optional second contact email type.
1756             * <P>Type: Either an integer value from
1757             * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
1758             *  or a string specifying a custom label.</P>
1759             */
1760            public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
1761
1762            /**
1763             * The extra field for an optional third contact email address.
1764             * <P>Type: String</P>
1765             */
1766            public static final String TERTIARY_EMAIL = "tertiary_email";
1767
1768            /**
1769             * The extra field for an optional third contact email type.
1770             * <P>Type: Either an integer value from
1771             * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
1772             *  or a string specifying a custom label.</P>
1773             */
1774            public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
1775
1776            /**
1777             * The extra field for the contact postal address.
1778             * <P>Type: String</P>
1779             */
1780            public static final String POSTAL = "postal";
1781
1782            /**
1783             * The extra field for the contact postal address type.
1784             * <P>Type: Either an integer value from
1785             * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
1786             *  or a string specifying a custom label.</P>
1787             */
1788            public static final String POSTAL_TYPE = "postal_type";
1789
1790            /**
1791             * The extra field for the postal isprimary flag.
1792             * <P>Type: boolean</P>
1793             */
1794            public static final String POSTAL_ISPRIMARY = "postal_isprimary";
1795
1796            /**
1797             * The extra field for an IM handle.
1798             * <P>Type: String</P>
1799             */
1800            public static final String IM_HANDLE = "im_handle";
1801
1802            /**
1803             * The extra field for the IM protocol
1804             * <P>Type: the result of {@link CommonDataKinds.Im#encodePredefinedImProtocol(int)}
1805             * or {@link CommonDataKinds.Im#encodeCustomImProtocol(String)}.</P>
1806             */
1807            public static final String IM_PROTOCOL = "im_protocol";
1808
1809            /**
1810             * The extra field for the IM isprimary flag.
1811             * <P>Type: boolean</P>
1812             */
1813            public static final String IM_ISPRIMARY = "im_isprimary";
1814        }
1815    }
1816
1817}
1818