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; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 21 | import android.content.ContentProviderClient; |
| 22 | import android.content.ContentProviderOperation; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 23 | import android.content.ContentResolver; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 24 | import android.content.ContentUris; |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 25 | import android.content.ContentValues; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 26 | import android.content.Context; |
Makoto Onuki | bba33cd | 2012-05-25 17:09:05 -0700 | [diff] [blame] | 27 | import android.content.ContextWrapper; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 28 | import android.content.CursorEntityIterator; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 29 | import android.content.Entity; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 30 | import android.content.EntityIterator; |
| 31 | import android.content.Intent; |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 32 | import android.content.res.AssetFileDescriptor; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 33 | import android.content.res.Resources; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 34 | import android.database.Cursor; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 35 | import android.database.DatabaseUtils; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 36 | import android.graphics.Rect; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 37 | import android.net.Uri; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 38 | import android.os.RemoteException; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 39 | import android.text.TextUtils; |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 40 | import android.util.DisplayMetrics; |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 41 | import android.util.Pair; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 42 | import android.view.View; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 43 | |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 44 | import java.io.ByteArrayInputStream; |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 45 | import java.io.IOException; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 46 | import java.io.InputStream; |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 47 | import java.util.ArrayList; |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 48 | import java.util.List; |
| 49 | import java.util.regex.Matcher; |
| 50 | import java.util.regex.Pattern; |
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.) |
| 168 | * |
| 169 | * @hide |
| 170 | */ |
| 171 | public static final String STREQUENT_PHONE_ONLY = "strequent_phone_only"; |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 172 | |
| 173 | /** |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 174 | * A key to a boolean in the "extras" bundle of the cursor. |
| 175 | * The boolean indicates that the provider did not create a snippet and that the client asking |
| 176 | * for the snippet should do it (true means the snippeting was deferred to the client). |
| 177 | * |
| 178 | * @hide |
| 179 | */ |
| 180 | public static final String DEFERRED_SNIPPETING = "deferred_snippeting"; |
| 181 | |
| 182 | /** |
| 183 | * Key to retrieve the original query on the client side. |
| 184 | * |
| 185 | * @hide |
| 186 | */ |
| 187 | public static final String DEFERRED_SNIPPETING_QUERY = "deferred_snippeting_query"; |
| 188 | |
| 189 | /** |
Daisuke Miyakawa | 19352e0 | 2011-11-14 13:16:07 -0800 | [diff] [blame] | 190 | * A boolean parameter for {@link CommonDataKinds.Phone#CONTENT_URI}, |
| 191 | * {@link CommonDataKinds.Email#CONTENT_URI}, and |
| 192 | * {@link CommonDataKinds.StructuredPostal#CONTENT_URI}. |
| 193 | * This enables a content provider to remove duplicate entries in results. |
| 194 | * |
| 195 | * @hide |
| 196 | */ |
| 197 | public static final String REMOVE_DUPLICATE_ENTRIES = "remove_duplicate_entries"; |
| 198 | |
| 199 | /** |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 200 | * <p> |
| 201 | * API for obtaining a pre-authorized version of a URI that normally requires special |
| 202 | * permission (beyond READ_CONTACTS) to read. The caller obtaining the pre-authorized URI |
| 203 | * must already have the necessary permissions to access the URI; otherwise a |
| 204 | * {@link SecurityException} will be thrown. |
| 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 |
| 209 | * be required. |
| 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> |
| 233 | * @hide |
| 234 | */ |
| 235 | public static final class Authorization { |
| 236 | /** |
| 237 | * The method to invoke to create a pre-authorized URI out of the input argument. |
| 238 | */ |
| 239 | public static final String AUTHORIZATION_METHOD = "authorize"; |
| 240 | |
| 241 | /** |
| 242 | * The key to set in the outbound Bundle with the URI that should be authorized. |
| 243 | */ |
| 244 | public static final String KEY_URI_TO_AUTHORIZE = "uri_to_authorize"; |
| 245 | |
| 246 | /** |
| 247 | * The key to retrieve from the returned Bundle to obtain the pre-authorized URI. |
| 248 | */ |
| 249 | public static final String KEY_AUTHORIZED_URI = "authorized_uri"; |
| 250 | } |
| 251 | |
| 252 | /** |
Dmitri Plotnikov | 2a650dd | 2010-01-26 17:28:52 -0800 | [diff] [blame] | 253 | * @hide |
| 254 | */ |
| 255 | public static final class Preferences { |
| 256 | |
| 257 | /** |
| 258 | * A key in the {@link android.provider.Settings android.provider.Settings} provider |
| 259 | * that stores the preferred sorting order for contacts (by given name vs. by family name). |
| 260 | * |
| 261 | * @hide |
| 262 | */ |
| 263 | public static final String SORT_ORDER = "android.contacts.SORT_ORDER"; |
| 264 | |
| 265 | /** |
| 266 | * The value for the SORT_ORDER key corresponding to sorting by given name first. |
| 267 | * |
| 268 | * @hide |
| 269 | */ |
| 270 | public static final int SORT_ORDER_PRIMARY = 1; |
| 271 | |
| 272 | /** |
| 273 | * The value for the SORT_ORDER key corresponding to sorting by family name first. |
| 274 | * |
| 275 | * @hide |
| 276 | */ |
| 277 | public static final int SORT_ORDER_ALTERNATIVE = 2; |
| 278 | |
| 279 | /** |
| 280 | * A key in the {@link android.provider.Settings android.provider.Settings} provider |
| 281 | * that stores the preferred display order for contacts (given name first vs. family |
| 282 | * name first). |
| 283 | * |
| 284 | * @hide |
| 285 | */ |
| 286 | public static final String DISPLAY_ORDER = "android.contacts.DISPLAY_ORDER"; |
| 287 | |
| 288 | /** |
| 289 | * The value for the DISPLAY_ORDER key corresponding to showing the given name first. |
| 290 | * |
| 291 | * @hide |
| 292 | */ |
| 293 | public static final int DISPLAY_ORDER_PRIMARY = 1; |
| 294 | |
| 295 | /** |
| 296 | * The value for the DISPLAY_ORDER key corresponding to showing the family name first. |
| 297 | * |
| 298 | * @hide |
| 299 | */ |
| 300 | public static final int DISPLAY_ORDER_ALTERNATIVE = 2; |
| 301 | } |
| 302 | |
| 303 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 304 | * A Directory represents a contacts corpus, e.g. Local contacts, |
| 305 | * Google Apps Global Address List or Corporate Global Address List. |
| 306 | * <p> |
| 307 | * A Directory is implemented as a content provider with its unique authority and |
| 308 | * the same API as the main Contacts Provider. However, there is no expectation that |
| 309 | * every directory provider will implement this Contract in its entirety. If a |
| 310 | * directory provider does not have an implementation for a specific request, it |
| 311 | * should throw an UnsupportedOperationException. |
| 312 | * </p> |
| 313 | * <p> |
| 314 | * 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] | 315 | * expected to support at least {@link ContactsContract.Contacts#CONTENT_FILTER_URI |
| 316 | * Contacts.CONTENT_FILTER_URI}. If a Directory provider wants to participate |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 317 | * in email and phone lookup functionalities, it should also implement |
| 318 | * {@link CommonDataKinds.Email#CONTENT_FILTER_URI CommonDataKinds.Email.CONTENT_FILTER_URI} |
| 319 | * and |
| 320 | * {@link CommonDataKinds.Phone#CONTENT_FILTER_URI CommonDataKinds.Phone.CONTENT_FILTER_URI}. |
| 321 | * </p> |
| 322 | * <p> |
| 323 | * A directory provider should return NULL for every projection field it does not |
| 324 | * recognize, rather than throwing an exception. This way it will not be broken |
| 325 | * if ContactsContract is extended with new fields in the future. |
| 326 | * </p> |
| 327 | * <p> |
| 328 | * The client interacts with a directory via Contacts Provider by supplying an |
| 329 | * optional {@code directory=} query parameter. |
| 330 | * <p> |
| 331 | * <p> |
| 332 | * When the Contacts Provider receives the request, it transforms the URI and forwards |
| 333 | * the request to the corresponding directory content provider. |
| 334 | * The URI is transformed in the following fashion: |
| 335 | * <ul> |
| 336 | * <li>The URI authority is replaced with the corresponding {@link #DIRECTORY_AUTHORITY}.</li> |
| 337 | * <li>The {@code accountName=} and {@code accountType=} parameters are added or |
| 338 | * 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] | 339 | * </ul> |
| 340 | * </p> |
| 341 | * <p> |
| 342 | * Clients should send directory requests to Contacts Provider and let it |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 343 | * forward them to the respective providers rather than constructing |
| 344 | * directory provider URIs by themselves. This level of indirection allows |
| 345 | * Contacts Provider to implement additional system-level features and |
| 346 | * optimizations. Access to Contacts Provider is protected by the |
Subir Jhanb | 603af61 | 2012-08-06 17:19:22 -0700 | [diff] [blame] | 347 | * READ_CONTACTS permission, but access to the directory provider is protected by |
| 348 | * BIND_DIRECTORY_SEARCH. This permission was introduced at the API level 17, for previous |
| 349 | * platform versions the provider should perform the following check to make sure the call |
| 350 | * is coming from the ContactsProvider: |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 351 | * <pre> |
| 352 | * private boolean isCallerAllowed() { |
| 353 | * PackageManager pm = getContext().getPackageManager(); |
| 354 | * for (String packageName: pm.getPackagesForUid(Binder.getCallingUid())) { |
| 355 | * if (packageName.equals("com.android.providers.contacts")) { |
| 356 | * return true; |
| 357 | * } |
| 358 | * } |
| 359 | * return false; |
| 360 | * } |
| 361 | * </pre> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 362 | * </p> |
| 363 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 364 | * The Directory table is read-only and is maintained by the Contacts Provider |
| 365 | * automatically. |
| 366 | * </p> |
| 367 | * <p>It always has at least these two rows: |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 368 | * <ul> |
| 369 | * <li> |
| 370 | * The local directory. It has {@link Directory#_ID Directory._ID} = |
| 371 | * {@link Directory#DEFAULT Directory.DEFAULT}. This directory can be used to access locally |
| 372 | * stored contacts. The same can be achieved by omitting the {@code directory=} |
| 373 | * parameter altogether. |
| 374 | * </li> |
| 375 | * <li> |
| 376 | * The local invisible contacts. The corresponding directory ID is |
| 377 | * {@link Directory#LOCAL_INVISIBLE Directory.LOCAL_INVISIBLE}. |
| 378 | * </li> |
| 379 | * </ul> |
| 380 | * </p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 381 | * <p>Custom Directories are discovered by the Contacts Provider following this procedure: |
| 382 | * <ul> |
| 383 | * <li>It finds all installed content providers with meta data identifying them |
| 384 | * as directory providers in AndroidManifest.xml: |
| 385 | * <code> |
| 386 | * <meta-data android:name="android.content.ContactDirectory" |
| 387 | * android:value="true" /> |
| 388 | * </code> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 389 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 390 | * This tag should be placed inside the corresponding content provider declaration. |
| 391 | * </p> |
| 392 | * </li> |
| 393 | * <li> |
| 394 | * Then Contacts Provider sends a {@link Directory#CONTENT_URI Directory.CONTENT_URI} |
| 395 | * query to each of the directory authorities. A directory provider must implement |
| 396 | * this query and return a list of directories. Each directory returned by |
| 397 | * the provider must have a unique combination for the {@link #ACCOUNT_NAME} and |
| 398 | * {@link #ACCOUNT_TYPE} columns (nulls are allowed). Since directory IDs are assigned |
| 399 | * automatically, the _ID field will not be part of the query projection. |
| 400 | * </li> |
| 401 | * <li>Contacts Provider compiles directory lists received from all directory |
| 402 | * providers into one, assigns each individual directory a globally unique ID and |
| 403 | * stores all directory records in the Directory table. |
| 404 | * </li> |
| 405 | * </ul> |
| 406 | * </p> |
| 407 | * <p>Contacts Provider automatically interrogates newly installed or replaced packages. |
| 408 | * Thus simply installing a package containing a directory provider is sufficient |
| 409 | * to have that provider registered. A package supplying a directory provider does |
| 410 | * not have to contain launchable activities. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 411 | * </p> |
| 412 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 413 | * Every row in the Directory table is automatically associated with the corresponding package |
| 414 | * (apk). If the package is later uninstalled, all corresponding directory rows |
| 415 | * are automatically removed from the Contacts Provider. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 416 | * </p> |
| 417 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 418 | * When the list of directories handled by a directory provider changes |
| 419 | * (for instance when the user adds a new Directory account), the directory provider |
| 420 | * should call {@link #notifyDirectoryChange} to notify the Contacts Provider of the change. |
| 421 | * In response, the Contacts Provider will requery the directory provider to obtain the |
| 422 | * new list of directories. |
| 423 | * </p> |
| 424 | * <p> |
| 425 | * A directory row can be optionally associated with an existing account |
| 426 | * (see {@link android.accounts.AccountManager}). If the account is later removed, |
Dmitri Plotnikov | e50ed08 | 2010-08-18 10:56:09 -0700 | [diff] [blame] | 427 | * the corresponding directory rows are automatically removed from the Contacts Provider. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 428 | * </p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 429 | */ |
| 430 | public static final class Directory implements BaseColumns { |
| 431 | |
| 432 | /** |
| 433 | * Not instantiable. |
| 434 | */ |
| 435 | private Directory() { |
| 436 | } |
| 437 | |
| 438 | /** |
| 439 | * The content:// style URI for this table. Requests to this URI can be |
| 440 | * performed on the UI thread because they are always unblocking. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 441 | */ |
| 442 | public static final Uri CONTENT_URI = |
| 443 | Uri.withAppendedPath(AUTHORITY_URI, "directories"); |
| 444 | |
| 445 | /** |
| 446 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 447 | * contact directories. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 448 | */ |
| 449 | public static final String CONTENT_TYPE = |
| 450 | "vnd.android.cursor.dir/contact_directories"; |
| 451 | |
| 452 | /** |
| 453 | * The MIME type of a {@link #CONTENT_URI} item. |
| 454 | */ |
| 455 | public static final String CONTENT_ITEM_TYPE = |
| 456 | "vnd.android.cursor.item/contact_directory"; |
| 457 | |
| 458 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 459 | * _ID of the default directory, which represents locally stored contacts. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 460 | */ |
| 461 | public static final long DEFAULT = 0; |
| 462 | |
| 463 | /** |
| 464 | * _ID of the directory that represents locally stored invisible contacts. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 465 | */ |
| 466 | public static final long LOCAL_INVISIBLE = 1; |
| 467 | |
| 468 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 469 | * The name of the package that owns this directory. Contacts Provider |
| 470 | * fill it in with the name of the package containing the directory provider. |
| 471 | * If the package is later uninstalled, the directories it owns are |
| 472 | * automatically removed from this table. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 473 | * |
| 474 | * <p>TYPE: TEXT</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 475 | */ |
| 476 | public static final String PACKAGE_NAME = "packageName"; |
| 477 | |
| 478 | /** |
| 479 | * The type of directory captured as a resource ID in the context of the |
| 480 | * package {@link #PACKAGE_NAME}, e.g. "Corporate Directory" |
| 481 | * |
| 482 | * <p>TYPE: INTEGER</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 483 | */ |
| 484 | public static final String TYPE_RESOURCE_ID = "typeResourceId"; |
| 485 | |
| 486 | /** |
| 487 | * An optional name that can be used in the UI to represent this directory, |
| 488 | * e.g. "Acme Corp" |
| 489 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 490 | */ |
| 491 | public static final String DISPLAY_NAME = "displayName"; |
| 492 | |
| 493 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 494 | * <p> |
| 495 | * The authority of the Directory Provider. Contacts Provider will |
| 496 | * use this authority to forward requests to the directory provider. |
| 497 | * A directory provider can leave this column empty - Contacts Provider will fill it in. |
| 498 | * </p> |
| 499 | * <p> |
| 500 | * Clients of this API should not send requests directly to this authority. |
| 501 | * All directory requests must be routed through Contacts Provider. |
| 502 | * </p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 503 | * |
| 504 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 505 | */ |
| 506 | public static final String DIRECTORY_AUTHORITY = "authority"; |
| 507 | |
| 508 | /** |
| 509 | * The account type which this directory is associated. |
| 510 | * |
| 511 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 512 | */ |
| 513 | public static final String ACCOUNT_TYPE = "accountType"; |
| 514 | |
| 515 | /** |
| 516 | * The account with which this directory is associated. If the account is later |
| 517 | * removed, the directories it owns are automatically removed from this table. |
| 518 | * |
| 519 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 520 | */ |
| 521 | public static final String ACCOUNT_NAME = "accountName"; |
| 522 | |
| 523 | /** |
| 524 | * One of {@link #EXPORT_SUPPORT_NONE}, {@link #EXPORT_SUPPORT_ANY_ACCOUNT}, |
| 525 | * {@link #EXPORT_SUPPORT_SAME_ACCOUNT_ONLY}. This is the expectation the |
| 526 | * directory has for data exported from it. Clients must obey this setting. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 527 | */ |
| 528 | public static final String EXPORT_SUPPORT = "exportSupport"; |
| 529 | |
| 530 | /** |
| 531 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 532 | * does not allow any data to be copied out of it. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 533 | */ |
| 534 | public static final int EXPORT_SUPPORT_NONE = 0; |
| 535 | |
| 536 | /** |
| 537 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 538 | * allow its data copied only to the account specified by |
| 539 | * {@link #ACCOUNT_TYPE}/{@link #ACCOUNT_NAME}. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 540 | */ |
| 541 | public static final int EXPORT_SUPPORT_SAME_ACCOUNT_ONLY = 1; |
| 542 | |
| 543 | /** |
| 544 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 545 | * allow its data copied to any contacts account. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 546 | */ |
| 547 | public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2; |
| 548 | |
| 549 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 550 | * One of {@link #SHORTCUT_SUPPORT_NONE}, {@link #SHORTCUT_SUPPORT_DATA_ITEMS_ONLY}, |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 551 | * {@link #SHORTCUT_SUPPORT_FULL}. This is the expectation the directory |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 552 | * has for shortcuts created for its elements. Clients must obey this setting. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 553 | */ |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 554 | public static final String SHORTCUT_SUPPORT = "shortcutSupport"; |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 555 | |
| 556 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 557 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 558 | * does not allow any shortcuts created for its contacts. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 559 | */ |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 560 | public static final int SHORTCUT_SUPPORT_NONE = 0; |
| 561 | |
| 562 | /** |
| 563 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 564 | * allow creation of shortcuts for data items like email, phone or postal address, |
| 565 | * but not the entire contact. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 566 | */ |
| 567 | public static final int SHORTCUT_SUPPORT_DATA_ITEMS_ONLY = 1; |
| 568 | |
| 569 | /** |
| 570 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 571 | * allow creation of shortcuts for contact as well as their constituent elements. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 572 | */ |
| 573 | public static final int SHORTCUT_SUPPORT_FULL = 2; |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 574 | |
| 575 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 576 | * One of {@link #PHOTO_SUPPORT_NONE}, {@link #PHOTO_SUPPORT_THUMBNAIL_ONLY}, |
| 577 | * {@link #PHOTO_SUPPORT_FULL}. This is a feature flag indicating the extent |
| 578 | * to which the directory supports contact photos. |
| 579 | */ |
| 580 | public static final String PHOTO_SUPPORT = "photoSupport"; |
| 581 | |
| 582 | /** |
| 583 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 584 | * does not provide any photos. |
| 585 | */ |
| 586 | public static final int PHOTO_SUPPORT_NONE = 0; |
| 587 | |
| 588 | /** |
| 589 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 590 | * can only produce small size thumbnails of contact photos. |
| 591 | */ |
| 592 | public static final int PHOTO_SUPPORT_THUMBNAIL_ONLY = 1; |
| 593 | |
| 594 | /** |
| 595 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 596 | * has full-size contact photos, but cannot provide scaled thumbnails. |
| 597 | */ |
| 598 | public static final int PHOTO_SUPPORT_FULL_SIZE_ONLY = 2; |
| 599 | |
| 600 | /** |
| 601 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 602 | * can produce thumbnails as well as full-size contact photos. |
| 603 | */ |
| 604 | public static final int PHOTO_SUPPORT_FULL = 3; |
| 605 | |
| 606 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 607 | * Notifies the system of a change in the list of directories handled by |
| 608 | * a particular directory provider. The Contacts provider will turn around |
| 609 | * and send a query to the directory provider for the full list of directories, |
| 610 | * which will replace the previous list. |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 611 | */ |
| 612 | public static void notifyDirectoryChange(ContentResolver resolver) { |
| 613 | // This is done to trigger a query by Contacts Provider back to the directory provider. |
| 614 | // No data needs to be sent back, because the provider can infer the calling |
| 615 | // package from binder. |
| 616 | ContentValues contentValues = new ContentValues(); |
| 617 | resolver.update(Directory.CONTENT_URI, contentValues, null, null); |
| 618 | } |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 619 | } |
| 620 | |
| 621 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 622 | * @hide should be removed when users are updated to refer to SyncState |
| 623 | * @deprecated use SyncState instead |
| 624 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 625 | @Deprecated |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 626 | public interface SyncStateColumns extends SyncStateContract.Columns { |
| 627 | } |
| 628 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 629 | /** |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 630 | * 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] | 631 | * |
| 632 | * @see SyncStateContract |
| 633 | */ |
| 634 | public static final class SyncState implements SyncStateContract.Columns { |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 635 | /** |
| 636 | * This utility class cannot be instantiated |
| 637 | */ |
| 638 | private SyncState() {} |
| 639 | |
| 640 | public static final String CONTENT_DIRECTORY = |
| 641 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 642 | |
| 643 | /** |
| 644 | * The content:// style URI for this table |
| 645 | */ |
| 646 | public static final Uri CONTENT_URI = |
| 647 | Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY); |
| 648 | |
| 649 | /** |
| 650 | * @see android.provider.SyncStateContract.Helpers#get |
| 651 | */ |
| 652 | public static byte[] get(ContentProviderClient provider, Account account) |
| 653 | throws RemoteException { |
| 654 | return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| 655 | } |
| 656 | |
| 657 | /** |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 658 | * @see android.provider.SyncStateContract.Helpers#get |
| 659 | */ |
| 660 | public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) |
| 661 | throws RemoteException { |
| 662 | return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); |
| 663 | } |
| 664 | |
| 665 | /** |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 666 | * @see android.provider.SyncStateContract.Helpers#set |
| 667 | */ |
| 668 | public static void set(ContentProviderClient provider, Account account, byte[] data) |
| 669 | throws RemoteException { |
| 670 | SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| 671 | } |
| 672 | |
| 673 | /** |
| 674 | * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| 675 | */ |
| 676 | public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| 677 | return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| 678 | } |
| 679 | } |
| 680 | |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 681 | |
| 682 | /** |
| 683 | * A table provided for sync adapters to use for storing private sync state data for the |
| 684 | * user's personal profile. |
| 685 | * |
| 686 | * @see SyncStateContract |
| 687 | */ |
| 688 | public static final class ProfileSyncState implements SyncStateContract.Columns { |
| 689 | /** |
| 690 | * This utility class cannot be instantiated |
| 691 | */ |
| 692 | private ProfileSyncState() {} |
| 693 | |
| 694 | public static final String CONTENT_DIRECTORY = |
| 695 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 696 | |
| 697 | /** |
| 698 | * The content:// style URI for this table |
| 699 | */ |
| 700 | public static final Uri CONTENT_URI = |
| 701 | Uri.withAppendedPath(Profile.CONTENT_URI, CONTENT_DIRECTORY); |
| 702 | |
| 703 | /** |
| 704 | * @see android.provider.SyncStateContract.Helpers#get |
| 705 | */ |
| 706 | public static byte[] get(ContentProviderClient provider, Account account) |
| 707 | throws RemoteException { |
| 708 | return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| 709 | } |
| 710 | |
| 711 | /** |
| 712 | * @see android.provider.SyncStateContract.Helpers#get |
| 713 | */ |
| 714 | public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) |
| 715 | throws RemoteException { |
| 716 | return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); |
| 717 | } |
| 718 | |
| 719 | /** |
| 720 | * @see android.provider.SyncStateContract.Helpers#set |
| 721 | */ |
| 722 | public static void set(ContentProviderClient provider, Account account, byte[] data) |
| 723 | throws RemoteException { |
| 724 | SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| 725 | } |
| 726 | |
| 727 | /** |
| 728 | * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| 729 | */ |
| 730 | public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| 731 | return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| 732 | } |
| 733 | } |
| 734 | |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 735 | /** |
| 736 | * Generic columns for use by sync adapters. The specific functions of |
| 737 | * these columns are private to the sync adapter. Other clients of the API |
| 738 | * should not attempt to either read or write this column. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 739 | * |
| 740 | * @see RawContacts |
| 741 | * @see Groups |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 742 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 743 | protected interface BaseSyncColumns { |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 744 | |
| 745 | /** Generic column for use by sync adapters. */ |
| 746 | public static final String SYNC1 = "sync1"; |
| 747 | /** Generic column for use by sync adapters. */ |
| 748 | public static final String SYNC2 = "sync2"; |
| 749 | /** Generic column for use by sync adapters. */ |
| 750 | public static final String SYNC3 = "sync3"; |
| 751 | /** Generic column for use by sync adapters. */ |
| 752 | public static final String SYNC4 = "sync4"; |
| 753 | } |
| 754 | |
| 755 | /** |
| 756 | * Columns that appear when each row of a table belongs to a specific |
| 757 | * account, including sync information that an account may need. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 758 | * |
| 759 | * @see RawContacts |
| 760 | * @see Groups |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 761 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 762 | protected interface SyncColumns extends BaseSyncColumns { |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 763 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 764 | * The name of the account instance to which this row belongs, which when paired with |
| 765 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 766 | * <P>Type: TEXT</P> |
| 767 | */ |
| 768 | public static final String ACCOUNT_NAME = "account_name"; |
| 769 | |
| 770 | /** |
| 771 | * The type of account to which this row belongs, which when paired with |
| 772 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 773 | * <P>Type: TEXT</P> |
| 774 | */ |
| 775 | public static final String ACCOUNT_TYPE = "account_type"; |
| 776 | |
| 777 | /** |
| 778 | * String that uniquely identifies this row to its source account. |
| 779 | * <P>Type: TEXT</P> |
| 780 | */ |
| 781 | public static final String SOURCE_ID = "sourceid"; |
| 782 | |
| 783 | /** |
| 784 | * Version number that is updated whenever this row or its related data |
| 785 | * changes. |
| 786 | * <P>Type: INTEGER</P> |
| 787 | */ |
| 788 | public static final String VERSION = "version"; |
| 789 | |
| 790 | /** |
| 791 | * Flag indicating that {@link #VERSION} has changed, and this row needs |
| 792 | * to be synchronized by its owning account. |
| 793 | * <P>Type: INTEGER (boolean)</P> |
| 794 | */ |
| 795 | public static final String DIRTY = "dirty"; |
| 796 | } |
| 797 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 798 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 799 | * Columns of {@link ContactsContract.Contacts} that track the user's |
| 800 | * preferences for, or interactions with, the contact. |
| 801 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 802 | * @see Contacts |
| 803 | * @see RawContacts |
| 804 | * @see ContactsContract.Data |
| 805 | * @see PhoneLookup |
| 806 | * @see ContactsContract.Contacts.AggregationSuggestions |
| 807 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 808 | protected interface ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 809 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 810 | * The number of times a contact has been contacted |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 811 | * <P>Type: INTEGER</P> |
| 812 | */ |
| 813 | public static final String TIMES_CONTACTED = "times_contacted"; |
| 814 | |
| 815 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 816 | * The last time a contact was contacted. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 817 | * <P>Type: INTEGER</P> |
| 818 | */ |
| 819 | public static final String LAST_TIME_CONTACTED = "last_time_contacted"; |
| 820 | |
| 821 | /** |
| 822 | * Is the contact starred? |
| 823 | * <P>Type: INTEGER (boolean)</P> |
| 824 | */ |
| 825 | public static final String STARRED = "starred"; |
| 826 | |
| 827 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 828 | * URI for a custom ringtone associated with the contact. If null or missing, |
| 829 | * the default ringtone is used. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 830 | * <P>Type: TEXT (URI to the ringtone)</P> |
| 831 | */ |
| 832 | public static final String CUSTOM_RINGTONE = "custom_ringtone"; |
| 833 | |
| 834 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 835 | * Whether the contact should always be sent to voicemail. If missing, |
| 836 | * defaults to false. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 837 | * <P>Type: INTEGER (0 for false, 1 for true)</P> |
| 838 | */ |
| 839 | public static final String SEND_TO_VOICEMAIL = "send_to_voicemail"; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 840 | } |
| 841 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 842 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 843 | * Columns of {@link ContactsContract.Contacts} that refer to intrinsic |
| 844 | * properties of the contact, as opposed to the user-specified options |
| 845 | * found in {@link ContactOptionsColumns}. |
| 846 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 847 | * @see Contacts |
| 848 | * @see ContactsContract.Data |
| 849 | * @see PhoneLookup |
| 850 | * @see ContactsContract.Contacts.AggregationSuggestions |
| 851 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 852 | protected interface ContactsColumns { |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 853 | /** |
| 854 | * The display name for the contact. |
| 855 | * <P>Type: TEXT</P> |
| 856 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 857 | public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY; |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 858 | |
| 859 | /** |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 860 | * Reference to the row in the RawContacts table holding the contact name. |
| 861 | * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P> |
| 862 | * @hide |
| 863 | */ |
| 864 | public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id"; |
| 865 | |
| 866 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 867 | * Reference to the row in the data table holding the photo. A photo can |
| 868 | * be referred to either by ID (this field) or by URI (see {@link #PHOTO_THUMBNAIL_URI} |
| 869 | * and {@link #PHOTO_URI}). |
| 870 | * If PHOTO_ID is null, consult {@link #PHOTO_URI} or {@link #PHOTO_THUMBNAIL_URI}, |
| 871 | * which is a more generic mechanism for referencing the contact photo, especially for |
| 872 | * contacts returned by non-local directories (see {@link Directory}). |
| 873 | * |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 874 | * <P>Type: INTEGER REFERENCES data(_id)</P> |
| 875 | */ |
| 876 | public static final String PHOTO_ID = "photo_id"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 877 | |
| 878 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 879 | * Photo file ID of the full-size photo. If present, this will be used to populate |
| 880 | * {@link #PHOTO_URI}. The ID can also be used with |
| 881 | * {@link ContactsContract.DisplayPhoto#CONTENT_URI} to create a URI to the photo. |
| 882 | * If this is present, {@link #PHOTO_ID} is also guaranteed to be populated. |
| 883 | * |
| 884 | * <P>Type: INTEGER</P> |
| 885 | */ |
| 886 | public static final String PHOTO_FILE_ID = "photo_file_id"; |
| 887 | |
| 888 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 889 | * 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] | 890 | * If PHOTO_FILE_ID is not null, this will be populated with a URI based off |
| 891 | * {@link ContactsContract.DisplayPhoto#CONTENT_URI}. Otherwise, this will |
| 892 | * be populated with the same value as {@link #PHOTO_THUMBNAIL_URI}. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 893 | * 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] | 894 | * (see {@link #PHOTO_ID}). If either PHOTO_FILE_ID or PHOTO_ID is not null, |
| 895 | * PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily |
| 896 | * vice versa). Thus using PHOTO_URI is a more robust method of retrieving |
| 897 | * contact photos. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 898 | * |
| 899 | * <P>Type: TEXT</P> |
| 900 | */ |
| 901 | public static final String PHOTO_URI = "photo_uri"; |
| 902 | |
| 903 | /** |
| 904 | * A URI that can be used to retrieve a thumbnail of the contact's photo. |
| 905 | * A photo can be referred to either by a URI (this field or {@link #PHOTO_URI}) |
| 906 | * or by ID (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and |
| 907 | * PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa). |
| 908 | * If the content provider does not differentiate between full-size photos |
| 909 | * and thumbnail photos, PHOTO_THUMBNAIL_URI and {@link #PHOTO_URI} can contain |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 910 | * 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] | 911 | * |
| 912 | * <P>Type: TEXT</P> |
| 913 | */ |
| 914 | public static final String PHOTO_THUMBNAIL_URI = "photo_thumb_uri"; |
| 915 | |
| 916 | /** |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 917 | * Flag that reflects the {@link Groups#GROUP_VISIBLE} state of any |
| 918 | * {@link CommonDataKinds.GroupMembership} for this contact. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 919 | */ |
| 920 | public static final String IN_VISIBLE_GROUP = "in_visible_group"; |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 921 | |
| 922 | /** |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 923 | * Flag that reflects whether this contact represents the user's |
| 924 | * personal profile entry. |
| 925 | */ |
| 926 | public static final String IS_USER_PROFILE = "is_user_profile"; |
| 927 | |
| 928 | /** |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 929 | * An indicator of whether this contact has at least one phone number. "1" if there is |
| 930 | * at least one phone number, "0" otherwise. |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 931 | * <P>Type: INTEGER</P> |
| 932 | */ |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 933 | public static final String HAS_PHONE_NUMBER = "has_phone_number"; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 934 | |
| 935 | /** |
| 936 | * An opaque value that contains hints on how to find the contact if |
| 937 | * its row id changed as a result of a sync or aggregation. |
| 938 | */ |
| 939 | public static final String LOOKUP_KEY = "lookup"; |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 940 | |
| 941 | /** |
| 942 | * Timestamp (milliseconds since epoch) of when this contact was last updated. This |
| 943 | * includes updates to all data associated with this contact including raw contacts. Any |
| 944 | * modification (including deletes and inserts) of underlying contact data are also |
| 945 | * reflected in this timestamp. |
| 946 | */ |
| 947 | public static final String CONTACT_LAST_UPDATED_TIMESTAMP = |
| 948 | "contact_last_updated_timestamp"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 949 | } |
| 950 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 951 | /** |
| 952 | * @see Contacts |
| 953 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 954 | protected interface ContactStatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 955 | /** |
| 956 | * Contact presence status. See {@link StatusUpdates} for individual status |
| 957 | * definitions. |
| 958 | * <p>Type: NUMBER</p> |
| 959 | */ |
| 960 | public static final String CONTACT_PRESENCE = "contact_presence"; |
| 961 | |
| 962 | /** |
Vasu Nori | fb5bccf | 2010-07-19 14:11:54 -0700 | [diff] [blame] | 963 | * Contact Chat Capabilities. See {@link StatusUpdates} for individual |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 964 | * definitions. |
| 965 | * <p>Type: NUMBER</p> |
| 966 | */ |
| 967 | public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability"; |
| 968 | |
| 969 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 970 | * Contact's latest status update. |
| 971 | * <p>Type: TEXT</p> |
| 972 | */ |
| 973 | public static final String CONTACT_STATUS = "contact_status"; |
| 974 | |
| 975 | /** |
| 976 | * The absolute time in milliseconds when the latest status was |
| 977 | * inserted/updated. |
| 978 | * <p>Type: NUMBER</p> |
| 979 | */ |
| 980 | public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts"; |
| 981 | |
| 982 | /** |
| 983 | * The package containing resources for this status: label and icon. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 984 | * <p>Type: TEXT</p> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 985 | */ |
| 986 | public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package"; |
| 987 | |
| 988 | /** |
| 989 | * The resource ID of the label describing the source of contact |
| 990 | * status, e.g. "Google Talk". This resource is scoped by the |
| 991 | * {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 992 | * <p>Type: NUMBER</p> |
| 993 | */ |
| 994 | public static final String CONTACT_STATUS_LABEL = "contact_status_label"; |
| 995 | |
| 996 | /** |
| 997 | * The resource ID of the icon for the source of contact status. This |
| 998 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 999 | * <p>Type: NUMBER</p> |
| 1000 | */ |
| 1001 | public static final String CONTACT_STATUS_ICON = "contact_status_icon"; |
| 1002 | } |
| 1003 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1004 | /** |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1005 | * Constants for various styles of combining given name, family name etc into |
| 1006 | * a full name. For example, the western tradition follows the pattern |
| 1007 | * 'given name' 'middle name' 'family name' with the alternative pattern being |
| 1008 | * 'family name', 'given name' 'middle name'. The CJK tradition is |
| 1009 | * 'family name' 'middle name' 'given name', with Japanese favoring a space between |
| 1010 | * the names and Chinese omitting the space. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1011 | */ |
| 1012 | public interface FullNameStyle { |
| 1013 | public static final int UNDEFINED = 0; |
| 1014 | public static final int WESTERN = 1; |
| 1015 | |
| 1016 | /** |
| 1017 | * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine |
| 1018 | * which specific language it belongs to: Chinese, Japanese or Korean. |
| 1019 | */ |
| 1020 | public static final int CJK = 2; |
| 1021 | |
| 1022 | public static final int CHINESE = 3; |
| 1023 | public static final int JAPANESE = 4; |
| 1024 | public static final int KOREAN = 5; |
| 1025 | } |
| 1026 | |
| 1027 | /** |
| 1028 | * 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] | 1029 | */ |
| 1030 | public interface PhoneticNameStyle { |
| 1031 | public static final int UNDEFINED = 0; |
| 1032 | |
| 1033 | /** |
| 1034 | * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly |
| 1035 | * shown in UIs, but used for searches and sorting. |
| 1036 | */ |
| 1037 | public static final int PINYIN = 3; |
| 1038 | |
| 1039 | /** |
| 1040 | * Hiragana and Katakana are two common styles of writing out the pronunciation |
| 1041 | * of a Japanese names. |
| 1042 | */ |
| 1043 | public static final int JAPANESE = 4; |
| 1044 | |
| 1045 | /** |
| 1046 | * Hangul is the Korean phonetic alphabet. |
| 1047 | */ |
| 1048 | public static final int KOREAN = 5; |
| 1049 | } |
| 1050 | |
| 1051 | /** |
Dmitri Plotnikov | dbcdbf2 | 2011-02-23 15:49:58 -0800 | [diff] [blame] | 1052 | * Types of data used to produce the display name for a contact. In the order |
| 1053 | * of increasing priority: {@link #EMAIL}, {@link #PHONE}, |
| 1054 | * {@link #ORGANIZATION}, {@link #NICKNAME}, {@link #STRUCTURED_NAME}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1055 | */ |
| 1056 | public interface DisplayNameSources { |
| 1057 | public static final int UNDEFINED = 0; |
| 1058 | public static final int EMAIL = 10; |
| 1059 | public static final int PHONE = 20; |
| 1060 | public static final int ORGANIZATION = 30; |
| 1061 | public static final int NICKNAME = 35; |
| 1062 | public static final int STRUCTURED_NAME = 40; |
| 1063 | } |
| 1064 | |
| 1065 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 1066 | * Contact name and contact name metadata columns in the RawContacts table. |
| 1067 | * |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1068 | * @see Contacts |
| 1069 | * @see RawContacts |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1070 | */ |
| 1071 | protected interface ContactNameColumns { |
| 1072 | |
| 1073 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1074 | * 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] | 1075 | * structured name or email address. See {@link DisplayNameSources}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1076 | */ |
| 1077 | public static final String DISPLAY_NAME_SOURCE = "display_name_source"; |
| 1078 | |
| 1079 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1080 | * <p> |
| 1081 | * The standard text shown as the contact's display name, based on the best |
| 1082 | * available information for the contact (for example, it might be the email address |
| 1083 | * if the name is not available). |
| 1084 | * The information actually used to compute the name is stored in |
| 1085 | * {@link #DISPLAY_NAME_SOURCE}. |
| 1086 | * </p> |
| 1087 | * <p> |
| 1088 | * A contacts provider is free to choose whatever representation makes most |
| 1089 | * sense for its target market. |
| 1090 | * For example in the default Android Open Source Project implementation, |
| 1091 | * if the display name is |
| 1092 | * based on the structured name and the structured name follows |
| 1093 | * the Western full-name style, then this field contains the "given name first" |
| 1094 | * version of the full name. |
| 1095 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1096 | * |
| 1097 | * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1098 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1099 | public static final String DISPLAY_NAME_PRIMARY = "display_name"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1100 | |
| 1101 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1102 | * <p> |
| 1103 | * An alternative representation of the display name, such as "family name first" |
| 1104 | * instead of "given name first" for Western names. If an alternative is not |
| 1105 | * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}. |
| 1106 | * </p> |
| 1107 | * <p> |
| 1108 | * A contacts provider is free to provide alternatives as necessary for |
| 1109 | * its target market. |
| 1110 | * For example the default Android Open Source Project contacts provider |
| 1111 | * currently provides an |
| 1112 | * alternative in a single case: if the display name is |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1113 | * based on the structured name and the structured name follows |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1114 | * the Western full name style, then the field contains the "family name first" |
| 1115 | * version of the full name. |
| 1116 | * Other cases may be added later. |
| 1117 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1118 | */ |
| 1119 | public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt"; |
| 1120 | |
| 1121 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1122 | * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}. See |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 1123 | * {@link PhoneticNameStyle}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1124 | */ |
| 1125 | public static final String PHONETIC_NAME_STYLE = "phonetic_name_style"; |
| 1126 | |
| 1127 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1128 | * <p> |
| 1129 | * Pronunciation of the full name in the phonetic alphabet specified by |
| 1130 | * {@link #PHONETIC_NAME_STYLE}. |
| 1131 | * </p> |
| 1132 | * <p> |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 1133 | * The value may be set manually by the user. This capability is of |
| 1134 | * interest only in countries with commonly used phonetic alphabets, |
| 1135 | * such as Japan and Korea. See {@link PhoneticNameStyle}. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1136 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1137 | */ |
| 1138 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 1139 | |
| 1140 | /** |
| 1141 | * Sort key that takes into account locale-based traditions for sorting |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1142 | * names in address books. The default |
| 1143 | * sort key is {@link #DISPLAY_NAME_PRIMARY}. For Chinese names |
| 1144 | * 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] | 1145 | * it is the Hiragana version of the phonetic name. |
| 1146 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1147 | public static final String SORT_KEY_PRIMARY = "sort_key"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1148 | |
| 1149 | /** |
| 1150 | * Sort key based on the alternative representation of the full name, |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1151 | * {@link #DISPLAY_NAME_ALTERNATIVE}. Thus for Western names, |
Dmitri Plotnikov | 2a650dd | 2010-01-26 17:28:52 -0800 | [diff] [blame] | 1152 | * it is the one using the "family name first" format. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1153 | */ |
| 1154 | public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt"; |
| 1155 | } |
| 1156 | |
| 1157 | /** |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1158 | * URI parameter and cursor extras that return counts of rows grouped by the |
| 1159 | * address book index, which is usually the first letter of the sort key. |
| 1160 | * When this parameter is supplied, the row counts are returned in the |
| 1161 | * cursor extras bundle. |
| 1162 | * |
| 1163 | * @hide |
| 1164 | */ |
| 1165 | public final static class ContactCounts { |
| 1166 | |
| 1167 | /** |
| 1168 | * Add this query parameter to a URI to get back row counts grouped by |
| 1169 | * the address book index as cursor extras. For most languages it is the |
| 1170 | * first letter of the sort key. This parameter does not affect the main |
| 1171 | * content of the cursor. |
| 1172 | * |
| 1173 | * @hide |
| 1174 | */ |
| 1175 | public static final String ADDRESS_BOOK_INDEX_EXTRAS = "address_book_index_extras"; |
| 1176 | |
| 1177 | /** |
| 1178 | * The array of address book index titles, which are returned in the |
| 1179 | * same order as the data in the cursor. |
| 1180 | * <p>TYPE: String[]</p> |
| 1181 | * |
| 1182 | * @hide |
| 1183 | */ |
| 1184 | public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "address_book_index_titles"; |
| 1185 | |
| 1186 | /** |
| 1187 | * The array of group counts for the corresponding group. Contains the same number |
| 1188 | * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array. |
| 1189 | * <p>TYPE: int[]</p> |
| 1190 | * |
| 1191 | * @hide |
| 1192 | */ |
| 1193 | public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "address_book_index_counts"; |
| 1194 | } |
| 1195 | |
| 1196 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1197 | * Constants for the contacts table, which contains a record per aggregate |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1198 | * of raw contacts representing the same person. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1199 | * <h3>Operations</h3> |
| 1200 | * <dl> |
| 1201 | * <dt><b>Insert</b></dt> |
| 1202 | * <dd>A Contact cannot be created explicitly. When a raw contact is |
| 1203 | * inserted, the provider will first try to find a Contact representing the |
| 1204 | * same person. If one is found, the raw contact's |
| 1205 | * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate |
| 1206 | * Contact. If no match is found, the provider automatically inserts a new |
| 1207 | * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column |
| 1208 | * of the newly inserted raw contact.</dd> |
| 1209 | * <dt><b>Update</b></dt> |
| 1210 | * <dd>Only certain columns of Contact are modifiable: |
| 1211 | * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED}, |
| 1212 | * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of |
| 1213 | * these columns on the Contact also changes them on all constituent raw |
| 1214 | * contacts.</dd> |
| 1215 | * <dt><b>Delete</b></dt> |
| 1216 | * <dd>Be careful with deleting Contacts! Deleting an aggregate contact |
| 1217 | * deletes all constituent raw contacts. The corresponding sync adapters |
| 1218 | * will notice the deletions of their respective raw contacts and remove |
| 1219 | * them from their back end storage.</dd> |
| 1220 | * <dt><b>Query</b></dt> |
| 1221 | * <dd> |
| 1222 | * <ul> |
| 1223 | * <li>If you need to read an individual contact, consider using |
| 1224 | * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li> |
| 1225 | * <li>If you need to look up a contact by the phone number, use |
| 1226 | * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI}, |
| 1227 | * which is optimized for this purpose.</li> |
| 1228 | * <li>If you need to look up a contact by partial name, e.g. to produce |
| 1229 | * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI. |
| 1230 | * <li>If you need to look up a contact by some data element like email |
| 1231 | * address, nickname, etc, use a query against the {@link ContactsContract.Data} table. |
| 1232 | * The result will contain contact ID, name etc. |
| 1233 | * </ul> |
| 1234 | * </dd> |
| 1235 | * </dl> |
| 1236 | * <h2>Columns</h2> |
| 1237 | * <table class="jd-sumtable"> |
| 1238 | * <tr> |
| 1239 | * <th colspan='4'>Contacts</th> |
| 1240 | * </tr> |
| 1241 | * <tr> |
| 1242 | * <td>long</td> |
| 1243 | * <td>{@link #_ID}</td> |
| 1244 | * <td>read-only</td> |
| 1245 | * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td> |
| 1246 | * </tr> |
| 1247 | * <tr> |
| 1248 | * <td>String</td> |
| 1249 | * <td>{@link #LOOKUP_KEY}</td> |
| 1250 | * <td>read-only</td> |
| 1251 | * <td>An opaque value that contains hints on how to find the contact if its |
| 1252 | * row id changed as a result of a sync or aggregation.</td> |
| 1253 | * </tr> |
| 1254 | * <tr> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1255 | * <td>long</td> |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1256 | * <td>NAME_RAW_CONTACT_ID</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1257 | * <td>read-only</td> |
| 1258 | * <td>The ID of the raw contact that contributes the display name |
| 1259 | * to the aggregate contact. During aggregation one of the constituent |
| 1260 | * raw contacts is chosen using a heuristic: a longer name or a name |
| 1261 | * with more diacritic marks or more upper case characters is chosen.</td> |
| 1262 | * </tr> |
| 1263 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1264 | * <td>String</td> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1265 | * <td>DISPLAY_NAME_PRIMARY</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1266 | * <td>read-only</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1267 | * <td>The display name for the contact. It is the display name |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1268 | * 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] | 1269 | * column.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1270 | * </tr> |
| 1271 | * <tr> |
| 1272 | * <td>long</td> |
| 1273 | * <td>{@link #PHOTO_ID}</td> |
| 1274 | * <td>read-only</td> |
| 1275 | * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo. |
| 1276 | * That row has the mime type |
| 1277 | * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field |
| 1278 | * is computed automatically based on the |
| 1279 | * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of |
| 1280 | * that mime type.</td> |
| 1281 | * </tr> |
| 1282 | * <tr> |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 1283 | * <td>long</td> |
| 1284 | * <td>{@link #PHOTO_URI}</td> |
| 1285 | * <td>read-only</td> |
| 1286 | * <td>A URI that can be used to retrieve the contact's full-size photo. This |
| 1287 | * column is the preferred method of retrieving the contact photo.</td> |
| 1288 | * </tr> |
| 1289 | * <tr> |
| 1290 | * <td>long</td> |
| 1291 | * <td>{@link #PHOTO_THUMBNAIL_URI}</td> |
| 1292 | * <td>read-only</td> |
| 1293 | * <td>A URI that can be used to retrieve the thumbnail of contact's photo. This |
| 1294 | * column is the preferred method of retrieving the contact photo.</td> |
| 1295 | * </tr> |
| 1296 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1297 | * <td>int</td> |
| 1298 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 1299 | * <td>read-only</td> |
| 1300 | * <td>An indicator of whether this contact is supposed to be visible in the |
| 1301 | * UI. "1" if the contact has at least one raw contact that belongs to a |
| 1302 | * visible group; "0" otherwise.</td> |
| 1303 | * </tr> |
| 1304 | * <tr> |
| 1305 | * <td>int</td> |
| 1306 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 1307 | * <td>read-only</td> |
| 1308 | * <td>An indicator of whether this contact has at least one phone number. |
| 1309 | * "1" if there is at least one phone number, "0" otherwise.</td> |
| 1310 | * </tr> |
| 1311 | * <tr> |
| 1312 | * <td>int</td> |
| 1313 | * <td>{@link #TIMES_CONTACTED}</td> |
| 1314 | * <td>read/write</td> |
| 1315 | * <td>The number of times the contact has been contacted. See |
| 1316 | * {@link #markAsContacted}. When raw contacts are aggregated, this field is |
| 1317 | * computed automatically as the maximum number of times contacted among all |
| 1318 | * constituent raw contacts. Setting this field automatically changes the |
| 1319 | * corresponding field on all constituent raw contacts.</td> |
| 1320 | * </tr> |
| 1321 | * <tr> |
| 1322 | * <td>long</td> |
| 1323 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 1324 | * <td>read/write</td> |
| 1325 | * <td>The timestamp of the last time the contact was contacted. See |
| 1326 | * {@link #markAsContacted}. Setting this field also automatically |
| 1327 | * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated, |
| 1328 | * this field is computed automatically as the latest time contacted of all |
| 1329 | * constituent raw contacts. Setting this field automatically changes the |
| 1330 | * corresponding field on all constituent raw contacts.</td> |
| 1331 | * </tr> |
| 1332 | * <tr> |
| 1333 | * <td>int</td> |
| 1334 | * <td>{@link #STARRED}</td> |
| 1335 | * <td>read/write</td> |
| 1336 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
| 1337 | * When raw contacts are aggregated, this field is automatically computed: |
| 1338 | * if any constituent raw contacts are starred, then this field is set to |
| 1339 | * '1'. Setting this field automatically changes the corresponding field on |
| 1340 | * all constituent raw contacts.</td> |
| 1341 | * </tr> |
| 1342 | * <tr> |
| 1343 | * <td>String</td> |
| 1344 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 1345 | * <td>read/write</td> |
| 1346 | * <td>A custom ringtone associated with a contact. Typically this is the |
| 1347 | * URI returned by an activity launched with the |
| 1348 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td> |
| 1349 | * </tr> |
| 1350 | * <tr> |
| 1351 | * <td>int</td> |
| 1352 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 1353 | * <td>read/write</td> |
| 1354 | * <td>An indicator of whether calls from this contact should be forwarded |
| 1355 | * directly to voice mail ('1') or not ('0'). When raw contacts are |
| 1356 | * aggregated, this field is automatically computed: if <i>all</i> |
| 1357 | * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set |
| 1358 | * to '1'. Setting this field automatically changes the corresponding field |
| 1359 | * on all constituent raw contacts.</td> |
| 1360 | * </tr> |
| 1361 | * <tr> |
| 1362 | * <td>int</td> |
| 1363 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 1364 | * <td>read-only</td> |
| 1365 | * <td>Contact IM presence status. See {@link StatusUpdates} for individual |
| 1366 | * status definitions. Automatically computed as the highest presence of all |
| 1367 | * constituent raw contacts. The provider may choose not to store this value |
| 1368 | * in persistent storage. The expectation is that presence status will be |
kmccormick | 50e27c8 | 2013-03-28 16:33:11 -0700 | [diff] [blame] | 1369 | * updated on a regular basis.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1370 | * </tr> |
| 1371 | * <tr> |
| 1372 | * <td>String</td> |
| 1373 | * <td>{@link #CONTACT_STATUS}</td> |
| 1374 | * <td>read-only</td> |
| 1375 | * <td>Contact's latest status update. Automatically computed as the latest |
| 1376 | * of all constituent raw contacts' status updates.</td> |
| 1377 | * </tr> |
| 1378 | * <tr> |
| 1379 | * <td>long</td> |
| 1380 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 1381 | * <td>read-only</td> |
| 1382 | * <td>The absolute time in milliseconds when the latest status was |
| 1383 | * inserted/updated.</td> |
| 1384 | * </tr> |
| 1385 | * <tr> |
| 1386 | * <td>String</td> |
| 1387 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 1388 | * <td>read-only</td> |
| 1389 | * <td> The package containing resources for this status: label and icon.</td> |
| 1390 | * </tr> |
| 1391 | * <tr> |
| 1392 | * <td>long</td> |
| 1393 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 1394 | * <td>read-only</td> |
| 1395 | * <td>The resource ID of the label describing the source of contact status, |
| 1396 | * e.g. "Google Talk". This resource is scoped by the |
| 1397 | * {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1398 | * </tr> |
| 1399 | * <tr> |
| 1400 | * <td>long</td> |
| 1401 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 1402 | * <td>read-only</td> |
| 1403 | * <td>The resource ID of the icon for the source of contact status. This |
| 1404 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1405 | * </tr> |
| 1406 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1407 | */ |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 1408 | public static class Contacts implements BaseColumns, ContactsColumns, |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1409 | ContactOptionsColumns, ContactNameColumns, ContactStatusColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1410 | /** |
| 1411 | * This utility class cannot be instantiated |
| 1412 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1413 | private Contacts() {} |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1414 | |
| 1415 | /** |
| 1416 | * The content:// style URI for this table |
| 1417 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1418 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1419 | |
| 1420 | /** |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1421 | * A content:// style URI for this table that should be used to create |
| 1422 | * shortcuts or otherwise create long-term links to contacts. This URI |
| 1423 | * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}. |
| 1424 | * It can optionally also have a "/" and last known contact ID appended after |
| 1425 | * that. This "complete" format is an important optimization and is highly recommended. |
| 1426 | * <p> |
| 1427 | * As long as the contact's row ID remains the same, this URI is |
| 1428 | * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes |
| 1429 | * as a result of a sync or aggregation, this URI will look up the |
| 1430 | * contact using indirect information (sync IDs or constituent raw |
| 1431 | * contacts). |
| 1432 | * <p> |
| 1433 | * Lookup key should be appended unencoded - it is stored in the encoded |
| 1434 | * form, ready for use in a URI. |
| 1435 | */ |
| 1436 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1437 | "lookup"); |
| 1438 | |
| 1439 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1440 | * Base {@link Uri} for referencing a single {@link Contacts} entry, |
Jeff Sharkey | 8f76734 | 2009-09-28 18:22:46 -0700 | [diff] [blame] | 1441 | * created by appending {@link #LOOKUP_KEY} using |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1442 | * {@link Uri#withAppendedPath(Uri, String)}. Provides |
| 1443 | * {@link OpenableColumns} columns when queried, or returns the |
| 1444 | * referenced contact formatted as a vCard when opened through |
| 1445 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1446 | */ |
| 1447 | public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1448 | "as_vcard"); |
| 1449 | |
Martijn Coenen | 037d3ff | 2011-06-15 16:01:45 +0200 | [diff] [blame] | 1450 | /** |
| 1451 | * Boolean parameter that may be used with {@link #CONTENT_VCARD_URI} |
| 1452 | * and {@link #CONTENT_MULTI_VCARD_URI} to indicate that the returned |
| 1453 | * vcard should not contain a photo. |
| 1454 | * |
| 1455 | * @hide |
| 1456 | */ |
| 1457 | public static final String QUERY_PARAMETER_VCARD_NO_PHOTO = "nophoto"; |
| 1458 | |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1459 | /** |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1460 | * Base {@link Uri} for referencing multiple {@link Contacts} entry, |
| 1461 | * created by appending {@link #LOOKUP_KEY} using |
| 1462 | * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 1463 | * encoded and joined with the colon (":") separator. The resulting string |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1464 | * has to be encoded again. Provides |
| 1465 | * {@link OpenableColumns} columns when queried, or returns the |
| 1466 | * referenced contact formatted as a vCard when opened through |
| 1467 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1468 | * |
| 1469 | * This is private API because we do not have a well-defined way to |
| 1470 | * specify several entities yet. The format of this Uri might change in the future |
| 1471 | * or the Uri might be completely removed. |
| 1472 | * |
| 1473 | * @hide |
| 1474 | */ |
| 1475 | public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1476 | "as_multi_vcard"); |
| 1477 | |
| 1478 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1479 | * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the |
| 1480 | * requested {@link Contacts} entry. |
| 1481 | * |
| 1482 | * @param contactUri A {@link #CONTENT_URI} row, or an existing |
| 1483 | * {@link #CONTENT_LOOKUP_URI} to attempt refreshing. |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1484 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1485 | public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) { |
| 1486 | final Cursor c = resolver.query(contactUri, new String[] { |
| 1487 | Contacts.LOOKUP_KEY, Contacts._ID |
| 1488 | }, null, null, null); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1489 | if (c == null) { |
| 1490 | return null; |
| 1491 | } |
| 1492 | |
| 1493 | try { |
| 1494 | if (c.moveToFirst()) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1495 | final String lookupKey = c.getString(0); |
| 1496 | final long contactId = c.getLong(1); |
| 1497 | return getLookupUri(contactId, lookupKey); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1498 | } |
| 1499 | } finally { |
| 1500 | c.close(); |
| 1501 | } |
| 1502 | return null; |
| 1503 | } |
| 1504 | |
| 1505 | /** |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1506 | * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1507 | * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}. |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1508 | */ |
| 1509 | public static Uri getLookupUri(long contactId, String lookupKey) { |
| 1510 | return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, |
| 1511 | lookupKey), contactId); |
| 1512 | } |
| 1513 | |
| 1514 | /** |
Dmitri Plotnikov | b5759b5 | 2009-09-01 15:58:40 -0700 | [diff] [blame] | 1515 | * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI. |
| 1516 | * <p> |
| 1517 | * Returns null if the contact cannot be found. |
| 1518 | */ |
| 1519 | public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) { |
| 1520 | if (lookupUri == null) { |
| 1521 | return null; |
| 1522 | } |
| 1523 | |
| 1524 | Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null); |
| 1525 | if (c == null) { |
| 1526 | return null; |
| 1527 | } |
| 1528 | |
| 1529 | try { |
| 1530 | if (c.moveToFirst()) { |
| 1531 | long contactId = c.getLong(0); |
| 1532 | return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1533 | } |
| 1534 | } finally { |
| 1535 | c.close(); |
| 1536 | } |
| 1537 | return null; |
| 1538 | } |
| 1539 | |
| 1540 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1541 | * Mark a contact as having been contacted. Updates two fields: |
| 1542 | * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED}. The |
| 1543 | * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED |
| 1544 | * field is populated with the current system time. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1545 | * |
| 1546 | * @param resolver the ContentResolver to use |
| 1547 | * @param contactId the person who was contacted |
Daniel Lehmann | a1620dc | 2012-04-13 13:29:49 -0700 | [diff] [blame] | 1548 | * |
| 1549 | * @deprecated The class DataUsageStatUpdater of the Android support library should |
| 1550 | * be used instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1551 | */ |
Daniel Lehmann | a1620dc | 2012-04-13 13:29:49 -0700 | [diff] [blame] | 1552 | @Deprecated |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1553 | public static void markAsContacted(ContentResolver resolver, long contactId) { |
| 1554 | Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId); |
| 1555 | ContentValues values = new ContentValues(); |
| 1556 | // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified. |
| 1557 | values.put(LAST_TIME_CONTACTED, System.currentTimeMillis()); |
| 1558 | resolver.update(uri, values, null, null); |
| 1559 | } |
| 1560 | |
| 1561 | /** |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1562 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1563 | * {@link #CONTENT_URI} URI. The filter string will be used to match |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1564 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1565 | * as an additional path segment after this URI. |
| 1566 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1567 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 1568 | CONTENT_URI, "filter"); |
| 1569 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1570 | /** |
| 1571 | * The content:// style URI for this table joined with useful data from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1572 | * {@link ContactsContract.Data}, filtered to include only starred contacts |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1573 | * and the most frequently contacted contacts. |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1574 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1575 | public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath( |
| 1576 | CONTENT_URI, "strequent"); |
| 1577 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1578 | /** |
Daisuke Miyakawa | 3604bc5 | 2011-07-21 10:14:32 -0700 | [diff] [blame] | 1579 | * The content:// style URI for showing frequently contacted person listing. |
| 1580 | * @hide |
| 1581 | */ |
| 1582 | public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath( |
| 1583 | CONTENT_URI, "frequent"); |
| 1584 | |
| 1585 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1586 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1587 | * {@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] | 1588 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1589 | * as an additional path segment after this URI. |
| 1590 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1591 | public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath( |
| 1592 | CONTENT_STREQUENT_URI, "filter"); |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1593 | |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1594 | public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath( |
| 1595 | CONTENT_URI, "group"); |
| 1596 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1597 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1598 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 1599 | * people. |
| 1600 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1601 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1602 | |
| 1603 | /** |
| 1604 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1605 | * person. |
| 1606 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1607 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1608 | |
| 1609 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1610 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1611 | * person. |
| 1612 | */ |
| 1613 | public static final String CONTENT_VCARD_TYPE = "text/x-vcard"; |
| 1614 | |
| 1615 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1616 | * 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] | 1617 | * {@link ContactsContract.Data} rows. This directory can be used either |
| 1618 | * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1619 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1620 | public static final class Data implements BaseColumns, DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1621 | /** |
| 1622 | * no public constructor since this is a utility class |
| 1623 | */ |
| 1624 | private Data() {} |
| 1625 | |
| 1626 | /** |
| 1627 | * The directory twig for this sub-table |
| 1628 | */ |
| 1629 | public static final String CONTENT_DIRECTORY = "data"; |
| 1630 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1631 | |
| 1632 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1633 | * <p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1634 | * A sub-directory of a contact that contains all of its |
| 1635 | * {@link ContactsContract.RawContacts} as well as |
| 1636 | * {@link ContactsContract.Data} rows. To access this directory append |
| 1637 | * {@link #CONTENT_DIRECTORY} to the contact URI. |
| 1638 | * </p> |
| 1639 | * <p> |
| 1640 | * Entity has three ID fields: {@link #CONTACT_ID} for the contact, |
| 1641 | * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for |
| 1642 | * the data rows. Entity always contains at least one row per |
| 1643 | * constituent raw contact, even if there are no actual data rows. In |
| 1644 | * this case the {@link #DATA_ID} field will be null. |
| 1645 | * </p> |
| 1646 | * <p> |
| 1647 | * Entity reads all data for the entire contact in one transaction, to |
| 1648 | * guarantee consistency. There is significant data duplication |
| 1649 | * in the Entity (each row repeats all Contact columns and all RawContact |
| 1650 | * columns), so the benefits of transactional consistency should be weighed |
| 1651 | * against the cost of transferring large amounts of denormalized data |
| 1652 | * from the Provider. |
| 1653 | * </p> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 1654 | * <p> |
| 1655 | * To reduce the amount of data duplication the contacts provider and directory |
| 1656 | * providers implementing this protocol are allowed to provide common Contacts |
| 1657 | * and RawContacts fields in the first row returned for each raw contact only and |
| 1658 | * leave them as null in subsequent rows. |
| 1659 | * </p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1660 | */ |
| 1661 | public static final class Entity implements BaseColumns, ContactsColumns, |
| 1662 | ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns, |
| 1663 | StatusColumns, ContactOptionsColumns, ContactStatusColumns { |
| 1664 | /** |
| 1665 | * no public constructor since this is a utility class |
| 1666 | */ |
| 1667 | private Entity() { |
| 1668 | } |
| 1669 | |
| 1670 | /** |
| 1671 | * The directory twig for this sub-table |
| 1672 | */ |
| 1673 | public static final String CONTENT_DIRECTORY = "entities"; |
| 1674 | |
| 1675 | /** |
| 1676 | * The ID of the raw contact row. |
| 1677 | * <P>Type: INTEGER</P> |
| 1678 | */ |
| 1679 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 1680 | |
| 1681 | /** |
| 1682 | * The ID of the data row. The value will be null if this raw contact has no |
| 1683 | * data rows. |
| 1684 | * <P>Type: INTEGER</P> |
| 1685 | */ |
| 1686 | public static final String DATA_ID = "data_id"; |
| 1687 | } |
| 1688 | |
| 1689 | /** |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 1690 | * <p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1691 | * A sub-directory of a single contact that contains all of the constituent raw contact |
| 1692 | * {@link ContactsContract.StreamItems} rows. This directory can be used either |
| 1693 | * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}. |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 1694 | * </p> |
| 1695 | * <p> |
| 1696 | * Querying for social stream data requires android.permission.READ_SOCIAL_STREAM |
| 1697 | * permission. |
| 1698 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1699 | */ |
| 1700 | public static final class StreamItems implements StreamItemsColumns { |
| 1701 | /** |
| 1702 | * no public constructor since this is a utility class |
| 1703 | */ |
| 1704 | private StreamItems() {} |
| 1705 | |
| 1706 | /** |
| 1707 | * The directory twig for this sub-table |
| 1708 | */ |
| 1709 | public static final String CONTENT_DIRECTORY = "stream_items"; |
| 1710 | } |
| 1711 | |
| 1712 | /** |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1713 | * <p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1714 | * A <i>read-only</i> sub-directory of a single contact aggregate that |
| 1715 | * contains all aggregation suggestions (other contacts). The |
| 1716 | * aggregation suggestions are computed based on approximate data |
| 1717 | * matches with this contact. |
| 1718 | * </p> |
| 1719 | * <p> |
| 1720 | * <i>Note: this query may be expensive! If you need to use it in bulk, |
| 1721 | * make sure the user experience is acceptable when the query runs for a |
| 1722 | * long time.</i> |
| 1723 | * <p> |
| 1724 | * Usage example: |
| 1725 | * |
| 1726 | * <pre> |
| 1727 | * Uri uri = Contacts.CONTENT_URI.buildUpon() |
| 1728 | * .appendEncodedPath(String.valueOf(contactId)) |
| 1729 | * .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY) |
| 1730 | * .appendQueryParameter("limit", "3") |
| 1731 | * .build() |
| 1732 | * Cursor cursor = getContentResolver().query(suggestionsUri, |
| 1733 | * new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY}, |
| 1734 | * null, null, null); |
| 1735 | * </pre> |
| 1736 | * |
| 1737 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1738 | * <p> |
| 1739 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 1740 | * {@link #CONTENT_LOOKUP_URI}. |
| 1741 | * </p> |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1742 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1743 | public static final class AggregationSuggestions implements BaseColumns, ContactsColumns, |
| 1744 | ContactOptionsColumns, ContactStatusColumns { |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1745 | /** |
| 1746 | * No public constructor since this is a utility class |
| 1747 | */ |
| 1748 | private AggregationSuggestions() {} |
| 1749 | |
| 1750 | /** |
Dmitri Plotnikov | 0fc0244 | 2009-09-21 13:26:28 -0700 | [diff] [blame] | 1751 | * 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] | 1752 | * type-to-filter, similar to |
| 1753 | * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}. |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1754 | */ |
| 1755 | public static final String CONTENT_DIRECTORY = "suggestions"; |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1756 | |
| 1757 | /** |
| 1758 | * Used with {@link Builder#addParameter} to specify what kind of data is |
| 1759 | * supplied for the suggestion query. |
| 1760 | * |
| 1761 | * @hide |
| 1762 | */ |
| 1763 | public static final String PARAMETER_MATCH_NAME = "name"; |
| 1764 | |
| 1765 | /** |
| 1766 | * Used with {@link Builder#addParameter} to specify what kind of data is |
| 1767 | * supplied for the suggestion query. |
| 1768 | * |
| 1769 | * @hide |
| 1770 | */ |
| 1771 | public static final String PARAMETER_MATCH_EMAIL = "email"; |
| 1772 | |
| 1773 | /** |
| 1774 | * Used with {@link Builder#addParameter} to specify what kind of data is |
| 1775 | * supplied for the suggestion query. |
| 1776 | * |
| 1777 | * @hide |
| 1778 | */ |
| 1779 | public static final String PARAMETER_MATCH_PHONE = "phone"; |
| 1780 | |
| 1781 | /** |
| 1782 | * Used with {@link Builder#addParameter} to specify what kind of data is |
| 1783 | * supplied for the suggestion query. |
| 1784 | * |
| 1785 | * @hide |
| 1786 | */ |
| 1787 | public static final String PARAMETER_MATCH_NICKNAME = "nickname"; |
| 1788 | |
| 1789 | /** |
| 1790 | * A convenience builder for aggregation suggestion content URIs. |
| 1791 | * |
| 1792 | * TODO: change documentation for this class to use the builder. |
| 1793 | * @hide |
| 1794 | */ |
| 1795 | public static final class Builder { |
| 1796 | private long mContactId; |
| 1797 | private ArrayList<String> mKinds = new ArrayList<String>(); |
| 1798 | private ArrayList<String> mValues = new ArrayList<String>(); |
| 1799 | private int mLimit; |
| 1800 | |
| 1801 | /** |
| 1802 | * Optional existing contact ID. If it is not provided, the search |
| 1803 | * will be based exclusively on the values supplied with {@link #addParameter}. |
| 1804 | */ |
| 1805 | public Builder setContactId(long contactId) { |
| 1806 | this.mContactId = contactId; |
| 1807 | return this; |
| 1808 | } |
| 1809 | |
| 1810 | /** |
| 1811 | * A value that can be used when searching for an aggregation |
| 1812 | * suggestion. |
| 1813 | * |
| 1814 | * @param kind can be one of |
| 1815 | * {@link AggregationSuggestions#PARAMETER_MATCH_NAME}, |
| 1816 | * {@link AggregationSuggestions#PARAMETER_MATCH_EMAIL}, |
| 1817 | * {@link AggregationSuggestions#PARAMETER_MATCH_NICKNAME}, |
| 1818 | * {@link AggregationSuggestions#PARAMETER_MATCH_PHONE} |
| 1819 | */ |
| 1820 | public Builder addParameter(String kind, String value) { |
| 1821 | if (!TextUtils.isEmpty(value)) { |
| 1822 | mKinds.add(kind); |
| 1823 | mValues.add(value); |
| 1824 | } |
| 1825 | return this; |
| 1826 | } |
| 1827 | |
| 1828 | public Builder setLimit(int limit) { |
| 1829 | mLimit = limit; |
| 1830 | return this; |
| 1831 | } |
| 1832 | |
| 1833 | public Uri build() { |
| 1834 | android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon(); |
| 1835 | builder.appendEncodedPath(String.valueOf(mContactId)); |
| 1836 | builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY); |
| 1837 | if (mLimit != 0) { |
| 1838 | builder.appendQueryParameter("limit", String.valueOf(mLimit)); |
| 1839 | } |
| 1840 | |
| 1841 | int count = mKinds.size(); |
| 1842 | for (int i = 0; i < count; i++) { |
| 1843 | builder.appendQueryParameter("query", mKinds.get(i) + ":" + mValues.get(i)); |
| 1844 | } |
| 1845 | |
| 1846 | return builder.build(); |
| 1847 | } |
| 1848 | } |
| 1849 | |
| 1850 | /** |
| 1851 | * @hide |
| 1852 | */ |
| 1853 | public static final Builder builder() { |
| 1854 | return new Builder(); |
| 1855 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1856 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1857 | |
| 1858 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1859 | * 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] | 1860 | * the contact's primary photo. The photo may be stored in up to two ways - |
| 1861 | * the default "photo" is a thumbnail-sized image stored directly in the data |
| 1862 | * row, while the "display photo", if present, is a larger version stored as |
| 1863 | * a file. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1864 | * <p> |
| 1865 | * Usage example: |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1866 | * <dl> |
| 1867 | * <dt>Retrieving the thumbnail-sized photo</dt> |
| 1868 | * <dd> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1869 | * <pre> |
| 1870 | * public InputStream openPhoto(long contactId) { |
| 1871 | * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1872 | * Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY); |
| 1873 | * Cursor cursor = getContentResolver().query(photoUri, |
| 1874 | * new String[] {Contacts.Photo.PHOTO}, null, null, null); |
| 1875 | * if (cursor == null) { |
| 1876 | * return null; |
| 1877 | * } |
| 1878 | * try { |
| 1879 | * if (cursor.moveToFirst()) { |
| 1880 | * byte[] data = cursor.getBlob(0); |
| 1881 | * if (data != null) { |
| 1882 | * return new ByteArrayInputStream(data); |
| 1883 | * } |
| 1884 | * } |
| 1885 | * } finally { |
| 1886 | * cursor.close(); |
| 1887 | * } |
| 1888 | * return null; |
| 1889 | * } |
| 1890 | * </pre> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1891 | * </dd> |
| 1892 | * <dt>Retrieving the larger photo version</dt> |
| 1893 | * <dd> |
| 1894 | * <pre> |
| 1895 | * public InputStream openDisplayPhoto(long contactId) { |
| 1896 | * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1897 | * Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO); |
| 1898 | * try { |
| 1899 | * AssetFileDescriptor fd = |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 1900 | * getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1901 | * return fd.createInputStream(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 1902 | * } catch (IOException e) { |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1903 | * return null; |
| 1904 | * } |
| 1905 | * } |
| 1906 | * </pre> |
| 1907 | * </dd> |
| 1908 | * </dl> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1909 | * |
| 1910 | * </p> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1911 | * <p>You may also consider using the convenience method |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1912 | * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri, boolean)} |
| 1913 | * 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] | 1914 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1915 | * <p> |
| 1916 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 1917 | * {@link #CONTENT_LOOKUP_URI}. |
| 1918 | * </p> |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1919 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1920 | public static final class Photo implements BaseColumns, DataColumnsWithJoins { |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 1921 | /** |
| 1922 | * no public constructor since this is a utility class |
| 1923 | */ |
| 1924 | private Photo() {} |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 1925 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 1926 | /** |
| 1927 | * The directory twig for this sub-table |
| 1928 | */ |
| 1929 | public static final String CONTENT_DIRECTORY = "photo"; |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1930 | |
| 1931 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1932 | * The directory twig for retrieving the full-size display photo. |
| 1933 | */ |
| 1934 | public static final String DISPLAY_PHOTO = "display_photo"; |
| 1935 | |
| 1936 | /** |
| 1937 | * Full-size photo file ID of the raw contact. |
| 1938 | * See {@link ContactsContract.DisplayPhoto}. |
| 1939 | * <p> |
| 1940 | * Type: NUMBER |
| 1941 | */ |
| 1942 | public static final String PHOTO_FILE_ID = DATA14; |
| 1943 | |
| 1944 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1945 | * Thumbnail photo of the raw contact. This is the raw bytes of an image |
| 1946 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
| 1947 | * <p> |
| 1948 | * Type: BLOB |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1949 | */ |
| 1950 | public static final String PHOTO = DATA15; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1951 | } |
| 1952 | |
| 1953 | /** |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1954 | * Opens an InputStream for the contacts's photo and returns the |
| 1955 | * photo as a byte stream. |
| 1956 | * @param cr The content resolver to use for querying |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1957 | * @param contactUri the contact whose photo should be used. This can be used with |
| 1958 | * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI. |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1959 | * @param preferHighres If this is true and the contact has a higher resolution photo |
| 1960 | * 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] | 1961 | * @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] | 1962 | */ |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1963 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri, |
| 1964 | boolean preferHighres) { |
| 1965 | if (preferHighres) { |
| 1966 | final Uri displayPhotoUri = Uri.withAppendedPath(contactUri, |
| 1967 | Contacts.Photo.DISPLAY_PHOTO); |
| 1968 | InputStream inputStream; |
| 1969 | try { |
| 1970 | AssetFileDescriptor fd = cr.openAssetFileDescriptor(displayPhotoUri, "r"); |
| 1971 | return fd.createInputStream(); |
| 1972 | } catch (IOException e) { |
| 1973 | // fallback to the thumbnail code |
| 1974 | } |
| 1975 | } |
| 1976 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 1977 | Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY); |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 1978 | if (photoUri == null) { |
| 1979 | return null; |
| 1980 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1981 | Cursor cursor = cr.query(photoUri, |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1982 | new String[] { |
| 1983 | ContactsContract.CommonDataKinds.Photo.PHOTO |
| 1984 | }, null, null, null); |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1985 | try { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 1986 | if (cursor == null || !cursor.moveToNext()) { |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1987 | return null; |
| 1988 | } |
| 1989 | byte[] data = cursor.getBlob(0); |
| 1990 | if (data == null) { |
| 1991 | return null; |
| 1992 | } |
| 1993 | return new ByteArrayInputStream(data); |
| 1994 | } finally { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 1995 | if (cursor != null) { |
| 1996 | cursor.close(); |
| 1997 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1998 | } |
| 1999 | } |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2000 | |
| 2001 | /** |
| 2002 | * Opens an InputStream for the contacts's thumbnail photo and returns the |
| 2003 | * photo as a byte stream. |
| 2004 | * @param cr The content resolver to use for querying |
| 2005 | * @param contactUri the contact whose photo should be used. This can be used with |
| 2006 | * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI. |
| 2007 | * @return an InputStream of the photo, or null if no photo is present |
| 2008 | * @see #openContactPhotoInputStream(ContentResolver, Uri, boolean), if instead |
| 2009 | * of the thumbnail the high-res picture is preferred |
| 2010 | */ |
| 2011 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) { |
| 2012 | return openContactPhotoInputStream(cr, contactUri, false); |
| 2013 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2014 | } |
| 2015 | |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2016 | /** |
| 2017 | * <p> |
| 2018 | * Constants for the user's profile data, which is represented as a single contact on |
| 2019 | * the device that represents the user. The profile contact is not aggregated |
| 2020 | * together automatically in the same way that normal contacts are; instead, each |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 2021 | * account (including data set, if applicable) on the device may contribute a single |
| 2022 | * raw contact representing the user's personal profile data from that source. |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2023 | * </p> |
| 2024 | * <p> |
| 2025 | * Access to the profile entry through these URIs (or incidental access to parts of |
| 2026 | * the profile if retrieved directly via ID) requires additional permissions beyond |
| 2027 | * the read/write contact permissions required by the provider. Querying for profile |
| 2028 | * data requires android.permission.READ_PROFILE permission, and inserting or |
| 2029 | * updating profile data requires android.permission.WRITE_PROFILE permission. |
| 2030 | * </p> |
| 2031 | * <h3>Operations</h3> |
| 2032 | * <dl> |
| 2033 | * <dt><b>Insert</b></dt> |
| 2034 | * <dd>The user's profile entry cannot be created explicitly (attempting to do so |
| 2035 | * will throw an exception). When a raw contact is inserted into the profile, the |
| 2036 | * provider will check for the existence of a profile on the device. If one is |
| 2037 | * found, the raw contact's {@link RawContacts#CONTACT_ID} column gets the _ID of |
| 2038 | * the profile Contact. If no match is found, the profile Contact is created and |
| 2039 | * its _ID is put into the {@link RawContacts#CONTACT_ID} column of the newly |
| 2040 | * inserted raw contact.</dd> |
| 2041 | * <dt><b>Update</b></dt> |
| 2042 | * <dd>The profile Contact has the same update restrictions as Contacts in general, |
| 2043 | * but requires the android.permission.WRITE_PROFILE permission.</dd> |
| 2044 | * <dt><b>Delete</b></dt> |
| 2045 | * <dd>The profile Contact cannot be explicitly deleted. It will be removed |
| 2046 | * automatically if all of its constituent raw contact entries are deleted.</dd> |
| 2047 | * <dt><b>Query</b></dt> |
| 2048 | * <dd> |
| 2049 | * <ul> |
| 2050 | * <li>The {@link #CONTENT_URI} for profiles behaves in much the same way as |
| 2051 | * retrieving a contact by ID, except that it will only ever return the user's |
| 2052 | * profile contact. |
| 2053 | * </li> |
| 2054 | * <li> |
| 2055 | * The profile contact supports all of the same sub-paths as an individual contact |
| 2056 | * does - the content of the profile contact can be retrieved as entities or |
| 2057 | * data rows. Similarly, specific raw contact entries can be retrieved by appending |
| 2058 | * the desired raw contact ID within the profile. |
| 2059 | * </li> |
| 2060 | * </ul> |
| 2061 | * </dd> |
| 2062 | * </dl> |
| 2063 | */ |
| 2064 | public static final class Profile implements BaseColumns, ContactsColumns, |
| 2065 | ContactOptionsColumns, ContactNameColumns, ContactStatusColumns { |
| 2066 | /** |
| 2067 | * This utility class cannot be instantiated |
| 2068 | */ |
| 2069 | private Profile() { |
| 2070 | } |
| 2071 | |
| 2072 | /** |
| 2073 | * The content:// style URI for this table, which requests the contact entry |
| 2074 | * representing the user's personal profile data. |
| 2075 | */ |
| 2076 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "profile"); |
| 2077 | |
| 2078 | /** |
| 2079 | * {@link Uri} for referencing the user's profile {@link Contacts} entry, |
| 2080 | * Provides {@link OpenableColumns} columns when queried, or returns the |
| 2081 | * user's profile contact formatted as a vCard when opened through |
| 2082 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 2083 | */ |
| 2084 | public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 2085 | "as_vcard"); |
| 2086 | |
| 2087 | /** |
| 2088 | * {@link Uri} for referencing the raw contacts that make up the user's profile |
| 2089 | * {@link Contacts} entry. An individual raw contact entry within the profile |
| 2090 | * can be addressed by appending the raw contact ID. The entities or data within |
| 2091 | * that specific raw contact can be requested by appending the entity or data |
| 2092 | * path as well. |
| 2093 | */ |
| 2094 | public static final Uri CONTENT_RAW_CONTACTS_URI = Uri.withAppendedPath(CONTENT_URI, |
| 2095 | "raw_contacts"); |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 2096 | |
| 2097 | /** |
| 2098 | * The minimum ID for any entity that belongs to the profile. This essentially |
| 2099 | * defines an ID-space in which profile data is stored, and is used by the provider |
| 2100 | * to determine whether a request via a non-profile-specific URI should be directed |
| 2101 | * to the profile data rather than general contacts data, along with all the special |
| 2102 | * permission checks that entails. |
| 2103 | * |
| 2104 | * Callers may use {@link #isProfileId} to check whether a specific ID falls into |
| 2105 | * the set of data intended for the profile. |
| 2106 | */ |
| 2107 | public static final long MIN_ID = Long.MAX_VALUE - (long) Integer.MAX_VALUE; |
| 2108 | } |
| 2109 | |
| 2110 | /** |
| 2111 | * This method can be used to identify whether the given ID is associated with profile |
| 2112 | * data. It does not necessarily indicate that the ID is tied to valid data, merely |
| 2113 | * that accessing data using this ID will result in profile access checks and will only |
| 2114 | * return data from the profile. |
| 2115 | * |
| 2116 | * @param id The ID to check. |
| 2117 | * @return Whether the ID is associated with profile data. |
| 2118 | */ |
| 2119 | public static boolean isProfileId(long id) { |
| 2120 | return id >= Profile.MIN_ID; |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2121 | } |
| 2122 | |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 2123 | protected interface DeletedContactsColumns { |
| 2124 | |
| 2125 | /** |
| 2126 | * A reference to the {@link ContactsContract.Contacts#_ID} that was deleted. |
| 2127 | * <P>Type: INTEGER</P> |
| 2128 | */ |
| 2129 | public static final String CONTACT_ID = "contact_id"; |
| 2130 | |
| 2131 | /** |
| 2132 | * Time (milliseconds since epoch) that the contact was deleted. |
| 2133 | */ |
| 2134 | public static final String CONTACT_DELETED_TIMESTAMP = "contact_deleted_timestamp"; |
| 2135 | } |
| 2136 | |
| 2137 | /** |
| 2138 | * Constants for the deleted contact table. This table holds a log of deleted contacts. |
| 2139 | * <p> |
| 2140 | * Log older than {@link #DAYS_KEPT_MILLISECONDS} may be deleted. |
| 2141 | */ |
| 2142 | public static final class DeletedContacts implements DeletedContactsColumns { |
| 2143 | |
| 2144 | /** |
| 2145 | * This utility class cannot be instantiated |
| 2146 | */ |
| 2147 | private DeletedContacts() { |
| 2148 | } |
| 2149 | |
| 2150 | /** |
| 2151 | * The content:// style URI for this table, which requests a directory of raw contact rows |
| 2152 | * matching the selection criteria. |
| 2153 | */ |
| 2154 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 2155 | "deleted_contacts"); |
| 2156 | |
| 2157 | /** |
| 2158 | * Number of days that the delete log will be kept. After this time, delete records may be |
| 2159 | * deleted. |
| 2160 | * |
| 2161 | * @hide |
| 2162 | */ |
| 2163 | private static final int DAYS_KEPT = 30; |
| 2164 | |
| 2165 | /** |
| 2166 | * Milliseconds that the delete log will be kept. After this time, delete records may be |
| 2167 | * deleted. |
| 2168 | */ |
| 2169 | public static final long DAYS_KEPT_MILLISECONDS = 1000L * 60L * 60L * 24L * (long)DAYS_KEPT; |
| 2170 | } |
| 2171 | |
| 2172 | |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 2173 | protected interface RawContactsColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2174 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2175 | * A reference to the {@link ContactsContract.Contacts#_ID} that this |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2176 | * data belongs to. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2177 | * <P>Type: INTEGER</P> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2178 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2179 | public static final String CONTACT_ID = "contact_id"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2180 | |
| 2181 | /** |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2182 | * The data set within the account that this row belongs to. This allows |
| 2183 | * multiple sync adapters for the same account type to distinguish between |
| 2184 | * each others' data. |
| 2185 | * |
| 2186 | * This is empty by default, and is completely optional. It only needs to |
| 2187 | * be populated if multiple sync adapters are entering distinct data for |
| 2188 | * the same account type and account name. |
| 2189 | * <P>Type: TEXT</P> |
| 2190 | */ |
| 2191 | public static final String DATA_SET = "data_set"; |
| 2192 | |
| 2193 | /** |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 2194 | * A concatenation of the account type and data set (delimited by a forward |
| 2195 | * slash) - if the data set is empty, this will be the same as the account |
| 2196 | * type. For applications that need to be aware of the data set, this can |
| 2197 | * be used instead of account type to distinguish sets of data. This is |
| 2198 | * never intended to be used for specifying accounts. |
| 2199 | * @hide |
| 2200 | */ |
| 2201 | public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; |
| 2202 | |
| 2203 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2204 | * The aggregation mode for this contact. |
| 2205 | * <P>Type: INTEGER</P> |
| 2206 | */ |
| 2207 | public static final String AGGREGATION_MODE = "aggregation_mode"; |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 2208 | |
| 2209 | /** |
| 2210 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 2211 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 2212 | * 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] | 2213 | * 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] | 2214 | * then calls ContactResolver.delete once more, this time passing the |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 2215 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 2216 | * the data removal. |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 2217 | * <P>Type: INTEGER</P> |
| 2218 | */ |
| 2219 | public static final String DELETED = "deleted"; |
Dmitri Plotnikov | 918007b | 2010-01-20 12:12:11 -0800 | [diff] [blame] | 2220 | |
| 2221 | /** |
| 2222 | * The "name_verified" flag: "1" means that the name fields on this raw |
| 2223 | * contact can be trusted and therefore should be used for the entire |
| 2224 | * aggregated contact. |
| 2225 | * <p> |
| 2226 | * If an aggregated contact contains more than one raw contact with a |
| 2227 | * verified name, one of those verified names is chosen at random. |
| 2228 | * If an aggregated contact contains no verified names, the |
| 2229 | * name is chosen randomly from the constituent raw contacts. |
| 2230 | * </p> |
| 2231 | * <p> |
| 2232 | * Updating this flag from "0" to "1" automatically resets it to "0" on |
| 2233 | * all other raw contacts in the same aggregated contact. |
| 2234 | * </p> |
| 2235 | * <p> |
| 2236 | * Sync adapters should only specify a value for this column when |
| 2237 | * inserting a raw contact and leave it out when doing an update. |
| 2238 | * </p> |
| 2239 | * <p> |
| 2240 | * The default value is "0" |
| 2241 | * </p> |
| 2242 | * <p>Type: INTEGER</p> |
| 2243 | * |
| 2244 | * @hide |
| 2245 | */ |
| 2246 | public static final String NAME_VERIFIED = "name_verified"; |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 2247 | |
| 2248 | /** |
| 2249 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 2250 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 2251 | * <P>Type: INTEGER</P> |
| 2252 | */ |
Dmitri Plotnikov | 86fe839 | 2010-07-16 11:19:46 -0700 | [diff] [blame] | 2253 | 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] | 2254 | |
| 2255 | /** |
| 2256 | * Flag that reflects whether this raw contact belongs to the user's |
| 2257 | * personal profile entry. |
| 2258 | */ |
| 2259 | 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] | 2260 | } |
| 2261 | |
| 2262 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2263 | * Constants for the raw contacts table, which contains one row of contact |
| 2264 | * information for each person in each synced account. Sync adapters and |
| 2265 | * contact management apps |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 2266 | * are the primary consumers of this API. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2267 | * |
| 2268 | * <h3>Aggregation</h3> |
| 2269 | * <p> |
| 2270 | * As soon as a raw contact is inserted or whenever its constituent data |
| 2271 | * changes, the provider will check if the raw contact matches other |
| 2272 | * existing raw contacts and if so will aggregate it with those. The |
| 2273 | * aggregation is reflected in the {@link RawContacts} table by the change of the |
| 2274 | * {@link #CONTACT_ID} field, which is the reference to the aggregate contact. |
| 2275 | * </p> |
| 2276 | * <p> |
| 2277 | * Changes to the structured name, organization, phone number, email address, |
| 2278 | * or nickname trigger a re-aggregation. |
| 2279 | * </p> |
| 2280 | * <p> |
| 2281 | * See also {@link AggregationExceptions} for a mechanism to control |
| 2282 | * aggregation programmatically. |
| 2283 | * </p> |
| 2284 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2285 | * <h3>Operations</h3> |
| 2286 | * <dl> |
| 2287 | * <dt><b>Insert</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2288 | * <dd> |
| 2289 | * <p> |
| 2290 | * Raw contacts can be inserted incrementally or in a batch. |
| 2291 | * The incremental method is more traditional but less efficient. |
| 2292 | * It should be used |
| 2293 | * 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] | 2294 | * <pre> |
| 2295 | * ContentValues values = new ContentValues(); |
| 2296 | * values.put(RawContacts.ACCOUNT_TYPE, accountType); |
| 2297 | * values.put(RawContacts.ACCOUNT_NAME, accountName); |
| 2298 | * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values); |
| 2299 | * long rawContactId = ContentUris.parseId(rawContactUri); |
| 2300 | * </pre> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2301 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2302 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2303 | * Once {@link Data} values become available, insert those. |
| 2304 | * For example, here's how you would insert a name: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2305 | * |
| 2306 | * <pre> |
| 2307 | * values.clear(); |
| 2308 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 2309 | * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); |
| 2310 | * values.put(StructuredName.DISPLAY_NAME, "Mike Sullivan"); |
| 2311 | * getContentResolver().insert(Data.CONTENT_URI, values); |
| 2312 | * </pre> |
| 2313 | * </p> |
| 2314 | * <p> |
| 2315 | * The batch method is by far preferred. It inserts the raw contact and its |
| 2316 | * constituent data rows in a single database transaction |
| 2317 | * and causes at most one aggregation pass. |
| 2318 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 2319 | * ArrayList<ContentProviderOperation> ops = |
| 2320 | * new ArrayList<ContentProviderOperation>(); |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2321 | * ... |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2322 | * int rawContactInsertIndex = ops.size(); |
| 2323 | * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) |
| 2324 | * .withValue(RawContacts.ACCOUNT_TYPE, accountType) |
| 2325 | * .withValue(RawContacts.ACCOUNT_NAME, accountName) |
| 2326 | * .build()); |
| 2327 | * |
| 2328 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 2329 | * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex) |
| 2330 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 2331 | * .withValue(StructuredName.DISPLAY_NAME, "Mike Sullivan") |
| 2332 | * .build()); |
| 2333 | * |
| 2334 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 2335 | * </pre> |
| 2336 | * </p> |
| 2337 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2338 | * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)} |
| 2339 | * to refer to the as-yet-unknown index value of the raw contact inserted in the |
| 2340 | * first operation. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2341 | * </p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2342 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2343 | * <dt><b>Update</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2344 | * <dd><p> |
| 2345 | * Raw contacts can be updated incrementally or in a batch. |
| 2346 | * Batch mode should be used whenever possible. |
| 2347 | * The procedures and considerations are analogous to those documented above for inserts. |
| 2348 | * </p></dd> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2349 | * <dt><b>Delete</b></dt> |
| 2350 | * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates, |
| 2351 | * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2352 | * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row |
| 2353 | * itself is also deleted automatically. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2354 | * </p> |
| 2355 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2356 | * The invocation of {@code resolver.delete(...)}, does not immediately delete |
| 2357 | * a raw contacts row. |
| 2358 | * Instead, it sets the {@link #DELETED} flag on the raw contact and |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2359 | * removes the raw contact from its aggregate contact. |
| 2360 | * The sync adapter then deletes the raw contact from the server and |
| 2361 | * finalizes phone-side deletion by calling {@code resolver.delete(...)} |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2362 | * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2363 | * <p>Some sync adapters are read-only, meaning that they only sync server-side |
| 2364 | * changes to the phone, but not the reverse. If one of those raw contacts |
| 2365 | * is marked for deletion, it will remain on the phone. However it will be |
| 2366 | * effectively invisible, because it will not be part of any aggregate contact. |
| 2367 | * </dd> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2368 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2369 | * <dt><b>Query</b></dt> |
| 2370 | * <dd> |
| 2371 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2372 | * It is easy to find all raw contacts in a Contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2373 | * <pre> |
| 2374 | * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI, |
| 2375 | * new String[]{RawContacts._ID}, |
| 2376 | * RawContacts.CONTACT_ID + "=?", |
| 2377 | * new String[]{String.valueOf(contactId)}, null); |
| 2378 | * </pre> |
| 2379 | * </p> |
| 2380 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2381 | * To find raw contacts within a specific account, |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2382 | * you can either put the account name and type in the selection or pass them as query |
| 2383 | * parameters. The latter approach is preferable, especially when you can reuse the |
| 2384 | * URI: |
| 2385 | * <pre> |
Adam Koch | 95e5a07 | 2013-05-21 09:47:55 -0400 | [diff] [blame] | 2386 | * Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon() |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2387 | * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName) |
| 2388 | * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType) |
| 2389 | * .build(); |
| 2390 | * Cursor c1 = getContentResolver().query(rawContactUri, |
| 2391 | * RawContacts.STARRED + "<>0", null, null, null); |
| 2392 | * ... |
| 2393 | * Cursor c2 = getContentResolver().query(rawContactUri, |
| 2394 | * RawContacts.DELETED + "<>0", null, null, null); |
| 2395 | * </pre> |
| 2396 | * </p> |
| 2397 | * <p>The best way to read a raw contact along with all the data associated with it is |
| 2398 | * by using the {@link Entity} directory. If the raw contact has data rows, |
| 2399 | * the Entity cursor will contain a row for each data row. If the raw contact has no |
| 2400 | * data rows, the cursor will still contain one row with the raw contact-level information. |
| 2401 | * <pre> |
| 2402 | * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); |
| 2403 | * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY); |
| 2404 | * Cursor c = getContentResolver().query(entityUri, |
| 2405 | * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1}, |
| 2406 | * null, null, null); |
| 2407 | * try { |
| 2408 | * while (c.moveToNext()) { |
| 2409 | * String sourceId = c.getString(0); |
| 2410 | * if (!c.isNull(1)) { |
| 2411 | * String mimeType = c.getString(2); |
| 2412 | * String data = c.getString(3); |
| 2413 | * ... |
| 2414 | * } |
| 2415 | * } |
| 2416 | * } finally { |
| 2417 | * c.close(); |
| 2418 | * } |
| 2419 | * </pre> |
| 2420 | * </p> |
| 2421 | * </dd> |
| 2422 | * </dl> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2423 | * <h2>Columns</h2> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2424 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2425 | * <table class="jd-sumtable"> |
| 2426 | * <tr> |
| 2427 | * <th colspan='4'>RawContacts</th> |
| 2428 | * </tr> |
| 2429 | * <tr> |
| 2430 | * <td>long</td> |
| 2431 | * <td>{@link #_ID}</td> |
| 2432 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2433 | * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words, |
| 2434 | * it is much better for a sync adapter to update a raw contact rather than to delete and |
| 2435 | * re-insert it.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2436 | * </tr> |
| 2437 | * <tr> |
| 2438 | * <td>long</td> |
| 2439 | * <td>{@link #CONTACT_ID}</td> |
| 2440 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2441 | * <td>The ID of the row in the {@link ContactsContract.Contacts} table |
| 2442 | * that this raw contact belongs |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2443 | * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled |
| 2444 | * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td> |
| 2445 | * </tr> |
| 2446 | * <tr> |
| 2447 | * <td>int</td> |
| 2448 | * <td>{@link #AGGREGATION_MODE}</td> |
| 2449 | * <td>read/write</td> |
| 2450 | * <td>A mechanism that allows programmatic control of the aggregation process. The allowed |
| 2451 | * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED} |
| 2452 | * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td> |
| 2453 | * </tr> |
| 2454 | * <tr> |
| 2455 | * <td>int</td> |
| 2456 | * <td>{@link #DELETED}</td> |
| 2457 | * <td>read/write</td> |
| 2458 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 2459 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 2460 | * called on a raw contact, it is marked for deletion and removed from its |
| 2461 | * aggregate contact. The sync adaptor deletes the raw contact on the server and |
| 2462 | * then calls ContactResolver.delete once more, this time passing the |
| 2463 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 2464 | * the data removal.</td> |
| 2465 | * </tr> |
| 2466 | * <tr> |
| 2467 | * <td>int</td> |
| 2468 | * <td>{@link #TIMES_CONTACTED}</td> |
| 2469 | * <td>read/write</td> |
| 2470 | * <td>The number of times the contact has been contacted. To have an effect |
| 2471 | * on the corresponding value of the aggregate contact, this field |
| 2472 | * should be set at the time the raw contact is inserted. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2473 | * After that, this value is typically updated via |
| 2474 | * {@link ContactsContract.Contacts#markAsContacted}.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2475 | * </tr> |
| 2476 | * <tr> |
| 2477 | * <td>long</td> |
| 2478 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 2479 | * <td>read/write</td> |
| 2480 | * <td>The timestamp of the last time the contact was contacted. To have an effect |
| 2481 | * on the corresponding value of the aggregate contact, this field |
| 2482 | * should be set at the time the raw contact is inserted. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2483 | * After that, this value is typically updated via |
| 2484 | * {@link ContactsContract.Contacts#markAsContacted}. |
| 2485 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2486 | * </tr> |
| 2487 | * <tr> |
| 2488 | * <td>int</td> |
| 2489 | * <td>{@link #STARRED}</td> |
| 2490 | * <td>read/write</td> |
| 2491 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2492 | * Changing this field immediately affects the corresponding aggregate contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2493 | * if any raw contacts in that aggregate contact are starred, then the contact |
| 2494 | * itself is marked as starred.</td> |
| 2495 | * </tr> |
| 2496 | * <tr> |
| 2497 | * <td>String</td> |
| 2498 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 2499 | * <td>read/write</td> |
| 2500 | * <td>A custom ringtone associated with a raw contact. Typically this is the |
| 2501 | * URI returned by an activity launched with the |
| 2502 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent. |
| 2503 | * To have an effect on the corresponding value of the aggregate contact, this field |
| 2504 | * 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] | 2505 | * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE |
| 2506 | * Contacts.CUSTOM_RINGTONE} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2507 | * instead.</td> |
| 2508 | * </tr> |
| 2509 | * <tr> |
| 2510 | * <td>int</td> |
| 2511 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 2512 | * <td>read/write</td> |
| 2513 | * <td>An indicator of whether calls from this raw contact should be forwarded |
| 2514 | * directly to voice mail ('1') or not ('0'). To have an effect |
| 2515 | * on the corresponding value of the aggregate contact, this field |
| 2516 | * should be set at the time the raw contact is inserted.</td> |
| 2517 | * </tr> |
| 2518 | * <tr> |
| 2519 | * <td>String</td> |
| 2520 | * <td>{@link #ACCOUNT_NAME}</td> |
| 2521 | * <td>read/write-once</td> |
| 2522 | * <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] | 2523 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
| 2524 | * 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] | 2525 | * It should be set at the time the raw contact is inserted and never |
| 2526 | * changed afterwards.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2527 | * </tr> |
| 2528 | * <tr> |
| 2529 | * <td>String</td> |
| 2530 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 2531 | * <td>read/write-once</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2532 | * <td> |
| 2533 | * <p> |
| 2534 | * The type of account to which this row belongs, which when paired with |
| 2535 | * {@link #ACCOUNT_NAME} identifies a specific account. |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2536 | * It should be set at the time the raw contact is inserted and never |
| 2537 | * changed afterwards. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2538 | * </p> |
| 2539 | * <p> |
| 2540 | * To ensure uniqueness, new account types should be chosen according to the |
| 2541 | * Java package naming convention. Thus a Google account is of type "com.google". |
| 2542 | * </p> |
| 2543 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2544 | * </tr> |
| 2545 | * <tr> |
| 2546 | * <td>String</td> |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2547 | * <td>{@link #DATA_SET}</td> |
| 2548 | * <td>read/write-once</td> |
| 2549 | * <td> |
| 2550 | * <p> |
| 2551 | * The data set within the account that this row belongs to. This allows |
| 2552 | * multiple sync adapters for the same account type to distinguish between |
| 2553 | * each others' data. The combination of {@link #ACCOUNT_TYPE}, |
| 2554 | * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data |
| 2555 | * that is associated with a single sync adapter. |
| 2556 | * </p> |
| 2557 | * <p> |
| 2558 | * This is empty by default, and is completely optional. It only needs to |
| 2559 | * be populated if multiple sync adapters are entering distinct data for |
| 2560 | * the same account type and account name. |
| 2561 | * </p> |
| 2562 | * <p> |
| 2563 | * It should be set at the time the raw contact is inserted and never |
| 2564 | * changed afterwards. |
| 2565 | * </p> |
| 2566 | * </td> |
| 2567 | * </tr> |
| 2568 | * <tr> |
| 2569 | * <td>String</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2570 | * <td>{@link #SOURCE_ID}</td> |
| 2571 | * <td>read/write</td> |
| 2572 | * <td>String that uniquely identifies this row to its source account. |
| 2573 | * Typically it is set at the time the raw contact is inserted and never |
| 2574 | * changed afterwards. The one notable exception is a new raw contact: it |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2575 | * will have an account name and type (and possibly a data set), but no |
| 2576 | * source id. This indicates to the sync adapter that a new contact needs |
| 2577 | * to be created server-side and its ID stored in the corresponding |
| 2578 | * SOURCE_ID field on the phone. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2579 | * </td> |
| 2580 | * </tr> |
| 2581 | * <tr> |
| 2582 | * <td>int</td> |
| 2583 | * <td>{@link #VERSION}</td> |
| 2584 | * <td>read-only</td> |
| 2585 | * <td>Version number that is updated whenever this row or its related data |
| 2586 | * changes. This field can be used for optimistic locking of a raw contact. |
| 2587 | * </td> |
| 2588 | * </tr> |
| 2589 | * <tr> |
| 2590 | * <td>int</td> |
| 2591 | * <td>{@link #DIRTY}</td> |
| 2592 | * <td>read/write</td> |
| 2593 | * <td>Flag indicating that {@link #VERSION} has changed, and this row needs |
| 2594 | * to be synchronized by its owning account. The value is set to "1" automatically |
| 2595 | * whenever the raw contact changes, unless the URI has the |
| 2596 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified. |
| 2597 | * The sync adapter should always supply this query parameter to prevent |
| 2598 | * unnecessary synchronization: user changes some data on the server, |
| 2599 | * the sync adapter updates the contact on the phone (without the |
| 2600 | * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag, |
| 2601 | * which triggers a sync to bring the changes to the server. |
| 2602 | * </td> |
| 2603 | * </tr> |
| 2604 | * <tr> |
| 2605 | * <td>String</td> |
| 2606 | * <td>{@link #SYNC1}</td> |
| 2607 | * <td>read/write</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2608 | * <td>Generic column provided for arbitrary use by sync adapters. |
| 2609 | * The content provider |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2610 | * stores this information on behalf of the sync adapter but does not |
| 2611 | * interpret it in any way. |
| 2612 | * </td> |
| 2613 | * </tr> |
| 2614 | * <tr> |
| 2615 | * <td>String</td> |
| 2616 | * <td>{@link #SYNC2}</td> |
| 2617 | * <td>read/write</td> |
| 2618 | * <td>Generic column for use by sync adapters. |
| 2619 | * </td> |
| 2620 | * </tr> |
| 2621 | * <tr> |
| 2622 | * <td>String</td> |
| 2623 | * <td>{@link #SYNC3}</td> |
| 2624 | * <td>read/write</td> |
| 2625 | * <td>Generic column for use by sync adapters. |
| 2626 | * </td> |
| 2627 | * </tr> |
| 2628 | * <tr> |
| 2629 | * <td>String</td> |
| 2630 | * <td>{@link #SYNC4}</td> |
| 2631 | * <td>read/write</td> |
| 2632 | * <td>Generic column for use by sync adapters. |
| 2633 | * </td> |
| 2634 | * </tr> |
| 2635 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2636 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2637 | public static final class RawContacts implements BaseColumns, RawContactsColumns, |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 2638 | ContactOptionsColumns, ContactNameColumns, SyncColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2639 | /** |
| 2640 | * This utility class cannot be instantiated |
| 2641 | */ |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 2642 | private RawContacts() { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2643 | } |
| 2644 | |
| 2645 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2646 | * The content:// style URI for this table, which requests a directory of |
| 2647 | * raw contact rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2648 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 2649 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2650 | |
| 2651 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2652 | * The MIME type of the results from {@link #CONTENT_URI} when a specific |
| 2653 | * ID value is not provided, and multiple raw contacts may be returned. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2654 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2655 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2656 | |
| 2657 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2658 | * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI}, |
| 2659 | * yielding a subdirectory of a single person. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2660 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2661 | 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] | 2662 | |
| 2663 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2664 | * Aggregation mode: aggregate immediately after insert or update operation(s) are complete. |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2665 | */ |
| 2666 | public static final int AGGREGATION_MODE_DEFAULT = 0; |
| 2667 | |
| 2668 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2669 | * Aggregation mode: aggregate at the time the raw contact is inserted/updated. |
| 2670 | * @deprecated Aggregation is synchronous, this historic value is a no-op |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2671 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2672 | @Deprecated |
Omari Stephens | bc9aa77 | 2009-09-08 19:10:53 -0700 | [diff] [blame] | 2673 | public static final int AGGREGATION_MODE_IMMEDIATE = 1; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2674 | |
| 2675 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2676 | * <p> |
| 2677 | * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later. |
| 2678 | * Changes to the raw contact will update the associated aggregate contact but will not |
| 2679 | * result in any change in how the contact is aggregated. Similar to |
| 2680 | * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding |
| 2681 | * {@link Contacts} aggregate. |
| 2682 | * </p> |
| 2683 | * <p> |
| 2684 | * This can be used to postpone aggregation until after a series of updates, for better |
| 2685 | * performance and/or user experience. |
| 2686 | * </p> |
| 2687 | * <p> |
| 2688 | * Note that changing |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2689 | * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2690 | * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any |
| 2691 | * subsequent |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2692 | * change to the raw contact's data will. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2693 | * </p> |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2694 | */ |
| 2695 | public static final int AGGREGATION_MODE_SUSPENDED = 2; |
| 2696 | |
| 2697 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2698 | * <p> |
| 2699 | * Aggregation mode: never aggregate this raw contact. The raw contact will not |
| 2700 | * have a corresponding {@link Contacts} aggregate and therefore will not be included in |
| 2701 | * {@link Contacts} query results. |
| 2702 | * </p> |
| 2703 | * <p> |
| 2704 | * For example, this mode can be used for a raw contact that is marked for deletion while |
| 2705 | * waiting for the deletion to occur on the server side. |
| 2706 | * </p> |
| 2707 | * |
| 2708 | * @see #AGGREGATION_MODE_SUSPENDED |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2709 | */ |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2710 | public static final int AGGREGATION_MODE_DISABLED = 3; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2711 | |
| 2712 | /** |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 2713 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 2714 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
| 2715 | * entry of the given {@link RawContacts} entry. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2716 | */ |
| 2717 | public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) { |
| 2718 | // TODO: use a lighter query by joining rawcontacts with contacts in provider |
| 2719 | final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY); |
| 2720 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 2721 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 2722 | }, null, null, null); |
| 2723 | |
| 2724 | Uri lookupUri = null; |
| 2725 | try { |
| 2726 | if (cursor != null && cursor.moveToFirst()) { |
| 2727 | final long contactId = cursor.getLong(0); |
| 2728 | final String lookupKey = cursor.getString(1); |
| 2729 | return Contacts.getLookupUri(contactId, lookupKey); |
| 2730 | } |
| 2731 | } finally { |
| 2732 | if (cursor != null) cursor.close(); |
| 2733 | } |
| 2734 | return lookupUri; |
| 2735 | } |
| 2736 | |
| 2737 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2738 | * 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] | 2739 | * {@link ContactsContract.Data} rows. To access this directory |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2740 | * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2741 | */ |
| 2742 | public static final class Data implements BaseColumns, DataColumns { |
| 2743 | /** |
| 2744 | * no public constructor since this is a utility class |
| 2745 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2746 | private Data() { |
| 2747 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2748 | |
| 2749 | /** |
| 2750 | * The directory twig for this sub-table |
| 2751 | */ |
| 2752 | public static final String CONTENT_DIRECTORY = "data"; |
| 2753 | } |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2754 | |
| 2755 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2756 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2757 | * 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] | 2758 | * {@link ContactsContract.Data} rows. To access this directory append |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2759 | * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2760 | * {@link RawContactsEntity} for a stand-alone table containing the same |
| 2761 | * data. |
| 2762 | * </p> |
| 2763 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2764 | * Entity has two ID fields: {@link #_ID} for the raw contact |
| 2765 | * and {@link #DATA_ID} for the data rows. |
| 2766 | * Entity always contains at least one row, even if there are no |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2767 | * 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] | 2768 | * null. |
| 2769 | * </p> |
| 2770 | * <p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2771 | * Using Entity should be preferred to using two separate queries: |
| 2772 | * RawContacts followed by Data. The reason is that Entity reads all |
| 2773 | * data for a raw contact in one transaction, so there is no possibility |
| 2774 | * of the data changing between the two queries. |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2775 | */ |
| 2776 | public static final class Entity implements BaseColumns, DataColumns { |
| 2777 | /** |
| 2778 | * no public constructor since this is a utility class |
| 2779 | */ |
| 2780 | private Entity() { |
| 2781 | } |
| 2782 | |
| 2783 | /** |
| 2784 | * The directory twig for this sub-table |
| 2785 | */ |
| 2786 | public static final String CONTENT_DIRECTORY = "entity"; |
| 2787 | |
| 2788 | /** |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 2789 | * 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] | 2790 | * data rows. |
| 2791 | * <P>Type: INTEGER</P> |
| 2792 | */ |
| 2793 | public static final String DATA_ID = "data_id"; |
| 2794 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2795 | |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2796 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2797 | * <p> |
| 2798 | * A sub-directory of a single raw contact that contains all of its |
| 2799 | * {@link ContactsContract.StreamItems} rows. To access this directory append |
| 2800 | * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See |
| 2801 | * {@link ContactsContract.StreamItems} for a stand-alone table containing the |
| 2802 | * same data. |
| 2803 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 2804 | * <p> |
| 2805 | * Access to the social stream through this sub-directory requires additional permissions |
| 2806 | * beyond the read/write contact permissions required by the provider. Querying for |
| 2807 | * social stream data requires android.permission.READ_SOCIAL_STREAM permission, and |
| 2808 | * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM |
| 2809 | * permission. |
| 2810 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2811 | */ |
| 2812 | public static final class StreamItems implements BaseColumns, StreamItemsColumns { |
| 2813 | /** |
| 2814 | * No public constructor since this is a utility class |
| 2815 | */ |
| 2816 | private StreamItems() { |
| 2817 | } |
| 2818 | |
| 2819 | /** |
| 2820 | * The directory twig for this sub-table |
| 2821 | */ |
| 2822 | public static final String CONTENT_DIRECTORY = "stream_items"; |
| 2823 | } |
| 2824 | |
| 2825 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2826 | * <p> |
| 2827 | * A sub-directory of a single raw contact that represents its primary |
| 2828 | * display photo. To access this directory append |
| 2829 | * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI. |
| 2830 | * The resulting URI represents an image file, and should be interacted with |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 2831 | * using ContentResolver.openAssetFileDescriptor. |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2832 | * <p> |
| 2833 | * <p> |
| 2834 | * Note that this sub-directory also supports opening the photo as an asset file |
| 2835 | * in write mode. Callers can create or replace the primary photo associated |
| 2836 | * with this raw contact by opening the asset file and writing the full-size |
| 2837 | * photo contents into it. When the file is closed, the image will be parsed, |
| 2838 | * sized down if necessary for the full-size display photo and thumbnail |
| 2839 | * dimensions, and stored. |
| 2840 | * </p> |
| 2841 | * <p> |
| 2842 | * Usage example: |
| 2843 | * <pre> |
| 2844 | * public void writeDisplayPhoto(long rawContactId, byte[] photo) { |
| 2845 | * Uri rawContactPhotoUri = Uri.withAppendedPath( |
| 2846 | * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), |
| 2847 | * RawContacts.DisplayPhoto.CONTENT_DIRECTORY); |
| 2848 | * try { |
| 2849 | * AssetFileDescriptor fd = |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 2850 | * getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2851 | * OutputStream os = fd.createOutputStream(); |
| 2852 | * os.write(photo); |
| 2853 | * os.close(); |
| 2854 | * fd.close(); |
| 2855 | * } catch (IOException e) { |
| 2856 | * // Handle error cases. |
| 2857 | * } |
| 2858 | * } |
| 2859 | * </pre> |
| 2860 | * </p> |
| 2861 | */ |
| 2862 | public static final class DisplayPhoto { |
| 2863 | /** |
| 2864 | * No public constructor since this is a utility class |
| 2865 | */ |
| 2866 | private DisplayPhoto() { |
| 2867 | } |
| 2868 | |
| 2869 | /** |
| 2870 | * The directory twig for this sub-table |
| 2871 | */ |
| 2872 | public static final String CONTENT_DIRECTORY = "display_photo"; |
| 2873 | } |
| 2874 | |
| 2875 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2876 | * TODO: javadoc |
| 2877 | * @param cursor |
| 2878 | * @return |
| 2879 | */ |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2880 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 2881 | return new EntityIteratorImpl(cursor); |
| 2882 | } |
| 2883 | |
| 2884 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 2885 | private static final String[] DATA_KEYS = new String[]{ |
| 2886 | Data.DATA1, |
| 2887 | Data.DATA2, |
| 2888 | Data.DATA3, |
| 2889 | Data.DATA4, |
| 2890 | Data.DATA5, |
| 2891 | Data.DATA6, |
| 2892 | Data.DATA7, |
| 2893 | Data.DATA8, |
| 2894 | Data.DATA9, |
| 2895 | Data.DATA10, |
| 2896 | Data.DATA11, |
| 2897 | Data.DATA12, |
| 2898 | Data.DATA13, |
| 2899 | Data.DATA14, |
| 2900 | Data.DATA15, |
| 2901 | Data.SYNC1, |
| 2902 | Data.SYNC2, |
| 2903 | Data.SYNC3, |
| 2904 | Data.SYNC4}; |
| 2905 | |
| 2906 | public EntityIteratorImpl(Cursor cursor) { |
| 2907 | super(cursor); |
| 2908 | } |
| 2909 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 2910 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2911 | public android.content.Entity getEntityAndIncrementCursor(Cursor cursor) |
| 2912 | throws RemoteException { |
| 2913 | final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID); |
| 2914 | final long rawContactId = cursor.getLong(columnRawContactId); |
| 2915 | |
| 2916 | // we expect the cursor is already at the row we need to read from |
| 2917 | ContentValues cv = new ContentValues(); |
| 2918 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME); |
| 2919 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE); |
Katherine Kuan | 1d83723 | 2011-08-24 16:06:06 -0700 | [diff] [blame] | 2920 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DATA_SET); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2921 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID); |
| 2922 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY); |
| 2923 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION); |
| 2924 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID); |
| 2925 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1); |
| 2926 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2); |
| 2927 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3); |
| 2928 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4); |
| 2929 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED); |
| 2930 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID); |
| 2931 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED); |
Dmitri Plotnikov | 918007b | 2010-01-20 12:12:11 -0800 | [diff] [blame] | 2932 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, NAME_VERIFIED); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2933 | android.content.Entity contact = new android.content.Entity(cv); |
| 2934 | |
| 2935 | // read data rows until the contact id changes |
| 2936 | do { |
| 2937 | if (rawContactId != cursor.getLong(columnRawContactId)) { |
| 2938 | break; |
| 2939 | } |
| 2940 | // add the data to to the contact |
| 2941 | cv = new ContentValues(); |
| 2942 | cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID))); |
| 2943 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 2944 | Data.RES_PACKAGE); |
| 2945 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE); |
| 2946 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY); |
| 2947 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, |
| 2948 | Data.IS_SUPER_PRIMARY); |
| 2949 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION); |
| 2950 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 2951 | CommonDataKinds.GroupMembership.GROUP_SOURCE_ID); |
| 2952 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 2953 | Data.DATA_VERSION); |
| 2954 | for (String key : DATA_KEYS) { |
| 2955 | final int columnIndex = cursor.getColumnIndexOrThrow(key); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 2956 | switch (cursor.getType(columnIndex)) { |
| 2957 | case Cursor.FIELD_TYPE_NULL: |
| 2958 | // don't put anything |
| 2959 | break; |
| 2960 | case Cursor.FIELD_TYPE_INTEGER: |
| 2961 | case Cursor.FIELD_TYPE_FLOAT: |
| 2962 | case Cursor.FIELD_TYPE_STRING: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 2963 | cv.put(key, cursor.getString(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 2964 | break; |
| 2965 | case Cursor.FIELD_TYPE_BLOB: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 2966 | cv.put(key, cursor.getBlob(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 2967 | break; |
| 2968 | default: |
| 2969 | throw new IllegalStateException("Invalid or unhandled data type"); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2970 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2971 | } |
| 2972 | contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv); |
| 2973 | } while (cursor.moveToNext()); |
| 2974 | |
| 2975 | return contact; |
| 2976 | } |
| 2977 | |
| 2978 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2979 | } |
| 2980 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2981 | /** |
| 2982 | * Social status update columns. |
| 2983 | * |
| 2984 | * @see StatusUpdates |
| 2985 | * @see ContactsContract.Data |
| 2986 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 2987 | protected interface StatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 2988 | /** |
Dmitri Plotnikov | a60479d | 2009-09-27 20:16:31 -0700 | [diff] [blame] | 2989 | * Contact's latest presence level. |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 2990 | * <P>Type: INTEGER (one of the values below)</P> |
| 2991 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 2992 | public static final String PRESENCE = "mode"; |
| 2993 | |
| 2994 | /** |
| 2995 | * @deprecated use {@link #PRESENCE} |
| 2996 | */ |
| 2997 | @Deprecated |
| 2998 | public static final String PRESENCE_STATUS = PRESENCE; |
| 2999 | |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3000 | /** |
| 3001 | * An allowed value of {@link #PRESENCE}. |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3002 | */ |
| 3003 | int OFFLINE = 0; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3004 | |
| 3005 | /** |
| 3006 | * An allowed value of {@link #PRESENCE}. |
| 3007 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3008 | int INVISIBLE = 1; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3009 | |
| 3010 | /** |
| 3011 | * An allowed value of {@link #PRESENCE}. |
| 3012 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3013 | int AWAY = 2; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3014 | |
| 3015 | /** |
| 3016 | * An allowed value of {@link #PRESENCE}. |
| 3017 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3018 | int IDLE = 3; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3019 | |
| 3020 | /** |
| 3021 | * An allowed value of {@link #PRESENCE}. |
| 3022 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3023 | int DO_NOT_DISTURB = 4; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3024 | |
| 3025 | /** |
| 3026 | * An allowed value of {@link #PRESENCE}. |
| 3027 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3028 | int AVAILABLE = 5; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3029 | |
| 3030 | /** |
| 3031 | * Contact latest status update. |
| 3032 | * <p>Type: TEXT</p> |
| 3033 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3034 | public static final String STATUS = "status"; |
| 3035 | |
| 3036 | /** |
| 3037 | * @deprecated use {@link #STATUS} |
| 3038 | */ |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3039 | @Deprecated |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3040 | public static final String PRESENCE_CUSTOM_STATUS = STATUS; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3041 | |
| 3042 | /** |
| 3043 | * The absolute time in milliseconds when the latest status was inserted/updated. |
| 3044 | * <p>Type: NUMBER</p> |
| 3045 | */ |
| 3046 | public static final String STATUS_TIMESTAMP = "status_ts"; |
| 3047 | |
| 3048 | /** |
| 3049 | * The package containing resources for this status: label and icon. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3050 | * <p>Type: TEXT</p> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3051 | */ |
| 3052 | public static final String STATUS_RES_PACKAGE = "status_res_package"; |
| 3053 | |
| 3054 | /** |
| 3055 | * The resource ID of the label describing the source of the status update, e.g. "Google |
| 3056 | * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 3057 | * <p>Type: NUMBER</p> |
| 3058 | */ |
| 3059 | public static final String STATUS_LABEL = "status_label"; |
| 3060 | |
| 3061 | /** |
| 3062 | * The resource ID of the icon for the source of the status update. |
| 3063 | * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 3064 | * <p>Type: NUMBER</p> |
| 3065 | */ |
| 3066 | public static final String STATUS_ICON = "status_icon"; |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3067 | |
| 3068 | /** |
| 3069 | * Contact's audio/video chat capability level. |
| 3070 | * <P>Type: INTEGER (one of the values below)</P> |
| 3071 | */ |
| 3072 | public static final String CHAT_CAPABILITY = "chat_capability"; |
| 3073 | |
| 3074 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3075 | * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone |
| 3076 | * and speaker) |
| 3077 | */ |
| 3078 | public static final int CAPABILITY_HAS_VOICE = 1; |
| 3079 | |
| 3080 | /** |
| 3081 | * 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] | 3082 | * display a video feed. |
| 3083 | */ |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3084 | public static final int CAPABILITY_HAS_VIDEO = 2; |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3085 | |
| 3086 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3087 | * 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] | 3088 | * camera that can be used for video chat (e.g. a front-facing camera on a phone). |
| 3089 | */ |
| 3090 | public static final int CAPABILITY_HAS_CAMERA = 4; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3091 | } |
| 3092 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3093 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3094 | * <p> |
| 3095 | * Constants for the stream_items table, which contains social stream updates from |
| 3096 | * the user's contact list. |
| 3097 | * </p> |
| 3098 | * <p> |
| 3099 | * Only a certain number of stream items will ever be stored under a given raw contact. |
| 3100 | * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to |
| 3101 | * determine this limit, and should restrict the number of items inserted in any given |
| 3102 | * transaction correspondingly. Insertion of more items beyond the limit will |
| 3103 | * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}. |
| 3104 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3105 | * <p> |
| 3106 | * Access to the social stream through these URIs requires additional permissions beyond the |
| 3107 | * read/write contact permissions required by the provider. Querying for social stream data |
| 3108 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social |
| 3109 | * stream items requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3110 | * </p> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3111 | * <h3>Account check</h3> |
| 3112 | * <p> |
| 3113 | * The content URIs to the insert, update and delete operations are required to have the account |
| 3114 | * information matching that of the owning raw contact as query parameters, namely |
| 3115 | * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. |
| 3116 | * {@link RawContacts#DATA_SET} isn't required. |
| 3117 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3118 | * <h3>Operations</h3> |
| 3119 | * <dl> |
| 3120 | * <dt><b>Insert</b></dt> |
| 3121 | * <dd> |
| 3122 | * <p>Social stream updates are always associated with a raw contact. There are a couple |
| 3123 | * of ways to insert these entries. |
| 3124 | * <dl> |
| 3125 | * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt> |
| 3126 | * <dd> |
| 3127 | * <pre> |
| 3128 | * ContentValues values = new ContentValues(); |
| 3129 | * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); |
| 3130 | * values.put(StreamItems.TIMESTAMP, timestamp); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3131 | * values.put(StreamItems.COMMENTS, "3 people reshared this"); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3132 | * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon(); |
| 3133 | * ContentUris.appendId(builder, rawContactId); |
| 3134 | * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY); |
| 3135 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3136 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3137 | * Uri streamItemUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3138 | * long streamItemId = ContentUris.parseId(streamItemUri); |
| 3139 | * </pre> |
| 3140 | * </dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3141 | * <dt>Via {@link StreamItems#CONTENT_URI}:</dt> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3142 | * <dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3143 | *<pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3144 | * ContentValues values = new ContentValues(); |
| 3145 | * values.put(StreamItems.RAW_CONTACT_ID, rawContactId); |
| 3146 | * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); |
| 3147 | * values.put(StreamItems.TIMESTAMP, timestamp); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3148 | * values.put(StreamItems.COMMENTS, "3 people reshared this"); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3149 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3150 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3151 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3152 | * Uri streamItemUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3153 | * long streamItemId = ContentUris.parseId(streamItemUri); |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3154 | *</pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3155 | * </dd> |
| 3156 | * </dl> |
| 3157 | * </dd> |
| 3158 | * </p> |
| 3159 | * <p> |
| 3160 | * Once a {@link StreamItems} entry has been inserted, photos associated with that |
| 3161 | * social update can be inserted. For example, after one of the insertions above, |
| 3162 | * photos could be added to the stream item in one of the following ways: |
| 3163 | * <dl> |
| 3164 | * <dt>Via a URI including the stream item ID:</dt> |
| 3165 | * <dd> |
| 3166 | * <pre> |
| 3167 | * values.clear(); |
| 3168 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3169 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3170 | * getContentResolver().insert(Uri.withAppendedPath( |
| 3171 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId), |
| 3172 | * StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values); |
| 3173 | * </pre> |
| 3174 | * </dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3175 | * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3176 | * <dd> |
| 3177 | * <pre> |
| 3178 | * values.clear(); |
| 3179 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
| 3180 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3181 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3182 | * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values); |
| 3183 | * </pre> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3184 | * <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] | 3185 | * photos in a single transaction, by using {@link ContentProviderOperation} with |
| 3186 | * back references to populate the stream item ID in the {@link ContentValues}. |
| 3187 | * </dd> |
| 3188 | * </dl> |
| 3189 | * </p> |
| 3190 | * </dd> |
| 3191 | * <dt><b>Update</b></dt> |
| 3192 | * <dd>Updates can be performed by appending the stream item ID to the |
| 3193 | * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were |
| 3194 | * created by the calling package can be updated.</dd> |
| 3195 | * <dt><b>Delete</b></dt> |
| 3196 | * <dd>Deletes can be performed by appending the stream item ID to the |
| 3197 | * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were |
| 3198 | * created by the calling package can be deleted.</dd> |
| 3199 | * <dt><b>Query</b></dt> |
| 3200 | * <dl> |
| 3201 | * <dt>Finding all social stream updates for a given contact</dt> |
| 3202 | * <dd>By Contact ID: |
| 3203 | * <pre> |
| 3204 | * Cursor c = getContentResolver().query(Uri.withAppendedPath( |
| 3205 | * ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId), |
| 3206 | * Contacts.StreamItems.CONTENT_DIRECTORY), |
| 3207 | * null, null, null, null); |
| 3208 | * </pre> |
| 3209 | * </dd> |
| 3210 | * <dd>By lookup key: |
| 3211 | * <pre> |
| 3212 | * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon() |
| 3213 | * .appendPath(lookupKey) |
| 3214 | * .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(), |
| 3215 | * null, null, null, null); |
| 3216 | * </pre> |
| 3217 | * </dd> |
| 3218 | * <dt>Finding all social stream updates for a given raw contact</dt> |
| 3219 | * <dd> |
| 3220 | * <pre> |
| 3221 | * Cursor c = getContentResolver().query(Uri.withAppendedPath( |
| 3222 | * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), |
| 3223 | * RawContacts.StreamItems.CONTENT_DIRECTORY)), |
| 3224 | * null, null, null, null); |
| 3225 | * </pre> |
| 3226 | * </dd> |
| 3227 | * <dt>Querying for a specific stream item by ID</dt> |
| 3228 | * <dd> |
| 3229 | * <pre> |
| 3230 | * Cursor c = getContentResolver().query(ContentUris.withAppendedId( |
| 3231 | * StreamItems.CONTENT_URI, streamItemId), |
| 3232 | * null, null, null, null); |
| 3233 | * </pre> |
| 3234 | * </dd> |
| 3235 | * </dl> |
| 3236 | */ |
| 3237 | public static final class StreamItems implements BaseColumns, StreamItemsColumns { |
| 3238 | /** |
| 3239 | * This utility class cannot be instantiated |
| 3240 | */ |
| 3241 | private StreamItems() { |
| 3242 | } |
| 3243 | |
| 3244 | /** |
| 3245 | * The content:// style URI for this table, which handles social network stream |
| 3246 | * updates for the user's contacts. |
| 3247 | */ |
| 3248 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items"); |
| 3249 | |
| 3250 | /** |
| 3251 | * <p> |
| 3252 | * A content:// style URI for the photos stored in a sub-table underneath |
| 3253 | * stream items. This is only used for inserts, and updates - queries and deletes |
| 3254 | * for photos should be performed by appending |
| 3255 | * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a |
| 3256 | * specific stream item. |
| 3257 | * </p> |
| 3258 | * <p> |
| 3259 | * When using this URI, the stream item ID for the photo(s) must be identified |
| 3260 | * in the {@link ContentValues} passed in. |
| 3261 | * </p> |
| 3262 | */ |
| 3263 | public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo"); |
| 3264 | |
| 3265 | /** |
| 3266 | * 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] | 3267 | * that will be stored under any single raw contact. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3268 | */ |
| 3269 | public static final Uri CONTENT_LIMIT_URI = |
| 3270 | Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit"); |
| 3271 | |
| 3272 | /** |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3273 | * The MIME type of a directory of stream items. |
| 3274 | */ |
| 3275 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item"; |
| 3276 | |
| 3277 | /** |
| 3278 | * The MIME type of a single stream item. |
| 3279 | */ |
| 3280 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/stream_item"; |
| 3281 | |
| 3282 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3283 | * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will |
| 3284 | * contain this column, with the value indicating the maximum number of |
| 3285 | * stream items that will be stored under any single raw contact. |
| 3286 | */ |
| 3287 | public static final String MAX_ITEMS = "max_items"; |
| 3288 | |
| 3289 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3290 | * <p> |
| 3291 | * A sub-directory of a single stream item entry that contains all of its |
| 3292 | * photo rows. To access this |
| 3293 | * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to |
| 3294 | * an individual stream item URI. |
| 3295 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3296 | * <p> |
| 3297 | * Access to social stream photos requires additional permissions beyond the read/write |
| 3298 | * contact permissions required by the provider. Querying for social stream photos |
| 3299 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating |
| 3300 | * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3301 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3302 | */ |
| 3303 | public static final class StreamItemPhotos |
| 3304 | implements BaseColumns, StreamItemPhotosColumns { |
| 3305 | /** |
| 3306 | * No public constructor since this is a utility class |
| 3307 | */ |
| 3308 | private StreamItemPhotos() { |
| 3309 | } |
| 3310 | |
| 3311 | /** |
| 3312 | * The directory twig for this sub-table |
| 3313 | */ |
| 3314 | public static final String CONTENT_DIRECTORY = "photo"; |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3315 | |
| 3316 | /** |
| 3317 | * The MIME type of a directory of stream item photos. |
| 3318 | */ |
| 3319 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item_photo"; |
| 3320 | |
| 3321 | /** |
| 3322 | * The MIME type of a single stream item photo. |
| 3323 | */ |
| 3324 | public static final String CONTENT_ITEM_TYPE |
| 3325 | = "vnd.android.cursor.item/stream_item_photo"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3326 | } |
| 3327 | } |
| 3328 | |
| 3329 | /** |
| 3330 | * Columns in the StreamItems table. |
| 3331 | * |
| 3332 | * @see ContactsContract.StreamItems |
| 3333 | */ |
| 3334 | protected interface StreamItemsColumns { |
| 3335 | /** |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3336 | * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} |
| 3337 | * that this stream item belongs to. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3338 | * |
| 3339 | * <p>Type: INTEGER</p> |
| 3340 | * <p>read-only</p> |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3341 | */ |
| 3342 | public static final String CONTACT_ID = "contact_id"; |
| 3343 | |
| 3344 | /** |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3345 | * A reference to the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY} |
| 3346 | * that this stream item belongs to. |
| 3347 | * |
| 3348 | * <p>Type: TEXT</p> |
| 3349 | * <p>read-only</p> |
| 3350 | */ |
| 3351 | public static final String CONTACT_LOOKUP_KEY = "contact_lookup"; |
| 3352 | |
| 3353 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3354 | * A reference to the {@link RawContacts#_ID} |
| 3355 | * that this stream item belongs to. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3356 | * <p>Type: INTEGER</p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3357 | */ |
| 3358 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 3359 | |
| 3360 | /** |
| 3361 | * The package name to use when creating {@link Resources} objects for |
| 3362 | * this stream item. This value is only designed for use when building |
| 3363 | * user interfaces, and should not be used to infer the owner. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3364 | * <P>Type: TEXT</P> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3365 | */ |
| 3366 | public static final String RES_PACKAGE = "res_package"; |
| 3367 | |
| 3368 | /** |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3369 | * The account type to which the raw_contact of this item is associated. See |
| 3370 | * {@link RawContacts#ACCOUNT_TYPE} |
| 3371 | * |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3372 | * <p>Type: TEXT</p> |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3373 | * <p>read-only</p> |
| 3374 | */ |
| 3375 | public static final String ACCOUNT_TYPE = "account_type"; |
| 3376 | |
| 3377 | /** |
| 3378 | * The account name to which the raw_contact of this item is associated. See |
| 3379 | * {@link RawContacts#ACCOUNT_NAME} |
| 3380 | * |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3381 | * <p>Type: TEXT</p> |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3382 | * <p>read-only</p> |
| 3383 | */ |
| 3384 | public static final String ACCOUNT_NAME = "account_name"; |
| 3385 | |
| 3386 | /** |
| 3387 | * The data set within the account that the raw_contact of this row belongs to. This allows |
| 3388 | * multiple sync adapters for the same account type to distinguish between |
| 3389 | * each others' data. |
| 3390 | * {@link RawContacts#DATA_SET} |
| 3391 | * |
| 3392 | * <P>Type: TEXT</P> |
| 3393 | * <p>read-only</p> |
| 3394 | */ |
| 3395 | public static final String DATA_SET = "data_set"; |
| 3396 | |
| 3397 | /** |
| 3398 | * The source_id of the raw_contact that this row belongs to. |
| 3399 | * {@link RawContacts#SOURCE_ID} |
| 3400 | * |
| 3401 | * <P>Type: TEXT</P> |
| 3402 | * <p>read-only</p> |
| 3403 | */ |
| 3404 | public static final String RAW_CONTACT_SOURCE_ID = "raw_contact_source_id"; |
| 3405 | |
| 3406 | /** |
| 3407 | * The resource name of the icon for the source of the stream item. |
| 3408 | * This resource should be scoped by the {@link #RES_PACKAGE}. As this can only reference |
| 3409 | * drawables, the "@drawable/" prefix must be omitted. |
| 3410 | * <P>Type: TEXT</P> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3411 | */ |
| 3412 | public static final String RES_ICON = "icon"; |
| 3413 | |
| 3414 | /** |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3415 | * The resource name of the label describing the source of the status update, e.g. "Google |
| 3416 | * Talk". This resource should be scoped by the {@link #RES_PACKAGE}. As this can only |
| 3417 | * reference strings, the "@string/" prefix must be omitted. |
| 3418 | * <p>Type: TEXT</p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3419 | */ |
| 3420 | public static final String RES_LABEL = "label"; |
| 3421 | |
| 3422 | /** |
| 3423 | * <P> |
| 3424 | * The main textual contents of the item. Typically this is content |
| 3425 | * that was posted by the source of this stream item, but it can also |
| 3426 | * be a textual representation of an action (e.g. ”Checked in at Joe's”). |
| 3427 | * This text is displayed to the user and allows formatting and embedded |
| 3428 | * resource images via HTML (as parseable via |
| 3429 | * {@link android.text.Html#fromHtml}). |
| 3430 | * </P> |
| 3431 | * <P> |
| 3432 | * Long content may be truncated and/or ellipsized - the exact behavior |
| 3433 | * is unspecified, but it should not break tags. |
| 3434 | * </P> |
| 3435 | * <P>Type: TEXT</P> |
| 3436 | */ |
| 3437 | public static final String TEXT = "text"; |
| 3438 | |
| 3439 | /** |
| 3440 | * The absolute time (milliseconds since epoch) when this stream item was |
| 3441 | * inserted/updated. |
| 3442 | * <P>Type: NUMBER</P> |
| 3443 | */ |
| 3444 | public static final String TIMESTAMP = "timestamp"; |
| 3445 | |
| 3446 | /** |
| 3447 | * <P> |
| 3448 | * Summary information about the stream item, for example to indicate how |
| 3449 | * many people have reshared it, how many have liked it, how many thumbs |
| 3450 | * up and/or thumbs down it has, what the original source was, etc. |
| 3451 | * </P> |
| 3452 | * <P> |
| 3453 | * This text is displayed to the user and allows simple formatting via |
| 3454 | * HTML, in the same manner as {@link #TEXT} allows. |
| 3455 | * </P> |
| 3456 | * <P> |
| 3457 | * Long content may be truncated and/or ellipsized - the exact behavior |
| 3458 | * is unspecified, but it should not break tags. |
| 3459 | * </P> |
| 3460 | * <P>Type: TEXT</P> |
| 3461 | */ |
| 3462 | public static final String COMMENTS = "comments"; |
| 3463 | |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3464 | /** Generic column for use by sync adapters. */ |
| 3465 | public static final String SYNC1 = "stream_item_sync1"; |
| 3466 | /** Generic column for use by sync adapters. */ |
| 3467 | public static final String SYNC2 = "stream_item_sync2"; |
| 3468 | /** Generic column for use by sync adapters. */ |
| 3469 | public static final String SYNC3 = "stream_item_sync3"; |
| 3470 | /** Generic column for use by sync adapters. */ |
| 3471 | public static final String SYNC4 = "stream_item_sync4"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3472 | } |
| 3473 | |
| 3474 | /** |
| 3475 | * <p> |
| 3476 | * Constants for the stream_item_photos table, which contains photos associated with |
| 3477 | * social stream updates. |
| 3478 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3479 | * <p> |
| 3480 | * Access to social stream photos requires additional permissions beyond the read/write |
| 3481 | * contact permissions required by the provider. Querying for social stream photos |
| 3482 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating |
| 3483 | * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3484 | * </p> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3485 | * <h3>Account check</h3> |
| 3486 | * <p> |
| 3487 | * The content URIs to the insert, update and delete operations are required to have the account |
| 3488 | * information matching that of the owning raw contact as query parameters, namely |
| 3489 | * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. |
| 3490 | * {@link RawContacts#DATA_SET} isn't required. |
| 3491 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3492 | * <h3>Operations</h3> |
| 3493 | * <dl> |
| 3494 | * <dt><b>Insert</b></dt> |
| 3495 | * <dd> |
| 3496 | * <p>Social stream photo entries are associated with a social stream item. Photos |
| 3497 | * can be inserted into a social stream item in a couple of ways: |
| 3498 | * <dl> |
| 3499 | * <dt> |
| 3500 | * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a |
| 3501 | * stream item: |
| 3502 | * </dt> |
| 3503 | * <dd> |
| 3504 | * <pre> |
| 3505 | * ContentValues values = new ContentValues(); |
| 3506 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3507 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3508 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3509 | * ContentUris.appendId(builder, streamItemId); |
| 3510 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3511 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3512 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3513 | * Uri photoUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3514 | * long photoId = ContentUris.parseId(photoUri); |
| 3515 | * </pre> |
| 3516 | * </dd> |
| 3517 | * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> |
| 3518 | * <dd> |
| 3519 | * <pre> |
| 3520 | * ContentValues values = new ContentValues(); |
| 3521 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
| 3522 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3523 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3524 | * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); |
| 3525 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3526 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3527 | * Uri photoUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3528 | * long photoId = ContentUris.parseId(photoUri); |
| 3529 | * </pre> |
| 3530 | * </dd> |
| 3531 | * </dl> |
| 3532 | * </p> |
| 3533 | * </dd> |
| 3534 | * <dt><b>Update</b></dt> |
| 3535 | * <dd> |
| 3536 | * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry, |
| 3537 | * identified by both the stream item ID it belongs to and the stream item photo ID. |
| 3538 | * This can be specified in two ways. |
| 3539 | * <dl> |
| 3540 | * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a |
| 3541 | * stream item: |
| 3542 | * </dt> |
| 3543 | * <dd> |
| 3544 | * <pre> |
| 3545 | * ContentValues values = new ContentValues(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3546 | * values.put(StreamItemPhotos.PHOTO, newPhotoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3547 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3548 | * ContentUris.appendId(builder, streamItemId); |
| 3549 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3550 | * ContentUris.appendId(builder, streamItemPhotoId); |
| 3551 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3552 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3553 | * getContentResolver().update(builder.build(), values, null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3554 | * </pre> |
| 3555 | * </dd> |
| 3556 | * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> |
| 3557 | * <dd> |
| 3558 | * <pre> |
| 3559 | * ContentValues values = new ContentValues(); |
| 3560 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3561 | * values.put(StreamItemPhotos.PHOTO, newPhotoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3562 | * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); |
| 3563 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3564 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3565 | * getContentResolver().update(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3566 | * </pre> |
| 3567 | * </dd> |
| 3568 | * </dl> |
| 3569 | * </p> |
| 3570 | * </dd> |
| 3571 | * <dt><b>Delete</b></dt> |
| 3572 | * <dd>Deletes can be made against either a specific photo item in a stream item, or |
| 3573 | * against all or a selected subset of photo items under a stream item. |
| 3574 | * For example: |
| 3575 | * <dl> |
| 3576 | * <dt>Deleting a single photo via the |
| 3577 | * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item: |
| 3578 | * </dt> |
| 3579 | * <dd> |
| 3580 | * <pre> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3581 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3582 | * ContentUris.appendId(builder, streamItemId); |
| 3583 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3584 | * ContentUris.appendId(builder, streamItemPhotoId); |
| 3585 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3586 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3587 | * getContentResolver().delete(builder.build(), null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3588 | * </pre> |
| 3589 | * </dd> |
| 3590 | * <dt>Deleting all photos under a stream item</dt> |
| 3591 | * <dd> |
| 3592 | * <pre> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3593 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3594 | * ContentUris.appendId(builder, streamItemId); |
| 3595 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3596 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3597 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3598 | * getContentResolver().delete(builder.build(), null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3599 | * </pre> |
| 3600 | * </dd> |
| 3601 | * </dl> |
| 3602 | * </dd> |
| 3603 | * <dt><b>Query</b></dt> |
| 3604 | * <dl> |
| 3605 | * <dt>Querying for a specific photo in a stream item</dt> |
| 3606 | * <dd> |
| 3607 | * <pre> |
| 3608 | * Cursor c = getContentResolver().query( |
| 3609 | * ContentUris.withAppendedId( |
| 3610 | * Uri.withAppendedPath( |
| 3611 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) |
| 3612 | * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), |
| 3613 | * streamItemPhotoId), null, null, null, null); |
| 3614 | * </pre> |
| 3615 | * </dd> |
| 3616 | * <dt>Querying for all photos in a stream item</dt> |
| 3617 | * <dd> |
| 3618 | * <pre> |
| 3619 | * Cursor c = getContentResolver().query( |
| 3620 | * Uri.withAppendedPath( |
| 3621 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) |
| 3622 | * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), |
| 3623 | * null, null, null, StreamItemPhotos.SORT_INDEX); |
| 3624 | * </pre> |
| 3625 | * </dl> |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3626 | * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a |
| 3627 | * {@link StreamItemPhotos#PHOTO_URI}. The {@link StreamItemPhotos#PHOTO_FILE_ID} |
| 3628 | * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to |
| 3629 | * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as |
| 3630 | * an asset file, as follows: |
| 3631 | * <pre> |
| 3632 | * public InputStream openDisplayPhoto(String photoUri) { |
| 3633 | * try { |
| 3634 | * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r"); |
| 3635 | * return fd.createInputStream(); |
| 3636 | * } catch (IOException e) { |
| 3637 | * return null; |
| 3638 | * } |
| 3639 | * } |
| 3640 | * <pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3641 | * </dd> |
| 3642 | * </dl> |
| 3643 | */ |
| 3644 | public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns { |
| 3645 | /** |
| 3646 | * No public constructor since this is a utility class |
| 3647 | */ |
| 3648 | private StreamItemPhotos() { |
| 3649 | } |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3650 | |
| 3651 | /** |
| 3652 | * <p> |
| 3653 | * The binary representation of the photo. Any size photo can be inserted; |
| 3654 | * the provider will resize it appropriately for storage and display. |
| 3655 | * </p> |
| 3656 | * <p> |
| 3657 | * This is only intended for use when inserting or updating a stream item photo. |
| 3658 | * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI} |
| 3659 | * as an asset file. |
| 3660 | * </p> |
| 3661 | * <P>Type: BLOB</P> |
| 3662 | */ |
| 3663 | public static final String PHOTO = "photo"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3664 | } |
| 3665 | |
| 3666 | /** |
| 3667 | * Columns in the StreamItemPhotos table. |
| 3668 | * |
| 3669 | * @see ContactsContract.StreamItemPhotos |
| 3670 | */ |
| 3671 | protected interface StreamItemPhotosColumns { |
| 3672 | /** |
| 3673 | * A reference to the {@link StreamItems#_ID} this photo is associated with. |
| 3674 | * <P>Type: NUMBER</P> |
| 3675 | */ |
| 3676 | public static final String STREAM_ITEM_ID = "stream_item_id"; |
| 3677 | |
| 3678 | /** |
| 3679 | * An integer to use for sort order for photos in the stream item. If not |
| 3680 | * specified, the {@link StreamItemPhotos#_ID} will be used for sorting. |
| 3681 | * <P>Type: NUMBER</P> |
| 3682 | */ |
| 3683 | public static final String SORT_INDEX = "sort_index"; |
| 3684 | |
| 3685 | /** |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3686 | * Photo file ID for the photo. |
| 3687 | * See {@link ContactsContract.DisplayPhoto}. |
| 3688 | * <P>Type: NUMBER</P> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3689 | */ |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3690 | public static final String PHOTO_FILE_ID = "photo_file_id"; |
| 3691 | |
| 3692 | /** |
| 3693 | * URI for retrieving the photo content, automatically populated. Callers |
| 3694 | * may retrieve the photo content by opening this URI as an asset file. |
| 3695 | * <P>Type: TEXT</P> |
| 3696 | */ |
| 3697 | public static final String PHOTO_URI = "photo_uri"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3698 | |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3699 | /** Generic column for use by sync adapters. */ |
| 3700 | public static final String SYNC1 = "stream_item_photo_sync1"; |
| 3701 | /** Generic column for use by sync adapters. */ |
| 3702 | public static final String SYNC2 = "stream_item_photo_sync2"; |
| 3703 | /** Generic column for use by sync adapters. */ |
| 3704 | public static final String SYNC3 = "stream_item_photo_sync3"; |
| 3705 | /** Generic column for use by sync adapters. */ |
| 3706 | public static final String SYNC4 = "stream_item_photo_sync4"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3707 | } |
| 3708 | |
| 3709 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 3710 | * <p> |
| 3711 | * Constants for the photo files table, which tracks metadata for hi-res photos |
| 3712 | * stored in the file system. |
| 3713 | * </p> |
| 3714 | * |
| 3715 | * @hide |
| 3716 | */ |
| 3717 | public static final class PhotoFiles implements BaseColumns, PhotoFilesColumns { |
| 3718 | /** |
| 3719 | * No public constructor since this is a utility class |
| 3720 | */ |
| 3721 | private PhotoFiles() { |
| 3722 | } |
| 3723 | } |
| 3724 | |
| 3725 | /** |
| 3726 | * Columns in the PhotoFiles table. |
| 3727 | * |
| 3728 | * @see ContactsContract.PhotoFiles |
| 3729 | * |
| 3730 | * @hide |
| 3731 | */ |
| 3732 | protected interface PhotoFilesColumns { |
| 3733 | |
| 3734 | /** |
| 3735 | * The height, in pixels, of the photo this entry is associated with. |
| 3736 | * <P>Type: NUMBER</P> |
| 3737 | */ |
| 3738 | public static final String HEIGHT = "height"; |
| 3739 | |
| 3740 | /** |
| 3741 | * The width, in pixels, of the photo this entry is associated with. |
| 3742 | * <P>Type: NUMBER</P> |
| 3743 | */ |
| 3744 | public static final String WIDTH = "width"; |
| 3745 | |
| 3746 | /** |
| 3747 | * The size, in bytes, of the photo stored on disk. |
| 3748 | * <P>Type: NUMBER</P> |
| 3749 | */ |
| 3750 | public static final String FILESIZE = "filesize"; |
| 3751 | } |
| 3752 | |
| 3753 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3754 | * Columns in the Data table. |
| 3755 | * |
| 3756 | * @see ContactsContract.Data |
| 3757 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 3758 | protected interface DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3759 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 3760 | * The package name to use when creating {@link Resources} objects for |
| 3761 | * this data row. This value is only designed for use when building user |
| 3762 | * interfaces, and should not be used to infer the owner. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 3763 | * |
| 3764 | * @hide |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 3765 | */ |
| 3766 | public static final String RES_PACKAGE = "res_package"; |
| 3767 | |
| 3768 | /** |
| 3769 | * The MIME type of the item represented by this row. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3770 | */ |
| 3771 | public static final String MIMETYPE = "mimetype"; |
| 3772 | |
| 3773 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 3774 | * A reference to the {@link RawContacts#_ID} |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 3775 | * that this data belongs to. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3776 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 3777 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 3778 | |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 3779 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3780 | * 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] | 3781 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 3782 | */ |
| 3783 | public static final String IS_PRIMARY = "is_primary"; |
| 3784 | |
| 3785 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 3786 | * Whether this is the primary entry of its kind for the aggregate |
| 3787 | * contact it belongs to. Any data record that is "super primary" must |
| 3788 | * also be "primary". |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 3789 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 3790 | */ |
| 3791 | public static final String IS_SUPER_PRIMARY = "is_super_primary"; |
| 3792 | |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 3793 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 3794 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 3795 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 3796 | * <P>Type: INTEGER</P> |
| 3797 | */ |
| 3798 | public static final String IS_READ_ONLY = "is_read_only"; |
| 3799 | |
| 3800 | /** |
Fred Quintana | c933fb6 | 2009-06-11 12:14:40 -0700 | [diff] [blame] | 3801 | * The version of this data record. This is a read-only value. The data column is |
| 3802 | * guaranteed to not change without the version going up. This value is monotonically |
| 3803 | * increasing. |
| 3804 | * <P>Type: INTEGER</P> |
| 3805 | */ |
| 3806 | public static final String DATA_VERSION = "data_version"; |
| 3807 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3808 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3809 | public static final String DATA1 = "data1"; |
| 3810 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3811 | public static final String DATA2 = "data2"; |
| 3812 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3813 | public static final String DATA3 = "data3"; |
| 3814 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3815 | public static final String DATA4 = "data4"; |
| 3816 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3817 | public static final String DATA5 = "data5"; |
| 3818 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3819 | public static final String DATA6 = "data6"; |
| 3820 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3821 | public static final String DATA7 = "data7"; |
| 3822 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3823 | public static final String DATA8 = "data8"; |
| 3824 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3825 | public static final String DATA9 = "data9"; |
| 3826 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3827 | public static final String DATA10 = "data10"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 3828 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3829 | public static final String DATA11 = "data11"; |
| 3830 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3831 | public static final String DATA12 = "data12"; |
| 3832 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3833 | public static final String DATA13 = "data13"; |
| 3834 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3835 | public static final String DATA14 = "data14"; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3836 | /** |
| 3837 | * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention, |
| 3838 | * this field is used to store BLOBs (binary data). |
| 3839 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 3840 | public static final String DATA15 = "data15"; |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 3841 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 3842 | /** Generic column for use by sync adapters. */ |
| 3843 | public static final String SYNC1 = "data_sync1"; |
| 3844 | /** Generic column for use by sync adapters. */ |
| 3845 | public static final String SYNC2 = "data_sync2"; |
| 3846 | /** Generic column for use by sync adapters. */ |
| 3847 | public static final String SYNC3 = "data_sync3"; |
| 3848 | /** Generic column for use by sync adapters. */ |
| 3849 | public static final String SYNC4 = "data_sync4"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3850 | } |
| 3851 | |
| 3852 | /** |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 3853 | * Columns in the Data_Usage_Stat table |
| 3854 | */ |
| 3855 | protected interface DataUsageStatColumns { |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 3856 | /** The last time (in milliseconds) this {@link Data} was used. */ |
| 3857 | public static final String LAST_TIME_USED = "last_time_used"; |
| 3858 | |
Yorke Lee | 5a53d70 | 2013-03-29 18:08:47 -0700 | [diff] [blame] | 3859 | /** The number of times the referenced {@link Data} has been used. */ |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 3860 | public static final String TIMES_USED = "times_used"; |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 3861 | } |
| 3862 | |
| 3863 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3864 | * Combines all columns returned by {@link ContactsContract.Data} table queries. |
| 3865 | * |
| 3866 | * @see ContactsContract.Data |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 3867 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 3868 | protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns, |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 3869 | RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns, |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 3870 | ContactStatusColumns, DataUsageStatColumns { |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 3871 | } |
| 3872 | |
| 3873 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3874 | * <p> |
| 3875 | * 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] | 3876 | * contact. Each row of the data table is typically used to store a single |
| 3877 | * piece of contact |
| 3878 | * information (such as a phone number) and its |
| 3879 | * associated metadata (such as whether it is a work or home number). |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3880 | * </p> |
| 3881 | * <h3>Data kinds</h3> |
| 3882 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3883 | * Data is a generic table that can hold any kind of contact data. |
| 3884 | * The kind of data stored in a given row is specified by the row's |
| 3885 | * {@link #MIMETYPE} value, which determines the meaning of the |
| 3886 | * generic columns {@link #DATA1} through |
| 3887 | * {@link #DATA15}. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3888 | * For example, if the data kind is |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3889 | * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column |
| 3890 | * {@link #DATA1} stores the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3891 | * phone number, but if the data kind is |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3892 | * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1} |
| 3893 | * stores the email address. |
| 3894 | * Sync adapters and applications can introduce their own data kinds. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3895 | * </p> |
| 3896 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3897 | * ContactsContract defines a small number of pre-defined data kinds, e.g. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3898 | * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a |
| 3899 | * convenience, these classes define data kind specific aliases for DATA1 etc. |
| 3900 | * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as |
| 3901 | * {@link ContactsContract.Data Data.DATA1}. |
| 3902 | * </p> |
| 3903 | * <p> |
| 3904 | * {@link #DATA1} is an indexed column and should be used for the data element that is |
| 3905 | * expected to be most frequently used in query selections. For example, in the |
| 3906 | * case of a row representing email addresses {@link #DATA1} should probably |
| 3907 | * be used for the email address itself, while {@link #DATA2} etc can be |
| 3908 | * used for auxiliary information like type of email address. |
| 3909 | * <p> |
| 3910 | * <p> |
| 3911 | * By convention, {@link #DATA15} is used for storing BLOBs (binary data). |
| 3912 | * </p> |
| 3913 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 3914 | * The sync adapter for a given account type must correctly handle every data type |
| 3915 | * used in the corresponding raw contacts. Otherwise it could result in lost or |
| 3916 | * corrupted data. |
| 3917 | * </p> |
| 3918 | * <p> |
| 3919 | * 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] | 3920 | * 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] | 3921 | * "favorite song" to a raw contact owned by a Google account, it will not |
| 3922 | * get synced to the server, because the Google sync adapter does not know |
| 3923 | * how to handle this data kind. Thus new data kinds are typically |
| 3924 | * introduced along with new account types, i.e. new sync adapters. |
| 3925 | * </p> |
| 3926 | * <h3>Batch operations</h3> |
| 3927 | * <p> |
| 3928 | * Data rows can be inserted/updated/deleted using the traditional |
| 3929 | * {@link ContentResolver#insert}, {@link ContentResolver#update} and |
| 3930 | * {@link ContentResolver#delete} methods, however the newer mechanism based |
| 3931 | * on a batch of {@link ContentProviderOperation} will prove to be a better |
| 3932 | * choice in almost all cases. All operations in a batch are executed in a |
| 3933 | * single transaction, which ensures that the phone-side and server-side |
| 3934 | * state of a raw contact are always consistent. Also, the batch-based |
| 3935 | * approach is far more efficient: not only are the database operations |
| 3936 | * faster when executed in a single transaction, but also sending a batch of |
| 3937 | * commands to the content provider saves a lot of time on context switching |
| 3938 | * between your process and the process in which the content provider runs. |
| 3939 | * </p> |
| 3940 | * <p> |
| 3941 | * The flip side of using batched operations is that a large batch may lock |
| 3942 | * up the database for a long time preventing other applications from |
| 3943 | * accessing data and potentially causing ANRs ("Application Not Responding" |
| 3944 | * dialogs.) |
| 3945 | * </p> |
| 3946 | * <p> |
| 3947 | * To avoid such lockups of the database, make sure to insert "yield points" |
| 3948 | * in the batch. A yield point indicates to the content provider that before |
| 3949 | * executing the next operation it can commit the changes that have already |
| 3950 | * been made, yield to other requests, open another transaction and continue |
| 3951 | * processing operations. A yield point will not automatically commit the |
| 3952 | * transaction, but only if there is another request waiting on the |
| 3953 | * database. Normally a sync adapter should insert a yield point at the |
| 3954 | * beginning of each raw contact operation sequence in the batch. See |
| 3955 | * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}. |
| 3956 | * </p> |
| 3957 | * <h3>Operations</h3> |
| 3958 | * <dl> |
| 3959 | * <dt><b>Insert</b></dt> |
| 3960 | * <dd> |
| 3961 | * <p> |
| 3962 | * An individual data row can be inserted using the traditional |
| 3963 | * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows |
| 3964 | * should always be inserted as a batch. |
| 3965 | * </p> |
| 3966 | * <p> |
| 3967 | * An example of a traditional insert: |
| 3968 | * <pre> |
| 3969 | * ContentValues values = new ContentValues(); |
| 3970 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 3971 | * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); |
| 3972 | * values.put(Phone.NUMBER, "1-800-GOOG-411"); |
| 3973 | * values.put(Phone.TYPE, Phone.TYPE_CUSTOM); |
| 3974 | * values.put(Phone.LABEL, "free directory assistance"); |
| 3975 | * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values); |
| 3976 | * </pre> |
| 3977 | * <p> |
| 3978 | * The same done using ContentProviderOperations: |
| 3979 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 3980 | * ArrayList<ContentProviderOperation> ops = |
| 3981 | * new ArrayList<ContentProviderOperation>(); |
| 3982 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3983 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 3984 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 3985 | * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE) |
| 3986 | * .withValue(Phone.NUMBER, "1-800-GOOG-411") |
| 3987 | * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM) |
| 3988 | * .withValue(Phone.LABEL, "free directory assistance") |
| 3989 | * .build()); |
| 3990 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 3991 | * </pre> |
| 3992 | * </p> |
| 3993 | * <dt><b>Update</b></dt> |
| 3994 | * <dd> |
| 3995 | * <p> |
| 3996 | * Just as with insert, update can be done incrementally or as a batch, |
| 3997 | * the batch mode being the preferred method: |
| 3998 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 3999 | * ArrayList<ContentProviderOperation> ops = |
| 4000 | * new ArrayList<ContentProviderOperation>(); |
| 4001 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4002 | * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI) |
| 4003 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 4004 | * .withValue(Email.DATA, "somebody@android.com") |
| 4005 | * .build()); |
| 4006 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4007 | * </pre> |
| 4008 | * </p> |
| 4009 | * </dd> |
| 4010 | * <dt><b>Delete</b></dt> |
| 4011 | * <dd> |
| 4012 | * <p> |
| 4013 | * Just as with insert and update, deletion can be done either using the |
| 4014 | * {@link ContentResolver#delete} method or using a ContentProviderOperation: |
| 4015 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4016 | * ArrayList<ContentProviderOperation> ops = |
| 4017 | * new ArrayList<ContentProviderOperation>(); |
| 4018 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4019 | * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI) |
| 4020 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 4021 | * .build()); |
| 4022 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4023 | * </pre> |
| 4024 | * </p> |
| 4025 | * </dd> |
| 4026 | * <dt><b>Query</b></dt> |
| 4027 | * <dd> |
| 4028 | * <p> |
| 4029 | * <dl> |
| 4030 | * <dt>Finding all Data of a given type for a given contact</dt> |
| 4031 | * <dd> |
| 4032 | * <pre> |
| 4033 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 4034 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 4035 | * Data.CONTACT_ID + "=?" + " AND " |
| 4036 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 4037 | * new String[] {String.valueOf(contactId)}, null); |
| 4038 | * </pre> |
| 4039 | * </p> |
| 4040 | * <p> |
| 4041 | * </dd> |
| 4042 | * <dt>Finding all Data of a given type for a given raw contact</dt> |
| 4043 | * <dd> |
| 4044 | * <pre> |
| 4045 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 4046 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 4047 | * Data.RAW_CONTACT_ID + "=?" + " AND " |
| 4048 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 4049 | * new String[] {String.valueOf(rawContactId)}, null); |
| 4050 | * </pre> |
| 4051 | * </dd> |
| 4052 | * <dt>Finding all Data for a given raw contact</dt> |
| 4053 | * <dd> |
| 4054 | * Most sync adapters will want to read all data rows for a raw contact |
| 4055 | * along with the raw contact itself. For that you should use the |
| 4056 | * {@link RawContactsEntity}. See also {@link RawContacts}. |
| 4057 | * </dd> |
| 4058 | * </dl> |
| 4059 | * </p> |
| 4060 | * </dd> |
| 4061 | * </dl> |
| 4062 | * <h2>Columns</h2> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4063 | * <p> |
| 4064 | * Many columns are available via a {@link Data#CONTENT_URI} query. For best performance you |
| 4065 | * should explicitly specify a projection to only those columns that you need. |
| 4066 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4067 | * <table class="jd-sumtable"> |
| 4068 | * <tr> |
| 4069 | * <th colspan='4'>Data</th> |
| 4070 | * </tr> |
| 4071 | * <tr> |
| 4072 | * <td style="width: 7em;">long</td> |
| 4073 | * <td style="width: 20em;">{@link #_ID}</td> |
| 4074 | * <td style="width: 5em;">read-only</td> |
| 4075 | * <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] | 4076 | * 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] | 4077 | * always do an update instead.</td> |
| 4078 | * </tr> |
| 4079 | * <tr> |
| 4080 | * <td>String</td> |
| 4081 | * <td>{@link #MIMETYPE}</td> |
| 4082 | * <td>read/write-once</td> |
| 4083 | * <td> |
| 4084 | * <p>The MIME type of the item represented by this row. Examples of common |
| 4085 | * MIME types are: |
| 4086 | * <ul> |
| 4087 | * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li> |
| 4088 | * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li> |
| 4089 | * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li> |
| 4090 | * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li> |
| 4091 | * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li> |
| 4092 | * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li> |
| 4093 | * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li> |
| 4094 | * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li> |
| 4095 | * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li> |
| 4096 | * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li> |
| 4097 | * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li> |
| 4098 | * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li> |
| 4099 | * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 4100 | * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4101 | * </ul> |
| 4102 | * </p> |
| 4103 | * </td> |
| 4104 | * </tr> |
| 4105 | * <tr> |
| 4106 | * <td>long</td> |
| 4107 | * <td>{@link #RAW_CONTACT_ID}</td> |
| 4108 | * <td>read/write-once</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4109 | * <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] | 4110 | * </tr> |
| 4111 | * <tr> |
| 4112 | * <td>int</td> |
| 4113 | * <td>{@link #IS_PRIMARY}</td> |
| 4114 | * <td>read/write</td> |
| 4115 | * <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] | 4116 | * "1" if true, "0" if false. |
| 4117 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4118 | * </tr> |
| 4119 | * <tr> |
| 4120 | * <td>int</td> |
| 4121 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 4122 | * <td>read/write</td> |
| 4123 | * <td>Whether this is the primary entry of its kind for the aggregate |
| 4124 | * 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] | 4125 | * also be "primary". For example, the super-primary entry may be |
| 4126 | * interpreted as the default contact value of its kind (for example, |
| 4127 | * the default phone number to use for the contact).</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4128 | * </tr> |
| 4129 | * <tr> |
| 4130 | * <td>int</td> |
| 4131 | * <td>{@link #DATA_VERSION}</td> |
| 4132 | * <td>read-only</td> |
| 4133 | * <td>The version of this data record. Whenever the data row changes |
| 4134 | * the version goes up. This value is monotonically increasing.</td> |
| 4135 | * </tr> |
| 4136 | * <tr> |
| 4137 | * <td>Any type</td> |
| 4138 | * <td> |
| 4139 | * {@link #DATA1}<br> |
| 4140 | * {@link #DATA2}<br> |
| 4141 | * {@link #DATA3}<br> |
| 4142 | * {@link #DATA4}<br> |
| 4143 | * {@link #DATA5}<br> |
| 4144 | * {@link #DATA6}<br> |
| 4145 | * {@link #DATA7}<br> |
| 4146 | * {@link #DATA8}<br> |
| 4147 | * {@link #DATA9}<br> |
| 4148 | * {@link #DATA10}<br> |
| 4149 | * {@link #DATA11}<br> |
| 4150 | * {@link #DATA12}<br> |
| 4151 | * {@link #DATA13}<br> |
| 4152 | * {@link #DATA14}<br> |
| 4153 | * {@link #DATA15} |
| 4154 | * </td> |
| 4155 | * <td>read/write</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4156 | * <td> |
| 4157 | * <p> |
| 4158 | * Generic data columns. The meaning of each column is determined by the |
| 4159 | * {@link #MIMETYPE}. By convention, {@link #DATA15} is used for storing |
| 4160 | * BLOBs (binary data). |
| 4161 | * </p> |
| 4162 | * <p> |
| 4163 | * Data columns whose meaning is not explicitly defined for a given MIMETYPE |
| 4164 | * should not be used. There is no guarantee that any sync adapter will |
| 4165 | * preserve them. Sync adapters themselves should not use such columns either, |
| 4166 | * but should instead use {@link #SYNC1}-{@link #SYNC4}. |
| 4167 | * </p> |
| 4168 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4169 | * </tr> |
| 4170 | * <tr> |
| 4171 | * <td>Any type</td> |
| 4172 | * <td> |
| 4173 | * {@link #SYNC1}<br> |
| 4174 | * {@link #SYNC2}<br> |
| 4175 | * {@link #SYNC3}<br> |
| 4176 | * {@link #SYNC4} |
| 4177 | * </td> |
| 4178 | * <td>read/write</td> |
| 4179 | * <td>Generic columns for use by sync adapters. For example, a Photo row |
| 4180 | * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error) |
| 4181 | * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td> |
| 4182 | * </tr> |
| 4183 | * </table> |
| 4184 | * |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4185 | * <p> |
| 4186 | * Some columns from the most recent associated status update are also available |
| 4187 | * through an implicit join. |
| 4188 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4189 | * <table class="jd-sumtable"> |
| 4190 | * <tr> |
| 4191 | * <th colspan='4'>Join with {@link StatusUpdates}</th> |
| 4192 | * </tr> |
| 4193 | * <tr> |
| 4194 | * <td style="width: 7em;">int</td> |
| 4195 | * <td style="width: 20em;">{@link #PRESENCE}</td> |
| 4196 | * <td style="width: 5em;">read-only</td> |
| 4197 | * <td>IM presence status linked to this data row. Compare with |
| 4198 | * {@link #CONTACT_PRESENCE}, which contains the contact's presence across |
| 4199 | * all IM rows. See {@link StatusUpdates} for individual status definitions. |
| 4200 | * The provider may choose not to store this value |
| 4201 | * in persistent storage. The expectation is that presence status will be |
kmccormick | 50e27c8 | 2013-03-28 16:33:11 -0700 | [diff] [blame] | 4202 | * updated on a regular basis. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4203 | * </td> |
| 4204 | * </tr> |
| 4205 | * <tr> |
| 4206 | * <td>String</td> |
| 4207 | * <td>{@link #STATUS}</td> |
| 4208 | * <td>read-only</td> |
| 4209 | * <td>Latest status update linked with this data row.</td> |
| 4210 | * </tr> |
| 4211 | * <tr> |
| 4212 | * <td>long</td> |
| 4213 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 4214 | * <td>read-only</td> |
| 4215 | * <td>The absolute time in milliseconds when the latest status was |
| 4216 | * inserted/updated for this data row.</td> |
| 4217 | * </tr> |
| 4218 | * <tr> |
| 4219 | * <td>String</td> |
| 4220 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 4221 | * <td>read-only</td> |
| 4222 | * <td>The package containing resources for this status: label and icon.</td> |
| 4223 | * </tr> |
| 4224 | * <tr> |
| 4225 | * <td>long</td> |
| 4226 | * <td>{@link #STATUS_LABEL}</td> |
| 4227 | * <td>read-only</td> |
| 4228 | * <td>The resource ID of the label describing the source of status update linked |
| 4229 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4230 | * </tr> |
| 4231 | * <tr> |
| 4232 | * <td>long</td> |
| 4233 | * <td>{@link #STATUS_ICON}</td> |
| 4234 | * <td>read-only</td> |
| 4235 | * <td>The resource ID of the icon for the source of the status update linked |
| 4236 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4237 | * </tr> |
| 4238 | * </table> |
| 4239 | * |
| 4240 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4241 | * Some columns from the associated raw contact are also available through an |
| 4242 | * implicit join. The other columns are excluded as uninteresting in this |
| 4243 | * context. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4244 | * </p> |
| 4245 | * |
| 4246 | * <table class="jd-sumtable"> |
| 4247 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4248 | * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4249 | * </tr> |
| 4250 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4251 | * <td style="width: 7em;">long</td> |
| 4252 | * <td style="width: 20em;">{@link #CONTACT_ID}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4253 | * <td style="width: 5em;">read-only</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4254 | * <td>The id of the row in the {@link Contacts} table that this data belongs |
| 4255 | * to.</td> |
| 4256 | * </tr> |
| 4257 | * <tr> |
| 4258 | * <td>int</td> |
| 4259 | * <td>{@link #AGGREGATION_MODE}</td> |
| 4260 | * <td>read-only</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4261 | * <td>See {@link RawContacts}.</td> |
| 4262 | * </tr> |
| 4263 | * <tr> |
| 4264 | * <td>int</td> |
| 4265 | * <td>{@link #DELETED}</td> |
| 4266 | * <td>read-only</td> |
| 4267 | * <td>See {@link RawContacts}.</td> |
| 4268 | * </tr> |
| 4269 | * </table> |
| 4270 | * |
| 4271 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4272 | * The ID column for the associated aggregated contact table |
| 4273 | * {@link ContactsContract.Contacts} is available |
| 4274 | * via the implicit join to the {@link RawContacts} table, see above. |
| 4275 | * The remaining columns from this table are also |
| 4276 | * available, through an implicit join. This |
| 4277 | * facilitates lookup by |
| 4278 | * the value of a single data element, such as the email address. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4279 | * </p> |
| 4280 | * |
| 4281 | * <table class="jd-sumtable"> |
| 4282 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4283 | * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4284 | * </tr> |
| 4285 | * <tr> |
| 4286 | * <td style="width: 7em;">String</td> |
| 4287 | * <td style="width: 20em;">{@link #LOOKUP_KEY}</td> |
| 4288 | * <td style="width: 5em;">read-only</td> |
| 4289 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4290 | * </tr> |
| 4291 | * <tr> |
| 4292 | * <td>String</td> |
| 4293 | * <td>{@link #DISPLAY_NAME}</td> |
| 4294 | * <td>read-only</td> |
| 4295 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4296 | * </tr> |
| 4297 | * <tr> |
| 4298 | * <td>long</td> |
| 4299 | * <td>{@link #PHOTO_ID}</td> |
| 4300 | * <td>read-only</td> |
| 4301 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4302 | * </tr> |
| 4303 | * <tr> |
| 4304 | * <td>int</td> |
| 4305 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 4306 | * <td>read-only</td> |
| 4307 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4308 | * </tr> |
| 4309 | * <tr> |
| 4310 | * <td>int</td> |
| 4311 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 4312 | * <td>read-only</td> |
| 4313 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4314 | * </tr> |
| 4315 | * <tr> |
| 4316 | * <td>int</td> |
| 4317 | * <td>{@link #TIMES_CONTACTED}</td> |
| 4318 | * <td>read-only</td> |
| 4319 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4320 | * </tr> |
| 4321 | * <tr> |
| 4322 | * <td>long</td> |
| 4323 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 4324 | * <td>read-only</td> |
| 4325 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4326 | * </tr> |
| 4327 | * <tr> |
| 4328 | * <td>int</td> |
| 4329 | * <td>{@link #STARRED}</td> |
| 4330 | * <td>read-only</td> |
| 4331 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4332 | * </tr> |
| 4333 | * <tr> |
| 4334 | * <td>String</td> |
| 4335 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 4336 | * <td>read-only</td> |
| 4337 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4338 | * </tr> |
| 4339 | * <tr> |
| 4340 | * <td>int</td> |
| 4341 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 4342 | * <td>read-only</td> |
| 4343 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4344 | * </tr> |
| 4345 | * <tr> |
| 4346 | * <td>int</td> |
| 4347 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 4348 | * <td>read-only</td> |
| 4349 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4350 | * </tr> |
| 4351 | * <tr> |
| 4352 | * <td>String</td> |
| 4353 | * <td>{@link #CONTACT_STATUS}</td> |
| 4354 | * <td>read-only</td> |
| 4355 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4356 | * </tr> |
| 4357 | * <tr> |
| 4358 | * <td>long</td> |
| 4359 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 4360 | * <td>read-only</td> |
| 4361 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4362 | * </tr> |
| 4363 | * <tr> |
| 4364 | * <td>String</td> |
| 4365 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 4366 | * <td>read-only</td> |
| 4367 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4368 | * </tr> |
| 4369 | * <tr> |
| 4370 | * <td>long</td> |
| 4371 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 4372 | * <td>read-only</td> |
| 4373 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4374 | * </tr> |
| 4375 | * <tr> |
| 4376 | * <td>long</td> |
| 4377 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 4378 | * <td>read-only</td> |
| 4379 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4380 | * </tr> |
| 4381 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4382 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4383 | public final static class Data implements DataColumnsWithJoins { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4384 | /** |
| 4385 | * This utility class cannot be instantiated |
| 4386 | */ |
| 4387 | private Data() {} |
| 4388 | |
| 4389 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4390 | * The content:// style URI for this table, which requests a directory |
| 4391 | * of data rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4392 | */ |
| 4393 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); |
| 4394 | |
| 4395 | /** |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 4396 | * A boolean parameter for {@link Data#CONTENT_URI}. |
| 4397 | * This specifies whether or not the returned data items should be filtered to show |
| 4398 | * data items belonging to visible contacts only. |
| 4399 | */ |
| 4400 | public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; |
| 4401 | |
| 4402 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4403 | * The MIME type of the results from {@link #CONTENT_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4404 | */ |
| 4405 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 4406 | |
| 4407 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4408 | * <p> |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4409 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 4410 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4411 | * entry of the given {@link ContactsContract.Data} entry. |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4412 | * </p> |
| 4413 | * <p> |
| 4414 | * Returns the Uri for the contact in the first entry returned by |
| 4415 | * {@link ContentResolver#query(Uri, String[], String, String[], String)} |
| 4416 | * for the provided {@code dataUri}. If the query returns null or empty |
| 4417 | * results, silently returns null. |
| 4418 | * </p> |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 4419 | */ |
| 4420 | public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) { |
| 4421 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 4422 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 4423 | }, null, null, null); |
| 4424 | |
| 4425 | Uri lookupUri = null; |
| 4426 | try { |
| 4427 | if (cursor != null && cursor.moveToFirst()) { |
| 4428 | final long contactId = cursor.getLong(0); |
| 4429 | final String lookupKey = cursor.getString(1); |
| 4430 | return Contacts.getLookupUri(contactId, lookupKey); |
| 4431 | } |
| 4432 | } finally { |
| 4433 | if (cursor != null) cursor.close(); |
| 4434 | } |
| 4435 | return lookupUri; |
| 4436 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4437 | } |
| 4438 | |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 4439 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4440 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4441 | * 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] | 4442 | * an outer join of the raw_contacts table with the data table. It is a strictly |
| 4443 | * read-only table. |
| 4444 | * </p> |
| 4445 | * <p> |
| 4446 | * If a raw contact has data rows, the RawContactsEntity cursor will contain |
| 4447 | * a one row for each data row. If the raw contact has no data rows, the |
| 4448 | * cursor will still contain one row with the raw contact-level information |
| 4449 | * and nulls for data columns. |
| 4450 | * |
| 4451 | * <pre> |
| 4452 | * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId); |
| 4453 | * Cursor c = getContentResolver().query(entityUri, |
| 4454 | * new String[]{ |
| 4455 | * RawContactsEntity.SOURCE_ID, |
| 4456 | * RawContactsEntity.DATA_ID, |
| 4457 | * RawContactsEntity.MIMETYPE, |
| 4458 | * RawContactsEntity.DATA1 |
| 4459 | * }, null, null, null); |
| 4460 | * try { |
| 4461 | * while (c.moveToNext()) { |
| 4462 | * String sourceId = c.getString(0); |
| 4463 | * if (!c.isNull(1)) { |
| 4464 | * String mimeType = c.getString(2); |
| 4465 | * String data = c.getString(3); |
| 4466 | * ... |
| 4467 | * } |
| 4468 | * } |
| 4469 | * } finally { |
| 4470 | * c.close(); |
| 4471 | * } |
| 4472 | * </pre> |
| 4473 | * |
| 4474 | * <h3>Columns</h3> |
| 4475 | * RawContactsEntity has a combination of RawContact and Data columns. |
| 4476 | * |
| 4477 | * <table class="jd-sumtable"> |
| 4478 | * <tr> |
| 4479 | * <th colspan='4'>RawContacts</th> |
| 4480 | * </tr> |
| 4481 | * <tr> |
| 4482 | * <td style="width: 7em;">long</td> |
| 4483 | * <td style="width: 20em;">{@link #_ID}</td> |
| 4484 | * <td style="width: 5em;">read-only</td> |
| 4485 | * <td>Raw contact row ID. See {@link RawContacts}.</td> |
| 4486 | * </tr> |
| 4487 | * <tr> |
| 4488 | * <td>long</td> |
| 4489 | * <td>{@link #CONTACT_ID}</td> |
| 4490 | * <td>read-only</td> |
| 4491 | * <td>See {@link RawContacts}.</td> |
| 4492 | * </tr> |
| 4493 | * <tr> |
| 4494 | * <td>int</td> |
| 4495 | * <td>{@link #AGGREGATION_MODE}</td> |
| 4496 | * <td>read-only</td> |
| 4497 | * <td>See {@link RawContacts}.</td> |
| 4498 | * </tr> |
| 4499 | * <tr> |
| 4500 | * <td>int</td> |
| 4501 | * <td>{@link #DELETED}</td> |
| 4502 | * <td>read-only</td> |
| 4503 | * <td>See {@link RawContacts}.</td> |
| 4504 | * </tr> |
| 4505 | * </table> |
| 4506 | * |
| 4507 | * <table class="jd-sumtable"> |
| 4508 | * <tr> |
| 4509 | * <th colspan='4'>Data</th> |
| 4510 | * </tr> |
| 4511 | * <tr> |
| 4512 | * <td style="width: 7em;">long</td> |
| 4513 | * <td style="width: 20em;">{@link #DATA_ID}</td> |
| 4514 | * <td style="width: 5em;">read-only</td> |
| 4515 | * <td>Data row ID. It will be null if the raw contact has no data rows.</td> |
| 4516 | * </tr> |
| 4517 | * <tr> |
| 4518 | * <td>String</td> |
| 4519 | * <td>{@link #MIMETYPE}</td> |
| 4520 | * <td>read-only</td> |
| 4521 | * <td>See {@link ContactsContract.Data}.</td> |
| 4522 | * </tr> |
| 4523 | * <tr> |
| 4524 | * <td>int</td> |
| 4525 | * <td>{@link #IS_PRIMARY}</td> |
| 4526 | * <td>read-only</td> |
| 4527 | * <td>See {@link ContactsContract.Data}.</td> |
| 4528 | * </tr> |
| 4529 | * <tr> |
| 4530 | * <td>int</td> |
| 4531 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 4532 | * <td>read-only</td> |
| 4533 | * <td>See {@link ContactsContract.Data}.</td> |
| 4534 | * </tr> |
| 4535 | * <tr> |
| 4536 | * <td>int</td> |
| 4537 | * <td>{@link #DATA_VERSION}</td> |
| 4538 | * <td>read-only</td> |
| 4539 | * <td>See {@link ContactsContract.Data}.</td> |
| 4540 | * </tr> |
| 4541 | * <tr> |
| 4542 | * <td>Any type</td> |
| 4543 | * <td> |
| 4544 | * {@link #DATA1}<br> |
| 4545 | * {@link #DATA2}<br> |
| 4546 | * {@link #DATA3}<br> |
| 4547 | * {@link #DATA4}<br> |
| 4548 | * {@link #DATA5}<br> |
| 4549 | * {@link #DATA6}<br> |
| 4550 | * {@link #DATA7}<br> |
| 4551 | * {@link #DATA8}<br> |
| 4552 | * {@link #DATA9}<br> |
| 4553 | * {@link #DATA10}<br> |
| 4554 | * {@link #DATA11}<br> |
| 4555 | * {@link #DATA12}<br> |
| 4556 | * {@link #DATA13}<br> |
| 4557 | * {@link #DATA14}<br> |
| 4558 | * {@link #DATA15} |
| 4559 | * </td> |
| 4560 | * <td>read-only</td> |
| 4561 | * <td>See {@link ContactsContract.Data}.</td> |
| 4562 | * </tr> |
| 4563 | * <tr> |
| 4564 | * <td>Any type</td> |
| 4565 | * <td> |
| 4566 | * {@link #SYNC1}<br> |
| 4567 | * {@link #SYNC2}<br> |
| 4568 | * {@link #SYNC3}<br> |
| 4569 | * {@link #SYNC4} |
| 4570 | * </td> |
| 4571 | * <td>read-only</td> |
| 4572 | * <td>See {@link ContactsContract.Data}.</td> |
| 4573 | * </tr> |
| 4574 | * </table> |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 4575 | */ |
| 4576 | public final static class RawContactsEntity |
| 4577 | implements BaseColumns, DataColumns, RawContactsColumns { |
| 4578 | /** |
| 4579 | * This utility class cannot be instantiated |
| 4580 | */ |
| 4581 | private RawContactsEntity() {} |
| 4582 | |
| 4583 | /** |
| 4584 | * The content:// style URI for this table |
| 4585 | */ |
| 4586 | public static final Uri CONTENT_URI = |
| 4587 | Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities"); |
| 4588 | |
| 4589 | /** |
Dave Santoro | 2b4d075 | 2011-09-07 17:37:33 -0700 | [diff] [blame] | 4590 | * The content:// style URI for this table, specific to the user's profile. |
| 4591 | */ |
| 4592 | public static final Uri PROFILE_CONTENT_URI = |
| 4593 | Uri.withAppendedPath(Profile.CONTENT_URI, "raw_contact_entities"); |
| 4594 | |
| 4595 | /** |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 4596 | * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities. |
| 4597 | */ |
| 4598 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity"; |
| 4599 | |
| 4600 | /** |
| 4601 | * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward |
| 4602 | * Data.CONTENT_URI contains only exportable data. |
| 4603 | * |
| 4604 | * This flag is useful (currently) only for vCard exporter in Contacts app, which |
| 4605 | * needs to exclude "un-exportable" data from available data to export, while |
| 4606 | * Contacts app itself has priviledge to access all data including "un-expotable" |
| 4607 | * ones and providers return all of them regardless of the callers' intention. |
| 4608 | * <P>Type: INTEGER</p> |
| 4609 | * |
| 4610 | * @hide Maybe available only in Eclair and not really ready for public use. |
| 4611 | * TODO: remove, or implement this feature completely. As of now (Eclair), |
| 4612 | * we only use this flag in queryEntities(), not query(). |
| 4613 | */ |
| 4614 | public static final String FOR_EXPORT_ONLY = "for_export_only"; |
| 4615 | |
| 4616 | /** |
| 4617 | * The ID of the data column. The value will be null if this raw contact has no data rows. |
| 4618 | * <P>Type: INTEGER</P> |
| 4619 | */ |
| 4620 | public static final String DATA_ID = "data_id"; |
| 4621 | } |
| 4622 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4623 | /** |
| 4624 | * @see PhoneLookup |
| 4625 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 4626 | protected interface PhoneLookupColumns { |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4627 | /** |
| 4628 | * The phone number as the user entered it. |
| 4629 | * <P>Type: TEXT</P> |
| 4630 | */ |
| 4631 | public static final String NUMBER = "number"; |
| 4632 | |
| 4633 | /** |
| 4634 | * The type of phone number, for example Home or Work. |
| 4635 | * <P>Type: INTEGER</P> |
| 4636 | */ |
| 4637 | public static final String TYPE = "type"; |
| 4638 | |
| 4639 | /** |
| 4640 | * The user defined label for the phone number. |
| 4641 | * <P>Type: TEXT</P> |
| 4642 | */ |
| 4643 | public static final String LABEL = "label"; |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 4644 | |
| 4645 | /** |
| 4646 | * The phone number's E164 representation. |
| 4647 | * <P>Type: TEXT</P> |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 4648 | */ |
| 4649 | public static final String NORMALIZED_NUMBER = "normalized_number"; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4650 | } |
| 4651 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4652 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4653 | * 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] | 4654 | * 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] | 4655 | * want to find to {@link #CONTENT_FILTER_URI}. This query is highly |
| 4656 | * optimized. |
| 4657 | * <pre> |
| 4658 | * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); |
| 4659 | * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,... |
| 4660 | * </pre> |
| 4661 | * |
| 4662 | * <h3>Columns</h3> |
| 4663 | * |
| 4664 | * <table class="jd-sumtable"> |
| 4665 | * <tr> |
| 4666 | * <th colspan='4'>PhoneLookup</th> |
| 4667 | * </tr> |
| 4668 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4669 | * <td>String</td> |
| 4670 | * <td>{@link #NUMBER}</td> |
| 4671 | * <td>read-only</td> |
| 4672 | * <td>Phone number.</td> |
| 4673 | * </tr> |
| 4674 | * <tr> |
| 4675 | * <td>String</td> |
| 4676 | * <td>{@link #TYPE}</td> |
| 4677 | * <td>read-only</td> |
| 4678 | * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td> |
| 4679 | * </tr> |
| 4680 | * <tr> |
| 4681 | * <td>String</td> |
| 4682 | * <td>{@link #LABEL}</td> |
| 4683 | * <td>read-only</td> |
| 4684 | * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td> |
| 4685 | * </tr> |
| 4686 | * </table> |
| 4687 | * <p> |
| 4688 | * Columns from the Contacts table are also available through a join. |
| 4689 | * </p> |
| 4690 | * <table class="jd-sumtable"> |
| 4691 | * <tr> |
| 4692 | * <th colspan='4'>Join with {@link Contacts}</th> |
| 4693 | * </tr> |
| 4694 | * <tr> |
Dmitri Plotnikov | 817b3f9 | 2011-01-09 17:07:13 -0800 | [diff] [blame] | 4695 | * <td>long</td> |
| 4696 | * <td>{@link #_ID}</td> |
| 4697 | * <td>read-only</td> |
| 4698 | * <td>Contact ID.</td> |
| 4699 | * </tr> |
| 4700 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4701 | * <td>String</td> |
| 4702 | * <td>{@link #LOOKUP_KEY}</td> |
| 4703 | * <td>read-only</td> |
| 4704 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4705 | * </tr> |
| 4706 | * <tr> |
| 4707 | * <td>String</td> |
| 4708 | * <td>{@link #DISPLAY_NAME}</td> |
| 4709 | * <td>read-only</td> |
| 4710 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4711 | * </tr> |
| 4712 | * <tr> |
| 4713 | * <td>long</td> |
| 4714 | * <td>{@link #PHOTO_ID}</td> |
| 4715 | * <td>read-only</td> |
| 4716 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4717 | * </tr> |
| 4718 | * <tr> |
| 4719 | * <td>int</td> |
| 4720 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 4721 | * <td>read-only</td> |
| 4722 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4723 | * </tr> |
| 4724 | * <tr> |
| 4725 | * <td>int</td> |
| 4726 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 4727 | * <td>read-only</td> |
| 4728 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4729 | * </tr> |
| 4730 | * <tr> |
| 4731 | * <td>int</td> |
| 4732 | * <td>{@link #TIMES_CONTACTED}</td> |
| 4733 | * <td>read-only</td> |
| 4734 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4735 | * </tr> |
| 4736 | * <tr> |
| 4737 | * <td>long</td> |
| 4738 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 4739 | * <td>read-only</td> |
| 4740 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4741 | * </tr> |
| 4742 | * <tr> |
| 4743 | * <td>int</td> |
| 4744 | * <td>{@link #STARRED}</td> |
| 4745 | * <td>read-only</td> |
| 4746 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4747 | * </tr> |
| 4748 | * <tr> |
| 4749 | * <td>String</td> |
| 4750 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 4751 | * <td>read-only</td> |
| 4752 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4753 | * </tr> |
| 4754 | * <tr> |
| 4755 | * <td>int</td> |
| 4756 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 4757 | * <td>read-only</td> |
| 4758 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4759 | * </tr> |
| 4760 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4761 | */ |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4762 | public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, |
| 4763 | ContactsColumns, ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4764 | /** |
| 4765 | * This utility class cannot be instantiated |
| 4766 | */ |
| 4767 | private PhoneLookup() {} |
| 4768 | |
| 4769 | /** |
| 4770 | * The content:// style URI for this table. Append the phone number you want to lookup |
| 4771 | * to this URI and query it to perform a lookup. For example: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4772 | * <pre> |
Scott Kennedy | 7ed189e | 2013-01-11 22:31:43 -0800 | [diff] [blame] | 4773 | * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, |
| 4774 | * Uri.encode(phoneNumber)); |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4775 | * </pre> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4776 | */ |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4777 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 4778 | "phone_lookup"); |
Dmitri Plotnikov | 0b0b8a8 | 2010-03-04 18:20:08 -0800 | [diff] [blame] | 4779 | |
| 4780 | /** |
| 4781 | * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows. |
| 4782 | * |
| 4783 | * @hide |
| 4784 | */ |
| 4785 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup"; |
Flavio Lerda | 52c01c2 | 2011-11-02 22:16:23 +0000 | [diff] [blame] | 4786 | |
| 4787 | /** |
| 4788 | * Boolean parameter that is used to look up a SIP address. |
| 4789 | * |
| 4790 | * @hide |
| 4791 | */ |
| 4792 | public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4793 | } |
| 4794 | |
| 4795 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 4796 | * Additional data mixed in with {@link StatusColumns} to link |
| 4797 | * back to specific {@link ContactsContract.Data#_ID} entries. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4798 | * |
| 4799 | * @see StatusUpdates |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4800 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 4801 | protected interface PresenceColumns { |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 4802 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4803 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4804 | * Reference to the {@link Data#_ID} entry that owns this presence. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4805 | * <P>Type: INTEGER</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4806 | */ |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 4807 | public static final String DATA_ID = "presence_data_id"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4808 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4809 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4810 | * See {@link CommonDataKinds.Im} for a list of defined protocol constants. |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 4811 | * <p>Type: NUMBER</p> |
| 4812 | */ |
| 4813 | public static final String PROTOCOL = "protocol"; |
| 4814 | |
| 4815 | /** |
| 4816 | * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 4817 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 4818 | * omitted if {@link #PROTOCOL} value is not |
| 4819 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. |
| 4820 | * |
| 4821 | * <p>Type: NUMBER</p> |
| 4822 | */ |
| 4823 | public static final String CUSTOM_PROTOCOL = "custom_protocol"; |
| 4824 | |
| 4825 | /** |
| 4826 | * The IM handle the presence item is for. The handle is scoped to |
| 4827 | * {@link #PROTOCOL}. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4828 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4829 | */ |
| 4830 | public static final String IM_HANDLE = "im_handle"; |
| 4831 | |
| 4832 | /** |
| 4833 | * 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] | 4834 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4835 | */ |
| 4836 | public static final String IM_ACCOUNT = "im_account"; |
| 4837 | } |
| 4838 | |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 4839 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4840 | * <p> |
| 4841 | * A status update is linked to a {@link ContactsContract.Data} row and captures |
| 4842 | * the user's latest status update via the corresponding source, e.g. |
| 4843 | * "Having lunch" via "Google Talk". |
| 4844 | * </p> |
| 4845 | * <p> |
| 4846 | * There are two ways a status update can be inserted: by explicitly linking |
| 4847 | * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row |
| 4848 | * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 4849 | * {@link #IM_HANDLE}. There is no difference between insert and update, you can use |
| 4850 | * either. |
| 4851 | * </p> |
| 4852 | * <p> |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 4853 | * Inserting or updating a status update for the user's profile requires either using |
| 4854 | * the {@link #DATA_ID} to identify the data row to attach the update to, or |
| 4855 | * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the |
| 4856 | * profile. |
| 4857 | * </p> |
| 4858 | * <p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4859 | * You cannot use {@link ContentResolver#update} to change a status, but |
| 4860 | * {@link ContentResolver#insert} will replace the latests status if it already |
| 4861 | * exists. |
| 4862 | * </p> |
| 4863 | * <p> |
| 4864 | * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses |
| 4865 | * for multiple contacts at once. |
| 4866 | * </p> |
| 4867 | * |
| 4868 | * <h3>Columns</h3> |
| 4869 | * <table class="jd-sumtable"> |
| 4870 | * <tr> |
| 4871 | * <th colspan='4'>StatusUpdates</th> |
| 4872 | * </tr> |
| 4873 | * <tr> |
| 4874 | * <td>long</td> |
| 4875 | * <td>{@link #DATA_ID}</td> |
| 4876 | * <td>read/write</td> |
| 4877 | * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this |
| 4878 | * field is <i>not</i> specified, the provider will attempt to find a data row |
| 4879 | * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 4880 | * {@link #IM_HANDLE} columns. |
| 4881 | * </td> |
| 4882 | * </tr> |
| 4883 | * <tr> |
| 4884 | * <td>long</td> |
| 4885 | * <td>{@link #PROTOCOL}</td> |
| 4886 | * <td>read/write</td> |
| 4887 | * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td> |
| 4888 | * </tr> |
| 4889 | * <tr> |
| 4890 | * <td>String</td> |
| 4891 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 4892 | * <td>read/write</td> |
| 4893 | * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 4894 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 4895 | * omitted if {@link #PROTOCOL} value is not |
| 4896 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td> |
| 4897 | * </tr> |
| 4898 | * <tr> |
| 4899 | * <td>String</td> |
| 4900 | * <td>{@link #IM_HANDLE}</td> |
| 4901 | * <td>read/write</td> |
| 4902 | * <td> The IM handle the presence item is for. The handle is scoped to |
| 4903 | * {@link #PROTOCOL}.</td> |
| 4904 | * </tr> |
| 4905 | * <tr> |
| 4906 | * <td>String</td> |
| 4907 | * <td>{@link #IM_ACCOUNT}</td> |
| 4908 | * <td>read/write</td> |
| 4909 | * <td>The IM account for the local user that the presence data came from.</td> |
| 4910 | * </tr> |
| 4911 | * <tr> |
| 4912 | * <td>int</td> |
| 4913 | * <td>{@link #PRESENCE}</td> |
| 4914 | * <td>read/write</td> |
| 4915 | * <td>Contact IM presence status. The allowed values are: |
| 4916 | * <p> |
| 4917 | * <ul> |
| 4918 | * <li>{@link #OFFLINE}</li> |
| 4919 | * <li>{@link #INVISIBLE}</li> |
| 4920 | * <li>{@link #AWAY}</li> |
| 4921 | * <li>{@link #IDLE}</li> |
| 4922 | * <li>{@link #DO_NOT_DISTURB}</li> |
| 4923 | * <li>{@link #AVAILABLE}</li> |
| 4924 | * </ul> |
| 4925 | * </p> |
| 4926 | * <p> |
| 4927 | * Since presence status is inherently volatile, the content provider |
| 4928 | * may choose not to store this field in long-term storage. |
| 4929 | * </p> |
| 4930 | * </td> |
| 4931 | * </tr> |
| 4932 | * <tr> |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 4933 | * <td>int</td> |
| 4934 | * <td>{@link #CHAT_CAPABILITY}</td> |
| 4935 | * <td>read/write</td> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 4936 | * <td>Contact IM chat compatibility value. The allowed values combinations of the following |
| 4937 | * 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] | 4938 | * <p> |
| 4939 | * <ul> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 4940 | * <li>{@link #CAPABILITY_HAS_VIDEO}</li> |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 4941 | * <li>{@link #CAPABILITY_HAS_VOICE}</li> |
| 4942 | * <li>{@link #CAPABILITY_HAS_CAMERA}</li> |
| 4943 | * </ul> |
| 4944 | * </p> |
| 4945 | * <p> |
| 4946 | * Since chat compatibility is inherently volatile as the contact's availability moves from |
| 4947 | * one device to another, the content provider may choose not to store this field in long-term |
| 4948 | * storage. |
| 4949 | * </p> |
| 4950 | * </td> |
| 4951 | * </tr> |
| 4952 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4953 | * <td>String</td> |
| 4954 | * <td>{@link #STATUS}</td> |
| 4955 | * <td>read/write</td> |
| 4956 | * <td>Contact's latest status update, e.g. "having toast for breakfast"</td> |
| 4957 | * </tr> |
| 4958 | * <tr> |
| 4959 | * <td>long</td> |
| 4960 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 4961 | * <td>read/write</td> |
| 4962 | * <td>The absolute time in milliseconds when the status was |
| 4963 | * entered by the user. If this value is not provided, the provider will follow |
| 4964 | * this logic: if there was no prior status update, the value will be left as null. |
| 4965 | * If there was a prior status update, the provider will default this field |
| 4966 | * to the current time.</td> |
| 4967 | * </tr> |
| 4968 | * <tr> |
| 4969 | * <td>String</td> |
| 4970 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 4971 | * <td>read/write</td> |
| 4972 | * <td> The package containing resources for this status: label and icon.</td> |
| 4973 | * </tr> |
| 4974 | * <tr> |
| 4975 | * <td>long</td> |
| 4976 | * <td>{@link #STATUS_LABEL}</td> |
| 4977 | * <td>read/write</td> |
| 4978 | * <td>The resource ID of the label describing the source of contact status, |
| 4979 | * e.g. "Google Talk". This resource is scoped by the |
| 4980 | * {@link #STATUS_RES_PACKAGE}.</td> |
| 4981 | * </tr> |
| 4982 | * <tr> |
| 4983 | * <td>long</td> |
| 4984 | * <td>{@link #STATUS_ICON}</td> |
| 4985 | * <td>read/write</td> |
| 4986 | * <td>The resource ID of the icon for the source of contact status. This |
| 4987 | * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4988 | * </tr> |
| 4989 | * </table> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 4990 | */ |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4991 | public static class StatusUpdates implements StatusColumns, PresenceColumns { |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 4992 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4993 | /** |
| 4994 | * This utility class cannot be instantiated |
| 4995 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 4996 | private StatusUpdates() {} |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4997 | |
| 4998 | /** |
| 4999 | * The content:// style URI for this table |
| 5000 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5001 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates"); |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5002 | |
| 5003 | /** |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 5004 | * The content:// style URI for this table, specific to the user's profile. |
| 5005 | */ |
| 5006 | public static final Uri PROFILE_CONTENT_URI = |
| 5007 | Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates"); |
| 5008 | |
| 5009 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5010 | * Gets the resource ID for the proper presence icon. |
| 5011 | * |
| 5012 | * @param status the status to get the icon for |
| 5013 | * @return the resource ID for the proper presence icon |
| 5014 | */ |
| 5015 | public static final int getPresenceIconResourceId(int status) { |
| 5016 | switch (status) { |
| 5017 | case AVAILABLE: |
| 5018 | return android.R.drawable.presence_online; |
| 5019 | case IDLE: |
| 5020 | case AWAY: |
| 5021 | return android.R.drawable.presence_away; |
| 5022 | case DO_NOT_DISTURB: |
| 5023 | return android.R.drawable.presence_busy; |
| 5024 | case INVISIBLE: |
| 5025 | return android.R.drawable.presence_invisible; |
| 5026 | case OFFLINE: |
| 5027 | default: |
| 5028 | return android.R.drawable.presence_offline; |
| 5029 | } |
| 5030 | } |
| 5031 | |
| 5032 | /** |
Evan Millar | c043752 | 2009-06-23 17:31:05 -0700 | [diff] [blame] | 5033 | * Returns the precedence of the status code the higher number being the higher precedence. |
| 5034 | * |
| 5035 | * @param status The status code. |
| 5036 | * @return An integer representing the precedence, 0 being the lowest. |
| 5037 | */ |
| 5038 | public static final int getPresencePrecedence(int status) { |
| 5039 | // Keep this function here incase we want to enforce a different precedence than the |
| 5040 | // natural order of the status constants. |
| 5041 | return status; |
| 5042 | } |
| 5043 | |
| 5044 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5045 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5046 | * status update details. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5047 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5048 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5049 | |
| 5050 | /** |
| 5051 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5052 | * status update detail. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5053 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5054 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update"; |
| 5055 | } |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 5056 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5057 | /** |
| 5058 | * @deprecated This old name was never meant to be made public. Do not use. |
| 5059 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5060 | @Deprecated |
| 5061 | public static final class Presence extends StatusUpdates { |
| 5062 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5063 | } |
| 5064 | |
| 5065 | /** |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5066 | * Additional column returned by the {@link Contacts#CONTENT_FILTER_URI} providing the |
| 5067 | * explanation of why the filter matched the contact. Specifically, it contains the |
| 5068 | * data elements that matched the query. The overall number of words in the snippet |
| 5069 | * can be capped. |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5070 | * |
| 5071 | * @hide |
| 5072 | */ |
| 5073 | public static class SearchSnippetColumns { |
| 5074 | |
| 5075 | /** |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5076 | * The search snippet constructed according to the SQLite rules, see |
| 5077 | * http://www.sqlite.org/fts3.html#snippet |
| 5078 | * <p> |
| 5079 | * The snippet may contain (parts of) several data elements comprising |
| 5080 | * the contact. |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5081 | * |
| 5082 | * @hide |
| 5083 | */ |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5084 | public static final String SNIPPET = "snippet"; |
| 5085 | |
| 5086 | |
| 5087 | /** |
| 5088 | * Comma-separated parameters for the generation of the snippet: |
| 5089 | * <ul> |
| 5090 | * <li>The "start match" text. Default is <b></li> |
| 5091 | * <li>The "end match" text. Default is </b></li> |
| 5092 | * <li>The "ellipsis" text. Default is <b>...</b></li> |
| 5093 | * <li>Maximum number of tokens to include in the snippet. Can be either |
| 5094 | * a positive or a negative number: A positive number indicates how many |
| 5095 | * tokens can be returned in total. A negative number indicates how many |
| 5096 | * tokens can be returned per occurrence of the search terms.</li> |
| 5097 | * </ul> |
| 5098 | * |
| 5099 | * @hide |
| 5100 | */ |
| 5101 | public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args"; |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5102 | |
| 5103 | /** |
| 5104 | * A key to ask the provider to defer the snippeting to the client if possible. |
| 5105 | * Value of 1 implies true, 0 implies false when 0 is the default. |
| 5106 | * When a cursor is returned to the client, it should check for an extra with the name |
| 5107 | * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client |
Chiao Cheng | 31b730a | 2013-06-17 18:31:34 -0700 | [diff] [blame^] | 5108 | * should do its own snippeting. If it doesn't exist, the snippet column in the cursor |
| 5109 | * should already contain a snippetized string. |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5110 | * |
| 5111 | * @hide |
| 5112 | */ |
| 5113 | public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting"; |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5114 | } |
| 5115 | |
| 5116 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5117 | * Container for definitions of common data types stored in the {@link ContactsContract.Data} |
| 5118 | * table. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5119 | */ |
| 5120 | public static final class CommonDataKinds { |
| 5121 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5122 | * This utility class cannot be instantiated |
| 5123 | */ |
| 5124 | private CommonDataKinds() {} |
| 5125 | |
| 5126 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5127 | * The {@link Data#RES_PACKAGE} value for common data that should be |
| 5128 | * shown using a default style. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5129 | * |
| 5130 | * @hide RES_PACKAGE is hidden |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5131 | */ |
| 5132 | public static final String PACKAGE_COMMON = "common"; |
| 5133 | |
| 5134 | /** |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5135 | * The base types that all "Typed" data kinds support. |
| 5136 | */ |
| 5137 | public interface BaseTypes { |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5138 | /** |
| 5139 | * A custom type. The custom label should be supplied by user. |
| 5140 | */ |
| 5141 | public static int TYPE_CUSTOM = 0; |
| 5142 | } |
| 5143 | |
| 5144 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5145 | * Columns common across the specific types. |
| 5146 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5147 | protected interface CommonColumns extends BaseTypes { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5148 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5149 | * The data for the contact method. |
| 5150 | * <P>Type: TEXT</P> |
| 5151 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5152 | public static final String DATA = DataColumns.DATA1; |
| 5153 | |
| 5154 | /** |
| 5155 | * The type of data, for example Home or Work. |
| 5156 | * <P>Type: INTEGER</P> |
| 5157 | */ |
| 5158 | public static final String TYPE = DataColumns.DATA2; |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 5159 | |
| 5160 | /** |
| 5161 | * The user defined label for the the contact method. |
| 5162 | * <P>Type: TEXT</P> |
| 5163 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5164 | public static final String LABEL = DataColumns.DATA3; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5165 | } |
| 5166 | |
| 5167 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5168 | * A data kind representing the contact's proper name. You can use all |
| 5169 | * columns defined for {@link ContactsContract.Data} as well as the following aliases. |
| 5170 | * |
| 5171 | * <h2>Column aliases</h2> |
| 5172 | * <table class="jd-sumtable"> |
| 5173 | * <tr> |
| 5174 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 5175 | * </tr> |
| 5176 | * <tr> |
| 5177 | * <td>String</td> |
| 5178 | * <td>{@link #DISPLAY_NAME}</td> |
| 5179 | * <td>{@link #DATA1}</td> |
| 5180 | * <td></td> |
| 5181 | * </tr> |
| 5182 | * <tr> |
| 5183 | * <td>String</td> |
| 5184 | * <td>{@link #GIVEN_NAME}</td> |
| 5185 | * <td>{@link #DATA2}</td> |
| 5186 | * <td></td> |
| 5187 | * </tr> |
| 5188 | * <tr> |
| 5189 | * <td>String</td> |
| 5190 | * <td>{@link #FAMILY_NAME}</td> |
| 5191 | * <td>{@link #DATA3}</td> |
| 5192 | * <td></td> |
| 5193 | * </tr> |
| 5194 | * <tr> |
| 5195 | * <td>String</td> |
| 5196 | * <td>{@link #PREFIX}</td> |
| 5197 | * <td>{@link #DATA4}</td> |
| 5198 | * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td> |
| 5199 | * </tr> |
| 5200 | * <tr> |
| 5201 | * <td>String</td> |
| 5202 | * <td>{@link #MIDDLE_NAME}</td> |
| 5203 | * <td>{@link #DATA5}</td> |
| 5204 | * <td></td> |
| 5205 | * </tr> |
| 5206 | * <tr> |
| 5207 | * <td>String</td> |
| 5208 | * <td>{@link #SUFFIX}</td> |
| 5209 | * <td>{@link #DATA6}</td> |
| 5210 | * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td> |
| 5211 | * </tr> |
| 5212 | * <tr> |
| 5213 | * <td>String</td> |
| 5214 | * <td>{@link #PHONETIC_GIVEN_NAME}</td> |
| 5215 | * <td>{@link #DATA7}</td> |
| 5216 | * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td> |
| 5217 | * </tr> |
| 5218 | * <tr> |
| 5219 | * <td>String</td> |
| 5220 | * <td>{@link #PHONETIC_MIDDLE_NAME}</td> |
| 5221 | * <td>{@link #DATA8}</td> |
| 5222 | * <td></td> |
| 5223 | * </tr> |
| 5224 | * <tr> |
| 5225 | * <td>String</td> |
| 5226 | * <td>{@link #PHONETIC_FAMILY_NAME}</td> |
| 5227 | * <td>{@link #DATA9}</td> |
| 5228 | * <td></td> |
| 5229 | * </tr> |
| 5230 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5231 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5232 | public static final class StructuredName implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5233 | /** |
| 5234 | * This utility class cannot be instantiated |
| 5235 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5236 | private StructuredName() {} |
| 5237 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5238 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5239 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; |
| 5240 | |
| 5241 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5242 | * The name that should be used to display the contact. |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 5243 | * <i>Unstructured component of the name should be consistent with |
| 5244 | * its structured representation.</i> |
| 5245 | * <p> |
| 5246 | * Type: TEXT |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5247 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5248 | public static final String DISPLAY_NAME = DATA1; |
| 5249 | |
| 5250 | /** |
| 5251 | * The given name for the contact. |
| 5252 | * <P>Type: TEXT</P> |
| 5253 | */ |
| 5254 | public static final String GIVEN_NAME = DATA2; |
| 5255 | |
| 5256 | /** |
| 5257 | * The family name for the contact. |
| 5258 | * <P>Type: TEXT</P> |
| 5259 | */ |
| 5260 | public static final String FAMILY_NAME = DATA3; |
| 5261 | |
| 5262 | /** |
| 5263 | * The contact's honorific prefix, e.g. "Sir" |
| 5264 | * <P>Type: TEXT</P> |
| 5265 | */ |
| 5266 | public static final String PREFIX = DATA4; |
| 5267 | |
| 5268 | /** |
| 5269 | * The contact's middle name |
| 5270 | * <P>Type: TEXT</P> |
| 5271 | */ |
| 5272 | public static final String MIDDLE_NAME = DATA5; |
| 5273 | |
| 5274 | /** |
| 5275 | * The contact's honorific suffix, e.g. "Jr" |
| 5276 | */ |
| 5277 | public static final String SUFFIX = DATA6; |
| 5278 | |
| 5279 | /** |
| 5280 | * The phonetic version of the given name for the contact. |
| 5281 | * <P>Type: TEXT</P> |
| 5282 | */ |
| 5283 | public static final String PHONETIC_GIVEN_NAME = DATA7; |
| 5284 | |
| 5285 | /** |
| 5286 | * The phonetic version of the additional name for the contact. |
| 5287 | * <P>Type: TEXT</P> |
| 5288 | */ |
| 5289 | public static final String PHONETIC_MIDDLE_NAME = DATA8; |
| 5290 | |
| 5291 | /** |
| 5292 | * The phonetic version of the family name for the contact. |
| 5293 | * <P>Type: TEXT</P> |
| 5294 | */ |
| 5295 | public static final String PHONETIC_FAMILY_NAME = DATA9; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5296 | |
| 5297 | /** |
| 5298 | * The style used for combining given/middle/family name into a full name. |
| 5299 | * See {@link ContactsContract.FullNameStyle}. |
| 5300 | * |
| 5301 | * @hide |
| 5302 | */ |
| 5303 | public static final String FULL_NAME_STYLE = DATA10; |
| 5304 | |
| 5305 | /** |
| 5306 | * The alphabet used for capturing the phonetic name. |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 5307 | * See ContactsContract.PhoneticNameStyle. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5308 | * @hide |
| 5309 | */ |
| 5310 | public static final String PHONETIC_NAME_STYLE = DATA11; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5311 | } |
| 5312 | |
| 5313 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5314 | * <p>A data kind representing the contact's nickname. For example, for |
| 5315 | * Bob Parr ("Mr. Incredible"): |
| 5316 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 5317 | * ArrayList<ContentProviderOperation> ops = |
| 5318 | * new ArrayList<ContentProviderOperation>(); |
| 5319 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5320 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 5321 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 5322 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 5323 | * .withValue(StructuredName.DISPLAY_NAME, "Bob Parr") |
| 5324 | * .build()); |
| 5325 | * |
| 5326 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 5327 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 5328 | * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE) |
| 5329 | * .withValue(Nickname.NAME, "Mr. Incredible") |
| 5330 | * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM) |
| 5331 | * .withValue(Nickname.LABEL, "Superhero") |
| 5332 | * .build()); |
| 5333 | * |
| 5334 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 5335 | * </pre> |
| 5336 | * </p> |
| 5337 | * <p> |
| 5338 | * You can use all columns defined for {@link ContactsContract.Data} as well as the |
| 5339 | * following aliases. |
| 5340 | * </p> |
| 5341 | * |
| 5342 | * <h2>Column aliases</h2> |
| 5343 | * <table class="jd-sumtable"> |
| 5344 | * <tr> |
| 5345 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 5346 | * </tr> |
| 5347 | * <tr> |
| 5348 | * <td>String</td> |
| 5349 | * <td>{@link #NAME}</td> |
| 5350 | * <td>{@link #DATA1}</td> |
| 5351 | * <td></td> |
| 5352 | * </tr> |
| 5353 | * <tr> |
| 5354 | * <td>int</td> |
| 5355 | * <td>{@link #TYPE}</td> |
| 5356 | * <td>{@link #DATA2}</td> |
| 5357 | * <td> |
| 5358 | * Allowed values are: |
| 5359 | * <p> |
| 5360 | * <ul> |
| 5361 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5362 | * <li>{@link #TYPE_DEFAULT}</li> |
| 5363 | * <li>{@link #TYPE_OTHER_NAME}</li> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5364 | * <li>{@link #TYPE_MAIDEN_NAME}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5365 | * <li>{@link #TYPE_SHORT_NAME}</li> |
| 5366 | * <li>{@link #TYPE_INITIALS}</li> |
| 5367 | * </ul> |
| 5368 | * </p> |
| 5369 | * </td> |
| 5370 | * </tr> |
| 5371 | * <tr> |
| 5372 | * <td>String</td> |
| 5373 | * <td>{@link #LABEL}</td> |
| 5374 | * <td>{@link #DATA3}</td> |
| 5375 | * <td></td> |
| 5376 | * </tr> |
| 5377 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5378 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5379 | public static final class Nickname implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5380 | /** |
| 5381 | * This utility class cannot be instantiated |
| 5382 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5383 | private Nickname() {} |
| 5384 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5385 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5386 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; |
| 5387 | |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 5388 | public static final int TYPE_DEFAULT = 1; |
| 5389 | public static final int TYPE_OTHER_NAME = 2; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5390 | public static final int TYPE_MAIDEN_NAME = 3; |
| 5391 | /** @deprecated Use TYPE_MAIDEN_NAME instead. */ |
| 5392 | @Deprecated |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 5393 | public static final int TYPE_MAINDEN_NAME = 3; |
| 5394 | public static final int TYPE_SHORT_NAME = 4; |
| 5395 | public static final int TYPE_INITIALS = 5; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5396 | |
| 5397 | /** |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 5398 | * The name itself |
| 5399 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5400 | public static final String NAME = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5401 | } |
| 5402 | |
| 5403 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5404 | * <p> |
| 5405 | * A data kind representing a telephone number. |
| 5406 | * </p> |
| 5407 | * <p> |
| 5408 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5409 | * well as the following aliases. |
| 5410 | * </p> |
| 5411 | * <h2>Column aliases</h2> |
| 5412 | * <table class="jd-sumtable"> |
| 5413 | * <tr> |
| 5414 | * <th>Type</th> |
| 5415 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5416 | * </tr> |
| 5417 | * <tr> |
| 5418 | * <td>String</td> |
| 5419 | * <td>{@link #NUMBER}</td> |
| 5420 | * <td>{@link #DATA1}</td> |
| 5421 | * <td></td> |
| 5422 | * </tr> |
| 5423 | * <tr> |
| 5424 | * <td>int</td> |
| 5425 | * <td>{@link #TYPE}</td> |
| 5426 | * <td>{@link #DATA2}</td> |
| 5427 | * <td>Allowed values are: |
| 5428 | * <p> |
| 5429 | * <ul> |
| 5430 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5431 | * <li>{@link #TYPE_HOME}</li> |
| 5432 | * <li>{@link #TYPE_MOBILE}</li> |
| 5433 | * <li>{@link #TYPE_WORK}</li> |
| 5434 | * <li>{@link #TYPE_FAX_WORK}</li> |
| 5435 | * <li>{@link #TYPE_FAX_HOME}</li> |
| 5436 | * <li>{@link #TYPE_PAGER}</li> |
| 5437 | * <li>{@link #TYPE_OTHER}</li> |
| 5438 | * <li>{@link #TYPE_CALLBACK}</li> |
| 5439 | * <li>{@link #TYPE_CAR}</li> |
| 5440 | * <li>{@link #TYPE_COMPANY_MAIN}</li> |
| 5441 | * <li>{@link #TYPE_ISDN}</li> |
| 5442 | * <li>{@link #TYPE_MAIN}</li> |
| 5443 | * <li>{@link #TYPE_OTHER_FAX}</li> |
| 5444 | * <li>{@link #TYPE_RADIO}</li> |
| 5445 | * <li>{@link #TYPE_TELEX}</li> |
| 5446 | * <li>{@link #TYPE_TTY_TDD}</li> |
| 5447 | * <li>{@link #TYPE_WORK_MOBILE}</li> |
| 5448 | * <li>{@link #TYPE_WORK_PAGER}</li> |
| 5449 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 5450 | * <li>{@link #TYPE_MMS}</li> |
| 5451 | * </ul> |
| 5452 | * </p> |
| 5453 | * </td> |
| 5454 | * </tr> |
| 5455 | * <tr> |
| 5456 | * <td>String</td> |
| 5457 | * <td>{@link #LABEL}</td> |
| 5458 | * <td>{@link #DATA3}</td> |
| 5459 | * <td></td> |
| 5460 | * </tr> |
| 5461 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5462 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5463 | public static final class Phone implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5464 | /** |
| 5465 | * This utility class cannot be instantiated |
| 5466 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5467 | private Phone() {} |
| 5468 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5469 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5470 | 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] | 5471 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5472 | /** |
| 5473 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 5474 | * phones. |
| 5475 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5476 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2"; |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5477 | |
| 5478 | /** |
| 5479 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5480 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 5481 | * associated raw contact and aggregate contact data. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5482 | */ |
| 5483 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 5484 | "phones"); |
| 5485 | |
| 5486 | /** |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5487 | * 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] | 5488 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5489 | * to display names as well as phone numbers. The filter argument should be passed |
| 5490 | * as an additional path segment after this URI. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5491 | */ |
| 5492 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 5493 | "filter"); |
| 5494 | |
Daniel Lehmann | 1024de5 | 2012-06-15 20:32:33 -0700 | [diff] [blame] | 5495 | /** |
| 5496 | * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. |
| 5497 | * If "1" or "true", display names are searched. If "0" or "false", display names |
| 5498 | * are not searched. Default is "1". |
| 5499 | */ |
| 5500 | public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name"; |
| 5501 | |
| 5502 | /** |
| 5503 | * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. |
| 5504 | * If "1" or "true", phone numbers are searched. If "0" or "false", phone numbers |
| 5505 | * are not searched. Default is "1". |
| 5506 | */ |
| 5507 | public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number"; |
| 5508 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5509 | public static final int TYPE_HOME = 1; |
| 5510 | public static final int TYPE_MOBILE = 2; |
| 5511 | public static final int TYPE_WORK = 3; |
| 5512 | public static final int TYPE_FAX_WORK = 4; |
| 5513 | public static final int TYPE_FAX_HOME = 5; |
| 5514 | public static final int TYPE_PAGER = 6; |
| 5515 | public static final int TYPE_OTHER = 7; |
Fred Quintana | 3f86715 | 2009-08-03 11:43:16 -0700 | [diff] [blame] | 5516 | public static final int TYPE_CALLBACK = 8; |
| 5517 | public static final int TYPE_CAR = 9; |
| 5518 | public static final int TYPE_COMPANY_MAIN = 10; |
| 5519 | public static final int TYPE_ISDN = 11; |
| 5520 | public static final int TYPE_MAIN = 12; |
| 5521 | public static final int TYPE_OTHER_FAX = 13; |
| 5522 | public static final int TYPE_RADIO = 14; |
| 5523 | public static final int TYPE_TELEX = 15; |
| 5524 | public static final int TYPE_TTY_TDD = 16; |
| 5525 | public static final int TYPE_WORK_MOBILE = 17; |
| 5526 | public static final int TYPE_WORK_PAGER = 18; |
| 5527 | public static final int TYPE_ASSISTANT = 19; |
Jeff Sharkey | d5abd46 | 2009-09-16 19:54:29 -0700 | [diff] [blame] | 5528 | public static final int TYPE_MMS = 20; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5529 | |
| 5530 | /** |
| 5531 | * The phone number as the user entered it. |
| 5532 | * <P>Type: TEXT</P> |
| 5533 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5534 | public static final String NUMBER = DATA; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5535 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5536 | /** |
Daniel Lehmann | db91915 | 2012-03-09 14:30:50 -0800 | [diff] [blame] | 5537 | * 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] | 5538 | * case the provider will try to automatically infer it. (It'll be left null if the |
| 5539 | * provider fails to infer.) |
| 5540 | * 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] | 5541 | * <P>Type: TEXT</P> |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 5542 | */ |
| 5543 | public static final String NORMALIZED_NUMBER = DATA4; |
| 5544 | |
| 5545 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5546 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5547 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5548 | */ |
| 5549 | @Deprecated |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5550 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 5551 | CharSequence label, CharSequence[] labelArray) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5552 | return getTypeLabel(context.getResources(), type, label); |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5553 | } |
| 5554 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5555 | /** |
| 5556 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5557 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5558 | */ |
| 5559 | @Deprecated |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5560 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 5561 | CharSequence label) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5562 | return getTypeLabel(context.getResources(), type, label); |
| 5563 | } |
| 5564 | |
| 5565 | /** |
| 5566 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5567 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5568 | */ |
| 5569 | public static final int getTypeLabelResource(int type) { |
| 5570 | switch (type) { |
| 5571 | case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome; |
| 5572 | case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile; |
| 5573 | case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork; |
| 5574 | case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork; |
| 5575 | case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome; |
| 5576 | case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager; |
| 5577 | case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther; |
| 5578 | case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback; |
| 5579 | case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar; |
| 5580 | case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain; |
| 5581 | case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn; |
| 5582 | case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain; |
| 5583 | case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax; |
| 5584 | case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio; |
| 5585 | case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex; |
| 5586 | case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd; |
| 5587 | case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile; |
| 5588 | case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager; |
| 5589 | case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant; |
| 5590 | case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms; |
| 5591 | default: return com.android.internal.R.string.phoneTypeCustom; |
| 5592 | } |
| 5593 | } |
| 5594 | |
| 5595 | /** |
| 5596 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5597 | * possibly substituting the given {@link #LABEL} value |
| 5598 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5599 | */ |
| 5600 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 5601 | CharSequence label) { |
| 5602 | if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) { |
| 5603 | return label; |
| 5604 | } else { |
| 5605 | final int labelRes = getTypeLabelResource(type); |
| 5606 | return res.getText(labelRes); |
| 5607 | } |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5608 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5609 | } |
| 5610 | |
| 5611 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5612 | * <p> |
| 5613 | * A data kind representing an email address. |
| 5614 | * </p> |
| 5615 | * <p> |
| 5616 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5617 | * well as the following aliases. |
| 5618 | * </p> |
| 5619 | * <h2>Column aliases</h2> |
| 5620 | * <table class="jd-sumtable"> |
| 5621 | * <tr> |
| 5622 | * <th>Type</th> |
| 5623 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5624 | * </tr> |
| 5625 | * <tr> |
| 5626 | * <td>String</td> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 5627 | * <td>{@link #ADDRESS}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5628 | * <td>{@link #DATA1}</td> |
| 5629 | * <td>Email address itself.</td> |
| 5630 | * </tr> |
| 5631 | * <tr> |
| 5632 | * <td>int</td> |
| 5633 | * <td>{@link #TYPE}</td> |
| 5634 | * <td>{@link #DATA2}</td> |
| 5635 | * <td>Allowed values are: |
| 5636 | * <p> |
| 5637 | * <ul> |
| 5638 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5639 | * <li>{@link #TYPE_HOME}</li> |
| 5640 | * <li>{@link #TYPE_WORK}</li> |
| 5641 | * <li>{@link #TYPE_OTHER}</li> |
| 5642 | * <li>{@link #TYPE_MOBILE}</li> |
| 5643 | * </ul> |
| 5644 | * </p> |
| 5645 | * </td> |
| 5646 | * </tr> |
| 5647 | * <tr> |
| 5648 | * <td>String</td> |
| 5649 | * <td>{@link #LABEL}</td> |
| 5650 | * <td>{@link #DATA3}</td> |
| 5651 | * <td></td> |
| 5652 | * </tr> |
| 5653 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5654 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5655 | public static final class Email implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5656 | /** |
| 5657 | * This utility class cannot be instantiated |
| 5658 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5659 | private Email() {} |
| 5660 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5661 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5662 | 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] | 5663 | |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5664 | /** |
Dmitri Plotnikov | abf15c3 | 2009-09-18 20:29:11 -0700 | [diff] [blame] | 5665 | * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses. |
| 5666 | */ |
| 5667 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2"; |
| 5668 | |
| 5669 | /** |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5670 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5671 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5672 | * associated raw contact and aggregate contact data. |
| 5673 | */ |
| 5674 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 5675 | "emails"); |
| 5676 | |
| 5677 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5678 | * <p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5679 | * The content:// style URL for looking up data rows by email address. The |
| 5680 | * lookup argument, an email address, should be passed as an additional path segment |
| 5681 | * after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5682 | * </p> |
| 5683 | * <p>Example: |
| 5684 | * <pre> |
| 5685 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email)); |
| 5686 | * Cursor c = getContentResolver().query(uri, |
| 5687 | * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA}, |
| 5688 | * null, null, null); |
| 5689 | * </pre> |
| 5690 | * </p> |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5691 | */ |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5692 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 5693 | "lookup"); |
| 5694 | |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5695 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5696 | * <p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5697 | * 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] | 5698 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5699 | * to display names as well as email addresses. The filter argument should be passed |
| 5700 | * as an additional path segment after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5701 | * </p> |
| 5702 | * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)" |
| 5703 | * as well as "Bob Parr (incredible@android.com)". |
| 5704 | * <pre> |
| 5705 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob")); |
| 5706 | * Cursor c = getContentResolver().query(uri, |
| 5707 | * new String[]{Email.DISPLAY_NAME, Email.DATA}, |
| 5708 | * null, null, null); |
| 5709 | * </pre> |
| 5710 | * </p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5711 | */ |
| 5712 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5713 | "filter"); |
| 5714 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5715 | /** |
| 5716 | * The email address. |
| 5717 | * <P>Type: TEXT</P> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5718 | */ |
| 5719 | public static final String ADDRESS = DATA1; |
| 5720 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5721 | public static final int TYPE_HOME = 1; |
| 5722 | public static final int TYPE_WORK = 2; |
| 5723 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 14fb153 | 2009-08-29 15:54:26 -0700 | [diff] [blame] | 5724 | public static final int TYPE_MOBILE = 4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 5725 | |
| 5726 | /** |
| 5727 | * The display name for the email address |
| 5728 | * <P>Type: TEXT</P> |
| 5729 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5730 | public static final String DISPLAY_NAME = DATA4; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5731 | |
| 5732 | /** |
| 5733 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5734 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5735 | */ |
| 5736 | public static final int getTypeLabelResource(int type) { |
| 5737 | switch (type) { |
| 5738 | case TYPE_HOME: return com.android.internal.R.string.emailTypeHome; |
| 5739 | case TYPE_WORK: return com.android.internal.R.string.emailTypeWork; |
| 5740 | case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther; |
| 5741 | case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile; |
| 5742 | default: return com.android.internal.R.string.emailTypeCustom; |
| 5743 | } |
| 5744 | } |
| 5745 | |
| 5746 | /** |
| 5747 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5748 | * possibly substituting the given {@link #LABEL} value |
| 5749 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5750 | */ |
| 5751 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 5752 | CharSequence label) { |
| 5753 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 5754 | return label; |
| 5755 | } else { |
| 5756 | final int labelRes = getTypeLabelResource(type); |
| 5757 | return res.getText(labelRes); |
| 5758 | } |
| 5759 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5760 | } |
| 5761 | |
| 5762 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5763 | * <p> |
| 5764 | * A data kind representing a postal addresses. |
| 5765 | * </p> |
| 5766 | * <p> |
| 5767 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5768 | * well as the following aliases. |
| 5769 | * </p> |
| 5770 | * <h2>Column aliases</h2> |
| 5771 | * <table class="jd-sumtable"> |
| 5772 | * <tr> |
| 5773 | * <th>Type</th> |
| 5774 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5775 | * </tr> |
| 5776 | * <tr> |
| 5777 | * <td>String</td> |
| 5778 | * <td>{@link #FORMATTED_ADDRESS}</td> |
| 5779 | * <td>{@link #DATA1}</td> |
| 5780 | * <td></td> |
| 5781 | * </tr> |
| 5782 | * <tr> |
| 5783 | * <td>int</td> |
| 5784 | * <td>{@link #TYPE}</td> |
| 5785 | * <td>{@link #DATA2}</td> |
| 5786 | * <td>Allowed values are: |
| 5787 | * <p> |
| 5788 | * <ul> |
| 5789 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5790 | * <li>{@link #TYPE_HOME}</li> |
| 5791 | * <li>{@link #TYPE_WORK}</li> |
| 5792 | * <li>{@link #TYPE_OTHER}</li> |
| 5793 | * </ul> |
| 5794 | * </p> |
| 5795 | * </td> |
| 5796 | * </tr> |
| 5797 | * <tr> |
| 5798 | * <td>String</td> |
| 5799 | * <td>{@link #LABEL}</td> |
| 5800 | * <td>{@link #DATA3}</td> |
| 5801 | * <td></td> |
| 5802 | * </tr> |
| 5803 | * <tr> |
| 5804 | * <td>String</td> |
| 5805 | * <td>{@link #STREET}</td> |
| 5806 | * <td>{@link #DATA4}</td> |
| 5807 | * <td></td> |
| 5808 | * </tr> |
| 5809 | * <tr> |
| 5810 | * <td>String</td> |
| 5811 | * <td>{@link #POBOX}</td> |
| 5812 | * <td>{@link #DATA5}</td> |
| 5813 | * <td>Post Office Box number</td> |
| 5814 | * </tr> |
| 5815 | * <tr> |
| 5816 | * <td>String</td> |
| 5817 | * <td>{@link #NEIGHBORHOOD}</td> |
| 5818 | * <td>{@link #DATA6}</td> |
| 5819 | * <td></td> |
| 5820 | * </tr> |
| 5821 | * <tr> |
| 5822 | * <td>String</td> |
| 5823 | * <td>{@link #CITY}</td> |
| 5824 | * <td>{@link #DATA7}</td> |
| 5825 | * <td></td> |
| 5826 | * </tr> |
| 5827 | * <tr> |
| 5828 | * <td>String</td> |
| 5829 | * <td>{@link #REGION}</td> |
| 5830 | * <td>{@link #DATA8}</td> |
| 5831 | * <td></td> |
| 5832 | * </tr> |
| 5833 | * <tr> |
| 5834 | * <td>String</td> |
| 5835 | * <td>{@link #POSTCODE}</td> |
| 5836 | * <td>{@link #DATA9}</td> |
| 5837 | * <td></td> |
| 5838 | * </tr> |
| 5839 | * <tr> |
| 5840 | * <td>String</td> |
| 5841 | * <td>{@link #COUNTRY}</td> |
| 5842 | * <td>{@link #DATA10}</td> |
| 5843 | * <td></td> |
| 5844 | * </tr> |
| 5845 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5846 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5847 | public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5848 | /** |
| 5849 | * This utility class cannot be instantiated |
| 5850 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5851 | private StructuredPostal() { |
| 5852 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5853 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5854 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5855 | public static final String CONTENT_ITEM_TYPE = |
| 5856 | "vnd.android.cursor.item/postal-address_v2"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5857 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5858 | /** |
| 5859 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 5860 | * postal addresses. |
| 5861 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5862 | 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] | 5863 | |
| 5864 | /** |
| 5865 | * The content:// style URI for all data records of the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5866 | * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5867 | */ |
| 5868 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 5869 | "postals"); |
| 5870 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5871 | public static final int TYPE_HOME = 1; |
| 5872 | public static final int TYPE_WORK = 2; |
| 5873 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5874 | |
| 5875 | /** |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 5876 | * The full, unstructured postal address. <i>This field must be |
| 5877 | * consistent with any structured data.</i> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5878 | * <p> |
| 5879 | * Type: TEXT |
| 5880 | */ |
| 5881 | public static final String FORMATTED_ADDRESS = DATA; |
| 5882 | |
| 5883 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5884 | * Can be street, avenue, road, etc. This element also includes the |
| 5885 | * house number and room/apartment/flat/floor number. |
| 5886 | * <p> |
| 5887 | * Type: TEXT |
| 5888 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5889 | public static final String STREET = DATA4; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5890 | |
| 5891 | /** |
| 5892 | * Covers actual P.O. boxes, drawers, locked bags, etc. This is |
| 5893 | * usually but not always mutually exclusive with street. |
| 5894 | * <p> |
| 5895 | * Type: TEXT |
| 5896 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5897 | public static final String POBOX = DATA5; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5898 | |
| 5899 | /** |
| 5900 | * This is used to disambiguate a street address when a city |
| 5901 | * contains more than one street with the same name, or to specify a |
| 5902 | * small place whose mail is routed through a larger postal town. In |
| 5903 | * China it could be a county or a minor city. |
| 5904 | * <p> |
| 5905 | * Type: TEXT |
| 5906 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5907 | public static final String NEIGHBORHOOD = DATA6; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5908 | |
| 5909 | /** |
| 5910 | * Can be city, village, town, borough, etc. This is the postal town |
| 5911 | * and not necessarily the place of residence or place of business. |
| 5912 | * <p> |
| 5913 | * Type: TEXT |
| 5914 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5915 | public static final String CITY = DATA7; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5916 | |
| 5917 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5918 | * A state, province, county (in Ireland), Land (in Germany), |
| 5919 | * departement (in France), etc. |
| 5920 | * <p> |
| 5921 | * Type: TEXT |
| 5922 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5923 | public static final String REGION = DATA8; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5924 | |
| 5925 | /** |
Jeff Sharkey | ef348c7 | 2009-07-26 14:14:34 -0700 | [diff] [blame] | 5926 | * Postal code. Usually country-wide, but sometimes specific to the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5927 | * city (e.g. "2" in "Dublin 2, Ireland" addresses). |
| 5928 | * <p> |
| 5929 | * Type: TEXT |
| 5930 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5931 | public static final String POSTCODE = DATA9; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5932 | |
| 5933 | /** |
| 5934 | * The name or code of the country. |
| 5935 | * <p> |
| 5936 | * Type: TEXT |
| 5937 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5938 | public static final String COUNTRY = DATA10; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5939 | |
| 5940 | /** |
| 5941 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5942 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5943 | */ |
| 5944 | public static final int getTypeLabelResource(int type) { |
| 5945 | switch (type) { |
| 5946 | case TYPE_HOME: return com.android.internal.R.string.postalTypeHome; |
| 5947 | case TYPE_WORK: return com.android.internal.R.string.postalTypeWork; |
| 5948 | case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther; |
| 5949 | default: return com.android.internal.R.string.postalTypeCustom; |
| 5950 | } |
| 5951 | } |
| 5952 | |
| 5953 | /** |
| 5954 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5955 | * possibly substituting the given {@link #LABEL} value |
| 5956 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5957 | */ |
| 5958 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 5959 | CharSequence label) { |
| 5960 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 5961 | return label; |
| 5962 | } else { |
| 5963 | final int labelRes = getTypeLabelResource(type); |
| 5964 | return res.getText(labelRes); |
| 5965 | } |
| 5966 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5967 | } |
| 5968 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 5969 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5970 | * <p> |
| 5971 | * A data kind representing an IM address |
| 5972 | * </p> |
| 5973 | * <p> |
| 5974 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5975 | * well as the following aliases. |
| 5976 | * </p> |
| 5977 | * <h2>Column aliases</h2> |
| 5978 | * <table class="jd-sumtable"> |
| 5979 | * <tr> |
| 5980 | * <th>Type</th> |
| 5981 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5982 | * </tr> |
| 5983 | * <tr> |
| 5984 | * <td>String</td> |
| 5985 | * <td>{@link #DATA}</td> |
| 5986 | * <td>{@link #DATA1}</td> |
| 5987 | * <td></td> |
| 5988 | * </tr> |
| 5989 | * <tr> |
| 5990 | * <td>int</td> |
| 5991 | * <td>{@link #TYPE}</td> |
| 5992 | * <td>{@link #DATA2}</td> |
| 5993 | * <td>Allowed values are: |
| 5994 | * <p> |
| 5995 | * <ul> |
| 5996 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5997 | * <li>{@link #TYPE_HOME}</li> |
| 5998 | * <li>{@link #TYPE_WORK}</li> |
| 5999 | * <li>{@link #TYPE_OTHER}</li> |
| 6000 | * </ul> |
| 6001 | * </p> |
| 6002 | * </td> |
| 6003 | * </tr> |
| 6004 | * <tr> |
| 6005 | * <td>String</td> |
| 6006 | * <td>{@link #LABEL}</td> |
| 6007 | * <td>{@link #DATA3}</td> |
| 6008 | * <td></td> |
| 6009 | * </tr> |
| 6010 | * <tr> |
| 6011 | * <td>String</td> |
| 6012 | * <td>{@link #PROTOCOL}</td> |
| 6013 | * <td>{@link #DATA5}</td> |
| 6014 | * <td> |
| 6015 | * <p> |
| 6016 | * Allowed values: |
| 6017 | * <ul> |
| 6018 | * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name |
| 6019 | * as {@link #CUSTOM_PROTOCOL}.</li> |
| 6020 | * <li>{@link #PROTOCOL_AIM}</li> |
| 6021 | * <li>{@link #PROTOCOL_MSN}</li> |
| 6022 | * <li>{@link #PROTOCOL_YAHOO}</li> |
| 6023 | * <li>{@link #PROTOCOL_SKYPE}</li> |
| 6024 | * <li>{@link #PROTOCOL_QQ}</li> |
| 6025 | * <li>{@link #PROTOCOL_GOOGLE_TALK}</li> |
| 6026 | * <li>{@link #PROTOCOL_ICQ}</li> |
| 6027 | * <li>{@link #PROTOCOL_JABBER}</li> |
| 6028 | * <li>{@link #PROTOCOL_NETMEETING}</li> |
| 6029 | * </ul> |
| 6030 | * </p> |
| 6031 | * </td> |
| 6032 | * </tr> |
| 6033 | * <tr> |
| 6034 | * <td>String</td> |
| 6035 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 6036 | * <td>{@link #DATA6}</td> |
| 6037 | * <td></td> |
| 6038 | * </tr> |
| 6039 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6040 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6041 | public static final class Im implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6042 | /** |
| 6043 | * This utility class cannot be instantiated |
| 6044 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6045 | private Im() {} |
| 6046 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6047 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6048 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; |
| 6049 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6050 | public static final int TYPE_HOME = 1; |
| 6051 | public static final int TYPE_WORK = 2; |
| 6052 | public static final int TYPE_OTHER = 3; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6053 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 6054 | /** |
| 6055 | * This column should be populated with one of the defined |
| 6056 | * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this |
| 6057 | * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL} |
| 6058 | * should contain the name of the custom protocol. |
| 6059 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6060 | public static final String PROTOCOL = DATA5; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6061 | |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6062 | public static final String CUSTOM_PROTOCOL = DATA6; |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 6063 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 6064 | /* |
| 6065 | * The predefined IM protocol types. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6066 | */ |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 6067 | public static final int PROTOCOL_CUSTOM = -1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6068 | public static final int PROTOCOL_AIM = 0; |
| 6069 | public static final int PROTOCOL_MSN = 1; |
| 6070 | public static final int PROTOCOL_YAHOO = 2; |
| 6071 | public static final int PROTOCOL_SKYPE = 3; |
| 6072 | public static final int PROTOCOL_QQ = 4; |
| 6073 | public static final int PROTOCOL_GOOGLE_TALK = 5; |
| 6074 | public static final int PROTOCOL_ICQ = 6; |
| 6075 | public static final int PROTOCOL_JABBER = 7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6076 | public static final int PROTOCOL_NETMEETING = 8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6077 | |
| 6078 | /** |
| 6079 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6080 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6081 | */ |
| 6082 | public static final int getTypeLabelResource(int type) { |
| 6083 | switch (type) { |
| 6084 | case TYPE_HOME: return com.android.internal.R.string.imTypeHome; |
| 6085 | case TYPE_WORK: return com.android.internal.R.string.imTypeWork; |
| 6086 | case TYPE_OTHER: return com.android.internal.R.string.imTypeOther; |
| 6087 | default: return com.android.internal.R.string.imTypeCustom; |
| 6088 | } |
| 6089 | } |
| 6090 | |
| 6091 | /** |
| 6092 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6093 | * possibly substituting the given {@link #LABEL} value |
| 6094 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6095 | */ |
| 6096 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6097 | CharSequence label) { |
| 6098 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6099 | return label; |
| 6100 | } else { |
| 6101 | final int labelRes = getTypeLabelResource(type); |
| 6102 | return res.getText(labelRes); |
| 6103 | } |
| 6104 | } |
| 6105 | |
| 6106 | /** |
| 6107 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6108 | * {@link #PROTOCOL}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6109 | */ |
| 6110 | public static final int getProtocolLabelResource(int type) { |
| 6111 | switch (type) { |
| 6112 | case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim; |
| 6113 | case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn; |
| 6114 | case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo; |
| 6115 | case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype; |
| 6116 | case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq; |
| 6117 | case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk; |
| 6118 | case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq; |
| 6119 | case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber; |
| 6120 | case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting; |
| 6121 | default: return com.android.internal.R.string.imProtocolCustom; |
| 6122 | } |
| 6123 | } |
| 6124 | |
| 6125 | /** |
| 6126 | * Return a {@link CharSequence} that best describes the given |
| 6127 | * protocol, possibly substituting the given |
| 6128 | * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}. |
| 6129 | */ |
| 6130 | public static final CharSequence getProtocolLabel(Resources res, int type, |
| 6131 | CharSequence label) { |
| 6132 | if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6133 | return label; |
| 6134 | } else { |
| 6135 | final int labelRes = getProtocolLabelResource(type); |
| 6136 | return res.getText(labelRes); |
| 6137 | } |
| 6138 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6139 | } |
| 6140 | |
| 6141 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6142 | * <p> |
| 6143 | * A data kind representing an organization. |
| 6144 | * </p> |
| 6145 | * <p> |
| 6146 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6147 | * well as the following aliases. |
| 6148 | * </p> |
| 6149 | * <h2>Column aliases</h2> |
| 6150 | * <table class="jd-sumtable"> |
| 6151 | * <tr> |
| 6152 | * <th>Type</th> |
| 6153 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6154 | * </tr> |
| 6155 | * <tr> |
| 6156 | * <td>String</td> |
| 6157 | * <td>{@link #COMPANY}</td> |
| 6158 | * <td>{@link #DATA1}</td> |
| 6159 | * <td></td> |
| 6160 | * </tr> |
| 6161 | * <tr> |
| 6162 | * <td>int</td> |
| 6163 | * <td>{@link #TYPE}</td> |
| 6164 | * <td>{@link #DATA2}</td> |
| 6165 | * <td>Allowed values are: |
| 6166 | * <p> |
| 6167 | * <ul> |
| 6168 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6169 | * <li>{@link #TYPE_WORK}</li> |
| 6170 | * <li>{@link #TYPE_OTHER}</li> |
| 6171 | * </ul> |
| 6172 | * </p> |
| 6173 | * </td> |
| 6174 | * </tr> |
| 6175 | * <tr> |
| 6176 | * <td>String</td> |
| 6177 | * <td>{@link #LABEL}</td> |
| 6178 | * <td>{@link #DATA3}</td> |
| 6179 | * <td></td> |
| 6180 | * </tr> |
| 6181 | * <tr> |
| 6182 | * <td>String</td> |
| 6183 | * <td>{@link #TITLE}</td> |
| 6184 | * <td>{@link #DATA4}</td> |
| 6185 | * <td></td> |
| 6186 | * </tr> |
| 6187 | * <tr> |
| 6188 | * <td>String</td> |
| 6189 | * <td>{@link #DEPARTMENT}</td> |
| 6190 | * <td>{@link #DATA5}</td> |
| 6191 | * <td></td> |
| 6192 | * </tr> |
| 6193 | * <tr> |
| 6194 | * <td>String</td> |
| 6195 | * <td>{@link #JOB_DESCRIPTION}</td> |
| 6196 | * <td>{@link #DATA6}</td> |
| 6197 | * <td></td> |
| 6198 | * </tr> |
| 6199 | * <tr> |
| 6200 | * <td>String</td> |
| 6201 | * <td>{@link #SYMBOL}</td> |
| 6202 | * <td>{@link #DATA7}</td> |
| 6203 | * <td></td> |
| 6204 | * </tr> |
| 6205 | * <tr> |
| 6206 | * <td>String</td> |
| 6207 | * <td>{@link #PHONETIC_NAME}</td> |
| 6208 | * <td>{@link #DATA8}</td> |
| 6209 | * <td></td> |
| 6210 | * </tr> |
| 6211 | * <tr> |
| 6212 | * <td>String</td> |
| 6213 | * <td>{@link #OFFICE_LOCATION}</td> |
| 6214 | * <td>{@link #DATA9}</td> |
| 6215 | * <td></td> |
| 6216 | * </tr> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 6217 | * <tr> |
| 6218 | * <td>String</td> |
| 6219 | * <td>PHONETIC_NAME_STYLE</td> |
| 6220 | * <td>{@link #DATA10}</td> |
| 6221 | * <td></td> |
| 6222 | * </tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6223 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6224 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6225 | public static final class Organization implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6226 | /** |
| 6227 | * This utility class cannot be instantiated |
| 6228 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6229 | private Organization() {} |
| 6230 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6231 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6232 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; |
| 6233 | |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6234 | public static final int TYPE_WORK = 1; |
| 6235 | public static final int TYPE_OTHER = 2; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6236 | |
| 6237 | /** |
| 6238 | * The company as the user entered it. |
| 6239 | * <P>Type: TEXT</P> |
| 6240 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6241 | public static final String COMPANY = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6242 | |
| 6243 | /** |
| 6244 | * The position title at this company as the user entered it. |
| 6245 | * <P>Type: TEXT</P> |
| 6246 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6247 | public static final String TITLE = DATA4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6248 | |
| 6249 | /** |
| 6250 | * The department at this company as the user entered it. |
| 6251 | * <P>Type: TEXT</P> |
| 6252 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6253 | public static final String DEPARTMENT = DATA5; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6254 | |
| 6255 | /** |
| 6256 | * The job description at this company as the user entered it. |
| 6257 | * <P>Type: TEXT</P> |
| 6258 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6259 | public static final String JOB_DESCRIPTION = DATA6; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6260 | |
| 6261 | /** |
| 6262 | * The symbol of this company as the user entered it. |
| 6263 | * <P>Type: TEXT</P> |
| 6264 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6265 | public static final String SYMBOL = DATA7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6266 | |
| 6267 | /** |
| 6268 | * The phonetic name of this company as the user entered it. |
| 6269 | * <P>Type: TEXT</P> |
| 6270 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6271 | public static final String PHONETIC_NAME = DATA8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6272 | |
| 6273 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 6274 | * The office location of this organization. |
| 6275 | * <P>Type: TEXT</P> |
| 6276 | */ |
| 6277 | public static final String OFFICE_LOCATION = DATA9; |
| 6278 | |
| 6279 | /** |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 6280 | * The alphabet used for capturing the phonetic name. |
| 6281 | * See {@link ContactsContract.PhoneticNameStyle}. |
| 6282 | * @hide |
| 6283 | */ |
| 6284 | public static final String PHONETIC_NAME_STYLE = DATA10; |
| 6285 | |
| 6286 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6287 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6288 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6289 | */ |
| 6290 | public static final int getTypeLabelResource(int type) { |
| 6291 | switch (type) { |
| 6292 | case TYPE_WORK: return com.android.internal.R.string.orgTypeWork; |
| 6293 | case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther; |
| 6294 | default: return com.android.internal.R.string.orgTypeCustom; |
| 6295 | } |
| 6296 | } |
| 6297 | |
| 6298 | /** |
| 6299 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6300 | * possibly substituting the given {@link #LABEL} value |
| 6301 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6302 | */ |
| 6303 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6304 | CharSequence label) { |
| 6305 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6306 | return label; |
| 6307 | } else { |
| 6308 | final int labelRes = getTypeLabelResource(type); |
| 6309 | return res.getText(labelRes); |
| 6310 | } |
| 6311 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6312 | } |
| 6313 | |
| 6314 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6315 | * <p> |
| 6316 | * A data kind representing a relation. |
| 6317 | * </p> |
| 6318 | * <p> |
| 6319 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6320 | * well as the following aliases. |
| 6321 | * </p> |
| 6322 | * <h2>Column aliases</h2> |
| 6323 | * <table class="jd-sumtable"> |
| 6324 | * <tr> |
| 6325 | * <th>Type</th> |
| 6326 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6327 | * </tr> |
| 6328 | * <tr> |
| 6329 | * <td>String</td> |
| 6330 | * <td>{@link #NAME}</td> |
| 6331 | * <td>{@link #DATA1}</td> |
| 6332 | * <td></td> |
| 6333 | * </tr> |
| 6334 | * <tr> |
| 6335 | * <td>int</td> |
| 6336 | * <td>{@link #TYPE}</td> |
| 6337 | * <td>{@link #DATA2}</td> |
| 6338 | * <td>Allowed values are: |
| 6339 | * <p> |
| 6340 | * <ul> |
| 6341 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6342 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 6343 | * <li>{@link #TYPE_BROTHER}</li> |
| 6344 | * <li>{@link #TYPE_CHILD}</li> |
| 6345 | * <li>{@link #TYPE_DOMESTIC_PARTNER}</li> |
| 6346 | * <li>{@link #TYPE_FATHER}</li> |
| 6347 | * <li>{@link #TYPE_FRIEND}</li> |
| 6348 | * <li>{@link #TYPE_MANAGER}</li> |
| 6349 | * <li>{@link #TYPE_MOTHER}</li> |
| 6350 | * <li>{@link #TYPE_PARENT}</li> |
| 6351 | * <li>{@link #TYPE_PARTNER}</li> |
| 6352 | * <li>{@link #TYPE_REFERRED_BY}</li> |
| 6353 | * <li>{@link #TYPE_RELATIVE}</li> |
| 6354 | * <li>{@link #TYPE_SISTER}</li> |
| 6355 | * <li>{@link #TYPE_SPOUSE}</li> |
| 6356 | * </ul> |
| 6357 | * </p> |
| 6358 | * </td> |
| 6359 | * </tr> |
| 6360 | * <tr> |
| 6361 | * <td>String</td> |
| 6362 | * <td>{@link #LABEL}</td> |
| 6363 | * <td>{@link #DATA3}</td> |
| 6364 | * <td></td> |
| 6365 | * </tr> |
| 6366 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6367 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6368 | public static final class Relation implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6369 | /** |
| 6370 | * This utility class cannot be instantiated |
| 6371 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6372 | private Relation() {} |
| 6373 | |
| 6374 | /** MIME type used when storing this in data table. */ |
| 6375 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; |
| 6376 | |
| 6377 | public static final int TYPE_ASSISTANT = 1; |
| 6378 | public static final int TYPE_BROTHER = 2; |
| 6379 | public static final int TYPE_CHILD = 3; |
| 6380 | public static final int TYPE_DOMESTIC_PARTNER = 4; |
| 6381 | public static final int TYPE_FATHER = 5; |
| 6382 | public static final int TYPE_FRIEND = 6; |
| 6383 | public static final int TYPE_MANAGER = 7; |
| 6384 | public static final int TYPE_MOTHER = 8; |
| 6385 | public static final int TYPE_PARENT = 9; |
| 6386 | public static final int TYPE_PARTNER = 10; |
| 6387 | public static final int TYPE_REFERRED_BY = 11; |
| 6388 | public static final int TYPE_RELATIVE = 12; |
| 6389 | public static final int TYPE_SISTER = 13; |
| 6390 | public static final int TYPE_SPOUSE = 14; |
| 6391 | |
| 6392 | /** |
| 6393 | * The name of the relative as the user entered it. |
| 6394 | * <P>Type: TEXT</P> |
| 6395 | */ |
| 6396 | public static final String NAME = DATA; |
Daniel Lehmann | 1fb39f0 | 2010-10-28 13:40:38 -0700 | [diff] [blame] | 6397 | |
| 6398 | /** |
| 6399 | * Return the string resource that best describes the given |
| 6400 | * {@link #TYPE}. Will always return a valid resource. |
| 6401 | */ |
| 6402 | public static final int getTypeLabelResource(int type) { |
| 6403 | switch (type) { |
| 6404 | case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant; |
| 6405 | case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother; |
| 6406 | case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild; |
| 6407 | case TYPE_DOMESTIC_PARTNER: |
| 6408 | return com.android.internal.R.string.relationTypeDomesticPartner; |
| 6409 | case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather; |
| 6410 | case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend; |
| 6411 | case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager; |
| 6412 | case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother; |
| 6413 | case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent; |
| 6414 | case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner; |
| 6415 | case TYPE_REFERRED_BY: |
| 6416 | return com.android.internal.R.string.relationTypeReferredBy; |
| 6417 | case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative; |
| 6418 | case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister; |
| 6419 | case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse; |
| 6420 | default: return com.android.internal.R.string.orgTypeCustom; |
| 6421 | } |
| 6422 | } |
| 6423 | |
| 6424 | /** |
| 6425 | * Return a {@link CharSequence} that best describes the given type, |
| 6426 | * possibly substituting the given {@link #LABEL} value |
| 6427 | * for {@link #TYPE_CUSTOM}. |
| 6428 | */ |
| 6429 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6430 | CharSequence label) { |
| 6431 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6432 | return label; |
| 6433 | } else { |
| 6434 | final int labelRes = getTypeLabelResource(type); |
| 6435 | return res.getText(labelRes); |
| 6436 | } |
| 6437 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6438 | } |
| 6439 | |
| 6440 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6441 | * <p> |
| 6442 | * A data kind representing an event. |
| 6443 | * </p> |
| 6444 | * <p> |
| 6445 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6446 | * well as the following aliases. |
| 6447 | * </p> |
| 6448 | * <h2>Column aliases</h2> |
| 6449 | * <table class="jd-sumtable"> |
| 6450 | * <tr> |
| 6451 | * <th>Type</th> |
| 6452 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6453 | * </tr> |
| 6454 | * <tr> |
| 6455 | * <td>String</td> |
| 6456 | * <td>{@link #START_DATE}</td> |
| 6457 | * <td>{@link #DATA1}</td> |
| 6458 | * <td></td> |
| 6459 | * </tr> |
| 6460 | * <tr> |
| 6461 | * <td>int</td> |
| 6462 | * <td>{@link #TYPE}</td> |
| 6463 | * <td>{@link #DATA2}</td> |
| 6464 | * <td>Allowed values are: |
| 6465 | * <p> |
| 6466 | * <ul> |
| 6467 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6468 | * <li>{@link #TYPE_ANNIVERSARY}</li> |
| 6469 | * <li>{@link #TYPE_OTHER}</li> |
| 6470 | * <li>{@link #TYPE_BIRTHDAY}</li> |
| 6471 | * </ul> |
| 6472 | * </p> |
| 6473 | * </td> |
| 6474 | * </tr> |
| 6475 | * <tr> |
| 6476 | * <td>String</td> |
| 6477 | * <td>{@link #LABEL}</td> |
| 6478 | * <td>{@link #DATA3}</td> |
| 6479 | * <td></td> |
| 6480 | * </tr> |
| 6481 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6482 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6483 | public static final class Event implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6484 | /** |
| 6485 | * This utility class cannot be instantiated |
| 6486 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6487 | private Event() {} |
| 6488 | |
| 6489 | /** MIME type used when storing this in data table. */ |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6490 | 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] | 6491 | |
| 6492 | public static final int TYPE_ANNIVERSARY = 1; |
| 6493 | public static final int TYPE_OTHER = 2; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6494 | public static final int TYPE_BIRTHDAY = 3; |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6495 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6496 | /** |
| 6497 | * The event start date as the user entered it. |
| 6498 | * <P>Type: TEXT</P> |
| 6499 | */ |
| 6500 | public static final String START_DATE = DATA; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6501 | |
| 6502 | /** |
| 6503 | * Return the string resource that best describes the given |
| 6504 | * {@link #TYPE}. Will always return a valid resource. |
| 6505 | */ |
| 6506 | public static int getTypeResource(Integer type) { |
| 6507 | if (type == null) { |
| 6508 | return com.android.internal.R.string.eventTypeOther; |
| 6509 | } |
| 6510 | switch (type) { |
| 6511 | case TYPE_ANNIVERSARY: |
| 6512 | return com.android.internal.R.string.eventTypeAnniversary; |
| 6513 | case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday; |
| 6514 | case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther; |
Daniel Lehmann | dd384a7 | 2010-11-01 18:40:50 -0700 | [diff] [blame] | 6515 | default: return com.android.internal.R.string.eventTypeCustom; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6516 | } |
| 6517 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6518 | } |
| 6519 | |
| 6520 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6521 | * <p> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6522 | * A data kind representing a photo for the contact. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6523 | * </p> |
| 6524 | * <p> |
| 6525 | * Some sync adapters will choose to download photos in a separate |
| 6526 | * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1} |
| 6527 | * through {@link ContactsContract.Data#SYNC4} to store temporary |
| 6528 | * data, e.g. the image URL or ID, state of download, server-side version |
| 6529 | * of the image. It is allowed for the {@link #PHOTO} to be null. |
| 6530 | * </p> |
| 6531 | * <p> |
| 6532 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6533 | * well as the following aliases. |
| 6534 | * </p> |
| 6535 | * <h2>Column aliases</h2> |
| 6536 | * <table class="jd-sumtable"> |
| 6537 | * <tr> |
| 6538 | * <th>Type</th> |
| 6539 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6540 | * </tr> |
| 6541 | * <tr> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6542 | * <td>NUMBER</td> |
| 6543 | * <td>{@link #PHOTO_FILE_ID}</td> |
| 6544 | * <td>{@link #DATA14}</td> |
| 6545 | * <td>ID of the hi-res photo file.</td> |
| 6546 | * </tr> |
| 6547 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6548 | * <td>BLOB</td> |
| 6549 | * <td>{@link #PHOTO}</td> |
| 6550 | * <td>{@link #DATA15}</td> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6551 | * <td>By convention, binary data is stored in DATA15. The thumbnail of the |
| 6552 | * photo is stored in this column.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6553 | * </tr> |
| 6554 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6555 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6556 | public static final class Photo implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6557 | /** |
| 6558 | * This utility class cannot be instantiated |
| 6559 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6560 | private Photo() {} |
| 6561 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6562 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6563 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; |
| 6564 | |
| 6565 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6566 | * Photo file ID for the display photo of the raw contact. |
| 6567 | * See {@link ContactsContract.DisplayPhoto}. |
| 6568 | * <p> |
| 6569 | * Type: NUMBER |
| 6570 | */ |
| 6571 | public static final String PHOTO_FILE_ID = DATA14; |
| 6572 | |
| 6573 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 6574 | * 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] | 6575 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6576 | * <p> |
| 6577 | * Type: BLOB |
| 6578 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6579 | public static final String PHOTO = DATA15; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6580 | } |
| 6581 | |
| 6582 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6583 | * <p> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6584 | * Notes about the contact. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6585 | * </p> |
| 6586 | * <p> |
| 6587 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6588 | * well as the following aliases. |
| 6589 | * </p> |
| 6590 | * <h2>Column aliases</h2> |
| 6591 | * <table class="jd-sumtable"> |
| 6592 | * <tr> |
| 6593 | * <th>Type</th> |
| 6594 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6595 | * </tr> |
| 6596 | * <tr> |
| 6597 | * <td>String</td> |
| 6598 | * <td>{@link #NOTE}</td> |
| 6599 | * <td>{@link #DATA1}</td> |
| 6600 | * <td></td> |
| 6601 | * </tr> |
| 6602 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6603 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6604 | public static final class Note implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6605 | /** |
| 6606 | * This utility class cannot be instantiated |
| 6607 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6608 | private Note() {} |
| 6609 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6610 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6611 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; |
| 6612 | |
| 6613 | /** |
| 6614 | * The note text. |
| 6615 | * <P>Type: TEXT</P> |
| 6616 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6617 | public static final String NOTE = DATA1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6618 | } |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6619 | |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 6620 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6621 | * <p> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6622 | * Group Membership. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6623 | * </p> |
| 6624 | * <p> |
| 6625 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6626 | * well as the following aliases. |
| 6627 | * </p> |
| 6628 | * <h2>Column aliases</h2> |
| 6629 | * <table class="jd-sumtable"> |
| 6630 | * <tr> |
| 6631 | * <th>Type</th> |
| 6632 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6633 | * </tr> |
| 6634 | * <tr> |
| 6635 | * <td>long</td> |
| 6636 | * <td>{@link #GROUP_ROW_ID}</td> |
| 6637 | * <td>{@link #DATA1}</td> |
| 6638 | * <td></td> |
| 6639 | * </tr> |
| 6640 | * <tr> |
| 6641 | * <td>String</td> |
| 6642 | * <td>{@link #GROUP_SOURCE_ID}</td> |
| 6643 | * <td>none</td> |
| 6644 | * <td> |
| 6645 | * <p> |
| 6646 | * The sourceid of the group that this group membership refers to. |
| 6647 | * Exactly one of this or {@link #GROUP_ROW_ID} must be set when |
| 6648 | * inserting a row. |
| 6649 | * </p> |
| 6650 | * <p> |
| 6651 | * If this field is specified, the provider will first try to |
| 6652 | * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group |
| 6653 | * is found, it will use the corresponding row id. If the group is not |
| 6654 | * found, it will create one. |
| 6655 | * </td> |
| 6656 | * </tr> |
| 6657 | * </table> |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 6658 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6659 | public static final class GroupMembership implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6660 | /** |
| 6661 | * This utility class cannot be instantiated |
| 6662 | */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6663 | private GroupMembership() {} |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 6664 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6665 | /** MIME type used when storing this in data table. */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6666 | public static final String CONTENT_ITEM_TYPE = |
| 6667 | "vnd.android.cursor.item/group_membership"; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 6668 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6669 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 6670 | * The row id of the group that this group membership refers to. Exactly one of |
| 6671 | * 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] | 6672 | * <P>Type: INTEGER</P> |
| 6673 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6674 | public static final String GROUP_ROW_ID = DATA1; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 6675 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6676 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 6677 | * The sourceid of the group that this group membership refers to. Exactly one of |
| 6678 | * 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] | 6679 | * <P>Type: TEXT</P> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6680 | */ |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 6681 | public static final String GROUP_SOURCE_ID = "group_sourceid"; |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6682 | } |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6683 | |
| 6684 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6685 | * <p> |
| 6686 | * A data kind representing a website related to the contact. |
| 6687 | * </p> |
| 6688 | * <p> |
| 6689 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6690 | * well as the following aliases. |
| 6691 | * </p> |
| 6692 | * <h2>Column aliases</h2> |
| 6693 | * <table class="jd-sumtable"> |
| 6694 | * <tr> |
| 6695 | * <th>Type</th> |
| 6696 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6697 | * </tr> |
| 6698 | * <tr> |
| 6699 | * <td>String</td> |
| 6700 | * <td>{@link #URL}</td> |
| 6701 | * <td>{@link #DATA1}</td> |
| 6702 | * <td></td> |
| 6703 | * </tr> |
| 6704 | * <tr> |
| 6705 | * <td>int</td> |
| 6706 | * <td>{@link #TYPE}</td> |
| 6707 | * <td>{@link #DATA2}</td> |
| 6708 | * <td>Allowed values are: |
| 6709 | * <p> |
| 6710 | * <ul> |
| 6711 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6712 | * <li>{@link #TYPE_HOMEPAGE}</li> |
| 6713 | * <li>{@link #TYPE_BLOG}</li> |
| 6714 | * <li>{@link #TYPE_PROFILE}</li> |
| 6715 | * <li>{@link #TYPE_HOME}</li> |
| 6716 | * <li>{@link #TYPE_WORK}</li> |
| 6717 | * <li>{@link #TYPE_FTP}</li> |
| 6718 | * <li>{@link #TYPE_OTHER}</li> |
| 6719 | * </ul> |
| 6720 | * </p> |
| 6721 | * </td> |
| 6722 | * </tr> |
| 6723 | * <tr> |
| 6724 | * <td>String</td> |
| 6725 | * <td>{@link #LABEL}</td> |
| 6726 | * <td>{@link #DATA3}</td> |
| 6727 | * <td></td> |
| 6728 | * </tr> |
| 6729 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6730 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6731 | public static final class Website implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6732 | /** |
| 6733 | * This utility class cannot be instantiated |
| 6734 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6735 | private Website() {} |
| 6736 | |
| 6737 | /** MIME type used when storing this in data table. */ |
| 6738 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; |
| 6739 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6740 | public static final int TYPE_HOMEPAGE = 1; |
| 6741 | public static final int TYPE_BLOG = 2; |
| 6742 | public static final int TYPE_PROFILE = 3; |
| 6743 | public static final int TYPE_HOME = 4; |
| 6744 | public static final int TYPE_WORK = 5; |
| 6745 | public static final int TYPE_FTP = 6; |
| 6746 | public static final int TYPE_OTHER = 7; |
| 6747 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6748 | /** |
| 6749 | * The website URL string. |
| 6750 | * <P>Type: TEXT</P> |
| 6751 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6752 | public static final String URL = DATA; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6753 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 6754 | |
| 6755 | /** |
| 6756 | * <p> |
| 6757 | * A data kind representing a SIP address for the contact. |
| 6758 | * </p> |
| 6759 | * <p> |
| 6760 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6761 | * well as the following aliases. |
| 6762 | * </p> |
| 6763 | * <h2>Column aliases</h2> |
| 6764 | * <table class="jd-sumtable"> |
| 6765 | * <tr> |
| 6766 | * <th>Type</th> |
| 6767 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6768 | * </tr> |
| 6769 | * <tr> |
| 6770 | * <td>String</td> |
| 6771 | * <td>{@link #SIP_ADDRESS}</td> |
| 6772 | * <td>{@link #DATA1}</td> |
| 6773 | * <td></td> |
| 6774 | * </tr> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 6775 | * <tr> |
| 6776 | * <td>int</td> |
| 6777 | * <td>{@link #TYPE}</td> |
| 6778 | * <td>{@link #DATA2}</td> |
| 6779 | * <td>Allowed values are: |
| 6780 | * <p> |
| 6781 | * <ul> |
| 6782 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6783 | * <li>{@link #TYPE_HOME}</li> |
| 6784 | * <li>{@link #TYPE_WORK}</li> |
| 6785 | * <li>{@link #TYPE_OTHER}</li> |
| 6786 | * </ul> |
| 6787 | * </p> |
| 6788 | * </td> |
| 6789 | * </tr> |
| 6790 | * <tr> |
| 6791 | * <td>String</td> |
| 6792 | * <td>{@link #LABEL}</td> |
| 6793 | * <td>{@link #DATA3}</td> |
| 6794 | * <td></td> |
| 6795 | * </tr> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 6796 | * </table> |
| 6797 | */ |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 6798 | public static final class SipAddress implements DataColumnsWithJoins, CommonColumns { |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 6799 | /** |
| 6800 | * This utility class cannot be instantiated |
| 6801 | */ |
| 6802 | private SipAddress() {} |
| 6803 | |
| 6804 | /** MIME type used when storing this in data table. */ |
| 6805 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address"; |
| 6806 | |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 6807 | public static final int TYPE_HOME = 1; |
| 6808 | public static final int TYPE_WORK = 2; |
| 6809 | public static final int TYPE_OTHER = 3; |
| 6810 | |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 6811 | /** |
| 6812 | * The SIP address. |
| 6813 | * <P>Type: TEXT</P> |
| 6814 | */ |
| 6815 | public static final String SIP_ADDRESS = DATA1; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 6816 | // ...and TYPE and LABEL come from the CommonColumns interface. |
| 6817 | |
| 6818 | /** |
| 6819 | * Return the string resource that best describes the given |
| 6820 | * {@link #TYPE}. Will always return a valid resource. |
| 6821 | */ |
| 6822 | public static final int getTypeLabelResource(int type) { |
| 6823 | switch (type) { |
| 6824 | case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome; |
| 6825 | case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork; |
| 6826 | case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther; |
| 6827 | default: return com.android.internal.R.string.sipAddressTypeCustom; |
| 6828 | } |
| 6829 | } |
| 6830 | |
| 6831 | /** |
| 6832 | * Return a {@link CharSequence} that best describes the given type, |
| 6833 | * possibly substituting the given {@link #LABEL} value |
| 6834 | * for {@link #TYPE_CUSTOM}. |
| 6835 | */ |
| 6836 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6837 | CharSequence label) { |
| 6838 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6839 | return label; |
| 6840 | } else { |
| 6841 | final int labelRes = getTypeLabelResource(type); |
| 6842 | return res.getText(labelRes); |
| 6843 | } |
| 6844 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 6845 | } |
Fred Quintana | 4923f1d | 2011-08-05 15:58:17 -0700 | [diff] [blame] | 6846 | |
| 6847 | /** |
| 6848 | * A data kind representing an Identity related to the contact. |
| 6849 | * <p> |
| 6850 | * This can be used as a signal by the aggregator to combine raw contacts into |
| 6851 | * contacts, e.g. if two contacts have Identity rows with |
| 6852 | * the same NAMESPACE and IDENTITY values the aggregator can know that they refer |
| 6853 | * to the same person. |
| 6854 | * </p> |
| 6855 | */ |
| 6856 | public static final class Identity implements DataColumnsWithJoins { |
| 6857 | /** |
| 6858 | * This utility class cannot be instantiated |
| 6859 | */ |
| 6860 | private Identity() {} |
| 6861 | |
| 6862 | /** MIME type used when storing this in data table. */ |
| 6863 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity"; |
| 6864 | |
| 6865 | /** |
| 6866 | * The identity string. |
| 6867 | * <P>Type: TEXT</P> |
| 6868 | */ |
| 6869 | public static final String IDENTITY = DataColumns.DATA1; |
| 6870 | |
| 6871 | /** |
| 6872 | * The namespace of the identity string, e.g. "com.google" |
| 6873 | * <P>Type: TEXT</P> |
| 6874 | */ |
| 6875 | public static final String NAMESPACE = DataColumns.DATA2; |
| 6876 | } |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 6877 | |
| 6878 | /** |
| 6879 | * <p> |
| 6880 | * Convenient functionalities for "callable" data. Note that, this is NOT a separate data |
| 6881 | * kind. |
| 6882 | * </p> |
| 6883 | * <p> |
| 6884 | * This URI allows the ContactsProvider to return a unified result for "callable" data |
| 6885 | * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the |
| 6886 | * current examples for "callable", but may be expanded to the other types. |
| 6887 | * </p> |
| 6888 | * <p> |
| 6889 | * Each returned row may have a different MIMETYPE and thus different interpretation for |
| 6890 | * each column. For example the meaning for {@link Phone}'s type is different than |
| 6891 | * {@link SipAddress}'s. |
| 6892 | * </p> |
| 6893 | * |
| 6894 | * @hide |
| 6895 | */ |
| 6896 | public static final class Callable implements DataColumnsWithJoins, CommonColumns { |
| 6897 | /** |
| 6898 | * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only |
| 6899 | * phone numbers. |
| 6900 | */ |
| 6901 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6902 | "callables"); |
| 6903 | /** |
| 6904 | * Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable |
| 6905 | * data. |
| 6906 | */ |
| 6907 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 6908 | "filter"); |
| 6909 | } |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 6910 | |
| 6911 | /** |
| 6912 | * A special class of data items, used to refer to types of data that can be used to attempt |
| 6913 | * to start communicating with a person ({@link Phone} and {@link Email}). Note that this |
| 6914 | * is NOT a separate data kind. |
| 6915 | * |
| 6916 | * This URI allows the ContactsProvider to return a unified result for data items that users |
| 6917 | * can use to initiate communications with another contact. {@link Phone} and {@link Email} |
| 6918 | * are the current data types in this category. |
| 6919 | */ |
| 6920 | public static final class Contactables implements DataColumnsWithJoins, CommonColumns { |
| 6921 | /** |
| 6922 | * The content:// style URI for these data items, which requests a directory of data |
| 6923 | * rows matching the selection criteria. |
| 6924 | */ |
| 6925 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6926 | "contactables"); |
| 6927 | |
| 6928 | /** |
| 6929 | * The content:// style URI for these data items, which allows for a query parameter to |
| 6930 | * be appended onto the end to filter for data items matching the query. |
| 6931 | */ |
| 6932 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 6933 | Contactables.CONTENT_URI, "filter"); |
| 6934 | |
| 6935 | /** |
| 6936 | * A boolean parameter for {@link Data#CONTENT_URI}. |
| 6937 | * This specifies whether or not the returned data items should be filtered to show |
| 6938 | * data items belonging to visible contacts only. |
| 6939 | */ |
| 6940 | public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; |
| 6941 | } |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 6942 | } |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 6943 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6944 | /** |
| 6945 | * @see Groups |
| 6946 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 6947 | protected interface GroupsColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 6948 | /** |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 6949 | * The data set within the account that this group belongs to. This allows |
| 6950 | * multiple sync adapters for the same account type to distinguish between |
| 6951 | * each others' group data. |
| 6952 | * |
| 6953 | * This is empty by default, and is completely optional. It only needs to |
| 6954 | * be populated if multiple sync adapters are entering distinct group data |
| 6955 | * for the same account type and account name. |
| 6956 | * <P>Type: TEXT</P> |
| 6957 | */ |
| 6958 | public static final String DATA_SET = "data_set"; |
| 6959 | |
| 6960 | /** |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 6961 | * A concatenation of the account type and data set (delimited by a forward |
| 6962 | * slash) - if the data set is empty, this will be the same as the account |
| 6963 | * type. For applications that need to be aware of the data set, this can |
| 6964 | * be used instead of account type to distinguish sets of data. This is |
| 6965 | * never intended to be used for specifying accounts. |
| 6966 | * @hide |
| 6967 | */ |
| 6968 | public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; |
| 6969 | |
| 6970 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 6971 | * The display title of this group. |
| 6972 | * <p> |
| 6973 | * Type: TEXT |
| 6974 | */ |
| 6975 | public static final String TITLE = "title"; |
| 6976 | |
| 6977 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6978 | * The package name to use when creating {@link Resources} objects for |
| 6979 | * this group. This value is only designed for use when building user |
| 6980 | * interfaces, and should not be used to infer the owner. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6981 | * |
| 6982 | * @hide |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 6983 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6984 | public static final String RES_PACKAGE = "res_package"; |
| 6985 | |
| 6986 | /** |
| 6987 | * The display title of this group to load as a resource from |
| 6988 | * {@link #RES_PACKAGE}, which may be localized. |
| 6989 | * <P>Type: TEXT</P> |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6990 | * |
| 6991 | * @hide |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6992 | */ |
| 6993 | public static final String TITLE_RES = "title_res"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 6994 | |
| 6995 | /** |
Dmitri Plotnikov | 02c5b45 | 2009-07-22 15:13:08 -0700 | [diff] [blame] | 6996 | * Notes about the group. |
| 6997 | * <p> |
| 6998 | * Type: TEXT |
| 6999 | */ |
| 7000 | public static final String NOTES = "notes"; |
| 7001 | |
| 7002 | /** |
| 7003 | * The ID of this group if it is a System Group, i.e. a group that has a special meaning |
| 7004 | * to the sync adapter, null otherwise. |
| 7005 | * <P>Type: TEXT</P> |
| 7006 | */ |
| 7007 | public static final String SYSTEM_ID = "system_id"; |
| 7008 | |
| 7009 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7010 | * The total number of {@link Contacts} that have |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7011 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7012 | * present when querying {@link Groups#CONTENT_SUMMARY_URI}. |
| 7013 | * <p> |
| 7014 | * Type: INTEGER |
| 7015 | */ |
| 7016 | public static final String SUMMARY_COUNT = "summ_count"; |
| 7017 | |
| 7018 | /** |
Daisuke Miyakawa | 15dec39 | 2011-07-23 11:39:23 -0700 | [diff] [blame] | 7019 | * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}. |
| 7020 | * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}. |
| 7021 | * |
| 7022 | * @hide |
| 7023 | */ |
| 7024 | public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT = |
| 7025 | "return_group_count_per_account"; |
| 7026 | |
| 7027 | /** |
| 7028 | * The total number of groups of the account that a group belongs to. |
| 7029 | * This column is available only when the parameter |
| 7030 | * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in |
| 7031 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 7032 | * |
| 7033 | * For example, when the account "A" has two groups "group1" and "group2", and the account |
| 7034 | * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for |
| 7035 | * "group3" returns "1" for this column. |
| 7036 | * |
| 7037 | * Note: This counts only non-favorites, non-auto-add, and not deleted groups. |
| 7038 | * |
| 7039 | * Type: INTEGER |
| 7040 | * @hide |
| 7041 | */ |
| 7042 | public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account"; |
| 7043 | |
| 7044 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7045 | * The total number of {@link Contacts} that have both |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7046 | * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7047 | * Read-only value that is only present when querying |
| 7048 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 7049 | * <p> |
| 7050 | * Type: INTEGER |
| 7051 | */ |
| 7052 | public static final String SUMMARY_WITH_PHONES = "summ_phones"; |
| 7053 | |
| 7054 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7055 | * Flag indicating if the contacts belonging to this group should be |
| 7056 | * visible in any user interface. |
| 7057 | * <p> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7058 | * Type: INTEGER (boolean) |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7059 | */ |
| 7060 | public static final String GROUP_VISIBLE = "group_visible"; |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 7061 | |
| 7062 | /** |
| 7063 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 7064 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7065 | * called on a group, it is marked for deletion. The sync adaptor |
| 7066 | * deletes the group on the server and then calls ContactResolver.delete |
| 7067 | * once more, this time setting the the |
| 7068 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to |
| 7069 | * finalize the data removal. |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 7070 | * <P>Type: INTEGER</P> |
| 7071 | */ |
| 7072 | public static final String DELETED = "deleted"; |
Jeff Sharkey | 403d7ac | 2009-08-16 16:34:35 -0700 | [diff] [blame] | 7073 | |
| 7074 | /** |
| 7075 | * Whether this group should be synced if the SYNC_EVERYTHING settings |
| 7076 | * is false for this group's account. |
| 7077 | * <p> |
| 7078 | * Type: INTEGER (boolean) |
| 7079 | */ |
| 7080 | public static final String SHOULD_SYNC = "should_sync"; |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 7081 | |
| 7082 | /** |
| 7083 | * Any newly created contacts will automatically be added to groups that have this |
| 7084 | * flag set to true. |
| 7085 | * <p> |
| 7086 | * Type: INTEGER (boolean) |
| 7087 | */ |
| 7088 | public static final String AUTO_ADD = "auto_add"; |
| 7089 | |
| 7090 | /** |
| 7091 | * When a contacts is marked as a favorites it will be automatically added |
| 7092 | * to the groups that have this flag set, and when it is removed from favorites |
| 7093 | * it will be removed from these groups. |
| 7094 | * <p> |
| 7095 | * Type: INTEGER (boolean) |
| 7096 | */ |
| 7097 | public static final String FAVORITES = "favorites"; |
Dmitri Plotnikov | 4ccf33a | 2010-11-19 11:10:43 -0800 | [diff] [blame] | 7098 | |
| 7099 | /** |
| 7100 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 7101 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 7102 | * <P>Type: INTEGER</P> |
| 7103 | */ |
| 7104 | public static final String GROUP_IS_READ_ONLY = "group_is_read_only"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7105 | } |
| 7106 | |
| 7107 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7108 | * Constants for the groups table. Only per-account groups are supported. |
| 7109 | * <h2>Columns</h2> |
| 7110 | * <table class="jd-sumtable"> |
| 7111 | * <tr> |
| 7112 | * <th colspan='4'>Groups</th> |
| 7113 | * </tr> |
| 7114 | * <tr> |
| 7115 | * <td>long</td> |
| 7116 | * <td>{@link #_ID}</td> |
| 7117 | * <td>read-only</td> |
| 7118 | * <td>Row ID. Sync adapter should try to preserve row IDs during updates. |
| 7119 | * In other words, it would be a really bad idea to delete and reinsert a |
| 7120 | * group. A sync adapter should always do an update instead.</td> |
| 7121 | * </tr> |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 7122 | # <tr> |
| 7123 | * <td>String</td> |
| 7124 | * <td>{@link #DATA_SET}</td> |
| 7125 | * <td>read/write-once</td> |
| 7126 | * <td> |
| 7127 | * <p> |
| 7128 | * The data set within the account that this group belongs to. This allows |
| 7129 | * multiple sync adapters for the same account type to distinguish between |
| 7130 | * each others' group data. The combination of {@link #ACCOUNT_TYPE}, |
| 7131 | * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data |
| 7132 | * that is associated with a single sync adapter. |
| 7133 | * </p> |
| 7134 | * <p> |
| 7135 | * This is empty by default, and is completely optional. It only needs to |
| 7136 | * be populated if multiple sync adapters are entering distinct data for |
| 7137 | * the same account type and account name. |
| 7138 | * </p> |
| 7139 | * <p> |
| 7140 | * It should be set at the time the group is inserted and never changed |
| 7141 | * afterwards. |
| 7142 | * </p> |
| 7143 | * </td> |
| 7144 | * </tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7145 | * <tr> |
| 7146 | * <td>String</td> |
| 7147 | * <td>{@link #TITLE}</td> |
| 7148 | * <td>read/write</td> |
| 7149 | * <td>The display title of this group.</td> |
| 7150 | * </tr> |
| 7151 | * <tr> |
| 7152 | * <td>String</td> |
| 7153 | * <td>{@link #NOTES}</td> |
| 7154 | * <td>read/write</td> |
| 7155 | * <td>Notes about the group.</td> |
| 7156 | * </tr> |
| 7157 | * <tr> |
| 7158 | * <td>String</td> |
| 7159 | * <td>{@link #SYSTEM_ID}</td> |
| 7160 | * <td>read/write</td> |
| 7161 | * <td>The ID of this group if it is a System Group, i.e. a group that has a |
| 7162 | * special meaning to the sync adapter, null otherwise.</td> |
| 7163 | * </tr> |
| 7164 | * <tr> |
| 7165 | * <td>int</td> |
| 7166 | * <td>{@link #SUMMARY_COUNT}</td> |
| 7167 | * <td>read-only</td> |
| 7168 | * <td>The total number of {@link Contacts} that have |
| 7169 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value |
| 7170 | * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 7171 | * </tr> |
| 7172 | * <tr> |
| 7173 | * <td>int</td> |
| 7174 | * <td>{@link #SUMMARY_WITH_PHONES}</td> |
| 7175 | * <td>read-only</td> |
| 7176 | * <td>The total number of {@link Contacts} that have both |
| 7177 | * {@link CommonDataKinds.GroupMembership} in this group, and also have |
| 7178 | * phone numbers. Read-only value that is only present when querying |
| 7179 | * {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 7180 | * </tr> |
| 7181 | * <tr> |
| 7182 | * <td>int</td> |
| 7183 | * <td>{@link #GROUP_VISIBLE}</td> |
| 7184 | * <td>read-only</td> |
| 7185 | * <td>Flag indicating if the contacts belonging to this group should be |
| 7186 | * visible in any user interface. Allowed values: 0 and 1.</td> |
| 7187 | * </tr> |
| 7188 | * <tr> |
| 7189 | * <td>int</td> |
| 7190 | * <td>{@link #DELETED}</td> |
| 7191 | * <td>read/write</td> |
| 7192 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 7193 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 7194 | * called on a group, it is marked for deletion. The sync adaptor deletes |
| 7195 | * the group on the server and then calls ContactResolver.delete once more, |
| 7196 | * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER} |
| 7197 | * query parameter to finalize the data removal.</td> |
| 7198 | * </tr> |
| 7199 | * <tr> |
| 7200 | * <td>int</td> |
| 7201 | * <td>{@link #SHOULD_SYNC}</td> |
| 7202 | * <td>read/write</td> |
| 7203 | * <td>Whether this group should be synced if the SYNC_EVERYTHING settings |
| 7204 | * is false for this group's account.</td> |
| 7205 | * </tr> |
| 7206 | * </table> |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7207 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7208 | public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7209 | /** |
| 7210 | * This utility class cannot be instantiated |
| 7211 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7212 | private Groups() { |
| 7213 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7214 | |
| 7215 | /** |
| 7216 | * The content:// style URI for this table |
| 7217 | */ |
| 7218 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); |
| 7219 | |
| 7220 | /** |
| 7221 | * The content:// style URI for this table joined with details data from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7222 | * {@link ContactsContract.Data}. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7223 | */ |
| 7224 | public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 7225 | "groups_summary"); |
| 7226 | |
| 7227 | /** |
| 7228 | * The MIME type of a directory of groups. |
| 7229 | */ |
| 7230 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; |
| 7231 | |
| 7232 | /** |
| 7233 | * The MIME type of a single group. |
| 7234 | */ |
| 7235 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7236 | |
| 7237 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 7238 | return new EntityIteratorImpl(cursor); |
| 7239 | } |
| 7240 | |
| 7241 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 7242 | public EntityIteratorImpl(Cursor cursor) { |
| 7243 | super(cursor); |
| 7244 | } |
| 7245 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 7246 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7247 | public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { |
| 7248 | // we expect the cursor is already at the row we need to read from |
| 7249 | final ContentValues values = new ContentValues(); |
| 7250 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID); |
| 7251 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME); |
| 7252 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE); |
| 7253 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY); |
| 7254 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION); |
| 7255 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID); |
| 7256 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE); |
| 7257 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE); |
| 7258 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES); |
| 7259 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE); |
| 7260 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1); |
| 7261 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2); |
| 7262 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3); |
| 7263 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4); |
| 7264 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID); |
| 7265 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED); |
| 7266 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES); |
| 7267 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC); |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 7268 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES); |
| 7269 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7270 | cursor.moveToNext(); |
| 7271 | return new Entity(values); |
| 7272 | } |
| 7273 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7274 | } |
| 7275 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7276 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7277 | * <p> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7278 | * Constants for the contact aggregation exceptions table, which contains |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7279 | * aggregation rules overriding those used by automatic aggregation. This |
| 7280 | * type only supports query and update. Neither insert nor delete are |
| 7281 | * supported. |
| 7282 | * </p> |
| 7283 | * <h2>Columns</h2> |
| 7284 | * <table class="jd-sumtable"> |
| 7285 | * <tr> |
| 7286 | * <th colspan='4'>AggregationExceptions</th> |
| 7287 | * </tr> |
| 7288 | * <tr> |
| 7289 | * <td>int</td> |
| 7290 | * <td>{@link #TYPE}</td> |
| 7291 | * <td>read/write</td> |
| 7292 | * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER}, |
| 7293 | * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td> |
| 7294 | * </tr> |
| 7295 | * <tr> |
| 7296 | * <td>long</td> |
| 7297 | * <td>{@link #RAW_CONTACT_ID1}</td> |
| 7298 | * <td>read/write</td> |
| 7299 | * <td>A reference to the {@link RawContacts#_ID} of the raw contact that |
| 7300 | * the rule applies to.</td> |
| 7301 | * </tr> |
| 7302 | * <tr> |
| 7303 | * <td>long</td> |
| 7304 | * <td>{@link #RAW_CONTACT_ID2}</td> |
| 7305 | * <td>read/write</td> |
| 7306 | * <td>A reference to the other {@link RawContacts#_ID} of the raw contact |
| 7307 | * that the rule applies to.</td> |
| 7308 | * </tr> |
| 7309 | * </table> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7310 | */ |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 7311 | public static final class AggregationExceptions implements BaseColumns { |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7312 | /** |
| 7313 | * This utility class cannot be instantiated |
| 7314 | */ |
| 7315 | private AggregationExceptions() {} |
| 7316 | |
| 7317 | /** |
| 7318 | * The content:// style URI for this table |
| 7319 | */ |
| 7320 | public static final Uri CONTENT_URI = |
| 7321 | Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); |
| 7322 | |
| 7323 | /** |
| 7324 | * The MIME type of {@link #CONTENT_URI} providing a directory of data. |
| 7325 | */ |
| 7326 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; |
| 7327 | |
| 7328 | /** |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 7329 | * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception |
| 7330 | */ |
| 7331 | public static final String CONTENT_ITEM_TYPE = |
| 7332 | "vnd.android.cursor.item/aggregation_exception"; |
| 7333 | |
| 7334 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7335 | * 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] | 7336 | * {@link #TYPE_AUTOMATIC}. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7337 | * |
| 7338 | * <P>Type: INTEGER</P> |
| 7339 | */ |
| 7340 | public static final String TYPE = "type"; |
| 7341 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7342 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7343 | * Allows the provider to automatically decide whether the specified raw contacts should |
| 7344 | * be included in the same aggregate contact or not. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7345 | */ |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7346 | public static final int TYPE_AUTOMATIC = 0; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7347 | |
| 7348 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7349 | * Makes sure that the specified raw contacts are included in the same |
| 7350 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7351 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7352 | public static final int TYPE_KEEP_TOGETHER = 1; |
| 7353 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7354 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7355 | * Makes sure that the specified raw contacts are NOT included in the same |
| 7356 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7357 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7358 | public static final int TYPE_KEEP_SEPARATE = 2; |
| 7359 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7360 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7361 | * 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] | 7362 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7363 | public static final String RAW_CONTACT_ID1 = "raw_contact_id1"; |
| 7364 | |
| 7365 | /** |
| 7366 | * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule |
| 7367 | * applies to. |
| 7368 | */ |
| 7369 | public static final String RAW_CONTACT_ID2 = "raw_contact_id2"; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7370 | } |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 7371 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7372 | /** |
| 7373 | * @see Settings |
| 7374 | */ |
Dmitri Plotnikov | fe4c871 | 2009-10-14 00:28:48 -0700 | [diff] [blame] | 7375 | protected interface SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7376 | /** |
| 7377 | * The name of the account instance to which this row belongs. |
| 7378 | * <P>Type: TEXT</P> |
| 7379 | */ |
| 7380 | public static final String ACCOUNT_NAME = "account_name"; |
| 7381 | |
| 7382 | /** |
| 7383 | * The type of account to which this row belongs, which when paired with |
| 7384 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 7385 | * <P>Type: TEXT</P> |
| 7386 | */ |
| 7387 | public static final String ACCOUNT_TYPE = "account_type"; |
| 7388 | |
| 7389 | /** |
Dave Santoro | 7c4479f | 2011-09-07 16:52:27 -0700 | [diff] [blame] | 7390 | * The data set within the account that this row belongs to. This allows |
| 7391 | * multiple sync adapters for the same account type to distinguish between |
| 7392 | * each others' data. |
| 7393 | * |
| 7394 | * This is empty by default, and is completely optional. It only needs to |
| 7395 | * be populated if multiple sync adapters are entering distinct data for |
| 7396 | * the same account type and account name. |
| 7397 | * <P>Type: TEXT</P> |
| 7398 | */ |
| 7399 | public static final String DATA_SET = "data_set"; |
| 7400 | |
| 7401 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7402 | * Depending on the mode defined by the sync-adapter, this flag controls |
| 7403 | * the top-level sync behavior for this data source. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7404 | * <p> |
| 7405 | * Type: INTEGER (boolean) |
| 7406 | */ |
| 7407 | public static final String SHOULD_SYNC = "should_sync"; |
| 7408 | |
| 7409 | /** |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7410 | * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership} |
Jeff Sharkey | a659744 | 2009-08-19 09:23:33 -0700 | [diff] [blame] | 7411 | * entries should be visible in any user interface. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7412 | * <p> |
| 7413 | * Type: INTEGER (boolean) |
| 7414 | */ |
| 7415 | public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7416 | |
| 7417 | /** |
Jeff Sharkey | 97bda4c | 2009-09-15 23:15:23 -0700 | [diff] [blame] | 7418 | * Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 7419 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 7420 | * unsynced. |
| 7421 | */ |
| 7422 | public static final String ANY_UNSYNCED = "any_unsynced"; |
| 7423 | |
| 7424 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7425 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 7426 | * no {@link CommonDataKinds.GroupMembership} entries. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7427 | * <p> |
| 7428 | * Type: INTEGER |
| 7429 | */ |
| 7430 | public static final String UNGROUPED_COUNT = "summ_count"; |
| 7431 | |
| 7432 | /** |
| 7433 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 7434 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7435 | * <p> |
| 7436 | * Type: INTEGER |
| 7437 | */ |
| 7438 | public static final String UNGROUPED_WITH_PHONES = "summ_phones"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7439 | } |
| 7440 | |
| 7441 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7442 | * <p> |
| 7443 | * Contacts-specific settings for various {@link Account}'s. |
| 7444 | * </p> |
| 7445 | * <h2>Columns</h2> |
| 7446 | * <table class="jd-sumtable"> |
| 7447 | * <tr> |
| 7448 | * <th colspan='4'>Settings</th> |
| 7449 | * </tr> |
| 7450 | * <tr> |
| 7451 | * <td>String</td> |
| 7452 | * <td>{@link #ACCOUNT_NAME}</td> |
| 7453 | * <td>read/write-once</td> |
| 7454 | * <td>The name of the account instance to which this row belongs.</td> |
| 7455 | * </tr> |
| 7456 | * <tr> |
| 7457 | * <td>String</td> |
| 7458 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 7459 | * <td>read/write-once</td> |
| 7460 | * <td>The type of account to which this row belongs, which when paired with |
| 7461 | * {@link #ACCOUNT_NAME} identifies a specific account.</td> |
| 7462 | * </tr> |
| 7463 | * <tr> |
| 7464 | * <td>int</td> |
| 7465 | * <td>{@link #SHOULD_SYNC}</td> |
| 7466 | * <td>read/write</td> |
| 7467 | * <td>Depending on the mode defined by the sync-adapter, this flag controls |
| 7468 | * the top-level sync behavior for this data source.</td> |
| 7469 | * </tr> |
| 7470 | * <tr> |
| 7471 | * <td>int</td> |
| 7472 | * <td>{@link #UNGROUPED_VISIBLE}</td> |
| 7473 | * <td>read/write</td> |
| 7474 | * <td>Flag indicating if contacts without any |
| 7475 | * {@link CommonDataKinds.GroupMembership} entries should be visible in any |
| 7476 | * user interface.</td> |
| 7477 | * </tr> |
| 7478 | * <tr> |
| 7479 | * <td>int</td> |
| 7480 | * <td>{@link #ANY_UNSYNCED}</td> |
| 7481 | * <td>read-only</td> |
| 7482 | * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 7483 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 7484 | * unsynced.</td> |
| 7485 | * </tr> |
| 7486 | * <tr> |
| 7487 | * <td>int</td> |
| 7488 | * <td>{@link #UNGROUPED_COUNT}</td> |
| 7489 | * <td>read-only</td> |
| 7490 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 7491 | * no {@link CommonDataKinds.GroupMembership} entries.</td> |
| 7492 | * </tr> |
| 7493 | * <tr> |
| 7494 | * <td>int</td> |
| 7495 | * <td>{@link #UNGROUPED_WITH_PHONES}</td> |
| 7496 | * <td>read-only</td> |
| 7497 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 7498 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone |
| 7499 | * numbers.</td> |
| 7500 | * </tr> |
| 7501 | * </table> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7502 | */ |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7503 | public static final class Settings implements SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7504 | /** |
| 7505 | * This utility class cannot be instantiated |
| 7506 | */ |
| 7507 | private Settings() { |
| 7508 | } |
| 7509 | |
| 7510 | /** |
| 7511 | * The content:// style URI for this table |
| 7512 | */ |
| 7513 | public static final Uri CONTENT_URI = |
| 7514 | Uri.withAppendedPath(AUTHORITY_URI, "settings"); |
| 7515 | |
| 7516 | /** |
| 7517 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 7518 | * settings. |
| 7519 | */ |
| 7520 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; |
| 7521 | |
| 7522 | /** |
| 7523 | * The MIME-type of {@link #CONTENT_URI} providing a single setting. |
| 7524 | */ |
| 7525 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7526 | } |
| 7527 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 7528 | /** |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 7529 | * Private API for inquiring about the general status of the provider. |
| 7530 | * |
| 7531 | * @hide |
| 7532 | */ |
| 7533 | public static final class ProviderStatus { |
| 7534 | |
| 7535 | /** |
| 7536 | * Not instantiable. |
| 7537 | */ |
| 7538 | private ProviderStatus() { |
| 7539 | } |
| 7540 | |
| 7541 | /** |
| 7542 | * The content:// style URI for this table. Requests to this URI can be |
| 7543 | * performed on the UI thread because they are always unblocking. |
| 7544 | * |
| 7545 | * @hide |
| 7546 | */ |
| 7547 | public static final Uri CONTENT_URI = |
| 7548 | Uri.withAppendedPath(AUTHORITY_URI, "provider_status"); |
| 7549 | |
| 7550 | /** |
| 7551 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 7552 | * settings. |
| 7553 | * |
| 7554 | * @hide |
| 7555 | */ |
| 7556 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status"; |
| 7557 | |
| 7558 | /** |
| 7559 | * An integer representing the current status of the provider. |
| 7560 | * |
| 7561 | * @hide |
| 7562 | */ |
| 7563 | public static final String STATUS = "status"; |
| 7564 | |
| 7565 | /** |
| 7566 | * Default status of the provider. |
| 7567 | * |
| 7568 | * @hide |
| 7569 | */ |
| 7570 | public static final int STATUS_NORMAL = 0; |
| 7571 | |
| 7572 | /** |
| 7573 | * The status used when the provider is in the process of upgrading. Contacts |
| 7574 | * are temporarily unaccessible. |
| 7575 | * |
| 7576 | * @hide |
| 7577 | */ |
| 7578 | public static final int STATUS_UPGRADING = 1; |
| 7579 | |
| 7580 | /** |
| 7581 | * The status used if the provider was in the process of upgrading but ran |
| 7582 | * out of storage. The DATA1 column will contain the estimated amount of |
| 7583 | * storage required (in bytes). Update status to STATUS_NORMAL to force |
| 7584 | * the provider to retry the upgrade. |
| 7585 | * |
| 7586 | * @hide |
| 7587 | */ |
| 7588 | public static final int STATUS_UPGRADE_OUT_OF_MEMORY = 2; |
| 7589 | |
| 7590 | /** |
| 7591 | * The status used during a locale change. |
| 7592 | * |
| 7593 | * @hide |
| 7594 | */ |
| 7595 | public static final int STATUS_CHANGING_LOCALE = 3; |
| 7596 | |
| 7597 | /** |
Dmitri Plotnikov | 37c3486 | 2010-11-12 16:12:53 -0800 | [diff] [blame] | 7598 | * The status that indicates that there are no accounts and no contacts |
| 7599 | * on the device. |
| 7600 | * |
| 7601 | * @hide |
| 7602 | */ |
| 7603 | public static final int STATUS_NO_ACCOUNTS_NO_CONTACTS = 4; |
| 7604 | |
| 7605 | /** |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 7606 | * Additional data associated with the status. |
| 7607 | * |
| 7608 | * @hide |
| 7609 | */ |
| 7610 | public static final String DATA1 = "data1"; |
| 7611 | } |
| 7612 | |
| 7613 | /** |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7614 | * <p> |
| 7615 | * 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] | 7616 | * Contacts Provider. Applications can also clear all usage information. |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7617 | * </p> |
| 7618 | * <p> |
| 7619 | * With the feedback, Contacts Provider may return more contextually appropriate results for |
| 7620 | * Data listing, typically supplied with |
| 7621 | * {@link ContactsContract.Contacts#CONTENT_FILTER_URI}, |
| 7622 | * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI}, |
| 7623 | * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit |
| 7624 | * from better ranked (sorted) lists in applications that show auto-complete list. |
| 7625 | * </p> |
| 7626 | * <p> |
| 7627 | * There is no guarantee for how this feedback is used, or even whether it is used at all. |
| 7628 | * The ranking algorithm will make best efforts to use the feedback data, but the exact |
| 7629 | * implementation, the storage data structures as well as the resulting sort order is device |
| 7630 | * and version specific and can change over time. |
| 7631 | * </p> |
| 7632 | * <p> |
| 7633 | * When updating usage information, users of this API need to use |
| 7634 | * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed |
| 7635 | * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as |
| 7636 | * its last path. They also need to append a query parameter to the Uri, to specify the type of |
| 7637 | * the communication, which enables the Contacts Provider to differentiate between kinds of |
| 7638 | * interactions using the same contact data field (for example a phone number can be used to |
| 7639 | * make phone calls or send SMS). |
| 7640 | * </p> |
| 7641 | * <p> |
| 7642 | * Selection and selectionArgs are ignored and must be set to null. To get data ids, |
| 7643 | * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)} |
| 7644 | * toward {@link Data#CONTENT_URI}. |
| 7645 | * </p> |
| 7646 | * <p> |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 7647 | * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive |
| 7648 | * integer when successful, and returns 0 if no contact with that id was found. |
| 7649 | * </p> |
| 7650 | * <p> |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7651 | * Example: |
| 7652 | * <pre> |
Daisuke Miyakawa | 52e3823 | 2011-06-14 10:56:46 -0700 | [diff] [blame] | 7653 | * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon() |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7654 | * .appendPath(TextUtils.join(",", dataIds)) |
Daisuke Miyakawa | 52e3823 | 2011-06-14 10:56:46 -0700 | [diff] [blame] | 7655 | * .appendQueryParameter(DataUsageFeedback.USAGE_TYPE, |
| 7656 | * DataUsageFeedback.USAGE_TYPE_CALL) |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7657 | * .build(); |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 7658 | * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0; |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7659 | * </pre> |
| 7660 | * </p> |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 7661 | * <p> |
| 7662 | * Applications can also clear all usage information with: |
| 7663 | * <pre> |
Makoto Onuki | 7ebbfd0 | 2012-04-13 12:56:42 -0700 | [diff] [blame] | 7664 | * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0; |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 7665 | * </pre> |
| 7666 | * </p> |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7667 | */ |
| 7668 | public static final class DataUsageFeedback { |
| 7669 | |
| 7670 | /** |
| 7671 | * The content:// style URI for sending usage feedback. |
| 7672 | * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}. |
| 7673 | */ |
| 7674 | public static final Uri FEEDBACK_URI = |
| 7675 | Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback"); |
| 7676 | |
| 7677 | /** |
Makoto Onuki | 7ebbfd0 | 2012-04-13 12:56:42 -0700 | [diff] [blame] | 7678 | * The content:// style URI for deleting all usage information. |
| 7679 | * Must be used with {@link ContentResolver#delete(Uri, String, String[])}. |
| 7680 | * The {@code where} and {@code selectionArgs} parameters are ignored. |
| 7681 | */ |
| 7682 | public static final Uri DELETE_USAGE_URI = |
| 7683 | Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage"); |
| 7684 | |
| 7685 | /** |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7686 | * <p> |
| 7687 | * Name for query parameter specifying the type of data usage. |
| 7688 | * </p> |
| 7689 | */ |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 7690 | public static final String USAGE_TYPE = "type"; |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7691 | |
| 7692 | /** |
| 7693 | * <p> |
| 7694 | * Type of usage for voice interaction, which includes phone call, voice chat, and |
| 7695 | * video chat. |
| 7696 | * </p> |
| 7697 | */ |
| 7698 | public static final String USAGE_TYPE_CALL = "call"; |
| 7699 | |
| 7700 | /** |
| 7701 | * <p> |
| 7702 | * Type of usage for text interaction involving longer messages, which includes email. |
| 7703 | * </p> |
| 7704 | */ |
| 7705 | public static final String USAGE_TYPE_LONG_TEXT = "long_text"; |
| 7706 | |
| 7707 | /** |
| 7708 | * <p> |
| 7709 | * Type of usage for text interaction involving shorter messages, which includes SMS, |
| 7710 | * text chat with email addresses. |
| 7711 | * </p> |
| 7712 | */ |
| 7713 | public static final String USAGE_TYPE_SHORT_TEXT = "short_text"; |
| 7714 | } |
| 7715 | |
| 7716 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 7717 | * Helper methods to display QuickContact dialogs that allow users to pivot on |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7718 | * a specific {@link Contacts} entry. |
| 7719 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 7720 | public static final class QuickContact { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7721 | /** |
| 7722 | * Action used to trigger person pivot dialog. |
| 7723 | * @hide |
| 7724 | */ |
Evan Millar | 5042f7e | 2009-09-30 21:28:33 -0700 | [diff] [blame] | 7725 | public static final String ACTION_QUICK_CONTACT = |
| 7726 | "com.android.contacts.action.QUICK_CONTACT"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7727 | |
| 7728 | /** |
| 7729 | * Extra used to specify pivot dialog location in screen coordinates. |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 7730 | * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7731 | * @hide |
| 7732 | */ |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 7733 | @Deprecated |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7734 | public static final String EXTRA_TARGET_RECT = "target_rect"; |
| 7735 | |
| 7736 | /** |
| 7737 | * Extra used to specify size of pivot dialog. |
| 7738 | * @hide |
| 7739 | */ |
| 7740 | public static final String EXTRA_MODE = "mode"; |
| 7741 | |
| 7742 | /** |
| 7743 | * Extra used to indicate a list of specific MIME-types to exclude and |
| 7744 | * not display. Stored as a {@link String} array. |
| 7745 | * @hide |
| 7746 | */ |
| 7747 | public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; |
| 7748 | |
| 7749 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 7750 | * Small QuickContact mode, usually presented with minimal actions. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7751 | */ |
| 7752 | public static final int MODE_SMALL = 1; |
| 7753 | |
| 7754 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 7755 | * Medium QuickContact mode, includes actions and light summary describing |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7756 | * the {@link Contacts} entry being shown. This may include social |
| 7757 | * status and presence details. |
| 7758 | */ |
| 7759 | public static final int MODE_MEDIUM = 2; |
| 7760 | |
| 7761 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 7762 | * Large QuickContact mode, includes actions and larger, card-like summary |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7763 | * of the {@link Contacts} entry being shown. This may include detailed |
| 7764 | * information, such as a photo. |
| 7765 | */ |
| 7766 | public static final int MODE_LARGE = 3; |
| 7767 | |
| 7768 | /** |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 7769 | * Constructs the QuickContacts intent with a view's rect. |
| 7770 | * @hide |
| 7771 | */ |
| 7772 | public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri, |
| 7773 | int mode, String[] excludeMimes) { |
| 7774 | // Find location and bounds of target view, adjusting based on the |
| 7775 | // assumed local density. |
| 7776 | final float appScale = context.getResources().getCompatibilityInfo().applicationScale; |
| 7777 | final int[] pos = new int[2]; |
| 7778 | target.getLocationOnScreen(pos); |
| 7779 | |
| 7780 | final Rect rect = new Rect(); |
| 7781 | rect.left = (int) (pos[0] * appScale + 0.5f); |
| 7782 | rect.top = (int) (pos[1] * appScale + 0.5f); |
| 7783 | rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); |
| 7784 | rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); |
| 7785 | |
| 7786 | return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes); |
| 7787 | } |
| 7788 | |
| 7789 | /** |
| 7790 | * Constructs the QuickContacts intent. |
| 7791 | * @hide |
| 7792 | */ |
| 7793 | public static Intent composeQuickContactsIntent(Context context, Rect target, |
| 7794 | Uri lookupUri, int mode, String[] excludeMimes) { |
| 7795 | // When launching from an Activiy, we don't want to start a new task, but otherwise |
| 7796 | // we *must* start a new task. (Otherwise startActivity() would crash.) |
| 7797 | Context actualContext = context; |
| 7798 | while ((actualContext instanceof ContextWrapper) |
| 7799 | && !(actualContext instanceof Activity)) { |
| 7800 | actualContext = ((ContextWrapper) actualContext).getBaseContext(); |
| 7801 | } |
| 7802 | final int intentFlags = (actualContext instanceof Activity) |
| 7803 | ? Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET |
| 7804 | : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK; |
| 7805 | |
| 7806 | // Launch pivot dialog through intent for now |
| 7807 | final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags); |
| 7808 | |
| 7809 | intent.setData(lookupUri); |
| 7810 | intent.setSourceBounds(target); |
| 7811 | intent.putExtra(EXTRA_MODE, mode); |
| 7812 | intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); |
| 7813 | return intent; |
| 7814 | } |
| 7815 | |
| 7816 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7817 | * Trigger a dialog that lists the various methods of interacting with |
| 7818 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7819 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 7820 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7821 | * |
| 7822 | * @param context The parent {@link Context} that may be used as the |
| 7823 | * parent for this dialog. |
| 7824 | * @param target Specific {@link View} from your layout that this dialog |
| 7825 | * should be centered around. In particular, if the dialog |
| 7826 | * has a "callout" arrow, it will be pointed and centered |
| 7827 | * around this {@link View}. |
Evan Millar | 772722e | 2009-09-30 22:24:07 -0700 | [diff] [blame] | 7828 | * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7829 | * {@link Uri} that describes a specific contact to feature |
| 7830 | * in this dialog. |
| 7831 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 7832 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 7833 | * when supported. |
| 7834 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 7835 | * to exclude when showing this dialog. For example, when |
| 7836 | * already viewing the contact details card, this can be used |
| 7837 | * to omit the details entry from the dialog. |
| 7838 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 7839 | public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7840 | String[] excludeMimes) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7841 | // Trigger with obtained rectangle |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 7842 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, |
| 7843 | excludeMimes); |
| 7844 | context.startActivity(intent); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7845 | } |
| 7846 | |
| 7847 | /** |
| 7848 | * Trigger a dialog that lists the various methods of interacting with |
| 7849 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7850 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 7851 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7852 | * |
| 7853 | * @param context The parent {@link Context} that may be used as the |
| 7854 | * parent for this dialog. |
| 7855 | * @param target Specific {@link Rect} that this dialog should be |
| 7856 | * centered around, in screen coordinates. In particular, if |
| 7857 | * the dialog has a "callout" arrow, it will be pointed and |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 7858 | * centered around this {@link Rect}. If you are running at a |
| 7859 | * non-native density, you need to manually adjust using |
| 7860 | * {@link DisplayMetrics#density} before calling. |
Jeff Sharkey | 223bd7a | 2009-12-21 14:51:19 -0800 | [diff] [blame] | 7861 | * @param lookupUri A |
| 7862 | * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7863 | * {@link Uri} that describes a specific contact to feature |
| 7864 | * in this dialog. |
| 7865 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 7866 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 7867 | * when supported. |
| 7868 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 7869 | * to exclude when showing this dialog. For example, when |
| 7870 | * already viewing the contact details card, this can be used |
| 7871 | * to omit the details entry from the dialog. |
| 7872 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 7873 | public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7874 | String[] excludeMimes) { |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 7875 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, |
| 7876 | excludeMimes); |
| 7877 | context.startActivity(intent); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7878 | } |
| 7879 | } |
| 7880 | |
| 7881 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 7882 | * Helper class for accessing full-size photos by photo file ID. |
| 7883 | * <p> |
| 7884 | * Usage example: |
| 7885 | * <dl> |
| 7886 | * <dt>Retrieving a full-size photo by photo file ID (see |
| 7887 | * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID}) |
| 7888 | * </dt> |
| 7889 | * <dd> |
| 7890 | * <pre> |
| 7891 | * public InputStream openDisplayPhoto(long photoFileId) { |
| 7892 | * Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey); |
| 7893 | * try { |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 7894 | * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor( |
| 7895 | * displayPhotoUri, "r"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 7896 | * return fd.createInputStream(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 7897 | * } catch (IOException e) { |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 7898 | * return null; |
| 7899 | * } |
| 7900 | * } |
| 7901 | * </pre> |
| 7902 | * </dd> |
| 7903 | * </dl> |
| 7904 | * </p> |
| 7905 | */ |
| 7906 | public static final class DisplayPhoto { |
| 7907 | /** |
| 7908 | * no public constructor since this is a utility class |
| 7909 | */ |
| 7910 | private DisplayPhoto() {} |
| 7911 | |
| 7912 | /** |
| 7913 | * The content:// style URI for this class, which allows access to full-size photos, |
| 7914 | * given a key. |
| 7915 | */ |
| 7916 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo"); |
| 7917 | |
| 7918 | /** |
| 7919 | * This URI allows the caller to query for the maximum dimensions of a display photo |
| 7920 | * or thumbnail. Requests to this URI can be performed on the UI thread because |
| 7921 | * they are always unblocking. |
| 7922 | */ |
| 7923 | public static final Uri CONTENT_MAX_DIMENSIONS_URI = |
| 7924 | Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions"); |
| 7925 | |
| 7926 | /** |
| 7927 | * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will |
| 7928 | * contain this column, populated with the maximum height and width (in pixels) |
| 7929 | * that will be stored for a display photo. Larger photos will be down-sized to |
| 7930 | * fit within a square of this many pixels. |
| 7931 | */ |
| 7932 | public static final String DISPLAY_MAX_DIM = "display_max_dim"; |
| 7933 | |
| 7934 | /** |
| 7935 | * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will |
| 7936 | * contain this column, populated with the height and width (in pixels) for photo |
| 7937 | * thumbnails. |
| 7938 | */ |
| 7939 | public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim"; |
| 7940 | } |
| 7941 | |
| 7942 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 7943 | * Contains helper classes used to create or manage {@link android.content.Intent Intents} |
| 7944 | * that involve contacts. |
| 7945 | */ |
| 7946 | public static final class Intents { |
| 7947 | /** |
| 7948 | * This is the intent that is fired when a search suggestion is clicked on. |
| 7949 | */ |
| 7950 | public static final String SEARCH_SUGGESTION_CLICKED = |
| 7951 | "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; |
| 7952 | |
| 7953 | /** |
| 7954 | * This is the intent that is fired when a search suggestion for dialing a number |
| 7955 | * is clicked on. |
| 7956 | */ |
| 7957 | public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = |
| 7958 | "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; |
| 7959 | |
| 7960 | /** |
| 7961 | * This is the intent that is fired when a search suggestion for creating a contact |
| 7962 | * is clicked on. |
| 7963 | */ |
| 7964 | public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = |
| 7965 | "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; |
| 7966 | |
| 7967 | /** |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 7968 | * This is the intent that is fired when the contacts database is created. <p> The |
| 7969 | * READ_CONTACT permission is required to receive these broadcasts. |
| 7970 | */ |
| 7971 | public static final String CONTACTS_DATABASE_CREATED = |
| 7972 | "android.provider.Contacts.DATABASE_CREATED"; |
| 7973 | |
| 7974 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 7975 | * Starts an Activity that lets the user pick a contact to attach an image to. |
| 7976 | * After picking the contact it launches the image cropper in face detection mode. |
| 7977 | */ |
| 7978 | public static final String ATTACH_IMAGE = |
| 7979 | "com.android.contacts.action.ATTACH_IMAGE"; |
| 7980 | |
| 7981 | /** |
Makoto Onuki | 85a01a6b | 2011-07-21 15:16:31 -0700 | [diff] [blame] | 7982 | * This is the intent that is fired when the user clicks the "invite to the network" button |
| 7983 | * on a contact. Only sent to an activity which is explicitly registered by a contact |
| 7984 | * provider which supports the "invite to the network" feature. |
| 7985 | * <p> |
| 7986 | * {@link Intent#getData()} contains the lookup URI for the contact. |
| 7987 | */ |
| 7988 | public static final String INVITE_CONTACT = |
| 7989 | "com.android.contacts.action.INVITE_CONTACT"; |
| 7990 | |
| 7991 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 7992 | * Takes as input a data URI with a mailto: or tel: scheme. If a single |
| 7993 | * contact exists with the given data it will be shown. If no contact |
| 7994 | * exists, a dialog will ask the user if they want to create a new |
| 7995 | * contact with the provided details filled in. If multiple contacts |
| 7996 | * share the data the user will be prompted to pick which contact they |
| 7997 | * want to view. |
| 7998 | * <p> |
| 7999 | * For <code>mailto:</code> URIs, the scheme specific portion must be a |
| 8000 | * raw email address, such as one built using |
| 8001 | * {@link Uri#fromParts(String, String, String)}. |
| 8002 | * <p> |
| 8003 | * For <code>tel:</code> URIs, the scheme specific portion is compared |
| 8004 | * to existing numbers using the standard caller ID lookup algorithm. |
| 8005 | * The number must be properly encoded, for example using |
| 8006 | * {@link Uri#fromParts(String, String, String)}. |
| 8007 | * <p> |
| 8008 | * Any extras from the {@link Insert} class will be passed along to the |
| 8009 | * create activity if there are no contacts to show. |
| 8010 | * <p> |
| 8011 | * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip |
| 8012 | * prompting the user when the contact doesn't exist. |
| 8013 | */ |
| 8014 | public static final String SHOW_OR_CREATE_CONTACT = |
| 8015 | "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; |
| 8016 | |
| 8017 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8018 | * Starts an Activity that lets the user select the multiple phones from a |
| 8019 | * list of phone numbers which come from the contacts or |
| 8020 | * {@link #EXTRA_PHONE_URIS}. |
| 8021 | * <p> |
| 8022 | * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS} |
| 8023 | * could belong to the contacts or not, and will be selected by default. |
| 8024 | * <p> |
| 8025 | * The user's selection will be returned from |
| 8026 | * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)} |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 8027 | * if the resultCode is |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8028 | * {@link android.app.Activity#RESULT_OK}, the array of picked phone |
| 8029 | * numbers are in the Intent's |
| 8030 | * {@link #EXTRA_PHONE_URIS}; otherwise, the |
| 8031 | * {@link android.app.Activity#RESULT_CANCELED} is returned if the user |
| 8032 | * left the Activity without changing the selection. |
| 8033 | * |
| 8034 | * @hide |
| 8035 | */ |
| 8036 | public static final String ACTION_GET_MULTIPLE_PHONES = |
| 8037 | "com.android.contacts.action.GET_MULTIPLE_PHONES"; |
| 8038 | |
| 8039 | /** |
Makoto Onuki | 90ddc90 | 2012-09-11 18:22:53 -0700 | [diff] [blame] | 8040 | * A broadcast action which is sent when any change has been made to the profile, such |
| 8041 | * as the profile name or the picture. A receiver must have |
| 8042 | * the android.permission.READ_PROFILE permission. |
| 8043 | * |
| 8044 | * @hide |
| 8045 | */ |
| 8046 | public static final String ACTION_PROFILE_CHANGED = |
| 8047 | "android.provider.Contacts.PROFILE_CHANGED"; |
| 8048 | |
| 8049 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8050 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new |
| 8051 | * contact if no matching contact found. Otherwise, default behavior is |
| 8052 | * to prompt user with dialog before creating. |
| 8053 | * <p> |
| 8054 | * Type: BOOLEAN |
| 8055 | */ |
| 8056 | public static final String EXTRA_FORCE_CREATE = |
| 8057 | "com.android.contacts.action.FORCE_CREATE"; |
| 8058 | |
| 8059 | /** |
| 8060 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact |
| 8061 | * description to be shown when prompting user about creating a new |
| 8062 | * contact. |
| 8063 | * <p> |
| 8064 | * Type: STRING |
| 8065 | */ |
| 8066 | public static final String EXTRA_CREATE_DESCRIPTION = |
| 8067 | "com.android.contacts.action.CREATE_DESCRIPTION"; |
| 8068 | |
| 8069 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8070 | * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value. |
| 8071 | * <p> |
| 8072 | * The phone numbers want to be picked by default should be passed in as |
| 8073 | * input value. These phone numbers could belong to the contacts or not. |
| 8074 | * <p> |
| 8075 | * The phone numbers which were picked by the user are returned as output |
| 8076 | * value. |
| 8077 | * <p> |
| 8078 | * Type: array of URIs, the tel URI is used for the phone numbers which don't |
| 8079 | * 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] | 8080 | * |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8081 | * @hide |
| 8082 | */ |
| 8083 | public static final String EXTRA_PHONE_URIS = |
| 8084 | "com.android.contacts.extra.PHONE_URIS"; |
| 8085 | |
| 8086 | /** |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 8087 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 8088 | * dialog location using screen coordinates. When not specified, the |
| 8089 | * dialog will be centered. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8090 | * |
| 8091 | * @hide |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 8092 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8093 | @Deprecated |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 8094 | public static final String EXTRA_TARGET_RECT = "target_rect"; |
| 8095 | |
| 8096 | /** |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8097 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 8098 | * desired dialog style, usually a variation on size. One of |
| 8099 | * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8100 | * |
| 8101 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8102 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8103 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8104 | public static final String EXTRA_MODE = "mode"; |
| 8105 | |
| 8106 | /** |
| 8107 | * Value for {@link #EXTRA_MODE} to show a small-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8108 | * |
| 8109 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8110 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8111 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8112 | public static final int MODE_SMALL = 1; |
| 8113 | |
| 8114 | /** |
| 8115 | * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8116 | * |
| 8117 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8118 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8119 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8120 | public static final int MODE_MEDIUM = 2; |
| 8121 | |
| 8122 | /** |
| 8123 | * Value for {@link #EXTRA_MODE} to show a large-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8124 | * |
| 8125 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8126 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8127 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8128 | public static final int MODE_LARGE = 3; |
| 8129 | |
| 8130 | /** |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 8131 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate |
| 8132 | * a list of specific MIME-types to exclude and not display. Stored as a |
| 8133 | * {@link String} array. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8134 | * |
| 8135 | * @hide |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 8136 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8137 | @Deprecated |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 8138 | public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; |
| 8139 | |
| 8140 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8141 | * Intents related to the Contacts app UI. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8142 | * |
| 8143 | * @hide |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8144 | */ |
| 8145 | public static final class UI { |
| 8146 | /** |
| 8147 | * The action for the default contacts list tab. |
| 8148 | */ |
| 8149 | public static final String LIST_DEFAULT = |
| 8150 | "com.android.contacts.action.LIST_DEFAULT"; |
| 8151 | |
| 8152 | /** |
| 8153 | * The action for the contacts list tab. |
| 8154 | */ |
| 8155 | public static final String LIST_GROUP_ACTION = |
| 8156 | "com.android.contacts.action.LIST_GROUP"; |
| 8157 | |
| 8158 | /** |
| 8159 | * When in LIST_GROUP_ACTION mode, this is the group to display. |
| 8160 | */ |
| 8161 | public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP"; |
| 8162 | |
| 8163 | /** |
| 8164 | * The action for the all contacts list tab. |
| 8165 | */ |
| 8166 | public static final String LIST_ALL_CONTACTS_ACTION = |
| 8167 | "com.android.contacts.action.LIST_ALL_CONTACTS"; |
| 8168 | |
| 8169 | /** |
| 8170 | * The action for the contacts with phone numbers list tab. |
| 8171 | */ |
| 8172 | public static final String LIST_CONTACTS_WITH_PHONES_ACTION = |
| 8173 | "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES"; |
| 8174 | |
| 8175 | /** |
| 8176 | * The action for the starred contacts list tab. |
| 8177 | */ |
| 8178 | public static final String LIST_STARRED_ACTION = |
| 8179 | "com.android.contacts.action.LIST_STARRED"; |
| 8180 | |
| 8181 | /** |
| 8182 | * The action for the frequent contacts list tab. |
| 8183 | */ |
| 8184 | public static final String LIST_FREQUENT_ACTION = |
| 8185 | "com.android.contacts.action.LIST_FREQUENT"; |
| 8186 | |
| 8187 | /** |
| 8188 | * The action for the "strequent" contacts list tab. It first lists the starred |
| 8189 | * contacts in alphabetical order and then the frequent contacts in descending |
| 8190 | * order of the number of times they have been contacted. |
| 8191 | */ |
| 8192 | public static final String LIST_STREQUENT_ACTION = |
| 8193 | "com.android.contacts.action.LIST_STREQUENT"; |
| 8194 | |
| 8195 | /** |
| 8196 | * A key for to be used as an intent extra to set the activity |
| 8197 | * title to a custom String value. |
| 8198 | */ |
| 8199 | public static final String TITLE_EXTRA_KEY = |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8200 | "com.android.contacts.extra.TITLE_EXTRA"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8201 | |
| 8202 | /** |
| 8203 | * Activity Action: Display a filtered list of contacts |
| 8204 | * <p> |
| 8205 | * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for |
| 8206 | * filtering |
| 8207 | * <p> |
| 8208 | * Output: Nothing. |
| 8209 | */ |
| 8210 | public static final String FILTER_CONTACTS_ACTION = |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8211 | "com.android.contacts.action.FILTER_CONTACTS"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8212 | |
| 8213 | /** |
| 8214 | * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION} |
| 8215 | * intents to supply the text on which to filter. |
| 8216 | */ |
| 8217 | public static final String FILTER_TEXT_EXTRA_KEY = |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8218 | "com.android.contacts.extra.FILTER_TEXT"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8219 | } |
| 8220 | |
| 8221 | /** |
| 8222 | * Convenience class that contains string constants used |
| 8223 | * to create contact {@link android.content.Intent Intents}. |
| 8224 | */ |
| 8225 | public static final class Insert { |
| 8226 | /** The action code to use when adding a contact */ |
| 8227 | public static final String ACTION = Intent.ACTION_INSERT; |
| 8228 | |
| 8229 | /** |
| 8230 | * If present, forces a bypass of quick insert mode. |
| 8231 | */ |
| 8232 | public static final String FULL_MODE = "full_mode"; |
| 8233 | |
| 8234 | /** |
| 8235 | * The extra field for the contact name. |
| 8236 | * <P>Type: String</P> |
| 8237 | */ |
| 8238 | public static final String NAME = "name"; |
| 8239 | |
| 8240 | // TODO add structured name values here. |
| 8241 | |
| 8242 | /** |
| 8243 | * The extra field for the contact phonetic name. |
| 8244 | * <P>Type: String</P> |
| 8245 | */ |
| 8246 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 8247 | |
| 8248 | /** |
| 8249 | * The extra field for the contact company. |
| 8250 | * <P>Type: String</P> |
| 8251 | */ |
| 8252 | public static final String COMPANY = "company"; |
| 8253 | |
| 8254 | /** |
| 8255 | * The extra field for the contact job title. |
| 8256 | * <P>Type: String</P> |
| 8257 | */ |
| 8258 | public static final String JOB_TITLE = "job_title"; |
| 8259 | |
| 8260 | /** |
| 8261 | * The extra field for the contact notes. |
| 8262 | * <P>Type: String</P> |
| 8263 | */ |
| 8264 | public static final String NOTES = "notes"; |
| 8265 | |
| 8266 | /** |
| 8267 | * The extra field for the contact phone number. |
| 8268 | * <P>Type: String</P> |
| 8269 | */ |
| 8270 | public static final String PHONE = "phone"; |
| 8271 | |
| 8272 | /** |
| 8273 | * The extra field for the contact phone number type. |
| 8274 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8275 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8276 | * or a string specifying a custom label.</P> |
| 8277 | */ |
| 8278 | public static final String PHONE_TYPE = "phone_type"; |
| 8279 | |
| 8280 | /** |
| 8281 | * The extra field for the phone isprimary flag. |
| 8282 | * <P>Type: boolean</P> |
| 8283 | */ |
| 8284 | public static final String PHONE_ISPRIMARY = "phone_isprimary"; |
| 8285 | |
| 8286 | /** |
| 8287 | * The extra field for an optional second contact phone number. |
| 8288 | * <P>Type: String</P> |
| 8289 | */ |
| 8290 | public static final String SECONDARY_PHONE = "secondary_phone"; |
| 8291 | |
| 8292 | /** |
| 8293 | * The extra field for an optional second contact phone number type. |
| 8294 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8295 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8296 | * or a string specifying a custom label.</P> |
| 8297 | */ |
| 8298 | public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; |
| 8299 | |
| 8300 | /** |
| 8301 | * The extra field for an optional third contact phone number. |
| 8302 | * <P>Type: String</P> |
| 8303 | */ |
| 8304 | public static final String TERTIARY_PHONE = "tertiary_phone"; |
| 8305 | |
| 8306 | /** |
| 8307 | * The extra field for an optional third contact phone number type. |
| 8308 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8309 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8310 | * or a string specifying a custom label.</P> |
| 8311 | */ |
| 8312 | public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; |
| 8313 | |
| 8314 | /** |
| 8315 | * The extra field for the contact email address. |
| 8316 | * <P>Type: String</P> |
| 8317 | */ |
| 8318 | public static final String EMAIL = "email"; |
| 8319 | |
| 8320 | /** |
| 8321 | * The extra field for the contact email type. |
| 8322 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8323 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8324 | * or a string specifying a custom label.</P> |
| 8325 | */ |
| 8326 | public static final String EMAIL_TYPE = "email_type"; |
| 8327 | |
| 8328 | /** |
| 8329 | * The extra field for the email isprimary flag. |
| 8330 | * <P>Type: boolean</P> |
| 8331 | */ |
| 8332 | public static final String EMAIL_ISPRIMARY = "email_isprimary"; |
| 8333 | |
| 8334 | /** |
| 8335 | * The extra field for an optional second contact email address. |
| 8336 | * <P>Type: String</P> |
| 8337 | */ |
| 8338 | public static final String SECONDARY_EMAIL = "secondary_email"; |
| 8339 | |
| 8340 | /** |
| 8341 | * The extra field for an optional second contact email type. |
| 8342 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8343 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8344 | * or a string specifying a custom label.</P> |
| 8345 | */ |
| 8346 | public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; |
| 8347 | |
| 8348 | /** |
| 8349 | * The extra field for an optional third contact email address. |
| 8350 | * <P>Type: String</P> |
| 8351 | */ |
| 8352 | public static final String TERTIARY_EMAIL = "tertiary_email"; |
| 8353 | |
| 8354 | /** |
| 8355 | * The extra field for an optional third contact email type. |
| 8356 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8357 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8358 | * or a string specifying a custom label.</P> |
| 8359 | */ |
| 8360 | public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; |
| 8361 | |
| 8362 | /** |
| 8363 | * The extra field for the contact postal address. |
| 8364 | * <P>Type: String</P> |
| 8365 | */ |
| 8366 | public static final String POSTAL = "postal"; |
| 8367 | |
| 8368 | /** |
| 8369 | * The extra field for the contact postal address type. |
| 8370 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8371 | * {@link CommonDataKinds.StructuredPostal} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8372 | * or a string specifying a custom label.</P> |
| 8373 | */ |
| 8374 | public static final String POSTAL_TYPE = "postal_type"; |
| 8375 | |
| 8376 | /** |
| 8377 | * The extra field for the postal isprimary flag. |
| 8378 | * <P>Type: boolean</P> |
| 8379 | */ |
| 8380 | public static final String POSTAL_ISPRIMARY = "postal_isprimary"; |
| 8381 | |
| 8382 | /** |
| 8383 | * The extra field for an IM handle. |
| 8384 | * <P>Type: String</P> |
| 8385 | */ |
| 8386 | public static final String IM_HANDLE = "im_handle"; |
| 8387 | |
| 8388 | /** |
| 8389 | * The extra field for the IM protocol |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8390 | */ |
| 8391 | public static final String IM_PROTOCOL = "im_protocol"; |
| 8392 | |
| 8393 | /** |
| 8394 | * The extra field for the IM isprimary flag. |
| 8395 | * <P>Type: boolean</P> |
| 8396 | */ |
| 8397 | public static final String IM_ISPRIMARY = "im_isprimary"; |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 8398 | |
| 8399 | /** |
| 8400 | * The extra field that allows the client to supply multiple rows of |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 8401 | * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT} |
| 8402 | * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of |
| 8403 | * {@link ContentValues}, one per data row. Supplying this extra is |
| 8404 | * similar to inserting multiple rows into the {@link Data} table, |
| 8405 | * except the user gets a chance to see and edit them before saving. |
| 8406 | * Each ContentValues object must have a value for {@link Data#MIMETYPE}. |
| 8407 | * If supplied values are not visible in the editor UI, they will be |
| 8408 | * dropped. Duplicate data will dropped. Some fields |
| 8409 | * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically |
| 8410 | * adjusted to comply with the constraints of the specific account type. |
| 8411 | * For example, an Exchange contact can only have one phone numbers of type Home, |
| 8412 | * so the contact editor may choose a different type for this phone number to |
| 8413 | * avoid dropping the valueable part of the row, which is the phone number. |
| 8414 | * <p> |
| 8415 | * Example: |
| 8416 | * <pre> |
| 8417 | * ArrayList<ContentValues> data = new ArrayList<ContentValues>(); |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 8418 | * |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 8419 | * ContentValues row1 = new ContentValues(); |
| 8420 | * row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE); |
| 8421 | * row1.put(Organization.COMPANY, "Android"); |
| 8422 | * data.add(row1); |
| 8423 | * |
| 8424 | * ContentValues row2 = new ContentValues(); |
| 8425 | * row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE); |
| 8426 | * row2.put(Email.TYPE, Email.TYPE_CUSTOM); |
| 8427 | * row2.put(Email.LABEL, "Green Bot"); |
| 8428 | * row2.put(Email.ADDRESS, "android@android.com"); |
| 8429 | * data.add(row2); |
| 8430 | * |
| 8431 | * Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); |
| 8432 | * intent.putParcelableArrayListExtra(Insert.DATA, data); |
| 8433 | * |
| 8434 | * startActivity(intent); |
| 8435 | * </pre> |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 8436 | */ |
| 8437 | public static final String DATA = "data"; |
Daniel Lehmann | cde1ac6 | 2010-10-21 20:40:11 -0700 | [diff] [blame] | 8438 | |
| 8439 | /** |
| 8440 | * Used to specify the account in which to create the new contact. |
| 8441 | * <p> |
| 8442 | * If this value is not provided, the user is presented with a disambiguation |
| 8443 | * dialog to chose an account |
| 8444 | * <p> |
| 8445 | * Type: {@link Account} |
| 8446 | * |
| 8447 | * @hide |
| 8448 | */ |
| 8449 | public static final String ACCOUNT = "com.android.contacts.extra.ACCOUNT"; |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 8450 | |
| 8451 | /** |
| 8452 | * Used to specify the data set within the account in which to create the |
| 8453 | * new contact. |
| 8454 | * <p> |
| 8455 | * This value is optional - if it is not specified, the contact will be |
| 8456 | * created in the base account, with no data set. |
| 8457 | * <p> |
| 8458 | * Type: String |
| 8459 | * |
| 8460 | * @hide |
| 8461 | */ |
| 8462 | public static final String DATA_SET = "com.android.contacts.extra.DATA_SET"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8463 | } |
| 8464 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 8465 | } |