blob: 513e47efb925cfbf821a3546f66d04c1d3c401d3 [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;
Daniel Lehmanne6d3d282011-07-13 15:35:05 -070020import android.app.Activity;
Yorke Lee4fc601a2013-12-06 16:35:29 -080021import android.content.ActivityNotFoundException;
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070022import android.content.ContentProviderClient;
23import android.content.ContentProviderOperation;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070024import android.content.ContentResolver;
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -070025import android.content.ContentUris;
Jeff Hamilton85abdc52009-09-22 12:41:45 -050026import android.content.ContentValues;
Dmitri Plotnikov93032952009-08-19 11:26:57 -070027import android.content.Context;
Makoto Onukibba33cd2012-05-25 17:09:05 -070028import android.content.ContextWrapper;
Fred Quintana328c0e72009-12-07 14:52:28 -080029import android.content.CursorEntityIterator;
Fred Quintana328c0e72009-12-07 14:52:28 -080030import android.content.Entity;
Tom O'Neill244327e22010-01-08 11:11:15 -080031import android.content.EntityIterator;
32import android.content.Intent;
Daniel Lehmannf5d46522011-07-14 22:16:21 -070033import android.content.res.AssetFileDescriptor;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -070034import android.content.res.Resources;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070035import android.database.Cursor;
Fred Quintana328c0e72009-12-07 14:52:28 -080036import android.database.DatabaseUtils;
Jeff Sharkey6449eb02009-09-16 21:41:51 -070037import android.graphics.Rect;
Evan Millar088b2912009-05-28 15:24:37 -070038import android.net.Uri;
Yorke Leeeaf094932014-07-01 10:28:56 -070039import android.net.Uri.Builder;
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070040import android.os.RemoteException;
Dmitri Plotnikov93032952009-08-19 11:26:57 -070041import android.text.TextUtils;
Jeff Sharkeya503f6f2009-12-08 21:50:14 -080042import android.util.DisplayMetrics;
Fred Quintanac4516a72009-09-03 12:14:06 -070043import android.util.Pair;
Jeff Sharkey6449eb02009-09-16 21:41:51 -070044import android.view.View;
Yorke Lee4fc601a2013-12-06 16:35:29 -080045import android.widget.Toast;
Evan Millar088b2912009-05-28 15:24:37 -070046
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070047import java.io.ByteArrayInputStream;
Daniel Lehmannf5d46522011-07-14 22:16:21 -070048import java.io.IOException;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070049import java.io.InputStream;
Dmitri Plotnikov44730c22010-08-12 10:09:58 -070050import java.util.ArrayList;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070051
Evan Millar088b2912009-05-28 15:24:37 -070052/**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080053 * <p>
54 * The contract between the contacts provider and applications. Contains
55 * definitions for the supported URIs and columns. These APIs supersede
56 * {@link Contacts}.
57 * </p>
58 * <h3>Overview</h3>
59 * <p>
60 * ContactsContract defines an extensible database of contact-related
61 * information. Contact information is stored in a three-tier data model:
62 * </p>
Dirk Dougherty4e7db252010-01-05 17:03:39 -080063 * <ul>
64 * <li>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080065 * A row in the {@link Data} table can store any kind of personal data, such
66 * as a phone number or email addresses. The set of data kinds that can be
67 * stored in this table is open-ended. There is a predefined set of common
68 * kinds, but any application can add its own data kinds.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080069 * </li>
70 * <li>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080071 * A row in the {@link RawContacts} table represents a set of data describing a
72 * person and associated with a single account (for example, one of the user's
73 * Gmail accounts).
Dirk Dougherty4e7db252010-01-05 17:03:39 -080074 * </li>
75 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080076 * A row in the {@link Contacts} table represents an aggregate of one or more
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080077 * RawContacts presumably describing the same person. When data in or associated with
78 * the RawContacts table is changed, the affected aggregate contacts are updated as
79 * necessary.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080080 * </li>
81 * </ul>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080082 * <p>
83 * Other tables include:
84 * </p>
Dirk Dougherty4e7db252010-01-05 17:03:39 -080085 * <ul>
86 * <li>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080087 * {@link Groups}, which contains information about raw contact groups
88 * such as Gmail contact groups. The
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080089 * current API does not support the notion of groups spanning multiple accounts.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080090 * </li>
91 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080092 * {@link StatusUpdates}, which contains social status updates including IM
93 * availability.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080094 * </li>
95 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080096 * {@link AggregationExceptions}, which is used for manual aggregation and
97 * disaggregation of raw contacts
Dirk Dougherty4e7db252010-01-05 17:03:39 -080098 * </li>
99 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800100 * {@link Settings}, which contains visibility and sync settings for accounts
101 * and groups.
Dirk Dougherty4e7db252010-01-05 17:03:39 -0800102 * </li>
103 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800104 * {@link SyncState}, which contains free-form data maintained on behalf of sync
105 * adapters
Dirk Dougherty4e7db252010-01-05 17:03:39 -0800106 * </li>
107 * <li>
108 * {@link PhoneLookup}, which is used for quick caller-ID lookup</li>
109 * </ul>
Evan Millar088b2912009-05-28 15:24:37 -0700110 */
Jeff Hamilton0c232122009-09-24 00:26:50 -0500111@SuppressWarnings("unused")
Evan Millar088b2912009-05-28 15:24:37 -0700112public final class ContactsContract {
113 /** The authority for the contacts provider */
114 public static final String AUTHORITY = "com.android.contacts";
115 /** A content:// style uri to the authority for the contacts provider */
116 public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
117
Fred Quintana33f889a2009-09-14 17:31:26 -0700118 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -0800119 * An optional URI parameter for insert, update, or delete queries
120 * that allows the caller
Fred Quintana33f889a2009-09-14 17:31:26 -0700121 * to specify that it is a sync adapter. The default value is false. If true
Tom O'Neilld6f9cd22010-01-14 18:17:01 -0800122 * {@link RawContacts#DIRTY} is not automatically set and the
123 * "syncToNetwork" parameter is set to false when calling
124 * {@link
125 * ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}.
126 * This prevents an unnecessary extra synchronization, see the discussion of
127 * the delete operation in {@link RawContacts}.
Fred Quintana33f889a2009-09-14 17:31:26 -0700128 */
129 public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
130
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500131 /**
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700132 * Query parameter that should be used by the client to access a specific
133 * {@link Directory}. The parameter value should be the _ID of the corresponding
134 * directory, e.g.
135 * {@code content://com.android.contacts/data/emails/filter/acme?directory=3}
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700136 */
137 public static final String DIRECTORY_PARAM_KEY = "directory";
138
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700139 /**
Dmitri Plotnikov5a998dd2010-08-31 17:32:16 -0700140 * A query parameter that limits the number of results returned. The
141 * parameter value should be an integer.
142 */
143 public static final String LIMIT_PARAM_KEY = "limit";
144
145 /**
Daisuke Miyakawa54fcd4c2011-04-06 17:35:38 -0700146 * A query parameter specifing a primary account. This parameter should be used with
147 * {@link #PRIMARY_ACCOUNT_TYPE}. The contacts provider handling a query may rely on
148 * this information to optimize its query results.
149 *
150 * For example, in an email composition screen, its implementation can specify an account when
151 * obtaining possible recipients, letting the provider know which account is selected during
152 * the composition. The provider may use the "primary account" information to optimize
153 * the search result.
Daisuke Miyakawa54fcd4c2011-04-06 17:35:38 -0700154 */
155 public static final String PRIMARY_ACCOUNT_NAME = "name_for_primary_account";
156
157 /**
158 * A query parameter specifing a primary account. This parameter should be used with
159 * {@link #PRIMARY_ACCOUNT_NAME}. See the doc in {@link #PRIMARY_ACCOUNT_NAME}.
Daisuke Miyakawa54fcd4c2011-04-06 17:35:38 -0700160 */
161 public static final String PRIMARY_ACCOUNT_TYPE = "type_for_primary_account";
162
Daisuke Miyakawaf4685912011-06-25 12:31:13 -0700163 /**
164 * A boolean parameter for {@link Contacts#CONTENT_STREQUENT_URI} and
165 * {@link Contacts#CONTENT_STREQUENT_FILTER_URI}, which requires the ContactsProvider to
166 * return only phone-related results. For example, frequently contacted person list should
167 * include persons contacted via phone (not email, sms, etc.)
Daisuke Miyakawaf4685912011-06-25 12:31:13 -0700168 */
169 public static final String STREQUENT_PHONE_ONLY = "strequent_phone_only";
Daisuke Miyakawa54fcd4c2011-04-06 17:35:38 -0700170
171 /**
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -0700172 * A key to a boolean in the "extras" bundle of the cursor.
173 * The boolean indicates that the provider did not create a snippet and that the client asking
174 * for the snippet should do it (true means the snippeting was deferred to the client).
Yorke Leeeaf094932014-07-01 10:28:56 -0700175 *
176 * @see SearchSnippets
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -0700177 */
178 public static final String DEFERRED_SNIPPETING = "deferred_snippeting";
179
180 /**
Yorke Leeeaf094932014-07-01 10:28:56 -0700181 * Key to retrieve the original deferred snippeting from the cursor on the client side.
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -0700182 *
Yorke Leeeaf094932014-07-01 10:28:56 -0700183 * @see SearchSnippets
184 * @see #DEFERRED_SNIPPETING
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -0700185 */
186 public static final String DEFERRED_SNIPPETING_QUERY = "deferred_snippeting_query";
187
188 /**
Yorke Lee1ca440b2014-06-04 18:01:46 -0700189 * A boolean parameter for {@link CommonDataKinds.Phone#CONTENT_URI Phone.CONTENT_URI},
190 * {@link CommonDataKinds.Email#CONTENT_URI Email.CONTENT_URI}, and
191 * {@link CommonDataKinds.StructuredPostal#CONTENT_URI StructuredPostal.CONTENT_URI}.
Daisuke Miyakawa19352e02011-11-14 13:16:07 -0800192 * This enables a content provider to remove duplicate entries in results.
Daisuke Miyakawa19352e02011-11-14 13:16:07 -0800193 */
194 public static final String REMOVE_DUPLICATE_ENTRIES = "remove_duplicate_entries";
195
196 /**
Dave Santoroe43185e2011-10-10 18:11:00 -0700197 * <p>
198 * API for obtaining a pre-authorized version of a URI that normally requires special
199 * permission (beyond READ_CONTACTS) to read. The caller obtaining the pre-authorized URI
200 * must already have the necessary permissions to access the URI; otherwise a
201 * {@link SecurityException} will be thrown.
202 * </p>
203 * <p>
204 * The authorized URI returned in the bundle contains an expiring token that allows the
205 * caller to execute the query without having the special permissions that would normally
206 * be required.
207 * </p>
208 * <p>
209 * This API does not access disk, and should be safe to invoke from the UI thread.
210 * </p>
211 * <p>
212 * Example usage:
213 * <pre>
214 * Uri profileUri = ContactsContract.Profile.CONTENT_VCARD_URI;
215 * Bundle uriBundle = new Bundle();
216 * uriBundle.putParcelable(ContactsContract.Authorization.KEY_URI_TO_AUTHORIZE, uri);
217 * Bundle authResponse = getContext().getContentResolver().call(
218 * ContactsContract.AUTHORITY_URI,
219 * ContactsContract.Authorization.AUTHORIZATION_METHOD,
220 * null, // String arg, not used.
221 * uriBundle);
222 * if (authResponse != null) {
223 * Uri preauthorizedProfileUri = (Uri) authResponse.getParcelable(
224 * ContactsContract.Authorization.KEY_AUTHORIZED_URI);
225 * // This pre-authorized URI can be queried by a caller without READ_PROFILE
226 * // permission.
227 * }
228 * </pre>
229 * </p>
230 * @hide
231 */
232 public static final class Authorization {
233 /**
234 * The method to invoke to create a pre-authorized URI out of the input argument.
235 */
236 public static final String AUTHORIZATION_METHOD = "authorize";
237
238 /**
239 * The key to set in the outbound Bundle with the URI that should be authorized.
240 */
241 public static final String KEY_URI_TO_AUTHORIZE = "uri_to_authorize";
242
243 /**
244 * The key to retrieve from the returned Bundle to obtain the pre-authorized URI.
245 */
246 public static final String KEY_AUTHORIZED_URI = "authorized_uri";
247 }
248
Yorke Lee6355c8f2014-07-08 11:48:42 -0700249 /**
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700250 * A Directory represents a contacts corpus, e.g. Local contacts,
251 * Google Apps Global Address List or Corporate Global Address List.
252 * <p>
253 * A Directory is implemented as a content provider with its unique authority and
254 * the same API as the main Contacts Provider. However, there is no expectation that
255 * every directory provider will implement this Contract in its entirety. If a
256 * directory provider does not have an implementation for a specific request, it
257 * should throw an UnsupportedOperationException.
258 * </p>
259 * <p>
260 * The most important use case for Directories is search. A Directory provider is
Dmitri Plotnikov13e03572010-08-19 16:31:29 -0700261 * expected to support at least {@link ContactsContract.Contacts#CONTENT_FILTER_URI
262 * Contacts.CONTENT_FILTER_URI}. If a Directory provider wants to participate
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700263 * in email and phone lookup functionalities, it should also implement
264 * {@link CommonDataKinds.Email#CONTENT_FILTER_URI CommonDataKinds.Email.CONTENT_FILTER_URI}
265 * and
266 * {@link CommonDataKinds.Phone#CONTENT_FILTER_URI CommonDataKinds.Phone.CONTENT_FILTER_URI}.
267 * </p>
268 * <p>
269 * A directory provider should return NULL for every projection field it does not
270 * recognize, rather than throwing an exception. This way it will not be broken
271 * if ContactsContract is extended with new fields in the future.
272 * </p>
273 * <p>
274 * The client interacts with a directory via Contacts Provider by supplying an
275 * optional {@code directory=} query parameter.
276 * <p>
277 * <p>
278 * When the Contacts Provider receives the request, it transforms the URI and forwards
279 * the request to the corresponding directory content provider.
280 * The URI is transformed in the following fashion:
281 * <ul>
282 * <li>The URI authority is replaced with the corresponding {@link #DIRECTORY_AUTHORITY}.</li>
283 * <li>The {@code accountName=} and {@code accountType=} parameters are added or
284 * replaced using the corresponding {@link #ACCOUNT_TYPE} and {@link #ACCOUNT_NAME} values.</li>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700285 * </ul>
286 * </p>
287 * <p>
288 * Clients should send directory requests to Contacts Provider and let it
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700289 * forward them to the respective providers rather than constructing
290 * directory provider URIs by themselves. This level of indirection allows
291 * Contacts Provider to implement additional system-level features and
292 * optimizations. Access to Contacts Provider is protected by the
Subir Jhanb603af612012-08-06 17:19:22 -0700293 * READ_CONTACTS permission, but access to the directory provider is protected by
294 * BIND_DIRECTORY_SEARCH. This permission was introduced at the API level 17, for previous
295 * platform versions the provider should perform the following check to make sure the call
296 * is coming from the ContactsProvider:
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700297 * <pre>
298 * private boolean isCallerAllowed() {
299 * PackageManager pm = getContext().getPackageManager();
300 * for (String packageName: pm.getPackagesForUid(Binder.getCallingUid())) {
301 * if (packageName.equals("com.android.providers.contacts")) {
302 * return true;
303 * }
304 * }
305 * return false;
306 * }
307 * </pre>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700308 * </p>
309 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700310 * The Directory table is read-only and is maintained by the Contacts Provider
311 * automatically.
312 * </p>
313 * <p>It always has at least these two rows:
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700314 * <ul>
315 * <li>
316 * The local directory. It has {@link Directory#_ID Directory._ID} =
317 * {@link Directory#DEFAULT Directory.DEFAULT}. This directory can be used to access locally
318 * stored contacts. The same can be achieved by omitting the {@code directory=}
319 * parameter altogether.
320 * </li>
321 * <li>
322 * The local invisible contacts. The corresponding directory ID is
323 * {@link Directory#LOCAL_INVISIBLE Directory.LOCAL_INVISIBLE}.
324 * </li>
325 * </ul>
326 * </p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700327 * <p>Custom Directories are discovered by the Contacts Provider following this procedure:
328 * <ul>
329 * <li>It finds all installed content providers with meta data identifying them
330 * as directory providers in AndroidManifest.xml:
331 * <code>
332 * &lt;meta-data android:name="android.content.ContactDirectory"
333 * android:value="true" /&gt;
334 * </code>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700335 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700336 * This tag should be placed inside the corresponding content provider declaration.
337 * </p>
338 * </li>
339 * <li>
340 * Then Contacts Provider sends a {@link Directory#CONTENT_URI Directory.CONTENT_URI}
341 * query to each of the directory authorities. A directory provider must implement
342 * this query and return a list of directories. Each directory returned by
343 * the provider must have a unique combination for the {@link #ACCOUNT_NAME} and
344 * {@link #ACCOUNT_TYPE} columns (nulls are allowed). Since directory IDs are assigned
345 * automatically, the _ID field will not be part of the query projection.
346 * </li>
347 * <li>Contacts Provider compiles directory lists received from all directory
348 * providers into one, assigns each individual directory a globally unique ID and
349 * stores all directory records in the Directory table.
350 * </li>
351 * </ul>
352 * </p>
353 * <p>Contacts Provider automatically interrogates newly installed or replaced packages.
354 * Thus simply installing a package containing a directory provider is sufficient
355 * to have that provider registered. A package supplying a directory provider does
356 * not have to contain launchable activities.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700357 * </p>
358 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700359 * Every row in the Directory table is automatically associated with the corresponding package
360 * (apk). If the package is later uninstalled, all corresponding directory rows
361 * are automatically removed from the Contacts Provider.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700362 * </p>
363 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700364 * When the list of directories handled by a directory provider changes
365 * (for instance when the user adds a new Directory account), the directory provider
366 * should call {@link #notifyDirectoryChange} to notify the Contacts Provider of the change.
367 * In response, the Contacts Provider will requery the directory provider to obtain the
368 * new list of directories.
369 * </p>
370 * <p>
371 * A directory row can be optionally associated with an existing account
372 * (see {@link android.accounts.AccountManager}). If the account is later removed,
Dmitri Plotnikove50ed082010-08-18 10:56:09 -0700373 * the corresponding directory rows are automatically removed from the Contacts Provider.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700374 * </p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700375 */
376 public static final class Directory implements BaseColumns {
377
378 /**
379 * Not instantiable.
380 */
381 private Directory() {
382 }
383
384 /**
385 * The content:// style URI for this table. Requests to this URI can be
386 * performed on the UI thread because they are always unblocking.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700387 */
388 public static final Uri CONTENT_URI =
389 Uri.withAppendedPath(AUTHORITY_URI, "directories");
390
391 /**
392 * The MIME-type of {@link #CONTENT_URI} providing a directory of
393 * contact directories.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700394 */
395 public static final String CONTENT_TYPE =
396 "vnd.android.cursor.dir/contact_directories";
397
398 /**
399 * The MIME type of a {@link #CONTENT_URI} item.
400 */
401 public static final String CONTENT_ITEM_TYPE =
402 "vnd.android.cursor.item/contact_directory";
403
404 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700405 * _ID of the default directory, which represents locally stored contacts.
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700406 */
407 public static final long DEFAULT = 0;
408
409 /**
410 * _ID of the directory that represents locally stored invisible contacts.
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700411 */
412 public static final long LOCAL_INVISIBLE = 1;
413
414 /**
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700415 * The name of the package that owns this directory. Contacts Provider
416 * fill it in with the name of the package containing the directory provider.
417 * If the package is later uninstalled, the directories it owns are
418 * automatically removed from this table.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700419 *
420 * <p>TYPE: TEXT</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700421 */
422 public static final String PACKAGE_NAME = "packageName";
423
424 /**
425 * The type of directory captured as a resource ID in the context of the
426 * package {@link #PACKAGE_NAME}, e.g. "Corporate Directory"
427 *
428 * <p>TYPE: INTEGER</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700429 */
430 public static final String TYPE_RESOURCE_ID = "typeResourceId";
431
432 /**
433 * An optional name that can be used in the UI to represent this directory,
434 * e.g. "Acme Corp"
435 * <p>TYPE: text</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700436 */
437 public static final String DISPLAY_NAME = "displayName";
438
439 /**
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700440 * <p>
441 * The authority of the Directory Provider. Contacts Provider will
442 * use this authority to forward requests to the directory provider.
443 * A directory provider can leave this column empty - Contacts Provider will fill it in.
444 * </p>
445 * <p>
446 * Clients of this API should not send requests directly to this authority.
447 * All directory requests must be routed through Contacts Provider.
448 * </p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700449 *
450 * <p>TYPE: text</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700451 */
452 public static final String DIRECTORY_AUTHORITY = "authority";
453
454 /**
455 * The account type which this directory is associated.
456 *
457 * <p>TYPE: text</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700458 */
459 public static final String ACCOUNT_TYPE = "accountType";
460
461 /**
462 * The account with which this directory is associated. If the account is later
463 * removed, the directories it owns are automatically removed from this table.
464 *
465 * <p>TYPE: text</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700466 */
467 public static final String ACCOUNT_NAME = "accountName";
468
469 /**
470 * One of {@link #EXPORT_SUPPORT_NONE}, {@link #EXPORT_SUPPORT_ANY_ACCOUNT},
471 * {@link #EXPORT_SUPPORT_SAME_ACCOUNT_ONLY}. This is the expectation the
472 * directory has for data exported from it. Clients must obey this setting.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700473 */
474 public static final String EXPORT_SUPPORT = "exportSupport";
475
476 /**
477 * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
478 * does not allow any data to be copied out of it.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700479 */
480 public static final int EXPORT_SUPPORT_NONE = 0;
481
482 /**
483 * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
484 * allow its data copied only to the account specified by
485 * {@link #ACCOUNT_TYPE}/{@link #ACCOUNT_NAME}.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700486 */
487 public static final int EXPORT_SUPPORT_SAME_ACCOUNT_ONLY = 1;
488
489 /**
490 * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
491 * allow its data copied to any contacts account.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700492 */
493 public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2;
494
495 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700496 * One of {@link #SHORTCUT_SUPPORT_NONE}, {@link #SHORTCUT_SUPPORT_DATA_ITEMS_ONLY},
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700497 * {@link #SHORTCUT_SUPPORT_FULL}. This is the expectation the directory
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700498 * has for shortcuts created for its elements. Clients must obey this setting.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700499 */
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700500 public static final String SHORTCUT_SUPPORT = "shortcutSupport";
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700501
502 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700503 * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
504 * does not allow any shortcuts created for its contacts.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700505 */
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700506 public static final int SHORTCUT_SUPPORT_NONE = 0;
507
508 /**
509 * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
510 * allow creation of shortcuts for data items like email, phone or postal address,
511 * but not the entire contact.
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700512 */
513 public static final int SHORTCUT_SUPPORT_DATA_ITEMS_ONLY = 1;
514
515 /**
516 * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
517 * allow creation of shortcuts for contact as well as their constituent elements.
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700518 */
519 public static final int SHORTCUT_SUPPORT_FULL = 2;
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700520
521 /**
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700522 * One of {@link #PHOTO_SUPPORT_NONE}, {@link #PHOTO_SUPPORT_THUMBNAIL_ONLY},
523 * {@link #PHOTO_SUPPORT_FULL}. This is a feature flag indicating the extent
524 * to which the directory supports contact photos.
525 */
526 public static final String PHOTO_SUPPORT = "photoSupport";
527
528 /**
529 * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
530 * does not provide any photos.
531 */
532 public static final int PHOTO_SUPPORT_NONE = 0;
533
534 /**
535 * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
536 * can only produce small size thumbnails of contact photos.
537 */
538 public static final int PHOTO_SUPPORT_THUMBNAIL_ONLY = 1;
539
540 /**
541 * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
542 * has full-size contact photos, but cannot provide scaled thumbnails.
543 */
544 public static final int PHOTO_SUPPORT_FULL_SIZE_ONLY = 2;
545
546 /**
547 * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
548 * can produce thumbnails as well as full-size contact photos.
549 */
550 public static final int PHOTO_SUPPORT_FULL = 3;
551
552 /**
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700553 * Notifies the system of a change in the list of directories handled by
554 * a particular directory provider. The Contacts provider will turn around
555 * and send a query to the directory provider for the full list of directories,
556 * which will replace the previous list.
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700557 */
558 public static void notifyDirectoryChange(ContentResolver resolver) {
559 // This is done to trigger a query by Contacts Provider back to the directory provider.
560 // No data needs to be sent back, because the provider can infer the calling
561 // package from binder.
562 ContentValues contentValues = new ContentValues();
563 resolver.update(Directory.CONTENT_URI, contentValues, null, null);
564 }
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700565 }
566
567 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500568 * @hide should be removed when users are updated to refer to SyncState
569 * @deprecated use SyncState instead
570 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700571 @Deprecated
Fred Quintana0f4e1ab2009-07-09 17:20:59 -0700572 public interface SyncStateColumns extends SyncStateContract.Columns {
573 }
574
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500575 /**
Dave Santoro063084e2011-08-23 15:42:49 -0700576 * A table provided for sync adapters to use for storing private sync state data for contacts.
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500577 *
578 * @see SyncStateContract
579 */
580 public static final class SyncState implements SyncStateContract.Columns {
Fred Quintana0f4e1ab2009-07-09 17:20:59 -0700581 /**
582 * This utility class cannot be instantiated
583 */
584 private SyncState() {}
585
586 public static final String CONTENT_DIRECTORY =
587 SyncStateContract.Constants.CONTENT_DIRECTORY;
588
589 /**
590 * The content:// style URI for this table
591 */
592 public static final Uri CONTENT_URI =
593 Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY);
594
595 /**
596 * @see android.provider.SyncStateContract.Helpers#get
597 */
598 public static byte[] get(ContentProviderClient provider, Account account)
599 throws RemoteException {
600 return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
601 }
602
603 /**
Fred Quintanac4516a72009-09-03 12:14:06 -0700604 * @see android.provider.SyncStateContract.Helpers#get
605 */
606 public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
607 throws RemoteException {
608 return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
609 }
610
611 /**
Fred Quintana0f4e1ab2009-07-09 17:20:59 -0700612 * @see android.provider.SyncStateContract.Helpers#set
613 */
614 public static void set(ContentProviderClient provider, Account account, byte[] data)
615 throws RemoteException {
616 SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
617 }
618
619 /**
620 * @see android.provider.SyncStateContract.Helpers#newSetOperation
621 */
622 public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
623 return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
624 }
625 }
626
Dave Santoro063084e2011-08-23 15:42:49 -0700627
628 /**
629 * A table provided for sync adapters to use for storing private sync state data for the
630 * user's personal profile.
631 *
632 * @see SyncStateContract
633 */
634 public static final class ProfileSyncState implements SyncStateContract.Columns {
635 /**
636 * This utility class cannot be instantiated
637 */
638 private ProfileSyncState() {}
639
640 public static final String CONTENT_DIRECTORY =
641 SyncStateContract.Constants.CONTENT_DIRECTORY;
642
643 /**
644 * The content:// style URI for this table
645 */
646 public static final Uri CONTENT_URI =
647 Uri.withAppendedPath(Profile.CONTENT_URI, CONTENT_DIRECTORY);
648
649 /**
650 * @see android.provider.SyncStateContract.Helpers#get
651 */
652 public static byte[] get(ContentProviderClient provider, Account account)
653 throws RemoteException {
654 return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
655 }
656
657 /**
658 * @see android.provider.SyncStateContract.Helpers#get
659 */
660 public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
661 throws RemoteException {
662 return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
663 }
664
665 /**
666 * @see android.provider.SyncStateContract.Helpers#set
667 */
668 public static void set(ContentProviderClient provider, Account account, byte[] data)
669 throws RemoteException {
670 SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
671 }
672
673 /**
674 * @see android.provider.SyncStateContract.Helpers#newSetOperation
675 */
676 public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
677 return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
678 }
679 }
680
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700681 /**
682 * Generic columns for use by sync adapters. The specific functions of
683 * these columns are private to the sync adapter. Other clients of the API
684 * should not attempt to either read or write this column.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800685 *
686 * @see RawContacts
687 * @see Groups
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700688 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700689 protected interface BaseSyncColumns {
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700690
691 /** Generic column for use by sync adapters. */
692 public static final String SYNC1 = "sync1";
693 /** Generic column for use by sync adapters. */
694 public static final String SYNC2 = "sync2";
695 /** Generic column for use by sync adapters. */
696 public static final String SYNC3 = "sync3";
697 /** Generic column for use by sync adapters. */
698 public static final String SYNC4 = "sync4";
699 }
700
701 /**
702 * Columns that appear when each row of a table belongs to a specific
703 * account, including sync information that an account may need.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800704 *
705 * @see RawContacts
706 * @see Groups
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700707 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700708 protected interface SyncColumns extends BaseSyncColumns {
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700709 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500710 * The name of the account instance to which this row belongs, which when paired with
711 * {@link #ACCOUNT_TYPE} identifies a specific account.
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700712 * <P>Type: TEXT</P>
713 */
714 public static final String ACCOUNT_NAME = "account_name";
715
716 /**
717 * The type of account to which this row belongs, which when paired with
718 * {@link #ACCOUNT_NAME} identifies a specific account.
719 * <P>Type: TEXT</P>
720 */
721 public static final String ACCOUNT_TYPE = "account_type";
722
723 /**
724 * String that uniquely identifies this row to its source account.
725 * <P>Type: TEXT</P>
726 */
727 public static final String SOURCE_ID = "sourceid";
728
729 /**
730 * Version number that is updated whenever this row or its related data
731 * changes.
732 * <P>Type: INTEGER</P>
733 */
734 public static final String VERSION = "version";
735
736 /**
737 * Flag indicating that {@link #VERSION} has changed, and this row needs
738 * to be synchronized by its owning account.
739 * <P>Type: INTEGER (boolean)</P>
740 */
741 public static final String DIRTY = "dirty";
742 }
743
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800744 /**
Tom O'Neill244327e22010-01-08 11:11:15 -0800745 * Columns of {@link ContactsContract.Contacts} that track the user's
746 * preferences for, or interactions with, the contact.
747 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800748 * @see Contacts
749 * @see RawContacts
750 * @see ContactsContract.Data
751 * @see PhoneLookup
752 * @see ContactsContract.Contacts.AggregationSuggestions
753 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700754 protected interface ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700755 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500756 * The number of times a contact has been contacted
Evan Millar088b2912009-05-28 15:24:37 -0700757 * <P>Type: INTEGER</P>
758 */
759 public static final String TIMES_CONTACTED = "times_contacted";
760
761 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500762 * The last time a contact was contacted.
Evan Millar088b2912009-05-28 15:24:37 -0700763 * <P>Type: INTEGER</P>
764 */
765 public static final String LAST_TIME_CONTACTED = "last_time_contacted";
766
767 /**
768 * Is the contact starred?
769 * <P>Type: INTEGER (boolean)</P>
770 */
771 public static final String STARRED = "starred";
772
773 /**
Yorke Lee217d8a72013-11-27 10:14:04 -0800774 * The position at which the contact is pinned. If {@link PinnedPositions#UNPINNED},
Yorke Lee6acfa5d2013-07-17 09:55:26 -0700775 * the contact is not pinned. Also see {@link PinnedPositions}.
776 * <P>Type: INTEGER </P>
Yorke Lee6acfa5d2013-07-17 09:55:26 -0700777 */
778 public static final String PINNED = "pinned";
779
780 /**
Tom O'Neill244327e22010-01-08 11:11:15 -0800781 * URI for a custom ringtone associated with the contact. If null or missing,
782 * the default ringtone is used.
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700783 * <P>Type: TEXT (URI to the ringtone)</P>
784 */
785 public static final String CUSTOM_RINGTONE = "custom_ringtone";
786
787 /**
Tom O'Neill244327e22010-01-08 11:11:15 -0800788 * Whether the contact should always be sent to voicemail. If missing,
789 * defaults to false.
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700790 * <P>Type: INTEGER (0 for false, 1 for true)</P>
791 */
792 public static final String SEND_TO_VOICEMAIL = "send_to_voicemail";
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700793 }
794
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800795 /**
Tom O'Neill244327e22010-01-08 11:11:15 -0800796 * Columns of {@link ContactsContract.Contacts} that refer to intrinsic
797 * properties of the contact, as opposed to the user-specified options
798 * found in {@link ContactOptionsColumns}.
799 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800800 * @see Contacts
801 * @see ContactsContract.Data
802 * @see PhoneLookup
803 * @see ContactsContract.Contacts.AggregationSuggestions
804 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700805 protected interface ContactsColumns {
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700806 /**
807 * The display name for the contact.
808 * <P>Type: TEXT</P>
809 */
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -0800810 public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY;
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700811
812 /**
Dmitri Plotnikov96186082009-12-01 14:35:04 -0800813 * Reference to the row in the RawContacts table holding the contact name.
814 * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P>
Dmitri Plotnikov96186082009-12-01 14:35:04 -0800815 */
816 public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id";
817
818 /**
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700819 * Reference to the row in the data table holding the photo. A photo can
820 * be referred to either by ID (this field) or by URI (see {@link #PHOTO_THUMBNAIL_URI}
821 * and {@link #PHOTO_URI}).
822 * If PHOTO_ID is null, consult {@link #PHOTO_URI} or {@link #PHOTO_THUMBNAIL_URI},
823 * which is a more generic mechanism for referencing the contact photo, especially for
824 * contacts returned by non-local directories (see {@link Directory}).
825 *
Evan Millar088b2912009-05-28 15:24:37 -0700826 * <P>Type: INTEGER REFERENCES data(_id)</P>
827 */
828 public static final String PHOTO_ID = "photo_id";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -0700829
830 /**
Dave Santoroa5282372011-06-29 00:25:16 -0700831 * Photo file ID of the full-size photo. If present, this will be used to populate
832 * {@link #PHOTO_URI}. The ID can also be used with
833 * {@link ContactsContract.DisplayPhoto#CONTENT_URI} to create a URI to the photo.
834 * If this is present, {@link #PHOTO_ID} is also guaranteed to be populated.
835 *
836 * <P>Type: INTEGER</P>
837 */
838 public static final String PHOTO_FILE_ID = "photo_file_id";
839
840 /**
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700841 * A URI that can be used to retrieve the contact's full-size photo.
Dave Santoroa5282372011-06-29 00:25:16 -0700842 * If PHOTO_FILE_ID is not null, this will be populated with a URI based off
843 * {@link ContactsContract.DisplayPhoto#CONTENT_URI}. Otherwise, this will
844 * be populated with the same value as {@link #PHOTO_THUMBNAIL_URI}.
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700845 * A photo can be referred to either by a URI (this field) or by ID
Dave Santoroa5282372011-06-29 00:25:16 -0700846 * (see {@link #PHOTO_ID}). If either PHOTO_FILE_ID or PHOTO_ID is not null,
847 * PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily
848 * vice versa). Thus using PHOTO_URI is a more robust method of retrieving
849 * contact photos.
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700850 *
851 * <P>Type: TEXT</P>
852 */
853 public static final String PHOTO_URI = "photo_uri";
854
855 /**
856 * A URI that can be used to retrieve a thumbnail of the contact's photo.
857 * A photo can be referred to either by a URI (this field or {@link #PHOTO_URI})
858 * or by ID (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and
859 * PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa).
860 * If the content provider does not differentiate between full-size photos
861 * and thumbnail photos, PHOTO_THUMBNAIL_URI and {@link #PHOTO_URI} can contain
Dave Santoroa5282372011-06-29 00:25:16 -0700862 * the same value, but either both shall be null or both not null.
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700863 *
864 * <P>Type: TEXT</P>
865 */
866 public static final String PHOTO_THUMBNAIL_URI = "photo_thumb_uri";
867
868 /**
Brian Attwell2fa85d32014-03-04 17:41:13 -0800869 * Flag that reflects whether the contact exists inside the default directory.
870 * Ie, whether the contact is designed to only be visible outside search.
Brian Attwell2fa85d32014-03-04 17:41:13 -0800871 */
872 public static final String IN_DEFAULT_DIRECTORY = "in_default_directory";
873
874 /**
Dave Santoro43251332011-05-11 11:39:54 -0700875 * Flag that reflects the {@link Groups#GROUP_VISIBLE} state of any
876 * {@link CommonDataKinds.GroupMembership} for this contact.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -0700877 */
878 public static final String IN_VISIBLE_GROUP = "in_visible_group";
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700879
880 /**
Dave Santoro43251332011-05-11 11:39:54 -0700881 * Flag that reflects whether this contact represents the user's
882 * personal profile entry.
883 */
884 public static final String IS_USER_PROFILE = "is_user_profile";
885
886 /**
Dmitri Plotnikov074fbfe2009-08-11 13:50:21 -0700887 * An indicator of whether this contact has at least one phone number. "1" if there is
888 * at least one phone number, "0" otherwise.
Dmitri Plotnikov55048a92009-07-24 10:25:34 -0700889 * <P>Type: INTEGER</P>
890 */
Dmitri Plotnikov074fbfe2009-08-11 13:50:21 -0700891 public static final String HAS_PHONE_NUMBER = "has_phone_number";
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -0700892
893 /**
894 * An opaque value that contains hints on how to find the contact if
895 * its row id changed as a result of a sync or aggregation.
896 */
897 public static final String LOOKUP_KEY = "lookup";
Chiao Cheng2355d132013-03-20 16:54:06 -0700898
899 /**
900 * Timestamp (milliseconds since epoch) of when this contact was last updated. This
901 * includes updates to all data associated with this contact including raw contacts. Any
902 * modification (including deletes and inserts) of underlying contact data are also
903 * reflected in this timestamp.
904 */
905 public static final String CONTACT_LAST_UPDATED_TIMESTAMP =
906 "contact_last_updated_timestamp";
Evan Millar088b2912009-05-28 15:24:37 -0700907 }
908
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800909 /**
910 * @see Contacts
911 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700912 protected interface ContactStatusColumns {
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700913 /**
914 * Contact presence status. See {@link StatusUpdates} for individual status
915 * definitions.
916 * <p>Type: NUMBER</p>
917 */
918 public static final String CONTACT_PRESENCE = "contact_presence";
919
920 /**
Vasu Norifb5bccf2010-07-19 14:11:54 -0700921 * Contact Chat Capabilities. See {@link StatusUpdates} for individual
Vasu Nori5b31498ba12010-07-12 15:13:37 -0700922 * definitions.
923 * <p>Type: NUMBER</p>
924 */
925 public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability";
926
927 /**
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700928 * Contact's latest status update.
929 * <p>Type: TEXT</p>
930 */
931 public static final String CONTACT_STATUS = "contact_status";
932
933 /**
934 * The absolute time in milliseconds when the latest status was
935 * inserted/updated.
936 * <p>Type: NUMBER</p>
937 */
938 public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts";
939
940 /**
941 * The package containing resources for this status: label and icon.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800942 * <p>Type: TEXT</p>
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700943 */
944 public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package";
945
946 /**
947 * The resource ID of the label describing the source of contact
948 * status, e.g. "Google Talk". This resource is scoped by the
949 * {@link #CONTACT_STATUS_RES_PACKAGE}.
950 * <p>Type: NUMBER</p>
951 */
952 public static final String CONTACT_STATUS_LABEL = "contact_status_label";
953
954 /**
955 * The resource ID of the icon for the source of contact status. This
956 * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.
957 * <p>Type: NUMBER</p>
958 */
959 public static final String CONTACT_STATUS_ICON = "contact_status_icon";
960 }
961
Evan Millar088b2912009-05-28 15:24:37 -0700962 /**
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800963 * Constants for various styles of combining given name, family name etc into
964 * a full name. For example, the western tradition follows the pattern
965 * 'given name' 'middle name' 'family name' with the alternative pattern being
966 * 'family name', 'given name' 'middle name'. The CJK tradition is
967 * 'family name' 'middle name' 'given name', with Japanese favoring a space between
968 * the names and Chinese omitting the space.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800969 */
970 public interface FullNameStyle {
971 public static final int UNDEFINED = 0;
972 public static final int WESTERN = 1;
973
974 /**
975 * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine
976 * which specific language it belongs to: Chinese, Japanese or Korean.
977 */
978 public static final int CJK = 2;
979
980 public static final int CHINESE = 3;
981 public static final int JAPANESE = 4;
982 public static final int KOREAN = 5;
983 }
984
985 /**
986 * Constants for various styles of capturing the pronunciation of a person's name.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -0800987 */
988 public interface PhoneticNameStyle {
989 public static final int UNDEFINED = 0;
990
991 /**
992 * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly
993 * shown in UIs, but used for searches and sorting.
994 */
995 public static final int PINYIN = 3;
996
997 /**
998 * Hiragana and Katakana are two common styles of writing out the pronunciation
999 * of a Japanese names.
1000 */
1001 public static final int JAPANESE = 4;
1002
1003 /**
1004 * Hangul is the Korean phonetic alphabet.
1005 */
1006 public static final int KOREAN = 5;
1007 }
1008
1009 /**
Dmitri Plotnikovdbcdbf22011-02-23 15:49:58 -08001010 * Types of data used to produce the display name for a contact. In the order
1011 * of increasing priority: {@link #EMAIL}, {@link #PHONE},
1012 * {@link #ORGANIZATION}, {@link #NICKNAME}, {@link #STRUCTURED_NAME}.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001013 */
1014 public interface DisplayNameSources {
1015 public static final int UNDEFINED = 0;
1016 public static final int EMAIL = 10;
1017 public static final int PHONE = 20;
1018 public static final int ORGANIZATION = 30;
1019 public static final int NICKNAME = 35;
1020 public static final int STRUCTURED_NAME = 40;
1021 }
1022
1023 /**
Tom O'Neill244327e22010-01-08 11:11:15 -08001024 * Contact name and contact name metadata columns in the RawContacts table.
1025 *
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001026 * @see Contacts
1027 * @see RawContacts
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001028 */
1029 protected interface ContactNameColumns {
1030
1031 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001032 * The kind of data that is used as the display name for the contact, such as
Dmitri Plotnikov59024f12010-08-27 10:59:22 -07001033 * structured name or email address. See {@link DisplayNameSources}.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001034 */
1035 public static final String DISPLAY_NAME_SOURCE = "display_name_source";
1036
1037 /**
Tom O'Neill093a8702010-01-15 16:20:34 -08001038 * <p>
1039 * The standard text shown as the contact's display name, based on the best
1040 * available information for the contact (for example, it might be the email address
1041 * if the name is not available).
1042 * The information actually used to compute the name is stored in
1043 * {@link #DISPLAY_NAME_SOURCE}.
1044 * </p>
1045 * <p>
1046 * A contacts provider is free to choose whatever representation makes most
1047 * sense for its target market.
1048 * For example in the default Android Open Source Project implementation,
1049 * if the display name is
1050 * based on the structured name and the structured name follows
1051 * the Western full-name style, then this field contains the "given name first"
1052 * version of the full name.
1053 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001054 *
1055 * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001056 */
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08001057 public static final String DISPLAY_NAME_PRIMARY = "display_name";
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001058
1059 /**
Tom O'Neill093a8702010-01-15 16:20:34 -08001060 * <p>
1061 * An alternative representation of the display name, such as "family name first"
1062 * instead of "given name first" for Western names. If an alternative is not
1063 * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}.
1064 * </p>
1065 * <p>
1066 * A contacts provider is free to provide alternatives as necessary for
1067 * its target market.
1068 * For example the default Android Open Source Project contacts provider
1069 * currently provides an
1070 * alternative in a single case: if the display name is
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001071 * based on the structured name and the structured name follows
Tom O'Neill093a8702010-01-15 16:20:34 -08001072 * the Western full name style, then the field contains the "family name first"
1073 * version of the full name.
1074 * Other cases may be added later.
1075 * </p>
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001076 */
1077 public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt";
1078
1079 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001080 * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}. See
Dmitri Plotnikov59024f12010-08-27 10:59:22 -07001081 * {@link PhoneticNameStyle}.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001082 */
1083 public static final String PHONETIC_NAME_STYLE = "phonetic_name_style";
1084
1085 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001086 * <p>
1087 * Pronunciation of the full name in the phonetic alphabet specified by
1088 * {@link #PHONETIC_NAME_STYLE}.
1089 * </p>
1090 * <p>
Dmitri Plotnikov59024f12010-08-27 10:59:22 -07001091 * The value may be set manually by the user. This capability is of
1092 * interest only in countries with commonly used phonetic alphabets,
1093 * such as Japan and Korea. See {@link PhoneticNameStyle}.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001094 * </p>
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001095 */
1096 public static final String PHONETIC_NAME = "phonetic_name";
1097
1098 /**
1099 * Sort key that takes into account locale-based traditions for sorting
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001100 * names in address books. The default
1101 * sort key is {@link #DISPLAY_NAME_PRIMARY}. For Chinese names
1102 * the sort key is the name's Pinyin spelling, and for Japanese names
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001103 * it is the Hiragana version of the phonetic name.
1104 */
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08001105 public static final String SORT_KEY_PRIMARY = "sort_key";
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001106
1107 /**
1108 * Sort key based on the alternative representation of the full name,
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001109 * {@link #DISPLAY_NAME_ALTERNATIVE}. Thus for Western names,
Dmitri Plotnikov2a650dd2010-01-26 17:28:52 -08001110 * it is the one using the "family name first" format.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001111 */
1112 public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt";
1113 }
1114
Yorke Lee94c87612014-07-18 18:57:17 -07001115 interface ContactCounts {
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001116
1117 /**
Yorke Lee94c87612014-07-18 18:57:17 -07001118 * Add this query parameter to a URI to get back row counts grouped by the address book
1119 * index as cursor extras. For most languages it is the first letter of the sort key. This
1120 * parameter does not affect the main content of the cursor.
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001121 *
Yorke Leef4b28452014-05-27 19:41:35 -07001122 * <p>
1123 * <pre>
1124 * Example:
Yorke Lee94c87612014-07-18 18:57:17 -07001125 *
1126 * import android.provider.ContactsContract.Contacts;
1127 *
Yorke Leef4b28452014-05-27 19:41:35 -07001128 * Uri uri = Contacts.CONTENT_URI.buildUpon()
Yorke Leea4aa9dc2014-08-04 13:47:50 -07001129 * .appendQueryParameter(Contacts.ADDRESS_BOOK_INDEX_EXTRAS, "true")
Yorke Leef4b28452014-05-27 19:41:35 -07001130 * .build();
1131 * Cursor cursor = getContentResolver().query(uri,
1132 * new String[] {Contacts.DISPLAY_NAME},
1133 * null, null, null);
1134 * Bundle bundle = cursor.getExtras();
Yorke Leea4aa9dc2014-08-04 13:47:50 -07001135 * if (bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES) &&
1136 * bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS)) {
Yorke Leef4b28452014-05-27 19:41:35 -07001137 * String sections[] =
Yorke Leea4aa9dc2014-08-04 13:47:50 -07001138 * bundle.getStringArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES);
1139 * int counts[] = bundle.getIntArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS);
Yorke Leef4b28452014-05-27 19:41:35 -07001140 * }
1141 * </pre>
1142 * </p>
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001143 */
1144 public static final String ADDRESS_BOOK_INDEX_EXTRAS = "address_book_index_extras";
1145
1146 /**
1147 * The array of address book index titles, which are returned in the
1148 * same order as the data in the cursor.
1149 * <p>TYPE: String[]</p>
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001150 */
1151 public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "address_book_index_titles";
1152
1153 /**
1154 * The array of group counts for the corresponding group. Contains the same number
1155 * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array.
1156 * <p>TYPE: int[]</p>
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001157 */
1158 public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "address_book_index_counts";
1159 }
1160
1161 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001162 * Constants for the contacts table, which contains a record per aggregate
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001163 * of raw contacts representing the same person.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001164 * <h3>Operations</h3>
1165 * <dl>
1166 * <dt><b>Insert</b></dt>
1167 * <dd>A Contact cannot be created explicitly. When a raw contact is
1168 * inserted, the provider will first try to find a Contact representing the
1169 * same person. If one is found, the raw contact's
1170 * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate
1171 * Contact. If no match is found, the provider automatically inserts a new
1172 * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column
1173 * of the newly inserted raw contact.</dd>
1174 * <dt><b>Update</b></dt>
1175 * <dd>Only certain columns of Contact are modifiable:
1176 * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED},
1177 * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of
1178 * these columns on the Contact also changes them on all constituent raw
1179 * contacts.</dd>
1180 * <dt><b>Delete</b></dt>
1181 * <dd>Be careful with deleting Contacts! Deleting an aggregate contact
1182 * deletes all constituent raw contacts. The corresponding sync adapters
1183 * will notice the deletions of their respective raw contacts and remove
1184 * them from their back end storage.</dd>
1185 * <dt><b>Query</b></dt>
1186 * <dd>
1187 * <ul>
1188 * <li>If you need to read an individual contact, consider using
1189 * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li>
1190 * <li>If you need to look up a contact by the phone number, use
1191 * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI},
1192 * which is optimized for this purpose.</li>
1193 * <li>If you need to look up a contact by partial name, e.g. to produce
1194 * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI.
1195 * <li>If you need to look up a contact by some data element like email
1196 * address, nickname, etc, use a query against the {@link ContactsContract.Data} table.
1197 * The result will contain contact ID, name etc.
1198 * </ul>
1199 * </dd>
1200 * </dl>
1201 * <h2>Columns</h2>
1202 * <table class="jd-sumtable">
1203 * <tr>
1204 * <th colspan='4'>Contacts</th>
1205 * </tr>
1206 * <tr>
1207 * <td>long</td>
1208 * <td>{@link #_ID}</td>
1209 * <td>read-only</td>
1210 * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td>
1211 * </tr>
1212 * <tr>
1213 * <td>String</td>
1214 * <td>{@link #LOOKUP_KEY}</td>
1215 * <td>read-only</td>
1216 * <td>An opaque value that contains hints on how to find the contact if its
1217 * row id changed as a result of a sync or aggregation.</td>
1218 * </tr>
1219 * <tr>
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001220 * <td>long</td>
Dmitri Plotnikov780211a2009-12-02 22:00:32 -08001221 * <td>NAME_RAW_CONTACT_ID</td>
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001222 * <td>read-only</td>
1223 * <td>The ID of the raw contact that contributes the display name
1224 * to the aggregate contact. During aggregation one of the constituent
1225 * raw contacts is chosen using a heuristic: a longer name or a name
1226 * with more diacritic marks or more upper case characters is chosen.</td>
1227 * </tr>
1228 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001229 * <td>String</td>
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08001230 * <td>DISPLAY_NAME_PRIMARY</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001231 * <td>read-only</td>
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001232 * <td>The display name for the contact. It is the display name
Dmitri Plotnikov780211a2009-12-02 22:00:32 -08001233 * contributed by the raw contact referred to by the NAME_RAW_CONTACT_ID
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001234 * column.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001235 * </tr>
1236 * <tr>
1237 * <td>long</td>
1238 * <td>{@link #PHOTO_ID}</td>
1239 * <td>read-only</td>
1240 * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo.
1241 * That row has the mime type
1242 * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field
1243 * is computed automatically based on the
1244 * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of
1245 * that mime type.</td>
1246 * </tr>
1247 * <tr>
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -07001248 * <td>long</td>
1249 * <td>{@link #PHOTO_URI}</td>
1250 * <td>read-only</td>
1251 * <td>A URI that can be used to retrieve the contact's full-size photo. This
1252 * column is the preferred method of retrieving the contact photo.</td>
1253 * </tr>
1254 * <tr>
1255 * <td>long</td>
1256 * <td>{@link #PHOTO_THUMBNAIL_URI}</td>
1257 * <td>read-only</td>
1258 * <td>A URI that can be used to retrieve the thumbnail of contact's photo. This
1259 * column is the preferred method of retrieving the contact photo.</td>
1260 * </tr>
1261 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001262 * <td>int</td>
1263 * <td>{@link #IN_VISIBLE_GROUP}</td>
1264 * <td>read-only</td>
1265 * <td>An indicator of whether this contact is supposed to be visible in the
1266 * UI. "1" if the contact has at least one raw contact that belongs to a
1267 * visible group; "0" otherwise.</td>
1268 * </tr>
1269 * <tr>
1270 * <td>int</td>
1271 * <td>{@link #HAS_PHONE_NUMBER}</td>
1272 * <td>read-only</td>
1273 * <td>An indicator of whether this contact has at least one phone number.
1274 * "1" if there is at least one phone number, "0" otherwise.</td>
1275 * </tr>
1276 * <tr>
1277 * <td>int</td>
1278 * <td>{@link #TIMES_CONTACTED}</td>
1279 * <td>read/write</td>
1280 * <td>The number of times the contact has been contacted. See
1281 * {@link #markAsContacted}. When raw contacts are aggregated, this field is
1282 * computed automatically as the maximum number of times contacted among all
1283 * constituent raw contacts. Setting this field automatically changes the
1284 * corresponding field on all constituent raw contacts.</td>
1285 * </tr>
1286 * <tr>
1287 * <td>long</td>
1288 * <td>{@link #LAST_TIME_CONTACTED}</td>
1289 * <td>read/write</td>
1290 * <td>The timestamp of the last time the contact was contacted. See
1291 * {@link #markAsContacted}. Setting this field also automatically
1292 * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated,
1293 * this field is computed automatically as the latest time contacted of all
1294 * constituent raw contacts. Setting this field automatically changes the
1295 * corresponding field on all constituent raw contacts.</td>
1296 * </tr>
1297 * <tr>
1298 * <td>int</td>
1299 * <td>{@link #STARRED}</td>
1300 * <td>read/write</td>
1301 * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
1302 * When raw contacts are aggregated, this field is automatically computed:
1303 * if any constituent raw contacts are starred, then this field is set to
1304 * '1'. Setting this field automatically changes the corresponding field on
1305 * all constituent raw contacts.</td>
1306 * </tr>
1307 * <tr>
1308 * <td>String</td>
1309 * <td>{@link #CUSTOM_RINGTONE}</td>
1310 * <td>read/write</td>
1311 * <td>A custom ringtone associated with a contact. Typically this is the
1312 * URI returned by an activity launched with the
1313 * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td>
1314 * </tr>
1315 * <tr>
1316 * <td>int</td>
1317 * <td>{@link #SEND_TO_VOICEMAIL}</td>
1318 * <td>read/write</td>
1319 * <td>An indicator of whether calls from this contact should be forwarded
1320 * directly to voice mail ('1') or not ('0'). When raw contacts are
1321 * aggregated, this field is automatically computed: if <i>all</i>
1322 * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set
1323 * to '1'. Setting this field automatically changes the corresponding field
1324 * on all constituent raw contacts.</td>
1325 * </tr>
1326 * <tr>
1327 * <td>int</td>
1328 * <td>{@link #CONTACT_PRESENCE}</td>
1329 * <td>read-only</td>
1330 * <td>Contact IM presence status. See {@link StatusUpdates} for individual
1331 * status definitions. Automatically computed as the highest presence of all
1332 * constituent raw contacts. The provider may choose not to store this value
1333 * in persistent storage. The expectation is that presence status will be
kmccormick50e27c82013-03-28 16:33:11 -07001334 * updated on a regular basis.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001335 * </tr>
1336 * <tr>
1337 * <td>String</td>
1338 * <td>{@link #CONTACT_STATUS}</td>
1339 * <td>read-only</td>
1340 * <td>Contact's latest status update. Automatically computed as the latest
1341 * of all constituent raw contacts' status updates.</td>
1342 * </tr>
1343 * <tr>
1344 * <td>long</td>
1345 * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
1346 * <td>read-only</td>
1347 * <td>The absolute time in milliseconds when the latest status was
1348 * inserted/updated.</td>
1349 * </tr>
1350 * <tr>
1351 * <td>String</td>
1352 * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
1353 * <td>read-only</td>
1354 * <td> The package containing resources for this status: label and icon.</td>
1355 * </tr>
1356 * <tr>
1357 * <td>long</td>
1358 * <td>{@link #CONTACT_STATUS_LABEL}</td>
1359 * <td>read-only</td>
1360 * <td>The resource ID of the label describing the source of contact status,
1361 * e.g. "Google Talk". This resource is scoped by the
1362 * {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
1363 * </tr>
1364 * <tr>
1365 * <td>long</td>
1366 * <td>{@link #CONTACT_STATUS_ICON}</td>
1367 * <td>read-only</td>
1368 * <td>The resource ID of the icon for the source of contact status. This
1369 * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
1370 * </tr>
1371 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07001372 */
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -07001373 public static class Contacts implements BaseColumns, ContactsColumns,
Yorke Lee94c87612014-07-18 18:57:17 -07001374 ContactOptionsColumns, ContactNameColumns, ContactStatusColumns, ContactCounts {
Evan Millar088b2912009-05-28 15:24:37 -07001375 /**
1376 * This utility class cannot be instantiated
1377 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001378 private Contacts() {}
Evan Millar088b2912009-05-28 15:24:37 -07001379
1380 /**
1381 * The content:// style URI for this table
1382 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001383 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
Evan Millar088b2912009-05-28 15:24:37 -07001384
1385 /**
Makoto Onuki31cd6f72014-07-08 15:20:39 -07001386 * Special contacts URI to refer to contacts on the corp profile from the personal
1387 * profile.
1388 *
1389 * It's supported only by a few specific places for referring to contact pictures that
1390 * are in the corp provider for enterprise caller-ID. Contact picture URIs returned from
1391 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may contain this kind of URI.
1392 *
1393 * @hide
1394 */
1395 public static final Uri CORP_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
1396 "contacts_corp");
1397
1398 /**
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001399 * A content:// style URI for this table that should be used to create
1400 * shortcuts or otherwise create long-term links to contacts. This URI
1401 * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}.
1402 * It can optionally also have a "/" and last known contact ID appended after
1403 * that. This "complete" format is an important optimization and is highly recommended.
1404 * <p>
1405 * As long as the contact's row ID remains the same, this URI is
1406 * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes
1407 * as a result of a sync or aggregation, this URI will look up the
1408 * contact using indirect information (sync IDs or constituent raw
1409 * contacts).
1410 * <p>
1411 * Lookup key should be appended unencoded - it is stored in the encoded
1412 * form, ready for use in a URI.
1413 */
1414 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
1415 "lookup");
1416
1417 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001418 * Base {@link Uri} for referencing a single {@link Contacts} entry,
Jeff Sharkey8f767342009-09-28 18:22:46 -07001419 * created by appending {@link #LOOKUP_KEY} using
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001420 * {@link Uri#withAppendedPath(Uri, String)}. Provides
1421 * {@link OpenableColumns} columns when queried, or returns the
1422 * referenced contact formatted as a vCard when opened through
1423 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
1424 */
1425 public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
1426 "as_vcard");
1427
Martijn Coenen037d3ff2011-06-15 16:01:45 +02001428 /**
1429 * Boolean parameter that may be used with {@link #CONTENT_VCARD_URI}
1430 * and {@link #CONTENT_MULTI_VCARD_URI} to indicate that the returned
1431 * vcard should not contain a photo.
1432 *
1433 * @hide
1434 */
1435 public static final String QUERY_PARAMETER_VCARD_NO_PHOTO = "nophoto";
1436
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001437 /**
Daniel Lehmann63e91402010-03-12 13:44:31 -08001438 * Base {@link Uri} for referencing multiple {@link Contacts} entry,
1439 * created by appending {@link #LOOKUP_KEY} using
1440 * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be
Yorke Lee217d8a72013-11-27 10:14:04 -08001441 * joined with the colon (":") separator, and the resulting string encoded.
1442 *
1443 * Provides {@link OpenableColumns} columns when queried, or returns the
Daniel Lehmann63e91402010-03-12 13:44:31 -08001444 * referenced contact formatted as a vCard when opened through
1445 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
1446 *
Yorke Lee217d8a72013-11-27 10:14:04 -08001447 * <p>
1448 * Usage example:
1449 * <dl>
1450 * <dt>The following code snippet creates a multi-vcard URI that references all the
1451 * contacts in a user's database.</dt>
1452 * <dd>
Daniel Lehmann63e91402010-03-12 13:44:31 -08001453 *
Yorke Lee217d8a72013-11-27 10:14:04 -08001454 * <pre>
1455 * public Uri getAllContactsVcardUri() {
1456 * Cursor cursor = getActivity().getContentResolver().query(Contacts.CONTENT_URI,
1457 * new String[] {Contacts.LOOKUP_KEY}, null, null, null);
1458 * if (cursor == null) {
1459 * return null;
1460 * }
1461 * try {
1462 * StringBuilder uriListBuilder = new StringBuilder();
1463 * int index = 0;
1464 * while (cursor.moveToNext()) {
1465 * if (index != 0) uriListBuilder.append(':');
1466 * uriListBuilder.append(cursor.getString(0));
1467 * index++;
1468 * }
1469 * return Uri.withAppendedPath(Contacts.CONTENT_MULTI_VCARD_URI,
1470 * Uri.encode(uriListBuilder.toString()));
1471 * } finally {
1472 * cursor.close();
1473 * }
1474 * }
1475 * </pre>
1476 *
1477 * </p>
Daniel Lehmann63e91402010-03-12 13:44:31 -08001478 */
1479 public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
1480 "as_multi_vcard");
1481
1482 /**
Jeff Sharkey6449eb02009-09-16 21:41:51 -07001483 * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the
1484 * requested {@link Contacts} entry.
1485 *
1486 * @param contactUri A {@link #CONTENT_URI} row, or an existing
1487 * {@link #CONTENT_LOOKUP_URI} to attempt refreshing.
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001488 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07001489 public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) {
1490 final Cursor c = resolver.query(contactUri, new String[] {
1491 Contacts.LOOKUP_KEY, Contacts._ID
1492 }, null, null, null);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001493 if (c == null) {
1494 return null;
1495 }
1496
1497 try {
1498 if (c.moveToFirst()) {
Jeff Sharkey6449eb02009-09-16 21:41:51 -07001499 final String lookupKey = c.getString(0);
1500 final long contactId = c.getLong(1);
1501 return getLookupUri(contactId, lookupKey);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001502 }
1503 } finally {
1504 c.close();
1505 }
1506 return null;
1507 }
1508
1509 /**
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -07001510 * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001511 * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}.
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -07001512 */
1513 public static Uri getLookupUri(long contactId, String lookupKey) {
1514 return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI,
1515 lookupKey), contactId);
1516 }
1517
1518 /**
Dmitri Plotnikovb5759b52009-09-01 15:58:40 -07001519 * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI.
1520 * <p>
1521 * Returns null if the contact cannot be found.
1522 */
1523 public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) {
1524 if (lookupUri == null) {
1525 return null;
1526 }
1527
1528 Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null);
1529 if (c == null) {
1530 return null;
1531 }
1532
1533 try {
1534 if (c.moveToFirst()) {
1535 long contactId = c.getLong(0);
1536 return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
1537 }
1538 } finally {
1539 c.close();
1540 }
1541 return null;
1542 }
1543
1544 /**
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001545 * Mark a contact as having been contacted. Updates two fields:
1546 * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED}. The
1547 * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED
1548 * field is populated with the current system time.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001549 *
1550 * @param resolver the ContentResolver to use
1551 * @param contactId the person who was contacted
Daniel Lehmanna1620dc2012-04-13 13:29:49 -07001552 *
1553 * @deprecated The class DataUsageStatUpdater of the Android support library should
1554 * be used instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001555 */
Daniel Lehmanna1620dc2012-04-13 13:29:49 -07001556 @Deprecated
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001557 public static void markAsContacted(ContentResolver resolver, long contactId) {
1558 Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId);
1559 ContentValues values = new ContentValues();
1560 // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified.
1561 values.put(LAST_TIME_CONTACTED, System.currentTimeMillis());
1562 resolver.update(uri, values, null, null);
1563 }
1564
1565 /**
Evan Millar161dd862009-06-12 16:02:43 -07001566 * The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001567 * {@link #CONTENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001568 * various parts of the contact name. The filter argument should be passed
Evan Millar161dd862009-06-12 16:02:43 -07001569 * as an additional path segment after this URI.
1570 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001571 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
1572 CONTENT_URI, "filter");
1573
Evan Millardc2da5f2009-06-18 16:07:13 -07001574 /**
1575 * The content:// style URI for this table joined with useful data from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001576 * {@link ContactsContract.Data}, filtered to include only starred contacts
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001577 * and the most frequently contacted contacts.
Evan Millardc2da5f2009-06-18 16:07:13 -07001578 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001579 public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath(
1580 CONTENT_URI, "strequent");
1581
Evan Millardc2da5f2009-06-18 16:07:13 -07001582 /**
Yorke Lee8d370092014-06-26 10:32:17 -07001583 * The content:// style URI for showing a list of frequently contacted people.
Daisuke Miyakawa3604bc52011-07-21 10:14:32 -07001584 */
1585 public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath(
1586 CONTENT_URI, "frequent");
1587
1588 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07001589 * The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001590 * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001591 * various parts of the contact name. The filter argument should be passed
Evan Millardc2da5f2009-06-18 16:07:13 -07001592 * as an additional path segment after this URI.
1593 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001594 public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath(
1595 CONTENT_STREQUENT_URI, "filter");
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001596
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001597 public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath(
1598 CONTENT_URI, "group");
1599
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001600 /**
Evan Millar088b2912009-05-28 15:24:37 -07001601 * The MIME type of {@link #CONTENT_URI} providing a directory of
1602 * people.
1603 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001604 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
Evan Millar088b2912009-05-28 15:24:37 -07001605
1606 /**
1607 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
1608 * person.
1609 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001610 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
Evan Millar088b2912009-05-28 15:24:37 -07001611
1612 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001613 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
1614 * person.
1615 */
1616 public static final String CONTENT_VCARD_TYPE = "text/x-vcard";
1617
Makoto Onuki80b3ab62014-07-10 11:24:21 -07001618
1619 /**
1620 * Mimimal ID for corp contacts returned from
1621 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
1622 *
1623 * @hide
1624 */
1625 public static long CORP_CONTACT_ID_BASE = 1000000000; // slightly smaller than 2 ** 30
1626
1627 /**
1628 * Return TRUE if a contact ID is from the contacts provider on the corp profile.
1629 *
1630 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may return such a contact.
1631 */
1632 public static boolean isCorpContactId(long contactId) {
1633 return (contactId >= CORP_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID);
1634 }
1635
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001636 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001637 * A sub-directory of a single contact that contains all of the constituent raw contact
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001638 * {@link ContactsContract.Data} rows. This directory can be used either
1639 * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}.
Evan Millar088b2912009-05-28 15:24:37 -07001640 */
Fred Quintana8851e162009-08-05 21:06:45 -07001641 public static final class Data implements BaseColumns, DataColumns {
Evan Millar088b2912009-05-28 15:24:37 -07001642 /**
1643 * no public constructor since this is a utility class
1644 */
1645 private Data() {}
1646
1647 /**
1648 * The directory twig for this sub-table
1649 */
1650 public static final String CONTENT_DIRECTORY = "data";
1651 }
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001652
1653 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001654 * <p>
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001655 * A sub-directory of a contact that contains all of its
1656 * {@link ContactsContract.RawContacts} as well as
1657 * {@link ContactsContract.Data} rows. To access this directory append
1658 * {@link #CONTENT_DIRECTORY} to the contact URI.
1659 * </p>
1660 * <p>
1661 * Entity has three ID fields: {@link #CONTACT_ID} for the contact,
1662 * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for
1663 * the data rows. Entity always contains at least one row per
1664 * constituent raw contact, even if there are no actual data rows. In
1665 * this case the {@link #DATA_ID} field will be null.
1666 * </p>
1667 * <p>
1668 * Entity reads all data for the entire contact in one transaction, to
1669 * guarantee consistency. There is significant data duplication
1670 * in the Entity (each row repeats all Contact columns and all RawContact
1671 * columns), so the benefits of transactional consistency should be weighed
1672 * against the cost of transferring large amounts of denormalized data
1673 * from the Provider.
1674 * </p>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07001675 * <p>
1676 * To reduce the amount of data duplication the contacts provider and directory
1677 * providers implementing this protocol are allowed to provide common Contacts
1678 * and RawContacts fields in the first row returned for each raw contact only and
1679 * leave them as null in subsequent rows.
1680 * </p>
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001681 */
1682 public static final class Entity implements BaseColumns, ContactsColumns,
1683 ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns,
Paul Soulos42cdda82014-06-19 16:13:38 -07001684 StatusColumns, ContactOptionsColumns, ContactStatusColumns, DataUsageStatColumns {
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001685 /**
1686 * no public constructor since this is a utility class
1687 */
1688 private Entity() {
1689 }
1690
1691 /**
1692 * The directory twig for this sub-table
1693 */
1694 public static final String CONTENT_DIRECTORY = "entities";
1695
1696 /**
1697 * The ID of the raw contact row.
1698 * <P>Type: INTEGER</P>
1699 */
1700 public static final String RAW_CONTACT_ID = "raw_contact_id";
1701
1702 /**
1703 * The ID of the data row. The value will be null if this raw contact has no
1704 * data rows.
1705 * <P>Type: INTEGER</P>
1706 */
1707 public static final String DATA_ID = "data_id";
1708 }
1709
1710 /**
Dave Santoro0b61f592011-10-03 18:25:26 -07001711 * <p>
Dave Santorod414f102011-06-20 14:35:06 -07001712 * A sub-directory of a single contact that contains all of the constituent raw contact
1713 * {@link ContactsContract.StreamItems} rows. This directory can be used either
1714 * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}.
Dave Santoro0b61f592011-10-03 18:25:26 -07001715 * </p>
1716 * <p>
1717 * Querying for social stream data requires android.permission.READ_SOCIAL_STREAM
1718 * permission.
1719 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07001720 *
1721 * @deprecated - Do not use. This will not be supported in the future. In the future,
1722 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07001723 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07001724 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07001725 public static final class StreamItems implements StreamItemsColumns {
1726 /**
1727 * no public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07001728 *
1729 * @deprecated - Do not use. This will not be supported in the future. In the future,
1730 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07001731 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07001732 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07001733 private StreamItems() {}
1734
1735 /**
1736 * The directory twig for this sub-table
Brian Attwellbdb13c82014-07-16 21:43:54 -07001737 *
1738 * @deprecated - Do not use. This will not be supported in the future. In the future,
1739 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07001740 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07001741 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07001742 public static final String CONTENT_DIRECTORY = "stream_items";
1743 }
1744
1745 /**
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001746 * <p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001747 * A <i>read-only</i> sub-directory of a single contact aggregate that
1748 * contains all aggregation suggestions (other contacts). The
1749 * aggregation suggestions are computed based on approximate data
1750 * matches with this contact.
1751 * </p>
1752 * <p>
1753 * <i>Note: this query may be expensive! If you need to use it in bulk,
1754 * make sure the user experience is acceptable when the query runs for a
1755 * long time.</i>
1756 * <p>
1757 * Usage example:
1758 *
1759 * <pre>
1760 * Uri uri = Contacts.CONTENT_URI.buildUpon()
1761 * .appendEncodedPath(String.valueOf(contactId))
1762 * .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY)
1763 * .appendQueryParameter(&quot;limit&quot;, &quot;3&quot;)
1764 * .build()
1765 * Cursor cursor = getContentResolver().query(suggestionsUri,
1766 * new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY},
1767 * null, null, null);
1768 * </pre>
1769 *
1770 * </p>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001771 * <p>
1772 * This directory can be used either with a {@link #CONTENT_URI} or
1773 * {@link #CONTENT_LOOKUP_URI}.
1774 * </p>
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001775 */
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001776 public static final class AggregationSuggestions implements BaseColumns, ContactsColumns,
1777 ContactOptionsColumns, ContactStatusColumns {
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001778 /**
1779 * No public constructor since this is a utility class
1780 */
1781 private AggregationSuggestions() {}
1782
1783 /**
Dmitri Plotnikov0fc02442009-09-21 13:26:28 -07001784 * The directory twig for this sub-table. The URI can be followed by an optional
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001785 * type-to-filter, similar to
1786 * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}.
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001787 */
1788 public static final String CONTENT_DIRECTORY = "suggestions";
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07001789
1790 /**
1791 * Used with {@link Builder#addParameter} to specify what kind of data is
1792 * supplied for the suggestion query.
1793 *
1794 * @hide
1795 */
1796 public static final String PARAMETER_MATCH_NAME = "name";
1797
1798 /**
1799 * Used with {@link Builder#addParameter} to specify what kind of data is
1800 * supplied for the suggestion query.
1801 *
1802 * @hide
1803 */
1804 public static final String PARAMETER_MATCH_EMAIL = "email";
1805
1806 /**
1807 * Used with {@link Builder#addParameter} to specify what kind of data is
1808 * supplied for the suggestion query.
1809 *
1810 * @hide
1811 */
1812 public static final String PARAMETER_MATCH_PHONE = "phone";
1813
1814 /**
1815 * Used with {@link Builder#addParameter} to specify what kind of data is
1816 * supplied for the suggestion query.
1817 *
1818 * @hide
1819 */
1820 public static final String PARAMETER_MATCH_NICKNAME = "nickname";
1821
1822 /**
1823 * A convenience builder for aggregation suggestion content URIs.
1824 *
1825 * TODO: change documentation for this class to use the builder.
1826 * @hide
1827 */
1828 public static final class Builder {
1829 private long mContactId;
1830 private ArrayList<String> mKinds = new ArrayList<String>();
1831 private ArrayList<String> mValues = new ArrayList<String>();
1832 private int mLimit;
1833
1834 /**
1835 * Optional existing contact ID. If it is not provided, the search
1836 * will be based exclusively on the values supplied with {@link #addParameter}.
1837 */
1838 public Builder setContactId(long contactId) {
1839 this.mContactId = contactId;
1840 return this;
1841 }
1842
1843 /**
1844 * A value that can be used when searching for an aggregation
1845 * suggestion.
1846 *
1847 * @param kind can be one of
1848 * {@link AggregationSuggestions#PARAMETER_MATCH_NAME},
1849 * {@link AggregationSuggestions#PARAMETER_MATCH_EMAIL},
1850 * {@link AggregationSuggestions#PARAMETER_MATCH_NICKNAME},
1851 * {@link AggregationSuggestions#PARAMETER_MATCH_PHONE}
1852 */
1853 public Builder addParameter(String kind, String value) {
1854 if (!TextUtils.isEmpty(value)) {
1855 mKinds.add(kind);
1856 mValues.add(value);
1857 }
1858 return this;
1859 }
1860
1861 public Builder setLimit(int limit) {
1862 mLimit = limit;
1863 return this;
1864 }
1865
1866 public Uri build() {
1867 android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon();
1868 builder.appendEncodedPath(String.valueOf(mContactId));
1869 builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY);
1870 if (mLimit != 0) {
1871 builder.appendQueryParameter("limit", String.valueOf(mLimit));
1872 }
1873
1874 int count = mKinds.size();
1875 for (int i = 0; i < count; i++) {
1876 builder.appendQueryParameter("query", mKinds.get(i) + ":" + mValues.get(i));
1877 }
1878
1879 return builder.build();
1880 }
1881 }
1882
1883 /**
1884 * @hide
1885 */
1886 public static final Builder builder() {
1887 return new Builder();
1888 }
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001889 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001890
1891 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001892 * A <i>read-only</i> sub-directory of a single contact that contains
Dave Santoroa5282372011-06-29 00:25:16 -07001893 * the contact's primary photo. The photo may be stored in up to two ways -
1894 * the default "photo" is a thumbnail-sized image stored directly in the data
1895 * row, while the "display photo", if present, is a larger version stored as
1896 * a file.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001897 * <p>
1898 * Usage example:
Dave Santoroa5282372011-06-29 00:25:16 -07001899 * <dl>
1900 * <dt>Retrieving the thumbnail-sized photo</dt>
1901 * <dd>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001902 * <pre>
1903 * public InputStream openPhoto(long contactId) {
1904 * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
1905 * Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
1906 * Cursor cursor = getContentResolver().query(photoUri,
1907 * new String[] {Contacts.Photo.PHOTO}, null, null, null);
1908 * if (cursor == null) {
1909 * return null;
1910 * }
1911 * try {
1912 * if (cursor.moveToFirst()) {
1913 * byte[] data = cursor.getBlob(0);
1914 * if (data != null) {
1915 * return new ByteArrayInputStream(data);
1916 * }
1917 * }
1918 * } finally {
1919 * cursor.close();
1920 * }
1921 * return null;
1922 * }
1923 * </pre>
Dave Santoroa5282372011-06-29 00:25:16 -07001924 * </dd>
1925 * <dt>Retrieving the larger photo version</dt>
1926 * <dd>
1927 * <pre>
1928 * public InputStream openDisplayPhoto(long contactId) {
1929 * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
1930 * Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO);
1931 * try {
1932 * AssetFileDescriptor fd =
Dave Santoro040e6b32011-07-15 15:14:08 -07001933 * getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r");
Dave Santoroa5282372011-06-29 00:25:16 -07001934 * return fd.createInputStream();
Dave Santoro040e6b32011-07-15 15:14:08 -07001935 * } catch (IOException e) {
Dave Santoroa5282372011-06-29 00:25:16 -07001936 * return null;
1937 * }
1938 * }
1939 * </pre>
1940 * </dd>
1941 * </dl>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001942 *
1943 * </p>
Dave Santoroa5282372011-06-29 00:25:16 -07001944 * <p>You may also consider using the convenience method
Daniel Lehmannf5d46522011-07-14 22:16:21 -07001945 * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri, boolean)}
1946 * to retrieve the raw photo contents of either the thumbnail-sized or the full-sized photo.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001947 * </p>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001948 * <p>
1949 * This directory can be used either with a {@link #CONTENT_URI} or
1950 * {@link #CONTENT_LOOKUP_URI}.
1951 * </p>
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001952 */
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001953 public static final class Photo implements BaseColumns, DataColumnsWithJoins {
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -07001954 /**
1955 * no public constructor since this is a utility class
1956 */
1957 private Photo() {}
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -07001958
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -07001959 /**
1960 * The directory twig for this sub-table
1961 */
1962 public static final String CONTENT_DIRECTORY = "photo";
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001963
1964 /**
Dave Santoroa5282372011-06-29 00:25:16 -07001965 * The directory twig for retrieving the full-size display photo.
1966 */
1967 public static final String DISPLAY_PHOTO = "display_photo";
1968
1969 /**
1970 * Full-size photo file ID of the raw contact.
1971 * See {@link ContactsContract.DisplayPhoto}.
1972 * <p>
1973 * Type: NUMBER
1974 */
1975 public static final String PHOTO_FILE_ID = DATA14;
1976
1977 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001978 * Thumbnail photo of the raw contact. This is the raw bytes of an image
1979 * that could be inflated using {@link android.graphics.BitmapFactory}.
1980 * <p>
1981 * Type: BLOB
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001982 */
1983 public static final String PHOTO = DATA15;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001984 }
1985
1986 /**
Daniel Lehmannf5d46522011-07-14 22:16:21 -07001987 * Opens an InputStream for the contacts's photo and returns the
1988 * photo as a byte stream.
1989 * @param cr The content resolver to use for querying
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001990 * @param contactUri the contact whose photo should be used. This can be used with
1991 * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI.
Daniel Lehmannf5d46522011-07-14 22:16:21 -07001992 * @param preferHighres If this is true and the contact has a higher resolution photo
1993 * available, it is returned. If false, this function always tries to get the thumbnail
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001994 * @return an InputStream of the photo, or null if no photo is present
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07001995 */
Daniel Lehmannf5d46522011-07-14 22:16:21 -07001996 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri,
1997 boolean preferHighres) {
1998 if (preferHighres) {
1999 final Uri displayPhotoUri = Uri.withAppendedPath(contactUri,
2000 Contacts.Photo.DISPLAY_PHOTO);
2001 InputStream inputStream;
2002 try {
2003 AssetFileDescriptor fd = cr.openAssetFileDescriptor(displayPhotoUri, "r");
2004 return fd.createInputStream();
2005 } catch (IOException e) {
2006 // fallback to the thumbnail code
2007 }
2008 }
2009
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -07002010 Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY);
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -07002011 if (photoUri == null) {
2012 return null;
2013 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002014 Cursor cursor = cr.query(photoUri,
Daniel Lehmannf5d46522011-07-14 22:16:21 -07002015 new String[] {
2016 ContactsContract.CommonDataKinds.Photo.PHOTO
2017 }, null, null, null);
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002018 try {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -07002019 if (cursor == null || !cursor.moveToNext()) {
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002020 return null;
2021 }
2022 byte[] data = cursor.getBlob(0);
2023 if (data == null) {
2024 return null;
2025 }
2026 return new ByteArrayInputStream(data);
2027 } finally {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -07002028 if (cursor != null) {
2029 cursor.close();
2030 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002031 }
2032 }
Daniel Lehmannf5d46522011-07-14 22:16:21 -07002033
2034 /**
2035 * Opens an InputStream for the contacts's thumbnail photo and returns the
2036 * photo as a byte stream.
2037 * @param cr The content resolver to use for querying
2038 * @param contactUri the contact whose photo should be used. This can be used with
2039 * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI.
2040 * @return an InputStream of the photo, or null if no photo is present
2041 * @see #openContactPhotoInputStream(ContentResolver, Uri, boolean), if instead
2042 * of the thumbnail the high-res picture is preferred
2043 */
2044 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
2045 return openContactPhotoInputStream(cr, contactUri, false);
2046 }
Evan Millar088b2912009-05-28 15:24:37 -07002047 }
2048
Dave Santoro43251332011-05-11 11:39:54 -07002049 /**
2050 * <p>
2051 * Constants for the user's profile data, which is represented as a single contact on
2052 * the device that represents the user. The profile contact is not aggregated
2053 * together automatically in the same way that normal contacts are; instead, each
Dave Santoro063084e2011-08-23 15:42:49 -07002054 * account (including data set, if applicable) on the device may contribute a single
2055 * raw contact representing the user's personal profile data from that source.
Dave Santoro43251332011-05-11 11:39:54 -07002056 * </p>
2057 * <p>
2058 * Access to the profile entry through these URIs (or incidental access to parts of
2059 * the profile if retrieved directly via ID) requires additional permissions beyond
2060 * the read/write contact permissions required by the provider. Querying for profile
2061 * data requires android.permission.READ_PROFILE permission, and inserting or
2062 * updating profile data requires android.permission.WRITE_PROFILE permission.
2063 * </p>
2064 * <h3>Operations</h3>
2065 * <dl>
2066 * <dt><b>Insert</b></dt>
2067 * <dd>The user's profile entry cannot be created explicitly (attempting to do so
2068 * will throw an exception). When a raw contact is inserted into the profile, the
2069 * provider will check for the existence of a profile on the device. If one is
2070 * found, the raw contact's {@link RawContacts#CONTACT_ID} column gets the _ID of
2071 * the profile Contact. If no match is found, the profile Contact is created and
2072 * its _ID is put into the {@link RawContacts#CONTACT_ID} column of the newly
2073 * inserted raw contact.</dd>
2074 * <dt><b>Update</b></dt>
2075 * <dd>The profile Contact has the same update restrictions as Contacts in general,
2076 * but requires the android.permission.WRITE_PROFILE permission.</dd>
2077 * <dt><b>Delete</b></dt>
2078 * <dd>The profile Contact cannot be explicitly deleted. It will be removed
2079 * automatically if all of its constituent raw contact entries are deleted.</dd>
2080 * <dt><b>Query</b></dt>
2081 * <dd>
2082 * <ul>
2083 * <li>The {@link #CONTENT_URI} for profiles behaves in much the same way as
2084 * retrieving a contact by ID, except that it will only ever return the user's
2085 * profile contact.
2086 * </li>
2087 * <li>
2088 * The profile contact supports all of the same sub-paths as an individual contact
2089 * does - the content of the profile contact can be retrieved as entities or
2090 * data rows. Similarly, specific raw contact entries can be retrieved by appending
2091 * the desired raw contact ID within the profile.
2092 * </li>
2093 * </ul>
2094 * </dd>
2095 * </dl>
2096 */
2097 public static final class Profile implements BaseColumns, ContactsColumns,
2098 ContactOptionsColumns, ContactNameColumns, ContactStatusColumns {
2099 /**
2100 * This utility class cannot be instantiated
2101 */
2102 private Profile() {
2103 }
2104
2105 /**
2106 * The content:// style URI for this table, which requests the contact entry
2107 * representing the user's personal profile data.
2108 */
2109 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "profile");
2110
2111 /**
2112 * {@link Uri} for referencing the user's profile {@link Contacts} entry,
2113 * Provides {@link OpenableColumns} columns when queried, or returns the
2114 * user's profile contact formatted as a vCard when opened through
2115 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
2116 */
2117 public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
2118 "as_vcard");
2119
2120 /**
2121 * {@link Uri} for referencing the raw contacts that make up the user's profile
2122 * {@link Contacts} entry. An individual raw contact entry within the profile
2123 * can be addressed by appending the raw contact ID. The entities or data within
2124 * that specific raw contact can be requested by appending the entity or data
2125 * path as well.
2126 */
2127 public static final Uri CONTENT_RAW_CONTACTS_URI = Uri.withAppendedPath(CONTENT_URI,
2128 "raw_contacts");
Dave Santoro063084e2011-08-23 15:42:49 -07002129
2130 /**
2131 * The minimum ID for any entity that belongs to the profile. This essentially
2132 * defines an ID-space in which profile data is stored, and is used by the provider
2133 * to determine whether a request via a non-profile-specific URI should be directed
2134 * to the profile data rather than general contacts data, along with all the special
2135 * permission checks that entails.
2136 *
2137 * Callers may use {@link #isProfileId} to check whether a specific ID falls into
2138 * the set of data intended for the profile.
2139 */
2140 public static final long MIN_ID = Long.MAX_VALUE - (long) Integer.MAX_VALUE;
2141 }
2142
2143 /**
2144 * This method can be used to identify whether the given ID is associated with profile
2145 * data. It does not necessarily indicate that the ID is tied to valid data, merely
2146 * that accessing data using this ID will result in profile access checks and will only
2147 * return data from the profile.
2148 *
2149 * @param id The ID to check.
2150 * @return Whether the ID is associated with profile data.
2151 */
2152 public static boolean isProfileId(long id) {
2153 return id >= Profile.MIN_ID;
Dave Santoro43251332011-05-11 11:39:54 -07002154 }
2155
Chiao Cheng2355d132013-03-20 16:54:06 -07002156 protected interface DeletedContactsColumns {
2157
2158 /**
2159 * A reference to the {@link ContactsContract.Contacts#_ID} that was deleted.
2160 * <P>Type: INTEGER</P>
2161 */
2162 public static final String CONTACT_ID = "contact_id";
2163
2164 /**
2165 * Time (milliseconds since epoch) that the contact was deleted.
2166 */
2167 public static final String CONTACT_DELETED_TIMESTAMP = "contact_deleted_timestamp";
2168 }
2169
2170 /**
2171 * Constants for the deleted contact table. This table holds a log of deleted contacts.
2172 * <p>
2173 * Log older than {@link #DAYS_KEPT_MILLISECONDS} may be deleted.
2174 */
2175 public static final class DeletedContacts implements DeletedContactsColumns {
2176
2177 /**
2178 * This utility class cannot be instantiated
2179 */
2180 private DeletedContacts() {
2181 }
2182
2183 /**
2184 * The content:// style URI for this table, which requests a directory of raw contact rows
2185 * matching the selection criteria.
2186 */
2187 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
2188 "deleted_contacts");
2189
2190 /**
2191 * Number of days that the delete log will be kept. After this time, delete records may be
2192 * deleted.
2193 *
2194 * @hide
2195 */
2196 private static final int DAYS_KEPT = 30;
2197
2198 /**
2199 * Milliseconds that the delete log will be kept. After this time, delete records may be
2200 * deleted.
2201 */
2202 public static final long DAYS_KEPT_MILLISECONDS = 1000L * 60L * 60L * 24L * (long)DAYS_KEPT;
2203 }
2204
2205
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07002206 protected interface RawContactsColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002207 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002208 * A reference to the {@link ContactsContract.Contacts#_ID} that this
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002209 * data belongs to.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002210 * <P>Type: INTEGER</P>
Evan Millar088b2912009-05-28 15:24:37 -07002211 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002212 public static final String CONTACT_ID = "contact_id";
Evan Millar088b2912009-05-28 15:24:37 -07002213
2214 /**
Dave Santorod7bdc182011-06-24 15:39:39 -07002215 * The data set within the account that this row belongs to. This allows
2216 * multiple sync adapters for the same account type to distinguish between
2217 * each others' data.
2218 *
2219 * This is empty by default, and is completely optional. It only needs to
2220 * be populated if multiple sync adapters are entering distinct data for
2221 * the same account type and account name.
2222 * <P>Type: TEXT</P>
2223 */
2224 public static final String DATA_SET = "data_set";
2225
2226 /**
Dave Santoro1d55c332011-07-25 16:44:45 -07002227 * A concatenation of the account type and data set (delimited by a forward
2228 * slash) - if the data set is empty, this will be the same as the account
2229 * type. For applications that need to be aware of the data set, this can
2230 * be used instead of account type to distinguish sets of data. This is
2231 * never intended to be used for specifying accounts.
Dave Santoro1d55c332011-07-25 16:44:45 -07002232 */
2233 public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
2234
2235 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002236 * The aggregation mode for this contact.
2237 * <P>Type: INTEGER</P>
2238 */
2239 public static final String AGGREGATION_MODE = "aggregation_mode";
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -07002240
2241 /**
2242 * The "deleted" flag: "0" by default, "1" if the row has been marked
2243 * for deletion. When {@link android.content.ContentResolver#delete} is
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07002244 * called on a raw contact, it is marked for deletion and removed from its
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002245 * aggregate contact. The sync adaptor deletes the raw contact on the server and
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -07002246 * then calls ContactResolver.delete once more, this time passing the
Fred Quintana33f889a2009-09-14 17:31:26 -07002247 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
2248 * the data removal.
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -07002249 * <P>Type: INTEGER</P>
2250 */
2251 public static final String DELETED = "deleted";
Dmitri Plotnikov918007b2010-01-20 12:12:11 -08002252
2253 /**
2254 * The "name_verified" flag: "1" means that the name fields on this raw
2255 * contact can be trusted and therefore should be used for the entire
2256 * aggregated contact.
2257 * <p>
2258 * If an aggregated contact contains more than one raw contact with a
2259 * verified name, one of those verified names is chosen at random.
2260 * If an aggregated contact contains no verified names, the
2261 * name is chosen randomly from the constituent raw contacts.
2262 * </p>
2263 * <p>
2264 * Updating this flag from "0" to "1" automatically resets it to "0" on
2265 * all other raw contacts in the same aggregated contact.
2266 * </p>
2267 * <p>
2268 * Sync adapters should only specify a value for this column when
2269 * inserting a raw contact and leave it out when doing an update.
2270 * </p>
2271 * <p>
2272 * The default value is "0"
2273 * </p>
2274 * <p>Type: INTEGER</p>
Yorke Leeb31c8ab2014-08-26 17:13:02 -07002275 *
2276 * @hide
Dmitri Plotnikov918007b2010-01-20 12:12:11 -08002277 */
2278 public static final String NAME_VERIFIED = "name_verified";
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -07002279
2280 /**
2281 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
2282 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
2283 * <P>Type: INTEGER</P>
2284 */
Dmitri Plotnikov86fe8392010-07-16 11:19:46 -07002285 public static final String RAW_CONTACT_IS_READ_ONLY = "raw_contact_is_read_only";
Dave Santoro43251332011-05-11 11:39:54 -07002286
2287 /**
2288 * Flag that reflects whether this raw contact belongs to the user's
2289 * personal profile entry.
2290 */
2291 public static final String RAW_CONTACT_IS_USER_PROFILE = "raw_contact_is_user_profile";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002292 }
2293
2294 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002295 * Constants for the raw contacts table, which contains one row of contact
2296 * information for each person in each synced account. Sync adapters and
2297 * contact management apps
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -07002298 * are the primary consumers of this API.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002299 *
2300 * <h3>Aggregation</h3>
2301 * <p>
2302 * As soon as a raw contact is inserted or whenever its constituent data
2303 * changes, the provider will check if the raw contact matches other
2304 * existing raw contacts and if so will aggregate it with those. The
2305 * aggregation is reflected in the {@link RawContacts} table by the change of the
2306 * {@link #CONTACT_ID} field, which is the reference to the aggregate contact.
2307 * </p>
2308 * <p>
2309 * Changes to the structured name, organization, phone number, email address,
2310 * or nickname trigger a re-aggregation.
2311 * </p>
2312 * <p>
2313 * See also {@link AggregationExceptions} for a mechanism to control
2314 * aggregation programmatically.
2315 * </p>
2316 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002317 * <h3>Operations</h3>
2318 * <dl>
2319 * <dt><b>Insert</b></dt>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002320 * <dd>
2321 * <p>
2322 * Raw contacts can be inserted incrementally or in a batch.
2323 * The incremental method is more traditional but less efficient.
2324 * It should be used
2325 * only if no {@link Data} values are available at the time the raw contact is created:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002326 * <pre>
2327 * ContentValues values = new ContentValues();
2328 * values.put(RawContacts.ACCOUNT_TYPE, accountType);
2329 * values.put(RawContacts.ACCOUNT_NAME, accountName);
2330 * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values);
2331 * long rawContactId = ContentUris.parseId(rawContactUri);
2332 * </pre>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002333 * </p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002334 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002335 * Once {@link Data} values become available, insert those.
2336 * For example, here's how you would insert a name:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002337 *
2338 * <pre>
2339 * values.clear();
2340 * values.put(Data.RAW_CONTACT_ID, rawContactId);
2341 * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
2342 * values.put(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;);
2343 * getContentResolver().insert(Data.CONTENT_URI, values);
2344 * </pre>
2345 * </p>
2346 * <p>
2347 * The batch method is by far preferred. It inserts the raw contact and its
2348 * constituent data rows in a single database transaction
2349 * and causes at most one aggregation pass.
2350 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07002351 * ArrayList&lt;ContentProviderOperation&gt; ops =
2352 * new ArrayList&lt;ContentProviderOperation&gt;();
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002353 * ...
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002354 * int rawContactInsertIndex = ops.size();
2355 * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
2356 * .withValue(RawContacts.ACCOUNT_TYPE, accountType)
2357 * .withValue(RawContacts.ACCOUNT_NAME, accountName)
2358 * .build());
2359 *
2360 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
2361 * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex)
2362 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
2363 * .withValue(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;)
2364 * .build());
2365 *
2366 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
2367 * </pre>
2368 * </p>
2369 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002370 * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)}
2371 * to refer to the as-yet-unknown index value of the raw contact inserted in the
2372 * first operation.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002373 * </p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002374 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002375 * <dt><b>Update</b></dt>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002376 * <dd><p>
2377 * Raw contacts can be updated incrementally or in a batch.
2378 * Batch mode should be used whenever possible.
2379 * The procedures and considerations are analogous to those documented above for inserts.
2380 * </p></dd>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002381 * <dt><b>Delete</b></dt>
2382 * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates,
2383 * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002384 * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row
2385 * itself is also deleted automatically.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002386 * </p>
2387 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002388 * The invocation of {@code resolver.delete(...)}, does not immediately delete
2389 * a raw contacts row.
2390 * Instead, it sets the {@link #DELETED} flag on the raw contact and
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002391 * removes the raw contact from its aggregate contact.
2392 * The sync adapter then deletes the raw contact from the server and
2393 * finalizes phone-side deletion by calling {@code resolver.delete(...)}
Fred Quintana328c0e72009-12-07 14:52:28 -08002394 * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002395 * <p>Some sync adapters are read-only, meaning that they only sync server-side
2396 * changes to the phone, but not the reverse. If one of those raw contacts
2397 * is marked for deletion, it will remain on the phone. However it will be
2398 * effectively invisible, because it will not be part of any aggregate contact.
2399 * </dd>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002400 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002401 * <dt><b>Query</b></dt>
2402 * <dd>
2403 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002404 * It is easy to find all raw contacts in a Contact:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002405 * <pre>
2406 * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI,
2407 * new String[]{RawContacts._ID},
2408 * RawContacts.CONTACT_ID + "=?",
2409 * new String[]{String.valueOf(contactId)}, null);
2410 * </pre>
2411 * </p>
2412 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002413 * To find raw contacts within a specific account,
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002414 * you can either put the account name and type in the selection or pass them as query
2415 * parameters. The latter approach is preferable, especially when you can reuse the
2416 * URI:
2417 * <pre>
Adam Koch95e5a072013-05-21 09:47:55 -04002418 * Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon()
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002419 * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName)
2420 * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType)
2421 * .build();
2422 * Cursor c1 = getContentResolver().query(rawContactUri,
2423 * RawContacts.STARRED + "&lt;&gt;0", null, null, null);
2424 * ...
2425 * Cursor c2 = getContentResolver().query(rawContactUri,
2426 * RawContacts.DELETED + "&lt;&gt;0", null, null, null);
2427 * </pre>
2428 * </p>
2429 * <p>The best way to read a raw contact along with all the data associated with it is
2430 * by using the {@link Entity} directory. If the raw contact has data rows,
2431 * the Entity cursor will contain a row for each data row. If the raw contact has no
2432 * data rows, the cursor will still contain one row with the raw contact-level information.
2433 * <pre>
2434 * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId);
2435 * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY);
2436 * Cursor c = getContentResolver().query(entityUri,
2437 * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1},
2438 * null, null, null);
2439 * try {
2440 * while (c.moveToNext()) {
2441 * String sourceId = c.getString(0);
2442 * if (!c.isNull(1)) {
2443 * String mimeType = c.getString(2);
2444 * String data = c.getString(3);
2445 * ...
2446 * }
2447 * }
2448 * } finally {
2449 * c.close();
2450 * }
2451 * </pre>
2452 * </p>
2453 * </dd>
2454 * </dl>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002455 * <h2>Columns</h2>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002456 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002457 * <table class="jd-sumtable">
2458 * <tr>
2459 * <th colspan='4'>RawContacts</th>
2460 * </tr>
2461 * <tr>
2462 * <td>long</td>
2463 * <td>{@link #_ID}</td>
2464 * <td>read-only</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002465 * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words,
2466 * it is much better for a sync adapter to update a raw contact rather than to delete and
2467 * re-insert it.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002468 * </tr>
2469 * <tr>
2470 * <td>long</td>
2471 * <td>{@link #CONTACT_ID}</td>
2472 * <td>read-only</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002473 * <td>The ID of the row in the {@link ContactsContract.Contacts} table
2474 * that this raw contact belongs
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002475 * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled
2476 * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td>
2477 * </tr>
2478 * <tr>
2479 * <td>int</td>
2480 * <td>{@link #AGGREGATION_MODE}</td>
2481 * <td>read/write</td>
2482 * <td>A mechanism that allows programmatic control of the aggregation process. The allowed
2483 * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED}
2484 * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td>
2485 * </tr>
2486 * <tr>
2487 * <td>int</td>
2488 * <td>{@link #DELETED}</td>
2489 * <td>read/write</td>
2490 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
2491 * for deletion. When {@link android.content.ContentResolver#delete} is
2492 * called on a raw contact, it is marked for deletion and removed from its
2493 * aggregate contact. The sync adaptor deletes the raw contact on the server and
2494 * then calls ContactResolver.delete once more, this time passing the
2495 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
2496 * the data removal.</td>
2497 * </tr>
2498 * <tr>
2499 * <td>int</td>
2500 * <td>{@link #TIMES_CONTACTED}</td>
2501 * <td>read/write</td>
2502 * <td>The number of times the contact has been contacted. To have an effect
2503 * on the corresponding value of the aggregate contact, this field
2504 * should be set at the time the raw contact is inserted.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002505 * After that, this value is typically updated via
2506 * {@link ContactsContract.Contacts#markAsContacted}.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002507 * </tr>
2508 * <tr>
2509 * <td>long</td>
2510 * <td>{@link #LAST_TIME_CONTACTED}</td>
2511 * <td>read/write</td>
2512 * <td>The timestamp of the last time the contact was contacted. To have an effect
2513 * on the corresponding value of the aggregate contact, this field
2514 * should be set at the time the raw contact is inserted.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002515 * After that, this value is typically updated via
2516 * {@link ContactsContract.Contacts#markAsContacted}.
2517 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002518 * </tr>
2519 * <tr>
2520 * <td>int</td>
2521 * <td>{@link #STARRED}</td>
2522 * <td>read/write</td>
2523 * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002524 * Changing this field immediately affects the corresponding aggregate contact:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002525 * if any raw contacts in that aggregate contact are starred, then the contact
2526 * itself is marked as starred.</td>
2527 * </tr>
2528 * <tr>
2529 * <td>String</td>
2530 * <td>{@link #CUSTOM_RINGTONE}</td>
2531 * <td>read/write</td>
2532 * <td>A custom ringtone associated with a raw contact. Typically this is the
2533 * URI returned by an activity launched with the
2534 * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.
2535 * To have an effect on the corresponding value of the aggregate contact, this field
2536 * should be set at the time the raw contact is inserted. To set a custom
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002537 * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE
2538 * Contacts.CUSTOM_RINGTONE}
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002539 * instead.</td>
2540 * </tr>
2541 * <tr>
2542 * <td>int</td>
2543 * <td>{@link #SEND_TO_VOICEMAIL}</td>
2544 * <td>read/write</td>
2545 * <td>An indicator of whether calls from this raw contact should be forwarded
2546 * directly to voice mail ('1') or not ('0'). To have an effect
2547 * on the corresponding value of the aggregate contact, this field
2548 * should be set at the time the raw contact is inserted.</td>
2549 * </tr>
2550 * <tr>
2551 * <td>String</td>
2552 * <td>{@link #ACCOUNT_NAME}</td>
2553 * <td>read/write-once</td>
2554 * <td>The name of the account instance to which this row belongs, which when paired with
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002555 * {@link #ACCOUNT_TYPE} identifies a specific account.
2556 * For example, this will be the Gmail address if it is a Google account.
Dave Santorod7bdc182011-06-24 15:39:39 -07002557 * It should be set at the time the raw contact is inserted and never
2558 * changed afterwards.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002559 * </tr>
2560 * <tr>
2561 * <td>String</td>
2562 * <td>{@link #ACCOUNT_TYPE}</td>
2563 * <td>read/write-once</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002564 * <td>
2565 * <p>
2566 * The type of account to which this row belongs, which when paired with
2567 * {@link #ACCOUNT_NAME} identifies a specific account.
Dave Santorod7bdc182011-06-24 15:39:39 -07002568 * It should be set at the time the raw contact is inserted and never
2569 * changed afterwards.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002570 * </p>
2571 * <p>
2572 * To ensure uniqueness, new account types should be chosen according to the
2573 * Java package naming convention. Thus a Google account is of type "com.google".
2574 * </p>
2575 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002576 * </tr>
2577 * <tr>
2578 * <td>String</td>
Dave Santorod7bdc182011-06-24 15:39:39 -07002579 * <td>{@link #DATA_SET}</td>
2580 * <td>read/write-once</td>
2581 * <td>
2582 * <p>
2583 * The data set within the account that this row belongs to. This allows
2584 * multiple sync adapters for the same account type to distinguish between
2585 * each others' data. The combination of {@link #ACCOUNT_TYPE},
2586 * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data
2587 * that is associated with a single sync adapter.
2588 * </p>
2589 * <p>
2590 * This is empty by default, and is completely optional. It only needs to
2591 * be populated if multiple sync adapters are entering distinct data for
2592 * the same account type and account name.
2593 * </p>
2594 * <p>
2595 * It should be set at the time the raw contact is inserted and never
2596 * changed afterwards.
2597 * </p>
2598 * </td>
2599 * </tr>
2600 * <tr>
2601 * <td>String</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002602 * <td>{@link #SOURCE_ID}</td>
2603 * <td>read/write</td>
2604 * <td>String that uniquely identifies this row to its source account.
2605 * Typically it is set at the time the raw contact is inserted and never
2606 * changed afterwards. The one notable exception is a new raw contact: it
Dave Santorod7bdc182011-06-24 15:39:39 -07002607 * will have an account name and type (and possibly a data set), but no
2608 * source id. This indicates to the sync adapter that a new contact needs
2609 * to be created server-side and its ID stored in the corresponding
2610 * SOURCE_ID field on the phone.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002611 * </td>
2612 * </tr>
2613 * <tr>
2614 * <td>int</td>
2615 * <td>{@link #VERSION}</td>
2616 * <td>read-only</td>
2617 * <td>Version number that is updated whenever this row or its related data
2618 * changes. This field can be used for optimistic locking of a raw contact.
2619 * </td>
2620 * </tr>
2621 * <tr>
2622 * <td>int</td>
2623 * <td>{@link #DIRTY}</td>
2624 * <td>read/write</td>
2625 * <td>Flag indicating that {@link #VERSION} has changed, and this row needs
2626 * to be synchronized by its owning account. The value is set to "1" automatically
2627 * whenever the raw contact changes, unless the URI has the
2628 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified.
2629 * The sync adapter should always supply this query parameter to prevent
2630 * unnecessary synchronization: user changes some data on the server,
2631 * the sync adapter updates the contact on the phone (without the
2632 * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag,
2633 * which triggers a sync to bring the changes to the server.
2634 * </td>
2635 * </tr>
2636 * <tr>
2637 * <td>String</td>
2638 * <td>{@link #SYNC1}</td>
2639 * <td>read/write</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002640 * <td>Generic column provided for arbitrary use by sync adapters.
2641 * The content provider
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002642 * stores this information on behalf of the sync adapter but does not
2643 * interpret it in any way.
2644 * </td>
2645 * </tr>
2646 * <tr>
2647 * <td>String</td>
2648 * <td>{@link #SYNC2}</td>
2649 * <td>read/write</td>
2650 * <td>Generic column for use by sync adapters.
2651 * </td>
2652 * </tr>
2653 * <tr>
2654 * <td>String</td>
2655 * <td>{@link #SYNC3}</td>
2656 * <td>read/write</td>
2657 * <td>Generic column for use by sync adapters.
2658 * </td>
2659 * </tr>
2660 * <tr>
2661 * <td>String</td>
2662 * <td>{@link #SYNC4}</td>
2663 * <td>read/write</td>
2664 * <td>Generic column for use by sync adapters.
2665 * </td>
2666 * </tr>
2667 * </table>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002668 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002669 public static final class RawContacts implements BaseColumns, RawContactsColumns,
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08002670 ContactOptionsColumns, ContactNameColumns, SyncColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002671 /**
2672 * This utility class cannot be instantiated
2673 */
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -07002674 private RawContacts() {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002675 }
2676
2677 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002678 * The content:// style URI for this table, which requests a directory of
2679 * raw contact rows matching the selection criteria.
Evan Millar088b2912009-05-28 15:24:37 -07002680 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07002681 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
Evan Millar088b2912009-05-28 15:24:37 -07002682
2683 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002684 * The MIME type of the results from {@link #CONTENT_URI} when a specific
2685 * ID value is not provided, and multiple raw contacts may be returned.
Evan Millar088b2912009-05-28 15:24:37 -07002686 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002687 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -07002688
2689 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002690 * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI},
2691 * yielding a subdirectory of a single person.
Evan Millar088b2912009-05-28 15:24:37 -07002692 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002693 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -07002694
2695 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002696 * Aggregation mode: aggregate immediately after insert or update operation(s) are complete.
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002697 */
2698 public static final int AGGREGATION_MODE_DEFAULT = 0;
2699
2700 /**
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002701 * Aggregation mode: aggregate at the time the raw contact is inserted/updated.
2702 * @deprecated Aggregation is synchronous, this historic value is a no-op
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002703 */
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002704 @Deprecated
Omari Stephensbc9aa772009-09-08 19:10:53 -07002705 public static final int AGGREGATION_MODE_IMMEDIATE = 1;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002706
2707 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002708 * <p>
2709 * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later.
2710 * Changes to the raw contact will update the associated aggregate contact but will not
2711 * result in any change in how the contact is aggregated. Similar to
2712 * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding
2713 * {@link Contacts} aggregate.
2714 * </p>
2715 * <p>
2716 * This can be used to postpone aggregation until after a series of updates, for better
2717 * performance and/or user experience.
2718 * </p>
2719 * <p>
2720 * Note that changing
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002721 * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002722 * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any
2723 * subsequent
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002724 * change to the raw contact's data will.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002725 * </p>
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002726 */
2727 public static final int AGGREGATION_MODE_SUSPENDED = 2;
2728
2729 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002730 * <p>
2731 * Aggregation mode: never aggregate this raw contact. The raw contact will not
2732 * have a corresponding {@link Contacts} aggregate and therefore will not be included in
2733 * {@link Contacts} query results.
2734 * </p>
2735 * <p>
2736 * For example, this mode can be used for a raw contact that is marked for deletion while
2737 * waiting for the deletion to occur on the server side.
2738 * </p>
2739 *
2740 * @see #AGGREGATION_MODE_SUSPENDED
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002741 */
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002742 public static final int AGGREGATION_MODE_DISABLED = 3;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002743
2744 /**
Jeff Hamiltonf8526982009-09-24 11:34:58 -05002745 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
2746 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
2747 * entry of the given {@link RawContacts} entry.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002748 */
2749 public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) {
2750 // TODO: use a lighter query by joining rawcontacts with contacts in provider
2751 final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY);
2752 final Cursor cursor = resolver.query(dataUri, new String[] {
2753 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
2754 }, null, null, null);
2755
2756 Uri lookupUri = null;
2757 try {
2758 if (cursor != null && cursor.moveToFirst()) {
2759 final long contactId = cursor.getLong(0);
2760 final String lookupKey = cursor.getString(1);
2761 return Contacts.getLookupUri(contactId, lookupKey);
2762 }
2763 } finally {
2764 if (cursor != null) cursor.close();
2765 }
2766 return lookupUri;
2767 }
2768
2769 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002770 * A sub-directory of a single raw contact that contains all of its
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002771 * {@link ContactsContract.Data} rows. To access this directory
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002772 * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI.
Evan Millar088b2912009-05-28 15:24:37 -07002773 */
2774 public static final class Data implements BaseColumns, DataColumns {
2775 /**
2776 * no public constructor since this is a utility class
2777 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002778 private Data() {
2779 }
Evan Millar088b2912009-05-28 15:24:37 -07002780
2781 /**
2782 * The directory twig for this sub-table
2783 */
2784 public static final String CONTENT_DIRECTORY = "data";
2785 }
Fred Quintana5bba6322009-10-05 14:21:12 -07002786
2787 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002788 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002789 * A sub-directory of a single raw contact that contains all of its
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002790 * {@link ContactsContract.Data} rows. To access this directory append
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002791 * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002792 * {@link RawContactsEntity} for a stand-alone table containing the same
2793 * data.
2794 * </p>
2795 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002796 * Entity has two ID fields: {@link #_ID} for the raw contact
2797 * and {@link #DATA_ID} for the data rows.
2798 * Entity always contains at least one row, even if there are no
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002799 * actual data rows. In this case the {@link #DATA_ID} field will be
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002800 * null.
2801 * </p>
2802 * <p>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002803 * Using Entity should be preferred to using two separate queries:
2804 * RawContacts followed by Data. The reason is that Entity reads all
2805 * data for a raw contact in one transaction, so there is no possibility
2806 * of the data changing between the two queries.
Fred Quintana5bba6322009-10-05 14:21:12 -07002807 */
2808 public static final class Entity implements BaseColumns, DataColumns {
2809 /**
2810 * no public constructor since this is a utility class
2811 */
2812 private Entity() {
2813 }
2814
2815 /**
2816 * The directory twig for this sub-table
2817 */
2818 public static final String CONTENT_DIRECTORY = "entity";
2819
2820 /**
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07002821 * The ID of the data row. The value will be null if this raw contact has no
Fred Quintana5bba6322009-10-05 14:21:12 -07002822 * data rows.
2823 * <P>Type: INTEGER</P>
2824 */
2825 public static final String DATA_ID = "data_id";
2826 }
Fred Quintana328c0e72009-12-07 14:52:28 -08002827
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002828 /**
Dave Santorod414f102011-06-20 14:35:06 -07002829 * <p>
2830 * A sub-directory of a single raw contact that contains all of its
2831 * {@link ContactsContract.StreamItems} rows. To access this directory append
2832 * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See
2833 * {@link ContactsContract.StreamItems} for a stand-alone table containing the
2834 * same data.
2835 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07002836 * <p>
2837 * Access to the social stream through this sub-directory requires additional permissions
2838 * beyond the read/write contact permissions required by the provider. Querying for
2839 * social stream data requires android.permission.READ_SOCIAL_STREAM permission, and
2840 * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM
2841 * permission.
2842 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07002843 *
2844 * @deprecated - Do not use. This will not be supported in the future. In the future,
2845 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07002846 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07002847 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07002848 public static final class StreamItems implements BaseColumns, StreamItemsColumns {
2849 /**
2850 * No public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07002851 *
2852 * @deprecated - Do not use. This will not be supported in the future. In the future,
2853 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07002854 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07002855 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07002856 private StreamItems() {
2857 }
2858
2859 /**
2860 * The directory twig for this sub-table
Brian Attwellbdb13c82014-07-16 21:43:54 -07002861 *
2862 * @deprecated - Do not use. This will not be supported in the future. In the future,
2863 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07002864 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07002865 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07002866 public static final String CONTENT_DIRECTORY = "stream_items";
2867 }
2868
2869 /**
Dave Santoroa5282372011-06-29 00:25:16 -07002870 * <p>
2871 * A sub-directory of a single raw contact that represents its primary
2872 * display photo. To access this directory append
2873 * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI.
2874 * The resulting URI represents an image file, and should be interacted with
Dave Santoro040e6b32011-07-15 15:14:08 -07002875 * using ContentResolver.openAssetFileDescriptor.
Dave Santoroa5282372011-06-29 00:25:16 -07002876 * <p>
2877 * <p>
2878 * Note that this sub-directory also supports opening the photo as an asset file
2879 * in write mode. Callers can create or replace the primary photo associated
2880 * with this raw contact by opening the asset file and writing the full-size
2881 * photo contents into it. When the file is closed, the image will be parsed,
2882 * sized down if necessary for the full-size display photo and thumbnail
2883 * dimensions, and stored.
2884 * </p>
2885 * <p>
2886 * Usage example:
2887 * <pre>
2888 * public void writeDisplayPhoto(long rawContactId, byte[] photo) {
2889 * Uri rawContactPhotoUri = Uri.withAppendedPath(
2890 * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
2891 * RawContacts.DisplayPhoto.CONTENT_DIRECTORY);
2892 * try {
2893 * AssetFileDescriptor fd =
Dave Santoro040e6b32011-07-15 15:14:08 -07002894 * getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw");
Dave Santoroa5282372011-06-29 00:25:16 -07002895 * OutputStream os = fd.createOutputStream();
2896 * os.write(photo);
2897 * os.close();
2898 * fd.close();
2899 * } catch (IOException e) {
2900 * // Handle error cases.
2901 * }
2902 * }
2903 * </pre>
2904 * </p>
2905 */
2906 public static final class DisplayPhoto {
2907 /**
2908 * No public constructor since this is a utility class
2909 */
2910 private DisplayPhoto() {
2911 }
2912
2913 /**
2914 * The directory twig for this sub-table
2915 */
2916 public static final String CONTENT_DIRECTORY = "display_photo";
2917 }
2918
2919 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002920 * TODO: javadoc
2921 * @param cursor
2922 * @return
2923 */
Fred Quintana328c0e72009-12-07 14:52:28 -08002924 public static EntityIterator newEntityIterator(Cursor cursor) {
2925 return new EntityIteratorImpl(cursor);
2926 }
2927
2928 private static class EntityIteratorImpl extends CursorEntityIterator {
2929 private static final String[] DATA_KEYS = new String[]{
2930 Data.DATA1,
2931 Data.DATA2,
2932 Data.DATA3,
2933 Data.DATA4,
2934 Data.DATA5,
2935 Data.DATA6,
2936 Data.DATA7,
2937 Data.DATA8,
2938 Data.DATA9,
2939 Data.DATA10,
2940 Data.DATA11,
2941 Data.DATA12,
2942 Data.DATA13,
2943 Data.DATA14,
2944 Data.DATA15,
2945 Data.SYNC1,
2946 Data.SYNC2,
2947 Data.SYNC3,
2948 Data.SYNC4};
2949
2950 public EntityIteratorImpl(Cursor cursor) {
2951 super(cursor);
2952 }
2953
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08002954 @Override
Fred Quintana328c0e72009-12-07 14:52:28 -08002955 public android.content.Entity getEntityAndIncrementCursor(Cursor cursor)
2956 throws RemoteException {
2957 final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID);
2958 final long rawContactId = cursor.getLong(columnRawContactId);
2959
2960 // we expect the cursor is already at the row we need to read from
2961 ContentValues cv = new ContentValues();
2962 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME);
2963 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE);
Katherine Kuan1d837232011-08-24 16:06:06 -07002964 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DATA_SET);
Fred Quintana328c0e72009-12-07 14:52:28 -08002965 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID);
2966 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
2967 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION);
2968 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID);
2969 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1);
2970 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2);
2971 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3);
2972 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4);
2973 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED);
2974 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID);
2975 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED);
Dmitri Plotnikov918007b2010-01-20 12:12:11 -08002976 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, NAME_VERIFIED);
Fred Quintana328c0e72009-12-07 14:52:28 -08002977 android.content.Entity contact = new android.content.Entity(cv);
2978
2979 // read data rows until the contact id changes
2980 do {
2981 if (rawContactId != cursor.getLong(columnRawContactId)) {
2982 break;
2983 }
2984 // add the data to to the contact
2985 cv = new ContentValues();
2986 cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID)));
2987 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
2988 Data.RES_PACKAGE);
2989 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE);
2990 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY);
2991 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv,
2992 Data.IS_SUPER_PRIMARY);
2993 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION);
2994 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
2995 CommonDataKinds.GroupMembership.GROUP_SOURCE_ID);
2996 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
2997 Data.DATA_VERSION);
2998 for (String key : DATA_KEYS) {
2999 final int columnIndex = cursor.getColumnIndexOrThrow(key);
Daniel Lehmann156add92010-07-19 18:01:10 -07003000 switch (cursor.getType(columnIndex)) {
3001 case Cursor.FIELD_TYPE_NULL:
3002 // don't put anything
3003 break;
3004 case Cursor.FIELD_TYPE_INTEGER:
3005 case Cursor.FIELD_TYPE_FLOAT:
3006 case Cursor.FIELD_TYPE_STRING:
Fred Quintana274dc9d2009-12-11 13:17:08 -08003007 cv.put(key, cursor.getString(columnIndex));
Daniel Lehmann156add92010-07-19 18:01:10 -07003008 break;
3009 case Cursor.FIELD_TYPE_BLOB:
Fred Quintana274dc9d2009-12-11 13:17:08 -08003010 cv.put(key, cursor.getBlob(columnIndex));
Daniel Lehmann156add92010-07-19 18:01:10 -07003011 break;
3012 default:
3013 throw new IllegalStateException("Invalid or unhandled data type");
Fred Quintana328c0e72009-12-07 14:52:28 -08003014 }
Fred Quintana328c0e72009-12-07 14:52:28 -08003015 }
3016 contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv);
3017 } while (cursor.moveToNext());
3018
3019 return contact;
3020 }
3021
3022 }
Evan Millar088b2912009-05-28 15:24:37 -07003023 }
3024
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003025 /**
3026 * Social status update columns.
3027 *
3028 * @see StatusUpdates
3029 * @see ContactsContract.Data
3030 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003031 protected interface StatusColumns {
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003032 /**
Dmitri Plotnikova60479d2009-09-27 20:16:31 -07003033 * Contact's latest presence level.
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003034 * <P>Type: INTEGER (one of the values below)</P>
3035 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003036 public static final String PRESENCE = "mode";
3037
3038 /**
3039 * @deprecated use {@link #PRESENCE}
3040 */
3041 @Deprecated
3042 public static final String PRESENCE_STATUS = PRESENCE;
3043
Tom O'Neill244327e22010-01-08 11:11:15 -08003044 /**
3045 * An allowed value of {@link #PRESENCE}.
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003046 */
3047 int OFFLINE = 0;
Tom O'Neill244327e22010-01-08 11:11:15 -08003048
3049 /**
3050 * An allowed value of {@link #PRESENCE}.
3051 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003052 int INVISIBLE = 1;
Tom O'Neill244327e22010-01-08 11:11:15 -08003053
3054 /**
3055 * An allowed value of {@link #PRESENCE}.
3056 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003057 int AWAY = 2;
Tom O'Neill244327e22010-01-08 11:11:15 -08003058
3059 /**
3060 * An allowed value of {@link #PRESENCE}.
3061 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003062 int IDLE = 3;
Tom O'Neill244327e22010-01-08 11:11:15 -08003063
3064 /**
3065 * An allowed value of {@link #PRESENCE}.
3066 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003067 int DO_NOT_DISTURB = 4;
Tom O'Neill244327e22010-01-08 11:11:15 -08003068
3069 /**
3070 * An allowed value of {@link #PRESENCE}.
3071 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003072 int AVAILABLE = 5;
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003073
3074 /**
3075 * Contact latest status update.
3076 * <p>Type: TEXT</p>
3077 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003078 public static final String STATUS = "status";
3079
3080 /**
3081 * @deprecated use {@link #STATUS}
3082 */
Tom O'Neill244327e22010-01-08 11:11:15 -08003083 @Deprecated
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003084 public static final String PRESENCE_CUSTOM_STATUS = STATUS;
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003085
3086 /**
3087 * The absolute time in milliseconds when the latest status was inserted/updated.
3088 * <p>Type: NUMBER</p>
3089 */
3090 public static final String STATUS_TIMESTAMP = "status_ts";
3091
3092 /**
3093 * The package containing resources for this status: label and icon.
Dave Santoro040e6b32011-07-15 15:14:08 -07003094 * <p>Type: TEXT</p>
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003095 */
3096 public static final String STATUS_RES_PACKAGE = "status_res_package";
3097
3098 /**
3099 * The resource ID of the label describing the source of the status update, e.g. "Google
3100 * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
3101 * <p>Type: NUMBER</p>
3102 */
3103 public static final String STATUS_LABEL = "status_label";
3104
3105 /**
3106 * The resource ID of the icon for the source of the status update.
3107 * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
3108 * <p>Type: NUMBER</p>
3109 */
3110 public static final String STATUS_ICON = "status_icon";
Vasu Nori5b31498ba12010-07-12 15:13:37 -07003111
3112 /**
3113 * Contact's audio/video chat capability level.
3114 * <P>Type: INTEGER (one of the values below)</P>
3115 */
3116 public static final String CHAT_CAPABILITY = "chat_capability";
3117
3118 /**
Daniel Lehmannb3327472010-08-13 15:16:11 -07003119 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone
3120 * and speaker)
3121 */
3122 public static final int CAPABILITY_HAS_VOICE = 1;
3123
3124 /**
3125 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device can
Vasu Nori5b31498ba12010-07-12 15:13:37 -07003126 * display a video feed.
3127 */
Daniel Lehmannb3327472010-08-13 15:16:11 -07003128 public static final int CAPABILITY_HAS_VIDEO = 2;
Vasu Nori5b31498ba12010-07-12 15:13:37 -07003129
3130 /**
Daniel Lehmannb3327472010-08-13 15:16:11 -07003131 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device has a
Vasu Nori5b31498ba12010-07-12 15:13:37 -07003132 * camera that can be used for video chat (e.g. a front-facing camera on a phone).
3133 */
3134 public static final int CAPABILITY_HAS_CAMERA = 4;
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003135 }
3136
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003137 /**
Dave Santorod414f102011-06-20 14:35:06 -07003138 * <p>
3139 * Constants for the stream_items table, which contains social stream updates from
3140 * the user's contact list.
3141 * </p>
3142 * <p>
3143 * Only a certain number of stream items will ever be stored under a given raw contact.
3144 * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to
3145 * determine this limit, and should restrict the number of items inserted in any given
3146 * transaction correspondingly. Insertion of more items beyond the limit will
3147 * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}.
3148 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07003149 * <p>
3150 * Access to the social stream through these URIs requires additional permissions beyond the
3151 * read/write contact permissions required by the provider. Querying for social stream data
3152 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social
3153 * stream items requires android.permission.WRITE_SOCIAL_STREAM permission.
3154 * </p>
Makoto Onuki46891a82012-04-26 12:46:47 -07003155 * <h3>Account check</h3>
3156 * <p>
3157 * The content URIs to the insert, update and delete operations are required to have the account
3158 * information matching that of the owning raw contact as query parameters, namely
3159 * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
3160 * {@link RawContacts#DATA_SET} isn't required.
3161 * </p>
Dave Santorod414f102011-06-20 14:35:06 -07003162 * <h3>Operations</h3>
3163 * <dl>
3164 * <dt><b>Insert</b></dt>
3165 * <dd>
3166 * <p>Social stream updates are always associated with a raw contact. There are a couple
3167 * of ways to insert these entries.
3168 * <dl>
3169 * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt>
3170 * <dd>
3171 * <pre>
3172 * ContentValues values = new ContentValues();
3173 * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
3174 * values.put(StreamItems.TIMESTAMP, timestamp);
Dave Santoro040e6b32011-07-15 15:14:08 -07003175 * values.put(StreamItems.COMMENTS, "3 people reshared this");
Makoto Onuki46891a82012-04-26 12:46:47 -07003176 * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon();
3177 * ContentUris.appendId(builder, rawContactId);
3178 * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY);
3179 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3180 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3181 * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003182 * long streamItemId = ContentUris.parseId(streamItemUri);
3183 * </pre>
3184 * </dd>
Scott Main45107052011-09-26 21:52:05 -07003185 * <dt>Via {@link StreamItems#CONTENT_URI}:</dt>
Dave Santorod414f102011-06-20 14:35:06 -07003186 * <dd>
Scott Main45107052011-09-26 21:52:05 -07003187 *<pre>
Dave Santorod414f102011-06-20 14:35:06 -07003188 * ContentValues values = new ContentValues();
3189 * values.put(StreamItems.RAW_CONTACT_ID, rawContactId);
3190 * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
3191 * values.put(StreamItems.TIMESTAMP, timestamp);
Dave Santoro040e6b32011-07-15 15:14:08 -07003192 * values.put(StreamItems.COMMENTS, "3 people reshared this");
Makoto Onuki46891a82012-04-26 12:46:47 -07003193 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3194 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3195 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3196 * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003197 * long streamItemId = ContentUris.parseId(streamItemUri);
Scott Main45107052011-09-26 21:52:05 -07003198 *</pre>
Dave Santorod414f102011-06-20 14:35:06 -07003199 * </dd>
3200 * </dl>
3201 * </dd>
3202 * </p>
3203 * <p>
3204 * Once a {@link StreamItems} entry has been inserted, photos associated with that
3205 * social update can be inserted. For example, after one of the insertions above,
3206 * photos could be added to the stream item in one of the following ways:
3207 * <dl>
3208 * <dt>Via a URI including the stream item ID:</dt>
3209 * <dd>
3210 * <pre>
3211 * values.clear();
3212 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003213 * values.put(StreamItemPhotos.PHOTO, photoData);
Dave Santorod414f102011-06-20 14:35:06 -07003214 * getContentResolver().insert(Uri.withAppendedPath(
3215 * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId),
3216 * StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values);
3217 * </pre>
3218 * </dd>
Scott Main45107052011-09-26 21:52:05 -07003219 * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt>
Dave Santorod414f102011-06-20 14:35:06 -07003220 * <dd>
3221 * <pre>
3222 * values.clear();
3223 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
3224 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003225 * values.put(StreamItemPhotos.PHOTO, photoData);
Dave Santorod414f102011-06-20 14:35:06 -07003226 * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values);
3227 * </pre>
Scott Main45107052011-09-26 21:52:05 -07003228 * <p>Note that this latter form allows the insertion of a stream item and its
Dave Santorod414f102011-06-20 14:35:06 -07003229 * photos in a single transaction, by using {@link ContentProviderOperation} with
3230 * back references to populate the stream item ID in the {@link ContentValues}.
3231 * </dd>
3232 * </dl>
3233 * </p>
3234 * </dd>
3235 * <dt><b>Update</b></dt>
3236 * <dd>Updates can be performed by appending the stream item ID to the
3237 * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were
3238 * created by the calling package can be updated.</dd>
3239 * <dt><b>Delete</b></dt>
3240 * <dd>Deletes can be performed by appending the stream item ID to the
3241 * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were
3242 * created by the calling package can be deleted.</dd>
3243 * <dt><b>Query</b></dt>
3244 * <dl>
3245 * <dt>Finding all social stream updates for a given contact</dt>
3246 * <dd>By Contact ID:
3247 * <pre>
3248 * Cursor c = getContentResolver().query(Uri.withAppendedPath(
3249 * ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId),
3250 * Contacts.StreamItems.CONTENT_DIRECTORY),
3251 * null, null, null, null);
3252 * </pre>
3253 * </dd>
3254 * <dd>By lookup key:
3255 * <pre>
3256 * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon()
3257 * .appendPath(lookupKey)
3258 * .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(),
3259 * null, null, null, null);
3260 * </pre>
3261 * </dd>
3262 * <dt>Finding all social stream updates for a given raw contact</dt>
3263 * <dd>
3264 * <pre>
3265 * Cursor c = getContentResolver().query(Uri.withAppendedPath(
3266 * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
3267 * RawContacts.StreamItems.CONTENT_DIRECTORY)),
3268 * null, null, null, null);
3269 * </pre>
3270 * </dd>
3271 * <dt>Querying for a specific stream item by ID</dt>
3272 * <dd>
3273 * <pre>
3274 * Cursor c = getContentResolver().query(ContentUris.withAppendedId(
3275 * StreamItems.CONTENT_URI, streamItemId),
3276 * null, null, null, null);
3277 * </pre>
3278 * </dd>
3279 * </dl>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003280 *
3281 * @deprecated - Do not use. This will not be supported in the future. In the future,
3282 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003283 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003284 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003285 public static final class StreamItems implements BaseColumns, StreamItemsColumns {
3286 /**
3287 * This utility class cannot be instantiated
Brian Attwellbdb13c82014-07-16 21:43:54 -07003288 *
3289 * @deprecated - Do not use. This will not be supported in the future. In the future,
3290 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003291 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003292 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003293 private StreamItems() {
3294 }
3295
3296 /**
3297 * The content:// style URI for this table, which handles social network stream
3298 * updates for the user's contacts.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003299 *
3300 * @deprecated - Do not use. This will not be supported in the future. In the future,
3301 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003302 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003303 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003304 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items");
3305
3306 /**
3307 * <p>
3308 * A content:// style URI for the photos stored in a sub-table underneath
3309 * stream items. This is only used for inserts, and updates - queries and deletes
3310 * for photos should be performed by appending
3311 * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a
3312 * specific stream item.
3313 * </p>
3314 * <p>
3315 * When using this URI, the stream item ID for the photo(s) must be identified
3316 * in the {@link ContentValues} passed in.
3317 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003318 *
3319 * @deprecated - Do not use. This will not be supported in the future. In the future,
3320 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003321 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003322 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003323 public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo");
3324
3325 /**
3326 * This URI allows the caller to query for the maximum number of stream items
Dave Santoro040e6b32011-07-15 15:14:08 -07003327 * that will be stored under any single raw contact.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003328 *
3329 * @deprecated - Do not use. This will not be supported in the future. In the future,
3330 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003331 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003332 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003333 public static final Uri CONTENT_LIMIT_URI =
3334 Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit");
3335
3336 /**
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003337 * The MIME type of a directory of stream items.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003338 *
3339 * @deprecated - Do not use. This will not be supported in the future. In the future,
3340 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003341 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003342 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003343 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item";
3344
3345 /**
3346 * The MIME type of a single stream item.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003347 *
3348 * @deprecated - Do not use. This will not be supported in the future. In the future,
3349 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003350 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003351 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003352 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/stream_item";
3353
3354 /**
Dave Santorod414f102011-06-20 14:35:06 -07003355 * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will
3356 * contain this column, with the value indicating the maximum number of
3357 * stream items that will be stored under any single raw contact.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003358 *
3359 * @deprecated - Do not use. This will not be supported in the future. In the future,
3360 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003361 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003362 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003363 public static final String MAX_ITEMS = "max_items";
3364
3365 /**
Dave Santorod414f102011-06-20 14:35:06 -07003366 * <p>
3367 * A sub-directory of a single stream item entry that contains all of its
3368 * photo rows. To access this
3369 * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to
3370 * an individual stream item URI.
3371 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07003372 * <p>
3373 * Access to social stream photos requires additional permissions beyond the read/write
3374 * contact permissions required by the provider. Querying for social stream photos
3375 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating
3376 * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.
3377 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003378 *
3379 * @deprecated - Do not use. This will not be supported in the future. In the future,
3380 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003381 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003382 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003383 public static final class StreamItemPhotos
3384 implements BaseColumns, StreamItemPhotosColumns {
3385 /**
3386 * No public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07003387 *
3388 * @deprecated - Do not use. This will not be supported in the future. In the future,
3389 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003390 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003391 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003392 private StreamItemPhotos() {
3393 }
3394
3395 /**
3396 * The directory twig for this sub-table
Brian Attwellbdb13c82014-07-16 21:43:54 -07003397 *
3398 * @deprecated - Do not use. This will not be supported in the future. In the future,
3399 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003400 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003401 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003402 public static final String CONTENT_DIRECTORY = "photo";
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003403
3404 /**
3405 * The MIME type of a directory of stream item photos.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003406 *
3407 * @deprecated - Do not use. This will not be supported in the future. In the future,
3408 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003409 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003410 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003411 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item_photo";
3412
3413 /**
3414 * The MIME type of a single stream item photo.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003415 *
3416 * @deprecated - Do not use. This will not be supported in the future. In the future,
3417 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003418 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003419 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003420 public static final String CONTENT_ITEM_TYPE
3421 = "vnd.android.cursor.item/stream_item_photo";
Dave Santorod414f102011-06-20 14:35:06 -07003422 }
3423 }
3424
3425 /**
3426 * Columns in the StreamItems table.
3427 *
3428 * @see ContactsContract.StreamItems
Brian Attwellbdb13c82014-07-16 21:43:54 -07003429 * @deprecated - Do not use. This will not be supported in the future. In the future,
3430 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003431 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003432 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003433 protected interface StreamItemsColumns {
3434 /**
Daniel Lehmanne8aae092011-08-24 16:41:00 -07003435 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID}
3436 * that this stream item belongs to.
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003437 *
3438 * <p>Type: INTEGER</p>
3439 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003440 *
3441 * @deprecated - Do not use. This will not be supported in the future. In the future,
3442 * cursors returned from related queries will be empty.
Daniel Lehmanne8aae092011-08-24 16:41:00 -07003443 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003444 @Deprecated
Daniel Lehmanne8aae092011-08-24 16:41:00 -07003445 public static final String CONTACT_ID = "contact_id";
3446
3447 /**
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003448 * A reference to the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY}
3449 * that this stream item belongs to.
3450 *
3451 * <p>Type: TEXT</p>
3452 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003453 *
3454 * @deprecated - Do not use. This will not be supported in the future. In the future,
3455 * cursors returned from related queries will be empty.
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003456 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003457 @Deprecated
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003458 public static final String CONTACT_LOOKUP_KEY = "contact_lookup";
3459
3460 /**
Dave Santorod414f102011-06-20 14:35:06 -07003461 * A reference to the {@link RawContacts#_ID}
3462 * that this stream item belongs to.
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003463 * <p>Type: INTEGER</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003464 *
3465 * @deprecated - Do not use. This will not be supported in the future. In the future,
3466 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003467 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003468 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003469 public static final String RAW_CONTACT_ID = "raw_contact_id";
3470
3471 /**
3472 * The package name to use when creating {@link Resources} objects for
3473 * this stream item. This value is only designed for use when building
3474 * user interfaces, and should not be used to infer the owner.
Dave Santoro040e6b32011-07-15 15:14:08 -07003475 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003476 *
3477 * @deprecated - Do not use. This will not be supported in the future. In the future,
3478 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003479 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003480 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003481 public static final String RES_PACKAGE = "res_package";
3482
3483 /**
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003484 * The account type to which the raw_contact of this item is associated. See
3485 * {@link RawContacts#ACCOUNT_TYPE}
3486 *
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003487 * <p>Type: TEXT</p>
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003488 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003489 *
3490 * @deprecated - Do not use. This will not be supported in the future. In the future,
3491 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003492 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003493 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003494 public static final String ACCOUNT_TYPE = "account_type";
3495
3496 /**
3497 * The account name to which the raw_contact of this item is associated. See
3498 * {@link RawContacts#ACCOUNT_NAME}
3499 *
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003500 * <p>Type: TEXT</p>
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003501 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003502 *
3503 * @deprecated - Do not use. This will not be supported in the future. In the future,
3504 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003505 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003506 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003507 public static final String ACCOUNT_NAME = "account_name";
3508
3509 /**
3510 * The data set within the account that the raw_contact of this row belongs to. This allows
3511 * multiple sync adapters for the same account type to distinguish between
3512 * each others' data.
3513 * {@link RawContacts#DATA_SET}
3514 *
3515 * <P>Type: TEXT</P>
3516 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003517 *
3518 * @deprecated - Do not use. This will not be supported in the future. In the future,
3519 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003520 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003521 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003522 public static final String DATA_SET = "data_set";
3523
3524 /**
3525 * The source_id of the raw_contact that this row belongs to.
3526 * {@link RawContacts#SOURCE_ID}
3527 *
3528 * <P>Type: TEXT</P>
3529 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003530 *
3531 * @deprecated - Do not use. This will not be supported in the future. In the future,
3532 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003533 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003534 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003535 public static final String RAW_CONTACT_SOURCE_ID = "raw_contact_source_id";
3536
3537 /**
3538 * The resource name of the icon for the source of the stream item.
3539 * This resource should be scoped by the {@link #RES_PACKAGE}. As this can only reference
3540 * drawables, the "@drawable/" prefix must be omitted.
3541 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003542 *
3543 * @deprecated - Do not use. This will not be supported in the future. In the future,
3544 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003545 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003546 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003547 public static final String RES_ICON = "icon";
3548
3549 /**
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003550 * The resource name of the label describing the source of the status update, e.g. "Google
3551 * Talk". This resource should be scoped by the {@link #RES_PACKAGE}. As this can only
3552 * reference strings, the "@string/" prefix must be omitted.
3553 * <p>Type: TEXT</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003554 *
3555 * @deprecated - Do not use. This will not be supported in the future. In the future,
3556 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003557 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003558 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003559 public static final String RES_LABEL = "label";
3560
3561 /**
3562 * <P>
3563 * The main textual contents of the item. Typically this is content
3564 * that was posted by the source of this stream item, but it can also
3565 * be a textual representation of an action (e.g. ”Checked in at Joe's”).
3566 * This text is displayed to the user and allows formatting and embedded
3567 * resource images via HTML (as parseable via
3568 * {@link android.text.Html#fromHtml}).
3569 * </P>
3570 * <P>
3571 * Long content may be truncated and/or ellipsized - the exact behavior
3572 * is unspecified, but it should not break tags.
3573 * </P>
3574 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003575 *
3576 * @deprecated - Do not use. This will not be supported in the future. In the future,
3577 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003578 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003579 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003580 public static final String TEXT = "text";
3581
3582 /**
3583 * The absolute time (milliseconds since epoch) when this stream item was
3584 * inserted/updated.
3585 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003586 *
3587 * @deprecated - Do not use. This will not be supported in the future. In the future,
3588 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003589 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003590 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003591 public static final String TIMESTAMP = "timestamp";
3592
3593 /**
3594 * <P>
3595 * Summary information about the stream item, for example to indicate how
3596 * many people have reshared it, how many have liked it, how many thumbs
3597 * up and/or thumbs down it has, what the original source was, etc.
3598 * </P>
3599 * <P>
3600 * This text is displayed to the user and allows simple formatting via
3601 * HTML, in the same manner as {@link #TEXT} allows.
3602 * </P>
3603 * <P>
3604 * Long content may be truncated and/or ellipsized - the exact behavior
3605 * is unspecified, but it should not break tags.
3606 * </P>
3607 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003608 *
3609 * @deprecated - Do not use. This will not be supported in the future. In the future,
3610 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003611 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003612 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003613 public static final String COMMENTS = "comments";
3614
Brian Attwellbdb13c82014-07-16 21:43:54 -07003615 /**
3616 * Generic column for use by sync adapters.
3617 *
3618 * @deprecated - Do not use. This will not be supported in the future. In the future,
3619 * cursors returned from related queries will be empty.
3620 */
3621 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003622 public static final String SYNC1 = "stream_item_sync1";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003623 /**
3624 * Generic column for use by sync adapters.
3625 *
3626 * @deprecated - Do not use. This will not be supported in the future. In the future,
3627 * cursors returned from related queries will be empty.
3628 */
3629 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003630 public static final String SYNC2 = "stream_item_sync2";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003631 /**
3632 * Generic column for use by sync adapters.
3633 *
3634 * @deprecated - Do not use. This will not be supported in the future. In the future,
3635 * cursors returned from related queries will be empty.
3636 */
3637 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003638 public static final String SYNC3 = "stream_item_sync3";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003639 /**
3640 * Generic column for use by sync adapters.
3641 *
3642 * @deprecated - Do not use. This will not be supported in the future. In the future,
3643 * cursors returned from related queries will be empty.
3644 */
3645 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003646 public static final String SYNC4 = "stream_item_sync4";
Dave Santorod414f102011-06-20 14:35:06 -07003647 }
3648
3649 /**
3650 * <p>
3651 * Constants for the stream_item_photos table, which contains photos associated with
3652 * social stream updates.
3653 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07003654 * <p>
3655 * Access to social stream photos requires additional permissions beyond the read/write
3656 * contact permissions required by the provider. Querying for social stream photos
3657 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating
3658 * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.
3659 * </p>
Makoto Onuki46891a82012-04-26 12:46:47 -07003660 * <h3>Account check</h3>
3661 * <p>
3662 * The content URIs to the insert, update and delete operations are required to have the account
3663 * information matching that of the owning raw contact as query parameters, namely
3664 * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
3665 * {@link RawContacts#DATA_SET} isn't required.
3666 * </p>
Dave Santorod414f102011-06-20 14:35:06 -07003667 * <h3>Operations</h3>
3668 * <dl>
3669 * <dt><b>Insert</b></dt>
3670 * <dd>
3671 * <p>Social stream photo entries are associated with a social stream item. Photos
3672 * can be inserted into a social stream item in a couple of ways:
3673 * <dl>
3674 * <dt>
3675 * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
3676 * stream item:
3677 * </dt>
3678 * <dd>
3679 * <pre>
3680 * ContentValues values = new ContentValues();
3681 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003682 * values.put(StreamItemPhotos.PHOTO, photoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003683 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3684 * ContentUris.appendId(builder, streamItemId);
3685 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3686 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3687 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3688 * Uri photoUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003689 * long photoId = ContentUris.parseId(photoUri);
3690 * </pre>
3691 * </dd>
3692 * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
3693 * <dd>
3694 * <pre>
3695 * ContentValues values = new ContentValues();
3696 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
3697 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003698 * values.put(StreamItemPhotos.PHOTO, photoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003699 * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
3700 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3701 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3702 * Uri photoUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003703 * long photoId = ContentUris.parseId(photoUri);
3704 * </pre>
3705 * </dd>
3706 * </dl>
3707 * </p>
3708 * </dd>
3709 * <dt><b>Update</b></dt>
3710 * <dd>
3711 * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry,
3712 * identified by both the stream item ID it belongs to and the stream item photo ID.
3713 * This can be specified in two ways.
3714 * <dl>
3715 * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
3716 * stream item:
3717 * </dt>
3718 * <dd>
3719 * <pre>
3720 * ContentValues values = new ContentValues();
Dave Santoro040e6b32011-07-15 15:14:08 -07003721 * values.put(StreamItemPhotos.PHOTO, newPhotoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003722 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3723 * ContentUris.appendId(builder, streamItemId);
3724 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3725 * ContentUris.appendId(builder, streamItemPhotoId);
3726 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3727 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3728 * getContentResolver().update(builder.build(), values, null, null);
Dave Santorod414f102011-06-20 14:35:06 -07003729 * </pre>
3730 * </dd>
3731 * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
3732 * <dd>
3733 * <pre>
3734 * ContentValues values = new ContentValues();
3735 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
Dave Santoro040e6b32011-07-15 15:14:08 -07003736 * values.put(StreamItemPhotos.PHOTO, newPhotoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003737 * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
3738 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3739 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3740 * getContentResolver().update(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003741 * </pre>
3742 * </dd>
3743 * </dl>
3744 * </p>
3745 * </dd>
3746 * <dt><b>Delete</b></dt>
3747 * <dd>Deletes can be made against either a specific photo item in a stream item, or
3748 * against all or a selected subset of photo items under a stream item.
3749 * For example:
3750 * <dl>
3751 * <dt>Deleting a single photo via the
3752 * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item:
3753 * </dt>
3754 * <dd>
3755 * <pre>
Makoto Onuki46891a82012-04-26 12:46:47 -07003756 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3757 * ContentUris.appendId(builder, streamItemId);
3758 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3759 * ContentUris.appendId(builder, streamItemPhotoId);
3760 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3761 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3762 * getContentResolver().delete(builder.build(), null, null);
Dave Santorod414f102011-06-20 14:35:06 -07003763 * </pre>
3764 * </dd>
3765 * <dt>Deleting all photos under a stream item</dt>
3766 * <dd>
3767 * <pre>
Makoto Onuki46891a82012-04-26 12:46:47 -07003768 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3769 * ContentUris.appendId(builder, streamItemId);
3770 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3771 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3772 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3773 * getContentResolver().delete(builder.build(), null, null);
Dave Santorod414f102011-06-20 14:35:06 -07003774 * </pre>
3775 * </dd>
3776 * </dl>
3777 * </dd>
3778 * <dt><b>Query</b></dt>
3779 * <dl>
3780 * <dt>Querying for a specific photo in a stream item</dt>
3781 * <dd>
3782 * <pre>
3783 * Cursor c = getContentResolver().query(
3784 * ContentUris.withAppendedId(
3785 * Uri.withAppendedPath(
3786 * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
3787 * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
3788 * streamItemPhotoId), null, null, null, null);
3789 * </pre>
3790 * </dd>
3791 * <dt>Querying for all photos in a stream item</dt>
3792 * <dd>
3793 * <pre>
3794 * Cursor c = getContentResolver().query(
3795 * Uri.withAppendedPath(
3796 * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
3797 * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
3798 * null, null, null, StreamItemPhotos.SORT_INDEX);
3799 * </pre>
3800 * </dl>
Dave Santoro040e6b32011-07-15 15:14:08 -07003801 * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a
3802 * {@link StreamItemPhotos#PHOTO_URI}. The {@link StreamItemPhotos#PHOTO_FILE_ID}
3803 * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to
3804 * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as
3805 * an asset file, as follows:
3806 * <pre>
3807 * public InputStream openDisplayPhoto(String photoUri) {
3808 * try {
3809 * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r");
3810 * return fd.createInputStream();
3811 * } catch (IOException e) {
3812 * return null;
3813 * }
3814 * }
3815 * <pre>
Dave Santorod414f102011-06-20 14:35:06 -07003816 * </dd>
3817 * </dl>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003818 *
3819 * @deprecated - Do not use. This will not be supported in the future. In the future,
3820 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003821 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003822 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003823 public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns {
3824 /**
3825 * No public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07003826 *
3827 * @deprecated - Do not use. This will not be supported in the future. In the future,
3828 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003829 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003830 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003831 private StreamItemPhotos() {
3832 }
Dave Santoro040e6b32011-07-15 15:14:08 -07003833
3834 /**
3835 * <p>
3836 * The binary representation of the photo. Any size photo can be inserted;
3837 * the provider will resize it appropriately for storage and display.
3838 * </p>
3839 * <p>
3840 * This is only intended for use when inserting or updating a stream item photo.
3841 * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI}
3842 * as an asset file.
3843 * </p>
3844 * <P>Type: BLOB</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003845 *
3846 * @deprecated - Do not use. This will not be supported in the future. In the future,
3847 * cursors returned from related queries will be empty.
Dave Santoro040e6b32011-07-15 15:14:08 -07003848 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003849 @Deprecated
Dave Santoro040e6b32011-07-15 15:14:08 -07003850 public static final String PHOTO = "photo";
Dave Santorod414f102011-06-20 14:35:06 -07003851 }
3852
3853 /**
3854 * Columns in the StreamItemPhotos table.
3855 *
3856 * @see ContactsContract.StreamItemPhotos
Brian Attwellbdb13c82014-07-16 21:43:54 -07003857 * @deprecated - Do not use. This will not be supported in the future. In the future,
3858 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003859 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003860 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003861 protected interface StreamItemPhotosColumns {
3862 /**
3863 * A reference to the {@link StreamItems#_ID} this photo is associated with.
3864 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003865 *
3866 * @deprecated - Do not use. This will not be supported in the future. In the future,
3867 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003868 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003869 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003870 public static final String STREAM_ITEM_ID = "stream_item_id";
3871
3872 /**
3873 * An integer to use for sort order for photos in the stream item. If not
3874 * specified, the {@link StreamItemPhotos#_ID} will be used for sorting.
3875 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003876 *
3877 * @deprecated - Do not use. This will not be supported in the future. In the future,
3878 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003879 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003880 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003881 public static final String SORT_INDEX = "sort_index";
3882
3883 /**
Dave Santoro040e6b32011-07-15 15:14:08 -07003884 * Photo file ID for the photo.
3885 * See {@link ContactsContract.DisplayPhoto}.
3886 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003887 *
3888 * @deprecated - Do not use. This will not be supported in the future. In the future,
3889 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003890 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003891 @Deprecated
Dave Santoro040e6b32011-07-15 15:14:08 -07003892 public static final String PHOTO_FILE_ID = "photo_file_id";
3893
3894 /**
3895 * URI for retrieving the photo content, automatically populated. Callers
3896 * may retrieve the photo content by opening this URI as an asset file.
3897 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003898 *
3899 * @deprecated - Do not use. This will not be supported in the future. In the future,
3900 * cursors returned from related queries will be empty.
Dave Santoro040e6b32011-07-15 15:14:08 -07003901 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003902 @Deprecated
Dave Santoro040e6b32011-07-15 15:14:08 -07003903 public static final String PHOTO_URI = "photo_uri";
Dave Santorod414f102011-06-20 14:35:06 -07003904
Brian Attwellbdb13c82014-07-16 21:43:54 -07003905 /**
3906 * Generic column for use by sync adapters.
3907 *
3908 * @deprecated - Do not use. This will not be supported in the future. In the future,
3909 * cursors returned from related queries will be empty.
3910 */
3911 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003912 public static final String SYNC1 = "stream_item_photo_sync1";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003913 /**
3914 * Generic column for use by sync adapters.
3915 *
3916 * @deprecated - Do not use. This will not be supported in the future. In the future,
3917 * cursors returned from related queries will be empty.
3918 */
3919 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003920 public static final String SYNC2 = "stream_item_photo_sync2";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003921 /**
3922 * Generic column for use by sync adapters.
3923 *
3924 * @deprecated - Do not use. This will not be supported in the future. In the future,
3925 * cursors returned from related queries will be empty.
3926 */
3927 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003928 public static final String SYNC3 = "stream_item_photo_sync3";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003929 /**
3930 * Generic column for use by sync adapters.
3931 *
3932 * @deprecated - Do not use. This will not be supported in the future. In the future,
3933 * cursors returned from related queries will be empty.
3934 */
3935 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003936 public static final String SYNC4 = "stream_item_photo_sync4";
Dave Santorod414f102011-06-20 14:35:06 -07003937 }
3938
3939 /**
Dave Santoroa5282372011-06-29 00:25:16 -07003940 * <p>
3941 * Constants for the photo files table, which tracks metadata for hi-res photos
3942 * stored in the file system.
3943 * </p>
3944 *
3945 * @hide
3946 */
3947 public static final class PhotoFiles implements BaseColumns, PhotoFilesColumns {
3948 /**
3949 * No public constructor since this is a utility class
3950 */
3951 private PhotoFiles() {
3952 }
3953 }
3954
3955 /**
3956 * Columns in the PhotoFiles table.
3957 *
3958 * @see ContactsContract.PhotoFiles
3959 *
3960 * @hide
3961 */
3962 protected interface PhotoFilesColumns {
3963
3964 /**
3965 * The height, in pixels, of the photo this entry is associated with.
3966 * <P>Type: NUMBER</P>
3967 */
3968 public static final String HEIGHT = "height";
3969
3970 /**
3971 * The width, in pixels, of the photo this entry is associated with.
3972 * <P>Type: NUMBER</P>
3973 */
3974 public static final String WIDTH = "width";
3975
3976 /**
3977 * The size, in bytes, of the photo stored on disk.
3978 * <P>Type: NUMBER</P>
3979 */
3980 public static final String FILESIZE = "filesize";
3981 }
3982
3983 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003984 * Columns in the Data table.
3985 *
3986 * @see ContactsContract.Data
3987 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07003988 protected interface DataColumns {
Evan Millar088b2912009-05-28 15:24:37 -07003989 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07003990 * The package name to use when creating {@link Resources} objects for
3991 * this data row. This value is only designed for use when building user
3992 * interfaces, and should not be used to infer the owner.
3993 */
3994 public static final String RES_PACKAGE = "res_package";
3995
3996 /**
3997 * The MIME type of the item represented by this row.
Evan Millar088b2912009-05-28 15:24:37 -07003998 */
3999 public static final String MIMETYPE = "mimetype";
4000
4001 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07004002 * A reference to the {@link RawContacts#_ID}
Dmitri Plotnikov56927772009-05-28 17:23:39 -07004003 * that this data belongs to.
Evan Millar088b2912009-05-28 15:24:37 -07004004 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07004005 public static final String RAW_CONTACT_ID = "raw_contact_id";
4006
Evan Millarab5742d2009-06-02 16:21:45 -07004007 /**
Tom O'Neill244327e22010-01-08 11:11:15 -08004008 * Whether this is the primary entry of its kind for the raw contact it belongs to.
Evan Millarab5742d2009-06-02 16:21:45 -07004009 * <P>Type: INTEGER (if set, non-0 means true)</P>
4010 */
4011 public static final String IS_PRIMARY = "is_primary";
4012
4013 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07004014 * Whether this is the primary entry of its kind for the aggregate
4015 * contact it belongs to. Any data record that is "super primary" must
4016 * also be "primary".
Evan Millarab5742d2009-06-02 16:21:45 -07004017 * <P>Type: INTEGER (if set, non-0 means true)</P>
4018 */
4019 public static final String IS_SUPER_PRIMARY = "is_super_primary";
4020
Jeff Sharkey28b68e52009-06-10 15:26:58 -07004021 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -07004022 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
4023 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
4024 * <P>Type: INTEGER</P>
4025 */
4026 public static final String IS_READ_ONLY = "is_read_only";
4027
4028 /**
Fred Quintanac933fb62009-06-11 12:14:40 -07004029 * The version of this data record. This is a read-only value. The data column is
4030 * guaranteed to not change without the version going up. This value is monotonically
4031 * increasing.
4032 * <P>Type: INTEGER</P>
4033 */
4034 public static final String DATA_VERSION = "data_version";
4035
Evan Millar088b2912009-05-28 15:24:37 -07004036 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4037 public static final String DATA1 = "data1";
4038 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4039 public static final String DATA2 = "data2";
4040 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4041 public static final String DATA3 = "data3";
4042 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4043 public static final String DATA4 = "data4";
4044 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4045 public static final String DATA5 = "data5";
4046 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4047 public static final String DATA6 = "data6";
4048 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4049 public static final String DATA7 = "data7";
4050 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4051 public static final String DATA8 = "data8";
4052 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4053 public static final String DATA9 = "data9";
4054 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4055 public static final String DATA10 = "data10";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004056 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4057 public static final String DATA11 = "data11";
4058 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4059 public static final String DATA12 = "data12";
4060 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4061 public static final String DATA13 = "data13";
4062 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4063 public static final String DATA14 = "data14";
Tom O'Neill244327e22010-01-08 11:11:15 -08004064 /**
4065 * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention,
4066 * this field is used to store BLOBs (binary data).
4067 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004068 public static final String DATA15 = "data15";
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -07004069
Fred Quintana8851e162009-08-05 21:06:45 -07004070 /** Generic column for use by sync adapters. */
4071 public static final String SYNC1 = "data_sync1";
4072 /** Generic column for use by sync adapters. */
4073 public static final String SYNC2 = "data_sync2";
4074 /** Generic column for use by sync adapters. */
4075 public static final String SYNC3 = "data_sync3";
4076 /** Generic column for use by sync adapters. */
4077 public static final String SYNC4 = "data_sync4";
Evan Millar088b2912009-05-28 15:24:37 -07004078 }
4079
4080 /**
Yorke Lee0dc523fa2013-03-12 12:48:06 -07004081 * Columns in the Data_Usage_Stat table
4082 */
4083 protected interface DataUsageStatColumns {
Yorke Lee0dc523fa2013-03-12 12:48:06 -07004084 /** The last time (in milliseconds) this {@link Data} was used. */
4085 public static final String LAST_TIME_USED = "last_time_used";
4086
Yorke Lee5a53d702013-03-29 18:08:47 -07004087 /** The number of times the referenced {@link Data} has been used. */
Yorke Lee0dc523fa2013-03-12 12:48:06 -07004088 public static final String TIMES_USED = "times_used";
Yorke Lee0dc523fa2013-03-12 12:48:06 -07004089 }
4090
4091 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004092 * Combines all columns returned by {@link ContactsContract.Data} table queries.
4093 *
4094 * @see ContactsContract.Data
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07004095 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07004096 protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns,
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08004097 RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns,
Yorke Lee0dc523fa2013-03-12 12:48:06 -07004098 ContactStatusColumns, DataUsageStatColumns {
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07004099 }
4100
4101 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004102 * <p>
4103 * Constants for the data table, which contains data points tied to a raw
Tom O'Neill244327e22010-01-08 11:11:15 -08004104 * contact. Each row of the data table is typically used to store a single
4105 * piece of contact
4106 * information (such as a phone number) and its
4107 * associated metadata (such as whether it is a work or home number).
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004108 * </p>
4109 * <h3>Data kinds</h3>
4110 * <p>
Tom O'Neill244327e22010-01-08 11:11:15 -08004111 * Data is a generic table that can hold any kind of contact data.
4112 * The kind of data stored in a given row is specified by the row's
4113 * {@link #MIMETYPE} value, which determines the meaning of the
4114 * generic columns {@link #DATA1} through
4115 * {@link #DATA15}.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004116 * For example, if the data kind is
Tom O'Neill244327e22010-01-08 11:11:15 -08004117 * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column
4118 * {@link #DATA1} stores the
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004119 * phone number, but if the data kind is
Tom O'Neill244327e22010-01-08 11:11:15 -08004120 * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1}
4121 * stores the email address.
4122 * Sync adapters and applications can introduce their own data kinds.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004123 * </p>
4124 * <p>
Tom O'Neill244327e22010-01-08 11:11:15 -08004125 * ContactsContract defines a small number of pre-defined data kinds, e.g.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004126 * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a
4127 * convenience, these classes define data kind specific aliases for DATA1 etc.
4128 * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as
4129 * {@link ContactsContract.Data Data.DATA1}.
4130 * </p>
4131 * <p>
4132 * {@link #DATA1} is an indexed column and should be used for the data element that is
4133 * expected to be most frequently used in query selections. For example, in the
4134 * case of a row representing email addresses {@link #DATA1} should probably
4135 * be used for the email address itself, while {@link #DATA2} etc can be
4136 * used for auxiliary information like type of email address.
4137 * <p>
4138 * <p>
4139 * By convention, {@link #DATA15} is used for storing BLOBs (binary data).
4140 * </p>
4141 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08004142 * The sync adapter for a given account type must correctly handle every data type
4143 * used in the corresponding raw contacts. Otherwise it could result in lost or
4144 * corrupted data.
4145 * </p>
4146 * <p>
4147 * Similarly, you should refrain from introducing new kinds of data for an other
Tom O'Neill244327e22010-01-08 11:11:15 -08004148 * party's account types. For example, if you add a data row for
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004149 * "favorite song" to a raw contact owned by a Google account, it will not
4150 * get synced to the server, because the Google sync adapter does not know
4151 * how to handle this data kind. Thus new data kinds are typically
4152 * introduced along with new account types, i.e. new sync adapters.
4153 * </p>
4154 * <h3>Batch operations</h3>
4155 * <p>
4156 * Data rows can be inserted/updated/deleted using the traditional
4157 * {@link ContentResolver#insert}, {@link ContentResolver#update} and
4158 * {@link ContentResolver#delete} methods, however the newer mechanism based
4159 * on a batch of {@link ContentProviderOperation} will prove to be a better
4160 * choice in almost all cases. All operations in a batch are executed in a
4161 * single transaction, which ensures that the phone-side and server-side
4162 * state of a raw contact are always consistent. Also, the batch-based
4163 * approach is far more efficient: not only are the database operations
4164 * faster when executed in a single transaction, but also sending a batch of
4165 * commands to the content provider saves a lot of time on context switching
4166 * between your process and the process in which the content provider runs.
4167 * </p>
4168 * <p>
4169 * The flip side of using batched operations is that a large batch may lock
4170 * up the database for a long time preventing other applications from
4171 * accessing data and potentially causing ANRs ("Application Not Responding"
4172 * dialogs.)
4173 * </p>
4174 * <p>
4175 * To avoid such lockups of the database, make sure to insert "yield points"
4176 * in the batch. A yield point indicates to the content provider that before
4177 * executing the next operation it can commit the changes that have already
4178 * been made, yield to other requests, open another transaction and continue
4179 * processing operations. A yield point will not automatically commit the
4180 * transaction, but only if there is another request waiting on the
4181 * database. Normally a sync adapter should insert a yield point at the
4182 * beginning of each raw contact operation sequence in the batch. See
4183 * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}.
4184 * </p>
4185 * <h3>Operations</h3>
4186 * <dl>
4187 * <dt><b>Insert</b></dt>
4188 * <dd>
4189 * <p>
4190 * An individual data row can be inserted using the traditional
4191 * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows
4192 * should always be inserted as a batch.
4193 * </p>
4194 * <p>
4195 * An example of a traditional insert:
4196 * <pre>
4197 * ContentValues values = new ContentValues();
4198 * values.put(Data.RAW_CONTACT_ID, rawContactId);
4199 * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
4200 * values.put(Phone.NUMBER, "1-800-GOOG-411");
4201 * values.put(Phone.TYPE, Phone.TYPE_CUSTOM);
4202 * values.put(Phone.LABEL, "free directory assistance");
4203 * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values);
4204 * </pre>
4205 * <p>
4206 * The same done using ContentProviderOperations:
4207 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07004208 * ArrayList&lt;ContentProviderOperation&gt; ops =
4209 * new ArrayList&lt;ContentProviderOperation&gt;();
4210 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004211 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
4212 * .withValue(Data.RAW_CONTACT_ID, rawContactId)
4213 * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
4214 * .withValue(Phone.NUMBER, "1-800-GOOG-411")
4215 * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM)
4216 * .withValue(Phone.LABEL, "free directory assistance")
4217 * .build());
4218 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
4219 * </pre>
4220 * </p>
4221 * <dt><b>Update</b></dt>
4222 * <dd>
4223 * <p>
4224 * Just as with insert, update can be done incrementally or as a batch,
4225 * the batch mode being the preferred method:
4226 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07004227 * ArrayList&lt;ContentProviderOperation&gt; ops =
4228 * new ArrayList&lt;ContentProviderOperation&gt;();
4229 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004230 * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
4231 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
4232 * .withValue(Email.DATA, "somebody@android.com")
4233 * .build());
4234 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
4235 * </pre>
4236 * </p>
4237 * </dd>
4238 * <dt><b>Delete</b></dt>
4239 * <dd>
4240 * <p>
4241 * Just as with insert and update, deletion can be done either using the
4242 * {@link ContentResolver#delete} method or using a ContentProviderOperation:
4243 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07004244 * ArrayList&lt;ContentProviderOperation&gt; ops =
4245 * new ArrayList&lt;ContentProviderOperation&gt;();
4246 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004247 * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI)
4248 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
4249 * .build());
4250 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
4251 * </pre>
4252 * </p>
4253 * </dd>
4254 * <dt><b>Query</b></dt>
4255 * <dd>
4256 * <p>
4257 * <dl>
4258 * <dt>Finding all Data of a given type for a given contact</dt>
4259 * <dd>
4260 * <pre>
4261 * Cursor c = getContentResolver().query(Data.CONTENT_URI,
4262 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
4263 * Data.CONTACT_ID + &quot;=?&quot; + " AND "
4264 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
4265 * new String[] {String.valueOf(contactId)}, null);
4266 * </pre>
4267 * </p>
4268 * <p>
4269 * </dd>
4270 * <dt>Finding all Data of a given type for a given raw contact</dt>
4271 * <dd>
4272 * <pre>
4273 * Cursor c = getContentResolver().query(Data.CONTENT_URI,
4274 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
4275 * Data.RAW_CONTACT_ID + &quot;=?&quot; + " AND "
4276 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
4277 * new String[] {String.valueOf(rawContactId)}, null);
4278 * </pre>
4279 * </dd>
4280 * <dt>Finding all Data for a given raw contact</dt>
4281 * <dd>
4282 * Most sync adapters will want to read all data rows for a raw contact
4283 * along with the raw contact itself. For that you should use the
4284 * {@link RawContactsEntity}. See also {@link RawContacts}.
4285 * </dd>
4286 * </dl>
4287 * </p>
4288 * </dd>
4289 * </dl>
4290 * <h2>Columns</h2>
Tom O'Neill244327e22010-01-08 11:11:15 -08004291 * <p>
4292 * Many columns are available via a {@link Data#CONTENT_URI} query. For best performance you
4293 * should explicitly specify a projection to only those columns that you need.
4294 * </p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004295 * <table class="jd-sumtable">
4296 * <tr>
4297 * <th colspan='4'>Data</th>
4298 * </tr>
4299 * <tr>
4300 * <td style="width: 7em;">long</td>
4301 * <td style="width: 20em;">{@link #_ID}</td>
4302 * <td style="width: 5em;">read-only</td>
4303 * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words,
Tom O'Neill244327e22010-01-08 11:11:15 -08004304 * it would be a bad idea to delete and reinsert a data row. A sync adapter should
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004305 * always do an update instead.</td>
4306 * </tr>
4307 * <tr>
4308 * <td>String</td>
4309 * <td>{@link #MIMETYPE}</td>
4310 * <td>read/write-once</td>
4311 * <td>
4312 * <p>The MIME type of the item represented by this row. Examples of common
4313 * MIME types are:
4314 * <ul>
4315 * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li>
4316 * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li>
4317 * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li>
4318 * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li>
4319 * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li>
4320 * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li>
4321 * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li>
4322 * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li>
4323 * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li>
4324 * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li>
4325 * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li>
4326 * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li>
4327 * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li>
David Brown846eb302010-08-23 17:40:51 -07004328 * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004329 * </ul>
4330 * </p>
4331 * </td>
4332 * </tr>
4333 * <tr>
4334 * <td>long</td>
4335 * <td>{@link #RAW_CONTACT_ID}</td>
4336 * <td>read/write-once</td>
Tom O'Neill244327e22010-01-08 11:11:15 -08004337 * <td>The id of the row in the {@link RawContacts} table that this data belongs to.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004338 * </tr>
4339 * <tr>
4340 * <td>int</td>
4341 * <td>{@link #IS_PRIMARY}</td>
4342 * <td>read/write</td>
4343 * <td>Whether this is the primary entry of its kind for the raw contact it belongs to.
Tom O'Neill244327e22010-01-08 11:11:15 -08004344 * "1" if true, "0" if false.
4345 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004346 * </tr>
4347 * <tr>
4348 * <td>int</td>
4349 * <td>{@link #IS_SUPER_PRIMARY}</td>
4350 * <td>read/write</td>
4351 * <td>Whether this is the primary entry of its kind for the aggregate
4352 * contact it belongs to. Any data record that is "super primary" must
Tom O'Neill244327e22010-01-08 11:11:15 -08004353 * also be "primary". For example, the super-primary entry may be
4354 * interpreted as the default contact value of its kind (for example,
4355 * the default phone number to use for the contact).</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004356 * </tr>
4357 * <tr>
4358 * <td>int</td>
4359 * <td>{@link #DATA_VERSION}</td>
4360 * <td>read-only</td>
4361 * <td>The version of this data record. Whenever the data row changes
4362 * the version goes up. This value is monotonically increasing.</td>
4363 * </tr>
4364 * <tr>
4365 * <td>Any type</td>
4366 * <td>
4367 * {@link #DATA1}<br>
4368 * {@link #DATA2}<br>
4369 * {@link #DATA3}<br>
4370 * {@link #DATA4}<br>
4371 * {@link #DATA5}<br>
4372 * {@link #DATA6}<br>
4373 * {@link #DATA7}<br>
4374 * {@link #DATA8}<br>
4375 * {@link #DATA9}<br>
4376 * {@link #DATA10}<br>
4377 * {@link #DATA11}<br>
4378 * {@link #DATA12}<br>
4379 * {@link #DATA13}<br>
4380 * {@link #DATA14}<br>
4381 * {@link #DATA15}
4382 * </td>
4383 * <td>read/write</td>
Tom O'Neill244327e22010-01-08 11:11:15 -08004384 * <td>
4385 * <p>
4386 * Generic data columns. The meaning of each column is determined by the
4387 * {@link #MIMETYPE}. By convention, {@link #DATA15} is used for storing
4388 * BLOBs (binary data).
4389 * </p>
4390 * <p>
4391 * Data columns whose meaning is not explicitly defined for a given MIMETYPE
4392 * should not be used. There is no guarantee that any sync adapter will
4393 * preserve them. Sync adapters themselves should not use such columns either,
4394 * but should instead use {@link #SYNC1}-{@link #SYNC4}.
4395 * </p>
4396 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004397 * </tr>
4398 * <tr>
4399 * <td>Any type</td>
4400 * <td>
4401 * {@link #SYNC1}<br>
4402 * {@link #SYNC2}<br>
4403 * {@link #SYNC3}<br>
4404 * {@link #SYNC4}
4405 * </td>
4406 * <td>read/write</td>
4407 * <td>Generic columns for use by sync adapters. For example, a Photo row
4408 * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error)
4409 * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td>
4410 * </tr>
4411 * </table>
4412 *
Tom O'Neill244327e22010-01-08 11:11:15 -08004413 * <p>
4414 * Some columns from the most recent associated status update are also available
4415 * through an implicit join.
4416 * </p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004417 * <table class="jd-sumtable">
4418 * <tr>
4419 * <th colspan='4'>Join with {@link StatusUpdates}</th>
4420 * </tr>
4421 * <tr>
4422 * <td style="width: 7em;">int</td>
4423 * <td style="width: 20em;">{@link #PRESENCE}</td>
4424 * <td style="width: 5em;">read-only</td>
4425 * <td>IM presence status linked to this data row. Compare with
4426 * {@link #CONTACT_PRESENCE}, which contains the contact's presence across
4427 * all IM rows. See {@link StatusUpdates} for individual status definitions.
4428 * The provider may choose not to store this value
4429 * in persistent storage. The expectation is that presence status will be
kmccormick50e27c82013-03-28 16:33:11 -07004430 * updated on a regular basis.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004431 * </td>
4432 * </tr>
4433 * <tr>
4434 * <td>String</td>
4435 * <td>{@link #STATUS}</td>
4436 * <td>read-only</td>
4437 * <td>Latest status update linked with this data row.</td>
4438 * </tr>
4439 * <tr>
4440 * <td>long</td>
4441 * <td>{@link #STATUS_TIMESTAMP}</td>
4442 * <td>read-only</td>
4443 * <td>The absolute time in milliseconds when the latest status was
4444 * inserted/updated for this data row.</td>
4445 * </tr>
4446 * <tr>
4447 * <td>String</td>
4448 * <td>{@link #STATUS_RES_PACKAGE}</td>
4449 * <td>read-only</td>
4450 * <td>The package containing resources for this status: label and icon.</td>
4451 * </tr>
4452 * <tr>
4453 * <td>long</td>
4454 * <td>{@link #STATUS_LABEL}</td>
4455 * <td>read-only</td>
4456 * <td>The resource ID of the label describing the source of status update linked
4457 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
4458 * </tr>
4459 * <tr>
4460 * <td>long</td>
4461 * <td>{@link #STATUS_ICON}</td>
4462 * <td>read-only</td>
4463 * <td>The resource ID of the icon for the source of the status update linked
4464 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
4465 * </tr>
4466 * </table>
4467 *
4468 * <p>
Tom O'Neill244327e22010-01-08 11:11:15 -08004469 * Some columns from the associated raw contact are also available through an
4470 * implicit join. The other columns are excluded as uninteresting in this
4471 * context.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004472 * </p>
4473 *
4474 * <table class="jd-sumtable">
4475 * <tr>
Tom O'Neill244327e22010-01-08 11:11:15 -08004476 * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004477 * </tr>
4478 * <tr>
Tom O'Neill244327e22010-01-08 11:11:15 -08004479 * <td style="width: 7em;">long</td>
4480 * <td style="width: 20em;">{@link #CONTACT_ID}</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004481 * <td style="width: 5em;">read-only</td>
Tom O'Neill244327e22010-01-08 11:11:15 -08004482 * <td>The id of the row in the {@link Contacts} table that this data belongs
4483 * to.</td>
4484 * </tr>
4485 * <tr>
4486 * <td>int</td>
4487 * <td>{@link #AGGREGATION_MODE}</td>
4488 * <td>read-only</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004489 * <td>See {@link RawContacts}.</td>
4490 * </tr>
4491 * <tr>
4492 * <td>int</td>
4493 * <td>{@link #DELETED}</td>
4494 * <td>read-only</td>
4495 * <td>See {@link RawContacts}.</td>
4496 * </tr>
4497 * </table>
4498 *
4499 * <p>
Tom O'Neill244327e22010-01-08 11:11:15 -08004500 * The ID column for the associated aggregated contact table
4501 * {@link ContactsContract.Contacts} is available
4502 * via the implicit join to the {@link RawContacts} table, see above.
4503 * The remaining columns from this table are also
4504 * available, through an implicit join. This
4505 * facilitates lookup by
4506 * the value of a single data element, such as the email address.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004507 * </p>
4508 *
4509 * <table class="jd-sumtable">
4510 * <tr>
Tom O'Neill244327e22010-01-08 11:11:15 -08004511 * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004512 * </tr>
4513 * <tr>
4514 * <td style="width: 7em;">String</td>
4515 * <td style="width: 20em;">{@link #LOOKUP_KEY}</td>
4516 * <td style="width: 5em;">read-only</td>
4517 * <td>See {@link ContactsContract.Contacts}</td>
4518 * </tr>
4519 * <tr>
4520 * <td>String</td>
4521 * <td>{@link #DISPLAY_NAME}</td>
4522 * <td>read-only</td>
4523 * <td>See {@link ContactsContract.Contacts}</td>
4524 * </tr>
4525 * <tr>
4526 * <td>long</td>
4527 * <td>{@link #PHOTO_ID}</td>
4528 * <td>read-only</td>
4529 * <td>See {@link ContactsContract.Contacts}.</td>
4530 * </tr>
4531 * <tr>
4532 * <td>int</td>
4533 * <td>{@link #IN_VISIBLE_GROUP}</td>
4534 * <td>read-only</td>
4535 * <td>See {@link ContactsContract.Contacts}.</td>
4536 * </tr>
4537 * <tr>
4538 * <td>int</td>
4539 * <td>{@link #HAS_PHONE_NUMBER}</td>
4540 * <td>read-only</td>
4541 * <td>See {@link ContactsContract.Contacts}.</td>
4542 * </tr>
4543 * <tr>
4544 * <td>int</td>
4545 * <td>{@link #TIMES_CONTACTED}</td>
4546 * <td>read-only</td>
4547 * <td>See {@link ContactsContract.Contacts}.</td>
4548 * </tr>
4549 * <tr>
4550 * <td>long</td>
4551 * <td>{@link #LAST_TIME_CONTACTED}</td>
4552 * <td>read-only</td>
4553 * <td>See {@link ContactsContract.Contacts}.</td>
4554 * </tr>
4555 * <tr>
4556 * <td>int</td>
4557 * <td>{@link #STARRED}</td>
4558 * <td>read-only</td>
4559 * <td>See {@link ContactsContract.Contacts}.</td>
4560 * </tr>
4561 * <tr>
4562 * <td>String</td>
4563 * <td>{@link #CUSTOM_RINGTONE}</td>
4564 * <td>read-only</td>
4565 * <td>See {@link ContactsContract.Contacts}.</td>
4566 * </tr>
4567 * <tr>
4568 * <td>int</td>
4569 * <td>{@link #SEND_TO_VOICEMAIL}</td>
4570 * <td>read-only</td>
4571 * <td>See {@link ContactsContract.Contacts}.</td>
4572 * </tr>
4573 * <tr>
4574 * <td>int</td>
4575 * <td>{@link #CONTACT_PRESENCE}</td>
4576 * <td>read-only</td>
4577 * <td>See {@link ContactsContract.Contacts}.</td>
4578 * </tr>
4579 * <tr>
4580 * <td>String</td>
4581 * <td>{@link #CONTACT_STATUS}</td>
4582 * <td>read-only</td>
4583 * <td>See {@link ContactsContract.Contacts}.</td>
4584 * </tr>
4585 * <tr>
4586 * <td>long</td>
4587 * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
4588 * <td>read-only</td>
4589 * <td>See {@link ContactsContract.Contacts}.</td>
4590 * </tr>
4591 * <tr>
4592 * <td>String</td>
4593 * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
4594 * <td>read-only</td>
4595 * <td>See {@link ContactsContract.Contacts}.</td>
4596 * </tr>
4597 * <tr>
4598 * <td>long</td>
4599 * <td>{@link #CONTACT_STATUS_LABEL}</td>
4600 * <td>read-only</td>
4601 * <td>See {@link ContactsContract.Contacts}.</td>
4602 * </tr>
4603 * <tr>
4604 * <td>long</td>
4605 * <td>{@link #CONTACT_STATUS_ICON}</td>
4606 * <td>read-only</td>
4607 * <td>See {@link ContactsContract.Contacts}.</td>
4608 * </tr>
4609 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07004610 */
Yorke Lee94c87612014-07-18 18:57:17 -07004611 public final static class Data implements DataColumnsWithJoins, ContactCounts {
Evan Millar088b2912009-05-28 15:24:37 -07004612 /**
4613 * This utility class cannot be instantiated
4614 */
4615 private Data() {}
4616
4617 /**
Tom O'Neill244327e22010-01-08 11:11:15 -08004618 * The content:// style URI for this table, which requests a directory
4619 * of data rows matching the selection criteria.
Evan Millar088b2912009-05-28 15:24:37 -07004620 */
4621 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
4622
4623 /**
Yorke Lee4f401eb2013-03-06 17:17:17 -08004624 * A boolean parameter for {@link Data#CONTENT_URI}.
4625 * This specifies whether or not the returned data items should be filtered to show
4626 * data items belonging to visible contacts only.
4627 */
4628 public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only";
4629
4630 /**
Tom O'Neill244327e22010-01-08 11:11:15 -08004631 * The MIME type of the results from {@link #CONTENT_URI}.
Evan Millar088b2912009-05-28 15:24:37 -07004632 */
4633 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07004634
4635 /**
Tom O'Neill244327e22010-01-08 11:11:15 -08004636 * <p>
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004637 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
4638 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004639 * entry of the given {@link ContactsContract.Data} entry.
Tom O'Neill244327e22010-01-08 11:11:15 -08004640 * </p>
4641 * <p>
4642 * Returns the Uri for the contact in the first entry returned by
4643 * {@link ContentResolver#query(Uri, String[], String, String[], String)}
4644 * for the provided {@code dataUri}. If the query returns null or empty
4645 * results, silently returns null.
4646 * </p>
Jeff Sharkey6449eb02009-09-16 21:41:51 -07004647 */
4648 public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) {
4649 final Cursor cursor = resolver.query(dataUri, new String[] {
4650 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
4651 }, null, null, null);
4652
4653 Uri lookupUri = null;
4654 try {
4655 if (cursor != null && cursor.moveToFirst()) {
4656 final long contactId = cursor.getLong(0);
4657 final String lookupKey = cursor.getString(1);
4658 return Contacts.getLookupUri(contactId, lookupKey);
4659 }
4660 } finally {
4661 if (cursor != null) cursor.close();
4662 }
4663 return lookupUri;
4664 }
Evan Millar088b2912009-05-28 15:24:37 -07004665 }
4666
Fred Quintana5bba6322009-10-05 14:21:12 -07004667 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004668 * <p>
Tom O'Neill244327e22010-01-08 11:11:15 -08004669 * Constants for the raw contacts entities table, which can be thought of as
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004670 * an outer join of the raw_contacts table with the data table. It is a strictly
4671 * read-only table.
4672 * </p>
4673 * <p>
4674 * If a raw contact has data rows, the RawContactsEntity cursor will contain
4675 * a one row for each data row. If the raw contact has no data rows, the
4676 * cursor will still contain one row with the raw contact-level information
4677 * and nulls for data columns.
4678 *
4679 * <pre>
4680 * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId);
4681 * Cursor c = getContentResolver().query(entityUri,
4682 * new String[]{
4683 * RawContactsEntity.SOURCE_ID,
4684 * RawContactsEntity.DATA_ID,
4685 * RawContactsEntity.MIMETYPE,
4686 * RawContactsEntity.DATA1
4687 * }, null, null, null);
4688 * try {
4689 * while (c.moveToNext()) {
4690 * String sourceId = c.getString(0);
4691 * if (!c.isNull(1)) {
4692 * String mimeType = c.getString(2);
4693 * String data = c.getString(3);
4694 * ...
4695 * }
4696 * }
4697 * } finally {
4698 * c.close();
4699 * }
4700 * </pre>
4701 *
4702 * <h3>Columns</h3>
4703 * RawContactsEntity has a combination of RawContact and Data columns.
4704 *
4705 * <table class="jd-sumtable">
4706 * <tr>
4707 * <th colspan='4'>RawContacts</th>
4708 * </tr>
4709 * <tr>
4710 * <td style="width: 7em;">long</td>
4711 * <td style="width: 20em;">{@link #_ID}</td>
4712 * <td style="width: 5em;">read-only</td>
4713 * <td>Raw contact row ID. See {@link RawContacts}.</td>
4714 * </tr>
4715 * <tr>
4716 * <td>long</td>
4717 * <td>{@link #CONTACT_ID}</td>
4718 * <td>read-only</td>
4719 * <td>See {@link RawContacts}.</td>
4720 * </tr>
4721 * <tr>
4722 * <td>int</td>
4723 * <td>{@link #AGGREGATION_MODE}</td>
4724 * <td>read-only</td>
4725 * <td>See {@link RawContacts}.</td>
4726 * </tr>
4727 * <tr>
4728 * <td>int</td>
4729 * <td>{@link #DELETED}</td>
4730 * <td>read-only</td>
4731 * <td>See {@link RawContacts}.</td>
4732 * </tr>
4733 * </table>
4734 *
4735 * <table class="jd-sumtable">
4736 * <tr>
4737 * <th colspan='4'>Data</th>
4738 * </tr>
4739 * <tr>
4740 * <td style="width: 7em;">long</td>
4741 * <td style="width: 20em;">{@link #DATA_ID}</td>
4742 * <td style="width: 5em;">read-only</td>
4743 * <td>Data row ID. It will be null if the raw contact has no data rows.</td>
4744 * </tr>
4745 * <tr>
4746 * <td>String</td>
4747 * <td>{@link #MIMETYPE}</td>
4748 * <td>read-only</td>
4749 * <td>See {@link ContactsContract.Data}.</td>
4750 * </tr>
4751 * <tr>
4752 * <td>int</td>
4753 * <td>{@link #IS_PRIMARY}</td>
4754 * <td>read-only</td>
4755 * <td>See {@link ContactsContract.Data}.</td>
4756 * </tr>
4757 * <tr>
4758 * <td>int</td>
4759 * <td>{@link #IS_SUPER_PRIMARY}</td>
4760 * <td>read-only</td>
4761 * <td>See {@link ContactsContract.Data}.</td>
4762 * </tr>
4763 * <tr>
4764 * <td>int</td>
4765 * <td>{@link #DATA_VERSION}</td>
4766 * <td>read-only</td>
4767 * <td>See {@link ContactsContract.Data}.</td>
4768 * </tr>
4769 * <tr>
4770 * <td>Any type</td>
4771 * <td>
4772 * {@link #DATA1}<br>
4773 * {@link #DATA2}<br>
4774 * {@link #DATA3}<br>
4775 * {@link #DATA4}<br>
4776 * {@link #DATA5}<br>
4777 * {@link #DATA6}<br>
4778 * {@link #DATA7}<br>
4779 * {@link #DATA8}<br>
4780 * {@link #DATA9}<br>
4781 * {@link #DATA10}<br>
4782 * {@link #DATA11}<br>
4783 * {@link #DATA12}<br>
4784 * {@link #DATA13}<br>
4785 * {@link #DATA14}<br>
4786 * {@link #DATA15}
4787 * </td>
4788 * <td>read-only</td>
4789 * <td>See {@link ContactsContract.Data}.</td>
4790 * </tr>
4791 * <tr>
4792 * <td>Any type</td>
4793 * <td>
4794 * {@link #SYNC1}<br>
4795 * {@link #SYNC2}<br>
4796 * {@link #SYNC3}<br>
4797 * {@link #SYNC4}
4798 * </td>
4799 * <td>read-only</td>
4800 * <td>See {@link ContactsContract.Data}.</td>
4801 * </tr>
4802 * </table>
Fred Quintana5bba6322009-10-05 14:21:12 -07004803 */
4804 public final static class RawContactsEntity
4805 implements BaseColumns, DataColumns, RawContactsColumns {
4806 /**
4807 * This utility class cannot be instantiated
4808 */
4809 private RawContactsEntity() {}
4810
4811 /**
4812 * The content:// style URI for this table
4813 */
4814 public static final Uri CONTENT_URI =
4815 Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities");
4816
4817 /**
Dave Santoro2b4d0752011-09-07 17:37:33 -07004818 * The content:// style URI for this table, specific to the user's profile.
4819 */
4820 public static final Uri PROFILE_CONTENT_URI =
4821 Uri.withAppendedPath(Profile.CONTENT_URI, "raw_contact_entities");
4822
4823 /**
Fred Quintana5bba6322009-10-05 14:21:12 -07004824 * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities.
4825 */
4826 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity";
4827
4828 /**
4829 * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
4830 * Data.CONTENT_URI contains only exportable data.
4831 *
4832 * This flag is useful (currently) only for vCard exporter in Contacts app, which
4833 * needs to exclude "un-exportable" data from available data to export, while
4834 * Contacts app itself has priviledge to access all data including "un-expotable"
4835 * ones and providers return all of them regardless of the callers' intention.
4836 * <P>Type: INTEGER</p>
4837 *
4838 * @hide Maybe available only in Eclair and not really ready for public use.
4839 * TODO: remove, or implement this feature completely. As of now (Eclair),
4840 * we only use this flag in queryEntities(), not query().
4841 */
4842 public static final String FOR_EXPORT_ONLY = "for_export_only";
4843
4844 /**
4845 * The ID of the data column. The value will be null if this raw contact has no data rows.
4846 * <P>Type: INTEGER</P>
4847 */
4848 public static final String DATA_ID = "data_id";
4849 }
4850
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004851 /**
4852 * @see PhoneLookup
4853 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07004854 protected interface PhoneLookupColumns {
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004855 /**
4856 * The phone number as the user entered it.
4857 * <P>Type: TEXT</P>
4858 */
4859 public static final String NUMBER = "number";
4860
4861 /**
4862 * The type of phone number, for example Home or Work.
4863 * <P>Type: INTEGER</P>
4864 */
4865 public static final String TYPE = "type";
4866
4867 /**
4868 * The user defined label for the phone number.
4869 * <P>Type: TEXT</P>
4870 */
4871 public static final String LABEL = "label";
Bai Tao224744c2010-08-31 09:59:13 +08004872
4873 /**
4874 * The phone number's E164 representation.
4875 * <P>Type: TEXT</P>
Bai Tao224744c2010-08-31 09:59:13 +08004876 */
4877 public static final String NORMALIZED_NUMBER = "normalized_number";
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004878 }
4879
Evan Millar088b2912009-05-28 15:24:37 -07004880 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004881 * A table that represents the result of looking up a phone number, for
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004882 * example for caller ID. To perform a lookup you must append the number you
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004883 * want to find to {@link #CONTENT_FILTER_URI}. This query is highly
4884 * optimized.
4885 * <pre>
4886 * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
4887 * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,...
4888 * </pre>
4889 *
4890 * <h3>Columns</h3>
4891 *
4892 * <table class="jd-sumtable">
4893 * <tr>
4894 * <th colspan='4'>PhoneLookup</th>
4895 * </tr>
4896 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004897 * <td>String</td>
4898 * <td>{@link #NUMBER}</td>
4899 * <td>read-only</td>
4900 * <td>Phone number.</td>
4901 * </tr>
4902 * <tr>
4903 * <td>String</td>
4904 * <td>{@link #TYPE}</td>
4905 * <td>read-only</td>
4906 * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td>
4907 * </tr>
4908 * <tr>
4909 * <td>String</td>
4910 * <td>{@link #LABEL}</td>
4911 * <td>read-only</td>
4912 * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td>
4913 * </tr>
4914 * </table>
4915 * <p>
4916 * Columns from the Contacts table are also available through a join.
4917 * </p>
4918 * <table class="jd-sumtable">
4919 * <tr>
4920 * <th colspan='4'>Join with {@link Contacts}</th>
4921 * </tr>
4922 * <tr>
Dmitri Plotnikov817b3f92011-01-09 17:07:13 -08004923 * <td>long</td>
4924 * <td>{@link #_ID}</td>
4925 * <td>read-only</td>
4926 * <td>Contact ID.</td>
4927 * </tr>
4928 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004929 * <td>String</td>
4930 * <td>{@link #LOOKUP_KEY}</td>
4931 * <td>read-only</td>
4932 * <td>See {@link ContactsContract.Contacts}</td>
4933 * </tr>
4934 * <tr>
4935 * <td>String</td>
4936 * <td>{@link #DISPLAY_NAME}</td>
4937 * <td>read-only</td>
4938 * <td>See {@link ContactsContract.Contacts}</td>
4939 * </tr>
4940 * <tr>
4941 * <td>long</td>
4942 * <td>{@link #PHOTO_ID}</td>
4943 * <td>read-only</td>
4944 * <td>See {@link ContactsContract.Contacts}.</td>
4945 * </tr>
4946 * <tr>
4947 * <td>int</td>
4948 * <td>{@link #IN_VISIBLE_GROUP}</td>
4949 * <td>read-only</td>
4950 * <td>See {@link ContactsContract.Contacts}.</td>
4951 * </tr>
4952 * <tr>
4953 * <td>int</td>
4954 * <td>{@link #HAS_PHONE_NUMBER}</td>
4955 * <td>read-only</td>
4956 * <td>See {@link ContactsContract.Contacts}.</td>
4957 * </tr>
4958 * <tr>
4959 * <td>int</td>
4960 * <td>{@link #TIMES_CONTACTED}</td>
4961 * <td>read-only</td>
4962 * <td>See {@link ContactsContract.Contacts}.</td>
4963 * </tr>
4964 * <tr>
4965 * <td>long</td>
4966 * <td>{@link #LAST_TIME_CONTACTED}</td>
4967 * <td>read-only</td>
4968 * <td>See {@link ContactsContract.Contacts}.</td>
4969 * </tr>
4970 * <tr>
4971 * <td>int</td>
4972 * <td>{@link #STARRED}</td>
4973 * <td>read-only</td>
4974 * <td>See {@link ContactsContract.Contacts}.</td>
4975 * </tr>
4976 * <tr>
4977 * <td>String</td>
4978 * <td>{@link #CUSTOM_RINGTONE}</td>
4979 * <td>read-only</td>
4980 * <td>See {@link ContactsContract.Contacts}.</td>
4981 * </tr>
4982 * <tr>
4983 * <td>int</td>
4984 * <td>{@link #SEND_TO_VOICEMAIL}</td>
4985 * <td>read-only</td>
4986 * <td>See {@link ContactsContract.Contacts}.</td>
4987 * </tr>
4988 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07004989 */
Dmitri Plotnikov93032952009-08-19 11:26:57 -07004990 public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
4991 ContactsColumns, ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -07004992 /**
4993 * This utility class cannot be instantiated
4994 */
4995 private PhoneLookup() {}
4996
4997 /**
4998 * The content:// style URI for this table. Append the phone number you want to lookup
4999 * to this URI and query it to perform a lookup. For example:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005000 * <pre>
Scott Kennedy7ed189e2013-01-11 22:31:43 -08005001 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
5002 * Uri.encode(phoneNumber));
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005003 * </pre>
Evan Millar088b2912009-05-28 15:24:37 -07005004 */
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005005 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
5006 "phone_lookup");
Dmitri Plotnikov0b0b8a82010-03-04 18:20:08 -08005007
5008 /**
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005009 * URI used for the "enterprise caller-id".
5010 *
5011 * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same
5012 * columns. If the device has no corp profile that is linked to the current profile, it
5013 * behaves in the exact same way as {@link #CONTENT_FILTER_URI}. If there is a corp profile
5014 * linked to the current profile, it first queries against the personal contact database,
5015 * and if no matching contacts are found there, then queries against the
5016 * corp contacts database.
5017 * <p>
5018 * If a result is from the corp profile, it makes the following changes to the data:
5019 * <ul>
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005020 * <li>
5021 * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special
5022 * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to
5023 * load pictures from them.
Makoto Onuki80b3ab62014-07-10 11:24:21 -07005024 * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not use them.
5025 * </li>
5026 * <li>
5027 * Corp contacts will get artificial {@link #_ID}s. In order to tell whether a contact
5028 * is from the corp profile, use {@link ContactsContract.Contacts#isCorpContactId(long)}.
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005029 * </li>
5030 * </ul>
Makoto Onuki95a9cfb2014-07-08 17:11:54 -07005031 * <p>
5032 * This URI does NOT support selection nor order-by.
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005033 *
5034 * <pre>
5035 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI,
5036 * Uri.encode(phoneNumber));
5037 * </pre>
5038 */
5039 public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
5040 "phone_lookup_enterprise");
5041
5042 /**
Dmitri Plotnikov0b0b8a82010-03-04 18:20:08 -08005043 * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows.
5044 *
5045 * @hide
5046 */
5047 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup";
Flavio Lerda52c01c22011-11-02 22:16:23 +00005048
Yorke Lee217d8a72013-11-27 10:14:04 -08005049 /**
5050 * If this boolean parameter is set to true, then the appended query is treated as a
5051 * SIP address and the lookup will be performed against SIP addresses in the user's
5052 * contacts.
5053 */
Flavio Lerda52c01c22011-11-02 22:16:23 +00005054 public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005055 }
5056
5057 /**
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005058 * Additional data mixed in with {@link StatusColumns} to link
5059 * back to specific {@link ContactsContract.Data#_ID} entries.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005060 *
5061 * @see StatusUpdates
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005062 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07005063 protected interface PresenceColumns {
Dmitri Plotnikov55048a92009-07-24 10:25:34 -07005064
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005065 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005066 * Reference to the {@link Data#_ID} entry that owns this presence.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005067 * <P>Type: INTEGER</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005068 */
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005069 public static final String DATA_ID = "presence_data_id";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005070
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005071 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005072 * See {@link CommonDataKinds.Im} for a list of defined protocol constants.
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07005073 * <p>Type: NUMBER</p>
5074 */
5075 public static final String PROTOCOL = "protocol";
5076
5077 /**
5078 * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value
5079 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or
5080 * omitted if {@link #PROTOCOL} value is not
5081 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.
5082 *
5083 * <p>Type: NUMBER</p>
5084 */
5085 public static final String CUSTOM_PROTOCOL = "custom_protocol";
5086
5087 /**
5088 * The IM handle the presence item is for. The handle is scoped to
5089 * {@link #PROTOCOL}.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005090 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005091 */
5092 public static final String IM_HANDLE = "im_handle";
5093
5094 /**
5095 * The IM account for the local user that the presence data came from.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005096 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005097 */
5098 public static final String IM_ACCOUNT = "im_account";
5099 }
5100
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005101 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005102 * <p>
5103 * A status update is linked to a {@link ContactsContract.Data} row and captures
5104 * the user's latest status update via the corresponding source, e.g.
5105 * "Having lunch" via "Google Talk".
5106 * </p>
5107 * <p>
5108 * There are two ways a status update can be inserted: by explicitly linking
5109 * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row
5110 * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
5111 * {@link #IM_HANDLE}. There is no difference between insert and update, you can use
5112 * either.
5113 * </p>
5114 * <p>
Dave Santoro063084e2011-08-23 15:42:49 -07005115 * Inserting or updating a status update for the user's profile requires either using
5116 * the {@link #DATA_ID} to identify the data row to attach the update to, or
5117 * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the
5118 * profile.
5119 * </p>
5120 * <p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005121 * You cannot use {@link ContentResolver#update} to change a status, but
5122 * {@link ContentResolver#insert} will replace the latests status if it already
5123 * exists.
5124 * </p>
5125 * <p>
5126 * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses
5127 * for multiple contacts at once.
5128 * </p>
5129 *
5130 * <h3>Columns</h3>
5131 * <table class="jd-sumtable">
5132 * <tr>
5133 * <th colspan='4'>StatusUpdates</th>
5134 * </tr>
5135 * <tr>
5136 * <td>long</td>
5137 * <td>{@link #DATA_ID}</td>
5138 * <td>read/write</td>
5139 * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this
5140 * field is <i>not</i> specified, the provider will attempt to find a data row
5141 * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
5142 * {@link #IM_HANDLE} columns.
5143 * </td>
5144 * </tr>
5145 * <tr>
5146 * <td>long</td>
5147 * <td>{@link #PROTOCOL}</td>
5148 * <td>read/write</td>
5149 * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td>
5150 * </tr>
5151 * <tr>
5152 * <td>String</td>
5153 * <td>{@link #CUSTOM_PROTOCOL}</td>
5154 * <td>read/write</td>
5155 * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value
5156 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or
5157 * omitted if {@link #PROTOCOL} value is not
5158 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td>
5159 * </tr>
5160 * <tr>
5161 * <td>String</td>
5162 * <td>{@link #IM_HANDLE}</td>
5163 * <td>read/write</td>
5164 * <td> The IM handle the presence item is for. The handle is scoped to
5165 * {@link #PROTOCOL}.</td>
5166 * </tr>
5167 * <tr>
5168 * <td>String</td>
5169 * <td>{@link #IM_ACCOUNT}</td>
5170 * <td>read/write</td>
5171 * <td>The IM account for the local user that the presence data came from.</td>
5172 * </tr>
5173 * <tr>
5174 * <td>int</td>
5175 * <td>{@link #PRESENCE}</td>
5176 * <td>read/write</td>
5177 * <td>Contact IM presence status. The allowed values are:
5178 * <p>
5179 * <ul>
5180 * <li>{@link #OFFLINE}</li>
5181 * <li>{@link #INVISIBLE}</li>
5182 * <li>{@link #AWAY}</li>
5183 * <li>{@link #IDLE}</li>
5184 * <li>{@link #DO_NOT_DISTURB}</li>
5185 * <li>{@link #AVAILABLE}</li>
5186 * </ul>
5187 * </p>
5188 * <p>
5189 * Since presence status is inherently volatile, the content provider
5190 * may choose not to store this field in long-term storage.
5191 * </p>
5192 * </td>
5193 * </tr>
5194 * <tr>
Vasu Nori5b31498ba12010-07-12 15:13:37 -07005195 * <td>int</td>
5196 * <td>{@link #CHAT_CAPABILITY}</td>
5197 * <td>read/write</td>
Daniel Lehmannb3327472010-08-13 15:16:11 -07005198 * <td>Contact IM chat compatibility value. The allowed values combinations of the following
5199 * flags. If None of these flags is set, the device can only do text messaging.
Vasu Nori5b31498ba12010-07-12 15:13:37 -07005200 * <p>
5201 * <ul>
Daniel Lehmannb3327472010-08-13 15:16:11 -07005202 * <li>{@link #CAPABILITY_HAS_VIDEO}</li>
Vasu Nori5b31498ba12010-07-12 15:13:37 -07005203 * <li>{@link #CAPABILITY_HAS_VOICE}</li>
5204 * <li>{@link #CAPABILITY_HAS_CAMERA}</li>
5205 * </ul>
5206 * </p>
5207 * <p>
5208 * Since chat compatibility is inherently volatile as the contact's availability moves from
5209 * one device to another, the content provider may choose not to store this field in long-term
5210 * storage.
5211 * </p>
5212 * </td>
5213 * </tr>
5214 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005215 * <td>String</td>
5216 * <td>{@link #STATUS}</td>
5217 * <td>read/write</td>
5218 * <td>Contact's latest status update, e.g. "having toast for breakfast"</td>
5219 * </tr>
5220 * <tr>
5221 * <td>long</td>
5222 * <td>{@link #STATUS_TIMESTAMP}</td>
5223 * <td>read/write</td>
5224 * <td>The absolute time in milliseconds when the status was
5225 * entered by the user. If this value is not provided, the provider will follow
5226 * this logic: if there was no prior status update, the value will be left as null.
5227 * If there was a prior status update, the provider will default this field
5228 * to the current time.</td>
5229 * </tr>
5230 * <tr>
5231 * <td>String</td>
5232 * <td>{@link #STATUS_RES_PACKAGE}</td>
5233 * <td>read/write</td>
5234 * <td> The package containing resources for this status: label and icon.</td>
5235 * </tr>
5236 * <tr>
5237 * <td>long</td>
5238 * <td>{@link #STATUS_LABEL}</td>
5239 * <td>read/write</td>
5240 * <td>The resource ID of the label describing the source of contact status,
5241 * e.g. "Google Talk". This resource is scoped by the
5242 * {@link #STATUS_RES_PACKAGE}.</td>
5243 * </tr>
5244 * <tr>
5245 * <td>long</td>
5246 * <td>{@link #STATUS_ICON}</td>
5247 * <td>read/write</td>
5248 * <td>The resource ID of the icon for the source of contact status. This
5249 * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
5250 * </tr>
5251 * </table>
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005252 */
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005253 public static class StatusUpdates implements StatusColumns, PresenceColumns {
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07005254
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005255 /**
5256 * This utility class cannot be instantiated
5257 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005258 private StatusUpdates() {}
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005259
5260 /**
5261 * The content:// style URI for this table
5262 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005263 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates");
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005264
5265 /**
Dave Santoro063084e2011-08-23 15:42:49 -07005266 * The content:// style URI for this table, specific to the user's profile.
5267 */
5268 public static final Uri PROFILE_CONTENT_URI =
5269 Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates");
5270
5271 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005272 * Gets the resource ID for the proper presence icon.
5273 *
5274 * @param status the status to get the icon for
5275 * @return the resource ID for the proper presence icon
5276 */
5277 public static final int getPresenceIconResourceId(int status) {
5278 switch (status) {
5279 case AVAILABLE:
5280 return android.R.drawable.presence_online;
5281 case IDLE:
5282 case AWAY:
5283 return android.R.drawable.presence_away;
5284 case DO_NOT_DISTURB:
5285 return android.R.drawable.presence_busy;
5286 case INVISIBLE:
5287 return android.R.drawable.presence_invisible;
5288 case OFFLINE:
5289 default:
5290 return android.R.drawable.presence_offline;
5291 }
5292 }
5293
5294 /**
Evan Millarc0437522009-06-23 17:31:05 -07005295 * Returns the precedence of the status code the higher number being the higher precedence.
5296 *
5297 * @param status The status code.
5298 * @return An integer representing the precedence, 0 being the lowest.
5299 */
5300 public static final int getPresencePrecedence(int status) {
5301 // Keep this function here incase we want to enforce a different precedence than the
5302 // natural order of the status constants.
5303 return status;
5304 }
5305
5306 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005307 * The MIME type of {@link #CONTENT_URI} providing a directory of
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005308 * status update details.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005309 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005310 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005311
5312 /**
5313 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005314 * status update detail.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005315 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005316 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update";
5317 }
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07005318
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005319 /**
5320 * @deprecated This old name was never meant to be made public. Do not use.
5321 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005322 @Deprecated
5323 public static final class Presence extends StatusUpdates {
5324
Evan Millar088b2912009-05-28 15:24:37 -07005325 }
5326
5327 /**
Yorke Lee8d370092014-06-26 10:32:17 -07005328 * Additional column returned by
5329 * {@link ContactsContract.Contacts#CONTENT_FILTER_URI Contacts.CONTENT_FILTER_URI} explaining
Yorke Leeeaf094932014-07-01 10:28:56 -07005330 * why the filter matched the contact. This column will contain extracts from the contact's
5331 * constituent {@link Data Data} items, formatted in a way that indicates the section of the
5332 * snippet that matched the filter.
5333 *
5334 * <p>
5335 * The following example searches for all contacts that match the query "presi" and requests
5336 * the snippet column as well.
5337 * <pre>
5338 * Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon();
5339 * builder.appendPath("presi");
5340 * // Defer snippeting to the client side if possible, for performance reasons.
5341 * builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1");
5342 *
5343 * Cursor cursor = getContentResolver().query(builder.build());
5344 *
5345 * Bundle extras = cursor.getExtras();
5346 * if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) {
5347 * // Do our own snippet formatting.
5348 * // For a contact with the email address (president@organization.com), the snippet
5349 * // column will contain the string "president@organization.com".
5350 * } else {
5351 * // The snippet has already been pre-formatted, we can display it as is.
5352 * // For a contact with the email address (president@organization.com), the snippet
5353 * // column will contain the string "[presi]dent@organization.com".
5354 * }
5355 * </pre>
5356 * </p>
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005357 */
Yorke Leeeaf094932014-07-01 10:28:56 -07005358 public static class SearchSnippets {
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005359
5360 /**
Yorke Leeeaf094932014-07-01 10:28:56 -07005361 * The search snippet constructed by SQLite snippeting functionality.
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005362 * <p>
Yorke Leeeaf094932014-07-01 10:28:56 -07005363 * The snippet may contain (parts of) several data elements belonging to the contact,
5364 * with the matching parts optionally surrounded by special characters that indicate the
5365 * start and end of matching text.
5366 *
5367 * For example, if a contact has an address "123 Main Street", using a filter "mai" would
5368 * return the formatted snippet "123 [Mai]n street".
5369 *
5370 * @see <a href="http://www.sqlite.org/fts3.html#snippet">
5371 * http://www.sqlite.org/fts3.html#snippet</a>
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005372 */
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005373 public static final String SNIPPET = "snippet";
5374
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005375 /**
5376 * Comma-separated parameters for the generation of the snippet:
5377 * <ul>
Yorke Leeeaf094932014-07-01 10:28:56 -07005378 * <li>The "start match" text. Default is '['</li>
5379 * <li>The "end match" text. Default is ']'</li>
5380 * <li>The "ellipsis" text. Default is "..."</li>
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005381 * <li>Maximum number of tokens to include in the snippet. Can be either
5382 * a positive or a negative number: A positive number indicates how many
5383 * tokens can be returned in total. A negative number indicates how many
5384 * tokens can be returned per occurrence of the search terms.</li>
5385 * </ul>
Yorke Leeeaf094932014-07-01 10:28:56 -07005386 *
5387 * @hide
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005388 */
5389 public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args";
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -07005390
5391 /**
Yorke Leeeaf094932014-07-01 10:28:56 -07005392 * The key to ask the provider to defer the formatting of the snippet to the client if
5393 * possible, for performance reasons.
5394 * A value of 1 indicates true, 0 indicates false. False is the default.
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -07005395 * When a cursor is returned to the client, it should check for an extra with the name
5396 * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client
Yorke Leeeaf094932014-07-01 10:28:56 -07005397 * should do its own formatting of the snippet. If it doesn't exist, the snippet column
5398 * in the cursor should already contain a formatted snippet.
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -07005399 */
5400 public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting";
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005401 }
5402
5403 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005404 * Container for definitions of common data types stored in the {@link ContactsContract.Data}
5405 * table.
Evan Millar088b2912009-05-28 15:24:37 -07005406 */
5407 public static final class CommonDataKinds {
5408 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005409 * This utility class cannot be instantiated
5410 */
5411 private CommonDataKinds() {}
5412
5413 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005414 * The {@link Data#RES_PACKAGE} value for common data that should be
5415 * shown using a default style.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005416 *
5417 * @hide RES_PACKAGE is hidden
Evan Millar088b2912009-05-28 15:24:37 -07005418 */
5419 public static final String PACKAGE_COMMON = "common";
5420
5421 /**
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07005422 * The base types that all "Typed" data kinds support.
5423 */
5424 public interface BaseTypes {
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07005425 /**
5426 * A custom type. The custom label should be supplied by user.
5427 */
5428 public static int TYPE_CUSTOM = 0;
5429 }
5430
5431 /**
Evan Millar088b2912009-05-28 15:24:37 -07005432 * Columns common across the specific types.
5433 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07005434 protected interface CommonColumns extends BaseTypes {
Evan Millar088b2912009-05-28 15:24:37 -07005435 /**
Evan Millar088b2912009-05-28 15:24:37 -07005436 * The data for the contact method.
5437 * <P>Type: TEXT</P>
5438 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005439 public static final String DATA = DataColumns.DATA1;
5440
5441 /**
5442 * The type of data, for example Home or Work.
5443 * <P>Type: INTEGER</P>
5444 */
5445 public static final String TYPE = DataColumns.DATA2;
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07005446
5447 /**
5448 * The user defined label for the the contact method.
5449 * <P>Type: TEXT</P>
5450 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005451 public static final String LABEL = DataColumns.DATA3;
Evan Millar088b2912009-05-28 15:24:37 -07005452 }
5453
5454 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005455 * A data kind representing the contact's proper name. You can use all
5456 * columns defined for {@link ContactsContract.Data} as well as the following aliases.
5457 *
5458 * <h2>Column aliases</h2>
5459 * <table class="jd-sumtable">
5460 * <tr>
5461 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
5462 * </tr>
5463 * <tr>
5464 * <td>String</td>
5465 * <td>{@link #DISPLAY_NAME}</td>
5466 * <td>{@link #DATA1}</td>
5467 * <td></td>
5468 * </tr>
5469 * <tr>
5470 * <td>String</td>
5471 * <td>{@link #GIVEN_NAME}</td>
5472 * <td>{@link #DATA2}</td>
5473 * <td></td>
5474 * </tr>
5475 * <tr>
5476 * <td>String</td>
5477 * <td>{@link #FAMILY_NAME}</td>
5478 * <td>{@link #DATA3}</td>
5479 * <td></td>
5480 * </tr>
5481 * <tr>
5482 * <td>String</td>
5483 * <td>{@link #PREFIX}</td>
5484 * <td>{@link #DATA4}</td>
5485 * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td>
5486 * </tr>
5487 * <tr>
5488 * <td>String</td>
5489 * <td>{@link #MIDDLE_NAME}</td>
5490 * <td>{@link #DATA5}</td>
5491 * <td></td>
5492 * </tr>
5493 * <tr>
5494 * <td>String</td>
5495 * <td>{@link #SUFFIX}</td>
5496 * <td>{@link #DATA6}</td>
5497 * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td>
5498 * </tr>
5499 * <tr>
5500 * <td>String</td>
5501 * <td>{@link #PHONETIC_GIVEN_NAME}</td>
5502 * <td>{@link #DATA7}</td>
5503 * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td>
5504 * </tr>
5505 * <tr>
5506 * <td>String</td>
5507 * <td>{@link #PHONETIC_MIDDLE_NAME}</td>
5508 * <td>{@link #DATA8}</td>
5509 * <td></td>
5510 * </tr>
5511 * <tr>
5512 * <td>String</td>
5513 * <td>{@link #PHONETIC_FAMILY_NAME}</td>
5514 * <td>{@link #DATA9}</td>
5515 * <td></td>
5516 * </tr>
5517 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005518 */
Yorke Lee94c87612014-07-18 18:57:17 -07005519 public static final class StructuredName implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005520 /**
5521 * This utility class cannot be instantiated
5522 */
Evan Millar088b2912009-05-28 15:24:37 -07005523 private StructuredName() {}
5524
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005525 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07005526 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
5527
5528 /**
Evan Millar088b2912009-05-28 15:24:37 -07005529 * The name that should be used to display the contact.
Jeff Sharkey62b83b72009-08-11 17:33:48 -07005530 * <i>Unstructured component of the name should be consistent with
5531 * its structured representation.</i>
5532 * <p>
5533 * Type: TEXT
Evan Millar088b2912009-05-28 15:24:37 -07005534 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005535 public static final String DISPLAY_NAME = DATA1;
5536
5537 /**
5538 * The given name for the contact.
5539 * <P>Type: TEXT</P>
5540 */
5541 public static final String GIVEN_NAME = DATA2;
5542
5543 /**
5544 * The family name for the contact.
5545 * <P>Type: TEXT</P>
5546 */
5547 public static final String FAMILY_NAME = DATA3;
5548
5549 /**
5550 * The contact's honorific prefix, e.g. "Sir"
5551 * <P>Type: TEXT</P>
5552 */
5553 public static final String PREFIX = DATA4;
5554
5555 /**
5556 * The contact's middle name
5557 * <P>Type: TEXT</P>
5558 */
5559 public static final String MIDDLE_NAME = DATA5;
5560
5561 /**
5562 * The contact's honorific suffix, e.g. "Jr"
5563 */
5564 public static final String SUFFIX = DATA6;
5565
5566 /**
5567 * The phonetic version of the given name for the contact.
5568 * <P>Type: TEXT</P>
5569 */
5570 public static final String PHONETIC_GIVEN_NAME = DATA7;
5571
5572 /**
5573 * The phonetic version of the additional name for the contact.
5574 * <P>Type: TEXT</P>
5575 */
5576 public static final String PHONETIC_MIDDLE_NAME = DATA8;
5577
5578 /**
5579 * The phonetic version of the family name for the contact.
5580 * <P>Type: TEXT</P>
5581 */
5582 public static final String PHONETIC_FAMILY_NAME = DATA9;
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08005583
5584 /**
5585 * The style used for combining given/middle/family name into a full name.
5586 * See {@link ContactsContract.FullNameStyle}.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08005587 */
5588 public static final String FULL_NAME_STYLE = DATA10;
5589
5590 /**
5591 * The alphabet used for capturing the phonetic name.
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08005592 * See ContactsContract.PhoneticNameStyle.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08005593 * @hide
5594 */
5595 public static final String PHONETIC_NAME_STYLE = DATA11;
Evan Millar088b2912009-05-28 15:24:37 -07005596 }
5597
5598 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005599 * <p>A data kind representing the contact's nickname. For example, for
5600 * Bob Parr ("Mr. Incredible"):
5601 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07005602 * ArrayList&lt;ContentProviderOperation&gt; ops =
5603 * new ArrayList&lt;ContentProviderOperation&gt;();
5604 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005605 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
5606 * .withValue(Data.RAW_CONTACT_ID, rawContactId)
5607 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
5608 * .withValue(StructuredName.DISPLAY_NAME, &quot;Bob Parr&quot;)
5609 * .build());
5610 *
5611 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
5612 * .withValue(Data.RAW_CONTACT_ID, rawContactId)
5613 * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE)
5614 * .withValue(Nickname.NAME, "Mr. Incredible")
5615 * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM)
5616 * .withValue(Nickname.LABEL, "Superhero")
5617 * .build());
5618 *
5619 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
5620 * </pre>
5621 * </p>
5622 * <p>
5623 * You can use all columns defined for {@link ContactsContract.Data} as well as the
5624 * following aliases.
5625 * </p>
5626 *
5627 * <h2>Column aliases</h2>
5628 * <table class="jd-sumtable">
5629 * <tr>
5630 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
5631 * </tr>
5632 * <tr>
5633 * <td>String</td>
5634 * <td>{@link #NAME}</td>
5635 * <td>{@link #DATA1}</td>
5636 * <td></td>
5637 * </tr>
5638 * <tr>
5639 * <td>int</td>
5640 * <td>{@link #TYPE}</td>
5641 * <td>{@link #DATA2}</td>
5642 * <td>
5643 * Allowed values are:
5644 * <p>
5645 * <ul>
5646 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
5647 * <li>{@link #TYPE_DEFAULT}</li>
5648 * <li>{@link #TYPE_OTHER_NAME}</li>
David Brown747c6152010-09-15 13:34:13 -07005649 * <li>{@link #TYPE_MAIDEN_NAME}</li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005650 * <li>{@link #TYPE_SHORT_NAME}</li>
5651 * <li>{@link #TYPE_INITIALS}</li>
5652 * </ul>
5653 * </p>
5654 * </td>
5655 * </tr>
5656 * <tr>
5657 * <td>String</td>
5658 * <td>{@link #LABEL}</td>
5659 * <td>{@link #DATA3}</td>
5660 * <td></td>
5661 * </tr>
5662 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005663 */
Yorke Lee94c87612014-07-18 18:57:17 -07005664 public static final class Nickname implements DataColumnsWithJoins, CommonColumns,
5665 ContactCounts{
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005666 /**
5667 * This utility class cannot be instantiated
5668 */
Evan Millar088b2912009-05-28 15:24:37 -07005669 private Nickname() {}
5670
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005671 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07005672 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
5673
Evan Millar78e79ad2009-06-08 10:24:44 -07005674 public static final int TYPE_DEFAULT = 1;
5675 public static final int TYPE_OTHER_NAME = 2;
David Brown747c6152010-09-15 13:34:13 -07005676 public static final int TYPE_MAIDEN_NAME = 3;
5677 /** @deprecated Use TYPE_MAIDEN_NAME instead. */
5678 @Deprecated
Evan Millar78e79ad2009-06-08 10:24:44 -07005679 public static final int TYPE_MAINDEN_NAME = 3;
5680 public static final int TYPE_SHORT_NAME = 4;
5681 public static final int TYPE_INITIALS = 5;
Evan Millar088b2912009-05-28 15:24:37 -07005682
5683 /**
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07005684 * The name itself
5685 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07005686 public static final String NAME = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07005687 }
5688
5689 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005690 * <p>
5691 * A data kind representing a telephone number.
5692 * </p>
5693 * <p>
5694 * You can use all columns defined for {@link ContactsContract.Data} as
5695 * well as the following aliases.
5696 * </p>
5697 * <h2>Column aliases</h2>
5698 * <table class="jd-sumtable">
5699 * <tr>
5700 * <th>Type</th>
5701 * <th>Alias</th><th colspan='2'>Data column</th>
5702 * </tr>
5703 * <tr>
5704 * <td>String</td>
5705 * <td>{@link #NUMBER}</td>
5706 * <td>{@link #DATA1}</td>
5707 * <td></td>
5708 * </tr>
5709 * <tr>
5710 * <td>int</td>
5711 * <td>{@link #TYPE}</td>
5712 * <td>{@link #DATA2}</td>
5713 * <td>Allowed values are:
5714 * <p>
5715 * <ul>
5716 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
5717 * <li>{@link #TYPE_HOME}</li>
5718 * <li>{@link #TYPE_MOBILE}</li>
5719 * <li>{@link #TYPE_WORK}</li>
5720 * <li>{@link #TYPE_FAX_WORK}</li>
5721 * <li>{@link #TYPE_FAX_HOME}</li>
5722 * <li>{@link #TYPE_PAGER}</li>
5723 * <li>{@link #TYPE_OTHER}</li>
5724 * <li>{@link #TYPE_CALLBACK}</li>
5725 * <li>{@link #TYPE_CAR}</li>
5726 * <li>{@link #TYPE_COMPANY_MAIN}</li>
5727 * <li>{@link #TYPE_ISDN}</li>
5728 * <li>{@link #TYPE_MAIN}</li>
5729 * <li>{@link #TYPE_OTHER_FAX}</li>
5730 * <li>{@link #TYPE_RADIO}</li>
5731 * <li>{@link #TYPE_TELEX}</li>
5732 * <li>{@link #TYPE_TTY_TDD}</li>
5733 * <li>{@link #TYPE_WORK_MOBILE}</li>
5734 * <li>{@link #TYPE_WORK_PAGER}</li>
5735 * <li>{@link #TYPE_ASSISTANT}</li>
5736 * <li>{@link #TYPE_MMS}</li>
5737 * </ul>
5738 * </p>
5739 * </td>
5740 * </tr>
5741 * <tr>
5742 * <td>String</td>
5743 * <td>{@link #LABEL}</td>
5744 * <td>{@link #DATA3}</td>
5745 * <td></td>
5746 * </tr>
5747 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005748 */
Yorke Lee94c87612014-07-18 18:57:17 -07005749 public static final class Phone implements DataColumnsWithJoins, CommonColumns,
5750 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005751 /**
5752 * This utility class cannot be instantiated
5753 */
Evan Millar088b2912009-05-28 15:24:37 -07005754 private Phone() {}
5755
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005756 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07005757 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
Evan Millar088b2912009-05-28 15:24:37 -07005758
Evan Millar161dd862009-06-12 16:02:43 -07005759 /**
5760 * The MIME type of {@link #CONTENT_URI} providing a directory of
5761 * phones.
5762 */
Evan Millarb3c49982009-09-01 11:38:04 -07005763 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
Evan Millar161dd862009-06-12 16:02:43 -07005764
5765 /**
5766 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005767 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07005768 * associated raw contact and aggregate contact data.
Evan Millar161dd862009-06-12 16:02:43 -07005769 */
5770 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
5771 "phones");
5772
5773 /**
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005774 * The content:// style URL for phone lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005775 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005776 * to display names as well as phone numbers. The filter argument should be passed
5777 * as an additional path segment after this URI.
Evan Millar161dd862009-06-12 16:02:43 -07005778 */
5779 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
5780 "filter");
5781
Daniel Lehmann1024de52012-06-15 20:32:33 -07005782 /**
5783 * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}.
5784 * If "1" or "true", display names are searched. If "0" or "false", display names
5785 * are not searched. Default is "1".
5786 */
5787 public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name";
5788
5789 /**
5790 * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}.
5791 * If "1" or "true", phone numbers are searched. If "0" or "false", phone numbers
5792 * are not searched. Default is "1".
5793 */
5794 public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number";
5795
Evan Millar088b2912009-05-28 15:24:37 -07005796 public static final int TYPE_HOME = 1;
5797 public static final int TYPE_MOBILE = 2;
5798 public static final int TYPE_WORK = 3;
5799 public static final int TYPE_FAX_WORK = 4;
5800 public static final int TYPE_FAX_HOME = 5;
5801 public static final int TYPE_PAGER = 6;
5802 public static final int TYPE_OTHER = 7;
Fred Quintana3f867152009-08-03 11:43:16 -07005803 public static final int TYPE_CALLBACK = 8;
5804 public static final int TYPE_CAR = 9;
5805 public static final int TYPE_COMPANY_MAIN = 10;
5806 public static final int TYPE_ISDN = 11;
5807 public static final int TYPE_MAIN = 12;
5808 public static final int TYPE_OTHER_FAX = 13;
5809 public static final int TYPE_RADIO = 14;
5810 public static final int TYPE_TELEX = 15;
5811 public static final int TYPE_TTY_TDD = 16;
5812 public static final int TYPE_WORK_MOBILE = 17;
5813 public static final int TYPE_WORK_PAGER = 18;
5814 public static final int TYPE_ASSISTANT = 19;
Jeff Sharkeyd5abd462009-09-16 19:54:29 -07005815 public static final int TYPE_MMS = 20;
Evan Millar088b2912009-05-28 15:24:37 -07005816
5817 /**
5818 * The phone number as the user entered it.
5819 * <P>Type: TEXT</P>
5820 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07005821 public static final String NUMBER = DATA;
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005822
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005823 /**
Daniel Lehmanndb919152012-03-09 14:30:50 -08005824 * The phone number's E164 representation. This value can be omitted in which
Makoto Onukie5420e92012-04-25 13:24:41 -07005825 * case the provider will try to automatically infer it. (It'll be left null if the
5826 * provider fails to infer.)
5827 * If present, {@link #NUMBER} has to be set as well (it will be ignored otherwise).
Bai Tao224744c2010-08-31 09:59:13 +08005828 * <P>Type: TEXT</P>
Bai Tao224744c2010-08-31 09:59:13 +08005829 */
5830 public static final String NORMALIZED_NUMBER = DATA4;
5831
5832 /**
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005833 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005834 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005835 */
5836 @Deprecated
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005837 public static final CharSequence getDisplayLabel(Context context, int type,
5838 CharSequence label, CharSequence[] labelArray) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005839 return getTypeLabel(context.getResources(), type, label);
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005840 }
5841
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005842 /**
5843 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005844 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005845 */
5846 @Deprecated
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005847 public static final CharSequence getDisplayLabel(Context context, int type,
5848 CharSequence label) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005849 return getTypeLabel(context.getResources(), type, label);
5850 }
5851
5852 /**
5853 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005854 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005855 */
5856 public static final int getTypeLabelResource(int type) {
5857 switch (type) {
5858 case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome;
5859 case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile;
5860 case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork;
5861 case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork;
5862 case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome;
5863 case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager;
5864 case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther;
5865 case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback;
5866 case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar;
5867 case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain;
5868 case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn;
5869 case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain;
5870 case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax;
5871 case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio;
5872 case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex;
5873 case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd;
5874 case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile;
5875 case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager;
5876 case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant;
5877 case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms;
5878 default: return com.android.internal.R.string.phoneTypeCustom;
5879 }
5880 }
5881
5882 /**
5883 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005884 * possibly substituting the given {@link #LABEL} value
5885 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07005886 */
5887 public static final CharSequence getTypeLabel(Resources res, int type,
5888 CharSequence label) {
5889 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) {
5890 return label;
5891 } else {
5892 final int labelRes = getTypeLabelResource(type);
5893 return res.getText(labelRes);
5894 }
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005895 }
Evan Millar088b2912009-05-28 15:24:37 -07005896 }
5897
5898 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005899 * <p>
5900 * A data kind representing an email address.
5901 * </p>
5902 * <p>
5903 * You can use all columns defined for {@link ContactsContract.Data} as
5904 * well as the following aliases.
5905 * </p>
5906 * <h2>Column aliases</h2>
5907 * <table class="jd-sumtable">
5908 * <tr>
5909 * <th>Type</th>
5910 * <th>Alias</th><th colspan='2'>Data column</th>
5911 * </tr>
5912 * <tr>
5913 * <td>String</td>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07005914 * <td>{@link #ADDRESS}</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005915 * <td>{@link #DATA1}</td>
5916 * <td>Email address itself.</td>
5917 * </tr>
5918 * <tr>
5919 * <td>int</td>
5920 * <td>{@link #TYPE}</td>
5921 * <td>{@link #DATA2}</td>
5922 * <td>Allowed values are:
5923 * <p>
5924 * <ul>
5925 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
5926 * <li>{@link #TYPE_HOME}</li>
5927 * <li>{@link #TYPE_WORK}</li>
5928 * <li>{@link #TYPE_OTHER}</li>
5929 * <li>{@link #TYPE_MOBILE}</li>
5930 * </ul>
5931 * </p>
5932 * </td>
5933 * </tr>
5934 * <tr>
5935 * <td>String</td>
5936 * <td>{@link #LABEL}</td>
5937 * <td>{@link #DATA3}</td>
5938 * <td></td>
5939 * </tr>
5940 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005941 */
Yorke Lee94c87612014-07-18 18:57:17 -07005942 public static final class Email implements DataColumnsWithJoins, CommonColumns,
5943 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005944 /**
5945 * This utility class cannot be instantiated
5946 */
Evan Millar088b2912009-05-28 15:24:37 -07005947 private Email() {}
5948
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005949 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07005950 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2";
Evan Millar088b2912009-05-28 15:24:37 -07005951
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005952 /**
Dmitri Plotnikovabf15c32009-09-18 20:29:11 -07005953 * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses.
5954 */
5955 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2";
5956
5957 /**
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005958 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005959 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005960 * associated raw contact and aggregate contact data.
5961 */
5962 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
5963 "emails");
5964
5965 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005966 * <p>
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005967 * The content:// style URL for looking up data rows by email address. The
5968 * lookup argument, an email address, should be passed as an additional path segment
5969 * after this URI.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005970 * </p>
5971 * <p>Example:
5972 * <pre>
5973 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email));
5974 * Cursor c = getContentResolver().query(uri,
5975 * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA},
5976 * null, null, null);
5977 * </pre>
5978 * </p>
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005979 */
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005980 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
5981 "lookup");
5982
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005983 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005984 * <p>
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005985 * The content:// style URL for email lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05005986 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005987 * to display names as well as email addresses. The filter argument should be passed
5988 * as an additional path segment after this URI.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005989 * </p>
5990 * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)"
5991 * as well as "Bob Parr (incredible@android.com)".
5992 * <pre>
5993 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob"));
5994 * Cursor c = getContentResolver().query(uri,
5995 * new String[]{Email.DISPLAY_NAME, Email.DATA},
5996 * null, null, null);
5997 * </pre>
5998 * </p>
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07005999 */
6000 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07006001 "filter");
6002
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006003 /**
6004 * The email address.
6005 * <P>Type: TEXT</P>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006006 */
6007 public static final String ADDRESS = DATA1;
6008
Evan Millar088b2912009-05-28 15:24:37 -07006009 public static final int TYPE_HOME = 1;
6010 public static final int TYPE_WORK = 2;
6011 public static final int TYPE_OTHER = 3;
Jeff Sharkey14fb1532009-08-29 15:54:26 -07006012 public static final int TYPE_MOBILE = 4;
Fred Quintana8851e162009-08-05 21:06:45 -07006013
6014 /**
6015 * The display name for the email address
6016 * <P>Type: TEXT</P>
6017 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006018 public static final String DISPLAY_NAME = DATA4;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006019
6020 /**
6021 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006022 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006023 */
6024 public static final int getTypeLabelResource(int type) {
6025 switch (type) {
6026 case TYPE_HOME: return com.android.internal.R.string.emailTypeHome;
6027 case TYPE_WORK: return com.android.internal.R.string.emailTypeWork;
6028 case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther;
6029 case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile;
6030 default: return com.android.internal.R.string.emailTypeCustom;
6031 }
6032 }
6033
6034 /**
6035 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006036 * possibly substituting the given {@link #LABEL} value
6037 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006038 */
6039 public static final CharSequence getTypeLabel(Resources res, int type,
6040 CharSequence label) {
6041 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6042 return label;
6043 } else {
6044 final int labelRes = getTypeLabelResource(type);
6045 return res.getText(labelRes);
6046 }
6047 }
Evan Millar088b2912009-05-28 15:24:37 -07006048 }
6049
6050 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006051 * <p>
6052 * A data kind representing a postal addresses.
6053 * </p>
6054 * <p>
6055 * You can use all columns defined for {@link ContactsContract.Data} as
6056 * well as the following aliases.
6057 * </p>
6058 * <h2>Column aliases</h2>
6059 * <table class="jd-sumtable">
6060 * <tr>
6061 * <th>Type</th>
6062 * <th>Alias</th><th colspan='2'>Data column</th>
6063 * </tr>
6064 * <tr>
6065 * <td>String</td>
6066 * <td>{@link #FORMATTED_ADDRESS}</td>
6067 * <td>{@link #DATA1}</td>
6068 * <td></td>
6069 * </tr>
6070 * <tr>
6071 * <td>int</td>
6072 * <td>{@link #TYPE}</td>
6073 * <td>{@link #DATA2}</td>
6074 * <td>Allowed values are:
6075 * <p>
6076 * <ul>
6077 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6078 * <li>{@link #TYPE_HOME}</li>
6079 * <li>{@link #TYPE_WORK}</li>
6080 * <li>{@link #TYPE_OTHER}</li>
6081 * </ul>
6082 * </p>
6083 * </td>
6084 * </tr>
6085 * <tr>
6086 * <td>String</td>
6087 * <td>{@link #LABEL}</td>
6088 * <td>{@link #DATA3}</td>
6089 * <td></td>
6090 * </tr>
6091 * <tr>
6092 * <td>String</td>
6093 * <td>{@link #STREET}</td>
6094 * <td>{@link #DATA4}</td>
6095 * <td></td>
6096 * </tr>
6097 * <tr>
6098 * <td>String</td>
6099 * <td>{@link #POBOX}</td>
6100 * <td>{@link #DATA5}</td>
6101 * <td>Post Office Box number</td>
6102 * </tr>
6103 * <tr>
6104 * <td>String</td>
6105 * <td>{@link #NEIGHBORHOOD}</td>
6106 * <td>{@link #DATA6}</td>
6107 * <td></td>
6108 * </tr>
6109 * <tr>
6110 * <td>String</td>
6111 * <td>{@link #CITY}</td>
6112 * <td>{@link #DATA7}</td>
6113 * <td></td>
6114 * </tr>
6115 * <tr>
6116 * <td>String</td>
6117 * <td>{@link #REGION}</td>
6118 * <td>{@link #DATA8}</td>
6119 * <td></td>
6120 * </tr>
6121 * <tr>
6122 * <td>String</td>
6123 * <td>{@link #POSTCODE}</td>
6124 * <td>{@link #DATA9}</td>
6125 * <td></td>
6126 * </tr>
6127 * <tr>
6128 * <td>String</td>
6129 * <td>{@link #COUNTRY}</td>
6130 * <td>{@link #DATA10}</td>
6131 * <td></td>
6132 * </tr>
6133 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006134 */
Yorke Lee94c87612014-07-18 18:57:17 -07006135 public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns,
6136 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006137 /**
6138 * This utility class cannot be instantiated
6139 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006140 private StructuredPostal() {
6141 }
Evan Millar088b2912009-05-28 15:24:37 -07006142
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006143 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07006144 public static final String CONTENT_ITEM_TYPE =
6145 "vnd.android.cursor.item/postal-address_v2";
Evan Millar088b2912009-05-28 15:24:37 -07006146
Evan Millar161dd862009-06-12 16:02:43 -07006147 /**
6148 * The MIME type of {@link #CONTENT_URI} providing a directory of
6149 * postal addresses.
6150 */
Evan Millarb3c49982009-09-01 11:38:04 -07006151 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2";
Evan Millar161dd862009-06-12 16:02:43 -07006152
6153 /**
6154 * The content:// style URI for all data records of the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006155 * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
Evan Millar161dd862009-06-12 16:02:43 -07006156 */
6157 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
6158 "postals");
6159
Evan Millar088b2912009-05-28 15:24:37 -07006160 public static final int TYPE_HOME = 1;
6161 public static final int TYPE_WORK = 2;
6162 public static final int TYPE_OTHER = 3;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006163
6164 /**
Jeff Sharkey62b83b72009-08-11 17:33:48 -07006165 * The full, unstructured postal address. <i>This field must be
6166 * consistent with any structured data.</i>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006167 * <p>
6168 * Type: TEXT
6169 */
6170 public static final String FORMATTED_ADDRESS = DATA;
6171
6172 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006173 * Can be street, avenue, road, etc. This element also includes the
6174 * house number and room/apartment/flat/floor number.
6175 * <p>
6176 * Type: TEXT
6177 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006178 public static final String STREET = DATA4;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006179
6180 /**
6181 * Covers actual P.O. boxes, drawers, locked bags, etc. This is
6182 * usually but not always mutually exclusive with street.
6183 * <p>
6184 * Type: TEXT
6185 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006186 public static final String POBOX = DATA5;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006187
6188 /**
6189 * This is used to disambiguate a street address when a city
6190 * contains more than one street with the same name, or to specify a
6191 * small place whose mail is routed through a larger postal town. In
6192 * China it could be a county or a minor city.
6193 * <p>
6194 * Type: TEXT
6195 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006196 public static final String NEIGHBORHOOD = DATA6;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006197
6198 /**
6199 * Can be city, village, town, borough, etc. This is the postal town
6200 * and not necessarily the place of residence or place of business.
6201 * <p>
6202 * Type: TEXT
6203 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006204 public static final String CITY = DATA7;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006205
6206 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006207 * A state, province, county (in Ireland), Land (in Germany),
6208 * departement (in France), etc.
6209 * <p>
6210 * Type: TEXT
6211 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006212 public static final String REGION = DATA8;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006213
6214 /**
Jeff Sharkeyef348c72009-07-26 14:14:34 -07006215 * Postal code. Usually country-wide, but sometimes specific to the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006216 * city (e.g. "2" in "Dublin 2, Ireland" addresses).
6217 * <p>
6218 * Type: TEXT
6219 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006220 public static final String POSTCODE = DATA9;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006221
6222 /**
6223 * The name or code of the country.
6224 * <p>
6225 * Type: TEXT
6226 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006227 public static final String COUNTRY = DATA10;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006228
6229 /**
6230 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006231 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006232 */
6233 public static final int getTypeLabelResource(int type) {
6234 switch (type) {
6235 case TYPE_HOME: return com.android.internal.R.string.postalTypeHome;
6236 case TYPE_WORK: return com.android.internal.R.string.postalTypeWork;
6237 case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther;
6238 default: return com.android.internal.R.string.postalTypeCustom;
6239 }
6240 }
6241
6242 /**
6243 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006244 * possibly substituting the given {@link #LABEL} value
6245 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006246 */
6247 public static final CharSequence getTypeLabel(Resources res, int type,
6248 CharSequence label) {
6249 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6250 return label;
6251 } else {
6252 final int labelRes = getTypeLabelResource(type);
6253 return res.getText(labelRes);
6254 }
6255 }
Evan Millar088b2912009-05-28 15:24:37 -07006256 }
6257
Fred Quintana8851e162009-08-05 21:06:45 -07006258 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006259 * <p>
6260 * A data kind representing an IM address
6261 * </p>
6262 * <p>
6263 * You can use all columns defined for {@link ContactsContract.Data} as
6264 * well as the following aliases.
6265 * </p>
6266 * <h2>Column aliases</h2>
6267 * <table class="jd-sumtable">
6268 * <tr>
6269 * <th>Type</th>
6270 * <th>Alias</th><th colspan='2'>Data column</th>
6271 * </tr>
6272 * <tr>
6273 * <td>String</td>
6274 * <td>{@link #DATA}</td>
6275 * <td>{@link #DATA1}</td>
6276 * <td></td>
6277 * </tr>
6278 * <tr>
6279 * <td>int</td>
6280 * <td>{@link #TYPE}</td>
6281 * <td>{@link #DATA2}</td>
6282 * <td>Allowed values are:
6283 * <p>
6284 * <ul>
6285 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6286 * <li>{@link #TYPE_HOME}</li>
6287 * <li>{@link #TYPE_WORK}</li>
6288 * <li>{@link #TYPE_OTHER}</li>
6289 * </ul>
6290 * </p>
6291 * </td>
6292 * </tr>
6293 * <tr>
6294 * <td>String</td>
6295 * <td>{@link #LABEL}</td>
6296 * <td>{@link #DATA3}</td>
6297 * <td></td>
6298 * </tr>
6299 * <tr>
6300 * <td>String</td>
6301 * <td>{@link #PROTOCOL}</td>
6302 * <td>{@link #DATA5}</td>
6303 * <td>
6304 * <p>
6305 * Allowed values:
6306 * <ul>
6307 * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name
6308 * as {@link #CUSTOM_PROTOCOL}.</li>
6309 * <li>{@link #PROTOCOL_AIM}</li>
6310 * <li>{@link #PROTOCOL_MSN}</li>
6311 * <li>{@link #PROTOCOL_YAHOO}</li>
6312 * <li>{@link #PROTOCOL_SKYPE}</li>
6313 * <li>{@link #PROTOCOL_QQ}</li>
6314 * <li>{@link #PROTOCOL_GOOGLE_TALK}</li>
6315 * <li>{@link #PROTOCOL_ICQ}</li>
6316 * <li>{@link #PROTOCOL_JABBER}</li>
6317 * <li>{@link #PROTOCOL_NETMEETING}</li>
6318 * </ul>
6319 * </p>
6320 * </td>
6321 * </tr>
6322 * <tr>
6323 * <td>String</td>
6324 * <td>{@link #CUSTOM_PROTOCOL}</td>
6325 * <td>{@link #DATA6}</td>
6326 * <td></td>
6327 * </tr>
6328 * </table>
Fred Quintana8851e162009-08-05 21:06:45 -07006329 */
Yorke Lee94c87612014-07-18 18:57:17 -07006330 public static final class Im implements DataColumnsWithJoins, CommonColumns, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006331 /**
6332 * This utility class cannot be instantiated
6333 */
Evan Millar088b2912009-05-28 15:24:37 -07006334 private Im() {}
6335
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006336 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07006337 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
6338
Evan Millar088b2912009-05-28 15:24:37 -07006339 public static final int TYPE_HOME = 1;
6340 public static final int TYPE_WORK = 2;
6341 public static final int TYPE_OTHER = 3;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07006342
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07006343 /**
6344 * This column should be populated with one of the defined
6345 * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this
6346 * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL}
6347 * should contain the name of the custom protocol.
6348 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006349 public static final String PROTOCOL = DATA5;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07006350
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006351 public static final String CUSTOM_PROTOCOL = DATA6;
Jeff Sharkey732da922009-07-30 09:59:31 -07006352
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07006353 /*
6354 * The predefined IM protocol types.
Evan Millar088b2912009-05-28 15:24:37 -07006355 */
Jeff Sharkey732da922009-07-30 09:59:31 -07006356 public static final int PROTOCOL_CUSTOM = -1;
Evan Millar088b2912009-05-28 15:24:37 -07006357 public static final int PROTOCOL_AIM = 0;
6358 public static final int PROTOCOL_MSN = 1;
6359 public static final int PROTOCOL_YAHOO = 2;
6360 public static final int PROTOCOL_SKYPE = 3;
6361 public static final int PROTOCOL_QQ = 4;
6362 public static final int PROTOCOL_GOOGLE_TALK = 5;
6363 public static final int PROTOCOL_ICQ = 6;
6364 public static final int PROTOCOL_JABBER = 7;
Fred Quintana8851e162009-08-05 21:06:45 -07006365 public static final int PROTOCOL_NETMEETING = 8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006366
6367 /**
6368 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006369 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006370 */
6371 public static final int getTypeLabelResource(int type) {
6372 switch (type) {
6373 case TYPE_HOME: return com.android.internal.R.string.imTypeHome;
6374 case TYPE_WORK: return com.android.internal.R.string.imTypeWork;
6375 case TYPE_OTHER: return com.android.internal.R.string.imTypeOther;
6376 default: return com.android.internal.R.string.imTypeCustom;
6377 }
6378 }
6379
6380 /**
6381 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006382 * possibly substituting the given {@link #LABEL} value
6383 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006384 */
6385 public static final CharSequence getTypeLabel(Resources res, int type,
6386 CharSequence label) {
6387 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6388 return label;
6389 } else {
6390 final int labelRes = getTypeLabelResource(type);
6391 return res.getText(labelRes);
6392 }
6393 }
6394
6395 /**
6396 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006397 * {@link #PROTOCOL}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006398 */
6399 public static final int getProtocolLabelResource(int type) {
6400 switch (type) {
6401 case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim;
6402 case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn;
6403 case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo;
6404 case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype;
6405 case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq;
6406 case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk;
6407 case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq;
6408 case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber;
6409 case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting;
6410 default: return com.android.internal.R.string.imProtocolCustom;
6411 }
6412 }
6413
6414 /**
6415 * Return a {@link CharSequence} that best describes the given
6416 * protocol, possibly substituting the given
6417 * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}.
6418 */
6419 public static final CharSequence getProtocolLabel(Resources res, int type,
6420 CharSequence label) {
6421 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) {
6422 return label;
6423 } else {
6424 final int labelRes = getProtocolLabelResource(type);
6425 return res.getText(labelRes);
6426 }
6427 }
Evan Millar088b2912009-05-28 15:24:37 -07006428 }
6429
6430 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006431 * <p>
6432 * A data kind representing an organization.
6433 * </p>
6434 * <p>
6435 * You can use all columns defined for {@link ContactsContract.Data} as
6436 * well as the following aliases.
6437 * </p>
6438 * <h2>Column aliases</h2>
6439 * <table class="jd-sumtable">
6440 * <tr>
6441 * <th>Type</th>
6442 * <th>Alias</th><th colspan='2'>Data column</th>
6443 * </tr>
6444 * <tr>
6445 * <td>String</td>
6446 * <td>{@link #COMPANY}</td>
6447 * <td>{@link #DATA1}</td>
6448 * <td></td>
6449 * </tr>
6450 * <tr>
6451 * <td>int</td>
6452 * <td>{@link #TYPE}</td>
6453 * <td>{@link #DATA2}</td>
6454 * <td>Allowed values are:
6455 * <p>
6456 * <ul>
6457 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6458 * <li>{@link #TYPE_WORK}</li>
6459 * <li>{@link #TYPE_OTHER}</li>
6460 * </ul>
6461 * </p>
6462 * </td>
6463 * </tr>
6464 * <tr>
6465 * <td>String</td>
6466 * <td>{@link #LABEL}</td>
6467 * <td>{@link #DATA3}</td>
6468 * <td></td>
6469 * </tr>
6470 * <tr>
6471 * <td>String</td>
6472 * <td>{@link #TITLE}</td>
6473 * <td>{@link #DATA4}</td>
6474 * <td></td>
6475 * </tr>
6476 * <tr>
6477 * <td>String</td>
6478 * <td>{@link #DEPARTMENT}</td>
6479 * <td>{@link #DATA5}</td>
6480 * <td></td>
6481 * </tr>
6482 * <tr>
6483 * <td>String</td>
6484 * <td>{@link #JOB_DESCRIPTION}</td>
6485 * <td>{@link #DATA6}</td>
6486 * <td></td>
6487 * </tr>
6488 * <tr>
6489 * <td>String</td>
6490 * <td>{@link #SYMBOL}</td>
6491 * <td>{@link #DATA7}</td>
6492 * <td></td>
6493 * </tr>
6494 * <tr>
6495 * <td>String</td>
6496 * <td>{@link #PHONETIC_NAME}</td>
6497 * <td>{@link #DATA8}</td>
6498 * <td></td>
6499 * </tr>
6500 * <tr>
6501 * <td>String</td>
6502 * <td>{@link #OFFICE_LOCATION}</td>
6503 * <td>{@link #DATA9}</td>
6504 * <td></td>
6505 * </tr>
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08006506 * <tr>
6507 * <td>String</td>
6508 * <td>PHONETIC_NAME_STYLE</td>
6509 * <td>{@link #DATA10}</td>
6510 * <td></td>
6511 * </tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006512 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006513 */
Yorke Lee94c87612014-07-18 18:57:17 -07006514 public static final class Organization implements DataColumnsWithJoins, CommonColumns,
6515 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006516 /**
6517 * This utility class cannot be instantiated
6518 */
Evan Millar088b2912009-05-28 15:24:37 -07006519 private Organization() {}
6520
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006521 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07006522 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
6523
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07006524 public static final int TYPE_WORK = 1;
6525 public static final int TYPE_OTHER = 2;
Evan Millar088b2912009-05-28 15:24:37 -07006526
6527 /**
6528 * The company as the user entered it.
6529 * <P>Type: TEXT</P>
6530 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07006531 public static final String COMPANY = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07006532
6533 /**
6534 * The position title at this company as the user entered it.
6535 * <P>Type: TEXT</P>
6536 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006537 public static final String TITLE = DATA4;
Fred Quintana8851e162009-08-05 21:06:45 -07006538
6539 /**
6540 * The department at this company as the user entered it.
6541 * <P>Type: TEXT</P>
6542 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006543 public static final String DEPARTMENT = DATA5;
Fred Quintana8851e162009-08-05 21:06:45 -07006544
6545 /**
6546 * The job description at this company as the user entered it.
6547 * <P>Type: TEXT</P>
6548 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006549 public static final String JOB_DESCRIPTION = DATA6;
Fred Quintana8851e162009-08-05 21:06:45 -07006550
6551 /**
6552 * The symbol of this company as the user entered it.
6553 * <P>Type: TEXT</P>
6554 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006555 public static final String SYMBOL = DATA7;
Fred Quintana8851e162009-08-05 21:06:45 -07006556
6557 /**
6558 * The phonetic name of this company as the user entered it.
6559 * <P>Type: TEXT</P>
6560 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006561 public static final String PHONETIC_NAME = DATA8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006562
6563 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07006564 * The office location of this organization.
6565 * <P>Type: TEXT</P>
6566 */
6567 public static final String OFFICE_LOCATION = DATA9;
6568
6569 /**
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08006570 * The alphabet used for capturing the phonetic name.
6571 * See {@link ContactsContract.PhoneticNameStyle}.
6572 * @hide
6573 */
6574 public static final String PHONETIC_NAME_STYLE = DATA10;
6575
6576 /**
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006577 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006578 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006579 */
6580 public static final int getTypeLabelResource(int type) {
6581 switch (type) {
6582 case TYPE_WORK: return com.android.internal.R.string.orgTypeWork;
6583 case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther;
6584 default: return com.android.internal.R.string.orgTypeCustom;
6585 }
6586 }
6587
6588 /**
6589 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006590 * possibly substituting the given {@link #LABEL} value
6591 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006592 */
6593 public static final CharSequence getTypeLabel(Resources res, int type,
6594 CharSequence label) {
6595 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6596 return label;
6597 } else {
6598 final int labelRes = getTypeLabelResource(type);
6599 return res.getText(labelRes);
6600 }
6601 }
Fred Quintana8851e162009-08-05 21:06:45 -07006602 }
6603
6604 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006605 * <p>
6606 * A data kind representing a relation.
6607 * </p>
6608 * <p>
6609 * You can use all columns defined for {@link ContactsContract.Data} as
6610 * well as the following aliases.
6611 * </p>
6612 * <h2>Column aliases</h2>
6613 * <table class="jd-sumtable">
6614 * <tr>
6615 * <th>Type</th>
6616 * <th>Alias</th><th colspan='2'>Data column</th>
6617 * </tr>
6618 * <tr>
6619 * <td>String</td>
6620 * <td>{@link #NAME}</td>
6621 * <td>{@link #DATA1}</td>
6622 * <td></td>
6623 * </tr>
6624 * <tr>
6625 * <td>int</td>
6626 * <td>{@link #TYPE}</td>
6627 * <td>{@link #DATA2}</td>
6628 * <td>Allowed values are:
6629 * <p>
6630 * <ul>
6631 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6632 * <li>{@link #TYPE_ASSISTANT}</li>
6633 * <li>{@link #TYPE_BROTHER}</li>
6634 * <li>{@link #TYPE_CHILD}</li>
6635 * <li>{@link #TYPE_DOMESTIC_PARTNER}</li>
6636 * <li>{@link #TYPE_FATHER}</li>
6637 * <li>{@link #TYPE_FRIEND}</li>
6638 * <li>{@link #TYPE_MANAGER}</li>
6639 * <li>{@link #TYPE_MOTHER}</li>
6640 * <li>{@link #TYPE_PARENT}</li>
6641 * <li>{@link #TYPE_PARTNER}</li>
6642 * <li>{@link #TYPE_REFERRED_BY}</li>
6643 * <li>{@link #TYPE_RELATIVE}</li>
6644 * <li>{@link #TYPE_SISTER}</li>
6645 * <li>{@link #TYPE_SPOUSE}</li>
6646 * </ul>
6647 * </p>
6648 * </td>
6649 * </tr>
6650 * <tr>
6651 * <td>String</td>
6652 * <td>{@link #LABEL}</td>
6653 * <td>{@link #DATA3}</td>
6654 * <td></td>
6655 * </tr>
6656 * </table>
Fred Quintana8851e162009-08-05 21:06:45 -07006657 */
Yorke Lee94c87612014-07-18 18:57:17 -07006658 public static final class Relation implements DataColumnsWithJoins, CommonColumns,
6659 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006660 /**
6661 * This utility class cannot be instantiated
6662 */
Fred Quintana8851e162009-08-05 21:06:45 -07006663 private Relation() {}
6664
6665 /** MIME type used when storing this in data table. */
6666 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
6667
6668 public static final int TYPE_ASSISTANT = 1;
6669 public static final int TYPE_BROTHER = 2;
6670 public static final int TYPE_CHILD = 3;
6671 public static final int TYPE_DOMESTIC_PARTNER = 4;
6672 public static final int TYPE_FATHER = 5;
6673 public static final int TYPE_FRIEND = 6;
6674 public static final int TYPE_MANAGER = 7;
6675 public static final int TYPE_MOTHER = 8;
6676 public static final int TYPE_PARENT = 9;
6677 public static final int TYPE_PARTNER = 10;
6678 public static final int TYPE_REFERRED_BY = 11;
6679 public static final int TYPE_RELATIVE = 12;
6680 public static final int TYPE_SISTER = 13;
6681 public static final int TYPE_SPOUSE = 14;
6682
6683 /**
6684 * The name of the relative as the user entered it.
6685 * <P>Type: TEXT</P>
6686 */
6687 public static final String NAME = DATA;
Daniel Lehmann1fb39f02010-10-28 13:40:38 -07006688
6689 /**
6690 * Return the string resource that best describes the given
6691 * {@link #TYPE}. Will always return a valid resource.
6692 */
6693 public static final int getTypeLabelResource(int type) {
6694 switch (type) {
6695 case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant;
6696 case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother;
6697 case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild;
6698 case TYPE_DOMESTIC_PARTNER:
6699 return com.android.internal.R.string.relationTypeDomesticPartner;
6700 case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather;
6701 case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend;
6702 case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager;
6703 case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother;
6704 case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent;
6705 case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner;
6706 case TYPE_REFERRED_BY:
6707 return com.android.internal.R.string.relationTypeReferredBy;
6708 case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative;
6709 case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister;
6710 case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse;
6711 default: return com.android.internal.R.string.orgTypeCustom;
6712 }
6713 }
6714
6715 /**
6716 * Return a {@link CharSequence} that best describes the given type,
6717 * possibly substituting the given {@link #LABEL} value
6718 * for {@link #TYPE_CUSTOM}.
6719 */
6720 public static final CharSequence getTypeLabel(Resources res, int type,
6721 CharSequence label) {
6722 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6723 return label;
6724 } else {
6725 final int labelRes = getTypeLabelResource(type);
6726 return res.getText(labelRes);
6727 }
6728 }
Fred Quintana8851e162009-08-05 21:06:45 -07006729 }
6730
6731 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006732 * <p>
6733 * A data kind representing an event.
6734 * </p>
6735 * <p>
6736 * You can use all columns defined for {@link ContactsContract.Data} as
6737 * well as the following aliases.
6738 * </p>
6739 * <h2>Column aliases</h2>
6740 * <table class="jd-sumtable">
6741 * <tr>
6742 * <th>Type</th>
6743 * <th>Alias</th><th colspan='2'>Data column</th>
6744 * </tr>
6745 * <tr>
6746 * <td>String</td>
6747 * <td>{@link #START_DATE}</td>
6748 * <td>{@link #DATA1}</td>
6749 * <td></td>
6750 * </tr>
6751 * <tr>
6752 * <td>int</td>
6753 * <td>{@link #TYPE}</td>
6754 * <td>{@link #DATA2}</td>
6755 * <td>Allowed values are:
6756 * <p>
6757 * <ul>
6758 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6759 * <li>{@link #TYPE_ANNIVERSARY}</li>
6760 * <li>{@link #TYPE_OTHER}</li>
6761 * <li>{@link #TYPE_BIRTHDAY}</li>
6762 * </ul>
6763 * </p>
6764 * </td>
6765 * </tr>
6766 * <tr>
6767 * <td>String</td>
6768 * <td>{@link #LABEL}</td>
6769 * <td>{@link #DATA3}</td>
6770 * <td></td>
6771 * </tr>
6772 * </table>
Fred Quintana8851e162009-08-05 21:06:45 -07006773 */
Yorke Lee94c87612014-07-18 18:57:17 -07006774 public static final class Event implements DataColumnsWithJoins, CommonColumns,
6775 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006776 /**
6777 * This utility class cannot be instantiated
6778 */
Fred Quintana8851e162009-08-05 21:06:45 -07006779 private Event() {}
6780
6781 /** MIME type used when storing this in data table. */
Fred Quintanac868acf2009-09-30 18:17:47 -07006782 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event";
Fred Quintana8851e162009-08-05 21:06:45 -07006783
6784 public static final int TYPE_ANNIVERSARY = 1;
6785 public static final int TYPE_OTHER = 2;
Fred Quintanac868acf2009-09-30 18:17:47 -07006786 public static final int TYPE_BIRTHDAY = 3;
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07006787
Fred Quintana8851e162009-08-05 21:06:45 -07006788 /**
6789 * The event start date as the user entered it.
6790 * <P>Type: TEXT</P>
6791 */
6792 public static final String START_DATE = DATA;
Fred Quintanac868acf2009-09-30 18:17:47 -07006793
6794 /**
6795 * Return the string resource that best describes the given
6796 * {@link #TYPE}. Will always return a valid resource.
6797 */
6798 public static int getTypeResource(Integer type) {
6799 if (type == null) {
6800 return com.android.internal.R.string.eventTypeOther;
6801 }
6802 switch (type) {
6803 case TYPE_ANNIVERSARY:
6804 return com.android.internal.R.string.eventTypeAnniversary;
6805 case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday;
6806 case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther;
Daniel Lehmanndd384a72010-11-01 18:40:50 -07006807 default: return com.android.internal.R.string.eventTypeCustom;
Fred Quintanac868acf2009-09-30 18:17:47 -07006808 }
6809 }
Paul Soulos6b2dd632014-07-24 17:17:42 -07006810
6811 /**
6812 * Return a {@link CharSequence} that best describes the given type,
6813 * possibly substituting the given {@link #LABEL} value
6814 * for {@link #TYPE_CUSTOM}.
6815 */
6816 public static final CharSequence getTypeLabel(Resources res, int type,
6817 CharSequence label) {
6818 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6819 return label;
6820 } else {
6821 final int labelRes = getTypeResource(type);
6822 return res.getText(labelRes);
6823 }
6824 }
Evan Millar088b2912009-05-28 15:24:37 -07006825 }
6826
6827 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006828 * <p>
Dave Santoroa5282372011-06-29 00:25:16 -07006829 * A data kind representing a photo for the contact.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006830 * </p>
6831 * <p>
6832 * Some sync adapters will choose to download photos in a separate
6833 * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1}
6834 * through {@link ContactsContract.Data#SYNC4} to store temporary
6835 * data, e.g. the image URL or ID, state of download, server-side version
6836 * of the image. It is allowed for the {@link #PHOTO} to be null.
6837 * </p>
6838 * <p>
6839 * You can use all columns defined for {@link ContactsContract.Data} as
6840 * well as the following aliases.
6841 * </p>
6842 * <h2>Column aliases</h2>
6843 * <table class="jd-sumtable">
6844 * <tr>
6845 * <th>Type</th>
6846 * <th>Alias</th><th colspan='2'>Data column</th>
6847 * </tr>
6848 * <tr>
Dave Santoroa5282372011-06-29 00:25:16 -07006849 * <td>NUMBER</td>
6850 * <td>{@link #PHOTO_FILE_ID}</td>
6851 * <td>{@link #DATA14}</td>
6852 * <td>ID of the hi-res photo file.</td>
6853 * </tr>
6854 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006855 * <td>BLOB</td>
6856 * <td>{@link #PHOTO}</td>
6857 * <td>{@link #DATA15}</td>
Dave Santoroa5282372011-06-29 00:25:16 -07006858 * <td>By convention, binary data is stored in DATA15. The thumbnail of the
6859 * photo is stored in this column.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006860 * </tr>
6861 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006862 */
Yorke Lee94c87612014-07-18 18:57:17 -07006863 public static final class Photo implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006864 /**
6865 * This utility class cannot be instantiated
6866 */
Evan Millar088b2912009-05-28 15:24:37 -07006867 private Photo() {}
6868
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006869 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07006870 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
6871
6872 /**
Dave Santoroa5282372011-06-29 00:25:16 -07006873 * Photo file ID for the display photo of the raw contact.
6874 * See {@link ContactsContract.DisplayPhoto}.
6875 * <p>
6876 * Type: NUMBER
6877 */
6878 public static final String PHOTO_FILE_ID = DATA14;
6879
6880 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07006881 * Thumbnail photo of the raw contact. This is the raw bytes of an image
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07006882 * that could be inflated using {@link android.graphics.BitmapFactory}.
Evan Millar088b2912009-05-28 15:24:37 -07006883 * <p>
6884 * Type: BLOB
6885 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006886 public static final String PHOTO = DATA15;
Evan Millar088b2912009-05-28 15:24:37 -07006887 }
6888
6889 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006890 * <p>
Evan Millar088b2912009-05-28 15:24:37 -07006891 * Notes about the contact.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006892 * </p>
6893 * <p>
6894 * You can use all columns defined for {@link ContactsContract.Data} as
6895 * well as the following aliases.
6896 * </p>
6897 * <h2>Column aliases</h2>
6898 * <table class="jd-sumtable">
6899 * <tr>
6900 * <th>Type</th>
6901 * <th>Alias</th><th colspan='2'>Data column</th>
6902 * </tr>
6903 * <tr>
6904 * <td>String</td>
6905 * <td>{@link #NOTE}</td>
6906 * <td>{@link #DATA1}</td>
6907 * <td></td>
6908 * </tr>
6909 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006910 */
Yorke Lee94c87612014-07-18 18:57:17 -07006911 public static final class Note implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006912 /**
6913 * This utility class cannot be instantiated
6914 */
Evan Millar088b2912009-05-28 15:24:37 -07006915 private Note() {}
6916
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006917 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07006918 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
6919
6920 /**
6921 * The note text.
6922 * <P>Type: TEXT</P>
6923 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006924 public static final String NOTE = DATA1;
Evan Millar088b2912009-05-28 15:24:37 -07006925 }
Dmitri Plotnikov56927772009-05-28 17:23:39 -07006926
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07006927 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006928 * <p>
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006929 * Group Membership.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006930 * </p>
6931 * <p>
6932 * You can use all columns defined for {@link ContactsContract.Data} as
6933 * well as the following aliases.
6934 * </p>
6935 * <h2>Column aliases</h2>
6936 * <table class="jd-sumtable">
6937 * <tr>
6938 * <th>Type</th>
6939 * <th>Alias</th><th colspan='2'>Data column</th>
6940 * </tr>
6941 * <tr>
6942 * <td>long</td>
6943 * <td>{@link #GROUP_ROW_ID}</td>
6944 * <td>{@link #DATA1}</td>
6945 * <td></td>
6946 * </tr>
6947 * <tr>
6948 * <td>String</td>
6949 * <td>{@link #GROUP_SOURCE_ID}</td>
6950 * <td>none</td>
6951 * <td>
6952 * <p>
6953 * The sourceid of the group that this group membership refers to.
6954 * Exactly one of this or {@link #GROUP_ROW_ID} must be set when
6955 * inserting a row.
6956 * </p>
6957 * <p>
6958 * If this field is specified, the provider will first try to
6959 * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group
6960 * is found, it will use the corresponding row id. If the group is not
6961 * found, it will create one.
6962 * </td>
6963 * </tr>
6964 * </table>
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07006965 */
Yorke Lee94c87612014-07-18 18:57:17 -07006966 public static final class GroupMembership implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006967 /**
6968 * This utility class cannot be instantiated
6969 */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006970 private GroupMembership() {}
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07006971
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006972 /** MIME type used when storing this in data table. */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006973 public static final String CONTENT_ITEM_TYPE =
6974 "vnd.android.cursor.item/group_membership";
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07006975
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006976 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07006977 * The row id of the group that this group membership refers to. Exactly one of
6978 * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006979 * <P>Type: INTEGER</P>
6980 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006981 public static final String GROUP_ROW_ID = DATA1;
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07006982
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006983 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07006984 * The sourceid of the group that this group membership refers to. Exactly one of
6985 * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006986 * <P>Type: TEXT</P>
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006987 */
Fred Quintanaffc34c12009-07-14 16:02:58 -07006988 public static final String GROUP_SOURCE_ID = "group_sourceid";
Fred Quintanad8dfeb52009-06-04 10:28:49 -07006989 }
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006990
6991 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006992 * <p>
6993 * A data kind representing a website related to the contact.
6994 * </p>
6995 * <p>
6996 * You can use all columns defined for {@link ContactsContract.Data} as
6997 * well as the following aliases.
6998 * </p>
6999 * <h2>Column aliases</h2>
7000 * <table class="jd-sumtable">
7001 * <tr>
7002 * <th>Type</th>
7003 * <th>Alias</th><th colspan='2'>Data column</th>
7004 * </tr>
7005 * <tr>
7006 * <td>String</td>
7007 * <td>{@link #URL}</td>
7008 * <td>{@link #DATA1}</td>
7009 * <td></td>
7010 * </tr>
7011 * <tr>
7012 * <td>int</td>
7013 * <td>{@link #TYPE}</td>
7014 * <td>{@link #DATA2}</td>
7015 * <td>Allowed values are:
7016 * <p>
7017 * <ul>
7018 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
7019 * <li>{@link #TYPE_HOMEPAGE}</li>
7020 * <li>{@link #TYPE_BLOG}</li>
7021 * <li>{@link #TYPE_PROFILE}</li>
7022 * <li>{@link #TYPE_HOME}</li>
7023 * <li>{@link #TYPE_WORK}</li>
7024 * <li>{@link #TYPE_FTP}</li>
7025 * <li>{@link #TYPE_OTHER}</li>
7026 * </ul>
7027 * </p>
7028 * </td>
7029 * </tr>
7030 * <tr>
7031 * <td>String</td>
7032 * <td>{@link #LABEL}</td>
7033 * <td>{@link #DATA3}</td>
7034 * <td></td>
7035 * </tr>
7036 * </table>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007037 */
Yorke Lee94c87612014-07-18 18:57:17 -07007038 public static final class Website implements DataColumnsWithJoins, CommonColumns,
7039 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05007040 /**
7041 * This utility class cannot be instantiated
7042 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007043 private Website() {}
7044
7045 /** MIME type used when storing this in data table. */
7046 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
7047
Fred Quintana8851e162009-08-05 21:06:45 -07007048 public static final int TYPE_HOMEPAGE = 1;
7049 public static final int TYPE_BLOG = 2;
7050 public static final int TYPE_PROFILE = 3;
7051 public static final int TYPE_HOME = 4;
7052 public static final int TYPE_WORK = 5;
7053 public static final int TYPE_FTP = 6;
7054 public static final int TYPE_OTHER = 7;
7055
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007056 /**
7057 * The website URL string.
7058 * <P>Type: TEXT</P>
7059 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07007060 public static final String URL = DATA;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007061 }
David Brown846eb302010-08-23 17:40:51 -07007062
7063 /**
7064 * <p>
7065 * A data kind representing a SIP address for the contact.
7066 * </p>
7067 * <p>
7068 * You can use all columns defined for {@link ContactsContract.Data} as
7069 * well as the following aliases.
7070 * </p>
7071 * <h2>Column aliases</h2>
7072 * <table class="jd-sumtable">
7073 * <tr>
7074 * <th>Type</th>
7075 * <th>Alias</th><th colspan='2'>Data column</th>
7076 * </tr>
7077 * <tr>
7078 * <td>String</td>
7079 * <td>{@link #SIP_ADDRESS}</td>
7080 * <td>{@link #DATA1}</td>
7081 * <td></td>
7082 * </tr>
David Brown747c6152010-09-15 13:34:13 -07007083 * <tr>
7084 * <td>int</td>
7085 * <td>{@link #TYPE}</td>
7086 * <td>{@link #DATA2}</td>
7087 * <td>Allowed values are:
7088 * <p>
7089 * <ul>
7090 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
7091 * <li>{@link #TYPE_HOME}</li>
7092 * <li>{@link #TYPE_WORK}</li>
7093 * <li>{@link #TYPE_OTHER}</li>
7094 * </ul>
7095 * </p>
7096 * </td>
7097 * </tr>
7098 * <tr>
7099 * <td>String</td>
7100 * <td>{@link #LABEL}</td>
7101 * <td>{@link #DATA3}</td>
7102 * <td></td>
7103 * </tr>
David Brown846eb302010-08-23 17:40:51 -07007104 * </table>
7105 */
Yorke Lee94c87612014-07-18 18:57:17 -07007106 public static final class SipAddress implements DataColumnsWithJoins, CommonColumns,
7107 ContactCounts {
David Brown846eb302010-08-23 17:40:51 -07007108 /**
7109 * This utility class cannot be instantiated
7110 */
7111 private SipAddress() {}
7112
7113 /** MIME type used when storing this in data table. */
7114 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address";
7115
David Brown747c6152010-09-15 13:34:13 -07007116 public static final int TYPE_HOME = 1;
7117 public static final int TYPE_WORK = 2;
7118 public static final int TYPE_OTHER = 3;
7119
David Brown846eb302010-08-23 17:40:51 -07007120 /**
7121 * The SIP address.
7122 * <P>Type: TEXT</P>
7123 */
7124 public static final String SIP_ADDRESS = DATA1;
David Brown747c6152010-09-15 13:34:13 -07007125 // ...and TYPE and LABEL come from the CommonColumns interface.
7126
7127 /**
7128 * Return the string resource that best describes the given
7129 * {@link #TYPE}. Will always return a valid resource.
7130 */
7131 public static final int getTypeLabelResource(int type) {
7132 switch (type) {
7133 case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome;
7134 case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork;
7135 case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther;
7136 default: return com.android.internal.R.string.sipAddressTypeCustom;
7137 }
7138 }
7139
7140 /**
7141 * Return a {@link CharSequence} that best describes the given type,
7142 * possibly substituting the given {@link #LABEL} value
7143 * for {@link #TYPE_CUSTOM}.
7144 */
7145 public static final CharSequence getTypeLabel(Resources res, int type,
7146 CharSequence label) {
7147 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
7148 return label;
7149 } else {
7150 final int labelRes = getTypeLabelResource(type);
7151 return res.getText(labelRes);
7152 }
7153 }
David Brown846eb302010-08-23 17:40:51 -07007154 }
Fred Quintana4923f1d2011-08-05 15:58:17 -07007155
7156 /**
7157 * A data kind representing an Identity related to the contact.
7158 * <p>
7159 * This can be used as a signal by the aggregator to combine raw contacts into
7160 * contacts, e.g. if two contacts have Identity rows with
7161 * the same NAMESPACE and IDENTITY values the aggregator can know that they refer
7162 * to the same person.
7163 * </p>
7164 */
Yorke Lee94c87612014-07-18 18:57:17 -07007165 public static final class Identity implements DataColumnsWithJoins, ContactCounts {
Fred Quintana4923f1d2011-08-05 15:58:17 -07007166 /**
7167 * This utility class cannot be instantiated
7168 */
7169 private Identity() {}
7170
7171 /** MIME type used when storing this in data table. */
7172 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity";
7173
7174 /**
7175 * The identity string.
7176 * <P>Type: TEXT</P>
7177 */
7178 public static final String IDENTITY = DataColumns.DATA1;
7179
7180 /**
7181 * The namespace of the identity string, e.g. "com.google"
7182 * <P>Type: TEXT</P>
7183 */
7184 public static final String NAMESPACE = DataColumns.DATA2;
7185 }
Daisuke Miyakawa3d340e72011-10-23 10:46:30 -07007186
7187 /**
7188 * <p>
7189 * Convenient functionalities for "callable" data. Note that, this is NOT a separate data
7190 * kind.
7191 * </p>
7192 * <p>
7193 * This URI allows the ContactsProvider to return a unified result for "callable" data
7194 * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the
7195 * current examples for "callable", but may be expanded to the other types.
7196 * </p>
7197 * <p>
7198 * Each returned row may have a different MIMETYPE and thus different interpretation for
7199 * each column. For example the meaning for {@link Phone}'s type is different than
7200 * {@link SipAddress}'s.
7201 * </p>
Daisuke Miyakawa3d340e72011-10-23 10:46:30 -07007202 */
Yorke Lee94c87612014-07-18 18:57:17 -07007203 public static final class Callable implements DataColumnsWithJoins, CommonColumns,
7204 ContactCounts {
Daisuke Miyakawa3d340e72011-10-23 10:46:30 -07007205 /**
7206 * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only
7207 * phone numbers.
7208 */
7209 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
7210 "callables");
7211 /**
7212 * Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable
7213 * data.
7214 */
7215 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
7216 "filter");
7217 }
Yorke Lee4f401eb2013-03-06 17:17:17 -08007218
7219 /**
7220 * A special class of data items, used to refer to types of data that can be used to attempt
7221 * to start communicating with a person ({@link Phone} and {@link Email}). Note that this
7222 * is NOT a separate data kind.
7223 *
7224 * This URI allows the ContactsProvider to return a unified result for data items that users
7225 * can use to initiate communications with another contact. {@link Phone} and {@link Email}
7226 * are the current data types in this category.
7227 */
Yorke Lee94c87612014-07-18 18:57:17 -07007228 public static final class Contactables implements DataColumnsWithJoins, CommonColumns,
7229 ContactCounts {
Yorke Lee4f401eb2013-03-06 17:17:17 -08007230 /**
7231 * The content:// style URI for these data items, which requests a directory of data
7232 * rows matching the selection criteria.
7233 */
7234 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
7235 "contactables");
7236
7237 /**
7238 * The content:// style URI for these data items, which allows for a query parameter to
7239 * be appended onto the end to filter for data items matching the query.
7240 */
7241 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
7242 Contactables.CONTENT_URI, "filter");
7243
7244 /**
7245 * A boolean parameter for {@link Data#CONTENT_URI}.
7246 * This specifies whether or not the returned data items should be filtered to show
7247 * data items belonging to visible contacts only.
7248 */
7249 public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only";
7250 }
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07007251 }
Fred Quintana435e4272009-06-04 17:30:28 -07007252
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007253 /**
7254 * @see Groups
7255 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07007256 protected interface GroupsColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007257 /**
Dave Santorod7bdc182011-06-24 15:39:39 -07007258 * The data set within the account that this group belongs to. This allows
7259 * multiple sync adapters for the same account type to distinguish between
7260 * each others' group data.
7261 *
7262 * This is empty by default, and is completely optional. It only needs to
7263 * be populated if multiple sync adapters are entering distinct group data
7264 * for the same account type and account name.
7265 * <P>Type: TEXT</P>
7266 */
7267 public static final String DATA_SET = "data_set";
7268
7269 /**
Dave Santoro1d55c332011-07-25 16:44:45 -07007270 * A concatenation of the account type and data set (delimited by a forward
7271 * slash) - if the data set is empty, this will be the same as the account
7272 * type. For applications that need to be aware of the data set, this can
7273 * be used instead of account type to distinguish sets of data. This is
7274 * never intended to be used for specifying accounts.
7275 * @hide
7276 */
7277 public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
7278
7279 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007280 * The display title of this group.
7281 * <p>
7282 * Type: TEXT
7283 */
7284 public static final String TITLE = "title";
7285
7286 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007287 * The package name to use when creating {@link Resources} objects for
7288 * this group. This value is only designed for use when building user
7289 * interfaces, and should not be used to infer the owner.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007290 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007291 public static final String RES_PACKAGE = "res_package";
7292
7293 /**
7294 * The display title of this group to load as a resource from
7295 * {@link #RES_PACKAGE}, which may be localized.
7296 * <P>Type: TEXT</P>
7297 */
7298 public static final String TITLE_RES = "title_res";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007299
7300 /**
Dmitri Plotnikov02c5b452009-07-22 15:13:08 -07007301 * Notes about the group.
7302 * <p>
7303 * Type: TEXT
7304 */
7305 public static final String NOTES = "notes";
7306
7307 /**
7308 * The ID of this group if it is a System Group, i.e. a group that has a special meaning
7309 * to the sync adapter, null otherwise.
7310 * <P>Type: TEXT</P>
7311 */
7312 public static final String SYSTEM_ID = "system_id";
7313
7314 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07007315 * The total number of {@link Contacts} that have
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07007316 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007317 * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
7318 * <p>
7319 * Type: INTEGER
7320 */
7321 public static final String SUMMARY_COUNT = "summ_count";
7322
7323 /**
Daisuke Miyakawa15dec392011-07-23 11:39:23 -07007324 * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}.
7325 * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}.
7326 *
7327 * @hide
7328 */
7329 public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT =
7330 "return_group_count_per_account";
7331
7332 /**
7333 * The total number of groups of the account that a group belongs to.
7334 * This column is available only when the parameter
7335 * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in
7336 * {@link Groups#CONTENT_SUMMARY_URI}.
7337 *
7338 * For example, when the account "A" has two groups "group1" and "group2", and the account
7339 * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for
7340 * "group3" returns "1" for this column.
7341 *
7342 * Note: This counts only non-favorites, non-auto-add, and not deleted groups.
7343 *
7344 * Type: INTEGER
7345 * @hide
7346 */
7347 public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account";
7348
7349 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07007350 * The total number of {@link Contacts} that have both
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07007351 * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007352 * Read-only value that is only present when querying
7353 * {@link Groups#CONTENT_SUMMARY_URI}.
7354 * <p>
7355 * Type: INTEGER
7356 */
7357 public static final String SUMMARY_WITH_PHONES = "summ_phones";
7358
7359 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007360 * Flag indicating if the contacts belonging to this group should be
7361 * visible in any user interface.
7362 * <p>
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007363 * Type: INTEGER (boolean)
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007364 */
7365 public static final String GROUP_VISIBLE = "group_visible";
Fred Quintana00c89f62009-08-10 14:43:24 -07007366
7367 /**
7368 * The "deleted" flag: "0" by default, "1" if the row has been marked
7369 * for deletion. When {@link android.content.ContentResolver#delete} is
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007370 * called on a group, it is marked for deletion. The sync adaptor
7371 * deletes the group on the server and then calls ContactResolver.delete
7372 * once more, this time setting the the
7373 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to
7374 * finalize the data removal.
Fred Quintana00c89f62009-08-10 14:43:24 -07007375 * <P>Type: INTEGER</P>
7376 */
7377 public static final String DELETED = "deleted";
Jeff Sharkey403d7ac2009-08-16 16:34:35 -07007378
7379 /**
7380 * Whether this group should be synced if the SYNC_EVERYTHING settings
7381 * is false for this group's account.
7382 * <p>
7383 * Type: INTEGER (boolean)
7384 */
7385 public static final String SHOULD_SYNC = "should_sync";
Fred Quintanaa31a9452010-04-13 14:52:20 -07007386
7387 /**
7388 * Any newly created contacts will automatically be added to groups that have this
7389 * flag set to true.
7390 * <p>
7391 * Type: INTEGER (boolean)
7392 */
7393 public static final String AUTO_ADD = "auto_add";
7394
7395 /**
7396 * When a contacts is marked as a favorites it will be automatically added
7397 * to the groups that have this flag set, and when it is removed from favorites
7398 * it will be removed from these groups.
7399 * <p>
7400 * Type: INTEGER (boolean)
7401 */
7402 public static final String FAVORITES = "favorites";
Dmitri Plotnikov4ccf33a2010-11-19 11:10:43 -08007403
7404 /**
7405 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
7406 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
7407 * <P>Type: INTEGER</P>
7408 */
7409 public static final String GROUP_IS_READ_ONLY = "group_is_read_only";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007410 }
7411
7412 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007413 * Constants for the groups table. Only per-account groups are supported.
7414 * <h2>Columns</h2>
7415 * <table class="jd-sumtable">
7416 * <tr>
7417 * <th colspan='4'>Groups</th>
7418 * </tr>
7419 * <tr>
7420 * <td>long</td>
7421 * <td>{@link #_ID}</td>
7422 * <td>read-only</td>
7423 * <td>Row ID. Sync adapter should try to preserve row IDs during updates.
7424 * In other words, it would be a really bad idea to delete and reinsert a
7425 * group. A sync adapter should always do an update instead.</td>
7426 * </tr>
Dave Santorod7bdc182011-06-24 15:39:39 -07007427 # <tr>
7428 * <td>String</td>
7429 * <td>{@link #DATA_SET}</td>
7430 * <td>read/write-once</td>
7431 * <td>
7432 * <p>
7433 * The data set within the account that this group belongs to. This allows
7434 * multiple sync adapters for the same account type to distinguish between
7435 * each others' group data. The combination of {@link #ACCOUNT_TYPE},
7436 * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data
7437 * that is associated with a single sync adapter.
7438 * </p>
7439 * <p>
7440 * This is empty by default, and is completely optional. It only needs to
7441 * be populated if multiple sync adapters are entering distinct data for
7442 * the same account type and account name.
7443 * </p>
7444 * <p>
7445 * It should be set at the time the group is inserted and never changed
7446 * afterwards.
7447 * </p>
7448 * </td>
7449 * </tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007450 * <tr>
7451 * <td>String</td>
7452 * <td>{@link #TITLE}</td>
7453 * <td>read/write</td>
7454 * <td>The display title of this group.</td>
7455 * </tr>
7456 * <tr>
7457 * <td>String</td>
7458 * <td>{@link #NOTES}</td>
7459 * <td>read/write</td>
7460 * <td>Notes about the group.</td>
7461 * </tr>
7462 * <tr>
7463 * <td>String</td>
7464 * <td>{@link #SYSTEM_ID}</td>
7465 * <td>read/write</td>
7466 * <td>The ID of this group if it is a System Group, i.e. a group that has a
7467 * special meaning to the sync adapter, null otherwise.</td>
7468 * </tr>
7469 * <tr>
7470 * <td>int</td>
7471 * <td>{@link #SUMMARY_COUNT}</td>
7472 * <td>read-only</td>
7473 * <td>The total number of {@link Contacts} that have
7474 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value
7475 * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td>
7476 * </tr>
7477 * <tr>
7478 * <td>int</td>
7479 * <td>{@link #SUMMARY_WITH_PHONES}</td>
7480 * <td>read-only</td>
7481 * <td>The total number of {@link Contacts} that have both
7482 * {@link CommonDataKinds.GroupMembership} in this group, and also have
7483 * phone numbers. Read-only value that is only present when querying
7484 * {@link Groups#CONTENT_SUMMARY_URI}.</td>
7485 * </tr>
7486 * <tr>
7487 * <td>int</td>
7488 * <td>{@link #GROUP_VISIBLE}</td>
7489 * <td>read-only</td>
7490 * <td>Flag indicating if the contacts belonging to this group should be
7491 * visible in any user interface. Allowed values: 0 and 1.</td>
7492 * </tr>
7493 * <tr>
7494 * <td>int</td>
7495 * <td>{@link #DELETED}</td>
7496 * <td>read/write</td>
7497 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
7498 * for deletion. When {@link android.content.ContentResolver#delete} is
7499 * called on a group, it is marked for deletion. The sync adaptor deletes
7500 * the group on the server and then calls ContactResolver.delete once more,
7501 * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER}
7502 * query parameter to finalize the data removal.</td>
7503 * </tr>
7504 * <tr>
7505 * <td>int</td>
7506 * <td>{@link #SHOULD_SYNC}</td>
7507 * <td>read/write</td>
7508 * <td>Whether this group should be synced if the SYNC_EVERYTHING settings
7509 * is false for this group's account.</td>
7510 * </tr>
7511 * </table>
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007512 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007513 public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007514 /**
7515 * This utility class cannot be instantiated
7516 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007517 private Groups() {
7518 }
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007519
7520 /**
7521 * The content:// style URI for this table
7522 */
7523 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
7524
7525 /**
7526 * The content:// style URI for this table joined with details data from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007527 * {@link ContactsContract.Data}.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007528 */
7529 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
7530 "groups_summary");
7531
7532 /**
7533 * The MIME type of a directory of groups.
7534 */
7535 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
7536
7537 /**
7538 * The MIME type of a single group.
7539 */
7540 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
Fred Quintana328c0e72009-12-07 14:52:28 -08007541
7542 public static EntityIterator newEntityIterator(Cursor cursor) {
7543 return new EntityIteratorImpl(cursor);
7544 }
7545
7546 private static class EntityIteratorImpl extends CursorEntityIterator {
7547 public EntityIteratorImpl(Cursor cursor) {
7548 super(cursor);
7549 }
7550
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08007551 @Override
Fred Quintana328c0e72009-12-07 14:52:28 -08007552 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
7553 // we expect the cursor is already at the row we need to read from
7554 final ContentValues values = new ContentValues();
7555 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID);
7556 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME);
7557 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE);
7558 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY);
7559 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION);
7560 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID);
7561 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE);
7562 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE);
7563 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES);
7564 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE);
7565 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1);
7566 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2);
7567 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3);
7568 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4);
7569 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID);
7570 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED);
7571 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES);
7572 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC);
Fred Quintanaa31a9452010-04-13 14:52:20 -07007573 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES);
7574 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD);
Fred Quintana328c0e72009-12-07 14:52:28 -08007575 cursor.moveToNext();
7576 return new Entity(values);
7577 }
7578 }
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007579 }
7580
Fred Quintana435e4272009-06-04 17:30:28 -07007581 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007582 * <p>
Fred Quintana435e4272009-06-04 17:30:28 -07007583 * Constants for the contact aggregation exceptions table, which contains
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007584 * aggregation rules overriding those used by automatic aggregation. This
7585 * type only supports query and update. Neither insert nor delete are
7586 * supported.
7587 * </p>
7588 * <h2>Columns</h2>
7589 * <table class="jd-sumtable">
7590 * <tr>
7591 * <th colspan='4'>AggregationExceptions</th>
7592 * </tr>
7593 * <tr>
7594 * <td>int</td>
7595 * <td>{@link #TYPE}</td>
7596 * <td>read/write</td>
7597 * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER},
7598 * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td>
7599 * </tr>
7600 * <tr>
7601 * <td>long</td>
7602 * <td>{@link #RAW_CONTACT_ID1}</td>
7603 * <td>read/write</td>
7604 * <td>A reference to the {@link RawContacts#_ID} of the raw contact that
7605 * the rule applies to.</td>
7606 * </tr>
7607 * <tr>
7608 * <td>long</td>
7609 * <td>{@link #RAW_CONTACT_ID2}</td>
7610 * <td>read/write</td>
7611 * <td>A reference to the other {@link RawContacts#_ID} of the raw contact
7612 * that the rule applies to.</td>
7613 * </tr>
7614 * </table>
Fred Quintana435e4272009-06-04 17:30:28 -07007615 */
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07007616 public static final class AggregationExceptions implements BaseColumns {
Fred Quintana435e4272009-06-04 17:30:28 -07007617 /**
7618 * This utility class cannot be instantiated
7619 */
7620 private AggregationExceptions() {}
7621
7622 /**
7623 * The content:// style URI for this table
7624 */
7625 public static final Uri CONTENT_URI =
7626 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
7627
7628 /**
7629 * The MIME type of {@link #CONTENT_URI} providing a directory of data.
7630 */
7631 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
7632
7633 /**
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07007634 * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
7635 */
7636 public static final String CONTENT_ITEM_TYPE =
7637 "vnd.android.cursor.item/aggregation_exception";
7638
7639 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007640 * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007641 * {@link #TYPE_AUTOMATIC}.
Fred Quintana435e4272009-06-04 17:30:28 -07007642 *
7643 * <P>Type: INTEGER</P>
7644 */
7645 public static final String TYPE = "type";
7646
Fred Quintana435e4272009-06-04 17:30:28 -07007647 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007648 * Allows the provider to automatically decide whether the specified raw contacts should
7649 * be included in the same aggregate contact or not.
Fred Quintana435e4272009-06-04 17:30:28 -07007650 */
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007651 public static final int TYPE_AUTOMATIC = 0;
Fred Quintana435e4272009-06-04 17:30:28 -07007652
7653 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007654 * Makes sure that the specified raw contacts are included in the same
7655 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007656 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007657 public static final int TYPE_KEEP_TOGETHER = 1;
7658
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007659 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007660 * Makes sure that the specified raw contacts are NOT included in the same
7661 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007662 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007663 public static final int TYPE_KEEP_SEPARATE = 2;
7664
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07007665 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07007666 * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
Fred Quintana435e4272009-06-04 17:30:28 -07007667 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07007668 public static final String RAW_CONTACT_ID1 = "raw_contact_id1";
7669
7670 /**
7671 * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule
7672 * applies to.
7673 */
7674 public static final String RAW_CONTACT_ID2 = "raw_contact_id2";
Fred Quintana435e4272009-06-04 17:30:28 -07007675 }
Jeff Sharkey28b68e52009-06-10 15:26:58 -07007676
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007677 /**
7678 * @see Settings
7679 */
Dmitri Plotnikovfe4c8712009-10-14 00:28:48 -07007680 protected interface SettingsColumns {
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007681 /**
7682 * The name of the account instance to which this row belongs.
7683 * <P>Type: TEXT</P>
7684 */
7685 public static final String ACCOUNT_NAME = "account_name";
7686
7687 /**
7688 * The type of account to which this row belongs, which when paired with
7689 * {@link #ACCOUNT_NAME} identifies a specific account.
7690 * <P>Type: TEXT</P>
7691 */
7692 public static final String ACCOUNT_TYPE = "account_type";
7693
7694 /**
Dave Santoro7c4479f2011-09-07 16:52:27 -07007695 * The data set within the account that this row belongs to. This allows
7696 * multiple sync adapters for the same account type to distinguish between
7697 * each others' data.
7698 *
7699 * This is empty by default, and is completely optional. It only needs to
7700 * be populated if multiple sync adapters are entering distinct data for
7701 * the same account type and account name.
7702 * <P>Type: TEXT</P>
7703 */
7704 public static final String DATA_SET = "data_set";
7705
7706 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07007707 * Depending on the mode defined by the sync-adapter, this flag controls
7708 * the top-level sync behavior for this data source.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007709 * <p>
7710 * Type: INTEGER (boolean)
7711 */
7712 public static final String SHOULD_SYNC = "should_sync";
7713
7714 /**
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07007715 * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership}
Jeff Sharkeya6597442009-08-19 09:23:33 -07007716 * entries should be visible in any user interface.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007717 * <p>
7718 * Type: INTEGER (boolean)
7719 */
7720 public static final String UNGROUPED_VISIBLE = "ungrouped_visible";
Jeff Sharkey06a03232009-08-21 17:37:56 -07007721
7722 /**
Jeff Sharkey97bda4c2009-09-15 23:15:23 -07007723 * Read-only flag indicating if this {@link #SHOULD_SYNC} or any
7724 * {@link Groups#SHOULD_SYNC} under this account have been marked as
7725 * unsynced.
7726 */
7727 public static final String ANY_UNSYNCED = "any_unsynced";
7728
7729 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07007730 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07007731 * no {@link CommonDataKinds.GroupMembership} entries.
Jeff Sharkey06a03232009-08-21 17:37:56 -07007732 * <p>
7733 * Type: INTEGER
7734 */
7735 public static final String UNGROUPED_COUNT = "summ_count";
7736
7737 /**
7738 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07007739 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers.
Jeff Sharkey06a03232009-08-21 17:37:56 -07007740 * <p>
7741 * Type: INTEGER
7742 */
7743 public static final String UNGROUPED_WITH_PHONES = "summ_phones";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007744 }
7745
7746 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007747 * <p>
7748 * Contacts-specific settings for various {@link Account}'s.
7749 * </p>
7750 * <h2>Columns</h2>
7751 * <table class="jd-sumtable">
7752 * <tr>
7753 * <th colspan='4'>Settings</th>
7754 * </tr>
7755 * <tr>
7756 * <td>String</td>
7757 * <td>{@link #ACCOUNT_NAME}</td>
7758 * <td>read/write-once</td>
7759 * <td>The name of the account instance to which this row belongs.</td>
7760 * </tr>
7761 * <tr>
7762 * <td>String</td>
7763 * <td>{@link #ACCOUNT_TYPE}</td>
7764 * <td>read/write-once</td>
7765 * <td>The type of account to which this row belongs, which when paired with
7766 * {@link #ACCOUNT_NAME} identifies a specific account.</td>
7767 * </tr>
7768 * <tr>
7769 * <td>int</td>
7770 * <td>{@link #SHOULD_SYNC}</td>
7771 * <td>read/write</td>
7772 * <td>Depending on the mode defined by the sync-adapter, this flag controls
7773 * the top-level sync behavior for this data source.</td>
7774 * </tr>
7775 * <tr>
7776 * <td>int</td>
7777 * <td>{@link #UNGROUPED_VISIBLE}</td>
7778 * <td>read/write</td>
7779 * <td>Flag indicating if contacts without any
7780 * {@link CommonDataKinds.GroupMembership} entries should be visible in any
7781 * user interface.</td>
7782 * </tr>
7783 * <tr>
7784 * <td>int</td>
7785 * <td>{@link #ANY_UNSYNCED}</td>
7786 * <td>read-only</td>
7787 * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any
7788 * {@link Groups#SHOULD_SYNC} under this account have been marked as
7789 * unsynced.</td>
7790 * </tr>
7791 * <tr>
7792 * <td>int</td>
7793 * <td>{@link #UNGROUPED_COUNT}</td>
7794 * <td>read-only</td>
7795 * <td>Read-only count of {@link Contacts} from a specific source that have
7796 * no {@link CommonDataKinds.GroupMembership} entries.</td>
7797 * </tr>
7798 * <tr>
7799 * <td>int</td>
7800 * <td>{@link #UNGROUPED_WITH_PHONES}</td>
7801 * <td>read-only</td>
7802 * <td>Read-only count of {@link Contacts} from a specific source that have
7803 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone
7804 * numbers.</td>
7805 * </tr>
7806 * </table>
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007807 */
Jeff Sharkey06a03232009-08-21 17:37:56 -07007808 public static final class Settings implements SettingsColumns {
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007809 /**
7810 * This utility class cannot be instantiated
7811 */
7812 private Settings() {
7813 }
7814
7815 /**
7816 * The content:// style URI for this table
7817 */
7818 public static final Uri CONTENT_URI =
7819 Uri.withAppendedPath(AUTHORITY_URI, "settings");
7820
7821 /**
7822 * The MIME-type of {@link #CONTENT_URI} providing a directory of
7823 * settings.
7824 */
7825 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting";
7826
7827 /**
7828 * The MIME-type of {@link #CONTENT_URI} providing a single setting.
7829 */
7830 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007831 }
7832
Evan Millardc2da5f2009-06-18 16:07:13 -07007833 /**
Dmitri Plotnikov4a8a3102010-03-08 19:40:19 -08007834 * Private API for inquiring about the general status of the provider.
7835 *
7836 * @hide
7837 */
7838 public static final class ProviderStatus {
7839
7840 /**
7841 * Not instantiable.
7842 */
7843 private ProviderStatus() {
7844 }
7845
7846 /**
7847 * The content:// style URI for this table. Requests to this URI can be
7848 * performed on the UI thread because they are always unblocking.
7849 *
7850 * @hide
7851 */
7852 public static final Uri CONTENT_URI =
7853 Uri.withAppendedPath(AUTHORITY_URI, "provider_status");
7854
7855 /**
7856 * The MIME-type of {@link #CONTENT_URI} providing a directory of
7857 * settings.
7858 *
7859 * @hide
7860 */
7861 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status";
7862
7863 /**
7864 * An integer representing the current status of the provider.
7865 *
7866 * @hide
7867 */
7868 public static final String STATUS = "status";
7869
7870 /**
7871 * Default status of the provider.
7872 *
7873 * @hide
7874 */
7875 public static final int STATUS_NORMAL = 0;
7876
7877 /**
7878 * The status used when the provider is in the process of upgrading. Contacts
7879 * are temporarily unaccessible.
7880 *
7881 * @hide
7882 */
7883 public static final int STATUS_UPGRADING = 1;
7884
7885 /**
7886 * The status used if the provider was in the process of upgrading but ran
7887 * out of storage. The DATA1 column will contain the estimated amount of
7888 * storage required (in bytes). Update status to STATUS_NORMAL to force
7889 * the provider to retry the upgrade.
7890 *
7891 * @hide
7892 */
7893 public static final int STATUS_UPGRADE_OUT_OF_MEMORY = 2;
7894
7895 /**
7896 * The status used during a locale change.
7897 *
7898 * @hide
7899 */
7900 public static final int STATUS_CHANGING_LOCALE = 3;
7901
7902 /**
Dmitri Plotnikov37c34862010-11-12 16:12:53 -08007903 * The status that indicates that there are no accounts and no contacts
7904 * on the device.
7905 *
7906 * @hide
7907 */
7908 public static final int STATUS_NO_ACCOUNTS_NO_CONTACTS = 4;
7909
7910 /**
Dmitri Plotnikov4a8a3102010-03-08 19:40:19 -08007911 * Additional data associated with the status.
7912 *
7913 * @hide
7914 */
7915 public static final String DATA1 = "data1";
7916 }
7917
7918 /**
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007919 * <p>
7920 * API allowing applications to send usage information for each {@link Data} row to the
Makoto Onukib0d22992012-04-12 17:09:58 -07007921 * Contacts Provider. Applications can also clear all usage information.
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007922 * </p>
7923 * <p>
7924 * With the feedback, Contacts Provider may return more contextually appropriate results for
7925 * Data listing, typically supplied with
7926 * {@link ContactsContract.Contacts#CONTENT_FILTER_URI},
7927 * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI},
7928 * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit
7929 * from better ranked (sorted) lists in applications that show auto-complete list.
7930 * </p>
7931 * <p>
7932 * There is no guarantee for how this feedback is used, or even whether it is used at all.
7933 * The ranking algorithm will make best efforts to use the feedback data, but the exact
7934 * implementation, the storage data structures as well as the resulting sort order is device
7935 * and version specific and can change over time.
7936 * </p>
7937 * <p>
7938 * When updating usage information, users of this API need to use
7939 * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed
7940 * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as
7941 * its last path. They also need to append a query parameter to the Uri, to specify the type of
7942 * the communication, which enables the Contacts Provider to differentiate between kinds of
7943 * interactions using the same contact data field (for example a phone number can be used to
7944 * make phone calls or send SMS).
7945 * </p>
7946 * <p>
7947 * Selection and selectionArgs are ignored and must be set to null. To get data ids,
7948 * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)}
7949 * toward {@link Data#CONTENT_URI}.
7950 * </p>
7951 * <p>
Daisuke Miyakawa63b709d2011-06-09 11:00:19 -07007952 * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive
7953 * integer when successful, and returns 0 if no contact with that id was found.
7954 * </p>
7955 * <p>
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007956 * Example:
7957 * <pre>
Daisuke Miyakawa52e38232011-06-14 10:56:46 -07007958 * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon()
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007959 * .appendPath(TextUtils.join(",", dataIds))
Daisuke Miyakawa52e38232011-06-14 10:56:46 -07007960 * .appendQueryParameter(DataUsageFeedback.USAGE_TYPE,
7961 * DataUsageFeedback.USAGE_TYPE_CALL)
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007962 * .build();
Daisuke Miyakawa63b709d2011-06-09 11:00:19 -07007963 * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0;
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007964 * </pre>
7965 * </p>
Makoto Onukib0d22992012-04-12 17:09:58 -07007966 * <p>
7967 * Applications can also clear all usage information with:
7968 * <pre>
Makoto Onuki7ebbfd02012-04-13 12:56:42 -07007969 * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0;
Makoto Onukib0d22992012-04-12 17:09:58 -07007970 * </pre>
7971 * </p>
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007972 */
7973 public static final class DataUsageFeedback {
7974
7975 /**
7976 * The content:// style URI for sending usage feedback.
7977 * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}.
7978 */
7979 public static final Uri FEEDBACK_URI =
7980 Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback");
7981
7982 /**
Makoto Onuki7ebbfd02012-04-13 12:56:42 -07007983 * The content:// style URI for deleting all usage information.
7984 * Must be used with {@link ContentResolver#delete(Uri, String, String[])}.
7985 * The {@code where} and {@code selectionArgs} parameters are ignored.
7986 */
7987 public static final Uri DELETE_USAGE_URI =
7988 Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage");
7989
7990 /**
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007991 * <p>
7992 * Name for query parameter specifying the type of data usage.
7993 * </p>
7994 */
Daisuke Miyakawa63b709d2011-06-09 11:00:19 -07007995 public static final String USAGE_TYPE = "type";
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07007996
7997 /**
7998 * <p>
7999 * Type of usage for voice interaction, which includes phone call, voice chat, and
8000 * video chat.
8001 * </p>
8002 */
8003 public static final String USAGE_TYPE_CALL = "call";
8004
8005 /**
8006 * <p>
8007 * Type of usage for text interaction involving longer messages, which includes email.
8008 * </p>
8009 */
8010 public static final String USAGE_TYPE_LONG_TEXT = "long_text";
8011
8012 /**
8013 * <p>
8014 * Type of usage for text interaction involving shorter messages, which includes SMS,
8015 * text chat with email addresses.
8016 * </p>
8017 */
8018 public static final String USAGE_TYPE_SHORT_TEXT = "short_text";
8019 }
8020
8021 /**
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008022 * <p>
Yorke Leecadbe4c2014-06-20 11:52:27 -07008023 * Contact-specific information about whether or not a contact has been pinned by the user
8024 * at a particular position within the system contact application's user interface.
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008025 * </p>
8026 *
8027 * <p>
8028 * This pinning information can be used by individual applications to customize how
8029 * they order particular pinned contacts. For example, a Dialer application could
8030 * use pinned information to order user-pinned contacts in a top row of favorites.
8031 * </p>
8032 *
8033 * <p>
8034 * It is possible for two or more contacts to occupy the same pinned position (due
8035 * to aggregation and sync), so this pinning information should be used on a best-effort
8036 * basis to order contacts in-application rather than an absolute guide on where a contact
8037 * should be positioned. Contacts returned by the ContactsProvider will not be ordered based
8038 * on this information, so it is up to the client application to reorder these contacts within
8039 * their own UI adhering to (or ignoring as appropriate) information stored in the pinned
8040 * column.
8041 * </p>
8042 *
8043 * <p>
8044 * By default, unpinned contacts will have a pinned position of
Yorke Lee7d246792014-07-25 10:05:55 -07008045 * {@link PinnedPositions#UNPINNED}. Client-provided pinned positions can be positive
8046 * integers that are greater than 1.
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008047 * </p>
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008048 */
8049 public static final class PinnedPositions {
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008050 /**
Yorke Lee0e040b02014-06-18 15:02:44 -07008051 * The method to invoke in order to undemote a formerly demoted contact. The contact id of
8052 * the contact must be provided as an argument. If the contact was not previously demoted,
8053 * nothing will be done.
Yorke Lee94c87612014-07-18 18:57:17 -07008054 * @hide
Yorke Lee0e040b02014-06-18 15:02:44 -07008055 */
8056 public static final String UNDEMOTE_METHOD = "undemote";
8057
8058 /**
Yorke Lee94c87612014-07-18 18:57:17 -07008059 * Undemotes a formerly demoted contact. If the contact was not previously demoted, nothing
8060 * will be done.
8061 *
8062 * @param contentResolver to perform the undemote operation on.
8063 * @param contactId the id of the contact to undemote.
8064 */
8065 public static void undemote(ContentResolver contentResolver, long contactId) {
8066 contentResolver.call(ContactsContract.AUTHORITY_URI, PinnedPositions.UNDEMOTE_METHOD,
8067 String.valueOf(contactId), null);
8068 }
8069
8070 /**
Yorke Leeb31c8ab2014-08-26 17:13:02 -07008071 * Pins a contact at a provided position, or unpins a contact.
8072 *
8073 * @param contentResolver to perform the pinning operation on.
8074 * @param pinnedPosition the position to pin the contact at. To unpin a contact, use
8075 * {@link PinnedPositions#UNPINNED}.
8076 */
8077 public static void pin(
8078 ContentResolver contentResolver, long contactId, int pinnedPosition) {
8079 final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId));
8080 final ContentValues values = new ContentValues();
8081 values.put(Contacts.PINNED, pinnedPosition);
8082 contentResolver.update(uri, values, null, null);
8083 }
8084
8085 /**
Yorke Lee94c87612014-07-18 18:57:17 -07008086 * Default value for the pinned position of an unpinned contact.
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008087 */
Yorke Lee7d246792014-07-25 10:05:55 -07008088 public static final int UNPINNED = 0;
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008089
8090 /**
Yorke Lee3585e1a2013-07-31 18:53:31 -07008091 * Value of pinned position for a contact that a user has indicated should be considered
8092 * of the lowest priority. It is up to the client application to determine how to present
8093 * such a contact - for example all the way at the bottom of a contact list, or simply
8094 * just hidden from view.
8095 */
8096 public static final int DEMOTED = -1;
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008097 }
8098
8099 /**
Yorke Leef8aadf32014-06-23 17:51:16 -07008100 * Helper methods to display QuickContact dialogs that display all the information belonging to
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008101 * a specific {@link Contacts} entry.
8102 */
Evan Millare3ec9972009-09-30 19:37:36 -07008103 public static final class QuickContact {
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008104 /**
Yorke Leef8aadf32014-06-23 17:51:16 -07008105 * Action used to launch the system contacts application and bring up a QuickContact dialog
8106 * for the provided {@link Contacts} entry.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008107 */
Evan Millar5042f7e2009-09-30 21:28:33 -07008108 public static final String ACTION_QUICK_CONTACT =
8109 "com.android.contacts.action.QUICK_CONTACT";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008110
8111 /**
8112 * Extra used to specify pivot dialog location in screen coordinates.
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08008113 * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008114 * @hide
8115 */
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08008116 @Deprecated
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008117 public static final String EXTRA_TARGET_RECT = "target_rect";
8118
8119 /**
8120 * Extra used to specify size of pivot dialog.
8121 * @hide
8122 */
8123 public static final String EXTRA_MODE = "mode";
8124
8125 /**
Yorke Leef8aadf32014-06-23 17:51:16 -07008126 * Extra used to indicate a list of specific MIME-types to exclude and not display in the
8127 * QuickContacts dialog. Stored as a {@link String} array.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008128 */
8129 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
8130
8131 /**
Evan Millare3ec9972009-09-30 19:37:36 -07008132 * Small QuickContact mode, usually presented with minimal actions.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008133 */
8134 public static final int MODE_SMALL = 1;
8135
8136 /**
Evan Millare3ec9972009-09-30 19:37:36 -07008137 * Medium QuickContact mode, includes actions and light summary describing
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008138 * the {@link Contacts} entry being shown. This may include social
8139 * status and presence details.
8140 */
8141 public static final int MODE_MEDIUM = 2;
8142
8143 /**
Evan Millare3ec9972009-09-30 19:37:36 -07008144 * Large QuickContact mode, includes actions and larger, card-like summary
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008145 * of the {@link Contacts} entry being shown. This may include detailed
8146 * information, such as a photo.
8147 */
8148 public static final int MODE_LARGE = 3;
8149
8150 /**
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008151 * Constructs the QuickContacts intent with a view's rect.
8152 * @hide
8153 */
8154 public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri,
8155 int mode, String[] excludeMimes) {
8156 // Find location and bounds of target view, adjusting based on the
8157 // assumed local density.
8158 final float appScale = context.getResources().getCompatibilityInfo().applicationScale;
8159 final int[] pos = new int[2];
8160 target.getLocationOnScreen(pos);
8161
8162 final Rect rect = new Rect();
8163 rect.left = (int) (pos[0] * appScale + 0.5f);
8164 rect.top = (int) (pos[1] * appScale + 0.5f);
8165 rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f);
8166 rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f);
8167
8168 return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes);
8169 }
8170
8171 /**
8172 * Constructs the QuickContacts intent.
8173 * @hide
8174 */
8175 public static Intent composeQuickContactsIntent(Context context, Rect target,
8176 Uri lookupUri, int mode, String[] excludeMimes) {
8177 // When launching from an Activiy, we don't want to start a new task, but otherwise
8178 // we *must* start a new task. (Otherwise startActivity() would crash.)
8179 Context actualContext = context;
8180 while ((actualContext instanceof ContextWrapper)
8181 && !(actualContext instanceof Activity)) {
8182 actualContext = ((ContextWrapper) actualContext).getBaseContext();
8183 }
Brian Attwell9ee66402014-08-11 22:42:26 -07008184 final int intentFlags = ((actualContext instanceof Activity)
8185 ? 0 : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
8186 // Workaround for b/16898764. Declaring singleTop in manifest doesn't work.
8187 | Intent.FLAG_ACTIVITY_SINGLE_TOP;
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008188
8189 // Launch pivot dialog through intent for now
8190 final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags);
8191
8192 intent.setData(lookupUri);
8193 intent.setSourceBounds(target);
8194 intent.putExtra(EXTRA_MODE, mode);
8195 intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes);
8196 return intent;
8197 }
8198
8199 /**
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008200 * Trigger a dialog that lists the various methods of interacting with
8201 * the requested {@link Contacts} entry. This may be based on available
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008202 * {@link ContactsContract.Data} rows under that contact, and may also
8203 * include social status and presence details.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008204 *
8205 * @param context The parent {@link Context} that may be used as the
8206 * parent for this dialog.
8207 * @param target Specific {@link View} from your layout that this dialog
8208 * should be centered around. In particular, if the dialog
8209 * has a "callout" arrow, it will be pointed and centered
8210 * around this {@link View}.
Evan Millar772722e2009-09-30 22:24:07 -07008211 * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008212 * {@link Uri} that describes a specific contact to feature
8213 * in this dialog.
8214 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
8215 * {@link #MODE_LARGE}, indicating the desired dialog size,
8216 * when supported.
8217 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
8218 * to exclude when showing this dialog. For example, when
8219 * already viewing the contact details card, this can be used
8220 * to omit the details entry from the dialog.
8221 */
Evan Millare3ec9972009-09-30 19:37:36 -07008222 public static void showQuickContact(Context context, View target, Uri lookupUri, int mode,
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008223 String[] excludeMimes) {
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008224 // Trigger with obtained rectangle
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008225 Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
8226 excludeMimes);
Yorke Lee4fc601a2013-12-06 16:35:29 -08008227 startActivityWithErrorToast(context, intent);
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008228 }
8229
8230 /**
8231 * Trigger a dialog that lists the various methods of interacting with
8232 * the requested {@link Contacts} entry. This may be based on available
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008233 * {@link ContactsContract.Data} rows under that contact, and may also
8234 * include social status and presence details.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008235 *
8236 * @param context The parent {@link Context} that may be used as the
8237 * parent for this dialog.
8238 * @param target Specific {@link Rect} that this dialog should be
8239 * centered around, in screen coordinates. In particular, if
8240 * the dialog has a "callout" arrow, it will be pointed and
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08008241 * centered around this {@link Rect}. If you are running at a
8242 * non-native density, you need to manually adjust using
8243 * {@link DisplayMetrics#density} before calling.
Jeff Sharkey223bd7a2009-12-21 14:51:19 -08008244 * @param lookupUri A
8245 * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008246 * {@link Uri} that describes a specific contact to feature
8247 * in this dialog.
8248 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
8249 * {@link #MODE_LARGE}, indicating the desired dialog size,
8250 * when supported.
8251 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
8252 * to exclude when showing this dialog. For example, when
8253 * already viewing the contact details card, this can be used
8254 * to omit the details entry from the dialog.
8255 */
Evan Millare3ec9972009-09-30 19:37:36 -07008256 public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode,
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008257 String[] excludeMimes) {
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008258 Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
8259 excludeMimes);
Yorke Lee4fc601a2013-12-06 16:35:29 -08008260 startActivityWithErrorToast(context, intent);
8261 }
8262
8263 private static void startActivityWithErrorToast(Context context, Intent intent) {
8264 try {
8265 context.startActivity(intent);
8266 } catch (ActivityNotFoundException e) {
8267 Toast.makeText(context, com.android.internal.R.string.quick_contacts_not_available,
8268 Toast.LENGTH_SHORT).show();
8269 }
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008270 }
8271 }
8272
8273 /**
Dave Santoroa5282372011-06-29 00:25:16 -07008274 * Helper class for accessing full-size photos by photo file ID.
8275 * <p>
8276 * Usage example:
8277 * <dl>
8278 * <dt>Retrieving a full-size photo by photo file ID (see
8279 * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID})
8280 * </dt>
8281 * <dd>
8282 * <pre>
8283 * public InputStream openDisplayPhoto(long photoFileId) {
8284 * Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey);
8285 * try {
Dave Santoro040e6b32011-07-15 15:14:08 -07008286 * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(
8287 * displayPhotoUri, "r");
Dave Santoroa5282372011-06-29 00:25:16 -07008288 * return fd.createInputStream();
Dave Santoro040e6b32011-07-15 15:14:08 -07008289 * } catch (IOException e) {
Dave Santoroa5282372011-06-29 00:25:16 -07008290 * return null;
8291 * }
8292 * }
8293 * </pre>
8294 * </dd>
8295 * </dl>
8296 * </p>
8297 */
8298 public static final class DisplayPhoto {
8299 /**
8300 * no public constructor since this is a utility class
8301 */
8302 private DisplayPhoto() {}
8303
8304 /**
8305 * The content:// style URI for this class, which allows access to full-size photos,
8306 * given a key.
8307 */
8308 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo");
8309
8310 /**
8311 * This URI allows the caller to query for the maximum dimensions of a display photo
8312 * or thumbnail. Requests to this URI can be performed on the UI thread because
8313 * they are always unblocking.
8314 */
8315 public static final Uri CONTENT_MAX_DIMENSIONS_URI =
8316 Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions");
8317
8318 /**
8319 * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will
8320 * contain this column, populated with the maximum height and width (in pixels)
8321 * that will be stored for a display photo. Larger photos will be down-sized to
8322 * fit within a square of this many pixels.
8323 */
8324 public static final String DISPLAY_MAX_DIM = "display_max_dim";
8325
8326 /**
8327 * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will
8328 * contain this column, populated with the height and width (in pixels) for photo
8329 * thumbnails.
8330 */
8331 public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim";
8332 }
8333
8334 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008335 * Contains helper classes used to create or manage {@link android.content.Intent Intents}
8336 * that involve contacts.
8337 */
8338 public static final class Intents {
8339 /**
8340 * This is the intent that is fired when a search suggestion is clicked on.
8341 */
8342 public static final String SEARCH_SUGGESTION_CLICKED =
8343 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
8344
8345 /**
8346 * This is the intent that is fired when a search suggestion for dialing a number
8347 * is clicked on.
8348 */
8349 public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
8350 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
8351
8352 /**
8353 * This is the intent that is fired when a search suggestion for creating a contact
8354 * is clicked on.
8355 */
8356 public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
8357 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
8358
8359 /**
Chiao Cheng2355d132013-03-20 16:54:06 -07008360 * This is the intent that is fired when the contacts database is created. <p> The
8361 * READ_CONTACT permission is required to receive these broadcasts.
8362 */
8363 public static final String CONTACTS_DATABASE_CREATED =
8364 "android.provider.Contacts.DATABASE_CREATED";
8365
8366 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008367 * Starts an Activity that lets the user pick a contact to attach an image to.
8368 * After picking the contact it launches the image cropper in face detection mode.
8369 */
8370 public static final String ATTACH_IMAGE =
8371 "com.android.contacts.action.ATTACH_IMAGE";
8372
8373 /**
Makoto Onuki85a01a6b2011-07-21 15:16:31 -07008374 * This is the intent that is fired when the user clicks the "invite to the network" button
8375 * on a contact. Only sent to an activity which is explicitly registered by a contact
8376 * provider which supports the "invite to the network" feature.
8377 * <p>
8378 * {@link Intent#getData()} contains the lookup URI for the contact.
8379 */
8380 public static final String INVITE_CONTACT =
8381 "com.android.contacts.action.INVITE_CONTACT";
8382
8383 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008384 * Takes as input a data URI with a mailto: or tel: scheme. If a single
8385 * contact exists with the given data it will be shown. If no contact
8386 * exists, a dialog will ask the user if they want to create a new
8387 * contact with the provided details filled in. If multiple contacts
8388 * share the data the user will be prompted to pick which contact they
8389 * want to view.
8390 * <p>
8391 * For <code>mailto:</code> URIs, the scheme specific portion must be a
8392 * raw email address, such as one built using
8393 * {@link Uri#fromParts(String, String, String)}.
8394 * <p>
8395 * For <code>tel:</code> URIs, the scheme specific portion is compared
8396 * to existing numbers using the standard caller ID lookup algorithm.
8397 * The number must be properly encoded, for example using
8398 * {@link Uri#fromParts(String, String, String)}.
8399 * <p>
8400 * Any extras from the {@link Insert} class will be passed along to the
8401 * create activity if there are no contacts to show.
8402 * <p>
8403 * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
8404 * prompting the user when the contact doesn't exist.
8405 */
8406 public static final String SHOW_OR_CREATE_CONTACT =
8407 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
8408
8409 /**
Bai Taofc7838b2010-01-22 03:34:56 +08008410 * Starts an Activity that lets the user select the multiple phones from a
8411 * list of phone numbers which come from the contacts or
8412 * {@link #EXTRA_PHONE_URIS}.
8413 * <p>
8414 * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS}
8415 * could belong to the contacts or not, and will be selected by default.
8416 * <p>
8417 * The user's selection will be returned from
8418 * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}
Fred Quintanaa31a9452010-04-13 14:52:20 -07008419 * if the resultCode is
Bai Taofc7838b2010-01-22 03:34:56 +08008420 * {@link android.app.Activity#RESULT_OK}, the array of picked phone
8421 * numbers are in the Intent's
8422 * {@link #EXTRA_PHONE_URIS}; otherwise, the
8423 * {@link android.app.Activity#RESULT_CANCELED} is returned if the user
8424 * left the Activity without changing the selection.
8425 *
8426 * @hide
8427 */
8428 public static final String ACTION_GET_MULTIPLE_PHONES =
8429 "com.android.contacts.action.GET_MULTIPLE_PHONES";
8430
8431 /**
Makoto Onuki90ddc902012-09-11 18:22:53 -07008432 * A broadcast action which is sent when any change has been made to the profile, such
8433 * as the profile name or the picture. A receiver must have
8434 * the android.permission.READ_PROFILE permission.
8435 *
8436 * @hide
8437 */
8438 public static final String ACTION_PROFILE_CHANGED =
8439 "android.provider.Contacts.PROFILE_CHANGED";
8440
8441 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008442 * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
8443 * contact if no matching contact found. Otherwise, default behavior is
8444 * to prompt user with dialog before creating.
8445 * <p>
8446 * Type: BOOLEAN
8447 */
8448 public static final String EXTRA_FORCE_CREATE =
8449 "com.android.contacts.action.FORCE_CREATE";
8450
8451 /**
8452 * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
8453 * description to be shown when prompting user about creating a new
8454 * contact.
8455 * <p>
8456 * Type: STRING
8457 */
8458 public static final String EXTRA_CREATE_DESCRIPTION =
8459 "com.android.contacts.action.CREATE_DESCRIPTION";
8460
8461 /**
Bai Taofc7838b2010-01-22 03:34:56 +08008462 * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value.
8463 * <p>
8464 * The phone numbers want to be picked by default should be passed in as
8465 * input value. These phone numbers could belong to the contacts or not.
8466 * <p>
8467 * The phone numbers which were picked by the user are returned as output
8468 * value.
8469 * <p>
8470 * Type: array of URIs, the tel URI is used for the phone numbers which don't
8471 * belong to any contact, the content URI is used for phone id in contacts.
Fred Quintanaa31a9452010-04-13 14:52:20 -07008472 *
Bai Taofc7838b2010-01-22 03:34:56 +08008473 * @hide
8474 */
8475 public static final String EXTRA_PHONE_URIS =
8476 "com.android.contacts.extra.PHONE_URIS";
8477
8478 /**
Jeff Sharkey11322002009-06-04 17:25:51 -07008479 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
8480 * dialog location using screen coordinates. When not specified, the
8481 * dialog will be centered.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008482 *
8483 * @hide
Jeff Sharkey11322002009-06-04 17:25:51 -07008484 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008485 @Deprecated
Jeff Sharkey11322002009-06-04 17:25:51 -07008486 public static final String EXTRA_TARGET_RECT = "target_rect";
8487
8488 /**
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008489 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
8490 * desired dialog style, usually a variation on size. One of
8491 * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008492 *
8493 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008494 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008495 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008496 public static final String EXTRA_MODE = "mode";
8497
8498 /**
8499 * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008500 *
8501 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008502 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008503 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008504 public static final int MODE_SMALL = 1;
8505
8506 /**
8507 * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008508 *
8509 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008510 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008511 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008512 public static final int MODE_MEDIUM = 2;
8513
8514 /**
8515 * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008516 *
8517 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008518 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008519 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07008520 public static final int MODE_LARGE = 3;
8521
8522 /**
Jeff Sharkey84235ee2009-08-23 14:07:02 -07008523 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate
8524 * a list of specific MIME-types to exclude and not display. Stored as a
8525 * {@link String} array.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008526 *
8527 * @hide
Jeff Sharkey84235ee2009-08-23 14:07:02 -07008528 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008529 @Deprecated
Jeff Sharkey84235ee2009-08-23 14:07:02 -07008530 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
8531
8532 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008533 * Intents related to the Contacts app UI.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008534 *
8535 * @hide
Evan Millardc2da5f2009-06-18 16:07:13 -07008536 */
8537 public static final class UI {
8538 /**
8539 * The action for the default contacts list tab.
8540 */
8541 public static final String LIST_DEFAULT =
8542 "com.android.contacts.action.LIST_DEFAULT";
8543
8544 /**
8545 * The action for the contacts list tab.
8546 */
8547 public static final String LIST_GROUP_ACTION =
8548 "com.android.contacts.action.LIST_GROUP";
8549
8550 /**
8551 * When in LIST_GROUP_ACTION mode, this is the group to display.
8552 */
8553 public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP";
8554
8555 /**
8556 * The action for the all contacts list tab.
8557 */
8558 public static final String LIST_ALL_CONTACTS_ACTION =
8559 "com.android.contacts.action.LIST_ALL_CONTACTS";
8560
8561 /**
8562 * The action for the contacts with phone numbers list tab.
8563 */
8564 public static final String LIST_CONTACTS_WITH_PHONES_ACTION =
8565 "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES";
8566
8567 /**
8568 * The action for the starred contacts list tab.
8569 */
8570 public static final String LIST_STARRED_ACTION =
8571 "com.android.contacts.action.LIST_STARRED";
8572
8573 /**
8574 * The action for the frequent contacts list tab.
8575 */
8576 public static final String LIST_FREQUENT_ACTION =
8577 "com.android.contacts.action.LIST_FREQUENT";
8578
8579 /**
Brian Attwelle98a95c2014-07-22 20:53:59 -07008580 * The action for the "Join Contact" picker.
8581 */
8582 public static final String PICK_JOIN_CONTACT_ACTION =
8583 "com.android.contacts.action.JOIN_CONTACT";
8584
8585 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008586 * The action for the "strequent" contacts list tab. It first lists the starred
8587 * contacts in alphabetical order and then the frequent contacts in descending
8588 * order of the number of times they have been contacted.
8589 */
8590 public static final String LIST_STREQUENT_ACTION =
8591 "com.android.contacts.action.LIST_STREQUENT";
8592
8593 /**
8594 * A key for to be used as an intent extra to set the activity
8595 * title to a custom String value.
8596 */
8597 public static final String TITLE_EXTRA_KEY =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008598 "com.android.contacts.extra.TITLE_EXTRA";
Evan Millardc2da5f2009-06-18 16:07:13 -07008599
8600 /**
8601 * Activity Action: Display a filtered list of contacts
8602 * <p>
8603 * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for
8604 * filtering
8605 * <p>
8606 * Output: Nothing.
8607 */
8608 public static final String FILTER_CONTACTS_ACTION =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008609 "com.android.contacts.action.FILTER_CONTACTS";
Evan Millardc2da5f2009-06-18 16:07:13 -07008610
8611 /**
8612 * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION}
8613 * intents to supply the text on which to filter.
8614 */
8615 public static final String FILTER_TEXT_EXTRA_KEY =
Jeff Hamilton85abdc52009-09-22 12:41:45 -05008616 "com.android.contacts.extra.FILTER_TEXT";
Brian Attwelle98a95c2014-07-22 20:53:59 -07008617
8618 /**
8619 * Used with JOIN_CONTACT action to set the target for aggregation. This action type
8620 * uses contact ids instead of contact uris for the sake of backwards compatibility.
8621 * <p>
8622 * Type: LONG
8623 */
8624 public static final String TARGET_CONTACT_ID_EXTRA_KEY
8625 = "com.android.contacts.action.CONTACT_ID";
Evan Millardc2da5f2009-06-18 16:07:13 -07008626 }
8627
8628 /**
8629 * Convenience class that contains string constants used
8630 * to create contact {@link android.content.Intent Intents}.
8631 */
8632 public static final class Insert {
8633 /** The action code to use when adding a contact */
8634 public static final String ACTION = Intent.ACTION_INSERT;
8635
8636 /**
8637 * If present, forces a bypass of quick insert mode.
8638 */
8639 public static final String FULL_MODE = "full_mode";
8640
8641 /**
8642 * The extra field for the contact name.
8643 * <P>Type: String</P>
8644 */
8645 public static final String NAME = "name";
8646
8647 // TODO add structured name values here.
8648
8649 /**
8650 * The extra field for the contact phonetic name.
8651 * <P>Type: String</P>
8652 */
8653 public static final String PHONETIC_NAME = "phonetic_name";
8654
8655 /**
8656 * The extra field for the contact company.
8657 * <P>Type: String</P>
8658 */
8659 public static final String COMPANY = "company";
8660
8661 /**
8662 * The extra field for the contact job title.
8663 * <P>Type: String</P>
8664 */
8665 public static final String JOB_TITLE = "job_title";
8666
8667 /**
8668 * The extra field for the contact notes.
8669 * <P>Type: String</P>
8670 */
8671 public static final String NOTES = "notes";
8672
8673 /**
8674 * The extra field for the contact phone number.
8675 * <P>Type: String</P>
8676 */
8677 public static final String PHONE = "phone";
8678
8679 /**
8680 * The extra field for the contact phone number type.
8681 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008682 * {@link CommonDataKinds.Phone},
Evan Millardc2da5f2009-06-18 16:07:13 -07008683 * or a string specifying a custom label.</P>
8684 */
8685 public static final String PHONE_TYPE = "phone_type";
8686
8687 /**
8688 * The extra field for the phone isprimary flag.
8689 * <P>Type: boolean</P>
8690 */
8691 public static final String PHONE_ISPRIMARY = "phone_isprimary";
8692
8693 /**
8694 * The extra field for an optional second contact phone number.
8695 * <P>Type: String</P>
8696 */
8697 public static final String SECONDARY_PHONE = "secondary_phone";
8698
8699 /**
8700 * The extra field for an optional second contact phone number type.
8701 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008702 * {@link CommonDataKinds.Phone},
Evan Millardc2da5f2009-06-18 16:07:13 -07008703 * or a string specifying a custom label.</P>
8704 */
8705 public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
8706
8707 /**
8708 * The extra field for an optional third contact phone number.
8709 * <P>Type: String</P>
8710 */
8711 public static final String TERTIARY_PHONE = "tertiary_phone";
8712
8713 /**
8714 * The extra field for an optional third contact phone number type.
8715 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008716 * {@link CommonDataKinds.Phone},
Evan Millardc2da5f2009-06-18 16:07:13 -07008717 * or a string specifying a custom label.</P>
8718 */
8719 public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
8720
8721 /**
8722 * The extra field for the contact email address.
8723 * <P>Type: String</P>
8724 */
8725 public static final String EMAIL = "email";
8726
8727 /**
8728 * The extra field for the contact email type.
8729 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008730 * {@link CommonDataKinds.Email}
Evan Millardc2da5f2009-06-18 16:07:13 -07008731 * or a string specifying a custom label.</P>
8732 */
8733 public static final String EMAIL_TYPE = "email_type";
8734
8735 /**
8736 * The extra field for the email isprimary flag.
8737 * <P>Type: boolean</P>
8738 */
8739 public static final String EMAIL_ISPRIMARY = "email_isprimary";
8740
8741 /**
8742 * The extra field for an optional second contact email address.
8743 * <P>Type: String</P>
8744 */
8745 public static final String SECONDARY_EMAIL = "secondary_email";
8746
8747 /**
8748 * The extra field for an optional second contact email type.
8749 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008750 * {@link CommonDataKinds.Email}
Evan Millardc2da5f2009-06-18 16:07:13 -07008751 * or a string specifying a custom label.</P>
8752 */
8753 public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
8754
8755 /**
8756 * The extra field for an optional third contact email address.
8757 * <P>Type: String</P>
8758 */
8759 public static final String TERTIARY_EMAIL = "tertiary_email";
8760
8761 /**
8762 * The extra field for an optional third contact email type.
8763 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008764 * {@link CommonDataKinds.Email}
Evan Millardc2da5f2009-06-18 16:07:13 -07008765 * or a string specifying a custom label.</P>
8766 */
8767 public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
8768
8769 /**
8770 * The extra field for the contact postal address.
8771 * <P>Type: String</P>
8772 */
8773 public static final String POSTAL = "postal";
8774
8775 /**
8776 * The extra field for the contact postal address type.
8777 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008778 * {@link CommonDataKinds.StructuredPostal}
Evan Millardc2da5f2009-06-18 16:07:13 -07008779 * or a string specifying a custom label.</P>
8780 */
8781 public static final String POSTAL_TYPE = "postal_type";
8782
8783 /**
8784 * The extra field for the postal isprimary flag.
8785 * <P>Type: boolean</P>
8786 */
8787 public static final String POSTAL_ISPRIMARY = "postal_isprimary";
8788
8789 /**
8790 * The extra field for an IM handle.
8791 * <P>Type: String</P>
8792 */
8793 public static final String IM_HANDLE = "im_handle";
8794
8795 /**
8796 * The extra field for the IM protocol
Evan Millardc2da5f2009-06-18 16:07:13 -07008797 */
8798 public static final String IM_PROTOCOL = "im_protocol";
8799
8800 /**
8801 * The extra field for the IM isprimary flag.
8802 * <P>Type: boolean</P>
8803 */
8804 public static final String IM_ISPRIMARY = "im_isprimary";
Dmitri Plotnikovbb549292010-10-18 20:37:02 -07008805
8806 /**
8807 * The extra field that allows the client to supply multiple rows of
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07008808 * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT}
8809 * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of
8810 * {@link ContentValues}, one per data row. Supplying this extra is
8811 * similar to inserting multiple rows into the {@link Data} table,
8812 * except the user gets a chance to see and edit them before saving.
8813 * Each ContentValues object must have a value for {@link Data#MIMETYPE}.
8814 * If supplied values are not visible in the editor UI, they will be
8815 * dropped. Duplicate data will dropped. Some fields
8816 * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically
8817 * adjusted to comply with the constraints of the specific account type.
8818 * For example, an Exchange contact can only have one phone numbers of type Home,
8819 * so the contact editor may choose a different type for this phone number to
8820 * avoid dropping the valueable part of the row, which is the phone number.
8821 * <p>
8822 * Example:
8823 * <pre>
8824 * ArrayList&lt;ContentValues&gt; data = new ArrayList&lt;ContentValues&gt;();
Dmitri Plotnikovbb549292010-10-18 20:37:02 -07008825 *
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07008826 * ContentValues row1 = new ContentValues();
8827 * row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE);
8828 * row1.put(Organization.COMPANY, "Android");
8829 * data.add(row1);
8830 *
8831 * ContentValues row2 = new ContentValues();
8832 * row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
8833 * row2.put(Email.TYPE, Email.TYPE_CUSTOM);
8834 * row2.put(Email.LABEL, "Green Bot");
8835 * row2.put(Email.ADDRESS, "android@android.com");
8836 * data.add(row2);
8837 *
8838 * Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
8839 * intent.putParcelableArrayListExtra(Insert.DATA, data);
8840 *
8841 * startActivity(intent);
8842 * </pre>
Dmitri Plotnikovbb549292010-10-18 20:37:02 -07008843 */
8844 public static final String DATA = "data";
Daniel Lehmanncde1ac62010-10-21 20:40:11 -07008845
8846 /**
8847 * Used to specify the account in which to create the new contact.
8848 * <p>
8849 * If this value is not provided, the user is presented with a disambiguation
8850 * dialog to chose an account
8851 * <p>
8852 * Type: {@link Account}
8853 *
8854 * @hide
8855 */
8856 public static final String ACCOUNT = "com.android.contacts.extra.ACCOUNT";
Dave Santoro1d55c332011-07-25 16:44:45 -07008857
8858 /**
8859 * Used to specify the data set within the account in which to create the
8860 * new contact.
8861 * <p>
8862 * This value is optional - if it is not specified, the contact will be
8863 * created in the base account, with no data set.
8864 * <p>
8865 * Type: String
8866 *
8867 * @hide
8868 */
8869 public static final String DATA_SET = "com.android.contacts.extra.DATA_SET";
Evan Millardc2da5f2009-06-18 16:07:13 -07008870 }
8871 }
Evan Millar088b2912009-05-28 15:24:37 -07008872}