Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.provider; |
| 18 | |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 19 | import android.accounts.Account; |
Daniel Lehmann | e6d3d28 | 2011-07-13 15:35:05 -0700 | [diff] [blame] | 20 | import android.app.Activity; |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 21 | import android.app.admin.DevicePolicyManager; |
Yorke Lee | 4fc601a | 2013-12-06 16:35:29 -0800 | [diff] [blame] | 22 | import android.content.ActivityNotFoundException; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 23 | import android.content.ContentProviderClient; |
| 24 | import android.content.ContentProviderOperation; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 25 | import android.content.ContentResolver; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 26 | import android.content.ContentUris; |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 27 | import android.content.ContentValues; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 28 | import android.content.Context; |
Makoto Onuki | bba33cd | 2012-05-25 17:09:05 -0700 | [diff] [blame] | 29 | import android.content.ContextWrapper; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 30 | import android.content.CursorEntityIterator; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 31 | import android.content.Entity; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 32 | import android.content.EntityIterator; |
| 33 | import android.content.Intent; |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 34 | import android.content.res.AssetFileDescriptor; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 35 | import android.content.res.Resources; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 36 | import android.database.Cursor; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 37 | import android.database.DatabaseUtils; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 38 | import android.graphics.Rect; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 39 | import android.net.Uri; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 40 | import android.os.RemoteException; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 41 | import android.text.TextUtils; |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 42 | import android.util.DisplayMetrics; |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 43 | import android.util.Pair; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 44 | import android.view.View; |
Yorke Lee | 4fc601a | 2013-12-06 16:35:29 -0800 | [diff] [blame] | 45 | import android.widget.Toast; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 46 | |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 47 | import java.io.ByteArrayInputStream; |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 48 | import java.io.IOException; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 49 | import java.io.InputStream; |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 50 | import java.util.ArrayList; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 51 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 52 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 53 | * <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 Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 63 | * <ul> |
| 64 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 65 | * 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 Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 69 | * </li> |
| 70 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 71 | * 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 Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 74 | * </li> |
| 75 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 76 | * A row in the {@link Contacts} table represents an aggregate of one or more |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 77 | * 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 Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 80 | * </li> |
| 81 | * </ul> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 82 | * <p> |
| 83 | * Other tables include: |
| 84 | * </p> |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 85 | * <ul> |
| 86 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 87 | * {@link Groups}, which contains information about raw contact groups |
| 88 | * such as Gmail contact groups. The |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 89 | * current API does not support the notion of groups spanning multiple accounts. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 90 | * </li> |
| 91 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 92 | * {@link StatusUpdates}, which contains social status updates including IM |
| 93 | * availability. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 94 | * </li> |
| 95 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 96 | * {@link AggregationExceptions}, which is used for manual aggregation and |
| 97 | * disaggregation of raw contacts |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 98 | * </li> |
| 99 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 100 | * {@link Settings}, which contains visibility and sync settings for accounts |
| 101 | * and groups. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 102 | * </li> |
| 103 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 104 | * {@link SyncState}, which contains free-form data maintained on behalf of sync |
| 105 | * adapters |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 106 | * </li> |
| 107 | * <li> |
| 108 | * {@link PhoneLookup}, which is used for quick caller-ID lookup</li> |
| 109 | * </ul> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 110 | */ |
Jeff Hamilton | 0c23212 | 2009-09-24 00:26:50 -0500 | [diff] [blame] | 111 | @SuppressWarnings("unused") |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 112 | public 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 Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 118 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 119 | * An optional URI parameter for insert, update, or delete queries |
| 120 | * that allows the caller |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 121 | * to specify that it is a sync adapter. The default value is false. If true |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 122 | * {@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 Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 128 | */ |
| 129 | public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter"; |
| 130 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 131 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 132 | * 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 Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 136 | */ |
| 137 | public static final String DIRECTORY_PARAM_KEY = "directory"; |
| 138 | |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 139 | /** |
Dmitri Plotnikov | 5a998dd | 2010-08-31 17:32:16 -0700 | [diff] [blame] | 140 | * 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 Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 146 | * 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 Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 154 | */ |
| 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 Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 160 | */ |
| 161 | public static final String PRIMARY_ACCOUNT_TYPE = "type_for_primary_account"; |
| 162 | |
Daisuke Miyakawa | f468591 | 2011-06-25 12:31:13 -0700 | [diff] [blame] | 163 | /** |
| 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 Miyakawa | f468591 | 2011-06-25 12:31:13 -0700 | [diff] [blame] | 168 | */ |
| 169 | public static final String STREQUENT_PHONE_ONLY = "strequent_phone_only"; |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 170 | |
| 171 | /** |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 172 | * 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 Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 175 | * |
| 176 | * @see SearchSnippets |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 177 | */ |
| 178 | public static final String DEFERRED_SNIPPETING = "deferred_snippeting"; |
| 179 | |
| 180 | /** |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 181 | * Key to retrieve the original deferred snippeting from the cursor on the client side. |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 182 | * |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 183 | * @see SearchSnippets |
| 184 | * @see #DEFERRED_SNIPPETING |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 185 | */ |
| 186 | public static final String DEFERRED_SNIPPETING_QUERY = "deferred_snippeting_query"; |
| 187 | |
| 188 | /** |
Yorke Lee | 1ca440b | 2014-06-04 18:01:46 -0700 | [diff] [blame] | 189 | * 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 Miyakawa | 19352e0 | 2011-11-14 13:16:07 -0800 | [diff] [blame] | 192 | * This enables a content provider to remove duplicate entries in results. |
Daisuke Miyakawa | 19352e0 | 2011-11-14 13:16:07 -0800 | [diff] [blame] | 193 | */ |
| 194 | public static final String REMOVE_DUPLICATE_ENTRIES = "remove_duplicate_entries"; |
| 195 | |
| 196 | /** |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 197 | * <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 |
Brian Attwell | cc4b2f7 | 2015-01-08 14:58:15 -0800 | [diff] [blame] | 201 | * {@link SecurityException} will be thrown. Unlike {@link Context#grantUriPermission}, |
| 202 | * this can be used to grant permissions that aren't explicitly required for the URI inside |
| 203 | * AndroidManifest.xml. For example, permissions that are only required when reading URIs |
| 204 | * that refer to the user's profile. |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 205 | * </p> |
| 206 | * <p> |
| 207 | * The authorized URI returned in the bundle contains an expiring token that allows the |
| 208 | * caller to execute the query without having the special permissions that would normally |
Brian Attwell | cc4b2f7 | 2015-01-08 14:58:15 -0800 | [diff] [blame] | 209 | * be required. The token expires in five minutes. |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 210 | * </p> |
| 211 | * <p> |
| 212 | * This API does not access disk, and should be safe to invoke from the UI thread. |
| 213 | * </p> |
| 214 | * <p> |
| 215 | * Example usage: |
| 216 | * <pre> |
| 217 | * Uri profileUri = ContactsContract.Profile.CONTENT_VCARD_URI; |
| 218 | * Bundle uriBundle = new Bundle(); |
| 219 | * uriBundle.putParcelable(ContactsContract.Authorization.KEY_URI_TO_AUTHORIZE, uri); |
| 220 | * Bundle authResponse = getContext().getContentResolver().call( |
| 221 | * ContactsContract.AUTHORITY_URI, |
| 222 | * ContactsContract.Authorization.AUTHORIZATION_METHOD, |
| 223 | * null, // String arg, not used. |
| 224 | * uriBundle); |
| 225 | * if (authResponse != null) { |
| 226 | * Uri preauthorizedProfileUri = (Uri) authResponse.getParcelable( |
| 227 | * ContactsContract.Authorization.KEY_AUTHORIZED_URI); |
| 228 | * // This pre-authorized URI can be queried by a caller without READ_PROFILE |
| 229 | * // permission. |
| 230 | * } |
| 231 | * </pre> |
| 232 | * </p> |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 233 | */ |
| 234 | public static final class Authorization { |
| 235 | /** |
| 236 | * The method to invoke to create a pre-authorized URI out of the input argument. |
| 237 | */ |
| 238 | public static final String AUTHORIZATION_METHOD = "authorize"; |
| 239 | |
| 240 | /** |
| 241 | * The key to set in the outbound Bundle with the URI that should be authorized. |
| 242 | */ |
| 243 | public static final String KEY_URI_TO_AUTHORIZE = "uri_to_authorize"; |
| 244 | |
| 245 | /** |
| 246 | * The key to retrieve from the returned Bundle to obtain the pre-authorized URI. |
| 247 | */ |
| 248 | public static final String KEY_AUTHORIZED_URI = "authorized_uri"; |
| 249 | } |
| 250 | |
Yorke Lee | 6355c8f | 2014-07-08 11:48:42 -0700 | [diff] [blame] | 251 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 252 | * A Directory represents a contacts corpus, e.g. Local contacts, |
| 253 | * Google Apps Global Address List or Corporate Global Address List. |
| 254 | * <p> |
| 255 | * A Directory is implemented as a content provider with its unique authority and |
| 256 | * the same API as the main Contacts Provider. However, there is no expectation that |
| 257 | * every directory provider will implement this Contract in its entirety. If a |
| 258 | * directory provider does not have an implementation for a specific request, it |
| 259 | * should throw an UnsupportedOperationException. |
| 260 | * </p> |
| 261 | * <p> |
| 262 | * The most important use case for Directories is search. A Directory provider is |
Dmitri Plotnikov | 13e0357 | 2010-08-19 16:31:29 -0700 | [diff] [blame] | 263 | * expected to support at least {@link ContactsContract.Contacts#CONTENT_FILTER_URI |
| 264 | * Contacts.CONTENT_FILTER_URI}. If a Directory provider wants to participate |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 265 | * in email and phone lookup functionalities, it should also implement |
| 266 | * {@link CommonDataKinds.Email#CONTENT_FILTER_URI CommonDataKinds.Email.CONTENT_FILTER_URI} |
| 267 | * and |
| 268 | * {@link CommonDataKinds.Phone#CONTENT_FILTER_URI CommonDataKinds.Phone.CONTENT_FILTER_URI}. |
| 269 | * </p> |
| 270 | * <p> |
| 271 | * A directory provider should return NULL for every projection field it does not |
| 272 | * recognize, rather than throwing an exception. This way it will not be broken |
| 273 | * if ContactsContract is extended with new fields in the future. |
| 274 | * </p> |
| 275 | * <p> |
| 276 | * The client interacts with a directory via Contacts Provider by supplying an |
| 277 | * optional {@code directory=} query parameter. |
| 278 | * <p> |
| 279 | * <p> |
| 280 | * When the Contacts Provider receives the request, it transforms the URI and forwards |
| 281 | * the request to the corresponding directory content provider. |
| 282 | * The URI is transformed in the following fashion: |
| 283 | * <ul> |
| 284 | * <li>The URI authority is replaced with the corresponding {@link #DIRECTORY_AUTHORITY}.</li> |
| 285 | * <li>The {@code accountName=} and {@code accountType=} parameters are added or |
| 286 | * replaced using the corresponding {@link #ACCOUNT_TYPE} and {@link #ACCOUNT_NAME} values.</li> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 287 | * </ul> |
| 288 | * </p> |
| 289 | * <p> |
| 290 | * Clients should send directory requests to Contacts Provider and let it |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 291 | * forward them to the respective providers rather than constructing |
| 292 | * directory provider URIs by themselves. This level of indirection allows |
| 293 | * Contacts Provider to implement additional system-level features and |
| 294 | * optimizations. Access to Contacts Provider is protected by the |
Subir Jhanb | 603af61 | 2012-08-06 17:19:22 -0700 | [diff] [blame] | 295 | * READ_CONTACTS permission, but access to the directory provider is protected by |
| 296 | * BIND_DIRECTORY_SEARCH. This permission was introduced at the API level 17, for previous |
| 297 | * platform versions the provider should perform the following check to make sure the call |
| 298 | * is coming from the ContactsProvider: |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 299 | * <pre> |
| 300 | * private boolean isCallerAllowed() { |
| 301 | * PackageManager pm = getContext().getPackageManager(); |
| 302 | * for (String packageName: pm.getPackagesForUid(Binder.getCallingUid())) { |
| 303 | * if (packageName.equals("com.android.providers.contacts")) { |
| 304 | * return true; |
| 305 | * } |
| 306 | * } |
| 307 | * return false; |
| 308 | * } |
| 309 | * </pre> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 310 | * </p> |
| 311 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 312 | * The Directory table is read-only and is maintained by the Contacts Provider |
| 313 | * automatically. |
| 314 | * </p> |
| 315 | * <p>It always has at least these two rows: |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 316 | * <ul> |
| 317 | * <li> |
| 318 | * The local directory. It has {@link Directory#_ID Directory._ID} = |
| 319 | * {@link Directory#DEFAULT Directory.DEFAULT}. This directory can be used to access locally |
| 320 | * stored contacts. The same can be achieved by omitting the {@code directory=} |
| 321 | * parameter altogether. |
| 322 | * </li> |
| 323 | * <li> |
| 324 | * The local invisible contacts. The corresponding directory ID is |
| 325 | * {@link Directory#LOCAL_INVISIBLE Directory.LOCAL_INVISIBLE}. |
| 326 | * </li> |
| 327 | * </ul> |
| 328 | * </p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 329 | * <p>Custom Directories are discovered by the Contacts Provider following this procedure: |
| 330 | * <ul> |
| 331 | * <li>It finds all installed content providers with meta data identifying them |
| 332 | * as directory providers in AndroidManifest.xml: |
| 333 | * <code> |
| 334 | * <meta-data android:name="android.content.ContactDirectory" |
| 335 | * android:value="true" /> |
| 336 | * </code> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 337 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 338 | * This tag should be placed inside the corresponding content provider declaration. |
| 339 | * </p> |
| 340 | * </li> |
| 341 | * <li> |
| 342 | * Then Contacts Provider sends a {@link Directory#CONTENT_URI Directory.CONTENT_URI} |
| 343 | * query to each of the directory authorities. A directory provider must implement |
| 344 | * this query and return a list of directories. Each directory returned by |
| 345 | * the provider must have a unique combination for the {@link #ACCOUNT_NAME} and |
| 346 | * {@link #ACCOUNT_TYPE} columns (nulls are allowed). Since directory IDs are assigned |
| 347 | * automatically, the _ID field will not be part of the query projection. |
| 348 | * </li> |
| 349 | * <li>Contacts Provider compiles directory lists received from all directory |
| 350 | * providers into one, assigns each individual directory a globally unique ID and |
| 351 | * stores all directory records in the Directory table. |
| 352 | * </li> |
| 353 | * </ul> |
| 354 | * </p> |
| 355 | * <p>Contacts Provider automatically interrogates newly installed or replaced packages. |
| 356 | * Thus simply installing a package containing a directory provider is sufficient |
| 357 | * to have that provider registered. A package supplying a directory provider does |
| 358 | * not have to contain launchable activities. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 359 | * </p> |
| 360 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 361 | * Every row in the Directory table is automatically associated with the corresponding package |
| 362 | * (apk). If the package is later uninstalled, all corresponding directory rows |
| 363 | * are automatically removed from the Contacts Provider. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 364 | * </p> |
| 365 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 366 | * When the list of directories handled by a directory provider changes |
| 367 | * (for instance when the user adds a new Directory account), the directory provider |
| 368 | * should call {@link #notifyDirectoryChange} to notify the Contacts Provider of the change. |
| 369 | * In response, the Contacts Provider will requery the directory provider to obtain the |
| 370 | * new list of directories. |
| 371 | * </p> |
| 372 | * <p> |
| 373 | * A directory row can be optionally associated with an existing account |
| 374 | * (see {@link android.accounts.AccountManager}). If the account is later removed, |
Dmitri Plotnikov | e50ed08 | 2010-08-18 10:56:09 -0700 | [diff] [blame] | 375 | * the corresponding directory rows are automatically removed from the Contacts Provider. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 376 | * </p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 377 | */ |
| 378 | public static final class Directory implements BaseColumns { |
| 379 | |
| 380 | /** |
| 381 | * Not instantiable. |
| 382 | */ |
| 383 | private Directory() { |
| 384 | } |
| 385 | |
| 386 | /** |
| 387 | * The content:// style URI for this table. Requests to this URI can be |
| 388 | * performed on the UI thread because they are always unblocking. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 389 | */ |
| 390 | public static final Uri CONTENT_URI = |
| 391 | Uri.withAppendedPath(AUTHORITY_URI, "directories"); |
| 392 | |
| 393 | /** |
| 394 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 395 | * contact directories. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 396 | */ |
| 397 | public static final String CONTENT_TYPE = |
| 398 | "vnd.android.cursor.dir/contact_directories"; |
| 399 | |
| 400 | /** |
| 401 | * The MIME type of a {@link #CONTENT_URI} item. |
| 402 | */ |
| 403 | public static final String CONTENT_ITEM_TYPE = |
| 404 | "vnd.android.cursor.item/contact_directory"; |
| 405 | |
| 406 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 407 | * _ID of the default directory, which represents locally stored contacts. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 408 | */ |
| 409 | public static final long DEFAULT = 0; |
| 410 | |
| 411 | /** |
| 412 | * _ID of the directory that represents locally stored invisible contacts. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 413 | */ |
| 414 | public static final long LOCAL_INVISIBLE = 1; |
| 415 | |
| 416 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 417 | * The name of the package that owns this directory. Contacts Provider |
| 418 | * fill it in with the name of the package containing the directory provider. |
| 419 | * If the package is later uninstalled, the directories it owns are |
| 420 | * automatically removed from this table. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 421 | * |
| 422 | * <p>TYPE: TEXT</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 423 | */ |
| 424 | public static final String PACKAGE_NAME = "packageName"; |
| 425 | |
| 426 | /** |
| 427 | * The type of directory captured as a resource ID in the context of the |
| 428 | * package {@link #PACKAGE_NAME}, e.g. "Corporate Directory" |
| 429 | * |
| 430 | * <p>TYPE: INTEGER</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 431 | */ |
| 432 | public static final String TYPE_RESOURCE_ID = "typeResourceId"; |
| 433 | |
| 434 | /** |
| 435 | * An optional name that can be used in the UI to represent this directory, |
| 436 | * e.g. "Acme Corp" |
| 437 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 438 | */ |
| 439 | public static final String DISPLAY_NAME = "displayName"; |
| 440 | |
| 441 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 442 | * <p> |
| 443 | * The authority of the Directory Provider. Contacts Provider will |
| 444 | * use this authority to forward requests to the directory provider. |
| 445 | * A directory provider can leave this column empty - Contacts Provider will fill it in. |
| 446 | * </p> |
| 447 | * <p> |
| 448 | * Clients of this API should not send requests directly to this authority. |
| 449 | * All directory requests must be routed through Contacts Provider. |
| 450 | * </p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 451 | * |
| 452 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 453 | */ |
| 454 | public static final String DIRECTORY_AUTHORITY = "authority"; |
| 455 | |
| 456 | /** |
| 457 | * The account type which this directory is associated. |
| 458 | * |
| 459 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 460 | */ |
| 461 | public static final String ACCOUNT_TYPE = "accountType"; |
| 462 | |
| 463 | /** |
| 464 | * The account with which this directory is associated. If the account is later |
| 465 | * removed, the directories it owns are automatically removed from this table. |
| 466 | * |
| 467 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 468 | */ |
| 469 | public static final String ACCOUNT_NAME = "accountName"; |
| 470 | |
| 471 | /** |
| 472 | * One of {@link #EXPORT_SUPPORT_NONE}, {@link #EXPORT_SUPPORT_ANY_ACCOUNT}, |
| 473 | * {@link #EXPORT_SUPPORT_SAME_ACCOUNT_ONLY}. This is the expectation the |
| 474 | * directory has for data exported from it. Clients must obey this setting. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 475 | */ |
| 476 | public static final String EXPORT_SUPPORT = "exportSupport"; |
| 477 | |
| 478 | /** |
| 479 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 480 | * does not allow any data to be copied out of it. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 481 | */ |
| 482 | public static final int EXPORT_SUPPORT_NONE = 0; |
| 483 | |
| 484 | /** |
| 485 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 486 | * allow its data copied only to the account specified by |
| 487 | * {@link #ACCOUNT_TYPE}/{@link #ACCOUNT_NAME}. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 488 | */ |
| 489 | public static final int EXPORT_SUPPORT_SAME_ACCOUNT_ONLY = 1; |
| 490 | |
| 491 | /** |
| 492 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 493 | * allow its data copied to any contacts account. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 494 | */ |
| 495 | public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2; |
| 496 | |
| 497 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 498 | * One of {@link #SHORTCUT_SUPPORT_NONE}, {@link #SHORTCUT_SUPPORT_DATA_ITEMS_ONLY}, |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 499 | * {@link #SHORTCUT_SUPPORT_FULL}. This is the expectation the directory |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 500 | * has for shortcuts created for its elements. Clients must obey this setting. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 501 | */ |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 502 | public static final String SHORTCUT_SUPPORT = "shortcutSupport"; |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 503 | |
| 504 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 505 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 506 | * does not allow any shortcuts created for its contacts. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 507 | */ |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 508 | public static final int SHORTCUT_SUPPORT_NONE = 0; |
| 509 | |
| 510 | /** |
| 511 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 512 | * allow creation of shortcuts for data items like email, phone or postal address, |
| 513 | * but not the entire contact. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 514 | */ |
| 515 | public static final int SHORTCUT_SUPPORT_DATA_ITEMS_ONLY = 1; |
| 516 | |
| 517 | /** |
| 518 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 519 | * allow creation of shortcuts for contact as well as their constituent elements. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 520 | */ |
| 521 | public static final int SHORTCUT_SUPPORT_FULL = 2; |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 522 | |
| 523 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 524 | * One of {@link #PHOTO_SUPPORT_NONE}, {@link #PHOTO_SUPPORT_THUMBNAIL_ONLY}, |
| 525 | * {@link #PHOTO_SUPPORT_FULL}. This is a feature flag indicating the extent |
| 526 | * to which the directory supports contact photos. |
| 527 | */ |
| 528 | public static final String PHOTO_SUPPORT = "photoSupport"; |
| 529 | |
| 530 | /** |
| 531 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 532 | * does not provide any photos. |
| 533 | */ |
| 534 | public static final int PHOTO_SUPPORT_NONE = 0; |
| 535 | |
| 536 | /** |
| 537 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 538 | * can only produce small size thumbnails of contact photos. |
| 539 | */ |
| 540 | public static final int PHOTO_SUPPORT_THUMBNAIL_ONLY = 1; |
| 541 | |
| 542 | /** |
| 543 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 544 | * has full-size contact photos, but cannot provide scaled thumbnails. |
| 545 | */ |
| 546 | public static final int PHOTO_SUPPORT_FULL_SIZE_ONLY = 2; |
| 547 | |
| 548 | /** |
| 549 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 550 | * can produce thumbnails as well as full-size contact photos. |
| 551 | */ |
| 552 | public static final int PHOTO_SUPPORT_FULL = 3; |
| 553 | |
| 554 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 555 | * Notifies the system of a change in the list of directories handled by |
| 556 | * a particular directory provider. The Contacts provider will turn around |
| 557 | * and send a query to the directory provider for the full list of directories, |
| 558 | * which will replace the previous list. |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 559 | */ |
| 560 | public static void notifyDirectoryChange(ContentResolver resolver) { |
| 561 | // This is done to trigger a query by Contacts Provider back to the directory provider. |
| 562 | // No data needs to be sent back, because the provider can infer the calling |
| 563 | // package from binder. |
| 564 | ContentValues contentValues = new ContentValues(); |
| 565 | resolver.update(Directory.CONTENT_URI, contentValues, null, null); |
| 566 | } |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 570 | * @hide should be removed when users are updated to refer to SyncState |
| 571 | * @deprecated use SyncState instead |
| 572 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 573 | @Deprecated |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 574 | public interface SyncStateColumns extends SyncStateContract.Columns { |
| 575 | } |
| 576 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 577 | /** |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 578 | * A table provided for sync adapters to use for storing private sync state data for contacts. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 579 | * |
| 580 | * @see SyncStateContract |
| 581 | */ |
| 582 | public static final class SyncState implements SyncStateContract.Columns { |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 583 | /** |
| 584 | * This utility class cannot be instantiated |
| 585 | */ |
| 586 | private SyncState() {} |
| 587 | |
| 588 | public static final String CONTENT_DIRECTORY = |
| 589 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 590 | |
| 591 | /** |
| 592 | * The content:// style URI for this table |
| 593 | */ |
| 594 | public static final Uri CONTENT_URI = |
| 595 | Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY); |
| 596 | |
| 597 | /** |
| 598 | * @see android.provider.SyncStateContract.Helpers#get |
| 599 | */ |
| 600 | public static byte[] get(ContentProviderClient provider, Account account) |
| 601 | throws RemoteException { |
| 602 | return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| 603 | } |
| 604 | |
| 605 | /** |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 606 | * @see android.provider.SyncStateContract.Helpers#get |
| 607 | */ |
| 608 | public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) |
| 609 | throws RemoteException { |
| 610 | return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); |
| 611 | } |
| 612 | |
| 613 | /** |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 614 | * @see android.provider.SyncStateContract.Helpers#set |
| 615 | */ |
| 616 | public static void set(ContentProviderClient provider, Account account, byte[] data) |
| 617 | throws RemoteException { |
| 618 | SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| 619 | } |
| 620 | |
| 621 | /** |
| 622 | * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| 623 | */ |
| 624 | public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| 625 | return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| 626 | } |
| 627 | } |
| 628 | |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 629 | |
| 630 | /** |
| 631 | * A table provided for sync adapters to use for storing private sync state data for the |
| 632 | * user's personal profile. |
| 633 | * |
| 634 | * @see SyncStateContract |
| 635 | */ |
| 636 | public static final class ProfileSyncState implements SyncStateContract.Columns { |
| 637 | /** |
| 638 | * This utility class cannot be instantiated |
| 639 | */ |
| 640 | private ProfileSyncState() {} |
| 641 | |
| 642 | public static final String CONTENT_DIRECTORY = |
| 643 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 644 | |
| 645 | /** |
| 646 | * The content:// style URI for this table |
| 647 | */ |
| 648 | public static final Uri CONTENT_URI = |
| 649 | Uri.withAppendedPath(Profile.CONTENT_URI, CONTENT_DIRECTORY); |
| 650 | |
| 651 | /** |
| 652 | * @see android.provider.SyncStateContract.Helpers#get |
| 653 | */ |
| 654 | public static byte[] get(ContentProviderClient provider, Account account) |
| 655 | throws RemoteException { |
| 656 | return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| 657 | } |
| 658 | |
| 659 | /** |
| 660 | * @see android.provider.SyncStateContract.Helpers#get |
| 661 | */ |
| 662 | public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) |
| 663 | throws RemoteException { |
| 664 | return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); |
| 665 | } |
| 666 | |
| 667 | /** |
| 668 | * @see android.provider.SyncStateContract.Helpers#set |
| 669 | */ |
| 670 | public static void set(ContentProviderClient provider, Account account, byte[] data) |
| 671 | throws RemoteException { |
| 672 | SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| 673 | } |
| 674 | |
| 675 | /** |
| 676 | * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| 677 | */ |
| 678 | public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| 679 | return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| 680 | } |
| 681 | } |
| 682 | |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 683 | /** |
| 684 | * Generic columns for use by sync adapters. The specific functions of |
| 685 | * these columns are private to the sync adapter. Other clients of the API |
| 686 | * should not attempt to either read or write this column. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 687 | * |
| 688 | * @see RawContacts |
| 689 | * @see Groups |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 690 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 691 | protected interface BaseSyncColumns { |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 692 | |
| 693 | /** Generic column for use by sync adapters. */ |
| 694 | public static final String SYNC1 = "sync1"; |
| 695 | /** Generic column for use by sync adapters. */ |
| 696 | public static final String SYNC2 = "sync2"; |
| 697 | /** Generic column for use by sync adapters. */ |
| 698 | public static final String SYNC3 = "sync3"; |
| 699 | /** Generic column for use by sync adapters. */ |
| 700 | public static final String SYNC4 = "sync4"; |
| 701 | } |
| 702 | |
| 703 | /** |
| 704 | * Columns that appear when each row of a table belongs to a specific |
| 705 | * account, including sync information that an account may need. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 706 | * |
| 707 | * @see RawContacts |
| 708 | * @see Groups |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 709 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 710 | protected interface SyncColumns extends BaseSyncColumns { |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 711 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 712 | * The name of the account instance to which this row belongs, which when paired with |
| 713 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 714 | * <P>Type: TEXT</P> |
| 715 | */ |
| 716 | public static final String ACCOUNT_NAME = "account_name"; |
| 717 | |
| 718 | /** |
| 719 | * The type of account to which this row belongs, which when paired with |
| 720 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 721 | * <P>Type: TEXT</P> |
| 722 | */ |
| 723 | public static final String ACCOUNT_TYPE = "account_type"; |
| 724 | |
| 725 | /** |
| 726 | * String that uniquely identifies this row to its source account. |
| 727 | * <P>Type: TEXT</P> |
| 728 | */ |
| 729 | public static final String SOURCE_ID = "sourceid"; |
| 730 | |
| 731 | /** |
| 732 | * Version number that is updated whenever this row or its related data |
| 733 | * changes. |
| 734 | * <P>Type: INTEGER</P> |
| 735 | */ |
| 736 | public static final String VERSION = "version"; |
| 737 | |
| 738 | /** |
| 739 | * Flag indicating that {@link #VERSION} has changed, and this row needs |
| 740 | * to be synchronized by its owning account. |
| 741 | * <P>Type: INTEGER (boolean)</P> |
| 742 | */ |
| 743 | public static final String DIRTY = "dirty"; |
| 744 | } |
| 745 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 746 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 747 | * Columns of {@link ContactsContract.Contacts} that track the user's |
| 748 | * preferences for, or interactions with, the contact. |
| 749 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 750 | * @see Contacts |
| 751 | * @see RawContacts |
| 752 | * @see ContactsContract.Data |
| 753 | * @see PhoneLookup |
| 754 | * @see ContactsContract.Contacts.AggregationSuggestions |
| 755 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 756 | protected interface ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 757 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 758 | * The number of times a contact has been contacted |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 759 | * <P>Type: INTEGER</P> |
| 760 | */ |
| 761 | public static final String TIMES_CONTACTED = "times_contacted"; |
| 762 | |
| 763 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 764 | * The last time a contact was contacted. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 765 | * <P>Type: INTEGER</P> |
| 766 | */ |
| 767 | public static final String LAST_TIME_CONTACTED = "last_time_contacted"; |
| 768 | |
| 769 | /** |
| 770 | * Is the contact starred? |
| 771 | * <P>Type: INTEGER (boolean)</P> |
| 772 | */ |
| 773 | public static final String STARRED = "starred"; |
| 774 | |
| 775 | /** |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 776 | * The position at which the contact is pinned. If {@link PinnedPositions#UNPINNED}, |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 777 | * the contact is not pinned. Also see {@link PinnedPositions}. |
| 778 | * <P>Type: INTEGER </P> |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 779 | */ |
| 780 | public static final String PINNED = "pinned"; |
| 781 | |
| 782 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 783 | * URI for a custom ringtone associated with the contact. If null or missing, |
| 784 | * the default ringtone is used. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 785 | * <P>Type: TEXT (URI to the ringtone)</P> |
| 786 | */ |
| 787 | public static final String CUSTOM_RINGTONE = "custom_ringtone"; |
| 788 | |
| 789 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 790 | * Whether the contact should always be sent to voicemail. If missing, |
| 791 | * defaults to false. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 792 | * <P>Type: INTEGER (0 for false, 1 for true)</P> |
| 793 | */ |
| 794 | public static final String SEND_TO_VOICEMAIL = "send_to_voicemail"; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 795 | } |
| 796 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 797 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 798 | * Columns of {@link ContactsContract.Contacts} that refer to intrinsic |
| 799 | * properties of the contact, as opposed to the user-specified options |
| 800 | * found in {@link ContactOptionsColumns}. |
| 801 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 802 | * @see Contacts |
| 803 | * @see ContactsContract.Data |
| 804 | * @see PhoneLookup |
| 805 | * @see ContactsContract.Contacts.AggregationSuggestions |
| 806 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 807 | protected interface ContactsColumns { |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 808 | /** |
| 809 | * The display name for the contact. |
| 810 | * <P>Type: TEXT</P> |
| 811 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 812 | public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY; |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 813 | |
| 814 | /** |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 815 | * Reference to the row in the RawContacts table holding the contact name. |
| 816 | * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 817 | */ |
| 818 | public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id"; |
| 819 | |
| 820 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 821 | * Reference to the row in the data table holding the photo. A photo can |
| 822 | * be referred to either by ID (this field) or by URI (see {@link #PHOTO_THUMBNAIL_URI} |
| 823 | * and {@link #PHOTO_URI}). |
| 824 | * If PHOTO_ID is null, consult {@link #PHOTO_URI} or {@link #PHOTO_THUMBNAIL_URI}, |
| 825 | * which is a more generic mechanism for referencing the contact photo, especially for |
| 826 | * contacts returned by non-local directories (see {@link Directory}). |
| 827 | * |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 828 | * <P>Type: INTEGER REFERENCES data(_id)</P> |
| 829 | */ |
| 830 | public static final String PHOTO_ID = "photo_id"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 831 | |
| 832 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 833 | * Photo file ID of the full-size photo. If present, this will be used to populate |
| 834 | * {@link #PHOTO_URI}. The ID can also be used with |
| 835 | * {@link ContactsContract.DisplayPhoto#CONTENT_URI} to create a URI to the photo. |
| 836 | * If this is present, {@link #PHOTO_ID} is also guaranteed to be populated. |
| 837 | * |
| 838 | * <P>Type: INTEGER</P> |
| 839 | */ |
| 840 | public static final String PHOTO_FILE_ID = "photo_file_id"; |
| 841 | |
| 842 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 843 | * A URI that can be used to retrieve the contact's full-size photo. |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 844 | * If PHOTO_FILE_ID is not null, this will be populated with a URI based off |
| 845 | * {@link ContactsContract.DisplayPhoto#CONTENT_URI}. Otherwise, this will |
| 846 | * be populated with the same value as {@link #PHOTO_THUMBNAIL_URI}. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 847 | * A photo can be referred to either by a URI (this field) or by ID |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 848 | * (see {@link #PHOTO_ID}). If either PHOTO_FILE_ID or PHOTO_ID is not null, |
| 849 | * PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily |
| 850 | * vice versa). Thus using PHOTO_URI is a more robust method of retrieving |
| 851 | * contact photos. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 852 | * |
| 853 | * <P>Type: TEXT</P> |
| 854 | */ |
| 855 | public static final String PHOTO_URI = "photo_uri"; |
| 856 | |
| 857 | /** |
| 858 | * A URI that can be used to retrieve a thumbnail of the contact's photo. |
| 859 | * A photo can be referred to either by a URI (this field or {@link #PHOTO_URI}) |
| 860 | * or by ID (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and |
| 861 | * PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa). |
| 862 | * If the content provider does not differentiate between full-size photos |
| 863 | * and thumbnail photos, PHOTO_THUMBNAIL_URI and {@link #PHOTO_URI} can contain |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 864 | * the same value, but either both shall be null or both not null. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 865 | * |
| 866 | * <P>Type: TEXT</P> |
| 867 | */ |
| 868 | public static final String PHOTO_THUMBNAIL_URI = "photo_thumb_uri"; |
| 869 | |
| 870 | /** |
Brian Attwell | 2fa85d3 | 2014-03-04 17:41:13 -0800 | [diff] [blame] | 871 | * Flag that reflects whether the contact exists inside the default directory. |
| 872 | * Ie, whether the contact is designed to only be visible outside search. |
Brian Attwell | 2fa85d3 | 2014-03-04 17:41:13 -0800 | [diff] [blame] | 873 | */ |
| 874 | public static final String IN_DEFAULT_DIRECTORY = "in_default_directory"; |
| 875 | |
| 876 | /** |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 877 | * Flag that reflects the {@link Groups#GROUP_VISIBLE} state of any |
| 878 | * {@link CommonDataKinds.GroupMembership} for this contact. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 879 | */ |
| 880 | public static final String IN_VISIBLE_GROUP = "in_visible_group"; |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 881 | |
| 882 | /** |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 883 | * Flag that reflects whether this contact represents the user's |
| 884 | * personal profile entry. |
| 885 | */ |
| 886 | public static final String IS_USER_PROFILE = "is_user_profile"; |
| 887 | |
| 888 | /** |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 889 | * An indicator of whether this contact has at least one phone number. "1" if there is |
| 890 | * at least one phone number, "0" otherwise. |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 891 | * <P>Type: INTEGER</P> |
| 892 | */ |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 893 | public static final String HAS_PHONE_NUMBER = "has_phone_number"; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 894 | |
| 895 | /** |
| 896 | * An opaque value that contains hints on how to find the contact if |
| 897 | * its row id changed as a result of a sync or aggregation. |
| 898 | */ |
| 899 | public static final String LOOKUP_KEY = "lookup"; |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 900 | |
| 901 | /** |
| 902 | * Timestamp (milliseconds since epoch) of when this contact was last updated. This |
| 903 | * includes updates to all data associated with this contact including raw contacts. Any |
| 904 | * modification (including deletes and inserts) of underlying contact data are also |
| 905 | * reflected in this timestamp. |
| 906 | */ |
| 907 | public static final String CONTACT_LAST_UPDATED_TIMESTAMP = |
| 908 | "contact_last_updated_timestamp"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 909 | } |
| 910 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 911 | /** |
| 912 | * @see Contacts |
| 913 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 914 | protected interface ContactStatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 915 | /** |
| 916 | * Contact presence status. See {@link StatusUpdates} for individual status |
| 917 | * definitions. |
| 918 | * <p>Type: NUMBER</p> |
| 919 | */ |
| 920 | public static final String CONTACT_PRESENCE = "contact_presence"; |
| 921 | |
| 922 | /** |
Vasu Nori | fb5bccf | 2010-07-19 14:11:54 -0700 | [diff] [blame] | 923 | * Contact Chat Capabilities. See {@link StatusUpdates} for individual |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 924 | * definitions. |
| 925 | * <p>Type: NUMBER</p> |
| 926 | */ |
| 927 | public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability"; |
| 928 | |
| 929 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 930 | * Contact's latest status update. |
| 931 | * <p>Type: TEXT</p> |
| 932 | */ |
| 933 | public static final String CONTACT_STATUS = "contact_status"; |
| 934 | |
| 935 | /** |
| 936 | * The absolute time in milliseconds when the latest status was |
| 937 | * inserted/updated. |
| 938 | * <p>Type: NUMBER</p> |
| 939 | */ |
| 940 | public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts"; |
| 941 | |
| 942 | /** |
| 943 | * The package containing resources for this status: label and icon. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 944 | * <p>Type: TEXT</p> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 945 | */ |
| 946 | public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package"; |
| 947 | |
| 948 | /** |
| 949 | * The resource ID of the label describing the source of contact |
| 950 | * status, e.g. "Google Talk". This resource is scoped by the |
| 951 | * {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 952 | * <p>Type: NUMBER</p> |
| 953 | */ |
| 954 | public static final String CONTACT_STATUS_LABEL = "contact_status_label"; |
| 955 | |
| 956 | /** |
| 957 | * The resource ID of the icon for the source of contact status. This |
| 958 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 959 | * <p>Type: NUMBER</p> |
| 960 | */ |
| 961 | public static final String CONTACT_STATUS_ICON = "contact_status_icon"; |
| 962 | } |
| 963 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 964 | /** |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 965 | * Constants for various styles of combining given name, family name etc into |
| 966 | * a full name. For example, the western tradition follows the pattern |
| 967 | * 'given name' 'middle name' 'family name' with the alternative pattern being |
| 968 | * 'family name', 'given name' 'middle name'. The CJK tradition is |
| 969 | * 'family name' 'middle name' 'given name', with Japanese favoring a space between |
| 970 | * the names and Chinese omitting the space. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 971 | */ |
| 972 | public interface FullNameStyle { |
| 973 | public static final int UNDEFINED = 0; |
| 974 | public static final int WESTERN = 1; |
| 975 | |
| 976 | /** |
| 977 | * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine |
| 978 | * which specific language it belongs to: Chinese, Japanese or Korean. |
| 979 | */ |
| 980 | public static final int CJK = 2; |
| 981 | |
| 982 | public static final int CHINESE = 3; |
| 983 | public static final int JAPANESE = 4; |
| 984 | public static final int KOREAN = 5; |
| 985 | } |
| 986 | |
| 987 | /** |
| 988 | * Constants for various styles of capturing the pronunciation of a person's name. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 989 | */ |
| 990 | public interface PhoneticNameStyle { |
| 991 | public static final int UNDEFINED = 0; |
| 992 | |
| 993 | /** |
| 994 | * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly |
| 995 | * shown in UIs, but used for searches and sorting. |
| 996 | */ |
| 997 | public static final int PINYIN = 3; |
| 998 | |
| 999 | /** |
| 1000 | * Hiragana and Katakana are two common styles of writing out the pronunciation |
| 1001 | * of a Japanese names. |
| 1002 | */ |
| 1003 | public static final int JAPANESE = 4; |
| 1004 | |
| 1005 | /** |
| 1006 | * Hangul is the Korean phonetic alphabet. |
| 1007 | */ |
| 1008 | public static final int KOREAN = 5; |
| 1009 | } |
| 1010 | |
| 1011 | /** |
Dmitri Plotnikov | dbcdbf2 | 2011-02-23 15:49:58 -0800 | [diff] [blame] | 1012 | * Types of data used to produce the display name for a contact. In the order |
| 1013 | * of increasing priority: {@link #EMAIL}, {@link #PHONE}, |
Brian Attwell | 643db51 | 2015-03-04 21:05:27 -0800 | [diff] [blame] | 1014 | * {@link #ORGANIZATION}, {@link #NICKNAME}, {@link #STRUCTURED_PHONETIC_NAME}, |
| 1015 | * {@link #STRUCTURED_NAME}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1016 | */ |
| 1017 | public interface DisplayNameSources { |
| 1018 | public static final int UNDEFINED = 0; |
| 1019 | public static final int EMAIL = 10; |
| 1020 | public static final int PHONE = 20; |
| 1021 | public static final int ORGANIZATION = 30; |
| 1022 | public static final int NICKNAME = 35; |
Brian Attwell | 643db51 | 2015-03-04 21:05:27 -0800 | [diff] [blame] | 1023 | /** Display name comes from a structured name that only has phonetic components. */ |
| 1024 | public static final int STRUCTURED_PHONETIC_NAME = 37; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1025 | public static final int STRUCTURED_NAME = 40; |
| 1026 | } |
| 1027 | |
| 1028 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 1029 | * Contact name and contact name metadata columns in the RawContacts table. |
| 1030 | * |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1031 | * @see Contacts |
| 1032 | * @see RawContacts |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1033 | */ |
| 1034 | protected interface ContactNameColumns { |
| 1035 | |
| 1036 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1037 | * The kind of data that is used as the display name for the contact, such as |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 1038 | * structured name or email address. See {@link DisplayNameSources}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1039 | */ |
| 1040 | public static final String DISPLAY_NAME_SOURCE = "display_name_source"; |
| 1041 | |
| 1042 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1043 | * <p> |
| 1044 | * The standard text shown as the contact's display name, based on the best |
| 1045 | * available information for the contact (for example, it might be the email address |
| 1046 | * if the name is not available). |
| 1047 | * The information actually used to compute the name is stored in |
| 1048 | * {@link #DISPLAY_NAME_SOURCE}. |
| 1049 | * </p> |
| 1050 | * <p> |
| 1051 | * A contacts provider is free to choose whatever representation makes most |
| 1052 | * sense for its target market. |
| 1053 | * For example in the default Android Open Source Project implementation, |
| 1054 | * if the display name is |
| 1055 | * based on the structured name and the structured name follows |
| 1056 | * the Western full-name style, then this field contains the "given name first" |
| 1057 | * version of the full name. |
| 1058 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1059 | * |
| 1060 | * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1061 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1062 | public static final String DISPLAY_NAME_PRIMARY = "display_name"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1063 | |
| 1064 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1065 | * <p> |
| 1066 | * An alternative representation of the display name, such as "family name first" |
| 1067 | * instead of "given name first" for Western names. If an alternative is not |
| 1068 | * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}. |
| 1069 | * </p> |
| 1070 | * <p> |
| 1071 | * A contacts provider is free to provide alternatives as necessary for |
| 1072 | * its target market. |
| 1073 | * For example the default Android Open Source Project contacts provider |
| 1074 | * currently provides an |
| 1075 | * alternative in a single case: if the display name is |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1076 | * based on the structured name and the structured name follows |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1077 | * the Western full name style, then the field contains the "family name first" |
| 1078 | * version of the full name. |
| 1079 | * Other cases may be added later. |
| 1080 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1081 | */ |
| 1082 | public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt"; |
| 1083 | |
| 1084 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1085 | * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}. See |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 1086 | * {@link PhoneticNameStyle}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1087 | */ |
| 1088 | public static final String PHONETIC_NAME_STYLE = "phonetic_name_style"; |
| 1089 | |
| 1090 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1091 | * <p> |
| 1092 | * Pronunciation of the full name in the phonetic alphabet specified by |
| 1093 | * {@link #PHONETIC_NAME_STYLE}. |
| 1094 | * </p> |
| 1095 | * <p> |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 1096 | * The value may be set manually by the user. This capability is of |
| 1097 | * interest only in countries with commonly used phonetic alphabets, |
| 1098 | * such as Japan and Korea. See {@link PhoneticNameStyle}. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1099 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1100 | */ |
| 1101 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 1102 | |
| 1103 | /** |
| 1104 | * Sort key that takes into account locale-based traditions for sorting |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1105 | * names in address books. The default |
| 1106 | * sort key is {@link #DISPLAY_NAME_PRIMARY}. For Chinese names |
| 1107 | * the sort key is the name's Pinyin spelling, and for Japanese names |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1108 | * it is the Hiragana version of the phonetic name. |
| 1109 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1110 | public static final String SORT_KEY_PRIMARY = "sort_key"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1111 | |
| 1112 | /** |
| 1113 | * Sort key based on the alternative representation of the full name, |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1114 | * {@link #DISPLAY_NAME_ALTERNATIVE}. Thus for Western names, |
Dmitri Plotnikov | 2a650dd | 2010-01-26 17:28:52 -0800 | [diff] [blame] | 1115 | * it is the one using the "family name first" format. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1116 | */ |
| 1117 | public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt"; |
| 1118 | } |
| 1119 | |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1120 | interface ContactCounts { |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1121 | |
| 1122 | /** |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1123 | * Add this query parameter to a URI to get back row counts grouped by the address book |
| 1124 | * index as cursor extras. For most languages it is the first letter of the sort key. This |
| 1125 | * parameter does not affect the main content of the cursor. |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1126 | * |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1127 | * <p> |
| 1128 | * <pre> |
| 1129 | * Example: |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1130 | * |
| 1131 | * import android.provider.ContactsContract.Contacts; |
| 1132 | * |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1133 | * Uri uri = Contacts.CONTENT_URI.buildUpon() |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1134 | * .appendQueryParameter(Contacts.EXTRA_ADDRESS_BOOK_INDEX, "true") |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1135 | * .build(); |
| 1136 | * Cursor cursor = getContentResolver().query(uri, |
| 1137 | * new String[] {Contacts.DISPLAY_NAME}, |
| 1138 | * null, null, null); |
| 1139 | * Bundle bundle = cursor.getExtras(); |
Yorke Lee | a4aa9dc | 2014-08-04 13:47:50 -0700 | [diff] [blame] | 1140 | * if (bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES) && |
| 1141 | * bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS)) { |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1142 | * String sections[] = |
Yorke Lee | a4aa9dc | 2014-08-04 13:47:50 -0700 | [diff] [blame] | 1143 | * bundle.getStringArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES); |
| 1144 | * int counts[] = bundle.getIntArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS); |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1145 | * } |
| 1146 | * </pre> |
| 1147 | * </p> |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1148 | */ |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1149 | public static final String EXTRA_ADDRESS_BOOK_INDEX = |
| 1150 | "android.provider.extra.ADDRESS_BOOK_INDEX"; |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1151 | |
| 1152 | /** |
| 1153 | * The array of address book index titles, which are returned in the |
| 1154 | * same order as the data in the cursor. |
| 1155 | * <p>TYPE: String[]</p> |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1156 | */ |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1157 | public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES = |
| 1158 | "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES"; |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1159 | |
| 1160 | /** |
| 1161 | * The array of group counts for the corresponding group. Contains the same number |
| 1162 | * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array. |
| 1163 | * <p>TYPE: int[]</p> |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1164 | */ |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1165 | public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = |
| 1166 | "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS"; |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1167 | } |
| 1168 | |
| 1169 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1170 | * Constants for the contacts table, which contains a record per aggregate |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1171 | * of raw contacts representing the same person. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1172 | * <h3>Operations</h3> |
| 1173 | * <dl> |
| 1174 | * <dt><b>Insert</b></dt> |
| 1175 | * <dd>A Contact cannot be created explicitly. When a raw contact is |
| 1176 | * inserted, the provider will first try to find a Contact representing the |
| 1177 | * same person. If one is found, the raw contact's |
| 1178 | * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate |
| 1179 | * Contact. If no match is found, the provider automatically inserts a new |
| 1180 | * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column |
| 1181 | * of the newly inserted raw contact.</dd> |
| 1182 | * <dt><b>Update</b></dt> |
| 1183 | * <dd>Only certain columns of Contact are modifiable: |
| 1184 | * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED}, |
| 1185 | * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of |
| 1186 | * these columns on the Contact also changes them on all constituent raw |
| 1187 | * contacts.</dd> |
| 1188 | * <dt><b>Delete</b></dt> |
| 1189 | * <dd>Be careful with deleting Contacts! Deleting an aggregate contact |
| 1190 | * deletes all constituent raw contacts. The corresponding sync adapters |
| 1191 | * will notice the deletions of their respective raw contacts and remove |
| 1192 | * them from their back end storage.</dd> |
| 1193 | * <dt><b>Query</b></dt> |
| 1194 | * <dd> |
| 1195 | * <ul> |
| 1196 | * <li>If you need to read an individual contact, consider using |
| 1197 | * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li> |
| 1198 | * <li>If you need to look up a contact by the phone number, use |
| 1199 | * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI}, |
| 1200 | * which is optimized for this purpose.</li> |
| 1201 | * <li>If you need to look up a contact by partial name, e.g. to produce |
| 1202 | * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI. |
| 1203 | * <li>If you need to look up a contact by some data element like email |
| 1204 | * address, nickname, etc, use a query against the {@link ContactsContract.Data} table. |
| 1205 | * The result will contain contact ID, name etc. |
| 1206 | * </ul> |
| 1207 | * </dd> |
| 1208 | * </dl> |
| 1209 | * <h2>Columns</h2> |
| 1210 | * <table class="jd-sumtable"> |
| 1211 | * <tr> |
| 1212 | * <th colspan='4'>Contacts</th> |
| 1213 | * </tr> |
| 1214 | * <tr> |
| 1215 | * <td>long</td> |
| 1216 | * <td>{@link #_ID}</td> |
| 1217 | * <td>read-only</td> |
| 1218 | * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td> |
| 1219 | * </tr> |
| 1220 | * <tr> |
| 1221 | * <td>String</td> |
| 1222 | * <td>{@link #LOOKUP_KEY}</td> |
| 1223 | * <td>read-only</td> |
| 1224 | * <td>An opaque value that contains hints on how to find the contact if its |
| 1225 | * row id changed as a result of a sync or aggregation.</td> |
| 1226 | * </tr> |
| 1227 | * <tr> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1228 | * <td>long</td> |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1229 | * <td>NAME_RAW_CONTACT_ID</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1230 | * <td>read-only</td> |
| 1231 | * <td>The ID of the raw contact that contributes the display name |
| 1232 | * to the aggregate contact. During aggregation one of the constituent |
| 1233 | * raw contacts is chosen using a heuristic: a longer name or a name |
| 1234 | * with more diacritic marks or more upper case characters is chosen.</td> |
| 1235 | * </tr> |
| 1236 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1237 | * <td>String</td> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1238 | * <td>DISPLAY_NAME_PRIMARY</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1239 | * <td>read-only</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1240 | * <td>The display name for the contact. It is the display name |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1241 | * contributed by the raw contact referred to by the NAME_RAW_CONTACT_ID |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1242 | * column.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1243 | * </tr> |
| 1244 | * <tr> |
| 1245 | * <td>long</td> |
| 1246 | * <td>{@link #PHOTO_ID}</td> |
| 1247 | * <td>read-only</td> |
| 1248 | * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo. |
| 1249 | * That row has the mime type |
| 1250 | * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field |
| 1251 | * is computed automatically based on the |
| 1252 | * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of |
| 1253 | * that mime type.</td> |
| 1254 | * </tr> |
| 1255 | * <tr> |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 1256 | * <td>long</td> |
| 1257 | * <td>{@link #PHOTO_URI}</td> |
| 1258 | * <td>read-only</td> |
| 1259 | * <td>A URI that can be used to retrieve the contact's full-size photo. This |
| 1260 | * column is the preferred method of retrieving the contact photo.</td> |
| 1261 | * </tr> |
| 1262 | * <tr> |
| 1263 | * <td>long</td> |
| 1264 | * <td>{@link #PHOTO_THUMBNAIL_URI}</td> |
| 1265 | * <td>read-only</td> |
| 1266 | * <td>A URI that can be used to retrieve the thumbnail of contact's photo. This |
| 1267 | * column is the preferred method of retrieving the contact photo.</td> |
| 1268 | * </tr> |
| 1269 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1270 | * <td>int</td> |
| 1271 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 1272 | * <td>read-only</td> |
| 1273 | * <td>An indicator of whether this contact is supposed to be visible in the |
| 1274 | * UI. "1" if the contact has at least one raw contact that belongs to a |
| 1275 | * visible group; "0" otherwise.</td> |
| 1276 | * </tr> |
| 1277 | * <tr> |
| 1278 | * <td>int</td> |
| 1279 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 1280 | * <td>read-only</td> |
| 1281 | * <td>An indicator of whether this contact has at least one phone number. |
| 1282 | * "1" if there is at least one phone number, "0" otherwise.</td> |
| 1283 | * </tr> |
| 1284 | * <tr> |
| 1285 | * <td>int</td> |
| 1286 | * <td>{@link #TIMES_CONTACTED}</td> |
| 1287 | * <td>read/write</td> |
| 1288 | * <td>The number of times the contact has been contacted. See |
| 1289 | * {@link #markAsContacted}. When raw contacts are aggregated, this field is |
| 1290 | * computed automatically as the maximum number of times contacted among all |
| 1291 | * constituent raw contacts. Setting this field automatically changes the |
| 1292 | * corresponding field on all constituent raw contacts.</td> |
| 1293 | * </tr> |
| 1294 | * <tr> |
| 1295 | * <td>long</td> |
| 1296 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 1297 | * <td>read/write</td> |
| 1298 | * <td>The timestamp of the last time the contact was contacted. See |
| 1299 | * {@link #markAsContacted}. Setting this field also automatically |
| 1300 | * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated, |
| 1301 | * this field is computed automatically as the latest time contacted of all |
| 1302 | * constituent raw contacts. Setting this field automatically changes the |
| 1303 | * corresponding field on all constituent raw contacts.</td> |
| 1304 | * </tr> |
| 1305 | * <tr> |
| 1306 | * <td>int</td> |
| 1307 | * <td>{@link #STARRED}</td> |
| 1308 | * <td>read/write</td> |
| 1309 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
| 1310 | * When raw contacts are aggregated, this field is automatically computed: |
| 1311 | * if any constituent raw contacts are starred, then this field is set to |
| 1312 | * '1'. Setting this field automatically changes the corresponding field on |
| 1313 | * all constituent raw contacts.</td> |
| 1314 | * </tr> |
| 1315 | * <tr> |
| 1316 | * <td>String</td> |
| 1317 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 1318 | * <td>read/write</td> |
| 1319 | * <td>A custom ringtone associated with a contact. Typically this is the |
| 1320 | * URI returned by an activity launched with the |
| 1321 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td> |
| 1322 | * </tr> |
| 1323 | * <tr> |
| 1324 | * <td>int</td> |
| 1325 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 1326 | * <td>read/write</td> |
| 1327 | * <td>An indicator of whether calls from this contact should be forwarded |
| 1328 | * directly to voice mail ('1') or not ('0'). When raw contacts are |
| 1329 | * aggregated, this field is automatically computed: if <i>all</i> |
| 1330 | * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set |
| 1331 | * to '1'. Setting this field automatically changes the corresponding field |
| 1332 | * on all constituent raw contacts.</td> |
| 1333 | * </tr> |
| 1334 | * <tr> |
| 1335 | * <td>int</td> |
| 1336 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 1337 | * <td>read-only</td> |
| 1338 | * <td>Contact IM presence status. See {@link StatusUpdates} for individual |
| 1339 | * status definitions. Automatically computed as the highest presence of all |
| 1340 | * constituent raw contacts. The provider may choose not to store this value |
| 1341 | * in persistent storage. The expectation is that presence status will be |
kmccormick | 50e27c8 | 2013-03-28 16:33:11 -0700 | [diff] [blame] | 1342 | * updated on a regular basis.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1343 | * </tr> |
| 1344 | * <tr> |
| 1345 | * <td>String</td> |
| 1346 | * <td>{@link #CONTACT_STATUS}</td> |
| 1347 | * <td>read-only</td> |
| 1348 | * <td>Contact's latest status update. Automatically computed as the latest |
| 1349 | * of all constituent raw contacts' status updates.</td> |
| 1350 | * </tr> |
| 1351 | * <tr> |
| 1352 | * <td>long</td> |
| 1353 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 1354 | * <td>read-only</td> |
| 1355 | * <td>The absolute time in milliseconds when the latest status was |
| 1356 | * inserted/updated.</td> |
| 1357 | * </tr> |
| 1358 | * <tr> |
| 1359 | * <td>String</td> |
| 1360 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 1361 | * <td>read-only</td> |
| 1362 | * <td> The package containing resources for this status: label and icon.</td> |
| 1363 | * </tr> |
| 1364 | * <tr> |
| 1365 | * <td>long</td> |
| 1366 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 1367 | * <td>read-only</td> |
| 1368 | * <td>The resource ID of the label describing the source of contact status, |
| 1369 | * e.g. "Google Talk". This resource is scoped by the |
| 1370 | * {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1371 | * </tr> |
| 1372 | * <tr> |
| 1373 | * <td>long</td> |
| 1374 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 1375 | * <td>read-only</td> |
| 1376 | * <td>The resource ID of the icon for the source of contact status. This |
| 1377 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1378 | * </tr> |
| 1379 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1380 | */ |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 1381 | public static class Contacts implements BaseColumns, ContactsColumns, |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1382 | ContactOptionsColumns, ContactNameColumns, ContactStatusColumns, ContactCounts { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1383 | /** |
| 1384 | * This utility class cannot be instantiated |
| 1385 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1386 | private Contacts() {} |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1387 | |
| 1388 | /** |
| 1389 | * The content:// style URI for this table |
| 1390 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1391 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1392 | |
| 1393 | /** |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 1394 | * Special contacts URI to refer to contacts on the corp profile from the personal |
| 1395 | * profile. |
| 1396 | * |
| 1397 | * It's supported only by a few specific places for referring to contact pictures that |
| 1398 | * are in the corp provider for enterprise caller-ID. Contact picture URIs returned from |
| 1399 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may contain this kind of URI. |
| 1400 | * |
| 1401 | * @hide |
| 1402 | */ |
| 1403 | public static final Uri CORP_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 1404 | "contacts_corp"); |
| 1405 | |
| 1406 | /** |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1407 | * A content:// style URI for this table that should be used to create |
| 1408 | * shortcuts or otherwise create long-term links to contacts. This URI |
| 1409 | * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}. |
| 1410 | * It can optionally also have a "/" and last known contact ID appended after |
| 1411 | * that. This "complete" format is an important optimization and is highly recommended. |
| 1412 | * <p> |
| 1413 | * As long as the contact's row ID remains the same, this URI is |
| 1414 | * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes |
| 1415 | * as a result of a sync or aggregation, this URI will look up the |
| 1416 | * contact using indirect information (sync IDs or constituent raw |
| 1417 | * contacts). |
| 1418 | * <p> |
| 1419 | * Lookup key should be appended unencoded - it is stored in the encoded |
| 1420 | * form, ready for use in a URI. |
| 1421 | */ |
| 1422 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1423 | "lookup"); |
| 1424 | |
| 1425 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1426 | * Base {@link Uri} for referencing a single {@link Contacts} entry, |
Jeff Sharkey | 8f76734 | 2009-09-28 18:22:46 -0700 | [diff] [blame] | 1427 | * created by appending {@link #LOOKUP_KEY} using |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1428 | * {@link Uri#withAppendedPath(Uri, String)}. Provides |
| 1429 | * {@link OpenableColumns} columns when queried, or returns the |
| 1430 | * referenced contact formatted as a vCard when opened through |
| 1431 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1432 | */ |
| 1433 | public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1434 | "as_vcard"); |
| 1435 | |
Martijn Coenen | 037d3ff | 2011-06-15 16:01:45 +0200 | [diff] [blame] | 1436 | /** |
| 1437 | * Boolean parameter that may be used with {@link #CONTENT_VCARD_URI} |
| 1438 | * and {@link #CONTENT_MULTI_VCARD_URI} to indicate that the returned |
| 1439 | * vcard should not contain a photo. |
| 1440 | * |
Brian Attwell | f9fb60a | 2015-02-02 12:16:13 -0800 | [diff] [blame] | 1441 | * This is useful for obtaining a space efficient vcard. |
Martijn Coenen | 037d3ff | 2011-06-15 16:01:45 +0200 | [diff] [blame] | 1442 | */ |
Brian Attwell | f9fb60a | 2015-02-02 12:16:13 -0800 | [diff] [blame] | 1443 | public static final String QUERY_PARAMETER_VCARD_NO_PHOTO = "no_photo"; |
Martijn Coenen | 037d3ff | 2011-06-15 16:01:45 +0200 | [diff] [blame] | 1444 | |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1445 | /** |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1446 | * Base {@link Uri} for referencing multiple {@link Contacts} entry, |
| 1447 | * created by appending {@link #LOOKUP_KEY} using |
| 1448 | * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 1449 | * joined with the colon (":") separator, and the resulting string encoded. |
| 1450 | * |
| 1451 | * Provides {@link OpenableColumns} columns when queried, or returns the |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1452 | * referenced contact formatted as a vCard when opened through |
| 1453 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1454 | * |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 1455 | * <p> |
| 1456 | * Usage example: |
| 1457 | * <dl> |
| 1458 | * <dt>The following code snippet creates a multi-vcard URI that references all the |
| 1459 | * contacts in a user's database.</dt> |
| 1460 | * <dd> |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1461 | * |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 1462 | * <pre> |
| 1463 | * public Uri getAllContactsVcardUri() { |
| 1464 | * Cursor cursor = getActivity().getContentResolver().query(Contacts.CONTENT_URI, |
| 1465 | * new String[] {Contacts.LOOKUP_KEY}, null, null, null); |
| 1466 | * if (cursor == null) { |
| 1467 | * return null; |
| 1468 | * } |
| 1469 | * try { |
| 1470 | * StringBuilder uriListBuilder = new StringBuilder(); |
| 1471 | * int index = 0; |
| 1472 | * while (cursor.moveToNext()) { |
| 1473 | * if (index != 0) uriListBuilder.append(':'); |
| 1474 | * uriListBuilder.append(cursor.getString(0)); |
| 1475 | * index++; |
| 1476 | * } |
| 1477 | * return Uri.withAppendedPath(Contacts.CONTENT_MULTI_VCARD_URI, |
| 1478 | * Uri.encode(uriListBuilder.toString())); |
| 1479 | * } finally { |
| 1480 | * cursor.close(); |
| 1481 | * } |
| 1482 | * } |
| 1483 | * </pre> |
| 1484 | * |
| 1485 | * </p> |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1486 | */ |
| 1487 | public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1488 | "as_multi_vcard"); |
| 1489 | |
| 1490 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1491 | * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the |
| 1492 | * requested {@link Contacts} entry. |
| 1493 | * |
| 1494 | * @param contactUri A {@link #CONTENT_URI} row, or an existing |
| 1495 | * {@link #CONTENT_LOOKUP_URI} to attempt refreshing. |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1496 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1497 | public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) { |
| 1498 | final Cursor c = resolver.query(contactUri, new String[] { |
| 1499 | Contacts.LOOKUP_KEY, Contacts._ID |
| 1500 | }, null, null, null); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1501 | if (c == null) { |
| 1502 | return null; |
| 1503 | } |
| 1504 | |
| 1505 | try { |
| 1506 | if (c.moveToFirst()) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1507 | final String lookupKey = c.getString(0); |
| 1508 | final long contactId = c.getLong(1); |
| 1509 | return getLookupUri(contactId, lookupKey); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1510 | } |
| 1511 | } finally { |
| 1512 | c.close(); |
| 1513 | } |
| 1514 | return null; |
| 1515 | } |
| 1516 | |
| 1517 | /** |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1518 | * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1519 | * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}. |
Jay Shrauner | 1ebaff2 | 2015-03-12 15:24:16 -0700 | [diff] [blame] | 1520 | * <p> |
| 1521 | * Returns null if unable to construct a valid lookup URI from the |
| 1522 | * provided parameters. |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1523 | */ |
| 1524 | public static Uri getLookupUri(long contactId, String lookupKey) { |
Jay Shrauner | 1ebaff2 | 2015-03-12 15:24:16 -0700 | [diff] [blame] | 1525 | if (TextUtils.isEmpty(lookupKey)) { |
| 1526 | return null; |
| 1527 | } |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1528 | return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, |
| 1529 | lookupKey), contactId); |
| 1530 | } |
| 1531 | |
| 1532 | /** |
Dmitri Plotnikov | b5759b5 | 2009-09-01 15:58:40 -0700 | [diff] [blame] | 1533 | * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI. |
| 1534 | * <p> |
| 1535 | * Returns null if the contact cannot be found. |
| 1536 | */ |
| 1537 | public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) { |
| 1538 | if (lookupUri == null) { |
| 1539 | return null; |
| 1540 | } |
| 1541 | |
| 1542 | Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null); |
| 1543 | if (c == null) { |
| 1544 | return null; |
| 1545 | } |
| 1546 | |
| 1547 | try { |
| 1548 | if (c.moveToFirst()) { |
| 1549 | long contactId = c.getLong(0); |
| 1550 | return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1551 | } |
| 1552 | } finally { |
| 1553 | c.close(); |
| 1554 | } |
| 1555 | return null; |
| 1556 | } |
| 1557 | |
| 1558 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1559 | * Mark a contact as having been contacted. Updates two fields: |
| 1560 | * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED}. The |
| 1561 | * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED |
| 1562 | * field is populated with the current system time. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1563 | * |
| 1564 | * @param resolver the ContentResolver to use |
| 1565 | * @param contactId the person who was contacted |
Daniel Lehmann | a1620dc | 2012-04-13 13:29:49 -0700 | [diff] [blame] | 1566 | * |
| 1567 | * @deprecated The class DataUsageStatUpdater of the Android support library should |
| 1568 | * be used instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1569 | */ |
Daniel Lehmann | a1620dc | 2012-04-13 13:29:49 -0700 | [diff] [blame] | 1570 | @Deprecated |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1571 | public static void markAsContacted(ContentResolver resolver, long contactId) { |
| 1572 | Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId); |
| 1573 | ContentValues values = new ContentValues(); |
| 1574 | // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified. |
| 1575 | values.put(LAST_TIME_CONTACTED, System.currentTimeMillis()); |
| 1576 | resolver.update(uri, values, null, null); |
| 1577 | } |
| 1578 | |
| 1579 | /** |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1580 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1581 | * {@link #CONTENT_URI} URI. The filter string will be used to match |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1582 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1583 | * as an additional path segment after this URI. |
| 1584 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1585 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 1586 | CONTENT_URI, "filter"); |
| 1587 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1588 | /** |
| 1589 | * The content:// style URI for this table joined with useful data from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1590 | * {@link ContactsContract.Data}, filtered to include only starred contacts |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1591 | * and the most frequently contacted contacts. |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1592 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1593 | public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath( |
| 1594 | CONTENT_URI, "strequent"); |
| 1595 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1596 | /** |
Yorke Lee | 8d37009 | 2014-06-26 10:32:17 -0700 | [diff] [blame] | 1597 | * The content:// style URI for showing a list of frequently contacted people. |
Daisuke Miyakawa | 3604bc5 | 2011-07-21 10:14:32 -0700 | [diff] [blame] | 1598 | */ |
| 1599 | public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath( |
| 1600 | CONTENT_URI, "frequent"); |
| 1601 | |
| 1602 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1603 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1604 | * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1605 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1606 | * as an additional path segment after this URI. |
| 1607 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1608 | public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath( |
| 1609 | CONTENT_STREQUENT_URI, "filter"); |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1610 | |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1611 | public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath( |
| 1612 | CONTENT_URI, "group"); |
| 1613 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1614 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1615 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 1616 | * people. |
| 1617 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1618 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1619 | |
| 1620 | /** |
| 1621 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1622 | * person. |
| 1623 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1624 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1625 | |
| 1626 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1627 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1628 | * person. |
| 1629 | */ |
| 1630 | public static final String CONTENT_VCARD_TYPE = "text/x-vcard"; |
| 1631 | |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 1632 | /** |
| 1633 | * Mimimal ID for corp contacts returned from |
| 1634 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
| 1635 | * |
| 1636 | * @hide |
| 1637 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 1638 | public static long ENTERPRISE_CONTACT_ID_BASE = 1000000000; // slightly smaller than 2 ** 30 |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 1639 | |
| 1640 | /** |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 1641 | * Prefix for corp contacts returned from |
| 1642 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
| 1643 | * |
| 1644 | * @hide |
| 1645 | */ |
| 1646 | public static String ENTERPRISE_CONTACT_LOOKUP_PREFIX = "c-"; |
| 1647 | |
| 1648 | /** |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 1649 | * Return TRUE if a contact ID is from the contacts provider on the enterprise profile. |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 1650 | * |
| 1651 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may return such a contact. |
| 1652 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 1653 | public static boolean isEnterpriseContactId(long contactId) { |
| 1654 | return (contactId >= ENTERPRISE_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID); |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 1655 | } |
| 1656 | |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1657 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1658 | * A sub-directory of a single contact that contains all of the constituent raw contact |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1659 | * {@link ContactsContract.Data} rows. This directory can be used either |
| 1660 | * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1661 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1662 | public static final class Data implements BaseColumns, DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1663 | /** |
| 1664 | * no public constructor since this is a utility class |
| 1665 | */ |
| 1666 | private Data() {} |
| 1667 | |
| 1668 | /** |
| 1669 | * The directory twig for this sub-table |
| 1670 | */ |
| 1671 | public static final String CONTENT_DIRECTORY = "data"; |
| 1672 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1673 | |
| 1674 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1675 | * <p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1676 | * A sub-directory of a contact that contains all of its |
| 1677 | * {@link ContactsContract.RawContacts} as well as |
| 1678 | * {@link ContactsContract.Data} rows. To access this directory append |
| 1679 | * {@link #CONTENT_DIRECTORY} to the contact URI. |
| 1680 | * </p> |
| 1681 | * <p> |
| 1682 | * Entity has three ID fields: {@link #CONTACT_ID} for the contact, |
| 1683 | * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for |
| 1684 | * the data rows. Entity always contains at least one row per |
| 1685 | * constituent raw contact, even if there are no actual data rows. In |
| 1686 | * this case the {@link #DATA_ID} field will be null. |
| 1687 | * </p> |
| 1688 | * <p> |
| 1689 | * Entity reads all data for the entire contact in one transaction, to |
| 1690 | * guarantee consistency. There is significant data duplication |
| 1691 | * in the Entity (each row repeats all Contact columns and all RawContact |
| 1692 | * columns), so the benefits of transactional consistency should be weighed |
| 1693 | * against the cost of transferring large amounts of denormalized data |
| 1694 | * from the Provider. |
| 1695 | * </p> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 1696 | * <p> |
| 1697 | * To reduce the amount of data duplication the contacts provider and directory |
| 1698 | * providers implementing this protocol are allowed to provide common Contacts |
| 1699 | * and RawContacts fields in the first row returned for each raw contact only and |
| 1700 | * leave them as null in subsequent rows. |
| 1701 | * </p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1702 | */ |
| 1703 | public static final class Entity implements BaseColumns, ContactsColumns, |
| 1704 | ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns, |
Paul Soulos | 42cdda8 | 2014-06-19 16:13:38 -0700 | [diff] [blame] | 1705 | StatusColumns, ContactOptionsColumns, ContactStatusColumns, DataUsageStatColumns { |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1706 | /** |
| 1707 | * no public constructor since this is a utility class |
| 1708 | */ |
| 1709 | private Entity() { |
| 1710 | } |
| 1711 | |
| 1712 | /** |
| 1713 | * The directory twig for this sub-table |
| 1714 | */ |
| 1715 | public static final String CONTENT_DIRECTORY = "entities"; |
| 1716 | |
| 1717 | /** |
| 1718 | * The ID of the raw contact row. |
| 1719 | * <P>Type: INTEGER</P> |
| 1720 | */ |
| 1721 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 1722 | |
| 1723 | /** |
| 1724 | * The ID of the data row. The value will be null if this raw contact has no |
| 1725 | * data rows. |
| 1726 | * <P>Type: INTEGER</P> |
| 1727 | */ |
| 1728 | public static final String DATA_ID = "data_id"; |
| 1729 | } |
| 1730 | |
| 1731 | /** |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 1732 | * <p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1733 | * A sub-directory of a single contact that contains all of the constituent raw contact |
| 1734 | * {@link ContactsContract.StreamItems} rows. This directory can be used either |
| 1735 | * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}. |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 1736 | * </p> |
| 1737 | * <p> |
| 1738 | * Querying for social stream data requires android.permission.READ_SOCIAL_STREAM |
| 1739 | * permission. |
| 1740 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1741 | * |
| 1742 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 1743 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1744 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1745 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1746 | public static final class StreamItems implements StreamItemsColumns { |
| 1747 | /** |
| 1748 | * no public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1749 | * |
| 1750 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 1751 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1752 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1753 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1754 | private StreamItems() {} |
| 1755 | |
| 1756 | /** |
| 1757 | * The directory twig for this sub-table |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1758 | * |
| 1759 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 1760 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1761 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1762 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1763 | public static final String CONTENT_DIRECTORY = "stream_items"; |
| 1764 | } |
| 1765 | |
| 1766 | /** |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1767 | * <p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1768 | * A <i>read-only</i> sub-directory of a single contact aggregate that |
| 1769 | * contains all aggregation suggestions (other contacts). The |
| 1770 | * aggregation suggestions are computed based on approximate data |
| 1771 | * matches with this contact. |
| 1772 | * </p> |
| 1773 | * <p> |
| 1774 | * <i>Note: this query may be expensive! If you need to use it in bulk, |
| 1775 | * make sure the user experience is acceptable when the query runs for a |
| 1776 | * long time.</i> |
| 1777 | * <p> |
| 1778 | * Usage example: |
| 1779 | * |
| 1780 | * <pre> |
| 1781 | * Uri uri = Contacts.CONTENT_URI.buildUpon() |
| 1782 | * .appendEncodedPath(String.valueOf(contactId)) |
| 1783 | * .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY) |
| 1784 | * .appendQueryParameter("limit", "3") |
| 1785 | * .build() |
| 1786 | * Cursor cursor = getContentResolver().query(suggestionsUri, |
| 1787 | * new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY}, |
| 1788 | * null, null, null); |
| 1789 | * </pre> |
| 1790 | * |
| 1791 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1792 | * <p> |
| 1793 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 1794 | * {@link #CONTENT_LOOKUP_URI}. |
| 1795 | * </p> |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1796 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1797 | public static final class AggregationSuggestions implements BaseColumns, ContactsColumns, |
| 1798 | ContactOptionsColumns, ContactStatusColumns { |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1799 | /** |
| 1800 | * No public constructor since this is a utility class |
| 1801 | */ |
| 1802 | private AggregationSuggestions() {} |
| 1803 | |
| 1804 | /** |
Dmitri Plotnikov | 0fc0244 | 2009-09-21 13:26:28 -0700 | [diff] [blame] | 1805 | * The directory twig for this sub-table. The URI can be followed by an optional |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1806 | * type-to-filter, similar to |
| 1807 | * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}. |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1808 | */ |
| 1809 | public static final String CONTENT_DIRECTORY = "suggestions"; |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1810 | |
| 1811 | /** |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1812 | * Used to specify what kind of data is supplied for the suggestion query. |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1813 | * |
| 1814 | * @hide |
| 1815 | */ |
| 1816 | public static final String PARAMETER_MATCH_NAME = "name"; |
| 1817 | |
| 1818 | /** |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1819 | * A convenience builder for aggregation suggestion content URIs. |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1820 | */ |
| 1821 | public static final class Builder { |
| 1822 | private long mContactId; |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1823 | private final ArrayList<String> mValues = new ArrayList<String>(); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1824 | private int mLimit; |
| 1825 | |
| 1826 | /** |
| 1827 | * Optional existing contact ID. If it is not provided, the search |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1828 | * will be based exclusively on the values supplied with {@link #addNameParameter}. |
| 1829 | * |
| 1830 | * @param contactId contact to find aggregation suggestions for |
| 1831 | * @return This Builder object to allow for chaining of calls to builder methods |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1832 | */ |
| 1833 | public Builder setContactId(long contactId) { |
| 1834 | this.mContactId = contactId; |
| 1835 | return this; |
| 1836 | } |
| 1837 | |
| 1838 | /** |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1839 | * Add a name to be used when searching for aggregation suggestions. |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1840 | * |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1841 | * @param name name to find aggregation suggestions for |
| 1842 | * @return This Builder object to allow for chaining of calls to builder methods |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1843 | */ |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1844 | public Builder addNameParameter(String name) { |
| 1845 | mValues.add(name); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1846 | return this; |
| 1847 | } |
| 1848 | |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1849 | /** |
| 1850 | * Sets the Maximum number of suggested aggregations that should be returned. |
| 1851 | * @param limit The maximum number of suggested aggregations |
| 1852 | * |
| 1853 | * @return This Builder object to allow for chaining of calls to builder methods |
| 1854 | */ |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1855 | public Builder setLimit(int limit) { |
| 1856 | mLimit = limit; |
| 1857 | return this; |
| 1858 | } |
| 1859 | |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1860 | /** |
| 1861 | * Combine all of the options that have been set and return a new {@link Uri} |
| 1862 | * object for fetching aggregation suggestions. |
| 1863 | */ |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1864 | public Uri build() { |
| 1865 | android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon(); |
| 1866 | builder.appendEncodedPath(String.valueOf(mContactId)); |
| 1867 | builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY); |
| 1868 | if (mLimit != 0) { |
| 1869 | builder.appendQueryParameter("limit", String.valueOf(mLimit)); |
| 1870 | } |
| 1871 | |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1872 | int count = mValues.size(); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1873 | for (int i = 0; i < count; i++) { |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1874 | builder.appendQueryParameter("query", PARAMETER_MATCH_NAME |
| 1875 | + ":" + mValues.get(i)); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1876 | } |
| 1877 | |
| 1878 | return builder.build(); |
| 1879 | } |
| 1880 | } |
| 1881 | |
| 1882 | /** |
| 1883 | * @hide |
| 1884 | */ |
| 1885 | public static final Builder builder() { |
| 1886 | return new Builder(); |
| 1887 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1888 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1889 | |
| 1890 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1891 | * A <i>read-only</i> sub-directory of a single contact that contains |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1892 | * the contact's primary photo. The photo may be stored in up to two ways - |
| 1893 | * the default "photo" is a thumbnail-sized image stored directly in the data |
| 1894 | * row, while the "display photo", if present, is a larger version stored as |
| 1895 | * a file. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1896 | * <p> |
| 1897 | * Usage example: |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1898 | * <dl> |
| 1899 | * <dt>Retrieving the thumbnail-sized photo</dt> |
| 1900 | * <dd> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1901 | * <pre> |
| 1902 | * public InputStream openPhoto(long contactId) { |
| 1903 | * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1904 | * Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY); |
| 1905 | * Cursor cursor = getContentResolver().query(photoUri, |
| 1906 | * new String[] {Contacts.Photo.PHOTO}, null, null, null); |
| 1907 | * if (cursor == null) { |
| 1908 | * return null; |
| 1909 | * } |
| 1910 | * try { |
| 1911 | * if (cursor.moveToFirst()) { |
| 1912 | * byte[] data = cursor.getBlob(0); |
| 1913 | * if (data != null) { |
| 1914 | * return new ByteArrayInputStream(data); |
| 1915 | * } |
| 1916 | * } |
| 1917 | * } finally { |
| 1918 | * cursor.close(); |
| 1919 | * } |
| 1920 | * return null; |
| 1921 | * } |
| 1922 | * </pre> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1923 | * </dd> |
| 1924 | * <dt>Retrieving the larger photo version</dt> |
| 1925 | * <dd> |
| 1926 | * <pre> |
| 1927 | * public InputStream openDisplayPhoto(long contactId) { |
| 1928 | * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1929 | * Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO); |
| 1930 | * try { |
| 1931 | * AssetFileDescriptor fd = |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 1932 | * getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1933 | * return fd.createInputStream(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 1934 | * } catch (IOException e) { |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1935 | * return null; |
| 1936 | * } |
| 1937 | * } |
| 1938 | * </pre> |
| 1939 | * </dd> |
| 1940 | * </dl> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1941 | * |
| 1942 | * </p> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1943 | * <p>You may also consider using the convenience method |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1944 | * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri, boolean)} |
| 1945 | * to retrieve the raw photo contents of either the thumbnail-sized or the full-sized photo. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1946 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1947 | * <p> |
| 1948 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 1949 | * {@link #CONTENT_LOOKUP_URI}. |
| 1950 | * </p> |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1951 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1952 | public static final class Photo implements BaseColumns, DataColumnsWithJoins { |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 1953 | /** |
| 1954 | * no public constructor since this is a utility class |
| 1955 | */ |
| 1956 | private Photo() {} |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 1957 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 1958 | /** |
| 1959 | * The directory twig for this sub-table |
| 1960 | */ |
| 1961 | public static final String CONTENT_DIRECTORY = "photo"; |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1962 | |
| 1963 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1964 | * The directory twig for retrieving the full-size display photo. |
| 1965 | */ |
| 1966 | public static final String DISPLAY_PHOTO = "display_photo"; |
| 1967 | |
| 1968 | /** |
| 1969 | * Full-size photo file ID of the raw contact. |
| 1970 | * See {@link ContactsContract.DisplayPhoto}. |
| 1971 | * <p> |
| 1972 | * Type: NUMBER |
| 1973 | */ |
| 1974 | public static final String PHOTO_FILE_ID = DATA14; |
| 1975 | |
| 1976 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1977 | * Thumbnail photo of the raw contact. This is the raw bytes of an image |
| 1978 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
| 1979 | * <p> |
| 1980 | * Type: BLOB |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1981 | */ |
| 1982 | public static final String PHOTO = DATA15; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1983 | } |
| 1984 | |
| 1985 | /** |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1986 | * Opens an InputStream for the contacts's photo and returns the |
| 1987 | * photo as a byte stream. |
| 1988 | * @param cr The content resolver to use for querying |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1989 | * @param contactUri the contact whose photo should be used. This can be used with |
| 1990 | * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI. |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1991 | * @param preferHighres If this is true and the contact has a higher resolution photo |
| 1992 | * available, it is returned. If false, this function always tries to get the thumbnail |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1993 | * @return an InputStream of the photo, or null if no photo is present |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1994 | */ |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1995 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri, |
| 1996 | boolean preferHighres) { |
| 1997 | if (preferHighres) { |
| 1998 | final Uri displayPhotoUri = Uri.withAppendedPath(contactUri, |
| 1999 | Contacts.Photo.DISPLAY_PHOTO); |
| 2000 | InputStream inputStream; |
| 2001 | try { |
| 2002 | AssetFileDescriptor fd = cr.openAssetFileDescriptor(displayPhotoUri, "r"); |
| 2003 | return fd.createInputStream(); |
| 2004 | } catch (IOException e) { |
| 2005 | // fallback to the thumbnail code |
| 2006 | } |
| 2007 | } |
| 2008 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 2009 | Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY); |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 2010 | if (photoUri == null) { |
| 2011 | return null; |
| 2012 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2013 | Cursor cursor = cr.query(photoUri, |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2014 | new String[] { |
| 2015 | ContactsContract.CommonDataKinds.Photo.PHOTO |
| 2016 | }, null, null, null); |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2017 | try { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 2018 | if (cursor == null || !cursor.moveToNext()) { |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2019 | return null; |
| 2020 | } |
| 2021 | byte[] data = cursor.getBlob(0); |
| 2022 | if (data == null) { |
| 2023 | return null; |
| 2024 | } |
| 2025 | return new ByteArrayInputStream(data); |
| 2026 | } finally { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 2027 | if (cursor != null) { |
| 2028 | cursor.close(); |
| 2029 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2030 | } |
| 2031 | } |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2032 | |
| 2033 | /** |
| 2034 | * Opens an InputStream for the contacts's thumbnail photo and returns the |
| 2035 | * photo as a byte stream. |
| 2036 | * @param cr The content resolver to use for querying |
| 2037 | * @param contactUri the contact whose photo should be used. This can be used with |
| 2038 | * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI. |
| 2039 | * @return an InputStream of the photo, or null if no photo is present |
| 2040 | * @see #openContactPhotoInputStream(ContentResolver, Uri, boolean), if instead |
| 2041 | * of the thumbnail the high-res picture is preferred |
| 2042 | */ |
| 2043 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) { |
| 2044 | return openContactPhotoInputStream(cr, contactUri, false); |
| 2045 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2046 | } |
| 2047 | |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2048 | /** |
| 2049 | * <p> |
| 2050 | * Constants for the user's profile data, which is represented as a single contact on |
| 2051 | * the device that represents the user. The profile contact is not aggregated |
| 2052 | * together automatically in the same way that normal contacts are; instead, each |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 2053 | * account (including data set, if applicable) on the device may contribute a single |
| 2054 | * raw contact representing the user's personal profile data from that source. |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2055 | * </p> |
| 2056 | * <p> |
| 2057 | * Access to the profile entry through these URIs (or incidental access to parts of |
| 2058 | * the profile if retrieved directly via ID) requires additional permissions beyond |
| 2059 | * the read/write contact permissions required by the provider. Querying for profile |
| 2060 | * data requires android.permission.READ_PROFILE permission, and inserting or |
| 2061 | * updating profile data requires android.permission.WRITE_PROFILE permission. |
| 2062 | * </p> |
| 2063 | * <h3>Operations</h3> |
| 2064 | * <dl> |
| 2065 | * <dt><b>Insert</b></dt> |
| 2066 | * <dd>The user's profile entry cannot be created explicitly (attempting to do so |
| 2067 | * will throw an exception). When a raw contact is inserted into the profile, the |
| 2068 | * provider will check for the existence of a profile on the device. If one is |
| 2069 | * found, the raw contact's {@link RawContacts#CONTACT_ID} column gets the _ID of |
| 2070 | * the profile Contact. If no match is found, the profile Contact is created and |
| 2071 | * its _ID is put into the {@link RawContacts#CONTACT_ID} column of the newly |
| 2072 | * inserted raw contact.</dd> |
| 2073 | * <dt><b>Update</b></dt> |
| 2074 | * <dd>The profile Contact has the same update restrictions as Contacts in general, |
| 2075 | * but requires the android.permission.WRITE_PROFILE permission.</dd> |
| 2076 | * <dt><b>Delete</b></dt> |
| 2077 | * <dd>The profile Contact cannot be explicitly deleted. It will be removed |
| 2078 | * automatically if all of its constituent raw contact entries are deleted.</dd> |
| 2079 | * <dt><b>Query</b></dt> |
| 2080 | * <dd> |
| 2081 | * <ul> |
| 2082 | * <li>The {@link #CONTENT_URI} for profiles behaves in much the same way as |
| 2083 | * retrieving a contact by ID, except that it will only ever return the user's |
| 2084 | * profile contact. |
| 2085 | * </li> |
| 2086 | * <li> |
| 2087 | * The profile contact supports all of the same sub-paths as an individual contact |
| 2088 | * does - the content of the profile contact can be retrieved as entities or |
| 2089 | * data rows. Similarly, specific raw contact entries can be retrieved by appending |
| 2090 | * the desired raw contact ID within the profile. |
| 2091 | * </li> |
| 2092 | * </ul> |
| 2093 | * </dd> |
| 2094 | * </dl> |
| 2095 | */ |
| 2096 | public static final class Profile implements BaseColumns, ContactsColumns, |
| 2097 | ContactOptionsColumns, ContactNameColumns, ContactStatusColumns { |
| 2098 | /** |
| 2099 | * This utility class cannot be instantiated |
| 2100 | */ |
| 2101 | private Profile() { |
| 2102 | } |
| 2103 | |
| 2104 | /** |
| 2105 | * The content:// style URI for this table, which requests the contact entry |
| 2106 | * representing the user's personal profile data. |
| 2107 | */ |
| 2108 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "profile"); |
| 2109 | |
| 2110 | /** |
| 2111 | * {@link Uri} for referencing the user's profile {@link Contacts} entry, |
| 2112 | * Provides {@link OpenableColumns} columns when queried, or returns the |
| 2113 | * user's profile contact formatted as a vCard when opened through |
| 2114 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 2115 | */ |
| 2116 | public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 2117 | "as_vcard"); |
| 2118 | |
| 2119 | /** |
| 2120 | * {@link Uri} for referencing the raw contacts that make up the user's profile |
| 2121 | * {@link Contacts} entry. An individual raw contact entry within the profile |
| 2122 | * can be addressed by appending the raw contact ID. The entities or data within |
| 2123 | * that specific raw contact can be requested by appending the entity or data |
| 2124 | * path as well. |
| 2125 | */ |
| 2126 | public static final Uri CONTENT_RAW_CONTACTS_URI = Uri.withAppendedPath(CONTENT_URI, |
| 2127 | "raw_contacts"); |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 2128 | |
| 2129 | /** |
| 2130 | * The minimum ID for any entity that belongs to the profile. This essentially |
| 2131 | * defines an ID-space in which profile data is stored, and is used by the provider |
| 2132 | * to determine whether a request via a non-profile-specific URI should be directed |
| 2133 | * to the profile data rather than general contacts data, along with all the special |
| 2134 | * permission checks that entails. |
| 2135 | * |
| 2136 | * Callers may use {@link #isProfileId} to check whether a specific ID falls into |
| 2137 | * the set of data intended for the profile. |
| 2138 | */ |
| 2139 | public static final long MIN_ID = Long.MAX_VALUE - (long) Integer.MAX_VALUE; |
| 2140 | } |
| 2141 | |
| 2142 | /** |
| 2143 | * This method can be used to identify whether the given ID is associated with profile |
| 2144 | * data. It does not necessarily indicate that the ID is tied to valid data, merely |
| 2145 | * that accessing data using this ID will result in profile access checks and will only |
| 2146 | * return data from the profile. |
| 2147 | * |
| 2148 | * @param id The ID to check. |
| 2149 | * @return Whether the ID is associated with profile data. |
| 2150 | */ |
| 2151 | public static boolean isProfileId(long id) { |
| 2152 | return id >= Profile.MIN_ID; |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2153 | } |
| 2154 | |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 2155 | protected interface DeletedContactsColumns { |
| 2156 | |
| 2157 | /** |
| 2158 | * A reference to the {@link ContactsContract.Contacts#_ID} that was deleted. |
| 2159 | * <P>Type: INTEGER</P> |
| 2160 | */ |
| 2161 | public static final String CONTACT_ID = "contact_id"; |
| 2162 | |
| 2163 | /** |
| 2164 | * Time (milliseconds since epoch) that the contact was deleted. |
| 2165 | */ |
| 2166 | public static final String CONTACT_DELETED_TIMESTAMP = "contact_deleted_timestamp"; |
| 2167 | } |
| 2168 | |
| 2169 | /** |
| 2170 | * Constants for the deleted contact table. This table holds a log of deleted contacts. |
| 2171 | * <p> |
| 2172 | * Log older than {@link #DAYS_KEPT_MILLISECONDS} may be deleted. |
| 2173 | */ |
| 2174 | public static final class DeletedContacts implements DeletedContactsColumns { |
| 2175 | |
| 2176 | /** |
| 2177 | * This utility class cannot be instantiated |
| 2178 | */ |
| 2179 | private DeletedContacts() { |
| 2180 | } |
| 2181 | |
| 2182 | /** |
| 2183 | * The content:// style URI for this table, which requests a directory of raw contact rows |
| 2184 | * matching the selection criteria. |
| 2185 | */ |
| 2186 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 2187 | "deleted_contacts"); |
| 2188 | |
| 2189 | /** |
| 2190 | * Number of days that the delete log will be kept. After this time, delete records may be |
| 2191 | * deleted. |
| 2192 | * |
| 2193 | * @hide |
| 2194 | */ |
| 2195 | private static final int DAYS_KEPT = 30; |
| 2196 | |
| 2197 | /** |
| 2198 | * Milliseconds that the delete log will be kept. After this time, delete records may be |
| 2199 | * deleted. |
| 2200 | */ |
| 2201 | public static final long DAYS_KEPT_MILLISECONDS = 1000L * 60L * 60L * 24L * (long)DAYS_KEPT; |
| 2202 | } |
| 2203 | |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 2204 | protected interface RawContactsColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2205 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2206 | * A reference to the {@link ContactsContract.Contacts#_ID} that this |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2207 | * data belongs to. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2208 | * <P>Type: INTEGER</P> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2209 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2210 | public static final String CONTACT_ID = "contact_id"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2211 | |
| 2212 | /** |
Zheng Fu | 9ea9a13 | 2015-01-07 11:33:19 -0800 | [diff] [blame] | 2213 | * Persistent unique id for each raw_contact within its account. |
| 2214 | * This id is provided by its own data source, and can be used to backup metadata |
| 2215 | * to the server. |
| 2216 | * This should be unique within each set of account_name/account_type/data_set |
| 2217 | * |
| 2218 | * @hide |
| 2219 | */ |
| 2220 | public static final String BACKUP_ID = "backup_id"; |
| 2221 | |
| 2222 | /** |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2223 | * The data set within the account that this row belongs to. This allows |
| 2224 | * multiple sync adapters for the same account type to distinguish between |
| 2225 | * each others' data. |
| 2226 | * |
| 2227 | * This is empty by default, and is completely optional. It only needs to |
| 2228 | * be populated if multiple sync adapters are entering distinct data for |
| 2229 | * the same account type and account name. |
| 2230 | * <P>Type: TEXT</P> |
| 2231 | */ |
| 2232 | public static final String DATA_SET = "data_set"; |
| 2233 | |
| 2234 | /** |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 2235 | * A concatenation of the account type and data set (delimited by a forward |
| 2236 | * slash) - if the data set is empty, this will be the same as the account |
| 2237 | * type. For applications that need to be aware of the data set, this can |
| 2238 | * be used instead of account type to distinguish sets of data. This is |
| 2239 | * never intended to be used for specifying accounts. |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 2240 | * <p> |
| 2241 | * This column does *not* escape forward slashes in the account type or the data set. |
| 2242 | * If this is an issue, consider using |
| 2243 | * {@link ContactsContract.RawContacts#ACCOUNT_TYPE} and |
| 2244 | * {@link ContactsContract.RawContacts#DATA_SET} directly. |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 2245 | */ |
| 2246 | public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; |
| 2247 | |
| 2248 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2249 | * The aggregation mode for this contact. |
| 2250 | * <P>Type: INTEGER</P> |
| 2251 | */ |
| 2252 | public static final String AGGREGATION_MODE = "aggregation_mode"; |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 2253 | |
| 2254 | /** |
| 2255 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 2256 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 2257 | * called on a raw contact, it is marked for deletion and removed from its |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2258 | * aggregate contact. The sync adaptor deletes the raw contact on the server and |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 2259 | * then calls ContactResolver.delete once more, this time passing the |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 2260 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 2261 | * the data removal. |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 2262 | * <P>Type: INTEGER</P> |
| 2263 | */ |
| 2264 | public static final String DELETED = "deleted"; |
Dmitri Plotnikov | 918007b | 2010-01-20 12:12:11 -0800 | [diff] [blame] | 2265 | |
| 2266 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 2267 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 2268 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 2269 | * <P>Type: INTEGER</P> |
| 2270 | */ |
Dmitri Plotnikov | 86fe839 | 2010-07-16 11:19:46 -0700 | [diff] [blame] | 2271 | public static final String RAW_CONTACT_IS_READ_ONLY = "raw_contact_is_read_only"; |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2272 | |
| 2273 | /** |
| 2274 | * Flag that reflects whether this raw contact belongs to the user's |
| 2275 | * personal profile entry. |
| 2276 | */ |
| 2277 | public static final String RAW_CONTACT_IS_USER_PROFILE = "raw_contact_is_user_profile"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2278 | } |
| 2279 | |
| 2280 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2281 | * Constants for the raw contacts table, which contains one row of contact |
| 2282 | * information for each person in each synced account. Sync adapters and |
| 2283 | * contact management apps |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 2284 | * are the primary consumers of this API. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2285 | * |
| 2286 | * <h3>Aggregation</h3> |
| 2287 | * <p> |
| 2288 | * As soon as a raw contact is inserted or whenever its constituent data |
| 2289 | * changes, the provider will check if the raw contact matches other |
| 2290 | * existing raw contacts and if so will aggregate it with those. The |
| 2291 | * aggregation is reflected in the {@link RawContacts} table by the change of the |
| 2292 | * {@link #CONTACT_ID} field, which is the reference to the aggregate contact. |
| 2293 | * </p> |
| 2294 | * <p> |
| 2295 | * Changes to the structured name, organization, phone number, email address, |
| 2296 | * or nickname trigger a re-aggregation. |
| 2297 | * </p> |
| 2298 | * <p> |
| 2299 | * See also {@link AggregationExceptions} for a mechanism to control |
| 2300 | * aggregation programmatically. |
| 2301 | * </p> |
| 2302 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2303 | * <h3>Operations</h3> |
| 2304 | * <dl> |
| 2305 | * <dt><b>Insert</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2306 | * <dd> |
| 2307 | * <p> |
| 2308 | * Raw contacts can be inserted incrementally or in a batch. |
| 2309 | * The incremental method is more traditional but less efficient. |
| 2310 | * It should be used |
| 2311 | * only if no {@link Data} values are available at the time the raw contact is created: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2312 | * <pre> |
| 2313 | * ContentValues values = new ContentValues(); |
| 2314 | * values.put(RawContacts.ACCOUNT_TYPE, accountType); |
| 2315 | * values.put(RawContacts.ACCOUNT_NAME, accountName); |
| 2316 | * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values); |
| 2317 | * long rawContactId = ContentUris.parseId(rawContactUri); |
| 2318 | * </pre> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2319 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2320 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2321 | * Once {@link Data} values become available, insert those. |
| 2322 | * For example, here's how you would insert a name: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2323 | * |
| 2324 | * <pre> |
| 2325 | * values.clear(); |
| 2326 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 2327 | * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); |
| 2328 | * values.put(StructuredName.DISPLAY_NAME, "Mike Sullivan"); |
| 2329 | * getContentResolver().insert(Data.CONTENT_URI, values); |
| 2330 | * </pre> |
| 2331 | * </p> |
| 2332 | * <p> |
| 2333 | * The batch method is by far preferred. It inserts the raw contact and its |
| 2334 | * constituent data rows in a single database transaction |
| 2335 | * and causes at most one aggregation pass. |
| 2336 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 2337 | * ArrayList<ContentProviderOperation> ops = |
| 2338 | * new ArrayList<ContentProviderOperation>(); |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2339 | * ... |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2340 | * int rawContactInsertIndex = ops.size(); |
| 2341 | * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) |
| 2342 | * .withValue(RawContacts.ACCOUNT_TYPE, accountType) |
| 2343 | * .withValue(RawContacts.ACCOUNT_NAME, accountName) |
| 2344 | * .build()); |
| 2345 | * |
| 2346 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 2347 | * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex) |
| 2348 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 2349 | * .withValue(StructuredName.DISPLAY_NAME, "Mike Sullivan") |
| 2350 | * .build()); |
| 2351 | * |
| 2352 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 2353 | * </pre> |
| 2354 | * </p> |
| 2355 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2356 | * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)} |
| 2357 | * to refer to the as-yet-unknown index value of the raw contact inserted in the |
| 2358 | * first operation. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2359 | * </p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2360 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2361 | * <dt><b>Update</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2362 | * <dd><p> |
| 2363 | * Raw contacts can be updated incrementally or in a batch. |
| 2364 | * Batch mode should be used whenever possible. |
| 2365 | * The procedures and considerations are analogous to those documented above for inserts. |
| 2366 | * </p></dd> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2367 | * <dt><b>Delete</b></dt> |
| 2368 | * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates, |
| 2369 | * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2370 | * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row |
| 2371 | * itself is also deleted automatically. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2372 | * </p> |
| 2373 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2374 | * The invocation of {@code resolver.delete(...)}, does not immediately delete |
| 2375 | * a raw contacts row. |
| 2376 | * Instead, it sets the {@link #DELETED} flag on the raw contact and |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2377 | * removes the raw contact from its aggregate contact. |
| 2378 | * The sync adapter then deletes the raw contact from the server and |
| 2379 | * finalizes phone-side deletion by calling {@code resolver.delete(...)} |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2380 | * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2381 | * <p>Some sync adapters are read-only, meaning that they only sync server-side |
| 2382 | * changes to the phone, but not the reverse. If one of those raw contacts |
| 2383 | * is marked for deletion, it will remain on the phone. However it will be |
| 2384 | * effectively invisible, because it will not be part of any aggregate contact. |
| 2385 | * </dd> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2386 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2387 | * <dt><b>Query</b></dt> |
| 2388 | * <dd> |
| 2389 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2390 | * It is easy to find all raw contacts in a Contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2391 | * <pre> |
| 2392 | * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI, |
| 2393 | * new String[]{RawContacts._ID}, |
| 2394 | * RawContacts.CONTACT_ID + "=?", |
| 2395 | * new String[]{String.valueOf(contactId)}, null); |
| 2396 | * </pre> |
| 2397 | * </p> |
| 2398 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2399 | * To find raw contacts within a specific account, |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2400 | * you can either put the account name and type in the selection or pass them as query |
| 2401 | * parameters. The latter approach is preferable, especially when you can reuse the |
| 2402 | * URI: |
| 2403 | * <pre> |
Adam Koch | 95e5a07 | 2013-05-21 09:47:55 -0400 | [diff] [blame] | 2404 | * Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon() |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2405 | * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName) |
| 2406 | * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType) |
| 2407 | * .build(); |
| 2408 | * Cursor c1 = getContentResolver().query(rawContactUri, |
| 2409 | * RawContacts.STARRED + "<>0", null, null, null); |
| 2410 | * ... |
| 2411 | * Cursor c2 = getContentResolver().query(rawContactUri, |
| 2412 | * RawContacts.DELETED + "<>0", null, null, null); |
| 2413 | * </pre> |
| 2414 | * </p> |
| 2415 | * <p>The best way to read a raw contact along with all the data associated with it is |
| 2416 | * by using the {@link Entity} directory. If the raw contact has data rows, |
| 2417 | * the Entity cursor will contain a row for each data row. If the raw contact has no |
| 2418 | * data rows, the cursor will still contain one row with the raw contact-level information. |
| 2419 | * <pre> |
| 2420 | * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); |
| 2421 | * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY); |
| 2422 | * Cursor c = getContentResolver().query(entityUri, |
| 2423 | * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1}, |
| 2424 | * null, null, null); |
| 2425 | * try { |
| 2426 | * while (c.moveToNext()) { |
| 2427 | * String sourceId = c.getString(0); |
| 2428 | * if (!c.isNull(1)) { |
| 2429 | * String mimeType = c.getString(2); |
| 2430 | * String data = c.getString(3); |
| 2431 | * ... |
| 2432 | * } |
| 2433 | * } |
| 2434 | * } finally { |
| 2435 | * c.close(); |
| 2436 | * } |
| 2437 | * </pre> |
| 2438 | * </p> |
| 2439 | * </dd> |
| 2440 | * </dl> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2441 | * <h2>Columns</h2> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2442 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2443 | * <table class="jd-sumtable"> |
| 2444 | * <tr> |
| 2445 | * <th colspan='4'>RawContacts</th> |
| 2446 | * </tr> |
| 2447 | * <tr> |
| 2448 | * <td>long</td> |
| 2449 | * <td>{@link #_ID}</td> |
| 2450 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2451 | * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words, |
| 2452 | * it is much better for a sync adapter to update a raw contact rather than to delete and |
| 2453 | * re-insert it.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2454 | * </tr> |
| 2455 | * <tr> |
| 2456 | * <td>long</td> |
| 2457 | * <td>{@link #CONTACT_ID}</td> |
| 2458 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2459 | * <td>The ID of the row in the {@link ContactsContract.Contacts} table |
| 2460 | * that this raw contact belongs |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2461 | * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled |
| 2462 | * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td> |
| 2463 | * </tr> |
| 2464 | * <tr> |
| 2465 | * <td>int</td> |
| 2466 | * <td>{@link #AGGREGATION_MODE}</td> |
| 2467 | * <td>read/write</td> |
| 2468 | * <td>A mechanism that allows programmatic control of the aggregation process. The allowed |
| 2469 | * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED} |
| 2470 | * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td> |
| 2471 | * </tr> |
| 2472 | * <tr> |
| 2473 | * <td>int</td> |
| 2474 | * <td>{@link #DELETED}</td> |
| 2475 | * <td>read/write</td> |
| 2476 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 2477 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 2478 | * called on a raw contact, it is marked for deletion and removed from its |
| 2479 | * aggregate contact. The sync adaptor deletes the raw contact on the server and |
| 2480 | * then calls ContactResolver.delete once more, this time passing the |
| 2481 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 2482 | * the data removal.</td> |
| 2483 | * </tr> |
| 2484 | * <tr> |
| 2485 | * <td>int</td> |
| 2486 | * <td>{@link #TIMES_CONTACTED}</td> |
| 2487 | * <td>read/write</td> |
| 2488 | * <td>The number of times the contact has been contacted. To have an effect |
| 2489 | * on the corresponding value of the aggregate contact, this field |
| 2490 | * should be set at the time the raw contact is inserted. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2491 | * After that, this value is typically updated via |
| 2492 | * {@link ContactsContract.Contacts#markAsContacted}.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2493 | * </tr> |
| 2494 | * <tr> |
| 2495 | * <td>long</td> |
| 2496 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 2497 | * <td>read/write</td> |
| 2498 | * <td>The timestamp of the last time the contact was contacted. To have an effect |
| 2499 | * on the corresponding value of the aggregate contact, this field |
| 2500 | * should be set at the time the raw contact is inserted. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2501 | * After that, this value is typically updated via |
| 2502 | * {@link ContactsContract.Contacts#markAsContacted}. |
| 2503 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2504 | * </tr> |
| 2505 | * <tr> |
| 2506 | * <td>int</td> |
| 2507 | * <td>{@link #STARRED}</td> |
| 2508 | * <td>read/write</td> |
| 2509 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2510 | * Changing this field immediately affects the corresponding aggregate contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2511 | * if any raw contacts in that aggregate contact are starred, then the contact |
| 2512 | * itself is marked as starred.</td> |
| 2513 | * </tr> |
| 2514 | * <tr> |
| 2515 | * <td>String</td> |
| 2516 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 2517 | * <td>read/write</td> |
| 2518 | * <td>A custom ringtone associated with a raw contact. Typically this is the |
| 2519 | * URI returned by an activity launched with the |
| 2520 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent. |
| 2521 | * To have an effect on the corresponding value of the aggregate contact, this field |
| 2522 | * should be set at the time the raw contact is inserted. To set a custom |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2523 | * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE |
| 2524 | * Contacts.CUSTOM_RINGTONE} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2525 | * instead.</td> |
| 2526 | * </tr> |
| 2527 | * <tr> |
| 2528 | * <td>int</td> |
| 2529 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 2530 | * <td>read/write</td> |
| 2531 | * <td>An indicator of whether calls from this raw contact should be forwarded |
| 2532 | * directly to voice mail ('1') or not ('0'). To have an effect |
| 2533 | * on the corresponding value of the aggregate contact, this field |
| 2534 | * should be set at the time the raw contact is inserted.</td> |
| 2535 | * </tr> |
| 2536 | * <tr> |
| 2537 | * <td>String</td> |
| 2538 | * <td>{@link #ACCOUNT_NAME}</td> |
| 2539 | * <td>read/write-once</td> |
| 2540 | * <td>The name of the account instance to which this row belongs, which when paired with |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2541 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
| 2542 | * For example, this will be the Gmail address if it is a Google account. |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2543 | * It should be set at the time the raw contact is inserted and never |
| 2544 | * changed afterwards.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2545 | * </tr> |
| 2546 | * <tr> |
| 2547 | * <td>String</td> |
| 2548 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 2549 | * <td>read/write-once</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2550 | * <td> |
| 2551 | * <p> |
| 2552 | * The type of account to which this row belongs, which when paired with |
| 2553 | * {@link #ACCOUNT_NAME} identifies a specific account. |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2554 | * It should be set at the time the raw contact is inserted and never |
| 2555 | * changed afterwards. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2556 | * </p> |
| 2557 | * <p> |
| 2558 | * To ensure uniqueness, new account types should be chosen according to the |
| 2559 | * Java package naming convention. Thus a Google account is of type "com.google". |
| 2560 | * </p> |
| 2561 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2562 | * </tr> |
| 2563 | * <tr> |
| 2564 | * <td>String</td> |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2565 | * <td>{@link #DATA_SET}</td> |
| 2566 | * <td>read/write-once</td> |
| 2567 | * <td> |
| 2568 | * <p> |
| 2569 | * The data set within the account that this row belongs to. This allows |
| 2570 | * multiple sync adapters for the same account type to distinguish between |
| 2571 | * each others' data. The combination of {@link #ACCOUNT_TYPE}, |
| 2572 | * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data |
| 2573 | * that is associated with a single sync adapter. |
| 2574 | * </p> |
| 2575 | * <p> |
| 2576 | * This is empty by default, and is completely optional. It only needs to |
| 2577 | * be populated if multiple sync adapters are entering distinct data for |
| 2578 | * the same account type and account name. |
| 2579 | * </p> |
| 2580 | * <p> |
| 2581 | * It should be set at the time the raw contact is inserted and never |
| 2582 | * changed afterwards. |
| 2583 | * </p> |
| 2584 | * </td> |
| 2585 | * </tr> |
| 2586 | * <tr> |
| 2587 | * <td>String</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2588 | * <td>{@link #SOURCE_ID}</td> |
| 2589 | * <td>read/write</td> |
| 2590 | * <td>String that uniquely identifies this row to its source account. |
| 2591 | * Typically it is set at the time the raw contact is inserted and never |
| 2592 | * changed afterwards. The one notable exception is a new raw contact: it |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2593 | * will have an account name and type (and possibly a data set), but no |
| 2594 | * source id. This indicates to the sync adapter that a new contact needs |
| 2595 | * to be created server-side and its ID stored in the corresponding |
| 2596 | * SOURCE_ID field on the phone. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2597 | * </td> |
| 2598 | * </tr> |
| 2599 | * <tr> |
| 2600 | * <td>int</td> |
| 2601 | * <td>{@link #VERSION}</td> |
| 2602 | * <td>read-only</td> |
| 2603 | * <td>Version number that is updated whenever this row or its related data |
| 2604 | * changes. This field can be used for optimistic locking of a raw contact. |
| 2605 | * </td> |
| 2606 | * </tr> |
| 2607 | * <tr> |
| 2608 | * <td>int</td> |
| 2609 | * <td>{@link #DIRTY}</td> |
| 2610 | * <td>read/write</td> |
| 2611 | * <td>Flag indicating that {@link #VERSION} has changed, and this row needs |
| 2612 | * to be synchronized by its owning account. The value is set to "1" automatically |
| 2613 | * whenever the raw contact changes, unless the URI has the |
| 2614 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified. |
| 2615 | * The sync adapter should always supply this query parameter to prevent |
| 2616 | * unnecessary synchronization: user changes some data on the server, |
| 2617 | * the sync adapter updates the contact on the phone (without the |
| 2618 | * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag, |
| 2619 | * which triggers a sync to bring the changes to the server. |
| 2620 | * </td> |
| 2621 | * </tr> |
| 2622 | * <tr> |
| 2623 | * <td>String</td> |
| 2624 | * <td>{@link #SYNC1}</td> |
| 2625 | * <td>read/write</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2626 | * <td>Generic column provided for arbitrary use by sync adapters. |
| 2627 | * The content provider |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2628 | * stores this information on behalf of the sync adapter but does not |
| 2629 | * interpret it in any way. |
| 2630 | * </td> |
| 2631 | * </tr> |
| 2632 | * <tr> |
| 2633 | * <td>String</td> |
| 2634 | * <td>{@link #SYNC2}</td> |
| 2635 | * <td>read/write</td> |
| 2636 | * <td>Generic column for use by sync adapters. |
| 2637 | * </td> |
| 2638 | * </tr> |
| 2639 | * <tr> |
| 2640 | * <td>String</td> |
| 2641 | * <td>{@link #SYNC3}</td> |
| 2642 | * <td>read/write</td> |
| 2643 | * <td>Generic column for use by sync adapters. |
| 2644 | * </td> |
| 2645 | * </tr> |
| 2646 | * <tr> |
| 2647 | * <td>String</td> |
| 2648 | * <td>{@link #SYNC4}</td> |
| 2649 | * <td>read/write</td> |
| 2650 | * <td>Generic column for use by sync adapters. |
| 2651 | * </td> |
| 2652 | * </tr> |
| 2653 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2654 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2655 | public static final class RawContacts implements BaseColumns, RawContactsColumns, |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 2656 | ContactOptionsColumns, ContactNameColumns, SyncColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2657 | /** |
| 2658 | * This utility class cannot be instantiated |
| 2659 | */ |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 2660 | private RawContacts() { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2661 | } |
| 2662 | |
| 2663 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2664 | * The content:// style URI for this table, which requests a directory of |
| 2665 | * raw contact rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2666 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 2667 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2668 | |
| 2669 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2670 | * The MIME type of the results from {@link #CONTENT_URI} when a specific |
| 2671 | * ID value is not provided, and multiple raw contacts may be returned. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2672 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2673 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2674 | |
| 2675 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2676 | * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI}, |
| 2677 | * yielding a subdirectory of a single person. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2678 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2679 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2680 | |
| 2681 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2682 | * Aggregation mode: aggregate immediately after insert or update operation(s) are complete. |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2683 | */ |
| 2684 | public static final int AGGREGATION_MODE_DEFAULT = 0; |
| 2685 | |
| 2686 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2687 | * Aggregation mode: aggregate at the time the raw contact is inserted/updated. |
| 2688 | * @deprecated Aggregation is synchronous, this historic value is a no-op |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2689 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2690 | @Deprecated |
Omari Stephens | bc9aa77 | 2009-09-08 19:10:53 -0700 | [diff] [blame] | 2691 | public static final int AGGREGATION_MODE_IMMEDIATE = 1; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2692 | |
| 2693 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2694 | * <p> |
| 2695 | * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later. |
| 2696 | * Changes to the raw contact will update the associated aggregate contact but will not |
| 2697 | * result in any change in how the contact is aggregated. Similar to |
| 2698 | * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding |
| 2699 | * {@link Contacts} aggregate. |
| 2700 | * </p> |
| 2701 | * <p> |
| 2702 | * This can be used to postpone aggregation until after a series of updates, for better |
| 2703 | * performance and/or user experience. |
| 2704 | * </p> |
| 2705 | * <p> |
| 2706 | * Note that changing |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2707 | * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2708 | * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any |
| 2709 | * subsequent |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2710 | * change to the raw contact's data will. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2711 | * </p> |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2712 | */ |
| 2713 | public static final int AGGREGATION_MODE_SUSPENDED = 2; |
| 2714 | |
| 2715 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2716 | * <p> |
| 2717 | * Aggregation mode: never aggregate this raw contact. The raw contact will not |
| 2718 | * have a corresponding {@link Contacts} aggregate and therefore will not be included in |
| 2719 | * {@link Contacts} query results. |
| 2720 | * </p> |
| 2721 | * <p> |
| 2722 | * For example, this mode can be used for a raw contact that is marked for deletion while |
| 2723 | * waiting for the deletion to occur on the server side. |
| 2724 | * </p> |
| 2725 | * |
| 2726 | * @see #AGGREGATION_MODE_SUSPENDED |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2727 | */ |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2728 | public static final int AGGREGATION_MODE_DISABLED = 3; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2729 | |
| 2730 | /** |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 2731 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 2732 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
| 2733 | * entry of the given {@link RawContacts} entry. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2734 | */ |
| 2735 | public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) { |
| 2736 | // TODO: use a lighter query by joining rawcontacts with contacts in provider |
| 2737 | final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY); |
| 2738 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 2739 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 2740 | }, null, null, null); |
| 2741 | |
| 2742 | Uri lookupUri = null; |
| 2743 | try { |
| 2744 | if (cursor != null && cursor.moveToFirst()) { |
| 2745 | final long contactId = cursor.getLong(0); |
| 2746 | final String lookupKey = cursor.getString(1); |
| 2747 | return Contacts.getLookupUri(contactId, lookupKey); |
| 2748 | } |
| 2749 | } finally { |
| 2750 | if (cursor != null) cursor.close(); |
| 2751 | } |
| 2752 | return lookupUri; |
| 2753 | } |
| 2754 | |
| 2755 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2756 | * A sub-directory of a single raw contact that contains all of its |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2757 | * {@link ContactsContract.Data} rows. To access this directory |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2758 | * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2759 | */ |
| 2760 | public static final class Data implements BaseColumns, DataColumns { |
| 2761 | /** |
| 2762 | * no public constructor since this is a utility class |
| 2763 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2764 | private Data() { |
| 2765 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2766 | |
| 2767 | /** |
| 2768 | * The directory twig for this sub-table |
| 2769 | */ |
| 2770 | public static final String CONTENT_DIRECTORY = "data"; |
| 2771 | } |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2772 | |
| 2773 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2774 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2775 | * A sub-directory of a single raw contact that contains all of its |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2776 | * {@link ContactsContract.Data} rows. To access this directory append |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2777 | * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2778 | * {@link RawContactsEntity} for a stand-alone table containing the same |
| 2779 | * data. |
| 2780 | * </p> |
| 2781 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2782 | * Entity has two ID fields: {@link #_ID} for the raw contact |
| 2783 | * and {@link #DATA_ID} for the data rows. |
| 2784 | * Entity always contains at least one row, even if there are no |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2785 | * actual data rows. In this case the {@link #DATA_ID} field will be |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2786 | * null. |
| 2787 | * </p> |
| 2788 | * <p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2789 | * Using Entity should be preferred to using two separate queries: |
| 2790 | * RawContacts followed by Data. The reason is that Entity reads all |
| 2791 | * data for a raw contact in one transaction, so there is no possibility |
| 2792 | * of the data changing between the two queries. |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2793 | */ |
| 2794 | public static final class Entity implements BaseColumns, DataColumns { |
| 2795 | /** |
| 2796 | * no public constructor since this is a utility class |
| 2797 | */ |
| 2798 | private Entity() { |
| 2799 | } |
| 2800 | |
| 2801 | /** |
| 2802 | * The directory twig for this sub-table |
| 2803 | */ |
| 2804 | public static final String CONTENT_DIRECTORY = "entity"; |
| 2805 | |
| 2806 | /** |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 2807 | * The ID of the data row. The value will be null if this raw contact has no |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2808 | * data rows. |
| 2809 | * <P>Type: INTEGER</P> |
| 2810 | */ |
| 2811 | public static final String DATA_ID = "data_id"; |
| 2812 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2813 | |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2814 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2815 | * <p> |
| 2816 | * A sub-directory of a single raw contact that contains all of its |
| 2817 | * {@link ContactsContract.StreamItems} rows. To access this directory append |
| 2818 | * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See |
| 2819 | * {@link ContactsContract.StreamItems} for a stand-alone table containing the |
| 2820 | * same data. |
| 2821 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 2822 | * <p> |
| 2823 | * Access to the social stream through this sub-directory requires additional permissions |
| 2824 | * beyond the read/write contact permissions required by the provider. Querying for |
| 2825 | * social stream data requires android.permission.READ_SOCIAL_STREAM permission, and |
| 2826 | * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM |
| 2827 | * permission. |
| 2828 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2829 | * |
| 2830 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 2831 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2832 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2833 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2834 | public static final class StreamItems implements BaseColumns, StreamItemsColumns { |
| 2835 | /** |
| 2836 | * No public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2837 | * |
| 2838 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 2839 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2840 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2841 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2842 | private StreamItems() { |
| 2843 | } |
| 2844 | |
| 2845 | /** |
| 2846 | * The directory twig for this sub-table |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2847 | * |
| 2848 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 2849 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2850 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2851 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2852 | public static final String CONTENT_DIRECTORY = "stream_items"; |
| 2853 | } |
| 2854 | |
| 2855 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2856 | * <p> |
| 2857 | * A sub-directory of a single raw contact that represents its primary |
| 2858 | * display photo. To access this directory append |
| 2859 | * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI. |
| 2860 | * The resulting URI represents an image file, and should be interacted with |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 2861 | * using ContentResolver.openAssetFileDescriptor. |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2862 | * <p> |
| 2863 | * <p> |
| 2864 | * Note that this sub-directory also supports opening the photo as an asset file |
| 2865 | * in write mode. Callers can create or replace the primary photo associated |
| 2866 | * with this raw contact by opening the asset file and writing the full-size |
| 2867 | * photo contents into it. When the file is closed, the image will be parsed, |
| 2868 | * sized down if necessary for the full-size display photo and thumbnail |
| 2869 | * dimensions, and stored. |
| 2870 | * </p> |
| 2871 | * <p> |
| 2872 | * Usage example: |
| 2873 | * <pre> |
| 2874 | * public void writeDisplayPhoto(long rawContactId, byte[] photo) { |
| 2875 | * Uri rawContactPhotoUri = Uri.withAppendedPath( |
| 2876 | * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), |
| 2877 | * RawContacts.DisplayPhoto.CONTENT_DIRECTORY); |
| 2878 | * try { |
| 2879 | * AssetFileDescriptor fd = |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 2880 | * getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2881 | * OutputStream os = fd.createOutputStream(); |
| 2882 | * os.write(photo); |
| 2883 | * os.close(); |
| 2884 | * fd.close(); |
| 2885 | * } catch (IOException e) { |
| 2886 | * // Handle error cases. |
| 2887 | * } |
| 2888 | * } |
| 2889 | * </pre> |
| 2890 | * </p> |
| 2891 | */ |
| 2892 | public static final class DisplayPhoto { |
| 2893 | /** |
| 2894 | * No public constructor since this is a utility class |
| 2895 | */ |
| 2896 | private DisplayPhoto() { |
| 2897 | } |
| 2898 | |
| 2899 | /** |
| 2900 | * The directory twig for this sub-table |
| 2901 | */ |
| 2902 | public static final String CONTENT_DIRECTORY = "display_photo"; |
| 2903 | } |
| 2904 | |
| 2905 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2906 | * TODO: javadoc |
| 2907 | * @param cursor |
| 2908 | * @return |
| 2909 | */ |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2910 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 2911 | return new EntityIteratorImpl(cursor); |
| 2912 | } |
| 2913 | |
| 2914 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 2915 | private static final String[] DATA_KEYS = new String[]{ |
| 2916 | Data.DATA1, |
| 2917 | Data.DATA2, |
| 2918 | Data.DATA3, |
| 2919 | Data.DATA4, |
| 2920 | Data.DATA5, |
| 2921 | Data.DATA6, |
| 2922 | Data.DATA7, |
| 2923 | Data.DATA8, |
| 2924 | Data.DATA9, |
| 2925 | Data.DATA10, |
| 2926 | Data.DATA11, |
| 2927 | Data.DATA12, |
| 2928 | Data.DATA13, |
| 2929 | Data.DATA14, |
| 2930 | Data.DATA15, |
| 2931 | Data.SYNC1, |
| 2932 | Data.SYNC2, |
| 2933 | Data.SYNC3, |
| 2934 | Data.SYNC4}; |
| 2935 | |
| 2936 | public EntityIteratorImpl(Cursor cursor) { |
| 2937 | super(cursor); |
| 2938 | } |
| 2939 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 2940 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2941 | public android.content.Entity getEntityAndIncrementCursor(Cursor cursor) |
| 2942 | throws RemoteException { |
| 2943 | final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID); |
| 2944 | final long rawContactId = cursor.getLong(columnRawContactId); |
| 2945 | |
| 2946 | // we expect the cursor is already at the row we need to read from |
| 2947 | ContentValues cv = new ContentValues(); |
| 2948 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME); |
| 2949 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE); |
Katherine Kuan | 1d83723 | 2011-08-24 16:06:06 -0700 | [diff] [blame] | 2950 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DATA_SET); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2951 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID); |
| 2952 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY); |
| 2953 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION); |
| 2954 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID); |
| 2955 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1); |
| 2956 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2); |
| 2957 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3); |
| 2958 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4); |
| 2959 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED); |
| 2960 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID); |
| 2961 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2962 | android.content.Entity contact = new android.content.Entity(cv); |
| 2963 | |
| 2964 | // read data rows until the contact id changes |
| 2965 | do { |
| 2966 | if (rawContactId != cursor.getLong(columnRawContactId)) { |
| 2967 | break; |
| 2968 | } |
| 2969 | // add the data to to the contact |
| 2970 | cv = new ContentValues(); |
| 2971 | cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID))); |
| 2972 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 2973 | Data.RES_PACKAGE); |
| 2974 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE); |
| 2975 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY); |
| 2976 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, |
| 2977 | Data.IS_SUPER_PRIMARY); |
| 2978 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION); |
| 2979 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 2980 | CommonDataKinds.GroupMembership.GROUP_SOURCE_ID); |
| 2981 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 2982 | Data.DATA_VERSION); |
| 2983 | for (String key : DATA_KEYS) { |
| 2984 | final int columnIndex = cursor.getColumnIndexOrThrow(key); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 2985 | switch (cursor.getType(columnIndex)) { |
| 2986 | case Cursor.FIELD_TYPE_NULL: |
| 2987 | // don't put anything |
| 2988 | break; |
| 2989 | case Cursor.FIELD_TYPE_INTEGER: |
| 2990 | case Cursor.FIELD_TYPE_FLOAT: |
| 2991 | case Cursor.FIELD_TYPE_STRING: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 2992 | cv.put(key, cursor.getString(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 2993 | break; |
| 2994 | case Cursor.FIELD_TYPE_BLOB: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 2995 | cv.put(key, cursor.getBlob(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 2996 | break; |
| 2997 | default: |
| 2998 | throw new IllegalStateException("Invalid or unhandled data type"); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2999 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3000 | } |
| 3001 | contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv); |
| 3002 | } while (cursor.moveToNext()); |
| 3003 | |
| 3004 | return contact; |
| 3005 | } |
| 3006 | |
| 3007 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3008 | } |
| 3009 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3010 | /** |
| 3011 | * Social status update columns. |
| 3012 | * |
| 3013 | * @see StatusUpdates |
| 3014 | * @see ContactsContract.Data |
| 3015 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3016 | protected interface StatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3017 | /** |
Dmitri Plotnikov | a60479d | 2009-09-27 20:16:31 -0700 | [diff] [blame] | 3018 | * Contact's latest presence level. |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3019 | * <P>Type: INTEGER (one of the values below)</P> |
| 3020 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3021 | public static final String PRESENCE = "mode"; |
| 3022 | |
| 3023 | /** |
| 3024 | * @deprecated use {@link #PRESENCE} |
| 3025 | */ |
| 3026 | @Deprecated |
| 3027 | public static final String PRESENCE_STATUS = PRESENCE; |
| 3028 | |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3029 | /** |
| 3030 | * An allowed value of {@link #PRESENCE}. |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3031 | */ |
| 3032 | int OFFLINE = 0; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3033 | |
| 3034 | /** |
| 3035 | * An allowed value of {@link #PRESENCE}. |
| 3036 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3037 | int INVISIBLE = 1; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3038 | |
| 3039 | /** |
| 3040 | * An allowed value of {@link #PRESENCE}. |
| 3041 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3042 | int AWAY = 2; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3043 | |
| 3044 | /** |
| 3045 | * An allowed value of {@link #PRESENCE}. |
| 3046 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3047 | int IDLE = 3; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3048 | |
| 3049 | /** |
| 3050 | * An allowed value of {@link #PRESENCE}. |
| 3051 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3052 | int DO_NOT_DISTURB = 4; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3053 | |
| 3054 | /** |
| 3055 | * An allowed value of {@link #PRESENCE}. |
| 3056 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3057 | int AVAILABLE = 5; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3058 | |
| 3059 | /** |
| 3060 | * Contact latest status update. |
| 3061 | * <p>Type: TEXT</p> |
| 3062 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3063 | public static final String STATUS = "status"; |
| 3064 | |
| 3065 | /** |
| 3066 | * @deprecated use {@link #STATUS} |
| 3067 | */ |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3068 | @Deprecated |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3069 | public static final String PRESENCE_CUSTOM_STATUS = STATUS; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3070 | |
| 3071 | /** |
| 3072 | * The absolute time in milliseconds when the latest status was inserted/updated. |
| 3073 | * <p>Type: NUMBER</p> |
| 3074 | */ |
| 3075 | public static final String STATUS_TIMESTAMP = "status_ts"; |
| 3076 | |
| 3077 | /** |
| 3078 | * The package containing resources for this status: label and icon. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3079 | * <p>Type: TEXT</p> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3080 | */ |
| 3081 | public static final String STATUS_RES_PACKAGE = "status_res_package"; |
| 3082 | |
| 3083 | /** |
| 3084 | * The resource ID of the label describing the source of the status update, e.g. "Google |
| 3085 | * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 3086 | * <p>Type: NUMBER</p> |
| 3087 | */ |
| 3088 | public static final String STATUS_LABEL = "status_label"; |
| 3089 | |
| 3090 | /** |
| 3091 | * The resource ID of the icon for the source of the status update. |
| 3092 | * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 3093 | * <p>Type: NUMBER</p> |
| 3094 | */ |
| 3095 | public static final String STATUS_ICON = "status_icon"; |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3096 | |
| 3097 | /** |
| 3098 | * Contact's audio/video chat capability level. |
| 3099 | * <P>Type: INTEGER (one of the values below)</P> |
| 3100 | */ |
| 3101 | public static final String CHAT_CAPABILITY = "chat_capability"; |
| 3102 | |
| 3103 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3104 | * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone |
| 3105 | * and speaker) |
| 3106 | */ |
| 3107 | public static final int CAPABILITY_HAS_VOICE = 1; |
| 3108 | |
| 3109 | /** |
| 3110 | * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device can |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3111 | * display a video feed. |
| 3112 | */ |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3113 | public static final int CAPABILITY_HAS_VIDEO = 2; |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3114 | |
| 3115 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3116 | * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device has a |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3117 | * camera that can be used for video chat (e.g. a front-facing camera on a phone). |
| 3118 | */ |
| 3119 | public static final int CAPABILITY_HAS_CAMERA = 4; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3120 | } |
| 3121 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3122 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3123 | * <p> |
| 3124 | * Constants for the stream_items table, which contains social stream updates from |
| 3125 | * the user's contact list. |
| 3126 | * </p> |
| 3127 | * <p> |
| 3128 | * Only a certain number of stream items will ever be stored under a given raw contact. |
| 3129 | * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to |
| 3130 | * determine this limit, and should restrict the number of items inserted in any given |
| 3131 | * transaction correspondingly. Insertion of more items beyond the limit will |
| 3132 | * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}. |
| 3133 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3134 | * <p> |
| 3135 | * Access to the social stream through these URIs requires additional permissions beyond the |
| 3136 | * read/write contact permissions required by the provider. Querying for social stream data |
| 3137 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social |
| 3138 | * stream items requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3139 | * </p> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3140 | * <h3>Account check</h3> |
| 3141 | * <p> |
| 3142 | * The content URIs to the insert, update and delete operations are required to have the account |
| 3143 | * information matching that of the owning raw contact as query parameters, namely |
| 3144 | * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. |
| 3145 | * {@link RawContacts#DATA_SET} isn't required. |
| 3146 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3147 | * <h3>Operations</h3> |
| 3148 | * <dl> |
| 3149 | * <dt><b>Insert</b></dt> |
| 3150 | * <dd> |
| 3151 | * <p>Social stream updates are always associated with a raw contact. There are a couple |
| 3152 | * of ways to insert these entries. |
| 3153 | * <dl> |
| 3154 | * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt> |
| 3155 | * <dd> |
| 3156 | * <pre> |
| 3157 | * ContentValues values = new ContentValues(); |
| 3158 | * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); |
| 3159 | * values.put(StreamItems.TIMESTAMP, timestamp); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3160 | * values.put(StreamItems.COMMENTS, "3 people reshared this"); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3161 | * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon(); |
| 3162 | * ContentUris.appendId(builder, rawContactId); |
| 3163 | * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY); |
| 3164 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3165 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3166 | * Uri streamItemUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3167 | * long streamItemId = ContentUris.parseId(streamItemUri); |
| 3168 | * </pre> |
| 3169 | * </dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3170 | * <dt>Via {@link StreamItems#CONTENT_URI}:</dt> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3171 | * <dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3172 | *<pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3173 | * ContentValues values = new ContentValues(); |
| 3174 | * values.put(StreamItems.RAW_CONTACT_ID, rawContactId); |
| 3175 | * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); |
| 3176 | * values.put(StreamItems.TIMESTAMP, timestamp); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3177 | * values.put(StreamItems.COMMENTS, "3 people reshared this"); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3178 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3179 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3180 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3181 | * Uri streamItemUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3182 | * long streamItemId = ContentUris.parseId(streamItemUri); |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3183 | *</pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3184 | * </dd> |
| 3185 | * </dl> |
| 3186 | * </dd> |
| 3187 | * </p> |
| 3188 | * <p> |
| 3189 | * Once a {@link StreamItems} entry has been inserted, photos associated with that |
| 3190 | * social update can be inserted. For example, after one of the insertions above, |
| 3191 | * photos could be added to the stream item in one of the following ways: |
| 3192 | * <dl> |
| 3193 | * <dt>Via a URI including the stream item ID:</dt> |
| 3194 | * <dd> |
| 3195 | * <pre> |
| 3196 | * values.clear(); |
| 3197 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3198 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3199 | * getContentResolver().insert(Uri.withAppendedPath( |
| 3200 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId), |
| 3201 | * StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values); |
| 3202 | * </pre> |
| 3203 | * </dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3204 | * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3205 | * <dd> |
| 3206 | * <pre> |
| 3207 | * values.clear(); |
| 3208 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
| 3209 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3210 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3211 | * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values); |
| 3212 | * </pre> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3213 | * <p>Note that this latter form allows the insertion of a stream item and its |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3214 | * photos in a single transaction, by using {@link ContentProviderOperation} with |
| 3215 | * back references to populate the stream item ID in the {@link ContentValues}. |
| 3216 | * </dd> |
| 3217 | * </dl> |
| 3218 | * </p> |
| 3219 | * </dd> |
| 3220 | * <dt><b>Update</b></dt> |
| 3221 | * <dd>Updates can be performed by appending the stream item ID to the |
| 3222 | * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were |
| 3223 | * created by the calling package can be updated.</dd> |
| 3224 | * <dt><b>Delete</b></dt> |
| 3225 | * <dd>Deletes can be performed by appending the stream item ID to the |
| 3226 | * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were |
| 3227 | * created by the calling package can be deleted.</dd> |
| 3228 | * <dt><b>Query</b></dt> |
| 3229 | * <dl> |
| 3230 | * <dt>Finding all social stream updates for a given contact</dt> |
| 3231 | * <dd>By Contact ID: |
| 3232 | * <pre> |
| 3233 | * Cursor c = getContentResolver().query(Uri.withAppendedPath( |
| 3234 | * ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId), |
| 3235 | * Contacts.StreamItems.CONTENT_DIRECTORY), |
| 3236 | * null, null, null, null); |
| 3237 | * </pre> |
| 3238 | * </dd> |
| 3239 | * <dd>By lookup key: |
| 3240 | * <pre> |
| 3241 | * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon() |
| 3242 | * .appendPath(lookupKey) |
| 3243 | * .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(), |
| 3244 | * null, null, null, null); |
| 3245 | * </pre> |
| 3246 | * </dd> |
| 3247 | * <dt>Finding all social stream updates for a given raw contact</dt> |
| 3248 | * <dd> |
| 3249 | * <pre> |
| 3250 | * Cursor c = getContentResolver().query(Uri.withAppendedPath( |
| 3251 | * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), |
| 3252 | * RawContacts.StreamItems.CONTENT_DIRECTORY)), |
| 3253 | * null, null, null, null); |
| 3254 | * </pre> |
| 3255 | * </dd> |
| 3256 | * <dt>Querying for a specific stream item by ID</dt> |
| 3257 | * <dd> |
| 3258 | * <pre> |
| 3259 | * Cursor c = getContentResolver().query(ContentUris.withAppendedId( |
| 3260 | * StreamItems.CONTENT_URI, streamItemId), |
| 3261 | * null, null, null, null); |
| 3262 | * </pre> |
| 3263 | * </dd> |
| 3264 | * </dl> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3265 | * |
| 3266 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3267 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3268 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3269 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3270 | public static final class StreamItems implements BaseColumns, StreamItemsColumns { |
| 3271 | /** |
| 3272 | * This utility class cannot be instantiated |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3273 | * |
| 3274 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3275 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3276 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3277 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3278 | private StreamItems() { |
| 3279 | } |
| 3280 | |
| 3281 | /** |
| 3282 | * The content:// style URI for this table, which handles social network stream |
| 3283 | * updates for the user's contacts. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3284 | * |
| 3285 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3286 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3287 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3288 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3289 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items"); |
| 3290 | |
| 3291 | /** |
| 3292 | * <p> |
| 3293 | * A content:// style URI for the photos stored in a sub-table underneath |
| 3294 | * stream items. This is only used for inserts, and updates - queries and deletes |
| 3295 | * for photos should be performed by appending |
| 3296 | * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a |
| 3297 | * specific stream item. |
| 3298 | * </p> |
| 3299 | * <p> |
| 3300 | * When using this URI, the stream item ID for the photo(s) must be identified |
| 3301 | * in the {@link ContentValues} passed in. |
| 3302 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3303 | * |
| 3304 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3305 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3306 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3307 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3308 | public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo"); |
| 3309 | |
| 3310 | /** |
| 3311 | * This URI allows the caller to query for the maximum number of stream items |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3312 | * that will be stored under any single raw contact. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3313 | * |
| 3314 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3315 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3316 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3317 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3318 | public static final Uri CONTENT_LIMIT_URI = |
| 3319 | Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit"); |
| 3320 | |
| 3321 | /** |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3322 | * The MIME type of a directory of stream items. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3323 | * |
| 3324 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3325 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3326 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3327 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3328 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item"; |
| 3329 | |
| 3330 | /** |
| 3331 | * The MIME type of a single stream item. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3332 | * |
| 3333 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3334 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3335 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3336 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3337 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/stream_item"; |
| 3338 | |
| 3339 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3340 | * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will |
| 3341 | * contain this column, with the value indicating the maximum number of |
| 3342 | * stream items that will be stored under any single raw contact. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3343 | * |
| 3344 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3345 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3346 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3347 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3348 | public static final String MAX_ITEMS = "max_items"; |
| 3349 | |
| 3350 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3351 | * <p> |
| 3352 | * A sub-directory of a single stream item entry that contains all of its |
| 3353 | * photo rows. To access this |
| 3354 | * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to |
| 3355 | * an individual stream item URI. |
| 3356 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3357 | * <p> |
| 3358 | * Access to social stream photos requires additional permissions beyond the read/write |
| 3359 | * contact permissions required by the provider. Querying for social stream photos |
| 3360 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating |
| 3361 | * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3362 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3363 | * |
| 3364 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3365 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3366 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3367 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3368 | public static final class StreamItemPhotos |
| 3369 | implements BaseColumns, StreamItemPhotosColumns { |
| 3370 | /** |
| 3371 | * No public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3372 | * |
| 3373 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3374 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3375 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3376 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3377 | private StreamItemPhotos() { |
| 3378 | } |
| 3379 | |
| 3380 | /** |
| 3381 | * The directory twig for this sub-table |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3382 | * |
| 3383 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3384 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3385 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3386 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3387 | public static final String CONTENT_DIRECTORY = "photo"; |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3388 | |
| 3389 | /** |
| 3390 | * The MIME type of a directory of stream item photos. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3391 | * |
| 3392 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3393 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3394 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3395 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3396 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item_photo"; |
| 3397 | |
| 3398 | /** |
| 3399 | * The MIME type of a single stream item photo. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3400 | * |
| 3401 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3402 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3403 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3404 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3405 | public static final String CONTENT_ITEM_TYPE |
| 3406 | = "vnd.android.cursor.item/stream_item_photo"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3407 | } |
| 3408 | } |
| 3409 | |
| 3410 | /** |
| 3411 | * Columns in the StreamItems table. |
| 3412 | * |
| 3413 | * @see ContactsContract.StreamItems |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3414 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3415 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3416 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3417 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3418 | protected interface StreamItemsColumns { |
| 3419 | /** |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3420 | * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} |
| 3421 | * that this stream item belongs to. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3422 | * |
| 3423 | * <p>Type: INTEGER</p> |
| 3424 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3425 | * |
| 3426 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3427 | * cursors returned from related queries will be empty. |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3428 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3429 | @Deprecated |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3430 | public static final String CONTACT_ID = "contact_id"; |
| 3431 | |
| 3432 | /** |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3433 | * A reference to the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY} |
| 3434 | * that this stream item belongs to. |
| 3435 | * |
| 3436 | * <p>Type: TEXT</p> |
| 3437 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3438 | * |
| 3439 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3440 | * cursors returned from related queries will be empty. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3441 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3442 | @Deprecated |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3443 | public static final String CONTACT_LOOKUP_KEY = "contact_lookup"; |
| 3444 | |
| 3445 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3446 | * A reference to the {@link RawContacts#_ID} |
| 3447 | * that this stream item belongs to. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3448 | * <p>Type: INTEGER</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3449 | * |
| 3450 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3451 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3452 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3453 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3454 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 3455 | |
| 3456 | /** |
| 3457 | * The package name to use when creating {@link Resources} objects for |
| 3458 | * this stream item. This value is only designed for use when building |
| 3459 | * user interfaces, and should not be used to infer the owner. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3460 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3461 | * |
| 3462 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3463 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3464 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3465 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3466 | public static final String RES_PACKAGE = "res_package"; |
| 3467 | |
| 3468 | /** |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3469 | * The account type to which the raw_contact of this item is associated. See |
| 3470 | * {@link RawContacts#ACCOUNT_TYPE} |
| 3471 | * |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3472 | * <p>Type: TEXT</p> |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3473 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3474 | * |
| 3475 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3476 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3477 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3478 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3479 | public static final String ACCOUNT_TYPE = "account_type"; |
| 3480 | |
| 3481 | /** |
| 3482 | * The account name to which the raw_contact of this item is associated. See |
| 3483 | * {@link RawContacts#ACCOUNT_NAME} |
| 3484 | * |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3485 | * <p>Type: TEXT</p> |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3486 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3487 | * |
| 3488 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3489 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3490 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3491 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3492 | public static final String ACCOUNT_NAME = "account_name"; |
| 3493 | |
| 3494 | /** |
| 3495 | * The data set within the account that the raw_contact of this row belongs to. This allows |
| 3496 | * multiple sync adapters for the same account type to distinguish between |
| 3497 | * each others' data. |
| 3498 | * {@link RawContacts#DATA_SET} |
| 3499 | * |
| 3500 | * <P>Type: TEXT</P> |
| 3501 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3502 | * |
| 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 Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3505 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3506 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3507 | public static final String DATA_SET = "data_set"; |
| 3508 | |
| 3509 | /** |
| 3510 | * The source_id of the raw_contact that this row belongs to. |
| 3511 | * {@link RawContacts#SOURCE_ID} |
| 3512 | * |
| 3513 | * <P>Type: TEXT</P> |
| 3514 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3515 | * |
| 3516 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3517 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3518 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3519 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3520 | public static final String RAW_CONTACT_SOURCE_ID = "raw_contact_source_id"; |
| 3521 | |
| 3522 | /** |
| 3523 | * The resource name of the icon for the source of the stream item. |
| 3524 | * This resource should be scoped by the {@link #RES_PACKAGE}. As this can only reference |
| 3525 | * drawables, the "@drawable/" prefix must be omitted. |
| 3526 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3527 | * |
| 3528 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3529 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3530 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3531 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3532 | public static final String RES_ICON = "icon"; |
| 3533 | |
| 3534 | /** |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3535 | * The resource name of the label describing the source of the status update, e.g. "Google |
| 3536 | * Talk". This resource should be scoped by the {@link #RES_PACKAGE}. As this can only |
| 3537 | * reference strings, the "@string/" prefix must be omitted. |
| 3538 | * <p>Type: TEXT</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3539 | * |
| 3540 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3541 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3542 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3543 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3544 | public static final String RES_LABEL = "label"; |
| 3545 | |
| 3546 | /** |
| 3547 | * <P> |
| 3548 | * The main textual contents of the item. Typically this is content |
| 3549 | * that was posted by the source of this stream item, but it can also |
| 3550 | * be a textual representation of an action (e.g. ”Checked in at Joe's”). |
| 3551 | * This text is displayed to the user and allows formatting and embedded |
| 3552 | * resource images via HTML (as parseable via |
| 3553 | * {@link android.text.Html#fromHtml}). |
| 3554 | * </P> |
| 3555 | * <P> |
| 3556 | * Long content may be truncated and/or ellipsized - the exact behavior |
| 3557 | * is unspecified, but it should not break tags. |
| 3558 | * </P> |
| 3559 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3560 | * |
| 3561 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3562 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3563 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3564 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3565 | public static final String TEXT = "text"; |
| 3566 | |
| 3567 | /** |
| 3568 | * The absolute time (milliseconds since epoch) when this stream item was |
| 3569 | * inserted/updated. |
| 3570 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3571 | * |
| 3572 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3573 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3574 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3575 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3576 | public static final String TIMESTAMP = "timestamp"; |
| 3577 | |
| 3578 | /** |
| 3579 | * <P> |
| 3580 | * Summary information about the stream item, for example to indicate how |
| 3581 | * many people have reshared it, how many have liked it, how many thumbs |
| 3582 | * up and/or thumbs down it has, what the original source was, etc. |
| 3583 | * </P> |
| 3584 | * <P> |
| 3585 | * This text is displayed to the user and allows simple formatting via |
| 3586 | * HTML, in the same manner as {@link #TEXT} allows. |
| 3587 | * </P> |
| 3588 | * <P> |
| 3589 | * Long content may be truncated and/or ellipsized - the exact behavior |
| 3590 | * is unspecified, but it should not break tags. |
| 3591 | * </P> |
| 3592 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3593 | * |
| 3594 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3595 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3596 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3597 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3598 | public static final String COMMENTS = "comments"; |
| 3599 | |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3600 | /** |
| 3601 | * Generic column for use by sync adapters. |
| 3602 | * |
| 3603 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3604 | * cursors returned from related queries will be empty. |
| 3605 | */ |
| 3606 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3607 | public static final String SYNC1 = "stream_item_sync1"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3608 | /** |
| 3609 | * Generic column for use by sync adapters. |
| 3610 | * |
| 3611 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3612 | * cursors returned from related queries will be empty. |
| 3613 | */ |
| 3614 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3615 | public static final String SYNC2 = "stream_item_sync2"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3616 | /** |
| 3617 | * Generic column for use by sync adapters. |
| 3618 | * |
| 3619 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3620 | * cursors returned from related queries will be empty. |
| 3621 | */ |
| 3622 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3623 | public static final String SYNC3 = "stream_item_sync3"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3624 | /** |
| 3625 | * Generic column for use by sync adapters. |
| 3626 | * |
| 3627 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3628 | * cursors returned from related queries will be empty. |
| 3629 | */ |
| 3630 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3631 | public static final String SYNC4 = "stream_item_sync4"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3632 | } |
| 3633 | |
| 3634 | /** |
| 3635 | * <p> |
| 3636 | * Constants for the stream_item_photos table, which contains photos associated with |
| 3637 | * social stream updates. |
| 3638 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3639 | * <p> |
| 3640 | * Access to social stream photos requires additional permissions beyond the read/write |
| 3641 | * contact permissions required by the provider. Querying for social stream photos |
| 3642 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating |
| 3643 | * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3644 | * </p> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3645 | * <h3>Account check</h3> |
| 3646 | * <p> |
| 3647 | * The content URIs to the insert, update and delete operations are required to have the account |
| 3648 | * information matching that of the owning raw contact as query parameters, namely |
| 3649 | * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. |
| 3650 | * {@link RawContacts#DATA_SET} isn't required. |
| 3651 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3652 | * <h3>Operations</h3> |
| 3653 | * <dl> |
| 3654 | * <dt><b>Insert</b></dt> |
| 3655 | * <dd> |
| 3656 | * <p>Social stream photo entries are associated with a social stream item. Photos |
| 3657 | * can be inserted into a social stream item in a couple of ways: |
| 3658 | * <dl> |
| 3659 | * <dt> |
| 3660 | * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a |
| 3661 | * stream item: |
| 3662 | * </dt> |
| 3663 | * <dd> |
| 3664 | * <pre> |
| 3665 | * ContentValues values = new ContentValues(); |
| 3666 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3667 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3668 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3669 | * ContentUris.appendId(builder, streamItemId); |
| 3670 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3671 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3672 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3673 | * Uri photoUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3674 | * long photoId = ContentUris.parseId(photoUri); |
| 3675 | * </pre> |
| 3676 | * </dd> |
| 3677 | * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> |
| 3678 | * <dd> |
| 3679 | * <pre> |
| 3680 | * ContentValues values = new ContentValues(); |
| 3681 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
| 3682 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3683 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3684 | * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); |
| 3685 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3686 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3687 | * Uri photoUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3688 | * long photoId = ContentUris.parseId(photoUri); |
| 3689 | * </pre> |
| 3690 | * </dd> |
| 3691 | * </dl> |
| 3692 | * </p> |
| 3693 | * </dd> |
| 3694 | * <dt><b>Update</b></dt> |
| 3695 | * <dd> |
| 3696 | * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry, |
| 3697 | * identified by both the stream item ID it belongs to and the stream item photo ID. |
| 3698 | * This can be specified in two ways. |
| 3699 | * <dl> |
| 3700 | * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a |
| 3701 | * stream item: |
| 3702 | * </dt> |
| 3703 | * <dd> |
| 3704 | * <pre> |
| 3705 | * ContentValues values = new ContentValues(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3706 | * values.put(StreamItemPhotos.PHOTO, newPhotoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3707 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3708 | * ContentUris.appendId(builder, streamItemId); |
| 3709 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3710 | * ContentUris.appendId(builder, streamItemPhotoId); |
| 3711 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3712 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3713 | * getContentResolver().update(builder.build(), values, null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3714 | * </pre> |
| 3715 | * </dd> |
| 3716 | * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> |
| 3717 | * <dd> |
| 3718 | * <pre> |
| 3719 | * ContentValues values = new ContentValues(); |
| 3720 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3721 | * values.put(StreamItemPhotos.PHOTO, newPhotoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3722 | * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); |
| 3723 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3724 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3725 | * getContentResolver().update(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3726 | * </pre> |
| 3727 | * </dd> |
| 3728 | * </dl> |
| 3729 | * </p> |
| 3730 | * </dd> |
| 3731 | * <dt><b>Delete</b></dt> |
| 3732 | * <dd>Deletes can be made against either a specific photo item in a stream item, or |
| 3733 | * against all or a selected subset of photo items under a stream item. |
| 3734 | * For example: |
| 3735 | * <dl> |
| 3736 | * <dt>Deleting a single photo via the |
| 3737 | * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item: |
| 3738 | * </dt> |
| 3739 | * <dd> |
| 3740 | * <pre> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3741 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3742 | * ContentUris.appendId(builder, streamItemId); |
| 3743 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3744 | * ContentUris.appendId(builder, streamItemPhotoId); |
| 3745 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3746 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3747 | * getContentResolver().delete(builder.build(), null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3748 | * </pre> |
| 3749 | * </dd> |
| 3750 | * <dt>Deleting all photos under a stream item</dt> |
| 3751 | * <dd> |
| 3752 | * <pre> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3753 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3754 | * ContentUris.appendId(builder, streamItemId); |
| 3755 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3756 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3757 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3758 | * getContentResolver().delete(builder.build(), null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3759 | * </pre> |
| 3760 | * </dd> |
| 3761 | * </dl> |
| 3762 | * </dd> |
| 3763 | * <dt><b>Query</b></dt> |
| 3764 | * <dl> |
| 3765 | * <dt>Querying for a specific photo in a stream item</dt> |
| 3766 | * <dd> |
| 3767 | * <pre> |
| 3768 | * Cursor c = getContentResolver().query( |
| 3769 | * ContentUris.withAppendedId( |
| 3770 | * Uri.withAppendedPath( |
| 3771 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) |
| 3772 | * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), |
| 3773 | * streamItemPhotoId), null, null, null, null); |
| 3774 | * </pre> |
| 3775 | * </dd> |
| 3776 | * <dt>Querying for all photos in a stream item</dt> |
| 3777 | * <dd> |
| 3778 | * <pre> |
| 3779 | * Cursor c = getContentResolver().query( |
| 3780 | * Uri.withAppendedPath( |
| 3781 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) |
| 3782 | * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), |
| 3783 | * null, null, null, StreamItemPhotos.SORT_INDEX); |
| 3784 | * </pre> |
| 3785 | * </dl> |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3786 | * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a |
| 3787 | * {@link StreamItemPhotos#PHOTO_URI}. The {@link StreamItemPhotos#PHOTO_FILE_ID} |
| 3788 | * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to |
| 3789 | * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as |
| 3790 | * an asset file, as follows: |
| 3791 | * <pre> |
| 3792 | * public InputStream openDisplayPhoto(String photoUri) { |
| 3793 | * try { |
| 3794 | * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r"); |
| 3795 | * return fd.createInputStream(); |
| 3796 | * } catch (IOException e) { |
| 3797 | * return null; |
| 3798 | * } |
| 3799 | * } |
| 3800 | * <pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3801 | * </dd> |
| 3802 | * </dl> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3803 | * |
| 3804 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3805 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3806 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3807 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3808 | public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns { |
| 3809 | /** |
| 3810 | * No public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3811 | * |
| 3812 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3813 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3814 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3815 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3816 | private StreamItemPhotos() { |
| 3817 | } |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3818 | |
| 3819 | /** |
| 3820 | * <p> |
| 3821 | * The binary representation of the photo. Any size photo can be inserted; |
| 3822 | * the provider will resize it appropriately for storage and display. |
| 3823 | * </p> |
| 3824 | * <p> |
| 3825 | * This is only intended for use when inserting or updating a stream item photo. |
| 3826 | * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI} |
| 3827 | * as an asset file. |
| 3828 | * </p> |
| 3829 | * <P>Type: BLOB</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3830 | * |
| 3831 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3832 | * cursors returned from related queries will be empty. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3833 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3834 | @Deprecated |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3835 | public static final String PHOTO = "photo"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3836 | } |
| 3837 | |
| 3838 | /** |
| 3839 | * Columns in the StreamItemPhotos table. |
| 3840 | * |
| 3841 | * @see ContactsContract.StreamItemPhotos |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3842 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3843 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3844 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3845 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3846 | protected interface StreamItemPhotosColumns { |
| 3847 | /** |
| 3848 | * A reference to the {@link StreamItems#_ID} this photo is associated with. |
| 3849 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3850 | * |
| 3851 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3852 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3853 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3854 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3855 | public static final String STREAM_ITEM_ID = "stream_item_id"; |
| 3856 | |
| 3857 | /** |
| 3858 | * An integer to use for sort order for photos in the stream item. If not |
| 3859 | * specified, the {@link StreamItemPhotos#_ID} will be used for sorting. |
| 3860 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3861 | * |
| 3862 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3863 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3864 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3865 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3866 | public static final String SORT_INDEX = "sort_index"; |
| 3867 | |
| 3868 | /** |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3869 | * Photo file ID for the photo. |
| 3870 | * See {@link ContactsContract.DisplayPhoto}. |
| 3871 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3872 | * |
| 3873 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3874 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3875 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3876 | @Deprecated |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3877 | public static final String PHOTO_FILE_ID = "photo_file_id"; |
| 3878 | |
| 3879 | /** |
| 3880 | * URI for retrieving the photo content, automatically populated. Callers |
| 3881 | * may retrieve the photo content by opening this URI as an asset file. |
| 3882 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3883 | * |
| 3884 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3885 | * cursors returned from related queries will be empty. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3886 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3887 | @Deprecated |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3888 | public static final String PHOTO_URI = "photo_uri"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3889 | |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3890 | /** |
| 3891 | * Generic column for use by sync adapters. |
| 3892 | * |
| 3893 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3894 | * cursors returned from related queries will be empty. |
| 3895 | */ |
| 3896 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3897 | public static final String SYNC1 = "stream_item_photo_sync1"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3898 | /** |
| 3899 | * Generic column for use by sync adapters. |
| 3900 | * |
| 3901 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3902 | * cursors returned from related queries will be empty. |
| 3903 | */ |
| 3904 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3905 | public static final String SYNC2 = "stream_item_photo_sync2"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3906 | /** |
| 3907 | * Generic column for use by sync adapters. |
| 3908 | * |
| 3909 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3910 | * cursors returned from related queries will be empty. |
| 3911 | */ |
| 3912 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3913 | public static final String SYNC3 = "stream_item_photo_sync3"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3914 | /** |
| 3915 | * Generic column for use by sync adapters. |
| 3916 | * |
| 3917 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3918 | * cursors returned from related queries will be empty. |
| 3919 | */ |
| 3920 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3921 | public static final String SYNC4 = "stream_item_photo_sync4"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3922 | } |
| 3923 | |
| 3924 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 3925 | * <p> |
| 3926 | * Constants for the photo files table, which tracks metadata for hi-res photos |
| 3927 | * stored in the file system. |
| 3928 | * </p> |
| 3929 | * |
| 3930 | * @hide |
| 3931 | */ |
| 3932 | public static final class PhotoFiles implements BaseColumns, PhotoFilesColumns { |
| 3933 | /** |
| 3934 | * No public constructor since this is a utility class |
| 3935 | */ |
| 3936 | private PhotoFiles() { |
| 3937 | } |
| 3938 | } |
| 3939 | |
| 3940 | /** |
| 3941 | * Columns in the PhotoFiles table. |
| 3942 | * |
| 3943 | * @see ContactsContract.PhotoFiles |
| 3944 | * |
| 3945 | * @hide |
| 3946 | */ |
| 3947 | protected interface PhotoFilesColumns { |
| 3948 | |
| 3949 | /** |
| 3950 | * The height, in pixels, of the photo this entry is associated with. |
| 3951 | * <P>Type: NUMBER</P> |
| 3952 | */ |
| 3953 | public static final String HEIGHT = "height"; |
| 3954 | |
| 3955 | /** |
| 3956 | * The width, in pixels, of the photo this entry is associated with. |
| 3957 | * <P>Type: NUMBER</P> |
| 3958 | */ |
| 3959 | public static final String WIDTH = "width"; |
| 3960 | |
| 3961 | /** |
| 3962 | * The size, in bytes, of the photo stored on disk. |
| 3963 | * <P>Type: NUMBER</P> |
| 3964 | */ |
| 3965 | public static final String FILESIZE = "filesize"; |
| 3966 | } |
| 3967 | |
| 3968 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3969 | * Columns in the Data table. |
| 3970 | * |
| 3971 | * @see ContactsContract.Data |
| 3972 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 3973 | protected interface DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3974 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 3975 | * The package name to use when creating {@link Resources} objects for |
| 3976 | * this data row. This value is only designed for use when building user |
| 3977 | * interfaces, and should not be used to infer the owner. |
| 3978 | */ |
| 3979 | public static final String RES_PACKAGE = "res_package"; |
| 3980 | |
| 3981 | /** |
| 3982 | * The MIME type of the item represented by this row. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3983 | */ |
| 3984 | public static final String MIMETYPE = "mimetype"; |
| 3985 | |
| 3986 | /** |
Zheng Fu | 9ea9a13 | 2015-01-07 11:33:19 -0800 | [diff] [blame] | 3987 | * Hash id on the data fields, used for backup and restore. |
| 3988 | * |
| 3989 | * @hide |
| 3990 | */ |
| 3991 | public static final String HASH_ID = "hash_id"; |
| 3992 | |
| 3993 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 3994 | * A reference to the {@link RawContacts#_ID} |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 3995 | * that this data belongs to. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3996 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 3997 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 3998 | |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 3999 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4000 | * Whether this is the primary entry of its kind for the raw contact it belongs to. |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 4001 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 4002 | */ |
| 4003 | public static final String IS_PRIMARY = "is_primary"; |
| 4004 | |
| 4005 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 4006 | * Whether this is the primary entry of its kind for the aggregate |
| 4007 | * contact it belongs to. Any data record that is "super primary" must |
| 4008 | * also be "primary". |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 4009 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 4010 | */ |
| 4011 | public static final String IS_SUPER_PRIMARY = "is_super_primary"; |
| 4012 | |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 4013 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 4014 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 4015 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 4016 | * <P>Type: INTEGER</P> |
| 4017 | */ |
| 4018 | public static final String IS_READ_ONLY = "is_read_only"; |
| 4019 | |
| 4020 | /** |
Fred Quintana | c933fb6 | 2009-06-11 12:14:40 -0700 | [diff] [blame] | 4021 | * The version of this data record. This is a read-only value. The data column is |
| 4022 | * guaranteed to not change without the version going up. This value is monotonically |
| 4023 | * increasing. |
| 4024 | * <P>Type: INTEGER</P> |
| 4025 | */ |
| 4026 | public static final String DATA_VERSION = "data_version"; |
| 4027 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4028 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4029 | public static final String DATA1 = "data1"; |
| 4030 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4031 | public static final String DATA2 = "data2"; |
| 4032 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4033 | public static final String DATA3 = "data3"; |
| 4034 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4035 | public static final String DATA4 = "data4"; |
| 4036 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4037 | public static final String DATA5 = "data5"; |
| 4038 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4039 | public static final String DATA6 = "data6"; |
| 4040 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4041 | public static final String DATA7 = "data7"; |
| 4042 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4043 | public static final String DATA8 = "data8"; |
| 4044 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4045 | public static final String DATA9 = "data9"; |
| 4046 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4047 | public static final String DATA10 = "data10"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4048 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4049 | public static final String DATA11 = "data11"; |
| 4050 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4051 | public static final String DATA12 = "data12"; |
| 4052 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4053 | public static final String DATA13 = "data13"; |
| 4054 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4055 | public static final String DATA14 = "data14"; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4056 | /** |
| 4057 | * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention, |
| 4058 | * this field is used to store BLOBs (binary data). |
| 4059 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4060 | public static final String DATA15 = "data15"; |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 4061 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 4062 | /** Generic column for use by sync adapters. */ |
| 4063 | public static final String SYNC1 = "data_sync1"; |
| 4064 | /** Generic column for use by sync adapters. */ |
| 4065 | public static final String SYNC2 = "data_sync2"; |
| 4066 | /** Generic column for use by sync adapters. */ |
| 4067 | public static final String SYNC3 = "data_sync3"; |
| 4068 | /** Generic column for use by sync adapters. */ |
| 4069 | public static final String SYNC4 = "data_sync4"; |
Etan Cohen | 534a65d | 2015-05-01 11:03:24 -0700 | [diff] [blame^] | 4070 | |
| 4071 | /** |
| 4072 | * Carrier presence information. |
| 4073 | * <P> |
| 4074 | * Type: INTEGER (A bitmask of CARRIER_PRESENCE_* fields) |
| 4075 | * </P> |
| 4076 | */ |
| 4077 | public static final String CARRIER_PRESENCE = "carrier_presence"; |
| 4078 | |
| 4079 | /** |
| 4080 | * Bitmask flags for CARRIER_PRESENCE column. Each value represents |
| 4081 | * a bit (or a set of bits) which may be set independently of each |
| 4082 | * other. |
| 4083 | */ |
| 4084 | public static final int CARRIER_PRESENCE_VT_CAPABLE = 0x01; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4085 | } |
| 4086 | |
| 4087 | /** |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4088 | * Columns in the Data_Usage_Stat table |
| 4089 | */ |
| 4090 | protected interface DataUsageStatColumns { |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4091 | /** The last time (in milliseconds) this {@link Data} was used. */ |
| 4092 | public static final String LAST_TIME_USED = "last_time_used"; |
| 4093 | |
Yorke Lee | 5a53d70 | 2013-03-29 18:08:47 -0700 | [diff] [blame] | 4094 | /** The number of times the referenced {@link Data} has been used. */ |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4095 | public static final String TIMES_USED = "times_used"; |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4096 | } |
| 4097 | |
| 4098 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4099 | * Combines all columns returned by {@link ContactsContract.Data} table queries. |
| 4100 | * |
| 4101 | * @see ContactsContract.Data |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4102 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 4103 | protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns, |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 4104 | RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns, |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4105 | ContactStatusColumns, DataUsageStatColumns { |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4106 | } |
| 4107 | |
| 4108 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4109 | * <p> |
| 4110 | * Constants for the data table, which contains data points tied to a raw |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4111 | * contact. Each row of the data table is typically used to store a single |
| 4112 | * piece of contact |
| 4113 | * information (such as a phone number) and its |
| 4114 | * associated metadata (such as whether it is a work or home number). |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4115 | * </p> |
| 4116 | * <h3>Data kinds</h3> |
| 4117 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4118 | * Data is a generic table that can hold any kind of contact data. |
| 4119 | * The kind of data stored in a given row is specified by the row's |
| 4120 | * {@link #MIMETYPE} value, which determines the meaning of the |
| 4121 | * generic columns {@link #DATA1} through |
| 4122 | * {@link #DATA15}. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4123 | * For example, if the data kind is |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4124 | * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column |
| 4125 | * {@link #DATA1} stores the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4126 | * phone number, but if the data kind is |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4127 | * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1} |
| 4128 | * stores the email address. |
| 4129 | * Sync adapters and applications can introduce their own data kinds. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4130 | * </p> |
| 4131 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4132 | * ContactsContract defines a small number of pre-defined data kinds, e.g. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4133 | * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a |
| 4134 | * convenience, these classes define data kind specific aliases for DATA1 etc. |
| 4135 | * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as |
| 4136 | * {@link ContactsContract.Data Data.DATA1}. |
| 4137 | * </p> |
| 4138 | * <p> |
| 4139 | * {@link #DATA1} is an indexed column and should be used for the data element that is |
| 4140 | * expected to be most frequently used in query selections. For example, in the |
| 4141 | * case of a row representing email addresses {@link #DATA1} should probably |
| 4142 | * be used for the email address itself, while {@link #DATA2} etc can be |
| 4143 | * used for auxiliary information like type of email address. |
| 4144 | * <p> |
| 4145 | * <p> |
| 4146 | * By convention, {@link #DATA15} is used for storing BLOBs (binary data). |
| 4147 | * </p> |
| 4148 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 4149 | * The sync adapter for a given account type must correctly handle every data type |
| 4150 | * used in the corresponding raw contacts. Otherwise it could result in lost or |
| 4151 | * corrupted data. |
| 4152 | * </p> |
| 4153 | * <p> |
| 4154 | * Similarly, you should refrain from introducing new kinds of data for an other |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4155 | * party's account types. For example, if you add a data row for |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4156 | * "favorite song" to a raw contact owned by a Google account, it will not |
| 4157 | * get synced to the server, because the Google sync adapter does not know |
| 4158 | * how to handle this data kind. Thus new data kinds are typically |
| 4159 | * introduced along with new account types, i.e. new sync adapters. |
| 4160 | * </p> |
| 4161 | * <h3>Batch operations</h3> |
| 4162 | * <p> |
| 4163 | * Data rows can be inserted/updated/deleted using the traditional |
| 4164 | * {@link ContentResolver#insert}, {@link ContentResolver#update} and |
| 4165 | * {@link ContentResolver#delete} methods, however the newer mechanism based |
| 4166 | * on a batch of {@link ContentProviderOperation} will prove to be a better |
| 4167 | * choice in almost all cases. All operations in a batch are executed in a |
| 4168 | * single transaction, which ensures that the phone-side and server-side |
| 4169 | * state of a raw contact are always consistent. Also, the batch-based |
| 4170 | * approach is far more efficient: not only are the database operations |
| 4171 | * faster when executed in a single transaction, but also sending a batch of |
| 4172 | * commands to the content provider saves a lot of time on context switching |
| 4173 | * between your process and the process in which the content provider runs. |
| 4174 | * </p> |
| 4175 | * <p> |
| 4176 | * The flip side of using batched operations is that a large batch may lock |
| 4177 | * up the database for a long time preventing other applications from |
| 4178 | * accessing data and potentially causing ANRs ("Application Not Responding" |
| 4179 | * dialogs.) |
| 4180 | * </p> |
| 4181 | * <p> |
| 4182 | * To avoid such lockups of the database, make sure to insert "yield points" |
| 4183 | * in the batch. A yield point indicates to the content provider that before |
| 4184 | * executing the next operation it can commit the changes that have already |
| 4185 | * been made, yield to other requests, open another transaction and continue |
| 4186 | * processing operations. A yield point will not automatically commit the |
| 4187 | * transaction, but only if there is another request waiting on the |
| 4188 | * database. Normally a sync adapter should insert a yield point at the |
| 4189 | * beginning of each raw contact operation sequence in the batch. See |
| 4190 | * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}. |
| 4191 | * </p> |
| 4192 | * <h3>Operations</h3> |
| 4193 | * <dl> |
| 4194 | * <dt><b>Insert</b></dt> |
| 4195 | * <dd> |
| 4196 | * <p> |
| 4197 | * An individual data row can be inserted using the traditional |
| 4198 | * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows |
| 4199 | * should always be inserted as a batch. |
| 4200 | * </p> |
| 4201 | * <p> |
| 4202 | * An example of a traditional insert: |
| 4203 | * <pre> |
| 4204 | * ContentValues values = new ContentValues(); |
| 4205 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 4206 | * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); |
| 4207 | * values.put(Phone.NUMBER, "1-800-GOOG-411"); |
| 4208 | * values.put(Phone.TYPE, Phone.TYPE_CUSTOM); |
| 4209 | * values.put(Phone.LABEL, "free directory assistance"); |
| 4210 | * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values); |
| 4211 | * </pre> |
| 4212 | * <p> |
| 4213 | * The same done using ContentProviderOperations: |
| 4214 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4215 | * ArrayList<ContentProviderOperation> ops = |
| 4216 | * new ArrayList<ContentProviderOperation>(); |
| 4217 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4218 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 4219 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 4220 | * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE) |
| 4221 | * .withValue(Phone.NUMBER, "1-800-GOOG-411") |
| 4222 | * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM) |
| 4223 | * .withValue(Phone.LABEL, "free directory assistance") |
| 4224 | * .build()); |
| 4225 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4226 | * </pre> |
| 4227 | * </p> |
| 4228 | * <dt><b>Update</b></dt> |
| 4229 | * <dd> |
| 4230 | * <p> |
| 4231 | * Just as with insert, update can be done incrementally or as a batch, |
| 4232 | * the batch mode being the preferred method: |
| 4233 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4234 | * ArrayList<ContentProviderOperation> ops = |
| 4235 | * new ArrayList<ContentProviderOperation>(); |
| 4236 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4237 | * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI) |
| 4238 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 4239 | * .withValue(Email.DATA, "somebody@android.com") |
| 4240 | * .build()); |
| 4241 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4242 | * </pre> |
| 4243 | * </p> |
| 4244 | * </dd> |
| 4245 | * <dt><b>Delete</b></dt> |
| 4246 | * <dd> |
| 4247 | * <p> |
| 4248 | * Just as with insert and update, deletion can be done either using the |
| 4249 | * {@link ContentResolver#delete} method or using a ContentProviderOperation: |
| 4250 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4251 | * ArrayList<ContentProviderOperation> ops = |
| 4252 | * new ArrayList<ContentProviderOperation>(); |
| 4253 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4254 | * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI) |
| 4255 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 4256 | * .build()); |
| 4257 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4258 | * </pre> |
| 4259 | * </p> |
| 4260 | * </dd> |
| 4261 | * <dt><b>Query</b></dt> |
| 4262 | * <dd> |
| 4263 | * <p> |
| 4264 | * <dl> |
| 4265 | * <dt>Finding all Data of a given type for a given contact</dt> |
| 4266 | * <dd> |
| 4267 | * <pre> |
| 4268 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 4269 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 4270 | * Data.CONTACT_ID + "=?" + " AND " |
| 4271 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 4272 | * new String[] {String.valueOf(contactId)}, null); |
| 4273 | * </pre> |
| 4274 | * </p> |
| 4275 | * <p> |
| 4276 | * </dd> |
| 4277 | * <dt>Finding all Data of a given type for a given raw contact</dt> |
| 4278 | * <dd> |
| 4279 | * <pre> |
| 4280 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 4281 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 4282 | * Data.RAW_CONTACT_ID + "=?" + " AND " |
| 4283 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 4284 | * new String[] {String.valueOf(rawContactId)}, null); |
| 4285 | * </pre> |
| 4286 | * </dd> |
| 4287 | * <dt>Finding all Data for a given raw contact</dt> |
| 4288 | * <dd> |
| 4289 | * Most sync adapters will want to read all data rows for a raw contact |
| 4290 | * along with the raw contact itself. For that you should use the |
| 4291 | * {@link RawContactsEntity}. See also {@link RawContacts}. |
| 4292 | * </dd> |
| 4293 | * </dl> |
| 4294 | * </p> |
| 4295 | * </dd> |
| 4296 | * </dl> |
| 4297 | * <h2>Columns</h2> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4298 | * <p> |
| 4299 | * Many columns are available via a {@link Data#CONTENT_URI} query. For best performance you |
| 4300 | * should explicitly specify a projection to only those columns that you need. |
| 4301 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4302 | * <table class="jd-sumtable"> |
| 4303 | * <tr> |
| 4304 | * <th colspan='4'>Data</th> |
| 4305 | * </tr> |
| 4306 | * <tr> |
| 4307 | * <td style="width: 7em;">long</td> |
| 4308 | * <td style="width: 20em;">{@link #_ID}</td> |
| 4309 | * <td style="width: 5em;">read-only</td> |
| 4310 | * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words, |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4311 | * it would be a bad idea to delete and reinsert a data row. A sync adapter should |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4312 | * always do an update instead.</td> |
| 4313 | * </tr> |
| 4314 | * <tr> |
| 4315 | * <td>String</td> |
| 4316 | * <td>{@link #MIMETYPE}</td> |
| 4317 | * <td>read/write-once</td> |
| 4318 | * <td> |
| 4319 | * <p>The MIME type of the item represented by this row. Examples of common |
| 4320 | * MIME types are: |
| 4321 | * <ul> |
| 4322 | * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li> |
| 4323 | * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li> |
| 4324 | * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li> |
| 4325 | * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li> |
| 4326 | * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li> |
| 4327 | * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li> |
| 4328 | * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li> |
| 4329 | * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li> |
| 4330 | * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li> |
| 4331 | * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li> |
| 4332 | * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li> |
| 4333 | * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li> |
| 4334 | * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 4335 | * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4336 | * </ul> |
| 4337 | * </p> |
| 4338 | * </td> |
| 4339 | * </tr> |
| 4340 | * <tr> |
| 4341 | * <td>long</td> |
| 4342 | * <td>{@link #RAW_CONTACT_ID}</td> |
| 4343 | * <td>read/write-once</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4344 | * <td>The id of the row in the {@link RawContacts} table that this data belongs to.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4345 | * </tr> |
| 4346 | * <tr> |
| 4347 | * <td>int</td> |
| 4348 | * <td>{@link #IS_PRIMARY}</td> |
| 4349 | * <td>read/write</td> |
| 4350 | * <td>Whether this is the primary entry of its kind for the raw contact it belongs to. |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4351 | * "1" if true, "0" if false. |
| 4352 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4353 | * </tr> |
| 4354 | * <tr> |
| 4355 | * <td>int</td> |
| 4356 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 4357 | * <td>read/write</td> |
| 4358 | * <td>Whether this is the primary entry of its kind for the aggregate |
| 4359 | * contact it belongs to. Any data record that is "super primary" must |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4360 | * also be "primary". For example, the super-primary entry may be |
| 4361 | * interpreted as the default contact value of its kind (for example, |
| 4362 | * the default phone number to use for the contact).</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4363 | * </tr> |
| 4364 | * <tr> |
| 4365 | * <td>int</td> |
| 4366 | * <td>{@link #DATA_VERSION}</td> |
| 4367 | * <td>read-only</td> |
| 4368 | * <td>The version of this data record. Whenever the data row changes |
| 4369 | * the version goes up. This value is monotonically increasing.</td> |
| 4370 | * </tr> |
| 4371 | * <tr> |
| 4372 | * <td>Any type</td> |
| 4373 | * <td> |
| 4374 | * {@link #DATA1}<br> |
| 4375 | * {@link #DATA2}<br> |
| 4376 | * {@link #DATA3}<br> |
| 4377 | * {@link #DATA4}<br> |
| 4378 | * {@link #DATA5}<br> |
| 4379 | * {@link #DATA6}<br> |
| 4380 | * {@link #DATA7}<br> |
| 4381 | * {@link #DATA8}<br> |
| 4382 | * {@link #DATA9}<br> |
| 4383 | * {@link #DATA10}<br> |
| 4384 | * {@link #DATA11}<br> |
| 4385 | * {@link #DATA12}<br> |
| 4386 | * {@link #DATA13}<br> |
| 4387 | * {@link #DATA14}<br> |
| 4388 | * {@link #DATA15} |
| 4389 | * </td> |
| 4390 | * <td>read/write</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4391 | * <td> |
| 4392 | * <p> |
| 4393 | * Generic data columns. The meaning of each column is determined by the |
| 4394 | * {@link #MIMETYPE}. By convention, {@link #DATA15} is used for storing |
| 4395 | * BLOBs (binary data). |
| 4396 | * </p> |
| 4397 | * <p> |
| 4398 | * Data columns whose meaning is not explicitly defined for a given MIMETYPE |
| 4399 | * should not be used. There is no guarantee that any sync adapter will |
| 4400 | * preserve them. Sync adapters themselves should not use such columns either, |
| 4401 | * but should instead use {@link #SYNC1}-{@link #SYNC4}. |
| 4402 | * </p> |
| 4403 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4404 | * </tr> |
| 4405 | * <tr> |
| 4406 | * <td>Any type</td> |
| 4407 | * <td> |
| 4408 | * {@link #SYNC1}<br> |
| 4409 | * {@link #SYNC2}<br> |
| 4410 | * {@link #SYNC3}<br> |
| 4411 | * {@link #SYNC4} |
| 4412 | * </td> |
| 4413 | * <td>read/write</td> |
| 4414 | * <td>Generic columns for use by sync adapters. For example, a Photo row |
| 4415 | * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error) |
| 4416 | * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td> |
| 4417 | * </tr> |
| 4418 | * </table> |
| 4419 | * |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4420 | * <p> |
| 4421 | * Some columns from the most recent associated status update are also available |
| 4422 | * through an implicit join. |
| 4423 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4424 | * <table class="jd-sumtable"> |
| 4425 | * <tr> |
| 4426 | * <th colspan='4'>Join with {@link StatusUpdates}</th> |
| 4427 | * </tr> |
| 4428 | * <tr> |
| 4429 | * <td style="width: 7em;">int</td> |
| 4430 | * <td style="width: 20em;">{@link #PRESENCE}</td> |
| 4431 | * <td style="width: 5em;">read-only</td> |
| 4432 | * <td>IM presence status linked to this data row. Compare with |
| 4433 | * {@link #CONTACT_PRESENCE}, which contains the contact's presence across |
| 4434 | * all IM rows. See {@link StatusUpdates} for individual status definitions. |
| 4435 | * The provider may choose not to store this value |
| 4436 | * in persistent storage. The expectation is that presence status will be |
kmccormick | 50e27c8 | 2013-03-28 16:33:11 -0700 | [diff] [blame] | 4437 | * updated on a regular basis. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4438 | * </td> |
| 4439 | * </tr> |
| 4440 | * <tr> |
| 4441 | * <td>String</td> |
| 4442 | * <td>{@link #STATUS}</td> |
| 4443 | * <td>read-only</td> |
| 4444 | * <td>Latest status update linked with this data row.</td> |
| 4445 | * </tr> |
| 4446 | * <tr> |
| 4447 | * <td>long</td> |
| 4448 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 4449 | * <td>read-only</td> |
| 4450 | * <td>The absolute time in milliseconds when the latest status was |
| 4451 | * inserted/updated for this data row.</td> |
| 4452 | * </tr> |
| 4453 | * <tr> |
| 4454 | * <td>String</td> |
| 4455 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 4456 | * <td>read-only</td> |
| 4457 | * <td>The package containing resources for this status: label and icon.</td> |
| 4458 | * </tr> |
| 4459 | * <tr> |
| 4460 | * <td>long</td> |
| 4461 | * <td>{@link #STATUS_LABEL}</td> |
| 4462 | * <td>read-only</td> |
| 4463 | * <td>The resource ID of the label describing the source of status update linked |
| 4464 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4465 | * </tr> |
| 4466 | * <tr> |
| 4467 | * <td>long</td> |
| 4468 | * <td>{@link #STATUS_ICON}</td> |
| 4469 | * <td>read-only</td> |
| 4470 | * <td>The resource ID of the icon for the source of the status update linked |
| 4471 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4472 | * </tr> |
| 4473 | * </table> |
| 4474 | * |
| 4475 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4476 | * Some columns from the associated raw contact are also available through an |
| 4477 | * implicit join. The other columns are excluded as uninteresting in this |
| 4478 | * context. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4479 | * </p> |
| 4480 | * |
| 4481 | * <table class="jd-sumtable"> |
| 4482 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4483 | * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4484 | * </tr> |
| 4485 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4486 | * <td style="width: 7em;">long</td> |
| 4487 | * <td style="width: 20em;">{@link #CONTACT_ID}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4488 | * <td style="width: 5em;">read-only</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4489 | * <td>The id of the row in the {@link Contacts} table that this data belongs |
| 4490 | * to.</td> |
| 4491 | * </tr> |
| 4492 | * <tr> |
| 4493 | * <td>int</td> |
| 4494 | * <td>{@link #AGGREGATION_MODE}</td> |
| 4495 | * <td>read-only</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4496 | * <td>See {@link RawContacts}.</td> |
| 4497 | * </tr> |
| 4498 | * <tr> |
| 4499 | * <td>int</td> |
| 4500 | * <td>{@link #DELETED}</td> |
| 4501 | * <td>read-only</td> |
| 4502 | * <td>See {@link RawContacts}.</td> |
| 4503 | * </tr> |
| 4504 | * </table> |
| 4505 | * |
| 4506 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4507 | * The ID column for the associated aggregated contact table |
| 4508 | * {@link ContactsContract.Contacts} is available |
| 4509 | * via the implicit join to the {@link RawContacts} table, see above. |
| 4510 | * The remaining columns from this table are also |
| 4511 | * available, through an implicit join. This |
| 4512 | * facilitates lookup by |
| 4513 | * the value of a single data element, such as the email address. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4514 | * </p> |
| 4515 | * |
| 4516 | * <table class="jd-sumtable"> |
| 4517 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4518 | * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4519 | * </tr> |
| 4520 | * <tr> |
| 4521 | * <td style="width: 7em;">String</td> |
| 4522 | * <td style="width: 20em;">{@link #LOOKUP_KEY}</td> |
| 4523 | * <td style="width: 5em;">read-only</td> |
| 4524 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4525 | * </tr> |
| 4526 | * <tr> |
| 4527 | * <td>String</td> |
| 4528 | * <td>{@link #DISPLAY_NAME}</td> |
| 4529 | * <td>read-only</td> |
| 4530 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4531 | * </tr> |
| 4532 | * <tr> |
| 4533 | * <td>long</td> |
| 4534 | * <td>{@link #PHOTO_ID}</td> |
| 4535 | * <td>read-only</td> |
| 4536 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4537 | * </tr> |
| 4538 | * <tr> |
| 4539 | * <td>int</td> |
| 4540 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 4541 | * <td>read-only</td> |
| 4542 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4543 | * </tr> |
| 4544 | * <tr> |
| 4545 | * <td>int</td> |
| 4546 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 4547 | * <td>read-only</td> |
| 4548 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4549 | * </tr> |
| 4550 | * <tr> |
| 4551 | * <td>int</td> |
| 4552 | * <td>{@link #TIMES_CONTACTED}</td> |
| 4553 | * <td>read-only</td> |
| 4554 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4555 | * </tr> |
| 4556 | * <tr> |
| 4557 | * <td>long</td> |
| 4558 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 4559 | * <td>read-only</td> |
| 4560 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4561 | * </tr> |
| 4562 | * <tr> |
| 4563 | * <td>int</td> |
| 4564 | * <td>{@link #STARRED}</td> |
| 4565 | * <td>read-only</td> |
| 4566 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4567 | * </tr> |
| 4568 | * <tr> |
| 4569 | * <td>String</td> |
| 4570 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 4571 | * <td>read-only</td> |
| 4572 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4573 | * </tr> |
| 4574 | * <tr> |
| 4575 | * <td>int</td> |
| 4576 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 4577 | * <td>read-only</td> |
| 4578 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4579 | * </tr> |
| 4580 | * <tr> |
| 4581 | * <td>int</td> |
| 4582 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 4583 | * <td>read-only</td> |
| 4584 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4585 | * </tr> |
| 4586 | * <tr> |
| 4587 | * <td>String</td> |
| 4588 | * <td>{@link #CONTACT_STATUS}</td> |
| 4589 | * <td>read-only</td> |
| 4590 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4591 | * </tr> |
| 4592 | * <tr> |
| 4593 | * <td>long</td> |
| 4594 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 4595 | * <td>read-only</td> |
| 4596 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4597 | * </tr> |
| 4598 | * <tr> |
| 4599 | * <td>String</td> |
| 4600 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 4601 | * <td>read-only</td> |
| 4602 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4603 | * </tr> |
| 4604 | * <tr> |
| 4605 | * <td>long</td> |
| 4606 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 4607 | * <td>read-only</td> |
| 4608 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4609 | * </tr> |
| 4610 | * <tr> |
| 4611 | * <td>long</td> |
| 4612 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 4613 | * <td>read-only</td> |
| 4614 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4615 | * </tr> |
| 4616 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4617 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 4618 | public final static class Data implements DataColumnsWithJoins, ContactCounts { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4619 | /** |
| 4620 | * This utility class cannot be instantiated |
| 4621 | */ |
| 4622 | private Data() {} |
| 4623 | |
| 4624 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4625 | * The content:// style URI for this table, which requests a directory |
| 4626 | * of data rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4627 | */ |
| 4628 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); |
| 4629 | |
| 4630 | /** |
Ricky Wai | fa5bbaf | 2015-02-26 16:51:32 +0000 | [diff] [blame] | 4631 | * The content:// style URI for this table in managed profile, which requests a directory |
| 4632 | * of data rows matching the selection criteria. |
| 4633 | * |
| 4634 | * @hide |
| 4635 | */ |
| 4636 | static final Uri ENTERPRISE_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 4637 | "data_enterprise"); |
| 4638 | |
| 4639 | /** |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 4640 | * A boolean parameter for {@link Data#CONTENT_URI}. |
| 4641 | * This specifies whether or not the returned data items should be filtered to show |
| 4642 | * data items belonging to visible contacts only. |
| 4643 | */ |
| 4644 | public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; |
| 4645 | |
| 4646 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4647 | * The MIME type of the results from {@link #CONTENT_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4648 | */ |
| 4649 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 4650 | |
| 4651 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4652 | * <p> |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4653 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 4654 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4655 | * entry of the given {@link ContactsContract.Data} entry. |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4656 | * </p> |
| 4657 | * <p> |
| 4658 | * Returns the Uri for the contact in the first entry returned by |
| 4659 | * {@link ContentResolver#query(Uri, String[], String, String[], String)} |
| 4660 | * for the provided {@code dataUri}. If the query returns null or empty |
| 4661 | * results, silently returns null. |
| 4662 | * </p> |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 4663 | */ |
| 4664 | public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) { |
| 4665 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 4666 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 4667 | }, null, null, null); |
| 4668 | |
| 4669 | Uri lookupUri = null; |
| 4670 | try { |
| 4671 | if (cursor != null && cursor.moveToFirst()) { |
| 4672 | final long contactId = cursor.getLong(0); |
| 4673 | final String lookupKey = cursor.getString(1); |
| 4674 | return Contacts.getLookupUri(contactId, lookupKey); |
| 4675 | } |
| 4676 | } finally { |
| 4677 | if (cursor != null) cursor.close(); |
| 4678 | } |
| 4679 | return lookupUri; |
| 4680 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4681 | } |
| 4682 | |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 4683 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4684 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4685 | * Constants for the raw contacts entities table, which can be thought of as |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4686 | * an outer join of the raw_contacts table with the data table. It is a strictly |
| 4687 | * read-only table. |
| 4688 | * </p> |
| 4689 | * <p> |
| 4690 | * If a raw contact has data rows, the RawContactsEntity cursor will contain |
| 4691 | * a one row for each data row. If the raw contact has no data rows, the |
| 4692 | * cursor will still contain one row with the raw contact-level information |
| 4693 | * and nulls for data columns. |
| 4694 | * |
| 4695 | * <pre> |
| 4696 | * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId); |
| 4697 | * Cursor c = getContentResolver().query(entityUri, |
| 4698 | * new String[]{ |
| 4699 | * RawContactsEntity.SOURCE_ID, |
| 4700 | * RawContactsEntity.DATA_ID, |
| 4701 | * RawContactsEntity.MIMETYPE, |
| 4702 | * RawContactsEntity.DATA1 |
| 4703 | * }, null, null, null); |
| 4704 | * try { |
| 4705 | * while (c.moveToNext()) { |
| 4706 | * String sourceId = c.getString(0); |
| 4707 | * if (!c.isNull(1)) { |
| 4708 | * String mimeType = c.getString(2); |
| 4709 | * String data = c.getString(3); |
| 4710 | * ... |
| 4711 | * } |
| 4712 | * } |
| 4713 | * } finally { |
| 4714 | * c.close(); |
| 4715 | * } |
| 4716 | * </pre> |
| 4717 | * |
| 4718 | * <h3>Columns</h3> |
| 4719 | * RawContactsEntity has a combination of RawContact and Data columns. |
| 4720 | * |
| 4721 | * <table class="jd-sumtable"> |
| 4722 | * <tr> |
| 4723 | * <th colspan='4'>RawContacts</th> |
| 4724 | * </tr> |
| 4725 | * <tr> |
| 4726 | * <td style="width: 7em;">long</td> |
| 4727 | * <td style="width: 20em;">{@link #_ID}</td> |
| 4728 | * <td style="width: 5em;">read-only</td> |
| 4729 | * <td>Raw contact row ID. See {@link RawContacts}.</td> |
| 4730 | * </tr> |
| 4731 | * <tr> |
| 4732 | * <td>long</td> |
| 4733 | * <td>{@link #CONTACT_ID}</td> |
| 4734 | * <td>read-only</td> |
| 4735 | * <td>See {@link RawContacts}.</td> |
| 4736 | * </tr> |
| 4737 | * <tr> |
| 4738 | * <td>int</td> |
| 4739 | * <td>{@link #AGGREGATION_MODE}</td> |
| 4740 | * <td>read-only</td> |
| 4741 | * <td>See {@link RawContacts}.</td> |
| 4742 | * </tr> |
| 4743 | * <tr> |
| 4744 | * <td>int</td> |
| 4745 | * <td>{@link #DELETED}</td> |
| 4746 | * <td>read-only</td> |
| 4747 | * <td>See {@link RawContacts}.</td> |
| 4748 | * </tr> |
| 4749 | * </table> |
| 4750 | * |
| 4751 | * <table class="jd-sumtable"> |
| 4752 | * <tr> |
| 4753 | * <th colspan='4'>Data</th> |
| 4754 | * </tr> |
| 4755 | * <tr> |
| 4756 | * <td style="width: 7em;">long</td> |
| 4757 | * <td style="width: 20em;">{@link #DATA_ID}</td> |
| 4758 | * <td style="width: 5em;">read-only</td> |
| 4759 | * <td>Data row ID. It will be null if the raw contact has no data rows.</td> |
| 4760 | * </tr> |
| 4761 | * <tr> |
| 4762 | * <td>String</td> |
| 4763 | * <td>{@link #MIMETYPE}</td> |
| 4764 | * <td>read-only</td> |
| 4765 | * <td>See {@link ContactsContract.Data}.</td> |
| 4766 | * </tr> |
| 4767 | * <tr> |
| 4768 | * <td>int</td> |
| 4769 | * <td>{@link #IS_PRIMARY}</td> |
| 4770 | * <td>read-only</td> |
| 4771 | * <td>See {@link ContactsContract.Data}.</td> |
| 4772 | * </tr> |
| 4773 | * <tr> |
| 4774 | * <td>int</td> |
| 4775 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 4776 | * <td>read-only</td> |
| 4777 | * <td>See {@link ContactsContract.Data}.</td> |
| 4778 | * </tr> |
| 4779 | * <tr> |
| 4780 | * <td>int</td> |
| 4781 | * <td>{@link #DATA_VERSION}</td> |
| 4782 | * <td>read-only</td> |
| 4783 | * <td>See {@link ContactsContract.Data}.</td> |
| 4784 | * </tr> |
| 4785 | * <tr> |
| 4786 | * <td>Any type</td> |
| 4787 | * <td> |
| 4788 | * {@link #DATA1}<br> |
| 4789 | * {@link #DATA2}<br> |
| 4790 | * {@link #DATA3}<br> |
| 4791 | * {@link #DATA4}<br> |
| 4792 | * {@link #DATA5}<br> |
| 4793 | * {@link #DATA6}<br> |
| 4794 | * {@link #DATA7}<br> |
| 4795 | * {@link #DATA8}<br> |
| 4796 | * {@link #DATA9}<br> |
| 4797 | * {@link #DATA10}<br> |
| 4798 | * {@link #DATA11}<br> |
| 4799 | * {@link #DATA12}<br> |
| 4800 | * {@link #DATA13}<br> |
| 4801 | * {@link #DATA14}<br> |
| 4802 | * {@link #DATA15} |
| 4803 | * </td> |
| 4804 | * <td>read-only</td> |
| 4805 | * <td>See {@link ContactsContract.Data}.</td> |
| 4806 | * </tr> |
| 4807 | * <tr> |
| 4808 | * <td>Any type</td> |
| 4809 | * <td> |
| 4810 | * {@link #SYNC1}<br> |
| 4811 | * {@link #SYNC2}<br> |
| 4812 | * {@link #SYNC3}<br> |
| 4813 | * {@link #SYNC4} |
| 4814 | * </td> |
| 4815 | * <td>read-only</td> |
| 4816 | * <td>See {@link ContactsContract.Data}.</td> |
| 4817 | * </tr> |
| 4818 | * </table> |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 4819 | */ |
| 4820 | public final static class RawContactsEntity |
| 4821 | implements BaseColumns, DataColumns, RawContactsColumns { |
| 4822 | /** |
| 4823 | * This utility class cannot be instantiated |
| 4824 | */ |
| 4825 | private RawContactsEntity() {} |
| 4826 | |
| 4827 | /** |
| 4828 | * The content:// style URI for this table |
| 4829 | */ |
| 4830 | public static final Uri CONTENT_URI = |
| 4831 | Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities"); |
| 4832 | |
| 4833 | /** |
Ricky Wai | 9aaaa1e | 2015-03-08 00:53:20 +0000 | [diff] [blame] | 4834 | * The content:// style URI for this table in corp profile |
| 4835 | * |
| 4836 | * @hide |
| 4837 | */ |
| 4838 | public static final Uri CORP_CONTENT_URI = |
| 4839 | Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities_corp"); |
| 4840 | |
| 4841 | /** |
Dave Santoro | 2b4d075 | 2011-09-07 17:37:33 -0700 | [diff] [blame] | 4842 | * The content:// style URI for this table, specific to the user's profile. |
| 4843 | */ |
| 4844 | public static final Uri PROFILE_CONTENT_URI = |
| 4845 | Uri.withAppendedPath(Profile.CONTENT_URI, "raw_contact_entities"); |
| 4846 | |
| 4847 | /** |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 4848 | * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities. |
| 4849 | */ |
| 4850 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity"; |
| 4851 | |
| 4852 | /** |
| 4853 | * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward |
| 4854 | * Data.CONTENT_URI contains only exportable data. |
| 4855 | * |
| 4856 | * This flag is useful (currently) only for vCard exporter in Contacts app, which |
| 4857 | * needs to exclude "un-exportable" data from available data to export, while |
| 4858 | * Contacts app itself has priviledge to access all data including "un-expotable" |
| 4859 | * ones and providers return all of them regardless of the callers' intention. |
| 4860 | * <P>Type: INTEGER</p> |
| 4861 | * |
| 4862 | * @hide Maybe available only in Eclair and not really ready for public use. |
| 4863 | * TODO: remove, or implement this feature completely. As of now (Eclair), |
| 4864 | * we only use this flag in queryEntities(), not query(). |
| 4865 | */ |
| 4866 | public static final String FOR_EXPORT_ONLY = "for_export_only"; |
| 4867 | |
| 4868 | /** |
| 4869 | * The ID of the data column. The value will be null if this raw contact has no data rows. |
| 4870 | * <P>Type: INTEGER</P> |
| 4871 | */ |
| 4872 | public static final String DATA_ID = "data_id"; |
| 4873 | } |
| 4874 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4875 | /** |
| 4876 | * @see PhoneLookup |
| 4877 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 4878 | protected interface PhoneLookupColumns { |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4879 | /** |
| 4880 | * The phone number as the user entered it. |
| 4881 | * <P>Type: TEXT</P> |
| 4882 | */ |
| 4883 | public static final String NUMBER = "number"; |
| 4884 | |
| 4885 | /** |
| 4886 | * The type of phone number, for example Home or Work. |
| 4887 | * <P>Type: INTEGER</P> |
| 4888 | */ |
| 4889 | public static final String TYPE = "type"; |
| 4890 | |
| 4891 | /** |
| 4892 | * The user defined label for the phone number. |
| 4893 | * <P>Type: TEXT</P> |
| 4894 | */ |
| 4895 | public static final String LABEL = "label"; |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 4896 | |
| 4897 | /** |
| 4898 | * The phone number's E164 representation. |
| 4899 | * <P>Type: TEXT</P> |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 4900 | */ |
| 4901 | public static final String NORMALIZED_NUMBER = "normalized_number"; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4902 | } |
| 4903 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4904 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4905 | * A table that represents the result of looking up a phone number, for |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4906 | * example for caller ID. To perform a lookup you must append the number you |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4907 | * want to find to {@link #CONTENT_FILTER_URI}. This query is highly |
| 4908 | * optimized. |
| 4909 | * <pre> |
| 4910 | * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); |
| 4911 | * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,... |
| 4912 | * </pre> |
| 4913 | * |
| 4914 | * <h3>Columns</h3> |
| 4915 | * |
| 4916 | * <table class="jd-sumtable"> |
| 4917 | * <tr> |
| 4918 | * <th colspan='4'>PhoneLookup</th> |
| 4919 | * </tr> |
| 4920 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4921 | * <td>String</td> |
| 4922 | * <td>{@link #NUMBER}</td> |
| 4923 | * <td>read-only</td> |
| 4924 | * <td>Phone number.</td> |
| 4925 | * </tr> |
| 4926 | * <tr> |
| 4927 | * <td>String</td> |
| 4928 | * <td>{@link #TYPE}</td> |
| 4929 | * <td>read-only</td> |
| 4930 | * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td> |
| 4931 | * </tr> |
| 4932 | * <tr> |
| 4933 | * <td>String</td> |
| 4934 | * <td>{@link #LABEL}</td> |
| 4935 | * <td>read-only</td> |
| 4936 | * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td> |
| 4937 | * </tr> |
| 4938 | * </table> |
| 4939 | * <p> |
| 4940 | * Columns from the Contacts table are also available through a join. |
| 4941 | * </p> |
| 4942 | * <table class="jd-sumtable"> |
| 4943 | * <tr> |
| 4944 | * <th colspan='4'>Join with {@link Contacts}</th> |
| 4945 | * </tr> |
| 4946 | * <tr> |
Dmitri Plotnikov | 817b3f9 | 2011-01-09 17:07:13 -0800 | [diff] [blame] | 4947 | * <td>long</td> |
| 4948 | * <td>{@link #_ID}</td> |
| 4949 | * <td>read-only</td> |
| 4950 | * <td>Contact ID.</td> |
| 4951 | * </tr> |
| 4952 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4953 | * <td>String</td> |
| 4954 | * <td>{@link #LOOKUP_KEY}</td> |
| 4955 | * <td>read-only</td> |
| 4956 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4957 | * </tr> |
| 4958 | * <tr> |
| 4959 | * <td>String</td> |
| 4960 | * <td>{@link #DISPLAY_NAME}</td> |
| 4961 | * <td>read-only</td> |
| 4962 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4963 | * </tr> |
| 4964 | * <tr> |
| 4965 | * <td>long</td> |
| 4966 | * <td>{@link #PHOTO_ID}</td> |
| 4967 | * <td>read-only</td> |
| 4968 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4969 | * </tr> |
| 4970 | * <tr> |
| 4971 | * <td>int</td> |
| 4972 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 4973 | * <td>read-only</td> |
| 4974 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4975 | * </tr> |
| 4976 | * <tr> |
| 4977 | * <td>int</td> |
| 4978 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 4979 | * <td>read-only</td> |
| 4980 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4981 | * </tr> |
| 4982 | * <tr> |
| 4983 | * <td>int</td> |
| 4984 | * <td>{@link #TIMES_CONTACTED}</td> |
| 4985 | * <td>read-only</td> |
| 4986 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4987 | * </tr> |
| 4988 | * <tr> |
| 4989 | * <td>long</td> |
| 4990 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 4991 | * <td>read-only</td> |
| 4992 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4993 | * </tr> |
| 4994 | * <tr> |
| 4995 | * <td>int</td> |
| 4996 | * <td>{@link #STARRED}</td> |
| 4997 | * <td>read-only</td> |
| 4998 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4999 | * </tr> |
| 5000 | * <tr> |
| 5001 | * <td>String</td> |
| 5002 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 5003 | * <td>read-only</td> |
| 5004 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5005 | * </tr> |
| 5006 | * <tr> |
| 5007 | * <td>int</td> |
| 5008 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 5009 | * <td>read-only</td> |
| 5010 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5011 | * </tr> |
| 5012 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5013 | */ |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5014 | public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, |
| 5015 | ContactsColumns, ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5016 | /** |
| 5017 | * This utility class cannot be instantiated |
| 5018 | */ |
| 5019 | private PhoneLookup() {} |
| 5020 | |
| 5021 | /** |
| 5022 | * The content:// style URI for this table. Append the phone number you want to lookup |
| 5023 | * to this URI and query it to perform a lookup. For example: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5024 | * <pre> |
Scott Kennedy | 7ed189e | 2013-01-11 22:31:43 -0800 | [diff] [blame] | 5025 | * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, |
| 5026 | * Uri.encode(phoneNumber)); |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5027 | * </pre> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5028 | */ |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5029 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 5030 | "phone_lookup"); |
Dmitri Plotnikov | 0b0b8a8 | 2010-03-04 18:20:08 -0800 | [diff] [blame] | 5031 | |
| 5032 | /** |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 5033 | * <p>URI used for the "enterprise caller-id".</p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5034 | * |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 5035 | * <p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5036 | * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same |
| 5037 | * columns. If the device has no corp profile that is linked to the current profile, it |
| 5038 | * behaves in the exact same way as {@link #CONTENT_FILTER_URI}. If there is a corp profile |
| 5039 | * linked to the current profile, it first queries against the personal contact database, |
| 5040 | * and if no matching contacts are found there, then queries against the |
| 5041 | * corp contacts database. |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 5042 | * </p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5043 | * <p> |
| 5044 | * If a result is from the corp profile, it makes the following changes to the data: |
| 5045 | * <ul> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5046 | * <li> |
| 5047 | * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special |
| 5048 | * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to |
| 5049 | * load pictures from them. |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 5050 | * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not use them. |
| 5051 | * </li> |
| 5052 | * <li> |
| 5053 | * Corp contacts will get artificial {@link #_ID}s. In order to tell whether a contact |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 5054 | * is from the corp profile, use |
| 5055 | * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}. |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5056 | * </li> |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 5057 | * <li> |
| 5058 | * Corp contacts will get artificial {@link #LOOKUP_KEY}s too. |
| 5059 | * </li> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5060 | * </ul> |
Makoto Onuki | 95a9cfb | 2014-07-08 17:11:54 -0700 | [diff] [blame] | 5061 | * <p> |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 5062 | * A contact lookup URL built by |
| 5063 | * {@link ContactsContract.Contacts#getLookupUri(long, String)} |
| 5064 | * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to |
| 5065 | * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the |
| 5066 | * corp profile. |
| 5067 | * </p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5068 | * |
| 5069 | * <pre> |
| 5070 | * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, |
| 5071 | * Uri.encode(phoneNumber)); |
| 5072 | * </pre> |
| 5073 | */ |
| 5074 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 5075 | "phone_lookup_enterprise"); |
| 5076 | |
| 5077 | /** |
Dmitri Plotnikov | 0b0b8a8 | 2010-03-04 18:20:08 -0800 | [diff] [blame] | 5078 | * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows. |
| 5079 | * |
| 5080 | * @hide |
| 5081 | */ |
| 5082 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup"; |
Flavio Lerda | 52c01c2 | 2011-11-02 22:16:23 +0000 | [diff] [blame] | 5083 | |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 5084 | /** |
| 5085 | * If this boolean parameter is set to true, then the appended query is treated as a |
| 5086 | * SIP address and the lookup will be performed against SIP addresses in the user's |
| 5087 | * contacts. |
| 5088 | */ |
Flavio Lerda | 52c01c2 | 2011-11-02 22:16:23 +0000 | [diff] [blame] | 5089 | public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5090 | } |
| 5091 | |
| 5092 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5093 | * Additional data mixed in with {@link StatusColumns} to link |
| 5094 | * back to specific {@link ContactsContract.Data#_ID} entries. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5095 | * |
| 5096 | * @see StatusUpdates |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5097 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5098 | protected interface PresenceColumns { |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 5099 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5100 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5101 | * Reference to the {@link Data#_ID} entry that owns this presence. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5102 | * <P>Type: INTEGER</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5103 | */ |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5104 | public static final String DATA_ID = "presence_data_id"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5105 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5106 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5107 | * See {@link CommonDataKinds.Im} for a list of defined protocol constants. |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 5108 | * <p>Type: NUMBER</p> |
| 5109 | */ |
| 5110 | public static final String PROTOCOL = "protocol"; |
| 5111 | |
| 5112 | /** |
| 5113 | * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 5114 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 5115 | * omitted if {@link #PROTOCOL} value is not |
| 5116 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. |
| 5117 | * |
| 5118 | * <p>Type: NUMBER</p> |
| 5119 | */ |
| 5120 | public static final String CUSTOM_PROTOCOL = "custom_protocol"; |
| 5121 | |
| 5122 | /** |
| 5123 | * The IM handle the presence item is for. The handle is scoped to |
| 5124 | * {@link #PROTOCOL}. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5125 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5126 | */ |
| 5127 | public static final String IM_HANDLE = "im_handle"; |
| 5128 | |
| 5129 | /** |
| 5130 | * The IM account for the local user that the presence data came from. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5131 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5132 | */ |
| 5133 | public static final String IM_ACCOUNT = "im_account"; |
| 5134 | } |
| 5135 | |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5136 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5137 | * <p> |
| 5138 | * A status update is linked to a {@link ContactsContract.Data} row and captures |
| 5139 | * the user's latest status update via the corresponding source, e.g. |
| 5140 | * "Having lunch" via "Google Talk". |
| 5141 | * </p> |
| 5142 | * <p> |
| 5143 | * There are two ways a status update can be inserted: by explicitly linking |
| 5144 | * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row |
| 5145 | * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 5146 | * {@link #IM_HANDLE}. There is no difference between insert and update, you can use |
| 5147 | * either. |
| 5148 | * </p> |
| 5149 | * <p> |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 5150 | * Inserting or updating a status update for the user's profile requires either using |
| 5151 | * the {@link #DATA_ID} to identify the data row to attach the update to, or |
| 5152 | * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the |
| 5153 | * profile. |
| 5154 | * </p> |
| 5155 | * <p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5156 | * You cannot use {@link ContentResolver#update} to change a status, but |
| 5157 | * {@link ContentResolver#insert} will replace the latests status if it already |
| 5158 | * exists. |
| 5159 | * </p> |
| 5160 | * <p> |
| 5161 | * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses |
| 5162 | * for multiple contacts at once. |
| 5163 | * </p> |
| 5164 | * |
| 5165 | * <h3>Columns</h3> |
| 5166 | * <table class="jd-sumtable"> |
| 5167 | * <tr> |
| 5168 | * <th colspan='4'>StatusUpdates</th> |
| 5169 | * </tr> |
| 5170 | * <tr> |
| 5171 | * <td>long</td> |
| 5172 | * <td>{@link #DATA_ID}</td> |
| 5173 | * <td>read/write</td> |
| 5174 | * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this |
| 5175 | * field is <i>not</i> specified, the provider will attempt to find a data row |
| 5176 | * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 5177 | * {@link #IM_HANDLE} columns. |
| 5178 | * </td> |
| 5179 | * </tr> |
| 5180 | * <tr> |
| 5181 | * <td>long</td> |
| 5182 | * <td>{@link #PROTOCOL}</td> |
| 5183 | * <td>read/write</td> |
| 5184 | * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td> |
| 5185 | * </tr> |
| 5186 | * <tr> |
| 5187 | * <td>String</td> |
| 5188 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 5189 | * <td>read/write</td> |
| 5190 | * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 5191 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 5192 | * omitted if {@link #PROTOCOL} value is not |
| 5193 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td> |
| 5194 | * </tr> |
| 5195 | * <tr> |
| 5196 | * <td>String</td> |
| 5197 | * <td>{@link #IM_HANDLE}</td> |
| 5198 | * <td>read/write</td> |
| 5199 | * <td> The IM handle the presence item is for. The handle is scoped to |
| 5200 | * {@link #PROTOCOL}.</td> |
| 5201 | * </tr> |
| 5202 | * <tr> |
| 5203 | * <td>String</td> |
| 5204 | * <td>{@link #IM_ACCOUNT}</td> |
| 5205 | * <td>read/write</td> |
| 5206 | * <td>The IM account for the local user that the presence data came from.</td> |
| 5207 | * </tr> |
| 5208 | * <tr> |
| 5209 | * <td>int</td> |
| 5210 | * <td>{@link #PRESENCE}</td> |
| 5211 | * <td>read/write</td> |
| 5212 | * <td>Contact IM presence status. The allowed values are: |
| 5213 | * <p> |
| 5214 | * <ul> |
| 5215 | * <li>{@link #OFFLINE}</li> |
| 5216 | * <li>{@link #INVISIBLE}</li> |
| 5217 | * <li>{@link #AWAY}</li> |
| 5218 | * <li>{@link #IDLE}</li> |
| 5219 | * <li>{@link #DO_NOT_DISTURB}</li> |
| 5220 | * <li>{@link #AVAILABLE}</li> |
| 5221 | * </ul> |
| 5222 | * </p> |
| 5223 | * <p> |
| 5224 | * Since presence status is inherently volatile, the content provider |
| 5225 | * may choose not to store this field in long-term storage. |
| 5226 | * </p> |
| 5227 | * </td> |
| 5228 | * </tr> |
| 5229 | * <tr> |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 5230 | * <td>int</td> |
| 5231 | * <td>{@link #CHAT_CAPABILITY}</td> |
| 5232 | * <td>read/write</td> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 5233 | * <td>Contact IM chat compatibility value. The allowed values combinations of the following |
| 5234 | * flags. If None of these flags is set, the device can only do text messaging. |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 5235 | * <p> |
| 5236 | * <ul> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 5237 | * <li>{@link #CAPABILITY_HAS_VIDEO}</li> |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 5238 | * <li>{@link #CAPABILITY_HAS_VOICE}</li> |
| 5239 | * <li>{@link #CAPABILITY_HAS_CAMERA}</li> |
| 5240 | * </ul> |
| 5241 | * </p> |
| 5242 | * <p> |
| 5243 | * Since chat compatibility is inherently volatile as the contact's availability moves from |
| 5244 | * one device to another, the content provider may choose not to store this field in long-term |
| 5245 | * storage. |
| 5246 | * </p> |
| 5247 | * </td> |
| 5248 | * </tr> |
| 5249 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5250 | * <td>String</td> |
| 5251 | * <td>{@link #STATUS}</td> |
| 5252 | * <td>read/write</td> |
| 5253 | * <td>Contact's latest status update, e.g. "having toast for breakfast"</td> |
| 5254 | * </tr> |
| 5255 | * <tr> |
| 5256 | * <td>long</td> |
| 5257 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 5258 | * <td>read/write</td> |
| 5259 | * <td>The absolute time in milliseconds when the status was |
| 5260 | * entered by the user. If this value is not provided, the provider will follow |
| 5261 | * this logic: if there was no prior status update, the value will be left as null. |
| 5262 | * If there was a prior status update, the provider will default this field |
| 5263 | * to the current time.</td> |
| 5264 | * </tr> |
| 5265 | * <tr> |
| 5266 | * <td>String</td> |
| 5267 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 5268 | * <td>read/write</td> |
| 5269 | * <td> The package containing resources for this status: label and icon.</td> |
| 5270 | * </tr> |
| 5271 | * <tr> |
| 5272 | * <td>long</td> |
| 5273 | * <td>{@link #STATUS_LABEL}</td> |
| 5274 | * <td>read/write</td> |
| 5275 | * <td>The resource ID of the label describing the source of contact status, |
| 5276 | * e.g. "Google Talk". This resource is scoped by the |
| 5277 | * {@link #STATUS_RES_PACKAGE}.</td> |
| 5278 | * </tr> |
| 5279 | * <tr> |
| 5280 | * <td>long</td> |
| 5281 | * <td>{@link #STATUS_ICON}</td> |
| 5282 | * <td>read/write</td> |
| 5283 | * <td>The resource ID of the icon for the source of contact status. This |
| 5284 | * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 5285 | * </tr> |
| 5286 | * </table> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5287 | */ |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5288 | public static class StatusUpdates implements StatusColumns, PresenceColumns { |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 5289 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5290 | /** |
| 5291 | * This utility class cannot be instantiated |
| 5292 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5293 | private StatusUpdates() {} |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5294 | |
| 5295 | /** |
| 5296 | * The content:// style URI for this table |
| 5297 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5298 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates"); |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5299 | |
| 5300 | /** |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 5301 | * The content:// style URI for this table, specific to the user's profile. |
| 5302 | */ |
| 5303 | public static final Uri PROFILE_CONTENT_URI = |
| 5304 | Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates"); |
| 5305 | |
| 5306 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5307 | * Gets the resource ID for the proper presence icon. |
| 5308 | * |
| 5309 | * @param status the status to get the icon for |
| 5310 | * @return the resource ID for the proper presence icon |
| 5311 | */ |
| 5312 | public static final int getPresenceIconResourceId(int status) { |
| 5313 | switch (status) { |
| 5314 | case AVAILABLE: |
| 5315 | return android.R.drawable.presence_online; |
| 5316 | case IDLE: |
| 5317 | case AWAY: |
| 5318 | return android.R.drawable.presence_away; |
| 5319 | case DO_NOT_DISTURB: |
| 5320 | return android.R.drawable.presence_busy; |
| 5321 | case INVISIBLE: |
| 5322 | return android.R.drawable.presence_invisible; |
| 5323 | case OFFLINE: |
| 5324 | default: |
| 5325 | return android.R.drawable.presence_offline; |
| 5326 | } |
| 5327 | } |
| 5328 | |
| 5329 | /** |
Evan Millar | c043752 | 2009-06-23 17:31:05 -0700 | [diff] [blame] | 5330 | * Returns the precedence of the status code the higher number being the higher precedence. |
| 5331 | * |
| 5332 | * @param status The status code. |
| 5333 | * @return An integer representing the precedence, 0 being the lowest. |
| 5334 | */ |
| 5335 | public static final int getPresencePrecedence(int status) { |
| 5336 | // Keep this function here incase we want to enforce a different precedence than the |
| 5337 | // natural order of the status constants. |
| 5338 | return status; |
| 5339 | } |
| 5340 | |
| 5341 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5342 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5343 | * status update details. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5344 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5345 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5346 | |
| 5347 | /** |
| 5348 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5349 | * status update detail. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5350 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5351 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update"; |
| 5352 | } |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 5353 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5354 | /** |
| 5355 | * @deprecated This old name was never meant to be made public. Do not use. |
| 5356 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5357 | @Deprecated |
| 5358 | public static final class Presence extends StatusUpdates { |
| 5359 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5360 | } |
| 5361 | |
| 5362 | /** |
Yorke Lee | 8d37009 | 2014-06-26 10:32:17 -0700 | [diff] [blame] | 5363 | * Additional column returned by |
| 5364 | * {@link ContactsContract.Contacts#CONTENT_FILTER_URI Contacts.CONTENT_FILTER_URI} explaining |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5365 | * why the filter matched the contact. This column will contain extracts from the contact's |
| 5366 | * constituent {@link Data Data} items, formatted in a way that indicates the section of the |
| 5367 | * snippet that matched the filter. |
| 5368 | * |
| 5369 | * <p> |
| 5370 | * The following example searches for all contacts that match the query "presi" and requests |
| 5371 | * the snippet column as well. |
| 5372 | * <pre> |
| 5373 | * Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon(); |
| 5374 | * builder.appendPath("presi"); |
| 5375 | * // Defer snippeting to the client side if possible, for performance reasons. |
| 5376 | * builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1"); |
| 5377 | * |
| 5378 | * Cursor cursor = getContentResolver().query(builder.build()); |
| 5379 | * |
| 5380 | * Bundle extras = cursor.getExtras(); |
| 5381 | * if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) { |
| 5382 | * // Do our own snippet formatting. |
| 5383 | * // For a contact with the email address (president@organization.com), the snippet |
| 5384 | * // column will contain the string "president@organization.com". |
| 5385 | * } else { |
| 5386 | * // The snippet has already been pre-formatted, we can display it as is. |
| 5387 | * // For a contact with the email address (president@organization.com), the snippet |
| 5388 | * // column will contain the string "[presi]dent@organization.com". |
| 5389 | * } |
| 5390 | * </pre> |
| 5391 | * </p> |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5392 | */ |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5393 | public static class SearchSnippets { |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5394 | |
| 5395 | /** |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5396 | * The search snippet constructed by SQLite snippeting functionality. |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5397 | * <p> |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5398 | * The snippet may contain (parts of) several data elements belonging to the contact, |
| 5399 | * with the matching parts optionally surrounded by special characters that indicate the |
| 5400 | * start and end of matching text. |
| 5401 | * |
| 5402 | * For example, if a contact has an address "123 Main Street", using a filter "mai" would |
| 5403 | * return the formatted snippet "123 [Mai]n street". |
| 5404 | * |
| 5405 | * @see <a href="http://www.sqlite.org/fts3.html#snippet"> |
| 5406 | * http://www.sqlite.org/fts3.html#snippet</a> |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5407 | */ |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5408 | public static final String SNIPPET = "snippet"; |
| 5409 | |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5410 | /** |
| 5411 | * Comma-separated parameters for the generation of the snippet: |
| 5412 | * <ul> |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5413 | * <li>The "start match" text. Default is '['</li> |
| 5414 | * <li>The "end match" text. Default is ']'</li> |
| 5415 | * <li>The "ellipsis" text. Default is "..."</li> |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5416 | * <li>Maximum number of tokens to include in the snippet. Can be either |
| 5417 | * a positive or a negative number: A positive number indicates how many |
| 5418 | * tokens can be returned in total. A negative number indicates how many |
| 5419 | * tokens can be returned per occurrence of the search terms.</li> |
| 5420 | * </ul> |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5421 | * |
| 5422 | * @hide |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5423 | */ |
| 5424 | public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args"; |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5425 | |
| 5426 | /** |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5427 | * The key to ask the provider to defer the formatting of the snippet to the client if |
| 5428 | * possible, for performance reasons. |
| 5429 | * A value of 1 indicates true, 0 indicates false. False is the default. |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5430 | * When a cursor is returned to the client, it should check for an extra with the name |
| 5431 | * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5432 | * should do its own formatting of the snippet. If it doesn't exist, the snippet column |
| 5433 | * in the cursor should already contain a formatted snippet. |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5434 | */ |
| 5435 | public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting"; |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5436 | } |
| 5437 | |
| 5438 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5439 | * Container for definitions of common data types stored in the {@link ContactsContract.Data} |
| 5440 | * table. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5441 | */ |
| 5442 | public static final class CommonDataKinds { |
| 5443 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5444 | * This utility class cannot be instantiated |
| 5445 | */ |
| 5446 | private CommonDataKinds() {} |
| 5447 | |
| 5448 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5449 | * The {@link Data#RES_PACKAGE} value for common data that should be |
| 5450 | * shown using a default style. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5451 | * |
| 5452 | * @hide RES_PACKAGE is hidden |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5453 | */ |
| 5454 | public static final String PACKAGE_COMMON = "common"; |
| 5455 | |
| 5456 | /** |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5457 | * The base types that all "Typed" data kinds support. |
| 5458 | */ |
| 5459 | public interface BaseTypes { |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5460 | /** |
| 5461 | * A custom type. The custom label should be supplied by user. |
| 5462 | */ |
| 5463 | public static int TYPE_CUSTOM = 0; |
| 5464 | } |
| 5465 | |
| 5466 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5467 | * Columns common across the specific types. |
| 5468 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5469 | protected interface CommonColumns extends BaseTypes { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5470 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5471 | * The data for the contact method. |
| 5472 | * <P>Type: TEXT</P> |
| 5473 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5474 | public static final String DATA = DataColumns.DATA1; |
| 5475 | |
| 5476 | /** |
| 5477 | * The type of data, for example Home or Work. |
| 5478 | * <P>Type: INTEGER</P> |
| 5479 | */ |
| 5480 | public static final String TYPE = DataColumns.DATA2; |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 5481 | |
| 5482 | /** |
| 5483 | * The user defined label for the the contact method. |
| 5484 | * <P>Type: TEXT</P> |
| 5485 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5486 | public static final String LABEL = DataColumns.DATA3; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5487 | } |
| 5488 | |
| 5489 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5490 | * A data kind representing the contact's proper name. You can use all |
| 5491 | * columns defined for {@link ContactsContract.Data} as well as the following aliases. |
| 5492 | * |
| 5493 | * <h2>Column aliases</h2> |
| 5494 | * <table class="jd-sumtable"> |
| 5495 | * <tr> |
| 5496 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 5497 | * </tr> |
| 5498 | * <tr> |
| 5499 | * <td>String</td> |
| 5500 | * <td>{@link #DISPLAY_NAME}</td> |
| 5501 | * <td>{@link #DATA1}</td> |
| 5502 | * <td></td> |
| 5503 | * </tr> |
| 5504 | * <tr> |
| 5505 | * <td>String</td> |
| 5506 | * <td>{@link #GIVEN_NAME}</td> |
| 5507 | * <td>{@link #DATA2}</td> |
| 5508 | * <td></td> |
| 5509 | * </tr> |
| 5510 | * <tr> |
| 5511 | * <td>String</td> |
| 5512 | * <td>{@link #FAMILY_NAME}</td> |
| 5513 | * <td>{@link #DATA3}</td> |
| 5514 | * <td></td> |
| 5515 | * </tr> |
| 5516 | * <tr> |
| 5517 | * <td>String</td> |
| 5518 | * <td>{@link #PREFIX}</td> |
| 5519 | * <td>{@link #DATA4}</td> |
| 5520 | * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td> |
| 5521 | * </tr> |
| 5522 | * <tr> |
| 5523 | * <td>String</td> |
| 5524 | * <td>{@link #MIDDLE_NAME}</td> |
| 5525 | * <td>{@link #DATA5}</td> |
| 5526 | * <td></td> |
| 5527 | * </tr> |
| 5528 | * <tr> |
| 5529 | * <td>String</td> |
| 5530 | * <td>{@link #SUFFIX}</td> |
| 5531 | * <td>{@link #DATA6}</td> |
| 5532 | * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td> |
| 5533 | * </tr> |
| 5534 | * <tr> |
| 5535 | * <td>String</td> |
| 5536 | * <td>{@link #PHONETIC_GIVEN_NAME}</td> |
| 5537 | * <td>{@link #DATA7}</td> |
| 5538 | * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td> |
| 5539 | * </tr> |
| 5540 | * <tr> |
| 5541 | * <td>String</td> |
| 5542 | * <td>{@link #PHONETIC_MIDDLE_NAME}</td> |
| 5543 | * <td>{@link #DATA8}</td> |
| 5544 | * <td></td> |
| 5545 | * </tr> |
| 5546 | * <tr> |
| 5547 | * <td>String</td> |
| 5548 | * <td>{@link #PHONETIC_FAMILY_NAME}</td> |
| 5549 | * <td>{@link #DATA9}</td> |
| 5550 | * <td></td> |
| 5551 | * </tr> |
| 5552 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5553 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 5554 | public static final class StructuredName implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5555 | /** |
| 5556 | * This utility class cannot be instantiated |
| 5557 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5558 | private StructuredName() {} |
| 5559 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5560 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5561 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; |
| 5562 | |
| 5563 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5564 | * The name that should be used to display the contact. |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 5565 | * <i>Unstructured component of the name should be consistent with |
| 5566 | * its structured representation.</i> |
| 5567 | * <p> |
| 5568 | * Type: TEXT |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5569 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5570 | public static final String DISPLAY_NAME = DATA1; |
| 5571 | |
| 5572 | /** |
| 5573 | * The given name for the contact. |
| 5574 | * <P>Type: TEXT</P> |
| 5575 | */ |
| 5576 | public static final String GIVEN_NAME = DATA2; |
| 5577 | |
| 5578 | /** |
| 5579 | * The family name for the contact. |
| 5580 | * <P>Type: TEXT</P> |
| 5581 | */ |
| 5582 | public static final String FAMILY_NAME = DATA3; |
| 5583 | |
| 5584 | /** |
| 5585 | * The contact's honorific prefix, e.g. "Sir" |
| 5586 | * <P>Type: TEXT</P> |
| 5587 | */ |
| 5588 | public static final String PREFIX = DATA4; |
| 5589 | |
| 5590 | /** |
| 5591 | * The contact's middle name |
| 5592 | * <P>Type: TEXT</P> |
| 5593 | */ |
| 5594 | public static final String MIDDLE_NAME = DATA5; |
| 5595 | |
| 5596 | /** |
| 5597 | * The contact's honorific suffix, e.g. "Jr" |
| 5598 | */ |
| 5599 | public static final String SUFFIX = DATA6; |
| 5600 | |
| 5601 | /** |
| 5602 | * The phonetic version of the given name for the contact. |
| 5603 | * <P>Type: TEXT</P> |
| 5604 | */ |
| 5605 | public static final String PHONETIC_GIVEN_NAME = DATA7; |
| 5606 | |
| 5607 | /** |
| 5608 | * The phonetic version of the additional name for the contact. |
| 5609 | * <P>Type: TEXT</P> |
| 5610 | */ |
| 5611 | public static final String PHONETIC_MIDDLE_NAME = DATA8; |
| 5612 | |
| 5613 | /** |
| 5614 | * The phonetic version of the family name for the contact. |
| 5615 | * <P>Type: TEXT</P> |
| 5616 | */ |
| 5617 | public static final String PHONETIC_FAMILY_NAME = DATA9; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5618 | |
| 5619 | /** |
| 5620 | * The style used for combining given/middle/family name into a full name. |
| 5621 | * See {@link ContactsContract.FullNameStyle}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5622 | */ |
| 5623 | public static final String FULL_NAME_STYLE = DATA10; |
| 5624 | |
| 5625 | /** |
| 5626 | * The alphabet used for capturing the phonetic name. |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 5627 | * See ContactsContract.PhoneticNameStyle. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5628 | * @hide |
| 5629 | */ |
| 5630 | public static final String PHONETIC_NAME_STYLE = DATA11; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5631 | } |
| 5632 | |
| 5633 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5634 | * <p>A data kind representing the contact's nickname. For example, for |
| 5635 | * Bob Parr ("Mr. Incredible"): |
| 5636 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 5637 | * ArrayList<ContentProviderOperation> ops = |
| 5638 | * new ArrayList<ContentProviderOperation>(); |
| 5639 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5640 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 5641 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 5642 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 5643 | * .withValue(StructuredName.DISPLAY_NAME, "Bob Parr") |
| 5644 | * .build()); |
| 5645 | * |
| 5646 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 5647 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 5648 | * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE) |
| 5649 | * .withValue(Nickname.NAME, "Mr. Incredible") |
| 5650 | * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM) |
| 5651 | * .withValue(Nickname.LABEL, "Superhero") |
| 5652 | * .build()); |
| 5653 | * |
| 5654 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 5655 | * </pre> |
| 5656 | * </p> |
| 5657 | * <p> |
| 5658 | * You can use all columns defined for {@link ContactsContract.Data} as well as the |
| 5659 | * following aliases. |
| 5660 | * </p> |
| 5661 | * |
| 5662 | * <h2>Column aliases</h2> |
| 5663 | * <table class="jd-sumtable"> |
| 5664 | * <tr> |
| 5665 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 5666 | * </tr> |
| 5667 | * <tr> |
| 5668 | * <td>String</td> |
| 5669 | * <td>{@link #NAME}</td> |
| 5670 | * <td>{@link #DATA1}</td> |
| 5671 | * <td></td> |
| 5672 | * </tr> |
| 5673 | * <tr> |
| 5674 | * <td>int</td> |
| 5675 | * <td>{@link #TYPE}</td> |
| 5676 | * <td>{@link #DATA2}</td> |
| 5677 | * <td> |
| 5678 | * Allowed values are: |
| 5679 | * <p> |
| 5680 | * <ul> |
| 5681 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5682 | * <li>{@link #TYPE_DEFAULT}</li> |
| 5683 | * <li>{@link #TYPE_OTHER_NAME}</li> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5684 | * <li>{@link #TYPE_MAIDEN_NAME}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5685 | * <li>{@link #TYPE_SHORT_NAME}</li> |
| 5686 | * <li>{@link #TYPE_INITIALS}</li> |
| 5687 | * </ul> |
| 5688 | * </p> |
| 5689 | * </td> |
| 5690 | * </tr> |
| 5691 | * <tr> |
| 5692 | * <td>String</td> |
| 5693 | * <td>{@link #LABEL}</td> |
| 5694 | * <td>{@link #DATA3}</td> |
| 5695 | * <td></td> |
| 5696 | * </tr> |
| 5697 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5698 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 5699 | public static final class Nickname implements DataColumnsWithJoins, CommonColumns, |
| 5700 | ContactCounts{ |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5701 | /** |
| 5702 | * This utility class cannot be instantiated |
| 5703 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5704 | private Nickname() {} |
| 5705 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5706 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5707 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; |
| 5708 | |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 5709 | public static final int TYPE_DEFAULT = 1; |
| 5710 | public static final int TYPE_OTHER_NAME = 2; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5711 | public static final int TYPE_MAIDEN_NAME = 3; |
| 5712 | /** @deprecated Use TYPE_MAIDEN_NAME instead. */ |
| 5713 | @Deprecated |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 5714 | public static final int TYPE_MAINDEN_NAME = 3; |
| 5715 | public static final int TYPE_SHORT_NAME = 4; |
| 5716 | public static final int TYPE_INITIALS = 5; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5717 | |
| 5718 | /** |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 5719 | * The name itself |
| 5720 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5721 | public static final String NAME = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5722 | } |
| 5723 | |
| 5724 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5725 | * <p> |
| 5726 | * A data kind representing a telephone number. |
| 5727 | * </p> |
| 5728 | * <p> |
| 5729 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5730 | * well as the following aliases. |
| 5731 | * </p> |
| 5732 | * <h2>Column aliases</h2> |
| 5733 | * <table class="jd-sumtable"> |
| 5734 | * <tr> |
| 5735 | * <th>Type</th> |
| 5736 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5737 | * </tr> |
| 5738 | * <tr> |
| 5739 | * <td>String</td> |
| 5740 | * <td>{@link #NUMBER}</td> |
| 5741 | * <td>{@link #DATA1}</td> |
| 5742 | * <td></td> |
| 5743 | * </tr> |
| 5744 | * <tr> |
| 5745 | * <td>int</td> |
| 5746 | * <td>{@link #TYPE}</td> |
| 5747 | * <td>{@link #DATA2}</td> |
| 5748 | * <td>Allowed values are: |
| 5749 | * <p> |
| 5750 | * <ul> |
| 5751 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5752 | * <li>{@link #TYPE_HOME}</li> |
| 5753 | * <li>{@link #TYPE_MOBILE}</li> |
| 5754 | * <li>{@link #TYPE_WORK}</li> |
| 5755 | * <li>{@link #TYPE_FAX_WORK}</li> |
| 5756 | * <li>{@link #TYPE_FAX_HOME}</li> |
| 5757 | * <li>{@link #TYPE_PAGER}</li> |
| 5758 | * <li>{@link #TYPE_OTHER}</li> |
| 5759 | * <li>{@link #TYPE_CALLBACK}</li> |
| 5760 | * <li>{@link #TYPE_CAR}</li> |
| 5761 | * <li>{@link #TYPE_COMPANY_MAIN}</li> |
| 5762 | * <li>{@link #TYPE_ISDN}</li> |
| 5763 | * <li>{@link #TYPE_MAIN}</li> |
| 5764 | * <li>{@link #TYPE_OTHER_FAX}</li> |
| 5765 | * <li>{@link #TYPE_RADIO}</li> |
| 5766 | * <li>{@link #TYPE_TELEX}</li> |
| 5767 | * <li>{@link #TYPE_TTY_TDD}</li> |
| 5768 | * <li>{@link #TYPE_WORK_MOBILE}</li> |
| 5769 | * <li>{@link #TYPE_WORK_PAGER}</li> |
| 5770 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 5771 | * <li>{@link #TYPE_MMS}</li> |
| 5772 | * </ul> |
| 5773 | * </p> |
| 5774 | * </td> |
| 5775 | * </tr> |
| 5776 | * <tr> |
| 5777 | * <td>String</td> |
| 5778 | * <td>{@link #LABEL}</td> |
| 5779 | * <td>{@link #DATA3}</td> |
| 5780 | * <td></td> |
| 5781 | * </tr> |
| 5782 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5783 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 5784 | public static final class Phone implements DataColumnsWithJoins, CommonColumns, |
| 5785 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5786 | /** |
| 5787 | * This utility class cannot be instantiated |
| 5788 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5789 | private Phone() {} |
| 5790 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5791 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5792 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5793 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5794 | /** |
| 5795 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 5796 | * phones. |
| 5797 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5798 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2"; |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5799 | |
| 5800 | /** |
| 5801 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5802 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 5803 | * associated raw contact and aggregate contact data. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5804 | */ |
| 5805 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 5806 | "phones"); |
| 5807 | |
| 5808 | /** |
Ricky Wai | fa5bbaf | 2015-02-26 16:51:32 +0000 | [diff] [blame] | 5809 | * URI used for getting all contacts from primary and managed profile. |
| 5810 | * |
| 5811 | * It supports the same semantics as {@link #CONTENT_URI} and returns the same |
| 5812 | * columns. If the device has no corp profile that is linked to the current profile, it |
| 5813 | * behaves in the exact same way as {@link #CONTENT_URI}. If there is a corp profile |
| 5814 | * linked to the current profile, it will merge corp profile and current profile's |
| 5815 | * results and return |
| 5816 | * |
| 5817 | * @hide |
| 5818 | */ |
| 5819 | public static final Uri ENTERPRISE_CONTENT_URI = |
| 5820 | Uri.withAppendedPath(Data.ENTERPRISE_CONTENT_URI, "phones"); |
| 5821 | |
| 5822 | /** |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5823 | * The content:// style URL for phone lookup using a filter. The filter returns |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5824 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5825 | * to display names as well as phone numbers. The filter argument should be passed |
| 5826 | * as an additional path segment after this URI. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5827 | */ |
| 5828 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 5829 | "filter"); |
| 5830 | |
Daniel Lehmann | 1024de5 | 2012-06-15 20:32:33 -0700 | [diff] [blame] | 5831 | /** |
| 5832 | * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. |
| 5833 | * If "1" or "true", display names are searched. If "0" or "false", display names |
| 5834 | * are not searched. Default is "1". |
| 5835 | */ |
| 5836 | public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name"; |
| 5837 | |
| 5838 | /** |
| 5839 | * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. |
| 5840 | * If "1" or "true", phone numbers are searched. If "0" or "false", phone numbers |
| 5841 | * are not searched. Default is "1". |
| 5842 | */ |
| 5843 | public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number"; |
| 5844 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5845 | public static final int TYPE_HOME = 1; |
| 5846 | public static final int TYPE_MOBILE = 2; |
| 5847 | public static final int TYPE_WORK = 3; |
| 5848 | public static final int TYPE_FAX_WORK = 4; |
| 5849 | public static final int TYPE_FAX_HOME = 5; |
| 5850 | public static final int TYPE_PAGER = 6; |
| 5851 | public static final int TYPE_OTHER = 7; |
Fred Quintana | 3f86715 | 2009-08-03 11:43:16 -0700 | [diff] [blame] | 5852 | public static final int TYPE_CALLBACK = 8; |
| 5853 | public static final int TYPE_CAR = 9; |
| 5854 | public static final int TYPE_COMPANY_MAIN = 10; |
| 5855 | public static final int TYPE_ISDN = 11; |
| 5856 | public static final int TYPE_MAIN = 12; |
| 5857 | public static final int TYPE_OTHER_FAX = 13; |
| 5858 | public static final int TYPE_RADIO = 14; |
| 5859 | public static final int TYPE_TELEX = 15; |
| 5860 | public static final int TYPE_TTY_TDD = 16; |
| 5861 | public static final int TYPE_WORK_MOBILE = 17; |
| 5862 | public static final int TYPE_WORK_PAGER = 18; |
| 5863 | public static final int TYPE_ASSISTANT = 19; |
Jeff Sharkey | d5abd46 | 2009-09-16 19:54:29 -0700 | [diff] [blame] | 5864 | public static final int TYPE_MMS = 20; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5865 | |
| 5866 | /** |
| 5867 | * The phone number as the user entered it. |
| 5868 | * <P>Type: TEXT</P> |
| 5869 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5870 | public static final String NUMBER = DATA; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5871 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5872 | /** |
Daniel Lehmann | db91915 | 2012-03-09 14:30:50 -0800 | [diff] [blame] | 5873 | * The phone number's E164 representation. This value can be omitted in which |
Makoto Onuki | e5420e9 | 2012-04-25 13:24:41 -0700 | [diff] [blame] | 5874 | * case the provider will try to automatically infer it. (It'll be left null if the |
| 5875 | * provider fails to infer.) |
| 5876 | * If present, {@link #NUMBER} has to be set as well (it will be ignored otherwise). |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 5877 | * <P>Type: TEXT</P> |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 5878 | */ |
| 5879 | public static final String NORMALIZED_NUMBER = DATA4; |
| 5880 | |
| 5881 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5882 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5883 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5884 | */ |
| 5885 | @Deprecated |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5886 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 5887 | CharSequence label, CharSequence[] labelArray) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5888 | return getTypeLabel(context.getResources(), type, label); |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5889 | } |
| 5890 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5891 | /** |
| 5892 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5893 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5894 | */ |
| 5895 | @Deprecated |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5896 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 5897 | CharSequence label) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5898 | return getTypeLabel(context.getResources(), type, label); |
| 5899 | } |
| 5900 | |
| 5901 | /** |
| 5902 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5903 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5904 | */ |
| 5905 | public static final int getTypeLabelResource(int type) { |
| 5906 | switch (type) { |
| 5907 | case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome; |
| 5908 | case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile; |
| 5909 | case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork; |
| 5910 | case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork; |
| 5911 | case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome; |
| 5912 | case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager; |
| 5913 | case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther; |
| 5914 | case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback; |
| 5915 | case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar; |
| 5916 | case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain; |
| 5917 | case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn; |
| 5918 | case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain; |
| 5919 | case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax; |
| 5920 | case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio; |
| 5921 | case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex; |
| 5922 | case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd; |
| 5923 | case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile; |
| 5924 | case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager; |
| 5925 | case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant; |
| 5926 | case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms; |
| 5927 | default: return com.android.internal.R.string.phoneTypeCustom; |
| 5928 | } |
| 5929 | } |
| 5930 | |
| 5931 | /** |
| 5932 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5933 | * possibly substituting the given {@link #LABEL} value |
| 5934 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5935 | */ |
| 5936 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 5937 | CharSequence label) { |
| 5938 | if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) { |
| 5939 | return label; |
| 5940 | } else { |
| 5941 | final int labelRes = getTypeLabelResource(type); |
| 5942 | return res.getText(labelRes); |
| 5943 | } |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5944 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5945 | } |
| 5946 | |
| 5947 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5948 | * <p> |
| 5949 | * A data kind representing an email address. |
| 5950 | * </p> |
| 5951 | * <p> |
| 5952 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5953 | * well as the following aliases. |
| 5954 | * </p> |
| 5955 | * <h2>Column aliases</h2> |
| 5956 | * <table class="jd-sumtable"> |
| 5957 | * <tr> |
| 5958 | * <th>Type</th> |
| 5959 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5960 | * </tr> |
| 5961 | * <tr> |
| 5962 | * <td>String</td> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 5963 | * <td>{@link #ADDRESS}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5964 | * <td>{@link #DATA1}</td> |
| 5965 | * <td>Email address itself.</td> |
| 5966 | * </tr> |
| 5967 | * <tr> |
| 5968 | * <td>int</td> |
| 5969 | * <td>{@link #TYPE}</td> |
| 5970 | * <td>{@link #DATA2}</td> |
| 5971 | * <td>Allowed values are: |
| 5972 | * <p> |
| 5973 | * <ul> |
| 5974 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5975 | * <li>{@link #TYPE_HOME}</li> |
| 5976 | * <li>{@link #TYPE_WORK}</li> |
| 5977 | * <li>{@link #TYPE_OTHER}</li> |
| 5978 | * <li>{@link #TYPE_MOBILE}</li> |
| 5979 | * </ul> |
| 5980 | * </p> |
| 5981 | * </td> |
| 5982 | * </tr> |
| 5983 | * <tr> |
| 5984 | * <td>String</td> |
| 5985 | * <td>{@link #LABEL}</td> |
| 5986 | * <td>{@link #DATA3}</td> |
| 5987 | * <td></td> |
| 5988 | * </tr> |
| 5989 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5990 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 5991 | public static final class Email implements DataColumnsWithJoins, CommonColumns, |
| 5992 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5993 | /** |
| 5994 | * This utility class cannot be instantiated |
| 5995 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5996 | private Email() {} |
| 5997 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5998 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5999 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6000 | |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6001 | /** |
Dmitri Plotnikov | abf15c3 | 2009-09-18 20:29:11 -0700 | [diff] [blame] | 6002 | * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses. |
| 6003 | */ |
| 6004 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2"; |
| 6005 | |
| 6006 | /** |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6007 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6008 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6009 | * associated raw contact and aggregate contact data. |
| 6010 | */ |
| 6011 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6012 | "emails"); |
| 6013 | |
| 6014 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6015 | * <p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6016 | * The content:// style URL for looking up data rows by email address. The |
| 6017 | * lookup argument, an email address, should be passed as an additional path segment |
| 6018 | * after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6019 | * </p> |
| 6020 | * <p>Example: |
| 6021 | * <pre> |
| 6022 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email)); |
| 6023 | * Cursor c = getContentResolver().query(uri, |
| 6024 | * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA}, |
| 6025 | * null, null, null); |
| 6026 | * </pre> |
| 6027 | * </p> |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6028 | */ |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6029 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 6030 | "lookup"); |
| 6031 | |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6032 | /** |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 6033 | * <p>URI used for enterprise email lookup.</p> |
| 6034 | * |
| 6035 | * <p> |
| 6036 | * It supports the same semantics as {@link #CONTENT_LOOKUP_URI} and returns the same |
| 6037 | * columns. If the device has no corp profile that is linked to the current profile, it |
| 6038 | * behaves in the exact same way as {@link #CONTENT_LOOKUP_URI}. If there is a |
| 6039 | * corp profile linked to the current profile, it first queries against the personal contact database, |
| 6040 | * and if no matching contacts are found there, then queries against the |
| 6041 | * corp contacts database. |
| 6042 | * </p> |
| 6043 | * <p> |
| 6044 | * If a result is from the corp profile, it makes the following changes to the data: |
| 6045 | * <ul> |
| 6046 | * <li> |
| 6047 | * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special |
| 6048 | * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to |
| 6049 | * load pictures from them. |
| 6050 | * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not |
| 6051 | * use them. |
| 6052 | * </li> |
| 6053 | * <li> |
| 6054 | * Corp contacts will get artificial {@link #CONTACT_ID}s. In order to tell whether |
| 6055 | * a contact |
| 6056 | * is from the corp profile, use |
| 6057 | * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}. |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 6058 | * </li> |
| 6059 | * <li> |
| 6060 | * Corp contacts will get artificial {@link #LOOKUP_KEY}s too. |
| 6061 | * </li> |
| 6062 | * </ul> |
| 6063 | * <p> |
| 6064 | * A contact lookup URL built by |
| 6065 | * {@link ContactsContract.Contacts#getLookupUri(long, String)} |
| 6066 | * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to |
| 6067 | * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the |
| 6068 | * corp profile. |
| 6069 | * </p> |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 6070 | * |
| 6071 | * <pre> |
| 6072 | * Uri lookupUri = Uri.withAppendedPath(Email.ENTERPRISE_CONTENT_LOOKUP_URI, |
| 6073 | * Uri.encode(email)); |
| 6074 | * </pre> |
| 6075 | */ |
| 6076 | public static final Uri ENTERPRISE_CONTENT_LOOKUP_URI = |
| 6077 | Uri.withAppendedPath(CONTENT_URI, "lookup_enterprise"); |
| 6078 | |
| 6079 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6080 | * <p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6081 | * The content:// style URL for email lookup using a filter. The filter returns |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6082 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6083 | * to display names as well as email addresses. The filter argument should be passed |
| 6084 | * as an additional path segment after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6085 | * </p> |
| 6086 | * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)" |
| 6087 | * as well as "Bob Parr (incredible@android.com)". |
| 6088 | * <pre> |
| 6089 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob")); |
| 6090 | * Cursor c = getContentResolver().query(uri, |
| 6091 | * new String[]{Email.DISPLAY_NAME, Email.DATA}, |
| 6092 | * null, null, null); |
| 6093 | * </pre> |
| 6094 | * </p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6095 | */ |
| 6096 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6097 | "filter"); |
| 6098 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6099 | /** |
| 6100 | * The email address. |
| 6101 | * <P>Type: TEXT</P> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6102 | */ |
| 6103 | public static final String ADDRESS = DATA1; |
| 6104 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6105 | public static final int TYPE_HOME = 1; |
| 6106 | public static final int TYPE_WORK = 2; |
| 6107 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 14fb153 | 2009-08-29 15:54:26 -0700 | [diff] [blame] | 6108 | public static final int TYPE_MOBILE = 4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6109 | |
| 6110 | /** |
| 6111 | * The display name for the email address |
| 6112 | * <P>Type: TEXT</P> |
| 6113 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6114 | public static final String DISPLAY_NAME = DATA4; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6115 | |
| 6116 | /** |
| 6117 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6118 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6119 | */ |
| 6120 | public static final int getTypeLabelResource(int type) { |
| 6121 | switch (type) { |
| 6122 | case TYPE_HOME: return com.android.internal.R.string.emailTypeHome; |
| 6123 | case TYPE_WORK: return com.android.internal.R.string.emailTypeWork; |
| 6124 | case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther; |
| 6125 | case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile; |
| 6126 | default: return com.android.internal.R.string.emailTypeCustom; |
| 6127 | } |
| 6128 | } |
| 6129 | |
| 6130 | /** |
| 6131 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6132 | * possibly substituting the given {@link #LABEL} value |
| 6133 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6134 | */ |
| 6135 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6136 | CharSequence label) { |
| 6137 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6138 | return label; |
| 6139 | } else { |
| 6140 | final int labelRes = getTypeLabelResource(type); |
| 6141 | return res.getText(labelRes); |
| 6142 | } |
| 6143 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6144 | } |
| 6145 | |
| 6146 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6147 | * <p> |
| 6148 | * A data kind representing a postal addresses. |
| 6149 | * </p> |
| 6150 | * <p> |
| 6151 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6152 | * well as the following aliases. |
| 6153 | * </p> |
| 6154 | * <h2>Column aliases</h2> |
| 6155 | * <table class="jd-sumtable"> |
| 6156 | * <tr> |
| 6157 | * <th>Type</th> |
| 6158 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6159 | * </tr> |
| 6160 | * <tr> |
| 6161 | * <td>String</td> |
| 6162 | * <td>{@link #FORMATTED_ADDRESS}</td> |
| 6163 | * <td>{@link #DATA1}</td> |
| 6164 | * <td></td> |
| 6165 | * </tr> |
| 6166 | * <tr> |
| 6167 | * <td>int</td> |
| 6168 | * <td>{@link #TYPE}</td> |
| 6169 | * <td>{@link #DATA2}</td> |
| 6170 | * <td>Allowed values are: |
| 6171 | * <p> |
| 6172 | * <ul> |
| 6173 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6174 | * <li>{@link #TYPE_HOME}</li> |
| 6175 | * <li>{@link #TYPE_WORK}</li> |
| 6176 | * <li>{@link #TYPE_OTHER}</li> |
| 6177 | * </ul> |
| 6178 | * </p> |
| 6179 | * </td> |
| 6180 | * </tr> |
| 6181 | * <tr> |
| 6182 | * <td>String</td> |
| 6183 | * <td>{@link #LABEL}</td> |
| 6184 | * <td>{@link #DATA3}</td> |
| 6185 | * <td></td> |
| 6186 | * </tr> |
| 6187 | * <tr> |
| 6188 | * <td>String</td> |
| 6189 | * <td>{@link #STREET}</td> |
| 6190 | * <td>{@link #DATA4}</td> |
| 6191 | * <td></td> |
| 6192 | * </tr> |
| 6193 | * <tr> |
| 6194 | * <td>String</td> |
| 6195 | * <td>{@link #POBOX}</td> |
| 6196 | * <td>{@link #DATA5}</td> |
| 6197 | * <td>Post Office Box number</td> |
| 6198 | * </tr> |
| 6199 | * <tr> |
| 6200 | * <td>String</td> |
| 6201 | * <td>{@link #NEIGHBORHOOD}</td> |
| 6202 | * <td>{@link #DATA6}</td> |
| 6203 | * <td></td> |
| 6204 | * </tr> |
| 6205 | * <tr> |
| 6206 | * <td>String</td> |
| 6207 | * <td>{@link #CITY}</td> |
| 6208 | * <td>{@link #DATA7}</td> |
| 6209 | * <td></td> |
| 6210 | * </tr> |
| 6211 | * <tr> |
| 6212 | * <td>String</td> |
| 6213 | * <td>{@link #REGION}</td> |
| 6214 | * <td>{@link #DATA8}</td> |
| 6215 | * <td></td> |
| 6216 | * </tr> |
| 6217 | * <tr> |
| 6218 | * <td>String</td> |
| 6219 | * <td>{@link #POSTCODE}</td> |
| 6220 | * <td>{@link #DATA9}</td> |
| 6221 | * <td></td> |
| 6222 | * </tr> |
| 6223 | * <tr> |
| 6224 | * <td>String</td> |
| 6225 | * <td>{@link #COUNTRY}</td> |
| 6226 | * <td>{@link #DATA10}</td> |
| 6227 | * <td></td> |
| 6228 | * </tr> |
| 6229 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6230 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6231 | public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns, |
| 6232 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6233 | /** |
| 6234 | * This utility class cannot be instantiated |
| 6235 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6236 | private StructuredPostal() { |
| 6237 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6238 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6239 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6240 | public static final String CONTENT_ITEM_TYPE = |
| 6241 | "vnd.android.cursor.item/postal-address_v2"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6242 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6243 | /** |
| 6244 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 6245 | * postal addresses. |
| 6246 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6247 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2"; |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6248 | |
| 6249 | /** |
| 6250 | * The content:// style URI for all data records of the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6251 | * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6252 | */ |
| 6253 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6254 | "postals"); |
| 6255 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6256 | public static final int TYPE_HOME = 1; |
| 6257 | public static final int TYPE_WORK = 2; |
| 6258 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6259 | |
| 6260 | /** |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 6261 | * The full, unstructured postal address. <i>This field must be |
| 6262 | * consistent with any structured data.</i> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6263 | * <p> |
| 6264 | * Type: TEXT |
| 6265 | */ |
| 6266 | public static final String FORMATTED_ADDRESS = DATA; |
| 6267 | |
| 6268 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6269 | * Can be street, avenue, road, etc. This element also includes the |
| 6270 | * house number and room/apartment/flat/floor number. |
| 6271 | * <p> |
| 6272 | * Type: TEXT |
| 6273 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6274 | public static final String STREET = DATA4; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6275 | |
| 6276 | /** |
| 6277 | * Covers actual P.O. boxes, drawers, locked bags, etc. This is |
| 6278 | * usually but not always mutually exclusive with street. |
| 6279 | * <p> |
| 6280 | * Type: TEXT |
| 6281 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6282 | public static final String POBOX = DATA5; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6283 | |
| 6284 | /** |
| 6285 | * This is used to disambiguate a street address when a city |
| 6286 | * contains more than one street with the same name, or to specify a |
| 6287 | * small place whose mail is routed through a larger postal town. In |
| 6288 | * China it could be a county or a minor city. |
| 6289 | * <p> |
| 6290 | * Type: TEXT |
| 6291 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6292 | public static final String NEIGHBORHOOD = DATA6; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6293 | |
| 6294 | /** |
| 6295 | * Can be city, village, town, borough, etc. This is the postal town |
| 6296 | * and not necessarily the place of residence or place of business. |
| 6297 | * <p> |
| 6298 | * Type: TEXT |
| 6299 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6300 | public static final String CITY = DATA7; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6301 | |
| 6302 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6303 | * A state, province, county (in Ireland), Land (in Germany), |
| 6304 | * departement (in France), etc. |
| 6305 | * <p> |
| 6306 | * Type: TEXT |
| 6307 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6308 | public static final String REGION = DATA8; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6309 | |
| 6310 | /** |
Jeff Sharkey | ef348c7 | 2009-07-26 14:14:34 -0700 | [diff] [blame] | 6311 | * Postal code. Usually country-wide, but sometimes specific to the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6312 | * city (e.g. "2" in "Dublin 2, Ireland" addresses). |
| 6313 | * <p> |
| 6314 | * Type: TEXT |
| 6315 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6316 | public static final String POSTCODE = DATA9; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6317 | |
| 6318 | /** |
| 6319 | * The name or code of the country. |
| 6320 | * <p> |
| 6321 | * Type: TEXT |
| 6322 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6323 | public static final String COUNTRY = DATA10; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6324 | |
| 6325 | /** |
| 6326 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6327 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6328 | */ |
| 6329 | public static final int getTypeLabelResource(int type) { |
| 6330 | switch (type) { |
| 6331 | case TYPE_HOME: return com.android.internal.R.string.postalTypeHome; |
| 6332 | case TYPE_WORK: return com.android.internal.R.string.postalTypeWork; |
| 6333 | case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther; |
| 6334 | default: return com.android.internal.R.string.postalTypeCustom; |
| 6335 | } |
| 6336 | } |
| 6337 | |
| 6338 | /** |
| 6339 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6340 | * possibly substituting the given {@link #LABEL} value |
| 6341 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6342 | */ |
| 6343 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6344 | CharSequence label) { |
| 6345 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6346 | return label; |
| 6347 | } else { |
| 6348 | final int labelRes = getTypeLabelResource(type); |
| 6349 | return res.getText(labelRes); |
| 6350 | } |
| 6351 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6352 | } |
| 6353 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6354 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6355 | * <p> |
| 6356 | * A data kind representing an IM address |
| 6357 | * </p> |
| 6358 | * <p> |
| 6359 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6360 | * well as the following aliases. |
| 6361 | * </p> |
| 6362 | * <h2>Column aliases</h2> |
| 6363 | * <table class="jd-sumtable"> |
| 6364 | * <tr> |
| 6365 | * <th>Type</th> |
| 6366 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6367 | * </tr> |
| 6368 | * <tr> |
| 6369 | * <td>String</td> |
| 6370 | * <td>{@link #DATA}</td> |
| 6371 | * <td>{@link #DATA1}</td> |
| 6372 | * <td></td> |
| 6373 | * </tr> |
| 6374 | * <tr> |
| 6375 | * <td>int</td> |
| 6376 | * <td>{@link #TYPE}</td> |
| 6377 | * <td>{@link #DATA2}</td> |
| 6378 | * <td>Allowed values are: |
| 6379 | * <p> |
| 6380 | * <ul> |
| 6381 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6382 | * <li>{@link #TYPE_HOME}</li> |
| 6383 | * <li>{@link #TYPE_WORK}</li> |
| 6384 | * <li>{@link #TYPE_OTHER}</li> |
| 6385 | * </ul> |
| 6386 | * </p> |
| 6387 | * </td> |
| 6388 | * </tr> |
| 6389 | * <tr> |
| 6390 | * <td>String</td> |
| 6391 | * <td>{@link #LABEL}</td> |
| 6392 | * <td>{@link #DATA3}</td> |
| 6393 | * <td></td> |
| 6394 | * </tr> |
| 6395 | * <tr> |
| 6396 | * <td>String</td> |
| 6397 | * <td>{@link #PROTOCOL}</td> |
| 6398 | * <td>{@link #DATA5}</td> |
| 6399 | * <td> |
| 6400 | * <p> |
| 6401 | * Allowed values: |
| 6402 | * <ul> |
| 6403 | * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name |
| 6404 | * as {@link #CUSTOM_PROTOCOL}.</li> |
| 6405 | * <li>{@link #PROTOCOL_AIM}</li> |
| 6406 | * <li>{@link #PROTOCOL_MSN}</li> |
| 6407 | * <li>{@link #PROTOCOL_YAHOO}</li> |
| 6408 | * <li>{@link #PROTOCOL_SKYPE}</li> |
| 6409 | * <li>{@link #PROTOCOL_QQ}</li> |
| 6410 | * <li>{@link #PROTOCOL_GOOGLE_TALK}</li> |
| 6411 | * <li>{@link #PROTOCOL_ICQ}</li> |
| 6412 | * <li>{@link #PROTOCOL_JABBER}</li> |
| 6413 | * <li>{@link #PROTOCOL_NETMEETING}</li> |
| 6414 | * </ul> |
| 6415 | * </p> |
| 6416 | * </td> |
| 6417 | * </tr> |
| 6418 | * <tr> |
| 6419 | * <td>String</td> |
| 6420 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 6421 | * <td>{@link #DATA6}</td> |
| 6422 | * <td></td> |
| 6423 | * </tr> |
| 6424 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6425 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6426 | public static final class Im implements DataColumnsWithJoins, CommonColumns, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6427 | /** |
| 6428 | * This utility class cannot be instantiated |
| 6429 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6430 | private Im() {} |
| 6431 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6432 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6433 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; |
| 6434 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6435 | public static final int TYPE_HOME = 1; |
| 6436 | public static final int TYPE_WORK = 2; |
| 6437 | public static final int TYPE_OTHER = 3; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6438 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 6439 | /** |
| 6440 | * This column should be populated with one of the defined |
| 6441 | * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this |
| 6442 | * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL} |
| 6443 | * should contain the name of the custom protocol. |
| 6444 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6445 | public static final String PROTOCOL = DATA5; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6446 | |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6447 | public static final String CUSTOM_PROTOCOL = DATA6; |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 6448 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 6449 | /* |
| 6450 | * The predefined IM protocol types. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6451 | */ |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 6452 | public static final int PROTOCOL_CUSTOM = -1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6453 | public static final int PROTOCOL_AIM = 0; |
| 6454 | public static final int PROTOCOL_MSN = 1; |
| 6455 | public static final int PROTOCOL_YAHOO = 2; |
| 6456 | public static final int PROTOCOL_SKYPE = 3; |
| 6457 | public static final int PROTOCOL_QQ = 4; |
| 6458 | public static final int PROTOCOL_GOOGLE_TALK = 5; |
| 6459 | public static final int PROTOCOL_ICQ = 6; |
| 6460 | public static final int PROTOCOL_JABBER = 7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6461 | public static final int PROTOCOL_NETMEETING = 8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6462 | |
| 6463 | /** |
| 6464 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6465 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6466 | */ |
| 6467 | public static final int getTypeLabelResource(int type) { |
| 6468 | switch (type) { |
| 6469 | case TYPE_HOME: return com.android.internal.R.string.imTypeHome; |
| 6470 | case TYPE_WORK: return com.android.internal.R.string.imTypeWork; |
| 6471 | case TYPE_OTHER: return com.android.internal.R.string.imTypeOther; |
| 6472 | default: return com.android.internal.R.string.imTypeCustom; |
| 6473 | } |
| 6474 | } |
| 6475 | |
| 6476 | /** |
| 6477 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6478 | * possibly substituting the given {@link #LABEL} value |
| 6479 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6480 | */ |
| 6481 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6482 | CharSequence label) { |
| 6483 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6484 | return label; |
| 6485 | } else { |
| 6486 | final int labelRes = getTypeLabelResource(type); |
| 6487 | return res.getText(labelRes); |
| 6488 | } |
| 6489 | } |
| 6490 | |
| 6491 | /** |
| 6492 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6493 | * {@link #PROTOCOL}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6494 | */ |
| 6495 | public static final int getProtocolLabelResource(int type) { |
| 6496 | switch (type) { |
| 6497 | case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim; |
| 6498 | case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn; |
| 6499 | case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo; |
| 6500 | case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype; |
| 6501 | case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq; |
| 6502 | case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk; |
| 6503 | case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq; |
| 6504 | case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber; |
| 6505 | case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting; |
| 6506 | default: return com.android.internal.R.string.imProtocolCustom; |
| 6507 | } |
| 6508 | } |
| 6509 | |
| 6510 | /** |
| 6511 | * Return a {@link CharSequence} that best describes the given |
| 6512 | * protocol, possibly substituting the given |
| 6513 | * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}. |
| 6514 | */ |
| 6515 | public static final CharSequence getProtocolLabel(Resources res, int type, |
| 6516 | CharSequence label) { |
| 6517 | if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6518 | return label; |
| 6519 | } else { |
| 6520 | final int labelRes = getProtocolLabelResource(type); |
| 6521 | return res.getText(labelRes); |
| 6522 | } |
| 6523 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6524 | } |
| 6525 | |
| 6526 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6527 | * <p> |
| 6528 | * A data kind representing an organization. |
| 6529 | * </p> |
| 6530 | * <p> |
| 6531 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6532 | * well as the following aliases. |
| 6533 | * </p> |
| 6534 | * <h2>Column aliases</h2> |
| 6535 | * <table class="jd-sumtable"> |
| 6536 | * <tr> |
| 6537 | * <th>Type</th> |
| 6538 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6539 | * </tr> |
| 6540 | * <tr> |
| 6541 | * <td>String</td> |
| 6542 | * <td>{@link #COMPANY}</td> |
| 6543 | * <td>{@link #DATA1}</td> |
| 6544 | * <td></td> |
| 6545 | * </tr> |
| 6546 | * <tr> |
| 6547 | * <td>int</td> |
| 6548 | * <td>{@link #TYPE}</td> |
| 6549 | * <td>{@link #DATA2}</td> |
| 6550 | * <td>Allowed values are: |
| 6551 | * <p> |
| 6552 | * <ul> |
| 6553 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6554 | * <li>{@link #TYPE_WORK}</li> |
| 6555 | * <li>{@link #TYPE_OTHER}</li> |
| 6556 | * </ul> |
| 6557 | * </p> |
| 6558 | * </td> |
| 6559 | * </tr> |
| 6560 | * <tr> |
| 6561 | * <td>String</td> |
| 6562 | * <td>{@link #LABEL}</td> |
| 6563 | * <td>{@link #DATA3}</td> |
| 6564 | * <td></td> |
| 6565 | * </tr> |
| 6566 | * <tr> |
| 6567 | * <td>String</td> |
| 6568 | * <td>{@link #TITLE}</td> |
| 6569 | * <td>{@link #DATA4}</td> |
| 6570 | * <td></td> |
| 6571 | * </tr> |
| 6572 | * <tr> |
| 6573 | * <td>String</td> |
| 6574 | * <td>{@link #DEPARTMENT}</td> |
| 6575 | * <td>{@link #DATA5}</td> |
| 6576 | * <td></td> |
| 6577 | * </tr> |
| 6578 | * <tr> |
| 6579 | * <td>String</td> |
| 6580 | * <td>{@link #JOB_DESCRIPTION}</td> |
| 6581 | * <td>{@link #DATA6}</td> |
| 6582 | * <td></td> |
| 6583 | * </tr> |
| 6584 | * <tr> |
| 6585 | * <td>String</td> |
| 6586 | * <td>{@link #SYMBOL}</td> |
| 6587 | * <td>{@link #DATA7}</td> |
| 6588 | * <td></td> |
| 6589 | * </tr> |
| 6590 | * <tr> |
| 6591 | * <td>String</td> |
| 6592 | * <td>{@link #PHONETIC_NAME}</td> |
| 6593 | * <td>{@link #DATA8}</td> |
| 6594 | * <td></td> |
| 6595 | * </tr> |
| 6596 | * <tr> |
| 6597 | * <td>String</td> |
| 6598 | * <td>{@link #OFFICE_LOCATION}</td> |
| 6599 | * <td>{@link #DATA9}</td> |
| 6600 | * <td></td> |
| 6601 | * </tr> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 6602 | * <tr> |
| 6603 | * <td>String</td> |
| 6604 | * <td>PHONETIC_NAME_STYLE</td> |
| 6605 | * <td>{@link #DATA10}</td> |
| 6606 | * <td></td> |
| 6607 | * </tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6608 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6609 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6610 | public static final class Organization implements DataColumnsWithJoins, CommonColumns, |
| 6611 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6612 | /** |
| 6613 | * This utility class cannot be instantiated |
| 6614 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6615 | private Organization() {} |
| 6616 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6617 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6618 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; |
| 6619 | |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6620 | public static final int TYPE_WORK = 1; |
| 6621 | public static final int TYPE_OTHER = 2; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6622 | |
| 6623 | /** |
| 6624 | * The company as the user entered it. |
| 6625 | * <P>Type: TEXT</P> |
| 6626 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6627 | public static final String COMPANY = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6628 | |
| 6629 | /** |
| 6630 | * The position title at this company as the user entered it. |
| 6631 | * <P>Type: TEXT</P> |
| 6632 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6633 | public static final String TITLE = DATA4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6634 | |
| 6635 | /** |
| 6636 | * The department at this company as the user entered it. |
| 6637 | * <P>Type: TEXT</P> |
| 6638 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6639 | public static final String DEPARTMENT = DATA5; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6640 | |
| 6641 | /** |
| 6642 | * The job description at this company as the user entered it. |
| 6643 | * <P>Type: TEXT</P> |
| 6644 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6645 | public static final String JOB_DESCRIPTION = DATA6; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6646 | |
| 6647 | /** |
| 6648 | * The symbol of this company as the user entered it. |
| 6649 | * <P>Type: TEXT</P> |
| 6650 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6651 | public static final String SYMBOL = DATA7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6652 | |
| 6653 | /** |
| 6654 | * The phonetic name of this company as the user entered it. |
| 6655 | * <P>Type: TEXT</P> |
| 6656 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6657 | public static final String PHONETIC_NAME = DATA8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6658 | |
| 6659 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 6660 | * The office location of this organization. |
| 6661 | * <P>Type: TEXT</P> |
| 6662 | */ |
| 6663 | public static final String OFFICE_LOCATION = DATA9; |
| 6664 | |
| 6665 | /** |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 6666 | * The alphabet used for capturing the phonetic name. |
| 6667 | * See {@link ContactsContract.PhoneticNameStyle}. |
| 6668 | * @hide |
| 6669 | */ |
| 6670 | public static final String PHONETIC_NAME_STYLE = DATA10; |
| 6671 | |
| 6672 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6673 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6674 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6675 | */ |
| 6676 | public static final int getTypeLabelResource(int type) { |
| 6677 | switch (type) { |
| 6678 | case TYPE_WORK: return com.android.internal.R.string.orgTypeWork; |
| 6679 | case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther; |
| 6680 | default: return com.android.internal.R.string.orgTypeCustom; |
| 6681 | } |
| 6682 | } |
| 6683 | |
| 6684 | /** |
| 6685 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6686 | * possibly substituting the given {@link #LABEL} value |
| 6687 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6688 | */ |
| 6689 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6690 | CharSequence label) { |
| 6691 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6692 | return label; |
| 6693 | } else { |
| 6694 | final int labelRes = getTypeLabelResource(type); |
| 6695 | return res.getText(labelRes); |
| 6696 | } |
| 6697 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6698 | } |
| 6699 | |
| 6700 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6701 | * <p> |
| 6702 | * A data kind representing a relation. |
| 6703 | * </p> |
| 6704 | * <p> |
| 6705 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6706 | * well as the following aliases. |
| 6707 | * </p> |
| 6708 | * <h2>Column aliases</h2> |
| 6709 | * <table class="jd-sumtable"> |
| 6710 | * <tr> |
| 6711 | * <th>Type</th> |
| 6712 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6713 | * </tr> |
| 6714 | * <tr> |
| 6715 | * <td>String</td> |
| 6716 | * <td>{@link #NAME}</td> |
| 6717 | * <td>{@link #DATA1}</td> |
| 6718 | * <td></td> |
| 6719 | * </tr> |
| 6720 | * <tr> |
| 6721 | * <td>int</td> |
| 6722 | * <td>{@link #TYPE}</td> |
| 6723 | * <td>{@link #DATA2}</td> |
| 6724 | * <td>Allowed values are: |
| 6725 | * <p> |
| 6726 | * <ul> |
| 6727 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6728 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 6729 | * <li>{@link #TYPE_BROTHER}</li> |
| 6730 | * <li>{@link #TYPE_CHILD}</li> |
| 6731 | * <li>{@link #TYPE_DOMESTIC_PARTNER}</li> |
| 6732 | * <li>{@link #TYPE_FATHER}</li> |
| 6733 | * <li>{@link #TYPE_FRIEND}</li> |
| 6734 | * <li>{@link #TYPE_MANAGER}</li> |
| 6735 | * <li>{@link #TYPE_MOTHER}</li> |
| 6736 | * <li>{@link #TYPE_PARENT}</li> |
| 6737 | * <li>{@link #TYPE_PARTNER}</li> |
| 6738 | * <li>{@link #TYPE_REFERRED_BY}</li> |
| 6739 | * <li>{@link #TYPE_RELATIVE}</li> |
| 6740 | * <li>{@link #TYPE_SISTER}</li> |
| 6741 | * <li>{@link #TYPE_SPOUSE}</li> |
| 6742 | * </ul> |
| 6743 | * </p> |
| 6744 | * </td> |
| 6745 | * </tr> |
| 6746 | * <tr> |
| 6747 | * <td>String</td> |
| 6748 | * <td>{@link #LABEL}</td> |
| 6749 | * <td>{@link #DATA3}</td> |
| 6750 | * <td></td> |
| 6751 | * </tr> |
| 6752 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6753 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6754 | public static final class Relation implements DataColumnsWithJoins, CommonColumns, |
| 6755 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6756 | /** |
| 6757 | * This utility class cannot be instantiated |
| 6758 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6759 | private Relation() {} |
| 6760 | |
| 6761 | /** MIME type used when storing this in data table. */ |
| 6762 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; |
| 6763 | |
| 6764 | public static final int TYPE_ASSISTANT = 1; |
| 6765 | public static final int TYPE_BROTHER = 2; |
| 6766 | public static final int TYPE_CHILD = 3; |
| 6767 | public static final int TYPE_DOMESTIC_PARTNER = 4; |
| 6768 | public static final int TYPE_FATHER = 5; |
| 6769 | public static final int TYPE_FRIEND = 6; |
| 6770 | public static final int TYPE_MANAGER = 7; |
| 6771 | public static final int TYPE_MOTHER = 8; |
| 6772 | public static final int TYPE_PARENT = 9; |
| 6773 | public static final int TYPE_PARTNER = 10; |
| 6774 | public static final int TYPE_REFERRED_BY = 11; |
| 6775 | public static final int TYPE_RELATIVE = 12; |
| 6776 | public static final int TYPE_SISTER = 13; |
| 6777 | public static final int TYPE_SPOUSE = 14; |
| 6778 | |
| 6779 | /** |
| 6780 | * The name of the relative as the user entered it. |
| 6781 | * <P>Type: TEXT</P> |
| 6782 | */ |
| 6783 | public static final String NAME = DATA; |
Daniel Lehmann | 1fb39f0 | 2010-10-28 13:40:38 -0700 | [diff] [blame] | 6784 | |
| 6785 | /** |
| 6786 | * Return the string resource that best describes the given |
| 6787 | * {@link #TYPE}. Will always return a valid resource. |
| 6788 | */ |
| 6789 | public static final int getTypeLabelResource(int type) { |
| 6790 | switch (type) { |
| 6791 | case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant; |
| 6792 | case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother; |
| 6793 | case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild; |
| 6794 | case TYPE_DOMESTIC_PARTNER: |
| 6795 | return com.android.internal.R.string.relationTypeDomesticPartner; |
| 6796 | case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather; |
| 6797 | case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend; |
| 6798 | case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager; |
| 6799 | case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother; |
| 6800 | case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent; |
| 6801 | case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner; |
| 6802 | case TYPE_REFERRED_BY: |
| 6803 | return com.android.internal.R.string.relationTypeReferredBy; |
| 6804 | case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative; |
| 6805 | case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister; |
| 6806 | case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse; |
| 6807 | default: return com.android.internal.R.string.orgTypeCustom; |
| 6808 | } |
| 6809 | } |
| 6810 | |
| 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 = getTypeLabelResource(type); |
| 6822 | return res.getText(labelRes); |
| 6823 | } |
| 6824 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6825 | } |
| 6826 | |
| 6827 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6828 | * <p> |
| 6829 | * A data kind representing an event. |
| 6830 | * </p> |
| 6831 | * <p> |
| 6832 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6833 | * well as the following aliases. |
| 6834 | * </p> |
| 6835 | * <h2>Column aliases</h2> |
| 6836 | * <table class="jd-sumtable"> |
| 6837 | * <tr> |
| 6838 | * <th>Type</th> |
| 6839 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6840 | * </tr> |
| 6841 | * <tr> |
| 6842 | * <td>String</td> |
| 6843 | * <td>{@link #START_DATE}</td> |
| 6844 | * <td>{@link #DATA1}</td> |
| 6845 | * <td></td> |
| 6846 | * </tr> |
| 6847 | * <tr> |
| 6848 | * <td>int</td> |
| 6849 | * <td>{@link #TYPE}</td> |
| 6850 | * <td>{@link #DATA2}</td> |
| 6851 | * <td>Allowed values are: |
| 6852 | * <p> |
| 6853 | * <ul> |
| 6854 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6855 | * <li>{@link #TYPE_ANNIVERSARY}</li> |
| 6856 | * <li>{@link #TYPE_OTHER}</li> |
| 6857 | * <li>{@link #TYPE_BIRTHDAY}</li> |
| 6858 | * </ul> |
| 6859 | * </p> |
| 6860 | * </td> |
| 6861 | * </tr> |
| 6862 | * <tr> |
| 6863 | * <td>String</td> |
| 6864 | * <td>{@link #LABEL}</td> |
| 6865 | * <td>{@link #DATA3}</td> |
| 6866 | * <td></td> |
| 6867 | * </tr> |
| 6868 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6869 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6870 | public static final class Event implements DataColumnsWithJoins, CommonColumns, |
| 6871 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6872 | /** |
| 6873 | * This utility class cannot be instantiated |
| 6874 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6875 | private Event() {} |
| 6876 | |
| 6877 | /** MIME type used when storing this in data table. */ |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6878 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event"; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6879 | |
| 6880 | public static final int TYPE_ANNIVERSARY = 1; |
| 6881 | public static final int TYPE_OTHER = 2; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6882 | public static final int TYPE_BIRTHDAY = 3; |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6883 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6884 | /** |
| 6885 | * The event start date as the user entered it. |
| 6886 | * <P>Type: TEXT</P> |
| 6887 | */ |
| 6888 | public static final String START_DATE = DATA; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6889 | |
| 6890 | /** |
| 6891 | * Return the string resource that best describes the given |
| 6892 | * {@link #TYPE}. Will always return a valid resource. |
| 6893 | */ |
| 6894 | public static int getTypeResource(Integer type) { |
| 6895 | if (type == null) { |
| 6896 | return com.android.internal.R.string.eventTypeOther; |
| 6897 | } |
| 6898 | switch (type) { |
| 6899 | case TYPE_ANNIVERSARY: |
| 6900 | return com.android.internal.R.string.eventTypeAnniversary; |
| 6901 | case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday; |
| 6902 | case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther; |
Daniel Lehmann | dd384a7 | 2010-11-01 18:40:50 -0700 | [diff] [blame] | 6903 | default: return com.android.internal.R.string.eventTypeCustom; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6904 | } |
| 6905 | } |
Paul Soulos | 6b2dd63 | 2014-07-24 17:17:42 -0700 | [diff] [blame] | 6906 | |
| 6907 | /** |
| 6908 | * Return a {@link CharSequence} that best describes the given type, |
| 6909 | * possibly substituting the given {@link #LABEL} value |
| 6910 | * for {@link #TYPE_CUSTOM}. |
| 6911 | */ |
| 6912 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6913 | CharSequence label) { |
| 6914 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6915 | return label; |
| 6916 | } else { |
| 6917 | final int labelRes = getTypeResource(type); |
| 6918 | return res.getText(labelRes); |
| 6919 | } |
| 6920 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6921 | } |
| 6922 | |
| 6923 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6924 | * <p> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6925 | * A data kind representing a photo for the contact. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6926 | * </p> |
| 6927 | * <p> |
| 6928 | * Some sync adapters will choose to download photos in a separate |
| 6929 | * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1} |
| 6930 | * through {@link ContactsContract.Data#SYNC4} to store temporary |
| 6931 | * data, e.g. the image URL or ID, state of download, server-side version |
| 6932 | * of the image. It is allowed for the {@link #PHOTO} to be null. |
| 6933 | * </p> |
| 6934 | * <p> |
| 6935 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6936 | * well as the following aliases. |
| 6937 | * </p> |
| 6938 | * <h2>Column aliases</h2> |
| 6939 | * <table class="jd-sumtable"> |
| 6940 | * <tr> |
| 6941 | * <th>Type</th> |
| 6942 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6943 | * </tr> |
| 6944 | * <tr> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6945 | * <td>NUMBER</td> |
| 6946 | * <td>{@link #PHOTO_FILE_ID}</td> |
| 6947 | * <td>{@link #DATA14}</td> |
| 6948 | * <td>ID of the hi-res photo file.</td> |
| 6949 | * </tr> |
| 6950 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6951 | * <td>BLOB</td> |
| 6952 | * <td>{@link #PHOTO}</td> |
| 6953 | * <td>{@link #DATA15}</td> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6954 | * <td>By convention, binary data is stored in DATA15. The thumbnail of the |
| 6955 | * photo is stored in this column.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6956 | * </tr> |
| 6957 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6958 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6959 | public static final class Photo implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6960 | /** |
| 6961 | * This utility class cannot be instantiated |
| 6962 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6963 | private Photo() {} |
| 6964 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6965 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6966 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; |
| 6967 | |
| 6968 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6969 | * Photo file ID for the display photo of the raw contact. |
| 6970 | * See {@link ContactsContract.DisplayPhoto}. |
| 6971 | * <p> |
| 6972 | * Type: NUMBER |
| 6973 | */ |
| 6974 | public static final String PHOTO_FILE_ID = DATA14; |
| 6975 | |
| 6976 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 6977 | * Thumbnail photo of the raw contact. This is the raw bytes of an image |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 6978 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6979 | * <p> |
| 6980 | * Type: BLOB |
| 6981 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6982 | public static final String PHOTO = DATA15; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6983 | } |
| 6984 | |
| 6985 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6986 | * <p> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6987 | * Notes about the contact. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6988 | * </p> |
| 6989 | * <p> |
| 6990 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6991 | * well as the following aliases. |
| 6992 | * </p> |
| 6993 | * <h2>Column aliases</h2> |
| 6994 | * <table class="jd-sumtable"> |
| 6995 | * <tr> |
| 6996 | * <th>Type</th> |
| 6997 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6998 | * </tr> |
| 6999 | * <tr> |
| 7000 | * <td>String</td> |
| 7001 | * <td>{@link #NOTE}</td> |
| 7002 | * <td>{@link #DATA1}</td> |
| 7003 | * <td></td> |
| 7004 | * </tr> |
| 7005 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7006 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7007 | public static final class Note implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7008 | /** |
| 7009 | * This utility class cannot be instantiated |
| 7010 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7011 | private Note() {} |
| 7012 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7013 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7014 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; |
| 7015 | |
| 7016 | /** |
| 7017 | * The note text. |
| 7018 | * <P>Type: TEXT</P> |
| 7019 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7020 | public static final String NOTE = DATA1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7021 | } |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 7022 | |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 7023 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7024 | * <p> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7025 | * Group Membership. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7026 | * </p> |
| 7027 | * <p> |
| 7028 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7029 | * well as the following aliases. |
| 7030 | * </p> |
| 7031 | * <h2>Column aliases</h2> |
| 7032 | * <table class="jd-sumtable"> |
| 7033 | * <tr> |
| 7034 | * <th>Type</th> |
| 7035 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7036 | * </tr> |
| 7037 | * <tr> |
| 7038 | * <td>long</td> |
| 7039 | * <td>{@link #GROUP_ROW_ID}</td> |
| 7040 | * <td>{@link #DATA1}</td> |
| 7041 | * <td></td> |
| 7042 | * </tr> |
| 7043 | * <tr> |
| 7044 | * <td>String</td> |
| 7045 | * <td>{@link #GROUP_SOURCE_ID}</td> |
| 7046 | * <td>none</td> |
| 7047 | * <td> |
| 7048 | * <p> |
| 7049 | * The sourceid of the group that this group membership refers to. |
| 7050 | * Exactly one of this or {@link #GROUP_ROW_ID} must be set when |
| 7051 | * inserting a row. |
| 7052 | * </p> |
| 7053 | * <p> |
| 7054 | * If this field is specified, the provider will first try to |
| 7055 | * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group |
| 7056 | * is found, it will use the corresponding row id. If the group is not |
| 7057 | * found, it will create one. |
| 7058 | * </td> |
| 7059 | * </tr> |
| 7060 | * </table> |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7061 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7062 | public static final class GroupMembership implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7063 | /** |
| 7064 | * This utility class cannot be instantiated |
| 7065 | */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7066 | private GroupMembership() {} |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7067 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7068 | /** MIME type used when storing this in data table. */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7069 | public static final String CONTENT_ITEM_TYPE = |
| 7070 | "vnd.android.cursor.item/group_membership"; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7071 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7072 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 7073 | * The row id of the group that this group membership refers to. Exactly one of |
| 7074 | * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row. |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7075 | * <P>Type: INTEGER</P> |
| 7076 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7077 | public static final String GROUP_ROW_ID = DATA1; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7078 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7079 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 7080 | * The sourceid of the group that this group membership refers to. Exactly one of |
| 7081 | * this or {@link #GROUP_ROW_ID} must be set when inserting a row. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7082 | * <P>Type: TEXT</P> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7083 | */ |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 7084 | public static final String GROUP_SOURCE_ID = "group_sourceid"; |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7085 | } |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7086 | |
| 7087 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7088 | * <p> |
| 7089 | * A data kind representing a website related to the contact. |
| 7090 | * </p> |
| 7091 | * <p> |
| 7092 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7093 | * well as the following aliases. |
| 7094 | * </p> |
| 7095 | * <h2>Column aliases</h2> |
| 7096 | * <table class="jd-sumtable"> |
| 7097 | * <tr> |
| 7098 | * <th>Type</th> |
| 7099 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7100 | * </tr> |
| 7101 | * <tr> |
| 7102 | * <td>String</td> |
| 7103 | * <td>{@link #URL}</td> |
| 7104 | * <td>{@link #DATA1}</td> |
| 7105 | * <td></td> |
| 7106 | * </tr> |
| 7107 | * <tr> |
| 7108 | * <td>int</td> |
| 7109 | * <td>{@link #TYPE}</td> |
| 7110 | * <td>{@link #DATA2}</td> |
| 7111 | * <td>Allowed values are: |
| 7112 | * <p> |
| 7113 | * <ul> |
| 7114 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 7115 | * <li>{@link #TYPE_HOMEPAGE}</li> |
| 7116 | * <li>{@link #TYPE_BLOG}</li> |
| 7117 | * <li>{@link #TYPE_PROFILE}</li> |
| 7118 | * <li>{@link #TYPE_HOME}</li> |
| 7119 | * <li>{@link #TYPE_WORK}</li> |
| 7120 | * <li>{@link #TYPE_FTP}</li> |
| 7121 | * <li>{@link #TYPE_OTHER}</li> |
| 7122 | * </ul> |
| 7123 | * </p> |
| 7124 | * </td> |
| 7125 | * </tr> |
| 7126 | * <tr> |
| 7127 | * <td>String</td> |
| 7128 | * <td>{@link #LABEL}</td> |
| 7129 | * <td>{@link #DATA3}</td> |
| 7130 | * <td></td> |
| 7131 | * </tr> |
| 7132 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7133 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7134 | public static final class Website implements DataColumnsWithJoins, CommonColumns, |
| 7135 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7136 | /** |
| 7137 | * This utility class cannot be instantiated |
| 7138 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7139 | private Website() {} |
| 7140 | |
| 7141 | /** MIME type used when storing this in data table. */ |
| 7142 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; |
| 7143 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7144 | public static final int TYPE_HOMEPAGE = 1; |
| 7145 | public static final int TYPE_BLOG = 2; |
| 7146 | public static final int TYPE_PROFILE = 3; |
| 7147 | public static final int TYPE_HOME = 4; |
| 7148 | public static final int TYPE_WORK = 5; |
| 7149 | public static final int TYPE_FTP = 6; |
| 7150 | public static final int TYPE_OTHER = 7; |
| 7151 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7152 | /** |
| 7153 | * The website URL string. |
| 7154 | * <P>Type: TEXT</P> |
| 7155 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7156 | public static final String URL = DATA; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7157 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7158 | |
| 7159 | /** |
| 7160 | * <p> |
| 7161 | * A data kind representing a SIP address for the contact. |
| 7162 | * </p> |
| 7163 | * <p> |
| 7164 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7165 | * well as the following aliases. |
| 7166 | * </p> |
| 7167 | * <h2>Column aliases</h2> |
| 7168 | * <table class="jd-sumtable"> |
| 7169 | * <tr> |
| 7170 | * <th>Type</th> |
| 7171 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7172 | * </tr> |
| 7173 | * <tr> |
| 7174 | * <td>String</td> |
| 7175 | * <td>{@link #SIP_ADDRESS}</td> |
| 7176 | * <td>{@link #DATA1}</td> |
| 7177 | * <td></td> |
| 7178 | * </tr> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 7179 | * <tr> |
| 7180 | * <td>int</td> |
| 7181 | * <td>{@link #TYPE}</td> |
| 7182 | * <td>{@link #DATA2}</td> |
| 7183 | * <td>Allowed values are: |
| 7184 | * <p> |
| 7185 | * <ul> |
| 7186 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 7187 | * <li>{@link #TYPE_HOME}</li> |
| 7188 | * <li>{@link #TYPE_WORK}</li> |
| 7189 | * <li>{@link #TYPE_OTHER}</li> |
| 7190 | * </ul> |
| 7191 | * </p> |
| 7192 | * </td> |
| 7193 | * </tr> |
| 7194 | * <tr> |
| 7195 | * <td>String</td> |
| 7196 | * <td>{@link #LABEL}</td> |
| 7197 | * <td>{@link #DATA3}</td> |
| 7198 | * <td></td> |
| 7199 | * </tr> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7200 | * </table> |
| 7201 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7202 | public static final class SipAddress implements DataColumnsWithJoins, CommonColumns, |
| 7203 | ContactCounts { |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7204 | /** |
| 7205 | * This utility class cannot be instantiated |
| 7206 | */ |
| 7207 | private SipAddress() {} |
| 7208 | |
| 7209 | /** MIME type used when storing this in data table. */ |
| 7210 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address"; |
| 7211 | |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 7212 | public static final int TYPE_HOME = 1; |
| 7213 | public static final int TYPE_WORK = 2; |
| 7214 | public static final int TYPE_OTHER = 3; |
| 7215 | |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7216 | /** |
| 7217 | * The SIP address. |
| 7218 | * <P>Type: TEXT</P> |
| 7219 | */ |
| 7220 | public static final String SIP_ADDRESS = DATA1; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 7221 | // ...and TYPE and LABEL come from the CommonColumns interface. |
| 7222 | |
| 7223 | /** |
| 7224 | * Return the string resource that best describes the given |
| 7225 | * {@link #TYPE}. Will always return a valid resource. |
| 7226 | */ |
| 7227 | public static final int getTypeLabelResource(int type) { |
| 7228 | switch (type) { |
| 7229 | case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome; |
| 7230 | case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork; |
| 7231 | case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther; |
| 7232 | default: return com.android.internal.R.string.sipAddressTypeCustom; |
| 7233 | } |
| 7234 | } |
| 7235 | |
| 7236 | /** |
| 7237 | * Return a {@link CharSequence} that best describes the given type, |
| 7238 | * possibly substituting the given {@link #LABEL} value |
| 7239 | * for {@link #TYPE_CUSTOM}. |
| 7240 | */ |
| 7241 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 7242 | CharSequence label) { |
| 7243 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 7244 | return label; |
| 7245 | } else { |
| 7246 | final int labelRes = getTypeLabelResource(type); |
| 7247 | return res.getText(labelRes); |
| 7248 | } |
| 7249 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7250 | } |
Fred Quintana | 4923f1d | 2011-08-05 15:58:17 -0700 | [diff] [blame] | 7251 | |
| 7252 | /** |
| 7253 | * A data kind representing an Identity related to the contact. |
| 7254 | * <p> |
| 7255 | * This can be used as a signal by the aggregator to combine raw contacts into |
| 7256 | * contacts, e.g. if two contacts have Identity rows with |
| 7257 | * the same NAMESPACE and IDENTITY values the aggregator can know that they refer |
| 7258 | * to the same person. |
| 7259 | * </p> |
| 7260 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7261 | public static final class Identity implements DataColumnsWithJoins, ContactCounts { |
Fred Quintana | 4923f1d | 2011-08-05 15:58:17 -0700 | [diff] [blame] | 7262 | /** |
| 7263 | * This utility class cannot be instantiated |
| 7264 | */ |
| 7265 | private Identity() {} |
| 7266 | |
| 7267 | /** MIME type used when storing this in data table. */ |
| 7268 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity"; |
| 7269 | |
| 7270 | /** |
| 7271 | * The identity string. |
| 7272 | * <P>Type: TEXT</P> |
| 7273 | */ |
| 7274 | public static final String IDENTITY = DataColumns.DATA1; |
| 7275 | |
| 7276 | /** |
| 7277 | * The namespace of the identity string, e.g. "com.google" |
| 7278 | * <P>Type: TEXT</P> |
| 7279 | */ |
| 7280 | public static final String NAMESPACE = DataColumns.DATA2; |
| 7281 | } |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7282 | |
| 7283 | /** |
| 7284 | * <p> |
| 7285 | * Convenient functionalities for "callable" data. Note that, this is NOT a separate data |
| 7286 | * kind. |
| 7287 | * </p> |
| 7288 | * <p> |
| 7289 | * This URI allows the ContactsProvider to return a unified result for "callable" data |
| 7290 | * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the |
| 7291 | * current examples for "callable", but may be expanded to the other types. |
| 7292 | * </p> |
| 7293 | * <p> |
| 7294 | * Each returned row may have a different MIMETYPE and thus different interpretation for |
| 7295 | * each column. For example the meaning for {@link Phone}'s type is different than |
| 7296 | * {@link SipAddress}'s. |
| 7297 | * </p> |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7298 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7299 | public static final class Callable implements DataColumnsWithJoins, CommonColumns, |
| 7300 | ContactCounts { |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7301 | /** |
| 7302 | * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only |
| 7303 | * phone numbers. |
| 7304 | */ |
| 7305 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 7306 | "callables"); |
| 7307 | /** |
| 7308 | * Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable |
| 7309 | * data. |
| 7310 | */ |
| 7311 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 7312 | "filter"); |
| 7313 | } |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 7314 | |
| 7315 | /** |
| 7316 | * A special class of data items, used to refer to types of data that can be used to attempt |
| 7317 | * to start communicating with a person ({@link Phone} and {@link Email}). Note that this |
| 7318 | * is NOT a separate data kind. |
| 7319 | * |
| 7320 | * This URI allows the ContactsProvider to return a unified result for data items that users |
| 7321 | * can use to initiate communications with another contact. {@link Phone} and {@link Email} |
| 7322 | * are the current data types in this category. |
| 7323 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7324 | public static final class Contactables implements DataColumnsWithJoins, CommonColumns, |
| 7325 | ContactCounts { |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 7326 | /** |
| 7327 | * The content:// style URI for these data items, which requests a directory of data |
| 7328 | * rows matching the selection criteria. |
| 7329 | */ |
| 7330 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 7331 | "contactables"); |
| 7332 | |
| 7333 | /** |
| 7334 | * The content:// style URI for these data items, which allows for a query parameter to |
| 7335 | * be appended onto the end to filter for data items matching the query. |
| 7336 | */ |
| 7337 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 7338 | Contactables.CONTENT_URI, "filter"); |
| 7339 | |
| 7340 | /** |
| 7341 | * A boolean parameter for {@link Data#CONTENT_URI}. |
| 7342 | * This specifies whether or not the returned data items should be filtered to show |
| 7343 | * data items belonging to visible contacts only. |
| 7344 | */ |
| 7345 | public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; |
| 7346 | } |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7347 | } |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7348 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7349 | /** |
| 7350 | * @see Groups |
| 7351 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 7352 | protected interface GroupsColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7353 | /** |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 7354 | * The data set within the account that this group belongs to. This allows |
| 7355 | * multiple sync adapters for the same account type to distinguish between |
| 7356 | * each others' group data. |
| 7357 | * |
| 7358 | * This is empty by default, and is completely optional. It only needs to |
| 7359 | * be populated if multiple sync adapters are entering distinct group data |
| 7360 | * for the same account type and account name. |
| 7361 | * <P>Type: TEXT</P> |
| 7362 | */ |
| 7363 | public static final String DATA_SET = "data_set"; |
| 7364 | |
| 7365 | /** |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 7366 | * A concatenation of the account type and data set (delimited by a forward |
| 7367 | * slash) - if the data set is empty, this will be the same as the account |
| 7368 | * type. For applications that need to be aware of the data set, this can |
| 7369 | * be used instead of account type to distinguish sets of data. This is |
| 7370 | * never intended to be used for specifying accounts. |
| 7371 | * @hide |
| 7372 | */ |
| 7373 | public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; |
| 7374 | |
| 7375 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7376 | * The display title of this group. |
| 7377 | * <p> |
| 7378 | * Type: TEXT |
| 7379 | */ |
| 7380 | public static final String TITLE = "title"; |
| 7381 | |
| 7382 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7383 | * The package name to use when creating {@link Resources} objects for |
| 7384 | * this group. This value is only designed for use when building user |
| 7385 | * interfaces, and should not be used to infer the owner. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7386 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7387 | public static final String RES_PACKAGE = "res_package"; |
| 7388 | |
| 7389 | /** |
| 7390 | * The display title of this group to load as a resource from |
| 7391 | * {@link #RES_PACKAGE}, which may be localized. |
| 7392 | * <P>Type: TEXT</P> |
| 7393 | */ |
| 7394 | public static final String TITLE_RES = "title_res"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7395 | |
| 7396 | /** |
Dmitri Plotnikov | 02c5b45 | 2009-07-22 15:13:08 -0700 | [diff] [blame] | 7397 | * Notes about the group. |
| 7398 | * <p> |
| 7399 | * Type: TEXT |
| 7400 | */ |
| 7401 | public static final String NOTES = "notes"; |
| 7402 | |
| 7403 | /** |
| 7404 | * The ID of this group if it is a System Group, i.e. a group that has a special meaning |
| 7405 | * to the sync adapter, null otherwise. |
| 7406 | * <P>Type: TEXT</P> |
| 7407 | */ |
| 7408 | public static final String SYSTEM_ID = "system_id"; |
| 7409 | |
| 7410 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7411 | * The total number of {@link Contacts} that have |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7412 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7413 | * present when querying {@link Groups#CONTENT_SUMMARY_URI}. |
| 7414 | * <p> |
| 7415 | * Type: INTEGER |
| 7416 | */ |
| 7417 | public static final String SUMMARY_COUNT = "summ_count"; |
| 7418 | |
| 7419 | /** |
Daisuke Miyakawa | 15dec39 | 2011-07-23 11:39:23 -0700 | [diff] [blame] | 7420 | * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}. |
| 7421 | * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}. |
| 7422 | * |
| 7423 | * @hide |
| 7424 | */ |
| 7425 | public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT = |
| 7426 | "return_group_count_per_account"; |
| 7427 | |
| 7428 | /** |
| 7429 | * The total number of groups of the account that a group belongs to. |
| 7430 | * This column is available only when the parameter |
| 7431 | * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in |
| 7432 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 7433 | * |
| 7434 | * For example, when the account "A" has two groups "group1" and "group2", and the account |
| 7435 | * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for |
| 7436 | * "group3" returns "1" for this column. |
| 7437 | * |
| 7438 | * Note: This counts only non-favorites, non-auto-add, and not deleted groups. |
| 7439 | * |
| 7440 | * Type: INTEGER |
| 7441 | * @hide |
| 7442 | */ |
| 7443 | public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account"; |
| 7444 | |
| 7445 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7446 | * The total number of {@link Contacts} that have both |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7447 | * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7448 | * Read-only value that is only present when querying |
| 7449 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 7450 | * <p> |
| 7451 | * Type: INTEGER |
| 7452 | */ |
| 7453 | public static final String SUMMARY_WITH_PHONES = "summ_phones"; |
| 7454 | |
| 7455 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7456 | * Flag indicating if the contacts belonging to this group should be |
| 7457 | * visible in any user interface. |
| 7458 | * <p> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7459 | * Type: INTEGER (boolean) |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7460 | */ |
| 7461 | public static final String GROUP_VISIBLE = "group_visible"; |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 7462 | |
| 7463 | /** |
| 7464 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 7465 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7466 | * called on a group, it is marked for deletion. The sync adaptor |
| 7467 | * deletes the group on the server and then calls ContactResolver.delete |
| 7468 | * once more, this time setting the the |
| 7469 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to |
| 7470 | * finalize the data removal. |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 7471 | * <P>Type: INTEGER</P> |
| 7472 | */ |
| 7473 | public static final String DELETED = "deleted"; |
Jeff Sharkey | 403d7ac | 2009-08-16 16:34:35 -0700 | [diff] [blame] | 7474 | |
| 7475 | /** |
| 7476 | * Whether this group should be synced if the SYNC_EVERYTHING settings |
| 7477 | * is false for this group's account. |
| 7478 | * <p> |
| 7479 | * Type: INTEGER (boolean) |
| 7480 | */ |
| 7481 | public static final String SHOULD_SYNC = "should_sync"; |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 7482 | |
| 7483 | /** |
| 7484 | * Any newly created contacts will automatically be added to groups that have this |
| 7485 | * flag set to true. |
| 7486 | * <p> |
| 7487 | * Type: INTEGER (boolean) |
| 7488 | */ |
| 7489 | public static final String AUTO_ADD = "auto_add"; |
| 7490 | |
| 7491 | /** |
| 7492 | * When a contacts is marked as a favorites it will be automatically added |
| 7493 | * to the groups that have this flag set, and when it is removed from favorites |
| 7494 | * it will be removed from these groups. |
| 7495 | * <p> |
| 7496 | * Type: INTEGER (boolean) |
| 7497 | */ |
| 7498 | public static final String FAVORITES = "favorites"; |
Dmitri Plotnikov | 4ccf33a | 2010-11-19 11:10:43 -0800 | [diff] [blame] | 7499 | |
| 7500 | /** |
| 7501 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 7502 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 7503 | * <P>Type: INTEGER</P> |
| 7504 | */ |
| 7505 | public static final String GROUP_IS_READ_ONLY = "group_is_read_only"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7506 | } |
| 7507 | |
| 7508 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7509 | * Constants for the groups table. Only per-account groups are supported. |
| 7510 | * <h2>Columns</h2> |
| 7511 | * <table class="jd-sumtable"> |
| 7512 | * <tr> |
| 7513 | * <th colspan='4'>Groups</th> |
| 7514 | * </tr> |
| 7515 | * <tr> |
| 7516 | * <td>long</td> |
| 7517 | * <td>{@link #_ID}</td> |
| 7518 | * <td>read-only</td> |
| 7519 | * <td>Row ID. Sync adapter should try to preserve row IDs during updates. |
| 7520 | * In other words, it would be a really bad idea to delete and reinsert a |
| 7521 | * group. A sync adapter should always do an update instead.</td> |
| 7522 | * </tr> |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 7523 | # <tr> |
| 7524 | * <td>String</td> |
| 7525 | * <td>{@link #DATA_SET}</td> |
| 7526 | * <td>read/write-once</td> |
| 7527 | * <td> |
| 7528 | * <p> |
| 7529 | * The data set within the account that this group belongs to. This allows |
| 7530 | * multiple sync adapters for the same account type to distinguish between |
| 7531 | * each others' group data. The combination of {@link #ACCOUNT_TYPE}, |
| 7532 | * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data |
| 7533 | * that is associated with a single sync adapter. |
| 7534 | * </p> |
| 7535 | * <p> |
| 7536 | * This is empty by default, and is completely optional. It only needs to |
| 7537 | * be populated if multiple sync adapters are entering distinct data for |
| 7538 | * the same account type and account name. |
| 7539 | * </p> |
| 7540 | * <p> |
| 7541 | * It should be set at the time the group is inserted and never changed |
| 7542 | * afterwards. |
| 7543 | * </p> |
| 7544 | * </td> |
| 7545 | * </tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7546 | * <tr> |
| 7547 | * <td>String</td> |
| 7548 | * <td>{@link #TITLE}</td> |
| 7549 | * <td>read/write</td> |
| 7550 | * <td>The display title of this group.</td> |
| 7551 | * </tr> |
| 7552 | * <tr> |
| 7553 | * <td>String</td> |
| 7554 | * <td>{@link #NOTES}</td> |
| 7555 | * <td>read/write</td> |
| 7556 | * <td>Notes about the group.</td> |
| 7557 | * </tr> |
| 7558 | * <tr> |
| 7559 | * <td>String</td> |
| 7560 | * <td>{@link #SYSTEM_ID}</td> |
| 7561 | * <td>read/write</td> |
| 7562 | * <td>The ID of this group if it is a System Group, i.e. a group that has a |
| 7563 | * special meaning to the sync adapter, null otherwise.</td> |
| 7564 | * </tr> |
| 7565 | * <tr> |
| 7566 | * <td>int</td> |
| 7567 | * <td>{@link #SUMMARY_COUNT}</td> |
| 7568 | * <td>read-only</td> |
| 7569 | * <td>The total number of {@link Contacts} that have |
| 7570 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value |
| 7571 | * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 7572 | * </tr> |
| 7573 | * <tr> |
| 7574 | * <td>int</td> |
| 7575 | * <td>{@link #SUMMARY_WITH_PHONES}</td> |
| 7576 | * <td>read-only</td> |
| 7577 | * <td>The total number of {@link Contacts} that have both |
| 7578 | * {@link CommonDataKinds.GroupMembership} in this group, and also have |
| 7579 | * phone numbers. Read-only value that is only present when querying |
| 7580 | * {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 7581 | * </tr> |
| 7582 | * <tr> |
| 7583 | * <td>int</td> |
| 7584 | * <td>{@link #GROUP_VISIBLE}</td> |
| 7585 | * <td>read-only</td> |
| 7586 | * <td>Flag indicating if the contacts belonging to this group should be |
| 7587 | * visible in any user interface. Allowed values: 0 and 1.</td> |
| 7588 | * </tr> |
| 7589 | * <tr> |
| 7590 | * <td>int</td> |
| 7591 | * <td>{@link #DELETED}</td> |
| 7592 | * <td>read/write</td> |
| 7593 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 7594 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 7595 | * called on a group, it is marked for deletion. The sync adaptor deletes |
| 7596 | * the group on the server and then calls ContactResolver.delete once more, |
| 7597 | * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER} |
| 7598 | * query parameter to finalize the data removal.</td> |
| 7599 | * </tr> |
| 7600 | * <tr> |
| 7601 | * <td>int</td> |
| 7602 | * <td>{@link #SHOULD_SYNC}</td> |
| 7603 | * <td>read/write</td> |
| 7604 | * <td>Whether this group should be synced if the SYNC_EVERYTHING settings |
| 7605 | * is false for this group's account.</td> |
| 7606 | * </tr> |
| 7607 | * </table> |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7608 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7609 | public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7610 | /** |
| 7611 | * This utility class cannot be instantiated |
| 7612 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7613 | private Groups() { |
| 7614 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7615 | |
| 7616 | /** |
| 7617 | * The content:// style URI for this table |
| 7618 | */ |
| 7619 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); |
| 7620 | |
| 7621 | /** |
| 7622 | * The content:// style URI for this table joined with details data from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7623 | * {@link ContactsContract.Data}. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7624 | */ |
| 7625 | public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 7626 | "groups_summary"); |
| 7627 | |
| 7628 | /** |
| 7629 | * The MIME type of a directory of groups. |
| 7630 | */ |
| 7631 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; |
| 7632 | |
| 7633 | /** |
| 7634 | * The MIME type of a single group. |
| 7635 | */ |
| 7636 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7637 | |
| 7638 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 7639 | return new EntityIteratorImpl(cursor); |
| 7640 | } |
| 7641 | |
| 7642 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 7643 | public EntityIteratorImpl(Cursor cursor) { |
| 7644 | super(cursor); |
| 7645 | } |
| 7646 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 7647 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7648 | public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { |
| 7649 | // we expect the cursor is already at the row we need to read from |
| 7650 | final ContentValues values = new ContentValues(); |
| 7651 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID); |
| 7652 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME); |
| 7653 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE); |
| 7654 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY); |
| 7655 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION); |
| 7656 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID); |
| 7657 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE); |
| 7658 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE); |
| 7659 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES); |
| 7660 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE); |
| 7661 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1); |
| 7662 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2); |
| 7663 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3); |
| 7664 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4); |
| 7665 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID); |
| 7666 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED); |
| 7667 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES); |
| 7668 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC); |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 7669 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES); |
| 7670 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7671 | cursor.moveToNext(); |
| 7672 | return new Entity(values); |
| 7673 | } |
| 7674 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7675 | } |
| 7676 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7677 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7678 | * <p> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7679 | * Constants for the contact aggregation exceptions table, which contains |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7680 | * aggregation rules overriding those used by automatic aggregation. This |
| 7681 | * type only supports query and update. Neither insert nor delete are |
| 7682 | * supported. |
| 7683 | * </p> |
| 7684 | * <h2>Columns</h2> |
| 7685 | * <table class="jd-sumtable"> |
| 7686 | * <tr> |
| 7687 | * <th colspan='4'>AggregationExceptions</th> |
| 7688 | * </tr> |
| 7689 | * <tr> |
| 7690 | * <td>int</td> |
| 7691 | * <td>{@link #TYPE}</td> |
| 7692 | * <td>read/write</td> |
| 7693 | * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER}, |
| 7694 | * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td> |
| 7695 | * </tr> |
| 7696 | * <tr> |
| 7697 | * <td>long</td> |
| 7698 | * <td>{@link #RAW_CONTACT_ID1}</td> |
| 7699 | * <td>read/write</td> |
| 7700 | * <td>A reference to the {@link RawContacts#_ID} of the raw contact that |
| 7701 | * the rule applies to.</td> |
| 7702 | * </tr> |
| 7703 | * <tr> |
| 7704 | * <td>long</td> |
| 7705 | * <td>{@link #RAW_CONTACT_ID2}</td> |
| 7706 | * <td>read/write</td> |
| 7707 | * <td>A reference to the other {@link RawContacts#_ID} of the raw contact |
| 7708 | * that the rule applies to.</td> |
| 7709 | * </tr> |
| 7710 | * </table> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7711 | */ |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 7712 | public static final class AggregationExceptions implements BaseColumns { |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7713 | /** |
| 7714 | * This utility class cannot be instantiated |
| 7715 | */ |
| 7716 | private AggregationExceptions() {} |
| 7717 | |
| 7718 | /** |
| 7719 | * The content:// style URI for this table |
| 7720 | */ |
| 7721 | public static final Uri CONTENT_URI = |
| 7722 | Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); |
| 7723 | |
| 7724 | /** |
| 7725 | * The MIME type of {@link #CONTENT_URI} providing a directory of data. |
| 7726 | */ |
| 7727 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; |
| 7728 | |
| 7729 | /** |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 7730 | * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception |
| 7731 | */ |
| 7732 | public static final String CONTENT_ITEM_TYPE = |
| 7733 | "vnd.android.cursor.item/aggregation_exception"; |
| 7734 | |
| 7735 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7736 | * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7737 | * {@link #TYPE_AUTOMATIC}. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7738 | * |
| 7739 | * <P>Type: INTEGER</P> |
| 7740 | */ |
| 7741 | public static final String TYPE = "type"; |
| 7742 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7743 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7744 | * Allows the provider to automatically decide whether the specified raw contacts should |
| 7745 | * be included in the same aggregate contact or not. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7746 | */ |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7747 | public static final int TYPE_AUTOMATIC = 0; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7748 | |
| 7749 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7750 | * Makes sure that the specified raw contacts are included in the same |
| 7751 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7752 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7753 | public static final int TYPE_KEEP_TOGETHER = 1; |
| 7754 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7755 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7756 | * Makes sure that the specified raw contacts are NOT included in the same |
| 7757 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7758 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7759 | public static final int TYPE_KEEP_SEPARATE = 2; |
| 7760 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7761 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7762 | * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7763 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7764 | public static final String RAW_CONTACT_ID1 = "raw_contact_id1"; |
| 7765 | |
| 7766 | /** |
| 7767 | * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule |
| 7768 | * applies to. |
| 7769 | */ |
| 7770 | public static final String RAW_CONTACT_ID2 = "raw_contact_id2"; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7771 | } |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 7772 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7773 | /** |
| 7774 | * @see Settings |
| 7775 | */ |
Dmitri Plotnikov | fe4c871 | 2009-10-14 00:28:48 -0700 | [diff] [blame] | 7776 | protected interface SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7777 | /** |
| 7778 | * The name of the account instance to which this row belongs. |
| 7779 | * <P>Type: TEXT</P> |
| 7780 | */ |
| 7781 | public static final String ACCOUNT_NAME = "account_name"; |
| 7782 | |
| 7783 | /** |
| 7784 | * The type of account to which this row belongs, which when paired with |
| 7785 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 7786 | * <P>Type: TEXT</P> |
| 7787 | */ |
| 7788 | public static final String ACCOUNT_TYPE = "account_type"; |
| 7789 | |
| 7790 | /** |
Dave Santoro | 7c4479f | 2011-09-07 16:52:27 -0700 | [diff] [blame] | 7791 | * The data set within the account that this row belongs to. This allows |
| 7792 | * multiple sync adapters for the same account type to distinguish between |
| 7793 | * each others' data. |
| 7794 | * |
| 7795 | * This is empty by default, and is completely optional. It only needs to |
| 7796 | * be populated if multiple sync adapters are entering distinct data for |
| 7797 | * the same account type and account name. |
| 7798 | * <P>Type: TEXT</P> |
| 7799 | */ |
| 7800 | public static final String DATA_SET = "data_set"; |
| 7801 | |
| 7802 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7803 | * Depending on the mode defined by the sync-adapter, this flag controls |
| 7804 | * the top-level sync behavior for this data source. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7805 | * <p> |
| 7806 | * Type: INTEGER (boolean) |
| 7807 | */ |
| 7808 | public static final String SHOULD_SYNC = "should_sync"; |
| 7809 | |
| 7810 | /** |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7811 | * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership} |
Jeff Sharkey | a659744 | 2009-08-19 09:23:33 -0700 | [diff] [blame] | 7812 | * entries should be visible in any user interface. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7813 | * <p> |
| 7814 | * Type: INTEGER (boolean) |
| 7815 | */ |
| 7816 | public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7817 | |
| 7818 | /** |
Jeff Sharkey | 97bda4c | 2009-09-15 23:15:23 -0700 | [diff] [blame] | 7819 | * Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 7820 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 7821 | * unsynced. |
| 7822 | */ |
| 7823 | public static final String ANY_UNSYNCED = "any_unsynced"; |
| 7824 | |
| 7825 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7826 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 7827 | * no {@link CommonDataKinds.GroupMembership} entries. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7828 | * <p> |
| 7829 | * Type: INTEGER |
| 7830 | */ |
| 7831 | public static final String UNGROUPED_COUNT = "summ_count"; |
| 7832 | |
| 7833 | /** |
| 7834 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 7835 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7836 | * <p> |
| 7837 | * Type: INTEGER |
| 7838 | */ |
| 7839 | public static final String UNGROUPED_WITH_PHONES = "summ_phones"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7840 | } |
| 7841 | |
| 7842 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7843 | * <p> |
| 7844 | * Contacts-specific settings for various {@link Account}'s. |
| 7845 | * </p> |
| 7846 | * <h2>Columns</h2> |
| 7847 | * <table class="jd-sumtable"> |
| 7848 | * <tr> |
| 7849 | * <th colspan='4'>Settings</th> |
| 7850 | * </tr> |
| 7851 | * <tr> |
| 7852 | * <td>String</td> |
| 7853 | * <td>{@link #ACCOUNT_NAME}</td> |
| 7854 | * <td>read/write-once</td> |
| 7855 | * <td>The name of the account instance to which this row belongs.</td> |
| 7856 | * </tr> |
| 7857 | * <tr> |
| 7858 | * <td>String</td> |
| 7859 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 7860 | * <td>read/write-once</td> |
| 7861 | * <td>The type of account to which this row belongs, which when paired with |
| 7862 | * {@link #ACCOUNT_NAME} identifies a specific account.</td> |
| 7863 | * </tr> |
| 7864 | * <tr> |
| 7865 | * <td>int</td> |
| 7866 | * <td>{@link #SHOULD_SYNC}</td> |
| 7867 | * <td>read/write</td> |
| 7868 | * <td>Depending on the mode defined by the sync-adapter, this flag controls |
| 7869 | * the top-level sync behavior for this data source.</td> |
| 7870 | * </tr> |
| 7871 | * <tr> |
| 7872 | * <td>int</td> |
| 7873 | * <td>{@link #UNGROUPED_VISIBLE}</td> |
| 7874 | * <td>read/write</td> |
| 7875 | * <td>Flag indicating if contacts without any |
| 7876 | * {@link CommonDataKinds.GroupMembership} entries should be visible in any |
| 7877 | * user interface.</td> |
| 7878 | * </tr> |
| 7879 | * <tr> |
| 7880 | * <td>int</td> |
| 7881 | * <td>{@link #ANY_UNSYNCED}</td> |
| 7882 | * <td>read-only</td> |
| 7883 | * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 7884 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 7885 | * unsynced.</td> |
| 7886 | * </tr> |
| 7887 | * <tr> |
| 7888 | * <td>int</td> |
| 7889 | * <td>{@link #UNGROUPED_COUNT}</td> |
| 7890 | * <td>read-only</td> |
| 7891 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 7892 | * no {@link CommonDataKinds.GroupMembership} entries.</td> |
| 7893 | * </tr> |
| 7894 | * <tr> |
| 7895 | * <td>int</td> |
| 7896 | * <td>{@link #UNGROUPED_WITH_PHONES}</td> |
| 7897 | * <td>read-only</td> |
| 7898 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 7899 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone |
| 7900 | * numbers.</td> |
| 7901 | * </tr> |
| 7902 | * </table> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7903 | */ |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7904 | public static final class Settings implements SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7905 | /** |
| 7906 | * This utility class cannot be instantiated |
| 7907 | */ |
| 7908 | private Settings() { |
| 7909 | } |
| 7910 | |
| 7911 | /** |
| 7912 | * The content:// style URI for this table |
| 7913 | */ |
| 7914 | public static final Uri CONTENT_URI = |
| 7915 | Uri.withAppendedPath(AUTHORITY_URI, "settings"); |
| 7916 | |
| 7917 | /** |
| 7918 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 7919 | * settings. |
| 7920 | */ |
| 7921 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; |
| 7922 | |
| 7923 | /** |
| 7924 | * The MIME-type of {@link #CONTENT_URI} providing a single setting. |
| 7925 | */ |
| 7926 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7927 | } |
| 7928 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 7929 | /** |
Brian Attwell | cc4b2f7 | 2015-01-08 14:58:15 -0800 | [diff] [blame] | 7930 | * API for inquiring about the general status of the provider. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 7931 | */ |
| 7932 | public static final class ProviderStatus { |
| 7933 | |
| 7934 | /** |
| 7935 | * Not instantiable. |
| 7936 | */ |
| 7937 | private ProviderStatus() { |
| 7938 | } |
| 7939 | |
| 7940 | /** |
| 7941 | * The content:// style URI for this table. Requests to this URI can be |
| 7942 | * performed on the UI thread because they are always unblocking. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 7943 | */ |
| 7944 | public static final Uri CONTENT_URI = |
| 7945 | Uri.withAppendedPath(AUTHORITY_URI, "provider_status"); |
| 7946 | |
| 7947 | /** |
| 7948 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 7949 | * settings. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 7950 | */ |
| 7951 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status"; |
| 7952 | |
| 7953 | /** |
| 7954 | * An integer representing the current status of the provider. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 7955 | */ |
| 7956 | public static final String STATUS = "status"; |
| 7957 | |
| 7958 | /** |
| 7959 | * Default status of the provider. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 7960 | */ |
| 7961 | public static final int STATUS_NORMAL = 0; |
| 7962 | |
| 7963 | /** |
| 7964 | * The status used when the provider is in the process of upgrading. Contacts |
| 7965 | * are temporarily unaccessible. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 7966 | */ |
| 7967 | public static final int STATUS_UPGRADING = 1; |
| 7968 | |
| 7969 | /** |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 7970 | * The status used during a locale change. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 7971 | */ |
| 7972 | public static final int STATUS_CHANGING_LOCALE = 3; |
| 7973 | |
| 7974 | /** |
Dmitri Plotnikov | 37c3486 | 2010-11-12 16:12:53 -0800 | [diff] [blame] | 7975 | * The status that indicates that there are no accounts and no contacts |
| 7976 | * on the device. |
Dmitri Plotnikov | 37c3486 | 2010-11-12 16:12:53 -0800 | [diff] [blame] | 7977 | */ |
| 7978 | public static final int STATUS_NO_ACCOUNTS_NO_CONTACTS = 4; |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 7979 | } |
| 7980 | |
| 7981 | /** |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7982 | * <p> |
| 7983 | * API allowing applications to send usage information for each {@link Data} row to the |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 7984 | * Contacts Provider. Applications can also clear all usage information. |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7985 | * </p> |
| 7986 | * <p> |
| 7987 | * With the feedback, Contacts Provider may return more contextually appropriate results for |
| 7988 | * Data listing, typically supplied with |
| 7989 | * {@link ContactsContract.Contacts#CONTENT_FILTER_URI}, |
| 7990 | * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI}, |
| 7991 | * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit |
| 7992 | * from better ranked (sorted) lists in applications that show auto-complete list. |
| 7993 | * </p> |
| 7994 | * <p> |
| 7995 | * There is no guarantee for how this feedback is used, or even whether it is used at all. |
| 7996 | * The ranking algorithm will make best efforts to use the feedback data, but the exact |
| 7997 | * implementation, the storage data structures as well as the resulting sort order is device |
| 7998 | * and version specific and can change over time. |
| 7999 | * </p> |
| 8000 | * <p> |
| 8001 | * When updating usage information, users of this API need to use |
| 8002 | * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed |
| 8003 | * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as |
| 8004 | * its last path. They also need to append a query parameter to the Uri, to specify the type of |
| 8005 | * the communication, which enables the Contacts Provider to differentiate between kinds of |
| 8006 | * interactions using the same contact data field (for example a phone number can be used to |
| 8007 | * make phone calls or send SMS). |
| 8008 | * </p> |
| 8009 | * <p> |
| 8010 | * Selection and selectionArgs are ignored and must be set to null. To get data ids, |
| 8011 | * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)} |
| 8012 | * toward {@link Data#CONTENT_URI}. |
| 8013 | * </p> |
| 8014 | * <p> |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 8015 | * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive |
| 8016 | * integer when successful, and returns 0 if no contact with that id was found. |
| 8017 | * </p> |
| 8018 | * <p> |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8019 | * Example: |
| 8020 | * <pre> |
Daisuke Miyakawa | 52e3823 | 2011-06-14 10:56:46 -0700 | [diff] [blame] | 8021 | * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon() |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8022 | * .appendPath(TextUtils.join(",", dataIds)) |
Daisuke Miyakawa | 52e3823 | 2011-06-14 10:56:46 -0700 | [diff] [blame] | 8023 | * .appendQueryParameter(DataUsageFeedback.USAGE_TYPE, |
| 8024 | * DataUsageFeedback.USAGE_TYPE_CALL) |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8025 | * .build(); |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 8026 | * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0; |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8027 | * </pre> |
| 8028 | * </p> |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 8029 | * <p> |
| 8030 | * Applications can also clear all usage information with: |
| 8031 | * <pre> |
Makoto Onuki | 7ebbfd0 | 2012-04-13 12:56:42 -0700 | [diff] [blame] | 8032 | * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0; |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 8033 | * </pre> |
| 8034 | * </p> |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8035 | */ |
| 8036 | public static final class DataUsageFeedback { |
| 8037 | |
| 8038 | /** |
| 8039 | * The content:// style URI for sending usage feedback. |
| 8040 | * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}. |
| 8041 | */ |
| 8042 | public static final Uri FEEDBACK_URI = |
| 8043 | Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback"); |
| 8044 | |
| 8045 | /** |
Makoto Onuki | 7ebbfd0 | 2012-04-13 12:56:42 -0700 | [diff] [blame] | 8046 | * The content:// style URI for deleting all usage information. |
| 8047 | * Must be used with {@link ContentResolver#delete(Uri, String, String[])}. |
| 8048 | * The {@code where} and {@code selectionArgs} parameters are ignored. |
| 8049 | */ |
| 8050 | public static final Uri DELETE_USAGE_URI = |
| 8051 | Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage"); |
| 8052 | |
| 8053 | /** |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8054 | * <p> |
| 8055 | * Name for query parameter specifying the type of data usage. |
| 8056 | * </p> |
| 8057 | */ |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 8058 | public static final String USAGE_TYPE = "type"; |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8059 | |
| 8060 | /** |
| 8061 | * <p> |
| 8062 | * Type of usage for voice interaction, which includes phone call, voice chat, and |
| 8063 | * video chat. |
| 8064 | * </p> |
| 8065 | */ |
| 8066 | public static final String USAGE_TYPE_CALL = "call"; |
| 8067 | |
| 8068 | /** |
| 8069 | * <p> |
| 8070 | * Type of usage for text interaction involving longer messages, which includes email. |
| 8071 | * </p> |
| 8072 | */ |
| 8073 | public static final String USAGE_TYPE_LONG_TEXT = "long_text"; |
| 8074 | |
| 8075 | /** |
| 8076 | * <p> |
| 8077 | * Type of usage for text interaction involving shorter messages, which includes SMS, |
| 8078 | * text chat with email addresses. |
| 8079 | * </p> |
| 8080 | */ |
| 8081 | public static final String USAGE_TYPE_SHORT_TEXT = "short_text"; |
| 8082 | } |
| 8083 | |
| 8084 | /** |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8085 | * <p> |
Yorke Lee | cadbe4c | 2014-06-20 11:52:27 -0700 | [diff] [blame] | 8086 | * Contact-specific information about whether or not a contact has been pinned by the user |
| 8087 | * at a particular position within the system contact application's user interface. |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8088 | * </p> |
| 8089 | * |
| 8090 | * <p> |
| 8091 | * This pinning information can be used by individual applications to customize how |
| 8092 | * they order particular pinned contacts. For example, a Dialer application could |
| 8093 | * use pinned information to order user-pinned contacts in a top row of favorites. |
| 8094 | * </p> |
| 8095 | * |
| 8096 | * <p> |
| 8097 | * It is possible for two or more contacts to occupy the same pinned position (due |
| 8098 | * to aggregation and sync), so this pinning information should be used on a best-effort |
| 8099 | * basis to order contacts in-application rather than an absolute guide on where a contact |
| 8100 | * should be positioned. Contacts returned by the ContactsProvider will not be ordered based |
| 8101 | * on this information, so it is up to the client application to reorder these contacts within |
| 8102 | * their own UI adhering to (or ignoring as appropriate) information stored in the pinned |
| 8103 | * column. |
| 8104 | * </p> |
| 8105 | * |
| 8106 | * <p> |
| 8107 | * By default, unpinned contacts will have a pinned position of |
Yorke Lee | 7d24679 | 2014-07-25 10:05:55 -0700 | [diff] [blame] | 8108 | * {@link PinnedPositions#UNPINNED}. Client-provided pinned positions can be positive |
| 8109 | * integers that are greater than 1. |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8110 | * </p> |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8111 | */ |
| 8112 | public static final class PinnedPositions { |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8113 | /** |
Yorke Lee | 0e040b0 | 2014-06-18 15:02:44 -0700 | [diff] [blame] | 8114 | * The method to invoke in order to undemote a formerly demoted contact. The contact id of |
| 8115 | * the contact must be provided as an argument. If the contact was not previously demoted, |
| 8116 | * nothing will be done. |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 8117 | * @hide |
Yorke Lee | 0e040b0 | 2014-06-18 15:02:44 -0700 | [diff] [blame] | 8118 | */ |
| 8119 | public static final String UNDEMOTE_METHOD = "undemote"; |
| 8120 | |
| 8121 | /** |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 8122 | * Undemotes a formerly demoted contact. If the contact was not previously demoted, nothing |
| 8123 | * will be done. |
| 8124 | * |
| 8125 | * @param contentResolver to perform the undemote operation on. |
| 8126 | * @param contactId the id of the contact to undemote. |
| 8127 | */ |
| 8128 | public static void undemote(ContentResolver contentResolver, long contactId) { |
| 8129 | contentResolver.call(ContactsContract.AUTHORITY_URI, PinnedPositions.UNDEMOTE_METHOD, |
| 8130 | String.valueOf(contactId), null); |
| 8131 | } |
| 8132 | |
| 8133 | /** |
Yorke Lee | b31c8ab | 2014-08-26 17:13:02 -0700 | [diff] [blame] | 8134 | * Pins a contact at a provided position, or unpins a contact. |
| 8135 | * |
| 8136 | * @param contentResolver to perform the pinning operation on. |
| 8137 | * @param pinnedPosition the position to pin the contact at. To unpin a contact, use |
| 8138 | * {@link PinnedPositions#UNPINNED}. |
| 8139 | */ |
| 8140 | public static void pin( |
| 8141 | ContentResolver contentResolver, long contactId, int pinnedPosition) { |
| 8142 | final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId)); |
| 8143 | final ContentValues values = new ContentValues(); |
| 8144 | values.put(Contacts.PINNED, pinnedPosition); |
| 8145 | contentResolver.update(uri, values, null, null); |
| 8146 | } |
| 8147 | |
| 8148 | /** |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 8149 | * Default value for the pinned position of an unpinned contact. |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8150 | */ |
Yorke Lee | 7d24679 | 2014-07-25 10:05:55 -0700 | [diff] [blame] | 8151 | public static final int UNPINNED = 0; |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8152 | |
| 8153 | /** |
Yorke Lee | 3585e1a | 2013-07-31 18:53:31 -0700 | [diff] [blame] | 8154 | * Value of pinned position for a contact that a user has indicated should be considered |
| 8155 | * of the lowest priority. It is up to the client application to determine how to present |
| 8156 | * such a contact - for example all the way at the bottom of a contact list, or simply |
| 8157 | * just hidden from view. |
| 8158 | */ |
| 8159 | public static final int DEMOTED = -1; |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8160 | } |
| 8161 | |
| 8162 | /** |
Yorke Lee | f8aadf3 | 2014-06-23 17:51:16 -0700 | [diff] [blame] | 8163 | * Helper methods to display QuickContact dialogs that display all the information belonging to |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8164 | * a specific {@link Contacts} entry. |
| 8165 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8166 | public static final class QuickContact { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8167 | /** |
Yorke Lee | f8aadf3 | 2014-06-23 17:51:16 -0700 | [diff] [blame] | 8168 | * Action used to launch the system contacts application and bring up a QuickContact dialog |
| 8169 | * for the provided {@link Contacts} entry. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8170 | */ |
Evan Millar | 5042f7e | 2009-09-30 21:28:33 -0700 | [diff] [blame] | 8171 | public static final String ACTION_QUICK_CONTACT = |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 8172 | "android.provider.action.QUICK_CONTACT"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8173 | |
| 8174 | /** |
| 8175 | * Extra used to specify pivot dialog location in screen coordinates. |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 8176 | * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8177 | * @hide |
| 8178 | */ |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 8179 | @Deprecated |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 8180 | public static final String EXTRA_TARGET_RECT = "android.provider.extra.TARGET_RECT"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8181 | |
| 8182 | /** |
Brian Attwell | 029e681 | 2015-02-02 16:10:39 -0800 | [diff] [blame] | 8183 | * Extra used to specify size of QuickContacts. Not all implementations of QuickContacts |
| 8184 | * will respect this extra's value. |
| 8185 | * |
| 8186 | * One of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8187 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 8188 | public static final String EXTRA_MODE = "android.provider.extra.MODE"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8189 | |
| 8190 | /** |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8191 | * Extra used to specify which mimetype should be prioritized in the QuickContacts UI. |
| 8192 | * For example, passing the value {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can |
| 8193 | * cause phone numbers to be displayed more prominently in QuickContacts. |
| 8194 | */ |
| 8195 | public static final String EXTRA_PRIORITIZED_MIMETYPE |
| 8196 | = "android.provider.extra.PRIORITIZED_MIMETYPE"; |
| 8197 | |
| 8198 | /** |
Yorke Lee | f8aadf3 | 2014-06-23 17:51:16 -0700 | [diff] [blame] | 8199 | * Extra used to indicate a list of specific MIME-types to exclude and not display in the |
| 8200 | * QuickContacts dialog. Stored as a {@link String} array. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8201 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 8202 | public static final String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8203 | |
| 8204 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8205 | * Small QuickContact mode, usually presented with minimal actions. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8206 | */ |
| 8207 | public static final int MODE_SMALL = 1; |
| 8208 | |
| 8209 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8210 | * Medium QuickContact mode, includes actions and light summary describing |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8211 | * the {@link Contacts} entry being shown. This may include social |
| 8212 | * status and presence details. |
| 8213 | */ |
| 8214 | public static final int MODE_MEDIUM = 2; |
| 8215 | |
| 8216 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8217 | * Large QuickContact mode, includes actions and larger, card-like summary |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8218 | * of the {@link Contacts} entry being shown. This may include detailed |
| 8219 | * information, such as a photo. |
| 8220 | */ |
| 8221 | public static final int MODE_LARGE = 3; |
| 8222 | |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8223 | /** @hide */ |
| 8224 | public static final int MODE_DEFAULT = MODE_LARGE; |
| 8225 | |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8226 | /** |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8227 | * Constructs the QuickContacts intent with a view's rect. |
| 8228 | * @hide |
| 8229 | */ |
| 8230 | public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri, |
| 8231 | int mode, String[] excludeMimes) { |
| 8232 | // Find location and bounds of target view, adjusting based on the |
| 8233 | // assumed local density. |
| 8234 | final float appScale = context.getResources().getCompatibilityInfo().applicationScale; |
| 8235 | final int[] pos = new int[2]; |
| 8236 | target.getLocationOnScreen(pos); |
| 8237 | |
| 8238 | final Rect rect = new Rect(); |
| 8239 | rect.left = (int) (pos[0] * appScale + 0.5f); |
| 8240 | rect.top = (int) (pos[1] * appScale + 0.5f); |
| 8241 | rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); |
| 8242 | rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); |
| 8243 | |
| 8244 | return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes); |
| 8245 | } |
| 8246 | |
| 8247 | /** |
| 8248 | * Constructs the QuickContacts intent. |
| 8249 | * @hide |
| 8250 | */ |
| 8251 | public static Intent composeQuickContactsIntent(Context context, Rect target, |
| 8252 | Uri lookupUri, int mode, String[] excludeMimes) { |
| 8253 | // When launching from an Activiy, we don't want to start a new task, but otherwise |
| 8254 | // we *must* start a new task. (Otherwise startActivity() would crash.) |
| 8255 | Context actualContext = context; |
| 8256 | while ((actualContext instanceof ContextWrapper) |
| 8257 | && !(actualContext instanceof Activity)) { |
| 8258 | actualContext = ((ContextWrapper) actualContext).getBaseContext(); |
| 8259 | } |
Brian Attwell | 9ee6640 | 2014-08-11 22:42:26 -0700 | [diff] [blame] | 8260 | final int intentFlags = ((actualContext instanceof Activity) |
| 8261 | ? 0 : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK) |
| 8262 | // Workaround for b/16898764. Declaring singleTop in manifest doesn't work. |
| 8263 | | Intent.FLAG_ACTIVITY_SINGLE_TOP; |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8264 | |
| 8265 | // Launch pivot dialog through intent for now |
| 8266 | final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags); |
| 8267 | |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8268 | // NOTE: This logic and rebuildManagedQuickContactsIntent() must be in sync. |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8269 | intent.setData(lookupUri); |
| 8270 | intent.setSourceBounds(target); |
| 8271 | intent.putExtra(EXTRA_MODE, mode); |
| 8272 | intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); |
| 8273 | return intent; |
| 8274 | } |
| 8275 | |
| 8276 | /** |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8277 | * Constructs a QuickContacts intent based on an incoming intent for DevicePolicyManager |
| 8278 | * to strip off anything not necessary. |
Etan Cohen | 534a65d | 2015-05-01 11:03:24 -0700 | [diff] [blame^] | 8279 | * |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8280 | * @hide |
| 8281 | */ |
| 8282 | public static Intent rebuildManagedQuickContactsIntent(String lookupKey, long contactId, |
| 8283 | Intent originalIntent) { |
| 8284 | final Intent intent = new Intent(ACTION_QUICK_CONTACT); |
| 8285 | // Rebuild the URI from a lookup key and a contact ID. |
| 8286 | intent.setData(Contacts.getLookupUri(contactId, lookupKey)); |
| 8287 | |
| 8288 | // Copy flags and always set NEW_TASK because it won't have a parent activity. |
| 8289 | intent.setFlags(originalIntent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK); |
| 8290 | |
| 8291 | // Copy extras. |
| 8292 | intent.setSourceBounds(originalIntent.getSourceBounds()); |
| 8293 | intent.putExtra(EXTRA_MODE, originalIntent.getIntExtra(EXTRA_MODE, MODE_DEFAULT)); |
| 8294 | intent.putExtra(EXTRA_EXCLUDE_MIMES, |
| 8295 | originalIntent.getStringArrayExtra(EXTRA_EXCLUDE_MIMES)); |
| 8296 | return intent; |
| 8297 | } |
| 8298 | |
| 8299 | |
| 8300 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8301 | * Trigger a dialog that lists the various methods of interacting with |
| 8302 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8303 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8304 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8305 | * |
| 8306 | * @param context The parent {@link Context} that may be used as the |
| 8307 | * parent for this dialog. |
| 8308 | * @param target Specific {@link View} from your layout that this dialog |
| 8309 | * should be centered around. In particular, if the dialog |
| 8310 | * has a "callout" arrow, it will be pointed and centered |
| 8311 | * around this {@link View}. |
Evan Millar | 772722e | 2009-09-30 22:24:07 -0700 | [diff] [blame] | 8312 | * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8313 | * {@link Uri} that describes a specific contact to feature |
| 8314 | * in this dialog. |
| 8315 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 8316 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 8317 | * when supported. |
| 8318 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8319 | * to exclude when showing this dialog. For example, when |
| 8320 | * already viewing the contact details card, this can be used |
| 8321 | * to omit the details entry from the dialog. |
| 8322 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8323 | public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8324 | String[] excludeMimes) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8325 | // Trigger with obtained rectangle |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8326 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, |
| 8327 | excludeMimes); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8328 | ContactsInternal.startQuickContactWithErrorToast(context, intent); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8329 | } |
| 8330 | |
| 8331 | /** |
| 8332 | * Trigger a dialog that lists the various methods of interacting with |
| 8333 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8334 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8335 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8336 | * |
| 8337 | * @param context The parent {@link Context} that may be used as the |
| 8338 | * parent for this dialog. |
| 8339 | * @param target Specific {@link Rect} that this dialog should be |
| 8340 | * centered around, in screen coordinates. In particular, if |
| 8341 | * the dialog has a "callout" arrow, it will be pointed and |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 8342 | * centered around this {@link Rect}. If you are running at a |
| 8343 | * non-native density, you need to manually adjust using |
| 8344 | * {@link DisplayMetrics#density} before calling. |
Jeff Sharkey | 223bd7a | 2009-12-21 14:51:19 -0800 | [diff] [blame] | 8345 | * @param lookupUri A |
| 8346 | * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8347 | * {@link Uri} that describes a specific contact to feature |
| 8348 | * in this dialog. |
| 8349 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 8350 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 8351 | * when supported. |
| 8352 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8353 | * to exclude when showing this dialog. For example, when |
| 8354 | * already viewing the contact details card, this can be used |
| 8355 | * to omit the details entry from the dialog. |
| 8356 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8357 | public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8358 | String[] excludeMimes) { |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8359 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, |
| 8360 | excludeMimes); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8361 | ContactsInternal.startQuickContactWithErrorToast(context, intent); |
Yorke Lee | 4fc601a | 2013-12-06 16:35:29 -0800 | [diff] [blame] | 8362 | } |
| 8363 | |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8364 | /** |
| 8365 | * Trigger a dialog that lists the various methods of interacting with |
| 8366 | * the requested {@link Contacts} entry. This may be based on available |
| 8367 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8368 | * include social status and presence details. |
| 8369 | * |
| 8370 | * @param context The parent {@link Context} that may be used as the |
| 8371 | * parent for this dialog. |
| 8372 | * @param target Specific {@link View} from your layout that this dialog |
| 8373 | * should be centered around. In particular, if the dialog |
| 8374 | * has a "callout" arrow, it will be pointed and centered |
| 8375 | * around this {@link View}. |
| 8376 | * @param lookupUri A |
| 8377 | * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
| 8378 | * {@link Uri} that describes a specific contact to feature |
| 8379 | * in this dialog. |
| 8380 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8381 | * to exclude when showing this dialog. For example, when |
| 8382 | * already viewing the contact details card, this can be used |
| 8383 | * to omit the details entry from the dialog. |
| 8384 | * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI. |
| 8385 | * For example, passing the value |
| 8386 | * {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be |
| 8387 | * displayed more prominently in QuickContacts. |
| 8388 | */ |
| 8389 | public static void showQuickContact(Context context, View target, Uri lookupUri, |
| 8390 | String[] excludeMimes, String prioritizedMimeType) { |
| 8391 | // Use MODE_LARGE instead of accepting mode as a parameter. The different mode |
| 8392 | // values defined in ContactsContract only affect very old implementations |
| 8393 | // of QuickContacts. |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8394 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT, |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8395 | excludeMimes); |
| 8396 | intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8397 | ContactsInternal.startQuickContactWithErrorToast(context, intent); |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8398 | } |
| 8399 | |
| 8400 | /** |
| 8401 | * Trigger a dialog that lists the various methods of interacting with |
| 8402 | * the requested {@link Contacts} entry. This may be based on available |
| 8403 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8404 | * include social status and presence details. |
| 8405 | * |
| 8406 | * @param context The parent {@link Context} that may be used as the |
| 8407 | * parent for this dialog. |
| 8408 | * @param target Specific {@link Rect} that this dialog should be |
| 8409 | * centered around, in screen coordinates. In particular, if |
| 8410 | * the dialog has a "callout" arrow, it will be pointed and |
| 8411 | * centered around this {@link Rect}. If you are running at a |
| 8412 | * non-native density, you need to manually adjust using |
| 8413 | * {@link DisplayMetrics#density} before calling. |
| 8414 | * @param lookupUri A |
| 8415 | * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
| 8416 | * {@link Uri} that describes a specific contact to feature |
| 8417 | * in this dialog. |
| 8418 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8419 | * to exclude when showing this dialog. For example, when |
| 8420 | * already viewing the contact details card, this can be used |
| 8421 | * to omit the details entry from the dialog. |
| 8422 | * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI. |
| 8423 | * For example, passing the value |
| 8424 | * {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be |
| 8425 | * displayed more prominently in QuickContacts. |
| 8426 | */ |
| 8427 | public static void showQuickContact(Context context, Rect target, Uri lookupUri, |
| 8428 | String[] excludeMimes, String prioritizedMimeType) { |
| 8429 | // Use MODE_LARGE instead of accepting mode as a parameter. The different mode |
| 8430 | // values defined in ContactsContract only affect very old implementations |
| 8431 | // of QuickContacts. |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8432 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT, |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8433 | excludeMimes); |
| 8434 | intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8435 | ContactsInternal.startQuickContactWithErrorToast(context, intent); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8436 | } |
| 8437 | } |
| 8438 | |
| 8439 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8440 | * Helper class for accessing full-size photos by photo file ID. |
| 8441 | * <p> |
| 8442 | * Usage example: |
| 8443 | * <dl> |
| 8444 | * <dt>Retrieving a full-size photo by photo file ID (see |
| 8445 | * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID}) |
| 8446 | * </dt> |
| 8447 | * <dd> |
| 8448 | * <pre> |
| 8449 | * public InputStream openDisplayPhoto(long photoFileId) { |
| 8450 | * Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey); |
| 8451 | * try { |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 8452 | * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor( |
| 8453 | * displayPhotoUri, "r"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8454 | * return fd.createInputStream(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 8455 | * } catch (IOException e) { |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8456 | * return null; |
| 8457 | * } |
| 8458 | * } |
| 8459 | * </pre> |
| 8460 | * </dd> |
| 8461 | * </dl> |
| 8462 | * </p> |
| 8463 | */ |
| 8464 | public static final class DisplayPhoto { |
| 8465 | /** |
| 8466 | * no public constructor since this is a utility class |
| 8467 | */ |
| 8468 | private DisplayPhoto() {} |
| 8469 | |
| 8470 | /** |
| 8471 | * The content:// style URI for this class, which allows access to full-size photos, |
| 8472 | * given a key. |
| 8473 | */ |
| 8474 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo"); |
| 8475 | |
| 8476 | /** |
| 8477 | * This URI allows the caller to query for the maximum dimensions of a display photo |
| 8478 | * or thumbnail. Requests to this URI can be performed on the UI thread because |
| 8479 | * they are always unblocking. |
| 8480 | */ |
| 8481 | public static final Uri CONTENT_MAX_DIMENSIONS_URI = |
| 8482 | Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions"); |
| 8483 | |
| 8484 | /** |
| 8485 | * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will |
| 8486 | * contain this column, populated with the maximum height and width (in pixels) |
| 8487 | * that will be stored for a display photo. Larger photos will be down-sized to |
| 8488 | * fit within a square of this many pixels. |
| 8489 | */ |
| 8490 | public static final String DISPLAY_MAX_DIM = "display_max_dim"; |
| 8491 | |
| 8492 | /** |
| 8493 | * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will |
| 8494 | * contain this column, populated with the height and width (in pixels) for photo |
| 8495 | * thumbnails. |
| 8496 | */ |
| 8497 | public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim"; |
| 8498 | } |
| 8499 | |
| 8500 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8501 | * Contains helper classes used to create or manage {@link android.content.Intent Intents} |
| 8502 | * that involve contacts. |
| 8503 | */ |
| 8504 | public static final class Intents { |
| 8505 | /** |
| 8506 | * This is the intent that is fired when a search suggestion is clicked on. |
| 8507 | */ |
| 8508 | public static final String SEARCH_SUGGESTION_CLICKED = |
| 8509 | "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; |
| 8510 | |
| 8511 | /** |
| 8512 | * This is the intent that is fired when a search suggestion for dialing a number |
| 8513 | * is clicked on. |
| 8514 | */ |
| 8515 | public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = |
| 8516 | "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; |
| 8517 | |
| 8518 | /** |
| 8519 | * This is the intent that is fired when a search suggestion for creating a contact |
| 8520 | * is clicked on. |
| 8521 | */ |
| 8522 | public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = |
| 8523 | "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; |
| 8524 | |
| 8525 | /** |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 8526 | * This is the intent that is fired when the contacts database is created. <p> The |
| 8527 | * READ_CONTACT permission is required to receive these broadcasts. |
| 8528 | */ |
| 8529 | public static final String CONTACTS_DATABASE_CREATED = |
| 8530 | "android.provider.Contacts.DATABASE_CREATED"; |
| 8531 | |
| 8532 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8533 | * Starts an Activity that lets the user pick a contact to attach an image to. |
| 8534 | * After picking the contact it launches the image cropper in face detection mode. |
| 8535 | */ |
| 8536 | public static final String ATTACH_IMAGE = |
| 8537 | "com.android.contacts.action.ATTACH_IMAGE"; |
| 8538 | |
| 8539 | /** |
Makoto Onuki | 85a01a6b | 2011-07-21 15:16:31 -0700 | [diff] [blame] | 8540 | * This is the intent that is fired when the user clicks the "invite to the network" button |
| 8541 | * on a contact. Only sent to an activity which is explicitly registered by a contact |
| 8542 | * provider which supports the "invite to the network" feature. |
| 8543 | * <p> |
| 8544 | * {@link Intent#getData()} contains the lookup URI for the contact. |
| 8545 | */ |
| 8546 | public static final String INVITE_CONTACT = |
| 8547 | "com.android.contacts.action.INVITE_CONTACT"; |
| 8548 | |
| 8549 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8550 | * Takes as input a data URI with a mailto: or tel: scheme. If a single |
| 8551 | * contact exists with the given data it will be shown. If no contact |
| 8552 | * exists, a dialog will ask the user if they want to create a new |
| 8553 | * contact with the provided details filled in. If multiple contacts |
| 8554 | * share the data the user will be prompted to pick which contact they |
| 8555 | * want to view. |
| 8556 | * <p> |
| 8557 | * For <code>mailto:</code> URIs, the scheme specific portion must be a |
| 8558 | * raw email address, such as one built using |
| 8559 | * {@link Uri#fromParts(String, String, String)}. |
| 8560 | * <p> |
| 8561 | * For <code>tel:</code> URIs, the scheme specific portion is compared |
| 8562 | * to existing numbers using the standard caller ID lookup algorithm. |
| 8563 | * The number must be properly encoded, for example using |
| 8564 | * {@link Uri#fromParts(String, String, String)}. |
| 8565 | * <p> |
| 8566 | * Any extras from the {@link Insert} class will be passed along to the |
| 8567 | * create activity if there are no contacts to show. |
| 8568 | * <p> |
| 8569 | * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip |
| 8570 | * prompting the user when the contact doesn't exist. |
| 8571 | */ |
| 8572 | public static final String SHOW_OR_CREATE_CONTACT = |
| 8573 | "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; |
| 8574 | |
| 8575 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8576 | * Starts an Activity that lets the user select the multiple phones from a |
| 8577 | * list of phone numbers which come from the contacts or |
| 8578 | * {@link #EXTRA_PHONE_URIS}. |
| 8579 | * <p> |
| 8580 | * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS} |
| 8581 | * could belong to the contacts or not, and will be selected by default. |
| 8582 | * <p> |
| 8583 | * The user's selection will be returned from |
| 8584 | * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)} |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 8585 | * if the resultCode is |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8586 | * {@link android.app.Activity#RESULT_OK}, the array of picked phone |
| 8587 | * numbers are in the Intent's |
| 8588 | * {@link #EXTRA_PHONE_URIS}; otherwise, the |
| 8589 | * {@link android.app.Activity#RESULT_CANCELED} is returned if the user |
| 8590 | * left the Activity without changing the selection. |
| 8591 | * |
| 8592 | * @hide |
| 8593 | */ |
| 8594 | public static final String ACTION_GET_MULTIPLE_PHONES = |
| 8595 | "com.android.contacts.action.GET_MULTIPLE_PHONES"; |
| 8596 | |
| 8597 | /** |
Makoto Onuki | 90ddc90 | 2012-09-11 18:22:53 -0700 | [diff] [blame] | 8598 | * A broadcast action which is sent when any change has been made to the profile, such |
| 8599 | * as the profile name or the picture. A receiver must have |
| 8600 | * the android.permission.READ_PROFILE permission. |
| 8601 | * |
| 8602 | * @hide |
| 8603 | */ |
| 8604 | public static final String ACTION_PROFILE_CHANGED = |
| 8605 | "android.provider.Contacts.PROFILE_CHANGED"; |
| 8606 | |
| 8607 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8608 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new |
| 8609 | * contact if no matching contact found. Otherwise, default behavior is |
| 8610 | * to prompt user with dialog before creating. |
| 8611 | * <p> |
| 8612 | * Type: BOOLEAN |
| 8613 | */ |
| 8614 | public static final String EXTRA_FORCE_CREATE = |
| 8615 | "com.android.contacts.action.FORCE_CREATE"; |
| 8616 | |
| 8617 | /** |
| 8618 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact |
| 8619 | * description to be shown when prompting user about creating a new |
| 8620 | * contact. |
| 8621 | * <p> |
| 8622 | * Type: STRING |
| 8623 | */ |
| 8624 | public static final String EXTRA_CREATE_DESCRIPTION = |
| 8625 | "com.android.contacts.action.CREATE_DESCRIPTION"; |
| 8626 | |
| 8627 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8628 | * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value. |
| 8629 | * <p> |
| 8630 | * The phone numbers want to be picked by default should be passed in as |
| 8631 | * input value. These phone numbers could belong to the contacts or not. |
| 8632 | * <p> |
| 8633 | * The phone numbers which were picked by the user are returned as output |
| 8634 | * value. |
| 8635 | * <p> |
| 8636 | * Type: array of URIs, the tel URI is used for the phone numbers which don't |
| 8637 | * belong to any contact, the content URI is used for phone id in contacts. |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 8638 | * |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8639 | * @hide |
| 8640 | */ |
| 8641 | public static final String EXTRA_PHONE_URIS = |
| 8642 | "com.android.contacts.extra.PHONE_URIS"; |
| 8643 | |
| 8644 | /** |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 8645 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 8646 | * dialog location using screen coordinates. When not specified, the |
| 8647 | * dialog will be centered. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8648 | * |
| 8649 | * @hide |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 8650 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8651 | @Deprecated |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 8652 | public static final String EXTRA_TARGET_RECT = "target_rect"; |
| 8653 | |
| 8654 | /** |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8655 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 8656 | * desired dialog style, usually a variation on size. One of |
| 8657 | * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8658 | * |
| 8659 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8660 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8661 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8662 | public static final String EXTRA_MODE = "mode"; |
| 8663 | |
| 8664 | /** |
| 8665 | * Value for {@link #EXTRA_MODE} to show a small-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8666 | * |
| 8667 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8668 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8669 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8670 | public static final int MODE_SMALL = 1; |
| 8671 | |
| 8672 | /** |
| 8673 | * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8674 | * |
| 8675 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8676 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8677 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8678 | public static final int MODE_MEDIUM = 2; |
| 8679 | |
| 8680 | /** |
| 8681 | * Value for {@link #EXTRA_MODE} to show a large-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8682 | * |
| 8683 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8684 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8685 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8686 | public static final int MODE_LARGE = 3; |
| 8687 | |
| 8688 | /** |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 8689 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate |
| 8690 | * a list of specific MIME-types to exclude and not display. Stored as a |
| 8691 | * {@link String} array. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8692 | * |
| 8693 | * @hide |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 8694 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8695 | @Deprecated |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 8696 | public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; |
| 8697 | |
| 8698 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8699 | * Convenience class that contains string constants used |
| 8700 | * to create contact {@link android.content.Intent Intents}. |
| 8701 | */ |
| 8702 | public static final class Insert { |
| 8703 | /** The action code to use when adding a contact */ |
| 8704 | public static final String ACTION = Intent.ACTION_INSERT; |
| 8705 | |
| 8706 | /** |
| 8707 | * If present, forces a bypass of quick insert mode. |
| 8708 | */ |
| 8709 | public static final String FULL_MODE = "full_mode"; |
| 8710 | |
| 8711 | /** |
| 8712 | * The extra field for the contact name. |
| 8713 | * <P>Type: String</P> |
| 8714 | */ |
| 8715 | public static final String NAME = "name"; |
| 8716 | |
| 8717 | // TODO add structured name values here. |
| 8718 | |
| 8719 | /** |
| 8720 | * The extra field for the contact phonetic name. |
| 8721 | * <P>Type: String</P> |
| 8722 | */ |
| 8723 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 8724 | |
| 8725 | /** |
| 8726 | * The extra field for the contact company. |
| 8727 | * <P>Type: String</P> |
| 8728 | */ |
| 8729 | public static final String COMPANY = "company"; |
| 8730 | |
| 8731 | /** |
| 8732 | * The extra field for the contact job title. |
| 8733 | * <P>Type: String</P> |
| 8734 | */ |
| 8735 | public static final String JOB_TITLE = "job_title"; |
| 8736 | |
| 8737 | /** |
| 8738 | * The extra field for the contact notes. |
| 8739 | * <P>Type: String</P> |
| 8740 | */ |
| 8741 | public static final String NOTES = "notes"; |
| 8742 | |
| 8743 | /** |
| 8744 | * The extra field for the contact phone number. |
| 8745 | * <P>Type: String</P> |
| 8746 | */ |
| 8747 | public static final String PHONE = "phone"; |
| 8748 | |
| 8749 | /** |
| 8750 | * The extra field for the contact phone number type. |
| 8751 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8752 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8753 | * or a string specifying a custom label.</P> |
| 8754 | */ |
| 8755 | public static final String PHONE_TYPE = "phone_type"; |
| 8756 | |
| 8757 | /** |
| 8758 | * The extra field for the phone isprimary flag. |
| 8759 | * <P>Type: boolean</P> |
| 8760 | */ |
| 8761 | public static final String PHONE_ISPRIMARY = "phone_isprimary"; |
| 8762 | |
| 8763 | /** |
| 8764 | * The extra field for an optional second contact phone number. |
| 8765 | * <P>Type: String</P> |
| 8766 | */ |
| 8767 | public static final String SECONDARY_PHONE = "secondary_phone"; |
| 8768 | |
| 8769 | /** |
| 8770 | * The extra field for an optional second contact phone number type. |
| 8771 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8772 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8773 | * or a string specifying a custom label.</P> |
| 8774 | */ |
| 8775 | public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; |
| 8776 | |
| 8777 | /** |
| 8778 | * The extra field for an optional third contact phone number. |
| 8779 | * <P>Type: String</P> |
| 8780 | */ |
| 8781 | public static final String TERTIARY_PHONE = "tertiary_phone"; |
| 8782 | |
| 8783 | /** |
| 8784 | * The extra field for an optional third contact phone number type. |
| 8785 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8786 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8787 | * or a string specifying a custom label.</P> |
| 8788 | */ |
| 8789 | public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; |
| 8790 | |
| 8791 | /** |
| 8792 | * The extra field for the contact email address. |
| 8793 | * <P>Type: String</P> |
| 8794 | */ |
| 8795 | public static final String EMAIL = "email"; |
| 8796 | |
| 8797 | /** |
| 8798 | * The extra field for the contact email type. |
| 8799 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8800 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8801 | * or a string specifying a custom label.</P> |
| 8802 | */ |
| 8803 | public static final String EMAIL_TYPE = "email_type"; |
| 8804 | |
| 8805 | /** |
| 8806 | * The extra field for the email isprimary flag. |
| 8807 | * <P>Type: boolean</P> |
| 8808 | */ |
| 8809 | public static final String EMAIL_ISPRIMARY = "email_isprimary"; |
| 8810 | |
| 8811 | /** |
| 8812 | * The extra field for an optional second contact email address. |
| 8813 | * <P>Type: String</P> |
| 8814 | */ |
| 8815 | public static final String SECONDARY_EMAIL = "secondary_email"; |
| 8816 | |
| 8817 | /** |
| 8818 | * The extra field for an optional second contact email type. |
| 8819 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8820 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8821 | * or a string specifying a custom label.</P> |
| 8822 | */ |
| 8823 | public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; |
| 8824 | |
| 8825 | /** |
| 8826 | * The extra field for an optional third contact email address. |
| 8827 | * <P>Type: String</P> |
| 8828 | */ |
| 8829 | public static final String TERTIARY_EMAIL = "tertiary_email"; |
| 8830 | |
| 8831 | /** |
| 8832 | * The extra field for an optional third contact email type. |
| 8833 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8834 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8835 | * or a string specifying a custom label.</P> |
| 8836 | */ |
| 8837 | public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; |
| 8838 | |
| 8839 | /** |
| 8840 | * The extra field for the contact postal address. |
| 8841 | * <P>Type: String</P> |
| 8842 | */ |
| 8843 | public static final String POSTAL = "postal"; |
| 8844 | |
| 8845 | /** |
| 8846 | * The extra field for the contact postal address type. |
| 8847 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8848 | * {@link CommonDataKinds.StructuredPostal} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8849 | * or a string specifying a custom label.</P> |
| 8850 | */ |
| 8851 | public static final String POSTAL_TYPE = "postal_type"; |
| 8852 | |
| 8853 | /** |
| 8854 | * The extra field for the postal isprimary flag. |
| 8855 | * <P>Type: boolean</P> |
| 8856 | */ |
| 8857 | public static final String POSTAL_ISPRIMARY = "postal_isprimary"; |
| 8858 | |
| 8859 | /** |
| 8860 | * The extra field for an IM handle. |
| 8861 | * <P>Type: String</P> |
| 8862 | */ |
| 8863 | public static final String IM_HANDLE = "im_handle"; |
| 8864 | |
| 8865 | /** |
| 8866 | * The extra field for the IM protocol |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8867 | */ |
| 8868 | public static final String IM_PROTOCOL = "im_protocol"; |
| 8869 | |
| 8870 | /** |
| 8871 | * The extra field for the IM isprimary flag. |
| 8872 | * <P>Type: boolean</P> |
| 8873 | */ |
| 8874 | public static final String IM_ISPRIMARY = "im_isprimary"; |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 8875 | |
| 8876 | /** |
| 8877 | * The extra field that allows the client to supply multiple rows of |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 8878 | * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT} |
| 8879 | * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of |
| 8880 | * {@link ContentValues}, one per data row. Supplying this extra is |
| 8881 | * similar to inserting multiple rows into the {@link Data} table, |
| 8882 | * except the user gets a chance to see and edit them before saving. |
| 8883 | * Each ContentValues object must have a value for {@link Data#MIMETYPE}. |
| 8884 | * If supplied values are not visible in the editor UI, they will be |
| 8885 | * dropped. Duplicate data will dropped. Some fields |
| 8886 | * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically |
| 8887 | * adjusted to comply with the constraints of the specific account type. |
| 8888 | * For example, an Exchange contact can only have one phone numbers of type Home, |
| 8889 | * so the contact editor may choose a different type for this phone number to |
| 8890 | * avoid dropping the valueable part of the row, which is the phone number. |
| 8891 | * <p> |
| 8892 | * Example: |
| 8893 | * <pre> |
| 8894 | * ArrayList<ContentValues> data = new ArrayList<ContentValues>(); |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 8895 | * |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 8896 | * ContentValues row1 = new ContentValues(); |
| 8897 | * row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE); |
| 8898 | * row1.put(Organization.COMPANY, "Android"); |
| 8899 | * data.add(row1); |
| 8900 | * |
| 8901 | * ContentValues row2 = new ContentValues(); |
| 8902 | * row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE); |
| 8903 | * row2.put(Email.TYPE, Email.TYPE_CUSTOM); |
| 8904 | * row2.put(Email.LABEL, "Green Bot"); |
| 8905 | * row2.put(Email.ADDRESS, "android@android.com"); |
| 8906 | * data.add(row2); |
| 8907 | * |
| 8908 | * Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); |
| 8909 | * intent.putParcelableArrayListExtra(Insert.DATA, data); |
| 8910 | * |
| 8911 | * startActivity(intent); |
| 8912 | * </pre> |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 8913 | */ |
| 8914 | public static final String DATA = "data"; |
Daniel Lehmann | cde1ac6 | 2010-10-21 20:40:11 -0700 | [diff] [blame] | 8915 | |
| 8916 | /** |
| 8917 | * Used to specify the account in which to create the new contact. |
| 8918 | * <p> |
| 8919 | * If this value is not provided, the user is presented with a disambiguation |
| 8920 | * dialog to chose an account |
| 8921 | * <p> |
| 8922 | * Type: {@link Account} |
Daniel Lehmann | cde1ac6 | 2010-10-21 20:40:11 -0700 | [diff] [blame] | 8923 | */ |
Brian Attwell | 63f859b | 2015-01-26 15:57:10 -0800 | [diff] [blame] | 8924 | public static final String EXTRA_ACCOUNT = "android.provider.extra.ACCOUNT"; |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 8925 | |
| 8926 | /** |
| 8927 | * Used to specify the data set within the account in which to create the |
| 8928 | * new contact. |
| 8929 | * <p> |
| 8930 | * This value is optional - if it is not specified, the contact will be |
| 8931 | * created in the base account, with no data set. |
| 8932 | * <p> |
| 8933 | * Type: String |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 8934 | */ |
Brian Attwell | 63f859b | 2015-01-26 15:57:10 -0800 | [diff] [blame] | 8935 | public static final String EXTRA_DATA_SET = "android.provider.extra.DATA_SET"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8936 | } |
| 8937 | } |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 8938 | |
| 8939 | /** |
| 8940 | * @hide |
| 8941 | */ |
| 8942 | protected interface MetadataSyncColumns { |
| 8943 | |
| 8944 | /** |
| 8945 | * The raw contact backup id. |
| 8946 | * A reference to the {@link ContactsContract.RawContacts#BACKUP_ID} that save the |
| 8947 | * persistent unique id for each raw contact within its source system. |
| 8948 | * |
| 8949 | * @hide |
| 8950 | */ |
| 8951 | public static final String RAW_CONTACT_BACKUP_ID = "raw_contact_backup_id"; |
| 8952 | |
| 8953 | /** |
| 8954 | * The account type to which the raw_contact of this item is associated. See |
| 8955 | * {@link RawContacts#ACCOUNT_TYPE} |
| 8956 | * |
| 8957 | * @hide |
| 8958 | */ |
| 8959 | public static final String ACCOUNT_TYPE = "account_type"; |
| 8960 | |
| 8961 | /** |
| 8962 | * The account name to which the raw_contact of this item is associated. See |
| 8963 | * {@link RawContacts#ACCOUNT_NAME} |
| 8964 | * |
| 8965 | * @hide |
| 8966 | */ |
| 8967 | public static final String ACCOUNT_NAME = "account_name"; |
| 8968 | |
| 8969 | /** |
| 8970 | * The data set within the account that the raw_contact of this row belongs to. This allows |
| 8971 | * multiple sync adapters for the same account type to distinguish between |
| 8972 | * each others' data. |
| 8973 | * {@link RawContacts#DATA_SET} |
| 8974 | * |
| 8975 | * @hide |
| 8976 | */ |
| 8977 | public static final String DATA_SET = "data_set"; |
| 8978 | |
| 8979 | /** |
| 8980 | * A text column contains the Json string got from People API. The Json string contains |
| 8981 | * all the metadata related to the raw contact, i.e., all the data fields and |
| 8982 | * aggregation exceptions. |
| 8983 | * |
| 8984 | * Here is an example of the Json string got from the actual schema. |
| 8985 | * <pre> |
| 8986 | * { |
| 8987 | * "unique_contact_id": { |
| 8988 | * "account_type": "CUSTOM_ACCOUNT", |
| 8989 | * "custom_account_type": "facebook", |
| 8990 | * "account_name": "android-test", |
| 8991 | * "contact_id": "1111111", |
| 8992 | * "data_set": "FOCUS" |
| 8993 | * }, |
| 8994 | * "contact_prefs": { |
| 8995 | * "send_to_voicemail": true, |
| 8996 | * "starred": false, |
| 8997 | * "pinned": 2 |
| 8998 | * }, |
| 8999 | * "aggregation_data": [ |
| 9000 | * { |
| 9001 | * "type": "TOGETHER", |
| 9002 | * "contact_ids": [ |
| 9003 | * { |
| 9004 | * "account_type": "GOOGLE_ACCOUNT", |
| 9005 | * "account_name": "android-test2", |
| 9006 | * "contact_id": "2222222", |
| 9007 | * "data_set": "GOOGLE_PLUS" |
| 9008 | * }, |
| 9009 | * { |
| 9010 | * "account_type": "GOOGLE_ACCOUNT", |
| 9011 | * "account_name": "android-test3", |
| 9012 | * "contact_id": "3333333", |
| 9013 | * "data_set": "CUSTOM", |
| 9014 | * "custom_data_set": "custom type" |
| 9015 | * } |
| 9016 | * ] |
| 9017 | * } |
| 9018 | * ], |
| 9019 | * "field_data": [ |
| 9020 | * { |
| 9021 | * "field_data_id": "1001", |
| 9022 | * "field_data_prefs": { |
| 9023 | * "is_primary": true, |
| 9024 | * "is_super_primary": true |
| 9025 | * }, |
| 9026 | * "usage_stats": [ |
| 9027 | * { |
| 9028 | * "usage_type": "CALL", |
| 9029 | * "last_time_used": 10000001, |
| 9030 | * "usage_count": 10 |
| 9031 | * } |
| 9032 | * ] |
| 9033 | * } |
| 9034 | * ] |
| 9035 | * } |
| 9036 | * </pre> |
| 9037 | * |
| 9038 | * @hide |
| 9039 | */ |
| 9040 | public static final String DATA = "data"; |
| 9041 | |
| 9042 | /** |
| 9043 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 9044 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 9045 | * called on a raw contact, updating MetadataSync table to set the flag of the raw contact |
| 9046 | * as "1", then metadata sync adapter deletes the raw contact metadata on the server. |
| 9047 | * <P>Type: INTEGER</P> |
| 9048 | * |
| 9049 | * @hide |
| 9050 | */ |
| 9051 | public static final String DELETED = "deleted"; |
| 9052 | } |
| 9053 | |
| 9054 | /** |
| 9055 | * Constants for the metadata sync table. This table is used to cache the metadata_sync data |
| 9056 | * from server before it is merged into other CP2 tables. |
| 9057 | * |
| 9058 | * @hide |
| 9059 | */ |
| 9060 | public static final class MetadataSync implements BaseColumns, MetadataSyncColumns { |
| 9061 | |
| 9062 | /** The authority for the contacts metadata */ |
| 9063 | public static final String METADATA_AUTHORITY = "com.android.contacts.metadata"; |
| 9064 | |
| 9065 | /** A content:// style uri to the authority for the contacts metadata */ |
| 9066 | public static final Uri METADATA_AUTHORITY_URI = Uri.parse( |
| 9067 | "content://" + METADATA_AUTHORITY); |
| 9068 | |
| 9069 | /** |
| 9070 | * This utility class cannot be instantiated |
| 9071 | */ |
| 9072 | private MetadataSync() { |
| 9073 | } |
| 9074 | |
| 9075 | /** |
| 9076 | * The content:// style URI for this table. |
| 9077 | */ |
| 9078 | public static final Uri CONTENT_URI = Uri.withAppendedPath(METADATA_AUTHORITY_URI, |
| 9079 | "metadata_sync"); |
| 9080 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 9081 | } |