blob: 2e4bbab2ade0ad2030882009b82e1bed25d0dfdd [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;
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -070023import android.content.ContentUris;
Jeff Hamilton85abdc52009-09-22 12:41:45 -050024import android.content.ContentValues;
Dmitri Plotnikov93032952009-08-19 11:26:57 -070025import android.content.Context;
Jeff Sharkey7b6771a2009-08-17 01:59:54 -070026import android.content.Intent;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -070027import android.content.res.Resources;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070028import android.database.Cursor;
Jeff Sharkey6449eb02009-09-16 21:41:51 -070029import android.graphics.Rect;
Evan Millar088b2912009-05-28 15:24:37 -070030import android.net.Uri;
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070031import android.os.RemoteException;
Dmitri Plotnikov93032952009-08-19 11:26:57 -070032import android.text.TextUtils;
Fred Quintanac4516a72009-09-03 12:14:06 -070033import android.util.Pair;
Jeff Sharkey6449eb02009-09-16 21:41:51 -070034import android.view.View;
Evan Millar088b2912009-05-28 15:24:37 -070035
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070036import java.io.ByteArrayInputStream;
37import java.io.InputStream;
38
Evan Millar088b2912009-05-28 15:24:37 -070039/**
40 * The contract between the contacts provider and applications. Contains definitions
Jeff Hamilton85abdc52009-09-22 12:41:45 -050041 * for the supported URIs and columns. These APIs supersede {@link Contacts}.
Evan Millar088b2912009-05-28 15:24:37 -070042 */
Jeff Hamilton0c232122009-09-24 00:26:50 -050043@SuppressWarnings("unused")
Evan Millar088b2912009-05-28 15:24:37 -070044public final class ContactsContract {
45 /** The authority for the contacts provider */
46 public static final String AUTHORITY = "com.android.contacts";
47 /** A content:// style uri to the authority for the contacts provider */
48 public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
49
Fred Quintana33f889a2009-09-14 17:31:26 -070050 /**
51 * An optional insert, update or delete URI parameter that allows the caller
52 * to specify that it is a sync adapter. The default value is false. If true
53 * the dirty flag is not automatically set and the "syncToNetwork" parameter
54 * is set to false when calling
55 * {@link ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}.
56 */
57 public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
58
Jeff Hamilton85abdc52009-09-22 12:41:45 -050059 /**
Evan Millar49da15f2009-09-29 12:02:56 -070060 * A query parameter key used to specify the package that is requesting a query.
61 * This is used for restricting data based on package name.
62 *
63 * @hide
64 */
65 public static final String REQUESTING_PACKAGE_PARAM_KEY = "requesting_package";
66
67 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -050068 * @hide should be removed when users are updated to refer to SyncState
69 * @deprecated use SyncState instead
70 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -070071 @Deprecated
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070072 public interface SyncStateColumns extends SyncStateContract.Columns {
73 }
74
Jeff Hamilton85abdc52009-09-22 12:41:45 -050075 /**
76 * A table provided for sync adapters to use for storing private sync state data.
77 *
78 * @see SyncStateContract
79 */
80 public static final class SyncState implements SyncStateContract.Columns {
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070081 /**
82 * This utility class cannot be instantiated
83 */
84 private SyncState() {}
85
86 public static final String CONTENT_DIRECTORY =
87 SyncStateContract.Constants.CONTENT_DIRECTORY;
88
89 /**
90 * The content:// style URI for this table
91 */
92 public static final Uri CONTENT_URI =
93 Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY);
94
95 /**
96 * @see android.provider.SyncStateContract.Helpers#get
97 */
98 public static byte[] get(ContentProviderClient provider, Account account)
99 throws RemoteException {
100 return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
101 }
102
103 /**
Fred Quintanac4516a72009-09-03 12:14:06 -0700104 * @see android.provider.SyncStateContract.Helpers#get
105 */
106 public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
107 throws RemoteException {
108 return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
109 }
110
111 /**
Fred Quintana0f4e1ab2009-07-09 17:20:59 -0700112 * @see android.provider.SyncStateContract.Helpers#set
113 */
114 public static void set(ContentProviderClient provider, Account account, byte[] data)
115 throws RemoteException {
116 SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
117 }
118
119 /**
120 * @see android.provider.SyncStateContract.Helpers#newSetOperation
121 */
122 public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
123 return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
124 }
125 }
126
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700127 /**
128 * Generic columns for use by sync adapters. The specific functions of
129 * these columns are private to the sync adapter. Other clients of the API
130 * should not attempt to either read or write this column.
131 */
132 private interface BaseSyncColumns {
133
134 /** Generic column for use by sync adapters. */
135 public static final String SYNC1 = "sync1";
136 /** Generic column for use by sync adapters. */
137 public static final String SYNC2 = "sync2";
138 /** Generic column for use by sync adapters. */
139 public static final String SYNC3 = "sync3";
140 /** Generic column for use by sync adapters. */
141 public static final String SYNC4 = "sync4";
142 }
143
144 /**
145 * Columns that appear when each row of a table belongs to a specific
146 * account, including sync information that an account may need.
147 */
148 private interface SyncColumns extends BaseSyncColumns {
149 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500150 * The name of the account instance to which this row belongs, which when paired with
151 * {@link #ACCOUNT_TYPE} identifies a specific account.
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700152 * <P>Type: TEXT</P>
153 */
154 public static final String ACCOUNT_NAME = "account_name";
155
156 /**
157 * The type of account to which this row belongs, which when paired with
158 * {@link #ACCOUNT_NAME} identifies a specific account.
159 * <P>Type: TEXT</P>
160 */
161 public static final String ACCOUNT_TYPE = "account_type";
162
163 /**
164 * String that uniquely identifies this row to its source account.
165 * <P>Type: TEXT</P>
166 */
167 public static final String SOURCE_ID = "sourceid";
168
169 /**
170 * Version number that is updated whenever this row or its related data
171 * changes.
172 * <P>Type: INTEGER</P>
173 */
174 public static final String VERSION = "version";
175
176 /**
177 * Flag indicating that {@link #VERSION} has changed, and this row needs
178 * to be synchronized by its owning account.
179 * <P>Type: INTEGER (boolean)</P>
180 */
181 public static final String DIRTY = "dirty";
182 }
183
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500184 private interface ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700185 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500186 * The number of times a contact has been contacted
Evan Millar088b2912009-05-28 15:24:37 -0700187 * <P>Type: INTEGER</P>
188 */
189 public static final String TIMES_CONTACTED = "times_contacted";
190
191 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500192 * The last time a contact was contacted.
Evan Millar088b2912009-05-28 15:24:37 -0700193 * <P>Type: INTEGER</P>
194 */
195 public static final String LAST_TIME_CONTACTED = "last_time_contacted";
196
197 /**
198 * Is the contact starred?
199 * <P>Type: INTEGER (boolean)</P>
200 */
201 public static final String STARRED = "starred";
202
203 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500204 * A custom ringtone associated with a contact. Not always present.
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700205 * <P>Type: TEXT (URI to the ringtone)</P>
206 */
207 public static final String CUSTOM_RINGTONE = "custom_ringtone";
208
209 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500210 * Whether the contact should always be sent to voicemail. Not always
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700211 * present.
212 * <P>Type: INTEGER (0 for false, 1 for true)</P>
213 */
214 public static final String SEND_TO_VOICEMAIL = "send_to_voicemail";
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700215 }
216
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700217 private interface ContactsColumns {
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700218 /**
219 * The display name for the contact.
220 * <P>Type: TEXT</P>
221 */
222 public static final String DISPLAY_NAME = "display_name";
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700223
224 /**
Evan Millar088b2912009-05-28 15:24:37 -0700225 * Reference to the row in the data table holding the photo.
226 * <P>Type: INTEGER REFERENCES data(_id)</P>
227 */
228 public static final String PHOTO_ID = "photo_id";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -0700229
230 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700231 * Lookup value that reflects the {@link Groups#GROUP_VISIBLE} state of
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -0700232 * any {@link CommonDataKinds.GroupMembership} for this contact.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -0700233 */
234 public static final String IN_VISIBLE_GROUP = "in_visible_group";
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700235
236 /**
Dmitri Plotnikov074fbfe2009-08-11 13:50:21 -0700237 * An indicator of whether this contact has at least one phone number. "1" if there is
238 * at least one phone number, "0" otherwise.
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700239 * <P>Type: INTEGER</P>
240 */
Dmitri Plotnikov074fbfe2009-08-11 13:50:21 -0700241 public static final String HAS_PHONE_NUMBER = "has_phone_number";
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700242
243 /**
244 * An opaque value that contains hints on how to find the contact if
245 * its row id changed as a result of a sync or aggregation.
246 */
247 public static final String LOOKUP_KEY = "lookup";
Evan Millar088b2912009-05-28 15:24:37 -0700248 }
249
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700250 private interface ContactStatusColumns {
251 /**
252 * Contact presence status. See {@link StatusUpdates} for individual status
253 * definitions.
254 * <p>Type: NUMBER</p>
255 */
256 public static final String CONTACT_PRESENCE = "contact_presence";
257
258 /**
259 * Contact's latest status update.
260 * <p>Type: TEXT</p>
261 */
262 public static final String CONTACT_STATUS = "contact_status";
263
264 /**
265 * The absolute time in milliseconds when the latest status was
266 * inserted/updated.
267 * <p>Type: NUMBER</p>
268 */
269 public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts";
270
271 /**
272 * The package containing resources for this status: label and icon.
273 * <p>Type: NUMBER</p>
274 */
275 public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package";
276
277 /**
278 * The resource ID of the label describing the source of contact
279 * status, e.g. "Google Talk". This resource is scoped by the
280 * {@link #CONTACT_STATUS_RES_PACKAGE}.
281 * <p>Type: NUMBER</p>
282 */
283 public static final String CONTACT_STATUS_LABEL = "contact_status_label";
284
285 /**
286 * The resource ID of the icon for the source of contact status. This
287 * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.
288 * <p>Type: NUMBER</p>
289 */
290 public static final String CONTACT_STATUS_ICON = "contact_status_icon";
291 }
292
Evan Millar088b2912009-05-28 15:24:37 -0700293 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700294 * Constants for the contacts table, which contains a record per group
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500295 * of raw contacts representing the same person.
Evan Millar088b2912009-05-28 15:24:37 -0700296 */
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700297 public static class Contacts implements BaseColumns, ContactsColumns,
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700298 ContactOptionsColumns, ContactStatusColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700299 /**
300 * This utility class cannot be instantiated
301 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700302 private Contacts() {}
Evan Millar088b2912009-05-28 15:24:37 -0700303
304 /**
305 * The content:// style URI for this table
306 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700307 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
Evan Millar088b2912009-05-28 15:24:37 -0700308
309 /**
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700310 * A content:// style URI for this table that should be used to create
311 * shortcuts or otherwise create long-term links to contacts. This URI
312 * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}.
313 * It can optionally also have a "/" and last known contact ID appended after
314 * that. This "complete" format is an important optimization and is highly recommended.
315 * <p>
316 * As long as the contact's row ID remains the same, this URI is
317 * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes
318 * as a result of a sync or aggregation, this URI will look up the
319 * contact using indirect information (sync IDs or constituent raw
320 * contacts).
321 * <p>
322 * Lookup key should be appended unencoded - it is stored in the encoded
323 * form, ready for use in a URI.
324 */
325 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
326 "lookup");
327
328 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -0700329 * Base {@link Uri} for referencing a single {@link Contacts} entry,
Jeff Sharkey8f767342009-09-28 18:22:46 -0700330 * created by appending {@link #LOOKUP_KEY} using
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -0700331 * {@link Uri#withAppendedPath(Uri, String)}. Provides
332 * {@link OpenableColumns} columns when queried, or returns the
333 * referenced contact formatted as a vCard when opened through
334 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
335 */
336 public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
337 "as_vcard");
338
339 /**
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700340 * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the
341 * requested {@link Contacts} entry.
342 *
343 * @param contactUri A {@link #CONTENT_URI} row, or an existing
344 * {@link #CONTENT_LOOKUP_URI} to attempt refreshing.
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700345 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700346 public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) {
347 final Cursor c = resolver.query(contactUri, new String[] {
348 Contacts.LOOKUP_KEY, Contacts._ID
349 }, null, null, null);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700350 if (c == null) {
351 return null;
352 }
353
354 try {
355 if (c.moveToFirst()) {
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700356 final String lookupKey = c.getString(0);
357 final long contactId = c.getLong(1);
358 return getLookupUri(contactId, lookupKey);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700359 }
360 } finally {
361 c.close();
362 }
363 return null;
364 }
365
366 /**
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -0700367 * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the
Jeff Hamiltonf8526982009-09-24 11:34:58 -0500368 * given {@link android.provider.ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}.
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -0700369 */
370 public static Uri getLookupUri(long contactId, String lookupKey) {
371 return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI,
372 lookupKey), contactId);
373 }
374
375 /**
Dmitri Plotnikovb5759b52009-09-01 15:58:40 -0700376 * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI.
377 * <p>
378 * Returns null if the contact cannot be found.
379 */
380 public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) {
381 if (lookupUri == null) {
382 return null;
383 }
384
385 Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null);
386 if (c == null) {
387 return null;
388 }
389
390 try {
391 if (c.moveToFirst()) {
392 long contactId = c.getLong(0);
393 return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
394 }
395 } finally {
396 c.close();
397 }
398 return null;
399 }
400
401 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500402 * Mark a contact as having been contacted.
403 *
404 * @param resolver the ContentResolver to use
405 * @param contactId the person who was contacted
406 */
407 public static void markAsContacted(ContentResolver resolver, long contactId) {
408 Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId);
409 ContentValues values = new ContentValues();
410 // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified.
411 values.put(LAST_TIME_CONTACTED, System.currentTimeMillis());
412 resolver.update(uri, values, null, null);
413 }
414
415 /**
Evan Millar161dd862009-06-12 16:02:43 -0700416 * The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700417 * {@link #CONTENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700418 * various parts of the contact name. The filter argument should be passed
Evan Millar161dd862009-06-12 16:02:43 -0700419 * as an additional path segment after this URI.
420 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700421 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
422 CONTENT_URI, "filter");
423
Evan Millardc2da5f2009-06-18 16:07:13 -0700424 /**
425 * The content:// style URI for this table joined with useful data from
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700426 * {@link Data}, filtered to include only starred contacts
427 * and the most frequently contacted contacts.
Evan Millardc2da5f2009-06-18 16:07:13 -0700428 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700429 public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath(
430 CONTENT_URI, "strequent");
431
Evan Millardc2da5f2009-06-18 16:07:13 -0700432 /**
433 * The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700434 * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700435 * various parts of the contact name. The filter argument should be passed
Evan Millardc2da5f2009-06-18 16:07:13 -0700436 * as an additional path segment after this URI.
437 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700438 public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath(
439 CONTENT_STREQUENT_URI, "filter");
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700440
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700441 public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath(
442 CONTENT_URI, "group");
443
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700444 /**
Evan Millar088b2912009-05-28 15:24:37 -0700445 * The MIME type of {@link #CONTENT_URI} providing a directory of
446 * people.
447 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700448 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
Evan Millar088b2912009-05-28 15:24:37 -0700449
450 /**
451 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
452 * person.
453 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700454 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
Evan Millar088b2912009-05-28 15:24:37 -0700455
456 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -0700457 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
458 * person.
459 */
460 public static final String CONTENT_VCARD_TYPE = "text/x-vcard";
461
462 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700463 * A sub-directory of a single contact that contains all of the constituent raw contact
Evan Millar088b2912009-05-28 15:24:37 -0700464 * {@link Data} rows.
465 */
Fred Quintana8851e162009-08-05 21:06:45 -0700466 public static final class Data implements BaseColumns, DataColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700467 /**
468 * no public constructor since this is a utility class
469 */
470 private Data() {}
471
472 /**
473 * The directory twig for this sub-table
474 */
475 public static final String CONTENT_DIRECTORY = "data";
476 }
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700477
478 /**
479 * A sub-directory of a single contact aggregate that contains all aggregation suggestions
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700480 * (other contacts). The aggregation suggestions are computed based on approximate
481 * data matches with this contact.
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700482 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700483 public static final class AggregationSuggestions implements BaseColumns, ContactsColumns {
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700484 /**
485 * No public constructor since this is a utility class
486 */
487 private AggregationSuggestions() {}
488
489 /**
Dmitri Plotnikov0fc02442009-09-21 13:26:28 -0700490 * The directory twig for this sub-table. The URI can be followed by an optional
Jeff Hamiltonf8526982009-09-24 11:34:58 -0500491 * type-to-filter, similar to
492 * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}.
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700493 */
494 public static final String CONTENT_DIRECTORY = "suggestions";
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700495 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700496
497 /**
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -0700498 * A sub-directory of a single contact that contains the contact's primary photo.
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700499 */
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -0700500 public static final class Photo implements BaseColumns, DataColumns {
501 /**
502 * no public constructor since this is a utility class
503 */
504 private Photo() {}
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -0700505
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -0700506 /**
507 * The directory twig for this sub-table
508 */
509 public static final String CONTENT_DIRECTORY = "photo";
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700510 }
511
512 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500513 * Opens an InputStream for the contacts's default photo and returns the
514 * photo as a byte stream. If there is not photo null will be returned.
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700515 *
516 * @param contactUri the contact whose photo should be used
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500517 * @return an InputStream of the photo, or null if no photo is present
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700518 */
519 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -0700520 Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY);
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -0700521 if (photoUri == null) {
522 return null;
523 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700524 Cursor cursor = cr.query(photoUri,
525 new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null);
526 try {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -0700527 if (cursor == null || !cursor.moveToNext()) {
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700528 return null;
529 }
530 byte[] data = cursor.getBlob(0);
531 if (data == null) {
532 return null;
533 }
534 return new ByteArrayInputStream(data);
535 } finally {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -0700536 if (cursor != null) {
537 cursor.close();
538 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700539 }
540 }
Evan Millar088b2912009-05-28 15:24:37 -0700541 }
542
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -0700543 private interface RawContactsColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700544 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700545 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} that this
546 * data belongs to.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700547 * <P>Type: INTEGER</P>
Evan Millar088b2912009-05-28 15:24:37 -0700548 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700549 public static final String CONTACT_ID = "contact_id";
Evan Millar088b2912009-05-28 15:24:37 -0700550
551 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500552 * Flag indicating that this {@link RawContacts} entry and its children have
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700553 * been restricted to specific platform apps.
554 * <P>Type: INTEGER (boolean)</P>
555 *
556 * @hide until finalized in future platform release
557 */
558 public static final String IS_RESTRICTED = "is_restricted";
559
560 /**
561 * The aggregation mode for this contact.
562 * <P>Type: INTEGER</P>
563 */
564 public static final String AGGREGATION_MODE = "aggregation_mode";
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -0700565
566 /**
567 * The "deleted" flag: "0" by default, "1" if the row has been marked
568 * for deletion. When {@link android.content.ContentResolver#delete} is
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700569 * called on a raw contact, it is marked for deletion and removed from its
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700570 * aggregate contact. The sync adaptor deletes the raw contact on the server and
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -0700571 * then calls ContactResolver.delete once more, this time passing the
Fred Quintana33f889a2009-09-14 17:31:26 -0700572 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
573 * the data removal.
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -0700574 * <P>Type: INTEGER</P>
575 */
576 public static final String DELETED = "deleted";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700577 }
578
579 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500580 * Constants for the raw contacts table, which contains the base contact
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -0700581 * information per sync source. Sync adapters and contact management apps
582 * are the primary consumers of this API.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700583 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700584 public static final class RawContacts implements BaseColumns, RawContactsColumns,
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700585 ContactOptionsColumns, SyncColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700586 /**
587 * This utility class cannot be instantiated
588 */
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -0700589 private RawContacts() {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700590 }
591
592 /**
Evan Millar088b2912009-05-28 15:24:37 -0700593 * The content:// style URI for this table
594 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700595 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
Evan Millar088b2912009-05-28 15:24:37 -0700596
597 /**
Evan Millar088b2912009-05-28 15:24:37 -0700598 * The MIME type of {@link #CONTENT_URI} providing a directory of
599 * people.
600 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700601 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -0700602
603 /**
604 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
605 * person.
606 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700607 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -0700608
609 /**
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700610 * Aggregation mode: aggregate asynchronously.
611 */
612 public static final int AGGREGATION_MODE_DEFAULT = 0;
613
614 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700615 * Aggregation mode: aggregate at the time the raw contact is inserted/updated.
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700616 */
Omari Stephensbc9aa772009-09-08 19:10:53 -0700617 public static final int AGGREGATION_MODE_IMMEDIATE = 1;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700618
619 /**
Dmitri Plotnikov5223b162009-08-25 15:15:06 -0700620 * If {@link #AGGREGATION_MODE} is {@link #AGGREGATION_MODE_SUSPENDED}, changes
621 * to the raw contact do not cause its aggregation to be revisited. Note that changing
622 * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to
623 * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass. Any subsequent
624 * change to the raw contact's data will.
625 */
626 public static final int AGGREGATION_MODE_SUSPENDED = 2;
627
628 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700629 * Aggregation mode: never aggregate this raw contact (note that the raw contact will not
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700630 * have a corresponding Aggregate and therefore will not be included in Aggregates
631 * query results.)
632 */
Dmitri Plotnikov5223b162009-08-25 15:15:06 -0700633 public static final int AGGREGATION_MODE_DISABLED = 3;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700634
635 /**
Jeff Hamiltonf8526982009-09-24 11:34:58 -0500636 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
637 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
638 * entry of the given {@link RawContacts} entry.
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700639 */
640 public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) {
641 // TODO: use a lighter query by joining rawcontacts with contacts in provider
642 final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY);
643 final Cursor cursor = resolver.query(dataUri, new String[] {
644 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
645 }, null, null, null);
646
647 Uri lookupUri = null;
648 try {
649 if (cursor != null && cursor.moveToFirst()) {
650 final long contactId = cursor.getLong(0);
651 final String lookupKey = cursor.getString(1);
652 return Contacts.getLookupUri(contactId, lookupKey);
653 }
654 } finally {
655 if (cursor != null) cursor.close();
656 }
657 return lookupUri;
658 }
659
660 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700661 * A sub-directory of a single raw contact that contains all of their {@link Data} rows.
Dmitri Plotnikov5223b162009-08-25 15:15:06 -0700662 * To access this directory append {@link Data#CONTENT_DIRECTORY} to the contact URI.
Evan Millar088b2912009-05-28 15:24:37 -0700663 */
664 public static final class Data implements BaseColumns, DataColumns {
665 /**
666 * no public constructor since this is a utility class
667 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700668 private Data() {
669 }
Evan Millar088b2912009-05-28 15:24:37 -0700670
671 /**
672 * The directory twig for this sub-table
673 */
674 public static final String CONTENT_DIRECTORY = "data";
675 }
676 }
677
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700678 private interface StatusColumns extends Im.CommonPresenceColumns {
679 /**
Dmitri Plotnikova60479d2009-09-27 20:16:31 -0700680 * Contact's latest presence level.
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700681 * <P>Type: INTEGER (one of the values below)</P>
682 */
683 public static final String PRESENCE = PRESENCE_STATUS;
684
685 /**
686 * Contact latest status update.
687 * <p>Type: TEXT</p>
688 */
689 public static final String STATUS = PRESENCE_CUSTOM_STATUS;
690
691 /**
692 * The absolute time in milliseconds when the latest status was inserted/updated.
693 * <p>Type: NUMBER</p>
694 */
695 public static final String STATUS_TIMESTAMP = "status_ts";
696
697 /**
698 * The package containing resources for this status: label and icon.
699 * <p>Type: NUMBER</p>
700 */
701 public static final String STATUS_RES_PACKAGE = "status_res_package";
702
703 /**
704 * The resource ID of the label describing the source of the status update, e.g. "Google
705 * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
706 * <p>Type: NUMBER</p>
707 */
708 public static final String STATUS_LABEL = "status_label";
709
710 /**
711 * The resource ID of the icon for the source of the status update.
712 * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
713 * <p>Type: NUMBER</p>
714 */
715 public static final String STATUS_ICON = "status_icon";
716 }
717
Evan Millar088b2912009-05-28 15:24:37 -0700718 private interface DataColumns {
719 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700720 * The package name to use when creating {@link Resources} objects for
721 * this data row. This value is only designed for use when building user
722 * interfaces, and should not be used to infer the owner.
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500723 *
724 * @hide
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700725 */
726 public static final String RES_PACKAGE = "res_package";
727
728 /**
729 * The MIME type of the item represented by this row.
Evan Millar088b2912009-05-28 15:24:37 -0700730 */
731 public static final String MIMETYPE = "mimetype";
732
733 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700734 * A reference to the {@link RawContacts#_ID}
Dmitri Plotnikov56927772009-05-28 17:23:39 -0700735 * that this data belongs to.
Evan Millar088b2912009-05-28 15:24:37 -0700736 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700737 public static final String RAW_CONTACT_ID = "raw_contact_id";
738
Evan Millarab5742d2009-06-02 16:21:45 -0700739 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700740 * Whether this is the primary entry of its kind for the raw contact it belongs to
Evan Millarab5742d2009-06-02 16:21:45 -0700741 * <P>Type: INTEGER (if set, non-0 means true)</P>
742 */
743 public static final String IS_PRIMARY = "is_primary";
744
745 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700746 * Whether this is the primary entry of its kind for the aggregate
747 * contact it belongs to. Any data record that is "super primary" must
748 * also be "primary".
Evan Millarab5742d2009-06-02 16:21:45 -0700749 * <P>Type: INTEGER (if set, non-0 means true)</P>
750 */
751 public static final String IS_SUPER_PRIMARY = "is_super_primary";
752
Jeff Sharkey28b68e52009-06-10 15:26:58 -0700753 /**
Fred Quintanac933fb62009-06-11 12:14:40 -0700754 * The version of this data record. This is a read-only value. The data column is
755 * guaranteed to not change without the version going up. This value is monotonically
756 * increasing.
757 * <P>Type: INTEGER</P>
758 */
759 public static final String DATA_VERSION = "data_version";
760
Evan Millar088b2912009-05-28 15:24:37 -0700761 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
762 public static final String DATA1 = "data1";
763 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
764 public static final String DATA2 = "data2";
765 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
766 public static final String DATA3 = "data3";
767 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
768 public static final String DATA4 = "data4";
769 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
770 public static final String DATA5 = "data5";
771 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
772 public static final String DATA6 = "data6";
773 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
774 public static final String DATA7 = "data7";
775 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
776 public static final String DATA8 = "data8";
777 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
778 public static final String DATA9 = "data9";
779 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
780 public static final String DATA10 = "data10";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700781 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
782 public static final String DATA11 = "data11";
783 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
784 public static final String DATA12 = "data12";
785 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
786 public static final String DATA13 = "data13";
787 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
788 public static final String DATA14 = "data14";
789 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
790 public static final String DATA15 = "data15";
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700791
Fred Quintana8851e162009-08-05 21:06:45 -0700792 /** Generic column for use by sync adapters. */
793 public static final String SYNC1 = "data_sync1";
794 /** Generic column for use by sync adapters. */
795 public static final String SYNC2 = "data_sync2";
796 /** Generic column for use by sync adapters. */
797 public static final String SYNC3 = "data_sync3";
798 /** Generic column for use by sync adapters. */
799 public static final String SYNC4 = "data_sync4";
Evan Millar088b2912009-05-28 15:24:37 -0700800 }
801
802 /**
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -0700803 * Combines all columns returned by {@link Data} table queries.
804 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700805 private interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns,
806 RawContactsColumns, ContactsColumns, ContactOptionsColumns, ContactStatusColumns {
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -0700807
808 }
809
810 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700811 * Constants for the data table, which contains data points tied to a raw contact.
Evan Millar088b2912009-05-28 15:24:37 -0700812 * For example, a phone number or email address. Each row in this table contains a type
813 * definition and some generic columns. Each data type can define the meaning for each of
814 * the generic columns.
815 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -0700816 public final static class Data implements DataColumnsWithJoins {
Evan Millar088b2912009-05-28 15:24:37 -0700817 /**
818 * This utility class cannot be instantiated
819 */
820 private Data() {}
821
822 /**
823 * The content:// style URI for this table
824 */
825 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
826
827 /**
828 * The MIME type of {@link #CONTENT_URI} providing a directory of data.
829 */
830 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700831
832 /**
Daisuke Miyakawaf2e0d7b2009-09-28 06:28:26 -0700833 * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
834 * Data.CONTENT_URI contains only exportable data.
835 *
836 * This flag is useful (currently) only for vCard exporter in Contacts app, which
837 * needs to exclude "un-exportable" data from available data to export, while
838 * Contacts app itself has priviledge to access all data including "un-expotable"
839 * ones and providers return all of them regardless of the callers' intention.
840 * <P>Type: INTEGER</p>
841 *
842 * @hide Maybe available only in Eclair and not really ready for public use.
843 * TODO: remove, or implement this feature completely. As of now (Eclair),
844 * we only use this flag in queryEntities(), not query().
845 */
846 public static final String FOR_EXPORT_ONLY = "for_export_only";
847
848 /**
Jeff Hamiltonf8526982009-09-24 11:34:58 -0500849 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
850 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
851 * entry of the given {@link Data} entry.
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700852 */
853 public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) {
854 final Cursor cursor = resolver.query(dataUri, new String[] {
855 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
856 }, null, null, null);
857
858 Uri lookupUri = null;
859 try {
860 if (cursor != null && cursor.moveToFirst()) {
861 final long contactId = cursor.getLong(0);
862 final String lookupKey = cursor.getString(1);
863 return Contacts.getLookupUri(contactId, lookupKey);
864 }
865 } finally {
866 if (cursor != null) cursor.close();
867 }
868 return lookupUri;
869 }
Evan Millar088b2912009-05-28 15:24:37 -0700870 }
871
Dmitri Plotnikov93032952009-08-19 11:26:57 -0700872 private interface PhoneLookupColumns {
873 /**
874 * The phone number as the user entered it.
875 * <P>Type: TEXT</P>
876 */
877 public static final String NUMBER = "number";
878
879 /**
880 * The type of phone number, for example Home or Work.
881 * <P>Type: INTEGER</P>
882 */
883 public static final String TYPE = "type";
884
885 /**
886 * The user defined label for the phone number.
887 * <P>Type: TEXT</P>
888 */
889 public static final String LABEL = "label";
890 }
891
Evan Millar088b2912009-05-28 15:24:37 -0700892 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700893 * A table that represents the result of looking up a phone number, for
Dmitri Plotnikov93032952009-08-19 11:26:57 -0700894 * example for caller ID. To perform a lookup you must append the number you
895 * want to find to {@link #CONTENT_FILTER_URI}.
Evan Millar088b2912009-05-28 15:24:37 -0700896 */
Dmitri Plotnikov93032952009-08-19 11:26:57 -0700897 public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
898 ContactsColumns, ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700899 /**
900 * This utility class cannot be instantiated
901 */
902 private PhoneLookup() {}
903
904 /**
905 * The content:// style URI for this table. Append the phone number you want to lookup
906 * to this URI and query it to perform a lookup. For example:
907 *
908 * {@code
909 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, phoneNumber);
910 * }
911 */
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700912 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
913 "phone_lookup");
914 }
915
916 /**
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700917 * Additional data mixed in with {@link StatusColumns} to link
918 * back to specific {@link ContactsContract.Data#_ID} entries.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700919 */
920 private interface PresenceColumns {
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700921
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700922 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700923 * Reference to the {@link Data#_ID} entry that owns this presence.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700924 * <P>Type: INTEGER</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700925 */
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -0700926 public static final String DATA_ID = "presence_data_id";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700927
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700928 /**
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -0700929 * <p>Type: NUMBER</p>
930 */
931 public static final String PROTOCOL = "protocol";
932
933 /**
934 * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value
935 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or
936 * omitted if {@link #PROTOCOL} value is not
937 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.
938 *
939 * <p>Type: NUMBER</p>
940 */
941 public static final String CUSTOM_PROTOCOL = "custom_protocol";
942
943 /**
944 * The IM handle the presence item is for. The handle is scoped to
945 * {@link #PROTOCOL}.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700946 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700947 */
948 public static final String IM_HANDLE = "im_handle";
949
950 /**
951 * The IM account for the local user that the presence data came from.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700952 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700953 */
954 public static final String IM_ACCOUNT = "im_account";
955 }
956
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700957 /**
958 * A status update is linked to a {@link Data} row and captures the user's latest status
959 * update via the corresponding source, e.g. "Having lunch" via "Google Talk".
960 */
961 // TODO make final as soon as Presence is removed
962 public static /*final*/ class StatusUpdates implements StatusColumns, PresenceColumns {
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -0700963
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700964 /**
965 * This utility class cannot be instantiated
966 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700967 private StatusUpdates() {}
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700968
969 /**
970 * The content:// style URI for this table
971 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700972 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates");
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500973
974 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700975 * Gets the resource ID for the proper presence icon.
976 *
977 * @param status the status to get the icon for
978 * @return the resource ID for the proper presence icon
979 */
980 public static final int getPresenceIconResourceId(int status) {
981 switch (status) {
982 case AVAILABLE:
983 return android.R.drawable.presence_online;
984 case IDLE:
985 case AWAY:
986 return android.R.drawable.presence_away;
987 case DO_NOT_DISTURB:
988 return android.R.drawable.presence_busy;
989 case INVISIBLE:
990 return android.R.drawable.presence_invisible;
991 case OFFLINE:
992 default:
993 return android.R.drawable.presence_offline;
994 }
995 }
996
997 /**
Evan Millarc0437522009-06-23 17:31:05 -0700998 * Returns the precedence of the status code the higher number being the higher precedence.
999 *
1000 * @param status The status code.
1001 * @return An integer representing the precedence, 0 being the lowest.
1002 */
1003 public static final int getPresencePrecedence(int status) {
1004 // Keep this function here incase we want to enforce a different precedence than the
1005 // natural order of the status constants.
1006 return status;
1007 }
1008
1009 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001010 * The MIME type of {@link #CONTENT_URI} providing a directory of
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07001011 * status update details.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001012 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07001013 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001014
1015 /**
1016 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07001017 * status update detail.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001018 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07001019 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update";
1020 }
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07001021
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07001022 @Deprecated
1023 public static final class Presence extends StatusUpdates {
1024
Evan Millar088b2912009-05-28 15:24:37 -07001025 }
1026
1027 /**
1028 * Container for definitions of common data types stored in the {@link Data} table.
1029 */
1030 public static final class CommonDataKinds {
1031 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001032 * This utility class cannot be instantiated
1033 */
1034 private CommonDataKinds() {}
1035
1036 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001037 * The {@link Data#RES_PACKAGE} value for common data that should be
1038 * shown using a default style.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001039 *
1040 * @hide RES_PACKAGE is hidden
Evan Millar088b2912009-05-28 15:24:37 -07001041 */
1042 public static final String PACKAGE_COMMON = "common";
1043
1044 /**
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001045 * The base types that all "Typed" data kinds support.
1046 */
1047 public interface BaseTypes {
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001048 /**
1049 * A custom type. The custom label should be supplied by user.
1050 */
1051 public static int TYPE_CUSTOM = 0;
1052 }
1053
1054 /**
Evan Millar088b2912009-05-28 15:24:37 -07001055 * Columns common across the specific types.
1056 */
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001057 private interface CommonColumns extends BaseTypes {
Evan Millar088b2912009-05-28 15:24:37 -07001058 /**
Evan Millar088b2912009-05-28 15:24:37 -07001059 * The data for the contact method.
1060 * <P>Type: TEXT</P>
1061 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001062 public static final String DATA = DataColumns.DATA1;
1063
1064 /**
1065 * The type of data, for example Home or Work.
1066 * <P>Type: INTEGER</P>
1067 */
1068 public static final String TYPE = DataColumns.DATA2;
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07001069
1070 /**
1071 * The user defined label for the the contact method.
1072 * <P>Type: TEXT</P>
1073 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001074 public static final String LABEL = DataColumns.DATA3;
Evan Millar088b2912009-05-28 15:24:37 -07001075 }
1076
1077 /**
1078 * Parts of the name.
1079 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001080 public static final class StructuredName implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001081 /**
1082 * This utility class cannot be instantiated
1083 */
Evan Millar088b2912009-05-28 15:24:37 -07001084 private StructuredName() {}
1085
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001086 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001087 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
1088
1089 /**
Evan Millar088b2912009-05-28 15:24:37 -07001090 * The name that should be used to display the contact.
Jeff Sharkey62b83b72009-08-11 17:33:48 -07001091 * <i>Unstructured component of the name should be consistent with
1092 * its structured representation.</i>
1093 * <p>
1094 * Type: TEXT
Evan Millar088b2912009-05-28 15:24:37 -07001095 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001096 public static final String DISPLAY_NAME = DATA1;
1097
1098 /**
1099 * The given name for the contact.
1100 * <P>Type: TEXT</P>
1101 */
1102 public static final String GIVEN_NAME = DATA2;
1103
1104 /**
1105 * The family name for the contact.
1106 * <P>Type: TEXT</P>
1107 */
1108 public static final String FAMILY_NAME = DATA3;
1109
1110 /**
1111 * The contact's honorific prefix, e.g. "Sir"
1112 * <P>Type: TEXT</P>
1113 */
1114 public static final String PREFIX = DATA4;
1115
1116 /**
1117 * The contact's middle name
1118 * <P>Type: TEXT</P>
1119 */
1120 public static final String MIDDLE_NAME = DATA5;
1121
1122 /**
1123 * The contact's honorific suffix, e.g. "Jr"
1124 */
1125 public static final String SUFFIX = DATA6;
1126
1127 /**
1128 * The phonetic version of the given name for the contact.
1129 * <P>Type: TEXT</P>
1130 */
1131 public static final String PHONETIC_GIVEN_NAME = DATA7;
1132
1133 /**
1134 * The phonetic version of the additional name for the contact.
1135 * <P>Type: TEXT</P>
1136 */
1137 public static final String PHONETIC_MIDDLE_NAME = DATA8;
1138
1139 /**
1140 * The phonetic version of the family name for the contact.
1141 * <P>Type: TEXT</P>
1142 */
1143 public static final String PHONETIC_FAMILY_NAME = DATA9;
Evan Millar088b2912009-05-28 15:24:37 -07001144 }
1145
1146 /**
1147 * A nickname.
1148 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001149 public static final class Nickname implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001150 /**
1151 * This utility class cannot be instantiated
1152 */
Evan Millar088b2912009-05-28 15:24:37 -07001153 private Nickname() {}
1154
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001155 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001156 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
1157
Evan Millar78e79ad2009-06-08 10:24:44 -07001158 public static final int TYPE_DEFAULT = 1;
1159 public static final int TYPE_OTHER_NAME = 2;
1160 public static final int TYPE_MAINDEN_NAME = 3;
1161 public static final int TYPE_SHORT_NAME = 4;
1162 public static final int TYPE_INITIALS = 5;
Evan Millar088b2912009-05-28 15:24:37 -07001163
1164 /**
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07001165 * The name itself
1166 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001167 public static final String NAME = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07001168 }
1169
1170 /**
1171 * Common data definition for telephone numbers.
1172 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001173 public static final class Phone implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001174 /**
1175 * This utility class cannot be instantiated
1176 */
Evan Millar088b2912009-05-28 15:24:37 -07001177 private Phone() {}
1178
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001179 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07001180 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
Evan Millar088b2912009-05-28 15:24:37 -07001181
Evan Millar161dd862009-06-12 16:02:43 -07001182 /**
1183 * The MIME type of {@link #CONTENT_URI} providing a directory of
1184 * phones.
1185 */
Evan Millarb3c49982009-09-01 11:38:04 -07001186 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
Evan Millar161dd862009-06-12 16:02:43 -07001187
1188 /**
1189 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001190 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001191 * associated raw contact and aggregate contact data.
Evan Millar161dd862009-06-12 16:02:43 -07001192 */
1193 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1194 "phones");
1195
1196 /**
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001197 * The content:// style URL for phone lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001198 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001199 * to display names as well as phone numbers. The filter argument should be passed
1200 * as an additional path segment after this URI.
Evan Millar161dd862009-06-12 16:02:43 -07001201 */
1202 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
1203 "filter");
1204
Evan Millar088b2912009-05-28 15:24:37 -07001205 public static final int TYPE_HOME = 1;
1206 public static final int TYPE_MOBILE = 2;
1207 public static final int TYPE_WORK = 3;
1208 public static final int TYPE_FAX_WORK = 4;
1209 public static final int TYPE_FAX_HOME = 5;
1210 public static final int TYPE_PAGER = 6;
1211 public static final int TYPE_OTHER = 7;
Fred Quintana3f867152009-08-03 11:43:16 -07001212 public static final int TYPE_CALLBACK = 8;
1213 public static final int TYPE_CAR = 9;
1214 public static final int TYPE_COMPANY_MAIN = 10;
1215 public static final int TYPE_ISDN = 11;
1216 public static final int TYPE_MAIN = 12;
1217 public static final int TYPE_OTHER_FAX = 13;
1218 public static final int TYPE_RADIO = 14;
1219 public static final int TYPE_TELEX = 15;
1220 public static final int TYPE_TTY_TDD = 16;
1221 public static final int TYPE_WORK_MOBILE = 17;
1222 public static final int TYPE_WORK_PAGER = 18;
1223 public static final int TYPE_ASSISTANT = 19;
Jeff Sharkeyd5abd462009-09-16 19:54:29 -07001224 public static final int TYPE_MMS = 20;
Evan Millar088b2912009-05-28 15:24:37 -07001225
1226 /**
1227 * The phone number as the user entered it.
1228 * <P>Type: TEXT</P>
1229 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001230 public static final String NUMBER = DATA;
Dmitri Plotnikov93032952009-08-19 11:26:57 -07001231
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001232 /**
1233 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001234 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001235 */
1236 @Deprecated
Dmitri Plotnikov93032952009-08-19 11:26:57 -07001237 public static final CharSequence getDisplayLabel(Context context, int type,
1238 CharSequence label, CharSequence[] labelArray) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001239 return getTypeLabel(context.getResources(), type, label);
Dmitri Plotnikov93032952009-08-19 11:26:57 -07001240 }
1241
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001242 /**
1243 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001244 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001245 */
1246 @Deprecated
Dmitri Plotnikov93032952009-08-19 11:26:57 -07001247 public static final CharSequence getDisplayLabel(Context context, int type,
1248 CharSequence label) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001249 return getTypeLabel(context.getResources(), type, label);
1250 }
1251
1252 /**
1253 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001254 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001255 */
1256 public static final int getTypeLabelResource(int type) {
1257 switch (type) {
1258 case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome;
1259 case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile;
1260 case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork;
1261 case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork;
1262 case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome;
1263 case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager;
1264 case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther;
1265 case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback;
1266 case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar;
1267 case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain;
1268 case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn;
1269 case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain;
1270 case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax;
1271 case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio;
1272 case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex;
1273 case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd;
1274 case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile;
1275 case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager;
1276 case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant;
1277 case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms;
1278 default: return com.android.internal.R.string.phoneTypeCustom;
1279 }
1280 }
1281
1282 /**
1283 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001284 * possibly substituting the given {@link #LABEL} value
1285 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001286 */
1287 public static final CharSequence getTypeLabel(Resources res, int type,
1288 CharSequence label) {
1289 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) {
1290 return label;
1291 } else {
1292 final int labelRes = getTypeLabelResource(type);
1293 return res.getText(labelRes);
1294 }
Dmitri Plotnikov93032952009-08-19 11:26:57 -07001295 }
Evan Millar088b2912009-05-28 15:24:37 -07001296 }
1297
1298 /**
1299 * Common data definition for email addresses.
1300 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001301 public static final class Email implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001302 /**
1303 * This utility class cannot be instantiated
1304 */
Evan Millar088b2912009-05-28 15:24:37 -07001305 private Email() {}
1306
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001307 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07001308 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2";
Evan Millar088b2912009-05-28 15:24:37 -07001309
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001310 /**
Dmitri Plotnikovabf15c32009-09-18 20:29:11 -07001311 * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses.
1312 */
1313 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2";
1314
1315 /**
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001316 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001317 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001318 * associated raw contact and aggregate contact data.
1319 */
1320 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1321 "emails");
1322
1323 /**
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001324 * The content:// style URL for looking up data rows by email address. The
1325 * lookup argument, an email address, should be passed as an additional path segment
1326 * after this URI.
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001327 */
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001328 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
1329 "lookup");
1330
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001331 /**
1332 * The content:// style URL for email lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001333 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001334 * to display names as well as email addresses. The filter argument should be passed
1335 * as an additional path segment after this URI.
1336 */
1337 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001338 "filter");
1339
Evan Millar088b2912009-05-28 15:24:37 -07001340 public static final int TYPE_HOME = 1;
1341 public static final int TYPE_WORK = 2;
1342 public static final int TYPE_OTHER = 3;
Jeff Sharkey14fb1532009-08-29 15:54:26 -07001343 public static final int TYPE_MOBILE = 4;
Fred Quintana8851e162009-08-05 21:06:45 -07001344
1345 /**
1346 * The display name for the email address
1347 * <P>Type: TEXT</P>
1348 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001349 public static final String DISPLAY_NAME = DATA4;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001350
1351 /**
1352 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001353 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001354 */
1355 public static final int getTypeLabelResource(int type) {
1356 switch (type) {
1357 case TYPE_HOME: return com.android.internal.R.string.emailTypeHome;
1358 case TYPE_WORK: return com.android.internal.R.string.emailTypeWork;
1359 case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther;
1360 case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile;
1361 default: return com.android.internal.R.string.emailTypeCustom;
1362 }
1363 }
1364
1365 /**
1366 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001367 * possibly substituting the given {@link #LABEL} value
1368 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001369 */
1370 public static final CharSequence getTypeLabel(Resources res, int type,
1371 CharSequence label) {
1372 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
1373 return label;
1374 } else {
1375 final int labelRes = getTypeLabelResource(type);
1376 return res.getText(labelRes);
1377 }
1378 }
Evan Millar088b2912009-05-28 15:24:37 -07001379 }
1380
1381 /**
1382 * Common data definition for postal addresses.
1383 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001384 public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001385 /**
1386 * This utility class cannot be instantiated
1387 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001388 private StructuredPostal() {
1389 }
Evan Millar088b2912009-05-28 15:24:37 -07001390
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001391 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07001392 public static final String CONTENT_ITEM_TYPE =
1393 "vnd.android.cursor.item/postal-address_v2";
Evan Millar088b2912009-05-28 15:24:37 -07001394
Evan Millar161dd862009-06-12 16:02:43 -07001395 /**
1396 * The MIME type of {@link #CONTENT_URI} providing a directory of
1397 * postal addresses.
1398 */
Evan Millarb3c49982009-09-01 11:38:04 -07001399 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2";
Evan Millar161dd862009-06-12 16:02:43 -07001400
1401 /**
1402 * The content:// style URI for all data records of the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001403 * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
Evan Millar161dd862009-06-12 16:02:43 -07001404 */
1405 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1406 "postals");
1407
Evan Millar088b2912009-05-28 15:24:37 -07001408 public static final int TYPE_HOME = 1;
1409 public static final int TYPE_WORK = 2;
1410 public static final int TYPE_OTHER = 3;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001411
1412 /**
Jeff Sharkey62b83b72009-08-11 17:33:48 -07001413 * The full, unstructured postal address. <i>This field must be
1414 * consistent with any structured data.</i>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001415 * <p>
1416 * Type: TEXT
1417 */
1418 public static final String FORMATTED_ADDRESS = DATA;
1419
1420 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001421 * Can be street, avenue, road, etc. This element also includes the
1422 * house number and room/apartment/flat/floor number.
1423 * <p>
1424 * Type: TEXT
1425 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001426 public static final String STREET = DATA4;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001427
1428 /**
1429 * Covers actual P.O. boxes, drawers, locked bags, etc. This is
1430 * usually but not always mutually exclusive with street.
1431 * <p>
1432 * Type: TEXT
1433 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001434 public static final String POBOX = DATA5;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001435
1436 /**
1437 * This is used to disambiguate a street address when a city
1438 * contains more than one street with the same name, or to specify a
1439 * small place whose mail is routed through a larger postal town. In
1440 * China it could be a county or a minor city.
1441 * <p>
1442 * Type: TEXT
1443 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001444 public static final String NEIGHBORHOOD = DATA6;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001445
1446 /**
1447 * Can be city, village, town, borough, etc. This is the postal town
1448 * and not necessarily the place of residence or place of business.
1449 * <p>
1450 * Type: TEXT
1451 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001452 public static final String CITY = DATA7;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001453
1454 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001455 * A state, province, county (in Ireland), Land (in Germany),
1456 * departement (in France), etc.
1457 * <p>
1458 * Type: TEXT
1459 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001460 public static final String REGION = DATA8;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001461
1462 /**
Jeff Sharkeyef348c72009-07-26 14:14:34 -07001463 * Postal code. Usually country-wide, but sometimes specific to the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001464 * city (e.g. "2" in "Dublin 2, Ireland" addresses).
1465 * <p>
1466 * Type: TEXT
1467 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001468 public static final String POSTCODE = DATA9;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001469
1470 /**
1471 * The name or code of the country.
1472 * <p>
1473 * Type: TEXT
1474 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001475 public static final String COUNTRY = DATA10;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001476
1477 /**
1478 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001479 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001480 */
1481 public static final int getTypeLabelResource(int type) {
1482 switch (type) {
1483 case TYPE_HOME: return com.android.internal.R.string.postalTypeHome;
1484 case TYPE_WORK: return com.android.internal.R.string.postalTypeWork;
1485 case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther;
1486 default: return com.android.internal.R.string.postalTypeCustom;
1487 }
1488 }
1489
1490 /**
1491 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001492 * possibly substituting the given {@link #LABEL} value
1493 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001494 */
1495 public static final CharSequence getTypeLabel(Resources res, int type,
1496 CharSequence label) {
1497 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
1498 return label;
1499 } else {
1500 final int labelRes = getTypeLabelResource(type);
1501 return res.getText(labelRes);
1502 }
1503 }
Evan Millar088b2912009-05-28 15:24:37 -07001504 }
1505
Fred Quintana8851e162009-08-05 21:06:45 -07001506 /**
1507 * Common data definition for IM addresses.
1508 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001509 public static final class Im implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001510 /**
1511 * This utility class cannot be instantiated
1512 */
Evan Millar088b2912009-05-28 15:24:37 -07001513 private Im() {}
1514
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001515 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001516 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
1517
Evan Millar088b2912009-05-28 15:24:37 -07001518 public static final int TYPE_HOME = 1;
1519 public static final int TYPE_WORK = 2;
1520 public static final int TYPE_OTHER = 3;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07001521
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07001522 /**
1523 * This column should be populated with one of the defined
1524 * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this
1525 * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL}
1526 * should contain the name of the custom protocol.
1527 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001528 public static final String PROTOCOL = DATA5;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07001529
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001530 public static final String CUSTOM_PROTOCOL = DATA6;
Jeff Sharkey732da922009-07-30 09:59:31 -07001531
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07001532 /*
1533 * The predefined IM protocol types.
Evan Millar088b2912009-05-28 15:24:37 -07001534 */
Jeff Sharkey732da922009-07-30 09:59:31 -07001535 public static final int PROTOCOL_CUSTOM = -1;
Evan Millar088b2912009-05-28 15:24:37 -07001536 public static final int PROTOCOL_AIM = 0;
1537 public static final int PROTOCOL_MSN = 1;
1538 public static final int PROTOCOL_YAHOO = 2;
1539 public static final int PROTOCOL_SKYPE = 3;
1540 public static final int PROTOCOL_QQ = 4;
1541 public static final int PROTOCOL_GOOGLE_TALK = 5;
1542 public static final int PROTOCOL_ICQ = 6;
1543 public static final int PROTOCOL_JABBER = 7;
Fred Quintana8851e162009-08-05 21:06:45 -07001544 public static final int PROTOCOL_NETMEETING = 8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001545
1546 /**
1547 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001548 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001549 */
1550 public static final int getTypeLabelResource(int type) {
1551 switch (type) {
1552 case TYPE_HOME: return com.android.internal.R.string.imTypeHome;
1553 case TYPE_WORK: return com.android.internal.R.string.imTypeWork;
1554 case TYPE_OTHER: return com.android.internal.R.string.imTypeOther;
1555 default: return com.android.internal.R.string.imTypeCustom;
1556 }
1557 }
1558
1559 /**
1560 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001561 * possibly substituting the given {@link #LABEL} value
1562 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001563 */
1564 public static final CharSequence getTypeLabel(Resources res, int type,
1565 CharSequence label) {
1566 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
1567 return label;
1568 } else {
1569 final int labelRes = getTypeLabelResource(type);
1570 return res.getText(labelRes);
1571 }
1572 }
1573
1574 /**
1575 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001576 * {@link #PROTOCOL}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001577 */
1578 public static final int getProtocolLabelResource(int type) {
1579 switch (type) {
1580 case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim;
1581 case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn;
1582 case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo;
1583 case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype;
1584 case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq;
1585 case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk;
1586 case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq;
1587 case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber;
1588 case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting;
1589 default: return com.android.internal.R.string.imProtocolCustom;
1590 }
1591 }
1592
1593 /**
1594 * Return a {@link CharSequence} that best describes the given
1595 * protocol, possibly substituting the given
1596 * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}.
1597 */
1598 public static final CharSequence getProtocolLabel(Resources res, int type,
1599 CharSequence label) {
1600 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) {
1601 return label;
1602 } else {
1603 final int labelRes = getProtocolLabelResource(type);
1604 return res.getText(labelRes);
1605 }
1606 }
Evan Millar088b2912009-05-28 15:24:37 -07001607 }
1608
1609 /**
1610 * Common data definition for organizations.
1611 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001612 public static final class Organization implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001613 /**
1614 * This utility class cannot be instantiated
1615 */
Evan Millar088b2912009-05-28 15:24:37 -07001616 private Organization() {}
1617
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001618 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001619 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
1620
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001621 public static final int TYPE_WORK = 1;
1622 public static final int TYPE_OTHER = 2;
Evan Millar088b2912009-05-28 15:24:37 -07001623
1624 /**
1625 * The company as the user entered it.
1626 * <P>Type: TEXT</P>
1627 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001628 public static final String COMPANY = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07001629
1630 /**
1631 * The position title at this company as the user entered it.
1632 * <P>Type: TEXT</P>
1633 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001634 public static final String TITLE = DATA4;
Fred Quintana8851e162009-08-05 21:06:45 -07001635
1636 /**
1637 * The department at this company as the user entered it.
1638 * <P>Type: TEXT</P>
1639 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001640 public static final String DEPARTMENT = DATA5;
Fred Quintana8851e162009-08-05 21:06:45 -07001641
1642 /**
1643 * The job description at this company as the user entered it.
1644 * <P>Type: TEXT</P>
1645 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001646 public static final String JOB_DESCRIPTION = DATA6;
Fred Quintana8851e162009-08-05 21:06:45 -07001647
1648 /**
1649 * The symbol of this company as the user entered it.
1650 * <P>Type: TEXT</P>
1651 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001652 public static final String SYMBOL = DATA7;
Fred Quintana8851e162009-08-05 21:06:45 -07001653
1654 /**
1655 * The phonetic name of this company as the user entered it.
1656 * <P>Type: TEXT</P>
1657 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001658 public static final String PHONETIC_NAME = DATA8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001659
1660 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001661 * The office location of this organization.
1662 * <P>Type: TEXT</P>
1663 */
1664 public static final String OFFICE_LOCATION = DATA9;
1665
1666 /**
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001667 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001668 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001669 */
1670 public static final int getTypeLabelResource(int type) {
1671 switch (type) {
1672 case TYPE_WORK: return com.android.internal.R.string.orgTypeWork;
1673 case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther;
1674 default: return com.android.internal.R.string.orgTypeCustom;
1675 }
1676 }
1677
1678 /**
1679 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001680 * possibly substituting the given {@link #LABEL} value
1681 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001682 */
1683 public static final CharSequence getTypeLabel(Resources res, int type,
1684 CharSequence label) {
1685 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
1686 return label;
1687 } else {
1688 final int labelRes = getTypeLabelResource(type);
1689 return res.getText(labelRes);
1690 }
1691 }
Fred Quintana8851e162009-08-05 21:06:45 -07001692 }
1693
1694 /**
Fred Quintana8851e162009-08-05 21:06:45 -07001695 * Common data definition for relations.
1696 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001697 public static final class Relation implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001698 /**
1699 * This utility class cannot be instantiated
1700 */
Fred Quintana8851e162009-08-05 21:06:45 -07001701 private Relation() {}
1702
1703 /** MIME type used when storing this in data table. */
1704 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
1705
1706 public static final int TYPE_ASSISTANT = 1;
1707 public static final int TYPE_BROTHER = 2;
1708 public static final int TYPE_CHILD = 3;
1709 public static final int TYPE_DOMESTIC_PARTNER = 4;
1710 public static final int TYPE_FATHER = 5;
1711 public static final int TYPE_FRIEND = 6;
1712 public static final int TYPE_MANAGER = 7;
1713 public static final int TYPE_MOTHER = 8;
1714 public static final int TYPE_PARENT = 9;
1715 public static final int TYPE_PARTNER = 10;
1716 public static final int TYPE_REFERRED_BY = 11;
1717 public static final int TYPE_RELATIVE = 12;
1718 public static final int TYPE_SISTER = 13;
1719 public static final int TYPE_SPOUSE = 14;
1720
1721 /**
1722 * The name of the relative as the user entered it.
1723 * <P>Type: TEXT</P>
1724 */
1725 public static final String NAME = DATA;
1726 }
1727
1728 /**
1729 * Common data definition for events.
1730 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001731 public static final class Event implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001732 /**
1733 * This utility class cannot be instantiated
1734 */
Fred Quintana8851e162009-08-05 21:06:45 -07001735 private Event() {}
1736
1737 /** MIME type used when storing this in data table. */
Fred Quintanac868acf2009-09-30 18:17:47 -07001738 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event";
Fred Quintana8851e162009-08-05 21:06:45 -07001739
1740 public static final int TYPE_ANNIVERSARY = 1;
1741 public static final int TYPE_OTHER = 2;
Fred Quintanac868acf2009-09-30 18:17:47 -07001742 public static final int TYPE_BIRTHDAY = 3;
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001743
Fred Quintana8851e162009-08-05 21:06:45 -07001744 /**
1745 * The event start date as the user entered it.
1746 * <P>Type: TEXT</P>
1747 */
1748 public static final String START_DATE = DATA;
Fred Quintanac868acf2009-09-30 18:17:47 -07001749
1750 /**
1751 * Return the string resource that best describes the given
1752 * {@link #TYPE}. Will always return a valid resource.
1753 */
1754 public static int getTypeResource(Integer type) {
1755 if (type == null) {
1756 return com.android.internal.R.string.eventTypeOther;
1757 }
1758 switch (type) {
1759 case TYPE_ANNIVERSARY:
1760 return com.android.internal.R.string.eventTypeAnniversary;
1761 case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday;
1762 case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther;
1763 default: return com.android.internal.R.string.eventTypeOther;
1764 }
1765 }
Evan Millar088b2912009-05-28 15:24:37 -07001766 }
1767
1768 /**
1769 * Photo of the contact.
1770 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001771 public static final class Photo implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001772 /**
1773 * This utility class cannot be instantiated
1774 */
Evan Millar088b2912009-05-28 15:24:37 -07001775 private Photo() {}
1776
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001777 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001778 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
1779
1780 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07001781 * Thumbnail photo of the raw contact. This is the raw bytes of an image
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07001782 * that could be inflated using {@link android.graphics.BitmapFactory}.
Evan Millar088b2912009-05-28 15:24:37 -07001783 * <p>
1784 * Type: BLOB
1785 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001786 public static final String PHOTO = DATA15;
Evan Millar088b2912009-05-28 15:24:37 -07001787 }
1788
1789 /**
1790 * Notes about the contact.
1791 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001792 public static final class Note implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001793 /**
1794 * This utility class cannot be instantiated
1795 */
Evan Millar088b2912009-05-28 15:24:37 -07001796 private Note() {}
1797
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001798 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001799 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
1800
1801 /**
1802 * The note text.
1803 * <P>Type: TEXT</P>
1804 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001805 public static final String NOTE = DATA1;
Evan Millar088b2912009-05-28 15:24:37 -07001806 }
Dmitri Plotnikov56927772009-05-28 17:23:39 -07001807
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07001808 /**
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001809 * Group Membership.
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001810 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001811 public static final class GroupMembership implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001812 /**
1813 * This utility class cannot be instantiated
1814 */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001815 private GroupMembership() {}
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001816
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001817 /** MIME type used when storing this in data table. */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001818 public static final String CONTENT_ITEM_TYPE =
1819 "vnd.android.cursor.item/group_membership";
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001820
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001821 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07001822 * The row id of the group that this group membership refers to. Exactly one of
1823 * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001824 * <P>Type: INTEGER</P>
1825 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001826 public static final String GROUP_ROW_ID = DATA1;
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001827
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001828 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07001829 * The sourceid of the group that this group membership refers to. Exactly one of
1830 * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001831 * <P>Type: TEXT</P>
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001832 */
Fred Quintanaffc34c12009-07-14 16:02:58 -07001833 public static final String GROUP_SOURCE_ID = "group_sourceid";
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001834 }
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001835
1836 /**
1837 * Website related to the contact.
1838 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001839 public static final class Website implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001840 /**
1841 * This utility class cannot be instantiated
1842 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001843 private Website() {}
1844
1845 /** MIME type used when storing this in data table. */
1846 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
1847
Fred Quintana8851e162009-08-05 21:06:45 -07001848 public static final int TYPE_HOMEPAGE = 1;
1849 public static final int TYPE_BLOG = 2;
1850 public static final int TYPE_PROFILE = 3;
1851 public static final int TYPE_HOME = 4;
1852 public static final int TYPE_WORK = 5;
1853 public static final int TYPE_FTP = 6;
1854 public static final int TYPE_OTHER = 7;
1855
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001856 /**
1857 * The website URL string.
1858 * <P>Type: TEXT</P>
1859 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001860 public static final String URL = DATA;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001861 }
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001862 }
Fred Quintana435e4272009-06-04 17:30:28 -07001863
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001864 private interface GroupsColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001865 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001866 * The display title of this group.
1867 * <p>
1868 * Type: TEXT
1869 */
1870 public static final String TITLE = "title";
1871
1872 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001873 * The package name to use when creating {@link Resources} objects for
1874 * this group. This value is only designed for use when building user
1875 * interfaces, and should not be used to infer the owner.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001876 *
1877 * @hide
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001878 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001879 public static final String RES_PACKAGE = "res_package";
1880
1881 /**
1882 * The display title of this group to load as a resource from
1883 * {@link #RES_PACKAGE}, which may be localized.
1884 * <P>Type: TEXT</P>
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001885 *
1886 * @hide
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001887 */
1888 public static final String TITLE_RES = "title_res";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001889
1890 /**
Dmitri Plotnikov02c5b452009-07-22 15:13:08 -07001891 * Notes about the group.
1892 * <p>
1893 * Type: TEXT
1894 */
1895 public static final String NOTES = "notes";
1896
1897 /**
1898 * The ID of this group if it is a System Group, i.e. a group that has a special meaning
1899 * to the sync adapter, null otherwise.
1900 * <P>Type: TEXT</P>
1901 */
1902 public static final String SYSTEM_ID = "system_id";
1903
1904 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001905 * The total number of {@link Contacts} that have
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07001906 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001907 * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
1908 * <p>
1909 * Type: INTEGER
1910 */
1911 public static final String SUMMARY_COUNT = "summ_count";
1912
1913 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001914 * The total number of {@link Contacts} that have both
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07001915 * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001916 * Read-only value that is only present when querying
1917 * {@link Groups#CONTENT_SUMMARY_URI}.
1918 * <p>
1919 * Type: INTEGER
1920 */
1921 public static final String SUMMARY_WITH_PHONES = "summ_phones";
1922
1923 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001924 * Flag indicating if the contacts belonging to this group should be
1925 * visible in any user interface.
1926 * <p>
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07001927 * Type: INTEGER (boolean)
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001928 */
1929 public static final String GROUP_VISIBLE = "group_visible";
Fred Quintana00c89f62009-08-10 14:43:24 -07001930
1931 /**
1932 * The "deleted" flag: "0" by default, "1" if the row has been marked
1933 * for deletion. When {@link android.content.ContentResolver#delete} is
1934 * called on a raw contact, it is marked for deletion and removed from its
1935 * aggregate contact. The sync adaptor deletes the raw contact on the server and
Fred Quintana33f889a2009-09-14 17:31:26 -07001936 * then calls ContactResolver.delete once more, this time setting the the
Jeff Sharkey97bda4c2009-09-15 23:15:23 -07001937 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
Fred Quintana33f889a2009-09-14 17:31:26 -07001938 * the data removal.
Fred Quintana00c89f62009-08-10 14:43:24 -07001939 * <P>Type: INTEGER</P>
1940 */
1941 public static final String DELETED = "deleted";
Jeff Sharkey403d7ac2009-08-16 16:34:35 -07001942
1943 /**
1944 * Whether this group should be synced if the SYNC_EVERYTHING settings
1945 * is false for this group's account.
1946 * <p>
1947 * Type: INTEGER (boolean)
1948 */
1949 public static final String SHOULD_SYNC = "should_sync";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001950 }
1951
1952 /**
1953 * Constants for the groups table.
1954 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001955 public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001956 /**
1957 * This utility class cannot be instantiated
1958 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001959 private Groups() {
1960 }
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001961
1962 /**
1963 * The content:// style URI for this table
1964 */
1965 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
1966
1967 /**
1968 * The content:// style URI for this table joined with details data from
Dmitri Plotnikov02c5b452009-07-22 15:13:08 -07001969 * {@link Data}.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001970 */
1971 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
1972 "groups_summary");
1973
1974 /**
1975 * The MIME type of a directory of groups.
1976 */
1977 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
1978
1979 /**
1980 * The MIME type of a single group.
1981 */
1982 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
1983 }
1984
Fred Quintana435e4272009-06-04 17:30:28 -07001985 /**
1986 * Constants for the contact aggregation exceptions table, which contains
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07001987 * aggregation rules overriding those used by automatic aggregation. This type only
1988 * supports query and update. Neither insert nor delete are supported.
Fred Quintana435e4272009-06-04 17:30:28 -07001989 */
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001990 public static final class AggregationExceptions implements BaseColumns {
Fred Quintana435e4272009-06-04 17:30:28 -07001991 /**
1992 * This utility class cannot be instantiated
1993 */
1994 private AggregationExceptions() {}
1995
1996 /**
1997 * The content:// style URI for this table
1998 */
1999 public static final Uri CONTENT_URI =
2000 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
2001
2002 /**
2003 * The MIME type of {@link #CONTENT_URI} providing a directory of data.
2004 */
2005 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
2006
2007 /**
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07002008 * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
2009 */
2010 public static final String CONTENT_ITEM_TYPE =
2011 "vnd.android.cursor.item/aggregation_exception";
2012
2013 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002014 * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002015 * {@link #TYPE_AUTOMATIC}.
Fred Quintana435e4272009-06-04 17:30:28 -07002016 *
2017 * <P>Type: INTEGER</P>
2018 */
2019 public static final String TYPE = "type";
2020
Fred Quintana435e4272009-06-04 17:30:28 -07002021 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002022 * Allows the provider to automatically decide whether the specified raw contacts should
2023 * be included in the same aggregate contact or not.
Fred Quintana435e4272009-06-04 17:30:28 -07002024 */
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002025 public static final int TYPE_AUTOMATIC = 0;
Fred Quintana435e4272009-06-04 17:30:28 -07002026
2027 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002028 * Makes sure that the specified raw contacts are included in the same
2029 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002030 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002031 public static final int TYPE_KEEP_TOGETHER = 1;
2032
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002033 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002034 * Makes sure that the specified raw contacts are NOT included in the same
2035 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002036 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002037 public static final int TYPE_KEEP_SEPARATE = 2;
2038
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002039 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002040 * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
Fred Quintana435e4272009-06-04 17:30:28 -07002041 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002042 public static final String RAW_CONTACT_ID1 = "raw_contact_id1";
2043
2044 /**
2045 * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule
2046 * applies to.
2047 */
2048 public static final String RAW_CONTACT_ID2 = "raw_contact_id2";
Fred Quintana435e4272009-06-04 17:30:28 -07002049 }
Jeff Sharkey28b68e52009-06-10 15:26:58 -07002050
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002051 private interface SettingsColumns {
2052 /**
2053 * The name of the account instance to which this row belongs.
2054 * <P>Type: TEXT</P>
2055 */
2056 public static final String ACCOUNT_NAME = "account_name";
2057
2058 /**
2059 * The type of account to which this row belongs, which when paired with
2060 * {@link #ACCOUNT_NAME} identifies a specific account.
2061 * <P>Type: TEXT</P>
2062 */
2063 public static final String ACCOUNT_TYPE = "account_type";
2064
2065 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07002066 * Depending on the mode defined by the sync-adapter, this flag controls
2067 * the top-level sync behavior for this data source.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002068 * <p>
2069 * Type: INTEGER (boolean)
2070 */
2071 public static final String SHOULD_SYNC = "should_sync";
2072
2073 /**
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07002074 * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership}
Jeff Sharkeya6597442009-08-19 09:23:33 -07002075 * entries should be visible in any user interface.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002076 * <p>
2077 * Type: INTEGER (boolean)
2078 */
2079 public static final String UNGROUPED_VISIBLE = "ungrouped_visible";
Jeff Sharkey06a03232009-08-21 17:37:56 -07002080
2081 /**
Jeff Sharkey97bda4c2009-09-15 23:15:23 -07002082 * Read-only flag indicating if this {@link #SHOULD_SYNC} or any
2083 * {@link Groups#SHOULD_SYNC} under this account have been marked as
2084 * unsynced.
2085 */
2086 public static final String ANY_UNSYNCED = "any_unsynced";
2087
2088 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07002089 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07002090 * no {@link CommonDataKinds.GroupMembership} entries.
Jeff Sharkey06a03232009-08-21 17:37:56 -07002091 * <p>
2092 * Type: INTEGER
2093 */
2094 public static final String UNGROUPED_COUNT = "summ_count";
2095
2096 /**
2097 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07002098 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers.
Jeff Sharkey06a03232009-08-21 17:37:56 -07002099 * <p>
2100 * Type: INTEGER
2101 */
2102 public static final String UNGROUPED_WITH_PHONES = "summ_phones";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002103 }
2104
2105 /**
2106 * Contacts-specific settings for various {@link Account}.
2107 */
Jeff Sharkey06a03232009-08-21 17:37:56 -07002108 public static final class Settings implements SettingsColumns {
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002109 /**
2110 * This utility class cannot be instantiated
2111 */
2112 private Settings() {
2113 }
2114
2115 /**
2116 * The content:// style URI for this table
2117 */
2118 public static final Uri CONTENT_URI =
2119 Uri.withAppendedPath(AUTHORITY_URI, "settings");
2120
2121 /**
2122 * The MIME-type of {@link #CONTENT_URI} providing a directory of
2123 * settings.
2124 */
2125 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting";
2126
2127 /**
2128 * The MIME-type of {@link #CONTENT_URI} providing a single setting.
2129 */
2130 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002131 }
2132
Evan Millardc2da5f2009-06-18 16:07:13 -07002133 /**
Evan Millare3ec9972009-09-30 19:37:36 -07002134 * Helper methods to display QuickContact dialogs that allow users to pivot on
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002135 * a specific {@link Contacts} entry.
2136 */
Evan Millare3ec9972009-09-30 19:37:36 -07002137 public static final class QuickContact {
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002138 /**
2139 * Action used to trigger person pivot dialog.
2140 * @hide
2141 */
Evan Millar5042f7e2009-09-30 21:28:33 -07002142 public static final String ACTION_QUICK_CONTACT =
2143 "com.android.contacts.action.QUICK_CONTACT";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002144
2145 /**
2146 * Extra used to specify pivot dialog location in screen coordinates.
2147 * @hide
2148 */
2149 public static final String EXTRA_TARGET_RECT = "target_rect";
2150
2151 /**
2152 * Extra used to specify size of pivot dialog.
2153 * @hide
2154 */
2155 public static final String EXTRA_MODE = "mode";
2156
2157 /**
2158 * Extra used to indicate a list of specific MIME-types to exclude and
2159 * not display. Stored as a {@link String} array.
2160 * @hide
2161 */
2162 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
2163
2164 /**
Evan Millare3ec9972009-09-30 19:37:36 -07002165 * Small QuickContact mode, usually presented with minimal actions.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002166 */
2167 public static final int MODE_SMALL = 1;
2168
2169 /**
Evan Millare3ec9972009-09-30 19:37:36 -07002170 * Medium QuickContact mode, includes actions and light summary describing
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002171 * the {@link Contacts} entry being shown. This may include social
2172 * status and presence details.
2173 */
2174 public static final int MODE_MEDIUM = 2;
2175
2176 /**
Evan Millare3ec9972009-09-30 19:37:36 -07002177 * Large QuickContact mode, includes actions and larger, card-like summary
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002178 * of the {@link Contacts} entry being shown. This may include detailed
2179 * information, such as a photo.
2180 */
2181 public static final int MODE_LARGE = 3;
2182
2183 /**
2184 * Trigger a dialog that lists the various methods of interacting with
2185 * the requested {@link Contacts} entry. This may be based on available
2186 * {@link Data} rows under that contact, and may also include social
2187 * status and presence details.
2188 *
2189 * @param context The parent {@link Context} that may be used as the
2190 * parent for this dialog.
2191 * @param target Specific {@link View} from your layout that this dialog
2192 * should be centered around. In particular, if the dialog
2193 * has a "callout" arrow, it will be pointed and centered
2194 * around this {@link View}.
2195 * @param lookupUri A {@link Contacts#CONTENT_LOOKUP_URI} style
2196 * {@link Uri} that describes a specific contact to feature
2197 * in this dialog.
2198 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
2199 * {@link #MODE_LARGE}, indicating the desired dialog size,
2200 * when supported.
2201 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
2202 * to exclude when showing this dialog. For example, when
2203 * already viewing the contact details card, this can be used
2204 * to omit the details entry from the dialog.
2205 */
Evan Millare3ec9972009-09-30 19:37:36 -07002206 public static void showQuickContact(Context context, View target, Uri lookupUri, int mode,
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002207 String[] excludeMimes) {
2208 // Find location and bounds of target view
2209 final int[] location = new int[2];
2210 target.getLocationOnScreen(location);
2211
2212 final Rect rect = new Rect();
2213 rect.left = location[0];
2214 rect.top = location[1];
2215 rect.right = rect.left + target.getWidth();
2216 rect.bottom = rect.top + target.getHeight();
2217
2218 // Trigger with obtained rectangle
Evan Millare3ec9972009-09-30 19:37:36 -07002219 showQuickContact(context, rect, lookupUri, mode, excludeMimes);
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002220 }
2221
2222 /**
2223 * Trigger a dialog that lists the various methods of interacting with
2224 * the requested {@link Contacts} entry. This may be based on available
2225 * {@link Data} rows under that contact, and may also include social
2226 * status and presence details.
2227 *
2228 * @param context The parent {@link Context} that may be used as the
2229 * parent for this dialog.
2230 * @param target Specific {@link Rect} that this dialog should be
2231 * centered around, in screen coordinates. In particular, if
2232 * the dialog has a "callout" arrow, it will be pointed and
2233 * centered around this {@link Rect}.
2234 * @param lookupUri A {@link Contacts#CONTENT_LOOKUP_URI} style
2235 * {@link Uri} that describes a specific contact to feature
2236 * in this dialog.
2237 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
2238 * {@link #MODE_LARGE}, indicating the desired dialog size,
2239 * when supported.
2240 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
2241 * to exclude when showing this dialog. For example, when
2242 * already viewing the contact details card, this can be used
2243 * to omit the details entry from the dialog.
2244 */
Evan Millare3ec9972009-09-30 19:37:36 -07002245 public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode,
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002246 String[] excludeMimes) {
2247 // Launch pivot dialog through intent for now
Evan Millar5042f7e2009-09-30 21:28:33 -07002248 final Intent intent = new Intent(ACTION_QUICK_CONTACT);
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002249 intent.setData(lookupUri);
2250 intent.putExtra(EXTRA_TARGET_RECT, target);
2251 intent.putExtra(EXTRA_MODE, mode);
2252 intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes);
Megha Joshicf1e2f92009-09-30 13:17:33 -07002253 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002254 context.startActivity(intent);
2255 }
2256 }
2257
2258 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07002259 * Contains helper classes used to create or manage {@link android.content.Intent Intents}
2260 * that involve contacts.
2261 */
2262 public static final class Intents {
2263 /**
2264 * This is the intent that is fired when a search suggestion is clicked on.
2265 */
2266 public static final String SEARCH_SUGGESTION_CLICKED =
2267 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
2268
2269 /**
2270 * This is the intent that is fired when a search suggestion for dialing a number
2271 * is clicked on.
2272 */
2273 public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
2274 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
2275
2276 /**
2277 * This is the intent that is fired when a search suggestion for creating a contact
2278 * is clicked on.
2279 */
2280 public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
2281 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
2282
2283 /**
2284 * Starts an Activity that lets the user pick a contact to attach an image to.
2285 * After picking the contact it launches the image cropper in face detection mode.
2286 */
2287 public static final String ATTACH_IMAGE =
2288 "com.android.contacts.action.ATTACH_IMAGE";
2289
2290 /**
2291 * Takes as input a data URI with a mailto: or tel: scheme. If a single
2292 * contact exists with the given data it will be shown. If no contact
2293 * exists, a dialog will ask the user if they want to create a new
2294 * contact with the provided details filled in. If multiple contacts
2295 * share the data the user will be prompted to pick which contact they
2296 * want to view.
2297 * <p>
2298 * For <code>mailto:</code> URIs, the scheme specific portion must be a
2299 * raw email address, such as one built using
2300 * {@link Uri#fromParts(String, String, String)}.
2301 * <p>
2302 * For <code>tel:</code> URIs, the scheme specific portion is compared
2303 * to existing numbers using the standard caller ID lookup algorithm.
2304 * The number must be properly encoded, for example using
2305 * {@link Uri#fromParts(String, String, String)}.
2306 * <p>
2307 * Any extras from the {@link Insert} class will be passed along to the
2308 * create activity if there are no contacts to show.
2309 * <p>
2310 * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
2311 * prompting the user when the contact doesn't exist.
2312 */
2313 public static final String SHOW_OR_CREATE_CONTACT =
2314 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
2315
2316 /**
2317 * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
2318 * contact if no matching contact found. Otherwise, default behavior is
2319 * to prompt user with dialog before creating.
2320 * <p>
2321 * Type: BOOLEAN
2322 */
2323 public static final String EXTRA_FORCE_CREATE =
2324 "com.android.contacts.action.FORCE_CREATE";
2325
2326 /**
2327 * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
2328 * description to be shown when prompting user about creating a new
2329 * contact.
2330 * <p>
2331 * Type: STRING
2332 */
2333 public static final String EXTRA_CREATE_DESCRIPTION =
2334 "com.android.contacts.action.CREATE_DESCRIPTION";
2335
2336 /**
Jeff Sharkey11322002009-06-04 17:25:51 -07002337 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
2338 * dialog location using screen coordinates. When not specified, the
2339 * dialog will be centered.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002340 *
2341 * @hide
Jeff Sharkey11322002009-06-04 17:25:51 -07002342 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002343 @Deprecated
Jeff Sharkey11322002009-06-04 17:25:51 -07002344 public static final String EXTRA_TARGET_RECT = "target_rect";
2345
2346 /**
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002347 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
2348 * desired dialog style, usually a variation on size. One of
2349 * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002350 *
2351 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002352 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002353 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002354 public static final String EXTRA_MODE = "mode";
2355
2356 /**
2357 * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002358 *
2359 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002360 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002361 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002362 public static final int MODE_SMALL = 1;
2363
2364 /**
2365 * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002366 *
2367 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002368 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002369 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002370 public static final int MODE_MEDIUM = 2;
2371
2372 /**
2373 * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002374 *
2375 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002376 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002377 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002378 public static final int MODE_LARGE = 3;
2379
2380 /**
Jeff Sharkey84235ee2009-08-23 14:07:02 -07002381 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate
2382 * a list of specific MIME-types to exclude and not display. Stored as a
2383 * {@link String} array.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002384 *
2385 * @hide
Jeff Sharkey84235ee2009-08-23 14:07:02 -07002386 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002387 @Deprecated
Jeff Sharkey84235ee2009-08-23 14:07:02 -07002388 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
2389
2390 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07002391 * Intents related to the Contacts app UI.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002392 *
2393 * @hide
Evan Millardc2da5f2009-06-18 16:07:13 -07002394 */
2395 public static final class UI {
2396 /**
2397 * The action for the default contacts list tab.
2398 */
2399 public static final String LIST_DEFAULT =
2400 "com.android.contacts.action.LIST_DEFAULT";
2401
2402 /**
2403 * The action for the contacts list tab.
2404 */
2405 public static final String LIST_GROUP_ACTION =
2406 "com.android.contacts.action.LIST_GROUP";
2407
2408 /**
2409 * When in LIST_GROUP_ACTION mode, this is the group to display.
2410 */
2411 public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP";
2412
2413 /**
2414 * The action for the all contacts list tab.
2415 */
2416 public static final String LIST_ALL_CONTACTS_ACTION =
2417 "com.android.contacts.action.LIST_ALL_CONTACTS";
2418
2419 /**
2420 * The action for the contacts with phone numbers list tab.
2421 */
2422 public static final String LIST_CONTACTS_WITH_PHONES_ACTION =
2423 "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES";
2424
2425 /**
2426 * The action for the starred contacts list tab.
2427 */
2428 public static final String LIST_STARRED_ACTION =
2429 "com.android.contacts.action.LIST_STARRED";
2430
2431 /**
2432 * The action for the frequent contacts list tab.
2433 */
2434 public static final String LIST_FREQUENT_ACTION =
2435 "com.android.contacts.action.LIST_FREQUENT";
2436
2437 /**
2438 * The action for the "strequent" contacts list tab. It first lists the starred
2439 * contacts in alphabetical order and then the frequent contacts in descending
2440 * order of the number of times they have been contacted.
2441 */
2442 public static final String LIST_STREQUENT_ACTION =
2443 "com.android.contacts.action.LIST_STREQUENT";
2444
2445 /**
2446 * A key for to be used as an intent extra to set the activity
2447 * title to a custom String value.
2448 */
2449 public static final String TITLE_EXTRA_KEY =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002450 "com.android.contacts.extra.TITLE_EXTRA";
Evan Millardc2da5f2009-06-18 16:07:13 -07002451
2452 /**
2453 * Activity Action: Display a filtered list of contacts
2454 * <p>
2455 * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for
2456 * filtering
2457 * <p>
2458 * Output: Nothing.
2459 */
2460 public static final String FILTER_CONTACTS_ACTION =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002461 "com.android.contacts.action.FILTER_CONTACTS";
Evan Millardc2da5f2009-06-18 16:07:13 -07002462
2463 /**
2464 * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION}
2465 * intents to supply the text on which to filter.
2466 */
2467 public static final String FILTER_TEXT_EXTRA_KEY =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002468 "com.android.contacts.extra.FILTER_TEXT";
Evan Millardc2da5f2009-06-18 16:07:13 -07002469 }
2470
2471 /**
2472 * Convenience class that contains string constants used
2473 * to create contact {@link android.content.Intent Intents}.
2474 */
2475 public static final class Insert {
2476 /** The action code to use when adding a contact */
2477 public static final String ACTION = Intent.ACTION_INSERT;
2478
2479 /**
2480 * If present, forces a bypass of quick insert mode.
2481 */
2482 public static final String FULL_MODE = "full_mode";
2483
2484 /**
2485 * The extra field for the contact name.
2486 * <P>Type: String</P>
2487 */
2488 public static final String NAME = "name";
2489
2490 // TODO add structured name values here.
2491
2492 /**
2493 * The extra field for the contact phonetic name.
2494 * <P>Type: String</P>
2495 */
2496 public static final String PHONETIC_NAME = "phonetic_name";
2497
2498 /**
2499 * The extra field for the contact company.
2500 * <P>Type: String</P>
2501 */
2502 public static final String COMPANY = "company";
2503
2504 /**
2505 * The extra field for the contact job title.
2506 * <P>Type: String</P>
2507 */
2508 public static final String JOB_TITLE = "job_title";
2509
2510 /**
2511 * The extra field for the contact notes.
2512 * <P>Type: String</P>
2513 */
2514 public static final String NOTES = "notes";
2515
2516 /**
2517 * The extra field for the contact phone number.
2518 * <P>Type: String</P>
2519 */
2520 public static final String PHONE = "phone";
2521
2522 /**
2523 * The extra field for the contact phone number type.
2524 * <P>Type: Either an integer value from
2525 * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
2526 * or a string specifying a custom label.</P>
2527 */
2528 public static final String PHONE_TYPE = "phone_type";
2529
2530 /**
2531 * The extra field for the phone isprimary flag.
2532 * <P>Type: boolean</P>
2533 */
2534 public static final String PHONE_ISPRIMARY = "phone_isprimary";
2535
2536 /**
2537 * The extra field for an optional second contact phone number.
2538 * <P>Type: String</P>
2539 */
2540 public static final String SECONDARY_PHONE = "secondary_phone";
2541
2542 /**
2543 * The extra field for an optional second contact phone number type.
2544 * <P>Type: Either an integer value from
2545 * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
2546 * or a string specifying a custom label.</P>
2547 */
2548 public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
2549
2550 /**
2551 * The extra field for an optional third contact phone number.
2552 * <P>Type: String</P>
2553 */
2554 public static final String TERTIARY_PHONE = "tertiary_phone";
2555
2556 /**
2557 * The extra field for an optional third contact phone number type.
2558 * <P>Type: Either an integer value from
2559 * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
2560 * or a string specifying a custom label.</P>
2561 */
2562 public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
2563
2564 /**
2565 * The extra field for the contact email address.
2566 * <P>Type: String</P>
2567 */
2568 public static final String EMAIL = "email";
2569
2570 /**
2571 * The extra field for the contact email type.
2572 * <P>Type: Either an integer value from
2573 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2574 * or a string specifying a custom label.</P>
2575 */
2576 public static final String EMAIL_TYPE = "email_type";
2577
2578 /**
2579 * The extra field for the email isprimary flag.
2580 * <P>Type: boolean</P>
2581 */
2582 public static final String EMAIL_ISPRIMARY = "email_isprimary";
2583
2584 /**
2585 * The extra field for an optional second contact email address.
2586 * <P>Type: String</P>
2587 */
2588 public static final String SECONDARY_EMAIL = "secondary_email";
2589
2590 /**
2591 * The extra field for an optional second contact email type.
2592 * <P>Type: Either an integer value from
2593 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2594 * or a string specifying a custom label.</P>
2595 */
2596 public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
2597
2598 /**
2599 * The extra field for an optional third contact email address.
2600 * <P>Type: String</P>
2601 */
2602 public static final String TERTIARY_EMAIL = "tertiary_email";
2603
2604 /**
2605 * The extra field for an optional third contact email type.
2606 * <P>Type: Either an integer value from
2607 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2608 * or a string specifying a custom label.</P>
2609 */
2610 public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
2611
2612 /**
2613 * The extra field for the contact postal address.
2614 * <P>Type: String</P>
2615 */
2616 public static final String POSTAL = "postal";
2617
2618 /**
2619 * The extra field for the contact postal address type.
2620 * <P>Type: Either an integer value from
2621 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2622 * or a string specifying a custom label.</P>
2623 */
2624 public static final String POSTAL_TYPE = "postal_type";
2625
2626 /**
2627 * The extra field for the postal isprimary flag.
2628 * <P>Type: boolean</P>
2629 */
2630 public static final String POSTAL_ISPRIMARY = "postal_isprimary";
2631
2632 /**
2633 * The extra field for an IM handle.
2634 * <P>Type: String</P>
2635 */
2636 public static final String IM_HANDLE = "im_handle";
2637
2638 /**
2639 * The extra field for the IM protocol
Evan Millardc2da5f2009-06-18 16:07:13 -07002640 */
2641 public static final String IM_PROTOCOL = "im_protocol";
2642
2643 /**
2644 * The extra field for the IM isprimary flag.
2645 * <P>Type: boolean</P>
2646 */
2647 public static final String IM_ISPRIMARY = "im_isprimary";
2648 }
2649 }
2650
Evan Millar088b2912009-05-28 15:24:37 -07002651}