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