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; |
Jeff Sharkey | 0f3f60b | 2017-04-24 18:06:20 -0600 | [diff] [blame] | 20 | import android.annotation.SdkConstant; |
| 21 | import android.annotation.SdkConstant.SdkConstantType; |
Zheng Fu | 7997bee | 2015-06-09 16:50:02 -0700 | [diff] [blame] | 22 | import android.annotation.SystemApi; |
Mathew Inwood | ba50311 | 2018-08-10 09:37:35 +0100 | [diff] [blame] | 23 | import android.annotation.UnsupportedAppUsage; |
Daniel Lehmann | e6d3d28 | 2011-07-13 15:35:05 -0700 | [diff] [blame] | 24 | import android.app.Activity; |
Makoto Onuki | 2a61537 | 2017-01-30 11:59:46 -0800 | [diff] [blame] | 25 | import android.content.BroadcastReceiver; |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 26 | import android.content.ComponentName; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 27 | import android.content.ContentProviderClient; |
| 28 | import android.content.ContentProviderOperation; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 29 | import android.content.ContentResolver; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 30 | import android.content.ContentUris; |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 31 | import android.content.ContentValues; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 32 | import android.content.Context; |
Makoto Onuki | bba33cd | 2012-05-25 17:09:05 -0700 | [diff] [blame] | 33 | import android.content.ContextWrapper; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 34 | import android.content.CursorEntityIterator; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 35 | import android.content.Entity; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 36 | import android.content.EntityIterator; |
| 37 | import android.content.Intent; |
Makoto Onuki | 2a61537 | 2017-01-30 11:59:46 -0800 | [diff] [blame] | 38 | import android.content.IntentFilter; |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 39 | import android.content.res.AssetFileDescriptor; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 40 | import android.content.res.Resources; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 41 | import android.database.Cursor; |
Makoto Onuki | 93d94eb | 2016-08-25 14:24:03 -0700 | [diff] [blame] | 42 | import android.database.CursorWrapper; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 43 | import android.database.DatabaseUtils; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 44 | import android.graphics.Rect; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 45 | import android.net.Uri; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 46 | import android.os.RemoteException; |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 47 | import android.telecom.PhoneAccountHandle; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 48 | import android.text.TextUtils; |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 49 | import android.util.DisplayMetrics; |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 50 | import android.util.Pair; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 51 | import android.view.View; |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 52 | |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 53 | import java.io.ByteArrayInputStream; |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 54 | import java.io.IOException; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 55 | import java.io.InputStream; |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 56 | import java.util.ArrayList; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 57 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 58 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 59 | * <p> |
| 60 | * The contract between the contacts provider and applications. Contains |
| 61 | * definitions for the supported URIs and columns. These APIs supersede |
| 62 | * {@link Contacts}. |
| 63 | * </p> |
| 64 | * <h3>Overview</h3> |
| 65 | * <p> |
| 66 | * ContactsContract defines an extensible database of contact-related |
| 67 | * information. Contact information is stored in a three-tier data model: |
| 68 | * </p> |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 69 | * <ul> |
| 70 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 71 | * A row in the {@link Data} table can store any kind of personal data, such |
| 72 | * as a phone number or email addresses. The set of data kinds that can be |
| 73 | * stored in this table is open-ended. There is a predefined set of common |
| 74 | * kinds, but any application can add its own data kinds. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 75 | * </li> |
| 76 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 77 | * A row in the {@link RawContacts} table represents a set of data describing a |
| 78 | * person and associated with a single account (for example, one of the user's |
| 79 | * Gmail accounts). |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 80 | * </li> |
| 81 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 82 | * 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] | 83 | * RawContacts presumably describing the same person. When data in or associated with |
| 84 | * the RawContacts table is changed, the affected aggregate contacts are updated as |
| 85 | * necessary. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 86 | * </li> |
| 87 | * </ul> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 88 | * <p> |
| 89 | * Other tables include: |
| 90 | * </p> |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 91 | * <ul> |
| 92 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 93 | * {@link Groups}, which contains information about raw contact groups |
| 94 | * such as Gmail contact groups. The |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 95 | * current API does not support the notion of groups spanning multiple accounts. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 96 | * </li> |
| 97 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 98 | * {@link StatusUpdates}, which contains social status updates including IM |
| 99 | * availability. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 100 | * </li> |
| 101 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 102 | * {@link AggregationExceptions}, which is used for manual aggregation and |
| 103 | * disaggregation of raw contacts |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 104 | * </li> |
| 105 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 106 | * {@link Settings}, which contains visibility and sync settings for accounts |
| 107 | * and groups. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 108 | * </li> |
| 109 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 110 | * {@link SyncState}, which contains free-form data maintained on behalf of sync |
| 111 | * adapters |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 112 | * </li> |
| 113 | * <li> |
| 114 | * {@link PhoneLookup}, which is used for quick caller-ID lookup</li> |
| 115 | * </ul> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 116 | */ |
Jeff Hamilton | 0c23212 | 2009-09-24 00:26:50 -0500 | [diff] [blame] | 117 | @SuppressWarnings("unused") |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 118 | public final class ContactsContract { |
| 119 | /** The authority for the contacts provider */ |
| 120 | public static final String AUTHORITY = "com.android.contacts"; |
| 121 | /** A content:// style uri to the authority for the contacts provider */ |
| 122 | public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); |
| 123 | |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 124 | /** |
Makoto Onuki | 203145e | 2016-09-28 15:41:29 -0700 | [diff] [blame] | 125 | * Prefix for column names that are not visible to client apps. |
| 126 | * @hide |
| 127 | */ |
| 128 | public static final String HIDDEN_COLUMN_PREFIX = "x_"; |
| 129 | |
| 130 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 131 | * An optional URI parameter for insert, update, or delete queries |
| 132 | * that allows the caller |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 133 | * 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] | 134 | * {@link RawContacts#DIRTY} is not automatically set and the |
| 135 | * "syncToNetwork" parameter is set to false when calling |
| 136 | * {@link |
| 137 | * ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}. |
| 138 | * This prevents an unnecessary extra synchronization, see the discussion of |
| 139 | * the delete operation in {@link RawContacts}. |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 140 | */ |
| 141 | public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter"; |
| 142 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 143 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 144 | * Query parameter that should be used by the client to access a specific |
| 145 | * {@link Directory}. The parameter value should be the _ID of the corresponding |
| 146 | * directory, e.g. |
| 147 | * {@code content://com.android.contacts/data/emails/filter/acme?directory=3} |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 148 | */ |
| 149 | public static final String DIRECTORY_PARAM_KEY = "directory"; |
| 150 | |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 151 | /** |
Makoto Onuki | 93d94eb | 2016-08-25 14:24:03 -0700 | [diff] [blame] | 152 | * A query parameter that limits the number of results returned for supported URIs. The |
Dmitri Plotnikov | 5a998dd | 2010-08-31 17:32:16 -0700 | [diff] [blame] | 153 | * parameter value should be an integer. |
Makoto Onuki | 93d94eb | 2016-08-25 14:24:03 -0700 | [diff] [blame] | 154 | * |
| 155 | * <p>This parameter is not supported by all URIs. Supported URIs include, but not limited to, |
| 156 | * {@link Contacts#CONTENT_URI}, |
| 157 | * {@link RawContacts#CONTENT_URI}, |
| 158 | * {@link Data#CONTENT_URI}, |
| 159 | * {@link CommonDataKinds.Phone#CONTENT_URI}, |
| 160 | * {@link CommonDataKinds.Callable#CONTENT_URI}, |
| 161 | * {@link CommonDataKinds.Email#CONTENT_URI}, |
| 162 | * {@link CommonDataKinds.Contactables#CONTENT_URI}, |
| 163 | * |
| 164 | * <p>In order to limit the number of rows returned by a non-supported URI, you can implement a |
| 165 | * {@link CursorWrapper} and override the {@link CursorWrapper#getCount()} methods. |
Dmitri Plotnikov | 5a998dd | 2010-08-31 17:32:16 -0700 | [diff] [blame] | 166 | */ |
| 167 | public static final String LIMIT_PARAM_KEY = "limit"; |
| 168 | |
| 169 | /** |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 170 | * A query parameter specifing a primary account. This parameter should be used with |
| 171 | * {@link #PRIMARY_ACCOUNT_TYPE}. The contacts provider handling a query may rely on |
| 172 | * this information to optimize its query results. |
| 173 | * |
| 174 | * For example, in an email composition screen, its implementation can specify an account when |
| 175 | * obtaining possible recipients, letting the provider know which account is selected during |
| 176 | * the composition. The provider may use the "primary account" information to optimize |
| 177 | * the search result. |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 178 | */ |
| 179 | public static final String PRIMARY_ACCOUNT_NAME = "name_for_primary_account"; |
| 180 | |
| 181 | /** |
| 182 | * A query parameter specifing a primary account. This parameter should be used with |
| 183 | * {@link #PRIMARY_ACCOUNT_NAME}. See the doc in {@link #PRIMARY_ACCOUNT_NAME}. |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 184 | */ |
| 185 | public static final String PRIMARY_ACCOUNT_TYPE = "type_for_primary_account"; |
| 186 | |
Daisuke Miyakawa | f468591 | 2011-06-25 12:31:13 -0700 | [diff] [blame] | 187 | /** |
| 188 | * A boolean parameter for {@link Contacts#CONTENT_STREQUENT_URI} and |
| 189 | * {@link Contacts#CONTENT_STREQUENT_FILTER_URI}, which requires the ContactsProvider to |
| 190 | * return only phone-related results. For example, frequently contacted person list should |
| 191 | * include persons contacted via phone (not email, sms, etc.) |
Daisuke Miyakawa | f468591 | 2011-06-25 12:31:13 -0700 | [diff] [blame] | 192 | */ |
| 193 | public static final String STREQUENT_PHONE_ONLY = "strequent_phone_only"; |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 194 | |
| 195 | /** |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 196 | * A key to a boolean in the "extras" bundle of the cursor. |
| 197 | * The boolean indicates that the provider did not create a snippet and that the client asking |
| 198 | * for the snippet should do it (true means the snippeting was deferred to the client). |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 199 | * |
| 200 | * @see SearchSnippets |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 201 | */ |
| 202 | public static final String DEFERRED_SNIPPETING = "deferred_snippeting"; |
| 203 | |
| 204 | /** |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 205 | * 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] | 206 | * |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 207 | * @see SearchSnippets |
| 208 | * @see #DEFERRED_SNIPPETING |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 209 | */ |
| 210 | public static final String DEFERRED_SNIPPETING_QUERY = "deferred_snippeting_query"; |
| 211 | |
| 212 | /** |
Yorke Lee | 1ca440b | 2014-06-04 18:01:46 -0700 | [diff] [blame] | 213 | * A boolean parameter for {@link CommonDataKinds.Phone#CONTENT_URI Phone.CONTENT_URI}, |
| 214 | * {@link CommonDataKinds.Email#CONTENT_URI Email.CONTENT_URI}, and |
| 215 | * {@link CommonDataKinds.StructuredPostal#CONTENT_URI StructuredPostal.CONTENT_URI}. |
Daisuke Miyakawa | 19352e0 | 2011-11-14 13:16:07 -0800 | [diff] [blame] | 216 | * This enables a content provider to remove duplicate entries in results. |
Daisuke Miyakawa | 19352e0 | 2011-11-14 13:16:07 -0800 | [diff] [blame] | 217 | */ |
| 218 | public static final String REMOVE_DUPLICATE_ENTRIES = "remove_duplicate_entries"; |
| 219 | |
| 220 | /** |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 221 | * <p> |
| 222 | * API for obtaining a pre-authorized version of a URI that normally requires special |
| 223 | * permission (beyond READ_CONTACTS) to read. The caller obtaining the pre-authorized URI |
| 224 | * must already have the necessary permissions to access the URI; otherwise a |
Brian Attwell | cc4b2f7 | 2015-01-08 14:58:15 -0800 | [diff] [blame] | 225 | * {@link SecurityException} will be thrown. Unlike {@link Context#grantUriPermission}, |
| 226 | * this can be used to grant permissions that aren't explicitly required for the URI inside |
| 227 | * AndroidManifest.xml. For example, permissions that are only required when reading URIs |
| 228 | * that refer to the user's profile. |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 229 | * </p> |
| 230 | * <p> |
| 231 | * The authorized URI returned in the bundle contains an expiring token that allows the |
| 232 | * caller to execute the query without having the special permissions that would normally |
Brian Attwell | cc4b2f7 | 2015-01-08 14:58:15 -0800 | [diff] [blame] | 233 | * be required. The token expires in five minutes. |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 234 | * </p> |
| 235 | * <p> |
| 236 | * This API does not access disk, and should be safe to invoke from the UI thread. |
| 237 | * </p> |
| 238 | * <p> |
| 239 | * Example usage: |
| 240 | * <pre> |
| 241 | * Uri profileUri = ContactsContract.Profile.CONTENT_VCARD_URI; |
| 242 | * Bundle uriBundle = new Bundle(); |
| 243 | * uriBundle.putParcelable(ContactsContract.Authorization.KEY_URI_TO_AUTHORIZE, uri); |
| 244 | * Bundle authResponse = getContext().getContentResolver().call( |
| 245 | * ContactsContract.AUTHORITY_URI, |
| 246 | * ContactsContract.Authorization.AUTHORIZATION_METHOD, |
| 247 | * null, // String arg, not used. |
| 248 | * uriBundle); |
| 249 | * if (authResponse != null) { |
| 250 | * Uri preauthorizedProfileUri = (Uri) authResponse.getParcelable( |
| 251 | * ContactsContract.Authorization.KEY_AUTHORIZED_URI); |
| 252 | * // This pre-authorized URI can be queried by a caller without READ_PROFILE |
| 253 | * // permission. |
| 254 | * } |
| 255 | * </pre> |
| 256 | * </p> |
Brian Attwell | 7d383b9 | 2015-05-14 15:25:01 -0700 | [diff] [blame] | 257 | * |
| 258 | * @hide |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 259 | */ |
| 260 | public static final class Authorization { |
| 261 | /** |
| 262 | * The method to invoke to create a pre-authorized URI out of the input argument. |
| 263 | */ |
| 264 | public static final String AUTHORIZATION_METHOD = "authorize"; |
| 265 | |
| 266 | /** |
| 267 | * The key to set in the outbound Bundle with the URI that should be authorized. |
| 268 | */ |
| 269 | public static final String KEY_URI_TO_AUTHORIZE = "uri_to_authorize"; |
| 270 | |
| 271 | /** |
| 272 | * The key to retrieve from the returned Bundle to obtain the pre-authorized URI. |
| 273 | */ |
| 274 | public static final String KEY_AUTHORIZED_URI = "authorized_uri"; |
| 275 | } |
| 276 | |
Yorke Lee | 6355c8f | 2014-07-08 11:48:42 -0700 | [diff] [blame] | 277 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 278 | * A Directory represents a contacts corpus, e.g. Local contacts, |
| 279 | * Google Apps Global Address List or Corporate Global Address List. |
| 280 | * <p> |
| 281 | * A Directory is implemented as a content provider with its unique authority and |
| 282 | * the same API as the main Contacts Provider. However, there is no expectation that |
| 283 | * every directory provider will implement this Contract in its entirety. If a |
| 284 | * directory provider does not have an implementation for a specific request, it |
| 285 | * should throw an UnsupportedOperationException. |
| 286 | * </p> |
| 287 | * <p> |
| 288 | * 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] | 289 | * expected to support at least {@link ContactsContract.Contacts#CONTENT_FILTER_URI |
| 290 | * Contacts.CONTENT_FILTER_URI}. If a Directory provider wants to participate |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 291 | * in email and phone lookup functionalities, it should also implement |
| 292 | * {@link CommonDataKinds.Email#CONTENT_FILTER_URI CommonDataKinds.Email.CONTENT_FILTER_URI} |
| 293 | * and |
| 294 | * {@link CommonDataKinds.Phone#CONTENT_FILTER_URI CommonDataKinds.Phone.CONTENT_FILTER_URI}. |
| 295 | * </p> |
| 296 | * <p> |
| 297 | * A directory provider should return NULL for every projection field it does not |
| 298 | * recognize, rather than throwing an exception. This way it will not be broken |
| 299 | * if ContactsContract is extended with new fields in the future. |
| 300 | * </p> |
| 301 | * <p> |
| 302 | * The client interacts with a directory via Contacts Provider by supplying an |
| 303 | * optional {@code directory=} query parameter. |
| 304 | * <p> |
| 305 | * <p> |
| 306 | * When the Contacts Provider receives the request, it transforms the URI and forwards |
| 307 | * the request to the corresponding directory content provider. |
| 308 | * The URI is transformed in the following fashion: |
| 309 | * <ul> |
| 310 | * <li>The URI authority is replaced with the corresponding {@link #DIRECTORY_AUTHORITY}.</li> |
| 311 | * <li>The {@code accountName=} and {@code accountType=} parameters are added or |
| 312 | * 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] | 313 | * </ul> |
| 314 | * </p> |
| 315 | * <p> |
| 316 | * Clients should send directory requests to Contacts Provider and let it |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 317 | * forward them to the respective providers rather than constructing |
| 318 | * directory provider URIs by themselves. This level of indirection allows |
| 319 | * Contacts Provider to implement additional system-level features and |
| 320 | * optimizations. Access to Contacts Provider is protected by the |
Subir Jhanb | 603af61 | 2012-08-06 17:19:22 -0700 | [diff] [blame] | 321 | * READ_CONTACTS permission, but access to the directory provider is protected by |
| 322 | * BIND_DIRECTORY_SEARCH. This permission was introduced at the API level 17, for previous |
| 323 | * platform versions the provider should perform the following check to make sure the call |
| 324 | * is coming from the ContactsProvider: |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 325 | * <pre> |
| 326 | * private boolean isCallerAllowed() { |
| 327 | * PackageManager pm = getContext().getPackageManager(); |
| 328 | * for (String packageName: pm.getPackagesForUid(Binder.getCallingUid())) { |
| 329 | * if (packageName.equals("com.android.providers.contacts")) { |
| 330 | * return true; |
| 331 | * } |
| 332 | * } |
| 333 | * return false; |
| 334 | * } |
| 335 | * </pre> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 336 | * </p> |
| 337 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 338 | * The Directory table is read-only and is maintained by the Contacts Provider |
| 339 | * automatically. |
| 340 | * </p> |
| 341 | * <p>It always has at least these two rows: |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 342 | * <ul> |
| 343 | * <li> |
| 344 | * The local directory. It has {@link Directory#_ID Directory._ID} = |
| 345 | * {@link Directory#DEFAULT Directory.DEFAULT}. This directory can be used to access locally |
| 346 | * stored contacts. The same can be achieved by omitting the {@code directory=} |
| 347 | * parameter altogether. |
| 348 | * </li> |
| 349 | * <li> |
| 350 | * The local invisible contacts. The corresponding directory ID is |
| 351 | * {@link Directory#LOCAL_INVISIBLE Directory.LOCAL_INVISIBLE}. |
| 352 | * </li> |
| 353 | * </ul> |
| 354 | * </p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 355 | * <p>Custom Directories are discovered by the Contacts Provider following this procedure: |
| 356 | * <ul> |
| 357 | * <li>It finds all installed content providers with meta data identifying them |
| 358 | * as directory providers in AndroidManifest.xml: |
| 359 | * <code> |
| 360 | * <meta-data android:name="android.content.ContactDirectory" |
| 361 | * android:value="true" /> |
| 362 | * </code> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 363 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 364 | * This tag should be placed inside the corresponding content provider declaration. |
| 365 | * </p> |
| 366 | * </li> |
| 367 | * <li> |
| 368 | * Then Contacts Provider sends a {@link Directory#CONTENT_URI Directory.CONTENT_URI} |
| 369 | * query to each of the directory authorities. A directory provider must implement |
| 370 | * this query and return a list of directories. Each directory returned by |
| 371 | * the provider must have a unique combination for the {@link #ACCOUNT_NAME} and |
| 372 | * {@link #ACCOUNT_TYPE} columns (nulls are allowed). Since directory IDs are assigned |
| 373 | * automatically, the _ID field will not be part of the query projection. |
| 374 | * </li> |
| 375 | * <li>Contacts Provider compiles directory lists received from all directory |
| 376 | * providers into one, assigns each individual directory a globally unique ID and |
| 377 | * stores all directory records in the Directory table. |
| 378 | * </li> |
| 379 | * </ul> |
| 380 | * </p> |
| 381 | * <p>Contacts Provider automatically interrogates newly installed or replaced packages. |
| 382 | * Thus simply installing a package containing a directory provider is sufficient |
| 383 | * to have that provider registered. A package supplying a directory provider does |
| 384 | * not have to contain launchable activities. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 385 | * </p> |
| 386 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 387 | * Every row in the Directory table is automatically associated with the corresponding package |
| 388 | * (apk). If the package is later uninstalled, all corresponding directory rows |
| 389 | * are automatically removed from the Contacts Provider. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 390 | * </p> |
| 391 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 392 | * When the list of directories handled by a directory provider changes |
| 393 | * (for instance when the user adds a new Directory account), the directory provider |
| 394 | * should call {@link #notifyDirectoryChange} to notify the Contacts Provider of the change. |
| 395 | * In response, the Contacts Provider will requery the directory provider to obtain the |
| 396 | * new list of directories. |
| 397 | * </p> |
| 398 | * <p> |
| 399 | * A directory row can be optionally associated with an existing account |
| 400 | * (see {@link android.accounts.AccountManager}). If the account is later removed, |
Dmitri Plotnikov | e50ed08 | 2010-08-18 10:56:09 -0700 | [diff] [blame] | 401 | * the corresponding directory rows are automatically removed from the Contacts Provider. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 402 | * </p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 403 | */ |
| 404 | public static final class Directory implements BaseColumns { |
| 405 | |
| 406 | /** |
| 407 | * Not instantiable. |
| 408 | */ |
| 409 | private Directory() { |
| 410 | } |
| 411 | |
| 412 | /** |
| 413 | * The content:// style URI for this table. Requests to this URI can be |
| 414 | * performed on the UI thread because they are always unblocking. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 415 | */ |
| 416 | public static final Uri CONTENT_URI = |
| 417 | Uri.withAppendedPath(AUTHORITY_URI, "directories"); |
| 418 | |
| 419 | /** |
Ricky Wai | 28ef5c5 | 2015-11-23 11:05:50 +0000 | [diff] [blame] | 420 | * URI used for getting all directories from primary and managed profile. |
| 421 | * It supports the same semantics as {@link #CONTENT_URI} and returns the same columns. |
| 422 | * If the device has no managed profile that is linked to the current profile, it behaves |
| 423 | * in the exact same way as {@link #CONTENT_URI}. |
| 424 | * If there is a managed profile linked to the current profile, it will merge |
| 425 | * managed profile and current profile's results and return. |
| 426 | * |
| 427 | * Note: this query returns primary profile results before managed profile results, |
| 428 | * and this order is not affected by sorting parameter. |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 429 | * |
| 430 | */ |
Ricky Wai | 28ef5c5 | 2015-11-23 11:05:50 +0000 | [diff] [blame] | 431 | public static final Uri ENTERPRISE_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 432 | "directories_enterprise"); |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 433 | |
| 434 | /** |
Victor Chang | dc0406d | 2016-01-14 21:02:06 +0000 | [diff] [blame] | 435 | * Access file provided by remote directory. It allows both personal and work remote |
| 436 | * directory, but not local and invisible diretory. |
| 437 | * |
| 438 | * It's supported only by a few specific places for referring to contact pictures in the |
| 439 | * remote directory. Contact picture URIs, e.g. |
| 440 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}, may contain this kind of URI. |
| 441 | * |
| 442 | * @hide |
| 443 | */ |
| 444 | public static final Uri ENTERPRISE_FILE_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 445 | "directory_file_enterprise"); |
| 446 | |
| 447 | |
| 448 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 449 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 450 | * contact directories. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 451 | */ |
| 452 | public static final String CONTENT_TYPE = |
| 453 | "vnd.android.cursor.dir/contact_directories"; |
| 454 | |
| 455 | /** |
| 456 | * The MIME type of a {@link #CONTENT_URI} item. |
| 457 | */ |
| 458 | public static final String CONTENT_ITEM_TYPE = |
| 459 | "vnd.android.cursor.item/contact_directory"; |
| 460 | |
| 461 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 462 | * _ID of the default directory, which represents locally stored contacts. |
Makoto Onuki | 93d94eb | 2016-08-25 14:24:03 -0700 | [diff] [blame] | 463 | * <b>This is only supported by {@link ContactsContract.Contacts#CONTENT_URI} and |
| 464 | * {@link ContactsContract.Contacts#CONTENT_FILTER_URI}. |
| 465 | * Other URLs do not support the concept of "visible" or "invisible" contacts. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 466 | */ |
| 467 | public static final long DEFAULT = 0; |
| 468 | |
| 469 | /** |
| 470 | * _ID of the directory that represents locally stored invisible contacts. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 471 | */ |
| 472 | public static final long LOCAL_INVISIBLE = 1; |
| 473 | |
| 474 | /** |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 475 | * _ID of the work profile default directory, which represents locally stored contacts. |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 476 | */ |
| 477 | public static final long ENTERPRISE_DEFAULT = Directory.ENTERPRISE_DIRECTORY_ID_BASE |
| 478 | + DEFAULT; |
| 479 | |
| 480 | /** |
| 481 | * _ID of the work profile directory that represents locally stored invisible contacts. |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 482 | */ |
| 483 | public static final long ENTERPRISE_LOCAL_INVISIBLE = Directory.ENTERPRISE_DIRECTORY_ID_BASE |
| 484 | + LOCAL_INVISIBLE; |
| 485 | |
| 486 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 487 | * The name of the package that owns this directory. Contacts Provider |
| 488 | * fill it in with the name of the package containing the directory provider. |
| 489 | * If the package is later uninstalled, the directories it owns are |
| 490 | * automatically removed from this table. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 491 | * |
| 492 | * <p>TYPE: TEXT</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 493 | */ |
| 494 | public static final String PACKAGE_NAME = "packageName"; |
| 495 | |
| 496 | /** |
| 497 | * The type of directory captured as a resource ID in the context of the |
| 498 | * package {@link #PACKAGE_NAME}, e.g. "Corporate Directory" |
| 499 | * |
| 500 | * <p>TYPE: INTEGER</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 501 | */ |
| 502 | public static final String TYPE_RESOURCE_ID = "typeResourceId"; |
| 503 | |
| 504 | /** |
| 505 | * An optional name that can be used in the UI to represent this directory, |
| 506 | * e.g. "Acme Corp" |
| 507 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 508 | */ |
| 509 | public static final String DISPLAY_NAME = "displayName"; |
| 510 | |
| 511 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 512 | * <p> |
| 513 | * The authority of the Directory Provider. Contacts Provider will |
| 514 | * use this authority to forward requests to the directory provider. |
| 515 | * A directory provider can leave this column empty - Contacts Provider will fill it in. |
| 516 | * </p> |
| 517 | * <p> |
| 518 | * Clients of this API should not send requests directly to this authority. |
| 519 | * All directory requests must be routed through Contacts Provider. |
| 520 | * </p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 521 | * |
| 522 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 523 | */ |
| 524 | public static final String DIRECTORY_AUTHORITY = "authority"; |
| 525 | |
| 526 | /** |
| 527 | * The account type which this directory is associated. |
| 528 | * |
| 529 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 530 | */ |
| 531 | public static final String ACCOUNT_TYPE = "accountType"; |
| 532 | |
| 533 | /** |
| 534 | * The account with which this directory is associated. If the account is later |
| 535 | * removed, the directories it owns are automatically removed from this table. |
| 536 | * |
| 537 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 538 | */ |
| 539 | public static final String ACCOUNT_NAME = "accountName"; |
| 540 | |
| 541 | /** |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 542 | * Mimimal ID for corp directory returned from |
| 543 | * {@link Directory#CORP_CONTENT_URI}. |
| 544 | * |
| 545 | * @hide |
| 546 | */ |
| 547 | // slightly smaller than 2 ** 30 |
| 548 | public static final long ENTERPRISE_DIRECTORY_ID_BASE = 1000000000; |
| 549 | |
| 550 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 551 | * One of {@link #EXPORT_SUPPORT_NONE}, {@link #EXPORT_SUPPORT_ANY_ACCOUNT}, |
| 552 | * {@link #EXPORT_SUPPORT_SAME_ACCOUNT_ONLY}. This is the expectation the |
| 553 | * directory has for data exported from it. Clients must obey this setting. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 554 | */ |
| 555 | public static final String EXPORT_SUPPORT = "exportSupport"; |
| 556 | |
| 557 | /** |
| 558 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 559 | * does not allow any data to be copied out of it. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 560 | */ |
| 561 | public static final int EXPORT_SUPPORT_NONE = 0; |
| 562 | |
| 563 | /** |
| 564 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 565 | * allow its data copied only to the account specified by |
| 566 | * {@link #ACCOUNT_TYPE}/{@link #ACCOUNT_NAME}. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 567 | */ |
| 568 | public static final int EXPORT_SUPPORT_SAME_ACCOUNT_ONLY = 1; |
| 569 | |
| 570 | /** |
| 571 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 572 | * allow its data copied to any contacts account. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 573 | */ |
| 574 | public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2; |
| 575 | |
| 576 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 577 | * One of {@link #SHORTCUT_SUPPORT_NONE}, {@link #SHORTCUT_SUPPORT_DATA_ITEMS_ONLY}, |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 578 | * {@link #SHORTCUT_SUPPORT_FULL}. This is the expectation the directory |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 579 | * has for shortcuts created for its elements. Clients must obey this setting. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 580 | */ |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 581 | public static final String SHORTCUT_SUPPORT = "shortcutSupport"; |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 582 | |
| 583 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 584 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 585 | * does not allow any shortcuts created for its contacts. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 586 | */ |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 587 | public static final int SHORTCUT_SUPPORT_NONE = 0; |
| 588 | |
| 589 | /** |
| 590 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 591 | * allow creation of shortcuts for data items like email, phone or postal address, |
| 592 | * but not the entire contact. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 593 | */ |
| 594 | public static final int SHORTCUT_SUPPORT_DATA_ITEMS_ONLY = 1; |
| 595 | |
| 596 | /** |
| 597 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 598 | * allow creation of shortcuts for contact as well as their constituent elements. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 599 | */ |
| 600 | public static final int SHORTCUT_SUPPORT_FULL = 2; |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 601 | |
| 602 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 603 | * One of {@link #PHOTO_SUPPORT_NONE}, {@link #PHOTO_SUPPORT_THUMBNAIL_ONLY}, |
| 604 | * {@link #PHOTO_SUPPORT_FULL}. This is a feature flag indicating the extent |
| 605 | * to which the directory supports contact photos. |
| 606 | */ |
| 607 | public static final String PHOTO_SUPPORT = "photoSupport"; |
| 608 | |
| 609 | /** |
| 610 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 611 | * does not provide any photos. |
| 612 | */ |
| 613 | public static final int PHOTO_SUPPORT_NONE = 0; |
| 614 | |
| 615 | /** |
| 616 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 617 | * can only produce small size thumbnails of contact photos. |
| 618 | */ |
| 619 | public static final int PHOTO_SUPPORT_THUMBNAIL_ONLY = 1; |
| 620 | |
| 621 | /** |
| 622 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 623 | * has full-size contact photos, but cannot provide scaled thumbnails. |
| 624 | */ |
| 625 | public static final int PHOTO_SUPPORT_FULL_SIZE_ONLY = 2; |
| 626 | |
| 627 | /** |
| 628 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 629 | * can produce thumbnails as well as full-size contact photos. |
| 630 | */ |
| 631 | public static final int PHOTO_SUPPORT_FULL = 3; |
| 632 | |
| 633 | /** |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 634 | * Return TRUE if it is a remote stored directory. |
| 635 | */ |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 636 | public static boolean isRemoteDirectoryId(long directoryId) { |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 637 | return directoryId != Directory.DEFAULT |
| 638 | && directoryId != Directory.LOCAL_INVISIBLE |
| 639 | && directoryId != Directory.ENTERPRISE_DEFAULT |
| 640 | && directoryId != Directory.ENTERPRISE_LOCAL_INVISIBLE; |
| 641 | } |
| 642 | |
| 643 | /** |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 644 | * Return TRUE if it is a remote stored directory. TODO: Remove this method once all |
| 645 | * internal apps are not using this API. |
| 646 | * |
| 647 | * @hide |
| 648 | */ |
| 649 | public static boolean isRemoteDirectory(long directoryId) { |
| 650 | return isRemoteDirectoryId(directoryId); |
| 651 | } |
| 652 | |
| 653 | /** |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 654 | * Return TRUE if a directory ID is from the contacts provider on the enterprise profile. |
| 655 | * |
| 656 | */ |
| 657 | public static boolean isEnterpriseDirectoryId(long directoryId) { |
| 658 | return directoryId >= ENTERPRISE_DIRECTORY_ID_BASE; |
| 659 | } |
| 660 | |
| 661 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 662 | * Notifies the system of a change in the list of directories handled by |
| 663 | * a particular directory provider. The Contacts provider will turn around |
| 664 | * and send a query to the directory provider for the full list of directories, |
| 665 | * which will replace the previous list. |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 666 | */ |
| 667 | public static void notifyDirectoryChange(ContentResolver resolver) { |
| 668 | // This is done to trigger a query by Contacts Provider back to the directory provider. |
| 669 | // No data needs to be sent back, because the provider can infer the calling |
| 670 | // package from binder. |
| 671 | ContentValues contentValues = new ContentValues(); |
| 672 | resolver.update(Directory.CONTENT_URI, contentValues, null, null); |
| 673 | } |
Makoto Onuki | 296a5fd | 2016-10-12 13:18:08 -0700 | [diff] [blame] | 674 | |
| 675 | /** |
| 676 | * A query parameter that's passed to directory providers which indicates the client |
| 677 | * package name that has made the query requests. |
| 678 | */ |
| 679 | public static final String CALLER_PACKAGE_PARAM_KEY = "callerPackage"; |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 680 | } |
| 681 | |
| 682 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 683 | * @hide should be removed when users are updated to refer to SyncState |
| 684 | * @deprecated use SyncState instead |
| 685 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 686 | @Deprecated |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 687 | public interface SyncStateColumns extends SyncStateContract.Columns { |
| 688 | } |
| 689 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 690 | /** |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 691 | * 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] | 692 | * |
| 693 | * @see SyncStateContract |
| 694 | */ |
| 695 | public static final class SyncState implements SyncStateContract.Columns { |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 696 | /** |
| 697 | * This utility class cannot be instantiated |
| 698 | */ |
| 699 | private SyncState() {} |
| 700 | |
| 701 | public static final String CONTENT_DIRECTORY = |
| 702 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 703 | |
| 704 | /** |
| 705 | * The content:// style URI for this table |
| 706 | */ |
| 707 | public static final Uri CONTENT_URI = |
| 708 | Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY); |
| 709 | |
| 710 | /** |
| 711 | * @see android.provider.SyncStateContract.Helpers#get |
| 712 | */ |
| 713 | public static byte[] get(ContentProviderClient provider, Account account) |
| 714 | throws RemoteException { |
| 715 | return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| 716 | } |
| 717 | |
| 718 | /** |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 719 | * @see android.provider.SyncStateContract.Helpers#get |
| 720 | */ |
| 721 | public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) |
| 722 | throws RemoteException { |
| 723 | return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); |
| 724 | } |
| 725 | |
| 726 | /** |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 727 | * @see android.provider.SyncStateContract.Helpers#set |
| 728 | */ |
| 729 | public static void set(ContentProviderClient provider, Account account, byte[] data) |
| 730 | throws RemoteException { |
| 731 | SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| 732 | } |
| 733 | |
| 734 | /** |
| 735 | * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| 736 | */ |
| 737 | public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| 738 | return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| 739 | } |
| 740 | } |
| 741 | |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 742 | |
| 743 | /** |
| 744 | * A table provided for sync adapters to use for storing private sync state data for the |
| 745 | * user's personal profile. |
| 746 | * |
| 747 | * @see SyncStateContract |
| 748 | */ |
| 749 | public static final class ProfileSyncState implements SyncStateContract.Columns { |
| 750 | /** |
| 751 | * This utility class cannot be instantiated |
| 752 | */ |
| 753 | private ProfileSyncState() {} |
| 754 | |
| 755 | public static final String CONTENT_DIRECTORY = |
| 756 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 757 | |
| 758 | /** |
| 759 | * The content:// style URI for this table |
| 760 | */ |
| 761 | public static final Uri CONTENT_URI = |
| 762 | Uri.withAppendedPath(Profile.CONTENT_URI, CONTENT_DIRECTORY); |
| 763 | |
| 764 | /** |
| 765 | * @see android.provider.SyncStateContract.Helpers#get |
| 766 | */ |
| 767 | public static byte[] get(ContentProviderClient provider, Account account) |
| 768 | throws RemoteException { |
| 769 | return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| 770 | } |
| 771 | |
| 772 | /** |
| 773 | * @see android.provider.SyncStateContract.Helpers#get |
| 774 | */ |
| 775 | public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) |
| 776 | throws RemoteException { |
| 777 | return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); |
| 778 | } |
| 779 | |
| 780 | /** |
| 781 | * @see android.provider.SyncStateContract.Helpers#set |
| 782 | */ |
| 783 | public static void set(ContentProviderClient provider, Account account, byte[] data) |
| 784 | throws RemoteException { |
| 785 | SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| 786 | } |
| 787 | |
| 788 | /** |
| 789 | * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| 790 | */ |
| 791 | public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| 792 | return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| 793 | } |
| 794 | } |
| 795 | |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 796 | /** |
| 797 | * Generic columns for use by sync adapters. The specific functions of |
| 798 | * these columns are private to the sync adapter. Other clients of the API |
| 799 | * should not attempt to either read or write this column. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 800 | * |
| 801 | * @see RawContacts |
| 802 | * @see Groups |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 803 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 804 | protected interface BaseSyncColumns { |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 805 | |
| 806 | /** Generic column for use by sync adapters. */ |
| 807 | public static final String SYNC1 = "sync1"; |
| 808 | /** Generic column for use by sync adapters. */ |
| 809 | public static final String SYNC2 = "sync2"; |
| 810 | /** Generic column for use by sync adapters. */ |
| 811 | public static final String SYNC3 = "sync3"; |
| 812 | /** Generic column for use by sync adapters. */ |
| 813 | public static final String SYNC4 = "sync4"; |
| 814 | } |
| 815 | |
| 816 | /** |
| 817 | * Columns that appear when each row of a table belongs to a specific |
| 818 | * account, including sync information that an account may need. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 819 | * |
| 820 | * @see RawContacts |
| 821 | * @see Groups |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 822 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 823 | protected interface SyncColumns extends BaseSyncColumns { |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 824 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 825 | * The name of the account instance to which this row belongs, which when paired with |
| 826 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 827 | * <P>Type: TEXT</P> |
| 828 | */ |
| 829 | public static final String ACCOUNT_NAME = "account_name"; |
| 830 | |
| 831 | /** |
| 832 | * The type of account to which this row belongs, which when paired with |
| 833 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 834 | * <P>Type: TEXT</P> |
| 835 | */ |
| 836 | public static final String ACCOUNT_TYPE = "account_type"; |
| 837 | |
| 838 | /** |
| 839 | * String that uniquely identifies this row to its source account. |
| 840 | * <P>Type: TEXT</P> |
| 841 | */ |
| 842 | public static final String SOURCE_ID = "sourceid"; |
| 843 | |
| 844 | /** |
| 845 | * Version number that is updated whenever this row or its related data |
| 846 | * changes. |
| 847 | * <P>Type: INTEGER</P> |
| 848 | */ |
| 849 | public static final String VERSION = "version"; |
| 850 | |
| 851 | /** |
| 852 | * Flag indicating that {@link #VERSION} has changed, and this row needs |
| 853 | * to be synchronized by its owning account. |
| 854 | * <P>Type: INTEGER (boolean)</P> |
| 855 | */ |
| 856 | public static final String DIRTY = "dirty"; |
| 857 | } |
| 858 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 859 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 860 | * Columns of {@link ContactsContract.Contacts} that track the user's |
| 861 | * preferences for, or interactions with, the contact. |
| 862 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 863 | * @see Contacts |
| 864 | * @see RawContacts |
| 865 | * @see ContactsContract.Data |
| 866 | * @see PhoneLookup |
| 867 | * @see ContactsContract.Contacts.AggregationSuggestions |
| 868 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 869 | protected interface ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 870 | /** |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 871 | * The number of times a contact has been contacted. |
| 872 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete. For |
| 873 | * more information, see the |
| 874 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 875 | * page.</p> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 876 | * <P>Type: INTEGER</P> |
| 877 | */ |
| 878 | public static final String TIMES_CONTACTED = "times_contacted"; |
| 879 | |
| 880 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 881 | * The last time a contact was contacted. |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 882 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete. For |
| 883 | * more information, see the |
| 884 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 885 | * page.</p> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 886 | * <P>Type: INTEGER</P> |
| 887 | */ |
| 888 | public static final String LAST_TIME_CONTACTED = "last_time_contacted"; |
| 889 | |
Makoto Onuki | 203145e | 2016-09-28 15:41:29 -0700 | [diff] [blame] | 890 | /** @hide Raw value. */ |
| 891 | public static final String RAW_TIMES_CONTACTED = HIDDEN_COLUMN_PREFIX + TIMES_CONTACTED; |
| 892 | |
| 893 | /** @hide Raw value. */ |
| 894 | public static final String RAW_LAST_TIME_CONTACTED = |
| 895 | HIDDEN_COLUMN_PREFIX + LAST_TIME_CONTACTED; |
| 896 | |
| 897 | /** |
| 898 | * @hide |
| 899 | * Low res version. Same as {@link #TIMES_CONTACTED} but use it in CP2 for clarification. |
| 900 | */ |
| 901 | public static final String LR_TIMES_CONTACTED = TIMES_CONTACTED; |
| 902 | |
| 903 | /** |
| 904 | * @hide |
| 905 | * Low res version. Same as {@link #TIMES_CONTACTED} but use it in CP2 for clarification. |
| 906 | */ |
| 907 | public static final String LR_LAST_TIME_CONTACTED = LAST_TIME_CONTACTED; |
| 908 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 909 | /** |
| 910 | * Is the contact starred? |
| 911 | * <P>Type: INTEGER (boolean)</P> |
| 912 | */ |
| 913 | public static final String STARRED = "starred"; |
| 914 | |
| 915 | /** |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 916 | * The position at which the contact is pinned. If {@link PinnedPositions#UNPINNED}, |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 917 | * the contact is not pinned. Also see {@link PinnedPositions}. |
| 918 | * <P>Type: INTEGER </P> |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 919 | */ |
| 920 | public static final String PINNED = "pinned"; |
| 921 | |
| 922 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 923 | * URI for a custom ringtone associated with the contact. If null or missing, |
| 924 | * the default ringtone is used. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 925 | * <P>Type: TEXT (URI to the ringtone)</P> |
| 926 | */ |
| 927 | public static final String CUSTOM_RINGTONE = "custom_ringtone"; |
| 928 | |
| 929 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 930 | * Whether the contact should always be sent to voicemail. If missing, |
| 931 | * defaults to false. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 932 | * <P>Type: INTEGER (0 for false, 1 for true)</P> |
| 933 | */ |
| 934 | public static final String SEND_TO_VOICEMAIL = "send_to_voicemail"; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 935 | } |
| 936 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 937 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 938 | * Columns of {@link ContactsContract.Contacts} that refer to intrinsic |
| 939 | * properties of the contact, as opposed to the user-specified options |
| 940 | * found in {@link ContactOptionsColumns}. |
| 941 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 942 | * @see Contacts |
| 943 | * @see ContactsContract.Data |
| 944 | * @see PhoneLookup |
| 945 | * @see ContactsContract.Contacts.AggregationSuggestions |
| 946 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 947 | protected interface ContactsColumns { |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 948 | /** |
| 949 | * The display name for the contact. |
| 950 | * <P>Type: TEXT</P> |
| 951 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 952 | public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY; |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 953 | |
| 954 | /** |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 955 | * Reference to the row in the RawContacts table holding the contact name. |
| 956 | * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 957 | */ |
| 958 | public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id"; |
| 959 | |
| 960 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 961 | * Reference to the row in the data table holding the photo. A photo can |
| 962 | * be referred to either by ID (this field) or by URI (see {@link #PHOTO_THUMBNAIL_URI} |
| 963 | * and {@link #PHOTO_URI}). |
| 964 | * If PHOTO_ID is null, consult {@link #PHOTO_URI} or {@link #PHOTO_THUMBNAIL_URI}, |
| 965 | * which is a more generic mechanism for referencing the contact photo, especially for |
| 966 | * contacts returned by non-local directories (see {@link Directory}). |
| 967 | * |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 968 | * <P>Type: INTEGER REFERENCES data(_id)</P> |
| 969 | */ |
| 970 | public static final String PHOTO_ID = "photo_id"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 971 | |
| 972 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 973 | * Photo file ID of the full-size photo. If present, this will be used to populate |
| 974 | * {@link #PHOTO_URI}. The ID can also be used with |
| 975 | * {@link ContactsContract.DisplayPhoto#CONTENT_URI} to create a URI to the photo. |
| 976 | * If this is present, {@link #PHOTO_ID} is also guaranteed to be populated. |
| 977 | * |
| 978 | * <P>Type: INTEGER</P> |
| 979 | */ |
| 980 | public static final String PHOTO_FILE_ID = "photo_file_id"; |
| 981 | |
| 982 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 983 | * 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] | 984 | * If PHOTO_FILE_ID is not null, this will be populated with a URI based off |
| 985 | * {@link ContactsContract.DisplayPhoto#CONTENT_URI}. Otherwise, this will |
| 986 | * be populated with the same value as {@link #PHOTO_THUMBNAIL_URI}. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 987 | * 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] | 988 | * (see {@link #PHOTO_ID}). If either PHOTO_FILE_ID or PHOTO_ID is not null, |
| 989 | * PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily |
| 990 | * vice versa). Thus using PHOTO_URI is a more robust method of retrieving |
| 991 | * contact photos. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 992 | * |
| 993 | * <P>Type: TEXT</P> |
| 994 | */ |
| 995 | public static final String PHOTO_URI = "photo_uri"; |
| 996 | |
| 997 | /** |
| 998 | * A URI that can be used to retrieve a thumbnail of the contact's photo. |
| 999 | * A photo can be referred to either by a URI (this field or {@link #PHOTO_URI}) |
| 1000 | * or by ID (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and |
| 1001 | * PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa). |
| 1002 | * If the content provider does not differentiate between full-size photos |
| 1003 | * and thumbnail photos, PHOTO_THUMBNAIL_URI and {@link #PHOTO_URI} can contain |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1004 | * 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] | 1005 | * |
| 1006 | * <P>Type: TEXT</P> |
| 1007 | */ |
| 1008 | public static final String PHOTO_THUMBNAIL_URI = "photo_thumb_uri"; |
| 1009 | |
| 1010 | /** |
Brian Attwell | 2fa85d3 | 2014-03-04 17:41:13 -0800 | [diff] [blame] | 1011 | * Flag that reflects whether the contact exists inside the default directory. |
| 1012 | * Ie, whether the contact is designed to only be visible outside search. |
Brian Attwell | 2fa85d3 | 2014-03-04 17:41:13 -0800 | [diff] [blame] | 1013 | */ |
| 1014 | public static final String IN_DEFAULT_DIRECTORY = "in_default_directory"; |
| 1015 | |
| 1016 | /** |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 1017 | * Flag that reflects the {@link Groups#GROUP_VISIBLE} state of any |
| 1018 | * {@link CommonDataKinds.GroupMembership} for this contact. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1019 | */ |
| 1020 | public static final String IN_VISIBLE_GROUP = "in_visible_group"; |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 1021 | |
| 1022 | /** |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 1023 | * Flag that reflects whether this contact represents the user's |
| 1024 | * personal profile entry. |
| 1025 | */ |
| 1026 | public static final String IS_USER_PROFILE = "is_user_profile"; |
| 1027 | |
| 1028 | /** |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 1029 | * An indicator of whether this contact has at least one phone number. "1" if there is |
| 1030 | * at least one phone number, "0" otherwise. |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 1031 | * <P>Type: INTEGER</P> |
| 1032 | */ |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 1033 | public static final String HAS_PHONE_NUMBER = "has_phone_number"; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1034 | |
| 1035 | /** |
| 1036 | * An opaque value that contains hints on how to find the contact if |
| 1037 | * its row id changed as a result of a sync or aggregation. |
| 1038 | */ |
| 1039 | public static final String LOOKUP_KEY = "lookup"; |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 1040 | |
| 1041 | /** |
| 1042 | * Timestamp (milliseconds since epoch) of when this contact was last updated. This |
| 1043 | * includes updates to all data associated with this contact including raw contacts. Any |
| 1044 | * modification (including deletes and inserts) of underlying contact data are also |
| 1045 | * reflected in this timestamp. |
| 1046 | */ |
| 1047 | public static final String CONTACT_LAST_UPDATED_TIMESTAMP = |
| 1048 | "contact_last_updated_timestamp"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1049 | } |
| 1050 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1051 | /** |
| 1052 | * @see Contacts |
| 1053 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 1054 | protected interface ContactStatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 1055 | /** |
| 1056 | * Contact presence status. See {@link StatusUpdates} for individual status |
| 1057 | * definitions. |
| 1058 | * <p>Type: NUMBER</p> |
| 1059 | */ |
| 1060 | public static final String CONTACT_PRESENCE = "contact_presence"; |
| 1061 | |
| 1062 | /** |
Vasu Nori | fb5bccf | 2010-07-19 14:11:54 -0700 | [diff] [blame] | 1063 | * Contact Chat Capabilities. See {@link StatusUpdates} for individual |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 1064 | * definitions. |
| 1065 | * <p>Type: NUMBER</p> |
| 1066 | */ |
| 1067 | public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability"; |
| 1068 | |
| 1069 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 1070 | * Contact's latest status update. |
| 1071 | * <p>Type: TEXT</p> |
| 1072 | */ |
| 1073 | public static final String CONTACT_STATUS = "contact_status"; |
| 1074 | |
| 1075 | /** |
| 1076 | * The absolute time in milliseconds when the latest status was |
| 1077 | * inserted/updated. |
| 1078 | * <p>Type: NUMBER</p> |
| 1079 | */ |
| 1080 | public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts"; |
| 1081 | |
| 1082 | /** |
| 1083 | * The package containing resources for this status: label and icon. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1084 | * <p>Type: TEXT</p> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 1085 | */ |
| 1086 | public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package"; |
| 1087 | |
| 1088 | /** |
| 1089 | * The resource ID of the label describing the source of contact |
| 1090 | * status, e.g. "Google Talk". This resource is scoped by the |
| 1091 | * {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 1092 | * <p>Type: NUMBER</p> |
| 1093 | */ |
| 1094 | public static final String CONTACT_STATUS_LABEL = "contact_status_label"; |
| 1095 | |
| 1096 | /** |
| 1097 | * The resource ID of the icon for the source of contact status. This |
| 1098 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 1099 | * <p>Type: NUMBER</p> |
| 1100 | */ |
| 1101 | public static final String CONTACT_STATUS_ICON = "contact_status_icon"; |
| 1102 | } |
| 1103 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1104 | /** |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1105 | * Constants for various styles of combining given name, family name etc into |
| 1106 | * a full name. For example, the western tradition follows the pattern |
| 1107 | * 'given name' 'middle name' 'family name' with the alternative pattern being |
| 1108 | * 'family name', 'given name' 'middle name'. The CJK tradition is |
| 1109 | * 'family name' 'middle name' 'given name', with Japanese favoring a space between |
| 1110 | * the names and Chinese omitting the space. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1111 | */ |
| 1112 | public interface FullNameStyle { |
| 1113 | public static final int UNDEFINED = 0; |
| 1114 | public static final int WESTERN = 1; |
| 1115 | |
| 1116 | /** |
| 1117 | * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine |
| 1118 | * which specific language it belongs to: Chinese, Japanese or Korean. |
| 1119 | */ |
| 1120 | public static final int CJK = 2; |
| 1121 | |
| 1122 | public static final int CHINESE = 3; |
| 1123 | public static final int JAPANESE = 4; |
| 1124 | public static final int KOREAN = 5; |
| 1125 | } |
| 1126 | |
| 1127 | /** |
| 1128 | * 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] | 1129 | */ |
| 1130 | public interface PhoneticNameStyle { |
| 1131 | public static final int UNDEFINED = 0; |
| 1132 | |
| 1133 | /** |
| 1134 | * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly |
| 1135 | * shown in UIs, but used for searches and sorting. |
| 1136 | */ |
| 1137 | public static final int PINYIN = 3; |
| 1138 | |
| 1139 | /** |
| 1140 | * Hiragana and Katakana are two common styles of writing out the pronunciation |
| 1141 | * of a Japanese names. |
| 1142 | */ |
| 1143 | public static final int JAPANESE = 4; |
| 1144 | |
| 1145 | /** |
| 1146 | * Hangul is the Korean phonetic alphabet. |
| 1147 | */ |
| 1148 | public static final int KOREAN = 5; |
| 1149 | } |
| 1150 | |
| 1151 | /** |
Dmitri Plotnikov | dbcdbf2 | 2011-02-23 15:49:58 -0800 | [diff] [blame] | 1152 | * Types of data used to produce the display name for a contact. In the order |
| 1153 | * of increasing priority: {@link #EMAIL}, {@link #PHONE}, |
Brian Attwell | 643db51 | 2015-03-04 21:05:27 -0800 | [diff] [blame] | 1154 | * {@link #ORGANIZATION}, {@link #NICKNAME}, {@link #STRUCTURED_PHONETIC_NAME}, |
| 1155 | * {@link #STRUCTURED_NAME}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1156 | */ |
| 1157 | public interface DisplayNameSources { |
| 1158 | public static final int UNDEFINED = 0; |
| 1159 | public static final int EMAIL = 10; |
| 1160 | public static final int PHONE = 20; |
| 1161 | public static final int ORGANIZATION = 30; |
| 1162 | public static final int NICKNAME = 35; |
Brian Attwell | 643db51 | 2015-03-04 21:05:27 -0800 | [diff] [blame] | 1163 | /** Display name comes from a structured name that only has phonetic components. */ |
| 1164 | public static final int STRUCTURED_PHONETIC_NAME = 37; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1165 | public static final int STRUCTURED_NAME = 40; |
| 1166 | } |
| 1167 | |
| 1168 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 1169 | * Contact name and contact name metadata columns in the RawContacts table. |
| 1170 | * |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1171 | * @see Contacts |
| 1172 | * @see RawContacts |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1173 | */ |
| 1174 | protected interface ContactNameColumns { |
| 1175 | |
| 1176 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1177 | * 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] | 1178 | * structured name or email address. See {@link DisplayNameSources}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1179 | */ |
| 1180 | public static final String DISPLAY_NAME_SOURCE = "display_name_source"; |
| 1181 | |
| 1182 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1183 | * <p> |
| 1184 | * The standard text shown as the contact's display name, based on the best |
| 1185 | * available information for the contact (for example, it might be the email address |
| 1186 | * if the name is not available). |
| 1187 | * The information actually used to compute the name is stored in |
| 1188 | * {@link #DISPLAY_NAME_SOURCE}. |
| 1189 | * </p> |
| 1190 | * <p> |
| 1191 | * A contacts provider is free to choose whatever representation makes most |
| 1192 | * sense for its target market. |
| 1193 | * For example in the default Android Open Source Project implementation, |
| 1194 | * if the display name is |
| 1195 | * based on the structured name and the structured name follows |
| 1196 | * the Western full-name style, then this field contains the "given name first" |
| 1197 | * version of the full name. |
| 1198 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1199 | * |
| 1200 | * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1201 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1202 | public static final String DISPLAY_NAME_PRIMARY = "display_name"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1203 | |
| 1204 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1205 | * <p> |
| 1206 | * An alternative representation of the display name, such as "family name first" |
| 1207 | * instead of "given name first" for Western names. If an alternative is not |
| 1208 | * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}. |
| 1209 | * </p> |
| 1210 | * <p> |
| 1211 | * A contacts provider is free to provide alternatives as necessary for |
| 1212 | * its target market. |
| 1213 | * For example the default Android Open Source Project contacts provider |
| 1214 | * currently provides an |
| 1215 | * alternative in a single case: if the display name is |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1216 | * based on the structured name and the structured name follows |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1217 | * the Western full name style, then the field contains the "family name first" |
| 1218 | * version of the full name. |
| 1219 | * Other cases may be added later. |
| 1220 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1221 | */ |
| 1222 | public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt"; |
| 1223 | |
| 1224 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1225 | * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}. See |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 1226 | * {@link PhoneticNameStyle}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1227 | */ |
| 1228 | public static final String PHONETIC_NAME_STYLE = "phonetic_name_style"; |
| 1229 | |
| 1230 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1231 | * <p> |
| 1232 | * Pronunciation of the full name in the phonetic alphabet specified by |
| 1233 | * {@link #PHONETIC_NAME_STYLE}. |
| 1234 | * </p> |
| 1235 | * <p> |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 1236 | * The value may be set manually by the user. This capability is of |
| 1237 | * interest only in countries with commonly used phonetic alphabets, |
| 1238 | * such as Japan and Korea. See {@link PhoneticNameStyle}. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1239 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1240 | */ |
| 1241 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 1242 | |
| 1243 | /** |
| 1244 | * Sort key that takes into account locale-based traditions for sorting |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1245 | * names in address books. The default |
| 1246 | * sort key is {@link #DISPLAY_NAME_PRIMARY}. For Chinese names |
| 1247 | * 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] | 1248 | * it is the Hiragana version of the phonetic name. |
| 1249 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1250 | public static final String SORT_KEY_PRIMARY = "sort_key"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1251 | |
| 1252 | /** |
| 1253 | * Sort key based on the alternative representation of the full name, |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1254 | * {@link #DISPLAY_NAME_ALTERNATIVE}. Thus for Western names, |
Dmitri Plotnikov | 2a650dd | 2010-01-26 17:28:52 -0800 | [diff] [blame] | 1255 | * it is the one using the "family name first" format. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1256 | */ |
| 1257 | public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt"; |
| 1258 | } |
| 1259 | |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1260 | interface ContactCounts { |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1261 | |
| 1262 | /** |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1263 | * Add this query parameter to a URI to get back row counts grouped by the address book |
| 1264 | * index as cursor extras. For most languages it is the first letter of the sort key. This |
| 1265 | * parameter does not affect the main content of the cursor. |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1266 | * |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1267 | * <p> |
| 1268 | * <pre> |
| 1269 | * Example: |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1270 | * |
| 1271 | * import android.provider.ContactsContract.Contacts; |
| 1272 | * |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1273 | * Uri uri = Contacts.CONTENT_URI.buildUpon() |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1274 | * .appendQueryParameter(Contacts.EXTRA_ADDRESS_BOOK_INDEX, "true") |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1275 | * .build(); |
| 1276 | * Cursor cursor = getContentResolver().query(uri, |
| 1277 | * new String[] {Contacts.DISPLAY_NAME}, |
| 1278 | * null, null, null); |
| 1279 | * Bundle bundle = cursor.getExtras(); |
Yorke Lee | a4aa9dc | 2014-08-04 13:47:50 -0700 | [diff] [blame] | 1280 | * if (bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES) && |
| 1281 | * bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS)) { |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1282 | * String sections[] = |
Yorke Lee | a4aa9dc | 2014-08-04 13:47:50 -0700 | [diff] [blame] | 1283 | * bundle.getStringArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES); |
| 1284 | * int counts[] = bundle.getIntArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS); |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1285 | * } |
| 1286 | * </pre> |
| 1287 | * </p> |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1288 | */ |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1289 | public static final String EXTRA_ADDRESS_BOOK_INDEX = |
| 1290 | "android.provider.extra.ADDRESS_BOOK_INDEX"; |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1291 | |
| 1292 | /** |
| 1293 | * The array of address book index titles, which are returned in the |
| 1294 | * same order as the data in the cursor. |
| 1295 | * <p>TYPE: String[]</p> |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1296 | */ |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1297 | public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES = |
| 1298 | "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES"; |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1299 | |
| 1300 | /** |
| 1301 | * The array of group counts for the corresponding group. Contains the same number |
| 1302 | * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array. |
| 1303 | * <p>TYPE: int[]</p> |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1304 | */ |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1305 | public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = |
| 1306 | "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS"; |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1307 | } |
| 1308 | |
| 1309 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1310 | * Constants for the contacts table, which contains a record per aggregate |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1311 | * of raw contacts representing the same person. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1312 | * <h3>Operations</h3> |
| 1313 | * <dl> |
| 1314 | * <dt><b>Insert</b></dt> |
| 1315 | * <dd>A Contact cannot be created explicitly. When a raw contact is |
| 1316 | * inserted, the provider will first try to find a Contact representing the |
| 1317 | * same person. If one is found, the raw contact's |
| 1318 | * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate |
| 1319 | * Contact. If no match is found, the provider automatically inserts a new |
| 1320 | * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column |
| 1321 | * of the newly inserted raw contact.</dd> |
| 1322 | * <dt><b>Update</b></dt> |
| 1323 | * <dd>Only certain columns of Contact are modifiable: |
| 1324 | * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED}, |
| 1325 | * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of |
| 1326 | * these columns on the Contact also changes them on all constituent raw |
| 1327 | * contacts.</dd> |
| 1328 | * <dt><b>Delete</b></dt> |
| 1329 | * <dd>Be careful with deleting Contacts! Deleting an aggregate contact |
| 1330 | * deletes all constituent raw contacts. The corresponding sync adapters |
| 1331 | * will notice the deletions of their respective raw contacts and remove |
| 1332 | * them from their back end storage.</dd> |
| 1333 | * <dt><b>Query</b></dt> |
| 1334 | * <dd> |
| 1335 | * <ul> |
| 1336 | * <li>If you need to read an individual contact, consider using |
| 1337 | * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li> |
| 1338 | * <li>If you need to look up a contact by the phone number, use |
| 1339 | * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI}, |
| 1340 | * which is optimized for this purpose.</li> |
| 1341 | * <li>If you need to look up a contact by partial name, e.g. to produce |
| 1342 | * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI. |
| 1343 | * <li>If you need to look up a contact by some data element like email |
| 1344 | * address, nickname, etc, use a query against the {@link ContactsContract.Data} table. |
| 1345 | * The result will contain contact ID, name etc. |
| 1346 | * </ul> |
| 1347 | * </dd> |
| 1348 | * </dl> |
| 1349 | * <h2>Columns</h2> |
| 1350 | * <table class="jd-sumtable"> |
| 1351 | * <tr> |
| 1352 | * <th colspan='4'>Contacts</th> |
| 1353 | * </tr> |
| 1354 | * <tr> |
| 1355 | * <td>long</td> |
| 1356 | * <td>{@link #_ID}</td> |
| 1357 | * <td>read-only</td> |
| 1358 | * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td> |
| 1359 | * </tr> |
| 1360 | * <tr> |
| 1361 | * <td>String</td> |
| 1362 | * <td>{@link #LOOKUP_KEY}</td> |
| 1363 | * <td>read-only</td> |
| 1364 | * <td>An opaque value that contains hints on how to find the contact if its |
| 1365 | * row id changed as a result of a sync or aggregation.</td> |
| 1366 | * </tr> |
| 1367 | * <tr> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1368 | * <td>long</td> |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1369 | * <td>NAME_RAW_CONTACT_ID</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1370 | * <td>read-only</td> |
| 1371 | * <td>The ID of the raw contact that contributes the display name |
| 1372 | * to the aggregate contact. During aggregation one of the constituent |
| 1373 | * raw contacts is chosen using a heuristic: a longer name or a name |
| 1374 | * with more diacritic marks or more upper case characters is chosen.</td> |
| 1375 | * </tr> |
| 1376 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1377 | * <td>String</td> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1378 | * <td>DISPLAY_NAME_PRIMARY</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1379 | * <td>read-only</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1380 | * <td>The display name for the contact. It is the display name |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1381 | * 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] | 1382 | * column.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1383 | * </tr> |
| 1384 | * <tr> |
| 1385 | * <td>long</td> |
| 1386 | * <td>{@link #PHOTO_ID}</td> |
| 1387 | * <td>read-only</td> |
| 1388 | * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo. |
| 1389 | * That row has the mime type |
| 1390 | * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field |
| 1391 | * is computed automatically based on the |
| 1392 | * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of |
| 1393 | * that mime type.</td> |
| 1394 | * </tr> |
| 1395 | * <tr> |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 1396 | * <td>long</td> |
| 1397 | * <td>{@link #PHOTO_URI}</td> |
| 1398 | * <td>read-only</td> |
| 1399 | * <td>A URI that can be used to retrieve the contact's full-size photo. This |
| 1400 | * column is the preferred method of retrieving the contact photo.</td> |
| 1401 | * </tr> |
| 1402 | * <tr> |
| 1403 | * <td>long</td> |
| 1404 | * <td>{@link #PHOTO_THUMBNAIL_URI}</td> |
| 1405 | * <td>read-only</td> |
| 1406 | * <td>A URI that can be used to retrieve the thumbnail of contact's photo. This |
| 1407 | * column is the preferred method of retrieving the contact photo.</td> |
| 1408 | * </tr> |
| 1409 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1410 | * <td>int</td> |
| 1411 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 1412 | * <td>read-only</td> |
| 1413 | * <td>An indicator of whether this contact is supposed to be visible in the |
| 1414 | * UI. "1" if the contact has at least one raw contact that belongs to a |
| 1415 | * visible group; "0" otherwise.</td> |
| 1416 | * </tr> |
| 1417 | * <tr> |
| 1418 | * <td>int</td> |
| 1419 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 1420 | * <td>read-only</td> |
| 1421 | * <td>An indicator of whether this contact has at least one phone number. |
| 1422 | * "1" if there is at least one phone number, "0" otherwise.</td> |
| 1423 | * </tr> |
| 1424 | * <tr> |
| 1425 | * <td>int</td> |
| 1426 | * <td>{@link #TIMES_CONTACTED}</td> |
| 1427 | * <td>read/write</td> |
| 1428 | * <td>The number of times the contact has been contacted. See |
| 1429 | * {@link #markAsContacted}. When raw contacts are aggregated, this field is |
| 1430 | * computed automatically as the maximum number of times contacted among all |
| 1431 | * constituent raw contacts. Setting this field automatically changes the |
| 1432 | * corresponding field on all constituent raw contacts.</td> |
| 1433 | * </tr> |
| 1434 | * <tr> |
| 1435 | * <td>long</td> |
| 1436 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 1437 | * <td>read/write</td> |
| 1438 | * <td>The timestamp of the last time the contact was contacted. See |
| 1439 | * {@link #markAsContacted}. Setting this field also automatically |
| 1440 | * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated, |
| 1441 | * this field is computed automatically as the latest time contacted of all |
| 1442 | * constituent raw contacts. Setting this field automatically changes the |
| 1443 | * corresponding field on all constituent raw contacts.</td> |
| 1444 | * </tr> |
| 1445 | * <tr> |
| 1446 | * <td>int</td> |
| 1447 | * <td>{@link #STARRED}</td> |
| 1448 | * <td>read/write</td> |
| 1449 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
| 1450 | * When raw contacts are aggregated, this field is automatically computed: |
| 1451 | * if any constituent raw contacts are starred, then this field is set to |
| 1452 | * '1'. Setting this field automatically changes the corresponding field on |
| 1453 | * all constituent raw contacts.</td> |
| 1454 | * </tr> |
| 1455 | * <tr> |
| 1456 | * <td>String</td> |
| 1457 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 1458 | * <td>read/write</td> |
| 1459 | * <td>A custom ringtone associated with a contact. Typically this is the |
| 1460 | * URI returned by an activity launched with the |
| 1461 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td> |
| 1462 | * </tr> |
| 1463 | * <tr> |
| 1464 | * <td>int</td> |
| 1465 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 1466 | * <td>read/write</td> |
| 1467 | * <td>An indicator of whether calls from this contact should be forwarded |
| 1468 | * directly to voice mail ('1') or not ('0'). When raw contacts are |
| 1469 | * aggregated, this field is automatically computed: if <i>all</i> |
| 1470 | * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set |
| 1471 | * to '1'. Setting this field automatically changes the corresponding field |
| 1472 | * on all constituent raw contacts.</td> |
| 1473 | * </tr> |
| 1474 | * <tr> |
| 1475 | * <td>int</td> |
| 1476 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 1477 | * <td>read-only</td> |
| 1478 | * <td>Contact IM presence status. See {@link StatusUpdates} for individual |
| 1479 | * status definitions. Automatically computed as the highest presence of all |
| 1480 | * constituent raw contacts. The provider may choose not to store this value |
| 1481 | * in persistent storage. The expectation is that presence status will be |
kmccormick | 50e27c8 | 2013-03-28 16:33:11 -0700 | [diff] [blame] | 1482 | * updated on a regular basis.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1483 | * </tr> |
| 1484 | * <tr> |
| 1485 | * <td>String</td> |
| 1486 | * <td>{@link #CONTACT_STATUS}</td> |
| 1487 | * <td>read-only</td> |
| 1488 | * <td>Contact's latest status update. Automatically computed as the latest |
| 1489 | * of all constituent raw contacts' status updates.</td> |
| 1490 | * </tr> |
| 1491 | * <tr> |
| 1492 | * <td>long</td> |
| 1493 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 1494 | * <td>read-only</td> |
| 1495 | * <td>The absolute time in milliseconds when the latest status was |
| 1496 | * inserted/updated.</td> |
| 1497 | * </tr> |
| 1498 | * <tr> |
| 1499 | * <td>String</td> |
| 1500 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 1501 | * <td>read-only</td> |
| 1502 | * <td> The package containing resources for this status: label and icon.</td> |
| 1503 | * </tr> |
| 1504 | * <tr> |
| 1505 | * <td>long</td> |
| 1506 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 1507 | * <td>read-only</td> |
| 1508 | * <td>The resource ID of the label describing the source of contact status, |
| 1509 | * e.g. "Google Talk". This resource is scoped by the |
| 1510 | * {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1511 | * </tr> |
| 1512 | * <tr> |
| 1513 | * <td>long</td> |
| 1514 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 1515 | * <td>read-only</td> |
| 1516 | * <td>The resource ID of the icon for the source of contact status. This |
| 1517 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1518 | * </tr> |
| 1519 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1520 | */ |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 1521 | public static class Contacts implements BaseColumns, ContactsColumns, |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1522 | ContactOptionsColumns, ContactNameColumns, ContactStatusColumns, ContactCounts { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1523 | /** |
| 1524 | * This utility class cannot be instantiated |
| 1525 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1526 | private Contacts() {} |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1527 | |
| 1528 | /** |
| 1529 | * The content:// style URI for this table |
| 1530 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1531 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1532 | |
| 1533 | /** |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 1534 | * Special contacts URI to refer to contacts on the corp profile from the personal |
| 1535 | * profile. |
| 1536 | * |
| 1537 | * It's supported only by a few specific places for referring to contact pictures that |
| 1538 | * are in the corp provider for enterprise caller-ID. Contact picture URIs returned from |
| 1539 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may contain this kind of URI. |
| 1540 | * |
| 1541 | * @hide |
| 1542 | */ |
Mathew Inwood | ba50311 | 2018-08-10 09:37:35 +0100 | [diff] [blame] | 1543 | @UnsupportedAppUsage |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 1544 | public static final Uri CORP_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 1545 | "contacts_corp"); |
| 1546 | |
| 1547 | /** |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1548 | * A content:// style URI for this table that should be used to create |
| 1549 | * shortcuts or otherwise create long-term links to contacts. This URI |
| 1550 | * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}. |
| 1551 | * It can optionally also have a "/" and last known contact ID appended after |
| 1552 | * that. This "complete" format is an important optimization and is highly recommended. |
| 1553 | * <p> |
| 1554 | * As long as the contact's row ID remains the same, this URI is |
| 1555 | * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes |
| 1556 | * as a result of a sync or aggregation, this URI will look up the |
| 1557 | * contact using indirect information (sync IDs or constituent raw |
| 1558 | * contacts). |
| 1559 | * <p> |
| 1560 | * Lookup key should be appended unencoded - it is stored in the encoded |
| 1561 | * form, ready for use in a URI. |
| 1562 | */ |
| 1563 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1564 | "lookup"); |
| 1565 | |
| 1566 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1567 | * Base {@link Uri} for referencing a single {@link Contacts} entry, |
Jeff Sharkey | 8f76734 | 2009-09-28 18:22:46 -0700 | [diff] [blame] | 1568 | * created by appending {@link #LOOKUP_KEY} using |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1569 | * {@link Uri#withAppendedPath(Uri, String)}. Provides |
| 1570 | * {@link OpenableColumns} columns when queried, or returns the |
| 1571 | * referenced contact formatted as a vCard when opened through |
| 1572 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1573 | */ |
| 1574 | public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1575 | "as_vcard"); |
| 1576 | |
Martijn Coenen | 037d3ff | 2011-06-15 16:01:45 +0200 | [diff] [blame] | 1577 | /** |
| 1578 | * Boolean parameter that may be used with {@link #CONTENT_VCARD_URI} |
| 1579 | * and {@link #CONTENT_MULTI_VCARD_URI} to indicate that the returned |
| 1580 | * vcard should not contain a photo. |
| 1581 | * |
Brian Attwell | f9fb60a | 2015-02-02 12:16:13 -0800 | [diff] [blame] | 1582 | * This is useful for obtaining a space efficient vcard. |
Martijn Coenen | 037d3ff | 2011-06-15 16:01:45 +0200 | [diff] [blame] | 1583 | */ |
Brian Attwell | f9fb60a | 2015-02-02 12:16:13 -0800 | [diff] [blame] | 1584 | public static final String QUERY_PARAMETER_VCARD_NO_PHOTO = "no_photo"; |
Martijn Coenen | 037d3ff | 2011-06-15 16:01:45 +0200 | [diff] [blame] | 1585 | |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1586 | /** |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1587 | * Base {@link Uri} for referencing multiple {@link Contacts} entry, |
| 1588 | * created by appending {@link #LOOKUP_KEY} using |
| 1589 | * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 1590 | * joined with the colon (":") separator, and the resulting string encoded. |
| 1591 | * |
| 1592 | * Provides {@link OpenableColumns} columns when queried, or returns the |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1593 | * referenced contact formatted as a vCard when opened through |
| 1594 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1595 | * |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 1596 | * <p> |
| 1597 | * Usage example: |
| 1598 | * <dl> |
| 1599 | * <dt>The following code snippet creates a multi-vcard URI that references all the |
| 1600 | * contacts in a user's database.</dt> |
| 1601 | * <dd> |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1602 | * |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 1603 | * <pre> |
| 1604 | * public Uri getAllContactsVcardUri() { |
| 1605 | * Cursor cursor = getActivity().getContentResolver().query(Contacts.CONTENT_URI, |
| 1606 | * new String[] {Contacts.LOOKUP_KEY}, null, null, null); |
| 1607 | * if (cursor == null) { |
| 1608 | * return null; |
| 1609 | * } |
| 1610 | * try { |
| 1611 | * StringBuilder uriListBuilder = new StringBuilder(); |
| 1612 | * int index = 0; |
| 1613 | * while (cursor.moveToNext()) { |
| 1614 | * if (index != 0) uriListBuilder.append(':'); |
| 1615 | * uriListBuilder.append(cursor.getString(0)); |
| 1616 | * index++; |
| 1617 | * } |
| 1618 | * return Uri.withAppendedPath(Contacts.CONTENT_MULTI_VCARD_URI, |
| 1619 | * Uri.encode(uriListBuilder.toString())); |
| 1620 | * } finally { |
| 1621 | * cursor.close(); |
| 1622 | * } |
| 1623 | * } |
| 1624 | * </pre> |
| 1625 | * |
| 1626 | * </p> |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1627 | */ |
| 1628 | public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1629 | "as_multi_vcard"); |
| 1630 | |
| 1631 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1632 | * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the |
| 1633 | * requested {@link Contacts} entry. |
| 1634 | * |
| 1635 | * @param contactUri A {@link #CONTENT_URI} row, or an existing |
| 1636 | * {@link #CONTENT_LOOKUP_URI} to attempt refreshing. |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1637 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1638 | public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) { |
| 1639 | final Cursor c = resolver.query(contactUri, new String[] { |
| 1640 | Contacts.LOOKUP_KEY, Contacts._ID |
| 1641 | }, null, null, null); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1642 | if (c == null) { |
| 1643 | return null; |
| 1644 | } |
| 1645 | |
| 1646 | try { |
| 1647 | if (c.moveToFirst()) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1648 | final String lookupKey = c.getString(0); |
| 1649 | final long contactId = c.getLong(1); |
| 1650 | return getLookupUri(contactId, lookupKey); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1651 | } |
| 1652 | } finally { |
| 1653 | c.close(); |
| 1654 | } |
| 1655 | return null; |
| 1656 | } |
| 1657 | |
| 1658 | /** |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1659 | * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1660 | * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}. |
Jay Shrauner | 1ebaff2 | 2015-03-12 15:24:16 -0700 | [diff] [blame] | 1661 | * <p> |
| 1662 | * Returns null if unable to construct a valid lookup URI from the |
| 1663 | * provided parameters. |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1664 | */ |
| 1665 | public static Uri getLookupUri(long contactId, String lookupKey) { |
Jay Shrauner | 1ebaff2 | 2015-03-12 15:24:16 -0700 | [diff] [blame] | 1666 | if (TextUtils.isEmpty(lookupKey)) { |
| 1667 | return null; |
| 1668 | } |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1669 | return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, |
| 1670 | lookupKey), contactId); |
| 1671 | } |
| 1672 | |
| 1673 | /** |
Dmitri Plotnikov | b5759b5 | 2009-09-01 15:58:40 -0700 | [diff] [blame] | 1674 | * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI. |
| 1675 | * <p> |
| 1676 | * Returns null if the contact cannot be found. |
| 1677 | */ |
| 1678 | public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) { |
| 1679 | if (lookupUri == null) { |
| 1680 | return null; |
| 1681 | } |
| 1682 | |
| 1683 | Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null); |
| 1684 | if (c == null) { |
| 1685 | return null; |
| 1686 | } |
| 1687 | |
| 1688 | try { |
| 1689 | if (c.moveToFirst()) { |
| 1690 | long contactId = c.getLong(0); |
| 1691 | return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1692 | } |
| 1693 | } finally { |
| 1694 | c.close(); |
| 1695 | } |
| 1696 | return null; |
| 1697 | } |
| 1698 | |
| 1699 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1700 | * Mark a contact as having been contacted. Updates two fields: |
| 1701 | * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED}. The |
| 1702 | * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED |
| 1703 | * field is populated with the current system time. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1704 | * |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 1705 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this method is obsolete. For |
| 1706 | * more information, see the |
| 1707 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 1708 | * page. |
| 1709 | * |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1710 | * @param resolver the ContentResolver to use |
| 1711 | * @param contactId the person who was contacted |
Daniel Lehmann | a1620dc | 2012-04-13 13:29:49 -0700 | [diff] [blame] | 1712 | * |
| 1713 | * @deprecated The class DataUsageStatUpdater of the Android support library should |
| 1714 | * be used instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1715 | */ |
Daniel Lehmann | a1620dc | 2012-04-13 13:29:49 -0700 | [diff] [blame] | 1716 | @Deprecated |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1717 | public static void markAsContacted(ContentResolver resolver, long contactId) { |
| 1718 | Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId); |
| 1719 | ContentValues values = new ContentValues(); |
| 1720 | // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified. |
Makoto Onuki | 203145e | 2016-09-28 15:41:29 -0700 | [diff] [blame] | 1721 | values.put(LR_LAST_TIME_CONTACTED, System.currentTimeMillis()); |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1722 | resolver.update(uri, values, null, null); |
| 1723 | } |
| 1724 | |
| 1725 | /** |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1726 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1727 | * {@link #CONTENT_URI} URI. The filter string will be used to match |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1728 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1729 | * as an additional path segment after this URI. |
| 1730 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1731 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 1732 | CONTENT_URI, "filter"); |
| 1733 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1734 | /** |
Ricky Wai | 6b38e06 | 2015-11-26 23:21:39 +0000 | [diff] [blame] | 1735 | * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same |
| 1736 | * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in parameters, |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 1737 | * otherwise it will throw IllegalArgumentException. |
Ricky Wai | a5efc47 | 2015-11-16 12:25:45 +0000 | [diff] [blame] | 1738 | */ |
Ricky Wai | 6b38e06 | 2015-11-26 23:21:39 +0000 | [diff] [blame] | 1739 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 1740 | CONTENT_URI, "filter_enterprise"); |
Ricky Wai | a5efc47 | 2015-11-16 12:25:45 +0000 | [diff] [blame] | 1741 | |
| 1742 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1743 | * The content:// style URI for this table joined with useful data from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1744 | * {@link ContactsContract.Data}, filtered to include only starred contacts |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1745 | * and the most frequently contacted contacts. |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 1746 | * |
| 1747 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts |
| 1748 | * results based on contacts frequency. For more information, see the |
| 1749 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 1750 | * page. |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1751 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1752 | public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath( |
| 1753 | CONTENT_URI, "strequent"); |
| 1754 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1755 | /** |
Yorke Lee | 8d37009 | 2014-06-26 10:32:17 -0700 | [diff] [blame] | 1756 | * The content:// style URI for showing a list of frequently contacted people. |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 1757 | * |
| 1758 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts |
| 1759 | * results based on contacts frequency. For more information, see the |
| 1760 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 1761 | * page. |
Daisuke Miyakawa | 3604bc5 | 2011-07-21 10:14:32 -0700 | [diff] [blame] | 1762 | */ |
| 1763 | public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath( |
| 1764 | CONTENT_URI, "frequent"); |
| 1765 | |
| 1766 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1767 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1768 | * {@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] | 1769 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1770 | * as an additional path segment after this URI. |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 1771 | * |
| 1772 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts |
| 1773 | * results based on contacts frequency. For more information, see the |
| 1774 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 1775 | * page. |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1776 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1777 | public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath( |
| 1778 | CONTENT_STREQUENT_URI, "filter"); |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1779 | |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1780 | public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath( |
| 1781 | CONTENT_URI, "group"); |
| 1782 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1783 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1784 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 1785 | * people. |
| 1786 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1787 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1788 | |
| 1789 | /** |
| 1790 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1791 | * person. |
| 1792 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1793 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1794 | |
| 1795 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1796 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1797 | * person. |
| 1798 | */ |
| 1799 | public static final String CONTENT_VCARD_TYPE = "text/x-vcard"; |
| 1800 | |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 1801 | /** |
| 1802 | * Mimimal ID for corp contacts returned from |
| 1803 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
| 1804 | * |
| 1805 | * @hide |
| 1806 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 1807 | 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] | 1808 | |
| 1809 | /** |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 1810 | * Prefix for corp contacts returned from |
| 1811 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
| 1812 | * |
| 1813 | * @hide |
| 1814 | */ |
| 1815 | public static String ENTERPRISE_CONTACT_LOOKUP_PREFIX = "c-"; |
| 1816 | |
| 1817 | /** |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 1818 | * 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] | 1819 | * |
| 1820 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may return such a contact. |
| 1821 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 1822 | public static boolean isEnterpriseContactId(long contactId) { |
| 1823 | return (contactId >= ENTERPRISE_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID); |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 1824 | } |
| 1825 | |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1826 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1827 | * 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] | 1828 | * {@link ContactsContract.Data} rows. This directory can be used either |
| 1829 | * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1830 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1831 | public static final class Data implements BaseColumns, DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1832 | /** |
| 1833 | * no public constructor since this is a utility class |
| 1834 | */ |
| 1835 | private Data() {} |
| 1836 | |
| 1837 | /** |
| 1838 | * The directory twig for this sub-table |
| 1839 | */ |
| 1840 | public static final String CONTENT_DIRECTORY = "data"; |
| 1841 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1842 | |
| 1843 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1844 | * <p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1845 | * A sub-directory of a contact that contains all of its |
| 1846 | * {@link ContactsContract.RawContacts} as well as |
| 1847 | * {@link ContactsContract.Data} rows. To access this directory append |
| 1848 | * {@link #CONTENT_DIRECTORY} to the contact URI. |
| 1849 | * </p> |
| 1850 | * <p> |
| 1851 | * Entity has three ID fields: {@link #CONTACT_ID} for the contact, |
| 1852 | * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for |
| 1853 | * the data rows. Entity always contains at least one row per |
| 1854 | * constituent raw contact, even if there are no actual data rows. In |
| 1855 | * this case the {@link #DATA_ID} field will be null. |
| 1856 | * </p> |
| 1857 | * <p> |
| 1858 | * Entity reads all data for the entire contact in one transaction, to |
| 1859 | * guarantee consistency. There is significant data duplication |
| 1860 | * in the Entity (each row repeats all Contact columns and all RawContact |
| 1861 | * columns), so the benefits of transactional consistency should be weighed |
| 1862 | * against the cost of transferring large amounts of denormalized data |
| 1863 | * from the Provider. |
| 1864 | * </p> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 1865 | * <p> |
| 1866 | * To reduce the amount of data duplication the contacts provider and directory |
| 1867 | * providers implementing this protocol are allowed to provide common Contacts |
| 1868 | * and RawContacts fields in the first row returned for each raw contact only and |
| 1869 | * leave them as null in subsequent rows. |
| 1870 | * </p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1871 | */ |
| 1872 | public static final class Entity implements BaseColumns, ContactsColumns, |
| 1873 | ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns, |
Paul Soulos | 42cdda8 | 2014-06-19 16:13:38 -0700 | [diff] [blame] | 1874 | StatusColumns, ContactOptionsColumns, ContactStatusColumns, DataUsageStatColumns { |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1875 | /** |
| 1876 | * no public constructor since this is a utility class |
| 1877 | */ |
| 1878 | private Entity() { |
| 1879 | } |
| 1880 | |
| 1881 | /** |
| 1882 | * The directory twig for this sub-table |
| 1883 | */ |
| 1884 | public static final String CONTENT_DIRECTORY = "entities"; |
| 1885 | |
| 1886 | /** |
| 1887 | * The ID of the raw contact row. |
| 1888 | * <P>Type: INTEGER</P> |
| 1889 | */ |
| 1890 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 1891 | |
| 1892 | /** |
| 1893 | * The ID of the data row. The value will be null if this raw contact has no |
| 1894 | * data rows. |
| 1895 | * <P>Type: INTEGER</P> |
| 1896 | */ |
| 1897 | public static final String DATA_ID = "data_id"; |
| 1898 | } |
| 1899 | |
| 1900 | /** |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 1901 | * <p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1902 | * A sub-directory of a single contact that contains all of the constituent raw contact |
| 1903 | * {@link ContactsContract.StreamItems} rows. This directory can be used either |
| 1904 | * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}. |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 1905 | * </p> |
| 1906 | * <p> |
| 1907 | * Querying for social stream data requires android.permission.READ_SOCIAL_STREAM |
| 1908 | * permission. |
| 1909 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1910 | * |
| 1911 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 1912 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 1913 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 1914 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1915 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1916 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1917 | public static final class StreamItems implements StreamItemsColumns { |
| 1918 | /** |
| 1919 | * no public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1920 | * |
| 1921 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 1922 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1923 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1924 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1925 | private StreamItems() {} |
| 1926 | |
| 1927 | /** |
| 1928 | * The directory twig for this sub-table |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1929 | * |
| 1930 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 1931 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1932 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1933 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1934 | public static final String CONTENT_DIRECTORY = "stream_items"; |
| 1935 | } |
| 1936 | |
| 1937 | /** |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1938 | * <p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1939 | * A <i>read-only</i> sub-directory of a single contact aggregate that |
| 1940 | * contains all aggregation suggestions (other contacts). The |
| 1941 | * aggregation suggestions are computed based on approximate data |
| 1942 | * matches with this contact. |
| 1943 | * </p> |
| 1944 | * <p> |
| 1945 | * <i>Note: this query may be expensive! If you need to use it in bulk, |
| 1946 | * make sure the user experience is acceptable when the query runs for a |
| 1947 | * long time.</i> |
| 1948 | * <p> |
| 1949 | * Usage example: |
| 1950 | * |
| 1951 | * <pre> |
| 1952 | * Uri uri = Contacts.CONTENT_URI.buildUpon() |
| 1953 | * .appendEncodedPath(String.valueOf(contactId)) |
| 1954 | * .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY) |
| 1955 | * .appendQueryParameter("limit", "3") |
| 1956 | * .build() |
| 1957 | * Cursor cursor = getContentResolver().query(suggestionsUri, |
| 1958 | * new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY}, |
| 1959 | * null, null, null); |
| 1960 | * </pre> |
| 1961 | * |
| 1962 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1963 | * <p> |
| 1964 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 1965 | * {@link #CONTENT_LOOKUP_URI}. |
| 1966 | * </p> |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1967 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1968 | public static final class AggregationSuggestions implements BaseColumns, ContactsColumns, |
| 1969 | ContactOptionsColumns, ContactStatusColumns { |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1970 | /** |
| 1971 | * No public constructor since this is a utility class |
| 1972 | */ |
| 1973 | private AggregationSuggestions() {} |
| 1974 | |
| 1975 | /** |
Dmitri Plotnikov | 0fc0244 | 2009-09-21 13:26:28 -0700 | [diff] [blame] | 1976 | * 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] | 1977 | * type-to-filter, similar to |
| 1978 | * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}. |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1979 | */ |
| 1980 | public static final String CONTENT_DIRECTORY = "suggestions"; |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1981 | |
| 1982 | /** |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1983 | * Used to specify what kind of data is supplied for the suggestion query. |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1984 | * |
| 1985 | * @hide |
| 1986 | */ |
| 1987 | public static final String PARAMETER_MATCH_NAME = "name"; |
| 1988 | |
| 1989 | /** |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1990 | * A convenience builder for aggregation suggestion content URIs. |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1991 | */ |
| 1992 | public static final class Builder { |
| 1993 | private long mContactId; |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1994 | private final ArrayList<String> mValues = new ArrayList<String>(); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1995 | private int mLimit; |
| 1996 | |
| 1997 | /** |
| 1998 | * Optional existing contact ID. If it is not provided, the search |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1999 | * will be based exclusively on the values supplied with {@link #addNameParameter}. |
| 2000 | * |
| 2001 | * @param contactId contact to find aggregation suggestions for |
| 2002 | * @return This Builder object to allow for chaining of calls to builder methods |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2003 | */ |
| 2004 | public Builder setContactId(long contactId) { |
| 2005 | this.mContactId = contactId; |
| 2006 | return this; |
| 2007 | } |
| 2008 | |
| 2009 | /** |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2010 | * Add a name to be used when searching for aggregation suggestions. |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2011 | * |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2012 | * @param name name to find aggregation suggestions for |
| 2013 | * @return This Builder object to allow for chaining of calls to builder methods |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2014 | */ |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2015 | public Builder addNameParameter(String name) { |
| 2016 | mValues.add(name); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2017 | return this; |
| 2018 | } |
| 2019 | |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2020 | /** |
| 2021 | * Sets the Maximum number of suggested aggregations that should be returned. |
| 2022 | * @param limit The maximum number of suggested aggregations |
| 2023 | * |
| 2024 | * @return This Builder object to allow for chaining of calls to builder methods |
| 2025 | */ |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2026 | public Builder setLimit(int limit) { |
| 2027 | mLimit = limit; |
| 2028 | return this; |
| 2029 | } |
| 2030 | |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2031 | /** |
| 2032 | * Combine all of the options that have been set and return a new {@link Uri} |
| 2033 | * object for fetching aggregation suggestions. |
| 2034 | */ |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2035 | public Uri build() { |
| 2036 | android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon(); |
| 2037 | builder.appendEncodedPath(String.valueOf(mContactId)); |
| 2038 | builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY); |
| 2039 | if (mLimit != 0) { |
| 2040 | builder.appendQueryParameter("limit", String.valueOf(mLimit)); |
| 2041 | } |
| 2042 | |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2043 | int count = mValues.size(); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2044 | for (int i = 0; i < count; i++) { |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2045 | builder.appendQueryParameter("query", PARAMETER_MATCH_NAME |
| 2046 | + ":" + mValues.get(i)); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2047 | } |
| 2048 | |
| 2049 | return builder.build(); |
| 2050 | } |
| 2051 | } |
| 2052 | |
| 2053 | /** |
| 2054 | * @hide |
| 2055 | */ |
Mathew Inwood | ba50311 | 2018-08-10 09:37:35 +0100 | [diff] [blame] | 2056 | @UnsupportedAppUsage |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2057 | public static final Builder builder() { |
| 2058 | return new Builder(); |
| 2059 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 2060 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2061 | |
| 2062 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2063 | * 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] | 2064 | * the contact's primary photo. The photo may be stored in up to two ways - |
| 2065 | * the default "photo" is a thumbnail-sized image stored directly in the data |
| 2066 | * row, while the "display photo", if present, is a larger version stored as |
| 2067 | * a file. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2068 | * <p> |
| 2069 | * Usage example: |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2070 | * <dl> |
| 2071 | * <dt>Retrieving the thumbnail-sized photo</dt> |
| 2072 | * <dd> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2073 | * <pre> |
| 2074 | * public InputStream openPhoto(long contactId) { |
| 2075 | * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 2076 | * Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY); |
| 2077 | * Cursor cursor = getContentResolver().query(photoUri, |
| 2078 | * new String[] {Contacts.Photo.PHOTO}, null, null, null); |
| 2079 | * if (cursor == null) { |
| 2080 | * return null; |
| 2081 | * } |
| 2082 | * try { |
| 2083 | * if (cursor.moveToFirst()) { |
| 2084 | * byte[] data = cursor.getBlob(0); |
| 2085 | * if (data != null) { |
| 2086 | * return new ByteArrayInputStream(data); |
| 2087 | * } |
| 2088 | * } |
| 2089 | * } finally { |
| 2090 | * cursor.close(); |
| 2091 | * } |
| 2092 | * return null; |
| 2093 | * } |
| 2094 | * </pre> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2095 | * </dd> |
| 2096 | * <dt>Retrieving the larger photo version</dt> |
| 2097 | * <dd> |
| 2098 | * <pre> |
| 2099 | * public InputStream openDisplayPhoto(long contactId) { |
| 2100 | * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 2101 | * Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO); |
| 2102 | * try { |
| 2103 | * AssetFileDescriptor fd = |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 2104 | * getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2105 | * return fd.createInputStream(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 2106 | * } catch (IOException e) { |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2107 | * return null; |
| 2108 | * } |
| 2109 | * } |
| 2110 | * </pre> |
| 2111 | * </dd> |
| 2112 | * </dl> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2113 | * |
| 2114 | * </p> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2115 | * <p>You may also consider using the convenience method |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2116 | * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri, boolean)} |
| 2117 | * 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] | 2118 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2119 | * <p> |
| 2120 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 2121 | * {@link #CONTENT_LOOKUP_URI}. |
| 2122 | * </p> |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2123 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2124 | public static final class Photo implements BaseColumns, DataColumnsWithJoins { |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 2125 | /** |
| 2126 | * no public constructor since this is a utility class |
| 2127 | */ |
| 2128 | private Photo() {} |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 2129 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 2130 | /** |
| 2131 | * The directory twig for this sub-table |
| 2132 | */ |
| 2133 | public static final String CONTENT_DIRECTORY = "photo"; |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2134 | |
| 2135 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2136 | * The directory twig for retrieving the full-size display photo. |
| 2137 | */ |
| 2138 | public static final String DISPLAY_PHOTO = "display_photo"; |
| 2139 | |
| 2140 | /** |
| 2141 | * Full-size photo file ID of the raw contact. |
| 2142 | * See {@link ContactsContract.DisplayPhoto}. |
| 2143 | * <p> |
| 2144 | * Type: NUMBER |
| 2145 | */ |
| 2146 | public static final String PHOTO_FILE_ID = DATA14; |
| 2147 | |
| 2148 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2149 | * Thumbnail photo of the raw contact. This is the raw bytes of an image |
| 2150 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
| 2151 | * <p> |
| 2152 | * Type: BLOB |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2153 | */ |
| 2154 | public static final String PHOTO = DATA15; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2155 | } |
| 2156 | |
| 2157 | /** |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2158 | * Opens an InputStream for the contacts's photo and returns the |
| 2159 | * photo as a byte stream. |
| 2160 | * @param cr The content resolver to use for querying |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2161 | * @param contactUri the contact whose photo should be used. This can be used with |
| 2162 | * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI. |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2163 | * @param preferHighres If this is true and the contact has a higher resolution photo |
| 2164 | * 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] | 2165 | * @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] | 2166 | */ |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2167 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri, |
| 2168 | boolean preferHighres) { |
| 2169 | if (preferHighres) { |
| 2170 | final Uri displayPhotoUri = Uri.withAppendedPath(contactUri, |
| 2171 | Contacts.Photo.DISPLAY_PHOTO); |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2172 | try { |
| 2173 | AssetFileDescriptor fd = cr.openAssetFileDescriptor(displayPhotoUri, "r"); |
Makoto Onuki | da072b3 | 2016-02-05 13:23:21 -0800 | [diff] [blame] | 2174 | if (fd != null) { |
| 2175 | return fd.createInputStream(); |
| 2176 | } |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2177 | } catch (IOException e) { |
| 2178 | // fallback to the thumbnail code |
| 2179 | } |
| 2180 | } |
| 2181 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 2182 | Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY); |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 2183 | if (photoUri == null) { |
| 2184 | return null; |
| 2185 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2186 | Cursor cursor = cr.query(photoUri, |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2187 | new String[] { |
| 2188 | ContactsContract.CommonDataKinds.Photo.PHOTO |
| 2189 | }, null, null, null); |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2190 | try { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 2191 | if (cursor == null || !cursor.moveToNext()) { |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2192 | return null; |
| 2193 | } |
| 2194 | byte[] data = cursor.getBlob(0); |
| 2195 | if (data == null) { |
| 2196 | return null; |
| 2197 | } |
| 2198 | return new ByteArrayInputStream(data); |
| 2199 | } finally { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 2200 | if (cursor != null) { |
| 2201 | cursor.close(); |
| 2202 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2203 | } |
| 2204 | } |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2205 | |
| 2206 | /** |
| 2207 | * Opens an InputStream for the contacts's thumbnail photo and returns the |
| 2208 | * photo as a byte stream. |
| 2209 | * @param cr The content resolver to use for querying |
| 2210 | * @param contactUri the contact whose photo should be used. This can be used with |
| 2211 | * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI. |
| 2212 | * @return an InputStream of the photo, or null if no photo is present |
| 2213 | * @see #openContactPhotoInputStream(ContentResolver, Uri, boolean), if instead |
| 2214 | * of the thumbnail the high-res picture is preferred |
| 2215 | */ |
| 2216 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) { |
| 2217 | return openContactPhotoInputStream(cr, contactUri, false); |
| 2218 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2219 | } |
| 2220 | |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2221 | /** |
| 2222 | * <p> |
| 2223 | * Constants for the user's profile data, which is represented as a single contact on |
| 2224 | * the device that represents the user. The profile contact is not aggregated |
| 2225 | * together automatically in the same way that normal contacts are; instead, each |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 2226 | * account (including data set, if applicable) on the device may contribute a single |
| 2227 | * raw contact representing the user's personal profile data from that source. |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2228 | * </p> |
| 2229 | * <p> |
| 2230 | * Access to the profile entry through these URIs (or incidental access to parts of |
| 2231 | * the profile if retrieved directly via ID) requires additional permissions beyond |
| 2232 | * the read/write contact permissions required by the provider. Querying for profile |
| 2233 | * data requires android.permission.READ_PROFILE permission, and inserting or |
| 2234 | * updating profile data requires android.permission.WRITE_PROFILE permission. |
| 2235 | * </p> |
| 2236 | * <h3>Operations</h3> |
| 2237 | * <dl> |
| 2238 | * <dt><b>Insert</b></dt> |
| 2239 | * <dd>The user's profile entry cannot be created explicitly (attempting to do so |
| 2240 | * will throw an exception). When a raw contact is inserted into the profile, the |
| 2241 | * provider will check for the existence of a profile on the device. If one is |
| 2242 | * found, the raw contact's {@link RawContacts#CONTACT_ID} column gets the _ID of |
| 2243 | * the profile Contact. If no match is found, the profile Contact is created and |
| 2244 | * its _ID is put into the {@link RawContacts#CONTACT_ID} column of the newly |
| 2245 | * inserted raw contact.</dd> |
| 2246 | * <dt><b>Update</b></dt> |
| 2247 | * <dd>The profile Contact has the same update restrictions as Contacts in general, |
| 2248 | * but requires the android.permission.WRITE_PROFILE permission.</dd> |
| 2249 | * <dt><b>Delete</b></dt> |
| 2250 | * <dd>The profile Contact cannot be explicitly deleted. It will be removed |
| 2251 | * automatically if all of its constituent raw contact entries are deleted.</dd> |
| 2252 | * <dt><b>Query</b></dt> |
| 2253 | * <dd> |
| 2254 | * <ul> |
| 2255 | * <li>The {@link #CONTENT_URI} for profiles behaves in much the same way as |
| 2256 | * retrieving a contact by ID, except that it will only ever return the user's |
| 2257 | * profile contact. |
| 2258 | * </li> |
| 2259 | * <li> |
| 2260 | * The profile contact supports all of the same sub-paths as an individual contact |
| 2261 | * does - the content of the profile contact can be retrieved as entities or |
| 2262 | * data rows. Similarly, specific raw contact entries can be retrieved by appending |
| 2263 | * the desired raw contact ID within the profile. |
| 2264 | * </li> |
| 2265 | * </ul> |
| 2266 | * </dd> |
| 2267 | * </dl> |
| 2268 | */ |
| 2269 | public static final class Profile implements BaseColumns, ContactsColumns, |
| 2270 | ContactOptionsColumns, ContactNameColumns, ContactStatusColumns { |
| 2271 | /** |
| 2272 | * This utility class cannot be instantiated |
| 2273 | */ |
| 2274 | private Profile() { |
| 2275 | } |
| 2276 | |
| 2277 | /** |
| 2278 | * The content:// style URI for this table, which requests the contact entry |
| 2279 | * representing the user's personal profile data. |
| 2280 | */ |
| 2281 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "profile"); |
| 2282 | |
| 2283 | /** |
| 2284 | * {@link Uri} for referencing the user's profile {@link Contacts} entry, |
| 2285 | * Provides {@link OpenableColumns} columns when queried, or returns the |
| 2286 | * user's profile contact formatted as a vCard when opened through |
| 2287 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 2288 | */ |
| 2289 | public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 2290 | "as_vcard"); |
| 2291 | |
| 2292 | /** |
| 2293 | * {@link Uri} for referencing the raw contacts that make up the user's profile |
| 2294 | * {@link Contacts} entry. An individual raw contact entry within the profile |
| 2295 | * can be addressed by appending the raw contact ID. The entities or data within |
| 2296 | * that specific raw contact can be requested by appending the entity or data |
| 2297 | * path as well. |
| 2298 | */ |
| 2299 | public static final Uri CONTENT_RAW_CONTACTS_URI = Uri.withAppendedPath(CONTENT_URI, |
| 2300 | "raw_contacts"); |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 2301 | |
| 2302 | /** |
| 2303 | * The minimum ID for any entity that belongs to the profile. This essentially |
| 2304 | * defines an ID-space in which profile data is stored, and is used by the provider |
| 2305 | * to determine whether a request via a non-profile-specific URI should be directed |
| 2306 | * to the profile data rather than general contacts data, along with all the special |
| 2307 | * permission checks that entails. |
| 2308 | * |
| 2309 | * Callers may use {@link #isProfileId} to check whether a specific ID falls into |
| 2310 | * the set of data intended for the profile. |
| 2311 | */ |
| 2312 | public static final long MIN_ID = Long.MAX_VALUE - (long) Integer.MAX_VALUE; |
| 2313 | } |
| 2314 | |
| 2315 | /** |
| 2316 | * This method can be used to identify whether the given ID is associated with profile |
| 2317 | * data. It does not necessarily indicate that the ID is tied to valid data, merely |
| 2318 | * that accessing data using this ID will result in profile access checks and will only |
| 2319 | * return data from the profile. |
| 2320 | * |
| 2321 | * @param id The ID to check. |
| 2322 | * @return Whether the ID is associated with profile data. |
| 2323 | */ |
| 2324 | public static boolean isProfileId(long id) { |
| 2325 | return id >= Profile.MIN_ID; |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2326 | } |
| 2327 | |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 2328 | protected interface DeletedContactsColumns { |
| 2329 | |
| 2330 | /** |
| 2331 | * A reference to the {@link ContactsContract.Contacts#_ID} that was deleted. |
| 2332 | * <P>Type: INTEGER</P> |
| 2333 | */ |
| 2334 | public static final String CONTACT_ID = "contact_id"; |
| 2335 | |
| 2336 | /** |
| 2337 | * Time (milliseconds since epoch) that the contact was deleted. |
| 2338 | */ |
| 2339 | public static final String CONTACT_DELETED_TIMESTAMP = "contact_deleted_timestamp"; |
| 2340 | } |
| 2341 | |
| 2342 | /** |
| 2343 | * Constants for the deleted contact table. This table holds a log of deleted contacts. |
| 2344 | * <p> |
| 2345 | * Log older than {@link #DAYS_KEPT_MILLISECONDS} may be deleted. |
| 2346 | */ |
| 2347 | public static final class DeletedContacts implements DeletedContactsColumns { |
| 2348 | |
| 2349 | /** |
| 2350 | * This utility class cannot be instantiated |
| 2351 | */ |
| 2352 | private DeletedContacts() { |
| 2353 | } |
| 2354 | |
| 2355 | /** |
| 2356 | * The content:// style URI for this table, which requests a directory of raw contact rows |
| 2357 | * matching the selection criteria. |
| 2358 | */ |
| 2359 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 2360 | "deleted_contacts"); |
| 2361 | |
| 2362 | /** |
| 2363 | * Number of days that the delete log will be kept. After this time, delete records may be |
| 2364 | * deleted. |
| 2365 | * |
| 2366 | * @hide |
| 2367 | */ |
| 2368 | private static final int DAYS_KEPT = 30; |
| 2369 | |
| 2370 | /** |
| 2371 | * Milliseconds that the delete log will be kept. After this time, delete records may be |
| 2372 | * deleted. |
| 2373 | */ |
| 2374 | public static final long DAYS_KEPT_MILLISECONDS = 1000L * 60L * 60L * 24L * (long)DAYS_KEPT; |
| 2375 | } |
| 2376 | |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 2377 | protected interface RawContactsColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2378 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2379 | * A reference to the {@link ContactsContract.Contacts#_ID} that this |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2380 | * data belongs to. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2381 | * <P>Type: INTEGER</P> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2382 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2383 | public static final String CONTACT_ID = "contact_id"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2384 | |
| 2385 | /** |
Zheng Fu | 9ea9a13 | 2015-01-07 11:33:19 -0800 | [diff] [blame] | 2386 | * Persistent unique id for each raw_contact within its account. |
| 2387 | * This id is provided by its own data source, and can be used to backup metadata |
| 2388 | * to the server. |
| 2389 | * This should be unique within each set of account_name/account_type/data_set |
Zheng Fu | 9ea9a13 | 2015-01-07 11:33:19 -0800 | [diff] [blame] | 2390 | */ |
| 2391 | public static final String BACKUP_ID = "backup_id"; |
| 2392 | |
| 2393 | /** |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2394 | * The data set within the account that this row belongs to. This allows |
| 2395 | * multiple sync adapters for the same account type to distinguish between |
| 2396 | * each others' data. |
| 2397 | * |
| 2398 | * This is empty by default, and is completely optional. It only needs to |
| 2399 | * be populated if multiple sync adapters are entering distinct data for |
| 2400 | * the same account type and account name. |
| 2401 | * <P>Type: TEXT</P> |
| 2402 | */ |
| 2403 | public static final String DATA_SET = "data_set"; |
| 2404 | |
| 2405 | /** |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 2406 | * A concatenation of the account type and data set (delimited by a forward |
| 2407 | * slash) - if the data set is empty, this will be the same as the account |
| 2408 | * type. For applications that need to be aware of the data set, this can |
| 2409 | * be used instead of account type to distinguish sets of data. This is |
| 2410 | * never intended to be used for specifying accounts. |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 2411 | * <p> |
| 2412 | * This column does *not* escape forward slashes in the account type or the data set. |
| 2413 | * If this is an issue, consider using |
| 2414 | * {@link ContactsContract.RawContacts#ACCOUNT_TYPE} and |
| 2415 | * {@link ContactsContract.RawContacts#DATA_SET} directly. |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 2416 | */ |
| 2417 | public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; |
| 2418 | |
| 2419 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2420 | * The aggregation mode for this contact. |
| 2421 | * <P>Type: INTEGER</P> |
| 2422 | */ |
| 2423 | public static final String AGGREGATION_MODE = "aggregation_mode"; |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 2424 | |
| 2425 | /** |
| 2426 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 2427 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 2428 | * 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] | 2429 | * 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] | 2430 | * then calls ContactResolver.delete once more, this time passing the |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 2431 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 2432 | * the data removal. |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 2433 | * <P>Type: INTEGER</P> |
| 2434 | */ |
| 2435 | public static final String DELETED = "deleted"; |
Dmitri Plotnikov | 918007b | 2010-01-20 12:12:11 -0800 | [diff] [blame] | 2436 | |
| 2437 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 2438 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 2439 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 2440 | * <P>Type: INTEGER</P> |
| 2441 | */ |
Dmitri Plotnikov | 86fe839 | 2010-07-16 11:19:46 -0700 | [diff] [blame] | 2442 | 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] | 2443 | |
| 2444 | /** |
| 2445 | * Flag that reflects whether this raw contact belongs to the user's |
| 2446 | * personal profile entry. |
| 2447 | */ |
| 2448 | public static final String RAW_CONTACT_IS_USER_PROFILE = "raw_contact_is_user_profile"; |
Tingting Wang | 03583a4 | 2015-05-04 13:48:23 -0700 | [diff] [blame] | 2449 | |
| 2450 | /** |
| 2451 | * Flag indicating that a raw contact's metadata has changed, and its metadata |
| 2452 | * needs to be synchronized by the server. |
| 2453 | * <P>Type: INTEGER (boolean)</P> |
| 2454 | */ |
| 2455 | public static final String METADATA_DIRTY = "metadata_dirty"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2456 | } |
| 2457 | |
| 2458 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2459 | * Constants for the raw contacts table, which contains one row of contact |
| 2460 | * information for each person in each synced account. Sync adapters and |
| 2461 | * contact management apps |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 2462 | * are the primary consumers of this API. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2463 | * |
| 2464 | * <h3>Aggregation</h3> |
| 2465 | * <p> |
| 2466 | * As soon as a raw contact is inserted or whenever its constituent data |
| 2467 | * changes, the provider will check if the raw contact matches other |
| 2468 | * existing raw contacts and if so will aggregate it with those. The |
| 2469 | * aggregation is reflected in the {@link RawContacts} table by the change of the |
| 2470 | * {@link #CONTACT_ID} field, which is the reference to the aggregate contact. |
| 2471 | * </p> |
| 2472 | * <p> |
| 2473 | * Changes to the structured name, organization, phone number, email address, |
| 2474 | * or nickname trigger a re-aggregation. |
| 2475 | * </p> |
| 2476 | * <p> |
| 2477 | * See also {@link AggregationExceptions} for a mechanism to control |
| 2478 | * aggregation programmatically. |
| 2479 | * </p> |
| 2480 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2481 | * <h3>Operations</h3> |
| 2482 | * <dl> |
| 2483 | * <dt><b>Insert</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2484 | * <dd> |
| 2485 | * <p> |
| 2486 | * Raw contacts can be inserted incrementally or in a batch. |
| 2487 | * The incremental method is more traditional but less efficient. |
| 2488 | * It should be used |
| 2489 | * 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] | 2490 | * <pre> |
| 2491 | * ContentValues values = new ContentValues(); |
| 2492 | * values.put(RawContacts.ACCOUNT_TYPE, accountType); |
| 2493 | * values.put(RawContacts.ACCOUNT_NAME, accountName); |
| 2494 | * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values); |
| 2495 | * long rawContactId = ContentUris.parseId(rawContactUri); |
| 2496 | * </pre> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2497 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2498 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2499 | * Once {@link Data} values become available, insert those. |
| 2500 | * For example, here's how you would insert a name: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2501 | * |
| 2502 | * <pre> |
| 2503 | * values.clear(); |
| 2504 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 2505 | * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); |
| 2506 | * values.put(StructuredName.DISPLAY_NAME, "Mike Sullivan"); |
| 2507 | * getContentResolver().insert(Data.CONTENT_URI, values); |
| 2508 | * </pre> |
| 2509 | * </p> |
| 2510 | * <p> |
| 2511 | * The batch method is by far preferred. It inserts the raw contact and its |
| 2512 | * constituent data rows in a single database transaction |
| 2513 | * and causes at most one aggregation pass. |
| 2514 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 2515 | * ArrayList<ContentProviderOperation> ops = |
| 2516 | * new ArrayList<ContentProviderOperation>(); |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2517 | * ... |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2518 | * int rawContactInsertIndex = ops.size(); |
| 2519 | * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) |
| 2520 | * .withValue(RawContacts.ACCOUNT_TYPE, accountType) |
| 2521 | * .withValue(RawContacts.ACCOUNT_NAME, accountName) |
| 2522 | * .build()); |
| 2523 | * |
| 2524 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 2525 | * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex) |
| 2526 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 2527 | * .withValue(StructuredName.DISPLAY_NAME, "Mike Sullivan") |
| 2528 | * .build()); |
| 2529 | * |
| 2530 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 2531 | * </pre> |
| 2532 | * </p> |
| 2533 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2534 | * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)} |
| 2535 | * to refer to the as-yet-unknown index value of the raw contact inserted in the |
| 2536 | * first operation. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2537 | * </p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2538 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2539 | * <dt><b>Update</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2540 | * <dd><p> |
| 2541 | * Raw contacts can be updated incrementally or in a batch. |
| 2542 | * Batch mode should be used whenever possible. |
| 2543 | * The procedures and considerations are analogous to those documented above for inserts. |
| 2544 | * </p></dd> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2545 | * <dt><b>Delete</b></dt> |
| 2546 | * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates, |
| 2547 | * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2548 | * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row |
| 2549 | * itself is also deleted automatically. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2550 | * </p> |
| 2551 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2552 | * The invocation of {@code resolver.delete(...)}, does not immediately delete |
| 2553 | * a raw contacts row. |
| 2554 | * Instead, it sets the {@link #DELETED} flag on the raw contact and |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2555 | * removes the raw contact from its aggregate contact. |
| 2556 | * The sync adapter then deletes the raw contact from the server and |
| 2557 | * finalizes phone-side deletion by calling {@code resolver.delete(...)} |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2558 | * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2559 | * <p>Some sync adapters are read-only, meaning that they only sync server-side |
| 2560 | * changes to the phone, but not the reverse. If one of those raw contacts |
| 2561 | * is marked for deletion, it will remain on the phone. However it will be |
| 2562 | * effectively invisible, because it will not be part of any aggregate contact. |
| 2563 | * </dd> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2564 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2565 | * <dt><b>Query</b></dt> |
| 2566 | * <dd> |
| 2567 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2568 | * It is easy to find all raw contacts in a Contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2569 | * <pre> |
| 2570 | * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI, |
| 2571 | * new String[]{RawContacts._ID}, |
| 2572 | * RawContacts.CONTACT_ID + "=?", |
| 2573 | * new String[]{String.valueOf(contactId)}, null); |
| 2574 | * </pre> |
| 2575 | * </p> |
| 2576 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2577 | * To find raw contacts within a specific account, |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2578 | * you can either put the account name and type in the selection or pass them as query |
| 2579 | * parameters. The latter approach is preferable, especially when you can reuse the |
| 2580 | * URI: |
| 2581 | * <pre> |
Adam Koch | 95e5a07 | 2013-05-21 09:47:55 -0400 | [diff] [blame] | 2582 | * Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon() |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2583 | * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName) |
| 2584 | * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType) |
| 2585 | * .build(); |
| 2586 | * Cursor c1 = getContentResolver().query(rawContactUri, |
| 2587 | * RawContacts.STARRED + "<>0", null, null, null); |
| 2588 | * ... |
| 2589 | * Cursor c2 = getContentResolver().query(rawContactUri, |
| 2590 | * RawContacts.DELETED + "<>0", null, null, null); |
| 2591 | * </pre> |
| 2592 | * </p> |
| 2593 | * <p>The best way to read a raw contact along with all the data associated with it is |
| 2594 | * by using the {@link Entity} directory. If the raw contact has data rows, |
| 2595 | * the Entity cursor will contain a row for each data row. If the raw contact has no |
| 2596 | * data rows, the cursor will still contain one row with the raw contact-level information. |
| 2597 | * <pre> |
| 2598 | * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); |
| 2599 | * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY); |
| 2600 | * Cursor c = getContentResolver().query(entityUri, |
| 2601 | * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1}, |
| 2602 | * null, null, null); |
| 2603 | * try { |
| 2604 | * while (c.moveToNext()) { |
| 2605 | * String sourceId = c.getString(0); |
| 2606 | * if (!c.isNull(1)) { |
| 2607 | * String mimeType = c.getString(2); |
| 2608 | * String data = c.getString(3); |
| 2609 | * ... |
| 2610 | * } |
| 2611 | * } |
| 2612 | * } finally { |
| 2613 | * c.close(); |
| 2614 | * } |
| 2615 | * </pre> |
| 2616 | * </p> |
| 2617 | * </dd> |
| 2618 | * </dl> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2619 | * <h2>Columns</h2> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2620 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2621 | * <table class="jd-sumtable"> |
| 2622 | * <tr> |
| 2623 | * <th colspan='4'>RawContacts</th> |
| 2624 | * </tr> |
| 2625 | * <tr> |
| 2626 | * <td>long</td> |
| 2627 | * <td>{@link #_ID}</td> |
| 2628 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2629 | * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words, |
| 2630 | * it is much better for a sync adapter to update a raw contact rather than to delete and |
| 2631 | * re-insert it.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2632 | * </tr> |
| 2633 | * <tr> |
| 2634 | * <td>long</td> |
| 2635 | * <td>{@link #CONTACT_ID}</td> |
| 2636 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2637 | * <td>The ID of the row in the {@link ContactsContract.Contacts} table |
| 2638 | * that this raw contact belongs |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2639 | * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled |
| 2640 | * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td> |
| 2641 | * </tr> |
| 2642 | * <tr> |
| 2643 | * <td>int</td> |
| 2644 | * <td>{@link #AGGREGATION_MODE}</td> |
| 2645 | * <td>read/write</td> |
| 2646 | * <td>A mechanism that allows programmatic control of the aggregation process. The allowed |
| 2647 | * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED} |
| 2648 | * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td> |
| 2649 | * </tr> |
| 2650 | * <tr> |
| 2651 | * <td>int</td> |
| 2652 | * <td>{@link #DELETED}</td> |
| 2653 | * <td>read/write</td> |
| 2654 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 2655 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 2656 | * called on a raw contact, it is marked for deletion and removed from its |
| 2657 | * aggregate contact. The sync adaptor deletes the raw contact on the server and |
| 2658 | * then calls ContactResolver.delete once more, this time passing the |
| 2659 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 2660 | * the data removal.</td> |
| 2661 | * </tr> |
| 2662 | * <tr> |
| 2663 | * <td>int</td> |
| 2664 | * <td>{@link #TIMES_CONTACTED}</td> |
| 2665 | * <td>read/write</td> |
| 2666 | * <td>The number of times the contact has been contacted. To have an effect |
| 2667 | * on the corresponding value of the aggregate contact, this field |
| 2668 | * should be set at the time the raw contact is inserted. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2669 | * After that, this value is typically updated via |
| 2670 | * {@link ContactsContract.Contacts#markAsContacted}.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2671 | * </tr> |
| 2672 | * <tr> |
| 2673 | * <td>long</td> |
| 2674 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 2675 | * <td>read/write</td> |
| 2676 | * <td>The timestamp of the last time the contact was contacted. To have an effect |
| 2677 | * on the corresponding value of the aggregate contact, this field |
| 2678 | * should be set at the time the raw contact is inserted. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2679 | * After that, this value is typically updated via |
| 2680 | * {@link ContactsContract.Contacts#markAsContacted}. |
| 2681 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2682 | * </tr> |
| 2683 | * <tr> |
| 2684 | * <td>int</td> |
| 2685 | * <td>{@link #STARRED}</td> |
| 2686 | * <td>read/write</td> |
| 2687 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2688 | * Changing this field immediately affects the corresponding aggregate contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2689 | * if any raw contacts in that aggregate contact are starred, then the contact |
| 2690 | * itself is marked as starred.</td> |
| 2691 | * </tr> |
| 2692 | * <tr> |
| 2693 | * <td>String</td> |
| 2694 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 2695 | * <td>read/write</td> |
| 2696 | * <td>A custom ringtone associated with a raw contact. Typically this is the |
| 2697 | * URI returned by an activity launched with the |
| 2698 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent. |
| 2699 | * To have an effect on the corresponding value of the aggregate contact, this field |
| 2700 | * 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] | 2701 | * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE |
| 2702 | * Contacts.CUSTOM_RINGTONE} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2703 | * instead.</td> |
| 2704 | * </tr> |
| 2705 | * <tr> |
| 2706 | * <td>int</td> |
| 2707 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 2708 | * <td>read/write</td> |
| 2709 | * <td>An indicator of whether calls from this raw contact should be forwarded |
| 2710 | * directly to voice mail ('1') or not ('0'). To have an effect |
| 2711 | * on the corresponding value of the aggregate contact, this field |
| 2712 | * should be set at the time the raw contact is inserted.</td> |
| 2713 | * </tr> |
| 2714 | * <tr> |
| 2715 | * <td>String</td> |
| 2716 | * <td>{@link #ACCOUNT_NAME}</td> |
| 2717 | * <td>read/write-once</td> |
| 2718 | * <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] | 2719 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
| 2720 | * 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] | 2721 | * It should be set at the time the raw contact is inserted and never |
| 2722 | * changed afterwards.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2723 | * </tr> |
| 2724 | * <tr> |
| 2725 | * <td>String</td> |
| 2726 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 2727 | * <td>read/write-once</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2728 | * <td> |
| 2729 | * <p> |
| 2730 | * The type of account to which this row belongs, which when paired with |
| 2731 | * {@link #ACCOUNT_NAME} identifies a specific account. |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2732 | * It should be set at the time the raw contact is inserted and never |
| 2733 | * changed afterwards. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2734 | * </p> |
| 2735 | * <p> |
| 2736 | * To ensure uniqueness, new account types should be chosen according to the |
| 2737 | * Java package naming convention. Thus a Google account is of type "com.google". |
| 2738 | * </p> |
| 2739 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2740 | * </tr> |
| 2741 | * <tr> |
| 2742 | * <td>String</td> |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2743 | * <td>{@link #DATA_SET}</td> |
| 2744 | * <td>read/write-once</td> |
| 2745 | * <td> |
| 2746 | * <p> |
| 2747 | * The data set within the account that this row belongs to. This allows |
| 2748 | * multiple sync adapters for the same account type to distinguish between |
| 2749 | * each others' data. The combination of {@link #ACCOUNT_TYPE}, |
| 2750 | * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data |
| 2751 | * that is associated with a single sync adapter. |
| 2752 | * </p> |
| 2753 | * <p> |
| 2754 | * This is empty by default, and is completely optional. It only needs to |
| 2755 | * be populated if multiple sync adapters are entering distinct data for |
| 2756 | * the same account type and account name. |
| 2757 | * </p> |
| 2758 | * <p> |
| 2759 | * It should be set at the time the raw contact is inserted and never |
| 2760 | * changed afterwards. |
| 2761 | * </p> |
| 2762 | * </td> |
| 2763 | * </tr> |
| 2764 | * <tr> |
| 2765 | * <td>String</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2766 | * <td>{@link #SOURCE_ID}</td> |
| 2767 | * <td>read/write</td> |
| 2768 | * <td>String that uniquely identifies this row to its source account. |
| 2769 | * Typically it is set at the time the raw contact is inserted and never |
| 2770 | * changed afterwards. The one notable exception is a new raw contact: it |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2771 | * will have an account name and type (and possibly a data set), but no |
| 2772 | * source id. This indicates to the sync adapter that a new contact needs |
| 2773 | * to be created server-side and its ID stored in the corresponding |
| 2774 | * SOURCE_ID field on the phone. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2775 | * </td> |
| 2776 | * </tr> |
| 2777 | * <tr> |
| 2778 | * <td>int</td> |
| 2779 | * <td>{@link #VERSION}</td> |
| 2780 | * <td>read-only</td> |
| 2781 | * <td>Version number that is updated whenever this row or its related data |
| 2782 | * changes. This field can be used for optimistic locking of a raw contact. |
| 2783 | * </td> |
| 2784 | * </tr> |
| 2785 | * <tr> |
| 2786 | * <td>int</td> |
| 2787 | * <td>{@link #DIRTY}</td> |
| 2788 | * <td>read/write</td> |
| 2789 | * <td>Flag indicating that {@link #VERSION} has changed, and this row needs |
| 2790 | * to be synchronized by its owning account. The value is set to "1" automatically |
| 2791 | * whenever the raw contact changes, unless the URI has the |
| 2792 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified. |
| 2793 | * The sync adapter should always supply this query parameter to prevent |
| 2794 | * unnecessary synchronization: user changes some data on the server, |
| 2795 | * the sync adapter updates the contact on the phone (without the |
| 2796 | * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag, |
| 2797 | * which triggers a sync to bring the changes to the server. |
| 2798 | * </td> |
| 2799 | * </tr> |
| 2800 | * <tr> |
| 2801 | * <td>String</td> |
| 2802 | * <td>{@link #SYNC1}</td> |
| 2803 | * <td>read/write</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2804 | * <td>Generic column provided for arbitrary use by sync adapters. |
| 2805 | * The content provider |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2806 | * stores this information on behalf of the sync adapter but does not |
| 2807 | * interpret it in any way. |
| 2808 | * </td> |
| 2809 | * </tr> |
| 2810 | * <tr> |
| 2811 | * <td>String</td> |
| 2812 | * <td>{@link #SYNC2}</td> |
| 2813 | * <td>read/write</td> |
| 2814 | * <td>Generic column for use by sync adapters. |
| 2815 | * </td> |
| 2816 | * </tr> |
| 2817 | * <tr> |
| 2818 | * <td>String</td> |
| 2819 | * <td>{@link #SYNC3}</td> |
| 2820 | * <td>read/write</td> |
| 2821 | * <td>Generic column for use by sync adapters. |
| 2822 | * </td> |
| 2823 | * </tr> |
| 2824 | * <tr> |
| 2825 | * <td>String</td> |
| 2826 | * <td>{@link #SYNC4}</td> |
| 2827 | * <td>read/write</td> |
| 2828 | * <td>Generic column for use by sync adapters. |
| 2829 | * </td> |
| 2830 | * </tr> |
| 2831 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2832 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2833 | public static final class RawContacts implements BaseColumns, RawContactsColumns, |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 2834 | ContactOptionsColumns, ContactNameColumns, SyncColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2835 | /** |
| 2836 | * This utility class cannot be instantiated |
| 2837 | */ |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 2838 | private RawContacts() { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2839 | } |
| 2840 | |
| 2841 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2842 | * The content:// style URI for this table, which requests a directory of |
| 2843 | * raw contact rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2844 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 2845 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2846 | |
| 2847 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2848 | * The MIME type of the results from {@link #CONTENT_URI} when a specific |
| 2849 | * ID value is not provided, and multiple raw contacts may be returned. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2850 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2851 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2852 | |
| 2853 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2854 | * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI}, |
| 2855 | * yielding a subdirectory of a single person. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2856 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2857 | 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] | 2858 | |
| 2859 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2860 | * Aggregation mode: aggregate immediately after insert or update operation(s) are complete. |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2861 | */ |
| 2862 | public static final int AGGREGATION_MODE_DEFAULT = 0; |
| 2863 | |
| 2864 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2865 | * Aggregation mode: aggregate at the time the raw contact is inserted/updated. |
| 2866 | * @deprecated Aggregation is synchronous, this historic value is a no-op |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2867 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2868 | @Deprecated |
Omari Stephens | bc9aa77 | 2009-09-08 19:10:53 -0700 | [diff] [blame] | 2869 | public static final int AGGREGATION_MODE_IMMEDIATE = 1; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2870 | |
| 2871 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2872 | * <p> |
| 2873 | * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later. |
| 2874 | * Changes to the raw contact will update the associated aggregate contact but will not |
| 2875 | * result in any change in how the contact is aggregated. Similar to |
| 2876 | * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding |
| 2877 | * {@link Contacts} aggregate. |
| 2878 | * </p> |
| 2879 | * <p> |
| 2880 | * This can be used to postpone aggregation until after a series of updates, for better |
| 2881 | * performance and/or user experience. |
| 2882 | * </p> |
| 2883 | * <p> |
| 2884 | * Note that changing |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2885 | * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2886 | * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any |
| 2887 | * subsequent |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2888 | * change to the raw contact's data will. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2889 | * </p> |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2890 | */ |
| 2891 | public static final int AGGREGATION_MODE_SUSPENDED = 2; |
| 2892 | |
| 2893 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2894 | * <p> |
| 2895 | * Aggregation mode: never aggregate this raw contact. The raw contact will not |
| 2896 | * have a corresponding {@link Contacts} aggregate and therefore will not be included in |
| 2897 | * {@link Contacts} query results. |
| 2898 | * </p> |
| 2899 | * <p> |
| 2900 | * For example, this mode can be used for a raw contact that is marked for deletion while |
| 2901 | * waiting for the deletion to occur on the server side. |
| 2902 | * </p> |
| 2903 | * |
| 2904 | * @see #AGGREGATION_MODE_SUSPENDED |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2905 | */ |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2906 | public static final int AGGREGATION_MODE_DISABLED = 3; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2907 | |
| 2908 | /** |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 2909 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 2910 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
| 2911 | * entry of the given {@link RawContacts} entry. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2912 | */ |
| 2913 | public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) { |
| 2914 | // TODO: use a lighter query by joining rawcontacts with contacts in provider |
| 2915 | final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY); |
| 2916 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 2917 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 2918 | }, null, null, null); |
| 2919 | |
| 2920 | Uri lookupUri = null; |
| 2921 | try { |
| 2922 | if (cursor != null && cursor.moveToFirst()) { |
| 2923 | final long contactId = cursor.getLong(0); |
| 2924 | final String lookupKey = cursor.getString(1); |
| 2925 | return Contacts.getLookupUri(contactId, lookupKey); |
| 2926 | } |
| 2927 | } finally { |
| 2928 | if (cursor != null) cursor.close(); |
| 2929 | } |
| 2930 | return lookupUri; |
| 2931 | } |
| 2932 | |
| 2933 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2934 | * 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] | 2935 | * {@link ContactsContract.Data} rows. To access this directory |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2936 | * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2937 | */ |
| 2938 | public static final class Data implements BaseColumns, DataColumns { |
| 2939 | /** |
| 2940 | * no public constructor since this is a utility class |
| 2941 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2942 | private Data() { |
| 2943 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2944 | |
| 2945 | /** |
| 2946 | * The directory twig for this sub-table |
| 2947 | */ |
| 2948 | public static final String CONTENT_DIRECTORY = "data"; |
| 2949 | } |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2950 | |
| 2951 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2952 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2953 | * 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] | 2954 | * {@link ContactsContract.Data} rows. To access this directory append |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2955 | * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2956 | * {@link RawContactsEntity} for a stand-alone table containing the same |
| 2957 | * data. |
| 2958 | * </p> |
| 2959 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2960 | * Entity has two ID fields: {@link #_ID} for the raw contact |
| 2961 | * and {@link #DATA_ID} for the data rows. |
| 2962 | * Entity always contains at least one row, even if there are no |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2963 | * 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] | 2964 | * null. |
| 2965 | * </p> |
| 2966 | * <p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2967 | * Using Entity should be preferred to using two separate queries: |
| 2968 | * RawContacts followed by Data. The reason is that Entity reads all |
| 2969 | * data for a raw contact in one transaction, so there is no possibility |
| 2970 | * of the data changing between the two queries. |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2971 | */ |
| 2972 | public static final class Entity implements BaseColumns, DataColumns { |
| 2973 | /** |
| 2974 | * no public constructor since this is a utility class |
| 2975 | */ |
| 2976 | private Entity() { |
| 2977 | } |
| 2978 | |
| 2979 | /** |
| 2980 | * The directory twig for this sub-table |
| 2981 | */ |
| 2982 | public static final String CONTENT_DIRECTORY = "entity"; |
| 2983 | |
| 2984 | /** |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 2985 | * 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] | 2986 | * data rows. |
| 2987 | * <P>Type: INTEGER</P> |
| 2988 | */ |
| 2989 | public static final String DATA_ID = "data_id"; |
| 2990 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2991 | |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2992 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2993 | * <p> |
| 2994 | * A sub-directory of a single raw contact that contains all of its |
| 2995 | * {@link ContactsContract.StreamItems} rows. To access this directory append |
| 2996 | * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See |
| 2997 | * {@link ContactsContract.StreamItems} for a stand-alone table containing the |
| 2998 | * same data. |
| 2999 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3000 | * <p> |
| 3001 | * Access to the social stream through this sub-directory requires additional permissions |
| 3002 | * beyond the read/write contact permissions required by the provider. Querying for |
| 3003 | * social stream data requires android.permission.READ_SOCIAL_STREAM permission, and |
| 3004 | * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM |
| 3005 | * permission. |
| 3006 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3007 | * |
| 3008 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3009 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3010 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3011 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3012 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3013 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3014 | public static final class StreamItems implements BaseColumns, StreamItemsColumns { |
| 3015 | /** |
| 3016 | * No public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3017 | * |
| 3018 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3019 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3020 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3021 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3022 | private StreamItems() { |
| 3023 | } |
| 3024 | |
| 3025 | /** |
| 3026 | * The directory twig for this sub-table |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3027 | * |
| 3028 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3029 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3030 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3031 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3032 | public static final String CONTENT_DIRECTORY = "stream_items"; |
| 3033 | } |
| 3034 | |
| 3035 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 3036 | * <p> |
| 3037 | * A sub-directory of a single raw contact that represents its primary |
| 3038 | * display photo. To access this directory append |
| 3039 | * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI. |
| 3040 | * The resulting URI represents an image file, and should be interacted with |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3041 | * using ContentResolver.openAssetFileDescriptor. |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 3042 | * <p> |
| 3043 | * <p> |
| 3044 | * Note that this sub-directory also supports opening the photo as an asset file |
| 3045 | * in write mode. Callers can create or replace the primary photo associated |
| 3046 | * with this raw contact by opening the asset file and writing the full-size |
| 3047 | * photo contents into it. When the file is closed, the image will be parsed, |
| 3048 | * sized down if necessary for the full-size display photo and thumbnail |
| 3049 | * dimensions, and stored. |
| 3050 | * </p> |
| 3051 | * <p> |
| 3052 | * Usage example: |
| 3053 | * <pre> |
| 3054 | * public void writeDisplayPhoto(long rawContactId, byte[] photo) { |
| 3055 | * Uri rawContactPhotoUri = Uri.withAppendedPath( |
| 3056 | * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), |
| 3057 | * RawContacts.DisplayPhoto.CONTENT_DIRECTORY); |
| 3058 | * try { |
| 3059 | * AssetFileDescriptor fd = |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3060 | * getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 3061 | * OutputStream os = fd.createOutputStream(); |
| 3062 | * os.write(photo); |
| 3063 | * os.close(); |
| 3064 | * fd.close(); |
| 3065 | * } catch (IOException e) { |
| 3066 | * // Handle error cases. |
| 3067 | * } |
| 3068 | * } |
| 3069 | * </pre> |
| 3070 | * </p> |
| 3071 | */ |
| 3072 | public static final class DisplayPhoto { |
| 3073 | /** |
| 3074 | * No public constructor since this is a utility class |
| 3075 | */ |
| 3076 | private DisplayPhoto() { |
| 3077 | } |
| 3078 | |
| 3079 | /** |
| 3080 | * The directory twig for this sub-table |
| 3081 | */ |
| 3082 | public static final String CONTENT_DIRECTORY = "display_photo"; |
| 3083 | } |
| 3084 | |
| 3085 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 3086 | * TODO: javadoc |
| 3087 | * @param cursor |
| 3088 | * @return |
| 3089 | */ |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3090 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 3091 | return new EntityIteratorImpl(cursor); |
| 3092 | } |
| 3093 | |
| 3094 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 3095 | private static final String[] DATA_KEYS = new String[]{ |
| 3096 | Data.DATA1, |
| 3097 | Data.DATA2, |
| 3098 | Data.DATA3, |
| 3099 | Data.DATA4, |
| 3100 | Data.DATA5, |
| 3101 | Data.DATA6, |
| 3102 | Data.DATA7, |
| 3103 | Data.DATA8, |
| 3104 | Data.DATA9, |
| 3105 | Data.DATA10, |
| 3106 | Data.DATA11, |
| 3107 | Data.DATA12, |
| 3108 | Data.DATA13, |
| 3109 | Data.DATA14, |
| 3110 | Data.DATA15, |
| 3111 | Data.SYNC1, |
| 3112 | Data.SYNC2, |
| 3113 | Data.SYNC3, |
| 3114 | Data.SYNC4}; |
| 3115 | |
| 3116 | public EntityIteratorImpl(Cursor cursor) { |
| 3117 | super(cursor); |
| 3118 | } |
| 3119 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 3120 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3121 | public android.content.Entity getEntityAndIncrementCursor(Cursor cursor) |
| 3122 | throws RemoteException { |
| 3123 | final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID); |
| 3124 | final long rawContactId = cursor.getLong(columnRawContactId); |
| 3125 | |
| 3126 | // we expect the cursor is already at the row we need to read from |
| 3127 | ContentValues cv = new ContentValues(); |
| 3128 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME); |
| 3129 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE); |
Katherine Kuan | 1d83723 | 2011-08-24 16:06:06 -0700 | [diff] [blame] | 3130 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DATA_SET); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3131 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID); |
| 3132 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY); |
| 3133 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION); |
| 3134 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID); |
| 3135 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1); |
| 3136 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2); |
| 3137 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3); |
| 3138 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4); |
| 3139 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED); |
| 3140 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID); |
| 3141 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3142 | android.content.Entity contact = new android.content.Entity(cv); |
| 3143 | |
| 3144 | // read data rows until the contact id changes |
| 3145 | do { |
| 3146 | if (rawContactId != cursor.getLong(columnRawContactId)) { |
| 3147 | break; |
| 3148 | } |
| 3149 | // add the data to to the contact |
| 3150 | cv = new ContentValues(); |
| 3151 | cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID))); |
| 3152 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 3153 | Data.RES_PACKAGE); |
| 3154 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE); |
| 3155 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY); |
| 3156 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, |
| 3157 | Data.IS_SUPER_PRIMARY); |
| 3158 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION); |
| 3159 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 3160 | CommonDataKinds.GroupMembership.GROUP_SOURCE_ID); |
| 3161 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 3162 | Data.DATA_VERSION); |
| 3163 | for (String key : DATA_KEYS) { |
| 3164 | final int columnIndex = cursor.getColumnIndexOrThrow(key); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 3165 | switch (cursor.getType(columnIndex)) { |
| 3166 | case Cursor.FIELD_TYPE_NULL: |
| 3167 | // don't put anything |
| 3168 | break; |
| 3169 | case Cursor.FIELD_TYPE_INTEGER: |
| 3170 | case Cursor.FIELD_TYPE_FLOAT: |
| 3171 | case Cursor.FIELD_TYPE_STRING: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 3172 | cv.put(key, cursor.getString(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 3173 | break; |
| 3174 | case Cursor.FIELD_TYPE_BLOB: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 3175 | cv.put(key, cursor.getBlob(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 3176 | break; |
| 3177 | default: |
| 3178 | throw new IllegalStateException("Invalid or unhandled data type"); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3179 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3180 | } |
| 3181 | contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv); |
| 3182 | } while (cursor.moveToNext()); |
| 3183 | |
| 3184 | return contact; |
| 3185 | } |
| 3186 | |
| 3187 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3188 | } |
| 3189 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3190 | /** |
| 3191 | * Social status update columns. |
| 3192 | * |
| 3193 | * @see StatusUpdates |
| 3194 | * @see ContactsContract.Data |
| 3195 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3196 | protected interface StatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3197 | /** |
Dmitri Plotnikov | a60479d | 2009-09-27 20:16:31 -0700 | [diff] [blame] | 3198 | * Contact's latest presence level. |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3199 | * <P>Type: INTEGER (one of the values below)</P> |
| 3200 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3201 | public static final String PRESENCE = "mode"; |
| 3202 | |
| 3203 | /** |
| 3204 | * @deprecated use {@link #PRESENCE} |
| 3205 | */ |
| 3206 | @Deprecated |
| 3207 | public static final String PRESENCE_STATUS = PRESENCE; |
| 3208 | |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3209 | /** |
| 3210 | * An allowed value of {@link #PRESENCE}. |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3211 | */ |
| 3212 | int OFFLINE = 0; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3213 | |
| 3214 | /** |
| 3215 | * An allowed value of {@link #PRESENCE}. |
| 3216 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3217 | int INVISIBLE = 1; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3218 | |
| 3219 | /** |
| 3220 | * An allowed value of {@link #PRESENCE}. |
| 3221 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3222 | int AWAY = 2; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3223 | |
| 3224 | /** |
| 3225 | * An allowed value of {@link #PRESENCE}. |
| 3226 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3227 | int IDLE = 3; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3228 | |
| 3229 | /** |
| 3230 | * An allowed value of {@link #PRESENCE}. |
| 3231 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3232 | int DO_NOT_DISTURB = 4; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3233 | |
| 3234 | /** |
| 3235 | * An allowed value of {@link #PRESENCE}. |
| 3236 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3237 | int AVAILABLE = 5; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3238 | |
| 3239 | /** |
| 3240 | * Contact latest status update. |
| 3241 | * <p>Type: TEXT</p> |
| 3242 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3243 | public static final String STATUS = "status"; |
| 3244 | |
| 3245 | /** |
| 3246 | * @deprecated use {@link #STATUS} |
| 3247 | */ |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3248 | @Deprecated |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3249 | public static final String PRESENCE_CUSTOM_STATUS = STATUS; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3250 | |
| 3251 | /** |
| 3252 | * The absolute time in milliseconds when the latest status was inserted/updated. |
| 3253 | * <p>Type: NUMBER</p> |
| 3254 | */ |
| 3255 | public static final String STATUS_TIMESTAMP = "status_ts"; |
| 3256 | |
| 3257 | /** |
| 3258 | * The package containing resources for this status: label and icon. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3259 | * <p>Type: TEXT</p> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3260 | */ |
| 3261 | public static final String STATUS_RES_PACKAGE = "status_res_package"; |
| 3262 | |
| 3263 | /** |
| 3264 | * The resource ID of the label describing the source of the status update, e.g. "Google |
| 3265 | * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 3266 | * <p>Type: NUMBER</p> |
| 3267 | */ |
| 3268 | public static final String STATUS_LABEL = "status_label"; |
| 3269 | |
| 3270 | /** |
| 3271 | * The resource ID of the icon for the source of the status update. |
| 3272 | * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 3273 | * <p>Type: NUMBER</p> |
| 3274 | */ |
| 3275 | public static final String STATUS_ICON = "status_icon"; |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3276 | |
| 3277 | /** |
| 3278 | * Contact's audio/video chat capability level. |
| 3279 | * <P>Type: INTEGER (one of the values below)</P> |
| 3280 | */ |
| 3281 | public static final String CHAT_CAPABILITY = "chat_capability"; |
| 3282 | |
| 3283 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3284 | * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone |
| 3285 | * and speaker) |
| 3286 | */ |
| 3287 | public static final int CAPABILITY_HAS_VOICE = 1; |
| 3288 | |
| 3289 | /** |
| 3290 | * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device can |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3291 | * display a video feed. |
| 3292 | */ |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3293 | public static final int CAPABILITY_HAS_VIDEO = 2; |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3294 | |
| 3295 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3296 | * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device has a |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3297 | * camera that can be used for video chat (e.g. a front-facing camera on a phone). |
| 3298 | */ |
| 3299 | public static final int CAPABILITY_HAS_CAMERA = 4; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3300 | } |
| 3301 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3302 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3303 | * <p> |
| 3304 | * Constants for the stream_items table, which contains social stream updates from |
| 3305 | * the user's contact list. |
| 3306 | * </p> |
| 3307 | * <p> |
| 3308 | * Only a certain number of stream items will ever be stored under a given raw contact. |
| 3309 | * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to |
| 3310 | * determine this limit, and should restrict the number of items inserted in any given |
| 3311 | * transaction correspondingly. Insertion of more items beyond the limit will |
| 3312 | * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}. |
| 3313 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3314 | * <p> |
| 3315 | * Access to the social stream through these URIs requires additional permissions beyond the |
| 3316 | * read/write contact permissions required by the provider. Querying for social stream data |
| 3317 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social |
| 3318 | * stream items requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3319 | * </p> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3320 | * <h3>Account check</h3> |
| 3321 | * <p> |
| 3322 | * The content URIs to the insert, update and delete operations are required to have the account |
| 3323 | * information matching that of the owning raw contact as query parameters, namely |
| 3324 | * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. |
| 3325 | * {@link RawContacts#DATA_SET} isn't required. |
| 3326 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3327 | * <h3>Operations</h3> |
| 3328 | * <dl> |
| 3329 | * <dt><b>Insert</b></dt> |
| 3330 | * <dd> |
| 3331 | * <p>Social stream updates are always associated with a raw contact. There are a couple |
| 3332 | * of ways to insert these entries. |
| 3333 | * <dl> |
| 3334 | * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt> |
| 3335 | * <dd> |
| 3336 | * <pre> |
| 3337 | * ContentValues values = new ContentValues(); |
| 3338 | * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); |
| 3339 | * values.put(StreamItems.TIMESTAMP, timestamp); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3340 | * values.put(StreamItems.COMMENTS, "3 people reshared this"); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3341 | * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon(); |
| 3342 | * ContentUris.appendId(builder, rawContactId); |
| 3343 | * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY); |
| 3344 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3345 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3346 | * Uri streamItemUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3347 | * long streamItemId = ContentUris.parseId(streamItemUri); |
| 3348 | * </pre> |
| 3349 | * </dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3350 | * <dt>Via {@link StreamItems#CONTENT_URI}:</dt> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3351 | * <dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3352 | *<pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3353 | * ContentValues values = new ContentValues(); |
| 3354 | * values.put(StreamItems.RAW_CONTACT_ID, rawContactId); |
| 3355 | * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); |
| 3356 | * values.put(StreamItems.TIMESTAMP, timestamp); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3357 | * values.put(StreamItems.COMMENTS, "3 people reshared this"); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3358 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3359 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3360 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3361 | * Uri streamItemUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3362 | * long streamItemId = ContentUris.parseId(streamItemUri); |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3363 | *</pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3364 | * </dd> |
| 3365 | * </dl> |
| 3366 | * </dd> |
| 3367 | * </p> |
| 3368 | * <p> |
| 3369 | * Once a {@link StreamItems} entry has been inserted, photos associated with that |
| 3370 | * social update can be inserted. For example, after one of the insertions above, |
| 3371 | * photos could be added to the stream item in one of the following ways: |
| 3372 | * <dl> |
| 3373 | * <dt>Via a URI including the stream item ID:</dt> |
| 3374 | * <dd> |
| 3375 | * <pre> |
| 3376 | * values.clear(); |
| 3377 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3378 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3379 | * getContentResolver().insert(Uri.withAppendedPath( |
| 3380 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId), |
| 3381 | * StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values); |
| 3382 | * </pre> |
| 3383 | * </dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3384 | * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3385 | * <dd> |
| 3386 | * <pre> |
| 3387 | * values.clear(); |
| 3388 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
| 3389 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3390 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3391 | * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values); |
| 3392 | * </pre> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3393 | * <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] | 3394 | * photos in a single transaction, by using {@link ContentProviderOperation} with |
| 3395 | * back references to populate the stream item ID in the {@link ContentValues}. |
| 3396 | * </dd> |
| 3397 | * </dl> |
| 3398 | * </p> |
| 3399 | * </dd> |
| 3400 | * <dt><b>Update</b></dt> |
| 3401 | * <dd>Updates can be performed by appending the stream item ID to the |
| 3402 | * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were |
| 3403 | * created by the calling package can be updated.</dd> |
| 3404 | * <dt><b>Delete</b></dt> |
| 3405 | * <dd>Deletes can be performed by appending the stream item ID to the |
| 3406 | * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were |
| 3407 | * created by the calling package can be deleted.</dd> |
| 3408 | * <dt><b>Query</b></dt> |
| 3409 | * <dl> |
| 3410 | * <dt>Finding all social stream updates for a given contact</dt> |
| 3411 | * <dd>By Contact ID: |
| 3412 | * <pre> |
| 3413 | * Cursor c = getContentResolver().query(Uri.withAppendedPath( |
| 3414 | * ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId), |
| 3415 | * Contacts.StreamItems.CONTENT_DIRECTORY), |
| 3416 | * null, null, null, null); |
| 3417 | * </pre> |
| 3418 | * </dd> |
| 3419 | * <dd>By lookup key: |
| 3420 | * <pre> |
| 3421 | * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon() |
| 3422 | * .appendPath(lookupKey) |
| 3423 | * .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(), |
| 3424 | * null, null, null, null); |
| 3425 | * </pre> |
| 3426 | * </dd> |
| 3427 | * <dt>Finding all social stream updates for a given raw contact</dt> |
| 3428 | * <dd> |
| 3429 | * <pre> |
| 3430 | * Cursor c = getContentResolver().query(Uri.withAppendedPath( |
| 3431 | * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), |
| 3432 | * RawContacts.StreamItems.CONTENT_DIRECTORY)), |
| 3433 | * null, null, null, null); |
| 3434 | * </pre> |
| 3435 | * </dd> |
| 3436 | * <dt>Querying for a specific stream item by ID</dt> |
| 3437 | * <dd> |
| 3438 | * <pre> |
| 3439 | * Cursor c = getContentResolver().query(ContentUris.withAppendedId( |
| 3440 | * StreamItems.CONTENT_URI, streamItemId), |
| 3441 | * null, null, null, null); |
| 3442 | * </pre> |
| 3443 | * </dd> |
| 3444 | * </dl> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3445 | * |
| 3446 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3447 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3448 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3449 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3450 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3451 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3452 | public static final class StreamItems implements BaseColumns, StreamItemsColumns { |
| 3453 | /** |
| 3454 | * This utility class cannot be instantiated |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3455 | * |
| 3456 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3457 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3458 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3459 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3460 | private StreamItems() { |
| 3461 | } |
| 3462 | |
| 3463 | /** |
| 3464 | * The content:// style URI for this table, which handles social network stream |
| 3465 | * updates for the user's contacts. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3466 | * |
| 3467 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3468 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3469 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3470 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3471 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items"); |
| 3472 | |
| 3473 | /** |
| 3474 | * <p> |
| 3475 | * A content:// style URI for the photos stored in a sub-table underneath |
| 3476 | * stream items. This is only used for inserts, and updates - queries and deletes |
| 3477 | * for photos should be performed by appending |
| 3478 | * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a |
| 3479 | * specific stream item. |
| 3480 | * </p> |
| 3481 | * <p> |
| 3482 | * When using this URI, the stream item ID for the photo(s) must be identified |
| 3483 | * in the {@link ContentValues} passed in. |
| 3484 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3485 | * |
| 3486 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3487 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3488 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3489 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3490 | public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo"); |
| 3491 | |
| 3492 | /** |
| 3493 | * 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] | 3494 | * that will be stored under any single raw contact. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3495 | * |
| 3496 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3497 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3498 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3499 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3500 | public static final Uri CONTENT_LIMIT_URI = |
| 3501 | Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit"); |
| 3502 | |
| 3503 | /** |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3504 | * The MIME type of a directory of stream items. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3505 | * |
| 3506 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3507 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3508 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3509 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3510 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item"; |
| 3511 | |
| 3512 | /** |
| 3513 | * The MIME type of a single stream item. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3514 | * |
| 3515 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3516 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3517 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3518 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3519 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/stream_item"; |
| 3520 | |
| 3521 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3522 | * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will |
| 3523 | * contain this column, with the value indicating the maximum number of |
| 3524 | * stream items that will be stored under any single raw contact. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3525 | * |
| 3526 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3527 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3528 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3529 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3530 | public static final String MAX_ITEMS = "max_items"; |
| 3531 | |
| 3532 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3533 | * <p> |
| 3534 | * A sub-directory of a single stream item entry that contains all of its |
| 3535 | * photo rows. To access this |
| 3536 | * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to |
| 3537 | * an individual stream item URI. |
| 3538 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3539 | * <p> |
| 3540 | * Access to social stream photos requires additional permissions beyond the read/write |
| 3541 | * contact permissions required by the provider. Querying for social stream photos |
| 3542 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating |
| 3543 | * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3544 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3545 | * |
| 3546 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3547 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3548 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3549 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3550 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3551 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3552 | public static final class StreamItemPhotos |
| 3553 | implements BaseColumns, StreamItemPhotosColumns { |
| 3554 | /** |
| 3555 | * No public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3556 | * |
| 3557 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3558 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3559 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3560 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3561 | private StreamItemPhotos() { |
| 3562 | } |
| 3563 | |
| 3564 | /** |
| 3565 | * The directory twig for this sub-table |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3566 | * |
| 3567 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3568 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3569 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3570 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3571 | public static final String CONTENT_DIRECTORY = "photo"; |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3572 | |
| 3573 | /** |
| 3574 | * The MIME type of a directory of stream item photos. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3575 | * |
| 3576 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3577 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3578 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3579 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3580 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item_photo"; |
| 3581 | |
| 3582 | /** |
| 3583 | * The MIME type of a single stream item photo. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3584 | * |
| 3585 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3586 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3587 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3588 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3589 | public static final String CONTENT_ITEM_TYPE |
| 3590 | = "vnd.android.cursor.item/stream_item_photo"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3591 | } |
| 3592 | } |
| 3593 | |
| 3594 | /** |
| 3595 | * Columns in the StreamItems table. |
| 3596 | * |
| 3597 | * @see ContactsContract.StreamItems |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3598 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3599 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3600 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3601 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3602 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3603 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3604 | protected interface StreamItemsColumns { |
| 3605 | /** |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3606 | * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} |
| 3607 | * that this stream item belongs to. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3608 | * |
| 3609 | * <p>Type: INTEGER</p> |
| 3610 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3611 | * |
| 3612 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3613 | * cursors returned from related queries will be empty. |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3614 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3615 | @Deprecated |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3616 | public static final String CONTACT_ID = "contact_id"; |
| 3617 | |
| 3618 | /** |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3619 | * A reference to the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY} |
| 3620 | * that this stream item belongs to. |
| 3621 | * |
| 3622 | * <p>Type: TEXT</p> |
| 3623 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 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. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3627 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3628 | @Deprecated |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3629 | public static final String CONTACT_LOOKUP_KEY = "contact_lookup"; |
| 3630 | |
| 3631 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3632 | * A reference to the {@link RawContacts#_ID} |
| 3633 | * that this stream item belongs to. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3634 | * <p>Type: INTEGER</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3635 | * |
| 3636 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3637 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3638 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3639 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3640 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 3641 | |
| 3642 | /** |
| 3643 | * The package name to use when creating {@link Resources} objects for |
| 3644 | * this stream item. This value is only designed for use when building |
| 3645 | * user interfaces, and should not be used to infer the owner. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3646 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3647 | * |
| 3648 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3649 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3650 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3651 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3652 | public static final String RES_PACKAGE = "res_package"; |
| 3653 | |
| 3654 | /** |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3655 | * The account type to which the raw_contact of this item is associated. See |
| 3656 | * {@link RawContacts#ACCOUNT_TYPE} |
| 3657 | * |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3658 | * <p>Type: TEXT</p> |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3659 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3660 | * |
| 3661 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3662 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3663 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3664 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3665 | public static final String ACCOUNT_TYPE = "account_type"; |
| 3666 | |
| 3667 | /** |
| 3668 | * The account name to which the raw_contact of this item is associated. See |
| 3669 | * {@link RawContacts#ACCOUNT_NAME} |
| 3670 | * |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3671 | * <p>Type: TEXT</p> |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3672 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3673 | * |
| 3674 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3675 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3676 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3677 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3678 | public static final String ACCOUNT_NAME = "account_name"; |
| 3679 | |
| 3680 | /** |
| 3681 | * The data set within the account that the raw_contact of this row belongs to. This allows |
| 3682 | * multiple sync adapters for the same account type to distinguish between |
| 3683 | * each others' data. |
| 3684 | * {@link RawContacts#DATA_SET} |
| 3685 | * |
| 3686 | * <P>Type: TEXT</P> |
| 3687 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3688 | * |
| 3689 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3690 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3691 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3692 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3693 | public static final String DATA_SET = "data_set"; |
| 3694 | |
| 3695 | /** |
| 3696 | * The source_id of the raw_contact that this row belongs to. |
| 3697 | * {@link RawContacts#SOURCE_ID} |
| 3698 | * |
| 3699 | * <P>Type: TEXT</P> |
| 3700 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3701 | * |
| 3702 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3703 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3704 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3705 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3706 | public static final String RAW_CONTACT_SOURCE_ID = "raw_contact_source_id"; |
| 3707 | |
| 3708 | /** |
| 3709 | * The resource name of the icon for the source of the stream item. |
| 3710 | * This resource should be scoped by the {@link #RES_PACKAGE}. As this can only reference |
| 3711 | * drawables, the "@drawable/" prefix must be omitted. |
| 3712 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3713 | * |
| 3714 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3715 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3716 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3717 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3718 | public static final String RES_ICON = "icon"; |
| 3719 | |
| 3720 | /** |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3721 | * The resource name of the label describing the source of the status update, e.g. "Google |
| 3722 | * Talk". This resource should be scoped by the {@link #RES_PACKAGE}. As this can only |
| 3723 | * reference strings, the "@string/" prefix must be omitted. |
| 3724 | * <p>Type: TEXT</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3725 | * |
| 3726 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3727 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3728 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3729 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3730 | public static final String RES_LABEL = "label"; |
| 3731 | |
| 3732 | /** |
| 3733 | * <P> |
| 3734 | * The main textual contents of the item. Typically this is content |
| 3735 | * that was posted by the source of this stream item, but it can also |
| 3736 | * be a textual representation of an action (e.g. ”Checked in at Joe's”). |
| 3737 | * This text is displayed to the user and allows formatting and embedded |
| 3738 | * resource images via HTML (as parseable via |
| 3739 | * {@link android.text.Html#fromHtml}). |
| 3740 | * </P> |
| 3741 | * <P> |
| 3742 | * Long content may be truncated and/or ellipsized - the exact behavior |
| 3743 | * is unspecified, but it should not break tags. |
| 3744 | * </P> |
| 3745 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3746 | * |
| 3747 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3748 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3749 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3750 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3751 | public static final String TEXT = "text"; |
| 3752 | |
| 3753 | /** |
| 3754 | * The absolute time (milliseconds since epoch) when this stream item was |
| 3755 | * inserted/updated. |
| 3756 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3757 | * |
| 3758 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3759 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3760 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3761 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3762 | public static final String TIMESTAMP = "timestamp"; |
| 3763 | |
| 3764 | /** |
| 3765 | * <P> |
| 3766 | * Summary information about the stream item, for example to indicate how |
| 3767 | * many people have reshared it, how many have liked it, how many thumbs |
| 3768 | * up and/or thumbs down it has, what the original source was, etc. |
| 3769 | * </P> |
| 3770 | * <P> |
| 3771 | * This text is displayed to the user and allows simple formatting via |
| 3772 | * HTML, in the same manner as {@link #TEXT} allows. |
| 3773 | * </P> |
| 3774 | * <P> |
| 3775 | * Long content may be truncated and/or ellipsized - the exact behavior |
| 3776 | * is unspecified, but it should not break tags. |
| 3777 | * </P> |
| 3778 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3779 | * |
| 3780 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3781 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3782 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3783 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3784 | public static final String COMMENTS = "comments"; |
| 3785 | |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3786 | /** |
| 3787 | * Generic column for use by sync adapters. |
| 3788 | * |
| 3789 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3790 | * cursors returned from related queries will be empty. |
| 3791 | */ |
| 3792 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3793 | public static final String SYNC1 = "stream_item_sync1"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3794 | /** |
| 3795 | * Generic column for use by sync adapters. |
| 3796 | * |
| 3797 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3798 | * cursors returned from related queries will be empty. |
| 3799 | */ |
| 3800 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3801 | public static final String SYNC2 = "stream_item_sync2"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3802 | /** |
| 3803 | * Generic column for use by sync adapters. |
| 3804 | * |
| 3805 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3806 | * cursors returned from related queries will be empty. |
| 3807 | */ |
| 3808 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3809 | public static final String SYNC3 = "stream_item_sync3"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3810 | /** |
| 3811 | * Generic column for use by sync adapters. |
| 3812 | * |
| 3813 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3814 | * cursors returned from related queries will be empty. |
| 3815 | */ |
| 3816 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3817 | public static final String SYNC4 = "stream_item_sync4"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3818 | } |
| 3819 | |
| 3820 | /** |
| 3821 | * <p> |
| 3822 | * Constants for the stream_item_photos table, which contains photos associated with |
| 3823 | * social stream updates. |
| 3824 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3825 | * <p> |
| 3826 | * Access to social stream photos requires additional permissions beyond the read/write |
| 3827 | * contact permissions required by the provider. Querying for social stream photos |
| 3828 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating |
| 3829 | * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3830 | * </p> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3831 | * <h3>Account check</h3> |
| 3832 | * <p> |
| 3833 | * The content URIs to the insert, update and delete operations are required to have the account |
| 3834 | * information matching that of the owning raw contact as query parameters, namely |
| 3835 | * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. |
| 3836 | * {@link RawContacts#DATA_SET} isn't required. |
| 3837 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3838 | * <h3>Operations</h3> |
| 3839 | * <dl> |
| 3840 | * <dt><b>Insert</b></dt> |
| 3841 | * <dd> |
| 3842 | * <p>Social stream photo entries are associated with a social stream item. Photos |
| 3843 | * can be inserted into a social stream item in a couple of ways: |
| 3844 | * <dl> |
| 3845 | * <dt> |
| 3846 | * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a |
| 3847 | * stream item: |
| 3848 | * </dt> |
| 3849 | * <dd> |
| 3850 | * <pre> |
| 3851 | * ContentValues values = new ContentValues(); |
| 3852 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3853 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3854 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3855 | * ContentUris.appendId(builder, streamItemId); |
| 3856 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3857 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3858 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3859 | * Uri photoUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3860 | * long photoId = ContentUris.parseId(photoUri); |
| 3861 | * </pre> |
| 3862 | * </dd> |
| 3863 | * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> |
| 3864 | * <dd> |
| 3865 | * <pre> |
| 3866 | * ContentValues values = new ContentValues(); |
| 3867 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
| 3868 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3869 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3870 | * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); |
| 3871 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3872 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3873 | * Uri photoUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3874 | * long photoId = ContentUris.parseId(photoUri); |
| 3875 | * </pre> |
| 3876 | * </dd> |
| 3877 | * </dl> |
| 3878 | * </p> |
| 3879 | * </dd> |
| 3880 | * <dt><b>Update</b></dt> |
| 3881 | * <dd> |
| 3882 | * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry, |
| 3883 | * identified by both the stream item ID it belongs to and the stream item photo ID. |
| 3884 | * This can be specified in two ways. |
| 3885 | * <dl> |
| 3886 | * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a |
| 3887 | * stream item: |
| 3888 | * </dt> |
| 3889 | * <dd> |
| 3890 | * <pre> |
| 3891 | * ContentValues values = new ContentValues(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3892 | * values.put(StreamItemPhotos.PHOTO, newPhotoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3893 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3894 | * ContentUris.appendId(builder, streamItemId); |
| 3895 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3896 | * ContentUris.appendId(builder, streamItemPhotoId); |
| 3897 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3898 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3899 | * getContentResolver().update(builder.build(), values, null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3900 | * </pre> |
| 3901 | * </dd> |
| 3902 | * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> |
| 3903 | * <dd> |
| 3904 | * <pre> |
| 3905 | * ContentValues values = new ContentValues(); |
| 3906 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3907 | * values.put(StreamItemPhotos.PHOTO, newPhotoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3908 | * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); |
| 3909 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3910 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3911 | * getContentResolver().update(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3912 | * </pre> |
| 3913 | * </dd> |
| 3914 | * </dl> |
| 3915 | * </p> |
| 3916 | * </dd> |
| 3917 | * <dt><b>Delete</b></dt> |
| 3918 | * <dd>Deletes can be made against either a specific photo item in a stream item, or |
| 3919 | * against all or a selected subset of photo items under a stream item. |
| 3920 | * For example: |
| 3921 | * <dl> |
| 3922 | * <dt>Deleting a single photo via the |
| 3923 | * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item: |
| 3924 | * </dt> |
| 3925 | * <dd> |
| 3926 | * <pre> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3927 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3928 | * ContentUris.appendId(builder, streamItemId); |
| 3929 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3930 | * ContentUris.appendId(builder, streamItemPhotoId); |
| 3931 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3932 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3933 | * getContentResolver().delete(builder.build(), null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3934 | * </pre> |
| 3935 | * </dd> |
| 3936 | * <dt>Deleting all photos under a stream item</dt> |
| 3937 | * <dd> |
| 3938 | * <pre> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3939 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3940 | * ContentUris.appendId(builder, streamItemId); |
| 3941 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3942 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3943 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3944 | * getContentResolver().delete(builder.build(), null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3945 | * </pre> |
| 3946 | * </dd> |
| 3947 | * </dl> |
| 3948 | * </dd> |
| 3949 | * <dt><b>Query</b></dt> |
| 3950 | * <dl> |
| 3951 | * <dt>Querying for a specific photo in a stream item</dt> |
| 3952 | * <dd> |
| 3953 | * <pre> |
| 3954 | * Cursor c = getContentResolver().query( |
| 3955 | * ContentUris.withAppendedId( |
| 3956 | * Uri.withAppendedPath( |
| 3957 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) |
| 3958 | * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), |
| 3959 | * streamItemPhotoId), null, null, null, null); |
| 3960 | * </pre> |
| 3961 | * </dd> |
| 3962 | * <dt>Querying for all photos in a stream item</dt> |
| 3963 | * <dd> |
| 3964 | * <pre> |
| 3965 | * Cursor c = getContentResolver().query( |
| 3966 | * Uri.withAppendedPath( |
| 3967 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) |
| 3968 | * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), |
| 3969 | * null, null, null, StreamItemPhotos.SORT_INDEX); |
| 3970 | * </pre> |
| 3971 | * </dl> |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3972 | * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a |
| 3973 | * {@link StreamItemPhotos#PHOTO_URI}. The {@link StreamItemPhotos#PHOTO_FILE_ID} |
| 3974 | * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to |
| 3975 | * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as |
| 3976 | * an asset file, as follows: |
| 3977 | * <pre> |
| 3978 | * public InputStream openDisplayPhoto(String photoUri) { |
| 3979 | * try { |
| 3980 | * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r"); |
| 3981 | * return fd.createInputStream(); |
| 3982 | * } catch (IOException e) { |
| 3983 | * return null; |
| 3984 | * } |
| 3985 | * } |
| 3986 | * <pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3987 | * </dd> |
| 3988 | * </dl> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3989 | * |
| 3990 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3991 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3992 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3993 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3994 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3995 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3996 | public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns { |
| 3997 | /** |
| 3998 | * No public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3999 | * |
| 4000 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4001 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4002 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4003 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4004 | private StreamItemPhotos() { |
| 4005 | } |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 4006 | |
| 4007 | /** |
| 4008 | * <p> |
| 4009 | * The binary representation of the photo. Any size photo can be inserted; |
| 4010 | * the provider will resize it appropriately for storage and display. |
| 4011 | * </p> |
| 4012 | * <p> |
| 4013 | * This is only intended for use when inserting or updating a stream item photo. |
| 4014 | * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI} |
| 4015 | * as an asset file. |
| 4016 | * </p> |
| 4017 | * <P>Type: BLOB</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4018 | * |
| 4019 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4020 | * cursors returned from related queries will be empty. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 4021 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4022 | @Deprecated |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 4023 | public static final String PHOTO = "photo"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4024 | } |
| 4025 | |
| 4026 | /** |
| 4027 | * Columns in the StreamItemPhotos table. |
| 4028 | * |
| 4029 | * @see ContactsContract.StreamItemPhotos |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4030 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4031 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 4032 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 4033 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4034 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4035 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4036 | protected interface StreamItemPhotosColumns { |
| 4037 | /** |
| 4038 | * A reference to the {@link StreamItems#_ID} this photo is associated with. |
| 4039 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4040 | * |
| 4041 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4042 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4043 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4044 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4045 | public static final String STREAM_ITEM_ID = "stream_item_id"; |
| 4046 | |
| 4047 | /** |
| 4048 | * An integer to use for sort order for photos in the stream item. If not |
| 4049 | * specified, the {@link StreamItemPhotos#_ID} will be used for sorting. |
| 4050 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4051 | * |
| 4052 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4053 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4054 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4055 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4056 | public static final String SORT_INDEX = "sort_index"; |
| 4057 | |
| 4058 | /** |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 4059 | * Photo file ID for the photo. |
| 4060 | * See {@link ContactsContract.DisplayPhoto}. |
| 4061 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4062 | * |
| 4063 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4064 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4065 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4066 | @Deprecated |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 4067 | public static final String PHOTO_FILE_ID = "photo_file_id"; |
| 4068 | |
| 4069 | /** |
| 4070 | * URI for retrieving the photo content, automatically populated. Callers |
| 4071 | * may retrieve the photo content by opening this URI as an asset file. |
| 4072 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4073 | * |
| 4074 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4075 | * cursors returned from related queries will be empty. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 4076 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4077 | @Deprecated |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 4078 | public static final String PHOTO_URI = "photo_uri"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4079 | |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4080 | /** |
| 4081 | * Generic column for use by sync adapters. |
| 4082 | * |
| 4083 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4084 | * cursors returned from related queries will be empty. |
| 4085 | */ |
| 4086 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 4087 | public static final String SYNC1 = "stream_item_photo_sync1"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4088 | /** |
| 4089 | * Generic column for use by sync adapters. |
| 4090 | * |
| 4091 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4092 | * cursors returned from related queries will be empty. |
| 4093 | */ |
| 4094 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 4095 | public static final String SYNC2 = "stream_item_photo_sync2"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4096 | /** |
| 4097 | * Generic column for use by sync adapters. |
| 4098 | * |
| 4099 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4100 | * cursors returned from related queries will be empty. |
| 4101 | */ |
| 4102 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 4103 | public static final String SYNC3 = "stream_item_photo_sync3"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4104 | /** |
| 4105 | * Generic column for use by sync adapters. |
| 4106 | * |
| 4107 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4108 | * cursors returned from related queries will be empty. |
| 4109 | */ |
| 4110 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 4111 | public static final String SYNC4 = "stream_item_photo_sync4"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4112 | } |
| 4113 | |
| 4114 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 4115 | * <p> |
| 4116 | * Constants for the photo files table, which tracks metadata for hi-res photos |
| 4117 | * stored in the file system. |
| 4118 | * </p> |
| 4119 | * |
| 4120 | * @hide |
| 4121 | */ |
| 4122 | public static final class PhotoFiles implements BaseColumns, PhotoFilesColumns { |
| 4123 | /** |
| 4124 | * No public constructor since this is a utility class |
| 4125 | */ |
| 4126 | private PhotoFiles() { |
| 4127 | } |
| 4128 | } |
| 4129 | |
| 4130 | /** |
| 4131 | * Columns in the PhotoFiles table. |
| 4132 | * |
| 4133 | * @see ContactsContract.PhotoFiles |
| 4134 | * |
| 4135 | * @hide |
| 4136 | */ |
| 4137 | protected interface PhotoFilesColumns { |
| 4138 | |
| 4139 | /** |
| 4140 | * The height, in pixels, of the photo this entry is associated with. |
| 4141 | * <P>Type: NUMBER</P> |
| 4142 | */ |
| 4143 | public static final String HEIGHT = "height"; |
| 4144 | |
| 4145 | /** |
| 4146 | * The width, in pixels, of the photo this entry is associated with. |
| 4147 | * <P>Type: NUMBER</P> |
| 4148 | */ |
| 4149 | public static final String WIDTH = "width"; |
| 4150 | |
| 4151 | /** |
| 4152 | * The size, in bytes, of the photo stored on disk. |
| 4153 | * <P>Type: NUMBER</P> |
| 4154 | */ |
| 4155 | public static final String FILESIZE = "filesize"; |
| 4156 | } |
| 4157 | |
| 4158 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4159 | * Columns in the Data table. |
| 4160 | * |
| 4161 | * @see ContactsContract.Data |
| 4162 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 4163 | protected interface DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4164 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4165 | * The package name to use when creating {@link Resources} objects for |
| 4166 | * this data row. This value is only designed for use when building user |
| 4167 | * interfaces, and should not be used to infer the owner. |
| 4168 | */ |
| 4169 | public static final String RES_PACKAGE = "res_package"; |
| 4170 | |
| 4171 | /** |
| 4172 | * The MIME type of the item represented by this row. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4173 | */ |
| 4174 | public static final String MIMETYPE = "mimetype"; |
| 4175 | |
| 4176 | /** |
Zheng Fu | 9ea9a13 | 2015-01-07 11:33:19 -0800 | [diff] [blame] | 4177 | * Hash id on the data fields, used for backup and restore. |
| 4178 | * |
| 4179 | * @hide |
| 4180 | */ |
| 4181 | public static final String HASH_ID = "hash_id"; |
| 4182 | |
| 4183 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 4184 | * A reference to the {@link RawContacts#_ID} |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 4185 | * that this data belongs to. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4186 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 4187 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 4188 | |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 4189 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4190 | * 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] | 4191 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 4192 | */ |
| 4193 | public static final String IS_PRIMARY = "is_primary"; |
| 4194 | |
| 4195 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 4196 | * Whether this is the primary entry of its kind for the aggregate |
| 4197 | * contact it belongs to. Any data record that is "super primary" must |
| 4198 | * also be "primary". |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 4199 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 4200 | */ |
| 4201 | public static final String IS_SUPER_PRIMARY = "is_super_primary"; |
| 4202 | |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 4203 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 4204 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 4205 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 4206 | * <P>Type: INTEGER</P> |
| 4207 | */ |
| 4208 | public static final String IS_READ_ONLY = "is_read_only"; |
| 4209 | |
| 4210 | /** |
Fred Quintana | c933fb6 | 2009-06-11 12:14:40 -0700 | [diff] [blame] | 4211 | * The version of this data record. This is a read-only value. The data column is |
| 4212 | * guaranteed to not change without the version going up. This value is monotonically |
| 4213 | * increasing. |
| 4214 | * <P>Type: INTEGER</P> |
| 4215 | */ |
| 4216 | public static final String DATA_VERSION = "data_version"; |
| 4217 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4218 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4219 | public static final String DATA1 = "data1"; |
| 4220 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4221 | public static final String DATA2 = "data2"; |
| 4222 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4223 | public static final String DATA3 = "data3"; |
| 4224 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4225 | public static final String DATA4 = "data4"; |
| 4226 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4227 | public static final String DATA5 = "data5"; |
| 4228 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4229 | public static final String DATA6 = "data6"; |
| 4230 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4231 | public static final String DATA7 = "data7"; |
| 4232 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4233 | public static final String DATA8 = "data8"; |
| 4234 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4235 | public static final String DATA9 = "data9"; |
| 4236 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4237 | public static final String DATA10 = "data10"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4238 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4239 | public static final String DATA11 = "data11"; |
| 4240 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4241 | public static final String DATA12 = "data12"; |
| 4242 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4243 | public static final String DATA13 = "data13"; |
| 4244 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4245 | public static final String DATA14 = "data14"; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4246 | /** |
| 4247 | * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention, |
| 4248 | * this field is used to store BLOBs (binary data). |
| 4249 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4250 | public static final String DATA15 = "data15"; |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 4251 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 4252 | /** Generic column for use by sync adapters. */ |
| 4253 | public static final String SYNC1 = "data_sync1"; |
| 4254 | /** Generic column for use by sync adapters. */ |
| 4255 | public static final String SYNC2 = "data_sync2"; |
| 4256 | /** Generic column for use by sync adapters. */ |
| 4257 | public static final String SYNC3 = "data_sync3"; |
| 4258 | /** Generic column for use by sync adapters. */ |
| 4259 | public static final String SYNC4 = "data_sync4"; |
Etan Cohen | 534a65d | 2015-05-01 11:03:24 -0700 | [diff] [blame] | 4260 | |
| 4261 | /** |
| 4262 | * Carrier presence information. |
| 4263 | * <P> |
| 4264 | * Type: INTEGER (A bitmask of CARRIER_PRESENCE_* fields) |
| 4265 | * </P> |
| 4266 | */ |
| 4267 | public static final String CARRIER_PRESENCE = "carrier_presence"; |
| 4268 | |
| 4269 | /** |
Etan Cohen | e4dc7e1 | 2015-06-08 13:02:44 -0700 | [diff] [blame] | 4270 | * Indicates that the entry is Video Telephony (VT) capable on the |
| 4271 | * current carrier. An allowed bitmask of {@link #CARRIER_PRESENCE}. |
Etan Cohen | 534a65d | 2015-05-01 11:03:24 -0700 | [diff] [blame] | 4272 | */ |
| 4273 | public static final int CARRIER_PRESENCE_VT_CAPABLE = 0x01; |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 4274 | |
| 4275 | /** |
| 4276 | * The flattened {@link android.content.ComponentName} of a {@link |
| 4277 | * android.telecom.PhoneAccountHandle} that is the preferred {@code PhoneAccountHandle} to |
Ta-wei Yen | 3ec3d5b | 2017-12-13 15:25:49 -0800 | [diff] [blame] | 4278 | * call the contact with. |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 4279 | * |
Ta-wei Yen | 3ec3d5b | 2017-12-13 15:25:49 -0800 | [diff] [blame] | 4280 | * <p> On a multi-SIM device this field can be used in a {@link CommonDataKinds.Phone} row |
| 4281 | * to indicate the {@link PhoneAccountHandle} to call the number with, instead of using |
| 4282 | * {@link android.telecom.TelecomManager#getDefaultOutgoingPhoneAccount(String)} or asking |
| 4283 | * every time. |
| 4284 | * |
| 4285 | * <p>{@link android.telecom.TelecomManager#placeCall(Uri, android.os.Bundle)} |
| 4286 | * should be called with {@link android.telecom.TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE} |
| 4287 | * set to the {@link PhoneAccountHandle} using the {@link ComponentName} from this field. |
| 4288 | * |
| 4289 | * @see #PREFERRED_PHONE_ACCOUNT_ID |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 4290 | * @see PhoneAccountHandle#getComponentName() |
| 4291 | * @see ComponentName#flattenToString() |
| 4292 | */ |
| 4293 | String PREFERRED_PHONE_ACCOUNT_COMPONENT_NAME = "preferred_phone_account_component_name"; |
| 4294 | |
| 4295 | /** |
Ta-wei Yen | 3ec3d5b | 2017-12-13 15:25:49 -0800 | [diff] [blame] | 4296 | * The ID of a {@link |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 4297 | * android.telecom.PhoneAccountHandle} that is the preferred {@code PhoneAccountHandle} to |
| 4298 | * call the contact with. Used by {@link CommonDataKinds.Phone}. |
| 4299 | * |
Ta-wei Yen | 3ec3d5b | 2017-12-13 15:25:49 -0800 | [diff] [blame] | 4300 | * <p> On a multi-SIM device this field can be used in a {@link CommonDataKinds.Phone} row |
| 4301 | * to indicate the {@link PhoneAccountHandle} to call the number with, instead of using |
| 4302 | * {@link android.telecom.TelecomManager#getDefaultOutgoingPhoneAccount(String)} or asking |
| 4303 | * every time. |
| 4304 | * |
| 4305 | * <p>{@link android.telecom.TelecomManager#placeCall(Uri, android.os.Bundle)} |
| 4306 | * should be called with {@link android.telecom.TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE} |
| 4307 | * set to the {@link PhoneAccountHandle} using the id from this field. |
| 4308 | * |
| 4309 | * @see #PREFERRED_PHONE_ACCOUNT_COMPONENT_NAME |
| 4310 | * @see PhoneAccountHandle#getId() |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 4311 | */ |
| 4312 | String PREFERRED_PHONE_ACCOUNT_ID = "preferred_phone_account_id"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4313 | } |
| 4314 | |
| 4315 | /** |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4316 | * Columns in the Data_Usage_Stat table |
| 4317 | */ |
| 4318 | protected interface DataUsageStatColumns { |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 4319 | /** |
| 4320 | * The last time (in milliseconds) this {@link Data} was used. |
| 4321 | * |
| 4322 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete. For |
| 4323 | * more information, see the |
| 4324 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 4325 | * page. |
| 4326 | * |
| 4327 | */ |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4328 | public static final String LAST_TIME_USED = "last_time_used"; |
| 4329 | |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 4330 | /** |
| 4331 | * The number of times the referenced {@link Data} has been used. |
| 4332 | * |
| 4333 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete. For |
| 4334 | * more information, see the |
| 4335 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 4336 | * page. |
| 4337 | * |
| 4338 | * |
| 4339 | */ |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4340 | public static final String TIMES_USED = "times_used"; |
Makoto Onuki | 203145e | 2016-09-28 15:41:29 -0700 | [diff] [blame] | 4341 | |
| 4342 | /** @hide Raw value. */ |
| 4343 | public static final String RAW_LAST_TIME_USED = HIDDEN_COLUMN_PREFIX + LAST_TIME_USED; |
| 4344 | |
| 4345 | /** @hide Raw value. */ |
| 4346 | public static final String RAW_TIMES_USED = HIDDEN_COLUMN_PREFIX + TIMES_USED; |
| 4347 | |
| 4348 | /** |
| 4349 | * @hide |
| 4350 | * Low res version. Same as {@link #LAST_TIME_USED} but use it in CP2 for clarification. |
| 4351 | */ |
| 4352 | public static final String LR_LAST_TIME_USED = LAST_TIME_USED; |
| 4353 | |
| 4354 | /** |
| 4355 | * @hide |
| 4356 | * Low res version. Same as {@link #TIMES_USED} but use it in CP2 for clarification. |
| 4357 | */ |
| 4358 | public static final String LR_TIMES_USED = TIMES_USED; |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4359 | } |
| 4360 | |
| 4361 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4362 | * Combines all columns returned by {@link ContactsContract.Data} table queries. |
| 4363 | * |
| 4364 | * @see ContactsContract.Data |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4365 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 4366 | protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns, |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 4367 | RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns, |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4368 | ContactStatusColumns, DataUsageStatColumns { |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4369 | } |
| 4370 | |
| 4371 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4372 | * <p> |
| 4373 | * Constants for the data table, which contains data points tied to a raw |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4374 | * contact. Each row of the data table is typically used to store a single |
| 4375 | * piece of contact |
| 4376 | * information (such as a phone number) and its |
| 4377 | * associated metadata (such as whether it is a work or home number). |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4378 | * </p> |
| 4379 | * <h3>Data kinds</h3> |
| 4380 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4381 | * Data is a generic table that can hold any kind of contact data. |
| 4382 | * The kind of data stored in a given row is specified by the row's |
| 4383 | * {@link #MIMETYPE} value, which determines the meaning of the |
| 4384 | * generic columns {@link #DATA1} through |
| 4385 | * {@link #DATA15}. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4386 | * For example, if the data kind is |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4387 | * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column |
| 4388 | * {@link #DATA1} stores the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4389 | * phone number, but if the data kind is |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4390 | * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1} |
| 4391 | * stores the email address. |
| 4392 | * Sync adapters and applications can introduce their own data kinds. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4393 | * </p> |
| 4394 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4395 | * ContactsContract defines a small number of pre-defined data kinds, e.g. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4396 | * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a |
| 4397 | * convenience, these classes define data kind specific aliases for DATA1 etc. |
| 4398 | * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as |
| 4399 | * {@link ContactsContract.Data Data.DATA1}. |
| 4400 | * </p> |
| 4401 | * <p> |
| 4402 | * {@link #DATA1} is an indexed column and should be used for the data element that is |
| 4403 | * expected to be most frequently used in query selections. For example, in the |
| 4404 | * case of a row representing email addresses {@link #DATA1} should probably |
| 4405 | * be used for the email address itself, while {@link #DATA2} etc can be |
| 4406 | * used for auxiliary information like type of email address. |
| 4407 | * <p> |
| 4408 | * <p> |
| 4409 | * By convention, {@link #DATA15} is used for storing BLOBs (binary data). |
| 4410 | * </p> |
| 4411 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 4412 | * The sync adapter for a given account type must correctly handle every data type |
| 4413 | * used in the corresponding raw contacts. Otherwise it could result in lost or |
| 4414 | * corrupted data. |
| 4415 | * </p> |
| 4416 | * <p> |
| 4417 | * Similarly, you should refrain from introducing new kinds of data for an other |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4418 | * 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] | 4419 | * "favorite song" to a raw contact owned by a Google account, it will not |
| 4420 | * get synced to the server, because the Google sync adapter does not know |
| 4421 | * how to handle this data kind. Thus new data kinds are typically |
| 4422 | * introduced along with new account types, i.e. new sync adapters. |
| 4423 | * </p> |
| 4424 | * <h3>Batch operations</h3> |
| 4425 | * <p> |
| 4426 | * Data rows can be inserted/updated/deleted using the traditional |
| 4427 | * {@link ContentResolver#insert}, {@link ContentResolver#update} and |
| 4428 | * {@link ContentResolver#delete} methods, however the newer mechanism based |
| 4429 | * on a batch of {@link ContentProviderOperation} will prove to be a better |
| 4430 | * choice in almost all cases. All operations in a batch are executed in a |
| 4431 | * single transaction, which ensures that the phone-side and server-side |
| 4432 | * state of a raw contact are always consistent. Also, the batch-based |
| 4433 | * approach is far more efficient: not only are the database operations |
| 4434 | * faster when executed in a single transaction, but also sending a batch of |
| 4435 | * commands to the content provider saves a lot of time on context switching |
| 4436 | * between your process and the process in which the content provider runs. |
| 4437 | * </p> |
| 4438 | * <p> |
| 4439 | * The flip side of using batched operations is that a large batch may lock |
| 4440 | * up the database for a long time preventing other applications from |
| 4441 | * accessing data and potentially causing ANRs ("Application Not Responding" |
| 4442 | * dialogs.) |
| 4443 | * </p> |
| 4444 | * <p> |
| 4445 | * To avoid such lockups of the database, make sure to insert "yield points" |
| 4446 | * in the batch. A yield point indicates to the content provider that before |
| 4447 | * executing the next operation it can commit the changes that have already |
| 4448 | * been made, yield to other requests, open another transaction and continue |
| 4449 | * processing operations. A yield point will not automatically commit the |
| 4450 | * transaction, but only if there is another request waiting on the |
| 4451 | * database. Normally a sync adapter should insert a yield point at the |
| 4452 | * beginning of each raw contact operation sequence in the batch. See |
| 4453 | * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}. |
| 4454 | * </p> |
| 4455 | * <h3>Operations</h3> |
| 4456 | * <dl> |
| 4457 | * <dt><b>Insert</b></dt> |
| 4458 | * <dd> |
| 4459 | * <p> |
| 4460 | * An individual data row can be inserted using the traditional |
| 4461 | * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows |
| 4462 | * should always be inserted as a batch. |
| 4463 | * </p> |
| 4464 | * <p> |
| 4465 | * An example of a traditional insert: |
| 4466 | * <pre> |
| 4467 | * ContentValues values = new ContentValues(); |
| 4468 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 4469 | * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); |
| 4470 | * values.put(Phone.NUMBER, "1-800-GOOG-411"); |
| 4471 | * values.put(Phone.TYPE, Phone.TYPE_CUSTOM); |
| 4472 | * values.put(Phone.LABEL, "free directory assistance"); |
| 4473 | * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values); |
| 4474 | * </pre> |
| 4475 | * <p> |
| 4476 | * The same done using ContentProviderOperations: |
| 4477 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4478 | * ArrayList<ContentProviderOperation> ops = |
| 4479 | * new ArrayList<ContentProviderOperation>(); |
| 4480 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4481 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 4482 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 4483 | * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE) |
| 4484 | * .withValue(Phone.NUMBER, "1-800-GOOG-411") |
| 4485 | * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM) |
| 4486 | * .withValue(Phone.LABEL, "free directory assistance") |
| 4487 | * .build()); |
| 4488 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4489 | * </pre> |
| 4490 | * </p> |
| 4491 | * <dt><b>Update</b></dt> |
| 4492 | * <dd> |
| 4493 | * <p> |
| 4494 | * Just as with insert, update can be done incrementally or as a batch, |
| 4495 | * the batch mode being the preferred method: |
| 4496 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4497 | * ArrayList<ContentProviderOperation> ops = |
| 4498 | * new ArrayList<ContentProviderOperation>(); |
| 4499 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4500 | * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI) |
| 4501 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 4502 | * .withValue(Email.DATA, "somebody@android.com") |
| 4503 | * .build()); |
| 4504 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4505 | * </pre> |
| 4506 | * </p> |
| 4507 | * </dd> |
| 4508 | * <dt><b>Delete</b></dt> |
| 4509 | * <dd> |
| 4510 | * <p> |
| 4511 | * Just as with insert and update, deletion can be done either using the |
| 4512 | * {@link ContentResolver#delete} method or using a ContentProviderOperation: |
| 4513 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4514 | * ArrayList<ContentProviderOperation> ops = |
| 4515 | * new ArrayList<ContentProviderOperation>(); |
| 4516 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4517 | * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI) |
| 4518 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 4519 | * .build()); |
| 4520 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4521 | * </pre> |
| 4522 | * </p> |
| 4523 | * </dd> |
| 4524 | * <dt><b>Query</b></dt> |
| 4525 | * <dd> |
| 4526 | * <p> |
| 4527 | * <dl> |
| 4528 | * <dt>Finding all Data of a given type for a given contact</dt> |
| 4529 | * <dd> |
| 4530 | * <pre> |
| 4531 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 4532 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 4533 | * Data.CONTACT_ID + "=?" + " AND " |
| 4534 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 4535 | * new String[] {String.valueOf(contactId)}, null); |
| 4536 | * </pre> |
| 4537 | * </p> |
| 4538 | * <p> |
| 4539 | * </dd> |
| 4540 | * <dt>Finding all Data of a given type for a given raw contact</dt> |
| 4541 | * <dd> |
| 4542 | * <pre> |
| 4543 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 4544 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 4545 | * Data.RAW_CONTACT_ID + "=?" + " AND " |
| 4546 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 4547 | * new String[] {String.valueOf(rawContactId)}, null); |
| 4548 | * </pre> |
| 4549 | * </dd> |
| 4550 | * <dt>Finding all Data for a given raw contact</dt> |
| 4551 | * <dd> |
| 4552 | * Most sync adapters will want to read all data rows for a raw contact |
| 4553 | * along with the raw contact itself. For that you should use the |
| 4554 | * {@link RawContactsEntity}. See also {@link RawContacts}. |
| 4555 | * </dd> |
| 4556 | * </dl> |
| 4557 | * </p> |
| 4558 | * </dd> |
| 4559 | * </dl> |
| 4560 | * <h2>Columns</h2> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4561 | * <p> |
| 4562 | * Many columns are available via a {@link Data#CONTENT_URI} query. For best performance you |
| 4563 | * should explicitly specify a projection to only those columns that you need. |
| 4564 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4565 | * <table class="jd-sumtable"> |
| 4566 | * <tr> |
| 4567 | * <th colspan='4'>Data</th> |
| 4568 | * </tr> |
| 4569 | * <tr> |
| 4570 | * <td style="width: 7em;">long</td> |
| 4571 | * <td style="width: 20em;">{@link #_ID}</td> |
| 4572 | * <td style="width: 5em;">read-only</td> |
| 4573 | * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words, |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4574 | * 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] | 4575 | * always do an update instead.</td> |
| 4576 | * </tr> |
| 4577 | * <tr> |
| 4578 | * <td>String</td> |
| 4579 | * <td>{@link #MIMETYPE}</td> |
| 4580 | * <td>read/write-once</td> |
| 4581 | * <td> |
| 4582 | * <p>The MIME type of the item represented by this row. Examples of common |
| 4583 | * MIME types are: |
| 4584 | * <ul> |
| 4585 | * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li> |
| 4586 | * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li> |
| 4587 | * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li> |
| 4588 | * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li> |
| 4589 | * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li> |
| 4590 | * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li> |
| 4591 | * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li> |
| 4592 | * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li> |
| 4593 | * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li> |
| 4594 | * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li> |
| 4595 | * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li> |
| 4596 | * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li> |
| 4597 | * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 4598 | * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4599 | * </ul> |
| 4600 | * </p> |
| 4601 | * </td> |
| 4602 | * </tr> |
| 4603 | * <tr> |
| 4604 | * <td>long</td> |
| 4605 | * <td>{@link #RAW_CONTACT_ID}</td> |
| 4606 | * <td>read/write-once</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4607 | * <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] | 4608 | * </tr> |
| 4609 | * <tr> |
| 4610 | * <td>int</td> |
| 4611 | * <td>{@link #IS_PRIMARY}</td> |
| 4612 | * <td>read/write</td> |
| 4613 | * <td>Whether this is the primary entry of its kind for the raw contact it belongs to. |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4614 | * "1" if true, "0" if false. |
| 4615 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4616 | * </tr> |
| 4617 | * <tr> |
| 4618 | * <td>int</td> |
| 4619 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 4620 | * <td>read/write</td> |
| 4621 | * <td>Whether this is the primary entry of its kind for the aggregate |
| 4622 | * contact it belongs to. Any data record that is "super primary" must |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4623 | * also be "primary". For example, the super-primary entry may be |
| 4624 | * interpreted as the default contact value of its kind (for example, |
| 4625 | * the default phone number to use for the contact).</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4626 | * </tr> |
| 4627 | * <tr> |
| 4628 | * <td>int</td> |
| 4629 | * <td>{@link #DATA_VERSION}</td> |
| 4630 | * <td>read-only</td> |
| 4631 | * <td>The version of this data record. Whenever the data row changes |
| 4632 | * the version goes up. This value is monotonically increasing.</td> |
| 4633 | * </tr> |
| 4634 | * <tr> |
| 4635 | * <td>Any type</td> |
| 4636 | * <td> |
| 4637 | * {@link #DATA1}<br> |
| 4638 | * {@link #DATA2}<br> |
| 4639 | * {@link #DATA3}<br> |
| 4640 | * {@link #DATA4}<br> |
| 4641 | * {@link #DATA5}<br> |
| 4642 | * {@link #DATA6}<br> |
| 4643 | * {@link #DATA7}<br> |
| 4644 | * {@link #DATA8}<br> |
| 4645 | * {@link #DATA9}<br> |
| 4646 | * {@link #DATA10}<br> |
| 4647 | * {@link #DATA11}<br> |
| 4648 | * {@link #DATA12}<br> |
| 4649 | * {@link #DATA13}<br> |
| 4650 | * {@link #DATA14}<br> |
| 4651 | * {@link #DATA15} |
| 4652 | * </td> |
| 4653 | * <td>read/write</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4654 | * <td> |
| 4655 | * <p> |
| 4656 | * Generic data columns. The meaning of each column is determined by the |
| 4657 | * {@link #MIMETYPE}. By convention, {@link #DATA15} is used for storing |
| 4658 | * BLOBs (binary data). |
| 4659 | * </p> |
| 4660 | * <p> |
| 4661 | * Data columns whose meaning is not explicitly defined for a given MIMETYPE |
| 4662 | * should not be used. There is no guarantee that any sync adapter will |
| 4663 | * preserve them. Sync adapters themselves should not use such columns either, |
| 4664 | * but should instead use {@link #SYNC1}-{@link #SYNC4}. |
| 4665 | * </p> |
| 4666 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4667 | * </tr> |
| 4668 | * <tr> |
| 4669 | * <td>Any type</td> |
| 4670 | * <td> |
| 4671 | * {@link #SYNC1}<br> |
| 4672 | * {@link #SYNC2}<br> |
| 4673 | * {@link #SYNC3}<br> |
| 4674 | * {@link #SYNC4} |
| 4675 | * </td> |
| 4676 | * <td>read/write</td> |
| 4677 | * <td>Generic columns for use by sync adapters. For example, a Photo row |
| 4678 | * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error) |
| 4679 | * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td> |
| 4680 | * </tr> |
| 4681 | * </table> |
| 4682 | * |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4683 | * <p> |
| 4684 | * Some columns from the most recent associated status update are also available |
| 4685 | * through an implicit join. |
| 4686 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4687 | * <table class="jd-sumtable"> |
| 4688 | * <tr> |
| 4689 | * <th colspan='4'>Join with {@link StatusUpdates}</th> |
| 4690 | * </tr> |
| 4691 | * <tr> |
| 4692 | * <td style="width: 7em;">int</td> |
| 4693 | * <td style="width: 20em;">{@link #PRESENCE}</td> |
| 4694 | * <td style="width: 5em;">read-only</td> |
| 4695 | * <td>IM presence status linked to this data row. Compare with |
| 4696 | * {@link #CONTACT_PRESENCE}, which contains the contact's presence across |
| 4697 | * all IM rows. See {@link StatusUpdates} for individual status definitions. |
| 4698 | * The provider may choose not to store this value |
| 4699 | * in persistent storage. The expectation is that presence status will be |
kmccormick | 50e27c8 | 2013-03-28 16:33:11 -0700 | [diff] [blame] | 4700 | * updated on a regular basis. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4701 | * </td> |
| 4702 | * </tr> |
| 4703 | * <tr> |
| 4704 | * <td>String</td> |
| 4705 | * <td>{@link #STATUS}</td> |
| 4706 | * <td>read-only</td> |
| 4707 | * <td>Latest status update linked with this data row.</td> |
| 4708 | * </tr> |
| 4709 | * <tr> |
| 4710 | * <td>long</td> |
| 4711 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 4712 | * <td>read-only</td> |
| 4713 | * <td>The absolute time in milliseconds when the latest status was |
| 4714 | * inserted/updated for this data row.</td> |
| 4715 | * </tr> |
| 4716 | * <tr> |
| 4717 | * <td>String</td> |
| 4718 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 4719 | * <td>read-only</td> |
| 4720 | * <td>The package containing resources for this status: label and icon.</td> |
| 4721 | * </tr> |
| 4722 | * <tr> |
| 4723 | * <td>long</td> |
| 4724 | * <td>{@link #STATUS_LABEL}</td> |
| 4725 | * <td>read-only</td> |
| 4726 | * <td>The resource ID of the label describing the source of status update linked |
| 4727 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4728 | * </tr> |
| 4729 | * <tr> |
| 4730 | * <td>long</td> |
| 4731 | * <td>{@link #STATUS_ICON}</td> |
| 4732 | * <td>read-only</td> |
| 4733 | * <td>The resource ID of the icon for the source of the status update linked |
| 4734 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4735 | * </tr> |
| 4736 | * </table> |
| 4737 | * |
| 4738 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4739 | * Some columns from the associated raw contact are also available through an |
| 4740 | * implicit join. The other columns are excluded as uninteresting in this |
| 4741 | * context. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4742 | * </p> |
| 4743 | * |
| 4744 | * <table class="jd-sumtable"> |
| 4745 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4746 | * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4747 | * </tr> |
| 4748 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4749 | * <td style="width: 7em;">long</td> |
| 4750 | * <td style="width: 20em;">{@link #CONTACT_ID}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4751 | * <td style="width: 5em;">read-only</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4752 | * <td>The id of the row in the {@link Contacts} table that this data belongs |
| 4753 | * to.</td> |
| 4754 | * </tr> |
| 4755 | * <tr> |
| 4756 | * <td>int</td> |
| 4757 | * <td>{@link #AGGREGATION_MODE}</td> |
| 4758 | * <td>read-only</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4759 | * <td>See {@link RawContacts}.</td> |
| 4760 | * </tr> |
| 4761 | * <tr> |
| 4762 | * <td>int</td> |
| 4763 | * <td>{@link #DELETED}</td> |
| 4764 | * <td>read-only</td> |
| 4765 | * <td>See {@link RawContacts}.</td> |
| 4766 | * </tr> |
| 4767 | * </table> |
| 4768 | * |
| 4769 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4770 | * The ID column for the associated aggregated contact table |
| 4771 | * {@link ContactsContract.Contacts} is available |
| 4772 | * via the implicit join to the {@link RawContacts} table, see above. |
| 4773 | * The remaining columns from this table are also |
| 4774 | * available, through an implicit join. This |
| 4775 | * facilitates lookup by |
| 4776 | * the value of a single data element, such as the email address. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4777 | * </p> |
| 4778 | * |
| 4779 | * <table class="jd-sumtable"> |
| 4780 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4781 | * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4782 | * </tr> |
| 4783 | * <tr> |
| 4784 | * <td style="width: 7em;">String</td> |
| 4785 | * <td style="width: 20em;">{@link #LOOKUP_KEY}</td> |
| 4786 | * <td style="width: 5em;">read-only</td> |
| 4787 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4788 | * </tr> |
| 4789 | * <tr> |
| 4790 | * <td>String</td> |
| 4791 | * <td>{@link #DISPLAY_NAME}</td> |
| 4792 | * <td>read-only</td> |
| 4793 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4794 | * </tr> |
| 4795 | * <tr> |
| 4796 | * <td>long</td> |
| 4797 | * <td>{@link #PHOTO_ID}</td> |
| 4798 | * <td>read-only</td> |
| 4799 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4800 | * </tr> |
| 4801 | * <tr> |
| 4802 | * <td>int</td> |
| 4803 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 4804 | * <td>read-only</td> |
| 4805 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4806 | * </tr> |
| 4807 | * <tr> |
| 4808 | * <td>int</td> |
| 4809 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 4810 | * <td>read-only</td> |
| 4811 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4812 | * </tr> |
| 4813 | * <tr> |
| 4814 | * <td>int</td> |
| 4815 | * <td>{@link #TIMES_CONTACTED}</td> |
| 4816 | * <td>read-only</td> |
| 4817 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4818 | * </tr> |
| 4819 | * <tr> |
| 4820 | * <td>long</td> |
| 4821 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 4822 | * <td>read-only</td> |
| 4823 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4824 | * </tr> |
| 4825 | * <tr> |
| 4826 | * <td>int</td> |
| 4827 | * <td>{@link #STARRED}</td> |
| 4828 | * <td>read-only</td> |
| 4829 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4830 | * </tr> |
| 4831 | * <tr> |
| 4832 | * <td>String</td> |
| 4833 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 4834 | * <td>read-only</td> |
| 4835 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4836 | * </tr> |
| 4837 | * <tr> |
| 4838 | * <td>int</td> |
| 4839 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 4840 | * <td>read-only</td> |
| 4841 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4842 | * </tr> |
| 4843 | * <tr> |
| 4844 | * <td>int</td> |
| 4845 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 4846 | * <td>read-only</td> |
| 4847 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4848 | * </tr> |
| 4849 | * <tr> |
| 4850 | * <td>String</td> |
| 4851 | * <td>{@link #CONTACT_STATUS}</td> |
| 4852 | * <td>read-only</td> |
| 4853 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4854 | * </tr> |
| 4855 | * <tr> |
| 4856 | * <td>long</td> |
| 4857 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 4858 | * <td>read-only</td> |
| 4859 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4860 | * </tr> |
| 4861 | * <tr> |
| 4862 | * <td>String</td> |
| 4863 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 4864 | * <td>read-only</td> |
| 4865 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4866 | * </tr> |
| 4867 | * <tr> |
| 4868 | * <td>long</td> |
| 4869 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 4870 | * <td>read-only</td> |
| 4871 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4872 | * </tr> |
| 4873 | * <tr> |
| 4874 | * <td>long</td> |
| 4875 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 4876 | * <td>read-only</td> |
| 4877 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4878 | * </tr> |
| 4879 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4880 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 4881 | public final static class Data implements DataColumnsWithJoins, ContactCounts { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4882 | /** |
| 4883 | * This utility class cannot be instantiated |
| 4884 | */ |
| 4885 | private Data() {} |
| 4886 | |
| 4887 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4888 | * The content:// style URI for this table, which requests a directory |
| 4889 | * of data rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4890 | */ |
| 4891 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); |
| 4892 | |
| 4893 | /** |
Ricky Wai | fa5bbaf | 2015-02-26 16:51:32 +0000 | [diff] [blame] | 4894 | * The content:// style URI for this table in managed profile, which requests a directory |
| 4895 | * of data rows matching the selection criteria. |
| 4896 | * |
| 4897 | * @hide |
| 4898 | */ |
| 4899 | static final Uri ENTERPRISE_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 4900 | "data_enterprise"); |
| 4901 | |
| 4902 | /** |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 4903 | * A boolean parameter for {@link Data#CONTENT_URI}. |
| 4904 | * This specifies whether or not the returned data items should be filtered to show |
| 4905 | * data items belonging to visible contacts only. |
| 4906 | */ |
| 4907 | public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; |
| 4908 | |
| 4909 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4910 | * The MIME type of the results from {@link #CONTENT_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4911 | */ |
| 4912 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 4913 | |
| 4914 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4915 | * <p> |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4916 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 4917 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4918 | * entry of the given {@link ContactsContract.Data} entry. |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4919 | * </p> |
| 4920 | * <p> |
| 4921 | * Returns the Uri for the contact in the first entry returned by |
| 4922 | * {@link ContentResolver#query(Uri, String[], String, String[], String)} |
| 4923 | * for the provided {@code dataUri}. If the query returns null or empty |
| 4924 | * results, silently returns null. |
| 4925 | * </p> |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 4926 | */ |
| 4927 | public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) { |
| 4928 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 4929 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 4930 | }, null, null, null); |
| 4931 | |
| 4932 | Uri lookupUri = null; |
| 4933 | try { |
| 4934 | if (cursor != null && cursor.moveToFirst()) { |
| 4935 | final long contactId = cursor.getLong(0); |
| 4936 | final String lookupKey = cursor.getString(1); |
| 4937 | return Contacts.getLookupUri(contactId, lookupKey); |
| 4938 | } |
| 4939 | } finally { |
| 4940 | if (cursor != null) cursor.close(); |
| 4941 | } |
| 4942 | return lookupUri; |
| 4943 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4944 | } |
| 4945 | |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 4946 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4947 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4948 | * 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] | 4949 | * an outer join of the raw_contacts table with the data table. It is a strictly |
| 4950 | * read-only table. |
| 4951 | * </p> |
| 4952 | * <p> |
| 4953 | * If a raw contact has data rows, the RawContactsEntity cursor will contain |
| 4954 | * a one row for each data row. If the raw contact has no data rows, the |
| 4955 | * cursor will still contain one row with the raw contact-level information |
| 4956 | * and nulls for data columns. |
| 4957 | * |
| 4958 | * <pre> |
| 4959 | * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId); |
| 4960 | * Cursor c = getContentResolver().query(entityUri, |
| 4961 | * new String[]{ |
| 4962 | * RawContactsEntity.SOURCE_ID, |
| 4963 | * RawContactsEntity.DATA_ID, |
| 4964 | * RawContactsEntity.MIMETYPE, |
| 4965 | * RawContactsEntity.DATA1 |
| 4966 | * }, null, null, null); |
| 4967 | * try { |
| 4968 | * while (c.moveToNext()) { |
| 4969 | * String sourceId = c.getString(0); |
| 4970 | * if (!c.isNull(1)) { |
| 4971 | * String mimeType = c.getString(2); |
| 4972 | * String data = c.getString(3); |
| 4973 | * ... |
| 4974 | * } |
| 4975 | * } |
| 4976 | * } finally { |
| 4977 | * c.close(); |
| 4978 | * } |
| 4979 | * </pre> |
| 4980 | * |
| 4981 | * <h3>Columns</h3> |
| 4982 | * RawContactsEntity has a combination of RawContact and Data columns. |
| 4983 | * |
| 4984 | * <table class="jd-sumtable"> |
| 4985 | * <tr> |
| 4986 | * <th colspan='4'>RawContacts</th> |
| 4987 | * </tr> |
| 4988 | * <tr> |
| 4989 | * <td style="width: 7em;">long</td> |
| 4990 | * <td style="width: 20em;">{@link #_ID}</td> |
| 4991 | * <td style="width: 5em;">read-only</td> |
| 4992 | * <td>Raw contact row ID. See {@link RawContacts}.</td> |
| 4993 | * </tr> |
| 4994 | * <tr> |
| 4995 | * <td>long</td> |
| 4996 | * <td>{@link #CONTACT_ID}</td> |
| 4997 | * <td>read-only</td> |
| 4998 | * <td>See {@link RawContacts}.</td> |
| 4999 | * </tr> |
| 5000 | * <tr> |
| 5001 | * <td>int</td> |
| 5002 | * <td>{@link #AGGREGATION_MODE}</td> |
| 5003 | * <td>read-only</td> |
| 5004 | * <td>See {@link RawContacts}.</td> |
| 5005 | * </tr> |
| 5006 | * <tr> |
| 5007 | * <td>int</td> |
| 5008 | * <td>{@link #DELETED}</td> |
| 5009 | * <td>read-only</td> |
| 5010 | * <td>See {@link RawContacts}.</td> |
| 5011 | * </tr> |
| 5012 | * </table> |
| 5013 | * |
| 5014 | * <table class="jd-sumtable"> |
| 5015 | * <tr> |
| 5016 | * <th colspan='4'>Data</th> |
| 5017 | * </tr> |
| 5018 | * <tr> |
| 5019 | * <td style="width: 7em;">long</td> |
| 5020 | * <td style="width: 20em;">{@link #DATA_ID}</td> |
| 5021 | * <td style="width: 5em;">read-only</td> |
| 5022 | * <td>Data row ID. It will be null if the raw contact has no data rows.</td> |
| 5023 | * </tr> |
| 5024 | * <tr> |
| 5025 | * <td>String</td> |
| 5026 | * <td>{@link #MIMETYPE}</td> |
| 5027 | * <td>read-only</td> |
| 5028 | * <td>See {@link ContactsContract.Data}.</td> |
| 5029 | * </tr> |
| 5030 | * <tr> |
| 5031 | * <td>int</td> |
| 5032 | * <td>{@link #IS_PRIMARY}</td> |
| 5033 | * <td>read-only</td> |
| 5034 | * <td>See {@link ContactsContract.Data}.</td> |
| 5035 | * </tr> |
| 5036 | * <tr> |
| 5037 | * <td>int</td> |
| 5038 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 5039 | * <td>read-only</td> |
| 5040 | * <td>See {@link ContactsContract.Data}.</td> |
| 5041 | * </tr> |
| 5042 | * <tr> |
| 5043 | * <td>int</td> |
| 5044 | * <td>{@link #DATA_VERSION}</td> |
| 5045 | * <td>read-only</td> |
| 5046 | * <td>See {@link ContactsContract.Data}.</td> |
| 5047 | * </tr> |
| 5048 | * <tr> |
| 5049 | * <td>Any type</td> |
| 5050 | * <td> |
| 5051 | * {@link #DATA1}<br> |
| 5052 | * {@link #DATA2}<br> |
| 5053 | * {@link #DATA3}<br> |
| 5054 | * {@link #DATA4}<br> |
| 5055 | * {@link #DATA5}<br> |
| 5056 | * {@link #DATA6}<br> |
| 5057 | * {@link #DATA7}<br> |
| 5058 | * {@link #DATA8}<br> |
| 5059 | * {@link #DATA9}<br> |
| 5060 | * {@link #DATA10}<br> |
| 5061 | * {@link #DATA11}<br> |
| 5062 | * {@link #DATA12}<br> |
| 5063 | * {@link #DATA13}<br> |
| 5064 | * {@link #DATA14}<br> |
| 5065 | * {@link #DATA15} |
| 5066 | * </td> |
| 5067 | * <td>read-only</td> |
| 5068 | * <td>See {@link ContactsContract.Data}.</td> |
| 5069 | * </tr> |
| 5070 | * <tr> |
| 5071 | * <td>Any type</td> |
| 5072 | * <td> |
| 5073 | * {@link #SYNC1}<br> |
| 5074 | * {@link #SYNC2}<br> |
| 5075 | * {@link #SYNC3}<br> |
| 5076 | * {@link #SYNC4} |
| 5077 | * </td> |
| 5078 | * <td>read-only</td> |
| 5079 | * <td>See {@link ContactsContract.Data}.</td> |
| 5080 | * </tr> |
| 5081 | * </table> |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 5082 | */ |
| 5083 | public final static class RawContactsEntity |
| 5084 | implements BaseColumns, DataColumns, RawContactsColumns { |
| 5085 | /** |
| 5086 | * This utility class cannot be instantiated |
| 5087 | */ |
| 5088 | private RawContactsEntity() {} |
| 5089 | |
| 5090 | /** |
| 5091 | * The content:// style URI for this table |
| 5092 | */ |
| 5093 | public static final Uri CONTENT_URI = |
| 5094 | Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities"); |
| 5095 | |
| 5096 | /** |
Ricky Wai | 9aaaa1e | 2015-03-08 00:53:20 +0000 | [diff] [blame] | 5097 | * The content:// style URI for this table in corp profile |
| 5098 | * |
| 5099 | * @hide |
| 5100 | */ |
| 5101 | public static final Uri CORP_CONTENT_URI = |
| 5102 | Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities_corp"); |
| 5103 | |
| 5104 | /** |
Dave Santoro | 2b4d075 | 2011-09-07 17:37:33 -0700 | [diff] [blame] | 5105 | * The content:// style URI for this table, specific to the user's profile. |
| 5106 | */ |
| 5107 | public static final Uri PROFILE_CONTENT_URI = |
| 5108 | Uri.withAppendedPath(Profile.CONTENT_URI, "raw_contact_entities"); |
| 5109 | |
| 5110 | /** |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 5111 | * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities. |
| 5112 | */ |
| 5113 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity"; |
| 5114 | |
| 5115 | /** |
| 5116 | * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward |
| 5117 | * Data.CONTENT_URI contains only exportable data. |
| 5118 | * |
| 5119 | * This flag is useful (currently) only for vCard exporter in Contacts app, which |
| 5120 | * needs to exclude "un-exportable" data from available data to export, while |
| 5121 | * Contacts app itself has priviledge to access all data including "un-expotable" |
| 5122 | * ones and providers return all of them regardless of the callers' intention. |
| 5123 | * <P>Type: INTEGER</p> |
| 5124 | * |
| 5125 | * @hide Maybe available only in Eclair and not really ready for public use. |
| 5126 | * TODO: remove, or implement this feature completely. As of now (Eclair), |
| 5127 | * we only use this flag in queryEntities(), not query(). |
| 5128 | */ |
| 5129 | public static final String FOR_EXPORT_ONLY = "for_export_only"; |
| 5130 | |
| 5131 | /** |
| 5132 | * The ID of the data column. The value will be null if this raw contact has no data rows. |
| 5133 | * <P>Type: INTEGER</P> |
| 5134 | */ |
| 5135 | public static final String DATA_ID = "data_id"; |
| 5136 | } |
| 5137 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5138 | /** |
| 5139 | * @see PhoneLookup |
| 5140 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5141 | protected interface PhoneLookupColumns { |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5142 | /** |
Tony Mak | fd9ec5a | 2016-02-17 14:11:52 +0000 | [diff] [blame] | 5143 | * The ID of the data row. |
| 5144 | * <P>Type: INTEGER</P> |
| 5145 | */ |
| 5146 | public static final String DATA_ID = "data_id"; |
| 5147 | /** |
| 5148 | * A reference to the {@link ContactsContract.Contacts#_ID} that this |
| 5149 | * data belongs to. |
| 5150 | * <P>Type: INTEGER</P> |
| 5151 | */ |
| 5152 | public static final String CONTACT_ID = "contact_id"; |
| 5153 | /** |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5154 | * The phone number as the user entered it. |
| 5155 | * <P>Type: TEXT</P> |
| 5156 | */ |
| 5157 | public static final String NUMBER = "number"; |
| 5158 | |
| 5159 | /** |
| 5160 | * The type of phone number, for example Home or Work. |
| 5161 | * <P>Type: INTEGER</P> |
| 5162 | */ |
| 5163 | public static final String TYPE = "type"; |
| 5164 | |
| 5165 | /** |
| 5166 | * The user defined label for the phone number. |
| 5167 | * <P>Type: TEXT</P> |
| 5168 | */ |
| 5169 | public static final String LABEL = "label"; |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 5170 | |
| 5171 | /** |
| 5172 | * The phone number's E164 representation. |
| 5173 | * <P>Type: TEXT</P> |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 5174 | */ |
| 5175 | public static final String NORMALIZED_NUMBER = "normalized_number"; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5176 | } |
| 5177 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5178 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5179 | * 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] | 5180 | * 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] | 5181 | * want to find to {@link #CONTENT_FILTER_URI}. This query is highly |
| 5182 | * optimized. |
| 5183 | * <pre> |
| 5184 | * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); |
| 5185 | * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,... |
| 5186 | * </pre> |
| 5187 | * |
| 5188 | * <h3>Columns</h3> |
| 5189 | * |
| 5190 | * <table class="jd-sumtable"> |
| 5191 | * <tr> |
| 5192 | * <th colspan='4'>PhoneLookup</th> |
| 5193 | * </tr> |
| 5194 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5195 | * <td>String</td> |
| 5196 | * <td>{@link #NUMBER}</td> |
| 5197 | * <td>read-only</td> |
| 5198 | * <td>Phone number.</td> |
| 5199 | * </tr> |
| 5200 | * <tr> |
| 5201 | * <td>String</td> |
| 5202 | * <td>{@link #TYPE}</td> |
| 5203 | * <td>read-only</td> |
| 5204 | * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td> |
| 5205 | * </tr> |
| 5206 | * <tr> |
| 5207 | * <td>String</td> |
| 5208 | * <td>{@link #LABEL}</td> |
| 5209 | * <td>read-only</td> |
| 5210 | * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td> |
| 5211 | * </tr> |
| 5212 | * </table> |
| 5213 | * <p> |
| 5214 | * Columns from the Contacts table are also available through a join. |
| 5215 | * </p> |
| 5216 | * <table class="jd-sumtable"> |
| 5217 | * <tr> |
| 5218 | * <th colspan='4'>Join with {@link Contacts}</th> |
| 5219 | * </tr> |
| 5220 | * <tr> |
Dmitri Plotnikov | 817b3f9 | 2011-01-09 17:07:13 -0800 | [diff] [blame] | 5221 | * <td>long</td> |
| 5222 | * <td>{@link #_ID}</td> |
| 5223 | * <td>read-only</td> |
| 5224 | * <td>Contact ID.</td> |
| 5225 | * </tr> |
| 5226 | * <tr> |
Tony Mak | fd9ec5a | 2016-02-17 14:11:52 +0000 | [diff] [blame] | 5227 | * <td>long</td> |
| 5228 | * <td>{@link #CONTACT_ID}</td> |
| 5229 | * <td>read-only</td> |
| 5230 | * <td>Contact ID.</td> |
| 5231 | * </tr> |
| 5232 | * <tr> |
| 5233 | * <td>long</td> |
| 5234 | * <td>{@link #DATA_ID}</td> |
| 5235 | * <td>read-only</td> |
| 5236 | * <td>Data ID.</td> |
| 5237 | * </tr> |
| 5238 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5239 | * <td>String</td> |
| 5240 | * <td>{@link #LOOKUP_KEY}</td> |
| 5241 | * <td>read-only</td> |
| 5242 | * <td>See {@link ContactsContract.Contacts}</td> |
| 5243 | * </tr> |
| 5244 | * <tr> |
| 5245 | * <td>String</td> |
| 5246 | * <td>{@link #DISPLAY_NAME}</td> |
| 5247 | * <td>read-only</td> |
| 5248 | * <td>See {@link ContactsContract.Contacts}</td> |
| 5249 | * </tr> |
| 5250 | * <tr> |
| 5251 | * <td>long</td> |
| 5252 | * <td>{@link #PHOTO_ID}</td> |
| 5253 | * <td>read-only</td> |
| 5254 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5255 | * </tr> |
| 5256 | * <tr> |
| 5257 | * <td>int</td> |
| 5258 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 5259 | * <td>read-only</td> |
| 5260 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5261 | * </tr> |
| 5262 | * <tr> |
| 5263 | * <td>int</td> |
| 5264 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 5265 | * <td>read-only</td> |
| 5266 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5267 | * </tr> |
| 5268 | * <tr> |
| 5269 | * <td>int</td> |
| 5270 | * <td>{@link #TIMES_CONTACTED}</td> |
| 5271 | * <td>read-only</td> |
| 5272 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5273 | * </tr> |
| 5274 | * <tr> |
| 5275 | * <td>long</td> |
| 5276 | * <td>{@link #LAST_TIME_CONTACTED}</td> |
| 5277 | * <td>read-only</td> |
| 5278 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5279 | * </tr> |
| 5280 | * <tr> |
| 5281 | * <td>int</td> |
| 5282 | * <td>{@link #STARRED}</td> |
| 5283 | * <td>read-only</td> |
| 5284 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5285 | * </tr> |
| 5286 | * <tr> |
| 5287 | * <td>String</td> |
| 5288 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 5289 | * <td>read-only</td> |
| 5290 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5291 | * </tr> |
| 5292 | * <tr> |
| 5293 | * <td>int</td> |
| 5294 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 5295 | * <td>read-only</td> |
| 5296 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5297 | * </tr> |
| 5298 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5299 | */ |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5300 | public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, |
Suprabh Shukla | 2c3fb3f | 2016-09-06 15:30:53 -0700 | [diff] [blame] | 5301 | ContactsColumns, ContactOptionsColumns, ContactNameColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5302 | /** |
| 5303 | * This utility class cannot be instantiated |
| 5304 | */ |
| 5305 | private PhoneLookup() {} |
| 5306 | |
| 5307 | /** |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 5308 | * The content:// style URI for this table. |
| 5309 | * |
| 5310 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer |
| 5311 | * sorts results based on contacts frequency. For more information, see the |
| 5312 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 5313 | * page. |
| 5314 | * |
| 5315 | * Append the phone number you want to lookup |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5316 | * to this URI and query it to perform a lookup. For example: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5317 | * <pre> |
Scott Kennedy | 7ed189e | 2013-01-11 22:31:43 -0800 | [diff] [blame] | 5318 | * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, |
| 5319 | * Uri.encode(phoneNumber)); |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5320 | * </pre> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5321 | */ |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5322 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 5323 | "phone_lookup"); |
Dmitri Plotnikov | 0b0b8a8 | 2010-03-04 18:20:08 -0800 | [diff] [blame] | 5324 | |
| 5325 | /** |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 5326 | * <p>URI used for the "enterprise caller-id".</p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5327 | * |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 5328 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer |
| 5329 | * sorts results based on contacts frequency. For more information, see the |
| 5330 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 5331 | * page. |
| 5332 | * |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 5333 | * <p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5334 | * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same |
| 5335 | * columns. If the device has no corp profile that is linked to the current profile, it |
| 5336 | * behaves in the exact same way as {@link #CONTENT_FILTER_URI}. If there is a corp profile |
| 5337 | * linked to the current profile, it first queries against the personal contact database, |
| 5338 | * and if no matching contacts are found there, then queries against the |
| 5339 | * corp contacts database. |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 5340 | * </p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5341 | * <p> |
| 5342 | * If a result is from the corp profile, it makes the following changes to the data: |
| 5343 | * <ul> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5344 | * <li> |
| 5345 | * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special |
| 5346 | * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to |
| 5347 | * load pictures from them. |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 5348 | * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not use them. |
| 5349 | * </li> |
| 5350 | * <li> |
| 5351 | * 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] | 5352 | * is from the corp profile, use |
| 5353 | * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}. |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5354 | * </li> |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 5355 | * <li> |
| 5356 | * Corp contacts will get artificial {@link #LOOKUP_KEY}s too. |
| 5357 | * </li> |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 5358 | * <li> |
| 5359 | * Returned work contact IDs and lookup keys are not accepted in places that not |
| 5360 | * explicitly say to accept them. |
| 5361 | * </li> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5362 | * </ul> |
Makoto Onuki | 95a9cfb | 2014-07-08 17:11:54 -0700 | [diff] [blame] | 5363 | * <p> |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 5364 | * A contact lookup URL built by |
| 5365 | * {@link ContactsContract.Contacts#getLookupUri(long, String)} |
| 5366 | * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to |
| 5367 | * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the |
| 5368 | * corp profile. |
| 5369 | * </p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5370 | * |
| 5371 | * <pre> |
| 5372 | * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, |
| 5373 | * Uri.encode(phoneNumber)); |
| 5374 | * </pre> |
| 5375 | */ |
| 5376 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 5377 | "phone_lookup_enterprise"); |
| 5378 | |
| 5379 | /** |
Dmitri Plotnikov | 0b0b8a8 | 2010-03-04 18:20:08 -0800 | [diff] [blame] | 5380 | * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows. |
| 5381 | * |
| 5382 | * @hide |
| 5383 | */ |
| 5384 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup"; |
Flavio Lerda | 52c01c2 | 2011-11-02 22:16:23 +0000 | [diff] [blame] | 5385 | |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 5386 | /** |
| 5387 | * If this boolean parameter is set to true, then the appended query is treated as a |
| 5388 | * SIP address and the lookup will be performed against SIP addresses in the user's |
| 5389 | * contacts. |
| 5390 | */ |
Flavio Lerda | 52c01c2 | 2011-11-02 22:16:23 +0000 | [diff] [blame] | 5391 | public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5392 | } |
| 5393 | |
| 5394 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5395 | * Additional data mixed in with {@link StatusColumns} to link |
| 5396 | * back to specific {@link ContactsContract.Data#_ID} entries. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5397 | * |
| 5398 | * @see StatusUpdates |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5399 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5400 | protected interface PresenceColumns { |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 5401 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5402 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5403 | * Reference to the {@link Data#_ID} entry that owns this presence. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5404 | * <P>Type: INTEGER</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5405 | */ |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5406 | public static final String DATA_ID = "presence_data_id"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5407 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5408 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5409 | * See {@link CommonDataKinds.Im} for a list of defined protocol constants. |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 5410 | * <p>Type: NUMBER</p> |
| 5411 | */ |
| 5412 | public static final String PROTOCOL = "protocol"; |
| 5413 | |
| 5414 | /** |
| 5415 | * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 5416 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 5417 | * omitted if {@link #PROTOCOL} value is not |
| 5418 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. |
| 5419 | * |
| 5420 | * <p>Type: NUMBER</p> |
| 5421 | */ |
| 5422 | public static final String CUSTOM_PROTOCOL = "custom_protocol"; |
| 5423 | |
| 5424 | /** |
| 5425 | * The IM handle the presence item is for. The handle is scoped to |
| 5426 | * {@link #PROTOCOL}. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5427 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5428 | */ |
| 5429 | public static final String IM_HANDLE = "im_handle"; |
| 5430 | |
| 5431 | /** |
| 5432 | * 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] | 5433 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5434 | */ |
| 5435 | public static final String IM_ACCOUNT = "im_account"; |
| 5436 | } |
| 5437 | |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5438 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5439 | * <p> |
| 5440 | * A status update is linked to a {@link ContactsContract.Data} row and captures |
| 5441 | * the user's latest status update via the corresponding source, e.g. |
| 5442 | * "Having lunch" via "Google Talk". |
| 5443 | * </p> |
| 5444 | * <p> |
| 5445 | * There are two ways a status update can be inserted: by explicitly linking |
| 5446 | * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row |
| 5447 | * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 5448 | * {@link #IM_HANDLE}. There is no difference between insert and update, you can use |
| 5449 | * either. |
| 5450 | * </p> |
| 5451 | * <p> |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 5452 | * Inserting or updating a status update for the user's profile requires either using |
| 5453 | * the {@link #DATA_ID} to identify the data row to attach the update to, or |
| 5454 | * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the |
| 5455 | * profile. |
| 5456 | * </p> |
| 5457 | * <p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5458 | * You cannot use {@link ContentResolver#update} to change a status, but |
| 5459 | * {@link ContentResolver#insert} will replace the latests status if it already |
| 5460 | * exists. |
| 5461 | * </p> |
| 5462 | * <p> |
| 5463 | * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses |
| 5464 | * for multiple contacts at once. |
| 5465 | * </p> |
| 5466 | * |
| 5467 | * <h3>Columns</h3> |
| 5468 | * <table class="jd-sumtable"> |
| 5469 | * <tr> |
| 5470 | * <th colspan='4'>StatusUpdates</th> |
| 5471 | * </tr> |
| 5472 | * <tr> |
| 5473 | * <td>long</td> |
| 5474 | * <td>{@link #DATA_ID}</td> |
| 5475 | * <td>read/write</td> |
| 5476 | * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this |
| 5477 | * field is <i>not</i> specified, the provider will attempt to find a data row |
| 5478 | * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 5479 | * {@link #IM_HANDLE} columns. |
| 5480 | * </td> |
| 5481 | * </tr> |
| 5482 | * <tr> |
| 5483 | * <td>long</td> |
| 5484 | * <td>{@link #PROTOCOL}</td> |
| 5485 | * <td>read/write</td> |
| 5486 | * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td> |
| 5487 | * </tr> |
| 5488 | * <tr> |
| 5489 | * <td>String</td> |
| 5490 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 5491 | * <td>read/write</td> |
| 5492 | * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 5493 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 5494 | * omitted if {@link #PROTOCOL} value is not |
| 5495 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td> |
| 5496 | * </tr> |
| 5497 | * <tr> |
| 5498 | * <td>String</td> |
| 5499 | * <td>{@link #IM_HANDLE}</td> |
| 5500 | * <td>read/write</td> |
| 5501 | * <td> The IM handle the presence item is for. The handle is scoped to |
| 5502 | * {@link #PROTOCOL}.</td> |
| 5503 | * </tr> |
| 5504 | * <tr> |
| 5505 | * <td>String</td> |
| 5506 | * <td>{@link #IM_ACCOUNT}</td> |
| 5507 | * <td>read/write</td> |
| 5508 | * <td>The IM account for the local user that the presence data came from.</td> |
| 5509 | * </tr> |
| 5510 | * <tr> |
| 5511 | * <td>int</td> |
| 5512 | * <td>{@link #PRESENCE}</td> |
| 5513 | * <td>read/write</td> |
| 5514 | * <td>Contact IM presence status. The allowed values are: |
| 5515 | * <p> |
| 5516 | * <ul> |
| 5517 | * <li>{@link #OFFLINE}</li> |
| 5518 | * <li>{@link #INVISIBLE}</li> |
| 5519 | * <li>{@link #AWAY}</li> |
| 5520 | * <li>{@link #IDLE}</li> |
| 5521 | * <li>{@link #DO_NOT_DISTURB}</li> |
| 5522 | * <li>{@link #AVAILABLE}</li> |
| 5523 | * </ul> |
| 5524 | * </p> |
| 5525 | * <p> |
| 5526 | * Since presence status is inherently volatile, the content provider |
| 5527 | * may choose not to store this field in long-term storage. |
| 5528 | * </p> |
| 5529 | * </td> |
| 5530 | * </tr> |
| 5531 | * <tr> |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 5532 | * <td>int</td> |
| 5533 | * <td>{@link #CHAT_CAPABILITY}</td> |
| 5534 | * <td>read/write</td> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 5535 | * <td>Contact IM chat compatibility value. The allowed values combinations of the following |
| 5536 | * flags. If None of these flags is set, the device can only do text messaging. |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 5537 | * <p> |
| 5538 | * <ul> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 5539 | * <li>{@link #CAPABILITY_HAS_VIDEO}</li> |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 5540 | * <li>{@link #CAPABILITY_HAS_VOICE}</li> |
| 5541 | * <li>{@link #CAPABILITY_HAS_CAMERA}</li> |
| 5542 | * </ul> |
| 5543 | * </p> |
| 5544 | * <p> |
| 5545 | * Since chat compatibility is inherently volatile as the contact's availability moves from |
| 5546 | * one device to another, the content provider may choose not to store this field in long-term |
| 5547 | * storage. |
| 5548 | * </p> |
| 5549 | * </td> |
| 5550 | * </tr> |
| 5551 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5552 | * <td>String</td> |
| 5553 | * <td>{@link #STATUS}</td> |
| 5554 | * <td>read/write</td> |
| 5555 | * <td>Contact's latest status update, e.g. "having toast for breakfast"</td> |
| 5556 | * </tr> |
| 5557 | * <tr> |
| 5558 | * <td>long</td> |
| 5559 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 5560 | * <td>read/write</td> |
| 5561 | * <td>The absolute time in milliseconds when the status was |
| 5562 | * entered by the user. If this value is not provided, the provider will follow |
| 5563 | * this logic: if there was no prior status update, the value will be left as null. |
| 5564 | * If there was a prior status update, the provider will default this field |
| 5565 | * to the current time.</td> |
| 5566 | * </tr> |
| 5567 | * <tr> |
| 5568 | * <td>String</td> |
| 5569 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 5570 | * <td>read/write</td> |
| 5571 | * <td> The package containing resources for this status: label and icon.</td> |
| 5572 | * </tr> |
| 5573 | * <tr> |
| 5574 | * <td>long</td> |
| 5575 | * <td>{@link #STATUS_LABEL}</td> |
| 5576 | * <td>read/write</td> |
| 5577 | * <td>The resource ID of the label describing the source of contact status, |
| 5578 | * e.g. "Google Talk". This resource is scoped by the |
| 5579 | * {@link #STATUS_RES_PACKAGE}.</td> |
| 5580 | * </tr> |
| 5581 | * <tr> |
| 5582 | * <td>long</td> |
| 5583 | * <td>{@link #STATUS_ICON}</td> |
| 5584 | * <td>read/write</td> |
| 5585 | * <td>The resource ID of the icon for the source of contact status. This |
| 5586 | * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 5587 | * </tr> |
| 5588 | * </table> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5589 | */ |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5590 | public static class StatusUpdates implements StatusColumns, PresenceColumns { |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 5591 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5592 | /** |
| 5593 | * This utility class cannot be instantiated |
| 5594 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5595 | private StatusUpdates() {} |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5596 | |
| 5597 | /** |
| 5598 | * The content:// style URI for this table |
| 5599 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5600 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates"); |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5601 | |
| 5602 | /** |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 5603 | * The content:// style URI for this table, specific to the user's profile. |
| 5604 | */ |
| 5605 | public static final Uri PROFILE_CONTENT_URI = |
| 5606 | Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates"); |
| 5607 | |
| 5608 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5609 | * Gets the resource ID for the proper presence icon. |
| 5610 | * |
| 5611 | * @param status the status to get the icon for |
| 5612 | * @return the resource ID for the proper presence icon |
| 5613 | */ |
| 5614 | public static final int getPresenceIconResourceId(int status) { |
| 5615 | switch (status) { |
| 5616 | case AVAILABLE: |
| 5617 | return android.R.drawable.presence_online; |
| 5618 | case IDLE: |
| 5619 | case AWAY: |
| 5620 | return android.R.drawable.presence_away; |
| 5621 | case DO_NOT_DISTURB: |
| 5622 | return android.R.drawable.presence_busy; |
| 5623 | case INVISIBLE: |
| 5624 | return android.R.drawable.presence_invisible; |
| 5625 | case OFFLINE: |
| 5626 | default: |
| 5627 | return android.R.drawable.presence_offline; |
| 5628 | } |
| 5629 | } |
| 5630 | |
| 5631 | /** |
Evan Millar | c043752 | 2009-06-23 17:31:05 -0700 | [diff] [blame] | 5632 | * Returns the precedence of the status code the higher number being the higher precedence. |
| 5633 | * |
| 5634 | * @param status The status code. |
| 5635 | * @return An integer representing the precedence, 0 being the lowest. |
| 5636 | */ |
| 5637 | public static final int getPresencePrecedence(int status) { |
| 5638 | // Keep this function here incase we want to enforce a different precedence than the |
| 5639 | // natural order of the status constants. |
| 5640 | return status; |
| 5641 | } |
| 5642 | |
| 5643 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5644 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5645 | * status update details. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5646 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5647 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5648 | |
| 5649 | /** |
| 5650 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5651 | * status update detail. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5652 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5653 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update"; |
| 5654 | } |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 5655 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5656 | /** |
| 5657 | * @deprecated This old name was never meant to be made public. Do not use. |
| 5658 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5659 | @Deprecated |
| 5660 | public static final class Presence extends StatusUpdates { |
| 5661 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5662 | } |
| 5663 | |
| 5664 | /** |
Yorke Lee | 8d37009 | 2014-06-26 10:32:17 -0700 | [diff] [blame] | 5665 | * Additional column returned by |
| 5666 | * {@link ContactsContract.Contacts#CONTENT_FILTER_URI Contacts.CONTENT_FILTER_URI} explaining |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5667 | * why the filter matched the contact. This column will contain extracts from the contact's |
| 5668 | * constituent {@link Data Data} items, formatted in a way that indicates the section of the |
| 5669 | * snippet that matched the filter. |
| 5670 | * |
| 5671 | * <p> |
| 5672 | * The following example searches for all contacts that match the query "presi" and requests |
| 5673 | * the snippet column as well. |
| 5674 | * <pre> |
| 5675 | * Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon(); |
| 5676 | * builder.appendPath("presi"); |
| 5677 | * // Defer snippeting to the client side if possible, for performance reasons. |
| 5678 | * builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1"); |
| 5679 | * |
| 5680 | * Cursor cursor = getContentResolver().query(builder.build()); |
| 5681 | * |
| 5682 | * Bundle extras = cursor.getExtras(); |
| 5683 | * if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) { |
| 5684 | * // Do our own snippet formatting. |
| 5685 | * // For a contact with the email address (president@organization.com), the snippet |
| 5686 | * // column will contain the string "president@organization.com". |
| 5687 | * } else { |
| 5688 | * // The snippet has already been pre-formatted, we can display it as is. |
| 5689 | * // For a contact with the email address (president@organization.com), the snippet |
| 5690 | * // column will contain the string "[presi]dent@organization.com". |
| 5691 | * } |
| 5692 | * </pre> |
| 5693 | * </p> |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5694 | */ |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5695 | public static class SearchSnippets { |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5696 | |
| 5697 | /** |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5698 | * The search snippet constructed by SQLite snippeting functionality. |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5699 | * <p> |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5700 | * The snippet may contain (parts of) several data elements belonging to the contact, |
| 5701 | * with the matching parts optionally surrounded by special characters that indicate the |
| 5702 | * start and end of matching text. |
| 5703 | * |
| 5704 | * For example, if a contact has an address "123 Main Street", using a filter "mai" would |
| 5705 | * return the formatted snippet "123 [Mai]n street". |
| 5706 | * |
| 5707 | * @see <a href="http://www.sqlite.org/fts3.html#snippet"> |
| 5708 | * http://www.sqlite.org/fts3.html#snippet</a> |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5709 | */ |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5710 | public static final String SNIPPET = "snippet"; |
| 5711 | |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5712 | /** |
| 5713 | * Comma-separated parameters for the generation of the snippet: |
| 5714 | * <ul> |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5715 | * <li>The "start match" text. Default is '['</li> |
| 5716 | * <li>The "end match" text. Default is ']'</li> |
| 5717 | * <li>The "ellipsis" text. Default is "..."</li> |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5718 | * <li>Maximum number of tokens to include in the snippet. Can be either |
| 5719 | * a positive or a negative number: A positive number indicates how many |
| 5720 | * tokens can be returned in total. A negative number indicates how many |
| 5721 | * tokens can be returned per occurrence of the search terms.</li> |
| 5722 | * </ul> |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5723 | * |
| 5724 | * @hide |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5725 | */ |
| 5726 | public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args"; |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5727 | |
| 5728 | /** |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5729 | * The key to ask the provider to defer the formatting of the snippet to the client if |
| 5730 | * possible, for performance reasons. |
| 5731 | * 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] | 5732 | * When a cursor is returned to the client, it should check for an extra with the name |
| 5733 | * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5734 | * should do its own formatting of the snippet. If it doesn't exist, the snippet column |
| 5735 | * in the cursor should already contain a formatted snippet. |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5736 | */ |
| 5737 | public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting"; |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5738 | } |
| 5739 | |
| 5740 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5741 | * Container for definitions of common data types stored in the {@link ContactsContract.Data} |
| 5742 | * table. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5743 | */ |
| 5744 | public static final class CommonDataKinds { |
| 5745 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5746 | * This utility class cannot be instantiated |
| 5747 | */ |
| 5748 | private CommonDataKinds() {} |
| 5749 | |
| 5750 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5751 | * The {@link Data#RES_PACKAGE} value for common data that should be |
| 5752 | * shown using a default style. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5753 | * |
| 5754 | * @hide RES_PACKAGE is hidden |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5755 | */ |
| 5756 | public static final String PACKAGE_COMMON = "common"; |
| 5757 | |
| 5758 | /** |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5759 | * The base types that all "Typed" data kinds support. |
| 5760 | */ |
| 5761 | public interface BaseTypes { |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5762 | /** |
| 5763 | * A custom type. The custom label should be supplied by user. |
| 5764 | */ |
| 5765 | public static int TYPE_CUSTOM = 0; |
| 5766 | } |
| 5767 | |
| 5768 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5769 | * Columns common across the specific types. |
| 5770 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5771 | protected interface CommonColumns extends BaseTypes { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5772 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5773 | * The data for the contact method. |
| 5774 | * <P>Type: TEXT</P> |
| 5775 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5776 | public static final String DATA = DataColumns.DATA1; |
| 5777 | |
| 5778 | /** |
| 5779 | * The type of data, for example Home or Work. |
| 5780 | * <P>Type: INTEGER</P> |
| 5781 | */ |
| 5782 | public static final String TYPE = DataColumns.DATA2; |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 5783 | |
| 5784 | /** |
| 5785 | * The user defined label for the the contact method. |
| 5786 | * <P>Type: TEXT</P> |
| 5787 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5788 | public static final String LABEL = DataColumns.DATA3; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5789 | } |
| 5790 | |
| 5791 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5792 | * A data kind representing the contact's proper name. You can use all |
| 5793 | * columns defined for {@link ContactsContract.Data} as well as the following aliases. |
| 5794 | * |
| 5795 | * <h2>Column aliases</h2> |
| 5796 | * <table class="jd-sumtable"> |
| 5797 | * <tr> |
| 5798 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 5799 | * </tr> |
| 5800 | * <tr> |
| 5801 | * <td>String</td> |
| 5802 | * <td>{@link #DISPLAY_NAME}</td> |
| 5803 | * <td>{@link #DATA1}</td> |
| 5804 | * <td></td> |
| 5805 | * </tr> |
| 5806 | * <tr> |
| 5807 | * <td>String</td> |
| 5808 | * <td>{@link #GIVEN_NAME}</td> |
| 5809 | * <td>{@link #DATA2}</td> |
| 5810 | * <td></td> |
| 5811 | * </tr> |
| 5812 | * <tr> |
| 5813 | * <td>String</td> |
| 5814 | * <td>{@link #FAMILY_NAME}</td> |
| 5815 | * <td>{@link #DATA3}</td> |
| 5816 | * <td></td> |
| 5817 | * </tr> |
| 5818 | * <tr> |
| 5819 | * <td>String</td> |
| 5820 | * <td>{@link #PREFIX}</td> |
| 5821 | * <td>{@link #DATA4}</td> |
| 5822 | * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td> |
| 5823 | * </tr> |
| 5824 | * <tr> |
| 5825 | * <td>String</td> |
| 5826 | * <td>{@link #MIDDLE_NAME}</td> |
| 5827 | * <td>{@link #DATA5}</td> |
| 5828 | * <td></td> |
| 5829 | * </tr> |
| 5830 | * <tr> |
| 5831 | * <td>String</td> |
| 5832 | * <td>{@link #SUFFIX}</td> |
| 5833 | * <td>{@link #DATA6}</td> |
| 5834 | * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td> |
| 5835 | * </tr> |
| 5836 | * <tr> |
| 5837 | * <td>String</td> |
| 5838 | * <td>{@link #PHONETIC_GIVEN_NAME}</td> |
| 5839 | * <td>{@link #DATA7}</td> |
| 5840 | * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td> |
| 5841 | * </tr> |
| 5842 | * <tr> |
| 5843 | * <td>String</td> |
| 5844 | * <td>{@link #PHONETIC_MIDDLE_NAME}</td> |
| 5845 | * <td>{@link #DATA8}</td> |
| 5846 | * <td></td> |
| 5847 | * </tr> |
| 5848 | * <tr> |
| 5849 | * <td>String</td> |
| 5850 | * <td>{@link #PHONETIC_FAMILY_NAME}</td> |
| 5851 | * <td>{@link #DATA9}</td> |
| 5852 | * <td></td> |
| 5853 | * </tr> |
| 5854 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5855 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 5856 | public static final class StructuredName implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5857 | /** |
| 5858 | * This utility class cannot be instantiated |
| 5859 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5860 | private StructuredName() {} |
| 5861 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5862 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5863 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; |
| 5864 | |
| 5865 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5866 | * The name that should be used to display the contact. |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 5867 | * <i>Unstructured component of the name should be consistent with |
| 5868 | * its structured representation.</i> |
| 5869 | * <p> |
| 5870 | * Type: TEXT |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5871 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5872 | public static final String DISPLAY_NAME = DATA1; |
| 5873 | |
| 5874 | /** |
| 5875 | * The given name for the contact. |
| 5876 | * <P>Type: TEXT</P> |
| 5877 | */ |
| 5878 | public static final String GIVEN_NAME = DATA2; |
| 5879 | |
| 5880 | /** |
| 5881 | * The family name for the contact. |
| 5882 | * <P>Type: TEXT</P> |
| 5883 | */ |
| 5884 | public static final String FAMILY_NAME = DATA3; |
| 5885 | |
| 5886 | /** |
| 5887 | * The contact's honorific prefix, e.g. "Sir" |
| 5888 | * <P>Type: TEXT</P> |
| 5889 | */ |
| 5890 | public static final String PREFIX = DATA4; |
| 5891 | |
| 5892 | /** |
| 5893 | * The contact's middle name |
| 5894 | * <P>Type: TEXT</P> |
| 5895 | */ |
| 5896 | public static final String MIDDLE_NAME = DATA5; |
| 5897 | |
| 5898 | /** |
| 5899 | * The contact's honorific suffix, e.g. "Jr" |
| 5900 | */ |
| 5901 | public static final String SUFFIX = DATA6; |
| 5902 | |
| 5903 | /** |
| 5904 | * The phonetic version of the given name for the contact. |
| 5905 | * <P>Type: TEXT</P> |
| 5906 | */ |
| 5907 | public static final String PHONETIC_GIVEN_NAME = DATA7; |
| 5908 | |
| 5909 | /** |
| 5910 | * The phonetic version of the additional name for the contact. |
| 5911 | * <P>Type: TEXT</P> |
| 5912 | */ |
| 5913 | public static final String PHONETIC_MIDDLE_NAME = DATA8; |
| 5914 | |
| 5915 | /** |
| 5916 | * The phonetic version of the family name for the contact. |
| 5917 | * <P>Type: TEXT</P> |
| 5918 | */ |
| 5919 | public static final String PHONETIC_FAMILY_NAME = DATA9; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5920 | |
| 5921 | /** |
| 5922 | * The style used for combining given/middle/family name into a full name. |
| 5923 | * See {@link ContactsContract.FullNameStyle}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5924 | */ |
| 5925 | public static final String FULL_NAME_STYLE = DATA10; |
| 5926 | |
| 5927 | /** |
| 5928 | * The alphabet used for capturing the phonetic name. |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 5929 | * See ContactsContract.PhoneticNameStyle. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5930 | */ |
| 5931 | public static final String PHONETIC_NAME_STYLE = DATA11; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5932 | } |
| 5933 | |
| 5934 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5935 | * <p>A data kind representing the contact's nickname. For example, for |
| 5936 | * Bob Parr ("Mr. Incredible"): |
| 5937 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 5938 | * ArrayList<ContentProviderOperation> ops = |
| 5939 | * new ArrayList<ContentProviderOperation>(); |
| 5940 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5941 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 5942 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 5943 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 5944 | * .withValue(StructuredName.DISPLAY_NAME, "Bob Parr") |
| 5945 | * .build()); |
| 5946 | * |
| 5947 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 5948 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 5949 | * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE) |
| 5950 | * .withValue(Nickname.NAME, "Mr. Incredible") |
| 5951 | * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM) |
| 5952 | * .withValue(Nickname.LABEL, "Superhero") |
| 5953 | * .build()); |
| 5954 | * |
| 5955 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 5956 | * </pre> |
| 5957 | * </p> |
| 5958 | * <p> |
| 5959 | * You can use all columns defined for {@link ContactsContract.Data} as well as the |
| 5960 | * following aliases. |
| 5961 | * </p> |
| 5962 | * |
| 5963 | * <h2>Column aliases</h2> |
| 5964 | * <table class="jd-sumtable"> |
| 5965 | * <tr> |
| 5966 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 5967 | * </tr> |
| 5968 | * <tr> |
| 5969 | * <td>String</td> |
| 5970 | * <td>{@link #NAME}</td> |
| 5971 | * <td>{@link #DATA1}</td> |
| 5972 | * <td></td> |
| 5973 | * </tr> |
| 5974 | * <tr> |
| 5975 | * <td>int</td> |
| 5976 | * <td>{@link #TYPE}</td> |
| 5977 | * <td>{@link #DATA2}</td> |
| 5978 | * <td> |
| 5979 | * Allowed values are: |
| 5980 | * <p> |
| 5981 | * <ul> |
| 5982 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5983 | * <li>{@link #TYPE_DEFAULT}</li> |
| 5984 | * <li>{@link #TYPE_OTHER_NAME}</li> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5985 | * <li>{@link #TYPE_MAIDEN_NAME}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5986 | * <li>{@link #TYPE_SHORT_NAME}</li> |
| 5987 | * <li>{@link #TYPE_INITIALS}</li> |
| 5988 | * </ul> |
| 5989 | * </p> |
| 5990 | * </td> |
| 5991 | * </tr> |
| 5992 | * <tr> |
| 5993 | * <td>String</td> |
| 5994 | * <td>{@link #LABEL}</td> |
| 5995 | * <td>{@link #DATA3}</td> |
| 5996 | * <td></td> |
| 5997 | * </tr> |
| 5998 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5999 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6000 | public static final class Nickname implements DataColumnsWithJoins, CommonColumns, |
| 6001 | ContactCounts{ |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6002 | /** |
| 6003 | * This utility class cannot be instantiated |
| 6004 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6005 | private Nickname() {} |
| 6006 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6007 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6008 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; |
| 6009 | |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 6010 | public static final int TYPE_DEFAULT = 1; |
| 6011 | public static final int TYPE_OTHER_NAME = 2; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 6012 | public static final int TYPE_MAIDEN_NAME = 3; |
| 6013 | /** @deprecated Use TYPE_MAIDEN_NAME instead. */ |
| 6014 | @Deprecated |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 6015 | public static final int TYPE_MAINDEN_NAME = 3; |
| 6016 | public static final int TYPE_SHORT_NAME = 4; |
| 6017 | public static final int TYPE_INITIALS = 5; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6018 | |
| 6019 | /** |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 6020 | * The name itself |
| 6021 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6022 | public static final String NAME = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6023 | } |
| 6024 | |
| 6025 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6026 | * <p> |
| 6027 | * A data kind representing a telephone number. |
| 6028 | * </p> |
| 6029 | * <p> |
| 6030 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6031 | * well as the following aliases. |
| 6032 | * </p> |
| 6033 | * <h2>Column aliases</h2> |
| 6034 | * <table class="jd-sumtable"> |
| 6035 | * <tr> |
| 6036 | * <th>Type</th> |
| 6037 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6038 | * </tr> |
| 6039 | * <tr> |
| 6040 | * <td>String</td> |
| 6041 | * <td>{@link #NUMBER}</td> |
| 6042 | * <td>{@link #DATA1}</td> |
| 6043 | * <td></td> |
| 6044 | * </tr> |
| 6045 | * <tr> |
| 6046 | * <td>int</td> |
| 6047 | * <td>{@link #TYPE}</td> |
| 6048 | * <td>{@link #DATA2}</td> |
| 6049 | * <td>Allowed values are: |
| 6050 | * <p> |
| 6051 | * <ul> |
| 6052 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6053 | * <li>{@link #TYPE_HOME}</li> |
| 6054 | * <li>{@link #TYPE_MOBILE}</li> |
| 6055 | * <li>{@link #TYPE_WORK}</li> |
| 6056 | * <li>{@link #TYPE_FAX_WORK}</li> |
| 6057 | * <li>{@link #TYPE_FAX_HOME}</li> |
| 6058 | * <li>{@link #TYPE_PAGER}</li> |
| 6059 | * <li>{@link #TYPE_OTHER}</li> |
| 6060 | * <li>{@link #TYPE_CALLBACK}</li> |
| 6061 | * <li>{@link #TYPE_CAR}</li> |
| 6062 | * <li>{@link #TYPE_COMPANY_MAIN}</li> |
| 6063 | * <li>{@link #TYPE_ISDN}</li> |
| 6064 | * <li>{@link #TYPE_MAIN}</li> |
| 6065 | * <li>{@link #TYPE_OTHER_FAX}</li> |
| 6066 | * <li>{@link #TYPE_RADIO}</li> |
| 6067 | * <li>{@link #TYPE_TELEX}</li> |
| 6068 | * <li>{@link #TYPE_TTY_TDD}</li> |
| 6069 | * <li>{@link #TYPE_WORK_MOBILE}</li> |
| 6070 | * <li>{@link #TYPE_WORK_PAGER}</li> |
| 6071 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 6072 | * <li>{@link #TYPE_MMS}</li> |
| 6073 | * </ul> |
| 6074 | * </p> |
| 6075 | * </td> |
| 6076 | * </tr> |
| 6077 | * <tr> |
| 6078 | * <td>String</td> |
| 6079 | * <td>{@link #LABEL}</td> |
| 6080 | * <td>{@link #DATA3}</td> |
| 6081 | * <td></td> |
| 6082 | * </tr> |
| 6083 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6084 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6085 | public static final class Phone implements DataColumnsWithJoins, CommonColumns, |
| 6086 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6087 | /** |
| 6088 | * This utility class cannot be instantiated |
| 6089 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6090 | private Phone() {} |
| 6091 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6092 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6093 | 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] | 6094 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6095 | /** |
| 6096 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 6097 | * phones. |
| 6098 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6099 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2"; |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6100 | |
| 6101 | /** |
| 6102 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6103 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 6104 | * associated raw contact and aggregate contact data. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6105 | */ |
| 6106 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6107 | "phones"); |
| 6108 | |
| 6109 | /** |
Ricky Wai | fa5bbaf | 2015-02-26 16:51:32 +0000 | [diff] [blame] | 6110 | * URI used for getting all contacts from primary and managed profile. |
| 6111 | * |
| 6112 | * It supports the same semantics as {@link #CONTENT_URI} and returns the same |
| 6113 | * columns. If the device has no corp profile that is linked to the current profile, it |
| 6114 | * behaves in the exact same way as {@link #CONTENT_URI}. If there is a corp profile |
| 6115 | * linked to the current profile, it will merge corp profile and current profile's |
| 6116 | * results and return |
| 6117 | * |
| 6118 | * @hide |
| 6119 | */ |
| 6120 | public static final Uri ENTERPRISE_CONTENT_URI = |
| 6121 | Uri.withAppendedPath(Data.ENTERPRISE_CONTENT_URI, "phones"); |
| 6122 | |
| 6123 | /** |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6124 | * 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] | 6125 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6126 | * to display names as well as phone numbers. The filter argument should be passed |
| 6127 | * as an additional path segment after this URI. |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6128 | * |
| 6129 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer |
| 6130 | * sorts results based on contacts frequency. For more information, see the |
| 6131 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 6132 | * page. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6133 | */ |
| 6134 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 6135 | "filter"); |
| 6136 | |
Daniel Lehmann | 1024de5 | 2012-06-15 20:32:33 -0700 | [diff] [blame] | 6137 | /** |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6138 | * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the |
| 6139 | * same columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 6140 | * parameters, otherwise it will throw IllegalArgumentException. |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6141 | * |
| 6142 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts |
| 6143 | * results based on contacts frequency. For more information, see the |
| 6144 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 6145 | * page. |
Victor Chang | 3d47ceb | 2015-12-01 16:30:43 +0000 | [diff] [blame] | 6146 | */ |
| 6147 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 6148 | CONTENT_URI, "filter_enterprise"); |
| 6149 | |
| 6150 | /** |
Daniel Lehmann | 1024de5 | 2012-06-15 20:32:33 -0700 | [diff] [blame] | 6151 | * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. |
| 6152 | * If "1" or "true", display names are searched. If "0" or "false", display names |
| 6153 | * are not searched. Default is "1". |
| 6154 | */ |
| 6155 | public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name"; |
| 6156 | |
| 6157 | /** |
| 6158 | * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. |
| 6159 | * If "1" or "true", phone numbers are searched. If "0" or "false", phone numbers |
| 6160 | * are not searched. Default is "1". |
| 6161 | */ |
| 6162 | public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number"; |
| 6163 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6164 | public static final int TYPE_HOME = 1; |
| 6165 | public static final int TYPE_MOBILE = 2; |
| 6166 | public static final int TYPE_WORK = 3; |
| 6167 | public static final int TYPE_FAX_WORK = 4; |
| 6168 | public static final int TYPE_FAX_HOME = 5; |
| 6169 | public static final int TYPE_PAGER = 6; |
| 6170 | public static final int TYPE_OTHER = 7; |
Fred Quintana | 3f86715 | 2009-08-03 11:43:16 -0700 | [diff] [blame] | 6171 | public static final int TYPE_CALLBACK = 8; |
| 6172 | public static final int TYPE_CAR = 9; |
| 6173 | public static final int TYPE_COMPANY_MAIN = 10; |
| 6174 | public static final int TYPE_ISDN = 11; |
| 6175 | public static final int TYPE_MAIN = 12; |
| 6176 | public static final int TYPE_OTHER_FAX = 13; |
| 6177 | public static final int TYPE_RADIO = 14; |
| 6178 | public static final int TYPE_TELEX = 15; |
| 6179 | public static final int TYPE_TTY_TDD = 16; |
| 6180 | public static final int TYPE_WORK_MOBILE = 17; |
| 6181 | public static final int TYPE_WORK_PAGER = 18; |
| 6182 | public static final int TYPE_ASSISTANT = 19; |
Jeff Sharkey | d5abd46 | 2009-09-16 19:54:29 -0700 | [diff] [blame] | 6183 | public static final int TYPE_MMS = 20; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6184 | |
| 6185 | /** |
| 6186 | * The phone number as the user entered it. |
| 6187 | * <P>Type: TEXT</P> |
| 6188 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6189 | public static final String NUMBER = DATA; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 6190 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6191 | /** |
Daniel Lehmann | db91915 | 2012-03-09 14:30:50 -0800 | [diff] [blame] | 6192 | * 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] | 6193 | * case the provider will try to automatically infer it. (It'll be left null if the |
| 6194 | * provider fails to infer.) |
| 6195 | * 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] | 6196 | * <P>Type: TEXT</P> |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 6197 | */ |
| 6198 | public static final String NORMALIZED_NUMBER = DATA4; |
| 6199 | |
| 6200 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6201 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6202 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6203 | */ |
| 6204 | @Deprecated |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 6205 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 6206 | CharSequence label, CharSequence[] labelArray) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6207 | return getTypeLabel(context.getResources(), type, label); |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 6208 | } |
| 6209 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6210 | /** |
| 6211 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6212 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6213 | */ |
| 6214 | @Deprecated |
Mathew Inwood | ba50311 | 2018-08-10 09:37:35 +0100 | [diff] [blame] | 6215 | @UnsupportedAppUsage |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 6216 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 6217 | CharSequence label) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6218 | return getTypeLabel(context.getResources(), type, label); |
| 6219 | } |
| 6220 | |
| 6221 | /** |
| 6222 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6223 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6224 | */ |
| 6225 | public static final int getTypeLabelResource(int type) { |
| 6226 | switch (type) { |
| 6227 | case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome; |
| 6228 | case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile; |
| 6229 | case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork; |
| 6230 | case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork; |
| 6231 | case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome; |
| 6232 | case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager; |
| 6233 | case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther; |
| 6234 | case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback; |
| 6235 | case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar; |
| 6236 | case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain; |
| 6237 | case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn; |
| 6238 | case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain; |
| 6239 | case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax; |
| 6240 | case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio; |
| 6241 | case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex; |
| 6242 | case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd; |
| 6243 | case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile; |
| 6244 | case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager; |
| 6245 | case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant; |
| 6246 | case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms; |
| 6247 | default: return com.android.internal.R.string.phoneTypeCustom; |
| 6248 | } |
| 6249 | } |
| 6250 | |
| 6251 | /** |
| 6252 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6253 | * possibly substituting the given {@link #LABEL} value |
| 6254 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6255 | */ |
| 6256 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6257 | CharSequence label) { |
Tingting Wang | 86ac228 | 2015-07-16 21:19:28 +0000 | [diff] [blame] | 6258 | if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6259 | return label; |
| 6260 | } else { |
| 6261 | final int labelRes = getTypeLabelResource(type); |
| 6262 | return res.getText(labelRes); |
| 6263 | } |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 6264 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6265 | } |
| 6266 | |
| 6267 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6268 | * <p> |
| 6269 | * A data kind representing an email address. |
| 6270 | * </p> |
| 6271 | * <p> |
| 6272 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6273 | * well as the following aliases. |
| 6274 | * </p> |
| 6275 | * <h2>Column aliases</h2> |
| 6276 | * <table class="jd-sumtable"> |
| 6277 | * <tr> |
| 6278 | * <th>Type</th> |
| 6279 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6280 | * </tr> |
| 6281 | * <tr> |
| 6282 | * <td>String</td> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 6283 | * <td>{@link #ADDRESS}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6284 | * <td>{@link #DATA1}</td> |
| 6285 | * <td>Email address itself.</td> |
| 6286 | * </tr> |
| 6287 | * <tr> |
| 6288 | * <td>int</td> |
| 6289 | * <td>{@link #TYPE}</td> |
| 6290 | * <td>{@link #DATA2}</td> |
| 6291 | * <td>Allowed values are: |
| 6292 | * <p> |
| 6293 | * <ul> |
| 6294 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6295 | * <li>{@link #TYPE_HOME}</li> |
| 6296 | * <li>{@link #TYPE_WORK}</li> |
| 6297 | * <li>{@link #TYPE_OTHER}</li> |
| 6298 | * <li>{@link #TYPE_MOBILE}</li> |
| 6299 | * </ul> |
| 6300 | * </p> |
| 6301 | * </td> |
| 6302 | * </tr> |
| 6303 | * <tr> |
| 6304 | * <td>String</td> |
| 6305 | * <td>{@link #LABEL}</td> |
| 6306 | * <td>{@link #DATA3}</td> |
| 6307 | * <td></td> |
| 6308 | * </tr> |
| 6309 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6310 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6311 | public static final class Email implements DataColumnsWithJoins, CommonColumns, |
| 6312 | ContactCounts { |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6313 | /* |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6314 | * This utility class cannot be instantiated |
| 6315 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6316 | private Email() {} |
| 6317 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6318 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6319 | 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] | 6320 | |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6321 | /** |
Dmitri Plotnikov | abf15c3 | 2009-09-18 20:29:11 -0700 | [diff] [blame] | 6322 | * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses. |
| 6323 | */ |
| 6324 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2"; |
| 6325 | |
| 6326 | /** |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6327 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6328 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6329 | * associated raw contact and aggregate contact data. |
| 6330 | */ |
| 6331 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6332 | "emails"); |
| 6333 | |
| 6334 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6335 | * <p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6336 | * The content:// style URL for looking up data rows by email address. The |
| 6337 | * lookup argument, an email address, should be passed as an additional path segment |
| 6338 | * after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6339 | * </p> |
| 6340 | * <p>Example: |
| 6341 | * <pre> |
| 6342 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email)); |
| 6343 | * Cursor c = getContentResolver().query(uri, |
| 6344 | * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA}, |
| 6345 | * null, null, null); |
| 6346 | * </pre> |
| 6347 | * </p> |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6348 | */ |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6349 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 6350 | "lookup"); |
| 6351 | |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6352 | /** |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 6353 | * <p>URI used for enterprise email lookup.</p> |
| 6354 | * |
| 6355 | * <p> |
| 6356 | * It supports the same semantics as {@link #CONTENT_LOOKUP_URI} and returns the same |
| 6357 | * columns. If the device has no corp profile that is linked to the current profile, it |
| 6358 | * behaves in the exact same way as {@link #CONTENT_LOOKUP_URI}. If there is a |
| 6359 | * corp profile linked to the current profile, it first queries against the personal contact database, |
| 6360 | * and if no matching contacts are found there, then queries against the |
| 6361 | * corp contacts database. |
| 6362 | * </p> |
| 6363 | * <p> |
| 6364 | * If a result is from the corp profile, it makes the following changes to the data: |
| 6365 | * <ul> |
| 6366 | * <li> |
| 6367 | * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special |
| 6368 | * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to |
| 6369 | * load pictures from them. |
| 6370 | * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not |
| 6371 | * use them. |
| 6372 | * </li> |
| 6373 | * <li> |
| 6374 | * Corp contacts will get artificial {@link #CONTACT_ID}s. In order to tell whether |
| 6375 | * a contact |
| 6376 | * is from the corp profile, use |
| 6377 | * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}. |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 6378 | * </li> |
| 6379 | * <li> |
| 6380 | * Corp contacts will get artificial {@link #LOOKUP_KEY}s too. |
| 6381 | * </li> |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 6382 | * <li> |
| 6383 | * Returned work contact IDs and lookup keys are not accepted in places that not |
| 6384 | * explicitly say to accept them. |
| 6385 | * </li> |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 6386 | * </ul> |
| 6387 | * <p> |
| 6388 | * A contact lookup URL built by |
| 6389 | * {@link ContactsContract.Contacts#getLookupUri(long, String)} |
| 6390 | * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to |
| 6391 | * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the |
| 6392 | * corp profile. |
| 6393 | * </p> |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 6394 | * |
| 6395 | * <pre> |
| 6396 | * Uri lookupUri = Uri.withAppendedPath(Email.ENTERPRISE_CONTENT_LOOKUP_URI, |
| 6397 | * Uri.encode(email)); |
| 6398 | * </pre> |
| 6399 | */ |
| 6400 | public static final Uri ENTERPRISE_CONTENT_LOOKUP_URI = |
| 6401 | Uri.withAppendedPath(CONTENT_URI, "lookup_enterprise"); |
| 6402 | |
| 6403 | /** |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6404 | * 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] | 6405 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6406 | * to display names as well as email addresses. The filter argument should be passed |
| 6407 | * as an additional path segment after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6408 | * </p> |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6409 | * |
| 6410 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts |
| 6411 | * results based on contacts frequency. For more information, see the |
| 6412 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 6413 | * page.</p> |
| 6414 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6415 | * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)" |
| 6416 | * as well as "Bob Parr (incredible@android.com)". |
| 6417 | * <pre> |
| 6418 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob")); |
| 6419 | * Cursor c = getContentResolver().query(uri, |
| 6420 | * new String[]{Email.DISPLAY_NAME, Email.DATA}, |
| 6421 | * null, null, null); |
| 6422 | * </pre> |
| 6423 | * </p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6424 | */ |
| 6425 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6426 | "filter"); |
| 6427 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6428 | /** |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6429 | * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the |
| 6430 | * same columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 6431 | * parameters, otherwise it will throw IllegalArgumentException. |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6432 | * |
| 6433 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer |
| 6434 | * sorts results based on contacts frequency. For more information, see the |
| 6435 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 6436 | * page. |
Tony Mak | 415369e | 2015-12-08 07:24:55 +0000 | [diff] [blame] | 6437 | */ |
| 6438 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 6439 | CONTENT_URI, "filter_enterprise"); |
| 6440 | |
| 6441 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6442 | * The email address. |
| 6443 | * <P>Type: TEXT</P> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6444 | */ |
| 6445 | public static final String ADDRESS = DATA1; |
| 6446 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6447 | public static final int TYPE_HOME = 1; |
| 6448 | public static final int TYPE_WORK = 2; |
| 6449 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 14fb153 | 2009-08-29 15:54:26 -0700 | [diff] [blame] | 6450 | public static final int TYPE_MOBILE = 4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6451 | |
| 6452 | /** |
| 6453 | * The display name for the email address |
| 6454 | * <P>Type: TEXT</P> |
| 6455 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6456 | public static final String DISPLAY_NAME = DATA4; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6457 | |
| 6458 | /** |
| 6459 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6460 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6461 | */ |
| 6462 | public static final int getTypeLabelResource(int type) { |
| 6463 | switch (type) { |
| 6464 | case TYPE_HOME: return com.android.internal.R.string.emailTypeHome; |
| 6465 | case TYPE_WORK: return com.android.internal.R.string.emailTypeWork; |
| 6466 | case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther; |
| 6467 | case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile; |
| 6468 | default: return com.android.internal.R.string.emailTypeCustom; |
| 6469 | } |
| 6470 | } |
| 6471 | |
| 6472 | /** |
| 6473 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6474 | * possibly substituting the given {@link #LABEL} value |
| 6475 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6476 | */ |
| 6477 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6478 | CharSequence label) { |
| 6479 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6480 | return label; |
| 6481 | } else { |
| 6482 | final int labelRes = getTypeLabelResource(type); |
| 6483 | return res.getText(labelRes); |
| 6484 | } |
| 6485 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6486 | } |
| 6487 | |
| 6488 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6489 | * <p> |
| 6490 | * A data kind representing a postal addresses. |
| 6491 | * </p> |
| 6492 | * <p> |
| 6493 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6494 | * well as the following aliases. |
| 6495 | * </p> |
| 6496 | * <h2>Column aliases</h2> |
| 6497 | * <table class="jd-sumtable"> |
| 6498 | * <tr> |
| 6499 | * <th>Type</th> |
| 6500 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6501 | * </tr> |
| 6502 | * <tr> |
| 6503 | * <td>String</td> |
| 6504 | * <td>{@link #FORMATTED_ADDRESS}</td> |
| 6505 | * <td>{@link #DATA1}</td> |
| 6506 | * <td></td> |
| 6507 | * </tr> |
| 6508 | * <tr> |
| 6509 | * <td>int</td> |
| 6510 | * <td>{@link #TYPE}</td> |
| 6511 | * <td>{@link #DATA2}</td> |
| 6512 | * <td>Allowed values are: |
| 6513 | * <p> |
| 6514 | * <ul> |
| 6515 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6516 | * <li>{@link #TYPE_HOME}</li> |
| 6517 | * <li>{@link #TYPE_WORK}</li> |
| 6518 | * <li>{@link #TYPE_OTHER}</li> |
| 6519 | * </ul> |
| 6520 | * </p> |
| 6521 | * </td> |
| 6522 | * </tr> |
| 6523 | * <tr> |
| 6524 | * <td>String</td> |
| 6525 | * <td>{@link #LABEL}</td> |
| 6526 | * <td>{@link #DATA3}</td> |
| 6527 | * <td></td> |
| 6528 | * </tr> |
| 6529 | * <tr> |
| 6530 | * <td>String</td> |
| 6531 | * <td>{@link #STREET}</td> |
| 6532 | * <td>{@link #DATA4}</td> |
| 6533 | * <td></td> |
| 6534 | * </tr> |
| 6535 | * <tr> |
| 6536 | * <td>String</td> |
| 6537 | * <td>{@link #POBOX}</td> |
| 6538 | * <td>{@link #DATA5}</td> |
| 6539 | * <td>Post Office Box number</td> |
| 6540 | * </tr> |
| 6541 | * <tr> |
| 6542 | * <td>String</td> |
| 6543 | * <td>{@link #NEIGHBORHOOD}</td> |
| 6544 | * <td>{@link #DATA6}</td> |
| 6545 | * <td></td> |
| 6546 | * </tr> |
| 6547 | * <tr> |
| 6548 | * <td>String</td> |
| 6549 | * <td>{@link #CITY}</td> |
| 6550 | * <td>{@link #DATA7}</td> |
| 6551 | * <td></td> |
| 6552 | * </tr> |
| 6553 | * <tr> |
| 6554 | * <td>String</td> |
| 6555 | * <td>{@link #REGION}</td> |
| 6556 | * <td>{@link #DATA8}</td> |
| 6557 | * <td></td> |
| 6558 | * </tr> |
| 6559 | * <tr> |
| 6560 | * <td>String</td> |
| 6561 | * <td>{@link #POSTCODE}</td> |
| 6562 | * <td>{@link #DATA9}</td> |
| 6563 | * <td></td> |
| 6564 | * </tr> |
| 6565 | * <tr> |
| 6566 | * <td>String</td> |
| 6567 | * <td>{@link #COUNTRY}</td> |
| 6568 | * <td>{@link #DATA10}</td> |
| 6569 | * <td></td> |
| 6570 | * </tr> |
| 6571 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6572 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6573 | public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns, |
| 6574 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6575 | /** |
| 6576 | * This utility class cannot be instantiated |
| 6577 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6578 | private StructuredPostal() { |
| 6579 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6580 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6581 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6582 | public static final String CONTENT_ITEM_TYPE = |
| 6583 | "vnd.android.cursor.item/postal-address_v2"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6584 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6585 | /** |
| 6586 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 6587 | * postal addresses. |
| 6588 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6589 | 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] | 6590 | |
| 6591 | /** |
| 6592 | * The content:// style URI for all data records of the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6593 | * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6594 | */ |
| 6595 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6596 | "postals"); |
| 6597 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6598 | public static final int TYPE_HOME = 1; |
| 6599 | public static final int TYPE_WORK = 2; |
| 6600 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6601 | |
| 6602 | /** |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 6603 | * The full, unstructured postal address. <i>This field must be |
| 6604 | * consistent with any structured data.</i> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6605 | * <p> |
| 6606 | * Type: TEXT |
| 6607 | */ |
| 6608 | public static final String FORMATTED_ADDRESS = DATA; |
| 6609 | |
| 6610 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6611 | * Can be street, avenue, road, etc. This element also includes the |
| 6612 | * house number and room/apartment/flat/floor number. |
| 6613 | * <p> |
| 6614 | * Type: TEXT |
| 6615 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6616 | public static final String STREET = DATA4; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6617 | |
| 6618 | /** |
| 6619 | * Covers actual P.O. boxes, drawers, locked bags, etc. This is |
| 6620 | * usually but not always mutually exclusive with street. |
| 6621 | * <p> |
| 6622 | * Type: TEXT |
| 6623 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6624 | public static final String POBOX = DATA5; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6625 | |
| 6626 | /** |
| 6627 | * This is used to disambiguate a street address when a city |
| 6628 | * contains more than one street with the same name, or to specify a |
| 6629 | * small place whose mail is routed through a larger postal town. In |
| 6630 | * China it could be a county or a minor city. |
| 6631 | * <p> |
| 6632 | * Type: TEXT |
| 6633 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6634 | public static final String NEIGHBORHOOD = DATA6; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6635 | |
| 6636 | /** |
| 6637 | * Can be city, village, town, borough, etc. This is the postal town |
| 6638 | * and not necessarily the place of residence or place of business. |
| 6639 | * <p> |
| 6640 | * Type: TEXT |
| 6641 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6642 | public static final String CITY = DATA7; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6643 | |
| 6644 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6645 | * A state, province, county (in Ireland), Land (in Germany), |
| 6646 | * departement (in France), etc. |
| 6647 | * <p> |
| 6648 | * Type: TEXT |
| 6649 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6650 | public static final String REGION = DATA8; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6651 | |
| 6652 | /** |
Jeff Sharkey | ef348c7 | 2009-07-26 14:14:34 -0700 | [diff] [blame] | 6653 | * Postal code. Usually country-wide, but sometimes specific to the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6654 | * city (e.g. "2" in "Dublin 2, Ireland" addresses). |
| 6655 | * <p> |
| 6656 | * Type: TEXT |
| 6657 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6658 | public static final String POSTCODE = DATA9; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6659 | |
| 6660 | /** |
| 6661 | * The name or code of the country. |
| 6662 | * <p> |
| 6663 | * Type: TEXT |
| 6664 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6665 | public static final String COUNTRY = DATA10; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6666 | |
| 6667 | /** |
| 6668 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6669 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6670 | */ |
| 6671 | public static final int getTypeLabelResource(int type) { |
| 6672 | switch (type) { |
| 6673 | case TYPE_HOME: return com.android.internal.R.string.postalTypeHome; |
| 6674 | case TYPE_WORK: return com.android.internal.R.string.postalTypeWork; |
| 6675 | case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther; |
| 6676 | default: return com.android.internal.R.string.postalTypeCustom; |
| 6677 | } |
| 6678 | } |
| 6679 | |
| 6680 | /** |
| 6681 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6682 | * possibly substituting the given {@link #LABEL} value |
| 6683 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6684 | */ |
| 6685 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6686 | CharSequence label) { |
| 6687 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6688 | return label; |
| 6689 | } else { |
| 6690 | final int labelRes = getTypeLabelResource(type); |
| 6691 | return res.getText(labelRes); |
| 6692 | } |
| 6693 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6694 | } |
| 6695 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6696 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6697 | * <p> |
| 6698 | * A data kind representing an IM address |
| 6699 | * </p> |
| 6700 | * <p> |
| 6701 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6702 | * well as the following aliases. |
| 6703 | * </p> |
| 6704 | * <h2>Column aliases</h2> |
| 6705 | * <table class="jd-sumtable"> |
| 6706 | * <tr> |
| 6707 | * <th>Type</th> |
| 6708 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6709 | * </tr> |
| 6710 | * <tr> |
| 6711 | * <td>String</td> |
| 6712 | * <td>{@link #DATA}</td> |
| 6713 | * <td>{@link #DATA1}</td> |
| 6714 | * <td></td> |
| 6715 | * </tr> |
| 6716 | * <tr> |
| 6717 | * <td>int</td> |
| 6718 | * <td>{@link #TYPE}</td> |
| 6719 | * <td>{@link #DATA2}</td> |
| 6720 | * <td>Allowed values are: |
| 6721 | * <p> |
| 6722 | * <ul> |
| 6723 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6724 | * <li>{@link #TYPE_HOME}</li> |
| 6725 | * <li>{@link #TYPE_WORK}</li> |
| 6726 | * <li>{@link #TYPE_OTHER}</li> |
| 6727 | * </ul> |
| 6728 | * </p> |
| 6729 | * </td> |
| 6730 | * </tr> |
| 6731 | * <tr> |
| 6732 | * <td>String</td> |
| 6733 | * <td>{@link #LABEL}</td> |
| 6734 | * <td>{@link #DATA3}</td> |
| 6735 | * <td></td> |
| 6736 | * </tr> |
| 6737 | * <tr> |
| 6738 | * <td>String</td> |
| 6739 | * <td>{@link #PROTOCOL}</td> |
| 6740 | * <td>{@link #DATA5}</td> |
| 6741 | * <td> |
| 6742 | * <p> |
| 6743 | * Allowed values: |
| 6744 | * <ul> |
| 6745 | * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name |
| 6746 | * as {@link #CUSTOM_PROTOCOL}.</li> |
| 6747 | * <li>{@link #PROTOCOL_AIM}</li> |
| 6748 | * <li>{@link #PROTOCOL_MSN}</li> |
| 6749 | * <li>{@link #PROTOCOL_YAHOO}</li> |
| 6750 | * <li>{@link #PROTOCOL_SKYPE}</li> |
| 6751 | * <li>{@link #PROTOCOL_QQ}</li> |
| 6752 | * <li>{@link #PROTOCOL_GOOGLE_TALK}</li> |
| 6753 | * <li>{@link #PROTOCOL_ICQ}</li> |
| 6754 | * <li>{@link #PROTOCOL_JABBER}</li> |
| 6755 | * <li>{@link #PROTOCOL_NETMEETING}</li> |
| 6756 | * </ul> |
| 6757 | * </p> |
| 6758 | * </td> |
| 6759 | * </tr> |
| 6760 | * <tr> |
| 6761 | * <td>String</td> |
| 6762 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 6763 | * <td>{@link #DATA6}</td> |
| 6764 | * <td></td> |
| 6765 | * </tr> |
| 6766 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6767 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6768 | public static final class Im implements DataColumnsWithJoins, CommonColumns, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6769 | /** |
| 6770 | * This utility class cannot be instantiated |
| 6771 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6772 | private Im() {} |
| 6773 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6774 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6775 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; |
| 6776 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6777 | public static final int TYPE_HOME = 1; |
| 6778 | public static final int TYPE_WORK = 2; |
| 6779 | public static final int TYPE_OTHER = 3; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6780 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 6781 | /** |
| 6782 | * This column should be populated with one of the defined |
| 6783 | * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this |
| 6784 | * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL} |
| 6785 | * should contain the name of the custom protocol. |
| 6786 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6787 | public static final String PROTOCOL = DATA5; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6788 | |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6789 | public static final String CUSTOM_PROTOCOL = DATA6; |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 6790 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 6791 | /* |
| 6792 | * The predefined IM protocol types. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6793 | */ |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 6794 | public static final int PROTOCOL_CUSTOM = -1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6795 | public static final int PROTOCOL_AIM = 0; |
| 6796 | public static final int PROTOCOL_MSN = 1; |
| 6797 | public static final int PROTOCOL_YAHOO = 2; |
| 6798 | public static final int PROTOCOL_SKYPE = 3; |
| 6799 | public static final int PROTOCOL_QQ = 4; |
| 6800 | public static final int PROTOCOL_GOOGLE_TALK = 5; |
| 6801 | public static final int PROTOCOL_ICQ = 6; |
| 6802 | public static final int PROTOCOL_JABBER = 7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6803 | public static final int PROTOCOL_NETMEETING = 8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6804 | |
| 6805 | /** |
| 6806 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6807 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6808 | */ |
| 6809 | public static final int getTypeLabelResource(int type) { |
| 6810 | switch (type) { |
| 6811 | case TYPE_HOME: return com.android.internal.R.string.imTypeHome; |
| 6812 | case TYPE_WORK: return com.android.internal.R.string.imTypeWork; |
| 6813 | case TYPE_OTHER: return com.android.internal.R.string.imTypeOther; |
| 6814 | default: return com.android.internal.R.string.imTypeCustom; |
| 6815 | } |
| 6816 | } |
| 6817 | |
| 6818 | /** |
| 6819 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6820 | * possibly substituting the given {@link #LABEL} value |
| 6821 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6822 | */ |
| 6823 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6824 | CharSequence label) { |
| 6825 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6826 | return label; |
| 6827 | } else { |
| 6828 | final int labelRes = getTypeLabelResource(type); |
| 6829 | return res.getText(labelRes); |
| 6830 | } |
| 6831 | } |
| 6832 | |
| 6833 | /** |
| 6834 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6835 | * {@link #PROTOCOL}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6836 | */ |
| 6837 | public static final int getProtocolLabelResource(int type) { |
| 6838 | switch (type) { |
| 6839 | case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim; |
| 6840 | case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn; |
| 6841 | case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo; |
| 6842 | case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype; |
| 6843 | case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq; |
| 6844 | case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk; |
| 6845 | case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq; |
| 6846 | case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber; |
| 6847 | case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting; |
| 6848 | default: return com.android.internal.R.string.imProtocolCustom; |
| 6849 | } |
| 6850 | } |
| 6851 | |
| 6852 | /** |
| 6853 | * Return a {@link CharSequence} that best describes the given |
| 6854 | * protocol, possibly substituting the given |
| 6855 | * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}. |
| 6856 | */ |
| 6857 | public static final CharSequence getProtocolLabel(Resources res, int type, |
| 6858 | CharSequence label) { |
| 6859 | if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6860 | return label; |
| 6861 | } else { |
| 6862 | final int labelRes = getProtocolLabelResource(type); |
| 6863 | return res.getText(labelRes); |
| 6864 | } |
| 6865 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6866 | } |
| 6867 | |
| 6868 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6869 | * <p> |
| 6870 | * A data kind representing an organization. |
| 6871 | * </p> |
| 6872 | * <p> |
| 6873 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6874 | * well as the following aliases. |
| 6875 | * </p> |
| 6876 | * <h2>Column aliases</h2> |
| 6877 | * <table class="jd-sumtable"> |
| 6878 | * <tr> |
| 6879 | * <th>Type</th> |
| 6880 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6881 | * </tr> |
| 6882 | * <tr> |
| 6883 | * <td>String</td> |
| 6884 | * <td>{@link #COMPANY}</td> |
| 6885 | * <td>{@link #DATA1}</td> |
| 6886 | * <td></td> |
| 6887 | * </tr> |
| 6888 | * <tr> |
| 6889 | * <td>int</td> |
| 6890 | * <td>{@link #TYPE}</td> |
| 6891 | * <td>{@link #DATA2}</td> |
| 6892 | * <td>Allowed values are: |
| 6893 | * <p> |
| 6894 | * <ul> |
| 6895 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6896 | * <li>{@link #TYPE_WORK}</li> |
| 6897 | * <li>{@link #TYPE_OTHER}</li> |
| 6898 | * </ul> |
| 6899 | * </p> |
| 6900 | * </td> |
| 6901 | * </tr> |
| 6902 | * <tr> |
| 6903 | * <td>String</td> |
| 6904 | * <td>{@link #LABEL}</td> |
| 6905 | * <td>{@link #DATA3}</td> |
| 6906 | * <td></td> |
| 6907 | * </tr> |
| 6908 | * <tr> |
| 6909 | * <td>String</td> |
| 6910 | * <td>{@link #TITLE}</td> |
| 6911 | * <td>{@link #DATA4}</td> |
| 6912 | * <td></td> |
| 6913 | * </tr> |
| 6914 | * <tr> |
| 6915 | * <td>String</td> |
| 6916 | * <td>{@link #DEPARTMENT}</td> |
| 6917 | * <td>{@link #DATA5}</td> |
| 6918 | * <td></td> |
| 6919 | * </tr> |
| 6920 | * <tr> |
| 6921 | * <td>String</td> |
| 6922 | * <td>{@link #JOB_DESCRIPTION}</td> |
| 6923 | * <td>{@link #DATA6}</td> |
| 6924 | * <td></td> |
| 6925 | * </tr> |
| 6926 | * <tr> |
| 6927 | * <td>String</td> |
| 6928 | * <td>{@link #SYMBOL}</td> |
| 6929 | * <td>{@link #DATA7}</td> |
| 6930 | * <td></td> |
| 6931 | * </tr> |
| 6932 | * <tr> |
| 6933 | * <td>String</td> |
| 6934 | * <td>{@link #PHONETIC_NAME}</td> |
| 6935 | * <td>{@link #DATA8}</td> |
| 6936 | * <td></td> |
| 6937 | * </tr> |
| 6938 | * <tr> |
| 6939 | * <td>String</td> |
| 6940 | * <td>{@link #OFFICE_LOCATION}</td> |
| 6941 | * <td>{@link #DATA9}</td> |
| 6942 | * <td></td> |
| 6943 | * </tr> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 6944 | * <tr> |
| 6945 | * <td>String</td> |
| 6946 | * <td>PHONETIC_NAME_STYLE</td> |
| 6947 | * <td>{@link #DATA10}</td> |
| 6948 | * <td></td> |
| 6949 | * </tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6950 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6951 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6952 | public static final class Organization implements DataColumnsWithJoins, CommonColumns, |
| 6953 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6954 | /** |
| 6955 | * This utility class cannot be instantiated |
| 6956 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6957 | private Organization() {} |
| 6958 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6959 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6960 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; |
| 6961 | |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6962 | public static final int TYPE_WORK = 1; |
| 6963 | public static final int TYPE_OTHER = 2; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6964 | |
| 6965 | /** |
| 6966 | * The company as the user entered it. |
| 6967 | * <P>Type: TEXT</P> |
| 6968 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6969 | public static final String COMPANY = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6970 | |
| 6971 | /** |
| 6972 | * The position title at this company as the user entered it. |
| 6973 | * <P>Type: TEXT</P> |
| 6974 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6975 | public static final String TITLE = DATA4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6976 | |
| 6977 | /** |
| 6978 | * The department at this company as the user entered it. |
| 6979 | * <P>Type: TEXT</P> |
| 6980 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6981 | public static final String DEPARTMENT = DATA5; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6982 | |
| 6983 | /** |
| 6984 | * The job description at this company as the user entered it. |
| 6985 | * <P>Type: TEXT</P> |
| 6986 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6987 | public static final String JOB_DESCRIPTION = DATA6; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6988 | |
| 6989 | /** |
| 6990 | * The symbol of this company as the user entered it. |
| 6991 | * <P>Type: TEXT</P> |
| 6992 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6993 | public static final String SYMBOL = DATA7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6994 | |
| 6995 | /** |
| 6996 | * The phonetic name of this company as the user entered it. |
| 6997 | * <P>Type: TEXT</P> |
| 6998 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6999 | public static final String PHONETIC_NAME = DATA8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 7000 | |
| 7001 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 7002 | * The office location of this organization. |
| 7003 | * <P>Type: TEXT</P> |
| 7004 | */ |
| 7005 | public static final String OFFICE_LOCATION = DATA9; |
| 7006 | |
| 7007 | /** |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 7008 | * The alphabet used for capturing the phonetic name. |
| 7009 | * See {@link ContactsContract.PhoneticNameStyle}. |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 7010 | */ |
| 7011 | public static final String PHONETIC_NAME_STYLE = DATA10; |
| 7012 | |
| 7013 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 7014 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 7015 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 7016 | */ |
| 7017 | public static final int getTypeLabelResource(int type) { |
| 7018 | switch (type) { |
| 7019 | case TYPE_WORK: return com.android.internal.R.string.orgTypeWork; |
| 7020 | case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther; |
| 7021 | default: return com.android.internal.R.string.orgTypeCustom; |
| 7022 | } |
| 7023 | } |
| 7024 | |
| 7025 | /** |
| 7026 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 7027 | * possibly substituting the given {@link #LABEL} value |
| 7028 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 7029 | */ |
| 7030 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 7031 | CharSequence label) { |
| 7032 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 7033 | return label; |
| 7034 | } else { |
| 7035 | final int labelRes = getTypeLabelResource(type); |
| 7036 | return res.getText(labelRes); |
| 7037 | } |
| 7038 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7039 | } |
| 7040 | |
| 7041 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7042 | * <p> |
| 7043 | * A data kind representing a relation. |
| 7044 | * </p> |
| 7045 | * <p> |
| 7046 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7047 | * well as the following aliases. |
| 7048 | * </p> |
| 7049 | * <h2>Column aliases</h2> |
| 7050 | * <table class="jd-sumtable"> |
| 7051 | * <tr> |
| 7052 | * <th>Type</th> |
| 7053 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7054 | * </tr> |
| 7055 | * <tr> |
| 7056 | * <td>String</td> |
| 7057 | * <td>{@link #NAME}</td> |
| 7058 | * <td>{@link #DATA1}</td> |
| 7059 | * <td></td> |
| 7060 | * </tr> |
| 7061 | * <tr> |
| 7062 | * <td>int</td> |
| 7063 | * <td>{@link #TYPE}</td> |
| 7064 | * <td>{@link #DATA2}</td> |
| 7065 | * <td>Allowed values are: |
| 7066 | * <p> |
| 7067 | * <ul> |
| 7068 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 7069 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 7070 | * <li>{@link #TYPE_BROTHER}</li> |
| 7071 | * <li>{@link #TYPE_CHILD}</li> |
| 7072 | * <li>{@link #TYPE_DOMESTIC_PARTNER}</li> |
| 7073 | * <li>{@link #TYPE_FATHER}</li> |
| 7074 | * <li>{@link #TYPE_FRIEND}</li> |
| 7075 | * <li>{@link #TYPE_MANAGER}</li> |
| 7076 | * <li>{@link #TYPE_MOTHER}</li> |
| 7077 | * <li>{@link #TYPE_PARENT}</li> |
| 7078 | * <li>{@link #TYPE_PARTNER}</li> |
| 7079 | * <li>{@link #TYPE_REFERRED_BY}</li> |
| 7080 | * <li>{@link #TYPE_RELATIVE}</li> |
| 7081 | * <li>{@link #TYPE_SISTER}</li> |
| 7082 | * <li>{@link #TYPE_SPOUSE}</li> |
| 7083 | * </ul> |
| 7084 | * </p> |
| 7085 | * </td> |
| 7086 | * </tr> |
| 7087 | * <tr> |
| 7088 | * <td>String</td> |
| 7089 | * <td>{@link #LABEL}</td> |
| 7090 | * <td>{@link #DATA3}</td> |
| 7091 | * <td></td> |
| 7092 | * </tr> |
| 7093 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7094 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7095 | public static final class Relation implements DataColumnsWithJoins, CommonColumns, |
| 7096 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7097 | /** |
| 7098 | * This utility class cannot be instantiated |
| 7099 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7100 | private Relation() {} |
| 7101 | |
| 7102 | /** MIME type used when storing this in data table. */ |
| 7103 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; |
| 7104 | |
| 7105 | public static final int TYPE_ASSISTANT = 1; |
| 7106 | public static final int TYPE_BROTHER = 2; |
| 7107 | public static final int TYPE_CHILD = 3; |
| 7108 | public static final int TYPE_DOMESTIC_PARTNER = 4; |
| 7109 | public static final int TYPE_FATHER = 5; |
| 7110 | public static final int TYPE_FRIEND = 6; |
| 7111 | public static final int TYPE_MANAGER = 7; |
| 7112 | public static final int TYPE_MOTHER = 8; |
| 7113 | public static final int TYPE_PARENT = 9; |
| 7114 | public static final int TYPE_PARTNER = 10; |
| 7115 | public static final int TYPE_REFERRED_BY = 11; |
| 7116 | public static final int TYPE_RELATIVE = 12; |
| 7117 | public static final int TYPE_SISTER = 13; |
| 7118 | public static final int TYPE_SPOUSE = 14; |
| 7119 | |
| 7120 | /** |
| 7121 | * The name of the relative as the user entered it. |
| 7122 | * <P>Type: TEXT</P> |
| 7123 | */ |
| 7124 | public static final String NAME = DATA; |
Daniel Lehmann | 1fb39f0 | 2010-10-28 13:40:38 -0700 | [diff] [blame] | 7125 | |
| 7126 | /** |
| 7127 | * Return the string resource that best describes the given |
| 7128 | * {@link #TYPE}. Will always return a valid resource. |
| 7129 | */ |
| 7130 | public static final int getTypeLabelResource(int type) { |
| 7131 | switch (type) { |
| 7132 | case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant; |
| 7133 | case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother; |
| 7134 | case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild; |
| 7135 | case TYPE_DOMESTIC_PARTNER: |
| 7136 | return com.android.internal.R.string.relationTypeDomesticPartner; |
| 7137 | case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather; |
| 7138 | case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend; |
| 7139 | case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager; |
| 7140 | case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother; |
| 7141 | case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent; |
| 7142 | case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner; |
| 7143 | case TYPE_REFERRED_BY: |
| 7144 | return com.android.internal.R.string.relationTypeReferredBy; |
| 7145 | case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative; |
| 7146 | case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister; |
| 7147 | case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse; |
| 7148 | default: return com.android.internal.R.string.orgTypeCustom; |
| 7149 | } |
| 7150 | } |
| 7151 | |
| 7152 | /** |
| 7153 | * Return a {@link CharSequence} that best describes the given type, |
| 7154 | * possibly substituting the given {@link #LABEL} value |
| 7155 | * for {@link #TYPE_CUSTOM}. |
| 7156 | */ |
| 7157 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 7158 | CharSequence label) { |
| 7159 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 7160 | return label; |
| 7161 | } else { |
| 7162 | final int labelRes = getTypeLabelResource(type); |
| 7163 | return res.getText(labelRes); |
| 7164 | } |
| 7165 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7166 | } |
| 7167 | |
| 7168 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7169 | * <p> |
| 7170 | * A data kind representing an event. |
| 7171 | * </p> |
| 7172 | * <p> |
| 7173 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7174 | * well as the following aliases. |
| 7175 | * </p> |
| 7176 | * <h2>Column aliases</h2> |
| 7177 | * <table class="jd-sumtable"> |
| 7178 | * <tr> |
| 7179 | * <th>Type</th> |
| 7180 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7181 | * </tr> |
| 7182 | * <tr> |
| 7183 | * <td>String</td> |
| 7184 | * <td>{@link #START_DATE}</td> |
| 7185 | * <td>{@link #DATA1}</td> |
| 7186 | * <td></td> |
| 7187 | * </tr> |
| 7188 | * <tr> |
| 7189 | * <td>int</td> |
| 7190 | * <td>{@link #TYPE}</td> |
| 7191 | * <td>{@link #DATA2}</td> |
| 7192 | * <td>Allowed values are: |
| 7193 | * <p> |
| 7194 | * <ul> |
| 7195 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 7196 | * <li>{@link #TYPE_ANNIVERSARY}</li> |
| 7197 | * <li>{@link #TYPE_OTHER}</li> |
| 7198 | * <li>{@link #TYPE_BIRTHDAY}</li> |
| 7199 | * </ul> |
| 7200 | * </p> |
| 7201 | * </td> |
| 7202 | * </tr> |
| 7203 | * <tr> |
| 7204 | * <td>String</td> |
| 7205 | * <td>{@link #LABEL}</td> |
| 7206 | * <td>{@link #DATA3}</td> |
| 7207 | * <td></td> |
| 7208 | * </tr> |
| 7209 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7210 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7211 | public static final class Event implements DataColumnsWithJoins, CommonColumns, |
| 7212 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7213 | /** |
| 7214 | * This utility class cannot be instantiated |
| 7215 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7216 | private Event() {} |
| 7217 | |
| 7218 | /** MIME type used when storing this in data table. */ |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 7219 | 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] | 7220 | |
| 7221 | public static final int TYPE_ANNIVERSARY = 1; |
| 7222 | public static final int TYPE_OTHER = 2; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 7223 | public static final int TYPE_BIRTHDAY = 3; |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 7224 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7225 | /** |
| 7226 | * The event start date as the user entered it. |
| 7227 | * <P>Type: TEXT</P> |
| 7228 | */ |
| 7229 | public static final String START_DATE = DATA; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 7230 | |
| 7231 | /** |
| 7232 | * Return the string resource that best describes the given |
| 7233 | * {@link #TYPE}. Will always return a valid resource. |
| 7234 | */ |
| 7235 | public static int getTypeResource(Integer type) { |
| 7236 | if (type == null) { |
| 7237 | return com.android.internal.R.string.eventTypeOther; |
| 7238 | } |
| 7239 | switch (type) { |
| 7240 | case TYPE_ANNIVERSARY: |
| 7241 | return com.android.internal.R.string.eventTypeAnniversary; |
| 7242 | case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday; |
| 7243 | case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther; |
Daniel Lehmann | dd384a7 | 2010-11-01 18:40:50 -0700 | [diff] [blame] | 7244 | default: return com.android.internal.R.string.eventTypeCustom; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 7245 | } |
| 7246 | } |
Paul Soulos | 6b2dd63 | 2014-07-24 17:17:42 -0700 | [diff] [blame] | 7247 | |
| 7248 | /** |
| 7249 | * Return a {@link CharSequence} that best describes the given type, |
| 7250 | * possibly substituting the given {@link #LABEL} value |
| 7251 | * for {@link #TYPE_CUSTOM}. |
| 7252 | */ |
| 7253 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 7254 | CharSequence label) { |
| 7255 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 7256 | return label; |
| 7257 | } else { |
| 7258 | final int labelRes = getTypeResource(type); |
| 7259 | return res.getText(labelRes); |
| 7260 | } |
| 7261 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7262 | } |
| 7263 | |
| 7264 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7265 | * <p> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 7266 | * A data kind representing a photo for the contact. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7267 | * </p> |
| 7268 | * <p> |
| 7269 | * Some sync adapters will choose to download photos in a separate |
| 7270 | * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1} |
| 7271 | * through {@link ContactsContract.Data#SYNC4} to store temporary |
| 7272 | * data, e.g. the image URL or ID, state of download, server-side version |
| 7273 | * of the image. It is allowed for the {@link #PHOTO} to be null. |
| 7274 | * </p> |
| 7275 | * <p> |
| 7276 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7277 | * well as the following aliases. |
| 7278 | * </p> |
| 7279 | * <h2>Column aliases</h2> |
| 7280 | * <table class="jd-sumtable"> |
| 7281 | * <tr> |
| 7282 | * <th>Type</th> |
| 7283 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7284 | * </tr> |
| 7285 | * <tr> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 7286 | * <td>NUMBER</td> |
| 7287 | * <td>{@link #PHOTO_FILE_ID}</td> |
| 7288 | * <td>{@link #DATA14}</td> |
| 7289 | * <td>ID of the hi-res photo file.</td> |
| 7290 | * </tr> |
| 7291 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7292 | * <td>BLOB</td> |
| 7293 | * <td>{@link #PHOTO}</td> |
| 7294 | * <td>{@link #DATA15}</td> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 7295 | * <td>By convention, binary data is stored in DATA15. The thumbnail of the |
| 7296 | * photo is stored in this column.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7297 | * </tr> |
| 7298 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7299 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7300 | public static final class Photo implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7301 | /** |
| 7302 | * This utility class cannot be instantiated |
| 7303 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7304 | private Photo() {} |
| 7305 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7306 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7307 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; |
| 7308 | |
| 7309 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 7310 | * Photo file ID for the display photo of the raw contact. |
| 7311 | * See {@link ContactsContract.DisplayPhoto}. |
| 7312 | * <p> |
| 7313 | * Type: NUMBER |
| 7314 | */ |
| 7315 | public static final String PHOTO_FILE_ID = DATA14; |
| 7316 | |
| 7317 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 7318 | * 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] | 7319 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7320 | * <p> |
| 7321 | * Type: BLOB |
| 7322 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7323 | public static final String PHOTO = DATA15; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7324 | } |
| 7325 | |
| 7326 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7327 | * <p> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7328 | * Notes about the contact. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7329 | * </p> |
| 7330 | * <p> |
| 7331 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7332 | * well as the following aliases. |
| 7333 | * </p> |
| 7334 | * <h2>Column aliases</h2> |
| 7335 | * <table class="jd-sumtable"> |
| 7336 | * <tr> |
| 7337 | * <th>Type</th> |
| 7338 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7339 | * </tr> |
| 7340 | * <tr> |
| 7341 | * <td>String</td> |
| 7342 | * <td>{@link #NOTE}</td> |
| 7343 | * <td>{@link #DATA1}</td> |
| 7344 | * <td></td> |
| 7345 | * </tr> |
| 7346 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7347 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7348 | public static final class Note implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7349 | /** |
| 7350 | * This utility class cannot be instantiated |
| 7351 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7352 | private Note() {} |
| 7353 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7354 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7355 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; |
| 7356 | |
| 7357 | /** |
| 7358 | * The note text. |
| 7359 | * <P>Type: TEXT</P> |
| 7360 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7361 | public static final String NOTE = DATA1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7362 | } |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 7363 | |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 7364 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7365 | * <p> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7366 | * Group Membership. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7367 | * </p> |
| 7368 | * <p> |
| 7369 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7370 | * well as the following aliases. |
| 7371 | * </p> |
| 7372 | * <h2>Column aliases</h2> |
| 7373 | * <table class="jd-sumtable"> |
| 7374 | * <tr> |
| 7375 | * <th>Type</th> |
| 7376 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7377 | * </tr> |
| 7378 | * <tr> |
| 7379 | * <td>long</td> |
| 7380 | * <td>{@link #GROUP_ROW_ID}</td> |
| 7381 | * <td>{@link #DATA1}</td> |
| 7382 | * <td></td> |
| 7383 | * </tr> |
| 7384 | * <tr> |
| 7385 | * <td>String</td> |
| 7386 | * <td>{@link #GROUP_SOURCE_ID}</td> |
| 7387 | * <td>none</td> |
| 7388 | * <td> |
| 7389 | * <p> |
| 7390 | * The sourceid of the group that this group membership refers to. |
| 7391 | * Exactly one of this or {@link #GROUP_ROW_ID} must be set when |
| 7392 | * inserting a row. |
| 7393 | * </p> |
| 7394 | * <p> |
| 7395 | * If this field is specified, the provider will first try to |
| 7396 | * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group |
| 7397 | * is found, it will use the corresponding row id. If the group is not |
| 7398 | * found, it will create one. |
| 7399 | * </td> |
| 7400 | * </tr> |
| 7401 | * </table> |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7402 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7403 | public static final class GroupMembership implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7404 | /** |
| 7405 | * This utility class cannot be instantiated |
| 7406 | */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7407 | private GroupMembership() {} |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7408 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7409 | /** MIME type used when storing this in data table. */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7410 | public static final String CONTENT_ITEM_TYPE = |
| 7411 | "vnd.android.cursor.item/group_membership"; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7412 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7413 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 7414 | * The row id of the group that this group membership refers to. Exactly one of |
| 7415 | * 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] | 7416 | * <P>Type: INTEGER</P> |
| 7417 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7418 | public static final String GROUP_ROW_ID = DATA1; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7419 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7420 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 7421 | * The sourceid of the group that this group membership refers to. Exactly one of |
| 7422 | * 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] | 7423 | * <P>Type: TEXT</P> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7424 | */ |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 7425 | public static final String GROUP_SOURCE_ID = "group_sourceid"; |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7426 | } |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7427 | |
| 7428 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7429 | * <p> |
| 7430 | * A data kind representing a website related to the contact. |
| 7431 | * </p> |
| 7432 | * <p> |
| 7433 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7434 | * well as the following aliases. |
| 7435 | * </p> |
| 7436 | * <h2>Column aliases</h2> |
| 7437 | * <table class="jd-sumtable"> |
| 7438 | * <tr> |
| 7439 | * <th>Type</th> |
| 7440 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7441 | * </tr> |
| 7442 | * <tr> |
| 7443 | * <td>String</td> |
| 7444 | * <td>{@link #URL}</td> |
| 7445 | * <td>{@link #DATA1}</td> |
| 7446 | * <td></td> |
| 7447 | * </tr> |
| 7448 | * <tr> |
| 7449 | * <td>int</td> |
| 7450 | * <td>{@link #TYPE}</td> |
| 7451 | * <td>{@link #DATA2}</td> |
| 7452 | * <td>Allowed values are: |
| 7453 | * <p> |
| 7454 | * <ul> |
| 7455 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 7456 | * <li>{@link #TYPE_HOMEPAGE}</li> |
| 7457 | * <li>{@link #TYPE_BLOG}</li> |
| 7458 | * <li>{@link #TYPE_PROFILE}</li> |
| 7459 | * <li>{@link #TYPE_HOME}</li> |
| 7460 | * <li>{@link #TYPE_WORK}</li> |
| 7461 | * <li>{@link #TYPE_FTP}</li> |
| 7462 | * <li>{@link #TYPE_OTHER}</li> |
| 7463 | * </ul> |
| 7464 | * </p> |
| 7465 | * </td> |
| 7466 | * </tr> |
| 7467 | * <tr> |
| 7468 | * <td>String</td> |
| 7469 | * <td>{@link #LABEL}</td> |
| 7470 | * <td>{@link #DATA3}</td> |
| 7471 | * <td></td> |
| 7472 | * </tr> |
| 7473 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7474 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7475 | public static final class Website implements DataColumnsWithJoins, CommonColumns, |
| 7476 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7477 | /** |
| 7478 | * This utility class cannot be instantiated |
| 7479 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7480 | private Website() {} |
| 7481 | |
| 7482 | /** MIME type used when storing this in data table. */ |
| 7483 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; |
| 7484 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7485 | public static final int TYPE_HOMEPAGE = 1; |
| 7486 | public static final int TYPE_BLOG = 2; |
| 7487 | public static final int TYPE_PROFILE = 3; |
| 7488 | public static final int TYPE_HOME = 4; |
| 7489 | public static final int TYPE_WORK = 5; |
| 7490 | public static final int TYPE_FTP = 6; |
| 7491 | public static final int TYPE_OTHER = 7; |
| 7492 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7493 | /** |
| 7494 | * The website URL string. |
| 7495 | * <P>Type: TEXT</P> |
| 7496 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7497 | public static final String URL = DATA; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7498 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7499 | |
| 7500 | /** |
| 7501 | * <p> |
| 7502 | * A data kind representing a SIP address for the contact. |
| 7503 | * </p> |
| 7504 | * <p> |
| 7505 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7506 | * well as the following aliases. |
| 7507 | * </p> |
| 7508 | * <h2>Column aliases</h2> |
| 7509 | * <table class="jd-sumtable"> |
| 7510 | * <tr> |
| 7511 | * <th>Type</th> |
| 7512 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7513 | * </tr> |
| 7514 | * <tr> |
| 7515 | * <td>String</td> |
| 7516 | * <td>{@link #SIP_ADDRESS}</td> |
| 7517 | * <td>{@link #DATA1}</td> |
| 7518 | * <td></td> |
| 7519 | * </tr> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 7520 | * <tr> |
| 7521 | * <td>int</td> |
| 7522 | * <td>{@link #TYPE}</td> |
| 7523 | * <td>{@link #DATA2}</td> |
| 7524 | * <td>Allowed values are: |
| 7525 | * <p> |
| 7526 | * <ul> |
| 7527 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 7528 | * <li>{@link #TYPE_HOME}</li> |
| 7529 | * <li>{@link #TYPE_WORK}</li> |
| 7530 | * <li>{@link #TYPE_OTHER}</li> |
| 7531 | * </ul> |
| 7532 | * </p> |
| 7533 | * </td> |
| 7534 | * </tr> |
| 7535 | * <tr> |
| 7536 | * <td>String</td> |
| 7537 | * <td>{@link #LABEL}</td> |
| 7538 | * <td>{@link #DATA3}</td> |
| 7539 | * <td></td> |
| 7540 | * </tr> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7541 | * </table> |
| 7542 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7543 | public static final class SipAddress implements DataColumnsWithJoins, CommonColumns, |
| 7544 | ContactCounts { |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7545 | /** |
| 7546 | * This utility class cannot be instantiated |
| 7547 | */ |
| 7548 | private SipAddress() {} |
| 7549 | |
| 7550 | /** MIME type used when storing this in data table. */ |
| 7551 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address"; |
| 7552 | |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 7553 | public static final int TYPE_HOME = 1; |
| 7554 | public static final int TYPE_WORK = 2; |
| 7555 | public static final int TYPE_OTHER = 3; |
| 7556 | |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7557 | /** |
| 7558 | * The SIP address. |
| 7559 | * <P>Type: TEXT</P> |
| 7560 | */ |
| 7561 | public static final String SIP_ADDRESS = DATA1; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 7562 | // ...and TYPE and LABEL come from the CommonColumns interface. |
| 7563 | |
| 7564 | /** |
| 7565 | * Return the string resource that best describes the given |
| 7566 | * {@link #TYPE}. Will always return a valid resource. |
| 7567 | */ |
| 7568 | public static final int getTypeLabelResource(int type) { |
| 7569 | switch (type) { |
| 7570 | case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome; |
| 7571 | case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork; |
| 7572 | case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther; |
| 7573 | default: return com.android.internal.R.string.sipAddressTypeCustom; |
| 7574 | } |
| 7575 | } |
| 7576 | |
| 7577 | /** |
| 7578 | * Return a {@link CharSequence} that best describes the given type, |
| 7579 | * possibly substituting the given {@link #LABEL} value |
| 7580 | * for {@link #TYPE_CUSTOM}. |
| 7581 | */ |
| 7582 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 7583 | CharSequence label) { |
| 7584 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 7585 | return label; |
| 7586 | } else { |
| 7587 | final int labelRes = getTypeLabelResource(type); |
| 7588 | return res.getText(labelRes); |
| 7589 | } |
| 7590 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7591 | } |
Fred Quintana | 4923f1d | 2011-08-05 15:58:17 -0700 | [diff] [blame] | 7592 | |
| 7593 | /** |
| 7594 | * A data kind representing an Identity related to the contact. |
| 7595 | * <p> |
| 7596 | * This can be used as a signal by the aggregator to combine raw contacts into |
| 7597 | * contacts, e.g. if two contacts have Identity rows with |
| 7598 | * the same NAMESPACE and IDENTITY values the aggregator can know that they refer |
| 7599 | * to the same person. |
| 7600 | * </p> |
| 7601 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7602 | public static final class Identity implements DataColumnsWithJoins, ContactCounts { |
Fred Quintana | 4923f1d | 2011-08-05 15:58:17 -0700 | [diff] [blame] | 7603 | /** |
| 7604 | * This utility class cannot be instantiated |
| 7605 | */ |
| 7606 | private Identity() {} |
| 7607 | |
| 7608 | /** MIME type used when storing this in data table. */ |
| 7609 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity"; |
| 7610 | |
| 7611 | /** |
| 7612 | * The identity string. |
| 7613 | * <P>Type: TEXT</P> |
| 7614 | */ |
| 7615 | public static final String IDENTITY = DataColumns.DATA1; |
| 7616 | |
| 7617 | /** |
| 7618 | * The namespace of the identity string, e.g. "com.google" |
| 7619 | * <P>Type: TEXT</P> |
| 7620 | */ |
| 7621 | public static final String NAMESPACE = DataColumns.DATA2; |
| 7622 | } |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7623 | |
| 7624 | /** |
| 7625 | * <p> |
| 7626 | * Convenient functionalities for "callable" data. Note that, this is NOT a separate data |
| 7627 | * kind. |
| 7628 | * </p> |
| 7629 | * <p> |
| 7630 | * This URI allows the ContactsProvider to return a unified result for "callable" data |
| 7631 | * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the |
| 7632 | * current examples for "callable", but may be expanded to the other types. |
| 7633 | * </p> |
| 7634 | * <p> |
| 7635 | * Each returned row may have a different MIMETYPE and thus different interpretation for |
| 7636 | * each column. For example the meaning for {@link Phone}'s type is different than |
| 7637 | * {@link SipAddress}'s. |
| 7638 | * </p> |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7639 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7640 | public static final class Callable implements DataColumnsWithJoins, CommonColumns, |
| 7641 | ContactCounts { |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7642 | /** |
| 7643 | * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only |
| 7644 | * phone numbers. |
| 7645 | */ |
| 7646 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 7647 | "callables"); |
| 7648 | /** |
| 7649 | * Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable |
| 7650 | * data. |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 7651 | * |
| 7652 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer |
| 7653 | * sorts results based on contacts frequency. For more information, see the |
| 7654 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 7655 | * page. |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7656 | */ |
| 7657 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 7658 | "filter"); |
Victor Chang | 3d47ceb | 2015-12-01 16:30:43 +0000 | [diff] [blame] | 7659 | |
| 7660 | /** |
| 7661 | * Similar to {@link Phone#ENTERPRISE_CONTENT_FILTER_URI}, but allows users to filter |
| 7662 | * callable data. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 7663 | * parameters, otherwise it will throw IllegalArgumentException. |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 7664 | * |
| 7665 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer |
| 7666 | * sorts results based on contacts frequency. For more information, see the |
| 7667 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 7668 | * page.</p> |
Victor Chang | 3d47ceb | 2015-12-01 16:30:43 +0000 | [diff] [blame] | 7669 | */ |
| 7670 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 7671 | CONTENT_URI, "filter_enterprise"); |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7672 | } |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 7673 | |
| 7674 | /** |
| 7675 | * A special class of data items, used to refer to types of data that can be used to attempt |
| 7676 | * to start communicating with a person ({@link Phone} and {@link Email}). Note that this |
| 7677 | * is NOT a separate data kind. |
| 7678 | * |
| 7679 | * This URI allows the ContactsProvider to return a unified result for data items that users |
| 7680 | * can use to initiate communications with another contact. {@link Phone} and {@link Email} |
| 7681 | * are the current data types in this category. |
| 7682 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7683 | public static final class Contactables implements DataColumnsWithJoins, CommonColumns, |
| 7684 | ContactCounts { |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 7685 | /** |
| 7686 | * The content:// style URI for these data items, which requests a directory of data |
| 7687 | * rows matching the selection criteria. |
| 7688 | */ |
| 7689 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 7690 | "contactables"); |
| 7691 | |
| 7692 | /** |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 7693 | * The content:// style URI for these data items, which allows for a query parameter |
| 7694 | * to be appended onto the end to filter for data items matching the query. |
| 7695 | * |
| 7696 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer |
| 7697 | * sorts results based on contacts frequency. For more information, see the |
| 7698 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 7699 | * page. |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 7700 | */ |
| 7701 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 7702 | Contactables.CONTENT_URI, "filter"); |
| 7703 | |
| 7704 | /** |
| 7705 | * A boolean parameter for {@link Data#CONTENT_URI}. |
| 7706 | * This specifies whether or not the returned data items should be filtered to show |
| 7707 | * data items belonging to visible contacts only. |
| 7708 | */ |
| 7709 | public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; |
| 7710 | } |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7711 | } |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7712 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7713 | /** |
| 7714 | * @see Groups |
| 7715 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 7716 | protected interface GroupsColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7717 | /** |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 7718 | * The data set within the account that this group belongs to. This allows |
| 7719 | * multiple sync adapters for the same account type to distinguish between |
| 7720 | * each others' group data. |
| 7721 | * |
| 7722 | * This is empty by default, and is completely optional. It only needs to |
| 7723 | * be populated if multiple sync adapters are entering distinct group data |
| 7724 | * for the same account type and account name. |
| 7725 | * <P>Type: TEXT</P> |
| 7726 | */ |
| 7727 | public static final String DATA_SET = "data_set"; |
| 7728 | |
| 7729 | /** |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 7730 | * A concatenation of the account type and data set (delimited by a forward |
| 7731 | * slash) - if the data set is empty, this will be the same as the account |
| 7732 | * type. For applications that need to be aware of the data set, this can |
| 7733 | * be used instead of account type to distinguish sets of data. This is |
| 7734 | * never intended to be used for specifying accounts. |
| 7735 | * @hide |
| 7736 | */ |
| 7737 | public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; |
| 7738 | |
| 7739 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7740 | * The display title of this group. |
| 7741 | * <p> |
| 7742 | * Type: TEXT |
| 7743 | */ |
| 7744 | public static final String TITLE = "title"; |
| 7745 | |
| 7746 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7747 | * The package name to use when creating {@link Resources} objects for |
| 7748 | * this group. This value is only designed for use when building user |
| 7749 | * interfaces, and should not be used to infer the owner. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7750 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7751 | public static final String RES_PACKAGE = "res_package"; |
| 7752 | |
| 7753 | /** |
| 7754 | * The display title of this group to load as a resource from |
| 7755 | * {@link #RES_PACKAGE}, which may be localized. |
| 7756 | * <P>Type: TEXT</P> |
| 7757 | */ |
| 7758 | public static final String TITLE_RES = "title_res"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7759 | |
| 7760 | /** |
Dmitri Plotnikov | 02c5b45 | 2009-07-22 15:13:08 -0700 | [diff] [blame] | 7761 | * Notes about the group. |
| 7762 | * <p> |
| 7763 | * Type: TEXT |
| 7764 | */ |
| 7765 | public static final String NOTES = "notes"; |
| 7766 | |
| 7767 | /** |
| 7768 | * The ID of this group if it is a System Group, i.e. a group that has a special meaning |
| 7769 | * to the sync adapter, null otherwise. |
| 7770 | * <P>Type: TEXT</P> |
| 7771 | */ |
| 7772 | public static final String SYSTEM_ID = "system_id"; |
| 7773 | |
| 7774 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7775 | * The total number of {@link Contacts} that have |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7776 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7777 | * present when querying {@link Groups#CONTENT_SUMMARY_URI}. |
| 7778 | * <p> |
| 7779 | * Type: INTEGER |
| 7780 | */ |
| 7781 | public static final String SUMMARY_COUNT = "summ_count"; |
| 7782 | |
| 7783 | /** |
Daisuke Miyakawa | 15dec39 | 2011-07-23 11:39:23 -0700 | [diff] [blame] | 7784 | * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}. |
| 7785 | * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}. |
| 7786 | * |
| 7787 | * @hide |
| 7788 | */ |
| 7789 | public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT = |
| 7790 | "return_group_count_per_account"; |
| 7791 | |
| 7792 | /** |
| 7793 | * The total number of groups of the account that a group belongs to. |
| 7794 | * This column is available only when the parameter |
| 7795 | * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in |
| 7796 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 7797 | * |
| 7798 | * For example, when the account "A" has two groups "group1" and "group2", and the account |
| 7799 | * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for |
| 7800 | * "group3" returns "1" for this column. |
| 7801 | * |
| 7802 | * Note: This counts only non-favorites, non-auto-add, and not deleted groups. |
| 7803 | * |
| 7804 | * Type: INTEGER |
| 7805 | * @hide |
| 7806 | */ |
| 7807 | public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account"; |
| 7808 | |
| 7809 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7810 | * The total number of {@link Contacts} that have both |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7811 | * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7812 | * Read-only value that is only present when querying |
| 7813 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 7814 | * <p> |
| 7815 | * Type: INTEGER |
| 7816 | */ |
| 7817 | public static final String SUMMARY_WITH_PHONES = "summ_phones"; |
| 7818 | |
| 7819 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7820 | * Flag indicating if the contacts belonging to this group should be |
| 7821 | * visible in any user interface. |
| 7822 | * <p> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7823 | * Type: INTEGER (boolean) |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7824 | */ |
| 7825 | public static final String GROUP_VISIBLE = "group_visible"; |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 7826 | |
| 7827 | /** |
| 7828 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 7829 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7830 | * called on a group, it is marked for deletion. The sync adaptor |
| 7831 | * deletes the group on the server and then calls ContactResolver.delete |
| 7832 | * once more, this time setting the the |
| 7833 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to |
| 7834 | * finalize the data removal. |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 7835 | * <P>Type: INTEGER</P> |
| 7836 | */ |
| 7837 | public static final String DELETED = "deleted"; |
Jeff Sharkey | 403d7ac | 2009-08-16 16:34:35 -0700 | [diff] [blame] | 7838 | |
| 7839 | /** |
| 7840 | * Whether this group should be synced if the SYNC_EVERYTHING settings |
| 7841 | * is false for this group's account. |
| 7842 | * <p> |
| 7843 | * Type: INTEGER (boolean) |
| 7844 | */ |
| 7845 | public static final String SHOULD_SYNC = "should_sync"; |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 7846 | |
| 7847 | /** |
| 7848 | * Any newly created contacts will automatically be added to groups that have this |
| 7849 | * flag set to true. |
| 7850 | * <p> |
| 7851 | * Type: INTEGER (boolean) |
| 7852 | */ |
| 7853 | public static final String AUTO_ADD = "auto_add"; |
| 7854 | |
| 7855 | /** |
| 7856 | * When a contacts is marked as a favorites it will be automatically added |
| 7857 | * to the groups that have this flag set, and when it is removed from favorites |
| 7858 | * it will be removed from these groups. |
| 7859 | * <p> |
| 7860 | * Type: INTEGER (boolean) |
| 7861 | */ |
| 7862 | public static final String FAVORITES = "favorites"; |
Dmitri Plotnikov | 4ccf33a | 2010-11-19 11:10:43 -0800 | [diff] [blame] | 7863 | |
| 7864 | /** |
| 7865 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 7866 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 7867 | * <P>Type: INTEGER</P> |
| 7868 | */ |
| 7869 | public static final String GROUP_IS_READ_ONLY = "group_is_read_only"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7870 | } |
| 7871 | |
| 7872 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7873 | * Constants for the groups table. Only per-account groups are supported. |
| 7874 | * <h2>Columns</h2> |
| 7875 | * <table class="jd-sumtable"> |
| 7876 | * <tr> |
| 7877 | * <th colspan='4'>Groups</th> |
| 7878 | * </tr> |
| 7879 | * <tr> |
| 7880 | * <td>long</td> |
| 7881 | * <td>{@link #_ID}</td> |
| 7882 | * <td>read-only</td> |
| 7883 | * <td>Row ID. Sync adapter should try to preserve row IDs during updates. |
| 7884 | * In other words, it would be a really bad idea to delete and reinsert a |
| 7885 | * group. A sync adapter should always do an update instead.</td> |
| 7886 | * </tr> |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 7887 | # <tr> |
| 7888 | * <td>String</td> |
| 7889 | * <td>{@link #DATA_SET}</td> |
| 7890 | * <td>read/write-once</td> |
| 7891 | * <td> |
| 7892 | * <p> |
| 7893 | * The data set within the account that this group belongs to. This allows |
| 7894 | * multiple sync adapters for the same account type to distinguish between |
| 7895 | * each others' group data. The combination of {@link #ACCOUNT_TYPE}, |
| 7896 | * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data |
| 7897 | * that is associated with a single sync adapter. |
| 7898 | * </p> |
| 7899 | * <p> |
| 7900 | * This is empty by default, and is completely optional. It only needs to |
| 7901 | * be populated if multiple sync adapters are entering distinct data for |
| 7902 | * the same account type and account name. |
| 7903 | * </p> |
| 7904 | * <p> |
| 7905 | * It should be set at the time the group is inserted and never changed |
| 7906 | * afterwards. |
| 7907 | * </p> |
| 7908 | * </td> |
| 7909 | * </tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7910 | * <tr> |
| 7911 | * <td>String</td> |
| 7912 | * <td>{@link #TITLE}</td> |
| 7913 | * <td>read/write</td> |
| 7914 | * <td>The display title of this group.</td> |
| 7915 | * </tr> |
| 7916 | * <tr> |
| 7917 | * <td>String</td> |
| 7918 | * <td>{@link #NOTES}</td> |
| 7919 | * <td>read/write</td> |
| 7920 | * <td>Notes about the group.</td> |
| 7921 | * </tr> |
| 7922 | * <tr> |
| 7923 | * <td>String</td> |
| 7924 | * <td>{@link #SYSTEM_ID}</td> |
| 7925 | * <td>read/write</td> |
| 7926 | * <td>The ID of this group if it is a System Group, i.e. a group that has a |
| 7927 | * special meaning to the sync adapter, null otherwise.</td> |
| 7928 | * </tr> |
| 7929 | * <tr> |
| 7930 | * <td>int</td> |
| 7931 | * <td>{@link #SUMMARY_COUNT}</td> |
| 7932 | * <td>read-only</td> |
| 7933 | * <td>The total number of {@link Contacts} that have |
| 7934 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value |
| 7935 | * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 7936 | * </tr> |
| 7937 | * <tr> |
| 7938 | * <td>int</td> |
| 7939 | * <td>{@link #SUMMARY_WITH_PHONES}</td> |
| 7940 | * <td>read-only</td> |
| 7941 | * <td>The total number of {@link Contacts} that have both |
| 7942 | * {@link CommonDataKinds.GroupMembership} in this group, and also have |
| 7943 | * phone numbers. Read-only value that is only present when querying |
| 7944 | * {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 7945 | * </tr> |
| 7946 | * <tr> |
| 7947 | * <td>int</td> |
| 7948 | * <td>{@link #GROUP_VISIBLE}</td> |
| 7949 | * <td>read-only</td> |
| 7950 | * <td>Flag indicating if the contacts belonging to this group should be |
| 7951 | * visible in any user interface. Allowed values: 0 and 1.</td> |
| 7952 | * </tr> |
| 7953 | * <tr> |
| 7954 | * <td>int</td> |
| 7955 | * <td>{@link #DELETED}</td> |
| 7956 | * <td>read/write</td> |
| 7957 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 7958 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 7959 | * called on a group, it is marked for deletion. The sync adaptor deletes |
| 7960 | * the group on the server and then calls ContactResolver.delete once more, |
| 7961 | * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER} |
| 7962 | * query parameter to finalize the data removal.</td> |
| 7963 | * </tr> |
| 7964 | * <tr> |
| 7965 | * <td>int</td> |
| 7966 | * <td>{@link #SHOULD_SYNC}</td> |
| 7967 | * <td>read/write</td> |
| 7968 | * <td>Whether this group should be synced if the SYNC_EVERYTHING settings |
| 7969 | * is false for this group's account.</td> |
| 7970 | * </tr> |
| 7971 | * </table> |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7972 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7973 | public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7974 | /** |
| 7975 | * This utility class cannot be instantiated |
| 7976 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7977 | private Groups() { |
| 7978 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7979 | |
| 7980 | /** |
| 7981 | * The content:// style URI for this table |
| 7982 | */ |
| 7983 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); |
| 7984 | |
| 7985 | /** |
| 7986 | * The content:// style URI for this table joined with details data from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7987 | * {@link ContactsContract.Data}. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7988 | */ |
| 7989 | public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 7990 | "groups_summary"); |
| 7991 | |
| 7992 | /** |
| 7993 | * The MIME type of a directory of groups. |
| 7994 | */ |
| 7995 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; |
| 7996 | |
| 7997 | /** |
| 7998 | * The MIME type of a single group. |
| 7999 | */ |
| 8000 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 8001 | |
| 8002 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 8003 | return new EntityIteratorImpl(cursor); |
| 8004 | } |
| 8005 | |
| 8006 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 8007 | public EntityIteratorImpl(Cursor cursor) { |
| 8008 | super(cursor); |
| 8009 | } |
| 8010 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 8011 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 8012 | public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { |
| 8013 | // we expect the cursor is already at the row we need to read from |
| 8014 | final ContentValues values = new ContentValues(); |
| 8015 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID); |
| 8016 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME); |
| 8017 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE); |
| 8018 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY); |
| 8019 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION); |
| 8020 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID); |
| 8021 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE); |
| 8022 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE); |
| 8023 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES); |
| 8024 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE); |
| 8025 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1); |
| 8026 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2); |
| 8027 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3); |
| 8028 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4); |
| 8029 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID); |
| 8030 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED); |
| 8031 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES); |
| 8032 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC); |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 8033 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES); |
| 8034 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 8035 | cursor.moveToNext(); |
| 8036 | return new Entity(values); |
| 8037 | } |
| 8038 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 8039 | } |
| 8040 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8041 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8042 | * <p> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8043 | * Constants for the contact aggregation exceptions table, which contains |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8044 | * aggregation rules overriding those used by automatic aggregation. This |
| 8045 | * type only supports query and update. Neither insert nor delete are |
| 8046 | * supported. |
| 8047 | * </p> |
| 8048 | * <h2>Columns</h2> |
| 8049 | * <table class="jd-sumtable"> |
| 8050 | * <tr> |
| 8051 | * <th colspan='4'>AggregationExceptions</th> |
| 8052 | * </tr> |
| 8053 | * <tr> |
| 8054 | * <td>int</td> |
| 8055 | * <td>{@link #TYPE}</td> |
| 8056 | * <td>read/write</td> |
| 8057 | * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER}, |
| 8058 | * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td> |
| 8059 | * </tr> |
| 8060 | * <tr> |
| 8061 | * <td>long</td> |
| 8062 | * <td>{@link #RAW_CONTACT_ID1}</td> |
| 8063 | * <td>read/write</td> |
| 8064 | * <td>A reference to the {@link RawContacts#_ID} of the raw contact that |
| 8065 | * the rule applies to.</td> |
| 8066 | * </tr> |
| 8067 | * <tr> |
| 8068 | * <td>long</td> |
| 8069 | * <td>{@link #RAW_CONTACT_ID2}</td> |
| 8070 | * <td>read/write</td> |
| 8071 | * <td>A reference to the other {@link RawContacts#_ID} of the raw contact |
| 8072 | * that the rule applies to.</td> |
| 8073 | * </tr> |
| 8074 | * </table> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8075 | */ |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 8076 | public static final class AggregationExceptions implements BaseColumns { |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8077 | /** |
| 8078 | * This utility class cannot be instantiated |
| 8079 | */ |
| 8080 | private AggregationExceptions() {} |
| 8081 | |
| 8082 | /** |
| 8083 | * The content:// style URI for this table |
| 8084 | */ |
| 8085 | public static final Uri CONTENT_URI = |
| 8086 | Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); |
| 8087 | |
| 8088 | /** |
| 8089 | * The MIME type of {@link #CONTENT_URI} providing a directory of data. |
| 8090 | */ |
| 8091 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; |
| 8092 | |
| 8093 | /** |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 8094 | * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception |
| 8095 | */ |
| 8096 | public static final String CONTENT_ITEM_TYPE = |
| 8097 | "vnd.android.cursor.item/aggregation_exception"; |
| 8098 | |
| 8099 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8100 | * 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] | 8101 | * {@link #TYPE_AUTOMATIC}. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8102 | * |
| 8103 | * <P>Type: INTEGER</P> |
| 8104 | */ |
| 8105 | public static final String TYPE = "type"; |
| 8106 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8107 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8108 | * Allows the provider to automatically decide whether the specified raw contacts should |
| 8109 | * be included in the same aggregate contact or not. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8110 | */ |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 8111 | public static final int TYPE_AUTOMATIC = 0; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8112 | |
| 8113 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8114 | * Makes sure that the specified raw contacts are included in the same |
| 8115 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 8116 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8117 | public static final int TYPE_KEEP_TOGETHER = 1; |
| 8118 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 8119 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8120 | * Makes sure that the specified raw contacts are NOT included in the same |
| 8121 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 8122 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8123 | public static final int TYPE_KEEP_SEPARATE = 2; |
| 8124 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 8125 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 8126 | * 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] | 8127 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8128 | public static final String RAW_CONTACT_ID1 = "raw_contact_id1"; |
| 8129 | |
| 8130 | /** |
| 8131 | * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule |
| 8132 | * applies to. |
| 8133 | */ |
| 8134 | public static final String RAW_CONTACT_ID2 = "raw_contact_id2"; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8135 | } |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 8136 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8137 | /** |
| 8138 | * @see Settings |
| 8139 | */ |
Dmitri Plotnikov | fe4c871 | 2009-10-14 00:28:48 -0700 | [diff] [blame] | 8140 | protected interface SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8141 | /** |
| 8142 | * The name of the account instance to which this row belongs. |
| 8143 | * <P>Type: TEXT</P> |
| 8144 | */ |
| 8145 | public static final String ACCOUNT_NAME = "account_name"; |
| 8146 | |
| 8147 | /** |
| 8148 | * The type of account to which this row belongs, which when paired with |
| 8149 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 8150 | * <P>Type: TEXT</P> |
| 8151 | */ |
| 8152 | public static final String ACCOUNT_TYPE = "account_type"; |
| 8153 | |
| 8154 | /** |
Dave Santoro | 7c4479f | 2011-09-07 16:52:27 -0700 | [diff] [blame] | 8155 | * The data set within the account that this row belongs to. This allows |
| 8156 | * multiple sync adapters for the same account type to distinguish between |
| 8157 | * each others' data. |
| 8158 | * |
| 8159 | * This is empty by default, and is completely optional. It only needs to |
| 8160 | * be populated if multiple sync adapters are entering distinct data for |
| 8161 | * the same account type and account name. |
| 8162 | * <P>Type: TEXT</P> |
| 8163 | */ |
| 8164 | public static final String DATA_SET = "data_set"; |
| 8165 | |
| 8166 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8167 | * Depending on the mode defined by the sync-adapter, this flag controls |
| 8168 | * the top-level sync behavior for this data source. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8169 | * <p> |
| 8170 | * Type: INTEGER (boolean) |
| 8171 | */ |
| 8172 | public static final String SHOULD_SYNC = "should_sync"; |
| 8173 | |
| 8174 | /** |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 8175 | * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership} |
Jeff Sharkey | a659744 | 2009-08-19 09:23:33 -0700 | [diff] [blame] | 8176 | * entries should be visible in any user interface. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8177 | * <p> |
| 8178 | * Type: INTEGER (boolean) |
| 8179 | */ |
| 8180 | public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8181 | |
| 8182 | /** |
Jeff Sharkey | 97bda4c | 2009-09-15 23:15:23 -0700 | [diff] [blame] | 8183 | * Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 8184 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 8185 | * unsynced. |
| 8186 | */ |
| 8187 | public static final String ANY_UNSYNCED = "any_unsynced"; |
| 8188 | |
| 8189 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8190 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 8191 | * no {@link CommonDataKinds.GroupMembership} entries. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8192 | * <p> |
| 8193 | * Type: INTEGER |
| 8194 | */ |
| 8195 | public static final String UNGROUPED_COUNT = "summ_count"; |
| 8196 | |
| 8197 | /** |
| 8198 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 8199 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8200 | * <p> |
| 8201 | * Type: INTEGER |
| 8202 | */ |
| 8203 | public static final String UNGROUPED_WITH_PHONES = "summ_phones"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8204 | } |
| 8205 | |
| 8206 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8207 | * <p> |
| 8208 | * Contacts-specific settings for various {@link Account}'s. |
| 8209 | * </p> |
| 8210 | * <h2>Columns</h2> |
| 8211 | * <table class="jd-sumtable"> |
| 8212 | * <tr> |
| 8213 | * <th colspan='4'>Settings</th> |
| 8214 | * </tr> |
| 8215 | * <tr> |
| 8216 | * <td>String</td> |
| 8217 | * <td>{@link #ACCOUNT_NAME}</td> |
| 8218 | * <td>read/write-once</td> |
| 8219 | * <td>The name of the account instance to which this row belongs.</td> |
| 8220 | * </tr> |
| 8221 | * <tr> |
| 8222 | * <td>String</td> |
| 8223 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 8224 | * <td>read/write-once</td> |
| 8225 | * <td>The type of account to which this row belongs, which when paired with |
| 8226 | * {@link #ACCOUNT_NAME} identifies a specific account.</td> |
| 8227 | * </tr> |
| 8228 | * <tr> |
| 8229 | * <td>int</td> |
| 8230 | * <td>{@link #SHOULD_SYNC}</td> |
| 8231 | * <td>read/write</td> |
| 8232 | * <td>Depending on the mode defined by the sync-adapter, this flag controls |
| 8233 | * the top-level sync behavior for this data source.</td> |
| 8234 | * </tr> |
| 8235 | * <tr> |
| 8236 | * <td>int</td> |
| 8237 | * <td>{@link #UNGROUPED_VISIBLE}</td> |
| 8238 | * <td>read/write</td> |
| 8239 | * <td>Flag indicating if contacts without any |
| 8240 | * {@link CommonDataKinds.GroupMembership} entries should be visible in any |
| 8241 | * user interface.</td> |
| 8242 | * </tr> |
| 8243 | * <tr> |
| 8244 | * <td>int</td> |
| 8245 | * <td>{@link #ANY_UNSYNCED}</td> |
| 8246 | * <td>read-only</td> |
| 8247 | * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 8248 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 8249 | * unsynced.</td> |
| 8250 | * </tr> |
| 8251 | * <tr> |
| 8252 | * <td>int</td> |
| 8253 | * <td>{@link #UNGROUPED_COUNT}</td> |
| 8254 | * <td>read-only</td> |
| 8255 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 8256 | * no {@link CommonDataKinds.GroupMembership} entries.</td> |
| 8257 | * </tr> |
| 8258 | * <tr> |
| 8259 | * <td>int</td> |
| 8260 | * <td>{@link #UNGROUPED_WITH_PHONES}</td> |
| 8261 | * <td>read-only</td> |
| 8262 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 8263 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone |
| 8264 | * numbers.</td> |
| 8265 | * </tr> |
| 8266 | * </table> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8267 | */ |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8268 | public static final class Settings implements SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8269 | /** |
| 8270 | * This utility class cannot be instantiated |
| 8271 | */ |
| 8272 | private Settings() { |
| 8273 | } |
| 8274 | |
| 8275 | /** |
| 8276 | * The content:// style URI for this table |
| 8277 | */ |
| 8278 | public static final Uri CONTENT_URI = |
| 8279 | Uri.withAppendedPath(AUTHORITY_URI, "settings"); |
| 8280 | |
| 8281 | /** |
| 8282 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 8283 | * settings. |
| 8284 | */ |
| 8285 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; |
| 8286 | |
| 8287 | /** |
| 8288 | * The MIME-type of {@link #CONTENT_URI} providing a single setting. |
| 8289 | */ |
| 8290 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8291 | } |
| 8292 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8293 | /** |
Brian Attwell | cc4b2f7 | 2015-01-08 14:58:15 -0800 | [diff] [blame] | 8294 | * API for inquiring about the general status of the provider. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8295 | */ |
| 8296 | public static final class ProviderStatus { |
| 8297 | |
| 8298 | /** |
| 8299 | * Not instantiable. |
| 8300 | */ |
| 8301 | private ProviderStatus() { |
| 8302 | } |
| 8303 | |
| 8304 | /** |
| 8305 | * The content:// style URI for this table. Requests to this URI can be |
| 8306 | * performed on the UI thread because they are always unblocking. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8307 | */ |
| 8308 | public static final Uri CONTENT_URI = |
| 8309 | Uri.withAppendedPath(AUTHORITY_URI, "provider_status"); |
| 8310 | |
| 8311 | /** |
| 8312 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 8313 | * settings. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8314 | */ |
| 8315 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status"; |
| 8316 | |
| 8317 | /** |
| 8318 | * An integer representing the current status of the provider. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8319 | */ |
| 8320 | public static final String STATUS = "status"; |
| 8321 | |
| 8322 | /** |
| 8323 | * Default status of the provider. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8324 | */ |
| 8325 | public static final int STATUS_NORMAL = 0; |
| 8326 | |
| 8327 | /** |
Brian Attwell | b36ad5d | 2015-05-28 19:25:21 -0700 | [diff] [blame] | 8328 | * The provider won't respond to queries. It is in the middle of a long running task, such |
| 8329 | * as a database upgrade or locale change. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8330 | */ |
Brian Attwell | b36ad5d | 2015-05-28 19:25:21 -0700 | [diff] [blame] | 8331 | public static final int STATUS_BUSY = 1; |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8332 | |
| 8333 | /** |
Dmitri Plotnikov | 37c3486 | 2010-11-12 16:12:53 -0800 | [diff] [blame] | 8334 | * The status that indicates that there are no accounts and no contacts |
| 8335 | * on the device. |
Dmitri Plotnikov | 37c3486 | 2010-11-12 16:12:53 -0800 | [diff] [blame] | 8336 | */ |
Brian Attwell | b36ad5d | 2015-05-28 19:25:21 -0700 | [diff] [blame] | 8337 | public static final int STATUS_EMPTY = 2; |
Makoto Onuki | 729a87b | 2017-01-11 13:40:06 -0800 | [diff] [blame] | 8338 | |
| 8339 | /** |
| 8340 | * Timestamp (milliseconds since epoch) of when the provider's database was created. |
| 8341 | * |
| 8342 | * <P>Type: long |
| 8343 | */ |
| 8344 | public static final String DATABASE_CREATION_TIMESTAMP = "database_creation_timestamp"; |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8345 | } |
| 8346 | |
| 8347 | /** |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8348 | * 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] | 8349 | * Contacts Provider. Applications can also clear all usage information. |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 8350 | * |
| 8351 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this class is obsolete. For |
| 8352 | * more information, see the |
| 8353 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 8354 | * page. |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8355 | * </p> |
Kevin Hufnagle | 18b799e | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 8356 | * |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8357 | * With the feedback, Contacts Provider may return more contextually appropriate results for |
| 8358 | * Data listing, typically supplied with |
| 8359 | * {@link ContactsContract.Contacts#CONTENT_FILTER_URI}, |
| 8360 | * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI}, |
| 8361 | * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit |
| 8362 | * from better ranked (sorted) lists in applications that show auto-complete list. |
| 8363 | * </p> |
| 8364 | * <p> |
| 8365 | * There is no guarantee for how this feedback is used, or even whether it is used at all. |
| 8366 | * The ranking algorithm will make best efforts to use the feedback data, but the exact |
| 8367 | * implementation, the storage data structures as well as the resulting sort order is device |
| 8368 | * and version specific and can change over time. |
| 8369 | * </p> |
| 8370 | * <p> |
| 8371 | * When updating usage information, users of this API need to use |
| 8372 | * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed |
| 8373 | * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as |
| 8374 | * its last path. They also need to append a query parameter to the Uri, to specify the type of |
| 8375 | * the communication, which enables the Contacts Provider to differentiate between kinds of |
| 8376 | * interactions using the same contact data field (for example a phone number can be used to |
| 8377 | * make phone calls or send SMS). |
| 8378 | * </p> |
| 8379 | * <p> |
| 8380 | * Selection and selectionArgs are ignored and must be set to null. To get data ids, |
| 8381 | * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)} |
| 8382 | * toward {@link Data#CONTENT_URI}. |
| 8383 | * </p> |
| 8384 | * <p> |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 8385 | * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive |
| 8386 | * integer when successful, and returns 0 if no contact with that id was found. |
| 8387 | * </p> |
| 8388 | * <p> |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8389 | * Example: |
| 8390 | * <pre> |
Daisuke Miyakawa | 52e3823 | 2011-06-14 10:56:46 -0700 | [diff] [blame] | 8391 | * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon() |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8392 | * .appendPath(TextUtils.join(",", dataIds)) |
Daisuke Miyakawa | 52e3823 | 2011-06-14 10:56:46 -0700 | [diff] [blame] | 8393 | * .appendQueryParameter(DataUsageFeedback.USAGE_TYPE, |
| 8394 | * DataUsageFeedback.USAGE_TYPE_CALL) |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8395 | * .build(); |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 8396 | * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0; |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8397 | * </pre> |
| 8398 | * </p> |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 8399 | * <p> |
| 8400 | * Applications can also clear all usage information with: |
| 8401 | * <pre> |
Makoto Onuki | 7ebbfd0 | 2012-04-13 12:56:42 -0700 | [diff] [blame] | 8402 | * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0; |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 8403 | * </pre> |
| 8404 | * </p> |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8405 | */ |
| 8406 | public static final class DataUsageFeedback { |
| 8407 | |
| 8408 | /** |
| 8409 | * The content:// style URI for sending usage feedback. |
| 8410 | * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}. |
| 8411 | */ |
| 8412 | public static final Uri FEEDBACK_URI = |
| 8413 | Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback"); |
| 8414 | |
| 8415 | /** |
Makoto Onuki | 7ebbfd0 | 2012-04-13 12:56:42 -0700 | [diff] [blame] | 8416 | * The content:// style URI for deleting all usage information. |
| 8417 | * Must be used with {@link ContentResolver#delete(Uri, String, String[])}. |
| 8418 | * The {@code where} and {@code selectionArgs} parameters are ignored. |
| 8419 | */ |
| 8420 | public static final Uri DELETE_USAGE_URI = |
| 8421 | Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage"); |
| 8422 | |
| 8423 | /** |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8424 | * <p> |
| 8425 | * Name for query parameter specifying the type of data usage. |
| 8426 | * </p> |
| 8427 | */ |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 8428 | public static final String USAGE_TYPE = "type"; |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8429 | |
| 8430 | /** |
| 8431 | * <p> |
| 8432 | * Type of usage for voice interaction, which includes phone call, voice chat, and |
| 8433 | * video chat. |
| 8434 | * </p> |
| 8435 | */ |
| 8436 | public static final String USAGE_TYPE_CALL = "call"; |
| 8437 | |
| 8438 | /** |
| 8439 | * <p> |
| 8440 | * Type of usage for text interaction involving longer messages, which includes email. |
| 8441 | * </p> |
| 8442 | */ |
| 8443 | public static final String USAGE_TYPE_LONG_TEXT = "long_text"; |
| 8444 | |
| 8445 | /** |
| 8446 | * <p> |
| 8447 | * Type of usage for text interaction involving shorter messages, which includes SMS, |
| 8448 | * text chat with email addresses. |
| 8449 | * </p> |
| 8450 | */ |
| 8451 | public static final String USAGE_TYPE_SHORT_TEXT = "short_text"; |
| 8452 | } |
| 8453 | |
| 8454 | /** |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8455 | * <p> |
Yorke Lee | cadbe4c | 2014-06-20 11:52:27 -0700 | [diff] [blame] | 8456 | * Contact-specific information about whether or not a contact has been pinned by the user |
| 8457 | * at a particular position within the system contact application's user interface. |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8458 | * </p> |
| 8459 | * |
| 8460 | * <p> |
| 8461 | * This pinning information can be used by individual applications to customize how |
| 8462 | * they order particular pinned contacts. For example, a Dialer application could |
| 8463 | * use pinned information to order user-pinned contacts in a top row of favorites. |
| 8464 | * </p> |
| 8465 | * |
| 8466 | * <p> |
| 8467 | * It is possible for two or more contacts to occupy the same pinned position (due |
| 8468 | * to aggregation and sync), so this pinning information should be used on a best-effort |
| 8469 | * basis to order contacts in-application rather than an absolute guide on where a contact |
| 8470 | * should be positioned. Contacts returned by the ContactsProvider will not be ordered based |
| 8471 | * on this information, so it is up to the client application to reorder these contacts within |
| 8472 | * their own UI adhering to (or ignoring as appropriate) information stored in the pinned |
| 8473 | * column. |
| 8474 | * </p> |
| 8475 | * |
| 8476 | * <p> |
| 8477 | * By default, unpinned contacts will have a pinned position of |
Yorke Lee | 7d24679 | 2014-07-25 10:05:55 -0700 | [diff] [blame] | 8478 | * {@link PinnedPositions#UNPINNED}. Client-provided pinned positions can be positive |
| 8479 | * integers that are greater than 1. |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8480 | * </p> |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8481 | */ |
| 8482 | public static final class PinnedPositions { |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8483 | /** |
Yorke Lee | 0e040b0 | 2014-06-18 15:02:44 -0700 | [diff] [blame] | 8484 | * The method to invoke in order to undemote a formerly demoted contact. The contact id of |
| 8485 | * the contact must be provided as an argument. If the contact was not previously demoted, |
| 8486 | * nothing will be done. |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 8487 | * @hide |
Yorke Lee | 0e040b0 | 2014-06-18 15:02:44 -0700 | [diff] [blame] | 8488 | */ |
| 8489 | public static final String UNDEMOTE_METHOD = "undemote"; |
| 8490 | |
| 8491 | /** |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 8492 | * Undemotes a formerly demoted contact. If the contact was not previously demoted, nothing |
| 8493 | * will be done. |
| 8494 | * |
| 8495 | * @param contentResolver to perform the undemote operation on. |
| 8496 | * @param contactId the id of the contact to undemote. |
| 8497 | */ |
| 8498 | public static void undemote(ContentResolver contentResolver, long contactId) { |
| 8499 | contentResolver.call(ContactsContract.AUTHORITY_URI, PinnedPositions.UNDEMOTE_METHOD, |
| 8500 | String.valueOf(contactId), null); |
| 8501 | } |
| 8502 | |
| 8503 | /** |
Yorke Lee | b31c8ab | 2014-08-26 17:13:02 -0700 | [diff] [blame] | 8504 | * Pins a contact at a provided position, or unpins a contact. |
| 8505 | * |
| 8506 | * @param contentResolver to perform the pinning operation on. |
| 8507 | * @param pinnedPosition the position to pin the contact at. To unpin a contact, use |
| 8508 | * {@link PinnedPositions#UNPINNED}. |
| 8509 | */ |
| 8510 | public static void pin( |
| 8511 | ContentResolver contentResolver, long contactId, int pinnedPosition) { |
| 8512 | final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId)); |
| 8513 | final ContentValues values = new ContentValues(); |
| 8514 | values.put(Contacts.PINNED, pinnedPosition); |
| 8515 | contentResolver.update(uri, values, null, null); |
| 8516 | } |
| 8517 | |
| 8518 | /** |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 8519 | * Default value for the pinned position of an unpinned contact. |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8520 | */ |
Yorke Lee | 7d24679 | 2014-07-25 10:05:55 -0700 | [diff] [blame] | 8521 | public static final int UNPINNED = 0; |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8522 | |
| 8523 | /** |
Yorke Lee | 3585e1a | 2013-07-31 18:53:31 -0700 | [diff] [blame] | 8524 | * Value of pinned position for a contact that a user has indicated should be considered |
| 8525 | * of the lowest priority. It is up to the client application to determine how to present |
| 8526 | * such a contact - for example all the way at the bottom of a contact list, or simply |
| 8527 | * just hidden from view. |
| 8528 | */ |
| 8529 | public static final int DEMOTED = -1; |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8530 | } |
| 8531 | |
| 8532 | /** |
Yorke Lee | f8aadf3 | 2014-06-23 17:51:16 -0700 | [diff] [blame] | 8533 | * 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] | 8534 | * a specific {@link Contacts} entry. |
| 8535 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8536 | public static final class QuickContact { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8537 | /** |
Yorke Lee | f8aadf3 | 2014-06-23 17:51:16 -0700 | [diff] [blame] | 8538 | * Action used to launch the system contacts application and bring up a QuickContact dialog |
| 8539 | * for the provided {@link Contacts} entry. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8540 | */ |
Jeff Sharkey | 0f3f60b | 2017-04-24 18:06:20 -0600 | [diff] [blame] | 8541 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
Evan Millar | 5042f7e | 2009-09-30 21:28:33 -0700 | [diff] [blame] | 8542 | public static final String ACTION_QUICK_CONTACT = |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 8543 | "android.provider.action.QUICK_CONTACT"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8544 | |
| 8545 | /** |
| 8546 | * Extra used to specify pivot dialog location in screen coordinates. |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 8547 | * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8548 | * @hide |
| 8549 | */ |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 8550 | @Deprecated |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 8551 | public static final String EXTRA_TARGET_RECT = "android.provider.extra.TARGET_RECT"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8552 | |
| 8553 | /** |
Brian Attwell | 029e681 | 2015-02-02 16:10:39 -0800 | [diff] [blame] | 8554 | * Extra used to specify size of QuickContacts. Not all implementations of QuickContacts |
| 8555 | * will respect this extra's value. |
| 8556 | * |
| 8557 | * One of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8558 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 8559 | public static final String EXTRA_MODE = "android.provider.extra.MODE"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8560 | |
| 8561 | /** |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8562 | * Extra used to specify which mimetype should be prioritized in the QuickContacts UI. |
| 8563 | * For example, passing the value {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can |
| 8564 | * cause phone numbers to be displayed more prominently in QuickContacts. |
| 8565 | */ |
| 8566 | public static final String EXTRA_PRIORITIZED_MIMETYPE |
| 8567 | = "android.provider.extra.PRIORITIZED_MIMETYPE"; |
| 8568 | |
| 8569 | /** |
Yorke Lee | f8aadf3 | 2014-06-23 17:51:16 -0700 | [diff] [blame] | 8570 | * Extra used to indicate a list of specific MIME-types to exclude and not display in the |
| 8571 | * QuickContacts dialog. Stored as a {@link String} array. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8572 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 8573 | public static final String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8574 | |
| 8575 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8576 | * Small QuickContact mode, usually presented with minimal actions. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8577 | */ |
| 8578 | public static final int MODE_SMALL = 1; |
| 8579 | |
| 8580 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8581 | * Medium QuickContact mode, includes actions and light summary describing |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8582 | * the {@link Contacts} entry being shown. This may include social |
| 8583 | * status and presence details. |
| 8584 | */ |
| 8585 | public static final int MODE_MEDIUM = 2; |
| 8586 | |
| 8587 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8588 | * Large QuickContact mode, includes actions and larger, card-like summary |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8589 | * of the {@link Contacts} entry being shown. This may include detailed |
| 8590 | * information, such as a photo. |
| 8591 | */ |
| 8592 | public static final int MODE_LARGE = 3; |
| 8593 | |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8594 | /** @hide */ |
| 8595 | public static final int MODE_DEFAULT = MODE_LARGE; |
| 8596 | |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8597 | /** |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8598 | * Constructs the QuickContacts intent with a view's rect. |
| 8599 | * @hide |
| 8600 | */ |
| 8601 | public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri, |
| 8602 | int mode, String[] excludeMimes) { |
| 8603 | // Find location and bounds of target view, adjusting based on the |
| 8604 | // assumed local density. |
| 8605 | final float appScale = context.getResources().getCompatibilityInfo().applicationScale; |
| 8606 | final int[] pos = new int[2]; |
| 8607 | target.getLocationOnScreen(pos); |
| 8608 | |
| 8609 | final Rect rect = new Rect(); |
| 8610 | rect.left = (int) (pos[0] * appScale + 0.5f); |
| 8611 | rect.top = (int) (pos[1] * appScale + 0.5f); |
| 8612 | rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); |
| 8613 | rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); |
| 8614 | |
| 8615 | return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes); |
| 8616 | } |
| 8617 | |
| 8618 | /** |
| 8619 | * Constructs the QuickContacts intent. |
| 8620 | * @hide |
| 8621 | */ |
Mathew Inwood | ba50311 | 2018-08-10 09:37:35 +0100 | [diff] [blame] | 8622 | @UnsupportedAppUsage |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8623 | public static Intent composeQuickContactsIntent(Context context, Rect target, |
| 8624 | Uri lookupUri, int mode, String[] excludeMimes) { |
| 8625 | // When launching from an Activiy, we don't want to start a new task, but otherwise |
| 8626 | // we *must* start a new task. (Otherwise startActivity() would crash.) |
| 8627 | Context actualContext = context; |
| 8628 | while ((actualContext instanceof ContextWrapper) |
| 8629 | && !(actualContext instanceof Activity)) { |
| 8630 | actualContext = ((ContextWrapper) actualContext).getBaseContext(); |
| 8631 | } |
Brian Attwell | 9ee6640 | 2014-08-11 22:42:26 -0700 | [diff] [blame] | 8632 | final int intentFlags = ((actualContext instanceof Activity) |
| 8633 | ? 0 : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK) |
| 8634 | // Workaround for b/16898764. Declaring singleTop in manifest doesn't work. |
| 8635 | | Intent.FLAG_ACTIVITY_SINGLE_TOP; |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8636 | |
| 8637 | // Launch pivot dialog through intent for now |
| 8638 | final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags); |
| 8639 | |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8640 | // NOTE: This logic and rebuildManagedQuickContactsIntent() must be in sync. |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8641 | intent.setData(lookupUri); |
| 8642 | intent.setSourceBounds(target); |
| 8643 | intent.putExtra(EXTRA_MODE, mode); |
| 8644 | intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); |
| 8645 | return intent; |
| 8646 | } |
| 8647 | |
| 8648 | /** |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8649 | * Constructs a QuickContacts intent based on an incoming intent for DevicePolicyManager |
| 8650 | * to strip off anything not necessary. |
Etan Cohen | 534a65d | 2015-05-01 11:03:24 -0700 | [diff] [blame] | 8651 | * |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8652 | * @hide |
| 8653 | */ |
| 8654 | public static Intent rebuildManagedQuickContactsIntent(String lookupKey, long contactId, |
Victor Chang | 97bdacc | 2016-01-21 22:24:11 +0000 | [diff] [blame] | 8655 | boolean isContactIdIgnored, long directoryId, Intent originalIntent) { |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8656 | final Intent intent = new Intent(ACTION_QUICK_CONTACT); |
| 8657 | // Rebuild the URI from a lookup key and a contact ID. |
Victor Chang | 97bdacc | 2016-01-21 22:24:11 +0000 | [diff] [blame] | 8658 | Uri uri = null; |
| 8659 | if (!TextUtils.isEmpty(lookupKey)) { |
| 8660 | uri = isContactIdIgnored |
| 8661 | ? Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey) |
| 8662 | : Contacts.getLookupUri(contactId, lookupKey); |
| 8663 | } |
Ricky Wai | 494b95d | 2015-11-20 16:07:15 +0000 | [diff] [blame] | 8664 | if (uri != null && directoryId != Directory.DEFAULT) { |
| 8665 | uri = uri.buildUpon().appendQueryParameter( |
| 8666 | ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(directoryId)).build(); |
| 8667 | } |
| 8668 | intent.setData(uri); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8669 | |
| 8670 | // Copy flags and always set NEW_TASK because it won't have a parent activity. |
| 8671 | intent.setFlags(originalIntent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK); |
| 8672 | |
| 8673 | // Copy extras. |
| 8674 | intent.setSourceBounds(originalIntent.getSourceBounds()); |
| 8675 | intent.putExtra(EXTRA_MODE, originalIntent.getIntExtra(EXTRA_MODE, MODE_DEFAULT)); |
| 8676 | intent.putExtra(EXTRA_EXCLUDE_MIMES, |
| 8677 | originalIntent.getStringArrayExtra(EXTRA_EXCLUDE_MIMES)); |
| 8678 | return intent; |
| 8679 | } |
| 8680 | |
| 8681 | |
| 8682 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8683 | * Trigger a dialog that lists the various methods of interacting with |
| 8684 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8685 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8686 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8687 | * |
| 8688 | * @param context The parent {@link Context} that may be used as the |
| 8689 | * parent for this dialog. |
| 8690 | * @param target Specific {@link View} from your layout that this dialog |
| 8691 | * should be centered around. In particular, if the dialog |
| 8692 | * has a "callout" arrow, it will be pointed and centered |
| 8693 | * around this {@link View}. |
Evan Millar | 772722e | 2009-09-30 22:24:07 -0700 | [diff] [blame] | 8694 | * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8695 | * {@link Uri} that describes a specific contact to feature |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 8696 | * in this dialog. A work lookup uri is supported here, |
| 8697 | * see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and |
| 8698 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8699 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 8700 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 8701 | * when supported. |
| 8702 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8703 | * to exclude when showing this dialog. For example, when |
| 8704 | * already viewing the contact details card, this can be used |
| 8705 | * to omit the details entry from the dialog. |
| 8706 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8707 | public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8708 | String[] excludeMimes) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8709 | // Trigger with obtained rectangle |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8710 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, |
| 8711 | excludeMimes); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8712 | ContactsInternal.startQuickContactWithErrorToast(context, intent); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8713 | } |
| 8714 | |
| 8715 | /** |
| 8716 | * Trigger a dialog that lists the various methods of interacting with |
| 8717 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8718 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8719 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8720 | * |
| 8721 | * @param context The parent {@link Context} that may be used as the |
| 8722 | * parent for this dialog. |
| 8723 | * @param target Specific {@link Rect} that this dialog should be |
| 8724 | * centered around, in screen coordinates. In particular, if |
| 8725 | * the dialog has a "callout" arrow, it will be pointed and |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 8726 | * centered around this {@link Rect}. If you are running at a |
| 8727 | * non-native density, you need to manually adjust using |
| 8728 | * {@link DisplayMetrics#density} before calling. |
Jeff Sharkey | 223bd7a | 2009-12-21 14:51:19 -0800 | [diff] [blame] | 8729 | * @param lookupUri A |
| 8730 | * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8731 | * {@link Uri} that describes a specific contact to feature |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 8732 | * in this dialog. A work lookup uri is supported here, |
| 8733 | * see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and |
| 8734 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8735 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 8736 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 8737 | * when supported. |
| 8738 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8739 | * to exclude when showing this dialog. For example, when |
| 8740 | * already viewing the contact details card, this can be used |
| 8741 | * to omit the details entry from the dialog. |
| 8742 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8743 | public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8744 | String[] excludeMimes) { |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8745 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, |
| 8746 | excludeMimes); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8747 | ContactsInternal.startQuickContactWithErrorToast(context, intent); |
Yorke Lee | 4fc601a | 2013-12-06 16:35:29 -0800 | [diff] [blame] | 8748 | } |
| 8749 | |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8750 | /** |
| 8751 | * Trigger a dialog that lists the various methods of interacting with |
| 8752 | * the requested {@link Contacts} entry. This may be based on available |
| 8753 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8754 | * include social status and presence details. |
| 8755 | * |
| 8756 | * @param context The parent {@link Context} that may be used as the |
| 8757 | * parent for this dialog. |
| 8758 | * @param target Specific {@link View} from your layout that this dialog |
| 8759 | * should be centered around. In particular, if the dialog |
| 8760 | * has a "callout" arrow, it will be pointed and centered |
| 8761 | * around this {@link View}. |
| 8762 | * @param lookupUri A |
| 8763 | * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
| 8764 | * {@link Uri} that describes a specific contact to feature |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 8765 | * in this dialog. A work lookup uri is supported here, |
| 8766 | * see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and |
| 8767 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8768 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8769 | * to exclude when showing this dialog. For example, when |
| 8770 | * already viewing the contact details card, this can be used |
| 8771 | * to omit the details entry from the dialog. |
| 8772 | * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI. |
| 8773 | * For example, passing the value |
| 8774 | * {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be |
| 8775 | * displayed more prominently in QuickContacts. |
| 8776 | */ |
| 8777 | public static void showQuickContact(Context context, View target, Uri lookupUri, |
| 8778 | String[] excludeMimes, String prioritizedMimeType) { |
| 8779 | // Use MODE_LARGE instead of accepting mode as a parameter. The different mode |
| 8780 | // values defined in ContactsContract only affect very old implementations |
| 8781 | // of QuickContacts. |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8782 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT, |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8783 | excludeMimes); |
| 8784 | intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8785 | ContactsInternal.startQuickContactWithErrorToast(context, intent); |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8786 | } |
| 8787 | |
| 8788 | /** |
| 8789 | * Trigger a dialog that lists the various methods of interacting with |
| 8790 | * the requested {@link Contacts} entry. This may be based on available |
| 8791 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8792 | * include social status and presence details. |
| 8793 | * |
| 8794 | * @param context The parent {@link Context} that may be used as the |
| 8795 | * parent for this dialog. |
| 8796 | * @param target Specific {@link Rect} that this dialog should be |
| 8797 | * centered around, in screen coordinates. In particular, if |
| 8798 | * the dialog has a "callout" arrow, it will be pointed and |
| 8799 | * centered around this {@link Rect}. If you are running at a |
| 8800 | * non-native density, you need to manually adjust using |
| 8801 | * {@link DisplayMetrics#density} before calling. |
| 8802 | * @param lookupUri A |
| 8803 | * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
| 8804 | * {@link Uri} that describes a specific contact to feature |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 8805 | * in this dialog. A work lookup uri is supported here, |
| 8806 | * see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and |
| 8807 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8808 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8809 | * to exclude when showing this dialog. For example, when |
| 8810 | * already viewing the contact details card, this can be used |
| 8811 | * to omit the details entry from the dialog. |
| 8812 | * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI. |
| 8813 | * For example, passing the value |
| 8814 | * {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be |
| 8815 | * displayed more prominently in QuickContacts. |
| 8816 | */ |
| 8817 | public static void showQuickContact(Context context, Rect target, Uri lookupUri, |
| 8818 | String[] excludeMimes, String prioritizedMimeType) { |
| 8819 | // Use MODE_LARGE instead of accepting mode as a parameter. The different mode |
| 8820 | // values defined in ContactsContract only affect very old implementations |
| 8821 | // of QuickContacts. |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8822 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT, |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8823 | excludeMimes); |
| 8824 | intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8825 | ContactsInternal.startQuickContactWithErrorToast(context, intent); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8826 | } |
| 8827 | } |
| 8828 | |
| 8829 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8830 | * Helper class for accessing full-size photos by photo file ID. |
| 8831 | * <p> |
| 8832 | * Usage example: |
| 8833 | * <dl> |
| 8834 | * <dt>Retrieving a full-size photo by photo file ID (see |
| 8835 | * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID}) |
| 8836 | * </dt> |
| 8837 | * <dd> |
| 8838 | * <pre> |
| 8839 | * public InputStream openDisplayPhoto(long photoFileId) { |
| 8840 | * Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey); |
| 8841 | * try { |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 8842 | * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor( |
| 8843 | * displayPhotoUri, "r"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8844 | * return fd.createInputStream(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 8845 | * } catch (IOException e) { |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8846 | * return null; |
| 8847 | * } |
| 8848 | * } |
| 8849 | * </pre> |
| 8850 | * </dd> |
| 8851 | * </dl> |
| 8852 | * </p> |
| 8853 | */ |
| 8854 | public static final class DisplayPhoto { |
| 8855 | /** |
| 8856 | * no public constructor since this is a utility class |
| 8857 | */ |
| 8858 | private DisplayPhoto() {} |
| 8859 | |
| 8860 | /** |
| 8861 | * The content:// style URI for this class, which allows access to full-size photos, |
| 8862 | * given a key. |
| 8863 | */ |
| 8864 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo"); |
| 8865 | |
| 8866 | /** |
| 8867 | * This URI allows the caller to query for the maximum dimensions of a display photo |
| 8868 | * or thumbnail. Requests to this URI can be performed on the UI thread because |
| 8869 | * they are always unblocking. |
| 8870 | */ |
| 8871 | public static final Uri CONTENT_MAX_DIMENSIONS_URI = |
| 8872 | Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions"); |
| 8873 | |
| 8874 | /** |
| 8875 | * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will |
| 8876 | * contain this column, populated with the maximum height and width (in pixels) |
| 8877 | * that will be stored for a display photo. Larger photos will be down-sized to |
| 8878 | * fit within a square of this many pixels. |
| 8879 | */ |
| 8880 | public static final String DISPLAY_MAX_DIM = "display_max_dim"; |
| 8881 | |
| 8882 | /** |
| 8883 | * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will |
| 8884 | * contain this column, populated with the height and width (in pixels) for photo |
| 8885 | * thumbnails. |
| 8886 | */ |
| 8887 | public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim"; |
| 8888 | } |
| 8889 | |
| 8890 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8891 | * Contains helper classes used to create or manage {@link android.content.Intent Intents} |
| 8892 | * that involve contacts. |
| 8893 | */ |
| 8894 | public static final class Intents { |
| 8895 | /** |
| 8896 | * This is the intent that is fired when a search suggestion is clicked on. |
| 8897 | */ |
| 8898 | public static final String SEARCH_SUGGESTION_CLICKED = |
| 8899 | "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; |
| 8900 | |
| 8901 | /** |
| 8902 | * This is the intent that is fired when a search suggestion for dialing a number |
| 8903 | * is clicked on. |
| 8904 | */ |
| 8905 | public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = |
| 8906 | "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; |
| 8907 | |
| 8908 | /** |
| 8909 | * This is the intent that is fired when a search suggestion for creating a contact |
| 8910 | * is clicked on. |
| 8911 | */ |
| 8912 | public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = |
| 8913 | "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; |
| 8914 | |
| 8915 | /** |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 8916 | * This is the intent that is fired when the contacts database is created. <p> The |
| 8917 | * READ_CONTACT permission is required to receive these broadcasts. |
Makoto Onuki | 729a87b | 2017-01-11 13:40:06 -0800 | [diff] [blame] | 8918 | * |
Makoto Onuki | 2a61537 | 2017-01-30 11:59:46 -0800 | [diff] [blame] | 8919 | * <p>Because this is an implicit broadcast, apps targeting Android O will no longer |
| 8920 | * receive this broadcast via a manifest broadcast receiver. (Broadcast receivers |
| 8921 | * registered at runtime with |
| 8922 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)} will still receive it.) |
| 8923 | * Instead, an app can use {@link ProviderStatus#DATABASE_CREATION_TIMESTAMP} to see if the |
| 8924 | * contacts database has been initialized when it starts. |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 8925 | */ |
| 8926 | public static final String CONTACTS_DATABASE_CREATED = |
| 8927 | "android.provider.Contacts.DATABASE_CREATED"; |
| 8928 | |
| 8929 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8930 | * Starts an Activity that lets the user pick a contact to attach an image to. |
| 8931 | * After picking the contact it launches the image cropper in face detection mode. |
| 8932 | */ |
| 8933 | public static final String ATTACH_IMAGE = |
| 8934 | "com.android.contacts.action.ATTACH_IMAGE"; |
| 8935 | |
| 8936 | /** |
Makoto Onuki | 85a01a6b | 2011-07-21 15:16:31 -0700 | [diff] [blame] | 8937 | * This is the intent that is fired when the user clicks the "invite to the network" button |
| 8938 | * on a contact. Only sent to an activity which is explicitly registered by a contact |
| 8939 | * provider which supports the "invite to the network" feature. |
| 8940 | * <p> |
| 8941 | * {@link Intent#getData()} contains the lookup URI for the contact. |
| 8942 | */ |
| 8943 | public static final String INVITE_CONTACT = |
| 8944 | "com.android.contacts.action.INVITE_CONTACT"; |
| 8945 | |
| 8946 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8947 | * Takes as input a data URI with a mailto: or tel: scheme. If a single |
| 8948 | * contact exists with the given data it will be shown. If no contact |
| 8949 | * exists, a dialog will ask the user if they want to create a new |
| 8950 | * contact with the provided details filled in. If multiple contacts |
| 8951 | * share the data the user will be prompted to pick which contact they |
| 8952 | * want to view. |
| 8953 | * <p> |
| 8954 | * For <code>mailto:</code> URIs, the scheme specific portion must be a |
| 8955 | * raw email address, such as one built using |
| 8956 | * {@link Uri#fromParts(String, String, String)}. |
| 8957 | * <p> |
| 8958 | * For <code>tel:</code> URIs, the scheme specific portion is compared |
| 8959 | * to existing numbers using the standard caller ID lookup algorithm. |
| 8960 | * The number must be properly encoded, for example using |
| 8961 | * {@link Uri#fromParts(String, String, String)}. |
| 8962 | * <p> |
| 8963 | * Any extras from the {@link Insert} class will be passed along to the |
| 8964 | * create activity if there are no contacts to show. |
| 8965 | * <p> |
| 8966 | * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip |
| 8967 | * prompting the user when the contact doesn't exist. |
| 8968 | */ |
| 8969 | public static final String SHOW_OR_CREATE_CONTACT = |
| 8970 | "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; |
| 8971 | |
| 8972 | /** |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 8973 | * Activity Action: Initiate a message to someone by voice. The message could be text, |
| 8974 | * audio, video or image(photo). This action supports messaging with a specific contact |
| 8975 | * regardless of the underlying messaging protocol used. |
| 8976 | * <p> |
| 8977 | * The action could be originated from the Voice Assistant as a voice interaction. In such |
| 8978 | * case, a receiving activity that supports {@link android.content.Intent#CATEGORY_VOICE} |
| 8979 | * could check return value of {@link android.app.Activity#isVoiceInteractionRoot} before |
| 8980 | * proceeding. By doing this check the activity verifies that the action indeed was |
| 8981 | * initiated by Voice Assistant and could send a message right away, without any further |
| 8982 | * input from the user. This allows for a smooth user experience when sending a message by |
| 8983 | * voice. Note: this activity must also support the {@link |
| 8984 | * android.content.Intent#CATEGORY_DEFAULT} so it can be found by {@link |
| 8985 | * android.service.voice.VoiceInteractionSession#startVoiceActivity}. |
| 8986 | * <p> |
| 8987 | * When the action was not initiated by Voice Assistant or when the receiving activity does |
Renat Aksitov | c8dd93d | 2016-05-01 16:31:28 -0700 | [diff] [blame] | 8988 | * not support {@link android.content.Intent#CATEGORY_VOICE}, the activity must confirm |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 8989 | * with the user before sending the message (because in this case it is unknown which app |
| 8990 | * sent the intent, it could be malicious). |
| 8991 | * <p> |
| 8992 | * To allow the Voice Assistant to help users with contacts disambiguation, the messaging |
Renat Aksitov | c8dd93d | 2016-05-01 16:31:28 -0700 | [diff] [blame] | 8993 | * app may choose to integrate with the Contacts Provider. You will need to specify a new |
| 8994 | * MIME type in order to store your app’s unique contact IDs and optional human readable |
| 8995 | * labels in the Data table. The Voice Assistant needs to know this MIME type and {@link |
| 8996 | * RawContacts#ACCOUNT_TYPE} that you are using in order to provide the smooth contact |
| 8997 | * disambiguation user experience. The following convention should be met when performing |
| 8998 | * such integration: |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 8999 | * <ul> |
Renat Aksitov | c8dd93d | 2016-05-01 16:31:28 -0700 | [diff] [blame] | 9000 | * <li>This activity should have a string meta-data field associated with it, {@link |
| 9001 | * #METADATA_ACCOUNT_TYPE}, which defines {@link RawContacts#ACCOUNT_TYPE} for your Contacts |
| 9002 | * Provider implementation. The account type should be globally unique, for example you can |
| 9003 | * use your app package name as the account type.</li> |
| 9004 | * <li>This activity should have a string meta-data field associated with it, {@link |
| 9005 | * #METADATA_MIMETYPE}, which defines {@link DataColumns#MIMETYPE} for your Contacts |
| 9006 | * Provider implementation. For example, you can use |
| 9007 | * "vnd.android.cursor.item/vnd.{$app_package_name}.profile" as MIME type.</li> |
| 9008 | * <li>When filling Data table row for METADATA_MIMETYPE, column {@link DataColumns#DATA1} |
| 9009 | * should store the unique contact ID as understood by the app. This value will be used in |
| 9010 | * the {@link #EXTRA_RECIPIENT_CONTACT_CHAT_ID}.</li> |
| 9011 | * <li>Optionally, when filling Data table row for METADATA_MIMETYPE, column {@link |
| 9012 | * DataColumns#DATA3} could store a human readable label for the ID. For example it could be |
| 9013 | * phone number or human readable username/user_id like "a_super_cool_user_name". This label |
| 9014 | * may be shown below the Contact Name by the Voice Assistant as the user completes the |
| 9015 | * voice action. If DATA3 is empty, the ID in DATA1 may be shown instead.</li> |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 9016 | * <li><em>Note: Do not use DATA3 to store the Contact Name. The Voice Assistant will |
| 9017 | * already get the Contact Name from the RawContact’s display_name.</em></li> |
| 9018 | * <li><em>Note: Some apps may choose to use phone number as the unique contact ID in DATA1. |
| 9019 | * If this applies to you and you’d like phone number to be shown below the Contact Name by |
| 9020 | * the Voice Assistant, then you may choose to leave DATA3 empty.</em></li> |
Renat Aksitov | 72ddba1 | 2016-02-20 19:16:46 -0800 | [diff] [blame] | 9021 | * <li><em>Note: If your app also uses DATA3 to display contact details in the Contacts App, |
| 9022 | * make sure it does not include prefix text such as "Message +<phone>" or "Free Message |
| 9023 | * +<phone>", etc. If you must show the prefix text in the Contacts App, please use a |
| 9024 | * different DATA# column, and update your contacts.xml to point to this new column. </em> |
| 9025 | * </li> |
| 9026 | * <li>Everytime the user sends a message to a contact, your app may choose to update the |
| 9027 | * {@link ContactOptionsColumns#TIMES_CONTACTED} entry through DataUsageFeedback class. |
| 9028 | * Doing this will allow Voice Assistant to bias speech recognition to contacts frequently |
| 9029 | * contacted, this is particularly useful for contact names that are hard to pronounce.</li> |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 9030 | * </ul> |
Renat Aksitov | c8dd93d | 2016-05-01 16:31:28 -0700 | [diff] [blame] | 9031 | * If the app chooses not to integrate with the Contacts Provider (in particular, when |
| 9032 | * either METADATA_ACCOUNT_TYPE or METADATA_MIMETYPE field is missing), Voice Assistant |
| 9033 | * will use existing phone number entries as contact ID's for such app. |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 9034 | * <p> |
| 9035 | * Input: {@link android.content.Intent#getType} is the MIME type of the data being sent. |
| 9036 | * The intent sender will always put the concrete mime type in the intent type, like |
| 9037 | * "text/plain" or "audio/wav" for example. If the MIME type is "text/plain", message to |
| 9038 | * sent will be provided via {@link android.content.Intent#EXTRA_TEXT} as a styled |
| 9039 | * CharSequence. Otherwise, the message content will be supplied through {@link |
| 9040 | * android.content.Intent#setClipData(ClipData)} as a content provider URI(s). In the latter |
| 9041 | * case, EXTRA_TEXT could still be supplied optionally; for example, for audio messages |
| 9042 | * ClipData will contain URI of a recording and EXTRA_TEXT could contain the text |
| 9043 | * transcription of this recording. |
| 9044 | * <p> |
| 9045 | * The message can have n recipients. The n-th recipient of the message will be provided as |
| 9046 | * n-th elements of {@link #EXTRA_RECIPIENT_CONTACT_URI}, {@link |
| 9047 | * #EXTRA_RECIPIENT_CONTACT_CHAT_ID} and {@link #EXTRA_RECIPIENT_CONTACT_NAME} (as a |
| 9048 | * consequence, EXTRA_RECIPIENT_CONTACT_URI, EXTRA_RECIPIENT_CONTACT_CHAT_ID and |
| 9049 | * EXTRA_RECIPIENT_CONTACT_NAME should all be of length n). If neither of these 3 elements |
| 9050 | * is provided (e.g. all 3 are null) for the recipient or if the information provided is |
| 9051 | * ambiguous then the activity should prompt the user for the recipient to send the message |
| 9052 | * to. |
| 9053 | * <p> |
| 9054 | * Output: nothing |
| 9055 | * |
| 9056 | * @see #EXTRA_RECIPIENT_CONTACT_URI |
| 9057 | * @see #EXTRA_RECIPIENT_CONTACT_CHAT_ID |
| 9058 | * @see #EXTRA_RECIPIENT_CONTACT_NAME |
Renat Aksitov | c8dd93d | 2016-05-01 16:31:28 -0700 | [diff] [blame] | 9059 | * @see #METADATA_ACCOUNT_TYPE |
| 9060 | * @see #METADATA_MIMETYPE |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 9061 | */ |
Jeff Sharkey | 0f3f60b | 2017-04-24 18:06:20 -0600 | [diff] [blame] | 9062 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 9063 | public static final String ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS = |
| 9064 | "android.provider.action.VOICE_SEND_MESSAGE_TO_CONTACTS"; |
| 9065 | |
| 9066 | /** |
| 9067 | * This extra specifies a content provider uri(s) for the contact(s) (if the contacts were |
| 9068 | * located in the Contacts Provider), used with {@link |
| 9069 | * #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient(s). The value of this |
| 9070 | * extra is a {@code String[]}. The number of elements in the array should be equal to |
| 9071 | * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_CHAT_ID} and |
| 9072 | * {@link #EXTRA_RECIPIENT_CONTACT_NAME}). When the value of the element for the particular |
| 9073 | * recipient is absent, it will be set to null. |
| 9074 | * <p> |
| 9075 | * <em>Note: one contact may have multiple accounts (e.g. Chat IDs) on a specific messaging |
| 9076 | * platform, so this may be ambiguous. E.g., one contact “John Smith” could have two |
| 9077 | * accounts on the same messaging app.</em> |
| 9078 | * <p> |
| 9079 | * <em>Example value: {"content://com.android.contacts/contacts/16"}</em> |
| 9080 | */ |
| 9081 | public static final String EXTRA_RECIPIENT_CONTACT_URI = |
| 9082 | "android.provider.extra.RECIPIENT_CONTACT_URI"; |
| 9083 | |
| 9084 | /** |
| 9085 | * This extra specifies a messaging app’s unique ID(s) for the contact(s), used with {@link |
| 9086 | * #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient(s). The value of this |
| 9087 | * extra is a {@code String[]}. The number of elements in the array should be equal to |
| 9088 | * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_URI} and {@link |
| 9089 | * #EXTRA_RECIPIENT_CONTACT_NAME}). When the value of the element for the particular |
| 9090 | * recipient is absent, it will be set to null. |
| 9091 | * <p> |
| 9092 | * The value of the elements comes from the {@link DataColumns#DATA1} column in Contacts |
Renat Aksitov | c8dd93d | 2016-05-01 16:31:28 -0700 | [diff] [blame] | 9093 | * Provider with {@link DataColumns#MIMETYPE} from {@link #METADATA_MIMETYPE} (if both |
| 9094 | * {@link #METADATA_ACCOUNT_TYPE} and {@link #METADATA_MIMETYPE} are specified by the app; |
| 9095 | * otherwise, the value will be a phone number), and should be the unambiguous contact |
| 9096 | * endpoint. This value is app-specific, it could be some proprietary ID or a phone number. |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 9097 | */ |
| 9098 | public static final String EXTRA_RECIPIENT_CONTACT_CHAT_ID = |
| 9099 | "android.provider.extra.RECIPIENT_CONTACT_CHAT_ID"; |
| 9100 | |
| 9101 | /** |
| 9102 | * This extra specifies the contact name (full name from the Contacts Provider), used with |
| 9103 | * {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient. The value of this |
| 9104 | * extra is a {@code String[]}. The number of elements in the array should be equal to |
| 9105 | * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_URI} and {@link |
| 9106 | * #EXTRA_RECIPIENT_CONTACT_CHAT_ID}). When the value of the element for the particular |
| 9107 | * recipient is absent, it will be set to null. |
| 9108 | * <p> |
| 9109 | * The value of the elements comes from RawContact's display_name column. |
| 9110 | * <p> |
| 9111 | * <em>Example value: {"Jane Doe"}</em> |
| 9112 | */ |
| 9113 | public static final String EXTRA_RECIPIENT_CONTACT_NAME = |
| 9114 | "android.provider.extra.RECIPIENT_CONTACT_NAME"; |
| 9115 | |
| 9116 | /** |
Renat Aksitov | c8dd93d | 2016-05-01 16:31:28 -0700 | [diff] [blame] | 9117 | * A string associated with an {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} activity |
| 9118 | * describing {@link RawContacts#ACCOUNT_TYPE} for the corresponding Contacts Provider |
| 9119 | * implementation. |
| 9120 | */ |
| 9121 | public static final String METADATA_ACCOUNT_TYPE = "android.provider.account_type"; |
| 9122 | |
| 9123 | /** |
| 9124 | * A string associated with an {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} activity |
| 9125 | * describing {@link DataColumns#MIMETYPE} for the corresponding Contacts Provider |
| 9126 | * implementation. |
| 9127 | */ |
| 9128 | public static final String METADATA_MIMETYPE = "android.provider.mimetype"; |
| 9129 | |
| 9130 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 9131 | * Starts an Activity that lets the user select the multiple phones from a |
| 9132 | * list of phone numbers which come from the contacts or |
| 9133 | * {@link #EXTRA_PHONE_URIS}. |
| 9134 | * <p> |
| 9135 | * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS} |
| 9136 | * could belong to the contacts or not, and will be selected by default. |
| 9137 | * <p> |
| 9138 | * The user's selection will be returned from |
| 9139 | * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)} |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 9140 | * if the resultCode is |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 9141 | * {@link android.app.Activity#RESULT_OK}, the array of picked phone |
| 9142 | * numbers are in the Intent's |
| 9143 | * {@link #EXTRA_PHONE_URIS}; otherwise, the |
| 9144 | * {@link android.app.Activity#RESULT_CANCELED} is returned if the user |
| 9145 | * left the Activity without changing the selection. |
| 9146 | * |
| 9147 | * @hide |
| 9148 | */ |
| 9149 | public static final String ACTION_GET_MULTIPLE_PHONES = |
| 9150 | "com.android.contacts.action.GET_MULTIPLE_PHONES"; |
| 9151 | |
| 9152 | /** |
Makoto Onuki | 90ddc90 | 2012-09-11 18:22:53 -0700 | [diff] [blame] | 9153 | * A broadcast action which is sent when any change has been made to the profile, such |
| 9154 | * as the profile name or the picture. A receiver must have |
| 9155 | * the android.permission.READ_PROFILE permission. |
| 9156 | * |
| 9157 | * @hide |
| 9158 | */ |
| 9159 | public static final String ACTION_PROFILE_CHANGED = |
| 9160 | "android.provider.Contacts.PROFILE_CHANGED"; |
| 9161 | |
| 9162 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9163 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new |
| 9164 | * contact if no matching contact found. Otherwise, default behavior is |
| 9165 | * to prompt user with dialog before creating. |
| 9166 | * <p> |
| 9167 | * Type: BOOLEAN |
| 9168 | */ |
| 9169 | public static final String EXTRA_FORCE_CREATE = |
| 9170 | "com.android.contacts.action.FORCE_CREATE"; |
| 9171 | |
| 9172 | /** |
| 9173 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact |
| 9174 | * description to be shown when prompting user about creating a new |
| 9175 | * contact. |
| 9176 | * <p> |
| 9177 | * Type: STRING |
| 9178 | */ |
| 9179 | public static final String EXTRA_CREATE_DESCRIPTION = |
| 9180 | "com.android.contacts.action.CREATE_DESCRIPTION"; |
| 9181 | |
| 9182 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 9183 | * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value. |
| 9184 | * <p> |
| 9185 | * The phone numbers want to be picked by default should be passed in as |
| 9186 | * input value. These phone numbers could belong to the contacts or not. |
| 9187 | * <p> |
| 9188 | * The phone numbers which were picked by the user are returned as output |
| 9189 | * value. |
| 9190 | * <p> |
| 9191 | * Type: array of URIs, the tel URI is used for the phone numbers which don't |
| 9192 | * 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] | 9193 | * |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 9194 | * @hide |
| 9195 | */ |
| 9196 | public static final String EXTRA_PHONE_URIS = |
| 9197 | "com.android.contacts.extra.PHONE_URIS"; |
| 9198 | |
| 9199 | /** |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 9200 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 9201 | * dialog location using screen coordinates. When not specified, the |
| 9202 | * dialog will be centered. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9203 | * |
| 9204 | * @hide |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 9205 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9206 | @Deprecated |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 9207 | public static final String EXTRA_TARGET_RECT = "target_rect"; |
| 9208 | |
| 9209 | /** |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9210 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 9211 | * desired dialog style, usually a variation on size. One of |
| 9212 | * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9213 | * |
| 9214 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9215 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9216 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9217 | public static final String EXTRA_MODE = "mode"; |
| 9218 | |
| 9219 | /** |
| 9220 | * Value for {@link #EXTRA_MODE} to show a small-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9221 | * |
| 9222 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9223 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9224 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9225 | public static final int MODE_SMALL = 1; |
| 9226 | |
| 9227 | /** |
| 9228 | * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9229 | * |
| 9230 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9231 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9232 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9233 | public static final int MODE_MEDIUM = 2; |
| 9234 | |
| 9235 | /** |
| 9236 | * Value for {@link #EXTRA_MODE} to show a large-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9237 | * |
| 9238 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9239 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9240 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9241 | public static final int MODE_LARGE = 3; |
| 9242 | |
| 9243 | /** |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 9244 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate |
| 9245 | * a list of specific MIME-types to exclude and not display. Stored as a |
| 9246 | * {@link String} array. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9247 | * |
| 9248 | * @hide |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 9249 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9250 | @Deprecated |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 9251 | public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; |
| 9252 | |
| 9253 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9254 | * Convenience class that contains string constants used |
| 9255 | * to create contact {@link android.content.Intent Intents}. |
| 9256 | */ |
| 9257 | public static final class Insert { |
| 9258 | /** The action code to use when adding a contact */ |
| 9259 | public static final String ACTION = Intent.ACTION_INSERT; |
| 9260 | |
| 9261 | /** |
| 9262 | * If present, forces a bypass of quick insert mode. |
| 9263 | */ |
| 9264 | public static final String FULL_MODE = "full_mode"; |
| 9265 | |
| 9266 | /** |
| 9267 | * The extra field for the contact name. |
| 9268 | * <P>Type: String</P> |
| 9269 | */ |
| 9270 | public static final String NAME = "name"; |
| 9271 | |
| 9272 | // TODO add structured name values here. |
| 9273 | |
| 9274 | /** |
| 9275 | * The extra field for the contact phonetic name. |
| 9276 | * <P>Type: String</P> |
| 9277 | */ |
| 9278 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 9279 | |
| 9280 | /** |
| 9281 | * The extra field for the contact company. |
| 9282 | * <P>Type: String</P> |
| 9283 | */ |
| 9284 | public static final String COMPANY = "company"; |
| 9285 | |
| 9286 | /** |
| 9287 | * The extra field for the contact job title. |
| 9288 | * <P>Type: String</P> |
| 9289 | */ |
| 9290 | public static final String JOB_TITLE = "job_title"; |
| 9291 | |
| 9292 | /** |
| 9293 | * The extra field for the contact notes. |
| 9294 | * <P>Type: String</P> |
| 9295 | */ |
| 9296 | public static final String NOTES = "notes"; |
| 9297 | |
| 9298 | /** |
| 9299 | * The extra field for the contact phone number. |
| 9300 | * <P>Type: String</P> |
| 9301 | */ |
| 9302 | public static final String PHONE = "phone"; |
| 9303 | |
| 9304 | /** |
| 9305 | * The extra field for the contact phone number type. |
| 9306 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9307 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9308 | * or a string specifying a custom label.</P> |
| 9309 | */ |
| 9310 | public static final String PHONE_TYPE = "phone_type"; |
| 9311 | |
| 9312 | /** |
| 9313 | * The extra field for the phone isprimary flag. |
| 9314 | * <P>Type: boolean</P> |
| 9315 | */ |
| 9316 | public static final String PHONE_ISPRIMARY = "phone_isprimary"; |
| 9317 | |
| 9318 | /** |
| 9319 | * The extra field for an optional second contact phone number. |
| 9320 | * <P>Type: String</P> |
| 9321 | */ |
| 9322 | public static final String SECONDARY_PHONE = "secondary_phone"; |
| 9323 | |
| 9324 | /** |
| 9325 | * The extra field for an optional second contact phone number type. |
| 9326 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9327 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9328 | * or a string specifying a custom label.</P> |
| 9329 | */ |
| 9330 | public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; |
| 9331 | |
| 9332 | /** |
| 9333 | * The extra field for an optional third contact phone number. |
| 9334 | * <P>Type: String</P> |
| 9335 | */ |
| 9336 | public static final String TERTIARY_PHONE = "tertiary_phone"; |
| 9337 | |
| 9338 | /** |
| 9339 | * The extra field for an optional third contact phone number type. |
| 9340 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9341 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9342 | * or a string specifying a custom label.</P> |
| 9343 | */ |
| 9344 | public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; |
| 9345 | |
| 9346 | /** |
| 9347 | * The extra field for the contact email address. |
| 9348 | * <P>Type: String</P> |
| 9349 | */ |
| 9350 | public static final String EMAIL = "email"; |
| 9351 | |
| 9352 | /** |
| 9353 | * The extra field for the contact email type. |
| 9354 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9355 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9356 | * or a string specifying a custom label.</P> |
| 9357 | */ |
| 9358 | public static final String EMAIL_TYPE = "email_type"; |
| 9359 | |
| 9360 | /** |
| 9361 | * The extra field for the email isprimary flag. |
| 9362 | * <P>Type: boolean</P> |
| 9363 | */ |
| 9364 | public static final String EMAIL_ISPRIMARY = "email_isprimary"; |
| 9365 | |
| 9366 | /** |
| 9367 | * The extra field for an optional second contact email address. |
| 9368 | * <P>Type: String</P> |
| 9369 | */ |
| 9370 | public static final String SECONDARY_EMAIL = "secondary_email"; |
| 9371 | |
| 9372 | /** |
| 9373 | * The extra field for an optional second contact email type. |
| 9374 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9375 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9376 | * or a string specifying a custom label.</P> |
| 9377 | */ |
| 9378 | public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; |
| 9379 | |
| 9380 | /** |
| 9381 | * The extra field for an optional third contact email address. |
| 9382 | * <P>Type: String</P> |
| 9383 | */ |
| 9384 | public static final String TERTIARY_EMAIL = "tertiary_email"; |
| 9385 | |
| 9386 | /** |
| 9387 | * The extra field for an optional third contact email type. |
| 9388 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9389 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9390 | * or a string specifying a custom label.</P> |
| 9391 | */ |
| 9392 | public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; |
| 9393 | |
| 9394 | /** |
| 9395 | * The extra field for the contact postal address. |
| 9396 | * <P>Type: String</P> |
| 9397 | */ |
| 9398 | public static final String POSTAL = "postal"; |
| 9399 | |
| 9400 | /** |
| 9401 | * The extra field for the contact postal address type. |
| 9402 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9403 | * {@link CommonDataKinds.StructuredPostal} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9404 | * or a string specifying a custom label.</P> |
| 9405 | */ |
| 9406 | public static final String POSTAL_TYPE = "postal_type"; |
| 9407 | |
| 9408 | /** |
| 9409 | * The extra field for the postal isprimary flag. |
| 9410 | * <P>Type: boolean</P> |
| 9411 | */ |
| 9412 | public static final String POSTAL_ISPRIMARY = "postal_isprimary"; |
| 9413 | |
| 9414 | /** |
| 9415 | * The extra field for an IM handle. |
| 9416 | * <P>Type: String</P> |
| 9417 | */ |
| 9418 | public static final String IM_HANDLE = "im_handle"; |
| 9419 | |
| 9420 | /** |
| 9421 | * The extra field for the IM protocol |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9422 | */ |
| 9423 | public static final String IM_PROTOCOL = "im_protocol"; |
| 9424 | |
| 9425 | /** |
| 9426 | * The extra field for the IM isprimary flag. |
| 9427 | * <P>Type: boolean</P> |
| 9428 | */ |
| 9429 | public static final String IM_ISPRIMARY = "im_isprimary"; |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 9430 | |
| 9431 | /** |
| 9432 | * The extra field that allows the client to supply multiple rows of |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 9433 | * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT} |
| 9434 | * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of |
| 9435 | * {@link ContentValues}, one per data row. Supplying this extra is |
| 9436 | * similar to inserting multiple rows into the {@link Data} table, |
| 9437 | * except the user gets a chance to see and edit them before saving. |
| 9438 | * Each ContentValues object must have a value for {@link Data#MIMETYPE}. |
| 9439 | * If supplied values are not visible in the editor UI, they will be |
| 9440 | * dropped. Duplicate data will dropped. Some fields |
| 9441 | * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically |
| 9442 | * adjusted to comply with the constraints of the specific account type. |
| 9443 | * For example, an Exchange contact can only have one phone numbers of type Home, |
| 9444 | * so the contact editor may choose a different type for this phone number to |
| 9445 | * avoid dropping the valueable part of the row, which is the phone number. |
| 9446 | * <p> |
| 9447 | * Example: |
| 9448 | * <pre> |
| 9449 | * ArrayList<ContentValues> data = new ArrayList<ContentValues>(); |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 9450 | * |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 9451 | * ContentValues row1 = new ContentValues(); |
| 9452 | * row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE); |
| 9453 | * row1.put(Organization.COMPANY, "Android"); |
| 9454 | * data.add(row1); |
| 9455 | * |
| 9456 | * ContentValues row2 = new ContentValues(); |
| 9457 | * row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE); |
| 9458 | * row2.put(Email.TYPE, Email.TYPE_CUSTOM); |
| 9459 | * row2.put(Email.LABEL, "Green Bot"); |
| 9460 | * row2.put(Email.ADDRESS, "android@android.com"); |
| 9461 | * data.add(row2); |
| 9462 | * |
| 9463 | * Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); |
| 9464 | * intent.putParcelableArrayListExtra(Insert.DATA, data); |
| 9465 | * |
| 9466 | * startActivity(intent); |
| 9467 | * </pre> |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 9468 | */ |
| 9469 | public static final String DATA = "data"; |
Daniel Lehmann | cde1ac6 | 2010-10-21 20:40:11 -0700 | [diff] [blame] | 9470 | |
| 9471 | /** |
| 9472 | * Used to specify the account in which to create the new contact. |
| 9473 | * <p> |
| 9474 | * If this value is not provided, the user is presented with a disambiguation |
| 9475 | * dialog to chose an account |
| 9476 | * <p> |
| 9477 | * Type: {@link Account} |
Daniel Lehmann | cde1ac6 | 2010-10-21 20:40:11 -0700 | [diff] [blame] | 9478 | */ |
Brian Attwell | 63f859b | 2015-01-26 15:57:10 -0800 | [diff] [blame] | 9479 | public static final String EXTRA_ACCOUNT = "android.provider.extra.ACCOUNT"; |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 9480 | |
| 9481 | /** |
| 9482 | * Used to specify the data set within the account in which to create the |
| 9483 | * new contact. |
| 9484 | * <p> |
| 9485 | * This value is optional - if it is not specified, the contact will be |
| 9486 | * created in the base account, with no data set. |
| 9487 | * <p> |
| 9488 | * Type: String |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 9489 | */ |
Brian Attwell | 63f859b | 2015-01-26 15:57:10 -0800 | [diff] [blame] | 9490 | public static final String EXTRA_DATA_SET = "android.provider.extra.DATA_SET"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9491 | } |
| 9492 | } |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9493 | |
| 9494 | /** |
| 9495 | * @hide |
| 9496 | */ |
Zheng Fu | 7997bee | 2015-06-09 16:50:02 -0700 | [diff] [blame] | 9497 | @SystemApi |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9498 | protected interface MetadataSyncColumns { |
| 9499 | |
| 9500 | /** |
| 9501 | * The raw contact backup id. |
| 9502 | * A reference to the {@link ContactsContract.RawContacts#BACKUP_ID} that save the |
| 9503 | * persistent unique id for each raw contact within its source system. |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9504 | */ |
| 9505 | public static final String RAW_CONTACT_BACKUP_ID = "raw_contact_backup_id"; |
| 9506 | |
| 9507 | /** |
| 9508 | * The account type to which the raw_contact of this item is associated. See |
| 9509 | * {@link RawContacts#ACCOUNT_TYPE} |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9510 | */ |
| 9511 | public static final String ACCOUNT_TYPE = "account_type"; |
| 9512 | |
| 9513 | /** |
| 9514 | * The account name to which the raw_contact of this item is associated. See |
| 9515 | * {@link RawContacts#ACCOUNT_NAME} |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9516 | */ |
| 9517 | public static final String ACCOUNT_NAME = "account_name"; |
| 9518 | |
| 9519 | /** |
| 9520 | * The data set within the account that the raw_contact of this row belongs to. This allows |
| 9521 | * multiple sync adapters for the same account type to distinguish between |
| 9522 | * each others' data. |
| 9523 | * {@link RawContacts#DATA_SET} |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9524 | */ |
| 9525 | public static final String DATA_SET = "data_set"; |
| 9526 | |
| 9527 | /** |
| 9528 | * A text column contains the Json string got from People API. The Json string contains |
| 9529 | * all the metadata related to the raw contact, i.e., all the data fields and |
| 9530 | * aggregation exceptions. |
| 9531 | * |
| 9532 | * Here is an example of the Json string got from the actual schema. |
| 9533 | * <pre> |
| 9534 | * { |
| 9535 | * "unique_contact_id": { |
| 9536 | * "account_type": "CUSTOM_ACCOUNT", |
| 9537 | * "custom_account_type": "facebook", |
| 9538 | * "account_name": "android-test", |
| 9539 | * "contact_id": "1111111", |
| 9540 | * "data_set": "FOCUS" |
| 9541 | * }, |
| 9542 | * "contact_prefs": { |
| 9543 | * "send_to_voicemail": true, |
| 9544 | * "starred": false, |
| 9545 | * "pinned": 2 |
| 9546 | * }, |
| 9547 | * "aggregation_data": [ |
| 9548 | * { |
| 9549 | * "type": "TOGETHER", |
| 9550 | * "contact_ids": [ |
| 9551 | * { |
| 9552 | * "account_type": "GOOGLE_ACCOUNT", |
| 9553 | * "account_name": "android-test2", |
| 9554 | * "contact_id": "2222222", |
| 9555 | * "data_set": "GOOGLE_PLUS" |
| 9556 | * }, |
| 9557 | * { |
| 9558 | * "account_type": "GOOGLE_ACCOUNT", |
| 9559 | * "account_name": "android-test3", |
| 9560 | * "contact_id": "3333333", |
| 9561 | * "data_set": "CUSTOM", |
| 9562 | * "custom_data_set": "custom type" |
| 9563 | * } |
| 9564 | * ] |
| 9565 | * } |
| 9566 | * ], |
| 9567 | * "field_data": [ |
| 9568 | * { |
| 9569 | * "field_data_id": "1001", |
| 9570 | * "field_data_prefs": { |
| 9571 | * "is_primary": true, |
| 9572 | * "is_super_primary": true |
| 9573 | * }, |
| 9574 | * "usage_stats": [ |
| 9575 | * { |
| 9576 | * "usage_type": "CALL", |
| 9577 | * "last_time_used": 10000001, |
| 9578 | * "usage_count": 10 |
| 9579 | * } |
| 9580 | * ] |
| 9581 | * } |
| 9582 | * ] |
| 9583 | * } |
| 9584 | * </pre> |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9585 | */ |
| 9586 | public static final String DATA = "data"; |
| 9587 | |
| 9588 | /** |
| 9589 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 9590 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 9591 | * called on a raw contact, updating MetadataSync table to set the flag of the raw contact |
| 9592 | * as "1", then metadata sync adapter deletes the raw contact metadata on the server. |
| 9593 | * <P>Type: INTEGER</P> |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9594 | */ |
| 9595 | public static final String DELETED = "deleted"; |
| 9596 | } |
| 9597 | |
| 9598 | /** |
| 9599 | * Constants for the metadata sync table. This table is used to cache the metadata_sync data |
| 9600 | * from server before it is merged into other CP2 tables. |
| 9601 | * |
| 9602 | * @hide |
| 9603 | */ |
Zheng Fu | 7997bee | 2015-06-09 16:50:02 -0700 | [diff] [blame] | 9604 | @SystemApi |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9605 | public static final class MetadataSync implements BaseColumns, MetadataSyncColumns { |
| 9606 | |
| 9607 | /** The authority for the contacts metadata */ |
| 9608 | public static final String METADATA_AUTHORITY = "com.android.contacts.metadata"; |
| 9609 | |
| 9610 | /** A content:// style uri to the authority for the contacts metadata */ |
| 9611 | public static final Uri METADATA_AUTHORITY_URI = Uri.parse( |
| 9612 | "content://" + METADATA_AUTHORITY); |
| 9613 | |
| 9614 | /** |
| 9615 | * This utility class cannot be instantiated |
| 9616 | */ |
| 9617 | private MetadataSync() { |
| 9618 | } |
| 9619 | |
| 9620 | /** |
| 9621 | * The content:// style URI for this table. |
| 9622 | */ |
| 9623 | public static final Uri CONTENT_URI = Uri.withAppendedPath(METADATA_AUTHORITY_URI, |
| 9624 | "metadata_sync"); |
Zheng Fu | c37ba12 | 2015-04-23 16:46:45 -0700 | [diff] [blame] | 9625 | |
| 9626 | /** |
| 9627 | * The MIME type of {@link #CONTENT_URI} providing a directory of contact metadata |
| 9628 | */ |
| 9629 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact_metadata"; |
| 9630 | |
| 9631 | /** |
| 9632 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single contact metadata. |
| 9633 | */ |
| 9634 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_metadata"; |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9635 | } |
Zheng Fu | ae678b8 | 2015-08-07 13:28:50 -0700 | [diff] [blame] | 9636 | |
| 9637 | /** |
| 9638 | * @hide |
| 9639 | */ |
| 9640 | @SystemApi |
| 9641 | protected interface MetadataSyncStateColumns { |
| 9642 | |
| 9643 | /** |
| 9644 | * A reference to the name of the account to which this state belongs |
| 9645 | * <P>Type: STRING</P> |
| 9646 | */ |
| 9647 | public static final String ACCOUNT_TYPE = "account_type"; |
| 9648 | |
| 9649 | /** |
| 9650 | * A reference to the type of the account to which this state belongs |
| 9651 | * <P>Type: STRING</P> |
| 9652 | */ |
| 9653 | public static final String ACCOUNT_NAME = "account_name"; |
| 9654 | |
| 9655 | /** |
| 9656 | * A reference to the data set within the account to which this state belongs |
| 9657 | * <P>Type: STRING</P> |
| 9658 | */ |
| 9659 | public static final String DATA_SET = "data_set"; |
| 9660 | |
| 9661 | /** |
| 9662 | * The sync state associated with this account. |
| 9663 | * <P>Type: Blob</P> |
| 9664 | */ |
| 9665 | public static final String STATE = "state"; |
| 9666 | } |
| 9667 | |
| 9668 | /** |
| 9669 | * Constants for the metadata_sync_state table. This table is used to store the metadata |
| 9670 | * sync state for a set of accounts. |
| 9671 | * |
| 9672 | * @hide |
| 9673 | */ |
| 9674 | @SystemApi |
| 9675 | public static final class MetadataSyncState implements BaseColumns, MetadataSyncStateColumns { |
| 9676 | |
| 9677 | /** |
| 9678 | * This utility class cannot be instantiated |
| 9679 | */ |
| 9680 | private MetadataSyncState() { |
| 9681 | } |
| 9682 | |
| 9683 | /** |
| 9684 | * The content:// style URI for this table. |
| 9685 | */ |
| 9686 | public static final Uri CONTENT_URI = |
| 9687 | Uri.withAppendedPath(MetadataSync.METADATA_AUTHORITY_URI, "metadata_sync_state"); |
| 9688 | |
| 9689 | /** |
| 9690 | * The MIME type of {@link #CONTENT_URI} providing a directory of contact metadata sync |
| 9691 | * states. |
| 9692 | */ |
| 9693 | public static final String CONTENT_TYPE = |
| 9694 | "vnd.android.cursor.dir/contact_metadata_sync_state"; |
| 9695 | |
| 9696 | /** |
| 9697 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single contact metadata sync |
| 9698 | * state. |
| 9699 | */ |
| 9700 | public static final String CONTENT_ITEM_TYPE = |
| 9701 | "vnd.android.cursor.item/contact_metadata_sync_state"; |
| 9702 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 9703 | } |