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