blob: 3a9bad8605a0e784b00705ec72a17eec5fbc25c7 [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 /**
60 * @hide should be removed when users are updated to refer to SyncState
61 * @deprecated use SyncState instead
62 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -070063 @Deprecated
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070064 public interface SyncStateColumns extends SyncStateContract.Columns {
65 }
66
Jeff Hamilton85abdc52009-09-22 12:41:45 -050067 /**
68 * A table provided for sync adapters to use for storing private sync state data.
69 *
70 * @see SyncStateContract
71 */
72 public static final class SyncState implements SyncStateContract.Columns {
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070073 /**
74 * This utility class cannot be instantiated
75 */
76 private SyncState() {}
77
78 public static final String CONTENT_DIRECTORY =
79 SyncStateContract.Constants.CONTENT_DIRECTORY;
80
81 /**
82 * The content:// style URI for this table
83 */
84 public static final Uri CONTENT_URI =
85 Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY);
86
87 /**
88 * @see android.provider.SyncStateContract.Helpers#get
89 */
90 public static byte[] get(ContentProviderClient provider, Account account)
91 throws RemoteException {
92 return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
93 }
94
95 /**
Fred Quintanac4516a72009-09-03 12:14:06 -070096 * @see android.provider.SyncStateContract.Helpers#get
97 */
98 public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
99 throws RemoteException {
100 return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
101 }
102
103 /**
Fred Quintana0f4e1ab2009-07-09 17:20:59 -0700104 * @see android.provider.SyncStateContract.Helpers#set
105 */
106 public static void set(ContentProviderClient provider, Account account, byte[] data)
107 throws RemoteException {
108 SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
109 }
110
111 /**
112 * @see android.provider.SyncStateContract.Helpers#newSetOperation
113 */
114 public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
115 return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
116 }
117 }
118
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700119 /**
120 * Generic columns for use by sync adapters. The specific functions of
121 * these columns are private to the sync adapter. Other clients of the API
122 * should not attempt to either read or write this column.
123 */
124 private interface BaseSyncColumns {
125
126 /** Generic column for use by sync adapters. */
127 public static final String SYNC1 = "sync1";
128 /** Generic column for use by sync adapters. */
129 public static final String SYNC2 = "sync2";
130 /** Generic column for use by sync adapters. */
131 public static final String SYNC3 = "sync3";
132 /** Generic column for use by sync adapters. */
133 public static final String SYNC4 = "sync4";
134 }
135
136 /**
137 * Columns that appear when each row of a table belongs to a specific
138 * account, including sync information that an account may need.
139 */
140 private interface SyncColumns extends BaseSyncColumns {
141 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500142 * The name of the account instance to which this row belongs, which when paired with
143 * {@link #ACCOUNT_TYPE} identifies a specific account.
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700144 * <P>Type: TEXT</P>
145 */
146 public static final String ACCOUNT_NAME = "account_name";
147
148 /**
149 * The type of account to which this row belongs, which when paired with
150 * {@link #ACCOUNT_NAME} identifies a specific account.
151 * <P>Type: TEXT</P>
152 */
153 public static final String ACCOUNT_TYPE = "account_type";
154
155 /**
156 * String that uniquely identifies this row to its source account.
157 * <P>Type: TEXT</P>
158 */
159 public static final String SOURCE_ID = "sourceid";
160
161 /**
162 * Version number that is updated whenever this row or its related data
163 * changes.
164 * <P>Type: INTEGER</P>
165 */
166 public static final String VERSION = "version";
167
168 /**
169 * Flag indicating that {@link #VERSION} has changed, and this row needs
170 * to be synchronized by its owning account.
171 * <P>Type: INTEGER (boolean)</P>
172 */
173 public static final String DIRTY = "dirty";
174 }
175
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500176 private interface ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700177 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500178 * The number of times a contact has been contacted
Evan Millar088b2912009-05-28 15:24:37 -0700179 * <P>Type: INTEGER</P>
180 */
181 public static final String TIMES_CONTACTED = "times_contacted";
182
183 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500184 * The last time a contact was contacted.
Evan Millar088b2912009-05-28 15:24:37 -0700185 * <P>Type: INTEGER</P>
186 */
187 public static final String LAST_TIME_CONTACTED = "last_time_contacted";
188
189 /**
190 * Is the contact starred?
191 * <P>Type: INTEGER (boolean)</P>
192 */
193 public static final String STARRED = "starred";
194
195 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500196 * A custom ringtone associated with a contact. Not always present.
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700197 * <P>Type: TEXT (URI to the ringtone)</P>
198 */
199 public static final String CUSTOM_RINGTONE = "custom_ringtone";
200
201 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500202 * Whether the contact should always be sent to voicemail. Not always
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700203 * present.
204 * <P>Type: INTEGER (0 for false, 1 for true)</P>
205 */
206 public static final String SEND_TO_VOICEMAIL = "send_to_voicemail";
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700207 }
208
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700209 private interface ContactsColumns {
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700210 /**
211 * The display name for the contact.
212 * <P>Type: TEXT</P>
213 */
214 public static final String DISPLAY_NAME = "display_name";
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700215
216 /**
Evan Millar088b2912009-05-28 15:24:37 -0700217 * Reference to the row in the data table holding the photo.
218 * <P>Type: INTEGER REFERENCES data(_id)</P>
219 */
220 public static final String PHOTO_ID = "photo_id";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -0700221
222 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700223 * Lookup value that reflects the {@link Groups#GROUP_VISIBLE} state of
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -0700224 * any {@link CommonDataKinds.GroupMembership} for this contact.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -0700225 */
226 public static final String IN_VISIBLE_GROUP = "in_visible_group";
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700227
228 /**
Dmitri Plotnikov074fbfe2009-08-11 13:50:21 -0700229 * An indicator of whether this contact has at least one phone number. "1" if there is
230 * at least one phone number, "0" otherwise.
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700231 * <P>Type: INTEGER</P>
232 */
Dmitri Plotnikov074fbfe2009-08-11 13:50:21 -0700233 public static final String HAS_PHONE_NUMBER = "has_phone_number";
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700234
235 /**
236 * An opaque value that contains hints on how to find the contact if
237 * its row id changed as a result of a sync or aggregation.
238 */
239 public static final String LOOKUP_KEY = "lookup";
Evan Millar088b2912009-05-28 15:24:37 -0700240 }
241
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700242 private interface ContactStatusColumns {
243 /**
244 * Contact presence status. See {@link StatusUpdates} for individual status
245 * definitions.
246 * <p>Type: NUMBER</p>
247 */
248 public static final String CONTACT_PRESENCE = "contact_presence";
249
250 /**
251 * Contact's latest status update.
252 * <p>Type: TEXT</p>
253 */
254 public static final String CONTACT_STATUS = "contact_status";
255
256 /**
257 * The absolute time in milliseconds when the latest status was
258 * inserted/updated.
259 * <p>Type: NUMBER</p>
260 */
261 public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts";
262
263 /**
264 * The package containing resources for this status: label and icon.
265 * <p>Type: NUMBER</p>
266 */
267 public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package";
268
269 /**
270 * The resource ID of the label describing the source of contact
271 * status, e.g. "Google Talk". This resource is scoped by the
272 * {@link #CONTACT_STATUS_RES_PACKAGE}.
273 * <p>Type: NUMBER</p>
274 */
275 public static final String CONTACT_STATUS_LABEL = "contact_status_label";
276
277 /**
278 * The resource ID of the icon for the source of contact status. This
279 * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.
280 * <p>Type: NUMBER</p>
281 */
282 public static final String CONTACT_STATUS_ICON = "contact_status_icon";
283 }
284
Evan Millar088b2912009-05-28 15:24:37 -0700285 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700286 * Constants for the contacts table, which contains a record per group
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500287 * of raw contacts representing the same person.
Evan Millar088b2912009-05-28 15:24:37 -0700288 */
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700289 public static class Contacts implements BaseColumns, ContactsColumns,
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700290 ContactOptionsColumns, ContactStatusColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700291 /**
292 * This utility class cannot be instantiated
293 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700294 private Contacts() {}
Evan Millar088b2912009-05-28 15:24:37 -0700295
296 /**
297 * The content:// style URI for this table
298 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700299 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
Evan Millar088b2912009-05-28 15:24:37 -0700300
301 /**
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700302 * A content:// style URI for this table that should be used to create
303 * shortcuts or otherwise create long-term links to contacts. This URI
304 * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}.
305 * It can optionally also have a "/" and last known contact ID appended after
306 * that. This "complete" format is an important optimization and is highly recommended.
307 * <p>
308 * As long as the contact's row ID remains the same, this URI is
309 * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes
310 * as a result of a sync or aggregation, this URI will look up the
311 * contact using indirect information (sync IDs or constituent raw
312 * contacts).
313 * <p>
314 * Lookup key should be appended unencoded - it is stored in the encoded
315 * form, ready for use in a URI.
316 */
317 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
318 "lookup");
319
320 /**
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700321 * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the
322 * requested {@link Contacts} entry.
323 *
324 * @param contactUri A {@link #CONTENT_URI} row, or an existing
325 * {@link #CONTENT_LOOKUP_URI} to attempt refreshing.
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700326 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700327 public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) {
328 final Cursor c = resolver.query(contactUri, new String[] {
329 Contacts.LOOKUP_KEY, Contacts._ID
330 }, null, null, null);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700331 if (c == null) {
332 return null;
333 }
334
335 try {
336 if (c.moveToFirst()) {
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700337 final String lookupKey = c.getString(0);
338 final long contactId = c.getLong(1);
339 return getLookupUri(contactId, lookupKey);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700340 }
341 } finally {
342 c.close();
343 }
344 return null;
345 }
346
347 /**
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -0700348 * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the
Jeff Hamiltonf8526982009-09-24 11:34:58 -0500349 * given {@link android.provider.ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}.
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -0700350 */
351 public static Uri getLookupUri(long contactId, String lookupKey) {
352 return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI,
353 lookupKey), contactId);
354 }
355
356 /**
Dmitri Plotnikovb5759b52009-09-01 15:58:40 -0700357 * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI.
358 * <p>
359 * Returns null if the contact cannot be found.
360 */
361 public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) {
362 if (lookupUri == null) {
363 return null;
364 }
365
366 Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null);
367 if (c == null) {
368 return null;
369 }
370
371 try {
372 if (c.moveToFirst()) {
373 long contactId = c.getLong(0);
374 return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
375 }
376 } finally {
377 c.close();
378 }
379 return null;
380 }
381
382 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500383 * Mark a contact as having been contacted.
384 *
385 * @param resolver the ContentResolver to use
386 * @param contactId the person who was contacted
387 */
388 public static void markAsContacted(ContentResolver resolver, long contactId) {
389 Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId);
390 ContentValues values = new ContentValues();
391 // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified.
392 values.put(LAST_TIME_CONTACTED, System.currentTimeMillis());
393 resolver.update(uri, values, null, null);
394 }
395
396 /**
Evan Millar161dd862009-06-12 16:02:43 -0700397 * The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700398 * {@link #CONTENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700399 * various parts of the contact name. The filter argument should be passed
Evan Millar161dd862009-06-12 16:02:43 -0700400 * as an additional path segment after this URI.
401 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700402 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
403 CONTENT_URI, "filter");
404
Evan Millardc2da5f2009-06-18 16:07:13 -0700405 /**
406 * The content:// style URI for this table joined with useful data from
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700407 * {@link Data}, filtered to include only starred contacts
408 * and the most frequently contacted contacts.
Evan Millardc2da5f2009-06-18 16:07:13 -0700409 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700410 public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath(
411 CONTENT_URI, "strequent");
412
Evan Millardc2da5f2009-06-18 16:07:13 -0700413 /**
414 * The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700415 * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700416 * various parts of the contact name. The filter argument should be passed
Evan Millardc2da5f2009-06-18 16:07:13 -0700417 * as an additional path segment after this URI.
418 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700419 public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath(
420 CONTENT_STREQUENT_URI, "filter");
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700421
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700422 public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath(
423 CONTENT_URI, "group");
424
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700425 /**
Evan Millar088b2912009-05-28 15:24:37 -0700426 * The MIME type of {@link #CONTENT_URI} providing a directory of
427 * people.
428 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700429 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
Evan Millar088b2912009-05-28 15:24:37 -0700430
431 /**
432 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
433 * person.
434 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700435 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
Evan Millar088b2912009-05-28 15:24:37 -0700436
437 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700438 * A sub-directory of a single contact that contains all of the constituent raw contact
Evan Millar088b2912009-05-28 15:24:37 -0700439 * {@link Data} rows.
440 */
Fred Quintana8851e162009-08-05 21:06:45 -0700441 public static final class Data implements BaseColumns, DataColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700442 /**
443 * no public constructor since this is a utility class
444 */
445 private Data() {}
446
447 /**
448 * The directory twig for this sub-table
449 */
450 public static final String CONTENT_DIRECTORY = "data";
451 }
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700452
453 /**
454 * A sub-directory of a single contact aggregate that contains all aggregation suggestions
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700455 * (other contacts). The aggregation suggestions are computed based on approximate
456 * data matches with this contact.
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700457 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700458 public static final class AggregationSuggestions implements BaseColumns, ContactsColumns {
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700459 /**
460 * No public constructor since this is a utility class
461 */
462 private AggregationSuggestions() {}
463
464 /**
Dmitri Plotnikov0fc02442009-09-21 13:26:28 -0700465 * The directory twig for this sub-table. The URI can be followed by an optional
Jeff Hamiltonf8526982009-09-24 11:34:58 -0500466 * type-to-filter, similar to
467 * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}.
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700468 */
469 public static final String CONTENT_DIRECTORY = "suggestions";
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700470 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700471
472 /**
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -0700473 * A sub-directory of a single contact that contains the contact's primary photo.
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700474 */
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -0700475 public static final class Photo implements BaseColumns, DataColumns {
476 /**
477 * no public constructor since this is a utility class
478 */
479 private Photo() {}
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -0700480
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -0700481 /**
482 * The directory twig for this sub-table
483 */
484 public static final String CONTENT_DIRECTORY = "photo";
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700485 }
486
487 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500488 * Opens an InputStream for the contacts's default photo and returns the
489 * photo as a byte stream. If there is not photo null will be returned.
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700490 *
491 * @param contactUri the contact whose photo should be used
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500492 * @return an InputStream of the photo, or null if no photo is present
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700493 */
494 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -0700495 Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY);
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -0700496 if (photoUri == null) {
497 return null;
498 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700499 Cursor cursor = cr.query(photoUri,
500 new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null);
501 try {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -0700502 if (cursor == null || !cursor.moveToNext()) {
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700503 return null;
504 }
505 byte[] data = cursor.getBlob(0);
506 if (data == null) {
507 return null;
508 }
509 return new ByteArrayInputStream(data);
510 } finally {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -0700511 if (cursor != null) {
512 cursor.close();
513 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700514 }
515 }
Evan Millar088b2912009-05-28 15:24:37 -0700516 }
517
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -0700518 private interface RawContactsColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700519 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700520 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} that this
521 * data belongs to.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700522 * <P>Type: INTEGER</P>
Evan Millar088b2912009-05-28 15:24:37 -0700523 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700524 public static final String CONTACT_ID = "contact_id";
Evan Millar088b2912009-05-28 15:24:37 -0700525
526 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500527 * Flag indicating that this {@link RawContacts} entry and its children have
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700528 * been restricted to specific platform apps.
529 * <P>Type: INTEGER (boolean)</P>
530 *
531 * @hide until finalized in future platform release
532 */
533 public static final String IS_RESTRICTED = "is_restricted";
534
535 /**
536 * The aggregation mode for this contact.
537 * <P>Type: INTEGER</P>
538 */
539 public static final String AGGREGATION_MODE = "aggregation_mode";
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -0700540
541 /**
542 * The "deleted" flag: "0" by default, "1" if the row has been marked
543 * for deletion. When {@link android.content.ContentResolver#delete} is
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700544 * called on a raw contact, it is marked for deletion and removed from its
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700545 * aggregate contact. The sync adaptor deletes the raw contact on the server and
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -0700546 * then calls ContactResolver.delete once more, this time passing the
Fred Quintana33f889a2009-09-14 17:31:26 -0700547 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
548 * the data removal.
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -0700549 * <P>Type: INTEGER</P>
550 */
551 public static final String DELETED = "deleted";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700552 }
553
554 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500555 * Constants for the raw contacts table, which contains the base contact
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -0700556 * information per sync source. Sync adapters and contact management apps
557 * are the primary consumers of this API.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700558 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700559 public static final class RawContacts implements BaseColumns, RawContactsColumns,
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700560 ContactOptionsColumns, SyncColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700561 /**
562 * This utility class cannot be instantiated
563 */
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -0700564 private RawContacts() {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700565 }
566
567 /**
Evan Millar088b2912009-05-28 15:24:37 -0700568 * The content:// style URI for this table
569 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700570 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
Evan Millar088b2912009-05-28 15:24:37 -0700571
572 /**
Evan Millar088b2912009-05-28 15:24:37 -0700573 * The MIME type of {@link #CONTENT_URI} providing a directory of
574 * people.
575 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700576 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -0700577
578 /**
579 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
580 * person.
581 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700582 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -0700583
584 /**
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700585 * Aggregation mode: aggregate asynchronously.
586 */
587 public static final int AGGREGATION_MODE_DEFAULT = 0;
588
589 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700590 * Aggregation mode: aggregate at the time the raw contact is inserted/updated.
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700591 */
Omari Stephensbc9aa772009-09-08 19:10:53 -0700592 public static final int AGGREGATION_MODE_IMMEDIATE = 1;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700593
594 /**
Dmitri Plotnikov5223b162009-08-25 15:15:06 -0700595 * If {@link #AGGREGATION_MODE} is {@link #AGGREGATION_MODE_SUSPENDED}, changes
596 * to the raw contact do not cause its aggregation to be revisited. Note that changing
597 * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to
598 * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass. Any subsequent
599 * change to the raw contact's data will.
600 */
601 public static final int AGGREGATION_MODE_SUSPENDED = 2;
602
603 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700604 * Aggregation mode: never aggregate this raw contact (note that the raw contact will not
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700605 * have a corresponding Aggregate and therefore will not be included in Aggregates
606 * query results.)
607 */
Dmitri Plotnikov5223b162009-08-25 15:15:06 -0700608 public static final int AGGREGATION_MODE_DISABLED = 3;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700609
610 /**
Jeff Hamiltonf8526982009-09-24 11:34:58 -0500611 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
612 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
613 * entry of the given {@link RawContacts} entry.
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700614 */
615 public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) {
616 // TODO: use a lighter query by joining rawcontacts with contacts in provider
617 final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY);
618 final Cursor cursor = resolver.query(dataUri, new String[] {
619 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
620 }, null, null, null);
621
622 Uri lookupUri = null;
623 try {
624 if (cursor != null && cursor.moveToFirst()) {
625 final long contactId = cursor.getLong(0);
626 final String lookupKey = cursor.getString(1);
627 return Contacts.getLookupUri(contactId, lookupKey);
628 }
629 } finally {
630 if (cursor != null) cursor.close();
631 }
632 return lookupUri;
633 }
634
635 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700636 * A sub-directory of a single raw contact that contains all of their {@link Data} rows.
Dmitri Plotnikov5223b162009-08-25 15:15:06 -0700637 * To access this directory append {@link Data#CONTENT_DIRECTORY} to the contact URI.
Evan Millar088b2912009-05-28 15:24:37 -0700638 */
639 public static final class Data implements BaseColumns, DataColumns {
640 /**
641 * no public constructor since this is a utility class
642 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700643 private Data() {
644 }
Evan Millar088b2912009-05-28 15:24:37 -0700645
646 /**
647 * The directory twig for this sub-table
648 */
649 public static final String CONTENT_DIRECTORY = "data";
650 }
651 }
652
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700653 private interface StatusColumns extends Im.CommonPresenceColumns {
654 /**
Dmitri Plotnikova60479d2009-09-27 20:16:31 -0700655 * Contact's latest presence level.
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700656 * <P>Type: INTEGER (one of the values below)</P>
657 */
658 public static final String PRESENCE = PRESENCE_STATUS;
659
660 /**
661 * Contact latest status update.
662 * <p>Type: TEXT</p>
663 */
664 public static final String STATUS = PRESENCE_CUSTOM_STATUS;
665
666 /**
667 * The absolute time in milliseconds when the latest status was inserted/updated.
668 * <p>Type: NUMBER</p>
669 */
670 public static final String STATUS_TIMESTAMP = "status_ts";
671
672 /**
673 * The package containing resources for this status: label and icon.
674 * <p>Type: NUMBER</p>
675 */
676 public static final String STATUS_RES_PACKAGE = "status_res_package";
677
678 /**
679 * The resource ID of the label describing the source of the status update, e.g. "Google
680 * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
681 * <p>Type: NUMBER</p>
682 */
683 public static final String STATUS_LABEL = "status_label";
684
685 /**
686 * The resource ID of the icon for the source of the status update.
687 * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
688 * <p>Type: NUMBER</p>
689 */
690 public static final String STATUS_ICON = "status_icon";
691 }
692
Evan Millar088b2912009-05-28 15:24:37 -0700693 private interface DataColumns {
694 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700695 * The package name to use when creating {@link Resources} objects for
696 * this data row. This value is only designed for use when building user
697 * interfaces, and should not be used to infer the owner.
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500698 *
699 * @hide
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700700 */
701 public static final String RES_PACKAGE = "res_package";
702
703 /**
704 * The MIME type of the item represented by this row.
Evan Millar088b2912009-05-28 15:24:37 -0700705 */
706 public static final String MIMETYPE = "mimetype";
707
708 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700709 * A reference to the {@link RawContacts#_ID}
Dmitri Plotnikov56927772009-05-28 17:23:39 -0700710 * that this data belongs to.
Evan Millar088b2912009-05-28 15:24:37 -0700711 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700712 public static final String RAW_CONTACT_ID = "raw_contact_id";
713
Evan Millarab5742d2009-06-02 16:21:45 -0700714 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700715 * Whether this is the primary entry of its kind for the raw contact it belongs to
Evan Millarab5742d2009-06-02 16:21:45 -0700716 * <P>Type: INTEGER (if set, non-0 means true)</P>
717 */
718 public static final String IS_PRIMARY = "is_primary";
719
720 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700721 * Whether this is the primary entry of its kind for the aggregate
722 * contact it belongs to. Any data record that is "super primary" must
723 * also be "primary".
Evan Millarab5742d2009-06-02 16:21:45 -0700724 * <P>Type: INTEGER (if set, non-0 means true)</P>
725 */
726 public static final String IS_SUPER_PRIMARY = "is_super_primary";
727
Jeff Sharkey28b68e52009-06-10 15:26:58 -0700728 /**
Fred Quintanac933fb62009-06-11 12:14:40 -0700729 * The version of this data record. This is a read-only value. The data column is
730 * guaranteed to not change without the version going up. This value is monotonically
731 * increasing.
732 * <P>Type: INTEGER</P>
733 */
734 public static final String DATA_VERSION = "data_version";
735
Evan Millar088b2912009-05-28 15:24:37 -0700736 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
737 public static final String DATA1 = "data1";
738 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
739 public static final String DATA2 = "data2";
740 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
741 public static final String DATA3 = "data3";
742 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
743 public static final String DATA4 = "data4";
744 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
745 public static final String DATA5 = "data5";
746 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
747 public static final String DATA6 = "data6";
748 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
749 public static final String DATA7 = "data7";
750 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
751 public static final String DATA8 = "data8";
752 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
753 public static final String DATA9 = "data9";
754 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
755 public static final String DATA10 = "data10";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700756 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
757 public static final String DATA11 = "data11";
758 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
759 public static final String DATA12 = "data12";
760 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
761 public static final String DATA13 = "data13";
762 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
763 public static final String DATA14 = "data14";
764 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
765 public static final String DATA15 = "data15";
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700766
Fred Quintana8851e162009-08-05 21:06:45 -0700767 /** Generic column for use by sync adapters. */
768 public static final String SYNC1 = "data_sync1";
769 /** Generic column for use by sync adapters. */
770 public static final String SYNC2 = "data_sync2";
771 /** Generic column for use by sync adapters. */
772 public static final String SYNC3 = "data_sync3";
773 /** Generic column for use by sync adapters. */
774 public static final String SYNC4 = "data_sync4";
Evan Millar088b2912009-05-28 15:24:37 -0700775 }
776
777 /**
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -0700778 * Combines all columns returned by {@link Data} table queries.
779 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700780 private interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns,
781 RawContactsColumns, ContactsColumns, ContactOptionsColumns, ContactStatusColumns {
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -0700782
783 }
784
785 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700786 * Constants for the data table, which contains data points tied to a raw contact.
Evan Millar088b2912009-05-28 15:24:37 -0700787 * For example, a phone number or email address. Each row in this table contains a type
788 * definition and some generic columns. Each data type can define the meaning for each of
789 * the generic columns.
790 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -0700791 public final static class Data implements DataColumnsWithJoins {
Evan Millar088b2912009-05-28 15:24:37 -0700792 /**
793 * This utility class cannot be instantiated
794 */
795 private Data() {}
796
797 /**
798 * The content:// style URI for this table
799 */
800 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
801
802 /**
803 * The MIME type of {@link #CONTENT_URI} providing a directory of data.
804 */
805 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700806
807 /**
Daisuke Miyakawaf2e0d7b2009-09-28 06:28:26 -0700808 * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
809 * Data.CONTENT_URI contains only exportable data.
810 *
811 * This flag is useful (currently) only for vCard exporter in Contacts app, which
812 * needs to exclude "un-exportable" data from available data to export, while
813 * Contacts app itself has priviledge to access all data including "un-expotable"
814 * ones and providers return all of them regardless of the callers' intention.
815 * <P>Type: INTEGER</p>
816 *
817 * @hide Maybe available only in Eclair and not really ready for public use.
818 * TODO: remove, or implement this feature completely. As of now (Eclair),
819 * we only use this flag in queryEntities(), not query().
820 */
821 public static final String FOR_EXPORT_ONLY = "for_export_only";
822
823 /**
Jeff Hamiltonf8526982009-09-24 11:34:58 -0500824 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
825 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
826 * entry of the given {@link Data} entry.
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700827 */
828 public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) {
829 final Cursor cursor = resolver.query(dataUri, new String[] {
830 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
831 }, null, null, null);
832
833 Uri lookupUri = null;
834 try {
835 if (cursor != null && cursor.moveToFirst()) {
836 final long contactId = cursor.getLong(0);
837 final String lookupKey = cursor.getString(1);
838 return Contacts.getLookupUri(contactId, lookupKey);
839 }
840 } finally {
841 if (cursor != null) cursor.close();
842 }
843 return lookupUri;
844 }
Evan Millar088b2912009-05-28 15:24:37 -0700845 }
846
Dmitri Plotnikov93032952009-08-19 11:26:57 -0700847 private interface PhoneLookupColumns {
848 /**
849 * The phone number as the user entered it.
850 * <P>Type: TEXT</P>
851 */
852 public static final String NUMBER = "number";
853
854 /**
855 * The type of phone number, for example Home or Work.
856 * <P>Type: INTEGER</P>
857 */
858 public static final String TYPE = "type";
859
860 /**
861 * The user defined label for the phone number.
862 * <P>Type: TEXT</P>
863 */
864 public static final String LABEL = "label";
865 }
866
Evan Millar088b2912009-05-28 15:24:37 -0700867 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700868 * A table that represents the result of looking up a phone number, for
Dmitri Plotnikov93032952009-08-19 11:26:57 -0700869 * example for caller ID. To perform a lookup you must append the number you
870 * want to find to {@link #CONTENT_FILTER_URI}.
Evan Millar088b2912009-05-28 15:24:37 -0700871 */
Dmitri Plotnikov93032952009-08-19 11:26:57 -0700872 public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
873 ContactsColumns, ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700874 /**
875 * This utility class cannot be instantiated
876 */
877 private PhoneLookup() {}
878
879 /**
880 * The content:// style URI for this table. Append the phone number you want to lookup
881 * to this URI and query it to perform a lookup. For example:
882 *
883 * {@code
884 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, phoneNumber);
885 * }
886 */
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700887 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
888 "phone_lookup");
889 }
890
891 /**
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700892 * Additional data mixed in with {@link StatusColumns} to link
893 * back to specific {@link ContactsContract.Data#_ID} entries.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700894 */
895 private interface PresenceColumns {
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700896
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700897 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700898 * Reference to the {@link Data#_ID} entry that owns this presence.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700899 * <P>Type: INTEGER</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700900 */
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -0700901 public static final String DATA_ID = "presence_data_id";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700902
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700903 /**
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -0700904 * <p>Type: NUMBER</p>
905 */
906 public static final String PROTOCOL = "protocol";
907
908 /**
909 * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value
910 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or
911 * omitted if {@link #PROTOCOL} value is not
912 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.
913 *
914 * <p>Type: NUMBER</p>
915 */
916 public static final String CUSTOM_PROTOCOL = "custom_protocol";
917
918 /**
919 * The IM handle the presence item is for. The handle is scoped to
920 * {@link #PROTOCOL}.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700921 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700922 */
923 public static final String IM_HANDLE = "im_handle";
924
925 /**
926 * The IM account for the local user that the presence data came from.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700927 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700928 */
929 public static final String IM_ACCOUNT = "im_account";
930 }
931
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700932 /**
933 * A status update is linked to a {@link Data} row and captures the user's latest status
934 * update via the corresponding source, e.g. "Having lunch" via "Google Talk".
935 */
936 // TODO make final as soon as Presence is removed
937 public static /*final*/ class StatusUpdates implements StatusColumns, PresenceColumns {
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -0700938
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700939 /**
940 * This utility class cannot be instantiated
941 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700942 private StatusUpdates() {}
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700943
944 /**
945 * The content:// style URI for this table
946 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700947 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates");
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500948
949 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700950 * Gets the resource ID for the proper presence icon.
951 *
952 * @param status the status to get the icon for
953 * @return the resource ID for the proper presence icon
954 */
955 public static final int getPresenceIconResourceId(int status) {
956 switch (status) {
957 case AVAILABLE:
958 return android.R.drawable.presence_online;
959 case IDLE:
960 case AWAY:
961 return android.R.drawable.presence_away;
962 case DO_NOT_DISTURB:
963 return android.R.drawable.presence_busy;
964 case INVISIBLE:
965 return android.R.drawable.presence_invisible;
966 case OFFLINE:
967 default:
968 return android.R.drawable.presence_offline;
969 }
970 }
971
972 /**
Evan Millarc0437522009-06-23 17:31:05 -0700973 * Returns the precedence of the status code the higher number being the higher precedence.
974 *
975 * @param status The status code.
976 * @return An integer representing the precedence, 0 being the lowest.
977 */
978 public static final int getPresencePrecedence(int status) {
979 // Keep this function here incase we want to enforce a different precedence than the
980 // natural order of the status constants.
981 return status;
982 }
983
984 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700985 * The MIME type of {@link #CONTENT_URI} providing a directory of
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700986 * status update details.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700987 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700988 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700989
990 /**
991 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700992 * status update detail.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700993 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700994 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update";
995 }
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -0700996
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700997 @Deprecated
998 public static final class Presence extends StatusUpdates {
999
Evan Millar088b2912009-05-28 15:24:37 -07001000 }
1001
1002 /**
1003 * Container for definitions of common data types stored in the {@link Data} table.
1004 */
1005 public static final class CommonDataKinds {
1006 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001007 * This utility class cannot be instantiated
1008 */
1009 private CommonDataKinds() {}
1010
1011 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001012 * The {@link Data#RES_PACKAGE} value for common data that should be
1013 * shown using a default style.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001014 *
1015 * @hide RES_PACKAGE is hidden
Evan Millar088b2912009-05-28 15:24:37 -07001016 */
1017 public static final String PACKAGE_COMMON = "common";
1018
1019 /**
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001020 * The base types that all "Typed" data kinds support.
1021 */
1022 public interface BaseTypes {
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001023 /**
1024 * A custom type. The custom label should be supplied by user.
1025 */
1026 public static int TYPE_CUSTOM = 0;
1027 }
1028
1029 /**
Evan Millar088b2912009-05-28 15:24:37 -07001030 * Columns common across the specific types.
1031 */
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001032 private interface CommonColumns extends BaseTypes {
Evan Millar088b2912009-05-28 15:24:37 -07001033 /**
Evan Millar088b2912009-05-28 15:24:37 -07001034 * The data for the contact method.
1035 * <P>Type: TEXT</P>
1036 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001037 public static final String DATA = DataColumns.DATA1;
1038
1039 /**
1040 * The type of data, for example Home or Work.
1041 * <P>Type: INTEGER</P>
1042 */
1043 public static final String TYPE = DataColumns.DATA2;
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07001044
1045 /**
1046 * The user defined label for the the contact method.
1047 * <P>Type: TEXT</P>
1048 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001049 public static final String LABEL = DataColumns.DATA3;
Evan Millar088b2912009-05-28 15:24:37 -07001050 }
1051
1052 /**
1053 * Parts of the name.
1054 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001055 public static final class StructuredName implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001056 /**
1057 * This utility class cannot be instantiated
1058 */
Evan Millar088b2912009-05-28 15:24:37 -07001059 private StructuredName() {}
1060
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001061 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001062 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
1063
1064 /**
Evan Millar088b2912009-05-28 15:24:37 -07001065 * The name that should be used to display the contact.
Jeff Sharkey62b83b72009-08-11 17:33:48 -07001066 * <i>Unstructured component of the name should be consistent with
1067 * its structured representation.</i>
1068 * <p>
1069 * Type: TEXT
Evan Millar088b2912009-05-28 15:24:37 -07001070 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001071 public static final String DISPLAY_NAME = DATA1;
1072
1073 /**
1074 * The given name for the contact.
1075 * <P>Type: TEXT</P>
1076 */
1077 public static final String GIVEN_NAME = DATA2;
1078
1079 /**
1080 * The family name for the contact.
1081 * <P>Type: TEXT</P>
1082 */
1083 public static final String FAMILY_NAME = DATA3;
1084
1085 /**
1086 * The contact's honorific prefix, e.g. "Sir"
1087 * <P>Type: TEXT</P>
1088 */
1089 public static final String PREFIX = DATA4;
1090
1091 /**
1092 * The contact's middle name
1093 * <P>Type: TEXT</P>
1094 */
1095 public static final String MIDDLE_NAME = DATA5;
1096
1097 /**
1098 * The contact's honorific suffix, e.g. "Jr"
1099 */
1100 public static final String SUFFIX = DATA6;
1101
1102 /**
1103 * The phonetic version of the given name for the contact.
1104 * <P>Type: TEXT</P>
1105 */
1106 public static final String PHONETIC_GIVEN_NAME = DATA7;
1107
1108 /**
1109 * The phonetic version of the additional name for the contact.
1110 * <P>Type: TEXT</P>
1111 */
1112 public static final String PHONETIC_MIDDLE_NAME = DATA8;
1113
1114 /**
1115 * The phonetic version of the family name for the contact.
1116 * <P>Type: TEXT</P>
1117 */
1118 public static final String PHONETIC_FAMILY_NAME = DATA9;
Evan Millar088b2912009-05-28 15:24:37 -07001119 }
1120
1121 /**
1122 * A nickname.
1123 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001124 public static final class Nickname implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001125 /**
1126 * This utility class cannot be instantiated
1127 */
Evan Millar088b2912009-05-28 15:24:37 -07001128 private Nickname() {}
1129
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001130 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001131 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
1132
Evan Millar78e79ad2009-06-08 10:24:44 -07001133 public static final int TYPE_DEFAULT = 1;
1134 public static final int TYPE_OTHER_NAME = 2;
1135 public static final int TYPE_MAINDEN_NAME = 3;
1136 public static final int TYPE_SHORT_NAME = 4;
1137 public static final int TYPE_INITIALS = 5;
Evan Millar088b2912009-05-28 15:24:37 -07001138
1139 /**
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07001140 * The name itself
1141 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001142 public static final String NAME = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07001143 }
1144
1145 /**
1146 * Common data definition for telephone numbers.
1147 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001148 public static final class Phone implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001149 /**
1150 * This utility class cannot be instantiated
1151 */
Evan Millar088b2912009-05-28 15:24:37 -07001152 private Phone() {}
1153
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001154 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07001155 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
Evan Millar088b2912009-05-28 15:24:37 -07001156
Evan Millar161dd862009-06-12 16:02:43 -07001157 /**
1158 * The MIME type of {@link #CONTENT_URI} providing a directory of
1159 * phones.
1160 */
Evan Millarb3c49982009-09-01 11:38:04 -07001161 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
Evan Millar161dd862009-06-12 16:02:43 -07001162
1163 /**
1164 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001165 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001166 * associated raw contact and aggregate contact data.
Evan Millar161dd862009-06-12 16:02:43 -07001167 */
1168 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1169 "phones");
1170
1171 /**
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001172 * The content:// style URL for phone lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001173 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001174 * to display names as well as phone numbers. The filter argument should be passed
1175 * as an additional path segment after this URI.
Evan Millar161dd862009-06-12 16:02:43 -07001176 */
1177 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
1178 "filter");
1179
Evan Millar088b2912009-05-28 15:24:37 -07001180 public static final int TYPE_HOME = 1;
1181 public static final int TYPE_MOBILE = 2;
1182 public static final int TYPE_WORK = 3;
1183 public static final int TYPE_FAX_WORK = 4;
1184 public static final int TYPE_FAX_HOME = 5;
1185 public static final int TYPE_PAGER = 6;
1186 public static final int TYPE_OTHER = 7;
Fred Quintana3f867152009-08-03 11:43:16 -07001187 public static final int TYPE_CALLBACK = 8;
1188 public static final int TYPE_CAR = 9;
1189 public static final int TYPE_COMPANY_MAIN = 10;
1190 public static final int TYPE_ISDN = 11;
1191 public static final int TYPE_MAIN = 12;
1192 public static final int TYPE_OTHER_FAX = 13;
1193 public static final int TYPE_RADIO = 14;
1194 public static final int TYPE_TELEX = 15;
1195 public static final int TYPE_TTY_TDD = 16;
1196 public static final int TYPE_WORK_MOBILE = 17;
1197 public static final int TYPE_WORK_PAGER = 18;
1198 public static final int TYPE_ASSISTANT = 19;
Jeff Sharkeyd5abd462009-09-16 19:54:29 -07001199 public static final int TYPE_MMS = 20;
Evan Millar088b2912009-05-28 15:24:37 -07001200
1201 /**
1202 * The phone number as the user entered it.
1203 * <P>Type: TEXT</P>
1204 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001205 public static final String NUMBER = DATA;
Dmitri Plotnikov93032952009-08-19 11:26:57 -07001206
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001207 /**
1208 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001209 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001210 */
1211 @Deprecated
Dmitri Plotnikov93032952009-08-19 11:26:57 -07001212 public static final CharSequence getDisplayLabel(Context context, int type,
1213 CharSequence label, CharSequence[] labelArray) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001214 return getTypeLabel(context.getResources(), type, label);
Dmitri Plotnikov93032952009-08-19 11:26:57 -07001215 }
1216
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001217 /**
1218 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001219 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001220 */
1221 @Deprecated
Dmitri Plotnikov93032952009-08-19 11:26:57 -07001222 public static final CharSequence getDisplayLabel(Context context, int type,
1223 CharSequence label) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001224 return getTypeLabel(context.getResources(), type, label);
1225 }
1226
1227 /**
1228 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001229 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001230 */
1231 public static final int getTypeLabelResource(int type) {
1232 switch (type) {
1233 case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome;
1234 case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile;
1235 case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork;
1236 case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork;
1237 case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome;
1238 case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager;
1239 case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther;
1240 case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback;
1241 case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar;
1242 case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain;
1243 case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn;
1244 case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain;
1245 case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax;
1246 case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio;
1247 case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex;
1248 case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd;
1249 case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile;
1250 case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager;
1251 case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant;
1252 case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms;
1253 default: return com.android.internal.R.string.phoneTypeCustom;
1254 }
1255 }
1256
1257 /**
1258 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001259 * possibly substituting the given {@link #LABEL} value
1260 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001261 */
1262 public static final CharSequence getTypeLabel(Resources res, int type,
1263 CharSequence label) {
1264 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) {
1265 return label;
1266 } else {
1267 final int labelRes = getTypeLabelResource(type);
1268 return res.getText(labelRes);
1269 }
Dmitri Plotnikov93032952009-08-19 11:26:57 -07001270 }
Evan Millar088b2912009-05-28 15:24:37 -07001271 }
1272
1273 /**
1274 * Common data definition for email addresses.
1275 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001276 public static final class Email implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001277 /**
1278 * This utility class cannot be instantiated
1279 */
Evan Millar088b2912009-05-28 15:24:37 -07001280 private Email() {}
1281
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001282 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07001283 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2";
Evan Millar088b2912009-05-28 15:24:37 -07001284
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001285 /**
Dmitri Plotnikovabf15c32009-09-18 20:29:11 -07001286 * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses.
1287 */
1288 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2";
1289
1290 /**
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001291 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001292 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001293 * associated raw contact and aggregate contact data.
1294 */
1295 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1296 "emails");
1297
1298 /**
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001299 * The content:// style URL for looking up data rows by email address. The
1300 * lookup argument, an email address, should be passed as an additional path segment
1301 * after this URI.
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001302 */
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001303 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
1304 "lookup");
1305
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001306 /**
1307 * The content:// style URL for email lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001308 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001309 * to display names as well as email addresses. The filter argument should be passed
1310 * as an additional path segment after this URI.
1311 */
1312 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001313 "filter");
1314
Evan Millar088b2912009-05-28 15:24:37 -07001315 public static final int TYPE_HOME = 1;
1316 public static final int TYPE_WORK = 2;
1317 public static final int TYPE_OTHER = 3;
Jeff Sharkey14fb1532009-08-29 15:54:26 -07001318 public static final int TYPE_MOBILE = 4;
Fred Quintana8851e162009-08-05 21:06:45 -07001319
1320 /**
1321 * The display name for the email address
1322 * <P>Type: TEXT</P>
1323 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001324 public static final String DISPLAY_NAME = DATA4;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001325
1326 /**
1327 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001328 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001329 */
1330 public static final int getTypeLabelResource(int type) {
1331 switch (type) {
1332 case TYPE_HOME: return com.android.internal.R.string.emailTypeHome;
1333 case TYPE_WORK: return com.android.internal.R.string.emailTypeWork;
1334 case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther;
1335 case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile;
1336 default: return com.android.internal.R.string.emailTypeCustom;
1337 }
1338 }
1339
1340 /**
1341 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001342 * possibly substituting the given {@link #LABEL} value
1343 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001344 */
1345 public static final CharSequence getTypeLabel(Resources res, int type,
1346 CharSequence label) {
1347 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
1348 return label;
1349 } else {
1350 final int labelRes = getTypeLabelResource(type);
1351 return res.getText(labelRes);
1352 }
1353 }
Evan Millar088b2912009-05-28 15:24:37 -07001354 }
1355
1356 /**
1357 * Common data definition for postal addresses.
1358 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001359 public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001360 /**
1361 * This utility class cannot be instantiated
1362 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001363 private StructuredPostal() {
1364 }
Evan Millar088b2912009-05-28 15:24:37 -07001365
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001366 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07001367 public static final String CONTENT_ITEM_TYPE =
1368 "vnd.android.cursor.item/postal-address_v2";
Evan Millar088b2912009-05-28 15:24:37 -07001369
Evan Millar161dd862009-06-12 16:02:43 -07001370 /**
1371 * The MIME type of {@link #CONTENT_URI} providing a directory of
1372 * postal addresses.
1373 */
Evan Millarb3c49982009-09-01 11:38:04 -07001374 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2";
Evan Millar161dd862009-06-12 16:02:43 -07001375
1376 /**
1377 * The content:// style URI for all data records of the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001378 * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
Evan Millar161dd862009-06-12 16:02:43 -07001379 */
1380 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1381 "postals");
1382
Evan Millar088b2912009-05-28 15:24:37 -07001383 public static final int TYPE_HOME = 1;
1384 public static final int TYPE_WORK = 2;
1385 public static final int TYPE_OTHER = 3;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001386
1387 /**
Jeff Sharkey62b83b72009-08-11 17:33:48 -07001388 * The full, unstructured postal address. <i>This field must be
1389 * consistent with any structured data.</i>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001390 * <p>
1391 * Type: TEXT
1392 */
1393 public static final String FORMATTED_ADDRESS = DATA;
1394
1395 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001396 * Can be street, avenue, road, etc. This element also includes the
1397 * house number and room/apartment/flat/floor number.
1398 * <p>
1399 * Type: TEXT
1400 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001401 public static final String STREET = DATA4;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001402
1403 /**
1404 * Covers actual P.O. boxes, drawers, locked bags, etc. This is
1405 * usually but not always mutually exclusive with street.
1406 * <p>
1407 * Type: TEXT
1408 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001409 public static final String POBOX = DATA5;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001410
1411 /**
1412 * This is used to disambiguate a street address when a city
1413 * contains more than one street with the same name, or to specify a
1414 * small place whose mail is routed through a larger postal town. In
1415 * China it could be a county or a minor city.
1416 * <p>
1417 * Type: TEXT
1418 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001419 public static final String NEIGHBORHOOD = DATA6;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001420
1421 /**
1422 * Can be city, village, town, borough, etc. This is the postal town
1423 * and not necessarily the place of residence or place of business.
1424 * <p>
1425 * Type: TEXT
1426 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001427 public static final String CITY = DATA7;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001428
1429 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001430 * A state, province, county (in Ireland), Land (in Germany),
1431 * departement (in France), etc.
1432 * <p>
1433 * Type: TEXT
1434 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001435 public static final String REGION = DATA8;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001436
1437 /**
Jeff Sharkeyef348c72009-07-26 14:14:34 -07001438 * Postal code. Usually country-wide, but sometimes specific to the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001439 * city (e.g. "2" in "Dublin 2, Ireland" addresses).
1440 * <p>
1441 * Type: TEXT
1442 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001443 public static final String POSTCODE = DATA9;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001444
1445 /**
1446 * The name or code of the country.
1447 * <p>
1448 * Type: TEXT
1449 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001450 public static final String COUNTRY = DATA10;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001451
1452 /**
1453 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001454 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001455 */
1456 public static final int getTypeLabelResource(int type) {
1457 switch (type) {
1458 case TYPE_HOME: return com.android.internal.R.string.postalTypeHome;
1459 case TYPE_WORK: return com.android.internal.R.string.postalTypeWork;
1460 case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther;
1461 default: return com.android.internal.R.string.postalTypeCustom;
1462 }
1463 }
1464
1465 /**
1466 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001467 * possibly substituting the given {@link #LABEL} value
1468 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001469 */
1470 public static final CharSequence getTypeLabel(Resources res, int type,
1471 CharSequence label) {
1472 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
1473 return label;
1474 } else {
1475 final int labelRes = getTypeLabelResource(type);
1476 return res.getText(labelRes);
1477 }
1478 }
Evan Millar088b2912009-05-28 15:24:37 -07001479 }
1480
Fred Quintana8851e162009-08-05 21:06:45 -07001481 /**
1482 * Common data definition for IM addresses.
1483 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001484 public static final class Im implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001485 /**
1486 * This utility class cannot be instantiated
1487 */
Evan Millar088b2912009-05-28 15:24:37 -07001488 private Im() {}
1489
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001490 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001491 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
1492
Evan Millar088b2912009-05-28 15:24:37 -07001493 public static final int TYPE_HOME = 1;
1494 public static final int TYPE_WORK = 2;
1495 public static final int TYPE_OTHER = 3;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07001496
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07001497 /**
1498 * This column should be populated with one of the defined
1499 * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this
1500 * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL}
1501 * should contain the name of the custom protocol.
1502 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001503 public static final String PROTOCOL = DATA5;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07001504
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001505 public static final String CUSTOM_PROTOCOL = DATA6;
Jeff Sharkey732da922009-07-30 09:59:31 -07001506
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07001507 /*
1508 * The predefined IM protocol types.
Evan Millar088b2912009-05-28 15:24:37 -07001509 */
Jeff Sharkey732da922009-07-30 09:59:31 -07001510 public static final int PROTOCOL_CUSTOM = -1;
Evan Millar088b2912009-05-28 15:24:37 -07001511 public static final int PROTOCOL_AIM = 0;
1512 public static final int PROTOCOL_MSN = 1;
1513 public static final int PROTOCOL_YAHOO = 2;
1514 public static final int PROTOCOL_SKYPE = 3;
1515 public static final int PROTOCOL_QQ = 4;
1516 public static final int PROTOCOL_GOOGLE_TALK = 5;
1517 public static final int PROTOCOL_ICQ = 6;
1518 public static final int PROTOCOL_JABBER = 7;
Fred Quintana8851e162009-08-05 21:06:45 -07001519 public static final int PROTOCOL_NETMEETING = 8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001520
1521 /**
1522 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001523 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001524 */
1525 public static final int getTypeLabelResource(int type) {
1526 switch (type) {
1527 case TYPE_HOME: return com.android.internal.R.string.imTypeHome;
1528 case TYPE_WORK: return com.android.internal.R.string.imTypeWork;
1529 case TYPE_OTHER: return com.android.internal.R.string.imTypeOther;
1530 default: return com.android.internal.R.string.imTypeCustom;
1531 }
1532 }
1533
1534 /**
1535 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001536 * possibly substituting the given {@link #LABEL} value
1537 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001538 */
1539 public static final CharSequence getTypeLabel(Resources res, int type,
1540 CharSequence label) {
1541 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
1542 return label;
1543 } else {
1544 final int labelRes = getTypeLabelResource(type);
1545 return res.getText(labelRes);
1546 }
1547 }
1548
1549 /**
1550 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001551 * {@link #PROTOCOL}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001552 */
1553 public static final int getProtocolLabelResource(int type) {
1554 switch (type) {
1555 case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim;
1556 case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn;
1557 case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo;
1558 case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype;
1559 case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq;
1560 case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk;
1561 case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq;
1562 case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber;
1563 case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting;
1564 default: return com.android.internal.R.string.imProtocolCustom;
1565 }
1566 }
1567
1568 /**
1569 * Return a {@link CharSequence} that best describes the given
1570 * protocol, possibly substituting the given
1571 * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}.
1572 */
1573 public static final CharSequence getProtocolLabel(Resources res, int type,
1574 CharSequence label) {
1575 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) {
1576 return label;
1577 } else {
1578 final int labelRes = getProtocolLabelResource(type);
1579 return res.getText(labelRes);
1580 }
1581 }
Evan Millar088b2912009-05-28 15:24:37 -07001582 }
1583
1584 /**
1585 * Common data definition for organizations.
1586 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001587 public static final class Organization implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001588 /**
1589 * This utility class cannot be instantiated
1590 */
Evan Millar088b2912009-05-28 15:24:37 -07001591 private Organization() {}
1592
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001593 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001594 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
1595
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001596 public static final int TYPE_WORK = 1;
1597 public static final int TYPE_OTHER = 2;
Evan Millar088b2912009-05-28 15:24:37 -07001598
1599 /**
1600 * The company as the user entered it.
1601 * <P>Type: TEXT</P>
1602 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001603 public static final String COMPANY = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07001604
1605 /**
1606 * The position title at this company as the user entered it.
1607 * <P>Type: TEXT</P>
1608 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001609 public static final String TITLE = DATA4;
Fred Quintana8851e162009-08-05 21:06:45 -07001610
1611 /**
1612 * The department at this company as the user entered it.
1613 * <P>Type: TEXT</P>
1614 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001615 public static final String DEPARTMENT = DATA5;
Fred Quintana8851e162009-08-05 21:06:45 -07001616
1617 /**
1618 * The job description at this company as the user entered it.
1619 * <P>Type: TEXT</P>
1620 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001621 public static final String JOB_DESCRIPTION = DATA6;
Fred Quintana8851e162009-08-05 21:06:45 -07001622
1623 /**
1624 * The symbol of this company as the user entered it.
1625 * <P>Type: TEXT</P>
1626 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001627 public static final String SYMBOL = DATA7;
Fred Quintana8851e162009-08-05 21:06:45 -07001628
1629 /**
1630 * The phonetic name of this company as the user entered it.
1631 * <P>Type: TEXT</P>
1632 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001633 public static final String PHONETIC_NAME = DATA8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001634
1635 /**
1636 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001637 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001638 */
1639 public static final int getTypeLabelResource(int type) {
1640 switch (type) {
1641 case TYPE_WORK: return com.android.internal.R.string.orgTypeWork;
1642 case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther;
1643 default: return com.android.internal.R.string.orgTypeCustom;
1644 }
1645 }
1646
1647 /**
1648 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001649 * possibly substituting the given {@link #LABEL} value
1650 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001651 */
1652 public static final CharSequence getTypeLabel(Resources res, int type,
1653 CharSequence label) {
1654 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
1655 return label;
1656 } else {
1657 final int labelRes = getTypeLabelResource(type);
1658 return res.getText(labelRes);
1659 }
1660 }
Fred Quintana8851e162009-08-05 21:06:45 -07001661 }
1662
1663 /**
Fred Quintanaf5808412009-09-24 15:37:39 -07001664 * Common data definition for birthdays.
Fred Quintana8851e162009-08-05 21:06:45 -07001665 */
Fred Quintanaf5808412009-09-24 15:37:39 -07001666 public static final class Birthday implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001667 /**
1668 * This utility class cannot be instantiated
1669 */
Fred Quintanaf5808412009-09-24 15:37:39 -07001670 private Birthday() {}
Fred Quintana8851e162009-08-05 21:06:45 -07001671
1672 /** MIME type used when storing this in data table. */
Fred Quintanaf5808412009-09-24 15:37:39 -07001673 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/birthday";
Fred Quintana8851e162009-08-05 21:06:45 -07001674
1675 /**
Fred Quintanaf5808412009-09-24 15:37:39 -07001676 * The birthday. This must be of the form YYYY-MM-DD or YYYY-MM-DDThh:mm:ss
1677 * These are xs:date and xs:dateTime
Fred Quintana8851e162009-08-05 21:06:45 -07001678 * <P>Type: TEXT</P>
1679 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001680 public static final String BIRTHDAY = DATA1;
Fred Quintana8851e162009-08-05 21:06:45 -07001681 }
1682
1683 /**
1684 * Common data definition for relations.
1685 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001686 public static final class Relation implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001687 /**
1688 * This utility class cannot be instantiated
1689 */
Fred Quintana8851e162009-08-05 21:06:45 -07001690 private Relation() {}
1691
1692 /** MIME type used when storing this in data table. */
1693 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
1694
1695 public static final int TYPE_ASSISTANT = 1;
1696 public static final int TYPE_BROTHER = 2;
1697 public static final int TYPE_CHILD = 3;
1698 public static final int TYPE_DOMESTIC_PARTNER = 4;
1699 public static final int TYPE_FATHER = 5;
1700 public static final int TYPE_FRIEND = 6;
1701 public static final int TYPE_MANAGER = 7;
1702 public static final int TYPE_MOTHER = 8;
1703 public static final int TYPE_PARENT = 9;
1704 public static final int TYPE_PARTNER = 10;
1705 public static final int TYPE_REFERRED_BY = 11;
1706 public static final int TYPE_RELATIVE = 12;
1707 public static final int TYPE_SISTER = 13;
1708 public static final int TYPE_SPOUSE = 14;
1709
1710 /**
1711 * The name of the relative as the user entered it.
1712 * <P>Type: TEXT</P>
1713 */
1714 public static final String NAME = DATA;
1715 }
1716
1717 /**
1718 * Common data definition for events.
1719 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001720 public static final class Event implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001721 /**
1722 * This utility class cannot be instantiated
1723 */
Fred Quintana8851e162009-08-05 21:06:45 -07001724 private Event() {}
1725
1726 /** MIME type used when storing this in data table. */
1727 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/event";
1728
1729 public static final int TYPE_ANNIVERSARY = 1;
1730 public static final int TYPE_OTHER = 2;
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001731
Fred Quintana8851e162009-08-05 21:06:45 -07001732 /**
1733 * The event start date as the user entered it.
1734 * <P>Type: TEXT</P>
1735 */
1736 public static final String START_DATE = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07001737 }
1738
1739 /**
1740 * Photo of the contact.
1741 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001742 public static final class Photo implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001743 /**
1744 * This utility class cannot be instantiated
1745 */
Evan Millar088b2912009-05-28 15:24:37 -07001746 private Photo() {}
1747
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001748 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001749 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
1750
1751 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07001752 * Thumbnail photo of the raw contact. This is the raw bytes of an image
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07001753 * that could be inflated using {@link android.graphics.BitmapFactory}.
Evan Millar088b2912009-05-28 15:24:37 -07001754 * <p>
1755 * Type: BLOB
1756 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001757 public static final String PHOTO = DATA15;
Evan Millar088b2912009-05-28 15:24:37 -07001758 }
1759
1760 /**
1761 * Notes about the contact.
1762 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001763 public static final class Note implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001764 /**
1765 * This utility class cannot be instantiated
1766 */
Evan Millar088b2912009-05-28 15:24:37 -07001767 private Note() {}
1768
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001769 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001770 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
1771
1772 /**
1773 * The note text.
1774 * <P>Type: TEXT</P>
1775 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001776 public static final String NOTE = DATA1;
Evan Millar088b2912009-05-28 15:24:37 -07001777 }
Dmitri Plotnikov56927772009-05-28 17:23:39 -07001778
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07001779 /**
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001780 * Group Membership.
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001781 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001782 public static final class GroupMembership implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001783 /**
1784 * This utility class cannot be instantiated
1785 */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001786 private GroupMembership() {}
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001787
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001788 /** MIME type used when storing this in data table. */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001789 public static final String CONTENT_ITEM_TYPE =
1790 "vnd.android.cursor.item/group_membership";
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001791
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001792 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07001793 * The row id of the group that this group membership refers to. Exactly one of
1794 * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001795 * <P>Type: INTEGER</P>
1796 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001797 public static final String GROUP_ROW_ID = DATA1;
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001798
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001799 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07001800 * The sourceid of the group that this group membership refers to. Exactly one of
1801 * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001802 * <P>Type: TEXT</P>
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001803 */
Fred Quintanaffc34c12009-07-14 16:02:58 -07001804 public static final String GROUP_SOURCE_ID = "group_sourceid";
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001805 }
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001806
1807 /**
1808 * Website related to the contact.
1809 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001810 public static final class Website implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001811 /**
1812 * This utility class cannot be instantiated
1813 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001814 private Website() {}
1815
1816 /** MIME type used when storing this in data table. */
1817 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
1818
Fred Quintana8851e162009-08-05 21:06:45 -07001819 public static final int TYPE_HOMEPAGE = 1;
1820 public static final int TYPE_BLOG = 2;
1821 public static final int TYPE_PROFILE = 3;
1822 public static final int TYPE_HOME = 4;
1823 public static final int TYPE_WORK = 5;
1824 public static final int TYPE_FTP = 6;
1825 public static final int TYPE_OTHER = 7;
1826
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001827 /**
1828 * The website URL string.
1829 * <P>Type: TEXT</P>
1830 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001831 public static final String URL = DATA;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001832 }
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001833 }
Fred Quintana435e4272009-06-04 17:30:28 -07001834
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001835 private interface GroupsColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001836 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001837 * The display title of this group.
1838 * <p>
1839 * Type: TEXT
1840 */
1841 public static final String TITLE = "title";
1842
1843 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001844 * The package name to use when creating {@link Resources} objects for
1845 * this group. This value is only designed for use when building user
1846 * interfaces, and should not be used to infer the owner.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001847 *
1848 * @hide
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001849 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001850 public static final String RES_PACKAGE = "res_package";
1851
1852 /**
1853 * The display title of this group to load as a resource from
1854 * {@link #RES_PACKAGE}, which may be localized.
1855 * <P>Type: TEXT</P>
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001856 *
1857 * @hide
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001858 */
1859 public static final String TITLE_RES = "title_res";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001860
1861 /**
Dmitri Plotnikov02c5b452009-07-22 15:13:08 -07001862 * Notes about the group.
1863 * <p>
1864 * Type: TEXT
1865 */
1866 public static final String NOTES = "notes";
1867
1868 /**
1869 * The ID of this group if it is a System Group, i.e. a group that has a special meaning
1870 * to the sync adapter, null otherwise.
1871 * <P>Type: TEXT</P>
1872 */
1873 public static final String SYSTEM_ID = "system_id";
1874
1875 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001876 * The total number of {@link Contacts} that have
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07001877 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001878 * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
1879 * <p>
1880 * Type: INTEGER
1881 */
1882 public static final String SUMMARY_COUNT = "summ_count";
1883
1884 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001885 * The total number of {@link Contacts} that have both
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07001886 * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001887 * Read-only value that is only present when querying
1888 * {@link Groups#CONTENT_SUMMARY_URI}.
1889 * <p>
1890 * Type: INTEGER
1891 */
1892 public static final String SUMMARY_WITH_PHONES = "summ_phones";
1893
1894 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001895 * Flag indicating if the contacts belonging to this group should be
1896 * visible in any user interface.
1897 * <p>
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07001898 * Type: INTEGER (boolean)
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001899 */
1900 public static final String GROUP_VISIBLE = "group_visible";
Fred Quintana00c89f62009-08-10 14:43:24 -07001901
1902 /**
1903 * The "deleted" flag: "0" by default, "1" if the row has been marked
1904 * for deletion. When {@link android.content.ContentResolver#delete} is
1905 * called on a raw contact, it is marked for deletion and removed from its
1906 * aggregate contact. The sync adaptor deletes the raw contact on the server and
Fred Quintana33f889a2009-09-14 17:31:26 -07001907 * then calls ContactResolver.delete once more, this time setting the the
Jeff Sharkey97bda4c2009-09-15 23:15:23 -07001908 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
Fred Quintana33f889a2009-09-14 17:31:26 -07001909 * the data removal.
Fred Quintana00c89f62009-08-10 14:43:24 -07001910 * <P>Type: INTEGER</P>
1911 */
1912 public static final String DELETED = "deleted";
Jeff Sharkey403d7ac2009-08-16 16:34:35 -07001913
1914 /**
1915 * Whether this group should be synced if the SYNC_EVERYTHING settings
1916 * is false for this group's account.
1917 * <p>
1918 * Type: INTEGER (boolean)
1919 */
1920 public static final String SHOULD_SYNC = "should_sync";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001921 }
1922
1923 /**
1924 * Constants for the groups table.
1925 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001926 public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001927 /**
1928 * This utility class cannot be instantiated
1929 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001930 private Groups() {
1931 }
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001932
1933 /**
1934 * The content:// style URI for this table
1935 */
1936 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
1937
1938 /**
1939 * The content:// style URI for this table joined with details data from
Dmitri Plotnikov02c5b452009-07-22 15:13:08 -07001940 * {@link Data}.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001941 */
1942 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
1943 "groups_summary");
1944
1945 /**
1946 * The MIME type of a directory of groups.
1947 */
1948 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
1949
1950 /**
1951 * The MIME type of a single group.
1952 */
1953 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
1954 }
1955
Fred Quintana435e4272009-06-04 17:30:28 -07001956 /**
1957 * Constants for the contact aggregation exceptions table, which contains
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07001958 * aggregation rules overriding those used by automatic aggregation. This type only
1959 * supports query and update. Neither insert nor delete are supported.
Fred Quintana435e4272009-06-04 17:30:28 -07001960 */
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001961 public static final class AggregationExceptions implements BaseColumns {
Fred Quintana435e4272009-06-04 17:30:28 -07001962 /**
1963 * This utility class cannot be instantiated
1964 */
1965 private AggregationExceptions() {}
1966
1967 /**
1968 * The content:// style URI for this table
1969 */
1970 public static final Uri CONTENT_URI =
1971 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
1972
1973 /**
1974 * The MIME type of {@link #CONTENT_URI} providing a directory of data.
1975 */
1976 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
1977
1978 /**
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001979 * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
1980 */
1981 public static final String CONTENT_ITEM_TYPE =
1982 "vnd.android.cursor.item/aggregation_exception";
1983
1984 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07001985 * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07001986 * {@link #TYPE_AUTOMATIC}.
Fred Quintana435e4272009-06-04 17:30:28 -07001987 *
1988 * <P>Type: INTEGER</P>
1989 */
1990 public static final String TYPE = "type";
1991
Fred Quintana435e4272009-06-04 17:30:28 -07001992 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07001993 * Allows the provider to automatically decide whether the specified raw contacts should
1994 * be included in the same aggregate contact or not.
Fred Quintana435e4272009-06-04 17:30:28 -07001995 */
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07001996 public static final int TYPE_AUTOMATIC = 0;
Fred Quintana435e4272009-06-04 17:30:28 -07001997
1998 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07001999 * Makes sure that the specified raw contacts are included in the same
2000 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002001 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002002 public static final int TYPE_KEEP_TOGETHER = 1;
2003
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002004 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002005 * Makes sure that the specified raw contacts are NOT included in the same
2006 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002007 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002008 public static final int TYPE_KEEP_SEPARATE = 2;
2009
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002010 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002011 * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
Fred Quintana435e4272009-06-04 17:30:28 -07002012 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002013 public static final String RAW_CONTACT_ID1 = "raw_contact_id1";
2014
2015 /**
2016 * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule
2017 * applies to.
2018 */
2019 public static final String RAW_CONTACT_ID2 = "raw_contact_id2";
Fred Quintana435e4272009-06-04 17:30:28 -07002020 }
Jeff Sharkey28b68e52009-06-10 15:26:58 -07002021
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002022 private interface SettingsColumns {
2023 /**
2024 * The name of the account instance to which this row belongs.
2025 * <P>Type: TEXT</P>
2026 */
2027 public static final String ACCOUNT_NAME = "account_name";
2028
2029 /**
2030 * The type of account to which this row belongs, which when paired with
2031 * {@link #ACCOUNT_NAME} identifies a specific account.
2032 * <P>Type: TEXT</P>
2033 */
2034 public static final String ACCOUNT_TYPE = "account_type";
2035
2036 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07002037 * Depending on the mode defined by the sync-adapter, this flag controls
2038 * the top-level sync behavior for this data source.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002039 * <p>
2040 * Type: INTEGER (boolean)
2041 */
2042 public static final String SHOULD_SYNC = "should_sync";
2043
2044 /**
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07002045 * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership}
Jeff Sharkeya6597442009-08-19 09:23:33 -07002046 * entries should be visible in any user interface.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002047 * <p>
2048 * Type: INTEGER (boolean)
2049 */
2050 public static final String UNGROUPED_VISIBLE = "ungrouped_visible";
Jeff Sharkey06a03232009-08-21 17:37:56 -07002051
2052 /**
Jeff Sharkey97bda4c2009-09-15 23:15:23 -07002053 * Read-only flag indicating if this {@link #SHOULD_SYNC} or any
2054 * {@link Groups#SHOULD_SYNC} under this account have been marked as
2055 * unsynced.
2056 */
2057 public static final String ANY_UNSYNCED = "any_unsynced";
2058
2059 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07002060 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07002061 * no {@link CommonDataKinds.GroupMembership} entries.
Jeff Sharkey06a03232009-08-21 17:37:56 -07002062 * <p>
2063 * Type: INTEGER
2064 */
2065 public static final String UNGROUPED_COUNT = "summ_count";
2066
2067 /**
2068 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07002069 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers.
Jeff Sharkey06a03232009-08-21 17:37:56 -07002070 * <p>
2071 * Type: INTEGER
2072 */
2073 public static final String UNGROUPED_WITH_PHONES = "summ_phones";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002074 }
2075
2076 /**
2077 * Contacts-specific settings for various {@link Account}.
2078 */
Jeff Sharkey06a03232009-08-21 17:37:56 -07002079 public static final class Settings implements SettingsColumns {
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002080 /**
2081 * This utility class cannot be instantiated
2082 */
2083 private Settings() {
2084 }
2085
2086 /**
2087 * The content:// style URI for this table
2088 */
2089 public static final Uri CONTENT_URI =
2090 Uri.withAppendedPath(AUTHORITY_URI, "settings");
2091
2092 /**
2093 * The MIME-type of {@link #CONTENT_URI} providing a directory of
2094 * settings.
2095 */
2096 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting";
2097
2098 /**
2099 * The MIME-type of {@link #CONTENT_URI} providing a single setting.
2100 */
2101 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002102 }
2103
Evan Millardc2da5f2009-06-18 16:07:13 -07002104 /**
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002105 * Helper methods to display FastTrack dialogs that allow users to pivot on
2106 * a specific {@link Contacts} entry.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002107 *
2108 * @hide
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002109 */
2110 public static final class FastTrack {
2111 /**
2112 * Action used to trigger person pivot dialog.
2113 * @hide
2114 */
2115 public static final String ACTION_FAST_TRACK =
Jeff Sharkey0050ee32009-09-17 16:11:32 -07002116 "com.android.contacts.action.FAST_TRACK";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002117
2118 /**
2119 * Extra used to specify pivot dialog location in screen coordinates.
2120 * @hide
2121 */
2122 public static final String EXTRA_TARGET_RECT = "target_rect";
2123
2124 /**
2125 * Extra used to specify size of pivot dialog.
2126 * @hide
2127 */
2128 public static final String EXTRA_MODE = "mode";
2129
2130 /**
2131 * Extra used to indicate a list of specific MIME-types to exclude and
2132 * not display. Stored as a {@link String} array.
2133 * @hide
2134 */
2135 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
2136
2137 /**
2138 * Small FastTrack mode, usually presented with minimal actions.
2139 */
2140 public static final int MODE_SMALL = 1;
2141
2142 /**
2143 * Medium FastTrack mode, includes actions and light summary describing
2144 * the {@link Contacts} entry being shown. This may include social
2145 * status and presence details.
2146 */
2147 public static final int MODE_MEDIUM = 2;
2148
2149 /**
2150 * Large FastTrack mode, includes actions and larger, card-like summary
2151 * of the {@link Contacts} entry being shown. This may include detailed
2152 * information, such as a photo.
2153 */
2154 public static final int MODE_LARGE = 3;
2155
2156 /**
2157 * Trigger a dialog that lists the various methods of interacting with
2158 * the requested {@link Contacts} entry. This may be based on available
2159 * {@link Data} rows under that contact, and may also include social
2160 * status and presence details.
2161 *
2162 * @param context The parent {@link Context} that may be used as the
2163 * parent for this dialog.
2164 * @param target Specific {@link View} from your layout that this dialog
2165 * should be centered around. In particular, if the dialog
2166 * has a "callout" arrow, it will be pointed and centered
2167 * around this {@link View}.
2168 * @param lookupUri A {@link Contacts#CONTENT_LOOKUP_URI} style
2169 * {@link Uri} that describes a specific contact to feature
2170 * in this dialog.
2171 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
2172 * {@link #MODE_LARGE}, indicating the desired dialog size,
2173 * when supported.
2174 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
2175 * to exclude when showing this dialog. For example, when
2176 * already viewing the contact details card, this can be used
2177 * to omit the details entry from the dialog.
2178 */
2179 public static void showFastTrack(Context context, View target, Uri lookupUri, int mode,
2180 String[] excludeMimes) {
2181 // Find location and bounds of target view
2182 final int[] location = new int[2];
2183 target.getLocationOnScreen(location);
2184
2185 final Rect rect = new Rect();
2186 rect.left = location[0];
2187 rect.top = location[1];
2188 rect.right = rect.left + target.getWidth();
2189 rect.bottom = rect.top + target.getHeight();
2190
2191 // Trigger with obtained rectangle
2192 showFastTrack(context, rect, lookupUri, mode, excludeMimes);
2193 }
2194
2195 /**
2196 * Trigger a dialog that lists the various methods of interacting with
2197 * the requested {@link Contacts} entry. This may be based on available
2198 * {@link Data} rows under that contact, and may also include social
2199 * status and presence details.
2200 *
2201 * @param context The parent {@link Context} that may be used as the
2202 * parent for this dialog.
2203 * @param target Specific {@link Rect} that this dialog should be
2204 * centered around, in screen coordinates. In particular, if
2205 * the dialog has a "callout" arrow, it will be pointed and
2206 * centered around this {@link Rect}.
2207 * @param lookupUri A {@link Contacts#CONTENT_LOOKUP_URI} style
2208 * {@link Uri} that describes a specific contact to feature
2209 * in this dialog.
2210 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
2211 * {@link #MODE_LARGE}, indicating the desired dialog size,
2212 * when supported.
2213 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
2214 * to exclude when showing this dialog. For example, when
2215 * already viewing the contact details card, this can be used
2216 * to omit the details entry from the dialog.
2217 */
2218 public static void showFastTrack(Context context, Rect target, Uri lookupUri, int mode,
2219 String[] excludeMimes) {
2220 // Launch pivot dialog through intent for now
2221 final Intent intent = new Intent(ACTION_FAST_TRACK);
2222 intent.setData(lookupUri);
2223 intent.putExtra(EXTRA_TARGET_RECT, target);
2224 intent.putExtra(EXTRA_MODE, mode);
2225 intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes);
2226 context.startActivity(intent);
2227 }
2228 }
2229
2230 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07002231 * Contains helper classes used to create or manage {@link android.content.Intent Intents}
2232 * that involve contacts.
2233 */
2234 public static final class Intents {
2235 /**
2236 * This is the intent that is fired when a search suggestion is clicked on.
2237 */
2238 public static final String SEARCH_SUGGESTION_CLICKED =
2239 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
2240
2241 /**
2242 * This is the intent that is fired when a search suggestion for dialing a number
2243 * is clicked on.
2244 */
2245 public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
2246 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
2247
2248 /**
2249 * This is the intent that is fired when a search suggestion for creating a contact
2250 * is clicked on.
2251 */
2252 public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
2253 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
2254
2255 /**
2256 * Starts an Activity that lets the user pick a contact to attach an image to.
2257 * After picking the contact it launches the image cropper in face detection mode.
2258 */
2259 public static final String ATTACH_IMAGE =
2260 "com.android.contacts.action.ATTACH_IMAGE";
2261
2262 /**
2263 * Takes as input a data URI with a mailto: or tel: scheme. If a single
2264 * contact exists with the given data it will be shown. If no contact
2265 * exists, a dialog will ask the user if they want to create a new
2266 * contact with the provided details filled in. If multiple contacts
2267 * share the data the user will be prompted to pick which contact they
2268 * want to view.
2269 * <p>
2270 * For <code>mailto:</code> URIs, the scheme specific portion must be a
2271 * raw email address, such as one built using
2272 * {@link Uri#fromParts(String, String, String)}.
2273 * <p>
2274 * For <code>tel:</code> URIs, the scheme specific portion is compared
2275 * to existing numbers using the standard caller ID lookup algorithm.
2276 * The number must be properly encoded, for example using
2277 * {@link Uri#fromParts(String, String, String)}.
2278 * <p>
2279 * Any extras from the {@link Insert} class will be passed along to the
2280 * create activity if there are no contacts to show.
2281 * <p>
2282 * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
2283 * prompting the user when the contact doesn't exist.
2284 */
2285 public static final String SHOW_OR_CREATE_CONTACT =
2286 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
2287
2288 /**
2289 * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
2290 * contact if no matching contact found. Otherwise, default behavior is
2291 * to prompt user with dialog before creating.
2292 * <p>
2293 * Type: BOOLEAN
2294 */
2295 public static final String EXTRA_FORCE_CREATE =
2296 "com.android.contacts.action.FORCE_CREATE";
2297
2298 /**
2299 * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
2300 * description to be shown when prompting user about creating a new
2301 * contact.
2302 * <p>
2303 * Type: STRING
2304 */
2305 public static final String EXTRA_CREATE_DESCRIPTION =
2306 "com.android.contacts.action.CREATE_DESCRIPTION";
2307
2308 /**
Jeff Sharkey11322002009-06-04 17:25:51 -07002309 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
2310 * dialog location using screen coordinates. When not specified, the
2311 * dialog will be centered.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002312 *
2313 * @hide
Jeff Sharkey11322002009-06-04 17:25:51 -07002314 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002315 @Deprecated
Jeff Sharkey11322002009-06-04 17:25:51 -07002316 public static final String EXTRA_TARGET_RECT = "target_rect";
2317
2318 /**
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002319 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
2320 * desired dialog style, usually a variation on size. One of
2321 * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002322 *
2323 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002324 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002325 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002326 public static final String EXTRA_MODE = "mode";
2327
2328 /**
2329 * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002330 *
2331 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002332 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002333 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002334 public static final int MODE_SMALL = 1;
2335
2336 /**
2337 * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002338 *
2339 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002340 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002341 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002342 public static final int MODE_MEDIUM = 2;
2343
2344 /**
2345 * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002346 *
2347 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002348 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002349 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002350 public static final int MODE_LARGE = 3;
2351
2352 /**
Jeff Sharkey84235ee2009-08-23 14:07:02 -07002353 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate
2354 * a list of specific MIME-types to exclude and not display. Stored as a
2355 * {@link String} array.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002356 *
2357 * @hide
Jeff Sharkey84235ee2009-08-23 14:07:02 -07002358 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002359 @Deprecated
Jeff Sharkey84235ee2009-08-23 14:07:02 -07002360 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
2361
2362 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07002363 * Intents related to the Contacts app UI.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002364 *
2365 * @hide
Evan Millardc2da5f2009-06-18 16:07:13 -07002366 */
2367 public static final class UI {
2368 /**
2369 * The action for the default contacts list tab.
2370 */
2371 public static final String LIST_DEFAULT =
2372 "com.android.contacts.action.LIST_DEFAULT";
2373
2374 /**
2375 * The action for the contacts list tab.
2376 */
2377 public static final String LIST_GROUP_ACTION =
2378 "com.android.contacts.action.LIST_GROUP";
2379
2380 /**
2381 * When in LIST_GROUP_ACTION mode, this is the group to display.
2382 */
2383 public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP";
2384
2385 /**
2386 * The action for the all contacts list tab.
2387 */
2388 public static final String LIST_ALL_CONTACTS_ACTION =
2389 "com.android.contacts.action.LIST_ALL_CONTACTS";
2390
2391 /**
2392 * The action for the contacts with phone numbers list tab.
2393 */
2394 public static final String LIST_CONTACTS_WITH_PHONES_ACTION =
2395 "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES";
2396
2397 /**
2398 * The action for the starred contacts list tab.
2399 */
2400 public static final String LIST_STARRED_ACTION =
2401 "com.android.contacts.action.LIST_STARRED";
2402
2403 /**
2404 * The action for the frequent contacts list tab.
2405 */
2406 public static final String LIST_FREQUENT_ACTION =
2407 "com.android.contacts.action.LIST_FREQUENT";
2408
2409 /**
2410 * The action for the "strequent" contacts list tab. It first lists the starred
2411 * contacts in alphabetical order and then the frequent contacts in descending
2412 * order of the number of times they have been contacted.
2413 */
2414 public static final String LIST_STREQUENT_ACTION =
2415 "com.android.contacts.action.LIST_STREQUENT";
2416
2417 /**
2418 * A key for to be used as an intent extra to set the activity
2419 * title to a custom String value.
2420 */
2421 public static final String TITLE_EXTRA_KEY =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002422 "com.android.contacts.extra.TITLE_EXTRA";
Evan Millardc2da5f2009-06-18 16:07:13 -07002423
2424 /**
2425 * Activity Action: Display a filtered list of contacts
2426 * <p>
2427 * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for
2428 * filtering
2429 * <p>
2430 * Output: Nothing.
2431 */
2432 public static final String FILTER_CONTACTS_ACTION =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002433 "com.android.contacts.action.FILTER_CONTACTS";
Evan Millardc2da5f2009-06-18 16:07:13 -07002434
2435 /**
2436 * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION}
2437 * intents to supply the text on which to filter.
2438 */
2439 public static final String FILTER_TEXT_EXTRA_KEY =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002440 "com.android.contacts.extra.FILTER_TEXT";
Evan Millardc2da5f2009-06-18 16:07:13 -07002441 }
2442
2443 /**
2444 * Convenience class that contains string constants used
2445 * to create contact {@link android.content.Intent Intents}.
2446 */
2447 public static final class Insert {
2448 /** The action code to use when adding a contact */
2449 public static final String ACTION = Intent.ACTION_INSERT;
2450
2451 /**
2452 * If present, forces a bypass of quick insert mode.
2453 */
2454 public static final String FULL_MODE = "full_mode";
2455
2456 /**
2457 * The extra field for the contact name.
2458 * <P>Type: String</P>
2459 */
2460 public static final String NAME = "name";
2461
2462 // TODO add structured name values here.
2463
2464 /**
2465 * The extra field for the contact phonetic name.
2466 * <P>Type: String</P>
2467 */
2468 public static final String PHONETIC_NAME = "phonetic_name";
2469
2470 /**
2471 * The extra field for the contact company.
2472 * <P>Type: String</P>
2473 */
2474 public static final String COMPANY = "company";
2475
2476 /**
2477 * The extra field for the contact job title.
2478 * <P>Type: String</P>
2479 */
2480 public static final String JOB_TITLE = "job_title";
2481
2482 /**
2483 * The extra field for the contact notes.
2484 * <P>Type: String</P>
2485 */
2486 public static final String NOTES = "notes";
2487
2488 /**
2489 * The extra field for the contact phone number.
2490 * <P>Type: String</P>
2491 */
2492 public static final String PHONE = "phone";
2493
2494 /**
2495 * The extra field for the contact phone number type.
2496 * <P>Type: Either an integer value from
2497 * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
2498 * or a string specifying a custom label.</P>
2499 */
2500 public static final String PHONE_TYPE = "phone_type";
2501
2502 /**
2503 * The extra field for the phone isprimary flag.
2504 * <P>Type: boolean</P>
2505 */
2506 public static final String PHONE_ISPRIMARY = "phone_isprimary";
2507
2508 /**
2509 * The extra field for an optional second contact phone number.
2510 * <P>Type: String</P>
2511 */
2512 public static final String SECONDARY_PHONE = "secondary_phone";
2513
2514 /**
2515 * The extra field for an optional second contact phone number type.
2516 * <P>Type: Either an integer value from
2517 * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
2518 * or a string specifying a custom label.</P>
2519 */
2520 public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
2521
2522 /**
2523 * The extra field for an optional third contact phone number.
2524 * <P>Type: String</P>
2525 */
2526 public static final String TERTIARY_PHONE = "tertiary_phone";
2527
2528 /**
2529 * The extra field for an optional third contact phone number type.
2530 * <P>Type: Either an integer value from
2531 * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
2532 * or a string specifying a custom label.</P>
2533 */
2534 public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
2535
2536 /**
2537 * The extra field for the contact email address.
2538 * <P>Type: String</P>
2539 */
2540 public static final String EMAIL = "email";
2541
2542 /**
2543 * The extra field for the contact email type.
2544 * <P>Type: Either an integer value from
2545 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2546 * or a string specifying a custom label.</P>
2547 */
2548 public static final String EMAIL_TYPE = "email_type";
2549
2550 /**
2551 * The extra field for the email isprimary flag.
2552 * <P>Type: boolean</P>
2553 */
2554 public static final String EMAIL_ISPRIMARY = "email_isprimary";
2555
2556 /**
2557 * The extra field for an optional second contact email address.
2558 * <P>Type: String</P>
2559 */
2560 public static final String SECONDARY_EMAIL = "secondary_email";
2561
2562 /**
2563 * The extra field for an optional second contact email type.
2564 * <P>Type: Either an integer value from
2565 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2566 * or a string specifying a custom label.</P>
2567 */
2568 public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
2569
2570 /**
2571 * The extra field for an optional third contact email address.
2572 * <P>Type: String</P>
2573 */
2574 public static final String TERTIARY_EMAIL = "tertiary_email";
2575
2576 /**
2577 * The extra field for an optional third contact email type.
2578 * <P>Type: Either an integer value from
2579 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2580 * or a string specifying a custom label.</P>
2581 */
2582 public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
2583
2584 /**
2585 * The extra field for the contact postal address.
2586 * <P>Type: String</P>
2587 */
2588 public static final String POSTAL = "postal";
2589
2590 /**
2591 * The extra field for the contact postal address 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 POSTAL_TYPE = "postal_type";
2597
2598 /**
2599 * The extra field for the postal isprimary flag.
2600 * <P>Type: boolean</P>
2601 */
2602 public static final String POSTAL_ISPRIMARY = "postal_isprimary";
2603
2604 /**
2605 * The extra field for an IM handle.
2606 * <P>Type: String</P>
2607 */
2608 public static final String IM_HANDLE = "im_handle";
2609
2610 /**
2611 * The extra field for the IM protocol
Evan Millardc2da5f2009-06-18 16:07:13 -07002612 */
2613 public static final String IM_PROTOCOL = "im_protocol";
2614
2615 /**
2616 * The extra field for the IM isprimary flag.
2617 * <P>Type: boolean</P>
2618 */
2619 public static final String IM_ISPRIMARY = "im_isprimary";
2620 }
2621 }
2622
Evan Millar088b2912009-05-28 15:24:37 -07002623}