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; |
Philip P. Moltmann | 3311515 | 2018-04-11 13:39:36 -0700 | [diff] [blame] | 23 | import android.annotation.TestApi; |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 24 | import android.annotation.UnsupportedAppUsage; |
Daniel Lehmann | e6d3d28 | 2011-07-13 15:35:05 -0700 | [diff] [blame] | 25 | import android.app.Activity; |
Makoto Onuki | 2a61537 | 2017-01-30 11:59:46 -0800 | [diff] [blame] | 26 | import android.content.BroadcastReceiver; |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 27 | import android.content.ComponentName; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 28 | import android.content.ContentProviderClient; |
| 29 | import android.content.ContentProviderOperation; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 30 | import android.content.ContentResolver; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 31 | import android.content.ContentUris; |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 32 | import android.content.ContentValues; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 33 | import android.content.Context; |
Makoto Onuki | bba33cd | 2012-05-25 17:09:05 -0700 | [diff] [blame] | 34 | import android.content.ContextWrapper; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 35 | import android.content.CursorEntityIterator; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 36 | import android.content.Entity; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 37 | import android.content.EntityIterator; |
| 38 | import android.content.Intent; |
Makoto Onuki | 2a61537 | 2017-01-30 11:59:46 -0800 | [diff] [blame] | 39 | import android.content.IntentFilter; |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 40 | import android.content.res.AssetFileDescriptor; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 41 | import android.content.res.Resources; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 42 | import android.database.Cursor; |
Makoto Onuki | 93d94eb | 2016-08-25 14:24:03 -0700 | [diff] [blame] | 43 | import android.database.CursorWrapper; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 44 | import android.database.DatabaseUtils; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 45 | import android.graphics.Rect; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 46 | import android.net.Uri; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 47 | import android.os.RemoteException; |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 48 | import android.telecom.PhoneAccountHandle; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 49 | import android.text.TextUtils; |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 50 | import android.util.DisplayMetrics; |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 51 | import android.util.Pair; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 52 | import android.view.View; |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 53 | |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 54 | import java.io.ByteArrayInputStream; |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 55 | import java.io.IOException; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 56 | import java.io.InputStream; |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 57 | import java.util.ArrayList; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 58 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 59 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 60 | * <p> |
| 61 | * The contract between the contacts provider and applications. Contains |
| 62 | * definitions for the supported URIs and columns. These APIs supersede |
| 63 | * {@link Contacts}. |
| 64 | * </p> |
| 65 | * <h3>Overview</h3> |
| 66 | * <p> |
| 67 | * ContactsContract defines an extensible database of contact-related |
| 68 | * information. Contact information is stored in a three-tier data model: |
| 69 | * </p> |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 70 | * <ul> |
| 71 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 72 | * A row in the {@link Data} table can store any kind of personal data, such |
| 73 | * as a phone number or email addresses. The set of data kinds that can be |
| 74 | * stored in this table is open-ended. There is a predefined set of common |
| 75 | * kinds, but any application can add its own data kinds. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 76 | * </li> |
| 77 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 78 | * A row in the {@link RawContacts} table represents a set of data describing a |
| 79 | * person and associated with a single account (for example, one of the user's |
| 80 | * Gmail accounts). |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 81 | * </li> |
| 82 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 83 | * 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] | 84 | * RawContacts presumably describing the same person. When data in or associated with |
| 85 | * the RawContacts table is changed, the affected aggregate contacts are updated as |
| 86 | * necessary. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 87 | * </li> |
| 88 | * </ul> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 89 | * <p> |
| 90 | * Other tables include: |
| 91 | * </p> |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 92 | * <ul> |
| 93 | * <li> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 94 | * {@link Groups}, which contains information about raw contact groups |
| 95 | * such as Gmail contact groups. The |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 96 | * current API does not support the notion of groups spanning multiple accounts. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 97 | * </li> |
| 98 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 99 | * {@link StatusUpdates}, which contains social status updates including IM |
| 100 | * availability. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 101 | * </li> |
| 102 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 103 | * {@link AggregationExceptions}, which is used for manual aggregation and |
| 104 | * disaggregation of raw contacts |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 105 | * </li> |
| 106 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 107 | * {@link Settings}, which contains visibility and sync settings for accounts |
| 108 | * and groups. |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 109 | * </li> |
| 110 | * <li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 111 | * {@link SyncState}, which contains free-form data maintained on behalf of sync |
| 112 | * adapters |
Dirk Dougherty | 4e7db25 | 2010-01-05 17:03:39 -0800 | [diff] [blame] | 113 | * </li> |
| 114 | * <li> |
| 115 | * {@link PhoneLookup}, which is used for quick caller-ID lookup</li> |
| 116 | * </ul> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 117 | */ |
Jeff Hamilton | 0c23212 | 2009-09-24 00:26:50 -0500 | [diff] [blame] | 118 | @SuppressWarnings("unused") |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 119 | public final class ContactsContract { |
| 120 | /** The authority for the contacts provider */ |
| 121 | public static final String AUTHORITY = "com.android.contacts"; |
| 122 | /** A content:// style uri to the authority for the contacts provider */ |
| 123 | public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); |
| 124 | |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 125 | /** |
Makoto Onuki | 203145e | 2016-09-28 15:41:29 -0700 | [diff] [blame] | 126 | * Prefix for column names that are not visible to client apps. |
| 127 | * @hide |
| 128 | */ |
Jeff Sharkey | cb269aac | 2019-01-25 11:15:38 -0700 | [diff] [blame] | 129 | @TestApi |
Makoto Onuki | 203145e | 2016-09-28 15:41:29 -0700 | [diff] [blame] | 130 | public static final String HIDDEN_COLUMN_PREFIX = "x_"; |
| 131 | |
| 132 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 133 | * An optional URI parameter for insert, update, or delete queries |
| 134 | * that allows the caller |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 135 | * 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] | 136 | * {@link RawContacts#DIRTY} is not automatically set and the |
| 137 | * "syncToNetwork" parameter is set to false when calling |
| 138 | * {@link |
| 139 | * ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}. |
| 140 | * This prevents an unnecessary extra synchronization, see the discussion of |
| 141 | * the delete operation in {@link RawContacts}. |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 142 | */ |
| 143 | public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter"; |
| 144 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 145 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 146 | * Query parameter that should be used by the client to access a specific |
| 147 | * {@link Directory}. The parameter value should be the _ID of the corresponding |
| 148 | * directory, e.g. |
| 149 | * {@code content://com.android.contacts/data/emails/filter/acme?directory=3} |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 150 | */ |
| 151 | public static final String DIRECTORY_PARAM_KEY = "directory"; |
| 152 | |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 153 | /** |
Makoto Onuki | 93d94eb | 2016-08-25 14:24:03 -0700 | [diff] [blame] | 154 | * 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] | 155 | * parameter value should be an integer. |
Makoto Onuki | 93d94eb | 2016-08-25 14:24:03 -0700 | [diff] [blame] | 156 | * |
| 157 | * <p>This parameter is not supported by all URIs. Supported URIs include, but not limited to, |
| 158 | * {@link Contacts#CONTENT_URI}, |
| 159 | * {@link RawContacts#CONTENT_URI}, |
| 160 | * {@link Data#CONTENT_URI}, |
| 161 | * {@link CommonDataKinds.Phone#CONTENT_URI}, |
| 162 | * {@link CommonDataKinds.Callable#CONTENT_URI}, |
| 163 | * {@link CommonDataKinds.Email#CONTENT_URI}, |
| 164 | * {@link CommonDataKinds.Contactables#CONTENT_URI}, |
| 165 | * |
| 166 | * <p>In order to limit the number of rows returned by a non-supported URI, you can implement a |
| 167 | * {@link CursorWrapper} and override the {@link CursorWrapper#getCount()} methods. |
Dmitri Plotnikov | 5a998dd | 2010-08-31 17:32:16 -0700 | [diff] [blame] | 168 | */ |
| 169 | public static final String LIMIT_PARAM_KEY = "limit"; |
| 170 | |
| 171 | /** |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 172 | * A query parameter specifing a primary account. This parameter should be used with |
| 173 | * {@link #PRIMARY_ACCOUNT_TYPE}. The contacts provider handling a query may rely on |
| 174 | * this information to optimize its query results. |
| 175 | * |
| 176 | * For example, in an email composition screen, its implementation can specify an account when |
| 177 | * obtaining possible recipients, letting the provider know which account is selected during |
| 178 | * the composition. The provider may use the "primary account" information to optimize |
| 179 | * the search result. |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 180 | */ |
| 181 | public static final String PRIMARY_ACCOUNT_NAME = "name_for_primary_account"; |
| 182 | |
| 183 | /** |
| 184 | * A query parameter specifing a primary account. This parameter should be used with |
| 185 | * {@link #PRIMARY_ACCOUNT_NAME}. See the doc in {@link #PRIMARY_ACCOUNT_NAME}. |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 186 | */ |
| 187 | public static final String PRIMARY_ACCOUNT_TYPE = "type_for_primary_account"; |
| 188 | |
Daisuke Miyakawa | f468591 | 2011-06-25 12:31:13 -0700 | [diff] [blame] | 189 | /** |
| 190 | * A boolean parameter for {@link Contacts#CONTENT_STREQUENT_URI} and |
| 191 | * {@link Contacts#CONTENT_STREQUENT_FILTER_URI}, which requires the ContactsProvider to |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 192 | * return only phone-related results. |
Daisuke Miyakawa | f468591 | 2011-06-25 12:31:13 -0700 | [diff] [blame] | 193 | */ |
| 194 | public static final String STREQUENT_PHONE_ONLY = "strequent_phone_only"; |
Daisuke Miyakawa | 54fcd4c | 2011-04-06 17:35:38 -0700 | [diff] [blame] | 195 | |
| 196 | /** |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 197 | * A key to a boolean in the "extras" bundle of the cursor. |
| 198 | * The boolean indicates that the provider did not create a snippet and that the client asking |
| 199 | * 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] | 200 | * |
| 201 | * @see SearchSnippets |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 202 | */ |
| 203 | public static final String DEFERRED_SNIPPETING = "deferred_snippeting"; |
| 204 | |
| 205 | /** |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 206 | * 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] | 207 | * |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 208 | * @see SearchSnippets |
| 209 | * @see #DEFERRED_SNIPPETING |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 210 | */ |
| 211 | public static final String DEFERRED_SNIPPETING_QUERY = "deferred_snippeting_query"; |
| 212 | |
| 213 | /** |
Yorke Lee | 1ca440b | 2014-06-04 18:01:46 -0700 | [diff] [blame] | 214 | * A boolean parameter for {@link CommonDataKinds.Phone#CONTENT_URI Phone.CONTENT_URI}, |
| 215 | * {@link CommonDataKinds.Email#CONTENT_URI Email.CONTENT_URI}, and |
| 216 | * {@link CommonDataKinds.StructuredPostal#CONTENT_URI StructuredPostal.CONTENT_URI}. |
Daisuke Miyakawa | 19352e0 | 2011-11-14 13:16:07 -0800 | [diff] [blame] | 217 | * This enables a content provider to remove duplicate entries in results. |
Daisuke Miyakawa | 19352e0 | 2011-11-14 13:16:07 -0800 | [diff] [blame] | 218 | */ |
| 219 | public static final String REMOVE_DUPLICATE_ENTRIES = "remove_duplicate_entries"; |
| 220 | |
| 221 | /** |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 222 | * <p> |
| 223 | * API for obtaining a pre-authorized version of a URI that normally requires special |
| 224 | * permission (beyond READ_CONTACTS) to read. The caller obtaining the pre-authorized URI |
| 225 | * must already have the necessary permissions to access the URI; otherwise a |
Brian Attwell | cc4b2f7 | 2015-01-08 14:58:15 -0800 | [diff] [blame] | 226 | * {@link SecurityException} will be thrown. Unlike {@link Context#grantUriPermission}, |
| 227 | * this can be used to grant permissions that aren't explicitly required for the URI inside |
| 228 | * AndroidManifest.xml. For example, permissions that are only required when reading URIs |
| 229 | * that refer to the user's profile. |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 230 | * </p> |
| 231 | * <p> |
| 232 | * The authorized URI returned in the bundle contains an expiring token that allows the |
| 233 | * 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] | 234 | * be required. The token expires in five minutes. |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 235 | * </p> |
| 236 | * <p> |
| 237 | * This API does not access disk, and should be safe to invoke from the UI thread. |
| 238 | * </p> |
| 239 | * <p> |
| 240 | * Example usage: |
| 241 | * <pre> |
| 242 | * Uri profileUri = ContactsContract.Profile.CONTENT_VCARD_URI; |
| 243 | * Bundle uriBundle = new Bundle(); |
| 244 | * uriBundle.putParcelable(ContactsContract.Authorization.KEY_URI_TO_AUTHORIZE, uri); |
| 245 | * Bundle authResponse = getContext().getContentResolver().call( |
| 246 | * ContactsContract.AUTHORITY_URI, |
| 247 | * ContactsContract.Authorization.AUTHORIZATION_METHOD, |
| 248 | * null, // String arg, not used. |
| 249 | * uriBundle); |
| 250 | * if (authResponse != null) { |
| 251 | * Uri preauthorizedProfileUri = (Uri) authResponse.getParcelable( |
| 252 | * ContactsContract.Authorization.KEY_AUTHORIZED_URI); |
| 253 | * // This pre-authorized URI can be queried by a caller without READ_PROFILE |
| 254 | * // permission. |
| 255 | * } |
| 256 | * </pre> |
| 257 | * </p> |
Brian Attwell | 7d383b9 | 2015-05-14 15:25:01 -0700 | [diff] [blame] | 258 | * |
| 259 | * @hide |
Dave Santoro | e43185e | 2011-10-10 18:11:00 -0700 | [diff] [blame] | 260 | */ |
| 261 | public static final class Authorization { |
| 262 | /** |
| 263 | * The method to invoke to create a pre-authorized URI out of the input argument. |
| 264 | */ |
| 265 | public static final String AUTHORIZATION_METHOD = "authorize"; |
| 266 | |
| 267 | /** |
| 268 | * The key to set in the outbound Bundle with the URI that should be authorized. |
| 269 | */ |
| 270 | public static final String KEY_URI_TO_AUTHORIZE = "uri_to_authorize"; |
| 271 | |
| 272 | /** |
| 273 | * The key to retrieve from the returned Bundle to obtain the pre-authorized URI. |
| 274 | */ |
| 275 | public static final String KEY_AUTHORIZED_URI = "authorized_uri"; |
| 276 | } |
| 277 | |
Yorke Lee | 6355c8f | 2014-07-08 11:48:42 -0700 | [diff] [blame] | 278 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 279 | * A Directory represents a contacts corpus, e.g. Local contacts, |
| 280 | * Google Apps Global Address List or Corporate Global Address List. |
| 281 | * <p> |
| 282 | * A Directory is implemented as a content provider with its unique authority and |
| 283 | * the same API as the main Contacts Provider. However, there is no expectation that |
| 284 | * every directory provider will implement this Contract in its entirety. If a |
| 285 | * directory provider does not have an implementation for a specific request, it |
| 286 | * should throw an UnsupportedOperationException. |
| 287 | * </p> |
| 288 | * <p> |
| 289 | * 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] | 290 | * expected to support at least {@link ContactsContract.Contacts#CONTENT_FILTER_URI |
| 291 | * Contacts.CONTENT_FILTER_URI}. If a Directory provider wants to participate |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 292 | * in email and phone lookup functionalities, it should also implement |
| 293 | * {@link CommonDataKinds.Email#CONTENT_FILTER_URI CommonDataKinds.Email.CONTENT_FILTER_URI} |
| 294 | * and |
| 295 | * {@link CommonDataKinds.Phone#CONTENT_FILTER_URI CommonDataKinds.Phone.CONTENT_FILTER_URI}. |
| 296 | * </p> |
| 297 | * <p> |
| 298 | * A directory provider should return NULL for every projection field it does not |
| 299 | * recognize, rather than throwing an exception. This way it will not be broken |
| 300 | * if ContactsContract is extended with new fields in the future. |
| 301 | * </p> |
| 302 | * <p> |
| 303 | * The client interacts with a directory via Contacts Provider by supplying an |
| 304 | * optional {@code directory=} query parameter. |
| 305 | * <p> |
| 306 | * <p> |
| 307 | * When the Contacts Provider receives the request, it transforms the URI and forwards |
| 308 | * the request to the corresponding directory content provider. |
| 309 | * The URI is transformed in the following fashion: |
| 310 | * <ul> |
| 311 | * <li>The URI authority is replaced with the corresponding {@link #DIRECTORY_AUTHORITY}.</li> |
| 312 | * <li>The {@code accountName=} and {@code accountType=} parameters are added or |
| 313 | * 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] | 314 | * </ul> |
| 315 | * </p> |
| 316 | * <p> |
| 317 | * Clients should send directory requests to Contacts Provider and let it |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 318 | * forward them to the respective providers rather than constructing |
| 319 | * directory provider URIs by themselves. This level of indirection allows |
| 320 | * Contacts Provider to implement additional system-level features and |
| 321 | * optimizations. Access to Contacts Provider is protected by the |
Subir Jhanb | 603af61 | 2012-08-06 17:19:22 -0700 | [diff] [blame] | 322 | * READ_CONTACTS permission, but access to the directory provider is protected by |
| 323 | * BIND_DIRECTORY_SEARCH. This permission was introduced at the API level 17, for previous |
| 324 | * platform versions the provider should perform the following check to make sure the call |
| 325 | * is coming from the ContactsProvider: |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 326 | * <pre> |
| 327 | * private boolean isCallerAllowed() { |
| 328 | * PackageManager pm = getContext().getPackageManager(); |
| 329 | * for (String packageName: pm.getPackagesForUid(Binder.getCallingUid())) { |
| 330 | * if (packageName.equals("com.android.providers.contacts")) { |
| 331 | * return true; |
| 332 | * } |
| 333 | * } |
| 334 | * return false; |
| 335 | * } |
| 336 | * </pre> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 337 | * </p> |
| 338 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 339 | * The Directory table is read-only and is maintained by the Contacts Provider |
| 340 | * automatically. |
| 341 | * </p> |
| 342 | * <p>It always has at least these two rows: |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 343 | * <ul> |
| 344 | * <li> |
| 345 | * The local directory. It has {@link Directory#_ID Directory._ID} = |
| 346 | * {@link Directory#DEFAULT Directory.DEFAULT}. This directory can be used to access locally |
| 347 | * stored contacts. The same can be achieved by omitting the {@code directory=} |
| 348 | * parameter altogether. |
| 349 | * </li> |
| 350 | * <li> |
| 351 | * The local invisible contacts. The corresponding directory ID is |
| 352 | * {@link Directory#LOCAL_INVISIBLE Directory.LOCAL_INVISIBLE}. |
| 353 | * </li> |
| 354 | * </ul> |
| 355 | * </p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 356 | * <p>Custom Directories are discovered by the Contacts Provider following this procedure: |
| 357 | * <ul> |
| 358 | * <li>It finds all installed content providers with meta data identifying them |
| 359 | * as directory providers in AndroidManifest.xml: |
| 360 | * <code> |
| 361 | * <meta-data android:name="android.content.ContactDirectory" |
| 362 | * android:value="true" /> |
| 363 | * </code> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 364 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 365 | * This tag should be placed inside the corresponding content provider declaration. |
| 366 | * </p> |
| 367 | * </li> |
| 368 | * <li> |
| 369 | * Then Contacts Provider sends a {@link Directory#CONTENT_URI Directory.CONTENT_URI} |
| 370 | * query to each of the directory authorities. A directory provider must implement |
| 371 | * this query and return a list of directories. Each directory returned by |
| 372 | * the provider must have a unique combination for the {@link #ACCOUNT_NAME} and |
| 373 | * {@link #ACCOUNT_TYPE} columns (nulls are allowed). Since directory IDs are assigned |
| 374 | * automatically, the _ID field will not be part of the query projection. |
| 375 | * </li> |
| 376 | * <li>Contacts Provider compiles directory lists received from all directory |
| 377 | * providers into one, assigns each individual directory a globally unique ID and |
| 378 | * stores all directory records in the Directory table. |
| 379 | * </li> |
| 380 | * </ul> |
| 381 | * </p> |
| 382 | * <p>Contacts Provider automatically interrogates newly installed or replaced packages. |
| 383 | * Thus simply installing a package containing a directory provider is sufficient |
| 384 | * to have that provider registered. A package supplying a directory provider does |
| 385 | * not have to contain launchable activities. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 386 | * </p> |
| 387 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 388 | * Every row in the Directory table is automatically associated with the corresponding package |
| 389 | * (apk). If the package is later uninstalled, all corresponding directory rows |
| 390 | * are automatically removed from the Contacts Provider. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 391 | * </p> |
| 392 | * <p> |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 393 | * When the list of directories handled by a directory provider changes |
| 394 | * (for instance when the user adds a new Directory account), the directory provider |
| 395 | * should call {@link #notifyDirectoryChange} to notify the Contacts Provider of the change. |
| 396 | * In response, the Contacts Provider will requery the directory provider to obtain the |
| 397 | * new list of directories. |
| 398 | * </p> |
| 399 | * <p> |
| 400 | * A directory row can be optionally associated with an existing account |
| 401 | * (see {@link android.accounts.AccountManager}). If the account is later removed, |
Dmitri Plotnikov | e50ed08 | 2010-08-18 10:56:09 -0700 | [diff] [blame] | 402 | * the corresponding directory rows are automatically removed from the Contacts Provider. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 403 | * </p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 404 | */ |
| 405 | public static final class Directory implements BaseColumns { |
| 406 | |
| 407 | /** |
| 408 | * Not instantiable. |
| 409 | */ |
| 410 | private Directory() { |
| 411 | } |
| 412 | |
| 413 | /** |
| 414 | * The content:// style URI for this table. Requests to this URI can be |
| 415 | * performed on the UI thread because they are always unblocking. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 416 | */ |
| 417 | public static final Uri CONTENT_URI = |
| 418 | Uri.withAppendedPath(AUTHORITY_URI, "directories"); |
| 419 | |
| 420 | /** |
Ricky Wai | 28ef5c5 | 2015-11-23 11:05:50 +0000 | [diff] [blame] | 421 | * URI used for getting all directories from primary and managed profile. |
| 422 | * It supports the same semantics as {@link #CONTENT_URI} and returns the same columns. |
| 423 | * If the device has no managed profile that is linked to the current profile, it behaves |
| 424 | * in the exact same way as {@link #CONTENT_URI}. |
| 425 | * If there is a managed profile linked to the current profile, it will merge |
| 426 | * managed profile and current profile's results and return. |
| 427 | * |
| 428 | * Note: this query returns primary profile results before managed profile results, |
| 429 | * and this order is not affected by sorting parameter. |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 430 | * |
| 431 | */ |
Ricky Wai | 28ef5c5 | 2015-11-23 11:05:50 +0000 | [diff] [blame] | 432 | public static final Uri ENTERPRISE_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 433 | "directories_enterprise"); |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 434 | |
| 435 | /** |
Victor Chang | dc0406d | 2016-01-14 21:02:06 +0000 | [diff] [blame] | 436 | * Access file provided by remote directory. It allows both personal and work remote |
| 437 | * directory, but not local and invisible diretory. |
| 438 | * |
| 439 | * It's supported only by a few specific places for referring to contact pictures in the |
| 440 | * remote directory. Contact picture URIs, e.g. |
| 441 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}, may contain this kind of URI. |
| 442 | * |
| 443 | * @hide |
| 444 | */ |
| 445 | public static final Uri ENTERPRISE_FILE_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 446 | "directory_file_enterprise"); |
| 447 | |
| 448 | |
| 449 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 450 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 451 | * contact directories. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 452 | */ |
| 453 | public static final String CONTENT_TYPE = |
| 454 | "vnd.android.cursor.dir/contact_directories"; |
| 455 | |
| 456 | /** |
| 457 | * The MIME type of a {@link #CONTENT_URI} item. |
| 458 | */ |
| 459 | public static final String CONTENT_ITEM_TYPE = |
| 460 | "vnd.android.cursor.item/contact_directory"; |
| 461 | |
| 462 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 463 | * _ID of the default directory, which represents locally stored contacts. |
Makoto Onuki | 93d94eb | 2016-08-25 14:24:03 -0700 | [diff] [blame] | 464 | * <b>This is only supported by {@link ContactsContract.Contacts#CONTENT_URI} and |
| 465 | * {@link ContactsContract.Contacts#CONTENT_FILTER_URI}. |
| 466 | * Other URLs do not support the concept of "visible" or "invisible" contacts. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 467 | */ |
| 468 | public static final long DEFAULT = 0; |
| 469 | |
| 470 | /** |
| 471 | * _ID of the directory that represents locally stored invisible contacts. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 472 | */ |
| 473 | public static final long LOCAL_INVISIBLE = 1; |
| 474 | |
| 475 | /** |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 476 | * _ID of the work profile default directory, which represents locally stored contacts. |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 477 | */ |
| 478 | public static final long ENTERPRISE_DEFAULT = Directory.ENTERPRISE_DIRECTORY_ID_BASE |
| 479 | + DEFAULT; |
| 480 | |
| 481 | /** |
| 482 | * _ID of the work profile directory that represents locally stored invisible contacts. |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 483 | */ |
| 484 | public static final long ENTERPRISE_LOCAL_INVISIBLE = Directory.ENTERPRISE_DIRECTORY_ID_BASE |
| 485 | + LOCAL_INVISIBLE; |
| 486 | |
| 487 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 488 | * The name of the package that owns this directory. Contacts Provider |
| 489 | * fill it in with the name of the package containing the directory provider. |
| 490 | * If the package is later uninstalled, the directories it owns are |
| 491 | * automatically removed from this table. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 492 | * |
| 493 | * <p>TYPE: TEXT</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 494 | */ |
| 495 | public static final String PACKAGE_NAME = "packageName"; |
| 496 | |
| 497 | /** |
| 498 | * The type of directory captured as a resource ID in the context of the |
| 499 | * package {@link #PACKAGE_NAME}, e.g. "Corporate Directory" |
| 500 | * |
| 501 | * <p>TYPE: INTEGER</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 502 | */ |
| 503 | public static final String TYPE_RESOURCE_ID = "typeResourceId"; |
| 504 | |
| 505 | /** |
| 506 | * An optional name that can be used in the UI to represent this directory, |
| 507 | * e.g. "Acme Corp" |
| 508 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 509 | */ |
| 510 | public static final String DISPLAY_NAME = "displayName"; |
| 511 | |
| 512 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 513 | * <p> |
| 514 | * The authority of the Directory Provider. Contacts Provider will |
| 515 | * use this authority to forward requests to the directory provider. |
| 516 | * A directory provider can leave this column empty - Contacts Provider will fill it in. |
| 517 | * </p> |
| 518 | * <p> |
| 519 | * Clients of this API should not send requests directly to this authority. |
| 520 | * All directory requests must be routed through Contacts Provider. |
| 521 | * </p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 522 | * |
| 523 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 524 | */ |
| 525 | public static final String DIRECTORY_AUTHORITY = "authority"; |
| 526 | |
| 527 | /** |
| 528 | * The account type which this directory is associated. |
| 529 | * |
| 530 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 531 | */ |
| 532 | public static final String ACCOUNT_TYPE = "accountType"; |
| 533 | |
| 534 | /** |
| 535 | * The account with which this directory is associated. If the account is later |
| 536 | * removed, the directories it owns are automatically removed from this table. |
| 537 | * |
| 538 | * <p>TYPE: text</p> |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 539 | */ |
| 540 | public static final String ACCOUNT_NAME = "accountName"; |
| 541 | |
| 542 | /** |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 543 | * Mimimal ID for corp directory returned from |
| 544 | * {@link Directory#CORP_CONTENT_URI}. |
| 545 | * |
| 546 | * @hide |
| 547 | */ |
| 548 | // slightly smaller than 2 ** 30 |
| 549 | public static final long ENTERPRISE_DIRECTORY_ID_BASE = 1000000000; |
| 550 | |
| 551 | /** |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 552 | * One of {@link #EXPORT_SUPPORT_NONE}, {@link #EXPORT_SUPPORT_ANY_ACCOUNT}, |
| 553 | * {@link #EXPORT_SUPPORT_SAME_ACCOUNT_ONLY}. This is the expectation the |
| 554 | * directory has for data exported from it. Clients must obey this setting. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 555 | */ |
| 556 | public static final String EXPORT_SUPPORT = "exportSupport"; |
| 557 | |
| 558 | /** |
| 559 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 560 | * does not allow any data to be copied out of it. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 561 | */ |
| 562 | public static final int EXPORT_SUPPORT_NONE = 0; |
| 563 | |
| 564 | /** |
| 565 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 566 | * allow its data copied only to the account specified by |
| 567 | * {@link #ACCOUNT_TYPE}/{@link #ACCOUNT_NAME}. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 568 | */ |
| 569 | public static final int EXPORT_SUPPORT_SAME_ACCOUNT_ONLY = 1; |
| 570 | |
| 571 | /** |
| 572 | * An {@link #EXPORT_SUPPORT} setting that indicates that the directory |
| 573 | * allow its data copied to any contacts account. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 574 | */ |
| 575 | public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2; |
| 576 | |
| 577 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 578 | * One of {@link #SHORTCUT_SUPPORT_NONE}, {@link #SHORTCUT_SUPPORT_DATA_ITEMS_ONLY}, |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 579 | * {@link #SHORTCUT_SUPPORT_FULL}. This is the expectation the directory |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 580 | * has for shortcuts created for its elements. Clients must obey this setting. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 581 | */ |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 582 | public static final String SHORTCUT_SUPPORT = "shortcutSupport"; |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 583 | |
| 584 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 585 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 586 | * does not allow any shortcuts created for its contacts. |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 587 | */ |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 588 | public static final int SHORTCUT_SUPPORT_NONE = 0; |
| 589 | |
| 590 | /** |
| 591 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 592 | * allow creation of shortcuts for data items like email, phone or postal address, |
| 593 | * but not the entire contact. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 594 | */ |
| 595 | public static final int SHORTCUT_SUPPORT_DATA_ITEMS_ONLY = 1; |
| 596 | |
| 597 | /** |
| 598 | * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory |
| 599 | * allow creation of shortcuts for contact as well as their constituent elements. |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 600 | */ |
| 601 | public static final int SHORTCUT_SUPPORT_FULL = 2; |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 602 | |
| 603 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 604 | * One of {@link #PHOTO_SUPPORT_NONE}, {@link #PHOTO_SUPPORT_THUMBNAIL_ONLY}, |
| 605 | * {@link #PHOTO_SUPPORT_FULL}. This is a feature flag indicating the extent |
| 606 | * to which the directory supports contact photos. |
| 607 | */ |
| 608 | public static final String PHOTO_SUPPORT = "photoSupport"; |
| 609 | |
| 610 | /** |
| 611 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 612 | * does not provide any photos. |
| 613 | */ |
| 614 | public static final int PHOTO_SUPPORT_NONE = 0; |
| 615 | |
| 616 | /** |
| 617 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 618 | * can only produce small size thumbnails of contact photos. |
| 619 | */ |
| 620 | public static final int PHOTO_SUPPORT_THUMBNAIL_ONLY = 1; |
| 621 | |
| 622 | /** |
| 623 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 624 | * has full-size contact photos, but cannot provide scaled thumbnails. |
| 625 | */ |
| 626 | public static final int PHOTO_SUPPORT_FULL_SIZE_ONLY = 2; |
| 627 | |
| 628 | /** |
| 629 | * An {@link #PHOTO_SUPPORT} setting that indicates that the directory |
| 630 | * can produce thumbnails as well as full-size contact photos. |
| 631 | */ |
| 632 | public static final int PHOTO_SUPPORT_FULL = 3; |
| 633 | |
| 634 | /** |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 635 | * Return TRUE if it is a remote stored directory. |
| 636 | */ |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 637 | public static boolean isRemoteDirectoryId(long directoryId) { |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 638 | return directoryId != Directory.DEFAULT |
| 639 | && directoryId != Directory.LOCAL_INVISIBLE |
| 640 | && directoryId != Directory.ENTERPRISE_DEFAULT |
| 641 | && directoryId != Directory.ENTERPRISE_LOCAL_INVISIBLE; |
| 642 | } |
| 643 | |
| 644 | /** |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 645 | * Return TRUE if it is a remote stored directory. TODO: Remove this method once all |
| 646 | * internal apps are not using this API. |
| 647 | * |
| 648 | * @hide |
| 649 | */ |
| 650 | public static boolean isRemoteDirectory(long directoryId) { |
| 651 | return isRemoteDirectoryId(directoryId); |
| 652 | } |
| 653 | |
| 654 | /** |
Ricky Wai | e363121 | 2015-11-09 18:20:57 +0000 | [diff] [blame] | 655 | * Return TRUE if a directory ID is from the contacts provider on the enterprise profile. |
| 656 | * |
| 657 | */ |
| 658 | public static boolean isEnterpriseDirectoryId(long directoryId) { |
| 659 | return directoryId >= ENTERPRISE_DIRECTORY_ID_BASE; |
| 660 | } |
| 661 | |
| 662 | /** |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 663 | * Notifies the system of a change in the list of directories handled by |
| 664 | * a particular directory provider. The Contacts provider will turn around |
| 665 | * and send a query to the directory provider for the full list of directories, |
| 666 | * which will replace the previous list. |
Dmitri Plotnikov | 2ef9d25 | 2010-08-05 08:28:11 -0700 | [diff] [blame] | 667 | */ |
| 668 | public static void notifyDirectoryChange(ContentResolver resolver) { |
| 669 | // This is done to trigger a query by Contacts Provider back to the directory provider. |
| 670 | // No data needs to be sent back, because the provider can infer the calling |
| 671 | // package from binder. |
| 672 | ContentValues contentValues = new ContentValues(); |
| 673 | resolver.update(Directory.CONTENT_URI, contentValues, null, null); |
| 674 | } |
Makoto Onuki | 296a5fd | 2016-10-12 13:18:08 -0700 | [diff] [blame] | 675 | |
| 676 | /** |
| 677 | * A query parameter that's passed to directory providers which indicates the client |
| 678 | * package name that has made the query requests. |
| 679 | */ |
| 680 | public static final String CALLER_PACKAGE_PARAM_KEY = "callerPackage"; |
Dmitri Plotnikov | a7f2f36 | 2010-05-20 20:48:50 -0700 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 684 | * @hide should be removed when users are updated to refer to SyncState |
| 685 | * @deprecated use SyncState instead |
| 686 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 687 | @Deprecated |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 688 | public interface SyncStateColumns extends SyncStateContract.Columns { |
| 689 | } |
| 690 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 691 | /** |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 692 | * 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] | 693 | * |
| 694 | * @see SyncStateContract |
| 695 | */ |
| 696 | public static final class SyncState implements SyncStateContract.Columns { |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 697 | /** |
| 698 | * This utility class cannot be instantiated |
| 699 | */ |
| 700 | private SyncState() {} |
| 701 | |
| 702 | public static final String CONTENT_DIRECTORY = |
| 703 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 704 | |
| 705 | /** |
| 706 | * The content:// style URI for this table |
| 707 | */ |
| 708 | public static final Uri CONTENT_URI = |
| 709 | Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY); |
| 710 | |
| 711 | /** |
| 712 | * @see android.provider.SyncStateContract.Helpers#get |
| 713 | */ |
| 714 | public static byte[] get(ContentProviderClient provider, Account account) |
| 715 | throws RemoteException { |
| 716 | return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| 717 | } |
| 718 | |
| 719 | /** |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 720 | * @see android.provider.SyncStateContract.Helpers#get |
| 721 | */ |
| 722 | public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) |
| 723 | throws RemoteException { |
| 724 | return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); |
| 725 | } |
| 726 | |
| 727 | /** |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 728 | * @see android.provider.SyncStateContract.Helpers#set |
| 729 | */ |
| 730 | public static void set(ContentProviderClient provider, Account account, byte[] data) |
| 731 | throws RemoteException { |
| 732 | SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| 733 | } |
| 734 | |
| 735 | /** |
| 736 | * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| 737 | */ |
| 738 | public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| 739 | return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| 740 | } |
| 741 | } |
| 742 | |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 743 | |
| 744 | /** |
| 745 | * A table provided for sync adapters to use for storing private sync state data for the |
| 746 | * user's personal profile. |
| 747 | * |
| 748 | * @see SyncStateContract |
| 749 | */ |
| 750 | public static final class ProfileSyncState implements SyncStateContract.Columns { |
| 751 | /** |
| 752 | * This utility class cannot be instantiated |
| 753 | */ |
| 754 | private ProfileSyncState() {} |
| 755 | |
| 756 | public static final String CONTENT_DIRECTORY = |
| 757 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 758 | |
| 759 | /** |
| 760 | * The content:// style URI for this table |
| 761 | */ |
| 762 | public static final Uri CONTENT_URI = |
| 763 | Uri.withAppendedPath(Profile.CONTENT_URI, CONTENT_DIRECTORY); |
| 764 | |
| 765 | /** |
| 766 | * @see android.provider.SyncStateContract.Helpers#get |
| 767 | */ |
| 768 | public static byte[] get(ContentProviderClient provider, Account account) |
| 769 | throws RemoteException { |
| 770 | return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| 771 | } |
| 772 | |
| 773 | /** |
| 774 | * @see android.provider.SyncStateContract.Helpers#get |
| 775 | */ |
| 776 | public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) |
| 777 | throws RemoteException { |
| 778 | return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); |
| 779 | } |
| 780 | |
| 781 | /** |
| 782 | * @see android.provider.SyncStateContract.Helpers#set |
| 783 | */ |
| 784 | public static void set(ContentProviderClient provider, Account account, byte[] data) |
| 785 | throws RemoteException { |
| 786 | SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| 787 | } |
| 788 | |
| 789 | /** |
| 790 | * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| 791 | */ |
| 792 | public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| 793 | return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| 794 | } |
| 795 | } |
| 796 | |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 797 | /** |
| 798 | * Generic columns for use by sync adapters. The specific functions of |
| 799 | * these columns are private to the sync adapter. Other clients of the API |
| 800 | * should not attempt to either read or write this column. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 801 | * |
| 802 | * @see RawContacts |
| 803 | * @see Groups |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 804 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 805 | protected interface BaseSyncColumns { |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 806 | |
| 807 | /** Generic column for use by sync adapters. */ |
| 808 | public static final String SYNC1 = "sync1"; |
| 809 | /** Generic column for use by sync adapters. */ |
| 810 | public static final String SYNC2 = "sync2"; |
| 811 | /** Generic column for use by sync adapters. */ |
| 812 | public static final String SYNC3 = "sync3"; |
| 813 | /** Generic column for use by sync adapters. */ |
| 814 | public static final String SYNC4 = "sync4"; |
| 815 | } |
| 816 | |
| 817 | /** |
| 818 | * Columns that appear when each row of a table belongs to a specific |
| 819 | * account, including sync information that an account may need. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 820 | * |
| 821 | * @see RawContacts |
| 822 | * @see Groups |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 823 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 824 | protected interface SyncColumns extends BaseSyncColumns { |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 825 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 826 | * The name of the account instance to which this row belongs, which when paired with |
| 827 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 828 | * <P>Type: TEXT</P> |
| 829 | */ |
| 830 | public static final String ACCOUNT_NAME = "account_name"; |
| 831 | |
| 832 | /** |
| 833 | * The type of account to which this row belongs, which when paired with |
| 834 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 835 | * <P>Type: TEXT</P> |
| 836 | */ |
| 837 | public static final String ACCOUNT_TYPE = "account_type"; |
| 838 | |
| 839 | /** |
| 840 | * String that uniquely identifies this row to its source account. |
| 841 | * <P>Type: TEXT</P> |
| 842 | */ |
| 843 | public static final String SOURCE_ID = "sourceid"; |
| 844 | |
| 845 | /** |
| 846 | * Version number that is updated whenever this row or its related data |
| 847 | * changes. |
| 848 | * <P>Type: INTEGER</P> |
| 849 | */ |
| 850 | public static final String VERSION = "version"; |
| 851 | |
| 852 | /** |
| 853 | * Flag indicating that {@link #VERSION} has changed, and this row needs |
| 854 | * to be synchronized by its owning account. |
| 855 | * <P>Type: INTEGER (boolean)</P> |
| 856 | */ |
| 857 | public static final String DIRTY = "dirty"; |
| 858 | } |
| 859 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 860 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 861 | * Columns of {@link ContactsContract.Contacts} that track the user's |
| 862 | * preferences for, or interactions with, the contact. |
| 863 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 864 | * @see Contacts |
| 865 | * @see RawContacts |
| 866 | * @see ContactsContract.Data |
| 867 | * @see PhoneLookup |
| 868 | * @see ContactsContract.Contacts.AggregationSuggestions |
| 869 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 870 | protected interface ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 871 | /** |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 872 | * The number of times a contact has been contacted. |
| 873 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete. For |
| 874 | * more information, see the |
| 875 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 876 | * page.</p> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 877 | * <P>Type: INTEGER</P> |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 878 | * |
| 879 | * @deprecated Contacts affinity information is no longer supported as of |
| 880 | * Android version {@link android.os.Build.VERSION_CODES#Q}. This column |
| 881 | * always contains 0. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 882 | */ |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 883 | @Deprecated |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 884 | public static final String TIMES_CONTACTED = "times_contacted"; |
| 885 | |
| 886 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 887 | * The last time a contact was contacted. |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 888 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete. For |
| 889 | * more information, see the |
| 890 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 891 | * page.</p> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 892 | * <P>Type: INTEGER</P> |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 893 | * |
| 894 | * @deprecated Contacts affinity information is no longer supported as of |
| 895 | * Android version {@link android.os.Build.VERSION_CODES#Q}. This column |
| 896 | * always contains 0. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 897 | */ |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 898 | @Deprecated |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 899 | public static final String LAST_TIME_CONTACTED = "last_time_contacted"; |
| 900 | |
Makoto Onuki | 203145e | 2016-09-28 15:41:29 -0700 | [diff] [blame] | 901 | /** @hide Raw value. */ |
| 902 | public static final String RAW_TIMES_CONTACTED = HIDDEN_COLUMN_PREFIX + TIMES_CONTACTED; |
| 903 | |
| 904 | /** @hide Raw value. */ |
| 905 | public static final String RAW_LAST_TIME_CONTACTED = |
| 906 | HIDDEN_COLUMN_PREFIX + LAST_TIME_CONTACTED; |
| 907 | |
| 908 | /** |
| 909 | * @hide |
| 910 | * Low res version. Same as {@link #TIMES_CONTACTED} but use it in CP2 for clarification. |
| 911 | */ |
| 912 | public static final String LR_TIMES_CONTACTED = TIMES_CONTACTED; |
| 913 | |
| 914 | /** |
| 915 | * @hide |
| 916 | * Low res version. Same as {@link #TIMES_CONTACTED} but use it in CP2 for clarification. |
| 917 | */ |
| 918 | public static final String LR_LAST_TIME_CONTACTED = LAST_TIME_CONTACTED; |
| 919 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 920 | /** |
| 921 | * Is the contact starred? |
| 922 | * <P>Type: INTEGER (boolean)</P> |
| 923 | */ |
| 924 | public static final String STARRED = "starred"; |
| 925 | |
| 926 | /** |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 927 | * The position at which the contact is pinned. If {@link PinnedPositions#UNPINNED}, |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 928 | * the contact is not pinned. Also see {@link PinnedPositions}. |
| 929 | * <P>Type: INTEGER </P> |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 930 | */ |
| 931 | public static final String PINNED = "pinned"; |
| 932 | |
| 933 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 934 | * URI for a custom ringtone associated with the contact. If null or missing, |
| 935 | * the default ringtone is used. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 936 | * <P>Type: TEXT (URI to the ringtone)</P> |
| 937 | */ |
| 938 | public static final String CUSTOM_RINGTONE = "custom_ringtone"; |
| 939 | |
| 940 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 941 | * Whether the contact should always be sent to voicemail. If missing, |
| 942 | * defaults to false. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 943 | * <P>Type: INTEGER (0 for false, 1 for true)</P> |
| 944 | */ |
| 945 | public static final String SEND_TO_VOICEMAIL = "send_to_voicemail"; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 946 | } |
| 947 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 948 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 949 | * Columns of {@link ContactsContract.Contacts} that refer to intrinsic |
| 950 | * properties of the contact, as opposed to the user-specified options |
| 951 | * found in {@link ContactOptionsColumns}. |
| 952 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 953 | * @see Contacts |
| 954 | * @see ContactsContract.Data |
| 955 | * @see PhoneLookup |
| 956 | * @see ContactsContract.Contacts.AggregationSuggestions |
| 957 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 958 | protected interface ContactsColumns { |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 959 | /** |
| 960 | * The display name for the contact. |
| 961 | * <P>Type: TEXT</P> |
| 962 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 963 | public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY; |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 964 | |
| 965 | /** |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 966 | * Reference to the row in the RawContacts table holding the contact name. |
| 967 | * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 968 | */ |
| 969 | public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id"; |
| 970 | |
| 971 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 972 | * Reference to the row in the data table holding the photo. A photo can |
| 973 | * be referred to either by ID (this field) or by URI (see {@link #PHOTO_THUMBNAIL_URI} |
| 974 | * and {@link #PHOTO_URI}). |
| 975 | * If PHOTO_ID is null, consult {@link #PHOTO_URI} or {@link #PHOTO_THUMBNAIL_URI}, |
| 976 | * which is a more generic mechanism for referencing the contact photo, especially for |
| 977 | * contacts returned by non-local directories (see {@link Directory}). |
| 978 | * |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 979 | * <P>Type: INTEGER REFERENCES data(_id)</P> |
| 980 | */ |
| 981 | public static final String PHOTO_ID = "photo_id"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 982 | |
| 983 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 984 | * Photo file ID of the full-size photo. If present, this will be used to populate |
| 985 | * {@link #PHOTO_URI}. The ID can also be used with |
| 986 | * {@link ContactsContract.DisplayPhoto#CONTENT_URI} to create a URI to the photo. |
| 987 | * If this is present, {@link #PHOTO_ID} is also guaranteed to be populated. |
| 988 | * |
| 989 | * <P>Type: INTEGER</P> |
| 990 | */ |
| 991 | public static final String PHOTO_FILE_ID = "photo_file_id"; |
| 992 | |
| 993 | /** |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 994 | * 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] | 995 | * If PHOTO_FILE_ID is not null, this will be populated with a URI based off |
| 996 | * {@link ContactsContract.DisplayPhoto#CONTENT_URI}. Otherwise, this will |
| 997 | * be populated with the same value as {@link #PHOTO_THUMBNAIL_URI}. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 998 | * 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] | 999 | * (see {@link #PHOTO_ID}). If either PHOTO_FILE_ID or PHOTO_ID is not null, |
| 1000 | * PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily |
| 1001 | * vice versa). Thus using PHOTO_URI is a more robust method of retrieving |
| 1002 | * contact photos. |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 1003 | * |
| 1004 | * <P>Type: TEXT</P> |
| 1005 | */ |
| 1006 | public static final String PHOTO_URI = "photo_uri"; |
| 1007 | |
| 1008 | /** |
| 1009 | * A URI that can be used to retrieve a thumbnail of the contact's photo. |
| 1010 | * A photo can be referred to either by a URI (this field or {@link #PHOTO_URI}) |
| 1011 | * or by ID (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and |
| 1012 | * PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa). |
| 1013 | * If the content provider does not differentiate between full-size photos |
| 1014 | * and thumbnail photos, PHOTO_THUMBNAIL_URI and {@link #PHOTO_URI} can contain |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 1015 | * 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] | 1016 | * |
| 1017 | * <P>Type: TEXT</P> |
| 1018 | */ |
| 1019 | public static final String PHOTO_THUMBNAIL_URI = "photo_thumb_uri"; |
| 1020 | |
| 1021 | /** |
Brian Attwell | 2fa85d3 | 2014-03-04 17:41:13 -0800 | [diff] [blame] | 1022 | * Flag that reflects whether the contact exists inside the default directory. |
| 1023 | * Ie, whether the contact is designed to only be visible outside search. |
Brian Attwell | 2fa85d3 | 2014-03-04 17:41:13 -0800 | [diff] [blame] | 1024 | */ |
| 1025 | public static final String IN_DEFAULT_DIRECTORY = "in_default_directory"; |
| 1026 | |
| 1027 | /** |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 1028 | * Flag that reflects the {@link Groups#GROUP_VISIBLE} state of any |
| 1029 | * {@link CommonDataKinds.GroupMembership} for this contact. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1030 | */ |
| 1031 | public static final String IN_VISIBLE_GROUP = "in_visible_group"; |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 1032 | |
| 1033 | /** |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 1034 | * Flag that reflects whether this contact represents the user's |
| 1035 | * personal profile entry. |
| 1036 | */ |
| 1037 | public static final String IS_USER_PROFILE = "is_user_profile"; |
| 1038 | |
| 1039 | /** |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 1040 | * An indicator of whether this contact has at least one phone number. "1" if there is |
| 1041 | * at least one phone number, "0" otherwise. |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 1042 | * <P>Type: INTEGER</P> |
| 1043 | */ |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 1044 | public static final String HAS_PHONE_NUMBER = "has_phone_number"; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1045 | |
| 1046 | /** |
| 1047 | * An opaque value that contains hints on how to find the contact if |
| 1048 | * its row id changed as a result of a sync or aggregation. |
| 1049 | */ |
| 1050 | public static final String LOOKUP_KEY = "lookup"; |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 1051 | |
| 1052 | /** |
| 1053 | * Timestamp (milliseconds since epoch) of when this contact was last updated. This |
| 1054 | * includes updates to all data associated with this contact including raw contacts. Any |
| 1055 | * modification (including deletes and inserts) of underlying contact data are also |
| 1056 | * reflected in this timestamp. |
| 1057 | */ |
| 1058 | public static final String CONTACT_LAST_UPDATED_TIMESTAMP = |
| 1059 | "contact_last_updated_timestamp"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1060 | } |
| 1061 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1062 | /** |
| 1063 | * @see Contacts |
| 1064 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 1065 | protected interface ContactStatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 1066 | /** |
| 1067 | * Contact presence status. See {@link StatusUpdates} for individual status |
| 1068 | * definitions. |
| 1069 | * <p>Type: NUMBER</p> |
| 1070 | */ |
| 1071 | public static final String CONTACT_PRESENCE = "contact_presence"; |
| 1072 | |
| 1073 | /** |
Vasu Nori | fb5bccf | 2010-07-19 14:11:54 -0700 | [diff] [blame] | 1074 | * Contact Chat Capabilities. See {@link StatusUpdates} for individual |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 1075 | * definitions. |
| 1076 | * <p>Type: NUMBER</p> |
| 1077 | */ |
| 1078 | public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability"; |
| 1079 | |
| 1080 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 1081 | * Contact's latest status update. |
| 1082 | * <p>Type: TEXT</p> |
| 1083 | */ |
| 1084 | public static final String CONTACT_STATUS = "contact_status"; |
| 1085 | |
| 1086 | /** |
| 1087 | * The absolute time in milliseconds when the latest status was |
| 1088 | * inserted/updated. |
| 1089 | * <p>Type: NUMBER</p> |
| 1090 | */ |
| 1091 | public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts"; |
| 1092 | |
| 1093 | /** |
| 1094 | * The package containing resources for this status: label and icon. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1095 | * <p>Type: TEXT</p> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 1096 | */ |
| 1097 | public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package"; |
| 1098 | |
| 1099 | /** |
| 1100 | * The resource ID of the label describing the source of contact |
| 1101 | * status, e.g. "Google Talk". This resource is scoped by the |
| 1102 | * {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 1103 | * <p>Type: NUMBER</p> |
| 1104 | */ |
| 1105 | public static final String CONTACT_STATUS_LABEL = "contact_status_label"; |
| 1106 | |
| 1107 | /** |
| 1108 | * The resource ID of the icon for the source of contact status. This |
| 1109 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 1110 | * <p>Type: NUMBER</p> |
| 1111 | */ |
| 1112 | public static final String CONTACT_STATUS_ICON = "contact_status_icon"; |
| 1113 | } |
| 1114 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1115 | /** |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1116 | * Constants for various styles of combining given name, family name etc into |
| 1117 | * a full name. For example, the western tradition follows the pattern |
| 1118 | * 'given name' 'middle name' 'family name' with the alternative pattern being |
| 1119 | * 'family name', 'given name' 'middle name'. The CJK tradition is |
| 1120 | * 'family name' 'middle name' 'given name', with Japanese favoring a space between |
| 1121 | * the names and Chinese omitting the space. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1122 | */ |
| 1123 | public interface FullNameStyle { |
| 1124 | public static final int UNDEFINED = 0; |
| 1125 | public static final int WESTERN = 1; |
| 1126 | |
| 1127 | /** |
| 1128 | * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine |
| 1129 | * which specific language it belongs to: Chinese, Japanese or Korean. |
| 1130 | */ |
| 1131 | public static final int CJK = 2; |
| 1132 | |
| 1133 | public static final int CHINESE = 3; |
| 1134 | public static final int JAPANESE = 4; |
| 1135 | public static final int KOREAN = 5; |
| 1136 | } |
| 1137 | |
| 1138 | /** |
| 1139 | * 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] | 1140 | */ |
| 1141 | public interface PhoneticNameStyle { |
| 1142 | public static final int UNDEFINED = 0; |
| 1143 | |
| 1144 | /** |
| 1145 | * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly |
| 1146 | * shown in UIs, but used for searches and sorting. |
| 1147 | */ |
| 1148 | public static final int PINYIN = 3; |
| 1149 | |
| 1150 | /** |
| 1151 | * Hiragana and Katakana are two common styles of writing out the pronunciation |
| 1152 | * of a Japanese names. |
| 1153 | */ |
| 1154 | public static final int JAPANESE = 4; |
| 1155 | |
| 1156 | /** |
| 1157 | * Hangul is the Korean phonetic alphabet. |
| 1158 | */ |
| 1159 | public static final int KOREAN = 5; |
| 1160 | } |
| 1161 | |
| 1162 | /** |
Dmitri Plotnikov | dbcdbf2 | 2011-02-23 15:49:58 -0800 | [diff] [blame] | 1163 | * Types of data used to produce the display name for a contact. In the order |
| 1164 | * of increasing priority: {@link #EMAIL}, {@link #PHONE}, |
Brian Attwell | 643db51 | 2015-03-04 21:05:27 -0800 | [diff] [blame] | 1165 | * {@link #ORGANIZATION}, {@link #NICKNAME}, {@link #STRUCTURED_PHONETIC_NAME}, |
| 1166 | * {@link #STRUCTURED_NAME}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1167 | */ |
| 1168 | public interface DisplayNameSources { |
| 1169 | public static final int UNDEFINED = 0; |
| 1170 | public static final int EMAIL = 10; |
| 1171 | public static final int PHONE = 20; |
| 1172 | public static final int ORGANIZATION = 30; |
| 1173 | public static final int NICKNAME = 35; |
Brian Attwell | 643db51 | 2015-03-04 21:05:27 -0800 | [diff] [blame] | 1174 | /** Display name comes from a structured name that only has phonetic components. */ |
| 1175 | public static final int STRUCTURED_PHONETIC_NAME = 37; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1176 | public static final int STRUCTURED_NAME = 40; |
| 1177 | } |
| 1178 | |
| 1179 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 1180 | * Contact name and contact name metadata columns in the RawContacts table. |
| 1181 | * |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1182 | * @see Contacts |
| 1183 | * @see RawContacts |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1184 | */ |
| 1185 | protected interface ContactNameColumns { |
| 1186 | |
| 1187 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1188 | * 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] | 1189 | * structured name or email address. See {@link DisplayNameSources}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1190 | */ |
| 1191 | public static final String DISPLAY_NAME_SOURCE = "display_name_source"; |
| 1192 | |
| 1193 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1194 | * <p> |
| 1195 | * The standard text shown as the contact's display name, based on the best |
| 1196 | * available information for the contact (for example, it might be the email address |
| 1197 | * if the name is not available). |
| 1198 | * The information actually used to compute the name is stored in |
| 1199 | * {@link #DISPLAY_NAME_SOURCE}. |
| 1200 | * </p> |
| 1201 | * <p> |
| 1202 | * A contacts provider is free to choose whatever representation makes most |
| 1203 | * sense for its target market. |
| 1204 | * For example in the default Android Open Source Project implementation, |
| 1205 | * if the display name is |
| 1206 | * based on the structured name and the structured name follows |
| 1207 | * the Western full-name style, then this field contains the "given name first" |
| 1208 | * version of the full name. |
| 1209 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1210 | * |
| 1211 | * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1212 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1213 | public static final String DISPLAY_NAME_PRIMARY = "display_name"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1214 | |
| 1215 | /** |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1216 | * <p> |
| 1217 | * An alternative representation of the display name, such as "family name first" |
| 1218 | * instead of "given name first" for Western names. If an alternative is not |
| 1219 | * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}. |
| 1220 | * </p> |
| 1221 | * <p> |
| 1222 | * A contacts provider is free to provide alternatives as necessary for |
| 1223 | * its target market. |
| 1224 | * For example the default Android Open Source Project contacts provider |
| 1225 | * currently provides an |
| 1226 | * alternative in a single case: if the display name is |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1227 | * based on the structured name and the structured name follows |
Tom O'Neill | 093a870 | 2010-01-15 16:20:34 -0800 | [diff] [blame] | 1228 | * the Western full name style, then the field contains the "family name first" |
| 1229 | * version of the full name. |
| 1230 | * Other cases may be added later. |
| 1231 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1232 | */ |
| 1233 | public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt"; |
| 1234 | |
| 1235 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1236 | * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}. See |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 1237 | * {@link PhoneticNameStyle}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1238 | */ |
| 1239 | public static final String PHONETIC_NAME_STYLE = "phonetic_name_style"; |
| 1240 | |
| 1241 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1242 | * <p> |
| 1243 | * Pronunciation of the full name in the phonetic alphabet specified by |
| 1244 | * {@link #PHONETIC_NAME_STYLE}. |
| 1245 | * </p> |
| 1246 | * <p> |
Dmitri Plotnikov | 59024f1 | 2010-08-27 10:59:22 -0700 | [diff] [blame] | 1247 | * The value may be set manually by the user. This capability is of |
| 1248 | * interest only in countries with commonly used phonetic alphabets, |
| 1249 | * such as Japan and Korea. See {@link PhoneticNameStyle}. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1250 | * </p> |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1251 | */ |
| 1252 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 1253 | |
| 1254 | /** |
| 1255 | * Sort key that takes into account locale-based traditions for sorting |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1256 | * names in address books. The default |
| 1257 | * sort key is {@link #DISPLAY_NAME_PRIMARY}. For Chinese names |
| 1258 | * 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] | 1259 | * it is the Hiragana version of the phonetic name. |
| 1260 | */ |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1261 | public static final String SORT_KEY_PRIMARY = "sort_key"; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1262 | |
| 1263 | /** |
| 1264 | * Sort key based on the alternative representation of the full name, |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 1265 | * {@link #DISPLAY_NAME_ALTERNATIVE}. Thus for Western names, |
Dmitri Plotnikov | 2a650dd | 2010-01-26 17:28:52 -0800 | [diff] [blame] | 1266 | * it is the one using the "family name first" format. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 1267 | */ |
| 1268 | public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt"; |
| 1269 | } |
| 1270 | |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1271 | interface ContactCounts { |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1272 | |
| 1273 | /** |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1274 | * Add this query parameter to a URI to get back row counts grouped by the address book |
| 1275 | * index as cursor extras. For most languages it is the first letter of the sort key. This |
| 1276 | * parameter does not affect the main content of the cursor. |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1277 | * |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1278 | * <p> |
| 1279 | * <pre> |
| 1280 | * Example: |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1281 | * |
| 1282 | * import android.provider.ContactsContract.Contacts; |
| 1283 | * |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1284 | * Uri uri = Contacts.CONTENT_URI.buildUpon() |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1285 | * .appendQueryParameter(Contacts.EXTRA_ADDRESS_BOOK_INDEX, "true") |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1286 | * .build(); |
| 1287 | * Cursor cursor = getContentResolver().query(uri, |
| 1288 | * new String[] {Contacts.DISPLAY_NAME}, |
| 1289 | * null, null, null); |
| 1290 | * Bundle bundle = cursor.getExtras(); |
Yorke Lee | a4aa9dc | 2014-08-04 13:47:50 -0700 | [diff] [blame] | 1291 | * if (bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES) && |
| 1292 | * bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS)) { |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1293 | * String sections[] = |
Yorke Lee | a4aa9dc | 2014-08-04 13:47:50 -0700 | [diff] [blame] | 1294 | * bundle.getStringArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES); |
| 1295 | * int counts[] = bundle.getIntArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS); |
Yorke Lee | f4b2845 | 2014-05-27 19:41:35 -0700 | [diff] [blame] | 1296 | * } |
| 1297 | * </pre> |
| 1298 | * </p> |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1299 | */ |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1300 | public static final String EXTRA_ADDRESS_BOOK_INDEX = |
| 1301 | "android.provider.extra.ADDRESS_BOOK_INDEX"; |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1302 | |
| 1303 | /** |
| 1304 | * The array of address book index titles, which are returned in the |
| 1305 | * same order as the data in the cursor. |
| 1306 | * <p>TYPE: String[]</p> |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1307 | */ |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1308 | public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES = |
| 1309 | "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES"; |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1310 | |
| 1311 | /** |
| 1312 | * The array of group counts for the corresponding group. Contains the same number |
| 1313 | * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array. |
| 1314 | * <p>TYPE: int[]</p> |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1315 | */ |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 1316 | public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS = |
| 1317 | "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS"; |
Dmitri Plotnikov | 53de904 | 2010-02-17 10:57:19 -0800 | [diff] [blame] | 1318 | } |
| 1319 | |
| 1320 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1321 | * Constants for the contacts table, which contains a record per aggregate |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1322 | * of raw contacts representing the same person. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1323 | * <h3>Operations</h3> |
| 1324 | * <dl> |
| 1325 | * <dt><b>Insert</b></dt> |
| 1326 | * <dd>A Contact cannot be created explicitly. When a raw contact is |
| 1327 | * inserted, the provider will first try to find a Contact representing the |
| 1328 | * same person. If one is found, the raw contact's |
| 1329 | * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate |
| 1330 | * Contact. If no match is found, the provider automatically inserts a new |
| 1331 | * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column |
| 1332 | * of the newly inserted raw contact.</dd> |
| 1333 | * <dt><b>Update</b></dt> |
| 1334 | * <dd>Only certain columns of Contact are modifiable: |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 1335 | * {@link #STARRED}, {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1336 | * these columns on the Contact also changes them on all constituent raw |
| 1337 | * contacts.</dd> |
| 1338 | * <dt><b>Delete</b></dt> |
| 1339 | * <dd>Be careful with deleting Contacts! Deleting an aggregate contact |
| 1340 | * deletes all constituent raw contacts. The corresponding sync adapters |
| 1341 | * will notice the deletions of their respective raw contacts and remove |
| 1342 | * them from their back end storage.</dd> |
| 1343 | * <dt><b>Query</b></dt> |
| 1344 | * <dd> |
| 1345 | * <ul> |
| 1346 | * <li>If you need to read an individual contact, consider using |
| 1347 | * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li> |
| 1348 | * <li>If you need to look up a contact by the phone number, use |
| 1349 | * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI}, |
| 1350 | * which is optimized for this purpose.</li> |
| 1351 | * <li>If you need to look up a contact by partial name, e.g. to produce |
| 1352 | * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI. |
| 1353 | * <li>If you need to look up a contact by some data element like email |
| 1354 | * address, nickname, etc, use a query against the {@link ContactsContract.Data} table. |
| 1355 | * The result will contain contact ID, name etc. |
| 1356 | * </ul> |
| 1357 | * </dd> |
| 1358 | * </dl> |
| 1359 | * <h2>Columns</h2> |
| 1360 | * <table class="jd-sumtable"> |
| 1361 | * <tr> |
| 1362 | * <th colspan='4'>Contacts</th> |
| 1363 | * </tr> |
| 1364 | * <tr> |
| 1365 | * <td>long</td> |
| 1366 | * <td>{@link #_ID}</td> |
| 1367 | * <td>read-only</td> |
| 1368 | * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td> |
| 1369 | * </tr> |
| 1370 | * <tr> |
| 1371 | * <td>String</td> |
| 1372 | * <td>{@link #LOOKUP_KEY}</td> |
| 1373 | * <td>read-only</td> |
| 1374 | * <td>An opaque value that contains hints on how to find the contact if its |
| 1375 | * row id changed as a result of a sync or aggregation.</td> |
| 1376 | * </tr> |
| 1377 | * <tr> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1378 | * <td>long</td> |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1379 | * <td>NAME_RAW_CONTACT_ID</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1380 | * <td>read-only</td> |
| 1381 | * <td>The ID of the raw contact that contributes the display name |
| 1382 | * to the aggregate contact. During aggregation one of the constituent |
| 1383 | * raw contacts is chosen using a heuristic: a longer name or a name |
| 1384 | * with more diacritic marks or more upper case characters is chosen.</td> |
| 1385 | * </tr> |
| 1386 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1387 | * <td>String</td> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 1388 | * <td>DISPLAY_NAME_PRIMARY</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1389 | * <td>read-only</td> |
Dmitri Plotnikov | 9618608 | 2009-12-01 14:35:04 -0800 | [diff] [blame] | 1390 | * <td>The display name for the contact. It is the display name |
Dmitri Plotnikov | 780211a | 2009-12-02 22:00:32 -0800 | [diff] [blame] | 1391 | * 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] | 1392 | * column.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1393 | * </tr> |
| 1394 | * <tr> |
| 1395 | * <td>long</td> |
| 1396 | * <td>{@link #PHOTO_ID}</td> |
| 1397 | * <td>read-only</td> |
| 1398 | * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo. |
| 1399 | * That row has the mime type |
| 1400 | * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field |
| 1401 | * is computed automatically based on the |
| 1402 | * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of |
| 1403 | * that mime type.</td> |
| 1404 | * </tr> |
| 1405 | * <tr> |
Dmitri Plotnikov | 3a668fe | 2010-09-22 14:24:15 -0700 | [diff] [blame] | 1406 | * <td>long</td> |
| 1407 | * <td>{@link #PHOTO_URI}</td> |
| 1408 | * <td>read-only</td> |
| 1409 | * <td>A URI that can be used to retrieve the contact's full-size photo. This |
| 1410 | * column is the preferred method of retrieving the contact photo.</td> |
| 1411 | * </tr> |
| 1412 | * <tr> |
| 1413 | * <td>long</td> |
| 1414 | * <td>{@link #PHOTO_THUMBNAIL_URI}</td> |
| 1415 | * <td>read-only</td> |
| 1416 | * <td>A URI that can be used to retrieve the thumbnail of contact's photo. This |
| 1417 | * column is the preferred method of retrieving the contact photo.</td> |
| 1418 | * </tr> |
| 1419 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1420 | * <td>int</td> |
| 1421 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 1422 | * <td>read-only</td> |
| 1423 | * <td>An indicator of whether this contact is supposed to be visible in the |
| 1424 | * UI. "1" if the contact has at least one raw contact that belongs to a |
| 1425 | * visible group; "0" otherwise.</td> |
| 1426 | * </tr> |
| 1427 | * <tr> |
| 1428 | * <td>int</td> |
| 1429 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 1430 | * <td>read-only</td> |
| 1431 | * <td>An indicator of whether this contact has at least one phone number. |
| 1432 | * "1" if there is at least one phone number, "0" otherwise.</td> |
| 1433 | * </tr> |
| 1434 | * <tr> |
| 1435 | * <td>int</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1436 | * <td>{@link #STARRED}</td> |
| 1437 | * <td>read/write</td> |
| 1438 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
| 1439 | * When raw contacts are aggregated, this field is automatically computed: |
| 1440 | * if any constituent raw contacts are starred, then this field is set to |
| 1441 | * '1'. Setting this field automatically changes the corresponding field on |
| 1442 | * all constituent raw contacts.</td> |
| 1443 | * </tr> |
| 1444 | * <tr> |
| 1445 | * <td>String</td> |
| 1446 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 1447 | * <td>read/write</td> |
| 1448 | * <td>A custom ringtone associated with a contact. Typically this is the |
| 1449 | * URI returned by an activity launched with the |
| 1450 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td> |
| 1451 | * </tr> |
| 1452 | * <tr> |
| 1453 | * <td>int</td> |
| 1454 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 1455 | * <td>read/write</td> |
| 1456 | * <td>An indicator of whether calls from this contact should be forwarded |
| 1457 | * directly to voice mail ('1') or not ('0'). When raw contacts are |
| 1458 | * aggregated, this field is automatically computed: if <i>all</i> |
| 1459 | * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set |
| 1460 | * to '1'. Setting this field automatically changes the corresponding field |
| 1461 | * on all constituent raw contacts.</td> |
| 1462 | * </tr> |
| 1463 | * <tr> |
| 1464 | * <td>int</td> |
| 1465 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 1466 | * <td>read-only</td> |
| 1467 | * <td>Contact IM presence status. See {@link StatusUpdates} for individual |
| 1468 | * status definitions. Automatically computed as the highest presence of all |
| 1469 | * constituent raw contacts. The provider may choose not to store this value |
| 1470 | * in persistent storage. The expectation is that presence status will be |
kmccormick | 50e27c8 | 2013-03-28 16:33:11 -0700 | [diff] [blame] | 1471 | * updated on a regular basis.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1472 | * </tr> |
| 1473 | * <tr> |
| 1474 | * <td>String</td> |
| 1475 | * <td>{@link #CONTACT_STATUS}</td> |
| 1476 | * <td>read-only</td> |
| 1477 | * <td>Contact's latest status update. Automatically computed as the latest |
| 1478 | * of all constituent raw contacts' status updates.</td> |
| 1479 | * </tr> |
| 1480 | * <tr> |
| 1481 | * <td>long</td> |
| 1482 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 1483 | * <td>read-only</td> |
| 1484 | * <td>The absolute time in milliseconds when the latest status was |
| 1485 | * inserted/updated.</td> |
| 1486 | * </tr> |
| 1487 | * <tr> |
| 1488 | * <td>String</td> |
| 1489 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 1490 | * <td>read-only</td> |
| 1491 | * <td> The package containing resources for this status: label and icon.</td> |
| 1492 | * </tr> |
| 1493 | * <tr> |
| 1494 | * <td>long</td> |
| 1495 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 1496 | * <td>read-only</td> |
| 1497 | * <td>The resource ID of the label describing the source of contact status, |
| 1498 | * e.g. "Google Talk". This resource is scoped by the |
| 1499 | * {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1500 | * </tr> |
| 1501 | * <tr> |
| 1502 | * <td>long</td> |
| 1503 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 1504 | * <td>read-only</td> |
| 1505 | * <td>The resource ID of the icon for the source of contact status. This |
| 1506 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td> |
| 1507 | * </tr> |
| 1508 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1509 | */ |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 1510 | public static class Contacts implements BaseColumns, ContactsColumns, |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 1511 | ContactOptionsColumns, ContactNameColumns, ContactStatusColumns, ContactCounts { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1512 | /** |
| 1513 | * This utility class cannot be instantiated |
| 1514 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1515 | private Contacts() {} |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1516 | |
| 1517 | /** |
| 1518 | * The content:// style URI for this table |
| 1519 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1520 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1521 | |
| 1522 | /** |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 1523 | * Special contacts URI to refer to contacts on the corp profile from the personal |
| 1524 | * profile. |
| 1525 | * |
| 1526 | * It's supported only by a few specific places for referring to contact pictures that |
| 1527 | * are in the corp provider for enterprise caller-ID. Contact picture URIs returned from |
| 1528 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may contain this kind of URI. |
| 1529 | * |
| 1530 | * @hide |
| 1531 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 1532 | @UnsupportedAppUsage |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 1533 | public static final Uri CORP_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 1534 | "contacts_corp"); |
| 1535 | |
| 1536 | /** |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1537 | * A content:// style URI for this table that should be used to create |
| 1538 | * shortcuts or otherwise create long-term links to contacts. This URI |
| 1539 | * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}. |
| 1540 | * It can optionally also have a "/" and last known contact ID appended after |
| 1541 | * that. This "complete" format is an important optimization and is highly recommended. |
| 1542 | * <p> |
| 1543 | * As long as the contact's row ID remains the same, this URI is |
| 1544 | * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes |
| 1545 | * as a result of a sync or aggregation, this URI will look up the |
| 1546 | * contact using indirect information (sync IDs or constituent raw |
| 1547 | * contacts). |
| 1548 | * <p> |
| 1549 | * Lookup key should be appended unencoded - it is stored in the encoded |
| 1550 | * form, ready for use in a URI. |
| 1551 | */ |
| 1552 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1553 | "lookup"); |
| 1554 | |
| 1555 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1556 | * Base {@link Uri} for referencing a single {@link Contacts} entry, |
Jeff Sharkey | 8f76734 | 2009-09-28 18:22:46 -0700 | [diff] [blame] | 1557 | * created by appending {@link #LOOKUP_KEY} using |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1558 | * {@link Uri#withAppendedPath(Uri, String)}. Provides |
| 1559 | * {@link OpenableColumns} columns when queried, or returns the |
| 1560 | * referenced contact formatted as a vCard when opened through |
| 1561 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1562 | */ |
| 1563 | public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1564 | "as_vcard"); |
| 1565 | |
Martijn Coenen | 037d3ff | 2011-06-15 16:01:45 +0200 | [diff] [blame] | 1566 | /** |
| 1567 | * Boolean parameter that may be used with {@link #CONTENT_VCARD_URI} |
| 1568 | * and {@link #CONTENT_MULTI_VCARD_URI} to indicate that the returned |
| 1569 | * vcard should not contain a photo. |
| 1570 | * |
Brian Attwell | f9fb60a | 2015-02-02 12:16:13 -0800 | [diff] [blame] | 1571 | * This is useful for obtaining a space efficient vcard. |
Martijn Coenen | 037d3ff | 2011-06-15 16:01:45 +0200 | [diff] [blame] | 1572 | */ |
Brian Attwell | f9fb60a | 2015-02-02 12:16:13 -0800 | [diff] [blame] | 1573 | public static final String QUERY_PARAMETER_VCARD_NO_PHOTO = "no_photo"; |
Martijn Coenen | 037d3ff | 2011-06-15 16:01:45 +0200 | [diff] [blame] | 1574 | |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1575 | /** |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1576 | * Base {@link Uri} for referencing multiple {@link Contacts} entry, |
| 1577 | * created by appending {@link #LOOKUP_KEY} using |
| 1578 | * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 1579 | * joined with the colon (":") separator, and the resulting string encoded. |
| 1580 | * |
| 1581 | * Provides {@link OpenableColumns} columns when queried, or returns the |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1582 | * referenced contact formatted as a vCard when opened through |
| 1583 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 1584 | * |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 1585 | * <p> |
| 1586 | * Usage example: |
| 1587 | * <dl> |
| 1588 | * <dt>The following code snippet creates a multi-vcard URI that references all the |
| 1589 | * contacts in a user's database.</dt> |
| 1590 | * <dd> |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1591 | * |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 1592 | * <pre> |
| 1593 | * public Uri getAllContactsVcardUri() { |
| 1594 | * Cursor cursor = getActivity().getContentResolver().query(Contacts.CONTENT_URI, |
| 1595 | * new String[] {Contacts.LOOKUP_KEY}, null, null, null); |
| 1596 | * if (cursor == null) { |
| 1597 | * return null; |
| 1598 | * } |
| 1599 | * try { |
| 1600 | * StringBuilder uriListBuilder = new StringBuilder(); |
| 1601 | * int index = 0; |
| 1602 | * while (cursor.moveToNext()) { |
| 1603 | * if (index != 0) uriListBuilder.append(':'); |
| 1604 | * uriListBuilder.append(cursor.getString(0)); |
| 1605 | * index++; |
| 1606 | * } |
| 1607 | * return Uri.withAppendedPath(Contacts.CONTENT_MULTI_VCARD_URI, |
| 1608 | * Uri.encode(uriListBuilder.toString())); |
| 1609 | * } finally { |
| 1610 | * cursor.close(); |
| 1611 | * } |
| 1612 | * } |
| 1613 | * </pre> |
| 1614 | * |
| 1615 | * </p> |
Daniel Lehmann | 63e9140 | 2010-03-12 13:44:31 -0800 | [diff] [blame] | 1616 | */ |
| 1617 | public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1618 | "as_multi_vcard"); |
| 1619 | |
| 1620 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1621 | * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the |
| 1622 | * requested {@link Contacts} entry. |
| 1623 | * |
| 1624 | * @param contactUri A {@link #CONTENT_URI} row, or an existing |
| 1625 | * {@link #CONTENT_LOOKUP_URI} to attempt refreshing. |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1626 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1627 | public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) { |
| 1628 | final Cursor c = resolver.query(contactUri, new String[] { |
| 1629 | Contacts.LOOKUP_KEY, Contacts._ID |
| 1630 | }, null, null, null); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1631 | if (c == null) { |
| 1632 | return null; |
| 1633 | } |
| 1634 | |
| 1635 | try { |
| 1636 | if (c.moveToFirst()) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 1637 | final String lookupKey = c.getString(0); |
| 1638 | final long contactId = c.getLong(1); |
| 1639 | return getLookupUri(contactId, lookupKey); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 1640 | } |
| 1641 | } finally { |
| 1642 | c.close(); |
| 1643 | } |
| 1644 | return null; |
| 1645 | } |
| 1646 | |
| 1647 | /** |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1648 | * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1649 | * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}. |
Jay Shrauner | 1ebaff2 | 2015-03-12 15:24:16 -0700 | [diff] [blame] | 1650 | * <p> |
| 1651 | * Returns null if unable to construct a valid lookup URI from the |
| 1652 | * provided parameters. |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1653 | */ |
| 1654 | public static Uri getLookupUri(long contactId, String lookupKey) { |
Jay Shrauner | 1ebaff2 | 2015-03-12 15:24:16 -0700 | [diff] [blame] | 1655 | if (TextUtils.isEmpty(lookupKey)) { |
| 1656 | return null; |
| 1657 | } |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 1658 | return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, |
| 1659 | lookupKey), contactId); |
| 1660 | } |
| 1661 | |
| 1662 | /** |
Dmitri Plotnikov | b5759b5 | 2009-09-01 15:58:40 -0700 | [diff] [blame] | 1663 | * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI. |
| 1664 | * <p> |
| 1665 | * Returns null if the contact cannot be found. |
| 1666 | */ |
| 1667 | public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) { |
| 1668 | if (lookupUri == null) { |
| 1669 | return null; |
| 1670 | } |
| 1671 | |
| 1672 | Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null); |
| 1673 | if (c == null) { |
| 1674 | return null; |
| 1675 | } |
| 1676 | |
| 1677 | try { |
| 1678 | if (c.moveToFirst()) { |
| 1679 | long contactId = c.getLong(0); |
| 1680 | return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 1681 | } |
| 1682 | } finally { |
| 1683 | c.close(); |
| 1684 | } |
| 1685 | return null; |
| 1686 | } |
| 1687 | |
| 1688 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1689 | * Mark a contact as having been contacted. Updates two fields: |
| 1690 | * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED}. The |
| 1691 | * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED |
| 1692 | * field is populated with the current system time. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1693 | * |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 1694 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this method is obsolete. For |
| 1695 | * more information, see the |
| 1696 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 1697 | * page. |
| 1698 | * |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1699 | * @param resolver the ContentResolver to use |
| 1700 | * @param contactId the person who was contacted |
Daniel Lehmann | a1620dc | 2012-04-13 13:29:49 -0700 | [diff] [blame] | 1701 | * |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 1702 | * @deprecated Contacts affinity information is no longer supported as of |
| 1703 | * Android version {@link android.os.Build.VERSION_CODES#Q}. This method |
| 1704 | * is no-op. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1705 | */ |
Daniel Lehmann | a1620dc | 2012-04-13 13:29:49 -0700 | [diff] [blame] | 1706 | @Deprecated |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1707 | public static void markAsContacted(ContentResolver resolver, long contactId) { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1708 | } |
| 1709 | |
| 1710 | /** |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1711 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1712 | * {@link #CONTENT_URI} URI. The filter string will be used to match |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1713 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1714 | * as an additional path segment after this URI. |
| 1715 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1716 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 1717 | CONTENT_URI, "filter"); |
| 1718 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1719 | /** |
Ricky Wai | 6b38e06 | 2015-11-26 23:21:39 +0000 | [diff] [blame] | 1720 | * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same |
| 1721 | * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in parameters, |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 1722 | * otherwise it will throw IllegalArgumentException. |
Ricky Wai | a5efc47 | 2015-11-16 12:25:45 +0000 | [diff] [blame] | 1723 | */ |
Ricky Wai | 6b38e06 | 2015-11-26 23:21:39 +0000 | [diff] [blame] | 1724 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 1725 | CONTENT_URI, "filter_enterprise"); |
Ricky Wai | a5efc47 | 2015-11-16 12:25:45 +0000 | [diff] [blame] | 1726 | |
| 1727 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1728 | * The content:// style URI for this table joined with useful data from |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 1729 | * {@link ContactsContract.Data}, filtered to include only starred contacts. |
| 1730 | * Frequent contacts are no longer included in the result as of |
| 1731 | * Android version {@link android.os.Build.VERSION_CODES#Q}. |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 1732 | * |
| 1733 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts |
| 1734 | * results based on contacts frequency. For more information, see the |
| 1735 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 1736 | * page. |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1737 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1738 | public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath( |
| 1739 | CONTENT_URI, "strequent"); |
| 1740 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1741 | /** |
Yorke Lee | 8d37009 | 2014-06-26 10:32:17 -0700 | [diff] [blame] | 1742 | * The content:// style URI for showing a list of frequently contacted people. |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 1743 | * |
| 1744 | * @deprecated Frequent contacts are no longer supported as of |
| 1745 | * Android version {@link android.os.Build.VERSION_CODES#Q}. |
| 1746 | * This URI always returns an empty cursor. |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 1747 | * |
| 1748 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts |
| 1749 | * results based on contacts frequency. For more information, see the |
| 1750 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 1751 | * page. |
Daisuke Miyakawa | 3604bc5 | 2011-07-21 10:14:32 -0700 | [diff] [blame] | 1752 | */ |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 1753 | @Deprecated |
Daisuke Miyakawa | 3604bc5 | 2011-07-21 10:14:32 -0700 | [diff] [blame] | 1754 | public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath( |
| 1755 | CONTENT_URI, "frequent"); |
| 1756 | |
| 1757 | /** |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 1758 | * <p>The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1759 | * {@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] | 1760 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1761 | * as an additional path segment after this URI. |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 1762 | * |
| 1763 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts |
| 1764 | * results based on contacts frequency. For more information, see the |
| 1765 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 1766 | * page. |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 1767 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1768 | public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath( |
| 1769 | CONTENT_STREQUENT_URI, "filter"); |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1770 | |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 1771 | public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath( |
| 1772 | CONTENT_URI, "group"); |
| 1773 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 1774 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1775 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 1776 | * people. |
| 1777 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1778 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1779 | |
| 1780 | /** |
| 1781 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1782 | * person. |
| 1783 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1784 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1785 | |
| 1786 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1787 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 1788 | * person. |
| 1789 | */ |
| 1790 | public static final String CONTENT_VCARD_TYPE = "text/x-vcard"; |
| 1791 | |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 1792 | /** |
| 1793 | * Mimimal ID for corp contacts returned from |
| 1794 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
| 1795 | * |
| 1796 | * @hide |
| 1797 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 1798 | 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] | 1799 | |
| 1800 | /** |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 1801 | * Prefix for corp contacts returned from |
| 1802 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
| 1803 | * |
| 1804 | * @hide |
| 1805 | */ |
| 1806 | public static String ENTERPRISE_CONTACT_LOOKUP_PREFIX = "c-"; |
| 1807 | |
| 1808 | /** |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 1809 | * 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] | 1810 | * |
| 1811 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may return such a contact. |
| 1812 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 1813 | public static boolean isEnterpriseContactId(long contactId) { |
| 1814 | return (contactId >= ENTERPRISE_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID); |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 1815 | } |
| 1816 | |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 1817 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1818 | * 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] | 1819 | * {@link ContactsContract.Data} rows. This directory can be used either |
| 1820 | * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1821 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1822 | public static final class Data implements BaseColumns, DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1823 | /** |
| 1824 | * no public constructor since this is a utility class |
| 1825 | */ |
| 1826 | private Data() {} |
| 1827 | |
| 1828 | /** |
| 1829 | * The directory twig for this sub-table |
| 1830 | */ |
| 1831 | public static final String CONTENT_DIRECTORY = "data"; |
| 1832 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1833 | |
| 1834 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1835 | * <p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1836 | * A sub-directory of a contact that contains all of its |
| 1837 | * {@link ContactsContract.RawContacts} as well as |
| 1838 | * {@link ContactsContract.Data} rows. To access this directory append |
| 1839 | * {@link #CONTENT_DIRECTORY} to the contact URI. |
| 1840 | * </p> |
| 1841 | * <p> |
| 1842 | * Entity has three ID fields: {@link #CONTACT_ID} for the contact, |
| 1843 | * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for |
| 1844 | * the data rows. Entity always contains at least one row per |
| 1845 | * constituent raw contact, even if there are no actual data rows. In |
| 1846 | * this case the {@link #DATA_ID} field will be null. |
| 1847 | * </p> |
| 1848 | * <p> |
| 1849 | * Entity reads all data for the entire contact in one transaction, to |
| 1850 | * guarantee consistency. There is significant data duplication |
| 1851 | * in the Entity (each row repeats all Contact columns and all RawContact |
| 1852 | * columns), so the benefits of transactional consistency should be weighed |
| 1853 | * against the cost of transferring large amounts of denormalized data |
| 1854 | * from the Provider. |
| 1855 | * </p> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 1856 | * <p> |
| 1857 | * To reduce the amount of data duplication the contacts provider and directory |
| 1858 | * providers implementing this protocol are allowed to provide common Contacts |
| 1859 | * and RawContacts fields in the first row returned for each raw contact only and |
| 1860 | * leave them as null in subsequent rows. |
| 1861 | * </p> |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1862 | */ |
| 1863 | public static final class Entity implements BaseColumns, ContactsColumns, |
| 1864 | ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns, |
Paul Soulos | 42cdda8 | 2014-06-19 16:13:38 -0700 | [diff] [blame] | 1865 | StatusColumns, ContactOptionsColumns, ContactStatusColumns, DataUsageStatColumns { |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1866 | /** |
| 1867 | * no public constructor since this is a utility class |
| 1868 | */ |
| 1869 | private Entity() { |
| 1870 | } |
| 1871 | |
| 1872 | /** |
| 1873 | * The directory twig for this sub-table |
| 1874 | */ |
| 1875 | public static final String CONTENT_DIRECTORY = "entities"; |
| 1876 | |
| 1877 | /** |
| 1878 | * The ID of the raw contact row. |
| 1879 | * <P>Type: INTEGER</P> |
| 1880 | */ |
| 1881 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 1882 | |
| 1883 | /** |
| 1884 | * The ID of the data row. The value will be null if this raw contact has no |
| 1885 | * data rows. |
| 1886 | * <P>Type: INTEGER</P> |
| 1887 | */ |
| 1888 | public static final String DATA_ID = "data_id"; |
| 1889 | } |
| 1890 | |
| 1891 | /** |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 1892 | * <p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1893 | * A sub-directory of a single contact that contains all of the constituent raw contact |
| 1894 | * {@link ContactsContract.StreamItems} rows. This directory can be used either |
| 1895 | * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}. |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 1896 | * </p> |
| 1897 | * <p> |
| 1898 | * Querying for social stream data requires android.permission.READ_SOCIAL_STREAM |
| 1899 | * permission. |
| 1900 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1901 | * |
| 1902 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 1903 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 1904 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 1905 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1906 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1907 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1908 | public static final class StreamItems implements StreamItemsColumns { |
| 1909 | /** |
| 1910 | * no public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1911 | * |
| 1912 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 1913 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1914 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 1915 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 1916 | private StreamItems() {} |
| 1917 | |
| 1918 | /** |
| 1919 | * The directory twig for this sub-table |
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 | public static final String CONTENT_DIRECTORY = "stream_items"; |
| 1926 | } |
| 1927 | |
| 1928 | /** |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 1929 | * <p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 1930 | * A <i>read-only</i> sub-directory of a single contact aggregate that |
| 1931 | * contains all aggregation suggestions (other contacts). The |
| 1932 | * aggregation suggestions are computed based on approximate data |
| 1933 | * matches with this contact. |
| 1934 | * </p> |
| 1935 | * <p> |
| 1936 | * <i>Note: this query may be expensive! If you need to use it in bulk, |
| 1937 | * make sure the user experience is acceptable when the query runs for a |
| 1938 | * long time.</i> |
| 1939 | * <p> |
| 1940 | * Usage example: |
| 1941 | * |
| 1942 | * <pre> |
| 1943 | * Uri uri = Contacts.CONTENT_URI.buildUpon() |
| 1944 | * .appendEncodedPath(String.valueOf(contactId)) |
| 1945 | * .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY) |
| 1946 | * .appendQueryParameter("limit", "3") |
| 1947 | * .build() |
| 1948 | * Cursor cursor = getContentResolver().query(suggestionsUri, |
| 1949 | * new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY}, |
| 1950 | * null, null, null); |
| 1951 | * </pre> |
| 1952 | * |
| 1953 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1954 | * <p> |
| 1955 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 1956 | * {@link #CONTENT_LOOKUP_URI}. |
| 1957 | * </p> |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1958 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 1959 | public static final class AggregationSuggestions implements BaseColumns, ContactsColumns, |
| 1960 | ContactOptionsColumns, ContactStatusColumns { |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1961 | /** |
| 1962 | * No public constructor since this is a utility class |
| 1963 | */ |
| 1964 | private AggregationSuggestions() {} |
| 1965 | |
| 1966 | /** |
Dmitri Plotnikov | 0fc0244 | 2009-09-21 13:26:28 -0700 | [diff] [blame] | 1967 | * 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] | 1968 | * type-to-filter, similar to |
| 1969 | * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}. |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1970 | */ |
| 1971 | public static final String CONTENT_DIRECTORY = "suggestions"; |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1972 | |
| 1973 | /** |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1974 | * 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] | 1975 | * |
| 1976 | * @hide |
| 1977 | */ |
| 1978 | public static final String PARAMETER_MATCH_NAME = "name"; |
| 1979 | |
| 1980 | /** |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1981 | * A convenience builder for aggregation suggestion content URIs. |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1982 | */ |
| 1983 | public static final class Builder { |
| 1984 | private long mContactId; |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1985 | private final ArrayList<String> mValues = new ArrayList<String>(); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 1986 | private int mLimit; |
| 1987 | |
| 1988 | /** |
| 1989 | * Optional existing contact ID. If it is not provided, the search |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 1990 | * will be based exclusively on the values supplied with {@link #addNameParameter}. |
| 1991 | * |
| 1992 | * @param contactId contact to find aggregation suggestions for |
| 1993 | * @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] | 1994 | */ |
| 1995 | public Builder setContactId(long contactId) { |
| 1996 | this.mContactId = contactId; |
| 1997 | return this; |
| 1998 | } |
| 1999 | |
| 2000 | /** |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2001 | * Add a name to be used when searching for aggregation suggestions. |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2002 | * |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2003 | * @param name name to find aggregation suggestions for |
| 2004 | * @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] | 2005 | */ |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2006 | public Builder addNameParameter(String name) { |
| 2007 | mValues.add(name); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2008 | return this; |
| 2009 | } |
| 2010 | |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2011 | /** |
| 2012 | * Sets the Maximum number of suggested aggregations that should be returned. |
| 2013 | * @param limit The maximum number of suggested aggregations |
| 2014 | * |
| 2015 | * @return This Builder object to allow for chaining of calls to builder methods |
| 2016 | */ |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2017 | public Builder setLimit(int limit) { |
| 2018 | mLimit = limit; |
| 2019 | return this; |
| 2020 | } |
| 2021 | |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2022 | /** |
| 2023 | * Combine all of the options that have been set and return a new {@link Uri} |
| 2024 | * object for fetching aggregation suggestions. |
| 2025 | */ |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2026 | public Uri build() { |
| 2027 | android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon(); |
| 2028 | builder.appendEncodedPath(String.valueOf(mContactId)); |
| 2029 | builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY); |
| 2030 | if (mLimit != 0) { |
| 2031 | builder.appendQueryParameter("limit", String.valueOf(mLimit)); |
| 2032 | } |
| 2033 | |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2034 | int count = mValues.size(); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2035 | for (int i = 0; i < count; i++) { |
Brian Attwell | 9ffad07 | 2015-01-21 16:28:59 -0800 | [diff] [blame] | 2036 | builder.appendQueryParameter("query", PARAMETER_MATCH_NAME |
| 2037 | + ":" + mValues.get(i)); |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2038 | } |
| 2039 | |
| 2040 | return builder.build(); |
| 2041 | } |
| 2042 | } |
| 2043 | |
| 2044 | /** |
| 2045 | * @hide |
| 2046 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 2047 | @UnsupportedAppUsage |
Dmitri Plotnikov | 44730c2 | 2010-08-12 10:09:58 -0700 | [diff] [blame] | 2048 | public static final Builder builder() { |
| 2049 | return new Builder(); |
| 2050 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 2051 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2052 | |
| 2053 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2054 | * 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] | 2055 | * the contact's primary photo. The photo may be stored in up to two ways - |
| 2056 | * the default "photo" is a thumbnail-sized image stored directly in the data |
| 2057 | * row, while the "display photo", if present, is a larger version stored as |
| 2058 | * a file. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2059 | * <p> |
| 2060 | * Usage example: |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2061 | * <dl> |
| 2062 | * <dt>Retrieving the thumbnail-sized photo</dt> |
| 2063 | * <dd> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2064 | * <pre> |
| 2065 | * public InputStream openPhoto(long contactId) { |
| 2066 | * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 2067 | * Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY); |
| 2068 | * Cursor cursor = getContentResolver().query(photoUri, |
| 2069 | * new String[] {Contacts.Photo.PHOTO}, null, null, null); |
| 2070 | * if (cursor == null) { |
| 2071 | * return null; |
| 2072 | * } |
| 2073 | * try { |
| 2074 | * if (cursor.moveToFirst()) { |
| 2075 | * byte[] data = cursor.getBlob(0); |
| 2076 | * if (data != null) { |
| 2077 | * return new ByteArrayInputStream(data); |
| 2078 | * } |
| 2079 | * } |
| 2080 | * } finally { |
| 2081 | * cursor.close(); |
| 2082 | * } |
| 2083 | * return null; |
| 2084 | * } |
| 2085 | * </pre> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2086 | * </dd> |
| 2087 | * <dt>Retrieving the larger photo version</dt> |
| 2088 | * <dd> |
| 2089 | * <pre> |
| 2090 | * public InputStream openDisplayPhoto(long contactId) { |
| 2091 | * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 2092 | * Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO); |
| 2093 | * try { |
| 2094 | * AssetFileDescriptor fd = |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 2095 | * getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2096 | * return fd.createInputStream(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 2097 | * } catch (IOException e) { |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2098 | * return null; |
| 2099 | * } |
| 2100 | * } |
| 2101 | * </pre> |
| 2102 | * </dd> |
| 2103 | * </dl> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2104 | * |
| 2105 | * </p> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2106 | * <p>You may also consider using the convenience method |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2107 | * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri, boolean)} |
| 2108 | * 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] | 2109 | * </p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2110 | * <p> |
| 2111 | * This directory can be used either with a {@link #CONTENT_URI} or |
| 2112 | * {@link #CONTENT_LOOKUP_URI}. |
| 2113 | * </p> |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2114 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2115 | public static final class Photo implements BaseColumns, DataColumnsWithJoins { |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 2116 | /** |
| 2117 | * no public constructor since this is a utility class |
| 2118 | */ |
| 2119 | private Photo() {} |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 2120 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 2121 | /** |
| 2122 | * The directory twig for this sub-table |
| 2123 | */ |
| 2124 | public static final String CONTENT_DIRECTORY = "photo"; |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2125 | |
| 2126 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 2127 | * The directory twig for retrieving the full-size display photo. |
| 2128 | */ |
| 2129 | public static final String DISPLAY_PHOTO = "display_photo"; |
| 2130 | |
| 2131 | /** |
| 2132 | * Full-size photo file ID of the raw contact. |
| 2133 | * See {@link ContactsContract.DisplayPhoto}. |
| 2134 | * <p> |
| 2135 | * Type: NUMBER |
| 2136 | */ |
| 2137 | public static final String PHOTO_FILE_ID = DATA14; |
| 2138 | |
| 2139 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2140 | * Thumbnail photo of the raw contact. This is the raw bytes of an image |
| 2141 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
| 2142 | * <p> |
| 2143 | * Type: BLOB |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2144 | */ |
| 2145 | public static final String PHOTO = DATA15; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2146 | } |
| 2147 | |
| 2148 | /** |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2149 | * Opens an InputStream for the contacts's photo and returns the |
| 2150 | * photo as a byte stream. |
| 2151 | * @param cr The content resolver to use for querying |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2152 | * @param contactUri the contact whose photo should be used. This can be used with |
| 2153 | * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI. |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2154 | * @param preferHighres If this is true and the contact has a higher resolution photo |
| 2155 | * 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] | 2156 | * @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] | 2157 | */ |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2158 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri, |
| 2159 | boolean preferHighres) { |
| 2160 | if (preferHighres) { |
| 2161 | final Uri displayPhotoUri = Uri.withAppendedPath(contactUri, |
| 2162 | Contacts.Photo.DISPLAY_PHOTO); |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2163 | try { |
| 2164 | AssetFileDescriptor fd = cr.openAssetFileDescriptor(displayPhotoUri, "r"); |
Makoto Onuki | da072b3 | 2016-02-05 13:23:21 -0800 | [diff] [blame] | 2165 | if (fd != null) { |
| 2166 | return fd.createInputStream(); |
| 2167 | } |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2168 | } catch (IOException e) { |
| 2169 | // fallback to the thumbnail code |
| 2170 | } |
| 2171 | } |
| 2172 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 2173 | Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY); |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 2174 | if (photoUri == null) { |
| 2175 | return null; |
| 2176 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2177 | Cursor cursor = cr.query(photoUri, |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2178 | new String[] { |
| 2179 | ContactsContract.CommonDataKinds.Photo.PHOTO |
| 2180 | }, null, null, null); |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2181 | try { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 2182 | if (cursor == null || !cursor.moveToNext()) { |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2183 | return null; |
| 2184 | } |
| 2185 | byte[] data = cursor.getBlob(0); |
| 2186 | if (data == null) { |
| 2187 | return null; |
| 2188 | } |
| 2189 | return new ByteArrayInputStream(data); |
| 2190 | } finally { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 2191 | if (cursor != null) { |
| 2192 | cursor.close(); |
| 2193 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 2194 | } |
| 2195 | } |
Daniel Lehmann | f5d4652 | 2011-07-14 22:16:21 -0700 | [diff] [blame] | 2196 | |
| 2197 | /** |
| 2198 | * Opens an InputStream for the contacts's thumbnail photo and returns the |
| 2199 | * photo as a byte stream. |
| 2200 | * @param cr The content resolver to use for querying |
| 2201 | * @param contactUri the contact whose photo should be used. This can be used with |
| 2202 | * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI. |
| 2203 | * @return an InputStream of the photo, or null if no photo is present |
| 2204 | * @see #openContactPhotoInputStream(ContentResolver, Uri, boolean), if instead |
| 2205 | * of the thumbnail the high-res picture is preferred |
| 2206 | */ |
| 2207 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) { |
| 2208 | return openContactPhotoInputStream(cr, contactUri, false); |
| 2209 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2210 | } |
| 2211 | |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2212 | /** |
| 2213 | * <p> |
| 2214 | * Constants for the user's profile data, which is represented as a single contact on |
| 2215 | * the device that represents the user. The profile contact is not aggregated |
| 2216 | * together automatically in the same way that normal contacts are; instead, each |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 2217 | * account (including data set, if applicable) on the device may contribute a single |
| 2218 | * raw contact representing the user's personal profile data from that source. |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2219 | * </p> |
| 2220 | * <p> |
| 2221 | * Access to the profile entry through these URIs (or incidental access to parts of |
| 2222 | * the profile if retrieved directly via ID) requires additional permissions beyond |
| 2223 | * the read/write contact permissions required by the provider. Querying for profile |
| 2224 | * data requires android.permission.READ_PROFILE permission, and inserting or |
| 2225 | * updating profile data requires android.permission.WRITE_PROFILE permission. |
| 2226 | * </p> |
| 2227 | * <h3>Operations</h3> |
| 2228 | * <dl> |
| 2229 | * <dt><b>Insert</b></dt> |
| 2230 | * <dd>The user's profile entry cannot be created explicitly (attempting to do so |
| 2231 | * will throw an exception). When a raw contact is inserted into the profile, the |
| 2232 | * provider will check for the existence of a profile on the device. If one is |
| 2233 | * found, the raw contact's {@link RawContacts#CONTACT_ID} column gets the _ID of |
| 2234 | * the profile Contact. If no match is found, the profile Contact is created and |
| 2235 | * its _ID is put into the {@link RawContacts#CONTACT_ID} column of the newly |
| 2236 | * inserted raw contact.</dd> |
| 2237 | * <dt><b>Update</b></dt> |
| 2238 | * <dd>The profile Contact has the same update restrictions as Contacts in general, |
| 2239 | * but requires the android.permission.WRITE_PROFILE permission.</dd> |
| 2240 | * <dt><b>Delete</b></dt> |
| 2241 | * <dd>The profile Contact cannot be explicitly deleted. It will be removed |
| 2242 | * automatically if all of its constituent raw contact entries are deleted.</dd> |
| 2243 | * <dt><b>Query</b></dt> |
| 2244 | * <dd> |
| 2245 | * <ul> |
| 2246 | * <li>The {@link #CONTENT_URI} for profiles behaves in much the same way as |
| 2247 | * retrieving a contact by ID, except that it will only ever return the user's |
| 2248 | * profile contact. |
| 2249 | * </li> |
| 2250 | * <li> |
| 2251 | * The profile contact supports all of the same sub-paths as an individual contact |
| 2252 | * does - the content of the profile contact can be retrieved as entities or |
| 2253 | * data rows. Similarly, specific raw contact entries can be retrieved by appending |
| 2254 | * the desired raw contact ID within the profile. |
| 2255 | * </li> |
| 2256 | * </ul> |
| 2257 | * </dd> |
| 2258 | * </dl> |
| 2259 | */ |
| 2260 | public static final class Profile implements BaseColumns, ContactsColumns, |
| 2261 | ContactOptionsColumns, ContactNameColumns, ContactStatusColumns { |
| 2262 | /** |
| 2263 | * This utility class cannot be instantiated |
| 2264 | */ |
| 2265 | private Profile() { |
| 2266 | } |
| 2267 | |
| 2268 | /** |
| 2269 | * The content:// style URI for this table, which requests the contact entry |
| 2270 | * representing the user's personal profile data. |
| 2271 | */ |
| 2272 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "profile"); |
| 2273 | |
| 2274 | /** |
| 2275 | * {@link Uri} for referencing the user's profile {@link Contacts} entry, |
| 2276 | * Provides {@link OpenableColumns} columns when queried, or returns the |
| 2277 | * user's profile contact formatted as a vCard when opened through |
| 2278 | * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. |
| 2279 | */ |
| 2280 | public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI, |
| 2281 | "as_vcard"); |
| 2282 | |
| 2283 | /** |
| 2284 | * {@link Uri} for referencing the raw contacts that make up the user's profile |
| 2285 | * {@link Contacts} entry. An individual raw contact entry within the profile |
| 2286 | * can be addressed by appending the raw contact ID. The entities or data within |
| 2287 | * that specific raw contact can be requested by appending the entity or data |
| 2288 | * path as well. |
| 2289 | */ |
| 2290 | public static final Uri CONTENT_RAW_CONTACTS_URI = Uri.withAppendedPath(CONTENT_URI, |
| 2291 | "raw_contacts"); |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 2292 | |
| 2293 | /** |
| 2294 | * The minimum ID for any entity that belongs to the profile. This essentially |
| 2295 | * defines an ID-space in which profile data is stored, and is used by the provider |
| 2296 | * to determine whether a request via a non-profile-specific URI should be directed |
| 2297 | * to the profile data rather than general contacts data, along with all the special |
| 2298 | * permission checks that entails. |
| 2299 | * |
| 2300 | * Callers may use {@link #isProfileId} to check whether a specific ID falls into |
| 2301 | * the set of data intended for the profile. |
| 2302 | */ |
| 2303 | public static final long MIN_ID = Long.MAX_VALUE - (long) Integer.MAX_VALUE; |
| 2304 | } |
| 2305 | |
| 2306 | /** |
| 2307 | * This method can be used to identify whether the given ID is associated with profile |
| 2308 | * data. It does not necessarily indicate that the ID is tied to valid data, merely |
| 2309 | * that accessing data using this ID will result in profile access checks and will only |
| 2310 | * return data from the profile. |
| 2311 | * |
| 2312 | * @param id The ID to check. |
| 2313 | * @return Whether the ID is associated with profile data. |
| 2314 | */ |
| 2315 | public static boolean isProfileId(long id) { |
| 2316 | return id >= Profile.MIN_ID; |
Dave Santoro | 4325133 | 2011-05-11 11:39:54 -0700 | [diff] [blame] | 2317 | } |
| 2318 | |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 2319 | protected interface DeletedContactsColumns { |
| 2320 | |
| 2321 | /** |
| 2322 | * A reference to the {@link ContactsContract.Contacts#_ID} that was deleted. |
| 2323 | * <P>Type: INTEGER</P> |
| 2324 | */ |
| 2325 | public static final String CONTACT_ID = "contact_id"; |
| 2326 | |
| 2327 | /** |
| 2328 | * Time (milliseconds since epoch) that the contact was deleted. |
| 2329 | */ |
| 2330 | public static final String CONTACT_DELETED_TIMESTAMP = "contact_deleted_timestamp"; |
| 2331 | } |
| 2332 | |
| 2333 | /** |
| 2334 | * Constants for the deleted contact table. This table holds a log of deleted contacts. |
| 2335 | * <p> |
| 2336 | * Log older than {@link #DAYS_KEPT_MILLISECONDS} may be deleted. |
| 2337 | */ |
| 2338 | public static final class DeletedContacts implements DeletedContactsColumns { |
| 2339 | |
| 2340 | /** |
| 2341 | * This utility class cannot be instantiated |
| 2342 | */ |
| 2343 | private DeletedContacts() { |
| 2344 | } |
| 2345 | |
| 2346 | /** |
| 2347 | * The content:// style URI for this table, which requests a directory of raw contact rows |
| 2348 | * matching the selection criteria. |
| 2349 | */ |
| 2350 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 2351 | "deleted_contacts"); |
| 2352 | |
| 2353 | /** |
| 2354 | * Number of days that the delete log will be kept. After this time, delete records may be |
| 2355 | * deleted. |
| 2356 | * |
| 2357 | * @hide |
| 2358 | */ |
| 2359 | private static final int DAYS_KEPT = 30; |
| 2360 | |
| 2361 | /** |
| 2362 | * Milliseconds that the delete log will be kept. After this time, delete records may be |
| 2363 | * deleted. |
| 2364 | */ |
| 2365 | public static final long DAYS_KEPT_MILLISECONDS = 1000L * 60L * 60L * 24L * (long)DAYS_KEPT; |
| 2366 | } |
| 2367 | |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 2368 | protected interface RawContactsColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2369 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2370 | * A reference to the {@link ContactsContract.Contacts#_ID} that this |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2371 | * data belongs to. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2372 | * <P>Type: INTEGER</P> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2373 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2374 | public static final String CONTACT_ID = "contact_id"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2375 | |
| 2376 | /** |
Zheng Fu | 9ea9a13 | 2015-01-07 11:33:19 -0800 | [diff] [blame] | 2377 | * Persistent unique id for each raw_contact within its account. |
| 2378 | * This id is provided by its own data source, and can be used to backup metadata |
| 2379 | * to the server. |
| 2380 | * 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] | 2381 | */ |
| 2382 | public static final String BACKUP_ID = "backup_id"; |
| 2383 | |
| 2384 | /** |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2385 | * The data set within the account that this row belongs to. This allows |
| 2386 | * multiple sync adapters for the same account type to distinguish between |
| 2387 | * each others' data. |
| 2388 | * |
| 2389 | * This is empty by default, and is completely optional. It only needs to |
| 2390 | * be populated if multiple sync adapters are entering distinct data for |
| 2391 | * the same account type and account name. |
| 2392 | * <P>Type: TEXT</P> |
| 2393 | */ |
| 2394 | public static final String DATA_SET = "data_set"; |
| 2395 | |
| 2396 | /** |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 2397 | * A concatenation of the account type and data set (delimited by a forward |
| 2398 | * slash) - if the data set is empty, this will be the same as the account |
| 2399 | * type. For applications that need to be aware of the data set, this can |
| 2400 | * be used instead of account type to distinguish sets of data. This is |
| 2401 | * never intended to be used for specifying accounts. |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 2402 | * <p> |
| 2403 | * This column does *not* escape forward slashes in the account type or the data set. |
| 2404 | * If this is an issue, consider using |
| 2405 | * {@link ContactsContract.RawContacts#ACCOUNT_TYPE} and |
| 2406 | * {@link ContactsContract.RawContacts#DATA_SET} directly. |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 2407 | */ |
| 2408 | public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; |
| 2409 | |
| 2410 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2411 | * The aggregation mode for this contact. |
| 2412 | * <P>Type: INTEGER</P> |
| 2413 | */ |
| 2414 | public static final String AGGREGATION_MODE = "aggregation_mode"; |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 2415 | |
| 2416 | /** |
| 2417 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 2418 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 2419 | * 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] | 2420 | * 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] | 2421 | * then calls ContactResolver.delete once more, this time passing the |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 2422 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 2423 | * the data removal. |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 2424 | * <P>Type: INTEGER</P> |
| 2425 | */ |
| 2426 | public static final String DELETED = "deleted"; |
Dmitri Plotnikov | 918007b | 2010-01-20 12:12:11 -0800 | [diff] [blame] | 2427 | |
| 2428 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 2429 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 2430 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 2431 | * <P>Type: INTEGER</P> |
| 2432 | */ |
Dmitri Plotnikov | 86fe839 | 2010-07-16 11:19:46 -0700 | [diff] [blame] | 2433 | 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] | 2434 | |
| 2435 | /** |
| 2436 | * Flag that reflects whether this raw contact belongs to the user's |
| 2437 | * personal profile entry. |
| 2438 | */ |
| 2439 | 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] | 2440 | |
| 2441 | /** |
| 2442 | * Flag indicating that a raw contact's metadata has changed, and its metadata |
| 2443 | * needs to be synchronized by the server. |
| 2444 | * <P>Type: INTEGER (boolean)</P> |
| 2445 | */ |
| 2446 | public static final String METADATA_DIRTY = "metadata_dirty"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2447 | } |
| 2448 | |
| 2449 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2450 | * Constants for the raw contacts table, which contains one row of contact |
| 2451 | * information for each person in each synced account. Sync adapters and |
| 2452 | * contact management apps |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 2453 | * are the primary consumers of this API. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2454 | * |
| 2455 | * <h3>Aggregation</h3> |
| 2456 | * <p> |
| 2457 | * As soon as a raw contact is inserted or whenever its constituent data |
| 2458 | * changes, the provider will check if the raw contact matches other |
| 2459 | * existing raw contacts and if so will aggregate it with those. The |
| 2460 | * aggregation is reflected in the {@link RawContacts} table by the change of the |
| 2461 | * {@link #CONTACT_ID} field, which is the reference to the aggregate contact. |
| 2462 | * </p> |
| 2463 | * <p> |
| 2464 | * Changes to the structured name, organization, phone number, email address, |
| 2465 | * or nickname trigger a re-aggregation. |
| 2466 | * </p> |
| 2467 | * <p> |
| 2468 | * See also {@link AggregationExceptions} for a mechanism to control |
| 2469 | * aggregation programmatically. |
| 2470 | * </p> |
| 2471 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2472 | * <h3>Operations</h3> |
| 2473 | * <dl> |
| 2474 | * <dt><b>Insert</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2475 | * <dd> |
| 2476 | * <p> |
| 2477 | * Raw contacts can be inserted incrementally or in a batch. |
| 2478 | * The incremental method is more traditional but less efficient. |
| 2479 | * It should be used |
| 2480 | * 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] | 2481 | * <pre> |
| 2482 | * ContentValues values = new ContentValues(); |
| 2483 | * values.put(RawContacts.ACCOUNT_TYPE, accountType); |
| 2484 | * values.put(RawContacts.ACCOUNT_NAME, accountName); |
| 2485 | * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values); |
| 2486 | * long rawContactId = ContentUris.parseId(rawContactUri); |
| 2487 | * </pre> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2488 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2489 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2490 | * Once {@link Data} values become available, insert those. |
| 2491 | * For example, here's how you would insert a name: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2492 | * |
| 2493 | * <pre> |
| 2494 | * values.clear(); |
| 2495 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 2496 | * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); |
| 2497 | * values.put(StructuredName.DISPLAY_NAME, "Mike Sullivan"); |
| 2498 | * getContentResolver().insert(Data.CONTENT_URI, values); |
| 2499 | * </pre> |
| 2500 | * </p> |
| 2501 | * <p> |
| 2502 | * The batch method is by far preferred. It inserts the raw contact and its |
| 2503 | * constituent data rows in a single database transaction |
| 2504 | * and causes at most one aggregation pass. |
| 2505 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 2506 | * ArrayList<ContentProviderOperation> ops = |
| 2507 | * new ArrayList<ContentProviderOperation>(); |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2508 | * ... |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2509 | * int rawContactInsertIndex = ops.size(); |
| 2510 | * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) |
| 2511 | * .withValue(RawContacts.ACCOUNT_TYPE, accountType) |
| 2512 | * .withValue(RawContacts.ACCOUNT_NAME, accountName) |
| 2513 | * .build()); |
| 2514 | * |
| 2515 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 2516 | * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex) |
| 2517 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 2518 | * .withValue(StructuredName.DISPLAY_NAME, "Mike Sullivan") |
| 2519 | * .build()); |
| 2520 | * |
| 2521 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 2522 | * </pre> |
| 2523 | * </p> |
| 2524 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2525 | * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)} |
| 2526 | * to refer to the as-yet-unknown index value of the raw contact inserted in the |
| 2527 | * first operation. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2528 | * </p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2529 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2530 | * <dt><b>Update</b></dt> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2531 | * <dd><p> |
| 2532 | * Raw contacts can be updated incrementally or in a batch. |
| 2533 | * Batch mode should be used whenever possible. |
| 2534 | * The procedures and considerations are analogous to those documented above for inserts. |
| 2535 | * </p></dd> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2536 | * <dt><b>Delete</b></dt> |
| 2537 | * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates, |
| 2538 | * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2539 | * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row |
| 2540 | * itself is also deleted automatically. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2541 | * </p> |
| 2542 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2543 | * The invocation of {@code resolver.delete(...)}, does not immediately delete |
| 2544 | * a raw contacts row. |
| 2545 | * Instead, it sets the {@link #DELETED} flag on the raw contact and |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2546 | * removes the raw contact from its aggregate contact. |
| 2547 | * The sync adapter then deletes the raw contact from the server and |
| 2548 | * finalizes phone-side deletion by calling {@code resolver.delete(...)} |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2549 | * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2550 | * <p>Some sync adapters are read-only, meaning that they only sync server-side |
| 2551 | * changes to the phone, but not the reverse. If one of those raw contacts |
| 2552 | * is marked for deletion, it will remain on the phone. However it will be |
| 2553 | * effectively invisible, because it will not be part of any aggregate contact. |
| 2554 | * </dd> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2555 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2556 | * <dt><b>Query</b></dt> |
| 2557 | * <dd> |
| 2558 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2559 | * It is easy to find all raw contacts in a Contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2560 | * <pre> |
| 2561 | * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI, |
| 2562 | * new String[]{RawContacts._ID}, |
| 2563 | * RawContacts.CONTACT_ID + "=?", |
| 2564 | * new String[]{String.valueOf(contactId)}, null); |
| 2565 | * </pre> |
| 2566 | * </p> |
| 2567 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2568 | * To find raw contacts within a specific account, |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2569 | * you can either put the account name and type in the selection or pass them as query |
| 2570 | * parameters. The latter approach is preferable, especially when you can reuse the |
| 2571 | * URI: |
| 2572 | * <pre> |
Adam Koch | 95e5a07 | 2013-05-21 09:47:55 -0400 | [diff] [blame] | 2573 | * Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon() |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2574 | * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName) |
| 2575 | * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType) |
| 2576 | * .build(); |
| 2577 | * Cursor c1 = getContentResolver().query(rawContactUri, |
| 2578 | * RawContacts.STARRED + "<>0", null, null, null); |
| 2579 | * ... |
| 2580 | * Cursor c2 = getContentResolver().query(rawContactUri, |
| 2581 | * RawContacts.DELETED + "<>0", null, null, null); |
| 2582 | * </pre> |
| 2583 | * </p> |
| 2584 | * <p>The best way to read a raw contact along with all the data associated with it is |
| 2585 | * by using the {@link Entity} directory. If the raw contact has data rows, |
| 2586 | * the Entity cursor will contain a row for each data row. If the raw contact has no |
| 2587 | * data rows, the cursor will still contain one row with the raw contact-level information. |
| 2588 | * <pre> |
| 2589 | * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); |
| 2590 | * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY); |
| 2591 | * Cursor c = getContentResolver().query(entityUri, |
| 2592 | * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1}, |
| 2593 | * null, null, null); |
| 2594 | * try { |
| 2595 | * while (c.moveToNext()) { |
| 2596 | * String sourceId = c.getString(0); |
| 2597 | * if (!c.isNull(1)) { |
| 2598 | * String mimeType = c.getString(2); |
| 2599 | * String data = c.getString(3); |
| 2600 | * ... |
| 2601 | * } |
| 2602 | * } |
| 2603 | * } finally { |
| 2604 | * c.close(); |
| 2605 | * } |
| 2606 | * </pre> |
| 2607 | * </p> |
| 2608 | * </dd> |
| 2609 | * </dl> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2610 | * <h2>Columns</h2> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2611 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2612 | * <table class="jd-sumtable"> |
| 2613 | * <tr> |
| 2614 | * <th colspan='4'>RawContacts</th> |
| 2615 | * </tr> |
| 2616 | * <tr> |
| 2617 | * <td>long</td> |
| 2618 | * <td>{@link #_ID}</td> |
| 2619 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2620 | * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words, |
| 2621 | * it is much better for a sync adapter to update a raw contact rather than to delete and |
| 2622 | * re-insert it.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2623 | * </tr> |
| 2624 | * <tr> |
| 2625 | * <td>long</td> |
| 2626 | * <td>{@link #CONTACT_ID}</td> |
| 2627 | * <td>read-only</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2628 | * <td>The ID of the row in the {@link ContactsContract.Contacts} table |
| 2629 | * that this raw contact belongs |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2630 | * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled |
| 2631 | * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td> |
| 2632 | * </tr> |
| 2633 | * <tr> |
| 2634 | * <td>int</td> |
| 2635 | * <td>{@link #AGGREGATION_MODE}</td> |
| 2636 | * <td>read/write</td> |
| 2637 | * <td>A mechanism that allows programmatic control of the aggregation process. The allowed |
| 2638 | * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED} |
| 2639 | * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td> |
| 2640 | * </tr> |
| 2641 | * <tr> |
| 2642 | * <td>int</td> |
| 2643 | * <td>{@link #DELETED}</td> |
| 2644 | * <td>read/write</td> |
| 2645 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 2646 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 2647 | * called on a raw contact, it is marked for deletion and removed from its |
| 2648 | * aggregate contact. The sync adaptor deletes the raw contact on the server and |
| 2649 | * then calls ContactResolver.delete once more, this time passing the |
| 2650 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 2651 | * the data removal.</td> |
| 2652 | * </tr> |
| 2653 | * <tr> |
| 2654 | * <td>int</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2655 | * <td>{@link #STARRED}</td> |
| 2656 | * <td>read/write</td> |
| 2657 | * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2658 | * Changing this field immediately affects the corresponding aggregate contact: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2659 | * if any raw contacts in that aggregate contact are starred, then the contact |
| 2660 | * itself is marked as starred.</td> |
| 2661 | * </tr> |
| 2662 | * <tr> |
| 2663 | * <td>String</td> |
| 2664 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 2665 | * <td>read/write</td> |
| 2666 | * <td>A custom ringtone associated with a raw contact. Typically this is the |
| 2667 | * URI returned by an activity launched with the |
| 2668 | * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent. |
| 2669 | * To have an effect on the corresponding value of the aggregate contact, this field |
| 2670 | * 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] | 2671 | * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE |
| 2672 | * Contacts.CUSTOM_RINGTONE} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2673 | * instead.</td> |
| 2674 | * </tr> |
| 2675 | * <tr> |
| 2676 | * <td>int</td> |
| 2677 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 2678 | * <td>read/write</td> |
| 2679 | * <td>An indicator of whether calls from this raw contact should be forwarded |
| 2680 | * directly to voice mail ('1') or not ('0'). To have an effect |
| 2681 | * on the corresponding value of the aggregate contact, this field |
| 2682 | * should be set at the time the raw contact is inserted.</td> |
| 2683 | * </tr> |
| 2684 | * <tr> |
| 2685 | * <td>String</td> |
| 2686 | * <td>{@link #ACCOUNT_NAME}</td> |
| 2687 | * <td>read/write-once</td> |
| 2688 | * <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] | 2689 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
| 2690 | * 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] | 2691 | * It should be set at the time the raw contact is inserted and never |
| 2692 | * changed afterwards.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2693 | * </tr> |
| 2694 | * <tr> |
| 2695 | * <td>String</td> |
| 2696 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 2697 | * <td>read/write-once</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2698 | * <td> |
| 2699 | * <p> |
| 2700 | * The type of account to which this row belongs, which when paired with |
| 2701 | * {@link #ACCOUNT_NAME} identifies a specific account. |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2702 | * It should be set at the time the raw contact is inserted and never |
| 2703 | * changed afterwards. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2704 | * </p> |
| 2705 | * <p> |
| 2706 | * To ensure uniqueness, new account types should be chosen according to the |
| 2707 | * Java package naming convention. Thus a Google account is of type "com.google". |
| 2708 | * </p> |
| 2709 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2710 | * </tr> |
| 2711 | * <tr> |
| 2712 | * <td>String</td> |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2713 | * <td>{@link #DATA_SET}</td> |
| 2714 | * <td>read/write-once</td> |
| 2715 | * <td> |
| 2716 | * <p> |
| 2717 | * The data set within the account that this row belongs to. This allows |
| 2718 | * multiple sync adapters for the same account type to distinguish between |
| 2719 | * each others' data. The combination of {@link #ACCOUNT_TYPE}, |
| 2720 | * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data |
| 2721 | * that is associated with a single sync adapter. |
| 2722 | * </p> |
| 2723 | * <p> |
| 2724 | * This is empty by default, and is completely optional. It only needs to |
| 2725 | * be populated if multiple sync adapters are entering distinct data for |
| 2726 | * the same account type and account name. |
| 2727 | * </p> |
| 2728 | * <p> |
| 2729 | * It should be set at the time the raw contact is inserted and never |
| 2730 | * changed afterwards. |
| 2731 | * </p> |
| 2732 | * </td> |
| 2733 | * </tr> |
| 2734 | * <tr> |
| 2735 | * <td>String</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2736 | * <td>{@link #SOURCE_ID}</td> |
| 2737 | * <td>read/write</td> |
| 2738 | * <td>String that uniquely identifies this row to its source account. |
| 2739 | * Typically it is set at the time the raw contact is inserted and never |
| 2740 | * changed afterwards. The one notable exception is a new raw contact: it |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 2741 | * will have an account name and type (and possibly a data set), but no |
| 2742 | * source id. This indicates to the sync adapter that a new contact needs |
| 2743 | * to be created server-side and its ID stored in the corresponding |
| 2744 | * SOURCE_ID field on the phone. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2745 | * </td> |
| 2746 | * </tr> |
| 2747 | * <tr> |
| 2748 | * <td>int</td> |
| 2749 | * <td>{@link #VERSION}</td> |
| 2750 | * <td>read-only</td> |
| 2751 | * <td>Version number that is updated whenever this row or its related data |
| 2752 | * changes. This field can be used for optimistic locking of a raw contact. |
| 2753 | * </td> |
| 2754 | * </tr> |
| 2755 | * <tr> |
| 2756 | * <td>int</td> |
| 2757 | * <td>{@link #DIRTY}</td> |
| 2758 | * <td>read/write</td> |
| 2759 | * <td>Flag indicating that {@link #VERSION} has changed, and this row needs |
| 2760 | * to be synchronized by its owning account. The value is set to "1" automatically |
| 2761 | * whenever the raw contact changes, unless the URI has the |
| 2762 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified. |
| 2763 | * The sync adapter should always supply this query parameter to prevent |
| 2764 | * unnecessary synchronization: user changes some data on the server, |
| 2765 | * the sync adapter updates the contact on the phone (without the |
| 2766 | * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag, |
| 2767 | * which triggers a sync to bring the changes to the server. |
| 2768 | * </td> |
| 2769 | * </tr> |
| 2770 | * <tr> |
| 2771 | * <td>String</td> |
| 2772 | * <td>{@link #SYNC1}</td> |
| 2773 | * <td>read/write</td> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2774 | * <td>Generic column provided for arbitrary use by sync adapters. |
| 2775 | * The content provider |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2776 | * stores this information on behalf of the sync adapter but does not |
| 2777 | * interpret it in any way. |
| 2778 | * </td> |
| 2779 | * </tr> |
| 2780 | * <tr> |
| 2781 | * <td>String</td> |
| 2782 | * <td>{@link #SYNC2}</td> |
| 2783 | * <td>read/write</td> |
| 2784 | * <td>Generic column for use by sync adapters. |
| 2785 | * </td> |
| 2786 | * </tr> |
| 2787 | * <tr> |
| 2788 | * <td>String</td> |
| 2789 | * <td>{@link #SYNC3}</td> |
| 2790 | * <td>read/write</td> |
| 2791 | * <td>Generic column for use by sync adapters. |
| 2792 | * </td> |
| 2793 | * </tr> |
| 2794 | * <tr> |
| 2795 | * <td>String</td> |
| 2796 | * <td>{@link #SYNC4}</td> |
| 2797 | * <td>read/write</td> |
| 2798 | * <td>Generic column for use by sync adapters. |
| 2799 | * </td> |
| 2800 | * </tr> |
| 2801 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2802 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2803 | public static final class RawContacts implements BaseColumns, RawContactsColumns, |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 2804 | ContactOptionsColumns, ContactNameColumns, SyncColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2805 | /** |
| 2806 | * This utility class cannot be instantiated |
| 2807 | */ |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 2808 | private RawContacts() { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2809 | } |
| 2810 | |
| 2811 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2812 | * The content:// style URI for this table, which requests a directory of |
| 2813 | * raw contact rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2814 | */ |
Makoto Onuki | 0554b19 | 2018-10-01 18:50:08 +0000 | [diff] [blame] | 2815 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2816 | |
| 2817 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2818 | * The MIME type of the results from {@link #CONTENT_URI} when a specific |
| 2819 | * ID value is not provided, and multiple raw contacts may be returned. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2820 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2821 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2822 | |
| 2823 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2824 | * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI}, |
| 2825 | * yielding a subdirectory of a single person. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2826 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2827 | 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] | 2828 | |
| 2829 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2830 | * Aggregation mode: aggregate immediately after insert or update operation(s) are complete. |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2831 | */ |
| 2832 | public static final int AGGREGATION_MODE_DEFAULT = 0; |
| 2833 | |
| 2834 | /** |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2835 | * Aggregation mode: aggregate at the time the raw contact is inserted/updated. |
| 2836 | * @deprecated Aggregation is synchronous, this historic value is a no-op |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2837 | */ |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2838 | @Deprecated |
Omari Stephens | bc9aa77 | 2009-09-08 19:10:53 -0700 | [diff] [blame] | 2839 | public static final int AGGREGATION_MODE_IMMEDIATE = 1; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2840 | |
| 2841 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2842 | * <p> |
| 2843 | * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later. |
| 2844 | * Changes to the raw contact will update the associated aggregate contact but will not |
| 2845 | * result in any change in how the contact is aggregated. Similar to |
| 2846 | * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding |
| 2847 | * {@link Contacts} aggregate. |
| 2848 | * </p> |
| 2849 | * <p> |
| 2850 | * This can be used to postpone aggregation until after a series of updates, for better |
| 2851 | * performance and/or user experience. |
| 2852 | * </p> |
| 2853 | * <p> |
| 2854 | * Note that changing |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2855 | * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2856 | * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any |
| 2857 | * subsequent |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2858 | * change to the raw contact's data will. |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2859 | * </p> |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2860 | */ |
| 2861 | public static final int AGGREGATION_MODE_SUSPENDED = 2; |
| 2862 | |
| 2863 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2864 | * <p> |
| 2865 | * Aggregation mode: never aggregate this raw contact. The raw contact will not |
| 2866 | * have a corresponding {@link Contacts} aggregate and therefore will not be included in |
| 2867 | * {@link Contacts} query results. |
| 2868 | * </p> |
| 2869 | * <p> |
| 2870 | * For example, this mode can be used for a raw contact that is marked for deletion while |
| 2871 | * waiting for the deletion to occur on the server side. |
| 2872 | * </p> |
| 2873 | * |
| 2874 | * @see #AGGREGATION_MODE_SUSPENDED |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2875 | */ |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 2876 | public static final int AGGREGATION_MODE_DISABLED = 3; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 2877 | |
| 2878 | /** |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 2879 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 2880 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
| 2881 | * entry of the given {@link RawContacts} entry. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2882 | */ |
| 2883 | public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) { |
| 2884 | // TODO: use a lighter query by joining rawcontacts with contacts in provider |
| 2885 | final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY); |
| 2886 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 2887 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 2888 | }, null, null, null); |
| 2889 | |
| 2890 | Uri lookupUri = null; |
| 2891 | try { |
| 2892 | if (cursor != null && cursor.moveToFirst()) { |
| 2893 | final long contactId = cursor.getLong(0); |
| 2894 | final String lookupKey = cursor.getString(1); |
| 2895 | return Contacts.getLookupUri(contactId, lookupKey); |
| 2896 | } |
| 2897 | } finally { |
| 2898 | if (cursor != null) cursor.close(); |
| 2899 | } |
| 2900 | return lookupUri; |
| 2901 | } |
| 2902 | |
| 2903 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2904 | * 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] | 2905 | * {@link ContactsContract.Data} rows. To access this directory |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2906 | * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2907 | */ |
| 2908 | public static final class Data implements BaseColumns, DataColumns { |
| 2909 | /** |
| 2910 | * no public constructor since this is a utility class |
| 2911 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 2912 | private Data() { |
| 2913 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2914 | |
| 2915 | /** |
| 2916 | * The directory twig for this sub-table |
| 2917 | */ |
| 2918 | public static final String CONTENT_DIRECTORY = "data"; |
| 2919 | } |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2920 | |
| 2921 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2922 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2923 | * 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] | 2924 | * {@link ContactsContract.Data} rows. To access this directory append |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2925 | * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2926 | * {@link RawContactsEntity} for a stand-alone table containing the same |
| 2927 | * data. |
| 2928 | * </p> |
| 2929 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2930 | * Entity has two ID fields: {@link #_ID} for the raw contact |
| 2931 | * and {@link #DATA_ID} for the data rows. |
| 2932 | * Entity always contains at least one row, even if there are no |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 2933 | * 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] | 2934 | * null. |
| 2935 | * </p> |
| 2936 | * <p> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 2937 | * Using Entity should be preferred to using two separate queries: |
| 2938 | * RawContacts followed by Data. The reason is that Entity reads all |
| 2939 | * data for a raw contact in one transaction, so there is no possibility |
| 2940 | * of the data changing between the two queries. |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 2941 | */ |
| 2942 | public static final class Entity implements BaseColumns, DataColumns { |
| 2943 | /** |
| 2944 | * no public constructor since this is a utility class |
| 2945 | */ |
| 2946 | private Entity() { |
| 2947 | } |
| 2948 | |
| 2949 | /** |
| 2950 | * The directory twig for this sub-table |
| 2951 | */ |
| 2952 | public static final String CONTENT_DIRECTORY = "entity"; |
| 2953 | |
| 2954 | /** |
Dmitri Plotnikov | b2ce481 | 2010-07-29 18:28:50 -0700 | [diff] [blame] | 2955 | * 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] | 2956 | * data rows. |
| 2957 | * <P>Type: INTEGER</P> |
| 2958 | */ |
| 2959 | public static final String DATA_ID = "data_id"; |
| 2960 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 2961 | |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 2962 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2963 | * <p> |
| 2964 | * A sub-directory of a single raw contact that contains all of its |
| 2965 | * {@link ContactsContract.StreamItems} rows. To access this directory append |
| 2966 | * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See |
| 2967 | * {@link ContactsContract.StreamItems} for a stand-alone table containing the |
| 2968 | * same data. |
| 2969 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 2970 | * <p> |
| 2971 | * Access to the social stream through this sub-directory requires additional permissions |
| 2972 | * beyond the read/write contact permissions required by the provider. Querying for |
| 2973 | * social stream data requires android.permission.READ_SOCIAL_STREAM permission, and |
| 2974 | * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM |
| 2975 | * permission. |
| 2976 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2977 | * |
| 2978 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 2979 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 2980 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 2981 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2982 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2983 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2984 | public static final class StreamItems implements BaseColumns, StreamItemsColumns { |
| 2985 | /** |
| 2986 | * No public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2987 | * |
| 2988 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 2989 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2990 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2991 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 2992 | private StreamItems() { |
| 2993 | } |
| 2994 | |
| 2995 | /** |
| 2996 | * The directory twig for this sub-table |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 2997 | * |
| 2998 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 2999 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3000 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3001 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3002 | public static final String CONTENT_DIRECTORY = "stream_items"; |
| 3003 | } |
| 3004 | |
| 3005 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 3006 | * <p> |
| 3007 | * A sub-directory of a single raw contact that represents its primary |
| 3008 | * display photo. To access this directory append |
| 3009 | * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI. |
| 3010 | * The resulting URI represents an image file, and should be interacted with |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3011 | * using ContentResolver.openAssetFileDescriptor. |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 3012 | * <p> |
| 3013 | * <p> |
| 3014 | * Note that this sub-directory also supports opening the photo as an asset file |
| 3015 | * in write mode. Callers can create or replace the primary photo associated |
| 3016 | * with this raw contact by opening the asset file and writing the full-size |
| 3017 | * photo contents into it. When the file is closed, the image will be parsed, |
| 3018 | * sized down if necessary for the full-size display photo and thumbnail |
| 3019 | * dimensions, and stored. |
| 3020 | * </p> |
| 3021 | * <p> |
| 3022 | * Usage example: |
| 3023 | * <pre> |
| 3024 | * public void writeDisplayPhoto(long rawContactId, byte[] photo) { |
| 3025 | * Uri rawContactPhotoUri = Uri.withAppendedPath( |
| 3026 | * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), |
| 3027 | * RawContacts.DisplayPhoto.CONTENT_DIRECTORY); |
| 3028 | * try { |
| 3029 | * AssetFileDescriptor fd = |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3030 | * getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 3031 | * OutputStream os = fd.createOutputStream(); |
| 3032 | * os.write(photo); |
| 3033 | * os.close(); |
| 3034 | * fd.close(); |
| 3035 | * } catch (IOException e) { |
| 3036 | * // Handle error cases. |
| 3037 | * } |
| 3038 | * } |
| 3039 | * </pre> |
| 3040 | * </p> |
| 3041 | */ |
| 3042 | public static final class DisplayPhoto { |
| 3043 | /** |
| 3044 | * No public constructor since this is a utility class |
| 3045 | */ |
| 3046 | private DisplayPhoto() { |
| 3047 | } |
| 3048 | |
| 3049 | /** |
| 3050 | * The directory twig for this sub-table |
| 3051 | */ |
| 3052 | public static final String CONTENT_DIRECTORY = "display_photo"; |
| 3053 | } |
| 3054 | |
| 3055 | /** |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 3056 | * TODO: javadoc |
| 3057 | * @param cursor |
| 3058 | * @return |
| 3059 | */ |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3060 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 3061 | return new EntityIteratorImpl(cursor); |
| 3062 | } |
| 3063 | |
| 3064 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 3065 | private static final String[] DATA_KEYS = new String[]{ |
| 3066 | Data.DATA1, |
| 3067 | Data.DATA2, |
| 3068 | Data.DATA3, |
| 3069 | Data.DATA4, |
| 3070 | Data.DATA5, |
| 3071 | Data.DATA6, |
| 3072 | Data.DATA7, |
| 3073 | Data.DATA8, |
| 3074 | Data.DATA9, |
| 3075 | Data.DATA10, |
| 3076 | Data.DATA11, |
| 3077 | Data.DATA12, |
| 3078 | Data.DATA13, |
| 3079 | Data.DATA14, |
| 3080 | Data.DATA15, |
| 3081 | Data.SYNC1, |
| 3082 | Data.SYNC2, |
| 3083 | Data.SYNC3, |
| 3084 | Data.SYNC4}; |
| 3085 | |
| 3086 | public EntityIteratorImpl(Cursor cursor) { |
| 3087 | super(cursor); |
| 3088 | } |
| 3089 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 3090 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3091 | public android.content.Entity getEntityAndIncrementCursor(Cursor cursor) |
| 3092 | throws RemoteException { |
| 3093 | final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID); |
| 3094 | final long rawContactId = cursor.getLong(columnRawContactId); |
| 3095 | |
| 3096 | // we expect the cursor is already at the row we need to read from |
| 3097 | ContentValues cv = new ContentValues(); |
| 3098 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME); |
| 3099 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE); |
Katherine Kuan | 1d83723 | 2011-08-24 16:06:06 -0700 | [diff] [blame] | 3100 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DATA_SET); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3101 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID); |
| 3102 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY); |
| 3103 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION); |
| 3104 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID); |
| 3105 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1); |
| 3106 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2); |
| 3107 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3); |
| 3108 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4); |
| 3109 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED); |
| 3110 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID); |
| 3111 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3112 | android.content.Entity contact = new android.content.Entity(cv); |
| 3113 | |
| 3114 | // read data rows until the contact id changes |
| 3115 | do { |
| 3116 | if (rawContactId != cursor.getLong(columnRawContactId)) { |
| 3117 | break; |
| 3118 | } |
| 3119 | // add the data to to the contact |
| 3120 | cv = new ContentValues(); |
| 3121 | cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID))); |
| 3122 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 3123 | Data.RES_PACKAGE); |
| 3124 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE); |
| 3125 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY); |
| 3126 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, |
| 3127 | Data.IS_SUPER_PRIMARY); |
| 3128 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION); |
| 3129 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 3130 | CommonDataKinds.GroupMembership.GROUP_SOURCE_ID); |
| 3131 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, |
| 3132 | Data.DATA_VERSION); |
| 3133 | for (String key : DATA_KEYS) { |
| 3134 | final int columnIndex = cursor.getColumnIndexOrThrow(key); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 3135 | switch (cursor.getType(columnIndex)) { |
| 3136 | case Cursor.FIELD_TYPE_NULL: |
| 3137 | // don't put anything |
| 3138 | break; |
| 3139 | case Cursor.FIELD_TYPE_INTEGER: |
| 3140 | case Cursor.FIELD_TYPE_FLOAT: |
| 3141 | case Cursor.FIELD_TYPE_STRING: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 3142 | cv.put(key, cursor.getString(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 3143 | break; |
| 3144 | case Cursor.FIELD_TYPE_BLOB: |
Fred Quintana | 274dc9d | 2009-12-11 13:17:08 -0800 | [diff] [blame] | 3145 | cv.put(key, cursor.getBlob(columnIndex)); |
Daniel Lehmann | 156add9 | 2010-07-19 18:01:10 -0700 | [diff] [blame] | 3146 | break; |
| 3147 | default: |
| 3148 | throw new IllegalStateException("Invalid or unhandled data type"); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3149 | } |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 3150 | } |
| 3151 | contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv); |
| 3152 | } while (cursor.moveToNext()); |
| 3153 | |
| 3154 | return contact; |
| 3155 | } |
| 3156 | |
| 3157 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 3158 | } |
| 3159 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3160 | /** |
| 3161 | * Social status update columns. |
| 3162 | * |
| 3163 | * @see StatusUpdates |
| 3164 | * @see ContactsContract.Data |
| 3165 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3166 | protected interface StatusColumns { |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3167 | /** |
Dmitri Plotnikov | a60479d | 2009-09-27 20:16:31 -0700 | [diff] [blame] | 3168 | * Contact's latest presence level. |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3169 | * <P>Type: INTEGER (one of the values below)</P> |
| 3170 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3171 | public static final String PRESENCE = "mode"; |
| 3172 | |
| 3173 | /** |
| 3174 | * @deprecated use {@link #PRESENCE} |
| 3175 | */ |
| 3176 | @Deprecated |
| 3177 | public static final String PRESENCE_STATUS = PRESENCE; |
| 3178 | |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3179 | /** |
| 3180 | * An allowed value of {@link #PRESENCE}. |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3181 | */ |
| 3182 | int OFFLINE = 0; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3183 | |
| 3184 | /** |
| 3185 | * An allowed value of {@link #PRESENCE}. |
| 3186 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3187 | int INVISIBLE = 1; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3188 | |
| 3189 | /** |
| 3190 | * An allowed value of {@link #PRESENCE}. |
| 3191 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3192 | int AWAY = 2; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3193 | |
| 3194 | /** |
| 3195 | * An allowed value of {@link #PRESENCE}. |
| 3196 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3197 | int IDLE = 3; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3198 | |
| 3199 | /** |
| 3200 | * An allowed value of {@link #PRESENCE}. |
| 3201 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3202 | int DO_NOT_DISTURB = 4; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3203 | |
| 3204 | /** |
| 3205 | * An allowed value of {@link #PRESENCE}. |
| 3206 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3207 | int AVAILABLE = 5; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3208 | |
| 3209 | /** |
| 3210 | * Contact latest status update. |
| 3211 | * <p>Type: TEXT</p> |
| 3212 | */ |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3213 | public static final String STATUS = "status"; |
| 3214 | |
| 3215 | /** |
| 3216 | * @deprecated use {@link #STATUS} |
| 3217 | */ |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 3218 | @Deprecated |
Jeff Hamilton | f3960b1 | 2009-11-20 20:04:03 -0800 | [diff] [blame] | 3219 | public static final String PRESENCE_CUSTOM_STATUS = STATUS; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3220 | |
| 3221 | /** |
| 3222 | * The absolute time in milliseconds when the latest status was inserted/updated. |
| 3223 | * <p>Type: NUMBER</p> |
| 3224 | */ |
| 3225 | public static final String STATUS_TIMESTAMP = "status_ts"; |
| 3226 | |
| 3227 | /** |
| 3228 | * The package containing resources for this status: label and icon. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3229 | * <p>Type: TEXT</p> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3230 | */ |
| 3231 | public static final String STATUS_RES_PACKAGE = "status_res_package"; |
| 3232 | |
| 3233 | /** |
| 3234 | * The resource ID of the label describing the source of the status update, e.g. "Google |
| 3235 | * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 3236 | * <p>Type: NUMBER</p> |
| 3237 | */ |
| 3238 | public static final String STATUS_LABEL = "status_label"; |
| 3239 | |
| 3240 | /** |
| 3241 | * The resource ID of the icon for the source of the status update. |
| 3242 | * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 3243 | * <p>Type: NUMBER</p> |
| 3244 | */ |
| 3245 | public static final String STATUS_ICON = "status_icon"; |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3246 | |
| 3247 | /** |
| 3248 | * Contact's audio/video chat capability level. |
| 3249 | * <P>Type: INTEGER (one of the values below)</P> |
| 3250 | */ |
| 3251 | public static final String CHAT_CAPABILITY = "chat_capability"; |
| 3252 | |
| 3253 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3254 | * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone |
| 3255 | * and speaker) |
| 3256 | */ |
| 3257 | public static final int CAPABILITY_HAS_VOICE = 1; |
| 3258 | |
| 3259 | /** |
| 3260 | * 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] | 3261 | * display a video feed. |
| 3262 | */ |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3263 | public static final int CAPABILITY_HAS_VIDEO = 2; |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 3264 | |
| 3265 | /** |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 3266 | * 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] | 3267 | * camera that can be used for video chat (e.g. a front-facing camera on a phone). |
| 3268 | */ |
| 3269 | public static final int CAPABILITY_HAS_CAMERA = 4; |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 3270 | } |
| 3271 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 3272 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3273 | * <p> |
| 3274 | * Constants for the stream_items table, which contains social stream updates from |
| 3275 | * the user's contact list. |
| 3276 | * </p> |
| 3277 | * <p> |
| 3278 | * Only a certain number of stream items will ever be stored under a given raw contact. |
| 3279 | * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to |
| 3280 | * determine this limit, and should restrict the number of items inserted in any given |
| 3281 | * transaction correspondingly. Insertion of more items beyond the limit will |
| 3282 | * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}. |
| 3283 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3284 | * <p> |
| 3285 | * Access to the social stream through these URIs requires additional permissions beyond the |
| 3286 | * read/write contact permissions required by the provider. Querying for social stream data |
| 3287 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social |
| 3288 | * stream items requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3289 | * </p> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3290 | * <h3>Account check</h3> |
| 3291 | * <p> |
| 3292 | * The content URIs to the insert, update and delete operations are required to have the account |
| 3293 | * information matching that of the owning raw contact as query parameters, namely |
| 3294 | * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. |
| 3295 | * {@link RawContacts#DATA_SET} isn't required. |
| 3296 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3297 | * <h3>Operations</h3> |
| 3298 | * <dl> |
| 3299 | * <dt><b>Insert</b></dt> |
| 3300 | * <dd> |
| 3301 | * <p>Social stream updates are always associated with a raw contact. There are a couple |
| 3302 | * of ways to insert these entries. |
| 3303 | * <dl> |
| 3304 | * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt> |
| 3305 | * <dd> |
| 3306 | * <pre> |
| 3307 | * ContentValues values = new ContentValues(); |
| 3308 | * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); |
| 3309 | * values.put(StreamItems.TIMESTAMP, timestamp); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3310 | * values.put(StreamItems.COMMENTS, "3 people reshared this"); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3311 | * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon(); |
| 3312 | * ContentUris.appendId(builder, rawContactId); |
| 3313 | * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY); |
| 3314 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3315 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3316 | * Uri streamItemUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3317 | * long streamItemId = ContentUris.parseId(streamItemUri); |
| 3318 | * </pre> |
| 3319 | * </dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3320 | * <dt>Via {@link StreamItems#CONTENT_URI}:</dt> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3321 | * <dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3322 | *<pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3323 | * ContentValues values = new ContentValues(); |
| 3324 | * values.put(StreamItems.RAW_CONTACT_ID, rawContactId); |
| 3325 | * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys"); |
| 3326 | * values.put(StreamItems.TIMESTAMP, timestamp); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3327 | * values.put(StreamItems.COMMENTS, "3 people reshared this"); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3328 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3329 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3330 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3331 | * Uri streamItemUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3332 | * long streamItemId = ContentUris.parseId(streamItemUri); |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3333 | *</pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3334 | * </dd> |
| 3335 | * </dl> |
| 3336 | * </dd> |
| 3337 | * </p> |
| 3338 | * <p> |
| 3339 | * Once a {@link StreamItems} entry has been inserted, photos associated with that |
| 3340 | * social update can be inserted. For example, after one of the insertions above, |
| 3341 | * photos could be added to the stream item in one of the following ways: |
| 3342 | * <dl> |
| 3343 | * <dt>Via a URI including the stream item ID:</dt> |
| 3344 | * <dd> |
| 3345 | * <pre> |
| 3346 | * values.clear(); |
| 3347 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3348 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3349 | * getContentResolver().insert(Uri.withAppendedPath( |
| 3350 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId), |
| 3351 | * StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values); |
| 3352 | * </pre> |
| 3353 | * </dd> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3354 | * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3355 | * <dd> |
| 3356 | * <pre> |
| 3357 | * values.clear(); |
| 3358 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
| 3359 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3360 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3361 | * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values); |
| 3362 | * </pre> |
Scott Main | 4510705 | 2011-09-26 21:52:05 -0700 | [diff] [blame] | 3363 | * <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] | 3364 | * photos in a single transaction, by using {@link ContentProviderOperation} with |
| 3365 | * back references to populate the stream item ID in the {@link ContentValues}. |
| 3366 | * </dd> |
| 3367 | * </dl> |
| 3368 | * </p> |
| 3369 | * </dd> |
| 3370 | * <dt><b>Update</b></dt> |
| 3371 | * <dd>Updates can be performed by appending the stream item ID to the |
| 3372 | * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were |
| 3373 | * created by the calling package can be updated.</dd> |
| 3374 | * <dt><b>Delete</b></dt> |
| 3375 | * <dd>Deletes can be performed by appending the stream item ID to the |
| 3376 | * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were |
| 3377 | * created by the calling package can be deleted.</dd> |
| 3378 | * <dt><b>Query</b></dt> |
| 3379 | * <dl> |
| 3380 | * <dt>Finding all social stream updates for a given contact</dt> |
| 3381 | * <dd>By Contact ID: |
| 3382 | * <pre> |
| 3383 | * Cursor c = getContentResolver().query(Uri.withAppendedPath( |
| 3384 | * ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId), |
| 3385 | * Contacts.StreamItems.CONTENT_DIRECTORY), |
| 3386 | * null, null, null, null); |
| 3387 | * </pre> |
| 3388 | * </dd> |
| 3389 | * <dd>By lookup key: |
| 3390 | * <pre> |
| 3391 | * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon() |
| 3392 | * .appendPath(lookupKey) |
| 3393 | * .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(), |
| 3394 | * null, null, null, null); |
| 3395 | * </pre> |
| 3396 | * </dd> |
| 3397 | * <dt>Finding all social stream updates for a given raw contact</dt> |
| 3398 | * <dd> |
| 3399 | * <pre> |
| 3400 | * Cursor c = getContentResolver().query(Uri.withAppendedPath( |
| 3401 | * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), |
| 3402 | * RawContacts.StreamItems.CONTENT_DIRECTORY)), |
| 3403 | * null, null, null, null); |
| 3404 | * </pre> |
| 3405 | * </dd> |
| 3406 | * <dt>Querying for a specific stream item by ID</dt> |
| 3407 | * <dd> |
| 3408 | * <pre> |
| 3409 | * Cursor c = getContentResolver().query(ContentUris.withAppendedId( |
| 3410 | * StreamItems.CONTENT_URI, streamItemId), |
| 3411 | * null, null, null, null); |
| 3412 | * </pre> |
| 3413 | * </dd> |
| 3414 | * </dl> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3415 | * |
| 3416 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3417 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3418 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3419 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3420 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3421 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3422 | public static final class StreamItems implements BaseColumns, StreamItemsColumns { |
| 3423 | /** |
| 3424 | * This utility class cannot be instantiated |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3425 | * |
| 3426 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3427 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3428 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3429 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3430 | private StreamItems() { |
| 3431 | } |
| 3432 | |
| 3433 | /** |
| 3434 | * The content:// style URI for this table, which handles social network stream |
| 3435 | * updates for the user's contacts. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3436 | * |
| 3437 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3438 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3439 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3440 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3441 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items"); |
| 3442 | |
| 3443 | /** |
| 3444 | * <p> |
| 3445 | * A content:// style URI for the photos stored in a sub-table underneath |
| 3446 | * stream items. This is only used for inserts, and updates - queries and deletes |
| 3447 | * for photos should be performed by appending |
| 3448 | * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a |
| 3449 | * specific stream item. |
| 3450 | * </p> |
| 3451 | * <p> |
| 3452 | * When using this URI, the stream item ID for the photo(s) must be identified |
| 3453 | * in the {@link ContentValues} passed in. |
| 3454 | * </p> |
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 | public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo"); |
| 3461 | |
| 3462 | /** |
| 3463 | * 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] | 3464 | * that will be stored under any single raw contact. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3465 | * |
| 3466 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3467 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3468 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3469 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3470 | public static final Uri CONTENT_LIMIT_URI = |
| 3471 | Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit"); |
| 3472 | |
| 3473 | /** |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3474 | * The MIME type of a directory of stream items. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3475 | * |
| 3476 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3477 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3478 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3479 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3480 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item"; |
| 3481 | |
| 3482 | /** |
| 3483 | * The MIME type of a single stream item. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3484 | * |
| 3485 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3486 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3487 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3488 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3489 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/stream_item"; |
| 3490 | |
| 3491 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3492 | * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will |
| 3493 | * contain this column, with the value indicating the maximum number of |
| 3494 | * stream items 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 String MAX_ITEMS = "max_items"; |
| 3501 | |
| 3502 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3503 | * <p> |
| 3504 | * A sub-directory of a single stream item entry that contains all of its |
| 3505 | * photo rows. To access this |
| 3506 | * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to |
| 3507 | * an individual stream item URI. |
| 3508 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3509 | * <p> |
| 3510 | * Access to social stream photos requires additional permissions beyond the read/write |
| 3511 | * contact permissions required by the provider. Querying for social stream photos |
| 3512 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating |
| 3513 | * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3514 | * </p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3515 | * |
| 3516 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3517 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3518 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3519 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3520 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3521 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3522 | public static final class StreamItemPhotos |
| 3523 | implements BaseColumns, StreamItemPhotosColumns { |
| 3524 | /** |
| 3525 | * No public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3526 | * |
| 3527 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3528 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3529 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3530 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3531 | private StreamItemPhotos() { |
| 3532 | } |
| 3533 | |
| 3534 | /** |
| 3535 | * The directory twig for this sub-table |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3536 | * |
| 3537 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3538 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3539 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3540 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3541 | public static final String CONTENT_DIRECTORY = "photo"; |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3542 | |
| 3543 | /** |
| 3544 | * The MIME type of a directory of stream item photos. |
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. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3548 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3549 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3550 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item_photo"; |
| 3551 | |
| 3552 | /** |
| 3553 | * The MIME type of a single stream item photo. |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3554 | * |
| 3555 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3556 | * cursors returned from related queries will be empty. |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3557 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3558 | @Deprecated |
Makoto Onuki | fc6d2fd | 2011-08-22 14:04:01 -0700 | [diff] [blame] | 3559 | public static final String CONTENT_ITEM_TYPE |
| 3560 | = "vnd.android.cursor.item/stream_item_photo"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3561 | } |
| 3562 | } |
| 3563 | |
| 3564 | /** |
| 3565 | * Columns in the StreamItems table. |
| 3566 | * |
| 3567 | * @see ContactsContract.StreamItems |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3568 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3569 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3570 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3571 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3572 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3573 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3574 | protected interface StreamItemsColumns { |
| 3575 | /** |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3576 | * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} |
| 3577 | * that this stream item belongs to. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3578 | * |
| 3579 | * <p>Type: INTEGER</p> |
| 3580 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3581 | * |
| 3582 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3583 | * cursors returned from related queries will be empty. |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3584 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3585 | @Deprecated |
Daniel Lehmann | e8aae09 | 2011-08-24 16:41:00 -0700 | [diff] [blame] | 3586 | public static final String CONTACT_ID = "contact_id"; |
| 3587 | |
| 3588 | /** |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3589 | * A reference to the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY} |
| 3590 | * that this stream item belongs to. |
| 3591 | * |
| 3592 | * <p>Type: TEXT</p> |
| 3593 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3594 | * |
| 3595 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3596 | * cursors returned from related queries will be empty. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3597 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3598 | @Deprecated |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3599 | public static final String CONTACT_LOOKUP_KEY = "contact_lookup"; |
| 3600 | |
| 3601 | /** |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3602 | * A reference to the {@link RawContacts#_ID} |
| 3603 | * that this stream item belongs to. |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3604 | * <p>Type: INTEGER</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3605 | * |
| 3606 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3607 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3608 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3609 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3610 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 3611 | |
| 3612 | /** |
| 3613 | * The package name to use when creating {@link Resources} objects for |
| 3614 | * this stream item. This value is only designed for use when building |
| 3615 | * user interfaces, and should not be used to infer the owner. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3616 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3617 | * |
| 3618 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3619 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3620 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3621 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3622 | public static final String RES_PACKAGE = "res_package"; |
| 3623 | |
| 3624 | /** |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3625 | * The account type to which the raw_contact of this item is associated. See |
| 3626 | * {@link RawContacts#ACCOUNT_TYPE} |
| 3627 | * |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3628 | * <p>Type: TEXT</p> |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3629 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3630 | * |
| 3631 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3632 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3633 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3634 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3635 | public static final String ACCOUNT_TYPE = "account_type"; |
| 3636 | |
| 3637 | /** |
| 3638 | * The account name to which the raw_contact of this item is associated. See |
| 3639 | * {@link RawContacts#ACCOUNT_NAME} |
| 3640 | * |
Daniel Lehmann | ceb476a | 2011-08-29 14:37:31 -0700 | [diff] [blame] | 3641 | * <p>Type: TEXT</p> |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3642 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3643 | * |
| 3644 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3645 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3646 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3647 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3648 | public static final String ACCOUNT_NAME = "account_name"; |
| 3649 | |
| 3650 | /** |
| 3651 | * The data set within the account that the raw_contact of this row belongs to. This allows |
| 3652 | * multiple sync adapters for the same account type to distinguish between |
| 3653 | * each others' data. |
| 3654 | * {@link RawContacts#DATA_SET} |
| 3655 | * |
| 3656 | * <P>Type: TEXT</P> |
| 3657 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3658 | * |
| 3659 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3660 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3661 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3662 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3663 | public static final String DATA_SET = "data_set"; |
| 3664 | |
| 3665 | /** |
| 3666 | * The source_id of the raw_contact that this row belongs to. |
| 3667 | * {@link RawContacts#SOURCE_ID} |
| 3668 | * |
| 3669 | * <P>Type: TEXT</P> |
| 3670 | * <p>read-only</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3671 | * |
| 3672 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3673 | * cursors returned from related queries will be empty. |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3674 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3675 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3676 | public static final String RAW_CONTACT_SOURCE_ID = "raw_contact_source_id"; |
| 3677 | |
| 3678 | /** |
| 3679 | * The resource name of the icon for the source of the stream item. |
| 3680 | * This resource should be scoped by the {@link #RES_PACKAGE}. As this can only reference |
| 3681 | * drawables, the "@drawable/" prefix must be omitted. |
| 3682 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3683 | * |
| 3684 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3685 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3686 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3687 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3688 | public static final String RES_ICON = "icon"; |
| 3689 | |
| 3690 | /** |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3691 | * The resource name of the label describing the source of the status update, e.g. "Google |
| 3692 | * Talk". This resource should be scoped by the {@link #RES_PACKAGE}. As this can only |
| 3693 | * reference strings, the "@string/" prefix must be omitted. |
| 3694 | * <p>Type: TEXT</p> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3695 | * |
| 3696 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3697 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3698 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3699 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3700 | public static final String RES_LABEL = "label"; |
| 3701 | |
| 3702 | /** |
| 3703 | * <P> |
| 3704 | * The main textual contents of the item. Typically this is content |
| 3705 | * that was posted by the source of this stream item, but it can also |
| 3706 | * be a textual representation of an action (e.g. ”Checked in at Joe's”). |
| 3707 | * This text is displayed to the user and allows formatting and embedded |
| 3708 | * resource images via HTML (as parseable via |
| 3709 | * {@link android.text.Html#fromHtml}). |
| 3710 | * </P> |
| 3711 | * <P> |
| 3712 | * Long content may be truncated and/or ellipsized - the exact behavior |
| 3713 | * is unspecified, but it should not break tags. |
| 3714 | * </P> |
| 3715 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3716 | * |
| 3717 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3718 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3719 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3720 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3721 | public static final String TEXT = "text"; |
| 3722 | |
| 3723 | /** |
| 3724 | * The absolute time (milliseconds since epoch) when this stream item was |
| 3725 | * inserted/updated. |
| 3726 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3727 | * |
| 3728 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3729 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3730 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3731 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3732 | public static final String TIMESTAMP = "timestamp"; |
| 3733 | |
| 3734 | /** |
| 3735 | * <P> |
| 3736 | * Summary information about the stream item, for example to indicate how |
| 3737 | * many people have reshared it, how many have liked it, how many thumbs |
| 3738 | * up and/or thumbs down it has, what the original source was, etc. |
| 3739 | * </P> |
| 3740 | * <P> |
| 3741 | * This text is displayed to the user and allows simple formatting via |
| 3742 | * HTML, in the same manner as {@link #TEXT} allows. |
| 3743 | * </P> |
| 3744 | * <P> |
| 3745 | * Long content may be truncated and/or ellipsized - the exact behavior |
| 3746 | * is unspecified, but it should not break tags. |
| 3747 | * </P> |
| 3748 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3749 | * |
| 3750 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3751 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3752 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3753 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3754 | public static final String COMMENTS = "comments"; |
| 3755 | |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3756 | /** |
| 3757 | * Generic column for use by sync adapters. |
| 3758 | * |
| 3759 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3760 | * cursors returned from related queries will be empty. |
| 3761 | */ |
| 3762 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3763 | public static final String SYNC1 = "stream_item_sync1"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3764 | /** |
| 3765 | * Generic column for use by sync adapters. |
| 3766 | * |
| 3767 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3768 | * cursors returned from related queries will be empty. |
| 3769 | */ |
| 3770 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3771 | public static final String SYNC2 = "stream_item_sync2"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3772 | /** |
| 3773 | * Generic column for use by sync adapters. |
| 3774 | * |
| 3775 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3776 | * cursors returned from related queries will be empty. |
| 3777 | */ |
| 3778 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3779 | public static final String SYNC3 = "stream_item_sync3"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3780 | /** |
| 3781 | * Generic column for use by sync adapters. |
| 3782 | * |
| 3783 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3784 | * cursors returned from related queries will be empty. |
| 3785 | */ |
| 3786 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 3787 | public static final String SYNC4 = "stream_item_sync4"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3788 | } |
| 3789 | |
| 3790 | /** |
| 3791 | * <p> |
| 3792 | * Constants for the stream_item_photos table, which contains photos associated with |
| 3793 | * social stream updates. |
| 3794 | * </p> |
Dave Santoro | 0b61f59 | 2011-10-03 18:25:26 -0700 | [diff] [blame] | 3795 | * <p> |
| 3796 | * Access to social stream photos requires additional permissions beyond the read/write |
| 3797 | * contact permissions required by the provider. Querying for social stream photos |
| 3798 | * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating |
| 3799 | * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission. |
| 3800 | * </p> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3801 | * <h3>Account check</h3> |
| 3802 | * <p> |
| 3803 | * The content URIs to the insert, update and delete operations are required to have the account |
| 3804 | * information matching that of the owning raw contact as query parameters, namely |
| 3805 | * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}. |
| 3806 | * {@link RawContacts#DATA_SET} isn't required. |
| 3807 | * </p> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3808 | * <h3>Operations</h3> |
| 3809 | * <dl> |
| 3810 | * <dt><b>Insert</b></dt> |
| 3811 | * <dd> |
| 3812 | * <p>Social stream photo entries are associated with a social stream item. Photos |
| 3813 | * can be inserted into a social stream item in a couple of ways: |
| 3814 | * <dl> |
| 3815 | * <dt> |
| 3816 | * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a |
| 3817 | * stream item: |
| 3818 | * </dt> |
| 3819 | * <dd> |
| 3820 | * <pre> |
| 3821 | * ContentValues values = new ContentValues(); |
| 3822 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3823 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3824 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3825 | * ContentUris.appendId(builder, streamItemId); |
| 3826 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3827 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3828 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3829 | * Uri photoUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3830 | * long photoId = ContentUris.parseId(photoUri); |
| 3831 | * </pre> |
| 3832 | * </dd> |
| 3833 | * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> |
| 3834 | * <dd> |
| 3835 | * <pre> |
| 3836 | * ContentValues values = new ContentValues(); |
| 3837 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
| 3838 | * values.put(StreamItemPhotos.SORT_INDEX, 1); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3839 | * values.put(StreamItemPhotos.PHOTO, photoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3840 | * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); |
| 3841 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3842 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3843 | * Uri photoUri = getContentResolver().insert(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3844 | * long photoId = ContentUris.parseId(photoUri); |
| 3845 | * </pre> |
| 3846 | * </dd> |
| 3847 | * </dl> |
| 3848 | * </p> |
| 3849 | * </dd> |
| 3850 | * <dt><b>Update</b></dt> |
| 3851 | * <dd> |
| 3852 | * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry, |
| 3853 | * identified by both the stream item ID it belongs to and the stream item photo ID. |
| 3854 | * This can be specified in two ways. |
| 3855 | * <dl> |
| 3856 | * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a |
| 3857 | * stream item: |
| 3858 | * </dt> |
| 3859 | * <dd> |
| 3860 | * <pre> |
| 3861 | * ContentValues values = new ContentValues(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3862 | * values.put(StreamItemPhotos.PHOTO, newPhotoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3863 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3864 | * ContentUris.appendId(builder, streamItemId); |
| 3865 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3866 | * ContentUris.appendId(builder, streamItemPhotoId); |
| 3867 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3868 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3869 | * getContentResolver().update(builder.build(), values, null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3870 | * </pre> |
| 3871 | * </dd> |
| 3872 | * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt> |
| 3873 | * <dd> |
| 3874 | * <pre> |
| 3875 | * ContentValues values = new ContentValues(); |
| 3876 | * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3877 | * values.put(StreamItemPhotos.PHOTO, newPhotoData); |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3878 | * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon(); |
| 3879 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3880 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3881 | * getContentResolver().update(builder.build(), values); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3882 | * </pre> |
| 3883 | * </dd> |
| 3884 | * </dl> |
| 3885 | * </p> |
| 3886 | * </dd> |
| 3887 | * <dt><b>Delete</b></dt> |
| 3888 | * <dd>Deletes can be made against either a specific photo item in a stream item, or |
| 3889 | * against all or a selected subset of photo items under a stream item. |
| 3890 | * For example: |
| 3891 | * <dl> |
| 3892 | * <dt>Deleting a single photo via the |
| 3893 | * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item: |
| 3894 | * </dt> |
| 3895 | * <dd> |
| 3896 | * <pre> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3897 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3898 | * ContentUris.appendId(builder, streamItemId); |
| 3899 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3900 | * ContentUris.appendId(builder, streamItemPhotoId); |
| 3901 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3902 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3903 | * getContentResolver().delete(builder.build(), null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3904 | * </pre> |
| 3905 | * </dd> |
| 3906 | * <dt>Deleting all photos under a stream item</dt> |
| 3907 | * <dd> |
| 3908 | * <pre> |
Makoto Onuki | 46891a8 | 2012-04-26 12:46:47 -0700 | [diff] [blame] | 3909 | * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon(); |
| 3910 | * ContentUris.appendId(builder, streamItemId); |
| 3911 | * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY); |
| 3912 | * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName); |
| 3913 | * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType); |
| 3914 | * getContentResolver().delete(builder.build(), null, null); |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3915 | * </pre> |
| 3916 | * </dd> |
| 3917 | * </dl> |
| 3918 | * </dd> |
| 3919 | * <dt><b>Query</b></dt> |
| 3920 | * <dl> |
| 3921 | * <dt>Querying for a specific photo in a stream item</dt> |
| 3922 | * <dd> |
| 3923 | * <pre> |
| 3924 | * Cursor c = getContentResolver().query( |
| 3925 | * ContentUris.withAppendedId( |
| 3926 | * Uri.withAppendedPath( |
| 3927 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) |
| 3928 | * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), |
| 3929 | * streamItemPhotoId), null, null, null, null); |
| 3930 | * </pre> |
| 3931 | * </dd> |
| 3932 | * <dt>Querying for all photos in a stream item</dt> |
| 3933 | * <dd> |
| 3934 | * <pre> |
| 3935 | * Cursor c = getContentResolver().query( |
| 3936 | * Uri.withAppendedPath( |
| 3937 | * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId) |
| 3938 | * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY), |
| 3939 | * null, null, null, StreamItemPhotos.SORT_INDEX); |
| 3940 | * </pre> |
| 3941 | * </dl> |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3942 | * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a |
| 3943 | * {@link StreamItemPhotos#PHOTO_URI}. The {@link StreamItemPhotos#PHOTO_FILE_ID} |
| 3944 | * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to |
| 3945 | * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as |
| 3946 | * an asset file, as follows: |
| 3947 | * <pre> |
| 3948 | * public InputStream openDisplayPhoto(String photoUri) { |
| 3949 | * try { |
| 3950 | * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r"); |
| 3951 | * return fd.createInputStream(); |
| 3952 | * } catch (IOException e) { |
| 3953 | * return null; |
| 3954 | * } |
| 3955 | * } |
| 3956 | * <pre> |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3957 | * </dd> |
| 3958 | * </dl> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3959 | * |
| 3960 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3961 | * cursors returned from related queries will be empty. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3962 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 3963 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3964 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3965 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3966 | public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns { |
| 3967 | /** |
| 3968 | * No public constructor since this is a utility class |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3969 | * |
| 3970 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3971 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3972 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3973 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3974 | private StreamItemPhotos() { |
| 3975 | } |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3976 | |
| 3977 | /** |
| 3978 | * <p> |
| 3979 | * The binary representation of the photo. Any size photo can be inserted; |
| 3980 | * the provider will resize it appropriately for storage and display. |
| 3981 | * </p> |
| 3982 | * <p> |
| 3983 | * This is only intended for use when inserting or updating a stream item photo. |
| 3984 | * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI} |
| 3985 | * as an asset file. |
| 3986 | * </p> |
| 3987 | * <P>Type: BLOB</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3988 | * |
| 3989 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 3990 | * cursors returned from related queries will be empty. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3991 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 3992 | @Deprecated |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 3993 | public static final String PHOTO = "photo"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 3994 | } |
| 3995 | |
| 3996 | /** |
| 3997 | * Columns in the StreamItemPhotos table. |
| 3998 | * |
| 3999 | * @see ContactsContract.StreamItemPhotos |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 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. |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 4002 | * |
Svetoslav Ganov | 6d2c0e5 | 2015-06-23 16:33:36 +0000 | [diff] [blame] | 4003 | * @removed |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4004 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4005 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4006 | protected interface StreamItemPhotosColumns { |
| 4007 | /** |
| 4008 | * A reference to the {@link StreamItems#_ID} this photo is associated with. |
| 4009 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4010 | * |
| 4011 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4012 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4013 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4014 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4015 | public static final String STREAM_ITEM_ID = "stream_item_id"; |
| 4016 | |
| 4017 | /** |
| 4018 | * An integer to use for sort order for photos in the stream item. If not |
| 4019 | * specified, the {@link StreamItemPhotos#_ID} will be used for sorting. |
| 4020 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4021 | * |
| 4022 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4023 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4024 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4025 | @Deprecated |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4026 | public static final String SORT_INDEX = "sort_index"; |
| 4027 | |
| 4028 | /** |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 4029 | * Photo file ID for the photo. |
| 4030 | * See {@link ContactsContract.DisplayPhoto}. |
| 4031 | * <P>Type: NUMBER</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4032 | * |
| 4033 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4034 | * cursors returned from related queries will be empty. |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4035 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4036 | @Deprecated |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 4037 | public static final String PHOTO_FILE_ID = "photo_file_id"; |
| 4038 | |
| 4039 | /** |
| 4040 | * URI for retrieving the photo content, automatically populated. Callers |
| 4041 | * may retrieve the photo content by opening this URI as an asset file. |
| 4042 | * <P>Type: TEXT</P> |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4043 | * |
| 4044 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4045 | * cursors returned from related queries will be empty. |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 4046 | */ |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4047 | @Deprecated |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 4048 | public static final String PHOTO_URI = "photo_uri"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4049 | |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4050 | /** |
| 4051 | * Generic column for use by sync adapters. |
| 4052 | * |
| 4053 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4054 | * cursors returned from related queries will be empty. |
| 4055 | */ |
| 4056 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 4057 | public static final String SYNC1 = "stream_item_photo_sync1"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4058 | /** |
| 4059 | * Generic column for use by sync adapters. |
| 4060 | * |
| 4061 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4062 | * cursors returned from related queries will be empty. |
| 4063 | */ |
| 4064 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 4065 | public static final String SYNC2 = "stream_item_photo_sync2"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4066 | /** |
| 4067 | * Generic column for use by sync adapters. |
| 4068 | * |
| 4069 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4070 | * cursors returned from related queries will be empty. |
| 4071 | */ |
| 4072 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 4073 | public static final String SYNC3 = "stream_item_photo_sync3"; |
Brian Attwell | bdb13c8 | 2014-07-16 21:43:54 -0700 | [diff] [blame] | 4074 | /** |
| 4075 | * Generic column for use by sync adapters. |
| 4076 | * |
| 4077 | * @deprecated - Do not use. This will not be supported in the future. In the future, |
| 4078 | * cursors returned from related queries will be empty. |
| 4079 | */ |
| 4080 | @Deprecated |
Daniel Lehmann | f188dfd | 2011-08-14 15:39:22 -0700 | [diff] [blame] | 4081 | public static final String SYNC4 = "stream_item_photo_sync4"; |
Dave Santoro | d414f10 | 2011-06-20 14:35:06 -0700 | [diff] [blame] | 4082 | } |
| 4083 | |
| 4084 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 4085 | * <p> |
| 4086 | * Constants for the photo files table, which tracks metadata for hi-res photos |
| 4087 | * stored in the file system. |
| 4088 | * </p> |
| 4089 | * |
| 4090 | * @hide |
| 4091 | */ |
| 4092 | public static final class PhotoFiles implements BaseColumns, PhotoFilesColumns { |
| 4093 | /** |
| 4094 | * No public constructor since this is a utility class |
| 4095 | */ |
| 4096 | private PhotoFiles() { |
| 4097 | } |
| 4098 | } |
| 4099 | |
| 4100 | /** |
| 4101 | * Columns in the PhotoFiles table. |
| 4102 | * |
| 4103 | * @see ContactsContract.PhotoFiles |
| 4104 | * |
| 4105 | * @hide |
| 4106 | */ |
| 4107 | protected interface PhotoFilesColumns { |
| 4108 | |
| 4109 | /** |
| 4110 | * The height, in pixels, of the photo this entry is associated with. |
| 4111 | * <P>Type: NUMBER</P> |
| 4112 | */ |
| 4113 | public static final String HEIGHT = "height"; |
| 4114 | |
| 4115 | /** |
| 4116 | * The width, in pixels, of the photo this entry is associated with. |
| 4117 | * <P>Type: NUMBER</P> |
| 4118 | */ |
| 4119 | public static final String WIDTH = "width"; |
| 4120 | |
| 4121 | /** |
| 4122 | * The size, in bytes, of the photo stored on disk. |
| 4123 | * <P>Type: NUMBER</P> |
| 4124 | */ |
| 4125 | public static final String FILESIZE = "filesize"; |
| 4126 | } |
| 4127 | |
| 4128 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4129 | * Columns in the Data table. |
| 4130 | * |
| 4131 | * @see ContactsContract.Data |
| 4132 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 4133 | protected interface DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4134 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4135 | * The package name to use when creating {@link Resources} objects for |
| 4136 | * this data row. This value is only designed for use when building user |
| 4137 | * interfaces, and should not be used to infer the owner. |
| 4138 | */ |
| 4139 | public static final String RES_PACKAGE = "res_package"; |
| 4140 | |
| 4141 | /** |
| 4142 | * The MIME type of the item represented by this row. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4143 | */ |
| 4144 | public static final String MIMETYPE = "mimetype"; |
| 4145 | |
| 4146 | /** |
Zheng Fu | 9ea9a13 | 2015-01-07 11:33:19 -0800 | [diff] [blame] | 4147 | * Hash id on the data fields, used for backup and restore. |
| 4148 | * |
| 4149 | * @hide |
| 4150 | */ |
| 4151 | public static final String HASH_ID = "hash_id"; |
| 4152 | |
| 4153 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 4154 | * A reference to the {@link RawContacts#_ID} |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 4155 | * that this data belongs to. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4156 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 4157 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 4158 | |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 4159 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4160 | * 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] | 4161 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 4162 | */ |
| 4163 | public static final String IS_PRIMARY = "is_primary"; |
| 4164 | |
| 4165 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 4166 | * Whether this is the primary entry of its kind for the aggregate |
| 4167 | * contact it belongs to. Any data record that is "super primary" must |
| 4168 | * also be "primary". |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 4169 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 4170 | */ |
| 4171 | public static final String IS_SUPER_PRIMARY = "is_super_primary"; |
| 4172 | |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 4173 | /** |
Dmitri Plotnikov | 30b7be3 | 2010-07-16 10:43:40 -0700 | [diff] [blame] | 4174 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 4175 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 4176 | * <P>Type: INTEGER</P> |
| 4177 | */ |
| 4178 | public static final String IS_READ_ONLY = "is_read_only"; |
| 4179 | |
| 4180 | /** |
Fred Quintana | c933fb6 | 2009-06-11 12:14:40 -0700 | [diff] [blame] | 4181 | * The version of this data record. This is a read-only value. The data column is |
| 4182 | * guaranteed to not change without the version going up. This value is monotonically |
| 4183 | * increasing. |
| 4184 | * <P>Type: INTEGER</P> |
| 4185 | */ |
| 4186 | public static final String DATA_VERSION = "data_version"; |
| 4187 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4188 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4189 | public static final String DATA1 = "data1"; |
| 4190 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4191 | public static final String DATA2 = "data2"; |
| 4192 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4193 | public static final String DATA3 = "data3"; |
| 4194 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4195 | public static final String DATA4 = "data4"; |
| 4196 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4197 | public static final String DATA5 = "data5"; |
| 4198 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4199 | public static final String DATA6 = "data6"; |
| 4200 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4201 | public static final String DATA7 = "data7"; |
| 4202 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4203 | public static final String DATA8 = "data8"; |
| 4204 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4205 | public static final String DATA9 = "data9"; |
| 4206 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4207 | public static final String DATA10 = "data10"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4208 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4209 | public static final String DATA11 = "data11"; |
| 4210 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4211 | public static final String DATA12 = "data12"; |
| 4212 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4213 | public static final String DATA13 = "data13"; |
| 4214 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 4215 | public static final String DATA14 = "data14"; |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4216 | /** |
| 4217 | * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention, |
| 4218 | * this field is used to store BLOBs (binary data). |
| 4219 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 4220 | public static final String DATA15 = "data15"; |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 4221 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 4222 | /** Generic column for use by sync adapters. */ |
| 4223 | public static final String SYNC1 = "data_sync1"; |
| 4224 | /** Generic column for use by sync adapters. */ |
| 4225 | public static final String SYNC2 = "data_sync2"; |
| 4226 | /** Generic column for use by sync adapters. */ |
| 4227 | public static final String SYNC3 = "data_sync3"; |
| 4228 | /** Generic column for use by sync adapters. */ |
| 4229 | public static final String SYNC4 = "data_sync4"; |
Etan Cohen | 534a65d | 2015-05-01 11:03:24 -0700 | [diff] [blame] | 4230 | |
| 4231 | /** |
| 4232 | * Carrier presence information. |
| 4233 | * <P> |
| 4234 | * Type: INTEGER (A bitmask of CARRIER_PRESENCE_* fields) |
| 4235 | * </P> |
| 4236 | */ |
| 4237 | public static final String CARRIER_PRESENCE = "carrier_presence"; |
| 4238 | |
| 4239 | /** |
Etan Cohen | e4dc7e1 | 2015-06-08 13:02:44 -0700 | [diff] [blame] | 4240 | * Indicates that the entry is Video Telephony (VT) capable on the |
| 4241 | * current carrier. An allowed bitmask of {@link #CARRIER_PRESENCE}. |
Etan Cohen | 534a65d | 2015-05-01 11:03:24 -0700 | [diff] [blame] | 4242 | */ |
| 4243 | public static final int CARRIER_PRESENCE_VT_CAPABLE = 0x01; |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 4244 | |
| 4245 | /** |
| 4246 | * The flattened {@link android.content.ComponentName} of a {@link |
| 4247 | * android.telecom.PhoneAccountHandle} that is the preferred {@code PhoneAccountHandle} to |
Ta-wei Yen | 3ec3d5b | 2017-12-13 15:25:49 -0800 | [diff] [blame] | 4248 | * call the contact with. |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 4249 | * |
Ta-wei Yen | 3ec3d5b | 2017-12-13 15:25:49 -0800 | [diff] [blame] | 4250 | * <p> On a multi-SIM device this field can be used in a {@link CommonDataKinds.Phone} row |
| 4251 | * to indicate the {@link PhoneAccountHandle} to call the number with, instead of using |
| 4252 | * {@link android.telecom.TelecomManager#getDefaultOutgoingPhoneAccount(String)} or asking |
| 4253 | * every time. |
| 4254 | * |
| 4255 | * <p>{@link android.telecom.TelecomManager#placeCall(Uri, android.os.Bundle)} |
| 4256 | * should be called with {@link android.telecom.TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE} |
| 4257 | * set to the {@link PhoneAccountHandle} using the {@link ComponentName} from this field. |
| 4258 | * |
| 4259 | * @see #PREFERRED_PHONE_ACCOUNT_ID |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 4260 | * @see PhoneAccountHandle#getComponentName() |
| 4261 | * @see ComponentName#flattenToString() |
| 4262 | */ |
| 4263 | String PREFERRED_PHONE_ACCOUNT_COMPONENT_NAME = "preferred_phone_account_component_name"; |
| 4264 | |
| 4265 | /** |
Ta-wei Yen | 3ec3d5b | 2017-12-13 15:25:49 -0800 | [diff] [blame] | 4266 | * The ID of a {@link |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 4267 | * android.telecom.PhoneAccountHandle} that is the preferred {@code PhoneAccountHandle} to |
| 4268 | * call the contact with. Used by {@link CommonDataKinds.Phone}. |
| 4269 | * |
Ta-wei Yen | 3ec3d5b | 2017-12-13 15:25:49 -0800 | [diff] [blame] | 4270 | * <p> On a multi-SIM device this field can be used in a {@link CommonDataKinds.Phone} row |
| 4271 | * to indicate the {@link PhoneAccountHandle} to call the number with, instead of using |
| 4272 | * {@link android.telecom.TelecomManager#getDefaultOutgoingPhoneAccount(String)} or asking |
| 4273 | * every time. |
| 4274 | * |
| 4275 | * <p>{@link android.telecom.TelecomManager#placeCall(Uri, android.os.Bundle)} |
| 4276 | * should be called with {@link android.telecom.TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE} |
| 4277 | * set to the {@link PhoneAccountHandle} using the id from this field. |
| 4278 | * |
| 4279 | * @see #PREFERRED_PHONE_ACCOUNT_COMPONENT_NAME |
| 4280 | * @see PhoneAccountHandle#getId() |
Ta-wei Yen | dc9daaa | 2017-11-28 17:10:48 -0800 | [diff] [blame] | 4281 | */ |
| 4282 | String PREFERRED_PHONE_ACCOUNT_ID = "preferred_phone_account_id"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4283 | } |
| 4284 | |
| 4285 | /** |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4286 | * Columns in the Data_Usage_Stat table |
| 4287 | */ |
| 4288 | protected interface DataUsageStatColumns { |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 4289 | /** |
| 4290 | * The last time (in milliseconds) this {@link Data} was used. |
| 4291 | * @deprecated Contacts affinity information is no longer supported as of |
| 4292 | * Android version {@link android.os.Build.VERSION_CODES#Q}. |
| 4293 | * This column always contains 0. |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 4294 | * |
| 4295 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete. |
| 4296 | * For more information, see the |
| 4297 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 4298 | * page. |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 4299 | */ |
| 4300 | @Deprecated |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4301 | public static final String LAST_TIME_USED = "last_time_used"; |
| 4302 | |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 4303 | /** |
| 4304 | * The number of times the referenced {@link Data} has been used. |
| 4305 | * @deprecated Contacts affinity information is no longer supported as of |
| 4306 | * Android version {@link android.os.Build.VERSION_CODES#Q}. |
| 4307 | * This column always contains 0. |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 4308 | * |
| 4309 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete. |
| 4310 | * For more information, see the |
| 4311 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 4312 | * page. |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 4313 | */ |
| 4314 | @Deprecated |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4315 | public static final String TIMES_USED = "times_used"; |
Makoto Onuki | 203145e | 2016-09-28 15:41:29 -0700 | [diff] [blame] | 4316 | |
| 4317 | /** @hide Raw value. */ |
| 4318 | public static final String RAW_LAST_TIME_USED = HIDDEN_COLUMN_PREFIX + LAST_TIME_USED; |
| 4319 | |
| 4320 | /** @hide Raw value. */ |
| 4321 | public static final String RAW_TIMES_USED = HIDDEN_COLUMN_PREFIX + TIMES_USED; |
| 4322 | |
| 4323 | /** |
| 4324 | * @hide |
| 4325 | * Low res version. Same as {@link #LAST_TIME_USED} but use it in CP2 for clarification. |
| 4326 | */ |
| 4327 | public static final String LR_LAST_TIME_USED = LAST_TIME_USED; |
| 4328 | |
| 4329 | /** |
| 4330 | * @hide |
| 4331 | * Low res version. Same as {@link #TIMES_USED} but use it in CP2 for clarification. |
| 4332 | */ |
| 4333 | public static final String LR_TIMES_USED = TIMES_USED; |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4334 | } |
| 4335 | |
| 4336 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4337 | * Combines all columns returned by {@link ContactsContract.Data} table queries. |
| 4338 | * |
| 4339 | * @see ContactsContract.Data |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4340 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 4341 | protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns, |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 4342 | RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns, |
Yorke Lee | 0dc523fa | 2013-03-12 12:48:06 -0700 | [diff] [blame] | 4343 | ContactStatusColumns, DataUsageStatColumns { |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 4344 | } |
| 4345 | |
| 4346 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4347 | * <p> |
| 4348 | * 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] | 4349 | * contact. Each row of the data table is typically used to store a single |
| 4350 | * piece of contact |
| 4351 | * information (such as a phone number) and its |
| 4352 | * associated metadata (such as whether it is a work or home number). |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4353 | * </p> |
| 4354 | * <h3>Data kinds</h3> |
| 4355 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4356 | * Data is a generic table that can hold any kind of contact data. |
| 4357 | * The kind of data stored in a given row is specified by the row's |
| 4358 | * {@link #MIMETYPE} value, which determines the meaning of the |
| 4359 | * generic columns {@link #DATA1} through |
| 4360 | * {@link #DATA15}. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4361 | * For example, if the data kind is |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4362 | * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column |
| 4363 | * {@link #DATA1} stores the |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4364 | * phone number, but if the data kind is |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4365 | * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1} |
| 4366 | * stores the email address. |
| 4367 | * Sync adapters and applications can introduce their own data kinds. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4368 | * </p> |
| 4369 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4370 | * ContactsContract defines a small number of pre-defined data kinds, e.g. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4371 | * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a |
| 4372 | * convenience, these classes define data kind specific aliases for DATA1 etc. |
| 4373 | * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as |
| 4374 | * {@link ContactsContract.Data Data.DATA1}. |
| 4375 | * </p> |
| 4376 | * <p> |
| 4377 | * {@link #DATA1} is an indexed column and should be used for the data element that is |
| 4378 | * expected to be most frequently used in query selections. For example, in the |
| 4379 | * case of a row representing email addresses {@link #DATA1} should probably |
| 4380 | * be used for the email address itself, while {@link #DATA2} etc can be |
| 4381 | * used for auxiliary information like type of email address. |
| 4382 | * <p> |
| 4383 | * <p> |
| 4384 | * By convention, {@link #DATA15} is used for storing BLOBs (binary data). |
| 4385 | * </p> |
| 4386 | * <p> |
Tom O'Neill | d6f9cd2 | 2010-01-14 18:17:01 -0800 | [diff] [blame] | 4387 | * The sync adapter for a given account type must correctly handle every data type |
| 4388 | * used in the corresponding raw contacts. Otherwise it could result in lost or |
| 4389 | * corrupted data. |
| 4390 | * </p> |
| 4391 | * <p> |
| 4392 | * 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] | 4393 | * 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] | 4394 | * "favorite song" to a raw contact owned by a Google account, it will not |
| 4395 | * get synced to the server, because the Google sync adapter does not know |
| 4396 | * how to handle this data kind. Thus new data kinds are typically |
| 4397 | * introduced along with new account types, i.e. new sync adapters. |
| 4398 | * </p> |
| 4399 | * <h3>Batch operations</h3> |
| 4400 | * <p> |
| 4401 | * Data rows can be inserted/updated/deleted using the traditional |
| 4402 | * {@link ContentResolver#insert}, {@link ContentResolver#update} and |
| 4403 | * {@link ContentResolver#delete} methods, however the newer mechanism based |
| 4404 | * on a batch of {@link ContentProviderOperation} will prove to be a better |
| 4405 | * choice in almost all cases. All operations in a batch are executed in a |
| 4406 | * single transaction, which ensures that the phone-side and server-side |
| 4407 | * state of a raw contact are always consistent. Also, the batch-based |
| 4408 | * approach is far more efficient: not only are the database operations |
| 4409 | * faster when executed in a single transaction, but also sending a batch of |
| 4410 | * commands to the content provider saves a lot of time on context switching |
| 4411 | * between your process and the process in which the content provider runs. |
| 4412 | * </p> |
| 4413 | * <p> |
| 4414 | * The flip side of using batched operations is that a large batch may lock |
| 4415 | * up the database for a long time preventing other applications from |
| 4416 | * accessing data and potentially causing ANRs ("Application Not Responding" |
| 4417 | * dialogs.) |
| 4418 | * </p> |
| 4419 | * <p> |
| 4420 | * To avoid such lockups of the database, make sure to insert "yield points" |
| 4421 | * in the batch. A yield point indicates to the content provider that before |
| 4422 | * executing the next operation it can commit the changes that have already |
| 4423 | * been made, yield to other requests, open another transaction and continue |
| 4424 | * processing operations. A yield point will not automatically commit the |
| 4425 | * transaction, but only if there is another request waiting on the |
| 4426 | * database. Normally a sync adapter should insert a yield point at the |
| 4427 | * beginning of each raw contact operation sequence in the batch. See |
| 4428 | * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}. |
| 4429 | * </p> |
| 4430 | * <h3>Operations</h3> |
| 4431 | * <dl> |
| 4432 | * <dt><b>Insert</b></dt> |
| 4433 | * <dd> |
| 4434 | * <p> |
| 4435 | * An individual data row can be inserted using the traditional |
| 4436 | * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows |
| 4437 | * should always be inserted as a batch. |
| 4438 | * </p> |
| 4439 | * <p> |
| 4440 | * An example of a traditional insert: |
| 4441 | * <pre> |
| 4442 | * ContentValues values = new ContentValues(); |
| 4443 | * values.put(Data.RAW_CONTACT_ID, rawContactId); |
| 4444 | * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); |
| 4445 | * values.put(Phone.NUMBER, "1-800-GOOG-411"); |
| 4446 | * values.put(Phone.TYPE, Phone.TYPE_CUSTOM); |
| 4447 | * values.put(Phone.LABEL, "free directory assistance"); |
| 4448 | * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values); |
| 4449 | * </pre> |
| 4450 | * <p> |
| 4451 | * The same done using ContentProviderOperations: |
| 4452 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4453 | * ArrayList<ContentProviderOperation> ops = |
| 4454 | * new ArrayList<ContentProviderOperation>(); |
| 4455 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4456 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 4457 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 4458 | * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE) |
| 4459 | * .withValue(Phone.NUMBER, "1-800-GOOG-411") |
| 4460 | * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM) |
| 4461 | * .withValue(Phone.LABEL, "free directory assistance") |
| 4462 | * .build()); |
| 4463 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4464 | * </pre> |
| 4465 | * </p> |
| 4466 | * <dt><b>Update</b></dt> |
| 4467 | * <dd> |
| 4468 | * <p> |
| 4469 | * Just as with insert, update can be done incrementally or as a batch, |
| 4470 | * the batch mode being the preferred method: |
| 4471 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4472 | * ArrayList<ContentProviderOperation> ops = |
| 4473 | * new ArrayList<ContentProviderOperation>(); |
| 4474 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4475 | * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI) |
| 4476 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 4477 | * .withValue(Email.DATA, "somebody@android.com") |
| 4478 | * .build()); |
| 4479 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4480 | * </pre> |
| 4481 | * </p> |
| 4482 | * </dd> |
| 4483 | * <dt><b>Delete</b></dt> |
| 4484 | * <dd> |
| 4485 | * <p> |
| 4486 | * Just as with insert and update, deletion can be done either using the |
| 4487 | * {@link ContentResolver#delete} method or using a ContentProviderOperation: |
| 4488 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 4489 | * ArrayList<ContentProviderOperation> ops = |
| 4490 | * new ArrayList<ContentProviderOperation>(); |
| 4491 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4492 | * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI) |
| 4493 | * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}) |
| 4494 | * .build()); |
| 4495 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 4496 | * </pre> |
| 4497 | * </p> |
| 4498 | * </dd> |
| 4499 | * <dt><b>Query</b></dt> |
| 4500 | * <dd> |
| 4501 | * <p> |
| 4502 | * <dl> |
| 4503 | * <dt>Finding all Data of a given type for a given contact</dt> |
| 4504 | * <dd> |
| 4505 | * <pre> |
| 4506 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 4507 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 4508 | * Data.CONTACT_ID + "=?" + " AND " |
| 4509 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 4510 | * new String[] {String.valueOf(contactId)}, null); |
| 4511 | * </pre> |
| 4512 | * </p> |
| 4513 | * <p> |
| 4514 | * </dd> |
| 4515 | * <dt>Finding all Data of a given type for a given raw contact</dt> |
| 4516 | * <dd> |
| 4517 | * <pre> |
| 4518 | * Cursor c = getContentResolver().query(Data.CONTENT_URI, |
| 4519 | * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL}, |
| 4520 | * Data.RAW_CONTACT_ID + "=?" + " AND " |
| 4521 | * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", |
| 4522 | * new String[] {String.valueOf(rawContactId)}, null); |
| 4523 | * </pre> |
| 4524 | * </dd> |
| 4525 | * <dt>Finding all Data for a given raw contact</dt> |
| 4526 | * <dd> |
| 4527 | * Most sync adapters will want to read all data rows for a raw contact |
| 4528 | * along with the raw contact itself. For that you should use the |
| 4529 | * {@link RawContactsEntity}. See also {@link RawContacts}. |
| 4530 | * </dd> |
| 4531 | * </dl> |
| 4532 | * </p> |
| 4533 | * </dd> |
| 4534 | * </dl> |
| 4535 | * <h2>Columns</h2> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4536 | * <p> |
| 4537 | * Many columns are available via a {@link Data#CONTENT_URI} query. For best performance you |
| 4538 | * should explicitly specify a projection to only those columns that you need. |
| 4539 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4540 | * <table class="jd-sumtable"> |
| 4541 | * <tr> |
| 4542 | * <th colspan='4'>Data</th> |
| 4543 | * </tr> |
| 4544 | * <tr> |
| 4545 | * <td style="width: 7em;">long</td> |
| 4546 | * <td style="width: 20em;">{@link #_ID}</td> |
| 4547 | * <td style="width: 5em;">read-only</td> |
| 4548 | * <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] | 4549 | * 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] | 4550 | * always do an update instead.</td> |
| 4551 | * </tr> |
| 4552 | * <tr> |
| 4553 | * <td>String</td> |
| 4554 | * <td>{@link #MIMETYPE}</td> |
| 4555 | * <td>read/write-once</td> |
| 4556 | * <td> |
| 4557 | * <p>The MIME type of the item represented by this row. Examples of common |
| 4558 | * MIME types are: |
| 4559 | * <ul> |
| 4560 | * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li> |
| 4561 | * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li> |
| 4562 | * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li> |
| 4563 | * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li> |
| 4564 | * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li> |
| 4565 | * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li> |
| 4566 | * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li> |
| 4567 | * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li> |
| 4568 | * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li> |
| 4569 | * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li> |
| 4570 | * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li> |
| 4571 | * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li> |
| 4572 | * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 4573 | * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4574 | * </ul> |
| 4575 | * </p> |
| 4576 | * </td> |
| 4577 | * </tr> |
| 4578 | * <tr> |
| 4579 | * <td>long</td> |
| 4580 | * <td>{@link #RAW_CONTACT_ID}</td> |
| 4581 | * <td>read/write-once</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4582 | * <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] | 4583 | * </tr> |
| 4584 | * <tr> |
| 4585 | * <td>int</td> |
| 4586 | * <td>{@link #IS_PRIMARY}</td> |
| 4587 | * <td>read/write</td> |
| 4588 | * <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] | 4589 | * "1" if true, "0" if false. |
| 4590 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4591 | * </tr> |
| 4592 | * <tr> |
| 4593 | * <td>int</td> |
| 4594 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 4595 | * <td>read/write</td> |
| 4596 | * <td>Whether this is the primary entry of its kind for the aggregate |
| 4597 | * 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] | 4598 | * also be "primary". For example, the super-primary entry may be |
| 4599 | * interpreted as the default contact value of its kind (for example, |
| 4600 | * the default phone number to use for the contact).</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4601 | * </tr> |
| 4602 | * <tr> |
| 4603 | * <td>int</td> |
| 4604 | * <td>{@link #DATA_VERSION}</td> |
| 4605 | * <td>read-only</td> |
| 4606 | * <td>The version of this data record. Whenever the data row changes |
| 4607 | * the version goes up. This value is monotonically increasing.</td> |
| 4608 | * </tr> |
| 4609 | * <tr> |
| 4610 | * <td>Any type</td> |
| 4611 | * <td> |
| 4612 | * {@link #DATA1}<br> |
| 4613 | * {@link #DATA2}<br> |
| 4614 | * {@link #DATA3}<br> |
| 4615 | * {@link #DATA4}<br> |
| 4616 | * {@link #DATA5}<br> |
| 4617 | * {@link #DATA6}<br> |
| 4618 | * {@link #DATA7}<br> |
| 4619 | * {@link #DATA8}<br> |
| 4620 | * {@link #DATA9}<br> |
| 4621 | * {@link #DATA10}<br> |
| 4622 | * {@link #DATA11}<br> |
| 4623 | * {@link #DATA12}<br> |
| 4624 | * {@link #DATA13}<br> |
| 4625 | * {@link #DATA14}<br> |
| 4626 | * {@link #DATA15} |
| 4627 | * </td> |
| 4628 | * <td>read/write</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4629 | * <td> |
| 4630 | * <p> |
| 4631 | * Generic data columns. The meaning of each column is determined by the |
| 4632 | * {@link #MIMETYPE}. By convention, {@link #DATA15} is used for storing |
| 4633 | * BLOBs (binary data). |
| 4634 | * </p> |
| 4635 | * <p> |
| 4636 | * Data columns whose meaning is not explicitly defined for a given MIMETYPE |
| 4637 | * should not be used. There is no guarantee that any sync adapter will |
| 4638 | * preserve them. Sync adapters themselves should not use such columns either, |
| 4639 | * but should instead use {@link #SYNC1}-{@link #SYNC4}. |
| 4640 | * </p> |
| 4641 | * </td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4642 | * </tr> |
| 4643 | * <tr> |
| 4644 | * <td>Any type</td> |
| 4645 | * <td> |
| 4646 | * {@link #SYNC1}<br> |
| 4647 | * {@link #SYNC2}<br> |
| 4648 | * {@link #SYNC3}<br> |
| 4649 | * {@link #SYNC4} |
| 4650 | * </td> |
| 4651 | * <td>read/write</td> |
| 4652 | * <td>Generic columns for use by sync adapters. For example, a Photo row |
| 4653 | * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error) |
| 4654 | * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td> |
| 4655 | * </tr> |
| 4656 | * </table> |
| 4657 | * |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4658 | * <p> |
| 4659 | * Some columns from the most recent associated status update are also available |
| 4660 | * through an implicit join. |
| 4661 | * </p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4662 | * <table class="jd-sumtable"> |
| 4663 | * <tr> |
| 4664 | * <th colspan='4'>Join with {@link StatusUpdates}</th> |
| 4665 | * </tr> |
| 4666 | * <tr> |
| 4667 | * <td style="width: 7em;">int</td> |
| 4668 | * <td style="width: 20em;">{@link #PRESENCE}</td> |
| 4669 | * <td style="width: 5em;">read-only</td> |
| 4670 | * <td>IM presence status linked to this data row. Compare with |
| 4671 | * {@link #CONTACT_PRESENCE}, which contains the contact's presence across |
| 4672 | * all IM rows. See {@link StatusUpdates} for individual status definitions. |
| 4673 | * The provider may choose not to store this value |
| 4674 | * in persistent storage. The expectation is that presence status will be |
kmccormick | 50e27c8 | 2013-03-28 16:33:11 -0700 | [diff] [blame] | 4675 | * updated on a regular basis. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4676 | * </td> |
| 4677 | * </tr> |
| 4678 | * <tr> |
| 4679 | * <td>String</td> |
| 4680 | * <td>{@link #STATUS}</td> |
| 4681 | * <td>read-only</td> |
| 4682 | * <td>Latest status update linked with this data row.</td> |
| 4683 | * </tr> |
| 4684 | * <tr> |
| 4685 | * <td>long</td> |
| 4686 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 4687 | * <td>read-only</td> |
| 4688 | * <td>The absolute time in milliseconds when the latest status was |
| 4689 | * inserted/updated for this data row.</td> |
| 4690 | * </tr> |
| 4691 | * <tr> |
| 4692 | * <td>String</td> |
| 4693 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 4694 | * <td>read-only</td> |
| 4695 | * <td>The package containing resources for this status: label and icon.</td> |
| 4696 | * </tr> |
| 4697 | * <tr> |
| 4698 | * <td>long</td> |
| 4699 | * <td>{@link #STATUS_LABEL}</td> |
| 4700 | * <td>read-only</td> |
| 4701 | * <td>The resource ID of the label describing the source of status update linked |
| 4702 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4703 | * </tr> |
| 4704 | * <tr> |
| 4705 | * <td>long</td> |
| 4706 | * <td>{@link #STATUS_ICON}</td> |
| 4707 | * <td>read-only</td> |
| 4708 | * <td>The resource ID of the icon for the source of the status update linked |
| 4709 | * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 4710 | * </tr> |
| 4711 | * </table> |
| 4712 | * |
| 4713 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4714 | * Some columns from the associated raw contact are also available through an |
| 4715 | * implicit join. The other columns are excluded as uninteresting in this |
| 4716 | * context. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4717 | * </p> |
| 4718 | * |
| 4719 | * <table class="jd-sumtable"> |
| 4720 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4721 | * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4722 | * </tr> |
| 4723 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4724 | * <td style="width: 7em;">long</td> |
| 4725 | * <td style="width: 20em;">{@link #CONTACT_ID}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4726 | * <td style="width: 5em;">read-only</td> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4727 | * <td>The id of the row in the {@link Contacts} table that this data belongs |
| 4728 | * to.</td> |
| 4729 | * </tr> |
| 4730 | * <tr> |
| 4731 | * <td>int</td> |
| 4732 | * <td>{@link #AGGREGATION_MODE}</td> |
| 4733 | * <td>read-only</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4734 | * <td>See {@link RawContacts}.</td> |
| 4735 | * </tr> |
| 4736 | * <tr> |
| 4737 | * <td>int</td> |
| 4738 | * <td>{@link #DELETED}</td> |
| 4739 | * <td>read-only</td> |
| 4740 | * <td>See {@link RawContacts}.</td> |
| 4741 | * </tr> |
| 4742 | * </table> |
| 4743 | * |
| 4744 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4745 | * The ID column for the associated aggregated contact table |
| 4746 | * {@link ContactsContract.Contacts} is available |
| 4747 | * via the implicit join to the {@link RawContacts} table, see above. |
| 4748 | * The remaining columns from this table are also |
| 4749 | * available, through an implicit join. This |
| 4750 | * facilitates lookup by |
| 4751 | * the value of a single data element, such as the email address. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4752 | * </p> |
| 4753 | * |
| 4754 | * <table class="jd-sumtable"> |
| 4755 | * <tr> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4756 | * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4757 | * </tr> |
| 4758 | * <tr> |
| 4759 | * <td style="width: 7em;">String</td> |
| 4760 | * <td style="width: 20em;">{@link #LOOKUP_KEY}</td> |
| 4761 | * <td style="width: 5em;">read-only</td> |
| 4762 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4763 | * </tr> |
| 4764 | * <tr> |
| 4765 | * <td>String</td> |
| 4766 | * <td>{@link #DISPLAY_NAME}</td> |
| 4767 | * <td>read-only</td> |
| 4768 | * <td>See {@link ContactsContract.Contacts}</td> |
| 4769 | * </tr> |
| 4770 | * <tr> |
| 4771 | * <td>long</td> |
| 4772 | * <td>{@link #PHOTO_ID}</td> |
| 4773 | * <td>read-only</td> |
| 4774 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4775 | * </tr> |
| 4776 | * <tr> |
| 4777 | * <td>int</td> |
| 4778 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 4779 | * <td>read-only</td> |
| 4780 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4781 | * </tr> |
| 4782 | * <tr> |
| 4783 | * <td>int</td> |
| 4784 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 4785 | * <td>read-only</td> |
| 4786 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4787 | * </tr> |
| 4788 | * <tr> |
| 4789 | * <td>int</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4790 | * <td>{@link #STARRED}</td> |
| 4791 | * <td>read-only</td> |
| 4792 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4793 | * </tr> |
| 4794 | * <tr> |
| 4795 | * <td>String</td> |
| 4796 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 4797 | * <td>read-only</td> |
| 4798 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4799 | * </tr> |
| 4800 | * <tr> |
| 4801 | * <td>int</td> |
| 4802 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 4803 | * <td>read-only</td> |
| 4804 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4805 | * </tr> |
| 4806 | * <tr> |
| 4807 | * <td>int</td> |
| 4808 | * <td>{@link #CONTACT_PRESENCE}</td> |
| 4809 | * <td>read-only</td> |
| 4810 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4811 | * </tr> |
| 4812 | * <tr> |
| 4813 | * <td>String</td> |
| 4814 | * <td>{@link #CONTACT_STATUS}</td> |
| 4815 | * <td>read-only</td> |
| 4816 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4817 | * </tr> |
| 4818 | * <tr> |
| 4819 | * <td>long</td> |
| 4820 | * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td> |
| 4821 | * <td>read-only</td> |
| 4822 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4823 | * </tr> |
| 4824 | * <tr> |
| 4825 | * <td>String</td> |
| 4826 | * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td> |
| 4827 | * <td>read-only</td> |
| 4828 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4829 | * </tr> |
| 4830 | * <tr> |
| 4831 | * <td>long</td> |
| 4832 | * <td>{@link #CONTACT_STATUS_LABEL}</td> |
| 4833 | * <td>read-only</td> |
| 4834 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4835 | * </tr> |
| 4836 | * <tr> |
| 4837 | * <td>long</td> |
| 4838 | * <td>{@link #CONTACT_STATUS_ICON}</td> |
| 4839 | * <td>read-only</td> |
| 4840 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 4841 | * </tr> |
| 4842 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4843 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 4844 | public final static class Data implements DataColumnsWithJoins, ContactCounts { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4845 | /** |
| 4846 | * This utility class cannot be instantiated |
| 4847 | */ |
| 4848 | private Data() {} |
| 4849 | |
| 4850 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4851 | * The content:// style URI for this table, which requests a directory |
| 4852 | * of data rows matching the selection criteria. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4853 | */ |
| 4854 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); |
| 4855 | |
| 4856 | /** |
Ricky Wai | fa5bbaf | 2015-02-26 16:51:32 +0000 | [diff] [blame] | 4857 | * The content:// style URI for this table in managed profile, which requests a directory |
| 4858 | * of data rows matching the selection criteria. |
| 4859 | * |
| 4860 | * @hide |
| 4861 | */ |
| 4862 | static final Uri ENTERPRISE_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 4863 | "data_enterprise"); |
| 4864 | |
| 4865 | /** |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 4866 | * A boolean parameter for {@link Data#CONTENT_URI}. |
| 4867 | * This specifies whether or not the returned data items should be filtered to show |
| 4868 | * data items belonging to visible contacts only. |
| 4869 | */ |
| 4870 | public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; |
| 4871 | |
| 4872 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4873 | * The MIME type of the results from {@link #CONTENT_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4874 | */ |
| 4875 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 4876 | |
| 4877 | /** |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4878 | * <p> |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 4879 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 4880 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4881 | * entry of the given {@link ContactsContract.Data} entry. |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4882 | * </p> |
| 4883 | * <p> |
| 4884 | * Returns the Uri for the contact in the first entry returned by |
| 4885 | * {@link ContentResolver#query(Uri, String[], String, String[], String)} |
| 4886 | * for the provided {@code dataUri}. If the query returns null or empty |
| 4887 | * results, silently returns null. |
| 4888 | * </p> |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 4889 | */ |
| 4890 | public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) { |
| 4891 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 4892 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 4893 | }, null, null, null); |
| 4894 | |
| 4895 | Uri lookupUri = null; |
| 4896 | try { |
| 4897 | if (cursor != null && cursor.moveToFirst()) { |
| 4898 | final long contactId = cursor.getLong(0); |
| 4899 | final String lookupKey = cursor.getString(1); |
| 4900 | return Contacts.getLookupUri(contactId, lookupKey); |
| 4901 | } |
| 4902 | } finally { |
| 4903 | if (cursor != null) cursor.close(); |
| 4904 | } |
| 4905 | return lookupUri; |
| 4906 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 4907 | } |
| 4908 | |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 4909 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 4910 | * <p> |
Tom O'Neill | 244327e2 | 2010-01-08 11:11:15 -0800 | [diff] [blame] | 4911 | * 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] | 4912 | * an outer join of the raw_contacts table with the data table. It is a strictly |
| 4913 | * read-only table. |
| 4914 | * </p> |
| 4915 | * <p> |
| 4916 | * If a raw contact has data rows, the RawContactsEntity cursor will contain |
| 4917 | * a one row for each data row. If the raw contact has no data rows, the |
| 4918 | * cursor will still contain one row with the raw contact-level information |
| 4919 | * and nulls for data columns. |
| 4920 | * |
| 4921 | * <pre> |
| 4922 | * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId); |
| 4923 | * Cursor c = getContentResolver().query(entityUri, |
| 4924 | * new String[]{ |
| 4925 | * RawContactsEntity.SOURCE_ID, |
| 4926 | * RawContactsEntity.DATA_ID, |
| 4927 | * RawContactsEntity.MIMETYPE, |
| 4928 | * RawContactsEntity.DATA1 |
| 4929 | * }, null, null, null); |
| 4930 | * try { |
| 4931 | * while (c.moveToNext()) { |
| 4932 | * String sourceId = c.getString(0); |
| 4933 | * if (!c.isNull(1)) { |
| 4934 | * String mimeType = c.getString(2); |
| 4935 | * String data = c.getString(3); |
| 4936 | * ... |
| 4937 | * } |
| 4938 | * } |
| 4939 | * } finally { |
| 4940 | * c.close(); |
| 4941 | * } |
| 4942 | * </pre> |
| 4943 | * |
| 4944 | * <h3>Columns</h3> |
| 4945 | * RawContactsEntity has a combination of RawContact and Data columns. |
| 4946 | * |
| 4947 | * <table class="jd-sumtable"> |
| 4948 | * <tr> |
| 4949 | * <th colspan='4'>RawContacts</th> |
| 4950 | * </tr> |
| 4951 | * <tr> |
| 4952 | * <td style="width: 7em;">long</td> |
| 4953 | * <td style="width: 20em;">{@link #_ID}</td> |
| 4954 | * <td style="width: 5em;">read-only</td> |
| 4955 | * <td>Raw contact row ID. See {@link RawContacts}.</td> |
| 4956 | * </tr> |
| 4957 | * <tr> |
| 4958 | * <td>long</td> |
| 4959 | * <td>{@link #CONTACT_ID}</td> |
| 4960 | * <td>read-only</td> |
| 4961 | * <td>See {@link RawContacts}.</td> |
| 4962 | * </tr> |
| 4963 | * <tr> |
| 4964 | * <td>int</td> |
| 4965 | * <td>{@link #AGGREGATION_MODE}</td> |
| 4966 | * <td>read-only</td> |
| 4967 | * <td>See {@link RawContacts}.</td> |
| 4968 | * </tr> |
| 4969 | * <tr> |
| 4970 | * <td>int</td> |
| 4971 | * <td>{@link #DELETED}</td> |
| 4972 | * <td>read-only</td> |
| 4973 | * <td>See {@link RawContacts}.</td> |
| 4974 | * </tr> |
| 4975 | * </table> |
| 4976 | * |
| 4977 | * <table class="jd-sumtable"> |
| 4978 | * <tr> |
| 4979 | * <th colspan='4'>Data</th> |
| 4980 | * </tr> |
| 4981 | * <tr> |
| 4982 | * <td style="width: 7em;">long</td> |
| 4983 | * <td style="width: 20em;">{@link #DATA_ID}</td> |
| 4984 | * <td style="width: 5em;">read-only</td> |
| 4985 | * <td>Data row ID. It will be null if the raw contact has no data rows.</td> |
| 4986 | * </tr> |
| 4987 | * <tr> |
| 4988 | * <td>String</td> |
| 4989 | * <td>{@link #MIMETYPE}</td> |
| 4990 | * <td>read-only</td> |
| 4991 | * <td>See {@link ContactsContract.Data}.</td> |
| 4992 | * </tr> |
| 4993 | * <tr> |
| 4994 | * <td>int</td> |
| 4995 | * <td>{@link #IS_PRIMARY}</td> |
| 4996 | * <td>read-only</td> |
| 4997 | * <td>See {@link ContactsContract.Data}.</td> |
| 4998 | * </tr> |
| 4999 | * <tr> |
| 5000 | * <td>int</td> |
| 5001 | * <td>{@link #IS_SUPER_PRIMARY}</td> |
| 5002 | * <td>read-only</td> |
| 5003 | * <td>See {@link ContactsContract.Data}.</td> |
| 5004 | * </tr> |
| 5005 | * <tr> |
| 5006 | * <td>int</td> |
| 5007 | * <td>{@link #DATA_VERSION}</td> |
| 5008 | * <td>read-only</td> |
| 5009 | * <td>See {@link ContactsContract.Data}.</td> |
| 5010 | * </tr> |
| 5011 | * <tr> |
| 5012 | * <td>Any type</td> |
| 5013 | * <td> |
| 5014 | * {@link #DATA1}<br> |
| 5015 | * {@link #DATA2}<br> |
| 5016 | * {@link #DATA3}<br> |
| 5017 | * {@link #DATA4}<br> |
| 5018 | * {@link #DATA5}<br> |
| 5019 | * {@link #DATA6}<br> |
| 5020 | * {@link #DATA7}<br> |
| 5021 | * {@link #DATA8}<br> |
| 5022 | * {@link #DATA9}<br> |
| 5023 | * {@link #DATA10}<br> |
| 5024 | * {@link #DATA11}<br> |
| 5025 | * {@link #DATA12}<br> |
| 5026 | * {@link #DATA13}<br> |
| 5027 | * {@link #DATA14}<br> |
| 5028 | * {@link #DATA15} |
| 5029 | * </td> |
| 5030 | * <td>read-only</td> |
| 5031 | * <td>See {@link ContactsContract.Data}.</td> |
| 5032 | * </tr> |
| 5033 | * <tr> |
| 5034 | * <td>Any type</td> |
| 5035 | * <td> |
| 5036 | * {@link #SYNC1}<br> |
| 5037 | * {@link #SYNC2}<br> |
| 5038 | * {@link #SYNC3}<br> |
| 5039 | * {@link #SYNC4} |
| 5040 | * </td> |
| 5041 | * <td>read-only</td> |
| 5042 | * <td>See {@link ContactsContract.Data}.</td> |
| 5043 | * </tr> |
| 5044 | * </table> |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 5045 | */ |
| 5046 | public final static class RawContactsEntity |
| 5047 | implements BaseColumns, DataColumns, RawContactsColumns { |
| 5048 | /** |
| 5049 | * This utility class cannot be instantiated |
| 5050 | */ |
| 5051 | private RawContactsEntity() {} |
| 5052 | |
| 5053 | /** |
| 5054 | * The content:// style URI for this table |
| 5055 | */ |
| 5056 | public static final Uri CONTENT_URI = |
| 5057 | Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities"); |
| 5058 | |
| 5059 | /** |
Ricky Wai | 9aaaa1e | 2015-03-08 00:53:20 +0000 | [diff] [blame] | 5060 | * The content:// style URI for this table in corp profile |
| 5061 | * |
| 5062 | * @hide |
| 5063 | */ |
Philip P. Moltmann | 3311515 | 2018-04-11 13:39:36 -0700 | [diff] [blame] | 5064 | @TestApi |
Ricky Wai | 9aaaa1e | 2015-03-08 00:53:20 +0000 | [diff] [blame] | 5065 | public static final Uri CORP_CONTENT_URI = |
| 5066 | Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities_corp"); |
| 5067 | |
| 5068 | /** |
Dave Santoro | 2b4d075 | 2011-09-07 17:37:33 -0700 | [diff] [blame] | 5069 | * The content:// style URI for this table, specific to the user's profile. |
| 5070 | */ |
| 5071 | public static final Uri PROFILE_CONTENT_URI = |
| 5072 | Uri.withAppendedPath(Profile.CONTENT_URI, "raw_contact_entities"); |
| 5073 | |
| 5074 | /** |
Fred Quintana | 5bba632 | 2009-10-05 14:21:12 -0700 | [diff] [blame] | 5075 | * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities. |
| 5076 | */ |
| 5077 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity"; |
| 5078 | |
| 5079 | /** |
| 5080 | * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward |
| 5081 | * Data.CONTENT_URI contains only exportable data. |
| 5082 | * |
| 5083 | * This flag is useful (currently) only for vCard exporter in Contacts app, which |
| 5084 | * needs to exclude "un-exportable" data from available data to export, while |
| 5085 | * Contacts app itself has priviledge to access all data including "un-expotable" |
| 5086 | * ones and providers return all of them regardless of the callers' intention. |
| 5087 | * <P>Type: INTEGER</p> |
| 5088 | * |
| 5089 | * @hide Maybe available only in Eclair and not really ready for public use. |
| 5090 | * TODO: remove, or implement this feature completely. As of now (Eclair), |
| 5091 | * we only use this flag in queryEntities(), not query(). |
| 5092 | */ |
| 5093 | public static final String FOR_EXPORT_ONLY = "for_export_only"; |
| 5094 | |
| 5095 | /** |
| 5096 | * The ID of the data column. The value will be null if this raw contact has no data rows. |
| 5097 | * <P>Type: INTEGER</P> |
| 5098 | */ |
| 5099 | public static final String DATA_ID = "data_id"; |
| 5100 | } |
| 5101 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5102 | /** |
| 5103 | * @see PhoneLookup |
| 5104 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5105 | protected interface PhoneLookupColumns { |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5106 | /** |
Tony Mak | fd9ec5a | 2016-02-17 14:11:52 +0000 | [diff] [blame] | 5107 | * The ID of the data row. |
| 5108 | * <P>Type: INTEGER</P> |
| 5109 | */ |
| 5110 | public static final String DATA_ID = "data_id"; |
| 5111 | /** |
| 5112 | * A reference to the {@link ContactsContract.Contacts#_ID} that this |
| 5113 | * data belongs to. |
| 5114 | * <P>Type: INTEGER</P> |
| 5115 | */ |
| 5116 | public static final String CONTACT_ID = "contact_id"; |
| 5117 | /** |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5118 | * The phone number as the user entered it. |
| 5119 | * <P>Type: TEXT</P> |
| 5120 | */ |
| 5121 | public static final String NUMBER = "number"; |
| 5122 | |
| 5123 | /** |
| 5124 | * The type of phone number, for example Home or Work. |
| 5125 | * <P>Type: INTEGER</P> |
| 5126 | */ |
| 5127 | public static final String TYPE = "type"; |
| 5128 | |
| 5129 | /** |
| 5130 | * The user defined label for the phone number. |
| 5131 | * <P>Type: TEXT</P> |
| 5132 | */ |
| 5133 | public static final String LABEL = "label"; |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 5134 | |
| 5135 | /** |
| 5136 | * The phone number's E164 representation. |
| 5137 | * <P>Type: TEXT</P> |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 5138 | */ |
| 5139 | public static final String NORMALIZED_NUMBER = "normalized_number"; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5140 | } |
| 5141 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5142 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5143 | * 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] | 5144 | * 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] | 5145 | * want to find to {@link #CONTENT_FILTER_URI}. This query is highly |
| 5146 | * optimized. |
| 5147 | * <pre> |
| 5148 | * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber)); |
| 5149 | * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,... |
| 5150 | * </pre> |
| 5151 | * |
| 5152 | * <h3>Columns</h3> |
| 5153 | * |
| 5154 | * <table class="jd-sumtable"> |
| 5155 | * <tr> |
| 5156 | * <th colspan='4'>PhoneLookup</th> |
| 5157 | * </tr> |
| 5158 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5159 | * <td>String</td> |
| 5160 | * <td>{@link #NUMBER}</td> |
| 5161 | * <td>read-only</td> |
| 5162 | * <td>Phone number.</td> |
| 5163 | * </tr> |
| 5164 | * <tr> |
| 5165 | * <td>String</td> |
| 5166 | * <td>{@link #TYPE}</td> |
| 5167 | * <td>read-only</td> |
| 5168 | * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td> |
| 5169 | * </tr> |
| 5170 | * <tr> |
| 5171 | * <td>String</td> |
| 5172 | * <td>{@link #LABEL}</td> |
| 5173 | * <td>read-only</td> |
| 5174 | * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td> |
| 5175 | * </tr> |
| 5176 | * </table> |
| 5177 | * <p> |
| 5178 | * Columns from the Contacts table are also available through a join. |
| 5179 | * </p> |
| 5180 | * <table class="jd-sumtable"> |
| 5181 | * <tr> |
| 5182 | * <th colspan='4'>Join with {@link Contacts}</th> |
| 5183 | * </tr> |
| 5184 | * <tr> |
Dmitri Plotnikov | 817b3f9 | 2011-01-09 17:07:13 -0800 | [diff] [blame] | 5185 | * <td>long</td> |
| 5186 | * <td>{@link #_ID}</td> |
| 5187 | * <td>read-only</td> |
| 5188 | * <td>Contact ID.</td> |
| 5189 | * </tr> |
| 5190 | * <tr> |
Tony Mak | fd9ec5a | 2016-02-17 14:11:52 +0000 | [diff] [blame] | 5191 | * <td>long</td> |
| 5192 | * <td>{@link #CONTACT_ID}</td> |
| 5193 | * <td>read-only</td> |
| 5194 | * <td>Contact ID.</td> |
| 5195 | * </tr> |
| 5196 | * <tr> |
| 5197 | * <td>long</td> |
| 5198 | * <td>{@link #DATA_ID}</td> |
| 5199 | * <td>read-only</td> |
| 5200 | * <td>Data ID.</td> |
| 5201 | * </tr> |
| 5202 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5203 | * <td>String</td> |
| 5204 | * <td>{@link #LOOKUP_KEY}</td> |
| 5205 | * <td>read-only</td> |
| 5206 | * <td>See {@link ContactsContract.Contacts}</td> |
| 5207 | * </tr> |
| 5208 | * <tr> |
| 5209 | * <td>String</td> |
| 5210 | * <td>{@link #DISPLAY_NAME}</td> |
| 5211 | * <td>read-only</td> |
| 5212 | * <td>See {@link ContactsContract.Contacts}</td> |
| 5213 | * </tr> |
| 5214 | * <tr> |
| 5215 | * <td>long</td> |
| 5216 | * <td>{@link #PHOTO_ID}</td> |
| 5217 | * <td>read-only</td> |
| 5218 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5219 | * </tr> |
| 5220 | * <tr> |
| 5221 | * <td>int</td> |
| 5222 | * <td>{@link #IN_VISIBLE_GROUP}</td> |
| 5223 | * <td>read-only</td> |
| 5224 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5225 | * </tr> |
| 5226 | * <tr> |
| 5227 | * <td>int</td> |
| 5228 | * <td>{@link #HAS_PHONE_NUMBER}</td> |
| 5229 | * <td>read-only</td> |
| 5230 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5231 | * </tr> |
| 5232 | * <tr> |
| 5233 | * <td>int</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5234 | * <td>{@link #STARRED}</td> |
| 5235 | * <td>read-only</td> |
| 5236 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5237 | * </tr> |
| 5238 | * <tr> |
| 5239 | * <td>String</td> |
| 5240 | * <td>{@link #CUSTOM_RINGTONE}</td> |
| 5241 | * <td>read-only</td> |
| 5242 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5243 | * </tr> |
| 5244 | * <tr> |
| 5245 | * <td>int</td> |
| 5246 | * <td>{@link #SEND_TO_VOICEMAIL}</td> |
| 5247 | * <td>read-only</td> |
| 5248 | * <td>See {@link ContactsContract.Contacts}.</td> |
| 5249 | * </tr> |
| 5250 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5251 | */ |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 5252 | public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, |
Suprabh Shukla | 2c3fb3f | 2016-09-06 15:30:53 -0700 | [diff] [blame] | 5253 | ContactsColumns, ContactOptionsColumns, ContactNameColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5254 | /** |
| 5255 | * This utility class cannot be instantiated |
| 5256 | */ |
| 5257 | private PhoneLookup() {} |
| 5258 | |
| 5259 | /** |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 5260 | * The content:// style URI for this table. |
| 5261 | * |
| 5262 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer |
| 5263 | * sorts results based on contacts frequency. For more information, see the |
| 5264 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 5265 | * page. |
| 5266 | * |
| 5267 | * Append the phone number you want to lookup |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5268 | * to this URI and query it to perform a lookup. For example: |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5269 | * <pre> |
Scott Kennedy | 7ed189e | 2013-01-11 22:31:43 -0800 | [diff] [blame] | 5270 | * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, |
| 5271 | * Uri.encode(phoneNumber)); |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5272 | * </pre> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5273 | */ |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5274 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 5275 | "phone_lookup"); |
Dmitri Plotnikov | 0b0b8a8 | 2010-03-04 18:20:08 -0800 | [diff] [blame] | 5276 | |
| 5277 | /** |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 5278 | * <p>URI used for the "enterprise caller-id".</p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5279 | * |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 5280 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer |
| 5281 | * sorts results based on contacts frequency. For more information, see the |
| 5282 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 5283 | * page. |
| 5284 | * |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 5285 | * <p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5286 | * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same |
| 5287 | * columns. If the device has no corp profile that is linked to the current profile, it |
| 5288 | * behaves in the exact same way as {@link #CONTENT_FILTER_URI}. If there is a corp profile |
| 5289 | * linked to the current profile, it first queries against the personal contact database, |
| 5290 | * and if no matching contacts are found there, then queries against the |
| 5291 | * corp contacts database. |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 5292 | * </p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5293 | * <p> |
| 5294 | * If a result is from the corp profile, it makes the following changes to the data: |
| 5295 | * <ul> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5296 | * <li> |
| 5297 | * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special |
| 5298 | * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to |
| 5299 | * load pictures from them. |
Makoto Onuki | 80b3ab6 | 2014-07-10 11:24:21 -0700 | [diff] [blame] | 5300 | * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not use them. |
| 5301 | * </li> |
| 5302 | * <li> |
| 5303 | * 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] | 5304 | * is from the corp profile, use |
| 5305 | * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}. |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5306 | * </li> |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 5307 | * <li> |
| 5308 | * Corp contacts will get artificial {@link #LOOKUP_KEY}s too. |
| 5309 | * </li> |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 5310 | * <li> |
| 5311 | * Returned work contact IDs and lookup keys are not accepted in places that not |
| 5312 | * explicitly say to accept them. |
| 5313 | * </li> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5314 | * </ul> |
Makoto Onuki | 95a9cfb | 2014-07-08 17:11:54 -0700 | [diff] [blame] | 5315 | * <p> |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 5316 | * A contact lookup URL built by |
| 5317 | * {@link ContactsContract.Contacts#getLookupUri(long, String)} |
| 5318 | * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to |
| 5319 | * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the |
| 5320 | * corp profile. |
| 5321 | * </p> |
Makoto Onuki | 31cd6f7 | 2014-07-08 15:20:39 -0700 | [diff] [blame] | 5322 | * |
| 5323 | * <pre> |
| 5324 | * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, |
| 5325 | * Uri.encode(phoneNumber)); |
| 5326 | * </pre> |
| 5327 | */ |
| 5328 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 5329 | "phone_lookup_enterprise"); |
| 5330 | |
| 5331 | /** |
Dmitri Plotnikov | 0b0b8a8 | 2010-03-04 18:20:08 -0800 | [diff] [blame] | 5332 | * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows. |
| 5333 | * |
| 5334 | * @hide |
| 5335 | */ |
| 5336 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup"; |
Flavio Lerda | 52c01c2 | 2011-11-02 22:16:23 +0000 | [diff] [blame] | 5337 | |
Yorke Lee | 217d8a7 | 2013-11-27 10:14:04 -0800 | [diff] [blame] | 5338 | /** |
| 5339 | * If this boolean parameter is set to true, then the appended query is treated as a |
| 5340 | * SIP address and the lookup will be performed against SIP addresses in the user's |
| 5341 | * contacts. |
| 5342 | */ |
Flavio Lerda | 52c01c2 | 2011-11-02 22:16:23 +0000 | [diff] [blame] | 5343 | public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5344 | } |
| 5345 | |
| 5346 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5347 | * Additional data mixed in with {@link StatusColumns} to link |
| 5348 | * back to specific {@link ContactsContract.Data#_ID} entries. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5349 | * |
| 5350 | * @see StatusUpdates |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5351 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5352 | protected interface PresenceColumns { |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 5353 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5354 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5355 | * Reference to the {@link Data#_ID} entry that owns this presence. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5356 | * <P>Type: INTEGER</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5357 | */ |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 5358 | public static final String DATA_ID = "presence_data_id"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5359 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5360 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5361 | * See {@link CommonDataKinds.Im} for a list of defined protocol constants. |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 5362 | * <p>Type: NUMBER</p> |
| 5363 | */ |
| 5364 | public static final String PROTOCOL = "protocol"; |
| 5365 | |
| 5366 | /** |
| 5367 | * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 5368 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 5369 | * omitted if {@link #PROTOCOL} value is not |
| 5370 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. |
| 5371 | * |
| 5372 | * <p>Type: NUMBER</p> |
| 5373 | */ |
| 5374 | public static final String CUSTOM_PROTOCOL = "custom_protocol"; |
| 5375 | |
| 5376 | /** |
| 5377 | * The IM handle the presence item is for. The handle is scoped to |
| 5378 | * {@link #PROTOCOL}. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5379 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5380 | */ |
| 5381 | public static final String IM_HANDLE = "im_handle"; |
| 5382 | |
| 5383 | /** |
| 5384 | * 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] | 5385 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5386 | */ |
| 5387 | public static final String IM_ACCOUNT = "im_account"; |
| 5388 | } |
| 5389 | |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5390 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5391 | * <p> |
| 5392 | * A status update is linked to a {@link ContactsContract.Data} row and captures |
| 5393 | * the user's latest status update via the corresponding source, e.g. |
| 5394 | * "Having lunch" via "Google Talk". |
| 5395 | * </p> |
| 5396 | * <p> |
| 5397 | * There are two ways a status update can be inserted: by explicitly linking |
| 5398 | * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row |
| 5399 | * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 5400 | * {@link #IM_HANDLE}. There is no difference between insert and update, you can use |
| 5401 | * either. |
| 5402 | * </p> |
| 5403 | * <p> |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 5404 | * Inserting or updating a status update for the user's profile requires either using |
| 5405 | * the {@link #DATA_ID} to identify the data row to attach the update to, or |
| 5406 | * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the |
| 5407 | * profile. |
| 5408 | * </p> |
| 5409 | * <p> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5410 | * You cannot use {@link ContentResolver#update} to change a status, but |
| 5411 | * {@link ContentResolver#insert} will replace the latests status if it already |
| 5412 | * exists. |
| 5413 | * </p> |
| 5414 | * <p> |
| 5415 | * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses |
| 5416 | * for multiple contacts at once. |
| 5417 | * </p> |
| 5418 | * |
| 5419 | * <h3>Columns</h3> |
| 5420 | * <table class="jd-sumtable"> |
| 5421 | * <tr> |
| 5422 | * <th colspan='4'>StatusUpdates</th> |
| 5423 | * </tr> |
| 5424 | * <tr> |
| 5425 | * <td>long</td> |
| 5426 | * <td>{@link #DATA_ID}</td> |
| 5427 | * <td>read/write</td> |
| 5428 | * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this |
| 5429 | * field is <i>not</i> specified, the provider will attempt to find a data row |
| 5430 | * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and |
| 5431 | * {@link #IM_HANDLE} columns. |
| 5432 | * </td> |
| 5433 | * </tr> |
| 5434 | * <tr> |
| 5435 | * <td>long</td> |
| 5436 | * <td>{@link #PROTOCOL}</td> |
| 5437 | * <td>read/write</td> |
| 5438 | * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td> |
| 5439 | * </tr> |
| 5440 | * <tr> |
| 5441 | * <td>String</td> |
| 5442 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 5443 | * <td>read/write</td> |
| 5444 | * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 5445 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 5446 | * omitted if {@link #PROTOCOL} value is not |
| 5447 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td> |
| 5448 | * </tr> |
| 5449 | * <tr> |
| 5450 | * <td>String</td> |
| 5451 | * <td>{@link #IM_HANDLE}</td> |
| 5452 | * <td>read/write</td> |
| 5453 | * <td> The IM handle the presence item is for. The handle is scoped to |
| 5454 | * {@link #PROTOCOL}.</td> |
| 5455 | * </tr> |
| 5456 | * <tr> |
| 5457 | * <td>String</td> |
| 5458 | * <td>{@link #IM_ACCOUNT}</td> |
| 5459 | * <td>read/write</td> |
| 5460 | * <td>The IM account for the local user that the presence data came from.</td> |
| 5461 | * </tr> |
| 5462 | * <tr> |
| 5463 | * <td>int</td> |
| 5464 | * <td>{@link #PRESENCE}</td> |
| 5465 | * <td>read/write</td> |
| 5466 | * <td>Contact IM presence status. The allowed values are: |
| 5467 | * <p> |
| 5468 | * <ul> |
| 5469 | * <li>{@link #OFFLINE}</li> |
| 5470 | * <li>{@link #INVISIBLE}</li> |
| 5471 | * <li>{@link #AWAY}</li> |
| 5472 | * <li>{@link #IDLE}</li> |
| 5473 | * <li>{@link #DO_NOT_DISTURB}</li> |
| 5474 | * <li>{@link #AVAILABLE}</li> |
| 5475 | * </ul> |
| 5476 | * </p> |
| 5477 | * <p> |
| 5478 | * Since presence status is inherently volatile, the content provider |
| 5479 | * may choose not to store this field in long-term storage. |
| 5480 | * </p> |
| 5481 | * </td> |
| 5482 | * </tr> |
| 5483 | * <tr> |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 5484 | * <td>int</td> |
| 5485 | * <td>{@link #CHAT_CAPABILITY}</td> |
| 5486 | * <td>read/write</td> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 5487 | * <td>Contact IM chat compatibility value. The allowed values combinations of the following |
| 5488 | * 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] | 5489 | * <p> |
| 5490 | * <ul> |
Daniel Lehmann | b332747 | 2010-08-13 15:16:11 -0700 | [diff] [blame] | 5491 | * <li>{@link #CAPABILITY_HAS_VIDEO}</li> |
Vasu Nori | 5b31498ba1 | 2010-07-12 15:13:37 -0700 | [diff] [blame] | 5492 | * <li>{@link #CAPABILITY_HAS_VOICE}</li> |
| 5493 | * <li>{@link #CAPABILITY_HAS_CAMERA}</li> |
| 5494 | * </ul> |
| 5495 | * </p> |
| 5496 | * <p> |
| 5497 | * Since chat compatibility is inherently volatile as the contact's availability moves from |
| 5498 | * one device to another, the content provider may choose not to store this field in long-term |
| 5499 | * storage. |
| 5500 | * </p> |
| 5501 | * </td> |
| 5502 | * </tr> |
| 5503 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5504 | * <td>String</td> |
| 5505 | * <td>{@link #STATUS}</td> |
| 5506 | * <td>read/write</td> |
| 5507 | * <td>Contact's latest status update, e.g. "having toast for breakfast"</td> |
| 5508 | * </tr> |
| 5509 | * <tr> |
| 5510 | * <td>long</td> |
| 5511 | * <td>{@link #STATUS_TIMESTAMP}</td> |
| 5512 | * <td>read/write</td> |
| 5513 | * <td>The absolute time in milliseconds when the status was |
| 5514 | * entered by the user. If this value is not provided, the provider will follow |
| 5515 | * this logic: if there was no prior status update, the value will be left as null. |
| 5516 | * If there was a prior status update, the provider will default this field |
| 5517 | * to the current time.</td> |
| 5518 | * </tr> |
| 5519 | * <tr> |
| 5520 | * <td>String</td> |
| 5521 | * <td>{@link #STATUS_RES_PACKAGE}</td> |
| 5522 | * <td>read/write</td> |
| 5523 | * <td> The package containing resources for this status: label and icon.</td> |
| 5524 | * </tr> |
| 5525 | * <tr> |
| 5526 | * <td>long</td> |
| 5527 | * <td>{@link #STATUS_LABEL}</td> |
| 5528 | * <td>read/write</td> |
| 5529 | * <td>The resource ID of the label describing the source of contact status, |
| 5530 | * e.g. "Google Talk". This resource is scoped by the |
| 5531 | * {@link #STATUS_RES_PACKAGE}.</td> |
| 5532 | * </tr> |
| 5533 | * <tr> |
| 5534 | * <td>long</td> |
| 5535 | * <td>{@link #STATUS_ICON}</td> |
| 5536 | * <td>read/write</td> |
| 5537 | * <td>The resource ID of the icon for the source of contact status. This |
| 5538 | * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td> |
| 5539 | * </tr> |
| 5540 | * </table> |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5541 | */ |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5542 | public static class StatusUpdates implements StatusColumns, PresenceColumns { |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 5543 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5544 | /** |
| 5545 | * This utility class cannot be instantiated |
| 5546 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5547 | private StatusUpdates() {} |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5548 | |
| 5549 | /** |
| 5550 | * The content:// style URI for this table |
| 5551 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5552 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates"); |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5553 | |
| 5554 | /** |
Dave Santoro | 063084e | 2011-08-23 15:42:49 -0700 | [diff] [blame] | 5555 | * The content:// style URI for this table, specific to the user's profile. |
| 5556 | */ |
| 5557 | public static final Uri PROFILE_CONTENT_URI = |
| 5558 | Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates"); |
| 5559 | |
| 5560 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5561 | * Gets the resource ID for the proper presence icon. |
| 5562 | * |
| 5563 | * @param status the status to get the icon for |
| 5564 | * @return the resource ID for the proper presence icon |
| 5565 | */ |
| 5566 | public static final int getPresenceIconResourceId(int status) { |
| 5567 | switch (status) { |
| 5568 | case AVAILABLE: |
| 5569 | return android.R.drawable.presence_online; |
| 5570 | case IDLE: |
| 5571 | case AWAY: |
| 5572 | return android.R.drawable.presence_away; |
| 5573 | case DO_NOT_DISTURB: |
| 5574 | return android.R.drawable.presence_busy; |
| 5575 | case INVISIBLE: |
| 5576 | return android.R.drawable.presence_invisible; |
| 5577 | case OFFLINE: |
| 5578 | default: |
| 5579 | return android.R.drawable.presence_offline; |
| 5580 | } |
| 5581 | } |
| 5582 | |
| 5583 | /** |
Evan Millar | c043752 | 2009-06-23 17:31:05 -0700 | [diff] [blame] | 5584 | * Returns the precedence of the status code the higher number being the higher precedence. |
| 5585 | * |
| 5586 | * @param status The status code. |
| 5587 | * @return An integer representing the precedence, 0 being the lowest. |
| 5588 | */ |
| 5589 | public static final int getPresencePrecedence(int status) { |
| 5590 | // Keep this function here incase we want to enforce a different precedence than the |
| 5591 | // natural order of the status constants. |
| 5592 | return status; |
| 5593 | } |
| 5594 | |
| 5595 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5596 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5597 | * status update details. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5598 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5599 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5600 | |
| 5601 | /** |
| 5602 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5603 | * status update detail. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 5604 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5605 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update"; |
| 5606 | } |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 5607 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5608 | /** |
| 5609 | * @deprecated This old name was never meant to be made public. Do not use. |
| 5610 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 5611 | @Deprecated |
| 5612 | public static final class Presence extends StatusUpdates { |
| 5613 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5614 | } |
| 5615 | |
| 5616 | /** |
Yorke Lee | 8d37009 | 2014-06-26 10:32:17 -0700 | [diff] [blame] | 5617 | * Additional column returned by |
| 5618 | * {@link ContactsContract.Contacts#CONTENT_FILTER_URI Contacts.CONTENT_FILTER_URI} explaining |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5619 | * why the filter matched the contact. This column will contain extracts from the contact's |
| 5620 | * constituent {@link Data Data} items, formatted in a way that indicates the section of the |
| 5621 | * snippet that matched the filter. |
| 5622 | * |
| 5623 | * <p> |
| 5624 | * The following example searches for all contacts that match the query "presi" and requests |
| 5625 | * the snippet column as well. |
| 5626 | * <pre> |
| 5627 | * Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon(); |
| 5628 | * builder.appendPath("presi"); |
| 5629 | * // Defer snippeting to the client side if possible, for performance reasons. |
| 5630 | * builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1"); |
| 5631 | * |
| 5632 | * Cursor cursor = getContentResolver().query(builder.build()); |
| 5633 | * |
| 5634 | * Bundle extras = cursor.getExtras(); |
| 5635 | * if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) { |
| 5636 | * // Do our own snippet formatting. |
| 5637 | * // For a contact with the email address (president@organization.com), the snippet |
| 5638 | * // column will contain the string "president@organization.com". |
| 5639 | * } else { |
| 5640 | * // The snippet has already been pre-formatted, we can display it as is. |
| 5641 | * // For a contact with the email address (president@organization.com), the snippet |
| 5642 | * // column will contain the string "[presi]dent@organization.com". |
| 5643 | * } |
| 5644 | * </pre> |
| 5645 | * </p> |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5646 | */ |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5647 | public static class SearchSnippets { |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5648 | |
| 5649 | /** |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5650 | * The search snippet constructed by SQLite snippeting functionality. |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5651 | * <p> |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5652 | * The snippet may contain (parts of) several data elements belonging to the contact, |
| 5653 | * with the matching parts optionally surrounded by special characters that indicate the |
| 5654 | * start and end of matching text. |
| 5655 | * |
| 5656 | * For example, if a contact has an address "123 Main Street", using a filter "mai" would |
| 5657 | * return the formatted snippet "123 [Mai]n street". |
| 5658 | * |
| 5659 | * @see <a href="http://www.sqlite.org/fts3.html#snippet"> |
| 5660 | * http://www.sqlite.org/fts3.html#snippet</a> |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5661 | */ |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5662 | public static final String SNIPPET = "snippet"; |
| 5663 | |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5664 | /** |
| 5665 | * Comma-separated parameters for the generation of the snippet: |
| 5666 | * <ul> |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5667 | * <li>The "start match" text. Default is '['</li> |
| 5668 | * <li>The "end match" text. Default is ']'</li> |
| 5669 | * <li>The "ellipsis" text. Default is "..."</li> |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5670 | * <li>Maximum number of tokens to include in the snippet. Can be either |
| 5671 | * a positive or a negative number: A positive number indicates how many |
| 5672 | * tokens can be returned in total. A negative number indicates how many |
| 5673 | * tokens can be returned per occurrence of the search terms.</li> |
| 5674 | * </ul> |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5675 | * |
| 5676 | * @hide |
Dmitri Plotnikov | 123653b | 2011-02-08 16:31:20 -0800 | [diff] [blame] | 5677 | */ |
| 5678 | public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args"; |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5679 | |
| 5680 | /** |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5681 | * The key to ask the provider to defer the formatting of the snippet to the client if |
| 5682 | * possible, for performance reasons. |
| 5683 | * 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] | 5684 | * When a cursor is returned to the client, it should check for an extra with the name |
| 5685 | * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client |
Yorke Lee | eaf09493 | 2014-07-01 10:28:56 -0700 | [diff] [blame] | 5686 | * should do its own formatting of the snippet. If it doesn't exist, the snippet column |
| 5687 | * in the cursor should already contain a formatted snippet. |
Isaac Katzenelson | 9fe83f0 | 2011-09-02 17:58:28 -0700 | [diff] [blame] | 5688 | */ |
| 5689 | public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting"; |
Dmitri Plotnikov | 3ba8a3b | 2010-02-24 18:23:43 -0800 | [diff] [blame] | 5690 | } |
| 5691 | |
| 5692 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5693 | * Container for definitions of common data types stored in the {@link ContactsContract.Data} |
| 5694 | * table. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5695 | */ |
| 5696 | public static final class CommonDataKinds { |
| 5697 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5698 | * This utility class cannot be instantiated |
| 5699 | */ |
| 5700 | private CommonDataKinds() {} |
| 5701 | |
| 5702 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5703 | * The {@link Data#RES_PACKAGE} value for common data that should be |
| 5704 | * shown using a default style. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5705 | * |
| 5706 | * @hide RES_PACKAGE is hidden |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5707 | */ |
| 5708 | public static final String PACKAGE_COMMON = "common"; |
| 5709 | |
| 5710 | /** |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5711 | * The base types that all "Typed" data kinds support. |
| 5712 | */ |
| 5713 | public interface BaseTypes { |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5714 | /** |
| 5715 | * A custom type. The custom label should be supplied by user. |
| 5716 | */ |
| 5717 | public static int TYPE_CUSTOM = 0; |
| 5718 | } |
| 5719 | |
| 5720 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5721 | * Columns common across the specific types. |
| 5722 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 5723 | protected interface CommonColumns extends BaseTypes { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5724 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5725 | * The data for the contact method. |
| 5726 | * <P>Type: TEXT</P> |
| 5727 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5728 | public static final String DATA = DataColumns.DATA1; |
| 5729 | |
| 5730 | /** |
| 5731 | * The type of data, for example Home or Work. |
| 5732 | * <P>Type: INTEGER</P> |
| 5733 | */ |
| 5734 | public static final String TYPE = DataColumns.DATA2; |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 5735 | |
| 5736 | /** |
| 5737 | * The user defined label for the the contact method. |
| 5738 | * <P>Type: TEXT</P> |
| 5739 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5740 | public static final String LABEL = DataColumns.DATA3; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5741 | } |
| 5742 | |
| 5743 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5744 | * A data kind representing the contact's proper name. You can use all |
| 5745 | * columns defined for {@link ContactsContract.Data} as well as the following aliases. |
| 5746 | * |
| 5747 | * <h2>Column aliases</h2> |
| 5748 | * <table class="jd-sumtable"> |
| 5749 | * <tr> |
| 5750 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 5751 | * </tr> |
| 5752 | * <tr> |
| 5753 | * <td>String</td> |
| 5754 | * <td>{@link #DISPLAY_NAME}</td> |
| 5755 | * <td>{@link #DATA1}</td> |
| 5756 | * <td></td> |
| 5757 | * </tr> |
| 5758 | * <tr> |
| 5759 | * <td>String</td> |
| 5760 | * <td>{@link #GIVEN_NAME}</td> |
| 5761 | * <td>{@link #DATA2}</td> |
| 5762 | * <td></td> |
| 5763 | * </tr> |
| 5764 | * <tr> |
| 5765 | * <td>String</td> |
| 5766 | * <td>{@link #FAMILY_NAME}</td> |
| 5767 | * <td>{@link #DATA3}</td> |
| 5768 | * <td></td> |
| 5769 | * </tr> |
| 5770 | * <tr> |
| 5771 | * <td>String</td> |
| 5772 | * <td>{@link #PREFIX}</td> |
| 5773 | * <td>{@link #DATA4}</td> |
| 5774 | * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td> |
| 5775 | * </tr> |
| 5776 | * <tr> |
| 5777 | * <td>String</td> |
| 5778 | * <td>{@link #MIDDLE_NAME}</td> |
| 5779 | * <td>{@link #DATA5}</td> |
| 5780 | * <td></td> |
| 5781 | * </tr> |
| 5782 | * <tr> |
| 5783 | * <td>String</td> |
| 5784 | * <td>{@link #SUFFIX}</td> |
| 5785 | * <td>{@link #DATA6}</td> |
| 5786 | * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td> |
| 5787 | * </tr> |
| 5788 | * <tr> |
| 5789 | * <td>String</td> |
| 5790 | * <td>{@link #PHONETIC_GIVEN_NAME}</td> |
| 5791 | * <td>{@link #DATA7}</td> |
| 5792 | * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td> |
| 5793 | * </tr> |
| 5794 | * <tr> |
| 5795 | * <td>String</td> |
| 5796 | * <td>{@link #PHONETIC_MIDDLE_NAME}</td> |
| 5797 | * <td>{@link #DATA8}</td> |
| 5798 | * <td></td> |
| 5799 | * </tr> |
| 5800 | * <tr> |
| 5801 | * <td>String</td> |
| 5802 | * <td>{@link #PHONETIC_FAMILY_NAME}</td> |
| 5803 | * <td>{@link #DATA9}</td> |
| 5804 | * <td></td> |
| 5805 | * </tr> |
| 5806 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5807 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 5808 | public static final class StructuredName implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5809 | /** |
| 5810 | * This utility class cannot be instantiated |
| 5811 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5812 | private StructuredName() {} |
| 5813 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5814 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5815 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; |
| 5816 | |
| 5817 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5818 | * The name that should be used to display the contact. |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 5819 | * <i>Unstructured component of the name should be consistent with |
| 5820 | * its structured representation.</i> |
| 5821 | * <p> |
| 5822 | * Type: TEXT |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5823 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 5824 | public static final String DISPLAY_NAME = DATA1; |
| 5825 | |
| 5826 | /** |
| 5827 | * The given name for the contact. |
| 5828 | * <P>Type: TEXT</P> |
| 5829 | */ |
| 5830 | public static final String GIVEN_NAME = DATA2; |
| 5831 | |
| 5832 | /** |
| 5833 | * The family name for the contact. |
| 5834 | * <P>Type: TEXT</P> |
| 5835 | */ |
| 5836 | public static final String FAMILY_NAME = DATA3; |
| 5837 | |
| 5838 | /** |
| 5839 | * The contact's honorific prefix, e.g. "Sir" |
| 5840 | * <P>Type: TEXT</P> |
| 5841 | */ |
| 5842 | public static final String PREFIX = DATA4; |
| 5843 | |
| 5844 | /** |
| 5845 | * The contact's middle name |
| 5846 | * <P>Type: TEXT</P> |
| 5847 | */ |
| 5848 | public static final String MIDDLE_NAME = DATA5; |
| 5849 | |
| 5850 | /** |
| 5851 | * The contact's honorific suffix, e.g. "Jr" |
| 5852 | */ |
| 5853 | public static final String SUFFIX = DATA6; |
| 5854 | |
| 5855 | /** |
| 5856 | * The phonetic version of the given name for the contact. |
| 5857 | * <P>Type: TEXT</P> |
| 5858 | */ |
| 5859 | public static final String PHONETIC_GIVEN_NAME = DATA7; |
| 5860 | |
| 5861 | /** |
| 5862 | * The phonetic version of the additional name for the contact. |
| 5863 | * <P>Type: TEXT</P> |
| 5864 | */ |
| 5865 | public static final String PHONETIC_MIDDLE_NAME = DATA8; |
| 5866 | |
| 5867 | /** |
| 5868 | * The phonetic version of the family name for the contact. |
| 5869 | * <P>Type: TEXT</P> |
| 5870 | */ |
| 5871 | public static final String PHONETIC_FAMILY_NAME = DATA9; |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5872 | |
| 5873 | /** |
| 5874 | * The style used for combining given/middle/family name into a full name. |
| 5875 | * See {@link ContactsContract.FullNameStyle}. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5876 | */ |
| 5877 | public static final String FULL_NAME_STYLE = DATA10; |
| 5878 | |
| 5879 | /** |
| 5880 | * The alphabet used for capturing the phonetic name. |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 5881 | * See ContactsContract.PhoneticNameStyle. |
Dmitri Plotnikov | 07ab85b | 2009-12-15 11:56:23 -0800 | [diff] [blame] | 5882 | */ |
| 5883 | public static final String PHONETIC_NAME_STYLE = DATA11; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5884 | } |
| 5885 | |
| 5886 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5887 | * <p>A data kind representing the contact's nickname. For example, for |
| 5888 | * Bob Parr ("Mr. Incredible"): |
| 5889 | * <pre> |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 5890 | * ArrayList<ContentProviderOperation> ops = |
| 5891 | * new ArrayList<ContentProviderOperation>(); |
| 5892 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5893 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 5894 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 5895 | * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) |
| 5896 | * .withValue(StructuredName.DISPLAY_NAME, "Bob Parr") |
| 5897 | * .build()); |
| 5898 | * |
| 5899 | * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) |
| 5900 | * .withValue(Data.RAW_CONTACT_ID, rawContactId) |
| 5901 | * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE) |
| 5902 | * .withValue(Nickname.NAME, "Mr. Incredible") |
| 5903 | * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM) |
| 5904 | * .withValue(Nickname.LABEL, "Superhero") |
| 5905 | * .build()); |
| 5906 | * |
| 5907 | * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); |
| 5908 | * </pre> |
| 5909 | * </p> |
| 5910 | * <p> |
| 5911 | * You can use all columns defined for {@link ContactsContract.Data} as well as the |
| 5912 | * following aliases. |
| 5913 | * </p> |
| 5914 | * |
| 5915 | * <h2>Column aliases</h2> |
| 5916 | * <table class="jd-sumtable"> |
| 5917 | * <tr> |
| 5918 | * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th> |
| 5919 | * </tr> |
| 5920 | * <tr> |
| 5921 | * <td>String</td> |
| 5922 | * <td>{@link #NAME}</td> |
| 5923 | * <td>{@link #DATA1}</td> |
| 5924 | * <td></td> |
| 5925 | * </tr> |
| 5926 | * <tr> |
| 5927 | * <td>int</td> |
| 5928 | * <td>{@link #TYPE}</td> |
| 5929 | * <td>{@link #DATA2}</td> |
| 5930 | * <td> |
| 5931 | * Allowed values are: |
| 5932 | * <p> |
| 5933 | * <ul> |
| 5934 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 5935 | * <li>{@link #TYPE_DEFAULT}</li> |
| 5936 | * <li>{@link #TYPE_OTHER_NAME}</li> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5937 | * <li>{@link #TYPE_MAIDEN_NAME}</li> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5938 | * <li>{@link #TYPE_SHORT_NAME}</li> |
| 5939 | * <li>{@link #TYPE_INITIALS}</li> |
| 5940 | * </ul> |
| 5941 | * </p> |
| 5942 | * </td> |
| 5943 | * </tr> |
| 5944 | * <tr> |
| 5945 | * <td>String</td> |
| 5946 | * <td>{@link #LABEL}</td> |
| 5947 | * <td>{@link #DATA3}</td> |
| 5948 | * <td></td> |
| 5949 | * </tr> |
| 5950 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5951 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 5952 | public static final class Nickname implements DataColumnsWithJoins, CommonColumns, |
| 5953 | ContactCounts{ |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 5954 | /** |
| 5955 | * This utility class cannot be instantiated |
| 5956 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5957 | private Nickname() {} |
| 5958 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 5959 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5960 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; |
| 5961 | |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 5962 | public static final int TYPE_DEFAULT = 1; |
| 5963 | public static final int TYPE_OTHER_NAME = 2; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 5964 | public static final int TYPE_MAIDEN_NAME = 3; |
| 5965 | /** @deprecated Use TYPE_MAIDEN_NAME instead. */ |
| 5966 | @Deprecated |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 5967 | public static final int TYPE_MAINDEN_NAME = 3; |
| 5968 | public static final int TYPE_SHORT_NAME = 4; |
| 5969 | public static final int TYPE_INITIALS = 5; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5970 | |
| 5971 | /** |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 5972 | * The name itself |
| 5973 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 5974 | public static final String NAME = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 5975 | } |
| 5976 | |
| 5977 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 5978 | * <p> |
| 5979 | * A data kind representing a telephone number. |
| 5980 | * </p> |
| 5981 | * <p> |
| 5982 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 5983 | * well as the following aliases. |
| 5984 | * </p> |
| 5985 | * <h2>Column aliases</h2> |
| 5986 | * <table class="jd-sumtable"> |
| 5987 | * <tr> |
| 5988 | * <th>Type</th> |
| 5989 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 5990 | * </tr> |
| 5991 | * <tr> |
| 5992 | * <td>String</td> |
| 5993 | * <td>{@link #NUMBER}</td> |
| 5994 | * <td>{@link #DATA1}</td> |
| 5995 | * <td></td> |
| 5996 | * </tr> |
| 5997 | * <tr> |
| 5998 | * <td>int</td> |
| 5999 | * <td>{@link #TYPE}</td> |
| 6000 | * <td>{@link #DATA2}</td> |
| 6001 | * <td>Allowed values are: |
| 6002 | * <p> |
| 6003 | * <ul> |
| 6004 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6005 | * <li>{@link #TYPE_HOME}</li> |
| 6006 | * <li>{@link #TYPE_MOBILE}</li> |
| 6007 | * <li>{@link #TYPE_WORK}</li> |
| 6008 | * <li>{@link #TYPE_FAX_WORK}</li> |
| 6009 | * <li>{@link #TYPE_FAX_HOME}</li> |
| 6010 | * <li>{@link #TYPE_PAGER}</li> |
| 6011 | * <li>{@link #TYPE_OTHER}</li> |
| 6012 | * <li>{@link #TYPE_CALLBACK}</li> |
| 6013 | * <li>{@link #TYPE_CAR}</li> |
| 6014 | * <li>{@link #TYPE_COMPANY_MAIN}</li> |
| 6015 | * <li>{@link #TYPE_ISDN}</li> |
| 6016 | * <li>{@link #TYPE_MAIN}</li> |
| 6017 | * <li>{@link #TYPE_OTHER_FAX}</li> |
| 6018 | * <li>{@link #TYPE_RADIO}</li> |
| 6019 | * <li>{@link #TYPE_TELEX}</li> |
| 6020 | * <li>{@link #TYPE_TTY_TDD}</li> |
| 6021 | * <li>{@link #TYPE_WORK_MOBILE}</li> |
| 6022 | * <li>{@link #TYPE_WORK_PAGER}</li> |
| 6023 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 6024 | * <li>{@link #TYPE_MMS}</li> |
| 6025 | * </ul> |
| 6026 | * </p> |
| 6027 | * </td> |
| 6028 | * </tr> |
| 6029 | * <tr> |
| 6030 | * <td>String</td> |
| 6031 | * <td>{@link #LABEL}</td> |
| 6032 | * <td>{@link #DATA3}</td> |
| 6033 | * <td></td> |
| 6034 | * </tr> |
| 6035 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6036 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6037 | public static final class Phone implements DataColumnsWithJoins, CommonColumns, |
| 6038 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6039 | /** |
| 6040 | * This utility class cannot be instantiated |
| 6041 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6042 | private Phone() {} |
| 6043 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6044 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6045 | 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] | 6046 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6047 | /** |
| 6048 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 6049 | * phones. |
| 6050 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6051 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2"; |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6052 | |
| 6053 | /** |
| 6054 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6055 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 6056 | * associated raw contact and aggregate contact data. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6057 | */ |
| 6058 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6059 | "phones"); |
| 6060 | |
| 6061 | /** |
Ricky Wai | fa5bbaf | 2015-02-26 16:51:32 +0000 | [diff] [blame] | 6062 | * URI used for getting all contacts from primary and managed profile. |
| 6063 | * |
| 6064 | * It supports the same semantics as {@link #CONTENT_URI} and returns the same |
| 6065 | * columns. If the device has no corp profile that is linked to the current profile, it |
| 6066 | * behaves in the exact same way as {@link #CONTENT_URI}. If there is a corp profile |
| 6067 | * linked to the current profile, it will merge corp profile and current profile's |
| 6068 | * results and return |
| 6069 | * |
| 6070 | * @hide |
| 6071 | */ |
Philip P. Moltmann | 3311515 | 2018-04-11 13:39:36 -0700 | [diff] [blame] | 6072 | @TestApi |
Ricky Wai | fa5bbaf | 2015-02-26 16:51:32 +0000 | [diff] [blame] | 6073 | public static final Uri ENTERPRISE_CONTENT_URI = |
| 6074 | Uri.withAppendedPath(Data.ENTERPRISE_CONTENT_URI, "phones"); |
| 6075 | |
| 6076 | /** |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6077 | * <p>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] | 6078 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6079 | * to display names as well as phone numbers. The filter argument should be passed |
| 6080 | * as an additional path segment after this URI. |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6081 | * |
| 6082 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer |
| 6083 | * sorts results based on contacts frequency. For more information, see the |
| 6084 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 6085 | * page. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6086 | */ |
| 6087 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 6088 | "filter"); |
| 6089 | |
Daniel Lehmann | 1024de5 | 2012-06-15 20:32:33 -0700 | [diff] [blame] | 6090 | /** |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6091 | * <p>It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the |
| 6092 | * same columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 6093 | * parameters, otherwise it will throw IllegalArgumentException. |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6094 | * |
| 6095 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts |
| 6096 | * results based on contacts frequency. For more information, see the |
| 6097 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 6098 | * page. |
Victor Chang | 3d47ceb | 2015-12-01 16:30:43 +0000 | [diff] [blame] | 6099 | */ |
| 6100 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 6101 | CONTENT_URI, "filter_enterprise"); |
| 6102 | |
| 6103 | /** |
Daniel Lehmann | 1024de5 | 2012-06-15 20:32:33 -0700 | [diff] [blame] | 6104 | * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. |
| 6105 | * If "1" or "true", display names are searched. If "0" or "false", display names |
| 6106 | * are not searched. Default is "1". |
| 6107 | */ |
| 6108 | public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name"; |
| 6109 | |
| 6110 | /** |
| 6111 | * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}. |
| 6112 | * If "1" or "true", phone numbers are searched. If "0" or "false", phone numbers |
| 6113 | * are not searched. Default is "1". |
| 6114 | */ |
| 6115 | public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number"; |
| 6116 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6117 | public static final int TYPE_HOME = 1; |
| 6118 | public static final int TYPE_MOBILE = 2; |
| 6119 | public static final int TYPE_WORK = 3; |
| 6120 | public static final int TYPE_FAX_WORK = 4; |
| 6121 | public static final int TYPE_FAX_HOME = 5; |
| 6122 | public static final int TYPE_PAGER = 6; |
| 6123 | public static final int TYPE_OTHER = 7; |
Fred Quintana | 3f86715 | 2009-08-03 11:43:16 -0700 | [diff] [blame] | 6124 | public static final int TYPE_CALLBACK = 8; |
| 6125 | public static final int TYPE_CAR = 9; |
| 6126 | public static final int TYPE_COMPANY_MAIN = 10; |
| 6127 | public static final int TYPE_ISDN = 11; |
| 6128 | public static final int TYPE_MAIN = 12; |
| 6129 | public static final int TYPE_OTHER_FAX = 13; |
| 6130 | public static final int TYPE_RADIO = 14; |
| 6131 | public static final int TYPE_TELEX = 15; |
| 6132 | public static final int TYPE_TTY_TDD = 16; |
| 6133 | public static final int TYPE_WORK_MOBILE = 17; |
| 6134 | public static final int TYPE_WORK_PAGER = 18; |
| 6135 | public static final int TYPE_ASSISTANT = 19; |
Jeff Sharkey | d5abd46 | 2009-09-16 19:54:29 -0700 | [diff] [blame] | 6136 | public static final int TYPE_MMS = 20; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6137 | |
| 6138 | /** |
| 6139 | * The phone number as the user entered it. |
| 6140 | * <P>Type: TEXT</P> |
| 6141 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6142 | public static final String NUMBER = DATA; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 6143 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6144 | /** |
Daniel Lehmann | db91915 | 2012-03-09 14:30:50 -0800 | [diff] [blame] | 6145 | * 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] | 6146 | * case the provider will try to automatically infer it. (It'll be left null if the |
| 6147 | * provider fails to infer.) |
| 6148 | * 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] | 6149 | * <P>Type: TEXT</P> |
Bai Tao | 224744c | 2010-08-31 09:59:13 +0800 | [diff] [blame] | 6150 | */ |
| 6151 | public static final String NORMALIZED_NUMBER = DATA4; |
| 6152 | |
| 6153 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6154 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6155 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6156 | */ |
| 6157 | @Deprecated |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 6158 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 6159 | CharSequence label, CharSequence[] labelArray) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6160 | return getTypeLabel(context.getResources(), type, label); |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 6161 | } |
| 6162 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6163 | /** |
| 6164 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6165 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6166 | */ |
| 6167 | @Deprecated |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 6168 | @UnsupportedAppUsage |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 6169 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 6170 | CharSequence label) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6171 | return getTypeLabel(context.getResources(), type, label); |
| 6172 | } |
| 6173 | |
| 6174 | /** |
| 6175 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6176 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6177 | */ |
| 6178 | public static final int getTypeLabelResource(int type) { |
| 6179 | switch (type) { |
| 6180 | case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome; |
| 6181 | case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile; |
| 6182 | case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork; |
| 6183 | case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork; |
| 6184 | case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome; |
| 6185 | case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager; |
| 6186 | case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther; |
| 6187 | case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback; |
| 6188 | case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar; |
| 6189 | case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain; |
| 6190 | case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn; |
| 6191 | case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain; |
| 6192 | case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax; |
| 6193 | case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio; |
| 6194 | case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex; |
| 6195 | case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd; |
| 6196 | case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile; |
| 6197 | case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager; |
| 6198 | case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant; |
| 6199 | case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms; |
| 6200 | default: return com.android.internal.R.string.phoneTypeCustom; |
| 6201 | } |
| 6202 | } |
| 6203 | |
| 6204 | /** |
| 6205 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6206 | * possibly substituting the given {@link #LABEL} value |
| 6207 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6208 | */ |
| 6209 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6210 | CharSequence label) { |
Tingting Wang | 86ac228 | 2015-07-16 21:19:28 +0000 | [diff] [blame] | 6211 | if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6212 | return label; |
| 6213 | } else { |
| 6214 | final int labelRes = getTypeLabelResource(type); |
| 6215 | return res.getText(labelRes); |
| 6216 | } |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 6217 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6218 | } |
| 6219 | |
| 6220 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6221 | * <p> |
| 6222 | * A data kind representing an email address. |
| 6223 | * </p> |
| 6224 | * <p> |
| 6225 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6226 | * well as the following aliases. |
| 6227 | * </p> |
| 6228 | * <h2>Column aliases</h2> |
| 6229 | * <table class="jd-sumtable"> |
| 6230 | * <tr> |
| 6231 | * <th>Type</th> |
| 6232 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6233 | * </tr> |
| 6234 | * <tr> |
| 6235 | * <td>String</td> |
Dmitri Plotnikov | 1ecf551 | 2010-09-02 11:00:04 -0700 | [diff] [blame] | 6236 | * <td>{@link #ADDRESS}</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6237 | * <td>{@link #DATA1}</td> |
| 6238 | * <td>Email address itself.</td> |
| 6239 | * </tr> |
| 6240 | * <tr> |
| 6241 | * <td>int</td> |
| 6242 | * <td>{@link #TYPE}</td> |
| 6243 | * <td>{@link #DATA2}</td> |
| 6244 | * <td>Allowed values are: |
| 6245 | * <p> |
| 6246 | * <ul> |
| 6247 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6248 | * <li>{@link #TYPE_HOME}</li> |
| 6249 | * <li>{@link #TYPE_WORK}</li> |
| 6250 | * <li>{@link #TYPE_OTHER}</li> |
| 6251 | * <li>{@link #TYPE_MOBILE}</li> |
| 6252 | * </ul> |
| 6253 | * </p> |
| 6254 | * </td> |
| 6255 | * </tr> |
| 6256 | * <tr> |
| 6257 | * <td>String</td> |
| 6258 | * <td>{@link #LABEL}</td> |
| 6259 | * <td>{@link #DATA3}</td> |
| 6260 | * <td></td> |
| 6261 | * </tr> |
| 6262 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6263 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6264 | public static final class Email implements DataColumnsWithJoins, CommonColumns, |
| 6265 | ContactCounts { |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6266 | /* |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6267 | * This utility class cannot be instantiated |
| 6268 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6269 | private Email() {} |
| 6270 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6271 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6272 | 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] | 6273 | |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6274 | /** |
Dmitri Plotnikov | abf15c3 | 2009-09-18 20:29:11 -0700 | [diff] [blame] | 6275 | * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses. |
| 6276 | */ |
| 6277 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2"; |
| 6278 | |
| 6279 | /** |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6280 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6281 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6282 | * associated raw contact and aggregate contact data. |
| 6283 | */ |
| 6284 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6285 | "emails"); |
| 6286 | |
| 6287 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6288 | * <p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6289 | * The content:// style URL for looking up data rows by email address. The |
| 6290 | * lookup argument, an email address, should be passed as an additional path segment |
| 6291 | * after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6292 | * </p> |
| 6293 | * <p>Example: |
| 6294 | * <pre> |
| 6295 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email)); |
| 6296 | * Cursor c = getContentResolver().query(uri, |
| 6297 | * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA}, |
| 6298 | * null, null, null); |
| 6299 | * </pre> |
| 6300 | * </p> |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6301 | */ |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6302 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 6303 | "lookup"); |
| 6304 | |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6305 | /** |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 6306 | * <p>URI used for enterprise email lookup.</p> |
| 6307 | * |
| 6308 | * <p> |
| 6309 | * It supports the same semantics as {@link #CONTENT_LOOKUP_URI} and returns the same |
| 6310 | * columns. If the device has no corp profile that is linked to the current profile, it |
| 6311 | * behaves in the exact same way as {@link #CONTENT_LOOKUP_URI}. If there is a |
| 6312 | * corp profile linked to the current profile, it first queries against the personal contact database, |
| 6313 | * and if no matching contacts are found there, then queries against the |
| 6314 | * corp contacts database. |
| 6315 | * </p> |
| 6316 | * <p> |
| 6317 | * If a result is from the corp profile, it makes the following changes to the data: |
| 6318 | * <ul> |
| 6319 | * <li> |
| 6320 | * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special |
| 6321 | * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to |
| 6322 | * load pictures from them. |
| 6323 | * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not |
| 6324 | * use them. |
| 6325 | * </li> |
| 6326 | * <li> |
| 6327 | * Corp contacts will get artificial {@link #CONTACT_ID}s. In order to tell whether |
| 6328 | * a contact |
| 6329 | * is from the corp profile, use |
| 6330 | * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}. |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 6331 | * </li> |
| 6332 | * <li> |
| 6333 | * Corp contacts will get artificial {@link #LOOKUP_KEY}s too. |
| 6334 | * </li> |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 6335 | * <li> |
| 6336 | * Returned work contact IDs and lookup keys are not accepted in places that not |
| 6337 | * explicitly say to accept them. |
| 6338 | * </li> |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 6339 | * </ul> |
| 6340 | * <p> |
| 6341 | * A contact lookup URL built by |
| 6342 | * {@link ContactsContract.Contacts#getLookupUri(long, String)} |
| 6343 | * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to |
| 6344 | * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the |
| 6345 | * corp profile. |
| 6346 | * </p> |
Ricky Wai | 323b30e | 2015-02-27 14:58:00 +0000 | [diff] [blame] | 6347 | * |
| 6348 | * <pre> |
| 6349 | * Uri lookupUri = Uri.withAppendedPath(Email.ENTERPRISE_CONTENT_LOOKUP_URI, |
| 6350 | * Uri.encode(email)); |
| 6351 | * </pre> |
| 6352 | */ |
| 6353 | public static final Uri ENTERPRISE_CONTENT_LOOKUP_URI = |
| 6354 | Uri.withAppendedPath(CONTENT_URI, "lookup_enterprise"); |
| 6355 | |
| 6356 | /** |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6357 | * <p>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] | 6358 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6359 | * to display names as well as email addresses. The filter argument should be passed |
| 6360 | * as an additional path segment after this URI. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6361 | * </p> |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6362 | * |
| 6363 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts |
| 6364 | * results based on contacts frequency. For more information, see the |
| 6365 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 6366 | * page.</p> |
| 6367 | * |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6368 | * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)" |
| 6369 | * as well as "Bob Parr (incredible@android.com)". |
| 6370 | * <pre> |
| 6371 | * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob")); |
| 6372 | * Cursor c = getContentResolver().query(uri, |
| 6373 | * new String[]{Email.DISPLAY_NAME, Email.DATA}, |
| 6374 | * null, null, null); |
| 6375 | * </pre> |
| 6376 | * </p> |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 6377 | */ |
| 6378 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 6379 | "filter"); |
| 6380 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6381 | /** |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6382 | * <p>It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the |
| 6383 | * same columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 6384 | * parameters, otherwise it will throw IllegalArgumentException. |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 6385 | * |
| 6386 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer |
| 6387 | * sorts results based on contacts frequency. For more information, see the |
| 6388 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 6389 | * page. |
Tony Mak | 415369e | 2015-12-08 07:24:55 +0000 | [diff] [blame] | 6390 | */ |
| 6391 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 6392 | CONTENT_URI, "filter_enterprise"); |
| 6393 | |
| 6394 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6395 | * The email address. |
| 6396 | * <P>Type: TEXT</P> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6397 | */ |
| 6398 | public static final String ADDRESS = DATA1; |
| 6399 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6400 | public static final int TYPE_HOME = 1; |
| 6401 | public static final int TYPE_WORK = 2; |
| 6402 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 14fb153 | 2009-08-29 15:54:26 -0700 | [diff] [blame] | 6403 | public static final int TYPE_MOBILE = 4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6404 | |
| 6405 | /** |
| 6406 | * The display name for the email address |
| 6407 | * <P>Type: TEXT</P> |
| 6408 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6409 | public static final String DISPLAY_NAME = DATA4; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6410 | |
| 6411 | /** |
| 6412 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6413 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6414 | */ |
| 6415 | public static final int getTypeLabelResource(int type) { |
| 6416 | switch (type) { |
| 6417 | case TYPE_HOME: return com.android.internal.R.string.emailTypeHome; |
| 6418 | case TYPE_WORK: return com.android.internal.R.string.emailTypeWork; |
| 6419 | case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther; |
| 6420 | case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile; |
| 6421 | default: return com.android.internal.R.string.emailTypeCustom; |
| 6422 | } |
| 6423 | } |
| 6424 | |
| 6425 | /** |
| 6426 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6427 | * possibly substituting the given {@link #LABEL} value |
| 6428 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6429 | */ |
| 6430 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6431 | CharSequence label) { |
| 6432 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6433 | return label; |
| 6434 | } else { |
| 6435 | final int labelRes = getTypeLabelResource(type); |
| 6436 | return res.getText(labelRes); |
| 6437 | } |
| 6438 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6439 | } |
| 6440 | |
| 6441 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6442 | * <p> |
| 6443 | * A data kind representing a postal addresses. |
| 6444 | * </p> |
| 6445 | * <p> |
| 6446 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6447 | * well as the following aliases. |
| 6448 | * </p> |
| 6449 | * <h2>Column aliases</h2> |
| 6450 | * <table class="jd-sumtable"> |
| 6451 | * <tr> |
| 6452 | * <th>Type</th> |
| 6453 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6454 | * </tr> |
| 6455 | * <tr> |
| 6456 | * <td>String</td> |
| 6457 | * <td>{@link #FORMATTED_ADDRESS}</td> |
| 6458 | * <td>{@link #DATA1}</td> |
| 6459 | * <td></td> |
| 6460 | * </tr> |
| 6461 | * <tr> |
| 6462 | * <td>int</td> |
| 6463 | * <td>{@link #TYPE}</td> |
| 6464 | * <td>{@link #DATA2}</td> |
| 6465 | * <td>Allowed values are: |
| 6466 | * <p> |
| 6467 | * <ul> |
| 6468 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6469 | * <li>{@link #TYPE_HOME}</li> |
| 6470 | * <li>{@link #TYPE_WORK}</li> |
| 6471 | * <li>{@link #TYPE_OTHER}</li> |
| 6472 | * </ul> |
| 6473 | * </p> |
| 6474 | * </td> |
| 6475 | * </tr> |
| 6476 | * <tr> |
| 6477 | * <td>String</td> |
| 6478 | * <td>{@link #LABEL}</td> |
| 6479 | * <td>{@link #DATA3}</td> |
| 6480 | * <td></td> |
| 6481 | * </tr> |
| 6482 | * <tr> |
| 6483 | * <td>String</td> |
| 6484 | * <td>{@link #STREET}</td> |
| 6485 | * <td>{@link #DATA4}</td> |
| 6486 | * <td></td> |
| 6487 | * </tr> |
| 6488 | * <tr> |
| 6489 | * <td>String</td> |
| 6490 | * <td>{@link #POBOX}</td> |
| 6491 | * <td>{@link #DATA5}</td> |
| 6492 | * <td>Post Office Box number</td> |
| 6493 | * </tr> |
| 6494 | * <tr> |
| 6495 | * <td>String</td> |
| 6496 | * <td>{@link #NEIGHBORHOOD}</td> |
| 6497 | * <td>{@link #DATA6}</td> |
| 6498 | * <td></td> |
| 6499 | * </tr> |
| 6500 | * <tr> |
| 6501 | * <td>String</td> |
| 6502 | * <td>{@link #CITY}</td> |
| 6503 | * <td>{@link #DATA7}</td> |
| 6504 | * <td></td> |
| 6505 | * </tr> |
| 6506 | * <tr> |
| 6507 | * <td>String</td> |
| 6508 | * <td>{@link #REGION}</td> |
| 6509 | * <td>{@link #DATA8}</td> |
| 6510 | * <td></td> |
| 6511 | * </tr> |
| 6512 | * <tr> |
| 6513 | * <td>String</td> |
| 6514 | * <td>{@link #POSTCODE}</td> |
| 6515 | * <td>{@link #DATA9}</td> |
| 6516 | * <td></td> |
| 6517 | * </tr> |
| 6518 | * <tr> |
| 6519 | * <td>String</td> |
| 6520 | * <td>{@link #COUNTRY}</td> |
| 6521 | * <td>{@link #DATA10}</td> |
| 6522 | * <td></td> |
| 6523 | * </tr> |
| 6524 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6525 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6526 | public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns, |
| 6527 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6528 | /** |
| 6529 | * This utility class cannot be instantiated |
| 6530 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6531 | private StructuredPostal() { |
| 6532 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6533 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6534 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6535 | public static final String CONTENT_ITEM_TYPE = |
| 6536 | "vnd.android.cursor.item/postal-address_v2"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6537 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6538 | /** |
| 6539 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 6540 | * postal addresses. |
| 6541 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 6542 | 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] | 6543 | |
| 6544 | /** |
| 6545 | * The content:// style URI for all data records of the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6546 | * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 6547 | */ |
| 6548 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 6549 | "postals"); |
| 6550 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6551 | public static final int TYPE_HOME = 1; |
| 6552 | public static final int TYPE_WORK = 2; |
| 6553 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6554 | |
| 6555 | /** |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 6556 | * The full, unstructured postal address. <i>This field must be |
| 6557 | * consistent with any structured data.</i> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6558 | * <p> |
| 6559 | * Type: TEXT |
| 6560 | */ |
| 6561 | public static final String FORMATTED_ADDRESS = DATA; |
| 6562 | |
| 6563 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6564 | * Can be street, avenue, road, etc. This element also includes the |
| 6565 | * house number and room/apartment/flat/floor number. |
| 6566 | * <p> |
| 6567 | * Type: TEXT |
| 6568 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6569 | public static final String STREET = DATA4; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6570 | |
| 6571 | /** |
| 6572 | * Covers actual P.O. boxes, drawers, locked bags, etc. This is |
| 6573 | * usually but not always mutually exclusive with street. |
| 6574 | * <p> |
| 6575 | * Type: TEXT |
| 6576 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6577 | public static final String POBOX = DATA5; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6578 | |
| 6579 | /** |
| 6580 | * This is used to disambiguate a street address when a city |
| 6581 | * contains more than one street with the same name, or to specify a |
| 6582 | * small place whose mail is routed through a larger postal town. In |
| 6583 | * China it could be a county or a minor city. |
| 6584 | * <p> |
| 6585 | * Type: TEXT |
| 6586 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6587 | public static final String NEIGHBORHOOD = DATA6; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6588 | |
| 6589 | /** |
| 6590 | * Can be city, village, town, borough, etc. This is the postal town |
| 6591 | * and not necessarily the place of residence or place of business. |
| 6592 | * <p> |
| 6593 | * Type: TEXT |
| 6594 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6595 | public static final String CITY = DATA7; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6596 | |
| 6597 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6598 | * A state, province, county (in Ireland), Land (in Germany), |
| 6599 | * departement (in France), etc. |
| 6600 | * <p> |
| 6601 | * Type: TEXT |
| 6602 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6603 | public static final String REGION = DATA8; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6604 | |
| 6605 | /** |
Jeff Sharkey | ef348c7 | 2009-07-26 14:14:34 -0700 | [diff] [blame] | 6606 | * Postal code. Usually country-wide, but sometimes specific to the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6607 | * city (e.g. "2" in "Dublin 2, Ireland" addresses). |
| 6608 | * <p> |
| 6609 | * Type: TEXT |
| 6610 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6611 | public static final String POSTCODE = DATA9; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6612 | |
| 6613 | /** |
| 6614 | * The name or code of the country. |
| 6615 | * <p> |
| 6616 | * Type: TEXT |
| 6617 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6618 | public static final String COUNTRY = DATA10; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6619 | |
| 6620 | /** |
| 6621 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6622 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6623 | */ |
| 6624 | public static final int getTypeLabelResource(int type) { |
| 6625 | switch (type) { |
| 6626 | case TYPE_HOME: return com.android.internal.R.string.postalTypeHome; |
| 6627 | case TYPE_WORK: return com.android.internal.R.string.postalTypeWork; |
| 6628 | case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther; |
| 6629 | default: return com.android.internal.R.string.postalTypeCustom; |
| 6630 | } |
| 6631 | } |
| 6632 | |
| 6633 | /** |
| 6634 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6635 | * possibly substituting the given {@link #LABEL} value |
| 6636 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6637 | */ |
| 6638 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6639 | CharSequence label) { |
| 6640 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6641 | return label; |
| 6642 | } else { |
| 6643 | final int labelRes = getTypeLabelResource(type); |
| 6644 | return res.getText(labelRes); |
| 6645 | } |
| 6646 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6647 | } |
| 6648 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6649 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6650 | * <p> |
| 6651 | * A data kind representing an IM address |
| 6652 | * </p> |
| 6653 | * <p> |
| 6654 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6655 | * well as the following aliases. |
| 6656 | * </p> |
| 6657 | * <h2>Column aliases</h2> |
| 6658 | * <table class="jd-sumtable"> |
| 6659 | * <tr> |
| 6660 | * <th>Type</th> |
| 6661 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6662 | * </tr> |
| 6663 | * <tr> |
| 6664 | * <td>String</td> |
| 6665 | * <td>{@link #DATA}</td> |
| 6666 | * <td>{@link #DATA1}</td> |
| 6667 | * <td></td> |
| 6668 | * </tr> |
| 6669 | * <tr> |
| 6670 | * <td>int</td> |
| 6671 | * <td>{@link #TYPE}</td> |
| 6672 | * <td>{@link #DATA2}</td> |
| 6673 | * <td>Allowed values are: |
| 6674 | * <p> |
| 6675 | * <ul> |
| 6676 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6677 | * <li>{@link #TYPE_HOME}</li> |
| 6678 | * <li>{@link #TYPE_WORK}</li> |
| 6679 | * <li>{@link #TYPE_OTHER}</li> |
| 6680 | * </ul> |
| 6681 | * </p> |
| 6682 | * </td> |
| 6683 | * </tr> |
| 6684 | * <tr> |
| 6685 | * <td>String</td> |
| 6686 | * <td>{@link #LABEL}</td> |
| 6687 | * <td>{@link #DATA3}</td> |
| 6688 | * <td></td> |
| 6689 | * </tr> |
| 6690 | * <tr> |
| 6691 | * <td>String</td> |
| 6692 | * <td>{@link #PROTOCOL}</td> |
| 6693 | * <td>{@link #DATA5}</td> |
| 6694 | * <td> |
| 6695 | * <p> |
| 6696 | * Allowed values: |
| 6697 | * <ul> |
| 6698 | * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name |
| 6699 | * as {@link #CUSTOM_PROTOCOL}.</li> |
| 6700 | * <li>{@link #PROTOCOL_AIM}</li> |
| 6701 | * <li>{@link #PROTOCOL_MSN}</li> |
| 6702 | * <li>{@link #PROTOCOL_YAHOO}</li> |
| 6703 | * <li>{@link #PROTOCOL_SKYPE}</li> |
| 6704 | * <li>{@link #PROTOCOL_QQ}</li> |
| 6705 | * <li>{@link #PROTOCOL_GOOGLE_TALK}</li> |
| 6706 | * <li>{@link #PROTOCOL_ICQ}</li> |
| 6707 | * <li>{@link #PROTOCOL_JABBER}</li> |
| 6708 | * <li>{@link #PROTOCOL_NETMEETING}</li> |
| 6709 | * </ul> |
| 6710 | * </p> |
| 6711 | * </td> |
| 6712 | * </tr> |
| 6713 | * <tr> |
| 6714 | * <td>String</td> |
| 6715 | * <td>{@link #CUSTOM_PROTOCOL}</td> |
| 6716 | * <td>{@link #DATA6}</td> |
| 6717 | * <td></td> |
| 6718 | * </tr> |
| 6719 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6720 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6721 | public static final class Im implements DataColumnsWithJoins, CommonColumns, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6722 | /** |
| 6723 | * This utility class cannot be instantiated |
| 6724 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6725 | private Im() {} |
| 6726 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6727 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6728 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; |
| 6729 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6730 | public static final int TYPE_HOME = 1; |
| 6731 | public static final int TYPE_WORK = 2; |
| 6732 | public static final int TYPE_OTHER = 3; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6733 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 6734 | /** |
| 6735 | * This column should be populated with one of the defined |
| 6736 | * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this |
| 6737 | * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL} |
| 6738 | * should contain the name of the custom protocol. |
| 6739 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6740 | public static final String PROTOCOL = DATA5; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 6741 | |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6742 | public static final String CUSTOM_PROTOCOL = DATA6; |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 6743 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 6744 | /* |
| 6745 | * The predefined IM protocol types. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6746 | */ |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 6747 | public static final int PROTOCOL_CUSTOM = -1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6748 | public static final int PROTOCOL_AIM = 0; |
| 6749 | public static final int PROTOCOL_MSN = 1; |
| 6750 | public static final int PROTOCOL_YAHOO = 2; |
| 6751 | public static final int PROTOCOL_SKYPE = 3; |
| 6752 | public static final int PROTOCOL_QQ = 4; |
| 6753 | public static final int PROTOCOL_GOOGLE_TALK = 5; |
| 6754 | public static final int PROTOCOL_ICQ = 6; |
| 6755 | public static final int PROTOCOL_JABBER = 7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6756 | public static final int PROTOCOL_NETMEETING = 8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6757 | |
| 6758 | /** |
| 6759 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6760 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6761 | */ |
| 6762 | public static final int getTypeLabelResource(int type) { |
| 6763 | switch (type) { |
| 6764 | case TYPE_HOME: return com.android.internal.R.string.imTypeHome; |
| 6765 | case TYPE_WORK: return com.android.internal.R.string.imTypeWork; |
| 6766 | case TYPE_OTHER: return com.android.internal.R.string.imTypeOther; |
| 6767 | default: return com.android.internal.R.string.imTypeCustom; |
| 6768 | } |
| 6769 | } |
| 6770 | |
| 6771 | /** |
| 6772 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6773 | * possibly substituting the given {@link #LABEL} value |
| 6774 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6775 | */ |
| 6776 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6777 | CharSequence label) { |
| 6778 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6779 | return label; |
| 6780 | } else { |
| 6781 | final int labelRes = getTypeLabelResource(type); |
| 6782 | return res.getText(labelRes); |
| 6783 | } |
| 6784 | } |
| 6785 | |
| 6786 | /** |
| 6787 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6788 | * {@link #PROTOCOL}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6789 | */ |
| 6790 | public static final int getProtocolLabelResource(int type) { |
| 6791 | switch (type) { |
| 6792 | case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim; |
| 6793 | case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn; |
| 6794 | case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo; |
| 6795 | case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype; |
| 6796 | case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq; |
| 6797 | case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk; |
| 6798 | case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq; |
| 6799 | case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber; |
| 6800 | case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting; |
| 6801 | default: return com.android.internal.R.string.imProtocolCustom; |
| 6802 | } |
| 6803 | } |
| 6804 | |
| 6805 | /** |
| 6806 | * Return a {@link CharSequence} that best describes the given |
| 6807 | * protocol, possibly substituting the given |
| 6808 | * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}. |
| 6809 | */ |
| 6810 | public static final CharSequence getProtocolLabel(Resources res, int type, |
| 6811 | CharSequence label) { |
| 6812 | if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6813 | return label; |
| 6814 | } else { |
| 6815 | final int labelRes = getProtocolLabelResource(type); |
| 6816 | return res.getText(labelRes); |
| 6817 | } |
| 6818 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6819 | } |
| 6820 | |
| 6821 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6822 | * <p> |
| 6823 | * A data kind representing an organization. |
| 6824 | * </p> |
| 6825 | * <p> |
| 6826 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 6827 | * well as the following aliases. |
| 6828 | * </p> |
| 6829 | * <h2>Column aliases</h2> |
| 6830 | * <table class="jd-sumtable"> |
| 6831 | * <tr> |
| 6832 | * <th>Type</th> |
| 6833 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 6834 | * </tr> |
| 6835 | * <tr> |
| 6836 | * <td>String</td> |
| 6837 | * <td>{@link #COMPANY}</td> |
| 6838 | * <td>{@link #DATA1}</td> |
| 6839 | * <td></td> |
| 6840 | * </tr> |
| 6841 | * <tr> |
| 6842 | * <td>int</td> |
| 6843 | * <td>{@link #TYPE}</td> |
| 6844 | * <td>{@link #DATA2}</td> |
| 6845 | * <td>Allowed values are: |
| 6846 | * <p> |
| 6847 | * <ul> |
| 6848 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 6849 | * <li>{@link #TYPE_WORK}</li> |
| 6850 | * <li>{@link #TYPE_OTHER}</li> |
| 6851 | * </ul> |
| 6852 | * </p> |
| 6853 | * </td> |
| 6854 | * </tr> |
| 6855 | * <tr> |
| 6856 | * <td>String</td> |
| 6857 | * <td>{@link #LABEL}</td> |
| 6858 | * <td>{@link #DATA3}</td> |
| 6859 | * <td></td> |
| 6860 | * </tr> |
| 6861 | * <tr> |
| 6862 | * <td>String</td> |
| 6863 | * <td>{@link #TITLE}</td> |
| 6864 | * <td>{@link #DATA4}</td> |
| 6865 | * <td></td> |
| 6866 | * </tr> |
| 6867 | * <tr> |
| 6868 | * <td>String</td> |
| 6869 | * <td>{@link #DEPARTMENT}</td> |
| 6870 | * <td>{@link #DATA5}</td> |
| 6871 | * <td></td> |
| 6872 | * </tr> |
| 6873 | * <tr> |
| 6874 | * <td>String</td> |
| 6875 | * <td>{@link #JOB_DESCRIPTION}</td> |
| 6876 | * <td>{@link #DATA6}</td> |
| 6877 | * <td></td> |
| 6878 | * </tr> |
| 6879 | * <tr> |
| 6880 | * <td>String</td> |
| 6881 | * <td>{@link #SYMBOL}</td> |
| 6882 | * <td>{@link #DATA7}</td> |
| 6883 | * <td></td> |
| 6884 | * </tr> |
| 6885 | * <tr> |
| 6886 | * <td>String</td> |
| 6887 | * <td>{@link #PHONETIC_NAME}</td> |
| 6888 | * <td>{@link #DATA8}</td> |
| 6889 | * <td></td> |
| 6890 | * </tr> |
| 6891 | * <tr> |
| 6892 | * <td>String</td> |
| 6893 | * <td>{@link #OFFICE_LOCATION}</td> |
| 6894 | * <td>{@link #DATA9}</td> |
| 6895 | * <td></td> |
| 6896 | * </tr> |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 6897 | * <tr> |
| 6898 | * <td>String</td> |
| 6899 | * <td>PHONETIC_NAME_STYLE</td> |
| 6900 | * <td>{@link #DATA10}</td> |
| 6901 | * <td></td> |
| 6902 | * </tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6903 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6904 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 6905 | public static final class Organization implements DataColumnsWithJoins, CommonColumns, |
| 6906 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 6907 | /** |
| 6908 | * This utility class cannot be instantiated |
| 6909 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6910 | private Organization() {} |
| 6911 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 6912 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6913 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; |
| 6914 | |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6915 | public static final int TYPE_WORK = 1; |
| 6916 | public static final int TYPE_OTHER = 2; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6917 | |
| 6918 | /** |
| 6919 | * The company as the user entered it. |
| 6920 | * <P>Type: TEXT</P> |
| 6921 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 6922 | public static final String COMPANY = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 6923 | |
| 6924 | /** |
| 6925 | * The position title at this company as the user entered it. |
| 6926 | * <P>Type: TEXT</P> |
| 6927 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6928 | public static final String TITLE = DATA4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6929 | |
| 6930 | /** |
| 6931 | * The department at this company as the user entered it. |
| 6932 | * <P>Type: TEXT</P> |
| 6933 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6934 | public static final String DEPARTMENT = DATA5; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6935 | |
| 6936 | /** |
| 6937 | * The job description at this company as the user entered it. |
| 6938 | * <P>Type: TEXT</P> |
| 6939 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6940 | public static final String JOB_DESCRIPTION = DATA6; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6941 | |
| 6942 | /** |
| 6943 | * The symbol of this company as the user entered it. |
| 6944 | * <P>Type: TEXT</P> |
| 6945 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6946 | public static final String SYMBOL = DATA7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6947 | |
| 6948 | /** |
| 6949 | * The phonetic name of this company as the user entered it. |
| 6950 | * <P>Type: TEXT</P> |
| 6951 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 6952 | public static final String PHONETIC_NAME = DATA8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6953 | |
| 6954 | /** |
Jeff Sharkey | ff18bbf | 2009-09-27 16:55:00 -0700 | [diff] [blame] | 6955 | * The office location of this organization. |
| 6956 | * <P>Type: TEXT</P> |
| 6957 | */ |
| 6958 | public static final String OFFICE_LOCATION = DATA9; |
| 6959 | |
| 6960 | /** |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 6961 | * The alphabet used for capturing the phonetic name. |
| 6962 | * See {@link ContactsContract.PhoneticNameStyle}. |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 6963 | */ |
| 6964 | public static final String PHONETIC_NAME_STYLE = DATA10; |
| 6965 | |
| 6966 | /** |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6967 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6968 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6969 | */ |
| 6970 | public static final int getTypeLabelResource(int type) { |
| 6971 | switch (type) { |
| 6972 | case TYPE_WORK: return com.android.internal.R.string.orgTypeWork; |
| 6973 | case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther; |
| 6974 | default: return com.android.internal.R.string.orgTypeCustom; |
| 6975 | } |
| 6976 | } |
| 6977 | |
| 6978 | /** |
| 6979 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 6980 | * possibly substituting the given {@link #LABEL} value |
| 6981 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 6982 | */ |
| 6983 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 6984 | CharSequence label) { |
| 6985 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 6986 | return label; |
| 6987 | } else { |
| 6988 | final int labelRes = getTypeLabelResource(type); |
| 6989 | return res.getText(labelRes); |
| 6990 | } |
| 6991 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 6992 | } |
| 6993 | |
| 6994 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 6995 | * <p> |
| 6996 | * A data kind representing a relation. |
| 6997 | * </p> |
| 6998 | * <p> |
| 6999 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7000 | * well as the following aliases. |
| 7001 | * </p> |
| 7002 | * <h2>Column aliases</h2> |
| 7003 | * <table class="jd-sumtable"> |
| 7004 | * <tr> |
| 7005 | * <th>Type</th> |
| 7006 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7007 | * </tr> |
| 7008 | * <tr> |
| 7009 | * <td>String</td> |
| 7010 | * <td>{@link #NAME}</td> |
| 7011 | * <td>{@link #DATA1}</td> |
| 7012 | * <td></td> |
| 7013 | * </tr> |
| 7014 | * <tr> |
| 7015 | * <td>int</td> |
| 7016 | * <td>{@link #TYPE}</td> |
| 7017 | * <td>{@link #DATA2}</td> |
| 7018 | * <td>Allowed values are: |
| 7019 | * <p> |
| 7020 | * <ul> |
| 7021 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 7022 | * <li>{@link #TYPE_ASSISTANT}</li> |
| 7023 | * <li>{@link #TYPE_BROTHER}</li> |
| 7024 | * <li>{@link #TYPE_CHILD}</li> |
| 7025 | * <li>{@link #TYPE_DOMESTIC_PARTNER}</li> |
| 7026 | * <li>{@link #TYPE_FATHER}</li> |
| 7027 | * <li>{@link #TYPE_FRIEND}</li> |
| 7028 | * <li>{@link #TYPE_MANAGER}</li> |
| 7029 | * <li>{@link #TYPE_MOTHER}</li> |
| 7030 | * <li>{@link #TYPE_PARENT}</li> |
| 7031 | * <li>{@link #TYPE_PARTNER}</li> |
| 7032 | * <li>{@link #TYPE_REFERRED_BY}</li> |
| 7033 | * <li>{@link #TYPE_RELATIVE}</li> |
| 7034 | * <li>{@link #TYPE_SISTER}</li> |
| 7035 | * <li>{@link #TYPE_SPOUSE}</li> |
| 7036 | * </ul> |
| 7037 | * </p> |
| 7038 | * </td> |
| 7039 | * </tr> |
| 7040 | * <tr> |
| 7041 | * <td>String</td> |
| 7042 | * <td>{@link #LABEL}</td> |
| 7043 | * <td>{@link #DATA3}</td> |
| 7044 | * <td></td> |
| 7045 | * </tr> |
| 7046 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7047 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7048 | public static final class Relation implements DataColumnsWithJoins, CommonColumns, |
| 7049 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7050 | /** |
| 7051 | * This utility class cannot be instantiated |
| 7052 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7053 | private Relation() {} |
| 7054 | |
| 7055 | /** MIME type used when storing this in data table. */ |
| 7056 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; |
| 7057 | |
| 7058 | public static final int TYPE_ASSISTANT = 1; |
| 7059 | public static final int TYPE_BROTHER = 2; |
| 7060 | public static final int TYPE_CHILD = 3; |
| 7061 | public static final int TYPE_DOMESTIC_PARTNER = 4; |
| 7062 | public static final int TYPE_FATHER = 5; |
| 7063 | public static final int TYPE_FRIEND = 6; |
| 7064 | public static final int TYPE_MANAGER = 7; |
| 7065 | public static final int TYPE_MOTHER = 8; |
| 7066 | public static final int TYPE_PARENT = 9; |
| 7067 | public static final int TYPE_PARTNER = 10; |
| 7068 | public static final int TYPE_REFERRED_BY = 11; |
| 7069 | public static final int TYPE_RELATIVE = 12; |
| 7070 | public static final int TYPE_SISTER = 13; |
| 7071 | public static final int TYPE_SPOUSE = 14; |
| 7072 | |
| 7073 | /** |
| 7074 | * The name of the relative as the user entered it. |
| 7075 | * <P>Type: TEXT</P> |
| 7076 | */ |
| 7077 | public static final String NAME = DATA; |
Daniel Lehmann | 1fb39f0 | 2010-10-28 13:40:38 -0700 | [diff] [blame] | 7078 | |
| 7079 | /** |
| 7080 | * Return the string resource that best describes the given |
| 7081 | * {@link #TYPE}. Will always return a valid resource. |
| 7082 | */ |
| 7083 | public static final int getTypeLabelResource(int type) { |
| 7084 | switch (type) { |
| 7085 | case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant; |
| 7086 | case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother; |
| 7087 | case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild; |
| 7088 | case TYPE_DOMESTIC_PARTNER: |
| 7089 | return com.android.internal.R.string.relationTypeDomesticPartner; |
| 7090 | case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather; |
| 7091 | case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend; |
| 7092 | case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager; |
| 7093 | case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother; |
| 7094 | case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent; |
| 7095 | case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner; |
| 7096 | case TYPE_REFERRED_BY: |
| 7097 | return com.android.internal.R.string.relationTypeReferredBy; |
| 7098 | case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative; |
| 7099 | case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister; |
| 7100 | case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse; |
| 7101 | default: return com.android.internal.R.string.orgTypeCustom; |
| 7102 | } |
| 7103 | } |
| 7104 | |
| 7105 | /** |
| 7106 | * Return a {@link CharSequence} that best describes the given type, |
| 7107 | * possibly substituting the given {@link #LABEL} value |
| 7108 | * for {@link #TYPE_CUSTOM}. |
| 7109 | */ |
| 7110 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 7111 | CharSequence label) { |
| 7112 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 7113 | return label; |
| 7114 | } else { |
| 7115 | final int labelRes = getTypeLabelResource(type); |
| 7116 | return res.getText(labelRes); |
| 7117 | } |
| 7118 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7119 | } |
| 7120 | |
| 7121 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7122 | * <p> |
| 7123 | * A data kind representing an event. |
| 7124 | * </p> |
| 7125 | * <p> |
| 7126 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7127 | * well as the following aliases. |
| 7128 | * </p> |
| 7129 | * <h2>Column aliases</h2> |
| 7130 | * <table class="jd-sumtable"> |
| 7131 | * <tr> |
| 7132 | * <th>Type</th> |
| 7133 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7134 | * </tr> |
| 7135 | * <tr> |
| 7136 | * <td>String</td> |
| 7137 | * <td>{@link #START_DATE}</td> |
| 7138 | * <td>{@link #DATA1}</td> |
| 7139 | * <td></td> |
| 7140 | * </tr> |
| 7141 | * <tr> |
| 7142 | * <td>int</td> |
| 7143 | * <td>{@link #TYPE}</td> |
| 7144 | * <td>{@link #DATA2}</td> |
| 7145 | * <td>Allowed values are: |
| 7146 | * <p> |
| 7147 | * <ul> |
| 7148 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 7149 | * <li>{@link #TYPE_ANNIVERSARY}</li> |
| 7150 | * <li>{@link #TYPE_OTHER}</li> |
| 7151 | * <li>{@link #TYPE_BIRTHDAY}</li> |
| 7152 | * </ul> |
| 7153 | * </p> |
| 7154 | * </td> |
| 7155 | * </tr> |
| 7156 | * <tr> |
| 7157 | * <td>String</td> |
| 7158 | * <td>{@link #LABEL}</td> |
| 7159 | * <td>{@link #DATA3}</td> |
| 7160 | * <td></td> |
| 7161 | * </tr> |
| 7162 | * </table> |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7163 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7164 | public static final class Event implements DataColumnsWithJoins, CommonColumns, |
| 7165 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7166 | /** |
| 7167 | * This utility class cannot be instantiated |
| 7168 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7169 | private Event() {} |
| 7170 | |
| 7171 | /** MIME type used when storing this in data table. */ |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 7172 | 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] | 7173 | |
| 7174 | public static final int TYPE_ANNIVERSARY = 1; |
| 7175 | public static final int TYPE_OTHER = 2; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 7176 | public static final int TYPE_BIRTHDAY = 3; |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 7177 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7178 | /** |
| 7179 | * The event start date as the user entered it. |
| 7180 | * <P>Type: TEXT</P> |
| 7181 | */ |
| 7182 | public static final String START_DATE = DATA; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 7183 | |
| 7184 | /** |
| 7185 | * Return the string resource that best describes the given |
| 7186 | * {@link #TYPE}. Will always return a valid resource. |
| 7187 | */ |
| 7188 | public static int getTypeResource(Integer type) { |
| 7189 | if (type == null) { |
| 7190 | return com.android.internal.R.string.eventTypeOther; |
| 7191 | } |
| 7192 | switch (type) { |
| 7193 | case TYPE_ANNIVERSARY: |
| 7194 | return com.android.internal.R.string.eventTypeAnniversary; |
| 7195 | case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday; |
| 7196 | case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther; |
Daniel Lehmann | dd384a7 | 2010-11-01 18:40:50 -0700 | [diff] [blame] | 7197 | default: return com.android.internal.R.string.eventTypeCustom; |
Fred Quintana | c868acf | 2009-09-30 18:17:47 -0700 | [diff] [blame] | 7198 | } |
| 7199 | } |
Paul Soulos | 6b2dd63 | 2014-07-24 17:17:42 -0700 | [diff] [blame] | 7200 | |
| 7201 | /** |
| 7202 | * Return a {@link CharSequence} that best describes the given type, |
| 7203 | * possibly substituting the given {@link #LABEL} value |
| 7204 | * for {@link #TYPE_CUSTOM}. |
| 7205 | */ |
| 7206 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 7207 | CharSequence label) { |
| 7208 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 7209 | return label; |
| 7210 | } else { |
| 7211 | final int labelRes = getTypeResource(type); |
| 7212 | return res.getText(labelRes); |
| 7213 | } |
| 7214 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7215 | } |
| 7216 | |
| 7217 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7218 | * <p> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 7219 | * A data kind representing a photo for the contact. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7220 | * </p> |
| 7221 | * <p> |
| 7222 | * Some sync adapters will choose to download photos in a separate |
| 7223 | * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1} |
| 7224 | * through {@link ContactsContract.Data#SYNC4} to store temporary |
| 7225 | * data, e.g. the image URL or ID, state of download, server-side version |
| 7226 | * of the image. It is allowed for the {@link #PHOTO} to be null. |
| 7227 | * </p> |
| 7228 | * <p> |
| 7229 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7230 | * well as the following aliases. |
| 7231 | * </p> |
| 7232 | * <h2>Column aliases</h2> |
| 7233 | * <table class="jd-sumtable"> |
| 7234 | * <tr> |
| 7235 | * <th>Type</th> |
| 7236 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7237 | * </tr> |
| 7238 | * <tr> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 7239 | * <td>NUMBER</td> |
| 7240 | * <td>{@link #PHOTO_FILE_ID}</td> |
| 7241 | * <td>{@link #DATA14}</td> |
| 7242 | * <td>ID of the hi-res photo file.</td> |
| 7243 | * </tr> |
| 7244 | * <tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7245 | * <td>BLOB</td> |
| 7246 | * <td>{@link #PHOTO}</td> |
| 7247 | * <td>{@link #DATA15}</td> |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 7248 | * <td>By convention, binary data is stored in DATA15. The thumbnail of the |
| 7249 | * photo is stored in this column.</td> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7250 | * </tr> |
| 7251 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7252 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7253 | public static final class Photo implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7254 | /** |
| 7255 | * This utility class cannot be instantiated |
| 7256 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7257 | private Photo() {} |
| 7258 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7259 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7260 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; |
| 7261 | |
| 7262 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 7263 | * Photo file ID for the display photo of the raw contact. |
| 7264 | * See {@link ContactsContract.DisplayPhoto}. |
| 7265 | * <p> |
| 7266 | * Type: NUMBER |
| 7267 | */ |
| 7268 | public static final String PHOTO_FILE_ID = DATA14; |
| 7269 | |
| 7270 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 7271 | * 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] | 7272 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7273 | * <p> |
| 7274 | * Type: BLOB |
| 7275 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7276 | public static final String PHOTO = DATA15; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7277 | } |
| 7278 | |
| 7279 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7280 | * <p> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7281 | * Notes about the contact. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7282 | * </p> |
| 7283 | * <p> |
| 7284 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7285 | * well as the following aliases. |
| 7286 | * </p> |
| 7287 | * <h2>Column aliases</h2> |
| 7288 | * <table class="jd-sumtable"> |
| 7289 | * <tr> |
| 7290 | * <th>Type</th> |
| 7291 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7292 | * </tr> |
| 7293 | * <tr> |
| 7294 | * <td>String</td> |
| 7295 | * <td>{@link #NOTE}</td> |
| 7296 | * <td>{@link #DATA1}</td> |
| 7297 | * <td></td> |
| 7298 | * </tr> |
| 7299 | * </table> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7300 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7301 | public static final class Note implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7302 | /** |
| 7303 | * This utility class cannot be instantiated |
| 7304 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7305 | private Note() {} |
| 7306 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7307 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7308 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; |
| 7309 | |
| 7310 | /** |
| 7311 | * The note text. |
| 7312 | * <P>Type: TEXT</P> |
| 7313 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7314 | public static final String NOTE = DATA1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 7315 | } |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 7316 | |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 7317 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7318 | * <p> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7319 | * Group Membership. |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7320 | * </p> |
| 7321 | * <p> |
| 7322 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7323 | * well as the following aliases. |
| 7324 | * </p> |
| 7325 | * <h2>Column aliases</h2> |
| 7326 | * <table class="jd-sumtable"> |
| 7327 | * <tr> |
| 7328 | * <th>Type</th> |
| 7329 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7330 | * </tr> |
| 7331 | * <tr> |
| 7332 | * <td>long</td> |
| 7333 | * <td>{@link #GROUP_ROW_ID}</td> |
| 7334 | * <td>{@link #DATA1}</td> |
| 7335 | * <td></td> |
| 7336 | * </tr> |
| 7337 | * <tr> |
| 7338 | * <td>String</td> |
| 7339 | * <td>{@link #GROUP_SOURCE_ID}</td> |
| 7340 | * <td>none</td> |
| 7341 | * <td> |
| 7342 | * <p> |
| 7343 | * The sourceid of the group that this group membership refers to. |
| 7344 | * Exactly one of this or {@link #GROUP_ROW_ID} must be set when |
| 7345 | * inserting a row. |
| 7346 | * </p> |
| 7347 | * <p> |
| 7348 | * If this field is specified, the provider will first try to |
| 7349 | * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group |
| 7350 | * is found, it will use the corresponding row id. If the group is not |
| 7351 | * found, it will create one. |
| 7352 | * </td> |
| 7353 | * </tr> |
| 7354 | * </table> |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7355 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7356 | public static final class GroupMembership implements DataColumnsWithJoins, ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7357 | /** |
| 7358 | * This utility class cannot be instantiated |
| 7359 | */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7360 | private GroupMembership() {} |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7361 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7362 | /** MIME type used when storing this in data table. */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7363 | public static final String CONTENT_ITEM_TYPE = |
| 7364 | "vnd.android.cursor.item/group_membership"; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7365 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7366 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 7367 | * The row id of the group that this group membership refers to. Exactly one of |
| 7368 | * 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] | 7369 | * <P>Type: INTEGER</P> |
| 7370 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7371 | public static final String GROUP_ROW_ID = DATA1; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7372 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7373 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 7374 | * The sourceid of the group that this group membership refers to. Exactly one of |
| 7375 | * 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] | 7376 | * <P>Type: TEXT</P> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7377 | */ |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 7378 | public static final String GROUP_SOURCE_ID = "group_sourceid"; |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 7379 | } |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7380 | |
| 7381 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7382 | * <p> |
| 7383 | * A data kind representing a website related to the contact. |
| 7384 | * </p> |
| 7385 | * <p> |
| 7386 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7387 | * well as the following aliases. |
| 7388 | * </p> |
| 7389 | * <h2>Column aliases</h2> |
| 7390 | * <table class="jd-sumtable"> |
| 7391 | * <tr> |
| 7392 | * <th>Type</th> |
| 7393 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7394 | * </tr> |
| 7395 | * <tr> |
| 7396 | * <td>String</td> |
| 7397 | * <td>{@link #URL}</td> |
| 7398 | * <td>{@link #DATA1}</td> |
| 7399 | * <td></td> |
| 7400 | * </tr> |
| 7401 | * <tr> |
| 7402 | * <td>int</td> |
| 7403 | * <td>{@link #TYPE}</td> |
| 7404 | * <td>{@link #DATA2}</td> |
| 7405 | * <td>Allowed values are: |
| 7406 | * <p> |
| 7407 | * <ul> |
| 7408 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 7409 | * <li>{@link #TYPE_HOMEPAGE}</li> |
| 7410 | * <li>{@link #TYPE_BLOG}</li> |
| 7411 | * <li>{@link #TYPE_PROFILE}</li> |
| 7412 | * <li>{@link #TYPE_HOME}</li> |
| 7413 | * <li>{@link #TYPE_WORK}</li> |
| 7414 | * <li>{@link #TYPE_FTP}</li> |
| 7415 | * <li>{@link #TYPE_OTHER}</li> |
| 7416 | * </ul> |
| 7417 | * </p> |
| 7418 | * </td> |
| 7419 | * </tr> |
| 7420 | * <tr> |
| 7421 | * <td>String</td> |
| 7422 | * <td>{@link #LABEL}</td> |
| 7423 | * <td>{@link #DATA3}</td> |
| 7424 | * <td></td> |
| 7425 | * </tr> |
| 7426 | * </table> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7427 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7428 | public static final class Website implements DataColumnsWithJoins, CommonColumns, |
| 7429 | ContactCounts { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 7430 | /** |
| 7431 | * This utility class cannot be instantiated |
| 7432 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7433 | private Website() {} |
| 7434 | |
| 7435 | /** MIME type used when storing this in data table. */ |
| 7436 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; |
| 7437 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 7438 | public static final int TYPE_HOMEPAGE = 1; |
| 7439 | public static final int TYPE_BLOG = 2; |
| 7440 | public static final int TYPE_PROFILE = 3; |
| 7441 | public static final int TYPE_HOME = 4; |
| 7442 | public static final int TYPE_WORK = 5; |
| 7443 | public static final int TYPE_FTP = 6; |
| 7444 | public static final int TYPE_OTHER = 7; |
| 7445 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7446 | /** |
| 7447 | * The website URL string. |
| 7448 | * <P>Type: TEXT</P> |
| 7449 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 7450 | public static final String URL = DATA; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7451 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7452 | |
| 7453 | /** |
| 7454 | * <p> |
| 7455 | * A data kind representing a SIP address for the contact. |
| 7456 | * </p> |
| 7457 | * <p> |
| 7458 | * You can use all columns defined for {@link ContactsContract.Data} as |
| 7459 | * well as the following aliases. |
| 7460 | * </p> |
| 7461 | * <h2>Column aliases</h2> |
| 7462 | * <table class="jd-sumtable"> |
| 7463 | * <tr> |
| 7464 | * <th>Type</th> |
| 7465 | * <th>Alias</th><th colspan='2'>Data column</th> |
| 7466 | * </tr> |
| 7467 | * <tr> |
| 7468 | * <td>String</td> |
| 7469 | * <td>{@link #SIP_ADDRESS}</td> |
| 7470 | * <td>{@link #DATA1}</td> |
| 7471 | * <td></td> |
| 7472 | * </tr> |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 7473 | * <tr> |
| 7474 | * <td>int</td> |
| 7475 | * <td>{@link #TYPE}</td> |
| 7476 | * <td>{@link #DATA2}</td> |
| 7477 | * <td>Allowed values are: |
| 7478 | * <p> |
| 7479 | * <ul> |
| 7480 | * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li> |
| 7481 | * <li>{@link #TYPE_HOME}</li> |
| 7482 | * <li>{@link #TYPE_WORK}</li> |
| 7483 | * <li>{@link #TYPE_OTHER}</li> |
| 7484 | * </ul> |
| 7485 | * </p> |
| 7486 | * </td> |
| 7487 | * </tr> |
| 7488 | * <tr> |
| 7489 | * <td>String</td> |
| 7490 | * <td>{@link #LABEL}</td> |
| 7491 | * <td>{@link #DATA3}</td> |
| 7492 | * <td></td> |
| 7493 | * </tr> |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7494 | * </table> |
| 7495 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7496 | public static final class SipAddress implements DataColumnsWithJoins, CommonColumns, |
| 7497 | ContactCounts { |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7498 | /** |
| 7499 | * This utility class cannot be instantiated |
| 7500 | */ |
| 7501 | private SipAddress() {} |
| 7502 | |
| 7503 | /** MIME type used when storing this in data table. */ |
| 7504 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address"; |
| 7505 | |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 7506 | public static final int TYPE_HOME = 1; |
| 7507 | public static final int TYPE_WORK = 2; |
| 7508 | public static final int TYPE_OTHER = 3; |
| 7509 | |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7510 | /** |
| 7511 | * The SIP address. |
| 7512 | * <P>Type: TEXT</P> |
| 7513 | */ |
| 7514 | public static final String SIP_ADDRESS = DATA1; |
David Brown | 747c615 | 2010-09-15 13:34:13 -0700 | [diff] [blame] | 7515 | // ...and TYPE and LABEL come from the CommonColumns interface. |
| 7516 | |
| 7517 | /** |
| 7518 | * Return the string resource that best describes the given |
| 7519 | * {@link #TYPE}. Will always return a valid resource. |
| 7520 | */ |
| 7521 | public static final int getTypeLabelResource(int type) { |
| 7522 | switch (type) { |
| 7523 | case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome; |
| 7524 | case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork; |
| 7525 | case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther; |
| 7526 | default: return com.android.internal.R.string.sipAddressTypeCustom; |
| 7527 | } |
| 7528 | } |
| 7529 | |
| 7530 | /** |
| 7531 | * Return a {@link CharSequence} that best describes the given type, |
| 7532 | * possibly substituting the given {@link #LABEL} value |
| 7533 | * for {@link #TYPE_CUSTOM}. |
| 7534 | */ |
| 7535 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 7536 | CharSequence label) { |
| 7537 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 7538 | return label; |
| 7539 | } else { |
| 7540 | final int labelRes = getTypeLabelResource(type); |
| 7541 | return res.getText(labelRes); |
| 7542 | } |
| 7543 | } |
David Brown | 846eb30 | 2010-08-23 17:40:51 -0700 | [diff] [blame] | 7544 | } |
Fred Quintana | 4923f1d | 2011-08-05 15:58:17 -0700 | [diff] [blame] | 7545 | |
| 7546 | /** |
| 7547 | * A data kind representing an Identity related to the contact. |
| 7548 | * <p> |
| 7549 | * This can be used as a signal by the aggregator to combine raw contacts into |
| 7550 | * contacts, e.g. if two contacts have Identity rows with |
| 7551 | * the same NAMESPACE and IDENTITY values the aggregator can know that they refer |
| 7552 | * to the same person. |
| 7553 | * </p> |
| 7554 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7555 | public static final class Identity implements DataColumnsWithJoins, ContactCounts { |
Fred Quintana | 4923f1d | 2011-08-05 15:58:17 -0700 | [diff] [blame] | 7556 | /** |
| 7557 | * This utility class cannot be instantiated |
| 7558 | */ |
| 7559 | private Identity() {} |
| 7560 | |
| 7561 | /** MIME type used when storing this in data table. */ |
| 7562 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity"; |
| 7563 | |
| 7564 | /** |
| 7565 | * The identity string. |
| 7566 | * <P>Type: TEXT</P> |
| 7567 | */ |
| 7568 | public static final String IDENTITY = DataColumns.DATA1; |
| 7569 | |
| 7570 | /** |
| 7571 | * The namespace of the identity string, e.g. "com.google" |
| 7572 | * <P>Type: TEXT</P> |
| 7573 | */ |
| 7574 | public static final String NAMESPACE = DataColumns.DATA2; |
| 7575 | } |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7576 | |
| 7577 | /** |
| 7578 | * <p> |
| 7579 | * Convenient functionalities for "callable" data. Note that, this is NOT a separate data |
| 7580 | * kind. |
| 7581 | * </p> |
| 7582 | * <p> |
| 7583 | * This URI allows the ContactsProvider to return a unified result for "callable" data |
| 7584 | * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the |
| 7585 | * current examples for "callable", but may be expanded to the other types. |
| 7586 | * </p> |
| 7587 | * <p> |
| 7588 | * Each returned row may have a different MIMETYPE and thus different interpretation for |
| 7589 | * each column. For example the meaning for {@link Phone}'s type is different than |
| 7590 | * {@link SipAddress}'s. |
| 7591 | * </p> |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7592 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7593 | public static final class Callable implements DataColumnsWithJoins, CommonColumns, |
| 7594 | ContactCounts { |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7595 | /** |
| 7596 | * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only |
| 7597 | * phone numbers. |
| 7598 | */ |
| 7599 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 7600 | "callables"); |
| 7601 | /** |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 7602 | * <p>Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7603 | * data. |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 7604 | * |
| 7605 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer |
| 7606 | * sorts results based on contacts frequency. For more information, see the |
| 7607 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 7608 | * page. |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7609 | */ |
| 7610 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 7611 | "filter"); |
Victor Chang | 3d47ceb | 2015-12-01 16:30:43 +0000 | [diff] [blame] | 7612 | |
| 7613 | /** |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 7614 | * <p>Similar to {@link Phone#ENTERPRISE_CONTENT_FILTER_URI}, but allows users to filter |
Victor Chang | 3d47ceb | 2015-12-01 16:30:43 +0000 | [diff] [blame] | 7615 | * callable data. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in |
Ricky Wai | 149a6c9 | 2016-04-25 12:14:53 +0100 | [diff] [blame] | 7616 | * parameters, otherwise it will throw IllegalArgumentException. |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 7617 | * |
| 7618 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer |
| 7619 | * sorts results based on contacts frequency. For more information, see the |
| 7620 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 7621 | * page.</p> |
Victor Chang | 3d47ceb | 2015-12-01 16:30:43 +0000 | [diff] [blame] | 7622 | */ |
| 7623 | public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 7624 | CONTENT_URI, "filter_enterprise"); |
Daisuke Miyakawa | 3d340e7 | 2011-10-23 10:46:30 -0700 | [diff] [blame] | 7625 | } |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 7626 | |
| 7627 | /** |
| 7628 | * A special class of data items, used to refer to types of data that can be used to attempt |
| 7629 | * to start communicating with a person ({@link Phone} and {@link Email}). Note that this |
| 7630 | * is NOT a separate data kind. |
| 7631 | * |
| 7632 | * This URI allows the ContactsProvider to return a unified result for data items that users |
| 7633 | * can use to initiate communications with another contact. {@link Phone} and {@link Email} |
| 7634 | * are the current data types in this category. |
| 7635 | */ |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 7636 | public static final class Contactables implements DataColumnsWithJoins, CommonColumns, |
| 7637 | ContactCounts { |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 7638 | /** |
| 7639 | * The content:// style URI for these data items, which requests a directory of data |
| 7640 | * rows matching the selection criteria. |
| 7641 | */ |
| 7642 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 7643 | "contactables"); |
| 7644 | |
| 7645 | /** |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 7646 | * <p>The content:// style URI for these data items, which allows for a query parameter |
| 7647 | * to be appended onto the end to filter for data items matching the query. |
| 7648 | * |
| 7649 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer |
| 7650 | * sorts results based on contacts frequency. For more information, see the |
| 7651 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 7652 | * page. |
Yorke Lee | 4f401eb | 2013-03-06 17:17:17 -0800 | [diff] [blame] | 7653 | */ |
| 7654 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 7655 | Contactables.CONTENT_URI, "filter"); |
| 7656 | |
| 7657 | /** |
| 7658 | * A boolean parameter for {@link Data#CONTENT_URI}. |
| 7659 | * This specifies whether or not the returned data items should be filtered to show |
| 7660 | * data items belonging to visible contacts only. |
| 7661 | */ |
| 7662 | public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only"; |
| 7663 | } |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 7664 | } |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7665 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7666 | /** |
| 7667 | * @see Groups |
| 7668 | */ |
Dmitri Plotnikov | 6e144ad | 2009-10-13 18:08:25 -0700 | [diff] [blame] | 7669 | protected interface GroupsColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7670 | /** |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 7671 | * The data set within the account that this group belongs to. This allows |
| 7672 | * multiple sync adapters for the same account type to distinguish between |
| 7673 | * each others' group data. |
| 7674 | * |
| 7675 | * This is empty by default, and is completely optional. It only needs to |
| 7676 | * be populated if multiple sync adapters are entering distinct group data |
| 7677 | * for the same account type and account name. |
| 7678 | * <P>Type: TEXT</P> |
| 7679 | */ |
| 7680 | public static final String DATA_SET = "data_set"; |
| 7681 | |
| 7682 | /** |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 7683 | * A concatenation of the account type and data set (delimited by a forward |
| 7684 | * slash) - if the data set is empty, this will be the same as the account |
| 7685 | * type. For applications that need to be aware of the data set, this can |
| 7686 | * be used instead of account type to distinguish sets of data. This is |
| 7687 | * never intended to be used for specifying accounts. |
| 7688 | * @hide |
| 7689 | */ |
| 7690 | public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; |
| 7691 | |
| 7692 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7693 | * The display title of this group. |
| 7694 | * <p> |
| 7695 | * Type: TEXT |
| 7696 | */ |
| 7697 | public static final String TITLE = "title"; |
| 7698 | |
| 7699 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7700 | * The package name to use when creating {@link Resources} objects for |
| 7701 | * this group. This value is only designed for use when building user |
| 7702 | * interfaces, and should not be used to infer the owner. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7703 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7704 | public static final String RES_PACKAGE = "res_package"; |
| 7705 | |
| 7706 | /** |
| 7707 | * The display title of this group to load as a resource from |
| 7708 | * {@link #RES_PACKAGE}, which may be localized. |
| 7709 | * <P>Type: TEXT</P> |
| 7710 | */ |
| 7711 | public static final String TITLE_RES = "title_res"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7712 | |
| 7713 | /** |
Dmitri Plotnikov | 02c5b45 | 2009-07-22 15:13:08 -0700 | [diff] [blame] | 7714 | * Notes about the group. |
| 7715 | * <p> |
| 7716 | * Type: TEXT |
| 7717 | */ |
| 7718 | public static final String NOTES = "notes"; |
| 7719 | |
| 7720 | /** |
| 7721 | * The ID of this group if it is a System Group, i.e. a group that has a special meaning |
| 7722 | * to the sync adapter, null otherwise. |
| 7723 | * <P>Type: TEXT</P> |
| 7724 | */ |
| 7725 | public static final String SYSTEM_ID = "system_id"; |
| 7726 | |
| 7727 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7728 | * The total number of {@link Contacts} that have |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7729 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7730 | * present when querying {@link Groups#CONTENT_SUMMARY_URI}. |
| 7731 | * <p> |
| 7732 | * Type: INTEGER |
| 7733 | */ |
| 7734 | public static final String SUMMARY_COUNT = "summ_count"; |
| 7735 | |
| 7736 | /** |
Daisuke Miyakawa | 15dec39 | 2011-07-23 11:39:23 -0700 | [diff] [blame] | 7737 | * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}. |
| 7738 | * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}. |
| 7739 | * |
| 7740 | * @hide |
| 7741 | */ |
| 7742 | public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT = |
| 7743 | "return_group_count_per_account"; |
| 7744 | |
| 7745 | /** |
| 7746 | * The total number of groups of the account that a group belongs to. |
| 7747 | * This column is available only when the parameter |
| 7748 | * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in |
| 7749 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 7750 | * |
| 7751 | * For example, when the account "A" has two groups "group1" and "group2", and the account |
| 7752 | * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for |
| 7753 | * "group3" returns "1" for this column. |
| 7754 | * |
| 7755 | * Note: This counts only non-favorites, non-auto-add, and not deleted groups. |
| 7756 | * |
| 7757 | * Type: INTEGER |
| 7758 | * @hide |
| 7759 | */ |
| 7760 | public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account"; |
| 7761 | |
| 7762 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 7763 | * The total number of {@link Contacts} that have both |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 7764 | * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7765 | * Read-only value that is only present when querying |
| 7766 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 7767 | * <p> |
| 7768 | * Type: INTEGER |
| 7769 | */ |
| 7770 | public static final String SUMMARY_WITH_PHONES = "summ_phones"; |
| 7771 | |
| 7772 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7773 | * Flag indicating if the contacts belonging to this group should be |
| 7774 | * visible in any user interface. |
| 7775 | * <p> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 7776 | * Type: INTEGER (boolean) |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7777 | */ |
| 7778 | public static final String GROUP_VISIBLE = "group_visible"; |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 7779 | |
| 7780 | /** |
| 7781 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 7782 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7783 | * called on a group, it is marked for deletion. The sync adaptor |
| 7784 | * deletes the group on the server and then calls ContactResolver.delete |
| 7785 | * once more, this time setting the the |
| 7786 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to |
| 7787 | * finalize the data removal. |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 7788 | * <P>Type: INTEGER</P> |
| 7789 | */ |
| 7790 | public static final String DELETED = "deleted"; |
Jeff Sharkey | 403d7ac | 2009-08-16 16:34:35 -0700 | [diff] [blame] | 7791 | |
| 7792 | /** |
| 7793 | * Whether this group should be synced if the SYNC_EVERYTHING settings |
| 7794 | * is false for this group's account. |
| 7795 | * <p> |
| 7796 | * Type: INTEGER (boolean) |
| 7797 | */ |
| 7798 | public static final String SHOULD_SYNC = "should_sync"; |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 7799 | |
| 7800 | /** |
| 7801 | * Any newly created contacts will automatically be added to groups that have this |
| 7802 | * flag set to true. |
| 7803 | * <p> |
| 7804 | * Type: INTEGER (boolean) |
| 7805 | */ |
| 7806 | public static final String AUTO_ADD = "auto_add"; |
| 7807 | |
| 7808 | /** |
| 7809 | * When a contacts is marked as a favorites it will be automatically added |
| 7810 | * to the groups that have this flag set, and when it is removed from favorites |
| 7811 | * it will be removed from these groups. |
| 7812 | * <p> |
| 7813 | * Type: INTEGER (boolean) |
| 7814 | */ |
| 7815 | public static final String FAVORITES = "favorites"; |
Dmitri Plotnikov | 4ccf33a | 2010-11-19 11:10:43 -0800 | [diff] [blame] | 7816 | |
| 7817 | /** |
| 7818 | * The "read-only" flag: "0" by default, "1" if the row cannot be modified or |
| 7819 | * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}. |
| 7820 | * <P>Type: INTEGER</P> |
| 7821 | */ |
| 7822 | public static final String GROUP_IS_READ_ONLY = "group_is_read_only"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7823 | } |
| 7824 | |
| 7825 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7826 | * Constants for the groups table. Only per-account groups are supported. |
| 7827 | * <h2>Columns</h2> |
| 7828 | * <table class="jd-sumtable"> |
| 7829 | * <tr> |
| 7830 | * <th colspan='4'>Groups</th> |
| 7831 | * </tr> |
| 7832 | * <tr> |
| 7833 | * <td>long</td> |
| 7834 | * <td>{@link #_ID}</td> |
| 7835 | * <td>read-only</td> |
| 7836 | * <td>Row ID. Sync adapter should try to preserve row IDs during updates. |
| 7837 | * In other words, it would be a really bad idea to delete and reinsert a |
| 7838 | * group. A sync adapter should always do an update instead.</td> |
| 7839 | * </tr> |
Dave Santoro | d7bdc18 | 2011-06-24 15:39:39 -0700 | [diff] [blame] | 7840 | # <tr> |
| 7841 | * <td>String</td> |
| 7842 | * <td>{@link #DATA_SET}</td> |
| 7843 | * <td>read/write-once</td> |
| 7844 | * <td> |
| 7845 | * <p> |
| 7846 | * The data set within the account that this group belongs to. This allows |
| 7847 | * multiple sync adapters for the same account type to distinguish between |
| 7848 | * each others' group data. The combination of {@link #ACCOUNT_TYPE}, |
| 7849 | * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data |
| 7850 | * that is associated with a single sync adapter. |
| 7851 | * </p> |
| 7852 | * <p> |
| 7853 | * This is empty by default, and is completely optional. It only needs to |
| 7854 | * be populated if multiple sync adapters are entering distinct data for |
| 7855 | * the same account type and account name. |
| 7856 | * </p> |
| 7857 | * <p> |
| 7858 | * It should be set at the time the group is inserted and never changed |
| 7859 | * afterwards. |
| 7860 | * </p> |
| 7861 | * </td> |
| 7862 | * </tr> |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7863 | * <tr> |
| 7864 | * <td>String</td> |
| 7865 | * <td>{@link #TITLE}</td> |
| 7866 | * <td>read/write</td> |
| 7867 | * <td>The display title of this group.</td> |
| 7868 | * </tr> |
| 7869 | * <tr> |
| 7870 | * <td>String</td> |
| 7871 | * <td>{@link #NOTES}</td> |
| 7872 | * <td>read/write</td> |
| 7873 | * <td>Notes about the group.</td> |
| 7874 | * </tr> |
| 7875 | * <tr> |
| 7876 | * <td>String</td> |
| 7877 | * <td>{@link #SYSTEM_ID}</td> |
| 7878 | * <td>read/write</td> |
| 7879 | * <td>The ID of this group if it is a System Group, i.e. a group that has a |
| 7880 | * special meaning to the sync adapter, null otherwise.</td> |
| 7881 | * </tr> |
| 7882 | * <tr> |
| 7883 | * <td>int</td> |
| 7884 | * <td>{@link #SUMMARY_COUNT}</td> |
| 7885 | * <td>read-only</td> |
| 7886 | * <td>The total number of {@link Contacts} that have |
| 7887 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value |
| 7888 | * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 7889 | * </tr> |
| 7890 | * <tr> |
| 7891 | * <td>int</td> |
| 7892 | * <td>{@link #SUMMARY_WITH_PHONES}</td> |
| 7893 | * <td>read-only</td> |
| 7894 | * <td>The total number of {@link Contacts} that have both |
| 7895 | * {@link CommonDataKinds.GroupMembership} in this group, and also have |
| 7896 | * phone numbers. Read-only value that is only present when querying |
| 7897 | * {@link Groups#CONTENT_SUMMARY_URI}.</td> |
| 7898 | * </tr> |
| 7899 | * <tr> |
| 7900 | * <td>int</td> |
| 7901 | * <td>{@link #GROUP_VISIBLE}</td> |
| 7902 | * <td>read-only</td> |
| 7903 | * <td>Flag indicating if the contacts belonging to this group should be |
| 7904 | * visible in any user interface. Allowed values: 0 and 1.</td> |
| 7905 | * </tr> |
| 7906 | * <tr> |
| 7907 | * <td>int</td> |
| 7908 | * <td>{@link #DELETED}</td> |
| 7909 | * <td>read/write</td> |
| 7910 | * <td>The "deleted" flag: "0" by default, "1" if the row has been marked |
| 7911 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 7912 | * called on a group, it is marked for deletion. The sync adaptor deletes |
| 7913 | * the group on the server and then calls ContactResolver.delete once more, |
| 7914 | * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER} |
| 7915 | * query parameter to finalize the data removal.</td> |
| 7916 | * </tr> |
| 7917 | * <tr> |
| 7918 | * <td>int</td> |
| 7919 | * <td>{@link #SHOULD_SYNC}</td> |
| 7920 | * <td>read/write</td> |
| 7921 | * <td>Whether this group should be synced if the SYNC_EVERYTHING settings |
| 7922 | * is false for this group's account.</td> |
| 7923 | * </tr> |
| 7924 | * </table> |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7925 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7926 | public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7927 | /** |
| 7928 | * This utility class cannot be instantiated |
| 7929 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 7930 | private Groups() { |
| 7931 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7932 | |
| 7933 | /** |
| 7934 | * The content:// style URI for this table |
| 7935 | */ |
| 7936 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); |
| 7937 | |
| 7938 | /** |
| 7939 | * The content:// style URI for this table joined with details data from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7940 | * {@link ContactsContract.Data}. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7941 | */ |
| 7942 | public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 7943 | "groups_summary"); |
| 7944 | |
| 7945 | /** |
| 7946 | * The MIME type of a directory of groups. |
| 7947 | */ |
| 7948 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; |
| 7949 | |
| 7950 | /** |
| 7951 | * The MIME type of a single group. |
| 7952 | */ |
| 7953 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7954 | |
| 7955 | public static EntityIterator newEntityIterator(Cursor cursor) { |
| 7956 | return new EntityIteratorImpl(cursor); |
| 7957 | } |
| 7958 | |
| 7959 | private static class EntityIteratorImpl extends CursorEntityIterator { |
| 7960 | public EntityIteratorImpl(Cursor cursor) { |
| 7961 | super(cursor); |
| 7962 | } |
| 7963 | |
Dmitri Plotnikov | b4413fa | 2009-12-17 20:05:50 -0800 | [diff] [blame] | 7964 | @Override |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7965 | public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { |
| 7966 | // we expect the cursor is already at the row we need to read from |
| 7967 | final ContentValues values = new ContentValues(); |
| 7968 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID); |
| 7969 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME); |
| 7970 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE); |
| 7971 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY); |
| 7972 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION); |
| 7973 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID); |
| 7974 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE); |
| 7975 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE); |
| 7976 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES); |
| 7977 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE); |
| 7978 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1); |
| 7979 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2); |
| 7980 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3); |
| 7981 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4); |
| 7982 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID); |
| 7983 | DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED); |
| 7984 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES); |
| 7985 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC); |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 7986 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES); |
| 7987 | DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD); |
Fred Quintana | 328c0e7 | 2009-12-07 14:52:28 -0800 | [diff] [blame] | 7988 | cursor.moveToNext(); |
| 7989 | return new Entity(values); |
| 7990 | } |
| 7991 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 7992 | } |
| 7993 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7994 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7995 | * <p> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 7996 | * Constants for the contact aggregation exceptions table, which contains |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 7997 | * aggregation rules overriding those used by automatic aggregation. This |
| 7998 | * type only supports query and update. Neither insert nor delete are |
| 7999 | * supported. |
| 8000 | * </p> |
| 8001 | * <h2>Columns</h2> |
| 8002 | * <table class="jd-sumtable"> |
| 8003 | * <tr> |
| 8004 | * <th colspan='4'>AggregationExceptions</th> |
| 8005 | * </tr> |
| 8006 | * <tr> |
| 8007 | * <td>int</td> |
| 8008 | * <td>{@link #TYPE}</td> |
| 8009 | * <td>read/write</td> |
| 8010 | * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER}, |
| 8011 | * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td> |
| 8012 | * </tr> |
| 8013 | * <tr> |
| 8014 | * <td>long</td> |
| 8015 | * <td>{@link #RAW_CONTACT_ID1}</td> |
| 8016 | * <td>read/write</td> |
| 8017 | * <td>A reference to the {@link RawContacts#_ID} of the raw contact that |
| 8018 | * the rule applies to.</td> |
| 8019 | * </tr> |
| 8020 | * <tr> |
| 8021 | * <td>long</td> |
| 8022 | * <td>{@link #RAW_CONTACT_ID2}</td> |
| 8023 | * <td>read/write</td> |
| 8024 | * <td>A reference to the other {@link RawContacts#_ID} of the raw contact |
| 8025 | * that the rule applies to.</td> |
| 8026 | * </tr> |
| 8027 | * </table> |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8028 | */ |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 8029 | public static final class AggregationExceptions implements BaseColumns { |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8030 | /** |
| 8031 | * This utility class cannot be instantiated |
| 8032 | */ |
| 8033 | private AggregationExceptions() {} |
| 8034 | |
| 8035 | /** |
| 8036 | * The content:// style URI for this table |
| 8037 | */ |
| 8038 | public static final Uri CONTENT_URI = |
| 8039 | Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); |
| 8040 | |
| 8041 | /** |
| 8042 | * The MIME type of {@link #CONTENT_URI} providing a directory of data. |
| 8043 | */ |
| 8044 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; |
| 8045 | |
| 8046 | /** |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 8047 | * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception |
| 8048 | */ |
| 8049 | public static final String CONTENT_ITEM_TYPE = |
| 8050 | "vnd.android.cursor.item/aggregation_exception"; |
| 8051 | |
| 8052 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8053 | * 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] | 8054 | * {@link #TYPE_AUTOMATIC}. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8055 | * |
| 8056 | * <P>Type: INTEGER</P> |
| 8057 | */ |
| 8058 | public static final String TYPE = "type"; |
| 8059 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8060 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8061 | * Allows the provider to automatically decide whether the specified raw contacts should |
| 8062 | * be included in the same aggregate contact or not. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8063 | */ |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 8064 | public static final int TYPE_AUTOMATIC = 0; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8065 | |
| 8066 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8067 | * Makes sure that the specified raw contacts are included in the same |
| 8068 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 8069 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8070 | public static final int TYPE_KEEP_TOGETHER = 1; |
| 8071 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 8072 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8073 | * Makes sure that the specified raw contacts are NOT included in the same |
| 8074 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 8075 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8076 | public static final int TYPE_KEEP_SEPARATE = 2; |
| 8077 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 8078 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 8079 | * 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] | 8080 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 8081 | public static final String RAW_CONTACT_ID1 = "raw_contact_id1"; |
| 8082 | |
| 8083 | /** |
| 8084 | * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule |
| 8085 | * applies to. |
| 8086 | */ |
| 8087 | public static final String RAW_CONTACT_ID2 = "raw_contact_id2"; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 8088 | } |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 8089 | |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8090 | /** |
| 8091 | * @see Settings |
| 8092 | */ |
Dmitri Plotnikov | fe4c871 | 2009-10-14 00:28:48 -0700 | [diff] [blame] | 8093 | protected interface SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8094 | /** |
| 8095 | * The name of the account instance to which this row belongs. |
| 8096 | * <P>Type: TEXT</P> |
| 8097 | */ |
| 8098 | public static final String ACCOUNT_NAME = "account_name"; |
| 8099 | |
| 8100 | /** |
| 8101 | * The type of account to which this row belongs, which when paired with |
| 8102 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 8103 | * <P>Type: TEXT</P> |
| 8104 | */ |
| 8105 | public static final String ACCOUNT_TYPE = "account_type"; |
| 8106 | |
| 8107 | /** |
Dave Santoro | 7c4479f | 2011-09-07 16:52:27 -0700 | [diff] [blame] | 8108 | * The data set within the account that this row belongs to. This allows |
| 8109 | * multiple sync adapters for the same account type to distinguish between |
| 8110 | * each others' data. |
| 8111 | * |
| 8112 | * This is empty by default, and is completely optional. It only needs to |
| 8113 | * be populated if multiple sync adapters are entering distinct data for |
| 8114 | * the same account type and account name. |
| 8115 | * <P>Type: TEXT</P> |
| 8116 | */ |
| 8117 | public static final String DATA_SET = "data_set"; |
| 8118 | |
| 8119 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8120 | * Depending on the mode defined by the sync-adapter, this flag controls |
| 8121 | * the top-level sync behavior for this data source. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8122 | * <p> |
| 8123 | * Type: INTEGER (boolean) |
| 8124 | */ |
| 8125 | public static final String SHOULD_SYNC = "should_sync"; |
| 8126 | |
| 8127 | /** |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 8128 | * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership} |
Jeff Sharkey | a659744 | 2009-08-19 09:23:33 -0700 | [diff] [blame] | 8129 | * entries should be visible in any user interface. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8130 | * <p> |
| 8131 | * Type: INTEGER (boolean) |
| 8132 | */ |
| 8133 | public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8134 | |
| 8135 | /** |
Jeff Sharkey | 97bda4c | 2009-09-15 23:15:23 -0700 | [diff] [blame] | 8136 | * Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 8137 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 8138 | * unsynced. |
| 8139 | */ |
| 8140 | public static final String ANY_UNSYNCED = "any_unsynced"; |
| 8141 | |
| 8142 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8143 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 8144 | * no {@link CommonDataKinds.GroupMembership} entries. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8145 | * <p> |
| 8146 | * Type: INTEGER |
| 8147 | */ |
| 8148 | public static final String UNGROUPED_COUNT = "summ_count"; |
| 8149 | |
| 8150 | /** |
| 8151 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 8152 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8153 | * <p> |
| 8154 | * Type: INTEGER |
| 8155 | */ |
| 8156 | public static final String UNGROUPED_WITH_PHONES = "summ_phones"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8157 | } |
| 8158 | |
| 8159 | /** |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8160 | * <p> |
| 8161 | * Contacts-specific settings for various {@link Account}'s. |
| 8162 | * </p> |
| 8163 | * <h2>Columns</h2> |
| 8164 | * <table class="jd-sumtable"> |
| 8165 | * <tr> |
| 8166 | * <th colspan='4'>Settings</th> |
| 8167 | * </tr> |
| 8168 | * <tr> |
| 8169 | * <td>String</td> |
| 8170 | * <td>{@link #ACCOUNT_NAME}</td> |
| 8171 | * <td>read/write-once</td> |
| 8172 | * <td>The name of the account instance to which this row belongs.</td> |
| 8173 | * </tr> |
| 8174 | * <tr> |
| 8175 | * <td>String</td> |
| 8176 | * <td>{@link #ACCOUNT_TYPE}</td> |
| 8177 | * <td>read/write-once</td> |
| 8178 | * <td>The type of account to which this row belongs, which when paired with |
| 8179 | * {@link #ACCOUNT_NAME} identifies a specific account.</td> |
| 8180 | * </tr> |
| 8181 | * <tr> |
| 8182 | * <td>int</td> |
| 8183 | * <td>{@link #SHOULD_SYNC}</td> |
| 8184 | * <td>read/write</td> |
| 8185 | * <td>Depending on the mode defined by the sync-adapter, this flag controls |
| 8186 | * the top-level sync behavior for this data source.</td> |
| 8187 | * </tr> |
| 8188 | * <tr> |
| 8189 | * <td>int</td> |
| 8190 | * <td>{@link #UNGROUPED_VISIBLE}</td> |
| 8191 | * <td>read/write</td> |
| 8192 | * <td>Flag indicating if contacts without any |
| 8193 | * {@link CommonDataKinds.GroupMembership} entries should be visible in any |
| 8194 | * user interface.</td> |
| 8195 | * </tr> |
| 8196 | * <tr> |
| 8197 | * <td>int</td> |
| 8198 | * <td>{@link #ANY_UNSYNCED}</td> |
| 8199 | * <td>read-only</td> |
| 8200 | * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 8201 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 8202 | * unsynced.</td> |
| 8203 | * </tr> |
| 8204 | * <tr> |
| 8205 | * <td>int</td> |
| 8206 | * <td>{@link #UNGROUPED_COUNT}</td> |
| 8207 | * <td>read-only</td> |
| 8208 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 8209 | * no {@link CommonDataKinds.GroupMembership} entries.</td> |
| 8210 | * </tr> |
| 8211 | * <tr> |
| 8212 | * <td>int</td> |
| 8213 | * <td>{@link #UNGROUPED_WITH_PHONES}</td> |
| 8214 | * <td>read-only</td> |
| 8215 | * <td>Read-only count of {@link Contacts} from a specific source that have |
| 8216 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone |
| 8217 | * numbers.</td> |
| 8218 | * </tr> |
| 8219 | * </table> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8220 | */ |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 8221 | public static final class Settings implements SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8222 | /** |
| 8223 | * This utility class cannot be instantiated |
| 8224 | */ |
| 8225 | private Settings() { |
| 8226 | } |
| 8227 | |
| 8228 | /** |
| 8229 | * The content:// style URI for this table |
| 8230 | */ |
| 8231 | public static final Uri CONTENT_URI = |
| 8232 | Uri.withAppendedPath(AUTHORITY_URI, "settings"); |
| 8233 | |
| 8234 | /** |
| 8235 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 8236 | * settings. |
| 8237 | */ |
| 8238 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; |
| 8239 | |
| 8240 | /** |
| 8241 | * The MIME-type of {@link #CONTENT_URI} providing a single setting. |
| 8242 | */ |
| 8243 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 8244 | } |
| 8245 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8246 | /** |
Brian Attwell | cc4b2f7 | 2015-01-08 14:58:15 -0800 | [diff] [blame] | 8247 | * API for inquiring about the general status of the provider. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8248 | */ |
| 8249 | public static final class ProviderStatus { |
| 8250 | |
| 8251 | /** |
| 8252 | * Not instantiable. |
| 8253 | */ |
| 8254 | private ProviderStatus() { |
| 8255 | } |
| 8256 | |
| 8257 | /** |
| 8258 | * The content:// style URI for this table. Requests to this URI can be |
| 8259 | * performed on the UI thread because they are always unblocking. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8260 | */ |
| 8261 | public static final Uri CONTENT_URI = |
| 8262 | Uri.withAppendedPath(AUTHORITY_URI, "provider_status"); |
| 8263 | |
| 8264 | /** |
| 8265 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 8266 | * settings. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8267 | */ |
| 8268 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status"; |
| 8269 | |
| 8270 | /** |
| 8271 | * An integer representing the current status of the provider. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8272 | */ |
| 8273 | public static final String STATUS = "status"; |
| 8274 | |
| 8275 | /** |
| 8276 | * Default status of the provider. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8277 | */ |
| 8278 | public static final int STATUS_NORMAL = 0; |
| 8279 | |
| 8280 | /** |
Brian Attwell | b36ad5d | 2015-05-28 19:25:21 -0700 | [diff] [blame] | 8281 | * The provider won't respond to queries. It is in the middle of a long running task, such |
| 8282 | * as a database upgrade or locale change. |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8283 | */ |
Brian Attwell | b36ad5d | 2015-05-28 19:25:21 -0700 | [diff] [blame] | 8284 | public static final int STATUS_BUSY = 1; |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8285 | |
| 8286 | /** |
Dmitri Plotnikov | 37c3486 | 2010-11-12 16:12:53 -0800 | [diff] [blame] | 8287 | * The status that indicates that there are no accounts and no contacts |
| 8288 | * on the device. |
Dmitri Plotnikov | 37c3486 | 2010-11-12 16:12:53 -0800 | [diff] [blame] | 8289 | */ |
Brian Attwell | b36ad5d | 2015-05-28 19:25:21 -0700 | [diff] [blame] | 8290 | public static final int STATUS_EMPTY = 2; |
Makoto Onuki | 729a87b | 2017-01-11 13:40:06 -0800 | [diff] [blame] | 8291 | |
| 8292 | /** |
| 8293 | * Timestamp (milliseconds since epoch) of when the provider's database was created. |
| 8294 | * |
| 8295 | * <P>Type: long |
| 8296 | */ |
| 8297 | public static final String DATABASE_CREATION_TIMESTAMP = "database_creation_timestamp"; |
Dmitri Plotnikov | 4a8a310 | 2010-03-08 19:40:19 -0800 | [diff] [blame] | 8298 | } |
| 8299 | |
| 8300 | /** |
Kevin Hufnagle | 94b9e05 | 2018-10-01 07:04:44 -0700 | [diff] [blame] | 8301 | * <p class="caution"><b>Caution: </b>As of January 7, 2019, this class is obsolete. For |
| 8302 | * more information, see the |
| 8303 | * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a> |
| 8304 | * page. |
| 8305 | * </p> |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8306 | * <p> |
| 8307 | * 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] | 8308 | * Contacts Provider. Applications can also clear all usage information. |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8309 | * </p> |
| 8310 | * <p> |
| 8311 | * With the feedback, Contacts Provider may return more contextually appropriate results for |
| 8312 | * Data listing, typically supplied with |
| 8313 | * {@link ContactsContract.Contacts#CONTENT_FILTER_URI}, |
| 8314 | * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI}, |
| 8315 | * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit |
| 8316 | * from better ranked (sorted) lists in applications that show auto-complete list. |
| 8317 | * </p> |
| 8318 | * <p> |
| 8319 | * There is no guarantee for how this feedback is used, or even whether it is used at all. |
| 8320 | * The ranking algorithm will make best efforts to use the feedback data, but the exact |
| 8321 | * implementation, the storage data structures as well as the resulting sort order is device |
| 8322 | * and version specific and can change over time. |
| 8323 | * </p> |
| 8324 | * <p> |
| 8325 | * When updating usage information, users of this API need to use |
| 8326 | * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed |
| 8327 | * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as |
| 8328 | * its last path. They also need to append a query parameter to the Uri, to specify the type of |
| 8329 | * the communication, which enables the Contacts Provider to differentiate between kinds of |
| 8330 | * interactions using the same contact data field (for example a phone number can be used to |
| 8331 | * make phone calls or send SMS). |
| 8332 | * </p> |
| 8333 | * <p> |
| 8334 | * Selection and selectionArgs are ignored and must be set to null. To get data ids, |
| 8335 | * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)} |
| 8336 | * toward {@link Data#CONTENT_URI}. |
| 8337 | * </p> |
| 8338 | * <p> |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 8339 | * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive |
| 8340 | * integer when successful, and returns 0 if no contact with that id was found. |
| 8341 | * </p> |
| 8342 | * <p> |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8343 | * Example: |
| 8344 | * <pre> |
Daisuke Miyakawa | 52e3823 | 2011-06-14 10:56:46 -0700 | [diff] [blame] | 8345 | * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon() |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8346 | * .appendPath(TextUtils.join(",", dataIds)) |
Daisuke Miyakawa | 52e3823 | 2011-06-14 10:56:46 -0700 | [diff] [blame] | 8347 | * .appendQueryParameter(DataUsageFeedback.USAGE_TYPE, |
| 8348 | * DataUsageFeedback.USAGE_TYPE_CALL) |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8349 | * .build(); |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 8350 | * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0; |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8351 | * </pre> |
| 8352 | * </p> |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 8353 | * <p> |
| 8354 | * Applications can also clear all usage information with: |
| 8355 | * <pre> |
Makoto Onuki | 7ebbfd0 | 2012-04-13 12:56:42 -0700 | [diff] [blame] | 8356 | * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0; |
Makoto Onuki | b0d2299 | 2012-04-12 17:09:58 -0700 | [diff] [blame] | 8357 | * </pre> |
| 8358 | * </p> |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 8359 | * |
| 8360 | * @deprecated Contacts affinity information is no longer supported as of |
| 8361 | * Android version {@link android.os.Build.VERSION_CODES#Q}. |
| 8362 | * Both update and delete calls are always ignored. |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8363 | */ |
Makoto Onuki | aa2dd62 | 2018-07-30 11:14:12 -0700 | [diff] [blame] | 8364 | @Deprecated |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8365 | public static final class DataUsageFeedback { |
| 8366 | |
| 8367 | /** |
| 8368 | * The content:// style URI for sending usage feedback. |
| 8369 | * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}. |
| 8370 | */ |
| 8371 | public static final Uri FEEDBACK_URI = |
| 8372 | Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback"); |
| 8373 | |
| 8374 | /** |
Makoto Onuki | 7ebbfd0 | 2012-04-13 12:56:42 -0700 | [diff] [blame] | 8375 | * The content:// style URI for deleting all usage information. |
| 8376 | * Must be used with {@link ContentResolver#delete(Uri, String, String[])}. |
| 8377 | * The {@code where} and {@code selectionArgs} parameters are ignored. |
| 8378 | */ |
| 8379 | public static final Uri DELETE_USAGE_URI = |
| 8380 | Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage"); |
| 8381 | |
| 8382 | /** |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8383 | * <p> |
| 8384 | * Name for query parameter specifying the type of data usage. |
| 8385 | * </p> |
| 8386 | */ |
Daisuke Miyakawa | 63b709d | 2011-06-09 11:00:19 -0700 | [diff] [blame] | 8387 | public static final String USAGE_TYPE = "type"; |
Daisuke Miyakawa | b2b651f | 2011-06-06 17:28:09 -0700 | [diff] [blame] | 8388 | |
| 8389 | /** |
| 8390 | * <p> |
| 8391 | * Type of usage for voice interaction, which includes phone call, voice chat, and |
| 8392 | * video chat. |
| 8393 | * </p> |
| 8394 | */ |
| 8395 | public static final String USAGE_TYPE_CALL = "call"; |
| 8396 | |
| 8397 | /** |
| 8398 | * <p> |
| 8399 | * Type of usage for text interaction involving longer messages, which includes email. |
| 8400 | * </p> |
| 8401 | */ |
| 8402 | public static final String USAGE_TYPE_LONG_TEXT = "long_text"; |
| 8403 | |
| 8404 | /** |
| 8405 | * <p> |
| 8406 | * Type of usage for text interaction involving shorter messages, which includes SMS, |
| 8407 | * text chat with email addresses. |
| 8408 | * </p> |
| 8409 | */ |
| 8410 | public static final String USAGE_TYPE_SHORT_TEXT = "short_text"; |
| 8411 | } |
| 8412 | |
| 8413 | /** |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8414 | * <p> |
Yorke Lee | cadbe4c | 2014-06-20 11:52:27 -0700 | [diff] [blame] | 8415 | * Contact-specific information about whether or not a contact has been pinned by the user |
| 8416 | * at a particular position within the system contact application's user interface. |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8417 | * </p> |
| 8418 | * |
| 8419 | * <p> |
| 8420 | * This pinning information can be used by individual applications to customize how |
| 8421 | * they order particular pinned contacts. For example, a Dialer application could |
| 8422 | * use pinned information to order user-pinned contacts in a top row of favorites. |
| 8423 | * </p> |
| 8424 | * |
| 8425 | * <p> |
| 8426 | * It is possible for two or more contacts to occupy the same pinned position (due |
| 8427 | * to aggregation and sync), so this pinning information should be used on a best-effort |
| 8428 | * basis to order contacts in-application rather than an absolute guide on where a contact |
| 8429 | * should be positioned. Contacts returned by the ContactsProvider will not be ordered based |
| 8430 | * on this information, so it is up to the client application to reorder these contacts within |
| 8431 | * their own UI adhering to (or ignoring as appropriate) information stored in the pinned |
| 8432 | * column. |
| 8433 | * </p> |
| 8434 | * |
| 8435 | * <p> |
| 8436 | * By default, unpinned contacts will have a pinned position of |
Yorke Lee | 7d24679 | 2014-07-25 10:05:55 -0700 | [diff] [blame] | 8437 | * {@link PinnedPositions#UNPINNED}. Client-provided pinned positions can be positive |
| 8438 | * integers that are greater than 1. |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8439 | * </p> |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8440 | */ |
| 8441 | public static final class PinnedPositions { |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8442 | /** |
Yorke Lee | 0e040b0 | 2014-06-18 15:02:44 -0700 | [diff] [blame] | 8443 | * The method to invoke in order to undemote a formerly demoted contact. The contact id of |
| 8444 | * the contact must be provided as an argument. If the contact was not previously demoted, |
| 8445 | * nothing will be done. |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 8446 | * @hide |
Yorke Lee | 0e040b0 | 2014-06-18 15:02:44 -0700 | [diff] [blame] | 8447 | */ |
Jeff Sharkey | cb269aac | 2019-01-25 11:15:38 -0700 | [diff] [blame] | 8448 | @TestApi |
Yorke Lee | 0e040b0 | 2014-06-18 15:02:44 -0700 | [diff] [blame] | 8449 | public static final String UNDEMOTE_METHOD = "undemote"; |
| 8450 | |
| 8451 | /** |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 8452 | * Undemotes a formerly demoted contact. If the contact was not previously demoted, nothing |
| 8453 | * will be done. |
| 8454 | * |
| 8455 | * @param contentResolver to perform the undemote operation on. |
| 8456 | * @param contactId the id of the contact to undemote. |
| 8457 | */ |
| 8458 | public static void undemote(ContentResolver contentResolver, long contactId) { |
| 8459 | contentResolver.call(ContactsContract.AUTHORITY_URI, PinnedPositions.UNDEMOTE_METHOD, |
| 8460 | String.valueOf(contactId), null); |
| 8461 | } |
| 8462 | |
| 8463 | /** |
Yorke Lee | b31c8ab | 2014-08-26 17:13:02 -0700 | [diff] [blame] | 8464 | * Pins a contact at a provided position, or unpins a contact. |
| 8465 | * |
| 8466 | * @param contentResolver to perform the pinning operation on. |
| 8467 | * @param pinnedPosition the position to pin the contact at. To unpin a contact, use |
| 8468 | * {@link PinnedPositions#UNPINNED}. |
| 8469 | */ |
| 8470 | public static void pin( |
| 8471 | ContentResolver contentResolver, long contactId, int pinnedPosition) { |
| 8472 | final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId)); |
| 8473 | final ContentValues values = new ContentValues(); |
| 8474 | values.put(Contacts.PINNED, pinnedPosition); |
| 8475 | contentResolver.update(uri, values, null, null); |
| 8476 | } |
| 8477 | |
| 8478 | /** |
Yorke Lee | 94c8761 | 2014-07-18 18:57:17 -0700 | [diff] [blame] | 8479 | * Default value for the pinned position of an unpinned contact. |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8480 | */ |
Yorke Lee | 7d24679 | 2014-07-25 10:05:55 -0700 | [diff] [blame] | 8481 | public static final int UNPINNED = 0; |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8482 | |
| 8483 | /** |
Yorke Lee | 3585e1a | 2013-07-31 18:53:31 -0700 | [diff] [blame] | 8484 | * Value of pinned position for a contact that a user has indicated should be considered |
| 8485 | * of the lowest priority. It is up to the client application to determine how to present |
| 8486 | * such a contact - for example all the way at the bottom of a contact list, or simply |
| 8487 | * just hidden from view. |
| 8488 | */ |
| 8489 | public static final int DEMOTED = -1; |
Yorke Lee | 6acfa5d | 2013-07-17 09:55:26 -0700 | [diff] [blame] | 8490 | } |
| 8491 | |
| 8492 | /** |
Yorke Lee | f8aadf3 | 2014-06-23 17:51:16 -0700 | [diff] [blame] | 8493 | * 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] | 8494 | * a specific {@link Contacts} entry. |
| 8495 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8496 | public static final class QuickContact { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8497 | /** |
Yorke Lee | f8aadf3 | 2014-06-23 17:51:16 -0700 | [diff] [blame] | 8498 | * Action used to launch the system contacts application and bring up a QuickContact dialog |
| 8499 | * for the provided {@link Contacts} entry. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8500 | */ |
Jeff Sharkey | 0f3f60b | 2017-04-24 18:06:20 -0600 | [diff] [blame] | 8501 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
Evan Millar | 5042f7e | 2009-09-30 21:28:33 -0700 | [diff] [blame] | 8502 | public static final String ACTION_QUICK_CONTACT = |
Yorke Lee | 7881462 | 2014-09-04 16:07:50 -0700 | [diff] [blame] | 8503 | "android.provider.action.QUICK_CONTACT"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8504 | |
| 8505 | /** |
| 8506 | * Extra used to specify pivot dialog location in screen coordinates. |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 8507 | * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8508 | * @hide |
| 8509 | */ |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 8510 | @Deprecated |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 8511 | public static final String EXTRA_TARGET_RECT = "android.provider.extra.TARGET_RECT"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8512 | |
| 8513 | /** |
Brian Attwell | 029e681 | 2015-02-02 16:10:39 -0800 | [diff] [blame] | 8514 | * Extra used to specify size of QuickContacts. Not all implementations of QuickContacts |
| 8515 | * will respect this extra's value. |
| 8516 | * |
| 8517 | * One of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8518 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 8519 | public static final String EXTRA_MODE = "android.provider.extra.MODE"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8520 | |
| 8521 | /** |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8522 | * Extra used to specify which mimetype should be prioritized in the QuickContacts UI. |
| 8523 | * For example, passing the value {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can |
| 8524 | * cause phone numbers to be displayed more prominently in QuickContacts. |
| 8525 | */ |
| 8526 | public static final String EXTRA_PRIORITIZED_MIMETYPE |
| 8527 | = "android.provider.extra.PRIORITIZED_MIMETYPE"; |
| 8528 | |
| 8529 | /** |
Yorke Lee | f8aadf3 | 2014-06-23 17:51:16 -0700 | [diff] [blame] | 8530 | * Extra used to indicate a list of specific MIME-types to exclude and not display in the |
| 8531 | * QuickContacts dialog. Stored as a {@link String} array. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8532 | */ |
Makoto Onuki | 0e91733 | 2014-08-26 14:06:30 -0700 | [diff] [blame] | 8533 | public static final String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8534 | |
| 8535 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8536 | * Small QuickContact mode, usually presented with minimal actions. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8537 | */ |
| 8538 | public static final int MODE_SMALL = 1; |
| 8539 | |
| 8540 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8541 | * Medium QuickContact mode, includes actions and light summary describing |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8542 | * the {@link Contacts} entry being shown. This may include social |
| 8543 | * status and presence details. |
| 8544 | */ |
| 8545 | public static final int MODE_MEDIUM = 2; |
| 8546 | |
| 8547 | /** |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8548 | * Large QuickContact mode, includes actions and larger, card-like summary |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8549 | * of the {@link Contacts} entry being shown. This may include detailed |
| 8550 | * information, such as a photo. |
| 8551 | */ |
| 8552 | public static final int MODE_LARGE = 3; |
| 8553 | |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8554 | /** @hide */ |
| 8555 | public static final int MODE_DEFAULT = MODE_LARGE; |
| 8556 | |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8557 | /** |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8558 | * Constructs the QuickContacts intent with a view's rect. |
| 8559 | * @hide |
| 8560 | */ |
| 8561 | public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri, |
| 8562 | int mode, String[] excludeMimes) { |
| 8563 | // Find location and bounds of target view, adjusting based on the |
| 8564 | // assumed local density. |
| 8565 | final float appScale = context.getResources().getCompatibilityInfo().applicationScale; |
| 8566 | final int[] pos = new int[2]; |
| 8567 | target.getLocationOnScreen(pos); |
| 8568 | |
| 8569 | final Rect rect = new Rect(); |
| 8570 | rect.left = (int) (pos[0] * appScale + 0.5f); |
| 8571 | rect.top = (int) (pos[1] * appScale + 0.5f); |
| 8572 | rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); |
| 8573 | rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); |
| 8574 | |
| 8575 | return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes); |
| 8576 | } |
| 8577 | |
| 8578 | /** |
| 8579 | * Constructs the QuickContacts intent. |
| 8580 | * @hide |
| 8581 | */ |
Mathew Inwood | 6750f2e | 2018-08-10 09:29:25 +0100 | [diff] [blame] | 8582 | @UnsupportedAppUsage |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8583 | public static Intent composeQuickContactsIntent(Context context, Rect target, |
| 8584 | Uri lookupUri, int mode, String[] excludeMimes) { |
| 8585 | // When launching from an Activiy, we don't want to start a new task, but otherwise |
| 8586 | // we *must* start a new task. (Otherwise startActivity() would crash.) |
| 8587 | Context actualContext = context; |
| 8588 | while ((actualContext instanceof ContextWrapper) |
| 8589 | && !(actualContext instanceof Activity)) { |
| 8590 | actualContext = ((ContextWrapper) actualContext).getBaseContext(); |
| 8591 | } |
Brian Attwell | 9ee6640 | 2014-08-11 22:42:26 -0700 | [diff] [blame] | 8592 | final int intentFlags = ((actualContext instanceof Activity) |
| 8593 | ? 0 : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK) |
| 8594 | // Workaround for b/16898764. Declaring singleTop in manifest doesn't work. |
| 8595 | | Intent.FLAG_ACTIVITY_SINGLE_TOP; |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8596 | |
| 8597 | // Launch pivot dialog through intent for now |
| 8598 | final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags); |
| 8599 | |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8600 | // NOTE: This logic and rebuildManagedQuickContactsIntent() must be in sync. |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8601 | intent.setData(lookupUri); |
| 8602 | intent.setSourceBounds(target); |
| 8603 | intent.putExtra(EXTRA_MODE, mode); |
| 8604 | intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); |
| 8605 | return intent; |
| 8606 | } |
| 8607 | |
| 8608 | /** |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8609 | * Constructs a QuickContacts intent based on an incoming intent for DevicePolicyManager |
| 8610 | * to strip off anything not necessary. |
Etan Cohen | 534a65d | 2015-05-01 11:03:24 -0700 | [diff] [blame] | 8611 | * |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8612 | * @hide |
| 8613 | */ |
| 8614 | public static Intent rebuildManagedQuickContactsIntent(String lookupKey, long contactId, |
Victor Chang | 97bdacc | 2016-01-21 22:24:11 +0000 | [diff] [blame] | 8615 | boolean isContactIdIgnored, long directoryId, Intent originalIntent) { |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8616 | final Intent intent = new Intent(ACTION_QUICK_CONTACT); |
| 8617 | // Rebuild the URI from a lookup key and a contact ID. |
Victor Chang | 97bdacc | 2016-01-21 22:24:11 +0000 | [diff] [blame] | 8618 | Uri uri = null; |
| 8619 | if (!TextUtils.isEmpty(lookupKey)) { |
| 8620 | uri = isContactIdIgnored |
| 8621 | ? Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey) |
| 8622 | : Contacts.getLookupUri(contactId, lookupKey); |
| 8623 | } |
Ricky Wai | 494b95d | 2015-11-20 16:07:15 +0000 | [diff] [blame] | 8624 | if (uri != null && directoryId != Directory.DEFAULT) { |
| 8625 | uri = uri.buildUpon().appendQueryParameter( |
| 8626 | ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(directoryId)).build(); |
| 8627 | } |
| 8628 | intent.setData(uri); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8629 | |
| 8630 | // Copy flags and always set NEW_TASK because it won't have a parent activity. |
| 8631 | intent.setFlags(originalIntent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK); |
| 8632 | |
| 8633 | // Copy extras. |
| 8634 | intent.setSourceBounds(originalIntent.getSourceBounds()); |
| 8635 | intent.putExtra(EXTRA_MODE, originalIntent.getIntExtra(EXTRA_MODE, MODE_DEFAULT)); |
| 8636 | intent.putExtra(EXTRA_EXCLUDE_MIMES, |
| 8637 | originalIntent.getStringArrayExtra(EXTRA_EXCLUDE_MIMES)); |
| 8638 | return intent; |
| 8639 | } |
| 8640 | |
| 8641 | |
| 8642 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8643 | * Trigger a dialog that lists the various methods of interacting with |
| 8644 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8645 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8646 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8647 | * |
| 8648 | * @param context The parent {@link Context} that may be used as the |
| 8649 | * parent for this dialog. |
| 8650 | * @param target Specific {@link View} from your layout that this dialog |
| 8651 | * should be centered around. In particular, if the dialog |
| 8652 | * has a "callout" arrow, it will be pointed and centered |
| 8653 | * around this {@link View}. |
Evan Millar | 772722e | 2009-09-30 22:24:07 -0700 | [diff] [blame] | 8654 | * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8655 | * {@link Uri} that describes a specific contact to feature |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 8656 | * in this dialog. A work lookup uri is supported here, |
| 8657 | * see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and |
| 8658 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8659 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 8660 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 8661 | * when supported. |
| 8662 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8663 | * to exclude when showing this dialog. For example, when |
| 8664 | * already viewing the contact details card, this can be used |
| 8665 | * to omit the details entry from the dialog. |
| 8666 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8667 | public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8668 | String[] excludeMimes) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8669 | // Trigger with obtained rectangle |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8670 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, |
| 8671 | excludeMimes); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8672 | ContactsInternal.startQuickContactWithErrorToast(context, intent); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8673 | } |
| 8674 | |
| 8675 | /** |
| 8676 | * Trigger a dialog that lists the various methods of interacting with |
| 8677 | * the requested {@link Contacts} entry. This may be based on available |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 8678 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8679 | * include social status and presence details. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8680 | * |
| 8681 | * @param context The parent {@link Context} that may be used as the |
| 8682 | * parent for this dialog. |
| 8683 | * @param target Specific {@link Rect} that this dialog should be |
| 8684 | * centered around, in screen coordinates. In particular, if |
| 8685 | * the dialog has a "callout" arrow, it will be pointed and |
Jeff Sharkey | a503f6f | 2009-12-08 21:50:14 -0800 | [diff] [blame] | 8686 | * centered around this {@link Rect}. If you are running at a |
| 8687 | * non-native density, you need to manually adjust using |
| 8688 | * {@link DisplayMetrics#density} before calling. |
Jeff Sharkey | 223bd7a | 2009-12-21 14:51:19 -0800 | [diff] [blame] | 8689 | * @param lookupUri A |
| 8690 | * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8691 | * {@link Uri} that describes a specific contact to feature |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 8692 | * in this dialog. A work lookup uri is supported here, |
| 8693 | * see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and |
| 8694 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8695 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 8696 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 8697 | * when supported. |
| 8698 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8699 | * to exclude when showing this dialog. For example, when |
| 8700 | * already viewing the contact details card, this can be used |
| 8701 | * to omit the details entry from the dialog. |
| 8702 | */ |
Evan Millar | e3ec997 | 2009-09-30 19:37:36 -0700 | [diff] [blame] | 8703 | public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8704 | String[] excludeMimes) { |
Winson Chung | 9fc6b8c | 2012-09-28 11:37:41 -0700 | [diff] [blame] | 8705 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, |
| 8706 | excludeMimes); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8707 | ContactsInternal.startQuickContactWithErrorToast(context, intent); |
Yorke Lee | 4fc601a | 2013-12-06 16:35:29 -0800 | [diff] [blame] | 8708 | } |
| 8709 | |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8710 | /** |
| 8711 | * Trigger a dialog that lists the various methods of interacting with |
| 8712 | * the requested {@link Contacts} entry. This may be based on available |
| 8713 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8714 | * include social status and presence details. |
| 8715 | * |
| 8716 | * @param context The parent {@link Context} that may be used as the |
| 8717 | * parent for this dialog. |
| 8718 | * @param target Specific {@link View} from your layout that this dialog |
| 8719 | * should be centered around. In particular, if the dialog |
| 8720 | * has a "callout" arrow, it will be pointed and centered |
| 8721 | * around this {@link View}. |
| 8722 | * @param lookupUri A |
| 8723 | * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style |
| 8724 | * {@link Uri} that describes a specific contact to feature |
Tony Mak | 935dafe | 2016-03-07 20:27:53 +0000 | [diff] [blame] | 8725 | * in this dialog. A work lookup uri is supported here, |
| 8726 | * see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and |
| 8727 | * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}. |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8728 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 8729 | * to exclude when showing this dialog. For example, when |
| 8730 | * already viewing the contact details card, this can be used |
| 8731 | * to omit the details entry from the dialog. |
| 8732 | * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI. |
| 8733 | * For example, passing the value |
| 8734 | * {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be |
| 8735 | * displayed more prominently in QuickContacts. |
| 8736 | */ |
| 8737 | public static void showQuickContact(Context context, View target, Uri lookupUri, |
| 8738 | String[] excludeMimes, String prioritizedMimeType) { |
| 8739 | // Use MODE_LARGE instead of accepting mode as a parameter. The different mode |
| 8740 | // values defined in ContactsContract only affect very old implementations |
| 8741 | // of QuickContacts. |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8742 | Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT, |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8743 | excludeMimes); |
| 8744 | intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType); |
Makoto Onuki | 1040da1 | 2015-03-19 11:24:00 -0700 | [diff] [blame] | 8745 | ContactsInternal.startQuickContactWithErrorToast(context, intent); |
Brian Attwell | 7035f2b | 2015-02-25 20:06:08 -0800 | [diff] [blame] | 8746 | } |
| 8747 | |
| 8748 | /** |
| 8749 | * Trigger a dialog that lists the various methods of interacting with |
| 8750 | * the requested {@link Contacts} entry. This may be based on available |
| 8751 | * {@link ContactsContract.Data} rows under that contact, and may also |
| 8752 | * include social status and presence details. |
| 8753 | * |
| 8754 | * @param context The parent {@link Context} that may be used as the |
| 8755 | * parent for this dialog. |
| 8756 | * @param target Specific {@link Rect} that this dialog should be |
| 8757 | * centered around, in screen coordinates. In particular, if |
| 8758 | * the dialog has a "callout" arrow, it will be pointed and |
| 8759 | * centered around this {@link Rect}. If you are running at a |
| 8760 | * non-native density, you need to manually adjust using |
| 8761 | * {@link DisplayMetrics#density} before calling. |
| 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, Rect 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); |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 8786 | } |
| 8787 | } |
| 8788 | |
| 8789 | /** |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8790 | * Helper class for accessing full-size photos by photo file ID. |
| 8791 | * <p> |
| 8792 | * Usage example: |
| 8793 | * <dl> |
| 8794 | * <dt>Retrieving a full-size photo by photo file ID (see |
| 8795 | * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID}) |
| 8796 | * </dt> |
| 8797 | * <dd> |
| 8798 | * <pre> |
| 8799 | * public InputStream openDisplayPhoto(long photoFileId) { |
| 8800 | * Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey); |
| 8801 | * try { |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 8802 | * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor( |
| 8803 | * displayPhotoUri, "r"); |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8804 | * return fd.createInputStream(); |
Dave Santoro | 040e6b3 | 2011-07-15 15:14:08 -0700 | [diff] [blame] | 8805 | * } catch (IOException e) { |
Dave Santoro | a528237 | 2011-06-29 00:25:16 -0700 | [diff] [blame] | 8806 | * return null; |
| 8807 | * } |
| 8808 | * } |
| 8809 | * </pre> |
| 8810 | * </dd> |
| 8811 | * </dl> |
| 8812 | * </p> |
| 8813 | */ |
| 8814 | public static final class DisplayPhoto { |
| 8815 | /** |
| 8816 | * no public constructor since this is a utility class |
| 8817 | */ |
| 8818 | private DisplayPhoto() {} |
| 8819 | |
| 8820 | /** |
| 8821 | * The content:// style URI for this class, which allows access to full-size photos, |
| 8822 | * given a key. |
| 8823 | */ |
| 8824 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo"); |
| 8825 | |
| 8826 | /** |
| 8827 | * This URI allows the caller to query for the maximum dimensions of a display photo |
| 8828 | * or thumbnail. Requests to this URI can be performed on the UI thread because |
| 8829 | * they are always unblocking. |
| 8830 | */ |
| 8831 | public static final Uri CONTENT_MAX_DIMENSIONS_URI = |
| 8832 | Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions"); |
| 8833 | |
| 8834 | /** |
| 8835 | * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will |
| 8836 | * contain this column, populated with the maximum height and width (in pixels) |
| 8837 | * that will be stored for a display photo. Larger photos will be down-sized to |
| 8838 | * fit within a square of this many pixels. |
| 8839 | */ |
| 8840 | public static final String DISPLAY_MAX_DIM = "display_max_dim"; |
| 8841 | |
| 8842 | /** |
| 8843 | * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will |
| 8844 | * contain this column, populated with the height and width (in pixels) for photo |
| 8845 | * thumbnails. |
| 8846 | */ |
| 8847 | public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim"; |
| 8848 | } |
| 8849 | |
| 8850 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8851 | * Contains helper classes used to create or manage {@link android.content.Intent Intents} |
| 8852 | * that involve contacts. |
| 8853 | */ |
| 8854 | public static final class Intents { |
| 8855 | /** |
| 8856 | * This is the intent that is fired when a search suggestion is clicked on. |
| 8857 | */ |
| 8858 | public static final String SEARCH_SUGGESTION_CLICKED = |
| 8859 | "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; |
| 8860 | |
| 8861 | /** |
| 8862 | * This is the intent that is fired when a search suggestion for dialing a number |
| 8863 | * is clicked on. |
| 8864 | */ |
| 8865 | public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = |
| 8866 | "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; |
| 8867 | |
| 8868 | /** |
| 8869 | * This is the intent that is fired when a search suggestion for creating a contact |
| 8870 | * is clicked on. |
| 8871 | */ |
| 8872 | public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = |
| 8873 | "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; |
| 8874 | |
| 8875 | /** |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 8876 | * This is the intent that is fired when the contacts database is created. <p> The |
| 8877 | * READ_CONTACT permission is required to receive these broadcasts. |
Makoto Onuki | 729a87b | 2017-01-11 13:40:06 -0800 | [diff] [blame] | 8878 | * |
Makoto Onuki | 2a61537 | 2017-01-30 11:59:46 -0800 | [diff] [blame] | 8879 | * <p>Because this is an implicit broadcast, apps targeting Android O will no longer |
| 8880 | * receive this broadcast via a manifest broadcast receiver. (Broadcast receivers |
| 8881 | * registered at runtime with |
| 8882 | * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)} will still receive it.) |
| 8883 | * Instead, an app can use {@link ProviderStatus#DATABASE_CREATION_TIMESTAMP} to see if the |
| 8884 | * contacts database has been initialized when it starts. |
Chiao Cheng | 2355d13 | 2013-03-20 16:54:06 -0700 | [diff] [blame] | 8885 | */ |
| 8886 | public static final String CONTACTS_DATABASE_CREATED = |
| 8887 | "android.provider.Contacts.DATABASE_CREATED"; |
| 8888 | |
| 8889 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8890 | * Starts an Activity that lets the user pick a contact to attach an image to. |
| 8891 | * After picking the contact it launches the image cropper in face detection mode. |
| 8892 | */ |
| 8893 | public static final String ATTACH_IMAGE = |
| 8894 | "com.android.contacts.action.ATTACH_IMAGE"; |
| 8895 | |
| 8896 | /** |
Makoto Onuki | 85a01a6b | 2011-07-21 15:16:31 -0700 | [diff] [blame] | 8897 | * This is the intent that is fired when the user clicks the "invite to the network" button |
| 8898 | * on a contact. Only sent to an activity which is explicitly registered by a contact |
| 8899 | * provider which supports the "invite to the network" feature. |
| 8900 | * <p> |
| 8901 | * {@link Intent#getData()} contains the lookup URI for the contact. |
| 8902 | */ |
| 8903 | public static final String INVITE_CONTACT = |
| 8904 | "com.android.contacts.action.INVITE_CONTACT"; |
| 8905 | |
| 8906 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 8907 | * Takes as input a data URI with a mailto: or tel: scheme. If a single |
| 8908 | * contact exists with the given data it will be shown. If no contact |
| 8909 | * exists, a dialog will ask the user if they want to create a new |
| 8910 | * contact with the provided details filled in. If multiple contacts |
| 8911 | * share the data the user will be prompted to pick which contact they |
| 8912 | * want to view. |
| 8913 | * <p> |
| 8914 | * For <code>mailto:</code> URIs, the scheme specific portion must be a |
| 8915 | * raw email address, such as one built using |
| 8916 | * {@link Uri#fromParts(String, String, String)}. |
| 8917 | * <p> |
| 8918 | * For <code>tel:</code> URIs, the scheme specific portion is compared |
| 8919 | * to existing numbers using the standard caller ID lookup algorithm. |
| 8920 | * The number must be properly encoded, for example using |
| 8921 | * {@link Uri#fromParts(String, String, String)}. |
| 8922 | * <p> |
| 8923 | * Any extras from the {@link Insert} class will be passed along to the |
| 8924 | * create activity if there are no contacts to show. |
| 8925 | * <p> |
| 8926 | * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip |
| 8927 | * prompting the user when the contact doesn't exist. |
| 8928 | */ |
| 8929 | public static final String SHOW_OR_CREATE_CONTACT = |
| 8930 | "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; |
| 8931 | |
| 8932 | /** |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 8933 | * Activity Action: Initiate a message to someone by voice. The message could be text, |
| 8934 | * audio, video or image(photo). This action supports messaging with a specific contact |
| 8935 | * regardless of the underlying messaging protocol used. |
| 8936 | * <p> |
| 8937 | * The action could be originated from the Voice Assistant as a voice interaction. In such |
| 8938 | * case, a receiving activity that supports {@link android.content.Intent#CATEGORY_VOICE} |
| 8939 | * could check return value of {@link android.app.Activity#isVoiceInteractionRoot} before |
| 8940 | * proceeding. By doing this check the activity verifies that the action indeed was |
| 8941 | * initiated by Voice Assistant and could send a message right away, without any further |
| 8942 | * input from the user. This allows for a smooth user experience when sending a message by |
| 8943 | * voice. Note: this activity must also support the {@link |
| 8944 | * android.content.Intent#CATEGORY_DEFAULT} so it can be found by {@link |
| 8945 | * android.service.voice.VoiceInteractionSession#startVoiceActivity}. |
| 8946 | * <p> |
| 8947 | * 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] | 8948 | * not support {@link android.content.Intent#CATEGORY_VOICE}, the activity must confirm |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 8949 | * with the user before sending the message (because in this case it is unknown which app |
| 8950 | * sent the intent, it could be malicious). |
| 8951 | * <p> |
| 8952 | * 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] | 8953 | * app may choose to integrate with the Contacts Provider. You will need to specify a new |
| 8954 | * MIME type in order to store your app’s unique contact IDs and optional human readable |
| 8955 | * labels in the Data table. The Voice Assistant needs to know this MIME type and {@link |
| 8956 | * RawContacts#ACCOUNT_TYPE} that you are using in order to provide the smooth contact |
| 8957 | * disambiguation user experience. The following convention should be met when performing |
| 8958 | * such integration: |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 8959 | * <ul> |
Renat Aksitov | c8dd93d | 2016-05-01 16:31:28 -0700 | [diff] [blame] | 8960 | * <li>This activity should have a string meta-data field associated with it, {@link |
| 8961 | * #METADATA_ACCOUNT_TYPE}, which defines {@link RawContacts#ACCOUNT_TYPE} for your Contacts |
| 8962 | * Provider implementation. The account type should be globally unique, for example you can |
| 8963 | * use your app package name as the account type.</li> |
| 8964 | * <li>This activity should have a string meta-data field associated with it, {@link |
| 8965 | * #METADATA_MIMETYPE}, which defines {@link DataColumns#MIMETYPE} for your Contacts |
| 8966 | * Provider implementation. For example, you can use |
| 8967 | * "vnd.android.cursor.item/vnd.{$app_package_name}.profile" as MIME type.</li> |
| 8968 | * <li>When filling Data table row for METADATA_MIMETYPE, column {@link DataColumns#DATA1} |
| 8969 | * should store the unique contact ID as understood by the app. This value will be used in |
| 8970 | * the {@link #EXTRA_RECIPIENT_CONTACT_CHAT_ID}.</li> |
| 8971 | * <li>Optionally, when filling Data table row for METADATA_MIMETYPE, column {@link |
| 8972 | * DataColumns#DATA3} could store a human readable label for the ID. For example it could be |
| 8973 | * phone number or human readable username/user_id like "a_super_cool_user_name". This label |
| 8974 | * may be shown below the Contact Name by the Voice Assistant as the user completes the |
| 8975 | * 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] | 8976 | * <li><em>Note: Do not use DATA3 to store the Contact Name. The Voice Assistant will |
| 8977 | * already get the Contact Name from the RawContact’s display_name.</em></li> |
| 8978 | * <li><em>Note: Some apps may choose to use phone number as the unique contact ID in DATA1. |
| 8979 | * If this applies to you and you’d like phone number to be shown below the Contact Name by |
| 8980 | * 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] | 8981 | * <li><em>Note: If your app also uses DATA3 to display contact details in the Contacts App, |
| 8982 | * make sure it does not include prefix text such as "Message +<phone>" or "Free Message |
| 8983 | * +<phone>", etc. If you must show the prefix text in the Contacts App, please use a |
| 8984 | * different DATA# column, and update your contacts.xml to point to this new column. </em> |
| 8985 | * </li> |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 8986 | * </ul> |
Renat Aksitov | c8dd93d | 2016-05-01 16:31:28 -0700 | [diff] [blame] | 8987 | * If the app chooses not to integrate with the Contacts Provider (in particular, when |
| 8988 | * either METADATA_ACCOUNT_TYPE or METADATA_MIMETYPE field is missing), Voice Assistant |
| 8989 | * 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] | 8990 | * <p> |
| 8991 | * Input: {@link android.content.Intent#getType} is the MIME type of the data being sent. |
| 8992 | * The intent sender will always put the concrete mime type in the intent type, like |
| 8993 | * "text/plain" or "audio/wav" for example. If the MIME type is "text/plain", message to |
| 8994 | * sent will be provided via {@link android.content.Intent#EXTRA_TEXT} as a styled |
| 8995 | * CharSequence. Otherwise, the message content will be supplied through {@link |
| 8996 | * android.content.Intent#setClipData(ClipData)} as a content provider URI(s). In the latter |
| 8997 | * case, EXTRA_TEXT could still be supplied optionally; for example, for audio messages |
| 8998 | * ClipData will contain URI of a recording and EXTRA_TEXT could contain the text |
| 8999 | * transcription of this recording. |
| 9000 | * <p> |
| 9001 | * The message can have n recipients. The n-th recipient of the message will be provided as |
| 9002 | * n-th elements of {@link #EXTRA_RECIPIENT_CONTACT_URI}, {@link |
| 9003 | * #EXTRA_RECIPIENT_CONTACT_CHAT_ID} and {@link #EXTRA_RECIPIENT_CONTACT_NAME} (as a |
| 9004 | * consequence, EXTRA_RECIPIENT_CONTACT_URI, EXTRA_RECIPIENT_CONTACT_CHAT_ID and |
| 9005 | * EXTRA_RECIPIENT_CONTACT_NAME should all be of length n). If neither of these 3 elements |
| 9006 | * is provided (e.g. all 3 are null) for the recipient or if the information provided is |
| 9007 | * ambiguous then the activity should prompt the user for the recipient to send the message |
| 9008 | * to. |
| 9009 | * <p> |
| 9010 | * Output: nothing |
| 9011 | * |
| 9012 | * @see #EXTRA_RECIPIENT_CONTACT_URI |
| 9013 | * @see #EXTRA_RECIPIENT_CONTACT_CHAT_ID |
| 9014 | * @see #EXTRA_RECIPIENT_CONTACT_NAME |
Renat Aksitov | c8dd93d | 2016-05-01 16:31:28 -0700 | [diff] [blame] | 9015 | * @see #METADATA_ACCOUNT_TYPE |
| 9016 | * @see #METADATA_MIMETYPE |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 9017 | */ |
Jeff Sharkey | 0f3f60b | 2017-04-24 18:06:20 -0600 | [diff] [blame] | 9018 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
Renat Aksitov | 799da39 | 2016-01-21 14:58:58 -0800 | [diff] [blame] | 9019 | public static final String ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS = |
| 9020 | "android.provider.action.VOICE_SEND_MESSAGE_TO_CONTACTS"; |
| 9021 | |
| 9022 | /** |
| 9023 | * This extra specifies a content provider uri(s) for the contact(s) (if the contacts were |
| 9024 | * located in the Contacts Provider), used with {@link |
| 9025 | * #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient(s). The value of this |
| 9026 | * extra is a {@code String[]}. The number of elements in the array should be equal to |
| 9027 | * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_CHAT_ID} and |
| 9028 | * {@link #EXTRA_RECIPIENT_CONTACT_NAME}). When the value of the element for the particular |
| 9029 | * recipient is absent, it will be set to null. |
| 9030 | * <p> |
| 9031 | * <em>Note: one contact may have multiple accounts (e.g. Chat IDs) on a specific messaging |
| 9032 | * platform, so this may be ambiguous. E.g., one contact “John Smith” could have two |
| 9033 | * accounts on the same messaging app.</em> |
| 9034 | * <p> |
| 9035 | * <em>Example value: {"content://com.android.contacts/contacts/16"}</em> |
| 9036 | */ |
| 9037 | public static final String EXTRA_RECIPIENT_CONTACT_URI = |
| 9038 | "android.provider.extra.RECIPIENT_CONTACT_URI"; |
| 9039 | |
| 9040 | /** |
| 9041 | * This extra specifies a messaging app’s unique ID(s) for the contact(s), used with {@link |
| 9042 | * #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient(s). The value of this |
| 9043 | * extra is a {@code String[]}. The number of elements in the array should be equal to |
| 9044 | * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_URI} and {@link |
| 9045 | * #EXTRA_RECIPIENT_CONTACT_NAME}). When the value of the element for the particular |
| 9046 | * recipient is absent, it will be set to null. |
| 9047 | * <p> |
| 9048 | * 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] | 9049 | * Provider with {@link DataColumns#MIMETYPE} from {@link #METADATA_MIMETYPE} (if both |
| 9050 | * {@link #METADATA_ACCOUNT_TYPE} and {@link #METADATA_MIMETYPE} are specified by the app; |
| 9051 | * otherwise, the value will be a phone number), and should be the unambiguous contact |
| 9052 | * 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] | 9053 | */ |
| 9054 | public static final String EXTRA_RECIPIENT_CONTACT_CHAT_ID = |
| 9055 | "android.provider.extra.RECIPIENT_CONTACT_CHAT_ID"; |
| 9056 | |
| 9057 | /** |
| 9058 | * This extra specifies the contact name (full name from the Contacts Provider), used with |
| 9059 | * {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient. The value of this |
| 9060 | * extra is a {@code String[]}. The number of elements in the array should be equal to |
| 9061 | * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_URI} and {@link |
| 9062 | * #EXTRA_RECIPIENT_CONTACT_CHAT_ID}). When the value of the element for the particular |
| 9063 | * recipient is absent, it will be set to null. |
| 9064 | * <p> |
| 9065 | * The value of the elements comes from RawContact's display_name column. |
| 9066 | * <p> |
| 9067 | * <em>Example value: {"Jane Doe"}</em> |
| 9068 | */ |
| 9069 | public static final String EXTRA_RECIPIENT_CONTACT_NAME = |
| 9070 | "android.provider.extra.RECIPIENT_CONTACT_NAME"; |
| 9071 | |
| 9072 | /** |
Renat Aksitov | c8dd93d | 2016-05-01 16:31:28 -0700 | [diff] [blame] | 9073 | * A string associated with an {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} activity |
| 9074 | * describing {@link RawContacts#ACCOUNT_TYPE} for the corresponding Contacts Provider |
| 9075 | * implementation. |
| 9076 | */ |
| 9077 | public static final String METADATA_ACCOUNT_TYPE = "android.provider.account_type"; |
| 9078 | |
| 9079 | /** |
| 9080 | * A string associated with an {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} activity |
| 9081 | * describing {@link DataColumns#MIMETYPE} for the corresponding Contacts Provider |
| 9082 | * implementation. |
| 9083 | */ |
| 9084 | public static final String METADATA_MIMETYPE = "android.provider.mimetype"; |
| 9085 | |
| 9086 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 9087 | * Starts an Activity that lets the user select the multiple phones from a |
| 9088 | * list of phone numbers which come from the contacts or |
| 9089 | * {@link #EXTRA_PHONE_URIS}. |
| 9090 | * <p> |
| 9091 | * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS} |
| 9092 | * could belong to the contacts or not, and will be selected by default. |
| 9093 | * <p> |
| 9094 | * The user's selection will be returned from |
| 9095 | * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)} |
Fred Quintana | a31a945 | 2010-04-13 14:52:20 -0700 | [diff] [blame] | 9096 | * if the resultCode is |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 9097 | * {@link android.app.Activity#RESULT_OK}, the array of picked phone |
| 9098 | * numbers are in the Intent's |
| 9099 | * {@link #EXTRA_PHONE_URIS}; otherwise, the |
| 9100 | * {@link android.app.Activity#RESULT_CANCELED} is returned if the user |
| 9101 | * left the Activity without changing the selection. |
| 9102 | * |
| 9103 | * @hide |
| 9104 | */ |
| 9105 | public static final String ACTION_GET_MULTIPLE_PHONES = |
| 9106 | "com.android.contacts.action.GET_MULTIPLE_PHONES"; |
| 9107 | |
| 9108 | /** |
Makoto Onuki | 90ddc90 | 2012-09-11 18:22:53 -0700 | [diff] [blame] | 9109 | * A broadcast action which is sent when any change has been made to the profile, such |
| 9110 | * as the profile name or the picture. A receiver must have |
| 9111 | * the android.permission.READ_PROFILE permission. |
| 9112 | * |
| 9113 | * @hide |
| 9114 | */ |
| 9115 | public static final String ACTION_PROFILE_CHANGED = |
| 9116 | "android.provider.Contacts.PROFILE_CHANGED"; |
| 9117 | |
| 9118 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9119 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new |
| 9120 | * contact if no matching contact found. Otherwise, default behavior is |
| 9121 | * to prompt user with dialog before creating. |
| 9122 | * <p> |
| 9123 | * Type: BOOLEAN |
| 9124 | */ |
| 9125 | public static final String EXTRA_FORCE_CREATE = |
| 9126 | "com.android.contacts.action.FORCE_CREATE"; |
| 9127 | |
| 9128 | /** |
| 9129 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact |
| 9130 | * description to be shown when prompting user about creating a new |
| 9131 | * contact. |
| 9132 | * <p> |
| 9133 | * Type: STRING |
| 9134 | */ |
| 9135 | public static final String EXTRA_CREATE_DESCRIPTION = |
| 9136 | "com.android.contacts.action.CREATE_DESCRIPTION"; |
| 9137 | |
| 9138 | /** |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 9139 | * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value. |
| 9140 | * <p> |
| 9141 | * The phone numbers want to be picked by default should be passed in as |
| 9142 | * input value. These phone numbers could belong to the contacts or not. |
| 9143 | * <p> |
| 9144 | * The phone numbers which were picked by the user are returned as output |
| 9145 | * value. |
| 9146 | * <p> |
| 9147 | * Type: array of URIs, the tel URI is used for the phone numbers which don't |
| 9148 | * 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] | 9149 | * |
Bai Tao | fc7838b | 2010-01-22 03:34:56 +0800 | [diff] [blame] | 9150 | * @hide |
| 9151 | */ |
| 9152 | public static final String EXTRA_PHONE_URIS = |
| 9153 | "com.android.contacts.extra.PHONE_URIS"; |
| 9154 | |
| 9155 | /** |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 9156 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 9157 | * dialog location using screen coordinates. When not specified, the |
| 9158 | * dialog will be centered. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9159 | * |
| 9160 | * @hide |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 9161 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9162 | @Deprecated |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 9163 | public static final String EXTRA_TARGET_RECT = "target_rect"; |
| 9164 | |
| 9165 | /** |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9166 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 9167 | * desired dialog style, usually a variation on size. One of |
| 9168 | * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9169 | * |
| 9170 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9171 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9172 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9173 | public static final String EXTRA_MODE = "mode"; |
| 9174 | |
| 9175 | /** |
| 9176 | * Value for {@link #EXTRA_MODE} to show a small-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9177 | * |
| 9178 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9179 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9180 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9181 | public static final int MODE_SMALL = 1; |
| 9182 | |
| 9183 | /** |
| 9184 | * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9185 | * |
| 9186 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9187 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9188 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9189 | public static final int MODE_MEDIUM = 2; |
| 9190 | |
| 9191 | /** |
| 9192 | * Value for {@link #EXTRA_MODE} to show a large-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9193 | * |
| 9194 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9195 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9196 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 9197 | public static final int MODE_LARGE = 3; |
| 9198 | |
| 9199 | /** |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 9200 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate |
| 9201 | * a list of specific MIME-types to exclude and not display. Stored as a |
| 9202 | * {@link String} array. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 9203 | * |
| 9204 | * @hide |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 9205 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 9206 | @Deprecated |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 9207 | public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; |
| 9208 | |
| 9209 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9210 | * Convenience class that contains string constants used |
| 9211 | * to create contact {@link android.content.Intent Intents}. |
| 9212 | */ |
| 9213 | public static final class Insert { |
| 9214 | /** The action code to use when adding a contact */ |
| 9215 | public static final String ACTION = Intent.ACTION_INSERT; |
| 9216 | |
| 9217 | /** |
| 9218 | * If present, forces a bypass of quick insert mode. |
| 9219 | */ |
| 9220 | public static final String FULL_MODE = "full_mode"; |
| 9221 | |
| 9222 | /** |
| 9223 | * The extra field for the contact name. |
| 9224 | * <P>Type: String</P> |
| 9225 | */ |
| 9226 | public static final String NAME = "name"; |
| 9227 | |
| 9228 | // TODO add structured name values here. |
| 9229 | |
| 9230 | /** |
| 9231 | * The extra field for the contact phonetic name. |
| 9232 | * <P>Type: String</P> |
| 9233 | */ |
| 9234 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 9235 | |
| 9236 | /** |
| 9237 | * The extra field for the contact company. |
| 9238 | * <P>Type: String</P> |
| 9239 | */ |
| 9240 | public static final String COMPANY = "company"; |
| 9241 | |
| 9242 | /** |
| 9243 | * The extra field for the contact job title. |
| 9244 | * <P>Type: String</P> |
| 9245 | */ |
| 9246 | public static final String JOB_TITLE = "job_title"; |
| 9247 | |
| 9248 | /** |
| 9249 | * The extra field for the contact notes. |
| 9250 | * <P>Type: String</P> |
| 9251 | */ |
| 9252 | public static final String NOTES = "notes"; |
| 9253 | |
| 9254 | /** |
| 9255 | * The extra field for the contact phone number. |
| 9256 | * <P>Type: String</P> |
| 9257 | */ |
| 9258 | public static final String PHONE = "phone"; |
| 9259 | |
| 9260 | /** |
| 9261 | * The extra field for the contact phone number type. |
| 9262 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9263 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9264 | * or a string specifying a custom label.</P> |
| 9265 | */ |
| 9266 | public static final String PHONE_TYPE = "phone_type"; |
| 9267 | |
| 9268 | /** |
| 9269 | * The extra field for the phone isprimary flag. |
| 9270 | * <P>Type: boolean</P> |
| 9271 | */ |
| 9272 | public static final String PHONE_ISPRIMARY = "phone_isprimary"; |
| 9273 | |
| 9274 | /** |
| 9275 | * The extra field for an optional second contact phone number. |
| 9276 | * <P>Type: String</P> |
| 9277 | */ |
| 9278 | public static final String SECONDARY_PHONE = "secondary_phone"; |
| 9279 | |
| 9280 | /** |
| 9281 | * The extra field for an optional second contact phone number type. |
| 9282 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9283 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9284 | * or a string specifying a custom label.</P> |
| 9285 | */ |
| 9286 | public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; |
| 9287 | |
| 9288 | /** |
| 9289 | * The extra field for an optional third contact phone number. |
| 9290 | * <P>Type: String</P> |
| 9291 | */ |
| 9292 | public static final String TERTIARY_PHONE = "tertiary_phone"; |
| 9293 | |
| 9294 | /** |
| 9295 | * The extra field for an optional third contact phone number type. |
| 9296 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9297 | * {@link CommonDataKinds.Phone}, |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9298 | * or a string specifying a custom label.</P> |
| 9299 | */ |
| 9300 | public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; |
| 9301 | |
| 9302 | /** |
| 9303 | * The extra field for the contact email address. |
| 9304 | * <P>Type: String</P> |
| 9305 | */ |
| 9306 | public static final String EMAIL = "email"; |
| 9307 | |
| 9308 | /** |
| 9309 | * The extra field for the contact email type. |
| 9310 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9311 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9312 | * or a string specifying a custom label.</P> |
| 9313 | */ |
| 9314 | public static final String EMAIL_TYPE = "email_type"; |
| 9315 | |
| 9316 | /** |
| 9317 | * The extra field for the email isprimary flag. |
| 9318 | * <P>Type: boolean</P> |
| 9319 | */ |
| 9320 | public static final String EMAIL_ISPRIMARY = "email_isprimary"; |
| 9321 | |
| 9322 | /** |
| 9323 | * The extra field for an optional second contact email address. |
| 9324 | * <P>Type: String</P> |
| 9325 | */ |
| 9326 | public static final String SECONDARY_EMAIL = "secondary_email"; |
| 9327 | |
| 9328 | /** |
| 9329 | * The extra field for an optional second contact email type. |
| 9330 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9331 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9332 | * or a string specifying a custom label.</P> |
| 9333 | */ |
| 9334 | public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; |
| 9335 | |
| 9336 | /** |
| 9337 | * The extra field for an optional third contact email address. |
| 9338 | * <P>Type: String</P> |
| 9339 | */ |
| 9340 | public static final String TERTIARY_EMAIL = "tertiary_email"; |
| 9341 | |
| 9342 | /** |
| 9343 | * The extra field for an optional third contact email type. |
| 9344 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9345 | * {@link CommonDataKinds.Email} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9346 | * or a string specifying a custom label.</P> |
| 9347 | */ |
| 9348 | public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; |
| 9349 | |
| 9350 | /** |
| 9351 | * The extra field for the contact postal address. |
| 9352 | * <P>Type: String</P> |
| 9353 | */ |
| 9354 | public static final String POSTAL = "postal"; |
| 9355 | |
| 9356 | /** |
| 9357 | * The extra field for the contact postal address type. |
| 9358 | * <P>Type: Either an integer value from |
Dmitri Plotnikov | dbe449e | 2009-11-11 18:48:19 -0800 | [diff] [blame] | 9359 | * {@link CommonDataKinds.StructuredPostal} |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9360 | * or a string specifying a custom label.</P> |
| 9361 | */ |
| 9362 | public static final String POSTAL_TYPE = "postal_type"; |
| 9363 | |
| 9364 | /** |
| 9365 | * The extra field for the postal isprimary flag. |
| 9366 | * <P>Type: boolean</P> |
| 9367 | */ |
| 9368 | public static final String POSTAL_ISPRIMARY = "postal_isprimary"; |
| 9369 | |
| 9370 | /** |
| 9371 | * The extra field for an IM handle. |
| 9372 | * <P>Type: String</P> |
| 9373 | */ |
| 9374 | public static final String IM_HANDLE = "im_handle"; |
| 9375 | |
| 9376 | /** |
| 9377 | * The extra field for the IM protocol |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9378 | */ |
| 9379 | public static final String IM_PROTOCOL = "im_protocol"; |
| 9380 | |
| 9381 | /** |
| 9382 | * The extra field for the IM isprimary flag. |
| 9383 | * <P>Type: boolean</P> |
| 9384 | */ |
| 9385 | public static final String IM_ISPRIMARY = "im_isprimary"; |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 9386 | |
| 9387 | /** |
| 9388 | * The extra field that allows the client to supply multiple rows of |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 9389 | * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT} |
| 9390 | * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of |
| 9391 | * {@link ContentValues}, one per data row. Supplying this extra is |
| 9392 | * similar to inserting multiple rows into the {@link Data} table, |
| 9393 | * except the user gets a chance to see and edit them before saving. |
| 9394 | * Each ContentValues object must have a value for {@link Data#MIMETYPE}. |
| 9395 | * If supplied values are not visible in the editor UI, they will be |
| 9396 | * dropped. Duplicate data will dropped. Some fields |
| 9397 | * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically |
| 9398 | * adjusted to comply with the constraints of the specific account type. |
| 9399 | * For example, an Exchange contact can only have one phone numbers of type Home, |
| 9400 | * so the contact editor may choose a different type for this phone number to |
| 9401 | * avoid dropping the valueable part of the row, which is the phone number. |
| 9402 | * <p> |
| 9403 | * Example: |
| 9404 | * <pre> |
| 9405 | * ArrayList<ContentValues> data = new ArrayList<ContentValues>(); |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 9406 | * |
Dmitri Plotnikov | beb2178 | 2010-10-21 10:02:12 -0700 | [diff] [blame] | 9407 | * ContentValues row1 = new ContentValues(); |
| 9408 | * row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE); |
| 9409 | * row1.put(Organization.COMPANY, "Android"); |
| 9410 | * data.add(row1); |
| 9411 | * |
| 9412 | * ContentValues row2 = new ContentValues(); |
| 9413 | * row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE); |
| 9414 | * row2.put(Email.TYPE, Email.TYPE_CUSTOM); |
| 9415 | * row2.put(Email.LABEL, "Green Bot"); |
| 9416 | * row2.put(Email.ADDRESS, "android@android.com"); |
| 9417 | * data.add(row2); |
| 9418 | * |
| 9419 | * Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); |
| 9420 | * intent.putParcelableArrayListExtra(Insert.DATA, data); |
| 9421 | * |
| 9422 | * startActivity(intent); |
| 9423 | * </pre> |
Dmitri Plotnikov | bb54929 | 2010-10-18 20:37:02 -0700 | [diff] [blame] | 9424 | */ |
| 9425 | public static final String DATA = "data"; |
Daniel Lehmann | cde1ac6 | 2010-10-21 20:40:11 -0700 | [diff] [blame] | 9426 | |
| 9427 | /** |
| 9428 | * Used to specify the account in which to create the new contact. |
| 9429 | * <p> |
| 9430 | * If this value is not provided, the user is presented with a disambiguation |
| 9431 | * dialog to chose an account |
| 9432 | * <p> |
| 9433 | * Type: {@link Account} |
Daniel Lehmann | cde1ac6 | 2010-10-21 20:40:11 -0700 | [diff] [blame] | 9434 | */ |
Brian Attwell | 63f859b | 2015-01-26 15:57:10 -0800 | [diff] [blame] | 9435 | public static final String EXTRA_ACCOUNT = "android.provider.extra.ACCOUNT"; |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 9436 | |
| 9437 | /** |
| 9438 | * Used to specify the data set within the account in which to create the |
| 9439 | * new contact. |
| 9440 | * <p> |
| 9441 | * This value is optional - if it is not specified, the contact will be |
| 9442 | * created in the base account, with no data set. |
| 9443 | * <p> |
| 9444 | * Type: String |
Dave Santoro | 1d55c33 | 2011-07-25 16:44:45 -0700 | [diff] [blame] | 9445 | */ |
Brian Attwell | 63f859b | 2015-01-26 15:57:10 -0800 | [diff] [blame] | 9446 | public static final String EXTRA_DATA_SET = "android.provider.extra.DATA_SET"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 9447 | } |
| 9448 | } |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9449 | |
| 9450 | /** |
| 9451 | * @hide |
| 9452 | */ |
Zheng Fu | 7997bee | 2015-06-09 16:50:02 -0700 | [diff] [blame] | 9453 | @SystemApi |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9454 | protected interface MetadataSyncColumns { |
| 9455 | |
| 9456 | /** |
| 9457 | * The raw contact backup id. |
| 9458 | * A reference to the {@link ContactsContract.RawContacts#BACKUP_ID} that save the |
| 9459 | * persistent unique id for each raw contact within its source system. |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9460 | */ |
| 9461 | public static final String RAW_CONTACT_BACKUP_ID = "raw_contact_backup_id"; |
| 9462 | |
| 9463 | /** |
| 9464 | * The account type to which the raw_contact of this item is associated. See |
| 9465 | * {@link RawContacts#ACCOUNT_TYPE} |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9466 | */ |
| 9467 | public static final String ACCOUNT_TYPE = "account_type"; |
| 9468 | |
| 9469 | /** |
| 9470 | * The account name to which the raw_contact of this item is associated. See |
| 9471 | * {@link RawContacts#ACCOUNT_NAME} |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9472 | */ |
| 9473 | public static final String ACCOUNT_NAME = "account_name"; |
| 9474 | |
| 9475 | /** |
| 9476 | * The data set within the account that the raw_contact of this row belongs to. This allows |
| 9477 | * multiple sync adapters for the same account type to distinguish between |
| 9478 | * each others' data. |
| 9479 | * {@link RawContacts#DATA_SET} |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9480 | */ |
| 9481 | public static final String DATA_SET = "data_set"; |
| 9482 | |
| 9483 | /** |
| 9484 | * A text column contains the Json string got from People API. The Json string contains |
| 9485 | * all the metadata related to the raw contact, i.e., all the data fields and |
| 9486 | * aggregation exceptions. |
| 9487 | * |
| 9488 | * Here is an example of the Json string got from the actual schema. |
| 9489 | * <pre> |
| 9490 | * { |
| 9491 | * "unique_contact_id": { |
| 9492 | * "account_type": "CUSTOM_ACCOUNT", |
| 9493 | * "custom_account_type": "facebook", |
| 9494 | * "account_name": "android-test", |
| 9495 | * "contact_id": "1111111", |
| 9496 | * "data_set": "FOCUS" |
| 9497 | * }, |
| 9498 | * "contact_prefs": { |
| 9499 | * "send_to_voicemail": true, |
| 9500 | * "starred": false, |
| 9501 | * "pinned": 2 |
| 9502 | * }, |
| 9503 | * "aggregation_data": [ |
| 9504 | * { |
| 9505 | * "type": "TOGETHER", |
| 9506 | * "contact_ids": [ |
| 9507 | * { |
| 9508 | * "account_type": "GOOGLE_ACCOUNT", |
| 9509 | * "account_name": "android-test2", |
| 9510 | * "contact_id": "2222222", |
| 9511 | * "data_set": "GOOGLE_PLUS" |
| 9512 | * }, |
| 9513 | * { |
| 9514 | * "account_type": "GOOGLE_ACCOUNT", |
| 9515 | * "account_name": "android-test3", |
| 9516 | * "contact_id": "3333333", |
| 9517 | * "data_set": "CUSTOM", |
| 9518 | * "custom_data_set": "custom type" |
| 9519 | * } |
| 9520 | * ] |
| 9521 | * } |
| 9522 | * ], |
| 9523 | * "field_data": [ |
| 9524 | * { |
| 9525 | * "field_data_id": "1001", |
| 9526 | * "field_data_prefs": { |
| 9527 | * "is_primary": true, |
| 9528 | * "is_super_primary": true |
| 9529 | * }, |
| 9530 | * "usage_stats": [ |
| 9531 | * { |
| 9532 | * "usage_type": "CALL", |
| 9533 | * "last_time_used": 10000001, |
| 9534 | * "usage_count": 10 |
| 9535 | * } |
| 9536 | * ] |
| 9537 | * } |
| 9538 | * ] |
| 9539 | * } |
| 9540 | * </pre> |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9541 | */ |
| 9542 | public static final String DATA = "data"; |
| 9543 | |
| 9544 | /** |
| 9545 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 9546 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 9547 | * called on a raw contact, updating MetadataSync table to set the flag of the raw contact |
| 9548 | * as "1", then metadata sync adapter deletes the raw contact metadata on the server. |
| 9549 | * <P>Type: INTEGER</P> |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9550 | */ |
| 9551 | public static final String DELETED = "deleted"; |
| 9552 | } |
| 9553 | |
| 9554 | /** |
| 9555 | * Constants for the metadata sync table. This table is used to cache the metadata_sync data |
| 9556 | * from server before it is merged into other CP2 tables. |
| 9557 | * |
| 9558 | * @hide |
| 9559 | */ |
Zheng Fu | 7997bee | 2015-06-09 16:50:02 -0700 | [diff] [blame] | 9560 | @SystemApi |
Tingting Wang | 20f1438 | 2015-04-21 12:04:04 -0700 | [diff] [blame] | 9561 | public static final class MetadataSync implements BaseColumns, MetadataSyncColumns { |
| 9562 | |
| 9563 | /** The authority for the contacts metadata */ |
| 9564 | public static final String METADATA_AUTHORITY = "com.android.contacts.metadata"; |
| 9565 | |
| 9566 | /** A content:// style uri to the authority for the contacts metadata */ |
| 9567 | public static final Uri METADATA_AUTHORITY_URI = Uri.parse( |
| 9568 | "content://" + METADATA_AUTHORITY); |
| 9569 | |
| 9570 | /** |
| 9571 | * This utility class cannot be instantiated |
| 9572 | */ |
| 9573 | private MetadataSync() { |
| 9574 | } |
| 9575 | |
| 9576 | /** |
| 9577 | * The content:// style URI for this table. |
| 9578 | */ |
| 9579 | public static final Uri CONTENT_URI = Uri.withAppendedPath(METADATA_AUTHORITY_URI, |
| 9580 | "metadata_sync"); |
Zheng Fu | c37ba12 | 2015-04-23 16:46:45 -0700 | [diff] [blame] | 9581 | |
| 9582 | /** |
| 9583 | * The MIME type of {@link #CONTENT_URI} providing a directory of contact metadata |
| 9584 | */ |
| 9585 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact_metadata"; |
| 9586 | |
| 9587 | /** |
| 9588 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single contact metadata. |
| 9589 | */ |
| 9590 | 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] | 9591 | } |
Zheng Fu | ae678b8 | 2015-08-07 13:28:50 -0700 | [diff] [blame] | 9592 | |
| 9593 | /** |
| 9594 | * @hide |
| 9595 | */ |
| 9596 | @SystemApi |
| 9597 | protected interface MetadataSyncStateColumns { |
| 9598 | |
| 9599 | /** |
| 9600 | * A reference to the name of the account to which this state belongs |
| 9601 | * <P>Type: STRING</P> |
| 9602 | */ |
| 9603 | public static final String ACCOUNT_TYPE = "account_type"; |
| 9604 | |
| 9605 | /** |
| 9606 | * A reference to the type of the account to which this state belongs |
| 9607 | * <P>Type: STRING</P> |
| 9608 | */ |
| 9609 | public static final String ACCOUNT_NAME = "account_name"; |
| 9610 | |
| 9611 | /** |
| 9612 | * A reference to the data set within the account to which this state belongs |
| 9613 | * <P>Type: STRING</P> |
| 9614 | */ |
| 9615 | public static final String DATA_SET = "data_set"; |
| 9616 | |
| 9617 | /** |
| 9618 | * The sync state associated with this account. |
| 9619 | * <P>Type: Blob</P> |
| 9620 | */ |
| 9621 | public static final String STATE = "state"; |
| 9622 | } |
| 9623 | |
| 9624 | /** |
| 9625 | * Constants for the metadata_sync_state table. This table is used to store the metadata |
| 9626 | * sync state for a set of accounts. |
| 9627 | * |
| 9628 | * @hide |
| 9629 | */ |
| 9630 | @SystemApi |
| 9631 | public static final class MetadataSyncState implements BaseColumns, MetadataSyncStateColumns { |
| 9632 | |
| 9633 | /** |
| 9634 | * This utility class cannot be instantiated |
| 9635 | */ |
| 9636 | private MetadataSyncState() { |
| 9637 | } |
| 9638 | |
| 9639 | /** |
| 9640 | * The content:// style URI for this table. |
| 9641 | */ |
| 9642 | public static final Uri CONTENT_URI = |
| 9643 | Uri.withAppendedPath(MetadataSync.METADATA_AUTHORITY_URI, "metadata_sync_state"); |
| 9644 | |
| 9645 | /** |
| 9646 | * The MIME type of {@link #CONTENT_URI} providing a directory of contact metadata sync |
| 9647 | * states. |
| 9648 | */ |
| 9649 | public static final String CONTENT_TYPE = |
| 9650 | "vnd.android.cursor.dir/contact_metadata_sync_state"; |
| 9651 | |
| 9652 | /** |
| 9653 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single contact metadata sync |
| 9654 | * state. |
| 9655 | */ |
| 9656 | public static final String CONTENT_ITEM_TYPE = |
| 9657 | "vnd.android.cursor.item/contact_metadata_sync_state"; |
| 9658 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 9659 | } |