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 | /** |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 828 | * The position at which the contact is pinned. If {@link PinnedPositions.UNPINNED}, |
| 829 | * the contact is not pinned. Also see {@link PinnedPositions}. |
| 830 | * <P>Type: INTEGER </P> |
| 831 | * @hide |
| 832 | */ |
| 833 | public static final String PINNED = "pinned"; |
| 834 | |
| 835 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 836 | * URI for a custom ringtone associated with the contact. If null or missing, |
| 837 | * the default ringtone is used. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 838 | * <P>Type: TEXT (URI to the ringtone)</P> |
| 839 | */ |
| 840 | public static final String CUSTOM_RINGTONE = "custom_ringtone"; |
| 841 | |
| 842 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 843 | * Whether the contact should always be sent to voicemail. If missing, |
| 844 | * defaults to false. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 845 | * <P>Type: INTEGER (0 for false, 1 for true)</P> |
| 846 | */ |
| 847 | public static final String SEND_TO_VOICEMAIL = "send_to_voicemail"; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 848 | } |
| 849 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 850 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 851 | * Columns of {@link ContactsContract.Contacts} that refer to intrinsic |
| 852 | * properties of the contact, as opposed to the user-specified options |
| 853 | * found in {@link ContactOptionsColumns}. |
| 854 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 855 | * @see Contacts |
| 856 | * @see ContactsContract.Data |
| 857 | * @see PhoneLookup |
| 858 | * @see ContactsContract.Contacts.AggregationSuggestions |
| 859 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 860 | protected interface ContactsColumns { |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 861 | /** |
| 862 | * The display name for the contact. |
| 863 | * <P>Type: TEXT</P> |
| 864 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 865 | public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY; |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 866 | |
| 867 | /** |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 868 | * Reference to the row in the RawContacts table holding the contact name. |
| 869 | * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P> |
| 870 | * @hide |
| 871 | */ |
| 872 | public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id"; |
| 873 | |
| 874 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 875 | * Reference to the row in the data table holding the photo. A photo can |
| 876 | * be referred to either by ID (this field) or by URI (see {@link #PHOTO_THUMBNAIL_URI} |
| 877 | * and {@link #PHOTO_URI}). |
| 878 | * If PHOTO_ID is null, consult {@link #PHOTO_URI} or {@link #PHOTO_THUMBNAIL_URI}, |
| 879 | * which is a more generic mechanism for referencing the contact photo, especially for |
| 880 | * contacts returned by non-local directories (see {@link Directory}). |
| 881 | * |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 882 | * <P>Type: INTEGER REFERENCES data(_id)</P> |
| 883 | */ |
| 884 | public static final String PHOTO_ID = "photo_id"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 885 | |
| 886 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 887 | * Photo file ID of the full-size photo. If present, this will be used to populate |
| 888 | * {@link #PHOTO_URI}. The ID can also be used with |
| 889 | * {@link ContactsContract.DisplayPhoto#CONTENT_URI} to create a URI to the photo. |
| 890 | * If this is present, {@link #PHOTO_ID} is also guaranteed to be populated. |
| 891 | * |
| 892 | * <P>Type: INTEGER</P> |
| 893 | */ |
| 894 | public static final String PHOTO_FILE_ID = "photo_file_id"; |
| 895 | |
| 896 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 897 | * 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] | 898 | * If PHOTO_FILE_ID is not null, this will be populated with a URI based off |
| 899 | * {@link ContactsContract.DisplayPhoto#CONTENT_URI}. Otherwise, this will |
| 900 | * be populated with the same value as {@link #PHOTO_THUMBNAIL_URI}. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 901 | * 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] | 902 | * (see {@link #PHOTO_ID}). If either PHOTO_FILE_ID or PHOTO_ID is not null, |
| 903 | * PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily |
| 904 | * vice versa). Thus using PHOTO_URI is a more robust method of retrieving |
| 905 | * contact photos. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 906 | * |
| 907 | * <P>Type: TEXT</P> |
| 908 | */ |
| 909 | public static final String PHOTO_URI = "photo_uri"; |
| 910 | |
| 911 | /** |
| 912 | * A URI that can be used to retrieve a thumbnail of the contact's photo. |
| 913 | * A photo can be referred to either by a URI (this field or {@link #PHOTO_URI}) |
| 914 | * or by ID (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and |
| 915 | * PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa). |
| 916 | * If the content provider does not differentiate between full-size photos |
| 917 | * and thumbnail photos, PHOTO_THUMBNAIL_URI and {@link #PHOTO_URI} can contain |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 918 | * 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] | 919 | * |
| 920 | * <P>Type: TEXT</P> |
| 921 | */ |
| 922 | public static final String PHOTO_THUMBNAIL_URI = "photo_thumb_uri"; |
| 923 | |
| 924 | /** |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 925 | * Flag that reflects the {@link Groups#GROUP_VISIBLE} state of any |
| 926 | * {@link CommonDataKinds.GroupMembership} for this contact. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 927 | */ |
| 928 | public static final String IN_VISIBLE_GROUP = "in_visible_group"; |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 929 | |
| 930 | /** |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 931 | * Flag that reflects whether this contact represents the user's |
| 932 | * personal profile entry. |
| 933 | */ |
| 934 | public static final String IS_USER_PROFILE = "is_user_profile"; |
| 935 | |
| 936 | /** |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 937 | * An indicator of whether this contact has at least one phone number. "1" if there is |
| 938 | * at least one phone number, "0" otherwise. |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 939 | * <P>Type: INTEGER</P> |
| 940 | */ |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 941 | public static final String HAS_PHONE_NUMBER = "has_phone_number"; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 942 | |
| 943 | /** |
| 944 | * An opaque value that contains hints on how to find the contact if |
| 945 | * its row id changed as a result of a sync or aggregation. |
| 946 | */ |
| 947 | public static final String LOOKUP_KEY = "lookup"; |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 948 | |
| 949 | /** |
| 950 | * Timestamp (milliseconds since epoch) of when this contact was last updated. This |
| 951 | * includes updates to all data associated with this contact including raw contacts. Any |
| 952 | * modification (including deletes and inserts) of underlying contact data are also |
| 953 | * reflected in this timestamp. |
| 954 | */ |
| 955 | public static final String CONTACT_LAST_UPDATED_TIMESTAMP = |
| 956 | "contact_last_updated_timestamp"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 957 | } |
| 958 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 959 | /** |
| 960 | * @see Contacts |
| 961 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 962 | protected interface ContactStatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 963 | /** |
| 964 | * Contact presence status. See {@link StatusUpdates} for individual status |
| 965 | * definitions. |
| 966 | * <p>Type: NUMBER</p> |
| 967 | */ |
| 968 | public static final String CONTACT_PRESENCE = "contact_presence"; |
| 969 | |
| 970 | /** |
Vasu Nori | fb5bccf | 2010-07-19 14:11:54 -0700 | [diff] [blame] | 971 | * Contact Chat Capabilities. See {@link StatusUpdates} for individual |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 972 | * definitions. |
| 973 | * <p>Type: NUMBER</p> |
| 974 | */ |
| 975 | public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability"; |
| 976 | |
| 977 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 978 | * Contact's latest status update. |
| 979 | * <p>Type: TEXT</p> |
| 980 | */ |
| 981 | public static final String CONTACT_STATUS = "contact_status"; |
| 982 | |
| 983 | /** |
| 984 | * The absolute time in milliseconds when the latest status was |
| 985 | * inserted/updated. |
| 986 | * <p>Type: NUMBER</p> |
| 987 | */ |
| 988 | public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts"; |
| 989 | |
| 990 | /** |
| 991 | * The package containing resources for this status: label and icon. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 992 | * <p>Type: TEXT</p> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 993 | */ |
| 994 | public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package"; |
| 995 | |
| 996 | /** |
| 997 | * The resource ID of the label describing the source of contact |
| 998 | * status, e.g. "Google Talk". This resource is scoped by the |
| 999 | * {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 1000 | * <p>Type: NUMBER</p> |
| 1001 | */ |
| 1002 | public static final String CONTACT_STATUS_LABEL = "contact_status_label"; |
| 1003 | |
| 1004 | /** |
| 1005 | * The resource ID of the icon for the source of contact status. This |
| 1006 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 1007 | * <p>Type: NUMBER</p> |
| 1008 | */ |
| 1009 | public static final String CONTACT_STATUS_ICON = "contact_status_icon"; |
| 1010 | } |
| 1011 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1012 | /** |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1013 | * Constants for various styles of combining given name, family name etc into |
| 1014 | * a full name. For example, the western tradition follows the pattern |
| 1015 | * 'given name' 'middle name' 'family name' with the alternative pattern being |
| 1016 | * 'family name', 'given name' 'middle name'. The CJK tradition is |
| 1017 | * 'family name' 'middle name' 'given name', with Japanese favoring a space between |
| 1018 | * the names and Chinese omitting the space. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1019 | */ |
| 1020 | public interface FullNameStyle { |
| 1021 | public static final int UNDEFINED = 0; |
| 1022 | public static final int WESTERN = 1; |
| 1023 | |
| 1024 | /** |
| 1025 | * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine |
| 1026 | * which specific language it belongs to: Chinese, Japanese or Korean. |
| 1027 | */ |
| 1028 | public static final int CJK = 2; |
| 1029 | |
| 1030 | public static final int CHINESE = 3; |
| 1031 | public static final int JAPANESE = 4; |
| 1032 | public static final int KOREAN = 5; |
| 1033 | } |
| 1034 | |
| 1035 | /** |
| 1036 | * 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] | 1037 | */ |
| 1038 | public interface PhoneticNameStyle { |
| 1039 | public static final int UNDEFINED = 0; |
| 1040 | |
| 1041 | /** |
| 1042 | * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly |
| 1043 | * shown in UIs, but used for searches and sorting. |
| 1044 | */ |
| 1045 | public static final int PINYIN = 3; |
| 1046 | |
| 1047 | /** |
| 1048 | * Hiragana and Katakana are two common styles of writing out the pronunciation |
| 1049 | * of a Japanese names. |
| 1050 | */ |
| 1051 | public static final int JAPANESE = 4; |
| 1052 | |
| 1053 | /** |
| 1054 | * Hangul is the Korean phonetic alphabet. |
| 1055 | */ |
| 1056 | public static final int KOREAN = 5; |
| 1057 | } |
| 1058 | |
| 1059 | /** |
Dmitri Plotnikov | dbcdbf2 | 2011-02-23 15:49:58 -0800 | [diff] [blame] | 1060 | * Types of data used to produce the display name for a contact. In the order |
| 1061 | * of increasing priority: {@link #EMAIL}, {@link #PHONE}, |
| 1062 | * {@link #ORGANIZATION}, {@link #NICKNAME}, {@link #STRUCTURED_NAME}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1063 | */ |
| 1064 | public interface DisplayNameSources { |
| 1065 | public static final int UNDEFINED = 0; |
| 1066 | public static final int EMAIL = 10; |
| 1067 | public static final int PHONE = 20; |
| 1068 | public static final int ORGANIZATION = 30; |
| 1069 | public static final int NICKNAME = 35; |
| 1070 | public static final int STRUCTURED_NAME = 40; |
| 1071 | } |
| 1072 | |
| 1073 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 1074 | * Contact name and contact name metadata columns in the RawContacts table. |
| 1075 | * |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1076 | * @see Contacts |
| 1077 | * @see RawContacts |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1078 | */ |
| 1079 | protected interface ContactNameColumns { |
| 1080 | |
| 1081 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1082 | * 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] | 1083 | * structured name or email address. See {@link DisplayNameSources}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1084 | */ |
| 1085 | public static final String DISPLAY_NAME_SOURCE = "display_name_source"; |
| 1086 | |
| 1087 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1088 | * <p> |
| 1089 | * The standard text shown as the contact's display name, based on the best |
| 1090 | * available information for the contact (for example, it might be the email address |
| 1091 | * if the name is not available). |
| 1092 | * The information actually used to compute the name is stored in |
| 1093 | * {@link #DISPLAY_NAME_SOURCE}. |
| 1094 | * </p> |
| 1095 | * <p> |
| 1096 | * A contacts provider is free to choose whatever representation makes most |
| 1097 | * sense for its target market. |
| 1098 | * For example in the default Android Open Source Project implementation, |
| 1099 | * if the display name is |
| 1100 | * based on the structured name and the structured name follows |
| 1101 | * the Western full-name style, then this field contains the "given name first" |
| 1102 | * version of the full name. |
| 1103 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1104 | * |
| 1105 | * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1106 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1107 | public static final String DISPLAY_NAME_PRIMARY = "display_name"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1108 | |
| 1109 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1110 | * <p> |
| 1111 | * An alternative representation of the display name, such as "family name first" |
| 1112 | * instead of "given name first" for Western names. If an alternative is not |
| 1113 | * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}. |
| 1114 | * </p> |
| 1115 | * <p> |
| 1116 | * A contacts provider is free to provide alternatives as necessary for |
| 1117 | * its target market. |
| 1118 | * For example the default Android Open Source Project contacts provider |
| 1119 | * currently provides an |
| 1120 | * alternative in a single case: if the display name is |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1121 | * based on the structured name and the structured name follows |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1122 | * the Western full name style, then the field contains the "family name first" |
| 1123 | * version of the full name. |
| 1124 | * Other cases may be added later. |
| 1125 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1126 | */ |
| 1127 | public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt"; |
| 1128 | |
| 1129 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1130 | * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}. See |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 1131 | * {@link PhoneticNameStyle}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1132 | */ |
| 1133 | public static final String PHONETIC_NAME_STYLE = "phonetic_name_style"; |
| 1134 | |
| 1135 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1136 | * <p> |
| 1137 | * Pronunciation of the full name in the phonetic alphabet specified by |
| 1138 | * {@link #PHONETIC_NAME_STYLE}. |
| 1139 | * </p> |
| 1140 | * <p> |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 1141 | * The value may be set manually by the user. This capability is of |
| 1142 | * interest only in countries with commonly used phonetic alphabets, |
| 1143 | * such as Japan and Korea. See {@link PhoneticNameStyle}. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1144 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1145 | */ |
| 1146 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 1147 | |
| 1148 | /** |
| 1149 | * Sort key that takes into account locale-based traditions for sorting |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1150 | * names in address books. The default |
| 1151 | * sort key is {@link #DISPLAY_NAME_PRIMARY}. For Chinese names |
| 1152 | * 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] | 1153 | * it is the Hiragana version of the phonetic name. |
| 1154 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1155 | public static final String SORT_KEY_PRIMARY = "sort_key"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1156 | |
| 1157 | /** |
| 1158 | * Sort key based on the alternative representation of the full name, |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1159 | * {@link #DISPLAY_NAME_ALTERNATIVE}. Thus for Western names, |
Dmitri Plotnikov | 2a650dd | 2010-01-26 17:28:52 -0800 | [diff] [blame] | 1160 | * it is the one using the "family name first" format. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1161 | */ |
| 1162 | public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt"; |
| 1163 | } |
| 1164 | |
| 1165 | /** |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1166 | * URI parameter and cursor extras that return counts of rows grouped by the |
| 1167 | * address book index, which is usually the first letter of the sort key. |
| 1168 | * When this parameter is supplied, the row counts are returned in the |
| 1169 | * cursor extras bundle. |
| 1170 | * |
| 1171 | * @hide |
| 1172 | */ |
| 1173 | public final static class ContactCounts { |
| 1174 | |
| 1175 | /** |
| 1176 | * Add this query parameter to a URI to get back row counts grouped by |
| 1177 | * the address book index as cursor extras. For most languages it is the |
| 1178 | * first letter of the sort key. This parameter does not affect the main |
| 1179 | * content of the cursor. |
| 1180 | * |
| 1181 | * @hide |
| 1182 | */ |
| 1183 | public static final String ADDRESS_BOOK_INDEX_EXTRAS = "address_book_index_extras"; |
| 1184 | |
| 1185 | /** |
| 1186 | * The array of address book index titles, which are returned in the |
| 1187 | * same order as the data in the cursor. |
| 1188 | * <p>TYPE: String[]</p> |
| 1189 | * |
| 1190 | * @hide |
| 1191 | */ |
| 1192 | public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "address_book_index_titles"; |
| 1193 | |
| 1194 | /** |
| 1195 | * The array of group counts for the corresponding group. Contains the same number |
| 1196 | * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array. |
| 1197 | * <p>TYPE: int[]</p> |
| 1198 | * |
| 1199 | * @hide |
| 1200 | */ |
| 1201 | public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "address_book_index_counts"; |
| 1202 | } |
| 1203 | |
| 1204 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1205 | * Constants for the contacts table, which contains a record per aggregate |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1206 | * of raw contacts representing the same person. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1207 | * <h3>Operations</h3> |
| 1208 | * <dl> |
| 1209 | * <dt><b>Insert</b></dt> |
| 1210 | * <dd>A Contact cannot be created explicitly. When a raw contact is |
| 1211 | * inserted, the provider will first try to find a Contact representing the |
| 1212 | * same person. If one is found, the raw contact's |
| 1213 | * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate |
| 1214 | * Contact. If no match is found, the provider automatically inserts a new |
| 1215 | * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column |
| 1216 | * of the newly inserted raw contact.</dd> |
| 1217 | * <dt><b>Update</b></dt> |
| 1218 | * <dd>Only certain columns of Contact are modifiable: |
| 1219 | * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED}, |
| 1220 | * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of |
| 1221 | * these columns on the Contact also changes them on all constituent raw |
| 1222 | * contacts.</dd> |
| 1223 | * <dt><b>Delete</b></dt> |
| 1224 | * <dd>Be careful with deleting Contacts! Deleting an aggregate contact |
| 1225 | * deletes all constituent raw contacts. The corresponding sync adapters |
| 1226 | * will notice the deletions of their respective raw contacts and remove |
| 1227 | * them from their back end storage.</dd> |
| 1228 | * <dt><b>Query</b></dt> |
| 1229 | * <dd> |
| 1230 | * <ul> |
| 1231 | * <li>If you need to read an individual contact, consider using |
| 1232 | * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li> |
| 1233 | * <li>If you need to look up a contact by the phone number, use |
| 1234 | * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI}, |
| 1235 | * which is optimized for this purpose.</li> |
| 1236 | * <li>If you need to look up a contact by partial name, e.g. to produce |
| 1237 | * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI. |
| 1238 | * <li>If you need to look up a contact by some data element like email |
| 1239 | * address, nickname, etc, use a query against the {@link ContactsContract.Data} table. |
| 1240 | * The result will contain contact ID, name etc. |
| 1241 | * </ul> |
| 1242 | * </dd> |
| 1243 | * </dl> |
| 1244 | * <h2>Columns</h2> |
| 1245 | * <table class="jd-sumtable"> |
| 1246 | * <tr> |
| 1247 | * <th colspan='4'>Contacts</th> |
| 1248 | * </tr> |
| 1249 | * <tr> |
| 1250 | * <td>long</td> |
| 1251 | * <td>{@link #_ID}</td> |
| 1252 | * <td>read-only</td> |
| 1253 | * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td> |
| 1254 | * </tr> |
| 1255 | * <tr> |
| 1256 | * <td>String</td> |
| 1257 | * <td>{@link #LOOKUP_KEY}</td> |
| 1258 | * <td>read-only</td> |
| 1259 | * <td>An opaque value that contains hints on how to find the contact if its |
| 1260 | * row id changed as a result of a sync or aggregation.</td> |
| 1261 | * </tr> |
| 1262 | * <tr> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1263 | * <td>long</td> |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1264 | * <td>NAME_RAW_CONTACT_ID</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1265 | * <td>read-only</td> |
| 1266 | * <td>The ID of the raw contact that contributes the display name |
| 1267 | * to the aggregate contact. During aggregation one of the constituent |
| 1268 | * raw contacts is chosen using a heuristic: a longer name or a name |
| 1269 | * with more diacritic marks or more upper case characters is chosen.</td> |
| 1270 | * </tr> |
| 1271 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1272 | * <td>String</td> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1273 | * <td>DISPLAY_NAME_PRIMARY</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1274 | * <td>read-only</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1275 | * <td>The display name for the contact. It is the display name |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1276 | * 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] | 1277 | * column.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1278 | * </tr> |
| 1279 | * <tr> |
| 1280 | * <td>long</td> |
| 1281 | * <td>{@link #PHOTO_ID}</td> |
| 1282 | * <td>read-only</td> |
| 1283 | * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo. |
| 1284 | * That row has the mime type |
| 1285 | * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field |
| 1286 | * is computed automatically based on the |
| 1287 | * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of |
| 1288 | * that mime type.</td> |
| 1289 | * </tr> |
| 1290 | * <tr> |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 1291 | * <td>long</td> |
| 1292 | * <td>{@link #PHOTO_URI}</td> |
| 1293 | * <td>read-only</td> |
| 1294 | * <td>A URI that can be used to retrieve the contact's full-size photo. This |
| 1295 | * column is the preferred method of retrieving the contact photo.</td> |
| 1296 | * </tr> |
| 1297 | * <tr> |
| 1298 | * <td>long</td> |
| 1299 | * <td>{@link #PHOTO_THUMBNAIL_URI}</td> |
| 1300 | * <td>read-only</td> |
| 1301 | * <td>A URI that can be used to retrieve the thumbnail of contact's photo. This |
| 1302 | * column is the preferred method of retrieving the contact photo.</td> |
| 1303 | * </tr> |
| 1304 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1305 | * <td>int</td> |
| 1306 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 1307 | * <td>read-only</td> |
| 1308 | * <td>An indicator of whether this contact is supposed to be visible in the |
| 1309 | * UI. "1" if the contact has at least one raw contact that belongs to a |
| 1310 | * visible group; "0" otherwise.</td> |
| 1311 | * </tr> |
| 1312 | * <tr> |
| 1313 | * <td>int</td> |
| 1314 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 1315 | * <td>read-only</td> |
| 1316 | * <td>An indicator of whether this contact has at least one phone number. |
| 1317 | * "1" if there is at least one phone number, "0" otherwise.</td> |
| 1318 | * </tr> |
| 1319 | * <tr> |
| 1320 | * <td>int</td> |
| 1321 | * <td>{@link #TIMES_CONTACTED}</td> |
| 1322 | * <td>read/write</td> |
| 1323 | * <td>The number of times the contact has been contacted. See |
| 1324 | * {@link #markAsContacted}. When raw contacts are aggregated, this field is |
| 1325 | * computed automatically as the maximum number of times contacted among all |
| 1326 | * constituent raw contacts. Setting this field automatically changes the |
| 1327 | * corresponding field on all constituent raw contacts.</td> |
| 1328 | * </tr> |
| 1329 | * <tr> |
| 1330 | * <td>long</td> |
| 1331 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 1332 | * <td>read/write</td> |
| 1333 | * <td>The timestamp of the last time the contact was contacted. See |
| 1334 | * {@link #markAsContacted}. Setting this field also automatically |
| 1335 | * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated, |
| 1336 | * this field is computed automatically as the latest time contacted of all |
| 1337 | * constituent raw contacts. Setting this field automatically changes the |
| 1338 | * corresponding field on all constituent raw contacts.</td> |
| 1339 | * </tr> |
| 1340 | * <tr> |
| 1341 | * <td>int</td> |
| 1342 | * <td>{@link #STARRED}</td> |
| 1343 | * <td>read/write</td> |
| 1344 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
| 1345 | * When raw contacts are aggregated, this field is automatically computed: |
| 1346 | * if any constituent raw contacts are starred, then this field is set to |
| 1347 | * '1'. Setting this field automatically changes the corresponding field on |
| 1348 | * all constituent raw contacts.</td> |
| 1349 | * </tr> |
| 1350 | * <tr> |
| 1351 | * <td>String</td> |
| 1352 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 1353 | * <td>read/write</td> |
| 1354 | * <td>A custom ringtone associated with a contact. Typically this is the |
| 1355 | * URI returned by an activity launched with the |
| 1356 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td> |
| 1357 | * </tr> |
| 1358 | * <tr> |
| 1359 | * <td>int</td> |
| 1360 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 1361 | * <td>read/write</td> |
| 1362 | * <td>An indicator of whether calls from this contact should be forwarded |
| 1363 | * directly to voice mail ('1') or not ('0'). When raw contacts are |
| 1364 | * aggregated, this field is automatically computed: if <i>all</i> |
| 1365 | * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set |
| 1366 | * to '1'. Setting this field automatically changes the corresponding field |
| 1367 | * on all constituent raw contacts.</td> |
| 1368 | * </tr> |
| 1369 | * <tr> |
| 1370 | * <td>int</td> |
| 1371 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 1372 | * <td>read-only</td> |
| 1373 | * <td>Contact IM presence status. See {@link StatusUpdates} for individual |
| 1374 | * status definitions. Automatically computed as the highest presence of all |
| 1375 | * constituent raw contacts. The provider may choose not to store this value |
| 1376 | * in persistent storage. The expectation is that presence status will be |
kmccormick | 50e27c8 | 2013-03-28 16:33:11 -0700 | [diff] [blame] | 1377 | * updated on a regular basis.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1378 | * </tr> |
| 1379 | * <tr> |
| 1380 | * <td>String</td> |
| 1381 | * <td>{@link #CONTACT_STATUS}</td> |
| 1382 | * <td>read-only</td> |
| 1383 | * <td>Contact's latest status update. Automatically computed as the latest |
| 1384 | * of all constituent raw contacts' status updates.</td> |
| 1385 | * </tr> |
| 1386 | * <tr> |
| 1387 | * <td>long</td> |
| 1388 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 1389 | * <td>read-only</td> |
| 1390 | * <td>The absolute time in milliseconds when the latest status was |
| 1391 | * inserted/updated.</td> |
| 1392 | * </tr> |
| 1393 | * <tr> |
| 1394 | * <td>String</td> |
| 1395 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 1396 | * <td>read-only</td> |
| 1397 | * <td> The package containing resources for this status: label and icon.</td> |
| 1398 | * </tr> |
| 1399 | * <tr> |
| 1400 | * <td>long</td> |
| 1401 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 1402 | * <td>read-only</td> |
| 1403 | * <td>The resource ID of the label describing the source of contact status, |
| 1404 | * e.g. "Google Talk". This resource is scoped by the |
| 1405 | * {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1406 | * </tr> |
| 1407 | * <tr> |
| 1408 | * <td>long</td> |
| 1409 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 1410 | * <td>read-only</td> |
| 1411 | * <td>The resource ID of the icon for the source of contact status. This |
| 1412 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1413 | * </tr> |
| 1414 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1415 | */ |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 1416 | public static class Contacts implements BaseColumns, ContactsColumns, |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1417 | ContactOptionsColumns, ContactNameColumns, ContactStatusColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1418 | /** |
| 1419 | * This utility class cannot be instantiated |
| 1420 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1421 | private Contacts() {} |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1422 | |
| 1423 | /** |
| 1424 | * The content:// style URI for this table |
| 1425 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1426 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1427 | |
| 1428 | /** |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1429 | * A content:// style URI for this table that should be used to create |
| 1430 | * shortcuts or otherwise create long-term links to contacts. This URI |
| 1431 | * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}. |
| 1432 | * It can optionally also have a "/" and last known contact ID appended after |
| 1433 | * that. This "complete" format is an important optimization and is highly recommended. |
| 1434 | * <p> |
| 1435 | * As long as the contact's row ID remains the same, this URI is |
| 1436 | * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes |
| 1437 | * as a result of a sync or aggregation, this URI will look up the |
| 1438 | * contact using indirect information (sync IDs or constituent raw |
| 1439 | * contacts). |
| 1440 | * <p> |
| 1441 | * Lookup key should be appended unencoded - it is stored in the encoded |
| 1442 | * form, ready for use in a URI. |
| 1443 | */ |
| 1444 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1445 | "lookup"); |
| 1446 | |
| 1447 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1448 | * Base {@link Uri} for referencing a single {@link Contacts} entry, |
Jeff Sharkey | 8f76734 | 2009-09-28 18:22:46 -0700 | [diff] [blame] | 1449 | * created by appending {@link #LOOKUP_KEY} using |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1450 | * {@link Uri#withAppendedPath(Uri, String)}. Provides |
| 1451 | * {@link OpenableColumns} columns when queried, or returns the |
| 1452 | * referenced contact formatted as a vCard when opened through |
| 1453 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1454 | */ |
| 1455 | public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1456 | "as_vcard"); |
| 1457 | |
Martijn Coenen | 037d3ff | 2011-06-15 16:01:45 +0200 | [diff] [blame] | 1458 | /** |
| 1459 | * Boolean parameter that may be used with {@link #CONTENT_VCARD_URI} |
| 1460 | * and {@link #CONTENT_MULTI_VCARD_URI} to indicate that the returned |
| 1461 | * vcard should not contain a photo. |
| 1462 | * |
| 1463 | * @hide |
| 1464 | */ |
| 1465 | public static final String QUERY_PARAMETER_VCARD_NO_PHOTO = "nophoto"; |
| 1466 | |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1467 | /** |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1468 | * Base {@link Uri} for referencing multiple {@link Contacts} entry, |
| 1469 | * created by appending {@link #LOOKUP_KEY} using |
| 1470 | * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 1471 | * encoded and joined with the colon (":") separator. The resulting string |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1472 | * has to be encoded again. Provides |
| 1473 | * {@link OpenableColumns} columns when queried, or returns the |
| 1474 | * referenced contact formatted as a vCard when opened through |
| 1475 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1476 | * |
| 1477 | * This is private API because we do not have a well-defined way to |
| 1478 | * specify several entities yet. The format of this Uri might change in the future |
| 1479 | * or the Uri might be completely removed. |
| 1480 | * |
| 1481 | * @hide |
| 1482 | */ |
| 1483 | public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1484 | "as_multi_vcard"); |
| 1485 | |
| 1486 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1487 | * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the |
| 1488 | * requested {@link Contacts} entry. |
| 1489 | * |
| 1490 | * @param contactUri A {@link #CONTENT_URI} row, or an existing |
| 1491 | * {@link #CONTENT_LOOKUP_URI} to attempt refreshing. |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1492 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1493 | public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) { |
| 1494 | final Cursor c = resolver.query(contactUri, new String[] { |
| 1495 | Contacts.LOOKUP_KEY, Contacts._ID |
| 1496 | }, null, null, null); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1497 | if (c == null) { |
| 1498 | return null; |
| 1499 | } |
| 1500 | |
| 1501 | try { |
| 1502 | if (c.moveToFirst()) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1503 | final String lookupKey = c.getString(0); |
| 1504 | final long contactId = c.getLong(1); |
| 1505 | return getLookupUri(contactId, lookupKey); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1506 | } |
| 1507 | } finally { |
| 1508 | c.close(); |
| 1509 | } |
| 1510 | return null; |
| 1511 | } |
| 1512 | |
| 1513 | /** |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1514 | * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1515 | * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}. |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1516 | */ |
| 1517 | public static Uri getLookupUri(long contactId, String lookupKey) { |
| 1518 | return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, |
| 1519 | lookupKey), contactId); |
| 1520 | } |
| 1521 | |
| 1522 | /** |
Dmitri Plotnikov | b5759b5 | 2009-09-01 15:58:40 -0700 | [diff] [blame] | 1523 | * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI. |
| 1524 | * <p> |
| 1525 | * Returns null if the contact cannot be found. |
| 1526 | */ |
| 1527 | public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) { |
| 1528 | if (lookupUri == null) { |
| 1529 | return null; |
| 1530 | } |
| 1531 | |
| 1532 | Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null); |
| 1533 | if (c == null) { |
| 1534 | return null; |
| 1535 | } |
| 1536 | |
| 1537 | try { |
| 1538 | if (c.moveToFirst()) { |
| 1539 | long contactId = c.getLong(0); |
| 1540 | return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1541 | } |
| 1542 | } finally { |
| 1543 | c.close(); |
| 1544 | } |
| 1545 | return null; |
| 1546 | } |
| 1547 | |
| 1548 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1549 | * Mark a contact as having been contacted. Updates two fields: |
| 1550 | * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED}. The |
| 1551 | * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED |
| 1552 | * field is populated with the current system time. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1553 | * |
| 1554 | * @param resolver the ContentResolver to use |
| 1555 | * @param contactId the person who was contacted |
Daniel Lehmann | a1620dc | 2012-04-13 13:29:49 -0700 | [diff] [blame] | 1556 | * |
| 1557 | * @deprecated The class DataUsageStatUpdater of the Android support library should |
| 1558 | * be used instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1559 | */ |
Daniel Lehmann | a1620dc | 2012-04-13 13:29:49 -0700 | [diff] [blame] | 1560 | @Deprecated |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1561 | public static void markAsContacted(ContentResolver resolver, long contactId) { |
| 1562 | Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId); |
| 1563 | ContentValues values = new ContentValues(); |
| 1564 | // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified. |
| 1565 | values.put(LAST_TIME_CONTACTED, System.currentTimeMillis()); |
| 1566 | resolver.update(uri, values, null, null); |
| 1567 | } |
| 1568 | |
| 1569 | /** |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1570 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1571 | * {@link #CONTENT_URI} URI. The filter string will be used to match |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1572 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1573 | * as an additional path segment after this URI. |
| 1574 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1575 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 1576 | CONTENT_URI, "filter"); |
| 1577 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1578 | /** |
| 1579 | * The content:// style URI for this table joined with useful data from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1580 | * {@link ContactsContract.Data}, filtered to include only starred contacts |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1581 | * and the most frequently contacted contacts. |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1582 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1583 | public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath( |
| 1584 | CONTENT_URI, "strequent"); |
| 1585 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1586 | /** |
Daisuke Miyakawa | 3604bc5 | 2011-07-21 10:14:32 -0700 | [diff] [blame] | 1587 | * The content:// style URI for showing frequently contacted person listing. |
| 1588 | * @hide |
| 1589 | */ |
| 1590 | public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath( |
| 1591 | CONTENT_URI, "frequent"); |
| 1592 | |
| 1593 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1594 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1595 | * {@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] | 1596 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1597 | * as an additional path segment after this URI. |
| 1598 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1599 | public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath( |
| 1600 | CONTENT_STREQUENT_URI, "filter"); |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1601 | |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1602 | public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath( |
| 1603 | CONTENT_URI, "group"); |
| 1604 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1605 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1606 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 1607 | * people. |
| 1608 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1609 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1610 | |
| 1611 | /** |
| 1612 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1613 | * person. |
| 1614 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1615 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1616 | |
| 1617 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1618 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1619 | * person. |
| 1620 | */ |
| 1621 | public static final String CONTENT_VCARD_TYPE = "text/x-vcard"; |
| 1622 | |
| 1623 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1624 | * 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] | 1625 | * {@link ContactsContract.Data} rows. This directory can be used either |
| 1626 | * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1627 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1628 | public static final class Data implements BaseColumns, DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1629 | /** |
| 1630 | * no public constructor since this is a utility class |
| 1631 | */ |
| 1632 | private Data() {} |
| 1633 | |
| 1634 | /** |
| 1635 | * The directory twig for this sub-table |
| 1636 | */ |
| 1637 | public static final String CONTENT_DIRECTORY = "data"; |
| 1638 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1639 | |
| 1640 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1641 | * <p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1642 | * A sub-directory of a contact that contains all of its |
| 1643 | * {@link ContactsContract.RawContacts} as well as |
| 1644 | * {@link ContactsContract.Data} rows. To access this directory append |
| 1645 | * {@link #CONTENT_DIRECTORY} to the contact URI. |
| 1646 | * </p> |
| 1647 | * <p> |
| 1648 | * Entity has three ID fields: {@link #CONTACT_ID} for the contact, |
| 1649 | * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for |
| 1650 | * the data rows. Entity always contains at least one row per |
| 1651 | * constituent raw contact, even if there are no actual data rows. In |
| 1652 | * this case the {@link #DATA_ID} field will be null. |
| 1653 | * </p> |
| 1654 | * <p> |
| 1655 | * Entity reads all data for the entire contact in one transaction, to |
| 1656 | * guarantee consistency. There is significant data duplication |
| 1657 | * in the Entity (each row repeats all Contact columns and all RawContact |
| 1658 | * columns), so the benefits of transactional consistency should be weighed |
| 1659 | * against the cost of transferring large amounts of denormalized data |
| 1660 | * from the Provider. |
| 1661 | * </p> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 1662 | * <p> |
| 1663 | * To reduce the amount of data duplication the contacts provider and directory |
| 1664 | * providers implementing this protocol are allowed to provide common Contacts |
| 1665 | * and RawContacts fields in the first row returned for each raw contact only and |
| 1666 | * leave them as null in subsequent rows. |
| 1667 | * </p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1668 | */ |
| 1669 | public static final class Entity implements BaseColumns, ContactsColumns, |
| 1670 | ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns, |
| 1671 | StatusColumns, ContactOptionsColumns, ContactStatusColumns { |
| 1672 | /** |
| 1673 | * no public constructor since this is a utility class |
| 1674 | */ |
| 1675 | private Entity() { |
| 1676 | } |
| 1677 | |
| 1678 | /** |
| 1679 | * The directory twig for this sub-table |
| 1680 | */ |
| 1681 | public static final String CONTENT_DIRECTORY = "entities"; |
| 1682 | |
| 1683 | /** |
| 1684 | * The ID of the raw contact row. |
| 1685 | * <P>Type: INTEGER</P> |
| 1686 | */ |
| 1687 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 1688 | |
| 1689 | /** |
| 1690 | * The ID of the data row. The value will be null if this raw contact has no |
| 1691 | * data rows. |
| 1692 | * <P>Type: INTEGER</P> |
| 1693 | */ |
| 1694 | public static final String DATA_ID = "data_id"; |
| 1695 | } |
| 1696 | |
| 1697 | /** |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 1698 | * <p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1699 | * A sub-directory of a single contact that contains all of the constituent raw contact |
| 1700 | * {@link ContactsContract.StreamItems} rows. This directory can be used either |
| 1701 | * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}. |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 1702 | * </p> |
| 1703 | * <p> |
| 1704 | * Querying for social stream data requires android.permission.READ_SOCIAL_STREAM |
| 1705 | * permission. |
| 1706 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1707 | */ |
| 1708 | public static final class StreamItems implements StreamItemsColumns { |
| 1709 | /** |
| 1710 | * no public constructor since this is a utility class |
| 1711 | */ |
| 1712 | private StreamItems() {} |
| 1713 | |
| 1714 | /** |
| 1715 | * The directory twig for this sub-table |
| 1716 | */ |
| 1717 | public static final String CONTENT_DIRECTORY = "stream_items"; |
| 1718 | } |
| 1719 | |
| 1720 | /** |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1721 | * <p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1722 | * A <i>read-only</i> sub-directory of a single contact aggregate that |
| 1723 | * contains all aggregation suggestions (other contacts). The |
| 1724 | * aggregation suggestions are computed based on approximate data |
| 1725 | * matches with this contact. |
| 1726 | * </p> |
| 1727 | * <p> |
| 1728 | * <i>Note: this query may be expensive! If you need to use it in bulk, |
| 1729 | * make sure the user experience is acceptable when the query runs for a |
| 1730 | * long time.</i> |
| 1731 | * <p> |
| 1732 | * Usage example: |
| 1733 | * |
| 1734 | * <pre> |
| 1735 | * Uri uri = Contacts.CONTENT_URI.buildUpon() |
| 1736 | * .appendEncodedPath(String.valueOf(contactId)) |
| 1737 | * .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY) |
| 1738 | * .appendQueryParameter("limit", "3") |
| 1739 | * .build() |
| 1740 | * Cursor cursor = getContentResolver().query(suggestionsUri, |
| 1741 | * new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY}, |
| 1742 | * null, null, null); |
| 1743 | * </pre> |
| 1744 | * |
| 1745 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1746 | * <p> |
| 1747 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 1748 | * {@link #CONTENT_LOOKUP_URI}. |
| 1749 | * </p> |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1750 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1751 | public static final class AggregationSuggestions implements BaseColumns, ContactsColumns, |
| 1752 | ContactOptionsColumns, ContactStatusColumns { |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1753 | /** |
| 1754 | * No public constructor since this is a utility class |
| 1755 | */ |
| 1756 | private AggregationSuggestions() {} |
| 1757 | |
| 1758 | /** |
Dmitri Plotnikov | 0fc0244 | 2009-09-21 13:26:28 -0700 | [diff] [blame] | 1759 | * 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] | 1760 | * type-to-filter, similar to |
| 1761 | * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}. |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1762 | */ |
| 1763 | public static final String CONTENT_DIRECTORY = "suggestions"; |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 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_NAME = "name"; |
| 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_EMAIL = "email"; |
| 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_PHONE = "phone"; |
| 1788 | |
| 1789 | /** |
| 1790 | * Used with {@link Builder#addParameter} to specify what kind of data is |
| 1791 | * supplied for the suggestion query. |
| 1792 | * |
| 1793 | * @hide |
| 1794 | */ |
| 1795 | public static final String PARAMETER_MATCH_NICKNAME = "nickname"; |
| 1796 | |
| 1797 | /** |
| 1798 | * A convenience builder for aggregation suggestion content URIs. |
| 1799 | * |
| 1800 | * TODO: change documentation for this class to use the builder. |
| 1801 | * @hide |
| 1802 | */ |
| 1803 | public static final class Builder { |
| 1804 | private long mContactId; |
| 1805 | private ArrayList<String> mKinds = new ArrayList<String>(); |
| 1806 | private ArrayList<String> mValues = new ArrayList<String>(); |
| 1807 | private int mLimit; |
| 1808 | |
| 1809 | /** |
| 1810 | * Optional existing contact ID. If it is not provided, the search |
| 1811 | * will be based exclusively on the values supplied with {@link #addParameter}. |
| 1812 | */ |
| 1813 | public Builder setContactId(long contactId) { |
| 1814 | this.mContactId = contactId; |
| 1815 | return this; |
| 1816 | } |
| 1817 | |
| 1818 | /** |
| 1819 | * A value that can be used when searching for an aggregation |
| 1820 | * suggestion. |
| 1821 | * |
| 1822 | * @param kind can be one of |
| 1823 | * {@link AggregationSuggestions#PARAMETER_MATCH_NAME}, |
| 1824 | * {@link AggregationSuggestions#PARAMETER_MATCH_EMAIL}, |
| 1825 | * {@link AggregationSuggestions#PARAMETER_MATCH_NICKNAME}, |
| 1826 | * {@link AggregationSuggestions#PARAMETER_MATCH_PHONE} |
| 1827 | */ |
| 1828 | public Builder addParameter(String kind, String value) { |
| 1829 | if (!TextUtils.isEmpty(value)) { |
| 1830 | mKinds.add(kind); |
| 1831 | mValues.add(value); |
| 1832 | } |
| 1833 | return this; |
| 1834 | } |
| 1835 | |
| 1836 | public Builder setLimit(int limit) { |
| 1837 | mLimit = limit; |
| 1838 | return this; |
| 1839 | } |
| 1840 | |
| 1841 | public Uri build() { |
| 1842 | android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon(); |
| 1843 | builder.appendEncodedPath(String.valueOf(mContactId)); |
| 1844 | builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY); |
| 1845 | if (mLimit != 0) { |
| 1846 | builder.appendQueryParameter("limit", String.valueOf(mLimit)); |
| 1847 | } |
| 1848 | |
| 1849 | int count = mKinds.size(); |
| 1850 | for (int i = 0; i < count; i++) { |
| 1851 | builder.appendQueryParameter("query", mKinds.get(i) + ":" + mValues.get(i)); |
| 1852 | } |
| 1853 | |
| 1854 | return builder.build(); |
| 1855 | } |
| 1856 | } |
| 1857 | |
| 1858 | /** |
| 1859 | * @hide |
| 1860 | */ |
| 1861 | public static final Builder builder() { |
| 1862 | return new Builder(); |
| 1863 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1864 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1865 | |
| 1866 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1867 | * 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] | 1868 | * the contact's primary photo. The photo may be stored in up to two ways - |
| 1869 | * the default "photo" is a thumbnail-sized image stored directly in the data |
| 1870 | * row, while the "display photo", if present, is a larger version stored as |
| 1871 | * a file. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1872 | * <p> |
| 1873 | * Usage example: |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1874 | * <dl> |
| 1875 | * <dt>Retrieving the thumbnail-sized photo</dt> |
| 1876 | * <dd> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1877 | * <pre> |
| 1878 | * public InputStream openPhoto(long contactId) { |
| 1879 | * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1880 | * Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY); |
| 1881 | * Cursor cursor = getContentResolver().query(photoUri, |
| 1882 | * new String[] {Contacts.Photo.PHOTO}, null, null, null); |
| 1883 | * if (cursor == null) { |
| 1884 | * return null; |
| 1885 | * } |
| 1886 | * try { |
| 1887 | * if (cursor.moveToFirst()) { |
| 1888 | * byte[] data = cursor.getBlob(0); |
| 1889 | * if (data != null) { |
| 1890 | * return new ByteArrayInputStream(data); |
| 1891 | * } |
| 1892 | * } |
| 1893 | * } finally { |
| 1894 | * cursor.close(); |
| 1895 | * } |
| 1896 | * return null; |
| 1897 | * } |
| 1898 | * </pre> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1899 | * </dd> |
| 1900 | * <dt>Retrieving the larger photo version</dt> |
| 1901 | * <dd> |
| 1902 | * <pre> |
| 1903 | * public InputStream openDisplayPhoto(long contactId) { |
| 1904 | * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1905 | * Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO); |
| 1906 | * try { |
| 1907 | * AssetFileDescriptor fd = |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 1908 | * getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1909 | * return fd.createInputStream(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 1910 | * } catch (IOException e) { |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1911 | * return null; |
| 1912 | * } |
| 1913 | * } |
| 1914 | * </pre> |
| 1915 | * </dd> |
| 1916 | * </dl> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1917 | * |
| 1918 | * </p> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1919 | * <p>You may also consider using the convenience method |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1920 | * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri, boolean)} |
| 1921 | * 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] | 1922 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1923 | * <p> |
| 1924 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 1925 | * {@link #CONTENT_LOOKUP_URI}. |
| 1926 | * </p> |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1927 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1928 | public static final class Photo implements BaseColumns, DataColumnsWithJoins { |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 1929 | /** |
| 1930 | * no public constructor since this is a utility class |
| 1931 | */ |
| 1932 | private Photo() {} |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 1933 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 1934 | /** |
| 1935 | * The directory twig for this sub-table |
| 1936 | */ |
| 1937 | public static final String CONTENT_DIRECTORY = "photo"; |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1938 | |
| 1939 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1940 | * The directory twig for retrieving the full-size display photo. |
| 1941 | */ |
| 1942 | public static final String DISPLAY_PHOTO = "display_photo"; |
| 1943 | |
| 1944 | /** |
| 1945 | * Full-size photo file ID of the raw contact. |
| 1946 | * See {@link ContactsContract.DisplayPhoto}. |
| 1947 | * <p> |
| 1948 | * Type: NUMBER |
| 1949 | */ |
| 1950 | public static final String PHOTO_FILE_ID = DATA14; |
| 1951 | |
| 1952 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1953 | * Thumbnail photo of the raw contact. This is the raw bytes of an image |
| 1954 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
| 1955 | * <p> |
| 1956 | * Type: BLOB |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1957 | */ |
| 1958 | public static final String PHOTO = DATA15; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1959 | } |
| 1960 | |
| 1961 | /** |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1962 | * Opens an InputStream for the contacts's photo and returns the |
| 1963 | * photo as a byte stream. |
| 1964 | * @param cr The content resolver to use for querying |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1965 | * @param contactUri the contact whose photo should be used. This can be used with |
| 1966 | * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI. |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1967 | * @param preferHighres If this is true and the contact has a higher resolution photo |
| 1968 | * 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] | 1969 | * @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] | 1970 | */ |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1971 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri, |
| 1972 | boolean preferHighres) { |
| 1973 | if (preferHighres) { |
| 1974 | final Uri displayPhotoUri = Uri.withAppendedPath(contactUri, |
| 1975 | Contacts.Photo.DISPLAY_PHOTO); |
| 1976 | InputStream inputStream; |
| 1977 | try { |
| 1978 | AssetFileDescriptor fd = cr.openAssetFileDescriptor(displayPhotoUri, "r"); |
| 1979 | return fd.createInputStream(); |
| 1980 | } catch (IOException e) { |
| 1981 | // fallback to the thumbnail code |
| 1982 | } |
| 1983 | } |
| 1984 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 1985 | Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY); |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 1986 | if (photoUri == null) { |
| 1987 | return null; |
| 1988 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1989 | Cursor cursor = cr.query(photoUri, |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1990 | new String[] { |
| 1991 | ContactsContract.CommonDataKinds.Photo.PHOTO |
| 1992 | }, null, null, null); |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1993 | try { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 1994 | if (cursor == null || !cursor.moveToNext()) { |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1995 | return null; |
| 1996 | } |
| 1997 | byte[] data = cursor.getBlob(0); |
| 1998 | if (data == null) { |
| 1999 | return null; |
| 2000 | } |
| 2001 | return new ByteArrayInputStream(data); |
| 2002 | } finally { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 2003 | if (cursor != null) { |
| 2004 | cursor.close(); |
| 2005 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2006 | } |
| 2007 | } |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2008 | |
| 2009 | /** |
| 2010 | * Opens an InputStream for the contacts's thumbnail photo and returns the |
| 2011 | * photo as a byte stream. |
| 2012 | * @param cr The content resolver to use for querying |
| 2013 | * @param contactUri the contact whose photo should be used. This can be used with |
| 2014 | * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI. |
| 2015 | * @return an InputStream of the photo, or null if no photo is present |
| 2016 | * @see #openContactPhotoInputStream(ContentResolver, Uri, boolean), if instead |
| 2017 | * of the thumbnail the high-res picture is preferred |
| 2018 | */ |
| 2019 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) { |
| 2020 | return openContactPhotoInputStream(cr, contactUri, false); |
| 2021 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2022 | } |
| 2023 | |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2024 | /** |
| 2025 | * <p> |
| 2026 | * Constants for the user's profile data, which is represented as a single contact on |
| 2027 | * the device that represents the user. The profile contact is not aggregated |
| 2028 | * together automatically in the same way that normal contacts are; instead, each |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 2029 | * account (including data set, if applicable) on the device may contribute a single |
| 2030 | * raw contact representing the user's personal profile data from that source. |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2031 | * </p> |
| 2032 | * <p> |
| 2033 | * Access to the profile entry through these URIs (or incidental access to parts of |
| 2034 | * the profile if retrieved directly via ID) requires additional permissions beyond |
| 2035 | * the read/write contact permissions required by the provider. Querying for profile |
| 2036 | * data requires android.permission.READ_PROFILE permission, and inserting or |
| 2037 | * updating profile data requires android.permission.WRITE_PROFILE permission. |
| 2038 | * </p> |
| 2039 | * <h3>Operations</h3> |
| 2040 | * <dl> |
| 2041 | * <dt><b>Insert</b></dt> |
| 2042 | * <dd>The user's profile entry cannot be created explicitly (attempting to do so |
| 2043 | * will throw an exception). When a raw contact is inserted into the profile, the |
| 2044 | * provider will check for the existence of a profile on the device. If one is |
| 2045 | * found, the raw contact's {@link RawContacts#CONTACT_ID} column gets the _ID of |
| 2046 | * the profile Contact. If no match is found, the profile Contact is created and |
| 2047 | * its _ID is put into the {@link RawContacts#CONTACT_ID} column of the newly |
| 2048 | * inserted raw contact.</dd> |
| 2049 | * <dt><b>Update</b></dt> |
| 2050 | * <dd>The profile Contact has the same update restrictions as Contacts in general, |
| 2051 | * but requires the android.permission.WRITE_PROFILE permission.</dd> |
| 2052 | * <dt><b>Delete</b></dt> |
| 2053 | * <dd>The profile Contact cannot be explicitly deleted. It will be removed |
| 2054 | * automatically if all of its constituent raw contact entries are deleted.</dd> |
| 2055 | * <dt><b>Query</b></dt> |
| 2056 | * <dd> |
| 2057 | * <ul> |
| 2058 | * <li>The {@link #CONTENT_URI} for profiles behaves in much the same way as |
| 2059 | * retrieving a contact by ID, except that it will only ever return the user's |
| 2060 | * profile contact. |
| 2061 | * </li> |
| 2062 | * <li> |
| 2063 | * The profile contact supports all of the same sub-paths as an individual contact |
| 2064 | * does - the content of the profile contact can be retrieved as entities or |
| 2065 | * data rows. Similarly, specific raw contact entries can be retrieved by appending |
| 2066 | * the desired raw contact ID within the profile. |
| 2067 | * </li> |
| 2068 | * </ul> |
| 2069 | * </dd> |
| 2070 | * </dl> |
| 2071 | */ |
| 2072 | public static final class Profile implements BaseColumns, ContactsColumns, |
| 2073 | ContactOptionsColumns, ContactNameColumns, ContactStatusColumns { |
| 2074 | /** |
| 2075 | * This utility class cannot be instantiated |
| 2076 | */ |
| 2077 | private Profile() { |
| 2078 | } |
| 2079 | |
| 2080 | /** |
| 2081 | * The content:// style URI for this table, which requests the contact entry |
| 2082 | * representing the user's personal profile data. |
| 2083 | */ |
| 2084 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "profile"); |
| 2085 | |
| 2086 | /** |
| 2087 | * {@link Uri} for referencing the user's profile {@link Contacts} entry, |
| 2088 | * Provides {@link OpenableColumns} columns when queried, or returns the |
| 2089 | * user's profile contact formatted as a vCard when opened through |
| 2090 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 2091 | */ |
| 2092 | public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 2093 | "as_vcard"); |
| 2094 | |
| 2095 | /** |
| 2096 | * {@link Uri} for referencing the raw contacts that make up the user's profile |
| 2097 | * {@link Contacts} entry. An individual raw contact entry within the profile |
| 2098 | * can be addressed by appending the raw contact ID. The entities or data within |
| 2099 | * that specific raw contact can be requested by appending the entity or data |
| 2100 | * path as well. |
| 2101 | */ |
| 2102 | public static final Uri CONTENT_RAW_CONTACTS_URI = Uri.withAppendedPath(CONTENT_URI, |
| 2103 | "raw_contacts"); |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 2104 | |
| 2105 | /** |
| 2106 | * The minimum ID for any entity that belongs to the profile. This essentially |
| 2107 | * defines an ID-space in which profile data is stored, and is used by the provider |
| 2108 | * to determine whether a request via a non-profile-specific URI should be directed |
| 2109 | * to the profile data rather than general contacts data, along with all the special |
| 2110 | * permission checks that entails. |
| 2111 | * |
| 2112 | * Callers may use {@link #isProfileId} to check whether a specific ID falls into |
| 2113 | * the set of data intended for the profile. |
| 2114 | */ |
| 2115 | public static final long MIN_ID = Long.MAX_VALUE - (long) Integer.MAX_VALUE; |
| 2116 | } |
| 2117 | |
| 2118 | /** |
| 2119 | * This method can be used to identify whether the given ID is associated with profile |
| 2120 | * data. It does not necessarily indicate that the ID is tied to valid data, merely |
| 2121 | * that accessing data using this ID will result in profile access checks and will only |
| 2122 | * return data from the profile. |
| 2123 | * |
| 2124 | * @param id The ID to check. |
| 2125 | * @return Whether the ID is associated with profile data. |
| 2126 | */ |
| 2127 | public static boolean isProfileId(long id) { |
| 2128 | return id >= Profile.MIN_ID; |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2129 | } |
| 2130 | |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 2131 | protected interface DeletedContactsColumns { |
| 2132 | |
| 2133 | /** |
| 2134 | * A reference to the {@link ContactsContract.Contacts#_ID} that was deleted. |
| 2135 | * <P>Type: INTEGER</P> |
| 2136 | */ |
| 2137 | public static final String CONTACT_ID = "contact_id"; |
| 2138 | |
| 2139 | /** |
| 2140 | * Time (milliseconds since epoch) that the contact was deleted. |
| 2141 | */ |
| 2142 | public static final String CONTACT_DELETED_TIMESTAMP = "contact_deleted_timestamp"; |
| 2143 | } |
| 2144 | |
| 2145 | /** |
| 2146 | * Constants for the deleted contact table. This table holds a log of deleted contacts. |
| 2147 | * <p> |
| 2148 | * Log older than {@link #DAYS_KEPT_MILLISECONDS} may be deleted. |
| 2149 | */ |
| 2150 | public static final class DeletedContacts implements DeletedContactsColumns { |
| 2151 | |
| 2152 | /** |
| 2153 | * This utility class cannot be instantiated |
| 2154 | */ |
| 2155 | private DeletedContacts() { |
| 2156 | } |
| 2157 | |
| 2158 | /** |
| 2159 | * The content:// style URI for this table, which requests a directory of raw contact rows |
| 2160 | * matching the selection criteria. |
| 2161 | */ |
| 2162 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 2163 | "deleted_contacts"); |
| 2164 | |
| 2165 | /** |
| 2166 | * Number of days that the delete log will be kept. After this time, delete records may be |
| 2167 | * deleted. |
| 2168 | * |
| 2169 | * @hide |
| 2170 | */ |
| 2171 | private static final int DAYS_KEPT = 30; |
| 2172 | |
| 2173 | /** |
| 2174 | * Milliseconds that the delete log will be kept. After this time, delete records may be |
| 2175 | * deleted. |
| 2176 | */ |
| 2177 | public static final long DAYS_KEPT_MILLISECONDS = 1000L * 60L * 60L * 24L * (long)DAYS_KEPT; |
| 2178 | } |
| 2179 | |
| 2180 | |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 2181 | protected interface RawContactsColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2182 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2183 | * A reference to the {@link ContactsContract.Contacts#_ID} that this |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2184 | * data belongs to. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2185 | * <P>Type: INTEGER</P> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2186 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2187 | public static final String CONTACT_ID = "contact_id"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2188 | |
| 2189 | /** |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2190 | * The data set within the account that this row belongs to. This allows |
| 2191 | * multiple sync adapters for the same account type to distinguish between |
| 2192 | * each others' data. |
| 2193 | * |
| 2194 | * This is empty by default, and is completely optional. It only needs to |
| 2195 | * be populated if multiple sync adapters are entering distinct data for |
| 2196 | * the same account type and account name. |
| 2197 | * <P>Type: TEXT</P> |
| 2198 | */ |
| 2199 | public static final String DATA_SET = "data_set"; |
| 2200 | |
| 2201 | /** |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 2202 | * A concatenation of the account type and data set (delimited by a forward |
| 2203 | * slash) - if the data set is empty, this will be the same as the account |
| 2204 | * type. For applications that need to be aware of the data set, this can |
| 2205 | * be used instead of account type to distinguish sets of data. This is |
| 2206 | * never intended to be used for specifying accounts. |
| 2207 | * @hide |
| 2208 | */ |
| 2209 | public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; |
| 2210 | |
| 2211 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2212 | * The aggregation mode for this contact. |
| 2213 | * <P>Type: INTEGER</P> |
| 2214 | */ |
| 2215 | public static final String AGGREGATION_MODE = "aggregation_mode"; |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 2216 | |
| 2217 | /** |
| 2218 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 2219 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 2220 | * 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] | 2221 | * 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] | 2222 | * then calls ContactResolver.delete once more, this time passing the |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 2223 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 2224 | * the data removal. |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 2225 | * <P>Type: INTEGER</P> |
| 2226 | */ |
| 2227 | public static final String DELETED = "deleted"; |
Dmitri Plotnikov | 918007b | 2010-01-20 12:12:11 -0800 | [diff] [blame] | 2228 | |
| 2229 | /** |
| 2230 | * The "name_verified" flag: "1" means that the name fields on this raw |
| 2231 | * contact can be trusted and therefore should be used for the entire |
| 2232 | * aggregated contact. |
| 2233 | * <p> |
| 2234 | * If an aggregated contact contains more than one raw contact with a |
| 2235 | * verified name, one of those verified names is chosen at random. |
| 2236 | * If an aggregated contact contains no verified names, the |
| 2237 | * name is chosen randomly from the constituent raw contacts. |
| 2238 | * </p> |
| 2239 | * <p> |
| 2240 | * Updating this flag from "0" to "1" automatically resets it to "0" on |
| 2241 | * all other raw contacts in the same aggregated contact. |
| 2242 | * </p> |
| 2243 | * <p> |
| 2244 | * Sync adapters should only specify a value for this column when |
| 2245 | * inserting a raw contact and leave it out when doing an update. |
| 2246 | * </p> |
| 2247 | * <p> |
| 2248 | * The default value is "0" |
| 2249 | * </p> |
| 2250 | * <p>Type: INTEGER</p> |
| 2251 | * |
| 2252 | * @hide |
| 2253 | */ |
| 2254 | public static final String NAME_VERIFIED = "name_verified"; |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 2255 | |
| 2256 | /** |
| 2257 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 2258 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 2259 | * <P>Type: INTEGER</P> |
| 2260 | */ |
Dmitri Plotnikov | 86fe839 | 2010-07-16 11:19:46 -0700 | [diff] [blame] | 2261 | 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] | 2262 | |
| 2263 | /** |
| 2264 | * Flag that reflects whether this raw contact belongs to the user's |
| 2265 | * personal profile entry. |
| 2266 | */ |
| 2267 | 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] | 2268 | } |
| 2269 | |
| 2270 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2271 | * Constants for the raw contacts table, which contains one row of contact |
| 2272 | * information for each person in each synced account. Sync adapters and |
| 2273 | * contact management apps |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 2274 | * are the primary consumers of this API. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2275 | * |
| 2276 | * <h3>Aggregation</h3> |
| 2277 | * <p> |
| 2278 | * As soon as a raw contact is inserted or whenever its constituent data |
| 2279 | * changes, the provider will check if the raw contact matches other |
| 2280 | * existing raw contacts and if so will aggregate it with those. The |
| 2281 | * aggregation is reflected in the {@link RawContacts} table by the change of the |
| 2282 | * {@link #CONTACT_ID} field, which is the reference to the aggregate contact. |
| 2283 | * </p> |
| 2284 | * <p> |
| 2285 | * Changes to the structured name, organization, phone number, email address, |
| 2286 | * or nickname trigger a re-aggregation. |
| 2287 | * </p> |
| 2288 | * <p> |
| 2289 | * See also {@link AggregationExceptions} for a mechanism to control |
| 2290 | * aggregation programmatically. |
| 2291 | * </p> |
| 2292 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2293 | * <h3>Operations</h3> |
| 2294 | * <dl> |
| 2295 | * <dt><b>Insert</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2296 | * <dd> |
| 2297 | * <p> |
| 2298 | * Raw contacts can be inserted incrementally or in a batch. |
| 2299 | * The incremental method is more traditional but less efficient. |
| 2300 | * It should be used |
| 2301 | * 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] | 2302 | * <pre> |
| 2303 | * ContentValues values = new ContentValues(); |
| 2304 | * values.put(RawContacts.ACCOUNT_TYPE, accountType); |
| 2305 | * values.put(RawContacts.ACCOUNT_NAME, accountName); |
| 2306 | * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values); |
| 2307 | * long rawContactId = ContentUris.parseId(rawContactUri); |
| 2308 | * </pre> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2309 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2310 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2311 | * Once {@link Data} values become available, insert those. |
| 2312 | * For example, here's how you would insert a name: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2313 | * |
| 2314 | * <pre> |
| 2315 | * values.clear(); |
| 2316 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 2317 | * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); |
| 2318 | * values.put(StructuredName.DISPLAY_NAME, "Mike Sullivan"); |
| 2319 | * getContentResolver().insert(Data.CONTENT_URI, values); |
| 2320 | * </pre> |
| 2321 | * </p> |
| 2322 | * <p> |
| 2323 | * The batch method is by far preferred. It inserts the raw contact and its |
| 2324 | * constituent data rows in a single database transaction |
| 2325 | * and causes at most one aggregation pass. |
| 2326 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 2327 | * ArrayList<ContentProviderOperation> ops = |
| 2328 | * new ArrayList<ContentProviderOperation>(); |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2329 | * ... |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2330 | * int rawContactInsertIndex = ops.size(); |
| 2331 | * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) |
| 2332 | * .withValue(RawContacts.ACCOUNT_TYPE, accountType) |
| 2333 | * .withValue(RawContacts.ACCOUNT_NAME, accountName) |
| 2334 | * .build()); |
| 2335 | * |
| 2336 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 2337 | * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex) |
| 2338 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 2339 | * .withValue(StructuredName.DISPLAY_NAME, "Mike Sullivan") |
| 2340 | * .build()); |
| 2341 | * |
| 2342 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 2343 | * </pre> |
| 2344 | * </p> |
| 2345 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2346 | * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)} |
| 2347 | * to refer to the as-yet-unknown index value of the raw contact inserted in the |
| 2348 | * first operation. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2349 | * </p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2350 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2351 | * <dt><b>Update</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2352 | * <dd><p> |
| 2353 | * Raw contacts can be updated incrementally or in a batch. |
| 2354 | * Batch mode should be used whenever possible. |
| 2355 | * The procedures and considerations are analogous to those documented above for inserts. |
| 2356 | * </p></dd> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2357 | * <dt><b>Delete</b></dt> |
| 2358 | * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates, |
| 2359 | * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2360 | * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row |
| 2361 | * itself is also deleted automatically. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2362 | * </p> |
| 2363 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2364 | * The invocation of {@code resolver.delete(...)}, does not immediately delete |
| 2365 | * a raw contacts row. |
| 2366 | * Instead, it sets the {@link #DELETED} flag on the raw contact and |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2367 | * removes the raw contact from its aggregate contact. |
| 2368 | * The sync adapter then deletes the raw contact from the server and |
| 2369 | * finalizes phone-side deletion by calling {@code resolver.delete(...)} |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2370 | * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2371 | * <p>Some sync adapters are read-only, meaning that they only sync server-side |
| 2372 | * changes to the phone, but not the reverse. If one of those raw contacts |
| 2373 | * is marked for deletion, it will remain on the phone. However it will be |
| 2374 | * effectively invisible, because it will not be part of any aggregate contact. |
| 2375 | * </dd> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2376 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2377 | * <dt><b>Query</b></dt> |
| 2378 | * <dd> |
| 2379 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2380 | * It is easy to find all raw contacts in a Contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2381 | * <pre> |
| 2382 | * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI, |
| 2383 | * new String[]{RawContacts._ID}, |
| 2384 | * RawContacts.CONTACT_ID + "=?", |
| 2385 | * new String[]{String.valueOf(contactId)}, null); |
| 2386 | * </pre> |
| 2387 | * </p> |
| 2388 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2389 | * To find raw contacts within a specific account, |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2390 | * you can either put the account name and type in the selection or pass them as query |
| 2391 | * parameters. The latter approach is preferable, especially when you can reuse the |
| 2392 | * URI: |
| 2393 | * <pre> |
Adam Koch | 95e5a07 | 2013-05-21 09:47:55 -0400 | [diff] [blame] | 2394 | * Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon() |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2395 | * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName) |
| 2396 | * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType) |
| 2397 | * .build(); |
| 2398 | * Cursor c1 = getContentResolver().query(rawContactUri, |
| 2399 | * RawContacts.STARRED + "<>0", null, null, null); |
| 2400 | * ... |
| 2401 | * Cursor c2 = getContentResolver().query(rawContactUri, |
| 2402 | * RawContacts.DELETED + "<>0", null, null, null); |
| 2403 | * </pre> |
| 2404 | * </p> |
| 2405 | * <p>The best way to read a raw contact along with all the data associated with it is |
| 2406 | * by using the {@link Entity} directory. If the raw contact has data rows, |
| 2407 | * the Entity cursor will contain a row for each data row. If the raw contact has no |
| 2408 | * data rows, the cursor will still contain one row with the raw contact-level information. |
| 2409 | * <pre> |
| 2410 | * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); |
| 2411 | * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY); |
| 2412 | * Cursor c = getContentResolver().query(entityUri, |
| 2413 | * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1}, |
| 2414 | * null, null, null); |
| 2415 | * try { |
| 2416 | * while (c.moveToNext()) { |
| 2417 | * String sourceId = c.getString(0); |
| 2418 | * if (!c.isNull(1)) { |
| 2419 | * String mimeType = c.getString(2); |
| 2420 | * String data = c.getString(3); |
| 2421 | * ... |
| 2422 | * } |
| 2423 | * } |
| 2424 | * } finally { |
| 2425 | * c.close(); |
| 2426 | * } |
| 2427 | * </pre> |
| 2428 | * </p> |
| 2429 | * </dd> |
| 2430 | * </dl> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2431 | * <h2>Columns</h2> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2432 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2433 | * <table class="jd-sumtable"> |
| 2434 | * <tr> |
| 2435 | * <th colspan='4'>RawContacts</th> |
| 2436 | * </tr> |
| 2437 | * <tr> |
| 2438 | * <td>long</td> |
| 2439 | * <td>{@link #_ID}</td> |
| 2440 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2441 | * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words, |
| 2442 | * it is much better for a sync adapter to update a raw contact rather than to delete and |
| 2443 | * re-insert it.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2444 | * </tr> |
| 2445 | * <tr> |
| 2446 | * <td>long</td> |
| 2447 | * <td>{@link #CONTACT_ID}</td> |
| 2448 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2449 | * <td>The ID of the row in the {@link ContactsContract.Contacts} table |
| 2450 | * that this raw contact belongs |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2451 | * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled |
| 2452 | * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td> |
| 2453 | * </tr> |
| 2454 | * <tr> |
| 2455 | * <td>int</td> |
| 2456 | * <td>{@link #AGGREGATION_MODE}</td> |
| 2457 | * <td>read/write</td> |
| 2458 | * <td>A mechanism that allows programmatic control of the aggregation process. The allowed |
| 2459 | * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED} |
| 2460 | * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td> |
| 2461 | * </tr> |
| 2462 | * <tr> |
| 2463 | * <td>int</td> |
| 2464 | * <td>{@link #DELETED}</td> |
| 2465 | * <td>read/write</td> |
| 2466 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 2467 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 2468 | * called on a raw contact, it is marked for deletion and removed from its |
| 2469 | * aggregate contact. The sync adaptor deletes the raw contact on the server and |
| 2470 | * then calls ContactResolver.delete once more, this time passing the |
| 2471 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 2472 | * the data removal.</td> |
| 2473 | * </tr> |
| 2474 | * <tr> |
| 2475 | * <td>int</td> |
| 2476 | * <td>{@link #TIMES_CONTACTED}</td> |
| 2477 | * <td>read/write</td> |
| 2478 | * <td>The number of times the contact has been contacted. To have an effect |
| 2479 | * on the corresponding value of the aggregate contact, this field |
| 2480 | * should be set at the time the raw contact is inserted. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2481 | * After that, this value is typically updated via |
| 2482 | * {@link ContactsContract.Contacts#markAsContacted}.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2483 | * </tr> |
| 2484 | * <tr> |
| 2485 | * <td>long</td> |
| 2486 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 2487 | * <td>read/write</td> |
| 2488 | * <td>The timestamp of the last time the contact was contacted. To have an effect |
| 2489 | * on the corresponding value of the aggregate contact, this field |
| 2490 | * should be set at the time the raw contact is inserted. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2491 | * After that, this value is typically updated via |
| 2492 | * {@link ContactsContract.Contacts#markAsContacted}. |
| 2493 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2494 | * </tr> |
| 2495 | * <tr> |
| 2496 | * <td>int</td> |
| 2497 | * <td>{@link #STARRED}</td> |
| 2498 | * <td>read/write</td> |
| 2499 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2500 | * Changing this field immediately affects the corresponding aggregate contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2501 | * if any raw contacts in that aggregate contact are starred, then the contact |
| 2502 | * itself is marked as starred.</td> |
| 2503 | * </tr> |
| 2504 | * <tr> |
| 2505 | * <td>String</td> |
| 2506 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 2507 | * <td>read/write</td> |
| 2508 | * <td>A custom ringtone associated with a raw contact. Typically this is the |
| 2509 | * URI returned by an activity launched with the |
| 2510 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent. |
| 2511 | * To have an effect on the corresponding value of the aggregate contact, this field |
| 2512 | * 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] | 2513 | * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE |
| 2514 | * Contacts.CUSTOM_RINGTONE} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2515 | * instead.</td> |
| 2516 | * </tr> |
| 2517 | * <tr> |
| 2518 | * <td>int</td> |
| 2519 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 2520 | * <td>read/write</td> |
| 2521 | * <td>An indicator of whether calls from this raw contact should be forwarded |
| 2522 | * directly to voice mail ('1') or not ('0'). To have an effect |
| 2523 | * on the corresponding value of the aggregate contact, this field |
| 2524 | * should be set at the time the raw contact is inserted.</td> |
| 2525 | * </tr> |
| 2526 | * <tr> |
| 2527 | * <td>String</td> |
| 2528 | * <td>{@link #ACCOUNT_NAME}</td> |
| 2529 | * <td>read/write-once</td> |
| 2530 | * <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] | 2531 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
| 2532 | * 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] | 2533 | * It should be set at the time the raw contact is inserted and never |
| 2534 | * changed afterwards.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2535 | * </tr> |
| 2536 | * <tr> |
| 2537 | * <td>String</td> |
| 2538 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 2539 | * <td>read/write-once</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2540 | * <td> |
| 2541 | * <p> |
| 2542 | * The type of account to which this row belongs, which when paired with |
| 2543 | * {@link #ACCOUNT_NAME} identifies a specific account. |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2544 | * It should be set at the time the raw contact is inserted and never |
| 2545 | * changed afterwards. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2546 | * </p> |
| 2547 | * <p> |
| 2548 | * To ensure uniqueness, new account types should be chosen according to the |
| 2549 | * Java package naming convention. Thus a Google account is of type "com.google". |
| 2550 | * </p> |
| 2551 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2552 | * </tr> |
| 2553 | * <tr> |
| 2554 | * <td>String</td> |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2555 | * <td>{@link #DATA_SET}</td> |
| 2556 | * <td>read/write-once</td> |
| 2557 | * <td> |
| 2558 | * <p> |
| 2559 | * The data set within the account that this row belongs to. This allows |
| 2560 | * multiple sync adapters for the same account type to distinguish between |
| 2561 | * each others' data. The combination of {@link #ACCOUNT_TYPE}, |
| 2562 | * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data |
| 2563 | * that is associated with a single sync adapter. |
| 2564 | * </p> |
| 2565 | * <p> |
| 2566 | * This is empty by default, and is completely optional. It only needs to |
| 2567 | * be populated if multiple sync adapters are entering distinct data for |
| 2568 | * the same account type and account name. |
| 2569 | * </p> |
| 2570 | * <p> |
| 2571 | * It should be set at the time the raw contact is inserted and never |
| 2572 | * changed afterwards. |
| 2573 | * </p> |
| 2574 | * </td> |
| 2575 | * </tr> |
| 2576 | * <tr> |
| 2577 | * <td>String</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2578 | * <td>{@link #SOURCE_ID}</td> |
| 2579 | * <td>read/write</td> |
| 2580 | * <td>String that uniquely identifies this row to its source account. |
| 2581 | * Typically it is set at the time the raw contact is inserted and never |
| 2582 | * changed afterwards. The one notable exception is a new raw contact: it |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2583 | * will have an account name and type (and possibly a data set), but no |
| 2584 | * source id. This indicates to the sync adapter that a new contact needs |
| 2585 | * to be created server-side and its ID stored in the corresponding |
| 2586 | * SOURCE_ID field on the phone. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2587 | * </td> |
| 2588 | * </tr> |
| 2589 | * <tr> |
| 2590 | * <td>int</td> |
| 2591 | * <td>{@link #VERSION}</td> |
| 2592 | * <td>read-only</td> |
| 2593 | * <td>Version number that is updated whenever this row or its related data |
| 2594 | * changes. This field can be used for optimistic locking of a raw contact. |
| 2595 | * </td> |
| 2596 | * </tr> |
| 2597 | * <tr> |
| 2598 | * <td>int</td> |
| 2599 | * <td>{@link #DIRTY}</td> |
| 2600 | * <td>read/write</td> |
| 2601 | * <td>Flag indicating that {@link #VERSION} has changed, and this row needs |
| 2602 | * to be synchronized by its owning account. The value is set to "1" automatically |
| 2603 | * whenever the raw contact changes, unless the URI has the |
| 2604 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified. |
| 2605 | * The sync adapter should always supply this query parameter to prevent |
| 2606 | * unnecessary synchronization: user changes some data on the server, |
| 2607 | * the sync adapter updates the contact on the phone (without the |
| 2608 | * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag, |
| 2609 | * which triggers a sync to bring the changes to the server. |
| 2610 | * </td> |
| 2611 | * </tr> |
| 2612 | * <tr> |
| 2613 | * <td>String</td> |
| 2614 | * <td>{@link #SYNC1}</td> |
| 2615 | * <td>read/write</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2616 | * <td>Generic column provided for arbitrary use by sync adapters. |
| 2617 | * The content provider |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2618 | * stores this information on behalf of the sync adapter but does not |
| 2619 | * interpret it in any way. |
| 2620 | * </td> |
| 2621 | * </tr> |
| 2622 | * <tr> |
| 2623 | * <td>String</td> |
| 2624 | * <td>{@link #SYNC2}</td> |
| 2625 | * <td>read/write</td> |
| 2626 | * <td>Generic column for use by sync adapters. |
| 2627 | * </td> |
| 2628 | * </tr> |
| 2629 | * <tr> |
| 2630 | * <td>String</td> |
| 2631 | * <td>{@link #SYNC3}</td> |
| 2632 | * <td>read/write</td> |
| 2633 | * <td>Generic column for use by sync adapters. |
| 2634 | * </td> |
| 2635 | * </tr> |
| 2636 | * <tr> |
| 2637 | * <td>String</td> |
| 2638 | * <td>{@link #SYNC4}</td> |
| 2639 | * <td>read/write</td> |
| 2640 | * <td>Generic column for use by sync adapters. |
| 2641 | * </td> |
| 2642 | * </tr> |
| 2643 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2644 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2645 | public static final class RawContacts implements BaseColumns, RawContactsColumns, |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 2646 | ContactOptionsColumns, ContactNameColumns, SyncColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2647 | /** |
| 2648 | * This utility class cannot be instantiated |
| 2649 | */ |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 2650 | private RawContacts() { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2651 | } |
| 2652 | |
| 2653 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2654 | * The content:// style URI for this table, which requests a directory of |
| 2655 | * raw contact rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2656 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 2657 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2658 | |
| 2659 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2660 | * The MIME type of the results from {@link #CONTENT_URI} when a specific |
| 2661 | * ID value is not provided, and multiple raw contacts may be returned. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2662 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2663 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2664 | |
| 2665 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2666 | * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI}, |
| 2667 | * yielding a subdirectory of a single person. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2668 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2669 | 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] | 2670 | |
| 2671 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2672 | * Aggregation mode: aggregate immediately after insert or update operation(s) are complete. |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2673 | */ |
| 2674 | public static final int AGGREGATION_MODE_DEFAULT = 0; |
| 2675 | |
| 2676 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2677 | * Aggregation mode: aggregate at the time the raw contact is inserted/updated. |
| 2678 | * @deprecated Aggregation is synchronous, this historic value is a no-op |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2679 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2680 | @Deprecated |
Omari Stephens | bc9aa77 | 2009-09-08 19:10:53 -0700 | [diff] [blame] | 2681 | public static final int AGGREGATION_MODE_IMMEDIATE = 1; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2682 | |
| 2683 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2684 | * <p> |
| 2685 | * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later. |
| 2686 | * Changes to the raw contact will update the associated aggregate contact but will not |
| 2687 | * result in any change in how the contact is aggregated. Similar to |
| 2688 | * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding |
| 2689 | * {@link Contacts} aggregate. |
| 2690 | * </p> |
| 2691 | * <p> |
| 2692 | * This can be used to postpone aggregation until after a series of updates, for better |
| 2693 | * performance and/or user experience. |
| 2694 | * </p> |
| 2695 | * <p> |
| 2696 | * Note that changing |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2697 | * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2698 | * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any |
| 2699 | * subsequent |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2700 | * change to the raw contact's data will. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2701 | * </p> |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2702 | */ |
| 2703 | public static final int AGGREGATION_MODE_SUSPENDED = 2; |
| 2704 | |
| 2705 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2706 | * <p> |
| 2707 | * Aggregation mode: never aggregate this raw contact. The raw contact will not |
| 2708 | * have a corresponding {@link Contacts} aggregate and therefore will not be included in |
| 2709 | * {@link Contacts} query results. |
| 2710 | * </p> |
| 2711 | * <p> |
| 2712 | * For example, this mode can be used for a raw contact that is marked for deletion while |
| 2713 | * waiting for the deletion to occur on the server side. |
| 2714 | * </p> |
| 2715 | * |
| 2716 | * @see #AGGREGATION_MODE_SUSPENDED |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2717 | */ |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2718 | public static final int AGGREGATION_MODE_DISABLED = 3; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2719 | |
| 2720 | /** |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 2721 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 2722 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
| 2723 | * entry of the given {@link RawContacts} entry. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2724 | */ |
| 2725 | public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) { |
| 2726 | // TODO: use a lighter query by joining rawcontacts with contacts in provider |
| 2727 | final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY); |
| 2728 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 2729 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 2730 | }, null, null, null); |
| 2731 | |
| 2732 | Uri lookupUri = null; |
| 2733 | try { |
| 2734 | if (cursor != null && cursor.moveToFirst()) { |
| 2735 | final long contactId = cursor.getLong(0); |
| 2736 | final String lookupKey = cursor.getString(1); |
| 2737 | return Contacts.getLookupUri(contactId, lookupKey); |
| 2738 | } |
| 2739 | } finally { |
| 2740 | if (cursor != null) cursor.close(); |
| 2741 | } |
| 2742 | return lookupUri; |
| 2743 | } |
| 2744 | |
| 2745 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2746 | * 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] | 2747 | * {@link ContactsContract.Data} rows. To access this directory |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2748 | * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2749 | */ |
| 2750 | public static final class Data implements BaseColumns, DataColumns { |
| 2751 | /** |
| 2752 | * no public constructor since this is a utility class |
| 2753 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2754 | private Data() { |
| 2755 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2756 | |
| 2757 | /** |
| 2758 | * The directory twig for this sub-table |
| 2759 | */ |
| 2760 | public static final String CONTENT_DIRECTORY = "data"; |
| 2761 | } |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2762 | |
| 2763 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2764 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2765 | * 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] | 2766 | * {@link ContactsContract.Data} rows. To access this directory append |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2767 | * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2768 | * {@link RawContactsEntity} for a stand-alone table containing the same |
| 2769 | * data. |
| 2770 | * </p> |
| 2771 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2772 | * Entity has two ID fields: {@link #_ID} for the raw contact |
| 2773 | * and {@link #DATA_ID} for the data rows. |
| 2774 | * Entity always contains at least one row, even if there are no |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2775 | * 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] | 2776 | * null. |
| 2777 | * </p> |
| 2778 | * <p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2779 | * Using Entity should be preferred to using two separate queries: |
| 2780 | * RawContacts followed by Data. The reason is that Entity reads all |
| 2781 | * data for a raw contact in one transaction, so there is no possibility |
| 2782 | * of the data changing between the two queries. |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2783 | */ |
| 2784 | public static final class Entity implements BaseColumns, DataColumns { |
| 2785 | /** |
| 2786 | * no public constructor since this is a utility class |
| 2787 | */ |
| 2788 | private Entity() { |
| 2789 | } |
| 2790 | |
| 2791 | /** |
| 2792 | * The directory twig for this sub-table |
| 2793 | */ |
| 2794 | public static final String CONTENT_DIRECTORY = "entity"; |
| 2795 | |
| 2796 | /** |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 2797 | * 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] | 2798 | * data rows. |
| 2799 | * <P>Type: INTEGER</P> |
| 2800 | */ |
| 2801 | public static final String DATA_ID = "data_id"; |
| 2802 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2803 | |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2804 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2805 | * <p> |
| 2806 | * A sub-directory of a single raw contact that contains all of its |
| 2807 | * {@link ContactsContract.StreamItems} rows. To access this directory append |
| 2808 | * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See |
| 2809 | * {@link ContactsContract.StreamItems} for a stand-alone table containing the |
| 2810 | * same data. |
| 2811 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 2812 | * <p> |
| 2813 | * Access to the social stream through this sub-directory requires additional permissions |
| 2814 | * beyond the read/write contact permissions required by the provider. Querying for |
| 2815 | * social stream data requires android.permission.READ_SOCIAL_STREAM permission, and |
| 2816 | * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM |
| 2817 | * permission. |
| 2818 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2819 | */ |
| 2820 | public static final class StreamItems implements BaseColumns, StreamItemsColumns { |
| 2821 | /** |
| 2822 | * No public constructor since this is a utility class |
| 2823 | */ |
| 2824 | private StreamItems() { |
| 2825 | } |
| 2826 | |
| 2827 | /** |
| 2828 | * The directory twig for this sub-table |
| 2829 | */ |
| 2830 | public static final String CONTENT_DIRECTORY = "stream_items"; |
| 2831 | } |
| 2832 | |
| 2833 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2834 | * <p> |
| 2835 | * A sub-directory of a single raw contact that represents its primary |
| 2836 | * display photo. To access this directory append |
| 2837 | * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI. |
| 2838 | * The resulting URI represents an image file, and should be interacted with |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 2839 | * using ContentResolver.openAssetFileDescriptor. |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2840 | * <p> |
| 2841 | * <p> |
| 2842 | * Note that this sub-directory also supports opening the photo as an asset file |
| 2843 | * in write mode. Callers can create or replace the primary photo associated |
| 2844 | * with this raw contact by opening the asset file and writing the full-size |
| 2845 | * photo contents into it. When the file is closed, the image will be parsed, |
| 2846 | * sized down if necessary for the full-size display photo and thumbnail |
| 2847 | * dimensions, and stored. |
| 2848 | * </p> |
| 2849 | * <p> |
| 2850 | * Usage example: |
| 2851 | * <pre> |
| 2852 | * public void writeDisplayPhoto(long rawContactId, byte[] photo) { |
| 2853 | * Uri rawContactPhotoUri = Uri.withAppendedPath( |
| 2854 | * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), |
| 2855 | * RawContacts.DisplayPhoto.CONTENT_DIRECTORY); |
| 2856 | * try { |
| 2857 | * AssetFileDescriptor fd = |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 2858 | * getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2859 | * OutputStream os = fd.createOutputStream(); |
| 2860 | * os.write(photo); |
| 2861 | * os.close(); |
| 2862 | * fd.close(); |
| 2863 | * } catch (IOException e) { |
| 2864 | * // Handle error cases. |
| 2865 | * } |
| 2866 | * } |
| 2867 | * </pre> |
| 2868 | * </p> |
| 2869 | */ |
| 2870 | public static final class DisplayPhoto { |
| 2871 | /** |
| 2872 | * No public constructor since this is a utility class |
| 2873 | */ |
| 2874 | private DisplayPhoto() { |
| 2875 | } |
| 2876 | |
| 2877 | /** |
| 2878 | * The directory twig for this sub-table |
| 2879 | */ |
| 2880 | public static final String CONTENT_DIRECTORY = "display_photo"; |
| 2881 | } |
| 2882 | |
| 2883 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2884 | * TODO: javadoc |
| 2885 | * @param cursor |
| 2886 | * @return |
| 2887 | */ |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2888 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 2889 | return new EntityIteratorImpl(cursor); |
| 2890 | } |
| 2891 | |
| 2892 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 2893 | private static final String[] DATA_KEYS = new String[]{ |
| 2894 | Data.DATA1, |
| 2895 | Data.DATA2, |
| 2896 | Data.DATA3, |
| 2897 | Data.DATA4, |
| 2898 | Data.DATA5, |
| 2899 | Data.DATA6, |
| 2900 | Data.DATA7, |
| 2901 | Data.DATA8, |
| 2902 | Data.DATA9, |
| 2903 | Data.DATA10, |
| 2904 | Data.DATA11, |
| 2905 | Data.DATA12, |
| 2906 | Data.DATA13, |
| 2907 | Data.DATA14, |
| 2908 | Data.DATA15, |
| 2909 | Data.SYNC1, |
| 2910 | Data.SYNC2, |
| 2911 | Data.SYNC3, |
| 2912 | Data.SYNC4}; |
| 2913 | |
| 2914 | public EntityIteratorImpl(Cursor cursor) { |
| 2915 | super(cursor); |
| 2916 | } |
| 2917 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 2918 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2919 | public android.content.Entity getEntityAndIncrementCursor(Cursor cursor) |
| 2920 | throws RemoteException { |
| 2921 | final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID); |
| 2922 | final long rawContactId = cursor.getLong(columnRawContactId); |
| 2923 | |
| 2924 | // we expect the cursor is already at the row we need to read from |
| 2925 | ContentValues cv = new ContentValues(); |
| 2926 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME); |
| 2927 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE); |
Katherine Kuan | 1d83723 | 2011-08-24 16:06:06 -0700 | [diff] [blame] | 2928 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DATA_SET); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2929 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID); |
| 2930 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY); |
| 2931 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION); |
| 2932 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID); |
| 2933 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1); |
| 2934 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2); |
| 2935 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3); |
| 2936 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4); |
| 2937 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED); |
| 2938 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID); |
| 2939 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED); |
Dmitri Plotnikov | 918007b | 2010-01-20 12:12:11 -0800 | [diff] [blame] | 2940 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, NAME_VERIFIED); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2941 | android.content.Entity contact = new android.content.Entity(cv); |
| 2942 | |
| 2943 | // read data rows until the contact id changes |
| 2944 | do { |
| 2945 | if (rawContactId != cursor.getLong(columnRawContactId)) { |
| 2946 | break; |
| 2947 | } |
| 2948 | // add the data to to the contact |
| 2949 | cv = new ContentValues(); |
| 2950 | cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID))); |
| 2951 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 2952 | Data.RES_PACKAGE); |
| 2953 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE); |
| 2954 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY); |
| 2955 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, |
| 2956 | Data.IS_SUPER_PRIMARY); |
| 2957 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION); |
| 2958 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 2959 | CommonDataKinds.GroupMembership.GROUP_SOURCE_ID); |
| 2960 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 2961 | Data.DATA_VERSION); |
| 2962 | for (String key : DATA_KEYS) { |
| 2963 | final int columnIndex = cursor.getColumnIndexOrThrow(key); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 2964 | switch (cursor.getType(columnIndex)) { |
| 2965 | case Cursor.FIELD_TYPE_NULL: |
| 2966 | // don't put anything |
| 2967 | break; |
| 2968 | case Cursor.FIELD_TYPE_INTEGER: |
| 2969 | case Cursor.FIELD_TYPE_FLOAT: |
| 2970 | case Cursor.FIELD_TYPE_STRING: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 2971 | cv.put(key, cursor.getString(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 2972 | break; |
| 2973 | case Cursor.FIELD_TYPE_BLOB: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 2974 | cv.put(key, cursor.getBlob(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 2975 | break; |
| 2976 | default: |
| 2977 | throw new IllegalStateException("Invalid or unhandled data type"); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2978 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2979 | } |
| 2980 | contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv); |
| 2981 | } while (cursor.moveToNext()); |
| 2982 | |
| 2983 | return contact; |
| 2984 | } |
| 2985 | |
| 2986 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2987 | } |
| 2988 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2989 | /** |
| 2990 | * Social status update columns. |
| 2991 | * |
| 2992 | * @see StatusUpdates |
| 2993 | * @see ContactsContract.Data |
| 2994 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 2995 | protected interface StatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 2996 | /** |
Dmitri Plotnikov | a60479d | 2009-09-27 20:16:31 -0700 | [diff] [blame] | 2997 | * Contact's latest presence level. |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 2998 | * <P>Type: INTEGER (one of the values below)</P> |
| 2999 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3000 | public static final String PRESENCE = "mode"; |
| 3001 | |
| 3002 | /** |
| 3003 | * @deprecated use {@link #PRESENCE} |
| 3004 | */ |
| 3005 | @Deprecated |
| 3006 | public static final String PRESENCE_STATUS = PRESENCE; |
| 3007 | |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3008 | /** |
| 3009 | * An allowed value of {@link #PRESENCE}. |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3010 | */ |
| 3011 | int OFFLINE = 0; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3012 | |
| 3013 | /** |
| 3014 | * An allowed value of {@link #PRESENCE}. |
| 3015 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3016 | int INVISIBLE = 1; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3017 | |
| 3018 | /** |
| 3019 | * An allowed value of {@link #PRESENCE}. |
| 3020 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3021 | int AWAY = 2; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3022 | |
| 3023 | /** |
| 3024 | * An allowed value of {@link #PRESENCE}. |
| 3025 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3026 | int IDLE = 3; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3027 | |
| 3028 | /** |
| 3029 | * An allowed value of {@link #PRESENCE}. |
| 3030 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3031 | int DO_NOT_DISTURB = 4; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3032 | |
| 3033 | /** |
| 3034 | * An allowed value of {@link #PRESENCE}. |
| 3035 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3036 | int AVAILABLE = 5; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3037 | |
| 3038 | /** |
| 3039 | * Contact latest status update. |
| 3040 | * <p>Type: TEXT</p> |
| 3041 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3042 | public static final String STATUS = "status"; |
| 3043 | |
| 3044 | /** |
| 3045 | * @deprecated use {@link #STATUS} |
| 3046 | */ |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3047 | @Deprecated |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3048 | public static final String PRESENCE_CUSTOM_STATUS = STATUS; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3049 | |
| 3050 | /** |
| 3051 | * The absolute time in milliseconds when the latest status was inserted/updated. |
| 3052 | * <p>Type: NUMBER</p> |
| 3053 | */ |
| 3054 | public static final String STATUS_TIMESTAMP = "status_ts"; |
| 3055 | |
| 3056 | /** |
| 3057 | * The package containing resources for this status: label and icon. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3058 | * <p>Type: TEXT</p> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3059 | */ |
| 3060 | public static final String STATUS_RES_PACKAGE = "status_res_package"; |
| 3061 | |
| 3062 | /** |
| 3063 | * The resource ID of the label describing the source of the status update, e.g. "Google |
| 3064 | * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 3065 | * <p>Type: NUMBER</p> |
| 3066 | */ |
| 3067 | public static final String STATUS_LABEL = "status_label"; |
| 3068 | |
| 3069 | /** |
| 3070 | * The resource ID of the icon for the source of the status update. |
| 3071 | * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 3072 | * <p>Type: NUMBER</p> |
| 3073 | */ |
| 3074 | public static final String STATUS_ICON = "status_icon"; |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3075 | |
| 3076 | /** |
| 3077 | * Contact's audio/video chat capability level. |
| 3078 | * <P>Type: INTEGER (one of the values below)</P> |
| 3079 | */ |
| 3080 | public static final String CHAT_CAPABILITY = "chat_capability"; |
| 3081 | |
| 3082 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3083 | * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone |
| 3084 | * and speaker) |
| 3085 | */ |
| 3086 | public static final int CAPABILITY_HAS_VOICE = 1; |
| 3087 | |
| 3088 | /** |
| 3089 | * 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] | 3090 | * display a video feed. |
| 3091 | */ |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3092 | public static final int CAPABILITY_HAS_VIDEO = 2; |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3093 | |
| 3094 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3095 | * 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] | 3096 | * camera that can be used for video chat (e.g. a front-facing camera on a phone). |
| 3097 | */ |
| 3098 | public static final int CAPABILITY_HAS_CAMERA = 4; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3099 | } |
| 3100 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3101 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3102 | * <p> |
| 3103 | * Constants for the stream_items table, which contains social stream updates from |
| 3104 | * the user's contact list. |
| 3105 | * </p> |
| 3106 | * <p> |
| 3107 | * Only a certain number of stream items will ever be stored under a given raw contact. |
| 3108 | * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to |
| 3109 | * determine this limit, and should restrict the number of items inserted in any given |
| 3110 | * transaction correspondingly. Insertion of more items beyond the limit will |
| 3111 | * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}. |
| 3112 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3113 | * <p> |
| 3114 | * Access to the social stream through these URIs requires additional permissions beyond the |
| 3115 | * read/write contact permissions required by the provider. Querying for social stream data |
| 3116 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social |
| 3117 | * stream items requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3118 | * </p> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3119 | * <h3>Account check</h3> |
| 3120 | * <p> |
| 3121 | * The content URIs to the insert, update and delete operations are required to have the account |
| 3122 | * information matching that of the owning raw contact as query parameters, namely |
| 3123 | * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. |
| 3124 | * {@link RawContacts#DATA_SET} isn't required. |
| 3125 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3126 | * <h3>Operations</h3> |
| 3127 | * <dl> |
| 3128 | * <dt><b>Insert</b></dt> |
| 3129 | * <dd> |
| 3130 | * <p>Social stream updates are always associated with a raw contact. There are a couple |
| 3131 | * of ways to insert these entries. |
| 3132 | * <dl> |
| 3133 | * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt> |
| 3134 | * <dd> |
| 3135 | * <pre> |
| 3136 | * ContentValues values = new ContentValues(); |
| 3137 | * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); |
| 3138 | * values.put(StreamItems.TIMESTAMP, timestamp); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3139 | * values.put(StreamItems.COMMENTS, "3 people reshared this"); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3140 | * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon(); |
| 3141 | * ContentUris.appendId(builder, rawContactId); |
| 3142 | * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY); |
| 3143 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3144 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3145 | * Uri streamItemUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3146 | * long streamItemId = ContentUris.parseId(streamItemUri); |
| 3147 | * </pre> |
| 3148 | * </dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3149 | * <dt>Via {@link StreamItems#CONTENT_URI}:</dt> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3150 | * <dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3151 | *<pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3152 | * ContentValues values = new ContentValues(); |
| 3153 | * values.put(StreamItems.RAW_CONTACT_ID, rawContactId); |
| 3154 | * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); |
| 3155 | * values.put(StreamItems.TIMESTAMP, timestamp); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3156 | * values.put(StreamItems.COMMENTS, "3 people reshared this"); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3157 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3158 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3159 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3160 | * Uri streamItemUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3161 | * long streamItemId = ContentUris.parseId(streamItemUri); |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3162 | *</pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3163 | * </dd> |
| 3164 | * </dl> |
| 3165 | * </dd> |
| 3166 | * </p> |
| 3167 | * <p> |
| 3168 | * Once a {@link StreamItems} entry has been inserted, photos associated with that |
| 3169 | * social update can be inserted. For example, after one of the insertions above, |
| 3170 | * photos could be added to the stream item in one of the following ways: |
| 3171 | * <dl> |
| 3172 | * <dt>Via a URI including the stream item ID:</dt> |
| 3173 | * <dd> |
| 3174 | * <pre> |
| 3175 | * values.clear(); |
| 3176 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3177 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3178 | * getContentResolver().insert(Uri.withAppendedPath( |
| 3179 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId), |
| 3180 | * StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values); |
| 3181 | * </pre> |
| 3182 | * </dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3183 | * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3184 | * <dd> |
| 3185 | * <pre> |
| 3186 | * values.clear(); |
| 3187 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
| 3188 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3189 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3190 | * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values); |
| 3191 | * </pre> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3192 | * <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] | 3193 | * photos in a single transaction, by using {@link ContentProviderOperation} with |
| 3194 | * back references to populate the stream item ID in the {@link ContentValues}. |
| 3195 | * </dd> |
| 3196 | * </dl> |
| 3197 | * </p> |
| 3198 | * </dd> |
| 3199 | * <dt><b>Update</b></dt> |
| 3200 | * <dd>Updates can be performed by appending the stream item ID to the |
| 3201 | * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were |
| 3202 | * created by the calling package can be updated.</dd> |
| 3203 | * <dt><b>Delete</b></dt> |
| 3204 | * <dd>Deletes can be performed by appending the stream item ID to the |
| 3205 | * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were |
| 3206 | * created by the calling package can be deleted.</dd> |
| 3207 | * <dt><b>Query</b></dt> |
| 3208 | * <dl> |
| 3209 | * <dt>Finding all social stream updates for a given contact</dt> |
| 3210 | * <dd>By Contact ID: |
| 3211 | * <pre> |
| 3212 | * Cursor c = getContentResolver().query(Uri.withAppendedPath( |
| 3213 | * ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId), |
| 3214 | * Contacts.StreamItems.CONTENT_DIRECTORY), |
| 3215 | * null, null, null, null); |
| 3216 | * </pre> |
| 3217 | * </dd> |
| 3218 | * <dd>By lookup key: |
| 3219 | * <pre> |
| 3220 | * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon() |
| 3221 | * .appendPath(lookupKey) |
| 3222 | * .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(), |
| 3223 | * null, null, null, null); |
| 3224 | * </pre> |
| 3225 | * </dd> |
| 3226 | * <dt>Finding all social stream updates for a given raw contact</dt> |
| 3227 | * <dd> |
| 3228 | * <pre> |
| 3229 | * Cursor c = getContentResolver().query(Uri.withAppendedPath( |
| 3230 | * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), |
| 3231 | * RawContacts.StreamItems.CONTENT_DIRECTORY)), |
| 3232 | * null, null, null, null); |
| 3233 | * </pre> |
| 3234 | * </dd> |
| 3235 | * <dt>Querying for a specific stream item by ID</dt> |
| 3236 | * <dd> |
| 3237 | * <pre> |
| 3238 | * Cursor c = getContentResolver().query(ContentUris.withAppendedId( |
| 3239 | * StreamItems.CONTENT_URI, streamItemId), |
| 3240 | * null, null, null, null); |
| 3241 | * </pre> |
| 3242 | * </dd> |
| 3243 | * </dl> |
| 3244 | */ |
| 3245 | public static final class StreamItems implements BaseColumns, StreamItemsColumns { |
| 3246 | /** |
| 3247 | * This utility class cannot be instantiated |
| 3248 | */ |
| 3249 | private StreamItems() { |
| 3250 | } |
| 3251 | |
| 3252 | /** |
| 3253 | * The content:// style URI for this table, which handles social network stream |
| 3254 | * updates for the user's contacts. |
| 3255 | */ |
| 3256 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items"); |
| 3257 | |
| 3258 | /** |
| 3259 | * <p> |
| 3260 | * A content:// style URI for the photos stored in a sub-table underneath |
| 3261 | * stream items. This is only used for inserts, and updates - queries and deletes |
| 3262 | * for photos should be performed by appending |
| 3263 | * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a |
| 3264 | * specific stream item. |
| 3265 | * </p> |
| 3266 | * <p> |
| 3267 | * When using this URI, the stream item ID for the photo(s) must be identified |
| 3268 | * in the {@link ContentValues} passed in. |
| 3269 | * </p> |
| 3270 | */ |
| 3271 | public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo"); |
| 3272 | |
| 3273 | /** |
| 3274 | * 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] | 3275 | * that will be stored under any single raw contact. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3276 | */ |
| 3277 | public static final Uri CONTENT_LIMIT_URI = |
| 3278 | Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit"); |
| 3279 | |
| 3280 | /** |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3281 | * The MIME type of a directory of stream items. |
| 3282 | */ |
| 3283 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item"; |
| 3284 | |
| 3285 | /** |
| 3286 | * The MIME type of a single stream item. |
| 3287 | */ |
| 3288 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/stream_item"; |
| 3289 | |
| 3290 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3291 | * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will |
| 3292 | * contain this column, with the value indicating the maximum number of |
| 3293 | * stream items that will be stored under any single raw contact. |
| 3294 | */ |
| 3295 | public static final String MAX_ITEMS = "max_items"; |
| 3296 | |
| 3297 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3298 | * <p> |
| 3299 | * A sub-directory of a single stream item entry that contains all of its |
| 3300 | * photo rows. To access this |
| 3301 | * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to |
| 3302 | * an individual stream item URI. |
| 3303 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3304 | * <p> |
| 3305 | * Access to social stream photos requires additional permissions beyond the read/write |
| 3306 | * contact permissions required by the provider. Querying for social stream photos |
| 3307 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating |
| 3308 | * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3309 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3310 | */ |
| 3311 | public static final class StreamItemPhotos |
| 3312 | implements BaseColumns, StreamItemPhotosColumns { |
| 3313 | /** |
| 3314 | * No public constructor since this is a utility class |
| 3315 | */ |
| 3316 | private StreamItemPhotos() { |
| 3317 | } |
| 3318 | |
| 3319 | /** |
| 3320 | * The directory twig for this sub-table |
| 3321 | */ |
| 3322 | public static final String CONTENT_DIRECTORY = "photo"; |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3323 | |
| 3324 | /** |
| 3325 | * The MIME type of a directory of stream item photos. |
| 3326 | */ |
| 3327 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item_photo"; |
| 3328 | |
| 3329 | /** |
| 3330 | * The MIME type of a single stream item photo. |
| 3331 | */ |
| 3332 | public static final String CONTENT_ITEM_TYPE |
| 3333 | = "vnd.android.cursor.item/stream_item_photo"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3334 | } |
| 3335 | } |
| 3336 | |
| 3337 | /** |
| 3338 | * Columns in the StreamItems table. |
| 3339 | * |
| 3340 | * @see ContactsContract.StreamItems |
| 3341 | */ |
| 3342 | protected interface StreamItemsColumns { |
| 3343 | /** |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3344 | * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} |
| 3345 | * that this stream item belongs to. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3346 | * |
| 3347 | * <p>Type: INTEGER</p> |
| 3348 | * <p>read-only</p> |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3349 | */ |
| 3350 | public static final String CONTACT_ID = "contact_id"; |
| 3351 | |
| 3352 | /** |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3353 | * A reference to the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY} |
| 3354 | * that this stream item belongs to. |
| 3355 | * |
| 3356 | * <p>Type: TEXT</p> |
| 3357 | * <p>read-only</p> |
| 3358 | */ |
| 3359 | public static final String CONTACT_LOOKUP_KEY = "contact_lookup"; |
| 3360 | |
| 3361 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3362 | * A reference to the {@link RawContacts#_ID} |
| 3363 | * that this stream item belongs to. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3364 | * <p>Type: INTEGER</p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3365 | */ |
| 3366 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 3367 | |
| 3368 | /** |
| 3369 | * The package name to use when creating {@link Resources} objects for |
| 3370 | * this stream item. This value is only designed for use when building |
| 3371 | * user interfaces, and should not be used to infer the owner. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3372 | * <P>Type: TEXT</P> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3373 | */ |
| 3374 | public static final String RES_PACKAGE = "res_package"; |
| 3375 | |
| 3376 | /** |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3377 | * The account type to which the raw_contact of this item is associated. See |
| 3378 | * {@link RawContacts#ACCOUNT_TYPE} |
| 3379 | * |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3380 | * <p>Type: TEXT</p> |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3381 | * <p>read-only</p> |
| 3382 | */ |
| 3383 | public static final String ACCOUNT_TYPE = "account_type"; |
| 3384 | |
| 3385 | /** |
| 3386 | * The account name to which the raw_contact of this item is associated. See |
| 3387 | * {@link RawContacts#ACCOUNT_NAME} |
| 3388 | * |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3389 | * <p>Type: TEXT</p> |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3390 | * <p>read-only</p> |
| 3391 | */ |
| 3392 | public static final String ACCOUNT_NAME = "account_name"; |
| 3393 | |
| 3394 | /** |
| 3395 | * The data set within the account that the raw_contact of this row belongs to. This allows |
| 3396 | * multiple sync adapters for the same account type to distinguish between |
| 3397 | * each others' data. |
| 3398 | * {@link RawContacts#DATA_SET} |
| 3399 | * |
| 3400 | * <P>Type: TEXT</P> |
| 3401 | * <p>read-only</p> |
| 3402 | */ |
| 3403 | public static final String DATA_SET = "data_set"; |
| 3404 | |
| 3405 | /** |
| 3406 | * The source_id of the raw_contact that this row belongs to. |
| 3407 | * {@link RawContacts#SOURCE_ID} |
| 3408 | * |
| 3409 | * <P>Type: TEXT</P> |
| 3410 | * <p>read-only</p> |
| 3411 | */ |
| 3412 | public static final String RAW_CONTACT_SOURCE_ID = "raw_contact_source_id"; |
| 3413 | |
| 3414 | /** |
| 3415 | * The resource name of the icon for the source of the stream item. |
| 3416 | * This resource should be scoped by the {@link #RES_PACKAGE}. As this can only reference |
| 3417 | * drawables, the "@drawable/" 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_ICON = "icon"; |
| 3421 | |
| 3422 | /** |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3423 | * The resource name of the label describing the source of the status update, e.g. "Google |
| 3424 | * Talk". This resource should be scoped by the {@link #RES_PACKAGE}. As this can only |
| 3425 | * reference strings, the "@string/" prefix must be omitted. |
| 3426 | * <p>Type: TEXT</p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3427 | */ |
| 3428 | public static final String RES_LABEL = "label"; |
| 3429 | |
| 3430 | /** |
| 3431 | * <P> |
| 3432 | * The main textual contents of the item. Typically this is content |
| 3433 | * that was posted by the source of this stream item, but it can also |
| 3434 | * be a textual representation of an action (e.g. ”Checked in at Joe's”). |
| 3435 | * This text is displayed to the user and allows formatting and embedded |
| 3436 | * resource images via HTML (as parseable via |
| 3437 | * {@link android.text.Html#fromHtml}). |
| 3438 | * </P> |
| 3439 | * <P> |
| 3440 | * Long content may be truncated and/or ellipsized - the exact behavior |
| 3441 | * is unspecified, but it should not break tags. |
| 3442 | * </P> |
| 3443 | * <P>Type: TEXT</P> |
| 3444 | */ |
| 3445 | public static final String TEXT = "text"; |
| 3446 | |
| 3447 | /** |
| 3448 | * The absolute time (milliseconds since epoch) when this stream item was |
| 3449 | * inserted/updated. |
| 3450 | * <P>Type: NUMBER</P> |
| 3451 | */ |
| 3452 | public static final String TIMESTAMP = "timestamp"; |
| 3453 | |
| 3454 | /** |
| 3455 | * <P> |
| 3456 | * Summary information about the stream item, for example to indicate how |
| 3457 | * many people have reshared it, how many have liked it, how many thumbs |
| 3458 | * up and/or thumbs down it has, what the original source was, etc. |
| 3459 | * </P> |
| 3460 | * <P> |
| 3461 | * This text is displayed to the user and allows simple formatting via |
| 3462 | * HTML, in the same manner as {@link #TEXT} allows. |
| 3463 | * </P> |
| 3464 | * <P> |
| 3465 | * Long content may be truncated and/or ellipsized - the exact behavior |
| 3466 | * is unspecified, but it should not break tags. |
| 3467 | * </P> |
| 3468 | * <P>Type: TEXT</P> |
| 3469 | */ |
| 3470 | public static final String COMMENTS = "comments"; |
| 3471 | |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3472 | /** Generic column for use by sync adapters. */ |
| 3473 | public static final String SYNC1 = "stream_item_sync1"; |
| 3474 | /** Generic column for use by sync adapters. */ |
| 3475 | public static final String SYNC2 = "stream_item_sync2"; |
| 3476 | /** Generic column for use by sync adapters. */ |
| 3477 | public static final String SYNC3 = "stream_item_sync3"; |
| 3478 | /** Generic column for use by sync adapters. */ |
| 3479 | public static final String SYNC4 = "stream_item_sync4"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3480 | } |
| 3481 | |
| 3482 | /** |
| 3483 | * <p> |
| 3484 | * Constants for the stream_item_photos table, which contains photos associated with |
| 3485 | * social stream updates. |
| 3486 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3487 | * <p> |
| 3488 | * Access to social stream photos requires additional permissions beyond the read/write |
| 3489 | * contact permissions required by the provider. Querying for social stream photos |
| 3490 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating |
| 3491 | * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3492 | * </p> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3493 | * <h3>Account check</h3> |
| 3494 | * <p> |
| 3495 | * The content URIs to the insert, update and delete operations are required to have the account |
| 3496 | * information matching that of the owning raw contact as query parameters, namely |
| 3497 | * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. |
| 3498 | * {@link RawContacts#DATA_SET} isn't required. |
| 3499 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3500 | * <h3>Operations</h3> |
| 3501 | * <dl> |
| 3502 | * <dt><b>Insert</b></dt> |
| 3503 | * <dd> |
| 3504 | * <p>Social stream photo entries are associated with a social stream item. Photos |
| 3505 | * can be inserted into a social stream item in a couple of ways: |
| 3506 | * <dl> |
| 3507 | * <dt> |
| 3508 | * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a |
| 3509 | * stream item: |
| 3510 | * </dt> |
| 3511 | * <dd> |
| 3512 | * <pre> |
| 3513 | * ContentValues values = new ContentValues(); |
| 3514 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3515 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3516 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3517 | * ContentUris.appendId(builder, streamItemId); |
| 3518 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3519 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3520 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3521 | * Uri photoUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3522 | * long photoId = ContentUris.parseId(photoUri); |
| 3523 | * </pre> |
| 3524 | * </dd> |
| 3525 | * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> |
| 3526 | * <dd> |
| 3527 | * <pre> |
| 3528 | * ContentValues values = new ContentValues(); |
| 3529 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
| 3530 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3531 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3532 | * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); |
| 3533 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3534 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3535 | * Uri photoUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3536 | * long photoId = ContentUris.parseId(photoUri); |
| 3537 | * </pre> |
| 3538 | * </dd> |
| 3539 | * </dl> |
| 3540 | * </p> |
| 3541 | * </dd> |
| 3542 | * <dt><b>Update</b></dt> |
| 3543 | * <dd> |
| 3544 | * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry, |
| 3545 | * identified by both the stream item ID it belongs to and the stream item photo ID. |
| 3546 | * This can be specified in two ways. |
| 3547 | * <dl> |
| 3548 | * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a |
| 3549 | * stream item: |
| 3550 | * </dt> |
| 3551 | * <dd> |
| 3552 | * <pre> |
| 3553 | * ContentValues values = new ContentValues(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3554 | * values.put(StreamItemPhotos.PHOTO, newPhotoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3555 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3556 | * ContentUris.appendId(builder, streamItemId); |
| 3557 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3558 | * ContentUris.appendId(builder, streamItemPhotoId); |
| 3559 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3560 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3561 | * getContentResolver().update(builder.build(), values, null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3562 | * </pre> |
| 3563 | * </dd> |
| 3564 | * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> |
| 3565 | * <dd> |
| 3566 | * <pre> |
| 3567 | * ContentValues values = new ContentValues(); |
| 3568 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3569 | * values.put(StreamItemPhotos.PHOTO, newPhotoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3570 | * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); |
| 3571 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3572 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3573 | * getContentResolver().update(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3574 | * </pre> |
| 3575 | * </dd> |
| 3576 | * </dl> |
| 3577 | * </p> |
| 3578 | * </dd> |
| 3579 | * <dt><b>Delete</b></dt> |
| 3580 | * <dd>Deletes can be made against either a specific photo item in a stream item, or |
| 3581 | * against all or a selected subset of photo items under a stream item. |
| 3582 | * For example: |
| 3583 | * <dl> |
| 3584 | * <dt>Deleting a single photo via the |
| 3585 | * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item: |
| 3586 | * </dt> |
| 3587 | * <dd> |
| 3588 | * <pre> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3589 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3590 | * ContentUris.appendId(builder, streamItemId); |
| 3591 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3592 | * ContentUris.appendId(builder, streamItemPhotoId); |
| 3593 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3594 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3595 | * getContentResolver().delete(builder.build(), null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3596 | * </pre> |
| 3597 | * </dd> |
| 3598 | * <dt>Deleting all photos under a stream item</dt> |
| 3599 | * <dd> |
| 3600 | * <pre> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3601 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3602 | * ContentUris.appendId(builder, streamItemId); |
| 3603 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3604 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3605 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3606 | * getContentResolver().delete(builder.build(), null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3607 | * </pre> |
| 3608 | * </dd> |
| 3609 | * </dl> |
| 3610 | * </dd> |
| 3611 | * <dt><b>Query</b></dt> |
| 3612 | * <dl> |
| 3613 | * <dt>Querying for a specific photo in a stream item</dt> |
| 3614 | * <dd> |
| 3615 | * <pre> |
| 3616 | * Cursor c = getContentResolver().query( |
| 3617 | * ContentUris.withAppendedId( |
| 3618 | * Uri.withAppendedPath( |
| 3619 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) |
| 3620 | * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), |
| 3621 | * streamItemPhotoId), null, null, null, null); |
| 3622 | * </pre> |
| 3623 | * </dd> |
| 3624 | * <dt>Querying for all photos in a stream item</dt> |
| 3625 | * <dd> |
| 3626 | * <pre> |
| 3627 | * Cursor c = getContentResolver().query( |
| 3628 | * Uri.withAppendedPath( |
| 3629 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) |
| 3630 | * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), |
| 3631 | * null, null, null, StreamItemPhotos.SORT_INDEX); |
| 3632 | * </pre> |
| 3633 | * </dl> |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3634 | * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a |
| 3635 | * {@link StreamItemPhotos#PHOTO_URI}. The {@link StreamItemPhotos#PHOTO_FILE_ID} |
| 3636 | * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to |
| 3637 | * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as |
| 3638 | * an asset file, as follows: |
| 3639 | * <pre> |
| 3640 | * public InputStream openDisplayPhoto(String photoUri) { |
| 3641 | * try { |
| 3642 | * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r"); |
| 3643 | * return fd.createInputStream(); |
| 3644 | * } catch (IOException e) { |
| 3645 | * return null; |
| 3646 | * } |
| 3647 | * } |
| 3648 | * <pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3649 | * </dd> |
| 3650 | * </dl> |
| 3651 | */ |
| 3652 | public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns { |
| 3653 | /** |
| 3654 | * No public constructor since this is a utility class |
| 3655 | */ |
| 3656 | private StreamItemPhotos() { |
| 3657 | } |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3658 | |
| 3659 | /** |
| 3660 | * <p> |
| 3661 | * The binary representation of the photo. Any size photo can be inserted; |
| 3662 | * the provider will resize it appropriately for storage and display. |
| 3663 | * </p> |
| 3664 | * <p> |
| 3665 | * This is only intended for use when inserting or updating a stream item photo. |
| 3666 | * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI} |
| 3667 | * as an asset file. |
| 3668 | * </p> |
| 3669 | * <P>Type: BLOB</P> |
| 3670 | */ |
| 3671 | public static final String PHOTO = "photo"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3672 | } |
| 3673 | |
| 3674 | /** |
| 3675 | * Columns in the StreamItemPhotos table. |
| 3676 | * |
| 3677 | * @see ContactsContract.StreamItemPhotos |
| 3678 | */ |
| 3679 | protected interface StreamItemPhotosColumns { |
| 3680 | /** |
| 3681 | * A reference to the {@link StreamItems#_ID} this photo is associated with. |
| 3682 | * <P>Type: NUMBER</P> |
| 3683 | */ |
| 3684 | public static final String STREAM_ITEM_ID = "stream_item_id"; |
| 3685 | |
| 3686 | /** |
| 3687 | * An integer to use for sort order for photos in the stream item. If not |
| 3688 | * specified, the {@link StreamItemPhotos#_ID} will be used for sorting. |
| 3689 | * <P>Type: NUMBER</P> |
| 3690 | */ |
| 3691 | public static final String SORT_INDEX = "sort_index"; |
| 3692 | |
| 3693 | /** |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3694 | * Photo file ID for the photo. |
| 3695 | * See {@link ContactsContract.DisplayPhoto}. |
| 3696 | * <P>Type: NUMBER</P> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3697 | */ |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3698 | public static final String PHOTO_FILE_ID = "photo_file_id"; |
| 3699 | |
| 3700 | /** |
| 3701 | * URI for retrieving the photo content, automatically populated. Callers |
| 3702 | * may retrieve the photo content by opening this URI as an asset file. |
| 3703 | * <P>Type: TEXT</P> |
| 3704 | */ |
| 3705 | public static final String PHOTO_URI = "photo_uri"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3706 | |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3707 | /** Generic column for use by sync adapters. */ |
| 3708 | public static final String SYNC1 = "stream_item_photo_sync1"; |
| 3709 | /** Generic column for use by sync adapters. */ |
| 3710 | public static final String SYNC2 = "stream_item_photo_sync2"; |
| 3711 | /** Generic column for use by sync adapters. */ |
| 3712 | public static final String SYNC3 = "stream_item_photo_sync3"; |
| 3713 | /** Generic column for use by sync adapters. */ |
| 3714 | public static final String SYNC4 = "stream_item_photo_sync4"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3715 | } |
| 3716 | |
| 3717 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 3718 | * <p> |
| 3719 | * Constants for the photo files table, which tracks metadata for hi-res photos |
| 3720 | * stored in the file system. |
| 3721 | * </p> |
| 3722 | * |
| 3723 | * @hide |
| 3724 | */ |
| 3725 | public static final class PhotoFiles implements BaseColumns, PhotoFilesColumns { |
| 3726 | /** |
| 3727 | * No public constructor since this is a utility class |
| 3728 | */ |
| 3729 | private PhotoFiles() { |
| 3730 | } |
| 3731 | } |
| 3732 | |
| 3733 | /** |
| 3734 | * Columns in the PhotoFiles table. |
| 3735 | * |
| 3736 | * @see ContactsContract.PhotoFiles |
| 3737 | * |
| 3738 | * @hide |
| 3739 | */ |
| 3740 | protected interface PhotoFilesColumns { |
| 3741 | |
| 3742 | /** |
| 3743 | * The height, in pixels, of the photo this entry is associated with. |
| 3744 | * <P>Type: NUMBER</P> |
| 3745 | */ |
| 3746 | public static final String HEIGHT = "height"; |
| 3747 | |
| 3748 | /** |
| 3749 | * The width, in pixels, of the photo this entry is associated with. |
| 3750 | * <P>Type: NUMBER</P> |
| 3751 | */ |
| 3752 | public static final String WIDTH = "width"; |
| 3753 | |
| 3754 | /** |
| 3755 | * The size, in bytes, of the photo stored on disk. |
| 3756 | * <P>Type: NUMBER</P> |
| 3757 | */ |
| 3758 | public static final String FILESIZE = "filesize"; |
| 3759 | } |
| 3760 | |
| 3761 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3762 | * Columns in the Data table. |
| 3763 | * |
| 3764 | * @see ContactsContract.Data |
| 3765 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 3766 | protected interface DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3767 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 3768 | * The package name to use when creating {@link Resources} objects for |
| 3769 | * this data row. This value is only designed for use when building user |
| 3770 | * interfaces, and should not be used to infer the owner. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 3771 | * |
| 3772 | * @hide |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 3773 | */ |
| 3774 | public static final String RES_PACKAGE = "res_package"; |
| 3775 | |
| 3776 | /** |
| 3777 | * The MIME type of the item represented by this row. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3778 | */ |
| 3779 | public static final String MIMETYPE = "mimetype"; |
| 3780 | |
| 3781 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 3782 | * A reference to the {@link RawContacts#_ID} |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 3783 | * that this data belongs to. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3784 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 3785 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 3786 | |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 3787 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3788 | * 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] | 3789 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 3790 | */ |
| 3791 | public static final String IS_PRIMARY = "is_primary"; |
| 3792 | |
| 3793 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 3794 | * Whether this is the primary entry of its kind for the aggregate |
| 3795 | * contact it belongs to. Any data record that is "super primary" must |
| 3796 | * also be "primary". |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 3797 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 3798 | */ |
| 3799 | public static final String IS_SUPER_PRIMARY = "is_super_primary"; |
| 3800 | |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 3801 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 3802 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 3803 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 3804 | * <P>Type: INTEGER</P> |
| 3805 | */ |
| 3806 | public static final String IS_READ_ONLY = "is_read_only"; |
| 3807 | |
| 3808 | /** |
Fred Quintana | c933fb6 | 2009-06-11 12:14:40 -0700 | [diff] [blame] | 3809 | * The version of this data record. This is a read-only value. The data column is |
| 3810 | * guaranteed to not change without the version going up. This value is monotonically |
| 3811 | * increasing. |
| 3812 | * <P>Type: INTEGER</P> |
| 3813 | */ |
| 3814 | public static final String DATA_VERSION = "data_version"; |
| 3815 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3816 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3817 | public static final String DATA1 = "data1"; |
| 3818 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3819 | public static final String DATA2 = "data2"; |
| 3820 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3821 | public static final String DATA3 = "data3"; |
| 3822 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3823 | public static final String DATA4 = "data4"; |
| 3824 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3825 | public static final String DATA5 = "data5"; |
| 3826 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3827 | public static final String DATA6 = "data6"; |
| 3828 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3829 | public static final String DATA7 = "data7"; |
| 3830 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3831 | public static final String DATA8 = "data8"; |
| 3832 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3833 | public static final String DATA9 = "data9"; |
| 3834 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3835 | public static final String DATA10 = "data10"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 3836 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3837 | public static final String DATA11 = "data11"; |
| 3838 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3839 | public static final String DATA12 = "data12"; |
| 3840 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3841 | public static final String DATA13 = "data13"; |
| 3842 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 3843 | public static final String DATA14 = "data14"; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3844 | /** |
| 3845 | * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention, |
| 3846 | * this field is used to store BLOBs (binary data). |
| 3847 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 3848 | public static final String DATA15 = "data15"; |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 3849 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 3850 | /** Generic column for use by sync adapters. */ |
| 3851 | public static final String SYNC1 = "data_sync1"; |
| 3852 | /** Generic column for use by sync adapters. */ |
| 3853 | public static final String SYNC2 = "data_sync2"; |
| 3854 | /** Generic column for use by sync adapters. */ |
| 3855 | public static final String SYNC3 = "data_sync3"; |
| 3856 | /** Generic column for use by sync adapters. */ |
| 3857 | public static final String SYNC4 = "data_sync4"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3858 | } |
| 3859 | |
| 3860 | /** |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 3861 | * Columns in the Data_Usage_Stat table |
| 3862 | */ |
| 3863 | protected interface DataUsageStatColumns { |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 3864 | /** The last time (in milliseconds) this {@link Data} was used. */ |
| 3865 | public static final String LAST_TIME_USED = "last_time_used"; |
| 3866 | |
Yorke Lee | 5a53d70 | 2013-03-29 18:08:47 -0700 | [diff] [blame] | 3867 | /** The number of times the referenced {@link Data} has been used. */ |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 3868 | public static final String TIMES_USED = "times_used"; |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 3869 | } |
| 3870 | |
| 3871 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3872 | * Combines all columns returned by {@link ContactsContract.Data} table queries. |
| 3873 | * |
| 3874 | * @see ContactsContract.Data |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 3875 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 3876 | protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns, |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 3877 | RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns, |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 3878 | ContactStatusColumns, DataUsageStatColumns { |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 3879 | } |
| 3880 | |
| 3881 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3882 | * <p> |
| 3883 | * 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] | 3884 | * contact. Each row of the data table is typically used to store a single |
| 3885 | * piece of contact |
| 3886 | * information (such as a phone number) and its |
| 3887 | * associated metadata (such as whether it is a work or home number). |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3888 | * </p> |
| 3889 | * <h3>Data kinds</h3> |
| 3890 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3891 | * Data is a generic table that can hold any kind of contact data. |
| 3892 | * The kind of data stored in a given row is specified by the row's |
| 3893 | * {@link #MIMETYPE} value, which determines the meaning of the |
| 3894 | * generic columns {@link #DATA1} through |
| 3895 | * {@link #DATA15}. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3896 | * For example, if the data kind is |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3897 | * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column |
| 3898 | * {@link #DATA1} stores the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3899 | * phone number, but if the data kind is |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3900 | * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1} |
| 3901 | * stores the email address. |
| 3902 | * Sync adapters and applications can introduce their own data kinds. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3903 | * </p> |
| 3904 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3905 | * ContactsContract defines a small number of pre-defined data kinds, e.g. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3906 | * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a |
| 3907 | * convenience, these classes define data kind specific aliases for DATA1 etc. |
| 3908 | * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as |
| 3909 | * {@link ContactsContract.Data Data.DATA1}. |
| 3910 | * </p> |
| 3911 | * <p> |
| 3912 | * {@link #DATA1} is an indexed column and should be used for the data element that is |
| 3913 | * expected to be most frequently used in query selections. For example, in the |
| 3914 | * case of a row representing email addresses {@link #DATA1} should probably |
| 3915 | * be used for the email address itself, while {@link #DATA2} etc can be |
| 3916 | * used for auxiliary information like type of email address. |
| 3917 | * <p> |
| 3918 | * <p> |
| 3919 | * By convention, {@link #DATA15} is used for storing BLOBs (binary data). |
| 3920 | * </p> |
| 3921 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 3922 | * The sync adapter for a given account type must correctly handle every data type |
| 3923 | * used in the corresponding raw contacts. Otherwise it could result in lost or |
| 3924 | * corrupted data. |
| 3925 | * </p> |
| 3926 | * <p> |
| 3927 | * 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] | 3928 | * 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] | 3929 | * "favorite song" to a raw contact owned by a Google account, it will not |
| 3930 | * get synced to the server, because the Google sync adapter does not know |
| 3931 | * how to handle this data kind. Thus new data kinds are typically |
| 3932 | * introduced along with new account types, i.e. new sync adapters. |
| 3933 | * </p> |
| 3934 | * <h3>Batch operations</h3> |
| 3935 | * <p> |
| 3936 | * Data rows can be inserted/updated/deleted using the traditional |
| 3937 | * {@link ContentResolver#insert}, {@link ContentResolver#update} and |
| 3938 | * {@link ContentResolver#delete} methods, however the newer mechanism based |
| 3939 | * on a batch of {@link ContentProviderOperation} will prove to be a better |
| 3940 | * choice in almost all cases. All operations in a batch are executed in a |
| 3941 | * single transaction, which ensures that the phone-side and server-side |
| 3942 | * state of a raw contact are always consistent. Also, the batch-based |
| 3943 | * approach is far more efficient: not only are the database operations |
| 3944 | * faster when executed in a single transaction, but also sending a batch of |
| 3945 | * commands to the content provider saves a lot of time on context switching |
| 3946 | * between your process and the process in which the content provider runs. |
| 3947 | * </p> |
| 3948 | * <p> |
| 3949 | * The flip side of using batched operations is that a large batch may lock |
| 3950 | * up the database for a long time preventing other applications from |
| 3951 | * accessing data and potentially causing ANRs ("Application Not Responding" |
| 3952 | * dialogs.) |
| 3953 | * </p> |
| 3954 | * <p> |
| 3955 | * To avoid such lockups of the database, make sure to insert "yield points" |
| 3956 | * in the batch. A yield point indicates to the content provider that before |
| 3957 | * executing the next operation it can commit the changes that have already |
| 3958 | * been made, yield to other requests, open another transaction and continue |
| 3959 | * processing operations. A yield point will not automatically commit the |
| 3960 | * transaction, but only if there is another request waiting on the |
| 3961 | * database. Normally a sync adapter should insert a yield point at the |
| 3962 | * beginning of each raw contact operation sequence in the batch. See |
| 3963 | * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}. |
| 3964 | * </p> |
| 3965 | * <h3>Operations</h3> |
| 3966 | * <dl> |
| 3967 | * <dt><b>Insert</b></dt> |
| 3968 | * <dd> |
| 3969 | * <p> |
| 3970 | * An individual data row can be inserted using the traditional |
| 3971 | * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows |
| 3972 | * should always be inserted as a batch. |
| 3973 | * </p> |
| 3974 | * <p> |
| 3975 | * An example of a traditional insert: |
| 3976 | * <pre> |
| 3977 | * ContentValues values = new ContentValues(); |
| 3978 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 3979 | * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); |
| 3980 | * values.put(Phone.NUMBER, "1-800-GOOG-411"); |
| 3981 | * values.put(Phone.TYPE, Phone.TYPE_CUSTOM); |
| 3982 | * values.put(Phone.LABEL, "free directory assistance"); |
| 3983 | * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values); |
| 3984 | * </pre> |
| 3985 | * <p> |
| 3986 | * The same done using ContentProviderOperations: |
| 3987 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 3988 | * ArrayList<ContentProviderOperation> ops = |
| 3989 | * new ArrayList<ContentProviderOperation>(); |
| 3990 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3991 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 3992 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 3993 | * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE) |
| 3994 | * .withValue(Phone.NUMBER, "1-800-GOOG-411") |
| 3995 | * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM) |
| 3996 | * .withValue(Phone.LABEL, "free directory assistance") |
| 3997 | * .build()); |
| 3998 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 3999 | * </pre> |
| 4000 | * </p> |
| 4001 | * <dt><b>Update</b></dt> |
| 4002 | * <dd> |
| 4003 | * <p> |
| 4004 | * Just as with insert, update can be done incrementally or as a batch, |
| 4005 | * the batch mode being the preferred method: |
| 4006 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4007 | * ArrayList<ContentProviderOperation> ops = |
| 4008 | * new ArrayList<ContentProviderOperation>(); |
| 4009 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4010 | * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI) |
| 4011 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 4012 | * .withValue(Email.DATA, "somebody@android.com") |
| 4013 | * .build()); |
| 4014 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4015 | * </pre> |
| 4016 | * </p> |
| 4017 | * </dd> |
| 4018 | * <dt><b>Delete</b></dt> |
| 4019 | * <dd> |
| 4020 | * <p> |
| 4021 | * Just as with insert and update, deletion can be done either using the |
| 4022 | * {@link ContentResolver#delete} method or using a ContentProviderOperation: |
| 4023 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4024 | * ArrayList<ContentProviderOperation> ops = |
| 4025 | * new ArrayList<ContentProviderOperation>(); |
| 4026 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4027 | * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI) |
| 4028 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 4029 | * .build()); |
| 4030 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4031 | * </pre> |
| 4032 | * </p> |
| 4033 | * </dd> |
| 4034 | * <dt><b>Query</b></dt> |
| 4035 | * <dd> |
| 4036 | * <p> |
| 4037 | * <dl> |
| 4038 | * <dt>Finding all Data of a given type for a given contact</dt> |
| 4039 | * <dd> |
| 4040 | * <pre> |
| 4041 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 4042 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 4043 | * Data.CONTACT_ID + "=?" + " AND " |
| 4044 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 4045 | * new String[] {String.valueOf(contactId)}, null); |
| 4046 | * </pre> |
| 4047 | * </p> |
| 4048 | * <p> |
| 4049 | * </dd> |
| 4050 | * <dt>Finding all Data of a given type for a given raw contact</dt> |
| 4051 | * <dd> |
| 4052 | * <pre> |
| 4053 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 4054 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 4055 | * Data.RAW_CONTACT_ID + "=?" + " AND " |
| 4056 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 4057 | * new String[] {String.valueOf(rawContactId)}, null); |
| 4058 | * </pre> |
| 4059 | * </dd> |
| 4060 | * <dt>Finding all Data for a given raw contact</dt> |
| 4061 | * <dd> |
| 4062 | * Most sync adapters will want to read all data rows for a raw contact |
| 4063 | * along with the raw contact itself. For that you should use the |
| 4064 | * {@link RawContactsEntity}. See also {@link RawContacts}. |
| 4065 | * </dd> |
| 4066 | * </dl> |
| 4067 | * </p> |
| 4068 | * </dd> |
| 4069 | * </dl> |
| 4070 | * <h2>Columns</h2> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4071 | * <p> |
| 4072 | * Many columns are available via a {@link Data#CONTENT_URI} query. For best performance you |
| 4073 | * should explicitly specify a projection to only those columns that you need. |
| 4074 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4075 | * <table class="jd-sumtable"> |
| 4076 | * <tr> |
| 4077 | * <th colspan='4'>Data</th> |
| 4078 | * </tr> |
| 4079 | * <tr> |
| 4080 | * <td style="width: 7em;">long</td> |
| 4081 | * <td style="width: 20em;">{@link #_ID}</td> |
| 4082 | * <td style="width: 5em;">read-only</td> |
| 4083 | * <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] | 4084 | * 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] | 4085 | * always do an update instead.</td> |
| 4086 | * </tr> |
| 4087 | * <tr> |
| 4088 | * <td>String</td> |
| 4089 | * <td>{@link #MIMETYPE}</td> |
| 4090 | * <td>read/write-once</td> |
| 4091 | * <td> |
| 4092 | * <p>The MIME type of the item represented by this row. Examples of common |
| 4093 | * MIME types are: |
| 4094 | * <ul> |
| 4095 | * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li> |
| 4096 | * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li> |
| 4097 | * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li> |
| 4098 | * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li> |
| 4099 | * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li> |
| 4100 | * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li> |
| 4101 | * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li> |
| 4102 | * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li> |
| 4103 | * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li> |
| 4104 | * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li> |
| 4105 | * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li> |
| 4106 | * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li> |
| 4107 | * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 4108 | * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4109 | * </ul> |
| 4110 | * </p> |
| 4111 | * </td> |
| 4112 | * </tr> |
| 4113 | * <tr> |
| 4114 | * <td>long</td> |
| 4115 | * <td>{@link #RAW_CONTACT_ID}</td> |
| 4116 | * <td>read/write-once</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4117 | * <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] | 4118 | * </tr> |
| 4119 | * <tr> |
| 4120 | * <td>int</td> |
| 4121 | * <td>{@link #IS_PRIMARY}</td> |
| 4122 | * <td>read/write</td> |
| 4123 | * <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] | 4124 | * "1" if true, "0" if false. |
| 4125 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4126 | * </tr> |
| 4127 | * <tr> |
| 4128 | * <td>int</td> |
| 4129 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 4130 | * <td>read/write</td> |
| 4131 | * <td>Whether this is the primary entry of its kind for the aggregate |
| 4132 | * 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] | 4133 | * also be "primary". For example, the super-primary entry may be |
| 4134 | * interpreted as the default contact value of its kind (for example, |
| 4135 | * the default phone number to use for the contact).</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4136 | * </tr> |
| 4137 | * <tr> |
| 4138 | * <td>int</td> |
| 4139 | * <td>{@link #DATA_VERSION}</td> |
| 4140 | * <td>read-only</td> |
| 4141 | * <td>The version of this data record. Whenever the data row changes |
| 4142 | * the version goes up. This value is monotonically increasing.</td> |
| 4143 | * </tr> |
| 4144 | * <tr> |
| 4145 | * <td>Any type</td> |
| 4146 | * <td> |
| 4147 | * {@link #DATA1}<br> |
| 4148 | * {@link #DATA2}<br> |
| 4149 | * {@link #DATA3}<br> |
| 4150 | * {@link #DATA4}<br> |
| 4151 | * {@link #DATA5}<br> |
| 4152 | * {@link #DATA6}<br> |
| 4153 | * {@link #DATA7}<br> |
| 4154 | * {@link #DATA8}<br> |
| 4155 | * {@link #DATA9}<br> |
| 4156 | * {@link #DATA10}<br> |
| 4157 | * {@link #DATA11}<br> |
| 4158 | * {@link #DATA12}<br> |
| 4159 | * {@link #DATA13}<br> |
| 4160 | * {@link #DATA14}<br> |
| 4161 | * {@link #DATA15} |
| 4162 | * </td> |
| 4163 | * <td>read/write</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4164 | * <td> |
| 4165 | * <p> |
| 4166 | * Generic data columns. The meaning of each column is determined by the |
| 4167 | * {@link #MIMETYPE}. By convention, {@link #DATA15} is used for storing |
| 4168 | * BLOBs (binary data). |
| 4169 | * </p> |
| 4170 | * <p> |
| 4171 | * Data columns whose meaning is not explicitly defined for a given MIMETYPE |
| 4172 | * should not be used. There is no guarantee that any sync adapter will |
| 4173 | * preserve them. Sync adapters themselves should not use such columns either, |
| 4174 | * but should instead use {@link #SYNC1}-{@link #SYNC4}. |
| 4175 | * </p> |
| 4176 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4177 | * </tr> |
| 4178 | * <tr> |
| 4179 | * <td>Any type</td> |
| 4180 | * <td> |
| 4181 | * {@link #SYNC1}<br> |
| 4182 | * {@link #SYNC2}<br> |
| 4183 | * {@link #SYNC3}<br> |
| 4184 | * {@link #SYNC4} |
| 4185 | * </td> |
| 4186 | * <td>read/write</td> |
| 4187 | * <td>Generic columns for use by sync adapters. For example, a Photo row |
| 4188 | * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error) |
| 4189 | * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td> |
| 4190 | * </tr> |
| 4191 | * </table> |
| 4192 | * |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4193 | * <p> |
| 4194 | * Some columns from the most recent associated status update are also available |
| 4195 | * through an implicit join. |
| 4196 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4197 | * <table class="jd-sumtable"> |
| 4198 | * <tr> |
| 4199 | * <th colspan='4'>Join with {@link StatusUpdates}</th> |
| 4200 | * </tr> |
| 4201 | * <tr> |
| 4202 | * <td style="width: 7em;">int</td> |
| 4203 | * <td style="width: 20em;">{@link #PRESENCE}</td> |
| 4204 | * <td style="width: 5em;">read-only</td> |
| 4205 | * <td>IM presence status linked to this data row. Compare with |
| 4206 | * {@link #CONTACT_PRESENCE}, which contains the contact's presence across |
| 4207 | * all IM rows. See {@link StatusUpdates} for individual status definitions. |
| 4208 | * The provider may choose not to store this value |
| 4209 | * in persistent storage. The expectation is that presence status will be |
kmccormick | 50e27c8 | 2013-03-28 16:33:11 -0700 | [diff] [blame] | 4210 | * updated on a regular basis. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4211 | * </td> |
| 4212 | * </tr> |
| 4213 | * <tr> |
| 4214 | * <td>String</td> |
| 4215 | * <td>{@link #STATUS}</td> |
| 4216 | * <td>read-only</td> |
| 4217 | * <td>Latest status update linked with this data row.</td> |
| 4218 | * </tr> |
| 4219 | * <tr> |
| 4220 | * <td>long</td> |
| 4221 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 4222 | * <td>read-only</td> |
| 4223 | * <td>The absolute time in milliseconds when the latest status was |
| 4224 | * inserted/updated for this data row.</td> |
| 4225 | * </tr> |
| 4226 | * <tr> |
| 4227 | * <td>String</td> |
| 4228 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 4229 | * <td>read-only</td> |
| 4230 | * <td>The package containing resources for this status: label and icon.</td> |
| 4231 | * </tr> |
| 4232 | * <tr> |
| 4233 | * <td>long</td> |
| 4234 | * <td>{@link #STATUS_LABEL}</td> |
| 4235 | * <td>read-only</td> |
| 4236 | * <td>The resource ID of the label describing the source of status update linked |
| 4237 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4238 | * </tr> |
| 4239 | * <tr> |
| 4240 | * <td>long</td> |
| 4241 | * <td>{@link #STATUS_ICON}</td> |
| 4242 | * <td>read-only</td> |
| 4243 | * <td>The resource ID of the icon for the source of the status update linked |
| 4244 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4245 | * </tr> |
| 4246 | * </table> |
| 4247 | * |
| 4248 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4249 | * Some columns from the associated raw contact are also available through an |
| 4250 | * implicit join. The other columns are excluded as uninteresting in this |
| 4251 | * context. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4252 | * </p> |
| 4253 | * |
| 4254 | * <table class="jd-sumtable"> |
| 4255 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4256 | * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4257 | * </tr> |
| 4258 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4259 | * <td style="width: 7em;">long</td> |
| 4260 | * <td style="width: 20em;">{@link #CONTACT_ID}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4261 | * <td style="width: 5em;">read-only</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4262 | * <td>The id of the row in the {@link Contacts} table that this data belongs |
| 4263 | * to.</td> |
| 4264 | * </tr> |
| 4265 | * <tr> |
| 4266 | * <td>int</td> |
| 4267 | * <td>{@link #AGGREGATION_MODE}</td> |
| 4268 | * <td>read-only</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4269 | * <td>See {@link RawContacts}.</td> |
| 4270 | * </tr> |
| 4271 | * <tr> |
| 4272 | * <td>int</td> |
| 4273 | * <td>{@link #DELETED}</td> |
| 4274 | * <td>read-only</td> |
| 4275 | * <td>See {@link RawContacts}.</td> |
| 4276 | * </tr> |
| 4277 | * </table> |
| 4278 | * |
| 4279 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4280 | * The ID column for the associated aggregated contact table |
| 4281 | * {@link ContactsContract.Contacts} is available |
| 4282 | * via the implicit join to the {@link RawContacts} table, see above. |
| 4283 | * The remaining columns from this table are also |
| 4284 | * available, through an implicit join. This |
| 4285 | * facilitates lookup by |
| 4286 | * the value of a single data element, such as the email address. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4287 | * </p> |
| 4288 | * |
| 4289 | * <table class="jd-sumtable"> |
| 4290 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4291 | * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4292 | * </tr> |
| 4293 | * <tr> |
| 4294 | * <td style="width: 7em;">String</td> |
| 4295 | * <td style="width: 20em;">{@link #LOOKUP_KEY}</td> |
| 4296 | * <td style="width: 5em;">read-only</td> |
| 4297 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4298 | * </tr> |
| 4299 | * <tr> |
| 4300 | * <td>String</td> |
| 4301 | * <td>{@link #DISPLAY_NAME}</td> |
| 4302 | * <td>read-only</td> |
| 4303 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4304 | * </tr> |
| 4305 | * <tr> |
| 4306 | * <td>long</td> |
| 4307 | * <td>{@link #PHOTO_ID}</td> |
| 4308 | * <td>read-only</td> |
| 4309 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4310 | * </tr> |
| 4311 | * <tr> |
| 4312 | * <td>int</td> |
| 4313 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 4314 | * <td>read-only</td> |
| 4315 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4316 | * </tr> |
| 4317 | * <tr> |
| 4318 | * <td>int</td> |
| 4319 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 4320 | * <td>read-only</td> |
| 4321 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4322 | * </tr> |
| 4323 | * <tr> |
| 4324 | * <td>int</td> |
| 4325 | * <td>{@link #TIMES_CONTACTED}</td> |
| 4326 | * <td>read-only</td> |
| 4327 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4328 | * </tr> |
| 4329 | * <tr> |
| 4330 | * <td>long</td> |
| 4331 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 4332 | * <td>read-only</td> |
| 4333 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4334 | * </tr> |
| 4335 | * <tr> |
| 4336 | * <td>int</td> |
| 4337 | * <td>{@link #STARRED}</td> |
| 4338 | * <td>read-only</td> |
| 4339 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4340 | * </tr> |
| 4341 | * <tr> |
| 4342 | * <td>String</td> |
| 4343 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 4344 | * <td>read-only</td> |
| 4345 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4346 | * </tr> |
| 4347 | * <tr> |
| 4348 | * <td>int</td> |
| 4349 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 4350 | * <td>read-only</td> |
| 4351 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4352 | * </tr> |
| 4353 | * <tr> |
| 4354 | * <td>int</td> |
| 4355 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 4356 | * <td>read-only</td> |
| 4357 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4358 | * </tr> |
| 4359 | * <tr> |
| 4360 | * <td>String</td> |
| 4361 | * <td>{@link #CONTACT_STATUS}</td> |
| 4362 | * <td>read-only</td> |
| 4363 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4364 | * </tr> |
| 4365 | * <tr> |
| 4366 | * <td>long</td> |
| 4367 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 4368 | * <td>read-only</td> |
| 4369 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4370 | * </tr> |
| 4371 | * <tr> |
| 4372 | * <td>String</td> |
| 4373 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 4374 | * <td>read-only</td> |
| 4375 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4376 | * </tr> |
| 4377 | * <tr> |
| 4378 | * <td>long</td> |
| 4379 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 4380 | * <td>read-only</td> |
| 4381 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4382 | * </tr> |
| 4383 | * <tr> |
| 4384 | * <td>long</td> |
| 4385 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 4386 | * <td>read-only</td> |
| 4387 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4388 | * </tr> |
| 4389 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4390 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4391 | public final static class Data implements DataColumnsWithJoins { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4392 | /** |
| 4393 | * This utility class cannot be instantiated |
| 4394 | */ |
| 4395 | private Data() {} |
| 4396 | |
| 4397 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4398 | * The content:// style URI for this table, which requests a directory |
| 4399 | * of data rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4400 | */ |
| 4401 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); |
| 4402 | |
| 4403 | /** |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 4404 | * A boolean parameter for {@link Data#CONTENT_URI}. |
| 4405 | * This specifies whether or not the returned data items should be filtered to show |
| 4406 | * data items belonging to visible contacts only. |
| 4407 | */ |
| 4408 | public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; |
| 4409 | |
| 4410 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4411 | * The MIME type of the results from {@link #CONTENT_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4412 | */ |
| 4413 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 4414 | |
| 4415 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4416 | * <p> |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4417 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 4418 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4419 | * entry of the given {@link ContactsContract.Data} entry. |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4420 | * </p> |
| 4421 | * <p> |
| 4422 | * Returns the Uri for the contact in the first entry returned by |
| 4423 | * {@link ContentResolver#query(Uri, String[], String, String[], String)} |
| 4424 | * for the provided {@code dataUri}. If the query returns null or empty |
| 4425 | * results, silently returns null. |
| 4426 | * </p> |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 4427 | */ |
| 4428 | public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) { |
| 4429 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 4430 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 4431 | }, null, null, null); |
| 4432 | |
| 4433 | Uri lookupUri = null; |
| 4434 | try { |
| 4435 | if (cursor != null && cursor.moveToFirst()) { |
| 4436 | final long contactId = cursor.getLong(0); |
| 4437 | final String lookupKey = cursor.getString(1); |
| 4438 | return Contacts.getLookupUri(contactId, lookupKey); |
| 4439 | } |
| 4440 | } finally { |
| 4441 | if (cursor != null) cursor.close(); |
| 4442 | } |
| 4443 | return lookupUri; |
| 4444 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4445 | } |
| 4446 | |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 4447 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4448 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4449 | * 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] | 4450 | * an outer join of the raw_contacts table with the data table. It is a strictly |
| 4451 | * read-only table. |
| 4452 | * </p> |
| 4453 | * <p> |
| 4454 | * If a raw contact has data rows, the RawContactsEntity cursor will contain |
| 4455 | * a one row for each data row. If the raw contact has no data rows, the |
| 4456 | * cursor will still contain one row with the raw contact-level information |
| 4457 | * and nulls for data columns. |
| 4458 | * |
| 4459 | * <pre> |
| 4460 | * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId); |
| 4461 | * Cursor c = getContentResolver().query(entityUri, |
| 4462 | * new String[]{ |
| 4463 | * RawContactsEntity.SOURCE_ID, |
| 4464 | * RawContactsEntity.DATA_ID, |
| 4465 | * RawContactsEntity.MIMETYPE, |
| 4466 | * RawContactsEntity.DATA1 |
| 4467 | * }, null, null, null); |
| 4468 | * try { |
| 4469 | * while (c.moveToNext()) { |
| 4470 | * String sourceId = c.getString(0); |
| 4471 | * if (!c.isNull(1)) { |
| 4472 | * String mimeType = c.getString(2); |
| 4473 | * String data = c.getString(3); |
| 4474 | * ... |
| 4475 | * } |
| 4476 | * } |
| 4477 | * } finally { |
| 4478 | * c.close(); |
| 4479 | * } |
| 4480 | * </pre> |
| 4481 | * |
| 4482 | * <h3>Columns</h3> |
| 4483 | * RawContactsEntity has a combination of RawContact and Data columns. |
| 4484 | * |
| 4485 | * <table class="jd-sumtable"> |
| 4486 | * <tr> |
| 4487 | * <th colspan='4'>RawContacts</th> |
| 4488 | * </tr> |
| 4489 | * <tr> |
| 4490 | * <td style="width: 7em;">long</td> |
| 4491 | * <td style="width: 20em;">{@link #_ID}</td> |
| 4492 | * <td style="width: 5em;">read-only</td> |
| 4493 | * <td>Raw contact row ID. See {@link RawContacts}.</td> |
| 4494 | * </tr> |
| 4495 | * <tr> |
| 4496 | * <td>long</td> |
| 4497 | * <td>{@link #CONTACT_ID}</td> |
| 4498 | * <td>read-only</td> |
| 4499 | * <td>See {@link RawContacts}.</td> |
| 4500 | * </tr> |
| 4501 | * <tr> |
| 4502 | * <td>int</td> |
| 4503 | * <td>{@link #AGGREGATION_MODE}</td> |
| 4504 | * <td>read-only</td> |
| 4505 | * <td>See {@link RawContacts}.</td> |
| 4506 | * </tr> |
| 4507 | * <tr> |
| 4508 | * <td>int</td> |
| 4509 | * <td>{@link #DELETED}</td> |
| 4510 | * <td>read-only</td> |
| 4511 | * <td>See {@link RawContacts}.</td> |
| 4512 | * </tr> |
| 4513 | * </table> |
| 4514 | * |
| 4515 | * <table class="jd-sumtable"> |
| 4516 | * <tr> |
| 4517 | * <th colspan='4'>Data</th> |
| 4518 | * </tr> |
| 4519 | * <tr> |
| 4520 | * <td style="width: 7em;">long</td> |
| 4521 | * <td style="width: 20em;">{@link #DATA_ID}</td> |
| 4522 | * <td style="width: 5em;">read-only</td> |
| 4523 | * <td>Data row ID. It will be null if the raw contact has no data rows.</td> |
| 4524 | * </tr> |
| 4525 | * <tr> |
| 4526 | * <td>String</td> |
| 4527 | * <td>{@link #MIMETYPE}</td> |
| 4528 | * <td>read-only</td> |
| 4529 | * <td>See {@link ContactsContract.Data}.</td> |
| 4530 | * </tr> |
| 4531 | * <tr> |
| 4532 | * <td>int</td> |
| 4533 | * <td>{@link #IS_PRIMARY}</td> |
| 4534 | * <td>read-only</td> |
| 4535 | * <td>See {@link ContactsContract.Data}.</td> |
| 4536 | * </tr> |
| 4537 | * <tr> |
| 4538 | * <td>int</td> |
| 4539 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 4540 | * <td>read-only</td> |
| 4541 | * <td>See {@link ContactsContract.Data}.</td> |
| 4542 | * </tr> |
| 4543 | * <tr> |
| 4544 | * <td>int</td> |
| 4545 | * <td>{@link #DATA_VERSION}</td> |
| 4546 | * <td>read-only</td> |
| 4547 | * <td>See {@link ContactsContract.Data}.</td> |
| 4548 | * </tr> |
| 4549 | * <tr> |
| 4550 | * <td>Any type</td> |
| 4551 | * <td> |
| 4552 | * {@link #DATA1}<br> |
| 4553 | * {@link #DATA2}<br> |
| 4554 | * {@link #DATA3}<br> |
| 4555 | * {@link #DATA4}<br> |
| 4556 | * {@link #DATA5}<br> |
| 4557 | * {@link #DATA6}<br> |
| 4558 | * {@link #DATA7}<br> |
| 4559 | * {@link #DATA8}<br> |
| 4560 | * {@link #DATA9}<br> |
| 4561 | * {@link #DATA10}<br> |
| 4562 | * {@link #DATA11}<br> |
| 4563 | * {@link #DATA12}<br> |
| 4564 | * {@link #DATA13}<br> |
| 4565 | * {@link #DATA14}<br> |
| 4566 | * {@link #DATA15} |
| 4567 | * </td> |
| 4568 | * <td>read-only</td> |
| 4569 | * <td>See {@link ContactsContract.Data}.</td> |
| 4570 | * </tr> |
| 4571 | * <tr> |
| 4572 | * <td>Any type</td> |
| 4573 | * <td> |
| 4574 | * {@link #SYNC1}<br> |
| 4575 | * {@link #SYNC2}<br> |
| 4576 | * {@link #SYNC3}<br> |
| 4577 | * {@link #SYNC4} |
| 4578 | * </td> |
| 4579 | * <td>read-only</td> |
| 4580 | * <td>See {@link ContactsContract.Data}.</td> |
| 4581 | * </tr> |
| 4582 | * </table> |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 4583 | */ |
| 4584 | public final static class RawContactsEntity |
| 4585 | implements BaseColumns, DataColumns, RawContactsColumns { |
| 4586 | /** |
| 4587 | * This utility class cannot be instantiated |
| 4588 | */ |
| 4589 | private RawContactsEntity() {} |
| 4590 | |
| 4591 | /** |
| 4592 | * The content:// style URI for this table |
| 4593 | */ |
| 4594 | public static final Uri CONTENT_URI = |
| 4595 | Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities"); |
| 4596 | |
| 4597 | /** |
Dave Santoro | 2b4d075 | 2011-09-07 17:37:33 -0700 | [diff] [blame] | 4598 | * The content:// style URI for this table, specific to the user's profile. |
| 4599 | */ |
| 4600 | public static final Uri PROFILE_CONTENT_URI = |
| 4601 | Uri.withAppendedPath(Profile.CONTENT_URI, "raw_contact_entities"); |
| 4602 | |
| 4603 | /** |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 4604 | * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities. |
| 4605 | */ |
| 4606 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity"; |
| 4607 | |
| 4608 | /** |
| 4609 | * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward |
| 4610 | * Data.CONTENT_URI contains only exportable data. |
| 4611 | * |
| 4612 | * This flag is useful (currently) only for vCard exporter in Contacts app, which |
| 4613 | * needs to exclude "un-exportable" data from available data to export, while |
| 4614 | * Contacts app itself has priviledge to access all data including "un-expotable" |
| 4615 | * ones and providers return all of them regardless of the callers' intention. |
| 4616 | * <P>Type: INTEGER</p> |
| 4617 | * |
| 4618 | * @hide Maybe available only in Eclair and not really ready for public use. |
| 4619 | * TODO: remove, or implement this feature completely. As of now (Eclair), |
| 4620 | * we only use this flag in queryEntities(), not query(). |
| 4621 | */ |
| 4622 | public static final String FOR_EXPORT_ONLY = "for_export_only"; |
| 4623 | |
| 4624 | /** |
| 4625 | * The ID of the data column. The value will be null if this raw contact has no data rows. |
| 4626 | * <P>Type: INTEGER</P> |
| 4627 | */ |
| 4628 | public static final String DATA_ID = "data_id"; |
| 4629 | } |
| 4630 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4631 | /** |
| 4632 | * @see PhoneLookup |
| 4633 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 4634 | protected interface PhoneLookupColumns { |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4635 | /** |
| 4636 | * The phone number as the user entered it. |
| 4637 | * <P>Type: TEXT</P> |
| 4638 | */ |
| 4639 | public static final String NUMBER = "number"; |
| 4640 | |
| 4641 | /** |
| 4642 | * The type of phone number, for example Home or Work. |
| 4643 | * <P>Type: INTEGER</P> |
| 4644 | */ |
| 4645 | public static final String TYPE = "type"; |
| 4646 | |
| 4647 | /** |
| 4648 | * The user defined label for the phone number. |
| 4649 | * <P>Type: TEXT</P> |
| 4650 | */ |
| 4651 | public static final String LABEL = "label"; |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 4652 | |
| 4653 | /** |
| 4654 | * The phone number's E164 representation. |
| 4655 | * <P>Type: TEXT</P> |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 4656 | */ |
| 4657 | public static final String NORMALIZED_NUMBER = "normalized_number"; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4658 | } |
| 4659 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4660 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4661 | * 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] | 4662 | * 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] | 4663 | * want to find to {@link #CONTENT_FILTER_URI}. This query is highly |
| 4664 | * optimized. |
| 4665 | * <pre> |
| 4666 | * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); |
| 4667 | * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,... |
| 4668 | * </pre> |
| 4669 | * |
| 4670 | * <h3>Columns</h3> |
| 4671 | * |
| 4672 | * <table class="jd-sumtable"> |
| 4673 | * <tr> |
| 4674 | * <th colspan='4'>PhoneLookup</th> |
| 4675 | * </tr> |
| 4676 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4677 | * <td>String</td> |
| 4678 | * <td>{@link #NUMBER}</td> |
| 4679 | * <td>read-only</td> |
| 4680 | * <td>Phone number.</td> |
| 4681 | * </tr> |
| 4682 | * <tr> |
| 4683 | * <td>String</td> |
| 4684 | * <td>{@link #TYPE}</td> |
| 4685 | * <td>read-only</td> |
| 4686 | * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td> |
| 4687 | * </tr> |
| 4688 | * <tr> |
| 4689 | * <td>String</td> |
| 4690 | * <td>{@link #LABEL}</td> |
| 4691 | * <td>read-only</td> |
| 4692 | * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td> |
| 4693 | * </tr> |
| 4694 | * </table> |
| 4695 | * <p> |
| 4696 | * Columns from the Contacts table are also available through a join. |
| 4697 | * </p> |
| 4698 | * <table class="jd-sumtable"> |
| 4699 | * <tr> |
| 4700 | * <th colspan='4'>Join with {@link Contacts}</th> |
| 4701 | * </tr> |
| 4702 | * <tr> |
Dmitri Plotnikov | 817b3f9 | 2011-01-09 17:07:13 -0800 | [diff] [blame] | 4703 | * <td>long</td> |
| 4704 | * <td>{@link #_ID}</td> |
| 4705 | * <td>read-only</td> |
| 4706 | * <td>Contact ID.</td> |
| 4707 | * </tr> |
| 4708 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4709 | * <td>String</td> |
| 4710 | * <td>{@link #LOOKUP_KEY}</td> |
| 4711 | * <td>read-only</td> |
| 4712 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4713 | * </tr> |
| 4714 | * <tr> |
| 4715 | * <td>String</td> |
| 4716 | * <td>{@link #DISPLAY_NAME}</td> |
| 4717 | * <td>read-only</td> |
| 4718 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4719 | * </tr> |
| 4720 | * <tr> |
| 4721 | * <td>long</td> |
| 4722 | * <td>{@link #PHOTO_ID}</td> |
| 4723 | * <td>read-only</td> |
| 4724 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4725 | * </tr> |
| 4726 | * <tr> |
| 4727 | * <td>int</td> |
| 4728 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 4729 | * <td>read-only</td> |
| 4730 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4731 | * </tr> |
| 4732 | * <tr> |
| 4733 | * <td>int</td> |
| 4734 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 4735 | * <td>read-only</td> |
| 4736 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4737 | * </tr> |
| 4738 | * <tr> |
| 4739 | * <td>int</td> |
| 4740 | * <td>{@link #TIMES_CONTACTED}</td> |
| 4741 | * <td>read-only</td> |
| 4742 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4743 | * </tr> |
| 4744 | * <tr> |
| 4745 | * <td>long</td> |
| 4746 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 4747 | * <td>read-only</td> |
| 4748 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4749 | * </tr> |
| 4750 | * <tr> |
| 4751 | * <td>int</td> |
| 4752 | * <td>{@link #STARRED}</td> |
| 4753 | * <td>read-only</td> |
| 4754 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4755 | * </tr> |
| 4756 | * <tr> |
| 4757 | * <td>String</td> |
| 4758 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 4759 | * <td>read-only</td> |
| 4760 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4761 | * </tr> |
| 4762 | * <tr> |
| 4763 | * <td>int</td> |
| 4764 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 4765 | * <td>read-only</td> |
| 4766 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4767 | * </tr> |
| 4768 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4769 | */ |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4770 | public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, |
| 4771 | ContactsColumns, ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4772 | /** |
| 4773 | * This utility class cannot be instantiated |
| 4774 | */ |
| 4775 | private PhoneLookup() {} |
| 4776 | |
| 4777 | /** |
| 4778 | * The content:// style URI for this table. Append the phone number you want to lookup |
| 4779 | * to this URI and query it to perform a lookup. For example: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4780 | * <pre> |
Scott Kennedy | 7ed189e | 2013-01-11 22:31:43 -0800 | [diff] [blame] | 4781 | * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, |
| 4782 | * Uri.encode(phoneNumber)); |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4783 | * </pre> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4784 | */ |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4785 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 4786 | "phone_lookup"); |
Dmitri Plotnikov | 0b0b8a8 | 2010-03-04 18:20:08 -0800 | [diff] [blame] | 4787 | |
| 4788 | /** |
| 4789 | * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows. |
| 4790 | * |
| 4791 | * @hide |
| 4792 | */ |
| 4793 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup"; |
Flavio Lerda | 52c01c2 | 2011-11-02 22:16:23 +0000 | [diff] [blame] | 4794 | |
| 4795 | /** |
| 4796 | * Boolean parameter that is used to look up a SIP address. |
| 4797 | * |
| 4798 | * @hide |
| 4799 | */ |
| 4800 | public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4801 | } |
| 4802 | |
| 4803 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 4804 | * Additional data mixed in with {@link StatusColumns} to link |
| 4805 | * back to specific {@link ContactsContract.Data#_ID} entries. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4806 | * |
| 4807 | * @see StatusUpdates |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4808 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 4809 | protected interface PresenceColumns { |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 4810 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4811 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4812 | * Reference to the {@link Data#_ID} entry that owns this presence. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4813 | * <P>Type: INTEGER</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4814 | */ |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 4815 | public static final String DATA_ID = "presence_data_id"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4816 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4817 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4818 | * See {@link CommonDataKinds.Im} for a list of defined protocol constants. |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 4819 | * <p>Type: NUMBER</p> |
| 4820 | */ |
| 4821 | public static final String PROTOCOL = "protocol"; |
| 4822 | |
| 4823 | /** |
| 4824 | * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 4825 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 4826 | * omitted if {@link #PROTOCOL} value is not |
| 4827 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. |
| 4828 | * |
| 4829 | * <p>Type: NUMBER</p> |
| 4830 | */ |
| 4831 | public static final String CUSTOM_PROTOCOL = "custom_protocol"; |
| 4832 | |
| 4833 | /** |
| 4834 | * The IM handle the presence item is for. The handle is scoped to |
| 4835 | * {@link #PROTOCOL}. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4836 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4837 | */ |
| 4838 | public static final String IM_HANDLE = "im_handle"; |
| 4839 | |
| 4840 | /** |
| 4841 | * 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] | 4842 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 4843 | */ |
| 4844 | public static final String IM_ACCOUNT = "im_account"; |
| 4845 | } |
| 4846 | |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 4847 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4848 | * <p> |
| 4849 | * A status update is linked to a {@link ContactsContract.Data} row and captures |
| 4850 | * the user's latest status update via the corresponding source, e.g. |
| 4851 | * "Having lunch" via "Google Talk". |
| 4852 | * </p> |
| 4853 | * <p> |
| 4854 | * There are two ways a status update can be inserted: by explicitly linking |
| 4855 | * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row |
| 4856 | * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 4857 | * {@link #IM_HANDLE}. There is no difference between insert and update, you can use |
| 4858 | * either. |
| 4859 | * </p> |
| 4860 | * <p> |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 4861 | * Inserting or updating a status update for the user's profile requires either using |
| 4862 | * the {@link #DATA_ID} to identify the data row to attach the update to, or |
| 4863 | * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the |
| 4864 | * profile. |
| 4865 | * </p> |
| 4866 | * <p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4867 | * You cannot use {@link ContentResolver#update} to change a status, but |
| 4868 | * {@link ContentResolver#insert} will replace the latests status if it already |
| 4869 | * exists. |
| 4870 | * </p> |
| 4871 | * <p> |
| 4872 | * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses |
| 4873 | * for multiple contacts at once. |
| 4874 | * </p> |
| 4875 | * |
| 4876 | * <h3>Columns</h3> |
| 4877 | * <table class="jd-sumtable"> |
| 4878 | * <tr> |
| 4879 | * <th colspan='4'>StatusUpdates</th> |
| 4880 | * </tr> |
| 4881 | * <tr> |
| 4882 | * <td>long</td> |
| 4883 | * <td>{@link #DATA_ID}</td> |
| 4884 | * <td>read/write</td> |
| 4885 | * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this |
| 4886 | * field is <i>not</i> specified, the provider will attempt to find a data row |
| 4887 | * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 4888 | * {@link #IM_HANDLE} columns. |
| 4889 | * </td> |
| 4890 | * </tr> |
| 4891 | * <tr> |
| 4892 | * <td>long</td> |
| 4893 | * <td>{@link #PROTOCOL}</td> |
| 4894 | * <td>read/write</td> |
| 4895 | * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td> |
| 4896 | * </tr> |
| 4897 | * <tr> |
| 4898 | * <td>String</td> |
| 4899 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 4900 | * <td>read/write</td> |
| 4901 | * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 4902 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 4903 | * omitted if {@link #PROTOCOL} value is not |
| 4904 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td> |
| 4905 | * </tr> |
| 4906 | * <tr> |
| 4907 | * <td>String</td> |
| 4908 | * <td>{@link #IM_HANDLE}</td> |
| 4909 | * <td>read/write</td> |
| 4910 | * <td> The IM handle the presence item is for. The handle is scoped to |
| 4911 | * {@link #PROTOCOL}.</td> |
| 4912 | * </tr> |
| 4913 | * <tr> |
| 4914 | * <td>String</td> |
| 4915 | * <td>{@link #IM_ACCOUNT}</td> |
| 4916 | * <td>read/write</td> |
| 4917 | * <td>The IM account for the local user that the presence data came from.</td> |
| 4918 | * </tr> |
| 4919 | * <tr> |
| 4920 | * <td>int</td> |
| 4921 | * <td>{@link #PRESENCE}</td> |
| 4922 | * <td>read/write</td> |
| 4923 | * <td>Contact IM presence status. The allowed values are: |
| 4924 | * <p> |
| 4925 | * <ul> |
| 4926 | * <li>{@link #OFFLINE}</li> |
| 4927 | * <li>{@link #INVISIBLE}</li> |
| 4928 | * <li>{@link #AWAY}</li> |
| 4929 | * <li>{@link #IDLE}</li> |
| 4930 | * <li>{@link #DO_NOT_DISTURB}</li> |
| 4931 | * <li>{@link #AVAILABLE}</li> |
| 4932 | * </ul> |
| 4933 | * </p> |
| 4934 | * <p> |
| 4935 | * Since presence status is inherently volatile, the content provider |
| 4936 | * may choose not to store this field in long-term storage. |
| 4937 | * </p> |
| 4938 | * </td> |
| 4939 | * </tr> |
| 4940 | * <tr> |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 4941 | * <td>int</td> |
| 4942 | * <td>{@link #CHAT_CAPABILITY}</td> |
| 4943 | * <td>read/write</td> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 4944 | * <td>Contact IM chat compatibility value. The allowed values combinations of the following |
| 4945 | * 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] | 4946 | * <p> |
| 4947 | * <ul> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 4948 | * <li>{@link #CAPABILITY_HAS_VIDEO}</li> |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 4949 | * <li>{@link #CAPABILITY_HAS_VOICE}</li> |
| 4950 | * <li>{@link #CAPABILITY_HAS_CAMERA}</li> |
| 4951 | * </ul> |
| 4952 | * </p> |
| 4953 | * <p> |
| 4954 | * Since chat compatibility is inherently volatile as the contact's availability moves from |
| 4955 | * one device to another, the content provider may choose not to store this field in long-term |
| 4956 | * storage. |
| 4957 | * </p> |
| 4958 | * </td> |
| 4959 | * </tr> |
| 4960 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4961 | * <td>String</td> |
| 4962 | * <td>{@link #STATUS}</td> |
| 4963 | * <td>read/write</td> |
| 4964 | * <td>Contact's latest status update, e.g. "having toast for breakfast"</td> |
| 4965 | * </tr> |
| 4966 | * <tr> |
| 4967 | * <td>long</td> |
| 4968 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 4969 | * <td>read/write</td> |
| 4970 | * <td>The absolute time in milliseconds when the status was |
| 4971 | * entered by the user. If this value is not provided, the provider will follow |
| 4972 | * this logic: if there was no prior status update, the value will be left as null. |
| 4973 | * If there was a prior status update, the provider will default this field |
| 4974 | * to the current time.</td> |
| 4975 | * </tr> |
| 4976 | * <tr> |
| 4977 | * <td>String</td> |
| 4978 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 4979 | * <td>read/write</td> |
| 4980 | * <td> The package containing resources for this status: label and icon.</td> |
| 4981 | * </tr> |
| 4982 | * <tr> |
| 4983 | * <td>long</td> |
| 4984 | * <td>{@link #STATUS_LABEL}</td> |
| 4985 | * <td>read/write</td> |
| 4986 | * <td>The resource ID of the label describing the source of contact status, |
| 4987 | * e.g. "Google Talk". This resource is scoped by the |
| 4988 | * {@link #STATUS_RES_PACKAGE}.</td> |
| 4989 | * </tr> |
| 4990 | * <tr> |
| 4991 | * <td>long</td> |
| 4992 | * <td>{@link #STATUS_ICON}</td> |
| 4993 | * <td>read/write</td> |
| 4994 | * <td>The resource ID of the icon for the source of contact status. This |
| 4995 | * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4996 | * </tr> |
| 4997 | * </table> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 4998 | */ |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4999 | public static class StatusUpdates implements StatusColumns, PresenceColumns { |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 5000 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5001 | /** |
| 5002 | * This utility class cannot be instantiated |
| 5003 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5004 | private StatusUpdates() {} |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5005 | |
| 5006 | /** |
| 5007 | * The content:// style URI for this table |
| 5008 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5009 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates"); |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5010 | |
| 5011 | /** |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 5012 | * The content:// style URI for this table, specific to the user's profile. |
| 5013 | */ |
| 5014 | public static final Uri PROFILE_CONTENT_URI = |
| 5015 | Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates"); |
| 5016 | |
| 5017 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5018 | * Gets the resource ID for the proper presence icon. |
| 5019 | * |
| 5020 | * @param status the status to get the icon for |
| 5021 | * @return the resource ID for the proper presence icon |
| 5022 | */ |
| 5023 | public static final int getPresenceIconResourceId(int status) { |
| 5024 | switch (status) { |
| 5025 | case AVAILABLE: |
| 5026 | return android.R.drawable.presence_online; |
| 5027 | case IDLE: |
| 5028 | case AWAY: |
| 5029 | return android.R.drawable.presence_away; |
| 5030 | case DO_NOT_DISTURB: |
| 5031 | return android.R.drawable.presence_busy; |
| 5032 | case INVISIBLE: |
| 5033 | return android.R.drawable.presence_invisible; |
| 5034 | case OFFLINE: |
| 5035 | default: |
| 5036 | return android.R.drawable.presence_offline; |
| 5037 | } |
| 5038 | } |
| 5039 | |
| 5040 | /** |
Evan Millar | c043752 | 2009-06-23 17:31:05 -0700 | [diff] [blame] | 5041 | * Returns the precedence of the status code the higher number being the higher precedence. |
| 5042 | * |
| 5043 | * @param status The status code. |
| 5044 | * @return An integer representing the precedence, 0 being the lowest. |
| 5045 | */ |
| 5046 | public static final int getPresencePrecedence(int status) { |
| 5047 | // Keep this function here incase we want to enforce a different precedence than the |
| 5048 | // natural order of the status constants. |
| 5049 | return status; |
| 5050 | } |
| 5051 | |
| 5052 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5053 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5054 | * status update details. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5055 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5056 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5057 | |
| 5058 | /** |
| 5059 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5060 | * status update detail. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5061 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5062 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update"; |
| 5063 | } |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 5064 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5065 | /** |
| 5066 | * @deprecated This old name was never meant to be made public. Do not use. |
| 5067 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5068 | @Deprecated |
| 5069 | public static final class Presence extends StatusUpdates { |
| 5070 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5071 | } |
| 5072 | |
| 5073 | /** |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5074 | * Additional column returned by the {@link Contacts#CONTENT_FILTER_URI} providing the |
| 5075 | * explanation of why the filter matched the contact. Specifically, it contains the |
| 5076 | * data elements that matched the query. The overall number of words in the snippet |
| 5077 | * can be capped. |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5078 | * |
| 5079 | * @hide |
| 5080 | */ |
| 5081 | public static class SearchSnippetColumns { |
| 5082 | |
| 5083 | /** |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5084 | * The search snippet constructed according to the SQLite rules, see |
| 5085 | * http://www.sqlite.org/fts3.html#snippet |
| 5086 | * <p> |
| 5087 | * The snippet may contain (parts of) several data elements comprising |
| 5088 | * the contact. |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5089 | * |
| 5090 | * @hide |
| 5091 | */ |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5092 | public static final String SNIPPET = "snippet"; |
| 5093 | |
| 5094 | |
| 5095 | /** |
| 5096 | * Comma-separated parameters for the generation of the snippet: |
| 5097 | * <ul> |
| 5098 | * <li>The "start match" text. Default is <b></li> |
| 5099 | * <li>The "end match" text. Default is </b></li> |
| 5100 | * <li>The "ellipsis" text. Default is <b>...</b></li> |
| 5101 | * <li>Maximum number of tokens to include in the snippet. Can be either |
| 5102 | * a positive or a negative number: A positive number indicates how many |
| 5103 | * tokens can be returned in total. A negative number indicates how many |
| 5104 | * tokens can be returned per occurrence of the search terms.</li> |
| 5105 | * </ul> |
| 5106 | * |
| 5107 | * @hide |
| 5108 | */ |
| 5109 | public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args"; |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5110 | |
| 5111 | /** |
| 5112 | * A key to ask the provider to defer the snippeting to the client if possible. |
| 5113 | * Value of 1 implies true, 0 implies false when 0 is the default. |
| 5114 | * When a cursor is returned to the client, it should check for an extra with the name |
| 5115 | * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client |
Chiao Cheng | 31b730a | 2013-06-17 18:31:34 -0700 | [diff] [blame] | 5116 | * should do its own snippeting. If it doesn't exist, the snippet column in the cursor |
| 5117 | * should already contain a snippetized string. |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5118 | * |
| 5119 | * @hide |
| 5120 | */ |
| 5121 | public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting"; |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5122 | } |
| 5123 | |
| 5124 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5125 | * Container for definitions of common data types stored in the {@link ContactsContract.Data} |
| 5126 | * table. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5127 | */ |
| 5128 | public static final class CommonDataKinds { |
| 5129 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5130 | * This utility class cannot be instantiated |
| 5131 | */ |
| 5132 | private CommonDataKinds() {} |
| 5133 | |
| 5134 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5135 | * The {@link Data#RES_PACKAGE} value for common data that should be |
| 5136 | * shown using a default style. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5137 | * |
| 5138 | * @hide RES_PACKAGE is hidden |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5139 | */ |
| 5140 | public static final String PACKAGE_COMMON = "common"; |
| 5141 | |
| 5142 | /** |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5143 | * The base types that all "Typed" data kinds support. |
| 5144 | */ |
| 5145 | public interface BaseTypes { |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5146 | /** |
| 5147 | * A custom type. The custom label should be supplied by user. |
| 5148 | */ |
| 5149 | public static int TYPE_CUSTOM = 0; |
| 5150 | } |
| 5151 | |
| 5152 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5153 | * Columns common across the specific types. |
| 5154 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5155 | protected interface CommonColumns extends BaseTypes { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5156 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5157 | * The data for the contact method. |
| 5158 | * <P>Type: TEXT</P> |
| 5159 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5160 | public static final String DATA = DataColumns.DATA1; |
| 5161 | |
| 5162 | /** |
| 5163 | * The type of data, for example Home or Work. |
| 5164 | * <P>Type: INTEGER</P> |
| 5165 | */ |
| 5166 | public static final String TYPE = DataColumns.DATA2; |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 5167 | |
| 5168 | /** |
| 5169 | * The user defined label for the the contact method. |
| 5170 | * <P>Type: TEXT</P> |
| 5171 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5172 | public static final String LABEL = DataColumns.DATA3; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5173 | } |
| 5174 | |
| 5175 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5176 | * A data kind representing the contact's proper name. You can use all |
| 5177 | * columns defined for {@link ContactsContract.Data} as well as the following aliases. |
| 5178 | * |
| 5179 | * <h2>Column aliases</h2> |
| 5180 | * <table class="jd-sumtable"> |
| 5181 | * <tr> |
| 5182 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 5183 | * </tr> |
| 5184 | * <tr> |
| 5185 | * <td>String</td> |
| 5186 | * <td>{@link #DISPLAY_NAME}</td> |
| 5187 | * <td>{@link #DATA1}</td> |
| 5188 | * <td></td> |
| 5189 | * </tr> |
| 5190 | * <tr> |
| 5191 | * <td>String</td> |
| 5192 | * <td>{@link #GIVEN_NAME}</td> |
| 5193 | * <td>{@link #DATA2}</td> |
| 5194 | * <td></td> |
| 5195 | * </tr> |
| 5196 | * <tr> |
| 5197 | * <td>String</td> |
| 5198 | * <td>{@link #FAMILY_NAME}</td> |
| 5199 | * <td>{@link #DATA3}</td> |
| 5200 | * <td></td> |
| 5201 | * </tr> |
| 5202 | * <tr> |
| 5203 | * <td>String</td> |
| 5204 | * <td>{@link #PREFIX}</td> |
| 5205 | * <td>{@link #DATA4}</td> |
| 5206 | * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td> |
| 5207 | * </tr> |
| 5208 | * <tr> |
| 5209 | * <td>String</td> |
| 5210 | * <td>{@link #MIDDLE_NAME}</td> |
| 5211 | * <td>{@link #DATA5}</td> |
| 5212 | * <td></td> |
| 5213 | * </tr> |
| 5214 | * <tr> |
| 5215 | * <td>String</td> |
| 5216 | * <td>{@link #SUFFIX}</td> |
| 5217 | * <td>{@link #DATA6}</td> |
| 5218 | * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td> |
| 5219 | * </tr> |
| 5220 | * <tr> |
| 5221 | * <td>String</td> |
| 5222 | * <td>{@link #PHONETIC_GIVEN_NAME}</td> |
| 5223 | * <td>{@link #DATA7}</td> |
| 5224 | * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td> |
| 5225 | * </tr> |
| 5226 | * <tr> |
| 5227 | * <td>String</td> |
| 5228 | * <td>{@link #PHONETIC_MIDDLE_NAME}</td> |
| 5229 | * <td>{@link #DATA8}</td> |
| 5230 | * <td></td> |
| 5231 | * </tr> |
| 5232 | * <tr> |
| 5233 | * <td>String</td> |
| 5234 | * <td>{@link #PHONETIC_FAMILY_NAME}</td> |
| 5235 | * <td>{@link #DATA9}</td> |
| 5236 | * <td></td> |
| 5237 | * </tr> |
| 5238 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5239 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5240 | public static final class StructuredName implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5241 | /** |
| 5242 | * This utility class cannot be instantiated |
| 5243 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5244 | private StructuredName() {} |
| 5245 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5246 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5247 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; |
| 5248 | |
| 5249 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5250 | * The name that should be used to display the contact. |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 5251 | * <i>Unstructured component of the name should be consistent with |
| 5252 | * its structured representation.</i> |
| 5253 | * <p> |
| 5254 | * Type: TEXT |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5255 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5256 | public static final String DISPLAY_NAME = DATA1; |
| 5257 | |
| 5258 | /** |
| 5259 | * The given name for the contact. |
| 5260 | * <P>Type: TEXT</P> |
| 5261 | */ |
| 5262 | public static final String GIVEN_NAME = DATA2; |
| 5263 | |
| 5264 | /** |
| 5265 | * The family name for the contact. |
| 5266 | * <P>Type: TEXT</P> |
| 5267 | */ |
| 5268 | public static final String FAMILY_NAME = DATA3; |
| 5269 | |
| 5270 | /** |
| 5271 | * The contact's honorific prefix, e.g. "Sir" |
| 5272 | * <P>Type: TEXT</P> |
| 5273 | */ |
| 5274 | public static final String PREFIX = DATA4; |
| 5275 | |
| 5276 | /** |
| 5277 | * The contact's middle name |
| 5278 | * <P>Type: TEXT</P> |
| 5279 | */ |
| 5280 | public static final String MIDDLE_NAME = DATA5; |
| 5281 | |
| 5282 | /** |
| 5283 | * The contact's honorific suffix, e.g. "Jr" |
| 5284 | */ |
| 5285 | public static final String SUFFIX = DATA6; |
| 5286 | |
| 5287 | /** |
| 5288 | * The phonetic version of the given name for the contact. |
| 5289 | * <P>Type: TEXT</P> |
| 5290 | */ |
| 5291 | public static final String PHONETIC_GIVEN_NAME = DATA7; |
| 5292 | |
| 5293 | /** |
| 5294 | * The phonetic version of the additional name for the contact. |
| 5295 | * <P>Type: TEXT</P> |
| 5296 | */ |
| 5297 | public static final String PHONETIC_MIDDLE_NAME = DATA8; |
| 5298 | |
| 5299 | /** |
| 5300 | * The phonetic version of the family name for the contact. |
| 5301 | * <P>Type: TEXT</P> |
| 5302 | */ |
| 5303 | public static final String PHONETIC_FAMILY_NAME = DATA9; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5304 | |
| 5305 | /** |
| 5306 | * The style used for combining given/middle/family name into a full name. |
| 5307 | * See {@link ContactsContract.FullNameStyle}. |
| 5308 | * |
| 5309 | * @hide |
| 5310 | */ |
| 5311 | public static final String FULL_NAME_STYLE = DATA10; |
| 5312 | |
| 5313 | /** |
| 5314 | * The alphabet used for capturing the phonetic name. |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 5315 | * See ContactsContract.PhoneticNameStyle. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5316 | * @hide |
| 5317 | */ |
| 5318 | public static final String PHONETIC_NAME_STYLE = DATA11; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5319 | } |
| 5320 | |
| 5321 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5322 | * <p>A data kind representing the contact's nickname. For example, for |
| 5323 | * Bob Parr ("Mr. Incredible"): |
| 5324 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 5325 | * ArrayList<ContentProviderOperation> ops = |
| 5326 | * new ArrayList<ContentProviderOperation>(); |
| 5327 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5328 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 5329 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 5330 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 5331 | * .withValue(StructuredName.DISPLAY_NAME, "Bob Parr") |
| 5332 | * .build()); |
| 5333 | * |
| 5334 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 5335 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 5336 | * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE) |
| 5337 | * .withValue(Nickname.NAME, "Mr. Incredible") |
| 5338 | * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM) |
| 5339 | * .withValue(Nickname.LABEL, "Superhero") |
| 5340 | * .build()); |
| 5341 | * |
| 5342 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 5343 | * </pre> |
| 5344 | * </p> |
| 5345 | * <p> |
| 5346 | * You can use all columns defined for {@link ContactsContract.Data} as well as the |
| 5347 | * following aliases. |
| 5348 | * </p> |
| 5349 | * |
| 5350 | * <h2>Column aliases</h2> |
| 5351 | * <table class="jd-sumtable"> |
| 5352 | * <tr> |
| 5353 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 5354 | * </tr> |
| 5355 | * <tr> |
| 5356 | * <td>String</td> |
| 5357 | * <td>{@link #NAME}</td> |
| 5358 | * <td>{@link #DATA1}</td> |
| 5359 | * <td></td> |
| 5360 | * </tr> |
| 5361 | * <tr> |
| 5362 | * <td>int</td> |
| 5363 | * <td>{@link #TYPE}</td> |
| 5364 | * <td>{@link #DATA2}</td> |
| 5365 | * <td> |
| 5366 | * Allowed values are: |
| 5367 | * <p> |
| 5368 | * <ul> |
| 5369 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5370 | * <li>{@link #TYPE_DEFAULT}</li> |
| 5371 | * <li>{@link #TYPE_OTHER_NAME}</li> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5372 | * <li>{@link #TYPE_MAIDEN_NAME}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5373 | * <li>{@link #TYPE_SHORT_NAME}</li> |
| 5374 | * <li>{@link #TYPE_INITIALS}</li> |
| 5375 | * </ul> |
| 5376 | * </p> |
| 5377 | * </td> |
| 5378 | * </tr> |
| 5379 | * <tr> |
| 5380 | * <td>String</td> |
| 5381 | * <td>{@link #LABEL}</td> |
| 5382 | * <td>{@link #DATA3}</td> |
| 5383 | * <td></td> |
| 5384 | * </tr> |
| 5385 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5386 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5387 | public static final class Nickname implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5388 | /** |
| 5389 | * This utility class cannot be instantiated |
| 5390 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5391 | private Nickname() {} |
| 5392 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5393 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5394 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; |
| 5395 | |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 5396 | public static final int TYPE_DEFAULT = 1; |
| 5397 | public static final int TYPE_OTHER_NAME = 2; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5398 | public static final int TYPE_MAIDEN_NAME = 3; |
| 5399 | /** @deprecated Use TYPE_MAIDEN_NAME instead. */ |
| 5400 | @Deprecated |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 5401 | public static final int TYPE_MAINDEN_NAME = 3; |
| 5402 | public static final int TYPE_SHORT_NAME = 4; |
| 5403 | public static final int TYPE_INITIALS = 5; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5404 | |
| 5405 | /** |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 5406 | * The name itself |
| 5407 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5408 | public static final String NAME = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5409 | } |
| 5410 | |
| 5411 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5412 | * <p> |
| 5413 | * A data kind representing a telephone number. |
| 5414 | * </p> |
| 5415 | * <p> |
| 5416 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5417 | * well as the following aliases. |
| 5418 | * </p> |
| 5419 | * <h2>Column aliases</h2> |
| 5420 | * <table class="jd-sumtable"> |
| 5421 | * <tr> |
| 5422 | * <th>Type</th> |
| 5423 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5424 | * </tr> |
| 5425 | * <tr> |
| 5426 | * <td>String</td> |
| 5427 | * <td>{@link #NUMBER}</td> |
| 5428 | * <td>{@link #DATA1}</td> |
| 5429 | * <td></td> |
| 5430 | * </tr> |
| 5431 | * <tr> |
| 5432 | * <td>int</td> |
| 5433 | * <td>{@link #TYPE}</td> |
| 5434 | * <td>{@link #DATA2}</td> |
| 5435 | * <td>Allowed values are: |
| 5436 | * <p> |
| 5437 | * <ul> |
| 5438 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5439 | * <li>{@link #TYPE_HOME}</li> |
| 5440 | * <li>{@link #TYPE_MOBILE}</li> |
| 5441 | * <li>{@link #TYPE_WORK}</li> |
| 5442 | * <li>{@link #TYPE_FAX_WORK}</li> |
| 5443 | * <li>{@link #TYPE_FAX_HOME}</li> |
| 5444 | * <li>{@link #TYPE_PAGER}</li> |
| 5445 | * <li>{@link #TYPE_OTHER}</li> |
| 5446 | * <li>{@link #TYPE_CALLBACK}</li> |
| 5447 | * <li>{@link #TYPE_CAR}</li> |
| 5448 | * <li>{@link #TYPE_COMPANY_MAIN}</li> |
| 5449 | * <li>{@link #TYPE_ISDN}</li> |
| 5450 | * <li>{@link #TYPE_MAIN}</li> |
| 5451 | * <li>{@link #TYPE_OTHER_FAX}</li> |
| 5452 | * <li>{@link #TYPE_RADIO}</li> |
| 5453 | * <li>{@link #TYPE_TELEX}</li> |
| 5454 | * <li>{@link #TYPE_TTY_TDD}</li> |
| 5455 | * <li>{@link #TYPE_WORK_MOBILE}</li> |
| 5456 | * <li>{@link #TYPE_WORK_PAGER}</li> |
| 5457 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 5458 | * <li>{@link #TYPE_MMS}</li> |
| 5459 | * </ul> |
| 5460 | * </p> |
| 5461 | * </td> |
| 5462 | * </tr> |
| 5463 | * <tr> |
| 5464 | * <td>String</td> |
| 5465 | * <td>{@link #LABEL}</td> |
| 5466 | * <td>{@link #DATA3}</td> |
| 5467 | * <td></td> |
| 5468 | * </tr> |
| 5469 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5470 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5471 | public static final class Phone implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5472 | /** |
| 5473 | * This utility class cannot be instantiated |
| 5474 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5475 | private Phone() {} |
| 5476 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5477 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5478 | 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] | 5479 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5480 | /** |
| 5481 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 5482 | * phones. |
| 5483 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5484 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2"; |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5485 | |
| 5486 | /** |
| 5487 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5488 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 5489 | * associated raw contact and aggregate contact data. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5490 | */ |
| 5491 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 5492 | "phones"); |
| 5493 | |
| 5494 | /** |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5495 | * 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] | 5496 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5497 | * to display names as well as phone numbers. The filter argument should be passed |
| 5498 | * as an additional path segment after this URI. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5499 | */ |
| 5500 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 5501 | "filter"); |
| 5502 | |
Daniel Lehmann | 1024de5 | 2012-06-15 20:32:33 -0700 | [diff] [blame] | 5503 | /** |
| 5504 | * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. |
| 5505 | * If "1" or "true", display names are searched. If "0" or "false", display names |
| 5506 | * are not searched. Default is "1". |
| 5507 | */ |
| 5508 | public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name"; |
| 5509 | |
| 5510 | /** |
| 5511 | * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. |
| 5512 | * If "1" or "true", phone numbers are searched. If "0" or "false", phone numbers |
| 5513 | * are not searched. Default is "1". |
| 5514 | */ |
| 5515 | public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number"; |
| 5516 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5517 | public static final int TYPE_HOME = 1; |
| 5518 | public static final int TYPE_MOBILE = 2; |
| 5519 | public static final int TYPE_WORK = 3; |
| 5520 | public static final int TYPE_FAX_WORK = 4; |
| 5521 | public static final int TYPE_FAX_HOME = 5; |
| 5522 | public static final int TYPE_PAGER = 6; |
| 5523 | public static final int TYPE_OTHER = 7; |
Fred Quintana | 3f86715 | 2009-08-03 11:43:16 -0700 | [diff] [blame] | 5524 | public static final int TYPE_CALLBACK = 8; |
| 5525 | public static final int TYPE_CAR = 9; |
| 5526 | public static final int TYPE_COMPANY_MAIN = 10; |
| 5527 | public static final int TYPE_ISDN = 11; |
| 5528 | public static final int TYPE_MAIN = 12; |
| 5529 | public static final int TYPE_OTHER_FAX = 13; |
| 5530 | public static final int TYPE_RADIO = 14; |
| 5531 | public static final int TYPE_TELEX = 15; |
| 5532 | public static final int TYPE_TTY_TDD = 16; |
| 5533 | public static final int TYPE_WORK_MOBILE = 17; |
| 5534 | public static final int TYPE_WORK_PAGER = 18; |
| 5535 | public static final int TYPE_ASSISTANT = 19; |
Jeff Sharkey | d5abd46 | 2009-09-16 19:54:29 -0700 | [diff] [blame] | 5536 | public static final int TYPE_MMS = 20; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5537 | |
| 5538 | /** |
| 5539 | * The phone number as the user entered it. |
| 5540 | * <P>Type: TEXT</P> |
| 5541 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5542 | public static final String NUMBER = DATA; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5543 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5544 | /** |
Daniel Lehmann | db91915 | 2012-03-09 14:30:50 -0800 | [diff] [blame] | 5545 | * 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] | 5546 | * case the provider will try to automatically infer it. (It'll be left null if the |
| 5547 | * provider fails to infer.) |
| 5548 | * 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] | 5549 | * <P>Type: TEXT</P> |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 5550 | */ |
| 5551 | public static final String NORMALIZED_NUMBER = DATA4; |
| 5552 | |
| 5553 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5554 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5555 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5556 | */ |
| 5557 | @Deprecated |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5558 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 5559 | CharSequence label, CharSequence[] labelArray) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5560 | return getTypeLabel(context.getResources(), type, label); |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5561 | } |
| 5562 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5563 | /** |
| 5564 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5565 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5566 | */ |
| 5567 | @Deprecated |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5568 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 5569 | CharSequence label) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5570 | return getTypeLabel(context.getResources(), type, label); |
| 5571 | } |
| 5572 | |
| 5573 | /** |
| 5574 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5575 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5576 | */ |
| 5577 | public static final int getTypeLabelResource(int type) { |
| 5578 | switch (type) { |
| 5579 | case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome; |
| 5580 | case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile; |
| 5581 | case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork; |
| 5582 | case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork; |
| 5583 | case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome; |
| 5584 | case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager; |
| 5585 | case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther; |
| 5586 | case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback; |
| 5587 | case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar; |
| 5588 | case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain; |
| 5589 | case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn; |
| 5590 | case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain; |
| 5591 | case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax; |
| 5592 | case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio; |
| 5593 | case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex; |
| 5594 | case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd; |
| 5595 | case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile; |
| 5596 | case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager; |
| 5597 | case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant; |
| 5598 | case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms; |
| 5599 | default: return com.android.internal.R.string.phoneTypeCustom; |
| 5600 | } |
| 5601 | } |
| 5602 | |
| 5603 | /** |
| 5604 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5605 | * possibly substituting the given {@link #LABEL} value |
| 5606 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5607 | */ |
| 5608 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 5609 | CharSequence label) { |
| 5610 | if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) { |
| 5611 | return label; |
| 5612 | } else { |
| 5613 | final int labelRes = getTypeLabelResource(type); |
| 5614 | return res.getText(labelRes); |
| 5615 | } |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5616 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5617 | } |
| 5618 | |
| 5619 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5620 | * <p> |
| 5621 | * A data kind representing an email address. |
| 5622 | * </p> |
| 5623 | * <p> |
| 5624 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5625 | * well as the following aliases. |
| 5626 | * </p> |
| 5627 | * <h2>Column aliases</h2> |
| 5628 | * <table class="jd-sumtable"> |
| 5629 | * <tr> |
| 5630 | * <th>Type</th> |
| 5631 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5632 | * </tr> |
| 5633 | * <tr> |
| 5634 | * <td>String</td> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 5635 | * <td>{@link #ADDRESS}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5636 | * <td>{@link #DATA1}</td> |
| 5637 | * <td>Email address itself.</td> |
| 5638 | * </tr> |
| 5639 | * <tr> |
| 5640 | * <td>int</td> |
| 5641 | * <td>{@link #TYPE}</td> |
| 5642 | * <td>{@link #DATA2}</td> |
| 5643 | * <td>Allowed values are: |
| 5644 | * <p> |
| 5645 | * <ul> |
| 5646 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5647 | * <li>{@link #TYPE_HOME}</li> |
| 5648 | * <li>{@link #TYPE_WORK}</li> |
| 5649 | * <li>{@link #TYPE_OTHER}</li> |
| 5650 | * <li>{@link #TYPE_MOBILE}</li> |
| 5651 | * </ul> |
| 5652 | * </p> |
| 5653 | * </td> |
| 5654 | * </tr> |
| 5655 | * <tr> |
| 5656 | * <td>String</td> |
| 5657 | * <td>{@link #LABEL}</td> |
| 5658 | * <td>{@link #DATA3}</td> |
| 5659 | * <td></td> |
| 5660 | * </tr> |
| 5661 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5662 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5663 | public static final class Email implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5664 | /** |
| 5665 | * This utility class cannot be instantiated |
| 5666 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5667 | private Email() {} |
| 5668 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5669 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5670 | 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] | 5671 | |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5672 | /** |
Dmitri Plotnikov | abf15c3 | 2009-09-18 20:29:11 -0700 | [diff] [blame] | 5673 | * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses. |
| 5674 | */ |
| 5675 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2"; |
| 5676 | |
| 5677 | /** |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5678 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5679 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5680 | * associated raw contact and aggregate contact data. |
| 5681 | */ |
| 5682 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 5683 | "emails"); |
| 5684 | |
| 5685 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5686 | * <p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5687 | * The content:// style URL for looking up data rows by email address. The |
| 5688 | * lookup argument, an email address, should be passed as an additional path segment |
| 5689 | * after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5690 | * </p> |
| 5691 | * <p>Example: |
| 5692 | * <pre> |
| 5693 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email)); |
| 5694 | * Cursor c = getContentResolver().query(uri, |
| 5695 | * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA}, |
| 5696 | * null, null, null); |
| 5697 | * </pre> |
| 5698 | * </p> |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5699 | */ |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5700 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 5701 | "lookup"); |
| 5702 | |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5703 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5704 | * <p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5705 | * 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] | 5706 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5707 | * to display names as well as email addresses. The filter argument should be passed |
| 5708 | * as an additional path segment after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5709 | * </p> |
| 5710 | * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)" |
| 5711 | * as well as "Bob Parr (incredible@android.com)". |
| 5712 | * <pre> |
| 5713 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob")); |
| 5714 | * Cursor c = getContentResolver().query(uri, |
| 5715 | * new String[]{Email.DISPLAY_NAME, Email.DATA}, |
| 5716 | * null, null, null); |
| 5717 | * </pre> |
| 5718 | * </p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5719 | */ |
| 5720 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5721 | "filter"); |
| 5722 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5723 | /** |
| 5724 | * The email address. |
| 5725 | * <P>Type: TEXT</P> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5726 | */ |
| 5727 | public static final String ADDRESS = DATA1; |
| 5728 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5729 | public static final int TYPE_HOME = 1; |
| 5730 | public static final int TYPE_WORK = 2; |
| 5731 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 14fb153 | 2009-08-29 15:54:26 -0700 | [diff] [blame] | 5732 | public static final int TYPE_MOBILE = 4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 5733 | |
| 5734 | /** |
| 5735 | * The display name for the email address |
| 5736 | * <P>Type: TEXT</P> |
| 5737 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5738 | public static final String DISPLAY_NAME = DATA4; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5739 | |
| 5740 | /** |
| 5741 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5742 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5743 | */ |
| 5744 | public static final int getTypeLabelResource(int type) { |
| 5745 | switch (type) { |
| 5746 | case TYPE_HOME: return com.android.internal.R.string.emailTypeHome; |
| 5747 | case TYPE_WORK: return com.android.internal.R.string.emailTypeWork; |
| 5748 | case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther; |
| 5749 | case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile; |
| 5750 | default: return com.android.internal.R.string.emailTypeCustom; |
| 5751 | } |
| 5752 | } |
| 5753 | |
| 5754 | /** |
| 5755 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5756 | * possibly substituting the given {@link #LABEL} value |
| 5757 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5758 | */ |
| 5759 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 5760 | CharSequence label) { |
| 5761 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 5762 | return label; |
| 5763 | } else { |
| 5764 | final int labelRes = getTypeLabelResource(type); |
| 5765 | return res.getText(labelRes); |
| 5766 | } |
| 5767 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5768 | } |
| 5769 | |
| 5770 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5771 | * <p> |
| 5772 | * A data kind representing a postal addresses. |
| 5773 | * </p> |
| 5774 | * <p> |
| 5775 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5776 | * well as the following aliases. |
| 5777 | * </p> |
| 5778 | * <h2>Column aliases</h2> |
| 5779 | * <table class="jd-sumtable"> |
| 5780 | * <tr> |
| 5781 | * <th>Type</th> |
| 5782 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5783 | * </tr> |
| 5784 | * <tr> |
| 5785 | * <td>String</td> |
| 5786 | * <td>{@link #FORMATTED_ADDRESS}</td> |
| 5787 | * <td>{@link #DATA1}</td> |
| 5788 | * <td></td> |
| 5789 | * </tr> |
| 5790 | * <tr> |
| 5791 | * <td>int</td> |
| 5792 | * <td>{@link #TYPE}</td> |
| 5793 | * <td>{@link #DATA2}</td> |
| 5794 | * <td>Allowed values are: |
| 5795 | * <p> |
| 5796 | * <ul> |
| 5797 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5798 | * <li>{@link #TYPE_HOME}</li> |
| 5799 | * <li>{@link #TYPE_WORK}</li> |
| 5800 | * <li>{@link #TYPE_OTHER}</li> |
| 5801 | * </ul> |
| 5802 | * </p> |
| 5803 | * </td> |
| 5804 | * </tr> |
| 5805 | * <tr> |
| 5806 | * <td>String</td> |
| 5807 | * <td>{@link #LABEL}</td> |
| 5808 | * <td>{@link #DATA3}</td> |
| 5809 | * <td></td> |
| 5810 | * </tr> |
| 5811 | * <tr> |
| 5812 | * <td>String</td> |
| 5813 | * <td>{@link #STREET}</td> |
| 5814 | * <td>{@link #DATA4}</td> |
| 5815 | * <td></td> |
| 5816 | * </tr> |
| 5817 | * <tr> |
| 5818 | * <td>String</td> |
| 5819 | * <td>{@link #POBOX}</td> |
| 5820 | * <td>{@link #DATA5}</td> |
| 5821 | * <td>Post Office Box number</td> |
| 5822 | * </tr> |
| 5823 | * <tr> |
| 5824 | * <td>String</td> |
| 5825 | * <td>{@link #NEIGHBORHOOD}</td> |
| 5826 | * <td>{@link #DATA6}</td> |
| 5827 | * <td></td> |
| 5828 | * </tr> |
| 5829 | * <tr> |
| 5830 | * <td>String</td> |
| 5831 | * <td>{@link #CITY}</td> |
| 5832 | * <td>{@link #DATA7}</td> |
| 5833 | * <td></td> |
| 5834 | * </tr> |
| 5835 | * <tr> |
| 5836 | * <td>String</td> |
| 5837 | * <td>{@link #REGION}</td> |
| 5838 | * <td>{@link #DATA8}</td> |
| 5839 | * <td></td> |
| 5840 | * </tr> |
| 5841 | * <tr> |
| 5842 | * <td>String</td> |
| 5843 | * <td>{@link #POSTCODE}</td> |
| 5844 | * <td>{@link #DATA9}</td> |
| 5845 | * <td></td> |
| 5846 | * </tr> |
| 5847 | * <tr> |
| 5848 | * <td>String</td> |
| 5849 | * <td>{@link #COUNTRY}</td> |
| 5850 | * <td>{@link #DATA10}</td> |
| 5851 | * <td></td> |
| 5852 | * </tr> |
| 5853 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5854 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5855 | public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5856 | /** |
| 5857 | * This utility class cannot be instantiated |
| 5858 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5859 | private StructuredPostal() { |
| 5860 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5861 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5862 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5863 | public static final String CONTENT_ITEM_TYPE = |
| 5864 | "vnd.android.cursor.item/postal-address_v2"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5865 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5866 | /** |
| 5867 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 5868 | * postal addresses. |
| 5869 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5870 | 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] | 5871 | |
| 5872 | /** |
| 5873 | * The content:// style URI for all data records of the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5874 | * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5875 | */ |
| 5876 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 5877 | "postals"); |
| 5878 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5879 | public static final int TYPE_HOME = 1; |
| 5880 | public static final int TYPE_WORK = 2; |
| 5881 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5882 | |
| 5883 | /** |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 5884 | * The full, unstructured postal address. <i>This field must be |
| 5885 | * consistent with any structured data.</i> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5886 | * <p> |
| 5887 | * Type: TEXT |
| 5888 | */ |
| 5889 | public static final String FORMATTED_ADDRESS = DATA; |
| 5890 | |
| 5891 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5892 | * Can be street, avenue, road, etc. This element also includes the |
| 5893 | * house number and room/apartment/flat/floor number. |
| 5894 | * <p> |
| 5895 | * Type: TEXT |
| 5896 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5897 | public static final String STREET = DATA4; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5898 | |
| 5899 | /** |
| 5900 | * Covers actual P.O. boxes, drawers, locked bags, etc. This is |
| 5901 | * usually but not always mutually exclusive with street. |
| 5902 | * <p> |
| 5903 | * Type: TEXT |
| 5904 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5905 | public static final String POBOX = DATA5; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5906 | |
| 5907 | /** |
| 5908 | * This is used to disambiguate a street address when a city |
| 5909 | * contains more than one street with the same name, or to specify a |
| 5910 | * small place whose mail is routed through a larger postal town. In |
| 5911 | * China it could be a county or a minor city. |
| 5912 | * <p> |
| 5913 | * Type: TEXT |
| 5914 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5915 | public static final String NEIGHBORHOOD = DATA6; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5916 | |
| 5917 | /** |
| 5918 | * Can be city, village, town, borough, etc. This is the postal town |
| 5919 | * and not necessarily the place of residence or place of business. |
| 5920 | * <p> |
| 5921 | * Type: TEXT |
| 5922 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5923 | public static final String CITY = DATA7; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5924 | |
| 5925 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5926 | * A state, province, county (in Ireland), Land (in Germany), |
| 5927 | * departement (in France), etc. |
| 5928 | * <p> |
| 5929 | * Type: TEXT |
| 5930 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5931 | public static final String REGION = DATA8; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5932 | |
| 5933 | /** |
Jeff Sharkey | ef348c7 | 2009-07-26 14:14:34 -0700 | [diff] [blame] | 5934 | * Postal code. Usually country-wide, but sometimes specific to the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5935 | * city (e.g. "2" in "Dublin 2, Ireland" addresses). |
| 5936 | * <p> |
| 5937 | * Type: TEXT |
| 5938 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5939 | public static final String POSTCODE = DATA9; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5940 | |
| 5941 | /** |
| 5942 | * The name or code of the country. |
| 5943 | * <p> |
| 5944 | * Type: TEXT |
| 5945 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5946 | public static final String COUNTRY = DATA10; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5947 | |
| 5948 | /** |
| 5949 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5950 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5951 | */ |
| 5952 | public static final int getTypeLabelResource(int type) { |
| 5953 | switch (type) { |
| 5954 | case TYPE_HOME: return com.android.internal.R.string.postalTypeHome; |
| 5955 | case TYPE_WORK: return com.android.internal.R.string.postalTypeWork; |
| 5956 | case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther; |
| 5957 | default: return com.android.internal.R.string.postalTypeCustom; |
| 5958 | } |
| 5959 | } |
| 5960 | |
| 5961 | /** |
| 5962 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5963 | * possibly substituting the given {@link #LABEL} value |
| 5964 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5965 | */ |
| 5966 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 5967 | CharSequence label) { |
| 5968 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 5969 | return label; |
| 5970 | } else { |
| 5971 | final int labelRes = getTypeLabelResource(type); |
| 5972 | return res.getText(labelRes); |
| 5973 | } |
| 5974 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5975 | } |
| 5976 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 5977 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5978 | * <p> |
| 5979 | * A data kind representing an IM address |
| 5980 | * </p> |
| 5981 | * <p> |
| 5982 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5983 | * well as the following aliases. |
| 5984 | * </p> |
| 5985 | * <h2>Column aliases</h2> |
| 5986 | * <table class="jd-sumtable"> |
| 5987 | * <tr> |
| 5988 | * <th>Type</th> |
| 5989 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5990 | * </tr> |
| 5991 | * <tr> |
| 5992 | * <td>String</td> |
| 5993 | * <td>{@link #DATA}</td> |
| 5994 | * <td>{@link #DATA1}</td> |
| 5995 | * <td></td> |
| 5996 | * </tr> |
| 5997 | * <tr> |
| 5998 | * <td>int</td> |
| 5999 | * <td>{@link #TYPE}</td> |
| 6000 | * <td>{@link #DATA2}</td> |
| 6001 | * <td>Allowed values are: |
| 6002 | * <p> |
| 6003 | * <ul> |
| 6004 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6005 | * <li>{@link #TYPE_HOME}</li> |
| 6006 | * <li>{@link #TYPE_WORK}</li> |
| 6007 | * <li>{@link #TYPE_OTHER}</li> |
| 6008 | * </ul> |
| 6009 | * </p> |
| 6010 | * </td> |
| 6011 | * </tr> |
| 6012 | * <tr> |
| 6013 | * <td>String</td> |
| 6014 | * <td>{@link #LABEL}</td> |
| 6015 | * <td>{@link #DATA3}</td> |
| 6016 | * <td></td> |
| 6017 | * </tr> |
| 6018 | * <tr> |
| 6019 | * <td>String</td> |
| 6020 | * <td>{@link #PROTOCOL}</td> |
| 6021 | * <td>{@link #DATA5}</td> |
| 6022 | * <td> |
| 6023 | * <p> |
| 6024 | * Allowed values: |
| 6025 | * <ul> |
| 6026 | * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name |
| 6027 | * as {@link #CUSTOM_PROTOCOL}.</li> |
| 6028 | * <li>{@link #PROTOCOL_AIM}</li> |
| 6029 | * <li>{@link #PROTOCOL_MSN}</li> |
| 6030 | * <li>{@link #PROTOCOL_YAHOO}</li> |
| 6031 | * <li>{@link #PROTOCOL_SKYPE}</li> |
| 6032 | * <li>{@link #PROTOCOL_QQ}</li> |
| 6033 | * <li>{@link #PROTOCOL_GOOGLE_TALK}</li> |
| 6034 | * <li>{@link #PROTOCOL_ICQ}</li> |
| 6035 | * <li>{@link #PROTOCOL_JABBER}</li> |
| 6036 | * <li>{@link #PROTOCOL_NETMEETING}</li> |
| 6037 | * </ul> |
| 6038 | * </p> |
| 6039 | * </td> |
| 6040 | * </tr> |
| 6041 | * <tr> |
| 6042 | * <td>String</td> |
| 6043 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 6044 | * <td>{@link #DATA6}</td> |
| 6045 | * <td></td> |
| 6046 | * </tr> |
| 6047 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6048 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6049 | public static final class Im implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6050 | /** |
| 6051 | * This utility class cannot be instantiated |
| 6052 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6053 | private Im() {} |
| 6054 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6055 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6056 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; |
| 6057 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6058 | public static final int TYPE_HOME = 1; |
| 6059 | public static final int TYPE_WORK = 2; |
| 6060 | public static final int TYPE_OTHER = 3; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6061 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 6062 | /** |
| 6063 | * This column should be populated with one of the defined |
| 6064 | * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this |
| 6065 | * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL} |
| 6066 | * should contain the name of the custom protocol. |
| 6067 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6068 | public static final String PROTOCOL = DATA5; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6069 | |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6070 | public static final String CUSTOM_PROTOCOL = DATA6; |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 6071 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 6072 | /* |
| 6073 | * The predefined IM protocol types. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6074 | */ |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 6075 | public static final int PROTOCOL_CUSTOM = -1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6076 | public static final int PROTOCOL_AIM = 0; |
| 6077 | public static final int PROTOCOL_MSN = 1; |
| 6078 | public static final int PROTOCOL_YAHOO = 2; |
| 6079 | public static final int PROTOCOL_SKYPE = 3; |
| 6080 | public static final int PROTOCOL_QQ = 4; |
| 6081 | public static final int PROTOCOL_GOOGLE_TALK = 5; |
| 6082 | public static final int PROTOCOL_ICQ = 6; |
| 6083 | public static final int PROTOCOL_JABBER = 7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6084 | public static final int PROTOCOL_NETMEETING = 8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6085 | |
| 6086 | /** |
| 6087 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6088 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6089 | */ |
| 6090 | public static final int getTypeLabelResource(int type) { |
| 6091 | switch (type) { |
| 6092 | case TYPE_HOME: return com.android.internal.R.string.imTypeHome; |
| 6093 | case TYPE_WORK: return com.android.internal.R.string.imTypeWork; |
| 6094 | case TYPE_OTHER: return com.android.internal.R.string.imTypeOther; |
| 6095 | default: return com.android.internal.R.string.imTypeCustom; |
| 6096 | } |
| 6097 | } |
| 6098 | |
| 6099 | /** |
| 6100 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6101 | * possibly substituting the given {@link #LABEL} value |
| 6102 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6103 | */ |
| 6104 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6105 | CharSequence label) { |
| 6106 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6107 | return label; |
| 6108 | } else { |
| 6109 | final int labelRes = getTypeLabelResource(type); |
| 6110 | return res.getText(labelRes); |
| 6111 | } |
| 6112 | } |
| 6113 | |
| 6114 | /** |
| 6115 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6116 | * {@link #PROTOCOL}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6117 | */ |
| 6118 | public static final int getProtocolLabelResource(int type) { |
| 6119 | switch (type) { |
| 6120 | case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim; |
| 6121 | case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn; |
| 6122 | case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo; |
| 6123 | case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype; |
| 6124 | case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq; |
| 6125 | case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk; |
| 6126 | case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq; |
| 6127 | case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber; |
| 6128 | case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting; |
| 6129 | default: return com.android.internal.R.string.imProtocolCustom; |
| 6130 | } |
| 6131 | } |
| 6132 | |
| 6133 | /** |
| 6134 | * Return a {@link CharSequence} that best describes the given |
| 6135 | * protocol, possibly substituting the given |
| 6136 | * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}. |
| 6137 | */ |
| 6138 | public static final CharSequence getProtocolLabel(Resources res, int type, |
| 6139 | CharSequence label) { |
| 6140 | if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6141 | return label; |
| 6142 | } else { |
| 6143 | final int labelRes = getProtocolLabelResource(type); |
| 6144 | return res.getText(labelRes); |
| 6145 | } |
| 6146 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6147 | } |
| 6148 | |
| 6149 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6150 | * <p> |
| 6151 | * A data kind representing an organization. |
| 6152 | * </p> |
| 6153 | * <p> |
| 6154 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6155 | * well as the following aliases. |
| 6156 | * </p> |
| 6157 | * <h2>Column aliases</h2> |
| 6158 | * <table class="jd-sumtable"> |
| 6159 | * <tr> |
| 6160 | * <th>Type</th> |
| 6161 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6162 | * </tr> |
| 6163 | * <tr> |
| 6164 | * <td>String</td> |
| 6165 | * <td>{@link #COMPANY}</td> |
| 6166 | * <td>{@link #DATA1}</td> |
| 6167 | * <td></td> |
| 6168 | * </tr> |
| 6169 | * <tr> |
| 6170 | * <td>int</td> |
| 6171 | * <td>{@link #TYPE}</td> |
| 6172 | * <td>{@link #DATA2}</td> |
| 6173 | * <td>Allowed values are: |
| 6174 | * <p> |
| 6175 | * <ul> |
| 6176 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6177 | * <li>{@link #TYPE_WORK}</li> |
| 6178 | * <li>{@link #TYPE_OTHER}</li> |
| 6179 | * </ul> |
| 6180 | * </p> |
| 6181 | * </td> |
| 6182 | * </tr> |
| 6183 | * <tr> |
| 6184 | * <td>String</td> |
| 6185 | * <td>{@link #LABEL}</td> |
| 6186 | * <td>{@link #DATA3}</td> |
| 6187 | * <td></td> |
| 6188 | * </tr> |
| 6189 | * <tr> |
| 6190 | * <td>String</td> |
| 6191 | * <td>{@link #TITLE}</td> |
| 6192 | * <td>{@link #DATA4}</td> |
| 6193 | * <td></td> |
| 6194 | * </tr> |
| 6195 | * <tr> |
| 6196 | * <td>String</td> |
| 6197 | * <td>{@link #DEPARTMENT}</td> |
| 6198 | * <td>{@link #DATA5}</td> |
| 6199 | * <td></td> |
| 6200 | * </tr> |
| 6201 | * <tr> |
| 6202 | * <td>String</td> |
| 6203 | * <td>{@link #JOB_DESCRIPTION}</td> |
| 6204 | * <td>{@link #DATA6}</td> |
| 6205 | * <td></td> |
| 6206 | * </tr> |
| 6207 | * <tr> |
| 6208 | * <td>String</td> |
| 6209 | * <td>{@link #SYMBOL}</td> |
| 6210 | * <td>{@link #DATA7}</td> |
| 6211 | * <td></td> |
| 6212 | * </tr> |
| 6213 | * <tr> |
| 6214 | * <td>String</td> |
| 6215 | * <td>{@link #PHONETIC_NAME}</td> |
| 6216 | * <td>{@link #DATA8}</td> |
| 6217 | * <td></td> |
| 6218 | * </tr> |
| 6219 | * <tr> |
| 6220 | * <td>String</td> |
| 6221 | * <td>{@link #OFFICE_LOCATION}</td> |
| 6222 | * <td>{@link #DATA9}</td> |
| 6223 | * <td></td> |
| 6224 | * </tr> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 6225 | * <tr> |
| 6226 | * <td>String</td> |
| 6227 | * <td>PHONETIC_NAME_STYLE</td> |
| 6228 | * <td>{@link #DATA10}</td> |
| 6229 | * <td></td> |
| 6230 | * </tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6231 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6232 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6233 | public static final class Organization implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6234 | /** |
| 6235 | * This utility class cannot be instantiated |
| 6236 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6237 | private Organization() {} |
| 6238 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6239 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6240 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; |
| 6241 | |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6242 | public static final int TYPE_WORK = 1; |
| 6243 | public static final int TYPE_OTHER = 2; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6244 | |
| 6245 | /** |
| 6246 | * The company as the user entered it. |
| 6247 | * <P>Type: TEXT</P> |
| 6248 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6249 | public static final String COMPANY = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6250 | |
| 6251 | /** |
| 6252 | * The position title at this company as the user entered it. |
| 6253 | * <P>Type: TEXT</P> |
| 6254 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6255 | public static final String TITLE = DATA4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6256 | |
| 6257 | /** |
| 6258 | * The department at this company as the user entered it. |
| 6259 | * <P>Type: TEXT</P> |
| 6260 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6261 | public static final String DEPARTMENT = DATA5; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6262 | |
| 6263 | /** |
| 6264 | * The job description at this company as the user entered it. |
| 6265 | * <P>Type: TEXT</P> |
| 6266 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6267 | public static final String JOB_DESCRIPTION = DATA6; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6268 | |
| 6269 | /** |
| 6270 | * The symbol of this company as the user entered it. |
| 6271 | * <P>Type: TEXT</P> |
| 6272 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6273 | public static final String SYMBOL = DATA7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6274 | |
| 6275 | /** |
| 6276 | * The phonetic name of this company as the user entered it. |
| 6277 | * <P>Type: TEXT</P> |
| 6278 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6279 | public static final String PHONETIC_NAME = DATA8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6280 | |
| 6281 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 6282 | * The office location of this organization. |
| 6283 | * <P>Type: TEXT</P> |
| 6284 | */ |
| 6285 | public static final String OFFICE_LOCATION = DATA9; |
| 6286 | |
| 6287 | /** |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 6288 | * The alphabet used for capturing the phonetic name. |
| 6289 | * See {@link ContactsContract.PhoneticNameStyle}. |
| 6290 | * @hide |
| 6291 | */ |
| 6292 | public static final String PHONETIC_NAME_STYLE = DATA10; |
| 6293 | |
| 6294 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6295 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6296 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6297 | */ |
| 6298 | public static final int getTypeLabelResource(int type) { |
| 6299 | switch (type) { |
| 6300 | case TYPE_WORK: return com.android.internal.R.string.orgTypeWork; |
| 6301 | case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther; |
| 6302 | default: return com.android.internal.R.string.orgTypeCustom; |
| 6303 | } |
| 6304 | } |
| 6305 | |
| 6306 | /** |
| 6307 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6308 | * possibly substituting the given {@link #LABEL} value |
| 6309 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6310 | */ |
| 6311 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6312 | CharSequence label) { |
| 6313 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6314 | return label; |
| 6315 | } else { |
| 6316 | final int labelRes = getTypeLabelResource(type); |
| 6317 | return res.getText(labelRes); |
| 6318 | } |
| 6319 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6320 | } |
| 6321 | |
| 6322 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6323 | * <p> |
| 6324 | * A data kind representing a relation. |
| 6325 | * </p> |
| 6326 | * <p> |
| 6327 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6328 | * well as the following aliases. |
| 6329 | * </p> |
| 6330 | * <h2>Column aliases</h2> |
| 6331 | * <table class="jd-sumtable"> |
| 6332 | * <tr> |
| 6333 | * <th>Type</th> |
| 6334 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6335 | * </tr> |
| 6336 | * <tr> |
| 6337 | * <td>String</td> |
| 6338 | * <td>{@link #NAME}</td> |
| 6339 | * <td>{@link #DATA1}</td> |
| 6340 | * <td></td> |
| 6341 | * </tr> |
| 6342 | * <tr> |
| 6343 | * <td>int</td> |
| 6344 | * <td>{@link #TYPE}</td> |
| 6345 | * <td>{@link #DATA2}</td> |
| 6346 | * <td>Allowed values are: |
| 6347 | * <p> |
| 6348 | * <ul> |
| 6349 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6350 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 6351 | * <li>{@link #TYPE_BROTHER}</li> |
| 6352 | * <li>{@link #TYPE_CHILD}</li> |
| 6353 | * <li>{@link #TYPE_DOMESTIC_PARTNER}</li> |
| 6354 | * <li>{@link #TYPE_FATHER}</li> |
| 6355 | * <li>{@link #TYPE_FRIEND}</li> |
| 6356 | * <li>{@link #TYPE_MANAGER}</li> |
| 6357 | * <li>{@link #TYPE_MOTHER}</li> |
| 6358 | * <li>{@link #TYPE_PARENT}</li> |
| 6359 | * <li>{@link #TYPE_PARTNER}</li> |
| 6360 | * <li>{@link #TYPE_REFERRED_BY}</li> |
| 6361 | * <li>{@link #TYPE_RELATIVE}</li> |
| 6362 | * <li>{@link #TYPE_SISTER}</li> |
| 6363 | * <li>{@link #TYPE_SPOUSE}</li> |
| 6364 | * </ul> |
| 6365 | * </p> |
| 6366 | * </td> |
| 6367 | * </tr> |
| 6368 | * <tr> |
| 6369 | * <td>String</td> |
| 6370 | * <td>{@link #LABEL}</td> |
| 6371 | * <td>{@link #DATA3}</td> |
| 6372 | * <td></td> |
| 6373 | * </tr> |
| 6374 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6375 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6376 | public static final class Relation implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6377 | /** |
| 6378 | * This utility class cannot be instantiated |
| 6379 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6380 | private Relation() {} |
| 6381 | |
| 6382 | /** MIME type used when storing this in data table. */ |
| 6383 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; |
| 6384 | |
| 6385 | public static final int TYPE_ASSISTANT = 1; |
| 6386 | public static final int TYPE_BROTHER = 2; |
| 6387 | public static final int TYPE_CHILD = 3; |
| 6388 | public static final int TYPE_DOMESTIC_PARTNER = 4; |
| 6389 | public static final int TYPE_FATHER = 5; |
| 6390 | public static final int TYPE_FRIEND = 6; |
| 6391 | public static final int TYPE_MANAGER = 7; |
| 6392 | public static final int TYPE_MOTHER = 8; |
| 6393 | public static final int TYPE_PARENT = 9; |
| 6394 | public static final int TYPE_PARTNER = 10; |
| 6395 | public static final int TYPE_REFERRED_BY = 11; |
| 6396 | public static final int TYPE_RELATIVE = 12; |
| 6397 | public static final int TYPE_SISTER = 13; |
| 6398 | public static final int TYPE_SPOUSE = 14; |
| 6399 | |
| 6400 | /** |
| 6401 | * The name of the relative as the user entered it. |
| 6402 | * <P>Type: TEXT</P> |
| 6403 | */ |
| 6404 | public static final String NAME = DATA; |
Daniel Lehmann | 1fb39f0 | 2010-10-28 13:40:38 -0700 | [diff] [blame] | 6405 | |
| 6406 | /** |
| 6407 | * Return the string resource that best describes the given |
| 6408 | * {@link #TYPE}. Will always return a valid resource. |
| 6409 | */ |
| 6410 | public static final int getTypeLabelResource(int type) { |
| 6411 | switch (type) { |
| 6412 | case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant; |
| 6413 | case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother; |
| 6414 | case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild; |
| 6415 | case TYPE_DOMESTIC_PARTNER: |
| 6416 | return com.android.internal.R.string.relationTypeDomesticPartner; |
| 6417 | case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather; |
| 6418 | case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend; |
| 6419 | case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager; |
| 6420 | case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother; |
| 6421 | case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent; |
| 6422 | case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner; |
| 6423 | case TYPE_REFERRED_BY: |
| 6424 | return com.android.internal.R.string.relationTypeReferredBy; |
| 6425 | case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative; |
| 6426 | case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister; |
| 6427 | case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse; |
| 6428 | default: return com.android.internal.R.string.orgTypeCustom; |
| 6429 | } |
| 6430 | } |
| 6431 | |
| 6432 | /** |
| 6433 | * Return a {@link CharSequence} that best describes the given type, |
| 6434 | * possibly substituting the given {@link #LABEL} value |
| 6435 | * for {@link #TYPE_CUSTOM}. |
| 6436 | */ |
| 6437 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6438 | CharSequence label) { |
| 6439 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6440 | return label; |
| 6441 | } else { |
| 6442 | final int labelRes = getTypeLabelResource(type); |
| 6443 | return res.getText(labelRes); |
| 6444 | } |
| 6445 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6446 | } |
| 6447 | |
| 6448 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6449 | * <p> |
| 6450 | * A data kind representing an event. |
| 6451 | * </p> |
| 6452 | * <p> |
| 6453 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6454 | * well as the following aliases. |
| 6455 | * </p> |
| 6456 | * <h2>Column aliases</h2> |
| 6457 | * <table class="jd-sumtable"> |
| 6458 | * <tr> |
| 6459 | * <th>Type</th> |
| 6460 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6461 | * </tr> |
| 6462 | * <tr> |
| 6463 | * <td>String</td> |
| 6464 | * <td>{@link #START_DATE}</td> |
| 6465 | * <td>{@link #DATA1}</td> |
| 6466 | * <td></td> |
| 6467 | * </tr> |
| 6468 | * <tr> |
| 6469 | * <td>int</td> |
| 6470 | * <td>{@link #TYPE}</td> |
| 6471 | * <td>{@link #DATA2}</td> |
| 6472 | * <td>Allowed values are: |
| 6473 | * <p> |
| 6474 | * <ul> |
| 6475 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6476 | * <li>{@link #TYPE_ANNIVERSARY}</li> |
| 6477 | * <li>{@link #TYPE_OTHER}</li> |
| 6478 | * <li>{@link #TYPE_BIRTHDAY}</li> |
| 6479 | * </ul> |
| 6480 | * </p> |
| 6481 | * </td> |
| 6482 | * </tr> |
| 6483 | * <tr> |
| 6484 | * <td>String</td> |
| 6485 | * <td>{@link #LABEL}</td> |
| 6486 | * <td>{@link #DATA3}</td> |
| 6487 | * <td></td> |
| 6488 | * </tr> |
| 6489 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6490 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6491 | public static final class Event implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6492 | /** |
| 6493 | * This utility class cannot be instantiated |
| 6494 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6495 | private Event() {} |
| 6496 | |
| 6497 | /** MIME type used when storing this in data table. */ |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6498 | 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] | 6499 | |
| 6500 | public static final int TYPE_ANNIVERSARY = 1; |
| 6501 | public static final int TYPE_OTHER = 2; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6502 | public static final int TYPE_BIRTHDAY = 3; |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6503 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6504 | /** |
| 6505 | * The event start date as the user entered it. |
| 6506 | * <P>Type: TEXT</P> |
| 6507 | */ |
| 6508 | public static final String START_DATE = DATA; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6509 | |
| 6510 | /** |
| 6511 | * Return the string resource that best describes the given |
| 6512 | * {@link #TYPE}. Will always return a valid resource. |
| 6513 | */ |
| 6514 | public static int getTypeResource(Integer type) { |
| 6515 | if (type == null) { |
| 6516 | return com.android.internal.R.string.eventTypeOther; |
| 6517 | } |
| 6518 | switch (type) { |
| 6519 | case TYPE_ANNIVERSARY: |
| 6520 | return com.android.internal.R.string.eventTypeAnniversary; |
| 6521 | case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday; |
| 6522 | case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther; |
Daniel Lehmann | dd384a7 | 2010-11-01 18:40:50 -0700 | [diff] [blame] | 6523 | default: return com.android.internal.R.string.eventTypeCustom; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6524 | } |
| 6525 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6526 | } |
| 6527 | |
| 6528 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6529 | * <p> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6530 | * A data kind representing a photo for the contact. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6531 | * </p> |
| 6532 | * <p> |
| 6533 | * Some sync adapters will choose to download photos in a separate |
| 6534 | * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1} |
| 6535 | * through {@link ContactsContract.Data#SYNC4} to store temporary |
| 6536 | * data, e.g. the image URL or ID, state of download, server-side version |
| 6537 | * of the image. It is allowed for the {@link #PHOTO} to be null. |
| 6538 | * </p> |
| 6539 | * <p> |
| 6540 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6541 | * well as the following aliases. |
| 6542 | * </p> |
| 6543 | * <h2>Column aliases</h2> |
| 6544 | * <table class="jd-sumtable"> |
| 6545 | * <tr> |
| 6546 | * <th>Type</th> |
| 6547 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6548 | * </tr> |
| 6549 | * <tr> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6550 | * <td>NUMBER</td> |
| 6551 | * <td>{@link #PHOTO_FILE_ID}</td> |
| 6552 | * <td>{@link #DATA14}</td> |
| 6553 | * <td>ID of the hi-res photo file.</td> |
| 6554 | * </tr> |
| 6555 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6556 | * <td>BLOB</td> |
| 6557 | * <td>{@link #PHOTO}</td> |
| 6558 | * <td>{@link #DATA15}</td> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6559 | * <td>By convention, binary data is stored in DATA15. The thumbnail of the |
| 6560 | * photo is stored in this column.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6561 | * </tr> |
| 6562 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6563 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6564 | public static final class Photo implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6565 | /** |
| 6566 | * This utility class cannot be instantiated |
| 6567 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6568 | private Photo() {} |
| 6569 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6570 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6571 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; |
| 6572 | |
| 6573 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6574 | * Photo file ID for the display photo of the raw contact. |
| 6575 | * See {@link ContactsContract.DisplayPhoto}. |
| 6576 | * <p> |
| 6577 | * Type: NUMBER |
| 6578 | */ |
| 6579 | public static final String PHOTO_FILE_ID = DATA14; |
| 6580 | |
| 6581 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 6582 | * 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] | 6583 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6584 | * <p> |
| 6585 | * Type: BLOB |
| 6586 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6587 | public static final String PHOTO = DATA15; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6588 | } |
| 6589 | |
| 6590 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6591 | * <p> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6592 | * Notes about the contact. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6593 | * </p> |
| 6594 | * <p> |
| 6595 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6596 | * well as the following aliases. |
| 6597 | * </p> |
| 6598 | * <h2>Column aliases</h2> |
| 6599 | * <table class="jd-sumtable"> |
| 6600 | * <tr> |
| 6601 | * <th>Type</th> |
| 6602 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6603 | * </tr> |
| 6604 | * <tr> |
| 6605 | * <td>String</td> |
| 6606 | * <td>{@link #NOTE}</td> |
| 6607 | * <td>{@link #DATA1}</td> |
| 6608 | * <td></td> |
| 6609 | * </tr> |
| 6610 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6611 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6612 | public static final class Note implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6613 | /** |
| 6614 | * This utility class cannot be instantiated |
| 6615 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6616 | private Note() {} |
| 6617 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6618 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6619 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; |
| 6620 | |
| 6621 | /** |
| 6622 | * The note text. |
| 6623 | * <P>Type: TEXT</P> |
| 6624 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6625 | public static final String NOTE = DATA1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6626 | } |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6627 | |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 6628 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6629 | * <p> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6630 | * Group Membership. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6631 | * </p> |
| 6632 | * <p> |
| 6633 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6634 | * well as the following aliases. |
| 6635 | * </p> |
| 6636 | * <h2>Column aliases</h2> |
| 6637 | * <table class="jd-sumtable"> |
| 6638 | * <tr> |
| 6639 | * <th>Type</th> |
| 6640 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6641 | * </tr> |
| 6642 | * <tr> |
| 6643 | * <td>long</td> |
| 6644 | * <td>{@link #GROUP_ROW_ID}</td> |
| 6645 | * <td>{@link #DATA1}</td> |
| 6646 | * <td></td> |
| 6647 | * </tr> |
| 6648 | * <tr> |
| 6649 | * <td>String</td> |
| 6650 | * <td>{@link #GROUP_SOURCE_ID}</td> |
| 6651 | * <td>none</td> |
| 6652 | * <td> |
| 6653 | * <p> |
| 6654 | * The sourceid of the group that this group membership refers to. |
| 6655 | * Exactly one of this or {@link #GROUP_ROW_ID} must be set when |
| 6656 | * inserting a row. |
| 6657 | * </p> |
| 6658 | * <p> |
| 6659 | * If this field is specified, the provider will first try to |
| 6660 | * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group |
| 6661 | * is found, it will use the corresponding row id. If the group is not |
| 6662 | * found, it will create one. |
| 6663 | * </td> |
| 6664 | * </tr> |
| 6665 | * </table> |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 6666 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6667 | public static final class GroupMembership implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6668 | /** |
| 6669 | * This utility class cannot be instantiated |
| 6670 | */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6671 | private GroupMembership() {} |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 6672 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6673 | /** MIME type used when storing this in data table. */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6674 | public static final String CONTENT_ITEM_TYPE = |
| 6675 | "vnd.android.cursor.item/group_membership"; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 6676 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6677 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 6678 | * The row id of the group that this group membership refers to. Exactly one of |
| 6679 | * 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] | 6680 | * <P>Type: INTEGER</P> |
| 6681 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6682 | public static final String GROUP_ROW_ID = DATA1; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 6683 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6684 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 6685 | * The sourceid of the group that this group membership refers to. Exactly one of |
| 6686 | * 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] | 6687 | * <P>Type: TEXT</P> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6688 | */ |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 6689 | public static final String GROUP_SOURCE_ID = "group_sourceid"; |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6690 | } |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6691 | |
| 6692 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6693 | * <p> |
| 6694 | * A data kind representing a website related to the contact. |
| 6695 | * </p> |
| 6696 | * <p> |
| 6697 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6698 | * well as the following aliases. |
| 6699 | * </p> |
| 6700 | * <h2>Column aliases</h2> |
| 6701 | * <table class="jd-sumtable"> |
| 6702 | * <tr> |
| 6703 | * <th>Type</th> |
| 6704 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6705 | * </tr> |
| 6706 | * <tr> |
| 6707 | * <td>String</td> |
| 6708 | * <td>{@link #URL}</td> |
| 6709 | * <td>{@link #DATA1}</td> |
| 6710 | * <td></td> |
| 6711 | * </tr> |
| 6712 | * <tr> |
| 6713 | * <td>int</td> |
| 6714 | * <td>{@link #TYPE}</td> |
| 6715 | * <td>{@link #DATA2}</td> |
| 6716 | * <td>Allowed values are: |
| 6717 | * <p> |
| 6718 | * <ul> |
| 6719 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6720 | * <li>{@link #TYPE_HOMEPAGE}</li> |
| 6721 | * <li>{@link #TYPE_BLOG}</li> |
| 6722 | * <li>{@link #TYPE_PROFILE}</li> |
| 6723 | * <li>{@link #TYPE_HOME}</li> |
| 6724 | * <li>{@link #TYPE_WORK}</li> |
| 6725 | * <li>{@link #TYPE_FTP}</li> |
| 6726 | * <li>{@link #TYPE_OTHER}</li> |
| 6727 | * </ul> |
| 6728 | * </p> |
| 6729 | * </td> |
| 6730 | * </tr> |
| 6731 | * <tr> |
| 6732 | * <td>String</td> |
| 6733 | * <td>{@link #LABEL}</td> |
| 6734 | * <td>{@link #DATA3}</td> |
| 6735 | * <td></td> |
| 6736 | * </tr> |
| 6737 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6738 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 6739 | public static final class Website implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6740 | /** |
| 6741 | * This utility class cannot be instantiated |
| 6742 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6743 | private Website() {} |
| 6744 | |
| 6745 | /** MIME type used when storing this in data table. */ |
| 6746 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; |
| 6747 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6748 | public static final int TYPE_HOMEPAGE = 1; |
| 6749 | public static final int TYPE_BLOG = 2; |
| 6750 | public static final int TYPE_PROFILE = 3; |
| 6751 | public static final int TYPE_HOME = 4; |
| 6752 | public static final int TYPE_WORK = 5; |
| 6753 | public static final int TYPE_FTP = 6; |
| 6754 | public static final int TYPE_OTHER = 7; |
| 6755 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6756 | /** |
| 6757 | * The website URL string. |
| 6758 | * <P>Type: TEXT</P> |
| 6759 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6760 | public static final String URL = DATA; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6761 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 6762 | |
| 6763 | /** |
| 6764 | * <p> |
| 6765 | * A data kind representing a SIP address for the contact. |
| 6766 | * </p> |
| 6767 | * <p> |
| 6768 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6769 | * well as the following aliases. |
| 6770 | * </p> |
| 6771 | * <h2>Column aliases</h2> |
| 6772 | * <table class="jd-sumtable"> |
| 6773 | * <tr> |
| 6774 | * <th>Type</th> |
| 6775 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6776 | * </tr> |
| 6777 | * <tr> |
| 6778 | * <td>String</td> |
| 6779 | * <td>{@link #SIP_ADDRESS}</td> |
| 6780 | * <td>{@link #DATA1}</td> |
| 6781 | * <td></td> |
| 6782 | * </tr> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 6783 | * <tr> |
| 6784 | * <td>int</td> |
| 6785 | * <td>{@link #TYPE}</td> |
| 6786 | * <td>{@link #DATA2}</td> |
| 6787 | * <td>Allowed values are: |
| 6788 | * <p> |
| 6789 | * <ul> |
| 6790 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6791 | * <li>{@link #TYPE_HOME}</li> |
| 6792 | * <li>{@link #TYPE_WORK}</li> |
| 6793 | * <li>{@link #TYPE_OTHER}</li> |
| 6794 | * </ul> |
| 6795 | * </p> |
| 6796 | * </td> |
| 6797 | * </tr> |
| 6798 | * <tr> |
| 6799 | * <td>String</td> |
| 6800 | * <td>{@link #LABEL}</td> |
| 6801 | * <td>{@link #DATA3}</td> |
| 6802 | * <td></td> |
| 6803 | * </tr> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 6804 | * </table> |
| 6805 | */ |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 6806 | public static final class SipAddress implements DataColumnsWithJoins, CommonColumns { |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 6807 | /** |
| 6808 | * This utility class cannot be instantiated |
| 6809 | */ |
| 6810 | private SipAddress() {} |
| 6811 | |
| 6812 | /** MIME type used when storing this in data table. */ |
| 6813 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address"; |
| 6814 | |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 6815 | public static final int TYPE_HOME = 1; |
| 6816 | public static final int TYPE_WORK = 2; |
| 6817 | public static final int TYPE_OTHER = 3; |
| 6818 | |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 6819 | /** |
| 6820 | * The SIP address. |
| 6821 | * <P>Type: TEXT</P> |
| 6822 | */ |
| 6823 | public static final String SIP_ADDRESS = DATA1; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 6824 | // ...and TYPE and LABEL come from the CommonColumns interface. |
| 6825 | |
| 6826 | /** |
| 6827 | * Return the string resource that best describes the given |
| 6828 | * {@link #TYPE}. Will always return a valid resource. |
| 6829 | */ |
| 6830 | public static final int getTypeLabelResource(int type) { |
| 6831 | switch (type) { |
| 6832 | case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome; |
| 6833 | case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork; |
| 6834 | case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther; |
| 6835 | default: return com.android.internal.R.string.sipAddressTypeCustom; |
| 6836 | } |
| 6837 | } |
| 6838 | |
| 6839 | /** |
| 6840 | * Return a {@link CharSequence} that best describes the given type, |
| 6841 | * possibly substituting the given {@link #LABEL} value |
| 6842 | * for {@link #TYPE_CUSTOM}. |
| 6843 | */ |
| 6844 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6845 | CharSequence label) { |
| 6846 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6847 | return label; |
| 6848 | } else { |
| 6849 | final int labelRes = getTypeLabelResource(type); |
| 6850 | return res.getText(labelRes); |
| 6851 | } |
| 6852 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 6853 | } |
Fred Quintana | 4923f1d | 2011-08-05 15:58:17 -0700 | [diff] [blame] | 6854 | |
| 6855 | /** |
| 6856 | * A data kind representing an Identity related to the contact. |
| 6857 | * <p> |
| 6858 | * This can be used as a signal by the aggregator to combine raw contacts into |
| 6859 | * contacts, e.g. if two contacts have Identity rows with |
| 6860 | * the same NAMESPACE and IDENTITY values the aggregator can know that they refer |
| 6861 | * to the same person. |
| 6862 | * </p> |
| 6863 | */ |
| 6864 | public static final class Identity implements DataColumnsWithJoins { |
| 6865 | /** |
| 6866 | * This utility class cannot be instantiated |
| 6867 | */ |
| 6868 | private Identity() {} |
| 6869 | |
| 6870 | /** MIME type used when storing this in data table. */ |
| 6871 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity"; |
| 6872 | |
| 6873 | /** |
| 6874 | * The identity string. |
| 6875 | * <P>Type: TEXT</P> |
| 6876 | */ |
| 6877 | public static final String IDENTITY = DataColumns.DATA1; |
| 6878 | |
| 6879 | /** |
| 6880 | * The namespace of the identity string, e.g. "com.google" |
| 6881 | * <P>Type: TEXT</P> |
| 6882 | */ |
| 6883 | public static final String NAMESPACE = DataColumns.DATA2; |
| 6884 | } |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 6885 | |
| 6886 | /** |
| 6887 | * <p> |
| 6888 | * Convenient functionalities for "callable" data. Note that, this is NOT a separate data |
| 6889 | * kind. |
| 6890 | * </p> |
| 6891 | * <p> |
| 6892 | * This URI allows the ContactsProvider to return a unified result for "callable" data |
| 6893 | * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the |
| 6894 | * current examples for "callable", but may be expanded to the other types. |
| 6895 | * </p> |
| 6896 | * <p> |
| 6897 | * Each returned row may have a different MIMETYPE and thus different interpretation for |
| 6898 | * each column. For example the meaning for {@link Phone}'s type is different than |
| 6899 | * {@link SipAddress}'s. |
| 6900 | * </p> |
| 6901 | * |
| 6902 | * @hide |
| 6903 | */ |
| 6904 | public static final class Callable implements DataColumnsWithJoins, CommonColumns { |
| 6905 | /** |
| 6906 | * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only |
| 6907 | * phone numbers. |
| 6908 | */ |
| 6909 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6910 | "callables"); |
| 6911 | /** |
| 6912 | * Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable |
| 6913 | * data. |
| 6914 | */ |
| 6915 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 6916 | "filter"); |
| 6917 | } |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 6918 | |
| 6919 | /** |
| 6920 | * A special class of data items, used to refer to types of data that can be used to attempt |
| 6921 | * to start communicating with a person ({@link Phone} and {@link Email}). Note that this |
| 6922 | * is NOT a separate data kind. |
| 6923 | * |
| 6924 | * This URI allows the ContactsProvider to return a unified result for data items that users |
| 6925 | * can use to initiate communications with another contact. {@link Phone} and {@link Email} |
| 6926 | * are the current data types in this category. |
| 6927 | */ |
| 6928 | public static final class Contactables implements DataColumnsWithJoins, CommonColumns { |
| 6929 | /** |
| 6930 | * The content:// style URI for these data items, which requests a directory of data |
| 6931 | * rows matching the selection criteria. |
| 6932 | */ |
| 6933 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6934 | "contactables"); |
| 6935 | |
| 6936 | /** |
| 6937 | * The content:// style URI for these data items, which allows for a query parameter to |
| 6938 | * be appended onto the end to filter for data items matching the query. |
| 6939 | */ |
| 6940 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 6941 | Contactables.CONTENT_URI, "filter"); |
| 6942 | |
| 6943 | /** |
| 6944 | * A boolean parameter for {@link Data#CONTENT_URI}. |
| 6945 | * This specifies whether or not the returned data items should be filtered to show |
| 6946 | * data items belonging to visible contacts only. |
| 6947 | */ |
| 6948 | public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; |
| 6949 | } |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 6950 | } |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 6951 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6952 | /** |
| 6953 | * @see Groups |
| 6954 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 6955 | protected interface GroupsColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 6956 | /** |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 6957 | * The data set within the account that this group belongs to. This allows |
| 6958 | * multiple sync adapters for the same account type to distinguish between |
| 6959 | * each others' group data. |
| 6960 | * |
| 6961 | * This is empty by default, and is completely optional. It only needs to |
| 6962 | * be populated if multiple sync adapters are entering distinct group data |
| 6963 | * for the same account type and account name. |
| 6964 | * <P>Type: TEXT</P> |
| 6965 | */ |
| 6966 | public static final String DATA_SET = "data_set"; |
| 6967 | |
| 6968 | /** |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 6969 | * A concatenation of the account type and data set (delimited by a forward |
| 6970 | * slash) - if the data set is empty, this will be the same as the account |
| 6971 | * type. For applications that need to be aware of the data set, this can |
| 6972 | * be used instead of account type to distinguish sets of data. This is |
| 6973 | * never intended to be used for specifying accounts. |
| 6974 | * @hide |
| 6975 | */ |
| 6976 | public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; |
| 6977 | |
| 6978 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 6979 | * The display title of this group. |
| 6980 | * <p> |
| 6981 | * Type: TEXT |
| 6982 | */ |
| 6983 | public static final String TITLE = "title"; |
| 6984 | |
| 6985 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6986 | * The package name to use when creating {@link Resources} objects for |
| 6987 | * this group. This value is only designed for use when building user |
| 6988 | * interfaces, and should not be used to infer the owner. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6989 | * |
| 6990 | * @hide |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 6991 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6992 | public static final String RES_PACKAGE = "res_package"; |
| 6993 | |
| 6994 | /** |
| 6995 | * The display title of this group to load as a resource from |
| 6996 | * {@link #RES_PACKAGE}, which may be localized. |
| 6997 | * <P>Type: TEXT</P> |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6998 | * |
| 6999 | * @hide |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7000 | */ |
| 7001 | public static final String TITLE_RES = "title_res"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7002 | |
| 7003 | /** |
Dmitri Plotnikov | 02c5b45 | 2009-07-22 15:13:08 -0700 | [diff] [blame] | 7004 | * Notes about the group. |
| 7005 | * <p> |
| 7006 | * Type: TEXT |
| 7007 | */ |
| 7008 | public static final String NOTES = "notes"; |
| 7009 | |
| 7010 | /** |
| 7011 | * The ID of this group if it is a System Group, i.e. a group that has a special meaning |
| 7012 | * to the sync adapter, null otherwise. |
| 7013 | * <P>Type: TEXT</P> |
| 7014 | */ |
| 7015 | public static final String SYSTEM_ID = "system_id"; |
| 7016 | |
| 7017 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7018 | * The total number of {@link Contacts} that have |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7019 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7020 | * present when querying {@link Groups#CONTENT_SUMMARY_URI}. |
| 7021 | * <p> |
| 7022 | * Type: INTEGER |
| 7023 | */ |
| 7024 | public static final String SUMMARY_COUNT = "summ_count"; |
| 7025 | |
| 7026 | /** |
Daisuke Miyakawa | 15dec39 | 2011-07-23 11:39:23 -0700 | [diff] [blame] | 7027 | * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}. |
| 7028 | * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}. |
| 7029 | * |
| 7030 | * @hide |
| 7031 | */ |
| 7032 | public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT = |
| 7033 | "return_group_count_per_account"; |
| 7034 | |
| 7035 | /** |
| 7036 | * The total number of groups of the account that a group belongs to. |
| 7037 | * This column is available only when the parameter |
| 7038 | * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in |
| 7039 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 7040 | * |
| 7041 | * For example, when the account "A" has two groups "group1" and "group2", and the account |
| 7042 | * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for |
| 7043 | * "group3" returns "1" for this column. |
| 7044 | * |
| 7045 | * Note: This counts only non-favorites, non-auto-add, and not deleted groups. |
| 7046 | * |
| 7047 | * Type: INTEGER |
| 7048 | * @hide |
| 7049 | */ |
| 7050 | public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account"; |
| 7051 | |
| 7052 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7053 | * The total number of {@link Contacts} that have both |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7054 | * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7055 | * Read-only value that is only present when querying |
| 7056 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 7057 | * <p> |
| 7058 | * Type: INTEGER |
| 7059 | */ |
| 7060 | public static final String SUMMARY_WITH_PHONES = "summ_phones"; |
| 7061 | |
| 7062 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7063 | * Flag indicating if the contacts belonging to this group should be |
| 7064 | * visible in any user interface. |
| 7065 | * <p> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7066 | * Type: INTEGER (boolean) |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7067 | */ |
| 7068 | public static final String GROUP_VISIBLE = "group_visible"; |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 7069 | |
| 7070 | /** |
| 7071 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 7072 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7073 | * called on a group, it is marked for deletion. The sync adaptor |
| 7074 | * deletes the group on the server and then calls ContactResolver.delete |
| 7075 | * once more, this time setting the the |
| 7076 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to |
| 7077 | * finalize the data removal. |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 7078 | * <P>Type: INTEGER</P> |
| 7079 | */ |
| 7080 | public static final String DELETED = "deleted"; |
Jeff Sharkey | 403d7ac | 2009-08-16 16:34:35 -0700 | [diff] [blame] | 7081 | |
| 7082 | /** |
| 7083 | * Whether this group should be synced if the SYNC_EVERYTHING settings |
| 7084 | * is false for this group's account. |
| 7085 | * <p> |
| 7086 | * Type: INTEGER (boolean) |
| 7087 | */ |
| 7088 | public static final String SHOULD_SYNC = "should_sync"; |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 7089 | |
| 7090 | /** |
| 7091 | * Any newly created contacts will automatically be added to groups that have this |
| 7092 | * flag set to true. |
| 7093 | * <p> |
| 7094 | * Type: INTEGER (boolean) |
| 7095 | */ |
| 7096 | public static final String AUTO_ADD = "auto_add"; |
| 7097 | |
| 7098 | /** |
| 7099 | * When a contacts is marked as a favorites it will be automatically added |
| 7100 | * to the groups that have this flag set, and when it is removed from favorites |
| 7101 | * it will be removed from these groups. |
| 7102 | * <p> |
| 7103 | * Type: INTEGER (boolean) |
| 7104 | */ |
| 7105 | public static final String FAVORITES = "favorites"; |
Dmitri Plotnikov | 4ccf33a | 2010-11-19 11:10:43 -0800 | [diff] [blame] | 7106 | |
| 7107 | /** |
| 7108 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 7109 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 7110 | * <P>Type: INTEGER</P> |
| 7111 | */ |
| 7112 | public static final String GROUP_IS_READ_ONLY = "group_is_read_only"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7113 | } |
| 7114 | |
| 7115 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7116 | * Constants for the groups table. Only per-account groups are supported. |
| 7117 | * <h2>Columns</h2> |
| 7118 | * <table class="jd-sumtable"> |
| 7119 | * <tr> |
| 7120 | * <th colspan='4'>Groups</th> |
| 7121 | * </tr> |
| 7122 | * <tr> |
| 7123 | * <td>long</td> |
| 7124 | * <td>{@link #_ID}</td> |
| 7125 | * <td>read-only</td> |
| 7126 | * <td>Row ID. Sync adapter should try to preserve row IDs during updates. |
| 7127 | * In other words, it would be a really bad idea to delete and reinsert a |
| 7128 | * group. A sync adapter should always do an update instead.</td> |
| 7129 | * </tr> |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 7130 | # <tr> |
| 7131 | * <td>String</td> |
| 7132 | * <td>{@link #DATA_SET}</td> |
| 7133 | * <td>read/write-once</td> |
| 7134 | * <td> |
| 7135 | * <p> |
| 7136 | * The data set within the account that this group belongs to. This allows |
| 7137 | * multiple sync adapters for the same account type to distinguish between |
| 7138 | * each others' group data. The combination of {@link #ACCOUNT_TYPE}, |
| 7139 | * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data |
| 7140 | * that is associated with a single sync adapter. |
| 7141 | * </p> |
| 7142 | * <p> |
| 7143 | * This is empty by default, and is completely optional. It only needs to |
| 7144 | * be populated if multiple sync adapters are entering distinct data for |
| 7145 | * the same account type and account name. |
| 7146 | * </p> |
| 7147 | * <p> |
| 7148 | * It should be set at the time the group is inserted and never changed |
| 7149 | * afterwards. |
| 7150 | * </p> |
| 7151 | * </td> |
| 7152 | * </tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7153 | * <tr> |
| 7154 | * <td>String</td> |
| 7155 | * <td>{@link #TITLE}</td> |
| 7156 | * <td>read/write</td> |
| 7157 | * <td>The display title of this group.</td> |
| 7158 | * </tr> |
| 7159 | * <tr> |
| 7160 | * <td>String</td> |
| 7161 | * <td>{@link #NOTES}</td> |
| 7162 | * <td>read/write</td> |
| 7163 | * <td>Notes about the group.</td> |
| 7164 | * </tr> |
| 7165 | * <tr> |
| 7166 | * <td>String</td> |
| 7167 | * <td>{@link #SYSTEM_ID}</td> |
| 7168 | * <td>read/write</td> |
| 7169 | * <td>The ID of this group if it is a System Group, i.e. a group that has a |
| 7170 | * special meaning to the sync adapter, null otherwise.</td> |
| 7171 | * </tr> |
| 7172 | * <tr> |
| 7173 | * <td>int</td> |
| 7174 | * <td>{@link #SUMMARY_COUNT}</td> |
| 7175 | * <td>read-only</td> |
| 7176 | * <td>The total number of {@link Contacts} that have |
| 7177 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value |
| 7178 | * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 7179 | * </tr> |
| 7180 | * <tr> |
| 7181 | * <td>int</td> |
| 7182 | * <td>{@link #SUMMARY_WITH_PHONES}</td> |
| 7183 | * <td>read-only</td> |
| 7184 | * <td>The total number of {@link Contacts} that have both |
| 7185 | * {@link CommonDataKinds.GroupMembership} in this group, and also have |
| 7186 | * phone numbers. Read-only value that is only present when querying |
| 7187 | * {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 7188 | * </tr> |
| 7189 | * <tr> |
| 7190 | * <td>int</td> |
| 7191 | * <td>{@link #GROUP_VISIBLE}</td> |
| 7192 | * <td>read-only</td> |
| 7193 | * <td>Flag indicating if the contacts belonging to this group should be |
| 7194 | * visible in any user interface. Allowed values: 0 and 1.</td> |
| 7195 | * </tr> |
| 7196 | * <tr> |
| 7197 | * <td>int</td> |
| 7198 | * <td>{@link #DELETED}</td> |
| 7199 | * <td>read/write</td> |
| 7200 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 7201 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 7202 | * called on a group, it is marked for deletion. The sync adaptor deletes |
| 7203 | * the group on the server and then calls ContactResolver.delete once more, |
| 7204 | * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER} |
| 7205 | * query parameter to finalize the data removal.</td> |
| 7206 | * </tr> |
| 7207 | * <tr> |
| 7208 | * <td>int</td> |
| 7209 | * <td>{@link #SHOULD_SYNC}</td> |
| 7210 | * <td>read/write</td> |
| 7211 | * <td>Whether this group should be synced if the SYNC_EVERYTHING settings |
| 7212 | * is false for this group's account.</td> |
| 7213 | * </tr> |
| 7214 | * </table> |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7215 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7216 | public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7217 | /** |
| 7218 | * This utility class cannot be instantiated |
| 7219 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7220 | private Groups() { |
| 7221 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7222 | |
| 7223 | /** |
| 7224 | * The content:// style URI for this table |
| 7225 | */ |
| 7226 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); |
| 7227 | |
| 7228 | /** |
| 7229 | * The content:// style URI for this table joined with details data from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7230 | * {@link ContactsContract.Data}. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7231 | */ |
| 7232 | public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 7233 | "groups_summary"); |
| 7234 | |
| 7235 | /** |
| 7236 | * The MIME type of a directory of groups. |
| 7237 | */ |
| 7238 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; |
| 7239 | |
| 7240 | /** |
| 7241 | * The MIME type of a single group. |
| 7242 | */ |
| 7243 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7244 | |
| 7245 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 7246 | return new EntityIteratorImpl(cursor); |
| 7247 | } |
| 7248 | |
| 7249 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 7250 | public EntityIteratorImpl(Cursor cursor) { |
| 7251 | super(cursor); |
| 7252 | } |
| 7253 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 7254 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7255 | public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { |
| 7256 | // we expect the cursor is already at the row we need to read from |
| 7257 | final ContentValues values = new ContentValues(); |
| 7258 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID); |
| 7259 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME); |
| 7260 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE); |
| 7261 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY); |
| 7262 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION); |
| 7263 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID); |
| 7264 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE); |
| 7265 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE); |
| 7266 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES); |
| 7267 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE); |
| 7268 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1); |
| 7269 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2); |
| 7270 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3); |
| 7271 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4); |
| 7272 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID); |
| 7273 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED); |
| 7274 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES); |
| 7275 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC); |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 7276 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES); |
| 7277 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7278 | cursor.moveToNext(); |
| 7279 | return new Entity(values); |
| 7280 | } |
| 7281 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7282 | } |
| 7283 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7284 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7285 | * <p> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7286 | * Constants for the contact aggregation exceptions table, which contains |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7287 | * aggregation rules overriding those used by automatic aggregation. This |
| 7288 | * type only supports query and update. Neither insert nor delete are |
| 7289 | * supported. |
| 7290 | * </p> |
| 7291 | * <h2>Columns</h2> |
| 7292 | * <table class="jd-sumtable"> |
| 7293 | * <tr> |
| 7294 | * <th colspan='4'>AggregationExceptions</th> |
| 7295 | * </tr> |
| 7296 | * <tr> |
| 7297 | * <td>int</td> |
| 7298 | * <td>{@link #TYPE}</td> |
| 7299 | * <td>read/write</td> |
| 7300 | * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER}, |
| 7301 | * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td> |
| 7302 | * </tr> |
| 7303 | * <tr> |
| 7304 | * <td>long</td> |
| 7305 | * <td>{@link #RAW_CONTACT_ID1}</td> |
| 7306 | * <td>read/write</td> |
| 7307 | * <td>A reference to the {@link RawContacts#_ID} of the raw contact that |
| 7308 | * the rule applies to.</td> |
| 7309 | * </tr> |
| 7310 | * <tr> |
| 7311 | * <td>long</td> |
| 7312 | * <td>{@link #RAW_CONTACT_ID2}</td> |
| 7313 | * <td>read/write</td> |
| 7314 | * <td>A reference to the other {@link RawContacts#_ID} of the raw contact |
| 7315 | * that the rule applies to.</td> |
| 7316 | * </tr> |
| 7317 | * </table> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7318 | */ |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 7319 | public static final class AggregationExceptions implements BaseColumns { |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7320 | /** |
| 7321 | * This utility class cannot be instantiated |
| 7322 | */ |
| 7323 | private AggregationExceptions() {} |
| 7324 | |
| 7325 | /** |
| 7326 | * The content:// style URI for this table |
| 7327 | */ |
| 7328 | public static final Uri CONTENT_URI = |
| 7329 | Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); |
| 7330 | |
| 7331 | /** |
| 7332 | * The MIME type of {@link #CONTENT_URI} providing a directory of data. |
| 7333 | */ |
| 7334 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; |
| 7335 | |
| 7336 | /** |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 7337 | * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception |
| 7338 | */ |
| 7339 | public static final String CONTENT_ITEM_TYPE = |
| 7340 | "vnd.android.cursor.item/aggregation_exception"; |
| 7341 | |
| 7342 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7343 | * 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] | 7344 | * {@link #TYPE_AUTOMATIC}. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7345 | * |
| 7346 | * <P>Type: INTEGER</P> |
| 7347 | */ |
| 7348 | public static final String TYPE = "type"; |
| 7349 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7350 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7351 | * Allows the provider to automatically decide whether the specified raw contacts should |
| 7352 | * be included in the same aggregate contact or not. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7353 | */ |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7354 | public static final int TYPE_AUTOMATIC = 0; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7355 | |
| 7356 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7357 | * Makes sure that the specified raw contacts are included in the same |
| 7358 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7359 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7360 | public static final int TYPE_KEEP_TOGETHER = 1; |
| 7361 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7362 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7363 | * Makes sure that the specified raw contacts are NOT included in the same |
| 7364 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7365 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7366 | public static final int TYPE_KEEP_SEPARATE = 2; |
| 7367 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7368 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7369 | * 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] | 7370 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7371 | public static final String RAW_CONTACT_ID1 = "raw_contact_id1"; |
| 7372 | |
| 7373 | /** |
| 7374 | * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule |
| 7375 | * applies to. |
| 7376 | */ |
| 7377 | public static final String RAW_CONTACT_ID2 = "raw_contact_id2"; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7378 | } |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 7379 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7380 | /** |
| 7381 | * @see Settings |
| 7382 | */ |
Dmitri Plotnikov | fe4c871 | 2009-10-14 00:28:48 -0700 | [diff] [blame] | 7383 | protected interface SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7384 | /** |
| 7385 | * The name of the account instance to which this row belongs. |
| 7386 | * <P>Type: TEXT</P> |
| 7387 | */ |
| 7388 | public static final String ACCOUNT_NAME = "account_name"; |
| 7389 | |
| 7390 | /** |
| 7391 | * The type of account to which this row belongs, which when paired with |
| 7392 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 7393 | * <P>Type: TEXT</P> |
| 7394 | */ |
| 7395 | public static final String ACCOUNT_TYPE = "account_type"; |
| 7396 | |
| 7397 | /** |
Dave Santoro | 7c4479f | 2011-09-07 16:52:27 -0700 | [diff] [blame] | 7398 | * The data set within the account that this row belongs to. This allows |
| 7399 | * multiple sync adapters for the same account type to distinguish between |
| 7400 | * each others' data. |
| 7401 | * |
| 7402 | * This is empty by default, and is completely optional. It only needs to |
| 7403 | * be populated if multiple sync adapters are entering distinct data for |
| 7404 | * the same account type and account name. |
| 7405 | * <P>Type: TEXT</P> |
| 7406 | */ |
| 7407 | public static final String DATA_SET = "data_set"; |
| 7408 | |
| 7409 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7410 | * Depending on the mode defined by the sync-adapter, this flag controls |
| 7411 | * the top-level sync behavior for this data source. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7412 | * <p> |
| 7413 | * Type: INTEGER (boolean) |
| 7414 | */ |
| 7415 | public static final String SHOULD_SYNC = "should_sync"; |
| 7416 | |
| 7417 | /** |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7418 | * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership} |
Jeff Sharkey | a659744 | 2009-08-19 09:23:33 -0700 | [diff] [blame] | 7419 | * entries should be visible in any user interface. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7420 | * <p> |
| 7421 | * Type: INTEGER (boolean) |
| 7422 | */ |
| 7423 | public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7424 | |
| 7425 | /** |
Jeff Sharkey | 97bda4c | 2009-09-15 23:15:23 -0700 | [diff] [blame] | 7426 | * Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 7427 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 7428 | * unsynced. |
| 7429 | */ |
| 7430 | public static final String ANY_UNSYNCED = "any_unsynced"; |
| 7431 | |
| 7432 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 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. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7435 | * <p> |
| 7436 | * Type: INTEGER |
| 7437 | */ |
| 7438 | public static final String UNGROUPED_COUNT = "summ_count"; |
| 7439 | |
| 7440 | /** |
| 7441 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 7442 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7443 | * <p> |
| 7444 | * Type: INTEGER |
| 7445 | */ |
| 7446 | public static final String UNGROUPED_WITH_PHONES = "summ_phones"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7447 | } |
| 7448 | |
| 7449 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7450 | * <p> |
| 7451 | * Contacts-specific settings for various {@link Account}'s. |
| 7452 | * </p> |
| 7453 | * <h2>Columns</h2> |
| 7454 | * <table class="jd-sumtable"> |
| 7455 | * <tr> |
| 7456 | * <th colspan='4'>Settings</th> |
| 7457 | * </tr> |
| 7458 | * <tr> |
| 7459 | * <td>String</td> |
| 7460 | * <td>{@link #ACCOUNT_NAME}</td> |
| 7461 | * <td>read/write-once</td> |
| 7462 | * <td>The name of the account instance to which this row belongs.</td> |
| 7463 | * </tr> |
| 7464 | * <tr> |
| 7465 | * <td>String</td> |
| 7466 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 7467 | * <td>read/write-once</td> |
| 7468 | * <td>The type of account to which this row belongs, which when paired with |
| 7469 | * {@link #ACCOUNT_NAME} identifies a specific account.</td> |
| 7470 | * </tr> |
| 7471 | * <tr> |
| 7472 | * <td>int</td> |
| 7473 | * <td>{@link #SHOULD_SYNC}</td> |
| 7474 | * <td>read/write</td> |
| 7475 | * <td>Depending on the mode defined by the sync-adapter, this flag controls |
| 7476 | * the top-level sync behavior for this data source.</td> |
| 7477 | * </tr> |
| 7478 | * <tr> |
| 7479 | * <td>int</td> |
| 7480 | * <td>{@link #UNGROUPED_VISIBLE}</td> |
| 7481 | * <td>read/write</td> |
| 7482 | * <td>Flag indicating if contacts without any |
| 7483 | * {@link CommonDataKinds.GroupMembership} entries should be visible in any |
| 7484 | * user interface.</td> |
| 7485 | * </tr> |
| 7486 | * <tr> |
| 7487 | * <td>int</td> |
| 7488 | * <td>{@link #ANY_UNSYNCED}</td> |
| 7489 | * <td>read-only</td> |
| 7490 | * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 7491 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 7492 | * unsynced.</td> |
| 7493 | * </tr> |
| 7494 | * <tr> |
| 7495 | * <td>int</td> |
| 7496 | * <td>{@link #UNGROUPED_COUNT}</td> |
| 7497 | * <td>read-only</td> |
| 7498 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 7499 | * no {@link CommonDataKinds.GroupMembership} entries.</td> |
| 7500 | * </tr> |
| 7501 | * <tr> |
| 7502 | * <td>int</td> |
| 7503 | * <td>{@link #UNGROUPED_WITH_PHONES}</td> |
| 7504 | * <td>read-only</td> |
| 7505 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 7506 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone |
| 7507 | * numbers.</td> |
| 7508 | * </tr> |
| 7509 | * </table> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7510 | */ |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7511 | public static final class Settings implements SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7512 | /** |
| 7513 | * This utility class cannot be instantiated |
| 7514 | */ |
| 7515 | private Settings() { |
| 7516 | } |
| 7517 | |
| 7518 | /** |
| 7519 | * The content:// style URI for this table |
| 7520 | */ |
| 7521 | public static final Uri CONTENT_URI = |
| 7522 | Uri.withAppendedPath(AUTHORITY_URI, "settings"); |
| 7523 | |
| 7524 | /** |
| 7525 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 7526 | * settings. |
| 7527 | */ |
| 7528 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; |
| 7529 | |
| 7530 | /** |
| 7531 | * The MIME-type of {@link #CONTENT_URI} providing a single setting. |
| 7532 | */ |
| 7533 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7534 | } |
| 7535 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 7536 | /** |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 7537 | * Private API for inquiring about the general status of the provider. |
| 7538 | * |
| 7539 | * @hide |
| 7540 | */ |
| 7541 | public static final class ProviderStatus { |
| 7542 | |
| 7543 | /** |
| 7544 | * Not instantiable. |
| 7545 | */ |
| 7546 | private ProviderStatus() { |
| 7547 | } |
| 7548 | |
| 7549 | /** |
| 7550 | * The content:// style URI for this table. Requests to this URI can be |
| 7551 | * performed on the UI thread because they are always unblocking. |
| 7552 | * |
| 7553 | * @hide |
| 7554 | */ |
| 7555 | public static final Uri CONTENT_URI = |
| 7556 | Uri.withAppendedPath(AUTHORITY_URI, "provider_status"); |
| 7557 | |
| 7558 | /** |
| 7559 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 7560 | * settings. |
| 7561 | * |
| 7562 | * @hide |
| 7563 | */ |
| 7564 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status"; |
| 7565 | |
| 7566 | /** |
| 7567 | * An integer representing the current status of the provider. |
| 7568 | * |
| 7569 | * @hide |
| 7570 | */ |
| 7571 | public static final String STATUS = "status"; |
| 7572 | |
| 7573 | /** |
| 7574 | * Default status of the provider. |
| 7575 | * |
| 7576 | * @hide |
| 7577 | */ |
| 7578 | public static final int STATUS_NORMAL = 0; |
| 7579 | |
| 7580 | /** |
| 7581 | * The status used when the provider is in the process of upgrading. Contacts |
| 7582 | * are temporarily unaccessible. |
| 7583 | * |
| 7584 | * @hide |
| 7585 | */ |
| 7586 | public static final int STATUS_UPGRADING = 1; |
| 7587 | |
| 7588 | /** |
| 7589 | * The status used if the provider was in the process of upgrading but ran |
| 7590 | * out of storage. The DATA1 column will contain the estimated amount of |
| 7591 | * storage required (in bytes). Update status to STATUS_NORMAL to force |
| 7592 | * the provider to retry the upgrade. |
| 7593 | * |
| 7594 | * @hide |
| 7595 | */ |
| 7596 | public static final int STATUS_UPGRADE_OUT_OF_MEMORY = 2; |
| 7597 | |
| 7598 | /** |
| 7599 | * The status used during a locale change. |
| 7600 | * |
| 7601 | * @hide |
| 7602 | */ |
| 7603 | public static final int STATUS_CHANGING_LOCALE = 3; |
| 7604 | |
| 7605 | /** |
Dmitri Plotnikov | 37c3486 | 2010-11-12 16:12:53 -0800 | [diff] [blame] | 7606 | * The status that indicates that there are no accounts and no contacts |
| 7607 | * on the device. |
| 7608 | * |
| 7609 | * @hide |
| 7610 | */ |
| 7611 | public static final int STATUS_NO_ACCOUNTS_NO_CONTACTS = 4; |
| 7612 | |
| 7613 | /** |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 7614 | * Additional data associated with the status. |
| 7615 | * |
| 7616 | * @hide |
| 7617 | */ |
| 7618 | public static final String DATA1 = "data1"; |
| 7619 | } |
| 7620 | |
| 7621 | /** |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7622 | * <p> |
| 7623 | * 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] | 7624 | * Contacts Provider. Applications can also clear all usage information. |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7625 | * </p> |
| 7626 | * <p> |
| 7627 | * With the feedback, Contacts Provider may return more contextually appropriate results for |
| 7628 | * Data listing, typically supplied with |
| 7629 | * {@link ContactsContract.Contacts#CONTENT_FILTER_URI}, |
| 7630 | * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI}, |
| 7631 | * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit |
| 7632 | * from better ranked (sorted) lists in applications that show auto-complete list. |
| 7633 | * </p> |
| 7634 | * <p> |
| 7635 | * There is no guarantee for how this feedback is used, or even whether it is used at all. |
| 7636 | * The ranking algorithm will make best efforts to use the feedback data, but the exact |
| 7637 | * implementation, the storage data structures as well as the resulting sort order is device |
| 7638 | * and version specific and can change over time. |
| 7639 | * </p> |
| 7640 | * <p> |
| 7641 | * When updating usage information, users of this API need to use |
| 7642 | * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed |
| 7643 | * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as |
| 7644 | * its last path. They also need to append a query parameter to the Uri, to specify the type of |
| 7645 | * the communication, which enables the Contacts Provider to differentiate between kinds of |
| 7646 | * interactions using the same contact data field (for example a phone number can be used to |
| 7647 | * make phone calls or send SMS). |
| 7648 | * </p> |
| 7649 | * <p> |
| 7650 | * Selection and selectionArgs are ignored and must be set to null. To get data ids, |
| 7651 | * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)} |
| 7652 | * toward {@link Data#CONTENT_URI}. |
| 7653 | * </p> |
| 7654 | * <p> |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 7655 | * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive |
| 7656 | * integer when successful, and returns 0 if no contact with that id was found. |
| 7657 | * </p> |
| 7658 | * <p> |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7659 | * Example: |
| 7660 | * <pre> |
Daisuke Miyakawa | 52e3823 | 2011-06-14 10:56:46 -0700 | [diff] [blame] | 7661 | * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon() |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7662 | * .appendPath(TextUtils.join(",", dataIds)) |
Daisuke Miyakawa | 52e3823 | 2011-06-14 10:56:46 -0700 | [diff] [blame] | 7663 | * .appendQueryParameter(DataUsageFeedback.USAGE_TYPE, |
| 7664 | * DataUsageFeedback.USAGE_TYPE_CALL) |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7665 | * .build(); |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 7666 | * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0; |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7667 | * </pre> |
| 7668 | * </p> |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 7669 | * <p> |
| 7670 | * Applications can also clear all usage information with: |
| 7671 | * <pre> |
Makoto Onuki | 7ebbfd0 | 2012-04-13 12:56:42 -0700 | [diff] [blame] | 7672 | * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0; |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 7673 | * </pre> |
| 7674 | * </p> |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7675 | */ |
| 7676 | public static final class DataUsageFeedback { |
| 7677 | |
| 7678 | /** |
| 7679 | * The content:// style URI for sending usage feedback. |
| 7680 | * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}. |
| 7681 | */ |
| 7682 | public static final Uri FEEDBACK_URI = |
| 7683 | Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback"); |
| 7684 | |
| 7685 | /** |
Makoto Onuki | 7ebbfd0 | 2012-04-13 12:56:42 -0700 | [diff] [blame] | 7686 | * The content:// style URI for deleting all usage information. |
| 7687 | * Must be used with {@link ContentResolver#delete(Uri, String, String[])}. |
| 7688 | * The {@code where} and {@code selectionArgs} parameters are ignored. |
| 7689 | */ |
| 7690 | public static final Uri DELETE_USAGE_URI = |
| 7691 | Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage"); |
| 7692 | |
| 7693 | /** |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7694 | * <p> |
| 7695 | * Name for query parameter specifying the type of data usage. |
| 7696 | * </p> |
| 7697 | */ |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 7698 | public static final String USAGE_TYPE = "type"; |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7699 | |
| 7700 | /** |
| 7701 | * <p> |
| 7702 | * Type of usage for voice interaction, which includes phone call, voice chat, and |
| 7703 | * video chat. |
| 7704 | * </p> |
| 7705 | */ |
| 7706 | public static final String USAGE_TYPE_CALL = "call"; |
| 7707 | |
| 7708 | /** |
| 7709 | * <p> |
| 7710 | * Type of usage for text interaction involving longer messages, which includes email. |
| 7711 | * </p> |
| 7712 | */ |
| 7713 | public static final String USAGE_TYPE_LONG_TEXT = "long_text"; |
| 7714 | |
| 7715 | /** |
| 7716 | * <p> |
| 7717 | * Type of usage for text interaction involving shorter messages, which includes SMS, |
| 7718 | * text chat with email addresses. |
| 7719 | * </p> |
| 7720 | */ |
| 7721 | public static final String USAGE_TYPE_SHORT_TEXT = "short_text"; |
| 7722 | } |
| 7723 | |
| 7724 | /** |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 7725 | * <p> |
| 7726 | * API allowing applications to send pinning information for specified contacts to the |
| 7727 | * Contacts Provider. |
| 7728 | * </p> |
| 7729 | * |
| 7730 | * <p> |
| 7731 | * This pinning information can be used by individual applications to customize how |
| 7732 | * they order particular pinned contacts. For example, a Dialer application could |
| 7733 | * use pinned information to order user-pinned contacts in a top row of favorites. |
| 7734 | * </p> |
| 7735 | * |
| 7736 | * <p> |
| 7737 | * It is possible for two or more contacts to occupy the same pinned position (due |
| 7738 | * to aggregation and sync), so this pinning information should be used on a best-effort |
| 7739 | * basis to order contacts in-application rather than an absolute guide on where a contact |
| 7740 | * should be positioned. Contacts returned by the ContactsProvider will not be ordered based |
| 7741 | * on this information, so it is up to the client application to reorder these contacts within |
| 7742 | * their own UI adhering to (or ignoring as appropriate) information stored in the pinned |
| 7743 | * column. |
| 7744 | * </p> |
| 7745 | * |
| 7746 | * <p> |
| 7747 | * By default, unpinned contacts will have a pinned position of |
| 7748 | * {@link PinnedPositions#UNPINNED}, or {@link Integer#MAX_VALUE} (2^31 - 1). Client-provided |
| 7749 | * pinned positions can be positive integers that range anywhere from 0 to |
| 7750 | * {@link PinnedPositions#UNPINNED}. |
| 7751 | * </p> |
| 7752 | * |
| 7753 | * <p> |
| 7754 | * When using {@link PinnedPositions#UPDATE_URI} to update the pinned positions of |
| 7755 | * certain contacts, it may make sense for your application to star any pinned contacts |
| 7756 | * by default. To specify this behavior, set the boolean query parameter |
| 7757 | * {@link PinnedPositions#STAR_WHEN_PINNING} to true to force all pinned and unpinned |
| 7758 | * contacts to be automatically starred and unstarred. |
| 7759 | * </p> |
| 7760 | * @hide |
| 7761 | */ |
| 7762 | public static final class PinnedPositions { |
| 7763 | |
| 7764 | /** |
| 7765 | * <p> |
| 7766 | * This URI allows applications to update pinned positions for a provided set of contacts. |
| 7767 | * </p> |
| 7768 | * |
| 7769 | * <p> |
| 7770 | * The list of contactIds to pin and their corresponding pinned positions should be |
| 7771 | * provided in key-value pairs stored in a {@link ContentValues} object where the key |
| 7772 | * is a valid contactId, while each pinned position is a positive integer. |
| 7773 | * </p> |
| 7774 | * |
| 7775 | * <p> |
| 7776 | * Example: |
| 7777 | * <pre> |
| 7778 | * ContentValues values = new ContentValues(); |
| 7779 | * values.put("10", 20); |
| 7780 | * values.put("12", 2); |
| 7781 | * values.put("15", PinnedPositions.UNPINNED); |
| 7782 | * int count = resolver.update(PinnedPositions.UPDATE_URI, values, null, null); |
| 7783 | * </pre> |
| 7784 | * |
| 7785 | * This pins the contact with id 10 at position 20, the contact with id 12 at position 2, |
| 7786 | * and unpins the contact with id 15. |
| 7787 | * </p> |
| 7788 | */ |
| 7789 | public static final Uri UPDATE_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 7790 | "pinned_position_update"); |
| 7791 | |
| 7792 | /** |
| 7793 | * Default value for the pinned position of an unpinned contact. Also equal to |
| 7794 | * {@link Integer#MAX_VALUE}. |
| 7795 | */ |
| 7796 | public static final int UNPINNED = 0x7FFFFFFF; |
| 7797 | |
| 7798 | /** |
Yorke Lee | 3585e1a | 2013-07-31 18:53:31 -0700 | [diff] [blame] | 7799 | * Value of pinned position for a contact that a user has indicated should be considered |
| 7800 | * of the lowest priority. It is up to the client application to determine how to present |
| 7801 | * such a contact - for example all the way at the bottom of a contact list, or simply |
| 7802 | * just hidden from view. |
| 7803 | */ |
| 7804 | public static final int DEMOTED = -1; |
| 7805 | |
| 7806 | /** |
| 7807 | * <p> Clients can provide this value as a pinned position to undemote a formerly demoted |
| 7808 | * contact. If the contact was formerly demoted, it will be restored to an |
| 7809 | * {@link #UNPINNED} position. If it was otherwise already pinned at another position, |
| 7810 | * it will not be affected. |
| 7811 | * </p> |
| 7812 | * |
| 7813 | * <p> |
| 7814 | * Example: |
| 7815 | * <pre> |
| 7816 | * ContentValues values = new ContentValues(); |
| 7817 | * values.put("15", PinnedPositions.UNDEMOTE); |
| 7818 | * int count = resolver.update(ContactsContract.PinnedPositions.UPDATE_URI.buildUpon() |
| 7819 | * .build(), values, null, null); |
| 7820 | * </pre> |
| 7821 | * |
| 7822 | * This restores the contact with id 15 to an {@link #UNPINNED} position, meaning that |
| 7823 | * other apps (e.g. the Dialer) that were formerly hiding this contact from view based on |
| 7824 | * its {@link #DEMOTED} position will start displaying it again. |
| 7825 | * </p> |
| 7826 | */ |
| 7827 | public static final String UNDEMOTE = "undemote"; |
| 7828 | |
| 7829 | /** |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 7830 | * <p> |
| 7831 | * A boolean query parameter that can be used with {@link #UPDATE_URI}. |
| 7832 | * If "1" or "true", any contact that is pinned or unpinned will be correspondingly |
| 7833 | * starred or unstarred. Otherwise, starring information will not be affected by pinned |
| 7834 | * updates. This is false by default. |
| 7835 | * </p> |
| 7836 | * |
| 7837 | * <p> |
| 7838 | * Example: |
| 7839 | * <pre> |
| 7840 | * ContentValues values = new ContentValues(); |
| 7841 | * values.put("10", 20); |
| 7842 | * values.put("15", PinnedPositions.UNPINNED); |
| 7843 | * int count = resolver.update(ContactsContract.PinnedPositions.UPDATE_URI.buildUpon() |
| 7844 | * .appendQueryParameter(PinnedPositions.FORCE_STAR_WHEN_PINNING, "true").build(), |
| 7845 | * values, null, null); |
| 7846 | * </pre> |
| 7847 | * |
| 7848 | * This will pin the contact with id 10 at position 20 and star it automatically if not |
| 7849 | * already starred, and unpin the contact with id 15, and unstar it automatically if not |
| 7850 | * already unstarred. |
| 7851 | * </p> |
| 7852 | */ |
| 7853 | public static final String STAR_WHEN_PINNING = "star_when_pinning"; |
| 7854 | } |
| 7855 | |
| 7856 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 7857 | * Helper methods to display QuickContact dialogs that allow users to pivot on |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7858 | * a specific {@link Contacts} entry. |
| 7859 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 7860 | public static final class QuickContact { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7861 | /** |
| 7862 | * Action used to trigger person pivot dialog. |
| 7863 | * @hide |
| 7864 | */ |
Evan Millar | 5042f7e | 2009-09-30 21:28:33 -0700 | [diff] [blame] | 7865 | public static final String ACTION_QUICK_CONTACT = |
| 7866 | "com.android.contacts.action.QUICK_CONTACT"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7867 | |
| 7868 | /** |
| 7869 | * Extra used to specify pivot dialog location in screen coordinates. |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 7870 | * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7871 | * @hide |
| 7872 | */ |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 7873 | @Deprecated |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7874 | public static final String EXTRA_TARGET_RECT = "target_rect"; |
| 7875 | |
| 7876 | /** |
| 7877 | * Extra used to specify size of pivot dialog. |
| 7878 | * @hide |
| 7879 | */ |
| 7880 | public static final String EXTRA_MODE = "mode"; |
| 7881 | |
| 7882 | /** |
| 7883 | * Extra used to indicate a list of specific MIME-types to exclude and |
| 7884 | * not display. Stored as a {@link String} array. |
| 7885 | * @hide |
| 7886 | */ |
| 7887 | public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; |
| 7888 | |
| 7889 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 7890 | * Small QuickContact mode, usually presented with minimal actions. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7891 | */ |
| 7892 | public static final int MODE_SMALL = 1; |
| 7893 | |
| 7894 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 7895 | * Medium QuickContact mode, includes actions and light summary describing |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7896 | * the {@link Contacts} entry being shown. This may include social |
| 7897 | * status and presence details. |
| 7898 | */ |
| 7899 | public static final int MODE_MEDIUM = 2; |
| 7900 | |
| 7901 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 7902 | * Large QuickContact mode, includes actions and larger, card-like summary |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7903 | * of the {@link Contacts} entry being shown. This may include detailed |
| 7904 | * information, such as a photo. |
| 7905 | */ |
| 7906 | public static final int MODE_LARGE = 3; |
| 7907 | |
| 7908 | /** |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 7909 | * Constructs the QuickContacts intent with a view's rect. |
| 7910 | * @hide |
| 7911 | */ |
| 7912 | public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri, |
| 7913 | int mode, String[] excludeMimes) { |
| 7914 | // Find location and bounds of target view, adjusting based on the |
| 7915 | // assumed local density. |
| 7916 | final float appScale = context.getResources().getCompatibilityInfo().applicationScale; |
| 7917 | final int[] pos = new int[2]; |
| 7918 | target.getLocationOnScreen(pos); |
| 7919 | |
| 7920 | final Rect rect = new Rect(); |
| 7921 | rect.left = (int) (pos[0] * appScale + 0.5f); |
| 7922 | rect.top = (int) (pos[1] * appScale + 0.5f); |
| 7923 | rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); |
| 7924 | rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); |
| 7925 | |
| 7926 | return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes); |
| 7927 | } |
| 7928 | |
| 7929 | /** |
| 7930 | * Constructs the QuickContacts intent. |
| 7931 | * @hide |
| 7932 | */ |
| 7933 | public static Intent composeQuickContactsIntent(Context context, Rect target, |
| 7934 | Uri lookupUri, int mode, String[] excludeMimes) { |
| 7935 | // When launching from an Activiy, we don't want to start a new task, but otherwise |
| 7936 | // we *must* start a new task. (Otherwise startActivity() would crash.) |
| 7937 | Context actualContext = context; |
| 7938 | while ((actualContext instanceof ContextWrapper) |
| 7939 | && !(actualContext instanceof Activity)) { |
| 7940 | actualContext = ((ContextWrapper) actualContext).getBaseContext(); |
| 7941 | } |
| 7942 | final int intentFlags = (actualContext instanceof Activity) |
| 7943 | ? Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET |
| 7944 | : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK; |
| 7945 | |
| 7946 | // Launch pivot dialog through intent for now |
| 7947 | final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags); |
| 7948 | |
| 7949 | intent.setData(lookupUri); |
| 7950 | intent.setSourceBounds(target); |
| 7951 | intent.putExtra(EXTRA_MODE, mode); |
| 7952 | intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); |
| 7953 | return intent; |
| 7954 | } |
| 7955 | |
| 7956 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7957 | * Trigger a dialog that lists the various methods of interacting with |
| 7958 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7959 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 7960 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7961 | * |
| 7962 | * @param context The parent {@link Context} that may be used as the |
| 7963 | * parent for this dialog. |
| 7964 | * @param target Specific {@link View} from your layout that this dialog |
| 7965 | * should be centered around. In particular, if the dialog |
| 7966 | * has a "callout" arrow, it will be pointed and centered |
| 7967 | * around this {@link View}. |
Evan Millar | 772722e | 2009-09-30 22:24:07 -0700 | [diff] [blame] | 7968 | * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7969 | * {@link Uri} that describes a specific contact to feature |
| 7970 | * in this dialog. |
| 7971 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 7972 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 7973 | * when supported. |
| 7974 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 7975 | * to exclude when showing this dialog. For example, when |
| 7976 | * already viewing the contact details card, this can be used |
| 7977 | * to omit the details entry from the dialog. |
| 7978 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 7979 | public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7980 | String[] excludeMimes) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7981 | // Trigger with obtained rectangle |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 7982 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, |
| 7983 | excludeMimes); |
| 7984 | context.startActivity(intent); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7985 | } |
| 7986 | |
| 7987 | /** |
| 7988 | * Trigger a dialog that lists the various methods of interacting with |
| 7989 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7990 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 7991 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 7992 | * |
| 7993 | * @param context The parent {@link Context} that may be used as the |
| 7994 | * parent for this dialog. |
| 7995 | * @param target Specific {@link Rect} that this dialog should be |
| 7996 | * centered around, in screen coordinates. In particular, if |
| 7997 | * the dialog has a "callout" arrow, it will be pointed and |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 7998 | * centered around this {@link Rect}. If you are running at a |
| 7999 | * non-native density, you need to manually adjust using |
| 8000 | * {@link DisplayMetrics#density} before calling. |
Jeff Sharkey | 223bd7a | 2009-12-21 14:51:19 -0800 | [diff] [blame] | 8001 | * @param lookupUri A |
| 8002 | * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8003 | * {@link Uri} that describes a specific contact to feature |
| 8004 | * in this dialog. |
| 8005 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 8006 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 8007 | * when supported. |
| 8008 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8009 | * to exclude when showing this dialog. For example, when |
| 8010 | * already viewing the contact details card, this can be used |
| 8011 | * to omit the details entry from the dialog. |
| 8012 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8013 | public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8014 | String[] excludeMimes) { |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8015 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, |
| 8016 | excludeMimes); |
| 8017 | context.startActivity(intent); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8018 | } |
| 8019 | } |
| 8020 | |
| 8021 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8022 | * Helper class for accessing full-size photos by photo file ID. |
| 8023 | * <p> |
| 8024 | * Usage example: |
| 8025 | * <dl> |
| 8026 | * <dt>Retrieving a full-size photo by photo file ID (see |
| 8027 | * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID}) |
| 8028 | * </dt> |
| 8029 | * <dd> |
| 8030 | * <pre> |
| 8031 | * public InputStream openDisplayPhoto(long photoFileId) { |
| 8032 | * Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey); |
| 8033 | * try { |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 8034 | * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor( |
| 8035 | * displayPhotoUri, "r"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8036 | * return fd.createInputStream(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 8037 | * } catch (IOException e) { |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8038 | * return null; |
| 8039 | * } |
| 8040 | * } |
| 8041 | * </pre> |
| 8042 | * </dd> |
| 8043 | * </dl> |
| 8044 | * </p> |
| 8045 | */ |
| 8046 | public static final class DisplayPhoto { |
| 8047 | /** |
| 8048 | * no public constructor since this is a utility class |
| 8049 | */ |
| 8050 | private DisplayPhoto() {} |
| 8051 | |
| 8052 | /** |
| 8053 | * The content:// style URI for this class, which allows access to full-size photos, |
| 8054 | * given a key. |
| 8055 | */ |
| 8056 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo"); |
| 8057 | |
| 8058 | /** |
| 8059 | * This URI allows the caller to query for the maximum dimensions of a display photo |
| 8060 | * or thumbnail. Requests to this URI can be performed on the UI thread because |
| 8061 | * they are always unblocking. |
| 8062 | */ |
| 8063 | public static final Uri CONTENT_MAX_DIMENSIONS_URI = |
| 8064 | Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions"); |
| 8065 | |
| 8066 | /** |
| 8067 | * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will |
| 8068 | * contain this column, populated with the maximum height and width (in pixels) |
| 8069 | * that will be stored for a display photo. Larger photos will be down-sized to |
| 8070 | * fit within a square of this many pixels. |
| 8071 | */ |
| 8072 | public static final String DISPLAY_MAX_DIM = "display_max_dim"; |
| 8073 | |
| 8074 | /** |
| 8075 | * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will |
| 8076 | * contain this column, populated with the height and width (in pixels) for photo |
| 8077 | * thumbnails. |
| 8078 | */ |
| 8079 | public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim"; |
| 8080 | } |
| 8081 | |
| 8082 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8083 | * Contains helper classes used to create or manage {@link android.content.Intent Intents} |
| 8084 | * that involve contacts. |
| 8085 | */ |
| 8086 | public static final class Intents { |
| 8087 | /** |
| 8088 | * This is the intent that is fired when a search suggestion is clicked on. |
| 8089 | */ |
| 8090 | public static final String SEARCH_SUGGESTION_CLICKED = |
| 8091 | "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; |
| 8092 | |
| 8093 | /** |
| 8094 | * This is the intent that is fired when a search suggestion for dialing a number |
| 8095 | * is clicked on. |
| 8096 | */ |
| 8097 | public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = |
| 8098 | "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; |
| 8099 | |
| 8100 | /** |
| 8101 | * This is the intent that is fired when a search suggestion for creating a contact |
| 8102 | * is clicked on. |
| 8103 | */ |
| 8104 | public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = |
| 8105 | "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; |
| 8106 | |
| 8107 | /** |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 8108 | * This is the intent that is fired when the contacts database is created. <p> The |
| 8109 | * READ_CONTACT permission is required to receive these broadcasts. |
| 8110 | */ |
| 8111 | public static final String CONTACTS_DATABASE_CREATED = |
| 8112 | "android.provider.Contacts.DATABASE_CREATED"; |
| 8113 | |
| 8114 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8115 | * Starts an Activity that lets the user pick a contact to attach an image to. |
| 8116 | * After picking the contact it launches the image cropper in face detection mode. |
| 8117 | */ |
| 8118 | public static final String ATTACH_IMAGE = |
| 8119 | "com.android.contacts.action.ATTACH_IMAGE"; |
| 8120 | |
| 8121 | /** |
Makoto Onuki | 85a01a6b | 2011-07-21 15:16:31 -0700 | [diff] [blame] | 8122 | * This is the intent that is fired when the user clicks the "invite to the network" button |
| 8123 | * on a contact. Only sent to an activity which is explicitly registered by a contact |
| 8124 | * provider which supports the "invite to the network" feature. |
| 8125 | * <p> |
| 8126 | * {@link Intent#getData()} contains the lookup URI for the contact. |
| 8127 | */ |
| 8128 | public static final String INVITE_CONTACT = |
| 8129 | "com.android.contacts.action.INVITE_CONTACT"; |
| 8130 | |
| 8131 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8132 | * Takes as input a data URI with a mailto: or tel: scheme. If a single |
| 8133 | * contact exists with the given data it will be shown. If no contact |
| 8134 | * exists, a dialog will ask the user if they want to create a new |
| 8135 | * contact with the provided details filled in. If multiple contacts |
| 8136 | * share the data the user will be prompted to pick which contact they |
| 8137 | * want to view. |
| 8138 | * <p> |
| 8139 | * For <code>mailto:</code> URIs, the scheme specific portion must be a |
| 8140 | * raw email address, such as one built using |
| 8141 | * {@link Uri#fromParts(String, String, String)}. |
| 8142 | * <p> |
| 8143 | * For <code>tel:</code> URIs, the scheme specific portion is compared |
| 8144 | * to existing numbers using the standard caller ID lookup algorithm. |
| 8145 | * The number must be properly encoded, for example using |
| 8146 | * {@link Uri#fromParts(String, String, String)}. |
| 8147 | * <p> |
| 8148 | * Any extras from the {@link Insert} class will be passed along to the |
| 8149 | * create activity if there are no contacts to show. |
| 8150 | * <p> |
| 8151 | * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip |
| 8152 | * prompting the user when the contact doesn't exist. |
| 8153 | */ |
| 8154 | public static final String SHOW_OR_CREATE_CONTACT = |
| 8155 | "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; |
| 8156 | |
| 8157 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8158 | * Starts an Activity that lets the user select the multiple phones from a |
| 8159 | * list of phone numbers which come from the contacts or |
| 8160 | * {@link #EXTRA_PHONE_URIS}. |
| 8161 | * <p> |
| 8162 | * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS} |
| 8163 | * could belong to the contacts or not, and will be selected by default. |
| 8164 | * <p> |
| 8165 | * The user's selection will be returned from |
| 8166 | * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)} |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 8167 | * if the resultCode is |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8168 | * {@link android.app.Activity#RESULT_OK}, the array of picked phone |
| 8169 | * numbers are in the Intent's |
| 8170 | * {@link #EXTRA_PHONE_URIS}; otherwise, the |
| 8171 | * {@link android.app.Activity#RESULT_CANCELED} is returned if the user |
| 8172 | * left the Activity without changing the selection. |
| 8173 | * |
| 8174 | * @hide |
| 8175 | */ |
| 8176 | public static final String ACTION_GET_MULTIPLE_PHONES = |
| 8177 | "com.android.contacts.action.GET_MULTIPLE_PHONES"; |
| 8178 | |
| 8179 | /** |
Makoto Onuki | 90ddc90 | 2012-09-11 18:22:53 -0700 | [diff] [blame] | 8180 | * A broadcast action which is sent when any change has been made to the profile, such |
| 8181 | * as the profile name or the picture. A receiver must have |
| 8182 | * the android.permission.READ_PROFILE permission. |
| 8183 | * |
| 8184 | * @hide |
| 8185 | */ |
| 8186 | public static final String ACTION_PROFILE_CHANGED = |
| 8187 | "android.provider.Contacts.PROFILE_CHANGED"; |
| 8188 | |
| 8189 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8190 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new |
| 8191 | * contact if no matching contact found. Otherwise, default behavior is |
| 8192 | * to prompt user with dialog before creating. |
| 8193 | * <p> |
| 8194 | * Type: BOOLEAN |
| 8195 | */ |
| 8196 | public static final String EXTRA_FORCE_CREATE = |
| 8197 | "com.android.contacts.action.FORCE_CREATE"; |
| 8198 | |
| 8199 | /** |
| 8200 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact |
| 8201 | * description to be shown when prompting user about creating a new |
| 8202 | * contact. |
| 8203 | * <p> |
| 8204 | * Type: STRING |
| 8205 | */ |
| 8206 | public static final String EXTRA_CREATE_DESCRIPTION = |
| 8207 | "com.android.contacts.action.CREATE_DESCRIPTION"; |
| 8208 | |
| 8209 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8210 | * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value. |
| 8211 | * <p> |
| 8212 | * The phone numbers want to be picked by default should be passed in as |
| 8213 | * input value. These phone numbers could belong to the contacts or not. |
| 8214 | * <p> |
| 8215 | * The phone numbers which were picked by the user are returned as output |
| 8216 | * value. |
| 8217 | * <p> |
| 8218 | * Type: array of URIs, the tel URI is used for the phone numbers which don't |
| 8219 | * 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] | 8220 | * |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8221 | * @hide |
| 8222 | */ |
| 8223 | public static final String EXTRA_PHONE_URIS = |
| 8224 | "com.android.contacts.extra.PHONE_URIS"; |
| 8225 | |
| 8226 | /** |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 8227 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 8228 | * dialog location using screen coordinates. When not specified, the |
| 8229 | * dialog will be centered. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8230 | * |
| 8231 | * @hide |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 8232 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8233 | @Deprecated |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 8234 | public static final String EXTRA_TARGET_RECT = "target_rect"; |
| 8235 | |
| 8236 | /** |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8237 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 8238 | * desired dialog style, usually a variation on size. One of |
| 8239 | * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8240 | * |
| 8241 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8242 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8243 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8244 | public static final String EXTRA_MODE = "mode"; |
| 8245 | |
| 8246 | /** |
| 8247 | * Value for {@link #EXTRA_MODE} to show a small-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8248 | * |
| 8249 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8250 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8251 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8252 | public static final int MODE_SMALL = 1; |
| 8253 | |
| 8254 | /** |
| 8255 | * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8256 | * |
| 8257 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8258 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8259 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8260 | public static final int MODE_MEDIUM = 2; |
| 8261 | |
| 8262 | /** |
| 8263 | * Value for {@link #EXTRA_MODE} to show a large-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8264 | * |
| 8265 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8266 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8267 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8268 | public static final int MODE_LARGE = 3; |
| 8269 | |
| 8270 | /** |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 8271 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate |
| 8272 | * a list of specific MIME-types to exclude and not display. Stored as a |
| 8273 | * {@link String} array. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8274 | * |
| 8275 | * @hide |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 8276 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8277 | @Deprecated |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 8278 | public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; |
| 8279 | |
| 8280 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8281 | * Intents related to the Contacts app UI. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8282 | * |
| 8283 | * @hide |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8284 | */ |
| 8285 | public static final class UI { |
| 8286 | /** |
| 8287 | * The action for the default contacts list tab. |
| 8288 | */ |
| 8289 | public static final String LIST_DEFAULT = |
| 8290 | "com.android.contacts.action.LIST_DEFAULT"; |
| 8291 | |
| 8292 | /** |
| 8293 | * The action for the contacts list tab. |
| 8294 | */ |
| 8295 | public static final String LIST_GROUP_ACTION = |
| 8296 | "com.android.contacts.action.LIST_GROUP"; |
| 8297 | |
| 8298 | /** |
| 8299 | * When in LIST_GROUP_ACTION mode, this is the group to display. |
| 8300 | */ |
| 8301 | public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP"; |
| 8302 | |
| 8303 | /** |
| 8304 | * The action for the all contacts list tab. |
| 8305 | */ |
| 8306 | public static final String LIST_ALL_CONTACTS_ACTION = |
| 8307 | "com.android.contacts.action.LIST_ALL_CONTACTS"; |
| 8308 | |
| 8309 | /** |
| 8310 | * The action for the contacts with phone numbers list tab. |
| 8311 | */ |
| 8312 | public static final String LIST_CONTACTS_WITH_PHONES_ACTION = |
| 8313 | "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES"; |
| 8314 | |
| 8315 | /** |
| 8316 | * The action for the starred contacts list tab. |
| 8317 | */ |
| 8318 | public static final String LIST_STARRED_ACTION = |
| 8319 | "com.android.contacts.action.LIST_STARRED"; |
| 8320 | |
| 8321 | /** |
| 8322 | * The action for the frequent contacts list tab. |
| 8323 | */ |
| 8324 | public static final String LIST_FREQUENT_ACTION = |
| 8325 | "com.android.contacts.action.LIST_FREQUENT"; |
| 8326 | |
| 8327 | /** |
| 8328 | * The action for the "strequent" contacts list tab. It first lists the starred |
| 8329 | * contacts in alphabetical order and then the frequent contacts in descending |
| 8330 | * order of the number of times they have been contacted. |
| 8331 | */ |
| 8332 | public static final String LIST_STREQUENT_ACTION = |
| 8333 | "com.android.contacts.action.LIST_STREQUENT"; |
| 8334 | |
| 8335 | /** |
| 8336 | * A key for to be used as an intent extra to set the activity |
| 8337 | * title to a custom String value. |
| 8338 | */ |
| 8339 | public static final String TITLE_EXTRA_KEY = |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8340 | "com.android.contacts.extra.TITLE_EXTRA"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8341 | |
| 8342 | /** |
| 8343 | * Activity Action: Display a filtered list of contacts |
| 8344 | * <p> |
| 8345 | * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for |
| 8346 | * filtering |
| 8347 | * <p> |
| 8348 | * Output: Nothing. |
| 8349 | */ |
| 8350 | public static final String FILTER_CONTACTS_ACTION = |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8351 | "com.android.contacts.action.FILTER_CONTACTS"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8352 | |
| 8353 | /** |
| 8354 | * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION} |
| 8355 | * intents to supply the text on which to filter. |
| 8356 | */ |
| 8357 | public static final String FILTER_TEXT_EXTRA_KEY = |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8358 | "com.android.contacts.extra.FILTER_TEXT"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8359 | } |
| 8360 | |
| 8361 | /** |
| 8362 | * Convenience class that contains string constants used |
| 8363 | * to create contact {@link android.content.Intent Intents}. |
| 8364 | */ |
| 8365 | public static final class Insert { |
| 8366 | /** The action code to use when adding a contact */ |
| 8367 | public static final String ACTION = Intent.ACTION_INSERT; |
| 8368 | |
| 8369 | /** |
| 8370 | * If present, forces a bypass of quick insert mode. |
| 8371 | */ |
| 8372 | public static final String FULL_MODE = "full_mode"; |
| 8373 | |
| 8374 | /** |
| 8375 | * The extra field for the contact name. |
| 8376 | * <P>Type: String</P> |
| 8377 | */ |
| 8378 | public static final String NAME = "name"; |
| 8379 | |
| 8380 | // TODO add structured name values here. |
| 8381 | |
| 8382 | /** |
| 8383 | * The extra field for the contact phonetic name. |
| 8384 | * <P>Type: String</P> |
| 8385 | */ |
| 8386 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 8387 | |
| 8388 | /** |
| 8389 | * The extra field for the contact company. |
| 8390 | * <P>Type: String</P> |
| 8391 | */ |
| 8392 | public static final String COMPANY = "company"; |
| 8393 | |
| 8394 | /** |
| 8395 | * The extra field for the contact job title. |
| 8396 | * <P>Type: String</P> |
| 8397 | */ |
| 8398 | public static final String JOB_TITLE = "job_title"; |
| 8399 | |
| 8400 | /** |
| 8401 | * The extra field for the contact notes. |
| 8402 | * <P>Type: String</P> |
| 8403 | */ |
| 8404 | public static final String NOTES = "notes"; |
| 8405 | |
| 8406 | /** |
| 8407 | * The extra field for the contact phone number. |
| 8408 | * <P>Type: String</P> |
| 8409 | */ |
| 8410 | public static final String PHONE = "phone"; |
| 8411 | |
| 8412 | /** |
| 8413 | * The extra field for the contact phone number type. |
| 8414 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8415 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8416 | * or a string specifying a custom label.</P> |
| 8417 | */ |
| 8418 | public static final String PHONE_TYPE = "phone_type"; |
| 8419 | |
| 8420 | /** |
| 8421 | * The extra field for the phone isprimary flag. |
| 8422 | * <P>Type: boolean</P> |
| 8423 | */ |
| 8424 | public static final String PHONE_ISPRIMARY = "phone_isprimary"; |
| 8425 | |
| 8426 | /** |
| 8427 | * The extra field for an optional second contact phone number. |
| 8428 | * <P>Type: String</P> |
| 8429 | */ |
| 8430 | public static final String SECONDARY_PHONE = "secondary_phone"; |
| 8431 | |
| 8432 | /** |
| 8433 | * The extra field for an optional second contact phone number type. |
| 8434 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8435 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8436 | * or a string specifying a custom label.</P> |
| 8437 | */ |
| 8438 | public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; |
| 8439 | |
| 8440 | /** |
| 8441 | * The extra field for an optional third contact phone number. |
| 8442 | * <P>Type: String</P> |
| 8443 | */ |
| 8444 | public static final String TERTIARY_PHONE = "tertiary_phone"; |
| 8445 | |
| 8446 | /** |
| 8447 | * The extra field for an optional third contact phone number type. |
| 8448 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8449 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8450 | * or a string specifying a custom label.</P> |
| 8451 | */ |
| 8452 | public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; |
| 8453 | |
| 8454 | /** |
| 8455 | * The extra field for the contact email address. |
| 8456 | * <P>Type: String</P> |
| 8457 | */ |
| 8458 | public static final String EMAIL = "email"; |
| 8459 | |
| 8460 | /** |
| 8461 | * The extra field for the contact email type. |
| 8462 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8463 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8464 | * or a string specifying a custom label.</P> |
| 8465 | */ |
| 8466 | public static final String EMAIL_TYPE = "email_type"; |
| 8467 | |
| 8468 | /** |
| 8469 | * The extra field for the email isprimary flag. |
| 8470 | * <P>Type: boolean</P> |
| 8471 | */ |
| 8472 | public static final String EMAIL_ISPRIMARY = "email_isprimary"; |
| 8473 | |
| 8474 | /** |
| 8475 | * The extra field for an optional second contact email address. |
| 8476 | * <P>Type: String</P> |
| 8477 | */ |
| 8478 | public static final String SECONDARY_EMAIL = "secondary_email"; |
| 8479 | |
| 8480 | /** |
| 8481 | * The extra field for an optional second contact email type. |
| 8482 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8483 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8484 | * or a string specifying a custom label.</P> |
| 8485 | */ |
| 8486 | public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; |
| 8487 | |
| 8488 | /** |
| 8489 | * The extra field for an optional third contact email address. |
| 8490 | * <P>Type: String</P> |
| 8491 | */ |
| 8492 | public static final String TERTIARY_EMAIL = "tertiary_email"; |
| 8493 | |
| 8494 | /** |
| 8495 | * The extra field for an optional third contact email type. |
| 8496 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8497 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8498 | * or a string specifying a custom label.</P> |
| 8499 | */ |
| 8500 | public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; |
| 8501 | |
| 8502 | /** |
| 8503 | * The extra field for the contact postal address. |
| 8504 | * <P>Type: String</P> |
| 8505 | */ |
| 8506 | public static final String POSTAL = "postal"; |
| 8507 | |
| 8508 | /** |
| 8509 | * The extra field for the contact postal address type. |
| 8510 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8511 | * {@link CommonDataKinds.StructuredPostal} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8512 | * or a string specifying a custom label.</P> |
| 8513 | */ |
| 8514 | public static final String POSTAL_TYPE = "postal_type"; |
| 8515 | |
| 8516 | /** |
| 8517 | * The extra field for the postal isprimary flag. |
| 8518 | * <P>Type: boolean</P> |
| 8519 | */ |
| 8520 | public static final String POSTAL_ISPRIMARY = "postal_isprimary"; |
| 8521 | |
| 8522 | /** |
| 8523 | * The extra field for an IM handle. |
| 8524 | * <P>Type: String</P> |
| 8525 | */ |
| 8526 | public static final String IM_HANDLE = "im_handle"; |
| 8527 | |
| 8528 | /** |
| 8529 | * The extra field for the IM protocol |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8530 | */ |
| 8531 | public static final String IM_PROTOCOL = "im_protocol"; |
| 8532 | |
| 8533 | /** |
| 8534 | * The extra field for the IM isprimary flag. |
| 8535 | * <P>Type: boolean</P> |
| 8536 | */ |
| 8537 | public static final String IM_ISPRIMARY = "im_isprimary"; |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 8538 | |
| 8539 | /** |
| 8540 | * The extra field that allows the client to supply multiple rows of |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 8541 | * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT} |
| 8542 | * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of |
| 8543 | * {@link ContentValues}, one per data row. Supplying this extra is |
| 8544 | * similar to inserting multiple rows into the {@link Data} table, |
| 8545 | * except the user gets a chance to see and edit them before saving. |
| 8546 | * Each ContentValues object must have a value for {@link Data#MIMETYPE}. |
| 8547 | * If supplied values are not visible in the editor UI, they will be |
| 8548 | * dropped. Duplicate data will dropped. Some fields |
| 8549 | * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically |
| 8550 | * adjusted to comply with the constraints of the specific account type. |
| 8551 | * For example, an Exchange contact can only have one phone numbers of type Home, |
| 8552 | * so the contact editor may choose a different type for this phone number to |
| 8553 | * avoid dropping the valueable part of the row, which is the phone number. |
| 8554 | * <p> |
| 8555 | * Example: |
| 8556 | * <pre> |
| 8557 | * ArrayList<ContentValues> data = new ArrayList<ContentValues>(); |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 8558 | * |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 8559 | * ContentValues row1 = new ContentValues(); |
| 8560 | * row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE); |
| 8561 | * row1.put(Organization.COMPANY, "Android"); |
| 8562 | * data.add(row1); |
| 8563 | * |
| 8564 | * ContentValues row2 = new ContentValues(); |
| 8565 | * row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE); |
| 8566 | * row2.put(Email.TYPE, Email.TYPE_CUSTOM); |
| 8567 | * row2.put(Email.LABEL, "Green Bot"); |
| 8568 | * row2.put(Email.ADDRESS, "android@android.com"); |
| 8569 | * data.add(row2); |
| 8570 | * |
| 8571 | * Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); |
| 8572 | * intent.putParcelableArrayListExtra(Insert.DATA, data); |
| 8573 | * |
| 8574 | * startActivity(intent); |
| 8575 | * </pre> |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 8576 | */ |
| 8577 | public static final String DATA = "data"; |
Daniel Lehmann | cde1ac6 | 2010-10-21 20:40:11 -0700 | [diff] [blame] | 8578 | |
| 8579 | /** |
| 8580 | * Used to specify the account in which to create the new contact. |
| 8581 | * <p> |
| 8582 | * If this value is not provided, the user is presented with a disambiguation |
| 8583 | * dialog to chose an account |
| 8584 | * <p> |
| 8585 | * Type: {@link Account} |
| 8586 | * |
| 8587 | * @hide |
| 8588 | */ |
| 8589 | public static final String ACCOUNT = "com.android.contacts.extra.ACCOUNT"; |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 8590 | |
| 8591 | /** |
| 8592 | * Used to specify the data set within the account in which to create the |
| 8593 | * new contact. |
| 8594 | * <p> |
| 8595 | * This value is optional - if it is not specified, the contact will be |
| 8596 | * created in the base account, with no data set. |
| 8597 | * <p> |
| 8598 | * Type: String |
| 8599 | * |
| 8600 | * @hide |
| 8601 | */ |
| 8602 | public static final String DATA_SET = "com.android.contacts.extra.DATA_SET"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8603 | } |
| 8604 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 8605 | } |