blob: ef79ed3c3b9482cefe4bd9c3a2fc6d8f3d6b6f42 [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 Sharkeyff18bbf2009-09-27 16:55:00 -0700321 * Base {@link Uri} for referencing a single {@link Contacts} entry,
322 * created by appending {@link Contacts#LOOKUP_KEY} using
323 * {@link Uri#withAppendedPath(Uri, String)}. Provides
324 * {@link OpenableColumns} columns when queried, or returns the
325 * referenced contact formatted as a vCard when opened through
326 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
327 */
328 public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
329 "as_vcard");
330
331 /**
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700332 * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the
333 * requested {@link Contacts} entry.
334 *
335 * @param contactUri A {@link #CONTENT_URI} row, or an existing
336 * {@link #CONTENT_LOOKUP_URI} to attempt refreshing.
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700337 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700338 public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) {
339 final Cursor c = resolver.query(contactUri, new String[] {
340 Contacts.LOOKUP_KEY, Contacts._ID
341 }, null, null, null);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700342 if (c == null) {
343 return null;
344 }
345
346 try {
347 if (c.moveToFirst()) {
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700348 final String lookupKey = c.getString(0);
349 final long contactId = c.getLong(1);
350 return getLookupUri(contactId, lookupKey);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700351 }
352 } finally {
353 c.close();
354 }
355 return null;
356 }
357
358 /**
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -0700359 * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the
Jeff Hamiltonf8526982009-09-24 11:34:58 -0500360 * given {@link android.provider.ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}.
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -0700361 */
362 public static Uri getLookupUri(long contactId, String lookupKey) {
363 return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI,
364 lookupKey), contactId);
365 }
366
367 /**
Dmitri Plotnikovb5759b52009-09-01 15:58:40 -0700368 * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI.
369 * <p>
370 * Returns null if the contact cannot be found.
371 */
372 public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) {
373 if (lookupUri == null) {
374 return null;
375 }
376
377 Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null);
378 if (c == null) {
379 return null;
380 }
381
382 try {
383 if (c.moveToFirst()) {
384 long contactId = c.getLong(0);
385 return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
386 }
387 } finally {
388 c.close();
389 }
390 return null;
391 }
392
393 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500394 * Mark a contact as having been contacted.
395 *
396 * @param resolver the ContentResolver to use
397 * @param contactId the person who was contacted
398 */
399 public static void markAsContacted(ContentResolver resolver, long contactId) {
400 Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId);
401 ContentValues values = new ContentValues();
402 // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified.
403 values.put(LAST_TIME_CONTACTED, System.currentTimeMillis());
404 resolver.update(uri, values, null, null);
405 }
406
407 /**
Evan Millar161dd862009-06-12 16:02:43 -0700408 * The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700409 * {@link #CONTENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700410 * various parts of the contact name. The filter argument should be passed
Evan Millar161dd862009-06-12 16:02:43 -0700411 * as an additional path segment after this URI.
412 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700413 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
414 CONTENT_URI, "filter");
415
Evan Millardc2da5f2009-06-18 16:07:13 -0700416 /**
417 * The content:// style URI for this table joined with useful data from
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700418 * {@link Data}, filtered to include only starred contacts
419 * and the most frequently contacted contacts.
Evan Millardc2da5f2009-06-18 16:07:13 -0700420 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700421 public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath(
422 CONTENT_URI, "strequent");
423
Evan Millardc2da5f2009-06-18 16:07:13 -0700424 /**
425 * The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700426 * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700427 * various parts of the contact name. The filter argument should be passed
Evan Millardc2da5f2009-06-18 16:07:13 -0700428 * as an additional path segment after this URI.
429 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700430 public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath(
431 CONTENT_STREQUENT_URI, "filter");
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700432
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -0700433 public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath(
434 CONTENT_URI, "group");
435
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700436 /**
Evan Millar088b2912009-05-28 15:24:37 -0700437 * The MIME type of {@link #CONTENT_URI} providing a directory of
438 * people.
439 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700440 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
Evan Millar088b2912009-05-28 15:24:37 -0700441
442 /**
443 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
444 * person.
445 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700446 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
Evan Millar088b2912009-05-28 15:24:37 -0700447
448 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -0700449 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
450 * person.
451 */
452 public static final String CONTENT_VCARD_TYPE = "text/x-vcard";
453
454 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700455 * A sub-directory of a single contact that contains all of the constituent raw contact
Evan Millar088b2912009-05-28 15:24:37 -0700456 * {@link Data} rows.
457 */
Fred Quintana8851e162009-08-05 21:06:45 -0700458 public static final class Data implements BaseColumns, DataColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700459 /**
460 * no public constructor since this is a utility class
461 */
462 private Data() {}
463
464 /**
465 * The directory twig for this sub-table
466 */
467 public static final String CONTENT_DIRECTORY = "data";
468 }
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700469
470 /**
471 * A sub-directory of a single contact aggregate that contains all aggregation suggestions
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700472 * (other contacts). The aggregation suggestions are computed based on approximate
473 * data matches with this contact.
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700474 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700475 public static final class AggregationSuggestions implements BaseColumns, ContactsColumns {
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700476 /**
477 * No public constructor since this is a utility class
478 */
479 private AggregationSuggestions() {}
480
481 /**
Dmitri Plotnikov0fc02442009-09-21 13:26:28 -0700482 * The directory twig for this sub-table. The URI can be followed by an optional
Jeff Hamiltonf8526982009-09-24 11:34:58 -0500483 * type-to-filter, similar to
484 * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}.
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700485 */
486 public static final String CONTENT_DIRECTORY = "suggestions";
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -0700487 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700488
489 /**
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -0700490 * A sub-directory of a single contact that contains the contact's primary photo.
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700491 */
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -0700492 public static final class Photo implements BaseColumns, DataColumns {
493 /**
494 * no public constructor since this is a utility class
495 */
496 private Photo() {}
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -0700497
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -0700498 /**
499 * The directory twig for this sub-table
500 */
501 public static final String CONTENT_DIRECTORY = "photo";
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700502 }
503
504 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500505 * Opens an InputStream for the contacts's default photo and returns the
506 * photo as a byte stream. If there is not photo null will be returned.
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700507 *
508 * @param contactUri the contact whose photo should be used
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500509 * @return an InputStream of the photo, or null if no photo is present
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700510 */
511 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -0700512 Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY);
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -0700513 if (photoUri == null) {
514 return null;
515 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700516 Cursor cursor = cr.query(photoUri,
517 new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null);
518 try {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -0700519 if (cursor == null || !cursor.moveToNext()) {
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700520 return null;
521 }
522 byte[] data = cursor.getBlob(0);
523 if (data == null) {
524 return null;
525 }
526 return new ByteArrayInputStream(data);
527 } finally {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -0700528 if (cursor != null) {
529 cursor.close();
530 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -0700531 }
532 }
Evan Millar088b2912009-05-28 15:24:37 -0700533 }
534
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -0700535 private interface RawContactsColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700536 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700537 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} that this
538 * data belongs to.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700539 * <P>Type: INTEGER</P>
Evan Millar088b2912009-05-28 15:24:37 -0700540 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700541 public static final String CONTACT_ID = "contact_id";
Evan Millar088b2912009-05-28 15:24:37 -0700542
543 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500544 * Flag indicating that this {@link RawContacts} entry and its children have
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700545 * been restricted to specific platform apps.
546 * <P>Type: INTEGER (boolean)</P>
547 *
548 * @hide until finalized in future platform release
549 */
550 public static final String IS_RESTRICTED = "is_restricted";
551
552 /**
553 * The aggregation mode for this contact.
554 * <P>Type: INTEGER</P>
555 */
556 public static final String AGGREGATION_MODE = "aggregation_mode";
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -0700557
558 /**
559 * The "deleted" flag: "0" by default, "1" if the row has been marked
560 * for deletion. When {@link android.content.ContentResolver#delete} is
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700561 * called on a raw contact, it is marked for deletion and removed from its
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700562 * aggregate contact. The sync adaptor deletes the raw contact on the server and
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -0700563 * then calls ContactResolver.delete once more, this time passing the
Fred Quintana33f889a2009-09-14 17:31:26 -0700564 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
565 * the data removal.
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -0700566 * <P>Type: INTEGER</P>
567 */
568 public static final String DELETED = "deleted";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700569 }
570
571 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500572 * Constants for the raw contacts table, which contains the base contact
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -0700573 * information per sync source. Sync adapters and contact management apps
574 * are the primary consumers of this API.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700575 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700576 public static final class RawContacts implements BaseColumns, RawContactsColumns,
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700577 ContactOptionsColumns, SyncColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700578 /**
579 * This utility class cannot be instantiated
580 */
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -0700581 private RawContacts() {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700582 }
583
584 /**
Evan Millar088b2912009-05-28 15:24:37 -0700585 * The content:// style URI for this table
586 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700587 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
Evan Millar088b2912009-05-28 15:24:37 -0700588
589 /**
Evan Millar088b2912009-05-28 15:24:37 -0700590 * The MIME type of {@link #CONTENT_URI} providing a directory of
591 * people.
592 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700593 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -0700594
595 /**
596 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
597 * person.
598 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700599 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -0700600
601 /**
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700602 * Aggregation mode: aggregate asynchronously.
603 */
604 public static final int AGGREGATION_MODE_DEFAULT = 0;
605
606 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700607 * Aggregation mode: aggregate at the time the raw contact is inserted/updated.
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700608 */
Omari Stephensbc9aa772009-09-08 19:10:53 -0700609 public static final int AGGREGATION_MODE_IMMEDIATE = 1;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700610
611 /**
Dmitri Plotnikov5223b162009-08-25 15:15:06 -0700612 * If {@link #AGGREGATION_MODE} is {@link #AGGREGATION_MODE_SUSPENDED}, changes
613 * to the raw contact do not cause its aggregation to be revisited. Note that changing
614 * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to
615 * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass. Any subsequent
616 * change to the raw contact's data will.
617 */
618 public static final int AGGREGATION_MODE_SUSPENDED = 2;
619
620 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700621 * Aggregation mode: never aggregate this raw contact (note that the raw contact will not
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700622 * have a corresponding Aggregate and therefore will not be included in Aggregates
623 * query results.)
624 */
Dmitri Plotnikov5223b162009-08-25 15:15:06 -0700625 public static final int AGGREGATION_MODE_DISABLED = 3;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700626
627 /**
Jeff Hamiltonf8526982009-09-24 11:34:58 -0500628 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
629 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
630 * entry of the given {@link RawContacts} entry.
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700631 */
632 public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) {
633 // TODO: use a lighter query by joining rawcontacts with contacts in provider
634 final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY);
635 final Cursor cursor = resolver.query(dataUri, new String[] {
636 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
637 }, null, null, null);
638
639 Uri lookupUri = null;
640 try {
641 if (cursor != null && cursor.moveToFirst()) {
642 final long contactId = cursor.getLong(0);
643 final String lookupKey = cursor.getString(1);
644 return Contacts.getLookupUri(contactId, lookupKey);
645 }
646 } finally {
647 if (cursor != null) cursor.close();
648 }
649 return lookupUri;
650 }
651
652 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700653 * A sub-directory of a single raw contact that contains all of their {@link Data} rows.
Dmitri Plotnikov5223b162009-08-25 15:15:06 -0700654 * To access this directory append {@link Data#CONTENT_DIRECTORY} to the contact URI.
Evan Millar088b2912009-05-28 15:24:37 -0700655 */
656 public static final class Data implements BaseColumns, DataColumns {
657 /**
658 * no public constructor since this is a utility class
659 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700660 private Data() {
661 }
Evan Millar088b2912009-05-28 15:24:37 -0700662
663 /**
664 * The directory twig for this sub-table
665 */
666 public static final String CONTENT_DIRECTORY = "data";
667 }
668 }
669
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700670 private interface StatusColumns extends Im.CommonPresenceColumns {
671 /**
Dmitri Plotnikova60479d2009-09-27 20:16:31 -0700672 * Contact's latest presence level.
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700673 * <P>Type: INTEGER (one of the values below)</P>
674 */
675 public static final String PRESENCE = PRESENCE_STATUS;
676
677 /**
678 * Contact latest status update.
679 * <p>Type: TEXT</p>
680 */
681 public static final String STATUS = PRESENCE_CUSTOM_STATUS;
682
683 /**
684 * The absolute time in milliseconds when the latest status was inserted/updated.
685 * <p>Type: NUMBER</p>
686 */
687 public static final String STATUS_TIMESTAMP = "status_ts";
688
689 /**
690 * The package containing resources for this status: label and icon.
691 * <p>Type: NUMBER</p>
692 */
693 public static final String STATUS_RES_PACKAGE = "status_res_package";
694
695 /**
696 * The resource ID of the label describing the source of the status update, e.g. "Google
697 * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
698 * <p>Type: NUMBER</p>
699 */
700 public static final String STATUS_LABEL = "status_label";
701
702 /**
703 * The resource ID of the icon for the source of the status update.
704 * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
705 * <p>Type: NUMBER</p>
706 */
707 public static final String STATUS_ICON = "status_icon";
708 }
709
Evan Millar088b2912009-05-28 15:24:37 -0700710 private interface DataColumns {
711 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700712 * The package name to use when creating {@link Resources} objects for
713 * this data row. This value is only designed for use when building user
714 * interfaces, and should not be used to infer the owner.
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500715 *
716 * @hide
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700717 */
718 public static final String RES_PACKAGE = "res_package";
719
720 /**
721 * The MIME type of the item represented by this row.
Evan Millar088b2912009-05-28 15:24:37 -0700722 */
723 public static final String MIMETYPE = "mimetype";
724
725 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700726 * A reference to the {@link RawContacts#_ID}
Dmitri Plotnikov56927772009-05-28 17:23:39 -0700727 * that this data belongs to.
Evan Millar088b2912009-05-28 15:24:37 -0700728 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700729 public static final String RAW_CONTACT_ID = "raw_contact_id";
730
Evan Millarab5742d2009-06-02 16:21:45 -0700731 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700732 * Whether this is the primary entry of its kind for the raw contact it belongs to
Evan Millarab5742d2009-06-02 16:21:45 -0700733 * <P>Type: INTEGER (if set, non-0 means true)</P>
734 */
735 public static final String IS_PRIMARY = "is_primary";
736
737 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -0700738 * Whether this is the primary entry of its kind for the aggregate
739 * contact it belongs to. Any data record that is "super primary" must
740 * also be "primary".
Evan Millarab5742d2009-06-02 16:21:45 -0700741 * <P>Type: INTEGER (if set, non-0 means true)</P>
742 */
743 public static final String IS_SUPER_PRIMARY = "is_super_primary";
744
Jeff Sharkey28b68e52009-06-10 15:26:58 -0700745 /**
Fred Quintanac933fb62009-06-11 12:14:40 -0700746 * The version of this data record. This is a read-only value. The data column is
747 * guaranteed to not change without the version going up. This value is monotonically
748 * increasing.
749 * <P>Type: INTEGER</P>
750 */
751 public static final String DATA_VERSION = "data_version";
752
Evan Millar088b2912009-05-28 15:24:37 -0700753 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
754 public static final String DATA1 = "data1";
755 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
756 public static final String DATA2 = "data2";
757 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
758 public static final String DATA3 = "data3";
759 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
760 public static final String DATA4 = "data4";
761 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
762 public static final String DATA5 = "data5";
763 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
764 public static final String DATA6 = "data6";
765 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
766 public static final String DATA7 = "data7";
767 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
768 public static final String DATA8 = "data8";
769 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
770 public static final String DATA9 = "data9";
771 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
772 public static final String DATA10 = "data10";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700773 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
774 public static final String DATA11 = "data11";
775 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
776 public static final String DATA12 = "data12";
777 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
778 public static final String DATA13 = "data13";
779 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
780 public static final String DATA14 = "data14";
781 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
782 public static final String DATA15 = "data15";
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700783
Fred Quintana8851e162009-08-05 21:06:45 -0700784 /** Generic column for use by sync adapters. */
785 public static final String SYNC1 = "data_sync1";
786 /** Generic column for use by sync adapters. */
787 public static final String SYNC2 = "data_sync2";
788 /** Generic column for use by sync adapters. */
789 public static final String SYNC3 = "data_sync3";
790 /** Generic column for use by sync adapters. */
791 public static final String SYNC4 = "data_sync4";
Evan Millar088b2912009-05-28 15:24:37 -0700792 }
793
794 /**
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -0700795 * Combines all columns returned by {@link Data} table queries.
796 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700797 private interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns,
798 RawContactsColumns, ContactsColumns, ContactOptionsColumns, ContactStatusColumns {
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -0700799
800 }
801
802 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -0700803 * Constants for the data table, which contains data points tied to a raw contact.
Evan Millar088b2912009-05-28 15:24:37 -0700804 * For example, a phone number or email address. Each row in this table contains a type
805 * definition and some generic columns. Each data type can define the meaning for each of
806 * the generic columns.
807 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -0700808 public final static class Data implements DataColumnsWithJoins {
Evan Millar088b2912009-05-28 15:24:37 -0700809 /**
810 * This utility class cannot be instantiated
811 */
812 private Data() {}
813
814 /**
815 * The content:// style URI for this table
816 */
817 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
818
819 /**
820 * The MIME type of {@link #CONTENT_URI} providing a directory of data.
821 */
822 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700823
824 /**
Daisuke Miyakawaf2e0d7b2009-09-28 06:28:26 -0700825 * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
826 * Data.CONTENT_URI contains only exportable data.
827 *
828 * This flag is useful (currently) only for vCard exporter in Contacts app, which
829 * needs to exclude "un-exportable" data from available data to export, while
830 * Contacts app itself has priviledge to access all data including "un-expotable"
831 * ones and providers return all of them regardless of the callers' intention.
832 * <P>Type: INTEGER</p>
833 *
834 * @hide Maybe available only in Eclair and not really ready for public use.
835 * TODO: remove, or implement this feature completely. As of now (Eclair),
836 * we only use this flag in queryEntities(), not query().
837 */
838 public static final String FOR_EXPORT_ONLY = "for_export_only";
839
840 /**
Jeff Hamiltonf8526982009-09-24 11:34:58 -0500841 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
842 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
843 * entry of the given {@link Data} entry.
Jeff Sharkey6449eb02009-09-16 21:41:51 -0700844 */
845 public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) {
846 final Cursor cursor = resolver.query(dataUri, new String[] {
847 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
848 }, null, null, null);
849
850 Uri lookupUri = null;
851 try {
852 if (cursor != null && cursor.moveToFirst()) {
853 final long contactId = cursor.getLong(0);
854 final String lookupKey = cursor.getString(1);
855 return Contacts.getLookupUri(contactId, lookupKey);
856 }
857 } finally {
858 if (cursor != null) cursor.close();
859 }
860 return lookupUri;
861 }
Evan Millar088b2912009-05-28 15:24:37 -0700862 }
863
Dmitri Plotnikov93032952009-08-19 11:26:57 -0700864 private interface PhoneLookupColumns {
865 /**
866 * The phone number as the user entered it.
867 * <P>Type: TEXT</P>
868 */
869 public static final String NUMBER = "number";
870
871 /**
872 * The type of phone number, for example Home or Work.
873 * <P>Type: INTEGER</P>
874 */
875 public static final String TYPE = "type";
876
877 /**
878 * The user defined label for the phone number.
879 * <P>Type: TEXT</P>
880 */
881 public static final String LABEL = "label";
882 }
883
Evan Millar088b2912009-05-28 15:24:37 -0700884 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700885 * A table that represents the result of looking up a phone number, for
Dmitri Plotnikov93032952009-08-19 11:26:57 -0700886 * example for caller ID. To perform a lookup you must append the number you
887 * want to find to {@link #CONTENT_FILTER_URI}.
Evan Millar088b2912009-05-28 15:24:37 -0700888 */
Dmitri Plotnikov93032952009-08-19 11:26:57 -0700889 public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
890 ContactsColumns, ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700891 /**
892 * This utility class cannot be instantiated
893 */
894 private PhoneLookup() {}
895
896 /**
897 * The content:// style URI for this table. Append the phone number you want to lookup
898 * to this URI and query it to perform a lookup. For example:
899 *
900 * {@code
901 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, phoneNumber);
902 * }
903 */
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700904 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
905 "phone_lookup");
906 }
907
908 /**
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700909 * Additional data mixed in with {@link StatusColumns} to link
910 * back to specific {@link ContactsContract.Data#_ID} entries.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700911 */
912 private interface PresenceColumns {
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700913
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700914 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700915 * Reference to the {@link Data#_ID} entry that owns this presence.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700916 * <P>Type: INTEGER</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700917 */
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -0700918 public static final String DATA_ID = "presence_data_id";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700919
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700920 /**
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -0700921 * <p>Type: NUMBER</p>
922 */
923 public static final String PROTOCOL = "protocol";
924
925 /**
926 * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value
927 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or
928 * omitted if {@link #PROTOCOL} value is not
929 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.
930 *
931 * <p>Type: NUMBER</p>
932 */
933 public static final String CUSTOM_PROTOCOL = "custom_protocol";
934
935 /**
936 * The IM handle the presence item is for. The handle is scoped to
937 * {@link #PROTOCOL}.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700938 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700939 */
940 public static final String IM_HANDLE = "im_handle";
941
942 /**
943 * The IM account for the local user that the presence data came from.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -0700944 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700945 */
946 public static final String IM_ACCOUNT = "im_account";
947 }
948
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700949 /**
950 * A status update is linked to a {@link Data} row and captures the user's latest status
951 * update via the corresponding source, e.g. "Having lunch" via "Google Talk".
952 */
953 // TODO make final as soon as Presence is removed
954 public static /*final*/ class StatusUpdates implements StatusColumns, PresenceColumns {
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -0700955
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700956 /**
957 * This utility class cannot be instantiated
958 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700959 private StatusUpdates() {}
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700960
961 /**
962 * The content:// style URI for this table
963 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700964 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates");
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500965
966 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -0700967 * Gets the resource ID for the proper presence icon.
968 *
969 * @param status the status to get the icon for
970 * @return the resource ID for the proper presence icon
971 */
972 public static final int getPresenceIconResourceId(int status) {
973 switch (status) {
974 case AVAILABLE:
975 return android.R.drawable.presence_online;
976 case IDLE:
977 case AWAY:
978 return android.R.drawable.presence_away;
979 case DO_NOT_DISTURB:
980 return android.R.drawable.presence_busy;
981 case INVISIBLE:
982 return android.R.drawable.presence_invisible;
983 case OFFLINE:
984 default:
985 return android.R.drawable.presence_offline;
986 }
987 }
988
989 /**
Evan Millarc0437522009-06-23 17:31:05 -0700990 * Returns the precedence of the status code the higher number being the higher precedence.
991 *
992 * @param status The status code.
993 * @return An integer representing the precedence, 0 being the lowest.
994 */
995 public static final int getPresencePrecedence(int status) {
996 // Keep this function here incase we want to enforce a different precedence than the
997 // natural order of the status constants.
998 return status;
999 }
1000
1001 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001002 * The MIME type of {@link #CONTENT_URI} providing a directory of
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07001003 * status update details.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001004 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07001005 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001006
1007 /**
1008 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07001009 * status update detail.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001010 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07001011 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update";
1012 }
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07001013
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07001014 @Deprecated
1015 public static final class Presence extends StatusUpdates {
1016
Evan Millar088b2912009-05-28 15:24:37 -07001017 }
1018
1019 /**
1020 * Container for definitions of common data types stored in the {@link Data} table.
1021 */
1022 public static final class CommonDataKinds {
1023 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001024 * This utility class cannot be instantiated
1025 */
1026 private CommonDataKinds() {}
1027
1028 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001029 * The {@link Data#RES_PACKAGE} value for common data that should be
1030 * shown using a default style.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001031 *
1032 * @hide RES_PACKAGE is hidden
Evan Millar088b2912009-05-28 15:24:37 -07001033 */
1034 public static final String PACKAGE_COMMON = "common";
1035
1036 /**
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001037 * The base types that all "Typed" data kinds support.
1038 */
1039 public interface BaseTypes {
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001040 /**
1041 * A custom type. The custom label should be supplied by user.
1042 */
1043 public static int TYPE_CUSTOM = 0;
1044 }
1045
1046 /**
Evan Millar088b2912009-05-28 15:24:37 -07001047 * Columns common across the specific types.
1048 */
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001049 private interface CommonColumns extends BaseTypes {
Evan Millar088b2912009-05-28 15:24:37 -07001050 /**
Evan Millar088b2912009-05-28 15:24:37 -07001051 * The data for the contact method.
1052 * <P>Type: TEXT</P>
1053 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001054 public static final String DATA = DataColumns.DATA1;
1055
1056 /**
1057 * The type of data, for example Home or Work.
1058 * <P>Type: INTEGER</P>
1059 */
1060 public static final String TYPE = DataColumns.DATA2;
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07001061
1062 /**
1063 * The user defined label for the the contact method.
1064 * <P>Type: TEXT</P>
1065 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001066 public static final String LABEL = DataColumns.DATA3;
Evan Millar088b2912009-05-28 15:24:37 -07001067 }
1068
1069 /**
1070 * Parts of the name.
1071 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001072 public static final class StructuredName implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001073 /**
1074 * This utility class cannot be instantiated
1075 */
Evan Millar088b2912009-05-28 15:24:37 -07001076 private StructuredName() {}
1077
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001078 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001079 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
1080
1081 /**
Evan Millar088b2912009-05-28 15:24:37 -07001082 * The name that should be used to display the contact.
Jeff Sharkey62b83b72009-08-11 17:33:48 -07001083 * <i>Unstructured component of the name should be consistent with
1084 * its structured representation.</i>
1085 * <p>
1086 * Type: TEXT
Evan Millar088b2912009-05-28 15:24:37 -07001087 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001088 public static final String DISPLAY_NAME = DATA1;
1089
1090 /**
1091 * The given name for the contact.
1092 * <P>Type: TEXT</P>
1093 */
1094 public static final String GIVEN_NAME = DATA2;
1095
1096 /**
1097 * The family name for the contact.
1098 * <P>Type: TEXT</P>
1099 */
1100 public static final String FAMILY_NAME = DATA3;
1101
1102 /**
1103 * The contact's honorific prefix, e.g. "Sir"
1104 * <P>Type: TEXT</P>
1105 */
1106 public static final String PREFIX = DATA4;
1107
1108 /**
1109 * The contact's middle name
1110 * <P>Type: TEXT</P>
1111 */
1112 public static final String MIDDLE_NAME = DATA5;
1113
1114 /**
1115 * The contact's honorific suffix, e.g. "Jr"
1116 */
1117 public static final String SUFFIX = DATA6;
1118
1119 /**
1120 * The phonetic version of the given name for the contact.
1121 * <P>Type: TEXT</P>
1122 */
1123 public static final String PHONETIC_GIVEN_NAME = DATA7;
1124
1125 /**
1126 * The phonetic version of the additional name for the contact.
1127 * <P>Type: TEXT</P>
1128 */
1129 public static final String PHONETIC_MIDDLE_NAME = DATA8;
1130
1131 /**
1132 * The phonetic version of the family name for the contact.
1133 * <P>Type: TEXT</P>
1134 */
1135 public static final String PHONETIC_FAMILY_NAME = DATA9;
Evan Millar088b2912009-05-28 15:24:37 -07001136 }
1137
1138 /**
1139 * A nickname.
1140 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001141 public static final class Nickname implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001142 /**
1143 * This utility class cannot be instantiated
1144 */
Evan Millar088b2912009-05-28 15:24:37 -07001145 private Nickname() {}
1146
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001147 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001148 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
1149
Evan Millar78e79ad2009-06-08 10:24:44 -07001150 public static final int TYPE_DEFAULT = 1;
1151 public static final int TYPE_OTHER_NAME = 2;
1152 public static final int TYPE_MAINDEN_NAME = 3;
1153 public static final int TYPE_SHORT_NAME = 4;
1154 public static final int TYPE_INITIALS = 5;
Evan Millar088b2912009-05-28 15:24:37 -07001155
1156 /**
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07001157 * The name itself
1158 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001159 public static final String NAME = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07001160 }
1161
1162 /**
1163 * Common data definition for telephone numbers.
1164 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001165 public static final class Phone implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001166 /**
1167 * This utility class cannot be instantiated
1168 */
Evan Millar088b2912009-05-28 15:24:37 -07001169 private Phone() {}
1170
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001171 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07001172 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
Evan Millar088b2912009-05-28 15:24:37 -07001173
Evan Millar161dd862009-06-12 16:02:43 -07001174 /**
1175 * The MIME type of {@link #CONTENT_URI} providing a directory of
1176 * phones.
1177 */
Evan Millarb3c49982009-09-01 11:38:04 -07001178 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
Evan Millar161dd862009-06-12 16:02:43 -07001179
1180 /**
1181 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001182 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001183 * associated raw contact and aggregate contact data.
Evan Millar161dd862009-06-12 16:02:43 -07001184 */
1185 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1186 "phones");
1187
1188 /**
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001189 * The content:// style URL for phone lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001190 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001191 * to display names as well as phone numbers. The filter argument should be passed
1192 * as an additional path segment after this URI.
Evan Millar161dd862009-06-12 16:02:43 -07001193 */
1194 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
1195 "filter");
1196
Evan Millar088b2912009-05-28 15:24:37 -07001197 public static final int TYPE_HOME = 1;
1198 public static final int TYPE_MOBILE = 2;
1199 public static final int TYPE_WORK = 3;
1200 public static final int TYPE_FAX_WORK = 4;
1201 public static final int TYPE_FAX_HOME = 5;
1202 public static final int TYPE_PAGER = 6;
1203 public static final int TYPE_OTHER = 7;
Fred Quintana3f867152009-08-03 11:43:16 -07001204 public static final int TYPE_CALLBACK = 8;
1205 public static final int TYPE_CAR = 9;
1206 public static final int TYPE_COMPANY_MAIN = 10;
1207 public static final int TYPE_ISDN = 11;
1208 public static final int TYPE_MAIN = 12;
1209 public static final int TYPE_OTHER_FAX = 13;
1210 public static final int TYPE_RADIO = 14;
1211 public static final int TYPE_TELEX = 15;
1212 public static final int TYPE_TTY_TDD = 16;
1213 public static final int TYPE_WORK_MOBILE = 17;
1214 public static final int TYPE_WORK_PAGER = 18;
1215 public static final int TYPE_ASSISTANT = 19;
Jeff Sharkeyd5abd462009-09-16 19:54:29 -07001216 public static final int TYPE_MMS = 20;
Evan Millar088b2912009-05-28 15:24:37 -07001217
1218 /**
1219 * The phone number as the user entered it.
1220 * <P>Type: TEXT</P>
1221 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001222 public static final String NUMBER = DATA;
Dmitri Plotnikov93032952009-08-19 11:26:57 -07001223
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001224 /**
1225 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001226 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001227 */
1228 @Deprecated
Dmitri Plotnikov93032952009-08-19 11:26:57 -07001229 public static final CharSequence getDisplayLabel(Context context, int type,
1230 CharSequence label, CharSequence[] labelArray) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001231 return getTypeLabel(context.getResources(), type, label);
Dmitri Plotnikov93032952009-08-19 11:26:57 -07001232 }
1233
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001234 /**
1235 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001236 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001237 */
1238 @Deprecated
Dmitri Plotnikov93032952009-08-19 11:26:57 -07001239 public static final CharSequence getDisplayLabel(Context context, int type,
1240 CharSequence label) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001241 return getTypeLabel(context.getResources(), type, label);
1242 }
1243
1244 /**
1245 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001246 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001247 */
1248 public static final int getTypeLabelResource(int type) {
1249 switch (type) {
1250 case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome;
1251 case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile;
1252 case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork;
1253 case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork;
1254 case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome;
1255 case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager;
1256 case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther;
1257 case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback;
1258 case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar;
1259 case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain;
1260 case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn;
1261 case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain;
1262 case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax;
1263 case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio;
1264 case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex;
1265 case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd;
1266 case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile;
1267 case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager;
1268 case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant;
1269 case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms;
1270 default: return com.android.internal.R.string.phoneTypeCustom;
1271 }
1272 }
1273
1274 /**
1275 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001276 * possibly substituting the given {@link #LABEL} value
1277 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001278 */
1279 public static final CharSequence getTypeLabel(Resources res, int type,
1280 CharSequence label) {
1281 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) {
1282 return label;
1283 } else {
1284 final int labelRes = getTypeLabelResource(type);
1285 return res.getText(labelRes);
1286 }
Dmitri Plotnikov93032952009-08-19 11:26:57 -07001287 }
Evan Millar088b2912009-05-28 15:24:37 -07001288 }
1289
1290 /**
1291 * Common data definition for email addresses.
1292 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001293 public static final class Email implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001294 /**
1295 * This utility class cannot be instantiated
1296 */
Evan Millar088b2912009-05-28 15:24:37 -07001297 private Email() {}
1298
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001299 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07001300 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2";
Evan Millar088b2912009-05-28 15:24:37 -07001301
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001302 /**
Dmitri Plotnikovabf15c32009-09-18 20:29:11 -07001303 * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses.
1304 */
1305 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2";
1306
1307 /**
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001308 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001309 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001310 * associated raw contact and aggregate contact data.
1311 */
1312 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1313 "emails");
1314
1315 /**
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001316 * The content:// style URL for looking up data rows by email address. The
1317 * lookup argument, an email address, should be passed as an additional path segment
1318 * after this URI.
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001319 */
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001320 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
1321 "lookup");
1322
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001323 /**
1324 * The content:// style URL for email lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001325 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07001326 * to display names as well as email addresses. The filter argument should be passed
1327 * as an additional path segment after this URI.
1328 */
1329 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001330 "filter");
1331
Evan Millar088b2912009-05-28 15:24:37 -07001332 public static final int TYPE_HOME = 1;
1333 public static final int TYPE_WORK = 2;
1334 public static final int TYPE_OTHER = 3;
Jeff Sharkey14fb1532009-08-29 15:54:26 -07001335 public static final int TYPE_MOBILE = 4;
Fred Quintana8851e162009-08-05 21:06:45 -07001336
1337 /**
1338 * The display name for the email address
1339 * <P>Type: TEXT</P>
1340 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001341 public static final String DISPLAY_NAME = DATA4;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001342
1343 /**
1344 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001345 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001346 */
1347 public static final int getTypeLabelResource(int type) {
1348 switch (type) {
1349 case TYPE_HOME: return com.android.internal.R.string.emailTypeHome;
1350 case TYPE_WORK: return com.android.internal.R.string.emailTypeWork;
1351 case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther;
1352 case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile;
1353 default: return com.android.internal.R.string.emailTypeCustom;
1354 }
1355 }
1356
1357 /**
1358 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001359 * possibly substituting the given {@link #LABEL} value
1360 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001361 */
1362 public static final CharSequence getTypeLabel(Resources res, int type,
1363 CharSequence label) {
1364 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
1365 return label;
1366 } else {
1367 final int labelRes = getTypeLabelResource(type);
1368 return res.getText(labelRes);
1369 }
1370 }
Evan Millar088b2912009-05-28 15:24:37 -07001371 }
1372
1373 /**
1374 * Common data definition for postal addresses.
1375 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001376 public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001377 /**
1378 * This utility class cannot be instantiated
1379 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001380 private StructuredPostal() {
1381 }
Evan Millar088b2912009-05-28 15:24:37 -07001382
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001383 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07001384 public static final String CONTENT_ITEM_TYPE =
1385 "vnd.android.cursor.item/postal-address_v2";
Evan Millar088b2912009-05-28 15:24:37 -07001386
Evan Millar161dd862009-06-12 16:02:43 -07001387 /**
1388 * The MIME type of {@link #CONTENT_URI} providing a directory of
1389 * postal addresses.
1390 */
Evan Millarb3c49982009-09-01 11:38:04 -07001391 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2";
Evan Millar161dd862009-06-12 16:02:43 -07001392
1393 /**
1394 * The content:// style URI for all data records of the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001395 * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
Evan Millar161dd862009-06-12 16:02:43 -07001396 */
1397 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
1398 "postals");
1399
Evan Millar088b2912009-05-28 15:24:37 -07001400 public static final int TYPE_HOME = 1;
1401 public static final int TYPE_WORK = 2;
1402 public static final int TYPE_OTHER = 3;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001403
1404 /**
Jeff Sharkey62b83b72009-08-11 17:33:48 -07001405 * The full, unstructured postal address. <i>This field must be
1406 * consistent with any structured data.</i>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001407 * <p>
1408 * Type: TEXT
1409 */
1410 public static final String FORMATTED_ADDRESS = DATA;
1411
1412 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001413 * Can be street, avenue, road, etc. This element also includes the
1414 * house number and room/apartment/flat/floor number.
1415 * <p>
1416 * Type: TEXT
1417 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001418 public static final String STREET = DATA4;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001419
1420 /**
1421 * Covers actual P.O. boxes, drawers, locked bags, etc. This is
1422 * usually but not always mutually exclusive with street.
1423 * <p>
1424 * Type: TEXT
1425 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001426 public static final String POBOX = DATA5;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001427
1428 /**
1429 * This is used to disambiguate a street address when a city
1430 * contains more than one street with the same name, or to specify a
1431 * small place whose mail is routed through a larger postal town. In
1432 * China it could be a county or a minor city.
1433 * <p>
1434 * Type: TEXT
1435 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001436 public static final String NEIGHBORHOOD = DATA6;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001437
1438 /**
1439 * Can be city, village, town, borough, etc. This is the postal town
1440 * and not necessarily the place of residence or place of business.
1441 * <p>
1442 * Type: TEXT
1443 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001444 public static final String CITY = DATA7;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001445
1446 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001447 * A state, province, county (in Ireland), Land (in Germany),
1448 * departement (in France), etc.
1449 * <p>
1450 * Type: TEXT
1451 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001452 public static final String REGION = DATA8;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001453
1454 /**
Jeff Sharkeyef348c72009-07-26 14:14:34 -07001455 * Postal code. Usually country-wide, but sometimes specific to the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001456 * city (e.g. "2" in "Dublin 2, Ireland" addresses).
1457 * <p>
1458 * Type: TEXT
1459 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001460 public static final String POSTCODE = DATA9;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001461
1462 /**
1463 * The name or code of the country.
1464 * <p>
1465 * Type: TEXT
1466 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001467 public static final String COUNTRY = DATA10;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001468
1469 /**
1470 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001471 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001472 */
1473 public static final int getTypeLabelResource(int type) {
1474 switch (type) {
1475 case TYPE_HOME: return com.android.internal.R.string.postalTypeHome;
1476 case TYPE_WORK: return com.android.internal.R.string.postalTypeWork;
1477 case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther;
1478 default: return com.android.internal.R.string.postalTypeCustom;
1479 }
1480 }
1481
1482 /**
1483 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001484 * possibly substituting the given {@link #LABEL} value
1485 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001486 */
1487 public static final CharSequence getTypeLabel(Resources res, int type,
1488 CharSequence label) {
1489 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
1490 return label;
1491 } else {
1492 final int labelRes = getTypeLabelResource(type);
1493 return res.getText(labelRes);
1494 }
1495 }
Evan Millar088b2912009-05-28 15:24:37 -07001496 }
1497
Fred Quintana8851e162009-08-05 21:06:45 -07001498 /**
1499 * Common data definition for IM addresses.
1500 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001501 public static final class Im implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001502 /**
1503 * This utility class cannot be instantiated
1504 */
Evan Millar088b2912009-05-28 15:24:37 -07001505 private Im() {}
1506
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001507 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001508 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
1509
Evan Millar088b2912009-05-28 15:24:37 -07001510 public static final int TYPE_HOME = 1;
1511 public static final int TYPE_WORK = 2;
1512 public static final int TYPE_OTHER = 3;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07001513
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07001514 /**
1515 * This column should be populated with one of the defined
1516 * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this
1517 * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL}
1518 * should contain the name of the custom protocol.
1519 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001520 public static final String PROTOCOL = DATA5;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07001521
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001522 public static final String CUSTOM_PROTOCOL = DATA6;
Jeff Sharkey732da922009-07-30 09:59:31 -07001523
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07001524 /*
1525 * The predefined IM protocol types.
Evan Millar088b2912009-05-28 15:24:37 -07001526 */
Jeff Sharkey732da922009-07-30 09:59:31 -07001527 public static final int PROTOCOL_CUSTOM = -1;
Evan Millar088b2912009-05-28 15:24:37 -07001528 public static final int PROTOCOL_AIM = 0;
1529 public static final int PROTOCOL_MSN = 1;
1530 public static final int PROTOCOL_YAHOO = 2;
1531 public static final int PROTOCOL_SKYPE = 3;
1532 public static final int PROTOCOL_QQ = 4;
1533 public static final int PROTOCOL_GOOGLE_TALK = 5;
1534 public static final int PROTOCOL_ICQ = 6;
1535 public static final int PROTOCOL_JABBER = 7;
Fred Quintana8851e162009-08-05 21:06:45 -07001536 public static final int PROTOCOL_NETMEETING = 8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001537
1538 /**
1539 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001540 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001541 */
1542 public static final int getTypeLabelResource(int type) {
1543 switch (type) {
1544 case TYPE_HOME: return com.android.internal.R.string.imTypeHome;
1545 case TYPE_WORK: return com.android.internal.R.string.imTypeWork;
1546 case TYPE_OTHER: return com.android.internal.R.string.imTypeOther;
1547 default: return com.android.internal.R.string.imTypeCustom;
1548 }
1549 }
1550
1551 /**
1552 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001553 * possibly substituting the given {@link #LABEL} value
1554 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001555 */
1556 public static final CharSequence getTypeLabel(Resources res, int type,
1557 CharSequence label) {
1558 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
1559 return label;
1560 } else {
1561 final int labelRes = getTypeLabelResource(type);
1562 return res.getText(labelRes);
1563 }
1564 }
1565
1566 /**
1567 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001568 * {@link #PROTOCOL}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001569 */
1570 public static final int getProtocolLabelResource(int type) {
1571 switch (type) {
1572 case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim;
1573 case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn;
1574 case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo;
1575 case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype;
1576 case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq;
1577 case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk;
1578 case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq;
1579 case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber;
1580 case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting;
1581 default: return com.android.internal.R.string.imProtocolCustom;
1582 }
1583 }
1584
1585 /**
1586 * Return a {@link CharSequence} that best describes the given
1587 * protocol, possibly substituting the given
1588 * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}.
1589 */
1590 public static final CharSequence getProtocolLabel(Resources res, int type,
1591 CharSequence label) {
1592 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) {
1593 return label;
1594 } else {
1595 final int labelRes = getProtocolLabelResource(type);
1596 return res.getText(labelRes);
1597 }
1598 }
Evan Millar088b2912009-05-28 15:24:37 -07001599 }
1600
1601 /**
1602 * Common data definition for organizations.
1603 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001604 public static final class Organization implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001605 /**
1606 * This utility class cannot be instantiated
1607 */
Evan Millar088b2912009-05-28 15:24:37 -07001608 private Organization() {}
1609
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001610 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001611 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
1612
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001613 public static final int TYPE_WORK = 1;
1614 public static final int TYPE_OTHER = 2;
Evan Millar088b2912009-05-28 15:24:37 -07001615
1616 /**
1617 * The company as the user entered it.
1618 * <P>Type: TEXT</P>
1619 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07001620 public static final String COMPANY = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07001621
1622 /**
1623 * The position title at this company as the user entered it.
1624 * <P>Type: TEXT</P>
1625 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001626 public static final String TITLE = DATA4;
Fred Quintana8851e162009-08-05 21:06:45 -07001627
1628 /**
1629 * The department at this company as the user entered it.
1630 * <P>Type: TEXT</P>
1631 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001632 public static final String DEPARTMENT = DATA5;
Fred Quintana8851e162009-08-05 21:06:45 -07001633
1634 /**
1635 * The job description at this company as the user entered it.
1636 * <P>Type: TEXT</P>
1637 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001638 public static final String JOB_DESCRIPTION = DATA6;
Fred Quintana8851e162009-08-05 21:06:45 -07001639
1640 /**
1641 * The symbol of this company as the user entered it.
1642 * <P>Type: TEXT</P>
1643 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001644 public static final String SYMBOL = DATA7;
Fred Quintana8851e162009-08-05 21:06:45 -07001645
1646 /**
1647 * The phonetic name of this company as the user entered it.
1648 * <P>Type: TEXT</P>
1649 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001650 public static final String PHONETIC_NAME = DATA8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001651
1652 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001653 * The office location of this organization.
1654 * <P>Type: TEXT</P>
1655 */
1656 public static final String OFFICE_LOCATION = DATA9;
1657
1658 /**
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001659 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001660 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001661 */
1662 public static final int getTypeLabelResource(int type) {
1663 switch (type) {
1664 case TYPE_WORK: return com.android.internal.R.string.orgTypeWork;
1665 case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther;
1666 default: return com.android.internal.R.string.orgTypeCustom;
1667 }
1668 }
1669
1670 /**
1671 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001672 * possibly substituting the given {@link #LABEL} value
1673 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07001674 */
1675 public static final CharSequence getTypeLabel(Resources res, int type,
1676 CharSequence label) {
1677 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
1678 return label;
1679 } else {
1680 final int labelRes = getTypeLabelResource(type);
1681 return res.getText(labelRes);
1682 }
1683 }
Fred Quintana8851e162009-08-05 21:06:45 -07001684 }
1685
1686 /**
Fred Quintanaf5808412009-09-24 15:37:39 -07001687 * Common data definition for birthdays.
Fred Quintana8851e162009-08-05 21:06:45 -07001688 */
Fred Quintanaf5808412009-09-24 15:37:39 -07001689 public static final class Birthday implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001690 /**
1691 * This utility class cannot be instantiated
1692 */
Fred Quintanaf5808412009-09-24 15:37:39 -07001693 private Birthday() {}
Fred Quintana8851e162009-08-05 21:06:45 -07001694
1695 /** MIME type used when storing this in data table. */
Fred Quintanaf5808412009-09-24 15:37:39 -07001696 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/birthday";
Fred Quintana8851e162009-08-05 21:06:45 -07001697
1698 /**
Fred Quintanaf5808412009-09-24 15:37:39 -07001699 * The birthday. This must be of the form YYYY-MM-DD or YYYY-MM-DDThh:mm:ss
1700 * These are xs:date and xs:dateTime
Fred Quintana8851e162009-08-05 21:06:45 -07001701 * <P>Type: TEXT</P>
1702 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001703 public static final String BIRTHDAY = DATA1;
Fred Quintana8851e162009-08-05 21:06:45 -07001704 }
1705
1706 /**
1707 * Common data definition for relations.
1708 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001709 public static final class Relation implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001710 /**
1711 * This utility class cannot be instantiated
1712 */
Fred Quintana8851e162009-08-05 21:06:45 -07001713 private Relation() {}
1714
1715 /** MIME type used when storing this in data table. */
1716 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
1717
1718 public static final int TYPE_ASSISTANT = 1;
1719 public static final int TYPE_BROTHER = 2;
1720 public static final int TYPE_CHILD = 3;
1721 public static final int TYPE_DOMESTIC_PARTNER = 4;
1722 public static final int TYPE_FATHER = 5;
1723 public static final int TYPE_FRIEND = 6;
1724 public static final int TYPE_MANAGER = 7;
1725 public static final int TYPE_MOTHER = 8;
1726 public static final int TYPE_PARENT = 9;
1727 public static final int TYPE_PARTNER = 10;
1728 public static final int TYPE_REFERRED_BY = 11;
1729 public static final int TYPE_RELATIVE = 12;
1730 public static final int TYPE_SISTER = 13;
1731 public static final int TYPE_SPOUSE = 14;
1732
1733 /**
1734 * The name of the relative as the user entered it.
1735 * <P>Type: TEXT</P>
1736 */
1737 public static final String NAME = DATA;
1738 }
1739
1740 /**
1741 * Common data definition for events.
1742 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001743 public static final class Event implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001744 /**
1745 * This utility class cannot be instantiated
1746 */
Fred Quintana8851e162009-08-05 21:06:45 -07001747 private Event() {}
1748
1749 /** MIME type used when storing this in data table. */
1750 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/event";
1751
1752 public static final int TYPE_ANNIVERSARY = 1;
1753 public static final int TYPE_OTHER = 2;
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07001754
Fred Quintana8851e162009-08-05 21:06:45 -07001755 /**
1756 * The event start date as the user entered it.
1757 * <P>Type: TEXT</P>
1758 */
1759 public static final String START_DATE = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07001760 }
1761
1762 /**
1763 * Photo of the contact.
1764 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001765 public static final class Photo implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001766 /**
1767 * This utility class cannot be instantiated
1768 */
Evan Millar088b2912009-05-28 15:24:37 -07001769 private Photo() {}
1770
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001771 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001772 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
1773
1774 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07001775 * Thumbnail photo of the raw contact. This is the raw bytes of an image
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07001776 * that could be inflated using {@link android.graphics.BitmapFactory}.
Evan Millar088b2912009-05-28 15:24:37 -07001777 * <p>
1778 * Type: BLOB
1779 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001780 public static final String PHOTO = DATA15;
Evan Millar088b2912009-05-28 15:24:37 -07001781 }
1782
1783 /**
1784 * Notes about the contact.
1785 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001786 public static final class Note implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001787 /**
1788 * This utility class cannot be instantiated
1789 */
Evan Millar088b2912009-05-28 15:24:37 -07001790 private Note() {}
1791
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001792 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07001793 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
1794
1795 /**
1796 * The note text.
1797 * <P>Type: TEXT</P>
1798 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001799 public static final String NOTE = DATA1;
Evan Millar088b2912009-05-28 15:24:37 -07001800 }
Dmitri Plotnikov56927772009-05-28 17:23:39 -07001801
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07001802 /**
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001803 * Group Membership.
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001804 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001805 public static final class GroupMembership implements DataColumnsWithJoins {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001806 /**
1807 * This utility class cannot be instantiated
1808 */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001809 private GroupMembership() {}
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001810
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001811 /** MIME type used when storing this in data table. */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001812 public static final String CONTENT_ITEM_TYPE =
1813 "vnd.android.cursor.item/group_membership";
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001814
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001815 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07001816 * The row id of the group that this group membership refers to. Exactly one of
1817 * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001818 * <P>Type: INTEGER</P>
1819 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001820 public static final String GROUP_ROW_ID = DATA1;
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001821
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001822 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07001823 * The sourceid of the group that this group membership refers to. Exactly one of
1824 * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001825 * <P>Type: TEXT</P>
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001826 */
Fred Quintanaffc34c12009-07-14 16:02:58 -07001827 public static final String GROUP_SOURCE_ID = "group_sourceid";
Fred Quintanad8dfeb52009-06-04 10:28:49 -07001828 }
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001829
1830 /**
1831 * Website related to the contact.
1832 */
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07001833 public static final class Website implements DataColumnsWithJoins, CommonColumns {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001834 /**
1835 * This utility class cannot be instantiated
1836 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001837 private Website() {}
1838
1839 /** MIME type used when storing this in data table. */
1840 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
1841
Fred Quintana8851e162009-08-05 21:06:45 -07001842 public static final int TYPE_HOMEPAGE = 1;
1843 public static final int TYPE_BLOG = 2;
1844 public static final int TYPE_PROFILE = 3;
1845 public static final int TYPE_HOME = 4;
1846 public static final int TYPE_WORK = 5;
1847 public static final int TYPE_FTP = 6;
1848 public static final int TYPE_OTHER = 7;
1849
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001850 /**
1851 * The website URL string.
1852 * <P>Type: TEXT</P>
1853 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07001854 public static final String URL = DATA;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001855 }
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07001856 }
Fred Quintana435e4272009-06-04 17:30:28 -07001857
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001858 private interface GroupsColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001859 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001860 * The display title of this group.
1861 * <p>
1862 * Type: TEXT
1863 */
1864 public static final String TITLE = "title";
1865
1866 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001867 * The package name to use when creating {@link Resources} objects for
1868 * this group. This value is only designed for use when building user
1869 * interfaces, and should not be used to infer the owner.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001870 *
1871 * @hide
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001872 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001873 public static final String RES_PACKAGE = "res_package";
1874
1875 /**
1876 * The display title of this group to load as a resource from
1877 * {@link #RES_PACKAGE}, which may be localized.
1878 * <P>Type: TEXT</P>
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001879 *
1880 * @hide
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001881 */
1882 public static final String TITLE_RES = "title_res";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001883
1884 /**
Dmitri Plotnikov02c5b452009-07-22 15:13:08 -07001885 * Notes about the group.
1886 * <p>
1887 * Type: TEXT
1888 */
1889 public static final String NOTES = "notes";
1890
1891 /**
1892 * The ID of this group if it is a System Group, i.e. a group that has a special meaning
1893 * to the sync adapter, null otherwise.
1894 * <P>Type: TEXT</P>
1895 */
1896 public static final String SYSTEM_ID = "system_id";
1897
1898 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001899 * The total number of {@link Contacts} that have
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07001900 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001901 * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
1902 * <p>
1903 * Type: INTEGER
1904 */
1905 public static final String SUMMARY_COUNT = "summ_count";
1906
1907 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001908 * The total number of {@link Contacts} that have both
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07001909 * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001910 * Read-only value that is only present when querying
1911 * {@link Groups#CONTENT_SUMMARY_URI}.
1912 * <p>
1913 * Type: INTEGER
1914 */
1915 public static final String SUMMARY_WITH_PHONES = "summ_phones";
1916
1917 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001918 * Flag indicating if the contacts belonging to this group should be
1919 * visible in any user interface.
1920 * <p>
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07001921 * Type: INTEGER (boolean)
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001922 */
1923 public static final String GROUP_VISIBLE = "group_visible";
Fred Quintana00c89f62009-08-10 14:43:24 -07001924
1925 /**
1926 * The "deleted" flag: "0" by default, "1" if the row has been marked
1927 * for deletion. When {@link android.content.ContentResolver#delete} is
1928 * called on a raw contact, it is marked for deletion and removed from its
1929 * aggregate contact. The sync adaptor deletes the raw contact on the server and
Fred Quintana33f889a2009-09-14 17:31:26 -07001930 * then calls ContactResolver.delete once more, this time setting the the
Jeff Sharkey97bda4c2009-09-15 23:15:23 -07001931 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
Fred Quintana33f889a2009-09-14 17:31:26 -07001932 * the data removal.
Fred Quintana00c89f62009-08-10 14:43:24 -07001933 * <P>Type: INTEGER</P>
1934 */
1935 public static final String DELETED = "deleted";
Jeff Sharkey403d7ac2009-08-16 16:34:35 -07001936
1937 /**
1938 * Whether this group should be synced if the SYNC_EVERYTHING settings
1939 * is false for this group's account.
1940 * <p>
1941 * Type: INTEGER (boolean)
1942 */
1943 public static final String SHOULD_SYNC = "should_sync";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001944 }
1945
1946 /**
1947 * Constants for the groups table.
1948 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001949 public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001950 /**
1951 * This utility class cannot be instantiated
1952 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07001953 private Groups() {
1954 }
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001955
1956 /**
1957 * The content:// style URI for this table
1958 */
1959 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
1960
1961 /**
1962 * The content:// style URI for this table joined with details data from
Dmitri Plotnikov02c5b452009-07-22 15:13:08 -07001963 * {@link Data}.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001964 */
1965 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
1966 "groups_summary");
1967
1968 /**
1969 * The MIME type of a directory of groups.
1970 */
1971 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
1972
1973 /**
1974 * The MIME type of a single group.
1975 */
1976 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
1977 }
1978
Fred Quintana435e4272009-06-04 17:30:28 -07001979 /**
1980 * Constants for the contact aggregation exceptions table, which contains
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07001981 * aggregation rules overriding those used by automatic aggregation. This type only
1982 * supports query and update. Neither insert nor delete are supported.
Fred Quintana435e4272009-06-04 17:30:28 -07001983 */
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001984 public static final class AggregationExceptions implements BaseColumns {
Fred Quintana435e4272009-06-04 17:30:28 -07001985 /**
1986 * This utility class cannot be instantiated
1987 */
1988 private AggregationExceptions() {}
1989
1990 /**
1991 * The content:// style URI for this table
1992 */
1993 public static final Uri CONTENT_URI =
1994 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
1995
1996 /**
1997 * The MIME type of {@link #CONTENT_URI} providing a directory of data.
1998 */
1999 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
2000
2001 /**
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07002002 * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
2003 */
2004 public static final String CONTENT_ITEM_TYPE =
2005 "vnd.android.cursor.item/aggregation_exception";
2006
2007 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002008 * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002009 * {@link #TYPE_AUTOMATIC}.
Fred Quintana435e4272009-06-04 17:30:28 -07002010 *
2011 * <P>Type: INTEGER</P>
2012 */
2013 public static final String TYPE = "type";
2014
Fred Quintana435e4272009-06-04 17:30:28 -07002015 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002016 * Allows the provider to automatically decide whether the specified raw contacts should
2017 * be included in the same aggregate contact or not.
Fred Quintana435e4272009-06-04 17:30:28 -07002018 */
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002019 public static final int TYPE_AUTOMATIC = 0;
Fred Quintana435e4272009-06-04 17:30:28 -07002020
2021 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002022 * Makes sure that the specified raw contacts are included in the same
2023 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002024 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002025 public static final int TYPE_KEEP_TOGETHER = 1;
2026
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002027 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002028 * Makes sure that the specified raw contacts are NOT included in the same
2029 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002030 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002031 public static final int TYPE_KEEP_SEPARATE = 2;
2032
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07002033 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002034 * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
Fred Quintana435e4272009-06-04 17:30:28 -07002035 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07002036 public static final String RAW_CONTACT_ID1 = "raw_contact_id1";
2037
2038 /**
2039 * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule
2040 * applies to.
2041 */
2042 public static final String RAW_CONTACT_ID2 = "raw_contact_id2";
Fred Quintana435e4272009-06-04 17:30:28 -07002043 }
Jeff Sharkey28b68e52009-06-10 15:26:58 -07002044
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002045 private interface SettingsColumns {
2046 /**
2047 * The name of the account instance to which this row belongs.
2048 * <P>Type: TEXT</P>
2049 */
2050 public static final String ACCOUNT_NAME = "account_name";
2051
2052 /**
2053 * The type of account to which this row belongs, which when paired with
2054 * {@link #ACCOUNT_NAME} identifies a specific account.
2055 * <P>Type: TEXT</P>
2056 */
2057 public static final String ACCOUNT_TYPE = "account_type";
2058
2059 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07002060 * Depending on the mode defined by the sync-adapter, this flag controls
2061 * the top-level sync behavior for this data source.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002062 * <p>
2063 * Type: INTEGER (boolean)
2064 */
2065 public static final String SHOULD_SYNC = "should_sync";
2066
2067 /**
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07002068 * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership}
Jeff Sharkeya6597442009-08-19 09:23:33 -07002069 * entries should be visible in any user interface.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002070 * <p>
2071 * Type: INTEGER (boolean)
2072 */
2073 public static final String UNGROUPED_VISIBLE = "ungrouped_visible";
Jeff Sharkey06a03232009-08-21 17:37:56 -07002074
2075 /**
Jeff Sharkey97bda4c2009-09-15 23:15:23 -07002076 * Read-only flag indicating if this {@link #SHOULD_SYNC} or any
2077 * {@link Groups#SHOULD_SYNC} under this account have been marked as
2078 * unsynced.
2079 */
2080 public static final String ANY_UNSYNCED = "any_unsynced";
2081
2082 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07002083 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07002084 * no {@link CommonDataKinds.GroupMembership} entries.
Jeff Sharkey06a03232009-08-21 17:37:56 -07002085 * <p>
2086 * Type: INTEGER
2087 */
2088 public static final String UNGROUPED_COUNT = "summ_count";
2089
2090 /**
2091 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07002092 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers.
Jeff Sharkey06a03232009-08-21 17:37:56 -07002093 * <p>
2094 * Type: INTEGER
2095 */
2096 public static final String UNGROUPED_WITH_PHONES = "summ_phones";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002097 }
2098
2099 /**
2100 * Contacts-specific settings for various {@link Account}.
2101 */
Jeff Sharkey06a03232009-08-21 17:37:56 -07002102 public static final class Settings implements SettingsColumns {
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002103 /**
2104 * This utility class cannot be instantiated
2105 */
2106 private Settings() {
2107 }
2108
2109 /**
2110 * The content:// style URI for this table
2111 */
2112 public static final Uri CONTENT_URI =
2113 Uri.withAppendedPath(AUTHORITY_URI, "settings");
2114
2115 /**
2116 * The MIME-type of {@link #CONTENT_URI} providing a directory of
2117 * settings.
2118 */
2119 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting";
2120
2121 /**
2122 * The MIME-type of {@link #CONTENT_URI} providing a single setting.
2123 */
2124 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07002125 }
2126
Evan Millardc2da5f2009-06-18 16:07:13 -07002127 /**
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002128 * Helper methods to display FastTrack dialogs that allow users to pivot on
2129 * a specific {@link Contacts} entry.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002130 *
2131 * @hide
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002132 */
2133 public static final class FastTrack {
2134 /**
2135 * Action used to trigger person pivot dialog.
2136 * @hide
2137 */
2138 public static final String ACTION_FAST_TRACK =
Jeff Sharkey0050ee32009-09-17 16:11:32 -07002139 "com.android.contacts.action.FAST_TRACK";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002140
2141 /**
2142 * Extra used to specify pivot dialog location in screen coordinates.
2143 * @hide
2144 */
2145 public static final String EXTRA_TARGET_RECT = "target_rect";
2146
2147 /**
2148 * Extra used to specify size of pivot dialog.
2149 * @hide
2150 */
2151 public static final String EXTRA_MODE = "mode";
2152
2153 /**
2154 * Extra used to indicate a list of specific MIME-types to exclude and
2155 * not display. Stored as a {@link String} array.
2156 * @hide
2157 */
2158 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
2159
2160 /**
2161 * Small FastTrack mode, usually presented with minimal actions.
2162 */
2163 public static final int MODE_SMALL = 1;
2164
2165 /**
2166 * Medium FastTrack mode, includes actions and light summary describing
2167 * the {@link Contacts} entry being shown. This may include social
2168 * status and presence details.
2169 */
2170 public static final int MODE_MEDIUM = 2;
2171
2172 /**
2173 * Large FastTrack mode, includes actions and larger, card-like summary
2174 * of the {@link Contacts} entry being shown. This may include detailed
2175 * information, such as a photo.
2176 */
2177 public static final int MODE_LARGE = 3;
2178
2179 /**
2180 * Trigger a dialog that lists the various methods of interacting with
2181 * the requested {@link Contacts} entry. This may be based on available
2182 * {@link Data} rows under that contact, and may also include social
2183 * status and presence details.
2184 *
2185 * @param context The parent {@link Context} that may be used as the
2186 * parent for this dialog.
2187 * @param target Specific {@link View} from your layout that this dialog
2188 * should be centered around. In particular, if the dialog
2189 * has a "callout" arrow, it will be pointed and centered
2190 * around this {@link View}.
2191 * @param lookupUri A {@link Contacts#CONTENT_LOOKUP_URI} style
2192 * {@link Uri} that describes a specific contact to feature
2193 * in this dialog.
2194 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
2195 * {@link #MODE_LARGE}, indicating the desired dialog size,
2196 * when supported.
2197 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
2198 * to exclude when showing this dialog. For example, when
2199 * already viewing the contact details card, this can be used
2200 * to omit the details entry from the dialog.
2201 */
2202 public static void showFastTrack(Context context, View target, Uri lookupUri, int mode,
2203 String[] excludeMimes) {
2204 // Find location and bounds of target view
2205 final int[] location = new int[2];
2206 target.getLocationOnScreen(location);
2207
2208 final Rect rect = new Rect();
2209 rect.left = location[0];
2210 rect.top = location[1];
2211 rect.right = rect.left + target.getWidth();
2212 rect.bottom = rect.top + target.getHeight();
2213
2214 // Trigger with obtained rectangle
2215 showFastTrack(context, rect, lookupUri, mode, excludeMimes);
2216 }
2217
2218 /**
2219 * Trigger a dialog that lists the various methods of interacting with
2220 * the requested {@link Contacts} entry. This may be based on available
2221 * {@link Data} rows under that contact, and may also include social
2222 * status and presence details.
2223 *
2224 * @param context The parent {@link Context} that may be used as the
2225 * parent for this dialog.
2226 * @param target Specific {@link Rect} that this dialog should be
2227 * centered around, in screen coordinates. In particular, if
2228 * the dialog has a "callout" arrow, it will be pointed and
2229 * centered around this {@link Rect}.
2230 * @param lookupUri A {@link Contacts#CONTENT_LOOKUP_URI} style
2231 * {@link Uri} that describes a specific contact to feature
2232 * in this dialog.
2233 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
2234 * {@link #MODE_LARGE}, indicating the desired dialog size,
2235 * when supported.
2236 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
2237 * to exclude when showing this dialog. For example, when
2238 * already viewing the contact details card, this can be used
2239 * to omit the details entry from the dialog.
2240 */
2241 public static void showFastTrack(Context context, Rect target, Uri lookupUri, int mode,
2242 String[] excludeMimes) {
2243 // Launch pivot dialog through intent for now
2244 final Intent intent = new Intent(ACTION_FAST_TRACK);
2245 intent.setData(lookupUri);
2246 intent.putExtra(EXTRA_TARGET_RECT, target);
2247 intent.putExtra(EXTRA_MODE, mode);
2248 intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes);
2249 context.startActivity(intent);
2250 }
2251 }
2252
2253 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07002254 * Contains helper classes used to create or manage {@link android.content.Intent Intents}
2255 * that involve contacts.
2256 */
2257 public static final class Intents {
2258 /**
2259 * This is the intent that is fired when a search suggestion is clicked on.
2260 */
2261 public static final String SEARCH_SUGGESTION_CLICKED =
2262 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
2263
2264 /**
2265 * This is the intent that is fired when a search suggestion for dialing a number
2266 * is clicked on.
2267 */
2268 public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
2269 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
2270
2271 /**
2272 * This is the intent that is fired when a search suggestion for creating a contact
2273 * is clicked on.
2274 */
2275 public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
2276 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
2277
2278 /**
2279 * Starts an Activity that lets the user pick a contact to attach an image to.
2280 * After picking the contact it launches the image cropper in face detection mode.
2281 */
2282 public static final String ATTACH_IMAGE =
2283 "com.android.contacts.action.ATTACH_IMAGE";
2284
2285 /**
2286 * Takes as input a data URI with a mailto: or tel: scheme. If a single
2287 * contact exists with the given data it will be shown. If no contact
2288 * exists, a dialog will ask the user if they want to create a new
2289 * contact with the provided details filled in. If multiple contacts
2290 * share the data the user will be prompted to pick which contact they
2291 * want to view.
2292 * <p>
2293 * For <code>mailto:</code> URIs, the scheme specific portion must be a
2294 * raw email address, such as one built using
2295 * {@link Uri#fromParts(String, String, String)}.
2296 * <p>
2297 * For <code>tel:</code> URIs, the scheme specific portion is compared
2298 * to existing numbers using the standard caller ID lookup algorithm.
2299 * The number must be properly encoded, for example using
2300 * {@link Uri#fromParts(String, String, String)}.
2301 * <p>
2302 * Any extras from the {@link Insert} class will be passed along to the
2303 * create activity if there are no contacts to show.
2304 * <p>
2305 * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
2306 * prompting the user when the contact doesn't exist.
2307 */
2308 public static final String SHOW_OR_CREATE_CONTACT =
2309 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
2310
2311 /**
2312 * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
2313 * contact if no matching contact found. Otherwise, default behavior is
2314 * to prompt user with dialog before creating.
2315 * <p>
2316 * Type: BOOLEAN
2317 */
2318 public static final String EXTRA_FORCE_CREATE =
2319 "com.android.contacts.action.FORCE_CREATE";
2320
2321 /**
2322 * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
2323 * description to be shown when prompting user about creating a new
2324 * contact.
2325 * <p>
2326 * Type: STRING
2327 */
2328 public static final String EXTRA_CREATE_DESCRIPTION =
2329 "com.android.contacts.action.CREATE_DESCRIPTION";
2330
2331 /**
Jeff Sharkey11322002009-06-04 17:25:51 -07002332 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
2333 * dialog location using screen coordinates. When not specified, the
2334 * dialog will be centered.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002335 *
2336 * @hide
Jeff Sharkey11322002009-06-04 17:25:51 -07002337 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002338 @Deprecated
Jeff Sharkey11322002009-06-04 17:25:51 -07002339 public static final String EXTRA_TARGET_RECT = "target_rect";
2340
2341 /**
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002342 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
2343 * desired dialog style, usually a variation on size. One of
2344 * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002345 *
2346 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002347 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002348 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002349 public static final String EXTRA_MODE = "mode";
2350
2351 /**
2352 * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002353 *
2354 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002355 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002356 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002357 public static final int MODE_SMALL = 1;
2358
2359 /**
2360 * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002361 *
2362 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002363 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002364 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002365 public static final int MODE_MEDIUM = 2;
2366
2367 /**
2368 * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002369 *
2370 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002371 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002372 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07002373 public static final int MODE_LARGE = 3;
2374
2375 /**
Jeff Sharkey84235ee2009-08-23 14:07:02 -07002376 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate
2377 * a list of specific MIME-types to exclude and not display. Stored as a
2378 * {@link String} array.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002379 *
2380 * @hide
Jeff Sharkey84235ee2009-08-23 14:07:02 -07002381 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002382 @Deprecated
Jeff Sharkey84235ee2009-08-23 14:07:02 -07002383 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
2384
2385 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07002386 * Intents related to the Contacts app UI.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002387 *
2388 * @hide
Evan Millardc2da5f2009-06-18 16:07:13 -07002389 */
2390 public static final class UI {
2391 /**
2392 * The action for the default contacts list tab.
2393 */
2394 public static final String LIST_DEFAULT =
2395 "com.android.contacts.action.LIST_DEFAULT";
2396
2397 /**
2398 * The action for the contacts list tab.
2399 */
2400 public static final String LIST_GROUP_ACTION =
2401 "com.android.contacts.action.LIST_GROUP";
2402
2403 /**
2404 * When in LIST_GROUP_ACTION mode, this is the group to display.
2405 */
2406 public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP";
2407
2408 /**
2409 * The action for the all contacts list tab.
2410 */
2411 public static final String LIST_ALL_CONTACTS_ACTION =
2412 "com.android.contacts.action.LIST_ALL_CONTACTS";
2413
2414 /**
2415 * The action for the contacts with phone numbers list tab.
2416 */
2417 public static final String LIST_CONTACTS_WITH_PHONES_ACTION =
2418 "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES";
2419
2420 /**
2421 * The action for the starred contacts list tab.
2422 */
2423 public static final String LIST_STARRED_ACTION =
2424 "com.android.contacts.action.LIST_STARRED";
2425
2426 /**
2427 * The action for the frequent contacts list tab.
2428 */
2429 public static final String LIST_FREQUENT_ACTION =
2430 "com.android.contacts.action.LIST_FREQUENT";
2431
2432 /**
2433 * The action for the "strequent" contacts list tab. It first lists the starred
2434 * contacts in alphabetical order and then the frequent contacts in descending
2435 * order of the number of times they have been contacted.
2436 */
2437 public static final String LIST_STREQUENT_ACTION =
2438 "com.android.contacts.action.LIST_STREQUENT";
2439
2440 /**
2441 * A key for to be used as an intent extra to set the activity
2442 * title to a custom String value.
2443 */
2444 public static final String TITLE_EXTRA_KEY =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002445 "com.android.contacts.extra.TITLE_EXTRA";
Evan Millardc2da5f2009-06-18 16:07:13 -07002446
2447 /**
2448 * Activity Action: Display a filtered list of contacts
2449 * <p>
2450 * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for
2451 * filtering
2452 * <p>
2453 * Output: Nothing.
2454 */
2455 public static final String FILTER_CONTACTS_ACTION =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002456 "com.android.contacts.action.FILTER_CONTACTS";
Evan Millardc2da5f2009-06-18 16:07:13 -07002457
2458 /**
2459 * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION}
2460 * intents to supply the text on which to filter.
2461 */
2462 public static final String FILTER_TEXT_EXTRA_KEY =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002463 "com.android.contacts.extra.FILTER_TEXT";
Evan Millardc2da5f2009-06-18 16:07:13 -07002464 }
2465
2466 /**
2467 * Convenience class that contains string constants used
2468 * to create contact {@link android.content.Intent Intents}.
2469 */
2470 public static final class Insert {
2471 /** The action code to use when adding a contact */
2472 public static final String ACTION = Intent.ACTION_INSERT;
2473
2474 /**
2475 * If present, forces a bypass of quick insert mode.
2476 */
2477 public static final String FULL_MODE = "full_mode";
2478
2479 /**
2480 * The extra field for the contact name.
2481 * <P>Type: String</P>
2482 */
2483 public static final String NAME = "name";
2484
2485 // TODO add structured name values here.
2486
2487 /**
2488 * The extra field for the contact phonetic name.
2489 * <P>Type: String</P>
2490 */
2491 public static final String PHONETIC_NAME = "phonetic_name";
2492
2493 /**
2494 * The extra field for the contact company.
2495 * <P>Type: String</P>
2496 */
2497 public static final String COMPANY = "company";
2498
2499 /**
2500 * The extra field for the contact job title.
2501 * <P>Type: String</P>
2502 */
2503 public static final String JOB_TITLE = "job_title";
2504
2505 /**
2506 * The extra field for the contact notes.
2507 * <P>Type: String</P>
2508 */
2509 public static final String NOTES = "notes";
2510
2511 /**
2512 * The extra field for the contact phone number.
2513 * <P>Type: String</P>
2514 */
2515 public static final String PHONE = "phone";
2516
2517 /**
2518 * The extra field for the contact phone number type.
2519 * <P>Type: Either an integer value from
2520 * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
2521 * or a string specifying a custom label.</P>
2522 */
2523 public static final String PHONE_TYPE = "phone_type";
2524
2525 /**
2526 * The extra field for the phone isprimary flag.
2527 * <P>Type: boolean</P>
2528 */
2529 public static final String PHONE_ISPRIMARY = "phone_isprimary";
2530
2531 /**
2532 * The extra field for an optional second contact phone number.
2533 * <P>Type: String</P>
2534 */
2535 public static final String SECONDARY_PHONE = "secondary_phone";
2536
2537 /**
2538 * The extra field for an optional second contact phone number type.
2539 * <P>Type: Either an integer value from
2540 * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
2541 * or a string specifying a custom label.</P>
2542 */
2543 public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
2544
2545 /**
2546 * The extra field for an optional third contact phone number.
2547 * <P>Type: String</P>
2548 */
2549 public static final String TERTIARY_PHONE = "tertiary_phone";
2550
2551 /**
2552 * The extra field for an optional third contact phone number type.
2553 * <P>Type: Either an integer value from
2554 * {@link android.provider.Contacts.PhonesColumns PhonesColumns},
2555 * or a string specifying a custom label.</P>
2556 */
2557 public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
2558
2559 /**
2560 * The extra field for the contact email address.
2561 * <P>Type: String</P>
2562 */
2563 public static final String EMAIL = "email";
2564
2565 /**
2566 * The extra field for the contact email type.
2567 * <P>Type: Either an integer value from
2568 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2569 * or a string specifying a custom label.</P>
2570 */
2571 public static final String EMAIL_TYPE = "email_type";
2572
2573 /**
2574 * The extra field for the email isprimary flag.
2575 * <P>Type: boolean</P>
2576 */
2577 public static final String EMAIL_ISPRIMARY = "email_isprimary";
2578
2579 /**
2580 * The extra field for an optional second contact email address.
2581 * <P>Type: String</P>
2582 */
2583 public static final String SECONDARY_EMAIL = "secondary_email";
2584
2585 /**
2586 * The extra field for an optional second contact email type.
2587 * <P>Type: Either an integer value from
2588 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2589 * or a string specifying a custom label.</P>
2590 */
2591 public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
2592
2593 /**
2594 * The extra field for an optional third contact email address.
2595 * <P>Type: String</P>
2596 */
2597 public static final String TERTIARY_EMAIL = "tertiary_email";
2598
2599 /**
2600 * The extra field for an optional third contact email type.
2601 * <P>Type: Either an integer value from
2602 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2603 * or a string specifying a custom label.</P>
2604 */
2605 public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
2606
2607 /**
2608 * The extra field for the contact postal address.
2609 * <P>Type: String</P>
2610 */
2611 public static final String POSTAL = "postal";
2612
2613 /**
2614 * The extra field for the contact postal address type.
2615 * <P>Type: Either an integer value from
2616 * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns}
2617 * or a string specifying a custom label.</P>
2618 */
2619 public static final String POSTAL_TYPE = "postal_type";
2620
2621 /**
2622 * The extra field for the postal isprimary flag.
2623 * <P>Type: boolean</P>
2624 */
2625 public static final String POSTAL_ISPRIMARY = "postal_isprimary";
2626
2627 /**
2628 * The extra field for an IM handle.
2629 * <P>Type: String</P>
2630 */
2631 public static final String IM_HANDLE = "im_handle";
2632
2633 /**
2634 * The extra field for the IM protocol
Evan Millardc2da5f2009-06-18 16:07:13 -07002635 */
2636 public static final String IM_PROTOCOL = "im_protocol";
2637
2638 /**
2639 * The extra field for the IM isprimary flag.
2640 * <P>Type: boolean</P>
2641 */
2642 public static final String IM_ISPRIMARY = "im_isprimary";
2643 }
2644 }
2645
Evan Millar088b2912009-05-28 15:24:37 -07002646}