Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
| 17 | package android.provider; |
| 18 | |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 19 | import android.accounts.Account; |
Daniel Lehmann | e6d3d28 | 2011-07-13 15:35:05 -0700 | [diff] [blame] | 20 | import android.app.Activity; |
Yorke Lee | 4fc601a | 2013-12-06 16:35:29 -0800 | [diff] [blame] | 21 | import android.content.ActivityNotFoundException; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 22 | import android.content.ContentProviderClient; |
| 23 | import android.content.ContentProviderOperation; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 24 | import android.content.ContentResolver; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 25 | import android.content.ContentUris; |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 26 | import android.content.ContentValues; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 27 | import android.content.Context; |
Makoto Onuki | bba33cd | 2012-05-25 17:09:05 -0700 | [diff] [blame] | 28 | import android.content.ContextWrapper; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 29 | import android.content.CursorEntityIterator; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 30 | import android.content.Entity; |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 31 | import android.content.EntityIterator; |
| 32 | import android.content.Intent; |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 33 | import android.content.res.AssetFileDescriptor; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 34 | import android.content.res.Resources; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 35 | import android.database.Cursor; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 36 | import android.database.DatabaseUtils; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 37 | import android.graphics.Rect; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 38 | import android.net.Uri; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 39 | import android.os.RemoteException; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 40 | import android.text.TextUtils; |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 41 | import android.util.DisplayMetrics; |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 42 | import android.util.Pair; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 43 | import android.view.View; |
Yorke Lee | 4fc601a | 2013-12-06 16:35:29 -0800 | [diff] [blame] | 44 | import android.widget.Toast; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 45 | |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 46 | import java.io.ByteArrayInputStream; |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 47 | import java.io.IOException; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 48 | import java.io.InputStream; |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 49 | import java.util.ArrayList; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 50 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 51 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 52 | * <p> |
| 53 | * The contract between the contacts provider and applications. Contains |
| 54 | * definitions for the supported URIs and columns. These APIs supersede |
| 55 | * {@link Contacts}. |
| 56 | * </p> |
| 57 | * <h3>Overview</h3> |
| 58 | * <p> |
| 59 | * ContactsContract defines an extensible database of contact-related |
| 60 | * information. Contact information is stored in a three-tier data model: |
| 61 | * </p> |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 62 | * <ul> |
| 63 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 64 | * A row in the {@link Data} table can store any kind of personal data, such |
| 65 | * as a phone number or email addresses. The set of data kinds that can be |
| 66 | * stored in this table is open-ended. There is a predefined set of common |
| 67 | * kinds, but any application can add its own data kinds. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 68 | * </li> |
| 69 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 70 | * A row in the {@link RawContacts} table represents a set of data describing a |
| 71 | * person and associated with a single account (for example, one of the user's |
| 72 | * Gmail accounts). |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 73 | * </li> |
| 74 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 75 | * 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] | 76 | * RawContacts presumably describing the same person. When data in or associated with |
| 77 | * the RawContacts table is changed, the affected aggregate contacts are updated as |
| 78 | * necessary. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 79 | * </li> |
| 80 | * </ul> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 81 | * <p> |
| 82 | * Other tables include: |
| 83 | * </p> |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 84 | * <ul> |
| 85 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 86 | * {@link Groups}, which contains information about raw contact groups |
| 87 | * such as Gmail contact groups. The |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 88 | * current API does not support the notion of groups spanning multiple accounts. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 89 | * </li> |
| 90 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 91 | * {@link StatusUpdates}, which contains social status updates including IM |
| 92 | * availability. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 93 | * </li> |
| 94 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 95 | * {@link AggregationExceptions}, which is used for manual aggregation and |
| 96 | * disaggregation of raw contacts |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 97 | * </li> |
| 98 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 99 | * {@link Settings}, which contains visibility and sync settings for accounts |
| 100 | * and groups. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 101 | * </li> |
| 102 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 103 | * {@link SyncState}, which contains free-form data maintained on behalf of sync |
| 104 | * adapters |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 105 | * </li> |
| 106 | * <li> |
| 107 | * {@link PhoneLookup}, which is used for quick caller-ID lookup</li> |
| 108 | * </ul> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 109 | */ |
Jeff Hamilton | 0c23212 | 2009-09-24 00:26:50 -0500 | [diff] [blame] | 110 | @SuppressWarnings("unused") |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 111 | public final class ContactsContract { |
| 112 | /** The authority for the contacts provider */ |
| 113 | public static final String AUTHORITY = "com.android.contacts"; |
| 114 | /** A content:// style uri to the authority for the contacts provider */ |
| 115 | public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); |
| 116 | |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 117 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 118 | * An optional URI parameter for insert, update, or delete queries |
| 119 | * that allows the caller |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 120 | * 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] | 121 | * {@link RawContacts#DIRTY} is not automatically set and the |
| 122 | * "syncToNetwork" parameter is set to false when calling |
| 123 | * {@link |
| 124 | * ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}. |
| 125 | * This prevents an unnecessary extra synchronization, see the discussion of |
| 126 | * the delete operation in {@link RawContacts}. |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 127 | */ |
| 128 | public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter"; |
| 129 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 130 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 131 | * Query parameter that should be used by the client to access a specific |
| 132 | * {@link Directory}. The parameter value should be the _ID of the corresponding |
| 133 | * directory, e.g. |
| 134 | * {@code content://com.android.contacts/data/emails/filter/acme?directory=3} |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 135 | */ |
| 136 | public static final String DIRECTORY_PARAM_KEY = "directory"; |
| 137 | |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 138 | /** |
Dmitri Plotnikov | 5a998dd | 2010-08-31 17:32:16 -0700 | [diff] [blame] | 139 | * A query parameter that limits the number of results returned. The |
| 140 | * parameter value should be an integer. |
| 141 | */ |
| 142 | public static final String LIMIT_PARAM_KEY = "limit"; |
| 143 | |
| 144 | /** |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 145 | * A query parameter specifing a primary account. This parameter should be used with |
| 146 | * {@link #PRIMARY_ACCOUNT_TYPE}. The contacts provider handling a query may rely on |
| 147 | * this information to optimize its query results. |
| 148 | * |
| 149 | * For example, in an email composition screen, its implementation can specify an account when |
| 150 | * obtaining possible recipients, letting the provider know which account is selected during |
| 151 | * the composition. The provider may use the "primary account" information to optimize |
| 152 | * the search result. |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 153 | */ |
| 154 | public static final String PRIMARY_ACCOUNT_NAME = "name_for_primary_account"; |
| 155 | |
| 156 | /** |
| 157 | * A query parameter specifing a primary account. This parameter should be used with |
| 158 | * {@link #PRIMARY_ACCOUNT_NAME}. See the doc in {@link #PRIMARY_ACCOUNT_NAME}. |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 159 | */ |
| 160 | public static final String PRIMARY_ACCOUNT_TYPE = "type_for_primary_account"; |
| 161 | |
Daisuke Miyakawa | f468591 | 2011-06-25 12:31:13 -0700 | [diff] [blame] | 162 | /** |
| 163 | * A boolean parameter for {@link Contacts#CONTENT_STREQUENT_URI} and |
| 164 | * {@link Contacts#CONTENT_STREQUENT_FILTER_URI}, which requires the ContactsProvider to |
| 165 | * return only phone-related results. For example, frequently contacted person list should |
| 166 | * include persons contacted via phone (not email, sms, etc.) |
Daisuke Miyakawa | f468591 | 2011-06-25 12:31:13 -0700 | [diff] [blame] | 167 | */ |
| 168 | public static final String STREQUENT_PHONE_ONLY = "strequent_phone_only"; |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 169 | |
| 170 | /** |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 171 | * A key to a boolean in the "extras" bundle of the cursor. |
| 172 | * The boolean indicates that the provider did not create a snippet and that the client asking |
| 173 | * for the snippet should do it (true means the snippeting was deferred to the client). |
Yorke Lee | eaf0949 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 174 | * |
| 175 | * @see SearchSnippets |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 176 | */ |
| 177 | public static final String DEFERRED_SNIPPETING = "deferred_snippeting"; |
| 178 | |
| 179 | /** |
Yorke Lee | eaf0949 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 180 | * Key to retrieve the original deferred snippeting from the cursor on the client side. |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 181 | * |
Yorke Lee | eaf0949 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 182 | * @see SearchSnippets |
| 183 | * @see #DEFERRED_SNIPPETING |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 184 | */ |
| 185 | public static final String DEFERRED_SNIPPETING_QUERY = "deferred_snippeting_query"; |
| 186 | |
| 187 | /** |
Yorke Lee | 1ca440b | 2014-06-04 18:01:46 -0700 | [diff] [blame] | 188 | * A boolean parameter for {@link CommonDataKinds.Phone#CONTENT_URI Phone.CONTENT_URI}, |
| 189 | * {@link CommonDataKinds.Email#CONTENT_URI Email.CONTENT_URI}, and |
| 190 | * {@link CommonDataKinds.StructuredPostal#CONTENT_URI StructuredPostal.CONTENT_URI}. |
Daisuke Miyakawa | 19352e0 | 2011-11-14 13:16:07 -0800 | [diff] [blame] | 191 | * This enables a content provider to remove duplicate entries in results. |
Daisuke Miyakawa | 19352e0 | 2011-11-14 13:16:07 -0800 | [diff] [blame] | 192 | */ |
| 193 | public static final String REMOVE_DUPLICATE_ENTRIES = "remove_duplicate_entries"; |
| 194 | |
| 195 | /** |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 196 | * <p> |
| 197 | * API for obtaining a pre-authorized version of a URI that normally requires special |
| 198 | * permission (beyond READ_CONTACTS) to read. The caller obtaining the pre-authorized URI |
| 199 | * must already have the necessary permissions to access the URI; otherwise a |
| 200 | * {@link SecurityException} will be thrown. |
| 201 | * </p> |
| 202 | * <p> |
| 203 | * The authorized URI returned in the bundle contains an expiring token that allows the |
| 204 | * caller to execute the query without having the special permissions that would normally |
| 205 | * be required. |
| 206 | * </p> |
| 207 | * <p> |
| 208 | * This API does not access disk, and should be safe to invoke from the UI thread. |
| 209 | * </p> |
| 210 | * <p> |
| 211 | * Example usage: |
| 212 | * <pre> |
| 213 | * Uri profileUri = ContactsContract.Profile.CONTENT_VCARD_URI; |
| 214 | * Bundle uriBundle = new Bundle(); |
| 215 | * uriBundle.putParcelable(ContactsContract.Authorization.KEY_URI_TO_AUTHORIZE, uri); |
| 216 | * Bundle authResponse = getContext().getContentResolver().call( |
| 217 | * ContactsContract.AUTHORITY_URI, |
| 218 | * ContactsContract.Authorization.AUTHORIZATION_METHOD, |
| 219 | * null, // String arg, not used. |
| 220 | * uriBundle); |
| 221 | * if (authResponse != null) { |
| 222 | * Uri preauthorizedProfileUri = (Uri) authResponse.getParcelable( |
| 223 | * ContactsContract.Authorization.KEY_AUTHORIZED_URI); |
| 224 | * // This pre-authorized URI can be queried by a caller without READ_PROFILE |
| 225 | * // permission. |
| 226 | * } |
| 227 | * </pre> |
| 228 | * </p> |
| 229 | * @hide |
| 230 | */ |
| 231 | public static final class Authorization { |
| 232 | /** |
| 233 | * The method to invoke to create a pre-authorized URI out of the input argument. |
| 234 | */ |
| 235 | public static final String AUTHORIZATION_METHOD = "authorize"; |
| 236 | |
| 237 | /** |
| 238 | * The key to set in the outbound Bundle with the URI that should be authorized. |
| 239 | */ |
| 240 | public static final String KEY_URI_TO_AUTHORIZE = "uri_to_authorize"; |
| 241 | |
| 242 | /** |
| 243 | * The key to retrieve from the returned Bundle to obtain the pre-authorized URI. |
| 244 | */ |
| 245 | public static final String KEY_AUTHORIZED_URI = "authorized_uri"; |
| 246 | } |
| 247 | |
Yorke Lee | 6355c8f | 2014-07-08 11:48:42 -0700 | [diff] [blame] | 248 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 249 | * A Directory represents a contacts corpus, e.g. Local contacts, |
| 250 | * Google Apps Global Address List or Corporate Global Address List. |
| 251 | * <p> |
| 252 | * A Directory is implemented as a content provider with its unique authority and |
| 253 | * the same API as the main Contacts Provider. However, there is no expectation that |
| 254 | * every directory provider will implement this Contract in its entirety. If a |
| 255 | * directory provider does not have an implementation for a specific request, it |
| 256 | * should throw an UnsupportedOperationException. |
| 257 | * </p> |
| 258 | * <p> |
| 259 | * 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] | 260 | * expected to support at least {@link ContactsContract.Contacts#CONTENT_FILTER_URI |
| 261 | * Contacts.CONTENT_FILTER_URI}. If a Directory provider wants to participate |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 262 | * in email and phone lookup functionalities, it should also implement |
| 263 | * {@link CommonDataKinds.Email#CONTENT_FILTER_URI CommonDataKinds.Email.CONTENT_FILTER_URI} |
| 264 | * and |
| 265 | * {@link CommonDataKinds.Phone#CONTENT_FILTER_URI CommonDataKinds.Phone.CONTENT_FILTER_URI}. |
| 266 | * </p> |
| 267 | * <p> |
| 268 | * A directory provider should return NULL for every projection field it does not |
| 269 | * recognize, rather than throwing an exception. This way it will not be broken |
| 270 | * if ContactsContract is extended with new fields in the future. |
| 271 | * </p> |
| 272 | * <p> |
| 273 | * The client interacts with a directory via Contacts Provider by supplying an |
| 274 | * optional {@code directory=} query parameter. |
| 275 | * <p> |
| 276 | * <p> |
| 277 | * When the Contacts Provider receives the request, it transforms the URI and forwards |
| 278 | * the request to the corresponding directory content provider. |
| 279 | * The URI is transformed in the following fashion: |
| 280 | * <ul> |
| 281 | * <li>The URI authority is replaced with the corresponding {@link #DIRECTORY_AUTHORITY}.</li> |
| 282 | * <li>The {@code accountName=} and {@code accountType=} parameters are added or |
| 283 | * replaced using the corresponding {@link #ACCOUNT_TYPE} and {@link #ACCOUNT_NAME} values.</li> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 284 | * </ul> |
| 285 | * </p> |
| 286 | * <p> |
| 287 | * Clients should send directory requests to Contacts Provider and let it |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 288 | * forward them to the respective providers rather than constructing |
| 289 | * directory provider URIs by themselves. This level of indirection allows |
| 290 | * Contacts Provider to implement additional system-level features and |
| 291 | * optimizations. Access to Contacts Provider is protected by the |
Subir Jhanb | 603af61 | 2012-08-06 17:19:22 -0700 | [diff] [blame] | 292 | * READ_CONTACTS permission, but access to the directory provider is protected by |
| 293 | * BIND_DIRECTORY_SEARCH. This permission was introduced at the API level 17, for previous |
| 294 | * platform versions the provider should perform the following check to make sure the call |
| 295 | * is coming from the ContactsProvider: |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 296 | * <pre> |
| 297 | * private boolean isCallerAllowed() { |
| 298 | * PackageManager pm = getContext().getPackageManager(); |
| 299 | * for (String packageName: pm.getPackagesForUid(Binder.getCallingUid())) { |
| 300 | * if (packageName.equals("com.android.providers.contacts")) { |
| 301 | * return true; |
| 302 | * } |
| 303 | * } |
| 304 | * return false; |
| 305 | * } |
| 306 | * </pre> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 307 | * </p> |
| 308 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 309 | * The Directory table is read-only and is maintained by the Contacts Provider |
| 310 | * automatically. |
| 311 | * </p> |
| 312 | * <p>It always has at least these two rows: |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 313 | * <ul> |
| 314 | * <li> |
| 315 | * The local directory. It has {@link Directory#_ID Directory._ID} = |
| 316 | * {@link Directory#DEFAULT Directory.DEFAULT}. This directory can be used to access locally |
| 317 | * stored contacts. The same can be achieved by omitting the {@code directory=} |
| 318 | * parameter altogether. |
| 319 | * </li> |
| 320 | * <li> |
| 321 | * The local invisible contacts. The corresponding directory ID is |
| 322 | * {@link Directory#LOCAL_INVISIBLE Directory.LOCAL_INVISIBLE}. |
| 323 | * </li> |
| 324 | * </ul> |
| 325 | * </p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 326 | * <p>Custom Directories are discovered by the Contacts Provider following this procedure: |
| 327 | * <ul> |
| 328 | * <li>It finds all installed content providers with meta data identifying them |
| 329 | * as directory providers in AndroidManifest.xml: |
| 330 | * <code> |
| 331 | * <meta-data android:name="android.content.ContactDirectory" |
| 332 | * android:value="true" /> |
| 333 | * </code> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 334 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 335 | * This tag should be placed inside the corresponding content provider declaration. |
| 336 | * </p> |
| 337 | * </li> |
| 338 | * <li> |
| 339 | * Then Contacts Provider sends a {@link Directory#CONTENT_URI Directory.CONTENT_URI} |
| 340 | * query to each of the directory authorities. A directory provider must implement |
| 341 | * this query and return a list of directories. Each directory returned by |
| 342 | * the provider must have a unique combination for the {@link #ACCOUNT_NAME} and |
| 343 | * {@link #ACCOUNT_TYPE} columns (nulls are allowed). Since directory IDs are assigned |
| 344 | * automatically, the _ID field will not be part of the query projection. |
| 345 | * </li> |
| 346 | * <li>Contacts Provider compiles directory lists received from all directory |
| 347 | * providers into one, assigns each individual directory a globally unique ID and |
| 348 | * stores all directory records in the Directory table. |
| 349 | * </li> |
| 350 | * </ul> |
| 351 | * </p> |
| 352 | * <p>Contacts Provider automatically interrogates newly installed or replaced packages. |
| 353 | * Thus simply installing a package containing a directory provider is sufficient |
| 354 | * to have that provider registered. A package supplying a directory provider does |
| 355 | * not have to contain launchable activities. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 356 | * </p> |
| 357 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 358 | * Every row in the Directory table is automatically associated with the corresponding package |
| 359 | * (apk). If the package is later uninstalled, all corresponding directory rows |
| 360 | * are automatically removed from the Contacts Provider. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 361 | * </p> |
| 362 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 363 | * When the list of directories handled by a directory provider changes |
| 364 | * (for instance when the user adds a new Directory account), the directory provider |
| 365 | * should call {@link #notifyDirectoryChange} to notify the Contacts Provider of the change. |
| 366 | * In response, the Contacts Provider will requery the directory provider to obtain the |
| 367 | * new list of directories. |
| 368 | * </p> |
| 369 | * <p> |
| 370 | * A directory row can be optionally associated with an existing account |
| 371 | * (see {@link android.accounts.AccountManager}). If the account is later removed, |
Dmitri Plotnikov | e50ed08 | 2010-08-18 10:56:09 -0700 | [diff] [blame] | 372 | * the corresponding directory rows are automatically removed from the Contacts Provider. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 373 | * </p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 374 | */ |
| 375 | public static final class Directory implements BaseColumns { |
| 376 | |
| 377 | /** |
| 378 | * Not instantiable. |
| 379 | */ |
| 380 | private Directory() { |
| 381 | } |
| 382 | |
| 383 | /** |
| 384 | * The content:// style URI for this table. Requests to this URI can be |
| 385 | * performed on the UI thread because they are always unblocking. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 386 | */ |
| 387 | public static final Uri CONTENT_URI = |
| 388 | Uri.withAppendedPath(AUTHORITY_URI, "directories"); |
| 389 | |
| 390 | /** |
| 391 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 392 | * contact directories. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 393 | */ |
| 394 | public static final String CONTENT_TYPE = |
| 395 | "vnd.android.cursor.dir/contact_directories"; |
| 396 | |
| 397 | /** |
| 398 | * The MIME type of a {@link #CONTENT_URI} item. |
| 399 | */ |
| 400 | public static final String CONTENT_ITEM_TYPE = |
| 401 | "vnd.android.cursor.item/contact_directory"; |
| 402 | |
| 403 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 404 | * _ID of the default directory, which represents locally stored contacts. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 405 | */ |
| 406 | public static final long DEFAULT = 0; |
| 407 | |
| 408 | /** |
| 409 | * _ID of the directory that represents locally stored invisible contacts. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 410 | */ |
| 411 | public static final long LOCAL_INVISIBLE = 1; |
| 412 | |
| 413 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 414 | * The name of the package that owns this directory. Contacts Provider |
| 415 | * fill it in with the name of the package containing the directory provider. |
| 416 | * If the package is later uninstalled, the directories it owns are |
| 417 | * automatically removed from this table. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 418 | * |
| 419 | * <p>TYPE: TEXT</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 420 | */ |
| 421 | public static final String PACKAGE_NAME = "packageName"; |
| 422 | |
| 423 | /** |
| 424 | * The type of directory captured as a resource ID in the context of the |
| 425 | * package {@link #PACKAGE_NAME}, e.g. "Corporate Directory" |
| 426 | * |
| 427 | * <p>TYPE: INTEGER</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 428 | */ |
| 429 | public static final String TYPE_RESOURCE_ID = "typeResourceId"; |
| 430 | |
| 431 | /** |
| 432 | * An optional name that can be used in the UI to represent this directory, |
| 433 | * e.g. "Acme Corp" |
| 434 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 435 | */ |
| 436 | public static final String DISPLAY_NAME = "displayName"; |
| 437 | |
| 438 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 439 | * <p> |
| 440 | * The authority of the Directory Provider. Contacts Provider will |
| 441 | * use this authority to forward requests to the directory provider. |
| 442 | * A directory provider can leave this column empty - Contacts Provider will fill it in. |
| 443 | * </p> |
| 444 | * <p> |
| 445 | * Clients of this API should not send requests directly to this authority. |
| 446 | * All directory requests must be routed through Contacts Provider. |
| 447 | * </p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 448 | * |
| 449 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 450 | */ |
| 451 | public static final String DIRECTORY_AUTHORITY = "authority"; |
| 452 | |
| 453 | /** |
| 454 | * The account type which this directory is associated. |
| 455 | * |
| 456 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 457 | */ |
| 458 | public static final String ACCOUNT_TYPE = "accountType"; |
| 459 | |
| 460 | /** |
| 461 | * The account with which this directory is associated. If the account is later |
| 462 | * removed, the directories it owns are automatically removed from this table. |
| 463 | * |
| 464 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 465 | */ |
| 466 | public static final String ACCOUNT_NAME = "accountName"; |
| 467 | |
| 468 | /** |
| 469 | * One of {@link #EXPORT_SUPPORT_NONE}, {@link #EXPORT_SUPPORT_ANY_ACCOUNT}, |
| 470 | * {@link #EXPORT_SUPPORT_SAME_ACCOUNT_ONLY}. This is the expectation the |
| 471 | * directory has for data exported from it. Clients must obey this setting. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 472 | */ |
| 473 | public static final String EXPORT_SUPPORT = "exportSupport"; |
| 474 | |
| 475 | /** |
| 476 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 477 | * does not allow any data to be copied out of it. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 478 | */ |
| 479 | public static final int EXPORT_SUPPORT_NONE = 0; |
| 480 | |
| 481 | /** |
| 482 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 483 | * allow its data copied only to the account specified by |
| 484 | * {@link #ACCOUNT_TYPE}/{@link #ACCOUNT_NAME}. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 485 | */ |
| 486 | public static final int EXPORT_SUPPORT_SAME_ACCOUNT_ONLY = 1; |
| 487 | |
| 488 | /** |
| 489 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 490 | * allow its data copied to any contacts account. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 491 | */ |
| 492 | public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2; |
| 493 | |
| 494 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 495 | * One of {@link #SHORTCUT_SUPPORT_NONE}, {@link #SHORTCUT_SUPPORT_DATA_ITEMS_ONLY}, |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 496 | * {@link #SHORTCUT_SUPPORT_FULL}. This is the expectation the directory |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 497 | * has for shortcuts created for its elements. Clients must obey this setting. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 498 | */ |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 499 | public static final String SHORTCUT_SUPPORT = "shortcutSupport"; |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 500 | |
| 501 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 502 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 503 | * does not allow any shortcuts created for its contacts. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 504 | */ |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 505 | public static final int SHORTCUT_SUPPORT_NONE = 0; |
| 506 | |
| 507 | /** |
| 508 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 509 | * allow creation of shortcuts for data items like email, phone or postal address, |
| 510 | * but not the entire contact. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 511 | */ |
| 512 | public static final int SHORTCUT_SUPPORT_DATA_ITEMS_ONLY = 1; |
| 513 | |
| 514 | /** |
| 515 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 516 | * allow creation of shortcuts for contact as well as their constituent elements. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 517 | */ |
| 518 | public static final int SHORTCUT_SUPPORT_FULL = 2; |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 519 | |
| 520 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 521 | * One of {@link #PHOTO_SUPPORT_NONE}, {@link #PHOTO_SUPPORT_THUMBNAIL_ONLY}, |
| 522 | * {@link #PHOTO_SUPPORT_FULL}. This is a feature flag indicating the extent |
| 523 | * to which the directory supports contact photos. |
| 524 | */ |
| 525 | public static final String PHOTO_SUPPORT = "photoSupport"; |
| 526 | |
| 527 | /** |
| 528 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 529 | * does not provide any photos. |
| 530 | */ |
| 531 | public static final int PHOTO_SUPPORT_NONE = 0; |
| 532 | |
| 533 | /** |
| 534 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 535 | * can only produce small size thumbnails of contact photos. |
| 536 | */ |
| 537 | public static final int PHOTO_SUPPORT_THUMBNAIL_ONLY = 1; |
| 538 | |
| 539 | /** |
| 540 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 541 | * has full-size contact photos, but cannot provide scaled thumbnails. |
| 542 | */ |
| 543 | public static final int PHOTO_SUPPORT_FULL_SIZE_ONLY = 2; |
| 544 | |
| 545 | /** |
| 546 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 547 | * can produce thumbnails as well as full-size contact photos. |
| 548 | */ |
| 549 | public static final int PHOTO_SUPPORT_FULL = 3; |
| 550 | |
| 551 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 552 | * Notifies the system of a change in the list of directories handled by |
| 553 | * a particular directory provider. The Contacts provider will turn around |
| 554 | * and send a query to the directory provider for the full list of directories, |
| 555 | * which will replace the previous list. |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 556 | */ |
| 557 | public static void notifyDirectoryChange(ContentResolver resolver) { |
| 558 | // This is done to trigger a query by Contacts Provider back to the directory provider. |
| 559 | // No data needs to be sent back, because the provider can infer the calling |
| 560 | // package from binder. |
| 561 | ContentValues contentValues = new ContentValues(); |
| 562 | resolver.update(Directory.CONTENT_URI, contentValues, null, null); |
| 563 | } |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 567 | * @hide should be removed when users are updated to refer to SyncState |
| 568 | * @deprecated use SyncState instead |
| 569 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 570 | @Deprecated |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 571 | public interface SyncStateColumns extends SyncStateContract.Columns { |
| 572 | } |
| 573 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 574 | /** |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 575 | * A table provided for sync adapters to use for storing private sync state data for contacts. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 576 | * |
| 577 | * @see SyncStateContract |
| 578 | */ |
| 579 | public static final class SyncState implements SyncStateContract.Columns { |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 580 | /** |
| 581 | * This utility class cannot be instantiated |
| 582 | */ |
| 583 | private SyncState() {} |
| 584 | |
| 585 | public static final String CONTENT_DIRECTORY = |
| 586 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 587 | |
| 588 | /** |
| 589 | * The content:// style URI for this table |
| 590 | */ |
| 591 | public static final Uri CONTENT_URI = |
| 592 | Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY); |
| 593 | |
| 594 | /** |
| 595 | * @see android.provider.SyncStateContract.Helpers#get |
| 596 | */ |
| 597 | public static byte[] get(ContentProviderClient provider, Account account) |
| 598 | throws RemoteException { |
| 599 | return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| 600 | } |
| 601 | |
| 602 | /** |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 603 | * @see android.provider.SyncStateContract.Helpers#get |
| 604 | */ |
| 605 | public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) |
| 606 | throws RemoteException { |
| 607 | return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); |
| 608 | } |
| 609 | |
| 610 | /** |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 611 | * @see android.provider.SyncStateContract.Helpers#set |
| 612 | */ |
| 613 | public static void set(ContentProviderClient provider, Account account, byte[] data) |
| 614 | throws RemoteException { |
| 615 | SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| 616 | } |
| 617 | |
| 618 | /** |
| 619 | * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| 620 | */ |
| 621 | public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| 622 | return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| 623 | } |
| 624 | } |
| 625 | |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 626 | |
| 627 | /** |
| 628 | * A table provided for sync adapters to use for storing private sync state data for the |
| 629 | * user's personal profile. |
| 630 | * |
| 631 | * @see SyncStateContract |
| 632 | */ |
| 633 | public static final class ProfileSyncState implements SyncStateContract.Columns { |
| 634 | /** |
| 635 | * This utility class cannot be instantiated |
| 636 | */ |
| 637 | private ProfileSyncState() {} |
| 638 | |
| 639 | public static final String CONTENT_DIRECTORY = |
| 640 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 641 | |
| 642 | /** |
| 643 | * The content:// style URI for this table |
| 644 | */ |
| 645 | public static final Uri CONTENT_URI = |
| 646 | Uri.withAppendedPath(Profile.CONTENT_URI, CONTENT_DIRECTORY); |
| 647 | |
| 648 | /** |
| 649 | * @see android.provider.SyncStateContract.Helpers#get |
| 650 | */ |
| 651 | public static byte[] get(ContentProviderClient provider, Account account) |
| 652 | throws RemoteException { |
| 653 | return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| 654 | } |
| 655 | |
| 656 | /** |
| 657 | * @see android.provider.SyncStateContract.Helpers#get |
| 658 | */ |
| 659 | public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) |
| 660 | throws RemoteException { |
| 661 | return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); |
| 662 | } |
| 663 | |
| 664 | /** |
| 665 | * @see android.provider.SyncStateContract.Helpers#set |
| 666 | */ |
| 667 | public static void set(ContentProviderClient provider, Account account, byte[] data) |
| 668 | throws RemoteException { |
| 669 | SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| 670 | } |
| 671 | |
| 672 | /** |
| 673 | * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| 674 | */ |
| 675 | public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| 676 | return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| 677 | } |
| 678 | } |
| 679 | |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 680 | /** |
| 681 | * Generic columns for use by sync adapters. The specific functions of |
| 682 | * these columns are private to the sync adapter. Other clients of the API |
| 683 | * should not attempt to either read or write this column. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 684 | * |
| 685 | * @see RawContacts |
| 686 | * @see Groups |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 687 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 688 | protected interface BaseSyncColumns { |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 689 | |
| 690 | /** Generic column for use by sync adapters. */ |
| 691 | public static final String SYNC1 = "sync1"; |
| 692 | /** Generic column for use by sync adapters. */ |
| 693 | public static final String SYNC2 = "sync2"; |
| 694 | /** Generic column for use by sync adapters. */ |
| 695 | public static final String SYNC3 = "sync3"; |
| 696 | /** Generic column for use by sync adapters. */ |
| 697 | public static final String SYNC4 = "sync4"; |
| 698 | } |
| 699 | |
| 700 | /** |
| 701 | * Columns that appear when each row of a table belongs to a specific |
| 702 | * account, including sync information that an account may need. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 703 | * |
| 704 | * @see RawContacts |
| 705 | * @see Groups |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 706 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 707 | protected interface SyncColumns extends BaseSyncColumns { |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 708 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 709 | * The name of the account instance to which this row belongs, which when paired with |
| 710 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 711 | * <P>Type: TEXT</P> |
| 712 | */ |
| 713 | public static final String ACCOUNT_NAME = "account_name"; |
| 714 | |
| 715 | /** |
| 716 | * The type of account to which this row belongs, which when paired with |
| 717 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 718 | * <P>Type: TEXT</P> |
| 719 | */ |
| 720 | public static final String ACCOUNT_TYPE = "account_type"; |
| 721 | |
| 722 | /** |
| 723 | * String that uniquely identifies this row to its source account. |
| 724 | * <P>Type: TEXT</P> |
| 725 | */ |
| 726 | public static final String SOURCE_ID = "sourceid"; |
| 727 | |
| 728 | /** |
| 729 | * Version number that is updated whenever this row or its related data |
| 730 | * changes. |
| 731 | * <P>Type: INTEGER</P> |
| 732 | */ |
| 733 | public static final String VERSION = "version"; |
| 734 | |
| 735 | /** |
| 736 | * Flag indicating that {@link #VERSION} has changed, and this row needs |
| 737 | * to be synchronized by its owning account. |
| 738 | * <P>Type: INTEGER (boolean)</P> |
| 739 | */ |
| 740 | public static final String DIRTY = "dirty"; |
| 741 | } |
| 742 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 743 | /** |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 744 | * Columns of {@link ContactsContract.Contacts} that track the user's |
| 745 | * preferences for, or interactions with, the contact. |
| 746 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 747 | * @see Contacts |
| 748 | * @see RawContacts |
| 749 | * @see ContactsContract.Data |
| 750 | * @see PhoneLookup |
| 751 | * @see ContactsContract.Contacts.AggregationSuggestions |
| 752 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 753 | protected interface ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 754 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 755 | * The number of times a contact has been contacted |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 756 | * <P>Type: INTEGER</P> |
| 757 | */ |
| 758 | public static final String TIMES_CONTACTED = "times_contacted"; |
| 759 | |
| 760 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 761 | * The last time a contact was contacted. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 762 | * <P>Type: INTEGER</P> |
| 763 | */ |
| 764 | public static final String LAST_TIME_CONTACTED = "last_time_contacted"; |
| 765 | |
| 766 | /** |
| 767 | * Is the contact starred? |
| 768 | * <P>Type: INTEGER (boolean)</P> |
| 769 | */ |
| 770 | public static final String STARRED = "starred"; |
| 771 | |
| 772 | /** |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 773 | * The position at which the contact is pinned. If {@link PinnedPositions#UNPINNED}, |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 774 | * the contact is not pinned. Also see {@link PinnedPositions}. |
| 775 | * <P>Type: INTEGER </P> |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 776 | */ |
| 777 | public static final String PINNED = "pinned"; |
| 778 | |
| 779 | /** |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 780 | * URI for a custom ringtone associated with the contact. If null or missing, |
| 781 | * the default ringtone is used. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 782 | * <P>Type: TEXT (URI to the ringtone)</P> |
| 783 | */ |
| 784 | public static final String CUSTOM_RINGTONE = "custom_ringtone"; |
| 785 | |
| 786 | /** |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 787 | * Whether the contact should always be sent to voicemail. If missing, |
| 788 | * defaults to false. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 789 | * <P>Type: INTEGER (0 for false, 1 for true)</P> |
| 790 | */ |
| 791 | public static final String SEND_TO_VOICEMAIL = "send_to_voicemail"; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 792 | } |
| 793 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 794 | /** |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 795 | * Columns of {@link ContactsContract.Contacts} that refer to intrinsic |
| 796 | * properties of the contact, as opposed to the user-specified options |
| 797 | * found in {@link ContactOptionsColumns}. |
| 798 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 799 | * @see Contacts |
| 800 | * @see ContactsContract.Data |
| 801 | * @see PhoneLookup |
| 802 | * @see ContactsContract.Contacts.AggregationSuggestions |
| 803 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 804 | protected interface ContactsColumns { |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 805 | /** |
| 806 | * The display name for the contact. |
| 807 | * <P>Type: TEXT</P> |
| 808 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 809 | public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY; |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 810 | |
| 811 | /** |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 812 | * Reference to the row in the RawContacts table holding the contact name. |
| 813 | * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 814 | */ |
| 815 | public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id"; |
| 816 | |
| 817 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 818 | * Reference to the row in the data table holding the photo. A photo can |
| 819 | * be referred to either by ID (this field) or by URI (see {@link #PHOTO_THUMBNAIL_URI} |
| 820 | * and {@link #PHOTO_URI}). |
| 821 | * If PHOTO_ID is null, consult {@link #PHOTO_URI} or {@link #PHOTO_THUMBNAIL_URI}, |
| 822 | * which is a more generic mechanism for referencing the contact photo, especially for |
| 823 | * contacts returned by non-local directories (see {@link Directory}). |
| 824 | * |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 825 | * <P>Type: INTEGER REFERENCES data(_id)</P> |
| 826 | */ |
| 827 | public static final String PHOTO_ID = "photo_id"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 828 | |
| 829 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 830 | * Photo file ID of the full-size photo. If present, this will be used to populate |
| 831 | * {@link #PHOTO_URI}. The ID can also be used with |
| 832 | * {@link ContactsContract.DisplayPhoto#CONTENT_URI} to create a URI to the photo. |
| 833 | * If this is present, {@link #PHOTO_ID} is also guaranteed to be populated. |
| 834 | * |
| 835 | * <P>Type: INTEGER</P> |
| 836 | */ |
| 837 | public static final String PHOTO_FILE_ID = "photo_file_id"; |
| 838 | |
| 839 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 840 | * A URI that can be used to retrieve the contact's full-size photo. |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 841 | * If PHOTO_FILE_ID is not null, this will be populated with a URI based off |
| 842 | * {@link ContactsContract.DisplayPhoto#CONTENT_URI}. Otherwise, this will |
| 843 | * be populated with the same value as {@link #PHOTO_THUMBNAIL_URI}. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 844 | * A photo can be referred to either by a URI (this field) or by ID |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 845 | * (see {@link #PHOTO_ID}). If either PHOTO_FILE_ID or PHOTO_ID is not null, |
| 846 | * PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily |
| 847 | * vice versa). Thus using PHOTO_URI is a more robust method of retrieving |
| 848 | * contact photos. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 849 | * |
| 850 | * <P>Type: TEXT</P> |
| 851 | */ |
| 852 | public static final String PHOTO_URI = "photo_uri"; |
| 853 | |
| 854 | /** |
| 855 | * A URI that can be used to retrieve a thumbnail of the contact's photo. |
| 856 | * A photo can be referred to either by a URI (this field or {@link #PHOTO_URI}) |
| 857 | * or by ID (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and |
| 858 | * PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa). |
| 859 | * If the content provider does not differentiate between full-size photos |
| 860 | * and thumbnail photos, PHOTO_THUMBNAIL_URI and {@link #PHOTO_URI} can contain |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 861 | * the same value, but either both shall be null or both not null. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 862 | * |
| 863 | * <P>Type: TEXT</P> |
| 864 | */ |
| 865 | public static final String PHOTO_THUMBNAIL_URI = "photo_thumb_uri"; |
| 866 | |
| 867 | /** |
Brian Attwell | 2fa85d3 | 2014-03-04 17:41:13 -0800 | [diff] [blame] | 868 | * Flag that reflects whether the contact exists inside the default directory. |
| 869 | * Ie, whether the contact is designed to only be visible outside search. |
Brian Attwell | 2fa85d3 | 2014-03-04 17:41:13 -0800 | [diff] [blame] | 870 | */ |
| 871 | public static final String IN_DEFAULT_DIRECTORY = "in_default_directory"; |
| 872 | |
| 873 | /** |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 874 | * Flag that reflects the {@link Groups#GROUP_VISIBLE} state of any |
| 875 | * {@link CommonDataKinds.GroupMembership} for this contact. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 876 | */ |
| 877 | public static final String IN_VISIBLE_GROUP = "in_visible_group"; |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 878 | |
| 879 | /** |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 880 | * Flag that reflects whether this contact represents the user's |
| 881 | * personal profile entry. |
| 882 | */ |
| 883 | public static final String IS_USER_PROFILE = "is_user_profile"; |
| 884 | |
| 885 | /** |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 886 | * An indicator of whether this contact has at least one phone number. "1" if there is |
| 887 | * at least one phone number, "0" otherwise. |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 888 | * <P>Type: INTEGER</P> |
| 889 | */ |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 890 | public static final String HAS_PHONE_NUMBER = "has_phone_number"; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 891 | |
| 892 | /** |
| 893 | * An opaque value that contains hints on how to find the contact if |
| 894 | * its row id changed as a result of a sync or aggregation. |
| 895 | */ |
| 896 | public static final String LOOKUP_KEY = "lookup"; |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 897 | |
| 898 | /** |
| 899 | * Timestamp (milliseconds since epoch) of when this contact was last updated. This |
| 900 | * includes updates to all data associated with this contact including raw contacts. Any |
| 901 | * modification (including deletes and inserts) of underlying contact data are also |
| 902 | * reflected in this timestamp. |
| 903 | */ |
| 904 | public static final String CONTACT_LAST_UPDATED_TIMESTAMP = |
| 905 | "contact_last_updated_timestamp"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 906 | } |
| 907 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 908 | /** |
| 909 | * @see Contacts |
| 910 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 911 | protected interface ContactStatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 912 | /** |
| 913 | * Contact presence status. See {@link StatusUpdates} for individual status |
| 914 | * definitions. |
| 915 | * <p>Type: NUMBER</p> |
| 916 | */ |
| 917 | public static final String CONTACT_PRESENCE = "contact_presence"; |
| 918 | |
| 919 | /** |
Vasu Nori | fb5bccf | 2010-07-19 14:11:54 -0700 | [diff] [blame] | 920 | * Contact Chat Capabilities. See {@link StatusUpdates} for individual |
Vasu Nori | 5b31498 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 921 | * definitions. |
| 922 | * <p>Type: NUMBER</p> |
| 923 | */ |
| 924 | public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability"; |
| 925 | |
| 926 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 927 | * Contact's latest status update. |
| 928 | * <p>Type: TEXT</p> |
| 929 | */ |
| 930 | public static final String CONTACT_STATUS = "contact_status"; |
| 931 | |
| 932 | /** |
| 933 | * The absolute time in milliseconds when the latest status was |
| 934 | * inserted/updated. |
| 935 | * <p>Type: NUMBER</p> |
| 936 | */ |
| 937 | public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts"; |
| 938 | |
| 939 | /** |
| 940 | * The package containing resources for this status: label and icon. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 941 | * <p>Type: TEXT</p> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 942 | */ |
| 943 | public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package"; |
| 944 | |
| 945 | /** |
| 946 | * The resource ID of the label describing the source of contact |
| 947 | * status, e.g. "Google Talk". This resource is scoped by the |
| 948 | * {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 949 | * <p>Type: NUMBER</p> |
| 950 | */ |
| 951 | public static final String CONTACT_STATUS_LABEL = "contact_status_label"; |
| 952 | |
| 953 | /** |
| 954 | * The resource ID of the icon for the source of contact status. This |
| 955 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 956 | * <p>Type: NUMBER</p> |
| 957 | */ |
| 958 | public static final String CONTACT_STATUS_ICON = "contact_status_icon"; |
| 959 | } |
| 960 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 961 | /** |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 962 | * Constants for various styles of combining given name, family name etc into |
| 963 | * a full name. For example, the western tradition follows the pattern |
| 964 | * 'given name' 'middle name' 'family name' with the alternative pattern being |
| 965 | * 'family name', 'given name' 'middle name'. The CJK tradition is |
| 966 | * 'family name' 'middle name' 'given name', with Japanese favoring a space between |
| 967 | * the names and Chinese omitting the space. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 968 | */ |
| 969 | public interface FullNameStyle { |
| 970 | public static final int UNDEFINED = 0; |
| 971 | public static final int WESTERN = 1; |
| 972 | |
| 973 | /** |
| 974 | * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine |
| 975 | * which specific language it belongs to: Chinese, Japanese or Korean. |
| 976 | */ |
| 977 | public static final int CJK = 2; |
| 978 | |
| 979 | public static final int CHINESE = 3; |
| 980 | public static final int JAPANESE = 4; |
| 981 | public static final int KOREAN = 5; |
| 982 | } |
| 983 | |
| 984 | /** |
| 985 | * 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] | 986 | */ |
| 987 | public interface PhoneticNameStyle { |
| 988 | public static final int UNDEFINED = 0; |
| 989 | |
| 990 | /** |
| 991 | * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly |
| 992 | * shown in UIs, but used for searches and sorting. |
| 993 | */ |
| 994 | public static final int PINYIN = 3; |
| 995 | |
| 996 | /** |
| 997 | * Hiragana and Katakana are two common styles of writing out the pronunciation |
| 998 | * of a Japanese names. |
| 999 | */ |
| 1000 | public static final int JAPANESE = 4; |
| 1001 | |
| 1002 | /** |
| 1003 | * Hangul is the Korean phonetic alphabet. |
| 1004 | */ |
| 1005 | public static final int KOREAN = 5; |
| 1006 | } |
| 1007 | |
| 1008 | /** |
Dmitri Plotnikov | dbcdbf2 | 2011-02-23 15:49:58 -0800 | [diff] [blame] | 1009 | * Types of data used to produce the display name for a contact. In the order |
| 1010 | * of increasing priority: {@link #EMAIL}, {@link #PHONE}, |
| 1011 | * {@link #ORGANIZATION}, {@link #NICKNAME}, {@link #STRUCTURED_NAME}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1012 | */ |
| 1013 | public interface DisplayNameSources { |
| 1014 | public static final int UNDEFINED = 0; |
| 1015 | public static final int EMAIL = 10; |
| 1016 | public static final int PHONE = 20; |
| 1017 | public static final int ORGANIZATION = 30; |
| 1018 | public static final int NICKNAME = 35; |
| 1019 | public static final int STRUCTURED_NAME = 40; |
| 1020 | } |
| 1021 | |
| 1022 | /** |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 1023 | * Contact name and contact name metadata columns in the RawContacts table. |
| 1024 | * |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1025 | * @see Contacts |
| 1026 | * @see RawContacts |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1027 | */ |
| 1028 | protected interface ContactNameColumns { |
| 1029 | |
| 1030 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1031 | * 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] | 1032 | * structured name or email address. See {@link DisplayNameSources}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1033 | */ |
| 1034 | public static final String DISPLAY_NAME_SOURCE = "display_name_source"; |
| 1035 | |
| 1036 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1037 | * <p> |
| 1038 | * The standard text shown as the contact's display name, based on the best |
| 1039 | * available information for the contact (for example, it might be the email address |
| 1040 | * if the name is not available). |
| 1041 | * The information actually used to compute the name is stored in |
| 1042 | * {@link #DISPLAY_NAME_SOURCE}. |
| 1043 | * </p> |
| 1044 | * <p> |
| 1045 | * A contacts provider is free to choose whatever representation makes most |
| 1046 | * sense for its target market. |
| 1047 | * For example in the default Android Open Source Project implementation, |
| 1048 | * if the display name is |
| 1049 | * based on the structured name and the structured name follows |
| 1050 | * the Western full-name style, then this field contains the "given name first" |
| 1051 | * version of the full name. |
| 1052 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1053 | * |
| 1054 | * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1055 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1056 | public static final String DISPLAY_NAME_PRIMARY = "display_name"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1057 | |
| 1058 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1059 | * <p> |
| 1060 | * An alternative representation of the display name, such as "family name first" |
| 1061 | * instead of "given name first" for Western names. If an alternative is not |
| 1062 | * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}. |
| 1063 | * </p> |
| 1064 | * <p> |
| 1065 | * A contacts provider is free to provide alternatives as necessary for |
| 1066 | * its target market. |
| 1067 | * For example the default Android Open Source Project contacts provider |
| 1068 | * currently provides an |
| 1069 | * alternative in a single case: if the display name is |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1070 | * based on the structured name and the structured name follows |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1071 | * the Western full name style, then the field contains the "family name first" |
| 1072 | * version of the full name. |
| 1073 | * Other cases may be added later. |
| 1074 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1075 | */ |
| 1076 | public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt"; |
| 1077 | |
| 1078 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1079 | * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}. See |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 1080 | * {@link PhoneticNameStyle}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1081 | */ |
| 1082 | public static final String PHONETIC_NAME_STYLE = "phonetic_name_style"; |
| 1083 | |
| 1084 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1085 | * <p> |
| 1086 | * Pronunciation of the full name in the phonetic alphabet specified by |
| 1087 | * {@link #PHONETIC_NAME_STYLE}. |
| 1088 | * </p> |
| 1089 | * <p> |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 1090 | * The value may be set manually by the user. This capability is of |
| 1091 | * interest only in countries with commonly used phonetic alphabets, |
| 1092 | * such as Japan and Korea. See {@link PhoneticNameStyle}. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1093 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1094 | */ |
| 1095 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 1096 | |
| 1097 | /** |
| 1098 | * Sort key that takes into account locale-based traditions for sorting |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1099 | * names in address books. The default |
| 1100 | * sort key is {@link #DISPLAY_NAME_PRIMARY}. For Chinese names |
| 1101 | * 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] | 1102 | * it is the Hiragana version of the phonetic name. |
| 1103 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1104 | public static final String SORT_KEY_PRIMARY = "sort_key"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1105 | |
| 1106 | /** |
| 1107 | * Sort key based on the alternative representation of the full name, |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1108 | * {@link #DISPLAY_NAME_ALTERNATIVE}. Thus for Western names, |
Dmitri Plotnikov | 2a650dd | 2010-01-26 17:28:52 -0800 | [diff] [blame] | 1109 | * it is the one using the "family name first" format. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1110 | */ |
| 1111 | public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt"; |
| 1112 | } |
| 1113 | |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1114 | interface ContactCounts { |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1115 | |
| 1116 | /** |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1117 | * Add this query parameter to a URI to get back row counts grouped by the address book |
| 1118 | * index as cursor extras. For most languages it is the first letter of the sort key. This |
| 1119 | * parameter does not affect the main content of the cursor. |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1120 | * |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1121 | * <p> |
| 1122 | * <pre> |
| 1123 | * Example: |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1124 | * |
| 1125 | * import android.provider.ContactsContract.Contacts; |
| 1126 | * |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1127 | * Uri uri = Contacts.CONTENT_URI.buildUpon() |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1128 | * .appendQueryParameter(Contacts.EXTRA_ADDRESS_BOOK_INDEX, "true") |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1129 | * .build(); |
| 1130 | * Cursor cursor = getContentResolver().query(uri, |
| 1131 | * new String[] {Contacts.DISPLAY_NAME}, |
| 1132 | * null, null, null); |
| 1133 | * Bundle bundle = cursor.getExtras(); |
Yorke Lee | a4aa9dc | 2014-08-04 13:47:50 -0700 | [diff] [blame] | 1134 | * if (bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES) && |
| 1135 | * bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS)) { |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1136 | * String sections[] = |
Yorke Lee | a4aa9dc | 2014-08-04 13:47:50 -0700 | [diff] [blame] | 1137 | * bundle.getStringArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES); |
| 1138 | * int counts[] = bundle.getIntArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS); |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1139 | * } |
| 1140 | * </pre> |
| 1141 | * </p> |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1142 | */ |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1143 | public static final String EXTRA_ADDRESS_BOOK_INDEX = |
| 1144 | "android.provider.extra.ADDRESS_BOOK_INDEX"; |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1145 | |
| 1146 | /** |
| 1147 | * The array of address book index titles, which are returned in the |
| 1148 | * same order as the data in the cursor. |
| 1149 | * <p>TYPE: String[]</p> |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1150 | */ |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1151 | public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES = |
| 1152 | "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES"; |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1153 | |
| 1154 | /** |
| 1155 | * The array of group counts for the corresponding group. Contains the same number |
| 1156 | * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array. |
| 1157 | * <p>TYPE: int[]</p> |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1158 | */ |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1159 | public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = |
| 1160 | "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS"; |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1161 | } |
| 1162 | |
| 1163 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1164 | * Constants for the contacts table, which contains a record per aggregate |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1165 | * of raw contacts representing the same person. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1166 | * <h3>Operations</h3> |
| 1167 | * <dl> |
| 1168 | * <dt><b>Insert</b></dt> |
| 1169 | * <dd>A Contact cannot be created explicitly. When a raw contact is |
| 1170 | * inserted, the provider will first try to find a Contact representing the |
| 1171 | * same person. If one is found, the raw contact's |
| 1172 | * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate |
| 1173 | * Contact. If no match is found, the provider automatically inserts a new |
| 1174 | * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column |
| 1175 | * of the newly inserted raw contact.</dd> |
| 1176 | * <dt><b>Update</b></dt> |
| 1177 | * <dd>Only certain columns of Contact are modifiable: |
| 1178 | * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED}, |
| 1179 | * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of |
| 1180 | * these columns on the Contact also changes them on all constituent raw |
| 1181 | * contacts.</dd> |
| 1182 | * <dt><b>Delete</b></dt> |
| 1183 | * <dd>Be careful with deleting Contacts! Deleting an aggregate contact |
| 1184 | * deletes all constituent raw contacts. The corresponding sync adapters |
| 1185 | * will notice the deletions of their respective raw contacts and remove |
| 1186 | * them from their back end storage.</dd> |
| 1187 | * <dt><b>Query</b></dt> |
| 1188 | * <dd> |
| 1189 | * <ul> |
| 1190 | * <li>If you need to read an individual contact, consider using |
| 1191 | * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li> |
| 1192 | * <li>If you need to look up a contact by the phone number, use |
| 1193 | * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI}, |
| 1194 | * which is optimized for this purpose.</li> |
| 1195 | * <li>If you need to look up a contact by partial name, e.g. to produce |
| 1196 | * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI. |
| 1197 | * <li>If you need to look up a contact by some data element like email |
| 1198 | * address, nickname, etc, use a query against the {@link ContactsContract.Data} table. |
| 1199 | * The result will contain contact ID, name etc. |
| 1200 | * </ul> |
| 1201 | * </dd> |
| 1202 | * </dl> |
| 1203 | * <h2>Columns</h2> |
| 1204 | * <table class="jd-sumtable"> |
| 1205 | * <tr> |
| 1206 | * <th colspan='4'>Contacts</th> |
| 1207 | * </tr> |
| 1208 | * <tr> |
| 1209 | * <td>long</td> |
| 1210 | * <td>{@link #_ID}</td> |
| 1211 | * <td>read-only</td> |
| 1212 | * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td> |
| 1213 | * </tr> |
| 1214 | * <tr> |
| 1215 | * <td>String</td> |
| 1216 | * <td>{@link #LOOKUP_KEY}</td> |
| 1217 | * <td>read-only</td> |
| 1218 | * <td>An opaque value that contains hints on how to find the contact if its |
| 1219 | * row id changed as a result of a sync or aggregation.</td> |
| 1220 | * </tr> |
| 1221 | * <tr> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1222 | * <td>long</td> |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1223 | * <td>NAME_RAW_CONTACT_ID</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1224 | * <td>read-only</td> |
| 1225 | * <td>The ID of the raw contact that contributes the display name |
| 1226 | * to the aggregate contact. During aggregation one of the constituent |
| 1227 | * raw contacts is chosen using a heuristic: a longer name or a name |
| 1228 | * with more diacritic marks or more upper case characters is chosen.</td> |
| 1229 | * </tr> |
| 1230 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1231 | * <td>String</td> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1232 | * <td>DISPLAY_NAME_PRIMARY</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1233 | * <td>read-only</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1234 | * <td>The display name for the contact. It is the display name |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1235 | * 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] | 1236 | * column.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1237 | * </tr> |
| 1238 | * <tr> |
| 1239 | * <td>long</td> |
| 1240 | * <td>{@link #PHOTO_ID}</td> |
| 1241 | * <td>read-only</td> |
| 1242 | * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo. |
| 1243 | * That row has the mime type |
| 1244 | * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field |
| 1245 | * is computed automatically based on the |
| 1246 | * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of |
| 1247 | * that mime type.</td> |
| 1248 | * </tr> |
| 1249 | * <tr> |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 1250 | * <td>long</td> |
| 1251 | * <td>{@link #PHOTO_URI}</td> |
| 1252 | * <td>read-only</td> |
| 1253 | * <td>A URI that can be used to retrieve the contact's full-size photo. This |
| 1254 | * column is the preferred method of retrieving the contact photo.</td> |
| 1255 | * </tr> |
| 1256 | * <tr> |
| 1257 | * <td>long</td> |
| 1258 | * <td>{@link #PHOTO_THUMBNAIL_URI}</td> |
| 1259 | * <td>read-only</td> |
| 1260 | * <td>A URI that can be used to retrieve the thumbnail of contact's photo. This |
| 1261 | * column is the preferred method of retrieving the contact photo.</td> |
| 1262 | * </tr> |
| 1263 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1264 | * <td>int</td> |
| 1265 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 1266 | * <td>read-only</td> |
| 1267 | * <td>An indicator of whether this contact is supposed to be visible in the |
| 1268 | * UI. "1" if the contact has at least one raw contact that belongs to a |
| 1269 | * visible group; "0" otherwise.</td> |
| 1270 | * </tr> |
| 1271 | * <tr> |
| 1272 | * <td>int</td> |
| 1273 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 1274 | * <td>read-only</td> |
| 1275 | * <td>An indicator of whether this contact has at least one phone number. |
| 1276 | * "1" if there is at least one phone number, "0" otherwise.</td> |
| 1277 | * </tr> |
| 1278 | * <tr> |
| 1279 | * <td>int</td> |
| 1280 | * <td>{@link #TIMES_CONTACTED}</td> |
| 1281 | * <td>read/write</td> |
| 1282 | * <td>The number of times the contact has been contacted. See |
| 1283 | * {@link #markAsContacted}. When raw contacts are aggregated, this field is |
| 1284 | * computed automatically as the maximum number of times contacted among all |
| 1285 | * constituent raw contacts. Setting this field automatically changes the |
| 1286 | * corresponding field on all constituent raw contacts.</td> |
| 1287 | * </tr> |
| 1288 | * <tr> |
| 1289 | * <td>long</td> |
| 1290 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 1291 | * <td>read/write</td> |
| 1292 | * <td>The timestamp of the last time the contact was contacted. See |
| 1293 | * {@link #markAsContacted}. Setting this field also automatically |
| 1294 | * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated, |
| 1295 | * this field is computed automatically as the latest time contacted of all |
| 1296 | * constituent raw contacts. Setting this field automatically changes the |
| 1297 | * corresponding field on all constituent raw contacts.</td> |
| 1298 | * </tr> |
| 1299 | * <tr> |
| 1300 | * <td>int</td> |
| 1301 | * <td>{@link #STARRED}</td> |
| 1302 | * <td>read/write</td> |
| 1303 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
| 1304 | * When raw contacts are aggregated, this field is automatically computed: |
| 1305 | * if any constituent raw contacts are starred, then this field is set to |
| 1306 | * '1'. Setting this field automatically changes the corresponding field on |
| 1307 | * all constituent raw contacts.</td> |
| 1308 | * </tr> |
| 1309 | * <tr> |
| 1310 | * <td>String</td> |
| 1311 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 1312 | * <td>read/write</td> |
| 1313 | * <td>A custom ringtone associated with a contact. Typically this is the |
| 1314 | * URI returned by an activity launched with the |
| 1315 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td> |
| 1316 | * </tr> |
| 1317 | * <tr> |
| 1318 | * <td>int</td> |
| 1319 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 1320 | * <td>read/write</td> |
| 1321 | * <td>An indicator of whether calls from this contact should be forwarded |
| 1322 | * directly to voice mail ('1') or not ('0'). When raw contacts are |
| 1323 | * aggregated, this field is automatically computed: if <i>all</i> |
| 1324 | * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set |
| 1325 | * to '1'. Setting this field automatically changes the corresponding field |
| 1326 | * on all constituent raw contacts.</td> |
| 1327 | * </tr> |
| 1328 | * <tr> |
| 1329 | * <td>int</td> |
| 1330 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 1331 | * <td>read-only</td> |
| 1332 | * <td>Contact IM presence status. See {@link StatusUpdates} for individual |
| 1333 | * status definitions. Automatically computed as the highest presence of all |
| 1334 | * constituent raw contacts. The provider may choose not to store this value |
| 1335 | * in persistent storage. The expectation is that presence status will be |
kmccormick | 50e27c8 | 2013-03-28 16:33:11 -0700 | [diff] [blame] | 1336 | * updated on a regular basis.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1337 | * </tr> |
| 1338 | * <tr> |
| 1339 | * <td>String</td> |
| 1340 | * <td>{@link #CONTACT_STATUS}</td> |
| 1341 | * <td>read-only</td> |
| 1342 | * <td>Contact's latest status update. Automatically computed as the latest |
| 1343 | * of all constituent raw contacts' status updates.</td> |
| 1344 | * </tr> |
| 1345 | * <tr> |
| 1346 | * <td>long</td> |
| 1347 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 1348 | * <td>read-only</td> |
| 1349 | * <td>The absolute time in milliseconds when the latest status was |
| 1350 | * inserted/updated.</td> |
| 1351 | * </tr> |
| 1352 | * <tr> |
| 1353 | * <td>String</td> |
| 1354 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 1355 | * <td>read-only</td> |
| 1356 | * <td> The package containing resources for this status: label and icon.</td> |
| 1357 | * </tr> |
| 1358 | * <tr> |
| 1359 | * <td>long</td> |
| 1360 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 1361 | * <td>read-only</td> |
| 1362 | * <td>The resource ID of the label describing the source of contact status, |
| 1363 | * e.g. "Google Talk". This resource is scoped by the |
| 1364 | * {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1365 | * </tr> |
| 1366 | * <tr> |
| 1367 | * <td>long</td> |
| 1368 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 1369 | * <td>read-only</td> |
| 1370 | * <td>The resource ID of the icon for the source of contact status. This |
| 1371 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1372 | * </tr> |
| 1373 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1374 | */ |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 1375 | public static class Contacts implements BaseColumns, ContactsColumns, |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1376 | ContactOptionsColumns, ContactNameColumns, ContactStatusColumns, ContactCounts { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1377 | /** |
| 1378 | * This utility class cannot be instantiated |
| 1379 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1380 | private Contacts() {} |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1381 | |
| 1382 | /** |
| 1383 | * The content:// style URI for this table |
| 1384 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1385 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1386 | |
| 1387 | /** |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 1388 | * Special contacts URI to refer to contacts on the corp profile from the personal |
| 1389 | * profile. |
| 1390 | * |
| 1391 | * It's supported only by a few specific places for referring to contact pictures that |
| 1392 | * are in the corp provider for enterprise caller-ID. Contact picture URIs returned from |
| 1393 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may contain this kind of URI. |
| 1394 | * |
| 1395 | * @hide |
| 1396 | */ |
| 1397 | public static final Uri CORP_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 1398 | "contacts_corp"); |
| 1399 | |
| 1400 | /** |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1401 | * A content:// style URI for this table that should be used to create |
| 1402 | * shortcuts or otherwise create long-term links to contacts. This URI |
| 1403 | * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}. |
| 1404 | * It can optionally also have a "/" and last known contact ID appended after |
| 1405 | * that. This "complete" format is an important optimization and is highly recommended. |
| 1406 | * <p> |
| 1407 | * As long as the contact's row ID remains the same, this URI is |
| 1408 | * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes |
| 1409 | * as a result of a sync or aggregation, this URI will look up the |
| 1410 | * contact using indirect information (sync IDs or constituent raw |
| 1411 | * contacts). |
| 1412 | * <p> |
| 1413 | * Lookup key should be appended unencoded - it is stored in the encoded |
| 1414 | * form, ready for use in a URI. |
| 1415 | */ |
| 1416 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1417 | "lookup"); |
| 1418 | |
| 1419 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1420 | * Base {@link Uri} for referencing a single {@link Contacts} entry, |
Jeff Sharkey | 8f76734 | 2009-09-28 18:22:46 -0700 | [diff] [blame] | 1421 | * created by appending {@link #LOOKUP_KEY} using |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1422 | * {@link Uri#withAppendedPath(Uri, String)}. Provides |
| 1423 | * {@link OpenableColumns} columns when queried, or returns the |
| 1424 | * referenced contact formatted as a vCard when opened through |
| 1425 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1426 | */ |
| 1427 | public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1428 | "as_vcard"); |
| 1429 | |
Martijn Coenen | 037d3ff | 2011-06-15 16:01:45 +0200 | [diff] [blame] | 1430 | /** |
| 1431 | * Boolean parameter that may be used with {@link #CONTENT_VCARD_URI} |
| 1432 | * and {@link #CONTENT_MULTI_VCARD_URI} to indicate that the returned |
| 1433 | * vcard should not contain a photo. |
| 1434 | * |
| 1435 | * @hide |
| 1436 | */ |
| 1437 | public static final String QUERY_PARAMETER_VCARD_NO_PHOTO = "nophoto"; |
| 1438 | |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1439 | /** |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1440 | * Base {@link Uri} for referencing multiple {@link Contacts} entry, |
| 1441 | * created by appending {@link #LOOKUP_KEY} using |
| 1442 | * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 1443 | * joined with the colon (":") separator, and the resulting string encoded. |
| 1444 | * |
| 1445 | * Provides {@link OpenableColumns} columns when queried, or returns the |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1446 | * referenced contact formatted as a vCard when opened through |
| 1447 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1448 | * |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 1449 | * <p> |
| 1450 | * Usage example: |
| 1451 | * <dl> |
| 1452 | * <dt>The following code snippet creates a multi-vcard URI that references all the |
| 1453 | * contacts in a user's database.</dt> |
| 1454 | * <dd> |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1455 | * |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 1456 | * <pre> |
| 1457 | * public Uri getAllContactsVcardUri() { |
| 1458 | * Cursor cursor = getActivity().getContentResolver().query(Contacts.CONTENT_URI, |
| 1459 | * new String[] {Contacts.LOOKUP_KEY}, null, null, null); |
| 1460 | * if (cursor == null) { |
| 1461 | * return null; |
| 1462 | * } |
| 1463 | * try { |
| 1464 | * StringBuilder uriListBuilder = new StringBuilder(); |
| 1465 | * int index = 0; |
| 1466 | * while (cursor.moveToNext()) { |
| 1467 | * if (index != 0) uriListBuilder.append(':'); |
| 1468 | * uriListBuilder.append(cursor.getString(0)); |
| 1469 | * index++; |
| 1470 | * } |
| 1471 | * return Uri.withAppendedPath(Contacts.CONTENT_MULTI_VCARD_URI, |
| 1472 | * Uri.encode(uriListBuilder.toString())); |
| 1473 | * } finally { |
| 1474 | * cursor.close(); |
| 1475 | * } |
| 1476 | * } |
| 1477 | * </pre> |
| 1478 | * |
| 1479 | * </p> |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1480 | */ |
| 1481 | public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1482 | "as_multi_vcard"); |
| 1483 | |
| 1484 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1485 | * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the |
| 1486 | * requested {@link Contacts} entry. |
| 1487 | * |
| 1488 | * @param contactUri A {@link #CONTENT_URI} row, or an existing |
| 1489 | * {@link #CONTENT_LOOKUP_URI} to attempt refreshing. |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1490 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1491 | public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) { |
| 1492 | final Cursor c = resolver.query(contactUri, new String[] { |
| 1493 | Contacts.LOOKUP_KEY, Contacts._ID |
| 1494 | }, null, null, null); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1495 | if (c == null) { |
| 1496 | return null; |
| 1497 | } |
| 1498 | |
| 1499 | try { |
| 1500 | if (c.moveToFirst()) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1501 | final String lookupKey = c.getString(0); |
| 1502 | final long contactId = c.getLong(1); |
| 1503 | return getLookupUri(contactId, lookupKey); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1504 | } |
| 1505 | } finally { |
| 1506 | c.close(); |
| 1507 | } |
| 1508 | return null; |
| 1509 | } |
| 1510 | |
| 1511 | /** |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1512 | * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1513 | * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}. |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1514 | */ |
| 1515 | public static Uri getLookupUri(long contactId, String lookupKey) { |
| 1516 | return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, |
| 1517 | lookupKey), contactId); |
| 1518 | } |
| 1519 | |
| 1520 | /** |
Dmitri Plotnikov | b5759b5 | 2009-09-01 15:58:40 -0700 | [diff] [blame] | 1521 | * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI. |
| 1522 | * <p> |
| 1523 | * Returns null if the contact cannot be found. |
| 1524 | */ |
| 1525 | public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) { |
| 1526 | if (lookupUri == null) { |
| 1527 | return null; |
| 1528 | } |
| 1529 | |
| 1530 | Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null); |
| 1531 | if (c == null) { |
| 1532 | return null; |
| 1533 | } |
| 1534 | |
| 1535 | try { |
| 1536 | if (c.moveToFirst()) { |
| 1537 | long contactId = c.getLong(0); |
| 1538 | return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1539 | } |
| 1540 | } finally { |
| 1541 | c.close(); |
| 1542 | } |
| 1543 | return null; |
| 1544 | } |
| 1545 | |
| 1546 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1547 | * Mark a contact as having been contacted. Updates two fields: |
| 1548 | * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED}. The |
| 1549 | * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED |
| 1550 | * field is populated with the current system time. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1551 | * |
| 1552 | * @param resolver the ContentResolver to use |
| 1553 | * @param contactId the person who was contacted |
Daniel Lehmann | a1620dc | 2012-04-13 13:29:49 -0700 | [diff] [blame] | 1554 | * |
| 1555 | * @deprecated The class DataUsageStatUpdater of the Android support library should |
| 1556 | * be used instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1557 | */ |
Daniel Lehmann | a1620dc | 2012-04-13 13:29:49 -0700 | [diff] [blame] | 1558 | @Deprecated |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1559 | public static void markAsContacted(ContentResolver resolver, long contactId) { |
| 1560 | Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId); |
| 1561 | ContentValues values = new ContentValues(); |
| 1562 | // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified. |
| 1563 | values.put(LAST_TIME_CONTACTED, System.currentTimeMillis()); |
| 1564 | resolver.update(uri, values, null, null); |
| 1565 | } |
| 1566 | |
| 1567 | /** |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1568 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1569 | * {@link #CONTENT_URI} URI. The filter string will be used to match |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1570 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1571 | * as an additional path segment after this URI. |
| 1572 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1573 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 1574 | CONTENT_URI, "filter"); |
| 1575 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1576 | /** |
| 1577 | * The content:// style URI for this table joined with useful data from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1578 | * {@link ContactsContract.Data}, filtered to include only starred contacts |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1579 | * and the most frequently contacted contacts. |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1580 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1581 | public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath( |
| 1582 | CONTENT_URI, "strequent"); |
| 1583 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1584 | /** |
Yorke Lee | 8d37009 | 2014-06-26 10:32:17 -0700 | [diff] [blame] | 1585 | * The content:// style URI for showing a list of frequently contacted people. |
Daisuke Miyakawa | 3604bc5 | 2011-07-21 10:14:32 -0700 | [diff] [blame] | 1586 | */ |
| 1587 | public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath( |
| 1588 | CONTENT_URI, "frequent"); |
| 1589 | |
| 1590 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1591 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1592 | * {@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] | 1593 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1594 | * as an additional path segment after this URI. |
| 1595 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1596 | public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath( |
| 1597 | CONTENT_STREQUENT_URI, "filter"); |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1598 | |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1599 | public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath( |
| 1600 | CONTENT_URI, "group"); |
| 1601 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1602 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1603 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 1604 | * people. |
| 1605 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1606 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1607 | |
| 1608 | /** |
| 1609 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1610 | * person. |
| 1611 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1612 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1613 | |
| 1614 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1615 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1616 | * person. |
| 1617 | */ |
| 1618 | public static final String CONTENT_VCARD_TYPE = "text/x-vcard"; |
| 1619 | |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 1620 | |
| 1621 | /** |
| 1622 | * Mimimal ID for corp contacts returned from |
| 1623 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
| 1624 | * |
| 1625 | * @hide |
| 1626 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 1627 | public static long ENTERPRISE_CONTACT_ID_BASE = 1000000000; // slightly smaller than 2 ** 30 |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 1628 | |
| 1629 | /** |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 1630 | * Return TRUE if a contact ID is from the contacts provider on the enterprise profile. |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 1631 | * |
| 1632 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may return such a contact. |
| 1633 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 1634 | public static boolean isEnterpriseContactId(long contactId) { |
| 1635 | return (contactId >= ENTERPRISE_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID); |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 1636 | } |
| 1637 | |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1638 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1639 | * 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] | 1640 | * {@link ContactsContract.Data} rows. This directory can be used either |
| 1641 | * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1642 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1643 | public static final class Data implements BaseColumns, DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1644 | /** |
| 1645 | * no public constructor since this is a utility class |
| 1646 | */ |
| 1647 | private Data() {} |
| 1648 | |
| 1649 | /** |
| 1650 | * The directory twig for this sub-table |
| 1651 | */ |
| 1652 | public static final String CONTENT_DIRECTORY = "data"; |
| 1653 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1654 | |
| 1655 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1656 | * <p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1657 | * A sub-directory of a contact that contains all of its |
| 1658 | * {@link ContactsContract.RawContacts} as well as |
| 1659 | * {@link ContactsContract.Data} rows. To access this directory append |
| 1660 | * {@link #CONTENT_DIRECTORY} to the contact URI. |
| 1661 | * </p> |
| 1662 | * <p> |
| 1663 | * Entity has three ID fields: {@link #CONTACT_ID} for the contact, |
| 1664 | * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for |
| 1665 | * the data rows. Entity always contains at least one row per |
| 1666 | * constituent raw contact, even if there are no actual data rows. In |
| 1667 | * this case the {@link #DATA_ID} field will be null. |
| 1668 | * </p> |
| 1669 | * <p> |
| 1670 | * Entity reads all data for the entire contact in one transaction, to |
| 1671 | * guarantee consistency. There is significant data duplication |
| 1672 | * in the Entity (each row repeats all Contact columns and all RawContact |
| 1673 | * columns), so the benefits of transactional consistency should be weighed |
| 1674 | * against the cost of transferring large amounts of denormalized data |
| 1675 | * from the Provider. |
| 1676 | * </p> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 1677 | * <p> |
| 1678 | * To reduce the amount of data duplication the contacts provider and directory |
| 1679 | * providers implementing this protocol are allowed to provide common Contacts |
| 1680 | * and RawContacts fields in the first row returned for each raw contact only and |
| 1681 | * leave them as null in subsequent rows. |
| 1682 | * </p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1683 | */ |
| 1684 | public static final class Entity implements BaseColumns, ContactsColumns, |
| 1685 | ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns, |
Paul Soulos | 42cdda8 | 2014-06-19 16:13:38 -0700 | [diff] [blame] | 1686 | StatusColumns, ContactOptionsColumns, ContactStatusColumns, DataUsageStatColumns { |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1687 | /** |
| 1688 | * no public constructor since this is a utility class |
| 1689 | */ |
| 1690 | private Entity() { |
| 1691 | } |
| 1692 | |
| 1693 | /** |
| 1694 | * The directory twig for this sub-table |
| 1695 | */ |
| 1696 | public static final String CONTENT_DIRECTORY = "entities"; |
| 1697 | |
| 1698 | /** |
| 1699 | * The ID of the raw contact row. |
| 1700 | * <P>Type: INTEGER</P> |
| 1701 | */ |
| 1702 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 1703 | |
| 1704 | /** |
| 1705 | * The ID of the data row. The value will be null if this raw contact has no |
| 1706 | * data rows. |
| 1707 | * <P>Type: INTEGER</P> |
| 1708 | */ |
| 1709 | public static final String DATA_ID = "data_id"; |
| 1710 | } |
| 1711 | |
| 1712 | /** |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 1713 | * <p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1714 | * A sub-directory of a single contact that contains all of the constituent raw contact |
| 1715 | * {@link ContactsContract.StreamItems} rows. This directory can be used either |
| 1716 | * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}. |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 1717 | * </p> |
| 1718 | * <p> |
| 1719 | * Querying for social stream data requires android.permission.READ_SOCIAL_STREAM |
| 1720 | * permission. |
| 1721 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1722 | * |
| 1723 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 1724 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1725 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1726 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1727 | public static final class StreamItems implements StreamItemsColumns { |
| 1728 | /** |
| 1729 | * no public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1730 | * |
| 1731 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 1732 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1733 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1734 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1735 | private StreamItems() {} |
| 1736 | |
| 1737 | /** |
| 1738 | * The directory twig for this sub-table |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1739 | * |
| 1740 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 1741 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1742 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1743 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1744 | public static final String CONTENT_DIRECTORY = "stream_items"; |
| 1745 | } |
| 1746 | |
| 1747 | /** |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1748 | * <p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1749 | * A <i>read-only</i> sub-directory of a single contact aggregate that |
| 1750 | * contains all aggregation suggestions (other contacts). The |
| 1751 | * aggregation suggestions are computed based on approximate data |
| 1752 | * matches with this contact. |
| 1753 | * </p> |
| 1754 | * <p> |
| 1755 | * <i>Note: this query may be expensive! If you need to use it in bulk, |
| 1756 | * make sure the user experience is acceptable when the query runs for a |
| 1757 | * long time.</i> |
| 1758 | * <p> |
| 1759 | * Usage example: |
| 1760 | * |
| 1761 | * <pre> |
| 1762 | * Uri uri = Contacts.CONTENT_URI.buildUpon() |
| 1763 | * .appendEncodedPath(String.valueOf(contactId)) |
| 1764 | * .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY) |
| 1765 | * .appendQueryParameter("limit", "3") |
| 1766 | * .build() |
| 1767 | * Cursor cursor = getContentResolver().query(suggestionsUri, |
| 1768 | * new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY}, |
| 1769 | * null, null, null); |
| 1770 | * </pre> |
| 1771 | * |
| 1772 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1773 | * <p> |
| 1774 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 1775 | * {@link #CONTENT_LOOKUP_URI}. |
| 1776 | * </p> |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1777 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1778 | public static final class AggregationSuggestions implements BaseColumns, ContactsColumns, |
| 1779 | ContactOptionsColumns, ContactStatusColumns { |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1780 | /** |
| 1781 | * No public constructor since this is a utility class |
| 1782 | */ |
| 1783 | private AggregationSuggestions() {} |
| 1784 | |
| 1785 | /** |
Dmitri Plotnikov | 0fc0244 | 2009-09-21 13:26:28 -0700 | [diff] [blame] | 1786 | * 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] | 1787 | * type-to-filter, similar to |
| 1788 | * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}. |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1789 | */ |
| 1790 | public static final String CONTENT_DIRECTORY = "suggestions"; |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1791 | |
| 1792 | /** |
| 1793 | * Used with {@link Builder#addParameter} to specify what kind of data is |
| 1794 | * supplied for the suggestion query. |
| 1795 | * |
| 1796 | * @hide |
| 1797 | */ |
| 1798 | public static final String PARAMETER_MATCH_NAME = "name"; |
| 1799 | |
| 1800 | /** |
| 1801 | * Used with {@link Builder#addParameter} to specify what kind of data is |
| 1802 | * supplied for the suggestion query. |
| 1803 | * |
| 1804 | * @hide |
| 1805 | */ |
| 1806 | public static final String PARAMETER_MATCH_EMAIL = "email"; |
| 1807 | |
| 1808 | /** |
| 1809 | * Used with {@link Builder#addParameter} to specify what kind of data is |
| 1810 | * supplied for the suggestion query. |
| 1811 | * |
| 1812 | * @hide |
| 1813 | */ |
| 1814 | public static final String PARAMETER_MATCH_PHONE = "phone"; |
| 1815 | |
| 1816 | /** |
| 1817 | * Used with {@link Builder#addParameter} to specify what kind of data is |
| 1818 | * supplied for the suggestion query. |
| 1819 | * |
| 1820 | * @hide |
| 1821 | */ |
| 1822 | public static final String PARAMETER_MATCH_NICKNAME = "nickname"; |
| 1823 | |
| 1824 | /** |
| 1825 | * A convenience builder for aggregation suggestion content URIs. |
| 1826 | * |
| 1827 | * TODO: change documentation for this class to use the builder. |
| 1828 | * @hide |
| 1829 | */ |
| 1830 | public static final class Builder { |
| 1831 | private long mContactId; |
| 1832 | private ArrayList<String> mKinds = new ArrayList<String>(); |
| 1833 | private ArrayList<String> mValues = new ArrayList<String>(); |
| 1834 | private int mLimit; |
| 1835 | |
| 1836 | /** |
| 1837 | * Optional existing contact ID. If it is not provided, the search |
| 1838 | * will be based exclusively on the values supplied with {@link #addParameter}. |
| 1839 | */ |
| 1840 | public Builder setContactId(long contactId) { |
| 1841 | this.mContactId = contactId; |
| 1842 | return this; |
| 1843 | } |
| 1844 | |
| 1845 | /** |
| 1846 | * A value that can be used when searching for an aggregation |
| 1847 | * suggestion. |
| 1848 | * |
| 1849 | * @param kind can be one of |
| 1850 | * {@link AggregationSuggestions#PARAMETER_MATCH_NAME}, |
| 1851 | * {@link AggregationSuggestions#PARAMETER_MATCH_EMAIL}, |
| 1852 | * {@link AggregationSuggestions#PARAMETER_MATCH_NICKNAME}, |
| 1853 | * {@link AggregationSuggestions#PARAMETER_MATCH_PHONE} |
| 1854 | */ |
| 1855 | public Builder addParameter(String kind, String value) { |
| 1856 | if (!TextUtils.isEmpty(value)) { |
| 1857 | mKinds.add(kind); |
| 1858 | mValues.add(value); |
| 1859 | } |
| 1860 | return this; |
| 1861 | } |
| 1862 | |
| 1863 | public Builder setLimit(int limit) { |
| 1864 | mLimit = limit; |
| 1865 | return this; |
| 1866 | } |
| 1867 | |
| 1868 | public Uri build() { |
| 1869 | android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon(); |
| 1870 | builder.appendEncodedPath(String.valueOf(mContactId)); |
| 1871 | builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY); |
| 1872 | if (mLimit != 0) { |
| 1873 | builder.appendQueryParameter("limit", String.valueOf(mLimit)); |
| 1874 | } |
| 1875 | |
| 1876 | int count = mKinds.size(); |
| 1877 | for (int i = 0; i < count; i++) { |
| 1878 | builder.appendQueryParameter("query", mKinds.get(i) + ":" + mValues.get(i)); |
| 1879 | } |
| 1880 | |
| 1881 | return builder.build(); |
| 1882 | } |
| 1883 | } |
| 1884 | |
| 1885 | /** |
| 1886 | * @hide |
| 1887 | */ |
| 1888 | public static final Builder builder() { |
| 1889 | return new Builder(); |
| 1890 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1891 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1892 | |
| 1893 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1894 | * A <i>read-only</i> sub-directory of a single contact that contains |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1895 | * the contact's primary photo. The photo may be stored in up to two ways - |
| 1896 | * the default "photo" is a thumbnail-sized image stored directly in the data |
| 1897 | * row, while the "display photo", if present, is a larger version stored as |
| 1898 | * a file. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1899 | * <p> |
| 1900 | * Usage example: |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1901 | * <dl> |
| 1902 | * <dt>Retrieving the thumbnail-sized photo</dt> |
| 1903 | * <dd> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1904 | * <pre> |
| 1905 | * public InputStream openPhoto(long contactId) { |
| 1906 | * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1907 | * Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY); |
| 1908 | * Cursor cursor = getContentResolver().query(photoUri, |
| 1909 | * new String[] {Contacts.Photo.PHOTO}, null, null, null); |
| 1910 | * if (cursor == null) { |
| 1911 | * return null; |
| 1912 | * } |
| 1913 | * try { |
| 1914 | * if (cursor.moveToFirst()) { |
| 1915 | * byte[] data = cursor.getBlob(0); |
| 1916 | * if (data != null) { |
| 1917 | * return new ByteArrayInputStream(data); |
| 1918 | * } |
| 1919 | * } |
| 1920 | * } finally { |
| 1921 | * cursor.close(); |
| 1922 | * } |
| 1923 | * return null; |
| 1924 | * } |
| 1925 | * </pre> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1926 | * </dd> |
| 1927 | * <dt>Retrieving the larger photo version</dt> |
| 1928 | * <dd> |
| 1929 | * <pre> |
| 1930 | * public InputStream openDisplayPhoto(long contactId) { |
| 1931 | * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1932 | * Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO); |
| 1933 | * try { |
| 1934 | * AssetFileDescriptor fd = |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 1935 | * getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1936 | * return fd.createInputStream(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 1937 | * } catch (IOException e) { |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1938 | * return null; |
| 1939 | * } |
| 1940 | * } |
| 1941 | * </pre> |
| 1942 | * </dd> |
| 1943 | * </dl> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1944 | * |
| 1945 | * </p> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1946 | * <p>You may also consider using the convenience method |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1947 | * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri, boolean)} |
| 1948 | * to retrieve the raw photo contents of either the thumbnail-sized or the full-sized photo. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1949 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1950 | * <p> |
| 1951 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 1952 | * {@link #CONTENT_LOOKUP_URI}. |
| 1953 | * </p> |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1954 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1955 | public static final class Photo implements BaseColumns, DataColumnsWithJoins { |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 1956 | /** |
| 1957 | * no public constructor since this is a utility class |
| 1958 | */ |
| 1959 | private Photo() {} |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 1960 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 1961 | /** |
| 1962 | * The directory twig for this sub-table |
| 1963 | */ |
| 1964 | public static final String CONTENT_DIRECTORY = "photo"; |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1965 | |
| 1966 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1967 | * The directory twig for retrieving the full-size display photo. |
| 1968 | */ |
| 1969 | public static final String DISPLAY_PHOTO = "display_photo"; |
| 1970 | |
| 1971 | /** |
| 1972 | * Full-size photo file ID of the raw contact. |
| 1973 | * See {@link ContactsContract.DisplayPhoto}. |
| 1974 | * <p> |
| 1975 | * Type: NUMBER |
| 1976 | */ |
| 1977 | public static final String PHOTO_FILE_ID = DATA14; |
| 1978 | |
| 1979 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1980 | * Thumbnail photo of the raw contact. This is the raw bytes of an image |
| 1981 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
| 1982 | * <p> |
| 1983 | * Type: BLOB |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1984 | */ |
| 1985 | public static final String PHOTO = DATA15; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 1986 | } |
| 1987 | |
| 1988 | /** |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1989 | * Opens an InputStream for the contacts's photo and returns the |
| 1990 | * photo as a byte stream. |
| 1991 | * @param cr The content resolver to use for querying |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1992 | * @param contactUri the contact whose photo should be used. This can be used with |
| 1993 | * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI. |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1994 | * @param preferHighres If this is true and the contact has a higher resolution photo |
| 1995 | * available, it is returned. If false, this function always tries to get the thumbnail |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1996 | * @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] | 1997 | */ |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 1998 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri, |
| 1999 | boolean preferHighres) { |
| 2000 | if (preferHighres) { |
| 2001 | final Uri displayPhotoUri = Uri.withAppendedPath(contactUri, |
| 2002 | Contacts.Photo.DISPLAY_PHOTO); |
| 2003 | InputStream inputStream; |
| 2004 | try { |
| 2005 | AssetFileDescriptor fd = cr.openAssetFileDescriptor(displayPhotoUri, "r"); |
| 2006 | return fd.createInputStream(); |
| 2007 | } catch (IOException e) { |
| 2008 | // fallback to the thumbnail code |
| 2009 | } |
| 2010 | } |
| 2011 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 2012 | Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY); |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 2013 | if (photoUri == null) { |
| 2014 | return null; |
| 2015 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2016 | Cursor cursor = cr.query(photoUri, |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2017 | new String[] { |
| 2018 | ContactsContract.CommonDataKinds.Photo.PHOTO |
| 2019 | }, null, null, null); |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2020 | try { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 2021 | if (cursor == null || !cursor.moveToNext()) { |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2022 | return null; |
| 2023 | } |
| 2024 | byte[] data = cursor.getBlob(0); |
| 2025 | if (data == null) { |
| 2026 | return null; |
| 2027 | } |
| 2028 | return new ByteArrayInputStream(data); |
| 2029 | } finally { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 2030 | if (cursor != null) { |
| 2031 | cursor.close(); |
| 2032 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2033 | } |
| 2034 | } |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2035 | |
| 2036 | /** |
| 2037 | * Opens an InputStream for the contacts's thumbnail photo and returns the |
| 2038 | * photo as a byte stream. |
| 2039 | * @param cr The content resolver to use for querying |
| 2040 | * @param contactUri the contact whose photo should be used. This can be used with |
| 2041 | * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI. |
| 2042 | * @return an InputStream of the photo, or null if no photo is present |
| 2043 | * @see #openContactPhotoInputStream(ContentResolver, Uri, boolean), if instead |
| 2044 | * of the thumbnail the high-res picture is preferred |
| 2045 | */ |
| 2046 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) { |
| 2047 | return openContactPhotoInputStream(cr, contactUri, false); |
| 2048 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2049 | } |
| 2050 | |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2051 | /** |
| 2052 | * <p> |
| 2053 | * Constants for the user's profile data, which is represented as a single contact on |
| 2054 | * the device that represents the user. The profile contact is not aggregated |
| 2055 | * together automatically in the same way that normal contacts are; instead, each |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 2056 | * account (including data set, if applicable) on the device may contribute a single |
| 2057 | * raw contact representing the user's personal profile data from that source. |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2058 | * </p> |
| 2059 | * <p> |
| 2060 | * Access to the profile entry through these URIs (or incidental access to parts of |
| 2061 | * the profile if retrieved directly via ID) requires additional permissions beyond |
| 2062 | * the read/write contact permissions required by the provider. Querying for profile |
| 2063 | * data requires android.permission.READ_PROFILE permission, and inserting or |
| 2064 | * updating profile data requires android.permission.WRITE_PROFILE permission. |
| 2065 | * </p> |
| 2066 | * <h3>Operations</h3> |
| 2067 | * <dl> |
| 2068 | * <dt><b>Insert</b></dt> |
| 2069 | * <dd>The user's profile entry cannot be created explicitly (attempting to do so |
| 2070 | * will throw an exception). When a raw contact is inserted into the profile, the |
| 2071 | * provider will check for the existence of a profile on the device. If one is |
| 2072 | * found, the raw contact's {@link RawContacts#CONTACT_ID} column gets the _ID of |
| 2073 | * the profile Contact. If no match is found, the profile Contact is created and |
| 2074 | * its _ID is put into the {@link RawContacts#CONTACT_ID} column of the newly |
| 2075 | * inserted raw contact.</dd> |
| 2076 | * <dt><b>Update</b></dt> |
| 2077 | * <dd>The profile Contact has the same update restrictions as Contacts in general, |
| 2078 | * but requires the android.permission.WRITE_PROFILE permission.</dd> |
| 2079 | * <dt><b>Delete</b></dt> |
| 2080 | * <dd>The profile Contact cannot be explicitly deleted. It will be removed |
| 2081 | * automatically if all of its constituent raw contact entries are deleted.</dd> |
| 2082 | * <dt><b>Query</b></dt> |
| 2083 | * <dd> |
| 2084 | * <ul> |
| 2085 | * <li>The {@link #CONTENT_URI} for profiles behaves in much the same way as |
| 2086 | * retrieving a contact by ID, except that it will only ever return the user's |
| 2087 | * profile contact. |
| 2088 | * </li> |
| 2089 | * <li> |
| 2090 | * The profile contact supports all of the same sub-paths as an individual contact |
| 2091 | * does - the content of the profile contact can be retrieved as entities or |
| 2092 | * data rows. Similarly, specific raw contact entries can be retrieved by appending |
| 2093 | * the desired raw contact ID within the profile. |
| 2094 | * </li> |
| 2095 | * </ul> |
| 2096 | * </dd> |
| 2097 | * </dl> |
| 2098 | */ |
| 2099 | public static final class Profile implements BaseColumns, ContactsColumns, |
| 2100 | ContactOptionsColumns, ContactNameColumns, ContactStatusColumns { |
| 2101 | /** |
| 2102 | * This utility class cannot be instantiated |
| 2103 | */ |
| 2104 | private Profile() { |
| 2105 | } |
| 2106 | |
| 2107 | /** |
| 2108 | * The content:// style URI for this table, which requests the contact entry |
| 2109 | * representing the user's personal profile data. |
| 2110 | */ |
| 2111 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "profile"); |
| 2112 | |
| 2113 | /** |
| 2114 | * {@link Uri} for referencing the user's profile {@link Contacts} entry, |
| 2115 | * Provides {@link OpenableColumns} columns when queried, or returns the |
| 2116 | * user's profile contact formatted as a vCard when opened through |
| 2117 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 2118 | */ |
| 2119 | public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 2120 | "as_vcard"); |
| 2121 | |
| 2122 | /** |
| 2123 | * {@link Uri} for referencing the raw contacts that make up the user's profile |
| 2124 | * {@link Contacts} entry. An individual raw contact entry within the profile |
| 2125 | * can be addressed by appending the raw contact ID. The entities or data within |
| 2126 | * that specific raw contact can be requested by appending the entity or data |
| 2127 | * path as well. |
| 2128 | */ |
| 2129 | public static final Uri CONTENT_RAW_CONTACTS_URI = Uri.withAppendedPath(CONTENT_URI, |
| 2130 | "raw_contacts"); |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 2131 | |
| 2132 | /** |
| 2133 | * The minimum ID for any entity that belongs to the profile. This essentially |
| 2134 | * defines an ID-space in which profile data is stored, and is used by the provider |
| 2135 | * to determine whether a request via a non-profile-specific URI should be directed |
| 2136 | * to the profile data rather than general contacts data, along with all the special |
| 2137 | * permission checks that entails. |
| 2138 | * |
| 2139 | * Callers may use {@link #isProfileId} to check whether a specific ID falls into |
| 2140 | * the set of data intended for the profile. |
| 2141 | */ |
| 2142 | public static final long MIN_ID = Long.MAX_VALUE - (long) Integer.MAX_VALUE; |
| 2143 | } |
| 2144 | |
| 2145 | /** |
| 2146 | * This method can be used to identify whether the given ID is associated with profile |
| 2147 | * data. It does not necessarily indicate that the ID is tied to valid data, merely |
| 2148 | * that accessing data using this ID will result in profile access checks and will only |
| 2149 | * return data from the profile. |
| 2150 | * |
| 2151 | * @param id The ID to check. |
| 2152 | * @return Whether the ID is associated with profile data. |
| 2153 | */ |
| 2154 | public static boolean isProfileId(long id) { |
| 2155 | return id >= Profile.MIN_ID; |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2156 | } |
| 2157 | |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 2158 | protected interface DeletedContactsColumns { |
| 2159 | |
| 2160 | /** |
| 2161 | * A reference to the {@link ContactsContract.Contacts#_ID} that was deleted. |
| 2162 | * <P>Type: INTEGER</P> |
| 2163 | */ |
| 2164 | public static final String CONTACT_ID = "contact_id"; |
| 2165 | |
| 2166 | /** |
| 2167 | * Time (milliseconds since epoch) that the contact was deleted. |
| 2168 | */ |
| 2169 | public static final String CONTACT_DELETED_TIMESTAMP = "contact_deleted_timestamp"; |
| 2170 | } |
| 2171 | |
| 2172 | /** |
| 2173 | * Constants for the deleted contact table. This table holds a log of deleted contacts. |
| 2174 | * <p> |
| 2175 | * Log older than {@link #DAYS_KEPT_MILLISECONDS} may be deleted. |
| 2176 | */ |
| 2177 | public static final class DeletedContacts implements DeletedContactsColumns { |
| 2178 | |
| 2179 | /** |
| 2180 | * This utility class cannot be instantiated |
| 2181 | */ |
| 2182 | private DeletedContacts() { |
| 2183 | } |
| 2184 | |
| 2185 | /** |
| 2186 | * The content:// style URI for this table, which requests a directory of raw contact rows |
| 2187 | * matching the selection criteria. |
| 2188 | */ |
| 2189 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 2190 | "deleted_contacts"); |
| 2191 | |
| 2192 | /** |
| 2193 | * Number of days that the delete log will be kept. After this time, delete records may be |
| 2194 | * deleted. |
| 2195 | * |
| 2196 | * @hide |
| 2197 | */ |
| 2198 | private static final int DAYS_KEPT = 30; |
| 2199 | |
| 2200 | /** |
| 2201 | * Milliseconds that the delete log will be kept. After this time, delete records may be |
| 2202 | * deleted. |
| 2203 | */ |
| 2204 | public static final long DAYS_KEPT_MILLISECONDS = 1000L * 60L * 60L * 24L * (long)DAYS_KEPT; |
| 2205 | } |
| 2206 | |
| 2207 | |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 2208 | protected interface RawContactsColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2209 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2210 | * A reference to the {@link ContactsContract.Contacts#_ID} that this |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2211 | * data belongs to. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2212 | * <P>Type: INTEGER</P> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2213 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2214 | public static final String CONTACT_ID = "contact_id"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2215 | |
| 2216 | /** |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2217 | * The data set within the account that this row belongs to. This allows |
| 2218 | * multiple sync adapters for the same account type to distinguish between |
| 2219 | * each others' data. |
| 2220 | * |
| 2221 | * This is empty by default, and is completely optional. It only needs to |
| 2222 | * be populated if multiple sync adapters are entering distinct data for |
| 2223 | * the same account type and account name. |
| 2224 | * <P>Type: TEXT</P> |
| 2225 | */ |
| 2226 | public static final String DATA_SET = "data_set"; |
| 2227 | |
| 2228 | /** |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 2229 | * A concatenation of the account type and data set (delimited by a forward |
| 2230 | * slash) - if the data set is empty, this will be the same as the account |
| 2231 | * type. For applications that need to be aware of the data set, this can |
| 2232 | * be used instead of account type to distinguish sets of data. This is |
| 2233 | * never intended to be used for specifying accounts. |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 2234 | * <p> |
| 2235 | * This column does *not* escape forward slashes in the account type or the data set. |
| 2236 | * If this is an issue, consider using |
| 2237 | * {@link ContactsContract.RawContacts#ACCOUNT_TYPE} and |
| 2238 | * {@link ContactsContract.RawContacts#DATA_SET} directly. |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 2239 | */ |
| 2240 | public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; |
| 2241 | |
| 2242 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2243 | * The aggregation mode for this contact. |
| 2244 | * <P>Type: INTEGER</P> |
| 2245 | */ |
| 2246 | public static final String AGGREGATION_MODE = "aggregation_mode"; |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 2247 | |
| 2248 | /** |
| 2249 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 2250 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 2251 | * 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] | 2252 | * 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] | 2253 | * then calls ContactResolver.delete once more, this time passing the |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 2254 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 2255 | * the data removal. |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 2256 | * <P>Type: INTEGER</P> |
| 2257 | */ |
| 2258 | public static final String DELETED = "deleted"; |
Dmitri Plotnikov | 918007b | 2010-01-20 12:12:11 -0800 | [diff] [blame] | 2259 | |
| 2260 | /** |
| 2261 | * The "name_verified" flag: "1" means that the name fields on this raw |
| 2262 | * contact can be trusted and therefore should be used for the entire |
| 2263 | * aggregated contact. |
| 2264 | * <p> |
| 2265 | * If an aggregated contact contains more than one raw contact with a |
| 2266 | * verified name, one of those verified names is chosen at random. |
| 2267 | * If an aggregated contact contains no verified names, the |
| 2268 | * name is chosen randomly from the constituent raw contacts. |
| 2269 | * </p> |
| 2270 | * <p> |
| 2271 | * Updating this flag from "0" to "1" automatically resets it to "0" on |
| 2272 | * all other raw contacts in the same aggregated contact. |
| 2273 | * </p> |
| 2274 | * <p> |
| 2275 | * Sync adapters should only specify a value for this column when |
| 2276 | * inserting a raw contact and leave it out when doing an update. |
| 2277 | * </p> |
| 2278 | * <p> |
| 2279 | * The default value is "0" |
| 2280 | * </p> |
| 2281 | * <p>Type: INTEGER</p> |
Yorke Lee | b31c8ab | 2014-08-26 17:13:02 -0700 | [diff] [blame] | 2282 | * |
| 2283 | * @hide |
Dmitri Plotnikov | 918007b | 2010-01-20 12:12:11 -0800 | [diff] [blame] | 2284 | */ |
| 2285 | public static final String NAME_VERIFIED = "name_verified"; |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 2286 | |
| 2287 | /** |
| 2288 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 2289 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 2290 | * <P>Type: INTEGER</P> |
| 2291 | */ |
Dmitri Plotnikov | 86fe839 | 2010-07-16 11:19:46 -0700 | [diff] [blame] | 2292 | public static final String RAW_CONTACT_IS_READ_ONLY = "raw_contact_is_read_only"; |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2293 | |
| 2294 | /** |
| 2295 | * Flag that reflects whether this raw contact belongs to the user's |
| 2296 | * personal profile entry. |
| 2297 | */ |
| 2298 | public static final String RAW_CONTACT_IS_USER_PROFILE = "raw_contact_is_user_profile"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2299 | } |
| 2300 | |
| 2301 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2302 | * Constants for the raw contacts table, which contains one row of contact |
| 2303 | * information for each person in each synced account. Sync adapters and |
| 2304 | * contact management apps |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 2305 | * are the primary consumers of this API. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2306 | * |
| 2307 | * <h3>Aggregation</h3> |
| 2308 | * <p> |
| 2309 | * As soon as a raw contact is inserted or whenever its constituent data |
| 2310 | * changes, the provider will check if the raw contact matches other |
| 2311 | * existing raw contacts and if so will aggregate it with those. The |
| 2312 | * aggregation is reflected in the {@link RawContacts} table by the change of the |
| 2313 | * {@link #CONTACT_ID} field, which is the reference to the aggregate contact. |
| 2314 | * </p> |
| 2315 | * <p> |
| 2316 | * Changes to the structured name, organization, phone number, email address, |
| 2317 | * or nickname trigger a re-aggregation. |
| 2318 | * </p> |
| 2319 | * <p> |
| 2320 | * See also {@link AggregationExceptions} for a mechanism to control |
| 2321 | * aggregation programmatically. |
| 2322 | * </p> |
| 2323 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2324 | * <h3>Operations</h3> |
| 2325 | * <dl> |
| 2326 | * <dt><b>Insert</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2327 | * <dd> |
| 2328 | * <p> |
| 2329 | * Raw contacts can be inserted incrementally or in a batch. |
| 2330 | * The incremental method is more traditional but less efficient. |
| 2331 | * It should be used |
| 2332 | * 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] | 2333 | * <pre> |
| 2334 | * ContentValues values = new ContentValues(); |
| 2335 | * values.put(RawContacts.ACCOUNT_TYPE, accountType); |
| 2336 | * values.put(RawContacts.ACCOUNT_NAME, accountName); |
| 2337 | * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values); |
| 2338 | * long rawContactId = ContentUris.parseId(rawContactUri); |
| 2339 | * </pre> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2340 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2341 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2342 | * Once {@link Data} values become available, insert those. |
| 2343 | * For example, here's how you would insert a name: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2344 | * |
| 2345 | * <pre> |
| 2346 | * values.clear(); |
| 2347 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 2348 | * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); |
| 2349 | * values.put(StructuredName.DISPLAY_NAME, "Mike Sullivan"); |
| 2350 | * getContentResolver().insert(Data.CONTENT_URI, values); |
| 2351 | * </pre> |
| 2352 | * </p> |
| 2353 | * <p> |
| 2354 | * The batch method is by far preferred. It inserts the raw contact and its |
| 2355 | * constituent data rows in a single database transaction |
| 2356 | * and causes at most one aggregation pass. |
| 2357 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 2358 | * ArrayList<ContentProviderOperation> ops = |
| 2359 | * new ArrayList<ContentProviderOperation>(); |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2360 | * ... |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2361 | * int rawContactInsertIndex = ops.size(); |
| 2362 | * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) |
| 2363 | * .withValue(RawContacts.ACCOUNT_TYPE, accountType) |
| 2364 | * .withValue(RawContacts.ACCOUNT_NAME, accountName) |
| 2365 | * .build()); |
| 2366 | * |
| 2367 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 2368 | * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex) |
| 2369 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 2370 | * .withValue(StructuredName.DISPLAY_NAME, "Mike Sullivan") |
| 2371 | * .build()); |
| 2372 | * |
| 2373 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 2374 | * </pre> |
| 2375 | * </p> |
| 2376 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2377 | * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)} |
| 2378 | * to refer to the as-yet-unknown index value of the raw contact inserted in the |
| 2379 | * first operation. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2380 | * </p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2381 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2382 | * <dt><b>Update</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2383 | * <dd><p> |
| 2384 | * Raw contacts can be updated incrementally or in a batch. |
| 2385 | * Batch mode should be used whenever possible. |
| 2386 | * The procedures and considerations are analogous to those documented above for inserts. |
| 2387 | * </p></dd> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2388 | * <dt><b>Delete</b></dt> |
| 2389 | * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates, |
| 2390 | * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2391 | * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row |
| 2392 | * itself is also deleted automatically. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2393 | * </p> |
| 2394 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2395 | * The invocation of {@code resolver.delete(...)}, does not immediately delete |
| 2396 | * a raw contacts row. |
| 2397 | * Instead, it sets the {@link #DELETED} flag on the raw contact and |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2398 | * removes the raw contact from its aggregate contact. |
| 2399 | * The sync adapter then deletes the raw contact from the server and |
| 2400 | * finalizes phone-side deletion by calling {@code resolver.delete(...)} |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2401 | * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2402 | * <p>Some sync adapters are read-only, meaning that they only sync server-side |
| 2403 | * changes to the phone, but not the reverse. If one of those raw contacts |
| 2404 | * is marked for deletion, it will remain on the phone. However it will be |
| 2405 | * effectively invisible, because it will not be part of any aggregate contact. |
| 2406 | * </dd> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2407 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2408 | * <dt><b>Query</b></dt> |
| 2409 | * <dd> |
| 2410 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2411 | * It is easy to find all raw contacts in a Contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2412 | * <pre> |
| 2413 | * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI, |
| 2414 | * new String[]{RawContacts._ID}, |
| 2415 | * RawContacts.CONTACT_ID + "=?", |
| 2416 | * new String[]{String.valueOf(contactId)}, null); |
| 2417 | * </pre> |
| 2418 | * </p> |
| 2419 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2420 | * To find raw contacts within a specific account, |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2421 | * you can either put the account name and type in the selection or pass them as query |
| 2422 | * parameters. The latter approach is preferable, especially when you can reuse the |
| 2423 | * URI: |
| 2424 | * <pre> |
Adam Koch | 95e5a07 | 2013-05-21 09:47:55 -0400 | [diff] [blame] | 2425 | * Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon() |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2426 | * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName) |
| 2427 | * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType) |
| 2428 | * .build(); |
| 2429 | * Cursor c1 = getContentResolver().query(rawContactUri, |
| 2430 | * RawContacts.STARRED + "<>0", null, null, null); |
| 2431 | * ... |
| 2432 | * Cursor c2 = getContentResolver().query(rawContactUri, |
| 2433 | * RawContacts.DELETED + "<>0", null, null, null); |
| 2434 | * </pre> |
| 2435 | * </p> |
| 2436 | * <p>The best way to read a raw contact along with all the data associated with it is |
| 2437 | * by using the {@link Entity} directory. If the raw contact has data rows, |
| 2438 | * the Entity cursor will contain a row for each data row. If the raw contact has no |
| 2439 | * data rows, the cursor will still contain one row with the raw contact-level information. |
| 2440 | * <pre> |
| 2441 | * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); |
| 2442 | * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY); |
| 2443 | * Cursor c = getContentResolver().query(entityUri, |
| 2444 | * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1}, |
| 2445 | * null, null, null); |
| 2446 | * try { |
| 2447 | * while (c.moveToNext()) { |
| 2448 | * String sourceId = c.getString(0); |
| 2449 | * if (!c.isNull(1)) { |
| 2450 | * String mimeType = c.getString(2); |
| 2451 | * String data = c.getString(3); |
| 2452 | * ... |
| 2453 | * } |
| 2454 | * } |
| 2455 | * } finally { |
| 2456 | * c.close(); |
| 2457 | * } |
| 2458 | * </pre> |
| 2459 | * </p> |
| 2460 | * </dd> |
| 2461 | * </dl> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2462 | * <h2>Columns</h2> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2463 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2464 | * <table class="jd-sumtable"> |
| 2465 | * <tr> |
| 2466 | * <th colspan='4'>RawContacts</th> |
| 2467 | * </tr> |
| 2468 | * <tr> |
| 2469 | * <td>long</td> |
| 2470 | * <td>{@link #_ID}</td> |
| 2471 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2472 | * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words, |
| 2473 | * it is much better for a sync adapter to update a raw contact rather than to delete and |
| 2474 | * re-insert it.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2475 | * </tr> |
| 2476 | * <tr> |
| 2477 | * <td>long</td> |
| 2478 | * <td>{@link #CONTACT_ID}</td> |
| 2479 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2480 | * <td>The ID of the row in the {@link ContactsContract.Contacts} table |
| 2481 | * that this raw contact belongs |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2482 | * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled |
| 2483 | * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td> |
| 2484 | * </tr> |
| 2485 | * <tr> |
| 2486 | * <td>int</td> |
| 2487 | * <td>{@link #AGGREGATION_MODE}</td> |
| 2488 | * <td>read/write</td> |
| 2489 | * <td>A mechanism that allows programmatic control of the aggregation process. The allowed |
| 2490 | * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED} |
| 2491 | * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td> |
| 2492 | * </tr> |
| 2493 | * <tr> |
| 2494 | * <td>int</td> |
| 2495 | * <td>{@link #DELETED}</td> |
| 2496 | * <td>read/write</td> |
| 2497 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 2498 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 2499 | * called on a raw contact, it is marked for deletion and removed from its |
| 2500 | * aggregate contact. The sync adaptor deletes the raw contact on the server and |
| 2501 | * then calls ContactResolver.delete once more, this time passing the |
| 2502 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 2503 | * the data removal.</td> |
| 2504 | * </tr> |
| 2505 | * <tr> |
| 2506 | * <td>int</td> |
| 2507 | * <td>{@link #TIMES_CONTACTED}</td> |
| 2508 | * <td>read/write</td> |
| 2509 | * <td>The number of times the contact has been contacted. To have an effect |
| 2510 | * on the corresponding value of the aggregate contact, this field |
| 2511 | * should be set at the time the raw contact is inserted. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2512 | * After that, this value is typically updated via |
| 2513 | * {@link ContactsContract.Contacts#markAsContacted}.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2514 | * </tr> |
| 2515 | * <tr> |
| 2516 | * <td>long</td> |
| 2517 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 2518 | * <td>read/write</td> |
| 2519 | * <td>The timestamp of the last time the contact was contacted. To have an effect |
| 2520 | * on the corresponding value of the aggregate contact, this field |
| 2521 | * should be set at the time the raw contact is inserted. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2522 | * After that, this value is typically updated via |
| 2523 | * {@link ContactsContract.Contacts#markAsContacted}. |
| 2524 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2525 | * </tr> |
| 2526 | * <tr> |
| 2527 | * <td>int</td> |
| 2528 | * <td>{@link #STARRED}</td> |
| 2529 | * <td>read/write</td> |
| 2530 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2531 | * Changing this field immediately affects the corresponding aggregate contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2532 | * if any raw contacts in that aggregate contact are starred, then the contact |
| 2533 | * itself is marked as starred.</td> |
| 2534 | * </tr> |
| 2535 | * <tr> |
| 2536 | * <td>String</td> |
| 2537 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 2538 | * <td>read/write</td> |
| 2539 | * <td>A custom ringtone associated with a raw contact. Typically this is the |
| 2540 | * URI returned by an activity launched with the |
| 2541 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent. |
| 2542 | * To have an effect on the corresponding value of the aggregate contact, this field |
| 2543 | * 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] | 2544 | * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE |
| 2545 | * Contacts.CUSTOM_RINGTONE} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2546 | * instead.</td> |
| 2547 | * </tr> |
| 2548 | * <tr> |
| 2549 | * <td>int</td> |
| 2550 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 2551 | * <td>read/write</td> |
| 2552 | * <td>An indicator of whether calls from this raw contact should be forwarded |
| 2553 | * directly to voice mail ('1') or not ('0'). To have an effect |
| 2554 | * on the corresponding value of the aggregate contact, this field |
| 2555 | * should be set at the time the raw contact is inserted.</td> |
| 2556 | * </tr> |
| 2557 | * <tr> |
| 2558 | * <td>String</td> |
| 2559 | * <td>{@link #ACCOUNT_NAME}</td> |
| 2560 | * <td>read/write-once</td> |
| 2561 | * <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] | 2562 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
| 2563 | * For example, this will be the Gmail address if it is a Google account. |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2564 | * It should be set at the time the raw contact is inserted and never |
| 2565 | * changed afterwards.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2566 | * </tr> |
| 2567 | * <tr> |
| 2568 | * <td>String</td> |
| 2569 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 2570 | * <td>read/write-once</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2571 | * <td> |
| 2572 | * <p> |
| 2573 | * The type of account to which this row belongs, which when paired with |
| 2574 | * {@link #ACCOUNT_NAME} identifies a specific account. |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2575 | * It should be set at the time the raw contact is inserted and never |
| 2576 | * changed afterwards. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2577 | * </p> |
| 2578 | * <p> |
| 2579 | * To ensure uniqueness, new account types should be chosen according to the |
| 2580 | * Java package naming convention. Thus a Google account is of type "com.google". |
| 2581 | * </p> |
| 2582 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2583 | * </tr> |
| 2584 | * <tr> |
| 2585 | * <td>String</td> |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2586 | * <td>{@link #DATA_SET}</td> |
| 2587 | * <td>read/write-once</td> |
| 2588 | * <td> |
| 2589 | * <p> |
| 2590 | * The data set within the account that this row belongs to. This allows |
| 2591 | * multiple sync adapters for the same account type to distinguish between |
| 2592 | * each others' data. The combination of {@link #ACCOUNT_TYPE}, |
| 2593 | * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data |
| 2594 | * that is associated with a single sync adapter. |
| 2595 | * </p> |
| 2596 | * <p> |
| 2597 | * This is empty by default, and is completely optional. It only needs to |
| 2598 | * be populated if multiple sync adapters are entering distinct data for |
| 2599 | * the same account type and account name. |
| 2600 | * </p> |
| 2601 | * <p> |
| 2602 | * It should be set at the time the raw contact is inserted and never |
| 2603 | * changed afterwards. |
| 2604 | * </p> |
| 2605 | * </td> |
| 2606 | * </tr> |
| 2607 | * <tr> |
| 2608 | * <td>String</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2609 | * <td>{@link #SOURCE_ID}</td> |
| 2610 | * <td>read/write</td> |
| 2611 | * <td>String that uniquely identifies this row to its source account. |
| 2612 | * Typically it is set at the time the raw contact is inserted and never |
| 2613 | * changed afterwards. The one notable exception is a new raw contact: it |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2614 | * will have an account name and type (and possibly a data set), but no |
| 2615 | * source id. This indicates to the sync adapter that a new contact needs |
| 2616 | * to be created server-side and its ID stored in the corresponding |
| 2617 | * SOURCE_ID field on the phone. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2618 | * </td> |
| 2619 | * </tr> |
| 2620 | * <tr> |
| 2621 | * <td>int</td> |
| 2622 | * <td>{@link #VERSION}</td> |
| 2623 | * <td>read-only</td> |
| 2624 | * <td>Version number that is updated whenever this row or its related data |
| 2625 | * changes. This field can be used for optimistic locking of a raw contact. |
| 2626 | * </td> |
| 2627 | * </tr> |
| 2628 | * <tr> |
| 2629 | * <td>int</td> |
| 2630 | * <td>{@link #DIRTY}</td> |
| 2631 | * <td>read/write</td> |
| 2632 | * <td>Flag indicating that {@link #VERSION} has changed, and this row needs |
| 2633 | * to be synchronized by its owning account. The value is set to "1" automatically |
| 2634 | * whenever the raw contact changes, unless the URI has the |
| 2635 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified. |
| 2636 | * The sync adapter should always supply this query parameter to prevent |
| 2637 | * unnecessary synchronization: user changes some data on the server, |
| 2638 | * the sync adapter updates the contact on the phone (without the |
| 2639 | * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag, |
| 2640 | * which triggers a sync to bring the changes to the server. |
| 2641 | * </td> |
| 2642 | * </tr> |
| 2643 | * <tr> |
| 2644 | * <td>String</td> |
| 2645 | * <td>{@link #SYNC1}</td> |
| 2646 | * <td>read/write</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2647 | * <td>Generic column provided for arbitrary use by sync adapters. |
| 2648 | * The content provider |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2649 | * stores this information on behalf of the sync adapter but does not |
| 2650 | * interpret it in any way. |
| 2651 | * </td> |
| 2652 | * </tr> |
| 2653 | * <tr> |
| 2654 | * <td>String</td> |
| 2655 | * <td>{@link #SYNC2}</td> |
| 2656 | * <td>read/write</td> |
| 2657 | * <td>Generic column for use by sync adapters. |
| 2658 | * </td> |
| 2659 | * </tr> |
| 2660 | * <tr> |
| 2661 | * <td>String</td> |
| 2662 | * <td>{@link #SYNC3}</td> |
| 2663 | * <td>read/write</td> |
| 2664 | * <td>Generic column for use by sync adapters. |
| 2665 | * </td> |
| 2666 | * </tr> |
| 2667 | * <tr> |
| 2668 | * <td>String</td> |
| 2669 | * <td>{@link #SYNC4}</td> |
| 2670 | * <td>read/write</td> |
| 2671 | * <td>Generic column for use by sync adapters. |
| 2672 | * </td> |
| 2673 | * </tr> |
| 2674 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2675 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2676 | public static final class RawContacts implements BaseColumns, RawContactsColumns, |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 2677 | ContactOptionsColumns, ContactNameColumns, SyncColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2678 | /** |
| 2679 | * This utility class cannot be instantiated |
| 2680 | */ |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 2681 | private RawContacts() { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2682 | } |
| 2683 | |
| 2684 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2685 | * The content:// style URI for this table, which requests a directory of |
| 2686 | * raw contact rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2687 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 2688 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2689 | |
| 2690 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2691 | * The MIME type of the results from {@link #CONTENT_URI} when a specific |
| 2692 | * ID value is not provided, and multiple raw contacts may be returned. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2693 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2694 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2695 | |
| 2696 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2697 | * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI}, |
| 2698 | * yielding a subdirectory of a single person. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2699 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2700 | 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] | 2701 | |
| 2702 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2703 | * Aggregation mode: aggregate immediately after insert or update operation(s) are complete. |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2704 | */ |
| 2705 | public static final int AGGREGATION_MODE_DEFAULT = 0; |
| 2706 | |
| 2707 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2708 | * Aggregation mode: aggregate at the time the raw contact is inserted/updated. |
| 2709 | * @deprecated Aggregation is synchronous, this historic value is a no-op |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2710 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2711 | @Deprecated |
Omari Stephens | bc9aa77 | 2009-09-08 19:10:53 -0700 | [diff] [blame] | 2712 | public static final int AGGREGATION_MODE_IMMEDIATE = 1; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2713 | |
| 2714 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2715 | * <p> |
| 2716 | * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later. |
| 2717 | * Changes to the raw contact will update the associated aggregate contact but will not |
| 2718 | * result in any change in how the contact is aggregated. Similar to |
| 2719 | * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding |
| 2720 | * {@link Contacts} aggregate. |
| 2721 | * </p> |
| 2722 | * <p> |
| 2723 | * This can be used to postpone aggregation until after a series of updates, for better |
| 2724 | * performance and/or user experience. |
| 2725 | * </p> |
| 2726 | * <p> |
| 2727 | * Note that changing |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2728 | * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2729 | * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any |
| 2730 | * subsequent |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2731 | * change to the raw contact's data will. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2732 | * </p> |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2733 | */ |
| 2734 | public static final int AGGREGATION_MODE_SUSPENDED = 2; |
| 2735 | |
| 2736 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2737 | * <p> |
| 2738 | * Aggregation mode: never aggregate this raw contact. The raw contact will not |
| 2739 | * have a corresponding {@link Contacts} aggregate and therefore will not be included in |
| 2740 | * {@link Contacts} query results. |
| 2741 | * </p> |
| 2742 | * <p> |
| 2743 | * For example, this mode can be used for a raw contact that is marked for deletion while |
| 2744 | * waiting for the deletion to occur on the server side. |
| 2745 | * </p> |
| 2746 | * |
| 2747 | * @see #AGGREGATION_MODE_SUSPENDED |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2748 | */ |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2749 | public static final int AGGREGATION_MODE_DISABLED = 3; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2750 | |
| 2751 | /** |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 2752 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 2753 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
| 2754 | * entry of the given {@link RawContacts} entry. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2755 | */ |
| 2756 | public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) { |
| 2757 | // TODO: use a lighter query by joining rawcontacts with contacts in provider |
| 2758 | final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY); |
| 2759 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 2760 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 2761 | }, null, null, null); |
| 2762 | |
| 2763 | Uri lookupUri = null; |
| 2764 | try { |
| 2765 | if (cursor != null && cursor.moveToFirst()) { |
| 2766 | final long contactId = cursor.getLong(0); |
| 2767 | final String lookupKey = cursor.getString(1); |
| 2768 | return Contacts.getLookupUri(contactId, lookupKey); |
| 2769 | } |
| 2770 | } finally { |
| 2771 | if (cursor != null) cursor.close(); |
| 2772 | } |
| 2773 | return lookupUri; |
| 2774 | } |
| 2775 | |
| 2776 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2777 | * 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] | 2778 | * {@link ContactsContract.Data} rows. To access this directory |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2779 | * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2780 | */ |
| 2781 | public static final class Data implements BaseColumns, DataColumns { |
| 2782 | /** |
| 2783 | * no public constructor since this is a utility class |
| 2784 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2785 | private Data() { |
| 2786 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2787 | |
| 2788 | /** |
| 2789 | * The directory twig for this sub-table |
| 2790 | */ |
| 2791 | public static final String CONTENT_DIRECTORY = "data"; |
| 2792 | } |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2793 | |
| 2794 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2795 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2796 | * 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] | 2797 | * {@link ContactsContract.Data} rows. To access this directory append |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2798 | * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2799 | * {@link RawContactsEntity} for a stand-alone table containing the same |
| 2800 | * data. |
| 2801 | * </p> |
| 2802 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2803 | * Entity has two ID fields: {@link #_ID} for the raw contact |
| 2804 | * and {@link #DATA_ID} for the data rows. |
| 2805 | * Entity always contains at least one row, even if there are no |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2806 | * 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] | 2807 | * null. |
| 2808 | * </p> |
| 2809 | * <p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2810 | * Using Entity should be preferred to using two separate queries: |
| 2811 | * RawContacts followed by Data. The reason is that Entity reads all |
| 2812 | * data for a raw contact in one transaction, so there is no possibility |
| 2813 | * of the data changing between the two queries. |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2814 | */ |
| 2815 | public static final class Entity implements BaseColumns, DataColumns { |
| 2816 | /** |
| 2817 | * no public constructor since this is a utility class |
| 2818 | */ |
| 2819 | private Entity() { |
| 2820 | } |
| 2821 | |
| 2822 | /** |
| 2823 | * The directory twig for this sub-table |
| 2824 | */ |
| 2825 | public static final String CONTENT_DIRECTORY = "entity"; |
| 2826 | |
| 2827 | /** |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 2828 | * 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] | 2829 | * data rows. |
| 2830 | * <P>Type: INTEGER</P> |
| 2831 | */ |
| 2832 | public static final String DATA_ID = "data_id"; |
| 2833 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2834 | |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2835 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2836 | * <p> |
| 2837 | * A sub-directory of a single raw contact that contains all of its |
| 2838 | * {@link ContactsContract.StreamItems} rows. To access this directory append |
| 2839 | * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See |
| 2840 | * {@link ContactsContract.StreamItems} for a stand-alone table containing the |
| 2841 | * same data. |
| 2842 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 2843 | * <p> |
| 2844 | * Access to the social stream through this sub-directory requires additional permissions |
| 2845 | * beyond the read/write contact permissions required by the provider. Querying for |
| 2846 | * social stream data requires android.permission.READ_SOCIAL_STREAM permission, and |
| 2847 | * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM |
| 2848 | * permission. |
| 2849 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2850 | * |
| 2851 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 2852 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2853 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2854 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2855 | public static final class StreamItems implements BaseColumns, StreamItemsColumns { |
| 2856 | /** |
| 2857 | * No public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2858 | * |
| 2859 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 2860 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2861 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2862 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2863 | private StreamItems() { |
| 2864 | } |
| 2865 | |
| 2866 | /** |
| 2867 | * The directory twig for this sub-table |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2868 | * |
| 2869 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 2870 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2871 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2872 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2873 | public static final String CONTENT_DIRECTORY = "stream_items"; |
| 2874 | } |
| 2875 | |
| 2876 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2877 | * <p> |
| 2878 | * A sub-directory of a single raw contact that represents its primary |
| 2879 | * display photo. To access this directory append |
| 2880 | * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI. |
| 2881 | * The resulting URI represents an image file, and should be interacted with |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 2882 | * using ContentResolver.openAssetFileDescriptor. |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2883 | * <p> |
| 2884 | * <p> |
| 2885 | * Note that this sub-directory also supports opening the photo as an asset file |
| 2886 | * in write mode. Callers can create or replace the primary photo associated |
| 2887 | * with this raw contact by opening the asset file and writing the full-size |
| 2888 | * photo contents into it. When the file is closed, the image will be parsed, |
| 2889 | * sized down if necessary for the full-size display photo and thumbnail |
| 2890 | * dimensions, and stored. |
| 2891 | * </p> |
| 2892 | * <p> |
| 2893 | * Usage example: |
| 2894 | * <pre> |
| 2895 | * public void writeDisplayPhoto(long rawContactId, byte[] photo) { |
| 2896 | * Uri rawContactPhotoUri = Uri.withAppendedPath( |
| 2897 | * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), |
| 2898 | * RawContacts.DisplayPhoto.CONTENT_DIRECTORY); |
| 2899 | * try { |
| 2900 | * AssetFileDescriptor fd = |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 2901 | * getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2902 | * OutputStream os = fd.createOutputStream(); |
| 2903 | * os.write(photo); |
| 2904 | * os.close(); |
| 2905 | * fd.close(); |
| 2906 | * } catch (IOException e) { |
| 2907 | * // Handle error cases. |
| 2908 | * } |
| 2909 | * } |
| 2910 | * </pre> |
| 2911 | * </p> |
| 2912 | */ |
| 2913 | public static final class DisplayPhoto { |
| 2914 | /** |
| 2915 | * No public constructor since this is a utility class |
| 2916 | */ |
| 2917 | private DisplayPhoto() { |
| 2918 | } |
| 2919 | |
| 2920 | /** |
| 2921 | * The directory twig for this sub-table |
| 2922 | */ |
| 2923 | public static final String CONTENT_DIRECTORY = "display_photo"; |
| 2924 | } |
| 2925 | |
| 2926 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2927 | * TODO: javadoc |
| 2928 | * @param cursor |
| 2929 | * @return |
| 2930 | */ |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2931 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 2932 | return new EntityIteratorImpl(cursor); |
| 2933 | } |
| 2934 | |
| 2935 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 2936 | private static final String[] DATA_KEYS = new String[]{ |
| 2937 | Data.DATA1, |
| 2938 | Data.DATA2, |
| 2939 | Data.DATA3, |
| 2940 | Data.DATA4, |
| 2941 | Data.DATA5, |
| 2942 | Data.DATA6, |
| 2943 | Data.DATA7, |
| 2944 | Data.DATA8, |
| 2945 | Data.DATA9, |
| 2946 | Data.DATA10, |
| 2947 | Data.DATA11, |
| 2948 | Data.DATA12, |
| 2949 | Data.DATA13, |
| 2950 | Data.DATA14, |
| 2951 | Data.DATA15, |
| 2952 | Data.SYNC1, |
| 2953 | Data.SYNC2, |
| 2954 | Data.SYNC3, |
| 2955 | Data.SYNC4}; |
| 2956 | |
| 2957 | public EntityIteratorImpl(Cursor cursor) { |
| 2958 | super(cursor); |
| 2959 | } |
| 2960 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 2961 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2962 | public android.content.Entity getEntityAndIncrementCursor(Cursor cursor) |
| 2963 | throws RemoteException { |
| 2964 | final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID); |
| 2965 | final long rawContactId = cursor.getLong(columnRawContactId); |
| 2966 | |
| 2967 | // we expect the cursor is already at the row we need to read from |
| 2968 | ContentValues cv = new ContentValues(); |
| 2969 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME); |
| 2970 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE); |
Katherine Kuan | 1d83723 | 2011-08-24 16:06:06 -0700 | [diff] [blame] | 2971 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DATA_SET); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2972 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID); |
| 2973 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY); |
| 2974 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION); |
| 2975 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID); |
| 2976 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1); |
| 2977 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2); |
| 2978 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3); |
| 2979 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4); |
| 2980 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED); |
| 2981 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID); |
| 2982 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED); |
Dmitri Plotnikov | 918007b | 2010-01-20 12:12:11 -0800 | [diff] [blame] | 2983 | DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, NAME_VERIFIED); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2984 | android.content.Entity contact = new android.content.Entity(cv); |
| 2985 | |
| 2986 | // read data rows until the contact id changes |
| 2987 | do { |
| 2988 | if (rawContactId != cursor.getLong(columnRawContactId)) { |
| 2989 | break; |
| 2990 | } |
| 2991 | // add the data to to the contact |
| 2992 | cv = new ContentValues(); |
| 2993 | cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID))); |
| 2994 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 2995 | Data.RES_PACKAGE); |
| 2996 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE); |
| 2997 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY); |
| 2998 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, |
| 2999 | Data.IS_SUPER_PRIMARY); |
| 3000 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION); |
| 3001 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 3002 | CommonDataKinds.GroupMembership.GROUP_SOURCE_ID); |
| 3003 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 3004 | Data.DATA_VERSION); |
| 3005 | for (String key : DATA_KEYS) { |
| 3006 | final int columnIndex = cursor.getColumnIndexOrThrow(key); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 3007 | switch (cursor.getType(columnIndex)) { |
| 3008 | case Cursor.FIELD_TYPE_NULL: |
| 3009 | // don't put anything |
| 3010 | break; |
| 3011 | case Cursor.FIELD_TYPE_INTEGER: |
| 3012 | case Cursor.FIELD_TYPE_FLOAT: |
| 3013 | case Cursor.FIELD_TYPE_STRING: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 3014 | cv.put(key, cursor.getString(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 3015 | break; |
| 3016 | case Cursor.FIELD_TYPE_BLOB: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 3017 | cv.put(key, cursor.getBlob(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 3018 | break; |
| 3019 | default: |
| 3020 | throw new IllegalStateException("Invalid or unhandled data type"); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3021 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3022 | } |
| 3023 | contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv); |
| 3024 | } while (cursor.moveToNext()); |
| 3025 | |
| 3026 | return contact; |
| 3027 | } |
| 3028 | |
| 3029 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3030 | } |
| 3031 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3032 | /** |
| 3033 | * Social status update columns. |
| 3034 | * |
| 3035 | * @see StatusUpdates |
| 3036 | * @see ContactsContract.Data |
| 3037 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3038 | protected interface StatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3039 | /** |
Dmitri Plotnikov | a60479d | 2009-09-27 20:16:31 -0700 | [diff] [blame] | 3040 | * Contact's latest presence level. |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3041 | * <P>Type: INTEGER (one of the values below)</P> |
| 3042 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3043 | public static final String PRESENCE = "mode"; |
| 3044 | |
| 3045 | /** |
| 3046 | * @deprecated use {@link #PRESENCE} |
| 3047 | */ |
| 3048 | @Deprecated |
| 3049 | public static final String PRESENCE_STATUS = PRESENCE; |
| 3050 | |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3051 | /** |
| 3052 | * An allowed value of {@link #PRESENCE}. |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3053 | */ |
| 3054 | int OFFLINE = 0; |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3055 | |
| 3056 | /** |
| 3057 | * An allowed value of {@link #PRESENCE}. |
| 3058 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3059 | int INVISIBLE = 1; |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3060 | |
| 3061 | /** |
| 3062 | * An allowed value of {@link #PRESENCE}. |
| 3063 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3064 | int AWAY = 2; |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3065 | |
| 3066 | /** |
| 3067 | * An allowed value of {@link #PRESENCE}. |
| 3068 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3069 | int IDLE = 3; |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3070 | |
| 3071 | /** |
| 3072 | * An allowed value of {@link #PRESENCE}. |
| 3073 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3074 | int DO_NOT_DISTURB = 4; |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3075 | |
| 3076 | /** |
| 3077 | * An allowed value of {@link #PRESENCE}. |
| 3078 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3079 | int AVAILABLE = 5; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3080 | |
| 3081 | /** |
| 3082 | * Contact latest status update. |
| 3083 | * <p>Type: TEXT</p> |
| 3084 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3085 | public static final String STATUS = "status"; |
| 3086 | |
| 3087 | /** |
| 3088 | * @deprecated use {@link #STATUS} |
| 3089 | */ |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3090 | @Deprecated |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3091 | public static final String PRESENCE_CUSTOM_STATUS = STATUS; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3092 | |
| 3093 | /** |
| 3094 | * The absolute time in milliseconds when the latest status was inserted/updated. |
| 3095 | * <p>Type: NUMBER</p> |
| 3096 | */ |
| 3097 | public static final String STATUS_TIMESTAMP = "status_ts"; |
| 3098 | |
| 3099 | /** |
| 3100 | * The package containing resources for this status: label and icon. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3101 | * <p>Type: TEXT</p> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3102 | */ |
| 3103 | public static final String STATUS_RES_PACKAGE = "status_res_package"; |
| 3104 | |
| 3105 | /** |
| 3106 | * The resource ID of the label describing the source of the status update, e.g. "Google |
| 3107 | * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 3108 | * <p>Type: NUMBER</p> |
| 3109 | */ |
| 3110 | public static final String STATUS_LABEL = "status_label"; |
| 3111 | |
| 3112 | /** |
| 3113 | * The resource ID of the icon for the source of the status update. |
| 3114 | * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 3115 | * <p>Type: NUMBER</p> |
| 3116 | */ |
| 3117 | public static final String STATUS_ICON = "status_icon"; |
Vasu Nori | 5b31498 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3118 | |
| 3119 | /** |
| 3120 | * Contact's audio/video chat capability level. |
| 3121 | * <P>Type: INTEGER (one of the values below)</P> |
| 3122 | */ |
| 3123 | public static final String CHAT_CAPABILITY = "chat_capability"; |
| 3124 | |
| 3125 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3126 | * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone |
| 3127 | * and speaker) |
| 3128 | */ |
| 3129 | public static final int CAPABILITY_HAS_VOICE = 1; |
| 3130 | |
| 3131 | /** |
| 3132 | * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device can |
Vasu Nori | 5b31498 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3133 | * display a video feed. |
| 3134 | */ |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3135 | public static final int CAPABILITY_HAS_VIDEO = 2; |
Vasu Nori | 5b31498 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3136 | |
| 3137 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3138 | * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device has a |
Vasu Nori | 5b31498 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3139 | * camera that can be used for video chat (e.g. a front-facing camera on a phone). |
| 3140 | */ |
| 3141 | public static final int CAPABILITY_HAS_CAMERA = 4; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3142 | } |
| 3143 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3144 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3145 | * <p> |
| 3146 | * Constants for the stream_items table, which contains social stream updates from |
| 3147 | * the user's contact list. |
| 3148 | * </p> |
| 3149 | * <p> |
| 3150 | * Only a certain number of stream items will ever be stored under a given raw contact. |
| 3151 | * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to |
| 3152 | * determine this limit, and should restrict the number of items inserted in any given |
| 3153 | * transaction correspondingly. Insertion of more items beyond the limit will |
| 3154 | * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}. |
| 3155 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3156 | * <p> |
| 3157 | * Access to the social stream through these URIs requires additional permissions beyond the |
| 3158 | * read/write contact permissions required by the provider. Querying for social stream data |
| 3159 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social |
| 3160 | * stream items requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3161 | * </p> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3162 | * <h3>Account check</h3> |
| 3163 | * <p> |
| 3164 | * The content URIs to the insert, update and delete operations are required to have the account |
| 3165 | * information matching that of the owning raw contact as query parameters, namely |
| 3166 | * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. |
| 3167 | * {@link RawContacts#DATA_SET} isn't required. |
| 3168 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3169 | * <h3>Operations</h3> |
| 3170 | * <dl> |
| 3171 | * <dt><b>Insert</b></dt> |
| 3172 | * <dd> |
| 3173 | * <p>Social stream updates are always associated with a raw contact. There are a couple |
| 3174 | * of ways to insert these entries. |
| 3175 | * <dl> |
| 3176 | * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt> |
| 3177 | * <dd> |
| 3178 | * <pre> |
| 3179 | * ContentValues values = new ContentValues(); |
| 3180 | * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); |
| 3181 | * values.put(StreamItems.TIMESTAMP, timestamp); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3182 | * values.put(StreamItems.COMMENTS, "3 people reshared this"); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3183 | * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon(); |
| 3184 | * ContentUris.appendId(builder, rawContactId); |
| 3185 | * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY); |
| 3186 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3187 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3188 | * Uri streamItemUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3189 | * long streamItemId = ContentUris.parseId(streamItemUri); |
| 3190 | * </pre> |
| 3191 | * </dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3192 | * <dt>Via {@link StreamItems#CONTENT_URI}:</dt> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3193 | * <dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3194 | *<pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3195 | * ContentValues values = new ContentValues(); |
| 3196 | * values.put(StreamItems.RAW_CONTACT_ID, rawContactId); |
| 3197 | * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); |
| 3198 | * values.put(StreamItems.TIMESTAMP, timestamp); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3199 | * values.put(StreamItems.COMMENTS, "3 people reshared this"); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3200 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3201 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3202 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3203 | * Uri streamItemUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3204 | * long streamItemId = ContentUris.parseId(streamItemUri); |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3205 | *</pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3206 | * </dd> |
| 3207 | * </dl> |
| 3208 | * </dd> |
| 3209 | * </p> |
| 3210 | * <p> |
| 3211 | * Once a {@link StreamItems} entry has been inserted, photos associated with that |
| 3212 | * social update can be inserted. For example, after one of the insertions above, |
| 3213 | * photos could be added to the stream item in one of the following ways: |
| 3214 | * <dl> |
| 3215 | * <dt>Via a URI including the stream item ID:</dt> |
| 3216 | * <dd> |
| 3217 | * <pre> |
| 3218 | * values.clear(); |
| 3219 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3220 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3221 | * getContentResolver().insert(Uri.withAppendedPath( |
| 3222 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId), |
| 3223 | * StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values); |
| 3224 | * </pre> |
| 3225 | * </dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3226 | * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3227 | * <dd> |
| 3228 | * <pre> |
| 3229 | * values.clear(); |
| 3230 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
| 3231 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3232 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3233 | * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values); |
| 3234 | * </pre> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3235 | * <p>Note that this latter form allows the insertion of a stream item and its |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3236 | * photos in a single transaction, by using {@link ContentProviderOperation} with |
| 3237 | * back references to populate the stream item ID in the {@link ContentValues}. |
| 3238 | * </dd> |
| 3239 | * </dl> |
| 3240 | * </p> |
| 3241 | * </dd> |
| 3242 | * <dt><b>Update</b></dt> |
| 3243 | * <dd>Updates can be performed by appending the stream item ID to the |
| 3244 | * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were |
| 3245 | * created by the calling package can be updated.</dd> |
| 3246 | * <dt><b>Delete</b></dt> |
| 3247 | * <dd>Deletes can be performed by appending the stream item ID to the |
| 3248 | * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were |
| 3249 | * created by the calling package can be deleted.</dd> |
| 3250 | * <dt><b>Query</b></dt> |
| 3251 | * <dl> |
| 3252 | * <dt>Finding all social stream updates for a given contact</dt> |
| 3253 | * <dd>By Contact ID: |
| 3254 | * <pre> |
| 3255 | * Cursor c = getContentResolver().query(Uri.withAppendedPath( |
| 3256 | * ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId), |
| 3257 | * Contacts.StreamItems.CONTENT_DIRECTORY), |
| 3258 | * null, null, null, null); |
| 3259 | * </pre> |
| 3260 | * </dd> |
| 3261 | * <dd>By lookup key: |
| 3262 | * <pre> |
| 3263 | * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon() |
| 3264 | * .appendPath(lookupKey) |
| 3265 | * .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(), |
| 3266 | * null, null, null, null); |
| 3267 | * </pre> |
| 3268 | * </dd> |
| 3269 | * <dt>Finding all social stream updates for a given raw contact</dt> |
| 3270 | * <dd> |
| 3271 | * <pre> |
| 3272 | * Cursor c = getContentResolver().query(Uri.withAppendedPath( |
| 3273 | * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), |
| 3274 | * RawContacts.StreamItems.CONTENT_DIRECTORY)), |
| 3275 | * null, null, null, null); |
| 3276 | * </pre> |
| 3277 | * </dd> |
| 3278 | * <dt>Querying for a specific stream item by ID</dt> |
| 3279 | * <dd> |
| 3280 | * <pre> |
| 3281 | * Cursor c = getContentResolver().query(ContentUris.withAppendedId( |
| 3282 | * StreamItems.CONTENT_URI, streamItemId), |
| 3283 | * null, null, null, null); |
| 3284 | * </pre> |
| 3285 | * </dd> |
| 3286 | * </dl> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3287 | * |
| 3288 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3289 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3290 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3291 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3292 | public static final class StreamItems implements BaseColumns, StreamItemsColumns { |
| 3293 | /** |
| 3294 | * This utility class cannot be instantiated |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3295 | * |
| 3296 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3297 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3298 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3299 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3300 | private StreamItems() { |
| 3301 | } |
| 3302 | |
| 3303 | /** |
| 3304 | * The content:// style URI for this table, which handles social network stream |
| 3305 | * updates for the user's contacts. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3306 | * |
| 3307 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3308 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3309 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3310 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3311 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items"); |
| 3312 | |
| 3313 | /** |
| 3314 | * <p> |
| 3315 | * A content:// style URI for the photos stored in a sub-table underneath |
| 3316 | * stream items. This is only used for inserts, and updates - queries and deletes |
| 3317 | * for photos should be performed by appending |
| 3318 | * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a |
| 3319 | * specific stream item. |
| 3320 | * </p> |
| 3321 | * <p> |
| 3322 | * When using this URI, the stream item ID for the photo(s) must be identified |
| 3323 | * in the {@link ContentValues} passed in. |
| 3324 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3325 | * |
| 3326 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3327 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3328 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3329 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3330 | public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo"); |
| 3331 | |
| 3332 | /** |
| 3333 | * This URI allows the caller to query for the maximum number of stream items |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3334 | * that will be stored under any single raw contact. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3335 | * |
| 3336 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3337 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3338 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3339 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3340 | public static final Uri CONTENT_LIMIT_URI = |
| 3341 | Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit"); |
| 3342 | |
| 3343 | /** |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3344 | * The MIME type of a directory of stream items. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3345 | * |
| 3346 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3347 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3348 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3349 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3350 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item"; |
| 3351 | |
| 3352 | /** |
| 3353 | * The MIME type of a single stream item. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3354 | * |
| 3355 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3356 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3357 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3358 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3359 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/stream_item"; |
| 3360 | |
| 3361 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3362 | * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will |
| 3363 | * contain this column, with the value indicating the maximum number of |
| 3364 | * stream items that will be stored under any single raw contact. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3365 | * |
| 3366 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3367 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3368 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3369 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3370 | public static final String MAX_ITEMS = "max_items"; |
| 3371 | |
| 3372 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3373 | * <p> |
| 3374 | * A sub-directory of a single stream item entry that contains all of its |
| 3375 | * photo rows. To access this |
| 3376 | * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to |
| 3377 | * an individual stream item URI. |
| 3378 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3379 | * <p> |
| 3380 | * Access to social stream photos requires additional permissions beyond the read/write |
| 3381 | * contact permissions required by the provider. Querying for social stream photos |
| 3382 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating |
| 3383 | * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3384 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3385 | * |
| 3386 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3387 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3388 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3389 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3390 | public static final class StreamItemPhotos |
| 3391 | implements BaseColumns, StreamItemPhotosColumns { |
| 3392 | /** |
| 3393 | * No public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3394 | * |
| 3395 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3396 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3397 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3398 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3399 | private StreamItemPhotos() { |
| 3400 | } |
| 3401 | |
| 3402 | /** |
| 3403 | * The directory twig for this sub-table |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3404 | * |
| 3405 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3406 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3407 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3408 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3409 | public static final String CONTENT_DIRECTORY = "photo"; |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3410 | |
| 3411 | /** |
| 3412 | * The MIME type of a directory of stream item photos. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3413 | * |
| 3414 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3415 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3416 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3417 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3418 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item_photo"; |
| 3419 | |
| 3420 | /** |
| 3421 | * The MIME type of a single stream item photo. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3422 | * |
| 3423 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3424 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3425 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3426 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3427 | public static final String CONTENT_ITEM_TYPE |
| 3428 | = "vnd.android.cursor.item/stream_item_photo"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3429 | } |
| 3430 | } |
| 3431 | |
| 3432 | /** |
| 3433 | * Columns in the StreamItems table. |
| 3434 | * |
| 3435 | * @see ContactsContract.StreamItems |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3436 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3437 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3438 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3439 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3440 | protected interface StreamItemsColumns { |
| 3441 | /** |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3442 | * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} |
| 3443 | * that this stream item belongs to. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3444 | * |
| 3445 | * <p>Type: INTEGER</p> |
| 3446 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3447 | * |
| 3448 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3449 | * cursors returned from related queries will be empty. |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3450 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3451 | @Deprecated |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3452 | public static final String CONTACT_ID = "contact_id"; |
| 3453 | |
| 3454 | /** |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3455 | * A reference to the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY} |
| 3456 | * that this stream item belongs to. |
| 3457 | * |
| 3458 | * <p>Type: TEXT</p> |
| 3459 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3460 | * |
| 3461 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3462 | * cursors returned from related queries will be empty. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3463 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3464 | @Deprecated |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3465 | public static final String CONTACT_LOOKUP_KEY = "contact_lookup"; |
| 3466 | |
| 3467 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3468 | * A reference to the {@link RawContacts#_ID} |
| 3469 | * that this stream item belongs to. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3470 | * <p>Type: INTEGER</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3471 | * |
| 3472 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3473 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3474 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3475 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3476 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 3477 | |
| 3478 | /** |
| 3479 | * The package name to use when creating {@link Resources} objects for |
| 3480 | * this stream item. This value is only designed for use when building |
| 3481 | * user interfaces, and should not be used to infer the owner. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3482 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3483 | * |
| 3484 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3485 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3486 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3487 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3488 | public static final String RES_PACKAGE = "res_package"; |
| 3489 | |
| 3490 | /** |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3491 | * The account type to which the raw_contact of this item is associated. See |
| 3492 | * {@link RawContacts#ACCOUNT_TYPE} |
| 3493 | * |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3494 | * <p>Type: TEXT</p> |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3495 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3496 | * |
| 3497 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3498 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3499 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3500 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3501 | public static final String ACCOUNT_TYPE = "account_type"; |
| 3502 | |
| 3503 | /** |
| 3504 | * The account name to which the raw_contact of this item is associated. See |
| 3505 | * {@link RawContacts#ACCOUNT_NAME} |
| 3506 | * |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3507 | * <p>Type: TEXT</p> |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3508 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3509 | * |
| 3510 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3511 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3512 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3513 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3514 | public static final String ACCOUNT_NAME = "account_name"; |
| 3515 | |
| 3516 | /** |
| 3517 | * The data set within the account that the raw_contact of this row belongs to. This allows |
| 3518 | * multiple sync adapters for the same account type to distinguish between |
| 3519 | * each others' data. |
| 3520 | * {@link RawContacts#DATA_SET} |
| 3521 | * |
| 3522 | * <P>Type: TEXT</P> |
| 3523 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3524 | * |
| 3525 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3526 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3527 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3528 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3529 | public static final String DATA_SET = "data_set"; |
| 3530 | |
| 3531 | /** |
| 3532 | * The source_id of the raw_contact that this row belongs to. |
| 3533 | * {@link RawContacts#SOURCE_ID} |
| 3534 | * |
| 3535 | * <P>Type: TEXT</P> |
| 3536 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3537 | * |
| 3538 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3539 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3540 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3541 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3542 | public static final String RAW_CONTACT_SOURCE_ID = "raw_contact_source_id"; |
| 3543 | |
| 3544 | /** |
| 3545 | * The resource name of the icon for the source of the stream item. |
| 3546 | * This resource should be scoped by the {@link #RES_PACKAGE}. As this can only reference |
| 3547 | * drawables, the "@drawable/" prefix must be omitted. |
| 3548 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3549 | * |
| 3550 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3551 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3552 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3553 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3554 | public static final String RES_ICON = "icon"; |
| 3555 | |
| 3556 | /** |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3557 | * The resource name of the label describing the source of the status update, e.g. "Google |
| 3558 | * Talk". This resource should be scoped by the {@link #RES_PACKAGE}. As this can only |
| 3559 | * reference strings, the "@string/" prefix must be omitted. |
| 3560 | * <p>Type: TEXT</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3561 | * |
| 3562 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3563 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3564 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3565 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3566 | public static final String RES_LABEL = "label"; |
| 3567 | |
| 3568 | /** |
| 3569 | * <P> |
| 3570 | * The main textual contents of the item. Typically this is content |
| 3571 | * that was posted by the source of this stream item, but it can also |
| 3572 | * be a textual representation of an action (e.g. ”Checked in at Joe's”). |
| 3573 | * This text is displayed to the user and allows formatting and embedded |
| 3574 | * resource images via HTML (as parseable via |
| 3575 | * {@link android.text.Html#fromHtml}). |
| 3576 | * </P> |
| 3577 | * <P> |
| 3578 | * Long content may be truncated and/or ellipsized - the exact behavior |
| 3579 | * is unspecified, but it should not break tags. |
| 3580 | * </P> |
| 3581 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3582 | * |
| 3583 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3584 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3585 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3586 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3587 | public static final String TEXT = "text"; |
| 3588 | |
| 3589 | /** |
| 3590 | * The absolute time (milliseconds since epoch) when this stream item was |
| 3591 | * inserted/updated. |
| 3592 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3593 | * |
| 3594 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3595 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3596 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3597 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3598 | public static final String TIMESTAMP = "timestamp"; |
| 3599 | |
| 3600 | /** |
| 3601 | * <P> |
| 3602 | * Summary information about the stream item, for example to indicate how |
| 3603 | * many people have reshared it, how many have liked it, how many thumbs |
| 3604 | * up and/or thumbs down it has, what the original source was, etc. |
| 3605 | * </P> |
| 3606 | * <P> |
| 3607 | * This text is displayed to the user and allows simple formatting via |
| 3608 | * HTML, in the same manner as {@link #TEXT} allows. |
| 3609 | * </P> |
| 3610 | * <P> |
| 3611 | * Long content may be truncated and/or ellipsized - the exact behavior |
| 3612 | * is unspecified, but it should not break tags. |
| 3613 | * </P> |
| 3614 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3615 | * |
| 3616 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3617 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3618 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3619 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3620 | public static final String COMMENTS = "comments"; |
| 3621 | |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3622 | /** |
| 3623 | * Generic column for use by sync adapters. |
| 3624 | * |
| 3625 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3626 | * cursors returned from related queries will be empty. |
| 3627 | */ |
| 3628 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3629 | public static final String SYNC1 = "stream_item_sync1"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3630 | /** |
| 3631 | * Generic column for use by sync adapters. |
| 3632 | * |
| 3633 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3634 | * cursors returned from related queries will be empty. |
| 3635 | */ |
| 3636 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3637 | public static final String SYNC2 = "stream_item_sync2"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3638 | /** |
| 3639 | * Generic column for use by sync adapters. |
| 3640 | * |
| 3641 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3642 | * cursors returned from related queries will be empty. |
| 3643 | */ |
| 3644 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3645 | public static final String SYNC3 = "stream_item_sync3"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3646 | /** |
| 3647 | * Generic column for use by sync adapters. |
| 3648 | * |
| 3649 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3650 | * cursors returned from related queries will be empty. |
| 3651 | */ |
| 3652 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3653 | public static final String SYNC4 = "stream_item_sync4"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3654 | } |
| 3655 | |
| 3656 | /** |
| 3657 | * <p> |
| 3658 | * Constants for the stream_item_photos table, which contains photos associated with |
| 3659 | * social stream updates. |
| 3660 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3661 | * <p> |
| 3662 | * Access to social stream photos requires additional permissions beyond the read/write |
| 3663 | * contact permissions required by the provider. Querying for social stream photos |
| 3664 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating |
| 3665 | * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3666 | * </p> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3667 | * <h3>Account check</h3> |
| 3668 | * <p> |
| 3669 | * The content URIs to the insert, update and delete operations are required to have the account |
| 3670 | * information matching that of the owning raw contact as query parameters, namely |
| 3671 | * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. |
| 3672 | * {@link RawContacts#DATA_SET} isn't required. |
| 3673 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3674 | * <h3>Operations</h3> |
| 3675 | * <dl> |
| 3676 | * <dt><b>Insert</b></dt> |
| 3677 | * <dd> |
| 3678 | * <p>Social stream photo entries are associated with a social stream item. Photos |
| 3679 | * can be inserted into a social stream item in a couple of ways: |
| 3680 | * <dl> |
| 3681 | * <dt> |
| 3682 | * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a |
| 3683 | * stream item: |
| 3684 | * </dt> |
| 3685 | * <dd> |
| 3686 | * <pre> |
| 3687 | * ContentValues values = new ContentValues(); |
| 3688 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3689 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3690 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3691 | * ContentUris.appendId(builder, streamItemId); |
| 3692 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3693 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3694 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3695 | * Uri photoUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3696 | * long photoId = ContentUris.parseId(photoUri); |
| 3697 | * </pre> |
| 3698 | * </dd> |
| 3699 | * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> |
| 3700 | * <dd> |
| 3701 | * <pre> |
| 3702 | * ContentValues values = new ContentValues(); |
| 3703 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
| 3704 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3705 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3706 | * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); |
| 3707 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3708 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3709 | * Uri photoUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3710 | * long photoId = ContentUris.parseId(photoUri); |
| 3711 | * </pre> |
| 3712 | * </dd> |
| 3713 | * </dl> |
| 3714 | * </p> |
| 3715 | * </dd> |
| 3716 | * <dt><b>Update</b></dt> |
| 3717 | * <dd> |
| 3718 | * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry, |
| 3719 | * identified by both the stream item ID it belongs to and the stream item photo ID. |
| 3720 | * This can be specified in two ways. |
| 3721 | * <dl> |
| 3722 | * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a |
| 3723 | * stream item: |
| 3724 | * </dt> |
| 3725 | * <dd> |
| 3726 | * <pre> |
| 3727 | * ContentValues values = new ContentValues(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3728 | * values.put(StreamItemPhotos.PHOTO, newPhotoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3729 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3730 | * ContentUris.appendId(builder, streamItemId); |
| 3731 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3732 | * ContentUris.appendId(builder, streamItemPhotoId); |
| 3733 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3734 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3735 | * getContentResolver().update(builder.build(), values, null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3736 | * </pre> |
| 3737 | * </dd> |
| 3738 | * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> |
| 3739 | * <dd> |
| 3740 | * <pre> |
| 3741 | * ContentValues values = new ContentValues(); |
| 3742 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3743 | * values.put(StreamItemPhotos.PHOTO, newPhotoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3744 | * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); |
| 3745 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3746 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3747 | * getContentResolver().update(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3748 | * </pre> |
| 3749 | * </dd> |
| 3750 | * </dl> |
| 3751 | * </p> |
| 3752 | * </dd> |
| 3753 | * <dt><b>Delete</b></dt> |
| 3754 | * <dd>Deletes can be made against either a specific photo item in a stream item, or |
| 3755 | * against all or a selected subset of photo items under a stream item. |
| 3756 | * For example: |
| 3757 | * <dl> |
| 3758 | * <dt>Deleting a single photo via the |
| 3759 | * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item: |
| 3760 | * </dt> |
| 3761 | * <dd> |
| 3762 | * <pre> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3763 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3764 | * ContentUris.appendId(builder, streamItemId); |
| 3765 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3766 | * ContentUris.appendId(builder, streamItemPhotoId); |
| 3767 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3768 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3769 | * getContentResolver().delete(builder.build(), null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3770 | * </pre> |
| 3771 | * </dd> |
| 3772 | * <dt>Deleting all photos under a stream item</dt> |
| 3773 | * <dd> |
| 3774 | * <pre> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3775 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3776 | * ContentUris.appendId(builder, streamItemId); |
| 3777 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3778 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3779 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3780 | * getContentResolver().delete(builder.build(), null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3781 | * </pre> |
| 3782 | * </dd> |
| 3783 | * </dl> |
| 3784 | * </dd> |
| 3785 | * <dt><b>Query</b></dt> |
| 3786 | * <dl> |
| 3787 | * <dt>Querying for a specific photo in a stream item</dt> |
| 3788 | * <dd> |
| 3789 | * <pre> |
| 3790 | * Cursor c = getContentResolver().query( |
| 3791 | * ContentUris.withAppendedId( |
| 3792 | * Uri.withAppendedPath( |
| 3793 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) |
| 3794 | * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), |
| 3795 | * streamItemPhotoId), null, null, null, null); |
| 3796 | * </pre> |
| 3797 | * </dd> |
| 3798 | * <dt>Querying for all photos in a stream item</dt> |
| 3799 | * <dd> |
| 3800 | * <pre> |
| 3801 | * Cursor c = getContentResolver().query( |
| 3802 | * Uri.withAppendedPath( |
| 3803 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) |
| 3804 | * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), |
| 3805 | * null, null, null, StreamItemPhotos.SORT_INDEX); |
| 3806 | * </pre> |
| 3807 | * </dl> |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3808 | * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a |
| 3809 | * {@link StreamItemPhotos#PHOTO_URI}. The {@link StreamItemPhotos#PHOTO_FILE_ID} |
| 3810 | * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to |
| 3811 | * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as |
| 3812 | * an asset file, as follows: |
| 3813 | * <pre> |
| 3814 | * public InputStream openDisplayPhoto(String photoUri) { |
| 3815 | * try { |
| 3816 | * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r"); |
| 3817 | * return fd.createInputStream(); |
| 3818 | * } catch (IOException e) { |
| 3819 | * return null; |
| 3820 | * } |
| 3821 | * } |
| 3822 | * <pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3823 | * </dd> |
| 3824 | * </dl> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3825 | * |
| 3826 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3827 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3828 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3829 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3830 | public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns { |
| 3831 | /** |
| 3832 | * No public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3833 | * |
| 3834 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3835 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3836 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3837 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3838 | private StreamItemPhotos() { |
| 3839 | } |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3840 | |
| 3841 | /** |
| 3842 | * <p> |
| 3843 | * The binary representation of the photo. Any size photo can be inserted; |
| 3844 | * the provider will resize it appropriately for storage and display. |
| 3845 | * </p> |
| 3846 | * <p> |
| 3847 | * This is only intended for use when inserting or updating a stream item photo. |
| 3848 | * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI} |
| 3849 | * as an asset file. |
| 3850 | * </p> |
| 3851 | * <P>Type: BLOB</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3852 | * |
| 3853 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3854 | * cursors returned from related queries will be empty. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3855 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3856 | @Deprecated |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3857 | public static final String PHOTO = "photo"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3858 | } |
| 3859 | |
| 3860 | /** |
| 3861 | * Columns in the StreamItemPhotos table. |
| 3862 | * |
| 3863 | * @see ContactsContract.StreamItemPhotos |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3864 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3865 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3866 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3867 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3868 | protected interface StreamItemPhotosColumns { |
| 3869 | /** |
| 3870 | * A reference to the {@link StreamItems#_ID} this photo is associated with. |
| 3871 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3872 | * |
| 3873 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3874 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3875 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3876 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3877 | public static final String STREAM_ITEM_ID = "stream_item_id"; |
| 3878 | |
| 3879 | /** |
| 3880 | * An integer to use for sort order for photos in the stream item. If not |
| 3881 | * specified, the {@link StreamItemPhotos#_ID} will be used for sorting. |
| 3882 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3883 | * |
| 3884 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3885 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3886 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3887 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3888 | public static final String SORT_INDEX = "sort_index"; |
| 3889 | |
| 3890 | /** |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3891 | * Photo file ID for the photo. |
| 3892 | * See {@link ContactsContract.DisplayPhoto}. |
| 3893 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3894 | * |
| 3895 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3896 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3897 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3898 | @Deprecated |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3899 | public static final String PHOTO_FILE_ID = "photo_file_id"; |
| 3900 | |
| 3901 | /** |
| 3902 | * URI for retrieving the photo content, automatically populated. Callers |
| 3903 | * may retrieve the photo content by opening this URI as an asset file. |
| 3904 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3905 | * |
| 3906 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3907 | * cursors returned from related queries will be empty. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3908 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3909 | @Deprecated |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3910 | public static final String PHOTO_URI = "photo_uri"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3911 | |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3912 | /** |
| 3913 | * Generic column for use by sync adapters. |
| 3914 | * |
| 3915 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3916 | * cursors returned from related queries will be empty. |
| 3917 | */ |
| 3918 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3919 | public static final String SYNC1 = "stream_item_photo_sync1"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3920 | /** |
| 3921 | * Generic column for use by sync adapters. |
| 3922 | * |
| 3923 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3924 | * cursors returned from related queries will be empty. |
| 3925 | */ |
| 3926 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3927 | public static final String SYNC2 = "stream_item_photo_sync2"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3928 | /** |
| 3929 | * Generic column for use by sync adapters. |
| 3930 | * |
| 3931 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3932 | * cursors returned from related queries will be empty. |
| 3933 | */ |
| 3934 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3935 | public static final String SYNC3 = "stream_item_photo_sync3"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3936 | /** |
| 3937 | * Generic column for use by sync adapters. |
| 3938 | * |
| 3939 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3940 | * cursors returned from related queries will be empty. |
| 3941 | */ |
| 3942 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3943 | public static final String SYNC4 = "stream_item_photo_sync4"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3944 | } |
| 3945 | |
| 3946 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 3947 | * <p> |
| 3948 | * Constants for the photo files table, which tracks metadata for hi-res photos |
| 3949 | * stored in the file system. |
| 3950 | * </p> |
| 3951 | * |
| 3952 | * @hide |
| 3953 | */ |
| 3954 | public static final class PhotoFiles implements BaseColumns, PhotoFilesColumns { |
| 3955 | /** |
| 3956 | * No public constructor since this is a utility class |
| 3957 | */ |
| 3958 | private PhotoFiles() { |
| 3959 | } |
| 3960 | } |
| 3961 | |
| 3962 | /** |
| 3963 | * Columns in the PhotoFiles table. |
| 3964 | * |
| 3965 | * @see ContactsContract.PhotoFiles |
| 3966 | * |
| 3967 | * @hide |
| 3968 | */ |
| 3969 | protected interface PhotoFilesColumns { |
| 3970 | |
| 3971 | /** |
| 3972 | * The height, in pixels, of the photo this entry is associated with. |
| 3973 | * <P>Type: NUMBER</P> |
| 3974 | */ |
| 3975 | public static final String HEIGHT = "height"; |
| 3976 | |
| 3977 | /** |
| 3978 | * The width, in pixels, of the photo this entry is associated with. |
| 3979 | * <P>Type: NUMBER</P> |
| 3980 | */ |
| 3981 | public static final String WIDTH = "width"; |
| 3982 | |
| 3983 | /** |
| 3984 | * The size, in bytes, of the photo stored on disk. |
| 3985 | * <P>Type: NUMBER</P> |
| 3986 | */ |
| 3987 | public static final String FILESIZE = "filesize"; |
| 3988 | } |
| 3989 | |
| 3990 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3991 | * Columns in the Data table. |
| 3992 | * |
| 3993 | * @see ContactsContract.Data |
| 3994 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 3995 | protected interface DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3996 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 3997 | * The package name to use when creating {@link Resources} objects for |
| 3998 | * this data row. This value is only designed for use when building user |
| 3999 | * interfaces, and should not be used to infer the owner. |
| 4000 | */ |
| 4001 | public static final String RES_PACKAGE = "res_package"; |
| 4002 | |
| 4003 | /** |
| 4004 | * The MIME type of the item represented by this row. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4005 | */ |
| 4006 | public static final String MIMETYPE = "mimetype"; |
| 4007 | |
| 4008 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 4009 | * A reference to the {@link RawContacts#_ID} |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 4010 | * that this data belongs to. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4011 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 4012 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 4013 | |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 4014 | /** |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4015 | * 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] | 4016 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 4017 | */ |
| 4018 | public static final String IS_PRIMARY = "is_primary"; |
| 4019 | |
| 4020 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 4021 | * Whether this is the primary entry of its kind for the aggregate |
| 4022 | * contact it belongs to. Any data record that is "super primary" must |
| 4023 | * also be "primary". |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 4024 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 4025 | */ |
| 4026 | public static final String IS_SUPER_PRIMARY = "is_super_primary"; |
| 4027 | |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 4028 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 4029 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 4030 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 4031 | * <P>Type: INTEGER</P> |
| 4032 | */ |
| 4033 | public static final String IS_READ_ONLY = "is_read_only"; |
| 4034 | |
| 4035 | /** |
Fred Quintana | c933fb6 | 2009-06-11 12:14:40 -0700 | [diff] [blame] | 4036 | * The version of this data record. This is a read-only value. The data column is |
| 4037 | * guaranteed to not change without the version going up. This value is monotonically |
| 4038 | * increasing. |
| 4039 | * <P>Type: INTEGER</P> |
| 4040 | */ |
| 4041 | public static final String DATA_VERSION = "data_version"; |
| 4042 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4043 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4044 | public static final String DATA1 = "data1"; |
| 4045 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4046 | public static final String DATA2 = "data2"; |
| 4047 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4048 | public static final String DATA3 = "data3"; |
| 4049 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4050 | public static final String DATA4 = "data4"; |
| 4051 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4052 | public static final String DATA5 = "data5"; |
| 4053 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4054 | public static final String DATA6 = "data6"; |
| 4055 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4056 | public static final String DATA7 = "data7"; |
| 4057 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4058 | public static final String DATA8 = "data8"; |
| 4059 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4060 | public static final String DATA9 = "data9"; |
| 4061 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4062 | public static final String DATA10 = "data10"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4063 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4064 | public static final String DATA11 = "data11"; |
| 4065 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4066 | public static final String DATA12 = "data12"; |
| 4067 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4068 | public static final String DATA13 = "data13"; |
| 4069 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4070 | public static final String DATA14 = "data14"; |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4071 | /** |
| 4072 | * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention, |
| 4073 | * this field is used to store BLOBs (binary data). |
| 4074 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4075 | public static final String DATA15 = "data15"; |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 4076 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 4077 | /** Generic column for use by sync adapters. */ |
| 4078 | public static final String SYNC1 = "data_sync1"; |
| 4079 | /** Generic column for use by sync adapters. */ |
| 4080 | public static final String SYNC2 = "data_sync2"; |
| 4081 | /** Generic column for use by sync adapters. */ |
| 4082 | public static final String SYNC3 = "data_sync3"; |
| 4083 | /** Generic column for use by sync adapters. */ |
| 4084 | public static final String SYNC4 = "data_sync4"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4085 | } |
| 4086 | |
| 4087 | /** |
Yorke Lee | 0dc523f | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4088 | * Columns in the Data_Usage_Stat table |
| 4089 | */ |
| 4090 | protected interface DataUsageStatColumns { |
Yorke Lee | 0dc523f | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4091 | /** The last time (in milliseconds) this {@link Data} was used. */ |
| 4092 | public static final String LAST_TIME_USED = "last_time_used"; |
| 4093 | |
Yorke Lee | 5a53d70 | 2013-03-29 18:08:47 -0700 | [diff] [blame] | 4094 | /** The number of times the referenced {@link Data} has been used. */ |
Yorke Lee | 0dc523f | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4095 | public static final String TIMES_USED = "times_used"; |
Yorke Lee | 0dc523f | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4096 | } |
| 4097 | |
| 4098 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4099 | * Combines all columns returned by {@link ContactsContract.Data} table queries. |
| 4100 | * |
| 4101 | * @see ContactsContract.Data |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4102 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 4103 | protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns, |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 4104 | RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns, |
Yorke Lee | 0dc523f | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4105 | ContactStatusColumns, DataUsageStatColumns { |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4106 | } |
| 4107 | |
| 4108 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4109 | * <p> |
| 4110 | * Constants for the data table, which contains data points tied to a raw |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4111 | * contact. Each row of the data table is typically used to store a single |
| 4112 | * piece of contact |
| 4113 | * information (such as a phone number) and its |
| 4114 | * associated metadata (such as whether it is a work or home number). |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4115 | * </p> |
| 4116 | * <h3>Data kinds</h3> |
| 4117 | * <p> |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4118 | * Data is a generic table that can hold any kind of contact data. |
| 4119 | * The kind of data stored in a given row is specified by the row's |
| 4120 | * {@link #MIMETYPE} value, which determines the meaning of the |
| 4121 | * generic columns {@link #DATA1} through |
| 4122 | * {@link #DATA15}. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4123 | * For example, if the data kind is |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4124 | * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column |
| 4125 | * {@link #DATA1} stores the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4126 | * phone number, but if the data kind is |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4127 | * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1} |
| 4128 | * stores the email address. |
| 4129 | * Sync adapters and applications can introduce their own data kinds. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4130 | * </p> |
| 4131 | * <p> |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4132 | * ContactsContract defines a small number of pre-defined data kinds, e.g. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4133 | * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a |
| 4134 | * convenience, these classes define data kind specific aliases for DATA1 etc. |
| 4135 | * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as |
| 4136 | * {@link ContactsContract.Data Data.DATA1}. |
| 4137 | * </p> |
| 4138 | * <p> |
| 4139 | * {@link #DATA1} is an indexed column and should be used for the data element that is |
| 4140 | * expected to be most frequently used in query selections. For example, in the |
| 4141 | * case of a row representing email addresses {@link #DATA1} should probably |
| 4142 | * be used for the email address itself, while {@link #DATA2} etc can be |
| 4143 | * used for auxiliary information like type of email address. |
| 4144 | * <p> |
| 4145 | * <p> |
| 4146 | * By convention, {@link #DATA15} is used for storing BLOBs (binary data). |
| 4147 | * </p> |
| 4148 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 4149 | * The sync adapter for a given account type must correctly handle every data type |
| 4150 | * used in the corresponding raw contacts. Otherwise it could result in lost or |
| 4151 | * corrupted data. |
| 4152 | * </p> |
| 4153 | * <p> |
| 4154 | * Similarly, you should refrain from introducing new kinds of data for an other |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4155 | * party's account types. For example, if you add a data row for |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4156 | * "favorite song" to a raw contact owned by a Google account, it will not |
| 4157 | * get synced to the server, because the Google sync adapter does not know |
| 4158 | * how to handle this data kind. Thus new data kinds are typically |
| 4159 | * introduced along with new account types, i.e. new sync adapters. |
| 4160 | * </p> |
| 4161 | * <h3>Batch operations</h3> |
| 4162 | * <p> |
| 4163 | * Data rows can be inserted/updated/deleted using the traditional |
| 4164 | * {@link ContentResolver#insert}, {@link ContentResolver#update} and |
| 4165 | * {@link ContentResolver#delete} methods, however the newer mechanism based |
| 4166 | * on a batch of {@link ContentProviderOperation} will prove to be a better |
| 4167 | * choice in almost all cases. All operations in a batch are executed in a |
| 4168 | * single transaction, which ensures that the phone-side and server-side |
| 4169 | * state of a raw contact are always consistent. Also, the batch-based |
| 4170 | * approach is far more efficient: not only are the database operations |
| 4171 | * faster when executed in a single transaction, but also sending a batch of |
| 4172 | * commands to the content provider saves a lot of time on context switching |
| 4173 | * between your process and the process in which the content provider runs. |
| 4174 | * </p> |
| 4175 | * <p> |
| 4176 | * The flip side of using batched operations is that a large batch may lock |
| 4177 | * up the database for a long time preventing other applications from |
| 4178 | * accessing data and potentially causing ANRs ("Application Not Responding" |
| 4179 | * dialogs.) |
| 4180 | * </p> |
| 4181 | * <p> |
| 4182 | * To avoid such lockups of the database, make sure to insert "yield points" |
| 4183 | * in the batch. A yield point indicates to the content provider that before |
| 4184 | * executing the next operation it can commit the changes that have already |
| 4185 | * been made, yield to other requests, open another transaction and continue |
| 4186 | * processing operations. A yield point will not automatically commit the |
| 4187 | * transaction, but only if there is another request waiting on the |
| 4188 | * database. Normally a sync adapter should insert a yield point at the |
| 4189 | * beginning of each raw contact operation sequence in the batch. See |
| 4190 | * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}. |
| 4191 | * </p> |
| 4192 | * <h3>Operations</h3> |
| 4193 | * <dl> |
| 4194 | * <dt><b>Insert</b></dt> |
| 4195 | * <dd> |
| 4196 | * <p> |
| 4197 | * An individual data row can be inserted using the traditional |
| 4198 | * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows |
| 4199 | * should always be inserted as a batch. |
| 4200 | * </p> |
| 4201 | * <p> |
| 4202 | * An example of a traditional insert: |
| 4203 | * <pre> |
| 4204 | * ContentValues values = new ContentValues(); |
| 4205 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 4206 | * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); |
| 4207 | * values.put(Phone.NUMBER, "1-800-GOOG-411"); |
| 4208 | * values.put(Phone.TYPE, Phone.TYPE_CUSTOM); |
| 4209 | * values.put(Phone.LABEL, "free directory assistance"); |
| 4210 | * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values); |
| 4211 | * </pre> |
| 4212 | * <p> |
| 4213 | * The same done using ContentProviderOperations: |
| 4214 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4215 | * ArrayList<ContentProviderOperation> ops = |
| 4216 | * new ArrayList<ContentProviderOperation>(); |
| 4217 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4218 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 4219 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 4220 | * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE) |
| 4221 | * .withValue(Phone.NUMBER, "1-800-GOOG-411") |
| 4222 | * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM) |
| 4223 | * .withValue(Phone.LABEL, "free directory assistance") |
| 4224 | * .build()); |
| 4225 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4226 | * </pre> |
| 4227 | * </p> |
| 4228 | * <dt><b>Update</b></dt> |
| 4229 | * <dd> |
| 4230 | * <p> |
| 4231 | * Just as with insert, update can be done incrementally or as a batch, |
| 4232 | * the batch mode being the preferred method: |
| 4233 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4234 | * ArrayList<ContentProviderOperation> ops = |
| 4235 | * new ArrayList<ContentProviderOperation>(); |
| 4236 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4237 | * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI) |
| 4238 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 4239 | * .withValue(Email.DATA, "somebody@android.com") |
| 4240 | * .build()); |
| 4241 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4242 | * </pre> |
| 4243 | * </p> |
| 4244 | * </dd> |
| 4245 | * <dt><b>Delete</b></dt> |
| 4246 | * <dd> |
| 4247 | * <p> |
| 4248 | * Just as with insert and update, deletion can be done either using the |
| 4249 | * {@link ContentResolver#delete} method or using a ContentProviderOperation: |
| 4250 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4251 | * ArrayList<ContentProviderOperation> ops = |
| 4252 | * new ArrayList<ContentProviderOperation>(); |
| 4253 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4254 | * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI) |
| 4255 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 4256 | * .build()); |
| 4257 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4258 | * </pre> |
| 4259 | * </p> |
| 4260 | * </dd> |
| 4261 | * <dt><b>Query</b></dt> |
| 4262 | * <dd> |
| 4263 | * <p> |
| 4264 | * <dl> |
| 4265 | * <dt>Finding all Data of a given type for a given contact</dt> |
| 4266 | * <dd> |
| 4267 | * <pre> |
| 4268 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 4269 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 4270 | * Data.CONTACT_ID + "=?" + " AND " |
| 4271 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 4272 | * new String[] {String.valueOf(contactId)}, null); |
| 4273 | * </pre> |
| 4274 | * </p> |
| 4275 | * <p> |
| 4276 | * </dd> |
| 4277 | * <dt>Finding all Data of a given type for a given raw contact</dt> |
| 4278 | * <dd> |
| 4279 | * <pre> |
| 4280 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 4281 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 4282 | * Data.RAW_CONTACT_ID + "=?" + " AND " |
| 4283 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 4284 | * new String[] {String.valueOf(rawContactId)}, null); |
| 4285 | * </pre> |
| 4286 | * </dd> |
| 4287 | * <dt>Finding all Data for a given raw contact</dt> |
| 4288 | * <dd> |
| 4289 | * Most sync adapters will want to read all data rows for a raw contact |
| 4290 | * along with the raw contact itself. For that you should use the |
| 4291 | * {@link RawContactsEntity}. See also {@link RawContacts}. |
| 4292 | * </dd> |
| 4293 | * </dl> |
| 4294 | * </p> |
| 4295 | * </dd> |
| 4296 | * </dl> |
| 4297 | * <h2>Columns</h2> |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4298 | * <p> |
| 4299 | * Many columns are available via a {@link Data#CONTENT_URI} query. For best performance you |
| 4300 | * should explicitly specify a projection to only those columns that you need. |
| 4301 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4302 | * <table class="jd-sumtable"> |
| 4303 | * <tr> |
| 4304 | * <th colspan='4'>Data</th> |
| 4305 | * </tr> |
| 4306 | * <tr> |
| 4307 | * <td style="width: 7em;">long</td> |
| 4308 | * <td style="width: 20em;">{@link #_ID}</td> |
| 4309 | * <td style="width: 5em;">read-only</td> |
| 4310 | * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words, |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4311 | * it would be a bad idea to delete and reinsert a data row. A sync adapter should |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4312 | * always do an update instead.</td> |
| 4313 | * </tr> |
| 4314 | * <tr> |
| 4315 | * <td>String</td> |
| 4316 | * <td>{@link #MIMETYPE}</td> |
| 4317 | * <td>read/write-once</td> |
| 4318 | * <td> |
| 4319 | * <p>The MIME type of the item represented by this row. Examples of common |
| 4320 | * MIME types are: |
| 4321 | * <ul> |
| 4322 | * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li> |
| 4323 | * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li> |
| 4324 | * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li> |
| 4325 | * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li> |
| 4326 | * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li> |
| 4327 | * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li> |
| 4328 | * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li> |
| 4329 | * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li> |
| 4330 | * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li> |
| 4331 | * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li> |
| 4332 | * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li> |
| 4333 | * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li> |
| 4334 | * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 4335 | * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4336 | * </ul> |
| 4337 | * </p> |
| 4338 | * </td> |
| 4339 | * </tr> |
| 4340 | * <tr> |
| 4341 | * <td>long</td> |
| 4342 | * <td>{@link #RAW_CONTACT_ID}</td> |
| 4343 | * <td>read/write-once</td> |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4344 | * <td>The id of the row in the {@link RawContacts} table that this data belongs to.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4345 | * </tr> |
| 4346 | * <tr> |
| 4347 | * <td>int</td> |
| 4348 | * <td>{@link #IS_PRIMARY}</td> |
| 4349 | * <td>read/write</td> |
| 4350 | * <td>Whether this is the primary entry of its kind for the raw contact it belongs to. |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4351 | * "1" if true, "0" if false. |
| 4352 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4353 | * </tr> |
| 4354 | * <tr> |
| 4355 | * <td>int</td> |
| 4356 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 4357 | * <td>read/write</td> |
| 4358 | * <td>Whether this is the primary entry of its kind for the aggregate |
| 4359 | * contact it belongs to. Any data record that is "super primary" must |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4360 | * also be "primary". For example, the super-primary entry may be |
| 4361 | * interpreted as the default contact value of its kind (for example, |
| 4362 | * the default phone number to use for the contact).</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4363 | * </tr> |
| 4364 | * <tr> |
| 4365 | * <td>int</td> |
| 4366 | * <td>{@link #DATA_VERSION}</td> |
| 4367 | * <td>read-only</td> |
| 4368 | * <td>The version of this data record. Whenever the data row changes |
| 4369 | * the version goes up. This value is monotonically increasing.</td> |
| 4370 | * </tr> |
| 4371 | * <tr> |
| 4372 | * <td>Any type</td> |
| 4373 | * <td> |
| 4374 | * {@link #DATA1}<br> |
| 4375 | * {@link #DATA2}<br> |
| 4376 | * {@link #DATA3}<br> |
| 4377 | * {@link #DATA4}<br> |
| 4378 | * {@link #DATA5}<br> |
| 4379 | * {@link #DATA6}<br> |
| 4380 | * {@link #DATA7}<br> |
| 4381 | * {@link #DATA8}<br> |
| 4382 | * {@link #DATA9}<br> |
| 4383 | * {@link #DATA10}<br> |
| 4384 | * {@link #DATA11}<br> |
| 4385 | * {@link #DATA12}<br> |
| 4386 | * {@link #DATA13}<br> |
| 4387 | * {@link #DATA14}<br> |
| 4388 | * {@link #DATA15} |
| 4389 | * </td> |
| 4390 | * <td>read/write</td> |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4391 | * <td> |
| 4392 | * <p> |
| 4393 | * Generic data columns. The meaning of each column is determined by the |
| 4394 | * {@link #MIMETYPE}. By convention, {@link #DATA15} is used for storing |
| 4395 | * BLOBs (binary data). |
| 4396 | * </p> |
| 4397 | * <p> |
| 4398 | * Data columns whose meaning is not explicitly defined for a given MIMETYPE |
| 4399 | * should not be used. There is no guarantee that any sync adapter will |
| 4400 | * preserve them. Sync adapters themselves should not use such columns either, |
| 4401 | * but should instead use {@link #SYNC1}-{@link #SYNC4}. |
| 4402 | * </p> |
| 4403 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4404 | * </tr> |
| 4405 | * <tr> |
| 4406 | * <td>Any type</td> |
| 4407 | * <td> |
| 4408 | * {@link #SYNC1}<br> |
| 4409 | * {@link #SYNC2}<br> |
| 4410 | * {@link #SYNC3}<br> |
| 4411 | * {@link #SYNC4} |
| 4412 | * </td> |
| 4413 | * <td>read/write</td> |
| 4414 | * <td>Generic columns for use by sync adapters. For example, a Photo row |
| 4415 | * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error) |
| 4416 | * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td> |
| 4417 | * </tr> |
| 4418 | * </table> |
| 4419 | * |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4420 | * <p> |
| 4421 | * Some columns from the most recent associated status update are also available |
| 4422 | * through an implicit join. |
| 4423 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4424 | * <table class="jd-sumtable"> |
| 4425 | * <tr> |
| 4426 | * <th colspan='4'>Join with {@link StatusUpdates}</th> |
| 4427 | * </tr> |
| 4428 | * <tr> |
| 4429 | * <td style="width: 7em;">int</td> |
| 4430 | * <td style="width: 20em;">{@link #PRESENCE}</td> |
| 4431 | * <td style="width: 5em;">read-only</td> |
| 4432 | * <td>IM presence status linked to this data row. Compare with |
| 4433 | * {@link #CONTACT_PRESENCE}, which contains the contact's presence across |
| 4434 | * all IM rows. See {@link StatusUpdates} for individual status definitions. |
| 4435 | * The provider may choose not to store this value |
| 4436 | * in persistent storage. The expectation is that presence status will be |
kmccormick | 50e27c8 | 2013-03-28 16:33:11 -0700 | [diff] [blame] | 4437 | * updated on a regular basis. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4438 | * </td> |
| 4439 | * </tr> |
| 4440 | * <tr> |
| 4441 | * <td>String</td> |
| 4442 | * <td>{@link #STATUS}</td> |
| 4443 | * <td>read-only</td> |
| 4444 | * <td>Latest status update linked with this data row.</td> |
| 4445 | * </tr> |
| 4446 | * <tr> |
| 4447 | * <td>long</td> |
| 4448 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 4449 | * <td>read-only</td> |
| 4450 | * <td>The absolute time in milliseconds when the latest status was |
| 4451 | * inserted/updated for this data row.</td> |
| 4452 | * </tr> |
| 4453 | * <tr> |
| 4454 | * <td>String</td> |
| 4455 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 4456 | * <td>read-only</td> |
| 4457 | * <td>The package containing resources for this status: label and icon.</td> |
| 4458 | * </tr> |
| 4459 | * <tr> |
| 4460 | * <td>long</td> |
| 4461 | * <td>{@link #STATUS_LABEL}</td> |
| 4462 | * <td>read-only</td> |
| 4463 | * <td>The resource ID of the label describing the source of status update linked |
| 4464 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4465 | * </tr> |
| 4466 | * <tr> |
| 4467 | * <td>long</td> |
| 4468 | * <td>{@link #STATUS_ICON}</td> |
| 4469 | * <td>read-only</td> |
| 4470 | * <td>The resource ID of the icon for the source of the status update linked |
| 4471 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4472 | * </tr> |
| 4473 | * </table> |
| 4474 | * |
| 4475 | * <p> |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4476 | * Some columns from the associated raw contact are also available through an |
| 4477 | * implicit join. The other columns are excluded as uninteresting in this |
| 4478 | * context. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4479 | * </p> |
| 4480 | * |
| 4481 | * <table class="jd-sumtable"> |
| 4482 | * <tr> |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4483 | * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4484 | * </tr> |
| 4485 | * <tr> |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4486 | * <td style="width: 7em;">long</td> |
| 4487 | * <td style="width: 20em;">{@link #CONTACT_ID}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4488 | * <td style="width: 5em;">read-only</td> |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4489 | * <td>The id of the row in the {@link Contacts} table that this data belongs |
| 4490 | * to.</td> |
| 4491 | * </tr> |
| 4492 | * <tr> |
| 4493 | * <td>int</td> |
| 4494 | * <td>{@link #AGGREGATION_MODE}</td> |
| 4495 | * <td>read-only</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4496 | * <td>See {@link RawContacts}.</td> |
| 4497 | * </tr> |
| 4498 | * <tr> |
| 4499 | * <td>int</td> |
| 4500 | * <td>{@link #DELETED}</td> |
| 4501 | * <td>read-only</td> |
| 4502 | * <td>See {@link RawContacts}.</td> |
| 4503 | * </tr> |
| 4504 | * </table> |
| 4505 | * |
| 4506 | * <p> |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4507 | * The ID column for the associated aggregated contact table |
| 4508 | * {@link ContactsContract.Contacts} is available |
| 4509 | * via the implicit join to the {@link RawContacts} table, see above. |
| 4510 | * The remaining columns from this table are also |
| 4511 | * available, through an implicit join. This |
| 4512 | * facilitates lookup by |
| 4513 | * the value of a single data element, such as the email address. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4514 | * </p> |
| 4515 | * |
| 4516 | * <table class="jd-sumtable"> |
| 4517 | * <tr> |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4518 | * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4519 | * </tr> |
| 4520 | * <tr> |
| 4521 | * <td style="width: 7em;">String</td> |
| 4522 | * <td style="width: 20em;">{@link #LOOKUP_KEY}</td> |
| 4523 | * <td style="width: 5em;">read-only</td> |
| 4524 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4525 | * </tr> |
| 4526 | * <tr> |
| 4527 | * <td>String</td> |
| 4528 | * <td>{@link #DISPLAY_NAME}</td> |
| 4529 | * <td>read-only</td> |
| 4530 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4531 | * </tr> |
| 4532 | * <tr> |
| 4533 | * <td>long</td> |
| 4534 | * <td>{@link #PHOTO_ID}</td> |
| 4535 | * <td>read-only</td> |
| 4536 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4537 | * </tr> |
| 4538 | * <tr> |
| 4539 | * <td>int</td> |
| 4540 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 4541 | * <td>read-only</td> |
| 4542 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4543 | * </tr> |
| 4544 | * <tr> |
| 4545 | * <td>int</td> |
| 4546 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 4547 | * <td>read-only</td> |
| 4548 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4549 | * </tr> |
| 4550 | * <tr> |
| 4551 | * <td>int</td> |
| 4552 | * <td>{@link #TIMES_CONTACTED}</td> |
| 4553 | * <td>read-only</td> |
| 4554 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4555 | * </tr> |
| 4556 | * <tr> |
| 4557 | * <td>long</td> |
| 4558 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 4559 | * <td>read-only</td> |
| 4560 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4561 | * </tr> |
| 4562 | * <tr> |
| 4563 | * <td>int</td> |
| 4564 | * <td>{@link #STARRED}</td> |
| 4565 | * <td>read-only</td> |
| 4566 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4567 | * </tr> |
| 4568 | * <tr> |
| 4569 | * <td>String</td> |
| 4570 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 4571 | * <td>read-only</td> |
| 4572 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4573 | * </tr> |
| 4574 | * <tr> |
| 4575 | * <td>int</td> |
| 4576 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 4577 | * <td>read-only</td> |
| 4578 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4579 | * </tr> |
| 4580 | * <tr> |
| 4581 | * <td>int</td> |
| 4582 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 4583 | * <td>read-only</td> |
| 4584 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4585 | * </tr> |
| 4586 | * <tr> |
| 4587 | * <td>String</td> |
| 4588 | * <td>{@link #CONTACT_STATUS}</td> |
| 4589 | * <td>read-only</td> |
| 4590 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4591 | * </tr> |
| 4592 | * <tr> |
| 4593 | * <td>long</td> |
| 4594 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 4595 | * <td>read-only</td> |
| 4596 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4597 | * </tr> |
| 4598 | * <tr> |
| 4599 | * <td>String</td> |
| 4600 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 4601 | * <td>read-only</td> |
| 4602 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4603 | * </tr> |
| 4604 | * <tr> |
| 4605 | * <td>long</td> |
| 4606 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 4607 | * <td>read-only</td> |
| 4608 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4609 | * </tr> |
| 4610 | * <tr> |
| 4611 | * <td>long</td> |
| 4612 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 4613 | * <td>read-only</td> |
| 4614 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4615 | * </tr> |
| 4616 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4617 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 4618 | public final static class Data implements DataColumnsWithJoins, ContactCounts { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4619 | /** |
| 4620 | * This utility class cannot be instantiated |
| 4621 | */ |
| 4622 | private Data() {} |
| 4623 | |
| 4624 | /** |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4625 | * The content:// style URI for this table, which requests a directory |
| 4626 | * of data rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4627 | */ |
| 4628 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); |
| 4629 | |
| 4630 | /** |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 4631 | * A boolean parameter for {@link Data#CONTENT_URI}. |
| 4632 | * This specifies whether or not the returned data items should be filtered to show |
| 4633 | * data items belonging to visible contacts only. |
| 4634 | */ |
| 4635 | public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; |
| 4636 | |
| 4637 | /** |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4638 | * The MIME type of the results from {@link #CONTENT_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4639 | */ |
| 4640 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 4641 | |
| 4642 | /** |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4643 | * <p> |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4644 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 4645 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4646 | * entry of the given {@link ContactsContract.Data} entry. |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4647 | * </p> |
| 4648 | * <p> |
| 4649 | * Returns the Uri for the contact in the first entry returned by |
| 4650 | * {@link ContentResolver#query(Uri, String[], String, String[], String)} |
| 4651 | * for the provided {@code dataUri}. If the query returns null or empty |
| 4652 | * results, silently returns null. |
| 4653 | * </p> |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 4654 | */ |
| 4655 | public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) { |
| 4656 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 4657 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 4658 | }, null, null, null); |
| 4659 | |
| 4660 | Uri lookupUri = null; |
| 4661 | try { |
| 4662 | if (cursor != null && cursor.moveToFirst()) { |
| 4663 | final long contactId = cursor.getLong(0); |
| 4664 | final String lookupKey = cursor.getString(1); |
| 4665 | return Contacts.getLookupUri(contactId, lookupKey); |
| 4666 | } |
| 4667 | } finally { |
| 4668 | if (cursor != null) cursor.close(); |
| 4669 | } |
| 4670 | return lookupUri; |
| 4671 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4672 | } |
| 4673 | |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 4674 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4675 | * <p> |
Tom O'Neill | 244327e | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4676 | * 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] | 4677 | * an outer join of the raw_contacts table with the data table. It is a strictly |
| 4678 | * read-only table. |
| 4679 | * </p> |
| 4680 | * <p> |
| 4681 | * If a raw contact has data rows, the RawContactsEntity cursor will contain |
| 4682 | * a one row for each data row. If the raw contact has no data rows, the |
| 4683 | * cursor will still contain one row with the raw contact-level information |
| 4684 | * and nulls for data columns. |
| 4685 | * |
| 4686 | * <pre> |
| 4687 | * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId); |
| 4688 | * Cursor c = getContentResolver().query(entityUri, |
| 4689 | * new String[]{ |
| 4690 | * RawContactsEntity.SOURCE_ID, |
| 4691 | * RawContactsEntity.DATA_ID, |
| 4692 | * RawContactsEntity.MIMETYPE, |
| 4693 | * RawContactsEntity.DATA1 |
| 4694 | * }, null, null, null); |
| 4695 | * try { |
| 4696 | * while (c.moveToNext()) { |
| 4697 | * String sourceId = c.getString(0); |
| 4698 | * if (!c.isNull(1)) { |
| 4699 | * String mimeType = c.getString(2); |
| 4700 | * String data = c.getString(3); |
| 4701 | * ... |
| 4702 | * } |
| 4703 | * } |
| 4704 | * } finally { |
| 4705 | * c.close(); |
| 4706 | * } |
| 4707 | * </pre> |
| 4708 | * |
| 4709 | * <h3>Columns</h3> |
| 4710 | * RawContactsEntity has a combination of RawContact and Data columns. |
| 4711 | * |
| 4712 | * <table class="jd-sumtable"> |
| 4713 | * <tr> |
| 4714 | * <th colspan='4'>RawContacts</th> |
| 4715 | * </tr> |
| 4716 | * <tr> |
| 4717 | * <td style="width: 7em;">long</td> |
| 4718 | * <td style="width: 20em;">{@link #_ID}</td> |
| 4719 | * <td style="width: 5em;">read-only</td> |
| 4720 | * <td>Raw contact row ID. See {@link RawContacts}.</td> |
| 4721 | * </tr> |
| 4722 | * <tr> |
| 4723 | * <td>long</td> |
| 4724 | * <td>{@link #CONTACT_ID}</td> |
| 4725 | * <td>read-only</td> |
| 4726 | * <td>See {@link RawContacts}.</td> |
| 4727 | * </tr> |
| 4728 | * <tr> |
| 4729 | * <td>int</td> |
| 4730 | * <td>{@link #AGGREGATION_MODE}</td> |
| 4731 | * <td>read-only</td> |
| 4732 | * <td>See {@link RawContacts}.</td> |
| 4733 | * </tr> |
| 4734 | * <tr> |
| 4735 | * <td>int</td> |
| 4736 | * <td>{@link #DELETED}</td> |
| 4737 | * <td>read-only</td> |
| 4738 | * <td>See {@link RawContacts}.</td> |
| 4739 | * </tr> |
| 4740 | * </table> |
| 4741 | * |
| 4742 | * <table class="jd-sumtable"> |
| 4743 | * <tr> |
| 4744 | * <th colspan='4'>Data</th> |
| 4745 | * </tr> |
| 4746 | * <tr> |
| 4747 | * <td style="width: 7em;">long</td> |
| 4748 | * <td style="width: 20em;">{@link #DATA_ID}</td> |
| 4749 | * <td style="width: 5em;">read-only</td> |
| 4750 | * <td>Data row ID. It will be null if the raw contact has no data rows.</td> |
| 4751 | * </tr> |
| 4752 | * <tr> |
| 4753 | * <td>String</td> |
| 4754 | * <td>{@link #MIMETYPE}</td> |
| 4755 | * <td>read-only</td> |
| 4756 | * <td>See {@link ContactsContract.Data}.</td> |
| 4757 | * </tr> |
| 4758 | * <tr> |
| 4759 | * <td>int</td> |
| 4760 | * <td>{@link #IS_PRIMARY}</td> |
| 4761 | * <td>read-only</td> |
| 4762 | * <td>See {@link ContactsContract.Data}.</td> |
| 4763 | * </tr> |
| 4764 | * <tr> |
| 4765 | * <td>int</td> |
| 4766 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 4767 | * <td>read-only</td> |
| 4768 | * <td>See {@link ContactsContract.Data}.</td> |
| 4769 | * </tr> |
| 4770 | * <tr> |
| 4771 | * <td>int</td> |
| 4772 | * <td>{@link #DATA_VERSION}</td> |
| 4773 | * <td>read-only</td> |
| 4774 | * <td>See {@link ContactsContract.Data}.</td> |
| 4775 | * </tr> |
| 4776 | * <tr> |
| 4777 | * <td>Any type</td> |
| 4778 | * <td> |
| 4779 | * {@link #DATA1}<br> |
| 4780 | * {@link #DATA2}<br> |
| 4781 | * {@link #DATA3}<br> |
| 4782 | * {@link #DATA4}<br> |
| 4783 | * {@link #DATA5}<br> |
| 4784 | * {@link #DATA6}<br> |
| 4785 | * {@link #DATA7}<br> |
| 4786 | * {@link #DATA8}<br> |
| 4787 | * {@link #DATA9}<br> |
| 4788 | * {@link #DATA10}<br> |
| 4789 | * {@link #DATA11}<br> |
| 4790 | * {@link #DATA12}<br> |
| 4791 | * {@link #DATA13}<br> |
| 4792 | * {@link #DATA14}<br> |
| 4793 | * {@link #DATA15} |
| 4794 | * </td> |
| 4795 | * <td>read-only</td> |
| 4796 | * <td>See {@link ContactsContract.Data}.</td> |
| 4797 | * </tr> |
| 4798 | * <tr> |
| 4799 | * <td>Any type</td> |
| 4800 | * <td> |
| 4801 | * {@link #SYNC1}<br> |
| 4802 | * {@link #SYNC2}<br> |
| 4803 | * {@link #SYNC3}<br> |
| 4804 | * {@link #SYNC4} |
| 4805 | * </td> |
| 4806 | * <td>read-only</td> |
| 4807 | * <td>See {@link ContactsContract.Data}.</td> |
| 4808 | * </tr> |
| 4809 | * </table> |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 4810 | */ |
| 4811 | public final static class RawContactsEntity |
| 4812 | implements BaseColumns, DataColumns, RawContactsColumns { |
| 4813 | /** |
| 4814 | * This utility class cannot be instantiated |
| 4815 | */ |
| 4816 | private RawContactsEntity() {} |
| 4817 | |
| 4818 | /** |
| 4819 | * The content:// style URI for this table |
| 4820 | */ |
| 4821 | public static final Uri CONTENT_URI = |
| 4822 | Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities"); |
| 4823 | |
| 4824 | /** |
Dave Santoro | 2b4d075 | 2011-09-07 17:37:33 -0700 | [diff] [blame] | 4825 | * The content:// style URI for this table, specific to the user's profile. |
| 4826 | */ |
| 4827 | public static final Uri PROFILE_CONTENT_URI = |
| 4828 | Uri.withAppendedPath(Profile.CONTENT_URI, "raw_contact_entities"); |
| 4829 | |
| 4830 | /** |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 4831 | * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities. |
| 4832 | */ |
| 4833 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity"; |
| 4834 | |
| 4835 | /** |
| 4836 | * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward |
| 4837 | * Data.CONTENT_URI contains only exportable data. |
| 4838 | * |
| 4839 | * This flag is useful (currently) only for vCard exporter in Contacts app, which |
| 4840 | * needs to exclude "un-exportable" data from available data to export, while |
| 4841 | * Contacts app itself has priviledge to access all data including "un-expotable" |
| 4842 | * ones and providers return all of them regardless of the callers' intention. |
| 4843 | * <P>Type: INTEGER</p> |
| 4844 | * |
| 4845 | * @hide Maybe available only in Eclair and not really ready for public use. |
| 4846 | * TODO: remove, or implement this feature completely. As of now (Eclair), |
| 4847 | * we only use this flag in queryEntities(), not query(). |
| 4848 | */ |
| 4849 | public static final String FOR_EXPORT_ONLY = "for_export_only"; |
| 4850 | |
| 4851 | /** |
| 4852 | * The ID of the data column. The value will be null if this raw contact has no data rows. |
| 4853 | * <P>Type: INTEGER</P> |
| 4854 | */ |
| 4855 | public static final String DATA_ID = "data_id"; |
| 4856 | } |
| 4857 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4858 | /** |
| 4859 | * @see PhoneLookup |
| 4860 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 4861 | protected interface PhoneLookupColumns { |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4862 | /** |
| 4863 | * The phone number as the user entered it. |
| 4864 | * <P>Type: TEXT</P> |
| 4865 | */ |
| 4866 | public static final String NUMBER = "number"; |
| 4867 | |
| 4868 | /** |
| 4869 | * The type of phone number, for example Home or Work. |
| 4870 | * <P>Type: INTEGER</P> |
| 4871 | */ |
| 4872 | public static final String TYPE = "type"; |
| 4873 | |
| 4874 | /** |
| 4875 | * The user defined label for the phone number. |
| 4876 | * <P>Type: TEXT</P> |
| 4877 | */ |
| 4878 | public static final String LABEL = "label"; |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 4879 | |
| 4880 | /** |
| 4881 | * The phone number's E164 representation. |
| 4882 | * <P>Type: TEXT</P> |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 4883 | */ |
| 4884 | public static final String NORMALIZED_NUMBER = "normalized_number"; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4885 | } |
| 4886 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4887 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4888 | * 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] | 4889 | * 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] | 4890 | * want to find to {@link #CONTENT_FILTER_URI}. This query is highly |
| 4891 | * optimized. |
| 4892 | * <pre> |
| 4893 | * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); |
| 4894 | * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,... |
| 4895 | * </pre> |
| 4896 | * |
| 4897 | * <h3>Columns</h3> |
| 4898 | * |
| 4899 | * <table class="jd-sumtable"> |
| 4900 | * <tr> |
| 4901 | * <th colspan='4'>PhoneLookup</th> |
| 4902 | * </tr> |
| 4903 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4904 | * <td>String</td> |
| 4905 | * <td>{@link #NUMBER}</td> |
| 4906 | * <td>read-only</td> |
| 4907 | * <td>Phone number.</td> |
| 4908 | * </tr> |
| 4909 | * <tr> |
| 4910 | * <td>String</td> |
| 4911 | * <td>{@link #TYPE}</td> |
| 4912 | * <td>read-only</td> |
| 4913 | * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td> |
| 4914 | * </tr> |
| 4915 | * <tr> |
| 4916 | * <td>String</td> |
| 4917 | * <td>{@link #LABEL}</td> |
| 4918 | * <td>read-only</td> |
| 4919 | * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td> |
| 4920 | * </tr> |
| 4921 | * </table> |
| 4922 | * <p> |
| 4923 | * Columns from the Contacts table are also available through a join. |
| 4924 | * </p> |
| 4925 | * <table class="jd-sumtable"> |
| 4926 | * <tr> |
| 4927 | * <th colspan='4'>Join with {@link Contacts}</th> |
| 4928 | * </tr> |
| 4929 | * <tr> |
Dmitri Plotnikov | 817b3f9 | 2011-01-09 17:07:13 -0800 | [diff] [blame] | 4930 | * <td>long</td> |
| 4931 | * <td>{@link #_ID}</td> |
| 4932 | * <td>read-only</td> |
| 4933 | * <td>Contact ID.</td> |
| 4934 | * </tr> |
| 4935 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4936 | * <td>String</td> |
| 4937 | * <td>{@link #LOOKUP_KEY}</td> |
| 4938 | * <td>read-only</td> |
| 4939 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4940 | * </tr> |
| 4941 | * <tr> |
| 4942 | * <td>String</td> |
| 4943 | * <td>{@link #DISPLAY_NAME}</td> |
| 4944 | * <td>read-only</td> |
| 4945 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4946 | * </tr> |
| 4947 | * <tr> |
| 4948 | * <td>long</td> |
| 4949 | * <td>{@link #PHOTO_ID}</td> |
| 4950 | * <td>read-only</td> |
| 4951 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4952 | * </tr> |
| 4953 | * <tr> |
| 4954 | * <td>int</td> |
| 4955 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 4956 | * <td>read-only</td> |
| 4957 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4958 | * </tr> |
| 4959 | * <tr> |
| 4960 | * <td>int</td> |
| 4961 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 4962 | * <td>read-only</td> |
| 4963 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4964 | * </tr> |
| 4965 | * <tr> |
| 4966 | * <td>int</td> |
| 4967 | * <td>{@link #TIMES_CONTACTED}</td> |
| 4968 | * <td>read-only</td> |
| 4969 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4970 | * </tr> |
| 4971 | * <tr> |
| 4972 | * <td>long</td> |
| 4973 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 4974 | * <td>read-only</td> |
| 4975 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4976 | * </tr> |
| 4977 | * <tr> |
| 4978 | * <td>int</td> |
| 4979 | * <td>{@link #STARRED}</td> |
| 4980 | * <td>read-only</td> |
| 4981 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4982 | * </tr> |
| 4983 | * <tr> |
| 4984 | * <td>String</td> |
| 4985 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 4986 | * <td>read-only</td> |
| 4987 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4988 | * </tr> |
| 4989 | * <tr> |
| 4990 | * <td>int</td> |
| 4991 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 4992 | * <td>read-only</td> |
| 4993 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4994 | * </tr> |
| 4995 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4996 | */ |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 4997 | public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, |
| 4998 | ContactsColumns, ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4999 | /** |
| 5000 | * This utility class cannot be instantiated |
| 5001 | */ |
| 5002 | private PhoneLookup() {} |
| 5003 | |
| 5004 | /** |
| 5005 | * The content:// style URI for this table. Append the phone number you want to lookup |
| 5006 | * to this URI and query it to perform a lookup. For example: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5007 | * <pre> |
Scott Kennedy | 7ed189e | 2013-01-11 22:31:43 -0800 | [diff] [blame] | 5008 | * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, |
| 5009 | * Uri.encode(phoneNumber)); |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5010 | * </pre> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5011 | */ |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5012 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 5013 | "phone_lookup"); |
Dmitri Plotnikov | 0b0b8a8 | 2010-03-04 18:20:08 -0800 | [diff] [blame] | 5014 | |
| 5015 | /** |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5016 | * URI used for the "enterprise caller-id". |
| 5017 | * |
| 5018 | * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same |
| 5019 | * columns. If the device has no corp profile that is linked to the current profile, it |
| 5020 | * behaves in the exact same way as {@link #CONTENT_FILTER_URI}. If there is a corp profile |
| 5021 | * linked to the current profile, it first queries against the personal contact database, |
| 5022 | * and if no matching contacts are found there, then queries against the |
| 5023 | * corp contacts database. |
| 5024 | * <p> |
| 5025 | * If a result is from the corp profile, it makes the following changes to the data: |
| 5026 | * <ul> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5027 | * <li> |
| 5028 | * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special |
| 5029 | * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to |
| 5030 | * load pictures from them. |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 5031 | * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not use them. |
| 5032 | * </li> |
| 5033 | * <li> |
| 5034 | * Corp contacts will get artificial {@link #_ID}s. In order to tell whether a contact |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 5035 | * is from the corp profile, use |
| 5036 | * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}. |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5037 | * </li> |
| 5038 | * </ul> |
Makoto Onuki | 95a9cfb | 2014-07-08 17:11:54 -0700 | [diff] [blame] | 5039 | * <p> |
| 5040 | * This URI does NOT support selection nor order-by. |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5041 | * |
| 5042 | * <pre> |
| 5043 | * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, |
| 5044 | * Uri.encode(phoneNumber)); |
| 5045 | * </pre> |
| 5046 | */ |
| 5047 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 5048 | "phone_lookup_enterprise"); |
| 5049 | |
| 5050 | /** |
Dmitri Plotnikov | 0b0b8a8 | 2010-03-04 18:20:08 -0800 | [diff] [blame] | 5051 | * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows. |
| 5052 | * |
| 5053 | * @hide |
| 5054 | */ |
| 5055 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup"; |
Flavio Lerda | 52c01c2 | 2011-11-02 22:16:23 +0000 | [diff] [blame] | 5056 | |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 5057 | /** |
| 5058 | * If this boolean parameter is set to true, then the appended query is treated as a |
| 5059 | * SIP address and the lookup will be performed against SIP addresses in the user's |
| 5060 | * contacts. |
| 5061 | */ |
Flavio Lerda | 52c01c2 | 2011-11-02 22:16:23 +0000 | [diff] [blame] | 5062 | public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5063 | } |
| 5064 | |
| 5065 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5066 | * Additional data mixed in with {@link StatusColumns} to link |
| 5067 | * back to specific {@link ContactsContract.Data#_ID} entries. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5068 | * |
| 5069 | * @see StatusUpdates |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5070 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5071 | protected interface PresenceColumns { |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 5072 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5073 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5074 | * Reference to the {@link Data#_ID} entry that owns this presence. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5075 | * <P>Type: INTEGER</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5076 | */ |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5077 | public static final String DATA_ID = "presence_data_id"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5078 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5079 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5080 | * See {@link CommonDataKinds.Im} for a list of defined protocol constants. |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 5081 | * <p>Type: NUMBER</p> |
| 5082 | */ |
| 5083 | public static final String PROTOCOL = "protocol"; |
| 5084 | |
| 5085 | /** |
| 5086 | * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 5087 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 5088 | * omitted if {@link #PROTOCOL} value is not |
| 5089 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. |
| 5090 | * |
| 5091 | * <p>Type: NUMBER</p> |
| 5092 | */ |
| 5093 | public static final String CUSTOM_PROTOCOL = "custom_protocol"; |
| 5094 | |
| 5095 | /** |
| 5096 | * The IM handle the presence item is for. The handle is scoped to |
| 5097 | * {@link #PROTOCOL}. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5098 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5099 | */ |
| 5100 | public static final String IM_HANDLE = "im_handle"; |
| 5101 | |
| 5102 | /** |
| 5103 | * 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] | 5104 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5105 | */ |
| 5106 | public static final String IM_ACCOUNT = "im_account"; |
| 5107 | } |
| 5108 | |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5109 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5110 | * <p> |
| 5111 | * A status update is linked to a {@link ContactsContract.Data} row and captures |
| 5112 | * the user's latest status update via the corresponding source, e.g. |
| 5113 | * "Having lunch" via "Google Talk". |
| 5114 | * </p> |
| 5115 | * <p> |
| 5116 | * There are two ways a status update can be inserted: by explicitly linking |
| 5117 | * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row |
| 5118 | * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 5119 | * {@link #IM_HANDLE}. There is no difference between insert and update, you can use |
| 5120 | * either. |
| 5121 | * </p> |
| 5122 | * <p> |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 5123 | * Inserting or updating a status update for the user's profile requires either using |
| 5124 | * the {@link #DATA_ID} to identify the data row to attach the update to, or |
| 5125 | * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the |
| 5126 | * profile. |
| 5127 | * </p> |
| 5128 | * <p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5129 | * You cannot use {@link ContentResolver#update} to change a status, but |
| 5130 | * {@link ContentResolver#insert} will replace the latests status if it already |
| 5131 | * exists. |
| 5132 | * </p> |
| 5133 | * <p> |
| 5134 | * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses |
| 5135 | * for multiple contacts at once. |
| 5136 | * </p> |
| 5137 | * |
| 5138 | * <h3>Columns</h3> |
| 5139 | * <table class="jd-sumtable"> |
| 5140 | * <tr> |
| 5141 | * <th colspan='4'>StatusUpdates</th> |
| 5142 | * </tr> |
| 5143 | * <tr> |
| 5144 | * <td>long</td> |
| 5145 | * <td>{@link #DATA_ID}</td> |
| 5146 | * <td>read/write</td> |
| 5147 | * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this |
| 5148 | * field is <i>not</i> specified, the provider will attempt to find a data row |
| 5149 | * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 5150 | * {@link #IM_HANDLE} columns. |
| 5151 | * </td> |
| 5152 | * </tr> |
| 5153 | * <tr> |
| 5154 | * <td>long</td> |
| 5155 | * <td>{@link #PROTOCOL}</td> |
| 5156 | * <td>read/write</td> |
| 5157 | * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td> |
| 5158 | * </tr> |
| 5159 | * <tr> |
| 5160 | * <td>String</td> |
| 5161 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 5162 | * <td>read/write</td> |
| 5163 | * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 5164 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 5165 | * omitted if {@link #PROTOCOL} value is not |
| 5166 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td> |
| 5167 | * </tr> |
| 5168 | * <tr> |
| 5169 | * <td>String</td> |
| 5170 | * <td>{@link #IM_HANDLE}</td> |
| 5171 | * <td>read/write</td> |
| 5172 | * <td> The IM handle the presence item is for. The handle is scoped to |
| 5173 | * {@link #PROTOCOL}.</td> |
| 5174 | * </tr> |
| 5175 | * <tr> |
| 5176 | * <td>String</td> |
| 5177 | * <td>{@link #IM_ACCOUNT}</td> |
| 5178 | * <td>read/write</td> |
| 5179 | * <td>The IM account for the local user that the presence data came from.</td> |
| 5180 | * </tr> |
| 5181 | * <tr> |
| 5182 | * <td>int</td> |
| 5183 | * <td>{@link #PRESENCE}</td> |
| 5184 | * <td>read/write</td> |
| 5185 | * <td>Contact IM presence status. The allowed values are: |
| 5186 | * <p> |
| 5187 | * <ul> |
| 5188 | * <li>{@link #OFFLINE}</li> |
| 5189 | * <li>{@link #INVISIBLE}</li> |
| 5190 | * <li>{@link #AWAY}</li> |
| 5191 | * <li>{@link #IDLE}</li> |
| 5192 | * <li>{@link #DO_NOT_DISTURB}</li> |
| 5193 | * <li>{@link #AVAILABLE}</li> |
| 5194 | * </ul> |
| 5195 | * </p> |
| 5196 | * <p> |
| 5197 | * Since presence status is inherently volatile, the content provider |
| 5198 | * may choose not to store this field in long-term storage. |
| 5199 | * </p> |
| 5200 | * </td> |
| 5201 | * </tr> |
| 5202 | * <tr> |
Vasu Nori | 5b31498 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 5203 | * <td>int</td> |
| 5204 | * <td>{@link #CHAT_CAPABILITY}</td> |
| 5205 | * <td>read/write</td> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 5206 | * <td>Contact IM chat compatibility value. The allowed values combinations of the following |
| 5207 | * flags. If None of these flags is set, the device can only do text messaging. |
Vasu Nori | 5b31498 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 5208 | * <p> |
| 5209 | * <ul> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 5210 | * <li>{@link #CAPABILITY_HAS_VIDEO}</li> |
Vasu Nori | 5b31498 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 5211 | * <li>{@link #CAPABILITY_HAS_VOICE}</li> |
| 5212 | * <li>{@link #CAPABILITY_HAS_CAMERA}</li> |
| 5213 | * </ul> |
| 5214 | * </p> |
| 5215 | * <p> |
| 5216 | * Since chat compatibility is inherently volatile as the contact's availability moves from |
| 5217 | * one device to another, the content provider may choose not to store this field in long-term |
| 5218 | * storage. |
| 5219 | * </p> |
| 5220 | * </td> |
| 5221 | * </tr> |
| 5222 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5223 | * <td>String</td> |
| 5224 | * <td>{@link #STATUS}</td> |
| 5225 | * <td>read/write</td> |
| 5226 | * <td>Contact's latest status update, e.g. "having toast for breakfast"</td> |
| 5227 | * </tr> |
| 5228 | * <tr> |
| 5229 | * <td>long</td> |
| 5230 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 5231 | * <td>read/write</td> |
| 5232 | * <td>The absolute time in milliseconds when the status was |
| 5233 | * entered by the user. If this value is not provided, the provider will follow |
| 5234 | * this logic: if there was no prior status update, the value will be left as null. |
| 5235 | * If there was a prior status update, the provider will default this field |
| 5236 | * to the current time.</td> |
| 5237 | * </tr> |
| 5238 | * <tr> |
| 5239 | * <td>String</td> |
| 5240 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 5241 | * <td>read/write</td> |
| 5242 | * <td> The package containing resources for this status: label and icon.</td> |
| 5243 | * </tr> |
| 5244 | * <tr> |
| 5245 | * <td>long</td> |
| 5246 | * <td>{@link #STATUS_LABEL}</td> |
| 5247 | * <td>read/write</td> |
| 5248 | * <td>The resource ID of the label describing the source of contact status, |
| 5249 | * e.g. "Google Talk". This resource is scoped by the |
| 5250 | * {@link #STATUS_RES_PACKAGE}.</td> |
| 5251 | * </tr> |
| 5252 | * <tr> |
| 5253 | * <td>long</td> |
| 5254 | * <td>{@link #STATUS_ICON}</td> |
| 5255 | * <td>read/write</td> |
| 5256 | * <td>The resource ID of the icon for the source of contact status. This |
| 5257 | * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 5258 | * </tr> |
| 5259 | * </table> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5260 | */ |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5261 | public static class StatusUpdates implements StatusColumns, PresenceColumns { |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 5262 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5263 | /** |
| 5264 | * This utility class cannot be instantiated |
| 5265 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5266 | private StatusUpdates() {} |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5267 | |
| 5268 | /** |
| 5269 | * The content:// style URI for this table |
| 5270 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5271 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates"); |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5272 | |
| 5273 | /** |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 5274 | * The content:// style URI for this table, specific to the user's profile. |
| 5275 | */ |
| 5276 | public static final Uri PROFILE_CONTENT_URI = |
| 5277 | Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates"); |
| 5278 | |
| 5279 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5280 | * Gets the resource ID for the proper presence icon. |
| 5281 | * |
| 5282 | * @param status the status to get the icon for |
| 5283 | * @return the resource ID for the proper presence icon |
| 5284 | */ |
| 5285 | public static final int getPresenceIconResourceId(int status) { |
| 5286 | switch (status) { |
| 5287 | case AVAILABLE: |
| 5288 | return android.R.drawable.presence_online; |
| 5289 | case IDLE: |
| 5290 | case AWAY: |
| 5291 | return android.R.drawable.presence_away; |
| 5292 | case DO_NOT_DISTURB: |
| 5293 | return android.R.drawable.presence_busy; |
| 5294 | case INVISIBLE: |
| 5295 | return android.R.drawable.presence_invisible; |
| 5296 | case OFFLINE: |
| 5297 | default: |
| 5298 | return android.R.drawable.presence_offline; |
| 5299 | } |
| 5300 | } |
| 5301 | |
| 5302 | /** |
Evan Millar | c043752 | 2009-06-23 17:31:05 -0700 | [diff] [blame] | 5303 | * Returns the precedence of the status code the higher number being the higher precedence. |
| 5304 | * |
| 5305 | * @param status The status code. |
| 5306 | * @return An integer representing the precedence, 0 being the lowest. |
| 5307 | */ |
| 5308 | public static final int getPresencePrecedence(int status) { |
| 5309 | // Keep this function here incase we want to enforce a different precedence than the |
| 5310 | // natural order of the status constants. |
| 5311 | return status; |
| 5312 | } |
| 5313 | |
| 5314 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5315 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5316 | * status update details. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5317 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5318 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5319 | |
| 5320 | /** |
| 5321 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5322 | * status update detail. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5323 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5324 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update"; |
| 5325 | } |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 5326 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5327 | /** |
| 5328 | * @deprecated This old name was never meant to be made public. Do not use. |
| 5329 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5330 | @Deprecated |
| 5331 | public static final class Presence extends StatusUpdates { |
| 5332 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5333 | } |
| 5334 | |
| 5335 | /** |
Yorke Lee | 8d37009 | 2014-06-26 10:32:17 -0700 | [diff] [blame] | 5336 | * Additional column returned by |
| 5337 | * {@link ContactsContract.Contacts#CONTENT_FILTER_URI Contacts.CONTENT_FILTER_URI} explaining |
Yorke Lee | eaf0949 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5338 | * why the filter matched the contact. This column will contain extracts from the contact's |
| 5339 | * constituent {@link Data Data} items, formatted in a way that indicates the section of the |
| 5340 | * snippet that matched the filter. |
| 5341 | * |
| 5342 | * <p> |
| 5343 | * The following example searches for all contacts that match the query "presi" and requests |
| 5344 | * the snippet column as well. |
| 5345 | * <pre> |
| 5346 | * Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon(); |
| 5347 | * builder.appendPath("presi"); |
| 5348 | * // Defer snippeting to the client side if possible, for performance reasons. |
| 5349 | * builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1"); |
| 5350 | * |
| 5351 | * Cursor cursor = getContentResolver().query(builder.build()); |
| 5352 | * |
| 5353 | * Bundle extras = cursor.getExtras(); |
| 5354 | * if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) { |
| 5355 | * // Do our own snippet formatting. |
| 5356 | * // For a contact with the email address (president@organization.com), the snippet |
| 5357 | * // column will contain the string "president@organization.com". |
| 5358 | * } else { |
| 5359 | * // The snippet has already been pre-formatted, we can display it as is. |
| 5360 | * // For a contact with the email address (president@organization.com), the snippet |
| 5361 | * // column will contain the string "[presi]dent@organization.com". |
| 5362 | * } |
| 5363 | * </pre> |
| 5364 | * </p> |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5365 | */ |
Yorke Lee | eaf0949 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5366 | public static class SearchSnippets { |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5367 | |
| 5368 | /** |
Yorke Lee | eaf0949 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5369 | * The search snippet constructed by SQLite snippeting functionality. |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5370 | * <p> |
Yorke Lee | eaf0949 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5371 | * The snippet may contain (parts of) several data elements belonging to the contact, |
| 5372 | * with the matching parts optionally surrounded by special characters that indicate the |
| 5373 | * start and end of matching text. |
| 5374 | * |
| 5375 | * For example, if a contact has an address "123 Main Street", using a filter "mai" would |
| 5376 | * return the formatted snippet "123 [Mai]n street". |
| 5377 | * |
| 5378 | * @see <a href="http://www.sqlite.org/fts3.html#snippet"> |
| 5379 | * http://www.sqlite.org/fts3.html#snippet</a> |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5380 | */ |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5381 | public static final String SNIPPET = "snippet"; |
| 5382 | |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5383 | /** |
| 5384 | * Comma-separated parameters for the generation of the snippet: |
| 5385 | * <ul> |
Yorke Lee | eaf0949 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5386 | * <li>The "start match" text. Default is '['</li> |
| 5387 | * <li>The "end match" text. Default is ']'</li> |
| 5388 | * <li>The "ellipsis" text. Default is "..."</li> |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5389 | * <li>Maximum number of tokens to include in the snippet. Can be either |
| 5390 | * a positive or a negative number: A positive number indicates how many |
| 5391 | * tokens can be returned in total. A negative number indicates how many |
| 5392 | * tokens can be returned per occurrence of the search terms.</li> |
| 5393 | * </ul> |
Yorke Lee | eaf0949 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5394 | * |
| 5395 | * @hide |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5396 | */ |
| 5397 | public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args"; |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5398 | |
| 5399 | /** |
Yorke Lee | eaf0949 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5400 | * The key to ask the provider to defer the formatting of the snippet to the client if |
| 5401 | * possible, for performance reasons. |
| 5402 | * A value of 1 indicates true, 0 indicates false. False is the default. |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5403 | * When a cursor is returned to the client, it should check for an extra with the name |
| 5404 | * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client |
Yorke Lee | eaf0949 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5405 | * should do its own formatting of the snippet. If it doesn't exist, the snippet column |
| 5406 | * in the cursor should already contain a formatted snippet. |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5407 | */ |
| 5408 | public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting"; |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5409 | } |
| 5410 | |
| 5411 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5412 | * Container for definitions of common data types stored in the {@link ContactsContract.Data} |
| 5413 | * table. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5414 | */ |
| 5415 | public static final class CommonDataKinds { |
| 5416 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5417 | * This utility class cannot be instantiated |
| 5418 | */ |
| 5419 | private CommonDataKinds() {} |
| 5420 | |
| 5421 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5422 | * The {@link Data#RES_PACKAGE} value for common data that should be |
| 5423 | * shown using a default style. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5424 | * |
| 5425 | * @hide RES_PACKAGE is hidden |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5426 | */ |
| 5427 | public static final String PACKAGE_COMMON = "common"; |
| 5428 | |
| 5429 | /** |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5430 | * The base types that all "Typed" data kinds support. |
| 5431 | */ |
| 5432 | public interface BaseTypes { |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5433 | /** |
| 5434 | * A custom type. The custom label should be supplied by user. |
| 5435 | */ |
| 5436 | public static int TYPE_CUSTOM = 0; |
| 5437 | } |
| 5438 | |
| 5439 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5440 | * Columns common across the specific types. |
| 5441 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5442 | protected interface CommonColumns extends BaseTypes { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5443 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5444 | * The data for the contact method. |
| 5445 | * <P>Type: TEXT</P> |
| 5446 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5447 | public static final String DATA = DataColumns.DATA1; |
| 5448 | |
| 5449 | /** |
| 5450 | * The type of data, for example Home or Work. |
| 5451 | * <P>Type: INTEGER</P> |
| 5452 | */ |
| 5453 | public static final String TYPE = DataColumns.DATA2; |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 5454 | |
| 5455 | /** |
| 5456 | * The user defined label for the the contact method. |
| 5457 | * <P>Type: TEXT</P> |
| 5458 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5459 | public static final String LABEL = DataColumns.DATA3; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5460 | } |
| 5461 | |
| 5462 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5463 | * A data kind representing the contact's proper name. You can use all |
| 5464 | * columns defined for {@link ContactsContract.Data} as well as the following aliases. |
| 5465 | * |
| 5466 | * <h2>Column aliases</h2> |
| 5467 | * <table class="jd-sumtable"> |
| 5468 | * <tr> |
| 5469 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 5470 | * </tr> |
| 5471 | * <tr> |
| 5472 | * <td>String</td> |
| 5473 | * <td>{@link #DISPLAY_NAME}</td> |
| 5474 | * <td>{@link #DATA1}</td> |
| 5475 | * <td></td> |
| 5476 | * </tr> |
| 5477 | * <tr> |
| 5478 | * <td>String</td> |
| 5479 | * <td>{@link #GIVEN_NAME}</td> |
| 5480 | * <td>{@link #DATA2}</td> |
| 5481 | * <td></td> |
| 5482 | * </tr> |
| 5483 | * <tr> |
| 5484 | * <td>String</td> |
| 5485 | * <td>{@link #FAMILY_NAME}</td> |
| 5486 | * <td>{@link #DATA3}</td> |
| 5487 | * <td></td> |
| 5488 | * </tr> |
| 5489 | * <tr> |
| 5490 | * <td>String</td> |
| 5491 | * <td>{@link #PREFIX}</td> |
| 5492 | * <td>{@link #DATA4}</td> |
| 5493 | * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td> |
| 5494 | * </tr> |
| 5495 | * <tr> |
| 5496 | * <td>String</td> |
| 5497 | * <td>{@link #MIDDLE_NAME}</td> |
| 5498 | * <td>{@link #DATA5}</td> |
| 5499 | * <td></td> |
| 5500 | * </tr> |
| 5501 | * <tr> |
| 5502 | * <td>String</td> |
| 5503 | * <td>{@link #SUFFIX}</td> |
| 5504 | * <td>{@link #DATA6}</td> |
| 5505 | * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td> |
| 5506 | * </tr> |
| 5507 | * <tr> |
| 5508 | * <td>String</td> |
| 5509 | * <td>{@link #PHONETIC_GIVEN_NAME}</td> |
| 5510 | * <td>{@link #DATA7}</td> |
| 5511 | * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td> |
| 5512 | * </tr> |
| 5513 | * <tr> |
| 5514 | * <td>String</td> |
| 5515 | * <td>{@link #PHONETIC_MIDDLE_NAME}</td> |
| 5516 | * <td>{@link #DATA8}</td> |
| 5517 | * <td></td> |
| 5518 | * </tr> |
| 5519 | * <tr> |
| 5520 | * <td>String</td> |
| 5521 | * <td>{@link #PHONETIC_FAMILY_NAME}</td> |
| 5522 | * <td>{@link #DATA9}</td> |
| 5523 | * <td></td> |
| 5524 | * </tr> |
| 5525 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5526 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 5527 | public static final class StructuredName implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5528 | /** |
| 5529 | * This utility class cannot be instantiated |
| 5530 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5531 | private StructuredName() {} |
| 5532 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5533 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5534 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; |
| 5535 | |
| 5536 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5537 | * The name that should be used to display the contact. |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 5538 | * <i>Unstructured component of the name should be consistent with |
| 5539 | * its structured representation.</i> |
| 5540 | * <p> |
| 5541 | * Type: TEXT |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5542 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5543 | public static final String DISPLAY_NAME = DATA1; |
| 5544 | |
| 5545 | /** |
| 5546 | * The given name for the contact. |
| 5547 | * <P>Type: TEXT</P> |
| 5548 | */ |
| 5549 | public static final String GIVEN_NAME = DATA2; |
| 5550 | |
| 5551 | /** |
| 5552 | * The family name for the contact. |
| 5553 | * <P>Type: TEXT</P> |
| 5554 | */ |
| 5555 | public static final String FAMILY_NAME = DATA3; |
| 5556 | |
| 5557 | /** |
| 5558 | * The contact's honorific prefix, e.g. "Sir" |
| 5559 | * <P>Type: TEXT</P> |
| 5560 | */ |
| 5561 | public static final String PREFIX = DATA4; |
| 5562 | |
| 5563 | /** |
| 5564 | * The contact's middle name |
| 5565 | * <P>Type: TEXT</P> |
| 5566 | */ |
| 5567 | public static final String MIDDLE_NAME = DATA5; |
| 5568 | |
| 5569 | /** |
| 5570 | * The contact's honorific suffix, e.g. "Jr" |
| 5571 | */ |
| 5572 | public static final String SUFFIX = DATA6; |
| 5573 | |
| 5574 | /** |
| 5575 | * The phonetic version of the given name for the contact. |
| 5576 | * <P>Type: TEXT</P> |
| 5577 | */ |
| 5578 | public static final String PHONETIC_GIVEN_NAME = DATA7; |
| 5579 | |
| 5580 | /** |
| 5581 | * The phonetic version of the additional name for the contact. |
| 5582 | * <P>Type: TEXT</P> |
| 5583 | */ |
| 5584 | public static final String PHONETIC_MIDDLE_NAME = DATA8; |
| 5585 | |
| 5586 | /** |
| 5587 | * The phonetic version of the family name for the contact. |
| 5588 | * <P>Type: TEXT</P> |
| 5589 | */ |
| 5590 | public static final String PHONETIC_FAMILY_NAME = DATA9; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5591 | |
| 5592 | /** |
| 5593 | * The style used for combining given/middle/family name into a full name. |
| 5594 | * See {@link ContactsContract.FullNameStyle}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5595 | */ |
| 5596 | public static final String FULL_NAME_STYLE = DATA10; |
| 5597 | |
| 5598 | /** |
| 5599 | * The alphabet used for capturing the phonetic name. |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 5600 | * See ContactsContract.PhoneticNameStyle. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5601 | * @hide |
| 5602 | */ |
| 5603 | public static final String PHONETIC_NAME_STYLE = DATA11; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5604 | } |
| 5605 | |
| 5606 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5607 | * <p>A data kind representing the contact's nickname. For example, for |
| 5608 | * Bob Parr ("Mr. Incredible"): |
| 5609 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 5610 | * ArrayList<ContentProviderOperation> ops = |
| 5611 | * new ArrayList<ContentProviderOperation>(); |
| 5612 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5613 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 5614 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 5615 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 5616 | * .withValue(StructuredName.DISPLAY_NAME, "Bob Parr") |
| 5617 | * .build()); |
| 5618 | * |
| 5619 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 5620 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 5621 | * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE) |
| 5622 | * .withValue(Nickname.NAME, "Mr. Incredible") |
| 5623 | * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM) |
| 5624 | * .withValue(Nickname.LABEL, "Superhero") |
| 5625 | * .build()); |
| 5626 | * |
| 5627 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 5628 | * </pre> |
| 5629 | * </p> |
| 5630 | * <p> |
| 5631 | * You can use all columns defined for {@link ContactsContract.Data} as well as the |
| 5632 | * following aliases. |
| 5633 | * </p> |
| 5634 | * |
| 5635 | * <h2>Column aliases</h2> |
| 5636 | * <table class="jd-sumtable"> |
| 5637 | * <tr> |
| 5638 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 5639 | * </tr> |
| 5640 | * <tr> |
| 5641 | * <td>String</td> |
| 5642 | * <td>{@link #NAME}</td> |
| 5643 | * <td>{@link #DATA1}</td> |
| 5644 | * <td></td> |
| 5645 | * </tr> |
| 5646 | * <tr> |
| 5647 | * <td>int</td> |
| 5648 | * <td>{@link #TYPE}</td> |
| 5649 | * <td>{@link #DATA2}</td> |
| 5650 | * <td> |
| 5651 | * Allowed values are: |
| 5652 | * <p> |
| 5653 | * <ul> |
| 5654 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5655 | * <li>{@link #TYPE_DEFAULT}</li> |
| 5656 | * <li>{@link #TYPE_OTHER_NAME}</li> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5657 | * <li>{@link #TYPE_MAIDEN_NAME}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5658 | * <li>{@link #TYPE_SHORT_NAME}</li> |
| 5659 | * <li>{@link #TYPE_INITIALS}</li> |
| 5660 | * </ul> |
| 5661 | * </p> |
| 5662 | * </td> |
| 5663 | * </tr> |
| 5664 | * <tr> |
| 5665 | * <td>String</td> |
| 5666 | * <td>{@link #LABEL}</td> |
| 5667 | * <td>{@link #DATA3}</td> |
| 5668 | * <td></td> |
| 5669 | * </tr> |
| 5670 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5671 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 5672 | public static final class Nickname implements DataColumnsWithJoins, CommonColumns, |
| 5673 | ContactCounts{ |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5674 | /** |
| 5675 | * This utility class cannot be instantiated |
| 5676 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5677 | private Nickname() {} |
| 5678 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5679 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5680 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; |
| 5681 | |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 5682 | public static final int TYPE_DEFAULT = 1; |
| 5683 | public static final int TYPE_OTHER_NAME = 2; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5684 | public static final int TYPE_MAIDEN_NAME = 3; |
| 5685 | /** @deprecated Use TYPE_MAIDEN_NAME instead. */ |
| 5686 | @Deprecated |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 5687 | public static final int TYPE_MAINDEN_NAME = 3; |
| 5688 | public static final int TYPE_SHORT_NAME = 4; |
| 5689 | public static final int TYPE_INITIALS = 5; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5690 | |
| 5691 | /** |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 5692 | * The name itself |
| 5693 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5694 | public static final String NAME = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5695 | } |
| 5696 | |
| 5697 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5698 | * <p> |
| 5699 | * A data kind representing a telephone number. |
| 5700 | * </p> |
| 5701 | * <p> |
| 5702 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5703 | * well as the following aliases. |
| 5704 | * </p> |
| 5705 | * <h2>Column aliases</h2> |
| 5706 | * <table class="jd-sumtable"> |
| 5707 | * <tr> |
| 5708 | * <th>Type</th> |
| 5709 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5710 | * </tr> |
| 5711 | * <tr> |
| 5712 | * <td>String</td> |
| 5713 | * <td>{@link #NUMBER}</td> |
| 5714 | * <td>{@link #DATA1}</td> |
| 5715 | * <td></td> |
| 5716 | * </tr> |
| 5717 | * <tr> |
| 5718 | * <td>int</td> |
| 5719 | * <td>{@link #TYPE}</td> |
| 5720 | * <td>{@link #DATA2}</td> |
| 5721 | * <td>Allowed values are: |
| 5722 | * <p> |
| 5723 | * <ul> |
| 5724 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5725 | * <li>{@link #TYPE_HOME}</li> |
| 5726 | * <li>{@link #TYPE_MOBILE}</li> |
| 5727 | * <li>{@link #TYPE_WORK}</li> |
| 5728 | * <li>{@link #TYPE_FAX_WORK}</li> |
| 5729 | * <li>{@link #TYPE_FAX_HOME}</li> |
| 5730 | * <li>{@link #TYPE_PAGER}</li> |
| 5731 | * <li>{@link #TYPE_OTHER}</li> |
| 5732 | * <li>{@link #TYPE_CALLBACK}</li> |
| 5733 | * <li>{@link #TYPE_CAR}</li> |
| 5734 | * <li>{@link #TYPE_COMPANY_MAIN}</li> |
| 5735 | * <li>{@link #TYPE_ISDN}</li> |
| 5736 | * <li>{@link #TYPE_MAIN}</li> |
| 5737 | * <li>{@link #TYPE_OTHER_FAX}</li> |
| 5738 | * <li>{@link #TYPE_RADIO}</li> |
| 5739 | * <li>{@link #TYPE_TELEX}</li> |
| 5740 | * <li>{@link #TYPE_TTY_TDD}</li> |
| 5741 | * <li>{@link #TYPE_WORK_MOBILE}</li> |
| 5742 | * <li>{@link #TYPE_WORK_PAGER}</li> |
| 5743 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 5744 | * <li>{@link #TYPE_MMS}</li> |
| 5745 | * </ul> |
| 5746 | * </p> |
| 5747 | * </td> |
| 5748 | * </tr> |
| 5749 | * <tr> |
| 5750 | * <td>String</td> |
| 5751 | * <td>{@link #LABEL}</td> |
| 5752 | * <td>{@link #DATA3}</td> |
| 5753 | * <td></td> |
| 5754 | * </tr> |
| 5755 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5756 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 5757 | public static final class Phone implements DataColumnsWithJoins, CommonColumns, |
| 5758 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5759 | /** |
| 5760 | * This utility class cannot be instantiated |
| 5761 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5762 | private Phone() {} |
| 5763 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5764 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5765 | 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] | 5766 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5767 | /** |
| 5768 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 5769 | * phones. |
| 5770 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5771 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2"; |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5772 | |
| 5773 | /** |
| 5774 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5775 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 5776 | * associated raw contact and aggregate contact data. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5777 | */ |
| 5778 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 5779 | "phones"); |
| 5780 | |
| 5781 | /** |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5782 | * 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] | 5783 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5784 | * to display names as well as phone numbers. The filter argument should be passed |
| 5785 | * as an additional path segment after this URI. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 5786 | */ |
| 5787 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 5788 | "filter"); |
| 5789 | |
Daniel Lehmann | 1024de5 | 2012-06-15 20:32:33 -0700 | [diff] [blame] | 5790 | /** |
| 5791 | * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. |
| 5792 | * If "1" or "true", display names are searched. If "0" or "false", display names |
| 5793 | * are not searched. Default is "1". |
| 5794 | */ |
| 5795 | public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name"; |
| 5796 | |
| 5797 | /** |
| 5798 | * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. |
| 5799 | * If "1" or "true", phone numbers are searched. If "0" or "false", phone numbers |
| 5800 | * are not searched. Default is "1". |
| 5801 | */ |
| 5802 | public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number"; |
| 5803 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5804 | public static final int TYPE_HOME = 1; |
| 5805 | public static final int TYPE_MOBILE = 2; |
| 5806 | public static final int TYPE_WORK = 3; |
| 5807 | public static final int TYPE_FAX_WORK = 4; |
| 5808 | public static final int TYPE_FAX_HOME = 5; |
| 5809 | public static final int TYPE_PAGER = 6; |
| 5810 | public static final int TYPE_OTHER = 7; |
Fred Quintana | 3f86715 | 2009-08-03 11:43:16 -0700 | [diff] [blame] | 5811 | public static final int TYPE_CALLBACK = 8; |
| 5812 | public static final int TYPE_CAR = 9; |
| 5813 | public static final int TYPE_COMPANY_MAIN = 10; |
| 5814 | public static final int TYPE_ISDN = 11; |
| 5815 | public static final int TYPE_MAIN = 12; |
| 5816 | public static final int TYPE_OTHER_FAX = 13; |
| 5817 | public static final int TYPE_RADIO = 14; |
| 5818 | public static final int TYPE_TELEX = 15; |
| 5819 | public static final int TYPE_TTY_TDD = 16; |
| 5820 | public static final int TYPE_WORK_MOBILE = 17; |
| 5821 | public static final int TYPE_WORK_PAGER = 18; |
| 5822 | public static final int TYPE_ASSISTANT = 19; |
Jeff Sharkey | d5abd46 | 2009-09-16 19:54:29 -0700 | [diff] [blame] | 5823 | public static final int TYPE_MMS = 20; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5824 | |
| 5825 | /** |
| 5826 | * The phone number as the user entered it. |
| 5827 | * <P>Type: TEXT</P> |
| 5828 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5829 | public static final String NUMBER = DATA; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5830 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5831 | /** |
Daniel Lehmann | db91915 | 2012-03-09 14:30:50 -0800 | [diff] [blame] | 5832 | * The phone number's E164 representation. This value can be omitted in which |
Makoto Onuki | e5420e9 | 2012-04-25 13:24:41 -0700 | [diff] [blame] | 5833 | * case the provider will try to automatically infer it. (It'll be left null if the |
| 5834 | * provider fails to infer.) |
| 5835 | * If present, {@link #NUMBER} has to be set as well (it will be ignored otherwise). |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 5836 | * <P>Type: TEXT</P> |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 5837 | */ |
| 5838 | public static final String NORMALIZED_NUMBER = DATA4; |
| 5839 | |
| 5840 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5841 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5842 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5843 | */ |
| 5844 | @Deprecated |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5845 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 5846 | CharSequence label, CharSequence[] labelArray) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5847 | return getTypeLabel(context.getResources(), type, label); |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5848 | } |
| 5849 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5850 | /** |
| 5851 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5852 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5853 | */ |
| 5854 | @Deprecated |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5855 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 5856 | CharSequence label) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5857 | return getTypeLabel(context.getResources(), type, label); |
| 5858 | } |
| 5859 | |
| 5860 | /** |
| 5861 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5862 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5863 | */ |
| 5864 | public static final int getTypeLabelResource(int type) { |
| 5865 | switch (type) { |
| 5866 | case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome; |
| 5867 | case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile; |
| 5868 | case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork; |
| 5869 | case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork; |
| 5870 | case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome; |
| 5871 | case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager; |
| 5872 | case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther; |
| 5873 | case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback; |
| 5874 | case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar; |
| 5875 | case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain; |
| 5876 | case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn; |
| 5877 | case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain; |
| 5878 | case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax; |
| 5879 | case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio; |
| 5880 | case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex; |
| 5881 | case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd; |
| 5882 | case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile; |
| 5883 | case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager; |
| 5884 | case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant; |
| 5885 | case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms; |
| 5886 | default: return com.android.internal.R.string.phoneTypeCustom; |
| 5887 | } |
| 5888 | } |
| 5889 | |
| 5890 | /** |
| 5891 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5892 | * possibly substituting the given {@link #LABEL} value |
| 5893 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 5894 | */ |
| 5895 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 5896 | CharSequence label) { |
| 5897 | if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) { |
| 5898 | return label; |
| 5899 | } else { |
| 5900 | final int labelRes = getTypeLabelResource(type); |
| 5901 | return res.getText(labelRes); |
| 5902 | } |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5903 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5904 | } |
| 5905 | |
| 5906 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5907 | * <p> |
| 5908 | * A data kind representing an email address. |
| 5909 | * </p> |
| 5910 | * <p> |
| 5911 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5912 | * well as the following aliases. |
| 5913 | * </p> |
| 5914 | * <h2>Column aliases</h2> |
| 5915 | * <table class="jd-sumtable"> |
| 5916 | * <tr> |
| 5917 | * <th>Type</th> |
| 5918 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5919 | * </tr> |
| 5920 | * <tr> |
| 5921 | * <td>String</td> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 5922 | * <td>{@link #ADDRESS}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5923 | * <td>{@link #DATA1}</td> |
| 5924 | * <td>Email address itself.</td> |
| 5925 | * </tr> |
| 5926 | * <tr> |
| 5927 | * <td>int</td> |
| 5928 | * <td>{@link #TYPE}</td> |
| 5929 | * <td>{@link #DATA2}</td> |
| 5930 | * <td>Allowed values are: |
| 5931 | * <p> |
| 5932 | * <ul> |
| 5933 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5934 | * <li>{@link #TYPE_HOME}</li> |
| 5935 | * <li>{@link #TYPE_WORK}</li> |
| 5936 | * <li>{@link #TYPE_OTHER}</li> |
| 5937 | * <li>{@link #TYPE_MOBILE}</li> |
| 5938 | * </ul> |
| 5939 | * </p> |
| 5940 | * </td> |
| 5941 | * </tr> |
| 5942 | * <tr> |
| 5943 | * <td>String</td> |
| 5944 | * <td>{@link #LABEL}</td> |
| 5945 | * <td>{@link #DATA3}</td> |
| 5946 | * <td></td> |
| 5947 | * </tr> |
| 5948 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5949 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 5950 | public static final class Email implements DataColumnsWithJoins, CommonColumns, |
| 5951 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5952 | /** |
| 5953 | * This utility class cannot be instantiated |
| 5954 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5955 | private Email() {} |
| 5956 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5957 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 5958 | 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] | 5959 | |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5960 | /** |
Dmitri Plotnikov | abf15c3 | 2009-09-18 20:29:11 -0700 | [diff] [blame] | 5961 | * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses. |
| 5962 | */ |
| 5963 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2"; |
| 5964 | |
| 5965 | /** |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5966 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 5967 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5968 | * associated raw contact and aggregate contact data. |
| 5969 | */ |
| 5970 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 5971 | "emails"); |
| 5972 | |
| 5973 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5974 | * <p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5975 | * The content:// style URL for looking up data rows by email address. The |
| 5976 | * lookup argument, an email address, should be passed as an additional path segment |
| 5977 | * after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5978 | * </p> |
| 5979 | * <p>Example: |
| 5980 | * <pre> |
| 5981 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email)); |
| 5982 | * Cursor c = getContentResolver().query(uri, |
| 5983 | * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA}, |
| 5984 | * null, null, null); |
| 5985 | * </pre> |
| 5986 | * </p> |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5987 | */ |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5988 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 5989 | "lookup"); |
| 5990 | |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5991 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5992 | * <p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5993 | * 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] | 5994 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 5995 | * to display names as well as email addresses. The filter argument should be passed |
| 5996 | * as an additional path segment after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5997 | * </p> |
| 5998 | * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)" |
| 5999 | * as well as "Bob Parr (incredible@android.com)". |
| 6000 | * <pre> |
| 6001 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob")); |
| 6002 | * Cursor c = getContentResolver().query(uri, |
| 6003 | * new String[]{Email.DISPLAY_NAME, Email.DATA}, |
| 6004 | * null, null, null); |
| 6005 | * </pre> |
| 6006 | * </p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6007 | */ |
| 6008 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6009 | "filter"); |
| 6010 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6011 | /** |
| 6012 | * The email address. |
| 6013 | * <P>Type: TEXT</P> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6014 | */ |
| 6015 | public static final String ADDRESS = DATA1; |
| 6016 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6017 | public static final int TYPE_HOME = 1; |
| 6018 | public static final int TYPE_WORK = 2; |
| 6019 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 14fb153 | 2009-08-29 15:54:26 -0700 | [diff] [blame] | 6020 | public static final int TYPE_MOBILE = 4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6021 | |
| 6022 | /** |
| 6023 | * The display name for the email address |
| 6024 | * <P>Type: TEXT</P> |
| 6025 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6026 | public static final String DISPLAY_NAME = DATA4; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6027 | |
| 6028 | /** |
| 6029 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6030 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6031 | */ |
| 6032 | public static final int getTypeLabelResource(int type) { |
| 6033 | switch (type) { |
| 6034 | case TYPE_HOME: return com.android.internal.R.string.emailTypeHome; |
| 6035 | case TYPE_WORK: return com.android.internal.R.string.emailTypeWork; |
| 6036 | case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther; |
| 6037 | case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile; |
| 6038 | default: return com.android.internal.R.string.emailTypeCustom; |
| 6039 | } |
| 6040 | } |
| 6041 | |
| 6042 | /** |
| 6043 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6044 | * possibly substituting the given {@link #LABEL} value |
| 6045 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6046 | */ |
| 6047 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6048 | CharSequence label) { |
| 6049 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6050 | return label; |
| 6051 | } else { |
| 6052 | final int labelRes = getTypeLabelResource(type); |
| 6053 | return res.getText(labelRes); |
| 6054 | } |
| 6055 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6056 | } |
| 6057 | |
| 6058 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6059 | * <p> |
| 6060 | * A data kind representing a postal addresses. |
| 6061 | * </p> |
| 6062 | * <p> |
| 6063 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6064 | * well as the following aliases. |
| 6065 | * </p> |
| 6066 | * <h2>Column aliases</h2> |
| 6067 | * <table class="jd-sumtable"> |
| 6068 | * <tr> |
| 6069 | * <th>Type</th> |
| 6070 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6071 | * </tr> |
| 6072 | * <tr> |
| 6073 | * <td>String</td> |
| 6074 | * <td>{@link #FORMATTED_ADDRESS}</td> |
| 6075 | * <td>{@link #DATA1}</td> |
| 6076 | * <td></td> |
| 6077 | * </tr> |
| 6078 | * <tr> |
| 6079 | * <td>int</td> |
| 6080 | * <td>{@link #TYPE}</td> |
| 6081 | * <td>{@link #DATA2}</td> |
| 6082 | * <td>Allowed values are: |
| 6083 | * <p> |
| 6084 | * <ul> |
| 6085 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6086 | * <li>{@link #TYPE_HOME}</li> |
| 6087 | * <li>{@link #TYPE_WORK}</li> |
| 6088 | * <li>{@link #TYPE_OTHER}</li> |
| 6089 | * </ul> |
| 6090 | * </p> |
| 6091 | * </td> |
| 6092 | * </tr> |
| 6093 | * <tr> |
| 6094 | * <td>String</td> |
| 6095 | * <td>{@link #LABEL}</td> |
| 6096 | * <td>{@link #DATA3}</td> |
| 6097 | * <td></td> |
| 6098 | * </tr> |
| 6099 | * <tr> |
| 6100 | * <td>String</td> |
| 6101 | * <td>{@link #STREET}</td> |
| 6102 | * <td>{@link #DATA4}</td> |
| 6103 | * <td></td> |
| 6104 | * </tr> |
| 6105 | * <tr> |
| 6106 | * <td>String</td> |
| 6107 | * <td>{@link #POBOX}</td> |
| 6108 | * <td>{@link #DATA5}</td> |
| 6109 | * <td>Post Office Box number</td> |
| 6110 | * </tr> |
| 6111 | * <tr> |
| 6112 | * <td>String</td> |
| 6113 | * <td>{@link #NEIGHBORHOOD}</td> |
| 6114 | * <td>{@link #DATA6}</td> |
| 6115 | * <td></td> |
| 6116 | * </tr> |
| 6117 | * <tr> |
| 6118 | * <td>String</td> |
| 6119 | * <td>{@link #CITY}</td> |
| 6120 | * <td>{@link #DATA7}</td> |
| 6121 | * <td></td> |
| 6122 | * </tr> |
| 6123 | * <tr> |
| 6124 | * <td>String</td> |
| 6125 | * <td>{@link #REGION}</td> |
| 6126 | * <td>{@link #DATA8}</td> |
| 6127 | * <td></td> |
| 6128 | * </tr> |
| 6129 | * <tr> |
| 6130 | * <td>String</td> |
| 6131 | * <td>{@link #POSTCODE}</td> |
| 6132 | * <td>{@link #DATA9}</td> |
| 6133 | * <td></td> |
| 6134 | * </tr> |
| 6135 | * <tr> |
| 6136 | * <td>String</td> |
| 6137 | * <td>{@link #COUNTRY}</td> |
| 6138 | * <td>{@link #DATA10}</td> |
| 6139 | * <td></td> |
| 6140 | * </tr> |
| 6141 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6142 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6143 | public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns, |
| 6144 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6145 | /** |
| 6146 | * This utility class cannot be instantiated |
| 6147 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6148 | private StructuredPostal() { |
| 6149 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6150 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6151 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6152 | public static final String CONTENT_ITEM_TYPE = |
| 6153 | "vnd.android.cursor.item/postal-address_v2"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6154 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6155 | /** |
| 6156 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 6157 | * postal addresses. |
| 6158 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6159 | 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] | 6160 | |
| 6161 | /** |
| 6162 | * The content:// style URI for all data records of the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6163 | * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6164 | */ |
| 6165 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6166 | "postals"); |
| 6167 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6168 | public static final int TYPE_HOME = 1; |
| 6169 | public static final int TYPE_WORK = 2; |
| 6170 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6171 | |
| 6172 | /** |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 6173 | * The full, unstructured postal address. <i>This field must be |
| 6174 | * consistent with any structured data.</i> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6175 | * <p> |
| 6176 | * Type: TEXT |
| 6177 | */ |
| 6178 | public static final String FORMATTED_ADDRESS = DATA; |
| 6179 | |
| 6180 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6181 | * Can be street, avenue, road, etc. This element also includes the |
| 6182 | * house number and room/apartment/flat/floor number. |
| 6183 | * <p> |
| 6184 | * Type: TEXT |
| 6185 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6186 | public static final String STREET = DATA4; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6187 | |
| 6188 | /** |
| 6189 | * Covers actual P.O. boxes, drawers, locked bags, etc. This is |
| 6190 | * usually but not always mutually exclusive with street. |
| 6191 | * <p> |
| 6192 | * Type: TEXT |
| 6193 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6194 | public static final String POBOX = DATA5; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6195 | |
| 6196 | /** |
| 6197 | * This is used to disambiguate a street address when a city |
| 6198 | * contains more than one street with the same name, or to specify a |
| 6199 | * small place whose mail is routed through a larger postal town. In |
| 6200 | * China it could be a county or a minor city. |
| 6201 | * <p> |
| 6202 | * Type: TEXT |
| 6203 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6204 | public static final String NEIGHBORHOOD = DATA6; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6205 | |
| 6206 | /** |
| 6207 | * Can be city, village, town, borough, etc. This is the postal town |
| 6208 | * and not necessarily the place of residence or place of business. |
| 6209 | * <p> |
| 6210 | * Type: TEXT |
| 6211 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6212 | public static final String CITY = DATA7; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6213 | |
| 6214 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6215 | * A state, province, county (in Ireland), Land (in Germany), |
| 6216 | * departement (in France), etc. |
| 6217 | * <p> |
| 6218 | * Type: TEXT |
| 6219 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6220 | public static final String REGION = DATA8; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6221 | |
| 6222 | /** |
Jeff Sharkey | ef348c7 | 2009-07-26 14:14:34 -0700 | [diff] [blame] | 6223 | * Postal code. Usually country-wide, but sometimes specific to the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6224 | * city (e.g. "2" in "Dublin 2, Ireland" addresses). |
| 6225 | * <p> |
| 6226 | * Type: TEXT |
| 6227 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6228 | public static final String POSTCODE = DATA9; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6229 | |
| 6230 | /** |
| 6231 | * The name or code of the country. |
| 6232 | * <p> |
| 6233 | * Type: TEXT |
| 6234 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6235 | public static final String COUNTRY = DATA10; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6236 | |
| 6237 | /** |
| 6238 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6239 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6240 | */ |
| 6241 | public static final int getTypeLabelResource(int type) { |
| 6242 | switch (type) { |
| 6243 | case TYPE_HOME: return com.android.internal.R.string.postalTypeHome; |
| 6244 | case TYPE_WORK: return com.android.internal.R.string.postalTypeWork; |
| 6245 | case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther; |
| 6246 | default: return com.android.internal.R.string.postalTypeCustom; |
| 6247 | } |
| 6248 | } |
| 6249 | |
| 6250 | /** |
| 6251 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6252 | * possibly substituting the given {@link #LABEL} value |
| 6253 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6254 | */ |
| 6255 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6256 | CharSequence label) { |
| 6257 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6258 | return label; |
| 6259 | } else { |
| 6260 | final int labelRes = getTypeLabelResource(type); |
| 6261 | return res.getText(labelRes); |
| 6262 | } |
| 6263 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6264 | } |
| 6265 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6266 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6267 | * <p> |
| 6268 | * A data kind representing an IM address |
| 6269 | * </p> |
| 6270 | * <p> |
| 6271 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6272 | * well as the following aliases. |
| 6273 | * </p> |
| 6274 | * <h2>Column aliases</h2> |
| 6275 | * <table class="jd-sumtable"> |
| 6276 | * <tr> |
| 6277 | * <th>Type</th> |
| 6278 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6279 | * </tr> |
| 6280 | * <tr> |
| 6281 | * <td>String</td> |
| 6282 | * <td>{@link #DATA}</td> |
| 6283 | * <td>{@link #DATA1}</td> |
| 6284 | * <td></td> |
| 6285 | * </tr> |
| 6286 | * <tr> |
| 6287 | * <td>int</td> |
| 6288 | * <td>{@link #TYPE}</td> |
| 6289 | * <td>{@link #DATA2}</td> |
| 6290 | * <td>Allowed values are: |
| 6291 | * <p> |
| 6292 | * <ul> |
| 6293 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6294 | * <li>{@link #TYPE_HOME}</li> |
| 6295 | * <li>{@link #TYPE_WORK}</li> |
| 6296 | * <li>{@link #TYPE_OTHER}</li> |
| 6297 | * </ul> |
| 6298 | * </p> |
| 6299 | * </td> |
| 6300 | * </tr> |
| 6301 | * <tr> |
| 6302 | * <td>String</td> |
| 6303 | * <td>{@link #LABEL}</td> |
| 6304 | * <td>{@link #DATA3}</td> |
| 6305 | * <td></td> |
| 6306 | * </tr> |
| 6307 | * <tr> |
| 6308 | * <td>String</td> |
| 6309 | * <td>{@link #PROTOCOL}</td> |
| 6310 | * <td>{@link #DATA5}</td> |
| 6311 | * <td> |
| 6312 | * <p> |
| 6313 | * Allowed values: |
| 6314 | * <ul> |
| 6315 | * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name |
| 6316 | * as {@link #CUSTOM_PROTOCOL}.</li> |
| 6317 | * <li>{@link #PROTOCOL_AIM}</li> |
| 6318 | * <li>{@link #PROTOCOL_MSN}</li> |
| 6319 | * <li>{@link #PROTOCOL_YAHOO}</li> |
| 6320 | * <li>{@link #PROTOCOL_SKYPE}</li> |
| 6321 | * <li>{@link #PROTOCOL_QQ}</li> |
| 6322 | * <li>{@link #PROTOCOL_GOOGLE_TALK}</li> |
| 6323 | * <li>{@link #PROTOCOL_ICQ}</li> |
| 6324 | * <li>{@link #PROTOCOL_JABBER}</li> |
| 6325 | * <li>{@link #PROTOCOL_NETMEETING}</li> |
| 6326 | * </ul> |
| 6327 | * </p> |
| 6328 | * </td> |
| 6329 | * </tr> |
| 6330 | * <tr> |
| 6331 | * <td>String</td> |
| 6332 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 6333 | * <td>{@link #DATA6}</td> |
| 6334 | * <td></td> |
| 6335 | * </tr> |
| 6336 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6337 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6338 | public static final class Im implements DataColumnsWithJoins, CommonColumns, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6339 | /** |
| 6340 | * This utility class cannot be instantiated |
| 6341 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6342 | private Im() {} |
| 6343 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6344 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6345 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; |
| 6346 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6347 | public static final int TYPE_HOME = 1; |
| 6348 | public static final int TYPE_WORK = 2; |
| 6349 | public static final int TYPE_OTHER = 3; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6350 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 6351 | /** |
| 6352 | * This column should be populated with one of the defined |
| 6353 | * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this |
| 6354 | * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL} |
| 6355 | * should contain the name of the custom protocol. |
| 6356 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6357 | public static final String PROTOCOL = DATA5; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6358 | |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6359 | public static final String CUSTOM_PROTOCOL = DATA6; |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 6360 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 6361 | /* |
| 6362 | * The predefined IM protocol types. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6363 | */ |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 6364 | public static final int PROTOCOL_CUSTOM = -1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6365 | public static final int PROTOCOL_AIM = 0; |
| 6366 | public static final int PROTOCOL_MSN = 1; |
| 6367 | public static final int PROTOCOL_YAHOO = 2; |
| 6368 | public static final int PROTOCOL_SKYPE = 3; |
| 6369 | public static final int PROTOCOL_QQ = 4; |
| 6370 | public static final int PROTOCOL_GOOGLE_TALK = 5; |
| 6371 | public static final int PROTOCOL_ICQ = 6; |
| 6372 | public static final int PROTOCOL_JABBER = 7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6373 | public static final int PROTOCOL_NETMEETING = 8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6374 | |
| 6375 | /** |
| 6376 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6377 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6378 | */ |
| 6379 | public static final int getTypeLabelResource(int type) { |
| 6380 | switch (type) { |
| 6381 | case TYPE_HOME: return com.android.internal.R.string.imTypeHome; |
| 6382 | case TYPE_WORK: return com.android.internal.R.string.imTypeWork; |
| 6383 | case TYPE_OTHER: return com.android.internal.R.string.imTypeOther; |
| 6384 | default: return com.android.internal.R.string.imTypeCustom; |
| 6385 | } |
| 6386 | } |
| 6387 | |
| 6388 | /** |
| 6389 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6390 | * possibly substituting the given {@link #LABEL} value |
| 6391 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6392 | */ |
| 6393 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6394 | CharSequence label) { |
| 6395 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6396 | return label; |
| 6397 | } else { |
| 6398 | final int labelRes = getTypeLabelResource(type); |
| 6399 | return res.getText(labelRes); |
| 6400 | } |
| 6401 | } |
| 6402 | |
| 6403 | /** |
| 6404 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6405 | * {@link #PROTOCOL}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6406 | */ |
| 6407 | public static final int getProtocolLabelResource(int type) { |
| 6408 | switch (type) { |
| 6409 | case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim; |
| 6410 | case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn; |
| 6411 | case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo; |
| 6412 | case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype; |
| 6413 | case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq; |
| 6414 | case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk; |
| 6415 | case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq; |
| 6416 | case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber; |
| 6417 | case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting; |
| 6418 | default: return com.android.internal.R.string.imProtocolCustom; |
| 6419 | } |
| 6420 | } |
| 6421 | |
| 6422 | /** |
| 6423 | * Return a {@link CharSequence} that best describes the given |
| 6424 | * protocol, possibly substituting the given |
| 6425 | * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}. |
| 6426 | */ |
| 6427 | public static final CharSequence getProtocolLabel(Resources res, int type, |
| 6428 | CharSequence label) { |
| 6429 | if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6430 | return label; |
| 6431 | } else { |
| 6432 | final int labelRes = getProtocolLabelResource(type); |
| 6433 | return res.getText(labelRes); |
| 6434 | } |
| 6435 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6436 | } |
| 6437 | |
| 6438 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6439 | * <p> |
| 6440 | * A data kind representing an organization. |
| 6441 | * </p> |
| 6442 | * <p> |
| 6443 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6444 | * well as the following aliases. |
| 6445 | * </p> |
| 6446 | * <h2>Column aliases</h2> |
| 6447 | * <table class="jd-sumtable"> |
| 6448 | * <tr> |
| 6449 | * <th>Type</th> |
| 6450 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6451 | * </tr> |
| 6452 | * <tr> |
| 6453 | * <td>String</td> |
| 6454 | * <td>{@link #COMPANY}</td> |
| 6455 | * <td>{@link #DATA1}</td> |
| 6456 | * <td></td> |
| 6457 | * </tr> |
| 6458 | * <tr> |
| 6459 | * <td>int</td> |
| 6460 | * <td>{@link #TYPE}</td> |
| 6461 | * <td>{@link #DATA2}</td> |
| 6462 | * <td>Allowed values are: |
| 6463 | * <p> |
| 6464 | * <ul> |
| 6465 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6466 | * <li>{@link #TYPE_WORK}</li> |
| 6467 | * <li>{@link #TYPE_OTHER}</li> |
| 6468 | * </ul> |
| 6469 | * </p> |
| 6470 | * </td> |
| 6471 | * </tr> |
| 6472 | * <tr> |
| 6473 | * <td>String</td> |
| 6474 | * <td>{@link #LABEL}</td> |
| 6475 | * <td>{@link #DATA3}</td> |
| 6476 | * <td></td> |
| 6477 | * </tr> |
| 6478 | * <tr> |
| 6479 | * <td>String</td> |
| 6480 | * <td>{@link #TITLE}</td> |
| 6481 | * <td>{@link #DATA4}</td> |
| 6482 | * <td></td> |
| 6483 | * </tr> |
| 6484 | * <tr> |
| 6485 | * <td>String</td> |
| 6486 | * <td>{@link #DEPARTMENT}</td> |
| 6487 | * <td>{@link #DATA5}</td> |
| 6488 | * <td></td> |
| 6489 | * </tr> |
| 6490 | * <tr> |
| 6491 | * <td>String</td> |
| 6492 | * <td>{@link #JOB_DESCRIPTION}</td> |
| 6493 | * <td>{@link #DATA6}</td> |
| 6494 | * <td></td> |
| 6495 | * </tr> |
| 6496 | * <tr> |
| 6497 | * <td>String</td> |
| 6498 | * <td>{@link #SYMBOL}</td> |
| 6499 | * <td>{@link #DATA7}</td> |
| 6500 | * <td></td> |
| 6501 | * </tr> |
| 6502 | * <tr> |
| 6503 | * <td>String</td> |
| 6504 | * <td>{@link #PHONETIC_NAME}</td> |
| 6505 | * <td>{@link #DATA8}</td> |
| 6506 | * <td></td> |
| 6507 | * </tr> |
| 6508 | * <tr> |
| 6509 | * <td>String</td> |
| 6510 | * <td>{@link #OFFICE_LOCATION}</td> |
| 6511 | * <td>{@link #DATA9}</td> |
| 6512 | * <td></td> |
| 6513 | * </tr> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 6514 | * <tr> |
| 6515 | * <td>String</td> |
| 6516 | * <td>PHONETIC_NAME_STYLE</td> |
| 6517 | * <td>{@link #DATA10}</td> |
| 6518 | * <td></td> |
| 6519 | * </tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6520 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6521 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6522 | public static final class Organization implements DataColumnsWithJoins, CommonColumns, |
| 6523 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6524 | /** |
| 6525 | * This utility class cannot be instantiated |
| 6526 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6527 | private Organization() {} |
| 6528 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6529 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6530 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; |
| 6531 | |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6532 | public static final int TYPE_WORK = 1; |
| 6533 | public static final int TYPE_OTHER = 2; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6534 | |
| 6535 | /** |
| 6536 | * The company as the user entered it. |
| 6537 | * <P>Type: TEXT</P> |
| 6538 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6539 | public static final String COMPANY = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6540 | |
| 6541 | /** |
| 6542 | * The position title at this company as the user entered it. |
| 6543 | * <P>Type: TEXT</P> |
| 6544 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6545 | public static final String TITLE = DATA4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6546 | |
| 6547 | /** |
| 6548 | * The department at this company as the user entered it. |
| 6549 | * <P>Type: TEXT</P> |
| 6550 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6551 | public static final String DEPARTMENT = DATA5; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6552 | |
| 6553 | /** |
| 6554 | * The job description at this company as the user entered it. |
| 6555 | * <P>Type: TEXT</P> |
| 6556 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6557 | public static final String JOB_DESCRIPTION = DATA6; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6558 | |
| 6559 | /** |
| 6560 | * The symbol of this company as the user entered it. |
| 6561 | * <P>Type: TEXT</P> |
| 6562 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6563 | public static final String SYMBOL = DATA7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6564 | |
| 6565 | /** |
| 6566 | * The phonetic name of this company as the user entered it. |
| 6567 | * <P>Type: TEXT</P> |
| 6568 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6569 | public static final String PHONETIC_NAME = DATA8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6570 | |
| 6571 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 6572 | * The office location of this organization. |
| 6573 | * <P>Type: TEXT</P> |
| 6574 | */ |
| 6575 | public static final String OFFICE_LOCATION = DATA9; |
| 6576 | |
| 6577 | /** |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 6578 | * The alphabet used for capturing the phonetic name. |
| 6579 | * See {@link ContactsContract.PhoneticNameStyle}. |
| 6580 | * @hide |
| 6581 | */ |
| 6582 | public static final String PHONETIC_NAME_STYLE = DATA10; |
| 6583 | |
| 6584 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6585 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6586 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6587 | */ |
| 6588 | public static final int getTypeLabelResource(int type) { |
| 6589 | switch (type) { |
| 6590 | case TYPE_WORK: return com.android.internal.R.string.orgTypeWork; |
| 6591 | case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther; |
| 6592 | default: return com.android.internal.R.string.orgTypeCustom; |
| 6593 | } |
| 6594 | } |
| 6595 | |
| 6596 | /** |
| 6597 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6598 | * possibly substituting the given {@link #LABEL} value |
| 6599 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6600 | */ |
| 6601 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6602 | CharSequence label) { |
| 6603 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6604 | return label; |
| 6605 | } else { |
| 6606 | final int labelRes = getTypeLabelResource(type); |
| 6607 | return res.getText(labelRes); |
| 6608 | } |
| 6609 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6610 | } |
| 6611 | |
| 6612 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6613 | * <p> |
| 6614 | * A data kind representing a relation. |
| 6615 | * </p> |
| 6616 | * <p> |
| 6617 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6618 | * well as the following aliases. |
| 6619 | * </p> |
| 6620 | * <h2>Column aliases</h2> |
| 6621 | * <table class="jd-sumtable"> |
| 6622 | * <tr> |
| 6623 | * <th>Type</th> |
| 6624 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6625 | * </tr> |
| 6626 | * <tr> |
| 6627 | * <td>String</td> |
| 6628 | * <td>{@link #NAME}</td> |
| 6629 | * <td>{@link #DATA1}</td> |
| 6630 | * <td></td> |
| 6631 | * </tr> |
| 6632 | * <tr> |
| 6633 | * <td>int</td> |
| 6634 | * <td>{@link #TYPE}</td> |
| 6635 | * <td>{@link #DATA2}</td> |
| 6636 | * <td>Allowed values are: |
| 6637 | * <p> |
| 6638 | * <ul> |
| 6639 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6640 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 6641 | * <li>{@link #TYPE_BROTHER}</li> |
| 6642 | * <li>{@link #TYPE_CHILD}</li> |
| 6643 | * <li>{@link #TYPE_DOMESTIC_PARTNER}</li> |
| 6644 | * <li>{@link #TYPE_FATHER}</li> |
| 6645 | * <li>{@link #TYPE_FRIEND}</li> |
| 6646 | * <li>{@link #TYPE_MANAGER}</li> |
| 6647 | * <li>{@link #TYPE_MOTHER}</li> |
| 6648 | * <li>{@link #TYPE_PARENT}</li> |
| 6649 | * <li>{@link #TYPE_PARTNER}</li> |
| 6650 | * <li>{@link #TYPE_REFERRED_BY}</li> |
| 6651 | * <li>{@link #TYPE_RELATIVE}</li> |
| 6652 | * <li>{@link #TYPE_SISTER}</li> |
| 6653 | * <li>{@link #TYPE_SPOUSE}</li> |
| 6654 | * </ul> |
| 6655 | * </p> |
| 6656 | * </td> |
| 6657 | * </tr> |
| 6658 | * <tr> |
| 6659 | * <td>String</td> |
| 6660 | * <td>{@link #LABEL}</td> |
| 6661 | * <td>{@link #DATA3}</td> |
| 6662 | * <td></td> |
| 6663 | * </tr> |
| 6664 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6665 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6666 | public static final class Relation implements DataColumnsWithJoins, CommonColumns, |
| 6667 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6668 | /** |
| 6669 | * This utility class cannot be instantiated |
| 6670 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6671 | private Relation() {} |
| 6672 | |
| 6673 | /** MIME type used when storing this in data table. */ |
| 6674 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; |
| 6675 | |
| 6676 | public static final int TYPE_ASSISTANT = 1; |
| 6677 | public static final int TYPE_BROTHER = 2; |
| 6678 | public static final int TYPE_CHILD = 3; |
| 6679 | public static final int TYPE_DOMESTIC_PARTNER = 4; |
| 6680 | public static final int TYPE_FATHER = 5; |
| 6681 | public static final int TYPE_FRIEND = 6; |
| 6682 | public static final int TYPE_MANAGER = 7; |
| 6683 | public static final int TYPE_MOTHER = 8; |
| 6684 | public static final int TYPE_PARENT = 9; |
| 6685 | public static final int TYPE_PARTNER = 10; |
| 6686 | public static final int TYPE_REFERRED_BY = 11; |
| 6687 | public static final int TYPE_RELATIVE = 12; |
| 6688 | public static final int TYPE_SISTER = 13; |
| 6689 | public static final int TYPE_SPOUSE = 14; |
| 6690 | |
| 6691 | /** |
| 6692 | * The name of the relative as the user entered it. |
| 6693 | * <P>Type: TEXT</P> |
| 6694 | */ |
| 6695 | public static final String NAME = DATA; |
Daniel Lehmann | 1fb39f0 | 2010-10-28 13:40:38 -0700 | [diff] [blame] | 6696 | |
| 6697 | /** |
| 6698 | * Return the string resource that best describes the given |
| 6699 | * {@link #TYPE}. Will always return a valid resource. |
| 6700 | */ |
| 6701 | public static final int getTypeLabelResource(int type) { |
| 6702 | switch (type) { |
| 6703 | case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant; |
| 6704 | case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother; |
| 6705 | case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild; |
| 6706 | case TYPE_DOMESTIC_PARTNER: |
| 6707 | return com.android.internal.R.string.relationTypeDomesticPartner; |
| 6708 | case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather; |
| 6709 | case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend; |
| 6710 | case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager; |
| 6711 | case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother; |
| 6712 | case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent; |
| 6713 | case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner; |
| 6714 | case TYPE_REFERRED_BY: |
| 6715 | return com.android.internal.R.string.relationTypeReferredBy; |
| 6716 | case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative; |
| 6717 | case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister; |
| 6718 | case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse; |
| 6719 | default: return com.android.internal.R.string.orgTypeCustom; |
| 6720 | } |
| 6721 | } |
| 6722 | |
| 6723 | /** |
| 6724 | * Return a {@link CharSequence} that best describes the given type, |
| 6725 | * possibly substituting the given {@link #LABEL} value |
| 6726 | * for {@link #TYPE_CUSTOM}. |
| 6727 | */ |
| 6728 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6729 | CharSequence label) { |
| 6730 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6731 | return label; |
| 6732 | } else { |
| 6733 | final int labelRes = getTypeLabelResource(type); |
| 6734 | return res.getText(labelRes); |
| 6735 | } |
| 6736 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6737 | } |
| 6738 | |
| 6739 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6740 | * <p> |
| 6741 | * A data kind representing an event. |
| 6742 | * </p> |
| 6743 | * <p> |
| 6744 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6745 | * well as the following aliases. |
| 6746 | * </p> |
| 6747 | * <h2>Column aliases</h2> |
| 6748 | * <table class="jd-sumtable"> |
| 6749 | * <tr> |
| 6750 | * <th>Type</th> |
| 6751 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6752 | * </tr> |
| 6753 | * <tr> |
| 6754 | * <td>String</td> |
| 6755 | * <td>{@link #START_DATE}</td> |
| 6756 | * <td>{@link #DATA1}</td> |
| 6757 | * <td></td> |
| 6758 | * </tr> |
| 6759 | * <tr> |
| 6760 | * <td>int</td> |
| 6761 | * <td>{@link #TYPE}</td> |
| 6762 | * <td>{@link #DATA2}</td> |
| 6763 | * <td>Allowed values are: |
| 6764 | * <p> |
| 6765 | * <ul> |
| 6766 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6767 | * <li>{@link #TYPE_ANNIVERSARY}</li> |
| 6768 | * <li>{@link #TYPE_OTHER}</li> |
| 6769 | * <li>{@link #TYPE_BIRTHDAY}</li> |
| 6770 | * </ul> |
| 6771 | * </p> |
| 6772 | * </td> |
| 6773 | * </tr> |
| 6774 | * <tr> |
| 6775 | * <td>String</td> |
| 6776 | * <td>{@link #LABEL}</td> |
| 6777 | * <td>{@link #DATA3}</td> |
| 6778 | * <td></td> |
| 6779 | * </tr> |
| 6780 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6781 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6782 | public static final class Event implements DataColumnsWithJoins, CommonColumns, |
| 6783 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6784 | /** |
| 6785 | * This utility class cannot be instantiated |
| 6786 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6787 | private Event() {} |
| 6788 | |
| 6789 | /** MIME type used when storing this in data table. */ |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6790 | 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] | 6791 | |
| 6792 | public static final int TYPE_ANNIVERSARY = 1; |
| 6793 | public static final int TYPE_OTHER = 2; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6794 | public static final int TYPE_BIRTHDAY = 3; |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6795 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6796 | /** |
| 6797 | * The event start date as the user entered it. |
| 6798 | * <P>Type: TEXT</P> |
| 6799 | */ |
| 6800 | public static final String START_DATE = DATA; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6801 | |
| 6802 | /** |
| 6803 | * Return the string resource that best describes the given |
| 6804 | * {@link #TYPE}. Will always return a valid resource. |
| 6805 | */ |
| 6806 | public static int getTypeResource(Integer type) { |
| 6807 | if (type == null) { |
| 6808 | return com.android.internal.R.string.eventTypeOther; |
| 6809 | } |
| 6810 | switch (type) { |
| 6811 | case TYPE_ANNIVERSARY: |
| 6812 | return com.android.internal.R.string.eventTypeAnniversary; |
| 6813 | case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday; |
| 6814 | case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther; |
Daniel Lehmann | dd384a7 | 2010-11-01 18:40:50 -0700 | [diff] [blame] | 6815 | default: return com.android.internal.R.string.eventTypeCustom; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 6816 | } |
| 6817 | } |
Paul Soulos | 6b2dd63 | 2014-07-24 17:17:42 -0700 | [diff] [blame] | 6818 | |
| 6819 | /** |
| 6820 | * Return a {@link CharSequence} that best describes the given type, |
| 6821 | * possibly substituting the given {@link #LABEL} value |
| 6822 | * for {@link #TYPE_CUSTOM}. |
| 6823 | */ |
| 6824 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6825 | CharSequence label) { |
| 6826 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6827 | return label; |
| 6828 | } else { |
| 6829 | final int labelRes = getTypeResource(type); |
| 6830 | return res.getText(labelRes); |
| 6831 | } |
| 6832 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6833 | } |
| 6834 | |
| 6835 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6836 | * <p> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6837 | * A data kind representing a photo for the contact. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6838 | * </p> |
| 6839 | * <p> |
| 6840 | * Some sync adapters will choose to download photos in a separate |
| 6841 | * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1} |
| 6842 | * through {@link ContactsContract.Data#SYNC4} to store temporary |
| 6843 | * data, e.g. the image URL or ID, state of download, server-side version |
| 6844 | * of the image. It is allowed for the {@link #PHOTO} to be null. |
| 6845 | * </p> |
| 6846 | * <p> |
| 6847 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6848 | * well as the following aliases. |
| 6849 | * </p> |
| 6850 | * <h2>Column aliases</h2> |
| 6851 | * <table class="jd-sumtable"> |
| 6852 | * <tr> |
| 6853 | * <th>Type</th> |
| 6854 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6855 | * </tr> |
| 6856 | * <tr> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6857 | * <td>NUMBER</td> |
| 6858 | * <td>{@link #PHOTO_FILE_ID}</td> |
| 6859 | * <td>{@link #DATA14}</td> |
| 6860 | * <td>ID of the hi-res photo file.</td> |
| 6861 | * </tr> |
| 6862 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6863 | * <td>BLOB</td> |
| 6864 | * <td>{@link #PHOTO}</td> |
| 6865 | * <td>{@link #DATA15}</td> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6866 | * <td>By convention, binary data is stored in DATA15. The thumbnail of the |
| 6867 | * photo is stored in this column.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6868 | * </tr> |
| 6869 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6870 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6871 | public static final class Photo implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6872 | /** |
| 6873 | * This utility class cannot be instantiated |
| 6874 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6875 | private Photo() {} |
| 6876 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6877 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6878 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; |
| 6879 | |
| 6880 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 6881 | * Photo file ID for the display photo of the raw contact. |
| 6882 | * See {@link ContactsContract.DisplayPhoto}. |
| 6883 | * <p> |
| 6884 | * Type: NUMBER |
| 6885 | */ |
| 6886 | public static final String PHOTO_FILE_ID = DATA14; |
| 6887 | |
| 6888 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 6889 | * 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] | 6890 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6891 | * <p> |
| 6892 | * Type: BLOB |
| 6893 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6894 | public static final String PHOTO = DATA15; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6895 | } |
| 6896 | |
| 6897 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6898 | * <p> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6899 | * Notes about the contact. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6900 | * </p> |
| 6901 | * <p> |
| 6902 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6903 | * well as the following aliases. |
| 6904 | * </p> |
| 6905 | * <h2>Column aliases</h2> |
| 6906 | * <table class="jd-sumtable"> |
| 6907 | * <tr> |
| 6908 | * <th>Type</th> |
| 6909 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6910 | * </tr> |
| 6911 | * <tr> |
| 6912 | * <td>String</td> |
| 6913 | * <td>{@link #NOTE}</td> |
| 6914 | * <td>{@link #DATA1}</td> |
| 6915 | * <td></td> |
| 6916 | * </tr> |
| 6917 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6918 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6919 | public static final class Note implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6920 | /** |
| 6921 | * This utility class cannot be instantiated |
| 6922 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6923 | private Note() {} |
| 6924 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6925 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6926 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; |
| 6927 | |
| 6928 | /** |
| 6929 | * The note text. |
| 6930 | * <P>Type: TEXT</P> |
| 6931 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6932 | public static final String NOTE = DATA1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6933 | } |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6934 | |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 6935 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6936 | * <p> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6937 | * Group Membership. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6938 | * </p> |
| 6939 | * <p> |
| 6940 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6941 | * well as the following aliases. |
| 6942 | * </p> |
| 6943 | * <h2>Column aliases</h2> |
| 6944 | * <table class="jd-sumtable"> |
| 6945 | * <tr> |
| 6946 | * <th>Type</th> |
| 6947 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6948 | * </tr> |
| 6949 | * <tr> |
| 6950 | * <td>long</td> |
| 6951 | * <td>{@link #GROUP_ROW_ID}</td> |
| 6952 | * <td>{@link #DATA1}</td> |
| 6953 | * <td></td> |
| 6954 | * </tr> |
| 6955 | * <tr> |
| 6956 | * <td>String</td> |
| 6957 | * <td>{@link #GROUP_SOURCE_ID}</td> |
| 6958 | * <td>none</td> |
| 6959 | * <td> |
| 6960 | * <p> |
| 6961 | * The sourceid of the group that this group membership refers to. |
| 6962 | * Exactly one of this or {@link #GROUP_ROW_ID} must be set when |
| 6963 | * inserting a row. |
| 6964 | * </p> |
| 6965 | * <p> |
| 6966 | * If this field is specified, the provider will first try to |
| 6967 | * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group |
| 6968 | * is found, it will use the corresponding row id. If the group is not |
| 6969 | * found, it will create one. |
| 6970 | * </td> |
| 6971 | * </tr> |
| 6972 | * </table> |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 6973 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6974 | public static final class GroupMembership implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6975 | /** |
| 6976 | * This utility class cannot be instantiated |
| 6977 | */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6978 | private GroupMembership() {} |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 6979 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6980 | /** MIME type used when storing this in data table. */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6981 | public static final String CONTENT_ITEM_TYPE = |
| 6982 | "vnd.android.cursor.item/group_membership"; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 6983 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6984 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 6985 | * The row id of the group that this group membership refers to. Exactly one of |
| 6986 | * 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] | 6987 | * <P>Type: INTEGER</P> |
| 6988 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6989 | public static final String GROUP_ROW_ID = DATA1; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 6990 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6991 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 6992 | * The sourceid of the group that this group membership refers to. Exactly one of |
| 6993 | * 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] | 6994 | * <P>Type: TEXT</P> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6995 | */ |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 6996 | public static final String GROUP_SOURCE_ID = "group_sourceid"; |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 6997 | } |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6998 | |
| 6999 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7000 | * <p> |
| 7001 | * A data kind representing a website related to the contact. |
| 7002 | * </p> |
| 7003 | * <p> |
| 7004 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7005 | * well as the following aliases. |
| 7006 | * </p> |
| 7007 | * <h2>Column aliases</h2> |
| 7008 | * <table class="jd-sumtable"> |
| 7009 | * <tr> |
| 7010 | * <th>Type</th> |
| 7011 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7012 | * </tr> |
| 7013 | * <tr> |
| 7014 | * <td>String</td> |
| 7015 | * <td>{@link #URL}</td> |
| 7016 | * <td>{@link #DATA1}</td> |
| 7017 | * <td></td> |
| 7018 | * </tr> |
| 7019 | * <tr> |
| 7020 | * <td>int</td> |
| 7021 | * <td>{@link #TYPE}</td> |
| 7022 | * <td>{@link #DATA2}</td> |
| 7023 | * <td>Allowed values are: |
| 7024 | * <p> |
| 7025 | * <ul> |
| 7026 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 7027 | * <li>{@link #TYPE_HOMEPAGE}</li> |
| 7028 | * <li>{@link #TYPE_BLOG}</li> |
| 7029 | * <li>{@link #TYPE_PROFILE}</li> |
| 7030 | * <li>{@link #TYPE_HOME}</li> |
| 7031 | * <li>{@link #TYPE_WORK}</li> |
| 7032 | * <li>{@link #TYPE_FTP}</li> |
| 7033 | * <li>{@link #TYPE_OTHER}</li> |
| 7034 | * </ul> |
| 7035 | * </p> |
| 7036 | * </td> |
| 7037 | * </tr> |
| 7038 | * <tr> |
| 7039 | * <td>String</td> |
| 7040 | * <td>{@link #LABEL}</td> |
| 7041 | * <td>{@link #DATA3}</td> |
| 7042 | * <td></td> |
| 7043 | * </tr> |
| 7044 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7045 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7046 | public static final class Website implements DataColumnsWithJoins, CommonColumns, |
| 7047 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7048 | /** |
| 7049 | * This utility class cannot be instantiated |
| 7050 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7051 | private Website() {} |
| 7052 | |
| 7053 | /** MIME type used when storing this in data table. */ |
| 7054 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; |
| 7055 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7056 | public static final int TYPE_HOMEPAGE = 1; |
| 7057 | public static final int TYPE_BLOG = 2; |
| 7058 | public static final int TYPE_PROFILE = 3; |
| 7059 | public static final int TYPE_HOME = 4; |
| 7060 | public static final int TYPE_WORK = 5; |
| 7061 | public static final int TYPE_FTP = 6; |
| 7062 | public static final int TYPE_OTHER = 7; |
| 7063 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7064 | /** |
| 7065 | * The website URL string. |
| 7066 | * <P>Type: TEXT</P> |
| 7067 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7068 | public static final String URL = DATA; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7069 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7070 | |
| 7071 | /** |
| 7072 | * <p> |
| 7073 | * A data kind representing a SIP address for the contact. |
| 7074 | * </p> |
| 7075 | * <p> |
| 7076 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7077 | * well as the following aliases. |
| 7078 | * </p> |
| 7079 | * <h2>Column aliases</h2> |
| 7080 | * <table class="jd-sumtable"> |
| 7081 | * <tr> |
| 7082 | * <th>Type</th> |
| 7083 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7084 | * </tr> |
| 7085 | * <tr> |
| 7086 | * <td>String</td> |
| 7087 | * <td>{@link #SIP_ADDRESS}</td> |
| 7088 | * <td>{@link #DATA1}</td> |
| 7089 | * <td></td> |
| 7090 | * </tr> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 7091 | * <tr> |
| 7092 | * <td>int</td> |
| 7093 | * <td>{@link #TYPE}</td> |
| 7094 | * <td>{@link #DATA2}</td> |
| 7095 | * <td>Allowed values are: |
| 7096 | * <p> |
| 7097 | * <ul> |
| 7098 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 7099 | * <li>{@link #TYPE_HOME}</li> |
| 7100 | * <li>{@link #TYPE_WORK}</li> |
| 7101 | * <li>{@link #TYPE_OTHER}</li> |
| 7102 | * </ul> |
| 7103 | * </p> |
| 7104 | * </td> |
| 7105 | * </tr> |
| 7106 | * <tr> |
| 7107 | * <td>String</td> |
| 7108 | * <td>{@link #LABEL}</td> |
| 7109 | * <td>{@link #DATA3}</td> |
| 7110 | * <td></td> |
| 7111 | * </tr> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7112 | * </table> |
| 7113 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7114 | public static final class SipAddress implements DataColumnsWithJoins, CommonColumns, |
| 7115 | ContactCounts { |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7116 | /** |
| 7117 | * This utility class cannot be instantiated |
| 7118 | */ |
| 7119 | private SipAddress() {} |
| 7120 | |
| 7121 | /** MIME type used when storing this in data table. */ |
| 7122 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address"; |
| 7123 | |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 7124 | public static final int TYPE_HOME = 1; |
| 7125 | public static final int TYPE_WORK = 2; |
| 7126 | public static final int TYPE_OTHER = 3; |
| 7127 | |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7128 | /** |
| 7129 | * The SIP address. |
| 7130 | * <P>Type: TEXT</P> |
| 7131 | */ |
| 7132 | public static final String SIP_ADDRESS = DATA1; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 7133 | // ...and TYPE and LABEL come from the CommonColumns interface. |
| 7134 | |
| 7135 | /** |
| 7136 | * Return the string resource that best describes the given |
| 7137 | * {@link #TYPE}. Will always return a valid resource. |
| 7138 | */ |
| 7139 | public static final int getTypeLabelResource(int type) { |
| 7140 | switch (type) { |
| 7141 | case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome; |
| 7142 | case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork; |
| 7143 | case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther; |
| 7144 | default: return com.android.internal.R.string.sipAddressTypeCustom; |
| 7145 | } |
| 7146 | } |
| 7147 | |
| 7148 | /** |
| 7149 | * Return a {@link CharSequence} that best describes the given type, |
| 7150 | * possibly substituting the given {@link #LABEL} value |
| 7151 | * for {@link #TYPE_CUSTOM}. |
| 7152 | */ |
| 7153 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 7154 | CharSequence label) { |
| 7155 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 7156 | return label; |
| 7157 | } else { |
| 7158 | final int labelRes = getTypeLabelResource(type); |
| 7159 | return res.getText(labelRes); |
| 7160 | } |
| 7161 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7162 | } |
Fred Quintana | 4923f1d | 2011-08-05 15:58:17 -0700 | [diff] [blame] | 7163 | |
| 7164 | /** |
| 7165 | * A data kind representing an Identity related to the contact. |
| 7166 | * <p> |
| 7167 | * This can be used as a signal by the aggregator to combine raw contacts into |
| 7168 | * contacts, e.g. if two contacts have Identity rows with |
| 7169 | * the same NAMESPACE and IDENTITY values the aggregator can know that they refer |
| 7170 | * to the same person. |
| 7171 | * </p> |
| 7172 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7173 | public static final class Identity implements DataColumnsWithJoins, ContactCounts { |
Fred Quintana | 4923f1d | 2011-08-05 15:58:17 -0700 | [diff] [blame] | 7174 | /** |
| 7175 | * This utility class cannot be instantiated |
| 7176 | */ |
| 7177 | private Identity() {} |
| 7178 | |
| 7179 | /** MIME type used when storing this in data table. */ |
| 7180 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity"; |
| 7181 | |
| 7182 | /** |
| 7183 | * The identity string. |
| 7184 | * <P>Type: TEXT</P> |
| 7185 | */ |
| 7186 | public static final String IDENTITY = DataColumns.DATA1; |
| 7187 | |
| 7188 | /** |
| 7189 | * The namespace of the identity string, e.g. "com.google" |
| 7190 | * <P>Type: TEXT</P> |
| 7191 | */ |
| 7192 | public static final String NAMESPACE = DataColumns.DATA2; |
| 7193 | } |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7194 | |
| 7195 | /** |
| 7196 | * <p> |
| 7197 | * Convenient functionalities for "callable" data. Note that, this is NOT a separate data |
| 7198 | * kind. |
| 7199 | * </p> |
| 7200 | * <p> |
| 7201 | * This URI allows the ContactsProvider to return a unified result for "callable" data |
| 7202 | * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the |
| 7203 | * current examples for "callable", but may be expanded to the other types. |
| 7204 | * </p> |
| 7205 | * <p> |
| 7206 | * Each returned row may have a different MIMETYPE and thus different interpretation for |
| 7207 | * each column. For example the meaning for {@link Phone}'s type is different than |
| 7208 | * {@link SipAddress}'s. |
| 7209 | * </p> |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7210 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7211 | public static final class Callable implements DataColumnsWithJoins, CommonColumns, |
| 7212 | ContactCounts { |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7213 | /** |
| 7214 | * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only |
| 7215 | * phone numbers. |
| 7216 | */ |
| 7217 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 7218 | "callables"); |
| 7219 | /** |
| 7220 | * Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable |
| 7221 | * data. |
| 7222 | */ |
| 7223 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 7224 | "filter"); |
| 7225 | } |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 7226 | |
| 7227 | /** |
| 7228 | * A special class of data items, used to refer to types of data that can be used to attempt |
| 7229 | * to start communicating with a person ({@link Phone} and {@link Email}). Note that this |
| 7230 | * is NOT a separate data kind. |
| 7231 | * |
| 7232 | * This URI allows the ContactsProvider to return a unified result for data items that users |
| 7233 | * can use to initiate communications with another contact. {@link Phone} and {@link Email} |
| 7234 | * are the current data types in this category. |
| 7235 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7236 | public static final class Contactables implements DataColumnsWithJoins, CommonColumns, |
| 7237 | ContactCounts { |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 7238 | /** |
| 7239 | * The content:// style URI for these data items, which requests a directory of data |
| 7240 | * rows matching the selection criteria. |
| 7241 | */ |
| 7242 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 7243 | "contactables"); |
| 7244 | |
| 7245 | /** |
| 7246 | * The content:// style URI for these data items, which allows for a query parameter to |
| 7247 | * be appended onto the end to filter for data items matching the query. |
| 7248 | */ |
| 7249 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 7250 | Contactables.CONTENT_URI, "filter"); |
| 7251 | |
| 7252 | /** |
| 7253 | * A boolean parameter for {@link Data#CONTENT_URI}. |
| 7254 | * This specifies whether or not the returned data items should be filtered to show |
| 7255 | * data items belonging to visible contacts only. |
| 7256 | */ |
| 7257 | public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; |
| 7258 | } |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7259 | } |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7260 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7261 | /** |
| 7262 | * @see Groups |
| 7263 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 7264 | protected interface GroupsColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7265 | /** |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 7266 | * The data set within the account that this group belongs to. This allows |
| 7267 | * multiple sync adapters for the same account type to distinguish between |
| 7268 | * each others' group data. |
| 7269 | * |
| 7270 | * This is empty by default, and is completely optional. It only needs to |
| 7271 | * be populated if multiple sync adapters are entering distinct group data |
| 7272 | * for the same account type and account name. |
| 7273 | * <P>Type: TEXT</P> |
| 7274 | */ |
| 7275 | public static final String DATA_SET = "data_set"; |
| 7276 | |
| 7277 | /** |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 7278 | * A concatenation of the account type and data set (delimited by a forward |
| 7279 | * slash) - if the data set is empty, this will be the same as the account |
| 7280 | * type. For applications that need to be aware of the data set, this can |
| 7281 | * be used instead of account type to distinguish sets of data. This is |
| 7282 | * never intended to be used for specifying accounts. |
| 7283 | * @hide |
| 7284 | */ |
| 7285 | public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; |
| 7286 | |
| 7287 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7288 | * The display title of this group. |
| 7289 | * <p> |
| 7290 | * Type: TEXT |
| 7291 | */ |
| 7292 | public static final String TITLE = "title"; |
| 7293 | |
| 7294 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7295 | * The package name to use when creating {@link Resources} objects for |
| 7296 | * this group. This value is only designed for use when building user |
| 7297 | * interfaces, and should not be used to infer the owner. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7298 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7299 | public static final String RES_PACKAGE = "res_package"; |
| 7300 | |
| 7301 | /** |
| 7302 | * The display title of this group to load as a resource from |
| 7303 | * {@link #RES_PACKAGE}, which may be localized. |
| 7304 | * <P>Type: TEXT</P> |
| 7305 | */ |
| 7306 | public static final String TITLE_RES = "title_res"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7307 | |
| 7308 | /** |
Dmitri Plotnikov | 02c5b45 | 2009-07-22 15:13:08 -0700 | [diff] [blame] | 7309 | * Notes about the group. |
| 7310 | * <p> |
| 7311 | * Type: TEXT |
| 7312 | */ |
| 7313 | public static final String NOTES = "notes"; |
| 7314 | |
| 7315 | /** |
| 7316 | * The ID of this group if it is a System Group, i.e. a group that has a special meaning |
| 7317 | * to the sync adapter, null otherwise. |
| 7318 | * <P>Type: TEXT</P> |
| 7319 | */ |
| 7320 | public static final String SYSTEM_ID = "system_id"; |
| 7321 | |
| 7322 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7323 | * The total number of {@link Contacts} that have |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7324 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7325 | * present when querying {@link Groups#CONTENT_SUMMARY_URI}. |
| 7326 | * <p> |
| 7327 | * Type: INTEGER |
| 7328 | */ |
| 7329 | public static final String SUMMARY_COUNT = "summ_count"; |
| 7330 | |
| 7331 | /** |
Daisuke Miyakawa | 15dec39 | 2011-07-23 11:39:23 -0700 | [diff] [blame] | 7332 | * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}. |
| 7333 | * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}. |
| 7334 | * |
| 7335 | * @hide |
| 7336 | */ |
| 7337 | public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT = |
| 7338 | "return_group_count_per_account"; |
| 7339 | |
| 7340 | /** |
| 7341 | * The total number of groups of the account that a group belongs to. |
| 7342 | * This column is available only when the parameter |
| 7343 | * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in |
| 7344 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 7345 | * |
| 7346 | * For example, when the account "A" has two groups "group1" and "group2", and the account |
| 7347 | * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for |
| 7348 | * "group3" returns "1" for this column. |
| 7349 | * |
| 7350 | * Note: This counts only non-favorites, non-auto-add, and not deleted groups. |
| 7351 | * |
| 7352 | * Type: INTEGER |
| 7353 | * @hide |
| 7354 | */ |
| 7355 | public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account"; |
| 7356 | |
| 7357 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7358 | * The total number of {@link Contacts} that have both |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7359 | * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7360 | * Read-only value that is only present when querying |
| 7361 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 7362 | * <p> |
| 7363 | * Type: INTEGER |
| 7364 | */ |
| 7365 | public static final String SUMMARY_WITH_PHONES = "summ_phones"; |
| 7366 | |
| 7367 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7368 | * Flag indicating if the contacts belonging to this group should be |
| 7369 | * visible in any user interface. |
| 7370 | * <p> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7371 | * Type: INTEGER (boolean) |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7372 | */ |
| 7373 | public static final String GROUP_VISIBLE = "group_visible"; |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 7374 | |
| 7375 | /** |
| 7376 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 7377 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7378 | * called on a group, it is marked for deletion. The sync adaptor |
| 7379 | * deletes the group on the server and then calls ContactResolver.delete |
| 7380 | * once more, this time setting the the |
| 7381 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to |
| 7382 | * finalize the data removal. |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 7383 | * <P>Type: INTEGER</P> |
| 7384 | */ |
| 7385 | public static final String DELETED = "deleted"; |
Jeff Sharkey | 403d7ac | 2009-08-16 16:34:35 -0700 | [diff] [blame] | 7386 | |
| 7387 | /** |
| 7388 | * Whether this group should be synced if the SYNC_EVERYTHING settings |
| 7389 | * is false for this group's account. |
| 7390 | * <p> |
| 7391 | * Type: INTEGER (boolean) |
| 7392 | */ |
| 7393 | public static final String SHOULD_SYNC = "should_sync"; |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 7394 | |
| 7395 | /** |
| 7396 | * Any newly created contacts will automatically be added to groups that have this |
| 7397 | * flag set to true. |
| 7398 | * <p> |
| 7399 | * Type: INTEGER (boolean) |
| 7400 | */ |
| 7401 | public static final String AUTO_ADD = "auto_add"; |
| 7402 | |
| 7403 | /** |
| 7404 | * When a contacts is marked as a favorites it will be automatically added |
| 7405 | * to the groups that have this flag set, and when it is removed from favorites |
| 7406 | * it will be removed from these groups. |
| 7407 | * <p> |
| 7408 | * Type: INTEGER (boolean) |
| 7409 | */ |
| 7410 | public static final String FAVORITES = "favorites"; |
Dmitri Plotnikov | 4ccf33a | 2010-11-19 11:10:43 -0800 | [diff] [blame] | 7411 | |
| 7412 | /** |
| 7413 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 7414 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 7415 | * <P>Type: INTEGER</P> |
| 7416 | */ |
| 7417 | public static final String GROUP_IS_READ_ONLY = "group_is_read_only"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7418 | } |
| 7419 | |
| 7420 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7421 | * Constants for the groups table. Only per-account groups are supported. |
| 7422 | * <h2>Columns</h2> |
| 7423 | * <table class="jd-sumtable"> |
| 7424 | * <tr> |
| 7425 | * <th colspan='4'>Groups</th> |
| 7426 | * </tr> |
| 7427 | * <tr> |
| 7428 | * <td>long</td> |
| 7429 | * <td>{@link #_ID}</td> |
| 7430 | * <td>read-only</td> |
| 7431 | * <td>Row ID. Sync adapter should try to preserve row IDs during updates. |
| 7432 | * In other words, it would be a really bad idea to delete and reinsert a |
| 7433 | * group. A sync adapter should always do an update instead.</td> |
| 7434 | * </tr> |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 7435 | # <tr> |
| 7436 | * <td>String</td> |
| 7437 | * <td>{@link #DATA_SET}</td> |
| 7438 | * <td>read/write-once</td> |
| 7439 | * <td> |
| 7440 | * <p> |
| 7441 | * The data set within the account that this group belongs to. This allows |
| 7442 | * multiple sync adapters for the same account type to distinguish between |
| 7443 | * each others' group data. The combination of {@link #ACCOUNT_TYPE}, |
| 7444 | * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data |
| 7445 | * that is associated with a single sync adapter. |
| 7446 | * </p> |
| 7447 | * <p> |
| 7448 | * This is empty by default, and is completely optional. It only needs to |
| 7449 | * be populated if multiple sync adapters are entering distinct data for |
| 7450 | * the same account type and account name. |
| 7451 | * </p> |
| 7452 | * <p> |
| 7453 | * It should be set at the time the group is inserted and never changed |
| 7454 | * afterwards. |
| 7455 | * </p> |
| 7456 | * </td> |
| 7457 | * </tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7458 | * <tr> |
| 7459 | * <td>String</td> |
| 7460 | * <td>{@link #TITLE}</td> |
| 7461 | * <td>read/write</td> |
| 7462 | * <td>The display title of this group.</td> |
| 7463 | * </tr> |
| 7464 | * <tr> |
| 7465 | * <td>String</td> |
| 7466 | * <td>{@link #NOTES}</td> |
| 7467 | * <td>read/write</td> |
| 7468 | * <td>Notes about the group.</td> |
| 7469 | * </tr> |
| 7470 | * <tr> |
| 7471 | * <td>String</td> |
| 7472 | * <td>{@link #SYSTEM_ID}</td> |
| 7473 | * <td>read/write</td> |
| 7474 | * <td>The ID of this group if it is a System Group, i.e. a group that has a |
| 7475 | * special meaning to the sync adapter, null otherwise.</td> |
| 7476 | * </tr> |
| 7477 | * <tr> |
| 7478 | * <td>int</td> |
| 7479 | * <td>{@link #SUMMARY_COUNT}</td> |
| 7480 | * <td>read-only</td> |
| 7481 | * <td>The total number of {@link Contacts} that have |
| 7482 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value |
| 7483 | * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 7484 | * </tr> |
| 7485 | * <tr> |
| 7486 | * <td>int</td> |
| 7487 | * <td>{@link #SUMMARY_WITH_PHONES}</td> |
| 7488 | * <td>read-only</td> |
| 7489 | * <td>The total number of {@link Contacts} that have both |
| 7490 | * {@link CommonDataKinds.GroupMembership} in this group, and also have |
| 7491 | * phone numbers. Read-only value that is only present when querying |
| 7492 | * {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 7493 | * </tr> |
| 7494 | * <tr> |
| 7495 | * <td>int</td> |
| 7496 | * <td>{@link #GROUP_VISIBLE}</td> |
| 7497 | * <td>read-only</td> |
| 7498 | * <td>Flag indicating if the contacts belonging to this group should be |
| 7499 | * visible in any user interface. Allowed values: 0 and 1.</td> |
| 7500 | * </tr> |
| 7501 | * <tr> |
| 7502 | * <td>int</td> |
| 7503 | * <td>{@link #DELETED}</td> |
| 7504 | * <td>read/write</td> |
| 7505 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 7506 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 7507 | * called on a group, it is marked for deletion. The sync adaptor deletes |
| 7508 | * the group on the server and then calls ContactResolver.delete once more, |
| 7509 | * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER} |
| 7510 | * query parameter to finalize the data removal.</td> |
| 7511 | * </tr> |
| 7512 | * <tr> |
| 7513 | * <td>int</td> |
| 7514 | * <td>{@link #SHOULD_SYNC}</td> |
| 7515 | * <td>read/write</td> |
| 7516 | * <td>Whether this group should be synced if the SYNC_EVERYTHING settings |
| 7517 | * is false for this group's account.</td> |
| 7518 | * </tr> |
| 7519 | * </table> |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7520 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7521 | public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7522 | /** |
| 7523 | * This utility class cannot be instantiated |
| 7524 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7525 | private Groups() { |
| 7526 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7527 | |
| 7528 | /** |
| 7529 | * The content:// style URI for this table |
| 7530 | */ |
| 7531 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); |
| 7532 | |
| 7533 | /** |
| 7534 | * The content:// style URI for this table joined with details data from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7535 | * {@link ContactsContract.Data}. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7536 | */ |
| 7537 | public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 7538 | "groups_summary"); |
| 7539 | |
| 7540 | /** |
| 7541 | * The MIME type of a directory of groups. |
| 7542 | */ |
| 7543 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; |
| 7544 | |
| 7545 | /** |
| 7546 | * The MIME type of a single group. |
| 7547 | */ |
| 7548 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7549 | |
| 7550 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 7551 | return new EntityIteratorImpl(cursor); |
| 7552 | } |
| 7553 | |
| 7554 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 7555 | public EntityIteratorImpl(Cursor cursor) { |
| 7556 | super(cursor); |
| 7557 | } |
| 7558 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 7559 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7560 | public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { |
| 7561 | // we expect the cursor is already at the row we need to read from |
| 7562 | final ContentValues values = new ContentValues(); |
| 7563 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID); |
| 7564 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME); |
| 7565 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE); |
| 7566 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY); |
| 7567 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION); |
| 7568 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID); |
| 7569 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE); |
| 7570 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE); |
| 7571 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES); |
| 7572 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE); |
| 7573 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1); |
| 7574 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2); |
| 7575 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3); |
| 7576 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4); |
| 7577 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID); |
| 7578 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED); |
| 7579 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES); |
| 7580 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC); |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 7581 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES); |
| 7582 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7583 | cursor.moveToNext(); |
| 7584 | return new Entity(values); |
| 7585 | } |
| 7586 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7587 | } |
| 7588 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7589 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7590 | * <p> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7591 | * Constants for the contact aggregation exceptions table, which contains |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7592 | * aggregation rules overriding those used by automatic aggregation. This |
| 7593 | * type only supports query and update. Neither insert nor delete are |
| 7594 | * supported. |
| 7595 | * </p> |
| 7596 | * <h2>Columns</h2> |
| 7597 | * <table class="jd-sumtable"> |
| 7598 | * <tr> |
| 7599 | * <th colspan='4'>AggregationExceptions</th> |
| 7600 | * </tr> |
| 7601 | * <tr> |
| 7602 | * <td>int</td> |
| 7603 | * <td>{@link #TYPE}</td> |
| 7604 | * <td>read/write</td> |
| 7605 | * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER}, |
| 7606 | * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td> |
| 7607 | * </tr> |
| 7608 | * <tr> |
| 7609 | * <td>long</td> |
| 7610 | * <td>{@link #RAW_CONTACT_ID1}</td> |
| 7611 | * <td>read/write</td> |
| 7612 | * <td>A reference to the {@link RawContacts#_ID} of the raw contact that |
| 7613 | * the rule applies to.</td> |
| 7614 | * </tr> |
| 7615 | * <tr> |
| 7616 | * <td>long</td> |
| 7617 | * <td>{@link #RAW_CONTACT_ID2}</td> |
| 7618 | * <td>read/write</td> |
| 7619 | * <td>A reference to the other {@link RawContacts#_ID} of the raw contact |
| 7620 | * that the rule applies to.</td> |
| 7621 | * </tr> |
| 7622 | * </table> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7623 | */ |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 7624 | public static final class AggregationExceptions implements BaseColumns { |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7625 | /** |
| 7626 | * This utility class cannot be instantiated |
| 7627 | */ |
| 7628 | private AggregationExceptions() {} |
| 7629 | |
| 7630 | /** |
| 7631 | * The content:// style URI for this table |
| 7632 | */ |
| 7633 | public static final Uri CONTENT_URI = |
| 7634 | Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); |
| 7635 | |
| 7636 | /** |
| 7637 | * The MIME type of {@link #CONTENT_URI} providing a directory of data. |
| 7638 | */ |
| 7639 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; |
| 7640 | |
| 7641 | /** |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 7642 | * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception |
| 7643 | */ |
| 7644 | public static final String CONTENT_ITEM_TYPE = |
| 7645 | "vnd.android.cursor.item/aggregation_exception"; |
| 7646 | |
| 7647 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7648 | * 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] | 7649 | * {@link #TYPE_AUTOMATIC}. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7650 | * |
| 7651 | * <P>Type: INTEGER</P> |
| 7652 | */ |
| 7653 | public static final String TYPE = "type"; |
| 7654 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7655 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7656 | * Allows the provider to automatically decide whether the specified raw contacts should |
| 7657 | * be included in the same aggregate contact or not. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7658 | */ |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7659 | public static final int TYPE_AUTOMATIC = 0; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7660 | |
| 7661 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7662 | * Makes sure that the specified raw contacts are included in the same |
| 7663 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7664 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7665 | public static final int TYPE_KEEP_TOGETHER = 1; |
| 7666 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7667 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7668 | * Makes sure that the specified raw contacts are NOT included in the same |
| 7669 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7670 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7671 | public static final int TYPE_KEEP_SEPARATE = 2; |
| 7672 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 7673 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7674 | * 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] | 7675 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 7676 | public static final String RAW_CONTACT_ID1 = "raw_contact_id1"; |
| 7677 | |
| 7678 | /** |
| 7679 | * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule |
| 7680 | * applies to. |
| 7681 | */ |
| 7682 | public static final String RAW_CONTACT_ID2 = "raw_contact_id2"; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7683 | } |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 7684 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7685 | /** |
| 7686 | * @see Settings |
| 7687 | */ |
Dmitri Plotnikov | fe4c871 | 2009-10-14 00:28:48 -0700 | [diff] [blame] | 7688 | protected interface SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7689 | /** |
| 7690 | * The name of the account instance to which this row belongs. |
| 7691 | * <P>Type: TEXT</P> |
| 7692 | */ |
| 7693 | public static final String ACCOUNT_NAME = "account_name"; |
| 7694 | |
| 7695 | /** |
| 7696 | * The type of account to which this row belongs, which when paired with |
| 7697 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 7698 | * <P>Type: TEXT</P> |
| 7699 | */ |
| 7700 | public static final String ACCOUNT_TYPE = "account_type"; |
| 7701 | |
| 7702 | /** |
Dave Santoro | 7c4479f | 2011-09-07 16:52:27 -0700 | [diff] [blame] | 7703 | * The data set within the account that this row belongs to. This allows |
| 7704 | * multiple sync adapters for the same account type to distinguish between |
| 7705 | * each others' data. |
| 7706 | * |
| 7707 | * This is empty by default, and is completely optional. It only needs to |
| 7708 | * be populated if multiple sync adapters are entering distinct data for |
| 7709 | * the same account type and account name. |
| 7710 | * <P>Type: TEXT</P> |
| 7711 | */ |
| 7712 | public static final String DATA_SET = "data_set"; |
| 7713 | |
| 7714 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7715 | * Depending on the mode defined by the sync-adapter, this flag controls |
| 7716 | * the top-level sync behavior for this data source. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7717 | * <p> |
| 7718 | * Type: INTEGER (boolean) |
| 7719 | */ |
| 7720 | public static final String SHOULD_SYNC = "should_sync"; |
| 7721 | |
| 7722 | /** |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7723 | * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership} |
Jeff Sharkey | a659744 | 2009-08-19 09:23:33 -0700 | [diff] [blame] | 7724 | * entries should be visible in any user interface. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7725 | * <p> |
| 7726 | * Type: INTEGER (boolean) |
| 7727 | */ |
| 7728 | public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7729 | |
| 7730 | /** |
Jeff Sharkey | 97bda4c | 2009-09-15 23:15:23 -0700 | [diff] [blame] | 7731 | * Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 7732 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 7733 | * unsynced. |
| 7734 | */ |
| 7735 | public static final String ANY_UNSYNCED = "any_unsynced"; |
| 7736 | |
| 7737 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7738 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 7739 | * no {@link CommonDataKinds.GroupMembership} entries. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7740 | * <p> |
| 7741 | * Type: INTEGER |
| 7742 | */ |
| 7743 | public static final String UNGROUPED_COUNT = "summ_count"; |
| 7744 | |
| 7745 | /** |
| 7746 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 7747 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7748 | * <p> |
| 7749 | * Type: INTEGER |
| 7750 | */ |
| 7751 | public static final String UNGROUPED_WITH_PHONES = "summ_phones"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7752 | } |
| 7753 | |
| 7754 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7755 | * <p> |
| 7756 | * Contacts-specific settings for various {@link Account}'s. |
| 7757 | * </p> |
| 7758 | * <h2>Columns</h2> |
| 7759 | * <table class="jd-sumtable"> |
| 7760 | * <tr> |
| 7761 | * <th colspan='4'>Settings</th> |
| 7762 | * </tr> |
| 7763 | * <tr> |
| 7764 | * <td>String</td> |
| 7765 | * <td>{@link #ACCOUNT_NAME}</td> |
| 7766 | * <td>read/write-once</td> |
| 7767 | * <td>The name of the account instance to which this row belongs.</td> |
| 7768 | * </tr> |
| 7769 | * <tr> |
| 7770 | * <td>String</td> |
| 7771 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 7772 | * <td>read/write-once</td> |
| 7773 | * <td>The type of account to which this row belongs, which when paired with |
| 7774 | * {@link #ACCOUNT_NAME} identifies a specific account.</td> |
| 7775 | * </tr> |
| 7776 | * <tr> |
| 7777 | * <td>int</td> |
| 7778 | * <td>{@link #SHOULD_SYNC}</td> |
| 7779 | * <td>read/write</td> |
| 7780 | * <td>Depending on the mode defined by the sync-adapter, this flag controls |
| 7781 | * the top-level sync behavior for this data source.</td> |
| 7782 | * </tr> |
| 7783 | * <tr> |
| 7784 | * <td>int</td> |
| 7785 | * <td>{@link #UNGROUPED_VISIBLE}</td> |
| 7786 | * <td>read/write</td> |
| 7787 | * <td>Flag indicating if contacts without any |
| 7788 | * {@link CommonDataKinds.GroupMembership} entries should be visible in any |
| 7789 | * user interface.</td> |
| 7790 | * </tr> |
| 7791 | * <tr> |
| 7792 | * <td>int</td> |
| 7793 | * <td>{@link #ANY_UNSYNCED}</td> |
| 7794 | * <td>read-only</td> |
| 7795 | * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 7796 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 7797 | * unsynced.</td> |
| 7798 | * </tr> |
| 7799 | * <tr> |
| 7800 | * <td>int</td> |
| 7801 | * <td>{@link #UNGROUPED_COUNT}</td> |
| 7802 | * <td>read-only</td> |
| 7803 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 7804 | * no {@link CommonDataKinds.GroupMembership} entries.</td> |
| 7805 | * </tr> |
| 7806 | * <tr> |
| 7807 | * <td>int</td> |
| 7808 | * <td>{@link #UNGROUPED_WITH_PHONES}</td> |
| 7809 | * <td>read-only</td> |
| 7810 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 7811 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone |
| 7812 | * numbers.</td> |
| 7813 | * </tr> |
| 7814 | * </table> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7815 | */ |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 7816 | public static final class Settings implements SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7817 | /** |
| 7818 | * This utility class cannot be instantiated |
| 7819 | */ |
| 7820 | private Settings() { |
| 7821 | } |
| 7822 | |
| 7823 | /** |
| 7824 | * The content:// style URI for this table |
| 7825 | */ |
| 7826 | public static final Uri CONTENT_URI = |
| 7827 | Uri.withAppendedPath(AUTHORITY_URI, "settings"); |
| 7828 | |
| 7829 | /** |
| 7830 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 7831 | * settings. |
| 7832 | */ |
| 7833 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; |
| 7834 | |
| 7835 | /** |
| 7836 | * The MIME-type of {@link #CONTENT_URI} providing a single setting. |
| 7837 | */ |
| 7838 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7839 | } |
| 7840 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 7841 | /** |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 7842 | * Private API for inquiring about the general status of the provider. |
| 7843 | * |
| 7844 | * @hide |
| 7845 | */ |
| 7846 | public static final class ProviderStatus { |
| 7847 | |
| 7848 | /** |
| 7849 | * Not instantiable. |
| 7850 | */ |
| 7851 | private ProviderStatus() { |
| 7852 | } |
| 7853 | |
| 7854 | /** |
| 7855 | * The content:// style URI for this table. Requests to this URI can be |
| 7856 | * performed on the UI thread because they are always unblocking. |
| 7857 | * |
| 7858 | * @hide |
| 7859 | */ |
| 7860 | public static final Uri CONTENT_URI = |
| 7861 | Uri.withAppendedPath(AUTHORITY_URI, "provider_status"); |
| 7862 | |
| 7863 | /** |
| 7864 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 7865 | * settings. |
| 7866 | * |
| 7867 | * @hide |
| 7868 | */ |
| 7869 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status"; |
| 7870 | |
| 7871 | /** |
| 7872 | * An integer representing the current status of the provider. |
| 7873 | * |
| 7874 | * @hide |
| 7875 | */ |
| 7876 | public static final String STATUS = "status"; |
| 7877 | |
| 7878 | /** |
| 7879 | * Default status of the provider. |
| 7880 | * |
| 7881 | * @hide |
| 7882 | */ |
| 7883 | public static final int STATUS_NORMAL = 0; |
| 7884 | |
| 7885 | /** |
| 7886 | * The status used when the provider is in the process of upgrading. Contacts |
| 7887 | * are temporarily unaccessible. |
| 7888 | * |
| 7889 | * @hide |
| 7890 | */ |
| 7891 | public static final int STATUS_UPGRADING = 1; |
| 7892 | |
| 7893 | /** |
| 7894 | * The status used if the provider was in the process of upgrading but ran |
| 7895 | * out of storage. The DATA1 column will contain the estimated amount of |
| 7896 | * storage required (in bytes). Update status to STATUS_NORMAL to force |
| 7897 | * the provider to retry the upgrade. |
| 7898 | * |
| 7899 | * @hide |
| 7900 | */ |
| 7901 | public static final int STATUS_UPGRADE_OUT_OF_MEMORY = 2; |
| 7902 | |
| 7903 | /** |
| 7904 | * The status used during a locale change. |
| 7905 | * |
| 7906 | * @hide |
| 7907 | */ |
| 7908 | public static final int STATUS_CHANGING_LOCALE = 3; |
| 7909 | |
| 7910 | /** |
Dmitri Plotnikov | 37c3486 | 2010-11-12 16:12:53 -0800 | [diff] [blame] | 7911 | * The status that indicates that there are no accounts and no contacts |
| 7912 | * on the device. |
| 7913 | * |
| 7914 | * @hide |
| 7915 | */ |
| 7916 | public static final int STATUS_NO_ACCOUNTS_NO_CONTACTS = 4; |
| 7917 | |
| 7918 | /** |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 7919 | * Additional data associated with the status. |
| 7920 | * |
| 7921 | * @hide |
| 7922 | */ |
| 7923 | public static final String DATA1 = "data1"; |
| 7924 | } |
| 7925 | |
| 7926 | /** |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7927 | * <p> |
| 7928 | * API allowing applications to send usage information for each {@link Data} row to the |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 7929 | * Contacts Provider. Applications can also clear all usage information. |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7930 | * </p> |
| 7931 | * <p> |
| 7932 | * With the feedback, Contacts Provider may return more contextually appropriate results for |
| 7933 | * Data listing, typically supplied with |
| 7934 | * {@link ContactsContract.Contacts#CONTENT_FILTER_URI}, |
| 7935 | * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI}, |
| 7936 | * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit |
| 7937 | * from better ranked (sorted) lists in applications that show auto-complete list. |
| 7938 | * </p> |
| 7939 | * <p> |
| 7940 | * There is no guarantee for how this feedback is used, or even whether it is used at all. |
| 7941 | * The ranking algorithm will make best efforts to use the feedback data, but the exact |
| 7942 | * implementation, the storage data structures as well as the resulting sort order is device |
| 7943 | * and version specific and can change over time. |
| 7944 | * </p> |
| 7945 | * <p> |
| 7946 | * When updating usage information, users of this API need to use |
| 7947 | * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed |
| 7948 | * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as |
| 7949 | * its last path. They also need to append a query parameter to the Uri, to specify the type of |
| 7950 | * the communication, which enables the Contacts Provider to differentiate between kinds of |
| 7951 | * interactions using the same contact data field (for example a phone number can be used to |
| 7952 | * make phone calls or send SMS). |
| 7953 | * </p> |
| 7954 | * <p> |
| 7955 | * Selection and selectionArgs are ignored and must be set to null. To get data ids, |
| 7956 | * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)} |
| 7957 | * toward {@link Data#CONTENT_URI}. |
| 7958 | * </p> |
| 7959 | * <p> |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 7960 | * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive |
| 7961 | * integer when successful, and returns 0 if no contact with that id was found. |
| 7962 | * </p> |
| 7963 | * <p> |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7964 | * Example: |
| 7965 | * <pre> |
Daisuke Miyakawa | 52e3823 | 2011-06-14 10:56:46 -0700 | [diff] [blame] | 7966 | * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon() |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7967 | * .appendPath(TextUtils.join(",", dataIds)) |
Daisuke Miyakawa | 52e3823 | 2011-06-14 10:56:46 -0700 | [diff] [blame] | 7968 | * .appendQueryParameter(DataUsageFeedback.USAGE_TYPE, |
| 7969 | * DataUsageFeedback.USAGE_TYPE_CALL) |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7970 | * .build(); |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 7971 | * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0; |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7972 | * </pre> |
| 7973 | * </p> |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 7974 | * <p> |
| 7975 | * Applications can also clear all usage information with: |
| 7976 | * <pre> |
Makoto Onuki | 7ebbfd0 | 2012-04-13 12:56:42 -0700 | [diff] [blame] | 7977 | * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0; |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 7978 | * </pre> |
| 7979 | * </p> |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7980 | */ |
| 7981 | public static final class DataUsageFeedback { |
| 7982 | |
| 7983 | /** |
| 7984 | * The content:// style URI for sending usage feedback. |
| 7985 | * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}. |
| 7986 | */ |
| 7987 | public static final Uri FEEDBACK_URI = |
| 7988 | Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback"); |
| 7989 | |
| 7990 | /** |
Makoto Onuki | 7ebbfd0 | 2012-04-13 12:56:42 -0700 | [diff] [blame] | 7991 | * The content:// style URI for deleting all usage information. |
| 7992 | * Must be used with {@link ContentResolver#delete(Uri, String, String[])}. |
| 7993 | * The {@code where} and {@code selectionArgs} parameters are ignored. |
| 7994 | */ |
| 7995 | public static final Uri DELETE_USAGE_URI = |
| 7996 | Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage"); |
| 7997 | |
| 7998 | /** |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 7999 | * <p> |
| 8000 | * Name for query parameter specifying the type of data usage. |
| 8001 | * </p> |
| 8002 | */ |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 8003 | public static final String USAGE_TYPE = "type"; |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8004 | |
| 8005 | /** |
| 8006 | * <p> |
| 8007 | * Type of usage for voice interaction, which includes phone call, voice chat, and |
| 8008 | * video chat. |
| 8009 | * </p> |
| 8010 | */ |
| 8011 | public static final String USAGE_TYPE_CALL = "call"; |
| 8012 | |
| 8013 | /** |
| 8014 | * <p> |
| 8015 | * Type of usage for text interaction involving longer messages, which includes email. |
| 8016 | * </p> |
| 8017 | */ |
| 8018 | public static final String USAGE_TYPE_LONG_TEXT = "long_text"; |
| 8019 | |
| 8020 | /** |
| 8021 | * <p> |
| 8022 | * Type of usage for text interaction involving shorter messages, which includes SMS, |
| 8023 | * text chat with email addresses. |
| 8024 | * </p> |
| 8025 | */ |
| 8026 | public static final String USAGE_TYPE_SHORT_TEXT = "short_text"; |
| 8027 | } |
| 8028 | |
| 8029 | /** |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8030 | * <p> |
Yorke Lee | cadbe4c | 2014-06-20 11:52:27 -0700 | [diff] [blame] | 8031 | * Contact-specific information about whether or not a contact has been pinned by the user |
| 8032 | * at a particular position within the system contact application's user interface. |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8033 | * </p> |
| 8034 | * |
| 8035 | * <p> |
| 8036 | * This pinning information can be used by individual applications to customize how |
| 8037 | * they order particular pinned contacts. For example, a Dialer application could |
| 8038 | * use pinned information to order user-pinned contacts in a top row of favorites. |
| 8039 | * </p> |
| 8040 | * |
| 8041 | * <p> |
| 8042 | * It is possible for two or more contacts to occupy the same pinned position (due |
| 8043 | * to aggregation and sync), so this pinning information should be used on a best-effort |
| 8044 | * basis to order contacts in-application rather than an absolute guide on where a contact |
| 8045 | * should be positioned. Contacts returned by the ContactsProvider will not be ordered based |
| 8046 | * on this information, so it is up to the client application to reorder these contacts within |
| 8047 | * their own UI adhering to (or ignoring as appropriate) information stored in the pinned |
| 8048 | * column. |
| 8049 | * </p> |
| 8050 | * |
| 8051 | * <p> |
| 8052 | * By default, unpinned contacts will have a pinned position of |
Yorke Lee | 7d24679 | 2014-07-25 10:05:55 -0700 | [diff] [blame] | 8053 | * {@link PinnedPositions#UNPINNED}. Client-provided pinned positions can be positive |
| 8054 | * integers that are greater than 1. |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8055 | * </p> |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8056 | */ |
| 8057 | public static final class PinnedPositions { |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8058 | /** |
Yorke Lee | 0e040b0 | 2014-06-18 15:02:44 -0700 | [diff] [blame] | 8059 | * The method to invoke in order to undemote a formerly demoted contact. The contact id of |
| 8060 | * the contact must be provided as an argument. If the contact was not previously demoted, |
| 8061 | * nothing will be done. |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 8062 | * @hide |
Yorke Lee | 0e040b0 | 2014-06-18 15:02:44 -0700 | [diff] [blame] | 8063 | */ |
| 8064 | public static final String UNDEMOTE_METHOD = "undemote"; |
| 8065 | |
| 8066 | /** |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 8067 | * Undemotes a formerly demoted contact. If the contact was not previously demoted, nothing |
| 8068 | * will be done. |
| 8069 | * |
| 8070 | * @param contentResolver to perform the undemote operation on. |
| 8071 | * @param contactId the id of the contact to undemote. |
| 8072 | */ |
| 8073 | public static void undemote(ContentResolver contentResolver, long contactId) { |
| 8074 | contentResolver.call(ContactsContract.AUTHORITY_URI, PinnedPositions.UNDEMOTE_METHOD, |
| 8075 | String.valueOf(contactId), null); |
| 8076 | } |
| 8077 | |
| 8078 | /** |
Yorke Lee | b31c8ab | 2014-08-26 17:13:02 -0700 | [diff] [blame] | 8079 | * Pins a contact at a provided position, or unpins a contact. |
| 8080 | * |
| 8081 | * @param contentResolver to perform the pinning operation on. |
| 8082 | * @param pinnedPosition the position to pin the contact at. To unpin a contact, use |
| 8083 | * {@link PinnedPositions#UNPINNED}. |
| 8084 | */ |
| 8085 | public static void pin( |
| 8086 | ContentResolver contentResolver, long contactId, int pinnedPosition) { |
| 8087 | final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId)); |
| 8088 | final ContentValues values = new ContentValues(); |
| 8089 | values.put(Contacts.PINNED, pinnedPosition); |
| 8090 | contentResolver.update(uri, values, null, null); |
| 8091 | } |
| 8092 | |
| 8093 | /** |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 8094 | * Default value for the pinned position of an unpinned contact. |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8095 | */ |
Yorke Lee | 7d24679 | 2014-07-25 10:05:55 -0700 | [diff] [blame] | 8096 | public static final int UNPINNED = 0; |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8097 | |
| 8098 | /** |
Yorke Lee | 3585e1a | 2013-07-31 18:53:31 -0700 | [diff] [blame] | 8099 | * Value of pinned position for a contact that a user has indicated should be considered |
| 8100 | * of the lowest priority. It is up to the client application to determine how to present |
| 8101 | * such a contact - for example all the way at the bottom of a contact list, or simply |
| 8102 | * just hidden from view. |
| 8103 | */ |
| 8104 | public static final int DEMOTED = -1; |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8105 | } |
| 8106 | |
| 8107 | /** |
Yorke Lee | f8aadf3 | 2014-06-23 17:51:16 -0700 | [diff] [blame] | 8108 | * Helper methods to display QuickContact dialogs that display all the information belonging to |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8109 | * a specific {@link Contacts} entry. |
| 8110 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8111 | public static final class QuickContact { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8112 | /** |
Yorke Lee | f8aadf3 | 2014-06-23 17:51:16 -0700 | [diff] [blame] | 8113 | * Action used to launch the system contacts application and bring up a QuickContact dialog |
| 8114 | * for the provided {@link Contacts} entry. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8115 | */ |
Evan Millar | 5042f7e | 2009-09-30 21:28:33 -0700 | [diff] [blame] | 8116 | public static final String ACTION_QUICK_CONTACT = |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 8117 | "android.provider.action.QUICK_CONTACT"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8118 | |
| 8119 | /** |
| 8120 | * Extra used to specify pivot dialog location in screen coordinates. |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 8121 | * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8122 | * @hide |
| 8123 | */ |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 8124 | @Deprecated |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 8125 | public static final String EXTRA_TARGET_RECT = "android.provider.extra.TARGET_RECT"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8126 | |
| 8127 | /** |
| 8128 | * Extra used to specify size of pivot dialog. |
| 8129 | * @hide |
| 8130 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 8131 | public static final String EXTRA_MODE = "android.provider.extra.MODE"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8132 | |
| 8133 | /** |
Yorke Lee | f8aadf3 | 2014-06-23 17:51:16 -0700 | [diff] [blame] | 8134 | * Extra used to indicate a list of specific MIME-types to exclude and not display in the |
| 8135 | * QuickContacts dialog. Stored as a {@link String} array. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8136 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 8137 | public static final String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8138 | |
| 8139 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8140 | * Small QuickContact mode, usually presented with minimal actions. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8141 | */ |
| 8142 | public static final int MODE_SMALL = 1; |
| 8143 | |
| 8144 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8145 | * Medium QuickContact mode, includes actions and light summary describing |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8146 | * the {@link Contacts} entry being shown. This may include social |
| 8147 | * status and presence details. |
| 8148 | */ |
| 8149 | public static final int MODE_MEDIUM = 2; |
| 8150 | |
| 8151 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8152 | * Large QuickContact mode, includes actions and larger, card-like summary |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8153 | * of the {@link Contacts} entry being shown. This may include detailed |
| 8154 | * information, such as a photo. |
| 8155 | */ |
| 8156 | public static final int MODE_LARGE = 3; |
| 8157 | |
| 8158 | /** |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8159 | * Constructs the QuickContacts intent with a view's rect. |
| 8160 | * @hide |
| 8161 | */ |
| 8162 | public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri, |
| 8163 | int mode, String[] excludeMimes) { |
| 8164 | // Find location and bounds of target view, adjusting based on the |
| 8165 | // assumed local density. |
| 8166 | final float appScale = context.getResources().getCompatibilityInfo().applicationScale; |
| 8167 | final int[] pos = new int[2]; |
| 8168 | target.getLocationOnScreen(pos); |
| 8169 | |
| 8170 | final Rect rect = new Rect(); |
| 8171 | rect.left = (int) (pos[0] * appScale + 0.5f); |
| 8172 | rect.top = (int) (pos[1] * appScale + 0.5f); |
| 8173 | rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); |
| 8174 | rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); |
| 8175 | |
| 8176 | return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes); |
| 8177 | } |
| 8178 | |
| 8179 | /** |
| 8180 | * Constructs the QuickContacts intent. |
| 8181 | * @hide |
| 8182 | */ |
| 8183 | public static Intent composeQuickContactsIntent(Context context, Rect target, |
| 8184 | Uri lookupUri, int mode, String[] excludeMimes) { |
| 8185 | // When launching from an Activiy, we don't want to start a new task, but otherwise |
| 8186 | // we *must* start a new task. (Otherwise startActivity() would crash.) |
| 8187 | Context actualContext = context; |
| 8188 | while ((actualContext instanceof ContextWrapper) |
| 8189 | && !(actualContext instanceof Activity)) { |
| 8190 | actualContext = ((ContextWrapper) actualContext).getBaseContext(); |
| 8191 | } |
Brian Attwell | 9ee6640 | 2014-08-11 22:42:26 -0700 | [diff] [blame] | 8192 | final int intentFlags = ((actualContext instanceof Activity) |
| 8193 | ? 0 : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK) |
| 8194 | // Workaround for b/16898764. Declaring singleTop in manifest doesn't work. |
| 8195 | | Intent.FLAG_ACTIVITY_SINGLE_TOP; |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8196 | |
| 8197 | // Launch pivot dialog through intent for now |
| 8198 | final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags); |
| 8199 | |
| 8200 | intent.setData(lookupUri); |
| 8201 | intent.setSourceBounds(target); |
| 8202 | intent.putExtra(EXTRA_MODE, mode); |
| 8203 | intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); |
| 8204 | return intent; |
| 8205 | } |
| 8206 | |
| 8207 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8208 | * Trigger a dialog that lists the various methods of interacting with |
| 8209 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8210 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8211 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8212 | * |
| 8213 | * @param context The parent {@link Context} that may be used as the |
| 8214 | * parent for this dialog. |
| 8215 | * @param target Specific {@link View} from your layout that this dialog |
| 8216 | * should be centered around. In particular, if the dialog |
| 8217 | * has a "callout" arrow, it will be pointed and centered |
| 8218 | * around this {@link View}. |
Evan Millar | 772722e | 2009-09-30 22:24:07 -0700 | [diff] [blame] | 8219 | * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8220 | * {@link Uri} that describes a specific contact to feature |
| 8221 | * in this dialog. |
| 8222 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 8223 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 8224 | * when supported. |
| 8225 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8226 | * to exclude when showing this dialog. For example, when |
| 8227 | * already viewing the contact details card, this can be used |
| 8228 | * to omit the details entry from the dialog. |
| 8229 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8230 | public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8231 | String[] excludeMimes) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8232 | // Trigger with obtained rectangle |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8233 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, |
| 8234 | excludeMimes); |
Yorke Lee | 4fc601a | 2013-12-06 16:35:29 -0800 | [diff] [blame] | 8235 | startActivityWithErrorToast(context, intent); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8236 | } |
| 8237 | |
| 8238 | /** |
| 8239 | * Trigger a dialog that lists the various methods of interacting with |
| 8240 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8241 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8242 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8243 | * |
| 8244 | * @param context The parent {@link Context} that may be used as the |
| 8245 | * parent for this dialog. |
| 8246 | * @param target Specific {@link Rect} that this dialog should be |
| 8247 | * centered around, in screen coordinates. In particular, if |
| 8248 | * the dialog has a "callout" arrow, it will be pointed and |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 8249 | * centered around this {@link Rect}. If you are running at a |
| 8250 | * non-native density, you need to manually adjust using |
| 8251 | * {@link DisplayMetrics#density} before calling. |
Jeff Sharkey | 223bd7a | 2009-12-21 14:51:19 -0800 | [diff] [blame] | 8252 | * @param lookupUri A |
| 8253 | * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8254 | * {@link Uri} that describes a specific contact to feature |
| 8255 | * in this dialog. |
| 8256 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 8257 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 8258 | * when supported. |
| 8259 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8260 | * to exclude when showing this dialog. For example, when |
| 8261 | * already viewing the contact details card, this can be used |
| 8262 | * to omit the details entry from the dialog. |
| 8263 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8264 | public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8265 | String[] excludeMimes) { |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8266 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, |
| 8267 | excludeMimes); |
Yorke Lee | 4fc601a | 2013-12-06 16:35:29 -0800 | [diff] [blame] | 8268 | startActivityWithErrorToast(context, intent); |
| 8269 | } |
| 8270 | |
| 8271 | private static void startActivityWithErrorToast(Context context, Intent intent) { |
| 8272 | try { |
| 8273 | context.startActivity(intent); |
| 8274 | } catch (ActivityNotFoundException e) { |
| 8275 | Toast.makeText(context, com.android.internal.R.string.quick_contacts_not_available, |
| 8276 | Toast.LENGTH_SHORT).show(); |
| 8277 | } |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8278 | } |
| 8279 | } |
| 8280 | |
| 8281 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8282 | * Helper class for accessing full-size photos by photo file ID. |
| 8283 | * <p> |
| 8284 | * Usage example: |
| 8285 | * <dl> |
| 8286 | * <dt>Retrieving a full-size photo by photo file ID (see |
| 8287 | * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID}) |
| 8288 | * </dt> |
| 8289 | * <dd> |
| 8290 | * <pre> |
| 8291 | * public InputStream openDisplayPhoto(long photoFileId) { |
| 8292 | * Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey); |
| 8293 | * try { |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 8294 | * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor( |
| 8295 | * displayPhotoUri, "r"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8296 | * return fd.createInputStream(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 8297 | * } catch (IOException e) { |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8298 | * return null; |
| 8299 | * } |
| 8300 | * } |
| 8301 | * </pre> |
| 8302 | * </dd> |
| 8303 | * </dl> |
| 8304 | * </p> |
| 8305 | */ |
| 8306 | public static final class DisplayPhoto { |
| 8307 | /** |
| 8308 | * no public constructor since this is a utility class |
| 8309 | */ |
| 8310 | private DisplayPhoto() {} |
| 8311 | |
| 8312 | /** |
| 8313 | * The content:// style URI for this class, which allows access to full-size photos, |
| 8314 | * given a key. |
| 8315 | */ |
| 8316 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo"); |
| 8317 | |
| 8318 | /** |
| 8319 | * This URI allows the caller to query for the maximum dimensions of a display photo |
| 8320 | * or thumbnail. Requests to this URI can be performed on the UI thread because |
| 8321 | * they are always unblocking. |
| 8322 | */ |
| 8323 | public static final Uri CONTENT_MAX_DIMENSIONS_URI = |
| 8324 | Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions"); |
| 8325 | |
| 8326 | /** |
| 8327 | * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will |
| 8328 | * contain this column, populated with the maximum height and width (in pixels) |
| 8329 | * that will be stored for a display photo. Larger photos will be down-sized to |
| 8330 | * fit within a square of this many pixels. |
| 8331 | */ |
| 8332 | public static final String DISPLAY_MAX_DIM = "display_max_dim"; |
| 8333 | |
| 8334 | /** |
| 8335 | * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will |
| 8336 | * contain this column, populated with the height and width (in pixels) for photo |
| 8337 | * thumbnails. |
| 8338 | */ |
| 8339 | public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim"; |
| 8340 | } |
| 8341 | |
| 8342 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8343 | * Contains helper classes used to create or manage {@link android.content.Intent Intents} |
| 8344 | * that involve contacts. |
| 8345 | */ |
| 8346 | public static final class Intents { |
| 8347 | /** |
| 8348 | * This is the intent that is fired when a search suggestion is clicked on. |
| 8349 | */ |
| 8350 | public static final String SEARCH_SUGGESTION_CLICKED = |
| 8351 | "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; |
| 8352 | |
| 8353 | /** |
| 8354 | * This is the intent that is fired when a search suggestion for dialing a number |
| 8355 | * is clicked on. |
| 8356 | */ |
| 8357 | public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = |
| 8358 | "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; |
| 8359 | |
| 8360 | /** |
| 8361 | * This is the intent that is fired when a search suggestion for creating a contact |
| 8362 | * is clicked on. |
| 8363 | */ |
| 8364 | public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = |
| 8365 | "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; |
| 8366 | |
| 8367 | /** |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 8368 | * This is the intent that is fired when the contacts database is created. <p> The |
| 8369 | * READ_CONTACT permission is required to receive these broadcasts. |
| 8370 | */ |
| 8371 | public static final String CONTACTS_DATABASE_CREATED = |
| 8372 | "android.provider.Contacts.DATABASE_CREATED"; |
| 8373 | |
| 8374 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8375 | * Starts an Activity that lets the user pick a contact to attach an image to. |
| 8376 | * After picking the contact it launches the image cropper in face detection mode. |
| 8377 | */ |
| 8378 | public static final String ATTACH_IMAGE = |
| 8379 | "com.android.contacts.action.ATTACH_IMAGE"; |
| 8380 | |
| 8381 | /** |
Makoto Onuki | 85a01a6 | 2011-07-21 15:16:31 -0700 | [diff] [blame] | 8382 | * This is the intent that is fired when the user clicks the "invite to the network" button |
| 8383 | * on a contact. Only sent to an activity which is explicitly registered by a contact |
| 8384 | * provider which supports the "invite to the network" feature. |
| 8385 | * <p> |
| 8386 | * {@link Intent#getData()} contains the lookup URI for the contact. |
| 8387 | */ |
| 8388 | public static final String INVITE_CONTACT = |
| 8389 | "com.android.contacts.action.INVITE_CONTACT"; |
| 8390 | |
| 8391 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8392 | * Takes as input a data URI with a mailto: or tel: scheme. If a single |
| 8393 | * contact exists with the given data it will be shown. If no contact |
| 8394 | * exists, a dialog will ask the user if they want to create a new |
| 8395 | * contact with the provided details filled in. If multiple contacts |
| 8396 | * share the data the user will be prompted to pick which contact they |
| 8397 | * want to view. |
| 8398 | * <p> |
| 8399 | * For <code>mailto:</code> URIs, the scheme specific portion must be a |
| 8400 | * raw email address, such as one built using |
| 8401 | * {@link Uri#fromParts(String, String, String)}. |
| 8402 | * <p> |
| 8403 | * For <code>tel:</code> URIs, the scheme specific portion is compared |
| 8404 | * to existing numbers using the standard caller ID lookup algorithm. |
| 8405 | * The number must be properly encoded, for example using |
| 8406 | * {@link Uri#fromParts(String, String, String)}. |
| 8407 | * <p> |
| 8408 | * Any extras from the {@link Insert} class will be passed along to the |
| 8409 | * create activity if there are no contacts to show. |
| 8410 | * <p> |
| 8411 | * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip |
| 8412 | * prompting the user when the contact doesn't exist. |
| 8413 | */ |
| 8414 | public static final String SHOW_OR_CREATE_CONTACT = |
| 8415 | "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; |
| 8416 | |
| 8417 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8418 | * Starts an Activity that lets the user select the multiple phones from a |
| 8419 | * list of phone numbers which come from the contacts or |
| 8420 | * {@link #EXTRA_PHONE_URIS}. |
| 8421 | * <p> |
| 8422 | * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS} |
| 8423 | * could belong to the contacts or not, and will be selected by default. |
| 8424 | * <p> |
| 8425 | * The user's selection will be returned from |
| 8426 | * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)} |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 8427 | * if the resultCode is |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8428 | * {@link android.app.Activity#RESULT_OK}, the array of picked phone |
| 8429 | * numbers are in the Intent's |
| 8430 | * {@link #EXTRA_PHONE_URIS}; otherwise, the |
| 8431 | * {@link android.app.Activity#RESULT_CANCELED} is returned if the user |
| 8432 | * left the Activity without changing the selection. |
| 8433 | * |
| 8434 | * @hide |
| 8435 | */ |
| 8436 | public static final String ACTION_GET_MULTIPLE_PHONES = |
| 8437 | "com.android.contacts.action.GET_MULTIPLE_PHONES"; |
| 8438 | |
| 8439 | /** |
Makoto Onuki | 90ddc90 | 2012-09-11 18:22:53 -0700 | [diff] [blame] | 8440 | * A broadcast action which is sent when any change has been made to the profile, such |
| 8441 | * as the profile name or the picture. A receiver must have |
| 8442 | * the android.permission.READ_PROFILE permission. |
| 8443 | * |
| 8444 | * @hide |
| 8445 | */ |
| 8446 | public static final String ACTION_PROFILE_CHANGED = |
| 8447 | "android.provider.Contacts.PROFILE_CHANGED"; |
| 8448 | |
| 8449 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8450 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new |
| 8451 | * contact if no matching contact found. Otherwise, default behavior is |
| 8452 | * to prompt user with dialog before creating. |
| 8453 | * <p> |
| 8454 | * Type: BOOLEAN |
| 8455 | */ |
| 8456 | public static final String EXTRA_FORCE_CREATE = |
| 8457 | "com.android.contacts.action.FORCE_CREATE"; |
| 8458 | |
| 8459 | /** |
| 8460 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact |
| 8461 | * description to be shown when prompting user about creating a new |
| 8462 | * contact. |
| 8463 | * <p> |
| 8464 | * Type: STRING |
| 8465 | */ |
| 8466 | public static final String EXTRA_CREATE_DESCRIPTION = |
| 8467 | "com.android.contacts.action.CREATE_DESCRIPTION"; |
| 8468 | |
| 8469 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8470 | * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value. |
| 8471 | * <p> |
| 8472 | * The phone numbers want to be picked by default should be passed in as |
| 8473 | * input value. These phone numbers could belong to the contacts or not. |
| 8474 | * <p> |
| 8475 | * The phone numbers which were picked by the user are returned as output |
| 8476 | * value. |
| 8477 | * <p> |
| 8478 | * Type: array of URIs, the tel URI is used for the phone numbers which don't |
| 8479 | * 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] | 8480 | * |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 8481 | * @hide |
| 8482 | */ |
| 8483 | public static final String EXTRA_PHONE_URIS = |
| 8484 | "com.android.contacts.extra.PHONE_URIS"; |
| 8485 | |
| 8486 | /** |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 8487 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 8488 | * dialog location using screen coordinates. When not specified, the |
| 8489 | * dialog will be centered. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8490 | * |
| 8491 | * @hide |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 8492 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8493 | @Deprecated |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 8494 | public static final String EXTRA_TARGET_RECT = "target_rect"; |
| 8495 | |
| 8496 | /** |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8497 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 8498 | * desired dialog style, usually a variation on size. One of |
| 8499 | * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8500 | * |
| 8501 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8502 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8503 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8504 | public static final String EXTRA_MODE = "mode"; |
| 8505 | |
| 8506 | /** |
| 8507 | * Value for {@link #EXTRA_MODE} to show a small-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8508 | * |
| 8509 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8510 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8511 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8512 | public static final int MODE_SMALL = 1; |
| 8513 | |
| 8514 | /** |
| 8515 | * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8516 | * |
| 8517 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8518 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8519 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8520 | public static final int MODE_MEDIUM = 2; |
| 8521 | |
| 8522 | /** |
| 8523 | * Value for {@link #EXTRA_MODE} to show a large-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8524 | * |
| 8525 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8526 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8527 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 8528 | public static final int MODE_LARGE = 3; |
| 8529 | |
| 8530 | /** |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 8531 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate |
| 8532 | * a list of specific MIME-types to exclude and not display. Stored as a |
| 8533 | * {@link String} array. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8534 | * |
| 8535 | * @hide |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 8536 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8537 | @Deprecated |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 8538 | public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; |
| 8539 | |
| 8540 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8541 | * Intents related to the Contacts app UI. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8542 | * |
| 8543 | * @hide |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8544 | */ |
| 8545 | public static final class UI { |
| 8546 | /** |
| 8547 | * The action for the default contacts list tab. |
| 8548 | */ |
| 8549 | public static final String LIST_DEFAULT = |
| 8550 | "com.android.contacts.action.LIST_DEFAULT"; |
| 8551 | |
| 8552 | /** |
| 8553 | * The action for the contacts list tab. |
| 8554 | */ |
| 8555 | public static final String LIST_GROUP_ACTION = |
| 8556 | "com.android.contacts.action.LIST_GROUP"; |
| 8557 | |
| 8558 | /** |
| 8559 | * When in LIST_GROUP_ACTION mode, this is the group to display. |
| 8560 | */ |
| 8561 | public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP"; |
| 8562 | |
| 8563 | /** |
| 8564 | * The action for the all contacts list tab. |
| 8565 | */ |
| 8566 | public static final String LIST_ALL_CONTACTS_ACTION = |
| 8567 | "com.android.contacts.action.LIST_ALL_CONTACTS"; |
| 8568 | |
| 8569 | /** |
| 8570 | * The action for the contacts with phone numbers list tab. |
| 8571 | */ |
| 8572 | public static final String LIST_CONTACTS_WITH_PHONES_ACTION = |
| 8573 | "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES"; |
| 8574 | |
| 8575 | /** |
| 8576 | * The action for the starred contacts list tab. |
| 8577 | */ |
| 8578 | public static final String LIST_STARRED_ACTION = |
| 8579 | "com.android.contacts.action.LIST_STARRED"; |
| 8580 | |
| 8581 | /** |
| 8582 | * The action for the frequent contacts list tab. |
| 8583 | */ |
| 8584 | public static final String LIST_FREQUENT_ACTION = |
| 8585 | "com.android.contacts.action.LIST_FREQUENT"; |
| 8586 | |
| 8587 | /** |
Brian Attwell | e98a95c | 2014-07-22 20:53:59 -0700 | [diff] [blame] | 8588 | * The action for the "Join Contact" picker. |
| 8589 | */ |
| 8590 | public static final String PICK_JOIN_CONTACT_ACTION = |
| 8591 | "com.android.contacts.action.JOIN_CONTACT"; |
| 8592 | |
| 8593 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8594 | * The action for the "strequent" contacts list tab. It first lists the starred |
| 8595 | * contacts in alphabetical order and then the frequent contacts in descending |
| 8596 | * order of the number of times they have been contacted. |
| 8597 | */ |
| 8598 | public static final String LIST_STREQUENT_ACTION = |
| 8599 | "com.android.contacts.action.LIST_STREQUENT"; |
| 8600 | |
| 8601 | /** |
| 8602 | * A key for to be used as an intent extra to set the activity |
| 8603 | * title to a custom String value. |
| 8604 | */ |
| 8605 | public static final String TITLE_EXTRA_KEY = |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8606 | "com.android.contacts.extra.TITLE_EXTRA"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8607 | |
| 8608 | /** |
| 8609 | * Activity Action: Display a filtered list of contacts |
| 8610 | * <p> |
| 8611 | * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for |
| 8612 | * filtering |
| 8613 | * <p> |
| 8614 | * Output: Nothing. |
| 8615 | */ |
| 8616 | public static final String FILTER_CONTACTS_ACTION = |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8617 | "com.android.contacts.action.FILTER_CONTACTS"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8618 | |
| 8619 | /** |
| 8620 | * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION} |
| 8621 | * intents to supply the text on which to filter. |
| 8622 | */ |
| 8623 | public static final String FILTER_TEXT_EXTRA_KEY = |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 8624 | "com.android.contacts.extra.FILTER_TEXT"; |
Brian Attwell | e98a95c | 2014-07-22 20:53:59 -0700 | [diff] [blame] | 8625 | |
| 8626 | /** |
| 8627 | * Used with JOIN_CONTACT action to set the target for aggregation. This action type |
| 8628 | * uses contact ids instead of contact uris for the sake of backwards compatibility. |
| 8629 | * <p> |
| 8630 | * Type: LONG |
| 8631 | */ |
| 8632 | public static final String TARGET_CONTACT_ID_EXTRA_KEY |
| 8633 | = "com.android.contacts.action.CONTACT_ID"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8634 | } |
| 8635 | |
| 8636 | /** |
| 8637 | * Convenience class that contains string constants used |
| 8638 | * to create contact {@link android.content.Intent Intents}. |
| 8639 | */ |
| 8640 | public static final class Insert { |
| 8641 | /** The action code to use when adding a contact */ |
| 8642 | public static final String ACTION = Intent.ACTION_INSERT; |
| 8643 | |
| 8644 | /** |
| 8645 | * If present, forces a bypass of quick insert mode. |
| 8646 | */ |
| 8647 | public static final String FULL_MODE = "full_mode"; |
| 8648 | |
| 8649 | /** |
| 8650 | * The extra field for the contact name. |
| 8651 | * <P>Type: String</P> |
| 8652 | */ |
| 8653 | public static final String NAME = "name"; |
| 8654 | |
| 8655 | // TODO add structured name values here. |
| 8656 | |
| 8657 | /** |
| 8658 | * The extra field for the contact phonetic name. |
| 8659 | * <P>Type: String</P> |
| 8660 | */ |
| 8661 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 8662 | |
| 8663 | /** |
| 8664 | * The extra field for the contact company. |
| 8665 | * <P>Type: String</P> |
| 8666 | */ |
| 8667 | public static final String COMPANY = "company"; |
| 8668 | |
| 8669 | /** |
| 8670 | * The extra field for the contact job title. |
| 8671 | * <P>Type: String</P> |
| 8672 | */ |
| 8673 | public static final String JOB_TITLE = "job_title"; |
| 8674 | |
| 8675 | /** |
| 8676 | * The extra field for the contact notes. |
| 8677 | * <P>Type: String</P> |
| 8678 | */ |
| 8679 | public static final String NOTES = "notes"; |
| 8680 | |
| 8681 | /** |
| 8682 | * The extra field for the contact phone number. |
| 8683 | * <P>Type: String</P> |
| 8684 | */ |
| 8685 | public static final String PHONE = "phone"; |
| 8686 | |
| 8687 | /** |
| 8688 | * The extra field for the contact phone number type. |
| 8689 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8690 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8691 | * or a string specifying a custom label.</P> |
| 8692 | */ |
| 8693 | public static final String PHONE_TYPE = "phone_type"; |
| 8694 | |
| 8695 | /** |
| 8696 | * The extra field for the phone isprimary flag. |
| 8697 | * <P>Type: boolean</P> |
| 8698 | */ |
| 8699 | public static final String PHONE_ISPRIMARY = "phone_isprimary"; |
| 8700 | |
| 8701 | /** |
| 8702 | * The extra field for an optional second contact phone number. |
| 8703 | * <P>Type: String</P> |
| 8704 | */ |
| 8705 | public static final String SECONDARY_PHONE = "secondary_phone"; |
| 8706 | |
| 8707 | /** |
| 8708 | * The extra field for an optional second contact phone number type. |
| 8709 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8710 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8711 | * or a string specifying a custom label.</P> |
| 8712 | */ |
| 8713 | public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; |
| 8714 | |
| 8715 | /** |
| 8716 | * The extra field for an optional third contact phone number. |
| 8717 | * <P>Type: String</P> |
| 8718 | */ |
| 8719 | public static final String TERTIARY_PHONE = "tertiary_phone"; |
| 8720 | |
| 8721 | /** |
| 8722 | * The extra field for an optional third contact phone number type. |
| 8723 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8724 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8725 | * or a string specifying a custom label.</P> |
| 8726 | */ |
| 8727 | public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; |
| 8728 | |
| 8729 | /** |
| 8730 | * The extra field for the contact email address. |
| 8731 | * <P>Type: String</P> |
| 8732 | */ |
| 8733 | public static final String EMAIL = "email"; |
| 8734 | |
| 8735 | /** |
| 8736 | * The extra field for the contact email type. |
| 8737 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8738 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8739 | * or a string specifying a custom label.</P> |
| 8740 | */ |
| 8741 | public static final String EMAIL_TYPE = "email_type"; |
| 8742 | |
| 8743 | /** |
| 8744 | * The extra field for the email isprimary flag. |
| 8745 | * <P>Type: boolean</P> |
| 8746 | */ |
| 8747 | public static final String EMAIL_ISPRIMARY = "email_isprimary"; |
| 8748 | |
| 8749 | /** |
| 8750 | * The extra field for an optional second contact email address. |
| 8751 | * <P>Type: String</P> |
| 8752 | */ |
| 8753 | public static final String SECONDARY_EMAIL = "secondary_email"; |
| 8754 | |
| 8755 | /** |
| 8756 | * The extra field for an optional second contact email type. |
| 8757 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8758 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8759 | * or a string specifying a custom label.</P> |
| 8760 | */ |
| 8761 | public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; |
| 8762 | |
| 8763 | /** |
| 8764 | * The extra field for an optional third contact email address. |
| 8765 | * <P>Type: String</P> |
| 8766 | */ |
| 8767 | public static final String TERTIARY_EMAIL = "tertiary_email"; |
| 8768 | |
| 8769 | /** |
| 8770 | * The extra field for an optional third contact email type. |
| 8771 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8772 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8773 | * or a string specifying a custom label.</P> |
| 8774 | */ |
| 8775 | public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; |
| 8776 | |
| 8777 | /** |
| 8778 | * The extra field for the contact postal address. |
| 8779 | * <P>Type: String</P> |
| 8780 | */ |
| 8781 | public static final String POSTAL = "postal"; |
| 8782 | |
| 8783 | /** |
| 8784 | * The extra field for the contact postal address type. |
| 8785 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8786 | * {@link CommonDataKinds.StructuredPostal} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8787 | * or a string specifying a custom label.</P> |
| 8788 | */ |
| 8789 | public static final String POSTAL_TYPE = "postal_type"; |
| 8790 | |
| 8791 | /** |
| 8792 | * The extra field for the postal isprimary flag. |
| 8793 | * <P>Type: boolean</P> |
| 8794 | */ |
| 8795 | public static final String POSTAL_ISPRIMARY = "postal_isprimary"; |
| 8796 | |
| 8797 | /** |
| 8798 | * The extra field for an IM handle. |
| 8799 | * <P>Type: String</P> |
| 8800 | */ |
| 8801 | public static final String IM_HANDLE = "im_handle"; |
| 8802 | |
| 8803 | /** |
| 8804 | * The extra field for the IM protocol |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8805 | */ |
| 8806 | public static final String IM_PROTOCOL = "im_protocol"; |
| 8807 | |
| 8808 | /** |
| 8809 | * The extra field for the IM isprimary flag. |
| 8810 | * <P>Type: boolean</P> |
| 8811 | */ |
| 8812 | public static final String IM_ISPRIMARY = "im_isprimary"; |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 8813 | |
| 8814 | /** |
| 8815 | * The extra field that allows the client to supply multiple rows of |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 8816 | * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT} |
| 8817 | * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of |
| 8818 | * {@link ContentValues}, one per data row. Supplying this extra is |
| 8819 | * similar to inserting multiple rows into the {@link Data} table, |
| 8820 | * except the user gets a chance to see and edit them before saving. |
| 8821 | * Each ContentValues object must have a value for {@link Data#MIMETYPE}. |
| 8822 | * If supplied values are not visible in the editor UI, they will be |
| 8823 | * dropped. Duplicate data will dropped. Some fields |
| 8824 | * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically |
| 8825 | * adjusted to comply with the constraints of the specific account type. |
| 8826 | * For example, an Exchange contact can only have one phone numbers of type Home, |
| 8827 | * so the contact editor may choose a different type for this phone number to |
| 8828 | * avoid dropping the valueable part of the row, which is the phone number. |
| 8829 | * <p> |
| 8830 | * Example: |
| 8831 | * <pre> |
| 8832 | * ArrayList<ContentValues> data = new ArrayList<ContentValues>(); |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 8833 | * |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 8834 | * ContentValues row1 = new ContentValues(); |
| 8835 | * row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE); |
| 8836 | * row1.put(Organization.COMPANY, "Android"); |
| 8837 | * data.add(row1); |
| 8838 | * |
| 8839 | * ContentValues row2 = new ContentValues(); |
| 8840 | * row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE); |
| 8841 | * row2.put(Email.TYPE, Email.TYPE_CUSTOM); |
| 8842 | * row2.put(Email.LABEL, "Green Bot"); |
| 8843 | * row2.put(Email.ADDRESS, "android@android.com"); |
| 8844 | * data.add(row2); |
| 8845 | * |
| 8846 | * Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); |
| 8847 | * intent.putParcelableArrayListExtra(Insert.DATA, data); |
| 8848 | * |
| 8849 | * startActivity(intent); |
| 8850 | * </pre> |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 8851 | */ |
| 8852 | public static final String DATA = "data"; |
Daniel Lehmann | cde1ac6 | 2010-10-21 20:40:11 -0700 | [diff] [blame] | 8853 | |
| 8854 | /** |
| 8855 | * Used to specify the account in which to create the new contact. |
| 8856 | * <p> |
| 8857 | * If this value is not provided, the user is presented with a disambiguation |
| 8858 | * dialog to chose an account |
| 8859 | * <p> |
| 8860 | * Type: {@link Account} |
| 8861 | * |
| 8862 | * @hide |
| 8863 | */ |
| 8864 | public static final String ACCOUNT = "com.android.contacts.extra.ACCOUNT"; |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 8865 | |
| 8866 | /** |
| 8867 | * Used to specify the data set within the account in which to create the |
| 8868 | * new contact. |
| 8869 | * <p> |
| 8870 | * This value is optional - if it is not specified, the contact will be |
| 8871 | * created in the base account, with no data set. |
| 8872 | * <p> |
| 8873 | * Type: String |
| 8874 | * |
| 8875 | * @hide |
| 8876 | */ |
| 8877 | public static final String DATA_SET = "com.android.contacts.extra.DATA_SET"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8878 | } |
| 8879 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 8880 | } |