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