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; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 20 | import android.content.ContentProviderClient; |
| 21 | import android.content.ContentProviderOperation; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 22 | import android.content.ContentResolver; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 23 | import android.content.ContentUris; |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 24 | import android.content.ContentValues; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 25 | import android.content.Context; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 26 | import android.content.CursorEntityIterator; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 27 | import android.content.Entity; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 28 | import android.content.EntityIterator; |
| 29 | import android.content.Intent; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 30 | import android.content.res.Resources; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 31 | import android.database.Cursor; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 32 | import android.database.DatabaseUtils; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 33 | import android.graphics.Rect; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 34 | import android.net.Uri; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 35 | import android.os.RemoteException; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 36 | import android.text.TextUtils; |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 37 | import android.util.DisplayMetrics; |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 38 | import android.util.Pair; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 39 | import android.view.View; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 40 | |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 41 | import java.io.ByteArrayInputStream; |
| 42 | import java.io.InputStream; |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 43 | import java.util.ArrayList; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 44 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 45 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 46 | * <p> |
| 47 | * The contract between the contacts provider and applications. Contains |
| 48 | * definitions for the supported URIs and columns. These APIs supersede |
| 49 | * {@link Contacts}. |
| 50 | * </p> |
| 51 | * <h3>Overview</h3> |
| 52 | * <p> |
| 53 | * ContactsContract defines an extensible database of contact-related |
| 54 | * information. Contact information is stored in a three-tier data model: |
| 55 | * </p> |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 56 | * <ul> |
| 57 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 58 | * A row in the {@link Data} table can store any kind of personal data, such |
| 59 | * as a phone number or email addresses. The set of data kinds that can be |
| 60 | * stored in this table is open-ended. There is a predefined set of common |
| 61 | * kinds, but any application can add its own data kinds. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 62 | * </li> |
| 63 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 64 | * A row in the {@link RawContacts} table represents a set of data describing a |
| 65 | * person and associated with a single account (for example, one of the user's |
| 66 | * Gmail accounts). |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 67 | * </li> |
| 68 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 69 | * 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] | 70 | * RawContacts presumably describing the same person. When data in or associated with |
| 71 | * the RawContacts table is changed, the affected aggregate contacts are updated as |
| 72 | * necessary. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 73 | * </li> |
| 74 | * </ul> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 75 | * <p> |
| 76 | * Other tables include: |
| 77 | * </p> |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 78 | * <ul> |
| 79 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 80 | * {@link Groups}, which contains information about raw contact groups |
| 81 | * such as Gmail contact groups. The |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 82 | * current API does not support the notion of groups spanning multiple accounts. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 83 | * </li> |
| 84 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 85 | * {@link StatusUpdates}, which contains social status updates including IM |
| 86 | * availability. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 87 | * </li> |
| 88 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 89 | * {@link AggregationExceptions}, which is used for manual aggregation and |
| 90 | * disaggregation of raw contacts |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 91 | * </li> |
| 92 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 93 | * {@link Settings}, which contains visibility and sync settings for accounts |
| 94 | * and groups. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 95 | * </li> |
| 96 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 97 | * {@link SyncState}, which contains free-form data maintained on behalf of sync |
| 98 | * adapters |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 99 | * </li> |
| 100 | * <li> |
| 101 | * {@link PhoneLookup}, which is used for quick caller-ID lookup</li> |
| 102 | * </ul> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 103 | */ |
Jeff Hamilton | 0c23212 | 2009-09-24 00:26:50 -0500 | [diff] [blame] | 104 | @SuppressWarnings("unused") |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 105 | public final class ContactsContract { |
| 106 | /** The authority for the contacts provider */ |
| 107 | public static final String AUTHORITY = "com.android.contacts"; |
| 108 | /** A content:// style uri to the authority for the contacts provider */ |
| 109 | public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); |
| 110 | |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 111 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 112 | * An optional URI parameter for insert, update, or delete queries |
| 113 | * that allows the caller |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 114 | * 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] | 115 | * {@link RawContacts#DIRTY} is not automatically set and the |
| 116 | * "syncToNetwork" parameter is set to false when calling |
| 117 | * {@link |
| 118 | * ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}. |
| 119 | * This prevents an unnecessary extra synchronization, see the discussion of |
| 120 | * the delete operation in {@link RawContacts}. |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 121 | */ |
| 122 | public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter"; |
| 123 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 124 | /** |
Evan Millar | 49da15f | 2009-09-29 12:02:56 -0700 | [diff] [blame] | 125 | * A query parameter key used to specify the package that is requesting a query. |
| 126 | * This is used for restricting data based on package name. |
| 127 | * |
| 128 | * @hide |
| 129 | */ |
| 130 | public static final String REQUESTING_PACKAGE_PARAM_KEY = "requesting_package"; |
| 131 | |
| 132 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 133 | * Query parameter that should be used by the client to access a specific |
| 134 | * {@link Directory}. The parameter value should be the _ID of the corresponding |
| 135 | * directory, e.g. |
| 136 | * {@code content://com.android.contacts/data/emails/filter/acme?directory=3} |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 137 | */ |
| 138 | public static final String DIRECTORY_PARAM_KEY = "directory"; |
| 139 | |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 140 | /** |
Dmitri Plotnikov | 5a998dd | 2010-08-31 17:32:16 -0700 | [diff] [blame] | 141 | * A query parameter that limits the number of results returned. The |
| 142 | * parameter value should be an integer. |
| 143 | */ |
| 144 | public static final String LIMIT_PARAM_KEY = "limit"; |
| 145 | |
| 146 | /** |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 147 | * A query parameter specifing a primary account. This parameter should be used with |
| 148 | * {@link #PRIMARY_ACCOUNT_TYPE}. The contacts provider handling a query may rely on |
| 149 | * this information to optimize its query results. |
| 150 | * |
| 151 | * For example, in an email composition screen, its implementation can specify an account when |
| 152 | * obtaining possible recipients, letting the provider know which account is selected during |
| 153 | * the composition. The provider may use the "primary account" information to optimize |
| 154 | * the search result. |
| 155 | * @hide |
| 156 | */ |
| 157 | public static final String PRIMARY_ACCOUNT_NAME = "name_for_primary_account"; |
| 158 | |
| 159 | /** |
| 160 | * A query parameter specifing a primary account. This parameter should be used with |
| 161 | * {@link #PRIMARY_ACCOUNT_NAME}. See the doc in {@link #PRIMARY_ACCOUNT_NAME}. |
| 162 | * @hide |
| 163 | */ |
| 164 | public static final String PRIMARY_ACCOUNT_TYPE = "type_for_primary_account"; |
| 165 | |
| 166 | |
| 167 | /** |
Dmitri Plotnikov | 2a650dd | 2010-01-26 17:28:52 -0800 | [diff] [blame] | 168 | * @hide |
| 169 | */ |
| 170 | public static final class Preferences { |
| 171 | |
| 172 | /** |
| 173 | * A key in the {@link android.provider.Settings android.provider.Settings} provider |
| 174 | * that stores the preferred sorting order for contacts (by given name vs. by family name). |
| 175 | * |
| 176 | * @hide |
| 177 | */ |
| 178 | public static final String SORT_ORDER = "android.contacts.SORT_ORDER"; |
| 179 | |
| 180 | /** |
| 181 | * The value for the SORT_ORDER key corresponding to sorting by given name first. |
| 182 | * |
| 183 | * @hide |
| 184 | */ |
| 185 | public static final int SORT_ORDER_PRIMARY = 1; |
| 186 | |
| 187 | /** |
| 188 | * The value for the SORT_ORDER key corresponding to sorting by family name first. |
| 189 | * |
| 190 | * @hide |
| 191 | */ |
| 192 | public static final int SORT_ORDER_ALTERNATIVE = 2; |
| 193 | |
| 194 | /** |
| 195 | * A key in the {@link android.provider.Settings android.provider.Settings} provider |
| 196 | * that stores the preferred display order for contacts (given name first vs. family |
| 197 | * name first). |
| 198 | * |
| 199 | * @hide |
| 200 | */ |
| 201 | public static final String DISPLAY_ORDER = "android.contacts.DISPLAY_ORDER"; |
| 202 | |
| 203 | /** |
| 204 | * The value for the DISPLAY_ORDER key corresponding to showing the given name first. |
| 205 | * |
| 206 | * @hide |
| 207 | */ |
| 208 | public static final int DISPLAY_ORDER_PRIMARY = 1; |
| 209 | |
| 210 | /** |
| 211 | * The value for the DISPLAY_ORDER key corresponding to showing the family name first. |
| 212 | * |
| 213 | * @hide |
| 214 | */ |
| 215 | public static final int DISPLAY_ORDER_ALTERNATIVE = 2; |
| 216 | } |
| 217 | |
| 218 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 219 | * A Directory represents a contacts corpus, e.g. Local contacts, |
| 220 | * Google Apps Global Address List or Corporate Global Address List. |
| 221 | * <p> |
| 222 | * A Directory is implemented as a content provider with its unique authority and |
| 223 | * the same API as the main Contacts Provider. However, there is no expectation that |
| 224 | * every directory provider will implement this Contract in its entirety. If a |
| 225 | * directory provider does not have an implementation for a specific request, it |
| 226 | * should throw an UnsupportedOperationException. |
| 227 | * </p> |
| 228 | * <p> |
| 229 | * 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] | 230 | * expected to support at least {@link ContactsContract.Contacts#CONTENT_FILTER_URI |
| 231 | * Contacts.CONTENT_FILTER_URI}. If a Directory provider wants to participate |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 232 | * in email and phone lookup functionalities, it should also implement |
| 233 | * {@link CommonDataKinds.Email#CONTENT_FILTER_URI CommonDataKinds.Email.CONTENT_FILTER_URI} |
| 234 | * and |
| 235 | * {@link CommonDataKinds.Phone#CONTENT_FILTER_URI CommonDataKinds.Phone.CONTENT_FILTER_URI}. |
| 236 | * </p> |
| 237 | * <p> |
| 238 | * A directory provider should return NULL for every projection field it does not |
| 239 | * recognize, rather than throwing an exception. This way it will not be broken |
| 240 | * if ContactsContract is extended with new fields in the future. |
| 241 | * </p> |
| 242 | * <p> |
| 243 | * The client interacts with a directory via Contacts Provider by supplying an |
| 244 | * optional {@code directory=} query parameter. |
| 245 | * <p> |
| 246 | * <p> |
| 247 | * When the Contacts Provider receives the request, it transforms the URI and forwards |
| 248 | * the request to the corresponding directory content provider. |
| 249 | * The URI is transformed in the following fashion: |
| 250 | * <ul> |
| 251 | * <li>The URI authority is replaced with the corresponding {@link #DIRECTORY_AUTHORITY}.</li> |
| 252 | * <li>The {@code accountName=} and {@code accountType=} parameters are added or |
| 253 | * replaced using the corresponding {@link #ACCOUNT_TYPE} and {@link #ACCOUNT_NAME} values.</li> |
Dmitri Plotnikov | 13e0357 | 2010-08-19 16:31:29 -0700 | [diff] [blame] | 254 | * <li>If the URI is missing a ContactsContract.REQUESTING_PACKAGE_PARAM_KEY |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 255 | * parameter, this parameter is added.</li> |
| 256 | * </ul> |
| 257 | * </p> |
| 258 | * <p> |
| 259 | * Clients should send directory requests to Contacts Provider and let it |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 260 | * forward them to the respective providers rather than constructing |
| 261 | * directory provider URIs by themselves. This level of indirection allows |
| 262 | * Contacts Provider to implement additional system-level features and |
| 263 | * optimizations. Access to Contacts Provider is protected by the |
| 264 | * READ_CONTACTS permission, but access to the directory provider is not. |
| 265 | * Therefore directory providers must reject requests coming from clients |
| 266 | * other than the Contacts Provider itself. An easy way to prevent such |
| 267 | * unauthorized access is to check the name of the calling package: |
| 268 | * <pre> |
| 269 | * private boolean isCallerAllowed() { |
| 270 | * PackageManager pm = getContext().getPackageManager(); |
| 271 | * for (String packageName: pm.getPackagesForUid(Binder.getCallingUid())) { |
| 272 | * if (packageName.equals("com.android.providers.contacts")) { |
| 273 | * return true; |
| 274 | * } |
| 275 | * } |
| 276 | * return false; |
| 277 | * } |
| 278 | * </pre> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 279 | * </p> |
| 280 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 281 | * The Directory table is read-only and is maintained by the Contacts Provider |
| 282 | * automatically. |
| 283 | * </p> |
| 284 | * <p>It always has at least these two rows: |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 285 | * <ul> |
| 286 | * <li> |
| 287 | * The local directory. It has {@link Directory#_ID Directory._ID} = |
| 288 | * {@link Directory#DEFAULT Directory.DEFAULT}. This directory can be used to access locally |
| 289 | * stored contacts. The same can be achieved by omitting the {@code directory=} |
| 290 | * parameter altogether. |
| 291 | * </li> |
| 292 | * <li> |
| 293 | * The local invisible contacts. The corresponding directory ID is |
| 294 | * {@link Directory#LOCAL_INVISIBLE Directory.LOCAL_INVISIBLE}. |
| 295 | * </li> |
| 296 | * </ul> |
| 297 | * </p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 298 | * <p>Custom Directories are discovered by the Contacts Provider following this procedure: |
| 299 | * <ul> |
| 300 | * <li>It finds all installed content providers with meta data identifying them |
| 301 | * as directory providers in AndroidManifest.xml: |
| 302 | * <code> |
| 303 | * <meta-data android:name="android.content.ContactDirectory" |
| 304 | * android:value="true" /> |
| 305 | * </code> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 306 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 307 | * This tag should be placed inside the corresponding content provider declaration. |
| 308 | * </p> |
| 309 | * </li> |
| 310 | * <li> |
| 311 | * Then Contacts Provider sends a {@link Directory#CONTENT_URI Directory.CONTENT_URI} |
| 312 | * query to each of the directory authorities. A directory provider must implement |
| 313 | * this query and return a list of directories. Each directory returned by |
| 314 | * the provider must have a unique combination for the {@link #ACCOUNT_NAME} and |
| 315 | * {@link #ACCOUNT_TYPE} columns (nulls are allowed). Since directory IDs are assigned |
| 316 | * automatically, the _ID field will not be part of the query projection. |
| 317 | * </li> |
| 318 | * <li>Contacts Provider compiles directory lists received from all directory |
| 319 | * providers into one, assigns each individual directory a globally unique ID and |
| 320 | * stores all directory records in the Directory table. |
| 321 | * </li> |
| 322 | * </ul> |
| 323 | * </p> |
| 324 | * <p>Contacts Provider automatically interrogates newly installed or replaced packages. |
| 325 | * Thus simply installing a package containing a directory provider is sufficient |
| 326 | * to have that provider registered. A package supplying a directory provider does |
| 327 | * not have to contain launchable activities. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 328 | * </p> |
| 329 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 330 | * Every row in the Directory table is automatically associated with the corresponding package |
| 331 | * (apk). If the package is later uninstalled, all corresponding directory rows |
| 332 | * are automatically removed from the Contacts Provider. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 333 | * </p> |
| 334 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 335 | * When the list of directories handled by a directory provider changes |
| 336 | * (for instance when the user adds a new Directory account), the directory provider |
| 337 | * should call {@link #notifyDirectoryChange} to notify the Contacts Provider of the change. |
| 338 | * In response, the Contacts Provider will requery the directory provider to obtain the |
| 339 | * new list of directories. |
| 340 | * </p> |
| 341 | * <p> |
| 342 | * A directory row can be optionally associated with an existing account |
| 343 | * (see {@link android.accounts.AccountManager}). If the account is later removed, |
Dmitri Plotnikov | e50ed08 | 2010-08-18 10:56:09 -0700 | [diff] [blame] | 344 | * the corresponding directory rows are automatically removed from the Contacts Provider. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 345 | * </p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 346 | */ |
| 347 | public static final class Directory implements BaseColumns { |
| 348 | |
| 349 | /** |
| 350 | * Not instantiable. |
| 351 | */ |
| 352 | private Directory() { |
| 353 | } |
| 354 | |
| 355 | /** |
| 356 | * The content:// style URI for this table. Requests to this URI can be |
| 357 | * performed on the UI thread because they are always unblocking. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 358 | */ |
| 359 | public static final Uri CONTENT_URI = |
| 360 | Uri.withAppendedPath(AUTHORITY_URI, "directories"); |
| 361 | |
| 362 | /** |
| 363 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 364 | * contact directories. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 365 | */ |
| 366 | public static final String CONTENT_TYPE = |
| 367 | "vnd.android.cursor.dir/contact_directories"; |
| 368 | |
| 369 | /** |
| 370 | * The MIME type of a {@link #CONTENT_URI} item. |
| 371 | */ |
| 372 | public static final String CONTENT_ITEM_TYPE = |
| 373 | "vnd.android.cursor.item/contact_directory"; |
| 374 | |
| 375 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 376 | * _ID of the default directory, which represents locally stored contacts. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 377 | */ |
| 378 | public static final long DEFAULT = 0; |
| 379 | |
| 380 | /** |
| 381 | * _ID of the directory that represents locally stored invisible contacts. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 382 | */ |
| 383 | public static final long LOCAL_INVISIBLE = 1; |
| 384 | |
| 385 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 386 | * The name of the package that owns this directory. Contacts Provider |
| 387 | * fill it in with the name of the package containing the directory provider. |
| 388 | * If the package is later uninstalled, the directories it owns are |
| 389 | * automatically removed from this table. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 390 | * |
| 391 | * <p>TYPE: TEXT</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 392 | */ |
| 393 | public static final String PACKAGE_NAME = "packageName"; |
| 394 | |
| 395 | /** |
| 396 | * The type of directory captured as a resource ID in the context of the |
| 397 | * package {@link #PACKAGE_NAME}, e.g. "Corporate Directory" |
| 398 | * |
| 399 | * <p>TYPE: INTEGER</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 400 | */ |
| 401 | public static final String TYPE_RESOURCE_ID = "typeResourceId"; |
| 402 | |
| 403 | /** |
| 404 | * An optional name that can be used in the UI to represent this directory, |
| 405 | * e.g. "Acme Corp" |
| 406 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 407 | */ |
| 408 | public static final String DISPLAY_NAME = "displayName"; |
| 409 | |
| 410 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 411 | * <p> |
| 412 | * The authority of the Directory Provider. Contacts Provider will |
| 413 | * use this authority to forward requests to the directory provider. |
| 414 | * A directory provider can leave this column empty - Contacts Provider will fill it in. |
| 415 | * </p> |
| 416 | * <p> |
| 417 | * Clients of this API should not send requests directly to this authority. |
| 418 | * All directory requests must be routed through Contacts Provider. |
| 419 | * </p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 420 | * |
| 421 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 422 | */ |
| 423 | public static final String DIRECTORY_AUTHORITY = "authority"; |
| 424 | |
| 425 | /** |
| 426 | * The account type which this directory is associated. |
| 427 | * |
| 428 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 429 | */ |
| 430 | public static final String ACCOUNT_TYPE = "accountType"; |
| 431 | |
| 432 | /** |
| 433 | * The account with which this directory is associated. If the account is later |
| 434 | * removed, the directories it owns are automatically removed from this table. |
| 435 | * |
| 436 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 437 | */ |
| 438 | public static final String ACCOUNT_NAME = "accountName"; |
| 439 | |
| 440 | /** |
| 441 | * One of {@link #EXPORT_SUPPORT_NONE}, {@link #EXPORT_SUPPORT_ANY_ACCOUNT}, |
| 442 | * {@link #EXPORT_SUPPORT_SAME_ACCOUNT_ONLY}. This is the expectation the |
| 443 | * directory has for data exported from it. Clients must obey this setting. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 444 | */ |
| 445 | public static final String EXPORT_SUPPORT = "exportSupport"; |
| 446 | |
| 447 | /** |
| 448 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 449 | * does not allow any data to be copied out of it. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 450 | */ |
| 451 | public static final int EXPORT_SUPPORT_NONE = 0; |
| 452 | |
| 453 | /** |
| 454 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 455 | * allow its data copied only to the account specified by |
| 456 | * {@link #ACCOUNT_TYPE}/{@link #ACCOUNT_NAME}. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 457 | */ |
| 458 | public static final int EXPORT_SUPPORT_SAME_ACCOUNT_ONLY = 1; |
| 459 | |
| 460 | /** |
| 461 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 462 | * allow its data copied to any contacts account. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 463 | */ |
| 464 | public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2; |
| 465 | |
| 466 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 467 | * One of {@link #SHORTCUT_SUPPORT_NONE}, {@link #SHORTCUT_SUPPORT_DATA_ITEMS_ONLY}, |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 468 | * {@link #SHORTCUT_SUPPORT_FULL}. This is the expectation the directory |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 469 | * has for shortcuts created for its elements. Clients must obey this setting. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 470 | */ |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 471 | public static final String SHORTCUT_SUPPORT = "shortcutSupport"; |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 472 | |
| 473 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 474 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 475 | * does not allow any shortcuts created for its contacts. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 476 | */ |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 477 | public static final int SHORTCUT_SUPPORT_NONE = 0; |
| 478 | |
| 479 | /** |
| 480 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 481 | * allow creation of shortcuts for data items like email, phone or postal address, |
| 482 | * but not the entire contact. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 483 | */ |
| 484 | public static final int SHORTCUT_SUPPORT_DATA_ITEMS_ONLY = 1; |
| 485 | |
| 486 | /** |
| 487 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 488 | * allow creation of shortcuts for contact as well as their constituent elements. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 489 | */ |
| 490 | public static final int SHORTCUT_SUPPORT_FULL = 2; |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 491 | |
| 492 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 493 | * One of {@link #PHOTO_SUPPORT_NONE}, {@link #PHOTO_SUPPORT_THUMBNAIL_ONLY}, |
| 494 | * {@link #PHOTO_SUPPORT_FULL}. This is a feature flag indicating the extent |
| 495 | * to which the directory supports contact photos. |
| 496 | */ |
| 497 | public static final String PHOTO_SUPPORT = "photoSupport"; |
| 498 | |
| 499 | /** |
| 500 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 501 | * does not provide any photos. |
| 502 | */ |
| 503 | public static final int PHOTO_SUPPORT_NONE = 0; |
| 504 | |
| 505 | /** |
| 506 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 507 | * can only produce small size thumbnails of contact photos. |
| 508 | */ |
| 509 | public static final int PHOTO_SUPPORT_THUMBNAIL_ONLY = 1; |
| 510 | |
| 511 | /** |
| 512 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 513 | * has full-size contact photos, but cannot provide scaled thumbnails. |
| 514 | */ |
| 515 | public static final int PHOTO_SUPPORT_FULL_SIZE_ONLY = 2; |
| 516 | |
| 517 | /** |
| 518 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 519 | * can produce thumbnails as well as full-size contact photos. |
| 520 | */ |
| 521 | public static final int PHOTO_SUPPORT_FULL = 3; |
| 522 | |
| 523 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 524 | * Notifies the system of a change in the list of directories handled by |
| 525 | * a particular directory provider. The Contacts provider will turn around |
| 526 | * and send a query to the directory provider for the full list of directories, |
| 527 | * which will replace the previous list. |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 528 | */ |
| 529 | public static void notifyDirectoryChange(ContentResolver resolver) { |
| 530 | // This is done to trigger a query by Contacts Provider back to the directory provider. |
| 531 | // No data needs to be sent back, because the provider can infer the calling |
| 532 | // package from binder. |
| 533 | ContentValues contentValues = new ContentValues(); |
| 534 | resolver.update(Directory.CONTENT_URI, contentValues, null, null); |
| 535 | } |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 539 | * @hide should be removed when users are updated to refer to SyncState |
| 540 | * @deprecated use SyncState instead |
| 541 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 542 | @Deprecated |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 543 | public interface SyncStateColumns extends SyncStateContract.Columns { |
| 544 | } |
| 545 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 546 | /** |
| 547 | * A table provided for sync adapters to use for storing private sync state data. |
| 548 | * |
| 549 | * @see SyncStateContract |
| 550 | */ |
| 551 | public static final class SyncState implements SyncStateContract.Columns { |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 552 | /** |
| 553 | * This utility class cannot be instantiated |
| 554 | */ |
| 555 | private SyncState() {} |
| 556 | |
| 557 | public static final String CONTENT_DIRECTORY = |
| 558 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 559 | |
| 560 | /** |
| 561 | * The content:// style URI for this table |
| 562 | */ |
| 563 | public static final Uri CONTENT_URI = |
| 564 | Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY); |
| 565 | |
| 566 | /** |
| 567 | * @see android.provider.SyncStateContract.Helpers#get |
| 568 | */ |
| 569 | public static byte[] get(ContentProviderClient provider, Account account) |
| 570 | throws RemoteException { |
| 571 | return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| 572 | } |
| 573 | |
| 574 | /** |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 575 | * @see android.provider.SyncStateContract.Helpers#get |
| 576 | */ |
| 577 | public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) |
| 578 | throws RemoteException { |
| 579 | return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); |
| 580 | } |
| 581 | |
| 582 | /** |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 583 | * @see android.provider.SyncStateContract.Helpers#set |
| 584 | */ |
| 585 | public static void set(ContentProviderClient provider, Account account, byte[] data) |
| 586 | throws RemoteException { |
| 587 | SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| 588 | } |
| 589 | |
| 590 | /** |
| 591 | * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| 592 | */ |
| 593 | public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| 594 | return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| 595 | } |
| 596 | } |
| 597 | |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 598 | /** |
| 599 | * Generic columns for use by sync adapters. The specific functions of |
| 600 | * these columns are private to the sync adapter. Other clients of the API |
| 601 | * should not attempt to either read or write this column. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 602 | * |
| 603 | * @see RawContacts |
| 604 | * @see Groups |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 605 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 606 | protected interface BaseSyncColumns { |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 607 | |
| 608 | /** Generic column for use by sync adapters. */ |
| 609 | public static final String SYNC1 = "sync1"; |
| 610 | /** Generic column for use by sync adapters. */ |
| 611 | public static final String SYNC2 = "sync2"; |
| 612 | /** Generic column for use by sync adapters. */ |
| 613 | public static final String SYNC3 = "sync3"; |
| 614 | /** Generic column for use by sync adapters. */ |
| 615 | public static final String SYNC4 = "sync4"; |
| 616 | } |
| 617 | |
| 618 | /** |
| 619 | * Columns that appear when each row of a table belongs to a specific |
| 620 | * account, including sync information that an account may need. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 621 | * |
| 622 | * @see RawContacts |
| 623 | * @see Groups |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 624 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 625 | protected interface SyncColumns extends BaseSyncColumns { |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 626 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 627 | * The name of the account instance to which this row belongs, which when paired with |
| 628 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 629 | * <P>Type: TEXT</P> |
| 630 | */ |
| 631 | public static final String ACCOUNT_NAME = "account_name"; |
| 632 | |
| 633 | /** |
| 634 | * The type of account to which this row belongs, which when paired with |
| 635 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 636 | * <P>Type: TEXT</P> |
| 637 | */ |
| 638 | public static final String ACCOUNT_TYPE = "account_type"; |
| 639 | |
| 640 | /** |
| 641 | * String that uniquely identifies this row to its source account. |
| 642 | * <P>Type: TEXT</P> |
| 643 | */ |
| 644 | public static final String SOURCE_ID = "sourceid"; |
| 645 | |
| 646 | /** |
| 647 | * Version number that is updated whenever this row or its related data |
| 648 | * changes. |
| 649 | * <P>Type: INTEGER</P> |
| 650 | */ |
| 651 | public static final String VERSION = "version"; |
| 652 | |
| 653 | /** |
| 654 | * Flag indicating that {@link #VERSION} has changed, and this row needs |
| 655 | * to be synchronized by its owning account. |
| 656 | * <P>Type: INTEGER (boolean)</P> |
| 657 | */ |
| 658 | public static final String DIRTY = "dirty"; |
| 659 | } |
| 660 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 661 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 662 | * Columns of {@link ContactsContract.Contacts} that track the user's |
| 663 | * preferences for, or interactions with, the contact. |
| 664 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 665 | * @see Contacts |
| 666 | * @see RawContacts |
| 667 | * @see ContactsContract.Data |
| 668 | * @see PhoneLookup |
| 669 | * @see ContactsContract.Contacts.AggregationSuggestions |
| 670 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 671 | protected interface ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 672 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 673 | * The number of times a contact has been contacted |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 674 | * <P>Type: INTEGER</P> |
| 675 | */ |
| 676 | public static final String TIMES_CONTACTED = "times_contacted"; |
| 677 | |
| 678 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 679 | * The last time a contact was contacted. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 680 | * <P>Type: INTEGER</P> |
| 681 | */ |
| 682 | public static final String LAST_TIME_CONTACTED = "last_time_contacted"; |
| 683 | |
| 684 | /** |
| 685 | * Is the contact starred? |
| 686 | * <P>Type: INTEGER (boolean)</P> |
| 687 | */ |
| 688 | public static final String STARRED = "starred"; |
| 689 | |
| 690 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 691 | * URI for a custom ringtone associated with the contact. If null or missing, |
| 692 | * the default ringtone is used. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 693 | * <P>Type: TEXT (URI to the ringtone)</P> |
| 694 | */ |
| 695 | public static final String CUSTOM_RINGTONE = "custom_ringtone"; |
| 696 | |
| 697 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 698 | * Whether the contact should always be sent to voicemail. If missing, |
| 699 | * defaults to false. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 700 | * <P>Type: INTEGER (0 for false, 1 for true)</P> |
| 701 | */ |
| 702 | public static final String SEND_TO_VOICEMAIL = "send_to_voicemail"; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 703 | } |
| 704 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 705 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 706 | * Columns of {@link ContactsContract.Contacts} that refer to intrinsic |
| 707 | * properties of the contact, as opposed to the user-specified options |
| 708 | * found in {@link ContactOptionsColumns}. |
| 709 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 710 | * @see Contacts |
| 711 | * @see ContactsContract.Data |
| 712 | * @see PhoneLookup |
| 713 | * @see ContactsContract.Contacts.AggregationSuggestions |
| 714 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 715 | protected interface ContactsColumns { |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 716 | /** |
| 717 | * The display name for the contact. |
| 718 | * <P>Type: TEXT</P> |
| 719 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 720 | public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY; |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 721 | |
| 722 | /** |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 723 | * Reference to the row in the RawContacts table holding the contact name. |
| 724 | * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P> |
| 725 | * @hide |
| 726 | */ |
| 727 | public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id"; |
| 728 | |
| 729 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 730 | * Reference to the row in the data table holding the photo. A photo can |
| 731 | * be referred to either by ID (this field) or by URI (see {@link #PHOTO_THUMBNAIL_URI} |
| 732 | * and {@link #PHOTO_URI}). |
| 733 | * If PHOTO_ID is null, consult {@link #PHOTO_URI} or {@link #PHOTO_THUMBNAIL_URI}, |
| 734 | * which is a more generic mechanism for referencing the contact photo, especially for |
| 735 | * contacts returned by non-local directories (see {@link Directory}). |
| 736 | * |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 737 | * <P>Type: INTEGER REFERENCES data(_id)</P> |
| 738 | */ |
| 739 | public static final String PHOTO_ID = "photo_id"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 740 | |
| 741 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 742 | * A URI that can be used to retrieve the contact's full-size photo. |
| 743 | * A photo can be referred to either by a URI (this field) or by ID |
| 744 | * (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and |
| 745 | * PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa). |
| 746 | * Thus using PHOTO_URI is a more robust method of retrieving contact photos. |
| 747 | * |
| 748 | * <P>Type: TEXT</P> |
| 749 | */ |
| 750 | public static final String PHOTO_URI = "photo_uri"; |
| 751 | |
| 752 | /** |
| 753 | * A URI that can be used to retrieve a thumbnail of the contact's photo. |
| 754 | * A photo can be referred to either by a URI (this field or {@link #PHOTO_URI}) |
| 755 | * or by ID (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and |
| 756 | * PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa). |
| 757 | * If the content provider does not differentiate between full-size photos |
| 758 | * and thumbnail photos, PHOTO_THUMBNAIL_URI and {@link #PHOTO_URI} can contain |
| 759 | * the same value, but either both shell be null or both not null. |
| 760 | * |
| 761 | * <P>Type: TEXT</P> |
| 762 | */ |
| 763 | public static final String PHOTO_THUMBNAIL_URI = "photo_thumb_uri"; |
| 764 | |
| 765 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 766 | * Lookup value that reflects the {@link Groups#GROUP_VISIBLE} state of |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 767 | * any {@link CommonDataKinds.GroupMembership} for this contact. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 768 | */ |
| 769 | public static final String IN_VISIBLE_GROUP = "in_visible_group"; |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 770 | |
| 771 | /** |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 772 | * An indicator of whether this contact has at least one phone number. "1" if there is |
| 773 | * at least one phone number, "0" otherwise. |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 774 | * <P>Type: INTEGER</P> |
| 775 | */ |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 776 | public static final String HAS_PHONE_NUMBER = "has_phone_number"; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 777 | |
| 778 | /** |
| 779 | * An opaque value that contains hints on how to find the contact if |
| 780 | * its row id changed as a result of a sync or aggregation. |
| 781 | */ |
| 782 | public static final String LOOKUP_KEY = "lookup"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 783 | } |
| 784 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 785 | /** |
| 786 | * @see Contacts |
| 787 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 788 | protected interface ContactStatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 789 | /** |
| 790 | * Contact presence status. See {@link StatusUpdates} for individual status |
| 791 | * definitions. |
| 792 | * <p>Type: NUMBER</p> |
| 793 | */ |
| 794 | public static final String CONTACT_PRESENCE = "contact_presence"; |
| 795 | |
| 796 | /** |
Vasu Nori | fb5bccf | 2010-07-19 14:11:54 -0700 | [diff] [blame] | 797 | * Contact Chat Capabilities. See {@link StatusUpdates} for individual |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 798 | * definitions. |
| 799 | * <p>Type: NUMBER</p> |
| 800 | */ |
| 801 | public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability"; |
| 802 | |
| 803 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 804 | * Contact's latest status update. |
| 805 | * <p>Type: TEXT</p> |
| 806 | */ |
| 807 | public static final String CONTACT_STATUS = "contact_status"; |
| 808 | |
| 809 | /** |
| 810 | * The absolute time in milliseconds when the latest status was |
| 811 | * inserted/updated. |
| 812 | * <p>Type: NUMBER</p> |
| 813 | */ |
| 814 | public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts"; |
| 815 | |
| 816 | /** |
| 817 | * The package containing resources for this status: label and icon. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 818 | * <p>Type: TEXT</p> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 819 | */ |
| 820 | public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package"; |
| 821 | |
| 822 | /** |
| 823 | * The resource ID of the label describing the source of contact |
| 824 | * status, e.g. "Google Talk". This resource is scoped by the |
| 825 | * {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 826 | * <p>Type: NUMBER</p> |
| 827 | */ |
| 828 | public static final String CONTACT_STATUS_LABEL = "contact_status_label"; |
| 829 | |
| 830 | /** |
| 831 | * The resource ID of the icon for the source of contact status. This |
| 832 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 833 | * <p>Type: NUMBER</p> |
| 834 | */ |
| 835 | public static final String CONTACT_STATUS_ICON = "contact_status_icon"; |
| 836 | } |
| 837 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 838 | /** |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 839 | * Constants for various styles of combining given name, family name etc into |
| 840 | * a full name. For example, the western tradition follows the pattern |
| 841 | * 'given name' 'middle name' 'family name' with the alternative pattern being |
| 842 | * 'family name', 'given name' 'middle name'. The CJK tradition is |
| 843 | * 'family name' 'middle name' 'given name', with Japanese favoring a space between |
| 844 | * the names and Chinese omitting the space. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 845 | */ |
| 846 | public interface FullNameStyle { |
| 847 | public static final int UNDEFINED = 0; |
| 848 | public static final int WESTERN = 1; |
| 849 | |
| 850 | /** |
| 851 | * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine |
| 852 | * which specific language it belongs to: Chinese, Japanese or Korean. |
| 853 | */ |
| 854 | public static final int CJK = 2; |
| 855 | |
| 856 | public static final int CHINESE = 3; |
| 857 | public static final int JAPANESE = 4; |
| 858 | public static final int KOREAN = 5; |
| 859 | } |
| 860 | |
| 861 | /** |
| 862 | * 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] | 863 | */ |
| 864 | public interface PhoneticNameStyle { |
| 865 | public static final int UNDEFINED = 0; |
| 866 | |
| 867 | /** |
| 868 | * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly |
| 869 | * shown in UIs, but used for searches and sorting. |
| 870 | */ |
| 871 | public static final int PINYIN = 3; |
| 872 | |
| 873 | /** |
| 874 | * Hiragana and Katakana are two common styles of writing out the pronunciation |
| 875 | * of a Japanese names. |
| 876 | */ |
| 877 | public static final int JAPANESE = 4; |
| 878 | |
| 879 | /** |
| 880 | * Hangul is the Korean phonetic alphabet. |
| 881 | */ |
| 882 | public static final int KOREAN = 5; |
| 883 | } |
| 884 | |
| 885 | /** |
Dmitri Plotnikov | dbcdbf2 | 2011-02-23 15:49:58 -0800 | [diff] [blame] | 886 | * Types of data used to produce the display name for a contact. In the order |
| 887 | * of increasing priority: {@link #EMAIL}, {@link #PHONE}, |
| 888 | * {@link #ORGANIZATION}, {@link #NICKNAME}, {@link #STRUCTURED_NAME}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 889 | */ |
| 890 | public interface DisplayNameSources { |
| 891 | public static final int UNDEFINED = 0; |
| 892 | public static final int EMAIL = 10; |
| 893 | public static final int PHONE = 20; |
| 894 | public static final int ORGANIZATION = 30; |
| 895 | public static final int NICKNAME = 35; |
| 896 | public static final int STRUCTURED_NAME = 40; |
| 897 | } |
| 898 | |
| 899 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 900 | * Contact name and contact name metadata columns in the RawContacts table. |
| 901 | * |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 902 | * @see Contacts |
| 903 | * @see RawContacts |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 904 | */ |
| 905 | protected interface ContactNameColumns { |
| 906 | |
| 907 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 908 | * 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] | 909 | * structured name or email address. See {@link DisplayNameSources}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 910 | */ |
| 911 | public static final String DISPLAY_NAME_SOURCE = "display_name_source"; |
| 912 | |
| 913 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 914 | * <p> |
| 915 | * The standard text shown as the contact's display name, based on the best |
| 916 | * available information for the contact (for example, it might be the email address |
| 917 | * if the name is not available). |
| 918 | * The information actually used to compute the name is stored in |
| 919 | * {@link #DISPLAY_NAME_SOURCE}. |
| 920 | * </p> |
| 921 | * <p> |
| 922 | * A contacts provider is free to choose whatever representation makes most |
| 923 | * sense for its target market. |
| 924 | * For example in the default Android Open Source Project implementation, |
| 925 | * if the display name is |
| 926 | * based on the structured name and the structured name follows |
| 927 | * the Western full-name style, then this field contains the "given name first" |
| 928 | * version of the full name. |
| 929 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 930 | * |
| 931 | * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 932 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 933 | public static final String DISPLAY_NAME_PRIMARY = "display_name"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 934 | |
| 935 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 936 | * <p> |
| 937 | * An alternative representation of the display name, such as "family name first" |
| 938 | * instead of "given name first" for Western names. If an alternative is not |
| 939 | * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}. |
| 940 | * </p> |
| 941 | * <p> |
| 942 | * A contacts provider is free to provide alternatives as necessary for |
| 943 | * its target market. |
| 944 | * For example the default Android Open Source Project contacts provider |
| 945 | * currently provides an |
| 946 | * alternative in a single case: if the display name is |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 947 | * based on the structured name and the structured name follows |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 948 | * the Western full name style, then the field contains the "family name first" |
| 949 | * version of the full name. |
| 950 | * Other cases may be added later. |
| 951 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 952 | */ |
| 953 | public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt"; |
| 954 | |
| 955 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 956 | * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}. See |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 957 | * {@link PhoneticNameStyle}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 958 | */ |
| 959 | public static final String PHONETIC_NAME_STYLE = "phonetic_name_style"; |
| 960 | |
| 961 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 962 | * <p> |
| 963 | * Pronunciation of the full name in the phonetic alphabet specified by |
| 964 | * {@link #PHONETIC_NAME_STYLE}. |
| 965 | * </p> |
| 966 | * <p> |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 967 | * The value may be set manually by the user. This capability is of |
| 968 | * interest only in countries with commonly used phonetic alphabets, |
| 969 | * such as Japan and Korea. See {@link PhoneticNameStyle}. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 970 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 971 | */ |
| 972 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 973 | |
| 974 | /** |
| 975 | * Sort key that takes into account locale-based traditions for sorting |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 976 | * names in address books. The default |
| 977 | * sort key is {@link #DISPLAY_NAME_PRIMARY}. For Chinese names |
| 978 | * 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] | 979 | * it is the Hiragana version of the phonetic name. |
| 980 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 981 | public static final String SORT_KEY_PRIMARY = "sort_key"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 982 | |
| 983 | /** |
| 984 | * Sort key based on the alternative representation of the full name, |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 985 | * {@link #DISPLAY_NAME_ALTERNATIVE}. Thus for Western names, |
Dmitri Plotnikov | 2a650dd | 2010-01-26 17:28:52 -0800 | [diff] [blame] | 986 | * it is the one using the "family name first" format. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 987 | */ |
| 988 | public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt"; |
| 989 | } |
| 990 | |
| 991 | /** |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 992 | * URI parameter and cursor extras that return counts of rows grouped by the |
| 993 | * address book index, which is usually the first letter of the sort key. |
| 994 | * When this parameter is supplied, the row counts are returned in the |
| 995 | * cursor extras bundle. |
| 996 | * |
| 997 | * @hide |
| 998 | */ |
| 999 | public final static class ContactCounts { |
| 1000 | |
| 1001 | /** |
| 1002 | * Add this query parameter to a URI to get back row counts grouped by |
| 1003 | * the address book index as cursor extras. For most languages it is the |
| 1004 | * first letter of the sort key. This parameter does not affect the main |
| 1005 | * content of the cursor. |
| 1006 | * |
| 1007 | * @hide |
| 1008 | */ |
| 1009 | public static final String ADDRESS_BOOK_INDEX_EXTRAS = "address_book_index_extras"; |
| 1010 | |
| 1011 | /** |
| 1012 | * The array of address book index titles, which are returned in the |
| 1013 | * same order as the data in the cursor. |
| 1014 | * <p>TYPE: String[]</p> |
| 1015 | * |
| 1016 | * @hide |
| 1017 | */ |
| 1018 | public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES = "address_book_index_titles"; |
| 1019 | |
| 1020 | /** |
| 1021 | * The array of group counts for the corresponding group. Contains the same number |
| 1022 | * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array. |
| 1023 | * <p>TYPE: int[]</p> |
| 1024 | * |
| 1025 | * @hide |
| 1026 | */ |
| 1027 | public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = "address_book_index_counts"; |
| 1028 | } |
| 1029 | |
| 1030 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1031 | * Constants for the contacts table, which contains a record per aggregate |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1032 | * of raw contacts representing the same person. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1033 | * <h3>Operations</h3> |
| 1034 | * <dl> |
| 1035 | * <dt><b>Insert</b></dt> |
| 1036 | * <dd>A Contact cannot be created explicitly. When a raw contact is |
| 1037 | * inserted, the provider will first try to find a Contact representing the |
| 1038 | * same person. If one is found, the raw contact's |
| 1039 | * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate |
| 1040 | * Contact. If no match is found, the provider automatically inserts a new |
| 1041 | * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column |
| 1042 | * of the newly inserted raw contact.</dd> |
| 1043 | * <dt><b>Update</b></dt> |
| 1044 | * <dd>Only certain columns of Contact are modifiable: |
| 1045 | * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED}, |
| 1046 | * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of |
| 1047 | * these columns on the Contact also changes them on all constituent raw |
| 1048 | * contacts.</dd> |
| 1049 | * <dt><b>Delete</b></dt> |
| 1050 | * <dd>Be careful with deleting Contacts! Deleting an aggregate contact |
| 1051 | * deletes all constituent raw contacts. The corresponding sync adapters |
| 1052 | * will notice the deletions of their respective raw contacts and remove |
| 1053 | * them from their back end storage.</dd> |
| 1054 | * <dt><b>Query</b></dt> |
| 1055 | * <dd> |
| 1056 | * <ul> |
| 1057 | * <li>If you need to read an individual contact, consider using |
| 1058 | * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li> |
| 1059 | * <li>If you need to look up a contact by the phone number, use |
| 1060 | * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI}, |
| 1061 | * which is optimized for this purpose.</li> |
| 1062 | * <li>If you need to look up a contact by partial name, e.g. to produce |
| 1063 | * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI. |
| 1064 | * <li>If you need to look up a contact by some data element like email |
| 1065 | * address, nickname, etc, use a query against the {@link ContactsContract.Data} table. |
| 1066 | * The result will contain contact ID, name etc. |
| 1067 | * </ul> |
| 1068 | * </dd> |
| 1069 | * </dl> |
| 1070 | * <h2>Columns</h2> |
| 1071 | * <table class="jd-sumtable"> |
| 1072 | * <tr> |
| 1073 | * <th colspan='4'>Contacts</th> |
| 1074 | * </tr> |
| 1075 | * <tr> |
| 1076 | * <td>long</td> |
| 1077 | * <td>{@link #_ID}</td> |
| 1078 | * <td>read-only</td> |
| 1079 | * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td> |
| 1080 | * </tr> |
| 1081 | * <tr> |
| 1082 | * <td>String</td> |
| 1083 | * <td>{@link #LOOKUP_KEY}</td> |
| 1084 | * <td>read-only</td> |
| 1085 | * <td>An opaque value that contains hints on how to find the contact if its |
| 1086 | * row id changed as a result of a sync or aggregation.</td> |
| 1087 | * </tr> |
| 1088 | * <tr> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1089 | * <td>long</td> |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1090 | * <td>NAME_RAW_CONTACT_ID</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1091 | * <td>read-only</td> |
| 1092 | * <td>The ID of the raw contact that contributes the display name |
| 1093 | * to the aggregate contact. During aggregation one of the constituent |
| 1094 | * raw contacts is chosen using a heuristic: a longer name or a name |
| 1095 | * with more diacritic marks or more upper case characters is chosen.</td> |
| 1096 | * </tr> |
| 1097 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1098 | * <td>String</td> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1099 | * <td>DISPLAY_NAME_PRIMARY</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1100 | * <td>read-only</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1101 | * <td>The display name for the contact. It is the display name |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1102 | * 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] | 1103 | * column.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1104 | * </tr> |
| 1105 | * <tr> |
| 1106 | * <td>long</td> |
| 1107 | * <td>{@link #PHOTO_ID}</td> |
| 1108 | * <td>read-only</td> |
| 1109 | * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo. |
| 1110 | * That row has the mime type |
| 1111 | * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field |
| 1112 | * is computed automatically based on the |
| 1113 | * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of |
| 1114 | * that mime type.</td> |
| 1115 | * </tr> |
| 1116 | * <tr> |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 1117 | * <td>long</td> |
| 1118 | * <td>{@link #PHOTO_URI}</td> |
| 1119 | * <td>read-only</td> |
| 1120 | * <td>A URI that can be used to retrieve the contact's full-size photo. This |
| 1121 | * column is the preferred method of retrieving the contact photo.</td> |
| 1122 | * </tr> |
| 1123 | * <tr> |
| 1124 | * <td>long</td> |
| 1125 | * <td>{@link #PHOTO_THUMBNAIL_URI}</td> |
| 1126 | * <td>read-only</td> |
| 1127 | * <td>A URI that can be used to retrieve the thumbnail of contact's photo. This |
| 1128 | * column is the preferred method of retrieving the contact photo.</td> |
| 1129 | * </tr> |
| 1130 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1131 | * <td>int</td> |
| 1132 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 1133 | * <td>read-only</td> |
| 1134 | * <td>An indicator of whether this contact is supposed to be visible in the |
| 1135 | * UI. "1" if the contact has at least one raw contact that belongs to a |
| 1136 | * visible group; "0" otherwise.</td> |
| 1137 | * </tr> |
| 1138 | * <tr> |
| 1139 | * <td>int</td> |
| 1140 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 1141 | * <td>read-only</td> |
| 1142 | * <td>An indicator of whether this contact has at least one phone number. |
| 1143 | * "1" if there is at least one phone number, "0" otherwise.</td> |
| 1144 | * </tr> |
| 1145 | * <tr> |
| 1146 | * <td>int</td> |
| 1147 | * <td>{@link #TIMES_CONTACTED}</td> |
| 1148 | * <td>read/write</td> |
| 1149 | * <td>The number of times the contact has been contacted. See |
| 1150 | * {@link #markAsContacted}. When raw contacts are aggregated, this field is |
| 1151 | * computed automatically as the maximum number of times contacted among all |
| 1152 | * constituent raw contacts. Setting this field automatically changes the |
| 1153 | * corresponding field on all constituent raw contacts.</td> |
| 1154 | * </tr> |
| 1155 | * <tr> |
| 1156 | * <td>long</td> |
| 1157 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 1158 | * <td>read/write</td> |
| 1159 | * <td>The timestamp of the last time the contact was contacted. See |
| 1160 | * {@link #markAsContacted}. Setting this field also automatically |
| 1161 | * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated, |
| 1162 | * this field is computed automatically as the latest time contacted of all |
| 1163 | * constituent raw contacts. Setting this field automatically changes the |
| 1164 | * corresponding field on all constituent raw contacts.</td> |
| 1165 | * </tr> |
| 1166 | * <tr> |
| 1167 | * <td>int</td> |
| 1168 | * <td>{@link #STARRED}</td> |
| 1169 | * <td>read/write</td> |
| 1170 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
| 1171 | * When raw contacts are aggregated, this field is automatically computed: |
| 1172 | * if any constituent raw contacts are starred, then this field is set to |
| 1173 | * '1'. Setting this field automatically changes the corresponding field on |
| 1174 | * all constituent raw contacts.</td> |
| 1175 | * </tr> |
| 1176 | * <tr> |
| 1177 | * <td>String</td> |
| 1178 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 1179 | * <td>read/write</td> |
| 1180 | * <td>A custom ringtone associated with a contact. Typically this is the |
| 1181 | * URI returned by an activity launched with the |
| 1182 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td> |
| 1183 | * </tr> |
| 1184 | * <tr> |
| 1185 | * <td>int</td> |
| 1186 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 1187 | * <td>read/write</td> |
| 1188 | * <td>An indicator of whether calls from this contact should be forwarded |
| 1189 | * directly to voice mail ('1') or not ('0'). When raw contacts are |
| 1190 | * aggregated, this field is automatically computed: if <i>all</i> |
| 1191 | * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set |
| 1192 | * to '1'. Setting this field automatically changes the corresponding field |
| 1193 | * on all constituent raw contacts.</td> |
| 1194 | * </tr> |
| 1195 | * <tr> |
| 1196 | * <td>int</td> |
| 1197 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 1198 | * <td>read-only</td> |
| 1199 | * <td>Contact IM presence status. See {@link StatusUpdates} for individual |
| 1200 | * status definitions. Automatically computed as the highest presence of all |
| 1201 | * constituent raw contacts. The provider may choose not to store this value |
| 1202 | * in persistent storage. The expectation is that presence status will be |
| 1203 | * updated on a regular basic.</td> |
| 1204 | * </tr> |
| 1205 | * <tr> |
| 1206 | * <td>String</td> |
| 1207 | * <td>{@link #CONTACT_STATUS}</td> |
| 1208 | * <td>read-only</td> |
| 1209 | * <td>Contact's latest status update. Automatically computed as the latest |
| 1210 | * of all constituent raw contacts' status updates.</td> |
| 1211 | * </tr> |
| 1212 | * <tr> |
| 1213 | * <td>long</td> |
| 1214 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 1215 | * <td>read-only</td> |
| 1216 | * <td>The absolute time in milliseconds when the latest status was |
| 1217 | * inserted/updated.</td> |
| 1218 | * </tr> |
| 1219 | * <tr> |
| 1220 | * <td>String</td> |
| 1221 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 1222 | * <td>read-only</td> |
| 1223 | * <td> The package containing resources for this status: label and icon.</td> |
| 1224 | * </tr> |
| 1225 | * <tr> |
| 1226 | * <td>long</td> |
| 1227 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 1228 | * <td>read-only</td> |
| 1229 | * <td>The resource ID of the label describing the source of contact status, |
| 1230 | * e.g. "Google Talk". This resource is scoped by the |
| 1231 | * {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1232 | * </tr> |
| 1233 | * <tr> |
| 1234 | * <td>long</td> |
| 1235 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 1236 | * <td>read-only</td> |
| 1237 | * <td>The resource ID of the icon for the source of contact status. This |
| 1238 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1239 | * </tr> |
| 1240 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1241 | */ |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 1242 | public static class Contacts implements BaseColumns, ContactsColumns, |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1243 | ContactOptionsColumns, ContactNameColumns, ContactStatusColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1244 | /** |
| 1245 | * This utility class cannot be instantiated |
| 1246 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1247 | private Contacts() {} |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1248 | |
| 1249 | /** |
| 1250 | * The content:// style URI for this table |
| 1251 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1252 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1253 | |
| 1254 | /** |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1255 | * A content:// style URI for this table that should be used to create |
| 1256 | * shortcuts or otherwise create long-term links to contacts. This URI |
| 1257 | * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}. |
| 1258 | * It can optionally also have a "/" and last known contact ID appended after |
| 1259 | * that. This "complete" format is an important optimization and is highly recommended. |
| 1260 | * <p> |
| 1261 | * As long as the contact's row ID remains the same, this URI is |
| 1262 | * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes |
| 1263 | * as a result of a sync or aggregation, this URI will look up the |
| 1264 | * contact using indirect information (sync IDs or constituent raw |
| 1265 | * contacts). |
| 1266 | * <p> |
| 1267 | * Lookup key should be appended unencoded - it is stored in the encoded |
| 1268 | * form, ready for use in a URI. |
| 1269 | */ |
| 1270 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1271 | "lookup"); |
| 1272 | |
| 1273 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1274 | * Base {@link Uri} for referencing a single {@link Contacts} entry, |
Jeff Sharkey | 8f76734 | 2009-09-28 18:22:46 -0700 | [diff] [blame] | 1275 | * created by appending {@link #LOOKUP_KEY} using |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1276 | * {@link Uri#withAppendedPath(Uri, String)}. Provides |
| 1277 | * {@link OpenableColumns} columns when queried, or returns the |
| 1278 | * referenced contact formatted as a vCard when opened through |
| 1279 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1280 | */ |
| 1281 | public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1282 | "as_vcard"); |
| 1283 | |
| 1284 | /** |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1285 | * Base {@link Uri} for referencing multiple {@link Contacts} entry, |
| 1286 | * created by appending {@link #LOOKUP_KEY} using |
| 1287 | * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be |
| 1288 | * encoded and joined with the colon (":") seperator. The resulting string |
| 1289 | * has to be encoded again. Provides |
| 1290 | * {@link OpenableColumns} columns when queried, or returns the |
| 1291 | * referenced contact formatted as a vCard when opened through |
| 1292 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1293 | * |
| 1294 | * This is private API because we do not have a well-defined way to |
| 1295 | * specify several entities yet. The format of this Uri might change in the future |
| 1296 | * or the Uri might be completely removed. |
| 1297 | * |
| 1298 | * @hide |
| 1299 | */ |
| 1300 | public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1301 | "as_multi_vcard"); |
| 1302 | |
| 1303 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1304 | * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the |
| 1305 | * requested {@link Contacts} entry. |
| 1306 | * |
| 1307 | * @param contactUri A {@link #CONTENT_URI} row, or an existing |
| 1308 | * {@link #CONTENT_LOOKUP_URI} to attempt refreshing. |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1309 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1310 | public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) { |
| 1311 | final Cursor c = resolver.query(contactUri, new String[] { |
| 1312 | Contacts.LOOKUP_KEY, Contacts._ID |
| 1313 | }, null, null, null); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1314 | if (c == null) { |
| 1315 | return null; |
| 1316 | } |
| 1317 | |
| 1318 | try { |
| 1319 | if (c.moveToFirst()) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1320 | final String lookupKey = c.getString(0); |
| 1321 | final long contactId = c.getLong(1); |
| 1322 | return getLookupUri(contactId, lookupKey); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1323 | } |
| 1324 | } finally { |
| 1325 | c.close(); |
| 1326 | } |
| 1327 | return null; |
| 1328 | } |
| 1329 | |
| 1330 | /** |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1331 | * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1332 | * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}. |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1333 | */ |
| 1334 | public static Uri getLookupUri(long contactId, String lookupKey) { |
| 1335 | return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, |
| 1336 | lookupKey), contactId); |
| 1337 | } |
| 1338 | |
| 1339 | /** |
Dmitri Plotnikov | b5759b5 | 2009-09-01 15:58:40 -0700 | [diff] [blame] | 1340 | * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI. |
| 1341 | * <p> |
| 1342 | * Returns null if the contact cannot be found. |
| 1343 | */ |
| 1344 | public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) { |
| 1345 | if (lookupUri == null) { |
| 1346 | return null; |
| 1347 | } |
| 1348 | |
| 1349 | Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null); |
| 1350 | if (c == null) { |
| 1351 | return null; |
| 1352 | } |
| 1353 | |
| 1354 | try { |
| 1355 | if (c.moveToFirst()) { |
| 1356 | long contactId = c.getLong(0); |
| 1357 | return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1358 | } |
| 1359 | } finally { |
| 1360 | c.close(); |
| 1361 | } |
| 1362 | return null; |
| 1363 | } |
| 1364 | |
| 1365 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1366 | * Mark a contact as having been contacted. Updates two fields: |
| 1367 | * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED}. The |
| 1368 | * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED |
| 1369 | * field is populated with the current system time. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1370 | * |
| 1371 | * @param resolver the ContentResolver to use |
| 1372 | * @param contactId the person who was contacted |
| 1373 | */ |
| 1374 | public static void markAsContacted(ContentResolver resolver, long contactId) { |
| 1375 | Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId); |
| 1376 | ContentValues values = new ContentValues(); |
| 1377 | // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified. |
| 1378 | values.put(LAST_TIME_CONTACTED, System.currentTimeMillis()); |
| 1379 | resolver.update(uri, values, null, null); |
| 1380 | } |
| 1381 | |
| 1382 | /** |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1383 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1384 | * {@link #CONTENT_URI} URI. The filter string will be used to match |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1385 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1386 | * as an additional path segment after this URI. |
| 1387 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1388 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 1389 | CONTENT_URI, "filter"); |
| 1390 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1391 | /** |
| 1392 | * The content:// style URI for this table joined with useful data from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1393 | * {@link ContactsContract.Data}, filtered to include only starred contacts |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1394 | * and the most frequently contacted contacts. |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1395 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1396 | public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath( |
| 1397 | CONTENT_URI, "strequent"); |
| 1398 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1399 | /** |
| 1400 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1401 | * {@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] | 1402 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1403 | * as an additional path segment after this URI. |
| 1404 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1405 | public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath( |
| 1406 | CONTENT_STREQUENT_URI, "filter"); |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1407 | |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1408 | public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath( |
| 1409 | CONTENT_URI, "group"); |
| 1410 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1411 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1412 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 1413 | * people. |
| 1414 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1415 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1416 | |
| 1417 | /** |
| 1418 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1419 | * person. |
| 1420 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1421 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1422 | |
| 1423 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1424 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1425 | * person. |
| 1426 | */ |
| 1427 | public static final String CONTENT_VCARD_TYPE = "text/x-vcard"; |
| 1428 | |
| 1429 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1430 | * 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] | 1431 | * {@link ContactsContract.Data} rows. This directory can be used either |
| 1432 | * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1433 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1434 | public static final class Data implements BaseColumns, DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1435 | /** |
| 1436 | * no public constructor since this is a utility class |
| 1437 | */ |
| 1438 | private Data() {} |
| 1439 | |
| 1440 | /** |
| 1441 | * The directory twig for this sub-table |
| 1442 | */ |
| 1443 | public static final String CONTENT_DIRECTORY = "data"; |
| 1444 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1445 | |
| 1446 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1447 | * <p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1448 | * A sub-directory of a contact that contains all of its |
| 1449 | * {@link ContactsContract.RawContacts} as well as |
| 1450 | * {@link ContactsContract.Data} rows. To access this directory append |
| 1451 | * {@link #CONTENT_DIRECTORY} to the contact URI. |
| 1452 | * </p> |
| 1453 | * <p> |
| 1454 | * Entity has three ID fields: {@link #CONTACT_ID} for the contact, |
| 1455 | * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for |
| 1456 | * the data rows. Entity always contains at least one row per |
| 1457 | * constituent raw contact, even if there are no actual data rows. In |
| 1458 | * this case the {@link #DATA_ID} field will be null. |
| 1459 | * </p> |
| 1460 | * <p> |
| 1461 | * Entity reads all data for the entire contact in one transaction, to |
| 1462 | * guarantee consistency. There is significant data duplication |
| 1463 | * in the Entity (each row repeats all Contact columns and all RawContact |
| 1464 | * columns), so the benefits of transactional consistency should be weighed |
| 1465 | * against the cost of transferring large amounts of denormalized data |
| 1466 | * from the Provider. |
| 1467 | * </p> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 1468 | * <p> |
| 1469 | * To reduce the amount of data duplication the contacts provider and directory |
| 1470 | * providers implementing this protocol are allowed to provide common Contacts |
| 1471 | * and RawContacts fields in the first row returned for each raw contact only and |
| 1472 | * leave them as null in subsequent rows. |
| 1473 | * </p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1474 | */ |
| 1475 | public static final class Entity implements BaseColumns, ContactsColumns, |
| 1476 | ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns, |
| 1477 | StatusColumns, ContactOptionsColumns, ContactStatusColumns { |
| 1478 | /** |
| 1479 | * no public constructor since this is a utility class |
| 1480 | */ |
| 1481 | private Entity() { |
| 1482 | } |
| 1483 | |
| 1484 | /** |
| 1485 | * The directory twig for this sub-table |
| 1486 | */ |
| 1487 | public static final String CONTENT_DIRECTORY = "entities"; |
| 1488 | |
| 1489 | /** |
| 1490 | * The ID of the raw contact row. |
| 1491 | * <P>Type: INTEGER</P> |
| 1492 | */ |
| 1493 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 1494 | |
| 1495 | /** |
| 1496 | * The ID of the data row. The value will be null if this raw contact has no |
| 1497 | * data rows. |
| 1498 | * <P>Type: INTEGER</P> |
| 1499 | */ |
| 1500 | public static final String DATA_ID = "data_id"; |
| 1501 | } |
| 1502 | |
| 1503 | /** |
| 1504 | * <p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1505 | * A <i>read-only</i> sub-directory of a single contact aggregate that |
| 1506 | * contains all aggregation suggestions (other contacts). The |
| 1507 | * aggregation suggestions are computed based on approximate data |
| 1508 | * matches with this contact. |
| 1509 | * </p> |
| 1510 | * <p> |
| 1511 | * <i>Note: this query may be expensive! If you need to use it in bulk, |
| 1512 | * make sure the user experience is acceptable when the query runs for a |
| 1513 | * long time.</i> |
| 1514 | * <p> |
| 1515 | * Usage example: |
| 1516 | * |
| 1517 | * <pre> |
| 1518 | * Uri uri = Contacts.CONTENT_URI.buildUpon() |
| 1519 | * .appendEncodedPath(String.valueOf(contactId)) |
| 1520 | * .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY) |
| 1521 | * .appendQueryParameter("limit", "3") |
| 1522 | * .build() |
| 1523 | * Cursor cursor = getContentResolver().query(suggestionsUri, |
| 1524 | * new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY}, |
| 1525 | * null, null, null); |
| 1526 | * </pre> |
| 1527 | * |
| 1528 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1529 | * <p> |
| 1530 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 1531 | * {@link #CONTENT_LOOKUP_URI}. |
| 1532 | * </p> |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1533 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1534 | public static final class AggregationSuggestions implements BaseColumns, ContactsColumns, |
| 1535 | ContactOptionsColumns, ContactStatusColumns { |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1536 | /** |
| 1537 | * No public constructor since this is a utility class |
| 1538 | */ |
| 1539 | private AggregationSuggestions() {} |
| 1540 | |
| 1541 | /** |
Dmitri Plotnikov | 0fc0244 | 2009-09-21 13:26:28 -0700 | [diff] [blame] | 1542 | * 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] | 1543 | * type-to-filter, similar to |
| 1544 | * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}. |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1545 | */ |
| 1546 | public static final String CONTENT_DIRECTORY = "suggestions"; |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1547 | |
| 1548 | /** |
| 1549 | * Used with {@link Builder#addParameter} to specify what kind of data is |
| 1550 | * supplied for the suggestion query. |
| 1551 | * |
| 1552 | * @hide |
| 1553 | */ |
| 1554 | public static final String PARAMETER_MATCH_NAME = "name"; |
| 1555 | |
| 1556 | /** |
| 1557 | * Used with {@link Builder#addParameter} to specify what kind of data is |
| 1558 | * supplied for the suggestion query. |
| 1559 | * |
| 1560 | * @hide |
| 1561 | */ |
| 1562 | public static final String PARAMETER_MATCH_EMAIL = "email"; |
| 1563 | |
| 1564 | /** |
| 1565 | * Used with {@link Builder#addParameter} to specify what kind of data is |
| 1566 | * supplied for the suggestion query. |
| 1567 | * |
| 1568 | * @hide |
| 1569 | */ |
| 1570 | public static final String PARAMETER_MATCH_PHONE = "phone"; |
| 1571 | |
| 1572 | /** |
| 1573 | * Used with {@link Builder#addParameter} to specify what kind of data is |
| 1574 | * supplied for the suggestion query. |
| 1575 | * |
| 1576 | * @hide |
| 1577 | */ |
| 1578 | public static final String PARAMETER_MATCH_NICKNAME = "nickname"; |
| 1579 | |
| 1580 | /** |
| 1581 | * A convenience builder for aggregation suggestion content URIs. |
| 1582 | * |
| 1583 | * TODO: change documentation for this class to use the builder. |
| 1584 | * @hide |
| 1585 | */ |
| 1586 | public static final class Builder { |
| 1587 | private long mContactId; |
| 1588 | private ArrayList<String> mKinds = new ArrayList<String>(); |
| 1589 | private ArrayList<String> mValues = new ArrayList<String>(); |
| 1590 | private int mLimit; |
| 1591 | |
| 1592 | /** |
| 1593 | * Optional existing contact ID. If it is not provided, the search |
| 1594 | * will be based exclusively on the values supplied with {@link #addParameter}. |
| 1595 | */ |
| 1596 | public Builder setContactId(long contactId) { |
| 1597 | this.mContactId = contactId; |
| 1598 | return this; |
| 1599 | } |
| 1600 | |
| 1601 | /** |
| 1602 | * A value that can be used when searching for an aggregation |
| 1603 | * suggestion. |
| 1604 | * |
| 1605 | * @param kind can be one of |
| 1606 | * {@link AggregationSuggestions#PARAMETER_MATCH_NAME}, |
| 1607 | * {@link AggregationSuggestions#PARAMETER_MATCH_EMAIL}, |
| 1608 | * {@link AggregationSuggestions#PARAMETER_MATCH_NICKNAME}, |
| 1609 | * {@link AggregationSuggestions#PARAMETER_MATCH_PHONE} |
| 1610 | */ |
| 1611 | public Builder addParameter(String kind, String value) { |
| 1612 | if (!TextUtils.isEmpty(value)) { |
| 1613 | mKinds.add(kind); |
| 1614 | mValues.add(value); |
| 1615 | } |
| 1616 | return this; |
| 1617 | } |
| 1618 | |
| 1619 | public Builder setLimit(int limit) { |
| 1620 | mLimit = limit; |
| 1621 | return this; |
| 1622 | } |
| 1623 | |
| 1624 | public Uri build() { |
| 1625 | android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon(); |
| 1626 | builder.appendEncodedPath(String.valueOf(mContactId)); |
| 1627 | builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY); |
| 1628 | if (mLimit != 0) { |
| 1629 | builder.appendQueryParameter("limit", String.valueOf(mLimit)); |
| 1630 | } |
| 1631 | |
| 1632 | int count = mKinds.size(); |
| 1633 | for (int i = 0; i < count; i++) { |
| 1634 | builder.appendQueryParameter("query", mKinds.get(i) + ":" + mValues.get(i)); |
| 1635 | } |
| 1636 | |
| 1637 | return builder.build(); |
| 1638 | } |
| 1639 | } |
| 1640 | |
| 1641 | /** |
| 1642 | * @hide |
| 1643 | */ |
| 1644 | public static final Builder builder() { |
| 1645 | return new Builder(); |
| 1646 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1647 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1648 | |
| 1649 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1650 | * A <i>read-only</i> sub-directory of a single contact that contains |
| 1651 | * the contact's primary photo. |
| 1652 | * <p> |
| 1653 | * Usage example: |
| 1654 | * |
| 1655 | * <pre> |
| 1656 | * public InputStream openPhoto(long contactId) { |
| 1657 | * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1658 | * Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY); |
| 1659 | * Cursor cursor = getContentResolver().query(photoUri, |
| 1660 | * new String[] {Contacts.Photo.PHOTO}, null, null, null); |
| 1661 | * if (cursor == null) { |
| 1662 | * return null; |
| 1663 | * } |
| 1664 | * try { |
| 1665 | * if (cursor.moveToFirst()) { |
| 1666 | * byte[] data = cursor.getBlob(0); |
| 1667 | * if (data != null) { |
| 1668 | * return new ByteArrayInputStream(data); |
| 1669 | * } |
| 1670 | * } |
| 1671 | * } finally { |
| 1672 | * cursor.close(); |
| 1673 | * } |
| 1674 | * return null; |
| 1675 | * } |
| 1676 | * </pre> |
| 1677 | * |
| 1678 | * </p> |
| 1679 | * <p>You should also consider using the convenience method |
| 1680 | * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri)} |
| 1681 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1682 | * <p> |
| 1683 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 1684 | * {@link #CONTENT_LOOKUP_URI}. |
| 1685 | * </p> |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1686 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1687 | public static final class Photo implements BaseColumns, DataColumnsWithJoins { |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 1688 | /** |
| 1689 | * no public constructor since this is a utility class |
| 1690 | */ |
| 1691 | private Photo() {} |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 1692 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 1693 | /** |
| 1694 | * The directory twig for this sub-table |
| 1695 | */ |
| 1696 | public static final String CONTENT_DIRECTORY = "photo"; |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1697 | |
| 1698 | /** |
| 1699 | * Thumbnail photo of the raw contact. This is the raw bytes of an image |
| 1700 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
| 1701 | * <p> |
| 1702 | * Type: BLOB |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1703 | */ |
| 1704 | public static final String PHOTO = DATA15; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1705 | } |
| 1706 | |
| 1707 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1708 | * Opens an InputStream for the contacts's default photo and returns the |
| 1709 | * photo as a byte stream. If there is not photo null will be returned. |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1710 | * |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1711 | * @param contactUri the contact whose photo should be used. This can be used with |
| 1712 | * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI. |
| 1713 | * </p> |
| 1714 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1715 | * @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] | 1716 | */ |
| 1717 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) { |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 1718 | Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY); |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 1719 | if (photoUri == null) { |
| 1720 | return null; |
| 1721 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1722 | Cursor cursor = cr.query(photoUri, |
| 1723 | new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null); |
| 1724 | try { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 1725 | if (cursor == null || !cursor.moveToNext()) { |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1726 | return null; |
| 1727 | } |
| 1728 | byte[] data = cursor.getBlob(0); |
| 1729 | if (data == null) { |
| 1730 | return null; |
| 1731 | } |
| 1732 | return new ByteArrayInputStream(data); |
| 1733 | } finally { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 1734 | if (cursor != null) { |
| 1735 | cursor.close(); |
| 1736 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1737 | } |
| 1738 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1739 | } |
| 1740 | |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 1741 | protected interface RawContactsColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1742 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1743 | * A reference to the {@link ContactsContract.Contacts#_ID} that this |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1744 | * data belongs to. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1745 | * <P>Type: INTEGER</P> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1746 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1747 | public static final String CONTACT_ID = "contact_id"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1748 | |
| 1749 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1750 | * Flag indicating that this {@link RawContacts} entry and its children have |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1751 | * been restricted to specific platform apps. |
| 1752 | * <P>Type: INTEGER (boolean)</P> |
| 1753 | * |
| 1754 | * @hide until finalized in future platform release |
| 1755 | */ |
| 1756 | public static final String IS_RESTRICTED = "is_restricted"; |
| 1757 | |
| 1758 | /** |
| 1759 | * The aggregation mode for this contact. |
| 1760 | * <P>Type: INTEGER</P> |
| 1761 | */ |
| 1762 | public static final String AGGREGATION_MODE = "aggregation_mode"; |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 1763 | |
| 1764 | /** |
| 1765 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 1766 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 1767 | * 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] | 1768 | * 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] | 1769 | * then calls ContactResolver.delete once more, this time passing the |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 1770 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 1771 | * the data removal. |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 1772 | * <P>Type: INTEGER</P> |
| 1773 | */ |
| 1774 | public static final String DELETED = "deleted"; |
Dmitri Plotnikov | 918007b | 2010-01-20 12:12:11 -0800 | [diff] [blame] | 1775 | |
| 1776 | /** |
| 1777 | * The "name_verified" flag: "1" means that the name fields on this raw |
| 1778 | * contact can be trusted and therefore should be used for the entire |
| 1779 | * aggregated contact. |
| 1780 | * <p> |
| 1781 | * If an aggregated contact contains more than one raw contact with a |
| 1782 | * verified name, one of those verified names is chosen at random. |
| 1783 | * If an aggregated contact contains no verified names, the |
| 1784 | * name is chosen randomly from the constituent raw contacts. |
| 1785 | * </p> |
| 1786 | * <p> |
| 1787 | * Updating this flag from "0" to "1" automatically resets it to "0" on |
| 1788 | * all other raw contacts in the same aggregated contact. |
| 1789 | * </p> |
| 1790 | * <p> |
| 1791 | * Sync adapters should only specify a value for this column when |
| 1792 | * inserting a raw contact and leave it out when doing an update. |
| 1793 | * </p> |
| 1794 | * <p> |
| 1795 | * The default value is "0" |
| 1796 | * </p> |
| 1797 | * <p>Type: INTEGER</p> |
| 1798 | * |
| 1799 | * @hide |
| 1800 | */ |
| 1801 | public static final String NAME_VERIFIED = "name_verified"; |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 1802 | |
| 1803 | /** |
| 1804 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 1805 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 1806 | * <P>Type: INTEGER</P> |
| 1807 | */ |
Dmitri Plotnikov | 86fe839 | 2010-07-16 11:19:46 -0700 | [diff] [blame] | 1808 | public static final String RAW_CONTACT_IS_READ_ONLY = "raw_contact_is_read_only"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1809 | } |
| 1810 | |
| 1811 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1812 | * Constants for the raw contacts table, which contains one row of contact |
| 1813 | * information for each person in each synced account. Sync adapters and |
| 1814 | * contact management apps |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 1815 | * are the primary consumers of this API. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1816 | * |
| 1817 | * <h3>Aggregation</h3> |
| 1818 | * <p> |
| 1819 | * As soon as a raw contact is inserted or whenever its constituent data |
| 1820 | * changes, the provider will check if the raw contact matches other |
| 1821 | * existing raw contacts and if so will aggregate it with those. The |
| 1822 | * aggregation is reflected in the {@link RawContacts} table by the change of the |
| 1823 | * {@link #CONTACT_ID} field, which is the reference to the aggregate contact. |
| 1824 | * </p> |
| 1825 | * <p> |
| 1826 | * Changes to the structured name, organization, phone number, email address, |
| 1827 | * or nickname trigger a re-aggregation. |
| 1828 | * </p> |
| 1829 | * <p> |
| 1830 | * See also {@link AggregationExceptions} for a mechanism to control |
| 1831 | * aggregation programmatically. |
| 1832 | * </p> |
| 1833 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1834 | * <h3>Operations</h3> |
| 1835 | * <dl> |
| 1836 | * <dt><b>Insert</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1837 | * <dd> |
| 1838 | * <p> |
| 1839 | * Raw contacts can be inserted incrementally or in a batch. |
| 1840 | * The incremental method is more traditional but less efficient. |
| 1841 | * It should be used |
| 1842 | * 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] | 1843 | * <pre> |
| 1844 | * ContentValues values = new ContentValues(); |
| 1845 | * values.put(RawContacts.ACCOUNT_TYPE, accountType); |
| 1846 | * values.put(RawContacts.ACCOUNT_NAME, accountName); |
| 1847 | * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values); |
| 1848 | * long rawContactId = ContentUris.parseId(rawContactUri); |
| 1849 | * </pre> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1850 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1851 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1852 | * Once {@link Data} values become available, insert those. |
| 1853 | * For example, here's how you would insert a name: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1854 | * |
| 1855 | * <pre> |
| 1856 | * values.clear(); |
| 1857 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 1858 | * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); |
| 1859 | * values.put(StructuredName.DISPLAY_NAME, "Mike Sullivan"); |
| 1860 | * getContentResolver().insert(Data.CONTENT_URI, values); |
| 1861 | * </pre> |
| 1862 | * </p> |
| 1863 | * <p> |
| 1864 | * The batch method is by far preferred. It inserts the raw contact and its |
| 1865 | * constituent data rows in a single database transaction |
| 1866 | * and causes at most one aggregation pass. |
| 1867 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 1868 | * ArrayList<ContentProviderOperation> ops = |
| 1869 | * new ArrayList<ContentProviderOperation>(); |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1870 | * ... |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1871 | * int rawContactInsertIndex = ops.size(); |
| 1872 | * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) |
| 1873 | * .withValue(RawContacts.ACCOUNT_TYPE, accountType) |
| 1874 | * .withValue(RawContacts.ACCOUNT_NAME, accountName) |
| 1875 | * .build()); |
| 1876 | * |
| 1877 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 1878 | * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex) |
| 1879 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 1880 | * .withValue(StructuredName.DISPLAY_NAME, "Mike Sullivan") |
| 1881 | * .build()); |
| 1882 | * |
| 1883 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 1884 | * </pre> |
| 1885 | * </p> |
| 1886 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1887 | * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)} |
| 1888 | * to refer to the as-yet-unknown index value of the raw contact inserted in the |
| 1889 | * first operation. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1890 | * </p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1891 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1892 | * <dt><b>Update</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1893 | * <dd><p> |
| 1894 | * Raw contacts can be updated incrementally or in a batch. |
| 1895 | * Batch mode should be used whenever possible. |
| 1896 | * The procedures and considerations are analogous to those documented above for inserts. |
| 1897 | * </p></dd> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1898 | * <dt><b>Delete</b></dt> |
| 1899 | * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates, |
| 1900 | * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1901 | * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row |
| 1902 | * itself is also deleted automatically. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1903 | * </p> |
| 1904 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1905 | * The invocation of {@code resolver.delete(...)}, does not immediately delete |
| 1906 | * a raw contacts row. |
| 1907 | * Instead, it sets the {@link #DELETED} flag on the raw contact and |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1908 | * removes the raw contact from its aggregate contact. |
| 1909 | * The sync adapter then deletes the raw contact from the server and |
| 1910 | * finalizes phone-side deletion by calling {@code resolver.delete(...)} |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 1911 | * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1912 | * <p>Some sync adapters are read-only, meaning that they only sync server-side |
| 1913 | * changes to the phone, but not the reverse. If one of those raw contacts |
| 1914 | * is marked for deletion, it will remain on the phone. However it will be |
| 1915 | * effectively invisible, because it will not be part of any aggregate contact. |
| 1916 | * </dd> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1917 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1918 | * <dt><b>Query</b></dt> |
| 1919 | * <dd> |
| 1920 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1921 | * It is easy to find all raw contacts in a Contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1922 | * <pre> |
| 1923 | * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI, |
| 1924 | * new String[]{RawContacts._ID}, |
| 1925 | * RawContacts.CONTACT_ID + "=?", |
| 1926 | * new String[]{String.valueOf(contactId)}, null); |
| 1927 | * </pre> |
| 1928 | * </p> |
| 1929 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1930 | * To find raw contacts within a specific account, |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1931 | * you can either put the account name and type in the selection or pass them as query |
| 1932 | * parameters. The latter approach is preferable, especially when you can reuse the |
| 1933 | * URI: |
| 1934 | * <pre> |
| 1935 | * Uri rawContactUri = RawContacts.URI.buildUpon() |
| 1936 | * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName) |
| 1937 | * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType) |
| 1938 | * .build(); |
| 1939 | * Cursor c1 = getContentResolver().query(rawContactUri, |
| 1940 | * RawContacts.STARRED + "<>0", null, null, null); |
| 1941 | * ... |
| 1942 | * Cursor c2 = getContentResolver().query(rawContactUri, |
| 1943 | * RawContacts.DELETED + "<>0", null, null, null); |
| 1944 | * </pre> |
| 1945 | * </p> |
| 1946 | * <p>The best way to read a raw contact along with all the data associated with it is |
| 1947 | * by using the {@link Entity} directory. If the raw contact has data rows, |
| 1948 | * the Entity cursor will contain a row for each data row. If the raw contact has no |
| 1949 | * data rows, the cursor will still contain one row with the raw contact-level information. |
| 1950 | * <pre> |
| 1951 | * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); |
| 1952 | * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY); |
| 1953 | * Cursor c = getContentResolver().query(entityUri, |
| 1954 | * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1}, |
| 1955 | * null, null, null); |
| 1956 | * try { |
| 1957 | * while (c.moveToNext()) { |
| 1958 | * String sourceId = c.getString(0); |
| 1959 | * if (!c.isNull(1)) { |
| 1960 | * String mimeType = c.getString(2); |
| 1961 | * String data = c.getString(3); |
| 1962 | * ... |
| 1963 | * } |
| 1964 | * } |
| 1965 | * } finally { |
| 1966 | * c.close(); |
| 1967 | * } |
| 1968 | * </pre> |
| 1969 | * </p> |
| 1970 | * </dd> |
| 1971 | * </dl> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1972 | * <h2>Columns</h2> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1973 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1974 | * <table class="jd-sumtable"> |
| 1975 | * <tr> |
| 1976 | * <th colspan='4'>RawContacts</th> |
| 1977 | * </tr> |
| 1978 | * <tr> |
| 1979 | * <td>long</td> |
| 1980 | * <td>{@link #_ID}</td> |
| 1981 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1982 | * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words, |
| 1983 | * it is much better for a sync adapter to update a raw contact rather than to delete and |
| 1984 | * re-insert it.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1985 | * </tr> |
| 1986 | * <tr> |
| 1987 | * <td>long</td> |
| 1988 | * <td>{@link #CONTACT_ID}</td> |
| 1989 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1990 | * <td>The ID of the row in the {@link ContactsContract.Contacts} table |
| 1991 | * that this raw contact belongs |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1992 | * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled |
| 1993 | * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td> |
| 1994 | * </tr> |
| 1995 | * <tr> |
| 1996 | * <td>int</td> |
| 1997 | * <td>{@link #AGGREGATION_MODE}</td> |
| 1998 | * <td>read/write</td> |
| 1999 | * <td>A mechanism that allows programmatic control of the aggregation process. The allowed |
| 2000 | * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED} |
| 2001 | * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td> |
| 2002 | * </tr> |
| 2003 | * <tr> |
| 2004 | * <td>int</td> |
| 2005 | * <td>{@link #DELETED}</td> |
| 2006 | * <td>read/write</td> |
| 2007 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 2008 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 2009 | * called on a raw contact, it is marked for deletion and removed from its |
| 2010 | * aggregate contact. The sync adaptor deletes the raw contact on the server and |
| 2011 | * then calls ContactResolver.delete once more, this time passing the |
| 2012 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 2013 | * the data removal.</td> |
| 2014 | * </tr> |
| 2015 | * <tr> |
| 2016 | * <td>int</td> |
| 2017 | * <td>{@link #TIMES_CONTACTED}</td> |
| 2018 | * <td>read/write</td> |
| 2019 | * <td>The number of times the contact has been contacted. To have an effect |
| 2020 | * on the corresponding value of the aggregate contact, this field |
| 2021 | * should be set at the time the raw contact is inserted. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2022 | * After that, this value is typically updated via |
| 2023 | * {@link ContactsContract.Contacts#markAsContacted}.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2024 | * </tr> |
| 2025 | * <tr> |
| 2026 | * <td>long</td> |
| 2027 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 2028 | * <td>read/write</td> |
| 2029 | * <td>The timestamp of the last time the contact was contacted. To have an effect |
| 2030 | * on the corresponding value of the aggregate contact, this field |
| 2031 | * should be set at the time the raw contact is inserted. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2032 | * After that, this value is typically updated via |
| 2033 | * {@link ContactsContract.Contacts#markAsContacted}. |
| 2034 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2035 | * </tr> |
| 2036 | * <tr> |
| 2037 | * <td>int</td> |
| 2038 | * <td>{@link #STARRED}</td> |
| 2039 | * <td>read/write</td> |
| 2040 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2041 | * Changing this field immediately affects the corresponding aggregate contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2042 | * if any raw contacts in that aggregate contact are starred, then the contact |
| 2043 | * itself is marked as starred.</td> |
| 2044 | * </tr> |
| 2045 | * <tr> |
| 2046 | * <td>String</td> |
| 2047 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 2048 | * <td>read/write</td> |
| 2049 | * <td>A custom ringtone associated with a raw contact. Typically this is the |
| 2050 | * URI returned by an activity launched with the |
| 2051 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent. |
| 2052 | * To have an effect on the corresponding value of the aggregate contact, this field |
| 2053 | * 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] | 2054 | * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE |
| 2055 | * Contacts.CUSTOM_RINGTONE} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2056 | * instead.</td> |
| 2057 | * </tr> |
| 2058 | * <tr> |
| 2059 | * <td>int</td> |
| 2060 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 2061 | * <td>read/write</td> |
| 2062 | * <td>An indicator of whether calls from this raw contact should be forwarded |
| 2063 | * directly to voice mail ('1') or not ('0'). To have an effect |
| 2064 | * on the corresponding value of the aggregate contact, this field |
| 2065 | * should be set at the time the raw contact is inserted.</td> |
| 2066 | * </tr> |
| 2067 | * <tr> |
| 2068 | * <td>String</td> |
| 2069 | * <td>{@link #ACCOUNT_NAME}</td> |
| 2070 | * <td>read/write-once</td> |
| 2071 | * <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] | 2072 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
| 2073 | * For example, this will be the Gmail address if it is a Google account. |
| 2074 | * It should be set at the time |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2075 | * the raw contact is inserted and never changed afterwards.</td> |
| 2076 | * </tr> |
| 2077 | * <tr> |
| 2078 | * <td>String</td> |
| 2079 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 2080 | * <td>read/write-once</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2081 | * <td> |
| 2082 | * <p> |
| 2083 | * The type of account to which this row belongs, which when paired with |
| 2084 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 2085 | * It should be set at the time |
| 2086 | * the raw contact is inserted and never changed afterwards. |
| 2087 | * </p> |
| 2088 | * <p> |
| 2089 | * To ensure uniqueness, new account types should be chosen according to the |
| 2090 | * Java package naming convention. Thus a Google account is of type "com.google". |
| 2091 | * </p> |
| 2092 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2093 | * </tr> |
| 2094 | * <tr> |
| 2095 | * <td>String</td> |
| 2096 | * <td>{@link #SOURCE_ID}</td> |
| 2097 | * <td>read/write</td> |
| 2098 | * <td>String that uniquely identifies this row to its source account. |
| 2099 | * Typically it is set at the time the raw contact is inserted and never |
| 2100 | * changed afterwards. The one notable exception is a new raw contact: it |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2101 | * will have an account name and type, but no source id. This |
| 2102 | * indicates to the sync adapter that a new contact needs to be created |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2103 | * server-side and its ID stored in the corresponding SOURCE_ID field on |
| 2104 | * the phone. |
| 2105 | * </td> |
| 2106 | * </tr> |
| 2107 | * <tr> |
| 2108 | * <td>int</td> |
| 2109 | * <td>{@link #VERSION}</td> |
| 2110 | * <td>read-only</td> |
| 2111 | * <td>Version number that is updated whenever this row or its related data |
| 2112 | * changes. This field can be used for optimistic locking of a raw contact. |
| 2113 | * </td> |
| 2114 | * </tr> |
| 2115 | * <tr> |
| 2116 | * <td>int</td> |
| 2117 | * <td>{@link #DIRTY}</td> |
| 2118 | * <td>read/write</td> |
| 2119 | * <td>Flag indicating that {@link #VERSION} has changed, and this row needs |
| 2120 | * to be synchronized by its owning account. The value is set to "1" automatically |
| 2121 | * whenever the raw contact changes, unless the URI has the |
| 2122 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified. |
| 2123 | * The sync adapter should always supply this query parameter to prevent |
| 2124 | * unnecessary synchronization: user changes some data on the server, |
| 2125 | * the sync adapter updates the contact on the phone (without the |
| 2126 | * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag, |
| 2127 | * which triggers a sync to bring the changes to the server. |
| 2128 | * </td> |
| 2129 | * </tr> |
| 2130 | * <tr> |
| 2131 | * <td>String</td> |
| 2132 | * <td>{@link #SYNC1}</td> |
| 2133 | * <td>read/write</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2134 | * <td>Generic column provided for arbitrary use by sync adapters. |
| 2135 | * The content provider |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2136 | * stores this information on behalf of the sync adapter but does not |
| 2137 | * interpret it in any way. |
| 2138 | * </td> |
| 2139 | * </tr> |
| 2140 | * <tr> |
| 2141 | * <td>String</td> |
| 2142 | * <td>{@link #SYNC2}</td> |
| 2143 | * <td>read/write</td> |
| 2144 | * <td>Generic column for use by sync adapters. |
| 2145 | * </td> |
| 2146 | * </tr> |
| 2147 | * <tr> |
| 2148 | * <td>String</td> |
| 2149 | * <td>{@link #SYNC3}</td> |
| 2150 | * <td>read/write</td> |
| 2151 | * <td>Generic column for use by sync adapters. |
| 2152 | * </td> |
| 2153 | * </tr> |
| 2154 | * <tr> |
| 2155 | * <td>String</td> |
| 2156 | * <td>{@link #SYNC4}</td> |
| 2157 | * <td>read/write</td> |
| 2158 | * <td>Generic column for use by sync adapters. |
| 2159 | * </td> |
| 2160 | * </tr> |
| 2161 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2162 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2163 | public static final class RawContacts implements BaseColumns, RawContactsColumns, |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 2164 | ContactOptionsColumns, ContactNameColumns, SyncColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2165 | /** |
| 2166 | * This utility class cannot be instantiated |
| 2167 | */ |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 2168 | private RawContacts() { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2169 | } |
| 2170 | |
| 2171 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2172 | * The content:// style URI for this table, which requests a directory of |
| 2173 | * raw contact rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2174 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 2175 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2176 | |
| 2177 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2178 | * The MIME type of the results from {@link #CONTENT_URI} when a specific |
| 2179 | * ID value is not provided, and multiple raw contacts may be returned. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2180 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2181 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2182 | |
| 2183 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2184 | * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI}, |
| 2185 | * yielding a subdirectory of a single person. |
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 CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2188 | |
| 2189 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2190 | * Aggregation mode: aggregate immediately after insert or update operation(s) are complete. |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2191 | */ |
| 2192 | public static final int AGGREGATION_MODE_DEFAULT = 0; |
| 2193 | |
| 2194 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2195 | * Aggregation mode: aggregate at the time the raw contact is inserted/updated. |
| 2196 | * @deprecated Aggregation is synchronous, this historic value is a no-op |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2197 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2198 | @Deprecated |
Omari Stephens | bc9aa77 | 2009-09-08 19:10:53 -0700 | [diff] [blame] | 2199 | public static final int AGGREGATION_MODE_IMMEDIATE = 1; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2200 | |
| 2201 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2202 | * <p> |
| 2203 | * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later. |
| 2204 | * Changes to the raw contact will update the associated aggregate contact but will not |
| 2205 | * result in any change in how the contact is aggregated. Similar to |
| 2206 | * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding |
| 2207 | * {@link Contacts} aggregate. |
| 2208 | * </p> |
| 2209 | * <p> |
| 2210 | * This can be used to postpone aggregation until after a series of updates, for better |
| 2211 | * performance and/or user experience. |
| 2212 | * </p> |
| 2213 | * <p> |
| 2214 | * Note that changing |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2215 | * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2216 | * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any |
| 2217 | * subsequent |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2218 | * change to the raw contact's data will. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2219 | * </p> |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2220 | */ |
| 2221 | public static final int AGGREGATION_MODE_SUSPENDED = 2; |
| 2222 | |
| 2223 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2224 | * <p> |
| 2225 | * Aggregation mode: never aggregate this raw contact. The raw contact will not |
| 2226 | * have a corresponding {@link Contacts} aggregate and therefore will not be included in |
| 2227 | * {@link Contacts} query results. |
| 2228 | * </p> |
| 2229 | * <p> |
| 2230 | * For example, this mode can be used for a raw contact that is marked for deletion while |
| 2231 | * waiting for the deletion to occur on the server side. |
| 2232 | * </p> |
| 2233 | * |
| 2234 | * @see #AGGREGATION_MODE_SUSPENDED |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2235 | */ |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2236 | public static final int AGGREGATION_MODE_DISABLED = 3; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2237 | |
| 2238 | /** |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 2239 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 2240 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
| 2241 | * entry of the given {@link RawContacts} entry. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2242 | */ |
| 2243 | public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) { |
| 2244 | // TODO: use a lighter query by joining rawcontacts with contacts in provider |
| 2245 | final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY); |
| 2246 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 2247 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 2248 | }, null, null, null); |
| 2249 | |
| 2250 | Uri lookupUri = null; |
| 2251 | try { |
| 2252 | if (cursor != null && cursor.moveToFirst()) { |
| 2253 | final long contactId = cursor.getLong(0); |
| 2254 | final String lookupKey = cursor.getString(1); |
| 2255 | return Contacts.getLookupUri(contactId, lookupKey); |
| 2256 | } |
| 2257 | } finally { |
| 2258 | if (cursor != null) cursor.close(); |
| 2259 | } |
| 2260 | return lookupUri; |
| 2261 | } |
| 2262 | |
| 2263 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2264 | * 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] | 2265 | * {@link ContactsContract.Data} rows. To access this directory |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2266 | * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2267 | */ |
| 2268 | public static final class Data implements BaseColumns, DataColumns { |
| 2269 | /** |
| 2270 | * no public constructor since this is a utility class |
| 2271 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2272 | private Data() { |
| 2273 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2274 | |
| 2275 | /** |
| 2276 | * The directory twig for this sub-table |
| 2277 | */ |
| 2278 | public static final String CONTENT_DIRECTORY = "data"; |
| 2279 | } |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2280 | |
| 2281 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2282 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2283 | * 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] | 2284 | * {@link ContactsContract.Data} rows. To access this directory append |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2285 | * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2286 | * {@link RawContactsEntity} for a stand-alone table containing the same |
| 2287 | * data. |
| 2288 | * </p> |
| 2289 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2290 | * Entity has two ID fields: {@link #_ID} for the raw contact |
| 2291 | * and {@link #DATA_ID} for the data rows. |
| 2292 | * Entity always contains at least one row, even if there are no |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2293 | * 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] | 2294 | * null. |
| 2295 | * </p> |
| 2296 | * <p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2297 | * Using Entity should be preferred to using two separate queries: |
| 2298 | * RawContacts followed by Data. The reason is that Entity reads all |
| 2299 | * data for a raw contact in one transaction, so there is no possibility |
| 2300 | * of the data changing between the two queries. |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2301 | */ |
| 2302 | public static final class Entity implements BaseColumns, DataColumns { |
| 2303 | /** |
| 2304 | * no public constructor since this is a utility class |
| 2305 | */ |
| 2306 | private Entity() { |
| 2307 | } |
| 2308 | |
| 2309 | /** |
| 2310 | * The directory twig for this sub-table |
| 2311 | */ |
| 2312 | public static final String CONTENT_DIRECTORY = "entity"; |
| 2313 | |
| 2314 | /** |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 2315 | * 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] | 2316 | * data rows. |
| 2317 | * <P>Type: INTEGER</P> |
| 2318 | */ |
| 2319 | public static final String DATA_ID = "data_id"; |
| 2320 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2321 | |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2322 | /** |
| 2323 | * TODO: javadoc |
| 2324 | * @param cursor |
| 2325 | * @return |
| 2326 | */ |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2327 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 2328 | return new EntityIteratorImpl(cursor); |
| 2329 | } |
| 2330 | |
| 2331 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 2332 | private static final String[] DATA_KEYS = new String[]{ |
| 2333 | Data.DATA1, |
| 2334 | Data.DATA2, |
| 2335 | Data.DATA3, |
| 2336 | Data.DATA4, |
| 2337 | Data.DATA5, |
| 2338 | Data.DATA6, |
| 2339 | Data.DATA7, |
| 2340 | Data.DATA8, |
| 2341 | Data.DATA9, |
| 2342 | Data.DATA10, |
| 2343 | Data.DATA11, |
| 2344 | Data.DATA12, |
| 2345 | Data.DATA13, |
| 2346 | Data.DATA14, |
| 2347 | Data.DATA15, |
| 2348 | Data.SYNC1, |
| 2349 | Data.SYNC2, |
| 2350 | Data.SYNC3, |
| 2351 | Data.SYNC4}; |
| 2352 | |
| 2353 | public EntityIteratorImpl(Cursor cursor) { |
| 2354 | super(cursor); |
| 2355 | } |
| 2356 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 2357 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2358 | public android.content.Entity getEntityAndIncrementCursor(Cursor cursor) |
| 2359 | throws RemoteException { |
| 2360 | final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID); |
| 2361 | final long rawContactId = cursor.getLong(columnRawContactId); |
| 2362 | |
| 2363 | // we expect the cursor is already at the row we need to read from |
| 2364 | ContentValues cv = new ContentValues(); |
| 2365 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME); |
| 2366 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE); |
| 2367 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID); |
| 2368 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY); |
| 2369 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION); |
| 2370 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID); |
| 2371 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1); |
| 2372 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2); |
| 2373 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3); |
| 2374 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4); |
| 2375 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED); |
| 2376 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID); |
| 2377 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED); |
| 2378 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, IS_RESTRICTED); |
Dmitri Plotnikov | 918007b | 2010-01-20 12:12:11 -0800 | [diff] [blame] | 2379 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, NAME_VERIFIED); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2380 | android.content.Entity contact = new android.content.Entity(cv); |
| 2381 | |
| 2382 | // read data rows until the contact id changes |
| 2383 | do { |
| 2384 | if (rawContactId != cursor.getLong(columnRawContactId)) { |
| 2385 | break; |
| 2386 | } |
| 2387 | // add the data to to the contact |
| 2388 | cv = new ContentValues(); |
| 2389 | cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID))); |
| 2390 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 2391 | Data.RES_PACKAGE); |
| 2392 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE); |
| 2393 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY); |
| 2394 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, |
| 2395 | Data.IS_SUPER_PRIMARY); |
| 2396 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION); |
| 2397 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 2398 | CommonDataKinds.GroupMembership.GROUP_SOURCE_ID); |
| 2399 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 2400 | Data.DATA_VERSION); |
| 2401 | for (String key : DATA_KEYS) { |
| 2402 | final int columnIndex = cursor.getColumnIndexOrThrow(key); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 2403 | switch (cursor.getType(columnIndex)) { |
| 2404 | case Cursor.FIELD_TYPE_NULL: |
| 2405 | // don't put anything |
| 2406 | break; |
| 2407 | case Cursor.FIELD_TYPE_INTEGER: |
| 2408 | case Cursor.FIELD_TYPE_FLOAT: |
| 2409 | case Cursor.FIELD_TYPE_STRING: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 2410 | cv.put(key, cursor.getString(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 2411 | break; |
| 2412 | case Cursor.FIELD_TYPE_BLOB: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 2413 | cv.put(key, cursor.getBlob(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 2414 | break; |
| 2415 | default: |
| 2416 | throw new IllegalStateException("Invalid or unhandled data type"); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2417 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2418 | } |
| 2419 | contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv); |
| 2420 | } while (cursor.moveToNext()); |
| 2421 | |
| 2422 | return contact; |
| 2423 | } |
| 2424 | |
| 2425 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2426 | } |
| 2427 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2428 | /** |
| 2429 | * Social status update columns. |
| 2430 | * |
| 2431 | * @see StatusUpdates |
| 2432 | * @see ContactsContract.Data |
| 2433 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 2434 | protected interface StatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 2435 | /** |
Dmitri Plotnikov | a60479d | 2009-09-27 20:16:31 -0700 | [diff] [blame] | 2436 | * Contact's latest presence level. |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 2437 | * <P>Type: INTEGER (one of the values below)</P> |
| 2438 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 2439 | public static final String PRESENCE = "mode"; |
| 2440 | |
| 2441 | /** |
| 2442 | * @deprecated use {@link #PRESENCE} |
| 2443 | */ |
| 2444 | @Deprecated |
| 2445 | public static final String PRESENCE_STATUS = PRESENCE; |
| 2446 | |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2447 | /** |
| 2448 | * An allowed value of {@link #PRESENCE}. |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 2449 | */ |
| 2450 | int OFFLINE = 0; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2451 | |
| 2452 | /** |
| 2453 | * An allowed value of {@link #PRESENCE}. |
| 2454 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 2455 | int INVISIBLE = 1; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2456 | |
| 2457 | /** |
| 2458 | * An allowed value of {@link #PRESENCE}. |
| 2459 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 2460 | int AWAY = 2; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2461 | |
| 2462 | /** |
| 2463 | * An allowed value of {@link #PRESENCE}. |
| 2464 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 2465 | int IDLE = 3; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2466 | |
| 2467 | /** |
| 2468 | * An allowed value of {@link #PRESENCE}. |
| 2469 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 2470 | int DO_NOT_DISTURB = 4; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2471 | |
| 2472 | /** |
| 2473 | * An allowed value of {@link #PRESENCE}. |
| 2474 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 2475 | int AVAILABLE = 5; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 2476 | |
| 2477 | /** |
| 2478 | * Contact latest status update. |
| 2479 | * <p>Type: TEXT</p> |
| 2480 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 2481 | public static final String STATUS = "status"; |
| 2482 | |
| 2483 | /** |
| 2484 | * @deprecated use {@link #STATUS} |
| 2485 | */ |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2486 | @Deprecated |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 2487 | public static final String PRESENCE_CUSTOM_STATUS = STATUS; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 2488 | |
| 2489 | /** |
| 2490 | * The absolute time in milliseconds when the latest status was inserted/updated. |
| 2491 | * <p>Type: NUMBER</p> |
| 2492 | */ |
| 2493 | public static final String STATUS_TIMESTAMP = "status_ts"; |
| 2494 | |
| 2495 | /** |
| 2496 | * The package containing resources for this status: label and icon. |
| 2497 | * <p>Type: NUMBER</p> |
| 2498 | */ |
| 2499 | public static final String STATUS_RES_PACKAGE = "status_res_package"; |
| 2500 | |
| 2501 | /** |
| 2502 | * The resource ID of the label describing the source of the status update, e.g. "Google |
| 2503 | * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 2504 | * <p>Type: NUMBER</p> |
| 2505 | */ |
| 2506 | public static final String STATUS_LABEL = "status_label"; |
| 2507 | |
| 2508 | /** |
| 2509 | * The resource ID of the icon for the source of the status update. |
| 2510 | * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 2511 | * <p>Type: NUMBER</p> |
| 2512 | */ |
| 2513 | public static final String STATUS_ICON = "status_icon"; |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 2514 | |
| 2515 | /** |
| 2516 | * Contact's audio/video chat capability level. |
| 2517 | * <P>Type: INTEGER (one of the values below)</P> |
| 2518 | */ |
| 2519 | public static final String CHAT_CAPABILITY = "chat_capability"; |
| 2520 | |
| 2521 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 2522 | * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone |
| 2523 | * and speaker) |
| 2524 | */ |
| 2525 | public static final int CAPABILITY_HAS_VOICE = 1; |
| 2526 | |
| 2527 | /** |
| 2528 | * 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] | 2529 | * display a video feed. |
| 2530 | */ |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 2531 | public static final int CAPABILITY_HAS_VIDEO = 2; |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 2532 | |
| 2533 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 2534 | * 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] | 2535 | * camera that can be used for video chat (e.g. a front-facing camera on a phone). |
| 2536 | */ |
| 2537 | public static final int CAPABILITY_HAS_CAMERA = 4; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 2538 | } |
| 2539 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2540 | /** |
| 2541 | * Columns in the Data table. |
| 2542 | * |
| 2543 | * @see ContactsContract.Data |
| 2544 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 2545 | protected interface DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2546 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2547 | * The package name to use when creating {@link Resources} objects for |
| 2548 | * this data row. This value is only designed for use when building user |
| 2549 | * interfaces, and should not be used to infer the owner. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 2550 | * |
| 2551 | * @hide |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2552 | */ |
| 2553 | public static final String RES_PACKAGE = "res_package"; |
| 2554 | |
| 2555 | /** |
| 2556 | * The MIME type of the item represented by this row. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2557 | */ |
| 2558 | public static final String MIMETYPE = "mimetype"; |
| 2559 | |
| 2560 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2561 | * A reference to the {@link RawContacts#_ID} |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 2562 | * that this data belongs to. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2563 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 2564 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 2565 | |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 2566 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2567 | * 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] | 2568 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 2569 | */ |
| 2570 | public static final String IS_PRIMARY = "is_primary"; |
| 2571 | |
| 2572 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2573 | * Whether this is the primary entry of its kind for the aggregate |
| 2574 | * contact it belongs to. Any data record that is "super primary" must |
| 2575 | * also be "primary". |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 2576 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 2577 | */ |
| 2578 | public static final String IS_SUPER_PRIMARY = "is_super_primary"; |
| 2579 | |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 2580 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 2581 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 2582 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 2583 | * <P>Type: INTEGER</P> |
| 2584 | */ |
| 2585 | public static final String IS_READ_ONLY = "is_read_only"; |
| 2586 | |
| 2587 | /** |
Fred Quintana | c933fb6 | 2009-06-11 12:14:40 -0700 | [diff] [blame] | 2588 | * The version of this data record. This is a read-only value. The data column is |
| 2589 | * guaranteed to not change without the version going up. This value is monotonically |
| 2590 | * increasing. |
| 2591 | * <P>Type: INTEGER</P> |
| 2592 | */ |
| 2593 | public static final String DATA_VERSION = "data_version"; |
| 2594 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2595 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 2596 | public static final String DATA1 = "data1"; |
| 2597 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 2598 | public static final String DATA2 = "data2"; |
| 2599 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 2600 | public static final String DATA3 = "data3"; |
| 2601 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 2602 | public static final String DATA4 = "data4"; |
| 2603 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 2604 | public static final String DATA5 = "data5"; |
| 2605 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 2606 | public static final String DATA6 = "data6"; |
| 2607 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 2608 | public static final String DATA7 = "data7"; |
| 2609 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 2610 | public static final String DATA8 = "data8"; |
| 2611 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 2612 | public static final String DATA9 = "data9"; |
| 2613 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 2614 | public static final String DATA10 = "data10"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2615 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 2616 | public static final String DATA11 = "data11"; |
| 2617 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 2618 | public static final String DATA12 = "data12"; |
| 2619 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 2620 | public static final String DATA13 = "data13"; |
| 2621 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 2622 | public static final String DATA14 = "data14"; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2623 | /** |
| 2624 | * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention, |
| 2625 | * this field is used to store BLOBs (binary data). |
| 2626 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2627 | public static final String DATA15 = "data15"; |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 2628 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 2629 | /** Generic column for use by sync adapters. */ |
| 2630 | public static final String SYNC1 = "data_sync1"; |
| 2631 | /** Generic column for use by sync adapters. */ |
| 2632 | public static final String SYNC2 = "data_sync2"; |
| 2633 | /** Generic column for use by sync adapters. */ |
| 2634 | public static final String SYNC3 = "data_sync3"; |
| 2635 | /** Generic column for use by sync adapters. */ |
| 2636 | public static final String SYNC4 = "data_sync4"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2637 | } |
| 2638 | |
| 2639 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2640 | * Combines all columns returned by {@link ContactsContract.Data} table queries. |
| 2641 | * |
| 2642 | * @see ContactsContract.Data |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 2643 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 2644 | protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns, |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 2645 | RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns, |
| 2646 | ContactStatusColumns { |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 2647 | } |
| 2648 | |
| 2649 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2650 | * <p> |
| 2651 | * 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] | 2652 | * contact. Each row of the data table is typically used to store a single |
| 2653 | * piece of contact |
| 2654 | * information (such as a phone number) and its |
| 2655 | * associated metadata (such as whether it is a work or home number). |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2656 | * </p> |
| 2657 | * <h3>Data kinds</h3> |
| 2658 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2659 | * Data is a generic table that can hold any kind of contact data. |
| 2660 | * The kind of data stored in a given row is specified by the row's |
| 2661 | * {@link #MIMETYPE} value, which determines the meaning of the |
| 2662 | * generic columns {@link #DATA1} through |
| 2663 | * {@link #DATA15}. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2664 | * For example, if the data kind is |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2665 | * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column |
| 2666 | * {@link #DATA1} stores the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2667 | * phone number, but if the data kind is |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2668 | * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1} |
| 2669 | * stores the email address. |
| 2670 | * Sync adapters and applications can introduce their own data kinds. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2671 | * </p> |
| 2672 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2673 | * ContactsContract defines a small number of pre-defined data kinds, e.g. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2674 | * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a |
| 2675 | * convenience, these classes define data kind specific aliases for DATA1 etc. |
| 2676 | * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as |
| 2677 | * {@link ContactsContract.Data Data.DATA1}. |
| 2678 | * </p> |
| 2679 | * <p> |
| 2680 | * {@link #DATA1} is an indexed column and should be used for the data element that is |
| 2681 | * expected to be most frequently used in query selections. For example, in the |
| 2682 | * case of a row representing email addresses {@link #DATA1} should probably |
| 2683 | * be used for the email address itself, while {@link #DATA2} etc can be |
| 2684 | * used for auxiliary information like type of email address. |
| 2685 | * <p> |
| 2686 | * <p> |
| 2687 | * By convention, {@link #DATA15} is used for storing BLOBs (binary data). |
| 2688 | * </p> |
| 2689 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2690 | * The sync adapter for a given account type must correctly handle every data type |
| 2691 | * used in the corresponding raw contacts. Otherwise it could result in lost or |
| 2692 | * corrupted data. |
| 2693 | * </p> |
| 2694 | * <p> |
| 2695 | * 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] | 2696 | * 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] | 2697 | * "favorite song" to a raw contact owned by a Google account, it will not |
| 2698 | * get synced to the server, because the Google sync adapter does not know |
| 2699 | * how to handle this data kind. Thus new data kinds are typically |
| 2700 | * introduced along with new account types, i.e. new sync adapters. |
| 2701 | * </p> |
| 2702 | * <h3>Batch operations</h3> |
| 2703 | * <p> |
| 2704 | * Data rows can be inserted/updated/deleted using the traditional |
| 2705 | * {@link ContentResolver#insert}, {@link ContentResolver#update} and |
| 2706 | * {@link ContentResolver#delete} methods, however the newer mechanism based |
| 2707 | * on a batch of {@link ContentProviderOperation} will prove to be a better |
| 2708 | * choice in almost all cases. All operations in a batch are executed in a |
| 2709 | * single transaction, which ensures that the phone-side and server-side |
| 2710 | * state of a raw contact are always consistent. Also, the batch-based |
| 2711 | * approach is far more efficient: not only are the database operations |
| 2712 | * faster when executed in a single transaction, but also sending a batch of |
| 2713 | * commands to the content provider saves a lot of time on context switching |
| 2714 | * between your process and the process in which the content provider runs. |
| 2715 | * </p> |
| 2716 | * <p> |
| 2717 | * The flip side of using batched operations is that a large batch may lock |
| 2718 | * up the database for a long time preventing other applications from |
| 2719 | * accessing data and potentially causing ANRs ("Application Not Responding" |
| 2720 | * dialogs.) |
| 2721 | * </p> |
| 2722 | * <p> |
| 2723 | * To avoid such lockups of the database, make sure to insert "yield points" |
| 2724 | * in the batch. A yield point indicates to the content provider that before |
| 2725 | * executing the next operation it can commit the changes that have already |
| 2726 | * been made, yield to other requests, open another transaction and continue |
| 2727 | * processing operations. A yield point will not automatically commit the |
| 2728 | * transaction, but only if there is another request waiting on the |
| 2729 | * database. Normally a sync adapter should insert a yield point at the |
| 2730 | * beginning of each raw contact operation sequence in the batch. See |
| 2731 | * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}. |
| 2732 | * </p> |
| 2733 | * <h3>Operations</h3> |
| 2734 | * <dl> |
| 2735 | * <dt><b>Insert</b></dt> |
| 2736 | * <dd> |
| 2737 | * <p> |
| 2738 | * An individual data row can be inserted using the traditional |
| 2739 | * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows |
| 2740 | * should always be inserted as a batch. |
| 2741 | * </p> |
| 2742 | * <p> |
| 2743 | * An example of a traditional insert: |
| 2744 | * <pre> |
| 2745 | * ContentValues values = new ContentValues(); |
| 2746 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 2747 | * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); |
| 2748 | * values.put(Phone.NUMBER, "1-800-GOOG-411"); |
| 2749 | * values.put(Phone.TYPE, Phone.TYPE_CUSTOM); |
| 2750 | * values.put(Phone.LABEL, "free directory assistance"); |
| 2751 | * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values); |
| 2752 | * </pre> |
| 2753 | * <p> |
| 2754 | * The same done using ContentProviderOperations: |
| 2755 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 2756 | * ArrayList<ContentProviderOperation> ops = |
| 2757 | * new ArrayList<ContentProviderOperation>(); |
| 2758 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2759 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 2760 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 2761 | * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE) |
| 2762 | * .withValue(Phone.NUMBER, "1-800-GOOG-411") |
| 2763 | * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM) |
| 2764 | * .withValue(Phone.LABEL, "free directory assistance") |
| 2765 | * .build()); |
| 2766 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 2767 | * </pre> |
| 2768 | * </p> |
| 2769 | * <dt><b>Update</b></dt> |
| 2770 | * <dd> |
| 2771 | * <p> |
| 2772 | * Just as with insert, update can be done incrementally or as a batch, |
| 2773 | * the batch mode being the preferred method: |
| 2774 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 2775 | * ArrayList<ContentProviderOperation> ops = |
| 2776 | * new ArrayList<ContentProviderOperation>(); |
| 2777 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2778 | * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI) |
| 2779 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 2780 | * .withValue(Email.DATA, "somebody@android.com") |
| 2781 | * .build()); |
| 2782 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 2783 | * </pre> |
| 2784 | * </p> |
| 2785 | * </dd> |
| 2786 | * <dt><b>Delete</b></dt> |
| 2787 | * <dd> |
| 2788 | * <p> |
| 2789 | * Just as with insert and update, deletion can be done either using the |
| 2790 | * {@link ContentResolver#delete} method or using a ContentProviderOperation: |
| 2791 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 2792 | * ArrayList<ContentProviderOperation> ops = |
| 2793 | * new ArrayList<ContentProviderOperation>(); |
| 2794 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2795 | * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI) |
| 2796 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 2797 | * .build()); |
| 2798 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 2799 | * </pre> |
| 2800 | * </p> |
| 2801 | * </dd> |
| 2802 | * <dt><b>Query</b></dt> |
| 2803 | * <dd> |
| 2804 | * <p> |
| 2805 | * <dl> |
| 2806 | * <dt>Finding all Data of a given type for a given contact</dt> |
| 2807 | * <dd> |
| 2808 | * <pre> |
| 2809 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 2810 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 2811 | * Data.CONTACT_ID + "=?" + " AND " |
| 2812 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 2813 | * new String[] {String.valueOf(contactId)}, null); |
| 2814 | * </pre> |
| 2815 | * </p> |
| 2816 | * <p> |
| 2817 | * </dd> |
| 2818 | * <dt>Finding all Data of a given type for a given raw contact</dt> |
| 2819 | * <dd> |
| 2820 | * <pre> |
| 2821 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 2822 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 2823 | * Data.RAW_CONTACT_ID + "=?" + " AND " |
| 2824 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 2825 | * new String[] {String.valueOf(rawContactId)}, null); |
| 2826 | * </pre> |
| 2827 | * </dd> |
| 2828 | * <dt>Finding all Data for a given raw contact</dt> |
| 2829 | * <dd> |
| 2830 | * Most sync adapters will want to read all data rows for a raw contact |
| 2831 | * along with the raw contact itself. For that you should use the |
| 2832 | * {@link RawContactsEntity}. See also {@link RawContacts}. |
| 2833 | * </dd> |
| 2834 | * </dl> |
| 2835 | * </p> |
| 2836 | * </dd> |
| 2837 | * </dl> |
| 2838 | * <h2>Columns</h2> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2839 | * <p> |
| 2840 | * Many columns are available via a {@link Data#CONTENT_URI} query. For best performance you |
| 2841 | * should explicitly specify a projection to only those columns that you need. |
| 2842 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2843 | * <table class="jd-sumtable"> |
| 2844 | * <tr> |
| 2845 | * <th colspan='4'>Data</th> |
| 2846 | * </tr> |
| 2847 | * <tr> |
| 2848 | * <td style="width: 7em;">long</td> |
| 2849 | * <td style="width: 20em;">{@link #_ID}</td> |
| 2850 | * <td style="width: 5em;">read-only</td> |
| 2851 | * <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] | 2852 | * 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] | 2853 | * always do an update instead.</td> |
| 2854 | * </tr> |
| 2855 | * <tr> |
| 2856 | * <td>String</td> |
| 2857 | * <td>{@link #MIMETYPE}</td> |
| 2858 | * <td>read/write-once</td> |
| 2859 | * <td> |
| 2860 | * <p>The MIME type of the item represented by this row. Examples of common |
| 2861 | * MIME types are: |
| 2862 | * <ul> |
| 2863 | * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li> |
| 2864 | * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li> |
| 2865 | * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li> |
| 2866 | * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li> |
| 2867 | * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li> |
| 2868 | * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li> |
| 2869 | * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li> |
| 2870 | * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li> |
| 2871 | * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li> |
| 2872 | * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li> |
| 2873 | * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li> |
| 2874 | * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li> |
| 2875 | * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 2876 | * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2877 | * </ul> |
| 2878 | * </p> |
| 2879 | * </td> |
| 2880 | * </tr> |
| 2881 | * <tr> |
| 2882 | * <td>long</td> |
| 2883 | * <td>{@link #RAW_CONTACT_ID}</td> |
| 2884 | * <td>read/write-once</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2885 | * <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] | 2886 | * </tr> |
| 2887 | * <tr> |
| 2888 | * <td>int</td> |
| 2889 | * <td>{@link #IS_PRIMARY}</td> |
| 2890 | * <td>read/write</td> |
| 2891 | * <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] | 2892 | * "1" if true, "0" if false. |
| 2893 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2894 | * </tr> |
| 2895 | * <tr> |
| 2896 | * <td>int</td> |
| 2897 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 2898 | * <td>read/write</td> |
| 2899 | * <td>Whether this is the primary entry of its kind for the aggregate |
| 2900 | * 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] | 2901 | * also be "primary". For example, the super-primary entry may be |
| 2902 | * interpreted as the default contact value of its kind (for example, |
| 2903 | * the default phone number to use for the contact).</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2904 | * </tr> |
| 2905 | * <tr> |
| 2906 | * <td>int</td> |
| 2907 | * <td>{@link #DATA_VERSION}</td> |
| 2908 | * <td>read-only</td> |
| 2909 | * <td>The version of this data record. Whenever the data row changes |
| 2910 | * the version goes up. This value is monotonically increasing.</td> |
| 2911 | * </tr> |
| 2912 | * <tr> |
| 2913 | * <td>Any type</td> |
| 2914 | * <td> |
| 2915 | * {@link #DATA1}<br> |
| 2916 | * {@link #DATA2}<br> |
| 2917 | * {@link #DATA3}<br> |
| 2918 | * {@link #DATA4}<br> |
| 2919 | * {@link #DATA5}<br> |
| 2920 | * {@link #DATA6}<br> |
| 2921 | * {@link #DATA7}<br> |
| 2922 | * {@link #DATA8}<br> |
| 2923 | * {@link #DATA9}<br> |
| 2924 | * {@link #DATA10}<br> |
| 2925 | * {@link #DATA11}<br> |
| 2926 | * {@link #DATA12}<br> |
| 2927 | * {@link #DATA13}<br> |
| 2928 | * {@link #DATA14}<br> |
| 2929 | * {@link #DATA15} |
| 2930 | * </td> |
| 2931 | * <td>read/write</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2932 | * <td> |
| 2933 | * <p> |
| 2934 | * Generic data columns. The meaning of each column is determined by the |
| 2935 | * {@link #MIMETYPE}. By convention, {@link #DATA15} is used for storing |
| 2936 | * BLOBs (binary data). |
| 2937 | * </p> |
| 2938 | * <p> |
| 2939 | * Data columns whose meaning is not explicitly defined for a given MIMETYPE |
| 2940 | * should not be used. There is no guarantee that any sync adapter will |
| 2941 | * preserve them. Sync adapters themselves should not use such columns either, |
| 2942 | * but should instead use {@link #SYNC1}-{@link #SYNC4}. |
| 2943 | * </p> |
| 2944 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2945 | * </tr> |
| 2946 | * <tr> |
| 2947 | * <td>Any type</td> |
| 2948 | * <td> |
| 2949 | * {@link #SYNC1}<br> |
| 2950 | * {@link #SYNC2}<br> |
| 2951 | * {@link #SYNC3}<br> |
| 2952 | * {@link #SYNC4} |
| 2953 | * </td> |
| 2954 | * <td>read/write</td> |
| 2955 | * <td>Generic columns for use by sync adapters. For example, a Photo row |
| 2956 | * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error) |
| 2957 | * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td> |
| 2958 | * </tr> |
| 2959 | * </table> |
| 2960 | * |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 2961 | * <p> |
| 2962 | * Some columns from the most recent associated status update are also available |
| 2963 | * through an implicit join. |
| 2964 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2965 | * <table class="jd-sumtable"> |
| 2966 | * <tr> |
| 2967 | * <th colspan='4'>Join with {@link StatusUpdates}</th> |
| 2968 | * </tr> |
| 2969 | * <tr> |
| 2970 | * <td style="width: 7em;">int</td> |
| 2971 | * <td style="width: 20em;">{@link #PRESENCE}</td> |
| 2972 | * <td style="width: 5em;">read-only</td> |
| 2973 | * <td>IM presence status linked to this data row. Compare with |
| 2974 | * {@link #CONTACT_PRESENCE}, which contains the contact's presence across |
| 2975 | * all IM rows. See {@link StatusUpdates} for individual status definitions. |
| 2976 | * The provider may choose not to store this value |
| 2977 | * in persistent storage. The expectation is that presence status will be |
| 2978 | * updated on a regular basic. |
| 2979 | * </td> |
| 2980 | * </tr> |
| 2981 | * <tr> |
| 2982 | * <td>String</td> |
| 2983 | * <td>{@link #STATUS}</td> |
| 2984 | * <td>read-only</td> |
| 2985 | * <td>Latest status update linked with this data row.</td> |
| 2986 | * </tr> |
| 2987 | * <tr> |
| 2988 | * <td>long</td> |
| 2989 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 2990 | * <td>read-only</td> |
| 2991 | * <td>The absolute time in milliseconds when the latest status was |
| 2992 | * inserted/updated for this data row.</td> |
| 2993 | * </tr> |
| 2994 | * <tr> |
| 2995 | * <td>String</td> |
| 2996 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 2997 | * <td>read-only</td> |
| 2998 | * <td>The package containing resources for this status: label and icon.</td> |
| 2999 | * </tr> |
| 3000 | * <tr> |
| 3001 | * <td>long</td> |
| 3002 | * <td>{@link #STATUS_LABEL}</td> |
| 3003 | * <td>read-only</td> |
| 3004 | * <td>The resource ID of the label describing the source of status update linked |
| 3005 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 3006 | * </tr> |
| 3007 | * <tr> |
| 3008 | * <td>long</td> |
| 3009 | * <td>{@link #STATUS_ICON}</td> |
| 3010 | * <td>read-only</td> |
| 3011 | * <td>The resource ID of the icon for the source of the status update linked |
| 3012 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 3013 | * </tr> |
| 3014 | * </table> |
| 3015 | * |
| 3016 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3017 | * Some columns from the associated raw contact are also available through an |
| 3018 | * implicit join. The other columns are excluded as uninteresting in this |
| 3019 | * context. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3020 | * </p> |
| 3021 | * |
| 3022 | * <table class="jd-sumtable"> |
| 3023 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3024 | * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3025 | * </tr> |
| 3026 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3027 | * <td style="width: 7em;">long</td> |
| 3028 | * <td style="width: 20em;">{@link #CONTACT_ID}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3029 | * <td style="width: 5em;">read-only</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3030 | * <td>The id of the row in the {@link Contacts} table that this data belongs |
| 3031 | * to.</td> |
| 3032 | * </tr> |
| 3033 | * <tr> |
| 3034 | * <td>int</td> |
| 3035 | * <td>{@link #AGGREGATION_MODE}</td> |
| 3036 | * <td>read-only</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3037 | * <td>See {@link RawContacts}.</td> |
| 3038 | * </tr> |
| 3039 | * <tr> |
| 3040 | * <td>int</td> |
| 3041 | * <td>{@link #DELETED}</td> |
| 3042 | * <td>read-only</td> |
| 3043 | * <td>See {@link RawContacts}.</td> |
| 3044 | * </tr> |
| 3045 | * </table> |
| 3046 | * |
| 3047 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3048 | * The ID column for the associated aggregated contact table |
| 3049 | * {@link ContactsContract.Contacts} is available |
| 3050 | * via the implicit join to the {@link RawContacts} table, see above. |
| 3051 | * The remaining columns from this table are also |
| 3052 | * available, through an implicit join. This |
| 3053 | * facilitates lookup by |
| 3054 | * the value of a single data element, such as the email address. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3055 | * </p> |
| 3056 | * |
| 3057 | * <table class="jd-sumtable"> |
| 3058 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3059 | * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3060 | * </tr> |
| 3061 | * <tr> |
| 3062 | * <td style="width: 7em;">String</td> |
| 3063 | * <td style="width: 20em;">{@link #LOOKUP_KEY}</td> |
| 3064 | * <td style="width: 5em;">read-only</td> |
| 3065 | * <td>See {@link ContactsContract.Contacts}</td> |
| 3066 | * </tr> |
| 3067 | * <tr> |
| 3068 | * <td>String</td> |
| 3069 | * <td>{@link #DISPLAY_NAME}</td> |
| 3070 | * <td>read-only</td> |
| 3071 | * <td>See {@link ContactsContract.Contacts}</td> |
| 3072 | * </tr> |
| 3073 | * <tr> |
| 3074 | * <td>long</td> |
| 3075 | * <td>{@link #PHOTO_ID}</td> |
| 3076 | * <td>read-only</td> |
| 3077 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3078 | * </tr> |
| 3079 | * <tr> |
| 3080 | * <td>int</td> |
| 3081 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 3082 | * <td>read-only</td> |
| 3083 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3084 | * </tr> |
| 3085 | * <tr> |
| 3086 | * <td>int</td> |
| 3087 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 3088 | * <td>read-only</td> |
| 3089 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3090 | * </tr> |
| 3091 | * <tr> |
| 3092 | * <td>int</td> |
| 3093 | * <td>{@link #TIMES_CONTACTED}</td> |
| 3094 | * <td>read-only</td> |
| 3095 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3096 | * </tr> |
| 3097 | * <tr> |
| 3098 | * <td>long</td> |
| 3099 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 3100 | * <td>read-only</td> |
| 3101 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3102 | * </tr> |
| 3103 | * <tr> |
| 3104 | * <td>int</td> |
| 3105 | * <td>{@link #STARRED}</td> |
| 3106 | * <td>read-only</td> |
| 3107 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3108 | * </tr> |
| 3109 | * <tr> |
| 3110 | * <td>String</td> |
| 3111 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 3112 | * <td>read-only</td> |
| 3113 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3114 | * </tr> |
| 3115 | * <tr> |
| 3116 | * <td>int</td> |
| 3117 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 3118 | * <td>read-only</td> |
| 3119 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3120 | * </tr> |
| 3121 | * <tr> |
| 3122 | * <td>int</td> |
| 3123 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 3124 | * <td>read-only</td> |
| 3125 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3126 | * </tr> |
| 3127 | * <tr> |
| 3128 | * <td>String</td> |
| 3129 | * <td>{@link #CONTACT_STATUS}</td> |
| 3130 | * <td>read-only</td> |
| 3131 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3132 | * </tr> |
| 3133 | * <tr> |
| 3134 | * <td>long</td> |
| 3135 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 3136 | * <td>read-only</td> |
| 3137 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3138 | * </tr> |
| 3139 | * <tr> |
| 3140 | * <td>String</td> |
| 3141 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 3142 | * <td>read-only</td> |
| 3143 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3144 | * </tr> |
| 3145 | * <tr> |
| 3146 | * <td>long</td> |
| 3147 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 3148 | * <td>read-only</td> |
| 3149 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3150 | * </tr> |
| 3151 | * <tr> |
| 3152 | * <td>long</td> |
| 3153 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 3154 | * <td>read-only</td> |
| 3155 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3156 | * </tr> |
| 3157 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3158 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 3159 | public final static class Data implements DataColumnsWithJoins { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3160 | /** |
| 3161 | * This utility class cannot be instantiated |
| 3162 | */ |
| 3163 | private Data() {} |
| 3164 | |
| 3165 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3166 | * The content:// style URI for this table, which requests a directory |
| 3167 | * of data rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3168 | */ |
| 3169 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); |
| 3170 | |
| 3171 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3172 | * The MIME type of the results from {@link #CONTENT_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3173 | */ |
| 3174 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 3175 | |
| 3176 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3177 | * <p> |
Daisuke Miyakawa | f2e0d7b | 2009-09-28 06:28:26 -0700 | [diff] [blame] | 3178 | * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward |
| 3179 | * Data.CONTENT_URI contains only exportable data. |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3180 | * </p> |
| 3181 | * <p> |
Daisuke Miyakawa | f2e0d7b | 2009-09-28 06:28:26 -0700 | [diff] [blame] | 3182 | * This flag is useful (currently) only for vCard exporter in Contacts app, which |
| 3183 | * needs to exclude "un-exportable" data from available data to export, while |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3184 | * Contacts app itself has priviledge to access all data including "un-exportable" |
Daisuke Miyakawa | f2e0d7b | 2009-09-28 06:28:26 -0700 | [diff] [blame] | 3185 | * ones and providers return all of them regardless of the callers' intention. |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3186 | * </p> |
| 3187 | * <p> |
| 3188 | * Type: INTEGER |
| 3189 | * </p> |
Daisuke Miyakawa | f2e0d7b | 2009-09-28 06:28:26 -0700 | [diff] [blame] | 3190 | * |
| 3191 | * @hide Maybe available only in Eclair and not really ready for public use. |
| 3192 | * TODO: remove, or implement this feature completely. As of now (Eclair), |
| 3193 | * we only use this flag in queryEntities(), not query(). |
| 3194 | */ |
| 3195 | public static final String FOR_EXPORT_ONLY = "for_export_only"; |
| 3196 | |
| 3197 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3198 | * <p> |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 3199 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 3200 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3201 | * entry of the given {@link ContactsContract.Data} entry. |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3202 | * </p> |
| 3203 | * <p> |
| 3204 | * Returns the Uri for the contact in the first entry returned by |
| 3205 | * {@link ContentResolver#query(Uri, String[], String, String[], String)} |
| 3206 | * for the provided {@code dataUri}. If the query returns null or empty |
| 3207 | * results, silently returns null. |
| 3208 | * </p> |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 3209 | */ |
| 3210 | public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) { |
| 3211 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 3212 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 3213 | }, null, null, null); |
| 3214 | |
| 3215 | Uri lookupUri = null; |
| 3216 | try { |
| 3217 | if (cursor != null && cursor.moveToFirst()) { |
| 3218 | final long contactId = cursor.getLong(0); |
| 3219 | final String lookupKey = cursor.getString(1); |
| 3220 | return Contacts.getLookupUri(contactId, lookupKey); |
| 3221 | } |
| 3222 | } finally { |
| 3223 | if (cursor != null) cursor.close(); |
| 3224 | } |
| 3225 | return lookupUri; |
| 3226 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3227 | } |
| 3228 | |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 3229 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3230 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3231 | * 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] | 3232 | * an outer join of the raw_contacts table with the data table. It is a strictly |
| 3233 | * read-only table. |
| 3234 | * </p> |
| 3235 | * <p> |
| 3236 | * If a raw contact has data rows, the RawContactsEntity cursor will contain |
| 3237 | * a one row for each data row. If the raw contact has no data rows, the |
| 3238 | * cursor will still contain one row with the raw contact-level information |
| 3239 | * and nulls for data columns. |
| 3240 | * |
| 3241 | * <pre> |
| 3242 | * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId); |
| 3243 | * Cursor c = getContentResolver().query(entityUri, |
| 3244 | * new String[]{ |
| 3245 | * RawContactsEntity.SOURCE_ID, |
| 3246 | * RawContactsEntity.DATA_ID, |
| 3247 | * RawContactsEntity.MIMETYPE, |
| 3248 | * RawContactsEntity.DATA1 |
| 3249 | * }, null, null, null); |
| 3250 | * try { |
| 3251 | * while (c.moveToNext()) { |
| 3252 | * String sourceId = c.getString(0); |
| 3253 | * if (!c.isNull(1)) { |
| 3254 | * String mimeType = c.getString(2); |
| 3255 | * String data = c.getString(3); |
| 3256 | * ... |
| 3257 | * } |
| 3258 | * } |
| 3259 | * } finally { |
| 3260 | * c.close(); |
| 3261 | * } |
| 3262 | * </pre> |
| 3263 | * |
| 3264 | * <h3>Columns</h3> |
| 3265 | * RawContactsEntity has a combination of RawContact and Data columns. |
| 3266 | * |
| 3267 | * <table class="jd-sumtable"> |
| 3268 | * <tr> |
| 3269 | * <th colspan='4'>RawContacts</th> |
| 3270 | * </tr> |
| 3271 | * <tr> |
| 3272 | * <td style="width: 7em;">long</td> |
| 3273 | * <td style="width: 20em;">{@link #_ID}</td> |
| 3274 | * <td style="width: 5em;">read-only</td> |
| 3275 | * <td>Raw contact row ID. See {@link RawContacts}.</td> |
| 3276 | * </tr> |
| 3277 | * <tr> |
| 3278 | * <td>long</td> |
| 3279 | * <td>{@link #CONTACT_ID}</td> |
| 3280 | * <td>read-only</td> |
| 3281 | * <td>See {@link RawContacts}.</td> |
| 3282 | * </tr> |
| 3283 | * <tr> |
| 3284 | * <td>int</td> |
| 3285 | * <td>{@link #AGGREGATION_MODE}</td> |
| 3286 | * <td>read-only</td> |
| 3287 | * <td>See {@link RawContacts}.</td> |
| 3288 | * </tr> |
| 3289 | * <tr> |
| 3290 | * <td>int</td> |
| 3291 | * <td>{@link #DELETED}</td> |
| 3292 | * <td>read-only</td> |
| 3293 | * <td>See {@link RawContacts}.</td> |
| 3294 | * </tr> |
| 3295 | * </table> |
| 3296 | * |
| 3297 | * <table class="jd-sumtable"> |
| 3298 | * <tr> |
| 3299 | * <th colspan='4'>Data</th> |
| 3300 | * </tr> |
| 3301 | * <tr> |
| 3302 | * <td style="width: 7em;">long</td> |
| 3303 | * <td style="width: 20em;">{@link #DATA_ID}</td> |
| 3304 | * <td style="width: 5em;">read-only</td> |
| 3305 | * <td>Data row ID. It will be null if the raw contact has no data rows.</td> |
| 3306 | * </tr> |
| 3307 | * <tr> |
| 3308 | * <td>String</td> |
| 3309 | * <td>{@link #MIMETYPE}</td> |
| 3310 | * <td>read-only</td> |
| 3311 | * <td>See {@link ContactsContract.Data}.</td> |
| 3312 | * </tr> |
| 3313 | * <tr> |
| 3314 | * <td>int</td> |
| 3315 | * <td>{@link #IS_PRIMARY}</td> |
| 3316 | * <td>read-only</td> |
| 3317 | * <td>See {@link ContactsContract.Data}.</td> |
| 3318 | * </tr> |
| 3319 | * <tr> |
| 3320 | * <td>int</td> |
| 3321 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 3322 | * <td>read-only</td> |
| 3323 | * <td>See {@link ContactsContract.Data}.</td> |
| 3324 | * </tr> |
| 3325 | * <tr> |
| 3326 | * <td>int</td> |
| 3327 | * <td>{@link #DATA_VERSION}</td> |
| 3328 | * <td>read-only</td> |
| 3329 | * <td>See {@link ContactsContract.Data}.</td> |
| 3330 | * </tr> |
| 3331 | * <tr> |
| 3332 | * <td>Any type</td> |
| 3333 | * <td> |
| 3334 | * {@link #DATA1}<br> |
| 3335 | * {@link #DATA2}<br> |
| 3336 | * {@link #DATA3}<br> |
| 3337 | * {@link #DATA4}<br> |
| 3338 | * {@link #DATA5}<br> |
| 3339 | * {@link #DATA6}<br> |
| 3340 | * {@link #DATA7}<br> |
| 3341 | * {@link #DATA8}<br> |
| 3342 | * {@link #DATA9}<br> |
| 3343 | * {@link #DATA10}<br> |
| 3344 | * {@link #DATA11}<br> |
| 3345 | * {@link #DATA12}<br> |
| 3346 | * {@link #DATA13}<br> |
| 3347 | * {@link #DATA14}<br> |
| 3348 | * {@link #DATA15} |
| 3349 | * </td> |
| 3350 | * <td>read-only</td> |
| 3351 | * <td>See {@link ContactsContract.Data}.</td> |
| 3352 | * </tr> |
| 3353 | * <tr> |
| 3354 | * <td>Any type</td> |
| 3355 | * <td> |
| 3356 | * {@link #SYNC1}<br> |
| 3357 | * {@link #SYNC2}<br> |
| 3358 | * {@link #SYNC3}<br> |
| 3359 | * {@link #SYNC4} |
| 3360 | * </td> |
| 3361 | * <td>read-only</td> |
| 3362 | * <td>See {@link ContactsContract.Data}.</td> |
| 3363 | * </tr> |
| 3364 | * </table> |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 3365 | */ |
| 3366 | public final static class RawContactsEntity |
| 3367 | implements BaseColumns, DataColumns, RawContactsColumns { |
| 3368 | /** |
| 3369 | * This utility class cannot be instantiated |
| 3370 | */ |
| 3371 | private RawContactsEntity() {} |
| 3372 | |
| 3373 | /** |
| 3374 | * The content:// style URI for this table |
| 3375 | */ |
| 3376 | public static final Uri CONTENT_URI = |
| 3377 | Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities"); |
| 3378 | |
| 3379 | /** |
| 3380 | * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities. |
| 3381 | */ |
| 3382 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity"; |
| 3383 | |
| 3384 | /** |
| 3385 | * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward |
| 3386 | * Data.CONTENT_URI contains only exportable data. |
| 3387 | * |
| 3388 | * This flag is useful (currently) only for vCard exporter in Contacts app, which |
| 3389 | * needs to exclude "un-exportable" data from available data to export, while |
| 3390 | * Contacts app itself has priviledge to access all data including "un-expotable" |
| 3391 | * ones and providers return all of them regardless of the callers' intention. |
| 3392 | * <P>Type: INTEGER</p> |
| 3393 | * |
| 3394 | * @hide Maybe available only in Eclair and not really ready for public use. |
| 3395 | * TODO: remove, or implement this feature completely. As of now (Eclair), |
| 3396 | * we only use this flag in queryEntities(), not query(). |
| 3397 | */ |
| 3398 | public static final String FOR_EXPORT_ONLY = "for_export_only"; |
| 3399 | |
| 3400 | /** |
| 3401 | * The ID of the data column. The value will be null if this raw contact has no data rows. |
| 3402 | * <P>Type: INTEGER</P> |
| 3403 | */ |
| 3404 | public static final String DATA_ID = "data_id"; |
| 3405 | } |
| 3406 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3407 | /** |
| 3408 | * @see PhoneLookup |
| 3409 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 3410 | protected interface PhoneLookupColumns { |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 3411 | /** |
| 3412 | * The phone number as the user entered it. |
| 3413 | * <P>Type: TEXT</P> |
| 3414 | */ |
| 3415 | public static final String NUMBER = "number"; |
| 3416 | |
| 3417 | /** |
| 3418 | * The type of phone number, for example Home or Work. |
| 3419 | * <P>Type: INTEGER</P> |
| 3420 | */ |
| 3421 | public static final String TYPE = "type"; |
| 3422 | |
| 3423 | /** |
| 3424 | * The user defined label for the phone number. |
| 3425 | * <P>Type: TEXT</P> |
| 3426 | */ |
| 3427 | public static final String LABEL = "label"; |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 3428 | |
| 3429 | /** |
| 3430 | * The phone number's E164 representation. |
| 3431 | * <P>Type: TEXT</P> |
| 3432 | * |
| 3433 | * @hide |
| 3434 | */ |
| 3435 | public static final String NORMALIZED_NUMBER = "normalized_number"; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 3436 | } |
| 3437 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3438 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 3439 | * 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] | 3440 | * 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] | 3441 | * want to find to {@link #CONTENT_FILTER_URI}. This query is highly |
| 3442 | * optimized. |
| 3443 | * <pre> |
| 3444 | * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); |
| 3445 | * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,... |
| 3446 | * </pre> |
| 3447 | * |
| 3448 | * <h3>Columns</h3> |
| 3449 | * |
| 3450 | * <table class="jd-sumtable"> |
| 3451 | * <tr> |
| 3452 | * <th colspan='4'>PhoneLookup</th> |
| 3453 | * </tr> |
| 3454 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3455 | * <td>String</td> |
| 3456 | * <td>{@link #NUMBER}</td> |
| 3457 | * <td>read-only</td> |
| 3458 | * <td>Phone number.</td> |
| 3459 | * </tr> |
| 3460 | * <tr> |
| 3461 | * <td>String</td> |
| 3462 | * <td>{@link #TYPE}</td> |
| 3463 | * <td>read-only</td> |
| 3464 | * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td> |
| 3465 | * </tr> |
| 3466 | * <tr> |
| 3467 | * <td>String</td> |
| 3468 | * <td>{@link #LABEL}</td> |
| 3469 | * <td>read-only</td> |
| 3470 | * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td> |
| 3471 | * </tr> |
| 3472 | * </table> |
| 3473 | * <p> |
| 3474 | * Columns from the Contacts table are also available through a join. |
| 3475 | * </p> |
| 3476 | * <table class="jd-sumtable"> |
| 3477 | * <tr> |
| 3478 | * <th colspan='4'>Join with {@link Contacts}</th> |
| 3479 | * </tr> |
| 3480 | * <tr> |
Dmitri Plotnikov | 817b3f9 | 2011-01-09 17:07:13 -0800 | [diff] [blame] | 3481 | * <td>long</td> |
| 3482 | * <td>{@link #_ID}</td> |
| 3483 | * <td>read-only</td> |
| 3484 | * <td>Contact ID.</td> |
| 3485 | * </tr> |
| 3486 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3487 | * <td>String</td> |
| 3488 | * <td>{@link #LOOKUP_KEY}</td> |
| 3489 | * <td>read-only</td> |
| 3490 | * <td>See {@link ContactsContract.Contacts}</td> |
| 3491 | * </tr> |
| 3492 | * <tr> |
| 3493 | * <td>String</td> |
| 3494 | * <td>{@link #DISPLAY_NAME}</td> |
| 3495 | * <td>read-only</td> |
| 3496 | * <td>See {@link ContactsContract.Contacts}</td> |
| 3497 | * </tr> |
| 3498 | * <tr> |
| 3499 | * <td>long</td> |
| 3500 | * <td>{@link #PHOTO_ID}</td> |
| 3501 | * <td>read-only</td> |
| 3502 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3503 | * </tr> |
| 3504 | * <tr> |
| 3505 | * <td>int</td> |
| 3506 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 3507 | * <td>read-only</td> |
| 3508 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3509 | * </tr> |
| 3510 | * <tr> |
| 3511 | * <td>int</td> |
| 3512 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 3513 | * <td>read-only</td> |
| 3514 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3515 | * </tr> |
| 3516 | * <tr> |
| 3517 | * <td>int</td> |
| 3518 | * <td>{@link #TIMES_CONTACTED}</td> |
| 3519 | * <td>read-only</td> |
| 3520 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3521 | * </tr> |
| 3522 | * <tr> |
| 3523 | * <td>long</td> |
| 3524 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 3525 | * <td>read-only</td> |
| 3526 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3527 | * </tr> |
| 3528 | * <tr> |
| 3529 | * <td>int</td> |
| 3530 | * <td>{@link #STARRED}</td> |
| 3531 | * <td>read-only</td> |
| 3532 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3533 | * </tr> |
| 3534 | * <tr> |
| 3535 | * <td>String</td> |
| 3536 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 3537 | * <td>read-only</td> |
| 3538 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3539 | * </tr> |
| 3540 | * <tr> |
| 3541 | * <td>int</td> |
| 3542 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 3543 | * <td>read-only</td> |
| 3544 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 3545 | * </tr> |
| 3546 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3547 | */ |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 3548 | public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, |
| 3549 | ContactsColumns, ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3550 | /** |
| 3551 | * This utility class cannot be instantiated |
| 3552 | */ |
| 3553 | private PhoneLookup() {} |
| 3554 | |
| 3555 | /** |
| 3556 | * The content:// style URI for this table. Append the phone number you want to lookup |
| 3557 | * to this URI and query it to perform a lookup. For example: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3558 | * <pre> |
| 3559 | * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, Uri.encode(phoneNumber)); |
| 3560 | * </pre> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3561 | */ |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3562 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 3563 | "phone_lookup"); |
Dmitri Plotnikov | 0b0b8a8 | 2010-03-04 18:20:08 -0800 | [diff] [blame] | 3564 | |
| 3565 | /** |
| 3566 | * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows. |
| 3567 | * |
| 3568 | * @hide |
| 3569 | */ |
| 3570 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3571 | } |
| 3572 | |
| 3573 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3574 | * Additional data mixed in with {@link StatusColumns} to link |
| 3575 | * back to specific {@link ContactsContract.Data#_ID} entries. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3576 | * |
| 3577 | * @see StatusUpdates |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3578 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 3579 | protected interface PresenceColumns { |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 3580 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3581 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3582 | * Reference to the {@link Data#_ID} entry that owns this presence. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 3583 | * <P>Type: INTEGER</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3584 | */ |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 3585 | public static final String DATA_ID = "presence_data_id"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3586 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3587 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3588 | * See {@link CommonDataKinds.Im} for a list of defined protocol constants. |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 3589 | * <p>Type: NUMBER</p> |
| 3590 | */ |
| 3591 | public static final String PROTOCOL = "protocol"; |
| 3592 | |
| 3593 | /** |
| 3594 | * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 3595 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 3596 | * omitted if {@link #PROTOCOL} value is not |
| 3597 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. |
| 3598 | * |
| 3599 | * <p>Type: NUMBER</p> |
| 3600 | */ |
| 3601 | public static final String CUSTOM_PROTOCOL = "custom_protocol"; |
| 3602 | |
| 3603 | /** |
| 3604 | * The IM handle the presence item is for. The handle is scoped to |
| 3605 | * {@link #PROTOCOL}. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 3606 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3607 | */ |
| 3608 | public static final String IM_HANDLE = "im_handle"; |
| 3609 | |
| 3610 | /** |
| 3611 | * 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] | 3612 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3613 | */ |
| 3614 | public static final String IM_ACCOUNT = "im_account"; |
| 3615 | } |
| 3616 | |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3617 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3618 | * <p> |
| 3619 | * A status update is linked to a {@link ContactsContract.Data} row and captures |
| 3620 | * the user's latest status update via the corresponding source, e.g. |
| 3621 | * "Having lunch" via "Google Talk". |
| 3622 | * </p> |
| 3623 | * <p> |
| 3624 | * There are two ways a status update can be inserted: by explicitly linking |
| 3625 | * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row |
| 3626 | * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 3627 | * {@link #IM_HANDLE}. There is no difference between insert and update, you can use |
| 3628 | * either. |
| 3629 | * </p> |
| 3630 | * <p> |
| 3631 | * You cannot use {@link ContentResolver#update} to change a status, but |
| 3632 | * {@link ContentResolver#insert} will replace the latests status if it already |
| 3633 | * exists. |
| 3634 | * </p> |
| 3635 | * <p> |
| 3636 | * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses |
| 3637 | * for multiple contacts at once. |
| 3638 | * </p> |
| 3639 | * |
| 3640 | * <h3>Columns</h3> |
| 3641 | * <table class="jd-sumtable"> |
| 3642 | * <tr> |
| 3643 | * <th colspan='4'>StatusUpdates</th> |
| 3644 | * </tr> |
| 3645 | * <tr> |
| 3646 | * <td>long</td> |
| 3647 | * <td>{@link #DATA_ID}</td> |
| 3648 | * <td>read/write</td> |
| 3649 | * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this |
| 3650 | * field is <i>not</i> specified, the provider will attempt to find a data row |
| 3651 | * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 3652 | * {@link #IM_HANDLE} columns. |
| 3653 | * </td> |
| 3654 | * </tr> |
| 3655 | * <tr> |
| 3656 | * <td>long</td> |
| 3657 | * <td>{@link #PROTOCOL}</td> |
| 3658 | * <td>read/write</td> |
| 3659 | * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td> |
| 3660 | * </tr> |
| 3661 | * <tr> |
| 3662 | * <td>String</td> |
| 3663 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 3664 | * <td>read/write</td> |
| 3665 | * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 3666 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 3667 | * omitted if {@link #PROTOCOL} value is not |
| 3668 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td> |
| 3669 | * </tr> |
| 3670 | * <tr> |
| 3671 | * <td>String</td> |
| 3672 | * <td>{@link #IM_HANDLE}</td> |
| 3673 | * <td>read/write</td> |
| 3674 | * <td> The IM handle the presence item is for. The handle is scoped to |
| 3675 | * {@link #PROTOCOL}.</td> |
| 3676 | * </tr> |
| 3677 | * <tr> |
| 3678 | * <td>String</td> |
| 3679 | * <td>{@link #IM_ACCOUNT}</td> |
| 3680 | * <td>read/write</td> |
| 3681 | * <td>The IM account for the local user that the presence data came from.</td> |
| 3682 | * </tr> |
| 3683 | * <tr> |
| 3684 | * <td>int</td> |
| 3685 | * <td>{@link #PRESENCE}</td> |
| 3686 | * <td>read/write</td> |
| 3687 | * <td>Contact IM presence status. The allowed values are: |
| 3688 | * <p> |
| 3689 | * <ul> |
| 3690 | * <li>{@link #OFFLINE}</li> |
| 3691 | * <li>{@link #INVISIBLE}</li> |
| 3692 | * <li>{@link #AWAY}</li> |
| 3693 | * <li>{@link #IDLE}</li> |
| 3694 | * <li>{@link #DO_NOT_DISTURB}</li> |
| 3695 | * <li>{@link #AVAILABLE}</li> |
| 3696 | * </ul> |
| 3697 | * </p> |
| 3698 | * <p> |
| 3699 | * Since presence status is inherently volatile, the content provider |
| 3700 | * may choose not to store this field in long-term storage. |
| 3701 | * </p> |
| 3702 | * </td> |
| 3703 | * </tr> |
| 3704 | * <tr> |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3705 | * <td>int</td> |
| 3706 | * <td>{@link #CHAT_CAPABILITY}</td> |
| 3707 | * <td>read/write</td> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3708 | * <td>Contact IM chat compatibility value. The allowed values combinations of the following |
| 3709 | * 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] | 3710 | * <p> |
| 3711 | * <ul> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3712 | * <li>{@link #CAPABILITY_HAS_VIDEO}</li> |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3713 | * <li>{@link #CAPABILITY_HAS_VOICE}</li> |
| 3714 | * <li>{@link #CAPABILITY_HAS_CAMERA}</li> |
| 3715 | * </ul> |
| 3716 | * </p> |
| 3717 | * <p> |
| 3718 | * Since chat compatibility is inherently volatile as the contact's availability moves from |
| 3719 | * one device to another, the content provider may choose not to store this field in long-term |
| 3720 | * storage. |
| 3721 | * </p> |
| 3722 | * </td> |
| 3723 | * </tr> |
| 3724 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3725 | * <td>String</td> |
| 3726 | * <td>{@link #STATUS}</td> |
| 3727 | * <td>read/write</td> |
| 3728 | * <td>Contact's latest status update, e.g. "having toast for breakfast"</td> |
| 3729 | * </tr> |
| 3730 | * <tr> |
| 3731 | * <td>long</td> |
| 3732 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 3733 | * <td>read/write</td> |
| 3734 | * <td>The absolute time in milliseconds when the status was |
| 3735 | * entered by the user. If this value is not provided, the provider will follow |
| 3736 | * this logic: if there was no prior status update, the value will be left as null. |
| 3737 | * If there was a prior status update, the provider will default this field |
| 3738 | * to the current time.</td> |
| 3739 | * </tr> |
| 3740 | * <tr> |
| 3741 | * <td>String</td> |
| 3742 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 3743 | * <td>read/write</td> |
| 3744 | * <td> The package containing resources for this status: label and icon.</td> |
| 3745 | * </tr> |
| 3746 | * <tr> |
| 3747 | * <td>long</td> |
| 3748 | * <td>{@link #STATUS_LABEL}</td> |
| 3749 | * <td>read/write</td> |
| 3750 | * <td>The resource ID of the label describing the source of contact status, |
| 3751 | * e.g. "Google Talk". This resource is scoped by the |
| 3752 | * {@link #STATUS_RES_PACKAGE}.</td> |
| 3753 | * </tr> |
| 3754 | * <tr> |
| 3755 | * <td>long</td> |
| 3756 | * <td>{@link #STATUS_ICON}</td> |
| 3757 | * <td>read/write</td> |
| 3758 | * <td>The resource ID of the icon for the source of contact status. This |
| 3759 | * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 3760 | * </tr> |
| 3761 | * </table> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3762 | */ |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3763 | public static class StatusUpdates implements StatusColumns, PresenceColumns { |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 3764 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3765 | /** |
| 3766 | * This utility class cannot be instantiated |
| 3767 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3768 | private StatusUpdates() {} |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3769 | |
| 3770 | /** |
| 3771 | * The content:// style URI for this table |
| 3772 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3773 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates"); |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 3774 | |
| 3775 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3776 | * Gets the resource ID for the proper presence icon. |
| 3777 | * |
| 3778 | * @param status the status to get the icon for |
| 3779 | * @return the resource ID for the proper presence icon |
| 3780 | */ |
| 3781 | public static final int getPresenceIconResourceId(int status) { |
| 3782 | switch (status) { |
| 3783 | case AVAILABLE: |
| 3784 | return android.R.drawable.presence_online; |
| 3785 | case IDLE: |
| 3786 | case AWAY: |
| 3787 | return android.R.drawable.presence_away; |
| 3788 | case DO_NOT_DISTURB: |
| 3789 | return android.R.drawable.presence_busy; |
| 3790 | case INVISIBLE: |
| 3791 | return android.R.drawable.presence_invisible; |
| 3792 | case OFFLINE: |
| 3793 | default: |
| 3794 | return android.R.drawable.presence_offline; |
| 3795 | } |
| 3796 | } |
| 3797 | |
| 3798 | /** |
Evan Millar | c043752 | 2009-06-23 17:31:05 -0700 | [diff] [blame] | 3799 | * Returns the precedence of the status code the higher number being the higher precedence. |
| 3800 | * |
| 3801 | * @param status The status code. |
| 3802 | * @return An integer representing the precedence, 0 being the lowest. |
| 3803 | */ |
| 3804 | public static final int getPresencePrecedence(int status) { |
| 3805 | // Keep this function here incase we want to enforce a different precedence than the |
| 3806 | // natural order of the status constants. |
| 3807 | return status; |
| 3808 | } |
| 3809 | |
| 3810 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3811 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3812 | * status update details. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3813 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3814 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3815 | |
| 3816 | /** |
| 3817 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3818 | * status update detail. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 3819 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3820 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update"; |
| 3821 | } |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 3822 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3823 | /** |
| 3824 | * @deprecated This old name was never meant to be made public. Do not use. |
| 3825 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3826 | @Deprecated |
| 3827 | public static final class Presence extends StatusUpdates { |
| 3828 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3829 | } |
| 3830 | |
| 3831 | /** |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 3832 | * Additional column returned by the {@link Contacts#CONTENT_FILTER_URI} providing the |
| 3833 | * explanation of why the filter matched the contact. Specifically, it contains the |
| 3834 | * data elements that matched the query. The overall number of words in the snippet |
| 3835 | * can be capped. |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 3836 | * |
| 3837 | * @hide |
| 3838 | */ |
| 3839 | public static class SearchSnippetColumns { |
| 3840 | |
| 3841 | /** |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 3842 | * The search snippet constructed according to the SQLite rules, see |
| 3843 | * http://www.sqlite.org/fts3.html#snippet |
| 3844 | * <p> |
| 3845 | * The snippet may contain (parts of) several data elements comprising |
| 3846 | * the contact. |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 3847 | * |
| 3848 | * @hide |
| 3849 | */ |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 3850 | public static final String SNIPPET = "snippet"; |
| 3851 | |
| 3852 | |
| 3853 | /** |
| 3854 | * Comma-separated parameters for the generation of the snippet: |
| 3855 | * <ul> |
| 3856 | * <li>The "start match" text. Default is <b></li> |
| 3857 | * <li>The "end match" text. Default is </b></li> |
| 3858 | * <li>The "ellipsis" text. Default is <b>...</b></li> |
| 3859 | * <li>Maximum number of tokens to include in the snippet. Can be either |
| 3860 | * a positive or a negative number: A positive number indicates how many |
| 3861 | * tokens can be returned in total. A negative number indicates how many |
| 3862 | * tokens can be returned per occurrence of the search terms.</li> |
| 3863 | * </ul> |
| 3864 | * |
| 3865 | * @hide |
| 3866 | */ |
| 3867 | public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args"; |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 3868 | } |
| 3869 | |
| 3870 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3871 | * Container for definitions of common data types stored in the {@link ContactsContract.Data} |
| 3872 | * table. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3873 | */ |
| 3874 | public static final class CommonDataKinds { |
| 3875 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 3876 | * This utility class cannot be instantiated |
| 3877 | */ |
| 3878 | private CommonDataKinds() {} |
| 3879 | |
| 3880 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 3881 | * The {@link Data#RES_PACKAGE} value for common data that should be |
| 3882 | * shown using a default style. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 3883 | * |
| 3884 | * @hide RES_PACKAGE is hidden |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3885 | */ |
| 3886 | public static final String PACKAGE_COMMON = "common"; |
| 3887 | |
| 3888 | /** |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 3889 | * The base types that all "Typed" data kinds support. |
| 3890 | */ |
| 3891 | public interface BaseTypes { |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 3892 | /** |
| 3893 | * A custom type. The custom label should be supplied by user. |
| 3894 | */ |
| 3895 | public static int TYPE_CUSTOM = 0; |
| 3896 | } |
| 3897 | |
| 3898 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3899 | * Columns common across the specific types. |
| 3900 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 3901 | protected interface CommonColumns extends BaseTypes { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3902 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3903 | * The data for the contact method. |
| 3904 | * <P>Type: TEXT</P> |
| 3905 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 3906 | public static final String DATA = DataColumns.DATA1; |
| 3907 | |
| 3908 | /** |
| 3909 | * The type of data, for example Home or Work. |
| 3910 | * <P>Type: INTEGER</P> |
| 3911 | */ |
| 3912 | public static final String TYPE = DataColumns.DATA2; |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 3913 | |
| 3914 | /** |
| 3915 | * The user defined label for the the contact method. |
| 3916 | * <P>Type: TEXT</P> |
| 3917 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 3918 | public static final String LABEL = DataColumns.DATA3; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3919 | } |
| 3920 | |
| 3921 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3922 | * A data kind representing the contact's proper name. You can use all |
| 3923 | * columns defined for {@link ContactsContract.Data} as well as the following aliases. |
| 3924 | * |
| 3925 | * <h2>Column aliases</h2> |
| 3926 | * <table class="jd-sumtable"> |
| 3927 | * <tr> |
| 3928 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 3929 | * </tr> |
| 3930 | * <tr> |
| 3931 | * <td>String</td> |
| 3932 | * <td>{@link #DISPLAY_NAME}</td> |
| 3933 | * <td>{@link #DATA1}</td> |
| 3934 | * <td></td> |
| 3935 | * </tr> |
| 3936 | * <tr> |
| 3937 | * <td>String</td> |
| 3938 | * <td>{@link #GIVEN_NAME}</td> |
| 3939 | * <td>{@link #DATA2}</td> |
| 3940 | * <td></td> |
| 3941 | * </tr> |
| 3942 | * <tr> |
| 3943 | * <td>String</td> |
| 3944 | * <td>{@link #FAMILY_NAME}</td> |
| 3945 | * <td>{@link #DATA3}</td> |
| 3946 | * <td></td> |
| 3947 | * </tr> |
| 3948 | * <tr> |
| 3949 | * <td>String</td> |
| 3950 | * <td>{@link #PREFIX}</td> |
| 3951 | * <td>{@link #DATA4}</td> |
| 3952 | * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td> |
| 3953 | * </tr> |
| 3954 | * <tr> |
| 3955 | * <td>String</td> |
| 3956 | * <td>{@link #MIDDLE_NAME}</td> |
| 3957 | * <td>{@link #DATA5}</td> |
| 3958 | * <td></td> |
| 3959 | * </tr> |
| 3960 | * <tr> |
| 3961 | * <td>String</td> |
| 3962 | * <td>{@link #SUFFIX}</td> |
| 3963 | * <td>{@link #DATA6}</td> |
| 3964 | * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td> |
| 3965 | * </tr> |
| 3966 | * <tr> |
| 3967 | * <td>String</td> |
| 3968 | * <td>{@link #PHONETIC_GIVEN_NAME}</td> |
| 3969 | * <td>{@link #DATA7}</td> |
| 3970 | * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td> |
| 3971 | * </tr> |
| 3972 | * <tr> |
| 3973 | * <td>String</td> |
| 3974 | * <td>{@link #PHONETIC_MIDDLE_NAME}</td> |
| 3975 | * <td>{@link #DATA8}</td> |
| 3976 | * <td></td> |
| 3977 | * </tr> |
| 3978 | * <tr> |
| 3979 | * <td>String</td> |
| 3980 | * <td>{@link #PHONETIC_FAMILY_NAME}</td> |
| 3981 | * <td>{@link #DATA9}</td> |
| 3982 | * <td></td> |
| 3983 | * </tr> |
| 3984 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3985 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 3986 | public static final class StructuredName implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 3987 | /** |
| 3988 | * This utility class cannot be instantiated |
| 3989 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3990 | private StructuredName() {} |
| 3991 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 3992 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3993 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; |
| 3994 | |
| 3995 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3996 | * The name that should be used to display the contact. |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 3997 | * <i>Unstructured component of the name should be consistent with |
| 3998 | * its structured representation.</i> |
| 3999 | * <p> |
| 4000 | * Type: TEXT |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4001 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 4002 | public static final String DISPLAY_NAME = DATA1; |
| 4003 | |
| 4004 | /** |
| 4005 | * The given name for the contact. |
| 4006 | * <P>Type: TEXT</P> |
| 4007 | */ |
| 4008 | public static final String GIVEN_NAME = DATA2; |
| 4009 | |
| 4010 | /** |
| 4011 | * The family name for the contact. |
| 4012 | * <P>Type: TEXT</P> |
| 4013 | */ |
| 4014 | public static final String FAMILY_NAME = DATA3; |
| 4015 | |
| 4016 | /** |
| 4017 | * The contact's honorific prefix, e.g. "Sir" |
| 4018 | * <P>Type: TEXT</P> |
| 4019 | */ |
| 4020 | public static final String PREFIX = DATA4; |
| 4021 | |
| 4022 | /** |
| 4023 | * The contact's middle name |
| 4024 | * <P>Type: TEXT</P> |
| 4025 | */ |
| 4026 | public static final String MIDDLE_NAME = DATA5; |
| 4027 | |
| 4028 | /** |
| 4029 | * The contact's honorific suffix, e.g. "Jr" |
| 4030 | */ |
| 4031 | public static final String SUFFIX = DATA6; |
| 4032 | |
| 4033 | /** |
| 4034 | * The phonetic version of the given name for the contact. |
| 4035 | * <P>Type: TEXT</P> |
| 4036 | */ |
| 4037 | public static final String PHONETIC_GIVEN_NAME = DATA7; |
| 4038 | |
| 4039 | /** |
| 4040 | * The phonetic version of the additional name for the contact. |
| 4041 | * <P>Type: TEXT</P> |
| 4042 | */ |
| 4043 | public static final String PHONETIC_MIDDLE_NAME = DATA8; |
| 4044 | |
| 4045 | /** |
| 4046 | * The phonetic version of the family name for the contact. |
| 4047 | * <P>Type: TEXT</P> |
| 4048 | */ |
| 4049 | public static final String PHONETIC_FAMILY_NAME = DATA9; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 4050 | |
| 4051 | /** |
| 4052 | * The style used for combining given/middle/family name into a full name. |
| 4053 | * See {@link ContactsContract.FullNameStyle}. |
| 4054 | * |
| 4055 | * @hide |
| 4056 | */ |
| 4057 | public static final String FULL_NAME_STYLE = DATA10; |
| 4058 | |
| 4059 | /** |
| 4060 | * The alphabet used for capturing the phonetic name. |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 4061 | * See ContactsContract.PhoneticNameStyle. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 4062 | * @hide |
| 4063 | */ |
| 4064 | public static final String PHONETIC_NAME_STYLE = DATA11; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4065 | } |
| 4066 | |
| 4067 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4068 | * <p>A data kind representing the contact's nickname. For example, for |
| 4069 | * Bob Parr ("Mr. Incredible"): |
| 4070 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4071 | * ArrayList<ContentProviderOperation> ops = |
| 4072 | * new ArrayList<ContentProviderOperation>(); |
| 4073 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4074 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 4075 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 4076 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 4077 | * .withValue(StructuredName.DISPLAY_NAME, "Bob Parr") |
| 4078 | * .build()); |
| 4079 | * |
| 4080 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 4081 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 4082 | * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE) |
| 4083 | * .withValue(Nickname.NAME, "Mr. Incredible") |
| 4084 | * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM) |
| 4085 | * .withValue(Nickname.LABEL, "Superhero") |
| 4086 | * .build()); |
| 4087 | * |
| 4088 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4089 | * </pre> |
| 4090 | * </p> |
| 4091 | * <p> |
| 4092 | * You can use all columns defined for {@link ContactsContract.Data} as well as the |
| 4093 | * following aliases. |
| 4094 | * </p> |
| 4095 | * |
| 4096 | * <h2>Column aliases</h2> |
| 4097 | * <table class="jd-sumtable"> |
| 4098 | * <tr> |
| 4099 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 4100 | * </tr> |
| 4101 | * <tr> |
| 4102 | * <td>String</td> |
| 4103 | * <td>{@link #NAME}</td> |
| 4104 | * <td>{@link #DATA1}</td> |
| 4105 | * <td></td> |
| 4106 | * </tr> |
| 4107 | * <tr> |
| 4108 | * <td>int</td> |
| 4109 | * <td>{@link #TYPE}</td> |
| 4110 | * <td>{@link #DATA2}</td> |
| 4111 | * <td> |
| 4112 | * Allowed values are: |
| 4113 | * <p> |
| 4114 | * <ul> |
| 4115 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 4116 | * <li>{@link #TYPE_DEFAULT}</li> |
| 4117 | * <li>{@link #TYPE_OTHER_NAME}</li> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 4118 | * <li>{@link #TYPE_MAIDEN_NAME}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4119 | * <li>{@link #TYPE_SHORT_NAME}</li> |
| 4120 | * <li>{@link #TYPE_INITIALS}</li> |
| 4121 | * </ul> |
| 4122 | * </p> |
| 4123 | * </td> |
| 4124 | * </tr> |
| 4125 | * <tr> |
| 4126 | * <td>String</td> |
| 4127 | * <td>{@link #LABEL}</td> |
| 4128 | * <td>{@link #DATA3}</td> |
| 4129 | * <td></td> |
| 4130 | * </tr> |
| 4131 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4132 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4133 | public static final class Nickname implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 4134 | /** |
| 4135 | * This utility class cannot be instantiated |
| 4136 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4137 | private Nickname() {} |
| 4138 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4139 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4140 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; |
| 4141 | |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 4142 | public static final int TYPE_DEFAULT = 1; |
| 4143 | public static final int TYPE_OTHER_NAME = 2; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 4144 | public static final int TYPE_MAIDEN_NAME = 3; |
| 4145 | /** @deprecated Use TYPE_MAIDEN_NAME instead. */ |
| 4146 | @Deprecated |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 4147 | public static final int TYPE_MAINDEN_NAME = 3; |
| 4148 | public static final int TYPE_SHORT_NAME = 4; |
| 4149 | public static final int TYPE_INITIALS = 5; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4150 | |
| 4151 | /** |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 4152 | * The name itself |
| 4153 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 4154 | public static final String NAME = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4155 | } |
| 4156 | |
| 4157 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4158 | * <p> |
| 4159 | * A data kind representing a telephone number. |
| 4160 | * </p> |
| 4161 | * <p> |
| 4162 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 4163 | * well as the following aliases. |
| 4164 | * </p> |
| 4165 | * <h2>Column aliases</h2> |
| 4166 | * <table class="jd-sumtable"> |
| 4167 | * <tr> |
| 4168 | * <th>Type</th> |
| 4169 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 4170 | * </tr> |
| 4171 | * <tr> |
| 4172 | * <td>String</td> |
| 4173 | * <td>{@link #NUMBER}</td> |
| 4174 | * <td>{@link #DATA1}</td> |
| 4175 | * <td></td> |
| 4176 | * </tr> |
| 4177 | * <tr> |
| 4178 | * <td>int</td> |
| 4179 | * <td>{@link #TYPE}</td> |
| 4180 | * <td>{@link #DATA2}</td> |
| 4181 | * <td>Allowed values are: |
| 4182 | * <p> |
| 4183 | * <ul> |
| 4184 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 4185 | * <li>{@link #TYPE_HOME}</li> |
| 4186 | * <li>{@link #TYPE_MOBILE}</li> |
| 4187 | * <li>{@link #TYPE_WORK}</li> |
| 4188 | * <li>{@link #TYPE_FAX_WORK}</li> |
| 4189 | * <li>{@link #TYPE_FAX_HOME}</li> |
| 4190 | * <li>{@link #TYPE_PAGER}</li> |
| 4191 | * <li>{@link #TYPE_OTHER}</li> |
| 4192 | * <li>{@link #TYPE_CALLBACK}</li> |
| 4193 | * <li>{@link #TYPE_CAR}</li> |
| 4194 | * <li>{@link #TYPE_COMPANY_MAIN}</li> |
| 4195 | * <li>{@link #TYPE_ISDN}</li> |
| 4196 | * <li>{@link #TYPE_MAIN}</li> |
| 4197 | * <li>{@link #TYPE_OTHER_FAX}</li> |
| 4198 | * <li>{@link #TYPE_RADIO}</li> |
| 4199 | * <li>{@link #TYPE_TELEX}</li> |
| 4200 | * <li>{@link #TYPE_TTY_TDD}</li> |
| 4201 | * <li>{@link #TYPE_WORK_MOBILE}</li> |
| 4202 | * <li>{@link #TYPE_WORK_PAGER}</li> |
| 4203 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 4204 | * <li>{@link #TYPE_MMS}</li> |
| 4205 | * </ul> |
| 4206 | * </p> |
| 4207 | * </td> |
| 4208 | * </tr> |
| 4209 | * <tr> |
| 4210 | * <td>String</td> |
| 4211 | * <td>{@link #LABEL}</td> |
| 4212 | * <td>{@link #DATA3}</td> |
| 4213 | * <td></td> |
| 4214 | * </tr> |
| 4215 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4216 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4217 | public static final class Phone implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 4218 | /** |
| 4219 | * This utility class cannot be instantiated |
| 4220 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4221 | private Phone() {} |
| 4222 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4223 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 4224 | 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] | 4225 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 4226 | /** |
| 4227 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 4228 | * phones. |
| 4229 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 4230 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2"; |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 4231 | |
| 4232 | /** |
| 4233 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4234 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 4235 | * associated raw contact and aggregate contact data. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 4236 | */ |
| 4237 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 4238 | "phones"); |
| 4239 | |
| 4240 | /** |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 4241 | * 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] | 4242 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 4243 | * to display names as well as phone numbers. The filter argument should be passed |
| 4244 | * as an additional path segment after this URI. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 4245 | */ |
| 4246 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 4247 | "filter"); |
| 4248 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4249 | public static final int TYPE_HOME = 1; |
| 4250 | public static final int TYPE_MOBILE = 2; |
| 4251 | public static final int TYPE_WORK = 3; |
| 4252 | public static final int TYPE_FAX_WORK = 4; |
| 4253 | public static final int TYPE_FAX_HOME = 5; |
| 4254 | public static final int TYPE_PAGER = 6; |
| 4255 | public static final int TYPE_OTHER = 7; |
Fred Quintana | 3f86715 | 2009-08-03 11:43:16 -0700 | [diff] [blame] | 4256 | public static final int TYPE_CALLBACK = 8; |
| 4257 | public static final int TYPE_CAR = 9; |
| 4258 | public static final int TYPE_COMPANY_MAIN = 10; |
| 4259 | public static final int TYPE_ISDN = 11; |
| 4260 | public static final int TYPE_MAIN = 12; |
| 4261 | public static final int TYPE_OTHER_FAX = 13; |
| 4262 | public static final int TYPE_RADIO = 14; |
| 4263 | public static final int TYPE_TELEX = 15; |
| 4264 | public static final int TYPE_TTY_TDD = 16; |
| 4265 | public static final int TYPE_WORK_MOBILE = 17; |
| 4266 | public static final int TYPE_WORK_PAGER = 18; |
| 4267 | public static final int TYPE_ASSISTANT = 19; |
Jeff Sharkey | d5abd46 | 2009-09-16 19:54:29 -0700 | [diff] [blame] | 4268 | public static final int TYPE_MMS = 20; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4269 | |
| 4270 | /** |
| 4271 | * The phone number as the user entered it. |
| 4272 | * <P>Type: TEXT</P> |
| 4273 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 4274 | public static final String NUMBER = DATA; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4275 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4276 | /** |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 4277 | * The phone number's E164 representation. |
| 4278 | * <P>Type: TEXT</P> |
| 4279 | * |
| 4280 | * @hide |
| 4281 | */ |
| 4282 | public static final String NORMALIZED_NUMBER = DATA4; |
| 4283 | |
| 4284 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4285 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 4286 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4287 | */ |
| 4288 | @Deprecated |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4289 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 4290 | CharSequence label, CharSequence[] labelArray) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4291 | return getTypeLabel(context.getResources(), type, label); |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4292 | } |
| 4293 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4294 | /** |
| 4295 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 4296 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4297 | */ |
| 4298 | @Deprecated |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4299 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 4300 | CharSequence label) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4301 | return getTypeLabel(context.getResources(), type, label); |
| 4302 | } |
| 4303 | |
| 4304 | /** |
| 4305 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4306 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4307 | */ |
| 4308 | public static final int getTypeLabelResource(int type) { |
| 4309 | switch (type) { |
| 4310 | case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome; |
| 4311 | case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile; |
| 4312 | case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork; |
| 4313 | case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork; |
| 4314 | case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome; |
| 4315 | case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager; |
| 4316 | case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther; |
| 4317 | case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback; |
| 4318 | case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar; |
| 4319 | case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain; |
| 4320 | case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn; |
| 4321 | case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain; |
| 4322 | case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax; |
| 4323 | case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio; |
| 4324 | case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex; |
| 4325 | case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd; |
| 4326 | case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile; |
| 4327 | case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager; |
| 4328 | case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant; |
| 4329 | case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms; |
| 4330 | default: return com.android.internal.R.string.phoneTypeCustom; |
| 4331 | } |
| 4332 | } |
| 4333 | |
| 4334 | /** |
| 4335 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4336 | * possibly substituting the given {@link #LABEL} value |
| 4337 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4338 | */ |
| 4339 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 4340 | CharSequence label) { |
| 4341 | if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) { |
| 4342 | return label; |
| 4343 | } else { |
| 4344 | final int labelRes = getTypeLabelResource(type); |
| 4345 | return res.getText(labelRes); |
| 4346 | } |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4347 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4348 | } |
| 4349 | |
| 4350 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4351 | * <p> |
| 4352 | * A data kind representing an email address. |
| 4353 | * </p> |
| 4354 | * <p> |
| 4355 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 4356 | * well as the following aliases. |
| 4357 | * </p> |
| 4358 | * <h2>Column aliases</h2> |
| 4359 | * <table class="jd-sumtable"> |
| 4360 | * <tr> |
| 4361 | * <th>Type</th> |
| 4362 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 4363 | * </tr> |
| 4364 | * <tr> |
| 4365 | * <td>String</td> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 4366 | * <td>{@link #ADDRESS}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4367 | * <td>{@link #DATA1}</td> |
| 4368 | * <td>Email address itself.</td> |
| 4369 | * </tr> |
| 4370 | * <tr> |
| 4371 | * <td>int</td> |
| 4372 | * <td>{@link #TYPE}</td> |
| 4373 | * <td>{@link #DATA2}</td> |
| 4374 | * <td>Allowed values are: |
| 4375 | * <p> |
| 4376 | * <ul> |
| 4377 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 4378 | * <li>{@link #TYPE_HOME}</li> |
| 4379 | * <li>{@link #TYPE_WORK}</li> |
| 4380 | * <li>{@link #TYPE_OTHER}</li> |
| 4381 | * <li>{@link #TYPE_MOBILE}</li> |
| 4382 | * </ul> |
| 4383 | * </p> |
| 4384 | * </td> |
| 4385 | * </tr> |
| 4386 | * <tr> |
| 4387 | * <td>String</td> |
| 4388 | * <td>{@link #LABEL}</td> |
| 4389 | * <td>{@link #DATA3}</td> |
| 4390 | * <td></td> |
| 4391 | * </tr> |
| 4392 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4393 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4394 | public static final class Email implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 4395 | /** |
| 4396 | * This utility class cannot be instantiated |
| 4397 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4398 | private Email() {} |
| 4399 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4400 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 4401 | 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] | 4402 | |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 4403 | /** |
Dmitri Plotnikov | abf15c3 | 2009-09-18 20:29:11 -0700 | [diff] [blame] | 4404 | * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses. |
| 4405 | */ |
| 4406 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2"; |
| 4407 | |
| 4408 | /** |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 4409 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4410 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 4411 | * associated raw contact and aggregate contact data. |
| 4412 | */ |
| 4413 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 4414 | "emails"); |
| 4415 | |
| 4416 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4417 | * <p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 4418 | * The content:// style URL for looking up data rows by email address. The |
| 4419 | * lookup argument, an email address, should be passed as an additional path segment |
| 4420 | * after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4421 | * </p> |
| 4422 | * <p>Example: |
| 4423 | * <pre> |
| 4424 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email)); |
| 4425 | * Cursor c = getContentResolver().query(uri, |
| 4426 | * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA}, |
| 4427 | * null, null, null); |
| 4428 | * </pre> |
| 4429 | * </p> |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 4430 | */ |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 4431 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 4432 | "lookup"); |
| 4433 | |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 4434 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4435 | * <p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 4436 | * 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] | 4437 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 4438 | * to display names as well as email addresses. The filter argument should be passed |
| 4439 | * as an additional path segment after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4440 | * </p> |
| 4441 | * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)" |
| 4442 | * as well as "Bob Parr (incredible@android.com)". |
| 4443 | * <pre> |
| 4444 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob")); |
| 4445 | * Cursor c = getContentResolver().query(uri, |
| 4446 | * new String[]{Email.DISPLAY_NAME, Email.DATA}, |
| 4447 | * null, null, null); |
| 4448 | * </pre> |
| 4449 | * </p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 4450 | */ |
| 4451 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 4452 | "filter"); |
| 4453 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4454 | /** |
| 4455 | * The email address. |
| 4456 | * <P>Type: TEXT</P> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4457 | */ |
| 4458 | public static final String ADDRESS = DATA1; |
| 4459 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4460 | public static final int TYPE_HOME = 1; |
| 4461 | public static final int TYPE_WORK = 2; |
| 4462 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 14fb153 | 2009-08-29 15:54:26 -0700 | [diff] [blame] | 4463 | public static final int TYPE_MOBILE = 4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 4464 | |
| 4465 | /** |
| 4466 | * The display name for the email address |
| 4467 | * <P>Type: TEXT</P> |
| 4468 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 4469 | public static final String DISPLAY_NAME = DATA4; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4470 | |
| 4471 | /** |
| 4472 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4473 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4474 | */ |
| 4475 | public static final int getTypeLabelResource(int type) { |
| 4476 | switch (type) { |
| 4477 | case TYPE_HOME: return com.android.internal.R.string.emailTypeHome; |
| 4478 | case TYPE_WORK: return com.android.internal.R.string.emailTypeWork; |
| 4479 | case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther; |
| 4480 | case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile; |
| 4481 | default: return com.android.internal.R.string.emailTypeCustom; |
| 4482 | } |
| 4483 | } |
| 4484 | |
| 4485 | /** |
| 4486 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4487 | * possibly substituting the given {@link #LABEL} value |
| 4488 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4489 | */ |
| 4490 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 4491 | CharSequence label) { |
| 4492 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 4493 | return label; |
| 4494 | } else { |
| 4495 | final int labelRes = getTypeLabelResource(type); |
| 4496 | return res.getText(labelRes); |
| 4497 | } |
| 4498 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4499 | } |
| 4500 | |
| 4501 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4502 | * <p> |
| 4503 | * A data kind representing a postal addresses. |
| 4504 | * </p> |
| 4505 | * <p> |
| 4506 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 4507 | * well as the following aliases. |
| 4508 | * </p> |
| 4509 | * <h2>Column aliases</h2> |
| 4510 | * <table class="jd-sumtable"> |
| 4511 | * <tr> |
| 4512 | * <th>Type</th> |
| 4513 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 4514 | * </tr> |
| 4515 | * <tr> |
| 4516 | * <td>String</td> |
| 4517 | * <td>{@link #FORMATTED_ADDRESS}</td> |
| 4518 | * <td>{@link #DATA1}</td> |
| 4519 | * <td></td> |
| 4520 | * </tr> |
| 4521 | * <tr> |
| 4522 | * <td>int</td> |
| 4523 | * <td>{@link #TYPE}</td> |
| 4524 | * <td>{@link #DATA2}</td> |
| 4525 | * <td>Allowed values are: |
| 4526 | * <p> |
| 4527 | * <ul> |
| 4528 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 4529 | * <li>{@link #TYPE_HOME}</li> |
| 4530 | * <li>{@link #TYPE_WORK}</li> |
| 4531 | * <li>{@link #TYPE_OTHER}</li> |
| 4532 | * </ul> |
| 4533 | * </p> |
| 4534 | * </td> |
| 4535 | * </tr> |
| 4536 | * <tr> |
| 4537 | * <td>String</td> |
| 4538 | * <td>{@link #LABEL}</td> |
| 4539 | * <td>{@link #DATA3}</td> |
| 4540 | * <td></td> |
| 4541 | * </tr> |
| 4542 | * <tr> |
| 4543 | * <td>String</td> |
| 4544 | * <td>{@link #STREET}</td> |
| 4545 | * <td>{@link #DATA4}</td> |
| 4546 | * <td></td> |
| 4547 | * </tr> |
| 4548 | * <tr> |
| 4549 | * <td>String</td> |
| 4550 | * <td>{@link #POBOX}</td> |
| 4551 | * <td>{@link #DATA5}</td> |
| 4552 | * <td>Post Office Box number</td> |
| 4553 | * </tr> |
| 4554 | * <tr> |
| 4555 | * <td>String</td> |
| 4556 | * <td>{@link #NEIGHBORHOOD}</td> |
| 4557 | * <td>{@link #DATA6}</td> |
| 4558 | * <td></td> |
| 4559 | * </tr> |
| 4560 | * <tr> |
| 4561 | * <td>String</td> |
| 4562 | * <td>{@link #CITY}</td> |
| 4563 | * <td>{@link #DATA7}</td> |
| 4564 | * <td></td> |
| 4565 | * </tr> |
| 4566 | * <tr> |
| 4567 | * <td>String</td> |
| 4568 | * <td>{@link #REGION}</td> |
| 4569 | * <td>{@link #DATA8}</td> |
| 4570 | * <td></td> |
| 4571 | * </tr> |
| 4572 | * <tr> |
| 4573 | * <td>String</td> |
| 4574 | * <td>{@link #POSTCODE}</td> |
| 4575 | * <td>{@link #DATA9}</td> |
| 4576 | * <td></td> |
| 4577 | * </tr> |
| 4578 | * <tr> |
| 4579 | * <td>String</td> |
| 4580 | * <td>{@link #COUNTRY}</td> |
| 4581 | * <td>{@link #DATA10}</td> |
| 4582 | * <td></td> |
| 4583 | * </tr> |
| 4584 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4585 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4586 | public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 4587 | /** |
| 4588 | * This utility class cannot be instantiated |
| 4589 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4590 | private StructuredPostal() { |
| 4591 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4592 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4593 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 4594 | public static final String CONTENT_ITEM_TYPE = |
| 4595 | "vnd.android.cursor.item/postal-address_v2"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4596 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 4597 | /** |
| 4598 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 4599 | * postal addresses. |
| 4600 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 4601 | 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] | 4602 | |
| 4603 | /** |
| 4604 | * The content:// style URI for all data records of the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4605 | * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 4606 | */ |
| 4607 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 4608 | "postals"); |
| 4609 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4610 | public static final int TYPE_HOME = 1; |
| 4611 | public static final int TYPE_WORK = 2; |
| 4612 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4613 | |
| 4614 | /** |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 4615 | * The full, unstructured postal address. <i>This field must be |
| 4616 | * consistent with any structured data.</i> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4617 | * <p> |
| 4618 | * Type: TEXT |
| 4619 | */ |
| 4620 | public static final String FORMATTED_ADDRESS = DATA; |
| 4621 | |
| 4622 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4623 | * Can be street, avenue, road, etc. This element also includes the |
| 4624 | * house number and room/apartment/flat/floor number. |
| 4625 | * <p> |
| 4626 | * Type: TEXT |
| 4627 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 4628 | public static final String STREET = DATA4; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4629 | |
| 4630 | /** |
| 4631 | * Covers actual P.O. boxes, drawers, locked bags, etc. This is |
| 4632 | * usually but not always mutually exclusive with street. |
| 4633 | * <p> |
| 4634 | * Type: TEXT |
| 4635 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 4636 | public static final String POBOX = DATA5; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4637 | |
| 4638 | /** |
| 4639 | * This is used to disambiguate a street address when a city |
| 4640 | * contains more than one street with the same name, or to specify a |
| 4641 | * small place whose mail is routed through a larger postal town. In |
| 4642 | * China it could be a county or a minor city. |
| 4643 | * <p> |
| 4644 | * Type: TEXT |
| 4645 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 4646 | public static final String NEIGHBORHOOD = DATA6; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4647 | |
| 4648 | /** |
| 4649 | * Can be city, village, town, borough, etc. This is the postal town |
| 4650 | * and not necessarily the place of residence or place of business. |
| 4651 | * <p> |
| 4652 | * Type: TEXT |
| 4653 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 4654 | public static final String CITY = DATA7; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4655 | |
| 4656 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4657 | * A state, province, county (in Ireland), Land (in Germany), |
| 4658 | * departement (in France), etc. |
| 4659 | * <p> |
| 4660 | * Type: TEXT |
| 4661 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 4662 | public static final String REGION = DATA8; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4663 | |
| 4664 | /** |
Jeff Sharkey | ef348c7 | 2009-07-26 14:14:34 -0700 | [diff] [blame] | 4665 | * Postal code. Usually country-wide, but sometimes specific to the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4666 | * city (e.g. "2" in "Dublin 2, Ireland" addresses). |
| 4667 | * <p> |
| 4668 | * Type: TEXT |
| 4669 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 4670 | public static final String POSTCODE = DATA9; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4671 | |
| 4672 | /** |
| 4673 | * The name or code of the country. |
| 4674 | * <p> |
| 4675 | * Type: TEXT |
| 4676 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 4677 | public static final String COUNTRY = DATA10; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4678 | |
| 4679 | /** |
| 4680 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4681 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4682 | */ |
| 4683 | public static final int getTypeLabelResource(int type) { |
| 4684 | switch (type) { |
| 4685 | case TYPE_HOME: return com.android.internal.R.string.postalTypeHome; |
| 4686 | case TYPE_WORK: return com.android.internal.R.string.postalTypeWork; |
| 4687 | case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther; |
| 4688 | default: return com.android.internal.R.string.postalTypeCustom; |
| 4689 | } |
| 4690 | } |
| 4691 | |
| 4692 | /** |
| 4693 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4694 | * possibly substituting the given {@link #LABEL} value |
| 4695 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4696 | */ |
| 4697 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 4698 | CharSequence label) { |
| 4699 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 4700 | return label; |
| 4701 | } else { |
| 4702 | final int labelRes = getTypeLabelResource(type); |
| 4703 | return res.getText(labelRes); |
| 4704 | } |
| 4705 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4706 | } |
| 4707 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 4708 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4709 | * <p> |
| 4710 | * A data kind representing an IM address |
| 4711 | * </p> |
| 4712 | * <p> |
| 4713 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 4714 | * well as the following aliases. |
| 4715 | * </p> |
| 4716 | * <h2>Column aliases</h2> |
| 4717 | * <table class="jd-sumtable"> |
| 4718 | * <tr> |
| 4719 | * <th>Type</th> |
| 4720 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 4721 | * </tr> |
| 4722 | * <tr> |
| 4723 | * <td>String</td> |
| 4724 | * <td>{@link #DATA}</td> |
| 4725 | * <td>{@link #DATA1}</td> |
| 4726 | * <td></td> |
| 4727 | * </tr> |
| 4728 | * <tr> |
| 4729 | * <td>int</td> |
| 4730 | * <td>{@link #TYPE}</td> |
| 4731 | * <td>{@link #DATA2}</td> |
| 4732 | * <td>Allowed values are: |
| 4733 | * <p> |
| 4734 | * <ul> |
| 4735 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 4736 | * <li>{@link #TYPE_HOME}</li> |
| 4737 | * <li>{@link #TYPE_WORK}</li> |
| 4738 | * <li>{@link #TYPE_OTHER}</li> |
| 4739 | * </ul> |
| 4740 | * </p> |
| 4741 | * </td> |
| 4742 | * </tr> |
| 4743 | * <tr> |
| 4744 | * <td>String</td> |
| 4745 | * <td>{@link #LABEL}</td> |
| 4746 | * <td>{@link #DATA3}</td> |
| 4747 | * <td></td> |
| 4748 | * </tr> |
| 4749 | * <tr> |
| 4750 | * <td>String</td> |
| 4751 | * <td>{@link #PROTOCOL}</td> |
| 4752 | * <td>{@link #DATA5}</td> |
| 4753 | * <td> |
| 4754 | * <p> |
| 4755 | * Allowed values: |
| 4756 | * <ul> |
| 4757 | * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name |
| 4758 | * as {@link #CUSTOM_PROTOCOL}.</li> |
| 4759 | * <li>{@link #PROTOCOL_AIM}</li> |
| 4760 | * <li>{@link #PROTOCOL_MSN}</li> |
| 4761 | * <li>{@link #PROTOCOL_YAHOO}</li> |
| 4762 | * <li>{@link #PROTOCOL_SKYPE}</li> |
| 4763 | * <li>{@link #PROTOCOL_QQ}</li> |
| 4764 | * <li>{@link #PROTOCOL_GOOGLE_TALK}</li> |
| 4765 | * <li>{@link #PROTOCOL_ICQ}</li> |
| 4766 | * <li>{@link #PROTOCOL_JABBER}</li> |
| 4767 | * <li>{@link #PROTOCOL_NETMEETING}</li> |
| 4768 | * </ul> |
| 4769 | * </p> |
| 4770 | * </td> |
| 4771 | * </tr> |
| 4772 | * <tr> |
| 4773 | * <td>String</td> |
| 4774 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 4775 | * <td>{@link #DATA6}</td> |
| 4776 | * <td></td> |
| 4777 | * </tr> |
| 4778 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 4779 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4780 | public static final class Im implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 4781 | /** |
| 4782 | * This utility class cannot be instantiated |
| 4783 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4784 | private Im() {} |
| 4785 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4786 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4787 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; |
| 4788 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4789 | public static final int TYPE_HOME = 1; |
| 4790 | public static final int TYPE_WORK = 2; |
| 4791 | public static final int TYPE_OTHER = 3; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 4792 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 4793 | /** |
| 4794 | * This column should be populated with one of the defined |
| 4795 | * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this |
| 4796 | * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL} |
| 4797 | * should contain the name of the custom protocol. |
| 4798 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 4799 | public static final String PROTOCOL = DATA5; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 4800 | |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 4801 | public static final String CUSTOM_PROTOCOL = DATA6; |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 4802 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 4803 | /* |
| 4804 | * The predefined IM protocol types. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4805 | */ |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 4806 | public static final int PROTOCOL_CUSTOM = -1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4807 | public static final int PROTOCOL_AIM = 0; |
| 4808 | public static final int PROTOCOL_MSN = 1; |
| 4809 | public static final int PROTOCOL_YAHOO = 2; |
| 4810 | public static final int PROTOCOL_SKYPE = 3; |
| 4811 | public static final int PROTOCOL_QQ = 4; |
| 4812 | public static final int PROTOCOL_GOOGLE_TALK = 5; |
| 4813 | public static final int PROTOCOL_ICQ = 6; |
| 4814 | public static final int PROTOCOL_JABBER = 7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 4815 | public static final int PROTOCOL_NETMEETING = 8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4816 | |
| 4817 | /** |
| 4818 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4819 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4820 | */ |
| 4821 | public static final int getTypeLabelResource(int type) { |
| 4822 | switch (type) { |
| 4823 | case TYPE_HOME: return com.android.internal.R.string.imTypeHome; |
| 4824 | case TYPE_WORK: return com.android.internal.R.string.imTypeWork; |
| 4825 | case TYPE_OTHER: return com.android.internal.R.string.imTypeOther; |
| 4826 | default: return com.android.internal.R.string.imTypeCustom; |
| 4827 | } |
| 4828 | } |
| 4829 | |
| 4830 | /** |
| 4831 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4832 | * possibly substituting the given {@link #LABEL} value |
| 4833 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4834 | */ |
| 4835 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 4836 | CharSequence label) { |
| 4837 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 4838 | return label; |
| 4839 | } else { |
| 4840 | final int labelRes = getTypeLabelResource(type); |
| 4841 | return res.getText(labelRes); |
| 4842 | } |
| 4843 | } |
| 4844 | |
| 4845 | /** |
| 4846 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4847 | * {@link #PROTOCOL}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 4848 | */ |
| 4849 | public static final int getProtocolLabelResource(int type) { |
| 4850 | switch (type) { |
| 4851 | case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim; |
| 4852 | case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn; |
| 4853 | case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo; |
| 4854 | case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype; |
| 4855 | case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq; |
| 4856 | case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk; |
| 4857 | case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq; |
| 4858 | case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber; |
| 4859 | case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting; |
| 4860 | default: return com.android.internal.R.string.imProtocolCustom; |
| 4861 | } |
| 4862 | } |
| 4863 | |
| 4864 | /** |
| 4865 | * Return a {@link CharSequence} that best describes the given |
| 4866 | * protocol, possibly substituting the given |
| 4867 | * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}. |
| 4868 | */ |
| 4869 | public static final CharSequence getProtocolLabel(Resources res, int type, |
| 4870 | CharSequence label) { |
| 4871 | if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) { |
| 4872 | return label; |
| 4873 | } else { |
| 4874 | final int labelRes = getProtocolLabelResource(type); |
| 4875 | return res.getText(labelRes); |
| 4876 | } |
| 4877 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4878 | } |
| 4879 | |
| 4880 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4881 | * <p> |
| 4882 | * A data kind representing an organization. |
| 4883 | * </p> |
| 4884 | * <p> |
| 4885 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 4886 | * well as the following aliases. |
| 4887 | * </p> |
| 4888 | * <h2>Column aliases</h2> |
| 4889 | * <table class="jd-sumtable"> |
| 4890 | * <tr> |
| 4891 | * <th>Type</th> |
| 4892 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 4893 | * </tr> |
| 4894 | * <tr> |
| 4895 | * <td>String</td> |
| 4896 | * <td>{@link #COMPANY}</td> |
| 4897 | * <td>{@link #DATA1}</td> |
| 4898 | * <td></td> |
| 4899 | * </tr> |
| 4900 | * <tr> |
| 4901 | * <td>int</td> |
| 4902 | * <td>{@link #TYPE}</td> |
| 4903 | * <td>{@link #DATA2}</td> |
| 4904 | * <td>Allowed values are: |
| 4905 | * <p> |
| 4906 | * <ul> |
| 4907 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 4908 | * <li>{@link #TYPE_WORK}</li> |
| 4909 | * <li>{@link #TYPE_OTHER}</li> |
| 4910 | * </ul> |
| 4911 | * </p> |
| 4912 | * </td> |
| 4913 | * </tr> |
| 4914 | * <tr> |
| 4915 | * <td>String</td> |
| 4916 | * <td>{@link #LABEL}</td> |
| 4917 | * <td>{@link #DATA3}</td> |
| 4918 | * <td></td> |
| 4919 | * </tr> |
| 4920 | * <tr> |
| 4921 | * <td>String</td> |
| 4922 | * <td>{@link #TITLE}</td> |
| 4923 | * <td>{@link #DATA4}</td> |
| 4924 | * <td></td> |
| 4925 | * </tr> |
| 4926 | * <tr> |
| 4927 | * <td>String</td> |
| 4928 | * <td>{@link #DEPARTMENT}</td> |
| 4929 | * <td>{@link #DATA5}</td> |
| 4930 | * <td></td> |
| 4931 | * </tr> |
| 4932 | * <tr> |
| 4933 | * <td>String</td> |
| 4934 | * <td>{@link #JOB_DESCRIPTION}</td> |
| 4935 | * <td>{@link #DATA6}</td> |
| 4936 | * <td></td> |
| 4937 | * </tr> |
| 4938 | * <tr> |
| 4939 | * <td>String</td> |
| 4940 | * <td>{@link #SYMBOL}</td> |
| 4941 | * <td>{@link #DATA7}</td> |
| 4942 | * <td></td> |
| 4943 | * </tr> |
| 4944 | * <tr> |
| 4945 | * <td>String</td> |
| 4946 | * <td>{@link #PHONETIC_NAME}</td> |
| 4947 | * <td>{@link #DATA8}</td> |
| 4948 | * <td></td> |
| 4949 | * </tr> |
| 4950 | * <tr> |
| 4951 | * <td>String</td> |
| 4952 | * <td>{@link #OFFICE_LOCATION}</td> |
| 4953 | * <td>{@link #DATA9}</td> |
| 4954 | * <td></td> |
| 4955 | * </tr> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 4956 | * <tr> |
| 4957 | * <td>String</td> |
| 4958 | * <td>PHONETIC_NAME_STYLE</td> |
| 4959 | * <td>{@link #DATA10}</td> |
| 4960 | * <td></td> |
| 4961 | * </tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4962 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4963 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4964 | public static final class Organization implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 4965 | /** |
| 4966 | * This utility class cannot be instantiated |
| 4967 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4968 | private Organization() {} |
| 4969 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4970 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4971 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; |
| 4972 | |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 4973 | public static final int TYPE_WORK = 1; |
| 4974 | public static final int TYPE_OTHER = 2; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4975 | |
| 4976 | /** |
| 4977 | * The company as the user entered it. |
| 4978 | * <P>Type: TEXT</P> |
| 4979 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 4980 | public static final String COMPANY = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4981 | |
| 4982 | /** |
| 4983 | * The position title at this company as the user entered it. |
| 4984 | * <P>Type: TEXT</P> |
| 4985 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 4986 | public static final String TITLE = DATA4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 4987 | |
| 4988 | /** |
| 4989 | * The department at this company as the user entered it. |
| 4990 | * <P>Type: TEXT</P> |
| 4991 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 4992 | public static final String DEPARTMENT = DATA5; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 4993 | |
| 4994 | /** |
| 4995 | * The job description at this company as the user entered it. |
| 4996 | * <P>Type: TEXT</P> |
| 4997 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 4998 | public static final String JOB_DESCRIPTION = DATA6; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 4999 | |
| 5000 | /** |
| 5001 | * The symbol of this company as the user entered it. |
| 5002 | * <P>Type: TEXT</P> |
| 5003 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5004 | public static final String SYMBOL = DATA7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 5005 | |
| 5006 | /** |
| 5007 | * The phonetic name of this company as the user entered it. |
| 5008 | * <P>Type: TEXT</P> |
| 5009 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5010 | public static final String PHONETIC_NAME = DATA8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5011 | |
| 5012 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 5013 | * The office location of this organization. |
| 5014 | * <P>Type: TEXT</P> |
| 5015 | */ |
| 5016 | public static final String OFFICE_LOCATION = DATA9; |
| 5017 | |
| 5018 | /** |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 5019 | * The alphabet used for capturing the phonetic name. |
| 5020 | * See {@link ContactsContract.PhoneticNameStyle}. |
| 5021 | * @hide |
| 5022 | */ |
| 5023 | public static final String PHONETIC_NAME_STYLE = DATA10; |
| 5024 | |
| 5025 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5026 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5027 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5028 | */ |
| 5029 | public static final int getTypeLabelResource(int type) { |
| 5030 | switch (type) { |
| 5031 | case TYPE_WORK: return com.android.internal.R.string.orgTypeWork; |
| 5032 | case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther; |
| 5033 | default: return com.android.internal.R.string.orgTypeCustom; |
| 5034 | } |
| 5035 | } |
| 5036 | |
| 5037 | /** |
| 5038 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5039 | * possibly substituting the given {@link #LABEL} value |
| 5040 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5041 | */ |
| 5042 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 5043 | CharSequence label) { |
| 5044 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 5045 | return label; |
| 5046 | } else { |
| 5047 | final int labelRes = getTypeLabelResource(type); |
| 5048 | return res.getText(labelRes); |
| 5049 | } |
| 5050 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 5051 | } |
| 5052 | |
| 5053 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5054 | * <p> |
| 5055 | * A data kind representing a relation. |
| 5056 | * </p> |
| 5057 | * <p> |
| 5058 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5059 | * well as the following aliases. |
| 5060 | * </p> |
| 5061 | * <h2>Column aliases</h2> |
| 5062 | * <table class="jd-sumtable"> |
| 5063 | * <tr> |
| 5064 | * <th>Type</th> |
| 5065 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5066 | * </tr> |
| 5067 | * <tr> |
| 5068 | * <td>String</td> |
| 5069 | * <td>{@link #NAME}</td> |
| 5070 | * <td>{@link #DATA1}</td> |
| 5071 | * <td></td> |
| 5072 | * </tr> |
| 5073 | * <tr> |
| 5074 | * <td>int</td> |
| 5075 | * <td>{@link #TYPE}</td> |
| 5076 | * <td>{@link #DATA2}</td> |
| 5077 | * <td>Allowed values are: |
| 5078 | * <p> |
| 5079 | * <ul> |
| 5080 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5081 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 5082 | * <li>{@link #TYPE_BROTHER}</li> |
| 5083 | * <li>{@link #TYPE_CHILD}</li> |
| 5084 | * <li>{@link #TYPE_DOMESTIC_PARTNER}</li> |
| 5085 | * <li>{@link #TYPE_FATHER}</li> |
| 5086 | * <li>{@link #TYPE_FRIEND}</li> |
| 5087 | * <li>{@link #TYPE_MANAGER}</li> |
| 5088 | * <li>{@link #TYPE_MOTHER}</li> |
| 5089 | * <li>{@link #TYPE_PARENT}</li> |
| 5090 | * <li>{@link #TYPE_PARTNER}</li> |
| 5091 | * <li>{@link #TYPE_REFERRED_BY}</li> |
| 5092 | * <li>{@link #TYPE_RELATIVE}</li> |
| 5093 | * <li>{@link #TYPE_SISTER}</li> |
| 5094 | * <li>{@link #TYPE_SPOUSE}</li> |
| 5095 | * </ul> |
| 5096 | * </p> |
| 5097 | * </td> |
| 5098 | * </tr> |
| 5099 | * <tr> |
| 5100 | * <td>String</td> |
| 5101 | * <td>{@link #LABEL}</td> |
| 5102 | * <td>{@link #DATA3}</td> |
| 5103 | * <td></td> |
| 5104 | * </tr> |
| 5105 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 5106 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5107 | public static final class Relation implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5108 | /** |
| 5109 | * This utility class cannot be instantiated |
| 5110 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 5111 | private Relation() {} |
| 5112 | |
| 5113 | /** MIME type used when storing this in data table. */ |
| 5114 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; |
| 5115 | |
| 5116 | public static final int TYPE_ASSISTANT = 1; |
| 5117 | public static final int TYPE_BROTHER = 2; |
| 5118 | public static final int TYPE_CHILD = 3; |
| 5119 | public static final int TYPE_DOMESTIC_PARTNER = 4; |
| 5120 | public static final int TYPE_FATHER = 5; |
| 5121 | public static final int TYPE_FRIEND = 6; |
| 5122 | public static final int TYPE_MANAGER = 7; |
| 5123 | public static final int TYPE_MOTHER = 8; |
| 5124 | public static final int TYPE_PARENT = 9; |
| 5125 | public static final int TYPE_PARTNER = 10; |
| 5126 | public static final int TYPE_REFERRED_BY = 11; |
| 5127 | public static final int TYPE_RELATIVE = 12; |
| 5128 | public static final int TYPE_SISTER = 13; |
| 5129 | public static final int TYPE_SPOUSE = 14; |
| 5130 | |
| 5131 | /** |
| 5132 | * The name of the relative as the user entered it. |
| 5133 | * <P>Type: TEXT</P> |
| 5134 | */ |
| 5135 | public static final String NAME = DATA; |
Daniel Lehmann | 1fb39f0 | 2010-10-28 13:40:38 -0700 | [diff] [blame] | 5136 | |
| 5137 | /** |
| 5138 | * Return the string resource that best describes the given |
| 5139 | * {@link #TYPE}. Will always return a valid resource. |
| 5140 | */ |
| 5141 | public static final int getTypeLabelResource(int type) { |
| 5142 | switch (type) { |
| 5143 | case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant; |
| 5144 | case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother; |
| 5145 | case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild; |
| 5146 | case TYPE_DOMESTIC_PARTNER: |
| 5147 | return com.android.internal.R.string.relationTypeDomesticPartner; |
| 5148 | case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather; |
| 5149 | case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend; |
| 5150 | case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager; |
| 5151 | case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother; |
| 5152 | case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent; |
| 5153 | case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner; |
| 5154 | case TYPE_REFERRED_BY: |
| 5155 | return com.android.internal.R.string.relationTypeReferredBy; |
| 5156 | case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative; |
| 5157 | case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister; |
| 5158 | case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse; |
| 5159 | default: return com.android.internal.R.string.orgTypeCustom; |
| 5160 | } |
| 5161 | } |
| 5162 | |
| 5163 | /** |
| 5164 | * Return a {@link CharSequence} that best describes the given type, |
| 5165 | * possibly substituting the given {@link #LABEL} value |
| 5166 | * for {@link #TYPE_CUSTOM}. |
| 5167 | */ |
| 5168 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 5169 | CharSequence label) { |
| 5170 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 5171 | return label; |
| 5172 | } else { |
| 5173 | final int labelRes = getTypeLabelResource(type); |
| 5174 | return res.getText(labelRes); |
| 5175 | } |
| 5176 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 5177 | } |
| 5178 | |
| 5179 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5180 | * <p> |
| 5181 | * A data kind representing an event. |
| 5182 | * </p> |
| 5183 | * <p> |
| 5184 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5185 | * well as the following aliases. |
| 5186 | * </p> |
| 5187 | * <h2>Column aliases</h2> |
| 5188 | * <table class="jd-sumtable"> |
| 5189 | * <tr> |
| 5190 | * <th>Type</th> |
| 5191 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5192 | * </tr> |
| 5193 | * <tr> |
| 5194 | * <td>String</td> |
| 5195 | * <td>{@link #START_DATE}</td> |
| 5196 | * <td>{@link #DATA1}</td> |
| 5197 | * <td></td> |
| 5198 | * </tr> |
| 5199 | * <tr> |
| 5200 | * <td>int</td> |
| 5201 | * <td>{@link #TYPE}</td> |
| 5202 | * <td>{@link #DATA2}</td> |
| 5203 | * <td>Allowed values are: |
| 5204 | * <p> |
| 5205 | * <ul> |
| 5206 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5207 | * <li>{@link #TYPE_ANNIVERSARY}</li> |
| 5208 | * <li>{@link #TYPE_OTHER}</li> |
| 5209 | * <li>{@link #TYPE_BIRTHDAY}</li> |
| 5210 | * </ul> |
| 5211 | * </p> |
| 5212 | * </td> |
| 5213 | * </tr> |
| 5214 | * <tr> |
| 5215 | * <td>String</td> |
| 5216 | * <td>{@link #LABEL}</td> |
| 5217 | * <td>{@link #DATA3}</td> |
| 5218 | * <td></td> |
| 5219 | * </tr> |
| 5220 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 5221 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5222 | public static final class Event implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5223 | /** |
| 5224 | * This utility class cannot be instantiated |
| 5225 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 5226 | private Event() {} |
| 5227 | |
| 5228 | /** MIME type used when storing this in data table. */ |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 5229 | 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] | 5230 | |
| 5231 | public static final int TYPE_ANNIVERSARY = 1; |
| 5232 | public static final int TYPE_OTHER = 2; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 5233 | public static final int TYPE_BIRTHDAY = 3; |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5234 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 5235 | /** |
| 5236 | * The event start date as the user entered it. |
| 5237 | * <P>Type: TEXT</P> |
| 5238 | */ |
| 5239 | public static final String START_DATE = DATA; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 5240 | |
| 5241 | /** |
| 5242 | * Return the string resource that best describes the given |
| 5243 | * {@link #TYPE}. Will always return a valid resource. |
| 5244 | */ |
| 5245 | public static int getTypeResource(Integer type) { |
| 5246 | if (type == null) { |
| 5247 | return com.android.internal.R.string.eventTypeOther; |
| 5248 | } |
| 5249 | switch (type) { |
| 5250 | case TYPE_ANNIVERSARY: |
| 5251 | return com.android.internal.R.string.eventTypeAnniversary; |
| 5252 | case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday; |
| 5253 | case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther; |
Daniel Lehmann | dd384a7 | 2010-11-01 18:40:50 -0700 | [diff] [blame] | 5254 | default: return com.android.internal.R.string.eventTypeCustom; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 5255 | } |
| 5256 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5257 | } |
| 5258 | |
| 5259 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5260 | * <p> |
| 5261 | * A data kind representing an photo for the contact. |
| 5262 | * </p> |
| 5263 | * <p> |
| 5264 | * Some sync adapters will choose to download photos in a separate |
| 5265 | * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1} |
| 5266 | * through {@link ContactsContract.Data#SYNC4} to store temporary |
| 5267 | * data, e.g. the image URL or ID, state of download, server-side version |
| 5268 | * of the image. It is allowed for the {@link #PHOTO} to be null. |
| 5269 | * </p> |
| 5270 | * <p> |
| 5271 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5272 | * well as the following aliases. |
| 5273 | * </p> |
| 5274 | * <h2>Column aliases</h2> |
| 5275 | * <table class="jd-sumtable"> |
| 5276 | * <tr> |
| 5277 | * <th>Type</th> |
| 5278 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5279 | * </tr> |
| 5280 | * <tr> |
| 5281 | * <td>BLOB</td> |
| 5282 | * <td>{@link #PHOTO}</td> |
| 5283 | * <td>{@link #DATA15}</td> |
| 5284 | * <td>By convention, binary data is stored in DATA15.</td> |
| 5285 | * </tr> |
| 5286 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5287 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5288 | public static final class Photo implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5289 | /** |
| 5290 | * This utility class cannot be instantiated |
| 5291 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5292 | private Photo() {} |
| 5293 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5294 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5295 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; |
| 5296 | |
| 5297 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 5298 | * 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] | 5299 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5300 | * <p> |
| 5301 | * Type: BLOB |
| 5302 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5303 | public static final String PHOTO = DATA15; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5304 | } |
| 5305 | |
| 5306 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5307 | * <p> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5308 | * Notes about the contact. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5309 | * </p> |
| 5310 | * <p> |
| 5311 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5312 | * well as the following aliases. |
| 5313 | * </p> |
| 5314 | * <h2>Column aliases</h2> |
| 5315 | * <table class="jd-sumtable"> |
| 5316 | * <tr> |
| 5317 | * <th>Type</th> |
| 5318 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5319 | * </tr> |
| 5320 | * <tr> |
| 5321 | * <td>String</td> |
| 5322 | * <td>{@link #NOTE}</td> |
| 5323 | * <td>{@link #DATA1}</td> |
| 5324 | * <td></td> |
| 5325 | * </tr> |
| 5326 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5327 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5328 | public static final class Note implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5329 | /** |
| 5330 | * This utility class cannot be instantiated |
| 5331 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5332 | private Note() {} |
| 5333 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5334 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5335 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; |
| 5336 | |
| 5337 | /** |
| 5338 | * The note text. |
| 5339 | * <P>Type: TEXT</P> |
| 5340 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5341 | public static final String NOTE = DATA1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5342 | } |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 5343 | |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 5344 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5345 | * <p> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 5346 | * Group Membership. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5347 | * </p> |
| 5348 | * <p> |
| 5349 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5350 | * well as the following aliases. |
| 5351 | * </p> |
| 5352 | * <h2>Column aliases</h2> |
| 5353 | * <table class="jd-sumtable"> |
| 5354 | * <tr> |
| 5355 | * <th>Type</th> |
| 5356 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5357 | * </tr> |
| 5358 | * <tr> |
| 5359 | * <td>long</td> |
| 5360 | * <td>{@link #GROUP_ROW_ID}</td> |
| 5361 | * <td>{@link #DATA1}</td> |
| 5362 | * <td></td> |
| 5363 | * </tr> |
| 5364 | * <tr> |
| 5365 | * <td>String</td> |
| 5366 | * <td>{@link #GROUP_SOURCE_ID}</td> |
| 5367 | * <td>none</td> |
| 5368 | * <td> |
| 5369 | * <p> |
| 5370 | * The sourceid of the group that this group membership refers to. |
| 5371 | * Exactly one of this or {@link #GROUP_ROW_ID} must be set when |
| 5372 | * inserting a row. |
| 5373 | * </p> |
| 5374 | * <p> |
| 5375 | * If this field is specified, the provider will first try to |
| 5376 | * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group |
| 5377 | * is found, it will use the corresponding row id. If the group is not |
| 5378 | * found, it will create one. |
| 5379 | * </td> |
| 5380 | * </tr> |
| 5381 | * </table> |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 5382 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5383 | public static final class GroupMembership implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5384 | /** |
| 5385 | * This utility class cannot be instantiated |
| 5386 | */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 5387 | private GroupMembership() {} |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 5388 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5389 | /** MIME type used when storing this in data table. */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 5390 | public static final String CONTENT_ITEM_TYPE = |
| 5391 | "vnd.android.cursor.item/group_membership"; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 5392 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 5393 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 5394 | * The row id of the group that this group membership refers to. Exactly one of |
| 5395 | * 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] | 5396 | * <P>Type: INTEGER</P> |
| 5397 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5398 | public static final String GROUP_ROW_ID = DATA1; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 5399 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 5400 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 5401 | * The sourceid of the group that this group membership refers to. Exactly one of |
| 5402 | * 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] | 5403 | * <P>Type: TEXT</P> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 5404 | */ |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 5405 | public static final String GROUP_SOURCE_ID = "group_sourceid"; |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 5406 | } |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5407 | |
| 5408 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5409 | * <p> |
| 5410 | * A data kind representing a website related to the contact. |
| 5411 | * </p> |
| 5412 | * <p> |
| 5413 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5414 | * well as the following aliases. |
| 5415 | * </p> |
| 5416 | * <h2>Column aliases</h2> |
| 5417 | * <table class="jd-sumtable"> |
| 5418 | * <tr> |
| 5419 | * <th>Type</th> |
| 5420 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5421 | * </tr> |
| 5422 | * <tr> |
| 5423 | * <td>String</td> |
| 5424 | * <td>{@link #URL}</td> |
| 5425 | * <td>{@link #DATA1}</td> |
| 5426 | * <td></td> |
| 5427 | * </tr> |
| 5428 | * <tr> |
| 5429 | * <td>int</td> |
| 5430 | * <td>{@link #TYPE}</td> |
| 5431 | * <td>{@link #DATA2}</td> |
| 5432 | * <td>Allowed values are: |
| 5433 | * <p> |
| 5434 | * <ul> |
| 5435 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5436 | * <li>{@link #TYPE_HOMEPAGE}</li> |
| 5437 | * <li>{@link #TYPE_BLOG}</li> |
| 5438 | * <li>{@link #TYPE_PROFILE}</li> |
| 5439 | * <li>{@link #TYPE_HOME}</li> |
| 5440 | * <li>{@link #TYPE_WORK}</li> |
| 5441 | * <li>{@link #TYPE_FTP}</li> |
| 5442 | * <li>{@link #TYPE_OTHER}</li> |
| 5443 | * </ul> |
| 5444 | * </p> |
| 5445 | * </td> |
| 5446 | * </tr> |
| 5447 | * <tr> |
| 5448 | * <td>String</td> |
| 5449 | * <td>{@link #LABEL}</td> |
| 5450 | * <td>{@link #DATA3}</td> |
| 5451 | * <td></td> |
| 5452 | * </tr> |
| 5453 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5454 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 5455 | public static final class Website implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5456 | /** |
| 5457 | * This utility class cannot be instantiated |
| 5458 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5459 | private Website() {} |
| 5460 | |
| 5461 | /** MIME type used when storing this in data table. */ |
| 5462 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; |
| 5463 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 5464 | public static final int TYPE_HOMEPAGE = 1; |
| 5465 | public static final int TYPE_BLOG = 2; |
| 5466 | public static final int TYPE_PROFILE = 3; |
| 5467 | public static final int TYPE_HOME = 4; |
| 5468 | public static final int TYPE_WORK = 5; |
| 5469 | public static final int TYPE_FTP = 6; |
| 5470 | public static final int TYPE_OTHER = 7; |
| 5471 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5472 | /** |
| 5473 | * The website URL string. |
| 5474 | * <P>Type: TEXT</P> |
| 5475 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5476 | public static final String URL = DATA; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5477 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 5478 | |
| 5479 | /** |
| 5480 | * <p> |
| 5481 | * A data kind representing a SIP address for the contact. |
| 5482 | * </p> |
| 5483 | * <p> |
| 5484 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5485 | * well as the following aliases. |
| 5486 | * </p> |
| 5487 | * <h2>Column aliases</h2> |
| 5488 | * <table class="jd-sumtable"> |
| 5489 | * <tr> |
| 5490 | * <th>Type</th> |
| 5491 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5492 | * </tr> |
| 5493 | * <tr> |
| 5494 | * <td>String</td> |
| 5495 | * <td>{@link #SIP_ADDRESS}</td> |
| 5496 | * <td>{@link #DATA1}</td> |
| 5497 | * <td></td> |
| 5498 | * </tr> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5499 | * <tr> |
| 5500 | * <td>int</td> |
| 5501 | * <td>{@link #TYPE}</td> |
| 5502 | * <td>{@link #DATA2}</td> |
| 5503 | * <td>Allowed values are: |
| 5504 | * <p> |
| 5505 | * <ul> |
| 5506 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5507 | * <li>{@link #TYPE_HOME}</li> |
| 5508 | * <li>{@link #TYPE_WORK}</li> |
| 5509 | * <li>{@link #TYPE_OTHER}</li> |
| 5510 | * </ul> |
| 5511 | * </p> |
| 5512 | * </td> |
| 5513 | * </tr> |
| 5514 | * <tr> |
| 5515 | * <td>String</td> |
| 5516 | * <td>{@link #LABEL}</td> |
| 5517 | * <td>{@link #DATA3}</td> |
| 5518 | * <td></td> |
| 5519 | * </tr> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 5520 | * </table> |
| 5521 | */ |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5522 | public static final class SipAddress implements DataColumnsWithJoins, CommonColumns { |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 5523 | /** |
| 5524 | * This utility class cannot be instantiated |
| 5525 | */ |
| 5526 | private SipAddress() {} |
| 5527 | |
| 5528 | /** MIME type used when storing this in data table. */ |
| 5529 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address"; |
| 5530 | |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5531 | public static final int TYPE_HOME = 1; |
| 5532 | public static final int TYPE_WORK = 2; |
| 5533 | public static final int TYPE_OTHER = 3; |
| 5534 | |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 5535 | /** |
| 5536 | * The SIP address. |
| 5537 | * <P>Type: TEXT</P> |
| 5538 | */ |
| 5539 | public static final String SIP_ADDRESS = DATA1; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5540 | // ...and TYPE and LABEL come from the CommonColumns interface. |
| 5541 | |
| 5542 | /** |
| 5543 | * Return the string resource that best describes the given |
| 5544 | * {@link #TYPE}. Will always return a valid resource. |
| 5545 | */ |
| 5546 | public static final int getTypeLabelResource(int type) { |
| 5547 | switch (type) { |
| 5548 | case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome; |
| 5549 | case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork; |
| 5550 | case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther; |
| 5551 | default: return com.android.internal.R.string.sipAddressTypeCustom; |
| 5552 | } |
| 5553 | } |
| 5554 | |
| 5555 | /** |
| 5556 | * Return a {@link CharSequence} that best describes the given type, |
| 5557 | * possibly substituting the given {@link #LABEL} value |
| 5558 | * for {@link #TYPE_CUSTOM}. |
| 5559 | */ |
| 5560 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 5561 | CharSequence label) { |
| 5562 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 5563 | return label; |
| 5564 | } else { |
| 5565 | final int labelRes = getTypeLabelResource(type); |
| 5566 | return res.getText(labelRes); |
| 5567 | } |
| 5568 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 5569 | } |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 5570 | } |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 5571 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5572 | /** |
| 5573 | * @see Groups |
| 5574 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5575 | protected interface GroupsColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 5576 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 5577 | * The display title of this group. |
| 5578 | * <p> |
| 5579 | * Type: TEXT |
| 5580 | */ |
| 5581 | public static final String TITLE = "title"; |
| 5582 | |
| 5583 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5584 | * The package name to use when creating {@link Resources} objects for |
| 5585 | * this group. This value is only designed for use when building user |
| 5586 | * interfaces, and should not be used to infer the owner. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5587 | * |
| 5588 | * @hide |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 5589 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5590 | public static final String RES_PACKAGE = "res_package"; |
| 5591 | |
| 5592 | /** |
| 5593 | * The display title of this group to load as a resource from |
| 5594 | * {@link #RES_PACKAGE}, which may be localized. |
| 5595 | * <P>Type: TEXT</P> |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5596 | * |
| 5597 | * @hide |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5598 | */ |
| 5599 | public static final String TITLE_RES = "title_res"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 5600 | |
| 5601 | /** |
Dmitri Plotnikov | 02c5b45 | 2009-07-22 15:13:08 -0700 | [diff] [blame] | 5602 | * Notes about the group. |
| 5603 | * <p> |
| 5604 | * Type: TEXT |
| 5605 | */ |
| 5606 | public static final String NOTES = "notes"; |
| 5607 | |
| 5608 | /** |
| 5609 | * The ID of this group if it is a System Group, i.e. a group that has a special meaning |
| 5610 | * to the sync adapter, null otherwise. |
| 5611 | * <P>Type: TEXT</P> |
| 5612 | */ |
| 5613 | public static final String SYSTEM_ID = "system_id"; |
| 5614 | |
| 5615 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 5616 | * The total number of {@link Contacts} that have |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 5617 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 5618 | * present when querying {@link Groups#CONTENT_SUMMARY_URI}. |
| 5619 | * <p> |
| 5620 | * Type: INTEGER |
| 5621 | */ |
| 5622 | public static final String SUMMARY_COUNT = "summ_count"; |
| 5623 | |
| 5624 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 5625 | * The total number of {@link Contacts} that have both |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 5626 | * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 5627 | * Read-only value that is only present when querying |
| 5628 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 5629 | * <p> |
| 5630 | * Type: INTEGER |
| 5631 | */ |
| 5632 | public static final String SUMMARY_WITH_PHONES = "summ_phones"; |
| 5633 | |
| 5634 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 5635 | * Flag indicating if the contacts belonging to this group should be |
| 5636 | * visible in any user interface. |
| 5637 | * <p> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 5638 | * Type: INTEGER (boolean) |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 5639 | */ |
| 5640 | public static final String GROUP_VISIBLE = "group_visible"; |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 5641 | |
| 5642 | /** |
| 5643 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 5644 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5645 | * called on a group, it is marked for deletion. The sync adaptor |
| 5646 | * deletes the group on the server and then calls ContactResolver.delete |
| 5647 | * once more, this time setting the the |
| 5648 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to |
| 5649 | * finalize the data removal. |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 5650 | * <P>Type: INTEGER</P> |
| 5651 | */ |
| 5652 | public static final String DELETED = "deleted"; |
Jeff Sharkey | 403d7ac | 2009-08-16 16:34:35 -0700 | [diff] [blame] | 5653 | |
| 5654 | /** |
| 5655 | * Whether this group should be synced if the SYNC_EVERYTHING settings |
| 5656 | * is false for this group's account. |
| 5657 | * <p> |
| 5658 | * Type: INTEGER (boolean) |
| 5659 | */ |
| 5660 | public static final String SHOULD_SYNC = "should_sync"; |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 5661 | |
| 5662 | /** |
| 5663 | * Any newly created contacts will automatically be added to groups that have this |
| 5664 | * flag set to true. |
| 5665 | * <p> |
| 5666 | * Type: INTEGER (boolean) |
| 5667 | */ |
| 5668 | public static final String AUTO_ADD = "auto_add"; |
| 5669 | |
| 5670 | /** |
| 5671 | * When a contacts is marked as a favorites it will be automatically added |
| 5672 | * to the groups that have this flag set, and when it is removed from favorites |
| 5673 | * it will be removed from these groups. |
| 5674 | * <p> |
| 5675 | * Type: INTEGER (boolean) |
| 5676 | */ |
| 5677 | public static final String FAVORITES = "favorites"; |
Dmitri Plotnikov | 4ccf33a | 2010-11-19 11:10:43 -0800 | [diff] [blame] | 5678 | |
| 5679 | /** |
| 5680 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 5681 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 5682 | * <P>Type: INTEGER</P> |
| 5683 | */ |
| 5684 | public static final String GROUP_IS_READ_ONLY = "group_is_read_only"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 5685 | } |
| 5686 | |
| 5687 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5688 | * Constants for the groups table. Only per-account groups are supported. |
| 5689 | * <h2>Columns</h2> |
| 5690 | * <table class="jd-sumtable"> |
| 5691 | * <tr> |
| 5692 | * <th colspan='4'>Groups</th> |
| 5693 | * </tr> |
| 5694 | * <tr> |
| 5695 | * <td>long</td> |
| 5696 | * <td>{@link #_ID}</td> |
| 5697 | * <td>read-only</td> |
| 5698 | * <td>Row ID. Sync adapter should try to preserve row IDs during updates. |
| 5699 | * In other words, it would be a really bad idea to delete and reinsert a |
| 5700 | * group. A sync adapter should always do an update instead.</td> |
| 5701 | * </tr> |
| 5702 | * <tr> |
| 5703 | * <td>String</td> |
| 5704 | * <td>{@link #TITLE}</td> |
| 5705 | * <td>read/write</td> |
| 5706 | * <td>The display title of this group.</td> |
| 5707 | * </tr> |
| 5708 | * <tr> |
| 5709 | * <td>String</td> |
| 5710 | * <td>{@link #NOTES}</td> |
| 5711 | * <td>read/write</td> |
| 5712 | * <td>Notes about the group.</td> |
| 5713 | * </tr> |
| 5714 | * <tr> |
| 5715 | * <td>String</td> |
| 5716 | * <td>{@link #SYSTEM_ID}</td> |
| 5717 | * <td>read/write</td> |
| 5718 | * <td>The ID of this group if it is a System Group, i.e. a group that has a |
| 5719 | * special meaning to the sync adapter, null otherwise.</td> |
| 5720 | * </tr> |
| 5721 | * <tr> |
| 5722 | * <td>int</td> |
| 5723 | * <td>{@link #SUMMARY_COUNT}</td> |
| 5724 | * <td>read-only</td> |
| 5725 | * <td>The total number of {@link Contacts} that have |
| 5726 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value |
| 5727 | * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 5728 | * </tr> |
| 5729 | * <tr> |
| 5730 | * <td>int</td> |
| 5731 | * <td>{@link #SUMMARY_WITH_PHONES}</td> |
| 5732 | * <td>read-only</td> |
| 5733 | * <td>The total number of {@link Contacts} that have both |
| 5734 | * {@link CommonDataKinds.GroupMembership} in this group, and also have |
| 5735 | * phone numbers. Read-only value that is only present when querying |
| 5736 | * {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 5737 | * </tr> |
| 5738 | * <tr> |
| 5739 | * <td>int</td> |
| 5740 | * <td>{@link #GROUP_VISIBLE}</td> |
| 5741 | * <td>read-only</td> |
| 5742 | * <td>Flag indicating if the contacts belonging to this group should be |
| 5743 | * visible in any user interface. Allowed values: 0 and 1.</td> |
| 5744 | * </tr> |
| 5745 | * <tr> |
| 5746 | * <td>int</td> |
| 5747 | * <td>{@link #DELETED}</td> |
| 5748 | * <td>read/write</td> |
| 5749 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 5750 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 5751 | * called on a group, it is marked for deletion. The sync adaptor deletes |
| 5752 | * the group on the server and then calls ContactResolver.delete once more, |
| 5753 | * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER} |
| 5754 | * query parameter to finalize the data removal.</td> |
| 5755 | * </tr> |
| 5756 | * <tr> |
| 5757 | * <td>int</td> |
| 5758 | * <td>{@link #SHOULD_SYNC}</td> |
| 5759 | * <td>read/write</td> |
| 5760 | * <td>Whether this group should be synced if the SYNC_EVERYTHING settings |
| 5761 | * is false for this group's account.</td> |
| 5762 | * </tr> |
| 5763 | * </table> |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 5764 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5765 | public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 5766 | /** |
| 5767 | * This utility class cannot be instantiated |
| 5768 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5769 | private Groups() { |
| 5770 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 5771 | |
| 5772 | /** |
| 5773 | * The content:// style URI for this table |
| 5774 | */ |
| 5775 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); |
| 5776 | |
| 5777 | /** |
| 5778 | * The content:// style URI for this table joined with details data from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5779 | * {@link ContactsContract.Data}. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 5780 | */ |
| 5781 | public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 5782 | "groups_summary"); |
| 5783 | |
| 5784 | /** |
| 5785 | * The MIME type of a directory of groups. |
| 5786 | */ |
| 5787 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; |
| 5788 | |
| 5789 | /** |
| 5790 | * The MIME type of a single group. |
| 5791 | */ |
| 5792 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 5793 | |
| 5794 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 5795 | return new EntityIteratorImpl(cursor); |
| 5796 | } |
| 5797 | |
| 5798 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 5799 | public EntityIteratorImpl(Cursor cursor) { |
| 5800 | super(cursor); |
| 5801 | } |
| 5802 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 5803 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 5804 | public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { |
| 5805 | // we expect the cursor is already at the row we need to read from |
| 5806 | final ContentValues values = new ContentValues(); |
| 5807 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID); |
| 5808 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME); |
| 5809 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE); |
| 5810 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY); |
| 5811 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION); |
| 5812 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID); |
| 5813 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE); |
| 5814 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE); |
| 5815 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES); |
| 5816 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE); |
| 5817 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1); |
| 5818 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2); |
| 5819 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3); |
| 5820 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4); |
| 5821 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID); |
| 5822 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED); |
| 5823 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES); |
| 5824 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC); |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 5825 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES); |
| 5826 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 5827 | cursor.moveToNext(); |
| 5828 | return new Entity(values); |
| 5829 | } |
| 5830 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 5831 | } |
| 5832 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 5833 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5834 | * <p> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 5835 | * Constants for the contact aggregation exceptions table, which contains |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5836 | * aggregation rules overriding those used by automatic aggregation. This |
| 5837 | * type only supports query and update. Neither insert nor delete are |
| 5838 | * supported. |
| 5839 | * </p> |
| 5840 | * <h2>Columns</h2> |
| 5841 | * <table class="jd-sumtable"> |
| 5842 | * <tr> |
| 5843 | * <th colspan='4'>AggregationExceptions</th> |
| 5844 | * </tr> |
| 5845 | * <tr> |
| 5846 | * <td>int</td> |
| 5847 | * <td>{@link #TYPE}</td> |
| 5848 | * <td>read/write</td> |
| 5849 | * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER}, |
| 5850 | * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td> |
| 5851 | * </tr> |
| 5852 | * <tr> |
| 5853 | * <td>long</td> |
| 5854 | * <td>{@link #RAW_CONTACT_ID1}</td> |
| 5855 | * <td>read/write</td> |
| 5856 | * <td>A reference to the {@link RawContacts#_ID} of the raw contact that |
| 5857 | * the rule applies to.</td> |
| 5858 | * </tr> |
| 5859 | * <tr> |
| 5860 | * <td>long</td> |
| 5861 | * <td>{@link #RAW_CONTACT_ID2}</td> |
| 5862 | * <td>read/write</td> |
| 5863 | * <td>A reference to the other {@link RawContacts#_ID} of the raw contact |
| 5864 | * that the rule applies to.</td> |
| 5865 | * </tr> |
| 5866 | * </table> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 5867 | */ |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 5868 | public static final class AggregationExceptions implements BaseColumns { |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 5869 | /** |
| 5870 | * This utility class cannot be instantiated |
| 5871 | */ |
| 5872 | private AggregationExceptions() {} |
| 5873 | |
| 5874 | /** |
| 5875 | * The content:// style URI for this table |
| 5876 | */ |
| 5877 | public static final Uri CONTENT_URI = |
| 5878 | Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); |
| 5879 | |
| 5880 | /** |
| 5881 | * The MIME type of {@link #CONTENT_URI} providing a directory of data. |
| 5882 | */ |
| 5883 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; |
| 5884 | |
| 5885 | /** |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 5886 | * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception |
| 5887 | */ |
| 5888 | public static final String CONTENT_ITEM_TYPE = |
| 5889 | "vnd.android.cursor.item/aggregation_exception"; |
| 5890 | |
| 5891 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 5892 | * 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] | 5893 | * {@link #TYPE_AUTOMATIC}. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 5894 | * |
| 5895 | * <P>Type: INTEGER</P> |
| 5896 | */ |
| 5897 | public static final String TYPE = "type"; |
| 5898 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 5899 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 5900 | * Allows the provider to automatically decide whether the specified raw contacts should |
| 5901 | * be included in the same aggregate contact or not. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 5902 | */ |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 5903 | public static final int TYPE_AUTOMATIC = 0; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 5904 | |
| 5905 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 5906 | * Makes sure that the specified raw contacts are included in the same |
| 5907 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 5908 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 5909 | public static final int TYPE_KEEP_TOGETHER = 1; |
| 5910 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 5911 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 5912 | * Makes sure that the specified raw contacts are NOT included in the same |
| 5913 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 5914 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 5915 | public static final int TYPE_KEEP_SEPARATE = 2; |
| 5916 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 5917 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 5918 | * 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] | 5919 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 5920 | public static final String RAW_CONTACT_ID1 = "raw_contact_id1"; |
| 5921 | |
| 5922 | /** |
| 5923 | * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule |
| 5924 | * applies to. |
| 5925 | */ |
| 5926 | public static final String RAW_CONTACT_ID2 = "raw_contact_id2"; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 5927 | } |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 5928 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5929 | /** |
| 5930 | * @see Settings |
| 5931 | */ |
Dmitri Plotnikov | fe4c871 | 2009-10-14 00:28:48 -0700 | [diff] [blame] | 5932 | protected interface SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 5933 | /** |
| 5934 | * The name of the account instance to which this row belongs. |
| 5935 | * <P>Type: TEXT</P> |
| 5936 | */ |
| 5937 | public static final String ACCOUNT_NAME = "account_name"; |
| 5938 | |
| 5939 | /** |
| 5940 | * The type of account to which this row belongs, which when paired with |
| 5941 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 5942 | * <P>Type: TEXT</P> |
| 5943 | */ |
| 5944 | public static final String ACCOUNT_TYPE = "account_type"; |
| 5945 | |
| 5946 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 5947 | * Depending on the mode defined by the sync-adapter, this flag controls |
| 5948 | * the top-level sync behavior for this data source. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 5949 | * <p> |
| 5950 | * Type: INTEGER (boolean) |
| 5951 | */ |
| 5952 | public static final String SHOULD_SYNC = "should_sync"; |
| 5953 | |
| 5954 | /** |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 5955 | * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership} |
Jeff Sharkey | a659744 | 2009-08-19 09:23:33 -0700 | [diff] [blame] | 5956 | * entries should be visible in any user interface. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 5957 | * <p> |
| 5958 | * Type: INTEGER (boolean) |
| 5959 | */ |
| 5960 | public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 5961 | |
| 5962 | /** |
Jeff Sharkey | 97bda4c | 2009-09-15 23:15:23 -0700 | [diff] [blame] | 5963 | * Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 5964 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 5965 | * unsynced. |
| 5966 | */ |
| 5967 | public static final String ANY_UNSYNCED = "any_unsynced"; |
| 5968 | |
| 5969 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 5970 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 5971 | * no {@link CommonDataKinds.GroupMembership} entries. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 5972 | * <p> |
| 5973 | * Type: INTEGER |
| 5974 | */ |
| 5975 | public static final String UNGROUPED_COUNT = "summ_count"; |
| 5976 | |
| 5977 | /** |
| 5978 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 5979 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 5980 | * <p> |
| 5981 | * Type: INTEGER |
| 5982 | */ |
| 5983 | public static final String UNGROUPED_WITH_PHONES = "summ_phones"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 5984 | } |
| 5985 | |
| 5986 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5987 | * <p> |
| 5988 | * Contacts-specific settings for various {@link Account}'s. |
| 5989 | * </p> |
| 5990 | * <h2>Columns</h2> |
| 5991 | * <table class="jd-sumtable"> |
| 5992 | * <tr> |
| 5993 | * <th colspan='4'>Settings</th> |
| 5994 | * </tr> |
| 5995 | * <tr> |
| 5996 | * <td>String</td> |
| 5997 | * <td>{@link #ACCOUNT_NAME}</td> |
| 5998 | * <td>read/write-once</td> |
| 5999 | * <td>The name of the account instance to which this row belongs.</td> |
| 6000 | * </tr> |
| 6001 | * <tr> |
| 6002 | * <td>String</td> |
| 6003 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 6004 | * <td>read/write-once</td> |
| 6005 | * <td>The type of account to which this row belongs, which when paired with |
| 6006 | * {@link #ACCOUNT_NAME} identifies a specific account.</td> |
| 6007 | * </tr> |
| 6008 | * <tr> |
| 6009 | * <td>int</td> |
| 6010 | * <td>{@link #SHOULD_SYNC}</td> |
| 6011 | * <td>read/write</td> |
| 6012 | * <td>Depending on the mode defined by the sync-adapter, this flag controls |
| 6013 | * the top-level sync behavior for this data source.</td> |
| 6014 | * </tr> |
| 6015 | * <tr> |
| 6016 | * <td>int</td> |
| 6017 | * <td>{@link #UNGROUPED_VISIBLE}</td> |
| 6018 | * <td>read/write</td> |
| 6019 | * <td>Flag indicating if contacts without any |
| 6020 | * {@link CommonDataKinds.GroupMembership} entries should be visible in any |
| 6021 | * user interface.</td> |
| 6022 | * </tr> |
| 6023 | * <tr> |
| 6024 | * <td>int</td> |
| 6025 | * <td>{@link #ANY_UNSYNCED}</td> |
| 6026 | * <td>read-only</td> |
| 6027 | * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 6028 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 6029 | * unsynced.</td> |
| 6030 | * </tr> |
| 6031 | * <tr> |
| 6032 | * <td>int</td> |
| 6033 | * <td>{@link #UNGROUPED_COUNT}</td> |
| 6034 | * <td>read-only</td> |
| 6035 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 6036 | * no {@link CommonDataKinds.GroupMembership} entries.</td> |
| 6037 | * </tr> |
| 6038 | * <tr> |
| 6039 | * <td>int</td> |
| 6040 | * <td>{@link #UNGROUPED_WITH_PHONES}</td> |
| 6041 | * <td>read-only</td> |
| 6042 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 6043 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone |
| 6044 | * numbers.</td> |
| 6045 | * </tr> |
| 6046 | * </table> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 6047 | */ |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 6048 | public static final class Settings implements SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 6049 | /** |
| 6050 | * This utility class cannot be instantiated |
| 6051 | */ |
| 6052 | private Settings() { |
| 6053 | } |
| 6054 | |
| 6055 | /** |
| 6056 | * The content:// style URI for this table |
| 6057 | */ |
| 6058 | public static final Uri CONTENT_URI = |
| 6059 | Uri.withAppendedPath(AUTHORITY_URI, "settings"); |
| 6060 | |
| 6061 | /** |
| 6062 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 6063 | * settings. |
| 6064 | */ |
| 6065 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; |
| 6066 | |
| 6067 | /** |
| 6068 | * The MIME-type of {@link #CONTENT_URI} providing a single setting. |
| 6069 | */ |
| 6070 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 6071 | } |
| 6072 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6073 | /** |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 6074 | * Private API for inquiring about the general status of the provider. |
| 6075 | * |
| 6076 | * @hide |
| 6077 | */ |
| 6078 | public static final class ProviderStatus { |
| 6079 | |
| 6080 | /** |
| 6081 | * Not instantiable. |
| 6082 | */ |
| 6083 | private ProviderStatus() { |
| 6084 | } |
| 6085 | |
| 6086 | /** |
| 6087 | * The content:// style URI for this table. Requests to this URI can be |
| 6088 | * performed on the UI thread because they are always unblocking. |
| 6089 | * |
| 6090 | * @hide |
| 6091 | */ |
| 6092 | public static final Uri CONTENT_URI = |
| 6093 | Uri.withAppendedPath(AUTHORITY_URI, "provider_status"); |
| 6094 | |
| 6095 | /** |
| 6096 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 6097 | * settings. |
| 6098 | * |
| 6099 | * @hide |
| 6100 | */ |
| 6101 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status"; |
| 6102 | |
| 6103 | /** |
| 6104 | * An integer representing the current status of the provider. |
| 6105 | * |
| 6106 | * @hide |
| 6107 | */ |
| 6108 | public static final String STATUS = "status"; |
| 6109 | |
| 6110 | /** |
| 6111 | * Default status of the provider. |
| 6112 | * |
| 6113 | * @hide |
| 6114 | */ |
| 6115 | public static final int STATUS_NORMAL = 0; |
| 6116 | |
| 6117 | /** |
| 6118 | * The status used when the provider is in the process of upgrading. Contacts |
| 6119 | * are temporarily unaccessible. |
| 6120 | * |
| 6121 | * @hide |
| 6122 | */ |
| 6123 | public static final int STATUS_UPGRADING = 1; |
| 6124 | |
| 6125 | /** |
| 6126 | * The status used if the provider was in the process of upgrading but ran |
| 6127 | * out of storage. The DATA1 column will contain the estimated amount of |
| 6128 | * storage required (in bytes). Update status to STATUS_NORMAL to force |
| 6129 | * the provider to retry the upgrade. |
| 6130 | * |
| 6131 | * @hide |
| 6132 | */ |
| 6133 | public static final int STATUS_UPGRADE_OUT_OF_MEMORY = 2; |
| 6134 | |
| 6135 | /** |
| 6136 | * The status used during a locale change. |
| 6137 | * |
| 6138 | * @hide |
| 6139 | */ |
| 6140 | public static final int STATUS_CHANGING_LOCALE = 3; |
| 6141 | |
| 6142 | /** |
Dmitri Plotnikov | 37c3486 | 2010-11-12 16:12:53 -0800 | [diff] [blame] | 6143 | * The status that indicates that there are no accounts and no contacts |
| 6144 | * on the device. |
| 6145 | * |
| 6146 | * @hide |
| 6147 | */ |
| 6148 | public static final int STATUS_NO_ACCOUNTS_NO_CONTACTS = 4; |
| 6149 | |
| 6150 | /** |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 6151 | * Additional data associated with the status. |
| 6152 | * |
| 6153 | * @hide |
| 6154 | */ |
| 6155 | public static final String DATA1 = "data1"; |
| 6156 | } |
| 6157 | |
| 6158 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 6159 | * Helper methods to display QuickContact dialogs that allow users to pivot on |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6160 | * a specific {@link Contacts} entry. |
| 6161 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 6162 | public static final class QuickContact { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6163 | /** |
| 6164 | * Action used to trigger person pivot dialog. |
| 6165 | * @hide |
| 6166 | */ |
Evan Millar | 5042f7e | 2009-09-30 21:28:33 -0700 | [diff] [blame] | 6167 | public static final String ACTION_QUICK_CONTACT = |
| 6168 | "com.android.contacts.action.QUICK_CONTACT"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6169 | |
| 6170 | /** |
| 6171 | * Extra used to specify pivot dialog location in screen coordinates. |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 6172 | * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6173 | * @hide |
| 6174 | */ |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 6175 | @Deprecated |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6176 | public static final String EXTRA_TARGET_RECT = "target_rect"; |
| 6177 | |
| 6178 | /** |
| 6179 | * Extra used to specify size of pivot dialog. |
| 6180 | * @hide |
| 6181 | */ |
| 6182 | public static final String EXTRA_MODE = "mode"; |
| 6183 | |
| 6184 | /** |
| 6185 | * Extra used to indicate a list of specific MIME-types to exclude and |
| 6186 | * not display. Stored as a {@link String} array. |
| 6187 | * @hide |
| 6188 | */ |
| 6189 | public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; |
| 6190 | |
| 6191 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 6192 | * Small QuickContact mode, usually presented with minimal actions. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6193 | */ |
| 6194 | public static final int MODE_SMALL = 1; |
| 6195 | |
| 6196 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 6197 | * Medium QuickContact mode, includes actions and light summary describing |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6198 | * the {@link Contacts} entry being shown. This may include social |
| 6199 | * status and presence details. |
| 6200 | */ |
| 6201 | public static final int MODE_MEDIUM = 2; |
| 6202 | |
| 6203 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 6204 | * Large QuickContact mode, includes actions and larger, card-like summary |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6205 | * of the {@link Contacts} entry being shown. This may include detailed |
| 6206 | * information, such as a photo. |
| 6207 | */ |
| 6208 | public static final int MODE_LARGE = 3; |
| 6209 | |
| 6210 | /** |
| 6211 | * Trigger a dialog that lists the various methods of interacting with |
| 6212 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6213 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 6214 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6215 | * |
| 6216 | * @param context The parent {@link Context} that may be used as the |
| 6217 | * parent for this dialog. |
| 6218 | * @param target Specific {@link View} from your layout that this dialog |
| 6219 | * should be centered around. In particular, if the dialog |
| 6220 | * has a "callout" arrow, it will be pointed and centered |
| 6221 | * around this {@link View}. |
Evan Millar | 772722e | 2009-09-30 22:24:07 -0700 | [diff] [blame] | 6222 | * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6223 | * {@link Uri} that describes a specific contact to feature |
| 6224 | * in this dialog. |
| 6225 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 6226 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 6227 | * when supported. |
| 6228 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 6229 | * to exclude when showing this dialog. For example, when |
| 6230 | * already viewing the contact details card, this can be used |
| 6231 | * to omit the details entry from the dialog. |
| 6232 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 6233 | public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6234 | String[] excludeMimes) { |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 6235 | // Find location and bounds of target view, adjusting based on the |
| 6236 | // assumed local density. |
| 6237 | final float appScale = context.getResources().getCompatibilityInfo().applicationScale; |
| 6238 | final int[] pos = new int[2]; |
| 6239 | target.getLocationOnScreen(pos); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6240 | |
| 6241 | final Rect rect = new Rect(); |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 6242 | rect.left = (int) (pos[0] * appScale + 0.5f); |
| 6243 | rect.top = (int) (pos[1] * appScale + 0.5f); |
| 6244 | rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); |
| 6245 | rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6246 | |
| 6247 | // Trigger with obtained rectangle |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 6248 | showQuickContact(context, rect, lookupUri, mode, excludeMimes); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6249 | } |
| 6250 | |
| 6251 | /** |
| 6252 | * Trigger a dialog that lists the various methods of interacting with |
| 6253 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6254 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 6255 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6256 | * |
| 6257 | * @param context The parent {@link Context} that may be used as the |
| 6258 | * parent for this dialog. |
| 6259 | * @param target Specific {@link Rect} that this dialog should be |
| 6260 | * centered around, in screen coordinates. In particular, if |
| 6261 | * the dialog has a "callout" arrow, it will be pointed and |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 6262 | * centered around this {@link Rect}. If you are running at a |
| 6263 | * non-native density, you need to manually adjust using |
| 6264 | * {@link DisplayMetrics#density} before calling. |
Jeff Sharkey | 223bd7a | 2009-12-21 14:51:19 -0800 | [diff] [blame] | 6265 | * @param lookupUri A |
| 6266 | * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6267 | * {@link Uri} that describes a specific contact to feature |
| 6268 | * in this dialog. |
| 6269 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 6270 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 6271 | * when supported. |
| 6272 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 6273 | * to exclude when showing this dialog. For example, when |
| 6274 | * already viewing the contact details card, this can be used |
| 6275 | * to omit the details entry from the dialog. |
| 6276 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 6277 | public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6278 | String[] excludeMimes) { |
| 6279 | // Launch pivot dialog through intent for now |
Evan Millar | 5042f7e | 2009-09-30 21:28:33 -0700 | [diff] [blame] | 6280 | final Intent intent = new Intent(ACTION_QUICK_CONTACT); |
Jeff Sharkey | c00099e | 2009-09-30 22:27:15 -0700 | [diff] [blame] | 6281 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP |
| 6282 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 6283 | |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6284 | intent.setData(lookupUri); |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 6285 | intent.setSourceBounds(target); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6286 | intent.putExtra(EXTRA_MODE, mode); |
| 6287 | intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); |
| 6288 | context.startActivity(intent); |
| 6289 | } |
| 6290 | } |
| 6291 | |
| 6292 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6293 | * Contains helper classes used to create or manage {@link android.content.Intent Intents} |
| 6294 | * that involve contacts. |
| 6295 | */ |
| 6296 | public static final class Intents { |
| 6297 | /** |
| 6298 | * This is the intent that is fired when a search suggestion is clicked on. |
| 6299 | */ |
| 6300 | public static final String SEARCH_SUGGESTION_CLICKED = |
| 6301 | "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; |
| 6302 | |
| 6303 | /** |
| 6304 | * This is the intent that is fired when a search suggestion for dialing a number |
| 6305 | * is clicked on. |
| 6306 | */ |
| 6307 | public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = |
| 6308 | "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; |
| 6309 | |
| 6310 | /** |
| 6311 | * This is the intent that is fired when a search suggestion for creating a contact |
| 6312 | * is clicked on. |
| 6313 | */ |
| 6314 | public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = |
| 6315 | "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; |
| 6316 | |
| 6317 | /** |
| 6318 | * Starts an Activity that lets the user pick a contact to attach an image to. |
| 6319 | * After picking the contact it launches the image cropper in face detection mode. |
| 6320 | */ |
| 6321 | public static final String ATTACH_IMAGE = |
| 6322 | "com.android.contacts.action.ATTACH_IMAGE"; |
| 6323 | |
| 6324 | /** |
| 6325 | * Takes as input a data URI with a mailto: or tel: scheme. If a single |
| 6326 | * contact exists with the given data it will be shown. If no contact |
| 6327 | * exists, a dialog will ask the user if they want to create a new |
| 6328 | * contact with the provided details filled in. If multiple contacts |
| 6329 | * share the data the user will be prompted to pick which contact they |
| 6330 | * want to view. |
| 6331 | * <p> |
| 6332 | * For <code>mailto:</code> URIs, the scheme specific portion must be a |
| 6333 | * raw email address, such as one built using |
| 6334 | * {@link Uri#fromParts(String, String, String)}. |
| 6335 | * <p> |
| 6336 | * For <code>tel:</code> URIs, the scheme specific portion is compared |
| 6337 | * to existing numbers using the standard caller ID lookup algorithm. |
| 6338 | * The number must be properly encoded, for example using |
| 6339 | * {@link Uri#fromParts(String, String, String)}. |
| 6340 | * <p> |
| 6341 | * Any extras from the {@link Insert} class will be passed along to the |
| 6342 | * create activity if there are no contacts to show. |
| 6343 | * <p> |
| 6344 | * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip |
| 6345 | * prompting the user when the contact doesn't exist. |
| 6346 | */ |
| 6347 | public static final String SHOW_OR_CREATE_CONTACT = |
| 6348 | "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; |
| 6349 | |
| 6350 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 6351 | * Starts an Activity that lets the user select the multiple phones from a |
| 6352 | * list of phone numbers which come from the contacts or |
| 6353 | * {@link #EXTRA_PHONE_URIS}. |
| 6354 | * <p> |
| 6355 | * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS} |
| 6356 | * could belong to the contacts or not, and will be selected by default. |
| 6357 | * <p> |
| 6358 | * The user's selection will be returned from |
| 6359 | * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)} |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 6360 | * if the resultCode is |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 6361 | * {@link android.app.Activity#RESULT_OK}, the array of picked phone |
| 6362 | * numbers are in the Intent's |
| 6363 | * {@link #EXTRA_PHONE_URIS}; otherwise, the |
| 6364 | * {@link android.app.Activity#RESULT_CANCELED} is returned if the user |
| 6365 | * left the Activity without changing the selection. |
| 6366 | * |
| 6367 | * @hide |
| 6368 | */ |
| 6369 | public static final String ACTION_GET_MULTIPLE_PHONES = |
| 6370 | "com.android.contacts.action.GET_MULTIPLE_PHONES"; |
| 6371 | |
| 6372 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6373 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new |
| 6374 | * contact if no matching contact found. Otherwise, default behavior is |
| 6375 | * to prompt user with dialog before creating. |
| 6376 | * <p> |
| 6377 | * Type: BOOLEAN |
| 6378 | */ |
| 6379 | public static final String EXTRA_FORCE_CREATE = |
| 6380 | "com.android.contacts.action.FORCE_CREATE"; |
| 6381 | |
| 6382 | /** |
| 6383 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact |
| 6384 | * description to be shown when prompting user about creating a new |
| 6385 | * contact. |
| 6386 | * <p> |
| 6387 | * Type: STRING |
| 6388 | */ |
| 6389 | public static final String EXTRA_CREATE_DESCRIPTION = |
| 6390 | "com.android.contacts.action.CREATE_DESCRIPTION"; |
| 6391 | |
| 6392 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 6393 | * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value. |
| 6394 | * <p> |
| 6395 | * The phone numbers want to be picked by default should be passed in as |
| 6396 | * input value. These phone numbers could belong to the contacts or not. |
| 6397 | * <p> |
| 6398 | * The phone numbers which were picked by the user are returned as output |
| 6399 | * value. |
| 6400 | * <p> |
| 6401 | * Type: array of URIs, the tel URI is used for the phone numbers which don't |
| 6402 | * 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] | 6403 | * |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 6404 | * @hide |
| 6405 | */ |
| 6406 | public static final String EXTRA_PHONE_URIS = |
| 6407 | "com.android.contacts.extra.PHONE_URIS"; |
| 6408 | |
| 6409 | /** |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 6410 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 6411 | * dialog location using screen coordinates. When not specified, the |
| 6412 | * dialog will be centered. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6413 | * |
| 6414 | * @hide |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 6415 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6416 | @Deprecated |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 6417 | public static final String EXTRA_TARGET_RECT = "target_rect"; |
| 6418 | |
| 6419 | /** |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 6420 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 6421 | * desired dialog style, usually a variation on size. One of |
| 6422 | * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6423 | * |
| 6424 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 6425 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6426 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 6427 | public static final String EXTRA_MODE = "mode"; |
| 6428 | |
| 6429 | /** |
| 6430 | * Value for {@link #EXTRA_MODE} to show a small-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6431 | * |
| 6432 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 6433 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6434 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 6435 | public static final int MODE_SMALL = 1; |
| 6436 | |
| 6437 | /** |
| 6438 | * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6439 | * |
| 6440 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 6441 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6442 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 6443 | public static final int MODE_MEDIUM = 2; |
| 6444 | |
| 6445 | /** |
| 6446 | * Value for {@link #EXTRA_MODE} to show a large-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6447 | * |
| 6448 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 6449 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6450 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 6451 | public static final int MODE_LARGE = 3; |
| 6452 | |
| 6453 | /** |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 6454 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate |
| 6455 | * a list of specific MIME-types to exclude and not display. Stored as a |
| 6456 | * {@link String} array. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6457 | * |
| 6458 | * @hide |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 6459 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 6460 | @Deprecated |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 6461 | public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; |
| 6462 | |
| 6463 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6464 | * Intents related to the Contacts app UI. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6465 | * |
| 6466 | * @hide |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6467 | */ |
| 6468 | public static final class UI { |
| 6469 | /** |
| 6470 | * The action for the default contacts list tab. |
| 6471 | */ |
| 6472 | public static final String LIST_DEFAULT = |
| 6473 | "com.android.contacts.action.LIST_DEFAULT"; |
| 6474 | |
| 6475 | /** |
| 6476 | * The action for the contacts list tab. |
| 6477 | */ |
| 6478 | public static final String LIST_GROUP_ACTION = |
| 6479 | "com.android.contacts.action.LIST_GROUP"; |
| 6480 | |
| 6481 | /** |
| 6482 | * When in LIST_GROUP_ACTION mode, this is the group to display. |
| 6483 | */ |
| 6484 | public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP"; |
| 6485 | |
| 6486 | /** |
| 6487 | * The action for the all contacts list tab. |
| 6488 | */ |
| 6489 | public static final String LIST_ALL_CONTACTS_ACTION = |
| 6490 | "com.android.contacts.action.LIST_ALL_CONTACTS"; |
| 6491 | |
| 6492 | /** |
| 6493 | * The action for the contacts with phone numbers list tab. |
| 6494 | */ |
| 6495 | public static final String LIST_CONTACTS_WITH_PHONES_ACTION = |
| 6496 | "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES"; |
| 6497 | |
| 6498 | /** |
| 6499 | * The action for the starred contacts list tab. |
| 6500 | */ |
| 6501 | public static final String LIST_STARRED_ACTION = |
| 6502 | "com.android.contacts.action.LIST_STARRED"; |
| 6503 | |
| 6504 | /** |
| 6505 | * The action for the frequent contacts list tab. |
| 6506 | */ |
| 6507 | public static final String LIST_FREQUENT_ACTION = |
| 6508 | "com.android.contacts.action.LIST_FREQUENT"; |
| 6509 | |
| 6510 | /** |
| 6511 | * The action for the "strequent" contacts list tab. It first lists the starred |
| 6512 | * contacts in alphabetical order and then the frequent contacts in descending |
| 6513 | * order of the number of times they have been contacted. |
| 6514 | */ |
| 6515 | public static final String LIST_STREQUENT_ACTION = |
| 6516 | "com.android.contacts.action.LIST_STREQUENT"; |
| 6517 | |
| 6518 | /** |
| 6519 | * A key for to be used as an intent extra to set the activity |
| 6520 | * title to a custom String value. |
| 6521 | */ |
| 6522 | public static final String TITLE_EXTRA_KEY = |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6523 | "com.android.contacts.extra.TITLE_EXTRA"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6524 | |
| 6525 | /** |
| 6526 | * Activity Action: Display a filtered list of contacts |
| 6527 | * <p> |
| 6528 | * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for |
| 6529 | * filtering |
| 6530 | * <p> |
| 6531 | * Output: Nothing. |
| 6532 | */ |
| 6533 | public static final String FILTER_CONTACTS_ACTION = |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6534 | "com.android.contacts.action.FILTER_CONTACTS"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6535 | |
| 6536 | /** |
| 6537 | * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION} |
| 6538 | * intents to supply the text on which to filter. |
| 6539 | */ |
| 6540 | public static final String FILTER_TEXT_EXTRA_KEY = |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6541 | "com.android.contacts.extra.FILTER_TEXT"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6542 | } |
| 6543 | |
| 6544 | /** |
| 6545 | * Convenience class that contains string constants used |
| 6546 | * to create contact {@link android.content.Intent Intents}. |
| 6547 | */ |
| 6548 | public static final class Insert { |
| 6549 | /** The action code to use when adding a contact */ |
| 6550 | public static final String ACTION = Intent.ACTION_INSERT; |
| 6551 | |
| 6552 | /** |
| 6553 | * If present, forces a bypass of quick insert mode. |
| 6554 | */ |
| 6555 | public static final String FULL_MODE = "full_mode"; |
| 6556 | |
| 6557 | /** |
| 6558 | * The extra field for the contact name. |
| 6559 | * <P>Type: String</P> |
| 6560 | */ |
| 6561 | public static final String NAME = "name"; |
| 6562 | |
| 6563 | // TODO add structured name values here. |
| 6564 | |
| 6565 | /** |
| 6566 | * The extra field for the contact phonetic name. |
| 6567 | * <P>Type: String</P> |
| 6568 | */ |
| 6569 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 6570 | |
| 6571 | /** |
| 6572 | * The extra field for the contact company. |
| 6573 | * <P>Type: String</P> |
| 6574 | */ |
| 6575 | public static final String COMPANY = "company"; |
| 6576 | |
| 6577 | /** |
| 6578 | * The extra field for the contact job title. |
| 6579 | * <P>Type: String</P> |
| 6580 | */ |
| 6581 | public static final String JOB_TITLE = "job_title"; |
| 6582 | |
| 6583 | /** |
| 6584 | * The extra field for the contact notes. |
| 6585 | * <P>Type: String</P> |
| 6586 | */ |
| 6587 | public static final String NOTES = "notes"; |
| 6588 | |
| 6589 | /** |
| 6590 | * The extra field for the contact phone number. |
| 6591 | * <P>Type: String</P> |
| 6592 | */ |
| 6593 | public static final String PHONE = "phone"; |
| 6594 | |
| 6595 | /** |
| 6596 | * The extra field for the contact phone number type. |
| 6597 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6598 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6599 | * or a string specifying a custom label.</P> |
| 6600 | */ |
| 6601 | public static final String PHONE_TYPE = "phone_type"; |
| 6602 | |
| 6603 | /** |
| 6604 | * The extra field for the phone isprimary flag. |
| 6605 | * <P>Type: boolean</P> |
| 6606 | */ |
| 6607 | public static final String PHONE_ISPRIMARY = "phone_isprimary"; |
| 6608 | |
| 6609 | /** |
| 6610 | * The extra field for an optional second contact phone number. |
| 6611 | * <P>Type: String</P> |
| 6612 | */ |
| 6613 | public static final String SECONDARY_PHONE = "secondary_phone"; |
| 6614 | |
| 6615 | /** |
| 6616 | * The extra field for an optional second contact phone number type. |
| 6617 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6618 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6619 | * or a string specifying a custom label.</P> |
| 6620 | */ |
| 6621 | public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; |
| 6622 | |
| 6623 | /** |
| 6624 | * The extra field for an optional third contact phone number. |
| 6625 | * <P>Type: String</P> |
| 6626 | */ |
| 6627 | public static final String TERTIARY_PHONE = "tertiary_phone"; |
| 6628 | |
| 6629 | /** |
| 6630 | * The extra field for an optional third contact phone number type. |
| 6631 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6632 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6633 | * or a string specifying a custom label.</P> |
| 6634 | */ |
| 6635 | public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; |
| 6636 | |
| 6637 | /** |
| 6638 | * The extra field for the contact email address. |
| 6639 | * <P>Type: String</P> |
| 6640 | */ |
| 6641 | public static final String EMAIL = "email"; |
| 6642 | |
| 6643 | /** |
| 6644 | * The extra field for the contact email type. |
| 6645 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6646 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6647 | * or a string specifying a custom label.</P> |
| 6648 | */ |
| 6649 | public static final String EMAIL_TYPE = "email_type"; |
| 6650 | |
| 6651 | /** |
| 6652 | * The extra field for the email isprimary flag. |
| 6653 | * <P>Type: boolean</P> |
| 6654 | */ |
| 6655 | public static final String EMAIL_ISPRIMARY = "email_isprimary"; |
| 6656 | |
| 6657 | /** |
| 6658 | * The extra field for an optional second contact email address. |
| 6659 | * <P>Type: String</P> |
| 6660 | */ |
| 6661 | public static final String SECONDARY_EMAIL = "secondary_email"; |
| 6662 | |
| 6663 | /** |
| 6664 | * The extra field for an optional second contact email type. |
| 6665 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6666 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6667 | * or a string specifying a custom label.</P> |
| 6668 | */ |
| 6669 | public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; |
| 6670 | |
| 6671 | /** |
| 6672 | * The extra field for an optional third contact email address. |
| 6673 | * <P>Type: String</P> |
| 6674 | */ |
| 6675 | public static final String TERTIARY_EMAIL = "tertiary_email"; |
| 6676 | |
| 6677 | /** |
| 6678 | * The extra field for an optional third contact email type. |
| 6679 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6680 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6681 | * or a string specifying a custom label.</P> |
| 6682 | */ |
| 6683 | public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; |
| 6684 | |
| 6685 | /** |
| 6686 | * The extra field for the contact postal address. |
| 6687 | * <P>Type: String</P> |
| 6688 | */ |
| 6689 | public static final String POSTAL = "postal"; |
| 6690 | |
| 6691 | /** |
| 6692 | * The extra field for the contact postal address type. |
| 6693 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6694 | * {@link CommonDataKinds.StructuredPostal} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6695 | * or a string specifying a custom label.</P> |
| 6696 | */ |
| 6697 | public static final String POSTAL_TYPE = "postal_type"; |
| 6698 | |
| 6699 | /** |
| 6700 | * The extra field for the postal isprimary flag. |
| 6701 | * <P>Type: boolean</P> |
| 6702 | */ |
| 6703 | public static final String POSTAL_ISPRIMARY = "postal_isprimary"; |
| 6704 | |
| 6705 | /** |
| 6706 | * The extra field for an IM handle. |
| 6707 | * <P>Type: String</P> |
| 6708 | */ |
| 6709 | public static final String IM_HANDLE = "im_handle"; |
| 6710 | |
| 6711 | /** |
| 6712 | * The extra field for the IM protocol |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6713 | */ |
| 6714 | public static final String IM_PROTOCOL = "im_protocol"; |
| 6715 | |
| 6716 | /** |
| 6717 | * The extra field for the IM isprimary flag. |
| 6718 | * <P>Type: boolean</P> |
| 6719 | */ |
| 6720 | public static final String IM_ISPRIMARY = "im_isprimary"; |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 6721 | |
| 6722 | /** |
| 6723 | * The extra field that allows the client to supply multiple rows of |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 6724 | * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT} |
| 6725 | * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of |
| 6726 | * {@link ContentValues}, one per data row. Supplying this extra is |
| 6727 | * similar to inserting multiple rows into the {@link Data} table, |
| 6728 | * except the user gets a chance to see and edit them before saving. |
| 6729 | * Each ContentValues object must have a value for {@link Data#MIMETYPE}. |
| 6730 | * If supplied values are not visible in the editor UI, they will be |
| 6731 | * dropped. Duplicate data will dropped. Some fields |
| 6732 | * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically |
| 6733 | * adjusted to comply with the constraints of the specific account type. |
| 6734 | * For example, an Exchange contact can only have one phone numbers of type Home, |
| 6735 | * so the contact editor may choose a different type for this phone number to |
| 6736 | * avoid dropping the valueable part of the row, which is the phone number. |
| 6737 | * <p> |
| 6738 | * Example: |
| 6739 | * <pre> |
| 6740 | * ArrayList<ContentValues> data = new ArrayList<ContentValues>(); |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 6741 | * |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 6742 | * ContentValues row1 = new ContentValues(); |
| 6743 | * row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE); |
| 6744 | * row1.put(Organization.COMPANY, "Android"); |
| 6745 | * data.add(row1); |
| 6746 | * |
| 6747 | * ContentValues row2 = new ContentValues(); |
| 6748 | * row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE); |
| 6749 | * row2.put(Email.TYPE, Email.TYPE_CUSTOM); |
| 6750 | * row2.put(Email.LABEL, "Green Bot"); |
| 6751 | * row2.put(Email.ADDRESS, "android@android.com"); |
| 6752 | * data.add(row2); |
| 6753 | * |
| 6754 | * Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); |
| 6755 | * intent.putParcelableArrayListExtra(Insert.DATA, data); |
| 6756 | * |
| 6757 | * startActivity(intent); |
| 6758 | * </pre> |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 6759 | */ |
| 6760 | public static final String DATA = "data"; |
Daniel Lehmann | cde1ac6 | 2010-10-21 20:40:11 -0700 | [diff] [blame] | 6761 | |
| 6762 | /** |
| 6763 | * Used to specify the account in which to create the new contact. |
| 6764 | * <p> |
| 6765 | * If this value is not provided, the user is presented with a disambiguation |
| 6766 | * dialog to chose an account |
| 6767 | * <p> |
| 6768 | * Type: {@link Account} |
| 6769 | * |
| 6770 | * @hide |
| 6771 | */ |
| 6772 | public static final String ACCOUNT = "com.android.contacts.extra.ACCOUNT"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 6773 | } |
| 6774 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6775 | } |