blob: 18b666cb74a55abd59bc9f8909bed36c61de1102 [file] [log] [blame]
Evan Millar088b2912009-05-28 15:24:37 -07001/*
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
Jeff Sharkey7b6771a2009-08-17 01:59:54 -070019import android.accounts.Account;
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070020import android.content.ContentProviderClient;
21import android.content.ContentProviderOperation;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070022import android.content.ContentResolver;
23import android.content.ContentUris;
Dmitri Plotnikov93032952009-08-19 11:26:57 -070024import android.content.Context;
Jeff Sharkey7b6771a2009-08-17 01:59:54 -070025import android.content.Intent;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -070026import android.content.res.Resources;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070027import android.database.Cursor;
Evan Millar088b2912009-05-28 15:24:37 -070028import android.graphics.BitmapFactory;
29import android.net.Uri;
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070030import android.os.RemoteException;
Jeff Sharkey7b6771a2009-08-17 01:59:54 -070031import android.provider.ContactsContract.CommonDataKinds.GroupMembership;
Dmitri Plotnikov93032952009-08-19 11:26:57 -070032import android.text.TextUtils;
Evan Millar088b2912009-05-28 15:24:37 -070033
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070034import java.io.ByteArrayInputStream;
35import java.io.InputStream;
36
Evan Millar088b2912009-05-28 15:24:37 -070037/**
38 * The contract between the contacts provider and applications. Contains definitions
39 * for the supported URIs and columns.
40 *
Dmitri Plotnikov5f123bd2009-05-28 18:06:31 -070041 * @hide
Evan Millar088b2912009-05-28 15:24:37 -070042 */
43public final class ContactsContract {
44 /** The authority for the contacts provider */
45 public static final String AUTHORITY = "com.android.contacts";
46 /** A content:// style uri to the authority for the contacts provider */
47 public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
48
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070049 public interface SyncStateColumns extends SyncStateContract.Columns {
50 }
51
52 public static final class SyncState {
53 /**
54 * This utility class cannot be instantiated
55 */
56 private SyncState() {}
57
58 public static final String CONTENT_DIRECTORY =
59 SyncStateContract.Constants.CONTENT_DIRECTORY;
60
61 /**
62 * The content:// style URI for this table
63 */
64 public static final Uri CONTENT_URI =
65 Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY);
66
67 /**
68 * @see android.provider.SyncStateContract.Helpers#get
69 */
70 public static byte[] get(ContentProviderClient provider, Account account)
71 throws RemoteException {
72 return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
73 }
74
75 /**
76 * @see android.provider.SyncStateContract.Helpers#set
77 */
78 public static void set(ContentProviderClient provider, Account account, byte[] data)
79 throws RemoteException {
80 SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
81 }
82
83 /**
84 * @see android.provider.SyncStateContract.Helpers#newSetOperation
85 */
86 public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
87 return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
88 }
89 }
90
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -070091 /**
92 * Generic columns for use by sync adapters. The specific functions of
93 * these columns are private to the sync adapter. Other clients of the API
94 * should not attempt to either read or write this column.
95 */
96 private interface BaseSyncColumns {
97
98 /** Generic column for use by sync adapters. */
99 public static final String SYNC1 = "sync1";
100 /** Generic column for use by sync adapters. */
101 public static final String SYNC2 = "sync2";
102 /** Generic column for use by sync adapters. */
103 public static final String SYNC3 = "sync3";
104 /** Generic column for use by sync adapters. */
105 public static final String SYNC4 = "sync4";
106 }
107
108 /**
109 * Columns that appear when each row of a table belongs to a specific
110 * account, including sync information that an account may need.
111 */
112 private interface SyncColumns extends BaseSyncColumns {
113 /**
114 * The name of the account instance to which this row belongs.
115 * <P>Type: TEXT</P>
116 */
117 public static final String ACCOUNT_NAME = "account_name";
118
119 /**
120 * The type of account to which this row belongs, which when paired with
121 * {@link #ACCOUNT_NAME} identifies a specific account.
122 * <P>Type: TEXT</P>
123 */
124 public static final String ACCOUNT_TYPE = "account_type";
125
126 /**
127 * String that uniquely identifies this row to its source account.
128 * <P>Type: TEXT</P>
129 */
130 public static final String SOURCE_ID = "sourceid";
131
132 /**
133 * Version number that is updated whenever this row or its related data
134 * changes.
135 * <P>Type: INTEGER</P>
136 */
137 public static final String VERSION = "version";
138
139 /**
140 * Flag indicating that {@link #VERSION} has changed, and this row needs
141 * to be synchronized by its owning account.
142 * <P>Type: INTEGER (boolean)</P>
143 */
144 public static final String DIRTY = "dirty";
145 }
146
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700147 public interface ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700148 /**
149 * The number of times a person has been contacted
150 * <P>Type: INTEGER</P>
151 */
152 public static final String TIMES_CONTACTED = "times_contacted";
153
154 /**
155 * The last time a person was contacted.
156 * <P>Type: INTEGER</P>
157 */
158 public static final String LAST_TIME_CONTACTED = "last_time_contacted";
159
160 /**
161 * Is the contact starred?
162 * <P>Type: INTEGER (boolean)</P>
163 */
164 public static final String STARRED = "starred";
165
166 /**
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700167 * A custom ringtone associated with a person. Not always present.
168 * <P>Type: TEXT (URI to the ringtone)</P>
169 */
170 public static final String CUSTOM_RINGTONE = "custom_ringtone";
171
172 /**
173 * Whether the person should always be sent to voicemail. Not always
174 * present.
175 * <P>Type: INTEGER (0 for false, 1 for true)</P>
176 */
177 public static final String SEND_TO_VOICEMAIL = "send_to_voicemail";
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700178 }
179
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700180 private interface ContactsColumns {
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700181 /**
182 * The display name for the contact.
183 * <P>Type: TEXT</P>
184 */
185 public static final String DISPLAY_NAME = "display_name";
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700186
187 /**
Evan Millar088b2912009-05-28 15:24:37 -0700188 * Reference to the row in the data table holding the photo.
189 * <P>Type: INTEGER REFERENCES data(_id)</P>
190 */
191 public static final String PHOTO_ID = "photo_id";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -0700192
193 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700194 * Lookup value that reflects the {@link Groups#GROUP_VISIBLE} state of
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700195 * any {@link GroupMembership} for this contact.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -0700196 */
197 public static final String IN_VISIBLE_GROUP = "in_visible_group";
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700198
199 /**
200 * Contact presence status. See {@link android.provider.Im.CommonPresenceColumns}
201 * for individual status definitions.
202 */
203 public static final String PRESENCE_STATUS = Presence.PRESENCE_STATUS;
204
205 /**
Dmitri Plotnikov074fbfe2009-08-11 13:50:21 -0700206 * An indicator of whether this contact has at least one phone number. "1" if there is
207 * at least one phone number, "0" otherwise.
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700208 * <P>Type: INTEGER</P>
209 */
Dmitri Plotnikov074fbfe2009-08-11 13:50:21 -0700210 public static final String HAS_PHONE_NUMBER = "has_phone_number";
Evan Millar088b2912009-05-28 15:24:37 -0700211 }
212
213 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700214 * Constants for the contacts table, which contains a record per group
215 * of raw contact representing the same person.
Evan Millar088b2912009-05-28 15:24:37 -0700216 */
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700217 public static class Contacts implements BaseColumns, ContactsColumns,
Dmitri Plotnikovc9ec66b2009-08-05 12:11:22 -0700218 ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700219 /**
220 * This utility class cannot be instantiated
221 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700222 private Contacts() {}
Evan Millar088b2912009-05-28 15:24:37 -0700223
224 /**
225 * The content:// style URI for this table
226 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700227 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
Evan Millar088b2912009-05-28 15:24:37 -0700228
229 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700230 * The content:// style URI for this table joined with useful data from
Dmitri Plotnikov02c5b452009-07-22 15:13:08 -0700231 * {@link Data}.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700232 */
233 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700234 "contacts_summary");
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700235
Evan Millar161dd862009-06-12 16:02:43 -0700236 /**
237 * The content:// style URI used for "type-to-filter" functionality on the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700238 * {@link #CONTENT_SUMMARY_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700239 * various parts of the contact name. The filter argument should be passed
Evan Millar161dd862009-06-12 16:02:43 -0700240 * as an additional path segment after this URI.
241 */
242 public static final Uri CONTENT_SUMMARY_FILTER_URI = Uri.withAppendedPath(
243 CONTENT_SUMMARY_URI, "filter");
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700244
Evan Millardc2da5f2009-06-18 16:07:13 -0700245 /**
246 * The content:// style URI for this table joined with useful data from
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700247 * {@link Data}, filtered to include only starred contacts
248 * and the most frequently contacted contacts.
Evan Millardc2da5f2009-06-18 16:07:13 -0700249 */
250 public static final Uri CONTENT_SUMMARY_STREQUENT_URI = Uri.withAppendedPath(
251 CONTENT_SUMMARY_URI, "strequent");
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700252
Evan Millardc2da5f2009-06-18 16:07:13 -0700253 /**
254 * The content:// style URI used for "type-to-filter" functionality on the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700255 * {@link #CONTENT_SUMMARY_STREQUENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700256 * various parts of the contact name. The filter argument should be passed
Evan Millardc2da5f2009-06-18 16:07:13 -0700257 * as an additional path segment after this URI.
258 */
259 public static final Uri CONTENT_SUMMARY_STREQUENT_FILTER_URI = Uri.withAppendedPath(
260 CONTENT_SUMMARY_STREQUENT_URI, "filter");
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700261
Evan Millarb9263752009-07-15 11:32:19 -0700262 public static final Uri CONTENT_SUMMARY_GROUP_URI = Uri.withAppendedPath(
263 CONTENT_SUMMARY_URI, "group");
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700264 /**
Evan Millar088b2912009-05-28 15:24:37 -0700265 * The MIME type of {@link #CONTENT_URI} providing a directory of
266 * people.
267 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700268 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
Evan Millar088b2912009-05-28 15:24:37 -0700269
270 /**
271 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
272 * person.
273 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700274 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
Evan Millar088b2912009-05-28 15:24:37 -0700275
276 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700277 * A sub-directory of a single contact that contains all of the constituent raw contact
Evan Millar088b2912009-05-28 15:24:37 -0700278 * {@link Data} rows.
279 */
Fred Quintana8851e162009-08-05 21:06:45 -0700280 public static final class Data implements BaseColumns, DataColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700281 /**
282 * no public constructor since this is a utility class
283 */
284 private Data() {}
285
286 /**
287 * The directory twig for this sub-table
288 */
289 public static final String CONTENT_DIRECTORY = "data";
290 }
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700291
292 /**
293 * A sub-directory of a single contact aggregate that contains all aggregation suggestions
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700294 * (other contacts). The aggregation suggestions are computed based on approximate
295 * data matches with this contact.
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700296 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700297 public static final class AggregationSuggestions implements BaseColumns, ContactsColumns {
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700298 /**
299 * No public constructor since this is a utility class
300 */
301 private AggregationSuggestions() {}
302
303 /**
304 * The directory twig for this sub-table
305 */
306 public static final String CONTENT_DIRECTORY = "suggestions";
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700307 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700308
309 /**
310 * Returns a URI that can be used to retrieve the contact's default photo.
311 *
312 * @param contactUri the contact whose photo should be used
313 */
314 public static Uri getPhotoUri(ContentResolver cr, Uri contactUri) {
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -0700315
316 // TODO remove try/catch block as soon as eclair-dev is merged in eclair
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700317 try {
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -0700318 long photoId = -1;
319 Cursor cursor = cr.query(contactUri, new String[] {Contacts.PHOTO_ID},
320 null, null, null);
321 try {
322 if (!cursor.moveToNext()) {
323 return null;
324 }
325
326 if (cursor.isNull(0)) {
327 return null;
328 }
329
330 photoId = cursor.getLong(0);
331 } finally {
332 cursor.close();
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700333 }
334
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -0700335 return ContentUris.withAppendedId(ContactsContract.Data.CONTENT_URI, photoId);
336 } catch (Exception e) {
337 return null;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700338 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700339 }
340
341 /**
342 * Opens an InputStream for the person's default photo and returns the
343 * photo as a Bitmap stream.
344 *
345 * @param contactUri the contact whose photo should be used
346 */
347 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
348 Uri photoUri = getPhotoUri(cr, contactUri);
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -0700349 if (photoUri == null) {
350 return null;
351 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700352 Cursor cursor = cr.query(photoUri,
353 new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null);
354 try {
355 if (!cursor.moveToNext()) {
356 return null;
357 }
358 byte[] data = cursor.getBlob(0);
359 if (data == null) {
360 return null;
361 }
362 return new ByteArrayInputStream(data);
363 } finally {
364 cursor.close();
365 }
366 }
Evan Millar088b2912009-05-28 15:24:37 -0700367 }
368
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -0700369 private interface RawContactsColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700370 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700371 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} that this
372 * data belongs to.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700373 * <P>Type: INTEGER</P>
Evan Millar088b2912009-05-28 15:24:37 -0700374 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700375 public static final String CONTACT_ID = "contact_id";
Evan Millar088b2912009-05-28 15:24:37 -0700376
377 /**
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -0700378 * Flag indicating that this {@link RawContacts} entry and its children has
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700379 * been restricted to specific platform apps.
380 * <P>Type: INTEGER (boolean)</P>
381 *
382 * @hide until finalized in future platform release
383 */
384 public static final String IS_RESTRICTED = "is_restricted";
385
386 /**
387 * The aggregation mode for this contact.
388 * <P>Type: INTEGER</P>
389 */
390 public static final String AGGREGATION_MODE = "aggregation_mode";
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -0700391
392 /**
393 * The "deleted" flag: "0" by default, "1" if the row has been marked
394 * for deletion. When {@link android.content.ContentResolver#delete} is
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700395 * called on a raw contact, it is marked for deletion and removed from its
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700396 * aggregate contact. The sync adaptor deletes the raw contact on the server and
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -0700397 * then calls ContactResolver.delete once more, this time passing the
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700398 * {@link RawContacts#DELETE_PERMANENTLY} query parameter to finalize the data removal.
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -0700399 * <P>Type: INTEGER</P>
400 */
401 public static final String DELETED = "deleted";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700402 }
403
404 /**
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -0700405 * Constants for the raw_contacts table, which contains the base contact
406 * information per sync source. Sync adapters and contact management apps
407 * are the primary consumers of this API.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700408 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700409 public static final class RawContacts implements BaseColumns, RawContactsColumns,
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700410 ContactOptionsColumns, SyncColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700411 /**
412 * This utility class cannot be instantiated
413 */
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -0700414 private RawContacts() {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700415 }
416
417 /**
Evan Millar088b2912009-05-28 15:24:37 -0700418 * The content:// style URI for this table
419 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700420 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
Evan Millar088b2912009-05-28 15:24:37 -0700421
422 /**
423 * The content:// style URL for filtering people by email address. The
424 * filter argument should be passed as an additional path segment after
425 * this URI.
Dmitri Plotnikov56927772009-05-28 17:23:39 -0700426 *
Evan Millar088b2912009-05-28 15:24:37 -0700427 * @hide
428 */
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -0700429 @Deprecated
Evan Millardc2da5f2009-06-18 16:07:13 -0700430 public static final Uri CONTENT_FILTER_EMAIL_URI =
431 Uri.withAppendedPath(CONTENT_URI, "filter_email");
Evan Millar088b2912009-05-28 15:24:37 -0700432
433 /**
434 * The MIME type of {@link #CONTENT_URI} providing a directory of
435 * people.
436 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700437 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -0700438
439 /**
440 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
441 * person.
442 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700443 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -0700444
445 /**
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -0700446 * Query parameter that can be passed with the {@link #CONTENT_URI} URI
447 * to the {@link android.content.ContentResolver#delete} method to
448 * indicate that the raw contact can be deleted physically, rather than
449 * merely marked as deleted.
450 */
451 public static final String DELETE_PERMANENTLY = "delete_permanently";
452
453 /**
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700454 * Aggregation mode: aggregate asynchronously.
455 */
456 public static final int AGGREGATION_MODE_DEFAULT = 0;
457
458 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700459 * Aggregation mode: aggregate at the time the raw contact is inserted/updated.
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700460 */
461 public static final int AGGREGATION_MODE_IMMEDITATE = 1;
462
463 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700464 * Aggregation mode: never aggregate this raw contact (note that the raw contact will not
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700465 * have a corresponding Aggregate and therefore will not be included in Aggregates
466 * query results.)
467 */
468 public static final int AGGREGATION_MODE_DISABLED = 2;
469
470 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700471 * A sub-directory of a single raw contact that contains all of their {@link Data} rows.
Evan Millar088b2912009-05-28 15:24:37 -0700472 * To access this directory append
473 */
474 public static final class Data implements BaseColumns, DataColumns {
475 /**
476 * no public constructor since this is a utility class
477 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700478 private Data() {
479 }
Evan Millar088b2912009-05-28 15:24:37 -0700480
481 /**
482 * The directory twig for this sub-table
483 */
484 public static final String CONTENT_DIRECTORY = "data";
485 }
486 }
487
488 private interface DataColumns {
489 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700490 * The package name to use when creating {@link Resources} objects for
491 * this data row. This value is only designed for use when building user
492 * interfaces, and should not be used to infer the owner.
493 */
494 public static final String RES_PACKAGE = "res_package";
495
496 /**
497 * The MIME type of the item represented by this row.
Evan Millar088b2912009-05-28 15:24:37 -0700498 */
499 public static final String MIMETYPE = "mimetype";
500
501 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700502 * A reference to the {@link RawContacts#_ID}
Dmitri Plotnikov56927772009-05-28 17:23:39 -0700503 * that this data belongs to.
Evan Millar088b2912009-05-28 15:24:37 -0700504 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700505 public static final String RAW_CONTACT_ID = "raw_contact_id";
506
Evan Millarab5742d2009-06-02 16:21:45 -0700507 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700508 * Whether this is the primary entry of its kind for the raw contact it belongs to
Evan Millarab5742d2009-06-02 16:21:45 -0700509 * <P>Type: INTEGER (if set, non-0 means true)</P>
510 */
511 public static final String IS_PRIMARY = "is_primary";
512
513 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700514 * Whether this is the primary entry of its kind for the aggregate
515 * contact it belongs to. Any data record that is "super primary" must
516 * also be "primary".
Evan Millarab5742d2009-06-02 16:21:45 -0700517 * <P>Type: INTEGER (if set, non-0 means true)</P>
518 */
519 public static final String IS_SUPER_PRIMARY = "is_super_primary";
520
Jeff Sharkey28b68e52009-06-10 15:26:58 -0700521 /**
Fred Quintanac933fb62009-06-11 12:14:40 -0700522 * The version of this data record. This is a read-only value. The data column is
523 * guaranteed to not change without the version going up. This value is monotonically
524 * increasing.
525 * <P>Type: INTEGER</P>
526 */
527 public static final String DATA_VERSION = "data_version";
528
Evan Millar088b2912009-05-28 15:24:37 -0700529 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
530 public static final String DATA1 = "data1";
531 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
532 public static final String DATA2 = "data2";
533 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
534 public static final String DATA3 = "data3";
535 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
536 public static final String DATA4 = "data4";
537 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
538 public static final String DATA5 = "data5";
539 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
540 public static final String DATA6 = "data6";
541 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
542 public static final String DATA7 = "data7";
543 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
544 public static final String DATA8 = "data8";
545 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
546 public static final String DATA9 = "data9";
547 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
548 public static final String DATA10 = "data10";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700549 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
550 public static final String DATA11 = "data11";
551 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
552 public static final String DATA12 = "data12";
553 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
554 public static final String DATA13 = "data13";
555 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
556 public static final String DATA14 = "data14";
557 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
558 public static final String DATA15 = "data15";
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700559
Fred Quintana8851e162009-08-05 21:06:45 -0700560 /** Generic column for use by sync adapters. */
561 public static final String SYNC1 = "data_sync1";
562 /** Generic column for use by sync adapters. */
563 public static final String SYNC2 = "data_sync2";
564 /** Generic column for use by sync adapters. */
565 public static final String SYNC3 = "data_sync3";
566 /** Generic column for use by sync adapters. */
567 public static final String SYNC4 = "data_sync4";
568
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700569 /**
Dmitri Plotnikov507f1602009-08-10 17:37:36 -0700570 * An optional insert, update or delete URI parameter that determines if
571 * the corresponding raw contact should be marked as dirty. The default
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700572 * value is true.
573 */
574 public static final String MARK_AS_DIRTY = "mark_as_dirty";
Evan Millar088b2912009-05-28 15:24:37 -0700575 }
576
577 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700578 * Constants for the data table, which contains data points tied to a raw contact.
Evan Millar088b2912009-05-28 15:24:37 -0700579 * For example, a phone number or email address. Each row in this table contains a type
580 * definition and some generic columns. Each data type can define the meaning for each of
581 * the generic columns.
582 */
Fred Quintana8851e162009-08-05 21:06:45 -0700583 public static final class Data implements BaseColumns, DataColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700584 /**
585 * This utility class cannot be instantiated
586 */
587 private Data() {}
588
589 /**
590 * The content:// style URI for this table
591 */
592 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
593
594 /**
595 * The MIME type of {@link #CONTENT_URI} providing a directory of data.
596 */
597 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
598 }
599
Dmitri Plotnikov93032952009-08-19 11:26:57 -0700600 private interface PhoneLookupColumns {
601 /**
602 * The phone number as the user entered it.
603 * <P>Type: TEXT</P>
604 */
605 public static final String NUMBER = "number";
606
607 /**
608 * The type of phone number, for example Home or Work.
609 * <P>Type: INTEGER</P>
610 */
611 public static final String TYPE = "type";
612
613 /**
614 * The user defined label for the phone number.
615 * <P>Type: TEXT</P>
616 */
617 public static final String LABEL = "label";
618 }
619
Evan Millar088b2912009-05-28 15:24:37 -0700620 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700621 * A table that represents the result of looking up a phone number, for
Dmitri Plotnikov93032952009-08-19 11:26:57 -0700622 * example for caller ID. To perform a lookup you must append the number you
623 * want to find to {@link #CONTENT_FILTER_URI}.
Evan Millar088b2912009-05-28 15:24:37 -0700624 */
Dmitri Plotnikov93032952009-08-19 11:26:57 -0700625 public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
626 ContactsColumns, ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700627 /**
628 * This utility class cannot be instantiated
629 */
630 private PhoneLookup() {}
631
632 /**
633 * The content:// style URI for this table. Append the phone number you want to lookup
634 * to this URI and query it to perform a lookup. For example:
635 *
636 * {@code
637 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, phoneNumber);
638 * }
639 */
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700640 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
641 "phone_lookup");
642 }
643
644 /**
645 * Additional data mixed in with {@link Im.CommonPresenceColumns} to link
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700646 * back to specific {@link ContactsContract.Contacts#_ID} entries.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700647 */
648 private interface PresenceColumns {
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700649
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700650 /**
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700651 * The unique ID for a row.
652 * <P>Type: INTEGER (long)</P>
653 */
654 public static final String _ID = "presence_id";
655
656 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700657 * Reference to the {@link RawContacts#_ID} this presence references.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700658 * <P>Type: INTEGER</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700659 */
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -0700660 public static final String RAW_CONTACT_ID = "presence_raw_contact_id";
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700661
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700662 /**
663 * Reference to the {@link Data#_ID} entry that owns this presence.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700664 * <P>Type: INTEGER</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700665 */
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -0700666 public static final String DATA_ID = "presence_data_id";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700667
668 /**
669 * The IM service the presence is coming from. Formatted using either
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700670 * {@link CommonDataKinds.Im#encodePredefinedImProtocol(int)} or
671 * {@link CommonDataKinds.Im#encodeCustomImProtocol(String)}.
672 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700673 */
674 public static final String IM_PROTOCOL = "im_protocol";
675
676 /**
677 * The IM handle the presence item is for. The handle is scoped to the
678 * {@link #IM_PROTOCOL}.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700679 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700680 */
681 public static final String IM_HANDLE = "im_handle";
682
683 /**
684 * The IM account for the local user that the presence data came from.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700685 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700686 */
687 public static final String IM_ACCOUNT = "im_account";
688 }
689
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700690 public static final class Presence implements PresenceColumns, Im.CommonPresenceColumns {
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700691 /**
692 * This utility class cannot be instantiated
693 */
694 private Presence() {
695 }
696
697 /**
698 * The content:// style URI for this table
699 */
700 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "presence");
701
702 /**
703 * Gets the resource ID for the proper presence icon.
704 *
705 * @param status the status to get the icon for
706 * @return the resource ID for the proper presence icon
707 */
708 public static final int getPresenceIconResourceId(int status) {
709 switch (status) {
710 case AVAILABLE:
711 return android.R.drawable.presence_online;
712 case IDLE:
713 case AWAY:
714 return android.R.drawable.presence_away;
715 case DO_NOT_DISTURB:
716 return android.R.drawable.presence_busy;
717 case INVISIBLE:
718 return android.R.drawable.presence_invisible;
719 case OFFLINE:
720 default:
721 return android.R.drawable.presence_offline;
722 }
723 }
724
725 /**
Evan Millarc0437522009-06-23 17:31:05 -0700726 * Returns the precedence of the status code the higher number being the higher precedence.
727 *
728 * @param status The status code.
729 * @return An integer representing the precedence, 0 being the lowest.
730 */
731 public static final int getPresencePrecedence(int status) {
732 // Keep this function here incase we want to enforce a different precedence than the
733 // natural order of the status constants.
734 return status;
735 }
736
737 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700738 * The MIME type of {@link #CONTENT_URI} providing a directory of
739 * presence details.
740 */
741 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-presence";
742
743 /**
744 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
745 * presence detail.
746 */
747 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-presence";
Evan Millar088b2912009-05-28 15:24:37 -0700748 }
749
750 /**
751 * Container for definitions of common data types stored in the {@link Data} table.
752 */
753 public static final class CommonDataKinds {
754 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700755 * The {@link Data#RES_PACKAGE} value for common data that should be
756 * shown using a default style.
Evan Millar088b2912009-05-28 15:24:37 -0700757 */
758 public static final String PACKAGE_COMMON = "common";
759
760 /**
761 * Columns common across the specific types.
762 */
763 private interface BaseCommonColumns {
764 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700765 * The package name to use when creating {@link Resources} objects for
766 * this data row. This value is only designed for use when building user
767 * interfaces, and should not be used to infer the owner.
Evan Millar088b2912009-05-28 15:24:37 -0700768 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700769 public static final String RES_PACKAGE = "res_package";
Evan Millar088b2912009-05-28 15:24:37 -0700770
771 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700772 * The MIME type of the item represented by this row.
Evan Millar088b2912009-05-28 15:24:37 -0700773 */
774 public static final String MIMETYPE = "mimetype";
775
776 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700777 * The {@link RawContacts#_ID} that this data belongs to.
Evan Millar088b2912009-05-28 15:24:37 -0700778 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700779 public static final String RAW_CONTACT_ID = "raw_contact_id";
Evan Millar088b2912009-05-28 15:24:37 -0700780 }
781
782 /**
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -0700783 * The base types that all "Typed" data kinds support.
784 */
785 public interface BaseTypes {
786
787 /**
788 * A custom type. The custom label should be supplied by user.
789 */
790 public static int TYPE_CUSTOM = 0;
791 }
792
793 /**
Evan Millar088b2912009-05-28 15:24:37 -0700794 * Columns common across the specific types.
795 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -0700796 private interface CommonColumns extends BaseTypes{
Evan Millar088b2912009-05-28 15:24:37 -0700797 /**
798 * The type of data, for example Home or Work.
799 * <P>Type: INTEGER</P>
800 */
801 public static final String TYPE = "data1";
802
803 /**
Evan Millar088b2912009-05-28 15:24:37 -0700804 * The data for the contact method.
805 * <P>Type: TEXT</P>
806 */
Dmitri Plotnikovc9260542009-05-28 17:55:12 -0700807 public static final String DATA = "data2";
808
809 /**
810 * The user defined label for the the contact method.
811 * <P>Type: TEXT</P>
812 */
813 public static final String LABEL = "data3";
Evan Millar088b2912009-05-28 15:24:37 -0700814 }
815
816 /**
817 * Parts of the name.
818 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700819 public static final class StructuredName implements BaseCommonColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700820 private StructuredName() {}
821
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700822 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -0700823 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
824
825 /**
Evan Millar088b2912009-05-28 15:24:37 -0700826 * The given name for the contact.
827 * <P>Type: TEXT</P>
828 */
Dmitri Plotnikovc9260542009-05-28 17:55:12 -0700829 public static final String GIVEN_NAME = "data1";
Evan Millar088b2912009-05-28 15:24:37 -0700830
831 /**
832 * The family name for the contact.
833 * <P>Type: TEXT</P>
834 */
Dmitri Plotnikovc9260542009-05-28 17:55:12 -0700835 public static final String FAMILY_NAME = "data2";
836
837 /**
838 * The contact's honorific prefix, e.g. "Sir"
839 * <P>Type: TEXT</P>
840 */
841 public static final String PREFIX = "data3";
842
843 /**
844 * The contact's middle name
845 * <P>Type: TEXT</P>
846 */
847 public static final String MIDDLE_NAME = "data4";
Evan Millar088b2912009-05-28 15:24:37 -0700848
849 /**
850 * The contact's honorific suffix, e.g. "Jr"
851 */
852 public static final String SUFFIX = "data5";
853
854 /**
855 * The phonetic version of the given name for the contact.
856 * <P>Type: TEXT</P>
857 */
858 public static final String PHONETIC_GIVEN_NAME = "data6";
859
860 /**
861 * The phonetic version of the additional name for the contact.
862 * <P>Type: TEXT</P>
863 */
864 public static final String PHONETIC_MIDDLE_NAME = "data7";
865
866 /**
867 * The phonetic version of the family name for the contact.
868 * <P>Type: TEXT</P>
869 */
870 public static final String PHONETIC_FAMILY_NAME = "data8";
871
872 /**
873 * The name that should be used to display the contact.
Jeff Sharkey62b83b72009-08-11 17:33:48 -0700874 * <i>Unstructured component of the name should be consistent with
875 * its structured representation.</i>
876 * <p>
877 * Type: TEXT
Evan Millar088b2912009-05-28 15:24:37 -0700878 */
879 public static final String DISPLAY_NAME = "data9";
880 }
881
882 /**
883 * A nickname.
884 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700885 public static final class Nickname implements CommonColumns, BaseCommonColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700886 private Nickname() {}
887
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700888 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -0700889 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
890
Evan Millar78e79ad2009-06-08 10:24:44 -0700891 public static final int TYPE_DEFAULT = 1;
892 public static final int TYPE_OTHER_NAME = 2;
893 public static final int TYPE_MAINDEN_NAME = 3;
894 public static final int TYPE_SHORT_NAME = 4;
895 public static final int TYPE_INITIALS = 5;
Evan Millar088b2912009-05-28 15:24:37 -0700896
897 /**
Dmitri Plotnikovc9260542009-05-28 17:55:12 -0700898 * The name itself
899 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -0700900 public static final String NAME = DATA;
Evan Millar088b2912009-05-28 15:24:37 -0700901 }
902
903 /**
904 * Common data definition for telephone numbers.
905 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -0700906 public static final class Phone implements BaseCommonColumns, CommonColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700907 private Phone() {}
908
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700909 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -0700910 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone";
911
Evan Millar161dd862009-06-12 16:02:43 -0700912 /**
913 * The MIME type of {@link #CONTENT_URI} providing a directory of
914 * phones.
915 */
916 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone";
917
918 /**
919 * The content:// style URI for all data records of the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700920 * {@link Phone#CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700921 * associated raw contact and aggregate contact data.
Evan Millar161dd862009-06-12 16:02:43 -0700922 */
923 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
924 "phones");
925
926 /**
927 * The content:// style URI for filtering data records of the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700928 * {@link Phone#CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700929 * associated raw contact and aggregate contact data. The filter argument should
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700930 * be passed as an additional path segment after this URI.
Evan Millar161dd862009-06-12 16:02:43 -0700931 */
932 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
933 "filter");
934
Evan Millar088b2912009-05-28 15:24:37 -0700935 public static final int TYPE_HOME = 1;
936 public static final int TYPE_MOBILE = 2;
937 public static final int TYPE_WORK = 3;
938 public static final int TYPE_FAX_WORK = 4;
939 public static final int TYPE_FAX_HOME = 5;
940 public static final int TYPE_PAGER = 6;
941 public static final int TYPE_OTHER = 7;
Fred Quintana3f867152009-08-03 11:43:16 -0700942 public static final int TYPE_CALLBACK = 8;
943 public static final int TYPE_CAR = 9;
944 public static final int TYPE_COMPANY_MAIN = 10;
945 public static final int TYPE_ISDN = 11;
946 public static final int TYPE_MAIN = 12;
947 public static final int TYPE_OTHER_FAX = 13;
948 public static final int TYPE_RADIO = 14;
949 public static final int TYPE_TELEX = 15;
950 public static final int TYPE_TTY_TDD = 16;
951 public static final int TYPE_WORK_MOBILE = 17;
952 public static final int TYPE_WORK_PAGER = 18;
953 public static final int TYPE_ASSISTANT = 19;
Evan Millar088b2912009-05-28 15:24:37 -0700954
955 /**
956 * The phone number as the user entered it.
957 * <P>Type: TEXT</P>
958 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -0700959 public static final String NUMBER = DATA;
Dmitri Plotnikov93032952009-08-19 11:26:57 -0700960
961 public static final CharSequence getDisplayLabel(Context context, int type,
962 CharSequence label, CharSequence[] labelArray) {
963 CharSequence display = "";
964
965 if (type != Phone.TYPE_CUSTOM) {
966 CharSequence[] labels = labelArray != null? labelArray
967 : context.getResources().getTextArray(
968 com.android.internal.R.array.phoneTypes);
969 try {
970 display = labels[type - 1];
971 } catch (ArrayIndexOutOfBoundsException e) {
972 display = labels[Phone.TYPE_CUSTOM];
973 }
974 } else {
975 if (!TextUtils.isEmpty(label)) {
976 display = label;
977 }
978 }
979 return display;
980 }
981
982 public static final CharSequence getDisplayLabel(Context context, int type,
983 CharSequence label) {
984 return getDisplayLabel(context, type, label, null);
985 }
Evan Millar088b2912009-05-28 15:24:37 -0700986 }
987
988 /**
989 * Common data definition for email addresses.
990 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -0700991 public static final class Email implements BaseCommonColumns, CommonColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700992 private Email() {}
993
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700994 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -0700995 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email";
996
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -0700997 /**
998 * The content:// style URI for all data records of the
999 * {@link Email#CONTENT_ITEM_TYPE} MIME type, combined with the
1000 * associated raw contact and aggregate contact data.
1001 */
1002 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1003 "emails");
1004
1005 /**
1006 * The content:// style URL for filtering data rows by email address. The
1007 * filter argument should be passed as an additional path segment after
1008 * this URI.
1009 */
1010 public static final Uri CONTENT_FILTER_EMAIL_URI = Uri.withAppendedPath(CONTENT_URI,
1011 "filter");
1012
Evan Millar088b2912009-05-28 15:24:37 -07001013 public static final int TYPE_HOME = 1;
1014 public static final int TYPE_WORK = 2;
1015 public static final int TYPE_OTHER = 3;
Fred Quintana8851e162009-08-05 21:06:45 -07001016
1017 /**
1018 * The display name for the email address
1019 * <P>Type: TEXT</P>
1020 */
1021 public static final String DISPLAY_NAME = "data4";
Evan Millar088b2912009-05-28 15:24:37 -07001022 }
1023
1024 /**
1025 * Common data definition for postal addresses.
1026 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001027 public static final class StructuredPostal implements BaseCommonColumns, CommonColumns {
1028 private StructuredPostal() {
1029 }
Evan Millar088b2912009-05-28 15:24:37 -07001030
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001031 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001032 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/postal-address";
1033
Evan Millar161dd862009-06-12 16:02:43 -07001034 /**
1035 * The MIME type of {@link #CONTENT_URI} providing a directory of
1036 * postal addresses.
1037 */
1038 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address";
1039
1040 /**
1041 * The content:// style URI for all data records of the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001042 * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
Evan Millar161dd862009-06-12 16:02:43 -07001043 */
1044 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1045 "postals");
1046
Evan Millar088b2912009-05-28 15:24:37 -07001047 public static final int TYPE_HOME = 1;
1048 public static final int TYPE_WORK = 2;
1049 public static final int TYPE_OTHER = 3;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001050
1051 /**
Jeff Sharkey62b83b72009-08-11 17:33:48 -07001052 * The full, unstructured postal address. <i>This field must be
1053 * consistent with any structured data.</i>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001054 * <p>
1055 * Type: TEXT
1056 */
1057 public static final String FORMATTED_ADDRESS = DATA;
1058
1059 /**
1060 * The agent who actually receives the mail. Used in work addresses.
1061 * Also for 'in care of' or 'c/o'.
1062 * <p>
1063 * Type: TEXT
Jeff Sharkey62b83b72009-08-11 17:33:48 -07001064 * @deprecated since this isn't supported by gd:structuredPostalAddress
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001065 */
Jeff Sharkey62b83b72009-08-11 17:33:48 -07001066 @Deprecated
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001067 public static final String AGENT = "data4";
1068
1069 /**
1070 * Used in places where houses or buildings have names (and not
1071 * necessarily numbers), eg. "The Pillars".
1072 * <p>
1073 * Type: TEXT
Jeff Sharkey62b83b72009-08-11 17:33:48 -07001074 * @deprecated since this isn't supported by gd:structuredPostalAddress
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001075 */
Jeff Sharkey62b83b72009-08-11 17:33:48 -07001076 @Deprecated
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001077 public static final String HOUSENAME = "data5";
1078
1079 /**
1080 * Can be street, avenue, road, etc. This element also includes the
1081 * house number and room/apartment/flat/floor number.
1082 * <p>
1083 * Type: TEXT
1084 */
1085 public static final String STREET = "data6";
1086
1087 /**
1088 * Covers actual P.O. boxes, drawers, locked bags, etc. This is
1089 * usually but not always mutually exclusive with street.
1090 * <p>
1091 * Type: TEXT
1092 */
1093 public static final String POBOX = "data7";
1094
1095 /**
1096 * This is used to disambiguate a street address when a city
1097 * contains more than one street with the same name, or to specify a
1098 * small place whose mail is routed through a larger postal town. In
1099 * China it could be a county or a minor city.
1100 * <p>
1101 * Type: TEXT
1102 */
Jeff Sharkeyef348c72009-07-26 14:14:34 -07001103 public static final String NEIGHBORHOOD = "data8";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001104
1105 /**
1106 * Can be city, village, town, borough, etc. This is the postal town
1107 * and not necessarily the place of residence or place of business.
1108 * <p>
1109 * Type: TEXT
1110 */
1111 public static final String CITY = "data9";
1112
1113 /**
1114 * Handles administrative districts such as U.S. or U.K. counties
1115 * that are not used for mail addressing purposes. Subregion is not
1116 * intended for delivery addresses.
1117 * <p>
1118 * Type: TEXT
Jeff Sharkey62b83b72009-08-11 17:33:48 -07001119 * @deprecated since this isn't supported by gd:structuredPostalAddress
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001120 */
Jeff Sharkey62b83b72009-08-11 17:33:48 -07001121 @Deprecated
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001122 public static final String SUBREGION = "data10";
1123
1124 /**
1125 * A state, province, county (in Ireland), Land (in Germany),
1126 * departement (in France), etc.
1127 * <p>
1128 * Type: TEXT
1129 */
1130 public static final String REGION = "data11";
1131
1132 /**
Jeff Sharkeyef348c72009-07-26 14:14:34 -07001133 * Postal code. Usually country-wide, but sometimes specific to the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001134 * city (e.g. "2" in "Dublin 2, Ireland" addresses).
1135 * <p>
1136 * Type: TEXT
1137 */
1138 public static final String POSTCODE = "data12";
1139
1140 /**
1141 * The name or code of the country.
1142 * <p>
1143 * Type: TEXT
1144 */
1145 public static final String COUNTRY = "data13";
Evan Millar088b2912009-05-28 15:24:37 -07001146 }
1147
Fred Quintana8851e162009-08-05 21:06:45 -07001148 /**
1149 * Common data definition for IM addresses.
1150 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001151 public static final class Im implements BaseCommonColumns, CommonColumns {
Evan Millar088b2912009-05-28 15:24:37 -07001152 private Im() {}
1153
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001154 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001155 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
1156
Evan Millar088b2912009-05-28 15:24:37 -07001157 public static final int TYPE_HOME = 1;
1158 public static final int TYPE_WORK = 2;
1159 public static final int TYPE_OTHER = 3;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07001160
Evan Millar088b2912009-05-28 15:24:37 -07001161 public static final String PROTOCOL = "data5";
Dmitri Plotnikov56927772009-05-28 17:23:39 -07001162
Jeff Sharkey732da922009-07-30 09:59:31 -07001163 public static final String CUSTOM_PROTOCOL = "data6";
1164
Evan Millar088b2912009-05-28 15:24:37 -07001165 /**
1166 * The predefined IM protocol types. The protocol can either be non-present, one
1167 * of these types, or a free-form string. These cases are encoded in the PROTOCOL
1168 * column as:
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07001169 * <ul>
1170 * <li>null</li>
1171 * <li>pre:&lt;an integer, one of the protocols below&gt;</li>
1172 * <li>custom:&lt;a string&gt;</li>
1173 * </ul>
Evan Millar088b2912009-05-28 15:24:37 -07001174 */
Jeff Sharkey732da922009-07-30 09:59:31 -07001175 public static final int PROTOCOL_CUSTOM = -1;
Evan Millar088b2912009-05-28 15:24:37 -07001176 public static final int PROTOCOL_AIM = 0;
1177 public static final int PROTOCOL_MSN = 1;
1178 public static final int PROTOCOL_YAHOO = 2;
1179 public static final int PROTOCOL_SKYPE = 3;
1180 public static final int PROTOCOL_QQ = 4;
1181 public static final int PROTOCOL_GOOGLE_TALK = 5;
1182 public static final int PROTOCOL_ICQ = 6;
1183 public static final int PROTOCOL_JABBER = 7;
Fred Quintana8851e162009-08-05 21:06:45 -07001184 public static final int PROTOCOL_NETMEETING = 8;
Evan Millar088b2912009-05-28 15:24:37 -07001185 }
1186
1187 /**
1188 * Common data definition for organizations.
1189 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001190 public static final class Organization implements BaseCommonColumns, CommonColumns {
Evan Millar088b2912009-05-28 15:24:37 -07001191 private Organization() {}
1192
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001193 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001194 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
1195
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001196 public static final int TYPE_WORK = 1;
1197 public static final int TYPE_OTHER = 2;
Evan Millar088b2912009-05-28 15:24:37 -07001198
1199 /**
1200 * The company as the user entered it.
1201 * <P>Type: TEXT</P>
1202 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001203 public static final String COMPANY = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07001204
1205 /**
1206 * The position title at this company as the user entered it.
1207 * <P>Type: TEXT</P>
1208 */
1209 public static final String TITLE = "data4";
Fred Quintana8851e162009-08-05 21:06:45 -07001210
1211 /**
1212 * The department at this company as the user entered it.
1213 * <P>Type: TEXT</P>
1214 */
1215 public static final String DEPARTMENT = "data5";
1216
1217 /**
1218 * The job description at this company as the user entered it.
1219 * <P>Type: TEXT</P>
1220 */
1221 public static final String JOB_DESCRIPTION = "data6";
1222
1223 /**
1224 * The symbol of this company as the user entered it.
1225 * <P>Type: TEXT</P>
1226 */
1227 public static final String SYMBOL = "data7";
1228
1229 /**
1230 * The phonetic name of this company as the user entered it.
1231 * <P>Type: TEXT</P>
1232 */
1233 public static final String PHONETIC_NAME = "data8";
1234 }
1235
1236 /**
1237 * Common data definition for miscellaneous information.
1238 */
1239 public static final class Miscellaneous implements BaseCommonColumns {
1240 private Miscellaneous() {}
1241
1242 /** MIME type used when storing this in data table. */
1243 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/misc";
1244
1245 /**
1246 * The birthday as the user entered it.
1247 * <P>Type: TEXT</P>
1248 */
1249 public static final String BIRTHDAY = "data1";
1250
1251 /**
1252 * The nickname as the user entered it.
1253 * <P>Type: TEXT</P>
1254 */
1255 public static final String NICKNAME = "data2";
1256 }
1257
1258 /**
1259 * Common data definition for relations.
1260 */
1261 public static final class Relation implements BaseCommonColumns, CommonColumns {
1262 private Relation() {}
1263
1264 /** MIME type used when storing this in data table. */
1265 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
1266
1267 public static final int TYPE_ASSISTANT = 1;
1268 public static final int TYPE_BROTHER = 2;
1269 public static final int TYPE_CHILD = 3;
1270 public static final int TYPE_DOMESTIC_PARTNER = 4;
1271 public static final int TYPE_FATHER = 5;
1272 public static final int TYPE_FRIEND = 6;
1273 public static final int TYPE_MANAGER = 7;
1274 public static final int TYPE_MOTHER = 8;
1275 public static final int TYPE_PARENT = 9;
1276 public static final int TYPE_PARTNER = 10;
1277 public static final int TYPE_REFERRED_BY = 11;
1278 public static final int TYPE_RELATIVE = 12;
1279 public static final int TYPE_SISTER = 13;
1280 public static final int TYPE_SPOUSE = 14;
1281
1282 /**
1283 * The name of the relative as the user entered it.
1284 * <P>Type: TEXT</P>
1285 */
1286 public static final String NAME = DATA;
1287 }
1288
1289 /**
1290 * Common data definition for events.
1291 */
1292 public static final class Event implements BaseCommonColumns, CommonColumns {
1293 private Event() {}
1294
1295 /** MIME type used when storing this in data table. */
1296 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/event";
1297
1298 public static final int TYPE_ANNIVERSARY = 1;
1299 public static final int TYPE_OTHER = 2;
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001300
Fred Quintana8851e162009-08-05 21:06:45 -07001301 /**
1302 * The event start date as the user entered it.
1303 * <P>Type: TEXT</P>
1304 */
1305 public static final String START_DATE = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07001306 }
1307
1308 /**
1309 * Photo of the contact.
1310 */
1311 public static final class Photo implements BaseCommonColumns {
1312 private Photo() {}
1313
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001314 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001315 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
1316
1317 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07001318 * Thumbnail photo of the raw contact. This is the raw bytes of an image
Evan Millar088b2912009-05-28 15:24:37 -07001319 * that could be inflated using {@link BitmapFactory}.
1320 * <p>
1321 * Type: BLOB
1322 */
1323 public static final String PHOTO = "data1";
1324 }
1325
1326 /**
1327 * Notes about the contact.
1328 */
1329 public static final class Note implements BaseCommonColumns {
1330 private Note() {}
1331
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001332 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001333 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
1334
1335 /**
1336 * The note text.
1337 * <P>Type: TEXT</P>
1338 */
1339 public static final String NOTE = "data1";
1340 }
Dmitri Plotnikov56927772009-05-28 17:23:39 -07001341
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07001342 /**
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001343 * Group Membership.
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001344 */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001345 public static final class GroupMembership implements BaseCommonColumns {
1346 private GroupMembership() {}
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001347
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001348 /** MIME type used when storing this in data table. */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001349 public static final String CONTENT_ITEM_TYPE =
1350 "vnd.android.cursor.item/group_membership";
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001351
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001352 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07001353 * The row id of the group that this group membership refers to. Exactly one of
1354 * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001355 * <P>Type: INTEGER</P>
1356 */
1357 public static final String GROUP_ROW_ID = "data1";
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001358
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001359 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07001360 * The sourceid of the group that this group membership refers to. Exactly one of
1361 * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001362 * <P>Type: TEXT</P>
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001363 */
Fred Quintanaffc34c12009-07-14 16:02:58 -07001364 public static final String GROUP_SOURCE_ID = "group_sourceid";
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001365 }
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001366
1367 /**
1368 * Website related to the contact.
1369 */
Fred Quintana8851e162009-08-05 21:06:45 -07001370 public static final class Website implements BaseCommonColumns, CommonColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001371 private Website() {}
1372
1373 /** MIME type used when storing this in data table. */
1374 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
1375
Fred Quintana8851e162009-08-05 21:06:45 -07001376 public static final int TYPE_HOMEPAGE = 1;
1377 public static final int TYPE_BLOG = 2;
1378 public static final int TYPE_PROFILE = 3;
1379 public static final int TYPE_HOME = 4;
1380 public static final int TYPE_WORK = 5;
1381 public static final int TYPE_FTP = 6;
1382 public static final int TYPE_OTHER = 7;
1383
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001384 /**
1385 * The website URL string.
1386 * <P>Type: TEXT</P>
1387 */
1388 public static final String URL = "data1";
1389 }
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001390 }
Fred Quintana435e4272009-06-04 17:30:28 -07001391
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07001392 // TODO: make this private before unhiding
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001393 public interface GroupsColumns {
1394 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001395 * The display title of this group.
1396 * <p>
1397 * Type: TEXT
1398 */
1399 public static final String TITLE = "title";
1400
1401 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001402 * The package name to use when creating {@link Resources} objects for
1403 * this group. This value is only designed for use when building user
1404 * interfaces, and should not be used to infer the owner.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001405 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001406 public static final String RES_PACKAGE = "res_package";
1407
1408 /**
1409 * The display title of this group to load as a resource from
1410 * {@link #RES_PACKAGE}, which may be localized.
1411 * <P>Type: TEXT</P>
1412 */
1413 public static final String TITLE_RES = "title_res";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001414
1415 /**
Dmitri Plotnikov02c5b452009-07-22 15:13:08 -07001416 * Notes about the group.
1417 * <p>
1418 * Type: TEXT
1419 */
1420 public static final String NOTES = "notes";
1421
1422 /**
1423 * The ID of this group if it is a System Group, i.e. a group that has a special meaning
1424 * to the sync adapter, null otherwise.
1425 * <P>Type: TEXT</P>
1426 */
1427 public static final String SYSTEM_ID = "system_id";
1428
1429 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001430 * The total number of {@link Contacts} that have
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001431 * {@link GroupMembership} in this group. Read-only value that is only
1432 * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
1433 * <p>
1434 * Type: INTEGER
1435 */
1436 public static final String SUMMARY_COUNT = "summ_count";
1437
1438 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001439 * The total number of {@link Contacts} that have both
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001440 * {@link GroupMembership} in this group, and also have phone numbers.
1441 * Read-only value that is only present when querying
1442 * {@link Groups#CONTENT_SUMMARY_URI}.
1443 * <p>
1444 * Type: INTEGER
1445 */
1446 public static final String SUMMARY_WITH_PHONES = "summ_phones";
1447
1448 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001449 * Flag indicating if the contacts belonging to this group should be
1450 * visible in any user interface.
1451 * <p>
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07001452 * Type: INTEGER (boolean)
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001453 */
1454 public static final String GROUP_VISIBLE = "group_visible";
Fred Quintana00c89f62009-08-10 14:43:24 -07001455
1456 /**
1457 * The "deleted" flag: "0" by default, "1" if the row has been marked
1458 * for deletion. When {@link android.content.ContentResolver#delete} is
1459 * called on a raw contact, it is marked for deletion and removed from its
1460 * aggregate contact. The sync adaptor deletes the raw contact on the server and
1461 * then calls ContactResolver.delete once more, this time passing the
1462 * {@link RawContacts#DELETE_PERMANENTLY} query parameter to finalize the data removal.
1463 * <P>Type: INTEGER</P>
1464 */
1465 public static final String DELETED = "deleted";
Jeff Sharkey403d7ac2009-08-16 16:34:35 -07001466
1467 /**
1468 * Whether this group should be synced if the SYNC_EVERYTHING settings
1469 * is false for this group's account.
1470 * <p>
1471 * Type: INTEGER (boolean)
1472 */
1473 public static final String SHOULD_SYNC = "should_sync";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001474 }
1475
1476 /**
1477 * Constants for the groups table.
1478 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001479 public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001480 /**
1481 * This utility class cannot be instantiated
1482 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001483 private Groups() {
1484 }
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001485
1486 /**
1487 * The content:// style URI for this table
1488 */
1489 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
1490
1491 /**
1492 * The content:// style URI for this table joined with details data from
Dmitri Plotnikov02c5b452009-07-22 15:13:08 -07001493 * {@link Data}.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001494 */
1495 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
1496 "groups_summary");
1497
1498 /**
1499 * The MIME type of a directory of groups.
1500 */
1501 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
1502
1503 /**
1504 * The MIME type of a single group.
1505 */
1506 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
Fred Quintana00c89f62009-08-10 14:43:24 -07001507
1508 /**
1509 * Query parameter that can be passed with the {@link #CONTENT_URI} URI
1510 * to the {@link android.content.ContentResolver#delete} method to
1511 * indicate that the raw contact can be deleted physically, rather than
1512 * merely marked as deleted.
1513 */
1514 public static final String DELETE_PERMANENTLY = "delete_permanently";
Dmitri Plotnikov507f1602009-08-10 17:37:36 -07001515
1516 /**
1517 * An optional update or insert URI parameter that determines if the
1518 * group should be marked as dirty. The default value is true.
1519 */
1520 public static final String MARK_AS_DIRTY = "mark_as_dirty";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001521 }
1522
Fred Quintana435e4272009-06-04 17:30:28 -07001523 /**
1524 * Constants for the contact aggregation exceptions table, which contains
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07001525 * aggregation rules overriding those used by automatic aggregation. This type only
1526 * supports query and update. Neither insert nor delete are supported.
Fred Quintana435e4272009-06-04 17:30:28 -07001527 */
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001528 public static final class AggregationExceptions implements BaseColumns {
Fred Quintana435e4272009-06-04 17:30:28 -07001529 /**
1530 * This utility class cannot be instantiated
1531 */
1532 private AggregationExceptions() {}
1533
1534 /**
1535 * The content:// style URI for this table
1536 */
1537 public static final Uri CONTENT_URI =
1538 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
1539
1540 /**
1541 * The MIME type of {@link #CONTENT_URI} providing a directory of data.
1542 */
1543 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
1544
1545 /**
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001546 * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
1547 */
1548 public static final String CONTENT_ITEM_TYPE =
1549 "vnd.android.cursor.item/aggregation_exception";
1550
1551 /**
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07001552 * The type of exception: {@link #TYPE_KEEP_IN}, {@link #TYPE_KEEP_OUT} or
1553 * {@link #TYPE_AUTOMATIC}.
Fred Quintana435e4272009-06-04 17:30:28 -07001554 *
1555 * <P>Type: INTEGER</P>
1556 */
1557 public static final String TYPE = "type";
1558
Fred Quintana435e4272009-06-04 17:30:28 -07001559 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001560 * Allows the provider to automatically decide whether the aggregate
1561 * contact should include a particular raw contact or not.
Fred Quintana435e4272009-06-04 17:30:28 -07001562 */
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07001563 public static final int TYPE_AUTOMATIC = 0;
Fred Quintana435e4272009-06-04 17:30:28 -07001564
1565 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001566 * Makes sure that the specified raw contact is included in the
1567 * specified aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07001568 */
1569 public static final int TYPE_KEEP_IN = 1;
1570
1571 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001572 * Makes sure that the specified raw contact is NOT included in the
1573 * specified aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07001574 */
1575 public static final int TYPE_KEEP_OUT = 2;
1576
1577 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001578 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} of the
1579 * aggregate contact that the rule applies to.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07001580 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001581 public static final String CONTACT_ID = "contact_id";
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07001582
1583 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001584 * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
Fred Quintana435e4272009-06-04 17:30:28 -07001585 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07001586 public static final String RAW_CONTACT_ID = "raw_contact_id";
Fred Quintana435e4272009-06-04 17:30:28 -07001587 }
Jeff Sharkey28b68e52009-06-10 15:26:58 -07001588
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07001589 private interface SettingsColumns {
1590 /**
1591 * The name of the account instance to which this row belongs.
1592 * <P>Type: TEXT</P>
1593 */
1594 public static final String ACCOUNT_NAME = "account_name";
1595
1596 /**
1597 * The type of account to which this row belongs, which when paired with
1598 * {@link #ACCOUNT_NAME} identifies a specific account.
1599 * <P>Type: TEXT</P>
1600 */
1601 public static final String ACCOUNT_TYPE = "account_type";
1602
1603 /**
1604 * Setting to indicate how this source handles {@link #SHOULD_SYNC} and
1605 * {@link Groups#SHOULD_SYNC} flags. This mode should be one of
1606 * {@link Settings#SYNC_MODE_EVERYTHING},
1607 * {@link Settings#SYNC_MODE_UNGROUPED}, or
1608 * {@link Settings#SYNC_MODE_UNSUPPORTED}.
1609 * <p>
1610 * Type: INTEGER
1611 */
1612 public static final String SHOULD_SYNC_MODE = "should_sync_mode";
1613
1614 /**
1615 * When modes is {@link Settings#SYNC_MODE_EVERYTHING}, this flag
1616 * overrides any children {@link Groups#SHOULD_SYNC} when set. When mode
1617 * is {@link Settings#SYNC_MODE_UNGROUPED}, this flag indicates the
1618 * syncing behavior for contacts not belonging to any group.
1619 * <p>
1620 * Type: INTEGER (boolean)
1621 */
1622 public static final String SHOULD_SYNC = "should_sync";
1623
1624 /**
Jeff Sharkeya6597442009-08-19 09:23:33 -07001625 * Flag indicating if contacts without any {@link GroupMembership}
1626 * entries should be visible in any user interface.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07001627 * <p>
1628 * Type: INTEGER (boolean)
1629 */
1630 public static final String UNGROUPED_VISIBLE = "ungrouped_visible";
1631 }
1632
1633 /**
1634 * Contacts-specific settings for various {@link Account}.
1635 */
1636 public static final class Settings implements BaseColumns, SettingsColumns {
1637 /**
1638 * This utility class cannot be instantiated
1639 */
1640 private Settings() {
1641 }
1642
1643 /**
1644 * The content:// style URI for this table
1645 */
1646 public static final Uri CONTENT_URI =
1647 Uri.withAppendedPath(AUTHORITY_URI, "settings");
1648
1649 /**
1650 * The MIME-type of {@link #CONTENT_URI} providing a directory of
1651 * settings.
1652 */
1653 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting";
1654
1655 /**
1656 * The MIME-type of {@link #CONTENT_URI} providing a single setting.
1657 */
1658 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
1659
1660 /**
1661 * Mode for {@link #SHOULD_SYNC_MODE} that indicates this data source
1662 * doesn't support per-group {@link Groups#SHOULD_SYNC} flags.
1663 */
1664 public static final int SYNC_MODE_UNSUPPORTED = 0;
1665
1666 /**
1667 * Mode for {@link #SHOULD_SYNC_MODE} that indicates this data source
1668 * fully supports per-group {@link Groups#SHOULD_SYNC} flags and assumes
1669 * that {@link #SHOULD_SYNC} refers to contacts without any
1670 * {@link GroupMembership}.
1671 */
1672 public static final int SYNC_MODE_UNGROUPED = 1;
1673
1674 /**
1675 * Mode for {@link #SHOULD_SYNC_MODE} that indicates this data source
1676 * fully supports per-group {@link Groups#SHOULD_SYNC} flags but assumes
1677 * that {@link #SHOULD_SYNC} overrides per-group flags when set.
1678 */
1679 public static final int SYNC_MODE_EVERYTHING = 2;
1680 }
1681
Evan Millardc2da5f2009-06-18 16:07:13 -07001682 /**
1683 * Contains helper classes used to create or manage {@link android.content.Intent Intents}
1684 * that involve contacts.
1685 */
1686 public static final class Intents {
1687 /**
1688 * This is the intent that is fired when a search suggestion is clicked on.
1689 */
1690 public static final String SEARCH_SUGGESTION_CLICKED =
1691 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
1692
1693 /**
1694 * This is the intent that is fired when a search suggestion for dialing a number
1695 * is clicked on.
1696 */
1697 public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
1698 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
1699
1700 /**
1701 * This is the intent that is fired when a search suggestion for creating a contact
1702 * is clicked on.
1703 */
1704 public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
1705 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
1706
1707 /**
1708 * Starts an Activity that lets the user pick a contact to attach an image to.
1709 * After picking the contact it launches the image cropper in face detection mode.
1710 */
1711 public static final String ATTACH_IMAGE =
1712 "com.android.contacts.action.ATTACH_IMAGE";
1713
1714 /**
1715 * Takes as input a data URI with a mailto: or tel: scheme. If a single
1716 * contact exists with the given data it will be shown. If no contact
1717 * exists, a dialog will ask the user if they want to create a new
1718 * contact with the provided details filled in. If multiple contacts
1719 * share the data the user will be prompted to pick which contact they
1720 * want to view.
1721 * <p>
1722 * For <code>mailto:</code> URIs, the scheme specific portion must be a
1723 * raw email address, such as one built using
1724 * {@link Uri#fromParts(String, String, String)}.
1725 * <p>
1726 * For <code>tel:</code> URIs, the scheme specific portion is compared
1727 * to existing numbers using the standard caller ID lookup algorithm.
1728 * The number must be properly encoded, for example using
1729 * {@link Uri#fromParts(String, String, String)}.
1730 * <p>
1731 * Any extras from the {@link Insert} class will be passed along to the
1732 * create activity if there are no contacts to show.
1733 * <p>
1734 * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
1735 * prompting the user when the contact doesn't exist.
1736 */
1737 public static final String SHOW_OR_CREATE_CONTACT =
1738 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
1739
1740 /**
1741 * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
1742 * contact if no matching contact found. Otherwise, default behavior is
1743 * to prompt user with dialog before creating.
1744 * <p>
1745 * Type: BOOLEAN
1746 */
1747 public static final String EXTRA_FORCE_CREATE =
1748 "com.android.contacts.action.FORCE_CREATE";
1749
1750 /**
1751 * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
1752 * description to be shown when prompting user about creating a new
1753 * contact.
1754 * <p>
1755 * Type: STRING
1756 */
1757 public static final String EXTRA_CREATE_DESCRIPTION =
1758 "com.android.contacts.action.CREATE_DESCRIPTION";
1759
1760 /**
Jeff Sharkey11322002009-06-04 17:25:51 -07001761 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
1762 * dialog location using screen coordinates. When not specified, the
1763 * dialog will be centered.
1764 */
1765 public static final String EXTRA_TARGET_RECT = "target_rect";
1766
1767 /**
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07001768 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
1769 * desired dialog style, usually a variation on size. One of
1770 * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
1771 */
1772 public static final String EXTRA_MODE = "mode";
1773
1774 /**
1775 * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
1776 */
1777 public static final int MODE_SMALL = 1;
1778
1779 /**
1780 * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
1781 */
1782 public static final int MODE_MEDIUM = 2;
1783
1784 /**
1785 * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
1786 */
1787 public static final int MODE_LARGE = 3;
1788
1789 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07001790 * Intents related to the Contacts app UI.
1791 */
1792 public static final class UI {
1793 /**
1794 * The action for the default contacts list tab.
1795 */
1796 public static final String LIST_DEFAULT =
1797 "com.android.contacts.action.LIST_DEFAULT";
1798
1799 /**
1800 * The action for the contacts list tab.
1801 */
1802 public static final String LIST_GROUP_ACTION =
1803 "com.android.contacts.action.LIST_GROUP";
1804
1805 /**
1806 * When in LIST_GROUP_ACTION mode, this is the group to display.
1807 */
1808 public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP";
1809
1810 /**
1811 * The action for the all contacts list tab.
1812 */
1813 public static final String LIST_ALL_CONTACTS_ACTION =
1814 "com.android.contacts.action.LIST_ALL_CONTACTS";
1815
1816 /**
1817 * The action for the contacts with phone numbers list tab.
1818 */
1819 public static final String LIST_CONTACTS_WITH_PHONES_ACTION =
1820 "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES";
1821
1822 /**
1823 * The action for the starred contacts list tab.
1824 */
1825 public static final String LIST_STARRED_ACTION =
1826 "com.android.contacts.action.LIST_STARRED";
1827
1828 /**
1829 * The action for the frequent contacts list tab.
1830 */
1831 public static final String LIST_FREQUENT_ACTION =
1832 "com.android.contacts.action.LIST_FREQUENT";
1833
1834 /**
1835 * The action for the "strequent" contacts list tab. It first lists the starred
1836 * contacts in alphabetical order and then the frequent contacts in descending
1837 * order of the number of times they have been contacted.
1838 */
1839 public static final String LIST_STREQUENT_ACTION =
1840 "com.android.contacts.action.LIST_STREQUENT";
1841
1842 /**
1843 * A key for to be used as an intent extra to set the activity
1844 * title to a custom String value.
1845 */
1846 public static final String TITLE_EXTRA_KEY =
1847 "com.android.contacts.extra.TITLE_EXTRA";
1848
1849 /**
1850 * Activity Action: Display a filtered list of contacts
1851 * <p>
1852 * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for
1853 * filtering
1854 * <p>
1855 * Output: Nothing.
1856 */
1857 public static final String FILTER_CONTACTS_ACTION =
1858 "com.android.contacts.action.FILTER_CONTACTS";
1859
1860 /**
1861 * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION}
1862 * intents to supply the text on which to filter.
1863 */
1864 public static final String FILTER_TEXT_EXTRA_KEY =
1865 "com.android.contacts.extra.FILTER_TEXT";
1866 }
1867
1868 /**
1869 * Convenience class that contains string constants used
1870 * to create contact {@link android.content.Intent Intents}.
1871 */
1872 public static final class Insert {
1873 /** The action code to use when adding a contact */
1874 public static final String ACTION = Intent.ACTION_INSERT;
1875
1876 /**
1877 * If present, forces a bypass of quick insert mode.
1878 */
1879 public static final String FULL_MODE = "full_mode";
1880
1881 /**
1882 * The extra field for the contact name.
1883 * <P>Type: String</P>
1884 */
1885 public static final String NAME = "name";
1886
1887 // TODO add structured name values here.
1888
1889 /**
1890 * The extra field for the contact phonetic name.
1891 * <P>Type: String</P>
1892 */
1893 public static final String PHONETIC_NAME = "phonetic_name";
1894
1895 /**
1896 * The extra field for the contact company.
1897 * <P>Type: String</P>
1898 */
1899 public static final String COMPANY = "company";
1900
1901 /**
1902 * The extra field for the contact job title.
1903 * <P>Type: String</P>
1904 */
1905 public static final String JOB_TITLE = "job_title";
1906
1907 /**
1908 * The extra field for the contact notes.
1909 * <P>Type: String</P>
1910 */
1911 public static final String NOTES = "notes";
1912
1913 /**
1914 * The extra field for the contact phone number.
1915 * <P>Type: String</P>
1916 */
1917 public static final String PHONE = "phone";
1918
1919 /**
1920 * The extra field for the contact phone number type.
1921 * <P>Type: Either an integer value from
1922 * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
1923 * or a string specifying a custom label.</P>
1924 */
1925 public static final String PHONE_TYPE = "phone_type";
1926
1927 /**
1928 * The extra field for the phone isprimary flag.
1929 * <P>Type: boolean</P>
1930 */
1931 public static final String PHONE_ISPRIMARY = "phone_isprimary";
1932
1933 /**
1934 * The extra field for an optional second contact phone number.
1935 * <P>Type: String</P>
1936 */
1937 public static final String SECONDARY_PHONE = "secondary_phone";
1938
1939 /**
1940 * The extra field for an optional second contact phone number type.
1941 * <P>Type: Either an integer value from
1942 * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
1943 * or a string specifying a custom label.</P>
1944 */
1945 public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
1946
1947 /**
1948 * The extra field for an optional third contact phone number.
1949 * <P>Type: String</P>
1950 */
1951 public static final String TERTIARY_PHONE = "tertiary_phone";
1952
1953 /**
1954 * The extra field for an optional third contact phone number type.
1955 * <P>Type: Either an integer value from
1956 * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
1957 * or a string specifying a custom label.</P>
1958 */
1959 public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
1960
1961 /**
1962 * The extra field for the contact email address.
1963 * <P>Type: String</P>
1964 */
1965 public static final String EMAIL = "email";
1966
1967 /**
1968 * The extra field for the contact email type.
1969 * <P>Type: Either an integer value from
1970 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
1971 * or a string specifying a custom label.</P>
1972 */
1973 public static final String EMAIL_TYPE = "email_type";
1974
1975 /**
1976 * The extra field for the email isprimary flag.
1977 * <P>Type: boolean</P>
1978 */
1979 public static final String EMAIL_ISPRIMARY = "email_isprimary";
1980
1981 /**
1982 * The extra field for an optional second contact email address.
1983 * <P>Type: String</P>
1984 */
1985 public static final String SECONDARY_EMAIL = "secondary_email";
1986
1987 /**
1988 * The extra field for an optional second contact email type.
1989 * <P>Type: Either an integer value from
1990 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
1991 * or a string specifying a custom label.</P>
1992 */
1993 public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
1994
1995 /**
1996 * The extra field for an optional third contact email address.
1997 * <P>Type: String</P>
1998 */
1999 public static final String TERTIARY_EMAIL = "tertiary_email";
2000
2001 /**
2002 * The extra field for an optional third contact email type.
2003 * <P>Type: Either an integer value from
2004 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2005 * or a string specifying a custom label.</P>
2006 */
2007 public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
2008
2009 /**
2010 * The extra field for the contact postal address.
2011 * <P>Type: String</P>
2012 */
2013 public static final String POSTAL = "postal";
2014
2015 /**
2016 * The extra field for the contact postal address type.
2017 * <P>Type: Either an integer value from
2018 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2019 * or a string specifying a custom label.</P>
2020 */
2021 public static final String POSTAL_TYPE = "postal_type";
2022
2023 /**
2024 * The extra field for the postal isprimary flag.
2025 * <P>Type: boolean</P>
2026 */
2027 public static final String POSTAL_ISPRIMARY = "postal_isprimary";
2028
2029 /**
2030 * The extra field for an IM handle.
2031 * <P>Type: String</P>
2032 */
2033 public static final String IM_HANDLE = "im_handle";
2034
2035 /**
2036 * The extra field for the IM protocol
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002037 * <P>Type: the result of {@link CommonDataKinds.Im#encodePredefinedImProtocol(int)}
2038 * or {@link CommonDataKinds.Im#encodeCustomImProtocol(String)}.</P>
Evan Millardc2da5f2009-06-18 16:07:13 -07002039 */
2040 public static final String IM_PROTOCOL = "im_protocol";
2041
2042 /**
2043 * The extra field for the IM isprimary flag.
2044 * <P>Type: boolean</P>
2045 */
2046 public static final String IM_ISPRIMARY = "im_isprimary";
2047 }
2048 }
2049
Evan Millar088b2912009-05-28 15:24:37 -07002050}